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] Browser-side client deprecation notice #148979

Merged
merged 9 commits into from
Jan 18, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { SimpleSavedObject } from '../simple_saved_object';
* Batch response for simple saved objects
*
* @public
* @deprecated See https://github.com/elastic/kibana/issues/149098
*/
export interface SavedObjectsBatchResponse<T = unknown> {
/** Array of simple saved objects */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import type { SavedObjectsCreateOptions } from './create';
* Per-object parameters for bulk create operation
*
* @public
* @deprecated See https://github.com/elastic/kibana/issues/149098
*/
export interface SavedObjectsBulkCreateObject<T = unknown> extends SavedObjectsCreateOptions {
/** Create a SavedObject of this type. */
Expand All @@ -24,6 +25,7 @@ export interface SavedObjectsBulkCreateObject<T = unknown> extends SavedObjectsC
* Options for bulk create operation
*
* @public
* @deprecated See https://github.com/elastic/kibana/issues/149098
* */
export interface SavedObjectsBulkCreateOptions {
/** If a document with the given `id` already exists, overwrite its contents (default=false). */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { SavedObjectError } from '@kbn/core-saved-objects-common';
* Options for bulk delete operation
*
* @public
* @deprecated See https://github.com/elastic/kibana/issues/149098
*/
export interface SavedObjectsBulkDeleteOptions {
/** Force deletion of any objects that exist in multiple namespaces (default=false) */
Expand All @@ -22,6 +23,7 @@ export interface SavedObjectsBulkDeleteOptions {
* Single item within the statuses array of the bulk delete response
*
* @public
* @deprecated See https://github.com/elastic/kibana/issues/149098
*/
export interface SavedObjectsBulkDeleteResponseItem {
/** saved object id */
Expand All @@ -38,6 +40,7 @@ export interface SavedObjectsBulkDeleteResponseItem {
* Return type of the Saved Objects `bulkDelete()` method.
*
* @public
* @deprecated See https://github.com/elastic/kibana/issues/149098
*/
export interface SavedObjectsBulkDeleteResponse {
/** array of statuses per object */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import type { ResolvedSimpleSavedObject } from './resolve';
* Return type of the Saved Objects `bulkResolve()` method.
*
* @public
* @deprecated See https://github.com/elastic/kibana/issues/149098
*/
export interface SavedObjectsBulkResolveResponse<T = unknown> {
/** Array of {@link ResolvedSimpleSavedObject} that were resolved */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import type { SavedObjectReference } from '@kbn/core-saved-objects-common';
* Per-object parameters for bulk update operation
*
* @public
* @deprecated See https://github.com/elastic/kibana/issues/149098
*/
export interface SavedObjectsBulkUpdateObject<T = unknown> {
/** Type of the saved object to update */
Expand All @@ -30,6 +31,7 @@ export interface SavedObjectsBulkUpdateObject<T = unknown> {
* Options for bulk update operation
*
* @public
* @deprecated See https://github.com/elastic/kibana/issues/149098
* */
export interface SavedObjectsBulkUpdateOptions {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import type {
* Options for creating a saved object.
*
* @public
* @deprecated See https://github.com/elastic/kibana/issues/149098
*/
export interface SavedObjectsCreateOptions {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* Options for deleting a saved object.
*
* @public
* @deprecated See https://github.com/elastic/kibana/issues/149098
*/
export interface SavedObjectsDeleteOptions {
/** Force deletion of an object that exists in multiple namespaces (default=false) */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export type { SavedObjectsFindOptionsReference } from '@kbn/core-saved-objects-a
* Browser options for finding saved objects
*
* @public
* @deprecated See https://github.com/elastic/kibana/issues/149098
*/
export type SavedObjectsFindOptions = Omit<
SavedObjectFindOptionsServer,
Expand All @@ -25,6 +26,7 @@ export type SavedObjectsFindOptions = Omit<
* Return type of the Saved Objects `find()` method.
*
* @public
* @deprecated See https://github.com/elastic/kibana/issues/149098
*/
export interface SavedObjectsFindResponse<T = unknown, A = unknown>
extends SavedObjectsBatchResponse<T> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import type { SimpleSavedObject } from '../simple_saved_object';
* with the {@link SavedObjectsClientContract}.
*
* @public
* @deprecated See https://github.com/elastic/kibana/issues/149098
*/
export interface ResolvedSimpleSavedObject<T = unknown> {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import type { SavedObjectReference } from '@kbn/core-saved-objects-common';
* Options for updating a saved object
*
* @public
* @deprecated See https://github.com/elastic/kibana/issues/149098
*/
export interface SavedObjectsUpdateOptions<Attributes = unknown> {
/** version of the saved object */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import type { SimpleSavedObject } from './simple_saved_object';
* HTTP API for interacting with Saved Objects.
*
* @public
* @deprecated See https://github.com/elastic/kibana/issues/149098
*/
export interface SavedObjectsClientContract {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import type { SavedObject as SavedObjectType } from '@kbn/core-saved-objects-com
* but doesn't include any type-specific implementations.
*
* @public
* @deprecated See https://github.com/elastic/kibana/issues/149098
*/
export interface SimpleSavedObject<T = unknown> {
/** attributes of the object, templated */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ const getObjectsToResolve = (queue: BatchResolveQueueEntry[]) => {
* HTTP API for interacting with Saved Objects.
*
* @internal
* @deprecated See https://github.com/elastic/kibana/issues/149098
*/
export class SavedObjectsClient implements SavedObjectsClientContract {
private http: HttpSetup;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ import type { HttpStart } from '@kbn/core-http-browser';
import type { SavedObjectsStart } from '@kbn/core-saved-objects-browser';
import { SavedObjectsClient } from './saved_objects_client';

/**
* @deprecated See https://github.com/elastic/kibana/issues/149098
*/
export class SavedObjectsService implements CoreService<void, SavedObjectsStart> {
public async setup() {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import type {
* Core internal implementation of {@link SimpleSavedObject}
*
* @internal Should use the {@link SimpleSavedObject} interface instead
* @deprecated See https://github.com/elastic/kibana/issues/149098
*/
export class SimpleSavedObjectImpl<T = unknown> implements SimpleSavedObject<T> {
public attributes: T;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ const createMock = () => {
return mocked;
};

/**
* @deprecated See https://github.com/elastic/kibana/issues/149098
*/
export const savedObjectsServiceMock = {
create: createMock,
createStartContract: createStartContractMock,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ const createSimpleSavedObjectMock = (
return mock;
};

/**
* @deprecated See https://github.com/elastic/kibana/issues/149098
*/
export const simpleSavedObjectMock = {
create: (client: SavedObjectsClientContract, savedObject: SavedObject) =>
createSimpleSavedObjectMock(savedObject),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import type { SavedObjectsClientContract } from '@kbn/core-saved-objects-api-bro

/**
* @public
* @deprecated See https://github.com/elastic/kibana/issues/149098
*/
export interface SavedObjectsStart {
/** {@link SavedObjectsClientContract} */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,47 +6,7 @@
* Side Public License, v 1.
*/

/**
* Don't use this type, it's simply a helper type for {@link SavedObjectAttribute}
*
* @public
*/
export type SavedObjectAttributeSingle =
| string
| number
| boolean
| null
| undefined
| SavedObjectAttributes;

/**
* Type definition for a Saved Object attribute value
*
* @public
*/
export type SavedObjectAttribute = SavedObjectAttributeSingle | SavedObjectAttributeSingle[];

/**
* The data for a Saved Object is stored as an object in the `attributes`
* property.
*
* @public
* @deprecated This type reduces the type safety of your code. Create an interface for your specific saved object type or use `unknown` instead.
*/
export interface SavedObjectAttributes {
[key: string]: SavedObjectAttribute;
}

/**
* A reference to another saved object.
*
* @public
*/
export interface SavedObjectReference {
name: string;
type: string;
id: string;
}
import * as serverTypes from './server_types';

/**
* Information about the migrations that have been applied to this SavedObject.
Expand All @@ -68,41 +28,6 @@ export interface SavedObjectsMigrationVersion {
[pluginName: string]: string;
}

export interface SavedObject<T = unknown> {
/** The ID of this Saved Object, guaranteed to be unique for all objects of the same `type` */
id: string;
/** The type of Saved Object. Each plugin can define it's own custom Saved Object types. */
type: string;
/** An opaque version number which changes on each successful write operation. Can be used for implementing optimistic concurrency control. */
version?: string;
/** Timestamp of the time this document had been created. */
created_at?: string;
/** Timestamp of the last time this document had been updated. */
updated_at?: string;
/** Error associated with this object, populated if an operation failed for this object. */
error?: SavedObjectError;
/** The data for a Saved Object is stored as an object in the `attributes` property. **/
attributes: T;
/** {@inheritdoc SavedObjectReference} */
references: SavedObjectReference[];
/** {@inheritdoc SavedObjectsMigrationVersion} */
migrationVersion?: SavedObjectsMigrationVersion;
/** A semver value that is used when upgrading objects between Kibana versions. */
coreMigrationVersion?: string;
/**
* Space(s) that this saved object exists in. This attribute is not used for "global" saved object types which are registered with
* `namespaceType: 'agnostic'`.
*/
namespaces?: string[];
/**
* The ID of the saved object this originated from. This is set if this object's `id` was regenerated; that can happen during migration
* from a legacy single-namespace type, or during import. It is only set during migration or create operations. This is used during import
* to ensure that ID regeneration is deterministic, so saved objects will be overwritten if they are imported multiple times into a given
* space.
*/
originId?: string;
}

/**
* The namespace type dictates how a saved object can be interacted in relation to namespaces. Each type is mutually exclusive:
* * single (default): This type of saved object is namespace-isolated, e.g., it exists in only one namespace.
Expand All @@ -123,3 +48,33 @@ export interface SavedObjectError {
statusCode: number;
metadata?: Record<string, unknown>;
}

/**
* @public
* @deprecated See https://github.com/elastic/kibana/issues/149098
*/
export type SavedObjectAttributeSingle = serverTypes.SavedObjectAttributeSingle;
Copy link
Contributor

@TinaHeiligers TinaHeiligers Jan 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly, I'm not a fan of this syntax. Using named imports:

import {
  SavedObjectAttributeSingle as LegacySavedObjectAttributeSingle,
  SavedObjectAttribute as LegacySavedObjectAttribute,
  SavedObjectAttributes as LegacySavedObjectAttributes,
  SavedObjectReference as LegacySavedObjectReference,
  SavedObject as LegacySavedObject,
} from './will_move_to_server';

allows us to use export type SavedObjectAttributeSingle = LegacySavedObjectAttributeSingle;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same response as #148979 (comment) :)


/**
* @public
* @deprecated See https://github.com/elastic/kibana/issues/149098
*/
export type SavedObjectAttribute = serverTypes.SavedObjectAttribute;

/**
* @public
* @deprecated See https://github.com/elastic/kibana/issues/149098
*/
export type SavedObjectAttributes = serverTypes.SavedObjectAttributes;

/**
* @public
* @deprecated See https://github.com/elastic/kibana/issues/149098
*/
export type SavedObjectReference = serverTypes.SavedObjectReference;

/**
* @public
* @deprecated See https://github.com/elastic/kibana/issues/149098
*/
export type SavedObject<T = unknown> = serverTypes.SavedObject<T>;
Loading