@backstage/plugin-catalog-node 1.18.1-next.0 → 1.19.0
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 +69 -0
- package/dist/catalogService.cjs.js +6 -0
- package/dist/catalogService.cjs.js.map +1 -1
- package/dist/index.d.ts +9 -1
- package/dist/testUtils/catalogServiceMock.cjs.js +2 -1
- package/dist/testUtils/catalogServiceMock.cjs.js.map +1 -1
- package/dist/testUtils.d.ts +2 -1
- package/package.json +11 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,74 @@
|
|
|
1
1
|
# @backstage/plugin-catalog-node
|
|
2
2
|
|
|
3
|
+
## 1.19.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 0e9ec44: Introduced new `streamEntities` async generator method for the catalog.
|
|
8
|
+
|
|
9
|
+
Catalog API and Catalog Service now includes a `streamEntities` method that allows for streaming entities from the catalog.
|
|
10
|
+
This method is designed to handle large datasets efficiently by processing entities in a stream rather than loading them
|
|
11
|
+
all into memory at once. This is useful when you need to fetch a large number of entities but do not want to use pagination
|
|
12
|
+
or fetch all entities at once.
|
|
13
|
+
|
|
14
|
+
Example usage:
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
const pageStream = catalogClient.streamEntities({ pageSize: 100 }, { token });
|
|
18
|
+
for await (const page of pageStream) {
|
|
19
|
+
// Handle page of entities
|
|
20
|
+
for (const entity of page) {
|
|
21
|
+
console.log(entity);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### Patch Changes
|
|
27
|
+
|
|
28
|
+
- 2bbd24f: Order catalog processors by priority.
|
|
29
|
+
|
|
30
|
+
This change enables the ordering of catalog processors by their priority,
|
|
31
|
+
allowing for more control over the catalog processing sequence.
|
|
32
|
+
The default priority is set to 20, and processors can be assigned a custom
|
|
33
|
+
priority to influence their execution order. Lower number indicates higher priority.
|
|
34
|
+
The priority can be set by implementing the `getPriority` method in the processor class
|
|
35
|
+
or by adding a `catalog.processors.<processorName>.priority` configuration
|
|
36
|
+
in the `app-config.yaml` file. The configuration takes precedence over the method.
|
|
37
|
+
|
|
38
|
+
- Updated dependencies
|
|
39
|
+
- @backstage/catalog-client@1.12.0
|
|
40
|
+
- @backstage/types@1.2.2
|
|
41
|
+
- @backstage/backend-plugin-api@1.4.3
|
|
42
|
+
- @backstage/plugin-permission-node@0.10.4
|
|
43
|
+
|
|
44
|
+
## 1.19.0-next.1
|
|
45
|
+
|
|
46
|
+
### Minor Changes
|
|
47
|
+
|
|
48
|
+
- 0e9ec44: Introduced new `streamEntities` async generator method for the catalog.
|
|
49
|
+
|
|
50
|
+
Catalog API and Catalog Service now includes a `streamEntities` method that allows for streaming entities from the catalog.
|
|
51
|
+
This method is designed to handle large datasets efficiently by processing entities in a stream rather than loading them
|
|
52
|
+
all into memory at once. This is useful when you need to fetch a large number of entities but do not want to use pagination
|
|
53
|
+
or fetch all entities at once.
|
|
54
|
+
|
|
55
|
+
Example usage:
|
|
56
|
+
|
|
57
|
+
```ts
|
|
58
|
+
const pageStream = catalogClient.streamEntities({ pageSize: 100 }, { token });
|
|
59
|
+
for await (const page of pageStream) {
|
|
60
|
+
// Handle page of entities
|
|
61
|
+
for (const entity of page) {
|
|
62
|
+
console.log(entity);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Patch Changes
|
|
68
|
+
|
|
69
|
+
- Updated dependencies
|
|
70
|
+
- @backstage/catalog-client@1.12.0-next.0
|
|
71
|
+
|
|
3
72
|
## 1.18.1-next.0
|
|
4
73
|
|
|
5
74
|
### Patch Changes
|
|
@@ -110,6 +110,12 @@ class DefaultCatalogService {
|
|
|
110
110
|
await this.#getOptions(options)
|
|
111
111
|
);
|
|
112
112
|
}
|
|
113
|
+
async *streamEntities(request, options) {
|
|
114
|
+
yield* this.#catalogApi.streamEntities(
|
|
115
|
+
request,
|
|
116
|
+
await this.#getOptions(options)
|
|
117
|
+
);
|
|
118
|
+
}
|
|
113
119
|
async #getOptions(options) {
|
|
114
120
|
return this.#auth.getPluginRequestToken({
|
|
115
121
|
onBehalfOf: options.credentials,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"catalogService.cjs.js","sources":["../src/catalogService.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 createServiceFactory,\n createServiceRef,\n coreServices,\n BackstageCredentials,\n AuthService,\n} from '@backstage/backend-plugin-api';\nimport {\n AddLocationRequest,\n AddLocationResponse,\n CatalogApi,\n CatalogClient,\n CatalogRequestOptions,\n GetEntitiesByRefsRequest,\n GetEntitiesByRefsResponse,\n GetEntitiesRequest,\n GetEntitiesResponse,\n GetEntityAncestorsRequest,\n GetEntityAncestorsResponse,\n GetEntityFacetsRequest,\n GetEntityFacetsResponse,\n GetLocationsResponse,\n Location,\n QueryEntitiesRequest,\n QueryEntitiesResponse,\n ValidateEntityResponse,\n} from '@backstage/catalog-client';\nimport { CompoundEntityRef, Entity } from '@backstage/catalog-model';\nimport {\n AnalyzeLocationRequest,\n AnalyzeLocationResponse,\n} from '@backstage/plugin-catalog-common';\n\n/**\n * @public\n */\nexport interface CatalogServiceRequestOptions {\n credentials: BackstageCredentials;\n}\n\n/**\n * A version of the {@link @backstage/catalog-client#CatalogApi | CatalogApi} that\n * requires backend credentials to be passed instead of a token.\n *\n * @public\n */\nexport interface CatalogService {\n getEntities(\n request: GetEntitiesRequest | undefined,\n options: CatalogServiceRequestOptions,\n ): Promise<GetEntitiesResponse>;\n\n getEntitiesByRefs(\n request: GetEntitiesByRefsRequest,\n options: CatalogServiceRequestOptions,\n ): Promise<GetEntitiesByRefsResponse>;\n\n queryEntities(\n request: QueryEntitiesRequest | undefined,\n options: CatalogServiceRequestOptions,\n ): Promise<QueryEntitiesResponse>;\n\n getEntityAncestors(\n request: GetEntityAncestorsRequest,\n options: CatalogServiceRequestOptions,\n ): Promise<GetEntityAncestorsResponse>;\n\n getEntityByRef(\n entityRef: string | CompoundEntityRef,\n options: CatalogServiceRequestOptions,\n ): Promise<Entity | undefined>;\n\n removeEntityByUid(\n uid: string,\n options: CatalogServiceRequestOptions,\n ): Promise<void>;\n\n refreshEntity(\n entityRef: string,\n options: CatalogServiceRequestOptions,\n ): Promise<void>;\n\n getEntityFacets(\n request: GetEntityFacetsRequest,\n options: CatalogServiceRequestOptions,\n ): Promise<GetEntityFacetsResponse>;\n\n getLocations(\n request: {} | undefined,\n options: CatalogServiceRequestOptions,\n ): Promise<GetLocationsResponse>;\n\n getLocationById(\n id: string,\n options: CatalogServiceRequestOptions,\n ): Promise<Location | undefined>;\n\n getLocationByRef(\n locationRef: string,\n options: CatalogServiceRequestOptions,\n ): Promise<Location | undefined>;\n\n addLocation(\n location: AddLocationRequest,\n options: CatalogServiceRequestOptions,\n ): Promise<AddLocationResponse>;\n\n removeLocationById(\n id: string,\n options: CatalogServiceRequestOptions,\n ): Promise<void>;\n\n getLocationByEntity(\n entityRef: string | CompoundEntityRef,\n options: CatalogServiceRequestOptions,\n ): Promise<Location | undefined>;\n\n validateEntity(\n entity: Entity,\n locationRef: string,\n options: CatalogServiceRequestOptions,\n ): Promise<ValidateEntityResponse>;\n\n analyzeLocation(\n location: AnalyzeLocationRequest,\n options: CatalogServiceRequestOptions,\n ): Promise<AnalyzeLocationResponse>;\n}\n\nclass DefaultCatalogService implements CatalogService {\n readonly #auth: AuthService;\n readonly #catalogApi: CatalogApi;\n\n constructor({\n catalogApi,\n auth,\n }: {\n catalogApi: CatalogApi;\n auth: AuthService;\n }) {\n this.#catalogApi = catalogApi;\n this.#auth = auth;\n }\n\n async getEntities(\n request: GetEntitiesRequest | undefined,\n options: CatalogServiceRequestOptions,\n ): Promise<GetEntitiesResponse> {\n return this.#catalogApi.getEntities(\n request,\n await this.#getOptions(options),\n );\n }\n\n async getEntitiesByRefs(\n request: GetEntitiesByRefsRequest,\n options: CatalogServiceRequestOptions,\n ): Promise<GetEntitiesByRefsResponse> {\n return this.#catalogApi.getEntitiesByRefs(\n request,\n await this.#getOptions(options),\n );\n }\n\n async queryEntities(\n request: QueryEntitiesRequest | undefined,\n options: CatalogServiceRequestOptions,\n ): Promise<QueryEntitiesResponse> {\n return this.#catalogApi.queryEntities(\n request,\n await this.#getOptions(options),\n );\n }\n\n async getEntityAncestors(\n request: GetEntityAncestorsRequest,\n options: CatalogServiceRequestOptions,\n ): Promise<GetEntityAncestorsResponse> {\n return this.#catalogApi.getEntityAncestors(\n request,\n await this.#getOptions(options),\n );\n }\n\n async getEntityByRef(\n entityRef: string | CompoundEntityRef,\n options: CatalogServiceRequestOptions,\n ): Promise<Entity | undefined> {\n return this.#catalogApi.getEntityByRef(\n entityRef,\n await this.#getOptions(options),\n );\n }\n\n async removeEntityByUid(\n uid: string,\n options: CatalogServiceRequestOptions,\n ): Promise<void> {\n return this.#catalogApi.removeEntityByUid(\n uid,\n await this.#getOptions(options),\n );\n }\n\n async refreshEntity(\n entityRef: string,\n options: CatalogServiceRequestOptions,\n ): Promise<void> {\n return this.#catalogApi.refreshEntity(\n entityRef,\n await this.#getOptions(options),\n );\n }\n\n async getEntityFacets(\n request: GetEntityFacetsRequest,\n options: CatalogServiceRequestOptions,\n ): Promise<GetEntityFacetsResponse> {\n return this.#catalogApi.getEntityFacets(\n request,\n await this.#getOptions(options),\n );\n }\n\n async getLocations(\n request: {} | undefined,\n options: CatalogServiceRequestOptions,\n ): Promise<GetLocationsResponse> {\n return this.#catalogApi.getLocations(\n request,\n await this.#getOptions(options),\n );\n }\n\n async getLocationById(\n id: string,\n options: CatalogServiceRequestOptions,\n ): Promise<Location | undefined> {\n return this.#catalogApi.getLocationById(\n id,\n await this.#getOptions(options),\n );\n }\n\n async getLocationByRef(\n locationRef: string,\n options: CatalogServiceRequestOptions,\n ): Promise<Location | undefined> {\n return this.#catalogApi.getLocationByRef(\n locationRef,\n await this.#getOptions(options),\n );\n }\n\n async addLocation(\n location: AddLocationRequest,\n options: CatalogServiceRequestOptions,\n ): Promise<AddLocationResponse> {\n return this.#catalogApi.addLocation(\n location,\n await this.#getOptions(options),\n );\n }\n\n async removeLocationById(\n id: string,\n options: CatalogServiceRequestOptions,\n ): Promise<void> {\n return this.#catalogApi.removeLocationById(\n id,\n await this.#getOptions(options),\n );\n }\n\n async getLocationByEntity(\n entityRef: string | CompoundEntityRef,\n options: CatalogServiceRequestOptions,\n ): Promise<Location | undefined> {\n return this.#catalogApi.getLocationByEntity(\n entityRef,\n await this.#getOptions(options),\n );\n }\n\n async validateEntity(\n entity: Entity,\n locationRef: string,\n options: CatalogServiceRequestOptions,\n ): Promise<ValidateEntityResponse> {\n return this.#catalogApi.validateEntity(\n entity,\n locationRef,\n await this.#getOptions(options),\n );\n }\n\n async analyzeLocation(\n location: AnalyzeLocationRequest,\n options: CatalogServiceRequestOptions,\n ): Promise<AnalyzeLocationResponse> {\n return this.#catalogApi.analyzeLocation(\n location,\n await this.#getOptions(options),\n );\n }\n\n async #getOptions(\n options: CatalogServiceRequestOptions,\n ): Promise<CatalogRequestOptions> {\n return this.#auth.getPluginRequestToken({\n onBehalfOf: options.credentials,\n targetPluginId: 'catalog',\n });\n }\n}\n\n/**\n * The catalogService provides the catalog API.\n *\n * @public\n */\nexport const catalogServiceRef = createServiceRef<CatalogService>({\n id: 'catalog-client',\n defaultFactory: async service =>\n createServiceFactory({\n service,\n deps: {\n auth: coreServices.auth,\n discoveryApi: coreServices.discovery,\n },\n async factory({ auth, discoveryApi }) {\n return new DefaultCatalogService({\n auth,\n catalogApi: new CatalogClient({ discoveryApi }),\n });\n },\n }),\n});\n"],"names":["createServiceRef","createServiceFactory","coreServices","CatalogClient"],"mappings":";;;;;AAiJA,MAAM,qBAAA,CAAgD;AAAA,EAC3C,KAAA;AAAA,EACA,WAAA;AAAA,EAET,WAAA,CAAY;AAAA,IACV,UAAA;AAAA,IACA;AAAA,GACF,EAGG;AACD,IAAA,IAAA,CAAK,WAAA,GAAc,UAAA;AACnB,IAAA,IAAA,CAAK,KAAA,GAAQ,IAAA;AAAA,EACf;AAAA,EAEA,MAAM,WAAA,CACJ,OAAA,EACA,OAAA,EAC8B;AAC9B,IAAA,OAAO,KAAK,WAAA,CAAY,WAAA;AAAA,MACtB,OAAA;AAAA,MACA,MAAM,IAAA,CAAK,WAAA,CAAY,OAAO;AAAA,KAChC;AAAA,EACF;AAAA,EAEA,MAAM,iBAAA,CACJ,OAAA,EACA,OAAA,EACoC;AACpC,IAAA,OAAO,KAAK,WAAA,CAAY,iBAAA;AAAA,MACtB,OAAA;AAAA,MACA,MAAM,IAAA,CAAK,WAAA,CAAY,OAAO;AAAA,KAChC;AAAA,EACF;AAAA,EAEA,MAAM,aAAA,CACJ,OAAA,EACA,OAAA,EACgC;AAChC,IAAA,OAAO,KAAK,WAAA,CAAY,aAAA;AAAA,MACtB,OAAA;AAAA,MACA,MAAM,IAAA,CAAK,WAAA,CAAY,OAAO;AAAA,KAChC;AAAA,EACF;AAAA,EAEA,MAAM,kBAAA,CACJ,OAAA,EACA,OAAA,EACqC;AACrC,IAAA,OAAO,KAAK,WAAA,CAAY,kBAAA;AAAA,MACtB,OAAA;AAAA,MACA,MAAM,IAAA,CAAK,WAAA,CAAY,OAAO;AAAA,KAChC;AAAA,EACF;AAAA,EAEA,MAAM,cAAA,CACJ,SAAA,EACA,OAAA,EAC6B;AAC7B,IAAA,OAAO,KAAK,WAAA,CAAY,cAAA;AAAA,MACtB,SAAA;AAAA,MACA,MAAM,IAAA,CAAK,WAAA,CAAY,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,IAAA;AAAA,MACnB,cAAcA,6BAAA,CAAa;AAAA,KAC7B;AAAA,IACA,MAAM,OAAA,CAAQ,EAAE,IAAA,EAAM,cAAa,EAAG;AACpC,MAAA,OAAO,IAAI,qBAAA,CAAsB;AAAA,QAC/B,IAAA;AAAA,QACA,UAAA,EAAY,IAAIC,2BAAA,CAAc,EAAE,cAAc;AAAA,OAC/C,CAAA;AAAA,IACH;AAAA,GACD;AACL,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"catalogService.cjs.js","sources":["../src/catalogService.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 AuthService,\n BackstageCredentials,\n coreServices,\n createServiceFactory,\n createServiceRef,\n} from '@backstage/backend-plugin-api';\nimport {\n AddLocationRequest,\n AddLocationResponse,\n CatalogApi,\n CatalogClient,\n CatalogRequestOptions,\n GetEntitiesByRefsRequest,\n GetEntitiesByRefsResponse,\n GetEntitiesRequest,\n GetEntitiesResponse,\n GetEntityAncestorsRequest,\n GetEntityAncestorsResponse,\n GetEntityFacetsRequest,\n GetEntityFacetsResponse,\n GetLocationsResponse,\n Location,\n QueryEntitiesRequest,\n QueryEntitiesResponse,\n StreamEntitiesRequest,\n ValidateEntityResponse,\n} from '@backstage/catalog-client';\nimport { CompoundEntityRef, Entity } from '@backstage/catalog-model';\nimport {\n AnalyzeLocationRequest,\n AnalyzeLocationResponse,\n} from '@backstage/plugin-catalog-common';\n\n/**\n * @public\n */\nexport interface CatalogServiceRequestOptions {\n credentials: BackstageCredentials;\n}\n\n/**\n * A version of the {@link @backstage/catalog-client#CatalogApi | CatalogApi} that\n * requires backend credentials to be passed instead of a token.\n *\n * @public\n */\nexport interface CatalogService {\n getEntities(\n request: GetEntitiesRequest | undefined,\n options: CatalogServiceRequestOptions,\n ): Promise<GetEntitiesResponse>;\n\n getEntitiesByRefs(\n request: GetEntitiesByRefsRequest,\n options: CatalogServiceRequestOptions,\n ): Promise<GetEntitiesByRefsResponse>;\n\n queryEntities(\n request: QueryEntitiesRequest | undefined,\n options: CatalogServiceRequestOptions,\n ): Promise<QueryEntitiesResponse>;\n\n getEntityAncestors(\n request: GetEntityAncestorsRequest,\n options: CatalogServiceRequestOptions,\n ): Promise<GetEntityAncestorsResponse>;\n\n getEntityByRef(\n entityRef: string | CompoundEntityRef,\n options: CatalogServiceRequestOptions,\n ): Promise<Entity | undefined>;\n\n removeEntityByUid(\n uid: string,\n options: CatalogServiceRequestOptions,\n ): Promise<void>;\n\n refreshEntity(\n entityRef: string,\n options: CatalogServiceRequestOptions,\n ): Promise<void>;\n\n getEntityFacets(\n request: GetEntityFacetsRequest,\n options: CatalogServiceRequestOptions,\n ): Promise<GetEntityFacetsResponse>;\n\n getLocations(\n request: {} | undefined,\n options: CatalogServiceRequestOptions,\n ): Promise<GetLocationsResponse>;\n\n getLocationById(\n id: string,\n options: CatalogServiceRequestOptions,\n ): Promise<Location | undefined>;\n\n getLocationByRef(\n locationRef: string,\n options: CatalogServiceRequestOptions,\n ): Promise<Location | undefined>;\n\n addLocation(\n location: AddLocationRequest,\n options: CatalogServiceRequestOptions,\n ): Promise<AddLocationResponse>;\n\n removeLocationById(\n id: string,\n options: CatalogServiceRequestOptions,\n ): Promise<void>;\n\n getLocationByEntity(\n entityRef: string | CompoundEntityRef,\n options: CatalogServiceRequestOptions,\n ): Promise<Location | undefined>;\n\n validateEntity(\n entity: Entity,\n locationRef: string,\n options: CatalogServiceRequestOptions,\n ): Promise<ValidateEntityResponse>;\n\n analyzeLocation(\n location: AnalyzeLocationRequest,\n options: CatalogServiceRequestOptions,\n ): Promise<AnalyzeLocationResponse>;\n\n streamEntities(\n request: StreamEntitiesRequest | undefined,\n options: CatalogServiceRequestOptions,\n ): AsyncIterable<Entity[]>;\n}\n\nclass DefaultCatalogService implements CatalogService {\n readonly #auth: AuthService;\n readonly #catalogApi: CatalogApi;\n\n constructor({\n catalogApi,\n auth,\n }: {\n catalogApi: CatalogApi;\n auth: AuthService;\n }) {\n this.#catalogApi = catalogApi;\n this.#auth = auth;\n }\n\n async getEntities(\n request: GetEntitiesRequest | undefined,\n options: CatalogServiceRequestOptions,\n ): Promise<GetEntitiesResponse> {\n return this.#catalogApi.getEntities(\n request,\n await this.#getOptions(options),\n );\n }\n\n async getEntitiesByRefs(\n request: GetEntitiesByRefsRequest,\n options: CatalogServiceRequestOptions,\n ): Promise<GetEntitiesByRefsResponse> {\n return this.#catalogApi.getEntitiesByRefs(\n request,\n await this.#getOptions(options),\n );\n }\n\n async queryEntities(\n request: QueryEntitiesRequest | undefined,\n options: CatalogServiceRequestOptions,\n ): Promise<QueryEntitiesResponse> {\n return this.#catalogApi.queryEntities(\n request,\n await this.#getOptions(options),\n );\n }\n\n async getEntityAncestors(\n request: GetEntityAncestorsRequest,\n options: CatalogServiceRequestOptions,\n ): Promise<GetEntityAncestorsResponse> {\n return this.#catalogApi.getEntityAncestors(\n request,\n await this.#getOptions(options),\n );\n }\n\n async getEntityByRef(\n entityRef: string | CompoundEntityRef,\n options: CatalogServiceRequestOptions,\n ): Promise<Entity | undefined> {\n return this.#catalogApi.getEntityByRef(\n entityRef,\n await this.#getOptions(options),\n );\n }\n\n async removeEntityByUid(\n uid: string,\n options: CatalogServiceRequestOptions,\n ): Promise<void> {\n return this.#catalogApi.removeEntityByUid(\n uid,\n await this.#getOptions(options),\n );\n }\n\n async refreshEntity(\n entityRef: string,\n options: CatalogServiceRequestOptions,\n ): Promise<void> {\n return this.#catalogApi.refreshEntity(\n entityRef,\n await this.#getOptions(options),\n );\n }\n\n async getEntityFacets(\n request: GetEntityFacetsRequest,\n options: CatalogServiceRequestOptions,\n ): Promise<GetEntityFacetsResponse> {\n return this.#catalogApi.getEntityFacets(\n request,\n await this.#getOptions(options),\n );\n }\n\n async getLocations(\n request: {} | undefined,\n options: CatalogServiceRequestOptions,\n ): Promise<GetLocationsResponse> {\n return this.#catalogApi.getLocations(\n request,\n await this.#getOptions(options),\n );\n }\n\n async getLocationById(\n id: string,\n options: CatalogServiceRequestOptions,\n ): Promise<Location | undefined> {\n return this.#catalogApi.getLocationById(\n id,\n await this.#getOptions(options),\n );\n }\n\n async getLocationByRef(\n locationRef: string,\n options: CatalogServiceRequestOptions,\n ): Promise<Location | undefined> {\n return this.#catalogApi.getLocationByRef(\n locationRef,\n await this.#getOptions(options),\n );\n }\n\n async addLocation(\n location: AddLocationRequest,\n options: CatalogServiceRequestOptions,\n ): Promise<AddLocationResponse> {\n return this.#catalogApi.addLocation(\n location,\n await this.#getOptions(options),\n );\n }\n\n async removeLocationById(\n id: string,\n options: CatalogServiceRequestOptions,\n ): Promise<void> {\n return this.#catalogApi.removeLocationById(\n id,\n await this.#getOptions(options),\n );\n }\n\n async getLocationByEntity(\n entityRef: string | CompoundEntityRef,\n options: CatalogServiceRequestOptions,\n ): Promise<Location | undefined> {\n return this.#catalogApi.getLocationByEntity(\n entityRef,\n await this.#getOptions(options),\n );\n }\n\n async validateEntity(\n entity: Entity,\n locationRef: string,\n options: CatalogServiceRequestOptions,\n ): Promise<ValidateEntityResponse> {\n return this.#catalogApi.validateEntity(\n entity,\n locationRef,\n await this.#getOptions(options),\n );\n }\n\n async analyzeLocation(\n location: AnalyzeLocationRequest,\n options: CatalogServiceRequestOptions,\n ): Promise<AnalyzeLocationResponse> {\n return this.#catalogApi.analyzeLocation(\n location,\n await this.#getOptions(options),\n );\n }\n\n async *streamEntities(\n request: StreamEntitiesRequest | undefined,\n options: CatalogServiceRequestOptions,\n ): AsyncIterable<Entity[]> {\n yield* this.#catalogApi.streamEntities(\n request,\n await this.#getOptions(options),\n );\n }\n\n async #getOptions(\n options: CatalogServiceRequestOptions,\n ): Promise<CatalogRequestOptions> {\n return this.#auth.getPluginRequestToken({\n onBehalfOf: options.credentials,\n targetPluginId: 'catalog',\n });\n }\n}\n\n/**\n * The catalogService provides the catalog API.\n *\n * @public\n */\nexport const catalogServiceRef = createServiceRef<CatalogService>({\n id: 'catalog-client',\n defaultFactory: async service =>\n createServiceFactory({\n service,\n deps: {\n auth: coreServices.auth,\n discoveryApi: coreServices.discovery,\n },\n async factory({ auth, discoveryApi }) {\n return new DefaultCatalogService({\n auth,\n catalogApi: new CatalogClient({ discoveryApi }),\n });\n },\n }),\n});\n"],"names":["createServiceRef","createServiceFactory","coreServices","CatalogClient"],"mappings":";;;;;AAuJA,MAAM,qBAAA,CAAgD;AAAA,EAC3C,KAAA;AAAA,EACA,WAAA;AAAA,EAET,WAAA,CAAY;AAAA,IACV,UAAA;AAAA,IACA;AAAA,GACF,EAGG;AACD,IAAA,IAAA,CAAK,WAAA,GAAc,UAAA;AACnB,IAAA,IAAA,CAAK,KAAA,GAAQ,IAAA;AAAA,EACf;AAAA,EAEA,MAAM,WAAA,CACJ,OAAA,EACA,OAAA,EAC8B;AAC9B,IAAA,OAAO,KAAK,WAAA,CAAY,WAAA;AAAA,MACtB,OAAA;AAAA,MACA,MAAM,IAAA,CAAK,WAAA,CAAY,OAAO;AAAA,KAChC;AAAA,EACF;AAAA,EAEA,MAAM,iBAAA,CACJ,OAAA,EACA,OAAA,EACoC;AACpC,IAAA,OAAO,KAAK,WAAA,CAAY,iBAAA;AAAA,MACtB,OAAA;AAAA,MACA,MAAM,IAAA,CAAK,WAAA,CAAY,OAAO;AAAA,KAChC;AAAA,EACF;AAAA,EAEA,MAAM,aAAA,CACJ,OAAA,EACA,OAAA,EACgC;AAChC,IAAA,OAAO,KAAK,WAAA,CAAY,aAAA;AAAA,MACtB,OAAA;AAAA,MACA,MAAM,IAAA,CAAK,WAAA,CAAY,OAAO;AAAA,KAChC;AAAA,EACF;AAAA,EAE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B;AACzB,IAAA,OAAO,KAAK,WAAA,CAAY,cAAA;AAAA,MACtB,OAAA;AAAA,MACA,MAAM,IAAA,CAAK,WAAA,CAAY,OAAO;AAAA,KAChC;AAAA,EACF;AAAA,EAEA,MAAM,YACJ,OAAA,EACgC;AAChC,IAAA,OAAO,IAAA,CAAK,MAAM,qBAAA,CAAsB;AAAA,MACtC,YAAY,OAAA,CAAQ,WAAA;AAAA,MACpB,cAAA,EAAgB;AAAA,KACjB,CAAA;AAAA,EACH;AACF;AAOO,MAAM,oBAAoBA,iCAAA,CAAiC;AAAA,EAChE,EAAA,EAAI,gBAAA;AAAA,EACJ,cAAA,EAAgB,OAAM,OAAA,KACpBC,qCAAA,CAAqB;AAAA,IACnB,OAAA;AAAA,IACA,IAAA,EAAM;AAAA,MACJ,MAAMC,6BAAA,CAAa,IAAA;AAAA,MACnB,cAAcA,6BAAA,CAAa;AAAA,KAC7B;AAAA,IACA,MAAM,OAAA,CAAQ,EAAE,IAAA,EAAM,cAAa,EAAG;AACpC,MAAA,OAAO,IAAI,qBAAA,CAAsB;AAAA,QAC/B,IAAA;AAAA,QACA,UAAA,EAAY,IAAIC,2BAAA,CAAc,EAAE,cAAc;AAAA,OAC/C,CAAA;AAAA,IACH;AAAA,GACD;AACL,CAAC;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { JsonValue } from '@backstage/types';
|
|
|
3
3
|
import { LocationSpec as LocationSpec$1, AnalyzeLocationRequest, AnalyzeLocationResponse, AnalyzeLocationExistingEntity } from '@backstage/plugin-catalog-common';
|
|
4
4
|
import * as _backstage_backend_plugin_api from '@backstage/backend-plugin-api';
|
|
5
5
|
import { BackstageCredentials } from '@backstage/backend-plugin-api';
|
|
6
|
-
import { GetEntitiesRequest, GetEntitiesResponse, GetEntitiesByRefsRequest, GetEntitiesByRefsResponse, QueryEntitiesRequest, QueryEntitiesResponse, GetEntityAncestorsRequest, GetEntityAncestorsResponse, GetEntityFacetsRequest, GetEntityFacetsResponse, GetLocationsResponse, Location, AddLocationRequest, AddLocationResponse, ValidateEntityResponse } from '@backstage/catalog-client';
|
|
6
|
+
import { GetEntitiesRequest, GetEntitiesResponse, GetEntitiesByRefsRequest, GetEntitiesByRefsResponse, QueryEntitiesRequest, QueryEntitiesResponse, GetEntityAncestorsRequest, GetEntityAncestorsResponse, GetEntityFacetsRequest, GetEntityFacetsResponse, GetLocationsResponse, Location, AddLocationRequest, AddLocationResponse, ValidateEntityResponse, StreamEntitiesRequest } from '@backstage/catalog-client';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Holds the entity location information.
|
|
@@ -130,6 +130,13 @@ type CatalogProcessor = {
|
|
|
130
130
|
* @returns The same entity or a modified version of it
|
|
131
131
|
*/
|
|
132
132
|
postProcessEntity?(entity: Entity, location: LocationSpec$1, emit: CatalogProcessorEmit, cache: CatalogProcessorCache): Promise<Entity>;
|
|
133
|
+
/**
|
|
134
|
+
* Returns a processor priority, which is used to determine the order in which
|
|
135
|
+
* processors are run. The default priority is 20, and lower value means
|
|
136
|
+
* that the processor runs earlier.
|
|
137
|
+
* @returns A number representing the priority of the processor.
|
|
138
|
+
*/
|
|
139
|
+
getPriority?(): number;
|
|
133
140
|
};
|
|
134
141
|
/**
|
|
135
142
|
* A parser, that is able to take the raw catalog descriptor data and turn it
|
|
@@ -423,6 +430,7 @@ interface CatalogService {
|
|
|
423
430
|
getLocationByEntity(entityRef: string | CompoundEntityRef, options: CatalogServiceRequestOptions): Promise<Location | undefined>;
|
|
424
431
|
validateEntity(entity: Entity, locationRef: string, options: CatalogServiceRequestOptions): Promise<ValidateEntityResponse>;
|
|
425
432
|
analyzeLocation(location: AnalyzeLocationRequest, options: CatalogServiceRequestOptions): Promise<AnalyzeLocationResponse>;
|
|
433
|
+
streamEntities(request: StreamEntitiesRequest | undefined, options: CatalogServiceRequestOptions): AsyncIterable<Entity[]>;
|
|
426
434
|
}
|
|
427
435
|
/**
|
|
428
436
|
* The catalogService provides the catalog API.
|
|
@@ -50,7 +50,8 @@ function catalogServiceMock(options) {
|
|
|
50
50
|
removeLocationById: jest.fn(),
|
|
51
51
|
getLocationByEntity: jest.fn(),
|
|
52
52
|
validateEntity: jest.fn(),
|
|
53
|
-
analyzeLocation: jest.fn()
|
|
53
|
+
analyzeLocation: jest.fn(),
|
|
54
|
+
streamEntities: jest.fn()
|
|
54
55
|
}));
|
|
55
56
|
})(catalogServiceMock || (catalogServiceMock = {}));
|
|
56
57
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"catalogServiceMock.cjs.js","sources":["../../src/testUtils/catalogServiceMock.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 {\n
|
|
1
|
+
{"version":3,"file":"catalogServiceMock.cjs.js","sources":["../../src/testUtils/catalogServiceMock.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 {\n createServiceFactory,\n ServiceFactory,\n ServiceRef,\n} from '@backstage/backend-plugin-api';\nimport { InMemoryCatalogClient } from '@backstage/catalog-client/testUtils';\nimport { Entity } from '@backstage/catalog-model';\nimport { catalogServiceRef } from '@backstage/plugin-catalog-node';\n// eslint-disable-next-line @backstage/no-undeclared-imports\nimport { ServiceMock } from '@backstage/backend-test-utils';\nimport { CatalogServiceMock } from './types';\n\n/** @internal */\nfunction simpleMock<TService>(\n ref: ServiceRef<TService, any>,\n mockFactory: () => jest.Mocked<TService>,\n): (partialImpl?: Partial<TService>) => ServiceMock<TService> {\n return partialImpl => {\n const mock = mockFactory();\n if (partialImpl) {\n for (const [key, impl] of Object.entries(partialImpl)) {\n if (typeof impl === 'function') {\n (mock as any)[key].mockImplementation(impl);\n } else {\n (mock as any)[key] = impl;\n }\n }\n }\n return Object.assign(mock, {\n factory: createServiceFactory({\n service: ref,\n deps: {},\n factory: () => mock,\n }),\n }) as ServiceMock<TService>;\n };\n}\n\n/**\n * Creates a fake catalog client that handles entities in memory storage. Note\n * that this client may be severely limited in functionality, and advanced\n * functions may not be available at all.\n *\n * @public\n */\nexport function catalogServiceMock(options?: {\n entities?: Entity[];\n}): CatalogServiceMock {\n return new InMemoryCatalogClient(options);\n}\n\n/**\n * A collection of mock functionality for the catalog service.\n *\n * @public\n */\nexport namespace catalogServiceMock {\n /**\n * Creates a fake catalog client that handles entities in memory storage. Note\n * that this client may be severely limited in functionality, and advanced\n * functions may not be available at all.\n */\n export const factory = (options?: { entities?: Entity[] }) =>\n createServiceFactory({\n service: catalogServiceRef,\n deps: {},\n factory: () => new InMemoryCatalogClient(options),\n }) as ServiceFactory<CatalogServiceMock, 'plugin', 'singleton'>;\n /**\n * Creates a catalog client whose methods are mock functions, possibly with\n * some of them overloaded by the caller.\n */\n export const mock = simpleMock<CatalogServiceMock>(catalogServiceRef, () => ({\n getEntities: jest.fn(),\n getEntitiesByRefs: jest.fn(),\n queryEntities: jest.fn(),\n getEntityAncestors: jest.fn(),\n getEntityByRef: jest.fn(),\n removeEntityByUid: jest.fn(),\n refreshEntity: jest.fn(),\n getEntityFacets: jest.fn(),\n getLocations: jest.fn(),\n getLocationById: jest.fn(),\n getLocationByRef: jest.fn(),\n addLocation: jest.fn(),\n removeLocationById: jest.fn(),\n getLocationByEntity: jest.fn(),\n validateEntity: jest.fn(),\n analyzeLocation: jest.fn(),\n streamEntities: jest.fn(),\n }));\n}\n"],"names":["createServiceFactory","InMemoryCatalogClient","catalogServiceMock","catalogServiceRef"],"mappings":";;;;;;AA6BA,SAAS,UAAA,CACP,KACA,WAAA,EAC4D;AAC5D,EAAA,OAAO,CAAA,WAAA,KAAe;AACpB,IAAA,MAAM,OAAO,WAAA,EAAY;AACzB,IAAA,IAAI,WAAA,EAAa;AACf,MAAA,KAAA,MAAW,CAAC,GAAA,EAAK,IAAI,KAAK,MAAA,CAAO,OAAA,CAAQ,WAAW,CAAA,EAAG;AACrD,QAAA,IAAI,OAAO,SAAS,UAAA,EAAY;AAC9B,UAAC,IAAA,CAAa,GAAG,CAAA,CAAE,kBAAA,CAAmB,IAAI,CAAA;AAAA,QAC5C,CAAA,MAAO;AACL,UAAC,IAAA,CAAa,GAAG,CAAA,GAAI,IAAA;AAAA,QACvB;AAAA,MACF;AAAA,IACF;AACA,IAAA,OAAO,MAAA,CAAO,OAAO,IAAA,EAAM;AAAA,MACzB,SAASA,qCAAA,CAAqB;AAAA,QAC5B,OAAA,EAAS,GAAA;AAAA,QACT,MAAM,EAAC;AAAA,QACP,SAAS,MAAM;AAAA,OAChB;AAAA,KACF,CAAA;AAAA,EACH,CAAA;AACF;AASO,SAAS,mBAAmB,OAAA,EAEZ;AACrB,EAAA,OAAO,IAAIC,gCAAsB,OAAO,CAAA;AAC1C;AAAA,CAOO,CAAUC,mBAAAA,KAAV;AAME,EAAMA,mBAAAA,CAAA,OAAA,GAAU,CAAC,OAAA,KACtBF,qCAAA,CAAqB;AAAA,IACnB,OAAA,EAASG,mCAAA;AAAA,IACT,MAAM,EAAC;AAAA,IACP,OAAA,EAAS,MAAM,IAAIF,+BAAA,CAAsB,OAAO;AAAA,GACjD,CAAA;AAKI,EAAMC,mBAAAA,CAAA,IAAA,GAAO,UAAA,CAA+BC,mCAAA,EAAmB,OAAO;AAAA,IAC3E,WAAA,EAAa,KAAK,EAAA,EAAG;AAAA,IACrB,iBAAA,EAAmB,KAAK,EAAA,EAAG;AAAA,IAC3B,aAAA,EAAe,KAAK,EAAA,EAAG;AAAA,IACvB,kBAAA,EAAoB,KAAK,EAAA,EAAG;AAAA,IAC5B,cAAA,EAAgB,KAAK,EAAA,EAAG;AAAA,IACxB,iBAAA,EAAmB,KAAK,EAAA,EAAG;AAAA,IAC3B,aAAA,EAAe,KAAK,EAAA,EAAG;AAAA,IACvB,eAAA,EAAiB,KAAK,EAAA,EAAG;AAAA,IACzB,YAAA,EAAc,KAAK,EAAA,EAAG;AAAA,IACtB,eAAA,EAAiB,KAAK,EAAA,EAAG;AAAA,IACzB,gBAAA,EAAkB,KAAK,EAAA,EAAG;AAAA,IAC1B,WAAA,EAAa,KAAK,EAAA,EAAG;AAAA,IACrB,kBAAA,EAAoB,KAAK,EAAA,EAAG;AAAA,IAC5B,mBAAA,EAAqB,KAAK,EAAA,EAAG;AAAA,IAC7B,cAAA,EAAgB,KAAK,EAAA,EAAG;AAAA,IACxB,eAAA,EAAiB,KAAK,EAAA,EAAG;AAAA,IACzB,cAAA,EAAgB,KAAK,EAAA;AAAG,GAC1B,CAAE,CAAA;AAAA,CAAA,EAlCa,kBAAA,KAAA,kBAAA,GAAA,EAAA,CAAA,CAAA;;;;"}
|
package/dist/testUtils.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ServiceFactory } from '@backstage/backend-plugin-api';
|
|
2
2
|
import { CompoundEntityRef, Entity } from '@backstage/catalog-model';
|
|
3
3
|
import { ServiceMock } from '@backstage/backend-test-utils';
|
|
4
|
-
import { CatalogApi, GetEntitiesRequest, CatalogRequestOptions, GetEntitiesResponse, GetEntitiesByRefsRequest, GetEntitiesByRefsResponse, QueryEntitiesRequest, QueryEntitiesResponse, GetEntityAncestorsRequest, GetEntityAncestorsResponse, GetEntityFacetsRequest, GetEntityFacetsResponse, GetLocationsResponse, Location, AddLocationRequest, AddLocationResponse, ValidateEntityResponse } from '@backstage/catalog-client';
|
|
4
|
+
import { CatalogApi, GetEntitiesRequest, CatalogRequestOptions, GetEntitiesResponse, GetEntitiesByRefsRequest, GetEntitiesByRefsResponse, QueryEntitiesRequest, QueryEntitiesResponse, GetEntityAncestorsRequest, GetEntityAncestorsResponse, GetEntityFacetsRequest, GetEntityFacetsResponse, GetLocationsResponse, Location, AddLocationRequest, AddLocationResponse, ValidateEntityResponse, StreamEntitiesRequest } from '@backstage/catalog-client';
|
|
5
5
|
import { AnalyzeLocationRequest, AnalyzeLocationResponse } from '@backstage/plugin-catalog-common';
|
|
6
6
|
import { CatalogService, CatalogServiceRequestOptions } from '@backstage/plugin-catalog-node';
|
|
7
7
|
|
|
@@ -33,6 +33,7 @@ interface CatalogServiceMock extends CatalogService, CatalogApi {
|
|
|
33
33
|
getLocationByEntity(entityRef: string | CompoundEntityRef, options?: CatalogServiceRequestOptions | CatalogRequestOptions): Promise<Location | undefined>;
|
|
34
34
|
validateEntity(entity: Entity, locationRef: string, options?: CatalogServiceRequestOptions | CatalogRequestOptions): Promise<ValidateEntityResponse>;
|
|
35
35
|
analyzeLocation(location: AnalyzeLocationRequest, options?: CatalogServiceRequestOptions | CatalogRequestOptions): Promise<AnalyzeLocationResponse>;
|
|
36
|
+
streamEntities(request?: StreamEntitiesRequest, options?: CatalogServiceRequestOptions | CatalogRequestOptions): AsyncIterable<Entity[]>;
|
|
36
37
|
}
|
|
37
38
|
|
|
38
39
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-catalog-node",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.19.0",
|
|
4
4
|
"description": "The plugin-catalog-node module for @backstage/plugin-catalog-backend",
|
|
5
5
|
"backstage": {
|
|
6
6
|
"role": "node-library",
|
|
@@ -72,20 +72,20 @@
|
|
|
72
72
|
"test": "backstage-cli package test"
|
|
73
73
|
},
|
|
74
74
|
"dependencies": {
|
|
75
|
-
"@backstage/backend-plugin-api": "1.4.3
|
|
76
|
-
"@backstage/catalog-client": "1.
|
|
77
|
-
"@backstage/catalog-model": "1.7.5",
|
|
78
|
-
"@backstage/errors": "1.2.7",
|
|
79
|
-
"@backstage/plugin-catalog-common": "1.1.5",
|
|
80
|
-
"@backstage/plugin-permission-common": "0.9.1",
|
|
81
|
-
"@backstage/plugin-permission-node": "0.10.4
|
|
82
|
-
"@backstage/types": "1.2.
|
|
75
|
+
"@backstage/backend-plugin-api": "^1.4.3",
|
|
76
|
+
"@backstage/catalog-client": "^1.12.0",
|
|
77
|
+
"@backstage/catalog-model": "^1.7.5",
|
|
78
|
+
"@backstage/errors": "^1.2.7",
|
|
79
|
+
"@backstage/plugin-catalog-common": "^1.1.5",
|
|
80
|
+
"@backstage/plugin-permission-common": "^0.9.1",
|
|
81
|
+
"@backstage/plugin-permission-node": "^0.10.4",
|
|
82
|
+
"@backstage/types": "^1.2.2",
|
|
83
83
|
"lodash": "^4.17.21",
|
|
84
84
|
"yaml": "^2.0.0"
|
|
85
85
|
},
|
|
86
86
|
"devDependencies": {
|
|
87
|
-
"@backstage/backend-test-utils": "1.9.0
|
|
88
|
-
"@backstage/cli": "0.34.2
|
|
87
|
+
"@backstage/backend-test-utils": "^1.9.0",
|
|
88
|
+
"@backstage/cli": "^0.34.2",
|
|
89
89
|
"msw": "^1.0.0"
|
|
90
90
|
}
|
|
91
91
|
}
|