@backstage/plugin-catalog-node 2.0.0-next.1 → 2.1.0-next.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 CHANGED
@@ -1,5 +1,55 @@
1
1
  # @backstage/plugin-catalog-node
2
2
 
3
+ ## 2.1.0-next.0
4
+
5
+ ### Minor Changes
6
+
7
+ - bf71677: Added the ability for SCM events subscribers to mark the fact that they have taken actions based on events, which produces output metrics:
8
+
9
+ - `catalog.events.scm.actions` with attribute `action`: Counter for the number of actions actually taken by catalog internals or other subscribers, based on SCM events. The `action` is currently either `create`, `delete`, `refresh`, or `move`.
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies
14
+ - @backstage/backend-plugin-api@1.7.1-next.0
15
+ - @backstage/catalog-client@1.13.1-next.0
16
+ - @backstage/backend-test-utils@1.11.1-next.0
17
+ - @backstage/catalog-model@1.7.6
18
+ - @backstage/errors@1.2.7
19
+ - @backstage/types@1.2.2
20
+ - @backstage/plugin-catalog-common@1.1.8
21
+ - @backstage/plugin-permission-common@0.9.6
22
+ - @backstage/plugin-permission-node@0.10.11-next.0
23
+
24
+ ## 2.0.0
25
+
26
+ ### Minor Changes
27
+
28
+ - 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`:
29
+
30
+ - `catalogLocationsExtensionPoint` and `CatalogLocationsExtensionPoint`
31
+ - `catalogProcessingExtensionPoint` and `CatalogProcessingExtensionPoint`
32
+ - `catalogAnalysisExtensionPoint` and `CatalogAnalysisExtensionPoint`
33
+
34
+ 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`.
35
+
36
+ Note: The `catalogModelExtensionPoint`, `catalogPermissionExtensionPoint`, and related types remain in alpha.
37
+
38
+ - b4e8249: Implemented support for the new `queryLocations` and `streamLocations` that allow paginated/streamed and filtered location queries
39
+ - 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.
40
+
41
+ ### Patch Changes
42
+
43
+ - 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.
44
+ - 7455dae: Use node prefix on native imports
45
+ - Updated dependencies
46
+ - @backstage/backend-test-utils@1.11.0
47
+ - @backstage/backend-plugin-api@1.7.0
48
+ - @backstage/catalog-client@1.13.0
49
+ - @backstage/plugin-permission-common@0.9.6
50
+ - @backstage/plugin-permission-node@0.10.10
51
+ - @backstage/plugin-catalog-common@1.1.8
52
+
3
53
  ## 2.0.0-next.1
4
54
 
5
55
  ### 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;
@@ -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":";;;;;;;;;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;;;;;;;;;;"}
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,192 @@ 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
+ * As a consumer of SCM events, mark that you have taken an action as a result
50
+ * of an SCM event.
51
+ *
52
+ * This is typically used to record metrics or other observability signals
53
+ * about how SCM events are handled, for example counting how many refresh,
54
+ * delete, create, or move operations are triggered by incoming events.
55
+ */
56
+ markEventActionTaken(options: {
57
+ /**
58
+ * The number of actions taken of the given type. Defaults to 1.
59
+ */
60
+ count?: number;
61
+ /**
62
+ * The type of action taken - typically "refresh", "delete",
63
+ * "create", or "move".
64
+ */
65
+ action: string;
66
+ }): void;
67
+ }
68
+ /**
69
+ * Voluntary contextual information related to a {@link CatalogScmEvent}.
70
+ *
71
+ * @alpha
72
+ */
73
+ type CatalogScmEventContext = {
74
+ /**
75
+ * URL to a commit related to this event being generated, if relevant.
76
+ */
77
+ commitUrl?: string;
78
+ };
79
+ /**
80
+ * Represents a high level change event that happened in a source control
81
+ * management system. These are usually produced as a distilled version of an
82
+ * incoming webhook event or similar.
83
+ *
84
+ * @alpha
85
+ */
86
+ type CatalogScmEvent = {
87
+ /**
88
+ * A new location was created.
89
+ *
90
+ * @remarks
91
+ *
92
+ * This typically means that an individual file was created in an existing
93
+ * repository, for example through a git push or merge.
94
+ */
95
+ type: 'location.created';
96
+ url: string;
97
+ context?: CatalogScmEventContext;
98
+ } | {
99
+ /**
100
+ * An existing location was modified.
101
+ *
102
+ * @remarks
103
+ *
104
+ * This typically means that an individual file was modified in an existing
105
+ * repository, for example through a git push or merge.
106
+ */
107
+ type: 'location.updated';
108
+ url: string;
109
+ context?: CatalogScmEventContext;
110
+ } | {
111
+ /**
112
+ * An existing location was deleted.
113
+ *
114
+ * @remarks
115
+ *
116
+ * This typically means that an individual file was deleted in an existing
117
+ * repository, for example through a git push or merge.
118
+ */
119
+ type: 'location.deleted';
120
+ url: string;
121
+ context?: CatalogScmEventContext;
122
+ } | {
123
+ /**
124
+ * An existing location was moved from one place to another.
125
+ *
126
+ * @remarks
127
+ *
128
+ * This typically means that an individual file was moved or renamed, for
129
+ * example through a git push or merge. The URLs do not necessarily refer
130
+ * to the same repository before and after the move.
131
+ */
132
+ type: 'location.moved';
133
+ fromUrl: string;
134
+ toUrl: string;
135
+ context?: CatalogScmEventContext;
136
+ } | {
137
+ /**
138
+ * A new repository was created.
139
+ */
140
+ type: 'repository.created';
141
+ url: string;
142
+ context?: CatalogScmEventContext;
143
+ } | {
144
+ /**
145
+ * An existing repository was updated.
146
+ *
147
+ * @remarks
148
+ *
149
+ * This usually refers to some form of meta state change, such as it being
150
+ * made public or private, or its visibility being changed.
151
+ */
152
+ type: 'repository.updated';
153
+ url: string;
154
+ context?: CatalogScmEventContext;
155
+ } | {
156
+ /**
157
+ * An existing repository was deleted.
158
+ */
159
+ type: 'repository.deleted';
160
+ url: string;
161
+ context?: CatalogScmEventContext;
162
+ } | {
163
+ /**
164
+ * An existing repository was moved or in some other way had its effective
165
+ * base URL changed.
166
+ *
167
+ * @remarks
168
+ *
169
+ * This typically refers to a repository being renamed, or transferred to
170
+ * a different owner. It can also refer to a change of base branch, which
171
+ * effectively changes the base URL for many repository URL patterns.
172
+ *
173
+ * The source and target URLs do not necessarily end exactly on a
174
+ * repository, but MAY include additional path segments such as the branch
175
+ * name.
176
+ */
177
+ type: 'repository.moved';
178
+ fromUrl: string;
179
+ toUrl: string;
180
+ context?: CatalogScmEventContext;
181
+ };
182
+
183
+ /**
184
+ * A service that allows publishing and subscribing to source control management
185
+ * system events.
186
+ *
187
+ * @alpha
188
+ * @remarks
189
+ *
190
+ * The default implementation of this service acts in-memory, which requires the
191
+ * producers and consumer (the catalog backend) to be deployed together.
192
+ */
193
+ declare const catalogScmEventsServiceRef: _backstage_backend_plugin_api.ServiceRef<CatalogScmEventsService, "plugin", "singleton">;
194
+
9
195
  /** @alpha */
10
196
  declare const catalogEntityPermissionResourceRef: _backstage_plugin_permission_node.PermissionResourceRef<Entity, EntitiesSearchFilter, "catalog-entity", "catalog">;
11
197
  /**
@@ -45,5 +231,5 @@ type CatalogAnalysisExtensionPoint = CatalogAnalysisExtensionPoint$1;
45
231
  */
46
232
  declare const catalogAnalysisExtensionPoint: _backstage_backend_plugin_api.ExtensionPoint<CatalogAnalysisExtensionPoint$1>;
47
233
 
48
- export { catalogAnalysisExtensionPoint, catalogEntityPermissionResourceRef, catalogLocationsExtensionPoint, catalogProcessingExtensionPoint, catalogServiceRef };
49
- export type { CatalogAnalysisExtensionPoint, CatalogLocationsExtensionPoint, CatalogProcessingExtensionPoint };
234
+ export { catalogAnalysisExtensionPoint, catalogEntityPermissionResourceRef, catalogLocationsExtensionPoint, catalogProcessingExtensionPoint, catalogScmEventsServiceRef, catalogServiceRef };
235
+ 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,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,OAAO,cAAA,CACL,OAAA,EACA,OAAA,EACyB;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;;;;"}
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;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,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WAAA,CAAY,eAAA;AAAA,MACtB,QAAA;AAAA,MACA,MAAM,IAAA,CAAK,WAAA,CAAY,OAAO;AAAA,KAChC;AAAA,EACF;AAAA,EAEA,OAAO,cAAA,CACL,OAAA,EACA,OAAA,EACyB;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, 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,40 @@
1
+ 'use strict';
2
+
3
+ class DefaultCatalogScmEventsService {
4
+ #subscribers;
5
+ #metrics;
6
+ constructor(metrics) {
7
+ this.#subscribers = /* @__PURE__ */ new Set();
8
+ const meter = metrics.getMeter("default");
9
+ this.#metrics = {
10
+ actions: meter.createCounter("catalog.events.scm.actions", {
11
+ description: "Number of actions taken as a result of SCM event messages",
12
+ unit: "short"
13
+ })
14
+ };
15
+ }
16
+ subscribe(subscriber) {
17
+ this.#subscribers.add(subscriber);
18
+ return {
19
+ unsubscribe: () => {
20
+ this.#subscribers.delete(subscriber);
21
+ }
22
+ };
23
+ }
24
+ async publish(events) {
25
+ await Promise.all(
26
+ Array.from(this.#subscribers).map(async (subscriber) => {
27
+ try {
28
+ await subscriber.onEvents(events);
29
+ } catch (error) {
30
+ }
31
+ })
32
+ );
33
+ }
34
+ markEventActionTaken(options) {
35
+ this.#metrics.actions.add(options.count ?? 1, { action: options.action });
36
+ }
37
+ }
38
+
39
+ exports.DefaultCatalogScmEventsService = DefaultCatalogScmEventsService;
40
+ //# 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 { Counter, MetricsAPI } from '@opentelemetry/api';\nimport {\n CatalogScmEvent,\n CatalogScmEventsService,\n CatalogScmEventsServiceSubscriber,\n} from './types';\n\n/**\n * The default implementation of the\n * {@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 *\n * It's defined in here instead of in the catalog-backend plugin because this\n * allows us to have a default factory whether you happen to be co-installed\n * with the catalog-backend plugin or not.\n */\nexport class DefaultCatalogScmEventsService implements CatalogScmEventsService {\n readonly #subscribers: Set<CatalogScmEventsServiceSubscriber>;\n readonly #metrics: {\n actions: Counter<{ action: string }>;\n };\n\n constructor(metrics: MetricsAPI) {\n this.#subscribers = new Set();\n\n const meter = metrics.getMeter('default');\n this.#metrics = {\n actions: meter.createCounter('catalog.events.scm.actions', {\n description:\n 'Number of actions taken as a result of SCM event messages',\n unit: 'short',\n }),\n };\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 markEventActionTaken(options: { count?: number; action: string }): void {\n this.#metrics.actions.add(options.count ?? 1, { action: options.action });\n }\n}\n"],"names":[],"mappings":";;AAqCO,MAAM,8BAAA,CAAkE;AAAA,EACpE,YAAA;AAAA,EACA,QAAA;AAAA,EAIT,YAAY,OAAA,EAAqB;AAC/B,IAAA,IAAA,CAAK,YAAA,uBAAmB,GAAA,EAAI;AAE5B,IAAA,MAAM,KAAA,GAAQ,OAAA,CAAQ,QAAA,CAAS,SAAS,CAAA;AACxC,IAAA,IAAA,CAAK,QAAA,GAAW;AAAA,MACd,OAAA,EAAS,KAAA,CAAM,aAAA,CAAc,4BAAA,EAA8B;AAAA,QACzD,WAAA,EACE,2DAAA;AAAA,QACF,IAAA,EAAM;AAAA,OACP;AAAA,KACH;AAAA,EACF;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;AAAA,EAEA,qBAAqB,OAAA,EAAmD;AACtE,IAAA,IAAA,CAAK,QAAA,CAAS,OAAA,CAAQ,GAAA,CAAI,OAAA,CAAQ,KAAA,IAAS,GAAG,EAAE,MAAA,EAAQ,OAAA,CAAQ,MAAA,EAAQ,CAAA;AAAA,EAC1E;AACF;;;;"}
@@ -0,0 +1,22 @@
1
+ 'use strict';
2
+
3
+ var backendPluginApi = require('@backstage/backend-plugin-api');
4
+ var api = require('@opentelemetry/api');
5
+ var DefaultCatalogScmEventsService = require('./DefaultCatalogScmEventsService.cjs.js');
6
+
7
+ const catalogScmEventsServiceRef = backendPluginApi.createServiceRef({
8
+ id: "catalog.scm-events.alpha",
9
+ defaultFactory: async (service) => backendPluginApi.createServiceFactory({
10
+ service,
11
+ deps: {},
12
+ createRootContext() {
13
+ return new DefaultCatalogScmEventsService.DefaultCatalogScmEventsService(api.metrics);
14
+ },
15
+ factory(_, ctx) {
16
+ return ctx;
17
+ }
18
+ })
19
+ });
20
+
21
+ exports.catalogScmEventsServiceRef = catalogScmEventsServiceRef;
22
+ //# 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 { metrics } from '@opentelemetry/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(metrics);\n },\n factory(_, ctx) {\n return ctx;\n },\n }),\n });\n"],"names":["createServiceRef","createServiceFactory","DefaultCatalogScmEventsService","metrics"],"mappings":";;;;;;AAkCO,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,8DAA+BC,WAAO,CAAA;AAAA,IACnD,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,EArCe,kBAAA,KAAA,kBAAA,GAAA,EAAA,CAAA,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 );\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,cAAA,EAAgB,KAAK,EAAA,EAAG;AAAA,MACxB,eAAA,EAAiB,KAAK,EAAA,EAAG;AAAA,MACzB,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,EAvCe,kBAAA,KAAA,kBAAA,GAAA,EAAA,CAAA,CAAA;;;;"}
@@ -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-next.1",
3
+ "version": "2.1.0-next.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,29 @@
72
72
  "test": "backstage-cli package test"
73
73
  },
74
74
  "dependencies": {
75
- "@backstage/backend-plugin-api": "1.7.0-next.1",
76
- "@backstage/catalog-client": "1.12.2-next.0",
75
+ "@backstage/backend-plugin-api": "1.7.1-next.0",
76
+ "@backstage/catalog-client": "1.13.1-next.0",
77
77
  "@backstage/catalog-model": "1.7.6",
78
78
  "@backstage/errors": "1.2.7",
79
- "@backstage/plugin-catalog-common": "1.1.8-next.0",
80
- "@backstage/plugin-permission-common": "0.9.6-next.0",
81
- "@backstage/plugin-permission-node": "0.10.10-next.0",
79
+ "@backstage/plugin-catalog-common": "1.1.8",
80
+ "@backstage/plugin-permission-common": "0.9.6",
81
+ "@backstage/plugin-permission-node": "0.10.11-next.0",
82
82
  "@backstage/types": "1.2.2",
83
+ "@opentelemetry/api": "^1.9.0",
83
84
  "lodash": "^4.17.21",
84
85
  "yaml": "^2.0.0"
85
86
  },
87
+ "devDependencies": {
88
+ "@backstage/backend-test-utils": "1.11.1-next.0",
89
+ "@backstage/cli": "0.35.5-next.0",
90
+ "msw": "^1.0.0"
91
+ },
86
92
  "peerDependencies": {
87
- "@backstage/backend-test-utils": "1.11.0-next.1"
93
+ "@backstage/backend-test-utils": "1.11.1-next.0"
88
94
  },
89
95
  "peerDependenciesMeta": {
90
96
  "@backstage/backend-test-utils": {
91
97
  "optional": true
92
98
  }
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
99
  }
99
100
  }