@backstage/plugin-search-backend-module-stack-overflow-collator 0.3.11 → 0.3.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @backstage/plugin-search-backend-module-stack-overflow-collator
|
|
2
2
|
|
|
3
|
+
## 0.3.12
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
- @backstage/plugin-search-backend-node@1.3.14
|
|
9
|
+
- @backstage/backend-plugin-api@1.4.2
|
|
10
|
+
|
|
11
|
+
## 0.3.12-next.0
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies
|
|
16
|
+
- @backstage/plugin-search-backend-node@1.3.14-next.0
|
|
17
|
+
- @backstage/backend-plugin-api@1.4.2-next.0
|
|
18
|
+
- @backstage/config@1.3.3
|
|
19
|
+
- @backstage/plugin-search-common@1.2.19
|
|
20
|
+
|
|
3
21
|
## 0.3.11
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StackOverflowQuestionsCollatorFactory.cjs.js","sources":["../../src/collators/StackOverflowQuestionsCollatorFactory.ts"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n DocumentCollatorFactory,\n IndexableDocument,\n} from '@backstage/plugin-search-common';\nimport { Config } from '@backstage/config';\nimport { Readable } from 'stream';\n\nimport qs from 'qs';\nimport { LoggerService } from '@backstage/backend-plugin-api';\n\n/**\n * Extended IndexableDocument with stack overflow specific properties\n *\n * @public\n */\nexport interface StackOverflowDocument extends IndexableDocument {\n answers: number;\n tags: string[];\n}\n\n/**\n * Type representing the request parameters accepted by the {@link StackOverflowQuestionsCollatorFactory}\n *\n * @public\n */\nexport type StackOverflowQuestionsRequestParams = {\n [key: string]: string | string[] | number;\n};\n\n/**\n * Options for {@link StackOverflowQuestionsCollatorFactory}\n *\n * @public\n */\nexport type StackOverflowQuestionsCollatorFactoryOptions = {\n baseUrl?: string;\n maxPage?: number;\n apiKey?: string;\n apiAccessToken?: string;\n teamName?: string;\n requestParams?: StackOverflowQuestionsRequestParams;\n logger: LoggerService;\n};\n\nconst DEFAULT_BASE_URL = 'https://api.stackexchange.com/2.3';\nconst DEFAULT_MAX_PAGE = 100;\n/**\n * Search collator responsible for collecting stack overflow questions to index.\n *\n * @public\n */\nexport class StackOverflowQuestionsCollatorFactory\n implements DocumentCollatorFactory\n{\n protected requestParams: StackOverflowQuestionsRequestParams;\n private readonly baseUrl: string | undefined;\n private readonly apiKey: string | undefined;\n private readonly apiAccessToken: string | undefined;\n private readonly teamName: string | undefined;\n private readonly maxPage: number | undefined;\n private readonly logger: LoggerService;\n public readonly type: string = 'stack-overflow';\n\n private constructor(options: StackOverflowQuestionsCollatorFactoryOptions) {\n this.baseUrl = options.baseUrl;\n this.apiKey = options.apiKey;\n this.apiAccessToken = options.apiAccessToken;\n this.teamName = options.teamName;\n this.maxPage = options.maxPage;\n this.logger = options.logger.child({ documentType: this.type });\n\n // Sets the same default request parameters as the official API documentation\n // See https://api.stackexchange.com/docs/questions\n this.requestParams = {\n order: 'desc',\n sort: 'activity',\n ...(options.requestParams ?? {}),\n };\n\n if (!options.requestParams?.site && this.baseUrl === DEFAULT_BASE_URL) {\n this.requestParams.site = 'stackoverflow';\n }\n }\n\n static fromConfig(\n config: Config,\n options: StackOverflowQuestionsCollatorFactoryOptions,\n ) {\n const apiKey = config.getOptionalString('stackoverflow.apiKey');\n const apiAccessToken = config.getOptionalString(\n 'stackoverflow.apiAccessToken',\n );\n const teamName = config.getOptionalString('stackoverflow.teamName');\n const baseUrl =\n config.getOptionalString('stackoverflow.baseUrl') || DEFAULT_BASE_URL;\n const maxPage = options.maxPage || DEFAULT_MAX_PAGE;\n const requestParams = config\n .getOptionalConfig('stackoverflow.requestParams')\n ?.get<StackOverflowQuestionsRequestParams>();\n\n return new StackOverflowQuestionsCollatorFactory({\n baseUrl,\n maxPage,\n apiKey,\n apiAccessToken,\n teamName,\n requestParams,\n ...options,\n });\n }\n\n async getCollator() {\n return Readable.from(this.execute());\n }\n\n async *execute(): AsyncGenerator<StackOverflowDocument> {\n if (!this.baseUrl) {\n this.logger.debug(\n `No stackoverflow.baseUrl configured in your app-config.yaml`,\n );\n }\n\n if (this.apiKey && this.teamName) {\n this.logger.debug(\n 'Both stackoverflow.apiKey and stackoverflow.teamName configured in your app-config.yaml, apiKey must be removed before teamName will be used',\n );\n }\n\n try {\n if (Object.keys(this.requestParams).indexOf('key') >= 0) {\n this.logger.warn(\n 'The API Key should be passed as a separate param to bypass encoding',\n );\n delete this.requestParams.key;\n }\n } catch (e) {\n this.logger.error(`Caught ${e}`);\n }\n\n const params = qs.stringify(this.requestParams, {\n arrayFormat: 'comma',\n addQueryPrefix: true,\n });\n\n const apiKeyParam = this.apiKey\n ? `${params ? '&' : '?'}key=${this.apiKey}`\n : '';\n\n const teamParam = this.teamName\n ? `${params ? '&' : '?'}team=${this.teamName}`\n : '';\n\n // PAT change requires team name as a parameter\n const requestUrl = this.apiKey\n ? `${this.baseUrl}/questions${params}${apiKeyParam}`\n : `${this.baseUrl}/questions${params}${teamParam}`;\n\n let hasMorePages = true;\n let page = 1;\n while (hasMorePages) {\n if (page === this.maxPage) {\n this.logger.warn(\n `Over ${this.maxPage} requests to the Stack Overflow API have been made, which may not have been intended. Either specify requestParams that limit the questions returned, or configure a higher maxPage if necessary.`,\n );\n break;\n }\n const res = await fetch(\n `${requestUrl}&page=${page}`,\n this.apiAccessToken\n ? {\n headers: {\n 'X-API-Access-Token': this.apiAccessToken,\n },\n }\n : undefined,\n );\n\n const data = await res.json();\n for (const question of data.items ?? []) {\n yield {\n title: question.title,\n location: question.link,\n text: question.owner.display_name,\n tags: question.tags,\n answers: question.answer_count,\n };\n }\n hasMorePages = data.has_more;\n page = page + 1;\n }\n }\n}\n"],"names":["Readable","qs"],"mappings":";;;;;;;;;AA4DA,MAAM,gBAAmB,GAAA,mCAAA;AACzB,MAAM,gBAAmB,GAAA,GAAA;AAMlB,MAAM,qCAEb,CAAA;AAAA,EACY,aAAA;AAAA,EACO,OAAA;AAAA,EACA,MAAA;AAAA,EACA,cAAA;AAAA,EACA,QAAA;AAAA,EACA,OAAA;AAAA,EACA,MAAA;AAAA,EACD,IAAe,GAAA,gBAAA;AAAA,EAEvB,YAAY,OAAuD,EAAA;AACzE,IAAA,IAAA,CAAK,UAAU,OAAQ,CAAA,OAAA;AACvB,IAAA,IAAA,CAAK,SAAS,OAAQ,CAAA,MAAA;AACtB,IAAA,IAAA,CAAK,iBAAiB,OAAQ,CAAA,cAAA;AAC9B,IAAA,IAAA,CAAK,WAAW,OAAQ,CAAA,QAAA;AACxB,IAAA,IAAA,CAAK,UAAU,OAAQ,CAAA,OAAA;AACvB,IAAK,IAAA,CAAA,MAAA,GAAS,QAAQ,MAAO,CAAA,KAAA,CAAM,EAAE,YAAc,EAAA,IAAA,CAAK,MAAM,CAAA;AAI9D,IAAA,IAAA,CAAK,aAAgB,GAAA;AAAA,MACnB,KAAO,EAAA,MAAA;AAAA,MACP,IAAM,EAAA,UAAA;AAAA,MACN,GAAI,OAAQ,CAAA,aAAA,IAAiB;AAAC,KAChC;AAEA,IAAA,IAAI,CAAC,OAAQ,CAAA,aAAA,EAAe,IAAQ,IAAA,IAAA,CAAK,YAAY,gBAAkB,EAAA;AACrE,MAAA,IAAA,CAAK,cAAc,IAAO,GAAA,e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,CAAA,CAAA;AAAA,QAC1B,KAAK,cACD,GAAA;AAAA,UACE,OAAS,EAAA;AAAA,YACP,sBAAsB,IAAK,CAAA;AAAA;AAC7B,SAEF,GAAA,KAAA;AAAA,OACN;AAEA,MAAM,MAAA,IAAA,GAAO,MAAM,GAAA,CAAI,IAAK,EAAA;AAC5B,MAAA,KAAA,MAAW,QAAY,IAAA,IAAA,CAAK,KAAS,IAAA,EAAI,EAAA;AACvC,QAAM,MAAA;AAAA,UACJ,OAAO,QAAS,CAAA,KAAA;AAAA,UAChB,UAAU,QAAS,CAAA,IAAA;AAAA,UACnB,IAAA,EAAM,SAAS,KAAM,CAAA,YAAA;AAAA,UACrB,MAAM,QAAS,CAAA,IAAA;AAAA,UACf,SAAS,QAAS,CAAA;AAAA,SACpB;AAAA;AAEF,MAAA,YAAA,GAAe,IAAK,CAAA,QAAA;AACpB,MAAA,IAAA,GAAO,IAAO,GAAA,CAAA;AAAA;AAChB;AAEJ;;;;"}
|
|
1
|
+
{"version":3,"file":"StackOverflowQuestionsCollatorFactory.cjs.js","sources":["../../src/collators/StackOverflowQuestionsCollatorFactory.ts"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n DocumentCollatorFactory,\n IndexableDocument,\n} from '@backstage/plugin-search-common';\nimport { Config } from '@backstage/config';\nimport { Readable } from 'stream';\n\nimport qs from 'qs';\nimport { LoggerService } from '@backstage/backend-plugin-api';\n\n/**\n * Extended IndexableDocument with stack overflow specific properties\n *\n * @public\n */\nexport interface StackOverflowDocument extends IndexableDocument {\n answers: number;\n tags: string[];\n}\n\n/**\n * Type representing the request parameters accepted by the {@link StackOverflowQuestionsCollatorFactory}\n *\n * @public\n */\nexport type StackOverflowQuestionsRequestParams = {\n [key: string]: string | string[] | number;\n};\n\n/**\n * Options for {@link StackOverflowQuestionsCollatorFactory}\n *\n * @public\n */\nexport type StackOverflowQuestionsCollatorFactoryOptions = {\n baseUrl?: string;\n maxPage?: number;\n apiKey?: string;\n apiAccessToken?: string;\n teamName?: string;\n requestParams?: StackOverflowQuestionsRequestParams;\n logger: LoggerService;\n};\n\nconst DEFAULT_BASE_URL = 'https://api.stackexchange.com/2.3';\nconst DEFAULT_MAX_PAGE = 100;\n/**\n * Search collator responsible for collecting stack overflow questions to index.\n *\n * @public\n */\nexport class StackOverflowQuestionsCollatorFactory\n implements DocumentCollatorFactory\n{\n protected requestParams: StackOverflowQuestionsRequestParams;\n private readonly baseUrl: string | undefined;\n private readonly apiKey: string | undefined;\n private readonly apiAccessToken: string | undefined;\n private readonly teamName: string | undefined;\n private readonly maxPage: number | undefined;\n private readonly logger: LoggerService;\n public readonly type: string = 'stack-overflow';\n\n private constructor(options: StackOverflowQuestionsCollatorFactoryOptions) {\n this.baseUrl = options.baseUrl;\n this.apiKey = options.apiKey;\n this.apiAccessToken = options.apiAccessToken;\n this.teamName = options.teamName;\n this.maxPage = options.maxPage;\n this.logger = options.logger.child({ documentType: this.type });\n\n // Sets the same default request parameters as the official API documentation\n // See https://api.stackexchange.com/docs/questions\n this.requestParams = {\n order: 'desc',\n sort: 'activity',\n ...(options.requestParams ?? {}),\n };\n\n if (!options.requestParams?.site && this.baseUrl === DEFAULT_BASE_URL) {\n this.requestParams.site = 'stackoverflow';\n }\n }\n\n static fromConfig(\n config: Config,\n options: StackOverflowQuestionsCollatorFactoryOptions,\n ) {\n const apiKey = config.getOptionalString('stackoverflow.apiKey');\n const apiAccessToken = config.getOptionalString(\n 'stackoverflow.apiAccessToken',\n );\n const teamName = config.getOptionalString('stackoverflow.teamName');\n const baseUrl =\n config.getOptionalString('stackoverflow.baseUrl') || DEFAULT_BASE_URL;\n const maxPage = options.maxPage || DEFAULT_MAX_PAGE;\n const requestParams = config\n .getOptionalConfig('stackoverflow.requestParams')\n ?.get<StackOverflowQuestionsRequestParams>();\n\n return new StackOverflowQuestionsCollatorFactory({\n baseUrl,\n maxPage,\n apiKey,\n apiAccessToken,\n teamName,\n requestParams,\n ...options,\n });\n }\n\n async getCollator() {\n return Readable.from(this.execute());\n }\n\n async *execute(): AsyncGenerator<StackOverflowDocument> {\n if (!this.baseUrl) {\n this.logger.debug(\n `No stackoverflow.baseUrl configured in your app-config.yaml`,\n );\n }\n\n if (this.apiKey && this.teamName) {\n this.logger.debug(\n 'Both stackoverflow.apiKey and stackoverflow.teamName configured in your app-config.yaml, apiKey must be removed before teamName will be used',\n );\n }\n\n try {\n if (Object.keys(this.requestParams).indexOf('key') >= 0) {\n this.logger.warn(\n 'The API Key should be passed as a separate param to bypass encoding',\n );\n delete this.requestParams.key;\n }\n } catch (e) {\n this.logger.error(`Caught ${e}`);\n }\n\n const params = qs.stringify(this.requestParams, {\n arrayFormat: 'comma',\n addQueryPrefix: true,\n });\n\n const apiKeyParam = this.apiKey\n ? `${params ? '&' : '?'}key=${this.apiKey}`\n : '';\n\n const teamParam = this.teamName\n ? `${params ? '&' : '?'}team=${this.teamName}`\n : '';\n\n // PAT change requires team name as a parameter\n const requestUrl = this.apiKey\n ? `${this.baseUrl}/questions${params}${apiKeyParam}`\n : `${this.baseUrl}/questions${params}${teamParam}`;\n\n let hasMorePages = true;\n let page = 1;\n while (hasMorePages) {\n if (page === this.maxPage) {\n this.logger.warn(\n `Over ${this.maxPage} requests to the Stack Overflow API have been made, which may not have been intended. Either specify requestParams that limit the questions returned, or configure a higher maxPage if necessary.`,\n );\n break;\n }\n const res = await fetch(\n `${requestUrl}&page=${page}`,\n this.apiAccessToken\n ? {\n headers: {\n 'X-API-Access-Token': this.apiAccessToken,\n },\n }\n : undefined,\n );\n\n const data = await res.json();\n for (const question of data.items ?? []) {\n yield {\n title: question.title,\n location: question.link,\n text: question.owner.display_name,\n tags: question.tags,\n answers: question.answer_count,\n };\n }\n hasMorePages = data.has_more;\n page = page + 1;\n }\n }\n}\n"],"names":["Readable","qs"],"mappings":";;;;;;;;;AA4DA,MAAM,gBAAA,GAAmB,mCAAA;AACzB,MAAM,gBAAA,GAAmB,GAAA;AAMlB,MAAM,qCAAA,CAEb;AAAA,EACY,aAAA;AAAA,EACO,OAAA;AAAA,EACA,MAAA;AAAA,EACA,cAAA;AAAA,EACA,QAAA;AAAA,EACA,OAAA;AAAA,EACA,MAAA;AAAA,EACD,IAAA,GAAe,gBAAA;AAAA,EAEvB,YAAY,OAAA,EAAuD;AACzE,IAAA,IAAA,CAAK,UAAU,OAAA,CAAQ,OAAA;AACvB,IAAA,IAAA,CAAK,SAAS,OAAA,CAAQ,MAAA;AACtB,IAAA,IAAA,CAAK,iBAAiB,OAAA,CAAQ,cAAA;AAC9B,IAAA,IAAA,CAAK,WAAW,OAAA,CAAQ,QAAA;AACxB,IAAA,IAAA,CAAK,UAAU,OAAA,CAAQ,OAAA;AACvB,IAAA,IAAA,CAAK,MAAA,GAAS,QAAQ,MAAA,CAAO,KAAA,CAAM,EAAE,YAAA,EAAc,IAAA,CAAK,MAAM,CAAA;AAI9D,IAAA,IAAA,CAAK,aAAA,GAAgB;AAAA,MACnB,KAAA,EAAO,MAAA;AAAA,MACP,IAAA,EAAM,UAAA;AAAA,MACN,GAAI,OAAA,CAAQ,aAAA,IAAiB;AAAC,KAChC;AAEA,IAAA,IAAI,CAAC,OAAA,CAAQ,aAAA,EAAe,IAAA,IAAQ,IAAA,CAAK,YAAY,gBAAA,EAAkB;AACrE,MAAA,IAAA,CAAK,cAAc,IAAA,GAAO,eAAA;AAAA,IAC5B;AAAA,EACF;AAAA,EAEA,OAAO,UAAA,CACL,MAAA,EACA,OAAA,EACA;AACA,IAAA,MAAM,MAAA,GAAS,MAAA,CAAO,iBAAA,CAAkB,sBAAsB,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,CAAK;AAAA;AAC7B,SACF,GACA;AAAA,OACN;AAEA,MAAA,MAAM,IAAA,GAAO,MAAM,GAAA,CAAI,IAAA,EAAK;AAC5B,MAAA,KAAA,MAAW,QAAA,IAAY,IAAA,CAAK,KAAA,IAAS,EAAC,EAAG;AACvC,QAAA,MAAM;AAAA,UACJ,OAAO,QAAA,CAAS,KAAA;AAAA,UAChB,UAAU,QAAA,CAAS,IAAA;AAAA,UACnB,IAAA,EAAM,SAAS,KAAA,CAAM,YAAA;AAAA,UACrB,MAAM,QAAA,CAAS,IAAA;AAAA,UACf,SAAS,QAAA,CAAS;AAAA,SACpB;AAAA,MACF;AACA,MAAA,YAAA,GAAe,IAAA,CAAK,QAAA;AACpB,MAAA,IAAA,GAAO,IAAA,GAAO,CAAA;AAAA,IAChB;AAAA,EACF;AACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchStackOverflowCollatorModule.cjs.js","sources":["../../src/module/SearchStackOverflowCollatorModule.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { readSchedulerServiceTaskScheduleDefinitionFromConfig } from '@backstage/backend-plugin-api';\nimport {\n coreServices,\n createBackendModule,\n} from '@backstage/backend-plugin-api';\nimport { searchIndexRegistryExtensionPoint } from '@backstage/plugin-search-backend-node/alpha';\nimport { StackOverflowQuestionsCollatorFactory } from '../collators';\n\n/**\n * @public\n * Search backend module for the Stack Overflow index.\n */\nexport const searchStackOverflowCollatorModule = createBackendModule({\n pluginId: 'search',\n moduleId: 'stack-overflow-collator',\n register(env) {\n env.registerInit({\n deps: {\n config: coreServices.rootConfig,\n logger: coreServices.logger,\n discovery: coreServices.discovery,\n scheduler: coreServices.scheduler,\n indexRegistry: searchIndexRegistryExtensionPoint,\n },\n async init({ config, logger, scheduler, indexRegistry }) {\n const defaultSchedule = {\n frequency: { minutes: 10 },\n timeout: { minutes: 15 },\n initialDelay: { seconds: 3 },\n };\n\n const schedule = config.has('stackoverflow.schedule')\n ? readSchedulerServiceTaskScheduleDefinitionFromConfig(\n config.getConfig('stackoverflow.schedule'),\n )\n : defaultSchedule;\n\n indexRegistry.addCollator({\n schedule: scheduler.createScheduledTaskRunner(schedule),\n factory: StackOverflowQuestionsCollatorFactory.fromConfig(config, {\n logger,\n }),\n });\n },\n });\n },\n});\n"],"names":["createBackendModule","coreServices","searchIndexRegistryExtensionPoint","readSchedulerServiceTaskScheduleDefinitionFromConfig","StackOverflowQuestionsCollatorFactory"],"mappings":";;;;;;AA4BO,MAAM,oCAAoCA,
|
|
1
|
+
{"version":3,"file":"SearchStackOverflowCollatorModule.cjs.js","sources":["../../src/module/SearchStackOverflowCollatorModule.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { readSchedulerServiceTaskScheduleDefinitionFromConfig } from '@backstage/backend-plugin-api';\nimport {\n coreServices,\n createBackendModule,\n} from '@backstage/backend-plugin-api';\nimport { searchIndexRegistryExtensionPoint } from '@backstage/plugin-search-backend-node/alpha';\nimport { StackOverflowQuestionsCollatorFactory } from '../collators';\n\n/**\n * @public\n * Search backend module for the Stack Overflow index.\n */\nexport const searchStackOverflowCollatorModule = createBackendModule({\n pluginId: 'search',\n moduleId: 'stack-overflow-collator',\n register(env) {\n env.registerInit({\n deps: {\n config: coreServices.rootConfig,\n logger: coreServices.logger,\n discovery: coreServices.discovery,\n scheduler: coreServices.scheduler,\n indexRegistry: searchIndexRegistryExtensionPoint,\n },\n async init({ config, logger, scheduler, indexRegistry }) {\n const defaultSchedule = {\n frequency: { minutes: 10 },\n timeout: { minutes: 15 },\n initialDelay: { seconds: 3 },\n };\n\n const schedule = config.has('stackoverflow.schedule')\n ? readSchedulerServiceTaskScheduleDefinitionFromConfig(\n config.getConfig('stackoverflow.schedule'),\n )\n : defaultSchedule;\n\n indexRegistry.addCollator({\n schedule: scheduler.createScheduledTaskRunner(schedule),\n factory: StackOverflowQuestionsCollatorFactory.fromConfig(config, {\n logger,\n }),\n });\n },\n });\n },\n});\n"],"names":["createBackendModule","coreServices","searchIndexRegistryExtensionPoint","readSchedulerServiceTaskScheduleDefinitionFromConfig","StackOverflowQuestionsCollatorFactory"],"mappings":";;;;;;AA4BO,MAAM,oCAAoCA,oCAAA,CAAoB;AAAA,EACnE,QAAA,EAAU,QAAA;AAAA,EACV,QAAA,EAAU,yBAAA;AAAA,EACV,SAAS,GAAA,EAAK;AACZ,IAAA,GAAA,CAAI,YAAA,CAAa;AAAA,MACf,IAAA,EAAM;AAAA,QACJ,QAAQC,6BAAA,CAAa,UAAA;AAAA,QACrB,QAAQA,6BAAA,CAAa,MAAA;AAAA,QACrB,WAAWA,6BAAA,CAAa,SAAA;AAAA,QACxB,WAAWA,6BAAA,CAAa,SAAA;AAAA,QACxB,aAAA,EAAeC;AAAA,OACjB;AAAA,MACA,MAAM,IAAA,CAAK,EAAE,QAAQ,MAAA,EAAQ,SAAA,EAAW,eAAc,EAAG;AACvD,QAAA,MAAM,eAAA,GAAkB;AAAA,UACtB,SAAA,EAAW,EAAE,OAAA,EAAS,EAAA,EAAG;AAAA,UACzB,OAAA,EAAS,EAAE,OAAA,EAAS,EAAA,EAAG;AAAA,UACvB,YAAA,EAAc,EAAE,OAAA,EAAS,CAAA;AAAE,SAC7B;AAEA,QAAA,MAAM,QAAA,GAAW,MAAA,CAAO,GAAA,CAAI,wBAAwB,CAAA,GAChDC,qEAAA;AAAA,UACE,MAAA,CAAO,UAAU,wBAAwB;AAAA,SAC3C,GACA,eAAA;AAEJ,QAAA,aAAA,CAAc,WAAA,CAAY;AAAA,UACxB,QAAA,EAAU,SAAA,CAAU,yBAAA,CAA0B,QAAQ,CAAA;AAAA,UACtD,OAAA,EAASC,2EAAA,CAAsC,UAAA,CAAW,MAAA,EAAQ;AAAA,YAChE;AAAA,WACD;AAAA,SACF,CAAA;AAAA,MACH;AAAA,KACD,CAAA;AAAA,EACH;AACF,CAAC;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-search-backend-module-stack-overflow-collator",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.12",
|
|
4
4
|
"description": "A module for the search backend that exports stack overflow modules",
|
|
5
5
|
"backstage": {
|
|
6
6
|
"role": "backend-plugin-module",
|
|
@@ -38,15 +38,15 @@
|
|
|
38
38
|
"test": "backstage-cli package test"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@backstage/backend-plugin-api": "^1.4.
|
|
41
|
+
"@backstage/backend-plugin-api": "^1.4.2",
|
|
42
42
|
"@backstage/config": "^1.3.3",
|
|
43
|
-
"@backstage/plugin-search-backend-node": "^1.3.
|
|
43
|
+
"@backstage/plugin-search-backend-node": "^1.3.14",
|
|
44
44
|
"@backstage/plugin-search-common": "^1.2.19",
|
|
45
45
|
"qs": "^6.9.4"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@backstage/backend-test-utils": "^1.
|
|
49
|
-
"@backstage/cli": "^0.
|
|
48
|
+
"@backstage/backend-test-utils": "^1.8.0",
|
|
49
|
+
"@backstage/cli": "^0.34.0",
|
|
50
50
|
"msw": "^1.2.1"
|
|
51
51
|
},
|
|
52
52
|
"configSchema": "config.d.ts",
|