force savedObject API consumers to define SO type explicitly (#58022) (#58281)

* force savedObject consumers to define type explicitly

* address comments

* regen docs
This commit is contained in:
Mikhail Shustov 2020-02-22 07:36:20 +01:00 committed by GitHub
parent 15880098cd
commit fc6674ad1e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
95 changed files with 387 additions and 329 deletions

View file

@ -8,7 +8,7 @@
<b>Signature:</b>
```typescript
export interface SavedObject<T extends SavedObjectAttributes = any>
export interface SavedObject<T = unknown>
```
## Properties

View file

@ -8,7 +8,7 @@
<b>Signature:</b>
```typescript
export interface SavedObjectsBatchResponse<T extends SavedObjectAttributes = SavedObjectAttributes>
export interface SavedObjectsBatchResponse<T = unknown>
```
## Properties

View file

@ -7,7 +7,7 @@
<b>Signature:</b>
```typescript
export interface SavedObjectsBulkCreateObject<T extends SavedObjectAttributes = SavedObjectAttributes> extends SavedObjectsCreateOptions
export interface SavedObjectsBulkCreateObject<T = unknown> extends SavedObjectsCreateOptions
```
## Properties

View file

@ -8,7 +8,7 @@
<b>Signature:</b>
```typescript
export interface SavedObjectsBulkUpdateObject<T extends SavedObjectAttributes = SavedObjectAttributes>
export interface SavedObjectsBulkUpdateObject<T = unknown>
```
## Properties

View file

@ -9,5 +9,5 @@ Creates multiple documents at once
<b>Signature:</b>
```typescript
bulkCreate: (objects?: SavedObjectsBulkCreateObject<SavedObjectAttributes>[], options?: SavedObjectsBulkCreateOptions) => Promise<SavedObjectsBatchResponse<SavedObjectAttributes>>;
bulkCreate: (objects?: SavedObjectsBulkCreateObject<unknown>[], options?: SavedObjectsBulkCreateOptions) => Promise<SavedObjectsBatchResponse<unknown>>;
```

View file

@ -12,7 +12,7 @@ Returns an array of objects by id
bulkGet: (objects?: {
id: string;
type: string;
}[]) => Promise<SavedObjectsBatchResponse<SavedObjectAttributes>>;
}[]) => Promise<SavedObjectsBatchResponse<unknown>>;
```
## Example

View file

@ -9,7 +9,7 @@ Update multiple documents at once
<b>Signature:</b>
```typescript
bulkUpdate<T extends SavedObjectAttributes>(objects?: SavedObjectsBulkUpdateObject[]): Promise<SavedObjectsBatchResponse<SavedObjectAttributes>>;
bulkUpdate<T = unknown>(objects?: SavedObjectsBulkUpdateObject[]): Promise<SavedObjectsBatchResponse<unknown>>;
```
## Parameters
@ -20,7 +20,7 @@ bulkUpdate<T extends SavedObjectAttributes>(objects?: SavedObjectsBulkUpdateObje
<b>Returns:</b>
`Promise<SavedObjectsBatchResponse<SavedObjectAttributes>>`
`Promise<SavedObjectsBatchResponse<unknown>>`
The result of the update operation containing both failed and updated saved objects.

View file

@ -9,5 +9,5 @@ Persists an object
<b>Signature:</b>
```typescript
create: <T extends SavedObjectAttributes>(type: string, attributes: T, options?: SavedObjectsCreateOptions) => Promise<SimpleSavedObject<T>>;
create: <T = unknown>(type: string, attributes: T, options?: SavedObjectsCreateOptions) => Promise<SimpleSavedObject<T>>;
```

View file

@ -9,5 +9,5 @@ Search for objects
<b>Signature:</b>
```typescript
find: <T extends SavedObjectAttributes>(options: Pick<SavedObjectFindOptionsServer, "search" | "filter" | "type" | "page" | "perPage" | "sortField" | "fields" | "searchFields" | "hasReference" | "defaultSearchOperator">) => Promise<SavedObjectsFindResponsePublic<T>>;
find: <T = unknown>(options: Pick<SavedObjectFindOptionsServer, "search" | "filter" | "type" | "page" | "perPage" | "sortField" | "fields" | "searchFields" | "hasReference" | "defaultSearchOperator">) => Promise<SavedObjectsFindResponsePublic<T>>;
```

View file

@ -9,5 +9,5 @@ Fetches a single object
<b>Signature:</b>
```typescript
get: <T extends SavedObjectAttributes>(type: string, id: string) => Promise<SimpleSavedObject<T>>;
get: <T = unknown>(type: string, id: string) => Promise<SimpleSavedObject<T>>;
```

View file

@ -20,12 +20,12 @@ The constructor for this class is marked as internal. Third-party code should no
| Property | Modifiers | Type | Description |
| --- | --- | --- | --- |
| [bulkCreate](./kibana-plugin-public.savedobjectsclient.bulkcreate.md) | | <code>(objects?: SavedObjectsBulkCreateObject&lt;SavedObjectAttributes&gt;[], options?: SavedObjectsBulkCreateOptions) =&gt; Promise&lt;SavedObjectsBatchResponse&lt;SavedObjectAttributes&gt;&gt;</code> | Creates multiple documents at once |
| [bulkGet](./kibana-plugin-public.savedobjectsclient.bulkget.md) | | <code>(objects?: {</code><br/><code> id: string;</code><br/><code> type: string;</code><br/><code> }[]) =&gt; Promise&lt;SavedObjectsBatchResponse&lt;SavedObjectAttributes&gt;&gt;</code> | Returns an array of objects by id |
| [create](./kibana-plugin-public.savedobjectsclient.create.md) | | <code>&lt;T extends SavedObjectAttributes&gt;(type: string, attributes: T, options?: SavedObjectsCreateOptions) =&gt; Promise&lt;SimpleSavedObject&lt;T&gt;&gt;</code> | Persists an object |
| [bulkCreate](./kibana-plugin-public.savedobjectsclient.bulkcreate.md) | | <code>(objects?: SavedObjectsBulkCreateObject&lt;unknown&gt;[], options?: SavedObjectsBulkCreateOptions) =&gt; Promise&lt;SavedObjectsBatchResponse&lt;unknown&gt;&gt;</code> | Creates multiple documents at once |
| [bulkGet](./kibana-plugin-public.savedobjectsclient.bulkget.md) | | <code>(objects?: {</code><br/><code> id: string;</code><br/><code> type: string;</code><br/><code> }[]) =&gt; Promise&lt;SavedObjectsBatchResponse&lt;unknown&gt;&gt;</code> | Returns an array of objects by id |
| [create](./kibana-plugin-public.savedobjectsclient.create.md) | | <code>&lt;T = unknown&gt;(type: string, attributes: T, options?: SavedObjectsCreateOptions) =&gt; Promise&lt;SimpleSavedObject&lt;T&gt;&gt;</code> | Persists an object |
| [delete](./kibana-plugin-public.savedobjectsclient.delete.md) | | <code>(type: string, id: string) =&gt; Promise&lt;{}&gt;</code> | Deletes an object |
| [find](./kibana-plugin-public.savedobjectsclient.find.md) | | <code>&lt;T extends SavedObjectAttributes&gt;(options: Pick&lt;SavedObjectFindOptionsServer, &quot;search&quot; &#124; &quot;filter&quot; &#124; &quot;type&quot; &#124; &quot;page&quot; &#124; &quot;perPage&quot; &#124; &quot;sortField&quot; &#124; &quot;fields&quot; &#124; &quot;searchFields&quot; &#124; &quot;hasReference&quot; &#124; &quot;defaultSearchOperator&quot;&gt;) =&gt; Promise&lt;SavedObjectsFindResponsePublic&lt;T&gt;&gt;</code> | Search for objects |
| [get](./kibana-plugin-public.savedobjectsclient.get.md) | | <code>&lt;T extends SavedObjectAttributes&gt;(type: string, id: string) =&gt; Promise&lt;SimpleSavedObject&lt;T&gt;&gt;</code> | Fetches a single object |
| [find](./kibana-plugin-public.savedobjectsclient.find.md) | | <code>&lt;T = unknown&gt;(options: Pick&lt;SavedObjectFindOptionsServer, &quot;search&quot; &#124; &quot;filter&quot; &#124; &quot;type&quot; &#124; &quot;page&quot; &#124; &quot;perPage&quot; &#124; &quot;sortField&quot; &#124; &quot;fields&quot; &#124; &quot;searchFields&quot; &#124; &quot;hasReference&quot; &#124; &quot;defaultSearchOperator&quot;&gt;) =&gt; Promise&lt;SavedObjectsFindResponsePublic&lt;T&gt;&gt;</code> | Search for objects |
| [get](./kibana-plugin-public.savedobjectsclient.get.md) | | <code>&lt;T = unknown&gt;(type: string, id: string) =&gt; Promise&lt;SimpleSavedObject&lt;T&gt;&gt;</code> | Fetches a single object |
## Methods

View file

@ -9,7 +9,7 @@ Updates an object
<b>Signature:</b>
```typescript
update<T extends SavedObjectAttributes>(type: string, id: string, attributes: T, { version, migrationVersion, references }?: SavedObjectsUpdateOptions): Promise<SimpleSavedObject<T>>;
update<T = unknown>(type: string, id: string, attributes: T, { version, migrationVersion, references }?: SavedObjectsUpdateOptions): Promise<SimpleSavedObject<T>>;
```
## Parameters

View file

@ -11,7 +11,7 @@ Return type of the Saved Objects `find()` method.
<b>Signature:</b>
```typescript
export interface SavedObjectsFindResponsePublic<T extends SavedObjectAttributes = SavedObjectAttributes> extends SavedObjectsBatchResponse<T>
export interface SavedObjectsFindResponsePublic<T = unknown> extends SavedObjectsBatchResponse<T>
```
## Properties

View file

@ -11,7 +11,7 @@ It provides basic functionality for creating/saving/deleting saved objects, but
<b>Signature:</b>
```typescript
export declare class SimpleSavedObject<T extends SavedObjectAttributes>
export declare class SimpleSavedObject<T = unknown>
```
## Constructors

View file

@ -8,7 +8,7 @@
<b>Signature:</b>
```typescript
export interface SavedObject<T extends SavedObjectAttributes = any>
export interface SavedObject<T = unknown>
```
## Properties

View file

@ -8,7 +8,7 @@
<b>Signature:</b>
```typescript
export interface SavedObjectsBulkCreateObject<T extends SavedObjectAttributes = any>
export interface SavedObjectsBulkCreateObject<T = unknown>
```
## Properties

View file

@ -8,7 +8,7 @@
<b>Signature:</b>
```typescript
export interface SavedObjectsBulkResponse<T extends SavedObjectAttributes = any>
export interface SavedObjectsBulkResponse<T = unknown>
```
## Properties

View file

@ -8,7 +8,7 @@
<b>Signature:</b>
```typescript
export interface SavedObjectsBulkUpdateObject<T extends SavedObjectAttributes = any> extends Pick<SavedObjectsUpdateOptions, 'version' | 'references'>
export interface SavedObjectsBulkUpdateObject<T = unknown> extends Pick<SavedObjectsUpdateOptions, 'version' | 'references'>
```
## Properties

View file

@ -8,7 +8,7 @@
<b>Signature:</b>
```typescript
export interface SavedObjectsBulkUpdateResponse<T extends SavedObjectAttributes = any>
export interface SavedObjectsBulkUpdateResponse<T = unknown>
```
## Properties

View file

@ -9,7 +9,7 @@ Persists multiple documents batched together as a single request
<b>Signature:</b>
```typescript
bulkCreate<T extends SavedObjectAttributes = any>(objects: Array<SavedObjectsBulkCreateObject<T>>, options?: SavedObjectsCreateOptions): Promise<SavedObjectsBulkResponse<T>>;
bulkCreate<T = unknown>(objects: Array<SavedObjectsBulkCreateObject<T>>, options?: SavedObjectsCreateOptions): Promise<SavedObjectsBulkResponse<T>>;
```
## Parameters

View file

@ -9,7 +9,7 @@ Returns an array of objects by id
<b>Signature:</b>
```typescript
bulkGet<T extends SavedObjectAttributes = any>(objects?: SavedObjectsBulkGetObject[], options?: SavedObjectsBaseOptions): Promise<SavedObjectsBulkResponse<T>>;
bulkGet<T = unknown>(objects?: SavedObjectsBulkGetObject[], options?: SavedObjectsBaseOptions): Promise<SavedObjectsBulkResponse<T>>;
```
## Parameters

View file

@ -9,7 +9,7 @@ Bulk Updates multiple SavedObject at once
<b>Signature:</b>
```typescript
bulkUpdate<T extends SavedObjectAttributes = any>(objects: Array<SavedObjectsBulkUpdateObject<T>>, options?: SavedObjectsBulkUpdateOptions): Promise<SavedObjectsBulkUpdateResponse<T>>;
bulkUpdate<T = unknown>(objects: Array<SavedObjectsBulkUpdateObject<T>>, options?: SavedObjectsBulkUpdateOptions): Promise<SavedObjectsBulkUpdateResponse<T>>;
```
## Parameters

View file

@ -9,7 +9,7 @@ Persists a SavedObject
<b>Signature:</b>
```typescript
create<T extends SavedObjectAttributes = any>(type: string, attributes: T, options?: SavedObjectsCreateOptions): Promise<SavedObject<T>>;
create<T = unknown>(type: string, attributes: T, options?: SavedObjectsCreateOptions): Promise<SavedObject<T>>;
```
## Parameters

View file

@ -9,7 +9,7 @@ Find all SavedObjects matching the search query
<b>Signature:</b>
```typescript
find<T extends SavedObjectAttributes = any>(options: SavedObjectsFindOptions): Promise<SavedObjectsFindResponse<T>>;
find<T = unknown>(options: SavedObjectsFindOptions): Promise<SavedObjectsFindResponse<T>>;
```
## Parameters

View file

@ -9,7 +9,7 @@ Retrieves a single object
<b>Signature:</b>
```typescript
get<T extends SavedObjectAttributes = any>(type: string, id: string, options?: SavedObjectsBaseOptions): Promise<SavedObject<T>>;
get<T = unknown>(type: string, id: string, options?: SavedObjectsBaseOptions): Promise<SavedObject<T>>;
```
## Parameters

View file

@ -9,7 +9,7 @@ Updates an SavedObject
<b>Signature:</b>
```typescript
update<T extends SavedObjectAttributes = any>(type: string, id: string, attributes: Partial<T>, options?: SavedObjectsUpdateOptions): Promise<SavedObjectsUpdateResponse<T>>;
update<T = unknown>(type: string, id: string, attributes: Partial<T>, options?: SavedObjectsUpdateOptions): Promise<SavedObjectsUpdateResponse<T>>;
```
## Parameters

View file

@ -11,7 +11,7 @@ Return type of the Saved Objects `find()` method.
<b>Signature:</b>
```typescript
export interface SavedObjectsFindResponse<T extends SavedObjectAttributes = any>
export interface SavedObjectsFindResponse<T = unknown>
```
## Properties

View file

@ -9,7 +9,7 @@ Creates multiple documents at once
<b>Signature:</b>
```typescript
bulkCreate<T extends SavedObjectAttributes = any>(objects: Array<SavedObjectsBulkCreateObject<T>>, options?: SavedObjectsCreateOptions): Promise<SavedObjectsBulkResponse<T>>;
bulkCreate<T = unknown>(objects: Array<SavedObjectsBulkCreateObject<T>>, options?: SavedObjectsCreateOptions): Promise<SavedObjectsBulkResponse<T>>;
```
## Parameters

View file

@ -9,7 +9,7 @@ Returns an array of objects by id
<b>Signature:</b>
```typescript
bulkGet<T extends SavedObjectAttributes = any>(objects?: SavedObjectsBulkGetObject[], options?: SavedObjectsBaseOptions): Promise<SavedObjectsBulkResponse<T>>;
bulkGet<T = unknown>(objects?: SavedObjectsBulkGetObject[], options?: SavedObjectsBaseOptions): Promise<SavedObjectsBulkResponse<T>>;
```
## Parameters

View file

@ -9,7 +9,7 @@ Updates multiple objects in bulk
<b>Signature:</b>
```typescript
bulkUpdate<T extends SavedObjectAttributes = any>(objects: Array<SavedObjectsBulkUpdateObject<T>>, options?: SavedObjectsBulkUpdateOptions): Promise<SavedObjectsBulkUpdateResponse<T>>;
bulkUpdate<T = unknown>(objects: Array<SavedObjectsBulkUpdateObject<T>>, options?: SavedObjectsBulkUpdateOptions): Promise<SavedObjectsBulkUpdateResponse<T>>;
```
## Parameters

View file

@ -9,7 +9,7 @@ Persists an object
<b>Signature:</b>
```typescript
create<T extends SavedObjectAttributes>(type: string, attributes: T, options?: SavedObjectsCreateOptions): Promise<SavedObject<T>>;
create<T = unknown>(type: string, attributes: T, options?: SavedObjectsCreateOptions): Promise<SavedObject<T>>;
```
## Parameters

View file

@ -7,7 +7,7 @@
<b>Signature:</b>
```typescript
find<T extends SavedObjectAttributes = any>({ search, defaultSearchOperator, searchFields, hasReference, page, perPage, sortField, sortOrder, fields, namespace, type, filter, }: SavedObjectsFindOptions): Promise<SavedObjectsFindResponse<T>>;
find<T = unknown>({ search, defaultSearchOperator, searchFields, hasReference, page, perPage, sortField, sortOrder, fields, namespace, type, filter, }: SavedObjectsFindOptions): Promise<SavedObjectsFindResponse<T>>;
```
## Parameters

View file

@ -9,7 +9,7 @@ Gets a single object
<b>Signature:</b>
```typescript
get<T extends SavedObjectAttributes = any>(type: string, id: string, options?: SavedObjectsBaseOptions): Promise<SavedObject<T>>;
get<T = unknown>(type: string, id: string, options?: SavedObjectsBaseOptions): Promise<SavedObject<T>>;
```
## Parameters

View file

@ -9,7 +9,7 @@ Updates an object
<b>Signature:</b>
```typescript
update<T extends SavedObjectAttributes = any>(type: string, id: string, attributes: Partial<T>, options?: SavedObjectsUpdateOptions): Promise<SavedObjectsUpdateResponse<T>>;
update<T = unknown>(type: string, id: string, attributes: Partial<T>, options?: SavedObjectsUpdateOptions): Promise<SavedObjectsUpdateResponse<T>>;
```
## Parameters

View file

@ -8,7 +8,7 @@
<b>Signature:</b>
```typescript
export interface SavedObjectsUpdateResponse<T extends SavedObjectAttributes = any> extends Omit<SavedObject<T>, 'attributes' | 'references'>
export interface SavedObjectsUpdateResponse<T = unknown> extends Omit<SavedObject<T>, 'attributes' | 'references'>
```
## Properties

View file

@ -932,7 +932,7 @@ export type RecursiveReadonly<T> = T extends (...args: any[]) => any ? T : T ext
}> : T;
// @public (undocumented)
export interface SavedObject<T extends SavedObjectAttributes = any> {
export interface SavedObject<T = unknown> {
attributes: T;
// (undocumented)
error?: {
@ -975,13 +975,13 @@ export interface SavedObjectsBaseOptions {
}
// @public (undocumented)
export interface SavedObjectsBatchResponse<T extends SavedObjectAttributes = SavedObjectAttributes> {
export interface SavedObjectsBatchResponse<T = unknown> {
// (undocumented)
savedObjects: Array<SimpleSavedObject<T>>;
}
// @public (undocumented)
export interface SavedObjectsBulkCreateObject<T extends SavedObjectAttributes = SavedObjectAttributes> extends SavedObjectsCreateOptions {
export interface SavedObjectsBulkCreateObject<T = unknown> extends SavedObjectsCreateOptions {
// (undocumented)
attributes: T;
// (undocumented)
@ -994,7 +994,7 @@ export interface SavedObjectsBulkCreateOptions {
}
// @public (undocumented)
export interface SavedObjectsBulkUpdateObject<T extends SavedObjectAttributes = SavedObjectAttributes> {
export interface SavedObjectsBulkUpdateObject<T = unknown> {
// (undocumented)
attributes: T;
// (undocumented)
@ -1017,17 +1017,17 @@ export interface SavedObjectsBulkUpdateOptions {
export class SavedObjectsClient {
// @internal
constructor(http: HttpSetup);
bulkCreate: (objects?: SavedObjectsBulkCreateObject<SavedObjectAttributes>[], options?: SavedObjectsBulkCreateOptions) => Promise<SavedObjectsBatchResponse<SavedObjectAttributes>>;
bulkCreate: (objects?: SavedObjectsBulkCreateObject<unknown>[], options?: SavedObjectsBulkCreateOptions) => Promise<SavedObjectsBatchResponse<unknown>>;
bulkGet: (objects?: {
id: string;
type: string;
}[]) => Promise<SavedObjectsBatchResponse<SavedObjectAttributes>>;
bulkUpdate<T extends SavedObjectAttributes>(objects?: SavedObjectsBulkUpdateObject[]): Promise<SavedObjectsBatchResponse<SavedObjectAttributes>>;
create: <T extends SavedObjectAttributes>(type: string, attributes: T, options?: SavedObjectsCreateOptions) => Promise<SimpleSavedObject<T>>;
}[]) => Promise<SavedObjectsBatchResponse<unknown>>;
bulkUpdate<T = unknown>(objects?: SavedObjectsBulkUpdateObject[]): Promise<SavedObjectsBatchResponse<unknown>>;
create: <T = unknown>(type: string, attributes: T, options?: SavedObjectsCreateOptions) => Promise<SimpleSavedObject<T>>;
delete: (type: string, id: string) => Promise<{}>;
find: <T extends SavedObjectAttributes>(options: Pick<SavedObjectsFindOptions, "search" | "filter" | "type" | "page" | "perPage" | "sortField" | "fields" | "searchFields" | "hasReference" | "defaultSearchOperator">) => Promise<SavedObjectsFindResponsePublic<T>>;
get: <T extends SavedObjectAttributes>(type: string, id: string) => Promise<SimpleSavedObject<T>>;
update<T extends SavedObjectAttributes>(type: string, id: string, attributes: T, { version, migrationVersion, references }?: SavedObjectsUpdateOptions): Promise<SimpleSavedObject<T>>;
find: <T = unknown>(options: Pick<SavedObjectsFindOptions, "search" | "filter" | "type" | "page" | "perPage" | "sortField" | "fields" | "searchFields" | "hasReference" | "defaultSearchOperator">) => Promise<SavedObjectsFindResponsePublic<T>>;
get: <T = unknown>(type: string, id: string) => Promise<SimpleSavedObject<T>>;
update<T = unknown>(type: string, id: string, attributes: T, { version, migrationVersion, references }?: SavedObjectsUpdateOptions): Promise<SimpleSavedObject<T>>;
}
// @public
@ -1069,7 +1069,7 @@ export interface SavedObjectsFindOptions extends SavedObjectsBaseOptions {
}
// @public
export interface SavedObjectsFindResponsePublic<T extends SavedObjectAttributes = SavedObjectAttributes> extends SavedObjectsBatchResponse<T> {
export interface SavedObjectsFindResponsePublic<T = unknown> extends SavedObjectsBatchResponse<T> {
// (undocumented)
page: number;
// (undocumented)
@ -1176,7 +1176,7 @@ export interface SavedObjectsUpdateOptions {
}
// @public
export class SimpleSavedObject<T extends SavedObjectAttributes> {
export class SimpleSavedObject<T = unknown> {
constructor(client: SavedObjectsClientContract, { id, type, version, attributes, error, references, migrationVersion }: SavedObject<T>);
// (undocumented)
attributes: T;

View file

@ -22,7 +22,6 @@ import { resolve as resolveUrl } from 'url';
import {
SavedObject,
SavedObjectAttributes,
SavedObjectReference,
SavedObjectsClientContract as SavedObjectsApi,
SavedObjectsFindOptions as SavedObjectFindOptionsServer,
@ -61,9 +60,7 @@ export interface SavedObjectsCreateOptions {
*
* @public
*/
export interface SavedObjectsBulkCreateObject<
T extends SavedObjectAttributes = SavedObjectAttributes
> extends SavedObjectsCreateOptions {
export interface SavedObjectsBulkCreateObject<T = unknown> extends SavedObjectsCreateOptions {
type: string;
attributes: T;
}
@ -75,9 +72,7 @@ export interface SavedObjectsBulkCreateOptions {
}
/** @public */
export interface SavedObjectsBulkUpdateObject<
T extends SavedObjectAttributes = SavedObjectAttributes
> {
export interface SavedObjectsBulkUpdateObject<T = unknown> {
type: string;
id: string;
attributes: T;
@ -99,9 +94,7 @@ export interface SavedObjectsUpdateOptions {
}
/** @public */
export interface SavedObjectsBatchResponse<
T extends SavedObjectAttributes = SavedObjectAttributes
> {
export interface SavedObjectsBatchResponse<T = unknown> {
savedObjects: Array<SimpleSavedObject<T>>;
}
@ -113,9 +106,7 @@ export interface SavedObjectsBatchResponse<
*
* @public
*/
export interface SavedObjectsFindResponsePublic<
T extends SavedObjectAttributes = SavedObjectAttributes
> extends SavedObjectsBatchResponse<T> {
export interface SavedObjectsFindResponsePublic<T = unknown> extends SavedObjectsBatchResponse<T> {
total: number;
perPage: number;
page: number;
@ -124,7 +115,7 @@ export interface SavedObjectsFindResponsePublic<
interface BatchQueueEntry {
type: string;
id: string;
resolve: <T extends SavedObjectAttributes>(value: SimpleSavedObject<T> | SavedObject<T>) => void;
resolve: <T = unknown>(value: SimpleSavedObject<T> | SavedObject<T>) => void;
reject: (reason?: any) => void;
}
@ -207,7 +198,7 @@ export class SavedObjectsClient {
* @param options
* @returns
*/
public create = <T extends SavedObjectAttributes>(
public create = <T = unknown>(
type: string,
attributes: T,
options: SavedObjectsCreateOptions = {}
@ -300,7 +291,7 @@ export class SavedObjectsClient {
* @property {object} [options.hasReference] - { type, id }
* @returns A find result with objects matching the specified search.
*/
public find = <T extends SavedObjectAttributes>(
public find = <T = unknown>(
options: SavedObjectsFindOptions
): Promise<SavedObjectsFindResponsePublic<T>> => {
const path = this.getPath(['_find']);
@ -348,10 +339,7 @@ export class SavedObjectsClient {
* @param {string} id
* @returns The saved object for the given type and id.
*/
public get = <T extends SavedObjectAttributes>(
type: string,
id: string
): Promise<SimpleSavedObject<T>> => {
public get = <T = unknown>(type: string, id: string): Promise<SimpleSavedObject<T>> => {
if (!type || !id) {
return Promise.reject(new Error('requires type and id'));
}
@ -402,7 +390,7 @@ export class SavedObjectsClient {
* @prop {object} options.migrationVersion - The optional migrationVersion of this document
* @returns
*/
public update<T extends SavedObjectAttributes>(
public update<T = unknown>(
type: string,
id: string,
attributes: T,
@ -434,7 +422,7 @@ export class SavedObjectsClient {
* @param {array} objects - [{ type, id, attributes, options: { version, references } }]
* @returns The result of the update operation containing both failed and updated saved objects.
*/
public bulkUpdate<T extends SavedObjectAttributes>(objects: SavedObjectsBulkUpdateObject[] = []) {
public bulkUpdate<T = unknown>(objects: SavedObjectsBulkUpdateObject[] = []) {
const path = this.getPath(['_bulk_update']);
return this.savedObjectsFetch(path, {
@ -449,9 +437,7 @@ export class SavedObjectsClient {
});
}
private createSavedObject<T extends SavedObjectAttributes>(
options: SavedObject<T>
): SimpleSavedObject<T> {
private createSavedObject<T = unknown>(options: SavedObject<T>): SimpleSavedObject<T> {
return new SimpleSavedObject(this, options);
}

View file

@ -18,7 +18,7 @@
*/
import { get, has, set } from 'lodash';
import { SavedObject as SavedObjectType, SavedObjectAttributes } from '../../server';
import { SavedObject as SavedObjectType } from '../../server';
import { SavedObjectsClientContract } from './saved_objects_client';
/**
@ -30,7 +30,7 @@ import { SavedObjectsClientContract } from './saved_objects_client';
*
* @public
*/
export class SimpleSavedObject<T extends SavedObjectAttributes> {
export class SimpleSavedObject<T = unknown> {
public attributes: T;
// We want to use the same interface this class had in JS
public _version?: SavedObjectType<T>['version'];
@ -46,7 +46,7 @@ export class SimpleSavedObject<T extends SavedObjectAttributes> {
) {
this.id = id;
this.type = type;
this.attributes = attributes || {};
this.attributes = attributes || ({} as T);
this.references = references || [];
this._version = version;
this.migrationVersion = migrationVersion;

View file

@ -42,10 +42,10 @@ export async function collectSavedObjects({
supportedTypes,
}: CollectSavedObjectsOptions) {
const errors: SavedObjectsImportError[] = [];
const collectedObjects: SavedObject[] = await createPromiseFromStreams([
const collectedObjects: Array<SavedObject<{ title: string }>> = await createPromiseFromStreams([
readStream,
createLimitStream(objectLimit),
createFilterStream<SavedObject>(obj => {
createFilterStream<SavedObject<{ title: string }>>(obj => {
if (supportedTypes.includes(obj.type)) {
return true;
}

View file

@ -20,11 +20,12 @@ import { SavedObject } from '../types';
import { SavedObjectsImportError } from './types';
export function extractErrors(
savedObjectResults: SavedObject[],
savedObjectsToImport: SavedObject[]
// TODO: define saved object type
savedObjectResults: Array<SavedObject<any>>,
savedObjectsToImport: Array<SavedObject<any>>
) {
const errors: SavedObjectsImportError[] = [];
const originalSavedObjectsMap = new Map<string, SavedObject>();
const originalSavedObjectsMap = new Map<string, SavedObject<{ title: string }>>();
for (const savedObject of savedObjectsToImport) {
originalSavedObjectsMap.set(`${savedObject.type}:${savedObject.id}`, savedObject);
}

View file

@ -77,7 +77,7 @@ export async function getNonExistingReferenceAsKeys(
}
export async function validateReferences(
savedObjects: SavedObject[],
savedObjects: Array<SavedObject<{ title?: string }>>,
savedObjectsClient: SavedObjectsClientContract,
namespace?: string
) {

View file

@ -23,9 +23,9 @@ interface SavedObjectsManagementTypeDefinition {
isImportableAndExportable?: boolean;
defaultSearchField?: string;
icon?: string;
getTitle?: (savedObject: SavedObject) => string;
getEditUrl?: (savedObject: SavedObject) => string;
getInAppUrl?: (savedObject: SavedObject) => { path: string; uiCapabilitiesPath: string };
getTitle?: (savedObject: SavedObject<any>) => string;
getEditUrl?: (savedObject: SavedObject<any>) => string;
getInAppUrl?: (savedObject: SavedObject<any>) => { path: string; uiCapabilitiesPath: string };
}
export interface SavedObjectsManagementDefinition {

View file

@ -50,7 +50,7 @@ export interface SavedObjectsRawDocSource {
* scenario out of the box.
*/
interface SavedObjectDoc {
attributes: object;
attributes: unknown;
id?: string; // NOTE: SavedObjectDoc is used for uncreated objects where `id` is optional
type: string;
namespace?: string;

View file

@ -47,7 +47,6 @@ import {
} from '../saved_objects_client';
import {
SavedObject,
SavedObjectAttributes,
SavedObjectsBaseOptions,
SavedObjectsFindOptions,
SavedObjectsMigrationVersion,
@ -212,7 +211,7 @@ export class SavedObjectsRepository {
* @property {array} [options.references=[]] - [{ name, type, id }]
* @returns {promise} - { id, type, version, attributes }
*/
public async create<T extends SavedObjectAttributes>(
public async create<T = unknown>(
type: string,
attributes: T,
options: SavedObjectsCreateOptions = {}
@ -253,7 +252,7 @@ export class SavedObjectsRepository {
body: raw._source,
});
return this._rawToSavedObject({
return this._rawToSavedObject<T>({
...raw,
...response,
});
@ -276,7 +275,7 @@ export class SavedObjectsRepository {
* @property {string} [options.namespace]
* @returns {promise} - {saved_objects: [[{ id, type, version, references, attributes, error: { message } }]}
*/
async bulkCreate<T extends SavedObjectAttributes = any>(
async bulkCreate<T = unknown>(
objects: Array<SavedObjectsBulkCreateObject<T>>,
options: SavedObjectsCreateOptions = {}
): Promise<SavedObjectsBulkResponse<T>> {
@ -463,7 +462,7 @@ export class SavedObjectsRepository {
* @property {object} [options.hasReference] - { type, id }
* @returns {promise} - { saved_objects: [{ id, type, version, attributes }], total, per_page, page }
*/
async find<T extends SavedObjectAttributes = any>({
async find<T = unknown>({
search,
defaultSearchOperator = 'OR',
searchFields,
@ -576,7 +575,7 @@ export class SavedObjectsRepository {
* { id: 'foo', type: 'index-pattern' }
* ])
*/
async bulkGet<T extends SavedObjectAttributes = any>(
async bulkGet<T = unknown>(
objects: SavedObjectsBulkGetObject[] = [],
options: SavedObjectsBaseOptions = {}
): Promise<SavedObjectsBulkResponse<T>> {
@ -647,7 +646,7 @@ export class SavedObjectsRepository {
* @property {string} [options.namespace]
* @returns {promise} - { id, type, version, attributes }
*/
async get<T extends SavedObjectAttributes = any>(
async get<T = unknown>(
type: string,
id: string,
options: SavedObjectsBaseOptions = {}
@ -695,7 +694,7 @@ export class SavedObjectsRepository {
* @property {array} [options.references] - [{ name, type, id }]
* @returns {promise}
*/
async update<T extends SavedObjectAttributes = any>(
async update<T = unknown>(
type: string,
id: string,
attributes: Partial<T>,
@ -752,7 +751,7 @@ export class SavedObjectsRepository {
* @property {string} [options.namespace]
* @returns {promise} - {saved_objects: [[{ id, type, version, references, attributes, error: { message } }]}
*/
async bulkUpdate<T extends SavedObjectAttributes = any>(
async bulkUpdate<T = unknown>(
objects: Array<SavedObjectsBulkUpdateObject<T>>,
options: SavedObjectsBulkUpdateOptions = {}
): Promise<SavedObjectsBulkUpdateResponse<T>> {
@ -971,7 +970,7 @@ export class SavedObjectsRepository {
// includes the namespace, and we use this for migrating documents. However, we don't
// want the namespace to be returned from the repository, as the repository scopes each
// method transparently to the specified namespace.
private _rawToSavedObject(raw: SavedObjectsRawDoc): SavedObject {
private _rawToSavedObject<T = unknown>(raw: SavedObjectsRawDoc): SavedObject<T> {
const savedObject = this._serializer.rawToSavedObject(raw);
return omit(savedObject, 'namespace');
}

View file

@ -20,7 +20,6 @@
import { ISavedObjectsRepository } from './lib';
import {
SavedObject,
SavedObjectAttributes,
SavedObjectReference,
SavedObjectsMigrationVersion,
SavedObjectsBaseOptions,
@ -49,7 +48,7 @@ export interface SavedObjectsCreateOptions extends SavedObjectsBaseOptions {
*
* @public
*/
export interface SavedObjectsBulkCreateObject<T extends SavedObjectAttributes = any> {
export interface SavedObjectsBulkCreateObject<T = unknown> {
id?: string;
type: string;
attributes: T;
@ -62,7 +61,7 @@ export interface SavedObjectsBulkCreateObject<T extends SavedObjectAttributes =
*
* @public
*/
export interface SavedObjectsBulkUpdateObject<T extends SavedObjectAttributes = any>
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;
@ -76,7 +75,7 @@ export interface SavedObjectsBulkUpdateObject<T extends SavedObjectAttributes =
*
* @public
*/
export interface SavedObjectsBulkResponse<T extends SavedObjectAttributes = any> {
export interface SavedObjectsBulkResponse<T = unknown> {
saved_objects: Array<SavedObject<T>>;
}
@ -88,7 +87,7 @@ export interface SavedObjectsBulkResponse<T extends SavedObjectAttributes = any>
*
* @public
*/
export interface SavedObjectsFindResponse<T extends SavedObjectAttributes = any> {
export interface SavedObjectsFindResponse<T = unknown> {
saved_objects: Array<SavedObject<T>>;
total: number;
per_page: number;
@ -141,7 +140,7 @@ export interface SavedObjectsBulkGetObject {
*
* @public
*/
export interface SavedObjectsBulkResponse<T extends SavedObjectAttributes = any> {
export interface SavedObjectsBulkResponse<T = unknown> {
saved_objects: Array<SavedObject<T>>;
}
@ -149,7 +148,7 @@ export interface SavedObjectsBulkResponse<T extends SavedObjectAttributes = any>
*
* @public
*/
export interface SavedObjectsBulkUpdateResponse<T extends SavedObjectAttributes = any> {
export interface SavedObjectsBulkUpdateResponse<T = unknown> {
saved_objects: Array<SavedObjectsUpdateResponse<T>>;
}
@ -157,7 +156,7 @@ export interface SavedObjectsBulkUpdateResponse<T extends SavedObjectAttributes
*
* @public
*/
export interface SavedObjectsUpdateResponse<T extends SavedObjectAttributes = any>
export interface SavedObjectsUpdateResponse<T = unknown>
extends Omit<SavedObject<T>, 'attributes' | 'references'> {
attributes: Partial<T>;
references: SavedObjectReference[] | undefined;
@ -185,11 +184,7 @@ export class SavedObjectsClient {
* @param attributes
* @param options
*/
async create<T extends SavedObjectAttributes = any>(
type: string,
attributes: T,
options?: SavedObjectsCreateOptions
) {
async create<T = unknown>(type: string, attributes: T, options?: SavedObjectsCreateOptions) {
return await this._repository.create(type, attributes, options);
}
@ -199,7 +194,7 @@ export class SavedObjectsClient {
* @param objects
* @param options
*/
async bulkCreate<T extends SavedObjectAttributes = any>(
async bulkCreate<T = unknown>(
objects: Array<SavedObjectsBulkCreateObject<T>>,
options?: SavedObjectsCreateOptions
) {
@ -222,9 +217,7 @@ export class SavedObjectsClient {
*
* @param options
*/
async find<T extends SavedObjectAttributes = any>(
options: SavedObjectsFindOptions
): Promise<SavedObjectsFindResponse<T>> {
async find<T = unknown>(options: SavedObjectsFindOptions): Promise<SavedObjectsFindResponse<T>> {
return await this._repository.find(options);
}
@ -239,7 +232,7 @@ export class SavedObjectsClient {
* { id: 'foo', type: 'index-pattern' }
* ])
*/
async bulkGet<T extends SavedObjectAttributes = any>(
async bulkGet<T = unknown>(
objects: SavedObjectsBulkGetObject[] = [],
options: SavedObjectsBaseOptions = {}
): Promise<SavedObjectsBulkResponse<T>> {
@ -253,7 +246,7 @@ export class SavedObjectsClient {
* @param id - The ID of the SavedObject to retrieve
* @param options
*/
async get<T extends SavedObjectAttributes = any>(
async get<T = unknown>(
type: string,
id: string,
options: SavedObjectsBaseOptions = {}
@ -268,7 +261,7 @@ export class SavedObjectsClient {
* @param id
* @param options
*/
async update<T extends SavedObjectAttributes = any>(
async update<T = unknown>(
type: string,
id: string,
attributes: Partial<T>,
@ -282,7 +275,7 @@ export class SavedObjectsClient {
*
* @param objects
*/
async bulkUpdate<T extends SavedObjectAttributes = any>(
async bulkUpdate<T = unknown>(
objects: Array<SavedObjectsBulkUpdateObject<T>>,
options?: SavedObjectsBulkUpdateOptions
): Promise<SavedObjectsBulkUpdateResponse<T>> {

View file

@ -33,7 +33,6 @@ export {
SavedObjectsImportRetry,
} from './import/types';
import { SavedObjectAttributes } from '../../types';
import { LegacyConfig } from '../legacy';
export {
SavedObjectAttributes,
@ -64,7 +63,7 @@ export interface SavedObjectsMigrationVersion {
*
* @public
*/
export interface SavedObject<T extends SavedObjectAttributes = any> {
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. */

View file

@ -1462,7 +1462,7 @@ export interface RouteValidatorOptions {
}
// @public (undocumented)
export interface SavedObject<T extends SavedObjectAttributes = any> {
export interface SavedObject<T = unknown> {
attributes: T;
// (undocumented)
error?: {
@ -1524,7 +1524,7 @@ export interface SavedObjectsBaseOptions {
}
// @public (undocumented)
export interface SavedObjectsBulkCreateObject<T extends SavedObjectAttributes = any> {
export interface SavedObjectsBulkCreateObject<T = unknown> {
// (undocumented)
attributes: T;
// (undocumented)
@ -1546,19 +1546,19 @@ export interface SavedObjectsBulkGetObject {
}
// @public (undocumented)
export interface SavedObjectsBulkResponse<T extends SavedObjectAttributes = any> {
export interface SavedObjectsBulkResponse<T = unknown> {
// (undocumented)
saved_objects: Array<SavedObject<T>>;
}
// @public (undocumented)
export interface SavedObjectsBulkResponse<T extends SavedObjectAttributes = any> {
export interface SavedObjectsBulkResponse<T = unknown> {
// (undocumented)
saved_objects: Array<SavedObject<T>>;
}
// @public (undocumented)
export interface SavedObjectsBulkUpdateObject<T extends SavedObjectAttributes = any> extends Pick<SavedObjectsUpdateOptions, 'version' | 'references'> {
export interface SavedObjectsBulkUpdateObject<T = unknown> extends Pick<SavedObjectsUpdateOptions, 'version' | 'references'> {
attributes: Partial<T>;
id: string;
type: string;
@ -1570,7 +1570,7 @@ export interface SavedObjectsBulkUpdateOptions extends SavedObjectsBaseOptions {
}
// @public (undocumented)
export interface SavedObjectsBulkUpdateResponse<T extends SavedObjectAttributes = any> {
export interface SavedObjectsBulkUpdateResponse<T = unknown> {
// (undocumented)
saved_objects: Array<SavedObjectsUpdateResponse<T>>;
}
@ -1579,18 +1579,18 @@ export interface SavedObjectsBulkUpdateResponse<T extends SavedObjectAttributes
export class SavedObjectsClient {
// @internal
constructor(repository: ISavedObjectsRepository);
bulkCreate<T extends SavedObjectAttributes = any>(objects: Array<SavedObjectsBulkCreateObject<T>>, options?: SavedObjectsCreateOptions): Promise<SavedObjectsBulkResponse<T>>;
bulkGet<T extends SavedObjectAttributes = any>(objects?: SavedObjectsBulkGetObject[], options?: SavedObjectsBaseOptions): Promise<SavedObjectsBulkResponse<T>>;
bulkUpdate<T extends SavedObjectAttributes = any>(objects: Array<SavedObjectsBulkUpdateObject<T>>, options?: SavedObjectsBulkUpdateOptions): Promise<SavedObjectsBulkUpdateResponse<T>>;
create<T extends SavedObjectAttributes = any>(type: string, attributes: T, options?: SavedObjectsCreateOptions): Promise<SavedObject<T>>;
bulkCreate<T = unknown>(objects: Array<SavedObjectsBulkCreateObject<T>>, options?: SavedObjectsCreateOptions): Promise<SavedObjectsBulkResponse<T>>;
bulkGet<T = unknown>(objects?: SavedObjectsBulkGetObject[], options?: SavedObjectsBaseOptions): Promise<SavedObjectsBulkResponse<T>>;
bulkUpdate<T = unknown>(objects: Array<SavedObjectsBulkUpdateObject<T>>, options?: SavedObjectsBulkUpdateOptions): Promise<SavedObjectsBulkUpdateResponse<T>>;
create<T = unknown>(type: string, attributes: T, options?: SavedObjectsCreateOptions): Promise<SavedObject<T>>;
delete(type: string, id: string, options?: SavedObjectsDeleteOptions): Promise<{}>;
// (undocumented)
static errors: typeof SavedObjectsErrorHelpers;
// (undocumented)
errors: typeof SavedObjectsErrorHelpers;
find<T extends SavedObjectAttributes = any>(options: SavedObjectsFindOptions): Promise<SavedObjectsFindResponse<T>>;
get<T extends SavedObjectAttributes = any>(type: string, id: string, options?: SavedObjectsBaseOptions): Promise<SavedObject<T>>;
update<T extends SavedObjectAttributes = any>(type: string, id: string, attributes: Partial<T>, options?: SavedObjectsUpdateOptions): Promise<SavedObjectsUpdateResponse<T>>;
find<T = unknown>(options: SavedObjectsFindOptions): Promise<SavedObjectsFindResponse<T>>;
get<T = unknown>(type: string, id: string, options?: SavedObjectsBaseOptions): Promise<SavedObject<T>>;
update<T = unknown>(type: string, id: string, attributes: Partial<T>, options?: SavedObjectsUpdateOptions): Promise<SavedObjectsUpdateResponse<T>>;
}
// @public
@ -1772,7 +1772,7 @@ export interface SavedObjectsFindOptions extends SavedObjectsBaseOptions {
}
// @public
export interface SavedObjectsFindResponse<T extends SavedObjectAttributes = any> {
export interface SavedObjectsFindResponse<T = unknown> {
// (undocumented)
page: number;
// (undocumented)
@ -1951,10 +1951,10 @@ export interface SavedObjectsRawDoc {
// @public (undocumented)
export class SavedObjectsRepository {
bulkCreate<T extends SavedObjectAttributes = any>(objects: Array<SavedObjectsBulkCreateObject<T>>, options?: SavedObjectsCreateOptions): Promise<SavedObjectsBulkResponse<T>>;
bulkGet<T extends SavedObjectAttributes = any>(objects?: SavedObjectsBulkGetObject[], options?: SavedObjectsBaseOptions): Promise<SavedObjectsBulkResponse<T>>;
bulkUpdate<T extends SavedObjectAttributes = any>(objects: Array<SavedObjectsBulkUpdateObject<T>>, options?: SavedObjectsBulkUpdateOptions): Promise<SavedObjectsBulkUpdateResponse<T>>;
create<T extends SavedObjectAttributes>(type: string, attributes: T, options?: SavedObjectsCreateOptions): Promise<SavedObject<T>>;
bulkCreate<T = unknown>(objects: Array<SavedObjectsBulkCreateObject<T>>, options?: SavedObjectsCreateOptions): Promise<SavedObjectsBulkResponse<T>>;
bulkGet<T = unknown>(objects?: SavedObjectsBulkGetObject[], options?: SavedObjectsBaseOptions): Promise<SavedObjectsBulkResponse<T>>;
bulkUpdate<T = unknown>(objects: Array<SavedObjectsBulkUpdateObject<T>>, options?: SavedObjectsBulkUpdateOptions): Promise<SavedObjectsBulkUpdateResponse<T>>;
create<T = unknown>(type: string, attributes: T, options?: SavedObjectsCreateOptions): Promise<SavedObject<T>>;
// Warning: (ae-forgotten-export) The symbol "KibanaMigrator" needs to be exported by the entry point index.d.ts
//
// @internal
@ -1962,8 +1962,8 @@ export class SavedObjectsRepository {
delete(type: string, id: string, options?: SavedObjectsDeleteOptions): Promise<{}>;
deleteByNamespace(namespace: string, options?: SavedObjectsDeleteByNamespaceOptions): Promise<any>;
// (undocumented)
find<T extends SavedObjectAttributes = any>({ search, defaultSearchOperator, searchFields, hasReference, page, perPage, sortField, sortOrder, fields, namespace, type, filter, }: SavedObjectsFindOptions): Promise<SavedObjectsFindResponse<T>>;
get<T extends SavedObjectAttributes = any>(type: string, id: string, options?: SavedObjectsBaseOptions): Promise<SavedObject<T>>;
find<T = unknown>({ search, defaultSearchOperator, searchFields, hasReference, page, perPage, sortField, sortOrder, fields, namespace, type, filter, }: SavedObjectsFindOptions): Promise<SavedObjectsFindResponse<T>>;
get<T = unknown>(type: string, id: string, options?: SavedObjectsBaseOptions): Promise<SavedObject<T>>;
incrementCounter(type: string, id: string, counterFieldName: string, options?: SavedObjectsIncrementCounterOptions): Promise<{
id: string;
type: string;
@ -1972,7 +1972,7 @@ export class SavedObjectsRepository {
version: string;
attributes: any;
}>;
update<T extends SavedObjectAttributes = any>(type: string, id: string, attributes: Partial<T>, options?: SavedObjectsUpdateOptions): Promise<SavedObjectsUpdateResponse<T>>;
update<T = unknown>(type: string, id: string, attributes: Partial<T>, options?: SavedObjectsUpdateOptions): Promise<SavedObjectsUpdateResponse<T>>;
}
// @public
@ -2062,7 +2062,7 @@ export interface SavedObjectsUpdateOptions extends SavedObjectsBaseOptions {
}
// @public (undocumented)
export interface SavedObjectsUpdateResponse<T extends SavedObjectAttributes = any> extends Omit<SavedObject<T>, 'attributes' | 'references'> {
export interface SavedObjectsUpdateResponse<T = unknown> extends Omit<SavedObject<T>, 'attributes' | 'references'> {
// (undocumented)
attributes: Partial<T>;
// (undocumented)

View file

@ -45,7 +45,10 @@ export async function createOrUpgradeSavedConfig(
});
// default to the attributes of the upgradeableConfig if available
const attributes = defaults({ buildNum }, upgradeableConfig ? upgradeableConfig.attributes : {});
const attributes = defaults(
{ buildNum },
upgradeableConfig ? (upgradeableConfig.attributes as any) : {}
);
try {
// create the new SavedConfig

View file

@ -185,7 +185,7 @@ export class UiSettingsClient implements IUiSettingsClient {
autoCreateOrUpgradeIfMissing = true,
}: ReadOptions = {}): Promise<Record<string, any>> {
try {
const resp = await this.savedObjectsClient.get(this.type, this.id);
const resp = await this.savedObjectsClient.get<Record<string, any>>(this.type, this.id);
return resp.attributes;
} catch (error) {
if (SavedObjectsErrorHelpers.isNotFoundError(error) && autoCreateOrUpgradeIfMissing) {

View file

@ -31,14 +31,14 @@ const indexPattern1 = {
attributes: {
title: 'test1 title',
},
} as SavedObject;
} as SavedObject<any>;
const indexPattern2 = {
id: 'test2',
attributes: {
title: 'test2 title',
},
} as SavedObject;
} as SavedObject<any>;
const defaultProps = {
indexPatternList: [indexPattern1, indexPattern2],

View file

@ -18,6 +18,7 @@
*/
import React, { useState } from 'react';
import { SavedObject } from 'kibana/server';
import { IndexPatternAttributes } from 'src/plugins/data/public';
import { I18nProvider } from '@kbn/i18n/react';
import { IndexPatternRef } from './types';
@ -26,11 +27,11 @@ export interface DiscoverIndexPatternProps {
/**
* list of available index patterns, if length > 1, component offers a "change" link
*/
indexPatternList: SavedObject[];
indexPatternList: Array<SavedObject<IndexPatternAttributes>>;
/**
* currently selected index pattern, due to angular issues it's undefined at first rendering
*/
selectedIndexPattern: SavedObject;
selectedIndexPattern: SavedObject<IndexPatternAttributes>;
/**
* triggered when user selects a new index pattern
*/

View file

@ -24,6 +24,7 @@ import { FormattedMessage } from '@kbn/i18n/react';
import {
indexPatterns,
DataPublicPluginStart,
IndexPatternAttributes,
} from '../../../../../../../../../../plugins/data/public';
import { SavedObjectsClient, IUiSettingsClient } from '../../../../../../../../../../core/public';
import { MAX_SEARCH_SIZE } from '../../constants';
@ -96,7 +97,7 @@ export class StepIndexPattern extends Component<StepIndexPatternProps, StepIndex
}
fetchExistingIndexPatterns = async () => {
const { savedObjects } = await this.props.savedObjectsClient.find({
const { savedObjects } = await this.props.savedObjectsClient.find<IndexPatternAttributes>({
type: 'index-pattern',
fields: ['title'],
perPage: 10000,

View file

@ -20,7 +20,10 @@
import { get } from 'lodash';
import { getIndexPatterns, getSavedObjectsClient } from './plugin_services';
import { TimelionFunctionArgs } from '../../../../../plugins/timelion/common/types';
import { indexPatterns as indexPatternsUtils } from '../../../../../plugins/data/public';
import {
indexPatterns as indexPatternsUtils,
IndexPatternAttributes,
} from '../../../../../plugins/data/public';
export interface Location {
min: number;
@ -53,7 +56,7 @@ export function getArgValueSuggestions() {
}
const indexPatternTitle = get(indexPatternArg, 'value.text');
const { savedObjects } = await savedObjectsClient.find({
const { savedObjects } = await savedObjectsClient.find<IndexPatternAttributes>({
type: 'index-pattern',
fields: ['title'],
search: `"${indexPatternTitle}"`,
@ -84,7 +87,7 @@ export function getArgValueSuggestions() {
es: {
async index(partial: string) {
const search = partial ? `${partial}*` : '*';
const resp = await savedObjectsClient.find({
const resp = await savedObjectsClient.find<IndexPatternAttributes>({
type: 'index-pattern',
fields: ['title', 'type'],
search: `${search}`,

View file

@ -18,7 +18,11 @@
*/
import { VisSavedObject } from './visualize_embeddable';
import { indexPatterns, IIndexPattern } from '../../../../../plugins/data/public';
import {
indexPatterns,
IIndexPattern,
IndexPatternAttributes,
} from '../../../../../plugins/data/public';
import { getUISettings, getSavedObjects } from '../np_ready/public/services';
export async function getIndexPattern(
@ -32,7 +36,7 @@ export async function getIndexPattern(
const defaultIndex = getUISettings().get('defaultIndex');
if (savedVis.vis.params.index_pattern) {
const indexPatternObjects = await savedObjectsClient.find({
const indexPatternObjects = await savedObjectsClient.find<IndexPatternAttributes>({
type: 'index-pattern',
fields: ['title', 'fields'],
search: `"${savedVis.vis.params.index_pattern}"`,
@ -42,6 +46,9 @@ export async function getIndexPattern(
return indexPattern;
}
const savedObject = await savedObjectsClient.get('index-pattern', defaultIndex);
const savedObject = await savedObjectsClient.get<IndexPatternAttributes>(
'index-pattern',
defaultIndex
);
return indexPatterns.getFromSavedObject(savedObject);
}

View file

@ -35,3 +35,15 @@ export interface IIndexPattern {
}
>;
}
/**
* Use data plugin interface instead
* @deprecated
*/
export interface IndexPatternAttributes {
type: string;
fields: string;
title: string;
typeMeta: string;
timeFieldName?: string;
}

View file

@ -263,6 +263,7 @@ export {
IFieldSubType,
ES_FIELD_TYPES,
KBN_FIELD_TYPES,
IndexPatternAttributes,
} from '../common';
/*

View file

@ -50,7 +50,7 @@ export class IndexPatternsService {
private async refreshSavedObjectsCache() {
this.savedObjectsCache = (
await this.savedObjectsClient.find({
await this.savedObjectsClient.find<Record<string, any>>({
type: 'index-pattern',
fields: ['title'],
perPage: 10000,

View file

@ -17,17 +17,20 @@
* under the License.
*/
import { SavedObject } from 'src/core/public';
import { get } from 'lodash';
import { IIndexPattern } from '../..';
import { IIndexPattern, IndexPatternAttributes } from '../..';
export function getFromSavedObject(savedObject: any): IIndexPattern | undefined {
export function getFromSavedObject(
savedObject: SavedObject<IndexPatternAttributes>
): IIndexPattern | undefined {
if (get(savedObject, 'attributes.fields') === undefined) {
return;
}
return {
id: savedObject.id,
fields: JSON.parse(savedObject.attributes.fields),
fields: JSON.parse(savedObject.attributes.fields!),
title: savedObject.attributes.title,
};
}

View file

@ -18,7 +18,7 @@
*/
import { isEmpty } from 'lodash';
import { IUiSettingsClient, SavedObjectsClientContract } from 'src/core/public';
import { indexPatterns } from '../..';
import { indexPatterns, IndexPatternAttributes } from '../..';
export async function fetchIndexPatterns(
savedObjectsClient: SavedObjectsClientContract,
@ -30,7 +30,7 @@ export async function fetchIndexPatterns(
}
const searchString = indexPatternStrings.map(string => `"${string}"`).join(' | ');
const indexPatternsFromSavedObjects = await savedObjectsClient.find({
const indexPatternsFromSavedObjects = await savedObjectsClient.find<IndexPatternAttributes>({
type: 'index-pattern',
fields: ['title', 'fields'],
search: searchString,
@ -38,7 +38,7 @@ export async function fetchIndexPatterns(
});
const exactMatches = indexPatternsFromSavedObjects.savedObjects.filter(savedObject => {
return indexPatternStrings.includes(savedObject.attributes.title as string);
return indexPatternStrings.includes(savedObject.attributes.title);
});
const defaultIndex = uiSettings.get('defaultIndex');
@ -46,7 +46,10 @@ export async function fetchIndexPatterns(
const allMatches =
exactMatches.length === indexPatternStrings.length
? exactMatches
: [...exactMatches, await savedObjectsClient.get('index-pattern', defaultIndex)];
: [
...exactMatches,
await savedObjectsClient.get<IndexPatternAttributes>('index-pattern', defaultIndex),
];
return allMatches.map(indexPatterns.getFromSavedObject);
}

View file

@ -142,6 +142,7 @@ export {
IFieldSubType,
ES_FIELD_TYPES,
KBN_FIELD_TYPES,
IndexPatternAttributes,
} from '../common';
/**

View file

@ -67,7 +67,7 @@ export interface AppLinkSchema {
label: string;
}
export interface SampleDatasetSchema {
export interface SampleDatasetSchema<T = unknown> {
id: string;
name: string;
description: string;
@ -83,7 +83,7 @@ export interface SampleDatasetSchema {
// Kibana saved objects (index patter, visualizations, dashboard, ...)
// Should provide a nice demo of Kibana's functionality with the sample data set
savedObjects: SavedObject[];
savedObjects: Array<SavedObject<T>>;
dataIndices: DataIndexSchema[];
status?: string | undefined;
statusMsg?: unknown;

View file

@ -137,9 +137,9 @@ export class SampleDataRegistry {
throw new Error(`Unable to find sample dataset with id: ${sampleDataId}`);
}
const dashboard = sampleDataset.savedObjects.find((savedObject: SavedObject) => {
const dashboard = sampleDataset.savedObjects.find(savedObject => {
return savedObject.id === dashboardId && savedObject.type === 'dashboard';
});
}) as SavedObject<{ panelsJSON: string }>;
if (!dashboard) {
throw new Error(`Unable to find dashboard with id: ${dashboardId}`);
}

View file

@ -43,14 +43,13 @@ import { Direction } from '@elastic/eui/src/services/sort/sort_direction';
import { i18n } from '@kbn/i18n';
import {
SavedObjectAttributes,
SimpleSavedObject,
CoreStart,
IUiSettingsClient,
SavedObjectsStart,
} from '../../../../core/public';
} from 'src/core/public';
export interface SavedObjectMetaData<T extends SavedObjectAttributes> {
export interface SavedObjectMetaData<T = unknown> {
type: string;
name: string;
getIconForSavedObject(savedObject: SimpleSavedObject<T>): IconType;
@ -59,12 +58,17 @@ export interface SavedObjectMetaData<T extends SavedObjectAttributes> {
includeFields?: string[];
}
interface FinderAttributes {
title?: string;
type: string;
}
interface SavedObjectFinderState {
items: Array<{
title: string | null;
id: SimpleSavedObject<SavedObjectAttributes>['id'];
type: SimpleSavedObject<SavedObjectAttributes>['type'];
savedObject: SimpleSavedObject<SavedObjectAttributes>;
id: SimpleSavedObject['id'];
type: SimpleSavedObject['type'];
savedObject: SimpleSavedObject<FinderAttributes>;
}>;
query: string;
isFetchingItems: boolean;
@ -78,13 +82,13 @@ interface SavedObjectFinderState {
interface BaseSavedObjectFinder {
onChoose?: (
id: SimpleSavedObject<SavedObjectAttributes>['id'],
type: SimpleSavedObject<SavedObjectAttributes>['type'],
id: SimpleSavedObject['id'],
type: SimpleSavedObject['type'],
name: string,
savedObject: SimpleSavedObject<SavedObjectAttributes>
savedObject: SimpleSavedObject
) => void;
noItemsMessage?: React.ReactNode;
savedObjectMetaData: Array<SavedObjectMetaData<SavedObjectAttributes>>;
savedObjectMetaData: Array<SavedObjectMetaData<FinderAttributes>>;
showFilter?: boolean;
}
@ -128,7 +132,7 @@ class SavedObjectFinderUi extends React.Component<
.reduce((allFields, currentFields) => allFields.concat(currentFields), ['title']);
const perPage = this.props.uiSettings.get('savedObjects:listingLimit');
const resp = await this.props.savedObjects.client.find({
const resp = await this.props.savedObjects.client.find<FinderAttributes>({
type: Object.keys(metaDataMap),
fields: [...new Set(fields)],
search: query ? `${query}*` : undefined,
@ -163,6 +167,7 @@ class SavedObjectFinderUi extends React.Component<
id,
type,
} = savedObject;
return {
title: typeof title === 'string' ? title : '',
id,
@ -208,7 +213,7 @@ class SavedObjectFinderUi extends React.Component<
);
}
private getSavedObjectMetaDataMap(): Record<string, SavedObjectMetaData<SavedObjectAttributes>> {
private getSavedObjectMetaDataMap(): Record<string, SavedObjectMetaData> {
return this.props.savedObjectMetaData.reduce(
(map, metaData) => ({ ...map, [metaData.type]: metaData }),
{}
@ -470,7 +475,7 @@ class SavedObjectFinderUi extends React.Component<
currentSavedObjectMetaData ||
({
getIconForSavedObject: () => 'document',
} as Pick<SavedObjectMetaData<SavedObjectAttributes>, 'getIconForSavedObject'>)
} as Pick<SavedObjectMetaData<{ title: string }>, 'getIconForSavedObject'>)
).getIconForSavedObject(item.savedObject);
return (
<EuiListGroupItem

View file

@ -124,7 +124,7 @@ export class SavedObjectLoader {
*/
findAll(search: string = '', size: number = 100, fields?: string[]) {
return this.savedObjectsClient
.find({
.find<Record<string, unknown>>({
type: this.lowercaseType,
search: search ? `${search}*` : undefined,
perPage: size,

View file

@ -17,9 +17,10 @@
* under the License.
*/
import { shortUrlLookupProvider, ShortUrlLookupService } from './short_url_lookup';
import { SavedObjectsClientContract, Logger } from 'kibana/server';
import { SavedObjectsClient } from '../../../../../core/server';
import { shortUrlLookupProvider, ShortUrlLookupService, UrlAttributes } from './short_url_lookup';
import { SavedObjectsClientContract, SavedObject } from 'kibana/server';
import { savedObjectsClientMock, loggingServiceMock } from '../../../../../core/server/mocks';
describe('shortUrlLookupProvider', () => {
const ID = 'bf00ad16941fc51420f91a93428b27a0';
@ -31,15 +32,10 @@ describe('shortUrlLookupProvider', () => {
let shortUrl: ShortUrlLookupService;
beforeEach(() => {
savedObjects = ({
get: jest.fn(),
create: jest.fn(() => Promise.resolve({ id: ID })),
update: jest.fn(),
errors: SavedObjectsClient.errors,
} as unknown) as jest.Mocked<SavedObjectsClientContract>;
savedObjects = savedObjectsClientMock.create();
savedObjects.create.mockResolvedValue({ id: ID } as SavedObject<UrlAttributes>);
deps = { savedObjects };
shortUrl = shortUrlLookupProvider({ logger: ({ warn: () => {} } as unknown) as Logger });
shortUrl = shortUrlLookupProvider({ logger: loggingServiceMock.create().get() });
});
describe('generateUrlId', () => {
@ -55,13 +51,13 @@ describe('shortUrlLookupProvider', () => {
const [type, attributes, options] = savedObjects.create.mock.calls[0];
expect(type).toEqual(TYPE);
expect(Object.keys(attributes).sort()).toEqual([
expect(Object.keys(attributes as UrlAttributes).sort()).toEqual([
'accessCount',
'accessDate',
'createDate',
'url',
]);
expect(attributes.url).toEqual(URL);
expect((attributes as UrlAttributes).url).toEqual(URL);
expect(options!.id).toEqual(ID);
});
@ -72,13 +68,13 @@ describe('shortUrlLookupProvider', () => {
const [type, attributes] = savedObjects.create.mock.calls[0];
expect(type).toEqual(TYPE);
expect(Object.keys(attributes).sort()).toEqual([
expect(Object.keys(attributes as UrlAttributes).sort()).toEqual([
'accessCount',
'accessDate',
'createDate',
'url',
]);
expect(attributes.url).toEqual(URL);
expect((attributes as UrlAttributes).url).toEqual(URL);
});
it('gracefully handles version conflict', async () => {
@ -119,7 +115,7 @@ describe('shortUrlLookupProvider', () => {
expect(type).toEqual(TYPE);
expect(id).toEqual(ID);
expect(Object.keys(attributes).sort()).toEqual(['accessCount', 'accessDate']);
expect(attributes.accessCount).toEqual(3);
expect((attributes as UrlAttributes).accessCount).toEqual(3);
});
});
});

View file

@ -27,13 +27,20 @@ export interface ShortUrlLookupService {
getUrl(url: string, deps: { savedObjects: SavedObjectsClientContract }): Promise<string>;
}
export interface UrlAttributes {
url: string;
accessCount: number;
createDate: number;
accessDate: number;
}
export function shortUrlLookupProvider({ logger }: { logger: Logger }): ShortUrlLookupService {
async function updateMetadata(
doc: SavedObject,
doc: SavedObject<UrlAttributes>,
{ savedObjects }: { savedObjects: SavedObjectsClientContract }
) {
try {
await savedObjects.update('url', doc.id, {
await savedObjects.update<UrlAttributes>('url', doc.id, {
accessDate: new Date().valueOf(),
accessCount: get(doc, 'attributes.accessCount', 0) + 1,
});
@ -53,7 +60,7 @@ export function shortUrlLookupProvider({ logger }: { logger: Logger }): ShortUrl
const { isConflictError } = savedObjects.errors;
try {
const doc = await savedObjects.create(
const doc = await savedObjects.create<UrlAttributes>(
'url',
{
url,
@ -75,7 +82,7 @@ export function shortUrlLookupProvider({ logger }: { logger: Logger }): ShortUrl
},
async getUrl(id, { savedObjects }) {
const doc = await savedObjects.get('url', id);
const doc = await savedObjects.get<UrlAttributes>('url', id);
updateMetadata(doc, { savedObjects });
return doc.attributes.url;

View file

@ -4,6 +4,8 @@
* you may not use this file except in compliance with the Elastic License.
*/
import { IndexPatternAttributes } from 'src/plugins/data/public';
import { API_ROUTE } from '../../common/lib/constants';
// @ts-ignore untyped local
import { fetch } from '../../common/lib/fetch';
@ -44,7 +46,7 @@ export const getFields = (index = '_all') => {
export const getIndices = () =>
getSavedObjectsClient()
.find({
.find<IndexPatternAttributes>({
type: 'index-pattern',
fields: ['title'],
searchFields: ['title'],
@ -62,7 +64,7 @@ export const getDefaultIndex = () => {
return defaultIndexId
? getSavedObjectsClient()
.get('index-pattern', defaultIndexId)
.get<IndexPatternAttributes>('index-pattern', defaultIndexId)
.then(defaultIndex => defaultIndex.attributes.title)
.catch(err => notify.error(err, { title: strings.getDefaultIndexFetchErrorMessage() }))
: Promise.resolve('');

View file

@ -52,7 +52,7 @@ export function createSavedWorkspacesLoader(
},
find: (searchString: string, size: number = 100) => {
return savedObjectsClient
.find({
.find<Record<string, unknown>>({
type: SavedWorkspace.type,
search: searchString ? `${searchString}*` : undefined,
perPage: size,

View file

@ -6,7 +6,8 @@
// custom edits or fixes for default kibana types which are incomplete
import { SavedObjectAttributes, SimpleSavedObject } from 'kibana/public';
import { SimpleSavedObject } from 'kibana/public';
import { IndexPatternAttributes } from 'src/plugins/data/common';
export type IndexPatternTitle = string;
@ -17,8 +18,9 @@ export interface Route {
k7Breadcrumbs: () => any;
}
export type IndexPatternSavedObject = SimpleSavedObject<SavedObjectAttributes>;
export type SavedSearchSavedObject = SimpleSavedObject<SavedObjectAttributes>;
export type IndexPatternSavedObject = SimpleSavedObject<IndexPatternAttributes>;
// TODO define saved object type
export type SavedSearchSavedObject = SimpleSavedObject<any>;
export function isSavedSearchSavedObject(
ss: SavedSearchSavedObject | null

View file

@ -61,7 +61,7 @@ export const checkForSavedObjects = async (objects: KibanaObjects): Promise<Kiba
try {
return await Object.keys(objects).reduce(async (prevPromise, type) => {
const acc = await prevPromise;
const { savedObjects } = await savedObjectsClient.find({
const { savedObjects } = await savedObjectsClient.find<any>({
type,
perPage: 1000,
});

View file

@ -5,11 +5,12 @@
*/
import { i18n } from '@kbn/i18n';
import { Query } from 'src/plugins/data/public';
import {
IndexPattern,
IIndexPattern,
IndexPatternsContract,
Query,
IndexPatternAttributes,
} from '../../../../../../../src/plugins/data/public';
import { getToastNotifications, getSavedObjectsClient } from './dependency_cache';
import { IndexPatternSavedObject, SavedSearchSavedObject } from '../../../common/types/kibana';
@ -22,7 +23,7 @@ export function loadIndexPatterns(indexPatterns: IndexPatternsContract) {
indexPatternsContract = indexPatterns;
const savedObjectsClient = getSavedObjectsClient();
return savedObjectsClient
.find({
.find<IndexPatternAttributes>({
type: 'index-pattern',
fields: ['id', 'title', 'type', 'fields'],
perPage: 10000,

View file

@ -8,6 +8,7 @@ import fs from 'fs';
import Boom from 'boom';
import numeral from '@elastic/numeral';
import { CallAPIOptions, RequestHandlerContext, SavedObjectsClientContract } from 'kibana/server';
import { IndexPatternAttributes } from 'src/plugins/data/server';
import { merge } from 'lodash';
import { MlJob } from '../../../common/types/jobs';
import {
@ -532,7 +533,10 @@ export class DataRecognizer {
}
async loadIndexPatterns() {
return await this.savedObjectsClient.find({ type: 'index-pattern', perPage: 1000 });
return await this.savedObjectsClient.find<IndexPatternAttributes>({
type: 'index-pattern',
perPage: 1000,
});
}
// returns a id based on an index pattern name
@ -620,7 +624,8 @@ export class DataRecognizer {
// find all existing savedObjects for a given type
loadExistingSavedObjects(type: string) {
return this.savedObjectsClient.find({ type, perPage: 1000 });
// TODO: define saved object type
return this.savedObjectsClient.find<any>({ type, perPage: 1000 });
}
// save the savedObjects if they do not exist already

View file

@ -5,6 +5,7 @@
*/
import { SavedObject } from 'src/core/server';
import { IndexPatternAttributes } from 'src/plugins/data/server';
import { SavedObjectsClientContract } from 'kibana/server';
import { FieldId } from '../../../../common/types/fields';
import { ES_AGGREGATION } from '../../../../common/constants/aggregation_types';
@ -58,8 +59,8 @@ export async function rollupServiceProvider(
async function loadRollupIndexPattern(
indexPattern: string,
savedObjectsClient: SavedObjectsClientContract
): Promise<SavedObject | null> {
const resp = await savedObjectsClient.find({
): Promise<SavedObject<IndexPatternAttributes> | null> {
const resp = await savedObjectsClient.find<IndexPatternAttributes>({
type: 'index-pattern',
fields: ['title', 'type', 'typeMeta'],
perPage: 1000,

View file

@ -51,6 +51,15 @@ interface GetFilterArgs {
index: string[] | undefined | null;
}
interface QueryAttributes {
// NOTE: doesn't match Query interface
query: {
query: string;
language: string;
};
filters: PartialFilter[];
}
export const getFilter = async ({
filters,
index,
@ -72,7 +81,10 @@ export const getFilter = async ({
if (savedId != null && index != null) {
try {
// try to get the saved object first
const savedObject = await services.savedObjectsClient.get('query', savedId);
const savedObject = await services.savedObjectsClient.get<QueryAttributes>(
'query',
savedId
);
return getQueryFilter(
savedObject.attributes.query.query,
savedObject.attributes.query.language,

View file

@ -16,7 +16,9 @@ export const getInputIndex = async (
if (inputIndex != null) {
return inputIndex;
} else {
const configuration = await services.savedObjectsClient.get('config', version);
const configuration = await services.savedObjectsClient.get<{
'siem:defaultIndex': string[];
}>('config', version);
if (configuration.attributes != null && configuration.attributes[DEFAULT_INDEX_KEY] != null) {
return configuration.attributes[DEFAULT_INDEX_KEY];
} else {

View file

@ -22,7 +22,17 @@ import { SignalRuleAlertTypeDefinition } from './types';
import { getGapBetweenRuns } from './utils';
import { ruleStatusSavedObjectType } from '../rules/saved_object_mappings';
import { IRuleSavedAttributesSavedObjectAttributes } from '../rules/types';
interface AlertAttributes {
enabled: boolean;
name: string;
tags: string[];
createdBy: string;
createdAt: string;
updatedBy: string;
schedule: {
interval: string;
};
}
export const signalRulesAlertType = ({
logger,
version,
@ -82,7 +92,7 @@ export const signalRulesAlertType = ({
type,
} = params;
// TODO: Remove this hard extraction of name once this is fixed: https://github.com/elastic/kibana/issues/50522
const savedObject = await services.savedObjectsClient.get('alert', alertId);
const savedObject = await services.savedObjectsClient.get<AlertAttributes>('alert', alertId);
const ruleStatusSavedObjects = await services.savedObjectsClient.find<
IRuleSavedAttributesSavedObjectAttributes
>({
@ -123,15 +133,15 @@ export const signalRulesAlertType = ({
);
}
const name: string = savedObject.attributes.name;
const tags: string[] = savedObject.attributes.tags;
const name = savedObject.attributes.name;
const tags = savedObject.attributes.tags;
const createdBy: string = savedObject.attributes.createdBy;
const createdAt: string = savedObject.attributes.createdAt;
const updatedBy: string = savedObject.attributes.updatedBy;
const updatedAt: string = savedObject.updated_at ?? '';
const interval: string = savedObject.attributes.schedule.interval;
const enabled: boolean = savedObject.attributes.enabled;
const createdBy = savedObject.attributes.createdBy;
const createdAt = savedObject.attributes.createdAt;
const updatedBy = savedObject.attributes.updatedBy;
const updatedAt = savedObject.updated_at ?? '';
const interval = savedObject.attributes.schedule.interval;
const enabled = savedObject.attributes.enabled;
const gap = getGapBetweenRuns({
previousStartedAt: previousStartedAt != null ? moment(previousStartedAt) : null, // TODO: Remove this once previousStartedAt is no longer a string
interval,

View file

@ -7,7 +7,7 @@ import { SavedObject } from '../../../../../src/core/server';
export const migrations = {
task: {
'7.4.0': (doc: SavedObject) => ({
'7.4.0': (doc: SavedObject<Record<any, any>>) => ({
...doc,
updated_at: new Date().toISOString(),
}),
@ -18,7 +18,7 @@ export const migrations = {
function moveIntervalIntoSchedule({
attributes: { interval, ...attributes },
...doc
}: SavedObject) {
}: SavedObject<Record<any, any>>) {
return {
...doc,
attributes: {

View file

@ -9,6 +9,7 @@ import {
IndexPattern,
esQuery,
IndexPatternsContract,
IndexPatternAttributes,
} from '../../../../../../../../src/plugins/data/public';
type IndexPatternId = string;
@ -27,7 +28,7 @@ export function loadIndexPatterns(
) {
fullIndexPatterns = indexPatterns;
return savedObjectsClient
.find({
.find<IndexPatternAttributes>({
type: 'index-pattern',
fields: ['id', 'title', 'type', 'fields'],
perPage: 10000,

View file

@ -24,7 +24,12 @@ async function getSavedObjectAttributesFromRepo(
docID: string
) {
try {
return (await savedObjectsRepository.get(docType, docID)).attributes;
return (
await savedObjectsRepository.get<UpgradeAssistantTelemetrySavedObjectAttributes>(
docType,
docID
)
).attributes;
} catch (e) {
return null;
}

View file

@ -10,7 +10,7 @@ import {
SavedObjectsClientContract,
SavedObjectAttributes,
SavedObject,
} from '../../../../src/core/server';
} from 'src/core/server';
import { ActionTypeRegistry } from './action_type_registry';
import { validateConfig, validateSecrets } from './lib';
@ -118,7 +118,7 @@ export class ActionsClient {
* Update action
*/
public async update({ id, action }: UpdateOptions): Promise<ActionResult> {
const existingObject = await this.savedObjectsClient.get('action', id);
const existingObject = await this.savedObjectsClient.get<RawAction>('action', id);
const { actionTypeId } = existingObject.attributes;
const { name, config, secrets } = action;
const actionType = this.actionTypeRegistry.get(actionTypeId);
@ -144,13 +144,13 @@ export class ActionsClient {
* Get an action
*/
public async get({ id }: { id: string }): Promise<ActionResult> {
const result = await this.savedObjectsClient.get('action', id);
const result = await this.savedObjectsClient.get<RawAction>('action', id);
return {
id,
actionTypeId: result.attributes.actionTypeId as string,
name: result.attributes.name as string,
config: result.attributes.config as Record<string, any>,
actionTypeId: result.attributes.actionTypeId,
name: result.attributes.name,
config: result.attributes.config,
};
}

View file

@ -6,7 +6,7 @@
import { SavedObjectsClientContract } from '../../../../src/core/server';
import { TaskManagerStartContract } from '../../task_manager/server';
import { GetBasePathFunction } from './types';
import { GetBasePathFunction, RawAction } from './types';
interface CreateExecuteFunctionOptions {
taskManager: TaskManagerStartContract;
@ -59,7 +59,7 @@ export function createExecuteFunction({
};
const savedObjectsClient = getScopedSavedObjectsClient(fakeRequest);
const actionSavedObject = await savedObjectsClient.get('action', id);
const actionSavedObject = await savedObjectsClient.get<RawAction>('action', id);
const actionTaskParamsRecord = await savedObjectsClient.create('action_task_params', {
actionId: id,
params,

View file

@ -203,7 +203,7 @@ export class AlertsClient {
}
public async get({ id }: { id: string }): Promise<SanitizedAlert> {
const result = await this.savedObjectsClient.get('alert', id);
const result = await this.savedObjectsClient.get<RawAlert>('alert', id);
return this.getAlertFromRaw(result.id, result.attributes, result.updated_at, result.references);
}

View file

@ -5,8 +5,7 @@
*/
import { pick, mapValues, omit } from 'lodash';
import { Logger } from '../../../../../src/core/server';
import { SavedObject } from '../../../../../src/core/server';
import { Logger, SavedObject } from '../../../../../src/core/server';
import { TaskRunnerContext } from './task_runner_factory';
import { ConcreteTaskInstance } from '../../../../plugins/task_manager/server';
import { createExecutionHandler } from './create_execution_handler';

View file

@ -6,8 +6,7 @@
import { schema, TypeOf } from '@kbn/config-schema';
import { omit } from 'lodash';
import { KibanaResponseFactory } from 'src/core/server';
import { SavedObjectsClientContract } from 'src/core/server';
import { KibanaResponseFactory, SavedObjectsClientContract } from 'src/core/server';
import { RouteInitializerDeps } from '../';
import {
CANVAS_TYPE,

View file

@ -52,7 +52,7 @@ export const readRawTags = async ({
page: 1,
perPage,
});
const tags = await client.find({
const tags = await client.find<CaseAttributes>({
type: CASE_SAVED_OBJECT,
fields: ['tags'],
page: 1,

View file

@ -7,7 +7,6 @@
import uuid from 'uuid';
import {
SavedObject,
SavedObjectAttributes,
SavedObjectsBaseOptions,
SavedObjectsBulkCreateObject,
SavedObjectsBulkGetObject,
@ -42,7 +41,7 @@ export class EncryptedSavedObjectsClientWrapper implements SavedObjectsClientCon
public readonly errors = options.baseClient.errors
) {}
public async create<T extends SavedObjectAttributes>(
public async create<T = unknown>(
type: string,
attributes: T = {} as T,
options: SavedObjectsCreateOptions = {}
@ -66,15 +65,15 @@ export class EncryptedSavedObjectsClientWrapper implements SavedObjectsClientCon
type,
await this.options.service.encryptAttributes(
{ type, id, namespace: options.namespace },
attributes
attributes as Record<string, unknown>
),
{ ...options, id }
)
);
) as SavedObject<T>;
}
public async bulkCreate(
objects: SavedObjectsBulkCreateObject[],
public async bulkCreate<T = unknown>(
objects: Array<SavedObjectsBulkCreateObject<T>>,
options?: SavedObjectsBaseOptions
) {
// We encrypt attributes for every object in parallel and that can potentially exhaust libuv or
@ -101,14 +100,14 @@ export class EncryptedSavedObjectsClientWrapper implements SavedObjectsClientCon
id,
attributes: await this.options.service.encryptAttributes(
{ type: object.type, id, namespace: options && options.namespace },
object.attributes
object.attributes as Record<string, unknown>
),
};
} as SavedObjectsBulkCreateObject<T>;
})
);
return this.stripEncryptedAttributesFromBulkResponse(
await this.options.baseClient.bulkCreate(encryptedObjects, options)
await this.options.baseClient.bulkCreate<T>(encryptedObjects, options)
);
}
@ -144,28 +143,28 @@ export class EncryptedSavedObjectsClientWrapper implements SavedObjectsClientCon
return await this.options.baseClient.delete(type, id, options);
}
public async find(options: SavedObjectsFindOptions) {
public async find<T = unknown>(options: SavedObjectsFindOptions) {
return this.stripEncryptedAttributesFromBulkResponse(
await this.options.baseClient.find(options)
await this.options.baseClient.find<T>(options)
);
}
public async bulkGet(
public async bulkGet<T = unknown>(
objects: SavedObjectsBulkGetObject[] = [],
options?: SavedObjectsBaseOptions
) {
return this.stripEncryptedAttributesFromBulkResponse(
await this.options.baseClient.bulkGet(objects, options)
await this.options.baseClient.bulkGet<T>(objects, options)
);
}
public async get(type: string, id: string, options?: SavedObjectsBaseOptions) {
public async get<T = unknown>(type: string, id: string, options?: SavedObjectsBaseOptions) {
return this.stripEncryptedAttributesFromResponse(
await this.options.baseClient.get(type, id, options)
await this.options.baseClient.get<T>(type, id, options)
);
}
public async update<T extends SavedObjectAttributes>(
public async update<T = unknown>(
type: string,
id: string,
attributes: Partial<T>,
@ -199,7 +198,7 @@ export class EncryptedSavedObjectsClientWrapper implements SavedObjectsClientCon
if (this.options.service.isRegistered(response.type)) {
response.attributes = this.options.service.stripEncryptedAttributes(
response.type,
response.attributes
response.attributes as Record<string, unknown>
);
}
@ -218,7 +217,7 @@ export class EncryptedSavedObjectsClientWrapper implements SavedObjectsClientCon
if (this.options.service.isRegistered(savedObject.type)) {
savedObject.attributes = this.options.service.stripEncryptedAttributes(
savedObject.type,
savedObject.attributes
savedObject.attributes as Record<string, unknown>
);
}
}

View file

@ -4,12 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/
import {
CoreSetup,
SavedObject,
SavedObjectAttributes,
SavedObjectsBaseOptions,
} from 'src/core/server';
import { CoreSetup, SavedObject, SavedObjectsBaseOptions } from 'src/core/server';
import { EncryptedSavedObjectsService } from '../crypto';
import { EncryptedSavedObjectsClientWrapper } from './encrypted_saved_objects_client_wrapper';
@ -20,7 +15,7 @@ interface SetupSavedObjectsParams {
}
export interface SavedObjectsSetup {
getDecryptedAsInternalUser: <T extends SavedObjectAttributes = any>(
getDecryptedAsInternalUser: <T = unknown>(
type: string,
id: string,
options?: SavedObjectsBaseOptions
@ -47,7 +42,7 @@ export function setupSavedObjects({
core.savedObjects.createInternalRepository()
);
return {
getDecryptedAsInternalUser: async <T extends SavedObjectAttributes = any>(
getDecryptedAsInternalUser: async <T = unknown>(
type: string,
id: string,
options?: SavedObjectsBaseOptions
@ -56,10 +51,10 @@ export function setupSavedObjects({
const savedObject = await internalRepository.get(type, id, options);
return {
...savedObject,
attributes: await service.decryptAttributes(
attributes: (await service.decryptAttributes(
{ type, id, namespace: options && options.namespace },
savedObject.attributes
),
savedObject.attributes as Record<string, unknown>
)) as T,
};
},
};

View file

@ -5,12 +5,13 @@
*/
import { useState, useCallback } from 'react';
import { SavedObjectAttributes, SavedObjectsBatchResponse } from 'src/core/public';
import { SavedObjectsBatchResponse } from 'src/core/public';
import { useKibana } from '../../../../../src/plugins/kibana_react/public';
export const useBulkGetSavedObject = (type: string) => {
const kibana = useKibana();
const [data, setData] = useState<SavedObjectsBatchResponse<SavedObjectAttributes> | null>(null);
// TODO: define saved object type
const [data, setData] = useState<SavedObjectsBatchResponse<any> | null>(null);
const [error, setError] = useState<string | null>(null);
const [loading, setLoading] = useState<boolean>(false);

View file

@ -91,6 +91,8 @@ describe('buildFieldList', () => {
type: 'indexpattern',
attributes: {
title: 'testpattern',
type: 'type',
typeMeta: 'typemeta',
fields: JSON.stringify([
{ name: 'foo', scripted: true, lang: 'painless', script: '2+2' },
{ name: 'bar' },

View file

@ -9,7 +9,10 @@ import { schema } from '@kbn/config-schema';
import { IScopedClusterClient, SavedObject, RequestHandlerContext } from 'src/core/server';
import { CoreSetup } from 'src/core/server';
import { BASE_API_URL } from '../../common';
import { IndexPatternsFetcher } from '../../../../../src/plugins/data/server';
import {
IndexPatternsFetcher,
IndexPatternAttributes,
} from '../../../../../src/plugins/data/server';
/**
* The number of docs to sample to determine field empty status.
@ -125,7 +128,10 @@ async function fetchFieldExistence({
async function fetchIndexPatternDefinition(indexPatternId: string, context: RequestHandlerContext) {
const savedObjectsClient = context.core.savedObjects.client;
const requestClient = context.core.elasticsearch.dataClient;
const indexPattern = await savedObjectsClient.get('index-pattern', indexPatternId);
const indexPattern = await savedObjectsClient.get<IndexPatternAttributes>(
'index-pattern',
indexPatternId
);
const indexPatternTitle = indexPattern.attributes.title;
// TODO: maybe don't use IndexPatternsFetcher at all, since we're only using it
// to look up field values in the resulting documents. We can accomplish the same
@ -155,7 +161,7 @@ async function fetchIndexPatternDefinition(indexPatternId: string, context: Requ
* Exported only for unit tests.
*/
export function buildFieldList(
indexPattern: SavedObject,
indexPattern: SavedObject<IndexPatternAttributes>,
mappings: MappingResult,
fieldDescriptors: FieldDescriptor[]
): Field[] {

View file

@ -5,7 +5,6 @@
*/
import {
SavedObjectAttributes,
SavedObjectsBaseOptions,
SavedObjectsBulkCreateObject,
SavedObjectsBulkGetObject,
@ -46,7 +45,7 @@ export class SecureSavedObjectsClientWrapper implements SavedObjectsClientContra
this.checkSavedObjectsPrivilegesAsCurrentUser = checkSavedObjectsPrivilegesAsCurrentUser;
}
public async create<T extends SavedObjectAttributes>(
public async create<T = unknown>(
type: string,
attributes: T = {} as T,
options: SavedObjectsCreateOptions = {}
@ -56,8 +55,8 @@ export class SecureSavedObjectsClientWrapper implements SavedObjectsClientContra
return await this.baseClient.create(type, attributes, options);
}
public async bulkCreate(
objects: SavedObjectsBulkCreateObject[],
public async bulkCreate<T = unknown>(
objects: Array<SavedObjectsBulkCreateObject<T>>,
options: SavedObjectsBaseOptions = {}
) {
await this.ensureAuthorized(
@ -76,13 +75,13 @@ export class SecureSavedObjectsClientWrapper implements SavedObjectsClientContra
return await this.baseClient.delete(type, id, options);
}
public async find(options: SavedObjectsFindOptions) {
public async find<T = unknown>(options: SavedObjectsFindOptions) {
await this.ensureAuthorized(options.type, 'find', options.namespace, { options });
return this.baseClient.find(options);
return this.baseClient.find<T>(options);
}
public async bulkGet(
public async bulkGet<T = unknown>(
objects: SavedObjectsBulkGetObject[] = [],
options: SavedObjectsBaseOptions = {}
) {
@ -91,16 +90,16 @@ export class SecureSavedObjectsClientWrapper implements SavedObjectsClientContra
options,
});
return await this.baseClient.bulkGet(objects, options);
return await this.baseClient.bulkGet<T>(objects, options);
}
public async get(type: string, id: string, options: SavedObjectsBaseOptions = {}) {
public async get<T = unknown>(type: string, id: string, options: SavedObjectsBaseOptions = {}) {
await this.ensureAuthorized(type, 'get', options.namespace, { type, id, options });
return await this.baseClient.get(type, id, options);
return await this.baseClient.get<T>(type, id, options);
}
public async update<T extends SavedObjectAttributes>(
public async update<T = unknown>(
type: string,
id: string,
attributes: Partial<T>,
@ -116,8 +115,8 @@ export class SecureSavedObjectsClientWrapper implements SavedObjectsClientContra
return await this.baseClient.update(type, id, attributes, options);
}
public async bulkUpdate(
objects: SavedObjectsBulkUpdateObject[] = [],
public async bulkUpdate<T = unknown>(
objects: Array<SavedObjectsBulkUpdateObject<T>> = [],
options: SavedObjectsBaseOptions = {}
) {
await this.ensureAuthorized(
@ -127,7 +126,7 @@ export class SecureSavedObjectsClientWrapper implements SavedObjectsClientContra
{ objects, options }
);
return await this.baseClient.bulkUpdate(objects, options);
return await this.baseClient.bulkUpdate<T>(objects, options);
}
private async checkPrivileges(actions: string | string[], namespace?: string) {

View file

@ -5,7 +5,6 @@
*/
import {
SavedObjectAttributes,
SavedObjectsBaseOptions,
SavedObjectsBulkCreateObject,
SavedObjectsBulkGetObject,
@ -65,14 +64,14 @@ export class SpacesSavedObjectsClient implements SavedObjectsClientContract {
* @property {string} [options.namespace]
* @returns {promise} - { id, type, version, attributes }
*/
public async create<T extends SavedObjectAttributes>(
public async create<T = unknown>(
type: string,
attributes: T = {} as T,
options: SavedObjectsCreateOptions = {}
) {
throwErrorIfNamespaceSpecified(options);
return await this.client.create(type, attributes, {
return await this.client.create<T>(type, attributes, {
...options,
namespace: spaceIdToNamespace(this.spaceId),
});
@ -87,8 +86,8 @@ export class SpacesSavedObjectsClient implements SavedObjectsClientContract {
* @property {string} [options.namespace]
* @returns {promise} - { saved_objects: [{ id, type, version, attributes, error: { message } }]}
*/
public async bulkCreate(
objects: SavedObjectsBulkCreateObject[],
public async bulkCreate<T = unknown>(
objects: Array<SavedObjectsBulkCreateObject<T>>,
options: SavedObjectsBaseOptions = {}
) {
throwErrorIfNamespaceSpecified(options);
@ -133,10 +132,10 @@ export class SpacesSavedObjectsClient implements SavedObjectsClientContract {
* @property {object} [options.hasReference] - { type, id }
* @returns {promise} - { saved_objects: [{ id, type, version, attributes }], total, per_page, page }
*/
public async find(options: SavedObjectsFindOptions) {
public async find<T = unknown>(options: SavedObjectsFindOptions) {
throwErrorIfNamespaceSpecified(options);
return await this.client.find({
return await this.client.find<T>({
...options,
type: (options.type ? coerceToArray(options.type) : this.types).filter(
type => type !== 'space'
@ -159,13 +158,13 @@ export class SpacesSavedObjectsClient implements SavedObjectsClientContract {
* { id: 'foo', type: 'index-pattern' }
* ])
*/
public async bulkGet(
public async bulkGet<T = unknown>(
objects: SavedObjectsBulkGetObject[] = [],
options: SavedObjectsBaseOptions = {}
) {
throwErrorIfNamespaceSpecified(options);
return await this.client.bulkGet(objects, {
return await this.client.bulkGet<T>(objects, {
...options,
namespace: spaceIdToNamespace(this.spaceId),
});
@ -180,10 +179,10 @@ export class SpacesSavedObjectsClient implements SavedObjectsClientContract {
* @property {string} [options.namespace]
* @returns {promise} - { id, type, version, attributes }
*/
public async get(type: string, id: string, options: SavedObjectsBaseOptions = {}) {
public async get<T = unknown>(type: string, id: string, options: SavedObjectsBaseOptions = {}) {
throwErrorIfNamespaceSpecified(options);
return await this.client.get(type, id, {
return await this.client.get<T>(type, id, {
...options,
namespace: spaceIdToNamespace(this.spaceId),
});
@ -199,7 +198,7 @@ export class SpacesSavedObjectsClient implements SavedObjectsClientContract {
* @property {string} [options.namespace]
* @returns {promise}
*/
public async update<T extends SavedObjectAttributes>(
public async update<T = unknown>(
type: string,
id: string,
attributes: Partial<T>,
@ -225,8 +224,8 @@ export class SpacesSavedObjectsClient implements SavedObjectsClientContract {
* { id: 'foo', type: 'index-pattern', attributes: {} }
* ])
*/
public async bulkUpdate(
objects: SavedObjectsBulkUpdateObject[] = [],
public async bulkUpdate<T = unknown>(
objects: Array<SavedObjectsBulkUpdateObject<T>> = [],
options: SavedObjectsBaseOptions = {}
) {
throwErrorIfNamespaceSpecified(options);

View file

@ -18,11 +18,7 @@ import {
} from './task';
import { StoreOpts, OwnershipClaimingOpts, TaskStore, SearchOpts } from './task_store';
import { savedObjectsRepositoryMock } from '../../../../src/core/server/mocks';
import {
SavedObjectsSerializer,
SavedObjectTypeRegistry,
SavedObjectAttributes,
} from '../../../../src/core/server';
import { SavedObjectsSerializer, SavedObjectTypeRegistry } from '../../../../src/core/server';
import { SavedObjectsErrorHelpers } from '../../../../src/core/server/saved_objects/service/lib/errors';
import { asTaskClaimEvent, TaskEvent } from './task_events';
import { asOk, asErr } from './lib/result_type';
@ -64,15 +60,13 @@ describe('TaskStore', () => {
describe('schedule', () => {
async function testSchedule(task: TaskInstance) {
const callCluster = jest.fn();
savedObjectsClient.create.mockImplementation(
async (type: string, attributes: SavedObjectAttributes) => ({
id: 'testid',
type,
attributes,
references: [],
version: '123',
})
);
savedObjectsClient.create.mockImplementation(async (type: string, attributes: any) => ({
id: 'testid',
type,
attributes,
references: [],
version: '123',
}));
const store = new TaskStore({
index: 'tasky',
taskManagerId: '',
@ -155,14 +149,14 @@ describe('TaskStore', () => {
test('sets runAt to now if not specified', async () => {
await testSchedule({ taskType: 'dernstraight', params: {}, state: {} });
expect(savedObjectsClient.create).toHaveBeenCalledTimes(1);
const attributes = savedObjectsClient.create.mock.calls[0][1];
const attributes: any = savedObjectsClient.create.mock.calls[0][1];
expect(new Date(attributes.runAt as string).getTime()).toEqual(mockedDate.getTime());
});
test('ensures params and state are not null', async () => {
await testSchedule({ taskType: 'yawn' } as any);
expect(savedObjectsClient.create).toHaveBeenCalledTimes(1);
const attributes = savedObjectsClient.create.mock.calls[0][1];
const attributes: any = savedObjectsClient.create.mock.calls[0][1];
expect(attributes.params).toEqual('{}');
expect(attributes.state).toEqual('{}');
});
@ -751,7 +745,7 @@ if (doc['task.runAt'].size()!=0) {
};
savedObjectsClient.update.mockImplementation(
async (type: string, id: string, attributes: SavedObjectAttributes) => {
async (type: string, id: string, attributes: any) => {
return {
id,
type,

View file

@ -428,7 +428,8 @@ function taskInstanceToAttributes(doc: TaskInstance): SavedObjectAttributes {
}
export function savedObjectToConcreteTaskInstance(
savedObject: Omit<SavedObject, 'references'>
// TODO: define saved object type
savedObject: Omit<SavedObject<any>, 'references'>
): ConcreteTaskInstance {
return {
...savedObject.attributes,

View file

@ -59,7 +59,9 @@ export function resolveCopyToSpaceConflictsSuite(
.then((response: any) => response.body);
};
const getObjectsAtSpace = async (spaceId: string): Promise<[SavedObject, SavedObject]> => {
const getObjectsAtSpace = async (
spaceId: string
): Promise<[SavedObject<any>, SavedObject<any>]> => {
const dashboard = await getDashboardAtSpace(spaceId);
const visualization = await getVisualizationAtSpace(spaceId);
return [dashboard, visualization];