todo-backend: fix API report warnings
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-todo-backend': patch
|
||||
---
|
||||
|
||||
Properly exported all referenced types
|
||||
@@ -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<express.Router>;
|
||||
|
||||
// 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<ReadTodosResult>;
|
||||
}
|
||||
|
||||
// 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<ListTodosResponse>;
|
||||
}
|
||||
|
||||
// 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, 'integrations'>,
|
||||
options: Omit<TodoScmReaderOptions, 'integrations'>,
|
||||
): TodoScmReader;
|
||||
// (undocumented)
|
||||
readTodos(options: ReadTodosOptions): Promise<ReadTodosResult>;
|
||||
}
|
||||
|
||||
// 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<ListTodosResponse>;
|
||||
}
|
||||
|
||||
// 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
|
||||
```
|
||||
|
||||
@@ -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<string, CacheItem>();
|
||||
private readonly inFlightReads = new Map<string, Promise<CacheItem>>();
|
||||
|
||||
static fromConfig(config: Config, options: Omit<Options, 'integrations'>) {
|
||||
static fromConfig(
|
||||
config: Config,
|
||||
options: Omit<TodoScmReaderOptions, 'integrations'>,
|
||||
) {
|
||||
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();
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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<ReadTodosResult>;
|
||||
}
|
||||
|
||||
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[];
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -28,10 +28,12 @@ const TODO_FIELDS = [
|
||||
'repoFilePath',
|
||||
] as const;
|
||||
|
||||
/** @public */
|
||||
export interface RouterOptions {
|
||||
todoService: TodoService;
|
||||
}
|
||||
|
||||
/** @public */
|
||||
export async function createRouter(
|
||||
options: RouterOptions,
|
||||
): Promise<express.Router> {
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user