Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Saved objects extensions refactor merge #142878

Merged
merged 67 commits into from
Nov 18, 2022
Merged
Show file tree
Hide file tree
Changes from 52 commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
e9f14d5
Adds extensions and factories for these
TinaHeiligers Oct 4, 2022
9386be3
Adds SO repo extensions, continues wrapper removal
jeramysoucy Oct 10, 2022
2f46222
Adds ROC extension implementations, complete removal of SOC wrapper r…
jeramysoucy Oct 11, 2022
06ca3e6
Removed unnecessary wrapper tests.
jeramysoucy Oct 12, 2022
72138ee
Removes wrapper references from secure spaces client. Moves extension…
jeramysoucy Oct 12, 2022
1bcbbdc
Fix to setup spaces client - now references security extension
jeramysoucy Oct 12, 2022
1f277e6
Resolves SO extension mock references.
jeramysoucy Oct 12, 2022
4fff618
Fixes several jest tests to include expected calling parameters with …
jeramysoucy Oct 12, 2022
c7c4d55
Fixes several unit tests, cleans up unused code and comments.
jeramysoucy Oct 13, 2022
a8eefce
Merges changes in api integration tests
jeramysoucy Oct 13, 2022
9935fef
Fixes accidental overwrite of esArchiver replacement.
jeramysoucy Oct 13, 2022
3398a57
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Oct 13, 2022
da05c66
Merge branch 'main' into refactor-update_object_spaces
jeramysoucy Oct 13, 2022
dfaf90b
Fixes repo called to find_legacy_url_aliases and find_shared_origin_o…
jeramysoucy Oct 14, 2022
e3b3fc1
Reordered testDataLoader calls to eliminate error when deleting objects.
jeramysoucy Oct 14, 2022
0eeb94b
Merge branch 'main' into refactor-update_object_spaces
jeramysoucy Oct 17, 2022
fce0433
Merge branch 'main' into refactor-update_object_spaces
jeramysoucy Oct 20, 2022
c3484af
Merge branch 'main' into refactor-update_object_spaces
jeramysoucy Oct 20, 2022
896813b
Manually adds definitions missed by merge from main.
jeramysoucy Oct 20, 2022
d831567
Additional manual merge of 'created at'
jeramysoucy Oct 20, 2022
ca77b0a
Merges bulk delete with SO extensions. Updates extension test suites …
jeramysoucy Oct 25, 2022
087c3a5
Adds test case for partially authorized in find
jeramysoucy Oct 26, 2022
dbb01f4
Adds test_helpers folder for commom test utilites.
jeramysoucy Oct 27, 2022
62c0ec1
Matches authorization behavior of bulk delete to existing delete. Res…
jeramysoucy Oct 28, 2022
7f8b670
Fixes bulk delete unit test based on changes to authz behavior.
jeramysoucy Oct 28, 2022
247de7b
Merge branch 'main' into merge-saved-objects-extensions
jeramysoucy Oct 28, 2022
2d01e30
Merge branch 'main' into refactor-update_object_spaces
jeramysoucy Oct 28, 2022
3192709
Resolves issues with fleet tests when bulkDelete is called with an em…
jeramysoucy Oct 31, 2022
e8c4840
Merge branch 'refactor-update_object_spaces' of https://github.com/Ti…
jeramysoucy Oct 31, 2022
1307b79
Merge branch 'main' into refactor-update_object_spaces
jeramysoucy Oct 31, 2022
2c45408
Merge branch 'main' into refactor-update_object_spaces
jeramysoucy Oct 31, 2022
0cbd92a
Fixes local types check issue
jeramysoucy Oct 31, 2022
b79b1b5
Adds missing TS docs - round 1
jeramysoucy Nov 2, 2022
33cb8e4
Adds missing TSDoc comments - round 2. Removes redundant ISavedObject…
jeramysoucy Nov 3, 2022
6a586e3
Removes 'import type' in so package domain. Updates mocks for find sh…
jeramysoucy Nov 3, 2022
7472293
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Nov 3, 2022
7f8214f
Removes 'import type' in so package domain. Updates mocks for find sh…
jeramysoucy Nov 3, 2022
507250f
Merge branch 'refactor-update_object_spaces' of https://github.com/Ti…
jeramysoucy Nov 3, 2022
d604293
Reverting removal of import type
jeramysoucy Nov 3, 2022
9ed2d02
Fixes lost update to point-in-time finder mock.
jeramysoucy Nov 3, 2022
bd0695b
import type housekeeping
jeramysoucy Nov 4, 2022
e72c6ad
Adds exports for extention ID's from core/server to replace static in…
jeramysoucy Nov 4, 2022
bca7189
Renames add_Extension functions to set_Extension
jeramysoucy Nov 4, 2022
8627b0f
Adds base extension factory and undefined consistency to extension fa…
jeramysoucy Nov 4, 2022
1df2e31
Adds enxtensions folder. Adds duplicate local extensions mock. Genera…
jeramysoucy Nov 4, 2022
eb39e38
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine Nov 4, 2022
f7dfda0
Fixes factory definitions.
jeramysoucy Nov 4, 2022
5edf4ed
Merge branch 'refactor-update_object_spaces' of https://github.com/Ti…
jeramysoucy Nov 4, 2022
f63f535
Merge branch 'main' into refactor-update_object_spaces
jeramysoucy Nov 4, 2022
7ca4adc
Merge branch 'main' into refactor-update_object_spaces
jeramysoucy Nov 7, 2022
1af7416
Changes imports for extension ID's to exports from packages. Removes …
jeramysoucy Nov 7, 2022
810878d
Merge branch 'refactor-update_object_spaces' of https://github.com/Ti…
jeramysoucy Nov 7, 2022
bd1a1a5
Adds unit tests for extension set methods of saved objects service.
jeramysoucy Nov 14, 2022
f146f2a
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine Nov 14, 2022
7e4d8c2
Updates checkConflicts comment, removes unused imports in service uni…
jeramysoucy Nov 14, 2022
4b083a1
Merge branch 'refactor-update_object_spaces' of https://github.com/Ti…
jeramysoucy Nov 14, 2022
6647ac9
Merge branch 'main' into refactor-update_object_spaces
jeramysoucy Nov 14, 2022
243bfaa
Merge branch 'main' into refactor-update_object_spaces
jeramysoucy Nov 15, 2022
3229e46
Refactor getAvailableSpaces in bulkGet to remove redundant null check.
jeramysoucy Nov 15, 2022
db77463
Merge branch 'refactor-update_object_spaces' of https://github.com/Ti…
jeramysoucy Nov 15, 2022
7f41316
Adds public types to core entry point exports.
jeramysoucy Nov 15, 2022
31b8532
Update packages/core/saved-objects/core-saved-objects-api-server/src/…
jeramysoucy Nov 17, 2022
f05c8b6
Refactors getExtensions of the scoped client provider, and CheckAutho…
jeramysoucy Nov 17, 2022
7678f71
Merge branch 'main' into refactor-update_object_spaces
jeramysoucy Nov 17, 2022
c9b25b0
Fixes unit tests for check auth expected actions.
jeramysoucy Nov 17, 2022
ae02c50
Fixes collect multi-namespace refs unit tests.
jeramysoucy Nov 17, 2022
9909253
Merge branch 'main' into refactor-update_object_spaces
jeramysoucy Nov 17, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,9 @@ export function createPluginSetupContext<TPlugin, TPluginDependencies>(
},
savedObjects: {
setClientFactoryProvider: deps.savedObjects.setClientFactoryProvider,
addClientWrapper: deps.savedObjects.addClientWrapper,
setEncryptionExtension: deps.savedObjects.setEncryptionExtension,
setSecurityExtension: deps.savedObjects.setSecurityExtension,
setSpacesExtension: deps.savedObjects.setSpacesExtension,
registerType: deps.savedObjects.registerType,
getKibanaIndex: deps.savedObjects.getKibanaIndex,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@

import { SimpleSavedObject } from '../simple_saved_object';

/** @public */
/**
* Batch response for simple saved objects
*
* @public
*/
export interface SavedObjectsBatchResponse<T = unknown> {
/** Array of simple saved objects */
savedObjects: Array<SimpleSavedObject<T>>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,23 @@
import type { SavedObjectsCreateOptions } from './create';

/**
* @param type - Create a SavedObject of the given type
* @param attributes - Create a SavedObject with the given attributes
* Per-object parameters for bulk create operation
*
* @public
*/
export interface SavedObjectsBulkCreateObject<T = unknown> extends SavedObjectsCreateOptions {
/** Create a SavedObject of this type. */
type: string;
/** Attributes for the saved object to be created. */
attributes: T;
}

/** @public */
/**
* Options for bulk create operation
*
* @public
* */
export interface SavedObjectsBulkCreateOptions {
/** If a document with the given `id` already exists, overwrite it's contents (default=false). */
/** If a document with the given `id` already exists, overwrite its contents (default=false). */
overwrite?: boolean;
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,38 @@

import { SavedObjectError } from '@kbn/core-saved-objects-common';

/** @public */
/**
* Options for bulk delete operation
*
* @public
*/
export interface SavedObjectsBulkDeleteOptions {
/** Force deletion of any objects that exist in multiple namespaces (default=false) */
force?: boolean;
}

/** @public */
/**
* Single item within the statuses array of the bulk delete response
*
* @public
*/
export interface SavedObjectsBulkDeleteResponseItem {
/** saved object id */
id: string;
/** saved object type */
type: string;
/** true if the delete operation succeeded*/
jeramysoucy marked this conversation as resolved.
Show resolved Hide resolved
success: boolean;
/** error from delete operation (undefined if no error) */
error?: SavedObjectError;
}

/** @public */
/**
* Return type of the Saved Objects `bulkDelete()` method.
*
* @public
*/
export interface SavedObjectsBulkDeleteResponse {
/** array of statuses per object */
statuses: SavedObjectsBulkDeleteResponseItem[];
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@

import type { ResolvedSimpleSavedObject } from './resolve';

/** @public */
/**
* Return type of the Saved Objects `bulkResolve()` method.
*
* @public
*/
export interface SavedObjectsBulkResolveResponse<T = unknown> {
/** Array of {@link ResolvedSimpleSavedObject} that were resolved */
resolved_objects: Array<ResolvedSimpleSavedObject<T>>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,33 @@

import type { SavedObjectReference } from '@kbn/core-saved-objects-common';

/** @public */
/**
* Per-object parameters for bulk update operation
*
* @public
*/
export interface SavedObjectsBulkUpdateObject<T = unknown> {
/** Type of the saved object to update */
type: string;
/** ID of the saved object to update */
id: string;
/** The attributes to update */
attributes: T;
/** The version string for the saved object */
version?: string;
/** Array of references to other saved objects */
references?: SavedObjectReference[];
}

/** @public */
/**
* Options for bulk update operation
*
* @public
* */
export interface SavedObjectsBulkUpdateOptions {
/**
* The namespace from which to apply the bulk update operation
* Not permitted if spaces extension is enabled
*/
namespace?: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ import type {
SavedObjectsMigrationVersion,
} from '@kbn/core-saved-objects-common';

/** @public */
/**
* Options for creating a saved object.
*
* @public
*/
export interface SavedObjectsCreateOptions {
/**
* (Not recommended) Specify an id instead of having the saved objects service generate one for you.
Expand All @@ -23,5 +27,6 @@ export interface SavedObjectsCreateOptions {
migrationVersion?: SavedObjectsMigrationVersion;
/** A semver value that is used when upgrading objects between Kibana versions. */
coreMigrationVersion?: string;
/** Array of referenced saved objects. */
references?: SavedObjectReference[];
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@
* Side Public License, v 1.
*/

/** @public */
/**
* Options for deleting a saved object.
*
* @public
*/
export interface SavedObjectsDeleteOptions {
/** Force deletion of an object that exists in multiple namespaces */
/** Force deletion of an object that exists in multiple namespaces (default=false) */
force?: boolean;
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@
import type { SavedObjectsFindOptions as SavedObjectFindOptionsServer } from '@kbn/core-saved-objects-api-server';
import type { SavedObjectsBatchResponse } from './base';

export type { SavedObjectsFindOptionsReference } from '@kbn/core-saved-objects-api-server';

/**
* Browser options for finding saved objects
*
* @public
*/
export type SavedObjectsFindOptions = Omit<
Expand All @@ -24,16 +28,12 @@ export type SavedObjectsFindOptions = Omit<
*/
export interface SavedObjectsFindResponse<T = unknown, A = unknown>
extends SavedObjectsBatchResponse<T> {
/** aggregations from the search query */
aggregations?: A;
/** total number of results */
total: number;
/** number of results per page */
perPage: number;
/** current page in results*/
page: number;
}

/**
* @public
*/
export interface SavedObjectsFindOptionsReference {
type: string;
id: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import type { SavedObjectsResolveResponse } from '@kbn/core-saved-objects-api-server';
import { SimpleSavedObject } from '../simple_saved_object';
import type { SimpleSavedObject } from '../simple_saved_object';

/**
* This interface is a very simple wrapper for SavedObjects resolved from the server
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,16 @@

import type { SavedObjectReference } from '@kbn/core-saved-objects-common';

/** @public */
/**
* Options for updating a saved object
*
* @public
*/
export interface SavedObjectsUpdateOptions<Attributes = unknown> {
/** version of the saved object */
version?: string;
/** Alternative attributes for the saved object if upserting */
upsert?: Attributes;
/** Array of references to other saved objects */
references?: SavedObjectReference[];
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@ import type { SimpleSavedObject } from './simple_saved_object';
*/
export interface SavedObjectsClientContract {
/**
* Persists an object
* Creates an object
*
* @param {string} type - the type of object to create
* @param {string} attributes - the attributes of the object
* @param {string} options {@link SavedObjectsCreateOptions}
* @returns The result of the create operation - the created saved object
*/
create<T = unknown>(
type: string,
Expand All @@ -42,7 +47,10 @@ export interface SavedObjectsClientContract {
): Promise<SimpleSavedObject<T>>;

/**
* Creates multiple documents at once
* Creates multiple objects at once
*
* @param {string} objects - an array of objects containing type, attributes
* @param {string} options {@link SavedObjectsBulkCreateOptions}
* @returns The result of the create operation containing created saved objects.
*/
bulkCreate(
Expand All @@ -52,6 +60,11 @@ export interface SavedObjectsClientContract {

/**
* Deletes an object
*
* @param {string} type - the type the of object to delete
* @param {string} id - the id of the object to delete
* @param {string} options {@link SavedObjectsDeleteOptions}
* @param {string} options.force - required to delete objects shared to multiple spaces
*/
delete(type: string, id: string, options?: SavedObjectsDeleteOptions): Promise<{}>;

Expand All @@ -69,8 +82,8 @@ export interface SavedObjectsClientContract {
/**
* Search for objects
*
* @param {object} [options={}]
* @property {string} options.type
* @param {object} [options={}] {@link SavedObjectsFindOptions}
* @property {string} options.type - the type or array of types to find
* @property {string} options.search
* @property {string} options.searchFields - see Elasticsearch Simple Query String
* Query field argument for more information
Expand All @@ -87,8 +100,8 @@ export interface SavedObjectsClientContract {
/**
* Fetches a single object
*
* @param {string} type
* @param {string} id
* @param {string} type - the type of the object to get
* @param {string} id - the ID of the object to get
* @returns The saved object for the given type and id.
*/
get<T = unknown>(type: string, id: string): Promise<SimpleSavedObject<T>>;
Expand All @@ -110,8 +123,8 @@ export interface SavedObjectsClientContract {
/**
* Resolves a single object
*
* @param {string} type
* @param {string} id
* @param {string} type - the type of the object to resolve
* @param {string} id - the ID of the object to resolve
* @returns The resolve result for the saved object for the given type and id.
*
* @note Saved objects that Kibana fails to find are replaced with an error object and an "exactMatch" outcome. The rationale behind the
Expand Down Expand Up @@ -144,13 +157,13 @@ export interface SavedObjectsClientContract {
/**
* Updates an object
*
* @param {string} type
* @param {string} id
* @param {object} attributes
* @param {object} options
* @param {string} type - the type of the object to update
* @param {string} id - the ID of the object to update
* @param {object} attributes - the attributes to update
* @param {object} options {@link SavedObjectsUpdateOptions}
* @prop {integer} options.version - ensures version matches that of persisted object
* @prop {object} options.migrationVersion - The optional migrationVersion of this document
* @returns
* @returns the udpated simple saved object
*/
update<T = unknown>(
type: string,
Expand All @@ -162,8 +175,8 @@ export interface SavedObjectsClientContract {
/**
* Update multiple documents at once
*
* @param {array} objects - [{ type, id, attributes, options: { version, references } }]
* @returns The result of the update operation containing both failed and updated saved objects.
* @param {array} objects - an array of objects containing type, id, attributes, and references
* @returns the result of the bulk update operation containing both failed and updated saved objects.
*/
bulkUpdate<T = unknown>(
objects: SavedObjectsBulkUpdateObject[]
Expand Down
Loading