-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(marketplace): initial version of a marketplace api
Signed-off-by: Christoph Jerolimov <[email protected]>
- Loading branch information
1 parent
e182a44
commit e1da485
Showing
18 changed files
with
576 additions
and
476 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
workspaces/marketplace/plugins/marketplace-common/src/types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
/** | ||
* @public | ||
*/ | ||
export interface MarketplacePluginEntry { | ||
metadata: MarketplacePluginMetadata; | ||
spec: MarketplacePluginSpec; | ||
} | ||
|
||
/** | ||
* @public | ||
*/ | ||
export interface MarketplacePluginMetadata { | ||
// primary identifier | ||
name: string; | ||
|
||
// primary display name | ||
title: string; | ||
|
||
abstract?: string; | ||
|
||
categories?: string[]; | ||
developer?: string; | ||
|
||
// TODO: support for light/dark icon | ||
icon?: string; | ||
|
||
labels?: Record<string, string>; | ||
annotations?: Record<string, string>; | ||
tags?: string[]; | ||
links?: MarketplacePluginLink[]; | ||
} | ||
|
||
/** | ||
* @public | ||
*/ | ||
export interface MarketplacePluginLink { | ||
url: string; | ||
title?: string; | ||
icon?: string; | ||
type?: string; | ||
} | ||
|
||
/** | ||
* @public | ||
*/ | ||
export interface MarketplacePluginSpec { | ||
highlights?: string[]; | ||
description?: string; | ||
installation?: { | ||
markdown?: string; | ||
appconfig?: string; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
workspaces/marketplace/plugins/marketplace/src/api/MarketplaceClient.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. | ||
*/ | ||
import { DiscoveryApi, FetchApi } from '@backstage/core-plugin-api'; | ||
|
||
import { MarketplacePluginEntry } from '@red-hat-developer-hub/backstage-plugin-marketplace-common'; | ||
|
||
import { MarketplaceApi } from './MarketplaceApi'; | ||
|
||
export type Options = { | ||
discoveryApi: DiscoveryApi; | ||
fetchApi: FetchApi; | ||
}; | ||
|
||
export class MarketplaceClient implements MarketplaceApi { | ||
private readonly discoveryApi: DiscoveryApi; | ||
private readonly fetchApi: FetchApi; | ||
|
||
constructor(options: Options) { | ||
this.discoveryApi = options.discoveryApi; | ||
this.fetchApi = options.fetchApi; | ||
} | ||
|
||
async getPlugins(): Promise<MarketplacePluginEntry[]> { | ||
const baseUrl = await this.discoveryApi.getBaseUrl('marketplace'); | ||
const url = `${baseUrl}/plugins`; | ||
|
||
const response = await this.fetchApi.fetch(url); | ||
if (!response.ok) { | ||
throw new Error( | ||
`Unexpected status code: ${response.status} ${response.statusText}`, | ||
); | ||
} | ||
|
||
return response.json(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 0 additions & 39 deletions
39
...marketplace/plugins/marketplace/src/components/ExampleComponent/ExampleComponent.test.tsx
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.