From 2efb3eb1bce5b920f1153d9f057f3e5ec24c8881 Mon Sep 17 00:00:00 2001 From: Bishoy Boktor <65934617+boktorbb-amzn@users.noreply.github.com> Date: Fri, 5 Mar 2021 10:58:39 -0800 Subject: [PATCH] Rename kbn-interpreter to osd-interpreter (#37) (#49) Signed-off-by: Bishoy Boktor --- packages/kbn-interpreter/.babelrc | 9 - packages/kbn-interpreter/tsconfig.json | 7 - packages/osd-interpreter/.babelrc | 14 + .../.npmignore | 0 .../common/package.json | 0 .../package.json | 12 +- .../scripts/build.js | 0 .../src/common/index.d.ts | 0 .../src/common/index.js | 0 .../src/common/lib/arg.js | 0 .../src/common/lib/arg.test.js | 0 .../src/common/lib/ast.d.ts | 0 .../common/lib/ast.from_expression.test.js | 0 .../src/common/lib/ast.js | 0 .../src/common/lib/ast.to_expression.test.js | 0 .../src/common/lib/cast.js | 0 .../src/common/lib/fn.js | 0 .../src/common/lib/get_by_alias.js | 0 .../src/common/lib/get_by_alias.test.js | 0 .../src/common/lib/get_type.d.ts | 0 .../src/common/lib/get_type.js | 0 .../src/common/lib/grammar.js | 571 +++++++++++------- .../src/common/lib/grammar.peg | 0 .../src/common/lib/registry.d.ts | 0 .../src/common/lib/registry.js | 0 .../src/common/lib/registry.test.js | 0 .../src/common/registries.js | 2 +- .../tasks/build/__fixtures__/sample.js | 0 .../tasks/build/cli.js | 4 +- .../tasks/build/paths.js | 2 +- packages/osd-interpreter/tsconfig.json | 10 + .../yarn.lock | 0 32 files changed, 398 insertions(+), 233 deletions(-) delete mode 100644 packages/kbn-interpreter/.babelrc delete mode 100644 packages/kbn-interpreter/tsconfig.json create mode 100644 packages/osd-interpreter/.babelrc rename packages/{kbn-interpreter => osd-interpreter}/.npmignore (100%) rename packages/{kbn-interpreter => osd-interpreter}/common/package.json (100%) rename packages/{kbn-interpreter => osd-interpreter}/package.json (78%) rename packages/{kbn-interpreter => osd-interpreter}/scripts/build.js (100%) rename packages/{kbn-interpreter => osd-interpreter}/src/common/index.d.ts (100%) rename packages/{kbn-interpreter => osd-interpreter}/src/common/index.js (100%) rename packages/{kbn-interpreter => osd-interpreter}/src/common/lib/arg.js (100%) rename packages/{kbn-interpreter => osd-interpreter}/src/common/lib/arg.test.js (100%) rename packages/{kbn-interpreter => osd-interpreter}/src/common/lib/ast.d.ts (100%) rename packages/{kbn-interpreter => osd-interpreter}/src/common/lib/ast.from_expression.test.js (100%) rename packages/{kbn-interpreter => osd-interpreter}/src/common/lib/ast.js (100%) rename packages/{kbn-interpreter => osd-interpreter}/src/common/lib/ast.to_expression.test.js (100%) rename packages/{kbn-interpreter => osd-interpreter}/src/common/lib/cast.js (100%) rename packages/{kbn-interpreter => osd-interpreter}/src/common/lib/fn.js (100%) rename packages/{kbn-interpreter => osd-interpreter}/src/common/lib/get_by_alias.js (100%) rename packages/{kbn-interpreter => osd-interpreter}/src/common/lib/get_by_alias.test.js (100%) rename packages/{kbn-interpreter => osd-interpreter}/src/common/lib/get_type.d.ts (100%) rename packages/{kbn-interpreter => osd-interpreter}/src/common/lib/get_type.js (100%) rename packages/{kbn-interpreter => osd-interpreter}/src/common/lib/grammar.js (64%) rename packages/{kbn-interpreter => osd-interpreter}/src/common/lib/grammar.peg (100%) rename packages/{kbn-interpreter => osd-interpreter}/src/common/lib/registry.d.ts (100%) rename packages/{kbn-interpreter => osd-interpreter}/src/common/lib/registry.js (100%) rename packages/{kbn-interpreter => osd-interpreter}/src/common/lib/registry.test.js (100%) rename packages/{kbn-interpreter => osd-interpreter}/src/common/registries.js (96%) rename packages/{kbn-interpreter => osd-interpreter}/tasks/build/__fixtures__/sample.js (100%) rename packages/{kbn-interpreter => osd-interpreter}/tasks/build/cli.js (97%) rename packages/{kbn-interpreter => osd-interpreter}/tasks/build/paths.js (94%) create mode 100644 packages/osd-interpreter/tsconfig.json rename packages/{kbn-interpreter => osd-interpreter}/yarn.lock (100%) diff --git a/packages/kbn-interpreter/.babelrc b/packages/kbn-interpreter/.babelrc deleted file mode 100644 index 309b3d5b323..00000000000 --- a/packages/kbn-interpreter/.babelrc +++ /dev/null @@ -1,9 +0,0 @@ -{ - "presets": ["@kbn/babel-preset/webpack_preset"], - "plugins": [ - "@babel/plugin-transform-modules-commonjs", - ["@babel/plugin-transform-runtime", { - "regenerator": true - }] - ] -} diff --git a/packages/kbn-interpreter/tsconfig.json b/packages/kbn-interpreter/tsconfig.json deleted file mode 100644 index 3b81bbb118a..00000000000 --- a/packages/kbn-interpreter/tsconfig.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "extends": "../../tsconfig.base.json", - "compilerOptions": { - "tsBuildInfoFile": "../../build/tsbuildinfo/packages/kbn-interpreter" - }, - "include": ["index.d.ts", "src/**/*.d.ts"] -} diff --git a/packages/osd-interpreter/.babelrc b/packages/osd-interpreter/.babelrc new file mode 100644 index 00000000000..e9197aca53a --- /dev/null +++ b/packages/osd-interpreter/.babelrc @@ -0,0 +1,14 @@ +{ + "presets": [ + "@osd/babel-preset/webpack_preset" + ], + "plugins": [ + "@babel/plugin-transform-modules-commonjs", + [ + "@babel/plugin-transform-runtime", + { + "regenerator": true + } + ] + ] +} \ No newline at end of file diff --git a/packages/kbn-interpreter/.npmignore b/packages/osd-interpreter/.npmignore similarity index 100% rename from packages/kbn-interpreter/.npmignore rename to packages/osd-interpreter/.npmignore diff --git a/packages/kbn-interpreter/common/package.json b/packages/osd-interpreter/common/package.json similarity index 100% rename from packages/kbn-interpreter/common/package.json rename to packages/osd-interpreter/common/package.json diff --git a/packages/kbn-interpreter/package.json b/packages/osd-interpreter/package.json similarity index 78% rename from packages/kbn-interpreter/package.json rename to packages/osd-interpreter/package.json index 4d415e96389..36b0f065bdd 100644 --- a/packages/kbn-interpreter/package.json +++ b/packages/osd-interpreter/package.json @@ -1,16 +1,16 @@ { - "name": "@kbn/interpreter", + "name": "@osd/interpreter", "version": "1.0.0", "license": "Apache-2.0", "scripts": { "interpreter:peg": "pegjs src/common/lib/grammar.peg", "build": "node scripts/build", - "kbn:bootstrap": "node scripts/build --dev", - "kbn:watch": "node scripts/build --dev --watch" + "osd:bootstrap": "node scripts/build --dev", + "osd:watch": "node scripts/build --dev --watch" }, "dependencies": { "@babel/runtime": "^7.11.2", - "@kbn/i18n": "1.0.0", + "@osd/i18n": "1.0.0", "lodash": "^4.17.20", "uuid": "3.3.2" }, @@ -19,8 +19,8 @@ "@babel/core": "^7.11.6", "@babel/plugin-transform-modules-commonjs": "^7.10.4", "@babel/plugin-transform-runtime": "^7.11.0", - "@kbn/babel-preset": "1.0.0", - "@kbn/dev-utils": "1.0.0", + "@osd/babel-preset": "1.0.0", + "@osd/dev-utils": "1.0.0", "babel-loader": "^8.0.6", "copy-webpack-plugin": "^6.0.2", "css-loader": "^3.4.2", diff --git a/packages/kbn-interpreter/scripts/build.js b/packages/osd-interpreter/scripts/build.js similarity index 100% rename from packages/kbn-interpreter/scripts/build.js rename to packages/osd-interpreter/scripts/build.js diff --git a/packages/kbn-interpreter/src/common/index.d.ts b/packages/osd-interpreter/src/common/index.d.ts similarity index 100% rename from packages/kbn-interpreter/src/common/index.d.ts rename to packages/osd-interpreter/src/common/index.d.ts diff --git a/packages/kbn-interpreter/src/common/index.js b/packages/osd-interpreter/src/common/index.js similarity index 100% rename from packages/kbn-interpreter/src/common/index.js rename to packages/osd-interpreter/src/common/index.js diff --git a/packages/kbn-interpreter/src/common/lib/arg.js b/packages/osd-interpreter/src/common/lib/arg.js similarity index 100% rename from packages/kbn-interpreter/src/common/lib/arg.js rename to packages/osd-interpreter/src/common/lib/arg.js diff --git a/packages/kbn-interpreter/src/common/lib/arg.test.js b/packages/osd-interpreter/src/common/lib/arg.test.js similarity index 100% rename from packages/kbn-interpreter/src/common/lib/arg.test.js rename to packages/osd-interpreter/src/common/lib/arg.test.js diff --git a/packages/kbn-interpreter/src/common/lib/ast.d.ts b/packages/osd-interpreter/src/common/lib/ast.d.ts similarity index 100% rename from packages/kbn-interpreter/src/common/lib/ast.d.ts rename to packages/osd-interpreter/src/common/lib/ast.d.ts diff --git a/packages/kbn-interpreter/src/common/lib/ast.from_expression.test.js b/packages/osd-interpreter/src/common/lib/ast.from_expression.test.js similarity index 100% rename from packages/kbn-interpreter/src/common/lib/ast.from_expression.test.js rename to packages/osd-interpreter/src/common/lib/ast.from_expression.test.js diff --git a/packages/kbn-interpreter/src/common/lib/ast.js b/packages/osd-interpreter/src/common/lib/ast.js similarity index 100% rename from packages/kbn-interpreter/src/common/lib/ast.js rename to packages/osd-interpreter/src/common/lib/ast.js diff --git a/packages/kbn-interpreter/src/common/lib/ast.to_expression.test.js b/packages/osd-interpreter/src/common/lib/ast.to_expression.test.js similarity index 100% rename from packages/kbn-interpreter/src/common/lib/ast.to_expression.test.js rename to packages/osd-interpreter/src/common/lib/ast.to_expression.test.js diff --git a/packages/kbn-interpreter/src/common/lib/cast.js b/packages/osd-interpreter/src/common/lib/cast.js similarity index 100% rename from packages/kbn-interpreter/src/common/lib/cast.js rename to packages/osd-interpreter/src/common/lib/cast.js diff --git a/packages/kbn-interpreter/src/common/lib/fn.js b/packages/osd-interpreter/src/common/lib/fn.js similarity index 100% rename from packages/kbn-interpreter/src/common/lib/fn.js rename to packages/osd-interpreter/src/common/lib/fn.js diff --git a/packages/kbn-interpreter/src/common/lib/get_by_alias.js b/packages/osd-interpreter/src/common/lib/get_by_alias.js similarity index 100% rename from packages/kbn-interpreter/src/common/lib/get_by_alias.js rename to packages/osd-interpreter/src/common/lib/get_by_alias.js diff --git a/packages/kbn-interpreter/src/common/lib/get_by_alias.test.js b/packages/osd-interpreter/src/common/lib/get_by_alias.test.js similarity index 100% rename from packages/kbn-interpreter/src/common/lib/get_by_alias.test.js rename to packages/osd-interpreter/src/common/lib/get_by_alias.test.js diff --git a/packages/kbn-interpreter/src/common/lib/get_type.d.ts b/packages/osd-interpreter/src/common/lib/get_type.d.ts similarity index 100% rename from packages/kbn-interpreter/src/common/lib/get_type.d.ts rename to packages/osd-interpreter/src/common/lib/get_type.d.ts diff --git a/packages/kbn-interpreter/src/common/lib/get_type.js b/packages/osd-interpreter/src/common/lib/get_type.js similarity index 100% rename from packages/kbn-interpreter/src/common/lib/get_type.js rename to packages/osd-interpreter/src/common/lib/get_type.js diff --git a/packages/kbn-interpreter/src/common/lib/grammar.js b/packages/osd-interpreter/src/common/lib/grammar.js similarity index 64% rename from packages/kbn-interpreter/src/common/lib/grammar.js rename to packages/osd-interpreter/src/common/lib/grammar.js index 2e87b52d68f..d338c36c893 100644 --- a/packages/kbn-interpreter/src/common/lib/grammar.js +++ b/packages/osd-interpreter/src/common/lib/grammar.js @@ -1,62 +1,82 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /* * Generated by PEG.js 0.10.0. * * http://pegjs.org/ */ -"use strict"; - function peg$subclass(child, parent) { - function ctor() { this.constructor = child; } + function ctor() { + this.constructor = child; + } ctor.prototype = parent.prototype; child.prototype = new ctor(); } function peg$SyntaxError(message, expected, found, location) { - this.message = message; + this.message = message; this.expected = expected; - this.found = found; + this.found = found; this.location = location; - this.name = "SyntaxError"; + this.name = 'SyntaxError'; - if (typeof Error.captureStackTrace === "function") { + if (typeof Error.captureStackTrace === 'function') { Error.captureStackTrace(this, peg$SyntaxError); } } peg$subclass(peg$SyntaxError, Error); -peg$SyntaxError.buildMessage = function(expected, found) { - var DESCRIBE_EXPECTATION_FNS = { - literal: function(expectation) { - return "\"" + literalEscape(expectation.text) + "\""; - }, - - "class": function(expectation) { - var escapedParts = "", - i; +peg$SyntaxError.buildMessage = function (expected, found) { + const DESCRIBE_EXPECTATION_FNS = { + literal: function (expectation) { + return '"' + literalEscape(expectation.text) + '"'; + }, + + class: function (expectation) { + let escapedParts = ''; + let i; + + for (i = 0; i < expectation.parts.length; i++) { + escapedParts += + expectation.parts[i] instanceof Array + ? classEscape(expectation.parts[i][0]) + '-' + classEscape(expectation.parts[i][1]) + : classEscape(expectation.parts[i]); + } - for (i = 0; i < expectation.parts.length; i++) { - escapedParts += expectation.parts[i] instanceof Array - ? classEscape(expectation.parts[i][0]) + "-" + classEscape(expectation.parts[i][1]) - : classEscape(expectation.parts[i]); - } + return '[' + (expectation.inverted ? '^' : '') + escapedParts + ']'; + }, - return "[" + (expectation.inverted ? "^" : "") + escapedParts + "]"; - }, + any: function (expectation) { + return 'any character'; + }, - any: function(expectation) { - return "any character"; - }, + end: function (expectation) { + return 'end of input'; + }, - end: function(expectation) { - return "end of input"; - }, - - other: function(expectation) { - return expectation.description; - } - }; + other: function (expectation) { + return expectation.description; + }, + }; function hex(ch) { return ch.charCodeAt(0).toString(16).toUpperCase(); @@ -65,13 +85,17 @@ peg$SyntaxError.buildMessage = function(expected, found) { function literalEscape(s) { return s .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, function(ch) { return '\\x0' + hex(ch); }) - .replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return '\\x' + hex(ch); }); + .replace(/[\x00-\x0F]/g, function (ch) { + return '\\x0' + hex(ch); + }) + .replace(/[\x10-\x1F\x7F-\x9F]/g, function (ch) { + return '\\x' + hex(ch); + }); } function classEscape(s) { @@ -79,13 +103,17 @@ peg$SyntaxError.buildMessage = function(expected, found) { .replace(/\\/g, '\\\\') .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, function(ch) { return '\\x0' + hex(ch); }) - .replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return '\\x' + hex(ch); }); + .replace(/[\x00-\x0F]/g, function (ch) { + return '\\x0' + hex(ch); + }) + .replace(/[\x10-\x1F\x7F-\x9F]/g, function (ch) { + return '\\x' + hex(ch); + }); } function describeExpectation(expectation) { @@ -93,8 +121,9 @@ peg$SyntaxError.buildMessage = function(expected, found) { } function describeExpected(expected) { - var descriptions = new Array(expected.length), - i, j; + const descriptions = new Array(expected.length); + let i; + let j; for (i = 0; i < expected.length; i++) { descriptions[i] = describeExpectation(expected[i]); @@ -117,119 +146,153 @@ peg$SyntaxError.buildMessage = function(expected, found) { return descriptions[0]; case 2: - return descriptions[0] + " or " + descriptions[1]; + return descriptions[0] + ' or ' + descriptions[1]; default: - return descriptions.slice(0, -1).join(", ") - + ", or " - + descriptions[descriptions.length - 1]; + return ( + descriptions.slice(0, -1).join(', ') + ', or ' + descriptions[descriptions.length - 1] + ); } } function describeFound(found) { - return found ? "\"" + literalEscape(found) + "\"" : "end of input"; + return found ? '"' + literalEscape(found) + '"' : 'end of input'; } - return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found."; + return 'Expected ' + describeExpected(expected) + ' but ' + describeFound(found) + ' found.'; }; function peg$parse(input, options) { options = options !== void 0 ? options : {}; - var peg$FAILED = {}, - - peg$startRuleFunctions = { expression: peg$parseexpression, argument: peg$parseargument }, - peg$startRuleFunction = peg$parseexpression, - - peg$c0 = "|", - peg$c1 = peg$literalExpectation("|", false), - peg$c2 = function(first, fn) { return fn; }, - peg$c3 = function(first, rest) { - return addMeta({ - type: 'expression', - chain: [first].concat(rest) - }, text(), location()); - }, - peg$c4 = peg$otherExpectation("function"), - peg$c5 = function(name, arg_list) { - return addMeta({ - type: 'function', - function: name, - arguments: arg_list - }, text(), location()); - }, - peg$c6 = "=", - peg$c7 = peg$literalExpectation("=", false), - peg$c8 = function(name, value) { - return { name, value }; - }, - peg$c9 = function(value) { - return { name: '_', value }; - }, - peg$c10 = "$", - peg$c11 = peg$literalExpectation("$", false), - peg$c12 = "{", - peg$c13 = peg$literalExpectation("{", false), - peg$c14 = "}", - peg$c15 = peg$literalExpectation("}", false), - peg$c16 = function(expression) { return expression; }, - peg$c17 = function(value) { - return addMeta(value, text(), location()); - }, - peg$c18 = function(arg) { return arg; }, - peg$c19 = function(args) { - return args.reduce((accumulator, { name, value }) => ({ - ...accumulator, - [name]: (accumulator[name] || []).concat(value) - }), {}); - }, - peg$c20 = /^[a-zA-Z0-9_\-]/, - peg$c21 = peg$classExpectation([["a", "z"], ["A", "Z"], ["0", "9"], "_", "-"], false, false), - peg$c22 = function(name) { - return name.join(''); - }, - peg$c23 = peg$otherExpectation("literal"), - peg$c24 = "\"", - peg$c25 = peg$literalExpectation("\"", false), - peg$c26 = function(chars) { return chars.join(''); }, - peg$c27 = "'", - peg$c28 = peg$literalExpectation("'", false), - peg$c29 = function(string) { // this also matches nulls, booleans, and numbers - var result = string.join(''); - // Sort of hacky, but PEG doesn't have backtracking so - // a null/boolean/number rule is hard to read, and performs worse - if (result === 'null') return null; - if (result === 'true') return true; - if (result === 'false') return false; - if (isNaN(Number(result))) return result; // 5bears - return Number(result); - }, - peg$c30 = /^[ \t\r\n]/, - peg$c31 = peg$classExpectation([" ", "\t", "\r", "\n"], false, false), - peg$c32 = "\\", - peg$c33 = peg$literalExpectation("\\", false), - peg$c34 = /^["'(){}<>[\]$`|= \t\n\r]/, - peg$c35 = peg$classExpectation(["\"", "'", "(", ")", "{", "}", "<", ">", "[", "]", "$", "`", "|", "=", " ", "\t", "\n", "\r"], false, false), - peg$c36 = function(sequence) { return sequence; }, - peg$c37 = /^[^"'(){}<>[\]$`|= \t\n\r]/, - peg$c38 = peg$classExpectation(["\"", "'", "(", ")", "{", "}", "<", ">", "[", "]", "$", "`", "|", "=", " ", "\t", "\n", "\r"], true, false), - peg$c39 = /^[^"]/, - peg$c40 = peg$classExpectation(["\""], true, false), - peg$c41 = /^[^']/, - peg$c42 = peg$classExpectation(["'"], true, false), - - peg$currPos = 0, - peg$savedPos = 0, - peg$posDetailsCache = [{ line: 1, column: 1 }], - peg$maxFailPos = 0, - peg$maxFailExpected = [], - peg$silentFails = 0, - - peg$result; - - if ("startRule" in options) { + const peg$FAILED = {}; + + const peg$startRuleFunctions = { expression: peg$parseexpression, argument: peg$parseargument }; + let peg$startRuleFunction = peg$parseexpression; + + const peg$c0 = '|'; + const peg$c1 = peg$literalExpectation('|', false); + const peg$c2 = function (first, fn) { + return fn; + }; + const peg$c3 = function (first, rest) { + return addMeta( + { + type: 'expression', + chain: [first].concat(rest), + }, + text(), + location() + ); + }; + const peg$c4 = peg$otherExpectation('function'); + const peg$c5 = function (name, arg_list) { + return addMeta( + { + type: 'function', + function: name, + arguments: arg_list, + }, + text(), + location() + ); + }; + const peg$c6 = '='; + const peg$c7 = peg$literalExpectation('=', false); + const peg$c8 = function (name, value) { + return { name, value }; + }; + const peg$c9 = function (value) { + return { name: '_', value }; + }; + const peg$c10 = '$'; + const peg$c11 = peg$literalExpectation('$', false); + const peg$c12 = '{'; + const peg$c13 = peg$literalExpectation('{', false); + const peg$c14 = '}'; + const peg$c15 = peg$literalExpectation('}', false); + const peg$c16 = function (expression) { + return expression; + }; + const peg$c17 = function (value) { + return addMeta(value, text(), location()); + }; + const peg$c18 = function (arg) { + return arg; + }; + const peg$c19 = function (args) { + return args.reduce( + (accumulator, { name, value }) => ({ + ...accumulator, + [name]: (accumulator[name] || []).concat(value), + }), + {} + ); + }; + const peg$c20 = /^[a-zA-Z0-9_\-]/; + const peg$c21 = peg$classExpectation( + [['a', 'z'], ['A', 'Z'], ['0', '9'], '_', '-'], + false, + false + ); + const peg$c22 = function (name) { + return name.join(''); + }; + const peg$c23 = peg$otherExpectation('literal'); + const peg$c24 = '"'; + const peg$c25 = peg$literalExpectation('"', false); + const peg$c26 = function (chars) { + return chars.join(''); + }; + const peg$c27 = "'"; + const peg$c28 = peg$literalExpectation("'", false); + const peg$c29 = function (string) { + // this also matches nulls, booleans, and numbers + const result = string.join(''); + // Sort of hacky, but PEG doesn't have backtracking so + // a null/boolean/number rule is hard to read, and performs worse + if (result === 'null') return null; + if (result === 'true') return true; + if (result === 'false') return false; + if (isNaN(Number(result))) return result; // 5bears + return Number(result); + }; + const peg$c30 = /^[ \t\r\n]/; + const peg$c31 = peg$classExpectation([' ', '\t', '\r', '\n'], false, false); + const peg$c32 = '\\'; + const peg$c33 = peg$literalExpectation('\\', false); + const peg$c34 = /^["'(){}<>[\]$`|= \t\n\r]/; + const peg$c35 = peg$classExpectation( + ['"', "'", '(', ')', '{', '}', '<', '>', '[', ']', '$', '`', '|', '=', ' ', '\t', '\n', '\r'], + false, + false + ); + const peg$c36 = function (sequence) { + return sequence; + }; + const peg$c37 = /^[^"'(){}<>[\]$`|= \t\n\r]/; + const peg$c38 = peg$classExpectation( + ['"', "'", '(', ')', '{', '}', '<', '>', '[', ']', '$', '`', '|', '=', ' ', '\t', '\n', '\r'], + true, + false + ); + const peg$c39 = /^[^"]/; + const peg$c40 = peg$classExpectation(['"'], true, false); + const peg$c41 = /^[^']/; + const peg$c42 = peg$classExpectation(["'"], true, false); + + let peg$currPos = 0; + let peg$savedPos = 0; + const peg$posDetailsCache = [{ line: 1, column: 1 }]; + let peg$maxFailPos = 0; + let peg$maxFailExpected = []; + let peg$silentFails = 0; + + let peg$result; + + if ('startRule' in options) { if (!(options.startRule in peg$startRuleFunctions)) { - throw new Error("Can't start parsing from rule \"" + options.startRule + "\"."); + throw new Error('Can\'t start parsing from rule "' + options.startRule + '".'); } peg$startRuleFunction = peg$startRuleFunctions[options.startRule]; @@ -244,7 +307,7 @@ function peg$parse(input, options) { } function expected(description, location) { - location = location !== void 0 ? location : peg$computeLocation(peg$savedPos, peg$currPos) + location = location !== void 0 ? location : peg$computeLocation(peg$savedPos, peg$currPos); throw peg$buildStructuredError( [peg$otherExpectation(description)], @@ -254,33 +317,34 @@ function peg$parse(input, options) { } function error(message, location) { - location = location !== void 0 ? location : peg$computeLocation(peg$savedPos, peg$currPos) + location = location !== void 0 ? location : peg$computeLocation(peg$savedPos, peg$currPos); throw peg$buildSimpleError(message, location); } function peg$literalExpectation(text, ignoreCase) { - return { type: "literal", text: text, ignoreCase: ignoreCase }; + return { type: 'literal', text: text, ignoreCase: ignoreCase }; } function peg$classExpectation(parts, inverted, ignoreCase) { - return { type: "class", parts: parts, inverted: inverted, ignoreCase: ignoreCase }; + return { type: 'class', parts: parts, inverted: inverted, ignoreCase: ignoreCase }; } function peg$anyExpectation() { - return { type: "any" }; + return { type: 'any' }; } function peg$endExpectation() { - return { type: "end" }; + return { type: 'end' }; } function peg$otherExpectation(description) { - return { type: "other", description: description }; + return { type: 'other', description: description }; } function peg$computePosDetails(pos) { - var details = peg$posDetailsCache[pos], p; + let details = peg$posDetailsCache[pos]; + let p; if (details) { return details; @@ -292,8 +356,8 @@ function peg$parse(input, options) { details = peg$posDetailsCache[p]; details = { - line: details.line, - column: details.column + line: details.line, + column: details.column, }; while (p < pos) { @@ -313,25 +377,27 @@ function peg$parse(input, options) { } function peg$computeLocation(startPos, endPos) { - var startPosDetails = peg$computePosDetails(startPos), - endPosDetails = peg$computePosDetails(endPos); + const startPosDetails = peg$computePosDetails(startPos); + const endPosDetails = peg$computePosDetails(endPos); return { start: { offset: startPos, - line: startPosDetails.line, - column: startPosDetails.column + line: startPosDetails.line, + column: startPosDetails.column, }, end: { offset: endPos, - line: endPosDetails.line, - column: endPosDetails.column - } + line: endPosDetails.line, + column: endPosDetails.column, + }, }; } function peg$fail(expected) { - if (peg$currPos < peg$maxFailPos) { return; } + if (peg$currPos < peg$maxFailPos) { + return; + } if (peg$currPos > peg$maxFailPos) { peg$maxFailPos = peg$currPos; @@ -355,7 +421,14 @@ function peg$parse(input, options) { } function peg$parseexpression() { - var s0, s1, s2, s3, s4, s5, s6, s7; + let s0; + let s1; + let s2; + let s3; + let s4; + let s5; + let s6; + let s7; s0 = peg$currPos; s1 = peg$parsespace(); @@ -372,7 +445,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c1); } + if (peg$silentFails === 0) { + peg$fail(peg$c1); + } } if (s5 !== peg$FAILED) { s6 = peg$parsespace(); @@ -405,7 +480,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c1); } + if (peg$silentFails === 0) { + peg$fail(peg$c1); + } } if (s5 !== peg$FAILED) { s6 = peg$parsespace(); @@ -452,7 +529,9 @@ function peg$parse(input, options) { } function peg$parsefunction() { - var s0, s1, s2; + let s0; + let s1; + let s2; peg$silentFails++; s0 = peg$currPos; @@ -474,14 +553,21 @@ function peg$parse(input, options) { peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c4); } + if (peg$silentFails === 0) { + peg$fail(peg$c4); + } } return s0; } function peg$parseargument_assignment() { - var s0, s1, s2, s3, s4, s5; + let s0; + let s1; + let s2; + let s3; + let s4; + let s5; s0 = peg$currPos; s1 = peg$parseidentifier(); @@ -496,7 +582,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c7); } + if (peg$silentFails === 0) { + peg$fail(peg$c7); + } } if (s3 !== peg$FAILED) { s4 = peg$parsespace(); @@ -543,7 +631,11 @@ function peg$parse(input, options) { } function peg$parseargument() { - var s0, s1, s2, s3, s4; + let s0; + let s1; + let s2; + let s3; + let s4; s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 36) { @@ -551,7 +643,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c11); } + if (peg$silentFails === 0) { + peg$fail(peg$c11); + } } if (s1 === peg$FAILED) { s1 = null; @@ -562,7 +656,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c13); } + if (peg$silentFails === 0) { + peg$fail(peg$c13); + } } if (s2 !== peg$FAILED) { s3 = peg$parseexpression(); @@ -572,7 +668,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c15); } + if (peg$silentFails === 0) { + peg$fail(peg$c15); + } } if (s4 !== peg$FAILED) { peg$savedPos = s0; @@ -608,7 +706,11 @@ function peg$parse(input, options) { } function peg$parsearg_list() { - var s0, s1, s2, s3, s4; + let s0; + let s1; + let s2; + let s3; + let s4; s0 = peg$currPos; s1 = []; @@ -669,7 +771,9 @@ function peg$parse(input, options) { } function peg$parseidentifier() { - var s0, s1, s2; + let s0; + let s1; + let s2; s0 = peg$currPos; s1 = []; @@ -678,7 +782,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c21); } + if (peg$silentFails === 0) { + peg$fail(peg$c21); + } } if (s2 !== peg$FAILED) { while (s2 !== peg$FAILED) { @@ -688,7 +794,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c21); } + if (peg$silentFails === 0) { + peg$fail(peg$c21); + } } } } else { @@ -704,7 +812,8 @@ function peg$parse(input, options) { } function peg$parseliteral() { - var s0, s1; + let s0; + let s1; peg$silentFails++; s0 = peg$parsephrase(); @@ -714,14 +823,19 @@ function peg$parse(input, options) { peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c23); } + if (peg$silentFails === 0) { + peg$fail(peg$c23); + } } return s0; } function peg$parsephrase() { - var s0, s1, s2, s3; + let s0; + let s1; + let s2; + let s3; s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 34) { @@ -729,7 +843,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c25); } + if (peg$silentFails === 0) { + peg$fail(peg$c25); + } } if (s1 !== peg$FAILED) { s2 = []; @@ -744,7 +860,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c25); } + if (peg$silentFails === 0) { + peg$fail(peg$c25); + } } if (s3 !== peg$FAILED) { peg$savedPos = s0; @@ -769,7 +887,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c28); } + if (peg$silentFails === 0) { + peg$fail(peg$c28); + } } if (s1 !== peg$FAILED) { s2 = []; @@ -784,7 +904,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c28); } + if (peg$silentFails === 0) { + peg$fail(peg$c28); + } } if (s3 !== peg$FAILED) { peg$savedPos = s0; @@ -808,7 +930,9 @@ function peg$parse(input, options) { } function peg$parseunquoted_string_or_number() { - var s0, s1, s2; + let s0; + let s1; + let s2; s0 = peg$currPos; s1 = []; @@ -831,7 +955,8 @@ function peg$parse(input, options) { } function peg$parsespace() { - var s0, s1; + let s0; + let s1; s0 = []; if (peg$c30.test(input.charAt(peg$currPos))) { @@ -839,7 +964,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c31); } + if (peg$silentFails === 0) { + peg$fail(peg$c31); + } } if (s1 !== peg$FAILED) { while (s1 !== peg$FAILED) { @@ -849,7 +976,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c31); } + if (peg$silentFails === 0) { + peg$fail(peg$c31); + } } } } else { @@ -860,7 +989,9 @@ function peg$parse(input, options) { } function peg$parseunquoted() { - var s0, s1, s2; + let s0; + let s1; + let s2; s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 92) { @@ -868,7 +999,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c33); } + if (peg$silentFails === 0) { + peg$fail(peg$c33); + } } if (s1 !== peg$FAILED) { if (peg$c34.test(input.charAt(peg$currPos))) { @@ -876,7 +1009,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c35); } + if (peg$silentFails === 0) { + peg$fail(peg$c35); + } } if (s2 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 92) { @@ -884,7 +1019,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c33); } + if (peg$silentFails === 0) { + peg$fail(peg$c33); + } } } if (s2 !== peg$FAILED) { @@ -905,7 +1042,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c38); } + if (peg$silentFails === 0) { + peg$fail(peg$c38); + } } } @@ -913,7 +1052,9 @@ function peg$parse(input, options) { } function peg$parsedq_char() { - var s0, s1, s2; + let s0; + let s1; + let s2; s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 92) { @@ -921,7 +1062,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c33); } + if (peg$silentFails === 0) { + peg$fail(peg$c33); + } } if (s1 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 34) { @@ -929,7 +1072,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c25); } + if (peg$silentFails === 0) { + peg$fail(peg$c25); + } } if (s2 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 92) { @@ -937,7 +1082,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c33); } + if (peg$silentFails === 0) { + peg$fail(peg$c33); + } } } if (s2 !== peg$FAILED) { @@ -958,7 +1105,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c40); } + if (peg$silentFails === 0) { + peg$fail(peg$c40); + } } } @@ -966,7 +1115,9 @@ function peg$parse(input, options) { } function peg$parsesq_char() { - var s0, s1, s2; + let s0; + let s1; + let s2; s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 92) { @@ -974,7 +1125,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c33); } + if (peg$silentFails === 0) { + peg$fail(peg$c33); + } } if (s1 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 39) { @@ -982,7 +1135,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c28); } + if (peg$silentFails === 0) { + peg$fail(peg$c28); + } } if (s2 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 92) { @@ -990,7 +1145,9 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c33); } + if (peg$silentFails === 0) { + peg$fail(peg$c33); + } } } if (s2 !== peg$FAILED) { @@ -1011,19 +1168,19 @@ function peg$parse(input, options) { peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c42); } + if (peg$silentFails === 0) { + peg$fail(peg$c42); + } } } return s0; } - - function addMeta(node, text, { start: { offset: start }, end: { offset: end } }) { - if (!options.addMeta) return node; - return { node, text, start, end }; - } - + function addMeta(node, text, { start: { offset: start }, end: { offset: end } }) { + if (!options.addMeta) return node; + return { node, text, start, end }; + } peg$result = peg$startRuleFunction(); @@ -1046,5 +1203,5 @@ function peg$parse(input, options) { module.exports = { SyntaxError: peg$SyntaxError, - parse: peg$parse + parse: peg$parse, }; diff --git a/packages/kbn-interpreter/src/common/lib/grammar.peg b/packages/osd-interpreter/src/common/lib/grammar.peg similarity index 100% rename from packages/kbn-interpreter/src/common/lib/grammar.peg rename to packages/osd-interpreter/src/common/lib/grammar.peg diff --git a/packages/kbn-interpreter/src/common/lib/registry.d.ts b/packages/osd-interpreter/src/common/lib/registry.d.ts similarity index 100% rename from packages/kbn-interpreter/src/common/lib/registry.d.ts rename to packages/osd-interpreter/src/common/lib/registry.d.ts diff --git a/packages/kbn-interpreter/src/common/lib/registry.js b/packages/osd-interpreter/src/common/lib/registry.js similarity index 100% rename from packages/kbn-interpreter/src/common/lib/registry.js rename to packages/osd-interpreter/src/common/lib/registry.js diff --git a/packages/kbn-interpreter/src/common/lib/registry.test.js b/packages/osd-interpreter/src/common/lib/registry.test.js similarity index 100% rename from packages/kbn-interpreter/src/common/lib/registry.test.js rename to packages/osd-interpreter/src/common/lib/registry.test.js diff --git a/packages/kbn-interpreter/src/common/registries.js b/packages/osd-interpreter/src/common/registries.js similarity index 96% rename from packages/kbn-interpreter/src/common/registries.js rename to packages/osd-interpreter/src/common/registries.js index 9d73433bb2d..352f7add7c9 100644 --- a/packages/kbn-interpreter/src/common/registries.js +++ b/packages/osd-interpreter/src/common/registries.js @@ -65,7 +65,7 @@ export function register(registries, specs) { export function registryFactory(registries) { return { // This is a getter function. We can't make it a property or a proper - // getter, because Kibana server will improperly clone it. + // getter, because OpenSearch Dashboards server will improperly clone it. registries() { return registries; }, diff --git a/packages/kbn-interpreter/tasks/build/__fixtures__/sample.js b/packages/osd-interpreter/tasks/build/__fixtures__/sample.js similarity index 100% rename from packages/kbn-interpreter/tasks/build/__fixtures__/sample.js rename to packages/osd-interpreter/tasks/build/__fixtures__/sample.js diff --git a/packages/kbn-interpreter/tasks/build/cli.js b/packages/osd-interpreter/tasks/build/cli.js similarity index 97% rename from packages/kbn-interpreter/tasks/build/cli.js rename to packages/osd-interpreter/tasks/build/cli.js index 970e0f88478..bfb81380537 100644 --- a/packages/kbn-interpreter/tasks/build/cli.js +++ b/packages/osd-interpreter/tasks/build/cli.js @@ -22,7 +22,7 @@ const { relative } = require('path'); const getopts = require('getopts'); const del = require('del'); const supportsColor = require('supports-color'); -const { ToolingLog, withProcRunner, pickLevelFromFlags } = require('@kbn/dev-utils'); +const { ToolingLog, withProcRunner, pickLevelFromFlags } = require('@osd/dev-utils'); const { ROOT_DIR, BUILD_DIR } = require('./paths'); @@ -47,7 +47,7 @@ if (unknownFlags.length) { if (flags.help) { log.info(` - Simple build tool for @kbn/interpreter package + Simple build tool for @osd/interpreter package --dev Build for development, include source maps --watch Run in watch mode diff --git a/packages/kbn-interpreter/tasks/build/paths.js b/packages/osd-interpreter/tasks/build/paths.js similarity index 94% rename from packages/kbn-interpreter/tasks/build/paths.js rename to packages/osd-interpreter/tasks/build/paths.js index aefd64a9394..a9e6131ec44 100644 --- a/packages/kbn-interpreter/tasks/build/paths.js +++ b/packages/osd-interpreter/tasks/build/paths.js @@ -23,4 +23,4 @@ exports.ROOT_DIR = resolve(__dirname, '../../'); exports.SOURCE_DIR = resolve(exports.ROOT_DIR, 'src'); exports.BUILD_DIR = resolve(exports.ROOT_DIR, 'target'); -exports.BABEL_PRESET_PATH = require.resolve('@kbn/babel-preset/webpack_preset'); +exports.BABEL_PRESET_PATH = require.resolve('@osd/babel-preset/webpack_preset'); diff --git a/packages/osd-interpreter/tsconfig.json b/packages/osd-interpreter/tsconfig.json new file mode 100644 index 00000000000..6aa67be4ba1 --- /dev/null +++ b/packages/osd-interpreter/tsconfig.json @@ -0,0 +1,10 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "tsBuildInfoFile": "../../build/tsbuildinfo/packages/osd-interpreter" + }, + "include": [ + "index.d.ts", + "src/**/*.d.ts" + ] +} \ No newline at end of file diff --git a/packages/kbn-interpreter/yarn.lock b/packages/osd-interpreter/yarn.lock similarity index 100% rename from packages/kbn-interpreter/yarn.lock rename to packages/osd-interpreter/yarn.lock