diff --git a/src/legacy/core_plugins/kibana/public/context/query_parameters/state.js b/src/legacy/core_plugins/opensearch-dashboards/public/context/query_parameters/state.js similarity index 100% rename from src/legacy/core_plugins/kibana/public/context/query_parameters/state.js rename to src/legacy/core_plugins/opensearch-dashboards/public/context/query_parameters/state.js diff --git a/src/legacy/server/config/complete.js b/src/legacy/server/config/complete.js index 7dbb3a722e38..f6578ff69bc0 100644 --- a/src/legacy/server/config/complete.js +++ b/src/legacy/server/config/complete.js @@ -17,8 +17,8 @@ * under the License. */ -export default function (kbnServer, server) { +export default function (osdServer, server) { server.decorate('server', 'config', function () { - return kbnServer.config; + return osdServer.config; }); } diff --git a/src/legacy/server/config/complete.test.js b/src/legacy/server/config/complete.test.js index e5484693ae55..140cf9960229 100644 --- a/src/legacy/server/config/complete.test.js +++ b/src/legacy/server/config/complete.test.js @@ -35,7 +35,7 @@ describe('server/config completeMixin()', function () { get: sinon.stub().returns(configValues), }; - const kbnServer = { + const osdServer = { newPlatform: {}, settings, server, @@ -44,7 +44,7 @@ describe('server/config completeMixin()', function () { plugins, }; - const callCompleteMixin = () => completeMixin(kbnServer, server, config); + const callCompleteMixin = () => completeMixin(osdServer, server, config); return { config, callCompleteMixin, server }; }; diff --git a/src/legacy/server/config/config.js b/src/legacy/server/config/config.js index 7805296258d9..12bab4ca4b08 100644 --- a/src/legacy/server/config/config.js +++ b/src/legacy/server/config/config.js @@ -22,8 +22,8 @@ import { set } from '@elastic/safer-lodash-set'; import _ from 'lodash'; import { override } from './override'; import createDefaultSchema from './schema'; -import { unset, deepCloneWithBuffers as clone, IS_KIBANA_DISTRIBUTABLE } from '../../utils'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths +import { unset, deepCloneWithBuffers as clone, IS_OPENSEARCH_DASHBOARDS_DISTRIBUTABLE } from '../../utils'; +// eslint-disable-next-line @osd/eslint/no-restricted-paths import { pkg } from '../../../core/server/utils'; const schema = Symbol('Joi Schema'); const schemaExts = Symbol('Schema Extensions'); @@ -109,11 +109,11 @@ export class Config { notDev: !dev, version: _.get(pkg, 'version'), branch: _.get(pkg, 'branch'), - buildNum: IS_KIBANA_DISTRIBUTABLE ? pkg.build.number : Number.MAX_SAFE_INTEGER, - buildSha: IS_KIBANA_DISTRIBUTABLE + buildNum: IS_OPENSEARCH_DASHBOARDS_DISTRIBUTABLE ? pkg.build.number : Number.MAX_SAFE_INTEGER, + buildSha: IS_OPENSEARCH_DASHBOARDS_DISTRIBUTABLE ? pkg.build.sha : 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', - dist: IS_KIBANA_DISTRIBUTABLE, + dist: IS_OPENSEARCH_DASHBOARDS_DISTRIBUTABLE, }; if (!context.dev && !context.prod) { diff --git a/src/legacy/server/config/schema.js b/src/legacy/server/config/schema.js index 1843bdd75be5..4115b6e8377e 100644 --- a/src/legacy/server/config/schema.js +++ b/src/legacy/server/config/schema.js @@ -145,12 +145,12 @@ export default () => locale: Joi.string().default('en'), }).default(), - // temporarily moved here from the (now deleted) kibana legacy plugin - kibana: Joi.object({ + // temporarily moved here from the (now deleted) opensearch-dashboards legacy plugin + opensearchDashboards: Joi.object({ enabled: Joi.boolean().default(true), - index: Joi.string().default('.kibana'), + index: Joi.string().default('.opensearch-dashboards'), autocompleteTerminateAfter: Joi.number().integer().min(1).default(100000), - // TODO Also allow units here like in elasticsearch config once this is moved to the new platform + // TODO Also allow units here like in opensearch config once this is moved to the new platform autocompleteTimeout: Joi.number().integer().min(1).default(1000), }).default(), diff --git a/src/legacy/server/core/index.ts b/src/legacy/server/core/index.ts index de5391d33cad..78550e95e52f 100644 --- a/src/legacy/server/core/index.ts +++ b/src/legacy/server/core/index.ts @@ -18,14 +18,14 @@ */ import { Server } from 'hapi'; -import KbnServer from '../kbn_server'; +import OsdServer from '../osd_server'; /** - * Exposes `kbnServer.newPlatform` through Hapi API. - * @param kbnServer KbnServer singleton instance. + * Exposes `osdServer.newPlatform` through Hapi API. + * @param osdServer OsdServer singleton instance. * @param server Hapi server instance to expose `core` on. */ -export function coreMixin(kbnServer: KbnServer, server: Server) { +export function coreMixin(osdServer: OsdServer, server: Server) { // we suppress type error because hapi expect a function here not an object - server.decorate('server', 'newPlatform', kbnServer.newPlatform as any); + server.decorate('server', 'newPlatform', osdServer.newPlatform as any); } diff --git a/src/legacy/server/http/index.js b/src/legacy/server/http/index.js index 0cab1a160928..87206ea19c62 100644 --- a/src/legacy/server/http/index.js +++ b/src/legacy/server/http/index.js @@ -23,10 +23,10 @@ import Boom from 'boom'; import { registerHapiPlugins } from './register_hapi_plugins'; import { setupBasePathProvider } from './setup_base_path_provider'; -export default async function (kbnServer, server) { - server = kbnServer.server; +export default async function (osdServer, server) { + server = osdServer.server; - setupBasePathProvider(kbnServer); + setupBasePathProvider(osdServer); await registerHapiPlugins(server); diff --git a/src/legacy/server/http/integration_tests/max_payload_size.test.js b/src/legacy/server/http/integration_tests/max_payload_size.test.js index 2d0718dd3560..5eed133cec45 100644 --- a/src/legacy/server/http/integration_tests/max_payload_size.test.js +++ b/src/legacy/server/http/integration_tests/max_payload_size.test.js @@ -17,11 +17,11 @@ * under the License. */ -import * as kbnTestServer from '../../../../core/test_helpers/kbn_server'; +import * as osdTestServer from '../../../../core/test_helpers/osd_server'; let root; beforeAll(async () => { - root = kbnTestServer.createRoot({ + root = osdTestServer.createRoot({ server: { maxPayloadBytes: 100 }, migrations: { skip: true }, plugins: { initialize: false }, @@ -30,7 +30,7 @@ beforeAll(async () => { await root.setup(); await root.start(); - kbnTestServer.getKbnServer(root).server.route({ + osdTestServer.getOsdServer(root).server.route({ path: '/payload_size_check/test/route', method: 'POST', config: { payload: { maxBytes: 200 } }, @@ -41,7 +41,7 @@ beforeAll(async () => { afterAll(async () => await root.shutdown()); test('accepts payload with a size larger than default but smaller than route config allows', async () => { - await kbnTestServer.request + await osdTestServer.request .post(root, '/payload_size_check/test/route') .send({ data: Array(150).fill('+').join(''), @@ -50,7 +50,7 @@ test('accepts payload with a size larger than default but smaller than route con }); test('fails with 413 if payload size is larger than default and route config allows', async () => { - await kbnTestServer.request + await osdTestServer.request .post(root, '/payload_size_check/test/route') .send({ data: Array(250).fill('+').join(''), diff --git a/src/legacy/server/http/setup_base_path_provider.js b/src/legacy/server/http/setup_base_path_provider.js index 6949d7e2eebd..6715201cb1ed 100644 --- a/src/legacy/server/http/setup_base_path_provider.js +++ b/src/legacy/server/http/setup_base_path_provider.js @@ -17,9 +17,9 @@ * under the License. */ -export function setupBasePathProvider(kbnServer) { - kbnServer.server.decorate('request', 'getBasePath', function () { +export function setupBasePathProvider(osdServer) { + osdServer.server.decorate('request', 'getBasePath', function () { const request = this; - return kbnServer.newPlatform.setup.core.http.basePath.get(request); + return osdServer.newPlatform.setup.core.http.basePath.get(request); }); } diff --git a/src/legacy/server/i18n/constants.ts b/src/legacy/server/i18n/constants.ts index 96fa420d4c6e..b89968e80bc2 100644 --- a/src/legacy/server/i18n/constants.ts +++ b/src/legacy/server/i18n/constants.ts @@ -22,4 +22,4 @@ export const I18N_RC = '.i18nrc.json'; /** * The type name used within the Monitoring index to publish localization stats. */ -export const KIBANA_LOCALIZATION_STATS_TYPE = 'localization'; +export const OPENSEARCH_DASHBOARDS_LOCALIZATION_STATS_TYPE = 'localization'; diff --git a/src/legacy/server/i18n/index.ts b/src/legacy/server/i18n/index.ts index 61caefb2fb59..9d7b1907af14 100644 --- a/src/legacy/server/i18n/index.ts +++ b/src/legacy/server/i18n/index.ts @@ -17,17 +17,17 @@ * under the License. */ -import { i18n, i18nLoader } from '@kbn/i18n'; +import { i18n, i18nLoader } from '@osd/i18n'; import { basename } from 'path'; import { Server } from 'hapi'; import { fromRoot } from '../../../core/server/utils'; import type { UsageCollectionSetup } from '../../../plugins/usage_collection/server'; import { getTranslationPaths } from './get_translations_path'; import { I18N_RC } from './constants'; -import KbnServer, { KibanaConfig } from '../kbn_server'; +import OsdServer, { OpenSearchDashboardsConfig } from '../osd_server'; import { registerLocalizationUsageCollector } from './localization'; -export async function i18nMixin(kbnServer: KbnServer, server: Server, config: KibanaConfig) { +export async function i18nMixin(osdServer: OsdServer, server: Server, config: OpenSearchDashboardsConfig) { const locale = config.get('i18n.locale') as string; const translationPaths = await Promise.all([ @@ -42,7 +42,7 @@ export async function i18nMixin(kbnServer: KbnServer, server: Server, config: Ki getTranslationPaths({ cwd, glob: `*/${I18N_RC}` }) ), getTranslationPaths({ - cwd: fromRoot('../kibana-extra'), + cwd: fromRoot('../opensearch-dashboards-extra'), glob: `*/${I18N_RC}`, }), ]); @@ -64,8 +64,8 @@ export async function i18nMixin(kbnServer: KbnServer, server: Server, config: Ki server.decorate('server', 'getTranslationsFilePaths', getTranslationsFilePaths); - if (kbnServer.newPlatform.setup.plugins.usageCollection) { - const { usageCollection } = kbnServer.newPlatform.setup.plugins as { + if (osdServer.newPlatform.setup.plugins.usageCollection) { + const { usageCollection } = osdServer.newPlatform.setup.plugins as { usageCollection: UsageCollectionSetup; }; registerLocalizationUsageCollector(usageCollection, { diff --git a/src/legacy/server/i18n/localization/telemetry_localization_collector.test.ts b/src/legacy/server/i18n/localization/telemetry_localization_collector.test.ts index cbe23da87c76..d5dee3a1f607 100644 --- a/src/legacy/server/i18n/localization/telemetry_localization_collector.test.ts +++ b/src/legacy/server/i18n/localization/telemetry_localization_collector.test.ts @@ -32,7 +32,7 @@ const createI18nLoaderMock = (translations: TranslationsMock) => { }; import { getTranslationCount } from './telemetry_localization_collector'; -import { i18nLoader } from '@kbn/i18n'; +import { i18nLoader } from '@osd/i18n'; describe('getTranslationCount', () => { it('returns 0 if no translations registered', async () => { diff --git a/src/legacy/server/i18n/localization/telemetry_localization_collector.ts b/src/legacy/server/i18n/localization/telemetry_localization_collector.ts index 89566dfd4ef6..f654836868ad 100644 --- a/src/legacy/server/i18n/localization/telemetry_localization_collector.ts +++ b/src/legacy/server/i18n/localization/telemetry_localization_collector.ts @@ -17,11 +17,11 @@ * under the License. */ -import { i18nLoader } from '@kbn/i18n'; +import { i18nLoader } from '@osd/i18n'; import { size } from 'lodash'; import { UsageCollectionSetup } from 'src/plugins/usage_collection/server'; import { getIntegrityHashes, Integrities } from './file_integrity'; -import { KIBANA_LOCALIZATION_STATS_TYPE } from '../constants'; +import { OPENSEARCH_DASHBOARDS_LOCALIZATION_STATS_TYPE } from '../constants'; export interface UsageStats { locale: string; @@ -68,7 +68,7 @@ export function registerLocalizationUsageCollector( helpers: LocalizationUsageCollectorHelpers ) { const collector = usageCollection.makeUsageCollector({ - type: KIBANA_LOCALIZATION_STATS_TYPE, + type: OPENSEARCH_DASHBOARDS_LOCALIZATION_STATS_TYPE, isReady: () => true, fetch: createCollectorFetch(helpers), }); diff --git a/src/legacy/server/logging/index.js b/src/legacy/server/logging/index.js index 5182de0b7f61..25a7d8ab2bc8 100644 --- a/src/legacy/server/logging/index.js +++ b/src/legacy/server/logging/index.js @@ -29,7 +29,7 @@ export async function setupLogging(server, config) { }); } -export async function loggingMixin(kbnServer, server, config) { +export async function loggingMixin(osdServer, server, config) { logWithMetadata.decorateServer(server); await setupLogging(server, config); diff --git a/src/legacy/server/logging/log_format_json.js b/src/legacy/server/logging/log_format_json.js index bfceb78b2450..2fbe06445c51 100644 --- a/src/legacy/server/logging/log_format_json.js +++ b/src/legacy/server/logging/log_format_json.js @@ -24,7 +24,7 @@ const stripColors = function (string) { return string.replace(/\u001b[^m]+m/g, ''); }; -export default class KbnLoggerJsonFormat extends LogFormat { +export default class OsdLoggerJsonFormat extends LogFormat { format(data) { data.message = stripColors(data.message); data['@timestamp'] = this.extractAndFormatTimestamp(data); diff --git a/src/legacy/server/logging/log_format_json.test.js b/src/legacy/server/logging/log_format_json.test.js index ec7296d21672..067986f24297 100644 --- a/src/legacy/server/logging/log_format_json.test.js +++ b/src/legacy/server/logging/log_format_json.test.js @@ -19,11 +19,11 @@ import moment from 'moment'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths +// eslint-disable-next-line @osd/eslint/no-restricted-paths import { attachMetaData } from '../../../../src/core/server/legacy/logging/legacy_logging_server'; import { createListStream, createPromiseFromStreams } from '../../../core/server/utils'; -import KbnLoggerJsonFormat from './log_format_json'; +import OsdLoggerJsonFormat from './log_format_json'; const time = +moment('2010-01-01T05:15:59Z', moment.ISO_8601); @@ -32,13 +32,13 @@ const makeEvent = (eventType) => ({ timestamp: time, }); -describe('KbnLoggerJsonFormat', () => { +describe('OsdLoggerJsonFormat', () => { const config = {}; describe('event types and messages', () => { let format; beforeEach(() => { - format = new KbnLoggerJsonFormat(config); + format = new OsdLoggerJsonFormat(config); }); it('log', async () => { @@ -248,7 +248,7 @@ describe('KbnLoggerJsonFormat', () => { describe('timezone', () => { it('logs in UTC', async () => { - const format = new KbnLoggerJsonFormat({ + const format = new OsdLoggerJsonFormat({ timezone: 'UTC', }); @@ -259,7 +259,7 @@ describe('KbnLoggerJsonFormat', () => { }); it('logs in local timezone timezone is undefined', async () => { - const format = new KbnLoggerJsonFormat({}); + const format = new OsdLoggerJsonFormat({}); const result = await createPromiseFromStreams([createListStream([makeEvent('log')]), format]); diff --git a/src/legacy/server/logging/log_format_string.js b/src/legacy/server/logging/log_format_string.js index cbbf71dd894a..0a09b55c953a 100644 --- a/src/legacy/server/logging/log_format_string.js +++ b/src/legacy/server/logging/log_format_string.js @@ -53,9 +53,9 @@ const type = _.memoize(function (t) { return color(t)(_.pad(t, 7).slice(0, 7)); }); -const workerType = process.env.kbnWorkerType ? `${type(process.env.kbnWorkerType)} ` : ''; +const workerType = process.env.osdWorkerType ? `${type(process.env.osdWorkerType)} ` : ''; -export default class KbnLoggerStringFormat extends LogFormat { +export default class OsdLoggerStringFormat extends LogFormat { format(data) { const time = color('time')(this.extractAndFormatTimestamp(data, 'HH:mm:ss.SSS')); const msg = data.error ? color('error')(data.error.stack) : color('message')(data.message); diff --git a/src/legacy/server/logging/log_format_string.test.js b/src/legacy/server/logging/log_format_string.test.js index 842325865cce..f9480941952e 100644 --- a/src/legacy/server/logging/log_format_string.test.js +++ b/src/legacy/server/logging/log_format_string.test.js @@ -18,12 +18,12 @@ */ import moment from 'moment'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths +// eslint-disable-next-line @osd/eslint/no-restricted-paths import { attachMetaData } from '../../../../src/core/server/legacy/logging/legacy_logging_server'; import { createListStream, createPromiseFromStreams } from '../../../core/server/utils'; -import KbnLoggerStringFormat from './log_format_string'; +import OsdLoggerStringFormat from './log_format_string'; const time = +moment('2010-01-01T05:15:59Z', moment.ISO_8601); @@ -35,9 +35,9 @@ const makeEvent = () => ({ data: 'my log message', }); -describe('KbnLoggerStringFormat', () => { +describe('OsdLoggerStringFormat', () => { it('logs in UTC', async () => { - const format = new KbnLoggerStringFormat({ + const format = new OsdLoggerStringFormat({ timezone: 'UTC', }); @@ -47,7 +47,7 @@ describe('KbnLoggerStringFormat', () => { }); it('logs in local timezone when timezone is undefined', async () => { - const format = new KbnLoggerStringFormat({}); + const format = new OsdLoggerStringFormat({}); const result = await createPromiseFromStreams([createListStream([makeEvent()]), format]); @@ -55,7 +55,7 @@ describe('KbnLoggerStringFormat', () => { }); describe('with metadata', () => { it('does not log meta data', async () => { - const format = new KbnLoggerStringFormat({}); + const format = new OsdLoggerStringFormat({}); const event = { data: attachMetaData('message for event', { prop1: 'value1', diff --git a/src/legacy/server/logging/log_with_metadata.js b/src/legacy/server/logging/log_with_metadata.js index 73e03a154907..d263de506177 100644 --- a/src/legacy/server/logging/log_with_metadata.js +++ b/src/legacy/server/logging/log_with_metadata.js @@ -21,7 +21,7 @@ import { isPlainObject } from 'lodash'; import { metadataSymbol, attachMetaData, - // eslint-disable-next-line @kbn/eslint/no-restricted-paths + // eslint-disable-next-line @osd/eslint/no-restricted-paths } from '../../../../src/core/server/legacy/logging/legacy_logging_server'; export const logWithMetadata = { diff --git a/src/legacy/server/logging/rotate/index.ts b/src/legacy/server/logging/rotate/index.ts index 646c89efe8e2..00e9e20cd644 100644 --- a/src/legacy/server/logging/rotate/index.ts +++ b/src/legacy/server/logging/rotate/index.ts @@ -20,11 +20,11 @@ import { isMaster, isWorker } from 'cluster'; import { Server } from 'hapi'; import { LogRotator } from './log_rotator'; -import { KibanaConfig } from '../../kbn_server'; +import { OpenSearchDashboardsConfig } from '../../osd_server'; let logRotator: LogRotator; -export async function setupLoggingRotate(server: Server, config: KibanaConfig) { +export async function setupLoggingRotate(server: Server, config: OpenSearchDashboardsConfig) { // If log rotate is not enabled we skip if (!config.get('logging.rotate.enabled')) { return; @@ -32,7 +32,7 @@ export async function setupLoggingRotate(server: Server, config: KibanaConfig) { // We just want to start the logging rotate service once // and we choose to use the master (prod) or the worker server (dev) - if (!isMaster && isWorker && process.env.kbnWorkerType !== 'server') { + if (!isMaster && isWorker && process.env.osdWorkerType !== 'server') { return; } diff --git a/src/legacy/server/logging/rotate/log_rotator.test.ts b/src/legacy/server/logging/rotate/log_rotator.test.ts index 8f67b47f6949..4e104a1b4781 100644 --- a/src/legacy/server/logging/rotate/log_rotator.test.ts +++ b/src/legacy/server/logging/rotate/log_rotator.test.ts @@ -34,7 +34,7 @@ jest.mock('chokidar', () => ({ lodash.throttle = (fn: any) => fn; -const tempDir = join(tmpdir(), 'kbn_log_rotator_test'); +const tempDir = join(tmpdir(), 'osd_log_rotator_test'); const testFilePath = join(tempDir, 'log_rotator_test_log_file.log'); const createLogRotatorConfig: any = (logFilePath: string) => { diff --git a/src/legacy/server/logging/rotate/log_rotator.ts b/src/legacy/server/logging/rotate/log_rotator.ts index 22183b2f0777..8c1f9c423c83 100644 --- a/src/legacy/server/logging/rotate/log_rotator.ts +++ b/src/legacy/server/logging/rotate/log_rotator.ts @@ -27,7 +27,7 @@ import { basename, dirname, join, sep } from 'path'; import { Observable } from 'rxjs'; import { first } from 'rxjs/operators'; import { promisify } from 'util'; -import { KibanaConfig } from '../../kbn_server'; +import { OpenSearchDashboardsConfig } from '../../osd_server'; const mkdirAsync = promisify(fs.mkdir); const readdirAsync = promisify(fs.readdir); @@ -37,7 +37,7 @@ const unlinkAsync = promisify(fs.unlink); const writeFileAsync = promisify(fs.writeFile); export class LogRotator { - private readonly config: KibanaConfig; + private readonly config: OpenSearchDashboardsConfig; private readonly log: Server['log']; public logFilePath: string; public everyBytes: number; @@ -52,7 +52,7 @@ export class LogRotator { private stalkerUsePollingPolicyTestTimeout: NodeJS.Timeout | null; public shouldUsePolling: boolean; - constructor(config: KibanaConfig, server: Server) { + constructor(config: OpenSearchDashboardsConfig, server: Server) { this.config = config; this.log = server.log.bind(server); this.logFilePath = config.get('logging.dest'); @@ -105,7 +105,7 @@ export class LogRotator { // Setup a test file in order to try the fs env // and understand if we need to usePolling or not const tempFileDir = tmpdir(); - const tempFile = join(tempFileDir, 'kbn_log_rotation_use_polling_test_file.log'); + const tempFile = join(tempFileDir, 'osd_log_rotation_use_polling_test_file.log'); await mkdirAsync(tempFileDir, { recursive: true }); await writeFileAsync(tempFile, ''); diff --git a/src/legacy/server/kbn_server.d.ts b/src/legacy/server/osd_server.d.ts similarity index 73% rename from src/legacy/server/kbn_server.d.ts rename to src/legacy/server/osd_server.d.ts index 1718a9a8f55d..f73bd2e07378 100644 --- a/src/legacy/server/kbn_server.d.ts +++ b/src/legacy/server/osd_server.d.ts @@ -28,13 +28,13 @@ import { LegacyServiceSetupDeps, } from '../../core/server'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths +// eslint-disable-next-line @osd/eslint/no-restricted-paths import { LegacyConfig } from '../../core/server/legacy'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths +// eslint-disable-next-line @osd/eslint/no-restricted-paths import { UiPlugins } from '../../core/server/plugins'; // lot of legacy code was assuming this type only had these two methods -export type KibanaConfig = Pick; +export type OpenSearchDashboardsConfig = Pick; // Extend the defaults with the plugins and server methods we need. declare module 'hapi' { @@ -43,19 +43,19 @@ declare module 'hapi' { } interface Server { - config: () => KibanaConfig; + config: () => OpenSearchDashboardsConfig; logWithMetadata: (tags: string[], message: string, meta: Record) => void; - newPlatform: KbnServer['newPlatform']; + newPlatform: OsdServer['newPlatform']; } } -type KbnMixinFunc = (kbnServer: KbnServer, server: Server, config: any) => Promise | void; +type OsdMixinFunc = (osdServer: OsdServer, server: Server, config: any) => Promise | void; export interface PluginsSetup { [key: string]: object; } -export interface KibanaCore { +export interface OpenSearchDashboardsCore { __internals: { hapiServer: LegacyServiceSetupDeps['core']['http']['server']; rendering: LegacyServiceSetupDeps['core']['rendering']; @@ -77,30 +77,30 @@ export interface KibanaCore { } export interface NewPlatform { - __internals: KibanaCore['__internals']; - env: KibanaCore['env']; + __internals: OpenSearchDashboardsCore['__internals']; + env: OpenSearchDashboardsCore['env']; coreContext: { - logger: KibanaCore['logger']; + logger: OpenSearchDashboardsCore['logger']; }; - setup: KibanaCore['setupDeps']; - start: KibanaCore['startDeps']; + setup: OpenSearchDashboardsCore['setupDeps']; + start: OpenSearchDashboardsCore['startDeps']; stop: null; } // eslint-disable-next-line import/no-default-export -export default class KbnServer { +export default class OsdServer { public readonly newPlatform: NewPlatform; public server: Server; public inject: Server['inject']; - constructor(settings: Record, config: KibanaConfig, core: KibanaCore); + constructor(settings: Record, config: OpenSearchDashboardsConfig, core: OpenSearchDashboardsCore); public ready(): Promise; - public mixin(...fns: KbnMixinFunc[]): Promise; + public mixin(...fns: OsdMixinFunc[]): Promise; public listen(): Promise; public close(): Promise; public applyLoggingConfiguration(settings: any): void; - public config: KibanaConfig; + public config: OpenSearchDashboardsConfig; } // Re-export commonly used hapi types. diff --git a/src/legacy/server/kbn_server.js b/src/legacy/server/osd_server.js similarity index 86% rename from src/legacy/server/kbn_server.js rename to src/legacy/server/osd_server.js index e29563a7c626..96689ce3e8d5 100644 --- a/src/legacy/server/kbn_server.js +++ b/src/legacy/server/osd_server.js @@ -20,7 +20,7 @@ import { constant, once, compact, flatten } from 'lodash'; import { isWorker } from 'cluster'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths +// eslint-disable-next-line @osd/eslint/no-restricted-paths import { fromRoot, pkg } from '../../core/server/utils'; import { Config } from './config'; import loggingConfiguration from './logging/configuration'; @@ -34,18 +34,18 @@ import { uiMixin } from '../ui'; import { i18nMixin } from './i18n'; /** - * @typedef {import('./kbn_server').KibanaConfig} KibanaConfig - * @typedef {import('./kbn_server').KibanaCore} KibanaCore - * @typedef {import('./kbn_server').LegacyPlugins} LegacyPlugins + * @typedef {import('./osd_server').OpenSearchDashboardsConfig} OpenSearchDashboardsConfig + * @typedef {import('./osd_server').OpenSearchDashboardsCore} OpenSearchDashboardsCore + * @typedef {import('./osd_server').LegacyPlugins} LegacyPlugins */ const rootDir = fromRoot('.'); -export default class KbnServer { +export default class OsdServer { /** * @param {Record} settings - * @param {KibanaConfig} config - * @param {KibanaCore} core + * @param {OpenSearchDashboardsConfig} config + * @param {OpenSearchDashboardsCore} core */ constructor(settings, config, core) { this.name = pkg.name; @@ -90,7 +90,7 @@ export default class KbnServer { uiMixin, - // setup routes that serve the @kbn/optimizer output + // setup routes that serve the @osd/optimizer output optimizeMixin ) ); @@ -99,12 +99,12 @@ export default class KbnServer { } /** - * Extend the KbnServer outside of the constraints of a plugin. This allows access + * Extend the OsdServer outside of the constraints of a plugin. This allows access * to APIs that are not exposed (intentionally) to the plugins and should only - * be used when the code will be kept up to date with Kibana. + * be used when the code will be kept up to date with OpenSearchDashboards. * * @param {...function} - functions that should be called to mixin functionality. - * They are called with the arguments (kibana, server, config) + * They are called with the arguments (opensearchDashboards, server, config) * and can return a promise to delay execution of the next mixin * @return {Promise} - promise that is resolved when the final mixin completes. */ diff --git a/src/legacy/server/warnings/index.js b/src/legacy/server/warnings/index.js index e96366893076..811a4b2fb5ea 100644 --- a/src/legacy/server/warnings/index.js +++ b/src/legacy/server/warnings/index.js @@ -17,7 +17,7 @@ * under the License. */ -export default function (kbnServer, server) { +export default function (osdServer, server) { process.on('warning', (warning) => { // deprecation warnings do no reflect a current problem for // the user and therefor should be filtered out. diff --git a/src/legacy/ui/apm/index.js b/src/legacy/ui/apm/index.js index e58f6fb73320..eb5cbad9f936 100644 --- a/src/legacy/ui/apm/index.js +++ b/src/legacy/ui/apm/index.js @@ -27,7 +27,7 @@ export function getApmConfig(requestPath) { return null; } const config = { - ...getConfig('kibana-frontend'), + ...getConfig('opensearch-dashboards-frontend'), pageLoadTransactionName: requestPath, }; diff --git a/src/legacy/ui/ui_mixin.js b/src/legacy/ui/ui_mixin.js index caa0ca489066..03a9c783a072 100644 --- a/src/legacy/ui/ui_mixin.js +++ b/src/legacy/ui/ui_mixin.js @@ -19,6 +19,6 @@ import { uiRenderMixin } from './ui_render'; -export async function uiMixin(kbnServer) { - await kbnServer.mixin(uiRenderMixin); +export async function uiMixin(osdServer) { + await osdServer.mixin(uiRenderMixin); } diff --git a/src/legacy/ui/ui_render/bootstrap/app_bootstrap.js b/src/legacy/ui/ui_render/bootstrap/app_bootstrap.js index 19f75317883d..45a666ab8468 100644 --- a/src/legacy/ui/ui_render/bootstrap/app_bootstrap.js +++ b/src/legacy/ui/ui_render/bootstrap/app_bootstrap.js @@ -22,11 +22,11 @@ import { createHash } from 'crypto'; import { readFile } from 'fs'; import { resolve } from 'path'; -import { kbnBundlesLoaderSource } from './kbn_bundles_loader_source'; +import { osdBundlesLoaderSource } from './osd_bundles_loader_source'; export class AppBootstrap { constructor({ templateData }) { - this.templateData = { ...templateData, kbnBundlesLoaderSource }; + this.templateData = { ...templateData, osdBundlesLoaderSource }; this._rawTemplate = undefined; } diff --git a/src/legacy/ui/ui_render/bootstrap/kbn_bundles_loader_source.js b/src/legacy/ui/ui_render/bootstrap/osd_bundles_loader_source.js similarity index 85% rename from src/legacy/ui/ui_render/bootstrap/kbn_bundles_loader_source.js rename to src/legacy/ui/ui_render/bootstrap/osd_bundles_loader_source.js index cb5488118cc7..79fe7ae92594 100644 --- a/src/legacy/ui/ui_render/bootstrap/kbn_bundles_loader_source.js +++ b/src/legacy/ui/ui_render/bootstrap/osd_bundles_loader_source.js @@ -18,10 +18,10 @@ */ module.exports = { - kbnBundlesLoaderSource: `(${kbnBundlesLoader.toString()})();`, + osdBundlesLoaderSource: `(${osdBundlesLoader.toString()})();`, }; -function kbnBundlesLoader() { +function osdBundlesLoader() { var modules = {}; function has(prop) { @@ -30,7 +30,7 @@ function kbnBundlesLoader() { function define(key, bundleRequire, bundleModuleKey) { if (has(key)) { - throw new Error('__kbnBundles__ already has a module defined for "' + key + '"'); + throw new Error('__osdBundles__ already has a module defined for "' + key + '"'); } modules[key] = { @@ -41,7 +41,7 @@ function kbnBundlesLoader() { function get(key) { if (!has(key)) { - throw new Error('__kbnBundles__ does not have a module defined for "' + key + '"'); + throw new Error('__osdBundles__ does not have a module defined for "' + key + '"'); } return modules[key].bundleRequire(modules[key].bundleModuleKey); diff --git a/src/legacy/ui/ui_render/bootstrap/template.js.hbs b/src/legacy/ui/ui_render/bootstrap/template.js.hbs index 89c7125b39e3..a5a95383b1f0 100644 --- a/src/legacy/ui/ui_render/bootstrap/template.js.hbs +++ b/src/legacy/ui/ui_render/bootstrap/template.js.hbs @@ -1,17 +1,17 @@ -var kbnCsp = JSON.parse(document.querySelector('kbn-csp').getAttribute('data')); -window.__kbnStrictCsp__ = kbnCsp.strictCsp; -window.__kbnThemeTag__ = "{{themeTag}}"; -window.__kbnPublicPath__ = {{publicPathMap}}; -window.__kbnBundles__ = {{kbnBundlesLoaderSource}} +var osdCsp = JSON.parse(document.querySelector('osd-csp').getAttribute('data')); +window.__osdStrictCsp__ = osdCsp.strictCsp; +window.__osdThemeTag__ = "{{themeTag}}"; +window.__osdPublicPath__ = {{publicPathMap}}; +window.__osdBundles__ = {{osdBundlesLoaderSource}} -if (window.__kbnStrictCsp__ && window.__kbnCspNotEnforced__) { - var legacyBrowserError = document.getElementById('kbn_legacy_browser_error'); +if (window.__osdStrictCsp__ && window.__osdCspNotEnforced__) { + var legacyBrowserError = document.getElementById('osd_legacy_browser_error'); legacyBrowserError.style.display = 'flex'; } else { - if (!window.__kbnCspNotEnforced__ && window.console) { + if (!window.__osdCspNotEnforced__ && window.console) { window.console.log("^ A single error about an inline script not firing due to content security policy is expected!"); } - var loadingMessage = document.getElementById('kbn_loading_message'); + var loadingMessage = document.getElementById('osd_loading_message'); loadingMessage.style.display = 'flex'; window.onload = function () { @@ -77,7 +77,7 @@ if (window.__kbnStrictCsp__ && window.__kbnCspNotEnforced__) { '{{this}}', {{/each}} ], function () { - __kbnBundles__.get('entry/core/public').__kbnBootstrap__(); + __osdBundles__.get('entry/core/public').__osdBootstrap__(); load([ {{#each styleSheetPaths}} diff --git a/src/legacy/ui/ui_render/ui_render_mixin.js b/src/legacy/ui/ui_render/ui_render_mixin.js index 2983dbbc2866..225a1284ffa6 100644 --- a/src/legacy/ui/ui_render/ui_render_mixin.js +++ b/src/legacy/ui/ui_render/ui_render_mixin.js @@ -19,31 +19,31 @@ import { createHash } from 'crypto'; import Boom from 'boom'; -import { i18n } from '@kbn/i18n'; -import * as UiSharedDeps from '@kbn/ui-shared-deps'; -import { KibanaRequest } from '../../../core/server'; +import { i18n } from '@osd/i18n'; +import * as UiSharedDeps from '@osd/ui-shared-deps'; +import { OpenSearchDashboardsRequest } from '../../../core/server'; import { AppBootstrap } from './bootstrap'; import { getApmConfig } from '../apm'; /** - * @typedef {import('../../server/kbn_server').default} KbnServer - * @typedef {import('../../server/kbn_server').ResponseToolkit} ResponseToolkit + * @typedef {import('../../server/osd_server').default} OsdServer + * @typedef {import('../../server/osd_server').ResponseToolkit} ResponseToolkit */ /** * - * @param {KbnServer} kbnServer - * @param {KbnServer['server']} server - * @param {KbnServer['config']} config + * @param {OsdServer} osdServer + * @param {OsdServer['server']} server + * @param {OsdServer['config']} config */ -export function uiRenderMixin(kbnServer, server, config) { +export function uiRenderMixin(osdServer, server, config) { const translationsCache = { translations: null, hash: null }; server.route({ path: '/translations/{locale}.json', method: 'GET', config: { auth: false }, handler(request, h) { - // Kibana server loads translations only for a single locale + // OpenSearch Dashboards server loads translations only for a single locale // that is specified in `i18n.locale` config value. const { locale } = request.params; if (i18n.getLocale() !== locale.toLowerCase()) { @@ -76,10 +76,10 @@ export function uiRenderMixin(kbnServer, server, config) { auth: authEnabled ? { mode: 'try' } : false, }, async handler(request, h) { - const soClient = kbnServer.newPlatform.start.core.savedObjects.getScopedClient( - KibanaRequest.from(request) + const soClient = osdServer.newPlatform.start.core.savedObjects.getScopedClient( + OpenSearchDashboardsRequest.from(request) ); - const uiSettings = kbnServer.newPlatform.start.core.uiSettings.asScopedToClient(soClient); + const uiSettings = osdServer.newPlatform.start.core.uiSettings.asScopedToClient(soClient); const darkMode = !authEnabled || request.auth.isAuthenticated @@ -97,25 +97,25 @@ export function uiRenderMixin(kbnServer, server, config) { const regularBundlePath = `${basePath}/${buildHash}/bundles`; const styleSheetPaths = [ - `${regularBundlePath}/kbn-ui-shared-deps/${UiSharedDeps.baseCssDistFilename}`, + `${regularBundlePath}/osd-ui-shared-deps/${UiSharedDeps.baseCssDistFilename}`, ...(darkMode ? [ themeVersion === 'v7' - ? `${regularBundlePath}/kbn-ui-shared-deps/${UiSharedDeps.darkCssDistFilename}` - : `${regularBundlePath}/kbn-ui-shared-deps/${UiSharedDeps.darkV8CssDistFilename}`, - `${basePath}/node_modules/@kbn/ui-framework/dist/kui_dark.css`, + ? `${regularBundlePath}/osd-ui-shared-deps/${UiSharedDeps.darkCssDistFilename}` + : `${regularBundlePath}/osd-ui-shared-deps/${UiSharedDeps.darkV8CssDistFilename}`, + `${basePath}/node_modules/@osd/ui-framework/dist/kui_dark.css`, `${basePath}/ui/legacy_dark_theme.css`, ] : [ themeVersion === 'v7' - ? `${regularBundlePath}/kbn-ui-shared-deps/${UiSharedDeps.lightCssDistFilename}` - : `${regularBundlePath}/kbn-ui-shared-deps/${UiSharedDeps.lightV8CssDistFilename}`, - `${basePath}/node_modules/@kbn/ui-framework/dist/kui_light.css`, + ? `${regularBundlePath}/osd-ui-shared-deps/${UiSharedDeps.lightCssDistFilename}` + : `${regularBundlePath}/osd-ui-shared-deps/${UiSharedDeps.lightV8CssDistFilename}`, + `${basePath}/node_modules/@osd/ui-framework/dist/kui_light.css`, `${basePath}/ui/legacy_light_theme.css`, ]), ]; - const kpUiPlugins = kbnServer.newPlatform.__internals.uiPlugins; + const kpUiPlugins = osdServer.newPlatform.__internals.uiPlugins; const kpPluginPublicPaths = new Map(); const kpPluginBundlePaths = new Set(); @@ -135,9 +135,9 @@ export function uiRenderMixin(kbnServer, server, config) { const jsDependencyPaths = [ ...UiSharedDeps.jsDepFilenames.map( - (filename) => `${regularBundlePath}/kbn-ui-shared-deps/${filename}` + (filename) => `${regularBundlePath}/osd-ui-shared-deps/${filename}` ), - `${regularBundlePath}/kbn-ui-shared-deps/${UiSharedDeps.jsFilename}`, + `${regularBundlePath}/osd-ui-shared-deps/${UiSharedDeps.jsFilename}`, `${regularBundlePath}/core/core.entry.js`, ...kpPluginBundlePaths, @@ -147,7 +147,7 @@ export function uiRenderMixin(kbnServer, server, config) { // src/optimize/bundles_route/bundles_route.ts const publicPathMap = JSON.stringify({ core: `${regularBundlePath}/core/`, - 'kbn-ui-shared-deps': `${regularBundlePath}/kbn-ui-shared-deps/`, + 'osd-ui-shared-deps': `${regularBundlePath}/osd-ui-shared-deps/`, ...Object.fromEntries(kpPluginPublicPaths), }); @@ -184,11 +184,11 @@ export function uiRenderMixin(kbnServer, server, config) { }); async function renderApp(h) { - const { http } = kbnServer.newPlatform.setup.core; - const { savedObjects } = kbnServer.newPlatform.start.core; - const { rendering } = kbnServer.newPlatform.__internals; - const req = KibanaRequest.from(h.request); - const uiSettings = kbnServer.newPlatform.start.core.uiSettings.asScopedToClient( + const { http } = osdServer.newPlatform.setup.core; + const { savedObjects } = osdServer.newPlatform.start.core; + const { rendering } = osdServer.newPlatform.__internals; + const req = OpenSearchDashboardsRequest.from(h.request); + const uiSettings = osdServer.newPlatform.start.core.uiSettings.asScopedToClient( savedObjects.getScopedClient(req) ); const vars = { diff --git a/src/legacy/utils/__tests__/unset.js b/src/legacy/utils/__tests__/unset.js index 69122e06ac57..eda0bb8b1d0e 100644 --- a/src/legacy/utils/__tests__/unset.js +++ b/src/legacy/utils/__tests__/unset.js @@ -18,7 +18,7 @@ */ import { unset } from '../unset'; -import expect from '@kbn/expect'; +import expect from '@osd/expect'; describe('unset(obj, key)', function () { describe('invalid input', function () { diff --git a/src/legacy/utils/artifact_type.ts b/src/legacy/utils/artifact_type.ts index ef471ef8e050..1c34737110e8 100644 --- a/src/legacy/utils/artifact_type.ts +++ b/src/legacy/utils/artifact_type.ts @@ -18,5 +18,5 @@ */ import { pkg } from '../../core/server/utils'; -export const IS_KIBANA_DISTRIBUTABLE = pkg.build && pkg.build.distributable === true; -export const IS_KIBANA_RELEASE = pkg.build && pkg.build.release === true; +export const IS_OPENSEARCH_DASHBOARDS_DISTRIBUTABLE = pkg.build && pkg.build.distributable === true; +export const IS_OPENSEARCH_DASHBOARDS_RELEASE = pkg.build && pkg.build.release === true; diff --git a/src/legacy/utils/index.js b/src/legacy/utils/index.js index e2e2331b3aea..bcc508319e01 100644 --- a/src/legacy/utils/index.js +++ b/src/legacy/utils/index.js @@ -19,5 +19,5 @@ export { deepCloneWithBuffers } from './deep_clone_with_buffers'; export { unset } from './unset'; -export { IS_KIBANA_DISTRIBUTABLE } from './artifact_type'; -export { IS_KIBANA_RELEASE } from './artifact_type'; +export { IS_OPENSEARCH_DASHBOARDS_DISTRIBUTABLE } from './artifact_type'; +export { IS_OPENSEARCH_DASHBOARDS_RELEASE } from './artifact_type';