Skip to content

Commit

Permalink
feat: use unified types
Browse files Browse the repository at this point in the history
Signed-off-by: SuZhou-Joe <[email protected]>
  • Loading branch information
SuZhou-Joe committed Mar 27, 2024
1 parent 655a6ad commit 78286c2
Show file tree
Hide file tree
Showing 12 changed files with 18 additions and 18 deletions.
4 changes: 2 additions & 2 deletions src/core/public/saved_objects/saved_objects_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export interface SavedObjectsCreateOptions {
/** {@inheritDoc SavedObjectsMigrationVersion} */
migrationVersion?: SavedObjectsMigrationVersion;
references?: SavedObjectReference[];
workspaces?: string[];
workspaces?: SavedObject['workspaces'];
}

/**
Expand All @@ -83,7 +83,7 @@ export interface SavedObjectsBulkCreateObject<T = unknown> extends SavedObjectsC
export interface SavedObjectsBulkCreateOptions {
/** If a document with the given `id` already exists, overwrite it's contents (default=false). */
overwrite?: boolean;
workspaces?: string[];
workspaces?: SavedObjectsCreateOptions['workspaces'];
}

/** @public */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export interface SavedObjectsExportOptions {
/** optional namespace to override the namespace used by the savedObjectsClient. */
namespace?: string;
/** optional workspaces to override the workspaces used by the savedObjectsClient. */
workspaces?: string[];
workspaces?: SavedObject['workspaces'];
}

/**
Expand Down Expand Up @@ -97,7 +97,7 @@ async function fetchObjectsToExport({
exportSizeLimit: number;
savedObjectsClient: SavedObjectsClientContract;
namespace?: string;
workspaces?: string[];
workspaces?: SavedObjectsExportOptions['workspaces'];
}) {
if ((types?.length ?? 0) > 0 && (objects?.length ?? 0) > 0) {
throw Boom.badRequest(`Can't specify both "types" and "objects" properties when exporting`);
Expand Down
2 changes: 1 addition & 1 deletion src/core/server/saved_objects/import/check_conflicts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ interface CheckConflictsParams {
ignoreRegularConflicts?: boolean;
retries?: SavedObjectsImportRetry[];
createNewCopies?: boolean;
workspaces?: string[];
workspaces?: SavedObject['workspaces'];
}

const isUnresolvableConflict = (error: SavedObjectError) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ interface CreateSavedObjectsParams<T> {
overwrite?: boolean;
dataSourceId?: string;
dataSourceTitle?: string;
workspaces?: string[];
workspaces?: SavedObject['workspaces'];
}
interface CreateSavedObjectsResult<T> {
createdObjects: Array<CreatedObject<T>>;
Expand Down
4 changes: 2 additions & 2 deletions src/core/server/saved_objects/import/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ export interface SavedObjectsImportOptions {
dataSourceId?: string;
dataSourceTitle?: string;
/** if specified, will import in given workspaces */
workspaces?: string[];
workspaces?: SavedObject['workspaces'];
}

/**
Expand All @@ -215,7 +215,7 @@ export interface SavedObjectsResolveImportErrorsOptions {
dataSourceId?: string;
dataSourceTitle?: string;
/** if specified, will import in given workspaces */
workspaces?: string[];
workspaces?: SavedObject['workspaces'];
}

export type CreatedObject<T> = SavedObject<T> & { destinationId?: string };
6 changes: 3 additions & 3 deletions src/core/server/saved_objects/serialization/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
*/

import { Permissions } from '../permission_control';
import { SavedObjectsMigrationVersion, SavedObjectReference } from '../types';
import { SavedObjectsMigrationVersion, SavedObjectReference, SavedObject } from '../types';

/**
* A raw document as represented directly in the saved object index.
Expand All @@ -53,7 +53,7 @@ export interface SavedObjectsRawDocSource {
updated_at?: string;
references?: SavedObjectReference[];
originId?: string;
workspaces?: string[];
workspaces?: SavedObject['workspaces'];

[typeMapping: string]: any;
}
Expand All @@ -71,7 +71,7 @@ interface SavedObjectDoc<T = unknown> {
version?: string;
updated_at?: string;
originId?: string;
workspaces?: string[];
workspaces?: SavedObject['workspaces'];
permissions?: Permissions;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ interface QueryParams {
defaultSearchOperator?: string;
hasReference?: HasReferenceQueryParams;
kueryNode?: KueryNode;
workspaces?: string[];
workspaces?: SavedObjectsFindOptions['workspaces'];
workspacesSearchOperator?: 'AND' | 'OR';
ACLSearchParams?: SavedObjectsFindOptions['ACLSearchParams'];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ interface GetSearchDslOptions {
id: string;
};
kueryNode?: KueryNode;
workspaces?: string[];
workspaces?: SavedObjectsFindOptions['workspaces'];
workspacesSearchOperator?: 'AND' | 'OR';
ACLSearchParams?: SavedObjectsFindOptions['ACLSearchParams'];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export interface SavedObjectsBulkCreateObject<T = unknown> {
/**
* workspaces the objects belong to, will only be used when overwrite is enabled.
*/
workspaces?: string[];
workspaces?: SavedObject['workspaces'];
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/core/server/saved_objects/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export interface SavedObjectsFindOptions {
/** An optional OpenSearch preference value to be used for the query **/
preference?: string;
/** If specified, will only retrieve objects that are in the workspaces */
workspaces?: string[] | null;
workspaces?: SavedObjectsBaseOptions['workspaces'];
/** By default the operator will be 'AND' */
workspacesSearchOperator?: 'AND' | 'OR';
/**
Expand All @@ -132,7 +132,7 @@ export interface SavedObjectsBaseOptions {
/** Specify the namespace for this operation */
namespace?: string;
/** Specify the workspaces for this operation */
workspaces?: string[] | null;
workspaces?: SavedObject['workspaces'];
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/core/types/saved_objects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export interface SavedObject<T = unknown> {
*/
originId?: string;
/** Workspaces that this saved object exists in. */
workspaces?: string[];
workspaces?: string[] | null;
/** Permissions that this saved objects exists in. */
permissions?: Permissions;
}
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/workspace/server/permission_control/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export class SavedObjectsPermissionControl {
const principals = this.getPrincipalsFromRequest(request);
const deniedObjects: Array<
Pick<SavedObjectsBulkGetObject, 'id' | 'type'> & {
workspaces?: string[];
workspaces?: SavedObject['workspaces'];
permissions?: Permissions;
}
> = [];
Expand Down

0 comments on commit 78286c2

Please sign in to comment.