@backstage/plugin-search-backend-node 1.3.16 → 1.3.17-next.1
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,25 @@
|
|
|
1
1
|
# @backstage/plugin-search-backend-node
|
|
2
2
|
|
|
3
|
+
## 1.3.17-next.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
- @backstage/backend-plugin-api@1.5.0-next.1
|
|
9
|
+
- @backstage/plugin-permission-common@0.9.3-next.1
|
|
10
|
+
|
|
11
|
+
## 1.3.17-next.0
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- 05f60e1: Refactored constructor parameter properties to explicit property declarations for compatibility with TypeScript's `erasableSyntaxOnly` setting. This internal refactoring maintains all existing functionality while ensuring TypeScript compilation compatibility.
|
|
16
|
+
- Updated dependencies
|
|
17
|
+
- @backstage/config@1.3.6-next.0
|
|
18
|
+
- @backstage/backend-plugin-api@1.4.5-next.0
|
|
19
|
+
- @backstage/errors@1.2.7
|
|
20
|
+
- @backstage/plugin-permission-common@0.9.3-next.0
|
|
21
|
+
- @backstage/plugin-search-common@1.2.21-next.0
|
|
22
|
+
|
|
3
23
|
## 1.3.16
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
|
@@ -3,6 +3,11 @@
|
|
|
3
3
|
var ndjson = require('ndjson');
|
|
4
4
|
|
|
5
5
|
class NewlineDelimitedJsonCollatorFactory {
|
|
6
|
+
type;
|
|
7
|
+
visibilityPermission;
|
|
8
|
+
searchPattern;
|
|
9
|
+
reader;
|
|
10
|
+
logger;
|
|
6
11
|
constructor(type, searchPattern, reader, logger, visibilityPermission) {
|
|
7
12
|
this.searchPattern = searchPattern;
|
|
8
13
|
this.reader = reader;
|
|
@@ -10,8 +15,6 @@ class NewlineDelimitedJsonCollatorFactory {
|
|
|
10
15
|
this.type = type;
|
|
11
16
|
this.visibilityPermission = visibilityPermission;
|
|
12
17
|
}
|
|
13
|
-
type;
|
|
14
|
-
visibilityPermission;
|
|
15
18
|
/**
|
|
16
19
|
* Returns a NewlineDelimitedJsonCollatorFactory instance from configuration
|
|
17
20
|
* and a set of options.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NewlineDelimitedJsonCollatorFactory.cjs.js","sources":["../../src/collators/NewlineDelimitedJsonCollatorFactory.ts"],"sourcesContent":["/*\n * Copyright 2021 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 { Config } from '@backstage/config';\nimport { DocumentCollatorFactory } from '@backstage/plugin-search-common';\nimport { Permission } from '@backstage/plugin-permission-common';\nimport { Readable } from 'stream';\nimport { parse as parseNdjson } from 'ndjson';\nimport { LoggerService, UrlReaderService } from '@backstage/backend-plugin-api';\n\n/**\n * Options for instantiate NewlineDelimitedJsonCollatorFactory\n * @public\n */\nexport type NewlineDelimitedJsonCollatorFactoryOptions = {\n type: string;\n searchPattern: string;\n reader: UrlReaderService;\n logger: LoggerService;\n visibilityPermission?: Permission;\n};\n\n/**\n * Factory class producing a collator that can be used to index documents\n * sourced from the latest newline delimited JSON file matching a given search\n * pattern. \"Latest\" is determined by the name of the file (last alphabetically\n * is considered latest).\n *\n * @remarks\n * The reader provided must implement the `search()` method as well as the\n * `readUrl` method whose response includes the `stream()` method. Naturally,\n * the reader must also be configured to understand the given search pattern.\n *\n * @example\n * Here's an example configuration using Google Cloud Storage, which would\n * return the latest file under the `bucket` GCS bucket with files like\n * `xyz-2021.ndjson` or `xyz-2022.ndjson`.\n * ```ts\n * indexBuilder.addCollator({\n * schedule,\n * factory: NewlineDelimitedJsonCollatorFactory.fromConfig(env.config, {\n * type: 'techdocs',\n * searchPattern: 'https://storage.cloud.google.com/bucket/xyz-*',\n * reader: env.reader,\n * logger: env.logger,\n * })\n * });\n * ```\n *\n * @public\n */\nexport class NewlineDelimitedJsonCollatorFactory\n implements DocumentCollatorFactory\n{\n readonly type: string;\n\n public readonly visibilityPermission: Permission | undefined;\n\n private constructor(\n type: string,\n
|
|
1
|
+
{"version":3,"file":"NewlineDelimitedJsonCollatorFactory.cjs.js","sources":["../../src/collators/NewlineDelimitedJsonCollatorFactory.ts"],"sourcesContent":["/*\n * Copyright 2021 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 { Config } from '@backstage/config';\nimport { DocumentCollatorFactory } from '@backstage/plugin-search-common';\nimport { Permission } from '@backstage/plugin-permission-common';\nimport { Readable } from 'stream';\nimport { parse as parseNdjson } from 'ndjson';\nimport { LoggerService, UrlReaderService } from '@backstage/backend-plugin-api';\n\n/**\n * Options for instantiate NewlineDelimitedJsonCollatorFactory\n * @public\n */\nexport type NewlineDelimitedJsonCollatorFactoryOptions = {\n type: string;\n searchPattern: string;\n reader: UrlReaderService;\n logger: LoggerService;\n visibilityPermission?: Permission;\n};\n\n/**\n * Factory class producing a collator that can be used to index documents\n * sourced from the latest newline delimited JSON file matching a given search\n * pattern. \"Latest\" is determined by the name of the file (last alphabetically\n * is considered latest).\n *\n * @remarks\n * The reader provided must implement the `search()` method as well as the\n * `readUrl` method whose response includes the `stream()` method. Naturally,\n * the reader must also be configured to understand the given search pattern.\n *\n * @example\n * Here's an example configuration using Google Cloud Storage, which would\n * return the latest file under the `bucket` GCS bucket with files like\n * `xyz-2021.ndjson` or `xyz-2022.ndjson`.\n * ```ts\n * indexBuilder.addCollator({\n * schedule,\n * factory: NewlineDelimitedJsonCollatorFactory.fromConfig(env.config, {\n * type: 'techdocs',\n * searchPattern: 'https://storage.cloud.google.com/bucket/xyz-*',\n * reader: env.reader,\n * logger: env.logger,\n * })\n * });\n * ```\n *\n * @public\n */\nexport class NewlineDelimitedJsonCollatorFactory\n implements DocumentCollatorFactory\n{\n readonly type: string;\n\n public readonly visibilityPermission: Permission | undefined;\n\n private readonly searchPattern: string;\n private readonly reader: UrlReaderService;\n private readonly logger: LoggerService;\n\n private constructor(\n type: string,\n searchPattern: string,\n reader: UrlReaderService,\n logger: LoggerService,\n visibilityPermission: Permission | undefined,\n ) {\n this.searchPattern = searchPattern;\n this.reader = reader;\n this.logger = logger;\n this.type = type;\n this.visibilityPermission = visibilityPermission;\n }\n\n /**\n * Returns a NewlineDelimitedJsonCollatorFactory instance from configuration\n * and a set of options.\n */\n static fromConfig(\n _config: Config,\n options: NewlineDelimitedJsonCollatorFactoryOptions,\n ): NewlineDelimitedJsonCollatorFactory {\n return new NewlineDelimitedJsonCollatorFactory(\n options.type,\n options.searchPattern,\n options.reader,\n options.logger.child({ documentType: options.type }),\n options.visibilityPermission,\n );\n }\n\n /**\n * Returns the \"latest\" URL for the given search pattern (e.g. the one at the\n * end of the list, sorted alphabetically).\n */\n private async lastUrl(): Promise<string | undefined> {\n try {\n // Search for files matching the given pattern, then sort/reverse. The\n // first item in the list will be the \"latest\" file.\n this.logger.info(\n `Attempting to find latest .ndjson matching ${this.searchPattern}`,\n );\n const { files } = await this.reader.search(this.searchPattern);\n const candidates = files\n .filter(file => file.url.endsWith('.ndjson'))\n .sort((a, b) => a.url.localeCompare(b.url))\n .reverse();\n\n return candidates[0]?.url;\n } catch (e) {\n this.logger.error(`Could not search for ${this.searchPattern}`, e);\n throw e;\n }\n }\n\n async getCollator(): Promise<Readable> {\n // Search for files matching the given pattern.\n const lastUrl = await this.lastUrl();\n\n // Abort if no such file could be found.\n if (!lastUrl) {\n const noMatchingFile = `Could not find an .ndjson file matching ${this.searchPattern}`;\n this.logger.error(noMatchingFile);\n throw new Error(noMatchingFile);\n } else {\n this.logger.info(`Using latest .ndjson file ${lastUrl}`);\n }\n\n // Use the UrlReader to try and stream the file.\n const readerResponse = await this.reader.readUrl!(lastUrl);\n const stream = readerResponse.stream!();\n\n // Use ndjson's parser to turn the raw file into an object-mode stream.\n return stream.pipe(parseNdjson());\n }\n}\n"],"names":["parseNdjson"],"mappings":";;;;AAgEO,MAAM,mCAAA,CAEb;AAAA,EACW,IAAA;AAAA,EAEO,oBAAA;AAAA,EAEC,aAAA;AAAA,EACA,MAAA;AAAA,EACA,MAAA;AAAA,EAET,WAAA,CACN,IAAA,EACA,aAAA,EACA,MAAA,EACA,QACA,oBAAA,EACA;AACA,IAAA,IAAA,CAAK,aAAA,GAAgB,aAAA;AACrB,IAAA,IAAA,CAAK,MAAA,GAAS,MAAA;AACd,IAAA,IAAA,CAAK,MAAA,GAAS,MAAA;AACd,IAAA,IAAA,CAAK,IAAA,GAAO,IAAA;AACZ,IAAA,IAAA,CAAK,oBAAA,GAAuB,oBAAA;AAAA,EAC9B;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,OAAO,UAAA,CACL,OAAA,EACA,OAAA,EACqC;AACrC,IAAA,OAAO,IAAI,mCAAA;AAAA,MACT,OAAA,CAAQ,IAAA;AAAA,MACR,OAAA,CAAQ,aAAA;AAAA,MACR,OAAA,CAAQ,MAAA;AAAA,MACR,QAAQ,MAAA,CAAO,KAAA,CAAM,EAAE,YAAA,EAAc,OAAA,CAAQ,MAAM,CAAA;AAAA,MACnD,OAAA,CAAQ;AAAA,KACV;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAc,OAAA,GAAuC;AACnD,IAAA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IAAA,OAAO,MAAA,CAAO,IAAA,CAAKA,YAAA,EAAa,CAAA;AAAA,EAClC;AACF;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -198,11 +198,11 @@ type NewlineDelimitedJsonCollatorFactoryOptions = {
|
|
|
198
198
|
* @public
|
|
199
199
|
*/
|
|
200
200
|
declare class NewlineDelimitedJsonCollatorFactory implements DocumentCollatorFactory {
|
|
201
|
+
readonly type: string;
|
|
202
|
+
readonly visibilityPermission: Permission | undefined;
|
|
201
203
|
private readonly searchPattern;
|
|
202
204
|
private readonly reader;
|
|
203
205
|
private readonly logger;
|
|
204
|
-
readonly type: string;
|
|
205
|
-
readonly visibilityPermission: Permission | undefined;
|
|
206
206
|
private constructor();
|
|
207
207
|
/**
|
|
208
208
|
* Returns a NewlineDelimitedJsonCollatorFactory instance from configuration
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-search-backend-node",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.17-next.1",
|
|
4
4
|
"description": "A library for Backstage backend plugins that want to interact with the search backend plugin",
|
|
5
5
|
"backstage": {
|
|
6
6
|
"role": "node-library",
|
|
@@ -61,11 +61,11 @@
|
|
|
61
61
|
"test": "backstage-cli package test"
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
|
-
"@backstage/backend-plugin-api": "
|
|
65
|
-
"@backstage/config": "
|
|
66
|
-
"@backstage/errors": "
|
|
67
|
-
"@backstage/plugin-permission-common": "
|
|
68
|
-
"@backstage/plugin-search-common": "
|
|
64
|
+
"@backstage/backend-plugin-api": "1.5.0-next.1",
|
|
65
|
+
"@backstage/config": "1.3.6-next.0",
|
|
66
|
+
"@backstage/errors": "1.2.7",
|
|
67
|
+
"@backstage/plugin-permission-common": "0.9.3-next.1",
|
|
68
|
+
"@backstage/plugin-search-common": "1.2.21-next.0",
|
|
69
69
|
"@types/lunr": "^2.3.3",
|
|
70
70
|
"lodash": "^4.17.21",
|
|
71
71
|
"lunr": "^2.3.9",
|
|
@@ -73,9 +73,9 @@
|
|
|
73
73
|
"uuid": "^11.0.0"
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|
|
76
|
-
"@backstage/backend-defaults": "
|
|
77
|
-
"@backstage/backend-test-utils": "
|
|
78
|
-
"@backstage/cli": "
|
|
76
|
+
"@backstage/backend-defaults": "0.13.1-next.1",
|
|
77
|
+
"@backstage/backend-test-utils": "1.10.0-next.1",
|
|
78
|
+
"@backstage/cli": "0.34.5-next.1",
|
|
79
79
|
"@types/ndjson": "^2.0.1"
|
|
80
80
|
}
|
|
81
81
|
}
|