From b8be639b9a9800217bee0fad99ab23cd46b8b1a1 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Thu, 23 May 2024 01:31:10 +0200 Subject: [PATCH] events-node: generate client Signed-off-by: Patrik Oldsberg --- plugins/events-backend/dev/index.ts | 73 ++------- plugins/events-backend/package.json | 2 +- plugins/events-node/package.json | 4 +- .../src/generated/apis/DefaultApi.client.ts | 152 ++++++++++++++++++ .../events-node/src/generated/apis/index.ts | 17 ++ plugins/events-node/src/generated/index.ts | 18 +++ .../src/generated/models/ErrorError.model.ts | 24 +++ .../generated/models/ErrorRequest.model.ts | 24 +++ .../generated/models/ErrorResponse.model.ts | 23 +++ .../src/generated/models/Event.model.ts | 27 ++++ .../GetSubscriptionEvents200Response.model.ts | 24 +++ .../src/generated/models/ModelError.model.ts | 28 ++++ .../models/PostEventRequest.model.ts | 28 ++++ .../models/PutSubscriptionRequest.model.ts | 26 +++ .../events-node/src/generated/models/index.ts | 24 +++ plugins/events-node/src/generated/pluginId.ts | 17 ++ .../src/generated/types/discovery.ts | 22 +++ .../events-node/src/generated/types/fetch.ts | 22 +++ yarn.lock | 2 + 19 files changed, 496 insertions(+), 61 deletions(-) create mode 100644 plugins/events-node/src/generated/apis/DefaultApi.client.ts create mode 100644 plugins/events-node/src/generated/apis/index.ts create mode 100644 plugins/events-node/src/generated/index.ts create mode 100644 plugins/events-node/src/generated/models/ErrorError.model.ts create mode 100644 plugins/events-node/src/generated/models/ErrorRequest.model.ts create mode 100644 plugins/events-node/src/generated/models/ErrorResponse.model.ts create mode 100644 plugins/events-node/src/generated/models/Event.model.ts create mode 100644 plugins/events-node/src/generated/models/GetSubscriptionEvents200Response.model.ts create mode 100644 plugins/events-node/src/generated/models/ModelError.model.ts create mode 100644 plugins/events-node/src/generated/models/PostEventRequest.model.ts create mode 100644 plugins/events-node/src/generated/models/PutSubscriptionRequest.model.ts create mode 100644 plugins/events-node/src/generated/models/index.ts create mode 100644 plugins/events-node/src/generated/pluginId.ts create mode 100644 plugins/events-node/src/generated/types/discovery.ts create mode 100644 plugins/events-node/src/generated/types/fetch.ts diff --git a/plugins/events-backend/dev/index.ts b/plugins/events-backend/dev/index.ts index 752b88fb1f..9476da1d0d 100644 --- a/plugins/events-backend/dev/index.ts +++ b/plugins/events-backend/dev/index.ts @@ -21,6 +21,7 @@ import { } from '@backstage/backend-plugin-api'; import { WebSocket } from 'ws'; import { eventsServiceRef } from '@backstage/plugin-events-node'; +import { DefaultApiClient } from '../../events-node/src/generated'; const backend = createBackend(); @@ -73,6 +74,8 @@ backend.add( rootLifecycle.addStartupHook(async () => { logger.info('Started!'); + + const client = new DefaultApiClient({ discoveryApi: discovery }); const baseUrl = await discovery.getBaseUrl('events'); console.log(`DEBUG: baseUrl=`, baseUrl); const { token } = await auth.getPluginRequestToken({ @@ -80,29 +83,23 @@ backend.add( targetPluginId: 'events', }); - const subRes = await fetch(`${baseUrl}/hub/subscriptions/123`, { - method: 'PUT', - headers: { - Authorization: `Bearer ${token}`, - 'Content-Type': 'application/json', + const subRes = await client.putSubscription( + { + path: { subscriptionId: '123' }, + body: { topics: ['test'] }, }, - body: JSON.stringify({ - topics: ['test'], - }), - }); + { token }, + ); console.log( `DEBUG: sub create req = ${subRes.status} ${subRes.statusText}`, ); const poll = async () => { - const res = await fetch( - `${baseUrl}/hub/subscriptions/123/events`, + const res = await client.getSubscriptionEvents( { - headers: { - Authorization: `Bearer ${token}`, - 'Content-Type': 'application/json', - }, + path: { subscriptionId: '123' }, }, + { token }, ); const data = res.status === 200 && (await res.json()); @@ -116,52 +113,10 @@ backend.add( setTimeout(() => { console.log(`DEBUG: publishing!`); - fetch(`${baseUrl}/hub/events`, { - method: 'POST', - headers: { - Authorization: `Bearer ${token}`, - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ - topic: 'test', - payload: { herp: 'derp' }, - }), + client.postEvent({ + body: { event: { topic: 'test', payload: { foo: 'bar' } } }, }); }, 500); - - const ws = new WebSocket(`${baseUrl}/hub/connect`, { - headers: { - Authorization: `Bearer ${token}`, - }, - }); - ws.onopen = () => { - console.log('DEBUG: ws.onopen'); - // ws.send( - // JSON.stringify([ - // 'req', - // 1, - // 'subscribe', - // { id: 'derp', topics: ['test'] }, - // ]), - // ); - setTimeout(() => { - console.log(`DEBUG: publish!`); - ws.send( - JSON.stringify([ - 'req', - 1, - 'publish', - { topic: 'test', payload: { foo: 'bar' } }, - ]), - ); - }, 1000); - }; - ws.onmessage = event => { - console.log(`DEBUG: client event=`, event.data); - }; - ws.onerror = event => { - console.log(`Client error`, event.error); - }; }); }, }); diff --git a/plugins/events-backend/package.json b/plugins/events-backend/package.json index 3160e6d494..aa788330ae 100644 --- a/plugins/events-backend/package.json +++ b/plugins/events-backend/package.json @@ -44,7 +44,7 @@ "scripts": { "build": "backstage-cli package build", "clean": "backstage-cli package clean", - "generate": "backstage-repo-tools package schema openapi generate --server", + "generate": "backstage-repo-tools package schema openapi generate --server --client-package plugins/events-node", "lint": "backstage-cli package lint", "prepack": "backstage-cli package prepack", "postpack": "backstage-cli package postpack", diff --git a/plugins/events-node/package.json b/plugins/events-node/package.json index 9f822c7a94..de880dc399 100644 --- a/plugins/events-node/package.json +++ b/plugins/events-node/package.json @@ -52,7 +52,9 @@ }, "dependencies": { "@backstage/backend-plugin-api": "workspace:^", - "@backstage/types": "workspace:^" + "@backstage/types": "workspace:^", + "cross-fetch": "^4.0.0", + "uri-template": "^2.0.0" }, "devDependencies": { "@backstage/backend-common": "^0.25.0", diff --git a/plugins/events-node/src/generated/apis/DefaultApi.client.ts b/plugins/events-node/src/generated/apis/DefaultApi.client.ts new file mode 100644 index 0000000000..7a2099e79a --- /dev/null +++ b/plugins/events-node/src/generated/apis/DefaultApi.client.ts @@ -0,0 +1,152 @@ +/* + * 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 { GetSubscriptionEvents200Response } from '../models/GetSubscriptionEvents200Response.model'; +import { PostEventRequest } from '../models/PostEventRequest.model'; +import { PutSubscriptionRequest } from '../models/PutSubscriptionRequest.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; +} + +/** + * no description + */ +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 }; + } + + /** + * Get new events for the provided subscription + * @param subscriptionId + */ + public async getSubscriptionEvents( + // @ts-ignore + request: { + path: { + subscriptionId: string; + }; + }, + options?: RequestOptions, + ): Promise> { + const baseUrl = await this.discoveryApi.getBaseUrl(pluginId); + + const uriTemplate = `/hub/subscriptions/{subscriptionId}/events`; + + const uri = parser.parse(uriTemplate).expand({ + subscriptionId: request.path.subscriptionId, + }); + + return await this.fetchApi.fetch(`${baseUrl}${uri}`, { + headers: { + 'Content-Type': 'application/json', + ...(options?.token && { Authorization: `Bearer ${options?.token}` }), + }, + method: 'GET', + }); + } + + /** + * Publish a new event + * @param postEventRequest + */ + public async postEvent( + // @ts-ignore + request: { + body: PostEventRequest; + }, + options?: RequestOptions, + ): Promise> { + const baseUrl = await this.discoveryApi.getBaseUrl(pluginId); + + const uriTemplate = `/hub/events`; + + const uri = parser.parse(uriTemplate).expand({}); + + return await this.fetchApi.fetch(`${baseUrl}${uri}`, { + headers: { + 'Content-Type': 'application/json', + ...(options?.token && { Authorization: `Bearer ${options?.token}` }), + }, + method: 'POST', + body: JSON.stringify(request.body), + }); + } + + /** + * Ensures that the subscription exists with the provided configuration + * @param subscriptionId + * @param putSubscriptionRequest + */ + public async putSubscription( + // @ts-ignore + request: { + path: { + subscriptionId: string; + }; + body: PutSubscriptionRequest; + }, + options?: RequestOptions, + ): Promise> { + const baseUrl = await this.discoveryApi.getBaseUrl(pluginId); + + const uriTemplate = `/hub/subscriptions/{subscriptionId}`; + + const uri = parser.parse(uriTemplate).expand({ + subscriptionId: request.path.subscriptionId, + }); + + return await this.fetchApi.fetch(`${baseUrl}${uri}`, { + headers: { + 'Content-Type': 'application/json', + ...(options?.token && { Authorization: `Bearer ${options?.token}` }), + }, + method: 'PUT', + body: JSON.stringify(request.body), + }); + } +} diff --git a/plugins/events-node/src/generated/apis/index.ts b/plugins/events-node/src/generated/apis/index.ts new file mode 100644 index 0000000000..51dcca33fe --- /dev/null +++ b/plugins/events-node/src/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/events-node/src/generated/index.ts b/plugins/events-node/src/generated/index.ts new file mode 100644 index 0000000000..bb399e97a0 --- /dev/null +++ b/plugins/events-node/src/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/events-node/src/generated/models/ErrorError.model.ts b/plugins/events-node/src/generated/models/ErrorError.model.ts new file mode 100644 index 0000000000..4bcc60b660 --- /dev/null +++ b/plugins/events-node/src/generated/models/ErrorError.model.ts @@ -0,0 +1,24 @@ +/* + * 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. * +// ****************************************************************** + +export interface ErrorError { + name: string; + message: string; +} diff --git a/plugins/events-node/src/generated/models/ErrorRequest.model.ts b/plugins/events-node/src/generated/models/ErrorRequest.model.ts new file mode 100644 index 0000000000..be62627814 --- /dev/null +++ b/plugins/events-node/src/generated/models/ErrorRequest.model.ts @@ -0,0 +1,24 @@ +/* + * 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. * +// ****************************************************************** + +export interface ErrorRequest { + method: string; + url: string; +} diff --git a/plugins/events-node/src/generated/models/ErrorResponse.model.ts b/plugins/events-node/src/generated/models/ErrorResponse.model.ts new file mode 100644 index 0000000000..008f8b7348 --- /dev/null +++ b/plugins/events-node/src/generated/models/ErrorResponse.model.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. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** + +export interface ErrorResponse { + statusCode: number; +} diff --git a/plugins/events-node/src/generated/models/Event.model.ts b/plugins/events-node/src/generated/models/Event.model.ts new file mode 100644 index 0000000000..b5a13b4d8d --- /dev/null +++ b/plugins/events-node/src/generated/models/Event.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. * +// ****************************************************************** + +export interface Event { + /** + * The topic that the event is published on + */ + topic: string; + payload: { [key: string]: any }; +} diff --git a/plugins/events-node/src/generated/models/GetSubscriptionEvents200Response.model.ts b/plugins/events-node/src/generated/models/GetSubscriptionEvents200Response.model.ts new file mode 100644 index 0000000000..653bfaf3fc --- /dev/null +++ b/plugins/events-node/src/generated/models/GetSubscriptionEvents200Response.model.ts @@ -0,0 +1,24 @@ +/* + * 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 { Event } from '../models/Event.model'; + +export interface GetSubscriptionEvents200Response { + events?: Array; +} diff --git a/plugins/events-node/src/generated/models/ModelError.model.ts b/plugins/events-node/src/generated/models/ModelError.model.ts new file mode 100644 index 0000000000..88b8e76762 --- /dev/null +++ b/plugins/events-node/src/generated/models/ModelError.model.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 { ErrorError } from '../models/ErrorError.model'; +import { ErrorRequest } from '../models/ErrorRequest.model'; +import { ErrorResponse } from '../models/ErrorResponse.model'; + +export interface ModelError { + error: ErrorError; + request: ErrorRequest; + response: ErrorResponse; +} diff --git a/plugins/events-node/src/generated/models/PostEventRequest.model.ts b/plugins/events-node/src/generated/models/PostEventRequest.model.ts new file mode 100644 index 0000000000..527064bc13 --- /dev/null +++ b/plugins/events-node/src/generated/models/PostEventRequest.model.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 { Event } from '../models/Event.model'; + +export interface PostEventRequest { + event: Event; + /** + * The IDs of subscriptions that have already received this event + */ + subscriptionIds?: Array; +} diff --git a/plugins/events-node/src/generated/models/PutSubscriptionRequest.model.ts b/plugins/events-node/src/generated/models/PutSubscriptionRequest.model.ts new file mode 100644 index 0000000000..3de35e0f81 --- /dev/null +++ b/plugins/events-node/src/generated/models/PutSubscriptionRequest.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. * +// ****************************************************************** + +export interface PutSubscriptionRequest { + /** + * The topics to subscribe to + */ + topics: Array; +} diff --git a/plugins/events-node/src/generated/models/index.ts b/plugins/events-node/src/generated/models/index.ts new file mode 100644 index 0000000000..5044f65fff --- /dev/null +++ b/plugins/events-node/src/generated/models/index.ts @@ -0,0 +1,24 @@ +/* + * 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/Event.model'; +export * from '../models/GetSubscriptionEvents200Response.model'; +export * from '../models/ModelError.model'; +export * from '../models/PostEventRequest.model'; +export * from '../models/PutSubscriptionRequest.model'; diff --git a/plugins/events-node/src/generated/pluginId.ts b/plugins/events-node/src/generated/pluginId.ts new file mode 100644 index 0000000000..36b5433cc3 --- /dev/null +++ b/plugins/events-node/src/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 = 'events'; diff --git a/plugins/events-node/src/generated/types/discovery.ts b/plugins/events-node/src/generated/types/discovery.ts new file mode 100644 index 0000000000..a7f87d3780 --- /dev/null +++ b/plugins/events-node/src/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/events-node/src/generated/types/fetch.ts b/plugins/events-node/src/generated/types/fetch.ts new file mode 100644 index 0000000000..3de56c028e --- /dev/null +++ b/plugins/events-node/src/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/yarn.lock b/yarn.lock index d1024c0d96..6636108958 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6169,6 +6169,8 @@ __metadata: "@backstage/backend-test-utils": "workspace:^" "@backstage/cli": "workspace:^" "@backstage/types": "workspace:^" + cross-fetch: ^4.0.0 + uri-template: ^2.0.0 languageName: unknown linkType: soft