Comparing version 2.1.16 to 2.1.17
@@ -12,4 +12,4 @@ import { EventEmitter } from "events"; | ||
load(dataname: string): Promise<AdapterResults>; | ||
findCollection(dataname: string, check?: 'startsWith' | 'endsWith' | 'normal'): Promise<AdapterResults>; | ||
updateCollection(dataname: string, newDataname: string): Promise<AdapterResults>; | ||
private loadSecureData; | ||
private loadPlainData; | ||
add(dataname: string, newData: any, options?: AdapterUniqueKey): Promise<AdapterResults>; | ||
@@ -16,0 +16,0 @@ private index; |
@@ -14,10 +14,20 @@ import { EventEmitter } from "events"; | ||
loadData(fileName: string, schema: SQLSchema, loadedContent?: string): Promise<AdapterResults>; | ||
findCollection(dataname: string, check?: 'startsWith' | 'endsWith' | 'normal'): Promise<AdapterResults>; | ||
updateCollection(dataname: string, newDataname: string): Promise<AdapterResults>; | ||
createTable(filePath: string, schema: SQLSchema): Promise<AdapterResults>; | ||
insertData(filename: string, { schema, dataArray }: { | ||
schema: SQLSchema; | ||
dataArray: any[]; | ||
dataArray: any; | ||
}): Promise<AdapterResults>; | ||
selectData(filePath: string, { query, schema, loadedData }: FindQuery, options?: any): Promise<AdapterResults>; | ||
/** | ||
* Rename a table in an SQL file with case-sensitive matching. | ||
* @param {string} filePath - Path to the SQL file. | ||
* @param {string} oldTableName - The current name of the table to rename. | ||
* @param {string} newTableName - The new name for the table. | ||
*/ | ||
renameTable(filePath: string, oldTableName: string, newTableName: string): Promise<AdapterResults>; | ||
selectData(dataname: string, { query, schema, loadedData, options }: { | ||
query: any; | ||
schema: SQLSchema; | ||
loadedData?: any[]; | ||
options?: any; | ||
}): Promise<any>; | ||
selectAll(filePath: string, { query, schema, loadedData }: FindQuery): Promise<AdapterResults>; | ||
@@ -24,0 +34,0 @@ removeData(filePath: string, { query, schema, docCount, loadedData }: { |
@@ -12,2 +12,4 @@ import { EventEmitter } from "events"; | ||
load(dataname: string): Promise<AdapterResults>; | ||
private loadSecureData; | ||
private loadPlainData; | ||
findCollection(dataname: string, check?: 'startsWith' | 'endsWith' | 'normal'): Promise<AdapterResults>; | ||
@@ -14,0 +16,0 @@ updateCollection(dataname: string, newDataname: string): Promise<AdapterResults>; |
@@ -1,3 +0,3 @@ | ||
import { AdapterOptions, BackupOptions, SecureSystem, DevLogsOptions, CollectionFilter, operationKeys, QueryOptions, JoinSQL, StructureMethods, ModelMethods } from "../types/connect"; | ||
import { MigrationPath, nearbyOptions, TableOptions } from "../types/adapter"; | ||
import { AdapterOptions, BackupOptions, SecureSystem, DevLogsOptions, CollectionFilter, operationKeys, QueryOptions, JoinSQL, StructureMethods, ModelMethods, ListCollectionOptions } from "../types/connect"; | ||
import { AdapterResults, MigrationPath, nearbyOptions, TableOptions } from "../types/adapter"; | ||
import Schema from "./functions/schema"; | ||
@@ -24,2 +24,9 @@ import { jsonAdapter, yamlAdapter, sqlAdapter } from "../adapters/export"; | ||
constructor(options: AdapterOptions); | ||
listCollections(options: ListCollectionOptions): Promise<AdapterResults>; | ||
listContainers(options: ListCollectionOptions): Promise<AdapterResults>; | ||
findCollection(dataname: string, check?: 'startsWith' | 'endsWith' | 'normal' | 'regex', regexPattern?: RegExp): Promise<AdapterResults>; | ||
findContainer(containerName: string, check?: 'startsWith' | 'endsWith' | 'normal' | 'regex', regexPattern?: RegExp): Promise<AdapterResults>; | ||
updateCollection(dataname: string, newDataname: string): Promise<AdapterResults>; | ||
updateContainer(containerName: string, newContainerName: string): Promise<AdapterResults>; | ||
dropContainer(containerName: string, options: ListCollectionOptions): Promise<AdapterResults>; | ||
/** | ||
@@ -30,5 +37,3 @@ * Load data from a file | ||
*/ | ||
load(dataname: string): Promise<import("../types/adapter").AdapterResults | undefined>; | ||
findCollection(dataname: string, check: 'startsWith' | 'endsWith' | 'normal'): Promise<import("../types/adapter").AdapterResults | undefined>; | ||
updateCollection(dataname: string, newDataName: string): Promise<import("../types/adapter").AdapterResults | undefined>; | ||
load(dataname: string): Promise<AdapterResults | undefined>; | ||
/** | ||
@@ -47,3 +52,3 @@ * Watch a data file for realtime database | ||
*/ | ||
add(dataname: string, newData: any, options?: any): Promise<import("../types/adapter").AdapterResults | undefined>; | ||
add(dataname: string, newData: any, options?: any): Promise<AdapterResults | undefined>; | ||
/** | ||
@@ -61,3 +66,3 @@ * @param dataname the data file name | ||
*/ | ||
loadAll(dataname: string, displayOptions: any, loadedData?: any[]): Promise<import("../types/adapter").AdapterResults | undefined>; | ||
loadAll(dataname: string, displayOptions: any, loadedData?: any[]): Promise<AdapterResults | undefined>; | ||
/** | ||
@@ -69,3 +74,3 @@ * | ||
*/ | ||
aggregate(dataname: string, pipeline: any[]): Promise<import("../types/adapter").AdapterResults | undefined>; | ||
aggregate(dataname: string, pipeline: any[]): Promise<AdapterResults | undefined>; | ||
/** | ||
@@ -76,3 +81,3 @@ * | ||
*/ | ||
batchTasks(operations: any[]): Promise<import("../types/adapter").AdapterResults | undefined>; | ||
batchTasks(operations: any[]): Promise<AdapterResults | undefined>; | ||
/** | ||
@@ -88,3 +93,3 @@ * Remove data from the database. | ||
docCount: number; | ||
}): Promise<import("../types/adapter").AdapterResults | undefined>; | ||
}): Promise<AdapterResults | undefined>; | ||
/** | ||
@@ -98,3 +103,3 @@ * edit functions for the data in the database | ||
*/ | ||
update(dataname: string, query: any, newData: operationKeys, upsert?: boolean, loadedData?: any[]): Promise<import("../types/adapter").AdapterResults | undefined>; | ||
update(dataname: string, query: any, newData: operationKeys, upsert?: boolean, loadedData?: any[]): Promise<AdapterResults | undefined>; | ||
/** | ||
@@ -104,3 +109,3 @@ * @param dataname the name of the data you want to drop | ||
*/ | ||
drop(dataname: string): Promise<void>; | ||
dropCollection(dataname: string): Promise<AdapterResults | undefined>; | ||
/** | ||
@@ -111,3 +116,3 @@ * full search method to find in all the database | ||
*/ | ||
search(collectionFilters: CollectionFilter[]): Promise<import("../types/adapter").AdapterResults | undefined>; | ||
search(collectionFilters: CollectionFilter[]): Promise<AdapterResults | undefined>; | ||
/** | ||
@@ -140,3 +145,3 @@ * Get nearby vectors from the database. | ||
*/ | ||
updateMany(dataname: string, queries: any, newData: operationKeys): Promise<import("../types/adapter").AdapterResults | undefined>; | ||
updateMany(dataname: string, queries: any, newData: operationKeys): Promise<AdapterResults | undefined>; | ||
/** | ||
@@ -148,3 +153,3 @@ * a function to count the data documents in the database (Note*: this is only supported for SQL adapter) | ||
*/ | ||
countDoc(dataname: string): Promise<import("../types/adapter").AdapterResults | undefined>; | ||
countDoc(dataname: string): Promise<AdapterResults | undefined>; | ||
/** | ||
@@ -155,3 +160,3 @@ * a function to give you the size of the database (Note*: this is only supported for SQL adapter) | ||
*/ | ||
dataSize(dataname: string): Promise<import("../types/adapter").AdapterResults | undefined>; | ||
dataSize(dataname: string): Promise<AdapterResults | undefined>; | ||
/** | ||
@@ -172,3 +177,3 @@ * Define a model for interacting with the database. | ||
*/ | ||
loadData(dataname: string, schema: SQLSchema): Promise<import("../types/adapter").AdapterResults>; | ||
loadData(dataname: string, schema: SQLSchema, loadedData?: string): Promise<AdapterResults>; | ||
/** | ||
@@ -182,3 +187,4 @@ * Creates a table in the database using the specified schema. | ||
*/ | ||
createTable(dataname: string, schema: SQLSchema): Promise<import("../types/adapter").AdapterResults>; | ||
createTable(dataname: string, schema: SQLSchema): Promise<AdapterResults>; | ||
renameTable(dataname: string, oldTableName: string, newTableName: string): Promise<AdapterResults>; | ||
/** | ||
@@ -190,3 +196,3 @@ * Inserts data into a file using the specified schema. | ||
* @param {SQLSchema} data.schema - The schema to use for inserting data. | ||
* @param {any[]} data.dataArray - The array of data to insert. | ||
* @param {any} data.dataArray - The array of data to insert. | ||
* @returns {Promise<any>} - The result of the data insertion. | ||
@@ -197,3 +203,3 @@ * @throws {Error} - If the database is not connected or the operation is not supported. | ||
schema: SQLSchema; | ||
dataArray: any[]; | ||
dataArray: any; | ||
}): Promise<any>; | ||
@@ -200,0 +206,0 @@ /** |
@@ -0,1 +1,2 @@ | ||
import { ListCollectionOptions } from '../../types/connect'; | ||
export declare const opSet: (doc: any, update: any) => void; | ||
@@ -17,2 +18,4 @@ export declare const opUnset: (doc: any, update: any) => void; | ||
export declare function isEqual(a: any, b: any): boolean; | ||
export declare function listFiles(directory: string, options: ListCollectionOptions): string[]; | ||
export declare function listContainer(directory: string, options: ListCollectionOptions): string[]; | ||
//# sourceMappingURL=operations.d.ts.map |
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.opSort = exports.opSlice = exports.opCurrentDate = exports.opPop = exports.opBit = exports.opInc = exports.opMul = exports.opMax = exports.opMin = exports.opAddToSet = exports.opRename = exports.opPull = exports.opPush = exports.opUnset = exports.opSet = void 0; | ||
exports.isEqual = isEqual; | ||
exports.listFiles = listFiles; | ||
exports.listContainer = listContainer; | ||
const fs_1 = __importDefault(require("fs")); | ||
const path_1 = __importDefault(require("path")); | ||
const opSet = (doc, update) => { | ||
@@ -863,2 +870,183 @@ for (const key in update) { | ||
} | ||
function listFiles(directory, options) { | ||
let results = []; | ||
const { type = [], recursive = false, size, date, sort, projection, regex } = options; | ||
const files = fs_1.default.readdirSync(directory); | ||
for (const file of files) { | ||
const fullPath = path_1.default.join(directory, file); | ||
const stat = fs_1.default.statSync(fullPath); | ||
if (regex) { | ||
if (regex.include && !regex.include.some(pattern => new RegExp(pattern).test(file))) { | ||
continue; | ||
} | ||
if (regex.exclude && regex.exclude.some(pattern => new RegExp(pattern).test(file))) { | ||
continue; | ||
} | ||
} | ||
const fileExt = path_1.default.extname(file).substring(1); | ||
if (type.length > 0 && !type.includes(fileExt)) { | ||
continue; | ||
} | ||
if (size) { | ||
if (size.minSize !== undefined && stat.size < size.minSize) { | ||
continue; | ||
} | ||
if (size.maxSize !== undefined && stat.size > size.maxSize) { | ||
continue; | ||
} | ||
} | ||
if (date) { | ||
if (date.modify) { | ||
if (date.modify.after && stat.mtime < date.modify.after) { | ||
continue; | ||
} | ||
if (date.modify.before && stat.mtime > date.modify.before) { | ||
continue; | ||
} | ||
} | ||
if (date.created) { | ||
if (date.created.after && stat.birthtime < date.created.after) { | ||
continue; | ||
} | ||
if (date.created.before && stat.birthtime > date.created.before) { | ||
continue; | ||
} | ||
} | ||
} | ||
if (stat.isDirectory() && recursive) { | ||
results = results.concat(listFiles(fullPath, options)); | ||
} | ||
else if (stat.isFile()) { | ||
results.push(fullPath); | ||
} | ||
} | ||
if (sort) { | ||
results.sort((a, b) => { | ||
const statA = fs_1.default.statSync(a); | ||
const statB = fs_1.default.statSync(b); | ||
let compare = 0; | ||
if (sort.by === 'name') { | ||
compare = a.localeCompare(b); | ||
} | ||
else if (sort.by === 'size') { | ||
compare = statA.size - statB.size; | ||
} | ||
else if (sort.by === 'dateModified') { | ||
compare = statA.mtime.getTime() - statB.mtime.getTime(); | ||
} | ||
else if (sort.by === 'dateCreated') { | ||
compare = statA.birthtime.getTime() - statB.birthtime.getTime(); | ||
} | ||
return sort.order === 'asc' ? compare : -compare; | ||
}); | ||
} | ||
if (projection) { | ||
const { limit, offset } = projection; | ||
if (offset) { | ||
results = results.slice(offset); | ||
} | ||
if (limit) { | ||
results = results.slice(0, limit); | ||
} | ||
} | ||
return results; | ||
} | ||
function listContainer(directory, options) { | ||
let results = []; | ||
const { recursive = false, size, date, sort, projection, regex } = options; | ||
const items = fs_1.default.readdirSync(directory); | ||
for (const item of items) { | ||
const fullPath = path_1.default.join(directory, item); | ||
const stat = fs_1.default.statSync(fullPath); | ||
if (!stat.isDirectory()) { | ||
continue; | ||
} | ||
if (regex) { | ||
if (regex.include && !regex.include.some(pattern => new RegExp(pattern).test(item))) { | ||
continue; | ||
} | ||
if (regex.exclude && regex.exclude.some(pattern => new RegExp(pattern).test(item))) { | ||
continue; | ||
} | ||
} | ||
if (size) { | ||
const dirSize = direSize(fullPath); | ||
if (size.minSize !== undefined && dirSize < size.minSize) { | ||
continue; | ||
} | ||
if (size.maxSize !== undefined && dirSize > size.maxSize) { | ||
continue; | ||
} | ||
} | ||
if (date) { | ||
if (date.modify) { | ||
if (date.modify.after && stat.mtime < date.modify.after) { | ||
continue; | ||
} | ||
if (date.modify.before && stat.mtime > date.modify.before) { | ||
continue; | ||
} | ||
} | ||
if (date.created) { | ||
if (date.created.after && stat.birthtime < date.created.after) { | ||
continue; | ||
} | ||
if (date.created.before && stat.birthtime > date.created.before) { | ||
continue; | ||
} | ||
} | ||
} | ||
results.push(fullPath); | ||
if (recursive) { | ||
results = results.concat(listContainer(fullPath, options)); | ||
} | ||
} | ||
if (sort) { | ||
results.sort((a, b) => { | ||
const statA = fs_1.default.statSync(a); | ||
const statB = fs_1.default.statSync(b); | ||
let compare = 0; | ||
if (sort.by === 'name') { | ||
compare = a.localeCompare(b); | ||
} | ||
else if (sort.by === 'size') { | ||
const sizeA = direSize(a); | ||
const sizeB = direSize(b); | ||
compare = sizeA - sizeB; | ||
} | ||
else if (sort.by === 'dateModified') { | ||
compare = statA.mtime.getTime() - statB.mtime.getTime(); | ||
} | ||
else if (sort.by === 'dateCreated') { | ||
compare = statA.birthtime.getTime() - statB.birthtime.getTime(); | ||
} | ||
return sort.order === 'asc' ? compare : -compare; | ||
}); | ||
} | ||
if (projection) { | ||
const { limit, offset } = projection; | ||
if (offset) { | ||
results = results.slice(offset); | ||
} | ||
if (limit) { | ||
results = results.slice(0, limit); | ||
} | ||
} | ||
return results; | ||
} | ||
function direSize(directory) { | ||
let totalSize = 0; | ||
const files = fs_1.default.readdirSync(directory); | ||
for (const file of files) { | ||
const fullPath = path_1.default.join(directory, file); | ||
const stat = fs_1.default.statSync(fullPath); | ||
if (stat.isDirectory()) { | ||
totalSize += direSize(fullPath); | ||
} | ||
else { | ||
totalSize += stat.size; | ||
} | ||
} | ||
return totalSize; | ||
} | ||
//# sourceMappingURL=operations.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.SQLSchema = void 0; | ||
// sql-schema.ts | ||
const sql_types_1 = require("../../types/sql-types"); | ||
const SQL_functions_1 = require("./SQL-functions"); | ||
class SQLSchema { | ||
@@ -10,29 +13,26 @@ constructor(tableName, schemaDefinition) { | ||
validateArrayOrJSON(field, value, existingData = []) { | ||
var _a, _b; | ||
if (field.type === 'ARRAY' && ((_a = field.validation) === null || _a === void 0 ? void 0 : _a.arrayLength)) { | ||
var _a, _b, _c, _d; | ||
const normalizedType = (0, SQL_functions_1.normalizeSQLType)(field.type); | ||
// Handle arrays | ||
if (normalizedType === sql_types_1.SQLTypes.ARRAY && Array.isArray(value)) { | ||
const length = value.length; | ||
if (field.validation.arrayLength.min !== undefined && length < field.validation.arrayLength.min) { | ||
if (((_b = (_a = field.validation) === null || _a === void 0 ? void 0 : _a.arrayLength) === null || _b === void 0 ? void 0 : _b.min) !== undefined && length < field.validation.arrayLength.min) { | ||
throw new Error(`Array length for field must be at least ${field.validation.arrayLength.min}.`); | ||
} | ||
if (field.validation.arrayLength.max !== undefined && length > field.validation.arrayLength.max) { | ||
if (((_d = (_c = field.validation) === null || _c === void 0 ? void 0 : _c.arrayLength) === null || _d === void 0 ? void 0 : _d.max) !== undefined && length > field.validation.arrayLength.max) { | ||
throw new Error(`Array length for field must be no more than ${field.validation.arrayLength.max}.`); | ||
} | ||
value.forEach((item) => { | ||
this.validateField('', item, existingData, field); | ||
}); | ||
} | ||
if (field.type === 'JSON' && ((_b = field.validation) === null || _b === void 0 ? void 0 : _b.arrayLength)) { | ||
const length = value.length; | ||
if (field.validation.arrayLength.min !== undefined && length < field.validation.arrayLength.min) { | ||
throw new Error(`Array length for field must be at least ${field.validation.arrayLength.min}.`); | ||
// Handle JSON objects | ||
else if (normalizedType === sql_types_1.SQLTypes.JSON && typeof value === 'object' && !Array.isArray(value)) { | ||
for (const key in value) { | ||
const fieldSchema = field.schema ? field.schema[key] : undefined; | ||
if (fieldSchema) { | ||
this.validateField(key, value[key], existingData, fieldSchema); | ||
} | ||
} | ||
if (field.validation.arrayLength.max !== undefined && length > field.validation.arrayLength.max) { | ||
throw new Error(`Array length for field must be no more than ${field.validation.arrayLength.max}.`); | ||
} | ||
} | ||
if (field.schema) { | ||
value.forEach((item) => { | ||
for (const subFieldName in field.schema) { | ||
const subField = field.schema[subFieldName]; | ||
this.validateField(subFieldName, item[subFieldName], existingData, subField); | ||
} | ||
}); | ||
} | ||
} | ||
@@ -64,4 +64,4 @@ validateField(fieldName, fieldValue, existingData = [], fieldSchema) { | ||
} | ||
const fieldType = field.type.toUpperCase(); | ||
if (['VARCHAR', 'CHAR', 'TEXT', 'UUID'].includes(fieldType) && ((_d = field.validation) === null || _d === void 0 ? void 0 : _d.length)) { | ||
const normalizedType = (0, SQL_functions_1.normalizeSQLType)(field.type); | ||
if (['VARCHAR', 'CHAR', 'TEXT', 'UUID'].includes(normalizedType) && ((_d = field.validation) === null || _d === void 0 ? void 0 : _d.length)) { | ||
const length = fieldValue ? fieldValue.length : 0; | ||
@@ -75,3 +75,3 @@ if (field.validation.length.min !== undefined && length < field.validation.length.min) { | ||
} | ||
if (['INTEGER', 'DECIMAL'].includes(fieldType) && ((_e = field.validation) === null || _e === void 0 ? void 0 : _e.range)) { | ||
if (['INTEGER', 'DECIMAL'].includes(normalizedType) && ((_e = field.validation) === null || _e === void 0 ? void 0 : _e.range)) { | ||
if (field.validation.range.min !== undefined && fieldValue < field.validation.range.min) { | ||
@@ -87,3 +87,3 @@ throw new Error(`Field ${fieldName} must be at least ${field.validation.range.min}.`); | ||
} | ||
if (field.type === 'ARRAY' || field.type === 'JSON') { | ||
if (normalizedType === sql_types_1.SQLTypes.ARRAY || normalizedType === sql_types_1.SQLTypes.JSON) { | ||
this.validateArrayOrJSON(field, fieldValue, existingData); | ||
@@ -90,0 +90,0 @@ } |
@@ -10,2 +10,3 @@ import { encodeJSON, decodeJSON, encodeYAML, decodeYAML, encodeSQL, decodeSQL, neutralizer, genObjectId } from "./core/functions/secureData"; | ||
import { SQLSchema } from "./core/functions/SQL-Schemas"; | ||
import { SQLTypes, SchemaDefinition } from "./types/sql-types"; | ||
declare const logger: { | ||
@@ -83,5 +84,6 @@ logError: typeof logError; | ||
SQLSchema: typeof SQLSchema; | ||
SQLTypes: typeof SQLTypes; | ||
}; | ||
export { connect, randomID, randomUUID, logger, Schema, verseParser, SchemaTypes, colors, neutralizer, genObjectId, verseConnector, verseManagers, SQLSchema }; | ||
export { connect, randomID, randomUUID, logger, Schema, verseParser, SchemaTypes, colors, neutralizer, genObjectId, verseConnector, verseManagers, SQLSchema, SQLTypes, SchemaDefinition }; | ||
export default versedb; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -29,5 +29,5 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.SQLSchema = exports.genObjectId = exports.neutralizer = exports.colors = exports.SchemaTypes = exports.verseParser = exports.Schema = exports.logger = exports.randomUUID = exports.randomID = exports.connect = void 0; | ||
exports.SQLTypes = exports.SQLSchema = exports.genObjectId = exports.neutralizer = exports.colors = exports.SchemaTypes = exports.verseParser = exports.Schema = exports.logger = exports.randomUUID = exports.randomID = exports.connect = void 0; | ||
/** | ||
* @params Copyright(c) 2023 marco5dev & elias79 & kmoshax | ||
* @params Copyright(c) 2023 marco5dev & jedi.tsx & kmoshax | ||
* MIT Licensed | ||
@@ -54,2 +54,4 @@ */ | ||
Object.defineProperty(exports, "SQLSchema", { enumerable: true, get: function () { return SQL_Schemas_1.SQLSchema; } }); | ||
const sql_types_1 = require("./types/sql-types"); | ||
Object.defineProperty(exports, "SQLTypes", { enumerable: true, get: function () { return sql_types_1.SQLTypes; } }); | ||
const packageJsonPath = path.resolve(process.cwd(), "package.json"); | ||
@@ -101,3 +103,3 @@ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8")); | ||
neutralizer: secureData_1.neutralizer, | ||
genObjectId: secureData_1.genObjectId | ||
genObjectId: secureData_1.genObjectId, | ||
}; | ||
@@ -116,5 +118,6 @@ exports.verseParser = verseParser; | ||
genObjectId: secureData_1.genObjectId, | ||
SQLSchema: SQL_Schemas_1.SQLSchema | ||
SQLSchema: SQL_Schemas_1.SQLSchema, | ||
SQLTypes: sql_types_1.SQLTypes, | ||
}; | ||
exports.default = versedb; | ||
//# sourceMappingURL=index.js.map |
@@ -46,4 +46,2 @@ import { FindQuery } from "./sql-types"; | ||
load(dataname: string): Promise<AdapterResults>; | ||
findCollection(dataname: string): Promise<AdapterResults>; | ||
updateCollection(dataname: string, newDataName: string): Promise<AdapterResults>; | ||
add(dataname: string, newData: any, options?: AdapterUniqueKey): Promise<AdapterResults>; | ||
@@ -70,9 +68,8 @@ find(dataname: string, query: any, options?: any, loadedData?: any[]): Promise<AdapterResults>; | ||
export interface SQLAdapter { | ||
loadData(dataname: string, schema: SQLSchema): Promise<AdapterResults>; | ||
findCollection(dataname: string): Promise<AdapterResults>; | ||
updateCollection(dataname: string, newDataName: string): Promise<AdapterResults>; | ||
loadData(dataname: string, schema: SQLSchema, loadedData?: string): Promise<AdapterResults>; | ||
createTable(dataname: string, schema: SQLSchema): Promise<AdapterResults>; | ||
renameTable(dataname: string, oldTableName: string, newTableName: string): Promise<AdapterResults>; | ||
insertData(filename: string, { schema, dataArray }: { | ||
schema: SQLSchema; | ||
dataArray: any[]; | ||
dataArray: any; | ||
}): Promise<AdapterResults>; | ||
@@ -79,0 +76,0 @@ selectData(filePath: string, { query, schema, loadedData }: FindQuery, options: any): Promise<AdapterResults>; |
import { FindQuery } from "./sql-types"; | ||
import { SQLSchema } from "../core/functions/SQL-Schemas"; | ||
import { MigrationPath, TableOptions } from "./adapter"; | ||
import { AdapterResults, MigrationPath, TableOptions } from "./adapter"; | ||
import { jsonAdapter } from "../adapters/json.adapter"; | ||
@@ -57,9 +57,10 @@ import { yamlAdapter } from "../adapters/yaml.adapter"; | ||
export interface SQLAdapter { | ||
loadData(dataname: string, schema: SQLSchema): Promise<void>; | ||
loadData(dataname: string, schema: SQLSchema, loadedData?: string): Promise<void>; | ||
findCollection(dataname: string): Promise<void>; | ||
updateCollection(dataname: string, newDataName: string): Promise<void>; | ||
createTable(dataname: string, schema: SQLSchema): Promise<void>; | ||
renameTable(dataname: string, oldTableName: string, newTableName: string): Promise<void>; | ||
insertData(filename: string, { schema, dataArray }: { | ||
schema: SQLSchema; | ||
dataArray: any[]; | ||
dataArray: any; | ||
}): Promise<void>; | ||
@@ -250,13 +251,18 @@ selectData(filePath: string, { query, schema, loadedData }: FindQuery, options: any): Promise<void>; | ||
export interface StructureMethods { | ||
loadData(): Promise<any>; | ||
createTable(): Promise<any>; | ||
insertData(data: any[]): Promise<any>; | ||
loadData(loadedData?: string): Promise<AdapterResults>; | ||
createTable(): Promise<AdapterResults>; | ||
listCollection(options: ListCollectionOptions): Promise<AdapterResults>; | ||
findCollection(check?: 'startsWith' | 'endsWith' | 'normal'): Promise<AdapterResults>; | ||
updateCollection(newDataName: string): Promise<AdapterResults>; | ||
dropCollection(): Promise<any>; | ||
renameTable(oldTableName: string, newTableName: string): Promise<AdapterResults>; | ||
insertData(data: any[]): Promise<AdapterResults>; | ||
selectData(params: { | ||
query: any; | ||
loadedData?: any[]; | ||
}): Promise<any>; | ||
}): Promise<AdapterResults>; | ||
selectAll(params: { | ||
query: any; | ||
loadedData?: any[]; | ||
}): Promise<any>; | ||
}): Promise<AdapterResults>; | ||
removeData(params: { | ||
@@ -266,3 +272,3 @@ query: any; | ||
docCount: number; | ||
}): Promise<any>; | ||
}): Promise<AdapterResults>; | ||
updateData(params1: { | ||
@@ -274,3 +280,3 @@ query: any; | ||
upsert?: boolean; | ||
}): Promise<any>; | ||
}): Promise<AdapterResults>; | ||
batchUpdate(params1: { | ||
@@ -281,11 +287,11 @@ query: any; | ||
updateQuery: operationKeys; | ||
}): Promise<any>; | ||
countTables(): Promise<any>; | ||
docsCount(): Promise<any>; | ||
}): Promise<AdapterResults>; | ||
countTables(): Promise<AdapterResults>; | ||
docsCount(): Promise<AdapterResults>; | ||
batchTasks(operations: any[]): Promise<any>; | ||
toJSON(tableName?: string): Promise<any>; | ||
join(collectionFilters: JoinSQL[]): Promise<any>; | ||
tableNames(filePath: string): Promise<any>; | ||
migrateData({ from, to }: MigrationPath, { fromTable, toTable, query }: TableOptions): Promise<any>; | ||
aggregateData(pipeline: any[]): Promise<any>; | ||
toJSON(tableName?: string): Promise<AdapterResults>; | ||
join(collectionFilters: JoinSQL[]): Promise<AdapterResults>; | ||
tableNames(filePath: string): Promise<AdapterResults>; | ||
migrateData({ from, to }: MigrationPath, { fromTable, toTable, query }: TableOptions): Promise<AdapterResults>; | ||
aggregateData(pipeline: any[]): Promise<AdapterResults>; | ||
dataSize(): Promise<any>; | ||
@@ -295,2 +301,5 @@ watch(): Promise<any>; | ||
export interface ModelMethods { | ||
listCollection(options: ListCollectionOptions): Promise<AdapterResults>; | ||
findCollection(check?: 'startsWith' | 'endsWith' | 'normal'): Promise<AdapterResults>; | ||
updateCollection(newDataName: string): Promise<AdapterResults>; | ||
add(newData: any, options?: any): Promise<any>; | ||
@@ -303,3 +312,3 @@ remove(query: any, options: { | ||
load(): Promise<any>; | ||
drop(): Promise<any>; | ||
dropCollection(): Promise<any>; | ||
updateMany(queries: any[], newData: operationKeys): Promise<any>; | ||
@@ -317,2 +326,32 @@ allData(displayOptions: any): Promise<any>; | ||
} | ||
export interface ListCollectionOptions { | ||
type?: string[]; | ||
recursive?: boolean; | ||
size?: { | ||
minSize?: number; | ||
maxSize?: number; | ||
}; | ||
date?: { | ||
modify?: { | ||
after?: Date; | ||
before?: Date; | ||
}; | ||
created?: { | ||
after?: Date; | ||
before?: Date; | ||
}; | ||
}; | ||
sort?: { | ||
by?: 'name' | 'size' | 'dateModified' | 'dateCreated'; | ||
order?: 'asc' | 'desc'; | ||
}; | ||
projection?: { | ||
limit?: number; | ||
offset?: number; | ||
}; | ||
regex?: { | ||
include?: string[]; | ||
exclude?: string[]; | ||
}; | ||
} | ||
//# sourceMappingURL=connect.d.ts.map |
@@ -20,5 +20,29 @@ import { SQLSchema } from "../core/functions/SQL-Schemas"; | ||
} | ||
export type SQLTypes = 'VARCHAR' | 'INTEGER' | 'UUID' | 'DATE' | 'DECIMAL' | 'BOOLEAN' | 'CHAR' | 'BLOB' | 'ARRAY' | 'JSON' | 'TEXT' | 'DATETIME' | 'DATETIME2' | 'SMALLDATETIME' | 'TIME' | 'DATETIMEOFFSET' | 'TIMESTAMP' | 'TIMESTAMPS' | 'BINARY' | 'CUSTOM' | 'ANY'; | ||
export declare enum SQLTypes { | ||
VARCHAR = "VARCHAR", | ||
INTEGER = "INTEGER", | ||
UUID = "UUID", | ||
DATE = "DATE", | ||
DECIMAL = "DECIMAL", | ||
BOOLEAN = "BOOLEAN", | ||
CHAR = "CHAR", | ||
BLOB = "BLOB", | ||
ARRAY = "ARRAY", | ||
JSON = "JSON", | ||
TEXT = "TEXT", | ||
DATETIME = "DATETIME", | ||
DATETIME2 = "DATETIME2", | ||
SMALLDATETIME = "SMALLDATETIME", | ||
TIME = "TIME", | ||
DATETIMEOFFSET = "DATETIMEOFFSET", | ||
TIMESTAMP = "TIMESTAMP", | ||
TIMESTAMPS = "TIMESTAMPS", | ||
BINARY = "BINARY", | ||
CUSTOM = "CUSTOM", | ||
ANY = "ANY" | ||
} | ||
export type SQLTypesString = keyof typeof SQLTypes; | ||
export type SQLTypesOrString = SQLTypes | SQLTypesString; | ||
export interface SchemaField { | ||
type: SQLTypes; | ||
type: SQLTypesOrString; | ||
validation?: SQLValidation; | ||
@@ -25,0 +49,0 @@ schema?: { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.SQLTypes = void 0; | ||
var SQLTypes; | ||
(function (SQLTypes) { | ||
SQLTypes["VARCHAR"] = "VARCHAR"; | ||
SQLTypes["INTEGER"] = "INTEGER"; | ||
SQLTypes["UUID"] = "UUID"; | ||
SQLTypes["DATE"] = "DATE"; | ||
SQLTypes["DECIMAL"] = "DECIMAL"; | ||
SQLTypes["BOOLEAN"] = "BOOLEAN"; | ||
SQLTypes["CHAR"] = "CHAR"; | ||
SQLTypes["BLOB"] = "BLOB"; | ||
SQLTypes["ARRAY"] = "ARRAY"; | ||
SQLTypes["JSON"] = "JSON"; | ||
SQLTypes["TEXT"] = "TEXT"; | ||
SQLTypes["DATETIME"] = "DATETIME"; | ||
SQLTypes["DATETIME2"] = "DATETIME2"; | ||
SQLTypes["SMALLDATETIME"] = "SMALLDATETIME"; | ||
SQLTypes["TIME"] = "TIME"; | ||
SQLTypes["DATETIMEOFFSET"] = "DATETIMEOFFSET"; | ||
SQLTypes["TIMESTAMP"] = "TIMESTAMP"; | ||
SQLTypes["TIMESTAMPS"] = "TIMESTAMPS"; | ||
SQLTypes["BINARY"] = "BINARY"; | ||
SQLTypes["CUSTOM"] = "CUSTOM"; | ||
SQLTypes["ANY"] = "ANY"; | ||
})(SQLTypes || (exports.SQLTypes = SQLTypes = {})); | ||
//# sourceMappingURL=sql-types.js.map |
{ | ||
"name": "verse.db", | ||
"version": "2.1.16", | ||
"version": "2.1.17", | ||
"description": "verse.db isn't just a database, it's your universal data bridge. Designed for unmatched flexibility, security, and performance, verse.db empowers you to manage your data with ease.", | ||
@@ -37,3 +37,7 @@ "license": "MIT", | ||
"@types/node": "^20.11.25", | ||
"@types/stream-chain": "^2.1.0", | ||
"@types/stream-json": "^1.7.7", | ||
"jest": "^29.7.0", | ||
"stream-chain": "^2.2.5", | ||
"stream-json": "^1.8.0", | ||
"ts-jest": "^29.1.2", | ||
@@ -40,0 +44,0 @@ "ts-node": "^10.9.2", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
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 too big to display
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 too big to display
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 too big to display
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
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
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
957942
92
13012
11
8