@bsb/tests 0.0.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/README.md +7 -0
- package/bin/bsb-tests.cjs +376 -0
- package/docs/index.md +101 -0
- package/lib/index.d.ts +7 -0
- package/lib/index.js +24 -0
- package/lib/index.js.map +1 -0
- package/lib/mocks.d.ts +39 -0
- package/lib/mocks.js +191 -0
- package/lib/mocks.js.map +1 -0
- package/lib/plugins/config-default/index.d.ts +27 -0
- package/lib/plugins/config-default/index.js +172 -0
- package/lib/plugins/config-default/index.js.map +1 -0
- package/lib/plugins/events-default/index.d.ts +27 -0
- package/lib/plugins/events-default/index.js +143 -0
- package/lib/plugins/events-default/index.js.map +1 -0
- package/lib/plugins/logging-default/index.d.ts +27 -0
- package/lib/plugins/logging-default/index.js +390 -0
- package/lib/plugins/logging-default/index.js.map +1 -0
- package/lib/plugins/observable-default/index.d.ts +27 -0
- package/lib/plugins/observable-default/index.js +166 -0
- package/lib/plugins/observable-default/index.js.map +1 -0
- package/lib/runner/plugin-custom.d.ts +1 -0
- package/lib/runner/plugin-custom.js +119 -0
- package/lib/runner/plugin-custom.js.map +1 -0
- package/lib/runner/plugin-events.d.ts +1 -0
- package/lib/runner/plugin-events.js +37 -0
- package/lib/runner/plugin-events.js.map +1 -0
- package/lib/runner/plugin-observable.d.ts +1 -0
- package/lib/runner/plugin-observable.js +22 -0
- package/lib/runner/plugin-observable.js.map +1 -0
- package/lib/runner/setup.d.ts +1 -0
- package/lib/runner/setup.js +19 -0
- package/lib/runner/setup.js.map +1 -0
- package/lib/sb/plugins/events/broadcast.d.ts +30 -0
- package/lib/sb/plugins/events/broadcast.js +390 -0
- package/lib/sb/plugins/events/broadcast.js.map +1 -0
- package/lib/sb/plugins/events/emit.d.ts +30 -0
- package/lib/sb/plugins/events/emit.js +386 -0
- package/lib/sb/plugins/events/emit.js.map +1 -0
- package/lib/sb/plugins/events/emitAndReturn.d.ts +30 -0
- package/lib/sb/plugins/events/emitAndReturn.js +415 -0
- package/lib/sb/plugins/events/emitAndReturn.js.map +1 -0
- package/lib/sb/plugins/events/emitStreamAndReceiveStream.d.ts +30 -0
- package/lib/sb/plugins/events/emitStreamAndReceiveStream.js +331 -0
- package/lib/sb/plugins/events/emitStreamAndReceiveStream.js.map +1 -0
- package/lib/sb/plugins/events/index.d.ts +28 -0
- package/lib/sb/plugins/events/index.js +69 -0
- package/lib/sb/plugins/events/index.js.map +1 -0
- package/lib/sb/plugins/events/plugin.d.ts +0 -0
- package/lib/sb/plugins/events/plugin.js +2 -0
- package/lib/sb/plugins/events/plugin.js.map +1 -0
- package/lib/sb/plugins/observable/index.d.ts +28 -0
- package/lib/sb/plugins/observable/index.js +141 -0
- package/lib/sb/plugins/observable/index.js.map +1 -0
- package/lib/trace.d.ts +40 -0
- package/lib/trace.js +85 -0
- package/lib/trace.js.map +1 -0
- package/package.json +51 -0
|
@@ -0,0 +1,331 @@
|
|
|
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
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
29
|
+
if (k2 === undefined) k2 = k;
|
|
30
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
31
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
32
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
33
|
+
}
|
|
34
|
+
Object.defineProperty(o, k2, desc);
|
|
35
|
+
}) : (function(o, m, k, k2) {
|
|
36
|
+
if (k2 === undefined) k2 = k;
|
|
37
|
+
o[k2] = m[k];
|
|
38
|
+
}));
|
|
39
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
40
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
41
|
+
}) : function(o, v) {
|
|
42
|
+
o["default"] = v;
|
|
43
|
+
});
|
|
44
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
45
|
+
var ownKeys = function(o) {
|
|
46
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
47
|
+
var ar = [];
|
|
48
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
49
|
+
return ar;
|
|
50
|
+
};
|
|
51
|
+
return ownKeys(o);
|
|
52
|
+
};
|
|
53
|
+
return function (mod) {
|
|
54
|
+
if (mod && mod.__esModule) return mod;
|
|
55
|
+
var result = {};
|
|
56
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
57
|
+
__setModuleDefault(result, mod);
|
|
58
|
+
return result;
|
|
59
|
+
};
|
|
60
|
+
})();
|
|
61
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
62
|
+
exports.emitStreamAndReceiveStream = emitStreamAndReceiveStream;
|
|
63
|
+
const fs = __importStar(require("fs"));
|
|
64
|
+
const crypto = __importStar(require("crypto"));
|
|
65
|
+
const stream_1 = require("stream");
|
|
66
|
+
const assert = __importStar(require("assert"));
|
|
67
|
+
const base_1 = require("@bsb/base");
|
|
68
|
+
const trace_1 = require("../../../trace");
|
|
69
|
+
const randomName = () => crypto.randomUUID();
|
|
70
|
+
const mockBareFakeStream = () => {
|
|
71
|
+
const obj = {
|
|
72
|
+
listeners: {},
|
|
73
|
+
emit: (name, data) => {
|
|
74
|
+
if (obj.listeners[name] !== undefined) {
|
|
75
|
+
obj.listeners[name](data);
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
on: (name, listn) => {
|
|
79
|
+
obj.listeners[name] = listn;
|
|
80
|
+
},
|
|
81
|
+
destroy: () => {
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
return obj;
|
|
85
|
+
};
|
|
86
|
+
const getFileHash = (filename) => new Promise((resolve, reject) => {
|
|
87
|
+
const fd = fs.createReadStream(filename);
|
|
88
|
+
// deepcode ignore InsecureHash/test: not production, just using to verify the files hash
|
|
89
|
+
const hash = crypto.createHash("sha1");
|
|
90
|
+
hash.setEncoding("hex");
|
|
91
|
+
fd.on("error", reject);
|
|
92
|
+
fd.on("end", () => {
|
|
93
|
+
hash.end();
|
|
94
|
+
resolve(hash.read());
|
|
95
|
+
});
|
|
96
|
+
// read all file and pipe it (write it) to the hash object
|
|
97
|
+
fd.pipe(hash);
|
|
98
|
+
});
|
|
99
|
+
// Cross-platform function to create test files with random data
|
|
100
|
+
const createTestFile = (filePath, sizeStr) => {
|
|
101
|
+
return new Promise((resolve, reject) => {
|
|
102
|
+
// Parse size string (e.g., "1KB", "16MB")
|
|
103
|
+
const match = sizeStr.match(/^(\d+)(KB|MB)$/);
|
|
104
|
+
if (!match) {
|
|
105
|
+
return reject(new Error(`Invalid size format: ${sizeStr}`));
|
|
106
|
+
}
|
|
107
|
+
const num = parseInt(match[1], 10);
|
|
108
|
+
const unit = match[2];
|
|
109
|
+
const sizeBytes = unit === 'KB' ? num * 1024 : num * 1024 * 1024;
|
|
110
|
+
// Create random data in chunks
|
|
111
|
+
const writeStream = fs.createWriteStream(filePath);
|
|
112
|
+
const chunkSize = 64 * 1024; // 64KB chunks
|
|
113
|
+
let written = 0;
|
|
114
|
+
const writeChunk = () => {
|
|
115
|
+
while (written < sizeBytes) {
|
|
116
|
+
const remaining = sizeBytes - written;
|
|
117
|
+
const size = Math.min(chunkSize, remaining);
|
|
118
|
+
const buffer = crypto.randomBytes(size);
|
|
119
|
+
const canContinue = writeStream.write(buffer);
|
|
120
|
+
written += size;
|
|
121
|
+
if (!canContinue) {
|
|
122
|
+
// Wait for drain event
|
|
123
|
+
writeStream.once('drain', writeChunk);
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
writeStream.end();
|
|
128
|
+
};
|
|
129
|
+
writeStream.on('finish', () => resolve());
|
|
130
|
+
writeStream.on('error', reject);
|
|
131
|
+
writeChunk();
|
|
132
|
+
});
|
|
133
|
+
};
|
|
134
|
+
// const convertBytes = (
|
|
135
|
+
// bytes: number,
|
|
136
|
+
// sizes = [
|
|
137
|
+
// "Bytes",
|
|
138
|
+
// "KB",
|
|
139
|
+
// "MB",
|
|
140
|
+
// "GB",
|
|
141
|
+
// "TB",
|
|
142
|
+
// ],
|
|
143
|
+
// ) => {
|
|
144
|
+
// if (bytes == 0) {
|
|
145
|
+
// return "n/a";
|
|
146
|
+
// }
|
|
147
|
+
// //const i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024)));
|
|
148
|
+
// const i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024))
|
|
149
|
+
// .toString());
|
|
150
|
+
// if (i == 0) {
|
|
151
|
+
// return bytes + " " + sizes[i];
|
|
152
|
+
// }
|
|
153
|
+
// return (
|
|
154
|
+
// bytes / Math.pow(1024, i)
|
|
155
|
+
// ).toFixed(1) + " " + sizes[i];
|
|
156
|
+
// };
|
|
157
|
+
function emitStreamAndReceiveStream(genNewPlugin, maxTimeoutToExpectAResponse) {
|
|
158
|
+
let emitter;
|
|
159
|
+
beforeEach(async () => {
|
|
160
|
+
emitter = await genNewPlugin();
|
|
161
|
+
});
|
|
162
|
+
afterEach(function () {
|
|
163
|
+
(0, base_1.SmartFunctionCallSync)(emitter, emitter.dispose);
|
|
164
|
+
});
|
|
165
|
+
describe("EmitStreamAndReceiveStream", async () => {
|
|
166
|
+
//this.timeout(maxTimeoutToExpectAResponse + 20);
|
|
167
|
+
//this.afterEach(done => setTimeout(done, maxTimeoutToExpectAResponse));
|
|
168
|
+
const timermaxTimeoutToExpectAResponse = maxTimeoutToExpectAResponse + 10;
|
|
169
|
+
it("receiveStream creates a should generate a valid string", async () => {
|
|
170
|
+
const thisCaller = randomName();
|
|
171
|
+
const thisCallerEvent = randomName();
|
|
172
|
+
const obs = (0, trace_1.createTestObservable)();
|
|
173
|
+
const uuid = await emitter.receiveStream(obs, thisCaller, thisCallerEvent, async (receivedObs, error, stream) => {
|
|
174
|
+
}, maxTimeoutToExpectAResponse);
|
|
175
|
+
assert.ok(`${uuid}`.length >= 10, "Not a valid unique ID for stream");
|
|
176
|
+
});
|
|
177
|
+
it("sendStream triggers timeout when no receiveStream setup", async () => {
|
|
178
|
+
const thisCaller = randomName();
|
|
179
|
+
const thisEvent = randomName();
|
|
180
|
+
// Use proper streamId format: uuid=timeoutSeconds
|
|
181
|
+
const streamId = `${randomName()}=1`;
|
|
182
|
+
const obs = (0, trace_1.createTestObservable)();
|
|
183
|
+
try {
|
|
184
|
+
await emitter.sendStream(obs, thisCaller, thisEvent, streamId, mockBareFakeStream());
|
|
185
|
+
assert.fail("Timeout not called");
|
|
186
|
+
}
|
|
187
|
+
catch {
|
|
188
|
+
assert.ok(true, "Timeout called exception");
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
it("sendStream triggers receiveStream listener", async () => {
|
|
192
|
+
const thisCaller = randomName();
|
|
193
|
+
const thisCallerEvent = randomName();
|
|
194
|
+
const obs = (0, trace_1.createTestObservable)();
|
|
195
|
+
const emitTimeout = setTimeout(() => {
|
|
196
|
+
assert.fail("Event not received");
|
|
197
|
+
}, timermaxTimeoutToExpectAResponse);
|
|
198
|
+
const uuid = await emitter.receiveStream(obs, thisCaller, thisCallerEvent, async (receivedObs, error, stream) => {
|
|
199
|
+
clearTimeout(emitTimeout);
|
|
200
|
+
stream.emit("end");
|
|
201
|
+
assert.ok(true, "Listener called");
|
|
202
|
+
}, maxTimeoutToExpectAResponse);
|
|
203
|
+
try {
|
|
204
|
+
await emitter.sendStream(obs, thisCaller, thisCallerEvent, uuid, mockBareFakeStream());
|
|
205
|
+
//console.log("endededed");
|
|
206
|
+
// eslint-disable-next-line no-empty
|
|
207
|
+
}
|
|
208
|
+
catch {
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
describe("sendStream triggers receiveStream listener passing in the stream", async () => {
|
|
212
|
+
it("should not call the listener with an error", async () => {
|
|
213
|
+
const thisCaller = randomName();
|
|
214
|
+
const thisCallerEvent = randomName();
|
|
215
|
+
const obs = (0, trace_1.createTestObservable)();
|
|
216
|
+
const emitTimeout = setTimeout(() => {
|
|
217
|
+
assert.fail("Event not received");
|
|
218
|
+
}, timermaxTimeoutToExpectAResponse);
|
|
219
|
+
const uuid = await emitter.receiveStream(obs, thisCaller, thisCallerEvent, async (receivedObs, error, stream) => {
|
|
220
|
+
clearTimeout(emitTimeout);
|
|
221
|
+
stream.emit("end");
|
|
222
|
+
assert.strictEqual(error, null, "Error is not null");
|
|
223
|
+
}, maxTimeoutToExpectAResponse);
|
|
224
|
+
try {
|
|
225
|
+
await emitter.sendStream(obs, thisCaller, thisCallerEvent, uuid, mockBareFakeStream());
|
|
226
|
+
// eslint-disable-next-line no-empty
|
|
227
|
+
}
|
|
228
|
+
catch {
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
it("should call the listener with a stream", async () => {
|
|
232
|
+
const thisCaller = randomName();
|
|
233
|
+
const thisCallerEvent = randomName();
|
|
234
|
+
const obs = (0, trace_1.createTestObservable)();
|
|
235
|
+
const emitTimeout = setTimeout(() => {
|
|
236
|
+
assert.fail("Event not received");
|
|
237
|
+
}, timermaxTimeoutToExpectAResponse);
|
|
238
|
+
const uuid = await emitter.receiveStream(obs, thisCaller, thisCallerEvent, async (receivedObs, error, stream) => {
|
|
239
|
+
clearTimeout(emitTimeout);
|
|
240
|
+
stream.emit("end");
|
|
241
|
+
assert.strictEqual(typeof stream, typeof mockBareFakeStream(), "Listener called");
|
|
242
|
+
}, maxTimeoutToExpectAResponse);
|
|
243
|
+
try {
|
|
244
|
+
await emitter.sendStream(obs, thisCaller, thisCallerEvent, uuid, mockBareFakeStream());
|
|
245
|
+
// eslint-disable-next-line no-empty
|
|
246
|
+
}
|
|
247
|
+
catch {
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
});
|
|
251
|
+
describe("sendStream triggers receiveStream files", function () {
|
|
252
|
+
this.timeout(120000);
|
|
253
|
+
const runTest = async (size, count = 1) => {
|
|
254
|
+
it(`should be able to fully stream a file - ${size}`, async function () {
|
|
255
|
+
this.timeout(120000);
|
|
256
|
+
const thisCaller = randomName();
|
|
257
|
+
const thisCallerEvent = randomName();
|
|
258
|
+
const obs = (0, trace_1.createTestObservable)();
|
|
259
|
+
//const now = new Date().getTime();
|
|
260
|
+
const fileName = `./test-file-${size}`;
|
|
261
|
+
const fileNameOut = fileName + "-out";
|
|
262
|
+
try {
|
|
263
|
+
// Create test file with random data (cross-platform)
|
|
264
|
+
await createTestFile(fileName, size);
|
|
265
|
+
//const fileBytes = fs.statSync(fileName).size;
|
|
266
|
+
//const fullBytes = convertBytes(fileBytes);
|
|
267
|
+
//console.log(` ${size} act size: ${fullBytes}`);
|
|
268
|
+
const srcFileHash = await getFileHash(fileName);
|
|
269
|
+
const emitTimeout = setTimeout(() => {
|
|
270
|
+
assert.fail("Event not received");
|
|
271
|
+
}, timermaxTimeoutToExpectAResponse);
|
|
272
|
+
const uuid = await emitter.receiveStream(obs, thisCaller, thisCallerEvent, async (receivedObs, error, stream) => {
|
|
273
|
+
if (error) {
|
|
274
|
+
return assert.fail(error);
|
|
275
|
+
}
|
|
276
|
+
clearTimeout(emitTimeout);
|
|
277
|
+
(0, stream_1.pipeline)(stream, fs.createWriteStream(fileNameOut), (errf) => {
|
|
278
|
+
if (errf) {
|
|
279
|
+
assert.fail(errf);
|
|
280
|
+
}
|
|
281
|
+
});
|
|
282
|
+
}, maxTimeoutToExpectAResponse);
|
|
283
|
+
await emitter.sendStream(obs, thisCaller, thisCallerEvent, uuid, fs.createReadStream(fileName));
|
|
284
|
+
fs.unlinkSync(fileName);
|
|
285
|
+
assert.strictEqual(await getFileHash(fileNameOut), srcFileHash, "Validate data equals");
|
|
286
|
+
fs.unlinkSync(fileNameOut);
|
|
287
|
+
//const done = new Date().getTime();
|
|
288
|
+
//const totalTimeMS = done - now;
|
|
289
|
+
// const bytesPerSecond = fileBytes / (
|
|
290
|
+
// totalTimeMS / 1000
|
|
291
|
+
// );
|
|
292
|
+
// console.log(
|
|
293
|
+
// ` ${size} act size: ${fullBytes} as ${convertBytes(
|
|
294
|
+
// bytesPerSecond,
|
|
295
|
+
// [
|
|
296
|
+
// "bps",
|
|
297
|
+
// "kbps",
|
|
298
|
+
// "mbps",
|
|
299
|
+
// "gbps",
|
|
300
|
+
// "tbps",
|
|
301
|
+
// ],
|
|
302
|
+
// )} in ${totalTimeMS}ms`,
|
|
303
|
+
// );
|
|
304
|
+
}
|
|
305
|
+
catch (xx) {
|
|
306
|
+
if (fs.existsSync(fileName)) {
|
|
307
|
+
fs.unlinkSync(fileName);
|
|
308
|
+
}
|
|
309
|
+
if (fs.existsSync(fileNameOut)) {
|
|
310
|
+
fs.unlinkSync(fileNameOut);
|
|
311
|
+
}
|
|
312
|
+
assert.fail(xx.toString());
|
|
313
|
+
}
|
|
314
|
+
});
|
|
315
|
+
};
|
|
316
|
+
runTest("1KB");
|
|
317
|
+
runTest("16KB");
|
|
318
|
+
runTest("128KB");
|
|
319
|
+
runTest("512KB");
|
|
320
|
+
runTest("1MB");
|
|
321
|
+
runTest("16MB");
|
|
322
|
+
//runTest("128MB", 1);
|
|
323
|
+
//runTest("128MB", 4);
|
|
324
|
+
//runTest('512MB', 16);
|
|
325
|
+
//runTest('1GB', 32);
|
|
326
|
+
//runTest('5GB', 160);
|
|
327
|
+
//runTest('12GB', 384);
|
|
328
|
+
});
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
//# sourceMappingURL=emitStreamAndReceiveStream.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emitStreamAndReceiveStream.js","sourceRoot":"","sources":["../../../../src/sb/plugins/events/emitStreamAndReceiveStream.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqHH,gEAmOC;AAtVD,uCAAyB;AACzB,+CAAiC;AACjC,mCAAkC;AAElC,+CAAiC;AACjC,oCAAyE;AACzE,0CAAsD;AAEtD,MAAM,UAAU,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;AAE7C,MAAM,kBAAkB,GAAG,GAAG,EAAE;IAC9B,MAAM,GAAG,GAAQ;QACf,SAAS,EAAE,EAAE;QACb,IAAI,EAAE,CAAC,IAAS,EAAE,IAAU,EAAE,EAAE;YAC9B,IAAI,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,SAAS,EAAE,CAAC;gBACtC,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;YAC5B,CAAC;QACH,CAAC;QACD,EAAE,EAAE,CAA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orp (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 { BSBEventsRef } from "@bsb/base";
|
|
28
|
+
export declare const RunEventsPluginTests: (eventsPlugin: typeof BSBEventsRef, config?: any) => void;
|
|
@@ -0,0 +1,69 @@
|
|
|
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.RunEventsPluginTests = void 0;
|
|
30
|
+
const broadcast_1 = require("./broadcast");
|
|
31
|
+
const emit_1 = require("./emit");
|
|
32
|
+
const emitAndReturn_1 = require("./emitAndReturn");
|
|
33
|
+
const emitStreamAndReceiveStream_1 = require("./emitStreamAndReceiveStream");
|
|
34
|
+
const mocks_1 = require("../../../mocks");
|
|
35
|
+
const trace_1 = require("../../../trace");
|
|
36
|
+
const RunEventsPluginTests = (eventsPlugin, config = undefined) => {
|
|
37
|
+
const obs = (0, trace_1.createTestObservable)();
|
|
38
|
+
(0, broadcast_1.broadcast)(async () => {
|
|
39
|
+
const refP = new eventsPlugin(await (0, mocks_1.getEventsConstructorConfig)(config));
|
|
40
|
+
if (refP.init !== undefined) {
|
|
41
|
+
await refP.init(obs);
|
|
42
|
+
}
|
|
43
|
+
return refP;
|
|
44
|
+
}, 100);
|
|
45
|
+
(0, emit_1.emit)(async () => {
|
|
46
|
+
const refP = new eventsPlugin(await (0, mocks_1.getEventsConstructorConfig)(config));
|
|
47
|
+
if (refP.init !== undefined) {
|
|
48
|
+
await refP.init(obs);
|
|
49
|
+
}
|
|
50
|
+
return refP;
|
|
51
|
+
}, 100);
|
|
52
|
+
(0, emitAndReturn_1.emitAndReturn)(async () => {
|
|
53
|
+
const refP = new eventsPlugin(await (0, mocks_1.getEventsConstructorConfig)(config));
|
|
54
|
+
if (refP.init !== undefined) {
|
|
55
|
+
await refP.init(obs);
|
|
56
|
+
}
|
|
57
|
+
return refP;
|
|
58
|
+
}, 100);
|
|
59
|
+
(0, emitStreamAndReceiveStream_1.emitStreamAndReceiveStream)(async () => {
|
|
60
|
+
const refP = new eventsPlugin(await (0, mocks_1.getEventsConstructorConfig)(config));
|
|
61
|
+
if (refP.init !== undefined) {
|
|
62
|
+
await refP.init(obs);
|
|
63
|
+
}
|
|
64
|
+
//refP.eas.staticCommsTimeout = 25;
|
|
65
|
+
return refP;
|
|
66
|
+
}, 50);
|
|
67
|
+
};
|
|
68
|
+
exports.RunEventsPluginTests = RunEventsPluginTests;
|
|
69
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/sb/plugins/events/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;;;AAEH,2CAAwC;AACxC,iCAA8B;AAC9B,mDAAgD;AAChD,6EAA0E;AAE1E,0CAA4D;AAC5D,0CAAsD;AAE/C,MAAM,oBAAoB,GAAG,CAClC,YAAiC,EACjC,SAAc,SAAS,EACvB,EAAE;IACF,MAAM,GAAG,GAAG,IAAA,4BAAoB,GAAE,CAAC;IACnC,IAAA,qBAAS,EAAC,KAAK,IAAI,EAAE;QACnB,MAAM,IAAI,GAAG,IAAI,YAAY,CAAC,MAAM,IAAA,kCAA0B,EAAC,MAAM,CAAC,CAAC,CAAC;QACxE,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;YAC5B,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACvB,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC,EAAE,GAAG,CAAC,CAAC;IACR,IAAA,WAAI,EAAC,KAAK,IAAI,EAAE;QACd,MAAM,IAAI,GAAG,IAAI,YAAY,CAAC,MAAM,IAAA,kCAA0B,EAAC,MAAM,CAAC,CAAC,CAAC;QACxE,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;YAC5B,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACvB,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC,EAAE,GAAG,CAAC,CAAC;IACR,IAAA,6BAAa,EAAC,KAAK,IAAI,EAAE;QACvB,MAAM,IAAI,GAAG,IAAI,YAAY,CAAC,MAAM,IAAA,kCAA0B,EAAC,MAAM,CAAC,CAAC,CAAC;QACxE,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;YAC5B,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACvB,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC,EAAE,GAAG,CAAC,CAAC;IACR,IAAA,uDAA0B,EAAC,KAAK,IAAI,EAAE;QACpC,MAAM,IAAI,GAAG,IAAI,YAAY,CAAC,MAAM,IAAA,kCAA0B,EAAC,MAAM,CAAC,CAAC,CAAC;QACxE,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;YAC5B,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACvB,CAAC;QACD,mCAAmC;QACnC,OAAO,IAAI,CAAC;IACd,CAAC,EAAE,EAAE,CAAC,CAAC;AACT,CAAC,CAAC;AAlCW,QAAA,oBAAoB,wBAkC/B"}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../../../src/sb/plugins/events/plugin.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,28 @@
|
|
|
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 { BSBObservableRef } from "@bsb/base";
|
|
28
|
+
export declare const RunObservablePluginTests: (observablePlugin: typeof BSBObservableRef, config?: any) => void;
|
|
@@ -0,0 +1,141 @@
|
|
|
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
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
29
|
+
if (k2 === undefined) k2 = k;
|
|
30
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
31
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
32
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
33
|
+
}
|
|
34
|
+
Object.defineProperty(o, k2, desc);
|
|
35
|
+
}) : (function(o, m, k, k2) {
|
|
36
|
+
if (k2 === undefined) k2 = k;
|
|
37
|
+
o[k2] = m[k];
|
|
38
|
+
}));
|
|
39
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
40
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
41
|
+
}) : function(o, v) {
|
|
42
|
+
o["default"] = v;
|
|
43
|
+
});
|
|
44
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
45
|
+
var ownKeys = function(o) {
|
|
46
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
47
|
+
var ar = [];
|
|
48
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
49
|
+
return ar;
|
|
50
|
+
};
|
|
51
|
+
return ownKeys(o);
|
|
52
|
+
};
|
|
53
|
+
return function (mod) {
|
|
54
|
+
if (mod && mod.__esModule) return mod;
|
|
55
|
+
var result = {};
|
|
56
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
57
|
+
__setModuleDefault(result, mod);
|
|
58
|
+
return result;
|
|
59
|
+
};
|
|
60
|
+
})();
|
|
61
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
62
|
+
exports.RunObservablePluginTests = void 0;
|
|
63
|
+
const assert = __importStar(require("assert"));
|
|
64
|
+
const base_1 = require("@bsb/base");
|
|
65
|
+
const trace_1 = require("../../../trace");
|
|
66
|
+
const RunObservablePluginTests = (observablePlugin, config = undefined) => {
|
|
67
|
+
describe("ObservableBase", async function () {
|
|
68
|
+
this.timeout(30000);
|
|
69
|
+
const obs = (0, trace_1.createTestObservable)();
|
|
70
|
+
const trace = obs.trace;
|
|
71
|
+
const pluginName = "test-plugin";
|
|
72
|
+
it("should construct", async () => {
|
|
73
|
+
const plugin = new observablePlugin(config);
|
|
74
|
+
assert.ok(plugin);
|
|
75
|
+
});
|
|
76
|
+
it("should init/run/dispose if implemented", async () => {
|
|
77
|
+
const plugin = new observablePlugin(config);
|
|
78
|
+
if (plugin.init) {
|
|
79
|
+
await plugin.init();
|
|
80
|
+
}
|
|
81
|
+
if (plugin.run) {
|
|
82
|
+
await plugin.run();
|
|
83
|
+
}
|
|
84
|
+
if (plugin.dispose) {
|
|
85
|
+
await plugin.dispose();
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
it("should support logging methods if implemented", async () => {
|
|
89
|
+
const plugin = new observablePlugin(config);
|
|
90
|
+
if (plugin.debug) {
|
|
91
|
+
plugin.debug(trace, pluginName, "debug message", {});
|
|
92
|
+
}
|
|
93
|
+
if (plugin.info) {
|
|
94
|
+
plugin.info(trace, pluginName, "info message", {});
|
|
95
|
+
}
|
|
96
|
+
if (plugin.warn) {
|
|
97
|
+
plugin.warn(trace, pluginName, "warn message", {});
|
|
98
|
+
}
|
|
99
|
+
if (plugin.error) {
|
|
100
|
+
plugin.error(trace, pluginName, "error message", {});
|
|
101
|
+
plugin.error(trace, pluginName, new base_1.BSBError(trace, "error message"));
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
it("should support metrics methods if implemented", async () => {
|
|
105
|
+
const plugin = new observablePlugin(config);
|
|
106
|
+
const timestamp = Date.now();
|
|
107
|
+
if (plugin.createCounter) {
|
|
108
|
+
await plugin.createCounter(timestamp, pluginName, "c", "desc", "help", ["a"]);
|
|
109
|
+
}
|
|
110
|
+
if (plugin.incrementCounter) {
|
|
111
|
+
await plugin.incrementCounter(timestamp, pluginName, "c", 1, { a: "b" });
|
|
112
|
+
}
|
|
113
|
+
if (plugin.createGauge) {
|
|
114
|
+
await plugin.createGauge(timestamp, pluginName, "g", "desc", "help", ["a"]);
|
|
115
|
+
}
|
|
116
|
+
if (plugin.setGauge) {
|
|
117
|
+
await plugin.setGauge(timestamp, pluginName, "g", 2, { a: "b" });
|
|
118
|
+
}
|
|
119
|
+
if (plugin.createHistogram) {
|
|
120
|
+
await plugin.createHistogram(timestamp, pluginName, "h", "desc", "help", [1, 2], ["a"]);
|
|
121
|
+
}
|
|
122
|
+
if (plugin.observeHistogram) {
|
|
123
|
+
await plugin.observeHistogram(timestamp, pluginName, "h", 3, { a: "b" });
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
it("should support tracing methods if implemented", async () => {
|
|
127
|
+
const plugin = new observablePlugin(config);
|
|
128
|
+
if (plugin.spanStart) {
|
|
129
|
+
await plugin.spanStart(Date.now(), trace, pluginName, "span", null, { a: "b" });
|
|
130
|
+
}
|
|
131
|
+
if (plugin.spanEnd) {
|
|
132
|
+
await plugin.spanEnd(Date.now(), trace, pluginName, { a: "b" });
|
|
133
|
+
}
|
|
134
|
+
if (plugin.spanError) {
|
|
135
|
+
await plugin.spanError(Date.now(), trace, pluginName, new Error("fail"), { a: "b" });
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
};
|
|
140
|
+
exports.RunObservablePluginTests = RunObservablePluginTests;
|
|
141
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/sb/plugins/observable/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,+CAAiC;AACjC,oCAAuD;AACvD,0CAAsD;AAE/C,MAAM,wBAAwB,GAAG,CACtC,gBAAyC,EACzC,SAAc,SAAS,EACvB,EAAE;IACF,QAAQ,CAAC,gBAAgB,EAAE,KAAK;QAC9B,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QACpB,MAAM,GAAG,GAAG,IAAA,4BAAoB,GAAE,CAAC;QACnC,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC;QACxB,MAAM,UAAU,GAAG,aAAa,CAAC;QAEjC,EAAE,CAAC,kBAAkB,EAAE,KAAK,IAAI,EAAE;YAChC,MAAM,MAAM,GAAG,IAAI,gBAAgB,CAAC,MAAM,CAAC,CAAC;YAC5C,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC;QACpB,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,wCAAwC,EAAE,KAAK,IAAI,EAAE;YACtD,MAAM,MAAM,GAAG,IAAI,gBAAgB,CAAC,MAAM,CAAC,CAAC;YAC5C,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC;gBAChB,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;YACtB,CAAC;YACD,IAAI,M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