@backstage/plugin-catalog-node 2.0.0 → 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 +21 -0
- package/dist/alpha.d.ts +19 -0
- package/dist/scmEvents/DefaultCatalogScmEventsService.cjs.js +12 -1
- package/dist/scmEvents/DefaultCatalogScmEventsService.cjs.js.map +1 -1
- package/dist/scmEvents/catalogScmEventsServiceRef.cjs.js +2 -1
- package/dist/scmEvents/catalogScmEventsServiceRef.cjs.js.map +1 -1
- package/package.json +13 -12
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
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
|
+
|
|
3
24
|
## 2.0.0
|
|
4
25
|
|
|
5
26
|
### Minor Changes
|
package/dist/alpha.d.ts
CHANGED
|
@@ -45,6 +45,25 @@ interface CatalogScmEventsService {
|
|
|
45
45
|
* guarantees.
|
|
46
46
|
*/
|
|
47
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;
|
|
48
67
|
}
|
|
49
68
|
/**
|
|
50
69
|
* Voluntary contextual information related to a {@link CatalogScmEvent}.
|
|
@@ -2,8 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
class DefaultCatalogScmEventsService {
|
|
4
4
|
#subscribers;
|
|
5
|
-
|
|
5
|
+
#metrics;
|
|
6
|
+
constructor(metrics) {
|
|
6
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
|
+
};
|
|
7
15
|
}
|
|
8
16
|
subscribe(subscriber) {
|
|
9
17
|
this.#subscribers.add(subscriber);
|
|
@@ -23,6 +31,9 @@ class DefaultCatalogScmEventsService {
|
|
|
23
31
|
})
|
|
24
32
|
);
|
|
25
33
|
}
|
|
34
|
+
markEventActionTaken(options) {
|
|
35
|
+
this.#metrics.actions.add(options.count ?? 1, { action: options.action });
|
|
36
|
+
}
|
|
26
37
|
}
|
|
27
38
|
|
|
28
39
|
exports.DefaultCatalogScmEventsService = DefaultCatalogScmEventsService;
|
|
@@ -1 +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":";;
|
|
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 ??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
var backendPluginApi = require('@backstage/backend-plugin-api');
|
|
4
|
+
var api = require('@opentelemetry/api');
|
|
4
5
|
var DefaultCatalogScmEventsService = require('./DefaultCatalogScmEventsService.cjs.js');
|
|
5
6
|
|
|
6
7
|
const catalogScmEventsServiceRef = backendPluginApi.createServiceRef({
|
|
@@ -9,7 +10,7 @@ const catalogScmEventsServiceRef = backendPluginApi.createServiceRef({
|
|
|
9
10
|
service,
|
|
10
11
|
deps: {},
|
|
11
12
|
createRootContext() {
|
|
12
|
-
return new DefaultCatalogScmEventsService.DefaultCatalogScmEventsService();
|
|
13
|
+
return new DefaultCatalogScmEventsService.DefaultCatalogScmEventsService(api.metrics);
|
|
13
14
|
},
|
|
14
15
|
factory(_, ctx) {
|
|
15
16
|
return ctx;
|
|
@@ -1 +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":"
|
|
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;;;;"}
|
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.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,24 +72,25 @@
|
|
|
72
72
|
"test": "backstage-cli package test"
|
|
73
73
|
},
|
|
74
74
|
"dependencies": {
|
|
75
|
-
"@backstage/backend-plugin-api": "
|
|
76
|
-
"@backstage/catalog-client": "
|
|
77
|
-
"@backstage/catalog-model": "
|
|
78
|
-
"@backstage/errors": "
|
|
79
|
-
"@backstage/plugin-catalog-common": "
|
|
80
|
-
"@backstage/plugin-permission-common": "
|
|
81
|
-
"@backstage/plugin-permission-node": "
|
|
82
|
-
"@backstage/types": "
|
|
75
|
+
"@backstage/backend-plugin-api": "1.7.1-next.0",
|
|
76
|
+
"@backstage/catalog-client": "1.13.1-next.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.11-next.0",
|
|
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
|
},
|
|
86
87
|
"devDependencies": {
|
|
87
|
-
"@backstage/backend-test-utils": "
|
|
88
|
-
"@backstage/cli": "
|
|
88
|
+
"@backstage/backend-test-utils": "1.11.1-next.0",
|
|
89
|
+
"@backstage/cli": "0.35.5-next.0",
|
|
89
90
|
"msw": "^1.0.0"
|
|
90
91
|
},
|
|
91
92
|
"peerDependencies": {
|
|
92
|
-
"@backstage/backend-test-utils": "
|
|
93
|
+
"@backstage/backend-test-utils": "1.11.1-next.0"
|
|
93
94
|
},
|
|
94
95
|
"peerDependenciesMeta": {
|
|
95
96
|
"@backstage/backend-test-utils": {
|