inibase 1.0.0-rc.84 → 1.0.0-rc.86
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +1 -1
- package/dist/file.js +2 -2
- package/dist/index.d.ts +4 -3
- package/dist/utils.d.ts +3 -3
- package/dist/utils.server.d.ts +1 -1
- package/dist/utils.server.js +7 -12
- package/package.json +2 -1
package/dist/cli.js
CHANGED
|
@@ -6,7 +6,7 @@ import { createInterface } from "node:readline/promises";
|
|
|
6
6
|
import { parseArgs } from "node:util";
|
|
7
7
|
import Inison from "inison";
|
|
8
8
|
import { isExists } from "./file.js";
|
|
9
|
-
import Inibase from "./index.js";
|
|
9
|
+
import Inibase, {} from "./index.js";
|
|
10
10
|
import { isJSON, isNumber, setField, unsetField } from "./utils.js";
|
|
11
11
|
const textGreen = (input) => `\u001b[1;32m${input}\u001b[0m`;
|
|
12
12
|
const textRed = (input) => `\u001b[1;31m${input}\u001b[0m`;
|
package/dist/file.js
CHANGED
|
@@ -16,7 +16,7 @@ export const lock = async (folderPath, prefix) => {
|
|
|
16
16
|
}
|
|
17
17
|
catch ({ message }) {
|
|
18
18
|
if (message.split(":")[0] === "EEXIST")
|
|
19
|
-
return await new Promise((resolve
|
|
19
|
+
return await new Promise((resolve) => setTimeout(() => resolve(lock(folderPath, prefix)), 13));
|
|
20
20
|
}
|
|
21
21
|
finally {
|
|
22
22
|
await lockFile?.close();
|
|
@@ -250,7 +250,7 @@ export const replace = async (filePath, replacements) => {
|
|
|
250
250
|
fileTempHandle = await open(fileTempPath, "w");
|
|
251
251
|
const rl = createReadLineInternface(filePath, fileHandle);
|
|
252
252
|
await _pipeline(filePath, rl, fileTempHandle.createWriteStream(), new Transform({
|
|
253
|
-
transform(line,
|
|
253
|
+
transform(line, _, callback) {
|
|
254
254
|
linesCount++;
|
|
255
255
|
const replacement = isObject(replacements)
|
|
256
256
|
? Object.hasOwn(replacements, linesCount)
|
package/dist/index.d.ts
CHANGED
|
@@ -41,10 +41,10 @@ export type Criteria = ({
|
|
|
41
41
|
} & {
|
|
42
42
|
[key: string]: string | number | boolean | undefined | Criteria;
|
|
43
43
|
}) | null;
|
|
44
|
+
type Entries<T> = {
|
|
45
|
+
[K in keyof T]: [K, T[K]];
|
|
46
|
+
}[keyof T][];
|
|
44
47
|
declare global {
|
|
45
|
-
type Entries<T> = {
|
|
46
|
-
[K in keyof T]: [K, T[K]];
|
|
47
|
-
}[keyof T][];
|
|
48
48
|
interface ObjectConstructor {
|
|
49
49
|
entries<T extends object>(o: T): Entries<T>;
|
|
50
50
|
}
|
|
@@ -185,3 +185,4 @@ export default class Inibase {
|
|
|
185
185
|
min(tableName: string | number, columns: string, where?: number | string | (number | string)[] | Criteria): Promise<number>;
|
|
186
186
|
min(tableName: string | number, columns: string[], where?: number | string | (number | string)[] | Criteria): Promise<Record<string, number>>;
|
|
187
187
|
}
|
|
188
|
+
export {};
|
package/dist/utils.d.ts
CHANGED
|
@@ -179,7 +179,7 @@ export declare function FormatObjectCriteriaValue(value: string): [
|
|
|
179
179
|
* @param {string} keyPath Support dot notation path
|
|
180
180
|
* @param {Schema} schema
|
|
181
181
|
*/
|
|
182
|
-
export declare function getField(keyPath: string, schema: Schema): Field
|
|
182
|
+
export declare function getField(keyPath: string, schema: Schema): Field;
|
|
183
183
|
/**
|
|
184
184
|
* Override a schema field, key, type or other properties
|
|
185
185
|
*
|
|
@@ -194,7 +194,7 @@ export declare function getField(keyPath: string, schema: Schema): Field | null;
|
|
|
194
194
|
export declare function setField(keyPath: string, schema: Schema, field: Omit<Field, "key" | "type"> & {
|
|
195
195
|
key?: string;
|
|
196
196
|
type?: FieldType | FieldType[];
|
|
197
|
-
}): Field
|
|
197
|
+
}): Field;
|
|
198
198
|
/**
|
|
199
199
|
* Remove field from schema
|
|
200
200
|
*
|
|
@@ -202,4 +202,4 @@ export declare function setField(keyPath: string, schema: Schema, field: Omit<Fi
|
|
|
202
202
|
* @param {string} keyPath Support dot notation path
|
|
203
203
|
* @param {Schema} schema
|
|
204
204
|
*/
|
|
205
|
-
export declare function unsetField(keyPath: string, schema: Schema): Field
|
|
205
|
+
export declare function unsetField(keyPath: string, schema: Schema): Field;
|
package/dist/utils.server.d.ts
CHANGED
|
@@ -55,7 +55,7 @@ export declare const hashString: (str: string) => string;
|
|
|
55
55
|
*
|
|
56
56
|
* Note: Handles various data types and comparison logic, including special handling for passwords and regex patterns.
|
|
57
57
|
*/
|
|
58
|
-
export declare const compare: (operator: ComparisonOperator, originalValue: string | number | boolean | null | (string | number | boolean | null)[], comparedValue: string | number | boolean | null | (string | number | boolean | null)[], fieldType?: FieldType | FieldType[]
|
|
58
|
+
export declare const compare: (operator: ComparisonOperator, originalValue: string | number | boolean | null | (string | number | boolean | null)[], comparedValue: string | number | boolean | null | (string | number | boolean | null)[], fieldType?: FieldType | FieldType[]) => boolean;
|
|
59
59
|
/**
|
|
60
60
|
* Helper function to check equality based on the field type.
|
|
61
61
|
*
|
package/dist/utils.server.js
CHANGED
|
@@ -141,15 +141,13 @@ export const hashString = (str) => createHash("sha256").update(str).digest("hex"
|
|
|
141
141
|
*
|
|
142
142
|
* Note: Handles various data types and comparison logic, including special handling for passwords and regex patterns.
|
|
143
143
|
*/
|
|
144
|
-
export const compare =
|
|
144
|
+
export const compare = (operator, originalValue, comparedValue, fieldType) => {
|
|
145
145
|
// Determine the field type if it's an array of potential types.
|
|
146
|
-
if (Array.isArray(fieldType))
|
|
146
|
+
if (Array.isArray(fieldType))
|
|
147
147
|
fieldType = detectFieldType(String(originalValue), fieldType);
|
|
148
|
-
}
|
|
149
148
|
// Handle comparisons involving arrays.
|
|
150
|
-
if (Array.isArray(comparedValue) && !["[]", "![]"].includes(operator))
|
|
149
|
+
if (Array.isArray(comparedValue) && !["[]", "![]"].includes(operator))
|
|
151
150
|
return comparedValue.some((value) => compare(operator, originalValue, value, fieldType));
|
|
152
|
-
}
|
|
153
151
|
// Switch statement for different comparison operators.
|
|
154
152
|
switch (operator) {
|
|
155
153
|
// Equal (Case Insensitive for strings, specific handling for passwords and booleans).
|
|
@@ -223,16 +221,13 @@ export const isEqual = (originalValue, comparedValue, fieldType) => {
|
|
|
223
221
|
* @returns boolean - Result of the array equality check.
|
|
224
222
|
*/
|
|
225
223
|
export const isArrayEqual = (originalValue, comparedValue) => {
|
|
226
|
-
if (Array.isArray(originalValue) && Array.isArray(comparedValue))
|
|
224
|
+
if (Array.isArray(originalValue) && Array.isArray(comparedValue))
|
|
227
225
|
return originalValue.some((v) => comparedValue.includes(v));
|
|
228
|
-
|
|
229
|
-
if (Array.isArray(originalValue)) {
|
|
226
|
+
if (Array.isArray(originalValue))
|
|
230
227
|
return originalValue.includes(comparedValue);
|
|
231
|
-
|
|
232
|
-
if (Array.isArray(comparedValue)) {
|
|
228
|
+
if (Array.isArray(comparedValue))
|
|
233
229
|
return comparedValue.includes(originalValue);
|
|
234
|
-
|
|
235
|
-
return originalValue === comparedValue;
|
|
230
|
+
return originalValue == comparedValue;
|
|
236
231
|
};
|
|
237
232
|
/**
|
|
238
233
|
* Helper function to check wildcard pattern matching using regex.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "inibase",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.86",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Karim Amahtil",
|
|
@@ -78,6 +78,7 @@
|
|
|
78
78
|
"inison": "1.0.0-rc.4"
|
|
79
79
|
},
|
|
80
80
|
"scripts": {
|
|
81
|
+
"prepublish": "npx tsc",
|
|
81
82
|
"build": "npx tsc",
|
|
82
83
|
"benchmark": "./benchmark/run.js"
|
|
83
84
|
}
|