@@ -127,11 +127,15 @@ export class SavedObjectsClient {
127127 *
128128 * This should only be used by import / export / resolve import errors.
129129 *
130- * @param {Array<string> } types Types of saved objects
130+ * @param {array } objects - [{ type, id, attributes }]
131+ * @param {object } [options={}]
132+ * @property {boolean } [options.overwrite=false] - overwrites existing documents
133+ * @property {string } [options.namespace]
131134 * @return [{ type, can }]
132135 */
133- async canBulkCreate ( types ) {
134- return types . map ( type => ( { type, can : true } ) ) ;
136+ async canBulkCreate ( objects ) {
137+ const types = new Set ( objects . map ( obj => obj . type ) ) ;
138+ return [ ...types ] . map ( type => ( { type, can : true } ) ) ;
135139 }
136140
137141 /**
@@ -172,17 +176,30 @@ export class SavedObjectsClient {
172176 *
173177 * This should only be used by import / export / resolve import errors.
174178 *
175- * @param {Array<string> } types Types of saved objects
179+ * @param {object } [options={}]
180+ * @property {(string|Array<string>) } [options.type]
181+ * @property {string } [options.search]
182+ * @property {string } [options.defaultSearchOperator]
183+ * @property {Array<string> } [options.searchFields] - see Elasticsearch Simple Query String
184+ * Query field argument for more information
185+ * @property {integer } [options.page=1]
186+ * @property {integer } [options.perPage=20]
187+ * @property {string } [options.sortField]
188+ * @property {string } [options.sortOrder]
189+ * @property {Array<string> } [options.fields]
190+ * @property {string } [options.namespace]
191+ * @property {object } [options.hasReference] - { type, id }
176192 * @return [{ type, can }]
177193 */
178- async canFind ( types ) {
194+ async canFind ( options = { } ) {
195+ const types = Array . isArray ( options . type ) ? options . type : [ options . type ] ;
179196 return types . map ( type => ( { type, can : true } ) ) ;
180197 }
181198
182199 /**
183200 * Returns an array of objects by id
184201 *
185- * @param {array } objects - an array ids, or an array of objects containing id and optionally type
202+ * @param {array } objects - an array of objects containing id and type
186203 * @param {object } [options={}]
187204 * @property {string } [options.namespace]
188205 * @returns {promise } - { saved_objects: [{ id, type, version, attributes }] }
@@ -202,11 +219,14 @@ export class SavedObjectsClient {
202219 *
203220 * This should only be used by import / export / resolve import errors.
204221 *
205- * @param {Array<string> } types Types of saved objects
222+ * @param {array } objects - an array of objects containing id and type
223+ * @param {object } [options={}]
224+ * @property {string } [options.namespace]
206225 * @return [{ type, can }]
207226 */
208- async canBulkGet ( types ) {
209- return types . map ( type => ( { type, can : true } ) ) ;
227+ async canBulkGet ( objects = [ ] ) {
228+ const types = new Set ( objects . map ( obj => obj . type ) ) ;
229+ return [ ...types ] . map ( type => ( { type, can : true } ) ) ;
210230 }
211231
212232 /**
0 commit comments