inibase 1.1.30 → 1.1.32

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/file.d.ts CHANGED
@@ -141,3 +141,4 @@ export declare const max: (filePath: string, lineNumbers?: number | number[]) =>
141
141
  * Note: Decodes each line as a number using the 'decode' function. Considers only numerical values for determining the minimum.
142
142
  */
143
143
  export declare const min: (filePath: string, lineNumbers?: number | number[]) => Promise<number>;
144
+ export declare const getFileDate: (path: string) => Promise<Date>;
package/dist/file.js CHANGED
@@ -1,4 +1,4 @@
1
- import { access, appendFile, copyFile, constants as fsConstants, open, readFile, unlink, writeFile, } from "node:fs/promises";
1
+ import { access, appendFile, copyFile, constants as fsConstants, open, readFile, stat, unlink, writeFile, } from "node:fs/promises";
2
2
  import { join, resolve } from "node:path";
3
3
  import { createInterface } from "node:readline";
4
4
  import { Transform } from "node:stream";
@@ -702,3 +702,6 @@ export const min = async (filePath, lineNumbers) => {
702
702
  await fileHandle?.close();
703
703
  }
704
704
  };
705
+ export const getFileDate = (path) => stat(path)
706
+ .then((s) => s.mtime || s.birthtime)
707
+ .catch(() => new Date());
package/dist/index.d.ts CHANGED
@@ -55,7 +55,9 @@ export type ErrorCodes = "GROUP_UNIQUE" | "FIELD_UNIQUE" | "FIELD_REQUIRED" | "N
55
55
  export type ErrorLang = "en" | "ar" | "fr" | "es";
56
56
  export declare const globalConfig: {
57
57
  [database: string]: {
58
- tables?: Map<string, TableObject>;
58
+ tables?: Map<string, TableObject & {
59
+ timestamp?: Date;
60
+ }>;
59
61
  };
60
62
  } & {
61
63
  salt?: string | Buffer;
package/dist/index.js CHANGED
@@ -298,7 +298,9 @@ export default class Inibase {
298
298
  const tablePath = join(this.databasePath, tableName);
299
299
  if (!(await File.isExists(tablePath)))
300
300
  throw this.createError("TABLE_NOT_EXISTS", tableName);
301
- if (!globalConfig[this.databasePath].tables.has(tableName))
301
+ if (!globalConfig[this.databasePath].tables.has(tableName) ||
302
+ globalConfig[this.databasePath].tables.get(tableName).timestamp !==
303
+ (await File.getFileDate(join(tablePath, "schema.json"))))
302
304
  globalConfig[this.databasePath].tables.set(tableName, {
303
305
  schema: await this.getTableSchema(tableName, encodeIDs),
304
306
  config: {
@@ -307,6 +309,7 @@ export default class Inibase {
307
309
  prepend: await File.isExists(join(tablePath, ".prepend.config")),
308
310
  decodeID: await File.isExists(join(tablePath, ".decodeID.config")),
309
311
  },
312
+ timestamp: await File.getFileDate(join(tablePath, "schema.json")),
310
313
  });
311
314
  return globalConfig[this.databasePath].tables.get(tableName);
312
315
  }
@@ -1017,7 +1020,6 @@ export default class Inibase {
1017
1020
  databasePath: this.databasePath,
1018
1021
  table: field.table ?? tableName,
1019
1022
  }, options.perPage, (options.page - 1) * options.perPage + 1, true);
1020
- console.log(searchResult, totalLines, linesNumbers);
1021
1023
  if (searchResult) {
1022
1024
  const formatedSearchResult = Object.fromEntries(Object.entries(searchResult).map(([id, value]) => {
1023
1025
  const nestedObj = {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "inibase",
3
- "version": "1.1.30",
3
+ "version": "1.1.32",
4
4
  "type": "module",
5
5
  "author": {
6
6
  "name": "Karim Amahtil",