diff --git a/.changeset/dry-boats-tap.md b/.changeset/dry-boats-tap.md new file mode 100644 index 0000000000..c69c4360b5 --- /dev/null +++ b/.changeset/dry-boats-tap.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-todo-backend': patch +--- + +Properly exported all referenced types diff --git a/plugins/todo-backend/api-report.md b/plugins/todo-backend/api-report.md index 00e243d1a2..ac8b2ce957 100644 --- a/plugins/todo-backend/api-report.md +++ b/plugins/todo-backend/api-report.md @@ -11,38 +11,27 @@ import { Logger as Logger_2 } from 'winston'; import { ScmIntegrations } from '@backstage/integration'; import { UrlReader } from '@backstage/backend-common'; -// Warning: (ae-forgotten-export) The symbol "RouterOptions" needs to be exported by the entry point index.d.ts -// Warning: (ae-missing-release-tag) "createRouter" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// // @public (undocumented) export function createRouter(options: RouterOptions): Promise; -// Warning: (ae-forgotten-export) The symbol "TodoParserOptions" needs to be exported by the entry point index.d.ts -// Warning: (ae-forgotten-export) The symbol "TodoParser" needs to be exported by the entry point index.d.ts -// Warning: (ae-missing-release-tag) "createTodoParser" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// // @public (undocumented) export function createTodoParser(options?: TodoParserOptions): TodoParser; -// Warning: (ae-missing-release-tag) "ListTodosRequest" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// // @public (undocumented) export type ListTodosRequest = { entity?: EntityName; offset?: number; limit?: number; orderBy?: { - field: Fields; + field: 'text' | 'tag' | 'author' | 'viewUrl' | 'repoFilePath'; direction: 'asc' | 'desc'; }; filters?: { - field: Fields; + field: 'text' | 'tag' | 'author' | 'viewUrl' | 'repoFilePath'; value: string; }[]; }; -// Warning: (ae-missing-release-tag) "ListTodosResponse" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// // @public (undocumented) export type ListTodosResponse = { items: TodoItem[]; @@ -51,22 +40,22 @@ export type ListTodosResponse = { limit: number; }; -// Warning: (ae-missing-release-tag) "ReadTodosOptions" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// // @public (undocumented) export type ReadTodosOptions = { url: string; }; -// Warning: (ae-missing-release-tag) "ReadTodosResult" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// // @public (undocumented) export type ReadTodosResult = { items: TodoItem[]; }; -// Warning: (ae-missing-release-tag) "TodoItem" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// +// @public (undocumented) +export interface RouterOptions { + // (undocumented) + todoService: TodoService; +} + // @public (undocumented) export type TodoItem = { text: string; @@ -77,19 +66,36 @@ export type TodoItem = { repoFilePath?: string; }; -// Warning: (ae-missing-release-tag) "TodoReader" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// +// @public (undocumented) +export type TodoParser = (ctx: TodoParserContext) => TodoParserResult[]; + +// @public (undocumented) +export type TodoParserContext = { + content: string; + path: string; +}; + +// @public (undocumented) +export type TodoParserOptions = { + additionalTags?: string[]; +}; + +// @public (undocumented) +export type TodoParserResult = { + text: string; + tag: string; + author?: string; + lineNumber: number; +}; + // @public (undocumented) export interface TodoReader { readTodos(options: ReadTodosOptions): Promise; } -// Warning: (ae-missing-release-tag) "TodoReaderService" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// // @public (undocumented) export class TodoReaderService implements TodoService { - // Warning: (ae-forgotten-export) The symbol "Options" needs to be exported by the entry point index.d.ts - constructor(options: Options_2); + constructor(options: TodoReaderServiceOptions); // (undocumented) listTodos( req: ListTodosRequest, @@ -99,24 +105,34 @@ export class TodoReaderService implements TodoService { ): Promise; } -// Warning: (ae-missing-release-tag) "TodoScmReader" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// +// @public (undocumented) +export type TodoReaderServiceOptions = { + todoReader: TodoReader; + catalogClient: CatalogApi; + maxPageSize?: number; + defaultPageSize?: number; +}; + // @public (undocumented) export class TodoScmReader implements TodoReader { - constructor(options: Options); - // Warning: (ae-forgotten-export) The symbol "Options" needs to be exported by the entry point index.d.ts - // + constructor(options: TodoScmReaderOptions); // (undocumented) static fromConfig( config: Config, - options: Omit, + options: Omit, ): TodoScmReader; // (undocumented) readTodos(options: ReadTodosOptions): Promise; } -// Warning: (ae-missing-release-tag) "TodoService" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// +// @public (undocumented) +export type TodoScmReaderOptions = { + logger: Logger_2; + reader: UrlReader; + integrations: ScmIntegrations; + parser?: TodoParser; +}; + // @public (undocumented) export interface TodoService { // (undocumented) @@ -127,8 +143,4 @@ export interface TodoService { }, ): Promise; } - -// Warnings were encountered during analysis: -// -// src/service/types.d.ts:9:9 - (ae-forgotten-export) The symbol "Fields" needs to be exported by the entry point index.d.ts ``` diff --git a/plugins/todo-backend/src/lib/TodoReader/TodoScmReader.ts b/plugins/todo-backend/src/lib/TodoReader/TodoScmReader.ts index 804dd1146d..19890a8d23 100644 --- a/plugins/todo-backend/src/lib/TodoReader/TodoScmReader.ts +++ b/plugins/todo-backend/src/lib/TodoReader/TodoScmReader.ts @@ -41,7 +41,8 @@ const excludedExtensions = [ ]; const MAX_FILE_SIZE = 200000; -type Options = { +/** @public */ +export type TodoScmReaderOptions = { logger: Logger; reader: UrlReader; integrations: ScmIntegrations; @@ -53,6 +54,7 @@ type CacheItem = { result: ReadTodosResult; }; +/** @public */ export class TodoScmReader implements TodoReader { private readonly logger: Logger; private readonly reader: UrlReader; @@ -62,14 +64,17 @@ export class TodoScmReader implements TodoReader { private readonly cache = new Map(); private readonly inFlightReads = new Map>(); - static fromConfig(config: Config, options: Omit) { + static fromConfig( + config: Config, + options: Omit, + ) { return new TodoScmReader({ ...options, integrations: ScmIntegrations.fromConfig(config), }); } - constructor(options: Options) { + constructor(options: TodoScmReaderOptions) { this.logger = options.logger; this.reader = options.reader; this.parser = options.parser ?? createTodoParser(); diff --git a/plugins/todo-backend/src/lib/TodoReader/createTodoParser.ts b/plugins/todo-backend/src/lib/TodoReader/createTodoParser.ts index 2835f0e8d5..720efe316b 100644 --- a/plugins/todo-backend/src/lib/TodoReader/createTodoParser.ts +++ b/plugins/todo-backend/src/lib/TodoReader/createTodoParser.ts @@ -18,11 +18,13 @@ import { extname } from 'path'; import { parse } from 'leasot'; import { TodoParser } from './types'; +/** @public */ export type TodoParserOptions = { /** Custom tags to support in addition to TODO and FIXME */ additionalTags?: string[]; }; +/** @public */ export function createTodoParser(options: TodoParserOptions = {}): TodoParser { return ({ content, path }) => { try { diff --git a/plugins/todo-backend/src/lib/TodoReader/index.ts b/plugins/todo-backend/src/lib/TodoReader/index.ts index aa7c36a09b..d0537861da 100644 --- a/plugins/todo-backend/src/lib/TodoReader/index.ts +++ b/plugins/todo-backend/src/lib/TodoReader/index.ts @@ -15,10 +15,15 @@ */ export { TodoScmReader } from './TodoScmReader'; +export type { TodoScmReaderOptions } from './TodoScmReader'; export { createTodoParser } from './createTodoParser'; +export type { TodoParserOptions } from './createTodoParser'; export type { TodoItem, TodoReader, ReadTodosOptions, ReadTodosResult, + TodoParser, + TodoParserContext, + TodoParserResult, } from './types'; diff --git a/plugins/todo-backend/src/lib/TodoReader/types.ts b/plugins/todo-backend/src/lib/TodoReader/types.ts index 14a622b482..628a78f0c2 100644 --- a/plugins/todo-backend/src/lib/TodoReader/types.ts +++ b/plugins/todo-backend/src/lib/TodoReader/types.ts @@ -14,6 +14,7 @@ * limitations under the License. */ +/** @public */ export type TodoItem = { /** The contents of the TODO comment */ text: string; @@ -34,6 +35,7 @@ export type TodoItem = { repoFilePath?: string; }; +/** @public */ export type ReadTodosOptions = { /** * Base URLs defining the root at which to search for TODOs @@ -41,6 +43,7 @@ export type ReadTodosOptions = { url: string; }; +/** @public */ export type ReadTodosResult = { /** * TODO items found at the given locations @@ -48,6 +51,7 @@ export type ReadTodosResult = { items: TodoItem[]; }; +/** @public */ export interface TodoReader { /** * Searches for TODO items in code at a given location @@ -55,16 +59,19 @@ export interface TodoReader { readTodos(options: ReadTodosOptions): Promise; } -type TodoParserContext = { +/** @public */ +export type TodoParserContext = { content: string; path: string; }; -type TodoParserResult = { +/** @public */ +export type TodoParserResult = { text: string; tag: string; author?: string; lineNumber: number; }; +/** @public */ export type TodoParser = (ctx: TodoParserContext) => TodoParserResult[]; diff --git a/plugins/todo-backend/src/service/TodoReaderService.ts b/plugins/todo-backend/src/service/TodoReaderService.ts index 6623f8090f..54957d89c4 100644 --- a/plugins/todo-backend/src/service/TodoReaderService.ts +++ b/plugins/todo-backend/src/service/TodoReaderService.ts @@ -29,7 +29,8 @@ import { ListTodosRequest, ListTodosResponse, TodoService } from './types'; const DEFAULT_DEFAULT_PAGE_SIZE = 10; const DEFAULT_MAX_PAGE_SIZE = 50; -type Options = { +/** @public */ +export type TodoReaderServiceOptions = { todoReader: TodoReader; catalogClient: CatalogApi; maxPageSize?: number; @@ -43,13 +44,14 @@ function wildcardRegex(str: string): RegExp { return new RegExp(`^${pattern}$`, 'i'); } +/** @public */ export class TodoReaderService implements TodoService { private readonly todoReader: TodoReader; private readonly catalogClient: CatalogApi; private readonly maxPageSize: number; private readonly defaultPageSize: number; - constructor(options: Options) { + constructor(options: TodoReaderServiceOptions) { this.todoReader = options.todoReader; this.catalogClient = options.catalogClient; this.maxPageSize = options.maxPageSize ?? DEFAULT_MAX_PAGE_SIZE; diff --git a/plugins/todo-backend/src/service/index.ts b/plugins/todo-backend/src/service/index.ts index 893d615405..380d95dbe1 100644 --- a/plugins/todo-backend/src/service/index.ts +++ b/plugins/todo-backend/src/service/index.ts @@ -15,5 +15,7 @@ */ export { createRouter } from './router'; +export type { RouterOptions } from './router'; export type { TodoService, ListTodosRequest, ListTodosResponse } from './types'; export { TodoReaderService } from './TodoReaderService'; +export type { TodoReaderServiceOptions } from './TodoReaderService'; diff --git a/plugins/todo-backend/src/service/router.ts b/plugins/todo-backend/src/service/router.ts index 91de76e358..203e552161 100644 --- a/plugins/todo-backend/src/service/router.ts +++ b/plugins/todo-backend/src/service/router.ts @@ -28,10 +28,12 @@ const TODO_FIELDS = [ 'repoFilePath', ] as const; +/** @public */ export interface RouterOptions { todoService: TodoService; } +/** @public */ export async function createRouter( options: RouterOptions, ): Promise { diff --git a/plugins/todo-backend/src/service/types.ts b/plugins/todo-backend/src/service/types.ts index f29e0d9908..90ee6bc913 100644 --- a/plugins/todo-backend/src/service/types.ts +++ b/plugins/todo-backend/src/service/types.ts @@ -17,23 +17,23 @@ import { EntityName } from '@backstage/catalog-model'; import { TodoItem } from '../lib'; -type Fields = 'text' | 'tag' | 'author' | 'viewUrl' | 'repoFilePath'; - +/** @public */ export type ListTodosRequest = { entity?: EntityName; offset?: number; limit?: number; orderBy?: { - field: Fields; + field: 'text' | 'tag' | 'author' | 'viewUrl' | 'repoFilePath'; direction: 'asc' | 'desc'; }; filters?: { - field: Fields; + field: 'text' | 'tag' | 'author' | 'viewUrl' | 'repoFilePath'; /** Value to filter by, with '*' used as wildcard */ value: string; }[]; }; +/** @public */ export type ListTodosResponse = { items: TodoItem[]; totalCount: number; @@ -41,6 +41,7 @@ export type ListTodosResponse = { limit: number; }; +/** @public */ export interface TodoService { listTodos( req: ListTodosRequest,