-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Use an instance of SavedObjectsSerializer for migrations and the repository * Fixing spelling of serialization * Making the serializer conditionally include and prepend id with ns * Adding repository tests for the namespaces * Implementing find * Modifying the SOCs to pass the options with the namespace * Centralizing omitting the namespace when using serializer.rawToSavedObject * Passing the schema through to the SavedObjectRepositoryProvider * Changing the schema to work with undefined ui exports schemas * Adding schema tests * Making the complimentary serialization test use the namespace * Fixing uiExports * Fixing some tests * Fixing included fields for the find * Fixing include field tests, they're checking length also... * Updating Repository test after adding namespace to always included fields * Renaming UIExportsSavedObjectTypeSchema to SavedObjectsSchemaDefinition * Completing rename... forgot to save usages * Fixing issue with the serialization.isRawSavedObject and the trailing :
- Loading branch information
Showing
38 changed files
with
2,442 additions
and
580 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* 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 { SavedObjectsSchema, SavedObjectsSchemaDefinition } from './schema'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* 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 { SavedObjectsSchema } from './schema'; | ||
|
||
describe('#isNamespaceAgnostic', () => { | ||
it(`returns false for unknown types`, () => { | ||
const schema = new SavedObjectsSchema(); | ||
const result = schema.isNamespaceAgnostic('bar'); | ||
expect(result).toBe(false); | ||
}); | ||
|
||
it(`returns true for explicitly namespace agnostic type`, () => { | ||
const schema = new SavedObjectsSchema({ | ||
foo: { | ||
isNamespaceAgnostic: true, | ||
}, | ||
}); | ||
const result = schema.isNamespaceAgnostic('foo'); | ||
expect(result).toBe(true); | ||
}); | ||
|
||
it(`returns false for explicitly namespaced type`, () => { | ||
const schema = new SavedObjectsSchema({ | ||
foo: { | ||
isNamespaceAgnostic: false, | ||
}, | ||
}); | ||
const result = schema.isNamespaceAgnostic('foo'); | ||
expect(result).toBe(false); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
interface SavedObjectsSchemaTypeDefinition { | ||
isNamespaceAgnostic: boolean; | ||
} | ||
|
||
export interface SavedObjectsSchemaDefinition { | ||
[key: string]: SavedObjectsSchemaTypeDefinition; | ||
} | ||
|
||
export class SavedObjectsSchema { | ||
private readonly definition?: SavedObjectsSchemaDefinition; | ||
constructor(schemaDefinition?: SavedObjectsSchemaDefinition) { | ||
this.definition = schemaDefinition; | ||
} | ||
|
||
public isNamespaceAgnostic(type: string) { | ||
// if no plugins have registered a uiExports.savedObjectSchemas, | ||
// this.schema will be undefined, and no types are namespace agnostic | ||
if (!this.definition) { | ||
return false; | ||
} | ||
|
||
const typeSchema = this.definition[type]; | ||
if (!typeSchema) { | ||
return false; | ||
} | ||
return Boolean(typeSchema.isNamespaceAgnostic); | ||
} | ||
} |
Oops, something went wrong.