diff --git a/packages/elastic-datemath/README.md b/packages/elastic-datemath/README.md new file mode 100644 index 0000000000000..a8dcd9f6721cb --- /dev/null +++ b/packages/elastic-datemath/README.md @@ -0,0 +1,5 @@ +# datemath + +Datemath string parser used in Kibana. This is published to NPM for use in a limited number of locations outside of Kibana, but is not regularly updated and may get seriously out of date. + +If you file an issue in elastic/kibana we can probably update it for you if needed, though you probably shouldn't depend on this package for anything important. diff --git a/packages/elastic-datemath/index.d.ts b/packages/elastic-datemath/index.d.ts deleted file mode 100644 index 319c598e3e4ab..0000000000000 --- a/packages/elastic-datemath/index.d.ts +++ /dev/null @@ -1,51 +0,0 @@ -/* - * 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. - */ - -import moment from 'moment'; -export type Unit = 'ms' | 's' | 'm' | 'h' | 'd' | 'w' | 'M' | 'y'; - -declare const datemath: { - unitsMap: { - [k in Unit]: { - weight: number; - type: 'calendar' | 'fixed' | 'mixed'; - base: number; - }; - }; - units: Unit[]; - unitsAsc: Unit[]; - unitsDesc: Unit[]; - - /** - * Parses a string into a moment object. The string can be something like "now - 15m". - * @param options.forceNow If this optional parameter is supplied, "now" will be treated as this - * date, rather than the real "now". - */ - parse( - input: string, - options?: { - roundUp?: boolean; - forceNow?: Date; - momentInstance?: typeof moment; - } - ): moment.Moment | undefined; -}; - -// eslint-disable-next-line import/no-default-export -export default datemath; diff --git a/packages/elastic-datemath/package.json b/packages/elastic-datemath/package.json index 0d8f936ae6358..4dc9c4f24d567 100644 --- a/packages/elastic-datemath/package.json +++ b/packages/elastic-datemath/package.json @@ -3,6 +3,10 @@ "version": "5.0.3", "description": "elasticsearch datemath parser, used in kibana", "license": "Apache-2.0", - "main": "index.js", - "typings": "index.d.ts" + "main": "./target/index.js", + "types": "./target/index.d.ts", + "scripts": { + "build": "../../node_modules/.bin/tsc", + "kbn:bootstrap": "yarn build" + } } \ No newline at end of file diff --git a/packages/elastic-datemath/readme.md b/packages/elastic-datemath/readme.md deleted file mode 100644 index f7de9627e6d69..0000000000000 --- a/packages/elastic-datemath/readme.md +++ /dev/null @@ -1,3 +0,0 @@ -# datemath - -Datemath string parser used in Kibana diff --git a/packages/elastic-datemath/index.test.js b/packages/elastic-datemath/src/index.test.js similarity index 100% rename from packages/elastic-datemath/index.test.js rename to packages/elastic-datemath/src/index.test.js diff --git a/packages/elastic-datemath/index.js b/packages/elastic-datemath/src/index.ts similarity index 71% rename from packages/elastic-datemath/index.js rename to packages/elastic-datemath/src/index.ts index 8a69d251d057d..a513af800b7c3 100644 --- a/packages/elastic-datemath/index.js +++ b/packages/elastic-datemath/src/index.ts @@ -17,9 +17,18 @@ * under the License. */ -const moment = require('moment'); +import moment from 'moment'; + +export type Unit = 'ms' | 's' | 'm' | 'h' | 'd' | 'w' | 'M' | 'y'; +export type UnitsMap = { + [k in Unit]: { + weight: number; + type: 'calendar' | 'fixed' | 'mixed'; + base: number; + }; +}; -const unitsMap = { +export const unitsMap: UnitsMap = { ms: { weight: 1, type: 'fixed', base: 1 }, s: { weight: 2, type: 'fixed', base: 1000 }, m: { weight: 3, type: 'mixed', base: 1000 * 60 }, @@ -30,13 +39,14 @@ const unitsMap = { // q: { weight: 8, type: 'calendar' }, // TODO: moment duration does not support quarter y: { weight: 9, type: 'calendar', base: NaN }, }; -const units = Object.keys(unitsMap).sort((a, b) => unitsMap[b].weight - unitsMap[a].weight); -const unitsDesc = [...units]; -const unitsAsc = [...units].reverse(); - -const isDate = (d) => Object.prototype.toString.call(d) === '[object Date]'; +export const units: Unit[] = Object.keys(unitsMap).sort( + (a, b) => unitsMap[b as Unit].weight - unitsMap[a as Unit].weight +) as Unit[]; +export const unitsDesc: Unit[] = [...units] as Unit[]; +export const unitsAsc: Unit[] = [...units].reverse() as Unit[]; -const isValidDate = (d) => isDate(d) && !isNaN(d.valueOf()); +const isDate = (d: string) => Object.prototype.toString.call(d) === '[object Date]'; +const isValidDate = (d: string) => isDate(d) && !isNaN(d.valueOf() as any); /* * This is a simplified version of elasticsearch's date parser. @@ -44,11 +54,17 @@ const isValidDate = (d) => isDate(d) && !isNaN(d.valueOf()); * will be done using this (and its locale settings) instead of the one bundled * with this library. */ -function parse(text, { roundUp = false, momentInstance = moment, forceNow } = {}) { +export function parse( + input: string, + options: { roundUp?: boolean; momentInstance?: typeof moment; forceNow?: Date } = {} +) { + const text = input; + const { roundUp = false, momentInstance = moment, forceNow } = options; + if (!text) return undefined; if (momentInstance.isMoment(text)) return text; if (isDate(text)) return momentInstance(text); - if (forceNow !== undefined && !isValidDate(forceNow)) { + if (forceNow !== undefined && !isValidDate(forceNow as any)) { throw new Error('forceNow must be a valid Date'); } @@ -80,7 +96,7 @@ function parse(text, { roundUp = false, momentInstance = moment, forceNow } = {} return parseDateMath(mathString, time, roundUp); } -function parseDateMath(mathString, time, roundUp) { +function parseDateMath(mathString: string, time: moment.Moment, roundUp: boolean) { const dateTime = time; const len = mathString.length; let i = 0; @@ -89,7 +105,7 @@ function parseDateMath(mathString, time, roundUp) { const c = mathString.charAt(i++); let type; let num; - let unit; + let unit: Unit; if (c === '/') { type = 0; @@ -101,13 +117,13 @@ function parseDateMath(mathString, time, roundUp) { return; } - if (isNaN(mathString.charAt(i))) { + if (isNaN(mathString.charAt(i) as any)) { num = 1; } else if (mathString.length === 2) { num = mathString.charAt(i); } else { const numFrom = i; - while (!isNaN(mathString.charAt(i))) { + while (!isNaN(mathString.charAt(i) as any)) { i++; if (i >= len) return; } @@ -121,7 +137,7 @@ function parseDateMath(mathString, time, roundUp) { } } - unit = mathString.charAt(i++); + unit = mathString.charAt(i++) as Unit; // append additional characters in the unit for (let j = i; j < len; j++) { @@ -138,12 +154,12 @@ function parseDateMath(mathString, time, roundUp) { return; } else { if (type === 0) { - if (roundUp) dateTime.endOf(unit); - else dateTime.startOf(unit); + if (roundUp) dateTime.endOf(unit as any); + else dateTime.startOf(unit as any); } else if (type === 1) { - dateTime.add(num, unit); + dateTime.add(num as any, unit); } else if (type === 2) { - dateTime.subtract(num, unit); + dateTime.subtract(num as any, unit); } } } @@ -151,8 +167,9 @@ function parseDateMath(mathString, time, roundUp) { return dateTime; } -module.exports = { - parse: parse, +// eslint-disable-next-line import/no-default-export +export default { + parse, unitsMap: Object.freeze(unitsMap), units: Object.freeze(units), unitsAsc: Object.freeze(unitsAsc), diff --git a/packages/elastic-datemath/tsconfig.json b/packages/elastic-datemath/tsconfig.json index cbfe1e8047433..6f04bee983a9e 100644 --- a/packages/elastic-datemath/tsconfig.json +++ b/packages/elastic-datemath/tsconfig.json @@ -1,9 +1,17 @@ { "extends": "../../tsconfig.base.json", "compilerOptions": { - "tsBuildInfoFile": "../../build/tsbuildinfo/packages/elastic-datemath" + "incremental": false, + "outDir": "./target", + "declaration": true, + "declarationMap": true, + "sourceMap": true, + "sourceRoot": "../../../../packages/elastic-datemath/src", + "types": [ + "node" + ] }, "include": [ - "index.d.ts" + "src/index.ts" ] } diff --git a/packages/kbn-ace/package.json b/packages/kbn-ace/package.json index f7ca76b35e7c2..30f37b4786f36 100644 --- a/packages/kbn-ace/package.json +++ b/packages/kbn-ace/package.json @@ -3,6 +3,7 @@ "version": "1.0.0", "private": true, "main": "./target/index.js", + "types": "./target/index.d.ts", "license": "SSPL-1.0 OR Elastic License 2.0", "scripts": { "build": "node ./scripts/build.js", diff --git a/packages/kbn-ace/tsconfig.json b/packages/kbn-ace/tsconfig.json index 6d3f433c6a6d1..9eef1ec56c6a2 100644 --- a/packages/kbn-ace/tsconfig.json +++ b/packages/kbn-ace/tsconfig.json @@ -1,13 +1,15 @@ { "extends": "../../tsconfig.base.json", "compilerOptions": { + "incremental": false, "outDir": "./target", "declaration": true, + "declarationMap": true, "sourceMap": true, + "sourceRoot": "../../../../packages/kbn-ace/src", "types": [ - "jest", "node" - ] + ], }, "include": [ "src/**/*" diff --git a/packages/kbn-analytics/tsconfig.json b/packages/kbn-analytics/tsconfig.json index 861e0204a31a2..c2e579e7fdbea 100644 --- a/packages/kbn-analytics/tsconfig.json +++ b/packages/kbn-analytics/tsconfig.json @@ -1,20 +1,19 @@ { "extends": "../../tsconfig.base.json", "compilerOptions": { - "declaration": true, - "emitDeclarationOnly": true, + "incremental": false, "outDir": "./target/types", "stripInternal": true, + "emitDeclarationOnly": true, + "declaration": true, "declarationMap": true, + "sourceMap": true, + "sourceRoot": "../../../../../packages/kbn-analytics/src", "types": [ - "jest", "node" ] }, "include": [ "src/**/*" - ], - "exclude": [ - "target" ] } diff --git a/packages/kbn-apm-config-loader/__fixtures__/config.yml b/packages/kbn-apm-config-loader/src/__fixtures__/config.yml similarity index 100% rename from packages/kbn-apm-config-loader/__fixtures__/config.yml rename to packages/kbn-apm-config-loader/src/__fixtures__/config.yml diff --git a/packages/kbn-apm-config-loader/__fixtures__/config_flat.yml b/packages/kbn-apm-config-loader/src/__fixtures__/config_flat.yml similarity index 100% rename from packages/kbn-apm-config-loader/__fixtures__/config_flat.yml rename to packages/kbn-apm-config-loader/src/__fixtures__/config_flat.yml diff --git a/packages/kbn-apm-config-loader/__fixtures__/en_var_ref_config.yml b/packages/kbn-apm-config-loader/src/__fixtures__/en_var_ref_config.yml similarity index 100% rename from packages/kbn-apm-config-loader/__fixtures__/en_var_ref_config.yml rename to packages/kbn-apm-config-loader/src/__fixtures__/en_var_ref_config.yml diff --git a/packages/kbn-apm-config-loader/__fixtures__/one.yml b/packages/kbn-apm-config-loader/src/__fixtures__/one.yml similarity index 100% rename from packages/kbn-apm-config-loader/__fixtures__/one.yml rename to packages/kbn-apm-config-loader/src/__fixtures__/one.yml diff --git a/packages/kbn-apm-config-loader/__fixtures__/two.yml b/packages/kbn-apm-config-loader/src/__fixtures__/two.yml similarity index 100% rename from packages/kbn-apm-config-loader/__fixtures__/two.yml rename to packages/kbn-apm-config-loader/src/__fixtures__/two.yml diff --git a/packages/kbn-apm-config-loader/src/utils/read_config.test.ts b/packages/kbn-apm-config-loader/src/utils/read_config.test.ts index 16fbb5ce7aed8..2838738c0ab6c 100644 --- a/packages/kbn-apm-config-loader/src/utils/read_config.test.ts +++ b/packages/kbn-apm-config-loader/src/utils/read_config.test.ts @@ -9,7 +9,7 @@ import { relative, resolve } from 'path'; import { getConfigFromFiles } from './read_config'; -const fixtureFile = (name: string) => resolve(__dirname, '..', '..', '__fixtures__', name); +const fixtureFile = (name: string) => resolve(__dirname, '..', '__fixtures__', name); test('reads single yaml from file system and parses to json', () => { const config = getConfigFromFiles([fixtureFile('config.yml')]); diff --git a/packages/kbn-apm-config-loader/tsconfig.json b/packages/kbn-apm-config-loader/tsconfig.json index ba00ddfa6adb6..250195785b931 100644 --- a/packages/kbn-apm-config-loader/tsconfig.json +++ b/packages/kbn-apm-config-loader/tsconfig.json @@ -1,12 +1,19 @@ { "extends": "../../tsconfig.base.json", "compilerOptions": { - "declaration": true, + "incremental": false, "outDir": "./target", "stripInternal": false, + "declaration": true, "declarationMap": true, - "types": ["jest", "node"] + "sourceMap": true, + "sourceRoot": "../../../../packages/kbn-apm-config-loader/src", + "types": [ + "jest", + "node" + ] }, - "include": ["./src/**/*.ts"], - "exclude": ["target"] + "include": [ + "src/**/*.ts" + ] } diff --git a/packages/kbn-apm-utils/tsconfig.json b/packages/kbn-apm-utils/tsconfig.json index e1f79b5ef394d..e08769aab6543 100644 --- a/packages/kbn-apm-utils/tsconfig.json +++ b/packages/kbn-apm-utils/tsconfig.json @@ -1,18 +1,18 @@ { "extends": "../../tsconfig.base.json", "compilerOptions": { - "declaration": true, + "incremental": false, "outDir": "./target", "stripInternal": false, + "declaration": true, "declarationMap": true, + "sourceMap": true, + "sourceRoot": "../../../../packages/kbn-apm-utils/src", "types": [ "node" ] }, "include": [ "./src/**/*.ts" - ], - "exclude": [ - "target" ] } diff --git a/packages/kbn-cli-dev-mode/tsconfig.json b/packages/kbn-cli-dev-mode/tsconfig.json index b2bdaf8ceea36..4436d27dbff88 100644 --- a/packages/kbn-cli-dev-mode/tsconfig.json +++ b/packages/kbn-cli-dev-mode/tsconfig.json @@ -1,11 +1,18 @@ { "extends": "../../tsconfig.base.json", "compilerOptions": { - "declaration": true, + "incremental": false, "outDir": "./target", + "declaration": true, "declarationMap": true, - "types": ["jest", "node"] + "sourceMap": true, + "sourceRoot": "../../../../packages/kbn-cli-dev-mode/src", + "types": [ + "jest", + "node" + ] }, - "include": ["./src/**/*.ts"], - "exclude": ["target"] + "include": [ + "./src/**/*.ts" + ], } diff --git a/packages/kbn-config-schema/tsconfig.json b/packages/kbn-config-schema/tsconfig.json index 6a268f2e7c016..d33683acded16 100644 --- a/packages/kbn-config-schema/tsconfig.json +++ b/packages/kbn-config-schema/tsconfig.json @@ -1,21 +1,21 @@ { "extends": "../../tsconfig.base.json", "compilerOptions": { - "declaration": true, - "declarationDir": "./target/types", + "incremental": false, "outDir": "./target/out", + "declarationDir": "./target/types", "stripInternal": true, + "declaration": true, "declarationMap": true, + "sourceMap": true, + "sourceRoot": "../../../../../packages/kbn-config-schema/src", "types": [ "jest", "node" ] }, "include": [ - "./types/joi.d.ts", - "./src/**/*.ts" - ], - "exclude": [ - "target" + "types/joi.d.ts", + "src/**/*.ts" ] } diff --git a/packages/kbn-config/__fixtures__/config.yml b/packages/kbn-config/src/__fixtures__/config.yml similarity index 100% rename from packages/kbn-config/__fixtures__/config.yml rename to packages/kbn-config/src/__fixtures__/config.yml diff --git a/packages/kbn-config/__fixtures__/config_flat.yml b/packages/kbn-config/src/__fixtures__/config_flat.yml similarity index 100% rename from packages/kbn-config/__fixtures__/config_flat.yml rename to packages/kbn-config/src/__fixtures__/config_flat.yml diff --git a/packages/kbn-config/__fixtures__/en_var_ref_config.yml b/packages/kbn-config/src/__fixtures__/en_var_ref_config.yml similarity index 100% rename from packages/kbn-config/__fixtures__/en_var_ref_config.yml rename to packages/kbn-config/src/__fixtures__/en_var_ref_config.yml diff --git a/packages/kbn-config/__fixtures__/one.yml b/packages/kbn-config/src/__fixtures__/one.yml similarity index 100% rename from packages/kbn-config/__fixtures__/one.yml rename to packages/kbn-config/src/__fixtures__/one.yml diff --git a/packages/kbn-config/__fixtures__/two.yml b/packages/kbn-config/src/__fixtures__/two.yml similarity index 100% rename from packages/kbn-config/__fixtures__/two.yml rename to packages/kbn-config/src/__fixtures__/two.yml diff --git a/packages/kbn-config/src/raw/read_config.test.ts b/packages/kbn-config/src/raw/read_config.test.ts index 3b56c69098d2c..d428fa6b0a2a1 100644 --- a/packages/kbn-config/src/raw/read_config.test.ts +++ b/packages/kbn-config/src/raw/read_config.test.ts @@ -9,7 +9,7 @@ import { relative, resolve } from 'path'; import { getConfigFromFiles } from './read_config'; -const fixtureFile = (name: string) => resolve(`${__dirname}/../../__fixtures__/${name}`); +const fixtureFile = (name: string) => resolve(`${__dirname}/../__fixtures__/${name}`); test('reads single yaml from file system and parses to json', () => { const config = getConfigFromFiles([fixtureFile('config.yml')]); diff --git a/packages/kbn-config/tsconfig.json b/packages/kbn-config/tsconfig.json index ba00ddfa6adb6..4e1bf573f488a 100644 --- a/packages/kbn-config/tsconfig.json +++ b/packages/kbn-config/tsconfig.json @@ -1,12 +1,22 @@ { "extends": "../../tsconfig.base.json", "compilerOptions": { - "declaration": true, + "incremental": false, "outDir": "./target", "stripInternal": false, + "declaration": true, "declarationMap": true, - "types": ["jest", "node"] + "sourceMap": true, + "sourceRoot": "../../../../packages/kbn-config/src", + "types": [ + "jest", + "node" + ] }, - "include": ["./src/**/*.ts"], - "exclude": ["target"] + "include": [ + "src/**/*.ts" + ], + "exclude": [ + "**/__fixtures__/**/*" + ] } diff --git a/packages/kbn-crypto/package.json b/packages/kbn-crypto/package.json index 6c7b3f3b0c719..7e26b96218319 100644 --- a/packages/kbn-crypto/package.json +++ b/packages/kbn-crypto/package.json @@ -4,6 +4,7 @@ "private": true, "license": "SSPL-1.0 OR Elastic License 2.0", "main": "./target/index.js", + "types": "./target/index.d.ts", "scripts": { "build": "../../node_modules/.bin/tsc", "kbn:bootstrap": "yarn build", diff --git a/packages/kbn-crypto/tsconfig.json b/packages/kbn-crypto/tsconfig.json index e9dd6313e6f79..5005152cac754 100644 --- a/packages/kbn-crypto/tsconfig.json +++ b/packages/kbn-crypto/tsconfig.json @@ -1,9 +1,12 @@ { "extends": "../../tsconfig.base.json", "compilerOptions": { - "outDir": "target", + "incremental": false, + "outDir": "./target", "declaration": true, - "declarationMap": true + "declarationMap": true, + "sourceMap": true, + "sourceRoot": "../../../../packages/kbn-crypto/src" }, "include": [ "src/**/*" diff --git a/packages/kbn-dev-utils/package.json b/packages/kbn-dev-utils/package.json index 7a2c3ce45a57d..e1990fca4e0bb 100644 --- a/packages/kbn-dev-utils/package.json +++ b/packages/kbn-dev-utils/package.json @@ -4,6 +4,7 @@ "private": true, "license": "SSPL-1.0 OR Elastic License 2.0", "main": "./target/index.js", + "types": "./target/index.d.ts", "scripts": { "build": "../../node_modules/.bin/tsc", "kbn:bootstrap": "yarn build", diff --git a/packages/kbn-dev-utils/tsconfig.json b/packages/kbn-dev-utils/tsconfig.json index 1c6c671d0b768..65536c576b679 100644 --- a/packages/kbn-dev-utils/tsconfig.json +++ b/packages/kbn-dev-utils/tsconfig.json @@ -1,10 +1,18 @@ { "extends": "../../tsconfig.base.json", "compilerOptions": { + "incremental": false, "outDir": "target", + "stripInternal": false, "target": "ES2019", "declaration": true, - "declarationMap": true + "declarationMap": true, + "sourceMap": true, + "sourceRoot": "../../../../packages/kbn-dev-utils/src", + "types": [ + "jest", + "node" + ] }, "include": [ "src/**/*" diff --git a/packages/kbn-docs-utils/package.json b/packages/kbn-docs-utils/package.json index 089732e9e6b40..26a7fa0e8c957 100644 --- a/packages/kbn-docs-utils/package.json +++ b/packages/kbn-docs-utils/package.json @@ -4,6 +4,7 @@ "license": "SSPL-1.0 OR Elastic License 2.0", "private": "true", "main": "target/index.js", + "types": "target/index.d.ts", "kibana": { "devOnly": true }, diff --git a/packages/kbn-docs-utils/tsconfig.json b/packages/kbn-docs-utils/tsconfig.json index 3c683f487b9f2..6f4a6fa2af8a5 100644 --- a/packages/kbn-docs-utils/tsconfig.json +++ b/packages/kbn-docs-utils/tsconfig.json @@ -1,10 +1,17 @@ { "extends": "../../tsconfig.base.json", "compilerOptions": { + "incremental": false, "outDir": "./target", + "target": "ES2019", "declaration": true, + "declarationMap": true, "sourceMap": true, - "target": "ES2019" + "sourceRoot": "../../../../packages/kbn-docs-utils/src", + "types": [ + "jest", + "node" + ] }, "include": [ "src/**/*" diff --git a/packages/kbn-es-archiver/package.json b/packages/kbn-es-archiver/package.json index 03ecee34be7e2..047d1dd675d26 100644 --- a/packages/kbn-es-archiver/package.json +++ b/packages/kbn-es-archiver/package.json @@ -4,6 +4,7 @@ "license": "SSPL-1.0 OR Elastic License 2.0", "private": "true", "main": "target/index.js", + "types": "target/index.d.ts", "kibana": { "devOnly": true }, diff --git a/packages/kbn-es-archiver/tsconfig.json b/packages/kbn-es-archiver/tsconfig.json index 02209a29e5817..0950cd39d0bee 100644 --- a/packages/kbn-es-archiver/tsconfig.json +++ b/packages/kbn-es-archiver/tsconfig.json @@ -1,10 +1,17 @@ { "extends": "../../tsconfig.base.json", "compilerOptions": { + "incremental": false, "outDir": "./target", + "target": "ES2019", "declaration": true, + "declarationMap": true, "sourceMap": true, - "target": "ES2019" + "sourceRoot": "../../../../packages/kbn-es-archiver/src", + "types": [ + "jest", + "node" + ] }, "include": [ "src/**/*" diff --git a/packages/kbn-i18n/tsconfig.json b/packages/kbn-i18n/tsconfig.json index c6380f1cde969..9d4cb8c9b0972 100644 --- a/packages/kbn-i18n/tsconfig.json +++ b/packages/kbn-i18n/tsconfig.json @@ -1,5 +1,18 @@ { "extends": "../../tsconfig.base.json", + "compilerOptions": { + "incremental": false, + "outDir": "./target/types", + "emitDeclarationOnly": true, + "declaration": true, + "declarationMap": true, + "sourceMap": true, + "sourceRoot": "../../../../../packages/kbn-i18n/src", + "types": [ + "jest", + "node" + ] + }, "include": [ "src/**/*.ts", "src/**/*.tsx", @@ -7,15 +20,6 @@ "types/intl_relativeformat.d.ts" ], "exclude": [ - "target" - ], - "compilerOptions": { - "declaration": true, - "emitDeclarationOnly": true, - "outDir": "./target/types", - "types": [ - "jest", - "node" - ] - } + "**/__fixtures__/**/*" + ] } diff --git a/packages/kbn-interpreter/common/package.json b/packages/kbn-interpreter/common/package.json index b569e42220f04..62061138234d9 100644 --- a/packages/kbn-interpreter/common/package.json +++ b/packages/kbn-interpreter/common/package.json @@ -1,5 +1,6 @@ { "private": true, "main": "../target/common/index.js", + "types": "../target/common/index.d.ts", "jsnext:main": "../src/common/index.js" } \ No newline at end of file diff --git a/packages/kbn-legacy-logging/package.json b/packages/kbn-legacy-logging/package.json index 1e3752eca6755..9450fd39607ea 100644 --- a/packages/kbn-legacy-logging/package.json +++ b/packages/kbn-legacy-logging/package.json @@ -4,6 +4,7 @@ "private": true, "license": "SSPL-1.0 OR Elastic License 2.0", "main": "./target/index.js", + "types": "./target/index.d.ts", "scripts": { "build": "tsc", "kbn:bootstrap": "yarn build", diff --git a/packages/kbn-legacy-logging/tsconfig.json b/packages/kbn-legacy-logging/tsconfig.json index 8fd202a2dce8b..5f8d38ec90bcd 100644 --- a/packages/kbn-legacy-logging/tsconfig.json +++ b/packages/kbn-legacy-logging/tsconfig.json @@ -1,11 +1,19 @@ { "extends": "../../tsconfig.base.json", "compilerOptions": { + "incremental": false, "outDir": "target", "stripInternal": false, "declaration": true, "declarationMap": true, - "types": ["jest", "node"] + "sourceMap": true, + "sourceRoot": "../../../../packages/kbn-legacy-logging/src", + "types": [ + "jest", + "node" + ] }, - "include": ["./src/**/*"] + "include": [ + "src/**/*" + ] } diff --git a/packages/kbn-logging/package.json b/packages/kbn-logging/package.json index 8d3ffa09b083e..c7db148c75a2a 100644 --- a/packages/kbn-logging/package.json +++ b/packages/kbn-logging/package.json @@ -4,6 +4,7 @@ "private": true, "license": "SSPL-1.0 OR Elastic License 2.0", "main": "./target/index.js", + "types": "./target/index.d.ts", "scripts": { "build": "../../node_modules/.bin/tsc", "kbn:bootstrap": "yarn build", diff --git a/packages/kbn-logging/tsconfig.json b/packages/kbn-logging/tsconfig.json index c55c05de30a52..adec4c1966036 100644 --- a/packages/kbn-logging/tsconfig.json +++ b/packages/kbn-logging/tsconfig.json @@ -1,11 +1,19 @@ { "extends": "../../tsconfig.base.json", "compilerOptions": { + "incremental": false, "outDir": "target", "stripInternal": false, "declaration": true, "declarationMap": true, - "types": ["jest", "node"] + "sourceMap": true, + "sourceRoot": "../../../../packages/kbn-logging/src", + "types": [ + "jest", + "node" + ] }, - "include": ["./src/**/*.ts"] + "include": [ + "src/**/*.ts" + ] } diff --git a/packages/kbn-monaco/package.json b/packages/kbn-monaco/package.json index e99661f8db598..bdf36915bab3a 100644 --- a/packages/kbn-monaco/package.json +++ b/packages/kbn-monaco/package.json @@ -3,6 +3,7 @@ "version": "1.0.0", "private": true, "main": "./target/index.js", + "types": "./target/index.d.ts", "license": "SSPL-1.0 OR Elastic License 2.0", "scripts": { "build": "node ./scripts/build.js", diff --git a/packages/kbn-monaco/tsconfig.json b/packages/kbn-monaco/tsconfig.json index 6d3f433c6a6d1..e6ec96b12c6cf 100644 --- a/packages/kbn-monaco/tsconfig.json +++ b/packages/kbn-monaco/tsconfig.json @@ -1,9 +1,12 @@ { "extends": "../../tsconfig.base.json", "compilerOptions": { + "incremental": false, "outDir": "./target", "declaration": true, + "declarationMap": true, "sourceMap": true, + "sourceRoot": "../../../../packages/kbn-monaco/src", "types": [ "jest", "node" diff --git a/packages/kbn-optimizer/index.d.ts b/packages/kbn-optimizer/index.d.ts deleted file mode 100644 index 004ac67f4b0c4..0000000000000 --- a/packages/kbn-optimizer/index.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ - -export * from './src/index'; diff --git a/packages/kbn-optimizer/package.json b/packages/kbn-optimizer/package.json index 29e33bf23424b..ac73fbc0fc16a 100644 --- a/packages/kbn-optimizer/package.json +++ b/packages/kbn-optimizer/package.json @@ -4,8 +4,9 @@ "private": true, "license": "SSPL-1.0 OR Elastic License 2.0", "main": "./target/index.js", + "types": "./target/index.d.ts", "scripts": { - "build": "../../node_modules/.bin/babel src --out-dir target --copy-files --delete-dir-on-start --extensions .ts --ignore *.test.ts --source-maps=inline", + "build": "../../node_modules/.bin/tsc", "kbn:bootstrap": "yarn build", "kbn:watch": "yarn build --watch" }, diff --git a/packages/kbn-optimizer/src/integration_tests/basic_optimization.test.ts b/packages/kbn-optimizer/src/integration_tests/basic_optimization.test.ts index 23b4c09f7a17c..da0a0cb7b75f2 100644 --- a/packages/kbn-optimizer/src/integration_tests/basic_optimization.test.ts +++ b/packages/kbn-optimizer/src/integration_tests/basic_optimization.test.ts @@ -16,7 +16,7 @@ import del from 'del'; import { tap, filter } from 'rxjs/operators'; import { REPO_ROOT } from '@kbn/utils'; import { ToolingLog } from '@kbn/dev-utils'; -import { runOptimizer, OptimizerConfig, OptimizerUpdate, logOptimizerState } from '@kbn/optimizer'; +import { runOptimizer, OptimizerConfig, OptimizerUpdate, logOptimizerState } from '../index'; import { allValuesFrom } from '../common'; @@ -135,7 +135,7 @@ it('builds expected bundles, saves bundle counts to metadata', async () => { /packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/plugins/foo/public/ext.ts, /packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/plugins/foo/public/index.ts, /packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/plugins/foo/public/lib.ts, - /packages/kbn-optimizer/target/worker/entry_point_creator.js, + /packages/kbn-optimizer/src/worker/entry_point_creator.ts, /packages/kbn-ui-shared-deps/public_path_module_creator.js, ] `); @@ -161,7 +161,7 @@ it('builds expected bundles, saves bundle counts to metadata', async () => { /packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/plugins/bar/public/lib.ts, /packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/src/core/public/core_app/styles/_globals_v7dark.scss, /packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/src/core/public/core_app/styles/_globals_v7light.scss, - /packages/kbn-optimizer/target/worker/entry_point_creator.js, + /packages/kbn-optimizer/src/worker/entry_point_creator.ts, /packages/kbn-ui-shared-deps/public_path_module_creator.js, ] `); @@ -175,7 +175,7 @@ it('builds expected bundles, saves bundle counts to metadata', async () => { Array [ /packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/x-pack/baz/kibana.json, /packages/kbn-optimizer/src/__fixtures__/__tmp__/mock_repo/x-pack/baz/public/index.ts, - /packages/kbn-optimizer/target/worker/entry_point_creator.js, + /packages/kbn-optimizer/src/worker/entry_point_creator.ts, /packages/kbn-ui-shared-deps/public_path_module_creator.js, ] `); diff --git a/packages/kbn-optimizer/src/optimizer/observe_worker.ts b/packages/kbn-optimizer/src/optimizer/observe_worker.ts index edf4545ae52b3..9f0ed9af556fb 100644 --- a/packages/kbn-optimizer/src/optimizer/observe_worker.ts +++ b/packages/kbn-optimizer/src/optimizer/observe_worker.ts @@ -61,18 +61,26 @@ function usingWorkerProc( ) { return Rx.using( (): ProcResource => { - const proc = execa.node(require.resolve('../worker/run_worker'), [], { - nodeOptions: [ - ...process.execArgv, - ...(inspectFlag && config.inspectWorkers - ? [`${inspectFlag}=${inspectPortCounter++}`] - : []), - ...(config.maxWorkerCount <= 3 ? ['--max-old-space-size=2048'] : []), - ], - buffer: false, - stderr: 'pipe', - stdout: 'pipe', - }); + const workerPath = require.resolve('../worker/run_worker'); + const proc = execa.node( + workerPath.endsWith('.ts') + ? require.resolve('../worker/run_worker_from_source') // workerFromSourcePath + : workerPath, + [], + { + nodeOptions: [ + '--preserve-symlinks', + '--preserve-symlinks-main', + ...(inspectFlag && config.inspectWorkers + ? [`${inspectFlag}=${inspectPortCounter++}`] + : []), + ...(config.maxWorkerCount <= 3 ? ['--max-old-space-size=2048'] : []), + ], + buffer: false, + stderr: 'pipe', + stdout: 'pipe', + } + ); return { proc, diff --git a/packages/kbn-optimizer/src/worker/bundle_ref_module.ts b/packages/kbn-optimizer/src/worker/bundle_ref_module.ts index 563b4ecb4bc37..f7604f0f78f71 100644 --- a/packages/kbn-optimizer/src/worker/bundle_ref_module.ts +++ b/packages/kbn-optimizer/src/worker/bundle_ref_module.ts @@ -16,7 +16,6 @@ export class BundleRefModule extends Module { public built = false; public buildMeta?: any; public buildInfo?: any; - public exportsArgument = '__webpack_exports__'; constructor(public readonly ref: BundleRef) { super('kbn/bundleRef', null); @@ -45,7 +44,9 @@ export class BundleRefModule extends Module { build(_: any, __: any, ___: any, ____: any, callback: () => void) { this.built = true; this.buildMeta = {}; - this.buildInfo = {}; + this.buildInfo = { + exportsArgument: '__webpack_exports__', + }; callback(); } diff --git a/packages/kbn-test/index.d.ts b/packages/kbn-optimizer/src/worker/run_worker_from_source.js similarity index 80% rename from packages/kbn-test/index.d.ts rename to packages/kbn-optimizer/src/worker/run_worker_from_source.js index 004ac67f4b0c4..bebe984a447d6 100644 --- a/packages/kbn-test/index.d.ts +++ b/packages/kbn-optimizer/src/worker/run_worker_from_source.js @@ -6,4 +6,5 @@ * Side Public License, v 1. */ -export * from './src/index'; +require('@kbn/optimizer').registerNodeAutoTranspilation(); +require('./run_worker'); diff --git a/packages/kbn-optimizer/tsconfig.json b/packages/kbn-optimizer/tsconfig.json index 20b06b5658cbc..f2d508cf14a55 100644 --- a/packages/kbn-optimizer/tsconfig.json +++ b/packages/kbn-optimizer/tsconfig.json @@ -1,10 +1,17 @@ { "extends": "../../tsconfig.base.json", "compilerOptions": { - "tsBuildInfoFile": "../../build/tsbuildinfo/packages/kbn-optimizer" + "incremental": false, + "outDir": "./target", + "declaration": true, + "declarationMap": true, + "sourceMap": true, + "sourceRoot": "../../../../packages/kbn-optimizer/src" }, "include": [ - "index.d.ts", "src/**/*" + ], + "exclude": [ + "**/__fixtures__/**/*" ] } diff --git a/packages/kbn-plugin-generator/package.json b/packages/kbn-plugin-generator/package.json index a0a18bfe7d1cb..ae4dfbc670f19 100644 --- a/packages/kbn-plugin-generator/package.json +++ b/packages/kbn-plugin-generator/package.json @@ -4,6 +4,7 @@ "private": true, "license": "SSPL-1.0 OR Elastic License 2.0", "main": "target/index.js", + "types": "target/index.d.ts", "scripts": { "kbn:bootstrap": "node scripts/build", "kbn:watch": "node scripts/build --watch" diff --git a/packages/kbn-plugin-generator/tsconfig.json b/packages/kbn-plugin-generator/tsconfig.json index c54ff041d7065..5e885527a7608 100644 --- a/packages/kbn-plugin-generator/tsconfig.json +++ b/packages/kbn-plugin-generator/tsconfig.json @@ -1,12 +1,22 @@ { "extends": "../../tsconfig.base.json", "compilerOptions": { + "incremental": false, "outDir": "target", "target": "ES2019", "declaration": true, "declarationMap": true, - "sourceMap": true + "sourceMap": true, + "sourceRoot": "../../../../packages/kbn-plugin-generator/src", + "types": [ + "jest", + "node" + ] }, - "include": ["src/**/*"], - "exclude": ["src/template/*"] + "include": [ + "src/**/*" + ], + "exclude": [ + "src/template/*" + ], } diff --git a/packages/kbn-plugin-helpers/package.json b/packages/kbn-plugin-helpers/package.json index cc845ef9d027f..6b9dd4d51baf9 100644 --- a/packages/kbn-plugin-helpers/package.json +++ b/packages/kbn-plugin-helpers/package.json @@ -8,6 +8,7 @@ "devOnly": true }, "main": "target/index.js", + "types": "target/index.d.ts", "bin": { "plugin-helpers": "bin/plugin-helpers.js" }, diff --git a/packages/kbn-plugin-helpers/tsconfig.json b/packages/kbn-plugin-helpers/tsconfig.json index 651bc79d6e707..87d11843f398a 100644 --- a/packages/kbn-plugin-helpers/tsconfig.json +++ b/packages/kbn-plugin-helpers/tsconfig.json @@ -1,10 +1,17 @@ { "extends": "../../tsconfig.base.json", "compilerOptions": { + "incremental": false, "outDir": "target", + "target": "ES2018", "declaration": true, + "declarationMap": true, "sourceMap": true, - "target": "ES2018" + "sourceRoot": "../../../../packages/kbn-plugin-helpers/src", + "types": [ + "jest", + "node" + ] }, "include": [ "src/**/*" diff --git a/packages/kbn-pm/dist/index.js b/packages/kbn-pm/dist/index.js index 9bf332bf82319..bcb0b6da2a2f8 100644 --- a/packages/kbn-pm/dist/index.js +++ b/packages/kbn-pm/dist/index.js @@ -550,7 +550,7 @@ Object.defineProperty(exports, "pickLevelFromFlags", { enumerable: true, get: fu Object.defineProperty(exports, "parseLogLevel", { enumerable: true, get: function () { return log_levels_1.parseLogLevel; } }); var tooling_log_collecting_writer_1 = __webpack_require__(127); Object.defineProperty(exports, "ToolingLogCollectingWriter", { enumerable: true, get: function () { return tooling_log_collecting_writer_1.ToolingLogCollectingWriter; } }); - +//# sourceMappingURL=index.js.map /***/ }), /* 6 */ @@ -628,7 +628,7 @@ class ToolingLog { } } exports.ToolingLog = ToolingLog; - +//# sourceMappingURL=tooling_log.js.map /***/ }), /* 7 */ @@ -6749,7 +6749,7 @@ class ToolingLogTextWriter { } } exports.ToolingLogTextWriter = ToolingLogTextWriter; - +//# sourceMappingURL=tooling_log_text_writer.js.map /***/ }), /* 112 */ @@ -8790,7 +8790,7 @@ function parseLogLevel(name) { }; } exports.parseLogLevel = parseLogLevel; - +//# sourceMappingURL=log_levels.js.map /***/ }), /* 127 */ @@ -8823,7 +8823,7 @@ class ToolingLogCollectingWriter extends tooling_log_text_writer_1.ToolingLogTex } } exports.ToolingLogCollectingWriter = ToolingLogCollectingWriter; - +//# sourceMappingURL=tooling_log_collecting_writer.js.map /***/ }), /* 128 */ @@ -54377,7 +54377,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = __webpack_require__(7); tslib_1.__exportStar(__webpack_require__(476), exports); tslib_1.__exportStar(__webpack_require__(477), exports); - +//# sourceMappingURL=index.js.map /***/ }), /* 476 */ @@ -54436,7 +54436,7 @@ function observeLines(readable) { operators_1.catchError(() => Rx.empty()))); } exports.observeLines = observeLines; - +//# sourceMappingURL=observe_lines.js.map /***/ }), /* 477 */ @@ -54465,7 +54465,7 @@ function observeReadable(readable) { return Rx.race(Rx.fromEvent(readable, 'end').pipe(operators_1.first(), operators_1.ignoreElements()), Rx.fromEvent(readable, 'error').pipe(operators_1.first(), operators_1.mergeMap((err) => Rx.throwError(err)))); } exports.observeReadable = observeReadable; - +//# sourceMappingURL=observe_readable.js.map /***/ }), /* 478 */ @@ -59798,7 +59798,7 @@ class CiStatsReporter { } } exports.CiStatsReporter = CiStatsReporter; - +//# sourceMappingURL=ci_stats_reporter.js.map /***/ }), /* 516 */ @@ -63258,7 +63258,7 @@ function parseConfig(log) { return; } exports.parseConfig = parseConfig; - +//# sourceMappingURL=ci_stats_config.js.map /***/ }), /* 557 */ diff --git a/packages/kbn-pm/tsconfig.json b/packages/kbn-pm/tsconfig.json index 175c4701f2e5b..558cff6556ff6 100644 --- a/packages/kbn-pm/tsconfig.json +++ b/packages/kbn-pm/tsconfig.json @@ -1,16 +1,14 @@ { "extends": "../../tsconfig.base.json", - "include": [ - "./index.d.ts", - "./src/**/*.ts", - "./dist/*.d.ts" - ], - "exclude": [], "compilerOptions": { "tsBuildInfoFile": "../../build/tsbuildinfo/packages/kbn-pm", "types": [ "jest", "node" ] - } + }, + "include": [ + "./index.d.ts", + "./src/**/*.ts" + ] } diff --git a/packages/kbn-server-http-tools/package.json b/packages/kbn-server-http-tools/package.json index a8f99689f3335..6c65a0dd6e475 100644 --- a/packages/kbn-server-http-tools/package.json +++ b/packages/kbn-server-http-tools/package.json @@ -1,6 +1,7 @@ { "name": "@kbn/server-http-tools", "main": "./target/index.js", + "types": "./target/index.d.ts", "version": "1.0.0", "license": "SSPL-1.0 OR Elastic License 2.0", "private": true, diff --git a/packages/kbn-server-http-tools/tsconfig.json b/packages/kbn-server-http-tools/tsconfig.json index ec84b963aed70..2f3e4626a04ce 100644 --- a/packages/kbn-server-http-tools/tsconfig.json +++ b/packages/kbn-server-http-tools/tsconfig.json @@ -1,14 +1,14 @@ { "extends": "../../tsconfig.base.json", "compilerOptions": { - "outDir": "target", + "incremental": false, + "outDir": "./target", "declaration": true, - "declarationMap": true + "declarationMap": true, + "sourceMap": true, + "sourceRoot": "../../../../packages/kbn-server-http-tools/src" }, "include": [ "src/**/*" - ], - "dependencies": { - "@kbn/std": "link:../kbn-std" - } + ] } diff --git a/packages/kbn-std/tsconfig.json b/packages/kbn-std/tsconfig.json index fd186a6e43d1c..d2ed46dcad6f8 100644 --- a/packages/kbn-std/tsconfig.json +++ b/packages/kbn-std/tsconfig.json @@ -1,13 +1,23 @@ { "extends": "../../tsconfig.base.json", "compilerOptions": { - "declaration": true, + "incremental": false, "declarationDir": "./target", "outDir": "./target", "stripInternal": true, + "declaration": true, "declarationMap": true, - "types": ["jest", "node"] + "sourceMap": true, + "sourceRoot": "../../../../packages/kbn-std/src", + "types": [ + "jest", + "node" + ] }, - "include": ["./src/**/*.ts"], - "exclude": ["target"] + "include": [ + "./src/**/*.ts" + ], + "exclude": [ + "**/__fixture__/**/*" + ] } diff --git a/packages/kbn-storybook/package.json b/packages/kbn-storybook/package.json index 75801948bb20b..fdc7359aab58d 100644 --- a/packages/kbn-storybook/package.json +++ b/packages/kbn-storybook/package.json @@ -4,6 +4,7 @@ "private": true, "license": "SSPL-1.0 OR Elastic License 2.0", "main": "./target/index.js", + "types": "./target/index.d.ts", "kibana": { "devOnly": true }, diff --git a/packages/kbn-storybook/tsconfig.json b/packages/kbn-storybook/tsconfig.json index 814a3963c9f49..db10d4630ff9c 100644 --- a/packages/kbn-storybook/tsconfig.json +++ b/packages/kbn-storybook/tsconfig.json @@ -1,9 +1,19 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "declaration": true, + "incremental": false, "outDir": "target", - "skipLibCheck": true + "skipLibCheck": true, + "declaration": true, + "declarationMap": true, + "sourceMap": true, + "sourceRoot": "../../../../packages/kbn-storybook", + "types": [ + "node" + ] }, - "include": ["*.ts", "lib/*.ts"] + "include": [ + "*.ts", + "lib/*.ts" + ] } diff --git a/packages/kbn-telemetry-tools/package.json b/packages/kbn-telemetry-tools/package.json index 28d67c73eb49e..2ae1f596a1c68 100644 --- a/packages/kbn-telemetry-tools/package.json +++ b/packages/kbn-telemetry-tools/package.json @@ -3,6 +3,7 @@ "version": "1.0.0", "license": "SSPL-1.0 OR Elastic License 2.0", "main": "./target/index.js", + "types": "./target/index.d.ts", "private": true, "kibana": { "devOnly": true diff --git a/packages/kbn-telemetry-tools/tsconfig.json b/packages/kbn-telemetry-tools/tsconfig.json index 98512053a5c92..39946fe9907e5 100644 --- a/packages/kbn-telemetry-tools/tsconfig.json +++ b/packages/kbn-telemetry-tools/tsconfig.json @@ -1,7 +1,12 @@ { "extends": "../../tsconfig.base.json", "compilerOptions": { - "tsBuildInfoFile": "../../build/tsbuildinfo/packages/kbn-telemetry-tools" + "incremental": false, + "outDir": "./target", + "declaration": true, + "declarationMap": true, + "sourceMap": true, + "sourceRoot": "../../../../packages/kbn-telemetry-tools/src" }, "include": [ "src/**/*", diff --git a/packages/kbn-test/package.json b/packages/kbn-test/package.json index 0f0ba8d79a1c1..a2dc8f84cfb51 100644 --- a/packages/kbn-test/package.json +++ b/packages/kbn-test/package.json @@ -4,6 +4,7 @@ "private": true, "license": "SSPL-1.0 OR Elastic License 2.0", "main": "./target/index.js", + "types": "./target/types/index.d.ts", "scripts": { "build": "node scripts/build", "kbn:bootstrap": "node scripts/build --source-maps", diff --git a/packages/kbn-test/src/functional_test_runner/fake_mocha_types.d.ts b/packages/kbn-test/src/functional_test_runner/fake_mocha_types.ts similarity index 100% rename from packages/kbn-test/src/functional_test_runner/fake_mocha_types.d.ts rename to packages/kbn-test/src/functional_test_runner/fake_mocha_types.ts diff --git a/packages/kbn-test/src/functional_test_runner/lib/index.ts b/packages/kbn-test/src/functional_test_runner/lib/index.ts index eef9e833fe5a8..1cb1e58a265d5 100644 --- a/packages/kbn-test/src/functional_test_runner/lib/index.ts +++ b/packages/kbn-test/src/functional_test_runner/lib/index.ts @@ -10,6 +10,7 @@ export { Lifecycle } from './lifecycle'; export { LifecyclePhase } from './lifecycle_phase'; export { readConfigFile, Config } from './config'; export { readProviderSpec, ProviderCollection } from './providers'; +// @internal export { runTests, setupMocha } from './mocha'; export { FailureMetadata } from './failure_metadata'; export * from './docker_servers'; diff --git a/packages/kbn-test/src/functional_test_runner/lib/mocha/index.ts b/packages/kbn-test/src/functional_test_runner/lib/mocha/index.ts index de55df34fa88b..4f27980db61d1 100644 --- a/packages/kbn-test/src/functional_test_runner/lib/mocha/index.ts +++ b/packages/kbn-test/src/functional_test_runner/lib/mocha/index.ts @@ -7,5 +7,7 @@ */ // @ts-ignore will be replaced shortly +// @internal export { setupMocha } from './setup_mocha'; +// @internal export { runTests } from './run_tests'; diff --git a/packages/kbn-test/src/index.ts b/packages/kbn-test/src/index.ts index 919dc8b4477f3..ef167bc5d7819 100644 --- a/packages/kbn-test/src/index.ts +++ b/packages/kbn-test/src/index.ts @@ -6,6 +6,7 @@ * Side Public License, v 1. */ +// @internal import { runTestsCli, processRunTestsCliOptions, @@ -14,27 +15,34 @@ import { // @ts-ignore not typed yet } from './functional_tests/cli'; +// @internal export { runTestsCli, processRunTestsCliOptions, startServersCli, processStartServersCliOptions }; // @ts-ignore not typed yet +// @internal export { runTests, startServers } from './functional_tests/tasks'; // @ts-ignore not typed yet +// @internal export { KIBANA_ROOT } from './functional_tests/lib/paths'; // @ts-ignore not typed yet +// @internal export { esTestConfig, createLegacyEsTestCluster } from './legacy_es'; // @ts-ignore not typed yet +// @internal export { kbnTestConfig, kibanaServerTestUser, kibanaTestUser, adminTestUser } from './kbn'; // @ts-ignore not typed yet +// @internal export { setupUsers, DEFAULT_SUPERUSER_PASS } from './functional_tests/lib/auth'; export { readConfigFile } from './functional_test_runner/lib/config/read_config_file'; export { runFtrCli } from './functional_test_runner/cli'; +// @internal export { setupJUnitReportGeneration, escapeCdata } from './mocha'; export { runFailedTestsReporterCli } from './failed_tests_reporter'; diff --git a/packages/kbn-test/src/kbn_archiver_cli.ts b/packages/kbn-test/src/kbn_archiver_cli.ts index 98bfa6eaa4046..04581a8354668 100644 --- a/packages/kbn-test/src/kbn_archiver_cli.ts +++ b/packages/kbn-test/src/kbn_archiver_cli.ts @@ -10,7 +10,7 @@ import Path from 'path'; import Url from 'url'; import { RunWithCommands, createFlagError, Flags } from '@kbn/dev-utils'; -import { KbnClient } from '@kbn/test'; +import { KbnClient } from './kbn_client'; import { readConfigFile } from './functional_test_runner'; diff --git a/packages/kbn-test/src/mocha/index.ts b/packages/kbn-test/src/mocha/index.ts index 1cff5202f33b9..4ada51c7ae013 100644 --- a/packages/kbn-test/src/mocha/index.ts +++ b/packages/kbn-test/src/mocha/index.ts @@ -7,8 +7,11 @@ */ // @ts-ignore not typed yet +// @internal export { setupJUnitReportGeneration } from './junit_report_generation'; // @ts-ignore not typed yet +// @internal export { recordLog, snapshotLogsForRunnable } from './log_cache'; // @ts-ignore not typed yet +// @internal export { escapeCdata } from './xml'; diff --git a/packages/kbn-test/tsconfig.json b/packages/kbn-test/tsconfig.json index 6d94389f82caa..8536ad7e0c12f 100644 --- a/packages/kbn-test/tsconfig.json +++ b/packages/kbn-test/tsconfig.json @@ -1,22 +1,26 @@ { "extends": "../../tsconfig.base.json", - "include": [ - "types/**/*", - "src/**/*", - "index.d.ts" - ], - "exclude": [ - "types/ftr_globals/**/*" - ], "compilerOptions": { - "declaration": true, - "emitDeclarationOnly": true, + "incremental": false, "outDir": "./target/types", + "stripInternal": true, + "emitDeclarationOnly": true, + "declaration": true, + "declarationMap": true, + "sourceMap": true, + "sourceRoot": "../../../../../packages/kbn-test/src", "types": [ "jest", "node" ], - "stripInternal": true, - "declarationMap": true - } + }, + "include": [ + "types/**/*", + "src/**/*", + "index.d.ts" + ], + "exclude": [ + "types/ftr_globals/**/*", + "**/__fixtures__/**/*" + ] } diff --git a/packages/kbn-utility-types/package.json b/packages/kbn-utility-types/package.json index 33419ee0f1ec4..ad7dcc6b906c3 100644 --- a/packages/kbn-utility-types/package.json +++ b/packages/kbn-utility-types/package.json @@ -3,7 +3,7 @@ "version": "1.0.0", "private": true, "license": "SSPL-1.0 OR Elastic License 2.0", - "main": "target", + "main": "target/index.js", "types": "target/index.d.ts", "kibana": { "devOnly": false diff --git a/packages/kbn-utility-types/tsconfig.json b/packages/kbn-utility-types/tsconfig.json index c2d206526e6f4..cfa782e5d38d2 100644 --- a/packages/kbn-utility-types/tsconfig.json +++ b/packages/kbn-utility-types/tsconfig.json @@ -1,18 +1,22 @@ { "extends": "../../tsconfig.base.json", "compilerOptions": { - "declaration": true, - "declarationDir": "./target", + "incremental": false, "outDir": "./target", + "declarationDir": "./target", "stripInternal": true, + "declaration": true, "declarationMap": true, + "sourceMap": true, + "sourceRoot": "../../../../packages/kbn-utility-types", "types": [ - "node", - "jest" + "jest", + "node" ] }, - "include": ["index.ts", "jest/**/*", "test-d/**/*"], - "exclude": [ - "target" + "include": [ + "index.ts", + "jest/**/*", + "test-d/**/*" ] } diff --git a/packages/kbn-utils/package.json b/packages/kbn-utils/package.json index 902eef82736fe..b6bb7759c40ef 100644 --- a/packages/kbn-utils/package.json +++ b/packages/kbn-utils/package.json @@ -1,6 +1,7 @@ { "name": "@kbn/utils", "main": "./target/index.js", + "types": "./target/index.d.ts", "version": "1.0.0", "license": "SSPL-1.0 OR Elastic License 2.0", "private": true, diff --git a/packages/kbn-utils/tsconfig.json b/packages/kbn-utils/tsconfig.json index e9dd6313e6f79..e6c83767c30dc 100644 --- a/packages/kbn-utils/tsconfig.json +++ b/packages/kbn-utils/tsconfig.json @@ -1,9 +1,16 @@ { "extends": "../../tsconfig.base.json", "compilerOptions": { + "incremental": false, "outDir": "target", "declaration": true, - "declarationMap": true + "declarationMap": true, + "sourceMap": true, + "sourceRoot": "../../../../packages/kbn-utils/src", + "types": [ + "jest", + "node" + ] }, "include": [ "src/**/*" diff --git a/src/core/test_helpers/kbn_server.ts b/src/core/test_helpers/kbn_server.ts index d702fed73778f..1844b5de3dc35 100644 --- a/src/core/test_helpers/kbn_server.ts +++ b/src/core/test_helpers/kbn_server.ts @@ -9,12 +9,19 @@ import { Client } from 'elasticsearch'; import { ToolingLog, REPO_ROOT } from '@kbn/dev-utils'; import { + // @ts-expect-error https://github.com/elastic/kibana/issues/95679 createLegacyEsTestCluster, + // @ts-expect-error https://github.com/elastic/kibana/issues/95679 DEFAULT_SUPERUSER_PASS, + // @ts-expect-error https://github.com/elastic/kibana/issues/95679 esTestConfig, + // @ts-expect-error https://github.com/elastic/kibana/issues/95679 kbnTestConfig, + // @ts-expect-error https://github.com/elastic/kibana/issues/95679 kibanaServerTestUser, + // @ts-expect-error https://github.com/elastic/kibana/issues/95679 kibanaTestUser, + // @ts-expect-error https://github.com/elastic/kibana/issues/95679 setupUsers, } from '@kbn/test'; import { defaultsDeep, get } from 'lodash'; diff --git a/tsconfig.base.json b/tsconfig.base.json index 865806cffe5bb..da4de5ef3712b 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -38,6 +38,8 @@ "moduleResolution": "node", // "resolveJsonModule" allows for importing, extracting types from and generating .json files. "resolveJsonModule": true, + // Do not resolve symlinks to their real path; treat a symlinked file like a real one. + "preserveSymlinks": true, // Disallow inconsistently-cased references to the same file. "forceConsistentCasingInFileNames": false, // Forbid unused local variables as the rule was deprecated by ts-lint diff --git a/x-pack/test/examples/config.ts b/x-pack/test/examples/config.ts index dd087772ae52c..fe1b5ce299447 100644 --- a/x-pack/test/examples/config.ts +++ b/x-pack/test/examples/config.ts @@ -8,6 +8,7 @@ import { FtrConfigProviderContext } from '@kbn/test/types/ftr'; import { resolve } from 'path'; import fs from 'fs'; +// @ts-expect-error https://github.com/elastic/kibana/issues/95679 import { KIBANA_ROOT } from '@kbn/test'; export default async function ({ readConfigFile }: FtrConfigProviderContext) { diff --git a/x-pack/test/functional/page_objects/security_page.ts b/x-pack/test/functional/page_objects/security_page.ts index 3c0ef7348a4b3..f153050018609 100644 --- a/x-pack/test/functional/page_objects/security_page.ts +++ b/x-pack/test/functional/page_objects/security_page.ts @@ -5,6 +5,7 @@ * 2.0. */ +// @ts-expect-error https://github.com/elastic/kibana/issues/95679 import { adminTestUser } from '@kbn/test'; import { FtrProviderContext } from '../ftr_provider_context'; import { AuthenticatedUser, Role } from '../../../plugins/security/common/model'; diff --git a/x-pack/test/functional_cors/config.ts b/x-pack/test/functional_cors/config.ts index 81870a948dc15..42e7771b14401 100644 --- a/x-pack/test/functional_cors/config.ts +++ b/x-pack/test/functional_cors/config.ts @@ -8,6 +8,7 @@ import Url from 'url'; import Path from 'path'; import type { FtrConfigProviderContext } from '@kbn/test/types/ftr'; +// @ts-expect-error https://github.com/elastic/kibana/issues/95679 import { kbnTestConfig } from '@kbn/test'; import { pageObjects } from '../functional/page_objects'; diff --git a/x-pack/test/functional_cors/plugins/kibana_cors_test/server/plugin.ts b/x-pack/test/functional_cors/plugins/kibana_cors_test/server/plugin.ts index e6c3f4b05aabd..e128ec6f13e77 100644 --- a/x-pack/test/functional_cors/plugins/kibana_cors_test/server/plugin.ts +++ b/x-pack/test/functional_cors/plugins/kibana_cors_test/server/plugin.ts @@ -6,6 +6,7 @@ */ import Hapi from '@hapi/hapi'; +// @ts-expect-error https://github.com/elastic/kibana/issues/95679 import { kbnTestConfig } from '@kbn/test'; import { take } from 'rxjs/operators'; import Url from 'url'; diff --git a/x-pack/test/licensing_plugin/config.public.ts b/x-pack/test/licensing_plugin/config.public.ts index 35f3bfa11fea0..0de536d7125ca 100644 --- a/x-pack/test/licensing_plugin/config.public.ts +++ b/x-pack/test/licensing_plugin/config.public.ts @@ -6,6 +6,7 @@ */ import path from 'path'; +// @ts-expect-error https://github.com/elastic/kibana/issues/95679 import { KIBANA_ROOT } from '@kbn/test'; import { FtrConfigProviderContext } from '@kbn/test/types/ftr'; diff --git a/x-pack/test/plugin_functional/config.ts b/x-pack/test/plugin_functional/config.ts index 9261650bb5d4e..5b846e414bd4c 100644 --- a/x-pack/test/plugin_functional/config.ts +++ b/x-pack/test/plugin_functional/config.ts @@ -7,6 +7,7 @@ import { resolve } from 'path'; import fs from 'fs'; +// @ts-expect-error https://github.com/elastic/kibana/issues/95679 import { KIBANA_ROOT } from '@kbn/test'; import { FtrConfigProviderContext } from '@kbn/test/types/ftr'; import { services } from './services'; diff --git a/x-pack/test/reporting_api_integration/reporting_and_security.config.ts b/x-pack/test/reporting_api_integration/reporting_and_security.config.ts index 6627cb3be5ed5..ddd6fe046dd31 100644 --- a/x-pack/test/reporting_api_integration/reporting_and_security.config.ts +++ b/x-pack/test/reporting_api_integration/reporting_and_security.config.ts @@ -5,6 +5,7 @@ * 2.0. */ +// @ts-expect-error https://github.com/elastic/kibana/issues/95679 import { esTestConfig, kbnTestConfig, kibanaServerTestUser } from '@kbn/test'; import { FtrConfigProviderContext } from '@kbn/test/types/ftr'; import { format as formatUrl } from 'url'; diff --git a/x-pack/test/reporting_api_integration/reporting_without_security.config.ts b/x-pack/test/reporting_api_integration/reporting_without_security.config.ts index 59d6074d9d8ca..20f9ff1b10592 100644 --- a/x-pack/test/reporting_api_integration/reporting_without_security.config.ts +++ b/x-pack/test/reporting_api_integration/reporting_without_security.config.ts @@ -5,6 +5,7 @@ * 2.0. */ +// @ts-expect-error https://github.com/elastic/kibana/issues/95679 import { esTestConfig, kbnTestConfig } from '@kbn/test'; import { FtrConfigProviderContext } from '@kbn/test/types/ftr'; import { format as formatUrl } from 'url'; diff --git a/x-pack/test/security_api_integration/tests/anonymous/login.ts b/x-pack/test/security_api_integration/tests/anonymous/login.ts index 183016316fcdb..3d1a05583e904 100644 --- a/x-pack/test/security_api_integration/tests/anonymous/login.ts +++ b/x-pack/test/security_api_integration/tests/anonymous/login.ts @@ -7,6 +7,7 @@ import expect from '@kbn/expect'; import request, { Cookie } from 'request'; +// @ts-expect-error https://github.com/elastic/kibana/issues/95679 import { adminTestUser } from '@kbn/test'; import { FtrProviderContext } from '../../ftr_provider_context'; diff --git a/x-pack/test/security_api_integration/tests/kerberos/kerberos_login.ts b/x-pack/test/security_api_integration/tests/kerberos/kerberos_login.ts index 2fe88dc21e5e0..3deb1408dc5c9 100644 --- a/x-pack/test/security_api_integration/tests/kerberos/kerberos_login.ts +++ b/x-pack/test/security_api_integration/tests/kerberos/kerberos_login.ts @@ -8,6 +8,7 @@ import expect from '@kbn/expect'; import request, { Cookie } from 'request'; import { delay } from 'bluebird'; +// @ts-expect-error https://github.com/elastic/kibana/issues/95679 import { adminTestUser } from '@kbn/test'; import { FtrProviderContext } from '../../ftr_provider_context'; import { diff --git a/x-pack/test/security_api_integration/tests/oidc/authorization_code_flow/oidc_auth.ts b/x-pack/test/security_api_integration/tests/oidc/authorization_code_flow/oidc_auth.ts index b2dd65b4f2009..c13ce902ad658 100644 --- a/x-pack/test/security_api_integration/tests/oidc/authorization_code_flow/oidc_auth.ts +++ b/x-pack/test/security_api_integration/tests/oidc/authorization_code_flow/oidc_auth.ts @@ -9,6 +9,7 @@ import expect from '@kbn/expect'; import request, { Cookie } from 'request'; import url from 'url'; import { delay } from 'bluebird'; +// @ts-expect-error https://github.com/elastic/kibana/issues/95679 import { adminTestUser } from '@kbn/test'; import { getStateAndNonce } from '../../../fixtures/oidc/oidc_tools'; import { FtrProviderContext } from '../../../ftr_provider_context'; diff --git a/x-pack/test/security_api_integration/tests/pki/pki_auth.ts b/x-pack/test/security_api_integration/tests/pki/pki_auth.ts index e3f63aad9e255..6eca9c354e248 100644 --- a/x-pack/test/security_api_integration/tests/pki/pki_auth.ts +++ b/x-pack/test/security_api_integration/tests/pki/pki_auth.ts @@ -11,6 +11,7 @@ import { delay } from 'bluebird'; import { readFileSync } from 'fs'; import { resolve } from 'path'; import { CA_CERT_PATH } from '@kbn/dev-utils'; +// @ts-expect-error https://github.com/elastic/kibana/issues/95679 import { adminTestUser } from '@kbn/test'; import { FtrProviderContext } from '../../ftr_provider_context'; diff --git a/x-pack/test/security_api_integration/tests/saml/saml_login.ts b/x-pack/test/security_api_integration/tests/saml/saml_login.ts index 598a65603e10f..c58f4d4373b1b 100644 --- a/x-pack/test/security_api_integration/tests/saml/saml_login.ts +++ b/x-pack/test/security_api_integration/tests/saml/saml_login.ts @@ -10,6 +10,7 @@ import url from 'url'; import { delay } from 'bluebird'; import expect from '@kbn/expect'; import request, { Cookie } from 'request'; +// @ts-expect-error https://github.com/elastic/kibana/issues/95679 import { adminTestUser } from '@kbn/test'; import { getLogoutRequest, diff --git a/x-pack/test/security_api_integration/tests/session_idle/cleanup.ts b/x-pack/test/security_api_integration/tests/session_idle/cleanup.ts index bb46beef41449..89bb79a4761a0 100644 --- a/x-pack/test/security_api_integration/tests/session_idle/cleanup.ts +++ b/x-pack/test/security_api_integration/tests/session_idle/cleanup.ts @@ -8,6 +8,7 @@ import request, { Cookie } from 'request'; import { delay } from 'bluebird'; import expect from '@kbn/expect'; +// @ts-expect-error https://github.com/elastic/kibana/issues/95679 import { adminTestUser } from '@kbn/test'; import type { AuthenticationProvider } from '../../../../plugins/security/common/model'; import { getSAMLRequestId, getSAMLResponse } from '../../fixtures/saml/saml_tools'; diff --git a/x-pack/test/security_api_integration/tests/session_invalidate/invalidate.ts b/x-pack/test/security_api_integration/tests/session_invalidate/invalidate.ts index 60605c88ce45e..db41aca86e0ba 100644 --- a/x-pack/test/security_api_integration/tests/session_invalidate/invalidate.ts +++ b/x-pack/test/security_api_integration/tests/session_invalidate/invalidate.ts @@ -7,6 +7,7 @@ import request, { Cookie } from 'request'; import expect from '@kbn/expect'; +// @ts-expect-error https://github.com/elastic/kibana/issues/95679 import { adminTestUser } from '@kbn/test'; import type { AuthenticationProvider } from '../../../../plugins/security/common/model'; import { getSAMLRequestId, getSAMLResponse } from '../../fixtures/saml/saml_tools'; diff --git a/x-pack/test/security_api_integration/tests/session_lifespan/cleanup.ts b/x-pack/test/security_api_integration/tests/session_lifespan/cleanup.ts index 0b17f037dfbd9..d2419ca07a434 100644 --- a/x-pack/test/security_api_integration/tests/session_lifespan/cleanup.ts +++ b/x-pack/test/security_api_integration/tests/session_lifespan/cleanup.ts @@ -8,6 +8,7 @@ import request, { Cookie } from 'request'; import { delay } from 'bluebird'; import expect from '@kbn/expect'; +// @ts-expect-error https://github.com/elastic/kibana/issues/95679 import { adminTestUser } from '@kbn/test'; import type { AuthenticationProvider } from '../../../../plugins/security/common/model'; import { getSAMLRequestId, getSAMLResponse } from '../../fixtures/saml/saml_tools'; diff --git a/x-pack/test/security_solution_endpoint/services/endpoint_telemetry.ts b/x-pack/test/security_solution_endpoint/services/endpoint_telemetry.ts index 646e0536c42f1..d91a772ccafac 100644 --- a/x-pack/test/security_solution_endpoint/services/endpoint_telemetry.ts +++ b/x-pack/test/security_solution_endpoint/services/endpoint_telemetry.ts @@ -7,6 +7,7 @@ import fs from 'fs'; import Path from 'path'; +// @ts-expect-error https://github.com/elastic/kibana/issues/95679 import { KIBANA_ROOT } from '@kbn/test'; import { FtrProviderContext } from '../ftr_provider_context';