@witchcraft/expressit 0.0.2

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.
Files changed (307) hide show
  1. package/README.md +86 -0
  2. package/dist/ast/builders/array.d.ts +8 -0
  3. package/dist/ast/builders/array.d.ts.map +1 -0
  4. package/dist/ast/builders/array.js +31 -0
  5. package/dist/ast/builders/condition.d.ts +20 -0
  6. package/dist/ast/builders/condition.d.ts.map +1 -0
  7. package/dist/ast/builders/condition.js +28 -0
  8. package/dist/ast/builders/delim.d.ts +11 -0
  9. package/dist/ast/builders/delim.d.ts.map +1 -0
  10. package/dist/ast/builders/delim.js +20 -0
  11. package/dist/ast/builders/error.d.ts +9 -0
  12. package/dist/ast/builders/error.d.ts.map +1 -0
  13. package/dist/ast/builders/error.js +16 -0
  14. package/dist/ast/builders/expression.d.ts +12 -0
  15. package/dist/ast/builders/expression.d.ts.map +1 -0
  16. package/dist/ast/builders/expression.js +31 -0
  17. package/dist/ast/builders/group.d.ts +20 -0
  18. package/dist/ast/builders/group.d.ts.map +1 -0
  19. package/dist/ast/builders/group.js +47 -0
  20. package/dist/ast/builders/index.d.ts +12 -0
  21. package/dist/ast/builders/index.d.ts.map +1 -0
  22. package/dist/ast/builders/index.js +24 -0
  23. package/dist/ast/builders/isFullPos.d.ts +6 -0
  24. package/dist/ast/builders/isFullPos.d.ts.map +1 -0
  25. package/dist/ast/builders/isFullPos.js +6 -0
  26. package/dist/ast/builders/pos.d.ts +21 -0
  27. package/dist/ast/builders/pos.d.ts.map +1 -0
  28. package/dist/ast/builders/pos.js +28 -0
  29. package/dist/ast/builders/token.d.ts +12 -0
  30. package/dist/ast/builders/token.d.ts.map +1 -0
  31. package/dist/ast/builders/token.js +26 -0
  32. package/dist/ast/builders/type.d.ts +6 -0
  33. package/dist/ast/builders/type.d.ts.map +1 -0
  34. package/dist/ast/builders/type.js +37 -0
  35. package/dist/ast/builders/variable.d.ts +17 -0
  36. package/dist/ast/builders/variable.d.ts.map +1 -0
  37. package/dist/ast/builders/variable.js +62 -0
  38. package/dist/ast/classes/ArrayNode.d.ts +18 -0
  39. package/dist/ast/classes/ArrayNode.d.ts.map +1 -0
  40. package/dist/ast/classes/ArrayNode.js +55 -0
  41. package/dist/ast/classes/Condition.d.ts +13 -0
  42. package/dist/ast/classes/Condition.d.ts.map +1 -0
  43. package/dist/ast/classes/Condition.js +21 -0
  44. package/dist/ast/classes/ConditionNode.d.ts +73 -0
  45. package/dist/ast/classes/ConditionNode.d.ts.map +1 -0
  46. package/dist/ast/classes/ConditionNode.js +101 -0
  47. package/dist/ast/classes/ErrorToken.d.ts +27 -0
  48. package/dist/ast/classes/ErrorToken.d.ts.map +1 -0
  49. package/dist/ast/classes/ErrorToken.js +47 -0
  50. package/dist/ast/classes/Expression.d.ts +13 -0
  51. package/dist/ast/classes/Expression.d.ts.map +1 -0
  52. package/dist/ast/classes/Expression.js +19 -0
  53. package/dist/ast/classes/ExpressionNode.d.ts +21 -0
  54. package/dist/ast/classes/ExpressionNode.d.ts.map +1 -0
  55. package/dist/ast/classes/ExpressionNode.js +57 -0
  56. package/dist/ast/classes/GroupNode.d.ts +64 -0
  57. package/dist/ast/classes/GroupNode.d.ts.map +1 -0
  58. package/dist/ast/classes/GroupNode.js +69 -0
  59. package/dist/ast/classes/Node.d.ts +22 -0
  60. package/dist/ast/classes/Node.d.ts.map +1 -0
  61. package/dist/ast/classes/Node.js +28 -0
  62. package/dist/ast/classes/Token.d.ts +27 -0
  63. package/dist/ast/classes/Token.d.ts.map +1 -0
  64. package/dist/ast/classes/Token.js +28 -0
  65. package/dist/ast/classes/ValidToken.d.ts +26 -0
  66. package/dist/ast/classes/ValidToken.d.ts.map +1 -0
  67. package/dist/ast/classes/ValidToken.js +49 -0
  68. package/dist/ast/classes/VariableNode.d.ts +33 -0
  69. package/dist/ast/classes/VariableNode.d.ts.map +1 -0
  70. package/dist/ast/classes/VariableNode.js +58 -0
  71. package/dist/ast/classes/index.d.ts +12 -0
  72. package/dist/ast/classes/index.d.ts.map +1 -0
  73. package/dist/ast/classes/index.js +24 -0
  74. package/dist/ast/handlers.d.ts +42 -0
  75. package/dist/ast/handlers.d.ts.map +1 -0
  76. package/dist/ast/handlers.js +150 -0
  77. package/dist/ast/index.d.ts +4 -0
  78. package/dist/ast/index.d.ts.map +1 -0
  79. package/dist/ast/index.js +8 -0
  80. package/dist/examples/advancedValueComparer.d.ts +3 -0
  81. package/dist/examples/advancedValueComparer.d.ts.map +1 -0
  82. package/dist/examples/advancedValueComparer.js +28 -0
  83. package/dist/examples/shortcutContextParser.d.ts +22 -0
  84. package/dist/examples/shortcutContextParser.d.ts.map +1 -0
  85. package/dist/examples/shortcutContextParser.js +126 -0
  86. package/dist/global.d.js +1 -0
  87. package/dist/grammar/ParserBase.d.ts +51 -0
  88. package/dist/grammar/ParserBase.d.ts.map +1 -0
  89. package/dist/grammar/ParserBase.js +516 -0
  90. package/dist/grammar/createTokens.d.ts +56 -0
  91. package/dist/grammar/createTokens.d.ts.map +1 -0
  92. package/dist/grammar/createTokens.js +843 -0
  93. package/dist/grammar/index.d.ts +3 -0
  94. package/dist/grammar/index.d.ts.map +1 -0
  95. package/dist/grammar/index.js +6 -0
  96. package/dist/helpers/errors.d.ts +9 -0
  97. package/dist/helpers/errors.d.ts.map +1 -0
  98. package/dist/helpers/errors.js +41 -0
  99. package/dist/helpers/general/applyBoolean.d.ts +3 -0
  100. package/dist/helpers/general/applyBoolean.d.ts.map +1 -0
  101. package/dist/helpers/general/applyBoolean.js +17 -0
  102. package/dist/helpers/general/applyPrefix.d.ts +4 -0
  103. package/dist/helpers/general/applyPrefix.d.ts.map +1 -0
  104. package/dist/helpers/general/applyPrefix.js +9 -0
  105. package/dist/helpers/general/defaultConditionNormalizer.d.ts +3 -0
  106. package/dist/helpers/general/defaultConditionNormalizer.d.ts.map +1 -0
  107. package/dist/helpers/general/defaultConditionNormalizer.js +6 -0
  108. package/dist/helpers/general/defaultKeyParser.d.ts +3 -0
  109. package/dist/helpers/general/defaultKeyParser.d.ts.map +1 -0
  110. package/dist/helpers/general/defaultKeyParser.js +8 -0
  111. package/dist/helpers/general/defaultPrefixApplier.d.ts +3 -0
  112. package/dist/helpers/general/defaultPrefixApplier.d.ts.map +1 -0
  113. package/dist/helpers/general/defaultPrefixApplier.js +6 -0
  114. package/dist/helpers/general/defaultValueComparer.d.ts +3 -0
  115. package/dist/helpers/general/defaultValueComparer.d.ts.map +1 -0
  116. package/dist/helpers/general/defaultValueComparer.js +6 -0
  117. package/dist/helpers/general/index.d.ts +7 -0
  118. package/dist/helpers/general/index.d.ts.map +1 -0
  119. package/dist/helpers/general/index.js +14 -0
  120. package/dist/helpers/index.d.ts +4 -0
  121. package/dist/helpers/index.d.ts.map +1 -0
  122. package/dist/helpers/index.js +8 -0
  123. package/dist/helpers/parser/assignParents.d.ts +4 -0
  124. package/dist/helpers/parser/assignParents.d.ts.map +1 -0
  125. package/dist/helpers/parser/assignParents.js +71 -0
  126. package/dist/helpers/parser/checkParserOpts.d.ts +3 -0
  127. package/dist/helpers/parser/checkParserOpts.d.ts.map +1 -0
  128. package/dist/helpers/parser/checkParserOpts.js +126 -0
  129. package/dist/helpers/parser/extractPosition.d.ts +9 -0
  130. package/dist/helpers/parser/extractPosition.d.ts.map +1 -0
  131. package/dist/helpers/parser/extractPosition.js +9 -0
  132. package/dist/helpers/parser/getUnclosedRightParenCount.d.ts +5 -0
  133. package/dist/helpers/parser/getUnclosedRightParenCount.d.ts.map +1 -0
  134. package/dist/helpers/parser/getUnclosedRightParenCount.js +20 -0
  135. package/dist/helpers/parser/index.d.ts +9 -0
  136. package/dist/helpers/parser/index.d.ts.map +1 -0
  137. package/dist/helpers/parser/index.js +18 -0
  138. package/dist/helpers/parser/parseParserOptions.d.ts +4 -0
  139. package/dist/helpers/parser/parseParserOptions.d.ts.map +1 -0
  140. package/dist/helpers/parser/parseParserOptions.js +45 -0
  141. package/dist/helpers/parser/seal.d.ts +8 -0
  142. package/dist/helpers/parser/seal.d.ts.map +1 -0
  143. package/dist/helpers/parser/seal.js +10 -0
  144. package/dist/helpers/parser/setParent.d.ts +6 -0
  145. package/dist/helpers/parser/setParent.d.ts.map +1 -0
  146. package/dist/helpers/parser/setParent.js +4 -0
  147. package/dist/helpers/parser/unescape.d.ts +3 -0
  148. package/dist/helpers/parser/unescape.d.ts.map +1 -0
  149. package/dist/helpers/parser/unescape.js +6 -0
  150. package/dist/index.d.ts +6 -0
  151. package/dist/index.d.ts.map +1 -0
  152. package/dist/index.js +17 -0
  153. package/dist/methods/autocomplete.d.ts +18 -0
  154. package/dist/methods/autocomplete.d.ts.map +1 -0
  155. package/dist/methods/autocomplete.js +109 -0
  156. package/dist/methods/autoreplace.d.ts +13 -0
  157. package/dist/methods/autoreplace.d.ts.map +1 -0
  158. package/dist/methods/autoreplace.js +36 -0
  159. package/dist/methods/autosuggest.d.ts +28 -0
  160. package/dist/methods/autosuggest.d.ts.map +1 -0
  161. package/dist/methods/autosuggest.js +371 -0
  162. package/dist/methods/evaluate.d.ts +11 -0
  163. package/dist/methods/evaluate.d.ts.map +1 -0
  164. package/dist/methods/evaluate.js +30 -0
  165. package/dist/methods/getBestIndex.d.ts +19 -0
  166. package/dist/methods/getBestIndex.d.ts.map +1 -0
  167. package/dist/methods/getBestIndex.js +53 -0
  168. package/dist/methods/getIndexes.d.ts +17 -0
  169. package/dist/methods/getIndexes.d.ts.map +1 -0
  170. package/dist/methods/getIndexes.js +97 -0
  171. package/dist/methods/index.d.ts +9 -0
  172. package/dist/methods/index.d.ts.map +1 -0
  173. package/dist/methods/index.js +18 -0
  174. package/dist/methods/normalize.d.ts +12 -0
  175. package/dist/methods/normalize.d.ts.map +1 -0
  176. package/dist/methods/normalize.js +99 -0
  177. package/dist/methods/validate.d.ts +11 -0
  178. package/dist/methods/validate.d.ts.map +1 -0
  179. package/dist/methods/validate.js +111 -0
  180. package/dist/package.js +7 -0
  181. package/dist/package.json.js +193 -0
  182. package/dist/parser.d.ts +58 -0
  183. package/dist/parser.d.ts.map +1 -0
  184. package/dist/parser.js +136 -0
  185. package/dist/types/ast.d.ts +70 -0
  186. package/dist/types/ast.d.ts.map +1 -0
  187. package/dist/types/ast.js +29 -0
  188. package/dist/types/autocomplete.d.ts +143 -0
  189. package/dist/types/autocomplete.d.ts.map +1 -0
  190. package/dist/types/autocomplete.js +24 -0
  191. package/dist/types/errors.d.ts +34 -0
  192. package/dist/types/errors.d.ts.map +1 -0
  193. package/dist/types/errors.js +10 -0
  194. package/dist/types/index.d.ts +5 -0
  195. package/dist/types/index.d.ts.map +1 -0
  196. package/dist/types/index.js +9 -0
  197. package/dist/types/parser.d.ts +451 -0
  198. package/dist/types/parser.d.ts.map +1 -0
  199. package/dist/types/parser.js +1 -0
  200. package/dist/utils/extractTokens.d.ts +8 -0
  201. package/dist/utils/extractTokens.d.ts.map +1 -0
  202. package/dist/utils/extractTokens.js +50 -0
  203. package/dist/utils/getCursorInfo.d.ts +7 -0
  204. package/dist/utils/getCursorInfo.d.ts.map +1 -0
  205. package/dist/utils/getCursorInfo.js +86 -0
  206. package/dist/utils/getOppositeDelimiter.d.ts +6 -0
  207. package/dist/utils/getOppositeDelimiter.d.ts.map +1 -0
  208. package/dist/utils/getOppositeDelimiter.js +35 -0
  209. package/dist/utils/getSurroundingErrors.d.ts +25 -0
  210. package/dist/utils/getSurroundingErrors.d.ts.map +1 -0
  211. package/dist/utils/getSurroundingErrors.js +37 -0
  212. package/dist/utils/index.d.ts +10 -0
  213. package/dist/utils/index.d.ts.map +1 -0
  214. package/dist/utils/index.js +20 -0
  215. package/dist/utils/isBracket.d.ts +3 -0
  216. package/dist/utils/isBracket.d.ts.map +1 -0
  217. package/dist/utils/isBracket.js +7 -0
  218. package/dist/utils/isDelimiter.d.ts +6 -0
  219. package/dist/utils/isDelimiter.d.ts.map +1 -0
  220. package/dist/utils/isDelimiter.js +17 -0
  221. package/dist/utils/isParen.d.ts +3 -0
  222. package/dist/utils/isParen.d.ts.map +1 -0
  223. package/dist/utils/isParen.js +7 -0
  224. package/dist/utils/isQuote.d.ts +4 -0
  225. package/dist/utils/isQuote.d.ts.map +1 -0
  226. package/dist/utils/isQuote.js +7 -0
  227. package/dist/utils/prettyAst.d.ts +35 -0
  228. package/dist/utils/prettyAst.d.ts.map +1 -0
  229. package/dist/utils/prettyAst.js +112 -0
  230. package/package.json +152 -0
  231. package/src/ast/builders/array.ts +45 -0
  232. package/src/ast/builders/condition.ts +56 -0
  233. package/src/ast/builders/delim.ts +39 -0
  234. package/src/ast/builders/error.ts +22 -0
  235. package/src/ast/builders/expression.ts +66 -0
  236. package/src/ast/builders/group.ts +79 -0
  237. package/src/ast/builders/index.ts +13 -0
  238. package/src/ast/builders/isFullPos.ts +10 -0
  239. package/src/ast/builders/pos.ts +57 -0
  240. package/src/ast/builders/token.ts +46 -0
  241. package/src/ast/builders/type.ts +32 -0
  242. package/src/ast/builders/variable.ts +89 -0
  243. package/src/ast/classes/ArrayNode.ts +46 -0
  244. package/src/ast/classes/Condition.ts +22 -0
  245. package/src/ast/classes/ConditionNode.ts +141 -0
  246. package/src/ast/classes/ErrorToken.ts +49 -0
  247. package/src/ast/classes/Expression.ts +26 -0
  248. package/src/ast/classes/ExpressionNode.ts +62 -0
  249. package/src/ast/classes/GroupNode.ts +127 -0
  250. package/src/ast/classes/Node.ts +47 -0
  251. package/src/ast/classes/Token.ts +59 -0
  252. package/src/ast/classes/ValidToken.ts +56 -0
  253. package/src/ast/classes/VariableNode.ts +67 -0
  254. package/src/ast/classes/index.ts +13 -0
  255. package/src/ast/handlers.ts +190 -0
  256. package/src/ast/index.ts +5 -0
  257. package/src/examples/advancedValueComparer.ts +31 -0
  258. package/src/examples/shortcutContextParser.ts +140 -0
  259. package/src/global.d.ts +4 -0
  260. package/src/grammar/ParserBase.ts +715 -0
  261. package/src/grammar/createTokens.ts +512 -0
  262. package/src/grammar/index.ts +4 -0
  263. package/src/helpers/errors.ts +45 -0
  264. package/src/helpers/general/applyBoolean.ts +9 -0
  265. package/src/helpers/general/applyPrefix.ts +7 -0
  266. package/src/helpers/general/defaultConditionNormalizer.ts +9 -0
  267. package/src/helpers/general/defaultKeyParser.ts +8 -0
  268. package/src/helpers/general/defaultPrefixApplier.ts +7 -0
  269. package/src/helpers/general/defaultValueComparer.ts +7 -0
  270. package/src/helpers/general/index.ts +8 -0
  271. package/src/helpers/index.ts +5 -0
  272. package/src/helpers/parser/assignParents.ts +51 -0
  273. package/src/helpers/parser/checkParserOpts.ts +143 -0
  274. package/src/helpers/parser/extractPosition.ts +15 -0
  275. package/src/helpers/parser/getUnclosedRightParenCount.ts +22 -0
  276. package/src/helpers/parser/index.ts +10 -0
  277. package/src/helpers/parser/parseParserOptions.ts +54 -0
  278. package/src/helpers/parser/seal.ts +14 -0
  279. package/src/helpers/parser/setParent.ts +5 -0
  280. package/src/helpers/parser/unescape.ts +4 -0
  281. package/src/index.ts +7 -0
  282. package/src/methods/autocomplete.ts +128 -0
  283. package/src/methods/autoreplace.ts +46 -0
  284. package/src/methods/autosuggest.ts +543 -0
  285. package/src/methods/evaluate.ts +37 -0
  286. package/src/methods/getBestIndex.ts +53 -0
  287. package/src/methods/getIndexes.ts +99 -0
  288. package/src/methods/index.ts +10 -0
  289. package/src/methods/normalize.ts +138 -0
  290. package/src/methods/validate.ts +141 -0
  291. package/src/package.js +11 -0
  292. package/src/parser.ts +183 -0
  293. package/src/types/ast.ts +148 -0
  294. package/src/types/autocomplete.ts +152 -0
  295. package/src/types/errors.ts +40 -0
  296. package/src/types/index.ts +6 -0
  297. package/src/types/parser.ts +479 -0
  298. package/src/utils/extractTokens.ts +67 -0
  299. package/src/utils/getCursorInfo.ts +106 -0
  300. package/src/utils/getOppositeDelimiter.ts +36 -0
  301. package/src/utils/getSurroundingErrors.ts +57 -0
  302. package/src/utils/index.ts +11 -0
  303. package/src/utils/isBracket.ts +6 -0
  304. package/src/utils/isDelimiter.ts +18 -0
  305. package/src/utils/isParen.ts +6 -0
  306. package/src/utils/isQuote.ts +6 -0
  307. package/src/utils/prettyAst.ts +152 -0
@@ -0,0 +1,11 @@
1
+ import { Condition } from "../ast/classes/Condition.js";
2
+ import { Expression } from "../ast/classes/Expression.js";
3
+ export declare class EvaluateMixin<T extends {}> {
4
+ /**
5
+ * Evaluates a {@link Parser.normalize normalized} ast.
6
+ *
7
+ * How the ast is evaluated for different operators can be controlled by the {@link ParserOptions.valueComparer valueComparer} option.
8
+ */
9
+ evaluate(ast: Expression<any, any> | Condition<any, any>, context: Record<string, any>): boolean;
10
+ }
11
+ //# sourceMappingURL=evaluate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"evaluate.d.ts","sourceRoot":"","sources":["../../src/methods/evaluate.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAA;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAA;AAKzD,qBAAa,aAAa,CAAC,CAAC,SAAS,EAAE;IACtC;;;;OAIG;IACH,QAAQ,CAAC,GAAG,EAAE,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO;CAsBhG"}
@@ -0,0 +1,30 @@
1
+ import { get, unreachable } from "@alanscodelog/utils";
2
+ import { Condition } from "../ast/classes/Condition.js";
3
+ import { Expression } from "../ast/classes/Expression.js";
4
+ import { TOKEN_TYPE } from "../types/ast.js";
5
+ class EvaluateMixin {
6
+ /**
7
+ * Evaluates a {@link Parser.normalize normalized} ast.
8
+ *
9
+ * How the ast is evaluated for different operators can be controlled by the {@link ParserOptions.valueComparer valueComparer} option.
10
+ */
11
+ evaluate(ast, context) {
12
+ this._checkEvaluationOptions();
13
+ const opts = this.options;
14
+ const self_ = this;
15
+ if (ast instanceof Condition) {
16
+ const contextValue = get(context, ast.property);
17
+ const res = opts.valueComparer({ property: ast.property, value: ast.value, operator: ast.operator }, contextValue, context);
18
+ return ast.negate ? !res : res;
19
+ }
20
+ if (ast instanceof Expression) {
21
+ const left = self_.evaluate(ast.left, context);
22
+ const right = self_.evaluate(ast.right, context);
23
+ return ast.operator === TOKEN_TYPE.AND ? left && right : left || right;
24
+ }
25
+ return unreachable();
26
+ }
27
+ }
28
+ export {
29
+ EvaluateMixin
30
+ };
@@ -0,0 +1,19 @@
1
+ export declare class GetBestIndexesMixin {
2
+ /**
3
+ * Given the set of indexes returned by {@link getBestIndex}, the set of existing indexes in a database, and the index to sort by\*, will return a list of the best/shortest sets of indexes.
4
+ *
5
+ * For example, given the query `a && b && c`, `getBestIndex` will return `[Set(a), Set(b)]`.
6
+ *
7
+ * Suppose we have indexes on all the variables and that the user wants to sort by `c`, this function will return [`Set(c)`].
8
+ *
9
+ * Suppose instead we have indexes only on `a` and `b` and that the user wants to sort by `c`, this function will return [`Set(a), Set(b)`]. Either can be picked by some other criteria (e.g. size of the indexes). Sort should then be done in memory.
10
+ *
11
+ * And then finally, if we have no existing indexes on any of the variables, the function will return `[]`.
12
+ *
13
+ * Note: This is a simple algorithm and is not designed to take into account instances where entries are indexed by two or more properties as their keys (i.e. multicolumn indexes).
14
+ *
15
+ * \* If the sort index is not in the list of existing indexes it is not taken into account.
16
+ */
17
+ getBestIndexes(indexes: Set<string>[], existing: Set<string> | Map<string, number>, sortIndex?: string): Set<string>[];
18
+ }
19
+ //# sourceMappingURL=getBestIndex.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getBestIndex.d.ts","sourceRoot":"","sources":["../../src/methods/getBestIndex.ts"],"names":[],"mappings":"AAAA,qBAAa,mBAAmB;IAC/B;;;;;;;;;;;;;;OAcG;IACH,cAAc,CAAC,OAAO,EAAE,GAAG,CAAC,MAAM,CAAC,EAAE,EAAE,QAAQ,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,SAAS,GAAE,MAAW,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE;CAmC1H"}
@@ -0,0 +1,53 @@
1
+ class GetBestIndexesMixin {
2
+ /**
3
+ * Given the set of indexes returned by {@link getBestIndex}, the set of existing indexes in a database, and the index to sort by\*, will return a list of the best/shortest sets of indexes.
4
+ *
5
+ * For example, given the query `a && b && c`, `getBestIndex` will return `[Set(a), Set(b)]`.
6
+ *
7
+ * Suppose we have indexes on all the variables and that the user wants to sort by `c`, this function will return [`Set(c)`].
8
+ *
9
+ * Suppose instead we have indexes only on `a` and `b` and that the user wants to sort by `c`, this function will return [`Set(a), Set(b)`]. Either can be picked by some other criteria (e.g. size of the indexes). Sort should then be done in memory.
10
+ *
11
+ * And then finally, if we have no existing indexes on any of the variables, the function will return `[]`.
12
+ *
13
+ * Note: This is a simple algorithm and is not designed to take into account instances where entries are indexed by two or more properties as their keys (i.e. multicolumn indexes).
14
+ *
15
+ * \* If the sort index is not in the list of existing indexes it is not taken into account.
16
+ */
17
+ getBestIndexes(indexes, existing, sortIndex = "") {
18
+ indexes = indexes.filter((set) => {
19
+ for (const key of set) {
20
+ if (!existing.has(key))
21
+ return false;
22
+ }
23
+ return true;
24
+ });
25
+ let finalIndexes = indexes;
26
+ if (existing.has(sortIndex)) {
27
+ const indexesWithSortIndex = indexes.filter((set) => set.has(sortIndex));
28
+ if (indexesWithSortIndex.length > 0)
29
+ finalIndexes = indexesWithSortIndex;
30
+ }
31
+ let smallest = Infinity;
32
+ if (existing instanceof Map) {
33
+ const scores = /* @__PURE__ */ new Map();
34
+ for (const set of finalIndexes) {
35
+ let score = 0;
36
+ for (const key of set) {
37
+ score += existing.get(key) ?? 0;
38
+ }
39
+ scores.set(set, score);
40
+ smallest = score < smallest ? score : smallest;
41
+ }
42
+ return indexes.filter((set) => smallest === Infinity || scores.get(set) === smallest);
43
+ } else {
44
+ for (const set of finalIndexes) {
45
+ smallest = set.size < smallest ? set.size : smallest;
46
+ }
47
+ return indexes.filter((set) => smallest === Infinity || set.size === smallest);
48
+ }
49
+ }
50
+ }
51
+ export {
52
+ GetBestIndexesMixin
53
+ };
@@ -0,0 +1,17 @@
1
+ import { Condition } from "../ast/classes/Condition.js";
2
+ import { Expression } from "../ast/classes/Expression.js";
3
+ export declare class GetIndexMixin<T> {
4
+ /**
5
+ * Returns a list of the different sets of keys that need to be indexed to run a normalized query on a database and hit an existing index.
6
+ *
7
+ * For example, the expression `a || b` requires both `a` AND `b` be indexed to use an index. The function would return `[Set(a, b)]`.
8
+ *
9
+ * On the otherhand, the expression `a && b` only requires `a` OR `b` to be indexed (`[Set(a), Set(b)]`) If at least one is indexed, the rest of the filtering can be done in memory. There is no need to in memory filter the entire database.
10
+ *
11
+ * Now take a more complicated query like `(a && b) || (a && c)`. This only requires `a` be indexed, or both `b` AND `c`. (`[Set(a)], [Set(b), Set(c)]`).
12
+ *
13
+ * Queries like `(a || b) && (a || c)` would require all the variables to be indexed `[Set(a), Set(b), Set(c)]`.
14
+ */
15
+ getIndexes(ast: Condition | Expression): Set<string>[];
16
+ }
17
+ //# sourceMappingURL=getIndexes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getIndexes.d.ts","sourceRoot":"","sources":["../../src/methods/getIndexes.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAA;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAA;AAIzD,qBAAa,aAAa,CAAC,CAAC;IAC3B;;;;;;;;;;OAUG;IACH,UAAU,CAAC,GAAG,EAAE,SAAS,GAAG,UAAU,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE;CAqEtD"}
@@ -0,0 +1,97 @@
1
+ import { unreachable } from "@alanscodelog/utils";
2
+ import { Condition } from "../ast/classes/Condition.js";
3
+ import { Expression } from "../ast/classes/Expression.js";
4
+ import { TOKEN_TYPE } from "../types/ast.js";
5
+ class GetIndexMixin {
6
+ /**
7
+ * Returns a list of the different sets of keys that need to be indexed to run a normalized query on a database and hit an existing index.
8
+ *
9
+ * For example, the expression `a || b` requires both `a` AND `b` be indexed to use an index. The function would return `[Set(a, b)]`.
10
+ *
11
+ * On the otherhand, the expression `a && b` only requires `a` OR `b` to be indexed (`[Set(a), Set(b)]`) If at least one is indexed, the rest of the filtering can be done in memory. There is no need to in memory filter the entire database.
12
+ *
13
+ * Now take a more complicated query like `(a && b) || (a && c)`. This only requires `a` be indexed, or both `b` AND `c`. (`[Set(a)], [Set(b), Set(c)]`).
14
+ *
15
+ * Queries like `(a || b) && (a || c)` would require all the variables to be indexed `[Set(a), Set(b), Set(c)]`.
16
+ */
17
+ getIndexes(ast) {
18
+ const self_ = this;
19
+ if (ast instanceof Condition) {
20
+ return [new Set(ast.property.join("."))];
21
+ }
22
+ if (ast instanceof Expression) {
23
+ const left = self_.getIndexes(ast.left);
24
+ const right = self_.getIndexes(ast.right);
25
+ if (ast.operator === TOKEN_TYPE.AND) {
26
+ const sets = [];
27
+ const allKeys = /* @__PURE__ */ new Set();
28
+ for (const leftSet of left) {
29
+ const exists = sets.find((set) => isEqualSet(set, leftSet));
30
+ if (exists)
31
+ continue;
32
+ sets.push(leftSet);
33
+ for (const key of leftSet) {
34
+ allKeys.add(key);
35
+ }
36
+ }
37
+ for (const rightSet of right) {
38
+ const exists = sets.find((set) => isEqualSet(set, rightSet));
39
+ if (exists)
40
+ continue;
41
+ sets.push(rightSet);
42
+ for (const key of rightSet) {
43
+ allKeys.add(key);
44
+ }
45
+ }
46
+ const commonKeys = /* @__PURE__ */ new Set();
47
+ outerCheck:
48
+ for (const key of allKeys) {
49
+ for (const set of sets) {
50
+ if (!set.has(key))
51
+ continue outerCheck;
52
+ }
53
+ commonKeys.add(key);
54
+ }
55
+ if (commonKeys.size > 0) {
56
+ return [commonKeys, allKeys];
57
+ } else {
58
+ return sets;
59
+ }
60
+ }
61
+ if (ast.operator === TOKEN_TYPE.OR) {
62
+ for (const rightSet of right) {
63
+ for (const leftSet of left) {
64
+ if (isEqualSet(leftSet, rightSet)) {
65
+ return [rightSet];
66
+ }
67
+ }
68
+ }
69
+ const res = /* @__PURE__ */ new Set();
70
+ for (const leftSet of left) {
71
+ for (const key of leftSet) {
72
+ res.add(key);
73
+ }
74
+ }
75
+ for (const rightSet of right) {
76
+ for (const key of rightSet) {
77
+ res.add(key);
78
+ }
79
+ }
80
+ return [res];
81
+ }
82
+ }
83
+ return unreachable();
84
+ }
85
+ }
86
+ function isEqualSet(setA, setB) {
87
+ if (setA.size !== setB.size)
88
+ return false;
89
+ for (const key of setA) {
90
+ if (!setB.has(key))
91
+ return false;
92
+ }
93
+ return true;
94
+ }
95
+ export {
96
+ GetIndexMixin
97
+ };
@@ -0,0 +1,9 @@
1
+ export { AutocompleteMixin } from "./autocomplete.js";
2
+ export { AutoreplaceMixin } from "./autoreplace.js";
3
+ export { Autosuggest } from "./autosuggest.js";
4
+ export { EvaluateMixin } from "./evaluate.js";
5
+ export { GetBestIndexesMixin } from "./getBestIndex.js";
6
+ export { GetIndexMixin } from "./getIndexes.js";
7
+ export { NormalizeMixin } from "./normalize.js";
8
+ export { ValidateMixin } from "./validate.js";
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/methods/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAC7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA"}
@@ -0,0 +1,18 @@
1
+ import { AutocompleteMixin } from "./autocomplete.js";
2
+ import { AutoreplaceMixin } from "./autoreplace.js";
3
+ import { Autosuggest } from "./autosuggest.js";
4
+ import { EvaluateMixin } from "./evaluate.js";
5
+ import { GetBestIndexesMixin } from "./getBestIndex.js";
6
+ import { GetIndexMixin } from "./getIndexes.js";
7
+ import { NormalizeMixin } from "./normalize.js";
8
+ import { ValidateMixin } from "./validate.js";
9
+ export {
10
+ AutocompleteMixin,
11
+ AutoreplaceMixin,
12
+ Autosuggest,
13
+ EvaluateMixin,
14
+ GetBestIndexesMixin,
15
+ GetIndexMixin,
16
+ NormalizeMixin,
17
+ ValidateMixin
18
+ };
@@ -0,0 +1,12 @@
1
+ import { Condition } from "../ast/classes/Condition.js";
2
+ import { Expression } from "../ast/classes/Expression.js";
3
+ import { type ParserResults } from "../types/ast.js";
4
+ export declare class NormalizeMixin<T extends {}> {
5
+ /**
6
+ * Normalizes the ast by applying {@link GroupNode GroupNodes} and converting {@link ConditionNode ConditionNodes} to {@link NormalizedConditionNode NormalizedConditionNodes}.
7
+ *
8
+ * To do this, a
9
+ */
10
+ normalize<TType extends string, TValue>(ast: ParserResults): Condition<TType, TValue> | Expression<TType, TValue>;
11
+ }
12
+ //# sourceMappingURL=normalize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalize.d.ts","sourceRoot":"","sources":["../../src/methods/normalize.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAA;AAGvD,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAA;AAQzD,OAAO,EAAE,KAAK,aAAa,EAAsC,MAAM,iBAAiB,CAAA;AASxF,qBAAa,cAAc,CAAC,CAAC,SAAS,EAAE;IACvC;;;;OAIG;IACH,SAAS,CAAC,KAAK,SAAS,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,aAAa,GAAG,SAAS,CAAC,KAAK,EAAE,MAAM,CAAC,GAAG,UAAU,CAAC,KAAK,EAAE,MAAM,CAAC;CA4GjH"}
@@ -0,0 +1,99 @@
1
+ import { unreachable } from "@alanscodelog/utils";
2
+ import { ArrayNode } from "../ast/classes/ArrayNode.js";
3
+ import { Condition } from "../ast/classes/Condition.js";
4
+ import { ConditionNode } from "../ast/classes/ConditionNode.js";
5
+ import { ErrorToken } from "../ast/classes/ErrorToken.js";
6
+ import { Expression } from "../ast/classes/Expression.js";
7
+ import { ExpressionNode } from "../ast/classes/ExpressionNode.js";
8
+ import { GroupNode } from "../ast/classes/GroupNode.js";
9
+ import { ValidToken } from "../ast/classes/ValidToken.js";
10
+ import { VariableNode } from "../ast/classes/VariableNode.js";
11
+ import { applyBoolean } from "../helpers/general/applyBoolean.js";
12
+ import { applyPrefix } from "../helpers/general/applyPrefix.js";
13
+ import { TOKEN_TYPE } from "../types/ast.js";
14
+ const OPPOSITE = {
15
+ [TOKEN_TYPE.AND]: TOKEN_TYPE.OR,
16
+ [TOKEN_TYPE.OR]: TOKEN_TYPE.AND
17
+ };
18
+ class NormalizeMixin {
19
+ /**
20
+ * Normalizes the ast by applying {@link GroupNode GroupNodes} and converting {@link ConditionNode ConditionNodes} to {@link NormalizedConditionNode NormalizedConditionNodes}.
21
+ *
22
+ * To do this, a
23
+ */
24
+ normalize(ast) {
25
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
26
+ this._checkEvaluationOptions();
27
+ const opts = this.options;
28
+ if (ast instanceof ErrorToken || !ast.valid) {
29
+ throw new Error("AST node must be valid.");
30
+ }
31
+ const prefix = arguments[1];
32
+ const groupValue = arguments[2];
33
+ let operator = arguments[3];
34
+ const self_ = this;
35
+ if (ast instanceof ConditionNode) {
36
+ if (!(ast.value instanceof GroupNode)) {
37
+ const isValue = ast.value instanceof ArrayNode || ((_b = (_a = ast.value) == null ? void 0 : _a.quote) == null ? void 0 : _b.left.type) === TOKEN_TYPE.REGEX;
38
+ let name = ast.property ? unescape(ast.property.value.value) : isValue ? void 0 : unescape((_c = ast.value) == null ? void 0 : _c.value.value);
39
+ const isNested = operator !== void 0;
40
+ if (prefix !== void 0 && !isNested) {
41
+ name = name ? applyPrefix(prefix, name, opts.prefixApplier) : prefix;
42
+ }
43
+ let value;
44
+ if (isNested) {
45
+ value = name ?? true;
46
+ name = prefix;
47
+ } else {
48
+ value = ast.value instanceof ArrayNode ? ast.value.values.map((val) => unescape(val.value.value)) : ((_e = (_d = ast.value) == null ? void 0 : _d.quote) == null ? void 0 : _e.left.type) === TOKEN_TYPE.REGEX ? ast.value.value.value : ast.property && ast.value instanceof VariableNode ? unescape(ast.value.value.value) : true;
49
+ }
50
+ const propertyKeys = name ? opts.keyParser(name) : [];
51
+ const boolValue = applyBoolean(groupValue, ast.operator === void 0);
52
+ const valuePrefix = ast.value instanceof VariableNode && ast.value.prefix ? unescape(ast.value.prefix.value) : void 0;
53
+ operator ?? (operator = (_f = ast.propertyOperator) == null ? void 0 : _f.value);
54
+ const isRegex = ((_h = (_g = ast.value) == null ? void 0 : _g.quote) == null ? void 0 : _h.left.type) === TOKEN_TYPE.REGEX;
55
+ const isQuoted = ((_i = ast.value) == null ? void 0 : _i.quote) !== void 0;
56
+ const isExpanded = ast.sep !== void 0;
57
+ const regexFlags = (_l = (_k = (_j = ast.value) == null ? void 0 : _j.quote) == null ? void 0 : _k.flags) == null ? void 0 : _l.value;
58
+ const query = {
59
+ value,
60
+ operator,
61
+ prefix: valuePrefix,
62
+ regexFlags,
63
+ property: propertyKeys,
64
+ isRegex,
65
+ isQuoted,
66
+ isExpanded,
67
+ isNegated: !boolValue,
68
+ condition: ast
69
+ };
70
+ const res = opts.conditionNormalizer(query);
71
+ return new Condition({ property: propertyKeys, ...res });
72
+ } else {
73
+ let name = unescape(ast.property.value.value);
74
+ if (prefix !== void 0) {
75
+ name = applyPrefix(prefix, name, opts.prefixApplier);
76
+ }
77
+ const boolValue = applyBoolean(groupValue, ast.operator === void 0);
78
+ const operator2 = (_m = ast.propertyOperator) == null ? void 0 : _m.value;
79
+ return self_.normalize(ast.value, name, boolValue, operator2);
80
+ }
81
+ }
82
+ if (ast instanceof GroupNode) {
83
+ const _prefix = ast.prefix instanceof ConditionNode && ast.prefix.value instanceof VariableNode ? unescape(ast.prefix.value.value.value) : void 0;
84
+ const _groupValue = ast.prefix instanceof ConditionNode ? ast.prefix.operator === void 0 : !(ast.prefix instanceof ValidToken);
85
+ const applied = applyPrefix(prefix, _prefix ?? "", opts.prefixApplier);
86
+ return self_.normalize(ast.expression, applied, applyBoolean(groupValue, _groupValue), operator);
87
+ }
88
+ if (ast instanceof ExpressionNode) {
89
+ const left = self_.normalize(ast.left, prefix, groupValue, operator);
90
+ const right = self_.normalize(ast.right, prefix, groupValue, operator);
91
+ const type = groupValue === false ? OPPOSITE[ast.operator.type] : ast.operator.type;
92
+ return new Expression({ operator: type, left, right });
93
+ }
94
+ return unreachable();
95
+ }
96
+ }
97
+ export {
98
+ NormalizeMixin
99
+ };
@@ -0,0 +1,11 @@
1
+ import { type ParserResults, type Position } from "../types/ast.js";
2
+ export declare class ValidateMixin<T extends {}> {
3
+ /**
4
+ * Allows pre-validating ASTs for syntax highlighting purposes.
5
+ * Works similar to evaluate. Internally it will use the prefixApplier, keyParser, and valueValidator (instead of comparer).
6
+ *
7
+ * The context does not need to be passed. If it's not passed, the function will not attempt to get the values (so it will not error) and the contextValue param of the valueValidator will be undefined.
8
+ */
9
+ validate(ast: ParserResults, context?: Record<string, any>): (Position & T)[];
10
+ }
11
+ //# sourceMappingURL=validate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/methods/validate.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,QAAQ,EAAc,MAAM,iBAAiB,CAAA;AAI/E,qBAAa,aAAa,CAAC,CAAC,SAAS,EAAE;IACtC;;;;;OAKG;IACH,QAAQ,CAAC,GAAG,EAAE,aAAa,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,CAAC,QAAQ,GAAG,CAAC,CAAC,EAAE;CAqH7E"}
@@ -0,0 +1,111 @@
1
+ import { get, isArray } from "@alanscodelog/utils";
2
+ import { ArrayNode } from "../ast/classes/ArrayNode.js";
3
+ import { ConditionNode } from "../ast/classes/ConditionNode.js";
4
+ import { ErrorToken } from "../ast/classes/ErrorToken.js";
5
+ import { ExpressionNode } from "../ast/classes/ExpressionNode.js";
6
+ import { GroupNode } from "../ast/classes/GroupNode.js";
7
+ import { ValidToken } from "../ast/classes/ValidToken.js";
8
+ import { VariableNode } from "../ast/classes/VariableNode.js";
9
+ import { applyBoolean } from "../helpers/general/applyBoolean.js";
10
+ import { applyPrefix } from "../helpers/general/applyPrefix.js";
11
+ import { TOKEN_TYPE } from "../types/ast.js";
12
+ class ValidateMixin {
13
+ /**
14
+ * Allows pre-validating ASTs for syntax highlighting purposes.
15
+ * Works similar to evaluate. Internally it will use the prefixApplier, keyParser, and valueValidator (instead of comparer).
16
+ *
17
+ * The context does not need to be passed. If it's not passed, the function will not attempt to get the values (so it will not error) and the contextValue param of the valueValidator will be undefined.
18
+ */
19
+ validate(ast, context) {
20
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
21
+ const self = this;
22
+ self._checkValidationOptions();
23
+ const opts = self.options;
24
+ if (ast instanceof ErrorToken || !ast.valid) {
25
+ throw new Error("AST node must be valid.");
26
+ }
27
+ const prefix = arguments[2];
28
+ const groupValue = arguments[3];
29
+ const results = arguments[4] ?? [];
30
+ const prefixes = arguments[5] ?? [];
31
+ let operator = arguments[6];
32
+ const self_ = this;
33
+ if (ast instanceof ConditionNode) {
34
+ if (!(ast.value instanceof GroupNode)) {
35
+ const isValue = ast.value instanceof ArrayNode || ((_b = (_a = ast.value) == null ? void 0 : _a.quote) == null ? void 0 : _b.left.type) === TOKEN_TYPE.REGEX;
36
+ const nameNode = ast.property ? ast.property : isValue ? void 0 : ast.value;
37
+ let name = nameNode ? unescape(nameNode.value.value) : void 0;
38
+ const isNested = operator !== void 0;
39
+ if (prefix !== void 0 && !isNested) {
40
+ name = name ? applyPrefix(prefix, name, opts.prefixApplier) : prefix;
41
+ }
42
+ let value;
43
+ let propertyNodes = [];
44
+ if (isNested) {
45
+ value = name;
46
+ name = prefix;
47
+ propertyNodes = [...prefixes];
48
+ } else {
49
+ propertyNodes = [...prefixes, ...nameNode ? [nameNode] : []];
50
+ value = ast.value instanceof ArrayNode ? ast.value.values : ((_d = (_c = ast.value) == null ? void 0 : _c.quote) == null ? void 0 : _d.left.type) === TOKEN_TYPE.REGEX ? ast.value : ast.property && ast.value instanceof VariableNode ? ast.value : true;
51
+ }
52
+ const propertyKeys = name ? opts.keyParser(name) : [];
53
+ const contextValue = context !== void 0 ? get(context, propertyKeys) : void 0;
54
+ const boolValue = applyBoolean(groupValue, ast.operator === void 0);
55
+ const valuePrefix = ast.value instanceof VariableNode && ast.value.prefix ? ast.value.prefix : void 0;
56
+ operator ?? (operator = ast.propertyOperator);
57
+ const isRegex = ((_f = (_e = ast.value) == null ? void 0 : _e.quote) == null ? void 0 : _f.left.type) === TOKEN_TYPE.REGEX;
58
+ const isQuoted = ((_g = ast.value) == null ? void 0 : _g.quote) !== void 0;
59
+ const isExpanded = ast.sep !== void 0;
60
+ const regexFlags = (_i = (_h = ast.value) == null ? void 0 : _h.quote) == null ? void 0 : _i.flags;
61
+ const query = {
62
+ value,
63
+ operator,
64
+ prefix: valuePrefix,
65
+ prefixes,
66
+ property: propertyNodes,
67
+ propertyKeys,
68
+ propertyName: name,
69
+ regexFlags,
70
+ isRegex,
71
+ isNegated: !boolValue,
72
+ isQuoted,
73
+ isExpanded,
74
+ condition: ast
75
+ };
76
+ const res = opts.valueValidator(contextValue, query, context);
77
+ if (res && !isArray(res))
78
+ throw new Error("The valueValidator must return an array or nothing/undefined");
79
+ if (res) {
80
+ for (const entry of res)
81
+ results.push(entry);
82
+ }
83
+ } else {
84
+ let name = unescape(ast.property.value.value);
85
+ if (prefix !== void 0) {
86
+ name = applyPrefix(prefix, name, opts.prefixApplier);
87
+ }
88
+ const boolValue = applyBoolean(groupValue, ast.operator === void 0);
89
+ if (ast.property)
90
+ prefixes.push(ast.property);
91
+ const operator2 = ast.propertyOperator;
92
+ self_.validate(ast.value, context, name, boolValue, results, prefixes, operator2);
93
+ }
94
+ }
95
+ if (ast instanceof GroupNode) {
96
+ const _prefix = ast.prefix instanceof ConditionNode && ast.prefix.value instanceof VariableNode ? ast.prefix.value : void 0;
97
+ if (_prefix)
98
+ prefixes.push(_prefix);
99
+ const _groupValue = ast.prefix instanceof ConditionNode ? ast.prefix.operator === void 0 : !(ast.prefix instanceof ValidToken);
100
+ self_.validate(ast.expression, context, applyPrefix(prefix, (_prefix == null ? void 0 : _prefix.value.value) ?? "", opts.prefixApplier), applyBoolean(groupValue, _groupValue), results, prefixes, operator);
101
+ }
102
+ if (ast instanceof ExpressionNode) {
103
+ self_.validate(ast.left, context, prefix, groupValue, results, [...prefixes], operator);
104
+ self_.validate(ast.right, context, prefix, groupValue, results, [...prefixes], operator);
105
+ }
106
+ return results;
107
+ }
108
+ }
109
+ export {
110
+ ValidateMixin
111
+ };
@@ -0,0 +1,7 @@
1
+ import pkg from "./package.json.js";
2
+ const version = pkg.version;
3
+ const repository = pkg.repository;
4
+ export {
5
+ repository,
6
+ version
7
+ };