diff --git a/plugins/todo/package.json b/plugins/todo/package.json index c587fb6dc1..59b66dabb0 100644 --- a/plugins/todo/package.json +++ b/plugins/todo/package.json @@ -20,6 +20,7 @@ "clean": "backstage-cli clean" }, "dependencies": { + "@backstage/catalog-model": "^0.7.3", "@backstage/core": "^0.7.0", "@backstage/theme": "^0.2.3", "@material-ui/core": "^4.11.0", diff --git a/plugins/todo/src/api/TodoClient.ts b/plugins/todo/src/api/TodoClient.ts new file mode 100644 index 0000000000..e85e49f1fa --- /dev/null +++ b/plugins/todo/src/api/TodoClient.ts @@ -0,0 +1,23 @@ +/* + * Copyright 2021 Spotify AB + * + * Licensed 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 { TodoApi, TodoListOptions, TodoListResult } from './types'; + +export class TodoClient implements TodoApi { + listTodos(_options: TodoListOptions): Promise { + throw new Error('Method not implemented.'); + } +} diff --git a/plugins/todo/src/api/index.ts b/plugins/todo/src/api/index.ts new file mode 100644 index 0000000000..813a161469 --- /dev/null +++ b/plugins/todo/src/api/index.ts @@ -0,0 +1,19 @@ +/* + * Copyright 2021 Spotify AB + * + * Licensed 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 { TodoClient } from './TodoClient'; +export { todoApiRef } from './types'; +export type { TodoApi } from './types'; diff --git a/plugins/todo/src/api/types.ts b/plugins/todo/src/api/types.ts new file mode 100644 index 0000000000..bc6a15620b --- /dev/null +++ b/plugins/todo/src/api/types.ts @@ -0,0 +1,49 @@ +/* + * Copyright 2021 Spotify AB + * + * Licensed 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 { createApiRef } from '@backstage/core'; +import { Entity } from '@backstage/catalog-model'; + +export type TodoItem = { + text: string; + author?: string; + viewUrl?: string; + editUrl?: string; +}; + +export type TodoListOptions = { + entity?: Entity; + cursor?: string; +}; + +export type TodoListResult = { + items: TodoItem[]; + totalCount: number; + cursors: { + prev: string; + self: string; + next: string; + }; +}; + +export interface TodoApi { + listTodos(options: TodoListOptions): Promise; +} + +export const todoApiRef = createApiRef({ + id: 'plugin.todo.api', + description: 'Lists TODOs', +});