-
Notifications
You must be signed in to change notification settings - Fork 8.5k
Change saved object bulkUpdate to work across multiple namespaces #75478
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
fa6ae1c
341052a
6c78cd4
9d849b6
2096fc3
440d987
0b2f62c
1228d61
46bc77d
9dd4d5b
ea2235f
17985c3
def73c7
978ccf1
ba8c72d
2c36a31
714a14e
c2a207a
0a36aa5
0c97bf3
65acf6d
cf0a0a0
71bf105
70793b0
f345891
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| <!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
|
||
| [Home](./index.md) > [kibana-plugin-core-server](./kibana-plugin-core-server.md) > [namespaceIdToString](./kibana-plugin-core-server.namespaceidtostring.md) | ||
|
|
||
| ## namespaceIdToString variable | ||
|
|
||
| Converts a given saved object namespace ID to its string representation. All namespace IDs have an identical string representation, with the exception of the `undefined` namespace ID (which has a namespace string of `'default'`<!-- -->). | ||
|
|
||
| <b>Signature:</b> | ||
|
|
||
| ```typescript | ||
| namespaceIdToString: (namespace?: string | undefined) => string | ||
| ``` |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| <!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
|
||
| [Home](./index.md) > [kibana-plugin-core-server](./kibana-plugin-core-server.md) > [namespaceStringToId](./kibana-plugin-core-server.namespacestringtoid.md) | ||
|
|
||
| ## namespaceStringToId variable | ||
|
|
||
| Converts a given saved object namespace string to its ID representation. All namespace strings have an identical ID representation, with the exception of the `'default'` namespace string (which has a namespace ID of `undefined`<!-- -->). | ||
|
|
||
| <b>Signature:</b> | ||
|
|
||
| ```typescript | ||
| namespaceStringToId: (namespace: string) => string | undefined | ||
| ``` |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| <!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
|
||
| [Home](./index.md) > [kibana-plugin-core-server](./kibana-plugin-core-server.md) > [SavedObjectsBulkUpdateObject](./kibana-plugin-core-server.savedobjectsbulkupdateobject.md) > [namespace](./kibana-plugin-core-server.savedobjectsbulkupdateobject.namespace.md) | ||
|
|
||
| ## SavedObjectsBulkUpdateObject.namespace property | ||
|
|
||
| Optional namespace string to use for this document. If this is defined, it will supersede the namespace ID that is in [SavedObjectsUpdateOptions](./kibana-plugin-core-server.savedobjectsupdateoptions.md)<!-- -->. | ||
|
|
||
| Note: the default namespace's string representation is `'default'`<!-- -->, and its ID representation is `undefined`<!-- -->. | ||
|
|
||
| <b>Signature:</b> | ||
|
|
||
| ```typescript | ||
| namespace?: string; | ||
| ``` |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| /* | ||
| * Licensed to Elasticsearch B.V. under one or more contributor | ||
| * license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright | ||
| * ownership. Elasticsearch B.V. licenses this file to you under | ||
| * the Apache License, Version 2.0 (the "License"); you may | ||
| * not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
|
|
||
| import { namespaceIdToString, namespaceStringToId } from './namespace'; | ||
|
|
||
| describe('#namespaceIdToString', () => { | ||
| it('converts `undefined` to default namespace string', () => { | ||
| expect(namespaceIdToString(undefined)).toEqual('default'); | ||
| }); | ||
|
|
||
| it('leaves other namespace IDs as-is', () => { | ||
| expect(namespaceIdToString('foo')).toEqual('foo'); | ||
| }); | ||
|
|
||
| it('throws an error when a namespace ID is an empty string', () => { | ||
| expect(() => namespaceIdToString('')).toThrowError('namespace cannot be an empty string'); | ||
| }); | ||
| }); | ||
|
|
||
| describe('#namespaceStringToId', () => { | ||
| it('converts default namespace string to `undefined`', () => { | ||
| expect(namespaceStringToId('default')).toBeUndefined(); | ||
| }); | ||
|
|
||
| it('leaves other namespace strings as-is', () => { | ||
| expect(namespaceStringToId('foo')).toEqual('foo'); | ||
| }); | ||
|
|
||
| it('throws an error when a namespace string is falsy', () => { | ||
| const test = (arg: any) => | ||
| expect(() => namespaceStringToId(arg)).toThrowError('namespace must be a non-empty string'); | ||
|
|
||
| test(undefined); | ||
| test(null); | ||
| test(''); | ||
| }); | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| /* | ||
| * Licensed to Elasticsearch B.V. under one or more contributor | ||
| * license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright | ||
| * ownership. Elasticsearch B.V. licenses this file to you under | ||
| * the Apache License, Version 2.0 (the "License"); you may | ||
| * not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
|
|
||
| export const DEFAULT_NAMESPACE_STRING = 'default'; | ||
|
|
||
| /** | ||
| * @public | ||
| * Converts a given saved object namespace ID to its string representation. All namespace IDs have an identical string representation, with | ||
| * the exception of the `undefined` namespace ID (which has a namespace string of `'default'`). | ||
| * | ||
| * @param namespace The namespace ID, which must be either a non-empty string or `undefined`. | ||
| */ | ||
| export const namespaceIdToString = (namespace?: string) => { | ||
| if (namespace === '') { | ||
| throw new TypeError('namespace cannot be an empty string'); | ||
| } | ||
|
|
||
| return namespace ?? DEFAULT_NAMESPACE_STRING; | ||
| }; | ||
|
|
||
| /** | ||
| * @public | ||
| * Converts a given saved object namespace string to its ID representation. All namespace strings have an identical ID representation, with | ||
| * the exception of the `'default'` namespace string (which has a namespace ID of `undefined`). | ||
| * | ||
| * @param namespace The namespace string, which must be non-empty. | ||
| */ | ||
| export const namespaceStringToId = (namespace: string) => { | ||
| if (!namespace) { | ||
| throw new TypeError('namespace must be a non-empty string'); | ||
| } | ||
|
||
|
|
||
| return namespace !== DEFAULT_NAMESPACE_STRING ? namespace : undefined; | ||
| }; | ||
Uh oh!
There was an error while loading. Please reload this page.