@witchcraft/expressit 0.2.2 → 0.3.1
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/README.md +1 -2
- package/dist/Lexer.d.ts +99 -94
- package/dist/Lexer.d.ts.map +1 -1
- package/dist/Lexer.js +221 -574
- package/dist/Parser.d.ts +26 -26
- package/dist/Parser.d.ts.map +1 -1
- package/dist/Parser.js +106 -116
- package/dist/ast/builders/array.js +7 -8
- package/dist/ast/builders/condition.d.ts +1 -1
- package/dist/ast/builders/condition.d.ts.map +1 -1
- package/dist/ast/builders/condition.js +2 -1
- package/dist/ast/builders/delim.d.ts +2 -2
- package/dist/ast/builders/delim.d.ts.map +1 -1
- package/dist/ast/builders/error.d.ts +2 -2
- package/dist/ast/builders/error.d.ts.map +1 -1
- package/dist/ast/builders/expression.d.ts +2 -2
- package/dist/ast/builders/expression.d.ts.map +1 -1
- package/dist/ast/builders/expression.js +4 -8
- package/dist/ast/builders/group.d.ts +1 -1
- package/dist/ast/builders/group.d.ts.map +1 -1
- package/dist/ast/builders/group.js +8 -11
- package/dist/ast/builders/pos.d.ts +2 -2
- package/dist/ast/builders/pos.d.ts.map +1 -1
- package/dist/ast/builders/token.d.ts +2 -2
- package/dist/ast/builders/token.d.ts.map +1 -1
- package/dist/ast/builders/token.js +1 -1
- package/dist/ast/builders/type.d.ts +2 -2
- package/dist/ast/builders/type.d.ts.map +1 -1
- package/dist/ast/builders/variable.d.ts +3 -3
- package/dist/ast/builders/variable.d.ts.map +1 -1
- package/dist/ast/builders/variable.js +5 -6
- package/dist/ast/createConditionNode.d.ts +1 -1
- package/dist/ast/createConditionNode.d.ts.map +1 -1
- package/dist/ast/createConditionNode.js +1 -2
- package/dist/ast/createGroupNode.d.ts +1 -1
- package/dist/ast/createGroupNode.d.ts.map +1 -1
- package/dist/ast/createToken.d.ts +2 -2
- package/dist/ast/createToken.d.ts.map +1 -1
- package/dist/ast/createToken.js +2 -2
- package/dist/ast/error.d.ts +2 -2
- package/dist/ast/error.d.ts.map +1 -1
- package/dist/ast/error.js +1 -0
- package/dist/ast/handlers.d.ts +23 -23
- package/dist/ast/handlers.d.ts.map +1 -1
- package/dist/ast/handlers.js +23 -26
- package/dist/examples/ParserWithSqlSupport.d.ts +5 -5
- package/dist/examples/ParserWithSqlSupport.d.ts.map +1 -1
- package/dist/examples/ParserWithSqlSupport.js +22 -28
- package/dist/examples/ShortcutContextParser.js +2 -5
- package/dist/index.js +2 -2
- package/dist/internal/ExpressitError.d.ts +2 -2
- package/dist/internal/ExpressitError.d.ts.map +1 -1
- package/dist/internal/ExpressitError.js +7 -10
- package/dist/internal/checkParserOpts.js +21 -22
- package/dist/internal/escapeVariableOrPrefix.js +1 -1
- package/dist/internal/parseParserOptions.js +3 -4
- package/dist/package.json.js +2 -60
- package/dist/types/ast.d.ts +60 -58
- package/dist/types/ast.d.ts.map +1 -1
- package/dist/types/ast.js +26 -27
- package/dist/types/autocomplete.d.ts +23 -21
- package/dist/types/autocomplete.d.ts.map +1 -1
- package/dist/types/autocomplete.js +24 -21
- package/dist/types/errors.d.ts +12 -10
- package/dist/types/errors.d.ts.map +1 -1
- package/dist/types/errors.js +8 -7
- package/dist/types/index.js +2 -2
- package/dist/types/parser.d.ts +3 -3
- package/dist/types/parser.d.ts.map +1 -1
- package/dist/utils/extractTokens.js +4 -5
- package/dist/utils/generateParentsMap.js +7 -8
- package/dist/utils/getCursorInfo.js +5 -3
- package/dist/utils/getOppositeDelimiter.d.ts +2 -2
- package/dist/utils/getOppositeDelimiter.d.ts.map +1 -1
- package/dist/utils/getOppositeDelimiter.js +1 -1
- package/dist/utils/getSurroundingErrors.js +2 -3
- package/dist/utils/isBracket.js +1 -1
- package/dist/utils/isDelimiter.d.ts +2 -2
- package/dist/utils/isDelimiter.d.ts.map +1 -1
- package/dist/utils/isDelimiter.js +1 -1
- package/dist/utils/isNode.js +1 -1
- package/dist/utils/isParen.d.ts +2 -2
- package/dist/utils/isParen.d.ts.map +1 -1
- package/dist/utils/isParen.js +1 -1
- package/dist/utils/isQuote.d.ts +2 -2
- package/dist/utils/isQuote.d.ts.map +1 -1
- package/dist/utils/isQuote.js +1 -1
- package/dist/utils/isToken.js +1 -1
- package/dist/utils/prettyAst.js +10 -11
- package/package.json +19 -20
- package/src/Lexer.ts +100 -90
- package/src/Parser.ts +68 -68
- package/src/ast/builders/condition.ts +3 -3
- package/src/ast/builders/delim.ts +4 -4
- package/src/ast/builders/error.ts +3 -3
- package/src/ast/builders/expression.ts +4 -8
- package/src/ast/builders/group.ts +2 -4
- package/src/ast/builders/pos.ts +3 -3
- package/src/ast/builders/token.ts +3 -3
- package/src/ast/builders/type.ts +2 -2
- package/src/ast/builders/variable.ts +5 -5
- package/src/ast/createConditionNode.ts +2 -2
- package/src/ast/createGroupNode.ts +4 -4
- package/src/ast/createToken.ts +6 -6
- package/src/ast/error.ts +2 -2
- package/src/ast/handlers.ts +20 -20
- package/src/examples/ParserWithSqlSupport.ts +12 -6
- package/src/internal/ExpressitError.ts +6 -6
- package/src/internal/checkParserOpts.ts +13 -13
- package/src/internal/escapeVariableOrPrefix.ts +1 -1
- package/src/types/ast.ts +101 -96
- package/src/types/autocomplete.ts +26 -22
- package/src/types/errors.ts +18 -13
- package/src/types/parser.ts +3 -3
- package/src/utils/extractTokens.ts +1 -1
- package/src/utils/getCursorInfo.ts +2 -2
- package/src/utils/getOppositeDelimiter.ts +3 -3
- package/src/utils/getSurroundingErrors.ts +4 -4
- package/src/utils/isDelimiter.ts +3 -3
- package/src/utils/isParen.ts +2 -2
- package/src/utils/isQuote.ts +2 -2
- package/src/utils/prettyAst.ts +3 -3
package/src/ast/createToken.ts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { ExpressitError } from "../internal/ExpressitError.js"
|
|
2
|
-
import type { ErrorToken, RawToken,
|
|
3
|
-
import {
|
|
2
|
+
import type { ErrorToken, RawToken, TokenType, ValidToken } from "../types/ast.js"
|
|
3
|
+
import { PARSER_ERROR } from "../types/errors.js"
|
|
4
4
|
|
|
5
5
|
export function createToken<
|
|
6
|
-
TType extends
|
|
6
|
+
TType extends TokenType,
|
|
7
7
|
>(raw: { type: TType } & RawToken<ValidToken>): ValidToken<TType>
|
|
8
8
|
export function createToken(raw: RawToken<ErrorToken>): ErrorToken
|
|
9
9
|
export function createToken<
|
|
10
10
|
TValid extends boolean = boolean,
|
|
11
11
|
TType extends
|
|
12
|
-
TValid extends true ?
|
|
13
|
-
TValid extends true ?
|
|
12
|
+
TValid extends true ? TokenType : never =
|
|
13
|
+
TValid extends true ? TokenType : never
|
|
14
14
|
>(raw: RawToken<ValidToken> | RawToken<ErrorToken>): TValid extends true
|
|
15
15
|
? ValidToken<TType>
|
|
16
16
|
: ErrorToken {
|
|
17
17
|
if (raw.start === undefined || raw.end === undefined) {
|
|
18
|
-
throw new ExpressitError(
|
|
18
|
+
throw new ExpressitError(PARSER_ERROR.POSITION_ERROR, raw)
|
|
19
19
|
}
|
|
20
20
|
return {
|
|
21
21
|
...raw,
|
package/src/ast/error.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { createToken } from "./createToken.js"
|
|
2
2
|
|
|
3
|
-
import { type ErrorToken,type
|
|
3
|
+
import { type ErrorToken,type TokenType } from "../types/ast.js"
|
|
4
4
|
|
|
5
|
-
export function error<T extends
|
|
5
|
+
export function error<T extends TokenType>(pos: number, expected: T[]): ErrorToken {
|
|
6
6
|
if (pos === undefined) throw new Error("should never happen, passed undefined position for error token")
|
|
7
7
|
return createToken({ expected, start: pos, end: pos })
|
|
8
8
|
}
|
package/src/ast/handlers.ts
CHANGED
|
@@ -7,28 +7,28 @@ import { createGroupNode } from "./createGroupNode.js"
|
|
|
7
7
|
import { createToken } from "./createToken.js"
|
|
8
8
|
import { createVariableNode } from "./createVariableNode.js"
|
|
9
9
|
|
|
10
|
-
import { type AnyToken, type ArrayNode,AST_TYPE,type ConditionNode, type ErrorToken, type ExpressionNode,type FirstParam,type GroupNode, type Position, TOKEN_TYPE, type
|
|
10
|
+
import { type AnyToken, type ArrayNode,AST_TYPE,type ConditionNode, type ErrorToken, type ExpressionNode,type FirstParam,type GroupNode, type Position, TOKEN_TYPE, type TokenBoolean, type TokenDelimiter, type TokenOperator, type TokenQuote, type TokenType, type ValidToken, type VariableNode } from "../types/ast.js"
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
/* #region HELPERS */
|
|
14
|
-
function error<T extends
|
|
14
|
+
function error<T extends TokenType>(pos: number, expected: T[]): ErrorToken {
|
|
15
15
|
if (pos === undefined) throw new Error("should never happen, passed undefined position for error token")
|
|
16
16
|
return createToken({ expected, start: pos, end: pos })
|
|
17
17
|
}
|
|
18
18
|
/* #regionend */
|
|
19
19
|
|
|
20
20
|
/* #region TOKENS */
|
|
21
|
-
const operators = <T extends
|
|
21
|
+
const operators = <T extends TokenOperator>
|
|
22
22
|
(type: T) =>
|
|
23
23
|
(value: string, pos: Position): ValidToken<T> => createToken({ value, type, ...pos })
|
|
24
24
|
|
|
25
|
-
const delimiters = <T extends
|
|
25
|
+
const delimiters = <T extends TokenDelimiter>
|
|
26
26
|
(type: T) =>
|
|
27
27
|
(value: string | undefined, pos: Position): ValidToken<T> | undefined =>
|
|
28
28
|
// check must be falsy, we want to return undefined when given ""
|
|
29
29
|
value ? createToken({ value, type, ...pos }) : undefined
|
|
30
30
|
|
|
31
|
-
const maybeToken = <T extends
|
|
31
|
+
const maybeToken = <T extends TokenType> (type: T) => <TVal extends string | undefined> (value: TVal, pos: Position): TVal extends string ? ValidToken<T> : ErrorToken => {
|
|
32
32
|
if (value === undefined) {
|
|
33
33
|
return error(pos.end, [type]) as any
|
|
34
34
|
} else {
|
|
@@ -63,11 +63,11 @@ export const operator = {
|
|
|
63
63
|
|
|
64
64
|
/* #region AST NODES */
|
|
65
65
|
export function variable(
|
|
66
|
-
prefix: ValidToken<TOKEN_TYPE.VALUE> | null | undefined,
|
|
67
|
-
quoteL: AnyToken<
|
|
68
|
-
value: AnyToken<TOKEN_TYPE.VALUE> | null | undefined,
|
|
69
|
-
quoteR: AnyToken<
|
|
70
|
-
flags?: ValidToken<TOKEN_TYPE.VALUE>,
|
|
66
|
+
prefix: ValidToken<typeof TOKEN_TYPE.VALUE> | null | undefined,
|
|
67
|
+
quoteL: AnyToken<TokenQuote> | null | undefined,
|
|
68
|
+
value: AnyToken<typeof TOKEN_TYPE.VALUE> | null | undefined,
|
|
69
|
+
quoteR: AnyToken<TokenQuote> | null | undefined,
|
|
70
|
+
flags?: ValidToken<typeof TOKEN_TYPE.VALUE>,
|
|
71
71
|
): VariableNode {
|
|
72
72
|
const node: FirstParam<typeof createVariableNode> = {
|
|
73
73
|
prefix: prefix ?? undefined,
|
|
@@ -92,19 +92,19 @@ export function variable(
|
|
|
92
92
|
|
|
93
93
|
|
|
94
94
|
export function condition(
|
|
95
|
-
not: ValidToken<TOKEN_TYPE.NOT> | null | undefined,
|
|
95
|
+
not: ValidToken<typeof TOKEN_TYPE.NOT> | null | undefined,
|
|
96
96
|
property: VariableNode | null | undefined,
|
|
97
97
|
{ propertyOperator, sepL, sepR }: {
|
|
98
98
|
propertyOperator?: ConditionNode["propertyOperator"] | null
|
|
99
|
-
sepL?: ValidToken<TOKEN_TYPE.OP_EXPANDED_SEP> | null
|
|
100
|
-
sepR?: ValidToken<TOKEN_TYPE.OP_EXPANDED_SEP> | null
|
|
99
|
+
sepL?: ValidToken<typeof TOKEN_TYPE.OP_EXPANDED_SEP> | null
|
|
100
|
+
sepR?: ValidToken<typeof TOKEN_TYPE.OP_EXPANDED_SEP> | null
|
|
101
101
|
} = {},
|
|
102
102
|
value?: VariableNode | GroupNode | ArrayNode | null,
|
|
103
103
|
): ConditionNode {
|
|
104
104
|
const start = (not?.start ?? property?.start ?? sepL?.start ?? propertyOperator?.start ?? sepR?.start ?? value?.start)!
|
|
105
105
|
const end = (value?.end ?? sepR?.end ?? propertyOperator?.end ?? sepL?.end ?? property?.end ?? not?.end)!
|
|
106
106
|
const node: FirstParam<typeof createConditionNode> = {
|
|
107
|
-
value: value
|
|
107
|
+
value: value ?? error(end, [TOKEN_TYPE.VALUE]),
|
|
108
108
|
start,
|
|
109
109
|
end,
|
|
110
110
|
}
|
|
@@ -130,7 +130,7 @@ export function condition(
|
|
|
130
130
|
|
|
131
131
|
export function expression(
|
|
132
132
|
left: ConditionNode | GroupNode | null | undefined,
|
|
133
|
-
operator: ValidToken<
|
|
133
|
+
operator: ValidToken<TokenBoolean> | null | undefined,
|
|
134
134
|
right: ConditionNode | GroupNode | null | undefined,
|
|
135
135
|
): ExpressionNode {
|
|
136
136
|
return createExpressionNode({
|
|
@@ -143,11 +143,11 @@ export function expression(
|
|
|
143
143
|
}
|
|
144
144
|
|
|
145
145
|
export function group(
|
|
146
|
-
operator: ValidToken<TOKEN_TYPE.NOT> | null | undefined,
|
|
146
|
+
operator: ValidToken<typeof TOKEN_TYPE.NOT> | null | undefined,
|
|
147
147
|
prefix: ConditionNode | null | undefined,
|
|
148
|
-
parenL: ValidToken<TOKEN_TYPE.PARENL> | null | undefined,
|
|
148
|
+
parenL: ValidToken<typeof TOKEN_TYPE.PARENL> | null | undefined,
|
|
149
149
|
condition: GroupNode["expression"],
|
|
150
|
-
parenR: ValidToken<TOKEN_TYPE.PARENR> | null | undefined,
|
|
150
|
+
parenR: ValidToken<typeof TOKEN_TYPE.PARENR> | null | undefined,
|
|
151
151
|
): GroupNode {
|
|
152
152
|
return createGroupNode({
|
|
153
153
|
prefix: prefix ?? operator ?? undefined,
|
|
@@ -162,9 +162,9 @@ export function group(
|
|
|
162
162
|
}
|
|
163
163
|
|
|
164
164
|
export function array(
|
|
165
|
-
bracketL: ValidToken<TOKEN_TYPE.BRACKETL>,
|
|
165
|
+
bracketL: ValidToken<typeof TOKEN_TYPE.BRACKETL>,
|
|
166
166
|
values: VariableNode[],
|
|
167
|
-
bracketR: ValidToken<TOKEN_TYPE.BRACKETR> | null | undefined,
|
|
167
|
+
bracketR: ValidToken<typeof TOKEN_TYPE.BRACKETR> | null | undefined,
|
|
168
168
|
): ArrayNode {
|
|
169
169
|
return createArrayNode({
|
|
170
170
|
values,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { unreachable } from "@alanscodelog/utils/unreachable
|
|
1
|
+
import { unreachable } from "@alanscodelog/utils/unreachable"
|
|
2
2
|
|
|
3
3
|
import { Parser } from "../Parser.js"
|
|
4
4
|
import { AST_TYPE, type NormalizedCondition, type NormalizedExpression, type Position,TOKEN_TYPE } from "../types/ast.js"
|
|
@@ -29,7 +29,7 @@ export interface BaseOperatorDefinition {
|
|
|
29
29
|
/** How to compare the value when evualuating a condition. This is only used if using `evaluate`. */
|
|
30
30
|
valueComparer: (condition: any, contextValue: any) => boolean
|
|
31
31
|
}
|
|
32
|
-
export type
|
|
32
|
+
export type SqlParserError =
|
|
33
33
|
| "invalidKey"
|
|
34
34
|
| "unknownProperty"
|
|
35
35
|
| "unknownOperator"
|
|
@@ -53,11 +53,11 @@ export type BaseErrorTokenTypes =
|
|
|
53
53
|
*/
|
|
54
54
|
export class ParserWithSqlSupport<TErrorToken extends
|
|
55
55
|
Position & {
|
|
56
|
-
type:
|
|
56
|
+
type: SqlParserError
|
|
57
57
|
message?: string
|
|
58
58
|
} =
|
|
59
59
|
Position & {
|
|
60
|
-
type:
|
|
60
|
+
type: SqlParserError
|
|
61
61
|
message?: string
|
|
62
62
|
},
|
|
63
63
|
TPropertyDefinition extends BasePropertyDefinition = BasePropertyDefinition,
|
|
@@ -70,9 +70,13 @@ export class ParserWithSqlSupport<TErrorToken extends
|
|
|
70
70
|
|
|
71
71
|
operatorMap: Record<string, string>
|
|
72
72
|
|
|
73
|
+
propertyDefinitions: TPropertyDefinitions
|
|
74
|
+
|
|
75
|
+
operatorDefinitions: TOperatorDefinitions
|
|
76
|
+
|
|
73
77
|
constructor(
|
|
74
|
-
|
|
75
|
-
|
|
78
|
+
propertyDefinitions: TPropertyDefinitions,
|
|
79
|
+
operatorDefinitions: TOperatorDefinitions,
|
|
76
80
|
{ sqlEscapeValue }: { sqlEscapeValue: TSqlEscapeValue }
|
|
77
81
|
) {
|
|
78
82
|
const operators = []
|
|
@@ -229,6 +233,8 @@ export class ParserWithSqlSupport<TErrorToken extends
|
|
|
229
233
|
return { value: finalValue, operator: finalOperator, negate: isNegated }
|
|
230
234
|
},
|
|
231
235
|
})
|
|
236
|
+
this.propertyDefinitions = propertyDefinitions
|
|
237
|
+
this.operatorDefinitions = operatorDefinitions
|
|
232
238
|
this.operatorMap = operatorMap
|
|
233
239
|
this.sqlEscapeValue = sqlEscapeValue
|
|
234
240
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { crop } from "@alanscodelog/utils/crop
|
|
2
|
-
import { indent } from "@alanscodelog/utils/indent
|
|
3
|
-
import { pretty } from "@alanscodelog/utils/pretty
|
|
1
|
+
import { crop } from "@alanscodelog/utils/crop"
|
|
2
|
+
import { indent } from "@alanscodelog/utils/indent"
|
|
3
|
+
import { pretty } from "@alanscodelog/utils/pretty"
|
|
4
4
|
import type { Keys } from "@alanscodelog/utils/types"
|
|
5
5
|
|
|
6
|
-
import packageJson from "../../package.json"
|
|
6
|
+
import packageJson from "../../package.json" with { type: "json" }
|
|
7
7
|
const { version, repository } = packageJson
|
|
8
|
-
import type {
|
|
8
|
+
import type { ErrorInfo, ParserError } from "../types/errors.js"
|
|
9
9
|
|
|
10
10
|
/** @internal */
|
|
11
|
-
export class ExpressitError<T extends
|
|
11
|
+
export class ExpressitError<T extends ParserError> extends Error {
|
|
12
12
|
version: string = version
|
|
13
13
|
|
|
14
14
|
repo: string = repository
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { isBlank } from "@alanscodelog/utils/isBlank
|
|
2
|
-
import { pushIfNotIn } from "@alanscodelog/utils/pushIfNotIn
|
|
1
|
+
import { isBlank } from "@alanscodelog/utils/isBlank"
|
|
2
|
+
import { pushIfNotIn } from "@alanscodelog/utils/pushIfNotIn"
|
|
3
3
|
|
|
4
4
|
import { ExpressitError } from "./ExpressitError.js"
|
|
5
5
|
|
|
6
6
|
import { defaultConditionNormalizer } from "../defaults/defaultConditionNormalizer.js"
|
|
7
7
|
import { defaultValueComparer } from "../defaults/defaultValueComparer.js"
|
|
8
|
-
import {
|
|
8
|
+
import { PARSER_ERROR } from "../types/errors.js"
|
|
9
9
|
import type { FullParserOptions, ParserOptions } from "../types/parser.js"
|
|
10
10
|
|
|
11
11
|
/** @internal */
|
|
@@ -27,7 +27,7 @@ export function checkParserOpts<T>(opts: FullParserOptions<T>, evaluatorChecks:
|
|
|
27
27
|
/* #region Blank Operator Checks */
|
|
28
28
|
if (opts.expandedPropertySeparator && isBlank(opts.expandedPropertySeparator)) {
|
|
29
29
|
throw new ExpressitError(
|
|
30
|
-
|
|
30
|
+
PARSER_ERROR.CONFLICTING_OPTIONS_ERROR,
|
|
31
31
|
{ prohibited: [""], invalid: opts.expandedPropertySeparator },
|
|
32
32
|
`expandedPropertySeparator cannot be blank`,
|
|
33
33
|
)
|
|
@@ -35,7 +35,7 @@ export function checkParserOpts<T>(opts: FullParserOptions<T>, evaluatorChecks:
|
|
|
35
35
|
const customInvalid = opts.customPropertyOperators?.find(_ => isBlank(_))
|
|
36
36
|
if (customInvalid !== undefined) {
|
|
37
37
|
throw new ExpressitError(
|
|
38
|
-
|
|
38
|
+
PARSER_ERROR.CONFLICTING_OPTIONS_ERROR,
|
|
39
39
|
{ prohibited: [""], invalid: customInvalid },
|
|
40
40
|
`customPropertyOperators cannot contain blank entries`,
|
|
41
41
|
)
|
|
@@ -43,7 +43,7 @@ export function checkParserOpts<T>(opts: FullParserOptions<T>, evaluatorChecks:
|
|
|
43
43
|
const prefixInvalid = opts.prefixableStrings?.find(_ => isBlank(_))
|
|
44
44
|
if (prefixInvalid !== undefined) {
|
|
45
45
|
throw new ExpressitError(
|
|
46
|
-
|
|
46
|
+
PARSER_ERROR.CONFLICTING_OPTIONS_ERROR,
|
|
47
47
|
{ prohibited: [""], invalid: prefixInvalid },
|
|
48
48
|
`prefixableStrings cannot contain blank entries`,
|
|
49
49
|
)
|
|
@@ -54,7 +54,7 @@ export function checkParserOpts<T>(opts: FullParserOptions<T>, evaluatorChecks:
|
|
|
54
54
|
?.value
|
|
55
55
|
if (invalid !== undefined) {
|
|
56
56
|
throw new ExpressitError(
|
|
57
|
-
|
|
57
|
+
PARSER_ERROR.CONFLICTING_OPTIONS_ERROR,
|
|
58
58
|
{ prohibited: [""], invalid },
|
|
59
59
|
`keywords.${key} cannot contain entries with blank values`,
|
|
60
60
|
)
|
|
@@ -77,7 +77,7 @@ export function checkParserOpts<T>(opts: FullParserOptions<T>, evaluatorChecks:
|
|
|
77
77
|
const invalidPrefixableString = opts.prefixableStrings?.find(val => all.includes(val))
|
|
78
78
|
if (invalidPrefixableString) {
|
|
79
79
|
throw new ExpressitError(
|
|
80
|
-
|
|
80
|
+
PARSER_ERROR.CONFLICTING_OPTIONS_ERROR,
|
|
81
81
|
{ prohibited: all, invalid: invalidPrefixableString },
|
|
82
82
|
`prefixableStrings ${messageInvalidAny} "${invalidPrefixableString}"`,
|
|
83
83
|
)
|
|
@@ -87,7 +87,7 @@ export function checkParserOpts<T>(opts: FullParserOptions<T>, evaluatorChecks:
|
|
|
87
87
|
.find(_ => _ === opts.expandedPropertySeparator as any)
|
|
88
88
|
if (invalidExpandedPropertySeparator) {
|
|
89
89
|
throw new ExpressitError(
|
|
90
|
-
|
|
90
|
+
PARSER_ERROR.CONFLICTING_OPTIONS_ERROR,
|
|
91
91
|
{ prohibited: allKeywords, invalid: invalidExpandedPropertySeparator },
|
|
92
92
|
`expandedPropertySeparator ${messageInvalidBool} "${invalidExpandedPropertySeparator}"`,
|
|
93
93
|
)
|
|
@@ -98,7 +98,7 @@ export function checkParserOpts<T>(opts: FullParserOptions<T>, evaluatorChecks:
|
|
|
98
98
|
: undefined
|
|
99
99
|
if (invalidCustomPropertyOperator) {
|
|
100
100
|
throw new ExpressitError(
|
|
101
|
-
|
|
101
|
+
PARSER_ERROR.CONFLICTING_OPTIONS_ERROR,
|
|
102
102
|
{ prohibited: keywords, invalid: invalidCustomPropertyOperator },
|
|
103
103
|
`customPropertyOperator ${messageInvalidBool} "${invalidCustomPropertyOperator}"`,
|
|
104
104
|
)
|
|
@@ -115,7 +115,7 @@ export function checkParserOpts<T>(opts: FullParserOptions<T>, evaluatorChecks:
|
|
|
115
115
|
|
|
116
116
|
if (requireCustomNormalizer.length > 0 && opts.conditionNormalizer === defaultConditionNormalizer) {
|
|
117
117
|
throw new ExpressitError(
|
|
118
|
-
|
|
118
|
+
PARSER_ERROR.OPTION_REQUIRED_ERROR,
|
|
119
119
|
{ options: requireCustomNormalizer, requires: "conditionNormalizer" },
|
|
120
120
|
`A custom conditionNormalizer function must be specified when using the following options: ${requireCustomNormalizer.join(", ")}`,
|
|
121
121
|
)
|
|
@@ -126,7 +126,7 @@ export function checkParserOpts<T>(opts: FullParserOptions<T>, evaluatorChecks:
|
|
|
126
126
|
|
|
127
127
|
if (requireCustomComparer.length > 0 && opts.valueComparer === defaultValueComparer) {
|
|
128
128
|
throw new ExpressitError(
|
|
129
|
-
|
|
129
|
+
PARSER_ERROR.OPTION_REQUIRED_ERROR,
|
|
130
130
|
{ options: requireCustomComparer, requires: "valueComparer" },
|
|
131
131
|
`A custom valueComparer function must be specified when using the following options: ${requireCustomComparer.join(", ")}`,
|
|
132
132
|
)
|
|
@@ -135,7 +135,7 @@ export function checkParserOpts<T>(opts: FullParserOptions<T>, evaluatorChecks:
|
|
|
135
135
|
if (validatorChecks) {
|
|
136
136
|
if (opts.valueValidator === undefined) {
|
|
137
137
|
throw new ExpressitError(
|
|
138
|
-
|
|
138
|
+
PARSER_ERROR.OPTION_REQUIRED_ERROR,
|
|
139
139
|
{ requires: "valueValidator" },
|
|
140
140
|
`A custom valueValidator function must be specified when using the validate method.`,
|
|
141
141
|
)
|