@aeriajs/common 0.0.28 → 0.0.30

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.
@@ -4,8 +4,8 @@ exports.convertConditionToQuery = void 0;
4
4
  const getValueFromPath_js_1 = require("./getValueFromPath.js");
5
5
  const convertExpression = (condition, subject) => {
6
6
  const term2 = 'term2' in condition
7
- ? typeof condition.term2 === 'string' && condition.term2.startsWith('$.')
8
- ? (0, getValueFromPath_js_1.getValueFromPath)(subject, condition.term2.split('$.')[1])
7
+ ? condition.fromState
8
+ ? (0, getValueFromPath_js_1.getValueFromPath)(subject, condition.term2)
9
9
  : condition.term2
10
10
  : null;
11
11
  switch (condition.operator) {
@@ -28,6 +28,10 @@ const convertExpression = (condition, subject) => {
28
28
  case 'lte': return {
29
29
  $lte: term2,
30
30
  };
31
+ case 'regex': return {
32
+ $regex: term2,
33
+ $options: condition.regexOptions,
34
+ };
31
35
  case 'in': {
32
36
  return Array.isArray(term2)
33
37
  ? {
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  import { getValueFromPath } from "./getValueFromPath.mjs";
3
3
  const convertExpression = (condition, subject) => {
4
- const term2 = "term2" in condition ? typeof condition.term2 === "string" && condition.term2.startsWith("$.") ? getValueFromPath(subject, condition.term2.split("$.")[1]) : condition.term2 : null;
4
+ const term2 = "term2" in condition ? condition.fromState ? getValueFromPath(subject, condition.term2) : condition.term2 : null;
5
5
  switch (condition.operator) {
6
6
  case "truthy":
7
7
  return {
@@ -28,6 +28,11 @@ const convertExpression = (condition, subject) => {
28
28
  return {
29
29
  $lte: term2
30
30
  };
31
+ case "regex":
32
+ return {
33
+ $regex: term2,
34
+ $options: condition.regexOptions
35
+ };
31
36
  case "in": {
32
37
  return Array.isArray(term2) ? {
33
38
  $in: term2
@@ -30,6 +30,7 @@ const evaluatesToTrue = (subject, condition) => {
30
30
  case 'lt': return term1 < term2;
31
31
  case 'gte': return term1 >= term2;
32
32
  case 'lte': return term1 <= term2;
33
+ case 'regex': return new RegExp(term2).test(term1);
33
34
  }
34
35
  }
35
36
  if ('and' in condition) {
@@ -34,6 +34,8 @@ const evaluatesToTrue = (subject, condition) => {
34
34
  return term1 >= term2;
35
35
  case "lte":
36
36
  return term1 <= term2;
37
+ case "regex":
38
+ return new RegExp(term2).test(term1);
37
39
  }
38
40
  }
39
41
  if ("and" in condition) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aeriajs/common",
3
- "version": "0.0.28",
3
+ "version": "0.0.30",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -27,12 +27,12 @@
27
27
  }
28
28
  },
29
29
  "devDependencies": {
30
- "@aeriajs/types": "^0.0.25",
31
- "bson": "^5.4.0"
30
+ "@aeriajs/types": "^0.0.27",
31
+ "bson": "^6.5.0"
32
32
  },
33
33
  "peerDependencies": {
34
- "@aeriajs/types": "^0.0.25",
35
- "bson": "^5.4.0"
34
+ "@aeriajs/types": "^0.0.27",
35
+ "bson": "^6.5.0"
36
36
  },
37
37
  "scripts": {
38
38
  "test": "echo skipping",