Skip to content

Commit 3ab627c

Browse files
committed
type issue fixes
1 parent d693bcc commit 3ab627c

16 files changed

Lines changed: 141 additions & 73 deletions

File tree

packages/kbn-performance-testing-dataset-extractor/src/es_client.ts

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

10+
import type { estypes } from 'elasticsearch-8.x';
1011
import { Client, HttpConnection } from 'elasticsearch-8.x'; // Switch to `@elastic/elasticsearch` when the CI cluster is upgraded.
11-
import type {
12-
QueryDslQueryContainer,
13-
SearchRequest,
14-
MsearchRequestItem,
15-
} from 'elasticsearch-8.x/lib/api/types'; // Switch to `@elastic/elasticsearch` when the CI cluster is upgraded.
12+
13+
type QueryDslQueryContainer = estypes.QueryDslQueryContainer;
14+
type SearchRequest = estypes.SearchRequest;
15+
type MsearchRequestItem = estypes.MsearchRequestItem;
1616
import type { ToolingLog } from '@kbn/tooling-log';
1717

1818
interface ClientOptions {

x-pack/platform/packages/shared/kbn-evals-phoenix-executor/src/client.ts

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77

88
import type { PhoenixClient } from '@arizeai/phoenix-client';
99
import { createClient } from '@arizeai/phoenix-client';
10-
import type { DatasetInfo } from '@arizeai/phoenix-client/dist/esm/types/datasets';
10+
import type { DatasetInfo } from '@arizeai/phoenix-client/types/datasets';
1111
import type {
1212
ExperimentRun,
1313
ExperimentEvaluationRun,
14-
} from '@arizeai/phoenix-client/dist/esm/types/experiments';
14+
} from '@arizeai/phoenix-client/types/experiments';
1515
import type { SomeDevLog } from '@kbn/some-dev-log';
1616
import type { Model } from '@kbn/inference-common';
1717
import { withInferenceContext } from '@kbn/inference-tracing';
@@ -53,7 +53,18 @@ export class KibanaPhoenixClient implements EvalsExecutorClient {
5353
}
5454

5555
private async syncDataSet(dataset: EvaluationDataset): Promise<{ datasetId: string }> {
56-
const datasets = await import('@arizeai/phoenix-client/datasets');
56+
// `module: preserve` + bundler resolution wrap the ESM namespace as
57+
// `{ default: <namespace> }` when imported from a CJS-context package.
58+
// Unwrap at runtime; cast to `any` because TS sees only the wrapped shape.
59+
const datasetsImport = (await import('@arizeai/phoenix-client/datasets')) as any;
60+
const datasets = (datasetsImport.default ?? datasetsImport) as {
61+
createDataset: (args: {
62+
client: PhoenixClient;
63+
name: string;
64+
description?: string;
65+
examples: Array<{ input: unknown; output: unknown; metadata: unknown }>;
66+
}) => Promise<{ datasetId: string }>;
67+
};
5768

5869
const getDatasetsByNameResponse = await this.phoenixClient.GET('/v1/datasets', {
5970
params: {
@@ -189,7 +200,10 @@ export class KibanaPhoenixClient implements EvalsExecutorClient {
189200
? (await this.getDatasetByName(dataset.name)).id
190201
: (await this.syncDataSet(dataset)).datasetId;
191202

192-
const experiments = await import('@arizeai/phoenix-client/experiments');
203+
const experimentsImport = (await import('@arizeai/phoenix-client/experiments')) as any;
204+
const experiments = (experimentsImport.default ?? experimentsImport) as {
205+
runExperiment: (args: any) => Promise<any>;
206+
};
193207

194208
const ran = await experiments.runExperiment({
195209
client: this.phoenixClient,

x-pack/platform/packages/shared/kbn-ink/src/prepare_ink.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import Module from 'node:module';
1111
// eslint-disable-next-line no-new-func
1212
const dynamicImport = new Function('path', 'return import(path);');
1313

14-
let ink: typeof import('ink/build');
14+
let ink: typeof import('ink');
1515

1616
function installModuleIntercept() {
1717
// @ts-expect-error

x-pack/platform/packages/shared/kbn-ink/typings.d.ts

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,55 @@
55
* 2.0.
66
*/
77

8+
// `ink` is ESM-only and ships an `exports` field that only exposes the root.
9+
// Under TS bundler resolution from a CJS package, the named exports become
10+
// inaccessible. The previous ambient declaration relied on the deep import
11+
// `ink/build` which is now blocked too. Declare the runtime shape explicitly.
812
declare module 'ink' {
9-
export * from 'ink/build';
13+
import type { ComponentType, ReactNode } from 'react';
14+
15+
export interface BoxProps {
16+
children?: ReactNode;
17+
flexDirection?: 'row' | 'column';
18+
marginTop?: number;
19+
marginBottom?: number;
20+
marginLeft?: number;
21+
marginRight?: number;
22+
[key: string]: unknown;
23+
}
24+
export const Box: ComponentType<BoxProps>;
25+
26+
export interface TextProps {
27+
children?: ReactNode;
28+
color?: string;
29+
bold?: boolean;
30+
dimColor?: boolean;
31+
[key: string]: unknown;
32+
}
33+
export const Text: ComponentType<TextProps>;
34+
35+
export interface Key {
36+
upArrow: boolean;
37+
downArrow: boolean;
38+
leftArrow: boolean;
39+
rightArrow: boolean;
40+
return: boolean;
41+
escape: boolean;
42+
ctrl: boolean;
43+
shift: boolean;
44+
tab: boolean;
45+
backspace: boolean;
46+
delete: boolean;
47+
meta: boolean;
48+
pageDown: boolean;
49+
pageUp: boolean;
50+
}
51+
export function useInput(callback: (input: string, key: Key) => void): void;
52+
53+
export function useApp(): { exit: (error?: Error) => void };
54+
55+
export function render(
56+
node: ReactNode,
57+
options?: unknown
58+
): { unmount: () => void; waitUntilExit: () => Promise<void> };
1059
}

x-pack/solutions/observability/plugins/infra/public/pages/metrics/inventory_view/components/waffle/metric_control/metric_control.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import React from 'react';
99
import { render, screen } from '@testing-library/react';
10-
import { faker } from '@faker-js/faker/.';
10+
import { faker } from '@faker-js/faker';
1111
import {
1212
SNAPSHOT_CUSTOM_AGGREGATIONS,
1313
type SnapshotCustomMetricInput,

x-pack/solutions/observability/plugins/slo/server/domain/services/compute_health.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77

88
import type { IScopedClusterClient } from '@kbn/core/server';
99
import { ALL_VALUE } from '@kbn/slo-schema';
10-
import type { TransformGetTransformStatsTransformStats } from 'elasticsearch-8.x/lib/api/types';
10+
import type { estypes } from 'elasticsearch-8.x';
11+
12+
type TransformGetTransformStatsTransformStats = estypes.TransformGetTransformStatsTransformStats;
1113
import { keyBy, uniqBy, type Dictionary } from 'lodash';
1214
import pLimit from 'p-limit';
1315
import {

x-pack/solutions/observability/plugins/synthetics/public/apps/synthetics/state/manual_test_runs/index.ts

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import type { PayloadAction } from '@reduxjs/toolkit';
99
import { createReducer } from '@reduxjs/toolkit';
1010

11-
import type { WritableDraft } from 'immer/dist/types/types-external';
11+
import type { Draft } from 'immer';
1212
import type { IHttpFetchError } from '@kbn/core-http-browser';
1313

1414
import type { ActionPayload } from '../utils/actions';
@@ -51,7 +51,7 @@ export const manualTestRunsReducer = createReducer(initialState, (builder) => {
5151
builder
5252
.addCase(
5353
String(manualTestMonitorAction.get),
54-
(state: WritableDraft<ManualTestRunsState>, action: PayloadAction<TestNowPayload>) => {
54+
(state: Draft<ManualTestRunsState>, action: PayloadAction<TestNowPayload>) => {
5555
state = Object.values(state).reduce((acc, curr) => {
5656
acc[curr.configId] = {
5757
...curr,
@@ -70,10 +70,7 @@ export const manualTestRunsReducer = createReducer(initialState, (builder) => {
7070
)
7171
.addCase(
7272
String(manualTestMonitorAction.success),
73-
(
74-
state: WritableDraft<ManualTestRunsState>,
75-
{ payload }: PayloadAction<EnrichedTestNowResponse>
76-
) => {
73+
(state: Draft<ManualTestRunsState>, { payload }: PayloadAction<EnrichedTestNowResponse>) => {
7774
state[payload.configId] = {
7875
configId: payload.configId,
7976
testRunId: payload.testRunId,
@@ -86,7 +83,7 @@ export const manualTestRunsReducer = createReducer(initialState, (builder) => {
8683
.addCase(
8784
String(manualTestMonitorAction.fail),
8885
(
89-
state: WritableDraft<ManualTestRunsState>,
86+
state: Draft<ManualTestRunsState>,
9087
action: ActionPayload<EnrichedTestNowResponse, TestNowPayload>
9188
) => {
9289
const fetchError = action.payload as unknown as IHttpFetchError;
@@ -118,7 +115,7 @@ export const manualTestRunsReducer = createReducer(initialState, (builder) => {
118115
return state;
119116
}
120117
)
121-
.addCase(manualTestRunUpdateAction, (state: WritableDraft<ManualTestRunsState>, action) => {
118+
.addCase(manualTestRunUpdateAction, (state: Draft<ManualTestRunsState>, action) => {
122119
const { testRunId, ...rest } = action.payload;
123120
const configId = Object.keys(state).find((key) => state[key].testRunId === testRunId);
124121
if (configId) {
@@ -128,7 +125,7 @@ export const manualTestRunsReducer = createReducer(initialState, (builder) => {
128125
};
129126
}
130127
})
131-
.addCase(toggleTestNowFlyoutAction, (state: WritableDraft<ManualTestRunsState>, action) => {
128+
.addCase(toggleTestNowFlyoutAction, (state: Draft<ManualTestRunsState>, action) => {
132129
state = Object.values(state).reduce((acc, curr) => {
133130
acc[curr.configId] = {
134131
...curr,
@@ -143,7 +140,7 @@ export const manualTestRunsReducer = createReducer(initialState, (builder) => {
143140
isTestNowFlyoutOpen: !state[action.payload].isTestNowFlyoutOpen,
144141
};
145142
})
146-
.addCase(hideTestNowFlyoutAction, (state: WritableDraft<ManualTestRunsState>) => {
143+
.addCase(hideTestNowFlyoutAction, (state: Draft<ManualTestRunsState>) => {
147144
state = Object.values(state).reduce((acc, curr) => {
148145
acc[curr.configId] = {
149146
...curr,
@@ -156,7 +153,7 @@ export const manualTestRunsReducer = createReducer(initialState, (builder) => {
156153
})
157154
.addCase(
158155
String(clearTestNowMonitorAction),
159-
(state: WritableDraft<ManualTestRunsState>, action: PayloadAction<string>) => {
156+
(state: Draft<ManualTestRunsState>, action: PayloadAction<string>) => {
160157
delete state[action.payload];
161158
}
162159
);

x-pack/solutions/search/plugins/search_playground/public/hooks/use_load_fields_by_indices.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77

88
import { useEffect } from 'react';
9-
import type { UseFormReturn } from 'react-hook-form/dist/types';
9+
import type { UseFormReturn } from 'react-hook-form';
1010
import type { IndexFields } from '@kbn/search-queries';
1111
import {
1212
generateSearchQuery,

x-pack/solutions/security/plugins/security_solution/server/assistant/tools/esql/graphs/analyse_index_pattern/nodes/explore_partial_index_mapping_responder/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import type { AIMessage, BaseMessage } from '@langchain/core/messages';
99
import { ToolMessage } from '@langchain/core/messages';
10-
import type { ToolCall } from '@langchain/core/dist/messages/tool';
10+
import type { ToolCall } from '@langchain/core/messages/tool';
1111
import { set } from '@kbn/safer-lodash-set';
1212
import { toolDetails } from '../../../../tools/inspect_index_mapping_tool/inspect_index_mapping_tool';
1313
import { messageContainsToolCalls } from '../../../../utils/common';

x-pack/solutions/security/plugins/security_solution/server/assistant/tools/esql/utils/common.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import type { BaseMessage } from '@langchain/core/messages';
99
import { AIMessage } from '@langchain/core/messages';
10-
import type { ToolCall } from '@langchain/core/dist/messages/tool';
10+
import type { ToolCall } from '@langchain/core/messages/tool';
1111
import type { AssistantToolParams } from '@kbn/elastic-assistant-plugin/server';
1212
import { toolDetails } from '../tools/inspect_index_mapping_tool/inspect_index_mapping_tool';
1313

0 commit comments

Comments
 (0)