@backstage/plugin-events-backend 0.3.12 → 0.3.13-next.1
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 +31 -0
- package/alpha/package.json +1 -1
- package/dist/alpha.cjs.js +2 -71
- package/dist/alpha.cjs.js.map +1 -1
- package/dist/index.cjs.js +5 -61
- package/dist/index.cjs.js.map +1 -1
- package/dist/schema/openapi.generated.cjs.js +272 -0
- package/dist/schema/openapi.generated.cjs.js.map +1 -0
- package/dist/service/DefaultEventBroker.cjs.js +32 -0
- package/dist/service/DefaultEventBroker.cjs.js.map +1 -0
- package/dist/service/EventsBackend.cjs.js +36 -0
- package/dist/service/EventsBackend.cjs.js.map +1 -0
- package/dist/service/EventsPlugin.cjs.js +98 -0
- package/dist/service/EventsPlugin.cjs.js.map +1 -0
- package/dist/{cjs/HttpPostIngressEventPublisher-D6pQ6awS.cjs.js → service/http/HttpPostIngressEventPublisher.cjs.js} +3 -18
- package/dist/service/http/HttpPostIngressEventPublisher.cjs.js.map +1 -0
- package/dist/service/http/validation/RequestValidationContextImpl.cjs.js +20 -0
- package/dist/service/http/validation/RequestValidationContextImpl.cjs.js.map +1 -0
- package/dist/service/hub/DatabaseEventBusStore.cjs.js +410 -0
- package/dist/service/hub/DatabaseEventBusStore.cjs.js.map +1 -0
- package/dist/service/hub/MemoryEventBusStore.cjs.js +106 -0
- package/dist/service/hub/MemoryEventBusStore.cjs.js.map +1 -0
- package/dist/service/hub/createEventBusRouter.cjs.js +130 -0
- package/dist/service/hub/createEventBusRouter.cjs.js.map +1 -0
- package/migrations/20240523100528_init.js +98 -0
- package/package.json +17 -8
- package/dist/cjs/HttpPostIngressEventPublisher-D6pQ6awS.cjs.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,36 @@
|
|
|
1
1
|
# @backstage/plugin-events-backend
|
|
2
2
|
|
|
3
|
+
## 0.3.13-next.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
- @backstage/backend-openapi-utils@0.2.0-next.1
|
|
9
|
+
- @backstage/backend-plugin-api@1.0.1-next.1
|
|
10
|
+
- @backstage/config@1.2.0
|
|
11
|
+
- @backstage/errors@1.2.4
|
|
12
|
+
- @backstage/types@1.1.1
|
|
13
|
+
- @backstage/plugin-events-node@0.4.1-next.1
|
|
14
|
+
|
|
15
|
+
## 0.3.13-next.0
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- 094eaa3: Remove references to in-repo backend-common
|
|
20
|
+
- 5c728ee: The events backend now has its own built-in event bus for distributing events across multiple backend instances. It exposes a new HTTP API under `/bus/v1/` for publishing and reading events from the bus, as well as its own storage and notification mechanism for events.
|
|
21
|
+
|
|
22
|
+
The backing event store for the bus only supports scaled deployment if PostgreSQL is used as the DBMS. If SQLite or MySQL is used, the event bus will fall back to an in-memory store that does not support multiple backend instances.
|
|
23
|
+
|
|
24
|
+
The default `EventsService` implementation from `@backstage/plugin-events-node` has also been updated to use the new events bus.
|
|
25
|
+
|
|
26
|
+
- Updated dependencies
|
|
27
|
+
- @backstage/plugin-events-node@0.4.1-next.0
|
|
28
|
+
- @backstage/backend-openapi-utils@0.1.19-next.0
|
|
29
|
+
- @backstage/backend-plugin-api@1.0.1-next.0
|
|
30
|
+
- @backstage/config@1.2.0
|
|
31
|
+
- @backstage/errors@1.2.4
|
|
32
|
+
- @backstage/types@1.1.1
|
|
33
|
+
|
|
3
34
|
## 0.3.12
|
|
4
35
|
|
|
5
36
|
### Patch Changes
|
package/alpha/package.json
CHANGED
package/dist/alpha.cjs.js
CHANGED
|
@@ -2,78 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
6
|
-
var alpha = require('@backstage/plugin-events-node/alpha');
|
|
7
|
-
var pluginEventsNode = require('@backstage/plugin-events-node');
|
|
8
|
-
var Router = require('express-promise-router');
|
|
9
|
-
var HttpPostIngressEventPublisher = require('./cjs/HttpPostIngressEventPublisher-D6pQ6awS.cjs.js');
|
|
10
|
-
require('@backstage/backend-common');
|
|
11
|
-
require('express');
|
|
5
|
+
var EventsPlugin = require('./service/EventsPlugin.cjs.js');
|
|
12
6
|
|
|
13
|
-
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
14
7
|
|
|
15
|
-
var Router__default = /*#__PURE__*/_interopDefaultCompat(Router);
|
|
16
8
|
|
|
17
|
-
|
|
18
|
-
#httpPostIngresses = [];
|
|
19
|
-
setEventBroker(_) {
|
|
20
|
-
throw new Error(
|
|
21
|
-
"setEventBroker is not supported anymore; use eventsServiceRef instead"
|
|
22
|
-
);
|
|
23
|
-
}
|
|
24
|
-
addPublishers(_) {
|
|
25
|
-
throw new Error(
|
|
26
|
-
"addPublishers is not supported anymore; use EventsService instead"
|
|
27
|
-
);
|
|
28
|
-
}
|
|
29
|
-
addSubscribers(_) {
|
|
30
|
-
throw new Error(
|
|
31
|
-
"addSubscribers is not supported anymore; use EventsService instead"
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
addHttpPostIngress(options) {
|
|
35
|
-
this.#httpPostIngresses.push(options);
|
|
36
|
-
}
|
|
37
|
-
get httpPostIngresses() {
|
|
38
|
-
return this.#httpPostIngresses;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
const eventsPlugin = backendPluginApi.createBackendPlugin({
|
|
42
|
-
pluginId: "events",
|
|
43
|
-
register(env) {
|
|
44
|
-
const extensionPoint = new EventsExtensionPointImpl();
|
|
45
|
-
env.registerExtensionPoint(alpha.eventsExtensionPoint, extensionPoint);
|
|
46
|
-
env.registerInit({
|
|
47
|
-
deps: {
|
|
48
|
-
config: backendPluginApi.coreServices.rootConfig,
|
|
49
|
-
events: pluginEventsNode.eventsServiceRef,
|
|
50
|
-
logger: backendPluginApi.coreServices.logger,
|
|
51
|
-
router: backendPluginApi.coreServices.httpRouter
|
|
52
|
-
},
|
|
53
|
-
async init({ config, events, logger, router }) {
|
|
54
|
-
const ingresses = Object.fromEntries(
|
|
55
|
-
extensionPoint.httpPostIngresses.map((ingress) => [
|
|
56
|
-
ingress.topic,
|
|
57
|
-
ingress
|
|
58
|
-
])
|
|
59
|
-
);
|
|
60
|
-
const http = HttpPostIngressEventPublisher.HttpPostIngressEventPublisher.fromConfig({
|
|
61
|
-
config,
|
|
62
|
-
events,
|
|
63
|
-
ingresses,
|
|
64
|
-
logger
|
|
65
|
-
});
|
|
66
|
-
const eventsRouter = Router__default.default();
|
|
67
|
-
http.bind(eventsRouter);
|
|
68
|
-
router.use(eventsRouter);
|
|
69
|
-
router.addAuthPolicy({
|
|
70
|
-
allow: "unauthenticated",
|
|
71
|
-
path: "/http"
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
exports.default = eventsPlugin;
|
|
9
|
+
exports.default = EventsPlugin.eventsPlugin;
|
|
79
10
|
//# sourceMappingURL=alpha.cjs.js.map
|
package/dist/alpha.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alpha.cjs.js","sources":[
|
|
1
|
+
{"version":3,"file":"alpha.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;"}
|
package/dist/index.cjs.js
CHANGED
|
@@ -1,68 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
require('
|
|
6
|
-
require('express');
|
|
7
|
-
require('express-promise-router');
|
|
3
|
+
var EventsBackend = require('./service/EventsBackend.cjs.js');
|
|
4
|
+
var DefaultEventBroker = require('./service/DefaultEventBroker.cjs.js');
|
|
5
|
+
var HttpPostIngressEventPublisher = require('./service/http/HttpPostIngressEventPublisher.cjs.js');
|
|
8
6
|
|
|
9
|
-
class DefaultEventBroker {
|
|
10
|
-
events;
|
|
11
|
-
/**
|
|
12
|
-
*
|
|
13
|
-
* @param logger - logger
|
|
14
|
-
* @param events - replacement that gets wrapped to support not yet migrated implementations.
|
|
15
|
-
* An instance can be passed (required for a mixed mode), otherwise a new instance gets created internally.
|
|
16
|
-
* @deprecated use `DefaultEventsService` directly instead
|
|
17
|
-
*/
|
|
18
|
-
constructor(logger, events) {
|
|
19
|
-
this.events = events ?? pluginEventsNode.DefaultEventsService.create({ logger });
|
|
20
|
-
}
|
|
21
|
-
async publish(params) {
|
|
22
|
-
return this.events.publish(params);
|
|
23
|
-
}
|
|
24
|
-
subscribe(...subscribers) {
|
|
25
|
-
subscribers.flat().forEach(async (subscriber) => {
|
|
26
|
-
await this.events.subscribe({
|
|
27
|
-
id: subscriber.constructor.name,
|
|
28
|
-
topics: subscriber.supportsEventTopics(),
|
|
29
|
-
onEvent: subscriber.onEvent.bind(subscriber)
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
7
|
|
|
35
|
-
class EventsBackend {
|
|
36
|
-
eventBroker;
|
|
37
|
-
publishers = [];
|
|
38
|
-
subscribers = [];
|
|
39
|
-
constructor(logger) {
|
|
40
|
-
this.eventBroker = new DefaultEventBroker(logger);
|
|
41
|
-
}
|
|
42
|
-
setEventBroker(eventBroker) {
|
|
43
|
-
this.eventBroker = eventBroker;
|
|
44
|
-
return this;
|
|
45
|
-
}
|
|
46
|
-
addPublishers(...publishers) {
|
|
47
|
-
this.publishers.push(...publishers.flat());
|
|
48
|
-
return this;
|
|
49
|
-
}
|
|
50
|
-
addSubscribers(...subscribers) {
|
|
51
|
-
this.subscribers.push(...subscribers.flat());
|
|
52
|
-
return this;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Wires up and returns all component parts of the event management.
|
|
56
|
-
*/
|
|
57
|
-
async start() {
|
|
58
|
-
this.eventBroker.subscribe(this.subscribers);
|
|
59
|
-
this.publishers.forEach(
|
|
60
|
-
(publisher) => publisher.setEventBroker(this.eventBroker)
|
|
61
|
-
);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
8
|
|
|
9
|
+
exports.EventsBackend = EventsBackend.EventsBackend;
|
|
10
|
+
exports.DefaultEventBroker = DefaultEventBroker.DefaultEventBroker;
|
|
65
11
|
exports.HttpPostIngressEventPublisher = HttpPostIngressEventPublisher.HttpPostIngressEventPublisher;
|
|
66
|
-
exports.DefaultEventBroker = DefaultEventBroker;
|
|
67
|
-
exports.EventsBackend = EventsBackend;
|
|
68
12
|
//# sourceMappingURL=index.cjs.js.map
|
package/dist/index.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs.js","sources":[
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;"}
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var backendOpenapiUtils = require('@backstage/backend-openapi-utils');
|
|
4
|
+
|
|
5
|
+
const spec = {
|
|
6
|
+
openapi: "3.0.3",
|
|
7
|
+
info: {
|
|
8
|
+
title: "events",
|
|
9
|
+
version: "1",
|
|
10
|
+
description: "The Backstage backend plugin that powers the events system.",
|
|
11
|
+
license: {
|
|
12
|
+
name: "Apache-2.0",
|
|
13
|
+
url: "http://www.apache.org/licenses/LICENSE-2.0.html"
|
|
14
|
+
},
|
|
15
|
+
contact: {}
|
|
16
|
+
},
|
|
17
|
+
servers: [
|
|
18
|
+
{
|
|
19
|
+
url: "/"
|
|
20
|
+
}
|
|
21
|
+
],
|
|
22
|
+
components: {
|
|
23
|
+
examples: {},
|
|
24
|
+
headers: {},
|
|
25
|
+
parameters: {
|
|
26
|
+
subscriptionId: {
|
|
27
|
+
name: "subscriptionId",
|
|
28
|
+
in: "path",
|
|
29
|
+
required: true,
|
|
30
|
+
allowReserved: true,
|
|
31
|
+
schema: {
|
|
32
|
+
type: "string"
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
requestBodies: {},
|
|
37
|
+
responses: {
|
|
38
|
+
ErrorResponse: {
|
|
39
|
+
description: "An error response from the backend.",
|
|
40
|
+
content: {
|
|
41
|
+
"application/json; charset=utf-8": {
|
|
42
|
+
schema: {
|
|
43
|
+
$ref: "#/components/schemas/Error"
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
schemas: {
|
|
50
|
+
Event: {
|
|
51
|
+
type: "object",
|
|
52
|
+
required: ["topic", "payload"],
|
|
53
|
+
properties: {
|
|
54
|
+
topic: {
|
|
55
|
+
type: "string",
|
|
56
|
+
description: "The topic that the event is published on"
|
|
57
|
+
},
|
|
58
|
+
payload: {
|
|
59
|
+
description: "The event payload"
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
Error: {
|
|
64
|
+
type: "object",
|
|
65
|
+
properties: {
|
|
66
|
+
error: {
|
|
67
|
+
type: "object",
|
|
68
|
+
properties: {
|
|
69
|
+
name: {
|
|
70
|
+
type: "string"
|
|
71
|
+
},
|
|
72
|
+
message: {
|
|
73
|
+
type: "string"
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
required: ["name", "message"]
|
|
77
|
+
},
|
|
78
|
+
request: {
|
|
79
|
+
type: "object",
|
|
80
|
+
properties: {
|
|
81
|
+
method: {
|
|
82
|
+
type: "string"
|
|
83
|
+
},
|
|
84
|
+
url: {
|
|
85
|
+
type: "string"
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
required: ["method", "url"]
|
|
89
|
+
},
|
|
90
|
+
response: {
|
|
91
|
+
type: "object",
|
|
92
|
+
properties: {
|
|
93
|
+
statusCode: {
|
|
94
|
+
type: "number"
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
required: ["statusCode"]
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
required: ["error", "request", "response"]
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
securitySchemes: {
|
|
104
|
+
JWT: {
|
|
105
|
+
type: "http",
|
|
106
|
+
scheme: "bearer",
|
|
107
|
+
bearerFormat: "JWT"
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
paths: {
|
|
112
|
+
"/bus/v1/events": {
|
|
113
|
+
post: {
|
|
114
|
+
operationId: "PostEvent",
|
|
115
|
+
description: "Publish a new event",
|
|
116
|
+
responses: {
|
|
117
|
+
"201": {
|
|
118
|
+
description: "The event was published successfully"
|
|
119
|
+
},
|
|
120
|
+
"204": {
|
|
121
|
+
description: "The event did not need to be published as all subscribers have already been notified"
|
|
122
|
+
},
|
|
123
|
+
default: {
|
|
124
|
+
$ref: "#/components/responses/ErrorResponse"
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
security: [
|
|
128
|
+
{},
|
|
129
|
+
{
|
|
130
|
+
JWT: []
|
|
131
|
+
}
|
|
132
|
+
],
|
|
133
|
+
requestBody: {
|
|
134
|
+
required: true,
|
|
135
|
+
content: {
|
|
136
|
+
"application/json": {
|
|
137
|
+
schema: {
|
|
138
|
+
type: "object",
|
|
139
|
+
required: ["event"],
|
|
140
|
+
properties: {
|
|
141
|
+
event: {
|
|
142
|
+
$ref: "#/components/schemas/Event"
|
|
143
|
+
},
|
|
144
|
+
notifiedSubscribers: {
|
|
145
|
+
type: "array",
|
|
146
|
+
description: "The IDs of subscriptions that have already received this event",
|
|
147
|
+
items: {
|
|
148
|
+
type: "string"
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
examples: {
|
|
154
|
+
"Publishing a simple Event": {
|
|
155
|
+
value: {
|
|
156
|
+
event: {
|
|
157
|
+
topic: "test-topic",
|
|
158
|
+
payload: {
|
|
159
|
+
myData: "foo"
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
"/bus/v1/subscriptions/{subscriptionId}": {
|
|
171
|
+
put: {
|
|
172
|
+
operationId: "PutSubscription",
|
|
173
|
+
description: "Ensures that the subscription exists with the provided configuration",
|
|
174
|
+
responses: {
|
|
175
|
+
"201": {
|
|
176
|
+
description: "The subscription exists or was created successfully"
|
|
177
|
+
},
|
|
178
|
+
default: {
|
|
179
|
+
$ref: "#/components/responses/ErrorResponse"
|
|
180
|
+
}
|
|
181
|
+
},
|
|
182
|
+
security: [
|
|
183
|
+
{},
|
|
184
|
+
{
|
|
185
|
+
JWT: []
|
|
186
|
+
}
|
|
187
|
+
],
|
|
188
|
+
parameters: [
|
|
189
|
+
{
|
|
190
|
+
$ref: "#/components/parameters/subscriptionId"
|
|
191
|
+
}
|
|
192
|
+
],
|
|
193
|
+
requestBody: {
|
|
194
|
+
required: true,
|
|
195
|
+
content: {
|
|
196
|
+
"application/json": {
|
|
197
|
+
schema: {
|
|
198
|
+
type: "object",
|
|
199
|
+
required: ["topics"],
|
|
200
|
+
properties: {
|
|
201
|
+
topics: {
|
|
202
|
+
type: "array",
|
|
203
|
+
description: "The topics to subscribe to",
|
|
204
|
+
items: {
|
|
205
|
+
type: "string"
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
},
|
|
210
|
+
examples: {
|
|
211
|
+
"Subscribing to a single topic": {
|
|
212
|
+
value: {
|
|
213
|
+
topics: ["test-topic"]
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
},
|
|
222
|
+
"/bus/v1/subscriptions/{subscriptionId}/events": {
|
|
223
|
+
get: {
|
|
224
|
+
operationId: "GetSubscriptionEvents",
|
|
225
|
+
description: "Get new events for the provided subscription",
|
|
226
|
+
responses: {
|
|
227
|
+
"200": {
|
|
228
|
+
description: "New events",
|
|
229
|
+
content: {
|
|
230
|
+
"application/json": {
|
|
231
|
+
schema: {
|
|
232
|
+
type: "object",
|
|
233
|
+
required: ["events"],
|
|
234
|
+
properties: {
|
|
235
|
+
events: {
|
|
236
|
+
type: "array",
|
|
237
|
+
items: {
|
|
238
|
+
$ref: "#/components/schemas/Event"
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
},
|
|
246
|
+
"202": {
|
|
247
|
+
description: "No new events are available. Response will block until the client should try again."
|
|
248
|
+
},
|
|
249
|
+
default: {
|
|
250
|
+
$ref: "#/components/responses/ErrorResponse"
|
|
251
|
+
}
|
|
252
|
+
},
|
|
253
|
+
security: [
|
|
254
|
+
{},
|
|
255
|
+
{
|
|
256
|
+
JWT: []
|
|
257
|
+
}
|
|
258
|
+
],
|
|
259
|
+
parameters: [
|
|
260
|
+
{
|
|
261
|
+
$ref: "#/components/parameters/subscriptionId"
|
|
262
|
+
}
|
|
263
|
+
]
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
};
|
|
268
|
+
const createOpenApiRouter = async (options) => backendOpenapiUtils.createValidatedOpenApiRouter(spec, options);
|
|
269
|
+
|
|
270
|
+
exports.createOpenApiRouter = createOpenApiRouter;
|
|
271
|
+
exports.spec = spec;
|
|
272
|
+
//# sourceMappingURL=openapi.generated.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openapi.generated.cjs.js","sources":["../../src/schema/openapi.generated.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\n// ******************************************************************\n// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. *\n// ******************************************************************\nimport { createValidatedOpenApiRouter } from '@backstage/backend-openapi-utils';\n\nexport const spec = {\n openapi: '3.0.3',\n info: {\n title: 'events',\n version: '1',\n description: 'The Backstage backend plugin that powers the events system.',\n license: {\n name: 'Apache-2.0',\n url: 'http://www.apache.org/licenses/LICENSE-2.0.html',\n },\n contact: {},\n },\n servers: [\n {\n url: '/',\n },\n ],\n components: {\n examples: {},\n headers: {},\n parameters: {\n subscriptionId: {\n name: 'subscriptionId',\n in: 'path',\n required: true,\n allowReserved: true,\n schema: {\n type: 'string',\n },\n },\n },\n requestBodies: {},\n responses: {\n ErrorResponse: {\n description: 'An error response from the backend.',\n content: {\n 'application/json; charset=utf-8': {\n schema: {\n $ref: '#/components/schemas/Error',\n },\n },\n },\n },\n },\n schemas: {\n Event: {\n type: 'object',\n required: ['topic', 'payload'],\n properties: {\n topic: {\n type: 'string',\n description: 'The topic that the event is published on',\n },\n payload: {\n description: 'The event payload',\n },\n },\n },\n Error: {\n type: 'object',\n properties: {\n error: {\n type: 'object',\n properties: {\n name: {\n type: 'string',\n },\n message: {\n type: 'string',\n },\n },\n required: ['name', 'message'],\n },\n request: {\n type: 'object',\n properties: {\n method: {\n type: 'string',\n },\n url: {\n type: 'string',\n },\n },\n required: ['method', 'url'],\n },\n response: {\n type: 'object',\n properties: {\n statusCode: {\n type: 'number',\n },\n },\n required: ['statusCode'],\n },\n },\n required: ['error', 'request', 'response'],\n },\n },\n securitySchemes: {\n JWT: {\n type: 'http',\n scheme: 'bearer',\n bearerFormat: 'JWT',\n },\n },\n },\n paths: {\n '/bus/v1/events': {\n post: {\n operationId: 'PostEvent',\n description: 'Publish a new event',\n responses: {\n '201': {\n description: 'The event was published successfully',\n },\n '204': {\n description:\n 'The event did not need to be published as all subscribers have already been notified',\n },\n default: {\n $ref: '#/components/responses/ErrorResponse',\n },\n },\n security: [\n {},\n {\n JWT: [],\n },\n ],\n requestBody: {\n required: true,\n content: {\n 'application/json': {\n schema: {\n type: 'object',\n required: ['event'],\n properties: {\n event: {\n $ref: '#/components/schemas/Event',\n },\n notifiedSubscribers: {\n type: 'array',\n description:\n 'The IDs of subscriptions that have already received this event',\n items: {\n type: 'string',\n },\n },\n },\n },\n examples: {\n 'Publishing a simple Event': {\n value: {\n event: {\n topic: 'test-topic',\n payload: {\n myData: 'foo',\n },\n },\n },\n },\n },\n },\n },\n },\n },\n },\n '/bus/v1/subscriptions/{subscriptionId}': {\n put: {\n operationId: 'PutSubscription',\n description:\n 'Ensures that the subscription exists with the provided configuration',\n responses: {\n '201': {\n description: 'The subscription exists or was created successfully',\n },\n default: {\n $ref: '#/components/responses/ErrorResponse',\n },\n },\n security: [\n {},\n {\n JWT: [],\n },\n ],\n parameters: [\n {\n $ref: '#/components/parameters/subscriptionId',\n },\n ],\n requestBody: {\n required: true,\n content: {\n 'application/json': {\n schema: {\n type: 'object',\n required: ['topics'],\n properties: {\n topics: {\n type: 'array',\n description: 'The topics to subscribe to',\n items: {\n type: 'string',\n },\n },\n },\n },\n examples: {\n 'Subscribing to a single topic': {\n value: {\n topics: ['test-topic'],\n },\n },\n },\n },\n },\n },\n },\n },\n '/bus/v1/subscriptions/{subscriptionId}/events': {\n get: {\n operationId: 'GetSubscriptionEvents',\n description: 'Get new events for the provided subscription',\n responses: {\n '200': {\n description: 'New events',\n content: {\n 'application/json': {\n schema: {\n type: 'object',\n required: ['events'],\n properties: {\n events: {\n type: 'array',\n items: {\n $ref: '#/components/schemas/Event',\n },\n },\n },\n },\n },\n },\n },\n '202': {\n description:\n 'No new events are available. Response will block until the client should try again.',\n },\n default: {\n $ref: '#/components/responses/ErrorResponse',\n },\n },\n security: [\n {},\n {\n JWT: [],\n },\n ],\n parameters: [\n {\n $ref: '#/components/parameters/subscriptionId',\n },\n ],\n },\n },\n },\n} as const;\nexport const createOpenApiRouter = async (\n options?: Parameters<typeof createValidatedOpenApiRouter>['1'],\n) => createValidatedOpenApiRouter<typeof spec>(spec, options);\n"],"names":["createValidatedOpenApiRouter"],"mappings":";;;;AAqBO,MAAM,IAAO,GAAA;AAAA,EAClB,OAAS,EAAA,OAAA;AAAA,EACT,IAAM,EAAA;AAAA,IACJ,KAAO,EAAA,QAAA;AAAA,IACP,OAAS,EAAA,GAAA;AAAA,IACT,WAAa,EAAA,6DAAA;AAAA,IACb,OAAS,EAAA;AAAA,MACP,IAAM,EAAA,YAAA;AAAA,MACN,GAAK,EAAA,iDAAA;AAAA,KACP;AAAA,IACA,SAAS,EAAC;AAAA,GACZ;AAAA,EACA,OAAS,EAAA;AAAA,IACP;AAAA,MACE,GAAK,EAAA,GAAA;AAAA,KACP;AAAA,GACF;AAAA,EACA,UAAY,EAAA;AAAA,IACV,UAAU,EAAC;AAAA,IACX,SAAS,EAAC;AAAA,IACV,UAAY,EAAA;AAAA,MACV,cAAgB,EAAA;AAAA,QACd,IAAM,EAAA,gBAAA;AAAA,QACN,EAAI,EAAA,MAAA;AAAA,QACJ,QAAU,EAAA,IAAA;AAAA,QACV,aAAe,EAAA,IAAA;AAAA,QACf,MAAQ,EAAA;AAAA,UACN,IAAM,EAAA,QAAA;AAAA,SACR;AAAA,OACF;AAAA,KACF;AAAA,IACA,eAAe,EAAC;AAAA,IAChB,SAAW,EAAA;AAAA,MACT,aAAe,EAAA;AAAA,QACb,WAAa,EAAA,qCAAA;AAAA,QACb,OAAS,EAAA;AAAA,UACP,iCAAmC,EAAA;AAAA,YACjC,MAAQ,EAAA;AAAA,cACN,IAAM,EAAA,4BAAA;AAAA,aACR;AAAA,WACF;AAAA,SACF;AAAA,OACF;AAAA,KACF;AAAA,IACA,OAAS,EAAA;AAAA,MACP,KAAO,EAAA;AAAA,QACL,I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iD,EAAA;AAAA,MAC/C,GAAK,EAAA;AAAA,QACH,WAAa,EAAA,uBAAA;AAAA,QACb,WAAa,EAAA,8CAAA;AAAA,QACb,SAAW,EAAA;AAAA,UACT,KAAO,EAAA;AAAA,YACL,WAAa,EAAA,YAAA;AAAA,YACb,OAAS,EAAA;AAAA,cACP,kBAAoB,EAAA;AAAA,gBAClB,MAAQ,EAAA;AAAA,kBACN,IAAM,EAAA,QAAA;AAAA,kBACN,QAAA,EAAU,CAAC,QAAQ,CAAA;AAAA,kBACnB,UAAY,EAAA;AAAA,oBACV,MAAQ,EAAA;AAAA,sBACN,IAAM,EAAA,OAAA;AAAA,sBACN,KAAO,EAAA;AAAA,wBACL,IAAM,EAAA,4BAAA;AAAA,uBACR;AAAA,qBACF;AAAA,mBACF;AAAA,iBACF;AAAA,eACF;AAAA,aACF;AAAA,WACF;AAAA,UACA,KAAO,EAAA;AAAA,YACL,WACE,EAAA,qFAAA;AAAA,WACJ;AAAA,UACA,OAAS,EAAA;AAAA,YACP,IAAM,EAAA,sCAAA;AAAA,WACR;AAAA,SACF;AAAA,QACA,QAAU,EAAA;AAAA,UACR,EAAC;AAAA,UACD;AAAA,YACE,KAAK,EAAC;AAAA,WACR;AAAA,SACF;AAAA,QACA,UAAY,EAAA;AAAA,UACV;AAAA,YACE,IAAM,EAAA,wCAAA;AAAA,WACR;AAAA,SACF;AAAA,OACF;AAAA,KACF;AAAA,GACF;AACF,EAAA;AACO,MAAM,mBAAsB,GAAA,OACjC,OACG,KAAAA,gDAAA,CAA0C,MAAM,OAAO;;;;;"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var pluginEventsNode = require('@backstage/plugin-events-node');
|
|
4
|
+
|
|
5
|
+
class DefaultEventBroker {
|
|
6
|
+
events;
|
|
7
|
+
/**
|
|
8
|
+
*
|
|
9
|
+
* @param logger - logger
|
|
10
|
+
* @param events - replacement that gets wrapped to support not yet migrated implementations.
|
|
11
|
+
* An instance can be passed (required for a mixed mode), otherwise a new instance gets created internally.
|
|
12
|
+
* @deprecated use `DefaultEventsService` directly instead
|
|
13
|
+
*/
|
|
14
|
+
constructor(logger, events) {
|
|
15
|
+
this.events = events ?? pluginEventsNode.DefaultEventsService.create({ logger });
|
|
16
|
+
}
|
|
17
|
+
async publish(params) {
|
|
18
|
+
return this.events.publish(params);
|
|
19
|
+
}
|
|
20
|
+
subscribe(...subscribers) {
|
|
21
|
+
subscribers.flat().forEach(async (subscriber) => {
|
|
22
|
+
await this.events.subscribe({
|
|
23
|
+
id: subscriber.constructor.name,
|
|
24
|
+
topics: subscriber.supportsEventTopics(),
|
|
25
|
+
onEvent: subscriber.onEvent.bind(subscriber)
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
exports.DefaultEventBroker = DefaultEventBroker;
|
|
32
|
+
//# sourceMappingURL=DefaultEventBroker.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DefaultEventBroker.cjs.js","sources":["../../src/service/DefaultEventBroker.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 { LoggerService } from '@backstage/backend-plugin-api';\nimport {\n DefaultEventsService,\n EventBroker,\n EventParams,\n EventsService,\n EventSubscriber,\n} from '@backstage/plugin-events-node';\n\n/**\n * In process event broker which will pass the event to all registered subscribers\n * interested in it.\n * Events will not be persisted in any form.\n *\n * @public\n * @deprecated use `DefaultEventsService` from `@backstage/plugin-events-node` instead\n */\nexport class DefaultEventBroker implements EventBroker {\n private readonly events: EventsService;\n\n /**\n *\n * @param logger - logger\n * @param events - replacement that gets wrapped to support not yet migrated implementations.\n * An instance can be passed (required for a mixed mode), otherwise a new instance gets created internally.\n * @deprecated use `DefaultEventsService` directly instead\n */\n constructor(logger: LoggerService, events?: EventsService) {\n this.events = events ?? DefaultEventsService.create({ logger });\n }\n\n async publish(params: EventParams): Promise<void> {\n return this.events.publish(params);\n }\n\n subscribe(\n ...subscribers: Array<EventSubscriber | Array<EventSubscriber>>\n ): void {\n subscribers.flat().forEach(async subscriber => {\n await this.events.subscribe({\n id: subscriber.constructor.name,\n topics: subscriber.supportsEventTopics(),\n onEvent: subscriber.onEvent.bind(subscriber),\n });\n });\n }\n}\n"],"names":["DefaultEventsService"],"mappings":";;;;AAiCO,MAAM,kBAA0C,CAAA;AAAA,EACpC,MAAA,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASjB,WAAA,CAAY,QAAuB,MAAwB,EAAA;AACzD,IAAA,IAAA,CAAK,SAAS,MAAU,IAAAA,qCAAA,CAAqB,MAAO,CAAA,EAAE,QAAQ,CAAA,CAAA;AAAA,GAChE;AAAA,EAEA,MAAM,QAAQ,MAAoC,EAAA;AAChD,IAAO,OAAA,IAAA,CAAK,MAAO,CAAA,OAAA,CAAQ,MAAM,CAAA,CAAA;AAAA,GACnC;AAAA,EAEA,aACK,WACG,EAAA;AACN,IAAA,WAAA,CAAY,IAAK,EAAA,CAAE,OAAQ,CAAA,OAAM,UAAc,KAAA;AAC7C,MAAM,MAAA,IAAA,CAAK,OAAO,SAAU,CAAA;AAAA,QAC1B,EAAA,EAAI,WAAW,WAAY,CAAA,IAAA;AAAA,QAC3B,MAAA,EAAQ,WAAW,mBAAoB,EAAA;AAAA,QACvC,OAAS,EAAA,UAAA,CAAW,OAAQ,CAAA,IAAA,CAAK,UAAU,CAAA;AAAA,OAC5C,CAAA,CAAA;AAAA,KACF,CAAA,CAAA;AAAA,GACH;AACF;;;;"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var DefaultEventBroker = require('./DefaultEventBroker.cjs.js');
|
|
4
|
+
|
|
5
|
+
class EventsBackend {
|
|
6
|
+
eventBroker;
|
|
7
|
+
publishers = [];
|
|
8
|
+
subscribers = [];
|
|
9
|
+
constructor(logger) {
|
|
10
|
+
this.eventBroker = new DefaultEventBroker.DefaultEventBroker(logger);
|
|
11
|
+
}
|
|
12
|
+
setEventBroker(eventBroker) {
|
|
13
|
+
this.eventBroker = eventBroker;
|
|
14
|
+
return this;
|
|
15
|
+
}
|
|
16
|
+
addPublishers(...publishers) {
|
|
17
|
+
this.publishers.push(...publishers.flat());
|
|
18
|
+
return this;
|
|
19
|
+
}
|
|
20
|
+
addSubscribers(...subscribers) {
|
|
21
|
+
this.subscribers.push(...subscribers.flat());
|
|
22
|
+
return this;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Wires up and returns all component parts of the event management.
|
|
26
|
+
*/
|
|
27
|
+
async start() {
|
|
28
|
+
this.eventBroker.subscribe(this.subscribers);
|
|
29
|
+
this.publishers.forEach(
|
|
30
|
+
(publisher) => publisher.setEventBroker(this.eventBroker)
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
exports.EventsBackend = EventsBackend;
|
|
36
|
+
//# sourceMappingURL=EventsBackend.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EventsBackend.cjs.js","sources":["../../src/service/EventsBackend.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 EventBroker,\n EventPublisher,\n EventSubscriber,\n} from '@backstage/plugin-events-node';\nimport { Logger } from 'winston';\nimport { DefaultEventBroker } from './DefaultEventBroker';\n\n/**\n * A builder that helps wire up all component parts of the event management.\n *\n * @public\n * @deprecated `EventBroker`, `EventPublisher`, and `EventSubscriber` got replaced by `EventsService` and its methods.\n */\nexport class EventsBackend {\n private eventBroker: EventBroker;\n private publishers: EventPublisher[] = [];\n private subscribers: EventSubscriber[] = [];\n\n constructor(logger: Logger) {\n this.eventBroker = new DefaultEventBroker(logger);\n }\n\n setEventBroker(eventBroker: EventBroker): EventsBackend {\n this.eventBroker = eventBroker;\n return this;\n }\n\n addPublishers(\n ...publishers: Array<EventPublisher | Array<EventPublisher>>\n ): EventsBackend {\n this.publishers.push(...publishers.flat());\n return this;\n }\n\n addSubscribers(\n ...subscribers: Array<EventSubscriber | Array<EventSubscriber>>\n ): EventsBackend {\n this.subscribers.push(...subscribers.flat());\n return this;\n }\n\n /**\n * Wires up and returns all component parts of the event management.\n */\n async start(): Promise<void> {\n this.eventBroker.subscribe(this.subscribers);\n this.publishers.forEach(publisher =>\n publisher.setEventBroker(this.eventBroker),\n );\n }\n}\n"],"names":["DefaultEventBroker"],"mappings":";;;;AA8BO,MAAM,aAAc,CAAA;AAAA,EACjB,WAAA,CAAA;AAAA,EACA,aAA+B,EAAC,CAAA;AAAA,EAChC,cAAiC,EAAC,CAAA;AAAA,EAE1C,YAAY,MAAgB,EAAA;AAC1B,IAAK,IAAA,CAAA,WAAA,GAAc,IAAIA,qCAAA,CAAmB,MAAM,CAAA,CAAA;AAAA,GAClD;AAAA,EAEA,eAAe,WAAyC,EAAA;AACtD,IAAA,IAAA,CAAK,WAAc,GAAA,WAAA,CAAA;AACnB,IAAO,OAAA,IAAA,CAAA;AAAA,GACT;AAAA,EAEA,iBACK,UACY,EAAA;AACf,IAAA,IAAA,CAAK,UAAW,CAAA,IAAA,CAAK,GAAG,UAAA,CAAW,MAAM,CAAA,CAAA;AACzC,IAAO,OAAA,IAAA,CAAA;AAAA,GACT;AAAA,EAEA,kBACK,WACY,EAAA;AACf,IAAA,IAAA,CAAK,WAAY,CAAA,IAAA,CAAK,GAAG,WAAA,CAAY,MAAM,CAAA,CAAA;AAC3C,IAAO,OAAA,IAAA,CAAA;AAAA,GACT;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,KAAuB,GAAA;AAC3B,IAAK,IAAA,CAAA,WAAA,CAAY,SAAU,CAAA,IAAA,CAAK,WAAW,CAAA,CAAA;AAC3C,IAAA,IAAA,CAAK,UAAW,CAAA,OAAA;AAAA,MAAQ,CACtB,SAAA,KAAA,SAAA,CAAU,cAAe,CAAA,IAAA,CAAK,WAAW,CAAA;AAAA,KAC3C,CAAA;AAAA,GACF;AACF;;;;"}
|