@backstage/plugin-events-backend-test-utils 0.1.28 → 0.1.29-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 +7 -0
- package/dist/index.cjs.js +17 -77
- package/dist/index.cjs.js.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
package/dist/index.cjs.js
CHANGED
|
@@ -1,16 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var __defProp$1 = Object.defineProperty;
|
|
4
|
-
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
5
|
-
var __publicField$1 = (obj, key, value) => {
|
|
6
|
-
__defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
7
|
-
return value;
|
|
8
|
-
};
|
|
9
3
|
class TestEventBroker {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
__publicField$1(this, "subscribed", []);
|
|
13
|
-
}
|
|
4
|
+
published = [];
|
|
5
|
+
subscribed = [];
|
|
14
6
|
async publish(params) {
|
|
15
7
|
this.published.push(params);
|
|
16
8
|
}
|
|
@@ -19,49 +11,21 @@ class TestEventBroker {
|
|
|
19
11
|
}
|
|
20
12
|
}
|
|
21
13
|
|
|
22
|
-
var __accessCheck$1 = (obj, member, msg) => {
|
|
23
|
-
if (!member.has(obj))
|
|
24
|
-
throw TypeError("Cannot " + msg);
|
|
25
|
-
};
|
|
26
|
-
var __privateGet$1 = (obj, member, getter) => {
|
|
27
|
-
__accessCheck$1(obj, member, "read from private field");
|
|
28
|
-
return member.get(obj);
|
|
29
|
-
};
|
|
30
|
-
var __privateAdd$1 = (obj, member, value) => {
|
|
31
|
-
if (member.has(obj))
|
|
32
|
-
throw TypeError("Cannot add the same private member more than once");
|
|
33
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
34
|
-
};
|
|
35
|
-
var __privateSet$1 = (obj, member, value, setter) => {
|
|
36
|
-
__accessCheck$1(obj, member, "write to private field");
|
|
37
|
-
member.set(obj, value);
|
|
38
|
-
return value;
|
|
39
|
-
};
|
|
40
|
-
var _eventBroker;
|
|
41
14
|
class TestEventPublisher {
|
|
42
|
-
|
|
43
|
-
__privateAdd$1(this, _eventBroker, void 0);
|
|
44
|
-
}
|
|
15
|
+
#eventBroker;
|
|
45
16
|
async setEventBroker(eventBroker) {
|
|
46
|
-
|
|
17
|
+
this.#eventBroker = eventBroker;
|
|
47
18
|
}
|
|
48
19
|
get eventBroker() {
|
|
49
|
-
return
|
|
20
|
+
return this.#eventBroker;
|
|
50
21
|
}
|
|
51
22
|
}
|
|
52
|
-
_eventBroker = new WeakMap();
|
|
53
23
|
|
|
54
|
-
var __defProp = Object.defineProperty;
|
|
55
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
56
|
-
var __publicField = (obj, key, value) => {
|
|
57
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
58
|
-
return value;
|
|
59
|
-
};
|
|
60
24
|
class TestEventSubscriber {
|
|
25
|
+
name;
|
|
26
|
+
topics;
|
|
27
|
+
receivedEvents = {};
|
|
61
28
|
constructor(name, topics) {
|
|
62
|
-
__publicField(this, "name");
|
|
63
|
-
__publicField(this, "topics");
|
|
64
|
-
__publicField(this, "receivedEvents", {});
|
|
65
29
|
this.name = name;
|
|
66
30
|
this.topics = topics;
|
|
67
31
|
}
|
|
@@ -69,55 +33,31 @@ class TestEventSubscriber {
|
|
|
69
33
|
return this.topics;
|
|
70
34
|
}
|
|
71
35
|
async onEvent(params) {
|
|
72
|
-
|
|
73
|
-
this.receivedEvents[params.topic] = (_a = this.receivedEvents[params.topic]) != null ? _a : [];
|
|
36
|
+
this.receivedEvents[params.topic] = this.receivedEvents[params.topic] ?? [];
|
|
74
37
|
this.receivedEvents[params.topic].push(params);
|
|
75
38
|
}
|
|
76
39
|
}
|
|
77
40
|
|
|
78
|
-
var __accessCheck = (obj, member, msg) => {
|
|
79
|
-
if (!member.has(obj))
|
|
80
|
-
throw TypeError("Cannot " + msg);
|
|
81
|
-
};
|
|
82
|
-
var __privateGet = (obj, member, getter) => {
|
|
83
|
-
__accessCheck(obj, member, "read from private field");
|
|
84
|
-
return member.get(obj);
|
|
85
|
-
};
|
|
86
|
-
var __privateAdd = (obj, member, value) => {
|
|
87
|
-
if (member.has(obj))
|
|
88
|
-
throw TypeError("Cannot add the same private member more than once");
|
|
89
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
90
|
-
};
|
|
91
|
-
var __privateSet = (obj, member, value, setter) => {
|
|
92
|
-
__accessCheck(obj, member, "write to private field");
|
|
93
|
-
member.set(obj, value);
|
|
94
|
-
return value;
|
|
95
|
-
};
|
|
96
|
-
var _published, _subscribed;
|
|
97
41
|
class TestEventsService {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
__privateAdd(this, _subscribed, []);
|
|
101
|
-
}
|
|
42
|
+
#published = [];
|
|
43
|
+
#subscribed = [];
|
|
102
44
|
async publish(params) {
|
|
103
|
-
|
|
45
|
+
this.#published.push(params);
|
|
104
46
|
}
|
|
105
47
|
async subscribe(options) {
|
|
106
|
-
|
|
48
|
+
this.#subscribed.push(options);
|
|
107
49
|
}
|
|
108
50
|
get published() {
|
|
109
|
-
return
|
|
51
|
+
return this.#published;
|
|
110
52
|
}
|
|
111
53
|
get subscribed() {
|
|
112
|
-
return
|
|
54
|
+
return this.#subscribed;
|
|
113
55
|
}
|
|
114
56
|
reset() {
|
|
115
|
-
|
|
116
|
-
|
|
57
|
+
this.#published = [];
|
|
58
|
+
this.#subscribed = [];
|
|
117
59
|
}
|
|
118
60
|
}
|
|
119
|
-
_published = new WeakMap();
|
|
120
|
-
_subscribed = new WeakMap();
|
|
121
61
|
|
|
122
62
|
exports.TestEventBroker = TestEventBroker;
|
|
123
63
|
exports.TestEventPublisher = TestEventPublisher;
|
package/dist/index.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs.js","sources":["../src/testUtils/TestEventBroker.ts","../src/testUtils/TestEventPublisher.ts","../src/testUtils/TestEventSubscriber.ts","../src/testUtils/TestEventsService.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 EventParams,\n EventSubscriber,\n} from '@backstage/plugin-events-node';\n\n/**\n * @public\n * @deprecated use `TestEventsService` instead\n */\nexport class TestEventBroker implements EventBroker {\n readonly published: EventParams[] = [];\n readonly subscribed: EventSubscriber[] = [];\n\n async publish(params: EventParams): Promise<void> {\n this.published.push(params);\n }\n\n subscribe(\n ...subscribers: Array<EventSubscriber | Array<EventSubscriber>>\n ): void {\n this.subscribed.push(...subscribers.flat());\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 { EventBroker, EventPublisher } from '@backstage/plugin-events-node';\n\n/**\n * @public\n * @deprecated `EventPublisher` was replaced by `EventsService.publish`\n */\nexport class TestEventPublisher implements EventPublisher {\n #eventBroker?: EventBroker;\n\n async setEventBroker(eventBroker: EventBroker): Promise<void> {\n this.#eventBroker = eventBroker;\n }\n\n get eventBroker() {\n return this.#eventBroker;\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 { EventParams, EventSubscriber } from '@backstage/plugin-events-node';\n\n/**\n * @public\n * @deprecated `EventSubscriber` was replaced by `EventsService.subscribe`.\n */\nexport class TestEventSubscriber implements EventSubscriber {\n readonly name: string;\n readonly topics: string[];\n\n readonly receivedEvents: Record<string, EventParams[]> = {};\n\n constructor(name: string, topics: string[]) {\n this.name = name;\n this.topics = topics;\n }\n\n supportsEventTopics(): string[] {\n return this.topics;\n }\n\n async onEvent(params: EventParams): Promise<void> {\n this.receivedEvents[params.topic] = this.receivedEvents[params.topic] ?? [];\n this.receivedEvents[params.topic].push(params);\n }\n}\n","/*\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\nimport {\n EventParams,\n EventsService,\n EventsServiceSubscribeOptions,\n} from '@backstage/plugin-events-node';\n\n/** @public */\nexport class TestEventsService implements EventsService {\n #published: EventParams[] = [];\n #subscribed: EventsServiceSubscribeOptions[] = [];\n\n async publish(params: EventParams): Promise<void> {\n this.#published.push(params);\n }\n\n async subscribe(options: EventsServiceSubscribeOptions): Promise<void> {\n this.#subscribed.push(options);\n }\n\n get published(): EventParams[] {\n return this.#published;\n }\n\n get subscribed(): EventsServiceSubscribeOptions[] {\n return this.#subscribed;\n }\n\n reset(): void {\n this.#published = [];\n this.#subscribed = [];\n }\n}\n"],"names":[
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":["../src/testUtils/TestEventBroker.ts","../src/testUtils/TestEventPublisher.ts","../src/testUtils/TestEventSubscriber.ts","../src/testUtils/TestEventsService.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 EventParams,\n EventSubscriber,\n} from '@backstage/plugin-events-node';\n\n/**\n * @public\n * @deprecated use `TestEventsService` instead\n */\nexport class TestEventBroker implements EventBroker {\n readonly published: EventParams[] = [];\n readonly subscribed: EventSubscriber[] = [];\n\n async publish(params: EventParams): Promise<void> {\n this.published.push(params);\n }\n\n subscribe(\n ...subscribers: Array<EventSubscriber | Array<EventSubscriber>>\n ): void {\n this.subscribed.push(...subscribers.flat());\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 { EventBroker, EventPublisher } from '@backstage/plugin-events-node';\n\n/**\n * @public\n * @deprecated `EventPublisher` was replaced by `EventsService.publish`\n */\nexport class TestEventPublisher implements EventPublisher {\n #eventBroker?: EventBroker;\n\n async setEventBroker(eventBroker: EventBroker): Promise<void> {\n this.#eventBroker = eventBroker;\n }\n\n get eventBroker() {\n return this.#eventBroker;\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 { EventParams, EventSubscriber } from '@backstage/plugin-events-node';\n\n/**\n * @public\n * @deprecated `EventSubscriber` was replaced by `EventsService.subscribe`.\n */\nexport class TestEventSubscriber implements EventSubscriber {\n readonly name: string;\n readonly topics: string[];\n\n readonly receivedEvents: Record<string, EventParams[]> = {};\n\n constructor(name: string, topics: string[]) {\n this.name = name;\n this.topics = topics;\n }\n\n supportsEventTopics(): string[] {\n return this.topics;\n }\n\n async onEvent(params: EventParams): Promise<void> {\n this.receivedEvents[params.topic] = this.receivedEvents[params.topic] ?? [];\n this.receivedEvents[params.topic].push(params);\n }\n}\n","/*\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\nimport {\n EventParams,\n EventsService,\n EventsServiceSubscribeOptions,\n} from '@backstage/plugin-events-node';\n\n/** @public */\nexport class TestEventsService implements EventsService {\n #published: EventParams[] = [];\n #subscribed: EventsServiceSubscribeOptions[] = [];\n\n async publish(params: EventParams): Promise<void> {\n this.#published.push(params);\n }\n\n async subscribe(options: EventsServiceSubscribeOptions): Promise<void> {\n this.#subscribed.push(options);\n }\n\n get published(): EventParams[] {\n return this.#published;\n }\n\n get subscribed(): EventsServiceSubscribeOptions[] {\n return this.#subscribed;\n }\n\n reset(): void {\n this.#published = [];\n this.#subscribed = [];\n }\n}\n"],"names":[],"mappings":";;AA0BO,MAAM,eAAuC,CAAA;AAAA,EACzC,YAA2B,EAAC,CAAA;AAAA,EAC5B,aAAgC,EAAC,CAAA;AAAA,EAE1C,MAAM,QAAQ,MAAoC,EAAA;AAChD,IAAK,IAAA,CAAA,SAAA,CAAU,KAAK,MAAM,CAAA,CAAA;AAAA,GAC5B;AAAA,EAEA,aACK,WACG,EAAA;AACN,IAAA,IAAA,CAAK,UAAW,CAAA,IAAA,CAAK,GAAG,WAAA,CAAY,MAAM,CAAA,CAAA;AAAA,GAC5C;AACF;;ACjBO,MAAM,kBAA6C,CAAA;AAAA,EACxD,YAAA,CAAA;AAAA,EAEA,MAAM,eAAe,WAAyC,EAAA;AAC5D,IAAA,IAAA,CAAK,YAAe,GAAA,WAAA,CAAA;AAAA,GACtB;AAAA,EAEA,IAAI,WAAc,GAAA;AAChB,IAAA,OAAO,IAAK,CAAA,YAAA,CAAA;AAAA,GACd;AACF;;ACVO,MAAM,mBAA+C,CAAA;AAAA,EACjD,IAAA,CAAA;AAAA,EACA,MAAA,CAAA;AAAA,EAEA,iBAAgD,EAAC,CAAA;AAAA,EAE1D,WAAA,CAAY,MAAc,MAAkB,EAAA;AAC1C,IAAA,IAAA,CAAK,IAAO,GAAA,IAAA,CAAA;AACZ,IAAA,IAAA,CAAK,MAAS,GAAA,MAAA,CAAA;AAAA,GAChB;AAAA,EAEA,mBAAgC,GAAA;AAC9B,IAAA,OAAO,IAAK,CAAA,MAAA,CAAA;AAAA,GACd;AAAA,EAEA,MAAM,QAAQ,MAAoC,EAAA;AAChD,IAAK,IAAA,CAAA,cAAA,CAAe,OAAO,KAAK,CAAA,GAAI,KAAK,cAAe,CAAA,MAAA,CAAO,KAAK,CAAA,IAAK,EAAC,CAAA;AAC1E,IAAA,IAAA,CAAK,cAAe,CAAA,MAAA,CAAO,KAAK,CAAA,CAAE,KAAK,MAAM,CAAA,CAAA;AAAA,GAC/C;AACF;;AClBO,MAAM,iBAA2C,CAAA;AAAA,EACtD,aAA4B,EAAC,CAAA;AAAA,EAC7B,cAA+C,EAAC,CAAA;AAAA,EAEhD,MAAM,QAAQ,MAAoC,EAAA;AAChD,IAAK,IAAA,CAAA,UAAA,CAAW,KAAK,MAAM,CAAA,CAAA;AAAA,GAC7B;AAAA,EAEA,MAAM,UAAU,OAAuD,EAAA;AACrE,IAAK,IAAA,CAAA,WAAA,CAAY,KAAK,OAAO,CAAA,CAAA;AAAA,GAC/B;AAAA,EAEA,IAAI,SAA2B,GAAA;AAC7B,IAAA,OAAO,IAAK,CAAA,UAAA,CAAA;AAAA,GACd;AAAA,EAEA,IAAI,UAA8C,GAAA;AAChD,IAAA,OAAO,IAAK,CAAA,WAAA,CAAA;AAAA,GACd;AAAA,EAEA,KAAc,GAAA;AACZ,IAAA,IAAA,CAAK,aAAa,EAAC,CAAA;AACnB,IAAA,IAAA,CAAK,cAAc,EAAC,CAAA;AAAA,GACtB;AACF;;;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-events-backend-test-utils",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.29-next.0",
|
|
4
4
|
"description": "The plugin-events-backend-test-utils for @backstage/plugin-events-node",
|
|
5
5
|
"backstage": {
|
|
6
6
|
"role": "node-library"
|
|
@@ -32,9 +32,9 @@
|
|
|
32
32
|
"test": "backstage-cli package test"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@backstage/plugin-events-node": "^0.3.
|
|
35
|
+
"@backstage/plugin-events-node": "^0.3.5-next.0"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@backstage/cli": "^0.26.
|
|
38
|
+
"@backstage/cli": "^0.26.6-next.0"
|
|
39
39
|
}
|
|
40
40
|
}
|