From 796ccf1ee5769dd0affe250e1d92f8f8578aec90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Fern=C3=A1ndez=20Haro?= Date: Wed, 22 Mar 2023 14:59:24 +0100 Subject: [PATCH] [SOR] Remove `fields` API --- .../src/saved_objects_client.ts | 1 - .../src/lib/find_shared_origin_objects.ts | 1 - .../src/lib/included_fields.test.ts | 43 +------------- .../src/lib/included_fields.ts | 27 --------- .../src/lib/repository.test.ts | 33 ----------- .../src/lib/repository.ts | 16 +----- .../src/apis/bulk_get.ts | 2 - .../src/apis/find.ts | 6 -- .../src/saved_objects_client.test.ts | 4 -- .../src/saved_objects_client.ts | 1 - .../src/import/lib/check_origin_conflicts.ts | 1 - .../src/import/lib/check_reference_origins.ts | 1 - .../import/lib/validate_references.test.ts | 16 +++--- .../src/import/lib/validate_references.ts | 2 +- .../src/routes/bulk_get.ts | 1 - .../src/routes/find.ts | 2 - .../src/routes/utils.ts | 1 - .../saved_objects/routes/find.test.ts | 30 ---------- .../saved_objects/routes/import.test.ts | 6 +- .../routes/resolve_import_errors.test.ts | 2 +- .../dashboard_actions/clone_panel_action.tsx | 1 - .../check_for_duplicate_dashboard_title.ts | 1 - .../server/deprecations/scripted_fields.ts | 1 - .../data_views/server/has_user_data_view.ts | 1 - ...register_index_pattern_usage_collection.ts | 1 - .../server/routes/has_data_views.test.ts | 3 - src/plugins/data_views/server/utils.ts | 1 - .../server/routes/kbn_client_so/find.ts | 2 - .../register_ui_counters_collector.ts | 1 - .../telemetry_ui_metric_collector.ts | 1 - .../register_usage_counters_collector.ts | 1 - .../helpers/find_object_by_title.ts | 1 - .../finder/saved_object_finder.test.tsx | 56 ------------------- .../public/finder/saved_object_finder.tsx | 5 -- .../server/routes/find.ts | 5 -- .../server/routes/find.ts | 1 - .../saved_searches/save_saved_searches.ts | 1 - .../find_object_by_title.ts | 1 - .../apis/saved_objects/find.ts | 8 +-- .../alerting/server/health/get_health.ts | 4 -- .../alerting/server/routes/find_rules.test.ts | 36 ------------ .../alerting/server/routes/find_rules.ts | 17 ------ .../server/routes/legacy/find.test.ts | 26 --------- .../alerting/server/routes/legacy/find.ts | 10 ---- ...lude_fields_required_for_authentication.ts | 12 ---- .../server/rules_client/common/index.ts | 1 - .../server/rules_client/methods/find.ts | 18 +----- .../rules_client/tests/aggregate.test.ts | 1 - .../server/rules_client/tests/find.test.ts | 7 +-- ...grate_legacy_apm_indices_to_space_aware.ts | 1 - .../server/routes/custom_elements/find.ts | 10 ---- .../canvas/server/routes/templates/list.ts | 1 - .../canvas/server/routes/workpad/find.ts | 1 - .../services/attachments/operations/get.ts | 6 -- .../cases/server/services/cases/index.ts | 2 - .../server/services/user_actions/index.ts | 6 -- .../fleet_integration/fleet_integration.ts | 1 - .../fleet/server/services/agent_policy.ts | 8 --- .../server/services/epm/packages/cleanup.ts | 2 - .../fleet/server/services/package_policy.ts | 1 - .../services/log_views/log_views_client.ts | 1 - .../find_object_by_title.ts | 1 - .../routes/list_page/load_list_and_render.tsx | 1 - .../routes/list_page/maps_list_view.tsx | 1 - .../components/edit_job_flyout/edit_utils.js | 1 - .../assignments/assignment_service.test.ts | 8 +-- .../assignments/assignment_service.ts | 2 - .../api_calls/risk_scores/saved_objects.ts | 4 +- .../common/hooks/use_dashboard_button_href.ts | 1 - .../route.ts | 1 - .../legacy_find_notifications.ts | 2 - .../logic/notifications/legacy_types.ts | 1 - .../api/rules/bulk_actions/route.ts | 1 - .../api/rules/filters/route.ts | 1 - .../api/rules/find_rules/route.ts | 1 - .../rule_management/logic/crud/read_rules.ts | 1 - .../validate_rule_default_exception_list.ts | 1 - .../logic/export/get_export_by_object_ids.ts | 1 - .../logic/search/find_rules.ts | 4 -- .../search/get_existing_prepackaged_rules.ts | 2 - .../synthetics/server/routes/common.ts | 3 - .../routes/overview_status/overview_status.ts | 9 --- .../synthetics_monitor/get_all_monitors.ts | 4 +- .../register_get_index_patterns_route.ts | 1 - .../tests/common/cases/find_cases.ts | 44 --------------- .../server/hidden_saved_object_routes.ts | 2 - .../common/suites/find.ts | 12 ++-- 87 files changed, 39 insertions(+), 531 deletions(-) delete mode 100644 x-pack/plugins/alerting/server/rules_client/common/include_fields_required_for_authentication.ts diff --git a/packages/core/saved-objects/core-saved-objects-api-browser/src/saved_objects_client.ts b/packages/core/saved-objects/core-saved-objects-api-browser/src/saved_objects_client.ts index ce225b86e46d8..7ec22edc9416e 100644 --- a/packages/core/saved-objects/core-saved-objects-api-browser/src/saved_objects_client.ts +++ b/packages/core/saved-objects/core-saved-objects-api-browser/src/saved_objects_client.ts @@ -93,7 +93,6 @@ export interface SavedObjectsClientContract { * Query field argument for more information * @property {integer} [options.page=1] * @property {integer} [options.perPage=20] - * @property {array} options.fields * @property {object} [options.hasReference] - { type, id } * @returns A find result with objects matching the specified search. * @deprecated See https://github.com/elastic/kibana/issues/149098 diff --git a/packages/core/saved-objects/core-saved-objects-api-server-internal/src/lib/find_shared_origin_objects.ts b/packages/core/saved-objects/core-saved-objects-api-server-internal/src/lib/find_shared_origin_objects.ts index a489e4afa91c3..f2b2396560456 100644 --- a/packages/core/saved-objects/core-saved-objects-api-server-internal/src/lib/find_shared_origin_objects.ts +++ b/packages/core/saved-objects/core-saved-objects-api-server-internal/src/lib/find_shared_origin_objects.ts @@ -39,7 +39,6 @@ export async function findSharedOriginObjects( type: [...uniqueObjectTypes], perPage, filter, - fields: ['not-a-field'], // Specify a non-existent field to avoid fetching all type-level fields (we only care about root-level fields) namespaces: [ALL_NAMESPACES_STRING], // We need to search across all spaces to have accurate results }, undefined, diff --git a/packages/core/saved-objects/core-saved-objects-api-server-internal/src/lib/included_fields.test.ts b/packages/core/saved-objects/core-saved-objects-api-server-internal/src/lib/included_fields.test.ts index 13dacc4f07a64..dfc0db206f50c 100644 --- a/packages/core/saved-objects/core-saved-objects-api-server-internal/src/lib/included_fields.test.ts +++ b/packages/core/saved-objects/core-saved-objects-api-server-internal/src/lib/included_fields.test.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import { getRootFields, includedFields } from './included_fields'; +import { getRootFields } from './included_fields'; describe('getRootFields', () => { it('returns copy of root fields', () => { @@ -27,44 +27,3 @@ describe('getRootFields', () => { `); }); }); - -describe('includedFields', () => { - const rootFields = getRootFields(); - - it('returns undefined if fields are not provided', () => { - expect(includedFields()).toBe(undefined); - }); - - it('accepts type and field as string', () => { - const fields = includedFields('config', 'foo'); - expect(fields).toEqual(['config.foo', ...rootFields, 'foo']); - }); - - it('accepts type as array and field as string', () => { - const fields = includedFields(['config', 'secret'], 'foo'); - expect(fields).toEqual(['config.foo', 'secret.foo', ...rootFields, 'foo']); - }); - - it('accepts type as string and field as array', () => { - const fields = includedFields('config', ['foo', 'bar']); - expect(fields).toEqual(['config.foo', 'config.bar', ...rootFields, 'foo', 'bar']); - }); - - it('accepts type as array and field as array', () => { - const fields = includedFields(['config', 'secret'], ['foo', 'bar']); - expect(fields).toEqual([ - 'config.foo', - 'config.bar', - 'secret.foo', - 'secret.bar', - ...rootFields, - 'foo', - 'bar', - ]); - }); - - it('uses wildcard when type is not provided', () => { - const fields = includedFields(undefined, 'foo'); - expect(fields).toEqual(['*.foo', ...rootFields, 'foo']); - }); -}); diff --git a/packages/core/saved-objects/core-saved-objects-api-server-internal/src/lib/included_fields.ts b/packages/core/saved-objects/core-saved-objects-api-server-internal/src/lib/included_fields.ts index 8ee3f70585452..ed6df68483085 100644 --- a/packages/core/saved-objects/core-saved-objects-api-server-internal/src/lib/included_fields.ts +++ b/packages/core/saved-objects/core-saved-objects-api-server-internal/src/lib/included_fields.ts @@ -6,10 +6,6 @@ * Side Public License, v 1. */ -function toArray(value: string | string[]): string[] { - return typeof value === 'string' ? [value] : value; -} - const ROOT_FIELDS = [ 'namespace', 'namespaces', @@ -26,26 +22,3 @@ const ROOT_FIELDS = [ export function getRootFields() { return [...ROOT_FIELDS]; } - -/** - * Provides an array of paths for ES source filtering - */ -export function includedFields( - type: string | string[] = '*', - fields?: string[] | string -): string[] | undefined { - if (!fields || fields.length === 0) { - return; - } - - // convert to an array - const sourceFields = toArray(fields); - const sourceType = toArray(type); - - return sourceType - .reduce((acc: string[], t) => { - return [...acc, ...sourceFields.map((f) => `${t}.${f}`)]; - }, []) - .concat(ROOT_FIELDS) - .concat(fields); // v5 compatibility -} diff --git a/packages/core/saved-objects/core-saved-objects-api-server-internal/src/lib/repository.test.ts b/packages/core/saved-objects/core-saved-objects-api-server-internal/src/lib/repository.test.ts index d8c4e33f0495e..0654ccb77ea90 100644 --- a/packages/core/saved-objects/core-saved-objects-api-server-internal/src/lib/repository.test.ts +++ b/packages/core/saved-objects/core-saved-objects-api-server-internal/src/lib/repository.test.ts @@ -3525,31 +3525,6 @@ describe('SavedObjectsRepository', () => { ); }); - it(`can filter by fields`, async () => { - await findSuccess(client, repository, { type, fields: ['title'] }); - expect(client.search).toHaveBeenCalledWith( - expect.objectContaining({ - body: expect.objectContaining({ - _source: [ - `${type}.title`, - 'namespace', - 'namespaces', - 'type', - 'references', - 'migrationVersion', - 'coreMigrationVersion', - 'typeMigrationVersion', - 'updated_at', - 'created_at', - 'originId', - 'title', - ], - }), - }), - expect.anything() - ); - }); - it(`should set rest_total_hits_as_int to true on a request`, async () => { await findSuccess(client, repository, { type }); expect(client.search).toHaveBeenCalledWith( @@ -3596,14 +3571,6 @@ describe('SavedObjectsRepository', () => { expect(client.search).not.toHaveBeenCalled(); }); - it(`throws when fields is defined but not an array`, async () => { - // @ts-expect-error fields is an array - await expect(repository.find({ type, fields: 'string' })).rejects.toThrowError( - 'options.fields must be an array' - ); - expect(client.search).not.toHaveBeenCalled(); - }); - it(`throws when a preference is provided with pit`, async () => { await expect( repository.find({ type: 'foo', pit: { id: 'abc123' }, preference: 'hi' }) diff --git a/packages/core/saved-objects/core-saved-objects-api-server-internal/src/lib/repository.ts b/packages/core/saved-objects/core-saved-objects-api-server-internal/src/lib/repository.ts index e62e4e8fc6155..ebc84398ab61f 100644 --- a/packages/core/saved-objects/core-saved-objects-api-server-internal/src/lib/repository.ts +++ b/packages/core/saved-objects/core-saved-objects-api-server-internal/src/lib/repository.ts @@ -100,7 +100,6 @@ import pMap from 'p-map'; import { PointInTimeFinder } from './point_in_time_finder'; import { createRepositoryEsClient, type RepositoryEsClient } from './repository_es_client'; import { getSearchDsl } from './search_dsl'; -import { includedFields } from './included_fields'; import { internalBulkResolve, isBulkResolveError } from './internal_bulk_resolve'; import { validateConvertFilterToKueryNode } from './filter_utils'; import { validateAndConvertAggregations } from './aggregations'; @@ -1290,7 +1289,6 @@ export class SavedObjectsRepository implements ISavedObjectsRepository { searchAfter, sortField, sortOrder, - fields, type, filter, preference, @@ -1317,10 +1315,6 @@ export class SavedObjectsRepository implements ISavedObjectsRepository { throw SavedObjectsErrorHelpers.createBadRequestError('options.searchFields must be an array'); } - if (fields && !Array.isArray(fields)) { - throw SavedObjectsErrorHelpers.createBadRequestError('options.fields must be an array'); - } - let kueryNode; if (filter) { try { @@ -1389,7 +1383,6 @@ export class SavedObjectsRepository implements ISavedObjectsRepository { index: pit ? undefined : this.getIndicesForTypes(allowedTypes), // If `searchAfter` is provided, we drop `from` as it will not be used for pagination. from: searchAfter ? undefined : perPage * (page - 1), - _source: includedFields(allowedTypes, fields), preference, rest_total_hits_as_int: true, size: perPage, @@ -1397,7 +1390,6 @@ export class SavedObjectsRepository implements ISavedObjectsRepository { size: perPage, seq_no_primary_term: true, from: perPage * (page - 1), - _source: includedFields(allowedTypes, fields), ...(aggsObject ? { aggs: aggsObject } : {}), ...getSearchDsl(this._mappings, this._registry, { search, @@ -1508,11 +1500,11 @@ export class SavedObjectsRepository implements ISavedObjectsRepository { let bulkGetRequestIndexCounter = 0; type ExpectedBulkGetResult = Either< { type: string; id: string; error: Payload }, - { type: string; id: string; fields?: string[]; namespaces?: string[]; esRequestIndex: number } + { type: string; id: string; namespaces?: string[]; esRequestIndex: number } >; const expectedBulkGetResults = await Promise.all( objects.map>(async (object) => { - const { type, id, fields } = object; + const { type, id } = object; let error: DecoratedError | undefined; if (!this._allowedTypes.includes(type)) { @@ -1541,7 +1533,6 @@ export class SavedObjectsRepository implements ISavedObjectsRepository { value: { type, id, - fields, namespaces, esRequestIndex: bulkGetRequestIndexCounter++, }, @@ -1562,10 +1553,9 @@ export class SavedObjectsRepository implements ISavedObjectsRepository { const getNamespaceId = (namespaces?: string[]) => namespaces !== undefined ? SavedObjectsUtils.namespaceStringToId(namespaces[0]) : namespace; - const bulkGetDocs = validObjects.map(({ value: { type, id, fields, namespaces } }) => ({ + const bulkGetDocs = validObjects.map(({ value: { type, id, namespaces } }) => ({ _id: this._serializer.generateRawId(getNamespaceId(namespaces), type, id), // the namespace prefix is only used for single-namespace object types _index: this.getIndexForType(type), - _source: { includes: includedFields(type, fields) }, })); const bulkGetResponse = bulkGetDocs.length ? await this.client.mget( diff --git a/packages/core/saved-objects/core-saved-objects-api-server/src/apis/bulk_get.ts b/packages/core/saved-objects/core-saved-objects-api-server/src/apis/bulk_get.ts index 1a3f4928db672..035c1ec8bc350 100644 --- a/packages/core/saved-objects/core-saved-objects-api-server/src/apis/bulk_get.ts +++ b/packages/core/saved-objects/core-saved-objects-api-server/src/apis/bulk_get.ts @@ -16,8 +16,6 @@ export interface SavedObjectsBulkGetObject { id: string; /** Type of the object to get */ type: string; - /** SavedObject fields to include in the response */ - fields?: string[]; /** * Optional namespace(s) for the object to be retrieved in. If this is defined, it will supersede the namespace ID that is in the * top-level options. diff --git a/packages/core/saved-objects/core-saved-objects-api-server/src/apis/find.ts b/packages/core/saved-objects/core-saved-objects-api-server/src/apis/find.ts index 311be05126a76..4d7ecade6c88d 100644 --- a/packages/core/saved-objects/core-saved-objects-api-server/src/apis/find.ts +++ b/packages/core/saved-objects/core-saved-objects-api-server/src/apis/find.ts @@ -55,12 +55,6 @@ export interface SavedObjectsFindOptions { sortField?: string; /** sort order, ascending or descending */ sortOrder?: SortOrder; - /** - * An array of fields to include in the results - * @example - * SavedObjects.find({type: 'dashboard', fields: ['attributes.name', 'attributes.location']}) - */ - fields?: string[]; /** Search documents using the Elasticsearch Simple Query String syntax. See Elasticsearch Simple Query String `query` argument for more information */ search?: string; /** The fields to perform the parsed query against. See Elasticsearch Simple Query String `fields` argument for more information */ diff --git a/packages/core/saved-objects/core-saved-objects-browser-internal/src/saved_objects_client.test.ts b/packages/core/saved-objects/core-saved-objects-browser-internal/src/saved_objects_client.test.ts index 7825b09cf29bd..1ea4aee11d975 100644 --- a/packages/core/saved-objects/core-saved-objects-browser-internal/src/saved_objects_client.test.ts +++ b/packages/core/saved-objects/core-saved-objects-browser-internal/src/saved_objects_client.test.ts @@ -610,7 +610,6 @@ describe('SavedObjectsClient', () => { test('makes HTTP call correctly mapping options into snake case query parameters', () => { const options = { defaultSearchOperator: 'OR' as const, - fields: ['title'], hasReference: { id: '1', type: 'reference' }, hasNoReference: { id: '1', type: 'reference' }, page: 10, @@ -631,9 +630,6 @@ describe('SavedObjectsClient', () => { "method": "GET", "query": Object { "default_search_operator": "OR", - "fields": Array [ - "title", - ], "has_no_reference": "{\\"id\\":\\"1\\",\\"type\\":\\"reference\\"}", "has_reference": "{\\"id\\":\\"1\\",\\"type\\":\\"reference\\"}", "page": 10, diff --git a/packages/core/saved-objects/core-saved-objects-browser-internal/src/saved_objects_client.ts b/packages/core/saved-objects/core-saved-objects-browser-internal/src/saved_objects_client.ts index d500bbfcd7716..6e1c6f6a5f2c7 100644 --- a/packages/core/saved-objects/core-saved-objects-browser-internal/src/saved_objects_client.ts +++ b/packages/core/saved-objects/core-saved-objects-browser-internal/src/saved_objects_client.ts @@ -290,7 +290,6 @@ export class SavedObjectsClient implements SavedObjectsClientContract { const path = this.getPath(['_find']); const renameMap = { defaultSearchOperator: 'default_search_operator', - fields: 'fields', hasReference: 'has_reference', hasReferenceOperator: 'has_reference_operator', hasNoReference: 'has_no_reference', diff --git a/packages/core/saved-objects/core-saved-objects-import-export-server-internal/src/import/lib/check_origin_conflicts.ts b/packages/core/saved-objects/core-saved-objects-import-export-server-internal/src/import/lib/check_origin_conflicts.ts index 0d4765743cddb..cfa549dc6f3ae 100644 --- a/packages/core/saved-objects/core-saved-objects-import-export-server-internal/src/import/lib/check_origin_conflicts.ts +++ b/packages/core/saved-objects/core-saved-objects-import-export-server-internal/src/import/lib/check_origin_conflicts.ts @@ -129,7 +129,6 @@ const checkOriginConflict = async ( rootSearchFields: ['_id', 'originId'], page: 1, perPage: 10, - fields: ['title'], sortField: 'updated_at', sortOrder: 'desc' as const, ...(namespace && { namespaces: [namespace] }), diff --git a/packages/core/saved-objects/core-saved-objects-import-export-server-internal/src/import/lib/check_reference_origins.ts b/packages/core/saved-objects/core-saved-objects-import-export-server-internal/src/import/lib/check_reference_origins.ts index 65a0f9fd432f2..d02a04eed77f2 100644 --- a/packages/core/saved-objects/core-saved-objects-import-export-server-internal/src/import/lib/check_reference_origins.ts +++ b/packages/core/saved-objects/core-saved-objects-import-export-server-internal/src/import/lib/check_reference_origins.ts @@ -43,7 +43,6 @@ async function checkOrigin( rootSearchFields: ['_id', 'originId'], page: 1, perPage: 1, // we only need one result for now - fields: ['title'], // we don't actually need the object's title, we just specify one field so we don't fetch *all* fields sortField: 'updated_at', sortOrder: 'desc' as const, ...(namespace && { namespaces: [namespace] }), diff --git a/packages/core/saved-objects/core-saved-objects-import-export-server-internal/src/import/lib/validate_references.test.ts b/packages/core/saved-objects/core-saved-objects-import-export-server-internal/src/import/lib/validate_references.test.ts index d46382a09b766..2984287b9ede8 100644 --- a/packages/core/saved-objects/core-saved-objects-import-export-server-internal/src/import/lib/validate_references.test.ts +++ b/packages/core/saved-objects/core-saved-objects-import-export-server-internal/src/import/lib/validate_references.test.ts @@ -99,11 +99,11 @@ describe('validateReferences()', () => { expect(params.savedObjectsClient.bulkGet).toHaveBeenCalledTimes(1); expect(params.savedObjectsClient.bulkGet).toHaveBeenCalledWith( [ - { type: 'index-pattern', id: '3', fields: ['id'] }, - { type: 'index-pattern', id: '5', fields: ['id'] }, - { type: 'index-pattern', id: '6', fields: ['id'] }, - { type: 'search', id: '7', fields: ['id'] }, - { type: 'search', id: '8', fields: ['id'] }, + { type: 'index-pattern', id: '3' }, + { type: 'index-pattern', id: '5' }, + { type: 'index-pattern', id: '6' }, + { type: 'search', id: '7' }, + { type: 'search', id: '8' }, ], { namespace: undefined } ); @@ -154,7 +154,7 @@ describe('validateReferences()', () => { expect(result).toEqual([]); expect(params.savedObjectsClient.bulkGet).toHaveBeenCalledTimes(1); expect(params.savedObjectsClient.bulkGet).toHaveBeenCalledWith( - [{ type: 'index-pattern', id: '1', fields: ['id'] }], + [{ type: 'index-pattern', id: '1' }], { namespace: undefined } ); }); @@ -211,9 +211,9 @@ describe('validateReferences()', () => { expect(params.savedObjectsClient.bulkGet).toHaveBeenCalledTimes(1); expect(params.savedObjectsClient.bulkGet).toHaveBeenCalledWith( [ - { type: 'index-pattern', id: '1', fields: ['id'] }, + { type: 'index-pattern', id: '1' }, // foo:2 is not included in the cluster call - { type: 'search', id: '3', fields: ['id'] }, + { type: 'search', id: '3' }, ], { namespace: undefined } ); diff --git a/packages/core/saved-objects/core-saved-objects-import-export-server-internal/src/import/lib/validate_references.ts b/packages/core/saved-objects/core-saved-objects-import-export-server-internal/src/import/lib/validate_references.ts index 05f6b9aa061b5..fd4a7bb7af754 100644 --- a/packages/core/saved-objects/core-saved-objects-import-export-server-internal/src/import/lib/validate_references.ts +++ b/packages/core/saved-objects/core-saved-objects-import-export-server-internal/src/import/lib/validate_references.ts @@ -72,7 +72,7 @@ async function getNonExistingReferenceAsKeys({ } // Fetch references to see if they exist - const bulkGetOpts = Array.from(collector.values()).map((obj) => ({ ...obj, fields: ['id'] })); + const bulkGetOpts = Array.from(collector.values()).map((obj) => ({ ...obj })); const bulkGetResponse = await savedObjectsClient.bulkGet(bulkGetOpts, { namespace }); // Error handling diff --git a/packages/core/saved-objects/core-saved-objects-server-internal/src/routes/bulk_get.ts b/packages/core/saved-objects/core-saved-objects-server-internal/src/routes/bulk_get.ts index b9bc66cc2f693..882d0bbff7609 100644 --- a/packages/core/saved-objects/core-saved-objects-server-internal/src/routes/bulk_get.ts +++ b/packages/core/saved-objects/core-saved-objects-server-internal/src/routes/bulk_get.ts @@ -36,7 +36,6 @@ export const registerBulkGetRoute = ( schema.object({ type: schema.string(), id: schema.string(), - fields: schema.maybe(schema.arrayOf(schema.string())), namespaces: schema.maybe(schema.arrayOf(schema.string())), }) ), diff --git a/packages/core/saved-objects/core-saved-objects-server-internal/src/routes/find.ts b/packages/core/saved-objects/core-saved-objects-server-internal/src/routes/find.ts index 9e8def13dbae1..032cfc4189532 100644 --- a/packages/core/saved-objects/core-saved-objects-server-internal/src/routes/find.ts +++ b/packages/core/saved-objects/core-saved-objects-server-internal/src/routes/find.ts @@ -53,7 +53,6 @@ export const registerFindRoute = ( schema.oneOf([referenceSchema, schema.arrayOf(referenceSchema)]) ), has_no_reference_operator: searchOperatorSchema, - fields: schema.maybe(schema.oneOf([schema.string(), schema.arrayOf(schema.string())])), filter: schema.maybe(schema.string()), aggs: schema.maybe(schema.string()), namespaces: schema.maybe( @@ -119,7 +118,6 @@ export const registerFindRoute = ( hasReferenceOperator: query.has_reference_operator, hasNoReference: query.has_no_reference, hasNoReferenceOperator: query.has_no_reference_operator, - fields: typeof query.fields === 'string' ? [query.fields] : query.fields, filter: query.filter, aggs, namespaces, diff --git a/packages/core/saved-objects/core-saved-objects-server-internal/src/routes/utils.ts b/packages/core/saved-objects/core-saved-objects-server-internal/src/routes/utils.ts index 03023d167a38f..a0fc70dc22882 100644 --- a/packages/core/saved-objects/core-saved-objects-server-internal/src/routes/utils.ts +++ b/packages/core/saved-objects/core-saved-objects-server-internal/src/routes/utils.ts @@ -150,7 +150,6 @@ export function throwIfAnyTypeNotVisibleByAPI( export interface BulkGetItem { type: string; id: string; - fields?: string[]; namespaces?: string[]; } diff --git a/src/core/server/integration_tests/saved_objects/routes/find.test.ts b/src/core/server/integration_tests/saved_objects/routes/find.test.ts index 7611e33171e4b..764cb602825b0 100644 --- a/src/core/server/integration_tests/saved_objects/routes/find.test.ts +++ b/src/core/server/integration_tests/saved_objects/routes/find.test.ts @@ -348,36 +348,6 @@ describe('GET /api/saved_objects/_find', () => { ); }); - it('accepts the query parameter fields as a string', async () => { - await supertest(httpSetup.server.listener) - .get('/api/saved_objects/_find?type=foo&fields=title') - .expect(200); - - expect(savedObjectsClient.find).toHaveBeenCalledTimes(1); - - const options = savedObjectsClient.find.mock.calls[0][0]; - expect(options).toEqual( - expect.objectContaining({ - fields: ['title'], - }) - ); - }); - - it('accepts the query parameter fields as an array', async () => { - await supertest(httpSetup.server.listener) - .get('/api/saved_objects/_find?type=foo&fields=title&fields=description') - .expect(200); - - expect(savedObjectsClient.find).toHaveBeenCalledTimes(1); - - const options = savedObjectsClient.find.mock.calls[0][0]; - expect(options).toEqual( - expect.objectContaining({ - fields: ['title', 'description'], - }) - ); - }); - it('accepts the query parameter type as a string', async () => { await supertest(httpSetup.server.listener) .get('/api/saved_objects/_find?type=index-pattern') diff --git a/src/core/server/integration_tests/saved_objects/routes/import.test.ts b/src/core/server/integration_tests/saved_objects/routes/import.test.ts index 44017096b7e10..5b12dd961bd49 100644 --- a/src/core/server/integration_tests/saved_objects/routes/import.test.ts +++ b/src/core/server/integration_tests/saved_objects/routes/import.test.ts @@ -347,7 +347,7 @@ describe(`POST ${URL}`, () => { }); expect(savedObjectsClient.bulkGet).toHaveBeenCalledTimes(1); expect(savedObjectsClient.bulkGet).toHaveBeenCalledWith( - [{ fields: ['id'], id: 'my-pattern', type: 'index-pattern' }], + [{ id: 'my-pattern', type: 'index-pattern' }], expect.any(Object) // options ); expect(savedObjectsClient.bulkCreate).not.toHaveBeenCalled(); // no objects were created @@ -416,7 +416,7 @@ describe(`POST ${URL}`, () => { }); expect(savedObjectsClient.bulkGet).toHaveBeenCalledTimes(1); expect(savedObjectsClient.bulkGet).toHaveBeenCalledWith( - [{ fields: ['id'], id: 'my-pattern', type: 'index-pattern' }], + [{ id: 'my-pattern', type: 'index-pattern' }], expect.any(Object) // options ); expect(savedObjectsClient.bulkCreate).not.toHaveBeenCalled(); // no objects were created @@ -480,7 +480,7 @@ describe(`POST ${URL}`, () => { }); expect(savedObjectsClient.bulkGet).toHaveBeenCalledTimes(1); expect(savedObjectsClient.bulkGet).toHaveBeenCalledWith( - [{ fields: ['id'], id: 'my-pattern', type: 'index-pattern' }], + [{ id: 'my-pattern', type: 'index-pattern' }], expect.any(Object) // options ); expect(savedObjectsClient.bulkCreate).not.toHaveBeenCalled(); // no objects were created diff --git a/src/core/server/integration_tests/saved_objects/routes/resolve_import_errors.test.ts b/src/core/server/integration_tests/saved_objects/routes/resolve_import_errors.test.ts index ceef6af3e48c1..da751caadbfc5 100644 --- a/src/core/server/integration_tests/saved_objects/routes/resolve_import_errors.test.ts +++ b/src/core/server/integration_tests/saved_objects/routes/resolve_import_errors.test.ts @@ -287,7 +287,7 @@ describe(`POST ${URL}`, () => { ); expect(savedObjectsClient.bulkGet).toHaveBeenCalledTimes(1); expect(savedObjectsClient.bulkGet).toHaveBeenCalledWith( - [{ fields: ['id'], id: 'existing', type: 'index-pattern' }], + [{ id: 'existing', type: 'index-pattern' }], expect.any(Object) // options ); }); diff --git a/src/plugins/dashboard/public/dashboard_actions/clone_panel_action.tsx b/src/plugins/dashboard/public/dashboard_actions/clone_panel_action.tsx index 482553e2f002f..ca603dc8f9851 100644 --- a/src/plugins/dashboard/public/dashboard_actions/clone_panel_action.tsx +++ b/src/plugins/dashboard/public/dashboard_actions/clone_panel_action.tsx @@ -120,7 +120,6 @@ export class ClonePanelAction implements Action { const similarSavedObjects = await this.savedObjects.client.find({ type: embeddable.type, perPage, - fields: ['title'], searchFields: ['title'], search: `"${baseTitle}"`, }); diff --git a/src/plugins/dashboard/public/services/dashboard_saved_object/lib/check_for_duplicate_dashboard_title.ts b/src/plugins/dashboard/public/services/dashboard_saved_object/lib/check_for_duplicate_dashboard_title.ts index 2f106a2e1a00d..2de6fd41c5be6 100644 --- a/src/plugins/dashboard/public/services/dashboard_saved_object/lib/check_for_duplicate_dashboard_title.ts +++ b/src/plugins/dashboard/public/services/dashboard_saved_object/lib/check_for_duplicate_dashboard_title.ts @@ -46,7 +46,6 @@ export async function checkForDuplicateDashboardTitle( } const response = await savedObjectsClient.find({ perPage: 10, - fields: ['title'], search: `"${title}"`, searchFields: ['title'], type: DASHBOARD_SAVED_OBJECT_TYPE, diff --git a/src/plugins/data_views/server/deprecations/scripted_fields.ts b/src/plugins/data_views/server/deprecations/scripted_fields.ts index 198a44ed45555..5f184cf97b8ec 100644 --- a/src/plugins/data_views/server/deprecations/scripted_fields.ts +++ b/src/plugins/data_views/server/deprecations/scripted_fields.ts @@ -25,7 +25,6 @@ export const createScriptedFieldsDeprecationsConfig: ( context.savedObjectsClient.createPointInTimeFinder({ type: 'index-pattern', perPage: 1000, - fields: ['title', 'fields'], }); const indexPatternsWithScriptedFields: IndexPatternAttributesWithFields[] = []; diff --git a/src/plugins/data_views/server/has_user_data_view.ts b/src/plugins/data_views/server/has_user_data_view.ts index e822b7cb35a49..17d41e8df114f 100644 --- a/src/plugins/data_views/server/has_user_data_view.ts +++ b/src/plugins/data_views/server/has_user_data_view.ts @@ -23,7 +23,6 @@ export const getDataViews = async ({ }: Deps): Promise> => soClient.find({ type: 'index-pattern', - fields: ['title'], search: `*`, searchFields: ['title'], perPage: 100, diff --git a/src/plugins/data_views/server/register_index_pattern_usage_collection.ts b/src/plugins/data_views/server/register_index_pattern_usage_collection.ts index 7b59f95d571ab..38a62eb00187a 100644 --- a/src/plugins/data_views/server/register_index_pattern_usage_collection.ts +++ b/src/plugins/data_views/server/register_index_pattern_usage_collection.ts @@ -88,7 +88,6 @@ export async function getIndexPatternTelemetry(savedObjectsService: SavedObjects const findOptions: SavedObjectsCreatePointInTimeFinderOptions = { type: DATA_VIEW_SAVED_OBJECT_TYPE, perPage: 1000, - fields: ['fields', 'runtimeFieldMap'], }; const finder = savedObjectsService.createPointInTimeFinder(findOptions); diff --git a/src/plugins/data_views/server/routes/has_data_views.test.ts b/src/plugins/data_views/server/routes/has_data_views.test.ts index e8e77fa9a79a0..d232d63c0ad8a 100644 --- a/src/plugins/data_views/server/routes/has_data_views.test.ts +++ b/src/plugins/data_views/server/routes/has_data_views.test.ts @@ -60,9 +60,6 @@ describe('preview has_data_views route', () => { expect(mockSOClient.find.mock.calls[0][0]).toMatchInlineSnapshot(` Object { - "fields": Array [ - "title", - ], "perPage": 100, "search": "*", "searchFields": Array [ diff --git a/src/plugins/data_views/server/utils.ts b/src/plugins/data_views/server/utils.ts index 79374609cdaa0..b219a488edf6e 100644 --- a/src/plugins/data_views/server/utils.ts +++ b/src/plugins/data_views/server/utils.ts @@ -31,7 +31,6 @@ export const findIndexPatternById = async ( ): Promise | undefined> => { const savedObjectsResponse = await savedObjectsClient.find({ type: DATA_VIEW_SAVED_OBJECT_TYPE, - fields: ['fields'], search: `"${index}"`, searchFields: ['title'], }); diff --git a/src/plugins/ftr_apis/server/routes/kbn_client_so/find.ts b/src/plugins/ftr_apis/server/routes/kbn_client_so/find.ts index 4ded164377646..340d19de94edf 100644 --- a/src/plugins/ftr_apis/server/routes/kbn_client_so/find.ts +++ b/src/plugins/ftr_apis/server/routes/kbn_client_so/find.ts @@ -23,7 +23,6 @@ export const registerFindRoute = (router: IRouter) => { page: schema.number({ min: 0, defaultValue: 1 }), type: schema.oneOf([schema.string(), schema.arrayOf(schema.string())]), search: schema.maybe(schema.string()), - fields: schema.maybe(schema.oneOf([schema.string(), schema.arrayOf(schema.string())])), }), }, }, @@ -39,7 +38,6 @@ export const registerFindRoute = (router: IRouter) => { page: query.page, type: Array.isArray(query.type) ? query.type : [query.type], search: query.search, - fields: typeof query.fields === 'string' ? [query.fields] : query.fields, }); return res.ok({ body: result }); diff --git a/src/plugins/kibana_usage_collection/server/collectors/ui_counters/register_ui_counters_collector.ts b/src/plugins/kibana_usage_collection/server/collectors/ui_counters/register_ui_counters_collector.ts index 0eb9d291337a7..946f6995dd0f4 100644 --- a/src/plugins/kibana_usage_collection/server/collectors/ui_counters/register_ui_counters_collector.ts +++ b/src/plugins/kibana_usage_collection/server/collectors/ui_counters/register_ui_counters_collector.ts @@ -59,7 +59,6 @@ export function transformRawUsageCounterObject( export async function fetchUiCounters({ soClient }: CollectorFetchContext) { const finder = soClient.createPointInTimeFinder({ type: USAGE_COUNTERS_SAVED_OBJECT_TYPE, - fields: ['count', 'counterName', 'counterType', 'domainId'], filter: `${USAGE_COUNTERS_SAVED_OBJECT_TYPE}.attributes.domainId: uiCounter`, perPage: 1000, }); diff --git a/src/plugins/kibana_usage_collection/server/collectors/ui_metric/telemetry_ui_metric_collector.ts b/src/plugins/kibana_usage_collection/server/collectors/ui_metric/telemetry_ui_metric_collector.ts index 917d7a06a0f47..5a9bfa7ef8b71 100644 --- a/src/plugins/kibana_usage_collection/server/collectors/ui_metric/telemetry_ui_metric_collector.ts +++ b/src/plugins/kibana_usage_collection/server/collectors/ui_metric/telemetry_ui_metric_collector.ts @@ -50,7 +50,6 @@ export function registerUiMetricUsageCollector( const finder = savedObjectsClient.createPointInTimeFinder({ type: 'ui-metric', - fields: ['count'], perPage: 1000, }); diff --git a/src/plugins/kibana_usage_collection/server/collectors/usage_counters/register_usage_counters_collector.ts b/src/plugins/kibana_usage_collection/server/collectors/usage_counters/register_usage_counters_collector.ts index a46782bf8563a..256262b22efb1 100644 --- a/src/plugins/kibana_usage_collection/server/collectors/usage_counters/register_usage_counters_collector.ts +++ b/src/plugins/kibana_usage_collection/server/collectors/usage_counters/register_usage_counters_collector.ts @@ -88,7 +88,6 @@ export function registerUsageCountersUsageCollector(usageCollection: UsageCollec fetch: async ({ soClient }: CollectorFetchContext) => { const finder = soClient.createPointInTimeFinder({ type: USAGE_COUNTERS_SAVED_OBJECT_TYPE, - fields: ['count', 'counterName', 'counterType', 'domainId'], filter: `NOT ${USAGE_COUNTERS_SAVED_OBJECT_TYPE}.attributes.domainId: uiCounter`, perPage: 1000, }); diff --git a/src/plugins/saved_objects/public/saved_object/helpers/find_object_by_title.ts b/src/plugins/saved_objects/public/saved_object/helpers/find_object_by_title.ts index 53b05265eecb7..7fef3f139f999 100644 --- a/src/plugins/saved_objects/public/saved_object/helpers/find_object_by_title.ts +++ b/src/plugins/saved_objects/public/saved_object/helpers/find_object_by_title.ts @@ -36,7 +36,6 @@ export async function findObjectByTitle( perPage: 10, search: `"${title}"`, searchFields: ['title'], - fields: ['title'], }); return response.savedObjects.find( (obj) => obj.get('title').toLowerCase() === title.toLowerCase() diff --git a/src/plugins/saved_objects_finder/public/finder/saved_object_finder.test.tsx b/src/plugins/saved_objects_finder/public/finder/saved_object_finder.test.tsx index 1c8ed33853c87..4474a5d4d4b41 100644 --- a/src/plugins/saved_objects_finder/public/finder/saved_object_finder.test.tsx +++ b/src/plugins/saved_objects_finder/public/finder/saved_object_finder.test.tsx @@ -129,7 +129,6 @@ describe('SavedObjectsFinder', () => { expect(core.http.get).toHaveBeenCalledWith('/internal/saved-objects-finder/find', { query: { type: ['search'], - fields: ['title', 'name'], search: undefined, hasReference: undefined, page: 1, @@ -518,7 +517,6 @@ describe('SavedObjectsFinder', () => { expect(core.http.get).toHaveBeenCalledWith('/internal/saved-objects-finder/find', { query: { type: ['search'], - fields: ['title', 'name'], search: 'abc*', hasReference: undefined, page: 1, @@ -529,55 +527,6 @@ describe('SavedObjectsFinder', () => { }); }); - it('should include additional fields in search if listed in meta data', async () => { - const core = coreMock.createStart(); - (core.http.get as jest.Mock).mockResolvedValue({ saved_objects: [] }); - core.uiSettings.get.mockImplementation(() => 10); - - const wrapper = mount( - 'search', - includeFields: ['field1', 'field2'], - }, - { - type: 'type2', - name: '', - getIconForSavedObject: () => 'search', - includeFields: ['field2', 'field3'], - }, - ]} - /> - ); - - wrapper.instance().componentDidMount!(); - await nextTick(); - wrapper - .find('[data-test-subj="savedObjectFinderSearchInput"] input') - .simulate('keyup', { key: 'Enter', target: { value: 'abc' } }); - expect(core.http.get).toHaveBeenCalledWith('/internal/saved-objects-finder/find', { - query: { - type: ['type1', 'type2'], - fields: ['title', 'name', 'field1', 'field2', 'field3'], - search: 'abc*', - hasReference: undefined, - page: 1, - perPage: 10, - searchFields: ['title^3', 'description'], - defaultSearchOperator: 'AND', - }, - }); - }); - it('should respect response order on search input', async () => { const core = coreMock.createStart(); (core.http.get as any as jest.SpyInstance).mockImplementation(() => @@ -643,7 +592,6 @@ describe('SavedObjectsFinder', () => { expect(core.http.get).toHaveBeenCalledWith('/internal/saved-objects-finder/find', { query: { type: ['search', 'vis'], - fields: ['title', 'name'], search: undefined, page: 1, perPage: 10, @@ -796,7 +744,6 @@ describe('SavedObjectsFinder', () => { expect(core.http.get).toHaveBeenLastCalledWith('/internal/saved-objects-finder/find', { query: { type: ['vis'], - fields: ['title', 'name'], search: undefined, hasReference: undefined, page: 1, @@ -809,7 +756,6 @@ describe('SavedObjectsFinder', () => { expect(core.http.get).toHaveBeenLastCalledWith('/internal/saved-objects-finder/find', { query: { type: ['search', 'vis'], - fields: ['title', 'name'], search: undefined, hasReference: undefined, page: 1, @@ -850,7 +796,6 @@ describe('SavedObjectsFinder', () => { expect(core.http.get).toHaveBeenLastCalledWith('/internal/saved-objects-finder/find', { query: { type: ['search', 'vis'], - fields: ['title', 'name'], search: undefined, hasReference: JSON.stringify(['tag1']), page: 1, @@ -863,7 +808,6 @@ describe('SavedObjectsFinder', () => { expect(core.http.get).toHaveBeenLastCalledWith('/internal/saved-objects-finder/find', { query: { type: ['search', 'vis'], - fields: ['title', 'name'], search: undefined, hasReference: JSON.stringify(['tag1', 'tag2']), page: 1, diff --git a/src/plugins/saved_objects_finder/public/finder/saved_object_finder.tsx b/src/plugins/saved_objects_finder/public/finder/saved_object_finder.tsx index 56f8b203f694c..dbe940d1798e4 100644 --- a/src/plugins/saved_objects_finder/public/finder/saved_object_finder.tsx +++ b/src/plugins/saved_objects_finder/public/finder/saved_object_finder.tsx @@ -110,10 +110,6 @@ export class SavedObjectFinderUi extends React.Component< const metaDataMap = this.getSavedObjectMetaDataMap(); const { savedObjectsManagement, uiSettings, http } = this.props.services; - const fields = Object.values(metaDataMap) - .map((metaData) => metaData.includeFields || []) - .reduce((allFields, currentFields) => allFields.concat(currentFields), ['title', 'name']); - const additionalSearchFields = Object.values(metaDataMap).reduce((col, item) => { if (item.defaultSearchField) { col.push(item.defaultSearchField); @@ -138,7 +134,6 @@ export class SavedObjectFinderUi extends React.Component< const params: FindQueryHTTP = { type: visibleTypes ?? Object.keys(metaDataMap), search: queryText ? `${queryText}*` : undefined, - fields: [...new Set(fields)], page: 1, perPage, searchFields: ['title^3', 'description', ...additionalSearchFields], diff --git a/src/plugins/saved_objects_finder/server/routes/find.ts b/src/plugins/saved_objects_finder/server/routes/find.ts index ce9377ce25333..ea10d3bf996f5 100644 --- a/src/plugins/saved_objects_finder/server/routes/find.ts +++ b/src/plugins/saved_objects_finder/server/routes/find.ts @@ -23,9 +23,6 @@ export const registerFindRoute = (router: SavedObjectsRouter) => { defaultSearchOperator: schema.oneOf([schema.literal('AND'), schema.literal('OR')]), sortField: schema.maybe(schema.string()), sortOrder: schema.maybe(schema.oneOf([schema.literal('asc'), schema.literal('desc')])), - fields: schema.oneOf([schema.string(), schema.arrayOf(schema.string())], { - defaultValue: [], - }), searchFields: schema.maybe(schema.arrayOf(schema.string())), hasReference: schema.maybe(schema.string()), }), @@ -39,12 +36,10 @@ export const registerFindRoute = (router: SavedObjectsRouter) => { const { query } = req; const searchTypes = Array.isArray(query.type) ? query.type : [query.type]; - const includedFields = Array.isArray(query.fields) ? query.fields : [query.fields]; const findResponse = await savedObjectsClient.find>({ ...query, type: searchTypes, - fields: includedFields, hasReference: query.hasReference ? JSON.parse(query.hasReference) : undefined, }); diff --git a/src/plugins/saved_objects_management/server/routes/find.ts b/src/plugins/saved_objects_management/server/routes/find.ts index 1412df99cbcef..567302dd7ec6c 100644 --- a/src/plugins/saved_objects_management/server/routes/find.ts +++ b/src/plugins/saved_objects_management/server/routes/find.ts @@ -76,7 +76,6 @@ export const registerFindRoute = ( const findResponse = await client.find({ ...query, - fields: undefined, searchFields: [...searchFields], }); diff --git a/src/plugins/saved_search/public/services/saved_searches/save_saved_searches.ts b/src/plugins/saved_search/public/services/saved_searches/save_saved_searches.ts index a7d11ab69166e..60ba0968aaeb2 100644 --- a/src/plugins/saved_search/public/services/saved_searches/save_saved_searches.ts +++ b/src/plugins/saved_search/public/services/saved_searches/save_saved_searches.ts @@ -31,7 +31,6 @@ const hasDuplicatedTitle = async ( perPage: 10, search: `"${title}"`, searchFields: ['title'], - fields: ['title'], }); return response.savedObjects.some( diff --git a/src/plugins/visualizations/public/utils/saved_objects_utils/find_object_by_title.ts b/src/plugins/visualizations/public/utils/saved_objects_utils/find_object_by_title.ts index 92fa0e0437695..eb60c68ec7f55 100644 --- a/src/plugins/visualizations/public/utils/saved_objects_utils/find_object_by_title.ts +++ b/src/plugins/visualizations/public/utils/saved_objects_utils/find_object_by_title.ts @@ -29,7 +29,6 @@ export async function findObjectByTitle( perPage: 10, search: `"${title}"`, searchFields: ['title'], - fields: ['title'], }); return response.savedObjects.find( (obj) => obj.get('title').toLowerCase() === title.toLowerCase() diff --git a/test/api_integration/apis/saved_objects/find.ts b/test/api_integration/apis/saved_objects/find.ts index 80b5787b880be..ee4e53b00b749 100644 --- a/test/api_integration/apis/saved_objects/find.ts +++ b/test/api_integration/apis/saved_objects/find.ts @@ -42,7 +42,7 @@ export default function ({ getService }: FtrProviderContext) { it('should return 200 with individual responses', async () => await supertest - .get(`/s/${SPACE_ID}/api/saved_objects/_find?type=visualization&fields=title`) + .get(`/s/${SPACE_ID}/api/saved_objects/_find?type=visualization`) .expect(200) .then((resp) => { expect(resp.body.saved_objects.map((so: { id: string }) => so.id)).to.eql([ @@ -115,7 +115,7 @@ export default function ({ getService }: FtrProviderContext) { describe('known namespace', () => { it('should return 200 with individual responses', async () => await supertest - .get(`/api/saved_objects/_find?type=visualization&fields=title&namespaces=${SPACE_ID}`) + .get(`/api/saved_objects/_find?type=visualization&namespaces=${SPACE_ID}`) .expect(200) .then((resp) => { expect( @@ -131,9 +131,7 @@ export default function ({ getService }: FtrProviderContext) { describe('wildcard namespace', () => { it('should return 200 with individual responses from the all namespaces', async () => await supertest - .get( - `/api/saved_objects/_find?type=visualization&fields=title&fields=originId&namespaces=*` - ) + .get(`/api/saved_objects/_find?type=visualization&namespaces=*`) .expect(200) .then((resp) => { const knownDocuments = resp.body.saved_objects.filter((so: { namespaces: string[] }) => diff --git a/x-pack/plugins/alerting/server/health/get_health.ts b/x-pack/plugins/alerting/server/health/get_health.ts index b101d0187e7e8..938227fe0f1b4 100644 --- a/x-pack/plugins/alerting/server/health/get_health.ts +++ b/x-pack/plugins/alerting/server/health/get_health.ts @@ -28,7 +28,6 @@ export const getHealth = async ( const { saved_objects: decryptErrorData } = await internalSavedObjectsRepository.find({ filter: `alert.attributes.executionStatus.status:error and alert.attributes.executionStatus.error.reason:${RuleExecutionStatusErrorReasons.Decrypt}`, - fields: ['executionStatus'], type: 'alert', sortField: 'executionStatus.lastExecutionDate', sortOrder: 'desc', @@ -46,7 +45,6 @@ export const getHealth = async ( const { saved_objects: executeErrorData } = await internalSavedObjectsRepository.find({ filter: `alert.attributes.executionStatus.status:error and alert.attributes.executionStatus.error.reason:${RuleExecutionStatusErrorReasons.Execute}`, - fields: ['executionStatus'], type: 'alert', sortField: 'executionStatus.lastExecutionDate', sortOrder: 'desc', @@ -64,7 +62,6 @@ export const getHealth = async ( const { saved_objects: readErrorData } = await internalSavedObjectsRepository.find({ filter: `alert.attributes.executionStatus.status:error and alert.attributes.executionStatus.error.reason:${RuleExecutionStatusErrorReasons.Read}`, - fields: ['executionStatus'], type: 'alert', sortField: 'executionStatus.lastExecutionDate', sortOrder: 'desc', @@ -82,7 +79,6 @@ export const getHealth = async ( const { saved_objects: noErrorData } = await internalSavedObjectsRepository.find({ filter: 'not alert.attributes.executionStatus.status:error', - fields: ['executionStatus'], type: 'alert', sortField: 'executionStatus.lastExecutionDate', sortOrder: 'desc', diff --git a/x-pack/plugins/alerting/server/routes/find_rules.test.ts b/x-pack/plugins/alerting/server/routes/find_rules.test.ts index 6e8f4e5474dbf..593316118dc2a 100644 --- a/x-pack/plugins/alerting/server/routes/find_rules.test.ts +++ b/x-pack/plugins/alerting/server/routes/find_rules.test.ts @@ -188,40 +188,4 @@ describe('findRulesRoute', () => { 'alertTypeId', ]); }); - - it('should track calls to deprecated functionality', async () => { - const licenseState = licenseStateMock.create(); - const router = httpServiceMock.createRouter(); - - findRulesRoute(router, licenseState, mockUsageCounter); - - const findResult = { - page: 1, - perPage: 1, - total: 0, - data: [], - }; - rulesClient.find.mockResolvedValueOnce(findResult); - - const [, handler] = router.get.mock.calls[0]; - const [context, req, res] = mockHandlerArguments( - { rulesClient }, - { - params: {}, - query: { - fields: ['foo', 'bar'], - per_page: 1, - page: 1, - default_search_operator: 'OR', - }, - }, - ['ok'] - ); - await handler(context, req, res); - expect(mockUsageCounter.incrementCounter).toHaveBeenCalledWith({ - counterName: `alertingFieldsUsage`, - counterType: 'alertingFieldsUsage', - incrementBy: 1, - }); - }); }); diff --git a/x-pack/plugins/alerting/server/routes/find_rules.ts b/x-pack/plugins/alerting/server/routes/find_rules.ts index 50bd9ad387d7d..c401fefc80064 100644 --- a/x-pack/plugins/alerting/server/routes/find_rules.ts +++ b/x-pack/plugins/alerting/server/routes/find_rules.ts @@ -45,7 +45,6 @@ const querySchema = schema.object({ }) ) ), - fields: schema.maybe(schema.arrayOf(schema.string())), filter: schema.maybe(schema.string()), }); @@ -117,14 +116,6 @@ const buildFindRulesRoute = ({ search_fields: searchFieldsAsArray(req.query.search_fields), }); - if (req.query.fields) { - usageCounter?.incrementCounter({ - counterName: `alertingFieldsUsage`, - counterType: 'alertingFieldsUsage', - incrementBy: 1, - }); - } - const findResult = await rulesClient.find({ options, excludeFromPublicApi, @@ -161,14 +152,6 @@ const buildFindRulesRoute = ({ search_fields: searchFieldsAsArray(req.body.search_fields), }); - if (req.body.fields) { - usageCounter?.incrementCounter({ - counterName: `alertingFieldsUsage`, - counterType: 'alertingFieldsUsage', - incrementBy: 1, - }); - } - const findResult = await rulesClient.find({ options, excludeFromPublicApi, diff --git a/x-pack/plugins/alerting/server/routes/legacy/find.test.ts b/x-pack/plugins/alerting/server/routes/legacy/find.test.ts index 026a4f81688e3..c7cc447e67304 100644 --- a/x-pack/plugins/alerting/server/routes/legacy/find.test.ts +++ b/x-pack/plugins/alerting/server/routes/legacy/find.test.ts @@ -195,30 +195,4 @@ describe('findAlertRoute', () => { 'alertTypeId', ]); }); - - it('should track calls to deprecated functionality', async () => { - const licenseState = licenseStateMock.create(); - const router = httpServiceMock.createRouter(); - const mockUsageCountersSetup = usageCountersServiceMock.createSetupContract(); - const mockUsageCounter = mockUsageCountersSetup.createUsageCounter('test'); - - findAlertRoute(router, licenseState, mockUsageCounter); - const [, handler] = router.get.mock.calls[0]; - const [context, req, res] = mockHandlerArguments( - { rulesClient }, - { - params: {}, - query: { - fields: ['foo', 'bar'], - }, - }, - ['ok'] - ); - await handler(context, req, res); - expect(mockUsageCounter.incrementCounter).toHaveBeenCalledWith({ - counterName: `legacyAlertingFieldsUsage`, - counterType: 'alertingFieldsUsage', - incrementBy: 1, - }); - }); }); diff --git a/x-pack/plugins/alerting/server/routes/legacy/find.ts b/x-pack/plugins/alerting/server/routes/legacy/find.ts index 9a33f5b2dc5fd..c57cf2d14ca37 100644 --- a/x-pack/plugins/alerting/server/routes/legacy/find.ts +++ b/x-pack/plugins/alerting/server/routes/legacy/find.ts @@ -38,7 +38,6 @@ const querySchema = schema.object({ }) ) ), - fields: schema.maybe(schema.arrayOf(schema.string())), filter: schema.maybe(schema.string()), }); @@ -71,7 +70,6 @@ export const findAlertRoute = ( const query = req.query; const renameMap = { default_search_operator: 'defaultSearchOperator', - fields: 'fields', has_reference: 'hasReference', page: 'page', per_page: 'perPage', @@ -89,14 +87,6 @@ export const findAlertRoute = ( : [query.search_fields]; } - if (query.fields) { - usageCounter?.incrementCounter({ - counterName: `legacyAlertingFieldsUsage`, - counterType: 'alertingFieldsUsage', - incrementBy: 1, - }); - } - const findResult = await rulesClient.find({ options, excludeFromPublicApi: true }); return res.ok({ body: findResult, diff --git a/x-pack/plugins/alerting/server/rules_client/common/include_fields_required_for_authentication.ts b/x-pack/plugins/alerting/server/rules_client/common/include_fields_required_for_authentication.ts deleted file mode 100644 index b89d56174c59b..0000000000000 --- a/x-pack/plugins/alerting/server/rules_client/common/include_fields_required_for_authentication.ts +++ /dev/null @@ -1,12 +0,0 @@ -/* - * 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; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import { uniq } from 'lodash'; - -export function includeFieldsRequiredForAuthentication(fields: string[]): string[] { - return uniq([...fields, 'alertTypeId', 'consumer']); -} diff --git a/x-pack/plugins/alerting/server/rules_client/common/index.ts b/x-pack/plugins/alerting/server/rules_client/common/index.ts index ab380a6ca178b..7f07ed795589a 100644 --- a/x-pack/plugins/alerting/server/rules_client/common/index.ts +++ b/x-pack/plugins/alerting/server/rules_client/common/index.ts @@ -16,7 +16,6 @@ export * from './mapped_params_utils'; export { apiKeyAsAlertAttributes } from './api_key_as_alert_attributes'; export * from './inject_references'; export { parseDate } from './parse_date'; -export { includeFieldsRequiredForAuthentication } from './include_fields_required_for_authentication'; export { getAndValidateCommonBulkOptions } from './get_and_validate_common_bulk_options'; export * from './snooze_utils'; export { tryToRemoveTasks } from './try_to_remove_tasks'; diff --git a/x-pack/plugins/alerting/server/rules_client/methods/find.ts b/x-pack/plugins/alerting/server/rules_client/methods/find.ts index 080c72c624cb3..00752110a1cd2 100644 --- a/x-pack/plugins/alerting/server/rules_client/methods/find.ts +++ b/x-pack/plugins/alerting/server/rules_client/methods/find.ts @@ -7,17 +7,11 @@ import Boom from '@hapi/boom'; import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; -import { pick } from 'lodash'; import { KueryNode, nodeBuilder } from '@kbn/es-query'; import { RawRule, RuleTypeParams, SanitizedRule } from '../../types'; import { AlertingAuthorizationEntity } from '../../authorization'; import { ruleAuditEvent, RuleAuditAction } from '../common/audit_events'; -import { - mapSortField, - validateOperationOnAttributes, - buildKueryNodeFilter, - includeFieldsRequiredForAuthentication, -} from '../common'; +import { mapSortField, validateOperationOnAttributes, buildKueryNodeFilter } from '../common'; import { getModifiedField, getModifiedSearchFields, @@ -46,7 +40,6 @@ export interface FindOptions extends IndexType { type: string; id: string; }; - fields?: string[]; filter?: string | KueryNode; } @@ -59,11 +52,7 @@ export interface FindResult { export async function find( context: RulesClientContext, - { - options: { fields, ...options } = {}, - excludeFromPublicApi = false, - includeSnoozeData = false, - }: FindParams = {} + { options = {}, excludeFromPublicApi = false, includeSnoozeData = false }: FindParams = {} ): Promise> { let authorizationTuple; try { @@ -128,7 +117,6 @@ export async function find( (authorizationFilter && filterKueryNode ? nodeBuilder.and([filterKueryNode, authorizationFilter as KueryNode]) : authorizationFilter) ?? filterKueryNode, - fields: fields ? includeFieldsRequiredForAuthentication(fields) : fields, type: 'alert', }); @@ -153,7 +141,7 @@ export async function find( context, id, attributes.alertTypeId, - fields ? (pick(attributes, fields) as RawRule) : attributes, + attributes, references, false, excludeFromPublicApi, diff --git a/x-pack/plugins/alerting/server/rules_client/tests/aggregate.test.ts b/x-pack/plugins/alerting/server/rules_client/tests/aggregate.test.ts index 3253d9d71ac03..019c6fb096aef 100644 --- a/x-pack/plugins/alerting/server/rules_client/tests/aggregate.test.ts +++ b/x-pack/plugins/alerting/server/rules_client/tests/aggregate.test.ts @@ -325,7 +325,6 @@ describe('aggregate()', () => { expect(unsecuredSavedObjectsClient.find).toHaveBeenCalledTimes(1); expect(unsecuredSavedObjectsClient.find.mock.calls[0]).toEqual([ { - fields: undefined, filter: nodeTypes.function.buildNode('and', [ fromKueryExpression('foo: someTerm'), authFilter, diff --git a/x-pack/plugins/alerting/server/rules_client/tests/find.test.ts b/x-pack/plugins/alerting/server/rules_client/tests/find.test.ts index 200b4a291baa1..a1ccaf3616e77 100644 --- a/x-pack/plugins/alerting/server/rules_client/tests/find.test.ts +++ b/x-pack/plugins/alerting/server/rules_client/tests/find.test.ts @@ -175,7 +175,6 @@ describe('find()', () => { expect(unsecuredSavedObjectsClient.find.mock.calls[0]).toMatchInlineSnapshot(` Array [ Object { - "fields": undefined, "filter": null, "sortField": undefined, "type": "alert", @@ -276,7 +275,6 @@ describe('find()', () => { expect(unsecuredSavedObjectsClient.find.mock.calls[0]).toMatchInlineSnapshot(` Array [ Object { - "fields": undefined, "filter": null, "sortField": undefined, "type": "alert", @@ -715,11 +713,13 @@ describe('find()', () => { }); const rulesClient = new RulesClient(rulesClientParams); - expect(await rulesClient.find({ options: { fields: ['tags'] } })).toMatchInlineSnapshot(` + expect(await rulesClient.find({ options: {} })).toMatchInlineSnapshot(` Object { "data": Array [ Object { "actions": Array [], + "alertTypeId": "myType", + "consumer": "myApp", "id": "1", "notifyWhen": undefined, "params": undefined, @@ -737,7 +737,6 @@ describe('find()', () => { `); expect(unsecuredSavedObjectsClient.find).toHaveBeenCalledWith({ - fields: ['tags', 'alertTypeId', 'consumer'], filter: null, sortField: undefined, type: 'alert', diff --git a/x-pack/plugins/apm/server/saved_objects/migrations/migrate_legacy_apm_indices_to_space_aware.ts b/x-pack/plugins/apm/server/saved_objects/migrations/migrate_legacy_apm_indices_to_space_aware.ts index 8098318ce61e6..86bb3aec49f72 100644 --- a/x-pack/plugins/apm/server/saved_objects/migrations/migrate_legacy_apm_indices_to_space_aware.ts +++ b/x-pack/plugins/apm/server/saved_objects/migrations/migrate_legacy_apm_indices_to_space_aware.ts @@ -57,7 +57,6 @@ export async function migrateLegacyAPMIndicesToSpaceAware({ type: 'space', page: 1, perPage: 10_000, // max number of spaces as of 8.2 - fields: ['name'], // to avoid fetching *all* fields }); const savedObjectAttributes = { diff --git a/x-pack/plugins/canvas/server/routes/custom_elements/find.ts b/x-pack/plugins/canvas/server/routes/custom_elements/find.ts index 0f7f492cef87c..d6db0e7fa981e 100644 --- a/x-pack/plugins/canvas/server/routes/custom_elements/find.ts +++ b/x-pack/plugins/canvas/server/routes/custom_elements/find.ts @@ -34,16 +34,6 @@ export function initializeFindCustomElementsRoute(deps: RouteInitializerDeps) { sortOrder: 'desc', search: name ? `${name}* | ${name}` : '*', searchFields: ['name'], - fields: [ - 'id', - 'name', - 'displayName', - 'help', - 'image', - 'content', - '@created', - '@timestamp', - ], page, perPage, }); diff --git a/x-pack/plugins/canvas/server/routes/templates/list.ts b/x-pack/plugins/canvas/server/routes/templates/list.ts index c0e32fb3722b1..a0f8900f5758c 100644 --- a/x-pack/plugins/canvas/server/routes/templates/list.ts +++ b/x-pack/plugins/canvas/server/routes/templates/list.ts @@ -29,7 +29,6 @@ export function initializeListTemplates(deps: RouteInitializerDeps) { sortOrder: 'desc', search: '*', searchFields: ['name', 'help'], - fields: ['id', 'name', 'help', 'tags'], }); return response.ok({ diff --git a/x-pack/plugins/canvas/server/routes/workpad/find.ts b/x-pack/plugins/canvas/server/routes/workpad/find.ts index 43db20ee11db5..be184d9bad006 100644 --- a/x-pack/plugins/canvas/server/routes/workpad/find.ts +++ b/x-pack/plugins/canvas/server/routes/workpad/find.ts @@ -34,7 +34,6 @@ export function initializeFindWorkpadsRoute(deps: RouteInitializerDeps) { sortOrder: 'desc', search: name ? `${name}* | ${name}` : '*', searchFields: ['name'], - fields: ['id', 'name', '@created', '@timestamp'], page, perPage, }); diff --git a/x-pack/plugins/cases/server/services/attachments/operations/get.ts b/x-pack/plugins/cases/server/services/attachments/operations/get.ts index 89fa8bbb12277..b10f2798c6f48 100644 --- a/x-pack/plugins/cases/server/services/attachments/operations/get.ts +++ b/x-pack/plugins/cases/server/services/attachments/operations/get.ts @@ -77,12 +77,6 @@ export class AttachmentGetter { hasReference: caseIds.map((id) => ({ id, type: CASE_SAVED_OBJECT })), sortField: 'created_at', sortOrder: 'asc', - /** - * We only care about the ids so to reduce the data returned we should limit the fields in the response. Core - * doesn't support retrieving no fields (id would always be returned anyway) so to limit it we'll only request - * the owner even though we don't need it. - */ - fields: ['owner'], perPage: MAX_DOCS_PER_PAGE, }); diff --git a/x-pack/plugins/cases/server/services/cases/index.ts b/x-pack/plugins/cases/server/services/cases/index.ts index bc694a44d93eb..c70d987bd3a77 100644 --- a/x-pack/plugins/cases/server/services/cases/index.ts +++ b/x-pack/plugins/cases/server/services/cases/index.ts @@ -41,7 +41,6 @@ import type { CaseSavedObject, SavedObjectFindOptionsKueryNode } from '../../com import { defaultSortField, flattenCaseSavedObject } from '../../common/utils'; import { DEFAULT_PAGE, DEFAULT_PER_PAGE } from '../../routes/api'; import { combineFilters } from '../../client/utils'; -import { includeFieldsRequiredForAuthentication } from '../../authorization/utils'; import { transformSavedObjectToExternalModel, transformAttributesToESModel, @@ -188,7 +187,6 @@ export class CasesService { GetCaseIdsByAlertIdAggs >({ type: CASE_COMMENT_SAVED_OBJECT, - fields: includeFieldsRequiredForAuthentication(), page: 1, perPage: 1, sortField: defaultSortField, diff --git a/x-pack/plugins/cases/server/services/user_actions/index.ts b/x-pack/plugins/cases/server/services/user_actions/index.ts index 252e3985a7483..f0bddfe1758be 100644 --- a/x-pack/plugins/cases/server/services/user_actions/index.ts +++ b/x-pack/plugins/cases/server/services/user_actions/index.ts @@ -600,12 +600,6 @@ export class CaseUserActionService { hasReference: caseIds.map((id) => ({ id, type: CASE_SAVED_OBJECT })), sortField: 'created_at', sortOrder: 'asc', - /** - * We only care about the ids so to reduce the data returned we should limit the fields in the response. Core - * doesn't support retrieving no fields (id would always be returned anyway) so to limit it we'll only request - * the owner even though we don't need it. - */ - fields: ['owner'], perPage: MAX_DOCS_PER_PAGE, }); diff --git a/x-pack/plugins/cloud_security_posture/server/fleet_integration/fleet_integration.ts b/x-pack/plugins/cloud_security_posture/server/fleet_integration/fleet_integration.ts index 0e9cf02ad0663..59723c6507606 100644 --- a/x-pack/plugins/cloud_security_posture/server/fleet_integration/fleet_integration.ts +++ b/x-pack/plugins/cloud_security_posture/server/fleet_integration/fleet_integration.ts @@ -23,7 +23,6 @@ export const onPackagePolicyPostCreateCallback = async ( async function addDataViewToAllSpaces(savedObjectsClient: SavedObjectsClientContract) { const cspmDataViews = await savedObjectsClient.find({ type: 'index-pattern', - fields: ['title'], search: CLOUD_SECURITY_POSTURE_PACKAGE_NAME + '*', searchFields: ['title'], perPage: 100, diff --git a/x-pack/plugins/fleet/server/services/agent_policy.ts b/x-pack/plugins/fleet/server/services/agent_policy.ts index 2720701f0b29c..c47827292f67b 100644 --- a/x-pack/plugins/fleet/server/services/agent_policy.ts +++ b/x-pack/plugins/fleet/server/services/agent_policy.ts @@ -529,7 +529,6 @@ class AgentPolicyService { const agentPolicies = ( await soClient.find({ type: SAVED_OBJECT_TYPE, - fields: ['revision', 'data_output_id', 'monitoring_output_id'], searchFields: ['data_output_id', 'monitoring_output_id'], search: escapeSearchQueryPhrase(outputId), perPage: SO_SEARCH_LIMIT, @@ -569,7 +568,6 @@ class AgentPolicyService { const agentPolicies = ( await soClient.find({ type: SAVED_OBJECT_TYPE, - fields: ['revision', 'fleet_server_host_id'], searchFields: ['fleet_server_host_id'], search: escapeSearchQueryPhrase(fleetServerHostId), perPage: SO_SEARCH_LIMIT, @@ -601,7 +599,6 @@ class AgentPolicyService { ): Promise> { const currentPolicies = await soClient.find({ type: SAVED_OBJECT_TYPE, - fields: ['revision', 'data_output_id', 'monitoring_output_id'], searchFields: ['data_output_id', 'monitoring_output_id'], search: escapeSearchQueryPhrase(outputId), perPage: SO_SEARCH_LIMIT, @@ -632,7 +629,6 @@ class AgentPolicyService { ): Promise> { const currentPolicies = await soClient.find({ type: SAVED_OBJECT_TYPE, - fields: ['revision'], perPage: SO_SEARCH_LIMIT, }); const bumpedPolicies = currentPolicies.saved_objects.map((policy) => { @@ -946,7 +942,6 @@ class AgentPolicyService { const agentPolicies = ( await soClient.find({ type: SAVED_OBJECT_TYPE, - fields: ['revision', 'download_source_id'], searchFields: ['download_source_id'], search: escapeSearchQueryPhrase(downloadSourceId), perPage: SO_SEARCH_LIMIT, @@ -981,7 +976,6 @@ class AgentPolicyService { ): Promise> { const currentPolicies = await soClient.find({ type: SAVED_OBJECT_TYPE, - fields: ['revision', 'download_source_id'], searchFields: ['download_source_id'], search: escapeSearchQueryPhrase(downloadSourceId), perPage: SO_SEARCH_LIMIT, @@ -1013,7 +1007,6 @@ class AgentPolicyService { ): Promise> { const currentPolicies = await soClient.find({ type: SAVED_OBJECT_TYPE, - fields: ['revision', 'fleet_server_host_id'], searchFields: ['fleet_server_host_id'], search: escapeSearchQueryPhrase(fleetServerHostId), perPage: SO_SEARCH_LIMIT, @@ -1045,7 +1038,6 @@ class AgentPolicyService { page: 1, perPage: SO_SEARCH_LIMIT, filter: `${SAVED_OBJECT_TYPE}.attributes.inactivity_timeout > 0`, - fields: [`inactivity_timeout`], }); const groupedResults = groupBy(findRes.saved_objects, (so) => so.attributes.inactivity_timeout); diff --git a/x-pack/plugins/fleet/server/services/epm/packages/cleanup.ts b/x-pack/plugins/fleet/server/services/epm/packages/cleanup.ts index ab287aa0b94ac..70f5b26245e0f 100644 --- a/x-pack/plugins/fleet/server/services/epm/packages/cleanup.ts +++ b/x-pack/plugins/fleet/server/services/epm/packages/cleanup.ts @@ -44,7 +44,6 @@ export async function removeOldAssets(options: { const packageAssetRefsRes = await soClient.find({ type: PACKAGES_SAVED_OBJECT_TYPE, filter: `${PACKAGES_SAVED_OBJECT_TYPE}.attributes.name:${pkgName}`, - fields: [`${PACKAGES_SAVED_OBJECT_TYPE}.package_assets`], }); const packageAssetRefs = ( @@ -81,7 +80,6 @@ async function removeAssetsFromVersion( type: ASSETS_SAVED_OBJECT_TYPE, filter: `${ASSETS_SAVED_OBJECT_TYPE}.attributes.package_name:${pkgName} AND ${ASSETS_SAVED_OBJECT_TYPE}.attributes.package_version:${oldVersion}`, perPage: 1000, - fields: ['id'], }); for await (const assets of finder.find()) { diff --git a/x-pack/plugins/fleet/server/services/package_policy.ts b/x-pack/plugins/fleet/server/services/package_policy.ts index fe044f012dd11..52912ce33a55c 100644 --- a/x-pack/plugins/fleet/server/services/package_policy.ts +++ b/x-pack/plugins/fleet/server/services/package_policy.ts @@ -488,7 +488,6 @@ class PackagePolicyClientImpl implements PackagePolicyClient { sortOrder, page, perPage, - fields: [], filter: kuery ? normalizeKuery(SAVED_OBJECT_TYPE, kuery) : undefined, }); diff --git a/x-pack/plugins/infra/server/services/log_views/log_views_client.ts b/x-pack/plugins/infra/server/services/log_views/log_views_client.ts index 3f832c6770717..9e6dcd48b1a8e 100644 --- a/x-pack/plugins/infra/server/services/log_views/log_views_client.ts +++ b/x-pack/plugins/infra/server/services/log_views/log_views_client.ts @@ -174,7 +174,6 @@ export class LogViewsClient implements ILogViewsClient { sortField: 'updated_at', sortOrder: 'desc', perPage: 1, - fields: [], }); const [newestSavedLogView] = response.saved_objects; diff --git a/x-pack/plugins/lens/public/persistence/saved_objects_utils/find_object_by_title.ts b/x-pack/plugins/lens/public/persistence/saved_objects_utils/find_object_by_title.ts index 1fda36f4ada36..4f81b5b6fadf0 100644 --- a/x-pack/plugins/lens/public/persistence/saved_objects_utils/find_object_by_title.ts +++ b/x-pack/plugins/lens/public/persistence/saved_objects_utils/find_object_by_title.ts @@ -24,7 +24,6 @@ export async function findObjectByTitle( perPage: 10, search: `"${title}"`, searchFields: ['title'], - fields: ['title'], }); return response.savedObjects.find( (obj) => obj.get('title').toLowerCase() === title.toLowerCase() diff --git a/x-pack/plugins/maps/public/routes/list_page/load_list_and_render.tsx b/x-pack/plugins/maps/public/routes/list_page/load_list_and_render.tsx index 62403cd4db327..1f87112d43b61 100644 --- a/x-pack/plugins/maps/public/routes/list_page/load_list_and_render.tsx +++ b/x-pack/plugins/maps/public/routes/list_page/load_list_and_render.tsx @@ -41,7 +41,6 @@ export class LoadListAndRender extends Component { const results = await getSavedObjectsClient().find({ type: MAP_SAVED_OBJECT_TYPE, perPage: 1, - fields: ['title'], }); if (this._isMounted) { this.setState({ mapsLoaded: true, hasSavedMaps: !!results.savedObjects.length }); diff --git a/x-pack/plugins/maps/public/routes/list_page/maps_list_view.tsx b/x-pack/plugins/maps/public/routes/list_page/maps_list_view.tsx index 3dab6db00885d..e482b305b7050 100644 --- a/x-pack/plugins/maps/public/routes/list_page/maps_list_view.tsx +++ b/x-pack/plugins/maps/public/routes/list_page/maps_list_view.tsx @@ -81,7 +81,6 @@ async function findMaps( page: 1, searchFields: ['title^3', 'description'], defaultSearchOperator: 'AND', - fields: ['description', 'title'], hasReference: references, hasNoReference: referencesToExclude, }); diff --git a/x-pack/plugins/ml/public/application/jobs/jobs_list/components/edit_job_flyout/edit_utils.js b/x-pack/plugins/ml/public/application/jobs/jobs_list/components/edit_job_flyout/edit_utils.js index 3a94cf6c673f3..2ae744e710a82 100644 --- a/x-pack/plugins/ml/public/application/jobs/jobs_list/components/edit_job_flyout/edit_utils.js +++ b/x-pack/plugins/ml/public/application/jobs/jobs_list/components/edit_job_flyout/edit_utils.js @@ -79,7 +79,6 @@ export function loadSavedDashboards(maxNumber) { savedObjectsClient .find({ type: 'dashboard', - fields: ['title'], perPage: maxNumber, }) .then((resp) => { diff --git a/x-pack/plugins/saved_objects_tagging/server/services/assignments/assignment_service.test.ts b/x-pack/plugins/saved_objects_tagging/server/services/assignments/assignment_service.test.ts index ec1a6575d2e3d..08c82c5492ea3 100644 --- a/x-pack/plugins/saved_objects_tagging/server/services/assignments/assignment_service.test.ts +++ b/x-pack/plugins/saved_objects_tagging/server/services/assignments/assignment_service.test.ts @@ -101,8 +101,8 @@ describe('AssignmentService', () => { expect(savedObjectClient.bulkGet).toHaveBeenCalledTimes(1); expect(savedObjectClient.bulkGet).toHaveBeenCalledWith([ - { type: 'dashboard', id: 'dash-1', fields: [] }, - { type: 'map', id: 'map-1', fields: [] }, + { type: 'dashboard', id: 'dash-1' }, + { type: 'map', id: 'map-1' }, ]); }); @@ -354,8 +354,8 @@ describe('AssignmentService', () => { expect(getUpdatableSavedObjectTypesMock).not.toHaveBeenCalled(); expect(savedObjectClient.bulkGet).toHaveBeenCalledTimes(1); expect(savedObjectClient.bulkGet).toHaveBeenCalledWith([ - { type: 'dashboard', id: 'dash-1', fields: [] }, - { type: 'map', id: 'map-1', fields: [] }, + { type: 'dashboard', id: 'dash-1' }, + { type: 'map', id: 'map-1' }, ]); }); }); diff --git a/x-pack/plugins/saved_objects_tagging/server/services/assignments/assignment_service.ts b/x-pack/plugins/saved_objects_tagging/server/services/assignments/assignment_service.ts index 9aeef11d606e8..3fbc2bda71185 100644 --- a/x-pack/plugins/saved_objects_tagging/server/services/assignments/assignment_service.ts +++ b/x-pack/plugins/saved_objects_tagging/server/services/assignments/assignment_service.ts @@ -161,6 +161,4 @@ export class AssignmentService { const referenceToBulkGet = ({ type, id }: ObjectReference): SavedObjectsBulkGetObject => ({ type, id, - // we only need `type`, `id` and `references` that are included by default. - fields: [], }); diff --git a/x-pack/plugins/security_solution/cypress/tasks/api_calls/risk_scores/saved_objects.ts b/x-pack/plugins/security_solution/cypress/tasks/api_calls/risk_scores/saved_objects.ts index 3e96bbcd2cb2c..1a28153f345cd 100644 --- a/x-pack/plugins/security_solution/cypress/tasks/api_calls/risk_scores/saved_objects.ts +++ b/x-pack/plugins/security_solution/cypress/tasks/api_calls/risk_scores/saved_objects.ts @@ -29,13 +29,13 @@ export const findSavedObjects = (riskScoreEntity: RiskScoreEntity, spaceId = 'de return cy .request({ method: 'get', - url: `${SAVED_OBJECTS_URL}/_find?fields=id&type=tag&sort_field=updated_at&search=${search}&search_fields=name`, + url: `${SAVED_OBJECTS_URL}/_find?type=tag&sort_field=updated_at&search=${search}&search_fields=name`, headers: { 'kbn-xsrf': 'cypress-creds-via-config' }, }) .then((res) => cy.request({ method: 'get', - url: `${SAVED_OBJECTS_URL}/_find?fields=id&type=index-pattern&type=tag&type=visualization&type=dashboard&type=lens&sort_field=updated_at&has_reference=${getReference( + url: `${SAVED_OBJECTS_URL}/_find?type=index-pattern&type=tag&type=visualization&type=dashboard&type=lens&sort_field=updated_at&has_reference=${getReference( res.body.saved_objects[0].id )}`, headers: { 'kbn-xsrf': 'cypress-creds-via-config' }, diff --git a/x-pack/plugins/security_solution/public/common/hooks/use_dashboard_button_href.ts b/x-pack/plugins/security_solution/public/common/hooks/use_dashboard_button_href.ts index e5e3d048a7b23..2742a4ec0fba5 100644 --- a/x-pack/plugins/security_solution/public/common/hooks/use_dashboard_button_href.ts +++ b/x-pack/plugins/security_solution/public/common/hooks/use_dashboard_button_href.ts @@ -11,7 +11,6 @@ import { useKibana } from '../lib/kibana'; export const dashboardRequestBody = (title: string) => ({ type: 'dashboard', search: `"${title}"`, - fields: ['title'], }); export const useDashboardButtonHref = ({ diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/prebuilt_rules/api/get_prebuilt_rules_and_timelines_status/route.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/prebuilt_rules/api/get_prebuilt_rules_and_timelines_status/route.ts index 40b3078fe06eb..10d6275e587f5 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/prebuilt_rules/api/get_prebuilt_rules_and_timelines_status/route.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/prebuilt_rules/api/get_prebuilt_rules_and_timelines_status/route.ts @@ -58,7 +58,6 @@ export const getPrebuiltRulesAndTimelinesStatusRoute = ( sortField: 'enabled', sortOrder: 'desc', filter: 'alert.attributes.params.immutable: false', - fields: undefined, }); const installedPrebuiltRules = rulesToMap( diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_actions_legacy/logic/notifications/legacy_find_notifications.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_actions_legacy/logic/notifications/legacy_find_notifications.ts index 0f981e6c6a005..8bfcae219197c 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_actions_legacy/logic/notifications/legacy_find_notifications.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_actions_legacy/logic/notifications/legacy_find_notifications.ts @@ -28,14 +28,12 @@ export const legacyFindNotifications = async ({ rulesClient, perPage, page, - fields, filter, sortField, sortOrder, }: LegacyFindNotificationParams): Promise> => rulesClient.find({ options: { - fields, page, perPage, filter: legacyGetFilter(filter), diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_actions_legacy/logic/notifications/legacy_types.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_actions_legacy/logic/notifications/legacy_types.ts index 2aea76d8c51e1..01bdd5d7808a9 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_actions_legacy/logic/notifications/legacy_types.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_actions_legacy/logic/notifications/legacy_types.ts @@ -42,7 +42,6 @@ export interface LegacyFindNotificationParams { page?: number; sortField?: string; filter?: string; - fields?: string[]; sortOrder?: 'asc' | 'desc'; } diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/api/rules/bulk_actions/route.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/api/rules/bulk_actions/route.ts index 8779c19e71988..630c3c680a8fd 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/api/rules/bulk_actions/route.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/api/rules/bulk_actions/route.ts @@ -219,7 +219,6 @@ const fetchRulesByQueryOrIds = async ({ page: undefined, sortField: undefined, sortOrder: undefined, - fields: undefined, }); if (total > MAX_RULES_TO_PROCESS_TOTAL) { diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/api/rules/filters/route.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/api/rules/filters/route.ts index d7d974aa8d9ef..1a92979a5fdc1 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/api/rules/filters/route.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/api/rules/filters/route.ts @@ -25,7 +25,6 @@ const DEFAULT_FIND_RULES_COUNT_PARAMS = { page: 1, sortField: undefined, sortOrder: undefined, - fields: undefined, }; async function fetchRulesCount(rulesClient: RulesClient): Promise { diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/api/rules/find_rules/route.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/api/rules/find_rules/route.ts index 8654a9dafd245..9a02e0d3b6652 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/api/rules/find_rules/route.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/api/rules/find_rules/route.ts @@ -58,7 +58,6 @@ export const findRulesRoute = (router: SecuritySolutionPluginRouter, logger: Log sortField: query.sort_field, sortOrder: query.sort_order, filter: query.filter, - fields: query.fields, }); const ruleIds = rules.data.map((rule) => rule.id); diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/logic/crud/read_rules.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/logic/crud/read_rules.ts index 76969b31aab66..e4366f0efd2fc 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/logic/crud/read_rules.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/logic/crud/read_rules.ts @@ -64,7 +64,6 @@ export const readRules = async ({ rulesClient, filter: `alert.attributes.params.ruleId: "${ruleId}"`, page: 1, - fields: undefined, perPage: undefined, sortField: undefined, sortOrder: undefined, diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/logic/exceptions/validate_rule_default_exception_list.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/logic/exceptions/validate_rule_default_exception_list.ts index 099a15ceeeac3..3a3a7db970d15 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/logic/exceptions/validate_rule_default_exception_list.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/logic/exceptions/validate_rule_default_exception_list.ts @@ -55,7 +55,6 @@ export const validateRuleDefaultExceptionList = async ({ rulesClient, filter: `alert.attributes.params.exceptionsList.list_id: "${newDefaultExceptionsList.list_id}"`, page: 1, - fields: undefined, perPage: undefined, sortField: undefined, sortOrder: undefined, diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/logic/export/get_export_by_object_ids.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/logic/export/get_export_by_object_ids.ts index 5221c4f26761b..46a13e65a796f 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/logic/export/get_export_by_object_ids.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/logic/export/get_export_by_object_ids.ts @@ -115,7 +115,6 @@ export const getRulesFromObjects = async ( rulesClient, filter, page: 1, - fields: undefined, perPage: 10000, sortField: undefined, sortOrder: undefined, diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/logic/search/find_rules.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/logic/search/find_rules.ts index d72e3e6900be3..5efae94ffef13 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/logic/search/find_rules.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/logic/search/find_rules.ts @@ -9,7 +9,6 @@ import type { FindResult, RulesClient } from '@kbn/alerting-plugin/server'; import type { FindRulesSortFieldOrUndefined } from '../../../../../../common/detection_engine/rule_management'; import type { - FieldsOrUndefined, PageOrUndefined, PerPageOrUndefined, QueryFilterOrUndefined, @@ -23,7 +22,6 @@ import { transformSortField } from './transform_sort_field'; export interface FindRuleOptions { rulesClient: RulesClient; filter: QueryFilterOrUndefined; - fields: FieldsOrUndefined; sortField: FindRulesSortFieldOrUndefined; sortOrder: SortOrderOrUndefined; page: PageOrUndefined; @@ -34,14 +32,12 @@ export const findRules = ({ rulesClient, perPage, page, - fields, filter, sortField, sortOrder, }: FindRuleOptions): Promise> => { return rulesClient.find({ options: { - fields, page, perPage, filter: enrichFilterWithRuleTypeMapping(filter), diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/logic/search/get_existing_prepackaged_rules.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/logic/search/get_existing_prepackaged_rules.ts index 469de8544a13a..7619e99c8882b 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/logic/search/get_existing_prepackaged_rules.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/logic/search/get_existing_prepackaged_rules.ts @@ -36,7 +36,6 @@ export const getRulesCount = async ({ page: 1, sortField: 'createdAt', sortOrder: 'desc', - fields: undefined, }); return total; }); @@ -58,7 +57,6 @@ export const getRules = async ({ page: 1, sortField: 'createdAt', sortOrder: 'desc', - fields: undefined, }); return rules.data; diff --git a/x-pack/plugins/synthetics/server/routes/common.ts b/x-pack/plugins/synthetics/server/routes/common.ts index c536884e25c4e..a57c1e59988ba 100644 --- a/x-pack/plugins/synthetics/server/routes/common.ts +++ b/x-pack/plugins/synthetics/server/routes/common.ts @@ -26,7 +26,6 @@ export const QuerySchema = schema.object({ projects: schema.maybe(schema.oneOf([schema.string(), schema.arrayOf(schema.string())])), schedules: schema.maybe(schema.oneOf([schema.string(), schema.arrayOf(schema.string())])), status: schema.maybe(schema.oneOf([schema.string(), schema.arrayOf(schema.string())])), - fields: schema.maybe(schema.arrayOf(schema.string())), searchAfter: schema.maybe(schema.arrayOf(schema.string())), }); @@ -69,7 +68,6 @@ export const getMonitors = async ( monitorTypes, locations, filter = '', - fields, searchAfter, projects, schedules, @@ -94,7 +92,6 @@ export const getMonitors = async ( searchFields: SEARCH_FIELDS, search: query ? `${query}*` : undefined, filter: filterStr, - fields, searchAfter, }); }; diff --git a/x-pack/plugins/synthetics/server/routes/overview_status/overview_status.ts b/x-pack/plugins/synthetics/server/routes/overview_status/overview_status.ts index 11ae9ff793e21..5c16fa77bebc2 100644 --- a/x-pack/plugins/synthetics/server/routes/overview_status/overview_status.ts +++ b/x-pack/plugins/synthetics/server/routes/overview_status/overview_status.ts @@ -7,7 +7,6 @@ import { intersection } from 'lodash'; import datemath, { Unit } from '@kbn/datemath'; import moment from 'moment'; -import { ConfigKey } from '../../../common/runtime_types'; import { getAllMonitors, processMonitors, @@ -56,14 +55,6 @@ export async function getStatus(context: RouteContext, params: OverviewStatusQue soClient: savedObjectsClient, search: query ? `${query}*` : undefined, filter: filtersStr, - fields: [ - ConfigKey.ENABLED, - ConfigKey.LOCATIONS, - ConfigKey.MONITOR_QUERY_ID, - ConfigKey.CONFIG_ID, - ConfigKey.SCHEDULE, - ConfigKey.MONITOR_SOURCE_TYPE, - ], }); const { diff --git a/x-pack/plugins/synthetics/server/saved_objects/synthetics_monitor/get_all_monitors.ts b/x-pack/plugins/synthetics/server/saved_objects/synthetics_monitor/get_all_monitors.ts index e0f404ebef875..6223ec4499c06 100644 --- a/x-pack/plugins/synthetics/server/saved_objects/synthetics_monitor/get_all_monitors.ts +++ b/x-pack/plugins/synthetics/server/saved_objects/synthetics_monitor/get_all_monitors.ts @@ -27,7 +27,6 @@ import { SyntheticsMonitorClient } from '../../synthetics_service/synthetics_mon export const getAllMonitors = async ({ soClient, search, - fields, filter, sortField = 'name.keyword', sortOrder = 'asc', @@ -36,14 +35,13 @@ export const getAllMonitors = async ({ soClient: SavedObjectsClientContract; search?: string; filter?: string; -} & Pick) => { +} & Pick) => { const finder = soClient.createPointInTimeFinder({ type: syntheticsMonitorType, perPage: 1000, search, sortField, sortOrder, - fields, filter, searchFields, }); diff --git a/x-pack/plugins/watcher/server/routes/api/indices/register_get_index_patterns_route.ts b/x-pack/plugins/watcher/server/routes/api/indices/register_get_index_patterns_route.ts index 0c49e5ea894dd..4df0849501a16 100644 --- a/x-pack/plugins/watcher/server/routes/api/indices/register_get_index_patterns_route.ts +++ b/x-pack/plugins/watcher/server/routes/api/indices/register_get_index_patterns_route.ts @@ -23,7 +23,6 @@ export function registerGetIndexPatternsRoute({ const { savedObjects } = await core; const finder = savedObjects.client.createPointInTimeFinder({ type: 'index-pattern', - fields: ['title'], perPage: 1000, }); diff --git a/x-pack/test/cases_api_integration/security_and_spaces/tests/common/cases/find_cases.ts b/x-pack/test/cases_api_integration/security_and_spaces/tests/common/cases/find_cases.ts index 712ec4722d500..d3ba6d09bed6c 100644 --- a/x-pack/test/cases_api_integration/security_and_spaces/tests/common/cases/find_cases.ts +++ b/x-pack/test/cases_api_integration/security_and_spaces/tests/common/cases/find_cases.ts @@ -238,50 +238,6 @@ export default ({ getService }: FtrProviderContext): void => { expect(cases.count_in_progress_cases).to.eql(1); }); - it('returns the correct fields', async () => { - const postedCase = await createCase(supertest, postCaseReq); - // all fields that contain the UserRt definition must be included here (aka created_by, closed_by, and updated_by) - // see https://github.com/elastic/kibana/issues/139503 - const queryFields: Array> = [ - ['title', 'created_by', 'closed_by', 'updated_by'], - ['title', 'description', 'created_by', 'closed_by', 'updated_by'], - ]; - - for (const fields of queryFields) { - const cases = await findCases({ supertest, query: { fields } }); - const fieldsAsArray = Array.isArray(fields) ? fields : [fields]; - - const expectedValues = fieldsAsArray.reduce( - (theCase, field) => ({ - ...theCase, - [field]: postedCase[field], - }), - {} - ); - - expect(cases).to.eql({ - ...findCasesResp, - total: 1, - cases: [ - { - id: postedCase.id, - version: postedCase.version, - external_service: postedCase.external_service, - owner: postedCase.owner, - connector: postedCase.connector, - severity: postedCase.severity, - status: postedCase.status, - comments: [], - totalAlerts: 0, - totalComment: 0, - ...expectedValues, - }, - ], - count_open_cases: 1, - }); - } - }); - it('sorts by title', async () => { const case3 = await createCase(supertest, { ...postCaseReq, title: 'c' }); const case2 = await createCase(supertest, { ...postCaseReq, title: 'b' }); diff --git a/x-pack/test/encrypted_saved_objects_api_integration/plugins/api_consumer_plugin/server/hidden_saved_object_routes.ts b/x-pack/test/encrypted_saved_objects_api_integration/plugins/api_consumer_plugin/server/hidden_saved_object_routes.ts index 9f1c0dee955fa..489ba17b3bdea 100644 --- a/x-pack/test/encrypted_saved_objects_api_integration/plugins/api_consumer_plugin/server/hidden_saved_object_routes.ts +++ b/x-pack/test/encrypted_saved_objects_api_integration/plugins/api_consumer_plugin/server/hidden_saved_object_routes.ts @@ -102,7 +102,6 @@ export function registerHiddenSORoutes( id: schema.string(), }) ), - fields: schema.maybe(schema.oneOf([schema.string(), schema.arrayOf(schema.string())])), filter: schema.maybe(schema.string()), }), }, @@ -123,7 +122,6 @@ export function registerHiddenSORoutes( typeof query.search_fields === 'string' ? [query.search_fields] : query.search_fields, sortField: query.sort_field, hasReference: query.has_reference, - fields: typeof query.fields === 'string' ? [query.fields] : query.fields, filter: query.filter, }), }); diff --git a/x-pack/test/saved_object_api_integration/common/suites/find.ts b/x-pack/test/saved_object_api_integration/common/suites/find.ts index 202fc02dbfc1c..0951cae8e7a79 100644 --- a/x-pack/test/saved_object_api_integration/common/suites/find.ts +++ b/x-pack/test/saved_object_api_integration/common/suites/find.ts @@ -99,14 +99,14 @@ export const getTestCases = ( return { singleNamespaceType: { title: buildTitle('find single-namespace type'), - query: `type=isolatedtype&fields=title${namespacesQueryParam}`, + query: `type=isolatedtype${namespacesQueryParam}`, successResult: { savedObjects: getExpectedSavedObjects((t) => t.type === 'isolatedtype'), }, } as FindTestCase, multiNamespaceType: { title: buildTitle('find multi-namespace type'), - query: `type=sharedtype&fields=title${namespacesQueryParam}`, + query: `type=sharedtype${namespacesQueryParam}`, successResult: { // expected depends on which spaces the user is authorized against... savedObjects: getExpectedSavedObjects((t) => t.type === 'sharedtype'), @@ -114,19 +114,19 @@ export const getTestCases = ( } as FindTestCase, multiNamespaceIsolatedType: { title: buildTitle('find multi-namespace isolated type'), - query: `type=sharecapabletype&fields=title${namespacesQueryParam}`, + query: `type=sharecapabletype${namespacesQueryParam}`, successResult: { savedObjects: getExpectedSavedObjects((t) => t.type === 'sharecapabletype'), }, } as FindTestCase, namespaceAgnosticType: { title: buildTitle('find namespace-agnostic type'), - query: `type=globaltype&fields=title${namespacesQueryParam}`, + query: `type=globaltype${namespacesQueryParam}`, successResult: { savedObjects: SAVED_OBJECT_TEST_CASES.NAMESPACE_AGNOSTIC }, } as FindTestCase, hiddenType: { title: buildTitle('find hidden type'), - query: `type=hiddentype&fields=name${namespacesQueryParam}`, + query: `type=hiddentype${namespacesQueryParam}`, } as FindTestCase, unknownType: { title: buildTitle('find unknown type'), @@ -162,7 +162,7 @@ export const getTestCases = ( } as FindTestCase, filterWithHiddenType: { title: buildTitle('filter with hidden type'), - query: `type=hiddentype&fields=name&filter=hiddentype.attributes.title:'hello'${namespacesQueryParam}`, + query: `type=hiddentype&filter=hiddentype.attributes.title:'hello'${namespacesQueryParam}`, } as FindTestCase, filterWithUnknownType: { title: buildTitle('filter with unknown type'),