@backstage/plugin-search-backend-module-catalog 0.2.6 → 0.3.0-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 +39 -0
- package/dist/collators/DefaultCatalogCollatorFactory.cjs.js +18 -31
- package/dist/collators/DefaultCatalogCollatorFactory.cjs.js.map +1 -1
- package/dist/index.cjs.js +1 -3
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +9 -66
- package/dist/module.cjs.js +9 -20
- package/dist/module.cjs.js.map +1 -1
- package/package.json +26 -43
- package/dist/alpha.cjs.js +0 -10
- package/dist/alpha.cjs.js.map +0 -1
- package/dist/alpha.d.ts +0 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,44 @@
|
|
|
1
1
|
# @backstage/plugin-search-backend-module-catalog
|
|
2
2
|
|
|
3
|
+
## 0.3.0-next.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
- @backstage/backend-plugin-api@1.1.1-next.1
|
|
9
|
+
- @backstage/catalog-model@1.7.3-next.0
|
|
10
|
+
- @backstage/config@1.3.2-next.0
|
|
11
|
+
- @backstage/errors@1.2.7-next.0
|
|
12
|
+
- @backstage/plugin-catalog-node@1.15.1-next.1
|
|
13
|
+
- @backstage/plugin-permission-common@0.8.4-next.0
|
|
14
|
+
- @backstage/plugin-search-common@1.2.17-next.0
|
|
15
|
+
- @backstage/plugin-search-backend-node@1.3.7-next.1
|
|
16
|
+
- @backstage/catalog-client@1.9.1-next.0
|
|
17
|
+
- @backstage/plugin-catalog-common@1.1.3-next.0
|
|
18
|
+
|
|
19
|
+
## 0.3.0-next.0
|
|
20
|
+
|
|
21
|
+
### Minor Changes
|
|
22
|
+
|
|
23
|
+
- dd515e3: **BREAKING**: Removed support for the old backend system. Please [migrate to the new backend system](https://backstage.io/docs/backend-system/) and enable [the catalog collator](https://backstage.io/docs/features/search/collators#catalog) there.
|
|
24
|
+
|
|
25
|
+
As part of this, the `/alpha` export path is gone too. Just import the module from the root of the package as usual instead.
|
|
26
|
+
|
|
27
|
+
### Patch Changes
|
|
28
|
+
|
|
29
|
+
- 1e09b06: Internal refactor to use cursor based pagination
|
|
30
|
+
- Updated dependencies
|
|
31
|
+
- @backstage/backend-plugin-api@1.1.1-next.0
|
|
32
|
+
- @backstage/catalog-client@1.9.0
|
|
33
|
+
- @backstage/catalog-model@1.7.2
|
|
34
|
+
- @backstage/config@1.3.1
|
|
35
|
+
- @backstage/errors@1.2.6
|
|
36
|
+
- @backstage/plugin-catalog-common@1.1.2
|
|
37
|
+
- @backstage/plugin-catalog-node@1.15.1-next.0
|
|
38
|
+
- @backstage/plugin-permission-common@0.8.3
|
|
39
|
+
- @backstage/plugin-search-backend-node@1.3.7-next.0
|
|
40
|
+
- @backstage/plugin-search-common@1.2.16
|
|
41
|
+
|
|
3
42
|
## 0.2.6
|
|
4
43
|
|
|
5
44
|
### Patch Changes
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var backendCommon = require('@backstage/backend-common');
|
|
4
|
-
var catalogClient = require('@backstage/catalog-client');
|
|
5
3
|
var catalogModel = require('@backstage/catalog-model');
|
|
6
4
|
var alpha = require('@backstage/plugin-catalog-common/alpha');
|
|
7
5
|
var stream = require('stream');
|
|
@@ -14,40 +12,33 @@ class DefaultCatalogCollatorFactory {
|
|
|
14
12
|
locationTemplate;
|
|
15
13
|
filter;
|
|
16
14
|
batchSize;
|
|
17
|
-
|
|
15
|
+
catalog;
|
|
18
16
|
entityTransformer;
|
|
19
17
|
auth;
|
|
20
18
|
static fromConfig(configRoot, options) {
|
|
21
19
|
const configOptions = config.readCollatorConfigOptions(configRoot);
|
|
22
|
-
const { auth: adaptedAuth } = backendCommon.createLegacyAuthAdapters({
|
|
23
|
-
auth: options.auth,
|
|
24
|
-
discovery: options.discovery,
|
|
25
|
-
tokenManager: options.tokenManager
|
|
26
|
-
});
|
|
27
20
|
return new DefaultCatalogCollatorFactory({
|
|
28
|
-
locationTemplate:
|
|
29
|
-
filter:
|
|
30
|
-
batchSize:
|
|
21
|
+
locationTemplate: configOptions.locationTemplate,
|
|
22
|
+
filter: configOptions.filter,
|
|
23
|
+
batchSize: configOptions.batchSize,
|
|
31
24
|
entityTransformer: options.entityTransformer,
|
|
32
|
-
auth:
|
|
33
|
-
|
|
34
|
-
catalogClient: options.catalogClient
|
|
25
|
+
auth: options.auth,
|
|
26
|
+
catalog: options.catalog
|
|
35
27
|
});
|
|
36
28
|
}
|
|
37
29
|
constructor(options) {
|
|
38
30
|
const {
|
|
39
31
|
auth,
|
|
40
32
|
batchSize,
|
|
41
|
-
discovery,
|
|
42
33
|
locationTemplate,
|
|
43
34
|
filter,
|
|
44
|
-
|
|
35
|
+
catalog,
|
|
45
36
|
entityTransformer
|
|
46
37
|
} = options;
|
|
47
38
|
this.locationTemplate = locationTemplate;
|
|
48
39
|
this.filter = filter;
|
|
49
40
|
this.batchSize = batchSize;
|
|
50
|
-
this.
|
|
41
|
+
this.catalog = catalog;
|
|
51
42
|
this.entityTransformer = entityTransformer ?? defaultCatalogCollatorEntityTransformer.defaultCatalogCollatorEntityTransformer;
|
|
52
43
|
this.auth = auth;
|
|
53
44
|
}
|
|
@@ -56,23 +47,19 @@ class DefaultCatalogCollatorFactory {
|
|
|
56
47
|
}
|
|
57
48
|
async *execute() {
|
|
58
49
|
let entitiesRetrieved = 0;
|
|
59
|
-
let
|
|
60
|
-
|
|
61
|
-
const
|
|
62
|
-
onBehalfOf: await this.auth.getOwnServiceCredentials(),
|
|
63
|
-
targetPluginId: "catalog"
|
|
64
|
-
});
|
|
65
|
-
const entities = (await this.catalogClient.getEntities(
|
|
50
|
+
let cursor = void 0;
|
|
51
|
+
do {
|
|
52
|
+
const response = await this.catalog.queryEntities(
|
|
66
53
|
{
|
|
67
54
|
filter: this.filter,
|
|
68
55
|
limit: this.batchSize,
|
|
69
|
-
|
|
56
|
+
...cursor ? { cursor } : {}
|
|
70
57
|
},
|
|
71
|
-
{
|
|
72
|
-
)
|
|
73
|
-
|
|
74
|
-
entitiesRetrieved +=
|
|
75
|
-
for (const entity of
|
|
58
|
+
{ credentials: await this.auth.getOwnServiceCredentials() }
|
|
59
|
+
);
|
|
60
|
+
cursor = response.pageInfo.nextCursor;
|
|
61
|
+
entitiesRetrieved += response.items.length;
|
|
62
|
+
for (const entity of response.items) {
|
|
76
63
|
yield {
|
|
77
64
|
...this.entityTransformer(entity),
|
|
78
65
|
authorization: {
|
|
@@ -85,7 +72,7 @@ class DefaultCatalogCollatorFactory {
|
|
|
85
72
|
})
|
|
86
73
|
};
|
|
87
74
|
}
|
|
88
|
-
}
|
|
75
|
+
} while (cursor);
|
|
89
76
|
}
|
|
90
77
|
applyArgsToFormat(format, args) {
|
|
91
78
|
let formatted = format;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DefaultCatalogCollatorFactory.cjs.js","sources":["../../src/collators/DefaultCatalogCollatorFactory.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 {
|
|
1
|
+
{"version":3,"file":"DefaultCatalogCollatorFactory.cjs.js","sources":["../../src/collators/DefaultCatalogCollatorFactory.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 { AuthService } from '@backstage/backend-plugin-api';\nimport { QueryEntitiesInitialRequest } from '@backstage/catalog-client';\nimport { stringifyEntityRef } from '@backstage/catalog-model';\nimport { Config } from '@backstage/config';\nimport { CatalogEntityDocument } from '@backstage/plugin-catalog-common';\nimport { catalogEntityReadPermission } from '@backstage/plugin-catalog-common/alpha';\nimport { CatalogService } from '@backstage/plugin-catalog-node';\nimport { Permission } from '@backstage/plugin-permission-common';\nimport { DocumentCollatorFactory } from '@backstage/plugin-search-common';\nimport { Readable } from 'stream';\nimport { CatalogCollatorEntityTransformer } from './CatalogCollatorEntityTransformer';\nimport { readCollatorConfigOptions } from './config';\nimport { defaultCatalogCollatorEntityTransformer } from './defaultCatalogCollatorEntityTransformer';\n\nexport type DefaultCatalogCollatorFactoryOptions = {\n auth: AuthService;\n catalog: CatalogService;\n /*\n * Allows you to customize how entities are shaped into documents.\n */\n entityTransformer?: CatalogCollatorEntityTransformer;\n};\n\n/**\n * Collates entities from the Catalog into documents for the search backend.\n */\nexport class DefaultCatalogCollatorFactory implements DocumentCollatorFactory {\n public readonly type = 'software-catalog';\n public readonly visibilityPermission: Permission =\n catalogEntityReadPermission;\n\n private locationTemplate: string;\n private filter?: QueryEntitiesInitialRequest['filter'];\n private batchSize: number;\n private readonly catalog: CatalogService;\n private entityTransformer: CatalogCollatorEntityTransformer;\n private auth: AuthService;\n\n static fromConfig(\n configRoot: Config,\n options: DefaultCatalogCollatorFactoryOptions,\n ) {\n const configOptions = readCollatorConfigOptions(configRoot);\n return new DefaultCatalogCollatorFactory({\n locationTemplate: configOptions.locationTemplate,\n filter: configOptions.filter,\n batchSize: configOptions.batchSize,\n entityTransformer: options.entityTransformer,\n auth: options.auth,\n catalog: options.catalog,\n });\n }\n\n private constructor(options: {\n locationTemplate: string;\n filter: QueryEntitiesInitialRequest['filter'];\n batchSize: number;\n entityTransformer?: CatalogCollatorEntityTransformer;\n auth: AuthService;\n catalog: CatalogService;\n }) {\n const {\n auth,\n batchSize,\n locationTemplate,\n filter,\n catalog,\n entityTransformer,\n } = options;\n\n this.locationTemplate = locationTemplate;\n this.filter = filter;\n this.batchSize = batchSize;\n this.catalog = catalog;\n this.entityTransformer =\n entityTransformer ?? defaultCatalogCollatorEntityTransformer;\n this.auth = auth;\n }\n\n async getCollator(): Promise<Readable> {\n return Readable.from(this.execute());\n }\n\n private async *execute(): AsyncGenerator<CatalogEntityDocument> {\n let entitiesRetrieved = 0;\n let cursor: string | undefined = undefined;\n\n do {\n const response = await this.catalog.queryEntities(\n {\n filter: this.filter,\n limit: this.batchSize,\n ...(cursor ? { cursor } : {}),\n },\n { credentials: await this.auth.getOwnServiceCredentials() },\n );\n cursor = response.pageInfo.nextCursor;\n entitiesRetrieved += response.items.length;\n\n for (const entity of response.items) {\n yield {\n ...this.entityTransformer(entity),\n authorization: {\n resourceRef: stringifyEntityRef(entity),\n },\n location: this.applyArgsToFormat(this.locationTemplate, {\n namespace: entity.metadata.namespace || 'default',\n kind: entity.kind,\n name: entity.metadata.name,\n }),\n };\n }\n } while (cursor);\n }\n\n private applyArgsToFormat(\n format: string,\n args: Record<string, string>,\n ): string {\n let formatted = format;\n\n for (const [key, value] of Object.entries(args)) {\n formatted = formatted.replace(`:${key}`, value);\n }\n\n return formatted.toLowerCase();\n }\n}\n"],"names":["catalogEntityReadPermission","readCollatorConfigOptions","defaultCatalogCollatorEntityTransformer","Readable","stringifyEntityRef"],"mappings":";;;;;;;;AA0CO,MAAM,6BAAiE,CAAA;AAAA,EAC5D,IAAO,GAAA,kBAAA;AAAA,EACP,oBACd,GAAAA,iCAAA;AAAA,EAEM,gBAAA;AAAA,EACA,MAAA;AAAA,EACA,SAAA;AAAA,EACS,OAAA;AAAA,EACT,iBAAA;AAAA,EACA,IAAA;AAAA,EAER,OAAO,UACL,CAAA,UAAA,EACA,OACA,EAAA;AACA,IAAM,MAAA,aAAA,GAAgBC,iCAA0B,UAAU,CAAA;AAC1D,IAAA,OAAO,IAAI,6BAA8B,CAAA;AAAA,MACvC,kBAAkB,aAAc,CAAA,gBAAA;AAAA,MAChC,QAAQ,aAAc,CAAA,MAAA;AAAA,MACtB,WAAW,aAAc,CAAA,SAAA;AAAA,MACzB,mBAAmB,OAAQ,CAAA,iBAAA;AAAA,MAC3B,MAAM,OAAQ,CAAA,IAAA;AAAA,MACd,SAAS,OAAQ,CAAA;AAAA,KAClB,CAAA;AAAA;AACH,EAEQ,YAAY,OAOjB,EAAA;AACD,IAAM,MAAA;AAAA,MACJ,IAAA;AAAA,MACA,SAAA;AAAA,MACA,gBAAA;AAAA,MACA,MAAA;AAAA,MACA,OAAA;AAAA,MACA;AAAA,KACE,GAAA,OAAA;AAEJ,IAAA,IAAA,CAAK,gBAAmB,GAAA,gBAAA;AACxB,IAAA,IAAA,CAAK,MAAS,GAAA,MAAA;AACd,IAAA,IAAA,CAAK,SAAY,GAAA,SAAA;AACjB,IAAA,IAAA,CAAK,OAAU,GAAA,OAAA;AACf,IAAA,IAAA,CAAK,oBACH,iBAAqB,IAAAC,+EAAA;AACvB,IAAA,IAAA,CAAK,IAAO,GAAA,IAAA;AAAA;AACd,EAEA,MAAM,WAAiC,GAAA;AACrC,IAAA,OAAOC,eAAS,CAAA,IAAA,CAAK,IAAK,CAAA,OAAA,EAAS,CAAA;AAAA;AACrC,EAEA,OAAe,OAAiD,GAAA;AAC9D,IAAA,IAAI,iBAAoB,GAAA,CAAA;AACxB,IAAA,IAAI,MAA6B,GAAA,KAAA,CAAA;AAEjC,IAAG,GAAA;AACD,MAAM,MAAA,QAAA,GAAW,MAAM,IAAA,CAAK,OAAQ,CAAA,aAAA;AAAA,QAClC;AAAA,UACE,QAAQ,IAAK,CAAA,MAAA;AAAA,UACb,OAAO,IAAK,CAAA,SAAA;AAAA,UACZ,GAAI,MAAA,GAAS,EAAE,MAAA,KAAW;AAAC,SAC7B;AAAA,QACA,EAAE,WAAa,EAAA,MAAM,IAAK,CAAA,IAAA,CAAK,0BAA2B;AAAA,OAC5D;AACA,MAAA,MAAA,GAAS,SAAS,QAAS,CAAA,UAAA;AAC3B,MAAA,iBAAA,IAAqB,SAAS,KAAM,CAAA,MAAA;AAEpC,MAAW,KAAA,MAAA,MAAA,IAAU,SAAS,KAAO,EAAA;AACnC,QAAM,MAAA;AAAA,UACJ,GAAG,IAAK,CAAA,iBAAA,CAAkB,MAAM,CAAA;AAAA,UAChC,aAAe,EAAA;AAAA,YACb,WAAA,EAAaC,gCAAmB,MAAM;AAAA,WACxC;AAAA,UACA,QAAU,EAAA,IAAA,CAAK,iBAAkB,CAAA,IAAA,CAAK,gBAAkB,EAAA;AAAA,YACtD,SAAA,EAAW,MAAO,CAAA,QAAA,CAAS,SAAa,IAAA,SAAA;AAAA,YACxC,MAAM,MAAO,CAAA,IAAA;AAAA,YACb,IAAA,EAAM,OAAO,QAAS,CAAA;AAAA,WACvB;AAAA,SACH;AAAA;AACF,KACO,QAAA,MAAA;AAAA;AACX,EAEQ,iBAAA,CACN,QACA,IACQ,EAAA;AACR,IAAA,IAAI,SAAY,GAAA,MAAA;AAEhB,IAAA,KAAA,MAAW,CAAC,GAAK,EAAA,KAAK,KAAK,MAAO,CAAA,OAAA,CAAQ,IAAI,CAAG,EAAA;AAC/C,MAAA,SAAA,GAAY,SAAU,CAAA,OAAA,CAAQ,CAAI,CAAA,EAAA,GAAG,IAAI,KAAK,CAAA;AAAA;AAGhD,IAAA,OAAO,UAAU,WAAY,EAAA;AAAA;AAEjC;;;;"}
|
package/dist/index.cjs.js
CHANGED
|
@@ -3,13 +3,11 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var module$1 = require('./module.cjs.js');
|
|
6
|
-
var DefaultCatalogCollatorFactory = require('./collators/DefaultCatalogCollatorFactory.cjs.js');
|
|
7
6
|
var defaultCatalogCollatorEntityTransformer = require('./collators/defaultCatalogCollatorEntityTransformer.cjs.js');
|
|
8
7
|
|
|
9
8
|
|
|
10
9
|
|
|
11
10
|
exports.catalogCollatorExtensionPoint = module$1.catalogCollatorExtensionPoint;
|
|
12
|
-
exports.default = module$1.
|
|
13
|
-
exports.DefaultCatalogCollatorFactory = DefaultCatalogCollatorFactory.DefaultCatalogCollatorFactory;
|
|
11
|
+
exports.default = module$1.searchModuleCatalogCollator;
|
|
14
12
|
exports.defaultCatalogCollatorEntityTransformer = defaultCatalogCollatorEntityTransformer.defaultCatalogCollatorEntityTransformer;
|
|
15
13
|
//# sourceMappingURL=index.cjs.js.map
|
package/dist/index.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import * as _backstage_backend_plugin_api from '@backstage/backend-plugin-api';
|
|
3
|
-
import { AuthService, DiscoveryService } from '@backstage/backend-plugin-api';
|
|
4
|
-
import { CatalogCollatorEntityTransformer as CatalogCollatorEntityTransformer$1 } from '@backstage/plugin-search-backend-module-catalog';
|
|
5
|
-
import { TokenManager } from '@backstage/backend-common';
|
|
6
|
-
import { GetEntitiesRequest, CatalogApi } from '@backstage/catalog-client';
|
|
7
|
-
import { Config } from '@backstage/config';
|
|
8
|
-
import { Permission } from '@backstage/plugin-permission-common';
|
|
9
|
-
import { DocumentCollatorFactory } from '@backstage/plugin-search-common';
|
|
10
|
-
import { Readable } from 'stream';
|
|
11
2
|
import { Entity } from '@backstage/catalog-model';
|
|
12
3
|
import { CatalogEntityDocument } from '@backstage/plugin-catalog-common';
|
|
13
4
|
|
|
5
|
+
/** @public */
|
|
6
|
+
type CatalogCollatorEntityTransformer = (entity: Entity) => Omit<CatalogEntityDocument, 'location' | 'authorization'>;
|
|
7
|
+
|
|
8
|
+
/** @public */
|
|
9
|
+
declare const defaultCatalogCollatorEntityTransformer: CatalogCollatorEntityTransformer;
|
|
10
|
+
|
|
14
11
|
/**
|
|
15
12
|
* Options for {@link catalogCollatorExtensionPoint}.
|
|
16
13
|
*
|
|
@@ -20,7 +17,7 @@ type CatalogCollatorExtensionPoint = {
|
|
|
20
17
|
/**
|
|
21
18
|
* Allows you to customize how entities are shaped into documents.
|
|
22
19
|
*/
|
|
23
|
-
setEntityTransformer(transformer: CatalogCollatorEntityTransformer
|
|
20
|
+
setEntityTransformer(transformer: CatalogCollatorEntityTransformer): void;
|
|
24
21
|
};
|
|
25
22
|
/**
|
|
26
23
|
* Extension point for customizing how catalog entities are shaped into
|
|
@@ -34,60 +31,6 @@ declare const catalogCollatorExtensionPoint: _backstage_backend_plugin_api.Exten
|
|
|
34
31
|
*
|
|
35
32
|
* @public
|
|
36
33
|
*/
|
|
37
|
-
declare const
|
|
38
|
-
|
|
39
|
-
/** @public */
|
|
40
|
-
type CatalogCollatorEntityTransformer = (entity: Entity) => Omit<CatalogEntityDocument, 'location' | 'authorization'>;
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* @public
|
|
44
|
-
* @deprecated This type is deprecated along with the {@link DefaultCatalogCollatorFactory}.
|
|
45
|
-
*/
|
|
46
|
-
type DefaultCatalogCollatorFactoryOptions = {
|
|
47
|
-
auth?: AuthService;
|
|
48
|
-
discovery: DiscoveryService;
|
|
49
|
-
tokenManager?: TokenManager;
|
|
50
|
-
/**
|
|
51
|
-
* @deprecated Use the config key `search.collators.catalog.locationTemplate` instead.
|
|
52
|
-
*/
|
|
53
|
-
locationTemplate?: string;
|
|
54
|
-
/**
|
|
55
|
-
* @deprecated Use the config key `search.collators.catalog.filter` instead.
|
|
56
|
-
*/
|
|
57
|
-
filter?: GetEntitiesRequest['filter'];
|
|
58
|
-
/**
|
|
59
|
-
* @deprecated Use the config key `search.collators.catalog.batchSize` instead.
|
|
60
|
-
*/
|
|
61
|
-
batchSize?: number;
|
|
62
|
-
catalogClient?: CatalogApi;
|
|
63
|
-
/**
|
|
64
|
-
* Allows you to customize how entities are shaped into documents.
|
|
65
|
-
*/
|
|
66
|
-
entityTransformer?: CatalogCollatorEntityTransformer;
|
|
67
|
-
};
|
|
68
|
-
/**
|
|
69
|
-
* Collates entities from the Catalog into documents for the search backend.
|
|
70
|
-
*
|
|
71
|
-
* @public
|
|
72
|
-
* @deprecated Migrate to the {@link https://backstage.io/docs/backend-system/building-backends/migrating | new backend system} and install this collator via module instead (see {@link https://github.com/backstage/backstage/blob/nbs10/search-deprecate-create-router/plugins/search-backend-module-catalog/README.md#installation | here} for more installation details).
|
|
73
|
-
*/
|
|
74
|
-
declare class DefaultCatalogCollatorFactory implements DocumentCollatorFactory {
|
|
75
|
-
readonly type = "software-catalog";
|
|
76
|
-
readonly visibilityPermission: Permission;
|
|
77
|
-
private locationTemplate;
|
|
78
|
-
private filter?;
|
|
79
|
-
private batchSize;
|
|
80
|
-
private readonly catalogClient;
|
|
81
|
-
private entityTransformer;
|
|
82
|
-
private auth;
|
|
83
|
-
static fromConfig(configRoot: Config, options: DefaultCatalogCollatorFactoryOptions): DefaultCatalogCollatorFactory;
|
|
84
|
-
private constructor();
|
|
85
|
-
getCollator(): Promise<Readable>;
|
|
86
|
-
private execute;
|
|
87
|
-
private applyArgsToFormat;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
/** @public */
|
|
91
|
-
declare const defaultCatalogCollatorEntityTransformer: CatalogCollatorEntityTransformer;
|
|
34
|
+
declare const searchModuleCatalogCollator: _backstage_backend_plugin_api.BackendFeature;
|
|
92
35
|
|
|
93
|
-
export { type CatalogCollatorEntityTransformer, type CatalogCollatorExtensionPoint,
|
|
36
|
+
export { type CatalogCollatorEntityTransformer, type CatalogCollatorExtensionPoint, catalogCollatorExtensionPoint, searchModuleCatalogCollator as default, defaultCatalogCollatorEntityTransformer };
|
package/dist/module.cjs.js
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
3
|
var backendPluginApi = require('@backstage/backend-plugin-api');
|
|
6
|
-
var
|
|
7
|
-
var pluginSearchBackendModuleCatalog = require('@backstage/plugin-search-backend-module-catalog');
|
|
4
|
+
var pluginCatalogNode = require('@backstage/plugin-catalog-node');
|
|
8
5
|
var alpha = require('@backstage/plugin-search-backend-node/alpha');
|
|
9
6
|
var config = require('./collators/config.cjs.js');
|
|
7
|
+
var DefaultCatalogCollatorFactory = require('./collators/DefaultCatalogCollatorFactory.cjs.js');
|
|
10
8
|
|
|
11
9
|
const catalogCollatorExtensionPoint = backendPluginApi.createExtensionPoint({
|
|
12
10
|
id: "search.catalogCollator.extension"
|
|
13
11
|
});
|
|
14
|
-
|
|
12
|
+
const searchModuleCatalogCollator = backendPluginApi.createBackendModule({
|
|
15
13
|
pluginId: "search",
|
|
16
14
|
moduleId: "catalog-collator",
|
|
17
15
|
register(env) {
|
|
@@ -28,28 +26,19 @@ var feature = backendPluginApi.createBackendModule({
|
|
|
28
26
|
deps: {
|
|
29
27
|
auth: backendPluginApi.coreServices.auth,
|
|
30
28
|
config: backendPluginApi.coreServices.rootConfig,
|
|
31
|
-
discovery: backendPluginApi.coreServices.discovery,
|
|
32
29
|
scheduler: backendPluginApi.coreServices.scheduler,
|
|
33
30
|
indexRegistry: alpha.searchIndexRegistryExtensionPoint,
|
|
34
|
-
catalog:
|
|
31
|
+
catalog: pluginCatalogNode.catalogServiceRef
|
|
35
32
|
},
|
|
36
|
-
async init({
|
|
37
|
-
auth,
|
|
38
|
-
config: config$1,
|
|
39
|
-
discovery,
|
|
40
|
-
scheduler,
|
|
41
|
-
indexRegistry,
|
|
42
|
-
catalog
|
|
43
|
-
}) {
|
|
33
|
+
async init({ auth, config: config$1, scheduler, indexRegistry, catalog }) {
|
|
44
34
|
indexRegistry.addCollator({
|
|
45
35
|
schedule: scheduler.createScheduledTaskRunner(
|
|
46
36
|
config.readScheduleConfigOptions(config$1)
|
|
47
37
|
),
|
|
48
|
-
factory:
|
|
38
|
+
factory: DefaultCatalogCollatorFactory.DefaultCatalogCollatorFactory.fromConfig(config$1, {
|
|
49
39
|
auth,
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
catalogClient: catalog
|
|
40
|
+
catalog,
|
|
41
|
+
entityTransformer
|
|
53
42
|
})
|
|
54
43
|
});
|
|
55
44
|
}
|
|
@@ -58,5 +47,5 @@ var feature = backendPluginApi.createBackendModule({
|
|
|
58
47
|
});
|
|
59
48
|
|
|
60
49
|
exports.catalogCollatorExtensionPoint = catalogCollatorExtensionPoint;
|
|
61
|
-
exports.
|
|
50
|
+
exports.searchModuleCatalogCollator = searchModuleCatalogCollator;
|
|
62
51
|
//# sourceMappingURL=module.cjs.js.map
|
package/dist/module.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.cjs.js","sources":["../src/module.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\n/**\n * @packageDocumentation\n * A module for the search backend that
|
|
1
|
+
{"version":3,"file":"module.cjs.js","sources":["../src/module.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\n/**\n * @packageDocumentation\n *\n * A collator module for the search backend that indexes your software catalog.\n */\n\nimport {\n coreServices,\n createBackendModule,\n createExtensionPoint,\n} from '@backstage/backend-plugin-api';\nimport { catalogServiceRef } from '@backstage/plugin-catalog-node';\nimport { searchIndexRegistryExtensionPoint } from '@backstage/plugin-search-backend-node/alpha';\nimport { readScheduleConfigOptions } from './collators/config';\nimport { CatalogCollatorEntityTransformer } from './collators';\nimport { DefaultCatalogCollatorFactory } from './collators/DefaultCatalogCollatorFactory';\n\n/**\n * Options for {@link catalogCollatorExtensionPoint}.\n *\n * @public\n */\nexport type CatalogCollatorExtensionPoint = {\n /**\n * Allows you to customize how entities are shaped into documents.\n */\n setEntityTransformer(transformer: CatalogCollatorEntityTransformer): void;\n};\n\n/**\n * Extension point for customizing how catalog entities are shaped into\n * documents for the search backend.\n *\n * @public\n */\nexport const catalogCollatorExtensionPoint =\n createExtensionPoint<CatalogCollatorExtensionPoint>({\n id: 'search.catalogCollator.extension',\n });\n\n/**\n * Search backend module for the Catalog index.\n *\n * @public\n */\nexport const searchModuleCatalogCollator = createBackendModule({\n pluginId: 'search',\n moduleId: 'catalog-collator',\n register(env) {\n let entityTransformer: CatalogCollatorEntityTransformer | undefined;\n\n env.registerExtensionPoint(catalogCollatorExtensionPoint, {\n setEntityTransformer(transformer) {\n if (entityTransformer) {\n throw new Error('setEntityTransformer can only be called once');\n }\n entityTransformer = transformer;\n },\n });\n\n env.registerInit({\n deps: {\n auth: coreServices.auth,\n config: coreServices.rootConfig,\n scheduler: coreServices.scheduler,\n indexRegistry: searchIndexRegistryExtensionPoint,\n catalog: catalogServiceRef,\n },\n async init({ auth, config, scheduler, indexRegistry, catalog }) {\n indexRegistry.addCollator({\n schedule: scheduler.createScheduledTaskRunner(\n readScheduleConfigOptions(config),\n ),\n factory: DefaultCatalogCollatorFactory.fromConfig(config, {\n auth,\n catalog,\n entityTransformer,\n }),\n });\n },\n });\n },\n});\n"],"names":["createExtensionPoint","createBackendModule","coreServices","searchIndexRegistryExtensionPoint","catalogServiceRef","config","readScheduleConfigOptions","DefaultCatalogCollatorFactory"],"mappings":";;;;;;;;AAmDO,MAAM,gCACXA,qCAAoD,CAAA;AAAA,EAClD,EAAI,EAAA;AACN,CAAC;AAOI,MAAM,8BAA8BC,oCAAoB,CAAA;AAAA,EAC7D,QAAU,EAAA,QAAA;AAAA,EACV,QAAU,EAAA,kBAAA;AAAA,EACV,SAAS,GAAK,EAAA;AACZ,IAAI,IAAA,iBAAA;AAEJ,IAAA,GAAA,CAAI,uBAAuB,6BAA+B,EAAA;AAAA,MACxD,qBAAqB,WAAa,EAAA;AAChC,QAAA,IAAI,iBAAmB,EAAA;AACrB,UAAM,MAAA,IAAI,MAAM,8CAA8C,CAAA;AAAA;AAEhE,QAAoB,iBAAA,GAAA,WAAA;AAAA;AACtB,KACD,CAAA;AAED,IAAA,GAAA,CAAI,YAAa,CAAA;AAAA,MACf,IAAM,EAAA;AAAA,QACJ,MAAMC,6BAAa,CAAA,IAAA;AAAA,QACnB,QAAQA,6BAAa,CAAA,UAAA;AAAA,QACrB,WAAWA,6BAAa,CAAA,SAAA;AAAA,QACxB,aAAe,EAAAC,uCAAA;AAAA,QACf,OAAS,EAAAC;AAAA,OACX;AAAA,MACA,MAAM,KAAK,EAAE,IAAA,UAAMC,UAAQ,SAAW,EAAA,aAAA,EAAe,SAAW,EAAA;AAC9D,QAAA,aAAA,CAAc,WAAY,CAAA;AAAA,UACxB,UAAU,SAAU,CAAA,yBAAA;AAAA,YAClBC,iCAA0BD,QAAM;AAAA,WAClC;AAAA,UACA,OAAA,EAASE,2DAA8B,CAAA,UAAA,CAAWF,QAAQ,EAAA;AAAA,YACxD,IAAA;AAAA,YACA,OAAA;AAAA,YACA;AAAA,WACD;AAAA,SACF,CAAA;AAAA;AACH,KACD,CAAA;AAAA;AAEL,CAAC;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-search-backend-module-catalog",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0-next.1",
|
|
4
4
|
"description": "A module for the search backend that exports catalog modules",
|
|
5
5
|
"backstage": {
|
|
6
6
|
"role": "backend-plugin-module",
|
|
@@ -8,7 +8,9 @@
|
|
|
8
8
|
"pluginPackage": "@backstage/plugin-search-backend"
|
|
9
9
|
},
|
|
10
10
|
"publishConfig": {
|
|
11
|
-
"access": "public"
|
|
11
|
+
"access": "public",
|
|
12
|
+
"main": "dist/index.cjs.js",
|
|
13
|
+
"types": "dist/index.d.ts"
|
|
12
14
|
},
|
|
13
15
|
"homepage": "https://backstage.io",
|
|
14
16
|
"repository": {
|
|
@@ -17,33 +19,8 @@
|
|
|
17
19
|
"directory": "plugins/search-backend-module-catalog"
|
|
18
20
|
},
|
|
19
21
|
"license": "Apache-2.0",
|
|
20
|
-
"
|
|
21
|
-
|
|
22
|
-
"backstage": "@backstage/BackendFeature",
|
|
23
|
-
"require": "./dist/index.cjs.js",
|
|
24
|
-
"types": "./dist/index.d.ts",
|
|
25
|
-
"default": "./dist/index.cjs.js"
|
|
26
|
-
},
|
|
27
|
-
"./alpha": {
|
|
28
|
-
"backstage": "@backstage/BackendFeature",
|
|
29
|
-
"require": "./dist/alpha.cjs.js",
|
|
30
|
-
"types": "./dist/alpha.d.ts",
|
|
31
|
-
"default": "./dist/alpha.cjs.js"
|
|
32
|
-
},
|
|
33
|
-
"./package.json": "./package.json"
|
|
34
|
-
},
|
|
35
|
-
"main": "./dist/index.cjs.js",
|
|
36
|
-
"types": "./dist/index.d.ts",
|
|
37
|
-
"typesVersions": {
|
|
38
|
-
"*": {
|
|
39
|
-
"index": [
|
|
40
|
-
"dist/index.d.ts"
|
|
41
|
-
],
|
|
42
|
-
"alpha": [
|
|
43
|
-
"dist/alpha.d.ts"
|
|
44
|
-
]
|
|
45
|
-
}
|
|
46
|
-
},
|
|
22
|
+
"main": "dist/index.cjs.js",
|
|
23
|
+
"types": "dist/index.d.ts",
|
|
47
24
|
"files": [
|
|
48
25
|
"dist",
|
|
49
26
|
"config.d.ts"
|
|
@@ -58,23 +35,29 @@
|
|
|
58
35
|
"test": "backstage-cli package test"
|
|
59
36
|
},
|
|
60
37
|
"dependencies": {
|
|
61
|
-
"@backstage/backend-
|
|
62
|
-
"@backstage/
|
|
63
|
-
"@backstage/catalog-
|
|
64
|
-
"@backstage/
|
|
65
|
-
"@backstage/
|
|
66
|
-
"@backstage/
|
|
67
|
-
"@backstage/plugin-catalog-
|
|
68
|
-
"@backstage/plugin-
|
|
69
|
-
"@backstage/plugin-
|
|
70
|
-
"@backstage/plugin-search-
|
|
71
|
-
"@backstage/plugin-search-common": "^1.2.16"
|
|
38
|
+
"@backstage/backend-plugin-api": "1.1.1-next.1",
|
|
39
|
+
"@backstage/catalog-client": "1.9.1-next.0",
|
|
40
|
+
"@backstage/catalog-model": "1.7.3-next.0",
|
|
41
|
+
"@backstage/config": "1.3.2-next.0",
|
|
42
|
+
"@backstage/errors": "1.2.7-next.0",
|
|
43
|
+
"@backstage/plugin-catalog-common": "1.1.3-next.0",
|
|
44
|
+
"@backstage/plugin-catalog-node": "1.15.1-next.1",
|
|
45
|
+
"@backstage/plugin-permission-common": "0.8.4-next.0",
|
|
46
|
+
"@backstage/plugin-search-backend-node": "1.3.7-next.1",
|
|
47
|
+
"@backstage/plugin-search-common": "1.2.17-next.0"
|
|
72
48
|
},
|
|
73
49
|
"devDependencies": {
|
|
74
50
|
"@backstage/backend-common": "^0.25.0",
|
|
75
|
-
"@backstage/backend-test-utils": "
|
|
76
|
-
"@backstage/cli": "
|
|
51
|
+
"@backstage/backend-test-utils": "1.2.1-next.1",
|
|
52
|
+
"@backstage/cli": "0.29.5-next.1",
|
|
77
53
|
"msw": "^1.0.0"
|
|
78
54
|
},
|
|
79
|
-
"configSchema": "config.d.ts"
|
|
55
|
+
"configSchema": "config.d.ts",
|
|
56
|
+
"typesVersions": {
|
|
57
|
+
"*": {
|
|
58
|
+
"index": [
|
|
59
|
+
"dist/index.d.ts"
|
|
60
|
+
]
|
|
61
|
+
}
|
|
62
|
+
}
|
|
80
63
|
}
|
package/dist/alpha.cjs.js
DELETED
package/dist/alpha.cjs.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"alpha.cjs.js","sources":["../src/alpha.ts"],"sourcesContent":["/*\n * Copyright 2024 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 { default as feature } from './module';\n\n/** @alpha */\nconst _feature = feature;\nexport default _feature;\n"],"names":["feature"],"mappings":";;;;;;AAmBA,MAAM,QAAW,GAAAA;;;;"}
|