diff --git a/packages/repo-tools/src/commands/package/schema/openapi/generate/server.ts b/packages/repo-tools/src/commands/package/schema/openapi/generate/server.ts index 2525bb9f98..ad5d3d8f82 100644 --- a/packages/repo-tools/src/commands/package/schema/openapi/generate/server.ts +++ b/packages/repo-tools/src/commands/package/schema/openapi/generate/server.ts @@ -42,7 +42,7 @@ async function generateSpecFile() { await fs.mkdirp(schemaDir); const oldTsPath = cliPaths.resolveTarget(OLD_SCHEMA_PATH); - if (oldTsPath) { + if (fs.existsSync(oldTsPath)) { console.warn(`Removing old schema file at ${oldTsPath}`); fs.removeSync(oldTsPath); } diff --git a/packages/repo-tools/templates/typescript-backstage-client/api.mustache b/packages/repo-tools/templates/typescript-backstage-client/api.mustache index ee8ea4d17e..36a200e5d7 100644 --- a/packages/repo-tools/templates/typescript-backstage-client/api.mustache +++ b/packages/repo-tools/templates/typescript-backstage-client/api.mustache @@ -92,7 +92,6 @@ export class {{classname}}Client { {{/allParams}} */ public async {{nickname}}( - // @ts-ignore request: {{#lambda.pascalcase}}{{nickname}}{{/lambda.pascalcase}}, options?: RequestOptions ): Promise> { diff --git a/plugins/search-backend/package.json b/plugins/search-backend/package.json index 52688fe512..d335756b7d 100644 --- a/plugins/search-backend/package.json +++ b/plugins/search-backend/package.json @@ -47,13 +47,13 @@ "scripts": { "build": "backstage-cli package build", "clean": "backstage-cli package clean", - "fuzz": "backstage-repo-tools package schema openapi fuzz", - "generate": "backstage-repo-tools package schema openapi generate --server", "lint": "backstage-cli package lint", "prepack": "backstage-cli package prepack", "postpack": "backstage-cli package postpack", "start": "backstage-cli package start", - "test": "backstage-cli package test" + "test": "backstage-cli package test", + "generate": "backstage-repo-tools package schema openapi generate --server --client-package plugins/search-common --server-client-import \"@backstage/plugin-search-common/client\"", + "fuzz": "backstage-repo-tools package schema openapi fuzz" }, "dependencies": { "@backstage/backend-common": "^0.25.0", diff --git a/plugins/search-backend/src/schema/openapi/generated/apis/DefaultApi.server.ts b/plugins/search-backend/src/schema/openapi/generated/apis/DefaultApi.server.ts new file mode 100644 index 0000000000..bd65e15c70 --- /dev/null +++ b/plugins/search-backend/src/schema/openapi/generated/apis/DefaultApi.server.ts @@ -0,0 +1,28 @@ +/* + * Copyright 2024 The Backstage Authors + * + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** +import type { Query } from '@backstage/plugin-search-common/client'; + +/** + * no description + */ + +export type EndpointMap = { + '#get|/query': Query; +}; diff --git a/plugins/search-backend/src/schema/openapi/generated/apis/index.ts b/plugins/search-backend/src/schema/openapi/generated/apis/index.ts new file mode 100644 index 0000000000..79855a6fc8 --- /dev/null +++ b/plugins/search-backend/src/schema/openapi/generated/apis/index.ts @@ -0,0 +1,17 @@ +/* + * Copyright 2024 The Backstage Authors + * + * 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 * from './DefaultApi.server'; diff --git a/plugins/search-backend/src/schema/openapi/generated/index.ts b/plugins/search-backend/src/schema/openapi/generated/index.ts new file mode 100644 index 0000000000..69c39313c6 --- /dev/null +++ b/plugins/search-backend/src/schema/openapi/generated/index.ts @@ -0,0 +1,18 @@ +/* + * Copyright 2024 The Backstage Authors + * + * 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 * from './apis'; +export * from './router'; diff --git a/plugins/search-backend/src/schema/openapi.generated.ts b/plugins/search-backend/src/schema/openapi/generated/router.ts similarity index 95% rename from plugins/search-backend/src/schema/openapi.generated.ts rename to plugins/search-backend/src/schema/openapi/generated/router.ts index 1e6adfb08f..8d55dfeef2 100644 --- a/plugins/search-backend/src/schema/openapi.generated.ts +++ b/plugins/search-backend/src/schema/openapi/generated/router.ts @@ -17,7 +17,8 @@ // ****************************************************************** // * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * // ****************************************************************** -import { createValidatedOpenApiRouter } from '@backstage/backend-openapi-utils'; +import { createValidatedOpenApiRouterFromGeneratedEndpointMap } from '@backstage/backend-openapi-utils'; +import { EndpointMap } from './'; export const spec = { openapi: '3.0.3', @@ -261,5 +262,11 @@ export const spec = { }, } as const; export const createOpenApiRouter = async ( - options?: Parameters['1'], -) => createValidatedOpenApiRouter(spec, options); + options?: Parameters< + typeof createValidatedOpenApiRouterFromGeneratedEndpointMap + >['1'], +) => + createValidatedOpenApiRouterFromGeneratedEndpointMap( + spec, + options, + ); diff --git a/plugins/search-backend/src/schema/openapi/index.ts b/plugins/search-backend/src/schema/openapi/index.ts new file mode 100644 index 0000000000..db98243cbf --- /dev/null +++ b/plugins/search-backend/src/schema/openapi/index.ts @@ -0,0 +1,17 @@ +/* + * Copyright 2024 The Backstage Authors + * + * 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 * from './generated'; diff --git a/plugins/search-backend/src/service/router.ts b/plugins/search-backend/src/service/router.ts index 9c22290a63..ab2d929ec1 100644 --- a/plugins/search-backend/src/service/router.ts +++ b/plugins/search-backend/src/service/router.ts @@ -32,7 +32,7 @@ import { } from '@backstage/plugin-search-common'; import { SearchEngine } from '@backstage/plugin-search-backend-node'; import { AuthorizedSearchEngine } from './AuthorizedSearchEngine'; -import { createOpenApiRouter } from '../schema/openapi.generated'; +import { createOpenApiRouter } from '../schema/openapi'; import { AuthService, DiscoveryService, diff --git a/plugins/search-common/package.json b/plugins/search-common/package.json index 10524c1515..25c60894bb 100644 --- a/plugins/search-common/package.json +++ b/plugins/search-common/package.json @@ -31,10 +31,25 @@ "url": "https://github.com/backstage/backstage", "directory": "plugins/search-common" }, + "exports": { + ".": "./src/index.ts", + "./client": "./src/client.ts", + "./package.json": "./package.json" + }, "license": "Apache-2.0", "sideEffects": false, "main": "src/index.ts", "types": "src/index.ts", + "typesVersions": { + "*": { + "client": [ + "src/client.ts" + ], + "package.json": [ + "package.json" + ] + } + }, "files": [ "dist" ], @@ -53,7 +68,9 @@ }, "dependencies": { "@backstage/plugin-permission-common": "workspace:^", - "@backstage/types": "workspace:^" + "@backstage/types": "workspace:^", + "cross-fetch": "^4.0.0", + "uri-template": "^2.0.0" }, "devDependencies": { "@backstage/cli": "workspace:^" diff --git a/plugins/search-common/src/client.ts b/plugins/search-common/src/client.ts new file mode 100644 index 0000000000..a46b762ba7 --- /dev/null +++ b/plugins/search-common/src/client.ts @@ -0,0 +1,16 @@ +/* + * Copyright 2024 The Backstage Authors + * + * 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 * from './schema/openapi/generated'; diff --git a/plugins/search-common/src/schema/openapi/generated/apis/DefaultApi.client.ts b/plugins/search-common/src/schema/openapi/generated/apis/DefaultApi.client.ts new file mode 100644 index 0000000000..6abb955794 --- /dev/null +++ b/plugins/search-common/src/schema/openapi/generated/apis/DefaultApi.client.ts @@ -0,0 +1,103 @@ +/* + * Copyright 2024 The Backstage Authors + * + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** +import { DiscoveryApi } from '../types/discovery'; +import { FetchApi } from '../types/fetch'; +import crossFetch from 'cross-fetch'; +import { pluginId } from '../pluginId'; +import * as parser from 'uri-template'; + +import { Query200Response } from '../models/Query200Response.model'; + +/** + * Wraps the Response type to convey a type on the json call. + * + * @public + */ +export type TypedResponse = Omit & { + json: () => Promise; +}; + +/** + * Options you can pass into a request for additional information. + * + * @public + */ +export interface RequestOptions { + token?: string; +} + +/** + * @public + */ +export type Query = { + query: { + term?: string; + filters?: { [key: string]: any }; + types?: Array; + pageCursor?: string; + pageLimit?: number; + }; +}; + +/** + * no description + * @public + */ +export class DefaultApiClient { + private readonly discoveryApi: DiscoveryApi; + private readonly fetchApi: FetchApi; + + constructor(options: { + discoveryApi: { getBaseUrl(pluginId: string): Promise }; + fetchApi?: { fetch: typeof fetch }; + }) { + this.discoveryApi = options.discoveryApi; + this.fetchApi = options.fetchApi || { fetch: crossFetch }; + } + + /** + * Query documents with a given filter. + * @param term - + * @param filters - + * @param types - + * @param pageCursor - + * @param pageLimit - + */ + public async query( + request: Query, + options?: RequestOptions, + ): Promise> { + const baseUrl = await this.discoveryApi.getBaseUrl(pluginId); + + const uriTemplate = `/query{?term,filters,types*,pageCursor,pageLimit}`; + + const uri = parser.parse(uriTemplate).expand({ + ...request.query, + }); + + return await this.fetchApi.fetch(`${baseUrl}${uri}`, { + headers: { + 'Content-Type': 'application/json', + ...(options?.token && { Authorization: `Bearer ${options?.token}` }), + }, + method: 'GET', + }); + } +} diff --git a/plugins/search-common/src/schema/openapi/generated/apis/index.ts b/plugins/search-common/src/schema/openapi/generated/apis/index.ts new file mode 100644 index 0000000000..51dcca33fe --- /dev/null +++ b/plugins/search-common/src/schema/openapi/generated/apis/index.ts @@ -0,0 +1,17 @@ +/* + * Copyright 2024 The Backstage Authors + * + * 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 * from './DefaultApi.client'; diff --git a/plugins/search-common/src/schema/openapi/generated/index.ts b/plugins/search-common/src/schema/openapi/generated/index.ts new file mode 100644 index 0000000000..bb399e97a0 --- /dev/null +++ b/plugins/search-common/src/schema/openapi/generated/index.ts @@ -0,0 +1,18 @@ +/* + * Copyright 2024 The Backstage Authors + * + * 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 * from './apis'; +export * from './models'; diff --git a/plugins/search-common/src/schema/openapi/generated/models/ErrorError.model.ts b/plugins/search-common/src/schema/openapi/generated/models/ErrorError.model.ts new file mode 100644 index 0000000000..0a51c67fef --- /dev/null +++ b/plugins/search-common/src/schema/openapi/generated/models/ErrorError.model.ts @@ -0,0 +1,27 @@ +/* + * Copyright 2024 The Backstage Authors + * + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** + +/** + * @public + */ +export interface ErrorError { + name: string; + message: string; +} diff --git a/plugins/search-common/src/schema/openapi/generated/models/ErrorRequest.model.ts b/plugins/search-common/src/schema/openapi/generated/models/ErrorRequest.model.ts new file mode 100644 index 0000000000..d44dcb66d9 --- /dev/null +++ b/plugins/search-common/src/schema/openapi/generated/models/ErrorRequest.model.ts @@ -0,0 +1,27 @@ +/* + * Copyright 2024 The Backstage Authors + * + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** + +/** + * @public + */ +export interface ErrorRequest { + method: string; + url: string; +} diff --git a/plugins/search-common/src/schema/openapi/generated/models/ErrorResponse.model.ts b/plugins/search-common/src/schema/openapi/generated/models/ErrorResponse.model.ts new file mode 100644 index 0000000000..91c120483d --- /dev/null +++ b/plugins/search-common/src/schema/openapi/generated/models/ErrorResponse.model.ts @@ -0,0 +1,26 @@ +/* + * Copyright 2024 The Backstage Authors + * + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** + +/** + * @public + */ +export interface ErrorResponse { + statusCode: number; +} diff --git a/plugins/search-common/src/schema/openapi/generated/models/ModelError.model.ts b/plugins/search-common/src/schema/openapi/generated/models/ModelError.model.ts new file mode 100644 index 0000000000..3e6af947ec --- /dev/null +++ b/plugins/search-common/src/schema/openapi/generated/models/ModelError.model.ts @@ -0,0 +1,31 @@ +/* + * Copyright 2024 The Backstage Authors + * + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** +import { ErrorError } from '../models/ErrorError.model'; +import { ErrorRequest } from '../models/ErrorRequest.model'; +import { ErrorResponse } from '../models/ErrorResponse.model'; + +/** + * @public + */ +export interface ModelError { + error: ErrorError; + request: ErrorRequest; + response: ErrorResponse; +} diff --git a/plugins/search-common/src/schema/openapi/generated/models/Query200Response.model.ts b/plugins/search-common/src/schema/openapi/generated/models/Query200Response.model.ts new file mode 100644 index 0000000000..8ddb2a0b63 --- /dev/null +++ b/plugins/search-common/src/schema/openapi/generated/models/Query200Response.model.ts @@ -0,0 +1,30 @@ +/* + * Copyright 2024 The Backstage Authors + * + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** +import { Query200ResponseResultsInner } from '../models/Query200ResponseResultsInner.model'; + +/** + * @public + */ +export interface Query200Response { + results: Array; + nextPageCursor?: string; + previousPageCursor?: string; + numberOfResults?: number; +} diff --git a/plugins/search-common/src/schema/openapi/generated/models/Query200ResponseResultsInner.model.ts b/plugins/search-common/src/schema/openapi/generated/models/Query200ResponseResultsInner.model.ts new file mode 100644 index 0000000000..ec635c8e5b --- /dev/null +++ b/plugins/search-common/src/schema/openapi/generated/models/Query200ResponseResultsInner.model.ts @@ -0,0 +1,39 @@ +/* + * Copyright 2024 The Backstage Authors + * + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** +import { Query200ResponseResultsInnerDocument } from '../models/Query200ResponseResultsInnerDocument.model'; + +/** + * @public + */ +export interface Query200ResponseResultsInner { + /** + * The \"type\" of the given document. + */ + type: string; + document: Query200ResponseResultsInnerDocument; + /** + * Optional result highlight. Useful for improving the search result display/experience. + */ + highlight?: any; + /** + * Optional result rank, where 1 is the first/top result returned. Useful for understanding search effectiveness in analytics. + */ + rank?: number; +} diff --git a/plugins/search-common/src/schema/openapi/generated/models/Query200ResponseResultsInnerDocument.model.ts b/plugins/search-common/src/schema/openapi/generated/models/Query200ResponseResultsInnerDocument.model.ts new file mode 100644 index 0000000000..9e82274aa7 --- /dev/null +++ b/plugins/search-common/src/schema/openapi/generated/models/Query200ResponseResultsInnerDocument.model.ts @@ -0,0 +1,38 @@ +/* + * Copyright 2024 The Backstage Authors + * + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** + +/** + * The raw value of the document, as indexed. + * @public + */ +export interface Query200ResponseResultsInnerDocument { + /** + * The primary name of the document (e.g. name, title, identifier, etc). + */ + title?: string; + /** + * Free-form text of the document (e.g. description, content, etc). + */ + text?: string; + /** + * The relative or absolute URL of the document (target when a search result is clicked). + */ + location?: string; +} diff --git a/plugins/search-common/src/schema/openapi/generated/models/index.ts b/plugins/search-common/src/schema/openapi/generated/models/index.ts new file mode 100644 index 0000000000..d38087bf8c --- /dev/null +++ b/plugins/search-common/src/schema/openapi/generated/models/index.ts @@ -0,0 +1,23 @@ +/* + * Copyright 2024 The Backstage Authors + * + * 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 * from '../models/ErrorError.model'; +export * from '../models/ErrorRequest.model'; +export * from '../models/ErrorResponse.model'; +export * from '../models/ModelError.model'; +export * from '../models/Query200Response.model'; +export * from '../models/Query200ResponseResultsInner.model'; +export * from '../models/Query200ResponseResultsInnerDocument.model'; diff --git a/plugins/search-common/src/schema/openapi/generated/pluginId.ts b/plugins/search-common/src/schema/openapi/generated/pluginId.ts new file mode 100644 index 0000000000..13046254c7 --- /dev/null +++ b/plugins/search-common/src/schema/openapi/generated/pluginId.ts @@ -0,0 +1,17 @@ +/* + * Copyright 2024 The Backstage Authors + * + * 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 const pluginId = 'search'; diff --git a/plugins/search-common/src/schema/openapi/generated/types/discovery.ts b/plugins/search-common/src/schema/openapi/generated/types/discovery.ts new file mode 100644 index 0000000000..a7f87d3780 --- /dev/null +++ b/plugins/search-common/src/schema/openapi/generated/types/discovery.ts @@ -0,0 +1,22 @@ +/* + * Copyright 2023 The Backstage Authors + * + * 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. + */ + +/** + * This is a copy of the DiscoveryApi, to avoid importing core-plugin-api. + */ +export type DiscoveryApi = { + getBaseUrl(pluginId: string): Promise; +}; diff --git a/plugins/search-common/src/schema/openapi/generated/types/fetch.ts b/plugins/search-common/src/schema/openapi/generated/types/fetch.ts new file mode 100644 index 0000000000..3de56c028e --- /dev/null +++ b/plugins/search-common/src/schema/openapi/generated/types/fetch.ts @@ -0,0 +1,22 @@ +/* + * Copyright 2023 The Backstage Authors + * + * 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. + */ + +/** + * This is a copy of FetchApi, to avoid importing core-plugin-api. + */ +export type FetchApi = { + fetch: typeof fetch; +}; diff --git a/plugins/todo-backend/src/schema/openapi/generated/apis/DefaultApi.server.ts b/plugins/todo-backend/src/schema/openapi/generated/apis/DefaultApi.server.ts new file mode 100644 index 0000000000..6054e4d45d --- /dev/null +++ b/plugins/todo-backend/src/schema/openapi/generated/apis/DefaultApi.server.ts @@ -0,0 +1,28 @@ +/* + * Copyright 2024 The Backstage Authors + * + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** +import type { ListTodos } from '@backstage/plugin-todo-common/client'; + +/** + * no description + */ + +export type EndpointMap = { + '#get|/v1/todos': ListTodos; +}; diff --git a/plugins/todo-backend/src/schema/openapi/generated/apis/index.ts b/plugins/todo-backend/src/schema/openapi/generated/apis/index.ts new file mode 100644 index 0000000000..79855a6fc8 --- /dev/null +++ b/plugins/todo-backend/src/schema/openapi/generated/apis/index.ts @@ -0,0 +1,17 @@ +/* + * Copyright 2024 The Backstage Authors + * + * 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 * from './DefaultApi.server'; diff --git a/plugins/todo-backend/src/schema/openapi/generated/index.ts b/plugins/todo-backend/src/schema/openapi/generated/index.ts new file mode 100644 index 0000000000..69c39313c6 --- /dev/null +++ b/plugins/todo-backend/src/schema/openapi/generated/index.ts @@ -0,0 +1,18 @@ +/* + * Copyright 2024 The Backstage Authors + * + * 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 * from './apis'; +export * from './router'; diff --git a/plugins/todo-backend/src/schema/openapi/index.ts b/plugins/todo-backend/src/schema/openapi/index.ts new file mode 100644 index 0000000000..db98243cbf --- /dev/null +++ b/plugins/todo-backend/src/schema/openapi/index.ts @@ -0,0 +1,17 @@ +/* + * Copyright 2024 The Backstage Authors + * + * 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 * from './generated'; diff --git a/plugins/todo-common/.eslintrc.js b/plugins/todo-common/.eslintrc.js new file mode 100644 index 0000000000..e2a53a6ad2 --- /dev/null +++ b/plugins/todo-common/.eslintrc.js @@ -0,0 +1 @@ +module.exports = require('@backstage/cli/config/eslint-factory')(__dirname); diff --git a/plugins/todo-common/README.md b/plugins/todo-common/README.md new file mode 100644 index 0000000000..542f7e1126 --- /dev/null +++ b/plugins/todo-common/README.md @@ -0,0 +1,5 @@ +# backstage-plugin-todo-common + +Welcome to the common package for the todo plugin! + +_This plugin was created through the Backstage CLI_ diff --git a/plugins/todo-common/catalog-info.yaml b/plugins/todo-common/catalog-info.yaml new file mode 100644 index 0000000000..ad20fb88e4 --- /dev/null +++ b/plugins/todo-common/catalog-info.yaml @@ -0,0 +1,10 @@ +apiVersion: backstage.io/v1alpha1 +kind: Component +metadata: + name: backstage-plugin-todo-common + title: '@backstage/plugin-todo-common' + description: Common functionalities for the todo plugin +spec: + lifecycle: experimental + type: backstage-common-library + owner: maintainers diff --git a/plugins/todo-common/package.json b/plugins/todo-common/package.json new file mode 100644 index 0000000000..767c91124e --- /dev/null +++ b/plugins/todo-common/package.json @@ -0,0 +1,52 @@ +{ + "name": "@backstage/plugin-todo-common", + "description": "Common functionalities for the todo plugin", + "version": "0.0.0", + "main": "src/index.ts", + "types": "src/index.ts", + "license": "Apache-2.0", + "private": true, + "publishConfig": { + "access": "public", + "main": "dist/index.cjs.js", + "module": "dist/index.esm.js", + "types": "dist/index.d.ts" + }, + "backstage": { + "role": "common-library" + }, + "exports": { + ".": "./src/index.ts", + "./client": "./src/client.ts", + "./package.json": "./package.json" + }, + "typesVersions": { + "*": { + "client": [ + "src/client.ts" + ], + "package.json": [ + "package.json" + ] + } + }, + "sideEffects": false, + "scripts": { + "build": "backstage-cli package build", + "lint": "backstage-cli package lint", + "test": "backstage-cli package test", + "clean": "backstage-cli package clean", + "prepack": "backstage-cli package prepack", + "postpack": "backstage-cli package postpack" + }, + "devDependencies": { + "@backstage/cli": "workspace:^" + }, + "files": [ + "dist" + ], + "dependencies": { + "cross-fetch": "^4.0.0", + "uri-template": "^2.0.0" + } +} diff --git a/plugins/todo-common/src/client.ts b/plugins/todo-common/src/client.ts new file mode 100644 index 0000000000..a46b762ba7 --- /dev/null +++ b/plugins/todo-common/src/client.ts @@ -0,0 +1,16 @@ +/* + * Copyright 2024 The Backstage Authors + * + * 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 * from './schema/openapi/generated'; diff --git a/plugins/todo-common/src/index.ts b/plugins/todo-common/src/index.ts new file mode 100644 index 0000000000..b0d900d42e --- /dev/null +++ b/plugins/todo-common/src/index.ts @@ -0,0 +1,34 @@ +/* + * Copyright 2024 The Backstage Authors + * + * 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. + */ + +/** + * Common functionalities for the todo plugin. + * + * @packageDocumentation + */ + +/** + * In this package you might for example declare types that are common + * between the frontend and backend plugin packages. + */ +export type CommonType = { + field: string; +}; + +/** + * Or you might declare some common constants. + */ +export const COMMON_CONSTANT = 1; diff --git a/plugins/todo-common/src/schema/openapi/generated/apis/DefaultApi.client.ts b/plugins/todo-common/src/schema/openapi/generated/apis/DefaultApi.client.ts new file mode 100644 index 0000000000..9eb423ecb7 --- /dev/null +++ b/plugins/todo-common/src/schema/openapi/generated/apis/DefaultApi.client.ts @@ -0,0 +1,102 @@ +/* + * Copyright 2024 The Backstage Authors + * + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** +import { DiscoveryApi } from '../types/discovery'; +import { FetchApi } from '../types/fetch'; +import crossFetch from 'cross-fetch'; +import { pluginId } from '../pluginId'; +import * as parser from 'uri-template'; + +import { ListTodos200Response } from '../models/ListTodos200Response.model'; + +/** + * Wraps the Response type to convey a type on the json call. + * + * @public + */ +export type TypedResponse = Omit & { + json: () => Promise; +}; + +/** + * Options you can pass into a request for additional information. + * + * @public + */ +export interface RequestOptions { + token?: string; +} + +/** + * @public + */ +export type ListTodos = { + query: { + entity?: string; + orderBy?: string; + filter?: Array; + offset?: number; + limit?: number; + }; +}; + +/** + * no description + * @public + */ +export class DefaultApiClient { + private readonly discoveryApi: DiscoveryApi; + private readonly fetchApi: FetchApi; + + constructor(options: { + discoveryApi: { getBaseUrl(pluginId: string): Promise }; + fetchApi?: { fetch: typeof fetch }; + }) { + this.discoveryApi = options.discoveryApi; + this.fetchApi = options.fetchApi || { fetch: crossFetch }; + } + + /** + * @param entity - + * @param orderBy - + * @param filter - + * @param offset - + * @param limit - + */ + public async listTodos( + request: ListTodos, + options?: RequestOptions, + ): Promise> { + const baseUrl = await this.discoveryApi.getBaseUrl(pluginId); + + const uriTemplate = `/v1/todos{?entity,orderBy,filter*,offset,limit}`; + + const uri = parser.parse(uriTemplate).expand({ + ...request.query, + }); + + return await this.fetchApi.fetch(`${baseUrl}${uri}`, { + headers: { + 'Content-Type': 'application/json', + ...(options?.token && { Authorization: `Bearer ${options?.token}` }), + }, + method: 'GET', + }); + } +} diff --git a/plugins/todo-common/src/schema/openapi/generated/apis/index.ts b/plugins/todo-common/src/schema/openapi/generated/apis/index.ts new file mode 100644 index 0000000000..51dcca33fe --- /dev/null +++ b/plugins/todo-common/src/schema/openapi/generated/apis/index.ts @@ -0,0 +1,17 @@ +/* + * Copyright 2024 The Backstage Authors + * + * 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 * from './DefaultApi.client'; diff --git a/plugins/todo-common/src/schema/openapi/generated/index.ts b/plugins/todo-common/src/schema/openapi/generated/index.ts new file mode 100644 index 0000000000..bb399e97a0 --- /dev/null +++ b/plugins/todo-common/src/schema/openapi/generated/index.ts @@ -0,0 +1,18 @@ +/* + * Copyright 2024 The Backstage Authors + * + * 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 * from './apis'; +export * from './models'; diff --git a/plugins/todo-common/src/schema/openapi/generated/models/ListTodos200Response.model.ts b/plugins/todo-common/src/schema/openapi/generated/models/ListTodos200Response.model.ts new file mode 100644 index 0000000000..5aa13bc4c0 --- /dev/null +++ b/plugins/todo-common/src/schema/openapi/generated/models/ListTodos200Response.model.ts @@ -0,0 +1,30 @@ +/* + * Copyright 2024 The Backstage Authors + * + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** +import { TodoItem } from '../models/TodoItem.model'; + +/** + * @public + */ +export interface ListTodos200Response { + items: Array; + totalCount: number; + offset: number; + limit: number; +} diff --git a/plugins/todo-common/src/schema/openapi/generated/models/ListTodos400Response.model.ts b/plugins/todo-common/src/schema/openapi/generated/models/ListTodos400Response.model.ts new file mode 100644 index 0000000000..8a78ff797a --- /dev/null +++ b/plugins/todo-common/src/schema/openapi/generated/models/ListTodos400Response.model.ts @@ -0,0 +1,27 @@ +/* + * Copyright 2024 The Backstage Authors + * + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** +import { ListTodos400ResponseError } from '../models/ListTodos400ResponseError.model'; + +/** + * @public + */ +export interface ListTodos400Response { + error?: ListTodos400ResponseError; +} diff --git a/plugins/todo-common/src/schema/openapi/generated/models/ListTodos400ResponseError.model.ts b/plugins/todo-common/src/schema/openapi/generated/models/ListTodos400ResponseError.model.ts new file mode 100644 index 0000000000..7ed1b08427 --- /dev/null +++ b/plugins/todo-common/src/schema/openapi/generated/models/ListTodos400ResponseError.model.ts @@ -0,0 +1,26 @@ +/* + * Copyright 2024 The Backstage Authors + * + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** + +/** + * @public + */ +export interface ListTodos400ResponseError { + message?: string; +} diff --git a/plugins/todo-common/src/schema/openapi/generated/models/TodoItem.model.ts b/plugins/todo-common/src/schema/openapi/generated/models/TodoItem.model.ts new file mode 100644 index 0000000000..99a3062465 --- /dev/null +++ b/plugins/todo-common/src/schema/openapi/generated/models/TodoItem.model.ts @@ -0,0 +1,49 @@ +/* + * Copyright 2024 The Backstage Authors + * + * 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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** + +/** + * @public + */ +export interface TodoItem { + /** + * The contents of the TODO comment + */ + text: string; + /** + * The tag used, e.g. TODO, FIXME + */ + tag: string; + /** + * References author, if any + */ + author?: string; + /** + * URL used to view the file + */ + viewUrl?: string; + /** + * The line number of the file that the TODO occurs at + */ + lineNumber?: number; + /** + * The path of the file containing the TODO within the repo + */ + repoFilePath?: string; +} diff --git a/plugins/todo-common/src/schema/openapi/generated/models/index.ts b/plugins/todo-common/src/schema/openapi/generated/models/index.ts new file mode 100644 index 0000000000..e4ce8db3e3 --- /dev/null +++ b/plugins/todo-common/src/schema/openapi/generated/models/index.ts @@ -0,0 +1,20 @@ +/* + * Copyright 2024 The Backstage Authors + * + * 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 * from '../models/ListTodos200Response.model'; +export * from '../models/ListTodos400Response.model'; +export * from '../models/ListTodos400ResponseError.model'; +export * from '../models/TodoItem.model'; diff --git a/plugins/todo-common/src/schema/openapi/generated/pluginId.ts b/plugins/todo-common/src/schema/openapi/generated/pluginId.ts new file mode 100644 index 0000000000..9952759225 --- /dev/null +++ b/plugins/todo-common/src/schema/openapi/generated/pluginId.ts @@ -0,0 +1,17 @@ +/* + * Copyright 2024 The Backstage Authors + * + * 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 const pluginId = 'todo'; diff --git a/plugins/todo-common/src/schema/openapi/generated/types/discovery.ts b/plugins/todo-common/src/schema/openapi/generated/types/discovery.ts new file mode 100644 index 0000000000..a7f87d3780 --- /dev/null +++ b/plugins/todo-common/src/schema/openapi/generated/types/discovery.ts @@ -0,0 +1,22 @@ +/* + * Copyright 2023 The Backstage Authors + * + * 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. + */ + +/** + * This is a copy of the DiscoveryApi, to avoid importing core-plugin-api. + */ +export type DiscoveryApi = { + getBaseUrl(pluginId: string): Promise; +}; diff --git a/plugins/todo-common/src/schema/openapi/generated/types/fetch.ts b/plugins/todo-common/src/schema/openapi/generated/types/fetch.ts new file mode 100644 index 0000000000..3de56c028e --- /dev/null +++ b/plugins/todo-common/src/schema/openapi/generated/types/fetch.ts @@ -0,0 +1,22 @@ +/* + * Copyright 2023 The Backstage Authors + * + * 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. + */ + +/** + * This is a copy of FetchApi, to avoid importing core-plugin-api. + */ +export type FetchApi = { + fetch: typeof fetch; +}; diff --git a/plugins/todo-common/src/setupTests.ts b/plugins/todo-common/src/setupTests.ts new file mode 100644 index 0000000000..c7ce5c0988 --- /dev/null +++ b/plugins/todo-common/src/setupTests.ts @@ -0,0 +1,16 @@ +/* + * Copyright 2024 The Backstage Authors + * + * 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 {}; diff --git a/yarn.lock b/yarn.lock index 2fbc0f876b..167e02a8ef 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8039,6 +8039,8 @@ __metadata: "@backstage/cli": "workspace:^" "@backstage/plugin-permission-common": "workspace:^" "@backstage/types": "workspace:^" + cross-fetch: ^4.0.0 + uri-template: ^2.0.0 languageName: unknown linkType: soft @@ -8486,6 +8488,16 @@ __metadata: languageName: unknown linkType: soft +"@backstage/plugin-todo-common@workspace:plugins/todo-common": + version: 0.0.0-use.local + resolution: "@backstage/plugin-todo-common@workspace:plugins/todo-common" + dependencies: + "@backstage/cli": "workspace:^" + cross-fetch: ^4.0.0 + uri-template: ^2.0.0 + languageName: unknown + linkType: soft + "@backstage/plugin-user-settings-backend@workspace:plugins/user-settings-backend": version: 0.0.0-use.local resolution: "@backstage/plugin-user-settings-backend@workspace:plugins/user-settings-backend"