@bsb/base 9.0.1 → 9.0.3

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.
Files changed (56) hide show
  1. package/README.md +5 -8
  2. package/lib/schemas/config-default.plugin.json +1 -1
  3. package/lib/schemas/events-default.plugin.json +1 -1
  4. package/lib/schemas/observable-default.plugin.json +1 -1
  5. package/lib/serviceBase/plugins.js +10 -20
  6. package/lib/serviceBase/plugins.js.map +1 -1
  7. package/lib/tests/mocks.d.ts +37 -0
  8. package/lib/tests/mocks.js +164 -0
  9. package/lib/tests/mocks.js.map +1 -0
  10. package/lib/tests/sb/plugins/events/broadcast.d.ts +30 -0
  11. package/lib/tests/sb/plugins/events/broadcast.js +357 -0
  12. package/lib/tests/sb/plugins/events/broadcast.js.map +1 -0
  13. package/lib/tests/sb/plugins/events/emit.d.ts +30 -0
  14. package/lib/tests/sb/plugins/events/emit.js +353 -0
  15. package/lib/tests/sb/plugins/events/emit.js.map +1 -0
  16. package/lib/tests/sb/plugins/events/emitAndReturn.d.ts +30 -0
  17. package/lib/tests/sb/plugins/events/emitAndReturn.js +382 -0
  18. package/lib/tests/sb/plugins/events/emitAndReturn.js.map +1 -0
  19. package/lib/{plugins/service-default1/client.d.ts → tests/sb/plugins/events/emitStreamAndReceiveStream.d.ts} +4 -16
  20. package/lib/tests/sb/plugins/events/emitStreamAndReceiveStream.js +298 -0
  21. package/lib/tests/sb/plugins/events/emitStreamAndReceiveStream.js.map +1 -0
  22. package/lib/tests/sb/plugins/events/index.d.ts +28 -0
  23. package/lib/tests/sb/plugins/events/index.js +69 -0
  24. package/lib/tests/sb/plugins/events/index.js.map +1 -0
  25. package/lib/tests/trace.d.ts +41 -0
  26. package/lib/tests/trace.js +85 -0
  27. package/lib/tests/trace.js.map +1 -0
  28. package/lib/tests.d.ts +27 -0
  29. package/lib/{plugins/service-default4/index.js → tests.js} +16 -35
  30. package/lib/tests.js.map +1 -0
  31. package/package.json +92 -91
  32. package/lib/plugins/service-benchmarkify/index.d.ts +0 -312
  33. package/lib/plugins/service-benchmarkify/index.js +0 -138
  34. package/lib/plugins/service-benchmarkify/index.js.map +0 -1
  35. package/lib/plugins/service-default0/index.d.ts +0 -287
  36. package/lib/plugins/service-default0/index.js +0 -118
  37. package/lib/plugins/service-default0/index.js.map +0 -1
  38. package/lib/plugins/service-default1/client.js +0 -70
  39. package/lib/plugins/service-default1/client.js.map +0 -1
  40. package/lib/plugins/service-default1/index.d.ts +0 -304
  41. package/lib/plugins/service-default1/index.js +0 -179
  42. package/lib/plugins/service-default1/index.js.map +0 -1
  43. package/lib/plugins/service-default2/index.d.ts +0 -359
  44. package/lib/plugins/service-default2/index.js +0 -137
  45. package/lib/plugins/service-default2/index.js.map +0 -1
  46. package/lib/plugins/service-default3/index.d.ts +0 -119
  47. package/lib/plugins/service-default3/index.js +0 -88
  48. package/lib/plugins/service-default3/index.js.map +0 -1
  49. package/lib/plugins/service-default4/index.d.ts +0 -81
  50. package/lib/plugins/service-default4/index.js.map +0 -1
  51. package/lib/schemas/service-benchmarkify.json +0 -229
  52. package/lib/schemas/service-default0.json +0 -216
  53. package/lib/schemas/service-default1.json +0 -242
  54. package/lib/schemas/service-default2.json +0 -268
  55. package/lib/schemas/service-default3.json +0 -65
  56. package/lib/schemas/service-default4.json +0 -33
package/package.json CHANGED
@@ -1,91 +1,92 @@
1
- {
2
- "name": "@bsb/base",
3
- "version": "9.0.1",
4
- "license": "(AGPL-3.0-only OR Commercial)",
5
- "author": {
6
- "name": "BetterCorp (PTY) Ltd",
7
- "email": "nick@bettercorp.dev",
8
- "url": "https://bettercorp.dev/"
9
- },
10
- "keywords": [
11
- "bsb",
12
- "base",
13
- "service",
14
- "event-driven",
15
- "microservice",
16
- "framework"
17
- ],
18
- "repository": {
19
- "url": "git+https://github.com/BetterCorp/better-service-base.git"
20
- },
21
- "bsb": {
22
- "publishIgnore": [
23
- "service-default0",
24
- "service-default1",
25
- "service-default2",
26
- "service-default3",
27
- "service-default4"
28
- ]
29
- },
30
- "engines": {
31
- "npm": ">=11.0.0",
32
- "node": ">=23.0.0"
33
- },
34
- "scripts": {
35
- "generate-docs": "typedoc --json ./docs.json --tsconfig ./tsconfig-release.json --cacheBust src/index.ts",
36
- "dev": "ts-node src/dev.ts",
37
- "start": "node lib/cli.js",
38
- "tsc": "echo 'cleaning...' && rm -rf ./lib && echo 'building...' && tsc && echo 'done'",
39
- "build": "rimraf ./lib && tsc && npm run testDev && npm run generate-docs && npm run export-schemas && npm run generate-plugin-json",
40
- "build-release": "rimraf ./lib && tsc --p ./tsconfig-release.json && npm run export-schemas && npm run generate-plugin-json",
41
- "export-schemas": "node -r ts-node/register src/scripts/export-schemas.ts",
42
- "generate-client-types": "node -r ts-node/register src/scripts/generate-client-types.ts",
43
- "generate-plugin-json": "node -r ts-node/register src/scripts/generate-plugin-json.ts",
44
- "publish:client": "node lib/cli.js client publish",
45
- "lint": "eslint src/ --ext .js,.jsx,.ts,.tsx",
46
- "test": "cross-env TS_NODE_PROJECT=tsconfig.test.json NODE_OPTIONS= nyc --reporter json --reporter lcov mocha --reporter json --reporter-options output=junit.json",
47
- "testDev": "cross-env TS_NODE_PROJECT=tsconfig.test.json NODE_OPTIONS= nyc mocha",
48
- "test:watch": "cross-env TS_NODE_PROJECT=tsconfig.test.json NODE_OPTIONS= mocha --watch --watch-files src"
49
- },
50
- "bin": {
51
- "bsb": "lib/cli.js",
52
- "bsb-plugin-cli": "lib/scripts/bsb-plugin-cli.js",
53
- "bsb-client-cli": "lib/scripts/bsb-client-cli.js"
54
- },
55
- "files": [
56
- "lib/**/*",
57
- "bsb-plugin.json",
58
- "README.md",
59
- "LICENSE",
60
- "LICENSE.commercial"
61
- ],
62
- "main": "lib/index.js",
63
- "devDependencies": {
64
- "@eslint/js": "^9.39.2",
65
- "@types/assert": "^1.5.10",
66
- "@types/chai": "^4.3.11",
67
- "@types/js-yaml": "^4.0.9",
68
- "@types/mocha": "^10.0.10",
69
- "@types/node": "^25.1.0",
70
- "@types/uuid": "^10.0.0",
71
- "@typescript-eslint/eslint-plugin": "^8.54.0",
72
- "@typescript-eslint/parser": "^8.54.0",
73
- "benchmarkify": "^4.0.0",
74
- "chai": "^4.3.10",
75
- "chokidar": "^5.0.0",
76
- "cross-env": "^10.1.0",
77
- "eslint": "^9.39.2",
78
- "mocha": "^11.7.5",
79
- "nyc": "^17.1.0",
80
- "rimraf": "^6.1.2",
81
- "ts-morph": "^27.0.2",
82
- "ts-node": "^10.9.2",
83
- "typedoc": "^0.28.16",
84
- "typescript": "^5.9.3"
85
- },
86
- "dependencies": {
87
- "uuid": "^13.0.0",
88
- "yaml": "^2.8.2",
89
- "zod": "^4.3.6"
90
- }
91
- }
1
+ {
2
+ "name": "@bsb/base",
3
+ "version": "9.0.3",
4
+ "license": "(AGPL-3.0-only OR Commercial)",
5
+ "author": {
6
+ "name": "BetterCorp (PTY) Ltd",
7
+ "email": "nick@bettercorp.dev",
8
+ "url": "https://bettercorp.dev/"
9
+ },
10
+ "keywords": [
11
+ "bsb",
12
+ "base",
13
+ "service",
14
+ "event-driven",
15
+ "microservice",
16
+ "framework"
17
+ ],
18
+ "repository": {
19
+ "url": "git+https://github.com/BetterCorp/better-service-base.git"
20
+ },
21
+ "bsb": {
22
+ "publishIgnore": [
23
+ "service-default0",
24
+ "service-default1",
25
+ "service-default2",
26
+ "service-default3",
27
+ "service-default4"
28
+ ]
29
+ },
30
+ "engines": {
31
+ "npm": ">=11.0.0",
32
+ "node": ">=23.0.0"
33
+ },
34
+ "scripts": {
35
+ "generate-docs": "typedoc --json ./docs.json --tsconfig ./tsconfig-release.json --cacheBust src/index.ts",
36
+ "dev": "ts-node src/dev.ts",
37
+ "start": "node lib/cli.js",
38
+ "tsc": "echo 'cleaning...' && rm -rf ./lib && echo 'building...' && tsc && echo 'done'",
39
+ "build": "rimraf ./lib && tsc && npm run testDev && npm run generate-docs && npm run export-schemas && npm run generate-plugin-json",
40
+ "build-release": "rimraf ./lib && tsc --p ./tsconfig-release.json && npm run export-schemas && npm run generate-plugin-json",
41
+ "export-schemas": "node -r ts-node/register src/scripts/export-schemas.ts",
42
+ "generate-client-types": "node -r ts-node/register src/scripts/generate-client-types.ts",
43
+ "generate-plugin-json": "node -r ts-node/register src/scripts/generate-plugin-json.ts",
44
+ "publish:client": "node lib/cli.js client publish",
45
+ "lint": "eslint src/ --ext .js,.jsx,.ts,.tsx",
46
+ "test": "cross-env TS_NODE_PROJECT=tsconfig.test.json NODE_OPTIONS= nyc --reporter json --reporter lcov mocha --reporter json --reporter-options output=junit.json",
47
+ "testDev": "cross-env TS_NODE_PROJECT=tsconfig.test.json NODE_OPTIONS= nyc mocha",
48
+ "test:watch": "cross-env TS_NODE_PROJECT=tsconfig.test.json NODE_OPTIONS= mocha --watch --watch-files src"
49
+ },
50
+ "bin": {
51
+ "bsb": "lib/cli.js",
52
+ "bsb-plugin-cli": "lib/scripts/bsb-plugin-cli.js",
53
+ "bsb-client-cli": "lib/scripts/bsb-client-cli.js"
54
+ },
55
+ "files": [
56
+ "lib/**/*",
57
+ "bsb-plugin.json",
58
+ "README.md",
59
+ "LICENSE",
60
+ "LICENSE.commercial"
61
+ ],
62
+ "main": "lib/index.js",
63
+ "devDependencies": {
64
+ "@eslint/js": "^9.39.2",
65
+ "@types/assert": "^1.5.10",
66
+ "@types/chai": "^4.3.11",
67
+ "@types/js-yaml": "^4.0.9",
68
+ "@types/mocha": "^10.0.10",
69
+ "@types/node": "^25.1.0",
70
+ "@types/uuid": "^10.0.0",
71
+ "@typescript-eslint/eslint-plugin": "^8.54.0",
72
+ "@typescript-eslint/parser": "^8.54.0",
73
+ "benchmarkify": "^4.0.0",
74
+ "chai": "^4.3.10",
75
+ "chokidar": "^5.0.0",
76
+ "cross-env": "^10.1.0",
77
+ "eslint": "^9.39.2",
78
+ "mocha": "^11.7.5",
79
+ "nyc": "^17.1.0",
80
+ "rimraf": "^6.1.2",
81
+ "ts-morph": "^27.0.2",
82
+ "ts-node": "^10.9.2",
83
+ "typedoc": "^0.28.16",
84
+ "typescript": "^5.9.3"
85
+ },
86
+ "dependencies": {
87
+ "uuid": "^13.0.0",
88
+ "yaml": "^2.8.2",
89
+ "zod": "^4.3.6"
90
+ },
91
+ "homepage": "https://bsbcode.dev/"
92
+ }
@@ -1,312 +0,0 @@
1
- /**
2
- * BSB (Better-Service-Base) is an event-bus based microservice framework.
3
- * Copyright (C) 2016 - 2025 BetterCorp (PTY) Ltd
4
- *
5
- * This program is free software: you can redistribute it and/or modify
6
- * it under the terms of the GNU Affero General Public License as published
7
- * by the Free Software Foundation, either version 3 of the License, or
8
- * (at your option) any later version.
9
- *
10
- * Alternatively, you may obtain a commercial license for this program.
11
- * The commercial license allows you to use the Program in a closed-source manner,
12
- * including the right to create derivative works that are not subject to the terms
13
- * of the AGPL.
14
- *
15
- * To obtain a commercial license, please contact the copyright holders at
16
- * https://www.bettercorp.dev. The terms and conditions of the commercial license
17
- * will be provided upon request.
18
- *
19
- * This program is distributed in the hope that it will be useful,
20
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
21
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
- * GNU Affero General Public License for more details.
23
- *
24
- * You should have received a copy of the GNU Affero General Public License
25
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
26
- */
27
- import { Observable } from "../../index";
28
- import { BSBService, BSBServiceConstructor } from "../../base";
29
- import { z } from "zod";
30
- export declare const Config: import("../../index").BSBPluginConfigClass<z.ZodNull>;
31
- export declare const EventSchemas: {
32
- readonly emitEvents: {
33
- readonly 'benchmark.started': {
34
- input: {
35
- _bsb: "object";
36
- properties: {
37
- readonly name: import("../../index").BSBStringType;
38
- readonly timestamp: import("../../index").BSBStringType;
39
- };
40
- required: string[];
41
- description?: string;
42
- optional?: boolean;
43
- nullable?: boolean;
44
- };
45
- description?: string;
46
- readonly __brand: "fire-and-forget";
47
- };
48
- };
49
- readonly onEvents: {
50
- readonly 'benchmark.trigger': {
51
- input: {
52
- _bsb: "object";
53
- properties: {
54
- readonly testName: import("../../index").BSBStringType & {
55
- optional: true;
56
- };
57
- };
58
- required: string[];
59
- description?: string;
60
- optional?: boolean;
61
- nullable?: boolean;
62
- };
63
- description?: string;
64
- readonly __brand: "fire-and-forget";
65
- };
66
- };
67
- readonly emitReturnableEvents: {
68
- readonly 'performance.test': {
69
- input: {
70
- _bsb: "object";
71
- properties: {
72
- readonly iterations: import("../../index").BSBNumberType;
73
- readonly warmup: import("../../index").BSBBooleanType;
74
- };
75
- required: string[];
76
- description?: string;
77
- optional?: boolean;
78
- nullable?: boolean;
79
- };
80
- output: {
81
- _bsb: "object";
82
- properties: {
83
- readonly duration: import("../../index").BSBNumberType;
84
- readonly opsPerSecond: import("../../index").BSBNumberType;
85
- };
86
- required: string[];
87
- description?: string;
88
- optional?: boolean;
89
- nullable?: boolean;
90
- };
91
- description?: string;
92
- defaultTimeout?: number;
93
- readonly __brand: "returnable";
94
- };
95
- };
96
- readonly onReturnableEvents: {
97
- readonly add: {
98
- input: {
99
- _bsb: "object";
100
- properties: {
101
- readonly a: import("../../index").BSBNumberType;
102
- readonly b: import("../../index").BSBNumberType;
103
- };
104
- required: string[];
105
- description?: string;
106
- optional?: boolean;
107
- nullable?: boolean;
108
- };
109
- output: import("../../index").BSBNumberType;
110
- description?: string;
111
- defaultTimeout?: number;
112
- readonly __brand: "returnable";
113
- };
114
- readonly void: {
115
- input: {
116
- _bsb: "object";
117
- properties: {};
118
- required: string[];
119
- description?: string;
120
- optional?: boolean;
121
- nullable?: boolean;
122
- };
123
- output: import("../../index").BSBType;
124
- description?: string;
125
- defaultTimeout?: number;
126
- readonly __brand: "returnable";
127
- };
128
- };
129
- readonly emitBroadcast: {
130
- readonly 'benchmark.results': {
131
- input: {
132
- _bsb: "object";
133
- properties: {
134
- readonly testName: import("../../index").BSBStringType;
135
- readonly results: import("../../index").BSBArrayType;
136
- readonly timestamp: import("../../index").BSBStringType;
137
- };
138
- required: string[];
139
- description?: string;
140
- optional?: boolean;
141
- nullable?: boolean;
142
- };
143
- description?: string;
144
- readonly __brand: "broadcast";
145
- };
146
- };
147
- readonly onBroadcast: {
148
- readonly 'system.load': {
149
- input: {
150
- _bsb: "object";
151
- properties: {
152
- readonly cpuUsage: import("../../index").BSBNumberType;
153
- readonly memoryUsage: import("../../index").BSBNumberType;
154
- readonly timestamp: import("../../index").BSBStringType;
155
- };
156
- required: string[];
157
- description?: string;
158
- optional?: boolean;
159
- nullable?: boolean;
160
- };
161
- description?: string;
162
- readonly __brand: "broadcast";
163
- };
164
- };
165
- };
166
- export declare class Plugin extends BSBService<InstanceType<typeof Config>, typeof EventSchemas> {
167
- static Config: import("../../index").BSBPluginConfigClass<z.ZodNull>;
168
- static EventSchemas: {
169
- readonly emitEvents: {
170
- readonly 'benchmark.started': {
171
- input: {
172
- _bsb: "object";
173
- properties: {
174
- readonly name: import("../../index").BSBStringType;
175
- readonly timestamp: import("../../index").BSBStringType;
176
- };
177
- required: string[];
178
- description?: string;
179
- optional?: boolean;
180
- nullable?: boolean;
181
- };
182
- description?: string;
183
- readonly __brand: "fire-and-forget";
184
- };
185
- };
186
- readonly onEvents: {
187
- readonly 'benchmark.trigger': {
188
- input: {
189
- _bsb: "object";
190
- properties: {
191
- readonly testName: import("../../index").BSBStringType & {
192
- optional: true;
193
- };
194
- };
195
- required: string[];
196
- description?: string;
197
- optional?: boolean;
198
- nullable?: boolean;
199
- };
200
- description?: string;
201
- readonly __brand: "fire-and-forget";
202
- };
203
- };
204
- readonly emitReturnableEvents: {
205
- readonly 'performance.test': {
206
- input: {
207
- _bsb: "object";
208
- properties: {
209
- readonly iterations: import("../../index").BSBNumberType;
210
- readonly warmup: import("../../index").BSBBooleanType;
211
- };
212
- required: string[];
213
- description?: string;
214
- optional?: boolean;
215
- nullable?: boolean;
216
- };
217
- output: {
218
- _bsb: "object";
219
- properties: {
220
- readonly duration: import("../../index").BSBNumberType;
221
- readonly opsPerSecond: import("../../index").BSBNumberType;
222
- };
223
- required: string[];
224
- description?: string;
225
- optional?: boolean;
226
- nullable?: boolean;
227
- };
228
- description?: string;
229
- defaultTimeout?: number;
230
- readonly __brand: "returnable";
231
- };
232
- };
233
- readonly onReturnableEvents: {
234
- readonly add: {
235
- input: {
236
- _bsb: "object";
237
- properties: {
238
- readonly a: import("../../index").BSBNumberType;
239
- readonly b: import("../../index").BSBNumberType;
240
- };
241
- required: string[];
242
- description?: string;
243
- optional?: boolean;
244
- nullable?: boolean;
245
- };
246
- output: import("../../index").BSBNumberType;
247
- description?: string;
248
- defaultTimeout?: number;
249
- readonly __brand: "returnable";
250
- };
251
- readonly void: {
252
- input: {
253
- _bsb: "object";
254
- properties: {};
255
- required: string[];
256
- description?: string;
257
- optional?: boolean;
258
- nullable?: boolean;
259
- };
260
- output: import("../../index").BSBType;
261
- description?: string;
262
- defaultTimeout?: number;
263
- readonly __brand: "returnable";
264
- };
265
- };
266
- readonly emitBroadcast: {
267
- readonly 'benchmark.results': {
268
- input: {
269
- _bsb: "object";
270
- properties: {
271
- readonly testName: import("../../index").BSBStringType;
272
- readonly results: import("../../index").BSBArrayType;
273
- readonly timestamp: import("../../index").BSBStringType;
274
- };
275
- required: string[];
276
- description?: string;
277
- optional?: boolean;
278
- nullable?: boolean;
279
- };
280
- description?: string;
281
- readonly __brand: "broadcast";
282
- };
283
- };
284
- readonly onBroadcast: {
285
- readonly 'system.load': {
286
- input: {
287
- _bsb: "object";
288
- properties: {
289
- readonly cpuUsage: import("../../index").BSBNumberType;
290
- readonly memoryUsage: import("../../index").BSBNumberType;
291
- readonly timestamp: import("../../index").BSBStringType;
292
- };
293
- required: string[];
294
- description?: string;
295
- optional?: boolean;
296
- nullable?: boolean;
297
- };
298
- description?: string;
299
- readonly __brand: "broadcast";
300
- };
301
- };
302
- };
303
- initBeforePlugins?: string[] | undefined;
304
- runBeforePlugins?: string[] | undefined;
305
- runAfterPlugins?: string[] | undefined;
306
- initAfterPlugins?: string[] | undefined;
307
- private self;
308
- dispose?(): void;
309
- init(obs: Observable): Promise<void>;
310
- constructor(config: BSBServiceConstructor<InstanceType<typeof Config>, typeof EventSchemas>);
311
- run(obs: Observable): Promise<void>;
312
- }
@@ -1,138 +0,0 @@
1
- "use strict";
2
- /**
3
- * BSB (Better-Service-Base) is an event-bus based microservice framework.
4
- * Copyright (C) 2016 - 2025 BetterCorp (PTY) Ltd
5
- *
6
- * This program is free software: you can redistribute it and/or modify
7
- * it under the terms of the GNU Affero General Public License as published
8
- * by the Free Software Foundation, either version 3 of the License, or
9
- * (at your option) any later version.
10
- *
11
- * Alternatively, you may obtain a commercial license for this program.
12
- * The commercial license allows you to use the Program in a closed-source manner,
13
- * including the right to create derivative works that are not subject to the terms
14
- * of the AGPL.
15
- *
16
- * To obtain a commercial license, please contact the copyright holders at
17
- * https://www.bettercorp.dev. The terms and conditions of the commercial license
18
- * will be provided upon request.
19
- *
20
- * This program is distributed in the hope that it will be useful,
21
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
22
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
- * GNU Affero General Public License for more details.
24
- *
25
- * You should have received a copy of the GNU Affero General Public License
26
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
27
- */
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.Plugin = exports.EventSchemas = exports.Config = void 0;
30
- const index_1 = require("../../index");
31
- const base_1 = require("../../base");
32
- const schema_events_1 = require("../../interfaces/schema-events");
33
- const zod_1 = require("zod");
34
- const Benchmarkify = require("benchmarkify");
35
- exports.Config = (0, base_1.createConfigSchema)({
36
- name: 'service-benchmarkify',
37
- description: 'Benchmarking service for performance testing',
38
- version: '1.0.0',
39
- image: '../docs/public/assets/images/bsb-logo.png',
40
- tags: ['benchmark', 'performance', 'test'],
41
- }, zod_1.z.null());
42
- exports.EventSchemas = (0, schema_events_1.createEventSchemas)({
43
- // Events this service emits (fire-and-forget, first listener receives)
44
- emitEvents: {
45
- 'benchmark.started': (0, schema_events_1.createFireAndForgetEvent)(base_1.bsb.object({
46
- name: base_1.bsb.string({ description: 'Benchmark name' }),
47
- timestamp: base_1.bsb.datetime('Start timestamp')
48
- }, 'Benchmark start parameters'), 'Benchmark test started')
49
- },
50
- // Events this service listens to (fire-and-forget)
51
- onEvents: {
52
- 'benchmark.trigger': (0, schema_events_1.createFireAndForgetEvent)(base_1.bsb.object({
53
- testName: (0, base_1.optional)(base_1.bsb.string({ description: 'Name of test to run' }))
54
- }, 'Benchmark trigger parameters'), 'Trigger benchmark execution')
55
- },
56
- // Returnable events this service emits (requests from this service)
57
- emitReturnableEvents: {
58
- 'performance.test': (0, schema_events_1.createReturnableEvent)(base_1.bsb.object({
59
- iterations: base_1.bsb.number({ description: 'Number of iterations to run' }),
60
- warmup: base_1.bsb.boolean('Whether to run warmup iterations')
61
- }, 'Performance test parameters'), base_1.bsb.object({
62
- duration: base_1.bsb.number({ description: 'Test duration in milliseconds' }),
63
- opsPerSecond: base_1.bsb.number({ description: 'Operations per second' })
64
- }, 'Performance test results'), 'Request performance test execution')
65
- },
66
- // Returnable events this service listens to (requests to this service)
67
- onReturnableEvents: {
68
- add: (0, schema_events_1.createReturnableEvent)(base_1.bsb.object({
69
- a: base_1.bsb.number({ description: 'First number' }),
70
- b: base_1.bsb.number({ description: 'Second number' })
71
- }, 'Add input parameters'), base_1.bsb.number({ description: 'Sum of numbers' }), 'Add two numbers'),
72
- void: (0, schema_events_1.createReturnableEvent)(base_1.bsb.object({}, 'Empty parameters'), base_1.bsb.void(), 'Void event for benchmarking')
73
- },
74
- // Broadcast events this service emits (all listeners receive)
75
- emitBroadcast: {
76
- 'benchmark.results': (0, schema_events_1.createBroadcastEvent)(base_1.bsb.object({
77
- testName: base_1.bsb.string({ description: 'Test name' }),
78
- results: base_1.bsb.array(base_1.bsb.object({
79
- operation: base_1.bsb.string({ description: 'Operation name' }),
80
- opsPerSecond: base_1.bsb.number({ description: 'Operations per second' }),
81
- duration: base_1.bsb.number({ description: 'Duration in milliseconds' })
82
- }, 'Benchmark result entry'), { description: 'Array of benchmark results' }),
83
- timestamp: base_1.bsb.datetime('Results timestamp')
84
- }, 'Benchmark results parameters'), 'Broadcast benchmark results to all interested parties')
85
- },
86
- // Broadcast events this service listens to
87
- onBroadcast: {
88
- 'system.load': (0, schema_events_1.createBroadcastEvent)(base_1.bsb.object({
89
- cpuUsage: base_1.bsb.number({ description: 'CPU usage percentage' }),
90
- memoryUsage: base_1.bsb.number({ description: 'Memory usage percentage' }),
91
- timestamp: base_1.bsb.datetime('Load measurement timestamp')
92
- }, 'System load parameters'), 'Listen for system load updates')
93
- }
94
- });
95
- class Plugin extends base_1.BSBService {
96
- static Config = exports.Config;
97
- static EventSchemas = exports.EventSchemas;
98
- // PLUGIN_CLIENT auto-generated from Config.metadata
99
- initBeforePlugins;
100
- runBeforePlugins;
101
- runAfterPlugins;
102
- initAfterPlugins;
103
- self;
104
- async init(obs) {
105
- await this.events.onReturnableEvent('add', obs, async (obs, input) => {
106
- return input.a + input.b;
107
- });
108
- await this.events.onReturnableEvent('void', obs, async (obs, input) => {
109
- return;
110
- });
111
- await this.events.onEvent('benchmark.trigger', obs, async (obs, input) => {
112
- obs.log.info("Benchmark triggered: {testName}", { testName: input.testName || 'default' });
113
- return;
114
- });
115
- }
116
- ;
117
- constructor(config) {
118
- super(config);
119
- this.self = new index_1.ServiceClient(Plugin, this);
120
- }
121
- async run(obs) {
122
- obs.log.info("Running service-benchmarkify");
123
- let benchmark = new Benchmarkify("BSB benchmark").printHeader();
124
- const bench = benchmark.createSuite("Call local actions");
125
- const self = this;
126
- bench.add("BSB:emitEventAndReturn:add", async (done) => {
127
- await self.self.events.emitEventAndReturn('add', obs, { a: 5, b: 3 }, 1);
128
- done();
129
- });
130
- bench.add("BSB:emitEventAndReturn:void", async (done) => {
131
- await self.self.events.emitEventAndReturn('void', obs, {}, 1);
132
- done();
133
- });
134
- await benchmark.run();
135
- }
136
- }
137
- exports.Plugin = Plugin;
138
- //# sourceMappingURL=index.js.map
@@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