mirror of
https://github.com/elastic/kibana.git
synced 2025-06-28 03:01:21 -04:00
[core] [i18n] Move i18n core server (#139808)
Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
dcbe46ba55
commit
d1b7f02a22
41 changed files with 572 additions and 34 deletions
|
@ -216,6 +216,9 @@
|
|||
"@kbn/core-i18n-browser": "link:bazel-bin/packages/core/i18n/core-i18n-browser",
|
||||
"@kbn/core-i18n-browser-internal": "link:bazel-bin/packages/core/i18n/core-i18n-browser-internal",
|
||||
"@kbn/core-i18n-browser-mocks": "link:bazel-bin/packages/core/i18n/core-i18n-browser-mocks",
|
||||
"@kbn/core-i18n-server": "link:bazel-bin/packages/core/i18n/core-i18n-server",
|
||||
"@kbn/core-i18n-server-internal": "link:bazel-bin/packages/core/i18n/core-i18n-server-internal",
|
||||
"@kbn/core-i18n-server-mocks": "link:bazel-bin/packages/core/i18n/core-i18n-server-mocks",
|
||||
"@kbn/core-injected-metadata-browser": "link:bazel-bin/packages/core/injected-metadata/core-injected-metadata-browser",
|
||||
"@kbn/core-injected-metadata-browser-internal": "link:bazel-bin/packages/core/injected-metadata/core-injected-metadata-browser-internal",
|
||||
"@kbn/core-injected-metadata-browser-mocks": "link:bazel-bin/packages/core/injected-metadata/core-injected-metadata-browser-mocks",
|
||||
|
@ -891,6 +894,9 @@
|
|||
"@types/kbn__core-i18n-browser": "link:bazel-bin/packages/core/i18n/core-i18n-browser/npm_module_types",
|
||||
"@types/kbn__core-i18n-browser-internal": "link:bazel-bin/packages/core/i18n/core-i18n-browser-internal/npm_module_types",
|
||||
"@types/kbn__core-i18n-browser-mocks": "link:bazel-bin/packages/core/i18n/core-i18n-browser-mocks/npm_module_types",
|
||||
"@types/kbn__core-i18n-server": "link:bazel-bin/packages/core/i18n/core-i18n-server/npm_module_types",
|
||||
"@types/kbn__core-i18n-server-internal": "link:bazel-bin/packages/core/i18n/core-i18n-server-internal/npm_module_types",
|
||||
"@types/kbn__core-i18n-server-mocks": "link:bazel-bin/packages/core/i18n/core-i18n-server-mocks/npm_module_types",
|
||||
"@types/kbn__core-injected-metadata-browser": "link:bazel-bin/packages/core/injected-metadata/core-injected-metadata-browser/npm_module_types",
|
||||
"@types/kbn__core-injected-metadata-browser-internal": "link:bazel-bin/packages/core/injected-metadata/core-injected-metadata-browser-internal/npm_module_types",
|
||||
"@types/kbn__core-injected-metadata-browser-mocks": "link:bazel-bin/packages/core/injected-metadata/core-injected-metadata-browser-mocks/npm_module_types",
|
||||
|
|
|
@ -81,6 +81,9 @@ filegroup(
|
|||
"//packages/core/i18n/core-i18n-browser:build",
|
||||
"//packages/core/i18n/core-i18n-browser-internal:build",
|
||||
"//packages/core/i18n/core-i18n-browser-mocks:build",
|
||||
"//packages/core/i18n/core-i18n-server:build",
|
||||
"//packages/core/i18n/core-i18n-server-internal:build",
|
||||
"//packages/core/i18n/core-i18n-server-mocks:build",
|
||||
"//packages/core/injected-metadata/core-injected-metadata-browser:build",
|
||||
"//packages/core/injected-metadata/core-injected-metadata-browser-internal:build",
|
||||
"//packages/core/injected-metadata/core-injected-metadata-browser-mocks:build",
|
||||
|
@ -376,6 +379,9 @@ filegroup(
|
|||
"//packages/core/i18n/core-i18n-browser:build_types",
|
||||
"//packages/core/i18n/core-i18n-browser-internal:build_types",
|
||||
"//packages/core/i18n/core-i18n-browser-mocks:build_types",
|
||||
"//packages/core/i18n/core-i18n-server:build_types",
|
||||
"//packages/core/i18n/core-i18n-server-internal:build_types",
|
||||
"//packages/core/i18n/core-i18n-server-mocks:build_types",
|
||||
"//packages/core/injected-metadata/core-injected-metadata-browser:build_types",
|
||||
"//packages/core/injected-metadata/core-injected-metadata-browser-internal:build_types",
|
||||
"//packages/core/injected-metadata/core-injected-metadata-browser-mocks:build_types",
|
||||
|
|
130
packages/core/i18n/core-i18n-server-internal/BUILD.bazel
Normal file
130
packages/core/i18n/core-i18n-server-internal/BUILD.bazel
Normal file
|
@ -0,0 +1,130 @@
|
|||
load("@npm//@bazel/typescript:index.bzl", "ts_config")
|
||||
load("@build_bazel_rules_nodejs//:index.bzl", "js_library")
|
||||
load("//src/dev/bazel:index.bzl", "jsts_transpiler", "pkg_npm", "pkg_npm_types", "ts_project")
|
||||
|
||||
PKG_DIRNAME = "core-i18n-server-internal"
|
||||
PKG_REQUIRE_NAME = "@kbn/core-i18n-server-internal"
|
||||
|
||||
SOURCE_FILES = glob(
|
||||
[
|
||||
"**/*.ts",
|
||||
],
|
||||
exclude = [
|
||||
"**/*.config.js",
|
||||
"**/*.mock.*",
|
||||
"**/*.test.*",
|
||||
"**/*.stories.*",
|
||||
"**/__snapshots__",
|
||||
"**/integration_tests",
|
||||
"**/mocks",
|
||||
"**/scripts",
|
||||
"**/storybook",
|
||||
"**/test_fixtures",
|
||||
"**/test_helpers",
|
||||
],
|
||||
)
|
||||
|
||||
SRCS = SOURCE_FILES
|
||||
|
||||
filegroup(
|
||||
name = "srcs",
|
||||
srcs = SRCS,
|
||||
)
|
||||
|
||||
NPM_MODULE_EXTRA_FILES = [
|
||||
"package.json",
|
||||
]
|
||||
|
||||
RUNTIME_DEPS = [
|
||||
"@npm//json-stable-stringify",
|
||||
"@npm//globby",
|
||||
"@npm//rxjs",
|
||||
"//packages/kbn-config-schema",
|
||||
"//packages/core/base/core-base-common",
|
||||
"//packages/kbn-i18n",
|
||||
"//packages/kbn-utils",
|
||||
"//packages/kbn-config-mocks",
|
||||
"//packages/kbn-utility-types",
|
||||
"//packages/core/base/core-base-server-mocks",
|
||||
"//packages/core/http/core-http-server-mocks"
|
||||
]
|
||||
|
||||
TYPES_DEPS = [
|
||||
"@npm//@types/node",
|
||||
"@npm//@types/jest",
|
||||
"@npm//@types/json-stable-stringify",
|
||||
"//packages/kbn-config:npm_module_types",
|
||||
"//packages/kbn-config-schema:npm_module_types",
|
||||
"//packages/kbn-logging:npm_module_types",
|
||||
"//packages/core/base/core-base-server-internal:npm_module_types",
|
||||
"//packages/core/base/core-base-common:npm_module_types",
|
||||
"//packages/core/deprecations/core-deprecations-common:npm_module_types",
|
||||
"//packages/core/i18n/core-i18n-server:npm_module_types",
|
||||
"//packages/core/http/core-http-server:npm_module_types",
|
||||
"//packages/core/http/core-http-server-internal:npm_module_types",
|
||||
"//packages/core/elasticsearch/core-elasticsearch-server:npm_module_types",
|
||||
"//packages/core/usage-data/core-usage-data-base-server-internal:npm_module_types",
|
||||
"//packages/core/deprecations/core-deprecations-server:npm_module_types",
|
||||
]
|
||||
|
||||
jsts_transpiler(
|
||||
name = "target_node",
|
||||
srcs = SRCS,
|
||||
build_pkg_name = package_name(),
|
||||
)
|
||||
|
||||
ts_config(
|
||||
name = "tsconfig",
|
||||
src = "tsconfig.json",
|
||||
deps = [
|
||||
"//:tsconfig.base.json",
|
||||
"//:tsconfig.bazel.json",
|
||||
],
|
||||
)
|
||||
|
||||
ts_project(
|
||||
name = "tsc_types",
|
||||
args = ['--pretty'],
|
||||
srcs = SRCS,
|
||||
deps = TYPES_DEPS,
|
||||
declaration = True,
|
||||
declaration_map = True,
|
||||
emit_declaration_only = True,
|
||||
out_dir = "target_types",
|
||||
root_dir = ".",
|
||||
tsconfig = ":tsconfig",
|
||||
)
|
||||
|
||||
js_library(
|
||||
name = PKG_DIRNAME,
|
||||
srcs = NPM_MODULE_EXTRA_FILES,
|
||||
deps = RUNTIME_DEPS + [":target_node"],
|
||||
package_name = PKG_REQUIRE_NAME,
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
pkg_npm(
|
||||
name = "npm_module",
|
||||
deps = [":" + PKG_DIRNAME],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "build",
|
||||
srcs = [":npm_module"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
pkg_npm_types(
|
||||
name = "npm_module_types",
|
||||
srcs = SRCS,
|
||||
deps = [":tsc_types"],
|
||||
package_name = PKG_REQUIRE_NAME,
|
||||
tsconfig = ":tsconfig",
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "build_types",
|
||||
srcs = [":npm_module_types"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
3
packages/core/i18n/core-i18n-server-internal/README.md
Normal file
3
packages/core/i18n/core-i18n-server-internal/README.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
# @kbn/core-i18n-server-internal
|
||||
|
||||
This package contains the internal implementation of Core's server-side i18n service.
|
|
@ -6,7 +6,5 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import Fs from 'fs';
|
||||
import { promisify } from 'util';
|
||||
|
||||
export const readFile = promisify(Fs.readFile);
|
||||
export type { I18nConfigType } from './src';
|
||||
export { config, I18nService } from './src';
|
13
packages/core/i18n/core-i18n-server-internal/jest.config.js
Normal file
13
packages/core/i18n/core-i18n-server-internal/jest.config.js
Normal file
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
preset: '@kbn/test/jest_node',
|
||||
rootDir: '../../../..',
|
||||
roots: ['<rootDir>/packages/core/i18n/core-i18n-server-internal'],
|
||||
};
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "@kbn/core-i18n-server-internal",
|
||||
"private": true,
|
||||
"version": "1.0.0",
|
||||
"main": "./target_node/index.js",
|
||||
"author": "Kibana Core",
|
||||
"license": "SSPL-1.0 OR Elastic License 2.0"
|
||||
}
|
|
@ -10,6 +10,6 @@ export const globbyMock = jest.fn();
|
|||
jest.doMock('globby', () => globbyMock);
|
||||
|
||||
export const readFileMock = jest.fn();
|
||||
jest.doMock('./fs', () => ({
|
||||
jest.doMock('fs/promises', () => ({
|
||||
readFile: readFileMock,
|
||||
}));
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
import { resolve, dirname } from 'path';
|
||||
import globby from 'globby';
|
||||
import { readFile } from './fs';
|
||||
import { readFile } from 'fs/promises';
|
||||
|
||||
interface I18NRCFileStructure {
|
||||
translations?: string[];
|
|
@ -17,7 +17,7 @@ import { I18nService } from './i18n_service';
|
|||
|
||||
import { configServiceMock } from '@kbn/config-mocks';
|
||||
import { mockCoreContext } from '@kbn/core-base-server-mocks';
|
||||
import { httpServiceMock } from '../mocks';
|
||||
import { httpServiceMock } from '@kbn/core-http-server-mocks';
|
||||
|
||||
const getConfigService = (locale = 'en') => {
|
||||
const configService = configServiceMock.create();
|
|
@ -14,6 +14,7 @@ import type {
|
|||
InternalHttpServicePreboot,
|
||||
InternalHttpServiceSetup,
|
||||
} from '@kbn/core-http-server-internal';
|
||||
import type { I18nServiceSetup } from '@kbn/core-i18n-server';
|
||||
import { config as i18nConfigDef, I18nConfigType } from './i18n_config';
|
||||
import { getKibanaTranslationFiles } from './get_kibana_translation_files';
|
||||
import { initTranslations } from './init_translations';
|
||||
|
@ -29,21 +30,6 @@ export interface SetupDeps {
|
|||
pluginPaths: string[];
|
||||
}
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface I18nServiceSetup {
|
||||
/**
|
||||
* Return the locale currently in use.
|
||||
*/
|
||||
getLocale(): string;
|
||||
|
||||
/**
|
||||
* Return the absolute paths to translation files currently in use.
|
||||
*/
|
||||
getTranslationFiles(): string[];
|
||||
}
|
||||
|
||||
export class I18nService {
|
||||
private readonly log: Logger;
|
||||
private readonly configService: IConfigService;
|
|
@ -9,4 +9,3 @@
|
|||
export { config } from './i18n_config';
|
||||
export type { I18nConfigType } from './i18n_config';
|
||||
export { I18nService } from './i18n_service';
|
||||
export type { I18nServiceSetup } from './i18n_service';
|
18
packages/core/i18n/core-i18n-server-internal/tsconfig.json
Normal file
18
packages/core/i18n/core-i18n-server-internal/tsconfig.json
Normal file
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"extends": "../../../../tsconfig.bazel.json",
|
||||
"compilerOptions": {
|
||||
"declaration": true,
|
||||
"declarationMap": true,
|
||||
"emitDeclarationOnly": true,
|
||||
"outDir": "target_types",
|
||||
"rootDir": ".",
|
||||
"stripInternal": false,
|
||||
"types": [
|
||||
"jest",
|
||||
"node"
|
||||
]
|
||||
},
|
||||
"include": [
|
||||
"**/*.ts",
|
||||
]
|
||||
}
|
115
packages/core/i18n/core-i18n-server-mocks/BUILD.bazel
Normal file
115
packages/core/i18n/core-i18n-server-mocks/BUILD.bazel
Normal file
|
@ -0,0 +1,115 @@
|
|||
load("@npm//@bazel/typescript:index.bzl", "ts_config")
|
||||
load("@build_bazel_rules_nodejs//:index.bzl", "js_library")
|
||||
load("//src/dev/bazel:index.bzl", "jsts_transpiler", "pkg_npm", "pkg_npm_types", "ts_project")
|
||||
|
||||
PKG_DIRNAME = "core-i18n-server-mocks"
|
||||
PKG_REQUIRE_NAME = "@kbn/core-i18n-server-mocks"
|
||||
|
||||
SOURCE_FILES = glob(
|
||||
[
|
||||
"**/*.ts",
|
||||
"**/*.tsx",
|
||||
],
|
||||
exclude = [
|
||||
"**/*.config.js",
|
||||
"**/*.test.*",
|
||||
"**/*.stories.*",
|
||||
"**/__snapshots__/**",
|
||||
"**/integration_tests/**",
|
||||
"**/scripts/**",
|
||||
"**/storybook/**",
|
||||
"**/test_fixtures/**",
|
||||
"**/test_helpers/**",
|
||||
],
|
||||
)
|
||||
|
||||
SRCS = SOURCE_FILES
|
||||
|
||||
filegroup(
|
||||
name = "srcs",
|
||||
srcs = SRCS,
|
||||
)
|
||||
|
||||
NPM_MODULE_EXTRA_FILES = [
|
||||
"package.json",
|
||||
]
|
||||
|
||||
RUNTIME_DEPS = [
|
||||
"//packages/core/i18n/core-i18n-server-internal",
|
||||
]
|
||||
|
||||
TYPES_DEPS = [
|
||||
"@npm//@types/node",
|
||||
"@npm//@types/jest",
|
||||
"//packages/kbn-utility-types:npm_module_types",
|
||||
"//packages/core/i18n/core-i18n-server:npm_module_types",
|
||||
"//packages/core/i18n/core-i18n-server-internal:npm_module_types",
|
||||
]
|
||||
|
||||
jsts_transpiler(
|
||||
name = "target_node",
|
||||
srcs = SRCS,
|
||||
build_pkg_name = package_name(),
|
||||
)
|
||||
|
||||
jsts_transpiler(
|
||||
name = "target_web",
|
||||
srcs = SRCS,
|
||||
build_pkg_name = package_name(),
|
||||
web = True,
|
||||
)
|
||||
|
||||
ts_config(
|
||||
name = "tsconfig",
|
||||
src = "tsconfig.json",
|
||||
deps = [
|
||||
"//:tsconfig.base.json",
|
||||
"//:tsconfig.bazel.json",
|
||||
],
|
||||
)
|
||||
|
||||
ts_project(
|
||||
name = "tsc_types",
|
||||
args = ['--pretty'],
|
||||
srcs = SRCS,
|
||||
deps = TYPES_DEPS,
|
||||
declaration = True,
|
||||
declaration_map = True,
|
||||
emit_declaration_only = True,
|
||||
out_dir = "target_types",
|
||||
tsconfig = ":tsconfig",
|
||||
)
|
||||
|
||||
js_library(
|
||||
name = PKG_DIRNAME,
|
||||
srcs = NPM_MODULE_EXTRA_FILES,
|
||||
deps = RUNTIME_DEPS + [":target_node", ":target_web"],
|
||||
package_name = PKG_REQUIRE_NAME,
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
pkg_npm(
|
||||
name = "npm_module",
|
||||
deps = [":" + PKG_DIRNAME],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "build",
|
||||
srcs = [":npm_module"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
pkg_npm_types(
|
||||
name = "npm_module_types",
|
||||
srcs = SRCS,
|
||||
deps = [":tsc_types"],
|
||||
package_name = PKG_REQUIRE_NAME,
|
||||
tsconfig = ":tsconfig",
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "build_types",
|
||||
srcs = [":npm_module_types"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
3
packages/core/i18n/core-i18n-server-mocks/README.md
Normal file
3
packages/core/i18n/core-i18n-server-mocks/README.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
# @kbn/core-i18n-server-mocks
|
||||
|
||||
This package contains the mocks for Core's server-side i18n service.
|
9
packages/core/i18n/core-i18n-server-mocks/index.ts
Normal file
9
packages/core/i18n/core-i18n-server-mocks/index.ts
Normal file
|
@ -0,0 +1,9 @@
|
|||
/*
|
||||
* 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 { i18nServiceMock } from './src/i18n_service.mock';
|
13
packages/core/i18n/core-i18n-server-mocks/jest.config.js
Normal file
13
packages/core/i18n/core-i18n-server-mocks/jest.config.js
Normal file
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
preset: '@kbn/test',
|
||||
rootDir: '../../../..',
|
||||
roots: ['<rootDir>/packages/core/i18n/core-i18n-server-mocks'],
|
||||
};
|
9
packages/core/i18n/core-i18n-server-mocks/package.json
Normal file
9
packages/core/i18n/core-i18n-server-mocks/package.json
Normal file
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"name": "@kbn/core-i18n-server-mocks",
|
||||
"private": true,
|
||||
"version": "1.0.0",
|
||||
"main": "./target_node/index.js",
|
||||
"browser": "./target_web/index.js",
|
||||
"author": "Kibana Core",
|
||||
"license": "SSPL-1.0 OR Elastic License 2.0"
|
||||
}
|
|
@ -6,8 +6,9 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import { PublicMethodsOf } from '@kbn/utility-types';
|
||||
import type { I18nServiceSetup, I18nService } from './i18n_service';
|
||||
import type { PublicMethodsOf } from '@kbn/utility-types';
|
||||
import type { I18nService } from '@kbn/core-i18n-server-internal';
|
||||
import type { I18nServiceSetup } from '@kbn/core-i18n-server';
|
||||
|
||||
const createSetupContractMock = () => {
|
||||
const mock: jest.Mocked<I18nServiceSetup> = {
|
17
packages/core/i18n/core-i18n-server-mocks/tsconfig.json
Normal file
17
packages/core/i18n/core-i18n-server-mocks/tsconfig.json
Normal file
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"extends": "../../../../tsconfig.bazel.json",
|
||||
"compilerOptions": {
|
||||
"declaration": true,
|
||||
"declarationMap": true,
|
||||
"emitDeclarationOnly": true,
|
||||
"outDir": "target_types",
|
||||
"stripInternal": false,
|
||||
"types": [
|
||||
"jest",
|
||||
"node"
|
||||
]
|
||||
},
|
||||
"include": [
|
||||
"**/*.ts"
|
||||
]
|
||||
}
|
106
packages/core/i18n/core-i18n-server/BUILD.bazel
Normal file
106
packages/core/i18n/core-i18n-server/BUILD.bazel
Normal file
|
@ -0,0 +1,106 @@
|
|||
load("@npm//@bazel/typescript:index.bzl", "ts_config")
|
||||
load("@build_bazel_rules_nodejs//:index.bzl", "js_library")
|
||||
load("//src/dev/bazel:index.bzl", "jsts_transpiler", "pkg_npm", "pkg_npm_types", "ts_project")
|
||||
|
||||
PKG_DIRNAME = "core-i18n-server"
|
||||
PKG_REQUIRE_NAME = "@kbn/core-i18n-server"
|
||||
|
||||
SOURCE_FILES = glob(
|
||||
[
|
||||
"**/*.ts",
|
||||
],
|
||||
exclude = [
|
||||
"**/*.config.js",
|
||||
"**/*.mock.*",
|
||||
"**/*.test.*",
|
||||
"**/*.stories.*",
|
||||
"**/__snapshots__",
|
||||
"**/integration_tests",
|
||||
"**/mocks",
|
||||
"**/scripts",
|
||||
"**/storybook",
|
||||
"**/test_fixtures",
|
||||
"**/test_helpers",
|
||||
],
|
||||
)
|
||||
|
||||
SRCS = SOURCE_FILES
|
||||
|
||||
filegroup(
|
||||
name = "srcs",
|
||||
srcs = SRCS,
|
||||
)
|
||||
|
||||
NPM_MODULE_EXTRA_FILES = [
|
||||
"package.json",
|
||||
]
|
||||
|
||||
RUNTIME_DEPS = [
|
||||
]
|
||||
|
||||
TYPES_DEPS = [
|
||||
"@npm//@types/node",
|
||||
"@npm//@types/jest",
|
||||
]
|
||||
|
||||
jsts_transpiler(
|
||||
name = "target_node",
|
||||
srcs = SRCS,
|
||||
build_pkg_name = package_name(),
|
||||
)
|
||||
|
||||
ts_config(
|
||||
name = "tsconfig",
|
||||
src = "tsconfig.json",
|
||||
deps = [
|
||||
"//:tsconfig.base.json",
|
||||
"//:tsconfig.bazel.json",
|
||||
],
|
||||
)
|
||||
|
||||
ts_project(
|
||||
name = "tsc_types",
|
||||
args = ['--pretty'],
|
||||
srcs = SRCS,
|
||||
deps = TYPES_DEPS,
|
||||
declaration = True,
|
||||
declaration_map = True,
|
||||
emit_declaration_only = True,
|
||||
out_dir = "target_types",
|
||||
root_dir = ".",
|
||||
tsconfig = ":tsconfig",
|
||||
)
|
||||
|
||||
js_library(
|
||||
name = PKG_DIRNAME,
|
||||
srcs = NPM_MODULE_EXTRA_FILES,
|
||||
deps = RUNTIME_DEPS + [":target_node"],
|
||||
package_name = PKG_REQUIRE_NAME,
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
pkg_npm(
|
||||
name = "npm_module",
|
||||
deps = [":" + PKG_DIRNAME],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "build",
|
||||
srcs = [":npm_module"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
pkg_npm_types(
|
||||
name = "npm_module_types",
|
||||
srcs = SRCS,
|
||||
deps = [":tsc_types"],
|
||||
package_name = PKG_REQUIRE_NAME,
|
||||
tsconfig = ":tsconfig",
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "build_types",
|
||||
srcs = [":npm_module_types"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
3
packages/core/i18n/core-i18n-server/README.md
Normal file
3
packages/core/i18n/core-i18n-server/README.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
# @kbn/core-i18n-browser
|
||||
|
||||
This package contains the public types for Core's server-side i18n service.
|
9
packages/core/i18n/core-i18n-server/index.ts
Normal file
9
packages/core/i18n/core-i18n-server/index.ts
Normal file
|
@ -0,0 +1,9 @@
|
|||
/*
|
||||
* 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 type { I18nServiceSetup } from './src/types';
|
13
packages/core/i18n/core-i18n-server/jest.config.js
Normal file
13
packages/core/i18n/core-i18n-server/jest.config.js
Normal file
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
preset: '@kbn/test',
|
||||
rootDir: '../../../..',
|
||||
roots: ['<rootDir>/packages/core/i18n/core-i18n-server'],
|
||||
};
|
9
packages/core/i18n/core-i18n-server/package.json
Normal file
9
packages/core/i18n/core-i18n-server/package.json
Normal file
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"name": "@kbn/core-i18n-server",
|
||||
"private": true,
|
||||
"version": "1.0.0",
|
||||
"main": "./target_node/index.js",
|
||||
"browser": "./target_web/index.js",
|
||||
"author": "Kibana Core",
|
||||
"license": "SSPL-1.0 OR Elastic License 2.0"
|
||||
}
|
22
packages/core/i18n/core-i18n-server/src/types.ts
Normal file
22
packages/core/i18n/core-i18n-server/src/types.ts
Normal file
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface I18nServiceSetup {
|
||||
/**
|
||||
* Return the locale currently in use.
|
||||
*/
|
||||
getLocale(): string;
|
||||
|
||||
/**
|
||||
* Return the absolute paths to translation files currently in use.
|
||||
*/
|
||||
getTranslationFiles(): string[];
|
||||
}
|
17
packages/core/i18n/core-i18n-server/tsconfig.json
Normal file
17
packages/core/i18n/core-i18n-server/tsconfig.json
Normal file
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"extends": "../../../../tsconfig.bazel.json",
|
||||
"compilerOptions": {
|
||||
"declaration": true,
|
||||
"declarationMap": true,
|
||||
"emitDeclarationOnly": true,
|
||||
"outDir": "target_types",
|
||||
"stripInternal": false,
|
||||
"types": [
|
||||
"jest",
|
||||
"node"
|
||||
]
|
||||
},
|
||||
"include": [
|
||||
"**/*.ts"
|
||||
]
|
||||
}
|
|
@ -66,12 +66,13 @@ import type {
|
|||
} from '@kbn/core-saved-objects-server';
|
||||
import { DeprecationsServiceSetup } from '@kbn/core-deprecations-server';
|
||||
|
||||
import { I18nServiceSetup } from '@kbn/core-i18n-server';
|
||||
import { HttpResources } from './http_resources';
|
||||
import { PluginsServiceSetup, PluginsServiceStart, PluginOpaqueId } from './plugins';
|
||||
import { UiSettingsServiceSetup, UiSettingsServiceStart } from './ui_settings';
|
||||
import { StatusServiceSetup } from './status';
|
||||
import { CoreUsageDataStart, CoreUsageDataSetup } from './core_usage_data';
|
||||
import { I18nServiceSetup } from './i18n';
|
||||
|
||||
// Because of #79265 we need to explicitly import, then export these types for
|
||||
// scripts/telemetry_check.js to work as expected
|
||||
import {
|
||||
|
@ -425,7 +426,7 @@ export type {
|
|||
} from '@kbn/core-metrics-server';
|
||||
export { EventLoopDelaysMonitor } from '@kbn/core-metrics-collectors-server-internal';
|
||||
|
||||
export type { I18nServiceSetup } from './i18n';
|
||||
export type { I18nServiceSetup } from '@kbn/core-i18n-server';
|
||||
export type {
|
||||
RegisterDeprecationsConfig,
|
||||
GetDeprecationsContext,
|
||||
|
|
|
@ -49,6 +49,7 @@ import {
|
|||
InternalDeprecationsServiceSetup,
|
||||
InternalDeprecationsServiceStart,
|
||||
} from '@kbn/core-deprecations-server-internal';
|
||||
import { I18nServiceSetup } from '@kbn/core-i18n-server';
|
||||
import {
|
||||
InternalUiSettingsServicePreboot,
|
||||
InternalUiSettingsServiceSetup,
|
||||
|
@ -58,7 +59,6 @@ import { InternalRenderingServiceSetup } from './rendering';
|
|||
import { InternalHttpResourcesPreboot, InternalHttpResourcesSetup } from './http_resources';
|
||||
import { InternalStatusServiceSetup } from './status';
|
||||
import { CoreUsageDataStart, InternalCoreUsageDataSetup } from './core_usage_data';
|
||||
import { I18nServiceSetup } from './i18n';
|
||||
|
||||
/** @internal */
|
||||
export interface InternalCorePreboot {
|
||||
|
|
|
@ -27,6 +27,8 @@ import { typeRegistryMock as savedObjectsTypeRegistryMock } from '@kbn/core-save
|
|||
import { savedObjectsServiceMock } from '@kbn/core-saved-objects-server-mocks';
|
||||
import { savedObjectsClientMock } from '@kbn/core-saved-objects-api-server-mocks';
|
||||
import { deprecationsServiceMock } from '@kbn/core-deprecations-server-mocks';
|
||||
import { i18nServiceMock } from '@kbn/core-i18n-server-mocks';
|
||||
|
||||
import type {
|
||||
PluginInitializerContext,
|
||||
CoreSetup,
|
||||
|
@ -41,7 +43,6 @@ import { uiSettingsServiceMock } from './ui_settings/ui_settings_service.mock';
|
|||
import { SharedGlobalConfig } from './plugins';
|
||||
import { statusServiceMock } from './status/status_service.mock';
|
||||
import { coreUsageDataServiceMock } from './core_usage_data/core_usage_data_service.mock';
|
||||
import { i18nServiceMock } from './i18n/i18n_service.mock';
|
||||
|
||||
export { configServiceMock, configDeprecationsMock } from '@kbn/config-mocks';
|
||||
export { loggingSystemMock } from '@kbn/core-logging-server-mocks';
|
||||
|
@ -63,7 +64,7 @@ export { contextServiceMock } from '@kbn/core-http-context-server-mocks';
|
|||
export { capabilitiesServiceMock } from '@kbn/core-capabilities-server-mocks';
|
||||
export { deprecationsServiceMock } from '@kbn/core-deprecations-server-mocks';
|
||||
export { coreUsageDataServiceMock } from './core_usage_data/core_usage_data_service.mock';
|
||||
export { i18nServiceMock } from './i18n/i18n_service.mock';
|
||||
export { i18nServiceMock } from '@kbn/core-i18n-server-mocks';
|
||||
export { executionContextServiceMock } from '@kbn/core-execution-context-server-mocks';
|
||||
export { docLinksServiceMock } from '@kbn/core-doc-links-server-mocks';
|
||||
export { analyticsServiceMock } from '@kbn/core-analytics-server-mocks';
|
||||
|
|
|
@ -103,10 +103,10 @@ jest.doMock('@kbn/core-logging-server-internal', () => ({
|
|||
LoggingService: jest.fn(() => mockLoggingService),
|
||||
}));
|
||||
|
||||
import { i18nServiceMock } from './i18n/i18n_service.mock';
|
||||
import { i18nServiceMock } from '@kbn/core-i18n-server-mocks';
|
||||
|
||||
export const mockI18nService = i18nServiceMock.create();
|
||||
jest.doMock('./i18n/i18n_service', () => ({
|
||||
jest.doMock('@kbn/core-i18n-server-internal', () => ({
|
||||
I18nService: jest.fn(() => mockI18nService),
|
||||
}));
|
||||
|
||||
|
|
|
@ -50,12 +50,12 @@ import {
|
|||
savedObjectsMigrationConfig,
|
||||
} from '@kbn/core-saved-objects-base-server-internal';
|
||||
import { SavedObjectsService } from '@kbn/core-saved-objects-server-internal';
|
||||
import { I18nService, config as i18nConfig } from '@kbn/core-i18n-server-internal';
|
||||
import {
|
||||
DeprecationsService,
|
||||
config as deprecationConfig,
|
||||
} from '@kbn/core-deprecations-server-internal';
|
||||
import { CoreApp } from './core_app';
|
||||
import { I18nService } from './i18n';
|
||||
import { HttpResourcesService } from './http_resources';
|
||||
import { RenderingService } from './rendering';
|
||||
import { UiSettingsService } from './ui_settings';
|
||||
|
@ -65,7 +65,6 @@ import { PluginsService, config as pluginsConfig } from './plugins';
|
|||
import { StatusService } from './status/status_service';
|
||||
import { config as uiSettingsConfig } from './ui_settings';
|
||||
import { config as statusConfig } from './status';
|
||||
import { config as i18nConfig } from './i18n';
|
||||
import { InternalCorePreboot, InternalCoreSetup, InternalCoreStart } from './internal_types';
|
||||
import { CoreUsageDataService } from './core_usage_data';
|
||||
import { CoreRouteHandlerContext } from './core_route_handler_context';
|
||||
|
|
24
yarn.lock
24
yarn.lock
|
@ -3003,6 +3003,18 @@
|
|||
version "0.0.0"
|
||||
uid ""
|
||||
|
||||
"@kbn/core-i18n-server-internal@link:bazel-bin/packages/core/i18n/core-i18n-server-internal":
|
||||
version "0.0.0"
|
||||
uid ""
|
||||
|
||||
"@kbn/core-i18n-server-mocks@link:bazel-bin/packages/core/i18n/core-i18n-server-mocks":
|
||||
version "0.0.0"
|
||||
uid ""
|
||||
|
||||
"@kbn/core-i18n-server@link:bazel-bin/packages/core/i18n/core-i18n-server":
|
||||
version "0.0.0"
|
||||
uid ""
|
||||
|
||||
"@kbn/core-injected-metadata-browser-internal@link:bazel-bin/packages/core/injected-metadata/core-injected-metadata-browser-internal":
|
||||
version "0.0.0"
|
||||
uid ""
|
||||
|
@ -7057,6 +7069,18 @@
|
|||
version "0.0.0"
|
||||
uid ""
|
||||
|
||||
"@types/kbn__core-i18n-server-internal@link:bazel-bin/packages/core/i18n/core-i18n-server-internal/npm_module_types":
|
||||
version "0.0.0"
|
||||
uid ""
|
||||
|
||||
"@types/kbn__core-i18n-server-mocks@link:bazel-bin/packages/core/i18n/core-i18n-server-mocks/npm_module_types":
|
||||
version "0.0.0"
|
||||
uid ""
|
||||
|
||||
"@types/kbn__core-i18n-server@link:bazel-bin/packages/core/i18n/core-i18n-server/npm_module_types":
|
||||
version "0.0.0"
|
||||
uid ""
|
||||
|
||||
"@types/kbn__core-injected-metadata-browser-internal@link:bazel-bin/packages/core/injected-metadata/core-injected-metadata-browser-internal/npm_module_types":
|
||||
version "0.0.0"
|
||||
uid ""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue