Skip to content
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ describe('searchEmbeddableTransforms', () => {
title: 'Test Title',
description: 'Test Description',
time_range: { from: 'now-15m', to: 'now' },
discover_session_id: 'session-123',
ref_id: 'session-123',
selected_tab_id: undefined,
overrides: {},
});
Expand Down Expand Up @@ -161,7 +161,7 @@ describe('searchEmbeddableTransforms', () => {
expect(result).toMatchObject({
title: 'Test Title',
description: 'Test Description',
discover_session_id: 'session-xyz',
ref_id: 'session-xyz',
});
});
});
Expand All @@ -173,7 +173,7 @@ describe('searchEmbeddableTransforms', () => {
title: 'Test Search',
description: 'Test Description',
time_range: { from: 'now-15m', to: 'now' },
discover_session_id: 'test-saved-object-id',
ref_id: 'test-saved-object-id',
selected_tab_id: undefined,
overrides: {},
};
Expand Down Expand Up @@ -201,7 +201,7 @@ describe('searchEmbeddableTransforms', () => {
title: 'My Search',
description: 'My description',
time_range: { from: 'now-1h', to: 'now' },
discover_session_id: 'session-456',
ref_id: 'session-456',
selected_tab_id: 'tab-1',
overrides: {},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ describe('search embeddable transform utils', () => {
title: 'My Search',
description: 'My description',
time_range: { from: 'now-15m', to: 'now' },
discover_session_id: 'session-123',
ref_id: 'session-123',
selected_tab_id: undefined,
overrides: {},
});
Expand Down Expand Up @@ -177,12 +177,12 @@ describe('search embeddable transform utils', () => {
});

describe('toStoredSearchEmbeddable', () => {
it('dispatches to by-reference transform when state has discover_session_id', () => {
it('dispatches to by-reference transform when state has ref_id', () => {
const apiState: DiscoverSessionEmbeddableByReferenceState = {
title: 'My Search',
description: 'My description',
time_range: { from: 'now-15m', to: 'now' },
discover_session_id: 'session-456',
ref_id: 'session-456',
selected_tab_id: undefined,
overrides: {},
};
Expand Down Expand Up @@ -325,7 +325,7 @@ describe('search embeddable transform utils', () => {
title: 'My Saved Search',
description: 'My description',
time_range: { from: 'now-15m', to: 'now' },
discover_session_id: 'session-123',
ref_id: 'session-123',
selected_tab_id: undefined,
overrides: {},
});
Expand Down Expand Up @@ -358,7 +358,7 @@ describe('search embeddable transform utils', () => {
title: 'My Saved Search',
description: 'My description',
time_range: { from: 'now-15m', to: 'now' },
discover_session_id: 'session-xyz',
ref_id: 'session-xyz',
selected_tab_id: 'tab-active',
overrides: {
sort: [{ name: '@timestamp', direction: 'desc' }],
Expand Down Expand Up @@ -399,7 +399,7 @@ describe('search embeddable transform utils', () => {
{ name: SAVED_SEARCH_SAVED_OBJECT_REF_NAME, type: SavedSearchType, id: 'session-picked' },
];
const result = fromStoredSearchEmbeddableByRef(storedSearch, references);
expect(result.discover_session_id).toBe('session-picked');
expect(result.ref_id).toBe('session-picked');
});

it('uses savedObjectId on state when present so a saved search reference is not required', () => {
Expand All @@ -408,7 +408,7 @@ describe('search embeddable transform utils', () => {
savedObjectId: 'session-without-ref-array',
};
const result = fromStoredSearchEmbeddableByRef(storedSearch, []);
expect(result.discover_session_id).toBe('session-without-ref-array');
expect(result.ref_id).toBe('session-without-ref-array');
});

it('prefers savedObjectId on state over the matching saved search reference', () => {
Expand All @@ -424,7 +424,7 @@ describe('search embeddable transform utils', () => {
},
];
const result = fromStoredSearchEmbeddableByRef(storedSearch, references);
expect(result.discover_session_id).toBe('id-from-state');
expect(result.ref_id).toBe('id-from-state');
});
});

Expand All @@ -434,7 +434,7 @@ describe('search embeddable transform utils', () => {
title: 'My Search',
description: 'My description',
time_range: { from: 'now-15m', to: 'now' },
discover_session_id: 'session-456',
ref_id: 'session-456',
selected_tab_id: 'tab-1',
overrides: {},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export function fromStoredSearchEmbeddableByRef(
if (!savedObjectId) throw new Error(`Missing reference of type "${SavedSearchType}"`);
return {
...otherAttrs,
discover_session_id: savedObjectId,
ref_id: savedObjectId,
selected_tab_id: selectedTabId,
overrides: toDiscoverSessionPanelOverrides(storedState),
};
Expand All @@ -104,9 +104,9 @@ export function toStoredSearchEmbeddableByRef(
const discoverSessionReference: SavedObjectReference = {
name: SAVED_SEARCH_SAVED_OBJECT_REF_NAME,
type: SavedSearchType,
id: apiState.discover_session_id,
id: apiState.ref_id,
};
const { discover_session_id, selected_tab_id, overrides, ...otherAttrs } = apiState;
const { ref_id, selected_tab_id, overrides, ...otherAttrs } = apiState;
const state: StoredSearchEmbeddableByReferenceState = {
...otherAttrs,
...fromDiscoverSessionPanelOverrides(overrides ?? {}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import type {
export function isDiscoverSessionEmbeddableByReferenceState(
state: DiscoverSessionEmbeddableState
): state is DiscoverSessionEmbeddableByReferenceState {
return 'discover_session_id' in state;
return 'ref_id' in state;
}

export function isSearchEmbeddableByValueState(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ export interface UrlTracker {
export interface DiscoverFeatureFlags {
getCascadeLayoutEnabled: () => boolean;
getIsEsqlDefault: () => boolean;
/** When true, panel state uses Discover session API format (discover_session_id, session tabs). */
getEmbeddableTransformsEnabled: () => boolean;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ describe('saved search embeddable', () => {
runtimeState = getInitialRuntimeState({ searchMock: search });
const { Component, api } = await factory.buildEmbeddable({
initializeDrilldownsManager: mockInitializeDrilldownsManager,
initialState: { discover_session_id: 'id', overrides: {} },
initialState: { ref_id: 'id', overrides: {} },
finalizeApi: finalizeApiMock,
uuid,
parentApi: mockedDashboardApi,
Expand Down Expand Up @@ -206,7 +206,7 @@ describe('saved search embeddable', () => {

const { Component, api } = await factory.buildEmbeddable({
initializeDrilldownsManager: mockInitializeDrilldownsManager,
initialState: { discover_session_id: 'id', overrides: {} },
initialState: { ref_id: 'id', overrides: {} },
finalizeApi: finalizeApiMock,
uuid,
parentApi: mockedDashboardApi,
Expand Down Expand Up @@ -288,7 +288,7 @@ describe('saved search embeddable', () => {
});
const { api } = await factory.buildEmbeddable({
initializeDrilldownsManager: mockInitializeDrilldownsManager,
initialState: { discover_session_id: 'id', overrides: {} },
initialState: { ref_id: 'id', overrides: {} },
finalizeApi: finalizeApiMock,
uuid,
parentApi: mockedDashboardApi,
Expand Down Expand Up @@ -446,7 +446,7 @@ describe('saved search embeddable', () => {
runtimeState = getInitialRuntimeState();
await factory.buildEmbeddable({
initializeDrilldownsManager: mockInitializeDrilldownsManager,
initialState: { discover_session_id: 'id', overrides: {} },
initialState: { ref_id: 'id', overrides: {} },
finalizeApi: finalizeApiMock,
uuid,
parentApi: mockedDashboardApi,
Expand All @@ -471,7 +471,7 @@ describe('saved search embeddable', () => {
};
await factory.buildEmbeddable({
initializeDrilldownsManager: mockInitializeDrilldownsManager,
initialState: { discover_session_id: 'id', overrides: {} },
initialState: { ref_id: 'id', overrides: {} },
finalizeApi: finalizeApiMock,
uuid,
parentApi: mockedDashboardApi,
Expand All @@ -498,7 +498,7 @@ describe('saved search embeddable', () => {
runtimeState = getInitialRuntimeState();
const { api } = await factory.buildEmbeddable({
initializeDrilldownsManager: mockInitializeDrilldownsManager,
initialState: { discover_session_id: 'id', overrides: {} },
initialState: { ref_id: 'id', overrides: {} },
finalizeApi: finalizeApiMock,
uuid,
parentApi: mockedDashboardApi,
Expand Down Expand Up @@ -531,7 +531,7 @@ describe('saved search embeddable', () => {
});
const { Component, api } = await factory.buildEmbeddable({
initializeDrilldownsManager: mockInitializeDrilldownsManager,
initialState: { discover_session_id: 'id', overrides: {} },
initialState: { ref_id: 'id', overrides: {} },
finalizeApi: finalizeApiMock,
uuid,
parentApi: mockedDashboardApi,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ export const getSearchEmbeddableFactory = ({
...drilldownsManager.comparators,
...titleComparators,
...timeRangeComparators,
discover_session_id: 'skip',
ref_id: 'skip',
selected_tab_id: shouldSkipTabComparators ? 'skip' : 'referenceEquality',
overrides: shouldSkipTabComparators ? 'skip' : 'deepEquality',
tabs: !isByValue || shouldSkipTabComparators ? 'skip' : 'deepEquality',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const addPanelFromLibrary: (...params: OnAddParams) => Promise<void> = as
{
panelType: SEARCH_EMBEDDABLE_TYPE,
serializedState: {
discover_session_id: savedObject.id,
ref_id: savedObject.id,
overrides: {},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ describe('Serialization utils', () => {
const apiStateByRef: DiscoverSessionEmbeddableByReferenceState = {
title: 'test panel title',
description: 'My description',
discover_session_id: 'savedSearch',
ref_id: 'savedSearch',
selected_tab_id: undefined,
overrides: {},
};
Expand All @@ -193,7 +193,7 @@ describe('Serialization utils', () => {
const apiStateByRef: DiscoverSessionEmbeddableByReferenceState = {
title: 'test panel title',
description: 'My description',
discover_session_id: 'savedSearch',
ref_id: 'savedSearch',
selected_tab_id: undefined,
overrides: { sort: [{ name: 'order_date', direction: 'asc' }] },
};
Expand Down Expand Up @@ -226,7 +226,7 @@ describe('Serialization utils', () => {

const serializedState: DiscoverSessionEmbeddableByReferenceState = {
title: 'test panel title',
discover_session_id: 'savedSearch',
ref_id: 'savedSearch',
selected_tab_id: 'tab-2',
overrides: {},
};
Expand Down Expand Up @@ -256,7 +256,7 @@ describe('Serialization utils', () => {

const serializedState: DiscoverSessionEmbeddableByReferenceState = {
title: 'test panel title',
discover_session_id: 'savedSearch',
ref_id: 'savedSearch',
selected_tab_id: 'deleted-tab-id',
overrides: {
column_order: ['stale-col-a'],
Expand Down Expand Up @@ -288,7 +288,7 @@ describe('Serialization utils', () => {

const serializedState: DiscoverSessionEmbeddableByReferenceState = {
title: 'test panel title',
discover_session_id: 'savedSearch',
ref_id: 'savedSearch',
selected_tab_id: 'tab-2',
overrides: { column_order: ['custom-col'] },
};
Expand Down Expand Up @@ -385,7 +385,7 @@ describe('Serialization utils', () => {
});

expect(serializedState).toMatchObject({
discover_session_id: 'test-id',
ref_id: 'test-id',
});
expect(serializedState).not.toHaveProperty('savedObjectId');
});
Expand All @@ -410,10 +410,10 @@ describe('Serialization utils', () => {
embeddableTransformsEnabled: true,
});

// By-reference API shape includes discover_session_id; panel overrides (sampleSize, sort)
// By-reference API shape includes ref_id; panel overrides (sampleSize, sort)
// are stored in the dashboard document but not part of the simplified by-ref schema
expect(serializedState).toMatchObject({
discover_session_id: 'test-id',
ref_id: 'test-id',
});
});

Expand All @@ -433,7 +433,7 @@ describe('Serialization utils', () => {
});

expect(serializedState).toMatchObject({
discover_session_id: 'test-id',
ref_id: 'test-id',
selected_tab_id: 'tab-2',
});
});
Expand All @@ -454,7 +454,7 @@ describe('Serialization utils', () => {
});

expect(serializedState).toMatchObject({
discover_session_id: 'test-id',
ref_id: 'test-id',
});
});
});
Expand Down Expand Up @@ -494,7 +494,7 @@ describe('Serialization utils', () => {
expect(deserializedState.title).toEqual('test panel title');
});

test('serialize by-ref returns savedObjectId (not discover_session_id)', () => {
test('serialize by-ref returns savedObjectId (not ref_id)', () => {
const sort: SortOrder[] = [['order_date', 'desc']];
const searchSource = createSearchSourceMock({ index: dataViewMock });
const savedSearch = {
Expand Down Expand Up @@ -522,7 +522,7 @@ describe('Serialization utils', () => {
});

expect(serialized).toMatchObject({ savedObjectId: 'legacy-id' });
expect(serialized).not.toHaveProperty('discover_session_id');
expect(serialized).not.toHaveProperty('ref_id');
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export const deserializeState = async ({

if (isDiscoverSessionEmbeddableByReferenceState(apiState)) {
// by reference
const { discover_session_id: savedObjectId, selected_tab_id: selectedTabId } = apiState;
const { ref_id: savedObjectId, selected_tab_id: selectedTabId } = apiState;
const { getDiscoverSession } = discoverServices.savedSearch;
const session = await getDiscoverSession(savedObjectId);
const selectedTab = selectedTabId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ const panelOverridesSchema = schema.object(
defaultValue: [],
meta: {
description:
'When set, overrides column order for the data table relative to the referenced saved object (`discover_session_id`) or the inline tab in `tabs`. If omitted, the source configuration is used.',
'When set, overrides column order for the data table relative to the referenced saved object (`ref_id`) or the inline tab in `tabs`. If omitted, the source configuration is used.',
},
}
)
Expand Down Expand Up @@ -356,7 +356,7 @@ const getDiscoverSessionByValueEmbeddableSchema = withPanelSchemas(
maxSize: 1,
meta: {
description:
'Inline tab configuration. Used when no `discover_session_id` is set. Currently supports one tab.',
'Inline tab configuration. Used when no `ref_id` is set. Currently supports one tab.',
},
}),
}),
Expand All @@ -365,7 +365,7 @@ const getDiscoverSessionByValueEmbeddableSchema = withPanelSchemas(

const getDiscoverSessionByReferenceEmbeddableSchema = withPanelSchemas(
schema.object({
discover_session_id: schema.string(),
ref_id: schema.string(),
selected_tab_id: schema.maybe(
schema.string({
meta: {
Expand Down
Loading