@backstage/plugin-events-backend-module-gerrit 0.1.22 → 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 +75 -13
- package/README.md +9 -19
- package/alpha/package.json +1 -1
- package/dist/alpha.cjs.js +5 -7
- package/dist/alpha.cjs.js.map +1 -1
- package/dist/cjs/{GerritEventRouter-21791cb7.cjs.js → GerritEventRouter-076aa57d.cjs.js} +9 -3
- package/dist/cjs/GerritEventRouter-076aa57d.cjs.js.map +1 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.d.ts +5 -2
- package/package.json +6 -7
- package/dist/cjs/GerritEventRouter-21791cb7.cjs.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,20 +1,82 @@
|
|
|
1
1
|
# @backstage/plugin-events-backend-module-gerrit
|
|
2
2
|
|
|
3
|
-
## 0.
|
|
3
|
+
## 0.2.0-next.0
|
|
4
4
|
|
|
5
|
-
###
|
|
6
|
-
|
|
7
|
-
- Updated dependencies
|
|
8
|
-
- @backstage/backend-plugin-api@0.6.12
|
|
9
|
-
- @backstage/plugin-events-node@0.2.21
|
|
10
|
-
|
|
11
|
-
## 0.1.21
|
|
12
|
-
|
|
13
|
-
### Patch Changes
|
|
5
|
+
### Minor Changes
|
|
14
6
|
|
|
15
|
-
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
|
18
80
|
|
|
19
81
|
## 0.1.20
|
|
20
82
|
|
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# events-backend-module-gerrit
|
|
2
2
|
|
|
3
|
-
Welcome to the `events-backend-module-gerrit` backend
|
|
3
|
+
Welcome to the `events-backend-module-gerrit` backend module!
|
|
4
4
|
|
|
5
|
-
This
|
|
5
|
+
This package is a module for the `events-backend` backend plugin
|
|
6
6
|
and extends it with an `GerritEventRouter`.
|
|
7
7
|
|
|
8
8
|
The event router will subscribe to the topic `gerrit`
|
|
@@ -21,30 +21,20 @@ Please find all possible webhook event types at the
|
|
|
21
21
|
|
|
22
22
|
## Installation
|
|
23
23
|
|
|
24
|
-
Install the [`events-backend` plugin](../events-backend/README.md).
|
|
25
|
-
|
|
26
|
-
Install this module:
|
|
27
|
-
|
|
28
24
|
```bash
|
|
29
25
|
# From your Backstage root directory
|
|
30
26
|
yarn --cwd packages/backend add @backstage/plugin-events-backend-module-gerrit
|
|
31
27
|
```
|
|
32
28
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
```ts title="packages/backend/src/index.ts"
|
|
29
|
+
```ts
|
|
30
|
+
// packages/backend/src/index.ts
|
|
36
31
|
backend.add(import('@backstage/plugin-events-backend-module-gerrit/alpha'));
|
|
37
32
|
```
|
|
38
33
|
|
|
39
|
-
###
|
|
40
|
-
|
|
41
|
-
Add the event router to the `EventsBackend` instance in `packages/backend/src/plugins/events.ts`:
|
|
42
|
-
|
|
43
|
-
```diff
|
|
44
|
-
+const gerritEventRouter = new GerritEventRouter();
|
|
34
|
+
### Legacy Backend System
|
|
45
35
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
36
|
+
```ts
|
|
37
|
+
// packages/backend/src/plugins/events.ts
|
|
38
|
+
const eventRouter = new GerritEventRouter({ events: env.events });
|
|
39
|
+
await eventRouter.subscribe();
|
|
50
40
|
```
|
package/alpha/package.json
CHANGED
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
|
|
7
|
-
var GerritEventRouter = require('./cjs/GerritEventRouter-
|
|
8
|
-
require('@backstage/plugin-events-node');
|
|
6
|
+
var pluginEventsNode = require('@backstage/plugin-events-node');
|
|
7
|
+
var GerritEventRouter = require('./cjs/GerritEventRouter-076aa57d.cjs.js');
|
|
9
8
|
|
|
10
9
|
const eventsModuleGerritEventRouter = backendPluginApi.createBackendModule({
|
|
11
10
|
pluginId: "events",
|
|
@@ -13,12 +12,11 @@ const eventsModuleGerritEventRouter = backendPluginApi.createBackendModule({
|
|
|
13
12
|
register(env) {
|
|
14
13
|
env.registerInit({
|
|
15
14
|
deps: {
|
|
16
|
-
events:
|
|
15
|
+
events: pluginEventsNode.eventsServiceRef
|
|
17
16
|
},
|
|
18
17
|
async init({ events }) {
|
|
19
|
-
const eventRouter = new GerritEventRouter.GerritEventRouter();
|
|
20
|
-
|
|
21
|
-
events.addSubscribers(eventRouter);
|
|
18
|
+
const eventRouter = new GerritEventRouter.GerritEventRouter({ events });
|
|
19
|
+
await eventRouter.subscribe();
|
|
22
20
|
}
|
|
23
21
|
});
|
|
24
22
|
}
|
package/dist/alpha.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alpha.cjs.js","sources":["../src/service/eventsModuleGerritEventRouter.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 {
|
|
1
|
+
{"version":3,"file":"alpha.cjs.js","sources":["../src/service/eventsModuleGerritEventRouter.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 { GerritEventRouter } from '../router/GerritEventRouter';\n\n/**\n * Module for the events-backend plugin, adding an event router for Gerrit.\n *\n * Registers the `GerritEventRouter`.\n *\n * @alpha\n */\nexport const eventsModuleGerritEventRouter = createBackendModule({\n pluginId: 'events',\n moduleId: 'gerrit-event-router',\n register(env) {\n env.registerInit({\n deps: {\n events: eventsServiceRef,\n },\n async init({ events }) {\n const eventRouter = new GerritEventRouter({ events });\n await eventRouter.subscribe();\n },\n });\n },\n});\n"],"names":["createBackendModule","eventsServiceRef","GerritEventRouter"],"mappings":";;;;;;;;AA2BO,MAAM,gCAAgCA,oCAAoB,CAAA;AAAA,EAC/D,QAAU,EAAA,QAAA;AAAA,EACV,QAAU,EAAA,qBAAA;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,QAAA,MAAM,WAAc,GAAA,IAAIC,mCAAkB,CAAA,EAAE,QAAQ,CAAA,CAAA;AACpD,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 GerritEventRouter extends pluginEventsNode.SubTopicEventRouter {
|
|
6
|
-
constructor() {
|
|
7
|
-
super(
|
|
6
|
+
constructor(options) {
|
|
7
|
+
super({
|
|
8
|
+
events: options.events,
|
|
9
|
+
topic: "gerrit"
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
getSubscriberId() {
|
|
13
|
+
return "GerritEventRouter";
|
|
8
14
|
}
|
|
9
15
|
determineSubTopic(params) {
|
|
10
16
|
if ("type" in params.eventPayload) {
|
|
@@ -16,4 +22,4 @@ class GerritEventRouter extends pluginEventsNode.SubTopicEventRouter {
|
|
|
16
22
|
}
|
|
17
23
|
|
|
18
24
|
exports.GerritEventRouter = GerritEventRouter;
|
|
19
|
-
//# sourceMappingURL=GerritEventRouter-
|
|
25
|
+
//# sourceMappingURL=GerritEventRouter-076aa57d.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GerritEventRouter-076aa57d.cjs.js","sources":["../../src/router/GerritEventRouter.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 `gerrit` topic\n * and publishes the events under the more concrete sub-topic\n * depending on the `$.type` field provided.\n *\n * @public\n */\nexport class GerritEventRouter extends SubTopicEventRouter {\n constructor(options: { events: EventsService }) {\n super({\n events: options.events,\n topic: 'gerrit',\n });\n }\n\n protected getSubscriberId(): string {\n return 'GerritEventRouter';\n }\n\n protected determineSubTopic(params: EventParams): string | undefined {\n if ('type' in (params.eventPayload as object)) {\n const payload = params.eventPayload as { type: string };\n return payload.type;\n }\n\n return undefined;\n }\n}\n"],"names":["SubTopicEventRouter"],"mappings":";;;;AA6BO,MAAM,0BAA0BA,oCAAoB,CAAA;AAAA,EACzD,YAAY,OAAoC,EAAA;AAC9C,IAAM,KAAA,CAAA;AAAA,MACJ,QAAQ,OAAQ,CAAA,MAAA;AAAA,MAChB,KAAO,EAAA,QAAA;AAAA,KACR,CAAA,CAAA;AAAA,GACH;AAAA,EAEU,eAA0B,GAAA;AAClC,IAAO,OAAA,mBAAA,CAAA;AAAA,GACT;AAAA,EAEU,kBAAkB,MAAyC,EAAA;AACnE,IAAI,IAAA,MAAA,IAAW,OAAO,YAAyB,EAAA;AAC7C,MAAA,MAAM,UAAU,MAAO,CAAA,YAAA,CAAA;AACvB,MAAA,OAAO,OAAQ,CAAA,IAAA,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 GerritEventRouter = require('./cjs/GerritEventRouter-
|
|
5
|
+
var GerritEventRouter = require('./cjs/GerritEventRouter-076aa57d.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 `gerrit` topic
|
|
@@ -8,7 +8,10 @@ import { SubTopicEventRouter, EventParams } from '@backstage/plugin-events-node'
|
|
|
8
8
|
* @public
|
|
9
9
|
*/
|
|
10
10
|
declare class GerritEventRouter 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-gerrit",
|
|
3
|
-
"version": "0.
|
|
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.
|
|
43
|
-
"@backstage/plugin-events-node": "^0.
|
|
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.
|
|
48
|
-
"@backstage/cli": "^0.25.
|
|
49
|
-
"@backstage/plugin-events-backend-test-utils": "^0.1.
|
|
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":"GerritEventRouter-21791cb7.cjs.js","sources":["../../src/router/GerritEventRouter.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 `gerrit` topic\n * and publishes the events under the more concrete sub-topic\n * depending on the `$.type` field provided.\n *\n * @public\n */\nexport class GerritEventRouter extends SubTopicEventRouter {\n constructor() {\n super('gerrit');\n }\n\n protected determineSubTopic(params: EventParams): string | undefined {\n if ('type' in (params.eventPayload as object)) {\n const payload = params.eventPayload as { type: string };\n return payload.type;\n }\n\n return undefined;\n }\n}\n"],"names":["SubTopicEventRouter"],"mappings":";;;;AA4BO,MAAM,0BAA0BA,oCAAoB,CAAA;AAAA,EACzD,WAAc,GAAA;AACZ,IAAA,KAAA,CAAM,QAAQ,CAAA,CAAA;AAAA,GAChB;AAAA,EAEU,kBAAkB,MAAyC,EAAA;AACnE,IAAI,IAAA,MAAA,IAAW,OAAO,YAAyB,EAAA;AAC7C,MAAA,MAAM,UAAU,MAAO,CAAA,YAAA,CAAA;AACvB,MAAA,OAAO,OAAQ,CAAA,IAAA,CAAA;AAAA,KACjB;AAEA,IAAO,OAAA,KAAA,CAAA,CAAA;AAAA,GACT;AACF;;;;"}
|