From 93e4fb26bbec4b6c44d5114485fa158055a8310c Mon Sep 17 00:00:00 2001 From: Miki Date: Mon, 13 Nov 2023 09:57:31 -0800 Subject: [PATCH] Bump typescript and axios * Bump axios due to CVE-2023-45857 * Bump typescript, only in resolutions, to 4.6.4 - needed for newer axios Signed-off-by: Miki --- CHANGELOG.md | 2 ++ package.json | 2 +- packages/osd-babel-preset/common_preset.js | 4 ++-- packages/osd-cross-platform/src/repo_root.ts | 2 +- packages/osd-dev-utils/package.json | 2 +- .../src/osd_client/osd_client_requester.ts | 2 +- packages/osd-opensearch-archiver/src/cli.ts | 2 +- .../src/failed_tests_reporter/github_api.ts | 6 +++--- .../lib/lifecycle_phase.ts | 11 +++++----- packages/osd-ui-shared-deps/package.json | 4 ++-- packages/osd-ui-shared-deps/webpack.config.js | 11 ++++++++++ .../application/application_service.test.ts | 2 +- .../application_service.test.tsx | 8 ++++---- .../application/ui/app_container.test.tsx | 2 +- src/core/public/chrome/chrome_service.test.ts | 7 +++++-- src/core/public/chrome/chrome_service.tsx | 2 +- .../recently_accessed_service.test.ts | 2 -- src/core/public/context/context_service.ts | 2 +- src/core/public/core_app/core_app.ts | 4 ++-- .../public/doc_links/doc_links_service.ts | 2 +- .../fatal_errors/fatal_errors_service.tsx | 2 +- src/core/public/http/fetch.ts | 2 ++ .../injected_metadata_service.ts | 10 ++++++---- .../integrations/integrations_service.ts | 2 +- .../notifications/notifications_service.ts | 4 ++-- .../public/rendering/rendering_service.tsx | 2 +- .../public/ui_settings/ui_settings_api.ts | 2 +- .../public/ui_settings/ui_settings_client.ts | 2 +- .../public/ui_settings/ui_settings_service.ts | 2 +- src/core/server/context/context_service.ts | 2 +- src/core/server/http/http_service.ts | 2 +- .../server/http/router/response_adapter.ts | 4 +++- .../logging/appenders/file/file_appender.ts | 2 +- src/core/server/logging/logging_service.ts | 2 +- src/core/server/metrics/metrics_service.ts | 2 +- .../opensearch/client/cluster_client.test.ts | 8 ++++---- .../server/opensearch/opensearch_service.ts | 4 ++-- src/core/server/status/status_service.ts | 2 +- .../common/of.test.ts | 4 ++-- tsconfig.base.json | 1 + yarn.lock | 20 ++++++------------- 41 files changed, 87 insertions(+), 73 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8c903635f24d..76f705be6eed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Add support for TLS v1.3 ([#5133](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5133)) - [CVE-2023-45133] Add package resolution for `@babel/traverse` to `7.23.2` to fix vulnerability ([#5309](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5309)) - [CVE-2023-45133] Bump all babel dependencies from `7.16.x` to `7.22.9` to fix upstream vulnerability ([#5428](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5428)) +- [CVE-2023-45857] Bump `axios` from `0.27.2` to `1.6.1` ([#5470](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5470)) - [CVE-2023-46234] Bump `eslint-import-resolver-webpack` from `0.11.1` to `0.13.8` and `browserify-sign` from `4.2.1` to `4.2.2` ([#5414](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5414/)) ### 📈 Features/Enhancements @@ -112,6 +113,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Add @bandinib-amzn as maintainer ([#5113](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5113)) - Add @bandinib-amzn to CODEOWNERS file. ([#5456](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5456)) - Bump `chromedriver` from `107.0.3` to `119.0.1` ([#5465](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5465)) +- Bump `typescript` resolution from `4.0.2` to `4.6.4` ([#5470](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5470)) ### 🪛 Refactoring diff --git a/package.json b/package.json index cfb328ebb831..6711ac386da3 100644 --- a/package.json +++ b/package.json @@ -96,7 +96,7 @@ "**/node-jose": "^2.2.0", "**/nth-check": "^2.0.1", "**/trim": "^0.0.3", - "**/typescript": "4.0.2", + "**/typescript": "4.6.4", "**/unset-value": "^2.0.1", "**/jest-config": "npm:@amoo-miki/jest-config@27.5.1", "**/jest-jasmine2": "npm:@amoo-miki/jest-jasmine2@27.5.1", diff --git a/packages/osd-babel-preset/common_preset.js b/packages/osd-babel-preset/common_preset.js index 493c67afbcb1..dc324f6efd35 100644 --- a/packages/osd-babel-preset/common_preset.js +++ b/packages/osd-babel-preset/common_preset.js @@ -29,8 +29,8 @@ */ const plugins = [ - '@babel/plugin-transform-class-properties', - '@babel/plugin-transform-private-methods', + require.resolve('@babel/plugin-transform-class-properties'), + require.resolve('@babel/plugin-transform-private-methods'), require.resolve('babel-plugin-add-module-exports'), // Optional Chaining proposal is stage 4 (https://github.com/tc39/proposal-optional-chaining) diff --git a/packages/osd-cross-platform/src/repo_root.ts b/packages/osd-cross-platform/src/repo_root.ts index a7ffc19a7f7c..ea2975d19eb5 100644 --- a/packages/osd-cross-platform/src/repo_root.ts +++ b/packages/osd-cross-platform/src/repo_root.ts @@ -41,7 +41,7 @@ const readOpenSearchDashboardsPkgJson = (dir: string) => { return json; } } catch (error) { - if (error && error.code === 'ENOENT') { + if (error?.code === 'ENOENT') { return; } diff --git a/packages/osd-dev-utils/package.json b/packages/osd-dev-utils/package.json index a361388647c5..bfd7b0785807 100644 --- a/packages/osd-dev-utils/package.json +++ b/packages/osd-dev-utils/package.json @@ -15,7 +15,7 @@ "dependencies": { "@babel/core": "^7.22.9", "@osd/utils": "1.0.0", - "axios": "^0.27.2", + "axios": "^1.6.1", "chalk": "^4.1.0", "cheerio": "0.22.0", "dedent": "^0.7.0", diff --git a/packages/osd-dev-utils/src/osd_client/osd_client_requester.ts b/packages/osd-dev-utils/src/osd_client/osd_client_requester.ts index 807ec64b0e5a..1519497705bb 100644 --- a/packages/osd-dev-utils/src/osd_client/osd_client_requester.ts +++ b/packages/osd-dev-utils/src/osd_client/osd_client_requester.ts @@ -36,7 +36,7 @@ import { ToolingLog } from '../tooling_log'; const isConcliftOnGetError = (error: any) => { return ( - isAxiosResponseError(error) && error.config.method === 'GET' && error.response.status === 409 + isAxiosResponseError(error) && error.config?.method === 'GET' && error.response.status === 409 ); }; diff --git a/packages/osd-opensearch-archiver/src/cli.ts b/packages/osd-opensearch-archiver/src/cli.ts index e8606ed26645..78df5a2c6407 100644 --- a/packages/osd-opensearch-archiver/src/cli.ts +++ b/packages/osd-opensearch-archiver/src/cli.ts @@ -239,7 +239,7 @@ export function runCli() { output: process.stdout, }); - await new Promise((resolveInput) => { + await new Promise((resolveInput) => { rl.question(`Press enter when you're done`, () => { rl.close(); resolveInput(); diff --git a/packages/osd-test/src/failed_tests_reporter/github_api.ts b/packages/osd-test/src/failed_tests_reporter/github_api.ts index c9df43472585..d6be81e0cfe4 100644 --- a/packages/osd-test/src/failed_tests_reporter/github_api.ts +++ b/packages/osd-test/src/failed_tests_reporter/github_api.ts @@ -28,7 +28,7 @@ * under the License. */ -import Axios, { AxiosRequestConfig, AxiosInstance } from 'axios'; +import Axios, { AxiosRequestConfig, AxiosInstance, AxiosHeaderValue } from 'axios'; import parseLinkHeader from 'parse-link-header'; import { ToolingLog, isAxiosResponseError, isAxiosRequestError } from '@osd/dev-utils'; @@ -206,7 +206,7 @@ export class GithubApi { ): Promise<{ status: number; statusText: string; - headers: Record; + headers: Record; data: T; }> { const executeRequest = !this.dryRun || options.safeForDryRun; @@ -231,7 +231,7 @@ export class GithubApi { const githubApiFailed = isAxiosResponseError(error) && error.response.status >= 500; const errorResponseLog = isAxiosResponseError(error) && - `[${error.config.method} ${error.config.url}] ${error.response.status} ${error.response.statusText} Error`; + `[${error.config?.method} ${error.config?.url}] ${error.response.status} ${error.response.statusText} Error`; if ((unableToReachGithub || githubApiFailed) && attempt < maxAttempts) { const waitMs = 1000 * attempt; diff --git a/packages/osd-test/src/functional_test_runner/lib/lifecycle_phase.ts b/packages/osd-test/src/functional_test_runner/lib/lifecycle_phase.ts index 02106a4b1dd1..f39f5ee6420b 100644 --- a/packages/osd-test/src/functional_test_runner/lib/lifecycle_phase.ts +++ b/packages/osd-test/src/functional_test_runner/lib/lifecycle_phase.ts @@ -44,16 +44,17 @@ export class LifecyclePhase { private readonly beforeSubj = new Rx.Subject(); public readonly before$ = this.beforeSubj.asObservable(); - private readonly afterSubj = this.options.singular - ? new Rx.ReplaySubject(1) - : new Rx.Subject(); - public readonly after$ = this.afterSubj.asObservable(); + private readonly afterSubj: Rx.Subject; + public readonly after$: Rx.Observable; constructor( private readonly options: { singular?: boolean; } = {} - ) {} + ) { + this.afterSubj = this.options.singular ? new Rx.ReplaySubject(1) : new Rx.Subject(); + this.after$ = this.afterSubj.asObservable(); + } public add(fn: (...args: Args) => Promise | void) { this.handlers.push(fn); diff --git a/packages/osd-ui-shared-deps/package.json b/packages/osd-ui-shared-deps/package.json index ca6028d56acc..995c56887612 100644 --- a/packages/osd-ui-shared-deps/package.json +++ b/packages/osd-ui-shared-deps/package.json @@ -16,7 +16,7 @@ "@osd/i18n": "1.0.0", "@osd/monaco": "1.0.0", "abortcontroller-polyfill": "^1.4.0", - "axios": "^0.27.2", + "axios": "^1.6.1", "compression-webpack-plugin": "npm:@amoo-miki/compression-webpack-plugin@4.0.1-rc.1", "core-js": "^3.6.5", "custom-event-polyfill": "^0.3.0", @@ -51,4 +51,4 @@ "val-loader": "^2.1.2", "webpack": "npm:@amoo-miki/webpack@4.46.0-rc.2" } -} \ No newline at end of file +} diff --git a/packages/osd-ui-shared-deps/webpack.config.js b/packages/osd-ui-shared-deps/webpack.config.js index d9bfd81af523..80e7aeef9c44 100644 --- a/packages/osd-ui-shared-deps/webpack.config.js +++ b/packages/osd-ui-shared-deps/webpack.config.js @@ -131,6 +131,17 @@ exports.getWebpackConfig = ({ dev = false } = {}) => ({ }, ], }, + { + test: /worker_proxy_service\.js$/, + exclude: /node_modules/, + use: { + loader: 'babel-loader', + options: { + babelrc: false, + presets: [require.resolve('@osd/babel-preset/webpack_preset')], + }, + }, + }, ], }, diff --git a/src/core/public/application/application_service.test.ts b/src/core/public/application/application_service.test.ts index c03afbba2767..691ba64cf00a 100644 --- a/src/core/public/application/application_service.test.ts +++ b/src/core/public/application/application_service.test.ts @@ -708,7 +708,7 @@ describe('#start()', () => { // Create an app and a promise that allows us to control when the app completes mounting const createWaitingApp = (props: Partial): [App, () => void] => { let finishMount: () => void; - const mountPromise = new Promise((resolve) => (finishMount = resolve)); + const mountPromise = new Promise((resolve) => (finishMount = resolve)); const app = { id: 'some-id', title: 'some-title', diff --git a/src/core/public/application/integration_tests/application_service.test.tsx b/src/core/public/application/integration_tests/application_service.test.tsx index 1b659c0dec5f..9d53d99c9d8c 100644 --- a/src/core/public/application/integration_tests/application_service.test.tsx +++ b/src/core/public/application/integration_tests/application_service.test.tsx @@ -77,7 +77,7 @@ describe('ApplicationService', () => { const { register } = service.setup(setupDeps); let resolveMount: () => void; - const promise = new Promise((resolve) => { + const promise = new Promise((resolve) => { resolveMount = resolve; }); @@ -111,7 +111,7 @@ describe('ApplicationService', () => { const { register } = service.setup(setupDeps); let resolveMount: () => void; - const promise = new Promise((resolve) => { + const promise = new Promise((resolve) => { resolveMount = resolve; }); @@ -453,7 +453,7 @@ describe('ApplicationService', () => { const { register } = service.setup(setupDeps); let resolveMount: () => void; - const promise = new Promise((resolve) => { + const promise = new Promise((resolve) => { resolveMount = resolve; }); @@ -491,7 +491,7 @@ describe('ApplicationService', () => { const { register } = service.setup(setupDeps); let resolveMount: () => void; - const promise = new Promise((resolve) => { + const promise = new Promise((resolve) => { resolveMount = resolve; }); diff --git a/src/core/public/application/ui/app_container.test.tsx b/src/core/public/application/ui/app_container.test.tsx index e9e2caed02e0..3e658fa25665 100644 --- a/src/core/public/application/ui/app_container.test.tsx +++ b/src/core/public/application/ui/app_container.test.tsx @@ -50,7 +50,7 @@ describe('AppContainer', () => { }); const flushPromises = async () => { - await new Promise(async (resolve) => { + await new Promise(async (resolve) => { setImmediate(() => resolve()); }); }; diff --git a/src/core/public/chrome/chrome_service.test.ts b/src/core/public/chrome/chrome_service.test.ts index f11b0f3965e6..e91056ed7766 100644 --- a/src/core/public/chrome/chrome_service.test.ts +++ b/src/core/public/chrome/chrome_service.test.ts @@ -43,9 +43,12 @@ import { ChromeService } from './chrome_service'; import { getAppInfo } from '../application/utils'; class FakeApp implements App { - public title = `${this.id} App`; + public title: string; public mount = () => () => {}; - constructor(public id: string, public chromeless?: boolean) {} + + constructor(public id: string, public chromeless?: boolean) { + this.title = `${this.id} App`; + } } const store = new Map(); const originalLocalStorage = window.localStorage; diff --git a/src/core/public/chrome/chrome_service.tsx b/src/core/public/chrome/chrome_service.tsx index d094d86360ef..37ac2ba508a1 100644 --- a/src/core/public/chrome/chrome_service.tsx +++ b/src/core/public/chrome/chrome_service.tsx @@ -89,7 +89,7 @@ interface ConstructorParams { browserSupportsCsp: boolean; } -interface StartDeps { +export interface StartDeps { application: InternalApplicationStart; docLinks: DocLinksStart; http: HttpStart; diff --git a/src/core/public/chrome/recently_accessed/recently_accessed_service.test.ts b/src/core/public/chrome/recently_accessed/recently_accessed_service.test.ts index 7046d5efc236..90e72af35652 100644 --- a/src/core/public/chrome/recently_accessed/recently_accessed_service.test.ts +++ b/src/core/public/chrome/recently_accessed/recently_accessed_service.test.ts @@ -69,11 +69,9 @@ describe('RecentlyAccessed#start()', () => { // @ts-expect-error to allow redeclaring a readonly prop delete window.localStorage; - // @ts-expect-error window.localStorage = new LocalStorageMock(); }); beforeEach(() => localStorage.clear()); - // @ts-expect-error afterAll(() => (window.localStorage = originalLocalStorage)); const getStart = async () => { diff --git a/src/core/public/context/context_service.ts b/src/core/public/context/context_service.ts index 5071288a1405..433e96c48d8b 100644 --- a/src/core/public/context/context_service.ts +++ b/src/core/public/context/context_service.ts @@ -32,7 +32,7 @@ import { PluginOpaqueId } from '../../server'; import { IContextContainer, ContextContainer, HandlerFunction } from '../../utils/context'; import { CoreContext } from '../core_system'; -interface StartDeps { +export interface StartDeps { pluginDependencies: ReadonlyMap; } diff --git a/src/core/public/core_app/core_app.ts b/src/core/public/core_app/core_app.ts index fcbcc5de5655..e1e91b775374 100644 --- a/src/core/public/core_app/core_app.ts +++ b/src/core/public/core_app/core_app.ts @@ -43,14 +43,14 @@ import type { InjectedMetadataSetup } from '../injected_metadata'; import { renderApp as renderErrorApp, setupUrlOverflowDetection } from './errors'; import { renderApp as renderStatusApp } from './status'; -interface SetupDeps { +export interface SetupDeps { application: InternalApplicationSetup; http: HttpSetup; injectedMetadata: InjectedMetadataSetup; notifications: NotificationsSetup; } -interface StartDeps { +export interface StartDeps { application: InternalApplicationStart; http: HttpStart; notifications: NotificationsStart; diff --git a/src/core/public/doc_links/doc_links_service.ts b/src/core/public/doc_links/doc_links_service.ts index 0acf4524ab14..d73a663a64b3 100644 --- a/src/core/public/doc_links/doc_links_service.ts +++ b/src/core/public/doc_links/doc_links_service.ts @@ -32,7 +32,7 @@ import { deepFreeze } from '@osd/std'; import { parse } from 'semver'; import { InjectedMetadataSetup } from '../injected_metadata'; -interface StartDeps { +export interface StartDeps { injectedMetadata: InjectedMetadataSetup; } diff --git a/src/core/public/fatal_errors/fatal_errors_service.tsx b/src/core/public/fatal_errors/fatal_errors_service.tsx index 59a23171ed17..73159ff20e4d 100644 --- a/src/core/public/fatal_errors/fatal_errors_service.tsx +++ b/src/core/public/fatal_errors/fatal_errors_service.tsx @@ -38,7 +38,7 @@ import { InjectedMetadataSetup } from '../injected_metadata'; import { FatalErrorsScreen } from './fatal_errors_screen'; import { FatalErrorInfo, getErrorInfo } from './get_error_info'; -interface Deps { +export interface Deps { i18n: I18nStart; injectedMetadata: InjectedMetadataSetup; } diff --git a/src/core/public/http/fetch.ts b/src/core/public/http/fetch.ts index 767d58643003..3dc89c63cb39 100644 --- a/src/core/public/http/fetch.ts +++ b/src/core/public/http/fetch.ts @@ -212,6 +212,8 @@ export class Fetch { } private shorthand(method: string): HttpHandler { + // ToDo: find why 'TResponseBody' of HttpHandler is not assignable to type 'HttpResponse' + // @ts-expect-error return (pathOrOptions: string | HttpFetchOptionsWithPath, options?: HttpFetchOptions) => { const optionsWithPath = validateFetchArguments(pathOrOptions, options); return this.fetch({ ...optionsWithPath, method }); diff --git a/src/core/public/injected_metadata/injected_metadata_service.ts b/src/core/public/injected_metadata/injected_metadata_service.ts index f4c6a7f7b91a..6be782c3673c 100644 --- a/src/core/public/injected_metadata/injected_metadata_service.ts +++ b/src/core/public/injected_metadata/injected_metadata_service.ts @@ -88,11 +88,13 @@ export interface InjectedMetadataParams { * @internal */ export class InjectedMetadataService { - private state = deepFreeze( - this.params.injectedMetadata - ) as InjectedMetadataParams['injectedMetadata']; + private state: InjectedMetadataParams['injectedMetadata']; - constructor(private readonly params: InjectedMetadataParams) {} + constructor(private readonly params: InjectedMetadataParams) { + this.state = deepFreeze( + this.params.injectedMetadata + ) as InjectedMetadataParams['injectedMetadata']; + } public start(): InjectedMetadataStart { return this.setup(); diff --git a/src/core/public/integrations/integrations_service.ts b/src/core/public/integrations/integrations_service.ts index df92f0b76d95..4c133eff82ba 100644 --- a/src/core/public/integrations/integrations_service.ts +++ b/src/core/public/integrations/integrations_service.ts @@ -34,7 +34,7 @@ import { CoreService } from '../../types'; import { MomentService } from './moment'; import { StylesService } from './styles'; -interface Deps { +export interface Deps { uiSettings: IUiSettingsClient; } diff --git a/src/core/public/notifications/notifications_service.ts b/src/core/public/notifications/notifications_service.ts index fcdf746f2ae6..3f3d2bdf3ac2 100644 --- a/src/core/public/notifications/notifications_service.ts +++ b/src/core/public/notifications/notifications_service.ts @@ -36,11 +36,11 @@ import { ToastsService, ToastsSetup, ToastsStart } from './toasts'; import { IUiSettingsClient } from '../ui_settings'; import { OverlayStart } from '../overlays'; -interface SetupDeps { +export interface SetupDeps { uiSettings: IUiSettingsClient; } -interface StartDeps { +export interface StartDeps { i18n: I18nStart; overlays: OverlayStart; targetDomElement: HTMLElement; diff --git a/src/core/public/rendering/rendering_service.tsx b/src/core/public/rendering/rendering_service.tsx index ffb147bc39fc..83168bb745e5 100644 --- a/src/core/public/rendering/rendering_service.tsx +++ b/src/core/public/rendering/rendering_service.tsx @@ -37,7 +37,7 @@ import { InternalApplicationStart } from '../application'; import { OverlayStart } from '../overlays'; import { AppWrapper, AppContainer } from './app_containers'; -interface StartDeps { +export interface StartDeps { application: InternalApplicationStart; chrome: InternalChromeStart; overlays: OverlayStart; diff --git a/src/core/public/ui_settings/ui_settings_api.ts b/src/core/public/ui_settings/ui_settings_api.ts index d8a68ac035a2..62e06cf571c4 100644 --- a/src/core/public/ui_settings/ui_settings_api.ts +++ b/src/core/public/ui_settings/ui_settings_api.ts @@ -66,7 +66,7 @@ export class UiSettingsApi { * before sending the next request */ public batchSet(key: string, value: any) { - return new Promise((resolve, reject) => { + return new Promise((resolve, reject) => { const prev = this.pendingChanges || NOOP_CHANGES; this.pendingChanges = { diff --git a/src/core/public/ui_settings/ui_settings_client.ts b/src/core/public/ui_settings/ui_settings_client.ts index d2015468befa..a234551c4bf5 100644 --- a/src/core/public/ui_settings/ui_settings_client.ts +++ b/src/core/public/ui_settings/ui_settings_client.ts @@ -198,7 +198,7 @@ You can use \`IUiSettingsClient.get("${key}", defaultValue)\`, which will just r this.setLocally(key, newVal); try { - const { settings } = await this.api.batchSet(key, newVal); + const { settings } = (await this.api.batchSet(key, newVal)) || {}; this.cache = defaultsDeep({}, defaults, settings); this.saved$.next({ key, newValue: newVal, oldValue: initialVal }); return true; diff --git a/src/core/public/ui_settings/ui_settings_service.ts b/src/core/public/ui_settings/ui_settings_service.ts index 9c677ff1c990..10c6b9ed784a 100644 --- a/src/core/public/ui_settings/ui_settings_service.ts +++ b/src/core/public/ui_settings/ui_settings_service.ts @@ -37,7 +37,7 @@ import { UiSettingsApi } from './ui_settings_api'; import { UiSettingsClient } from './ui_settings_client'; import { IUiSettingsClient } from './types'; -interface UiSettingsServiceDeps { +export interface UiSettingsServiceDeps { http: HttpSetup; injectedMetadata: InjectedMetadataSetup; } diff --git a/src/core/server/context/context_service.ts b/src/core/server/context/context_service.ts index fd8ede37a832..2ec1234b754a 100644 --- a/src/core/server/context/context_service.ts +++ b/src/core/server/context/context_service.ts @@ -32,7 +32,7 @@ import { PluginOpaqueId } from '../../server'; import { IContextContainer, ContextContainer, HandlerFunction } from '../../utils/context'; import { CoreContext } from '../core_context'; -interface SetupDeps { +export interface SetupDeps { pluginDependencies: ReadonlyMap; } diff --git a/src/core/server/http/http_service.ts b/src/core/server/http/http_service.ts index 8627557c7332..ed1da8754721 100644 --- a/src/core/server/http/http_service.ts +++ b/src/core/server/http/http_service.ts @@ -56,7 +56,7 @@ import { import { RequestHandlerContext } from '../../server'; import { registerCoreHandlers } from './lifecycle_handlers'; -interface SetupDeps { +export interface SetupDeps { context: ContextSetup; } diff --git a/src/core/server/http/router/response_adapter.ts b/src/core/server/http/router/response_adapter.ts index 08dcaf1e9c60..f61d1f93c301 100644 --- a/src/core/server/http/router/response_adapter.ts +++ b/src/core/server/http/router/response_adapter.ts @@ -117,7 +117,9 @@ export class HapiResponseAdapter { private toRedirect( opensearchDashboardsResponse: OpenSearchDashboardsResponse ) { - const { headers } = opensearchDashboardsResponse.options; + const { + headers, + }: { headers?: Record } = opensearchDashboardsResponse.options; if (!headers || typeof headers.location !== 'string') { throw new Error("expected 'location' header to be set"); } diff --git a/src/core/server/logging/appenders/file/file_appender.ts b/src/core/server/logging/appenders/file/file_appender.ts index 87959641e9fb..9d00d26fe654 100644 --- a/src/core/server/logging/appenders/file/file_appender.ts +++ b/src/core/server/logging/appenders/file/file_appender.ts @@ -82,7 +82,7 @@ export class FileAppender implements DisposableAppender { * Disposes `FileAppender`. Waits for the underlying file stream to be completely flushed and closed. */ public async dispose() { - await new Promise((resolve) => { + await new Promise((resolve) => { if (this.outputStream === undefined) { return resolve(); } diff --git a/src/core/server/logging/logging_service.ts b/src/core/server/logging/logging_service.ts index 7459d4b1790c..80a67f1265f8 100644 --- a/src/core/server/logging/logging_service.ts +++ b/src/core/server/logging/logging_service.ts @@ -68,7 +68,7 @@ export interface InternalLoggingServiceSetup { configure(contextParts: string[], config$: Observable): void; } -interface SetupDeps { +export interface SetupDeps { loggingSystem: ILoggingSystem; } diff --git a/src/core/server/metrics/metrics_service.ts b/src/core/server/metrics/metrics_service.ts index 62e1c9706309..4181d40e4bce 100644 --- a/src/core/server/metrics/metrics_service.ts +++ b/src/core/server/metrics/metrics_service.ts @@ -38,7 +38,7 @@ import { InternalMetricsServiceSetup, InternalMetricsServiceStart, OpsMetrics } import { OpsMetricsCollector } from './ops_metrics_collector'; import { opsConfig, OpsConfigType } from './ops_config'; -interface MetricsServiceSetupDeps { +export interface MetricsServiceSetupDeps { http: InternalHttpServiceSetup; } diff --git a/src/core/server/opensearch/client/cluster_client.test.ts b/src/core/server/opensearch/client/cluster_client.test.ts index 046939072710..c188426e8517 100644 --- a/src/core/server/opensearch/client/cluster_client.test.ts +++ b/src/core/server/opensearch/client/cluster_client.test.ts @@ -530,7 +530,7 @@ describe('ClusterClient', () => { let closeScopedClientWithLongNumeralsSupport: () => void; internalClient.close.mockReturnValue( - new Promise((resolve) => { + new Promise((resolve) => { closeInternalClient = resolve; }).then(() => { expect(clusterClientClosed).toBe(false); @@ -538,7 +538,7 @@ describe('ClusterClient', () => { }) ); scopedClient.close.mockReturnValue( - new Promise((resolve) => { + new Promise((resolve) => { closeScopedClient = resolve; }).then(() => { expect(clusterClientClosed).toBe(false); @@ -546,7 +546,7 @@ describe('ClusterClient', () => { }) ); internalClientWithLongNumeralsSupport.close.mockReturnValue( - new Promise((resolve) => { + new Promise((resolve) => { closeInternalClientWithLongNumeralsSupport = resolve; }).then(() => { expect(clusterClientClosed).toBe(false); @@ -554,7 +554,7 @@ describe('ClusterClient', () => { }) ); scopedClientWithLongNumeralsSupport.close.mockReturnValue( - new Promise((resolve) => { + new Promise((resolve) => { closeScopedClientWithLongNumeralsSupport = resolve; }).then(() => { expect(clusterClientClosed).toBe(false); diff --git a/src/core/server/opensearch/opensearch_service.ts b/src/core/server/opensearch/opensearch_service.ts index bab3e7ede9f3..6881ce06a0d5 100644 --- a/src/core/server/opensearch/opensearch_service.ts +++ b/src/core/server/opensearch/opensearch_service.ts @@ -48,11 +48,11 @@ import { InternalOpenSearchServiceSetup, InternalOpenSearchServiceStart } from ' import { pollOpenSearchNodesVersion } from './version_check/ensure_opensearch_version'; import { calculateStatus$ } from './status'; -interface SetupDeps { +export interface SetupDeps { http: InternalHttpServiceSetup; } -interface StartDeps { +export interface StartDeps { auditTrail: AuditTrailStart; } diff --git a/src/core/server/status/status_service.ts b/src/core/server/status/status_service.ts index 10547e510fa6..d243aa4f5045 100644 --- a/src/core/server/status/status_service.ts +++ b/src/core/server/status/status_service.ts @@ -48,7 +48,7 @@ import { ServiceStatus, CoreStatus, InternalStatusServiceSetup } from './types'; import { getSummaryStatus } from './get_summary_status'; import { PluginsStatusService } from './plugins_status'; -interface SetupDeps { +export interface SetupDeps { opensearch: Pick; environment: InternalEnvironmentServiceSetup; pluginDependencies: ReadonlyMap; diff --git a/src/plugins/opensearch_dashboards_utils/common/of.test.ts b/src/plugins/opensearch_dashboards_utils/common/of.test.ts index 499f831042e4..66280559d9b0 100644 --- a/src/plugins/opensearch_dashboards_utils/common/of.test.ts +++ b/src/plugins/opensearch_dashboards_utils/common/of.test.ts @@ -32,7 +32,7 @@ import { of } from './of'; describe('of()', () => { describe('when promise resolves', () => { - const promise = new Promise((resolve) => resolve()).then(() => 123); + const promise = new Promise((resolve) => resolve()).then(() => 123); test('first member of 3-tuple is the promise value', async () => { const [result] = await of(promise); @@ -51,7 +51,7 @@ describe('of()', () => { }); describe('when promise rejects', () => { - const promise = new Promise((resolve) => resolve()).then(() => { + const promise = new Promise((resolve) => resolve()).then(() => { // eslint-disable-next-line no-throw-literal throw 123; }); diff --git a/tsconfig.base.json b/tsconfig.base.json index 5d4321fac3b0..981ed82dd77a 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -50,6 +50,7 @@ "downlevelIteration": true, // import tslib helpers rather than inlining helpers for iteration or spreading, for instance "importHelpers": true, + "useUnknownInCatchVariables": false, // adding global typings "types": [ "node", diff --git a/yarn.lock b/yarn.lock index ffbb66b6c21f..ef1661d7a82d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5109,15 +5109,7 @@ axe-core@^4.0.2, axe-core@^4.3.5: resolved "https://registry.yarnpkg.com/axe-core/-/axe-core-4.4.1.tgz#7dbdc25989298f9ad006645cd396782443757413" integrity sha512-gd1kmb21kwNuWr6BQz8fv6GNECPBnUasepcoLbekws23NVBLODdsClRZ+bQ8+9Uomf3Sm3+Vwn0oYG9NvwnJCw== -axios@^0.27.2: - version "0.27.2" - resolved "https://registry.yarnpkg.com/axios/-/axios-0.27.2.tgz#207658cc8621606e586c85db4b41a750e756d972" - integrity sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ== - dependencies: - follow-redirects "^1.14.9" - form-data "^4.0.0" - -axios@^1.6.0: +axios@^1.6.0, axios@^1.6.1: version "1.6.1" resolved "https://registry.yarnpkg.com/axios/-/axios-1.6.1.tgz#76550d644bf0a2d469a01f9244db6753208397d7" integrity sha512-vfBmhDpKafglh0EldBEbVuoe7DyAavGSLWhuSm5ZSEKQnHhBf0xAAwybbNH1IkrJNGnS/VG4I5yxig1pCEXE4g== @@ -9109,7 +9101,7 @@ focus-lock@^0.10.2: dependencies: tslib "^2.0.3" -follow-redirects@^1.14.9, follow-redirects@^1.15.0: +follow-redirects@^1.15.0: version "1.15.2" resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.2.tgz#b460864144ba63f2681096f274c4e57026da2c13" integrity sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA== @@ -17971,10 +17963,10 @@ typedarray@^0.0.6: resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c= -typescript@4.0.2, typescript@~4.5.2: - version "4.0.2" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.0.2.tgz#7ea7c88777c723c681e33bf7988be5d008d05ac2" - integrity sha512-e4ERvRV2wb+rRZ/IQeb3jm2VxBsirQLpQhdxplZ2MEzGvDkkMmPglecnNDfSUBivMjP93vRbngYYDQqQ/78bcQ== +typescript@4.0.2, typescript@4.6.4, typescript@~4.5.2: + version "4.6.4" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.6.4.tgz#caa78bbc3a59e6a5c510d35703f6a09877ce45e9" + integrity sha512-9ia/jWHIEbo49HfjrLGfKbZSuWo9iTMwXO+Ca3pRsSpbsMbc7/IU8NKdCZVRRBafVPGnoJeFL76ZOAA84I9fEg== uc.micro@^1.0.1, uc.micro@^1.0.5: version "1.0.6"