@backstage/plugin-events-backend-module-gerrit 0.0.0-nightly-20221115024001
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 +22 -0
- package/README.md +42 -0
- package/alpha/package.json +6 -0
- package/dist/index.alpha.d.ts +33 -0
- package/dist/index.beta.d.ts +26 -0
- package/dist/index.cjs.js +40 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.d.ts +26 -0
- package/package.json +40 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# @backstage/plugin-events-backend-module-gerrit
|
|
2
|
+
|
|
3
|
+
## 0.0.0-nightly-20221115024001
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 25f6d7bddb: Adds a new module `gerrit` to plugin-events-backend.
|
|
8
|
+
|
|
9
|
+
The module adds a new event router `GerritEventRouter`.
|
|
10
|
+
|
|
11
|
+
The event router will re-publish events received at topic `gerrit`
|
|
12
|
+
under a more specific topic depending on their `$.type` value
|
|
13
|
+
(e.g., `gerrit.change-merged`).
|
|
14
|
+
|
|
15
|
+
Please find more information at
|
|
16
|
+
https://github.com/backstage/backstage/tree/master/plugins/events-backend-module-gerrit/README.md.
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- Updated dependencies
|
|
21
|
+
- @backstage/plugin-events-node@0.0.0-nightly-20221115024001
|
|
22
|
+
- @backstage/backend-plugin-api@0.0.0-nightly-20221115024001
|
package/README.md
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# events-backend-module-gerrit
|
|
2
|
+
|
|
3
|
+
Welcome to the `events-backend-module-gerrit` backend plugin!
|
|
4
|
+
|
|
5
|
+
This plugin is a module for the `events-backend` backend plugin
|
|
6
|
+
and extends it with an `GerritEventRouter`.
|
|
7
|
+
|
|
8
|
+
The event router will subscribe to the topic `gerrit`
|
|
9
|
+
and route the events to more concrete topics based on the value
|
|
10
|
+
of the provided `$.type` payload field.
|
|
11
|
+
|
|
12
|
+
Examples:
|
|
13
|
+
|
|
14
|
+
| `$.type` | topic |
|
|
15
|
+
| ---------------- | ----------------------- |
|
|
16
|
+
| `change-created` | `gerrit.change-created` |
|
|
17
|
+
| `change-merged` | `gerrit.change-merged` |
|
|
18
|
+
|
|
19
|
+
Please find all possible webhook event types at the
|
|
20
|
+
[official documentation](https://gerrit-review.googlesource.com/Documentation/cmd-stream-events.html#events).
|
|
21
|
+
|
|
22
|
+
## Installation
|
|
23
|
+
|
|
24
|
+
Install the [`events-backend` plugin](../events-backend/README.md).
|
|
25
|
+
|
|
26
|
+
Install this module:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
# From your Backstage root directory
|
|
30
|
+
yarn add --cwd packages/backend @backstage/plugin-events-backend-module-gerrit
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Add the event router to the `EventsBackend`:
|
|
34
|
+
|
|
35
|
+
```diff
|
|
36
|
+
+const gerritEventRouter = new GerritEventRouter();
|
|
37
|
+
|
|
38
|
+
EventsBackend
|
|
39
|
+
+ .addPublishers(gerritEventRouter)
|
|
40
|
+
+ .addSubscribers(gerritEventRouter);
|
|
41
|
+
// [...]
|
|
42
|
+
```
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The module `gerrit` for the Backstage backend plugin "events-backend"
|
|
3
|
+
* adding an event router for Gerrit.
|
|
4
|
+
*
|
|
5
|
+
* @packageDocumentation
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { BackendFeature } from '@backstage/backend-plugin-api';
|
|
9
|
+
import { EventParams } from '@backstage/plugin-events-node';
|
|
10
|
+
import { SubTopicEventRouter } from '@backstage/plugin-events-node';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Subscribes to the generic `gerrit` topic
|
|
14
|
+
* and publishes the events under the more concrete sub-topic
|
|
15
|
+
* depending on the `$.type` field provided.
|
|
16
|
+
*
|
|
17
|
+
* @public
|
|
18
|
+
*/
|
|
19
|
+
export declare class GerritEventRouter extends SubTopicEventRouter {
|
|
20
|
+
constructor();
|
|
21
|
+
protected determineSubTopic(params: EventParams): string | undefined;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Module for the events-backend plugin, adding an event router for Gerrit.
|
|
26
|
+
*
|
|
27
|
+
* Registers the {@link GerritEventRouter}.
|
|
28
|
+
*
|
|
29
|
+
* @alpha
|
|
30
|
+
*/
|
|
31
|
+
export declare const gerritEventRouterEventsModule: (options?: undefined) => BackendFeature;
|
|
32
|
+
|
|
33
|
+
export { }
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The module `gerrit` for the Backstage backend plugin "events-backend"
|
|
3
|
+
* adding an event router for Gerrit.
|
|
4
|
+
*
|
|
5
|
+
* @packageDocumentation
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { BackendFeature } from '@backstage/backend-plugin-api';
|
|
9
|
+
import { EventParams } from '@backstage/plugin-events-node';
|
|
10
|
+
import { SubTopicEventRouter } from '@backstage/plugin-events-node';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Subscribes to the generic `gerrit` topic
|
|
14
|
+
* and publishes the events under the more concrete sub-topic
|
|
15
|
+
* depending on the `$.type` field provided.
|
|
16
|
+
*
|
|
17
|
+
* @public
|
|
18
|
+
*/
|
|
19
|
+
export declare class GerritEventRouter extends SubTopicEventRouter {
|
|
20
|
+
constructor();
|
|
21
|
+
protected determineSubTopic(params: EventParams): string | undefined;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/* Excluded from this release type: gerritEventRouterEventsModule */
|
|
25
|
+
|
|
26
|
+
export { }
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var pluginEventsNode = require('@backstage/plugin-events-node');
|
|
6
|
+
var backendPluginApi = require('@backstage/backend-plugin-api');
|
|
7
|
+
|
|
8
|
+
class GerritEventRouter extends pluginEventsNode.SubTopicEventRouter {
|
|
9
|
+
constructor() {
|
|
10
|
+
super("gerrit");
|
|
11
|
+
}
|
|
12
|
+
determineSubTopic(params) {
|
|
13
|
+
if ("type" in params.eventPayload) {
|
|
14
|
+
const payload = params.eventPayload;
|
|
15
|
+
return payload.type;
|
|
16
|
+
}
|
|
17
|
+
return void 0;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const gerritEventRouterEventsModule = backendPluginApi.createBackendModule({
|
|
22
|
+
pluginId: "events",
|
|
23
|
+
moduleId: "gerritEventRouter",
|
|
24
|
+
register(env) {
|
|
25
|
+
env.registerInit({
|
|
26
|
+
deps: {
|
|
27
|
+
events: pluginEventsNode.eventsExtensionPoint
|
|
28
|
+
},
|
|
29
|
+
async init({ events }) {
|
|
30
|
+
const eventRouter = new GerritEventRouter();
|
|
31
|
+
events.addPublishers(eventRouter);
|
|
32
|
+
events.addSubscribers(eventRouter);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
exports.GerritEventRouter = GerritEventRouter;
|
|
39
|
+
exports.gerritEventRouterEventsModule = gerritEventRouterEventsModule;
|
|
40
|
+
//# sourceMappingURL=index.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":["../src/router/GerritEventRouter.ts","../src/service/GerritEventRouterEventsModule.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","/*\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';\nimport { GerritEventRouter } from '../router/GerritEventRouter';\n\n/**\n * Module for the events-backend plugin, adding an event router for Gerrit.\n *\n * Registers the {@link GerritEventRouter}.\n *\n * @alpha\n */\nexport const gerritEventRouterEventsModule = createBackendModule({\n pluginId: 'events',\n moduleId: 'gerritEventRouter',\n register(env) {\n env.registerInit({\n deps: {\n events: eventsExtensionPoint,\n },\n async init({ events }) {\n const eventRouter = new GerritEventRouter();\n\n events.addPublishers(eventRouter);\n events.addSubscribers(eventRouter);\n },\n });\n },\n});\n"],"names":["SubTopicEventRouter","createBackendModule","eventsExtensionPoint"],"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;;ACdO,MAAM,gCAAgCC,oCAAoB,CAAA;AAAA,EAC/D,QAAU,EAAA,QAAA;AAAA,EACV,QAAU,EAAA,mBAAA;AAAA,EACV,SAAS,GAAK,EAAA;AACZ,IAAA,GAAA,CAAI,YAAa,CAAA;AAAA,MACf,IAAM,EAAA;AAAA,QACJ,MAAQ,EAAAC,qCAAA;AAAA,OACV;AAAA,MACA,MAAM,IAAA,CAAK,EAAE,MAAA,EAAU,EAAA;AACrB,QAAM,MAAA,WAAA,GAAc,IAAI,iBAAkB,EAAA,CAAA;AAE1C,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;;;;;"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The module `gerrit` for the Backstage backend plugin "events-backend"
|
|
3
|
+
* adding an event router for Gerrit.
|
|
4
|
+
*
|
|
5
|
+
* @packageDocumentation
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { BackendFeature } from '@backstage/backend-plugin-api';
|
|
9
|
+
import { EventParams } from '@backstage/plugin-events-node';
|
|
10
|
+
import { SubTopicEventRouter } from '@backstage/plugin-events-node';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Subscribes to the generic `gerrit` topic
|
|
14
|
+
* and publishes the events under the more concrete sub-topic
|
|
15
|
+
* depending on the `$.type` field provided.
|
|
16
|
+
*
|
|
17
|
+
* @public
|
|
18
|
+
*/
|
|
19
|
+
export declare class GerritEventRouter extends SubTopicEventRouter {
|
|
20
|
+
constructor();
|
|
21
|
+
protected determineSubTopic(params: EventParams): string | undefined;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/* Excluded from this release type: gerritEventRouterEventsModule */
|
|
25
|
+
|
|
26
|
+
export { }
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@backstage/plugin-events-backend-module-gerrit",
|
|
3
|
+
"version": "0.0.0-nightly-20221115024001",
|
|
4
|
+
"main": "dist/index.cjs.js",
|
|
5
|
+
"types": "dist/index.d.ts",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"publishConfig": {
|
|
8
|
+
"access": "public",
|
|
9
|
+
"alphaTypes": "dist/index.alpha.d.ts",
|
|
10
|
+
"main": "dist/index.cjs.js",
|
|
11
|
+
"types": "dist/index.d.ts"
|
|
12
|
+
},
|
|
13
|
+
"backstage": {
|
|
14
|
+
"role": "backend-plugin-module"
|
|
15
|
+
},
|
|
16
|
+
"scripts": {
|
|
17
|
+
"start": "backstage-cli package start",
|
|
18
|
+
"build": "backstage-cli package build --experimental-type-build",
|
|
19
|
+
"lint": "backstage-cli package lint",
|
|
20
|
+
"test": "backstage-cli package test",
|
|
21
|
+
"clean": "backstage-cli package clean",
|
|
22
|
+
"prepack": "backstage-cli package prepack",
|
|
23
|
+
"postpack": "backstage-cli package postpack"
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@backstage/backend-plugin-api": "^0.0.0-nightly-20221115024001",
|
|
27
|
+
"@backstage/plugin-events-node": "^0.0.0-nightly-20221115024001",
|
|
28
|
+
"winston": "^3.2.1"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@backstage/backend-test-utils": "^0.0.0-nightly-20221115024001",
|
|
32
|
+
"@backstage/cli": "^0.0.0-nightly-20221115024001",
|
|
33
|
+
"@backstage/plugin-events-backend-test-utils": "^0.0.0-nightly-20221115024001",
|
|
34
|
+
"supertest": "^6.1.3"
|
|
35
|
+
},
|
|
36
|
+
"files": [
|
|
37
|
+
"alpha",
|
|
38
|
+
"dist"
|
|
39
|
+
]
|
|
40
|
+
}
|