refactor: rename stack overflow backend module
Signed-off-by: Camila Belo <camilaibs@gmail.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-search-backend-module-stack-overflow': patch
|
||||
'@backstage/plugin-search-backend-module-stack-overflow-collator': patch
|
||||
---
|
||||
|
||||
Extract a package for the Stack Overflow new backend system plugin.
|
||||
|
||||
@@ -2,6 +2,6 @@
|
||||
'@backstage/plugin-stack-overflow-backend': patch
|
||||
---
|
||||
|
||||
Deprecate package in favor of the new `@backstage/plugin-search-backend-module-stack-overflow` module.
|
||||
Deprecate package in favor of the new `@backstage/plugin-search-backend-module-stack-overflow-collator` module.
|
||||
|
||||
The search collator `requestParams` option is optional now, so its default value is `{ order: 'desc', sort: 'activity', site: 'stackoverflow' }` as defined in the `Try It` section on the [official Stack Overflow API documentation](https://api.stackexchange.com/docs/questions).
|
||||
|
||||
@@ -22,7 +22,7 @@ Imagine you have a plugin that is responsible for storing FAQ snippets in a data
|
||||
|
||||
The search platform provides an interface (`DocumentCollatorFactory` from package `@backstage/plugin-search-common`) that allows you to do exactly that. It works by registering each of your entries as a "document" that later represents one search result each.
|
||||
|
||||
> You can always look at a working example, e.g. [StackOverflowQuestionsCollatorFactory](https://github.com/backstage/backstage/blob/master/plugins/search-backend-module-stack-overflow/src/collators/StackOverflowQuestionsCollatorFactory.ts), if you are unsure or want to follow best practices.
|
||||
> You can always look at a working example, e.g. [StackOverflowQuestionsCollatorFactory](https://github.com/backstage/backstage/blob/master/plugins/search-backend-module-stack-overflow-collator/src/collators/StackOverflowQuestionsCollatorFactory.ts), if you are unsure or want to follow best practices.
|
||||
|
||||
#### 1. Install collator interface dependencies
|
||||
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
# Stack Overflow Search Backend Module
|
||||
|
||||
A plugin that provides stack overflow specific functionality that can be used in different ways (e.g. for search) to compose your Backstage App.
|
||||
|
||||
## Getting started
|
||||
|
||||
Before we begin, make sure:
|
||||
|
||||
- You have created your own standalone Backstage app using @backstage/create-app and not using a fork of the backstage repository. If you haven't setup Backstage already, start [here](https://backstage.io/docs/getting-started/).
|
||||
|
||||
To use any of the functionality this plugin provides, you need to start by configuring your App with the following config:
|
||||
|
||||
```yaml
|
||||
stackoverflow:
|
||||
baseUrl: https://api.stackexchange.com/2.2 # alternative: your internal stack overflow instance
|
||||
```
|
||||
|
||||
### Stack Overflow for Teams
|
||||
|
||||
If you have a private Stack Overflow instance and/or a private Stack Overflow Team you will need to supply an API key or Personal Access Token. You can read more about how to set this up by going to [Stack Overflow's Help Page](https://stackoverflow.help/en/articles/4385859-stack-overflow-for-teams-api).
|
||||
|
||||
The existing API key approach remains the default, to support the new v2.3 API and PAT authentication model you need to pass the team name and the new PAT into the existing apiAccessToken parameter to the new URL. See [15770](https://github.com/backstage/backstage/issues/15770) for more details.
|
||||
|
||||
```yaml
|
||||
stackoverflow:
|
||||
baseUrl: https://api.stackexchange.com/2.2 # alternative: your internal stack overflow instance
|
||||
apiKey: $STACK_OVERFLOW_API_KEY
|
||||
apiAccessToken: $STACK_OVERFLOW_API_ACCESS_TOKEN
|
||||
```
|
||||
|
||||
```yaml
|
||||
stackoverflow:
|
||||
baseUrl: https://api.stackoverflowteams.com/2.3 # alternative: your internal stack overflow instance
|
||||
teamName: $STACK_OVERFLOW_TEAM_NAME
|
||||
apiAccessToken: $STACK_OVERFLOW_API_ACCESS_TOKEN
|
||||
```
|
||||
|
||||
## Areas of Responsibility
|
||||
|
||||
This stack overflow backend plugin is primarily responsible for the following:
|
||||
|
||||
- Provides a `StackOverflowQuestionsCollatorFactory`, which can be used in the search backend to index stack overflow questions to your Backstage Search.
|
||||
|
||||
### Index Stack Overflow Questions to search
|
||||
|
||||
Before you are able to start index stack overflow questions to search, you need to go through the [search getting started guide](https://backstage.io/docs/features/search/getting-started).
|
||||
|
||||
When you have your `packages/backend/src/plugins/search.ts` file ready to make modifications, add the following code snippet to add the `StackOverflowQuestionsCollatorFactory`. Note that you can optionally modify the `requestParams`, otherwise it will defaults to `{ order: 'desc', sort: 'activity', site: 'stackoverflow' }` as done in the `Try It` section on the [official Stack Overflow API documentation](https://api.stackexchange.com/docs/questions).
|
||||
|
||||
> Note: if your `baseUrl` is set to the external stack overflow api `https://api.stackexchange.com/2.2`, you can find optional and required parameters under the official API documentation under [`Usage of /questions GET`](https://api.stackexchange.com/docs/questions)
|
||||
|
||||
```ts
|
||||
indexBuilder.addCollator({
|
||||
schedule,
|
||||
factory: StackOverflowQuestionsCollatorFactory.fromConfig(env.config, {
|
||||
logger: env.logger,
|
||||
requestParams: {
|
||||
tagged: ['backstage'],
|
||||
site: 'stackoverflow',
|
||||
pagesize: 100,
|
||||
},
|
||||
}),
|
||||
});
|
||||
```
|
||||
|
||||
## New Backend System
|
||||
|
||||
> DISCLAIMER: The new backend system is in alpha, and so are the search backend module support for the new backend system. We don't recommend you to migrate your backend installations to the new system yet. But if you want to experiment, you can find getting started guides below.
|
||||
|
||||
This package exports a module that extends the search backend to also indexing the questions exposed by the [`Stack Overflow` API](https://api.stackexchange.com/docs/questions).
|
||||
|
||||
### Installation
|
||||
|
||||
Add the module package as a dependency:
|
||||
|
||||
```bash
|
||||
# From your Backstage root directory
|
||||
yarn add --cwd packages/backend @backstage/plugin-search-backend-module-stack-overflow-collator
|
||||
```
|
||||
|
||||
Add the collator to your backend instance, along with the search plugin itself:
|
||||
|
||||
```tsx
|
||||
// packages/backend/src/index.ts
|
||||
import { createBackend } from '@backstage/backend-defaults';
|
||||
|
||||
const backend = createBackend();
|
||||
backend.add(import('@backstage/plugin-search-backend/alpha'));
|
||||
backend.add(
|
||||
import(
|
||||
'@backstage/plugin-search-backend-module-stack-overflow-collator/alpha'
|
||||
),
|
||||
);
|
||||
backend.start();
|
||||
```
|
||||
|
||||
You may also want to add configuration parameters to your app-config, for example for controlling the scheduled indexing interval. These parameters should be placed under the `stackoverflow` key. See [the config definition file](https://github.com/backstage/backstage/blob/master/plugins/search-backend-module-stack-overflow/config.d.ts) for more details.
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
## API Report File for "@backstage/plugin-search-backend-module-stack-overflow"
|
||||
## API Report File for "@backstage/plugin-search-backend-module-stack-overflow-collator"
|
||||
|
||||
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
## API Report File for "@backstage/plugin-search-backend-module-stack-overflow"
|
||||
## API Report File for "@backstage/plugin-search-backend-module-stack-overflow-collator"
|
||||
|
||||
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
apiVersion: backstage.io/v1alpha1
|
||||
kind: Component
|
||||
metadata:
|
||||
name: backstage-plugin-search-backend-module-stack-overflow
|
||||
title: '@backstage/plugin-search-backend-module-stack-overflow'
|
||||
name: backstage-plugin-search-backend-module-stack-overflow-collator
|
||||
title: '@backstage/plugin-search-backend-module-stack-overflow-collator'
|
||||
description: A module for the search backend that exports stack overflow modules
|
||||
spec:
|
||||
lifecycle: experimental
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "@backstage/plugin-search-backend-module-stack-overflow",
|
||||
"name": "@backstage/plugin-search-backend-module-stack-overflow-collator",
|
||||
"description": "A module for the search backend that exports stack overflow modules",
|
||||
"version": "0.0.0",
|
||||
"main": "src/index.ts",
|
||||
@@ -1,30 +0,0 @@
|
||||
# search-backend-module-stack-overflow
|
||||
|
||||
> DISCLAIMER: The new backend system is in alpha, and so are the search backend module support for the new backend system. We don't recommend you to migrate your backend installations to the new system yet. But if you want to experiment, you can find getting started guides below.
|
||||
|
||||
This package exports a module that extends the search backend to also indexing the questions exposed by the [`Stack Overflow` API](https://api.stackexchange.com/docs/questions).
|
||||
|
||||
## Installation
|
||||
|
||||
Add the module package as a dependency:
|
||||
|
||||
```bash
|
||||
# From your Backstage root directory
|
||||
yarn add --cwd packages/backend @backstage/plugin-search-backend-module-stack-overflow
|
||||
```
|
||||
|
||||
Add the collator to your backend instance, along with the search plugin itself:
|
||||
|
||||
```tsx
|
||||
// packages/backend/src/index.ts
|
||||
import { createBackend } from '@backstage/backend-defaults';
|
||||
|
||||
const backend = createBackend();
|
||||
backend.add(import('@backstage/plugin-search-backend/alpha'));
|
||||
backend.add(
|
||||
import('@backstage/plugin-search-backend-module-stack-overflow/alpha'),
|
||||
);
|
||||
backend.start();
|
||||
```
|
||||
|
||||
You may also want to add configuration parameters to your app-config, for example for controlling the scheduled indexing interval. These parameters should be placed under the `stackoverflow` key. See [the config definition file](https://github.com/backstage/backstage/blob/master/plugins/search-backend-module-stack-overflow/config.d.ts) for more details.
|
||||
@@ -3,9 +3,9 @@
|
||||
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
|
||||
|
||||
```ts
|
||||
import { StackOverflowDocument as StackOverflowDocument_2 } from '@backstage/plugin-search-backend-module-stack-overflow';
|
||||
import { StackOverflowQuestionsCollatorFactory as StackOverflowQuestionsCollatorFactory_2 } from '@backstage/plugin-search-backend-module-stack-overflow';
|
||||
import { StackOverflowQuestionsRequestParams as StackOverflowQuestionsRequestParams_2 } from '@backstage/plugin-search-backend-module-stack-overflow';
|
||||
import { StackOverflowDocument as StackOverflowDocument_2 } from '@backstage/plugin-search-backend-module-stack-overflow-collator';
|
||||
import { StackOverflowQuestionsCollatorFactory as StackOverflowQuestionsCollatorFactory_2 } from '@backstage/plugin-search-backend-module-stack-overflow-collator';
|
||||
import { StackOverflowQuestionsRequestParams as StackOverflowQuestionsRequestParams_2 } from '@backstage/plugin-search-backend-module-stack-overflow-collator';
|
||||
|
||||
// @public @deprecated (undocumented)
|
||||
export type StackOverflowDocument = StackOverflowDocument_2;
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
"dependencies": {
|
||||
"@backstage/backend-common": "workspace:^",
|
||||
"@backstage/config": "workspace:^",
|
||||
"@backstage/plugin-search-backend-module-stack-overflow": "workspace:^",
|
||||
"@backstage/plugin-search-backend-module-stack-overflow-collator": "workspace:^",
|
||||
"@backstage/plugin-search-common": "workspace:^",
|
||||
"node-fetch": "^2.6.7",
|
||||
"qs": "^6.9.4",
|
||||
|
||||
@@ -25,19 +25,19 @@ import {
|
||||
StackOverflowQuestionsRequestParams as _StackOverflowQuestionsRequestParams,
|
||||
StackOverflowQuestionsCollatorFactory as _StackOverflowQuestionsCollatorFactory,
|
||||
StackOverflowQuestionsCollatorFactoryOptions as _StackOverflowQuestionsCollatorFactoryOptions,
|
||||
} from '@backstage/plugin-search-backend-module-stack-overflow';
|
||||
} from '@backstage/plugin-search-backend-module-stack-overflow-collator';
|
||||
|
||||
/**
|
||||
* @public
|
||||
* @deprecated
|
||||
* Import from `@backstage/plugin-search-backend-module-stack-overflow` instead.
|
||||
* Import from `@backstage/plugin-search-backend-module-stack-overflow-collator` instead.
|
||||
*/
|
||||
export type StackOverflowDocument = _StackOverflowDocument;
|
||||
|
||||
/**
|
||||
* @public
|
||||
* @deprecated
|
||||
* Import from `@backstage/plugin-search-backend-module-stack-overflow` instead.
|
||||
* Import from `@backstage/plugin-search-backend-module-stack-overflow-collator` instead.
|
||||
*/
|
||||
export type StackOverflowQuestionsRequestParams =
|
||||
_StackOverflowQuestionsRequestParams;
|
||||
@@ -45,7 +45,7 @@ export type StackOverflowQuestionsRequestParams =
|
||||
/**
|
||||
* @public
|
||||
* @deprecated
|
||||
* Import from `@backstage/plugin-search-backend-module-stack-overflow` instead.
|
||||
* Import from `@backstage/plugin-search-backend-module-stack-overflow-collator` instead.
|
||||
*/
|
||||
export type StackOverflowQuestionsCollatorFactoryOptions =
|
||||
_StackOverflowQuestionsCollatorFactory;
|
||||
@@ -53,7 +53,7 @@ export type StackOverflowQuestionsCollatorFactoryOptions =
|
||||
/**
|
||||
* @public
|
||||
* @deprecated
|
||||
* Import from `@backstage/plugin-search-backend-module-stack-overflow` instead.
|
||||
* Import from `@backstage/plugin-search-backend-module-stack-overflow-collator` instead.
|
||||
*/
|
||||
export const StackOverflowQuestionsCollatorFactory =
|
||||
_StackOverflowQuestionsCollatorFactory;
|
||||
|
||||
@@ -8847,9 +8847,9 @@ __metadata:
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
"@backstage/plugin-search-backend-module-stack-overflow@workspace:^, @backstage/plugin-search-backend-module-stack-overflow@workspace:plugins/search-backend-module-stack-overflow":
|
||||
"@backstage/plugin-search-backend-module-stack-overflow-collator@workspace:^, @backstage/plugin-search-backend-module-stack-overflow-collator@workspace:plugins/search-backend-module-stack-overflow-collator":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@backstage/plugin-search-backend-module-stack-overflow@workspace:plugins/search-backend-module-stack-overflow"
|
||||
resolution: "@backstage/plugin-search-backend-module-stack-overflow-collator@workspace:plugins/search-backend-module-stack-overflow-collator"
|
||||
dependencies:
|
||||
"@backstage/backend-common": "workspace:^"
|
||||
"@backstage/backend-plugin-api": "workspace:^"
|
||||
@@ -9209,7 +9209,7 @@ __metadata:
|
||||
"@backstage/backend-test-utils": "workspace:^"
|
||||
"@backstage/cli": "workspace:^"
|
||||
"@backstage/config": "workspace:^"
|
||||
"@backstage/plugin-search-backend-module-stack-overflow": "workspace:^"
|
||||
"@backstage/plugin-search-backend-module-stack-overflow-collator": "workspace:^"
|
||||
"@backstage/plugin-search-backend-node": "workspace:^"
|
||||
"@backstage/plugin-search-common": "workspace:^"
|
||||
msw: ^1.0.0
|
||||
|
||||
Reference in New Issue
Block a user