@backstage/plugin-events-backend-module-azure 0.1.21 → 0.2.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,12 +1,82 @@
1
1
  # @backstage/plugin-events-backend-module-azure
2
2
 
3
- ## 0.1.21
3
+ ## 0.2.0-next.0
4
4
 
5
- ### Patch Changes
5
+ ### Minor Changes
6
6
 
7
- - Updated dependencies
8
- - @backstage/backend-plugin-api@0.6.11
9
- - @backstage/plugin-events-node@0.2.20
7
+ - eff3ca9: BREAKING CHANGE: Migrate `EventRouter` implementations from `EventBroker` to `EventsService`.
8
+
9
+ `EventRouter` uses the new `EventsService` instead of the `EventBroker` now,
10
+ causing a breaking change to its signature.
11
+
12
+ All of its extensions and implementations got adjusted accordingly.
13
+ (`SubTopicEventRouter`, `AzureDevOpsEventRouter`, `BitbucketCloudEventRouter`,
14
+ `GerritEventRouter`, `GithubEventRouter`, `GitlabEventRouter`)
15
+
16
+ Required adjustments were made to all backend modules for the new backend system,
17
+ now also making use of the `eventsServiceRef` instead of the `eventsExtensionPoint`.
18
+
19
+ **Migration:**
20
+
21
+ Example for implementations of `SubTopicEventRouter`:
22
+
23
+ ```diff
24
+ import {
25
+ EventParams,
26
+ + EventsService,
27
+ SubTopicEventRouter,
28
+ } from '@backstage/plugin-events-node';
29
+
30
+ export class GithubEventRouter extends SubTopicEventRouter {
31
+ - constructor() {
32
+ - super('github');
33
+ + constructor(options: { events: EventsService }) {
34
+ + super({
35
+ + events: options.events,
36
+ + topic: 'github',
37
+ + });
38
+ }
39
+
40
+ + protected getSubscriberId(): string {
41
+ + return 'GithubEventRouter';
42
+ + }
43
+ +
44
+ // ...
45
+ }
46
+ ```
47
+
48
+ Example for a direct extension of `EventRouter`:
49
+
50
+ ```diff
51
+ class MyEventRouter extends EventRouter {
52
+ - constructor(/* ... */) {
53
+ + constructor(options: {
54
+ + events: EventsService;
55
+ + // ...
56
+ + }) {
57
+ - super();
58
+ // ...
59
+ + super({
60
+ + events: options.events,
61
+ + topics: topics,
62
+ + });
63
+ }
64
+ +
65
+ + protected getSubscriberId(): string {
66
+ + return 'MyEventRouter';
67
+ + }
68
+ -
69
+ - supportsEventTopics(): string[] {
70
+ - return this.topics;
71
+ - }
72
+ }
73
+ ```
74
+
75
+ ### Patch Changes
76
+
77
+ - Updated dependencies
78
+ - @backstage/plugin-events-node@0.3.0-next.0
79
+ - @backstage/backend-plugin-api@0.6.13-next.0
10
80
 
11
81
  ## 0.1.20
12
82
 
package/README.md CHANGED
@@ -1,9 +1,9 @@
1
1
  # events-backend-module-azure
2
2
 
3
- Welcome to the `events-backend-module-azure` backend plugin!
3
+ Welcome to the `events-backend-module-azure` backend module!
4
4
 
5
- This plugin is a module for the `events-backend` backend plugin
6
- and extends it with an `AzureDevOpsEventRouter`.
5
+ This package is a module for the `events-backend` backend plugin
6
+ and extends the event system with an `AzureDevOpsEventRouter`.
7
7
 
8
8
  The event router will subscribe to the topic `azureDevOps`
9
9
  and route the events to more concrete topics based on the value
@@ -22,30 +22,22 @@ and [webhooks](https://learn.microsoft.com/en-us/azure/devops/service-hooks/serv
22
22
 
23
23
  ## Installation
24
24
 
25
- Install the [`events-backend` plugin](../events-backend/README.md).
26
-
27
- Install this module:
28
-
29
25
  ```bash
30
26
  # From your Backstage root directory
31
27
  yarn --cwd packages/backend add @backstage/plugin-events-backend-module-azure
32
28
  ```
33
29
 
34
- ### Add to backend
35
-
36
- ```ts title="packages/backend/src/index.ts"
30
+ ```ts
31
+ // packages/backend/src/index.ts
37
32
  backend.add(import('@backstage/plugin-events-backend-module-azure/alpha'));
38
33
  ```
39
34
 
40
- ### Add to backend (old)
41
-
42
- Add the event router to the `EventsBackend` instance in `packages/backend/src/plugins/events.ts`:
43
-
44
- ```diff
45
- +const azureEventRouter = new AzureDevOpsEventRouter();
35
+ ### Legacy Backend System
46
36
 
47
- new EventsBackend(env.logger)
48
- + .addPublishers(azureEventRouter)
49
- + .addSubscribers(azureEventRouter);
50
- // [...]
37
+ ```ts
38
+ // packages/backend/src/plugins/events.ts
39
+ const eventRouter = new AzureDevOpsEventRouter({
40
+ events: env.events,
41
+ });
42
+ await eventRouter.subscribe();
51
43
  ```
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-events-backend-module-azure",
3
- "version": "0.1.21",
3
+ "version": "0.2.0-next.0",
4
4
  "main": "../dist/alpha.cjs.js",
5
5
  "types": "../dist/alpha.d.ts"
6
6
  }
package/dist/alpha.cjs.js CHANGED
@@ -3,9 +3,8 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var backendPluginApi = require('@backstage/backend-plugin-api');
6
- var alpha = require('@backstage/plugin-events-node/alpha');
7
- var AzureDevOpsEventRouter = require('./cjs/AzureDevOpsEventRouter-0c5cf09d.cjs.js');
8
- require('@backstage/plugin-events-node');
6
+ var pluginEventsNode = require('@backstage/plugin-events-node');
7
+ var AzureDevOpsEventRouter = require('./cjs/AzureDevOpsEventRouter-d0832ee6.cjs.js');
9
8
 
10
9
  const eventsModuleAzureDevOpsEventRouter = backendPluginApi.createBackendModule({
11
10
  pluginId: "events",
@@ -13,12 +12,13 @@ const eventsModuleAzureDevOpsEventRouter = backendPluginApi.createBackendModule(
13
12
  register(env) {
14
13
  env.registerInit({
15
14
  deps: {
16
- events: alpha.eventsExtensionPoint
15
+ events: pluginEventsNode.eventsServiceRef
17
16
  },
18
17
  async init({ events }) {
19
- const eventRouter = new AzureDevOpsEventRouter.AzureDevOpsEventRouter();
20
- events.addPublishers(eventRouter);
21
- events.addSubscribers(eventRouter);
18
+ const eventRouter = new AzureDevOpsEventRouter.AzureDevOpsEventRouter({
19
+ events
20
+ });
21
+ await eventRouter.subscribe();
22
22
  }
23
23
  });
24
24
  }
@@ -1 +1 @@
1
- {"version":3,"file":"alpha.cjs.js","sources":["../src/service/eventsModuleAzureDevOpsEventRouter.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 { createBackendModule } from '@backstage/backend-plugin-api';\nimport { eventsExtensionPoint } from '@backstage/plugin-events-node/alpha';\nimport { AzureDevOpsEventRouter } from '../router/AzureDevOpsEventRouter';\n\n/**\n * Module for the events-backend plugin, adding an event router for Azure DevOps.\n *\n * Registers the `AzureDevOpsEventRouter`.\n *\n * @alpha\n */\nexport const eventsModuleAzureDevOpsEventRouter = createBackendModule({\n pluginId: 'events',\n moduleId: 'azure-dev-ops-event-router',\n register(env) {\n env.registerInit({\n deps: {\n events: eventsExtensionPoint,\n },\n async init({ events }) {\n const eventRouter = new AzureDevOpsEventRouter();\n\n events.addPublishers(eventRouter);\n events.addSubscribers(eventRouter);\n },\n });\n },\n});\n"],"names":["createBackendModule","eventsExtensionPoint","AzureDevOpsEventRouter"],"mappings":";;;;;;;;;AA2BO,MAAM,qCAAqCA,oCAAoB,CAAA;AAAA,EACpE,QAAU,EAAA,QAAA;AAAA,EACV,QAAU,EAAA,4BAAA;AAAA,EACV,SAAS,GAAK,EAAA;AACZ,IAAA,GAAA,CAAI,YAAa,CAAA;AAAA,MACf,IAAM,EAAA;AAAA,QACJ,MAAQ,EAAAC,0BAAA;AAAA,OACV;AAAA,MACA,MAAM,IAAA,CAAK,EAAE,MAAA,EAAU,EAAA;AACrB,QAAM,MAAA,WAAA,GAAc,IAAIC,6CAAuB,EAAA,CAAA;AAE/C,QAAA,MAAA,CAAO,cAAc,WAAW,CAAA,CAAA;AAChC,QAAA,MAAA,CAAO,eAAe,WAAW,CAAA,CAAA;AAAA,OACnC;AAAA,KACD,CAAA,CAAA;AAAA,GACH;AACF,CAAC;;;;;"}
1
+ {"version":3,"file":"alpha.cjs.js","sources":["../src/service/eventsModuleAzureDevOpsEventRouter.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 { createBackendModule } from '@backstage/backend-plugin-api';\nimport { eventsServiceRef } from '@backstage/plugin-events-node';\nimport { AzureDevOpsEventRouter } from '../router/AzureDevOpsEventRouter';\n\n/**\n * Module for the events-backend plugin, adding an event router for Azure DevOps.\n *\n * Registers the `AzureDevOpsEventRouter`.\n *\n * @alpha\n */\nexport const eventsModuleAzureDevOpsEventRouter = createBackendModule({\n pluginId: 'events',\n moduleId: 'azure-dev-ops-event-router',\n register(env) {\n env.registerInit({\n deps: {\n events: eventsServiceRef,\n },\n async init({ events }) {\n const eventRouter = new AzureDevOpsEventRouter({\n events,\n });\n await eventRouter.subscribe();\n },\n });\n },\n});\n"],"names":["createBackendModule","eventsServiceRef","AzureDevOpsEventRouter"],"mappings":";;;;;;;;AA2BO,MAAM,qCAAqCA,oCAAoB,CAAA;AAAA,EACpE,QAAU,EAAA,QAAA;AAAA,EACV,QAAU,EAAA,4BAAA;AAAA,EACV,SAAS,GAAK,EAAA;AACZ,IAAA,GAAA,CAAI,YAAa,CAAA;AAAA,MACf,IAAM,EAAA;AAAA,QACJ,MAAQ,EAAAC,iCAAA;AAAA,OACV;AAAA,MACA,MAAM,IAAA,CAAK,EAAE,MAAA,EAAU,EAAA;AACrB,QAAM,MAAA,WAAA,GAAc,IAAIC,6CAAuB,CAAA;AAAA,UAC7C,MAAA;AAAA,SACD,CAAA,CAAA;AACD,QAAA,MAAM,YAAY,SAAU,EAAA,CAAA;AAAA,OAC9B;AAAA,KACD,CAAA,CAAA;AAAA,GACH;AACF,CAAC;;;;;"}
@@ -3,8 +3,14 @@
3
3
  var pluginEventsNode = require('@backstage/plugin-events-node');
4
4
 
5
5
  class AzureDevOpsEventRouter extends pluginEventsNode.SubTopicEventRouter {
6
- constructor() {
7
- super("azureDevOps");
6
+ constructor(options) {
7
+ super({
8
+ events: options.events,
9
+ topic: "azureDevOps"
10
+ });
11
+ }
12
+ getSubscriberId() {
13
+ return "AzureDevOpsEventRouter";
8
14
  }
9
15
  determineSubTopic(params) {
10
16
  if ("eventType" in params.eventPayload) {
@@ -16,4 +22,4 @@ class AzureDevOpsEventRouter extends pluginEventsNode.SubTopicEventRouter {
16
22
  }
17
23
 
18
24
  exports.AzureDevOpsEventRouter = AzureDevOpsEventRouter;
19
- //# sourceMappingURL=AzureDevOpsEventRouter-0c5cf09d.cjs.js.map
25
+ //# sourceMappingURL=AzureDevOpsEventRouter-d0832ee6.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AzureDevOpsEventRouter-d0832ee6.cjs.js","sources":["../../src/router/AzureDevOpsEventRouter.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 EventParams,\n EventsService,\n SubTopicEventRouter,\n} from '@backstage/plugin-events-node';\n\n/**\n * Subscribes to the generic `azureDevOps` topic\n * and publishes the events under the more concrete sub-topic\n * depending on the `$.eventType` provided.\n *\n * @public\n */\nexport class AzureDevOpsEventRouter extends SubTopicEventRouter {\n constructor(options: { events: EventsService }) {\n super({\n events: options.events,\n topic: 'azureDevOps',\n });\n }\n\n protected getSubscriberId(): string {\n return 'AzureDevOpsEventRouter';\n }\n\n protected determineSubTopic(params: EventParams): string | undefined {\n if ('eventType' in (params.eventPayload as object)) {\n const payload = params.eventPayload as { eventType: string };\n return payload.eventType;\n }\n\n return undefined;\n }\n}\n"],"names":["SubTopicEventRouter"],"mappings":";;;;AA6BO,MAAM,+BAA+BA,oCAAoB,CAAA;AAAA,EAC9D,YAAY,OAAoC,EAAA;AAC9C,IAAM,KAAA,CAAA;AAAA,MACJ,QAAQ,OAAQ,CAAA,MAAA;AAAA,MAChB,KAAO,EAAA,aAAA;AAAA,KACR,CAAA,CAAA;AAAA,GACH;AAAA,EAEU,eAA0B,GAAA;AAClC,IAAO,OAAA,wBAAA,CAAA;AAAA,GACT;AAAA,EAEU,kBAAkB,MAAyC,EAAA;AACnE,IAAI,IAAA,WAAA,IAAgB,OAAO,YAAyB,EAAA;AAClD,MAAA,MAAM,UAAU,MAAO,CAAA,YAAA,CAAA;AACvB,MAAA,OAAO,OAAQ,CAAA,SAAA,CAAA;AAAA,KACjB;AAEA,IAAO,OAAA,KAAA,CAAA,CAAA;AAAA,GACT;AACF;;;;"}
package/dist/index.cjs.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var AzureDevOpsEventRouter = require('./cjs/AzureDevOpsEventRouter-0c5cf09d.cjs.js');
5
+ var AzureDevOpsEventRouter = require('./cjs/AzureDevOpsEventRouter-d0832ee6.cjs.js');
6
6
  require('@backstage/plugin-events-node');
7
7
 
8
8
 
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { SubTopicEventRouter, EventParams } from '@backstage/plugin-events-node';
1
+ import { SubTopicEventRouter, EventsService, EventParams } from '@backstage/plugin-events-node';
2
2
 
3
3
  /**
4
4
  * Subscribes to the generic `azureDevOps` topic
@@ -8,7 +8,10 @@ import { SubTopicEventRouter, EventParams } from '@backstage/plugin-events-node'
8
8
  * @public
9
9
  */
10
10
  declare class AzureDevOpsEventRouter extends SubTopicEventRouter {
11
- constructor();
11
+ constructor(options: {
12
+ events: EventsService;
13
+ });
14
+ protected getSubscriberId(): string;
12
15
  protected determineSubTopic(params: EventParams): string | undefined;
13
16
  }
14
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-events-backend-module-azure",
3
- "version": "0.1.21",
3
+ "version": "0.2.0-next.0",
4
4
  "main": "./dist/index.cjs.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "license": "Apache-2.0",
@@ -39,14 +39,13 @@
39
39
  "postpack": "backstage-cli package postpack"
40
40
  },
41
41
  "dependencies": {
42
- "@backstage/backend-plugin-api": "^0.6.11",
43
- "@backstage/plugin-events-node": "^0.2.20",
44
- "winston": "^3.2.1"
42
+ "@backstage/backend-plugin-api": "^0.6.13-next.0",
43
+ "@backstage/plugin-events-node": "^0.3.0-next.0"
45
44
  },
46
45
  "devDependencies": {
47
- "@backstage/backend-test-utils": "^0.3.1",
48
- "@backstage/cli": "^0.25.2",
49
- "@backstage/plugin-events-backend-test-utils": "^0.1.21"
46
+ "@backstage/backend-test-utils": "^0.3.3-next.0",
47
+ "@backstage/cli": "^0.25.3-next.0",
48
+ "@backstage/plugin-events-backend-test-utils": "^0.1.23-next.0"
50
49
  },
51
50
  "files": [
52
51
  "dist",
@@ -1 +0,0 @@
1
- {"version":3,"file":"AzureDevOpsEventRouter-0c5cf09d.cjs.js","sources":["../../src/router/AzureDevOpsEventRouter.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 EventParams,\n SubTopicEventRouter,\n} from '@backstage/plugin-events-node';\n\n/**\n * Subscribes to the generic `azureDevOps` topic\n * and publishes the events under the more concrete sub-topic\n * depending on the `$.eventType` provided.\n *\n * @public\n */\nexport class AzureDevOpsEventRouter extends SubTopicEventRouter {\n constructor() {\n super('azureDevOps');\n }\n\n protected determineSubTopic(params: EventParams): string | undefined {\n if ('eventType' in (params.eventPayload as object)) {\n const payload = params.eventPayload as { eventType: string };\n return payload.eventType;\n }\n\n return undefined;\n }\n}\n"],"names":["SubTopicEventRouter"],"mappings":";;;;AA4BO,MAAM,+BAA+BA,oCAAoB,CAAA;AAAA,EAC9D,WAAc,GAAA;AACZ,IAAA,KAAA,CAAM,aAAa,CAAA,CAAA;AAAA,GACrB;AAAA,EAEU,kBAAkB,MAAyC,EAAA;AACnE,IAAI,IAAA,WAAA,IAAgB,OAAO,YAAyB,EAAA;AAClD,MAAA,MAAM,UAAU,MAAO,CAAA,YAAA,CAAA;AACvB,MAAA,OAAO,OAAQ,CAAA,SAAA,CAAA;AAAA,KACjB;AAEA,IAAO,OAAA,KAAA,CAAA,CAAA;AAAA,GACT;AACF;;;;"}