inibase 1.5.9 → 1.5.11

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.js CHANGED
@@ -8,6 +8,8 @@ import Inison from "inison";
8
8
  import { globalConfig, } from "./index.js";
9
9
  import { detectFieldType, isArrayOfObjects, isNumber, isObject, isStringified, } from "./utils.js";
10
10
  import { compare, encodeID, exec, gunzip, gzip } from "./utils.server.js";
11
+ // Locks older than this are assumed abandoned by a crashed/killed process, not a slow operation.
12
+ const STALE_LOCK_MS = 30_000;
11
13
  export const lock = async (folderPath, prefix) => {
12
14
  let lockFile = null;
13
15
  const lockFilePath = join(folderPath, `${prefix ?? ""}.locked`);
@@ -16,8 +18,12 @@ export const lock = async (folderPath, prefix) => {
16
18
  return;
17
19
  }
18
20
  catch ({ message }) {
19
- if (message.split(":")[0] === "EEXIST")
21
+ if (message.split(":")[0] === "EEXIST") {
22
+ const lockStat = await stat(lockFilePath).catch(() => null);
23
+ if (lockStat && Date.now() - lockStat.mtimeMs > STALE_LOCK_MS)
24
+ await unlink(lockFilePath).catch(() => { });
20
25
  return await new Promise((resolve) => setTimeout(() => resolve(lock(folderPath, prefix)), 13));
26
+ }
21
27
  }
22
28
  finally {
23
29
  await lockFile?.close();
package/dist/index.js CHANGED
@@ -1049,6 +1049,18 @@ export default class Inibase {
1049
1049
  searchLogicalOperator = logic;
1050
1050
  }
1051
1051
  }
1052
+ else if (Array.isArray(logicalChild)) {
1053
+ const crit = logicalChild
1054
+ .map((item) => typeof item === "string"
1055
+ ? Utils.FormatObjectCriteriaValue(item)
1056
+ : ["=", item])
1057
+ .filter(Boolean);
1058
+ if (crit.length) {
1059
+ searchOperator = crit.map((c) => c[0]);
1060
+ searchComparedAtValue = crit.map((c) => c[1]);
1061
+ searchLogicalOperator = logic;
1062
+ }
1063
+ }
1052
1064
  delete value[logic];
1053
1065
  }
1054
1066
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "inibase",
3
- "version": "1.5.9",
3
+ "version": "1.5.11",
4
4
  "type": "module",
5
5
  "author": {
6
6
  "name": "Karim Amahtil",