diff --git a/.oxfmtrc.json b/.oxfmtrc.json index 4e98fd9c6..75785910b 100644 --- a/.oxfmtrc.json +++ b/.oxfmtrc.json @@ -17,8 +17,6 @@ "packages/cli/AGENTS.md", "packages/mcp-server-mocks/src/fixtures/**", "**/worker-configuration.d.ts", - "**/tsconfig*.json", - "packages/toolkit-core/src/generated/**", - "packages/toolkit-core/test/fixtures/**" + "**/tsconfig*.json" ] } diff --git a/.oxlintrc.json b/.oxlintrc.json index 2bb513015..695f7bab6 100644 --- a/.oxlintrc.json +++ b/.oxlintrc.json @@ -12,8 +12,6 @@ "apps/cli-docs/**", "**/worker-configuration.d.ts", "**/tsconfig*.json", - "packages/toolkit-core/src/generated/**", - "packages/toolkit-core/test/fixtures/**", "packages/mcp-server-mocks/src/fixtures/**", "packages/cli/test/init-eval/templates/sveltekit-app/**" ], diff --git a/package.json b/package.json index 7019f8c3b..d2b3cfc4d 100644 --- a/package.json +++ b/package.json @@ -28,8 +28,7 @@ "dev:stdio": "pnpm --filter '@sentry/mcp-server...' --if-present run build && dotenv -e .env -e .env.local -- pnpm --parallel --filter @sentry/mcp-server --filter @sentry/mcp-core --filter @sentry/mcp-server-mocks --if-present run dev", "build": "dotenv -e .env -e .env.local -- pnpm -r --filter '!sentry' --filter '!sentry-cli-docs' --if-present run build", "build:cli": "dotenv -e .env -e .env.local -- pnpm --filter sentry run build && pnpm --filter sentry-cli-docs run build", - "check:generated": "pnpm --filter @sentry/mcp-core generate-definitions && pnpm run generate:parsers && git diff --exit-code -- packages/mcp-core/src/toolDefinitions.json packages/mcp-core/src/skillDefinitions.json plugins/sentry-mcp/agents/sentry-mcp.md plugins/sentry-mcp-experimental/agents/sentry-mcp.md packages/toolkit-core/src/generated", - "generate:parsers": "node scripts/generate-parsers.mjs packages/toolkit-core", + "check:generated": "pnpm --filter @sentry/mcp-core generate-definitions && git diff --exit-code -- packages/mcp-core/src/toolDefinitions.json packages/mcp-core/src/skillDefinitions.json plugins/sentry-mcp/agents/sentry-mcp.md plugins/sentry-mcp-experimental/agents/sentry-mcp.md", "deploy:docs": "pnpm --filter sentry run generate:schema && pnpm --filter sentry run generate:docs && pnpm --filter sentry-cli-docs run build && pnpm --filter sentry-cli-docs run deploy", "eval": "pnpm --filter '@sentry/mcp-server-evals...' --if-present run build && dotenv -e .env -e .env.local -- pnpm --filter @sentry/mcp-server-evals run eval", "eval:ci": "pnpm --filter '@sentry/mcp-server-evals...' --if-present run build && CI=true dotenv -e .env -e .env.local -- pnpm --stream -r run eval:ci", diff --git a/packages/cli/test/lib/search-query.test.ts b/packages/cli/test/lib/search-query.test.ts index 9de8b7040..a51a4a972 100644 --- a/packages/cli/test/lib/search-query.test.ts +++ b/packages/cli/test/lib/search-query.test.ts @@ -435,7 +435,7 @@ describe("sanitizeQuery: edge cases", () => { describe("sanitizeQuery: regex filters", () => { // How the grammar reads regex patterns and keys is tested in - // packages/toolkit-core/src/search-syntax.test.ts. These cover the + // @sentry/search-syntax (getsentry/sentry). These cover the // sanitizer: patterns survive AND stripping and OR rewriting untouched. test("preserves repeated whitespace inside a pattern", () => { expect(sanitizeQuery("message://a AND b//")).toBe( diff --git a/packages/mcp-core/package.json b/packages/mcp-core/package.json index 8227c2949..123d00191 100644 --- a/packages/mcp-core/package.json +++ b/packages/mcp-core/package.json @@ -175,6 +175,7 @@ "@modelcontextprotocol/server": "catalog:", "@sentry/api": "catalog:", "@sentry/core": "catalog:", + "@sentry/search-syntax": "catalog:", "@sentry/toolkit-core": "workspace:*", "ai": "catalog:", "dotenv": "catalog:", diff --git a/packages/mcp-core/src/tools/support/search-events/utils.test.ts b/packages/mcp-core/src/tools/support/search-events/utils.test.ts index 80230886c..a7b9244fa 100644 --- a/packages/mcp-core/src/tools/support/search-events/utils.test.ts +++ b/packages/mcp-core/src/tools/support/search-events/utils.test.ts @@ -365,7 +365,7 @@ describe("search query helpers", () => { }); // Which key shapes can carry a regex is tested with the grammar in - // packages/toolkit-core/src/search-syntax.test.ts. + // @sentry/search-syntax (getsentry/sentry). it("should detect regex filters and other filters inside parentheses", () => { expect(looksLikeSentrySearchSyntax("(message://a b//)", "logs")).toBe(true); // The parser reads filters inside parentheses like any other filter. diff --git a/packages/mcp-core/src/tools/support/search-events/utils.ts b/packages/mcp-core/src/tools/support/search-events/utils.ts index d759f30aa..564aacf22 100644 --- a/packages/mcp-core/src/tools/support/search-events/utils.ts +++ b/packages/mcp-core/src/tools/support/search-events/utils.ts @@ -3,9 +3,8 @@ import { type FilterToken, type ParseResultToken, parseSearch, - TermOperator, - Token, -} from "@sentry/toolkit-core/search-syntax"; +} from "@sentry/search-syntax/parser"; +import { TermOperator, Token } from "@sentry/search-syntax/tokens"; import { getActiveSpan } from "@sentry/core"; import { z } from "zod"; import type { diff --git a/packages/toolkit-core/README.md b/packages/toolkit-core/README.md index 72fb2905d..886a48a5e 100644 --- a/packages/toolkit-core/README.md +++ b/packages/toolkit-core/README.md @@ -41,14 +41,12 @@ types. Each product keeps its own response validation. ## Search syntax -`search-syntax` parses Sentry search queries with the Sentry frontend's own -grammar. `grammar/search-syntax.pegjs` is an unchanged copy of -[`static/app/components/searchSyntax/grammar.pegjs`](https://github.com/getsentry/sentry/blob/master/static/app/components/searchSyntax/grammar.pegjs), -and `test/fixtures/search-syntax/` is a copy of the `fixtures/search-syntax` -cases the frontend and `event_search.py` both test against. `parseSearch` -returns the frontend's token tree, minus validation: `TokenConverter` never -marks tokens invalid or fills `parsed` values. A product that needs those -subclasses `TokenConverter` and passes it as `converter`. +Search queries are parsed with +[`@sentry/search-syntax`](https://www.npmjs.com/package/@sentry/search-syntax), +the Sentry frontend's own grammar and structural parser, published from +[`static/packages/search-syntax`](https://github.com/getsentry/sentry/tree/master/static/packages/search-syntax) +in getsentry/sentry. Grammar changes and their tests (including the +`fixtures/search-syntax` cases shared with `event_search.py`) live there. `search-query` uses that parser to rewrite queries the API would reject: explicit `AND` is dropped, and `OR` on one key becomes an in-list. With @@ -56,11 +54,3 @@ explicit `AND` is dropped, and `OR` on one key becomes an in-list. With `substatus:[…]` and unwraps parentheses, which the issues endpoint doesn't support. It returns the rewrite notes and throws `SearchQueryError` for anything it can't rewrite; each product decides how to report them. - -The parser is compiled ahead of time into `src/generated/` and committed, -since this package has no build step. Its types live in -`grammar/search-syntax.d.ts`. After editing either file, run -`pnpm run generate:parsers`; the pre-commit hook does this for staged -grammar changes, and `pnpm run check:generated` fails in CI when -the committed parser is out of date. When updating the grammar from upstream, -copy the fixtures too. diff --git a/packages/toolkit-core/grammar/search-syntax.d.ts b/packages/toolkit-core/grammar/search-syntax.d.ts deleted file mode 100644 index 51dd8ec90..000000000 --- a/packages/toolkit-core/grammar/search-syntax.d.ts +++ /dev/null @@ -1,25 +0,0 @@ -/** - * Options the search grammar reads from `options`. The grammar builds every - * token through `TokenConverter`, so callers decide the token shapes and the - * key-type predicates. See `src/search-syntax.ts` for the default converter. - */ -export type SearchGrammarOptions = { - /** Constructed with `{ text, location, config }` once per parse. */ - TokenConverter: new (opts: never) => unknown; - TermOperator: { DEFAULT: string }; - FilterType: Record; - config: unknown; - startRule?: "search"; -}; - -export declare class SyntaxError extends Error { - expected: unknown; - found: string | null; - location: unknown; -} - -/** Parse a search query. Throws {@link SyntaxError} when it does not match. */ -export declare function parse( - input: string, - options: SearchGrammarOptions, -): unknown[]; diff --git a/packages/toolkit-core/grammar/search-syntax.pegjs b/packages/toolkit-core/grammar/search-syntax.pegjs deleted file mode 100644 index 2ffab55dd..000000000 --- a/packages/toolkit-core/grammar/search-syntax.pegjs +++ /dev/null @@ -1,541 +0,0 @@ -{ - const {TokenConverter, TermOperator, FilterType, config} = options; - const tc = new TokenConverter({text, location, config}); - - const opDefault = TermOperator.DEFAULT; -} - -search - = space:spaces terms:term* { - return [space, ...terms.flat()]; - } - -term - = (boolean_operator / paren_group / open_paren / closed_paren / filter / free_text) spaces - -term_no_paren - = (boolean_operator / paren_group / filter / free_text) spaces - -boolean_operator - = (or_operator / and_operator) { - return tc.tokenLogicBoolean(text().toUpperCase()); - } - -paren_group - = open_paren spaces:spaces inner:term_no_paren* closed_paren &{ - return tc.predicateParenGroup(); - } { - return tc.tokenLogicGroup([spaces, ...inner].flat()); - } - -free_text - = free_text_quoted / free_text_unquoted - -free_text_unquoted - = (!filter_start !boolean_operator (free_parens / [^()\n ]+) spaces)+ { - return tc.tokenFreeText(text(), false); - } - -free_text_quoted - = value:quoted_value { - return tc.tokenFreeText(value.value, true); - } - -free_parens - = open_paren free_text? closed_paren - -// All key:value filter types - -filter_start - = negation? ((array_includes_key / text_key / search_key) sep / aggregate_filter_start) - -aggregate_filter_start - = &aggregate_key_start &aggregate_filter - -aggregate_key_start - = [a-zA-Z0-9_.-]+ "(" - -filter - = date_filter - / specific_date_filter - / rel_date_filter - / duration_filter - / size_filter - / boolean_filter - / numeric_in_filter - / numeric_filter - / aggregate_filter - / has_filter - / is_filter - / regex_filter - / array_includes_filter - / text_in_filter - / text_filter - -aggregate_filter - = aggregate_duration_filter - / aggregate_size_filter - / aggregate_numeric_filter - / aggregate_percentage_filter - / aggregate_date_filter - / aggregate_rel_date_filter - -// filter for dates -date_filter - = key:search_key sep op:operator value:iso_8601_date_format &{ - return tc.predicateFilter(FilterType.DATE, key, value, op) - } { - return tc.tokenFilter(FilterType.DATE, key, value, op, false); - } - -// filter for exact dates -specific_date_filter - = key:search_key sep value:iso_8601_date_format &{ - return tc.predicateFilter(FilterType.SPECIFIC_DATE, key) - } { - return tc.tokenFilter(FilterType.SPECIFIC_DATE, key, value, opDefault, false); - } - -// filter for relative dates -rel_date_filter - = key:search_key sep value:rel_date_format &{ - return tc.predicateFilter(FilterType.RELATIVE_DATE, key) - } { - return tc.tokenFilter(FilterType.RELATIVE_DATE, key, value, opDefault, false); - } - -// filter for durations -duration_filter - = negation:negation? key:search_key sep op:operator? value:duration_format &{ - return tc.predicateFilter(FilterType.DURATION, key) - } { - return tc.tokenFilter(FilterType.DURATION, key, value, op, !!negation); - } - -// filter for file size -size_filter - = negation:negation? key:search_key sep op:operator? value:size_format &{ - return tc.predicateFilter(FilterType.SIZE, key) - } { - return tc.tokenFilter(FilterType.SIZE, key, value, op, !!negation); - } - -// boolean comparison filter -boolean_filter - = negation:negation? key:search_key sep value:boolean_value &{ - return tc.predicateFilter(FilterType.BOOLEAN, key) - } { - return tc.tokenFilter(FilterType.BOOLEAN, key, value, opDefault, !!negation); - } - -// numeric in filter -numeric_in_filter - = negation:negation? key:search_key sep value:numeric_in_list &{ - return tc.predicateFilter(FilterType.NUMERIC_IN, key) - } { - return tc.tokenFilter(FilterType.NUMERIC_IN, key, value, opDefault, !!negation); - } - -// numeric comparison filter -numeric_filter - = negation:negation? key:search_key sep op:operator? value:numeric_value &{ - return tc.predicateFilter(FilterType.NUMERIC, key) - } { - return tc.tokenFilter(FilterType.NUMERIC, key, value, op, !!negation); - } - -// aggregate duration filter -aggregate_duration_filter - = negation:negation? key:aggregate_key sep op:operator? value:duration_format &{ - return tc.predicateFilter(FilterType.AGGREGATE_DURATION, key) - } { - return tc.tokenFilter(FilterType.AGGREGATE_DURATION, key, value, op, !!negation); - } - -// aggregate file size filter -aggregate_size_filter - = negation:negation? key:aggregate_key sep op:operator? value:size_format &{ - return tc.predicateFilter(FilterType.AGGREGATE_SIZE, key) - } { - return tc.tokenFilter(FilterType.AGGREGATE_SIZE, key, value, op, !!negation); - } - -// aggregate percentage filter -aggregate_percentage_filter - = negation:negation? key:aggregate_key sep op:operator? value:percentage_format &{ - return tc.predicateFilter(FilterType.AGGREGATE_PERCENTAGE, key) - } { - return tc.tokenFilter(FilterType.AGGREGATE_PERCENTAGE, key, value, op, !!negation); - } - -// aggregate numeric filter -aggregate_numeric_filter - = negation:negation? key:aggregate_key sep op:operator? value:numeric_value &{ - return tc.predicateFilter(FilterType.AGGREGATE_NUMERIC, key) - } { - return tc.tokenFilter(FilterType.AGGREGATE_NUMERIC, key, value, op, !!negation); - } - -// aggregate date filter -aggregate_date_filter - = negation:negation? key:aggregate_key sep op:operator? value:iso_8601_date_format &{ - return tc.predicateFilter(FilterType.AGGREGATE_DATE, key) - } { - return tc.tokenFilter(FilterType.AGGREGATE_DATE, key, value, op, !!negation); - } - -// filter for relative dates -aggregate_rel_date_filter - = negation:negation? key:aggregate_key sep op:operator? value:rel_date_format &{ - return tc.predicateFilter(FilterType.AGGREGATE_RELATIVE_DATE, key) - } { - return tc.tokenFilter(FilterType.AGGREGATE_RELATIVE_DATE, key, value, op, !!negation); - } - -// has filter for not null type checks -has_filter - = negation:negation? &"has:" key:search_key sep value:(search_value/search_key) &{ - return tc.predicateFilter(FilterType.HAS, key) - } { - return tc.tokenFilter(FilterType.HAS, key, value, opDefault, !!negation); - } - -// is filter. Specific to issue search -is_filter - = negation:negation? &"is:" key:search_key sep value:search_value &{ - return tc.predicateFilter(FilterType.IS, key) - } { - return tc.tokenFilter(FilterType.IS, key, value, opDefault, !!negation); - } - -// Array membership filter, eg. `foo[*]:value`. The `[*]` on the key carries the -// operation, so it uses the default operator (`:`) with `!` for negation. -array_includes_filter - = negation:negation? - key:array_includes_key - sep - value:search_value &{ - return tc.predicateFilter(FilterType.ARRAY_INCLUDES, key) - } { - return tc.tokenFilter( - FilterType.ARRAY_INCLUDES, - key, - value, - opDefault, - !!negation, - undefined, - ); - } - -regex_filter - = negation:negation? - key:(array_includes_key / text_key) - sep - value:regex_value { - return tc.tokenRegexFilter(key, value.literal, value.pattern, !!negation); - } - -regex_value - = "//" pattern:regex_pattern "//" &end_value { - return {pattern, literal: tc.tokenValueText(text(), false)}; - } - -regex_pattern - = (!("//" end_value) [^\n])* { - return tc.tokenValueText(text(), false); - } - -// in filter key:[val1, val2] -text_in_filter - = negation:negation? - key:text_key - sep - wildcard_op:wildcard_op? - value:text_in_list &{ - return tc.predicateFilter(FilterType.TEXT_IN, key) - } { - const wildcard = wildcard_op ? wildcard_op.join("") : undefined; - return tc.tokenFilter( - FilterType.TEXT_IN, - key, - value, - opDefault, - !!negation, - wildcard, - ); - } - -// standard key:val filter -// -// The text_filter is a little special since it may not have an operator -// depending on the configuration of the search parser, thus we have a -// predicate for the operator. -text_filter - = negation:negation? - key:text_key - sep - wildcard_op:wildcard_op? - op:(operator &{ return tc.predicateTextOperator(key); })? - value:search_value &{ - return tc.predicateFilter(FilterType.TEXT, key) - } { - const wildcard = wildcard_op ? wildcard_op.join("") : undefined; - return tc.tokenFilter( - FilterType.TEXT, - key, - value, - op ? op[0] : opDefault, - !!negation, - wildcard, - ); - } - -// Filter keys -key - = key:$[a-zA-Z0-9_.-]+ { - return tc.tokenKeySimple(key, false); - } - -escaped_key - = key:$[a-zA-Z0-9_.:-]+ { - return tc.tokenKeySimple(key, false); - } - -quoted_key - = '"' key:escaped_key '"' { - return tc.tokenKeySimple(key.value, true); - } - -explicit_flag_key - = prefix:"flags" open_bracket key:escaped_key closed_bracket { - return tc.tokenKeyExplicitFlag(prefix, key); - } - -explicit_string_flag_key - = prefix:"flags" open_bracket key:escaped_key spaces comma spaces 'string' closed_bracket { - return tc.tokenKeyExplicitStringFlag(prefix, key) - } - -explicit_number_flag_key - = prefix:"flags" open_bracket key:escaped_key spaces comma spaces 'number' closed_bracket { - return tc.tokenKeyExplicitNumberFlag(prefix, key) - } - -explicit_tag_key - = prefix:"tags" open_bracket key:escaped_key closed_bracket { - return tc.tokenKeyExplicitTag(prefix, key); - } - -explicit_string_tag_key - = prefix:"tags" open_bracket key:escaped_key spaces comma spaces 'string' closed_bracket { - return tc.tokenKeyExplicitStringTag(prefix, key) - } - -explicit_number_tag_key - = prefix:"tags" open_bracket key:escaped_key spaces comma spaces 'number' closed_bracket { - return tc.tokenKeyExplicitNumberTag(prefix, key) - } - -explicit_boolean_tag_key - = prefix:"tags" open_bracket key:escaped_key spaces comma spaces 'boolean' closed_bracket { - return tc.tokenKeyExplicitBooleanTag(prefix, key) - } - -explicit_array_tag_key - = prefix:"tags" open_bracket key:escaped_key spaces comma spaces 'array' closed_bracket { - return tc.tokenKeyExplicitArrayTag(prefix, key) - } - -// `[*]` is the required array membership operator ("any element equals value"), -// the array analogue of scalar `:`. A future `[N]` would target one index. -array_access_suffix = open_bracket "*" closed_bracket - -array_includes_tag_key - = prefix:"tags" open_bracket key:escaped_key array_access_suffix spaces comma spaces 'array' closed_bracket { - return tc.tokenKeyArrayIncludes(tc.tokenKeyExplicitArrayTag(prefix, key), "*"); - } - -array_includes_attr_key - = base:key array_access_suffix { - return tc.tokenKeyArrayIncludes(base, "*"); - } - -array_includes_key - = array_includes_tag_key / array_includes_attr_key - -aggregate_key - = name:key open_paren s1:spaces args:function_args? s2:spaces closed_paren { - return tc.tokenKeyAggregate(name, args, s1, s2); - } - -function_args - = arg1:aggregate_param - args:(spaces comma spaces (!comma aggregate_param)?)* { - return tc.tokenKeyAggregateArgs(arg1, args); - } - -aggregate_param - = explicit_tag_aggregate_param / quoted_aggregate_param / raw_aggregate_param - -raw_aggregate_param - = param:$[^()\t\n, \"]+ { - return tc.tokenKeyAggregateParam(param, false); - } - -quoted_aggregate_param - = '"' param:$('\\"' / [^\t\n\"])* '"' { - return tc.tokenKeyAggregateParam(`"${param}"`, true); - } - -explicit_tag_aggregate_param - = key:(explicit_tag_key / explicit_string_tag_key / explicit_number_tag_key / explicit_boolean_tag_key) { - return tc.tokenKeyAggregateParam(key.text, false); - } - -search_key - = explicit_number_flag_key / explicit_number_tag_key / explicit_boolean_tag_key / key / quoted_key - -text_key - = explicit_flag_key / explicit_string_flag_key / explicit_tag_key / explicit_string_tag_key / explicit_array_tag_key / search_key - -// Filter values - -value - = value:$[^()\t\n ]* { - return tc.tokenValueText(value, false); - } - -quoted_value - = '"' value:$('\\"' / [^"])* '"' { - return tc.tokenValueText(value, true); - } - -in_value - = (&in_value_termination in_value_char)+ { - return tc.tokenValueText(text(), false); - } - -text_in_value - = quoted_value / in_value - -search_value - = quoted_value / value - -numeric_value - = value:("-"? numeric) unit:(number_unit)? &(end_value / comma / closed_bracket) { - return tc.tokenValueNumber(value.join(''), unit); - } - -boolean_value - = value:("true"i / "1" / "false"i / "0") &end_value { - return tc.tokenValueBoolean(value); - } - -text_in_list - = open_bracket - item1:text_in_value - items:(spaces comma spaces (!comma text_in_value)?)* - closed_bracket - &end_value { - return tc.tokenValueTextList(item1, items); - } - -numeric_in_list - = open_bracket - item1:numeric_value - items:(spaces comma spaces (!comma numeric_value)?)* - closed_bracket - &end_value { - return tc.tokenValueNumberList(item1, items); - } - -// NOTE: These wildcard operators are internal implementation details and -// should not be included in product docs. Users should use `*` instead. -wildcard_op - = wildcard_unicode - (contains / starts_with / ends_with ) - wildcard_unicode - -// See: https://stackoverflow.com/a/39617181/790169 -in_value_termination - = in_value_char (!in_value_end in_value_char)* in_value_end - -in_value_char - = [^(), ] - -in_value_end - = closed_bracket / (spaces comma) - -// Format values - -// XXX: Since pegjs does not support regex there is no easy way to repeat -// groups n times. So we have some dumb tokens here to handle that. We don't do -// this in the backend grammar since we just use regex there. -num2 = [0-9] [0-9] -num4 = [0-9] [0-9] [0-9] [0-9] - -date_format = num4 "-" num2 "-" num2 -time_format = "T" num2 ":" num2 ":" num2 ("." ms_format)? -ms_format = [0-9] [0-9]? [0-9]? [0-9]? [0-9]? [0-9]? -tz_format = [+-] num2 ":" num2 - -iso_8601_date_format - = date:date_format time:time_format? tz:("Z" / tz_format)? &end_value { - return tc.tokenValueIso8601Date(text(), date, time, tz); - } - -rel_date_format - = sign:[+-] value:$[0-9]+ unit:[wdhm] &end_value { - return tc.tokenValueRelativeDate(value, sign, unit); - } - -duration_format - = value:numeric - unit:(duration_unit) - &end_value { - return tc.tokenValueDuration(value, unit); - } - -size_format - = value:numeric - unit:(size_unit) - &end_value { - return tc.tokenValueSize(value, unit); - } - -percentage_format - = value:numeric "%" { - return tc.tokenValuePercentage(value); - } - -// Units for special values -number_unit = "k"i/"m"i/"b"i - -duration_unit = "ms"/"s"/"min"/"m"/"hr"/"h"/"day"/"d"/"wk"/"w" -size_unit = bit_unit / byte_unit - -bit_unit = "bit"i / "kib"i / "mib"i / "gib"i / "tib"i / "pib"i / "eib"i / "zib"i / "yib"i -byte_unit = "bytes"i / "nb"i / "kb"i / "mb"i / "gb"i / "tb"i / "pb"i / "eb"i / "zb"i / "yb"i - -// NOTE: the order in which these operators are listed matters because for -// example, if < comes before <= it will match that even if the operator is <= -operator = ">=" / "<=" / ">" / "<" / "=" / "!=" -or_operator = "OR"i &end_value -and_operator = "AND"i &end_value -numeric = [0-9]+ ("." [0-9]*)? { return text(); } -open_paren = "(" { return tc.tokenLParen(text()); } -closed_paren = ")" { return tc.tokenRParen(text()); } -open_bracket = "[" -closed_bracket = "]" -sep = ":" -negation = "!" -// NOTE: These wildcard operators are internal implementation details and -// should not be included in product docs. Users should use `*` instead. -wildcard_unicode = [\uF00D] -contains = "Contains" -starts_with = "StartsWith" -ends_with = "EndsWith" -comma = "," -spaces = " "* { return tc.tokenSpaces(text()) } - -end_value = [\t\n )] / !. diff --git a/packages/toolkit-core/package.json b/packages/toolkit-core/package.json index 3405dd814..e9969e777 100644 --- a/packages/toolkit-core/package.json +++ b/packages/toolkit-core/package.json @@ -59,10 +59,6 @@ "types": "./src/search-query.ts", "default": "./src/search-query.ts" }, - "./search-syntax": { - "types": "./src/search-syntax.ts", - "default": "./src/search-syntax.ts" - }, "./sentry-host": { "types": "./src/sentry-host.ts", "default": "./src/sentry-host.ts" @@ -77,6 +73,9 @@ "test:ci": "vitest run --reporter=default --reporter=junit --outputFile=tests.junit.xml", "tsc": "tsc --noEmit" }, + "dependencies": { + "@sentry/search-syntax": "catalog:" + }, "devDependencies": { "typescript": "catalog:", "vitest": "catalog:" diff --git a/packages/toolkit-core/src/generated/search-syntax-grammar.d.ts b/packages/toolkit-core/src/generated/search-syntax-grammar.d.ts deleted file mode 100644 index bbc26e0a6..000000000 --- a/packages/toolkit-core/src/generated/search-syntax-grammar.d.ts +++ /dev/null @@ -1,27 +0,0 @@ -// Auto-generated by scripts/generate-parsers.mjs — DO NOT EDIT - -/** - * Options the search grammar reads from `options`. The grammar builds every - * token through `TokenConverter`, so callers decide the token shapes and the - * key-type predicates. See `src/search-syntax.ts` for the default converter. - */ -export type SearchGrammarOptions = { - /** Constructed with `{ text, location, config }` once per parse. */ - TokenConverter: new (opts: never) => unknown; - TermOperator: { DEFAULT: string }; - FilterType: Record; - config: unknown; - startRule?: "search"; -}; - -export declare class SyntaxError extends Error { - expected: unknown; - found: string | null; - location: unknown; -} - -/** Parse a search query. Throws {@link SyntaxError} when it does not match. */ -export declare function parse( - input: string, - options: SearchGrammarOptions, -): unknown[]; diff --git a/packages/toolkit-core/src/generated/search-syntax-grammar.js b/packages/toolkit-core/src/generated/search-syntax-grammar.js deleted file mode 100644 index ae63c86f5..000000000 --- a/packages/toolkit-core/src/generated/search-syntax-grammar.js +++ /dev/null @@ -1,5522 +0,0 @@ -// Auto-generated by scripts/generate-parsers.mjs — DO NOT EDIT - -// @generated by Peggy 5.1.0. -// -// https://peggyjs.org/ - - -class peg$SyntaxError extends SyntaxError { - constructor(message, expected, found, location) { - super(message); - this.expected = expected; - this.found = found; - this.location = location; - this.name = "SyntaxError"; - } - - format(sources) { - let str = "Error: " + this.message; - if (this.location) { - let src = null; - const st = sources.find(s => s.source === this.location.source); - if (st) { - src = st.text.split(/\r\n|\n|\r/g); - } - const s = this.location.start; - const offset_s = (this.location.source && (typeof this.location.source.offset === "function")) - ? this.location.source.offset(s) - : s; - const loc = this.location.source + ":" + offset_s.line + ":" + offset_s.column; - if (src) { - const e = this.location.end; - const filler = "".padEnd(offset_s.line.toString().length, " "); - const line = src[s.line - 1]; - const last = s.line === e.line ? e.column : line.length + 1; - const hatLen = (last - s.column) || 1; - str += "\n --> " + loc + "\n" - + filler + " |\n" - + offset_s.line + " | " + line + "\n" - + filler + " | " + "".padEnd(s.column - 1, " ") - + "".padEnd(hatLen, "^"); - } else { - str += "\n at " + loc; - } - } - return str; - } - - static buildMessage(expected, found) { - function hex(ch) { - return ch.codePointAt(0).toString(16).toUpperCase(); - } - - const nonPrintable = Object.prototype.hasOwnProperty.call(RegExp.prototype, "unicode") - ? new RegExp("[\\p{C}\\p{Mn}\\p{Mc}]", "gu") - : null; - function unicodeEscape(s) { - if (nonPrintable) { - return s.replace(nonPrintable, ch => "\\u{" + hex(ch) + "}"); - } - return s; - } - - function literalEscape(s) { - return unicodeEscape(s - .replace(/\\/g, "\\\\") - .replace(/"/g, "\\\"") - .replace(/\0/g, "\\0") - .replace(/\t/g, "\\t") - .replace(/\n/g, "\\n") - .replace(/\r/g, "\\r") - .replace(/[\x00-\x0F]/g, ch => "\\x0" + hex(ch)) - .replace(/[\x10-\x1F\x7F-\x9F]/g, ch => "\\x" + hex(ch))); - } - - function classEscape(s) { - return unicodeEscape(s - .replace(/\\/g, "\\\\") - .replace(/\]/g, "\\]") - .replace(/\^/g, "\\^") - .replace(/-/g, "\\-") - .replace(/\0/g, "\\0") - .replace(/\t/g, "\\t") - .replace(/\n/g, "\\n") - .replace(/\r/g, "\\r") - .replace(/[\x00-\x0F]/g, ch => "\\x0" + hex(ch)) - .replace(/[\x10-\x1F\x7F-\x9F]/g, ch => "\\x" + hex(ch))); - } - - const DESCRIBE_EXPECTATION_FNS = { - literal(expectation) { - return "\"" + literalEscape(expectation.text) + "\""; - }, - - class(expectation) { - const escapedParts = expectation.parts.map( - part => (Array.isArray(part) - ? classEscape(part[0]) + "-" + classEscape(part[1]) - : classEscape(part)) - ); - - return "[" + (expectation.inverted ? "^" : "") + escapedParts.join("") + "]" + (expectation.unicode ? "u" : ""); - }, - - any() { - return "any character"; - }, - - end() { - return "end of input"; - }, - - other(expectation) { - return expectation.description; - }, - }; - - function describeExpectation(expectation) { - return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation); - } - - function describeExpected(expected) { - const descriptions = expected.map(describeExpectation); - descriptions.sort(); - - if (descriptions.length > 0) { - let j = 1; - for (let i = 1; i < descriptions.length; i++) { - if (descriptions[i - 1] !== descriptions[i]) { - descriptions[j] = descriptions[i]; - j++; - } - } - descriptions.length = j; - } - - switch (descriptions.length) { - case 1: - return descriptions[0]; - - case 2: - return descriptions[0] + " or " + descriptions[1]; - - default: - return descriptions.slice(0, -1).join(", ") - + ", or " - + descriptions[descriptions.length - 1]; - } - } - - function describeFound(found) { - return found ? "\"" + literalEscape(found) + "\"" : "end of input"; - } - - return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found."; - } -} - -function peg$parse(input, options) { - options = options !== undefined ? options : {}; - - const peg$FAILED = {}; - const peg$source = options.grammarSource; - - const peg$startRuleFunctions = { - search: peg$parsesearch, - }; - let peg$startRuleFunction = peg$parsesearch; - - const peg$c0 = "("; - const peg$c1 = "has:"; - const peg$c2 = "is:"; - const peg$c3 = "//"; - const peg$c4 = "\""; - const peg$c5 = "flags"; - const peg$c6 = "string"; - const peg$c7 = "number"; - const peg$c8 = "tags"; - const peg$c9 = "boolean"; - const peg$c10 = "array"; - const peg$c11 = "*"; - const peg$c12 = "\\\""; - const peg$c13 = "-"; - const peg$c14 = "true"; - const peg$c15 = "1"; - const peg$c16 = "false"; - const peg$c17 = "0"; - const peg$c18 = "T"; - const peg$c19 = ":"; - const peg$c20 = "."; - const peg$c21 = "Z"; - const peg$c22 = "%"; - const peg$c23 = "ms"; - const peg$c24 = "s"; - const peg$c25 = "min"; - const peg$c26 = "m"; - const peg$c27 = "hr"; - const peg$c28 = "h"; - const peg$c29 = "day"; - const peg$c30 = "d"; - const peg$c31 = "wk"; - const peg$c32 = "w"; - const peg$c33 = "bit"; - const peg$c34 = "kib"; - const peg$c35 = "mib"; - const peg$c36 = "gib"; - const peg$c37 = "tib"; - const peg$c38 = "pib"; - const peg$c39 = "eib"; - const peg$c40 = "zib"; - const peg$c41 = "yib"; - const peg$c42 = "bytes"; - const peg$c43 = "nb"; - const peg$c44 = "kb"; - const peg$c45 = "mb"; - const peg$c46 = "gb"; - const peg$c47 = "tb"; - const peg$c48 = "pb"; - const peg$c49 = "eb"; - const peg$c50 = "zb"; - const peg$c51 = "yb"; - const peg$c52 = ">="; - const peg$c53 = "<="; - const peg$c54 = "!="; - const peg$c55 = "or"; - const peg$c56 = "and"; - const peg$c57 = ")"; - const peg$c58 = "["; - const peg$c59 = "]"; - const peg$c60 = "!"; - const peg$c61 = "Contains"; - const peg$c62 = "StartsWith"; - const peg$c63 = "EndsWith"; - const peg$c64 = ","; - const peg$c65 = " "; - - const peg$r0 = /^[^()\n ]/; - const peg$r1 = /^[a-zA-Z0-9_.\-]/; - const peg$r2 = /^[^\n]/; - const peg$r3 = /^[a-zA-Z0-9_.:\-]/; - const peg$r4 = /^[^()\t\n, "]/; - const peg$r5 = /^[^\t\n"]/; - const peg$r6 = /^[^()\t\n ]/; - const peg$r7 = /^[^"]/; - const peg$r8 = /^[,\]]/; - const peg$r9 = /^[^(), ]/; - const peg$r10 = /^[0-9]/; - const peg$r11 = /^[+\-]/; - const peg$r12 = /^[wdhm]/; - const peg$r13 = /^[bkm]/i; - const peg$r14 = /^[<->]/; - const peg$r15 = /^[\uF00D]/; - const peg$r16 = /^[\t\n )]/; - - const peg$e0 = peg$classExpectation(["(", ")", "\n", " "], true, false, false); - const peg$e1 = peg$classExpectation([["a", "z"], ["A", "Z"], ["0", "9"], "_", ".", "-"], false, false, false); - const peg$e2 = peg$literalExpectation("(", false); - const peg$e3 = peg$literalExpectation("has:", false); - const peg$e4 = peg$literalExpectation("is:", false); - const peg$e5 = peg$literalExpectation("//", false); - const peg$e6 = peg$classExpectation(["\n"], true, false, false); - const peg$e7 = peg$classExpectation([["a", "z"], ["A", "Z"], ["0", "9"], "_", ".", ":", "-"], false, false, false); - const peg$e8 = peg$literalExpectation("\"", false); - const peg$e9 = peg$literalExpectation("flags", false); - const peg$e10 = peg$literalExpectation("string", false); - const peg$e11 = peg$literalExpectation("number", false); - const peg$e12 = peg$literalExpectation("tags", false); - const peg$e13 = peg$literalExpectation("boolean", false); - const peg$e14 = peg$literalExpectation("array", false); - const peg$e15 = peg$literalExpectation("*", false); - const peg$e16 = peg$classExpectation(["(", ")", "\t", "\n", ",", " ", "\""], true, false, false); - const peg$e17 = peg$literalExpectation("\\\"", false); - const peg$e18 = peg$classExpectation(["\t", "\n", "\""], true, false, false); - const peg$e19 = peg$classExpectation(["(", ")", "\t", "\n", " "], true, false, false); - const peg$e20 = peg$classExpectation(["\""], true, false, false); - const peg$e21 = peg$literalExpectation("-", false); - const peg$e22 = peg$classExpectation([",", "]"], false, false, false); - const peg$e23 = peg$literalExpectation("true", true); - const peg$e24 = peg$literalExpectation("1", false); - const peg$e25 = peg$literalExpectation("false", true); - const peg$e26 = peg$literalExpectation("0", false); - const peg$e27 = peg$classExpectation(["(", ")", ",", " "], true, false, false); - const peg$e28 = peg$classExpectation([["0", "9"]], false, false, false); - const peg$e29 = peg$literalExpectation("T", false); - const peg$e30 = peg$literalExpectation(":", false); - const peg$e31 = peg$literalExpectation(".", false); - const peg$e32 = peg$classExpectation(["+", "-"], false, false, false); - const peg$e33 = peg$literalExpectation("Z", false); - const peg$e34 = peg$classExpectation(["w", "d", "h", "m"], false, false, false); - const peg$e35 = peg$literalExpectation("%", false); - const peg$e36 = peg$classExpectation(["b", "k", "m"], false, true, false); - const peg$e37 = peg$literalExpectation("ms", false); - const peg$e38 = peg$literalExpectation("s", false); - const peg$e39 = peg$literalExpectation("min", false); - const peg$e40 = peg$literalExpectation("m", false); - const peg$e41 = peg$literalExpectation("hr", false); - const peg$e42 = peg$literalExpectation("h", false); - const peg$e43 = peg$literalExpectation("day", false); - const peg$e44 = peg$literalExpectation("d", false); - const peg$e45 = peg$literalExpectation("wk", false); - const peg$e46 = peg$literalExpectation("w", false); - const peg$e47 = peg$literalExpectation("bit", true); - const peg$e48 = peg$literalExpectation("kib", true); - const peg$e49 = peg$literalExpectation("mib", true); - const peg$e50 = peg$literalExpectation("gib", true); - const peg$e51 = peg$literalExpectation("tib", true); - const peg$e52 = peg$literalExpectation("pib", true); - const peg$e53 = peg$literalExpectation("eib", true); - const peg$e54 = peg$literalExpectation("zib", true); - const peg$e55 = peg$literalExpectation("yib", true); - const peg$e56 = peg$literalExpectation("bytes", true); - const peg$e57 = peg$literalExpectation("nb", true); - const peg$e58 = peg$literalExpectation("kb", true); - const peg$e59 = peg$literalExpectation("mb", true); - const peg$e60 = peg$literalExpectation("gb", true); - const peg$e61 = peg$literalExpectation("tb", true); - const peg$e62 = peg$literalExpectation("pb", true); - const peg$e63 = peg$literalExpectation("eb", true); - const peg$e64 = peg$literalExpectation("zb", true); - const peg$e65 = peg$literalExpectation("yb", true); - const peg$e66 = peg$literalExpectation(">=", false); - const peg$e67 = peg$literalExpectation("<=", false); - const peg$e68 = peg$classExpectation([["<", ">"]], false, false, false); - const peg$e69 = peg$literalExpectation("!=", false); - const peg$e70 = peg$literalExpectation("OR", true); - const peg$e71 = peg$literalExpectation("AND", true); - const peg$e72 = peg$literalExpectation(")", false); - const peg$e73 = peg$literalExpectation("[", false); - const peg$e74 = peg$literalExpectation("]", false); - const peg$e75 = peg$literalExpectation("!", false); - const peg$e76 = peg$classExpectation(["\uF00D"], false, false, false); - const peg$e77 = peg$literalExpectation("Contains", false); - const peg$e78 = peg$literalExpectation("StartsWith", false); - const peg$e79 = peg$literalExpectation("EndsWith", false); - const peg$e80 = peg$literalExpectation(",", false); - const peg$e81 = peg$literalExpectation(" ", false); - const peg$e82 = peg$classExpectation(["\t", "\n", " ", ")"], false, false, false); - const peg$e83 = peg$anyExpectation(); - - function peg$f0(space, terms) { - return [space, ...terms.flat()]; - } - function peg$f1() { - return tc.tokenLogicBoolean(text().toUpperCase()); - } - function peg$f2(spaces, inner) { - return tc.predicateParenGroup(); - } - function peg$f3(spaces, inner) { - return tc.tokenLogicGroup([spaces, ...inner].flat()); - } - function peg$f4() { - return tc.tokenFreeText(text(), false); - } - function peg$f5(value) { - return tc.tokenFreeText(value.value, true); - } - function peg$f6(key, op, value) { - return tc.predicateFilter(FilterType.DATE, key, value, op) - } - function peg$f7(key, op, value) { - return tc.tokenFilter(FilterType.DATE, key, value, op, false); - } - function peg$f8(key, value) { - return tc.predicateFilter(FilterType.SPECIFIC_DATE, key) - } - function peg$f9(key, value) { - return tc.tokenFilter(FilterType.SPECIFIC_DATE, key, value, opDefault, false); - } - function peg$f10(key, value) { - return tc.predicateFilter(FilterType.RELATIVE_DATE, key) - } - function peg$f11(key, value) { - return tc.tokenFilter(FilterType.RELATIVE_DATE, key, value, opDefault, false); - } - function peg$f12(negation, key, op, value) { - return tc.predicateFilter(FilterType.DURATION, key) - } - function peg$f13(negation, key, op, value) { - return tc.tokenFilter(FilterType.DURATION, key, value, op, !!negation); - } - function peg$f14(negation, key, op, value) { - return tc.predicateFilter(FilterType.SIZE, key) - } - function peg$f15(negation, key, op, value) { - return tc.tokenFilter(FilterType.SIZE, key, value, op, !!negation); - } - function peg$f16(negation, key, value) { - return tc.predicateFilter(FilterType.BOOLEAN, key) - } - function peg$f17(negation, key, value) { - return tc.tokenFilter(FilterType.BOOLEAN, key, value, opDefault, !!negation); - } - function peg$f18(negation, key, value) { - return tc.predicateFilter(FilterType.NUMERIC_IN, key) - } - function peg$f19(negation, key, value) { - return tc.tokenFilter(FilterType.NUMERIC_IN, key, value, opDefault, !!negation); - } - function peg$f20(negation, key, op, value) { - return tc.predicateFilter(FilterType.NUMERIC, key) - } - function peg$f21(negation, key, op, value) { - return tc.tokenFilter(FilterType.NUMERIC, key, value, op, !!negation); - } - function peg$f22(negation, key, op, value) { - return tc.predicateFilter(FilterType.AGGREGATE_DURATION, key) - } - function peg$f23(negation, key, op, value) { - return tc.tokenFilter(FilterType.AGGREGATE_DURATION, key, value, op, !!negation); - } - function peg$f24(negation, key, op, value) { - return tc.predicateFilter(FilterType.AGGREGATE_SIZE, key) - } - function peg$f25(negation, key, op, value) { - return tc.tokenFilter(FilterType.AGGREGATE_SIZE, key, value, op, !!negation); - } - function peg$f26(negation, key, op, value) { - return tc.predicateFilter(FilterType.AGGREGATE_PERCENTAGE, key) - } - function peg$f27(negation, key, op, value) { - return tc.tokenFilter(FilterType.AGGREGATE_PERCENTAGE, key, value, op, !!negation); - } - function peg$f28(negation, key, op, value) { - return tc.predicateFilter(FilterType.AGGREGATE_NUMERIC, key) - } - function peg$f29(negation, key, op, value) { - return tc.tokenFilter(FilterType.AGGREGATE_NUMERIC, key, value, op, !!negation); - } - function peg$f30(negation, key, op, value) { - return tc.predicateFilter(FilterType.AGGREGATE_DATE, key) - } - function peg$f31(negation, key, op, value) { - return tc.tokenFilter(FilterType.AGGREGATE_DATE, key, value, op, !!negation); - } - function peg$f32(negation, key, op, value) { - return tc.predicateFilter(FilterType.AGGREGATE_RELATIVE_DATE, key) - } - function peg$f33(negation, key, op, value) { - return tc.tokenFilter(FilterType.AGGREGATE_RELATIVE_DATE, key, value, op, !!negation); - } - function peg$f34(negation, key, value) { - return tc.predicateFilter(FilterType.HAS, key) - } - function peg$f35(negation, key, value) { - return tc.tokenFilter(FilterType.HAS, key, value, opDefault, !!negation); - } - function peg$f36(negation, key, value) { - return tc.predicateFilter(FilterType.IS, key) - } - function peg$f37(negation, key, value) { - return tc.tokenFilter(FilterType.IS, key, value, opDefault, !!negation); - } - function peg$f38(negation, key, value) { - return tc.predicateFilter(FilterType.ARRAY_INCLUDES, key) - } - function peg$f39(negation, key, value) { - return tc.tokenFilter( - FilterType.ARRAY_INCLUDES, - key, - value, - opDefault, - !!negation, - undefined, - ); - } - function peg$f40(negation, key, value) { - return tc.tokenRegexFilter(key, value.literal, value.pattern, !!negation); - } - function peg$f41(pattern) { - return {pattern, literal: tc.tokenValueText(text(), false)}; - } - function peg$f42() { - return tc.tokenValueText(text(), false); - } - function peg$f43(negation, key, wildcard_op, value) { - return tc.predicateFilter(FilterType.TEXT_IN, key) - } - function peg$f44(negation, key, wildcard_op, value) { - const wildcard = wildcard_op ? wildcard_op.join("") : undefined; - return tc.tokenFilter( - FilterType.TEXT_IN, - key, - value, - opDefault, - !!negation, - wildcard, - ); - } - function peg$f45(negation, key, wildcard_op) { return tc.predicateTextOperator(key); } - function peg$f46(negation, key, wildcard_op, op, value) { - return tc.predicateFilter(FilterType.TEXT, key) - } - function peg$f47(negation, key, wildcard_op, op, value) { - const wildcard = wildcard_op ? wildcard_op.join("") : undefined; - return tc.tokenFilter( - FilterType.TEXT, - key, - value, - op ? op[0] : opDefault, - !!negation, - wildcard, - ); - } - function peg$f48(key) { - return tc.tokenKeySimple(key, false); - } - function peg$f49(key) { - return tc.tokenKeySimple(key, false); - } - function peg$f50(key) { - return tc.tokenKeySimple(key.value, true); - } - function peg$f51(prefix, key) { - return tc.tokenKeyExplicitFlag(prefix, key); - } - function peg$f52(prefix, key) { - return tc.tokenKeyExplicitStringFlag(prefix, key) - } - function peg$f53(prefix, key) { - return tc.tokenKeyExplicitNumberFlag(prefix, key) - } - function peg$f54(prefix, key) { - return tc.tokenKeyExplicitTag(prefix, key); - } - function peg$f55(prefix, key) { - return tc.tokenKeyExplicitStringTag(prefix, key) - } - function peg$f56(prefix, key) { - return tc.tokenKeyExplicitNumberTag(prefix, key) - } - function peg$f57(prefix, key) { - return tc.tokenKeyExplicitBooleanTag(prefix, key) - } - function peg$f58(prefix, key) { - return tc.tokenKeyExplicitArrayTag(prefix, key) - } - function peg$f59(prefix, key) { - return tc.tokenKeyArrayIncludes(tc.tokenKeyExplicitArrayTag(prefix, key), "*"); - } - function peg$f60(base) { - return tc.tokenKeyArrayIncludes(base, "*"); - } - function peg$f61(name, s1, args, s2) { - return tc.tokenKeyAggregate(name, args, s1, s2); - } - function peg$f62(arg1, args) { - return tc.tokenKeyAggregateArgs(arg1, args); - } - function peg$f63(param) { - return tc.tokenKeyAggregateParam(param, false); - } - function peg$f64(param) { - return tc.tokenKeyAggregateParam(`"${param}"`, true); - } - function peg$f65(key) { - return tc.tokenKeyAggregateParam(key.text, false); - } - function peg$f66(value) { - return tc.tokenValueText(value, false); - } - function peg$f67(value) { - return tc.tokenValueText(value, true); - } - function peg$f68() { - return tc.tokenValueText(text(), false); - } - function peg$f69(value, unit) { - return tc.tokenValueNumber(value.join(''), unit); - } - function peg$f70(value) { - return tc.tokenValueBoolean(value); - } - function peg$f71(item1, items) { - return tc.tokenValueTextList(item1, items); - } - function peg$f72(item1, items) { - return tc.tokenValueNumberList(item1, items); - } - function peg$f73(date, time, tz) { - return tc.tokenValueIso8601Date(text(), date, time, tz); - } - function peg$f74(sign, value, unit) { - return tc.tokenValueRelativeDate(value, sign, unit); - } - function peg$f75(value, unit) { - return tc.tokenValueDuration(value, unit); - } - function peg$f76(value, unit) { - return tc.tokenValueSize(value, unit); - } - function peg$f77(value) { - return tc.tokenValuePercentage(value); - } - function peg$f78() { return text(); } - function peg$f79() { return tc.tokenLParen(text()); } - function peg$f80() { return tc.tokenRParen(text()); } - function peg$f81() { return tc.tokenSpaces(text()) } - let peg$currPos = options.peg$currPos | 0; - let peg$savedPos = peg$currPos; - const peg$posDetailsCache = [{ line: 1, column: 1 }]; - let peg$maxFailPos = peg$currPos; - let peg$maxFailExpected = options.peg$maxFailExpected || []; - let peg$silentFails = options.peg$silentFails | 0; - - let peg$result; - - if (options.startRule) { - if (!(options.startRule in peg$startRuleFunctions)) { - throw new Error("Can't start parsing from rule \"" + options.startRule + "\"."); - } - - peg$startRuleFunction = peg$startRuleFunctions[options.startRule]; - } - - function text() { - return input.substring(peg$savedPos, peg$currPos); - } - - function offset() { - return peg$savedPos; - } - - function range() { - return { - source: peg$source, - start: peg$savedPos, - end: peg$currPos, - }; - } - - function location() { - return peg$computeLocation(peg$savedPos, peg$currPos); - } - - function expected(description, location) { - location = location !== undefined - ? location - : peg$computeLocation(peg$savedPos, peg$currPos); - - throw peg$buildStructuredError( - [peg$otherExpectation(description)], - input.substring(peg$savedPos, peg$currPos), - location - ); - } - - function error(message, location) { - location = location !== undefined - ? location - : peg$computeLocation(peg$savedPos, peg$currPos); - - throw peg$buildSimpleError(message, location); - } - - function peg$getUnicode(pos = peg$currPos) { - const cp = input.codePointAt(pos); - if (cp === undefined) { - return ""; - } - return String.fromCodePoint(cp); - } - - function peg$literalExpectation(text, ignoreCase) { - return { type: "literal", text, ignoreCase }; - } - - function peg$classExpectation(parts, inverted, ignoreCase, unicode) { - return { type: "class", parts, inverted, ignoreCase, unicode }; - } - - function peg$anyExpectation() { - return { type: "any" }; - } - - function peg$endExpectation() { - return { type: "end" }; - } - - function peg$otherExpectation(description) { - return { type: "other", description }; - } - - function peg$computePosDetails(pos) { - let details = peg$posDetailsCache[pos]; - let p; - - if (details) { - return details; - } else { - if (pos >= peg$posDetailsCache.length) { - p = peg$posDetailsCache.length - 1; - } else { - p = pos; - while (!peg$posDetailsCache[--p]) {} - } - - details = peg$posDetailsCache[p]; - details = { - line: details.line, - column: details.column, - }; - - while (p < pos) { - if (input.charCodeAt(p) === 10) { - details.line++; - details.column = 1; - } else { - details.column++; - } - - p++; - } - - peg$posDetailsCache[pos] = details; - - return details; - } - } - - function peg$computeLocation(startPos, endPos, offset) { - const startPosDetails = peg$computePosDetails(startPos); - const endPosDetails = peg$computePosDetails(endPos); - - const res = { - source: peg$source, - start: { - offset: startPos, - line: startPosDetails.line, - column: startPosDetails.column, - }, - end: { - offset: endPos, - line: endPosDetails.line, - column: endPosDetails.column, - }, - }; - if (offset && peg$source && (typeof peg$source.offset === "function")) { - res.start = peg$source.offset(res.start); - res.end = peg$source.offset(res.end); - } - return res; - } - - function peg$fail(expected) { - if (peg$currPos < peg$maxFailPos) { return; } - - if (peg$currPos > peg$maxFailPos) { - peg$maxFailPos = peg$currPos; - peg$maxFailExpected = []; - } - - peg$maxFailExpected.push(expected); - } - - function peg$buildSimpleError(message, location) { - return new peg$SyntaxError(message, null, null, location); - } - - function peg$buildStructuredError(expected, found, location) { - return new peg$SyntaxError( - peg$SyntaxError.buildMessage(expected, found), - expected, - found, - location - ); - } - - function peg$parsesearch() { - let s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$parsespaces(); - s2 = []; - s3 = peg$parseterm(); - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$parseterm(); - } - peg$savedPos = s0; - s0 = peg$f0(s1, s2); - - return s0; - } - - function peg$parseterm() { - let s0, s1, s2; - - s0 = peg$currPos; - s1 = peg$parseboolean_operator(); - if (s1 === peg$FAILED) { - s1 = peg$parseparen_group(); - if (s1 === peg$FAILED) { - s1 = peg$parseopen_paren(); - if (s1 === peg$FAILED) { - s1 = peg$parseclosed_paren(); - if (s1 === peg$FAILED) { - s1 = peg$parsefilter(); - if (s1 === peg$FAILED) { - s1 = peg$parsefree_text(); - } - } - } - } - } - if (s1 !== peg$FAILED) { - s2 = peg$parsespaces(); - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseterm_no_paren() { - let s0, s1, s2; - - s0 = peg$currPos; - s1 = peg$parseboolean_operator(); - if (s1 === peg$FAILED) { - s1 = peg$parseparen_group(); - if (s1 === peg$FAILED) { - s1 = peg$parsefilter(); - if (s1 === peg$FAILED) { - s1 = peg$parsefree_text(); - } - } - } - if (s1 !== peg$FAILED) { - s2 = peg$parsespaces(); - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseboolean_operator() { - let s0, s1; - - s0 = peg$currPos; - s1 = peg$parseor_operator(); - if (s1 === peg$FAILED) { - s1 = peg$parseand_operator(); - } - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f1(); - } - s0 = s1; - - return s0; - } - - function peg$parseparen_group() { - let s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - s1 = peg$parseopen_paren(); - if (s1 !== peg$FAILED) { - s2 = peg$parsespaces(); - s3 = []; - s4 = peg$parseterm_no_paren(); - while (s4 !== peg$FAILED) { - s3.push(s4); - s4 = peg$parseterm_no_paren(); - } - s4 = peg$parseclosed_paren(); - if (s4 !== peg$FAILED) { - peg$savedPos = peg$currPos; - s5 = peg$f2(s2, s3); - if (s5) { - s5 = undefined; - } else { - s5 = peg$FAILED; - } - if (s5 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f3(s2, s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsefree_text() { - let s0; - - s0 = peg$parsefree_text_quoted(); - if (s0 === peg$FAILED) { - s0 = peg$parsefree_text_unquoted(); - } - - return s0; - } - - function peg$parsefree_text_unquoted() { - let s0, s1, s2, s3, s4, s5, s6; - - s0 = peg$currPos; - s1 = []; - s2 = peg$currPos; - s3 = peg$currPos; - peg$silentFails++; - s4 = peg$parsefilter_start(); - peg$silentFails--; - if (s4 === peg$FAILED) { - s3 = undefined; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - if (s3 !== peg$FAILED) { - s4 = peg$currPos; - peg$silentFails++; - s5 = peg$parseboolean_operator(); - peg$silentFails--; - if (s5 === peg$FAILED) { - s4 = undefined; - } else { - peg$currPos = s4; - s4 = peg$FAILED; - } - if (s4 !== peg$FAILED) { - s5 = peg$parsefree_parens(); - if (s5 === peg$FAILED) { - s5 = []; - s6 = input.charAt(peg$currPos); - if (peg$r0.test(s6)) { - peg$currPos++; - } else { - s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e0); } - } - if (s6 !== peg$FAILED) { - while (s6 !== peg$FAILED) { - s5.push(s6); - s6 = input.charAt(peg$currPos); - if (peg$r0.test(s6)) { - peg$currPos++; - } else { - s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e0); } - } - } - } else { - s5 = peg$FAILED; - } - } - if (s5 !== peg$FAILED) { - s6 = peg$parsespaces(); - s3 = [s3, s4, s5, s6]; - s2 = s3; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - while (s2 !== peg$FAILED) { - s1.push(s2); - s2 = peg$currPos; - s3 = peg$currPos; - peg$silentFails++; - s4 = peg$parsefilter_start(); - peg$silentFails--; - if (s4 === peg$FAILED) { - s3 = undefined; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - if (s3 !== peg$FAILED) { - s4 = peg$currPos; - peg$silentFails++; - s5 = peg$parseboolean_operator(); - peg$silentFails--; - if (s5 === peg$FAILED) { - s4 = undefined; - } else { - peg$currPos = s4; - s4 = peg$FAILED; - } - if (s4 !== peg$FAILED) { - s5 = peg$parsefree_parens(); - if (s5 === peg$FAILED) { - s5 = []; - s6 = input.charAt(peg$currPos); - if (peg$r0.test(s6)) { - peg$currPos++; - } else { - s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e0); } - } - if (s6 !== peg$FAILED) { - while (s6 !== peg$FAILED) { - s5.push(s6); - s6 = input.charAt(peg$currPos); - if (peg$r0.test(s6)) { - peg$currPos++; - } else { - s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e0); } - } - } - } else { - s5 = peg$FAILED; - } - } - if (s5 !== peg$FAILED) { - s6 = peg$parsespaces(); - s3 = [s3, s4, s5, s6]; - s2 = s3; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - } - } else { - s1 = peg$FAILED; - } - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f4(); - } - s0 = s1; - - return s0; - } - - function peg$parsefree_text_quoted() { - let s0, s1; - - s0 = peg$currPos; - s1 = peg$parsequoted_value(); - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f5(s1); - } - s0 = s1; - - return s0; - } - - function peg$parsefree_parens() { - let s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$parseopen_paren(); - if (s1 !== peg$FAILED) { - s2 = peg$parsefree_text(); - if (s2 === peg$FAILED) { - s2 = null; - } - s3 = peg$parseclosed_paren(); - if (s3 !== peg$FAILED) { - s1 = [s1, s2, s3]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsefilter_start() { - let s0, s1, s2, s3, s4; - - s0 = peg$currPos; - s1 = peg$parsenegation(); - if (s1 === peg$FAILED) { - s1 = null; - } - s2 = peg$currPos; - s3 = peg$parsearray_includes_key(); - if (s3 === peg$FAILED) { - s3 = peg$parsetext_key(); - if (s3 === peg$FAILED) { - s3 = peg$parsesearch_key(); - } - } - if (s3 !== peg$FAILED) { - s4 = peg$parsesep(); - if (s4 !== peg$FAILED) { - s3 = [s3, s4]; - s2 = s3; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 === peg$FAILED) { - s2 = peg$parseaggregate_filter_start(); - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseaggregate_filter_start() { - let s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$currPos; - peg$silentFails++; - s2 = peg$parseaggregate_key_start(); - peg$silentFails--; - if (s2 !== peg$FAILED) { - peg$currPos = s1; - s1 = undefined; - } else { - s1 = peg$FAILED; - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseaggregate_filter(); - peg$silentFails--; - if (s3 !== peg$FAILED) { - peg$currPos = s2; - s2 = undefined; - } else { - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseaggregate_key_start() { - let s0, s1, s2; - - s0 = peg$currPos; - s1 = []; - s2 = input.charAt(peg$currPos); - if (peg$r1.test(s2)) { - peg$currPos++; - } else { - s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e1); } - } - if (s2 !== peg$FAILED) { - while (s2 !== peg$FAILED) { - s1.push(s2); - s2 = input.charAt(peg$currPos); - if (peg$r1.test(s2)) { - peg$currPos++; - } else { - s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e1); } - } - } - } else { - s1 = peg$FAILED; - } - if (s1 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 40) { - s2 = peg$c0; - peg$currPos++; - } else { - s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e2); } - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsefilter() { - let s0; - - s0 = peg$parsedate_filter(); - if (s0 === peg$FAILED) { - s0 = peg$parsespecific_date_filter(); - if (s0 === peg$FAILED) { - s0 = peg$parserel_date_filter(); - if (s0 === peg$FAILED) { - s0 = peg$parseduration_filter(); - if (s0 === peg$FAILED) { - s0 = peg$parsesize_filter(); - if (s0 === peg$FAILED) { - s0 = peg$parseboolean_filter(); - if (s0 === peg$FAILED) { - s0 = peg$parsenumeric_in_filter(); - if (s0 === peg$FAILED) { - s0 = peg$parsenumeric_filter(); - if (s0 === peg$FAILED) { - s0 = peg$parseaggregate_filter(); - if (s0 === peg$FAILED) { - s0 = peg$parsehas_filter(); - if (s0 === peg$FAILED) { - s0 = peg$parseis_filter(); - if (s0 === peg$FAILED) { - s0 = peg$parseregex_filter(); - if (s0 === peg$FAILED) { - s0 = peg$parsearray_includes_filter(); - if (s0 === peg$FAILED) { - s0 = peg$parsetext_in_filter(); - if (s0 === peg$FAILED) { - s0 = peg$parsetext_filter(); - } - } - } - } - } - } - } - } - } - } - } - } - } - } - - return s0; - } - - function peg$parseaggregate_filter() { - let s0; - - s0 = peg$parseaggregate_duration_filter(); - if (s0 === peg$FAILED) { - s0 = peg$parseaggregate_size_filter(); - if (s0 === peg$FAILED) { - s0 = peg$parseaggregate_numeric_filter(); - if (s0 === peg$FAILED) { - s0 = peg$parseaggregate_percentage_filter(); - if (s0 === peg$FAILED) { - s0 = peg$parseaggregate_date_filter(); - if (s0 === peg$FAILED) { - s0 = peg$parseaggregate_rel_date_filter(); - } - } - } - } - } - - return s0; - } - - function peg$parsedate_filter() { - let s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - s1 = peg$parsesearch_key(); - if (s1 !== peg$FAILED) { - s2 = peg$parsesep(); - if (s2 !== peg$FAILED) { - s3 = peg$parseoperator(); - if (s3 !== peg$FAILED) { - s4 = peg$parseiso_8601_date_format(); - if (s4 !== peg$FAILED) { - peg$savedPos = peg$currPos; - s5 = peg$f6(s1, s3, s4); - if (s5) { - s5 = undefined; - } else { - s5 = peg$FAILED; - } - if (s5 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f7(s1, s3, s4); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsespecific_date_filter() { - let s0, s1, s2, s3, s4; - - s0 = peg$currPos; - s1 = peg$parsesearch_key(); - if (s1 !== peg$FAILED) { - s2 = peg$parsesep(); - if (s2 !== peg$FAILED) { - s3 = peg$parseiso_8601_date_format(); - if (s3 !== peg$FAILED) { - peg$savedPos = peg$currPos; - s4 = peg$f8(s1, s3); - if (s4) { - s4 = undefined; - } else { - s4 = peg$FAILED; - } - if (s4 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f9(s1, s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parserel_date_filter() { - let s0, s1, s2, s3, s4; - - s0 = peg$currPos; - s1 = peg$parsesearch_key(); - if (s1 !== peg$FAILED) { - s2 = peg$parsesep(); - if (s2 !== peg$FAILED) { - s3 = peg$parserel_date_format(); - if (s3 !== peg$FAILED) { - peg$savedPos = peg$currPos; - s4 = peg$f10(s1, s3); - if (s4) { - s4 = undefined; - } else { - s4 = peg$FAILED; - } - if (s4 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f11(s1, s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseduration_filter() { - let s0, s1, s2, s3, s4, s5, s6; - - s0 = peg$currPos; - s1 = peg$parsenegation(); - if (s1 === peg$FAILED) { - s1 = null; - } - s2 = peg$parsesearch_key(); - if (s2 !== peg$FAILED) { - s3 = peg$parsesep(); - if (s3 !== peg$FAILED) { - s4 = peg$parseoperator(); - if (s4 === peg$FAILED) { - s4 = null; - } - s5 = peg$parseduration_format(); - if (s5 !== peg$FAILED) { - peg$savedPos = peg$currPos; - s6 = peg$f12(s1, s2, s4, s5); - if (s6) { - s6 = undefined; - } else { - s6 = peg$FAILED; - } - if (s6 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f13(s1, s2, s4, s5); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsesize_filter() { - let s0, s1, s2, s3, s4, s5, s6; - - s0 = peg$currPos; - s1 = peg$parsenegation(); - if (s1 === peg$FAILED) { - s1 = null; - } - s2 = peg$parsesearch_key(); - if (s2 !== peg$FAILED) { - s3 = peg$parsesep(); - if (s3 !== peg$FAILED) { - s4 = peg$parseoperator(); - if (s4 === peg$FAILED) { - s4 = null; - } - s5 = peg$parsesize_format(); - if (s5 !== peg$FAILED) { - peg$savedPos = peg$currPos; - s6 = peg$f14(s1, s2, s4, s5); - if (s6) { - s6 = undefined; - } else { - s6 = peg$FAILED; - } - if (s6 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f15(s1, s2, s4, s5); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseboolean_filter() { - let s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - s1 = peg$parsenegation(); - if (s1 === peg$FAILED) { - s1 = null; - } - s2 = peg$parsesearch_key(); - if (s2 !== peg$FAILED) { - s3 = peg$parsesep(); - if (s3 !== peg$FAILED) { - s4 = peg$parseboolean_value(); - if (s4 !== peg$FAILED) { - peg$savedPos = peg$currPos; - s5 = peg$f16(s1, s2, s4); - if (s5) { - s5 = undefined; - } else { - s5 = peg$FAILED; - } - if (s5 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f17(s1, s2, s4); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsenumeric_in_filter() { - let s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - s1 = peg$parsenegation(); - if (s1 === peg$FAILED) { - s1 = null; - } - s2 = peg$parsesearch_key(); - if (s2 !== peg$FAILED) { - s3 = peg$parsesep(); - if (s3 !== peg$FAILED) { - s4 = peg$parsenumeric_in_list(); - if (s4 !== peg$FAILED) { - peg$savedPos = peg$currPos; - s5 = peg$f18(s1, s2, s4); - if (s5) { - s5 = undefined; - } else { - s5 = peg$FAILED; - } - if (s5 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f19(s1, s2, s4); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsenumeric_filter() { - let s0, s1, s2, s3, s4, s5, s6; - - s0 = peg$currPos; - s1 = peg$parsenegation(); - if (s1 === peg$FAILED) { - s1 = null; - } - s2 = peg$parsesearch_key(); - if (s2 !== peg$FAILED) { - s3 = peg$parsesep(); - if (s3 !== peg$FAILED) { - s4 = peg$parseoperator(); - if (s4 === peg$FAILED) { - s4 = null; - } - s5 = peg$parsenumeric_value(); - if (s5 !== peg$FAILED) { - peg$savedPos = peg$currPos; - s6 = peg$f20(s1, s2, s4, s5); - if (s6) { - s6 = undefined; - } else { - s6 = peg$FAILED; - } - if (s6 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f21(s1, s2, s4, s5); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseaggregate_duration_filter() { - let s0, s1, s2, s3, s4, s5, s6; - - s0 = peg$currPos; - s1 = peg$parsenegation(); - if (s1 === peg$FAILED) { - s1 = null; - } - s2 = peg$parseaggregate_key(); - if (s2 !== peg$FAILED) { - s3 = peg$parsesep(); - if (s3 !== peg$FAILED) { - s4 = peg$parseoperator(); - if (s4 === peg$FAILED) { - s4 = null; - } - s5 = peg$parseduration_format(); - if (s5 !== peg$FAILED) { - peg$savedPos = peg$currPos; - s6 = peg$f22(s1, s2, s4, s5); - if (s6) { - s6 = undefined; - } else { - s6 = peg$FAILED; - } - if (s6 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f23(s1, s2, s4, s5); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseaggregate_size_filter() { - let s0, s1, s2, s3, s4, s5, s6; - - s0 = peg$currPos; - s1 = peg$parsenegation(); - if (s1 === peg$FAILED) { - s1 = null; - } - s2 = peg$parseaggregate_key(); - if (s2 !== peg$FAILED) { - s3 = peg$parsesep(); - if (s3 !== peg$FAILED) { - s4 = peg$parseoperator(); - if (s4 === peg$FAILED) { - s4 = null; - } - s5 = peg$parsesize_format(); - if (s5 !== peg$FAILED) { - peg$savedPos = peg$currPos; - s6 = peg$f24(s1, s2, s4, s5); - if (s6) { - s6 = undefined; - } else { - s6 = peg$FAILED; - } - if (s6 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f25(s1, s2, s4, s5); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseaggregate_percentage_filter() { - let s0, s1, s2, s3, s4, s5, s6; - - s0 = peg$currPos; - s1 = peg$parsenegation(); - if (s1 === peg$FAILED) { - s1 = null; - } - s2 = peg$parseaggregate_key(); - if (s2 !== peg$FAILED) { - s3 = peg$parsesep(); - if (s3 !== peg$FAILED) { - s4 = peg$parseoperator(); - if (s4 === peg$FAILED) { - s4 = null; - } - s5 = peg$parsepercentage_format(); - if (s5 !== peg$FAILED) { - peg$savedPos = peg$currPos; - s6 = peg$f26(s1, s2, s4, s5); - if (s6) { - s6 = undefined; - } else { - s6 = peg$FAILED; - } - if (s6 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f27(s1, s2, s4, s5); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseaggregate_numeric_filter() { - let s0, s1, s2, s3, s4, s5, s6; - - s0 = peg$currPos; - s1 = peg$parsenegation(); - if (s1 === peg$FAILED) { - s1 = null; - } - s2 = peg$parseaggregate_key(); - if (s2 !== peg$FAILED) { - s3 = peg$parsesep(); - if (s3 !== peg$FAILED) { - s4 = peg$parseoperator(); - if (s4 === peg$FAILED) { - s4 = null; - } - s5 = peg$parsenumeric_value(); - if (s5 !== peg$FAILED) { - peg$savedPos = peg$currPos; - s6 = peg$f28(s1, s2, s4, s5); - if (s6) { - s6 = undefined; - } else { - s6 = peg$FAILED; - } - if (s6 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f29(s1, s2, s4, s5); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseaggregate_date_filter() { - let s0, s1, s2, s3, s4, s5, s6; - - s0 = peg$currPos; - s1 = peg$parsenegation(); - if (s1 === peg$FAILED) { - s1 = null; - } - s2 = peg$parseaggregate_key(); - if (s2 !== peg$FAILED) { - s3 = peg$parsesep(); - if (s3 !== peg$FAILED) { - s4 = peg$parseoperator(); - if (s4 === peg$FAILED) { - s4 = null; - } - s5 = peg$parseiso_8601_date_format(); - if (s5 !== peg$FAILED) { - peg$savedPos = peg$currPos; - s6 = peg$f30(s1, s2, s4, s5); - if (s6) { - s6 = undefined; - } else { - s6 = peg$FAILED; - } - if (s6 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f31(s1, s2, s4, s5); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseaggregate_rel_date_filter() { - let s0, s1, s2, s3, s4, s5, s6; - - s0 = peg$currPos; - s1 = peg$parsenegation(); - if (s1 === peg$FAILED) { - s1 = null; - } - s2 = peg$parseaggregate_key(); - if (s2 !== peg$FAILED) { - s3 = peg$parsesep(); - if (s3 !== peg$FAILED) { - s4 = peg$parseoperator(); - if (s4 === peg$FAILED) { - s4 = null; - } - s5 = peg$parserel_date_format(); - if (s5 !== peg$FAILED) { - peg$savedPos = peg$currPos; - s6 = peg$f32(s1, s2, s4, s5); - if (s6) { - s6 = undefined; - } else { - s6 = peg$FAILED; - } - if (s6 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f33(s1, s2, s4, s5); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsehas_filter() { - let s0, s1, s2, s3, s4, s5, s6; - - s0 = peg$currPos; - s1 = peg$parsenegation(); - if (s1 === peg$FAILED) { - s1 = null; - } - s2 = peg$currPos; - peg$silentFails++; - if (input.substr(peg$currPos, 4) === peg$c1) { - s3 = peg$c1; - peg$currPos += 4; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e3); } - } - peg$silentFails--; - if (s3 !== peg$FAILED) { - peg$currPos = s2; - s2 = undefined; - } else { - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s3 = peg$parsesearch_key(); - if (s3 !== peg$FAILED) { - s4 = peg$parsesep(); - if (s4 !== peg$FAILED) { - s5 = peg$parsesearch_value(); - if (s5 === peg$FAILED) { - s5 = peg$parsesearch_key(); - } - if (s5 !== peg$FAILED) { - peg$savedPos = peg$currPos; - s6 = peg$f34(s1, s3, s5); - if (s6) { - s6 = undefined; - } else { - s6 = peg$FAILED; - } - if (s6 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f35(s1, s3, s5); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseis_filter() { - let s0, s1, s2, s3, s4, s5, s6; - - s0 = peg$currPos; - s1 = peg$parsenegation(); - if (s1 === peg$FAILED) { - s1 = null; - } - s2 = peg$currPos; - peg$silentFails++; - if (input.substr(peg$currPos, 3) === peg$c2) { - s3 = peg$c2; - peg$currPos += 3; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e4); } - } - peg$silentFails--; - if (s3 !== peg$FAILED) { - peg$currPos = s2; - s2 = undefined; - } else { - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s3 = peg$parsesearch_key(); - if (s3 !== peg$FAILED) { - s4 = peg$parsesep(); - if (s4 !== peg$FAILED) { - s5 = peg$parsesearch_value(); - if (s5 !== peg$FAILED) { - peg$savedPos = peg$currPos; - s6 = peg$f36(s1, s3, s5); - if (s6) { - s6 = undefined; - } else { - s6 = peg$FAILED; - } - if (s6 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f37(s1, s3, s5); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsearray_includes_filter() { - let s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - s1 = peg$parsenegation(); - if (s1 === peg$FAILED) { - s1 = null; - } - s2 = peg$parsearray_includes_key(); - if (s2 !== peg$FAILED) { - s3 = peg$parsesep(); - if (s3 !== peg$FAILED) { - s4 = peg$parsesearch_value(); - if (s4 !== peg$FAILED) { - peg$savedPos = peg$currPos; - s5 = peg$f38(s1, s2, s4); - if (s5) { - s5 = undefined; - } else { - s5 = peg$FAILED; - } - if (s5 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f39(s1, s2, s4); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseregex_filter() { - let s0, s1, s2, s3, s4; - - s0 = peg$currPos; - s1 = peg$parsenegation(); - if (s1 === peg$FAILED) { - s1 = null; - } - s2 = peg$parsearray_includes_key(); - if (s2 === peg$FAILED) { - s2 = peg$parsetext_key(); - } - if (s2 !== peg$FAILED) { - s3 = peg$parsesep(); - if (s3 !== peg$FAILED) { - s4 = peg$parseregex_value(); - if (s4 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f40(s1, s2, s4); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseregex_value() { - let s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c3) { - s1 = peg$c3; - peg$currPos += 2; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e5); } - } - if (s1 !== peg$FAILED) { - s2 = peg$parseregex_pattern(); - if (input.substr(peg$currPos, 2) === peg$c3) { - s3 = peg$c3; - peg$currPos += 2; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e5); } - } - if (s3 !== peg$FAILED) { - s4 = peg$currPos; - peg$silentFails++; - s5 = peg$parseend_value(); - peg$silentFails--; - if (s5 !== peg$FAILED) { - peg$currPos = s4; - s4 = undefined; - } else { - s4 = peg$FAILED; - } - if (s4 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f41(s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseregex_pattern() { - let s0, s1, s2, s3, s4, s5, s6; - - s0 = peg$currPos; - s1 = []; - s2 = peg$currPos; - s3 = peg$currPos; - peg$silentFails++; - s4 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c3) { - s5 = peg$c3; - peg$currPos += 2; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e5); } - } - if (s5 !== peg$FAILED) { - s6 = peg$parseend_value(); - if (s6 !== peg$FAILED) { - s5 = [s5, s6]; - s4 = s5; - } else { - peg$currPos = s4; - s4 = peg$FAILED; - } - } else { - peg$currPos = s4; - s4 = peg$FAILED; - } - peg$silentFails--; - if (s4 === peg$FAILED) { - s3 = undefined; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - if (s3 !== peg$FAILED) { - s4 = input.charAt(peg$currPos); - if (peg$r2.test(s4)) { - peg$currPos++; - } else { - s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e6); } - } - if (s4 !== peg$FAILED) { - s3 = [s3, s4]; - s2 = s3; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - while (s2 !== peg$FAILED) { - s1.push(s2); - s2 = peg$currPos; - s3 = peg$currPos; - peg$silentFails++; - s4 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c3) { - s5 = peg$c3; - peg$currPos += 2; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e5); } - } - if (s5 !== peg$FAILED) { - s6 = peg$parseend_value(); - if (s6 !== peg$FAILED) { - s5 = [s5, s6]; - s4 = s5; - } else { - peg$currPos = s4; - s4 = peg$FAILED; - } - } else { - peg$currPos = s4; - s4 = peg$FAILED; - } - peg$silentFails--; - if (s4 === peg$FAILED) { - s3 = undefined; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - if (s3 !== peg$FAILED) { - s4 = input.charAt(peg$currPos); - if (peg$r2.test(s4)) { - peg$currPos++; - } else { - s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e6); } - } - if (s4 !== peg$FAILED) { - s3 = [s3, s4]; - s2 = s3; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - } - peg$savedPos = s0; - s1 = peg$f42(); - s0 = s1; - - return s0; - } - - function peg$parsetext_in_filter() { - let s0, s1, s2, s3, s4, s5, s6; - - s0 = peg$currPos; - s1 = peg$parsenegation(); - if (s1 === peg$FAILED) { - s1 = null; - } - s2 = peg$parsetext_key(); - if (s2 !== peg$FAILED) { - s3 = peg$parsesep(); - if (s3 !== peg$FAILED) { - s4 = peg$parsewildcard_op(); - if (s4 === peg$FAILED) { - s4 = null; - } - s5 = peg$parsetext_in_list(); - if (s5 !== peg$FAILED) { - peg$savedPos = peg$currPos; - s6 = peg$f43(s1, s2, s4, s5); - if (s6) { - s6 = undefined; - } else { - s6 = peg$FAILED; - } - if (s6 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f44(s1, s2, s4, s5); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsetext_filter() { - let s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parsenegation(); - if (s1 === peg$FAILED) { - s1 = null; - } - s2 = peg$parsetext_key(); - if (s2 !== peg$FAILED) { - s3 = peg$parsesep(); - if (s3 !== peg$FAILED) { - s4 = peg$parsewildcard_op(); - if (s4 === peg$FAILED) { - s4 = null; - } - s5 = peg$currPos; - s6 = peg$parseoperator(); - if (s6 !== peg$FAILED) { - peg$savedPos = peg$currPos; - s7 = peg$f45(s1, s2, s4); - if (s7) { - s7 = undefined; - } else { - s7 = peg$FAILED; - } - if (s7 !== peg$FAILED) { - s6 = [s6, s7]; - s5 = s6; - } else { - peg$currPos = s5; - s5 = peg$FAILED; - } - } else { - peg$currPos = s5; - s5 = peg$FAILED; - } - if (s5 === peg$FAILED) { - s5 = null; - } - s6 = peg$parsesearch_value(); - if (s6 !== peg$FAILED) { - peg$savedPos = peg$currPos; - s7 = peg$f46(s1, s2, s4, s5, s6); - if (s7) { - s7 = undefined; - } else { - s7 = peg$FAILED; - } - if (s7 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f47(s1, s2, s4, s5, s6); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsekey() { - let s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$currPos; - s2 = []; - s3 = input.charAt(peg$currPos); - if (peg$r1.test(s3)) { - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e1); } - } - if (s3 !== peg$FAILED) { - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = input.charAt(peg$currPos); - if (peg$r1.test(s3)) { - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e1); } - } - } - } else { - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = input.substring(s1, peg$currPos); - } else { - s1 = s2; - } - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f48(s1); - } - s0 = s1; - - return s0; - } - - function peg$parseescaped_key() { - let s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$currPos; - s2 = []; - s3 = input.charAt(peg$currPos); - if (peg$r3.test(s3)) { - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e7); } - } - if (s3 !== peg$FAILED) { - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = input.charAt(peg$currPos); - if (peg$r3.test(s3)) { - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e7); } - } - } - } else { - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = input.substring(s1, peg$currPos); - } else { - s1 = s2; - } - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f49(s1); - } - s0 = s1; - - return s0; - } - - function peg$parsequoted_key() { - let s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 34) { - s1 = peg$c4; - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e8); } - } - if (s1 !== peg$FAILED) { - s2 = peg$parseescaped_key(); - if (s2 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 34) { - s3 = peg$c4; - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e8); } - } - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f50(s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseexplicit_flag_key() { - let s0, s1, s2, s3, s4; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 5) === peg$c5) { - s1 = peg$c5; - peg$currPos += 5; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e9); } - } - if (s1 !== peg$FAILED) { - s2 = peg$parseopen_bracket(); - if (s2 !== peg$FAILED) { - s3 = peg$parseescaped_key(); - if (s3 !== peg$FAILED) { - s4 = peg$parseclosed_bracket(); - if (s4 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f51(s1, s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseexplicit_string_flag_key() { - let s0, s1, s2, s3, s4, s5, s6, s7, s8; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 5) === peg$c5) { - s1 = peg$c5; - peg$currPos += 5; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e9); } - } - if (s1 !== peg$FAILED) { - s2 = peg$parseopen_bracket(); - if (s2 !== peg$FAILED) { - s3 = peg$parseescaped_key(); - if (s3 !== peg$FAILED) { - s4 = peg$parsespaces(); - s5 = peg$parsecomma(); - if (s5 !== peg$FAILED) { - s6 = peg$parsespaces(); - if (input.substr(peg$currPos, 6) === peg$c6) { - s7 = peg$c6; - peg$currPos += 6; - } else { - s7 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e10); } - } - if (s7 !== peg$FAILED) { - s8 = peg$parseclosed_bracket(); - if (s8 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f52(s1, s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseexplicit_number_flag_key() { - let s0, s1, s2, s3, s4, s5, s6, s7, s8; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 5) === peg$c5) { - s1 = peg$c5; - peg$currPos += 5; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e9); } - } - if (s1 !== peg$FAILED) { - s2 = peg$parseopen_bracket(); - if (s2 !== peg$FAILED) { - s3 = peg$parseescaped_key(); - if (s3 !== peg$FAILED) { - s4 = peg$parsespaces(); - s5 = peg$parsecomma(); - if (s5 !== peg$FAILED) { - s6 = peg$parsespaces(); - if (input.substr(peg$currPos, 6) === peg$c7) { - s7 = peg$c7; - peg$currPos += 6; - } else { - s7 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e11); } - } - if (s7 !== peg$FAILED) { - s8 = peg$parseclosed_bracket(); - if (s8 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f53(s1, s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseexplicit_tag_key() { - let s0, s1, s2, s3, s4; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 4) === peg$c8) { - s1 = peg$c8; - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e12); } - } - if (s1 !== peg$FAILED) { - s2 = peg$parseopen_bracket(); - if (s2 !== peg$FAILED) { - s3 = peg$parseescaped_key(); - if (s3 !== peg$FAILED) { - s4 = peg$parseclosed_bracket(); - if (s4 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f54(s1, s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseexplicit_string_tag_key() { - let s0, s1, s2, s3, s4, s5, s6, s7, s8; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 4) === peg$c8) { - s1 = peg$c8; - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e12); } - } - if (s1 !== peg$FAILED) { - s2 = peg$parseopen_bracket(); - if (s2 !== peg$FAILED) { - s3 = peg$parseescaped_key(); - if (s3 !== peg$FAILED) { - s4 = peg$parsespaces(); - s5 = peg$parsecomma(); - if (s5 !== peg$FAILED) { - s6 = peg$parsespaces(); - if (input.substr(peg$currPos, 6) === peg$c6) { - s7 = peg$c6; - peg$currPos += 6; - } else { - s7 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e10); } - } - if (s7 !== peg$FAILED) { - s8 = peg$parseclosed_bracket(); - if (s8 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f55(s1, s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseexplicit_number_tag_key() { - let s0, s1, s2, s3, s4, s5, s6, s7, s8; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 4) === peg$c8) { - s1 = peg$c8; - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e12); } - } - if (s1 !== peg$FAILED) { - s2 = peg$parseopen_bracket(); - if (s2 !== peg$FAILED) { - s3 = peg$parseescaped_key(); - if (s3 !== peg$FAILED) { - s4 = peg$parsespaces(); - s5 = peg$parsecomma(); - if (s5 !== peg$FAILED) { - s6 = peg$parsespaces(); - if (input.substr(peg$currPos, 6) === peg$c7) { - s7 = peg$c7; - peg$currPos += 6; - } else { - s7 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e11); } - } - if (s7 !== peg$FAILED) { - s8 = peg$parseclosed_bracket(); - if (s8 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f56(s1, s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseexplicit_boolean_tag_key() { - let s0, s1, s2, s3, s4, s5, s6, s7, s8; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 4) === peg$c8) { - s1 = peg$c8; - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e12); } - } - if (s1 !== peg$FAILED) { - s2 = peg$parseopen_bracket(); - if (s2 !== peg$FAILED) { - s3 = peg$parseescaped_key(); - if (s3 !== peg$FAILED) { - s4 = peg$parsespaces(); - s5 = peg$parsecomma(); - if (s5 !== peg$FAILED) { - s6 = peg$parsespaces(); - if (input.substr(peg$currPos, 7) === peg$c9) { - s7 = peg$c9; - peg$currPos += 7; - } else { - s7 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e13); } - } - if (s7 !== peg$FAILED) { - s8 = peg$parseclosed_bracket(); - if (s8 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f57(s1, s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseexplicit_array_tag_key() { - let s0, s1, s2, s3, s4, s5, s6, s7, s8; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 4) === peg$c8) { - s1 = peg$c8; - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e12); } - } - if (s1 !== peg$FAILED) { - s2 = peg$parseopen_bracket(); - if (s2 !== peg$FAILED) { - s3 = peg$parseescaped_key(); - if (s3 !== peg$FAILED) { - s4 = peg$parsespaces(); - s5 = peg$parsecomma(); - if (s5 !== peg$FAILED) { - s6 = peg$parsespaces(); - if (input.substr(peg$currPos, 5) === peg$c10) { - s7 = peg$c10; - peg$currPos += 5; - } else { - s7 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e14); } - } - if (s7 !== peg$FAILED) { - s8 = peg$parseclosed_bracket(); - if (s8 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f58(s1, s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsearray_access_suffix() { - let s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$parseopen_bracket(); - if (s1 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 42) { - s2 = peg$c11; - peg$currPos++; - } else { - s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e15); } - } - if (s2 !== peg$FAILED) { - s3 = peg$parseclosed_bracket(); - if (s3 !== peg$FAILED) { - s1 = [s1, s2, s3]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsearray_includes_tag_key() { - let s0, s1, s2, s3, s4, s5, s6, s7, s8, s9; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 4) === peg$c8) { - s1 = peg$c8; - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e12); } - } - if (s1 !== peg$FAILED) { - s2 = peg$parseopen_bracket(); - if (s2 !== peg$FAILED) { - s3 = peg$parseescaped_key(); - if (s3 !== peg$FAILED) { - s4 = peg$parsearray_access_suffix(); - if (s4 !== peg$FAILED) { - s5 = peg$parsespaces(); - s6 = peg$parsecomma(); - if (s6 !== peg$FAILED) { - s7 = peg$parsespaces(); - if (input.substr(peg$currPos, 5) === peg$c10) { - s8 = peg$c10; - peg$currPos += 5; - } else { - s8 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e14); } - } - if (s8 !== peg$FAILED) { - s9 = peg$parseclosed_bracket(); - if (s9 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f59(s1, s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsearray_includes_attr_key() { - let s0, s1, s2; - - s0 = peg$currPos; - s1 = peg$parsekey(); - if (s1 !== peg$FAILED) { - s2 = peg$parsearray_access_suffix(); - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f60(s1); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsearray_includes_key() { - let s0; - - s0 = peg$parsearray_includes_tag_key(); - if (s0 === peg$FAILED) { - s0 = peg$parsearray_includes_attr_key(); - } - - return s0; - } - - function peg$parseaggregate_key() { - let s0, s1, s2, s3, s4, s5, s6; - - s0 = peg$currPos; - s1 = peg$parsekey(); - if (s1 !== peg$FAILED) { - s2 = peg$parseopen_paren(); - if (s2 !== peg$FAILED) { - s3 = peg$parsespaces(); - s4 = peg$parsefunction_args(); - if (s4 === peg$FAILED) { - s4 = null; - } - s5 = peg$parsespaces(); - s6 = peg$parseclosed_paren(); - if (s6 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f61(s1, s3, s4, s5); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsefunction_args() { - let s0, s1, s2, s3, s4, s5, s6, s7, s8, s9; - - s0 = peg$currPos; - s1 = peg$parseaggregate_param(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parsespaces(); - s5 = peg$parsecomma(); - if (s5 !== peg$FAILED) { - s6 = peg$parsespaces(); - s7 = peg$currPos; - s8 = peg$currPos; - peg$silentFails++; - s9 = peg$parsecomma(); - peg$silentFails--; - if (s9 === peg$FAILED) { - s8 = undefined; - } else { - peg$currPos = s8; - s8 = peg$FAILED; - } - if (s8 !== peg$FAILED) { - s9 = peg$parseaggregate_param(); - if (s9 !== peg$FAILED) { - s8 = [s8, s9]; - s7 = s8; - } else { - peg$currPos = s7; - s7 = peg$FAILED; - } - } else { - peg$currPos = s7; - s7 = peg$FAILED; - } - if (s7 === peg$FAILED) { - s7 = null; - } - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parsespaces(); - s5 = peg$parsecomma(); - if (s5 !== peg$FAILED) { - s6 = peg$parsespaces(); - s7 = peg$currPos; - s8 = peg$currPos; - peg$silentFails++; - s9 = peg$parsecomma(); - peg$silentFails--; - if (s9 === peg$FAILED) { - s8 = undefined; - } else { - peg$currPos = s8; - s8 = peg$FAILED; - } - if (s8 !== peg$FAILED) { - s9 = peg$parseaggregate_param(); - if (s9 !== peg$FAILED) { - s8 = [s8, s9]; - s7 = s8; - } else { - peg$currPos = s7; - s7 = peg$FAILED; - } - } else { - peg$currPos = s7; - s7 = peg$FAILED; - } - if (s7 === peg$FAILED) { - s7 = null; - } - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } - peg$savedPos = s0; - s0 = peg$f62(s1, s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseaggregate_param() { - let s0; - - s0 = peg$parseexplicit_tag_aggregate_param(); - if (s0 === peg$FAILED) { - s0 = peg$parsequoted_aggregate_param(); - if (s0 === peg$FAILED) { - s0 = peg$parseraw_aggregate_param(); - } - } - - return s0; - } - - function peg$parseraw_aggregate_param() { - let s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$currPos; - s2 = []; - s3 = input.charAt(peg$currPos); - if (peg$r4.test(s3)) { - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e16); } - } - if (s3 !== peg$FAILED) { - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = input.charAt(peg$currPos); - if (peg$r4.test(s3)) { - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e16); } - } - } - } else { - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = input.substring(s1, peg$currPos); - } else { - s1 = s2; - } - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f63(s1); - } - s0 = s1; - - return s0; - } - - function peg$parsequoted_aggregate_param() { - let s0, s1, s2, s3, s4; - - s0 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 34) { - s1 = peg$c4; - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e8); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - s3 = []; - if (input.substr(peg$currPos, 2) === peg$c12) { - s4 = peg$c12; - peg$currPos += 2; - } else { - s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e17); } - } - if (s4 === peg$FAILED) { - s4 = input.charAt(peg$currPos); - if (peg$r5.test(s4)) { - peg$currPos++; - } else { - s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e18); } - } - } - while (s4 !== peg$FAILED) { - s3.push(s4); - if (input.substr(peg$currPos, 2) === peg$c12) { - s4 = peg$c12; - peg$currPos += 2; - } else { - s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e17); } - } - if (s4 === peg$FAILED) { - s4 = input.charAt(peg$currPos); - if (peg$r5.test(s4)) { - peg$currPos++; - } else { - s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e18); } - } - } - } - s2 = input.substring(s2, peg$currPos); - if (input.charCodeAt(peg$currPos) === 34) { - s3 = peg$c4; - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e8); } - } - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f64(s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseexplicit_tag_aggregate_param() { - let s0, s1; - - s0 = peg$currPos; - s1 = peg$parseexplicit_tag_key(); - if (s1 === peg$FAILED) { - s1 = peg$parseexplicit_string_tag_key(); - if (s1 === peg$FAILED) { - s1 = peg$parseexplicit_number_tag_key(); - if (s1 === peg$FAILED) { - s1 = peg$parseexplicit_boolean_tag_key(); - } - } - } - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f65(s1); - } - s0 = s1; - - return s0; - } - - function peg$parsesearch_key() { - let s0; - - s0 = peg$parseexplicit_number_flag_key(); - if (s0 === peg$FAILED) { - s0 = peg$parseexplicit_number_tag_key(); - if (s0 === peg$FAILED) { - s0 = peg$parseexplicit_boolean_tag_key(); - if (s0 === peg$FAILED) { - s0 = peg$parsekey(); - if (s0 === peg$FAILED) { - s0 = peg$parsequoted_key(); - } - } - } - } - - return s0; - } - - function peg$parsetext_key() { - let s0; - - s0 = peg$parseexplicit_flag_key(); - if (s0 === peg$FAILED) { - s0 = peg$parseexplicit_string_flag_key(); - if (s0 === peg$FAILED) { - s0 = peg$parseexplicit_tag_key(); - if (s0 === peg$FAILED) { - s0 = peg$parseexplicit_string_tag_key(); - if (s0 === peg$FAILED) { - s0 = peg$parseexplicit_array_tag_key(); - if (s0 === peg$FAILED) { - s0 = peg$parsesearch_key(); - } - } - } - } - } - - return s0; - } - - function peg$parsevalue() { - let s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$currPos; - s2 = []; - s3 = input.charAt(peg$currPos); - if (peg$r6.test(s3)) { - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e19); } - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = input.charAt(peg$currPos); - if (peg$r6.test(s3)) { - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e19); } - } - } - s1 = input.substring(s1, peg$currPos); - peg$savedPos = s0; - s1 = peg$f66(s1); - s0 = s1; - - return s0; - } - - function peg$parsequoted_value() { - let s0, s1, s2, s3, s4; - - s0 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 34) { - s1 = peg$c4; - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e8); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - s3 = []; - if (input.substr(peg$currPos, 2) === peg$c12) { - s4 = peg$c12; - peg$currPos += 2; - } else { - s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e17); } - } - if (s4 === peg$FAILED) { - s4 = input.charAt(peg$currPos); - if (peg$r7.test(s4)) { - peg$currPos++; - } else { - s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e20); } - } - } - while (s4 !== peg$FAILED) { - s3.push(s4); - if (input.substr(peg$currPos, 2) === peg$c12) { - s4 = peg$c12; - peg$currPos += 2; - } else { - s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e17); } - } - if (s4 === peg$FAILED) { - s4 = input.charAt(peg$currPos); - if (peg$r7.test(s4)) { - peg$currPos++; - } else { - s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e20); } - } - } - } - s2 = input.substring(s2, peg$currPos); - if (input.charCodeAt(peg$currPos) === 34) { - s3 = peg$c4; - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e8); } - } - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f67(s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsein_value() { - let s0, s1, s2, s3, s4; - - s0 = peg$currPos; - s1 = []; - s2 = peg$currPos; - s3 = peg$currPos; - peg$silentFails++; - s4 = peg$parsein_value_termination(); - peg$silentFails--; - if (s4 !== peg$FAILED) { - peg$currPos = s3; - s3 = undefined; - } else { - s3 = peg$FAILED; - } - if (s3 !== peg$FAILED) { - s4 = peg$parsein_value_char(); - if (s4 !== peg$FAILED) { - s3 = [s3, s4]; - s2 = s3; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - while (s2 !== peg$FAILED) { - s1.push(s2); - s2 = peg$currPos; - s3 = peg$currPos; - peg$silentFails++; - s4 = peg$parsein_value_termination(); - peg$silentFails--; - if (s4 !== peg$FAILED) { - peg$currPos = s3; - s3 = undefined; - } else { - s3 = peg$FAILED; - } - if (s3 !== peg$FAILED) { - s4 = peg$parsein_value_char(); - if (s4 !== peg$FAILED) { - s3 = [s3, s4]; - s2 = s3; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - } - } else { - s1 = peg$FAILED; - } - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f68(); - } - s0 = s1; - - return s0; - } - - function peg$parsetext_in_value() { - let s0; - - s0 = peg$parsequoted_value(); - if (s0 === peg$FAILED) { - s0 = peg$parsein_value(); - } - - return s0; - } - - function peg$parsesearch_value() { - let s0; - - s0 = peg$parsequoted_value(); - if (s0 === peg$FAILED) { - s0 = peg$parsevalue(); - } - - return s0; - } - - function peg$parsenumeric_value() { - let s0, s1, s2, s3, s4; - - s0 = peg$currPos; - s1 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 45) { - s2 = peg$c13; - peg$currPos++; - } else { - s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e21); } - } - if (s2 === peg$FAILED) { - s2 = null; - } - s3 = peg$parsenumeric(); - if (s3 !== peg$FAILED) { - s2 = [s2, s3]; - s1 = s2; - } else { - peg$currPos = s1; - s1 = peg$FAILED; - } - if (s1 !== peg$FAILED) { - s2 = peg$parsenumber_unit(); - if (s2 === peg$FAILED) { - s2 = null; - } - s3 = peg$currPos; - peg$silentFails++; - s4 = peg$parseend_value(); - if (s4 === peg$FAILED) { - s4 = input.charAt(peg$currPos); - if (peg$r8.test(s4)) { - peg$currPos++; - } else { - s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e22); } - } - } - peg$silentFails--; - if (s4 !== peg$FAILED) { - peg$currPos = s3; - s3 = undefined; - } else { - s3 = peg$FAILED; - } - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f69(s1, s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseboolean_value() { - let s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = input.substr(peg$currPos, 4); - if (s1.toLowerCase() === peg$c14) { - peg$currPos += (4); - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e23); } - } - if (s1 === peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 49) { - s1 = peg$c15; - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e24); } - } - if (s1 === peg$FAILED) { - s1 = input.substr(peg$currPos, 5); - if (s1.toLowerCase() === peg$c16) { - peg$currPos += (5); - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e25); } - } - if (s1 === peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 48) { - s1 = peg$c17; - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e26); } - } - } - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseend_value(); - peg$silentFails--; - if (s3 !== peg$FAILED) { - peg$currPos = s2; - s2 = undefined; - } else { - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f70(s1); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsetext_in_list() { - let s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10; - - s0 = peg$currPos; - s1 = peg$parseopen_bracket(); - if (s1 !== peg$FAILED) { - s2 = peg$parsetext_in_value(); - if (s2 !== peg$FAILED) { - s3 = []; - s4 = peg$currPos; - s5 = peg$parsespaces(); - s6 = peg$parsecomma(); - if (s6 !== peg$FAILED) { - s7 = peg$parsespaces(); - s8 = peg$currPos; - s9 = peg$currPos; - peg$silentFails++; - s10 = peg$parsecomma(); - peg$silentFails--; - if (s10 === peg$FAILED) { - s9 = undefined; - } else { - peg$currPos = s9; - s9 = peg$FAILED; - } - if (s9 !== peg$FAILED) { - s10 = peg$parsetext_in_value(); - if (s10 !== peg$FAILED) { - s9 = [s9, s10]; - s8 = s9; - } else { - peg$currPos = s8; - s8 = peg$FAILED; - } - } else { - peg$currPos = s8; - s8 = peg$FAILED; - } - if (s8 === peg$FAILED) { - s8 = null; - } - s5 = [s5, s6, s7, s8]; - s4 = s5; - } else { - peg$currPos = s4; - s4 = peg$FAILED; - } - while (s4 !== peg$FAILED) { - s3.push(s4); - s4 = peg$currPos; - s5 = peg$parsespaces(); - s6 = peg$parsecomma(); - if (s6 !== peg$FAILED) { - s7 = peg$parsespaces(); - s8 = peg$currPos; - s9 = peg$currPos; - peg$silentFails++; - s10 = peg$parsecomma(); - peg$silentFails--; - if (s10 === peg$FAILED) { - s9 = undefined; - } else { - peg$currPos = s9; - s9 = peg$FAILED; - } - if (s9 !== peg$FAILED) { - s10 = peg$parsetext_in_value(); - if (s10 !== peg$FAILED) { - s9 = [s9, s10]; - s8 = s9; - } else { - peg$currPos = s8; - s8 = peg$FAILED; - } - } else { - peg$currPos = s8; - s8 = peg$FAILED; - } - if (s8 === peg$FAILED) { - s8 = null; - } - s5 = [s5, s6, s7, s8]; - s4 = s5; - } else { - peg$currPos = s4; - s4 = peg$FAILED; - } - } - s4 = peg$parseclosed_bracket(); - if (s4 !== peg$FAILED) { - s5 = peg$currPos; - peg$silentFails++; - s6 = peg$parseend_value(); - peg$silentFails--; - if (s6 !== peg$FAILED) { - peg$currPos = s5; - s5 = undefined; - } else { - s5 = peg$FAILED; - } - if (s5 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f71(s2, s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsenumeric_in_list() { - let s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10; - - s0 = peg$currPos; - s1 = peg$parseopen_bracket(); - if (s1 !== peg$FAILED) { - s2 = peg$parsenumeric_value(); - if (s2 !== peg$FAILED) { - s3 = []; - s4 = peg$currPos; - s5 = peg$parsespaces(); - s6 = peg$parsecomma(); - if (s6 !== peg$FAILED) { - s7 = peg$parsespaces(); - s8 = peg$currPos; - s9 = peg$currPos; - peg$silentFails++; - s10 = peg$parsecomma(); - peg$silentFails--; - if (s10 === peg$FAILED) { - s9 = undefined; - } else { - peg$currPos = s9; - s9 = peg$FAILED; - } - if (s9 !== peg$FAILED) { - s10 = peg$parsenumeric_value(); - if (s10 !== peg$FAILED) { - s9 = [s9, s10]; - s8 = s9; - } else { - peg$currPos = s8; - s8 = peg$FAILED; - } - } else { - peg$currPos = s8; - s8 = peg$FAILED; - } - if (s8 === peg$FAILED) { - s8 = null; - } - s5 = [s5, s6, s7, s8]; - s4 = s5; - } else { - peg$currPos = s4; - s4 = peg$FAILED; - } - while (s4 !== peg$FAILED) { - s3.push(s4); - s4 = peg$currPos; - s5 = peg$parsespaces(); - s6 = peg$parsecomma(); - if (s6 !== peg$FAILED) { - s7 = peg$parsespaces(); - s8 = peg$currPos; - s9 = peg$currPos; - peg$silentFails++; - s10 = peg$parsecomma(); - peg$silentFails--; - if (s10 === peg$FAILED) { - s9 = undefined; - } else { - peg$currPos = s9; - s9 = peg$FAILED; - } - if (s9 !== peg$FAILED) { - s10 = peg$parsenumeric_value(); - if (s10 !== peg$FAILED) { - s9 = [s9, s10]; - s8 = s9; - } else { - peg$currPos = s8; - s8 = peg$FAILED; - } - } else { - peg$currPos = s8; - s8 = peg$FAILED; - } - if (s8 === peg$FAILED) { - s8 = null; - } - s5 = [s5, s6, s7, s8]; - s4 = s5; - } else { - peg$currPos = s4; - s4 = peg$FAILED; - } - } - s4 = peg$parseclosed_bracket(); - if (s4 !== peg$FAILED) { - s5 = peg$currPos; - peg$silentFails++; - s6 = peg$parseend_value(); - peg$silentFails--; - if (s6 !== peg$FAILED) { - peg$currPos = s5; - s5 = undefined; - } else { - s5 = peg$FAILED; - } - if (s5 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f72(s2, s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsewildcard_op() { - let s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$parsewildcard_unicode(); - if (s1 !== peg$FAILED) { - s2 = peg$parsecontains(); - if (s2 === peg$FAILED) { - s2 = peg$parsestarts_with(); - if (s2 === peg$FAILED) { - s2 = peg$parseends_with(); - } - } - if (s2 !== peg$FAILED) { - s3 = peg$parsewildcard_unicode(); - if (s3 !== peg$FAILED) { - s1 = [s1, s2, s3]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsein_value_termination() { - let s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - s1 = peg$parsein_value_char(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$currPos; - peg$silentFails++; - s5 = peg$parsein_value_end(); - peg$silentFails--; - if (s5 === peg$FAILED) { - s4 = undefined; - } else { - peg$currPos = s4; - s4 = peg$FAILED; - } - if (s4 !== peg$FAILED) { - s5 = peg$parsein_value_char(); - if (s5 !== peg$FAILED) { - s4 = [s4, s5]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$currPos; - peg$silentFails++; - s5 = peg$parsein_value_end(); - peg$silentFails--; - if (s5 === peg$FAILED) { - s4 = undefined; - } else { - peg$currPos = s4; - s4 = peg$FAILED; - } - if (s4 !== peg$FAILED) { - s5 = peg$parsein_value_char(); - if (s5 !== peg$FAILED) { - s4 = [s4, s5]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } - s3 = peg$parsein_value_end(); - if (s3 !== peg$FAILED) { - s1 = [s1, s2, s3]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsein_value_char() { - let s0; - - s0 = input.charAt(peg$currPos); - if (peg$r9.test(s0)) { - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e27); } - } - - return s0; - } - - function peg$parsein_value_end() { - let s0, s1, s2; - - s0 = peg$parseclosed_bracket(); - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parsespaces(); - s2 = peg$parsecomma(); - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } - - return s0; - } - - function peg$parsenum2() { - let s0, s1, s2; - - s0 = peg$currPos; - s1 = input.charAt(peg$currPos); - if (peg$r10.test(s1)) { - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e28); } - } - if (s1 !== peg$FAILED) { - s2 = input.charAt(peg$currPos); - if (peg$r10.test(s2)) { - peg$currPos++; - } else { - s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e28); } - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsenum4() { - let s0, s1, s2, s3, s4; - - s0 = peg$currPos; - s1 = input.charAt(peg$currPos); - if (peg$r10.test(s1)) { - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e28); } - } - if (s1 !== peg$FAILED) { - s2 = input.charAt(peg$currPos); - if (peg$r10.test(s2)) { - peg$currPos++; - } else { - s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e28); } - } - if (s2 !== peg$FAILED) { - s3 = input.charAt(peg$currPos); - if (peg$r10.test(s3)) { - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e28); } - } - if (s3 !== peg$FAILED) { - s4 = input.charAt(peg$currPos); - if (peg$r10.test(s4)) { - peg$currPos++; - } else { - s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e28); } - } - if (s4 !== peg$FAILED) { - s1 = [s1, s2, s3, s4]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsedate_format() { - let s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - s1 = peg$parsenum4(); - if (s1 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 45) { - s2 = peg$c13; - peg$currPos++; - } else { - s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e21); } - } - if (s2 !== peg$FAILED) { - s3 = peg$parsenum2(); - if (s3 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 45) { - s4 = peg$c13; - peg$currPos++; - } else { - s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e21); } - } - if (s4 !== peg$FAILED) { - s5 = peg$parsenum2(); - if (s5 !== peg$FAILED) { - s1 = [s1, s2, s3, s4, s5]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsetime_format() { - let s0, s1, s2, s3, s4, s5, s6, s7, s8, s9; - - s0 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 84) { - s1 = peg$c18; - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e29); } - } - if (s1 !== peg$FAILED) { - s2 = peg$parsenum2(); - if (s2 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 58) { - s3 = peg$c19; - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e30); } - } - if (s3 !== peg$FAILED) { - s4 = peg$parsenum2(); - if (s4 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 58) { - s5 = peg$c19; - peg$currPos++; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e30); } - } - if (s5 !== peg$FAILED) { - s6 = peg$parsenum2(); - if (s6 !== peg$FAILED) { - s7 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 46) { - s8 = peg$c20; - peg$currPos++; - } else { - s8 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e31); } - } - if (s8 !== peg$FAILED) { - s9 = peg$parsems_format(); - if (s9 !== peg$FAILED) { - s8 = [s8, s9]; - s7 = s8; - } else { - peg$currPos = s7; - s7 = peg$FAILED; - } - } else { - peg$currPos = s7; - s7 = peg$FAILED; - } - if (s7 === peg$FAILED) { - s7 = null; - } - s1 = [s1, s2, s3, s4, s5, s6, s7]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsems_format() { - let s0, s1, s2, s3, s4, s5, s6; - - s0 = peg$currPos; - s1 = input.charAt(peg$currPos); - if (peg$r10.test(s1)) { - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e28); } - } - if (s1 !== peg$FAILED) { - s2 = input.charAt(peg$currPos); - if (peg$r10.test(s2)) { - peg$currPos++; - } else { - s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e28); } - } - if (s2 === peg$FAILED) { - s2 = null; - } - s3 = input.charAt(peg$currPos); - if (peg$r10.test(s3)) { - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e28); } - } - if (s3 === peg$FAILED) { - s3 = null; - } - s4 = input.charAt(peg$currPos); - if (peg$r10.test(s4)) { - peg$currPos++; - } else { - s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e28); } - } - if (s4 === peg$FAILED) { - s4 = null; - } - s5 = input.charAt(peg$currPos); - if (peg$r10.test(s5)) { - peg$currPos++; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e28); } - } - if (s5 === peg$FAILED) { - s5 = null; - } - s6 = input.charAt(peg$currPos); - if (peg$r10.test(s6)) { - peg$currPos++; - } else { - s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e28); } - } - if (s6 === peg$FAILED) { - s6 = null; - } - s1 = [s1, s2, s3, s4, s5, s6]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsetz_format() { - let s0, s1, s2, s3, s4; - - s0 = peg$currPos; - s1 = input.charAt(peg$currPos); - if (peg$r11.test(s1)) { - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e32); } - } - if (s1 !== peg$FAILED) { - s2 = peg$parsenum2(); - if (s2 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 58) { - s3 = peg$c19; - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e30); } - } - if (s3 !== peg$FAILED) { - s4 = peg$parsenum2(); - if (s4 !== peg$FAILED) { - s1 = [s1, s2, s3, s4]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseiso_8601_date_format() { - let s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - s1 = peg$parsedate_format(); - if (s1 !== peg$FAILED) { - s2 = peg$parsetime_format(); - if (s2 === peg$FAILED) { - s2 = null; - } - if (input.charCodeAt(peg$currPos) === 90) { - s3 = peg$c21; - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e33); } - } - if (s3 === peg$FAILED) { - s3 = peg$parsetz_format(); - } - if (s3 === peg$FAILED) { - s3 = null; - } - s4 = peg$currPos; - peg$silentFails++; - s5 = peg$parseend_value(); - peg$silentFails--; - if (s5 !== peg$FAILED) { - peg$currPos = s4; - s4 = undefined; - } else { - s4 = peg$FAILED; - } - if (s4 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f73(s1, s2, s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parserel_date_format() { - let s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - s1 = input.charAt(peg$currPos); - if (peg$r11.test(s1)) { - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e32); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - s3 = []; - s4 = input.charAt(peg$currPos); - if (peg$r10.test(s4)) { - peg$currPos++; - } else { - s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e28); } - } - if (s4 !== peg$FAILED) { - while (s4 !== peg$FAILED) { - s3.push(s4); - s4 = input.charAt(peg$currPos); - if (peg$r10.test(s4)) { - peg$currPos++; - } else { - s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e28); } - } - } - } else { - s3 = peg$FAILED; - } - if (s3 !== peg$FAILED) { - s2 = input.substring(s2, peg$currPos); - } else { - s2 = s3; - } - if (s2 !== peg$FAILED) { - s3 = input.charAt(peg$currPos); - if (peg$r12.test(s3)) { - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e34); } - } - if (s3 !== peg$FAILED) { - s4 = peg$currPos; - peg$silentFails++; - s5 = peg$parseend_value(); - peg$silentFails--; - if (s5 !== peg$FAILED) { - peg$currPos = s4; - s4 = undefined; - } else { - s4 = peg$FAILED; - } - if (s4 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f74(s1, s2, s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseduration_format() { - let s0, s1, s2, s3, s4; - - s0 = peg$currPos; - s1 = peg$parsenumeric(); - if (s1 !== peg$FAILED) { - s2 = peg$parseduration_unit(); - if (s2 !== peg$FAILED) { - s3 = peg$currPos; - peg$silentFails++; - s4 = peg$parseend_value(); - peg$silentFails--; - if (s4 !== peg$FAILED) { - peg$currPos = s3; - s3 = undefined; - } else { - s3 = peg$FAILED; - } - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f75(s1, s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsesize_format() { - let s0, s1, s2, s3, s4; - - s0 = peg$currPos; - s1 = peg$parsenumeric(); - if (s1 !== peg$FAILED) { - s2 = peg$parsesize_unit(); - if (s2 !== peg$FAILED) { - s3 = peg$currPos; - peg$silentFails++; - s4 = peg$parseend_value(); - peg$silentFails--; - if (s4 !== peg$FAILED) { - peg$currPos = s3; - s3 = undefined; - } else { - s3 = peg$FAILED; - } - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f76(s1, s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsepercentage_format() { - let s0, s1, s2; - - s0 = peg$currPos; - s1 = peg$parsenumeric(); - if (s1 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 37) { - s2 = peg$c22; - peg$currPos++; - } else { - s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e35); } - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f77(s1); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsenumber_unit() { - let s0; - - s0 = input.charAt(peg$currPos); - if (peg$r13.test(s0)) { - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e36); } - } - - return s0; - } - - function peg$parseduration_unit() { - let s0; - - if (input.substr(peg$currPos, 2) === peg$c23) { - s0 = peg$c23; - peg$currPos += 2; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e37); } - } - if (s0 === peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 115) { - s0 = peg$c24; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e38); } - } - if (s0 === peg$FAILED) { - if (input.substr(peg$currPos, 3) === peg$c25) { - s0 = peg$c25; - peg$currPos += 3; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e39); } - } - if (s0 === peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 109) { - s0 = peg$c26; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e40); } - } - if (s0 === peg$FAILED) { - if (input.substr(peg$currPos, 2) === peg$c27) { - s0 = peg$c27; - peg$currPos += 2; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e41); } - } - if (s0 === peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 104) { - s0 = peg$c28; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e42); } - } - if (s0 === peg$FAILED) { - if (input.substr(peg$currPos, 3) === peg$c29) { - s0 = peg$c29; - peg$currPos += 3; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e43); } - } - if (s0 === peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 100) { - s0 = peg$c30; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e44); } - } - if (s0 === peg$FAILED) { - if (input.substr(peg$currPos, 2) === peg$c31) { - s0 = peg$c31; - peg$currPos += 2; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e45); } - } - if (s0 === peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 119) { - s0 = peg$c32; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e46); } - } - } - } - } - } - } - } - } - } - } - - return s0; - } - - function peg$parsesize_unit() { - let s0; - - s0 = peg$parsebit_unit(); - if (s0 === peg$FAILED) { - s0 = peg$parsebyte_unit(); - } - - return s0; - } - - function peg$parsebit_unit() { - let s0; - - s0 = input.substr(peg$currPos, 3); - if (s0.toLowerCase() === peg$c33) { - peg$currPos += (3); - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e47); } - } - if (s0 === peg$FAILED) { - s0 = input.substr(peg$currPos, 3); - if (s0.toLowerCase() === peg$c34) { - peg$currPos += (3); - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e48); } - } - if (s0 === peg$FAILED) { - s0 = input.substr(peg$currPos, 3); - if (s0.toLowerCase() === peg$c35) { - peg$currPos += (3); - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e49); } - } - if (s0 === peg$FAILED) { - s0 = input.substr(peg$currPos, 3); - if (s0.toLowerCase() === peg$c36) { - peg$currPos += (3); - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e50); } - } - if (s0 === peg$FAILED) { - s0 = input.substr(peg$currPos, 3); - if (s0.toLowerCase() === peg$c37) { - peg$currPos += (3); - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e51); } - } - if (s0 === peg$FAILED) { - s0 = input.substr(peg$currPos, 3); - if (s0.toLowerCase() === peg$c38) { - peg$currPos += (3); - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e52); } - } - if (s0 === peg$FAILED) { - s0 = input.substr(peg$currPos, 3); - if (s0.toLowerCase() === peg$c39) { - peg$currPos += (3); - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e53); } - } - if (s0 === peg$FAILED) { - s0 = input.substr(peg$currPos, 3); - if (s0.toLowerCase() === peg$c40) { - peg$currPos += (3); - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e54); } - } - if (s0 === peg$FAILED) { - s0 = input.substr(peg$currPos, 3); - if (s0.toLowerCase() === peg$c41) { - peg$currPos += (3); - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e55); } - } - } - } - } - } - } - } - } - } - - return s0; - } - - function peg$parsebyte_unit() { - let s0; - - s0 = input.substr(peg$currPos, 5); - if (s0.toLowerCase() === peg$c42) { - peg$currPos += (5); - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e56); } - } - if (s0 === peg$FAILED) { - s0 = input.substr(peg$currPos, 2); - if (s0.toLowerCase() === peg$c43) { - peg$currPos += (2); - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e57); } - } - if (s0 === peg$FAILED) { - s0 = input.substr(peg$currPos, 2); - if (s0.toLowerCase() === peg$c44) { - peg$currPos += (2); - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e58); } - } - if (s0 === peg$FAILED) { - s0 = input.substr(peg$currPos, 2); - if (s0.toLowerCase() === peg$c45) { - peg$currPos += (2); - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e59); } - } - if (s0 === peg$FAILED) { - s0 = input.substr(peg$currPos, 2); - if (s0.toLowerCase() === peg$c46) { - peg$currPos += (2); - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e60); } - } - if (s0 === peg$FAILED) { - s0 = input.substr(peg$currPos, 2); - if (s0.toLowerCase() === peg$c47) { - peg$currPos += (2); - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e61); } - } - if (s0 === peg$FAILED) { - s0 = input.substr(peg$currPos, 2); - if (s0.toLowerCase() === peg$c48) { - peg$currPos += (2); - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e62); } - } - if (s0 === peg$FAILED) { - s0 = input.substr(peg$currPos, 2); - if (s0.toLowerCase() === peg$c49) { - peg$currPos += (2); - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e63); } - } - if (s0 === peg$FAILED) { - s0 = input.substr(peg$currPos, 2); - if (s0.toLowerCase() === peg$c50) { - peg$currPos += (2); - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e64); } - } - if (s0 === peg$FAILED) { - s0 = input.substr(peg$currPos, 2); - if (s0.toLowerCase() === peg$c51) { - peg$currPos += (2); - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e65); } - } - } - } - } - } - } - } - } - } - } - - return s0; - } - - function peg$parseoperator() { - let s0; - - if (input.substr(peg$currPos, 2) === peg$c52) { - s0 = peg$c52; - peg$currPos += 2; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e66); } - } - if (s0 === peg$FAILED) { - if (input.substr(peg$currPos, 2) === peg$c53) { - s0 = peg$c53; - peg$currPos += 2; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e67); } - } - if (s0 === peg$FAILED) { - s0 = input.charAt(peg$currPos); - if (peg$r14.test(s0)) { - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e68); } - } - if (s0 === peg$FAILED) { - if (input.substr(peg$currPos, 2) === peg$c54) { - s0 = peg$c54; - peg$currPos += 2; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e69); } - } - } - } - } - - return s0; - } - - function peg$parseor_operator() { - let s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = input.substr(peg$currPos, 2); - if (s1.toLowerCase() === peg$c55) { - peg$currPos += (2); - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e70); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseend_value(); - peg$silentFails--; - if (s3 !== peg$FAILED) { - peg$currPos = s2; - s2 = undefined; - } else { - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseand_operator() { - let s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = input.substr(peg$currPos, 3); - if (s1.toLowerCase() === peg$c56) { - peg$currPos += (3); - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e71); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseend_value(); - peg$silentFails--; - if (s3 !== peg$FAILED) { - peg$currPos = s2; - s2 = undefined; - } else { - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsenumeric() { - let s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - s1 = []; - s2 = input.charAt(peg$currPos); - if (peg$r10.test(s2)) { - peg$currPos++; - } else { - s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e28); } - } - if (s2 !== peg$FAILED) { - while (s2 !== peg$FAILED) { - s1.push(s2); - s2 = input.charAt(peg$currPos); - if (peg$r10.test(s2)) { - peg$currPos++; - } else { - s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e28); } - } - } - } else { - s1 = peg$FAILED; - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 46) { - s3 = peg$c20; - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e31); } - } - if (s3 !== peg$FAILED) { - s4 = []; - s5 = input.charAt(peg$currPos); - if (peg$r10.test(s5)) { - peg$currPos++; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e28); } - } - while (s5 !== peg$FAILED) { - s4.push(s5); - s5 = input.charAt(peg$currPos); - if (peg$r10.test(s5)) { - peg$currPos++; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e28); } - } - } - s3 = [s3, s4]; - s2 = s3; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 === peg$FAILED) { - s2 = null; - } - peg$savedPos = s0; - s0 = peg$f78(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseopen_paren() { - let s0, s1; - - s0 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 40) { - s1 = peg$c0; - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e2); } - } - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f79(); - } - s0 = s1; - - return s0; - } - - function peg$parseclosed_paren() { - let s0, s1; - - s0 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 41) { - s1 = peg$c57; - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e72); } - } - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f80(); - } - s0 = s1; - - return s0; - } - - function peg$parseopen_bracket() { - let s0; - - if (input.charCodeAt(peg$currPos) === 91) { - s0 = peg$c58; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e73); } - } - - return s0; - } - - function peg$parseclosed_bracket() { - let s0; - - if (input.charCodeAt(peg$currPos) === 93) { - s0 = peg$c59; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e74); } - } - - return s0; - } - - function peg$parsesep() { - let s0; - - if (input.charCodeAt(peg$currPos) === 58) { - s0 = peg$c19; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e30); } - } - - return s0; - } - - function peg$parsenegation() { - let s0; - - if (input.charCodeAt(peg$currPos) === 33) { - s0 = peg$c60; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e75); } - } - - return s0; - } - - function peg$parsewildcard_unicode() { - let s0; - - s0 = input.charAt(peg$currPos); - if (peg$r15.test(s0)) { - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e76); } - } - - return s0; - } - - function peg$parsecontains() { - let s0; - - if (input.substr(peg$currPos, 8) === peg$c61) { - s0 = peg$c61; - peg$currPos += 8; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e77); } - } - - return s0; - } - - function peg$parsestarts_with() { - let s0; - - if (input.substr(peg$currPos, 10) === peg$c62) { - s0 = peg$c62; - peg$currPos += 10; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e78); } - } - - return s0; - } - - function peg$parseends_with() { - let s0; - - if (input.substr(peg$currPos, 8) === peg$c63) { - s0 = peg$c63; - peg$currPos += 8; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e79); } - } - - return s0; - } - - function peg$parsecomma() { - let s0; - - if (input.charCodeAt(peg$currPos) === 44) { - s0 = peg$c64; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e80); } - } - - return s0; - } - - function peg$parsespaces() { - let s0, s1, s2; - - s0 = peg$currPos; - s1 = []; - if (input.charCodeAt(peg$currPos) === 32) { - s2 = peg$c65; - peg$currPos++; - } else { - s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e81); } - } - while (s2 !== peg$FAILED) { - s1.push(s2); - if (input.charCodeAt(peg$currPos) === 32) { - s2 = peg$c65; - peg$currPos++; - } else { - s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e81); } - } - } - peg$savedPos = s0; - s1 = peg$f81(); - s0 = s1; - - return s0; - } - - function peg$parseend_value() { - let s0, s1; - - s0 = input.charAt(peg$currPos); - if (peg$r16.test(s0)) { - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e82); } - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - peg$silentFails++; - if (input.length > peg$currPos) { - s1 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e83); } - } - peg$silentFails--; - if (s1 === peg$FAILED) { - s0 = undefined; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } - - return s0; - } - - - const {TokenConverter, TermOperator, FilterType, config} = options; - const tc = new TokenConverter({text, location, config}); - - const opDefault = TermOperator.DEFAULT; - - peg$result = peg$startRuleFunction(); - - const peg$success = (peg$result !== peg$FAILED && peg$currPos === input.length); - function peg$throw() { - if (peg$result !== peg$FAILED && peg$currPos < input.length) { - peg$fail(peg$endExpectation()); - } - - throw peg$buildStructuredError( - peg$maxFailExpected, - peg$maxFailPos < input.length ? peg$getUnicode(peg$maxFailPos) : null, - peg$maxFailPos < input.length - ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1) - : peg$computeLocation(peg$maxFailPos, peg$maxFailPos) - ); - } - if (options.peg$library) { - return /** @type {any} */ ({ - peg$result, - peg$currPos, - peg$FAILED, - peg$maxFailExpected, - peg$maxFailPos, - peg$success, - peg$throw: peg$success ? undefined : peg$throw, - }); - } - if (peg$success) { - return peg$result; - } else { - peg$throw(); - } -} - -const peg$allowedStartRules = [ - "search" -]; - -export { - peg$allowedStartRules as StartRules, - peg$SyntaxError as SyntaxError, - peg$parse as parse -}; - diff --git a/packages/toolkit-core/src/search-query.ts b/packages/toolkit-core/src/search-query.ts index d05b55c3d..cec3ce544 100644 --- a/packages/toolkit-core/src/search-query.ts +++ b/packages/toolkit-core/src/search-query.ts @@ -28,7 +28,7 @@ * and the caller decides whether to log them or show them to a model. * * Boolean rewriting uses the Sentry frontend's search grammar through - * `./search-syntax.ts`. Its token tree is flattened into + * `@sentry/search-syntax`. Its token tree is flattened into * the {@link SearchNode} list below, which classifies every term * structurally — comparison operators, in-list values, paren groups, * etc. — so the rewriting logic doesn't need regex-based reject-lists. @@ -38,12 +38,10 @@ import { type FilterToken, - FilterType, type ParseResultToken, parseSearch, - TermOperator, - Token, -} from "./search-syntax.js"; +} from "@sentry/search-syntax/parser"; +import { FilterType, TermOperator, Token } from "@sentry/search-syntax/tokens"; /** A query that can't be rewritten into syntax the endpoint accepts. */ export class SearchQueryError extends Error { diff --git a/packages/toolkit-core/src/search-syntax.test.ts b/packages/toolkit-core/src/search-syntax.test.ts deleted file mode 100644 index fcfe82a68..000000000 --- a/packages/toolkit-core/src/search-syntax.test.ts +++ /dev/null @@ -1,303 +0,0 @@ -import { readdirSync, readFileSync } from "node:fs"; -import { dirname, join, resolve } from "node:path"; -import { fileURLToPath } from "node:url"; -import { describe, expect, it } from "vitest"; -import { - FilterType, - getKeyName, - type FilterToken, - type KeyToken, - type ParseResultToken, - parseSearch, - parseSearchOrThrow, - type SearchConfig, - TermOperator, - Token, - TokenConverter, -} from "./search-syntax"; - -// Copied from getsentry/sentry `fixtures/search-syntax`. The frontend parser -// and the backend `event_search.py` grammar both test against these. -const FIXTURES_DIR = resolve( - dirname(fileURLToPath(import.meta.url)), - "../test/fixtures/search-syntax", -); - -type FixtureCase = { - query: string; - result: unknown[]; - additionalConfig?: Partial & Record; - raisesError?: boolean; -}; - -// Location, text, `parsed` values, and validation results are frontend -// concerns the structural converter does not produce; compare everything else. -const STRIPPED_KEYS = new Set([ - "location", - "text", - "config", - "parsed", - "invalid", - "warning", -]); - -function normalize(value: unknown): unknown { - if (Array.isArray(value)) { - return value.map(normalize); - } - if (value && typeof value === "object") { - return Object.fromEntries( - Object.entries(value) - .filter(([key]) => !STRIPPED_KEYS.has(key)) - .map(([key, inner]) => [key, normalize(inner)]), - ); - } - return value; -} - -const fixtureFiles = readdirSync(FIXTURES_DIR).filter((file) => - file.endsWith(".json"), -); - -describe("search-syntax fixtures", () => { - it("loads the shared fixtures", () => { - expect(fixtureFiles.length).toBeGreaterThan(70); - }); - - for (const file of fixtureFiles) { - const cases = JSON.parse( - readFileSync(join(FIXTURES_DIR, file), "utf-8"), - ) as FixtureCase[]; - - describe(file.replace(/\.json$/, ""), () => { - for (const testCase of cases) { - it(`handles ${JSON.stringify(testCase.query)}`, () => { - const result = parseSearch(testCase.query, { - config: testCase.additionalConfig, - }); - if (testCase.raisesError) { - expect(result).toBeNull(); - return; - } - expect(result).not.toBeNull(); - expect(normalize(result)).toEqual(normalize(testCase.result)); - }); - } - }); - } -}); - -describe("parseSearch", () => { - it("keeps exact text and offsets on every token", () => { - const query = "!level:error count():>10 (a OR b)"; - const result = parseSearchOrThrow(query); - expect(result.map((token) => token.text).join("")).toBe(query); - for (const token of result) { - expect( - query.slice(token.location.start.offset, token.location.end.offset), - ).toBe(token.text); - } - }); - - it("classifies typed filters from the default key sets", () => { - const result = parseSearchOrThrow( - "transaction.duration:>1s error.handled:true timestamp:-24h count():>10", - ); - const filters = result.filter( - (token): token is FilterToken => token.type === Token.FILTER, - ); - expect(filters.map((filter) => filter.filter)).toEqual([ - FilterType.DURATION, - FilterType.BOOLEAN, - FilterType.RELATIVE_DATE, - FilterType.AGGREGATE_NUMERIC, - ]); - expect(filters[0]?.operator).toBe(TermOperator.GREATER_THAN); - }); - - it("reads aggregate size filters only when an argument is a size key", () => { - const filterOf = (query: string, config?: Partial) => - parseSearchOrThrow(query, { config }).find( - (token): token is FilterToken => token.type === Token.FILTER, - ); - const sized = { sizeKeys: new Set(["span.size"]) }; - - expect(filterOf("avg(span.size):>1kb", sized)?.filter).toBe( - FilterType.AGGREGATE_SIZE, - ); - // Like duration values on a non-duration aggregate, a size value on a - // non-size aggregate isn't a typed filter. - expect(filterOf("avg(span.duration):>1kb", sized)).toBeUndefined(); - expect(filterOf("avg(span.size):>1kb")).toBeUndefined(); - expect(filterOf("avg(span.duration):>1s")).toBeUndefined(); - }); - - it("returns null for queries that do not parse, and throws from parseSearchOrThrow", () => { - // The grammar falls back to free text for almost anything; a newline - // outside quotes is one of the few inputs it rejects. - expect(parseSearch("release:a\nrelease")).toBeNull(); - expect(() => parseSearchOrThrow("release:a\nrelease")).toThrow(); - }); - - it("builds paren tokens instead of groups with flattenParenGroups", () => { - const grouped = parseSearchOrThrow("(a:b)"); - expect(grouped.map((token) => token.type)).toContain(Token.LOGIC_GROUP); - const flat = parseSearchOrThrow("(a:b)", { - config: { flattenParenGroups: true }, - }); - expect(flat.map((token) => token.type)).toEqual([ - Token.SPACES, - Token.L_PAREN, - Token.SPACES, - Token.FILTER, - Token.SPACES, - Token.R_PAREN, - Token.SPACES, - ]); - }); - - it("uses a converter subclass for validation", () => { - class NoFreeText extends TokenConverter { - override checkInvalidFreeText(value: string) { - return { type: "free-text-not-allowed", reason: `no "${value}"` }; - } - } - const result = parseSearchOrThrow("hello", { converter: NoFreeText }); - const freeText = result.find((token) => token.type === Token.FREE_TEXT); - expect(freeText).toMatchObject({ - invalid: { type: "free-text-not-allowed", reason: 'no "hello"' }, - }); - }); -}); - -describe("regex filters", () => { - type RegexFilter = { key: string; pattern: string; negated: boolean }; - - function regexFilters(query: string): RegexFilter[] { - const found: RegexFilter[] = []; - const visit = (tokens: ParseResultToken[]): void => { - for (const token of tokens) { - if (token.type === Token.LOGIC_GROUP) { - visit(token.inner); - } else if ( - token.type === Token.FILTER && - token.operator === TermOperator.MATCHES - ) { - found.push({ - key: token.key.text, - pattern: token.value.text, - negated: token.negated, - }); - } - } - }; - visit(parseSearchOrThrow(query, { config: { allowRegex: true } })); - return found; - } - - const regex = (key: string, pattern: string, negated = false) => ({ - key, - pattern, - negated, - }); - - it.each([ - // Pattern contents: commas, brackets, boolean words, parens and quotes - // all stay inside the pattern. - ["message://[a-z,]+//", [regex("message", "[a-z,]+")]], - [ - "message://codes [401,403,) seen//", - [regex("message", "codes [401,403,) seen")], - ], - [ - "message://timeout OR refused//", - [regex("message", "timeout OR refused")], - ], - ["message://read AND write//", [regex("message", "read AND write")]], - [ - "message://(reset|timeout) [0-9,]+//", - [regex("message", "(reset|timeout) [0-9,]+")], - ], - ['message://say "hi" [a,]//', [regex("message", 'say "hi" [a,]')]], - [ - String.raw`!message://^GET OR POST \d+ms//`, - [regex("message", String.raw`^GET OR POST \d+ms`, true)], - ], - // The pattern ends at the first `//` followed by whitespace. - [ - "url://https://x// AND message://a OR b//", - [regex("url", "https://x"), regex("message", "a OR b")], - ], - // Every key shape that can carry a regex. - [ - "tags[foo,string]://[a-z,]+ AND b//", - [regex("tags[foo,string]", "[a-z,]+ AND b")], - ], - [ - "tags[foo, string]://a OR [b,]//", - [regex("tags[foo, string]", "a OR [b,]")], - ], - [ - "tags[sentry:user]://^id [0-9,]+//", - [regex("tags[sentry:user]", "^id [0-9,]+")], - ], - ["tags[App:Region]://^us-//", [regex("tags[App:Region]", "^us-")]], - [ - "flags[beta,string]://^on OR off$//", - [regex("flags[beta,string]", "^on OR off$")], - ], - ["flags[Feature:X]://y//", [regex("flags[Feature:X]", "y")]], - ['"my.key"://a OR [b,]//', [regex('"my.key"', "a OR [b,]")]], - [ - "arr[*]://a OR [b,]// tags[k[*],array]://a OR b//", - [regex("arr[*]", "a OR [b,]"), regex("tags[k[*],array]", "a OR b")], - ], - // Regex filters directly after a paren group or quoted text, and inside - // a paren group. - [ - '(level:x)message://[a,]// "foo"message://[b,]//', - [regex("message", "[a,]"), regex("message", "[b,]")], - ], - ['"Note"message://a b//', [regex("message", "a b")]], - ["(message://a b//)", [regex("message", "a b")]], - ])("parses %j", (query, expected) => { - expect(regexFilters(query)).toEqual(expected); - }); - - it("reads key://pattern// as a literal text filter without allowRegex", () => { - const [filter] = parseSearchOrThrow("message://^Timeout//").filter( - (token): token is FilterToken => token.type === Token.FILTER, - ); - expect(filter).toMatchObject({ - filter: FilterType.TEXT, - operator: TermOperator.DEFAULT, - }); - expect(filter?.value.text).toBe("//^Timeout//"); - }); -}); - -describe("getKeyName", () => { - function firstKey(query: string): KeyToken { - const filter = parseSearchOrThrow(query).find( - (token): token is FilterToken => token.type === Token.FILTER, - ); - if (!filter) { - throw new Error(`no filter in ${query}`); - } - return filter.key; - } - - it("names each key kind the way the API expects", () => { - expect(getKeyName(firstKey("level:error"))).toBe("level"); - expect(getKeyName(firstKey("tags[foo]:bar"))).toBe("foo"); - expect(getKeyName(firstKey("tags[foo,number]:1"))).toBe("tags[foo,number]"); - expect(getKeyName(firstKey("flags[beta]:on"))).toBe("flags[beta]"); - expect(getKeyName(firstKey("foo[*]:bar"))).toBe("foo"); - expect(getKeyName(firstKey("count():>1"))).toBe("count"); - expect( - getKeyName(firstKey("p95(span.duration):>1"), { - aggregateWithArgs: true, - }), - ).toBe("p95(span.duration)"); - }); -}); diff --git a/packages/toolkit-core/src/search-syntax.ts b/packages/toolkit-core/src/search-syntax.ts deleted file mode 100644 index 9aabd7c3b..000000000 --- a/packages/toolkit-core/src/search-syntax.ts +++ /dev/null @@ -1,1020 +0,0 @@ -/** - * Sentry search syntax parser. - * - * Runs the Sentry frontend's search grammar (`grammar/search-syntax.pegjs`, - * copied unchanged from getsentry/sentry - * `static/app/components/searchSyntax/grammar.pegjs`) and builds the same - * token tree as the frontend's `parseSearch`. Location, text, and filter - * classification match; the shared fixtures in `test/fixtures/search-syntax` - * check that. - * - * {@link TokenConverter} only does structural work. It never marks a token - * invalid, attaches warnings, or fills `parsed` values. Products that need - * that (the frontend's validation messages, for example) subclass it and - * override the `checkInvalid*` hooks or the value builders. - */ - -import { parse as parseGrammar } from "./generated/search-syntax-grammar.js"; - -/** A node type in the search syntax tree. Values match the frontend. */ -export const Token = { - SPACES: "spaces", - FILTER: "filter", - FREE_TEXT: "freeText", - LOGIC_GROUP: "logicGroup", - LOGIC_BOOLEAN: "logicBoolean", - KEY_SIMPLE: "keySimple", - KEY_EXPLICIT_FLAG: "keyExplicitFlag", - KEY_EXPLICIT_NUMBER_FLAG: "keyExplicitNumberFlag", - KEY_EXPLICIT_STRING_FLAG: "keyExplicitStringFlag", - KEY_EXPLICIT_TAG: "keyExplicitTag", - KEY_EXPLICIT_BOOLEAN_TAG: "keyExplicitBooleanTag", - KEY_EXPLICIT_NUMBER_TAG: "keyExplicitNumberTag", - KEY_EXPLICIT_STRING_TAG: "keyExplicitStringTag", - KEY_EXPLICIT_ARRAY_TAG: "keyExplicitArrayTag", - KEY_ARRAY_INCLUDES: "keyArrayIncludes", - KEY_AGGREGATE: "keyAggregate", - KEY_AGGREGATE_ARGS: "keyAggregateArgs", - KEY_AGGREGATE_PARAMS: "keyAggregateParam", - L_PAREN: "lParen", - R_PAREN: "rParen", - VALUE_ISO_8601_DATE: "valueIso8601Date", - VALUE_RELATIVE_DATE: "valueRelativeDate", - VALUE_DURATION: "valueDuration", - VALUE_SIZE: "valueSize", - VALUE_PERCENTAGE: "valuePercentage", - VALUE_BOOLEAN: "valueBoolean", - VALUE_NUMBER: "valueNumber", - VALUE_TEXT: "valueText", - VALUE_NUMBER_LIST: "valueNumberList", - VALUE_TEXT_LIST: "valueTextList", -} as const; -export type Token = (typeof Token)[keyof typeof Token]; - -/** The operator in a `key:value` filter. Values match the frontend. */ -export const TermOperator = { - DEFAULT: "", - GREATER_THAN_EQUAL: ">=", - LESS_THAN_EQUAL: "<=", - GREATER_THAN: ">", - LESS_THAN: "<", - EQUAL: "=", - NOT_EQUAL: "!=", - // Internal wildcard operators; users write `*` instead. - CONTAINS: "\uF00DContains\uF00D", - DOES_NOT_CONTAIN: "\uF00DDoesNotContain\uF00D", - STARTS_WITH: "\uF00DStartsWith\uF00D", - DOES_NOT_START_WITH: "\uF00DDoesNotStartWith\uF00D", - ENDS_WITH: "\uF00DEndsWith\uF00D", - DOES_NOT_END_WITH: "\uF00DDoesNotEndWith\uF00D", - MATCHES: "//", - DOES_NOT_MATCH: "!//", -} as const; -export type TermOperator = (typeof TermOperator)[keyof typeof TermOperator]; - -export const BooleanOperator = { - AND: "AND", - OR: "OR", -} as const; -export type BooleanOperator = - (typeof BooleanOperator)[keyof typeof BooleanOperator]; - -/** Which kind of filter a {@link FilterToken} is. Values match the frontend. */ -export const FilterType = { - TEXT: "text", - TEXT_IN: "textIn", - DATE: "date", - SPECIFIC_DATE: "specificDate", - RELATIVE_DATE: "relativeDate", - DURATION: "duration", - SIZE: "size", - NUMERIC: "numeric", - NUMERIC_IN: "numericIn", - BOOLEAN: "boolean", - AGGREGATE_DURATION: "aggregateDuration", - AGGREGATE_SIZE: "aggregateSize", - AGGREGATE_PERCENTAGE: "aggregatePercentage", - AGGREGATE_NUMERIC: "aggregateNumeric", - AGGREGATE_DATE: "aggregateDate", - AGGREGATE_RELATIVE_DATE: "aggregateRelativeDate", - HAS: "has", - IS: "is", - ARRAY_INCLUDES: "arrayIncludes", -} as const; -export type FilterType = (typeof FilterType)[keyof typeof FilterType]; - -export type SourcePosition = { - offset: number; - line: number; - column: number; -}; - -export type SourceLocation = { - source: unknown; - start: SourcePosition; - end: SourcePosition; -}; - -type BaseToken = { - type: T; - /** The exact input text this token covers. */ - text: string; - location: SourceLocation; -}; - -/** - * Why a token is invalid. The structural converter never sets one; a - * subclass with product-specific validation can. - */ -export type InvalidToken = { - type: string; - reason: string; - expectedType?: FilterType[]; -} | null; - -export type SpacesToken = BaseToken & { value: string }; - -export type KeySimpleToken = BaseToken & { - value: string; - quoted: boolean; -}; - -type PrefixedKeyToken = BaseToken & { - prefix: string; - key: KeySimpleToken; -}; - -export type KeyExplicitFlagToken = PrefixedKeyToken< - typeof Token.KEY_EXPLICIT_FLAG ->; -export type KeyExplicitStringFlagToken = PrefixedKeyToken< - typeof Token.KEY_EXPLICIT_STRING_FLAG ->; -export type KeyExplicitNumberFlagToken = PrefixedKeyToken< - typeof Token.KEY_EXPLICIT_NUMBER_FLAG ->; -export type KeyExplicitTagToken = PrefixedKeyToken< - typeof Token.KEY_EXPLICIT_TAG ->; -export type KeyExplicitStringTagToken = PrefixedKeyToken< - typeof Token.KEY_EXPLICIT_STRING_TAG ->; -export type KeyExplicitNumberTagToken = PrefixedKeyToken< - typeof Token.KEY_EXPLICIT_NUMBER_TAG ->; -export type KeyExplicitBooleanTagToken = PrefixedKeyToken< - typeof Token.KEY_EXPLICIT_BOOLEAN_TAG ->; -export type KeyExplicitArrayTagToken = PrefixedKeyToken< - typeof Token.KEY_EXPLICIT_ARRAY_TAG ->; - -/** An array element key such as `foo[*]`. */ -export type KeyArrayIncludesToken = BaseToken< - typeof Token.KEY_ARRAY_INCLUDES -> & { - key: KeySimpleToken | KeyExplicitArrayTagToken; - index: string; -}; - -export type KeyAggregateParamToken = BaseToken< - typeof Token.KEY_AGGREGATE_PARAMS -> & { - value: string; - quoted: boolean; -}; - -export type ListItem = { separator: string; value: V | null }; - -export type KeyAggregateArgsToken = BaseToken< - typeof Token.KEY_AGGREGATE_ARGS -> & { - args: ListItem[]; -}; - -export type KeyAggregateToken = BaseToken & { - name: KeySimpleToken; - args: KeyAggregateArgsToken | null; - argsSpaceBefore: SpacesToken; - argsSpaceAfter: SpacesToken; -}; - -export type KeyToken = - | KeySimpleToken - | KeyExplicitFlagToken - | KeyExplicitStringFlagToken - | KeyExplicitNumberFlagToken - | KeyExplicitTagToken - | KeyExplicitStringTagToken - | KeyExplicitNumberTagToken - | KeyExplicitBooleanTagToken - | KeyExplicitArrayTagToken - | KeyArrayIncludesToken - | KeyAggregateToken; - -export type ValueIso8601DateToken = BaseToken< - typeof Token.VALUE_ISO_8601_DATE -> & { - value: string; - date: string; - time: string | undefined | null; - tz: string | undefined | null; -}; - -export type ValueRelativeDateToken = BaseToken< - typeof Token.VALUE_RELATIVE_DATE -> & { - value: string; - sign: "-" | "+"; - unit: "w" | "d" | "h" | "m"; -}; - -export type ValueDurationToken = BaseToken & { - value: string; - unit: string; -}; - -export type ValueSizeToken = BaseToken & { - value: string; - unit: string; -}; - -export type ValuePercentageToken = BaseToken & { - value: string; -}; - -export type ValueBooleanToken = BaseToken & { - value: string; -}; - -export type ValueNumberToken = BaseToken & { - value: string; - unit: string | null; -}; - -export type ValueTextToken = BaseToken & { - value: string; - quoted: boolean; -}; - -export type ValueNumberListToken = BaseToken & { - items: ListItem[]; -}; - -export type ValueTextListToken = BaseToken & { - items: ListItem[]; -}; - -export type ValueToken = - | ValueIso8601DateToken - | ValueRelativeDateToken - | ValueDurationToken - | ValueSizeToken - | ValuePercentageToken - | ValueBooleanToken - | ValueNumberToken - | ValueTextToken - | ValueNumberListToken - | ValueTextListToken; - -export type FilterToken = BaseToken & { - filter: FilterType; - key: KeyToken; - /** `has:` filters may hold a key token as their value. */ - value: ValueToken | KeyToken; - negated: boolean; - operator: TermOperator; - invalid: InvalidToken; -}; - -export type FreeTextToken = BaseToken & { - value: string; - quoted: boolean; - invalid: InvalidToken; -}; - -export type LogicBooleanToken = BaseToken & { - value: BooleanOperator; - invalid: InvalidToken; -}; - -export type LParenToken = BaseToken & { - value: "("; - invalid: InvalidToken; -}; - -export type RParenToken = BaseToken & { - value: ")"; - invalid: InvalidToken; -}; - -export type LogicGroupToken = BaseToken & { - inner: ParseResultToken[]; -}; - -/** A top-level token, or one directly inside a {@link LogicGroupToken}. */ -export type ParseResultToken = - | SpacesToken - | FilterToken - | FreeTextToken - | LogicBooleanToken - | LogicGroupToken - | LParenToken - | RParenToken; - -export type ParseResult = ParseResultToken[]; - -/** The structural part of the frontend's `SearchConfig`. */ -export type SearchConfig = { - /** Parse `key://pattern//` as a regex filter rather than literal text. */ - allowRegex: boolean; - booleanKeys: Set; - dateKeys: Set; - durationKeys: Set; - numericKeys: Set; - /** Aggregates whose filters take percentage values. */ - percentageKeys: Set; - sizeKeys: Set; - /** Text filter keys that may carry a comparison operator. */ - textOperatorKeys: Set; - /** Return paren tokens instead of {@link LogicGroupToken}s. */ - flattenParenGroups?: boolean; -}; - -/** The frontend's default key sets. */ -export const defaultConfig: SearchConfig = { - textOperatorKeys: new Set([ - "release.version", - "release.build", - "release.package", - "release.stage", - ]), - durationKeys: new Set(["transaction.duration"]), - percentageKeys: new Set(["percentage"]), - numericKeys: new Set([ - "project_id", - "project.id", - "issue.id", - "stack.colno", - "stack.lineno", - "stack.stack_level", - "transaction.duration", - ]), - dateKeys: new Set([ - "start", - "end", - "firstSeen", - "lastSeen", - "last_seen()", - "time", - "event.timestamp", - "timestamp", - "timestamp.to_hour", - "timestamp.to_day", - ]), - booleanKeys: new Set([ - "error.handled", - "error.unhandled", - "stack.in_app", - "team_key_transaction", - "symbolicated_in_app", - ]), - sizeKeys: new Set(), - allowRegex: false, -}; - -const MEASUREMENT_PATTERN = /^measurements\.[\w.-]+$/; -const SPAN_OP_BREAKDOWN_PREFIX = "spans."; - -/** - * Web and mobile vitals whose value type is a duration, from the frontend's - * `MEASUREMENT_FIELDS`. Other measurements are plain numbers. - */ -const DURATION_MEASUREMENTS = new Set([ - "measurements.fp", - "measurements.fcp", - "measurements.lcp", - "measurements.fid", - "measurements.ttfb", - "measurements.ttfb.requesttime", - "measurements.inp", - "measurements.app_start_cold", - "measurements.app_start_warm", - "measurements.stall_total_time", - "measurements.stall_longest_time", - "measurements.time_to_full_display", - "measurements.time_to_initial_display", -]); - -type GetKeyNameOptions = { - /** Include the arguments of aggregate keys, e.g. `p95(span.duration)`. */ - aggregateWithArgs?: boolean; -}; - -/** The key name the API expects for a filter key. Matches the frontend. */ -export function getKeyName( - key: KeyToken, - options: GetKeyNameOptions = {}, -): string { - switch (key.type) { - case Token.KEY_SIMPLE: - return key.value; - case Token.KEY_EXPLICIT_TAG: - return key.key.value; - case Token.KEY_AGGREGATE: - return options.aggregateWithArgs - ? `${key.name.value}(${key.args ? key.args.text : ""})` - : key.name.value; - case Token.KEY_ARRAY_INCLUDES: - return getKeyName(key.key); - default: - return key.text; - } -} - -type RawListItem = [ - space1: SpacesToken, - comma: string, - space2: SpacesToken, - value?: [notComma: undefined, value: V | null] | null, -]; - -function joinListItem([ - space1, - comma, - space2, - value, -]: RawListItem): ListItem { - return { - separator: [space1.value, comma, space2.value].join(""), - value: value ? value[1] : null, - }; -} - -type ConverterOptions = { - text: () => string; - location: () => SourceLocation; - config: C; -}; - -/** - * Builds tokens for the grammar. The grammar calls these methods directly, - * so their names and argument order follow the grammar actions. - */ -export class TokenConverter { - protected readonly text: () => string; - protected readonly location: () => SourceLocation; - protected readonly config: C; - - constructor({ text, location, config }: ConverterOptions) { - this.text = text; - this.location = location; - this.config = config; - } - - protected get defaultTokenFields(): { - text: string; - location: SourceLocation; - } { - return { text: this.text(), location: this.location() }; - } - - // -- Key type predicates ------------------------------------------------ - - isNumericKey(key: string): boolean { - return ( - this.config.numericKeys.has(key) || - MEASUREMENT_PATTERN.test(key) || - key.startsWith(SPAN_OP_BREAKDOWN_PREFIX) || - this.isDurationKey(key) || - this.isSizeKey(key) - ); - } - - isBooleanKey(key: string): boolean { - return this.config.booleanKeys.has(key); - } - - isPercentageKey(key: string): boolean { - return this.config.percentageKeys.has(key); - } - - isDateKey(key: string): boolean { - return this.config.dateKeys.has(key); - } - - isDurationKey(key: string): boolean { - return ( - this.config.durationKeys.has(key) || - key.startsWith(SPAN_OP_BREAKDOWN_PREFIX) || - DURATION_MEASUREMENTS.has(key) - ); - } - - isSizeKey(key: string): boolean { - return this.config.sizeKeys.has(key); - } - - // -- Validation hooks (structural parsing never marks tokens invalid) --- - - checkInvalidFilter( - _filter: FilterType, - _key: KeyToken, - _value: FilterToken["value"], - _negated: boolean, - _operator: TermOperator, - ): InvalidToken { - return null; - } - - checkInvalidFreeText(_value: string): InvalidToken { - return null; - } - - checkInvalidLogicalBoolean(_value: BooleanOperator): InvalidToken { - return null; - } - - checkInvalidParen(): InvalidToken { - return null; - } - - // -- Tokens ------------------------------------------------------------- - - tokenSpaces(value: string): SpacesToken { - return { ...this.defaultTokenFields, type: Token.SPACES, value }; - } - - tokenFilter( - filter: FilterType, - key: KeyToken, - value: FilterToken["value"], - operator: TermOperator | undefined | null, - negated: boolean, - wildcard?: TermOperator, - ): FilterToken { - let operatorToUse = operator ?? TermOperator.DEFAULT; - if ( - wildcard && - (filter === FilterType.TEXT || filter === FilterType.TEXT_IN) - ) { - operatorToUse = wildcard; - } - return { - ...this.defaultTokenFields, - type: Token.FILTER, - filter, - key, - value, - negated, - operator: operatorToUse, - invalid: this.checkInvalidFilter( - filter, - key, - value, - negated, - operatorToUse, - ), - }; - } - - tokenRegexFilter( - key: KeyToken, - literal: ValueTextToken, - pattern: ValueTextToken, - negated: boolean, - ): FilterToken { - const filter = - key.type === Token.KEY_ARRAY_INCLUDES - ? FilterType.ARRAY_INCLUDES - : FilterType.TEXT; - if (!this.config.allowRegex) { - return this.tokenFilter( - filter, - key, - literal, - TermOperator.DEFAULT, - negated, - ); - } - return this.tokenFilter( - filter, - key, - pattern, - TermOperator.MATCHES, - negated, - ); - } - - tokenLParen(value: "("): LParenToken { - return { - ...this.defaultTokenFields, - type: Token.L_PAREN, - value, - invalid: this.checkInvalidParen(), - }; - } - - tokenRParen(value: ")"): RParenToken { - return { - ...this.defaultTokenFields, - type: Token.R_PAREN, - value, - invalid: this.checkInvalidParen(), - }; - } - - tokenFreeText(value: string, quoted: boolean): FreeTextToken { - return { - ...this.defaultTokenFields, - type: Token.FREE_TEXT, - value, - quoted, - invalid: this.checkInvalidFreeText(value), - }; - } - - tokenLogicGroup(inner: ParseResultToken[]): LogicGroupToken { - return { ...this.defaultTokenFields, type: Token.LOGIC_GROUP, inner }; - } - - tokenLogicBoolean(value: BooleanOperator): LogicBooleanToken { - return { - ...this.defaultTokenFields, - type: Token.LOGIC_BOOLEAN, - value, - invalid: this.checkInvalidLogicalBoolean(value), - }; - } - - tokenKeySimple(value: string, quoted: boolean): KeySimpleToken { - return { - ...this.defaultTokenFields, - type: Token.KEY_SIMPLE, - value, - quoted, - }; - } - - tokenKeyExplicitFlag( - prefix: string, - key: KeySimpleToken, - ): KeyExplicitFlagToken { - return { - ...this.defaultTokenFields, - type: Token.KEY_EXPLICIT_FLAG, - prefix, - key, - }; - } - - tokenKeyExplicitStringFlag( - prefix: string, - key: KeySimpleToken, - ): KeyExplicitStringFlagToken { - return { - ...this.defaultTokenFields, - type: Token.KEY_EXPLICIT_STRING_FLAG, - prefix, - key, - }; - } - - tokenKeyExplicitNumberFlag( - prefix: string, - key: KeySimpleToken, - ): KeyExplicitNumberFlagToken { - return { - ...this.defaultTokenFields, - type: Token.KEY_EXPLICIT_NUMBER_FLAG, - prefix, - key, - }; - } - - tokenKeyExplicitTag( - prefix: string, - key: KeySimpleToken, - ): KeyExplicitTagToken { - return { - ...this.defaultTokenFields, - type: Token.KEY_EXPLICIT_TAG, - prefix, - key, - }; - } - - tokenKeyExplicitStringTag( - prefix: string, - key: KeySimpleToken, - ): KeyExplicitStringTagToken { - return { - ...this.defaultTokenFields, - type: Token.KEY_EXPLICIT_STRING_TAG, - prefix, - key, - }; - } - - tokenKeyExplicitNumberTag( - prefix: string, - key: KeySimpleToken, - ): KeyExplicitNumberTagToken { - return { - ...this.defaultTokenFields, - type: Token.KEY_EXPLICIT_NUMBER_TAG, - prefix, - key, - }; - } - - tokenKeyExplicitBooleanTag( - prefix: string, - key: KeySimpleToken, - ): KeyExplicitBooleanTagToken { - return { - ...this.defaultTokenFields, - type: Token.KEY_EXPLICIT_BOOLEAN_TAG, - prefix, - key, - }; - } - - tokenKeyExplicitArrayTag( - prefix: string, - key: KeySimpleToken, - ): KeyExplicitArrayTagToken { - return { - ...this.defaultTokenFields, - // The array-includes rule consumes `[*]` around this token, so build the - // text from the key to keep the tag identity operator-free. - text: `${prefix}[${key.text},array]`, - type: Token.KEY_EXPLICIT_ARRAY_TAG, - prefix, - key, - }; - } - - tokenKeyArrayIncludes( - key: KeySimpleToken | KeyExplicitArrayTagToken, - index: string, - ): KeyArrayIncludesToken { - return { - ...this.defaultTokenFields, - type: Token.KEY_ARRAY_INCLUDES, - key, - index, - }; - } - - tokenKeyAggregateParam( - value: string, - quoted: boolean, - ): KeyAggregateParamToken { - return { - ...this.defaultTokenFields, - type: Token.KEY_AGGREGATE_PARAMS, - value, - quoted, - }; - } - - tokenKeyAggregate( - name: KeySimpleToken, - args: KeyAggregateArgsToken | null, - argsSpaceBefore: SpacesToken, - argsSpaceAfter: SpacesToken, - ): KeyAggregateToken { - return { - ...this.defaultTokenFields, - type: Token.KEY_AGGREGATE, - name, - args, - argsSpaceBefore, - argsSpaceAfter, - }; - } - - tokenKeyAggregateArgs( - arg1: KeyAggregateParamToken, - args: RawListItem[], - ): KeyAggregateArgsToken { - return { - ...this.defaultTokenFields, - type: Token.KEY_AGGREGATE_ARGS, - args: [{ separator: "", value: arg1 }, ...args.map(joinListItem)], - }; - } - - tokenValueIso8601Date( - value: string, - date: (string | string[])[], - time?: (string | string[] | string[][])[] | null, - tz?: (string | string[])[] | string | null, - ): ValueIso8601DateToken { - return { - ...this.defaultTokenFields, - type: Token.VALUE_ISO_8601_DATE, - value, - date: date.flat().join(""), - time: Array.isArray(time) - ? time.flat().flat().join("").replace("T", "") - : time, - tz: Array.isArray(tz) ? tz.flat().join("") : tz, - }; - } - - tokenValueRelativeDate( - value: string, - sign: "-" | "+", - unit: "w" | "d" | "h" | "m", - ): ValueRelativeDateToken { - return { - ...this.defaultTokenFields, - type: Token.VALUE_RELATIVE_DATE, - value, - sign, - unit, - }; - } - - tokenValueDuration(value: string, unit: string): ValueDurationToken { - return { - ...this.defaultTokenFields, - type: Token.VALUE_DURATION, - value, - unit, - }; - } - - tokenValueSize(value: string, unit: string): ValueSizeToken { - return { ...this.defaultTokenFields, type: Token.VALUE_SIZE, value, unit }; - } - - tokenValuePercentage(value: string): ValuePercentageToken { - return { ...this.defaultTokenFields, type: Token.VALUE_PERCENTAGE, value }; - } - - tokenValueBoolean(value: string): ValueBooleanToken { - return { ...this.defaultTokenFields, type: Token.VALUE_BOOLEAN, value }; - } - - tokenValueNumber(value: string, unit: string | null): ValueNumberToken { - return { - ...this.defaultTokenFields, - type: Token.VALUE_NUMBER, - value, - unit, - }; - } - - tokenValueNumberList( - item1: ValueNumberToken, - items: RawListItem[], - ): ValueNumberListToken { - return { - ...this.defaultTokenFields, - type: Token.VALUE_NUMBER_LIST, - items: [{ separator: "", value: item1 }, ...items.map(joinListItem)], - }; - } - - tokenValueTextList( - item1: ValueTextToken, - items: RawListItem[], - ): ValueTextListToken { - return { - ...this.defaultTokenFields, - type: Token.VALUE_TEXT_LIST, - items: [{ separator: "", value: item1 }, ...items.map(joinListItem)], - }; - } - - tokenValueText(value: string, quoted: boolean): ValueTextToken { - return { - ...this.defaultTokenFields, - type: Token.VALUE_TEXT, - value, - quoted, - }; - } - - // -- Grammar predicates ------------------------------------------------- - - /** - * Whether a typed filter rule may match this key. Keys that fail every - * typed rule fall through to a text filter. - */ - predicateFilter(type: FilterType, key: KeyToken): boolean { - const keyName = getKeyName(key); - const checkAggregate = (check: (name: string) => boolean): boolean => - key.type === Token.KEY_AGGREGATE && - (key.args?.args.some((arg) => check(arg.value?.value ?? "")) ?? false); - - switch (type) { - case FilterType.NUMERIC: - case FilterType.NUMERIC_IN: - return this.isNumericKey(keyName); - case FilterType.DURATION: - return this.isDurationKey(keyName); - case FilterType.SIZE: - return this.isSizeKey(keyName); - case FilterType.BOOLEAN: - return this.isBooleanKey(keyName); - case FilterType.DATE: - case FilterType.RELATIVE_DATE: - case FilterType.SPECIFIC_DATE: - return this.isDateKey(keyName); - case FilterType.AGGREGATE_DURATION: - return checkAggregate((name) => this.isDurationKey(name)); - // Diverges from the frontend, whose `predicateFilter` lets every - // aggregate take a size value. Gate it on a size argument like the - // other typed aggregates (see getsentry/toolkit#1533). - case FilterType.AGGREGATE_SIZE: - return checkAggregate((name) => this.isSizeKey(name)); - case FilterType.AGGREGATE_DATE: - return checkAggregate((name) => this.isDateKey(name)); - case FilterType.AGGREGATE_PERCENTAGE: - return checkAggregate((name) => this.isPercentageKey(name)); - default: - return true; - } - } - - /** Whether a text filter on this key may carry a comparison operator. */ - predicateTextOperator(key: KeyToken): boolean { - return this.config.textOperatorKeys.has(getKeyName(key)); - } - - /** Whether to build {@link LogicGroupToken}s for parenthesized terms. */ - predicateParenGroup(): boolean { - return !this.config.flattenParenGroups; - } -} - -export type TokenConverterClass = new ( - options: ConverterOptions, -) => TokenConverter; - -/** Thrown by {@link parseSearchOrThrow} when a query does not parse. */ -export type SearchSyntaxError = Error & { - found: string | null; - location: SourceLocation; -}; - -/** - * Apply `overrides` onto `base`, skipping `undefined` values so an unset - * override never clears a default. - */ -export function mergeSearchConfig( - base: C, - overrides: Partial, -): C { - return { - ...base, - ...Object.fromEntries( - Object.entries(overrides).filter(([, value]) => value !== undefined), - ), - }; -} - -type ParseSearchOptions = { - /** Overrides applied onto {@link defaultConfig}. */ - config?: Partial; - /** A converter subclass, e.g. one that adds validation. */ - converter?: TokenConverterClass; -}; - -/** - * Parse a Sentry search query. Throws a {@link SearchSyntaxError} when the - * query does not match the grammar. - */ -export function parseSearchOrThrow( - query: string, - options: ParseSearchOptions = {}, -): ParseResult { - const config = options.config - ? mergeSearchConfig(defaultConfig as C, options.config) - : defaultConfig; - return parseGrammar(query, { - config, - TokenConverter: options.converter ?? TokenConverter, - TermOperator, - FilterType, - }) as ParseResult; -} - -/** - * Parse a Sentry search query, or return `null` when it does not match the - * grammar. Mirrors the frontend's `parseSearch`. - */ -export function parseSearch( - query: string, - options: ParseSearchOptions = {}, -): ParseResult | null { - try { - return parseSearchOrThrow(query, options); - } catch { - return null; - } -} diff --git a/packages/toolkit-core/test/fixtures/search-syntax/aggregate_duration_filter.json b/packages/toolkit-core/test/fixtures/search-syntax/aggregate_duration_filter.json deleted file mode 100644 index 168735e0d..000000000 --- a/packages/toolkit-core/test/fixtures/search-syntax/aggregate_duration_filter.json +++ /dev/null @@ -1,80 +0,0 @@ -[ - { - "query": "avg(transaction.duration):>500s", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "aggregateDuration", - "negated": false, - "key": { - "type": "keyAggregate", - "name": {"type": "keySimple", "value": "avg", "quoted": false}, - "args": { - "type": "keyAggregateArgs", - "args": [ - { - "separator": "", - "value": { - "type": "keyAggregateParam", - "value": "transaction.duration", - "quoted": false - } - } - ] - }, - "argsSpaceBefore": {"type": "spaces", "value": ""}, - "argsSpaceAfter": {"type": "spaces", "value": ""} - }, - "operator": ">", - "value": { - "type": "valueDuration", - "value": "500", - "unit": "s", - "parsed": {"value": 500000} - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "TypeError avg(transaction.duration):>500s", - "result": [ - {"type": "spaces", "value": ""}, - {"type": "freeText", "value": "TypeError ", "quoted": false, "invalid": null}, - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "aggregateDuration", - "negated": false, - "key": { - "type": "keyAggregate", - "name": {"type": "keySimple", "value": "avg", "quoted": false}, - "args": { - "type": "keyAggregateArgs", - "args": [ - { - "separator": "", - "value": { - "type": "keyAggregateParam", - "value": "transaction.duration", - "quoted": false - } - } - ] - }, - "argsSpaceBefore": {"type": "spaces", "value": ""}, - "argsSpaceAfter": {"type": "spaces", "value": ""} - }, - "operator": ">", - "value": { - "type": "valueDuration", - "value": "500", - "unit": "s", - "parsed": {"value": 500000} - } - }, - {"type": "spaces", "value": ""} - ] - } -] diff --git a/packages/toolkit-core/test/fixtures/search-syntax/aggregate_duration_filter_overrides_numeric_shorthand.json b/packages/toolkit-core/test/fixtures/search-syntax/aggregate_duration_filter_overrides_numeric_shorthand.json deleted file mode 100644 index 4307cefe2..000000000 --- a/packages/toolkit-core/test/fixtures/search-syntax/aggregate_duration_filter_overrides_numeric_shorthand.json +++ /dev/null @@ -1,41 +0,0 @@ -[ - { - "desc": "2m should mean 2 minutes for duration filters (as opposed to 2 million)", - "query": "avg(transaction.duration):>2m", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "aggregateDuration", - "negated": false, - "key": { - "type": "keyAggregate", - "name": {"type": "keySimple", "value": "avg", "quoted": false}, - "args": { - "type": "keyAggregateArgs", - "args": [ - { - "separator": "", - "value": { - "type": "keyAggregateParam", - "value": "transaction.duration", - "quoted": false - } - } - ] - }, - "argsSpaceBefore": {"type": "spaces", "value": ""}, - "argsSpaceAfter": {"type": "spaces", "value": ""} - }, - "operator": ">", - "value": { - "type": "valueDuration", - "value": "2", - "unit": "m", - "parsed": {"value": 120000} - } - }, - {"type": "spaces", "value": ""} - ] - } -] diff --git a/packages/toolkit-core/test/fixtures/search-syntax/aggregate_filter_on_explicit_typed_attributes.json b/packages/toolkit-core/test/fixtures/search-syntax/aggregate_filter_on_explicit_typed_attributes.json deleted file mode 100644 index bcc560bd2..000000000 --- a/packages/toolkit-core/test/fixtures/search-syntax/aggregate_filter_on_explicit_typed_attributes.json +++ /dev/null @@ -1,192 +0,0 @@ -[ - { - "query": "count_unique(tags[foo]):>500", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "aggregateNumeric", - "negated": false, - "key": { - "type": "keyAggregate", - "name": {"type": "keySimple", "value": "count_unique", "quoted": false}, - "args": { - "type": "keyAggregateArgs", - "args": [ - { - "separator": "", - "value": { - "type": "keyAggregateParam", - "value": "tags[foo]", - "quoted": false - } - } - ] - }, - "argsSpaceBefore": {"type": "spaces", "value": ""}, - "argsSpaceAfter": {"type": "spaces", "value": ""} - }, - "operator": ">", - "value": { - "type": "valueNumber", - "value": "500", - "unit": null, - "parsed": {"value": 500} - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "avg(tags[foo,number]):>500", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "aggregateNumeric", - "negated": false, - "key": { - "type": "keyAggregate", - "name": {"type": "keySimple", "value": "avg", "quoted": false}, - "args": { - "type": "keyAggregateArgs", - "args": [ - { - "separator": "", - "value": { - "type": "keyAggregateParam", - "value": "tags[foo,number]", - "quoted": false - } - } - ] - }, - "argsSpaceBefore": {"type": "spaces", "value": ""}, - "argsSpaceAfter": {"type": "spaces", "value": ""} - }, - "operator": ">", - "value": { - "type": "valueNumber", - "value": "500", - "unit": null, - "parsed": {"value": 500} - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "avg(tags[foo:bar,number]):>500", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "aggregateNumeric", - "negated": false, - "key": { - "type": "keyAggregate", - "name": {"type": "keySimple", "value": "avg", "quoted": false}, - "args": { - "type": "keyAggregateArgs", - "args": [ - { - "separator": "", - "value": { - "type": "keyAggregateParam", - "value": "tags[foo:bar,number]", - "quoted": false - } - } - ] - }, - "argsSpaceBefore": {"type": "spaces", "value": ""}, - "argsSpaceAfter": {"type": "spaces", "value": ""} - }, - "operator": ">", - "value": { - "type": "valueNumber", - "value": "500", - "unit": null, - "parsed": {"value": 500} - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "count_unique(tags[foo,string]):>500", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "aggregateNumeric", - "negated": false, - "key": { - "type": "keyAggregate", - "name": {"type": "keySimple", "value": "count_unique", "quoted": false}, - "args": { - "type": "keyAggregateArgs", - "args": [ - { - "separator": "", - "value": { - "type": "keyAggregateParam", - "value": "tags[foo,string]", - "quoted": false - } - } - ] - }, - "argsSpaceBefore": {"type": "spaces", "value": ""}, - "argsSpaceAfter": {"type": "spaces", "value": ""} - }, - "operator": ">", - "value": { - "type": "valueNumber", - "value": "500", - "unit": null, - "parsed": {"value": 500} - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "count_unique(tags[foo:bar,string]):>500", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "aggregateNumeric", - "negated": false, - "key": { - "type": "keyAggregate", - "name": {"type": "keySimple", "value": "count_unique", "quoted": false}, - "args": { - "type": "keyAggregateArgs", - "args": [ - { - "separator": "", - "value": { - "type": "keyAggregateParam", - "value": "tags[foo:bar,string]", - "quoted": false - } - } - ] - }, - "argsSpaceBefore": {"type": "spaces", "value": ""}, - "argsSpaceAfter": {"type": "spaces", "value": ""} - }, - "operator": ">", - "value": { - "type": "valueNumber", - "value": "500", - "unit": null, - "parsed": {"value": 500} - } - }, - {"type": "spaces", "value": ""} - ] - } -] diff --git a/packages/toolkit-core/test/fixtures/search-syntax/aggregate_rel_time_filter.json b/packages/toolkit-core/test/fixtures/search-syntax/aggregate_rel_time_filter.json deleted file mode 100644 index 7316cfdf7..000000000 --- a/packages/toolkit-core/test/fixtures/search-syntax/aggregate_rel_time_filter.json +++ /dev/null @@ -1,79 +0,0 @@ -[ - { - "query": "last_seen():+7d", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "aggregateRelativeDate", - "negated": false, - "key": { - "type": "keyAggregate", - "name": {"type": "keySimple", "value": "last_seen", "quoted": false}, - "args": null, - "argsSpaceBefore": {"type": "spaces", "value": ""}, - "argsSpaceAfter": {"type": "spaces", "value": ""} - }, - "operator": "", - "value": { - "type": "valueRelativeDate", - "value": "7", - "sign": "+", - "unit": "d", - "parsed": { - "value": "2017-10-24T02:41:20.000Z" - } - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "last_seen():-2w", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "aggregateRelativeDate", - "negated": false, - "key": { - "type": "keyAggregate", - "name": {"type": "keySimple", "value": "last_seen", "quoted": false}, - "args": null, - "argsSpaceBefore": {"type": "spaces", "value": ""}, - "argsSpaceAfter": {"type": "spaces", "value": ""} - }, - "operator": "", - "value": { - "type": "valueRelativeDate", - "value": "2", - "sign": "-", - "unit": "w", - "parsed": { - "value": "2017-10-03T02:41:20.000Z" - } - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "random:-2w", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "text", - "negated": false, - "key": {"type": "keySimple", "value": "random", "quoted": false}, - "operator": "", - "value": { - "type": "valueText", - "value": "-2w", - "quoted": false - } - }, - {"type": "spaces", "value": ""} - ] - } -] diff --git a/packages/toolkit-core/test/fixtures/search-syntax/basic_fallthrough.json b/packages/toolkit-core/test/fixtures/search-syntax/basic_fallthrough.json deleted file mode 100644 index fddb456c6..000000000 --- a/packages/toolkit-core/test/fixtures/search-syntax/basic_fallthrough.json +++ /dev/null @@ -1,135 +0,0 @@ -[ - { - "query": "random:2018-01-01", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "text", - "negated": false, - "key": {"type": "keySimple", "value": "random", "quoted": false}, - "operator": "", - "value": { - "type": "valueText", - "value": ">2018-01-01", - "quoted": false - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "random:hello", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "text", - "negated": false, - "key": {"type": "keySimple", "value": "random", "quoted": false}, - "operator": "", - "value": { - "type": "valueText", - "value": "hello", - "quoted": false - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "random:123", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "text", - "negated": false, - "key": {"type": "keySimple", "value": "random", "quoted": false}, - "operator": "", - "value": { - "type": "valueText", - "value": "123", - "quoted": false - } - }, - {"type": "spaces", "value": ""} - ] - } -] diff --git a/packages/toolkit-core/test/fixtures/search-syntax/boolean_filter.json b/packages/toolkit-core/test/fixtures/search-syntax/boolean_filter.json deleted file mode 100644 index 2350733a8..000000000 --- a/packages/toolkit-core/test/fixtures/search-syntax/boolean_filter.json +++ /dev/null @@ -1,107 +0,0 @@ -[ - { - "query": "stack.in_app:true", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "boolean", - "negated": false, - "key": {"type": "keySimple", "value": "stack.in_app", "quoted": false}, - "operator": "", - "value": {"type": "valueBoolean", "value": "true", "parsed": {"value": true}} - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "stack.in_app:TRUE", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "boolean", - "negated": false, - "key": {"type": "keySimple", "value": "stack.in_app", "quoted": false}, - "operator": "", - "value": {"type": "valueBoolean", "value": "TRUE", "parsed": {"value": true}} - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "stack.in_app:1", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "boolean", - "negated": false, - "key": {"type": "keySimple", "value": "stack.in_app", "quoted": false}, - "operator": "", - "value": {"type": "valueBoolean", "value": "1", "parsed": {"value": true}} - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "stack.in_app:false", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "boolean", - "negated": false, - "key": {"type": "keySimple", "value": "stack.in_app", "quoted": false}, - "operator": "", - "value": {"type": "valueBoolean", "value": "false", "parsed": {"value": false}} - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "stack.in_app:FALSE", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "boolean", - "negated": false, - "key": {"type": "keySimple", "value": "stack.in_app", "quoted": false}, - "operator": "", - "value": {"type": "valueBoolean", "value": "FALSE", "parsed": {"value": false}} - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "stack.in_app:0", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "boolean", - "negated": false, - "key": {"type": "keySimple", "value": "stack.in_app", "quoted": false}, - "operator": "", - "value": {"type": "valueBoolean", "value": "0", "parsed": {"value": false}} - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "!stack.in_app:false", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "boolean", - "negated": true, - "key": {"type": "keySimple", "value": "stack.in_app", "quoted": false}, - "operator": "", - "value": {"type": "valueBoolean", "value": "false", "parsed": {"value": false}} - }, - {"type": "spaces", "value": ""} - ] - } -] diff --git a/packages/toolkit-core/test/fixtures/search-syntax/boolean_filter_passthrough.json b/packages/toolkit-core/test/fixtures/search-syntax/boolean_filter_passthrough.json deleted file mode 100644 index 6112685e6..000000000 --- a/packages/toolkit-core/test/fixtures/search-syntax/boolean_filter_passthrough.json +++ /dev/null @@ -1,22 +0,0 @@ -[ - { - "query": "project_id:1", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "numeric", - "negated": false, - "key": {"type": "keySimple", "value": "project_id", "quoted": false}, - "operator": "", - "value": { - "type": "valueNumber", - "value": "1", - "unit": null, - "parsed": {"value": 1} - } - }, - {"type": "spaces", "value": ""} - ] - } -] diff --git a/packages/toolkit-core/test/fixtures/search-syntax/contains_operator.json b/packages/toolkit-core/test/fixtures/search-syntax/contains_operator.json deleted file mode 100644 index 0e8efa5fa..000000000 --- a/packages/toolkit-core/test/fixtures/search-syntax/contains_operator.json +++ /dev/null @@ -1,86 +0,0 @@ -[ - { - "query": "browser.name:Containsfirefox", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "text", - "negated": false, - "operator": "Contains", - "key": {"type": "keySimple", "value": "browser.name", "quoted": false}, - "value": {"type": "valueText", "value": "firefox", "quoted": false} - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "browser.name:Contains[firefox, chrome]", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "textIn", - "negated": false, - "operator": "Contains", - "key": {"type": "keySimple", "value": "browser.name", "quoted": false}, - "value": { - "type": "valueTextList", - "items": [ - { - "separator": "", - "value": {"type": "valueText", "value": "firefox", "quoted": false} - }, - { - "separator": ", ", - "value": {"type": "valueText", "value": "chrome", "quoted": false} - } - ] - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "!browser.name:Containsfirefox", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "text", - "negated": true, - "operator": "Contains", - "key": {"type": "keySimple", "value": "browser.name", "quoted": false}, - "value": {"type": "valueText", "value": "firefox", "quoted": false} - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "!browser.name:Contains[firefox, chrome]", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "textIn", - "negated": true, - "operator": "Contains", - "key": {"type": "keySimple", "value": "browser.name", "quoted": false}, - "value": { - "type": "valueTextList", - "items": [ - { - "separator": "", - "value": {"type": "valueText", "value": "firefox", "quoted": false} - }, - { - "separator": ", ", - "value": {"type": "valueText", "value": "chrome", "quoted": false} - } - ] - } - }, - {"type": "spaces", "value": ""} - ] - } -] diff --git a/packages/toolkit-core/test/fixtures/search-syntax/custom_explicit_tag.json b/packages/toolkit-core/test/fixtures/search-syntax/custom_explicit_tag.json deleted file mode 100644 index d2198878e..000000000 --- a/packages/toolkit-core/test/fixtures/search-syntax/custom_explicit_tag.json +++ /dev/null @@ -1,55 +0,0 @@ -[ - { - "query": "tags[fruit]:apple release:1.2.1 tags[project_id]:123", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "text", - "negated": false, - "key": { - "type": "keyExplicitTag", - "prefix": "tags", - "key": {"type": "keySimple", "value": "fruit", "quoted": false} - }, - "operator": "", - "value": { - "type": "valueText", - "value": "apple", - "quoted": false - } - }, - {"type": "spaces", "value": " "}, - { - "type": "filter", - "filter": "text", - "negated": false, - "key": {"type": "keySimple", "value": "release", "quoted": false}, - "operator": "", - "value": { - "type": "valueText", - "value": "1.2.1", - "quoted": false - } - }, - {"type": "spaces", "value": " "}, - { - "type": "filter", - "filter": "text", - "negated": false, - "key": { - "type": "keyExplicitTag", - "prefix": "tags", - "key": {"type": "keySimple", "value": "project_id", "quoted": false} - }, - "operator": "", - "value": { - "type": "valueText", - "value": "123", - "quoted": false - } - }, - {"type": "spaces", "value": ""} - ] - } -] diff --git a/packages/toolkit-core/test/fixtures/search-syntax/custom_tag.json b/packages/toolkit-core/test/fixtures/search-syntax/custom_tag.json deleted file mode 100644 index 744aaf32d..000000000 --- a/packages/toolkit-core/test/fixtures/search-syntax/custom_tag.json +++ /dev/null @@ -1,72 +0,0 @@ -[ - { - "query": "fruit:apple release:1.2.1", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "text", - "negated": false, - "key": {"type": "keySimple", "value": "fruit", "quoted": false}, - "operator": "", - "value": { - "type": "valueText", - "value": "apple", - "quoted": false - } - }, - {"type": "spaces", "value": " "}, - { - "type": "filter", - "filter": "text", - "negated": false, - "key": {"type": "keySimple", "value": "release", "quoted": false}, - "operator": "", - "value": { - "type": "valueText", - "value": "1.2.1", - "quoted": false - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "p95:>5s", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "text", - "negated": false, - "key": {"type": "keySimple", "value": "p95", "quoted": false}, - "operator": "", - "value": { - "type": "valueText", - "value": ">5s", - "quoted": false - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "p95:>5k", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "text", - "negated": false, - "key": {"type": "keySimple", "value": "p95", "quoted": false}, - "operator": "", - "value": { - "type": "valueText", - "value": ">5k", - "quoted": false - } - }, - {"type": "spaces", "value": ""} - ] - } -] diff --git a/packages/toolkit-core/test/fixtures/search-syntax/disallow_wildcard_filter.json b/packages/toolkit-core/test/fixtures/search-syntax/disallow_wildcard_filter.json deleted file mode 100644 index e1ad356d4..000000000 --- a/packages/toolkit-core/test/fixtures/search-syntax/disallow_wildcard_filter.json +++ /dev/null @@ -1,194 +0,0 @@ -[ - { - "desc": "FreeText with wildcard shall be invalid if disallowWildcard is true", - "query": "freeTextWith*", - "additionalConfig": { - "disallowWildcard": true - }, - "result": [ - { - "type": "spaces", - "value": "" - }, - { - "type": "freeText", - "value": "freeTextWith*", - "quoted": false, - "invalid": { - "type": "wildcard-not-allowed", - "reason": "Wildcards not supported in search" - } - }, - { - "type": "spaces", - "value": "" - } - ] - }, - { - "desc": "List value with wildcard shall be invalid if disallowWildcard is true", - "query": "release:[*]", - "additionalConfig": { - "disallowWildcard": true - }, - "result": [ - { - "type": "spaces", - "value": "" - }, - { - "type": "filter", - "filter": "textIn", - "invalid": { - "type": "wildcard-not-allowed", - "reason": "Wildcards not supported in search" - }, - "key": { - "type": "keySimple", - "value": "release", - "quoted": false - }, - "operator": "", - "negated": false, - "value": { - "items": [ - { - "separator": "", - "value": { - "quoted": false, - "type": "valueText", - "value": "*" - } - } - ], - "type": "valueTextList" - } - }, - { - "type": "spaces", - "value": "" - } - ] - }, - { - "desc": "Value shall be invalid if disallowWildcard is true", - "query": "release:*", - "additionalConfig": { - "disallowWildcard": true - }, - "result": [ - { - "type": "spaces", - "value": "" - }, - { - "type": "filter", - "filter": "text", - "negated": false, - "key": { - "type": "keySimple", - "value": "release", - "quoted": false - }, - "operator": "", - "value": { - "type": "valueText", - "value": "*", - "quoted": false - }, - "invalid": { - "type": "wildcard-not-allowed", - "reason": "Wildcards not supported in search" - } - }, - { - "type": "spaces", - "value": "" - } - ] - }, - { - "desc": "Key shall be invalid if not in supportedTags", - "query": "release*:1", - "additionalConfig": { - "disallowWildcard": true, - "supportedTags": { - "release": { - "key": "release", - "kind": "field" - } - } - }, - "result": [ - { - "type": "spaces", - "value": "" - }, - { - "type": "freeText", - "value": "release*:1", - "quoted": false, - "invalid": { - "type": "wildcard-not-allowed", - "reason": "Wildcards not supported in search" - } - }, - { - "type": "spaces", - "value": "" - } - ] - }, - { - "desc": "If disallowWildcard is true and a custom reason is provided, it shall be shown", - "query": "rele*ase", - "additionalConfig": { - "disallowWildcard": true, - "invalidMessages": { - "wildcard-not-allowed": "Release queries don't support wildcards" - } - }, - "result": [ - { - "type": "spaces", - "value": "" - }, - { - "type": "freeText", - "value": "rele*ase", - "quoted": false, - "invalid": { - "type": "wildcard-not-allowed", - "reason": "Release queries don't support wildcards" - } - }, - { - "type": "spaces", - "value": "" - } - ] - }, - { - "desc": "If disallowWildcard is true and a custom reason is provided, it shall be shown", - "query": "rele*ase", - "additionalConfig": { - "disallowWildcard": true, - "invalidMessages": { - "wildcard-not-allowed": "Release queries don't support wildcards" - } - }, - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "freeText", - "value": "rele*ase", - "quoted": false, - "invalid": { - "type": "wildcard-not-allowed", - "reason": "Release queries don't support wildcards" - } - }, - {"type": "spaces", "value": ""} - ] - } -] diff --git a/packages/toolkit-core/test/fixtures/search-syntax/duration_aggregate_measurements_filter.json b/packages/toolkit-core/test/fixtures/search-syntax/duration_aggregate_measurements_filter.json deleted file mode 100644 index b2d72aa65..000000000 --- a/packages/toolkit-core/test/fixtures/search-syntax/duration_aggregate_measurements_filter.json +++ /dev/null @@ -1,128 +0,0 @@ -[ - { - "query": "percentile(measurements.fp, 0.5):3.3s", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "aggregateDuration", - "negated": false, - "key": { - "type": "keyAggregate", - "name": {"type": "keySimple", "value": "percentile", "quoted": false}, - "args": { - "type": "keyAggregateArgs", - "args": [ - { - "separator": "", - "value": { - "type": "keyAggregateParam", - "value": "measurements.fp", - "quoted": false - } - }, - { - "separator": ", ", - "value": {"type": "keyAggregateParam", "value": "0.5", "quoted": false} - } - ] - }, - "argsSpaceBefore": {"type": "spaces", "value": ""}, - "argsSpaceAfter": {"type": "spaces", "value": ""} - }, - "operator": "", - "value": { - "type": "valueDuration", - "value": "3.3", - "unit": "s", - "parsed": {"value": 3300} - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "percentile(measurements.fp, 0.5):>3.3s", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "aggregateDuration", - "negated": false, - "key": { - "type": "keyAggregate", - "name": {"type": "keySimple", "value": "percentile", "quoted": false}, - "args": { - "type": "keyAggregateArgs", - "args": [ - { - "separator": "", - "value": { - "type": "keyAggregateParam", - "value": "measurements.fp", - "quoted": false - } - }, - { - "separator": ", ", - "value": {"type": "keyAggregateParam", "value": "0.5", "quoted": false} - } - ] - }, - "argsSpaceBefore": {"type": "spaces", "value": ""}, - "argsSpaceAfter": {"type": "spaces", "value": ""} - }, - "operator": ">", - "value": { - "type": "valueDuration", - "value": "3.3", - "unit": "s", - "parsed": {"value": 3300} - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "percentile(measurements.fp, 0.5):<3.3s", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "aggregateDuration", - "negated": false, - "key": { - "type": "keyAggregate", - "name": {"type": "keySimple", "value": "percentile", "quoted": false}, - "args": { - "type": "keyAggregateArgs", - "args": [ - { - "separator": "", - "value": { - "type": "keyAggregateParam", - "value": "measurements.fp", - "quoted": false - } - }, - { - "separator": ", ", - "value": {"type": "keyAggregateParam", "value": "0.5", "quoted": false} - } - ] - }, - "argsSpaceBefore": {"type": "spaces", "value": ""}, - "argsSpaceAfter": {"type": "spaces", "value": ""} - }, - "operator": "<", - "value": { - "type": "valueDuration", - "value": "3.3", - "unit": "s", - "parsed": {"value": 3300} - } - }, - {"type": "spaces", "value": ""} - ] - } -] diff --git a/packages/toolkit-core/test/fixtures/search-syntax/duration_aggregate_op_breakdowns_filter.json b/packages/toolkit-core/test/fixtures/search-syntax/duration_aggregate_op_breakdowns_filter.json deleted file mode 100644 index cee58f03b..000000000 --- a/packages/toolkit-core/test/fixtures/search-syntax/duration_aggregate_op_breakdowns_filter.json +++ /dev/null @@ -1,128 +0,0 @@ -[ - { - "query": "percentile(spans.browser, 0.5):3.3s", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "aggregateDuration", - "negated": false, - "key": { - "type": "keyAggregate", - "name": {"type": "keySimple", "value": "percentile", "quoted": false}, - "args": { - "type": "keyAggregateArgs", - "args": [ - { - "separator": "", - "value": { - "type": "keyAggregateParam", - "value": "spans.browser", - "quoted": false - } - }, - { - "separator": ", ", - "value": {"type": "keyAggregateParam", "value": "0.5", "quoted": false} - } - ] - }, - "argsSpaceBefore": {"type": "spaces", "value": ""}, - "argsSpaceAfter": {"type": "spaces", "value": ""} - }, - "operator": "", - "value": { - "type": "valueDuration", - "value": "3.3", - "unit": "s", - "parsed": {"value": 3300} - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "percentile(spans.browser, 0.5):>3.3s", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "aggregateDuration", - "negated": false, - "key": { - "type": "keyAggregate", - "name": {"type": "keySimple", "value": "percentile", "quoted": false}, - "args": { - "type": "keyAggregateArgs", - "args": [ - { - "separator": "", - "value": { - "type": "keyAggregateParam", - "value": "spans.browser", - "quoted": false - } - }, - { - "separator": ", ", - "value": {"type": "keyAggregateParam", "value": "0.5", "quoted": false} - } - ] - }, - "argsSpaceBefore": {"type": "spaces", "value": ""}, - "argsSpaceAfter": {"type": "spaces", "value": ""} - }, - "operator": ">", - "value": { - "type": "valueDuration", - "value": "3.3", - "unit": "s", - "parsed": {"value": 3300} - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "percentile(spans.browser, 0.5):<3.3s", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "aggregateDuration", - "negated": false, - "key": { - "type": "keyAggregate", - "name": {"type": "keySimple", "value": "percentile", "quoted": false}, - "args": { - "type": "keyAggregateArgs", - "args": [ - { - "separator": "", - "value": { - "type": "keyAggregateParam", - "value": "spans.browser", - "quoted": false - } - }, - { - "separator": ", ", - "value": {"type": "keyAggregateParam", "value": "0.5", "quoted": false} - } - ] - }, - "argsSpaceBefore": {"type": "spaces", "value": ""}, - "argsSpaceAfter": {"type": "spaces", "value": ""} - }, - "operator": "<", - "value": { - "type": "valueDuration", - "value": "3.3", - "unit": "s", - "parsed": {"value": 3300} - } - }, - {"type": "spaces", "value": ""} - ] - } -] diff --git a/packages/toolkit-core/test/fixtures/search-syntax/duration_filter.json b/packages/toolkit-core/test/fixtures/search-syntax/duration_filter.json deleted file mode 100644 index e2ce7d779..000000000 --- a/packages/toolkit-core/test/fixtures/search-syntax/duration_filter.json +++ /dev/null @@ -1,42 +0,0 @@ -[ - { - "query": "transaction.duration:>500s", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "duration", - "negated": false, - "key": {"type": "keySimple", "value": "transaction.duration", "quoted": false}, - "operator": ">", - "value": { - "type": "valueDuration", - "value": "500", - "unit": "s", - "parsed": {"value": 500000} - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "!transaction.duration:500s", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "duration", - "negated": true, - "key": {"type": "keySimple", "value": "transaction.duration", "quoted": false}, - "operator": "", - "value": { - "type": "valueDuration", - "value": "500", - "unit": "s", - "parsed": {"value": 500000} - } - }, - {"type": "spaces", "value": ""} - ] - } -] diff --git a/packages/toolkit-core/test/fixtures/search-syntax/duration_filter_overrides_numeric_shorthand.json b/packages/toolkit-core/test/fixtures/search-syntax/duration_filter_overrides_numeric_shorthand.json deleted file mode 100644 index a81ba0d9c..000000000 --- a/packages/toolkit-core/test/fixtures/search-syntax/duration_filter_overrides_numeric_shorthand.json +++ /dev/null @@ -1,23 +0,0 @@ -[ - { - "desc": "2m should mean 2 minutes for duration filters (as opposed to 2 million)", - "query": "transaction.duration:>2m", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "duration", - "negated": false, - "key": {"type": "keySimple", "value": "transaction.duration", "quoted": false}, - "operator": ">", - "value": { - "type": "valueDuration", - "value": "2", - "unit": "m", - "parsed": {"value": 120000} - } - }, - {"type": "spaces", "value": ""} - ] - } -] diff --git a/packages/toolkit-core/test/fixtures/search-syntax/duration_measurements_filter.json b/packages/toolkit-core/test/fixtures/search-syntax/duration_measurements_filter.json deleted file mode 100644 index 56f7bf875..000000000 --- a/packages/toolkit-core/test/fixtures/search-syntax/duration_measurements_filter.json +++ /dev/null @@ -1,62 +0,0 @@ -[ - { - "query": "measurements.fp:1.5s", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "duration", - "negated": false, - "key": {"type": "keySimple", "value": "measurements.fp", "quoted": false}, - "operator": "", - "value": { - "type": "valueDuration", - "value": "1.5", - "unit": "s", - "parsed": {"value": 1500} - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "measurements.fp:>1.5s", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "duration", - "negated": false, - "key": {"type": "keySimple", "value": "measurements.fp", "quoted": false}, - "operator": ">", - "value": { - "type": "valueDuration", - "value": "1.5", - "unit": "s", - "parsed": {"value": 1500} - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "measurements.fp:<1.5s", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "duration", - "negated": false, - "key": {"type": "keySimple", "value": "measurements.fp", "quoted": false}, - "operator": "<", - "value": { - "type": "valueDuration", - "value": "1.5", - "unit": "s", - "parsed": {"value": 1500} - } - }, - {"type": "spaces", "value": ""} - ] - } -] diff --git a/packages/toolkit-core/test/fixtures/search-syntax/duration_on_non_duration_field.json b/packages/toolkit-core/test/fixtures/search-syntax/duration_on_non_duration_field.json deleted file mode 100644 index 76d03df7a..000000000 --- a/packages/toolkit-core/test/fixtures/search-syntax/duration_on_non_duration_field.json +++ /dev/null @@ -1,21 +0,0 @@ -[ - { - "query": "user.id:500s", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "text", - "negated": false, - "key": {"type": "keySimple", "value": "user.id", "quoted": false}, - "operator": "", - "value": { - "type": "valueText", - "value": "500s", - "quoted": false - } - }, - {"type": "spaces", "value": ""} - ] - } -] diff --git a/packages/toolkit-core/test/fixtures/search-syntax/duration_op_breakdowns_filter.json b/packages/toolkit-core/test/fixtures/search-syntax/duration_op_breakdowns_filter.json deleted file mode 100644 index 87b8f9811..000000000 --- a/packages/toolkit-core/test/fixtures/search-syntax/duration_op_breakdowns_filter.json +++ /dev/null @@ -1,62 +0,0 @@ -[ - { - "query": "spans.browser:1.5s", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "duration", - "negated": false, - "key": {"type": "keySimple", "value": "spans.browser", "quoted": false}, - "operator": "", - "value": { - "type": "valueDuration", - "value": "1.5", - "unit": "s", - "parsed": {"value": 1500} - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "spans.browser:>1.5s", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "duration", - "negated": false, - "key": {"type": "keySimple", "value": "spans.browser", "quoted": false}, - "operator": ">", - "value": { - "type": "valueDuration", - "value": "1.5", - "unit": "s", - "parsed": {"value": 1500} - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "spans.browser:<1.5s", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "duration", - "negated": false, - "key": {"type": "keySimple", "value": "spans.browser", "quoted": false}, - "operator": "<", - "value": { - "type": "valueDuration", - "value": "1.5", - "unit": "s", - "parsed": {"value": 1500} - } - }, - {"type": "spaces", "value": ""} - ] - } -] diff --git a/packages/toolkit-core/test/fixtures/search-syntax/empty_filter_value.json b/packages/toolkit-core/test/fixtures/search-syntax/empty_filter_value.json deleted file mode 100644 index f214021b2..000000000 --- a/packages/toolkit-core/test/fixtures/search-syntax/empty_filter_value.json +++ /dev/null @@ -1,44 +0,0 @@ -[ - { - "query": "device.family:\"\"", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "text", - "negated": false, - "key": {"type": "keySimple", "value": "device.family", "quoted": false}, - "operator": "", - "value": { - "type": "valueText", - "value": "", - "quoted": true - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "device.family:", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "text", - "negated": false, - "invalid": { - "type": "filter-must-have-value", - "reason": "Filter must have a value" - }, - "key": {"type": "keySimple", "value": "device.family", "quoted": false}, - "operator": "", - "value": { - "type": "valueText", - "value": "", - "quoted": false - } - }, - {"type": "spaces", "value": ""} - ] - } -] diff --git a/packages/toolkit-core/test/fixtures/search-syntax/empty_spaces_stripped_correctly.json b/packages/toolkit-core/test/fixtures/search-syntax/empty_spaces_stripped_correctly.json deleted file mode 100644 index 754194830..000000000 --- a/packages/toolkit-core/test/fixtures/search-syntax/empty_spaces_stripped_correctly.json +++ /dev/null @@ -1,34 +0,0 @@ -[ - { - "query": "event.type:transaction transaction:/organizations/:orgId/discover/results/", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "text", - "negated": false, - "key": {"type": "keySimple", "value": "event.type", "quoted": false}, - "operator": "", - "value": { - "type": "valueText", - "value": "transaction", - "quoted": false - } - }, - {"type": "spaces", "value": " "}, - { - "type": "filter", - "filter": "text", - "negated": false, - "key": {"type": "keySimple", "value": "transaction", "quoted": false}, - "operator": "", - "value": { - "type": "valueText", - "value": "/organizations/:orgId/discover/results/", - "quoted": false - } - }, - {"type": "spaces", "value": ""} - ] - } -] diff --git a/packages/toolkit-core/test/fixtures/search-syntax/empty_string.json b/packages/toolkit-core/test/fixtures/search-syntax/empty_string.json deleted file mode 100644 index fd48840ec..000000000 --- a/packages/toolkit-core/test/fixtures/search-syntax/empty_string.json +++ /dev/null @@ -1,7 +0,0 @@ -[ - { - "desc": "Empty quotations become a dropped term", - "query": "", - "result": [{"type": "spaces", "value": ""}] - } -] diff --git a/packages/toolkit-core/test/fixtures/search-syntax/ends_with_operator.json b/packages/toolkit-core/test/fixtures/search-syntax/ends_with_operator.json deleted file mode 100644 index 2cbcad530..000000000 --- a/packages/toolkit-core/test/fixtures/search-syntax/ends_with_operator.json +++ /dev/null @@ -1,86 +0,0 @@ -[ - { - "query": "browser.name:EndsWithfirefox", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "text", - "negated": false, - "operator": "EndsWith", - "key": {"type": "keySimple", "value": "browser.name", "quoted": false}, - "value": {"type": "valueText", "value": "firefox", "quoted": false} - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "browser.name:EndsWith[firefox, chrome]", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "textIn", - "negated": false, - "operator": "EndsWith", - "key": {"type": "keySimple", "value": "browser.name", "quoted": false}, - "value": { - "type": "valueTextList", - "items": [ - { - "separator": "", - "value": {"type": "valueText", "value": "firefox", "quoted": false} - }, - { - "separator": ", ", - "value": {"type": "valueText", "value": "chrome", "quoted": false} - } - ] - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "!browser.name:EndsWithfirefox", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "text", - "negated": true, - "operator": "EndsWith", - "key": {"type": "keySimple", "value": "browser.name", "quoted": false}, - "value": {"type": "valueText", "value": "firefox", "quoted": false} - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "!browser.name:EndsWith[firefox, chrome]", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "textIn", - "negated": true, - "operator": "EndsWith", - "key": {"type": "keySimple", "value": "browser.name", "quoted": false}, - "value": { - "type": "valueTextList", - "items": [ - { - "separator": "", - "value": {"type": "valueText", "value": "firefox", "quoted": false} - }, - { - "separator": ", ", - "value": {"type": "valueText", "value": "chrome", "quoted": false} - } - ] - } - }, - {"type": "spaces", "value": ""} - ] - } -] diff --git a/packages/toolkit-core/test/fixtures/search-syntax/escaped_quote_value.json b/packages/toolkit-core/test/fixtures/search-syntax/escaped_quote_value.json deleted file mode 100644 index 3fa9d057c..000000000 --- a/packages/toolkit-core/test/fixtures/search-syntax/escaped_quote_value.json +++ /dev/null @@ -1,62 +0,0 @@ -[ - { - "query": "device.family:\\\"", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "text", - "negated": false, - "key": {"type": "keySimple", "value": "device.family", "quoted": false}, - "operator": "", - "value": { - "type": "valueText", - "value": "\\\"", - "quoted": false - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "device.family:te\\\"st", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "text", - "negated": false, - "key": {"type": "keySimple", "value": "device.family", "quoted": false}, - "operator": "", - "value": { - "type": "valueText", - "value": "te\\\"st", - "quoted": false - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "desc": "This is a weird case. I think this should be an error, but it doesn't seem trivial to rewrite the grammar to handle that.", - "query": "url:\"te\"st", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "text", - "negated": false, - "key": {"type": "keySimple", "value": "url", "quoted": false}, - "operator": "", - "value": { - "type": "valueText", - "value": "te", - "quoted": true - } - }, - {"type": "spaces", "value": ""}, - {"type": "freeText", "value": "st", "quoted": false, "invalid": null}, - {"type": "spaces", "value": ""} - ] - } -] diff --git a/packages/toolkit-core/test/fixtures/search-syntax/escaped_quotes.json b/packages/toolkit-core/test/fixtures/search-syntax/escaped_quotes.json deleted file mode 100644 index 54b88671c..000000000 --- a/packages/toolkit-core/test/fixtures/search-syntax/escaped_quotes.json +++ /dev/null @@ -1,40 +0,0 @@ -[ - { - "query": "release:\"a\\\"thing\\\"\"", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "text", - "negated": false, - "key": {"type": "keySimple", "value": "release", "quoted": false}, - "operator": "", - "value": { - "type": "valueText", - "value": "a\\\"thing\\\"", - "quoted": true - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "release:\"a\\\"\\\"release\"", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "text", - "negated": false, - "key": {"type": "keySimple", "value": "release", "quoted": false}, - "operator": "", - "value": { - "type": "valueText", - "value": "a\\\"\\\"release", - "quoted": true - } - }, - {"type": "spaces", "value": ""} - ] - } -] diff --git a/packages/toolkit-core/test/fixtures/search-syntax/explicit_array_tag.json b/packages/toolkit-core/test/fixtures/search-syntax/explicit_array_tag.json deleted file mode 100644 index 00d9ee7e2..000000000 --- a/packages/toolkit-core/test/fixtures/search-syntax/explicit_array_tag.json +++ /dev/null @@ -1,87 +0,0 @@ -[ - { - "query": "tags[fruit[*],array]:apple release:1.2.1 tags[project_id[*],array]:123", - "result": [ - { - "type": "spaces", - "value": "" - }, - { - "type": "filter", - "filter": "arrayIncludes", - "key": { - "type": "keyArrayIncludes", - "key": { - "type": "keyExplicitArrayTag", - "prefix": "tags", - "key": { - "type": "keySimple", - "value": "fruit", - "quoted": false - } - }, - "index": "*" - }, - "value": { - "type": "valueText", - "value": "apple", - "quoted": false - }, - "negated": false, - "operator": "" - }, - { - "type": "spaces", - "value": " " - }, - { - "type": "filter", - "filter": "text", - "key": { - "type": "keySimple", - "value": "release", - "quoted": false - }, - "value": { - "type": "valueText", - "value": "1.2.1", - "quoted": false - }, - "negated": false, - "operator": "" - }, - { - "type": "spaces", - "value": " " - }, - { - "type": "filter", - "filter": "arrayIncludes", - "key": { - "type": "keyArrayIncludes", - "key": { - "type": "keyExplicitArrayTag", - "prefix": "tags", - "key": { - "type": "keySimple", - "value": "project_id", - "quoted": false - } - }, - "index": "*" - }, - "value": { - "type": "valueText", - "value": "123", - "quoted": false - }, - "negated": false, - "operator": "" - }, - { - "type": "spaces", - "value": "" - } - ] - } -] diff --git a/packages/toolkit-core/test/fixtures/search-syntax/explicit_boolean_tag.json b/packages/toolkit-core/test/fixtures/search-syntax/explicit_boolean_tag.json deleted file mode 100644 index 63bfe309e..000000000 --- a/packages/toolkit-core/test/fixtures/search-syntax/explicit_boolean_tag.json +++ /dev/null @@ -1,55 +0,0 @@ -[ - { - "query": "tags[foo,boolean]:true release:1.2.1 tags[project_id,boolean]:false", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "text", - "negated": false, - "key": { - "type": "keyExplicitBooleanTag", - "prefix": "tags", - "key": {"type": "keySimple", "value": "foo", "quoted": false} - }, - "operator": "", - "value": { - "type": "valueText", - "value": "true", - "quoted": false - } - }, - {"type": "spaces", "value": " "}, - { - "type": "filter", - "filter": "text", - "negated": false, - "key": {"type": "keySimple", "value": "release", "quoted": false}, - "operator": "", - "value": { - "type": "valueText", - "value": "1.2.1", - "quoted": false - } - }, - {"type": "spaces", "value": " "}, - { - "type": "filter", - "filter": "text", - "negated": false, - "key": { - "type": "keyExplicitBooleanTag", - "prefix": "tags", - "key": {"type": "keySimple", "value": "project_id", "quoted": false} - }, - "operator": "", - "value": { - "type": "valueText", - "value": "false", - "quoted": false - } - }, - {"type": "spaces", "value": ""} - ] - } -] diff --git a/packages/toolkit-core/test/fixtures/search-syntax/explicit_number_tag.json b/packages/toolkit-core/test/fixtures/search-syntax/explicit_number_tag.json deleted file mode 100644 index 9ee432a6c..000000000 --- a/packages/toolkit-core/test/fixtures/search-syntax/explicit_number_tag.json +++ /dev/null @@ -1,55 +0,0 @@ -[ - { - "query": "tags[foo,number]:456 release:1.2.1 tags[project_id,number]:123", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "text", - "negated": false, - "key": { - "type": "keyExplicitNumberTag", - "prefix": "tags", - "key": {"type": "keySimple", "value": "foo", "quoted": false} - }, - "operator": "", - "value": { - "type": "valueText", - "value": "456", - "quoted": false - } - }, - {"type": "spaces", "value": " "}, - { - "type": "filter", - "filter": "text", - "negated": false, - "key": {"type": "keySimple", "value": "release", "quoted": false}, - "operator": "", - "value": { - "type": "valueText", - "value": "1.2.1", - "quoted": false - } - }, - {"type": "spaces", "value": " "}, - { - "type": "filter", - "filter": "text", - "negated": false, - "key": { - "type": "keyExplicitNumberTag", - "prefix": "tags", - "key": {"type": "keySimple", "value": "project_id", "quoted": false} - }, - "operator": "", - "value": { - "type": "valueText", - "value": "123", - "quoted": false - } - }, - {"type": "spaces", "value": ""} - ] - } -] diff --git a/packages/toolkit-core/test/fixtures/search-syntax/explicit_number_tags_in_filter.json b/packages/toolkit-core/test/fixtures/search-syntax/explicit_number_tags_in_filter.json deleted file mode 100644 index 681e1d38b..000000000 --- a/packages/toolkit-core/test/fixtures/search-syntax/explicit_number_tags_in_filter.json +++ /dev/null @@ -1,41 +0,0 @@ -[ - { - "query": "tags[foo,number]:[123, 456]", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "textIn", - "negated": false, - "key": { - "type": "keyExplicitNumberTag", - "prefix": "tags", - "key": {"type": "keySimple", "value": "foo", "quoted": false} - }, - "operator": "", - "value": { - "type": "valueTextList", - "items": [ - { - "separator": "", - "value": { - "type": "valueText", - "value": "123", - "quoted": false - } - }, - { - "separator": ", ", - "value": { - "type": "valueText", - "value": "456", - "quoted": false - } - } - ] - } - }, - {"type": "spaces", "value": ""} - ] - } -] diff --git a/packages/toolkit-core/test/fixtures/search-syntax/explicit_string_tag.json b/packages/toolkit-core/test/fixtures/search-syntax/explicit_string_tag.json deleted file mode 100644 index 95bf5320c..000000000 --- a/packages/toolkit-core/test/fixtures/search-syntax/explicit_string_tag.json +++ /dev/null @@ -1,55 +0,0 @@ -[ - { - "query": "tags[fruit,string]:apple release:1.2.1 tags[project_id,string]:123", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "text", - "negated": false, - "key": { - "type": "keyExplicitStringTag", - "prefix": "tags", - "key": {"type": "keySimple", "value": "fruit", "quoted": false} - }, - "operator": "", - "value": { - "type": "valueText", - "value": "apple", - "quoted": false - } - }, - {"type": "spaces", "value": " "}, - { - "type": "filter", - "filter": "text", - "negated": false, - "key": {"type": "keySimple", "value": "release", "quoted": false}, - "operator": "", - "value": { - "type": "valueText", - "value": "1.2.1", - "quoted": false - } - }, - {"type": "spaces", "value": " "}, - { - "type": "filter", - "filter": "text", - "negated": false, - "key": { - "type": "keyExplicitStringTag", - "prefix": "tags", - "key": {"type": "keySimple", "value": "project_id", "quoted": false} - }, - "operator": "", - "value": { - "type": "valueText", - "value": "123", - "quoted": false - } - }, - {"type": "spaces", "value": ""} - ] - } -] diff --git a/packages/toolkit-core/test/fixtures/search-syntax/explicit_string_tags_in_filter.json b/packages/toolkit-core/test/fixtures/search-syntax/explicit_string_tags_in_filter.json deleted file mode 100644 index 16498eb1a..000000000 --- a/packages/toolkit-core/test/fixtures/search-syntax/explicit_string_tags_in_filter.json +++ /dev/null @@ -1,80 +0,0 @@ -[ - { - "query": "tags[fruit,string]:[apple, pear]", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "textIn", - "negated": false, - "key": { - "type": "keyExplicitStringTag", - "prefix": "tags", - "key": {"type": "keySimple", "value": "fruit", "quoted": false} - }, - "operator": "", - "value": { - "type": "valueTextList", - "items": [ - { - "separator": "", - "value": { - "type": "valueText", - "value": "apple", - "quoted": false - } - }, - { - "separator": ", ", - "value": { - "type": "valueText", - "value": "pear", - "quoted": false - } - } - ] - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "tags[fruit,string]:[\"apple wow\", \"pear\"]", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "textIn", - "negated": false, - "key": { - "type": "keyExplicitStringTag", - "prefix": "tags", - "key": {"type": "keySimple", "value": "fruit", "quoted": false} - }, - "operator": "", - "value": { - "type": "valueTextList", - "items": [ - { - "separator": "", - "value": { - "type": "valueText", - "value": "apple wow", - "quoted": true - } - }, - { - "separator": ", ", - "value": { - "type": "valueText", - "value": "pear", - "quoted": true - } - } - ] - } - }, - {"type": "spaces", "value": ""} - ] - } -] diff --git a/packages/toolkit-core/test/fixtures/search-syntax/explicit_tags_in_filter.json b/packages/toolkit-core/test/fixtures/search-syntax/explicit_tags_in_filter.json deleted file mode 100644 index c85b99915..000000000 --- a/packages/toolkit-core/test/fixtures/search-syntax/explicit_tags_in_filter.json +++ /dev/null @@ -1,80 +0,0 @@ -[ - { - "query": "tags[fruit]:[apple, pear]", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "textIn", - "negated": false, - "key": { - "type": "keyExplicitTag", - "prefix": "tags", - "key": {"type": "keySimple", "value": "fruit", "quoted": false} - }, - "operator": "", - "value": { - "type": "valueTextList", - "items": [ - { - "separator": "", - "value": { - "type": "valueText", - "value": "apple", - "quoted": false - } - }, - { - "separator": ", ", - "value": { - "type": "valueText", - "value": "pear", - "quoted": false - } - } - ] - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "tags[fruit]:[\"apple wow\", \"pear\"]", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "textIn", - "negated": false, - "key": { - "type": "keyExplicitTag", - "prefix": "tags", - "key": {"type": "keySimple", "value": "fruit", "quoted": false} - }, - "operator": "", - "value": { - "type": "valueTextList", - "items": [ - { - "separator": "", - "value": { - "type": "valueText", - "value": "apple wow", - "quoted": true - } - }, - { - "separator": ", ", - "value": { - "type": "valueText", - "value": "pear", - "quoted": true - } - } - ] - } - }, - {"type": "spaces", "value": ""} - ] - } -] diff --git a/packages/toolkit-core/test/fixtures/search-syntax/free_text_search_anywhere.json b/packages/toolkit-core/test/fixtures/search-syntax/free_text_search_anywhere.json deleted file mode 100644 index ecf438d2a..000000000 --- a/packages/toolkit-core/test/fixtures/search-syntax/free_text_search_anywhere.json +++ /dev/null @@ -1,85 +0,0 @@ -[ - { - "query": "hello what user.email:foo@example.com where release:1.2.1 when", - "result": [ - {"type": "spaces", "value": ""}, - {"type": "freeText", "value": "hello what ", "quoted": false, "invalid": null}, - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "text", - "negated": false, - "key": {"type": "keySimple", "value": "user.email", "quoted": false}, - "operator": "", - "value": { - "type": "valueText", - "value": "foo@example.com", - "quoted": false - } - }, - {"type": "spaces", "value": " "}, - {"type": "freeText", "value": "where ", "quoted": false, "invalid": null}, - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "text", - "negated": false, - "key": {"type": "keySimple", "value": "release", "quoted": false}, - "operator": "", - "value": { - "type": "valueText", - "value": "1.2.1", - "quoted": false - } - }, - {"type": "spaces", "value": " "}, - {"type": "freeText", "value": "when", "quoted": false, "invalid": null}, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "hello", - "result": [ - {"type": "spaces", "value": ""}, - {"type": "freeText", "value": "hello", "quoted": false, "invalid": null}, - {"type": "spaces", "value": ""} - ] - }, - { - "query": " hello ", - "result": [ - {"type": "spaces", "value": " "}, - {"type": "freeText", "value": "hello ", "quoted": false, "invalid": null}, - {"type": "spaces", "value": ""} - ] - }, - { - "query": " hello there", - "result": [ - {"type": "spaces", "value": " "}, - {"type": "freeText", "value": "hello there", "quoted": false, "invalid": null}, - {"type": "spaces", "value": ""} - ] - }, - { - "query": " hello there:bye", - "result": [ - {"type": "spaces", "value": " "}, - {"type": "freeText", "value": "hello ", "quoted": false, "invalid": null}, - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "text", - "negated": false, - "key": {"type": "keySimple", "value": "there", "quoted": false}, - "operator": "", - "value": { - "type": "valueText", - "value": "bye", - "quoted": false - } - }, - {"type": "spaces", "value": ""} - ] - } -] diff --git a/packages/toolkit-core/test/fixtures/search-syntax/has_tag.json b/packages/toolkit-core/test/fixtures/search-syntax/has_tag.json deleted file mode 100644 index 0d8ce7ba9..000000000 --- a/packages/toolkit-core/test/fixtures/search-syntax/has_tag.json +++ /dev/null @@ -1,62 +0,0 @@ -[ - { - "desc": "unquoted key", - "query": "has:release", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "has", - "negated": false, - "key": {"type": "keySimple", "value": "has", "quoted": false}, - "operator": "", - "value": { - "type": "valueText", - "value": "release", - "quoted": false - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "desc": "quoted key", - "query": "has:\"hi:there\"", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "has", - "negated": false, - "key": {"type": "keySimple", "value": "has", "quoted": false}, - "operator": "", - "value": { - "type": "valueText", - "value": "hi:there", - "quoted": true - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "desc": "malformed key", - "query": "has:\"hi there\"", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "has", - "negated": false, - "key": {"type": "keySimple", "value": "has", "quoted": false}, - "operator": "", - "value": { - "type": "valueText", - "value": "hi there", - "quoted": true - } - }, - {"type": "spaces", "value": ""} - ] - } -] diff --git a/packages/toolkit-core/test/fixtures/search-syntax/invalid_aggregate_column_with_duration_filter.json b/packages/toolkit-core/test/fixtures/search-syntax/invalid_aggregate_column_with_duration_filter.json deleted file mode 100644 index a105d967f..000000000 --- a/packages/toolkit-core/test/fixtures/search-syntax/invalid_aggregate_column_with_duration_filter.json +++ /dev/null @@ -1,15 +0,0 @@ -[ - { - "query": "avg(stack.colno):>500s", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "freeText", - "quoted": false, - "value": "avg(stack.colno):>500s", - "invalid": null - }, - {"type": "spaces", "value": ""} - ] - } -] diff --git a/packages/toolkit-core/test/fixtures/search-syntax/invalid_aggregate_duration_filter.json b/packages/toolkit-core/test/fixtures/search-syntax/invalid_aggregate_duration_filter.json deleted file mode 100644 index b777144d1..000000000 --- a/packages/toolkit-core/test/fixtures/search-syntax/invalid_aggregate_duration_filter.json +++ /dev/null @@ -1,15 +0,0 @@ -[ - { - "query": "avg(transaction.duration):>..500s", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "freeText", - "value": "avg(transaction.duration):>..500s", - "quoted": false, - "invalid": null - }, - {"type": "spaces", "value": ""} - ] - } -] diff --git a/packages/toolkit-core/test/fixtures/search-syntax/invalid_aggregate_empty_parameter.json b/packages/toolkit-core/test/fixtures/search-syntax/invalid_aggregate_empty_parameter.json deleted file mode 100644 index dec8d006e..000000000 --- a/packages/toolkit-core/test/fixtures/search-syntax/invalid_aggregate_empty_parameter.json +++ /dev/null @@ -1,48 +0,0 @@ -[ - { - "query": "percentile(measurements.fp,):3.3s", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "aggregateDuration", - "negated": false, - "key": { - "type": "keyAggregate", - "name": {"type": "keySimple", "value": "percentile", "quoted": false}, - "args": { - "type": "keyAggregateArgs", - "args": [ - { - "separator": "", - "value": { - "type": "keyAggregateParam", - "value": "measurements.fp", - "quoted": false - } - }, - { - "separator": ",", - "value": null - } - ] - }, - "argsSpaceBefore": {"type": "spaces", "value": ""}, - "argsSpaceAfter": {"type": "spaces", "value": ""} - }, - "operator": "", - "value": { - "type": "valueDuration", - "value": "3.3", - "unit": "s", - "parsed": {"value": 3300} - }, - "invalid": { - "reason": "Function parameters should not have empty values", - "type": "empty-parameter-not-allowed" - } - }, - {"type": "spaces", "value": ""} - ] - } -] diff --git a/packages/toolkit-core/test/fixtures/search-syntax/invalid_aggregate_percentage_filter.json b/packages/toolkit-core/test/fixtures/search-syntax/invalid_aggregate_percentage_filter.json deleted file mode 100644 index 4395c14da..000000000 --- a/packages/toolkit-core/test/fixtures/search-syntax/invalid_aggregate_percentage_filter.json +++ /dev/null @@ -1,15 +0,0 @@ -[ - { - "query": "percentage(transaction.duration, transaction.duration):>..500%", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "freeText", - "value": "percentage(transaction.duration, transaction.duration):>..500%", - "quoted": false, - "invalid": null - }, - {"type": "spaces", "value": ""} - ] - } -] diff --git a/packages/toolkit-core/test/fixtures/search-syntax/invalid_boolean_filter.json b/packages/toolkit-core/test/fixtures/search-syntax/invalid_boolean_filter.json deleted file mode 100644 index 38bab1cf8..000000000 --- a/packages/toolkit-core/test/fixtures/search-syntax/invalid_boolean_filter.json +++ /dev/null @@ -1,74 +0,0 @@ -[ - { - "query": "stack.in_app:lol", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "text", - "negated": false, - "invalid": { - "type": "invalid-boolean", - "reason": "Invalid boolean. Expected true, 1, false, or 0.", - "expectedType": ["boolean"] - }, - "key": {"type": "keySimple", "value": "stack.in_app", "quoted": false}, - "operator": "", - "value": { - "type": "valueText", - "value": "lol", - "quoted": false - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "stack.in_app:123", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "text", - "negated": false, - "invalid": { - "type": "invalid-boolean", - "reason": "Invalid boolean. Expected true, 1, false, or 0.", - "expectedType": ["boolean"] - }, - "key": {"type": "keySimple", "value": "stack.in_app", "quoted": false}, - "operator": "", - "value": { - "type": "valueText", - "value": "123", - "quoted": false - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "stack.in_app:>true", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "text", - "negated": false, - "invalid": { - "type": "invalid-boolean", - "reason": "Invalid boolean. Expected true, 1, false, or 0.", - "expectedType": ["boolean"] - }, - "key": {"type": "keySimple", "value": "stack.in_app", "quoted": false}, - "operator": "", - "value": { - "type": "valueText", - "value": ">true", - "quoted": false - } - }, - {"type": "spaces", "value": ""} - ] - } -] diff --git a/packages/toolkit-core/test/fixtures/search-syntax/invalid_date_formats.json b/packages/toolkit-core/test/fixtures/search-syntax/invalid_date_formats.json deleted file mode 100644 index a65a6f4f7..000000000 --- a/packages/toolkit-core/test/fixtures/search-syntax/invalid_date_formats.json +++ /dev/null @@ -1,74 +0,0 @@ -[ - { - "query": "timestamp:hello", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "text", - "negated": false, - "invalid": { - "type": "invalid-date-format", - "reason": "Invalid date format. Expected +/-duration (e.g. +1h) or ISO 8601-like (e.g. 2017-10-17 or 2017-10-17T02:41:00.000Z)", - "expectedType": ["date", "specificDate", "relativeDate"] - }, - "key": {"type": "keySimple", "value": "timestamp", "quoted": false}, - "operator": "", - "value": { - "type": "valueText", - "value": "hello", - "quoted": false - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "timestamp:123", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "text", - "negated": false, - "invalid": { - "type": "invalid-date-format", - "reason": "Invalid date format. Expected +/-duration (e.g. +1h) or ISO 8601-like (e.g. 2017-10-17 or 2017-10-17T02:41:00.000Z)", - "expectedType": ["date", "specificDate", "relativeDate"] - }, - "key": {"type": "keySimple", "value": "timestamp", "quoted": false}, - "operator": "", - "value": { - "type": "valueText", - "value": "123", - "quoted": false - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "timestamp:2018-01-01T00:01ZZ", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "text", - "negated": false, - "invalid": { - "type": "invalid-date-format", - "reason": "Invalid date format. Expected +/-duration (e.g. +1h) or ISO 8601-like (e.g. 2017-10-17 or 2017-10-17T02:41:00.000Z)", - "expectedType": ["date", "specificDate", "relativeDate"] - }, - "key": {"type": "keySimple", "value": "timestamp", "quoted": false}, - "operator": "", - "value": { - "type": "valueText", - "value": "2018-01-01T00:01ZZ", - "quoted": false - } - }, - {"type": "spaces", "value": ""} - ] - } -] diff --git a/packages/toolkit-core/test/fixtures/search-syntax/invalid_duration_filter.json b/packages/toolkit-core/test/fixtures/search-syntax/invalid_duration_filter.json deleted file mode 100644 index fa00d622d..000000000 --- a/packages/toolkit-core/test/fixtures/search-syntax/invalid_duration_filter.json +++ /dev/null @@ -1,26 +0,0 @@ -[ - { - "query": "transaction.duration:>..500s", - "result": [ - {"type": "spaces", "value": ""}, - { - "filter": "text", - "negated": false, - "operator": "", - "invalid": { - "type": "invalid-duration", - "reason": "Invalid duration. Expected number followed by duration unit suffix", - "expectedType": ["duration"] - }, - "key": {"quoted": false, "type": "keySimple", "value": "transaction.duration"}, - "type": "filter", - "value": { - "quoted": false, - "type": "valueText", - "value": ">..500s" - } - }, - {"type": "spaces", "value": ""} - ] - } -] diff --git a/packages/toolkit-core/test/fixtures/search-syntax/invalid_numeric_aggregate_filter.json b/packages/toolkit-core/test/fixtures/search-syntax/invalid_numeric_aggregate_filter.json deleted file mode 100644 index 7d324fa86..000000000 --- a/packages/toolkit-core/test/fixtures/search-syntax/invalid_numeric_aggregate_filter.json +++ /dev/null @@ -1,15 +0,0 @@ -[ - { - "query": "min(measurements.size):3s", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "freeText", - "quoted": false, - "value": "min(measurements.size):3s", - "invalid": null - }, - {"type": "spaces", "value": ""} - ] - } -] diff --git a/packages/toolkit-core/test/fixtures/search-syntax/invalid_numeric_fields.json b/packages/toolkit-core/test/fixtures/search-syntax/invalid_numeric_fields.json deleted file mode 100644 index e9db488c9..000000000 --- a/packages/toolkit-core/test/fixtures/search-syntax/invalid_numeric_fields.json +++ /dev/null @@ -1,122 +0,0 @@ -[ - { - "query": "project.id:one", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "text", - "negated": false, - "invalid": { - "type": "invalid-number", - "reason": "Invalid number. Expected number then optional k, m, or b suffix (e.g. 500k)", - "expectedType": ["numeric", "numericIn"] - }, - "key": {"type": "keySimple", "value": "project.id", "quoted": false}, - "operator": "", - "value": { - "type": "valueText", - "value": "one", - "quoted": false - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "issue.id:two", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "text", - "negated": false, - "invalid": { - "type": "invalid-number", - "reason": "Invalid number. Expected number then optional k, m, or b suffix (e.g. 500k)", - "expectedType": ["numeric", "numericIn"] - }, - "key": {"type": "keySimple", "value": "issue.id", "quoted": false}, - "operator": "", - "value": { - "type": "valueText", - "value": "two", - "quoted": false - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "transaction.duration:>hotdog", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "text", - "negated": false, - "invalid": { - "type": "invalid-duration", - "reason": "Invalid duration. Expected number followed by duration unit suffix", - "expectedType": ["duration"] - }, - "key": {"type": "keySimple", "value": "transaction.duration", "quoted": false}, - "operator": "", - "value": { - "type": "valueText", - "value": ">hotdog", - "quoted": false - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "measurements.lcp:>hotdog", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "text", - "negated": false, - "invalid": { - "type": "invalid-duration", - "reason": "Invalid duration. Expected number followed by duration unit suffix", - "expectedType": ["duration"] - }, - "key": {"type": "keySimple", "value": "measurements.lcp", "quoted": false}, - "operator": "", - "value": { - "type": "valueText", - "value": ">hotdog", - "quoted": false - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "spans.db:>hotdog", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "text", - "negated": false, - "invalid": { - "type": "invalid-duration", - "reason": "Invalid duration. Expected number followed by duration unit suffix", - "expectedType": ["duration"] - }, - "key": {"type": "keySimple", "value": "spans.db", "quoted": false}, - "operator": "", - "value": { - "type": "valueText", - "value": ">hotdog", - "quoted": false - } - }, - {"type": "spaces", "value": ""} - ] - } -] diff --git a/packages/toolkit-core/test/fixtures/search-syntax/invalid_numeric_shorthand.json b/packages/toolkit-core/test/fixtures/search-syntax/invalid_numeric_shorthand.json deleted file mode 100644 index a9f37cda5..000000000 --- a/packages/toolkit-core/test/fixtures/search-syntax/invalid_numeric_shorthand.json +++ /dev/null @@ -1,26 +0,0 @@ -[ - { - "query": "stack.colno:>3s", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "text", - "negated": false, - "invalid": { - "type": "invalid-number", - "reason": "Invalid number. Expected number then optional k, m, or b suffix (e.g. 500k)", - "expectedType": ["numeric", "numericIn"] - }, - "key": {"type": "keySimple", "value": "stack.colno", "quoted": false}, - "operator": "", - "value": { - "type": "valueText", - "value": ">3s", - "quoted": false - } - }, - {"type": "spaces", "value": ""} - ] - } -] diff --git a/packages/toolkit-core/test/fixtures/search-syntax/multiple_quotes.json b/packages/toolkit-core/test/fixtures/search-syntax/multiple_quotes.json deleted file mode 100644 index 264d9ebe6..000000000 --- a/packages/toolkit-core/test/fixtures/search-syntax/multiple_quotes.json +++ /dev/null @@ -1,66 +0,0 @@ -[ - { - "query": "device.family:\"\" browser.name:\"Chrome\"", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "text", - "negated": false, - "key": {"type": "keySimple", "value": "device.family", "quoted": false}, - "operator": "", - "value": { - "type": "valueText", - "value": "", - "quoted": true - } - }, - {"type": "spaces", "value": " "}, - { - "type": "filter", - "filter": "text", - "negated": false, - "key": {"type": "keySimple", "value": "browser.name", "quoted": false}, - "operator": "", - "value": { - "type": "valueText", - "value": "Chrome", - "quoted": true - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "device.family:\"\\\"\" browser.name:\"Chrome\"", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "text", - "negated": false, - "key": {"type": "keySimple", "value": "device.family", "quoted": false}, - "operator": "", - "value": { - "type": "valueText", - "value": "\\\"", - "quoted": true - } - }, - {"type": "spaces", "value": " "}, - { - "type": "filter", - "filter": "text", - "negated": false, - "key": {"type": "keySimple", "value": "browser.name", "quoted": false}, - "operator": "", - "value": { - "type": "valueText", - "value": "Chrome", - "quoted": true - } - }, - {"type": "spaces", "value": ""} - ] - } -] diff --git a/packages/toolkit-core/test/fixtures/search-syntax/negated_duration_on_non_duration_field.json b/packages/toolkit-core/test/fixtures/search-syntax/negated_duration_on_non_duration_field.json deleted file mode 100644 index fe60ce7c8..000000000 --- a/packages/toolkit-core/test/fixtures/search-syntax/negated_duration_on_non_duration_field.json +++ /dev/null @@ -1,21 +0,0 @@ -[ - { - "query": "!user.id:500s", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "text", - "negated": true, - "key": {"type": "keySimple", "value": "user.id", "quoted": false}, - "operator": "", - "value": { - "type": "valueText", - "value": "500s", - "quoted": false - } - }, - {"type": "spaces", "value": ""} - ] - } -] diff --git a/packages/toolkit-core/test/fixtures/search-syntax/negated_on_boolean_values_and_non_boolean_field.json b/packages/toolkit-core/test/fixtures/search-syntax/negated_on_boolean_values_and_non_boolean_field.json deleted file mode 100644 index dd1e0abf0..000000000 --- a/packages/toolkit-core/test/fixtures/search-syntax/negated_on_boolean_values_and_non_boolean_field.json +++ /dev/null @@ -1,40 +0,0 @@ -[ - { - "query": "!user.id:true", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "text", - "negated": true, - "key": {"type": "keySimple", "value": "user.id", "quoted": false}, - "operator": "", - "value": { - "type": "valueText", - "value": "true", - "quoted": false - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "!user.id:1", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "text", - "negated": true, - "key": {"type": "keySimple", "value": "user.id", "quoted": false}, - "operator": "", - "value": { - "type": "valueText", - "value": "1", - "quoted": false - } - }, - {"type": "spaces", "value": ""} - ] - } -] diff --git a/packages/toolkit-core/test/fixtures/search-syntax/newline_outside_quote.json b/packages/toolkit-core/test/fixtures/search-syntax/newline_outside_quote.json deleted file mode 100644 index a6c28f9d5..000000000 --- a/packages/toolkit-core/test/fixtures/search-syntax/newline_outside_quote.json +++ /dev/null @@ -1 +0,0 @@ -[{"query": "release:a\nrelease", "raisesError": true, "result": []}] diff --git a/packages/toolkit-core/test/fixtures/search-syntax/newline_within_quote.json b/packages/toolkit-core/test/fixtures/search-syntax/newline_within_quote.json deleted file mode 100644 index 6676d3e89..000000000 --- a/packages/toolkit-core/test/fixtures/search-syntax/newline_within_quote.json +++ /dev/null @@ -1,21 +0,0 @@ -[ - { - "query": "release:\"a\nrelease\"", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "text", - "negated": false, - "key": {"type": "keySimple", "value": "release", "quoted": false}, - "operator": "", - "value": { - "type": "valueText", - "value": "a\nrelease", - "quoted": true - } - }, - {"type": "spaces", "value": ""} - ] - } -] diff --git a/packages/toolkit-core/test/fixtures/search-syntax/not_has_tag.json b/packages/toolkit-core/test/fixtures/search-syntax/not_has_tag.json deleted file mode 100644 index 7427d4324..000000000 --- a/packages/toolkit-core/test/fixtures/search-syntax/not_has_tag.json +++ /dev/null @@ -1,42 +0,0 @@ -[ - { - "desc": "unquoted key", - "query": "!has:release", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "has", - "negated": true, - "key": {"type": "keySimple", "value": "has", "quoted": false}, - "operator": "", - "value": { - "type": "valueText", - "value": "release", - "quoted": false - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "desc": "quoted key", - "query": "!has:\"hi:there\"", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "has", - "negated": true, - "key": {"type": "keySimple", "value": "has", "quoted": false}, - "operator": "", - "value": { - "type": "valueText", - "value": "hi:there", - "quoted": true - } - }, - {"type": "spaces", "value": ""} - ] - } -] diff --git a/packages/toolkit-core/test/fixtures/search-syntax/numeric_aggregate_measurements_filter.json b/packages/toolkit-core/test/fixtures/search-syntax/numeric_aggregate_measurements_filter.json deleted file mode 100644 index 3ca68cec0..000000000 --- a/packages/toolkit-core/test/fixtures/search-syntax/numeric_aggregate_measurements_filter.json +++ /dev/null @@ -1,192 +0,0 @@ -[ - { - "query": "min(measurements.size):3.1415", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "aggregateNumeric", - "negated": false, - "key": { - "type": "keyAggregate", - "name": {"type": "keySimple", "value": "min", "quoted": false}, - "args": { - "type": "keyAggregateArgs", - "args": [ - { - "separator": "", - "value": { - "type": "keyAggregateParam", - "value": "measurements.size", - "quoted": false - } - } - ] - }, - "argsSpaceBefore": {"type": "spaces", "value": ""}, - "argsSpaceAfter": {"type": "spaces", "value": ""} - }, - "operator": "", - "value": { - "type": "valueNumber", - "value": "3.1415", - "unit": null, - "parsed": {"value": 3.1415} - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "min(measurements.size):>3.1415", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "aggregateNumeric", - "negated": false, - "key": { - "type": "keyAggregate", - "name": {"type": "keySimple", "value": "min", "quoted": false}, - "args": { - "type": "keyAggregateArgs", - "args": [ - { - "separator": "", - "value": { - "type": "keyAggregateParam", - "value": "measurements.size", - "quoted": false - } - } - ] - }, - "argsSpaceBefore": {"type": "spaces", "value": ""}, - "argsSpaceAfter": {"type": "spaces", "value": ""} - }, - "operator": ">", - "value": { - "type": "valueNumber", - "value": "3.1415", - "unit": null, - "parsed": {"value": 3.1415} - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "min(measurements.size):<3.1415", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "aggregateNumeric", - "negated": false, - "key": { - "type": "keyAggregate", - "name": {"type": "keySimple", "value": "min", "quoted": false}, - "args": { - "type": "keyAggregateArgs", - "args": [ - { - "separator": "", - "value": { - "type": "keyAggregateParam", - "value": "measurements.size", - "quoted": false - } - } - ] - }, - "argsSpaceBefore": {"type": "spaces", "value": ""}, - "argsSpaceAfter": {"type": "spaces", "value": ""} - }, - "operator": "<", - "value": { - "type": "valueNumber", - "value": "3.1415", - "unit": null, - "parsed": {"value": 3.1415} - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "min(measurements.size):<3k", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "aggregateNumeric", - "negated": false, - "key": { - "type": "keyAggregate", - "name": {"type": "keySimple", "value": "min", "quoted": false}, - "args": { - "type": "keyAggregateArgs", - "args": [ - { - "separator": "", - "value": { - "type": "keyAggregateParam", - "value": "measurements.size", - "quoted": false - } - } - ] - }, - "argsSpaceBefore": {"type": "spaces", "value": ""}, - "argsSpaceAfter": {"type": "spaces", "value": ""} - }, - "operator": "<", - "value": { - "type": "valueNumber", - "value": "3", - "unit": "k", - "parsed": {"value": 3000} - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "min(measurements.size):2m", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "aggregateNumeric", - "negated": false, - "key": { - "type": "keyAggregate", - "name": {"type": "keySimple", "value": "min", "quoted": false}, - "args": { - "type": "keyAggregateArgs", - "args": [ - { - "separator": "", - "value": { - "type": "keyAggregateParam", - "value": "measurements.size", - "quoted": false - } - } - ] - }, - "argsSpaceBefore": {"type": "spaces", "value": ""}, - "argsSpaceAfter": {"type": "spaces", "value": ""} - }, - "operator": "", - "value": { - "type": "valueNumber", - "value": "2", - "unit": "m", - "parsed": {"value": 2000000} - } - }, - {"type": "spaces", "value": ""} - ] - } -] diff --git a/packages/toolkit-core/test/fixtures/search-syntax/numeric_aggregate_op_breakdowns_filter.json b/packages/toolkit-core/test/fixtures/search-syntax/numeric_aggregate_op_breakdowns_filter.json deleted file mode 100644 index e5ebdc673..000000000 --- a/packages/toolkit-core/test/fixtures/search-syntax/numeric_aggregate_op_breakdowns_filter.json +++ /dev/null @@ -1,283 +0,0 @@ -[ - { - "query": "min(spans.browser):3.1415", - "result": [ - { - "type": "spaces", - "value": "" - }, - { - "type": "filter", - "filter": "aggregateNumeric", - "negated": false, - "key": { - "type": "keyAggregate", - "name": { - "type": "keySimple", - "value": "min", - "quoted": false - }, - "args": { - "type": "keyAggregateArgs", - "args": [ - { - "separator": "", - "value": { - "type": "keyAggregateParam", - "value": "spans.browser", - "quoted": false - } - } - ] - }, - "argsSpaceBefore": { - "type": "spaces", - "value": "" - }, - "argsSpaceAfter": { - "type": "spaces", - "value": "" - } - }, - "operator": "", - "value": { - "type": "valueNumber", - "value": "3.1415", - "unit": null, - "parsed": { - "value": 3.1415 - } - } - }, - { - "type": "spaces", - "value": "" - } - ] - }, - { - "query": "min(spans.browser):>3.1415", - "result": [ - { - "type": "spaces", - "value": "" - }, - { - "type": "filter", - "filter": "aggregateNumeric", - "negated": false, - "key": { - "type": "keyAggregate", - "name": { - "type": "keySimple", - "value": "min", - "quoted": false - }, - "args": { - "type": "keyAggregateArgs", - "args": [ - { - "separator": "", - "value": { - "type": "keyAggregateParam", - "value": "spans.browser", - "quoted": false - } - } - ] - }, - "argsSpaceBefore": { - "type": "spaces", - "value": "" - }, - "argsSpaceAfter": { - "type": "spaces", - "value": "" - } - }, - "operator": ">", - "value": { - "type": "valueNumber", - "value": "3.1415", - "unit": null, - "parsed": { - "value": 3.1415 - } - } - }, - { - "type": "spaces", - "value": "" - } - ] - }, - { - "query": "min(spans.browser):<3.1415", - "result": [ - { - "type": "spaces", - "value": "" - }, - { - "type": "filter", - "filter": "aggregateNumeric", - "negated": false, - "key": { - "type": "keyAggregate", - "name": { - "type": "keySimple", - "value": "min", - "quoted": false - }, - "args": { - "type": "keyAggregateArgs", - "args": [ - { - "separator": "", - "value": { - "type": "keyAggregateParam", - "value": "spans.browser", - "quoted": false - } - } - ] - }, - "argsSpaceBefore": { - "type": "spaces", - "value": "" - }, - "argsSpaceAfter": { - "type": "spaces", - "value": "" - } - }, - "operator": "<", - "value": { - "type": "valueNumber", - "value": "3.1415", - "unit": null, - "parsed": { - "value": 3.1415 - } - } - }, - { - "type": "spaces", - "value": "" - } - ] - }, - { - "query": "min(spans.browser):<3k", - "result": [ - { - "type": "spaces", - "value": "" - }, - { - "type": "filter", - "filter": "aggregateNumeric", - "negated": false, - "key": { - "type": "keyAggregate", - "name": { - "type": "keySimple", - "value": "min", - "quoted": false - }, - "args": { - "type": "keyAggregateArgs", - "args": [ - { - "separator": "", - "value": { - "type": "keyAggregateParam", - "value": "spans.browser", - "quoted": false - } - } - ] - }, - "argsSpaceBefore": { - "type": "spaces", - "value": "" - }, - "argsSpaceAfter": { - "type": "spaces", - "value": "" - } - }, - "operator": "<", - "value": { - "type": "valueNumber", - "value": "3", - "unit": "k", - "parsed": { - "value": 3000 - } - } - }, - { - "type": "spaces", - "value": "" - } - ] - }, - { - "query": "min(spans.browser):2m", - "desc": "XXX: Questionable if this should actually be parsed as a duration? This is how it was written when moved from the original python test", - "result": [ - { - "type": "spaces", - "value": "" - }, - { - "type": "filter", - "filter": "aggregateDuration", - "negated": false, - "key": { - "type": "keyAggregate", - "name": { - "type": "keySimple", - "value": "min", - "quoted": false - }, - "args": { - "type": "keyAggregateArgs", - "args": [ - { - "separator": "", - "value": { - "type": "keyAggregateParam", - "value": "spans.browser", - "quoted": false - } - } - ] - }, - "argsSpaceBefore": { - "type": "spaces", - "value": "" - }, - "argsSpaceAfter": { - "type": "spaces", - "value": "" - } - }, - "operator": "", - "value": { - "type": "valueDuration", - "value": "2", - "unit": "m", - "parsed": { - "value": 120000 - } - } - }, - { - "type": "spaces", - "value": "" - } - ] - } -] diff --git a/packages/toolkit-core/test/fixtures/search-syntax/numeric_filter.json b/packages/toolkit-core/test/fixtures/search-syntax/numeric_filter.json deleted file mode 100644 index 2cacb8028..000000000 --- a/packages/toolkit-core/test/fixtures/search-syntax/numeric_filter.json +++ /dev/null @@ -1,121 +0,0 @@ -[ - { - "desc": "Numeric format should still return a string if field isn't allowed", - "query": "random_field:>500", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "text", - "negated": false, - "key": {"type": "keySimple", "value": "random_field", "quoted": false}, - "operator": "", - "value": { - "type": "valueText", - "value": ">500", - "quoted": false - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "desc": "Numeric format should not negate operator if field isn't allowed", - "query": "!random_field:>500", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "text", - "negated": true, - "key": {"type": "keySimple", "value": "random_field", "quoted": false}, - "operator": "", - "value": { - "type": "valueText", - "value": ">500", - "quoted": false - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "!random_field:500", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "text", - "negated": true, - "key": {"type": "keySimple", "value": "random_field", "quoted": false}, - "operator": "", - "value": { - "type": "valueText", - "value": "500", - "quoted": false - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "project_id:-500", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "numeric", - "negated": false, - "key": {"type": "keySimple", "value": "project_id", "quoted": false}, - "operator": "", - "value": { - "type": "valueNumber", - "value": "-500", - "unit": null, - "parsed": {"value": -500} - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "!issue.id:500", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "numeric", - "negated": true, - "key": {"type": "keySimple", "value": "issue.id", "quoted": false}, - "operator": "", - "value": { - "type": "valueNumber", - "value": "500", - "unit": null, - "parsed": {"value": 500} - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "issue.id:<500", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "numeric", - "negated": false, - "key": {"type": "keySimple", "value": "issue.id", "quoted": false}, - "operator": "<", - "value": { - "type": "valueNumber", - "value": "500", - "unit": null, - "parsed": {"value": 500} - } - }, - {"type": "spaces", "value": ""} - ] - } -] diff --git a/packages/toolkit-core/test/fixtures/search-syntax/numeric_filter_with_decimals.json b/packages/toolkit-core/test/fixtures/search-syntax/numeric_filter_with_decimals.json deleted file mode 100644 index cfb71dd76..000000000 --- a/packages/toolkit-core/test/fixtures/search-syntax/numeric_filter_with_decimals.json +++ /dev/null @@ -1,24 +0,0 @@ -[ - { - "query": "transaction.duration:>3.1415", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "numeric", - "negated": false, - "key": {"type": "keySimple", "value": "transaction.duration", "quoted": false}, - "operator": ">", - "value": { - "type": "valueNumber", - "value": "3.1415", - "unit": null, - "parsed": { - "value": 3.1415 - } - } - }, - {"type": "spaces", "value": ""} - ] - } -] diff --git a/packages/toolkit-core/test/fixtures/search-syntax/numeric_filter_with_shorthand.json b/packages/toolkit-core/test/fixtures/search-syntax/numeric_filter_with_shorthand.json deleted file mode 100644 index 9a8865d78..000000000 --- a/packages/toolkit-core/test/fixtures/search-syntax/numeric_filter_with_shorthand.json +++ /dev/null @@ -1,62 +0,0 @@ -[ - { - "query": "stack.colno:>3k", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "numeric", - "negated": false, - "key": {"type": "keySimple", "value": "stack.colno", "quoted": false}, - "operator": ">", - "value": { - "type": "valueNumber", - "value": "3", - "unit": "k", - "parsed": {"value": 3000} - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "stack.colno:>3m", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "numeric", - "negated": false, - "key": {"type": "keySimple", "value": "stack.colno", "quoted": false}, - "operator": ">", - "value": { - "type": "valueNumber", - "value": "3", - "unit": "m", - "parsed": {"value": 3000000} - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "stack.colno:>3b", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "numeric", - "negated": false, - "key": {"type": "keySimple", "value": "stack.colno", "quoted": false}, - "operator": ">", - "value": { - "type": "valueNumber", - "value": "3", - "unit": "b", - "parsed": {"value": 3000000000} - } - }, - {"type": "spaces", "value": ""} - ] - } -] diff --git a/packages/toolkit-core/test/fixtures/search-syntax/numeric_in_filter.json b/packages/toolkit-core/test/fixtures/search-syntax/numeric_in_filter.json deleted file mode 100644 index b28347160..000000000 --- a/packages/toolkit-core/test/fixtures/search-syntax/numeric_in_filter.json +++ /dev/null @@ -1,414 +0,0 @@ -[ - { - "query": "project_id:[500,501,502]", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "numericIn", - "negated": false, - "key": {"type": "keySimple", "value": "project_id", "quoted": false}, - "operator": "", - "value": { - "type": "valueNumberList", - "items": [ - { - "separator": "", - "value": { - "type": "valueNumber", - "value": "500", - "unit": null, - "parsed": { - "value": 500 - } - } - }, - { - "separator": ",", - "value": { - "type": "valueNumber", - "value": "501", - "unit": null, - "parsed": { - "value": 501 - } - } - }, - { - "separator": ",", - "value": { - "type": "valueNumber", - "value": "502", - "unit": null, - "parsed": { - "value": 502 - } - } - } - ] - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "project_id:[500, 501, 502]", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "numericIn", - "negated": false, - "key": {"type": "keySimple", "value": "project_id", "quoted": false}, - "operator": "", - "value": { - "type": "valueNumberList", - "items": [ - { - "separator": "", - "value": { - "type": "valueNumber", - "value": "500", - "unit": null, - "parsed": { - "value": 500 - } - } - }, - { - "separator": ", ", - "value": { - "type": "valueNumber", - "value": "501", - "unit": null, - "parsed": { - "value": 501 - } - } - }, - { - "separator": ", ", - "value": { - "type": "valueNumber", - "value": "502", - "unit": null, - "parsed": { - "value": 502 - } - } - } - ] - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "project_id:[500, 501 ,502]", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "numericIn", - "negated": false, - "key": {"type": "keySimple", "value": "project_id", "quoted": false}, - "operator": "", - "value": { - "type": "valueNumberList", - "items": [ - { - "separator": "", - "value": { - "type": "valueNumber", - "value": "500", - "unit": null, - "parsed": { - "value": 500 - } - } - }, - { - "separator": ", ", - "value": { - "type": "valueNumber", - "value": "501", - "unit": null, - "parsed": { - "value": 501 - } - } - }, - { - "separator": " ,", - "value": { - "type": "valueNumber", - "value": "502", - "unit": null, - "parsed": { - "value": 502 - } - } - } - ] - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "project_id:[500,501,502] issue.id:[100]", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "numericIn", - "negated": false, - "key": {"type": "keySimple", "value": "project_id", "quoted": false}, - "operator": "", - "value": { - "type": "valueNumberList", - "items": [ - { - "separator": "", - "value": { - "type": "valueNumber", - "value": "500", - "unit": null, - "parsed": { - "value": 500 - } - } - }, - { - "separator": ",", - "value": { - "type": "valueNumber", - "value": "501", - "unit": null, - "parsed": { - "value": 501 - } - } - }, - { - "separator": ",", - "value": { - "type": "valueNumber", - "value": "502", - "unit": null, - "parsed": { - "value": 502 - } - } - } - ] - } - }, - {"type": "spaces", "value": " "}, - { - "type": "filter", - "filter": "numericIn", - "negated": false, - "key": {"type": "keySimple", "value": "issue.id", "quoted": false}, - "operator": "", - "value": { - "type": "valueNumberList", - "items": [ - { - "separator": "", - "value": { - "type": "valueNumber", - "value": "100", - "unit": null, - "parsed": { - "value": 100 - } - } - } - ] - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "desc": "Numeric format should still return a string if field isn't allowed", - "query": "project_id:[500,501,502] random_field:[500,501,502]", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "numericIn", - "negated": false, - "key": {"type": "keySimple", "value": "project_id", "quoted": false}, - "operator": "", - "value": { - "type": "valueNumberList", - "items": [ - { - "separator": "", - "value": { - "type": "valueNumber", - "value": "500", - "unit": null, - "parsed": { - "value": 500 - } - } - }, - { - "separator": ",", - "value": { - "type": "valueNumber", - "value": "501", - "unit": null, - "parsed": { - "value": 501 - } - } - }, - { - "separator": ",", - "value": { - "type": "valueNumber", - "value": "502", - "unit": null, - "parsed": { - "value": 502 - } - } - } - ] - } - }, - {"type": "spaces", "value": " "}, - { - "type": "filter", - "filter": "textIn", - "negated": false, - "key": {"type": "keySimple", "value": "random_field", "quoted": false}, - "operator": "", - "value": { - "type": "valueTextList", - "items": [ - { - "separator": "", - "value": { - "type": "valueText", - "value": "500", - "quoted": false - } - }, - { - "separator": ",", - "value": { - "type": "valueText", - "value": "501", - "quoted": false - } - }, - { - "separator": ",", - "value": { - "type": "valueText", - "value": "502", - "quoted": false - } - } - ] - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "project_id:[500,501,]", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "numericIn", - "invalid": { - "type": "empty-value-in-list-not-allowed", - "reason": "Lists should not have empty values" - }, - "negated": false, - "key": {"type": "keySimple", "value": "project_id", "quoted": false}, - "operator": "", - "value": { - "type": "valueNumberList", - "items": [ - { - "separator": "", - "value": { - "type": "valueNumber", - "value": "500", - "unit": null, - "parsed": { - "value": 500 - } - } - }, - { - "separator": ",", - "value": { - "type": "valueNumber", - "value": "501", - "unit": null, - "parsed": { - "value": 501 - } - } - }, - { - "separator": ",", - "value": null - } - ] - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "!project_id:[500,501]", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "numericIn", - "negated": true, - "key": {"type": "keySimple", "value": "project_id", "quoted": false}, - "operator": "", - "value": { - "type": "valueNumberList", - "items": [ - { - "separator": "", - "value": { - "type": "valueNumber", - "value": "500", - "unit": null, - "parsed": { - "value": 500 - } - } - }, - { - "separator": ",", - "value": { - "type": "valueNumber", - "value": "501", - "unit": null, - "parsed": { - "value": 501 - } - } - } - ] - } - }, - {"type": "spaces", "value": ""} - ] - } -] diff --git a/packages/toolkit-core/test/fixtures/search-syntax/numeric_measurements_filter.json b/packages/toolkit-core/test/fixtures/search-syntax/numeric_measurements_filter.json deleted file mode 100644 index aaa5465ff..000000000 --- a/packages/toolkit-core/test/fixtures/search-syntax/numeric_measurements_filter.json +++ /dev/null @@ -1,68 +0,0 @@ -[ - { - "query": "measurements.size:3.1415", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "numeric", - "negated": false, - "key": {"type": "keySimple", "value": "measurements.size", "quoted": false}, - "operator": "", - "value": { - "type": "valueNumber", - "value": "3.1415", - "unit": null, - "parsed": { - "value": 3.1415 - } - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "measurements.size:>3.1415", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "numeric", - "negated": false, - "key": {"type": "keySimple", "value": "measurements.size", "quoted": false}, - "operator": ">", - "value": { - "type": "valueNumber", - "value": "3.1415", - "unit": null, - "parsed": { - "value": 3.1415 - } - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "measurements.size:<3.1415", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "numeric", - "negated": false, - "key": {"type": "keySimple", "value": "measurements.size", "quoted": false}, - "operator": "<", - "value": { - "type": "valueNumber", - "value": "3.1415", - "unit": null, - "parsed": { - "value": 3.1415 - } - } - }, - {"type": "spaces", "value": ""} - ] - } -] diff --git a/packages/toolkit-core/test/fixtures/search-syntax/other_dates.json b/packages/toolkit-core/test/fixtures/search-syntax/other_dates.json deleted file mode 100644 index ac822f052..000000000 --- a/packages/toolkit-core/test/fixtures/search-syntax/other_dates.json +++ /dev/null @@ -1,66 +0,0 @@ -[ - { - "desc": "test date format with other name", - "query": "timestamp:>2015-05-18", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "date", - "negated": false, - "key": {"type": "keySimple", "value": "timestamp", "quoted": false}, - "operator": ">", - "value": { - "type": "valueIso8601Date", - "value": "2015-05-18", - "parsed": {"value": "2015-05-18T00:00:00.000Z"}, - "date": "2015-05-18", - "time": null, - "tz": null - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "timestamp.to_hour:>2018-01-01T05:06:07+00:00", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "date", - "negated": false, - "key": {"type": "keySimple", "value": "timestamp.to_hour", "quoted": false}, - "operator": ">", - "value": { - "type": "valueIso8601Date", - "value": "2018-01-01T05:06:07+00:00", - "parsed": {"value": "2018-01-01T05:06:07.000Z"}, - "date": "2018-01-01", - "time": "05:06:07", - "tz": "+00:00" - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "random:>2015-05-18", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "text", - "negated": false, - "key": {"type": "keySimple", "value": "random", "quoted": false}, - "operator": "", - "value": { - "type": "valueText", - "value": ">2015-05-18", - "quoted": false - } - }, - {"type": "spaces", "value": ""} - ] - } -] diff --git a/packages/toolkit-core/test/fixtures/search-syntax/quoted_free_text_search_anywhere.json b/packages/toolkit-core/test/fixtures/search-syntax/quoted_free_text_search_anywhere.json deleted file mode 100644 index 7022c0446..000000000 --- a/packages/toolkit-core/test/fixtures/search-syntax/quoted_free_text_search_anywhere.json +++ /dev/null @@ -1,41 +0,0 @@ -[ - { - "query": "\"hello there\" user.email:foo@example.com \"general kenobi\"", - "result": [ - {"type": "spaces", "value": ""}, - {"type": "freeText", "value": "hello there", "quoted": true, "invalid": null}, - {"type": "spaces", "value": " "}, - { - "type": "filter", - "filter": "text", - "negated": false, - "key": {"type": "keySimple", "value": "user.email", "quoted": false}, - "operator": "", - "value": { - "type": "valueText", - "value": "foo@example.com", - "quoted": false - } - }, - {"type": "spaces", "value": " "}, - {"type": "freeText", "value": "general kenobi", "quoted": true, "invalid": null}, - {"type": "spaces", "value": ""} - ] - }, - { - "query": " \" hello \" ", - "result": [ - {"type": "spaces", "value": " "}, - {"type": "freeText", "value": " hello ", "quoted": true, "invalid": null}, - {"type": "spaces", "value": " "} - ] - }, - { - "query": " \" he\\\"llo \" ", - "result": [ - {"type": "spaces", "value": " "}, - {"type": "freeText", "value": " he\\\"llo ", "quoted": true, "invalid": null}, - {"type": "spaces", "value": " "} - ] - } -] diff --git a/packages/toolkit-core/test/fixtures/search-syntax/quoted_key.json b/packages/toolkit-core/test/fixtures/search-syntax/quoted_key.json deleted file mode 100644 index 89e8ffa82..000000000 --- a/packages/toolkit-core/test/fixtures/search-syntax/quoted_key.json +++ /dev/null @@ -1,40 +0,0 @@ -[ - { - "query": "\"hi:there\":value", - "result": [ - {"type": "spaces", "value": ""}, - { - "filter": "text", - "negated": false, - "key": {"quoted": true, "type": "keySimple", "value": "hi:there"}, - "operator": "", - "type": "filter", - "value": { - "quoted": false, - "type": "valueText", - "value": "value" - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "!\"hi:there\":value", - "result": [ - {"type": "spaces", "value": ""}, - { - "filter": "text", - "negated": true, - "key": {"quoted": true, "type": "keySimple", "value": "hi:there"}, - "operator": "", - "type": "filter", - "value": { - "quoted": false, - "type": "valueText", - "value": "value" - } - }, - {"type": "spaces", "value": ""} - ] - } -] diff --git a/packages/toolkit-core/test/fixtures/search-syntax/quoted_val.json b/packages/toolkit-core/test/fixtures/search-syntax/quoted_val.json deleted file mode 100644 index fb7271381..000000000 --- a/packages/toolkit-core/test/fixtures/search-syntax/quoted_val.json +++ /dev/null @@ -1,228 +0,0 @@ -[ - { - "query": "release:\"a release\"", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "text", - "negated": false, - "key": {"type": "keySimple", "value": "release", "quoted": false}, - "operator": "", - "value": { - "type": "valueText", - "value": "a release", - "quoted": true - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "!release:\"a release\"", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "text", - "negated": true, - "key": {"type": "keySimple", "value": "release", "quoted": false}, - "operator": "", - "value": { - "type": "valueText", - "value": "a release", - "quoted": true - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "release:[\"a release\"]", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "textIn", - "negated": false, - "key": {"type": "keySimple", "value": "release", "quoted": false}, - "operator": "", - "value": { - "type": "valueTextList", - "items": [ - { - "separator": "", - "value": { - "type": "valueText", - "value": "a release", - "quoted": true - } - } - ] - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "release:[\"a release\",\"b release\"]", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "textIn", - "negated": false, - "key": {"type": "keySimple", "value": "release", "quoted": false}, - "operator": "", - "value": { - "type": "valueTextList", - "items": [ - { - "separator": "", - "value": { - "type": "valueText", - "value": "a release", - "quoted": true - } - }, - { - "separator": ",", - "value": { - "type": "valueText", - "value": "b release", - "quoted": true - } - } - ] - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "release:[\"a release\", \"b release\", \"c release\"]", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "textIn", - "negated": false, - "key": {"type": "keySimple", "value": "release", "quoted": false}, - "operator": "", - "value": { - "type": "valueTextList", - "items": [ - { - "separator": "", - "value": { - "type": "valueText", - "value": "a release", - "quoted": true - } - }, - { - "separator": ", ", - "value": { - "type": "valueText", - "value": "b release", - "quoted": true - } - }, - { - "separator": ", ", - "value": { - "type": "valueText", - "value": "c release", - "quoted": true - } - } - ] - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "!release:[\"a release\",\"b release\"]", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "textIn", - "negated": true, - "key": {"type": "keySimple", "value": "release", "quoted": false}, - "operator": "", - "value": { - "type": "valueTextList", - "items": [ - { - "separator": "", - "value": { - "type": "valueText", - "value": "a release", - "quoted": true - } - }, - { - "separator": ",", - "value": { - "type": "valueText", - "value": "b release", - "quoted": true - } - } - ] - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "release:[\"a release\"] hello:[\"123\"]", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "textIn", - "negated": false, - "key": {"type": "keySimple", "value": "release", "quoted": false}, - "operator": "", - "value": { - "type": "valueTextList", - "items": [ - { - "separator": "", - "value": { - "type": "valueText", - "value": "a release", - "quoted": true - } - } - ] - } - }, - {"type": "spaces", "value": " "}, - { - "type": "filter", - "filter": "textIn", - "negated": false, - "key": {"type": "keySimple", "value": "hello", "quoted": false}, - "operator": "", - "value": { - "type": "valueTextList", - "items": [ - { - "separator": "", - "value": { - "type": "valueText", - "value": "123", - "quoted": true - } - } - ] - } - }, - {"type": "spaces", "value": ""} - ] - } -] diff --git a/packages/toolkit-core/test/fixtures/search-syntax/quotes_filtered_on_raw.json b/packages/toolkit-core/test/fixtures/search-syntax/quotes_filtered_on_raw.json deleted file mode 100644 index e67139289..000000000 --- a/packages/toolkit-core/test/fixtures/search-syntax/quotes_filtered_on_raw.json +++ /dev/null @@ -1,111 +0,0 @@ -[ - { - "desc": "Enclose the full raw query? Strip it.", - "query": "thinger:unknown \"what is this?\"", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "text", - "negated": false, - "key": {"type": "keySimple", "value": "thinger", "quoted": false}, - "operator": "", - "value": { - "type": "valueText", - "value": "unknown", - "quoted": false - } - }, - {"type": "spaces", "value": " "}, - {"type": "freeText", "value": "what is this?", "quoted": true, "invalid": null}, - {"type": "spaces", "value": ""} - ] - }, - { - "desc": "Enclose the full query? Strip it and the whole query is raw.", - "query": "\"thinger:unknown what is this?\"", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "freeText", - "value": "thinger:unknown what is this?", - "quoted": true, - "invalid": null - }, - {"type": "spaces", "value": ""} - ] - }, - { - "desc": "Allow a single quotation at end", - "query": "end\"", - "result": [ - {"type": "spaces", "value": ""}, - {"type": "freeText", "value": "end\"", "quoted": false, "invalid": null}, - {"type": "spaces", "value": ""} - ] - }, - { - "desc": "Allow a single quotation at beginning", - "query": "\"beginning", - "result": [ - {"type": "spaces", "value": ""}, - {"type": "freeText", "value": "\"beginning", "quoted": false, "invalid": null}, - {"type": "spaces", "value": ""} - ] - }, - { - "desc": "Allow a single quotation", - "query": "\"", - "result": [ - {"type": "spaces", "value": ""}, - {"type": "freeText", "value": "\"", "quoted": false, "invalid": null}, - {"type": "spaces", "value": ""} - ] - }, - { - "desc": "Empty quotations become a dropped term", - "query": "\"\"", - "result": [ - {"type": "spaces", "value": ""}, - {"type": "freeText", "value": "", "quoted": true, "invalid": null}, - {"type": "spaces", "value": ""} - ] - }, - { - "desc": "Allow a search for space", - "query": "\" \"", - "result": [ - {"type": "spaces", "value": ""}, - {"type": "freeText", "value": " ", "quoted": true, "invalid": null}, - {"type": "spaces", "value": ""} - ] - }, - { - "desc": "Strip in a balanced manner", - "query": "\"\"woof\"", - "result": [ - {"type": "spaces", "value": ""}, - {"type": "freeText", "value": "", "quoted": true, "invalid": null}, - {"type": "spaces", "value": ""}, - {"type": "freeText", "value": "woof\"", "quoted": false, "invalid": null}, - {"type": "spaces", "value": ""} - ] - }, - { - "desc": "Don't try this at home kids", - "query": "\"\"\"\"\"\"\"\"\"", - "result": [ - {"type": "spaces", "value": ""}, - {"type": "freeText", "value": "", "quoted": true, "invalid": null}, - {"type": "spaces", "value": ""}, - {"type": "freeText", "value": "", "quoted": true, "invalid": null}, - {"type": "spaces", "value": ""}, - {"type": "freeText", "value": "", "quoted": true, "invalid": null}, - {"type": "spaces", "value": ""}, - {"type": "freeText", "value": "", "quoted": true, "invalid": null}, - {"type": "spaces", "value": ""}, - {"type": "freeText", "value": "\"", "quoted": false, "invalid": null}, - {"type": "spaces", "value": ""} - ] - } -] diff --git a/packages/toolkit-core/test/fixtures/search-syntax/regex_empty_pattern.json b/packages/toolkit-core/test/fixtures/search-syntax/regex_empty_pattern.json deleted file mode 100644 index 499958c55..000000000 --- a/packages/toolkit-core/test/fixtures/search-syntax/regex_empty_pattern.json +++ /dev/null @@ -1,84 +0,0 @@ -[ - { - "desc": "An empty pattern is flagged rather than searched for", - "query": "message:////", - "additionalConfig": { - "allowRegex": true - }, - "result": [ - { - "type": "spaces", - "value": "" - }, - { - "type": "filter", - "filter": "text", - "key": { - "type": "keySimple", - "value": "message", - "quoted": false - }, - "value": { - "type": "valueText", - "value": "", - "quoted": false - }, - "negated": false, - "operator": "//", - "invalid": { - "type": "filter-must-have-value", - "reason": "Filter must have a value" - } - }, - { - "type": "spaces", - "value": "" - } - ] - }, - { - "desc": "An empty pattern on an array membership key is flagged too", - "query": "tags[csv_headers[*],array]:////", - "additionalConfig": { - "allowRegex": true - }, - "result": [ - { - "type": "spaces", - "value": "" - }, - { - "type": "filter", - "filter": "arrayIncludes", - "key": { - "type": "keyArrayIncludes", - "key": { - "type": "keyExplicitArrayTag", - "prefix": "tags", - "key": { - "type": "keySimple", - "value": "csv_headers", - "quoted": false - } - }, - "index": "*" - }, - "value": { - "type": "valueText", - "value": "", - "quoted": false - }, - "negated": false, - "operator": "//", - "invalid": { - "type": "filter-must-have-value", - "reason": "Filter must have a value" - } - }, - { - "type": "spaces", - "value": "" - } - ] - } -] diff --git a/packages/toolkit-core/test/fixtures/search-syntax/regex_filter_as_literal.json b/packages/toolkit-core/test/fixtures/search-syntax/regex_filter_as_literal.json deleted file mode 100644 index f44c5ebc0..000000000 --- a/packages/toolkit-core/test/fixtures/search-syntax/regex_filter_as_literal.json +++ /dev/null @@ -1,41 +0,0 @@ -[ - { - "query": "message://GET (api) v2// level:error", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "text", - "negated": false, - "key": {"type": "keySimple", "value": "message", "quoted": false}, - "operator": "", - "value": {"type": "valueText", "value": "//GET (api) v2//", "quoted": false} - }, - {"type": "spaces", "value": " "}, - { - "type": "filter", - "filter": "text", - "negated": false, - "key": {"type": "keySimple", "value": "level", "quoted": false}, - "operator": "", - "value": {"type": "valueText", "value": "error", "quoted": false} - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "!message://a//b//", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "text", - "negated": true, - "key": {"type": "keySimple", "value": "message", "quoted": false}, - "operator": "", - "value": {"type": "valueText", "value": "//a//b//", "quoted": false} - }, - {"type": "spaces", "value": ""} - ] - } -] diff --git a/packages/toolkit-core/test/fixtures/search-syntax/regex_operator.json b/packages/toolkit-core/test/fixtures/search-syntax/regex_operator.json deleted file mode 100644 index c6dfbe329..000000000 --- a/packages/toolkit-core/test/fixtures/search-syntax/regex_operator.json +++ /dev/null @@ -1,411 +0,0 @@ -[ - { - "desc": "Spaces and parens need no quoting inside a pattern", - "query": "message://GET (api) v2//", - "additionalConfig": { - "allowRegex": true - }, - "result": [ - { - "type": "spaces", - "value": "" - }, - { - "type": "filter", - "filter": "text", - "key": { - "type": "keySimple", - "value": "message", - "quoted": false - }, - "value": { - "type": "valueText", - "value": "GET (api) v2", - "quoted": false - }, - "negated": false, - "operator": "//" - }, - { - "type": "spaces", - "value": "" - } - ] - }, - { - "desc": "A leading ! negates the whole regex filter", - "query": "!message://^a.*b//", - "additionalConfig": { - "allowRegex": true - }, - "result": [ - { - "type": "spaces", - "value": "" - }, - { - "type": "filter", - "filter": "text", - "key": { - "type": "keySimple", - "value": "message", - "quoted": false - }, - "value": { - "type": "valueText", - "value": "^a.*b", - "quoted": false - }, - "negated": true, - "operator": "//" - }, - { - "type": "spaces", - "value": "" - } - ] - }, - { - "desc": "The pattern runs to the first // that ends the value, so inner // are literal", - "query": "message://a//b//", - "additionalConfig": { - "allowRegex": true - }, - "result": [ - { - "type": "spaces", - "value": "" - }, - { - "type": "filter", - "filter": "text", - "key": { - "type": "keySimple", - "value": "message", - "quoted": false - }, - "value": { - "type": "valueText", - "value": "a//b", - "quoted": false - }, - "negated": false, - "operator": "//" - }, - { - "type": "spaces", - "value": "" - } - ] - }, - { - "desc": "A space after the closing // ends the pattern", - "query": "message://a// level:error", - "additionalConfig": { - "allowRegex": true - }, - "result": [ - { - "type": "spaces", - "value": "" - }, - { - "type": "filter", - "filter": "text", - "key": { - "type": "keySimple", - "value": "message", - "quoted": false - }, - "value": { - "type": "valueText", - "value": "a", - "quoted": false - }, - "negated": false, - "operator": "//" - }, - { - "type": "spaces", - "value": " " - }, - { - "type": "filter", - "filter": "text", - "key": { - "type": "keySimple", - "value": "level", - "quoted": false - }, - "value": { - "type": "valueText", - "value": "error", - "quoted": false - }, - "negated": false, - "operator": "" - }, - { - "type": "spaces", - "value": "" - } - ] - }, - { - "desc": "Array membership keys accept a pattern", - "query": "tags[csv_headers[*],array]://^a b//", - "additionalConfig": { - "allowRegex": true - }, - "result": [ - { - "type": "spaces", - "value": "" - }, - { - "type": "filter", - "filter": "arrayIncludes", - "key": { - "type": "keyArrayIncludes", - "key": { - "type": "keyExplicitArrayTag", - "prefix": "tags", - "key": { - "type": "keySimple", - "value": "csv_headers", - "quoted": false - } - }, - "index": "*" - }, - "value": { - "type": "valueText", - "value": "^a b", - "quoted": false - }, - "negated": false, - "operator": "//" - }, - { - "type": "spaces", - "value": "" - } - ] - }, - { - "desc": "A quoted //...// stays a literal value", - "query": "message:\"//a//\"", - "additionalConfig": { - "allowRegex": true - }, - "result": [ - { - "type": "spaces", - "value": "" - }, - { - "type": "filter", - "filter": "text", - "key": { - "type": "keySimple", - "value": "message", - "quoted": false - }, - "value": { - "type": "valueText", - "value": "//a//", - "quoted": true - }, - "negated": false, - "operator": "" - }, - { - "type": "spaces", - "value": "" - } - ] - }, - { - "desc": "Without a terminator after the closing //, the value stays literal", - "query": "message://a b//x", - "additionalConfig": { - "allowRegex": true - }, - "result": [ - { - "type": "spaces", - "value": "" - }, - { - "type": "filter", - "filter": "text", - "key": { - "type": "keySimple", - "value": "message", - "quoted": false - }, - "value": { - "type": "valueText", - "value": "//a", - "quoted": false - }, - "negated": false, - "operator": "" - }, - { - "type": "spaces", - "value": " " - }, - { - "type": "freeText", - "value": "b//x", - "quoted": false, - "invalid": null - }, - { - "type": "spaces", - "value": "" - } - ] - }, - { - "desc": "A pattern at the length limit is accepted", - "query": "message://aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa//", - "additionalConfig": { - "allowRegex": true - }, - "result": [ - { - "type": "spaces", - "value": "" - }, - { - "type": "filter", - "filter": "text", - "key": { - "type": "keySimple", - "value": "message", - "quoted": false - }, - "value": { - "type": "valueText", - "value": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", - "quoted": false - }, - "negated": false, - "operator": "//" - }, - { - "type": "spaces", - "value": "" - } - ] - }, - { - "desc": "A pattern over the length limit is rejected", - "query": "message://aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa//", - "additionalConfig": { - "allowRegex": true - }, - "result": [ - { - "type": "spaces", - "value": "" - }, - { - "type": "filter", - "filter": "text", - "key": { - "type": "keySimple", - "value": "message", - "quoted": false - }, - "value": { - "type": "valueText", - "value": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", - "quoted": false - }, - "negated": false, - "operator": "//", - "invalid": { - "type": "regex-pattern-too-long", - "reason": "Regex patterns are limited to 64 characters. To search for a literal value that starts with //, quote it: \"//...\"" - } - }, - { - "type": "spaces", - "value": "" - } - ] - }, - { - "desc": "A pattern within the length limit when each escape sequence counts as one character is accepted", - "query": "message://^(https?:\\/\\/)?(www\\.)?([a-zA-Z0-9-]+)(\\.[a-zA-Z]{2,})(\\/[^\\s]*)?$//", - "additionalConfig": { - "allowRegex": true - }, - "result": [ - { - "type": "spaces", - "value": "" - }, - { - "type": "filter", - "filter": "text", - "key": { - "type": "keySimple", - "value": "message", - "quoted": false - }, - "value": { - "type": "valueText", - "value": "^(https?:\\/\\/)?(www\\.)?([a-zA-Z0-9-]+)(\\.[a-zA-Z]{2,})(\\/[^\\s]*)?$", - "quoted": false - }, - "negated": false, - "operator": "//" - }, - { - "type": "spaces", - "value": "" - } - ] - }, - { - "desc": "A pattern over the length limit when each escape sequence counts as one character is rejected", - "query": "message://\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.//", - "additionalConfig": { - "allowRegex": true - }, - "result": [ - { - "type": "spaces", - "value": "" - }, - { - "type": "filter", - "filter": "text", - "key": { - "type": "keySimple", - "value": "message", - "quoted": false - }, - "value": { - "type": "valueText", - "value": "\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.", - "quoted": false - }, - "negated": false, - "operator": "//", - "invalid": { - "type": "regex-pattern-too-long", - "reason": "Regex patterns are limited to 64 characters. To search for a literal value that starts with //, quote it: \"//...\"" - } - }, - { - "type": "spaces", - "value": "" - } - ] - } -] diff --git a/packages/toolkit-core/test/fixtures/search-syntax/rel_time_filter.json b/packages/toolkit-core/test/fixtures/search-syntax/rel_time_filter.json deleted file mode 100644 index 2ba3dfc22..000000000 --- a/packages/toolkit-core/test/fixtures/search-syntax/rel_time_filter.json +++ /dev/null @@ -1,97 +0,0 @@ -[ - { - "query": "firstSeen:+7d", - "result": [ - { - "type": "spaces", - "value": "" - }, - { - "type": "filter", - "filter": "relativeDate", - "negated": false, - "key": { - "type": "keySimple", - "value": "firstSeen", - "quoted": false - }, - "operator": "", - "value": { - "type": "valueRelativeDate", - "value": "7", - "sign": "+", - "unit": "d", - "parsed": { - "value": "2017-10-24T02:41:20.000Z" - } - } - }, - { - "type": "spaces", - "value": "" - } - ] - }, - { - "query": "firstSeen:-2w", - "result": [ - { - "type": "spaces", - "value": "" - }, - { - "type": "filter", - "filter": "relativeDate", - "negated": false, - "key": { - "type": "keySimple", - "value": "firstSeen", - "quoted": false - }, - "operator": "", - "value": { - "type": "valueRelativeDate", - "value": "2", - "sign": "-", - "unit": "w", - "parsed": { - "value": "2017-10-03T02:41:20.000Z" - } - } - }, - { - "type": "spaces", - "value": "" - } - ] - }, - { - "query": "random:-2w", - "result": [ - { - "type": "spaces", - "value": "" - }, - { - "type": "filter", - "filter": "text", - "negated": false, - "key": { - "type": "keySimple", - "value": "random", - "quoted": false - }, - "operator": "", - "value": { - "type": "valueText", - "value": "-2w", - "quoted": false - } - }, - { - "type": "spaces", - "value": "" - } - ] - } -] diff --git a/packages/toolkit-core/test/fixtures/search-syntax/semver.json b/packages/toolkit-core/test/fixtures/search-syntax/semver.json deleted file mode 100644 index 5f210b6fd..000000000 --- a/packages/toolkit-core/test/fixtures/search-syntax/semver.json +++ /dev/null @@ -1,78 +0,0 @@ -[ - { - "query": "release.version:>1.2.3", - "result": [ - {"type": "spaces", "value": ""}, - { - "filter": "text", - "key": {"quoted": false, "type": "keySimple", "value": "release.version"}, - "negated": false, - "operator": ">", - "type": "filter", - "value": { - "quoted": false, - "type": "valueText", - "value": "1.2.3" - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "release.version:>1.2.3-hi", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "text", - "key": {"quoted": false, "type": "keySimple", "value": "release.version"}, - "negated": false, - "operator": ">", - "value": { - "quoted": false, - "type": "valueText", - "value": "1.2.3-hi" - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "release.version:>=1.2.3-hi", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "text", - "key": {"quoted": false, "type": "keySimple", "value": "release.version"}, - "negated": false, - "operator": ">=", - "value": { - "quoted": false, - "type": "valueText", - "value": "1.2.3-hi" - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "release.version:1.2.3-hi", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "text", - "key": {"quoted": false, "type": "keySimple", "value": "release.version"}, - "negated": false, - "operator": "", - "value": { - "quoted": false, - "type": "valueText", - "value": "1.2.3-hi" - } - }, - {"type": "spaces", "value": ""} - ] - } -] diff --git a/packages/toolkit-core/test/fixtures/search-syntax/simple.json b/packages/toolkit-core/test/fixtures/search-syntax/simple.json deleted file mode 100644 index e3642011a..000000000 --- a/packages/toolkit-core/test/fixtures/search-syntax/simple.json +++ /dev/null @@ -1,71 +0,0 @@ -[ - { - "desc": "test with raw search query at the end", - "query": "user.email:foo@example.com release:1.2.1 hello", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "text", - "negated": false, - "key": {"type": "keySimple", "value": "user.email", "quoted": false}, - "operator": "", - "value": { - "type": "valueText", - "value": "foo@example.com", - "quoted": false - } - }, - {"type": "spaces", "value": " "}, - { - "type": "filter", - "filter": "text", - "negated": false, - "key": {"type": "keySimple", "value": "release", "quoted": false}, - "operator": "", - "value": { - "type": "valueText", - "value": "1.2.1", - "quoted": false - } - }, - {"type": "spaces", "value": " "}, - {"type": "freeText", "value": "hello", "quoted": false, "invalid": null}, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "hello user.email:foo@example.com release:1.2.1", - "result": [ - {"type": "spaces", "value": ""}, - {"type": "freeText", "value": "hello ", "quoted": false, "invalid": null}, - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "text", - "negated": false, - "key": {"type": "keySimple", "value": "user.email", "quoted": false}, - "operator": "", - "value": { - "type": "valueText", - "value": "foo@example.com", - "quoted": false - } - }, - {"type": "spaces", "value": " "}, - { - "type": "filter", - "filter": "text", - "negated": false, - "key": {"type": "keySimple", "value": "release", "quoted": false}, - "operator": "", - "value": { - "type": "valueText", - "value": "1.2.1", - "quoted": false - } - }, - {"type": "spaces", "value": ""} - ] - } -] diff --git a/packages/toolkit-core/test/fixtures/search-syntax/simple_in.json b/packages/toolkit-core/test/fixtures/search-syntax/simple_in.json deleted file mode 100644 index c94f00aed..000000000 --- a/packages/toolkit-core/test/fixtures/search-syntax/simple_in.json +++ /dev/null @@ -1,496 +0,0 @@ -[ - { - "query": "user.email:[test@test.com] test:[hello]", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "textIn", - "negated": false, - "key": {"type": "keySimple", "value": "user.email", "quoted": false}, - "operator": "", - "value": { - "type": "valueTextList", - "items": [ - { - "separator": "", - "value": { - "type": "valueText", - "value": "test@test.com", - "quoted": false - } - } - ] - } - }, - {"type": "spaces", "value": " "}, - { - "type": "filter", - "filter": "textIn", - "negated": false, - "key": {"type": "keySimple", "value": "test", "quoted": false}, - "operator": "", - "value": { - "type": "valueTextList", - "items": [ - { - "separator": "", - "value": { - "type": "valueText", - "value": "hello", - "quoted": false - } - } - ] - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "user.email:[test@test.com,test2@test.com,test3@test.com] test:[hello]", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "textIn", - "negated": false, - "key": {"type": "keySimple", "value": "user.email", "quoted": false}, - "operator": "", - "value": { - "type": "valueTextList", - "items": [ - { - "separator": "", - "value": { - "type": "valueText", - "value": "test@test.com", - "quoted": false - } - }, - { - "separator": ",", - "value": { - "type": "valueText", - "value": "test2@test.com", - "quoted": false - } - }, - { - "separator": ",", - "value": { - "type": "valueText", - "value": "test3@test.com", - "quoted": false - } - } - ] - } - }, - {"type": "spaces", "value": " "}, - { - "type": "filter", - "filter": "textIn", - "negated": false, - "key": {"type": "keySimple", "value": "test", "quoted": false}, - "operator": "", - "value": { - "type": "valueTextList", - "items": [ - { - "separator": "", - "value": { - "type": "valueText", - "value": "hello", - "quoted": false - } - } - ] - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "!user.email:[test@test.com, test@test2.com, test@test3.com] test:[hello]", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "textIn", - "negated": true, - "key": {"type": "keySimple", "value": "user.email", "quoted": false}, - "operator": "", - "value": { - "type": "valueTextList", - "items": [ - { - "separator": "", - "value": { - "type": "valueText", - "value": "test@test.com", - "quoted": false - } - }, - { - "separator": ", ", - "value": { - "type": "valueText", - "value": "test@test2.com", - "quoted": false - } - }, - { - "separator": ", ", - "value": { - "type": "valueText", - "value": "test@test3.com", - "quoted": false - } - } - ] - } - }, - {"type": "spaces", "value": " "}, - { - "type": "filter", - "filter": "textIn", - "negated": false, - "key": {"type": "keySimple", "value": "test", "quoted": false}, - "operator": "", - "value": { - "type": "valueTextList", - "items": [ - { - "separator": "", - "value": { - "type": "valueText", - "value": "hello", - "quoted": false - } - } - ] - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "test:h[e]llo]", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "text", - "negated": false, - "key": {"type": "keySimple", "value": "test", "quoted": false}, - "operator": "", - "value": { - "type": "valueText", - "value": "h[e]llo]", - "quoted": false - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "test:[h[e]llo", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "text", - "negated": false, - "key": {"type": "keySimple", "value": "test", "quoted": false}, - "operator": "", - "value": { - "type": "valueText", - "value": "[h[e]llo", - "quoted": false - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "test:\"[h]\"", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "text", - "negated": false, - "key": {"type": "keySimple", "value": "test", "quoted": false}, - "operator": "", - "value": { - "type": "valueText", - "value": "[h]", - "quoted": true - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "test:[h]*", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "text", - "negated": false, - "key": {"type": "keySimple", "value": "test", "quoted": false}, - "operator": "", - "value": { - "type": "valueText", - "value": "[h]*", - "quoted": false - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "test:[h e]", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "text", - "negated": false, - "key": {"type": "keySimple", "value": "test", "quoted": false}, - "operator": "", - "value": { - "type": "valueText", - "value": "[h", - "quoted": false - } - }, - {"type": "spaces", "value": " "}, - {"type": "freeText", "value": "e]", "quoted": false, "invalid": null}, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "test:[]", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "text", - "negated": false, - "key": {"type": "keySimple", "value": "test", "quoted": false}, - "operator": "", - "value": { - "type": "valueText", - "value": "[]", - "quoted": false - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "user.email:[test@test.com, \"hi\", 1]", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "textIn", - "negated": false, - "key": {"type": "keySimple", "value": "user.email", "quoted": false}, - "operator": "", - "value": { - "type": "valueTextList", - "items": [ - { - "separator": "", - "value": { - "type": "valueText", - "value": "test@test.com", - "quoted": false - } - }, - { - "separator": ", ", - "value": { - "type": "valueText", - "value": "hi", - "quoted": true - } - }, - { - "separator": ", ", - "value": { - "type": "valueText", - "value": "1", - "quoted": false - } - } - ] - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "user.email:[test@test.com, \"hi\", 1.0]", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "textIn", - "negated": false, - "key": {"type": "keySimple", "value": "user.email", "quoted": false}, - "operator": "", - "value": { - "type": "valueTextList", - "items": [ - { - "separator": "", - "value": { - "type": "valueText", - "value": "test@test.com", - "quoted": false - } - }, - { - "separator": ", ", - "value": { - "type": "valueText", - "value": "hi", - "quoted": true - } - }, - { - "separator": ", ", - "value": { - "type": "valueText", - "value": "1.0", - "quoted": false - } - } - ] - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "test:[[h]]", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "textIn", - "negated": false, - "key": {"type": "keySimple", "value": "test", "quoted": false}, - "operator": "", - "value": { - "type": "valueTextList", - "items": [ - { - "separator": "", - "value": { - "type": "valueText", - "value": "[h]", - "quoted": false - } - } - ] - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "test:[a, [h]]", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "textIn", - "negated": false, - "key": {"type": "keySimple", "value": "test", "quoted": false}, - "operator": "", - "value": { - "type": "valueTextList", - "items": [ - { - "separator": "", - "value": { - "type": "valueText", - "value": "a", - "quoted": false - } - }, - { - "separator": ", ", - "value": { - "type": "valueText", - "value": "[h]", - "quoted": false - } - } - ] - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "user.email:[test@test.com]user.email:hello@hello.com", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "text", - "negated": false, - "key": {"type": "keySimple", "value": "user.email", "quoted": false}, - "operator": "", - "value": { - "type": "valueText", - "value": "[test@test.com]user.email:hello@hello.com", - "quoted": false - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "user.email:[test@test.com, ]", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "textIn", - "invalid": { - "type": "empty-value-in-list-not-allowed", - "reason": "Lists should not have empty values" - }, - "negated": false, - "key": {"type": "keySimple", "value": "user.email", "quoted": false}, - "operator": "", - "value": { - "type": "valueTextList", - "items": [ - { - "separator": "", - "value": { - "type": "valueText", - "value": "test@test.com", - "quoted": false - } - }, - { - "separator": ", ", - "value": null - } - ] - } - }, - {"type": "spaces", "value": ""} - ] - } -] diff --git a/packages/toolkit-core/test/fixtures/search-syntax/sooo_many_quotes.json b/packages/toolkit-core/test/fixtures/search-syntax/sooo_many_quotes.json deleted file mode 100644 index 368151deb..000000000 --- a/packages/toolkit-core/test/fixtures/search-syntax/sooo_many_quotes.json +++ /dev/null @@ -1,21 +0,0 @@ -[ - { - "query": "device.family:\"\\\"\\\"\\\"\\\"\\\"\\\"\\\"\\\"\\\"\\\"\"", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "text", - "negated": false, - "key": {"type": "keySimple", "value": "device.family", "quoted": false}, - "operator": "", - "value": { - "type": "valueText", - "value": "\\\"\\\"\\\"\\\"\\\"\\\"\\\"\\\"\\\"\\\"", - "quoted": true - } - }, - {"type": "spaces", "value": ""} - ] - } -] diff --git a/packages/toolkit-core/test/fixtures/search-syntax/special_character_params.json b/packages/toolkit-core/test/fixtures/search-syntax/special_character_params.json deleted file mode 100644 index f3e1b11de..000000000 --- a/packages/toolkit-core/test/fixtures/search-syntax/special_character_params.json +++ /dev/null @@ -1,173 +0,0 @@ -[ - { - "query": "count_if(user.email,equals,test+something@example.com):>100", - "result": [ - { - "type": "spaces", - "value": "" - }, - { - "type": "filter", - "filter": "aggregateNumeric", - "negated": false, - "key": { - "type": "keyAggregate", - "name": {"type": "keySimple", "value": "count_if", "quoted": false}, - "args": { - "type": "keyAggregateArgs", - "args": [ - { - "separator": "", - "value": { - "type": "keyAggregateParam", - "value": "user.email", - "quoted": false - } - }, - { - "separator": ",", - "value": { - "type": "keyAggregateParam", - "value": "equals", - "quoted": false - } - }, - { - "separator": ",", - "value": { - "type": "keyAggregateParam", - "value": "test+something@example.com", - "quoted": false - } - } - ] - }, - "argsSpaceBefore": {"type": "spaces", "value": ""}, - "argsSpaceAfter": {"type": "spaces", "value": ""} - }, - "operator": ">", - "value": { - "type": "valueNumber", - "unit": null, - "value": "100", - "parsed": {"value": 100} - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "count_if(user.email,equals,\"something,with,commas\"):>100", - "result": [ - { - "type": "spaces", - "value": "" - }, - { - "type": "filter", - "filter": "aggregateNumeric", - "negated": false, - "key": { - "type": "keyAggregate", - "name": {"type": "keySimple", "value": "count_if", "quoted": false}, - "args": { - "type": "keyAggregateArgs", - "args": [ - { - "separator": "", - "value": { - "type": "keyAggregateParam", - "value": "user.email", - "quoted": false - } - }, - { - "separator": ",", - "value": { - "type": "keyAggregateParam", - "value": "equals", - "quoted": false - } - }, - { - "separator": ",", - "value": { - "type": "keyAggregateParam", - "value": "\"something,with,commas\"", - "quoted": true - } - } - ] - }, - "argsSpaceBefore": {"type": "spaces", "value": ""}, - "argsSpaceAfter": {"type": "spaces", "value": ""} - }, - "operator": ">", - "value": { - "type": "valueNumber", - "unit": null, - "value": "100", - "parsed": {"value": 100} - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "count_if(user.email,equals,\"I, got my own \\\"quotes\\\"\"):>100", - "result": [ - { - "type": "spaces", - "value": "" - }, - { - "type": "filter", - "filter": "aggregateNumeric", - "negated": false, - "key": { - "type": "keyAggregate", - "name": {"type": "keySimple", "value": "count_if", "quoted": false}, - "args": { - "type": "keyAggregateArgs", - "args": [ - { - "separator": "", - "value": { - "type": "keyAggregateParam", - "value": "user.email", - "quoted": false - } - }, - { - "separator": ",", - "value": { - "type": "keyAggregateParam", - "value": "equals", - "quoted": false - } - }, - { - "separator": ",", - "value": { - "type": "keyAggregateParam", - "value": "\"I, got my own \\\"quotes\\\"\"", - "quoted": true - } - } - ] - }, - "argsSpaceBefore": {"type": "spaces", "value": ""}, - "argsSpaceAfter": {"type": "spaces", "value": ""} - }, - "operator": ">", - "value": { - "type": "valueNumber", - "unit": null, - "value": "100", - "parsed": {"value": 100} - } - }, - {"type": "spaces", "value": ""} - ] - } -] diff --git a/packages/toolkit-core/test/fixtures/search-syntax/specific_time_filter.json b/packages/toolkit-core/test/fixtures/search-syntax/specific_time_filter.json deleted file mode 100644 index ad18fd476..000000000 --- a/packages/toolkit-core/test/fixtures/search-syntax/specific_time_filter.json +++ /dev/null @@ -1,131 +0,0 @@ -[ - { - "query": "firstSeen:2018-01-01", - "result": [ - { - "type": "spaces", - "value": "" - }, - { - "type": "filter", - "filter": "specificDate", - "negated": false, - "key": { - "type": "keySimple", - "value": "firstSeen", - "quoted": false - }, - "operator": "", - "value": { - "type": "valueIso8601Date", - "value": "2018-01-01", - "parsed": {"value": "2018-01-01T00:00:00.000Z"}, - "date": "2018-01-01", - "time": null, - "tz": null - } - }, - { - "type": "spaces", - "value": "" - } - ] - }, - { - "query": "lastSeen:2018-01-01T05:06:07Z", - "result": [ - { - "type": "spaces", - "value": "" - }, - { - "type": "filter", - "filter": "specificDate", - "negated": false, - "key": { - "type": "keySimple", - "value": "lastSeen", - "quoted": false - }, - "operator": "", - "value": { - "type": "valueIso8601Date", - "value": "2018-01-01T05:06:07Z", - "parsed": { - "value": "2018-01-01T05:06:07.000Z" - }, - "date": "2018-01-01", - "time": "05:06:07", - "tz": "Z" - } - }, - { - "type": "spaces", - "value": "" - } - ] - }, - { - "query": "firstSeen:2018-01-01T05:06:07+00:00", - "result": [ - { - "type": "spaces", - "value": "" - }, - { - "type": "filter", - "filter": "specificDate", - "negated": false, - "key": { - "type": "keySimple", - "value": "firstSeen", - "quoted": false - }, - "operator": "", - "value": { - "type": "valueIso8601Date", - "value": "2018-01-01T05:06:07+00:00", - "parsed": { - "value": "2018-01-01T05:06:07.000Z" - }, - "date": "2018-01-01", - "time": "05:06:07", - "tz": "+00:00" - } - }, - { - "type": "spaces", - "value": "" - } - ] - }, - { - "query": "random:2018-01-01T05:06:07", - "result": [ - { - "type": "spaces", - "value": "" - }, - { - "type": "filter", - "filter": "text", - "negated": false, - "key": { - "type": "keySimple", - "value": "random", - "quoted": false - }, - "operator": "", - "value": { - "type": "valueText", - "value": "2018-01-01T05:06:07", - "quoted": false - } - }, - { - "type": "spaces", - "value": "" - } - ] - } -] diff --git a/packages/toolkit-core/test/fixtures/search-syntax/starts_with_operator.json b/packages/toolkit-core/test/fixtures/search-syntax/starts_with_operator.json deleted file mode 100644 index 913534d24..000000000 --- a/packages/toolkit-core/test/fixtures/search-syntax/starts_with_operator.json +++ /dev/null @@ -1,86 +0,0 @@ -[ - { - "query": "browser.name:StartsWithfirefox", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "text", - "negated": false, - "operator": "StartsWith", - "key": {"type": "keySimple", "value": "browser.name", "quoted": false}, - "value": {"type": "valueText", "value": "firefox", "quoted": false} - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "browser.name:StartsWith[firefox, chrome]", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "textIn", - "negated": false, - "operator": "StartsWith", - "key": {"type": "keySimple", "value": "browser.name", "quoted": false}, - "value": { - "type": "valueTextList", - "items": [ - { - "separator": "", - "value": {"type": "valueText", "value": "firefox", "quoted": false} - }, - { - "separator": ", ", - "value": {"type": "valueText", "value": "chrome", "quoted": false} - } - ] - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "!browser.name:StartsWithfirefox", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "text", - "negated": true, - "operator": "StartsWith", - "key": {"type": "keySimple", "value": "browser.name", "quoted": false}, - "value": {"type": "valueText", "value": "firefox", "quoted": false} - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "!browser.name:StartsWith[firefox, chrome]", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "textIn", - "negated": true, - "operator": "StartsWith", - "key": {"type": "keySimple", "value": "browser.name", "quoted": false}, - "value": { - "type": "valueTextList", - "items": [ - { - "separator": "", - "value": {"type": "valueText", "value": "firefox", "quoted": false} - }, - { - "separator": ", ", - "value": {"type": "valueText", "value": "chrome", "quoted": false} - } - ] - } - }, - {"type": "spaces", "value": ""} - ] - } -] diff --git a/packages/toolkit-core/test/fixtures/search-syntax/supported_tags.json b/packages/toolkit-core/test/fixtures/search-syntax/supported_tags.json deleted file mode 100644 index c35b4fe2f..000000000 --- a/packages/toolkit-core/test/fixtures/search-syntax/supported_tags.json +++ /dev/null @@ -1,97 +0,0 @@ -[ - { - "desc": "test with unsupported text field", - "query": "browser:\"chrome\" os:*windows*", - "additionalConfig": { - "validateKeys": true, - "supportedTags": { - "browser": { - "key": "browser", - "kind": "field" - } - } - }, - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "text", - "negated": false, - "key": {"type": "keySimple", "value": "browser", "quoted": false}, - "operator": "", - "value": { - "type": "valueText", - "value": "chrome", - "quoted": true - } - }, - {"type": "spaces", "value": " "}, - { - "type": "filter", - "filter": "text", - "negated": false, - "invalid": { - "type": "invalid-key", - "reason": "Invalid key. \"os\" is not a supported search key." - }, - "key": {"type": "keySimple", "value": "os", "quoted": false}, - "operator": "", - "value": { - "type": "valueText", - "value": "*windows*", - "quoted": false - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "desc": "test with unsupported numeric field", - "query": "browser:\"chrome\" transaction.duration:>0", - "additionalConfig": { - "validateKeys": true, - "supportedTags": { - "browser": { - "key": "browser", - "kind": "field" - } - } - }, - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "text", - "negated": false, - "key": {"type": "keySimple", "value": "browser", "quoted": false}, - "operator": "", - "value": { - "type": "valueText", - "value": "chrome", - "quoted": true - } - }, - {"type": "spaces", "value": " "}, - { - "type": "filter", - "filter": "numeric", - "negated": false, - "invalid": { - "type": "invalid-key", - "reason": "Invalid key. \"transaction.duration\" is not a supported search key." - }, - "key": {"type": "keySimple", "value": "transaction.duration", "quoted": false}, - "operator": ">", - "value": { - "type": "valueNumber", - "value": "0", - "unit": null, - "parsed": { - "value": 0 - } - } - }, - {"type": "spaces", "value": ""} - ] - } -] diff --git a/packages/toolkit-core/test/fixtures/search-syntax/tab_outside_quote.json b/packages/toolkit-core/test/fixtures/search-syntax/tab_outside_quote.json deleted file mode 100644 index 47cb8b903..000000000 --- a/packages/toolkit-core/test/fixtures/search-syntax/tab_outside_quote.json +++ /dev/null @@ -1,24 +0,0 @@ -[ - { - "desc": "tab outside quote", - "query": "release:a\trelease", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "text", - "negated": false, - "key": {"type": "keySimple", "value": "release", "quoted": false}, - "operator": "", - "value": { - "type": "valueText", - "value": "a", - "quoted": false - } - }, - {"type": "spaces", "value": ""}, - {"quoted": false, "type": "freeText", "value": "\trelease", "invalid": null}, - {"type": "spaces", "value": ""} - ] - } -] diff --git a/packages/toolkit-core/test/fixtures/search-syntax/tab_within_quote.json b/packages/toolkit-core/test/fixtures/search-syntax/tab_within_quote.json deleted file mode 100644 index d5ed0ed67..000000000 --- a/packages/toolkit-core/test/fixtures/search-syntax/tab_within_quote.json +++ /dev/null @@ -1,21 +0,0 @@ -[ - { - "query": "release:\"a\trelease\"", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "text", - "negated": false, - "key": {"type": "keySimple", "value": "release", "quoted": false}, - "operator": "", - "value": { - "type": "valueText", - "value": "a\trelease", - "quoted": true - } - }, - {"type": "spaces", "value": ""} - ] - } -] diff --git a/packages/toolkit-core/test/fixtures/search-syntax/timestamp.json b/packages/toolkit-core/test/fixtures/search-syntax/timestamp.json deleted file mode 100644 index 8e0176c74..000000000 --- a/packages/toolkit-core/test/fixtures/search-syntax/timestamp.json +++ /dev/null @@ -1,94 +0,0 @@ -[ - { - "desc": "test date format", - "query": "timestamp:>2015-05-18", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "date", - "negated": false, - "key": {"type": "keySimple", "value": "timestamp", "quoted": false}, - "operator": ">", - "value": { - "type": "valueIso8601Date", - "value": "2015-05-18", - "parsed": {"value": "2015-05-18T00:00:00.000Z"}, - "date": "2015-05-18", - "time": null, - "tz": null - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "desc": "test date time format", - "query": "timestamp:>2015-05-18T10:15:01", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "date", - "negated": false, - "key": {"type": "keySimple", "value": "timestamp", "quoted": false}, - "operator": ">", - "value": { - "type": "valueIso8601Date", - "value": "2015-05-18T10:15:01", - "parsed": {"value": "2015-05-18T10:15:01.000Z"}, - "date": "2015-05-18", - "time": "10:15:01", - "tz": null - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "desc": "test date time format w microseconds", - "query": "timestamp:>2015-05-18T10:15:01.103", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "date", - "negated": false, - "key": {"type": "keySimple", "value": "timestamp", "quoted": false}, - "operator": ">", - "value": { - "type": "valueIso8601Date", - "value": "2015-05-18T10:15:01.103", - "parsed": {"value": "2015-05-18T10:15:01.103Z"}, - "date": "2015-05-18", - "time": "10:15:01.103", - "tz": null - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "desc": "test date time format w microseconds and utc marker", - "query": "timestamp:>2015-05-18T10:15:01.103Z", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "date", - "negated": false, - "key": {"type": "keySimple", "value": "timestamp", "quoted": false}, - "operator": ">", - "value": { - "type": "valueIso8601Date", - "value": "2015-05-18T10:15:01.103Z", - "parsed": {"value": "2015-05-18T10:15:01.103Z"}, - "date": "2015-05-18", - "time": "10:15:01.103", - "tz": "Z" - } - }, - {"type": "spaces", "value": ""} - ] - } -] diff --git a/packages/toolkit-core/test/fixtures/search-syntax/timestamp_rollup.json b/packages/toolkit-core/test/fixtures/search-syntax/timestamp_rollup.json deleted file mode 100644 index 66211b15d..000000000 --- a/packages/toolkit-core/test/fixtures/search-syntax/timestamp_rollup.json +++ /dev/null @@ -1,24 +0,0 @@ -[ - { - "query": "timestamp.to_hour:2018-01-01T05:06:07+00:00", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "specificDate", - "negated": false, - "key": {"type": "keySimple", "value": "timestamp.to_hour", "quoted": false}, - "operator": "", - "value": { - "type": "valueIso8601Date", - "value": "2018-01-01T05:06:07+00:00", - "parsed": {"value": "2018-01-01T05:06:07.000Z"}, - "date": "2018-01-01", - "time": "05:06:07", - "tz": "+00:00" - } - }, - {"type": "spaces", "value": ""} - ] - } -] diff --git a/packages/toolkit-core/test/fixtures/search-syntax/trailing_quote_value.json b/packages/toolkit-core/test/fixtures/search-syntax/trailing_quote_value.json deleted file mode 100644 index ebaf191d9..000000000 --- a/packages/toolkit-core/test/fixtures/search-syntax/trailing_quote_value.json +++ /dev/null @@ -1,120 +0,0 @@ -[ - { - "query": "device.family:\"test", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "text", - "negated": false, - "invalid": { - "type": "must-be-quoted", - "reason": "Quotes must enclose text or be escaped" - }, - "key": {"type": "keySimple", "value": "device.family", "quoted": false}, - "operator": "", - "value": { - "type": "valueText", - "value": "\"test", - "quoted": false - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "url:test\"", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "text", - "negated": false, - "invalid": { - "type": "must-be-quoted", - "reason": "Quotes must enclose text or be escaped" - }, - "key": {"type": "keySimple", "value": "url", "quoted": false}, - "operator": "", - "value": { - "type": "valueText", - "value": "test\"", - "quoted": false - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "url:\"test transaction:abadcafe", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "text", - "negated": false, - "invalid": { - "type": "must-be-quoted", - "reason": "Quotes must enclose text or be escaped" - }, - "key": {"type": "keySimple", "value": "url", "quoted": false}, - "operator": "", - "value": { - "type": "valueText", - "value": "\"test", - "quoted": false - } - }, - {"type": "spaces", "value": " "}, - { - "type": "filter", - "filter": "text", - "negated": false, - "key": {"type": "keySimple", "value": "transaction", "quoted": false}, - "operator": "", - "value": { - "type": "valueText", - "value": "abadcafe", - "quoted": false - } - }, - {"type": "spaces", "value": ""} - ] - }, - { - "query": "url:te\"st transaction:abadcafe", - "result": [ - {"type": "spaces", "value": ""}, - { - "type": "filter", - "filter": "text", - "negated": false, - "invalid": { - "type": "must-be-quoted", - "reason": "Quotes must enclose text or be escaped" - }, - "key": {"type": "keySimple", "value": "url", "quoted": false}, - "operator": "", - "value": { - "type": "valueText", - "value": "te\"st", - "quoted": false - } - }, - {"type": "spaces", "value": " "}, - { - "type": "filter", - "filter": "text", - "negated": false, - "key": {"type": "keySimple", "value": "transaction", "quoted": false}, - "operator": "", - "value": { - "type": "valueText", - "value": "abadcafe", - "quoted": false - } - }, - {"type": "spaces", "value": ""} - ] - } -] diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 47ea8b669..a3c11f0d4 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -54,6 +54,9 @@ catalogs: '@sentry/react': specifier: 11.6.0 version: 11.6.0 + '@sentry/search-syntax': + specifier: ^1.0.0 + version: 1.0.0 '@sentry/vite-plugin': specifier: ^4.6.1 version: 4.6.1 @@ -807,6 +810,9 @@ importers: '@sentry/core': specifier: 'catalog:' version: 11.6.0 + '@sentry/search-syntax': + specifier: 'catalog:' + version: 1.0.0 '@sentry/toolkit-core': specifier: workspace:* version: link:../toolkit-core @@ -1016,6 +1022,10 @@ importers: version: 4.1.11(@opentelemetry/api@1.9.1)(@types/node@22.16.0)(@vitest/coverage-v8@4.1.11)(jsdom@28.1.0)(msw@2.10.2(@types/node@22.16.0)(typescript@5.9.3))(vite@8.3.3(@types/node@22.16.0)(esbuild@0.28.2)(jiti@2.7.0)(tsx@4.23.13)(yaml@2.9.0)) packages/toolkit-core: + dependencies: + '@sentry/search-syntax': + specifier: 'catalog:' + version: 1.0.0 devDependencies: typescript: specifier: 'catalog:' @@ -4709,6 +4719,9 @@ packages: resolution: {integrity: sha512-cJyPYnF6QJA8ADRfAW06YoU7EVIebtWezBOCU9Vag5+W1VLBkXEvH7C4LbeMUiDmrqw92sumq06NgqipIxA7BA==} engines: {node: '>=20.19.0 <22.0.0 || >=22.12.0 <23.0.0 || >=23.2.0'} + '@sentry/search-syntax@1.0.0': + resolution: {integrity: sha512-R+raAe4PixC+e7Zn6uPH7NSK7nzfHy2MA1kRWDn7dFH8zaU10edFBVPj8qO3TlSb58yts0tejPdy+s1acq80wQ==} + '@sentry/server-runtime-injection@11.6.0': resolution: {integrity: sha512-3plQzwQfvz4HJkXLDfr5VuQQL5vyjar7RKn7UwFne3jc+9OSXRkxkZ6S0Z3RdBgbaFO1GkFwf/mFNX4H8nNcuw==} engines: {node: '>=20.19.0 <22.0.0 || >=22.12.0 <23.0.0 || >=23.2.0'} @@ -12942,6 +12955,8 @@ snapshots: '@sentry/browser-utils': 11.6.0 '@sentry/core': 11.6.0 + '@sentry/search-syntax@1.0.0': {} + '@sentry/server-runtime-injection@11.6.0': dependencies: '@sentry/core': 11.6.0 diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index f0d9cc083..0afd230e1 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -58,6 +58,7 @@ catalog: "@sentry/core": 11.6.0 "@sentry/node": 11.6.0 "@sentry/react": 11.6.0 + "@sentry/search-syntax": ^1.0.0 "@sentry/vite-plugin": ^4.6.1 "@tailwindcss/typography": ^0.5.16 "@tailwindcss/vite": ^4.3.3 @@ -121,6 +122,7 @@ minimumReleaseAgeExclude: - "@sentry/react@11.6.0" - "@sentry/replay-canvas@11.6.0" - "@sentry/replay@11.6.0" + - "@sentry/search-syntax@1.0.0" - "@sentry/server-runtime-injection@11.6.0" - "@sentry/server-utils@11.6.0" - "@oxfmt/binding-android-arm-eabi@0.72.0" diff --git a/scripts/generate-parsers.mjs b/scripts/generate-parsers.mjs index c0e085c84..fb6248543 100644 --- a/scripts/generate-parsers.mjs +++ b/scripts/generate-parsers.mjs @@ -10,14 +10,8 @@ * with the TypeScript parser, are rebased so they resolve to the same * modules from there; nothing else in the file changes. * - * toolkit-core has no build step, so its parser is committed and - * `pnpm run check:generated` fails when it is out of date. The CLI generates - * its parser at build time (`pnpm run generate:grammar` in packages/cli). - * - * `packages/toolkit-core/grammar/search-syntax.pegjs` is a byte-for-byte copy - * of the Sentry frontend grammar at - * https://github.com/getsentry/sentry/blob/master/static/app/components/searchSyntax/grammar.pegjs - * so the two can converge on one source. + * The CLI generates its parsers at build time (`pnpm run generate:grammar` + * in packages/cli). * * Usage: * node scripts/generate-parsers.mjs diff --git a/scripts/pre-commit-generated.mjs b/scripts/pre-commit-generated.mjs index 98aed210b..2cba9b4e6 100644 --- a/scripts/pre-commit-generated.mjs +++ b/scripts/pre-commit-generated.mjs @@ -26,18 +26,6 @@ const GENERATED_TASKS = [ "plugins/sentry-mcp-experimental/agents/sentry-mcp.md", ], }, - { - name: "toolkit-core grammar parsers", - command: ["pnpm", "run", "generate:parsers"], - inputs: [ - /^packages\/toolkit-core\/grammar\//, - /^scripts\/generate-parsers\.mjs$/, - ], - outputs: [ - "packages/toolkit-core/src/generated/search-syntax-grammar.js", - "packages/toolkit-core/src/generated/search-syntax-grammar.d.ts", - ], - }, ]; function run(command) {