[Content management] BWC - versioned content (#152729)

This commit is contained in:
Sébastien Loix 2023-03-10 14:36:17 +00:00 committed by GitHub
parent e36ed9658d
commit 206a9d114d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
44 changed files with 715 additions and 804 deletions

View file

@ -8,6 +8,7 @@
import * as React from 'react';
import { ContentClientProvider, ContentClient } from '@kbn/content-management-plugin/public';
import { ContentTypeRegistry } from '@kbn/content-management-plugin/public/registry';
import { Todos } from '../todos';
import { TodosClient } from './todos_client';
@ -19,6 +20,10 @@ export default {
};
const todosClient = new TodosClient();
const contentTypeRegistry = new ContentTypeRegistry();
contentTypeRegistry.register({ id: 'todos', version: { latest: 'v1' } });
const contentClient = new ContentClient((contentType: string) => {
switch (contentType) {
case 'todos':
@ -27,7 +32,7 @@ const contentClient = new ContentClient((contentType: string) => {
default:
throw new Error(`Unknown content type: ${contentType}`);
}
});
}, contentTypeRegistry);
export const SimpleTodoApp = () => (
<ContentClientProvider contentClient={contentClient}>

View file

@ -31,10 +31,17 @@ export class ContentManagementExamplesPlugin
},
});
contentManagement.registry.register({
id: 'todos',
version: {
latest: 'v1',
},
});
return {};
}
public start(core: CoreStart) {
public start(core: CoreStart, deps: StartDeps) {
return {};
}

View file

@ -13,20 +13,13 @@ import {
} from '@kbn/content-management-plugin/server';
import { v4 } from 'uuid';
import {
createInSchema,
searchInSchema,
Todo,
TODO_CONTENT_ID,
updateInSchema,
TodoSearchOut,
TodoCreateOut,
TodoUpdateOut,
TodoDeleteOut,
TodoGetOut,
createOutSchema,
getOutSchema,
updateOutSchema,
searchOutSchema,
TodoUpdateIn,
TodoSearchIn,
TodoCreateIn,
@ -39,40 +32,10 @@ export const registerTodoContentType = ({
}) => {
contentManagement.register({
id: TODO_CONTENT_ID,
schemas: {
content: {
create: {
in: {
data: createInSchema,
},
out: {
result: createOutSchema,
},
},
update: {
in: {
data: updateInSchema,
},
out: {
result: updateOutSchema,
},
},
search: {
in: {
query: searchInSchema,
},
out: {
result: searchOutSchema,
},
},
get: {
out: {
result: getOutSchema,
},
},
},
},
storage: new TodosStorage(),
version: {
latest: 'v1',
},
});
};