@backstage/plugin-catalog-node 2.0.0-next.1 → 2.0.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 +29 -0
- package/dist/alpha.cjs.js +2 -0
- package/dist/alpha.cjs.js.map +1 -1
- package/dist/alpha.d.ts +169 -2
- package/dist/catalogService.cjs.js +12 -0
- package/dist/catalogService.cjs.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/scmEvents/DefaultCatalogScmEventsService.cjs.js +29 -0
- package/dist/scmEvents/DefaultCatalogScmEventsService.cjs.js.map +1 -0
- package/dist/scmEvents/catalogScmEventsServiceRef.cjs.js +21 -0
- package/dist/scmEvents/catalogScmEventsServiceRef.cjs.js.map +1 -0
- package/dist/testUtils/catalogServiceMock.cjs.js +2 -0
- package/dist/testUtils/catalogServiceMock.cjs.js.map +1 -1
- package/dist/testUtils.d.ts +3 -1
- package/package.json +15 -15
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
# @backstage/plugin-catalog-node
|
|
2
2
|
|
|
3
|
+
## 2.0.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- cfd8103: Promoted stable catalog extension points from alpha to main export. The following extension points are now exported from `@backstage/plugin-catalog-node` instead of `@backstage/plugin-catalog-node/alpha`:
|
|
8
|
+
|
|
9
|
+
- `catalogLocationsExtensionPoint` and `CatalogLocationsExtensionPoint`
|
|
10
|
+
- `catalogProcessingExtensionPoint` and `CatalogProcessingExtensionPoint`
|
|
11
|
+
- `catalogAnalysisExtensionPoint` and `CatalogAnalysisExtensionPoint`
|
|
12
|
+
|
|
13
|
+
The old alpha exports for these extension points are now deprecated with `@deprecated` markers pointing to the new stable exports. Please update your imports from `@backstage/plugin-catalog-node/alpha` to `@backstage/plugin-catalog-node`.
|
|
14
|
+
|
|
15
|
+
Note: The `catalogModelExtensionPoint`, `catalogPermissionExtensionPoint`, and related types remain in alpha.
|
|
16
|
+
|
|
17
|
+
- b4e8249: Implemented support for the new `queryLocations` and `streamLocations` that allow paginated/streamed and filtered location queries
|
|
18
|
+
- 34cc520: Introduced the `catalogScmEventsServiceRef`, along with `CatalogScmEventsService` and associated types. These allow communicating a unified set of events, that parts of the catalog can react to.
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- 42abfb1: Updated `catalogServiceMock.mock` to use `createServiceMock` from `@backstage/backend-test-utils`, replacing the internal copy of `simpleMock`. Added `@backstage/backend-test-utils` as an optional peer dependency.
|
|
23
|
+
- 7455dae: Use node prefix on native imports
|
|
24
|
+
- Updated dependencies
|
|
25
|
+
- @backstage/backend-test-utils@1.11.0
|
|
26
|
+
- @backstage/backend-plugin-api@1.7.0
|
|
27
|
+
- @backstage/catalog-client@1.13.0
|
|
28
|
+
- @backstage/plugin-permission-common@0.9.6
|
|
29
|
+
- @backstage/plugin-permission-node@0.10.10
|
|
30
|
+
- @backstage/plugin-catalog-common@1.1.8
|
|
31
|
+
|
|
3
32
|
## 2.0.0-next.1
|
|
4
33
|
|
|
5
34
|
### Patch Changes
|
package/dist/alpha.cjs.js
CHANGED
|
@@ -6,6 +6,7 @@ var alpha = require('@backstage/plugin-catalog-common/alpha');
|
|
|
6
6
|
var pluginPermissionNode = require('@backstage/plugin-permission-node');
|
|
7
7
|
var pluginCatalogNode = require('@backstage/plugin-catalog-node');
|
|
8
8
|
var extensions = require('./extensions.cjs.js');
|
|
9
|
+
var catalogScmEventsServiceRef = require('./scmEvents/catalogScmEventsServiceRef.cjs.js');
|
|
9
10
|
|
|
10
11
|
const catalogEntityPermissionResourceRef = pluginPermissionNode.createPermissionResourceRef().with({
|
|
11
12
|
pluginId: "catalog",
|
|
@@ -29,6 +30,7 @@ const catalogAnalysisExtensionPoint = pluginCatalogNode.catalogAnalysisExtension
|
|
|
29
30
|
|
|
30
31
|
exports.catalogModelExtensionPoint = extensions.catalogModelExtensionPoint;
|
|
31
32
|
exports.catalogPermissionExtensionPoint = extensions.catalogPermissionExtensionPoint;
|
|
33
|
+
exports.catalogScmEventsServiceRef = catalogScmEventsServiceRef.catalogScmEventsServiceRef;
|
|
32
34
|
exports.catalogAnalysisExtensionPoint = catalogAnalysisExtensionPoint;
|
|
33
35
|
exports.catalogEntityPermissionResourceRef = catalogEntityPermissionResourceRef;
|
|
34
36
|
exports.catalogLocationsExtensionPoint = catalogLocationsExtensionPoint;
|
package/dist/alpha.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alpha.cjs.js","sources":["../src/alpha.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 {\n coreServices,\n createServiceFactory,\n createServiceRef,\n} from '@backstage/backend-plugin-api';\nimport { catalogServiceRef as _catalogServiceRef } from './catalogService';\nimport { CatalogApi, CatalogClient } from '@backstage/catalog-client';\nimport { RESOURCE_TYPE_CATALOG_ENTITY } from '@backstage/plugin-catalog-common/alpha';\nimport { createPermissionResourceRef } from '@backstage/plugin-permission-node';\nimport { Entity } from '@backstage/catalog-model';\nimport { EntitiesSearchFilter } from '@backstage/plugin-catalog-node';\n\n/** @alpha */\nexport const catalogEntityPermissionResourceRef = createPermissionResourceRef<\n Entity,\n EntitiesSearchFilter\n>().with({\n pluginId: 'catalog',\n resourceType: RESOURCE_TYPE_CATALOG_ENTITY,\n});\n\n/**\n * @alpha\n * @deprecated Use {@link @backstage/plugin-catalog-node#catalogServiceRef} instead\n */\nexport const catalogServiceRef = createServiceRef<CatalogApi>({\n id: 'catalog-client-legacy',\n defaultFactory: async service =>\n createServiceFactory({\n service,\n deps: {\n discoveryApi: coreServices.discovery,\n },\n async factory({ discoveryApi }) {\n return new CatalogClient({ discoveryApi });\n },\n }),\n});\n\nimport {\n CatalogLocationsExtensionPoint as _CatalogLocationsExtensionPoint,\n CatalogProcessingExtensionPoint as _CatalogProcessingExtensionPoint,\n CatalogAnalysisExtensionPoint as _CatalogAnalysisExtensionPoint,\n catalogLocationsExtensionPoint as _catalogLocationsExtensionPoint,\n catalogProcessingExtensionPoint as _catalogProcessingExtensionPoint,\n catalogAnalysisExtensionPoint as _catalogAnalysisExtensionPoint,\n} from '@backstage/plugin-catalog-node';\n\n/**\n * @alpha\n * @deprecated Use {@link @backstage/plugin-catalog-node#CatalogLocationsExtensionPoint} instead\n */\nexport type CatalogLocationsExtensionPoint = _CatalogLocationsExtensionPoint;\n\n/**\n * @alpha\n * @deprecated Use {@link @backstage/plugin-catalog-node#catalogLocationsExtensionPoint} instead\n */\nexport const catalogLocationsExtensionPoint = _catalogLocationsExtensionPoint;\n\n/**\n * @alpha\n * @deprecated Use {@link @backstage/plugin-catalog-node#CatalogProcessingExtensionPoint} instead\n */\nexport type CatalogProcessingExtensionPoint = _CatalogProcessingExtensionPoint;\n\n/**\n * @alpha\n * @deprecated Use {@link @backstage/plugin-catalog-node#catalogProcessingExtensionPoint} instead\n */\nexport const catalogProcessingExtensionPoint = _catalogProcessingExtensionPoint;\n\n/**\n * @alpha\n * @deprecated Use {@link @backstage/plugin-catalog-node#CatalogAnalysisExtensionPoint} instead\n */\nexport type CatalogAnalysisExtensionPoint = _CatalogAnalysisExtensionPoint;\n\n/**\n * @alpha\n * @deprecated Use {@link @backstage/plugin-catalog-node#catalogAnalysisExtensionPoint} instead\n */\nexport const catalogAnalysisExtensionPoint = _catalogAnalysisExtensionPoint;\n\nexport type { CatalogModelExtensionPoint } from './extensions';\nexport { catalogModelExtensionPoint } from './extensions';\nexport type { CatalogPermissionRuleInput } from './extensions';\nexport type { CatalogPermissionExtensionPoint } from './extensions';\nexport { catalogPermissionExtensionPoint } from './extensions';\n"],"names":["createPermissionResourceRef","RESOURCE_TYPE_CATALOG_ENTITY","createServiceRef","createServiceFactory","coreServices","CatalogClient","_catalogLocationsExtensionPoint","_catalogProcessingExtensionPoint","_catalogAnalysisExtensionPoint"],"mappings":"
|
|
1
|
+
{"version":3,"file":"alpha.cjs.js","sources":["../src/alpha.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 {\n coreServices,\n createServiceFactory,\n createServiceRef,\n} from '@backstage/backend-plugin-api';\nimport { catalogServiceRef as _catalogServiceRef } from './catalogService';\nimport { CatalogApi, CatalogClient } from '@backstage/catalog-client';\nimport { RESOURCE_TYPE_CATALOG_ENTITY } from '@backstage/plugin-catalog-common/alpha';\nimport { createPermissionResourceRef } from '@backstage/plugin-permission-node';\nimport { Entity } from '@backstage/catalog-model';\nimport { EntitiesSearchFilter } from '@backstage/plugin-catalog-node';\n\n/** @alpha */\nexport const catalogEntityPermissionResourceRef = createPermissionResourceRef<\n Entity,\n EntitiesSearchFilter\n>().with({\n pluginId: 'catalog',\n resourceType: RESOURCE_TYPE_CATALOG_ENTITY,\n});\n\n/**\n * @alpha\n * @deprecated Use {@link @backstage/plugin-catalog-node#catalogServiceRef} instead\n */\nexport const catalogServiceRef = createServiceRef<CatalogApi>({\n id: 'catalog-client-legacy',\n defaultFactory: async service =>\n createServiceFactory({\n service,\n deps: {\n discoveryApi: coreServices.discovery,\n },\n async factory({ discoveryApi }) {\n return new CatalogClient({ discoveryApi });\n },\n }),\n});\n\nimport {\n CatalogLocationsExtensionPoint as _CatalogLocationsExtensionPoint,\n CatalogProcessingExtensionPoint as _CatalogProcessingExtensionPoint,\n CatalogAnalysisExtensionPoint as _CatalogAnalysisExtensionPoint,\n catalogLocationsExtensionPoint as _catalogLocationsExtensionPoint,\n catalogProcessingExtensionPoint as _catalogProcessingExtensionPoint,\n catalogAnalysisExtensionPoint as _catalogAnalysisExtensionPoint,\n} from '@backstage/plugin-catalog-node';\n\n/**\n * @alpha\n * @deprecated Use {@link @backstage/plugin-catalog-node#CatalogLocationsExtensionPoint} instead\n */\nexport type CatalogLocationsExtensionPoint = _CatalogLocationsExtensionPoint;\n\n/**\n * @alpha\n * @deprecated Use {@link @backstage/plugin-catalog-node#catalogLocationsExtensionPoint} instead\n */\nexport const catalogLocationsExtensionPoint = _catalogLocationsExtensionPoint;\n\n/**\n * @alpha\n * @deprecated Use {@link @backstage/plugin-catalog-node#CatalogProcessingExtensionPoint} instead\n */\nexport type CatalogProcessingExtensionPoint = _CatalogProcessingExtensionPoint;\n\n/**\n * @alpha\n * @deprecated Use {@link @backstage/plugin-catalog-node#catalogProcessingExtensionPoint} instead\n */\nexport const catalogProcessingExtensionPoint = _catalogProcessingExtensionPoint;\n\n/**\n * @alpha\n * @deprecated Use {@link @backstage/plugin-catalog-node#CatalogAnalysisExtensionPoint} instead\n */\nexport type CatalogAnalysisExtensionPoint = _CatalogAnalysisExtensionPoint;\n\n/**\n * @alpha\n * @deprecated Use {@link @backstage/plugin-catalog-node#catalogAnalysisExtensionPoint} instead\n */\nexport const catalogAnalysisExtensionPoint = _catalogAnalysisExtensionPoint;\n\nexport type { CatalogModelExtensionPoint } from './extensions';\nexport { catalogModelExtensionPoint } from './extensions';\nexport type { CatalogPermissionRuleInput } from './extensions';\nexport type { CatalogPermissionExtensionPoint } from './extensions';\nexport { catalogPermissionExtensionPoint } from './extensions';\n\nexport * from './scmEvents';\n"],"names":["createPermissionResourceRef","RESOURCE_TYPE_CATALOG_ENTITY","createServiceRef","createServiceFactory","coreServices","CatalogClient","_catalogLocationsExtensionPoint","_catalogProcessingExtensionPoint","_catalogAnalysisExtensionPoint"],"mappings":";;;;;;;;;;AA6BO,MAAM,kCAAA,GAAqCA,gDAAA,EAGhD,CAAE,IAAA,CAAK;AAAA,EACP,QAAA,EAAU,SAAA;AAAA,EACV,YAAA,EAAcC;AAChB,CAAC;AAMM,MAAM,oBAAoBC,iCAAA,CAA6B;AAAA,EAC5D,EAAA,EAAI,uBAAA;AAAA,EACJ,cAAA,EAAgB,OAAM,OAAA,KACpBC,qCAAA,CAAqB;AAAA,IACnB,OAAA;AAAA,IACA,IAAA,EAAM;AAAA,MACJ,cAAcC,6BAAA,CAAa;AAAA,KAC7B;AAAA,IACA,MAAM,OAAA,CAAQ,EAAE,YAAA,EAAa,EAAG;AAC9B,MAAA,OAAO,IAAIC,2BAAA,CAAc,EAAE,YAAA,EAAc,CAAA;AAAA,IAC3C;AAAA,GACD;AACL,CAAC;AAqBM,MAAM,8BAAA,GAAiCC;AAYvC,MAAM,+BAAA,GAAkCC;AAYxC,MAAM,6BAAA,GAAgCC;;;;;;;;;;;"}
|
package/dist/alpha.d.ts
CHANGED
|
@@ -6,6 +6,173 @@ import { EntitiesSearchFilter, CatalogLocationsExtensionPoint as CatalogLocation
|
|
|
6
6
|
export { f as CatalogModelExtensionPoint, i as CatalogPermissionExtensionPoint, h as CatalogPermissionRuleInput, g as catalogModelExtensionPoint, j as catalogPermissionExtensionPoint } from './types/extensions.d-Cvnx6_V0.js';
|
|
7
7
|
import '@backstage/plugin-permission-common';
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* A subscriber of the {@link CatalogScmEventsService}.
|
|
11
|
+
*
|
|
12
|
+
* @alpha
|
|
13
|
+
*/
|
|
14
|
+
interface CatalogScmEventsServiceSubscriber {
|
|
15
|
+
/**
|
|
16
|
+
* Receives a number of events.
|
|
17
|
+
*/
|
|
18
|
+
onEvents: (events: CatalogScmEvent[]) => Promise<void>;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* A publish/subscribe service for source control management system events. This
|
|
22
|
+
* allows different producers of interesting events in a multi-SCM environment
|
|
23
|
+
* communicate those events to multiple interested parties. As an example, one
|
|
24
|
+
* entity provider might automatically register and unregister locations as an
|
|
25
|
+
* effect of these events.
|
|
26
|
+
*
|
|
27
|
+
* @alpha
|
|
28
|
+
*/
|
|
29
|
+
interface CatalogScmEventsService {
|
|
30
|
+
/**
|
|
31
|
+
* Subscribes to events, and returns a function to unsubscribe.
|
|
32
|
+
*/
|
|
33
|
+
subscribe(subscriber: CatalogScmEventsServiceSubscriber): {
|
|
34
|
+
unsubscribe: () => void;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Publish an event to all subscribers.
|
|
38
|
+
*
|
|
39
|
+
* @remarks
|
|
40
|
+
*
|
|
41
|
+
* This call blocks until all subscribers have either acknowledged that they
|
|
42
|
+
* have received and handled the event, or thrown an error. There are no
|
|
43
|
+
* re-sends or dead letter queues; receivers must implement a suitable
|
|
44
|
+
* resilience model themselves internally if they want to have better delivery
|
|
45
|
+
* guarantees.
|
|
46
|
+
*/
|
|
47
|
+
publish(events: CatalogScmEvent[]): Promise<void>;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Voluntary contextual information related to a {@link CatalogScmEvent}.
|
|
51
|
+
*
|
|
52
|
+
* @alpha
|
|
53
|
+
*/
|
|
54
|
+
type CatalogScmEventContext = {
|
|
55
|
+
/**
|
|
56
|
+
* URL to a commit related to this event being generated, if relevant.
|
|
57
|
+
*/
|
|
58
|
+
commitUrl?: string;
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Represents a high level change event that happened in a source control
|
|
62
|
+
* management system. These are usually produced as a distilled version of an
|
|
63
|
+
* incoming webhook event or similar.
|
|
64
|
+
*
|
|
65
|
+
* @alpha
|
|
66
|
+
*/
|
|
67
|
+
type CatalogScmEvent = {
|
|
68
|
+
/**
|
|
69
|
+
* A new location was created.
|
|
70
|
+
*
|
|
71
|
+
* @remarks
|
|
72
|
+
*
|
|
73
|
+
* This typically means that an individual file was created in an existing
|
|
74
|
+
* repository, for example through a git push or merge.
|
|
75
|
+
*/
|
|
76
|
+
type: 'location.created';
|
|
77
|
+
url: string;
|
|
78
|
+
context?: CatalogScmEventContext;
|
|
79
|
+
} | {
|
|
80
|
+
/**
|
|
81
|
+
* An existing location was modified.
|
|
82
|
+
*
|
|
83
|
+
* @remarks
|
|
84
|
+
*
|
|
85
|
+
* This typically means that an individual file was modified in an existing
|
|
86
|
+
* repository, for example through a git push or merge.
|
|
87
|
+
*/
|
|
88
|
+
type: 'location.updated';
|
|
89
|
+
url: string;
|
|
90
|
+
context?: CatalogScmEventContext;
|
|
91
|
+
} | {
|
|
92
|
+
/**
|
|
93
|
+
* An existing location was deleted.
|
|
94
|
+
*
|
|
95
|
+
* @remarks
|
|
96
|
+
*
|
|
97
|
+
* This typically means that an individual file was deleted in an existing
|
|
98
|
+
* repository, for example through a git push or merge.
|
|
99
|
+
*/
|
|
100
|
+
type: 'location.deleted';
|
|
101
|
+
url: string;
|
|
102
|
+
context?: CatalogScmEventContext;
|
|
103
|
+
} | {
|
|
104
|
+
/**
|
|
105
|
+
* An existing location was moved from one place to another.
|
|
106
|
+
*
|
|
107
|
+
* @remarks
|
|
108
|
+
*
|
|
109
|
+
* This typically means that an individual file was moved or renamed, for
|
|
110
|
+
* example through a git push or merge. The URLs do not necessarily refer
|
|
111
|
+
* to the same repository before and after the move.
|
|
112
|
+
*/
|
|
113
|
+
type: 'location.moved';
|
|
114
|
+
fromUrl: string;
|
|
115
|
+
toUrl: string;
|
|
116
|
+
context?: CatalogScmEventContext;
|
|
117
|
+
} | {
|
|
118
|
+
/**
|
|
119
|
+
* A new repository was created.
|
|
120
|
+
*/
|
|
121
|
+
type: 'repository.created';
|
|
122
|
+
url: string;
|
|
123
|
+
context?: CatalogScmEventContext;
|
|
124
|
+
} | {
|
|
125
|
+
/**
|
|
126
|
+
* An existing repository was updated.
|
|
127
|
+
*
|
|
128
|
+
* @remarks
|
|
129
|
+
*
|
|
130
|
+
* This usually refers to some form of meta state change, such as it being
|
|
131
|
+
* made public or private, or its visibility being changed.
|
|
132
|
+
*/
|
|
133
|
+
type: 'repository.updated';
|
|
134
|
+
url: string;
|
|
135
|
+
context?: CatalogScmEventContext;
|
|
136
|
+
} | {
|
|
137
|
+
/**
|
|
138
|
+
* An existing repository was deleted.
|
|
139
|
+
*/
|
|
140
|
+
type: 'repository.deleted';
|
|
141
|
+
url: string;
|
|
142
|
+
context?: CatalogScmEventContext;
|
|
143
|
+
} | {
|
|
144
|
+
/**
|
|
145
|
+
* An existing repository was moved or in some other way had its effective
|
|
146
|
+
* base URL changed.
|
|
147
|
+
*
|
|
148
|
+
* @remarks
|
|
149
|
+
*
|
|
150
|
+
* This typically refers to a repository being renamed, or transferred to
|
|
151
|
+
* a different owner. It can also refer to a change of base branch, which
|
|
152
|
+
* effectively changes the base URL for many repository URL patterns.
|
|
153
|
+
*
|
|
154
|
+
* The source and target URLs do not necessarily end exactly on a
|
|
155
|
+
* repository, but MAY include additional path segments such as the branch
|
|
156
|
+
* name.
|
|
157
|
+
*/
|
|
158
|
+
type: 'repository.moved';
|
|
159
|
+
fromUrl: string;
|
|
160
|
+
toUrl: string;
|
|
161
|
+
context?: CatalogScmEventContext;
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* A service that allows publishing and subscribing to source control management
|
|
166
|
+
* system events.
|
|
167
|
+
*
|
|
168
|
+
* @alpha
|
|
169
|
+
* @remarks
|
|
170
|
+
*
|
|
171
|
+
* The default implementation of this service acts in-memory, which requires the
|
|
172
|
+
* producers and consumer (the catalog backend) to be deployed together.
|
|
173
|
+
*/
|
|
174
|
+
declare const catalogScmEventsServiceRef: _backstage_backend_plugin_api.ServiceRef<CatalogScmEventsService, "plugin", "singleton">;
|
|
175
|
+
|
|
9
176
|
/** @alpha */
|
|
10
177
|
declare const catalogEntityPermissionResourceRef: _backstage_plugin_permission_node.PermissionResourceRef<Entity, EntitiesSearchFilter, "catalog-entity", "catalog">;
|
|
11
178
|
/**
|
|
@@ -45,5 +212,5 @@ type CatalogAnalysisExtensionPoint = CatalogAnalysisExtensionPoint$1;
|
|
|
45
212
|
*/
|
|
46
213
|
declare const catalogAnalysisExtensionPoint: _backstage_backend_plugin_api.ExtensionPoint<CatalogAnalysisExtensionPoint$1>;
|
|
47
214
|
|
|
48
|
-
export { catalogAnalysisExtensionPoint, catalogEntityPermissionResourceRef, catalogLocationsExtensionPoint, catalogProcessingExtensionPoint, catalogServiceRef };
|
|
49
|
-
export type { CatalogAnalysisExtensionPoint, CatalogLocationsExtensionPoint, CatalogProcessingExtensionPoint };
|
|
215
|
+
export { catalogAnalysisExtensionPoint, catalogEntityPermissionResourceRef, catalogLocationsExtensionPoint, catalogProcessingExtensionPoint, catalogScmEventsServiceRef, catalogServiceRef };
|
|
216
|
+
export type { CatalogAnalysisExtensionPoint, CatalogLocationsExtensionPoint, CatalogProcessingExtensionPoint, CatalogScmEvent, CatalogScmEventContext, CatalogScmEventsService, CatalogScmEventsServiceSubscriber };
|
|
@@ -67,6 +67,18 @@ class DefaultCatalogService {
|
|
|
67
67
|
await this.#getOptions(options)
|
|
68
68
|
);
|
|
69
69
|
}
|
|
70
|
+
async queryLocations(request, options) {
|
|
71
|
+
return this.#catalogApi.queryLocations(
|
|
72
|
+
request,
|
|
73
|
+
await this.#getOptions(options)
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
async *streamLocations(request, options) {
|
|
77
|
+
yield* this.#catalogApi.streamLocations(
|
|
78
|
+
request,
|
|
79
|
+
await this.#getOptions(options)
|
|
80
|
+
);
|
|
81
|
+
}
|
|
70
82
|
async getLocationById(id, options) {
|
|
71
83
|
return this.#catalogApi.getLocationById(
|
|
72
84
|
id,
|
|
@@ -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 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,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,CA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AOO,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;;;;"}
|
|
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 QueryLocationsInitialRequest,\n QueryLocationsRequest,\n QueryLocationsResponse,\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 queryLocations(\n request: QueryLocationsRequest | undefined,\n options: CatalogServiceRequestOptions,\n ): Promise<QueryLocationsResponse>;\n\n streamLocations(\n request: QueryLocationsInitialRequest | undefined,\n options: CatalogServiceRequestOptions,\n ): AsyncIterable<Location[]>;\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 queryLocations(\n request: QueryLocationsRequest,\n options: CatalogServiceRequestOptions,\n ): Promise<QueryLocationsResponse> {\n return this.#catalogApi.queryLocations(\n request,\n await this.#getOptions(options),\n );\n }\n\n async *streamLocations(\n request: QueryLocationsInitialRequest | undefined,\n options: CatalogServiceRequestOptions,\n ): AsyncIterable<Location[]> {\n yield* this.#catalogApi.streamLocations(\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":";;;;;AAoKA,MAAM,qBAAA,CAAgD;AAAA,EAC3C,KAAA;AAAA,EACA,WAAA;AAAA,EAET,WAAA,CAAY;AAAA,IACV,UAAA;AAAA,IACA;AA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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, StreamEntitiesRequest } from '@backstage/catalog-client';
|
|
6
|
+
import { GetEntitiesRequest, GetEntitiesResponse, GetEntitiesByRefsRequest, GetEntitiesByRefsResponse, QueryEntitiesRequest, QueryEntitiesResponse, GetEntityAncestorsRequest, GetEntityAncestorsResponse, GetEntityFacetsRequest, GetEntityFacetsResponse, GetLocationsResponse, QueryLocationsRequest, QueryLocationsResponse, QueryLocationsInitialRequest, Location, AddLocationRequest, AddLocationResponse, ValidateEntityResponse, StreamEntitiesRequest } from '@backstage/catalog-client';
|
|
7
7
|
export { b as CatalogAnalysisExtensionPoint, C as CatalogLocationsExtensionPoint, a as CatalogProcessingExtensionPoint, e as catalogAnalysisExtensionPoint, c as catalogLocationsExtensionPoint, d as catalogProcessingExtensionPoint } from './types/extensions.d-Cvnx6_V0.js';
|
|
8
8
|
import '@backstage/plugin-catalog-node';
|
|
9
9
|
import '@backstage/plugin-permission-common';
|
|
@@ -435,6 +435,8 @@ interface CatalogService {
|
|
|
435
435
|
refreshEntity(entityRef: string, options: CatalogServiceRequestOptions): Promise<void>;
|
|
436
436
|
getEntityFacets(request: GetEntityFacetsRequest, options: CatalogServiceRequestOptions): Promise<GetEntityFacetsResponse>;
|
|
437
437
|
getLocations(request: {} | undefined, options: CatalogServiceRequestOptions): Promise<GetLocationsResponse>;
|
|
438
|
+
queryLocations(request: QueryLocationsRequest | undefined, options: CatalogServiceRequestOptions): Promise<QueryLocationsResponse>;
|
|
439
|
+
streamLocations(request: QueryLocationsInitialRequest | undefined, options: CatalogServiceRequestOptions): AsyncIterable<Location[]>;
|
|
438
440
|
getLocationById(id: string, options: CatalogServiceRequestOptions): Promise<Location | undefined>;
|
|
439
441
|
getLocationByRef(locationRef: string, options: CatalogServiceRequestOptions): Promise<Location | undefined>;
|
|
440
442
|
addLocation(location: AddLocationRequest, options: CatalogServiceRequestOptions): Promise<AddLocationResponse>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
class DefaultCatalogScmEventsService {
|
|
4
|
+
#subscribers;
|
|
5
|
+
constructor() {
|
|
6
|
+
this.#subscribers = /* @__PURE__ */ new Set();
|
|
7
|
+
}
|
|
8
|
+
subscribe(subscriber) {
|
|
9
|
+
this.#subscribers.add(subscriber);
|
|
10
|
+
return {
|
|
11
|
+
unsubscribe: () => {
|
|
12
|
+
this.#subscribers.delete(subscriber);
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
async publish(events) {
|
|
17
|
+
await Promise.all(
|
|
18
|
+
Array.from(this.#subscribers).map(async (subscriber) => {
|
|
19
|
+
try {
|
|
20
|
+
await subscriber.onEvents(events);
|
|
21
|
+
} catch (error) {
|
|
22
|
+
}
|
|
23
|
+
})
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
exports.DefaultCatalogScmEventsService = DefaultCatalogScmEventsService;
|
|
29
|
+
//# sourceMappingURL=DefaultCatalogScmEventsService.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DefaultCatalogScmEventsService.cjs.js","sources":["../../src/scmEvents/DefaultCatalogScmEventsService.ts"],"sourcesContent":["/*\n * Copyright 2026 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 CatalogScmEvent,\n CatalogScmEventsService,\n CatalogScmEventsServiceSubscriber,\n} from './types';\n\n/**\n * The default implementation of the {@link CatalogScmEventsService}/{@link catalogScmEventsServiceRef}.\n *\n * @internal\n * @remarks\n *\n * This implementation is in-memory, which requires the producers and consumer\n * (the catalog backend) to be deployed together.\n */\nexport class DefaultCatalogScmEventsService implements CatalogScmEventsService {\n readonly #subscribers: Set<CatalogScmEventsServiceSubscriber>;\n\n constructor() {\n this.#subscribers = new Set();\n }\n\n subscribe(subscriber: CatalogScmEventsServiceSubscriber): {\n unsubscribe: () => void;\n } {\n this.#subscribers.add(subscriber);\n return {\n unsubscribe: () => {\n this.#subscribers.delete(subscriber);\n },\n };\n }\n\n async publish(events: CatalogScmEvent[]): Promise<void> {\n await Promise.all(\n Array.from(this.#subscribers).map(async subscriber => {\n try {\n await subscriber.onEvents(events);\n } catch (error) {\n // The subscribers are expected to handle errors themselves.\n }\n }),\n );\n }\n}\n"],"names":[],"mappings":";;AA+BO,MAAM,8BAAA,CAAkE;AAAA,EACpE,YAAA;AAAA,EAET,WAAA,GAAc;AACZ,IAAA,IAAA,CAAK,YAAA,uBAAmB,GAAA,EAAI;AAAA,EAC9B;AAAA,EAEA,UAAU,UAAA,EAER;AACA,IAAA,IAAA,CAAK,YAAA,CAAa,IAAI,UAAU,CAAA;AAChC,IAAA,OAAO;AAAA,MACL,aAAa,MAAM;AACjB,QAAA,IAAA,CAAK,YAAA,CAAa,OAAO,UAAU,CAAA;AAAA,MACrC;AAAA,KACF;AAAA,EACF;AAAA,EAEA,MAAM,QAAQ,MAAA,EAA0C;AACtD,IAAA,MAAM,OAAA,CAAQ,GAAA;AAAA,MACZ,MAAM,IAAA,CAAK,IAAA,CAAK,YAAY,CAAA,CAAE,GAAA,CAAI,OAAM,UAAA,KAAc;AACpD,QAAA,IAAI;AACF,UAAA,MAAM,UAAA,CAAW,SAAS,MAAM,CAAA;AAAA,QAClC,SAAS,KAAA,EAAO;AAAA,QAEhB;AAAA,MACF,CAAC;AAAA,KACH;AAAA,EACF;AACF;;;;"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var backendPluginApi = require('@backstage/backend-plugin-api');
|
|
4
|
+
var DefaultCatalogScmEventsService = require('./DefaultCatalogScmEventsService.cjs.js');
|
|
5
|
+
|
|
6
|
+
const catalogScmEventsServiceRef = backendPluginApi.createServiceRef({
|
|
7
|
+
id: "catalog.scm-events.alpha",
|
|
8
|
+
defaultFactory: async (service) => backendPluginApi.createServiceFactory({
|
|
9
|
+
service,
|
|
10
|
+
deps: {},
|
|
11
|
+
createRootContext() {
|
|
12
|
+
return new DefaultCatalogScmEventsService.DefaultCatalogScmEventsService();
|
|
13
|
+
},
|
|
14
|
+
factory(_, ctx) {
|
|
15
|
+
return ctx;
|
|
16
|
+
}
|
|
17
|
+
})
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
exports.catalogScmEventsServiceRef = catalogScmEventsServiceRef;
|
|
21
|
+
//# sourceMappingURL=catalogScmEventsServiceRef.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalogScmEventsServiceRef.cjs.js","sources":["../../src/scmEvents/catalogScmEventsServiceRef.ts"],"sourcesContent":["/*\n * Copyright 2025 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} from '@backstage/backend-plugin-api';\nimport { CatalogScmEventsService } from './types';\nimport { DefaultCatalogScmEventsService } from './DefaultCatalogScmEventsService';\n\n/**\n * A service that allows publishing and subscribing to source control management\n * system events.\n *\n * @alpha\n * @remarks\n *\n * The default implementation of this service acts in-memory, which requires the\n * producers and consumer (the catalog backend) to be deployed together.\n */\nexport const catalogScmEventsServiceRef =\n createServiceRef<CatalogScmEventsService>({\n id: 'catalog.scm-events.alpha',\n defaultFactory: async service =>\n createServiceFactory({\n service,\n deps: {},\n createRootContext() {\n return new DefaultCatalogScmEventsService();\n },\n factory(_, ctx) {\n return ctx;\n },\n }),\n });\n"],"names":["createServiceRef","createServiceFactory","DefaultCatalogScmEventsService"],"mappings":";;;;;AAiCO,MAAM,6BACXA,iCAAA,CAA0C;AAAA,EACxC,EAAA,EAAI,0BAAA;AAAA,EACJ,cAAA,EAAgB,OAAM,OAAA,KACpBC,qCAAA,CAAqB;AAAA,IACnB,OAAA;AAAA,IACA,MAAM,EAAC;AAAA,IACP,iBAAA,GAAoB;AAClB,MAAA,OAAO,IAAIC,6DAAA,EAA+B;AAAA,IAC5C,CAAA;AAAA,IACA,OAAA,CAAQ,GAAG,GAAA,EAAK;AACd,MAAA,OAAO,GAAA;AAAA,IACT;AAAA,GACD;AACL,CAAC;;;;"}
|
|
@@ -26,6 +26,8 @@ function catalogServiceMock(options) {
|
|
|
26
26
|
refreshEntity: jest.fn(),
|
|
27
27
|
getEntityFacets: jest.fn(),
|
|
28
28
|
getLocations: jest.fn(),
|
|
29
|
+
queryLocations: jest.fn(),
|
|
30
|
+
streamLocations: jest.fn(),
|
|
29
31
|
getLocationById: jest.fn(),
|
|
30
32
|
getLocationByRef: jest.fn(),
|
|
31
33
|
addLocation: jest.fn(),
|
|
@@ -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 createServiceFactory,\n ServiceFactory,\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';\nimport { createServiceMock } from '@backstage/backend-test-utils';\nimport { CatalogServiceMock } from './types';\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 = createServiceMock<CatalogServiceMock>(\n catalogServiceRef,\n () => ({\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}\n"],"names":["InMemoryCatalogClient","catalogServiceMock","createServiceFactory","catalogServiceRef","createServiceMock"],"mappings":";;;;;;;AAiCO,SAAS,mBAAmB,OAAA,EAEZ;AACrB,EAAA,OAAO,IAAIA,gCAAsB,OAAO,CAAA;AAC1C;AAAA,CAOO,CAAUC,mBAAAA,KAAV;AAME,EAAMA,mBAAAA,CAAA,OAAA,GAAU,CAAC,OAAA,KACtBC,qCAAA,CAAqB;AAAA,IACnB,OAAA,EAASC,mCAAA;AAAA,IACT,MAAM,EAAC;AAAA,IACP,OAAA,EAAS,MAAM,IAAIH,+BAAA,CAAsB,OAAO;AAAA,GACjD,CAAA;AAKI,EAAMC,oBAAA,IAAA,GAAOG,kCAAA;AAAA,IAClBD,mCAAA;AAAA,IACA,OAAO;AAAA,MACL,WAAA,EAAa,KAAK,EAAA,EAAG;AAAA,MACrB,iBAAA,EAAmB,KAAK,EAAA,EAAG;AAAA,MAC3B,aAAA,EAAe,KAAK,EAAA,EAAG;AAAA,MACvB,kBAAA,EAAoB,KAAK,EAAA,EAAG;AAAA,MAC5B,cAAA,EAAgB,KAAK,EAAA,EAAG;AAAA,MACxB,iBAAA,EAAmB,KAAK,EAAA,EAAG;AAAA,MAC3B,aAAA,EAAe,KAAK,EAAA,EAAG;AAAA,MACvB,eAAA,EAAiB,KAAK,EAAA,EAAG;AAAA,MACzB,YAAA,EAAc,KAAK,EAAA,EAAG;AAAA,MACtB,eAAA,EAAiB,KAAK,EAAA,EAAG;AAAA,MACzB,gBAAA,EAAkB,KAAK,EAAA,EAAG;AAAA,MAC1B,WAAA,EAAa,KAAK,EAAA,EAAG;AAAA,MACrB,kBAAA,EAAoB,KAAK,EAAA,EAAG;AAAA,MAC5B,mBAAA,EAAqB,KAAK,EAAA,EAAG;AAAA,MAC7B,cAAA,EAAgB,KAAK,EAAA,EAAG;AAAA,MACxB,eAAA,EAAiB,KAAK,EAAA,EAAG;AAAA,MACzB,cAAA,EAAgB,KAAK,EAAA;AAAG,KAC1B;AAAA,GACF;AAAA,CAAA,
|
|
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} 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';\nimport { createServiceMock } from '@backstage/backend-test-utils';\nimport { CatalogServiceMock } from './types';\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 = createServiceMock<CatalogServiceMock>(\n catalogServiceRef,\n () => ({\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 queryLocations: jest.fn(),\n streamLocations: 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 );\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MACxB,eAAA,EAAiB,KAAK,EAAA,EAAG;AAAA,MACzB,cAAA,EAAgB,KAAK,EAAA;AAAG,KAC1B;AAAA,GACF;AAAA,CAAA,EAvCe,kBAAA,KAAA,kBAAA,GAAA,EAAA,CAAA,CAAA;;;;"}
|
package/dist/testUtils.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as _backstage_backend_test_utils from '@backstage/backend-test-utils';
|
|
2
2
|
import { ServiceFactory } from '@backstage/backend-plugin-api';
|
|
3
3
|
import { CompoundEntityRef, Entity } from '@backstage/catalog-model';
|
|
4
|
-
import { CatalogApi, GetEntitiesRequest, CatalogRequestOptions, GetEntitiesResponse, GetEntitiesByRefsRequest, GetEntitiesByRefsResponse, QueryEntitiesRequest, QueryEntitiesResponse, GetEntityAncestorsRequest, GetEntityAncestorsResponse, GetEntityFacetsRequest, GetEntityFacetsResponse, GetLocationsResponse, Location, AddLocationRequest, AddLocationResponse, ValidateEntityResponse, StreamEntitiesRequest } from '@backstage/catalog-client';
|
|
4
|
+
import { CatalogApi, GetEntitiesRequest, CatalogRequestOptions, GetEntitiesResponse, GetEntitiesByRefsRequest, GetEntitiesByRefsResponse, QueryEntitiesRequest, QueryEntitiesResponse, GetEntityAncestorsRequest, GetEntityAncestorsResponse, GetEntityFacetsRequest, GetEntityFacetsResponse, GetLocationsResponse, QueryLocationsRequest, QueryLocationsResponse, QueryLocationsInitialRequest, 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
|
|
|
@@ -26,6 +26,8 @@ interface CatalogServiceMock extends CatalogService, CatalogApi {
|
|
|
26
26
|
refreshEntity(entityRef: string, options?: CatalogServiceRequestOptions | CatalogRequestOptions): Promise<void>;
|
|
27
27
|
getEntityFacets(request: GetEntityFacetsRequest, options?: CatalogServiceRequestOptions | CatalogRequestOptions): Promise<GetEntityFacetsResponse>;
|
|
28
28
|
getLocations(request?: {}, options?: CatalogServiceRequestOptions | CatalogRequestOptions): Promise<GetLocationsResponse>;
|
|
29
|
+
queryLocations(request?: QueryLocationsRequest, options?: CatalogServiceRequestOptions | CatalogRequestOptions): Promise<QueryLocationsResponse>;
|
|
30
|
+
streamLocations(request?: QueryLocationsInitialRequest, options?: CatalogServiceRequestOptions | CatalogRequestOptions): AsyncIterable<Location[]>;
|
|
29
31
|
getLocationById(id: string, options?: CatalogServiceRequestOptions | CatalogRequestOptions): Promise<Location | undefined>;
|
|
30
32
|
getLocationByRef(locationRef: string, options?: CatalogServiceRequestOptions | CatalogRequestOptions): Promise<Location | undefined>;
|
|
31
33
|
addLocation(location: AddLocationRequest, options?: CatalogServiceRequestOptions | CatalogRequestOptions): Promise<AddLocationResponse>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-catalog-node",
|
|
3
|
-
"version": "2.0.0
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "The plugin-catalog-node module for @backstage/plugin-catalog-backend",
|
|
5
5
|
"backstage": {
|
|
6
6
|
"role": "node-library",
|
|
@@ -72,28 +72,28 @@
|
|
|
72
72
|
"test": "backstage-cli package test"
|
|
73
73
|
},
|
|
74
74
|
"dependencies": {
|
|
75
|
-
"@backstage/backend-plugin-api": "1.7.0
|
|
76
|
-
"@backstage/catalog-client": "1.
|
|
77
|
-
"@backstage/catalog-model": "1.7.6",
|
|
78
|
-
"@backstage/errors": "1.2.7",
|
|
79
|
-
"@backstage/plugin-catalog-common": "1.1.8
|
|
80
|
-
"@backstage/plugin-permission-common": "0.9.6
|
|
81
|
-
"@backstage/plugin-permission-node": "0.10.10
|
|
82
|
-
"@backstage/types": "1.2.2",
|
|
75
|
+
"@backstage/backend-plugin-api": "^1.7.0",
|
|
76
|
+
"@backstage/catalog-client": "^1.13.0",
|
|
77
|
+
"@backstage/catalog-model": "^1.7.6",
|
|
78
|
+
"@backstage/errors": "^1.2.7",
|
|
79
|
+
"@backstage/plugin-catalog-common": "^1.1.8",
|
|
80
|
+
"@backstage/plugin-permission-common": "^0.9.6",
|
|
81
|
+
"@backstage/plugin-permission-node": "^0.10.10",
|
|
82
|
+
"@backstage/types": "^1.2.2",
|
|
83
83
|
"lodash": "^4.17.21",
|
|
84
84
|
"yaml": "^2.0.0"
|
|
85
85
|
},
|
|
86
|
+
"devDependencies": {
|
|
87
|
+
"@backstage/backend-test-utils": "^1.11.0",
|
|
88
|
+
"@backstage/cli": "^0.35.4",
|
|
89
|
+
"msw": "^1.0.0"
|
|
90
|
+
},
|
|
86
91
|
"peerDependencies": {
|
|
87
|
-
"@backstage/backend-test-utils": "1.11.0
|
|
92
|
+
"@backstage/backend-test-utils": "^1.11.0"
|
|
88
93
|
},
|
|
89
94
|
"peerDependenciesMeta": {
|
|
90
95
|
"@backstage/backend-test-utils": {
|
|
91
96
|
"optional": true
|
|
92
97
|
}
|
|
93
|
-
},
|
|
94
|
-
"devDependencies": {
|
|
95
|
-
"@backstage/backend-test-utils": "1.11.0-next.1",
|
|
96
|
-
"@backstage/cli": "0.35.4-next.2",
|
|
97
|
-
"msw": "^1.0.0"
|
|
98
98
|
}
|
|
99
99
|
}
|