@backstage/plugin-events-node 0.2.3 → 0.2.4-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,5 +1,13 @@
1
1
  # @backstage/plugin-events-node
2
2
 
3
+ ## 0.2.4-next.0
4
+
5
+ ### Patch Changes
6
+
7
+ - 928a12a9b3: Internal refactor of `/alpha` exports.
8
+ - Updated dependencies
9
+ - @backstage/backend-plugin-api@0.4.1-next.0
10
+
3
11
  ## 0.2.3
4
12
 
5
13
  ### Patch Changes
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-events-node",
3
- "version": "0.2.3",
4
- "main": "../dist/index.cjs.js",
5
- "types": "../dist/index.alpha.d.ts"
3
+ "version": "0.2.4-next.0",
4
+ "main": "../dist/alpha.cjs.js",
5
+ "types": "../dist/alpha.d.ts"
6
6
  }
@@ -0,0 +1,12 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var backendPluginApi = require('@backstage/backend-plugin-api');
6
+
7
+ const eventsExtensionPoint = backendPluginApi.createExtensionPoint({
8
+ id: "events"
9
+ });
10
+
11
+ exports.eventsExtensionPoint = eventsExtensionPoint;
12
+ //# sourceMappingURL=alpha.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"alpha.cjs.js","sources":["../src/extensions.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 { createExtensionPoint } from '@backstage/backend-plugin-api';\nimport {\n EventBroker,\n EventPublisher,\n EventSubscriber,\n HttpPostIngressOptions,\n} from '@backstage/plugin-events-node';\n\n/**\n * @alpha\n */\nexport interface EventsExtensionPoint {\n setEventBroker(eventBroker: EventBroker): void;\n\n addPublishers(\n ...publishers: Array<EventPublisher | Array<EventPublisher>>\n ): void;\n\n addSubscribers(\n ...subscribers: Array<EventSubscriber | Array<EventSubscriber>>\n ): void;\n\n addHttpPostIngress(options: HttpPostIngressOptions): void;\n}\n\n/**\n * @alpha\n */\nexport const eventsExtensionPoint = createExtensionPoint<EventsExtensionPoint>({\n id: 'events',\n});\n"],"names":["createExtensionPoint"],"mappings":";;;;;;AA4CO,MAAM,uBAAuBA,qCAA2C,CAAA;AAAA,EAC7E,EAAI,EAAA,QAAA;AACN,CAAC;;;;"}
@@ -0,0 +1,18 @@
1
+ import * as _backstage_backend_plugin_api from '@backstage/backend-plugin-api';
2
+ import { EventBroker, EventPublisher, EventSubscriber, HttpPostIngressOptions } from '@backstage/plugin-events-node';
3
+
4
+ /**
5
+ * @alpha
6
+ */
7
+ interface EventsExtensionPoint {
8
+ setEventBroker(eventBroker: EventBroker): void;
9
+ addPublishers(...publishers: Array<EventPublisher | Array<EventPublisher>>): void;
10
+ addSubscribers(...subscribers: Array<EventSubscriber | Array<EventSubscriber>>): void;
11
+ addHttpPostIngress(options: HttpPostIngressOptions): void;
12
+ }
13
+ /**
14
+ * @alpha
15
+ */
16
+ declare const eventsExtensionPoint: _backstage_backend_plugin_api.ExtensionPoint<EventsExtensionPoint>;
17
+
18
+ export { EventsExtensionPoint, eventsExtensionPoint };
package/dist/index.cjs.js CHANGED
@@ -2,8 +2,6 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var backendPluginApi = require('@backstage/backend-plugin-api');
6
-
7
5
  class EventRouter {
8
6
  async onEvent(params) {
9
7
  var _a;
@@ -35,11 +33,6 @@ class SubTopicEventRouter extends EventRouter {
35
33
  }
36
34
  }
37
35
 
38
- const eventsExtensionPoint = backendPluginApi.createExtensionPoint({
39
- id: "events"
40
- });
41
-
42
36
  exports.EventRouter = EventRouter;
43
37
  exports.SubTopicEventRouter = SubTopicEventRouter;
44
- exports.eventsExtensionPoint = eventsExtensionPoint;
45
38
  //# sourceMappingURL=index.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs.js","sources":["../src/api/EventRouter.ts","../src/api/SubTopicEventRouter.ts","../src/extensions.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 { EventBroker } from './EventBroker';\nimport { EventParams } from './EventParams';\nimport { EventPublisher } from './EventPublisher';\nimport { EventSubscriber } from './EventSubscriber';\n\n/**\n * Subscribes to a topic and - depending on a set of conditions -\n * republishes the event to another topic.\n *\n * @see {@link https://www.enterpriseintegrationpatterns.com/MessageRouter.html | Message Router pattern}.\n * @public\n */\nexport abstract class EventRouter implements EventPublisher, EventSubscriber {\n private eventBroker?: EventBroker;\n\n protected abstract determineDestinationTopic(\n params: EventParams,\n ): string | undefined;\n\n async onEvent(params: EventParams): Promise<void> {\n const topic = this.determineDestinationTopic(params);\n\n if (!topic) {\n return;\n }\n\n // republish to different topic\n this.eventBroker?.publish({\n ...params,\n topic,\n });\n }\n\n async setEventBroker(eventBroker: EventBroker): Promise<void> {\n this.eventBroker = eventBroker;\n }\n\n abstract supportsEventTopics(): string[];\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 { EventParams } from './EventParams';\nimport { EventRouter } from './EventRouter';\n\n/**\n * Subscribes to the provided (generic) topic\n * and publishes the events under the more concrete sub-topic\n * depending on the implemented logic for determining it.\n * Implementing classes might use information from `metadata`\n * and/or properties within the payload.\n *\n * @public\n */\nexport abstract class SubTopicEventRouter extends EventRouter {\n protected constructor(private readonly topic: string) {\n super();\n }\n\n protected abstract determineSubTopic(params: EventParams): string | undefined;\n\n protected determineDestinationTopic(params: EventParams): string | undefined {\n const subTopic = this.determineSubTopic(params);\n return subTopic ? `${params.topic}.${subTopic}` : undefined;\n }\n\n supportsEventTopics(): string[] {\n return [this.topic];\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 { createExtensionPoint } from '@backstage/backend-plugin-api';\nimport {\n EventBroker,\n EventPublisher,\n EventSubscriber,\n HttpPostIngressOptions,\n} from './api';\n\n/**\n * @alpha\n */\nexport interface EventsExtensionPoint {\n setEventBroker(eventBroker: EventBroker): void;\n\n addPublishers(\n ...publishers: Array<EventPublisher | Array<EventPublisher>>\n ): void;\n\n addSubscribers(\n ...subscribers: Array<EventSubscriber | Array<EventSubscriber>>\n ): void;\n\n addHttpPostIngress(options: HttpPostIngressOptions): void;\n}\n\n/**\n * @alpha\n */\nexport const eventsExtensionPoint = createExtensionPoint<EventsExtensionPoint>({\n id: 'events',\n});\n"],"names":["createExtensionPoint"],"mappings":";;;;;;AA4BO,MAAe,WAAuD,CAAA;AAAA,EAO3E,MAAM,QAAQ,MAAoC,EAAA;AAnCpD,IAAA,IAAA,EAAA,CAAA;AAoCI,IAAM,MAAA,KAAA,GAAQ,IAAK,CAAA,yBAAA,CAA0B,MAAM,CAAA,CAAA;AAEnD,IAAA,IAAI,CAAC,KAAO,EAAA;AACV,MAAA,OAAA;AAAA,KACF;AAGA,IAAK,CAAA,EAAA,GAAA,IAAA,CAAA,WAAA,KAAL,mBAAkB,OAAQ,CAAA;AAAA,MACxB,GAAG,MAAA;AAAA,MACH,KAAA;AAAA,KACF,CAAA,CAAA;AAAA,GACF;AAAA,EAEA,MAAM,eAAe,WAAyC,EAAA;AAC5D,IAAA,IAAA,CAAK,WAAc,GAAA,WAAA,CAAA;AAAA,GACrB;AAGF;;AC1BO,MAAe,4BAA4B,WAAY,CAAA;AAAA,EAClD,YAA6B,KAAe,EAAA;AACpD,IAAM,KAAA,EAAA,CAAA;AAD+B,IAAA,IAAA,CAAA,KAAA,GAAA,KAAA,CAAA;AAAA,GAEvC;AAAA,EAIU,0BAA0B,MAAyC,EAAA;AAC3E,IAAM,MAAA,QAAA,GAAW,IAAK,CAAA,iBAAA,CAAkB,MAAM,CAAA,CAAA;AAC9C,IAAA,OAAO,QAAW,GAAA,CAAA,EAAG,MAAO,CAAA,KAAA,CAAA,CAAA,EAAS,QAAa,CAAA,CAAA,GAAA,KAAA,CAAA,CAAA;AAAA,GACpD;AAAA,EAEA,mBAAgC,GAAA;AAC9B,IAAO,OAAA,CAAC,KAAK,KAAK,CAAA,CAAA;AAAA,GACpB;AACF;;ACCO,MAAM,uBAAuBA,qCAA2C,CAAA;AAAA,EAC7E,EAAI,EAAA,QAAA;AACN,CAAC;;;;;;"}
1
+ {"version":3,"file":"index.cjs.js","sources":["../src/api/EventRouter.ts","../src/api/SubTopicEventRouter.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 { EventBroker } from './EventBroker';\nimport { EventParams } from './EventParams';\nimport { EventPublisher } from './EventPublisher';\nimport { EventSubscriber } from './EventSubscriber';\n\n/**\n * Subscribes to a topic and - depending on a set of conditions -\n * republishes the event to another topic.\n *\n * @see {@link https://www.enterpriseintegrationpatterns.com/MessageRouter.html | Message Router pattern}.\n * @public\n */\nexport abstract class EventRouter implements EventPublisher, EventSubscriber {\n private eventBroker?: EventBroker;\n\n protected abstract determineDestinationTopic(\n params: EventParams,\n ): string | undefined;\n\n async onEvent(params: EventParams): Promise<void> {\n const topic = this.determineDestinationTopic(params);\n\n if (!topic) {\n return;\n }\n\n // republish to different topic\n this.eventBroker?.publish({\n ...params,\n topic,\n });\n }\n\n async setEventBroker(eventBroker: EventBroker): Promise<void> {\n this.eventBroker = eventBroker;\n }\n\n abstract supportsEventTopics(): string[];\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 { EventParams } from './EventParams';\nimport { EventRouter } from './EventRouter';\n\n/**\n * Subscribes to the provided (generic) topic\n * and publishes the events under the more concrete sub-topic\n * depending on the implemented logic for determining it.\n * Implementing classes might use information from `metadata`\n * and/or properties within the payload.\n *\n * @public\n */\nexport abstract class SubTopicEventRouter extends EventRouter {\n protected constructor(private readonly topic: string) {\n super();\n }\n\n protected abstract determineSubTopic(params: EventParams): string | undefined;\n\n protected determineDestinationTopic(params: EventParams): string | undefined {\n const subTopic = this.determineSubTopic(params);\n return subTopic ? `${params.topic}.${subTopic}` : undefined;\n }\n\n supportsEventTopics(): string[] {\n return [this.topic];\n }\n}\n"],"names":[],"mappings":";;;;AA4BO,MAAe,WAAuD,CAAA;AAAA,EAO3E,MAAM,QAAQ,MAAoC,EAAA;AAnCpD,IAAA,IAAA,EAAA,CAAA;AAoCI,IAAM,MAAA,KAAA,GAAQ,IAAK,CAAA,yBAAA,CAA0B,MAAM,CAAA,CAAA;AAEnD,IAAA,IAAI,CAAC,KAAO,EAAA;AACV,MAAA,OAAA;AAAA,KACF;AAGA,IAAK,CAAA,EAAA,GAAA,IAAA,CAAA,WAAA,KAAL,mBAAkB,OAAQ,CAAA;AAAA,MACxB,GAAG,MAAA;AAAA,MACH,KAAA;AAAA,KACF,CAAA,CAAA;AAAA,GACF;AAAA,EAEA,MAAM,eAAe,WAAyC,EAAA;AAC5D,IAAA,IAAA,CAAK,WAAc,GAAA,WAAA,CAAA;AAAA,GACrB;AAGF;;AC1BO,MAAe,4BAA4B,WAAY,CAAA;AAAA,EAClD,YAA6B,KAAe,EAAA;AACpD,IAAM,KAAA,EAAA,CAAA;AAD+B,IAAA,IAAA,CAAA,KAAA,GAAA,KAAA,CAAA;AAAA,GAEvC;AAAA,EAIU,0BAA0B,MAAyC,EAAA;AAC3E,IAAM,MAAA,QAAA,GAAW,IAAK,CAAA,iBAAA,CAAkB,MAAM,CAAA,CAAA;AAC9C,IAAA,OAAO,QAAW,GAAA,CAAA,EAAG,MAAO,CAAA,KAAA,CAAA,CAAA,EAAS,QAAa,CAAA,CAAA,GAAA,KAAA,CAAA,CAAA;AAAA,GACpD;AAAA,EAEA,mBAAgC,GAAA;AAC9B,IAAO,OAAA,CAAC,KAAK,KAAK,CAAA,CAAA;AAAA,GACpB;AACF;;;;;"}
package/dist/index.d.ts CHANGED
@@ -1,10 +1,40 @@
1
1
  /**
2
- * The events-node module for `@backstage/plugin-events-backend`.
3
- *
4
- * @packageDocumentation
2
+ * @public
5
3
  */
4
+ interface EventParams<TPayload = unknown> {
5
+ /**
6
+ * Topic for which this event should be published.
7
+ */
8
+ topic: string;
9
+ /**
10
+ * Event payload.
11
+ */
12
+ eventPayload: TPayload;
13
+ /**
14
+ * Metadata (e.g., HTTP headers and similar for events received from external).
15
+ */
16
+ metadata?: Record<string, string | string[] | undefined>;
17
+ }
6
18
 
7
- import { ExtensionPoint } from '@backstage/backend-plugin-api';
19
+ /**
20
+ * Handles received events.
21
+ * This may include triggering refreshes of catalog entities
22
+ * or other actions to react on events.
23
+ *
24
+ * @public
25
+ */
26
+ interface EventSubscriber {
27
+ /**
28
+ * Supported event topics like "github", "bitbucketCloud", etc.
29
+ */
30
+ supportsEventTopics(): string[];
31
+ /**
32
+ * React on a received event.
33
+ *
34
+ * @param params - parameters for the to be received event.
35
+ */
36
+ onEvent(params: EventParams): Promise<void>;
37
+ }
8
38
 
9
39
  /**
10
40
  * Allows a decoupled and asynchronous communication between components.
@@ -13,7 +43,7 @@ import { ExtensionPoint } from '@backstage/backend-plugin-api';
13
43
  *
14
44
  * @public
15
45
  */
16
- export declare interface EventBroker {
46
+ interface EventBroker {
17
47
  /**
18
48
  * Publishes an event for the topic.
19
49
  *
@@ -28,24 +58,6 @@ export declare interface EventBroker {
28
58
  subscribe(...subscribers: Array<EventSubscriber | Array<EventSubscriber>>): void;
29
59
  }
30
60
 
31
- /**
32
- * @public
33
- */
34
- export declare interface EventParams<TPayload = unknown> {
35
- /**
36
- * Topic for which this event should be published.
37
- */
38
- topic: string;
39
- /**
40
- * Event payload.
41
- */
42
- eventPayload: TPayload;
43
- /**
44
- * Metadata (e.g., HTTP headers and similar for events received from external).
45
- */
46
- metadata?: Record<string, string | string[] | undefined>;
47
- }
48
-
49
61
  /**
50
62
  * Publishes events to be consumed by subscribers for their topic.
51
63
  * The events can come from different (external) sources
@@ -54,7 +66,7 @@ export declare interface EventParams<TPayload = unknown> {
54
66
  *
55
67
  * @public
56
68
  */
57
- export declare interface EventPublisher {
69
+ interface EventPublisher {
58
70
  setEventBroker(eventBroker: EventBroker): Promise<void>;
59
71
  }
60
72
 
@@ -65,7 +77,7 @@ export declare interface EventPublisher {
65
77
  * @see {@link https://www.enterpriseintegrationpatterns.com/MessageRouter.html | Message Router pattern}.
66
78
  * @public
67
79
  */
68
- export declare abstract class EventRouter implements EventPublisher, EventSubscriber {
80
+ declare abstract class EventRouter implements EventPublisher, EventSubscriber {
69
81
  private eventBroker?;
70
82
  protected abstract determineDestinationTopic(params: EventParams): string | undefined;
71
83
  onEvent(params: EventParams): Promise<void>;
@@ -73,42 +85,10 @@ export declare abstract class EventRouter implements EventPublisher, EventSubscr
73
85
  abstract supportsEventTopics(): string[];
74
86
  }
75
87
 
76
- /* Excluded from this release type: EventsExtensionPoint */
77
-
78
- /* Excluded from this release type: eventsExtensionPoint */
79
-
80
- /**
81
- * Handles received events.
82
- * This may include triggering refreshes of catalog entities
83
- * or other actions to react on events.
84
- *
85
- * @public
86
- */
87
- export declare interface EventSubscriber {
88
- /**
89
- * Supported event topics like "github", "bitbucketCloud", etc.
90
- */
91
- supportsEventTopics(): string[];
92
- /**
93
- * React on a received event.
94
- *
95
- * @param params - parameters for the to be received event.
96
- */
97
- onEvent(params: EventParams): Promise<void>;
98
- }
99
-
100
88
  /**
101
89
  * @public
102
90
  */
103
- export declare interface HttpPostIngressOptions {
104
- topic: string;
105
- validator?: RequestValidator;
106
- }
107
-
108
- /**
109
- * @public
110
- */
111
- export declare interface RequestDetails {
91
+ interface RequestDetails {
112
92
  /**
113
93
  * Request body. JSON payloads have been parsed already.
114
94
  */
@@ -125,7 +105,7 @@ export declare interface RequestDetails {
125
105
  *
126
106
  * @public
127
107
  */
128
- export declare interface RequestRejectionDetails {
108
+ interface RequestRejectionDetails {
129
109
  status: number;
130
110
  payload: unknown;
131
111
  }
@@ -136,7 +116,7 @@ export declare interface RequestRejectionDetails {
136
116
  *
137
117
  * @public
138
118
  */
139
- export declare interface RequestValidationContext {
119
+ interface RequestValidationContext {
140
120
  /**
141
121
  * Rejects the validated request
142
122
  *
@@ -156,7 +136,15 @@ export declare interface RequestValidationContext {
156
136
  *
157
137
  * @public
158
138
  */
159
- export declare type RequestValidator = (request: RequestDetails, context: RequestValidationContext) => Promise<void>;
139
+ declare type RequestValidator = (request: RequestDetails, context: RequestValidationContext) => Promise<void>;
140
+
141
+ /**
142
+ * @public
143
+ */
144
+ interface HttpPostIngressOptions {
145
+ topic: string;
146
+ validator?: RequestValidator;
147
+ }
160
148
 
161
149
  /**
162
150
  * Subscribes to the provided (generic) topic
@@ -167,7 +155,7 @@ export declare type RequestValidator = (request: RequestDetails, context: Reques
167
155
  *
168
156
  * @public
169
157
  */
170
- export declare abstract class SubTopicEventRouter extends EventRouter {
158
+ declare abstract class SubTopicEventRouter extends EventRouter {
171
159
  private readonly topic;
172
160
  protected constructor(topic: string);
173
161
  protected abstract determineSubTopic(params: EventParams): string | undefined;
@@ -175,4 +163,4 @@ export declare abstract class SubTopicEventRouter extends EventRouter {
175
163
  supportsEventTopics(): string[];
176
164
  }
177
165
 
178
- export { }
166
+ export { EventBroker, EventParams, EventPublisher, EventRouter, EventSubscriber, HttpPostIngressOptions, RequestDetails, RequestRejectionDetails, RequestValidationContext, RequestValidator, SubTopicEventRouter };
package/package.json CHANGED
@@ -1,22 +1,32 @@
1
1
  {
2
2
  "name": "@backstage/plugin-events-node",
3
3
  "description": "The plugin-events-node module for @backstage/plugin-events-backend",
4
- "version": "0.2.3",
5
- "main": "dist/index.cjs.js",
6
- "types": "dist/index.d.ts",
4
+ "version": "0.2.4-next.0",
5
+ "main": "./dist/index.cjs.js",
6
+ "types": "./dist/index.d.ts",
7
7
  "license": "Apache-2.0",
8
8
  "publishConfig": {
9
- "access": "public",
10
- "alphaTypes": "dist/index.alpha.d.ts",
11
- "main": "dist/index.cjs.js",
12
- "types": "dist/index.d.ts"
9
+ "access": "public"
10
+ },
11
+ "exports": {
12
+ ".": {
13
+ "require": "./dist/index.cjs.js",
14
+ "types": "./dist/index.d.ts",
15
+ "default": "./dist/index.cjs.js"
16
+ },
17
+ "./alpha": {
18
+ "require": "./dist/alpha.cjs.js",
19
+ "types": "./dist/alpha.d.ts",
20
+ "default": "./dist/alpha.cjs.js"
21
+ },
22
+ "./package.json": "./package.json"
13
23
  },
14
24
  "backstage": {
15
25
  "role": "node-library"
16
26
  },
17
27
  "scripts": {
18
28
  "start": "backstage-cli package start",
19
- "build": "backstage-cli package build --experimental-type-build",
29
+ "build": "backstage-cli package build",
20
30
  "lint": "backstage-cli package lint",
21
31
  "test": "backstage-cli package test",
22
32
  "clean": "backstage-cli package clean",
@@ -24,13 +34,13 @@
24
34
  "postpack": "backstage-cli package postpack"
25
35
  },
26
36
  "dependencies": {
27
- "@backstage/backend-plugin-api": "^0.4.0"
37
+ "@backstage/backend-plugin-api": "^0.4.1-next.0"
28
38
  },
29
39
  "devDependencies": {
30
- "@backstage/cli": "^0.22.2"
40
+ "@backstage/cli": "^0.22.4-next.0"
31
41
  },
32
42
  "files": [
33
- "alpha",
34
- "dist"
43
+ "dist",
44
+ "alpha"
35
45
  ]
36
46
  }
@@ -1,189 +0,0 @@
1
- /**
2
- * The events-node module for `@backstage/plugin-events-backend`.
3
- *
4
- * @packageDocumentation
5
- */
6
-
7
- import { ExtensionPoint } from '@backstage/backend-plugin-api';
8
-
9
- /**
10
- * Allows a decoupled and asynchronous communication between components.
11
- * Components can publish events for a given topic and
12
- * others can subscribe for future events for topics they are interested in.
13
- *
14
- * @public
15
- */
16
- export declare interface EventBroker {
17
- /**
18
- * Publishes an event for the topic.
19
- *
20
- * @param params - parameters for the to be published event.
21
- */
22
- publish(params: EventParams): Promise<void>;
23
- /**
24
- * Adds new subscribers for {@link EventSubscriber#supportsEventTopics | interested topics}.
25
- *
26
- * @param subscribers - interested in events of specified topics.
27
- */
28
- subscribe(...subscribers: Array<EventSubscriber | Array<EventSubscriber>>): void;
29
- }
30
-
31
- /**
32
- * @public
33
- */
34
- export declare interface EventParams<TPayload = unknown> {
35
- /**
36
- * Topic for which this event should be published.
37
- */
38
- topic: string;
39
- /**
40
- * Event payload.
41
- */
42
- eventPayload: TPayload;
43
- /**
44
- * Metadata (e.g., HTTP headers and similar for events received from external).
45
- */
46
- metadata?: Record<string, string | string[] | undefined>;
47
- }
48
-
49
- /**
50
- * Publishes events to be consumed by subscribers for their topic.
51
- * The events can come from different (external) sources
52
- * like emitted themselves, received via HTTP endpoint (i.e. webhook)
53
- * or from event brokers, queues, etc.
54
- *
55
- * @public
56
- */
57
- export declare interface EventPublisher {
58
- setEventBroker(eventBroker: EventBroker): Promise<void>;
59
- }
60
-
61
- /**
62
- * Subscribes to a topic and - depending on a set of conditions -
63
- * republishes the event to another topic.
64
- *
65
- * @see {@link https://www.enterpriseintegrationpatterns.com/MessageRouter.html | Message Router pattern}.
66
- * @public
67
- */
68
- export declare abstract class EventRouter implements EventPublisher, EventSubscriber {
69
- private eventBroker?;
70
- protected abstract determineDestinationTopic(params: EventParams): string | undefined;
71
- onEvent(params: EventParams): Promise<void>;
72
- setEventBroker(eventBroker: EventBroker): Promise<void>;
73
- abstract supportsEventTopics(): string[];
74
- }
75
-
76
- /**
77
- * @alpha
78
- */
79
- export declare interface EventsExtensionPoint {
80
- setEventBroker(eventBroker: EventBroker): void;
81
- addPublishers(...publishers: Array<EventPublisher | Array<EventPublisher>>): void;
82
- addSubscribers(...subscribers: Array<EventSubscriber | Array<EventSubscriber>>): void;
83
- addHttpPostIngress(options: HttpPostIngressOptions): void;
84
- }
85
-
86
- /**
87
- * @alpha
88
- */
89
- export declare const eventsExtensionPoint: ExtensionPoint<EventsExtensionPoint>;
90
-
91
- /**
92
- * Handles received events.
93
- * This may include triggering refreshes of catalog entities
94
- * or other actions to react on events.
95
- *
96
- * @public
97
- */
98
- export declare interface EventSubscriber {
99
- /**
100
- * Supported event topics like "github", "bitbucketCloud", etc.
101
- */
102
- supportsEventTopics(): string[];
103
- /**
104
- * React on a received event.
105
- *
106
- * @param params - parameters for the to be received event.
107
- */
108
- onEvent(params: EventParams): Promise<void>;
109
- }
110
-
111
- /**
112
- * @public
113
- */
114
- export declare interface HttpPostIngressOptions {
115
- topic: string;
116
- validator?: RequestValidator;
117
- }
118
-
119
- /**
120
- * @public
121
- */
122
- export declare interface RequestDetails {
123
- /**
124
- * Request body. JSON payloads have been parsed already.
125
- */
126
- body: unknown;
127
- /**
128
- * Key-value pairs of header names and values. Header names are lower-cased.
129
- */
130
- headers: Record<string, string | string[] | undefined>;
131
- }
132
-
133
- /**
134
- * Details for how to respond to the rejection
135
- * of the received HTTP request transmitting an event payload.
136
- *
137
- * @public
138
- */
139
- export declare interface RequestRejectionDetails {
140
- status: number;
141
- payload: unknown;
142
- }
143
-
144
- /**
145
- * Passed context for the validation
146
- * at which rejections can be expressed.
147
- *
148
- * @public
149
- */
150
- export declare interface RequestValidationContext {
151
- /**
152
- * Rejects the validated request
153
- *
154
- * @param details - Optional details about the rejection which will be provided to the sender.
155
- */
156
- reject(details?: Partial<RequestRejectionDetails>): void;
157
- }
158
-
159
- /**
160
- * Validator used to check the received HTTP request
161
- * transmitting an event payload.
162
- *
163
- * E.g., it can be used for signature verification like
164
- * for GitHub webhook events
165
- * (https://docs.github.com/en/developers/webhooks-and-events/webhooks/creating-webhooks#secret)
166
- * or other kinds of checks.
167
- *
168
- * @public
169
- */
170
- export declare type RequestValidator = (request: RequestDetails, context: RequestValidationContext) => Promise<void>;
171
-
172
- /**
173
- * Subscribes to the provided (generic) topic
174
- * and publishes the events under the more concrete sub-topic
175
- * depending on the implemented logic for determining it.
176
- * Implementing classes might use information from `metadata`
177
- * and/or properties within the payload.
178
- *
179
- * @public
180
- */
181
- export declare abstract class SubTopicEventRouter extends EventRouter {
182
- private readonly topic;
183
- protected constructor(topic: string);
184
- protected abstract determineSubTopic(params: EventParams): string | undefined;
185
- protected determineDestinationTopic(params: EventParams): string | undefined;
186
- supportsEventTopics(): string[];
187
- }
188
-
189
- export { }
@@ -1,178 +0,0 @@
1
- /**
2
- * The events-node module for `@backstage/plugin-events-backend`.
3
- *
4
- * @packageDocumentation
5
- */
6
-
7
- import { ExtensionPoint } from '@backstage/backend-plugin-api';
8
-
9
- /**
10
- * Allows a decoupled and asynchronous communication between components.
11
- * Components can publish events for a given topic and
12
- * others can subscribe for future events for topics they are interested in.
13
- *
14
- * @public
15
- */
16
- export declare interface EventBroker {
17
- /**
18
- * Publishes an event for the topic.
19
- *
20
- * @param params - parameters for the to be published event.
21
- */
22
- publish(params: EventParams): Promise<void>;
23
- /**
24
- * Adds new subscribers for {@link EventSubscriber#supportsEventTopics | interested topics}.
25
- *
26
- * @param subscribers - interested in events of specified topics.
27
- */
28
- subscribe(...subscribers: Array<EventSubscriber | Array<EventSubscriber>>): void;
29
- }
30
-
31
- /**
32
- * @public
33
- */
34
- export declare interface EventParams<TPayload = unknown> {
35
- /**
36
- * Topic for which this event should be published.
37
- */
38
- topic: string;
39
- /**
40
- * Event payload.
41
- */
42
- eventPayload: TPayload;
43
- /**
44
- * Metadata (e.g., HTTP headers and similar for events received from external).
45
- */
46
- metadata?: Record<string, string | string[] | undefined>;
47
- }
48
-
49
- /**
50
- * Publishes events to be consumed by subscribers for their topic.
51
- * The events can come from different (external) sources
52
- * like emitted themselves, received via HTTP endpoint (i.e. webhook)
53
- * or from event brokers, queues, etc.
54
- *
55
- * @public
56
- */
57
- export declare interface EventPublisher {
58
- setEventBroker(eventBroker: EventBroker): Promise<void>;
59
- }
60
-
61
- /**
62
- * Subscribes to a topic and - depending on a set of conditions -
63
- * republishes the event to another topic.
64
- *
65
- * @see {@link https://www.enterpriseintegrationpatterns.com/MessageRouter.html | Message Router pattern}.
66
- * @public
67
- */
68
- export declare abstract class EventRouter implements EventPublisher, EventSubscriber {
69
- private eventBroker?;
70
- protected abstract determineDestinationTopic(params: EventParams): string | undefined;
71
- onEvent(params: EventParams): Promise<void>;
72
- setEventBroker(eventBroker: EventBroker): Promise<void>;
73
- abstract supportsEventTopics(): string[];
74
- }
75
-
76
- /* Excluded from this release type: EventsExtensionPoint */
77
-
78
- /* Excluded from this release type: eventsExtensionPoint */
79
-
80
- /**
81
- * Handles received events.
82
- * This may include triggering refreshes of catalog entities
83
- * or other actions to react on events.
84
- *
85
- * @public
86
- */
87
- export declare interface EventSubscriber {
88
- /**
89
- * Supported event topics like "github", "bitbucketCloud", etc.
90
- */
91
- supportsEventTopics(): string[];
92
- /**
93
- * React on a received event.
94
- *
95
- * @param params - parameters for the to be received event.
96
- */
97
- onEvent(params: EventParams): Promise<void>;
98
- }
99
-
100
- /**
101
- * @public
102
- */
103
- export declare interface HttpPostIngressOptions {
104
- topic: string;
105
- validator?: RequestValidator;
106
- }
107
-
108
- /**
109
- * @public
110
- */
111
- export declare interface RequestDetails {
112
- /**
113
- * Request body. JSON payloads have been parsed already.
114
- */
115
- body: unknown;
116
- /**
117
- * Key-value pairs of header names and values. Header names are lower-cased.
118
- */
119
- headers: Record<string, string | string[] | undefined>;
120
- }
121
-
122
- /**
123
- * Details for how to respond to the rejection
124
- * of the received HTTP request transmitting an event payload.
125
- *
126
- * @public
127
- */
128
- export declare interface RequestRejectionDetails {
129
- status: number;
130
- payload: unknown;
131
- }
132
-
133
- /**
134
- * Passed context for the validation
135
- * at which rejections can be expressed.
136
- *
137
- * @public
138
- */
139
- export declare interface RequestValidationContext {
140
- /**
141
- * Rejects the validated request
142
- *
143
- * @param details - Optional details about the rejection which will be provided to the sender.
144
- */
145
- reject(details?: Partial<RequestRejectionDetails>): void;
146
- }
147
-
148
- /**
149
- * Validator used to check the received HTTP request
150
- * transmitting an event payload.
151
- *
152
- * E.g., it can be used for signature verification like
153
- * for GitHub webhook events
154
- * (https://docs.github.com/en/developers/webhooks-and-events/webhooks/creating-webhooks#secret)
155
- * or other kinds of checks.
156
- *
157
- * @public
158
- */
159
- export declare type RequestValidator = (request: RequestDetails, context: RequestValidationContext) => Promise<void>;
160
-
161
- /**
162
- * Subscribes to the provided (generic) topic
163
- * and publishes the events under the more concrete sub-topic
164
- * depending on the implemented logic for determining it.
165
- * Implementing classes might use information from `metadata`
166
- * and/or properties within the payload.
167
- *
168
- * @public
169
- */
170
- export declare abstract class SubTopicEventRouter extends EventRouter {
171
- private readonly topic;
172
- protected constructor(topic: string);
173
- protected abstract determineSubTopic(params: EventParams): string | undefined;
174
- protected determineDestinationTopic(params: EventParams): string | undefined;
175
- supportsEventTopics(): string[];
176
- }
177
-
178
- export { }