Skip to content

Commit fe1a8c9

Browse files
committed
move kbn-client into its own package (#258963)
## Summary Extracts the Kibana tooling HTTP client (`KbnClient` and related helpers) from `@kbn/test` into a dedicated `@kbn/kbn-client` package. `@kbn/test` continues to re-export the same symbols so existing `import { … } from '@kbn/test'` call sites keep working. ### Why - Smaller, clearer dependency graph for tools that only need a Kibana HTTP client (e.g. `Scout`, `Cypress` helpers, `evals`) without pulling in the full FTR/Jest/Mocha surface of `@kbn/test`. - Single public entry for client APIs instead of deep imports like `@kbn/test/src/kbn_client/...`, which aligns with package boundaries and makes types like UiSettingValues and ReqOptions part of a stable export surface. - Easier next steps to peel off other focused pieces (e.g. SAML session management) on top of `@kbn/kbn-client` instead of growing `@kbn/test` further. ### Notes - New package is `devOnly` like @kbn/test. - Jest/unit tests for the client live under `@kbn/kbn-client`. --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> (cherry picked from commit c701e38) # Conflicts: # .github/CODEOWNERS # src/platform/packages/shared/kbn-kbn-client/src/kbn_client/kbn_client_requester_error.test.ts # src/platform/packages/shared/kbn-test/src/auth/session_manager.ts # x-pack/platform/packages/shared/kbn-evals/moon.yml # x-pack/platform/packages/shared/kbn-evals/src/utils/evaluations_kbn_client.test.ts # x-pack/platform/packages/shared/kbn-evals/src/utils/evaluations_kbn_client.ts # x-pack/platform/packages/shared/kbn-evals/src/utils/kbn_client_with_retries.ts # x-pack/platform/packages/shared/kbn-evals/tsconfig.json # x-pack/solutions/security/test/cloud_security_posture_functional/data_views/data_views.ts # x-pack/solutions/security/test/moon.yml # x-pack/solutions/security/test/tsconfig.json
1 parent fbe8d32 commit fe1a8c9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+176
-31
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,7 @@ src/platform/packages/shared/kbn-io-ts-utils @elastic/obs-knowledge-team
520520
src/platform/packages/shared/kbn-jest-benchmarks @elastic/observability-ui
521521
src/platform/packages/shared/kbn-lazy-object @elastic/kibana-operations
522522
src/platform/packages/shared/kbn-lens-embeddable-utils @elastic/obs-presentation-team @elastic/kibana-visualizations
523+
src/platform/packages/shared/kbn-kbn-client @elastic/kibana-operations @elastic/appex-qa
523524
src/platform/packages/shared/kbn-licensing-types @elastic/kibana-core
524525
src/platform/packages/shared/kbn-lock-manager @elastic/obs-ai-assistant
525526
src/platform/packages/shared/kbn-logging @elastic/kibana-core

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1612,6 +1612,7 @@
16121612
"@kbn/jest-serializers": "link:src/platform/packages/private/kbn-jest-serializers",
16131613
"@kbn/journeys": "link:src/platform/packages/private/kbn-journeys",
16141614
"@kbn/json-ast": "link:packages/kbn-json-ast",
1615+
"@kbn/kbn-client": "link:src/platform/packages/shared/kbn-kbn-client",
16151616
"@kbn/kbn-genai-cli": "link:x-pack/solutions/observability/packages/kbn-genai-cli",
16161617
"@kbn/kibana-manifest-schema": "link:packages/kbn-kibana-manifest-schema",
16171618
"@kbn/lazy-object": "link:src/platform/packages/shared/kbn-lazy-object",

src/platform/packages/shared/kbn-cypress-test-helper/moon.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ dependsOn:
2222
- '@kbn/security-plugin'
2323
- '@kbn/tooling-log'
2424
- '@kbn/repo-info'
25+
- '@kbn/kbn-client'
2526
- '@kbn/test'
2627
- '@kbn/dev-cli-runner'
2728
- '@kbn/core-status-common'

src/platform/packages/shared/kbn-cypress-test-helper/src/services/stack_services.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import type { ToolingLog } from '@kbn/tooling-log';
1212
import type { KbnClientOptions } from '@kbn/test';
1313
import { KbnClient } from '@kbn/test';
1414
import pRetry from 'p-retry';
15-
import type { ReqOptions } from '@kbn/test/src/kbn_client/kbn_client_requester';
15+
import type { ReqOptions } from '@kbn/kbn-client';
1616
import { type AxiosResponse } from 'axios';
1717
import type { ClientOptions } from '@elastic/elasticsearch/lib/client';
1818
import fs from 'fs';

src/platform/packages/shared/kbn-cypress-test-helper/tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"@kbn/security-plugin",
2525
"@kbn/tooling-log",
2626
"@kbn/repo-info",
27+
"@kbn/kbn-client",
2728
"@kbn/test",
2829
"@kbn/dev-cli-runner",
2930
"@kbn/core-status-common",

src/platform/packages/shared/kbn-test/src/kbn_client/index.ts renamed to src/platform/packages/shared/kbn-kbn-client/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,4 @@
77
* License v3.0 only", or the "Server Side Public License, v 1".
88
*/
99

10-
export * from './kbn_client';
11-
export { uriencode } from './kbn_client_requester';
10+
export * from './src/kbn_client';
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the "Elastic License
4+
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
5+
* Public License v 1"; you may not use this file except in compliance with, at
6+
* your election, the "Elastic License 2.0", the "GNU Affero General Public
7+
* License v3.0 only", or the "Server Side Public License, v 1".
8+
*/
9+
10+
module.exports = {
11+
preset: '@kbn/test/jest_node',
12+
rootDir: '../../../../..',
13+
roots: ['<rootDir>/src/platform/packages/shared/kbn-kbn-client'],
14+
};
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"type": "shared-common",
3+
"id": "@kbn/kbn-client",
4+
"owner": [
5+
"@elastic/kibana-operations",
6+
"@elastic/appex-qa"
7+
],
8+
"group": "platform",
9+
"visibility": "shared",
10+
"devOnly": true
11+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# This file is generated by the @kbn/moon package. Any manual edits will be erased!
2+
# To extend this, write your extensions/overrides to 'moon.extend.yml'
3+
# then regenerate this file with: 'node scripts/regenerate_moon_projects.js --update --filter @kbn/kbn-client'
4+
5+
$schema: https://moonrepo.dev/schemas/project.json
6+
id: '@kbn/kbn-client'
7+
layer: unknown
8+
owners:
9+
defaultOwner: '@elastic/kibana-operations'
10+
toolchains:
11+
default: node
12+
language: typescript
13+
project:
14+
title: '@kbn/kbn-client'
15+
description: Moon project for @kbn/kbn-client
16+
channel: ''
17+
owner: '@elastic/kibana-operations'
18+
sourceRoot: src/platform/packages/shared/kbn-kbn-client
19+
dependsOn:
20+
- '@kbn/core-saved-objects-api-server'
21+
- '@kbn/dev-cli-errors'
22+
- '@kbn/dev-utils'
23+
- '@kbn/repo-info'
24+
- '@kbn/tooling-log'
25+
tags:
26+
- shared-common
27+
- package
28+
- dev
29+
- group-platform
30+
- shared
31+
- jest-unit-tests
32+
fileGroups:
33+
src:
34+
- '**/*.ts'
35+
- '!target/**/*'
36+
tasks:
37+
jest:
38+
command: node
39+
args:
40+
- '--no-experimental-require-module'
41+
- $workspaceRoot/scripts/jest
42+
- '--config'
43+
- $projectRoot/jest.config.js
44+
options:
45+
runFromWorkspaceRoot: true
46+
inputs:
47+
- '@group(src)'
48+
jestCI:
49+
command: node
50+
args:
51+
- '--no-experimental-require-module'
52+
- $workspaceRoot/scripts/jest
53+
- '--config'
54+
- $projectRoot/jest.config.js
55+
options:
56+
runFromWorkspaceRoot: true
57+
inputs:
58+
- '@group(src)'
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"name": "@kbn/kbn-client",
3+
"private": true,
4+
"version": "1.0.0",
5+
"license": "Elastic License 2.0 OR AGPL-3.0-only OR SSPL-1.0"
6+
}

0 commit comments

Comments
 (0)