import { ISavedObjectsRepository } from './lib' ; import { SavedObject , SavedObjectError , SavedObjectReference , SavedObjectsMigrationVersion , SavedObjectsBaseOptions , MutatingOperationRefreshSetting , SavedObjectsFindOptions , } from '../types' ; import { SavedObjectsErrorHelpers } from './lib/errors' ; public export interface SavedObjectsCreateOptions extends SavedObjectsBaseOptions { /** (not recommended) Specify an id for the document */ id ? : string ; /** Overwrite existing documents (defaults to false) */ overwrite ? : boolean ; /**
     * An opaque version number which changes on each successful write operation.
     * Can be used in conjunction with `overwrite` for implementing optimistic concurrency control.
     **/ version ? : string ; /** {@inheritDoc SavedObjectsMigrationVersion} */ migrationVersion ? : SavedObjectsMigrationVersion ; references ? : SavedObjectReference [ ] ; /** The OpenSearch Refresh setting for this operation */ refresh ? : MutatingOperationRefreshSetting ; /** Optional ID of the original saved object, if this object's `id` was regenerated */ originId ? : string ; /**
     * Optional initial namespaces for the object to be created in. If this is defined, it will supersede the namespace ID that is in
     *  SavedObjectsCreateOptions .
     *
     * Note: this can only be used for multi-namespace object types.
      initialNamespaces ? : string [ ] ; } public export interface SavedObjectsBulkCreateObject < T = unknown > { id ? : string ; type : string ; attributes : T ; version ? : string ; references ? : SavedObjectReference [ ] ; /** {@inheritDoc SavedObjectsMigrationVersion} */ migrationVersion ? : SavedObjectsMigrationVersion ; /** Optional ID of the original saved object, if this object's `id` was regenerated */ originId ? : string ; /**
     * Optional initial namespaces for the object to be created in. If this is defined, it will supersede the namespace ID that is in
     *  SavedObjectsCreateOptions .
     *
     * Note: this can only be used for multi-namespace object types.
      initialNamespaces ? : string [ ] ; } public export interface SavedObjectsBulkUpdateObject < T = unknown > extends Pick < SavedObjectsUpdateOptions , 'version' | 'references' > { /** The ID of this Saved Object, guaranteed to be unique for all objects of the same `type` */ id : string ; /**  The type of this Saved Object. Each plugin can define it's own custom Saved Object types. */ type : string ; /** {@inheritdoc SavedObjectAttributes} */ attributes : Partial < T > ; /**
     * Optional namespace string to use when searching for this object. If this is defined, it will supersede the namespace ID that is in
     *  SavedObjectsBulkUpdateOptions .
     *
     * Note: the default namespace's string representation is `'default'`, and its ID representation is `undefined`.
     * namespace ? : string ; } public export interface SavedObjectsBulkResponse < T = unknown > { saved_objects : Array < SavedObject < T > > ; } public export interface SavedObjectsFindResult < T = unknown > extends SavedObject < T > { /**
     * The OpenSearch `_score` of this result.
     */ score : number ; } public export interface SavedObjectsFindResponse < T = unknown > { saved_objects : Array < SavedObjectsFindResult < T > > ; total : number ; per_page : number ; page : number ; } public export interface SavedObjectsCheckConflictsObject { id : string ; type : string ; } public export interface SavedObjectsCheckConflictsResponse { errors : Array < { id : string ; type : string ; error : SavedObjectError ; } > ; } public export interface SavedObjectsUpdateOptions extends SavedObjectsBaseOptions { /** An opaque version number which changes on each successful write operation. Can be used for implementing optimistic concurrency control. */ version ? : string ; /** {@inheritdoc SavedObjectReference} */ references ? : SavedObjectReference [ ] ; /** The OpenSearch Refresh setting for this operation */ refresh ? : MutatingOperationRefreshSetting ; } public export interface SavedObjectsAddToNamespacesOptions extends SavedObjectsBaseOptions { /** An opaque version number which changes on each successful write operation. Can be used for implementing optimistic concurrency control. */ version ? : string ; /** The OpenSearch Refresh setting for this operation */ refresh ? : MutatingOperationRefreshSetting ; } public export interface SavedObjectsAddToNamespacesResponse { /** The namespaces the object exists in after this operation is complete. */ namespaces : string [ ] ; } public export interface SavedObjectsDeleteFromNamespacesOptions extends SavedObjectsBaseOptions { /** The OpenSearch Refresh setting for this operation */ refresh ? : MutatingOperationRefreshSetting ; } public export interface SavedObjectsDeleteFromNamespacesResponse { /** The namespaces the object exists in after this operation is complete. An empty array indicates the object was deleted. */ namespaces : string [ ] ; } public export interface SavedObjectsBulkUpdateOptions extends SavedObjectsBaseOptions { /** The OpenSearch Refresh setting for this operation */ refresh ? : MutatingOperationRefreshSetting ; } public export interface SavedObjectsDeleteOptions extends SavedObjectsBaseOptions { /** The OpenSearch Refresh setting for this operation */ refresh ? : MutatingOperationRefreshSetting ; /** Force deletion of an object that exists in multiple namespaces */ force ? : boolean ; } public export interface SavedObjectsBulkGetObject { id : string ; type : string ; /** SavedObject fields to include in the response */ fields ? : string [ ] ; } public export interface SavedObjectsBulkResponse < T = unknown > { saved_objects : Array < SavedObject < T > > ; } public export interface SavedObjectsBulkUpdateResponse < T = unknown > { saved_objects : Array < SavedObjectsUpdateResponse < T > > ; } public export interface SavedObjectsUpdateResponse < T = unknown > extends Omit < SavedObject < T > , 'attributes' | 'references' > { attributes : Partial < T > ; references : SavedObjectReference [ ] | undefined ; } public export class SavedObjectsClient { public static errors = SavedObjectsErrorHelpers ; public errors = SavedObjectsErrorHelpers ; private _repository : ISavedObjectsRepository ; internal constructor ( repository ) { this . _repository = repository ; } param type param attributes param options async create < T = unknown > ( type , attributes , options ? ) { return await this . _repository . create ( type , attributes , options ) ; } param objects param options async bulkCreate < T = unknown > ( objects , options ? ) { return await this . _repository . bulkCreate ( objects , options ) ; } param objects param options async checkConflicts ( objects = [ ] , options = { } ) { return await this . _repository . checkConflicts ( objects , options ) ; } param type param id param options async delete ( type , id , options = { } ) { return await this . _repository . delete ( type , id , options ) ; } param options async find < T = unknown > ( options ) { return await this . _repository . find ( options ) ; } param objects example async bulkGet < T = unknown > ( objects = [ ] , options = { } ) { return await this . _repository . bulkGet ( objects , options ) ; } param type param id param options async get < T = unknown > ( type , id , options = { } ) { return await this . _repository . get ( type , id , options ) ; } param type param id param options async update < T = unknown > ( type , id , attributes , options = { } ) { return await this . _repository . update ( type , id , attributes , options ) ; } param type param id param namespaces param options async addToNamespaces ( type , id , namespaces , options = { } ) { return await this . _repository . addToNamespaces ( type , id , namespaces , options ) ; } param type param id param namespaces param options async deleteFromNamespaces ( type , id , namespaces , options = { } ) { return await this . _repository . deleteFromNamespaces ( type , id , namespaces , options ) ; } param objects async bulkUpdate < T = unknown > ( objects , options ? ) { return await this . _repository . bulkUpdate ( objects , options ) ; } }