@bsb/base 9.0.0 → 9.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 +6 -41
- package/lib/plugins/config-default/interfaces.d.ts +3 -2
- package/lib/plugins/service-benchmarkify/index.d.ts +312 -0
- package/lib/plugins/service-benchmarkify/index.js +138 -0
- package/lib/plugins/service-benchmarkify/index.js.map +1 -0
- package/lib/plugins/service-default0/index.d.ts +287 -0
- package/lib/plugins/service-default0/index.js +118 -0
- package/lib/plugins/service-default0/index.js.map +1 -0
- package/lib/{tests.d.ts → plugins/service-default1/client.d.ts} +16 -1
- package/lib/plugins/service-default1/client.js +70 -0
- package/lib/plugins/service-default1/client.js.map +1 -0
- package/lib/plugins/service-default1/index.d.ts +304 -0
- package/lib/plugins/service-default1/index.js +179 -0
- package/lib/plugins/service-default1/index.js.map +1 -0
- package/lib/plugins/service-default2/index.d.ts +359 -0
- package/lib/plugins/service-default2/index.js +137 -0
- package/lib/plugins/service-default2/index.js.map +1 -0
- package/lib/plugins/service-default3/index.d.ts +119 -0
- package/lib/plugins/service-default3/index.js +88 -0
- package/lib/plugins/service-default3/index.js.map +1 -0
- package/lib/plugins/service-default4/index.d.ts +81 -0
- package/lib/{tests.js → plugins/service-default4/index.js} +35 -16
- package/lib/plugins/service-default4/index.js.map +1 -0
- package/lib/schemas/config-default.plugin.json +1 -1
- package/lib/schemas/events-default.plugin.json +1 -1
- package/lib/schemas/observable-default.plugin.json +1 -1
- package/lib/schemas/service-benchmarkify.json +229 -0
- package/lib/schemas/service-default0.json +216 -0
- package/lib/schemas/service-default1.json +242 -0
- package/lib/schemas/service-default2.json +268 -0
- package/lib/schemas/service-default3.json +65 -0
- package/lib/schemas/service-default4.json +33 -0
- package/lib/serviceBase/events.js +2 -2
- package/lib/serviceBase/events.js.map +1 -1
- package/lib/serviceBase/observable.js +1 -1
- package/lib/serviceBase/observable.js.map +1 -1
- package/lib/serviceBase/plugins.d.ts +8 -1
- package/lib/serviceBase/plugins.js +113 -13
- package/lib/serviceBase/plugins.js.map +1 -1
- package/lib/serviceBase/services.js +2 -2
- package/lib/serviceBase/services.js.map +1 -1
- package/package.json +1 -1
- package/lib/tests.js.map +0 -1
|
@@ -0,0 +1,287 @@
|
|
|
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 { BSBService, BSBServiceConstructor } from "../../base";
|
|
28
|
+
import { z } from "zod";
|
|
29
|
+
import { Observable } from "../../interfaces/observable";
|
|
30
|
+
export declare const Config: import("../../base").BSBPluginConfigClass<z.ZodObject<{
|
|
31
|
+
testa: z.ZodNumber;
|
|
32
|
+
testb: z.ZodNumber;
|
|
33
|
+
}, z.core.$strip>>;
|
|
34
|
+
export declare const EventSchemas: {
|
|
35
|
+
readonly emitEvents: {
|
|
36
|
+
readonly test: {
|
|
37
|
+
input: {
|
|
38
|
+
_bsb: "object";
|
|
39
|
+
properties: {
|
|
40
|
+
readonly a: import("../..").BSBStringType;
|
|
41
|
+
readonly b: import("../..").BSBStringType;
|
|
42
|
+
};
|
|
43
|
+
required: string[];
|
|
44
|
+
description?: string;
|
|
45
|
+
optional?: boolean;
|
|
46
|
+
nullable?: boolean;
|
|
47
|
+
};
|
|
48
|
+
description?: string;
|
|
49
|
+
readonly __brand: "fire-and-forget";
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
readonly onEvents: {
|
|
53
|
+
readonly startup: {
|
|
54
|
+
input: {
|
|
55
|
+
_bsb: "object";
|
|
56
|
+
properties: {
|
|
57
|
+
readonly timestamp: import("../..").BSBStringType;
|
|
58
|
+
readonly source: import("../..").BSBStringType;
|
|
59
|
+
};
|
|
60
|
+
required: string[];
|
|
61
|
+
description?: string;
|
|
62
|
+
optional?: boolean;
|
|
63
|
+
nullable?: boolean;
|
|
64
|
+
};
|
|
65
|
+
description?: string;
|
|
66
|
+
readonly __brand: "fire-and-forget";
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
readonly emitReturnableEvents: {
|
|
70
|
+
readonly calculate: {
|
|
71
|
+
input: {
|
|
72
|
+
_bsb: "object";
|
|
73
|
+
properties: {
|
|
74
|
+
readonly a: import("../..").BSBNumberType;
|
|
75
|
+
readonly b: import("../..").BSBNumberType;
|
|
76
|
+
};
|
|
77
|
+
required: string[];
|
|
78
|
+
description?: string;
|
|
79
|
+
optional?: boolean;
|
|
80
|
+
nullable?: boolean;
|
|
81
|
+
};
|
|
82
|
+
output: import("../..").BSBNumberType;
|
|
83
|
+
description?: string;
|
|
84
|
+
defaultTimeout?: number;
|
|
85
|
+
readonly __brand: "returnable";
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
readonly onReturnableEvents: {
|
|
89
|
+
readonly 'data.validate': {
|
|
90
|
+
input: {
|
|
91
|
+
_bsb: "object";
|
|
92
|
+
properties: {
|
|
93
|
+
readonly data: import("../..").BSBType;
|
|
94
|
+
readonly schema: import("../..").BSBStringType;
|
|
95
|
+
};
|
|
96
|
+
required: string[];
|
|
97
|
+
description?: string;
|
|
98
|
+
optional?: boolean;
|
|
99
|
+
nullable?: boolean;
|
|
100
|
+
};
|
|
101
|
+
output: {
|
|
102
|
+
_bsb: "object";
|
|
103
|
+
properties: {
|
|
104
|
+
readonly valid: import("../..").BSBBooleanType;
|
|
105
|
+
readonly errors: import("../..").BSBArrayType;
|
|
106
|
+
};
|
|
107
|
+
required: string[];
|
|
108
|
+
description?: string;
|
|
109
|
+
optional?: boolean;
|
|
110
|
+
nullable?: boolean;
|
|
111
|
+
};
|
|
112
|
+
description?: string;
|
|
113
|
+
defaultTimeout?: number;
|
|
114
|
+
readonly __brand: "returnable";
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
readonly emitBroadcast: {
|
|
118
|
+
readonly 'system.alert': {
|
|
119
|
+
input: {
|
|
120
|
+
_bsb: "object";
|
|
121
|
+
properties: {
|
|
122
|
+
readonly level: import("../..").BSBEnumType;
|
|
123
|
+
readonly message: import("../..").BSBStringType;
|
|
124
|
+
readonly timestamp: import("../..").BSBStringType;
|
|
125
|
+
readonly source: import("../..").BSBStringType;
|
|
126
|
+
};
|
|
127
|
+
required: string[];
|
|
128
|
+
description?: string;
|
|
129
|
+
optional?: boolean;
|
|
130
|
+
nullable?: boolean;
|
|
131
|
+
};
|
|
132
|
+
description?: string;
|
|
133
|
+
readonly __brand: "broadcast";
|
|
134
|
+
};
|
|
135
|
+
};
|
|
136
|
+
readonly onBroadcast: {
|
|
137
|
+
readonly 'system.shutdown': {
|
|
138
|
+
input: {
|
|
139
|
+
_bsb: "object";
|
|
140
|
+
properties: {
|
|
141
|
+
readonly reason: import("../..").BSBStringType;
|
|
142
|
+
readonly gracefulTimeout: import("../..").BSBNumberType;
|
|
143
|
+
};
|
|
144
|
+
required: string[];
|
|
145
|
+
description?: string;
|
|
146
|
+
optional?: boolean;
|
|
147
|
+
nullable?: boolean;
|
|
148
|
+
};
|
|
149
|
+
description?: string;
|
|
150
|
+
readonly __brand: "broadcast";
|
|
151
|
+
};
|
|
152
|
+
};
|
|
153
|
+
};
|
|
154
|
+
export declare class Plugin extends BSBService<InstanceType<typeof Config>, typeof EventSchemas> {
|
|
155
|
+
static Config: import("../../base").BSBPluginConfigClass<z.ZodObject<{
|
|
156
|
+
testa: z.ZodNumber;
|
|
157
|
+
testb: z.ZodNumber;
|
|
158
|
+
}, z.core.$strip>>;
|
|
159
|
+
static EventSchemas: {
|
|
160
|
+
readonly emitEvents: {
|
|
161
|
+
readonly test: {
|
|
162
|
+
input: {
|
|
163
|
+
_bsb: "object";
|
|
164
|
+
properties: {
|
|
165
|
+
readonly a: import("../..").BSBStringType;
|
|
166
|
+
readonly b: import("../..").BSBStringType;
|
|
167
|
+
};
|
|
168
|
+
required: string[];
|
|
169
|
+
description?: string;
|
|
170
|
+
optional?: boolean;
|
|
171
|
+
nullable?: boolean;
|
|
172
|
+
};
|
|
173
|
+
description?: string;
|
|
174
|
+
readonly __brand: "fire-and-forget";
|
|
175
|
+
};
|
|
176
|
+
};
|
|
177
|
+
readonly onEvents: {
|
|
178
|
+
readonly startup: {
|
|
179
|
+
input: {
|
|
180
|
+
_bsb: "object";
|
|
181
|
+
properties: {
|
|
182
|
+
readonly timestamp: import("../..").BSBStringType;
|
|
183
|
+
readonly source: import("../..").BSBStringType;
|
|
184
|
+
};
|
|
185
|
+
required: string[];
|
|
186
|
+
description?: string;
|
|
187
|
+
optional?: boolean;
|
|
188
|
+
nullable?: boolean;
|
|
189
|
+
};
|
|
190
|
+
description?: string;
|
|
191
|
+
readonly __brand: "fire-and-forget";
|
|
192
|
+
};
|
|
193
|
+
};
|
|
194
|
+
readonly emitReturnableEvents: {
|
|
195
|
+
readonly calculate: {
|
|
196
|
+
input: {
|
|
197
|
+
_bsb: "object";
|
|
198
|
+
properties: {
|
|
199
|
+
readonly a: import("../..").BSBNumberType;
|
|
200
|
+
readonly b: import("../..").BSBNumberType;
|
|
201
|
+
};
|
|
202
|
+
required: string[];
|
|
203
|
+
description?: string;
|
|
204
|
+
optional?: boolean;
|
|
205
|
+
nullable?: boolean;
|
|
206
|
+
};
|
|
207
|
+
output: import("../..").BSBNumberType;
|
|
208
|
+
description?: string;
|
|
209
|
+
defaultTimeout?: number;
|
|
210
|
+
readonly __brand: "returnable";
|
|
211
|
+
};
|
|
212
|
+
};
|
|
213
|
+
readonly onReturnableEvents: {
|
|
214
|
+
readonly 'data.validate': {
|
|
215
|
+
input: {
|
|
216
|
+
_bsb: "object";
|
|
217
|
+
properties: {
|
|
218
|
+
readonly data: import("../..").BSBType;
|
|
219
|
+
readonly schema: import("../..").BSBStringType;
|
|
220
|
+
};
|
|
221
|
+
required: string[];
|
|
222
|
+
description?: string;
|
|
223
|
+
optional?: boolean;
|
|
224
|
+
nullable?: boolean;
|
|
225
|
+
};
|
|
226
|
+
output: {
|
|
227
|
+
_bsb: "object";
|
|
228
|
+
properties: {
|
|
229
|
+
readonly valid: import("../..").BSBBooleanType;
|
|
230
|
+
readonly errors: import("../..").BSBArrayType;
|
|
231
|
+
};
|
|
232
|
+
required: string[];
|
|
233
|
+
description?: string;
|
|
234
|
+
optional?: boolean;
|
|
235
|
+
nullable?: boolean;
|
|
236
|
+
};
|
|
237
|
+
description?: string;
|
|
238
|
+
defaultTimeout?: number;
|
|
239
|
+
readonly __brand: "returnable";
|
|
240
|
+
};
|
|
241
|
+
};
|
|
242
|
+
readonly emitBroadcast: {
|
|
243
|
+
readonly 'system.alert': {
|
|
244
|
+
input: {
|
|
245
|
+
_bsb: "object";
|
|
246
|
+
properties: {
|
|
247
|
+
readonly level: import("../..").BSBEnumType;
|
|
248
|
+
readonly message: import("../..").BSBStringType;
|
|
249
|
+
readonly timestamp: import("../..").BSBStringType;
|
|
250
|
+
readonly source: import("../..").BSBStringType;
|
|
251
|
+
};
|
|
252
|
+
required: string[];
|
|
253
|
+
description?: string;
|
|
254
|
+
optional?: boolean;
|
|
255
|
+
nullable?: boolean;
|
|
256
|
+
};
|
|
257
|
+
description?: string;
|
|
258
|
+
readonly __brand: "broadcast";
|
|
259
|
+
};
|
|
260
|
+
};
|
|
261
|
+
readonly onBroadcast: {
|
|
262
|
+
readonly 'system.shutdown': {
|
|
263
|
+
input: {
|
|
264
|
+
_bsb: "object";
|
|
265
|
+
properties: {
|
|
266
|
+
readonly reason: import("../..").BSBStringType;
|
|
267
|
+
readonly gracefulTimeout: import("../..").BSBNumberType;
|
|
268
|
+
};
|
|
269
|
+
required: string[];
|
|
270
|
+
description?: string;
|
|
271
|
+
optional?: boolean;
|
|
272
|
+
nullable?: boolean;
|
|
273
|
+
};
|
|
274
|
+
description?: string;
|
|
275
|
+
readonly __brand: "broadcast";
|
|
276
|
+
};
|
|
277
|
+
};
|
|
278
|
+
};
|
|
279
|
+
initBeforePlugins?: string[] | undefined;
|
|
280
|
+
initAfterPlugins?: string[] | undefined;
|
|
281
|
+
runBeforePlugins?: string[] | undefined;
|
|
282
|
+
runAfterPlugins?: string[] | undefined;
|
|
283
|
+
dispose?(): void;
|
|
284
|
+
init?(): void | Promise<void>;
|
|
285
|
+
constructor(config: BSBServiceConstructor<InstanceType<typeof Config>, typeof EventSchemas>);
|
|
286
|
+
run(obs: Observable): Promise<void>;
|
|
287
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
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 base_1 = require("../../base");
|
|
31
|
+
const zod_1 = require("zod");
|
|
32
|
+
const schema_events_1 = require("../../interfaces/schema-events");
|
|
33
|
+
const secSchema = zod_1.z.object({
|
|
34
|
+
testa: zod_1.z.number(),
|
|
35
|
+
testb: zod_1.z.number(),
|
|
36
|
+
});
|
|
37
|
+
exports.Config = (0, base_1.createConfigSchema)({
|
|
38
|
+
name: 'service-default0',
|
|
39
|
+
description: 'Default service plugin 0 for testing',
|
|
40
|
+
version: '1.0.0',
|
|
41
|
+
image: '../docs/public/assets/images/bsb-logo.png',
|
|
42
|
+
tags: ['default', 'example', 'test'],
|
|
43
|
+
}, secSchema);
|
|
44
|
+
exports.EventSchemas = (0, schema_events_1.createEventSchemas)({
|
|
45
|
+
// Events this service emits (fire-and-forget, first listener receives)
|
|
46
|
+
emitEvents: {
|
|
47
|
+
test: (0, schema_events_1.createFireAndForgetEvent)(base_1.bsb.object({
|
|
48
|
+
a: base_1.bsb.string({ description: 'First string parameter' }),
|
|
49
|
+
b: base_1.bsb.string({ description: 'Second string parameter' })
|
|
50
|
+
}, 'Test event parameters'), 'Test event with string parameters')
|
|
51
|
+
},
|
|
52
|
+
// Events this service listens to (fire-and-forget)
|
|
53
|
+
onEvents: {
|
|
54
|
+
startup: (0, schema_events_1.createFireAndForgetEvent)(base_1.bsb.object({
|
|
55
|
+
timestamp: base_1.bsb.datetime('Startup timestamp'),
|
|
56
|
+
source: base_1.bsb.string({ description: 'Source identifier' })
|
|
57
|
+
}, 'Startup event parameters'), 'Handle system startup notification')
|
|
58
|
+
},
|
|
59
|
+
// Returnable events this service emits (requests from this service)
|
|
60
|
+
emitReturnableEvents: {
|
|
61
|
+
calculate: (0, schema_events_1.createReturnableEvent)(base_1.bsb.object({
|
|
62
|
+
a: base_1.bsb.number({ min: 0, description: 'First number' }),
|
|
63
|
+
b: base_1.bsb.number({ min: 0, description: 'Second number' })
|
|
64
|
+
}, 'Calculate input parameters'), base_1.bsb.number({ description: 'Calculation result' }), 'Calculate with two numbers')
|
|
65
|
+
},
|
|
66
|
+
// Returnable events this service listens to (requests to this service)
|
|
67
|
+
onReturnableEvents: {
|
|
68
|
+
'data.validate': (0, schema_events_1.createReturnableEvent)(base_1.bsb.object({
|
|
69
|
+
data: base_1.bsb.unknown('Data to validate'),
|
|
70
|
+
schema: base_1.bsb.string({ description: 'Schema name' })
|
|
71
|
+
}, 'Validation input'), base_1.bsb.object({
|
|
72
|
+
valid: base_1.bsb.boolean('Validation result'),
|
|
73
|
+
errors: base_1.bsb.array(base_1.bsb.string({ description: 'Error message' }), { description: 'Validation errors' })
|
|
74
|
+
}, 'Validation output'), 'Validate data against a schema')
|
|
75
|
+
},
|
|
76
|
+
// Broadcast events this service emits (all listeners receive)
|
|
77
|
+
emitBroadcast: {
|
|
78
|
+
'system.alert': (0, schema_events_1.createBroadcastEvent)(base_1.bsb.object({
|
|
79
|
+
level: base_1.bsb.enum(['info', 'warning', 'error', 'critical'], 'Alert level'),
|
|
80
|
+
message: base_1.bsb.string({ description: 'Alert message' }),
|
|
81
|
+
timestamp: base_1.bsb.datetime('Alert timestamp'),
|
|
82
|
+
source: base_1.bsb.string({ description: 'Alert source' })
|
|
83
|
+
}, 'System alert parameters'), 'System-wide alert broadcast')
|
|
84
|
+
},
|
|
85
|
+
// Broadcast events this service listens to
|
|
86
|
+
onBroadcast: {
|
|
87
|
+
'system.shutdown': (0, schema_events_1.createBroadcastEvent)(base_1.bsb.object({
|
|
88
|
+
reason: base_1.bsb.string({ description: 'Shutdown reason' }),
|
|
89
|
+
gracefulTimeout: base_1.bsb.number({ description: 'Graceful timeout in milliseconds' })
|
|
90
|
+
}, 'Shutdown parameters'), 'Listen for system shutdown broadcasts')
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
class Plugin extends base_1.BSBService {
|
|
94
|
+
static Config = exports.Config;
|
|
95
|
+
static EventSchemas = exports.EventSchemas;
|
|
96
|
+
// PLUGIN_CLIENT auto-generated from Config.metadata
|
|
97
|
+
initBeforePlugins;
|
|
98
|
+
initAfterPlugins;
|
|
99
|
+
runBeforePlugins;
|
|
100
|
+
runAfterPlugins;
|
|
101
|
+
constructor(config) {
|
|
102
|
+
super(config);
|
|
103
|
+
}
|
|
104
|
+
async run(obs) {
|
|
105
|
+
obs.log.info("Starting service-default0");
|
|
106
|
+
await this.events.emitEvent("test", obs, {
|
|
107
|
+
a: "test",
|
|
108
|
+
b: "test"
|
|
109
|
+
});
|
|
110
|
+
const result = await this.events.emitEventAndReturn("calculate", obs, {
|
|
111
|
+
a: this.config.testa,
|
|
112
|
+
b: this.config.testb
|
|
113
|
+
});
|
|
114
|
+
obs.log.info("Calculation result: {result}", { result });
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
exports.Plugin = Plugin;
|
|
118
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file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IAAI,CAAC,8BAA8B,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;IAC3D,CAAC;;AAnCH,wBAoCC"}
|
|
@@ -24,4 +24,19 @@
|
|
|
24
24
|
* You should have received a copy of the GNU Affero General Public License
|
|
25
25
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
26
26
|
*/
|
|
27
|
-
|
|
27
|
+
import { BSBServiceClient } from "../..";
|
|
28
|
+
import { Plugin } from ".";
|
|
29
|
+
import { Observable } from "../../interfaces";
|
|
30
|
+
export declare class testClient extends BSBServiceClient<Plugin> {
|
|
31
|
+
initBeforePlugins?: string[] | undefined;
|
|
32
|
+
initAfterPlugins?: string[] | undefined;
|
|
33
|
+
runBeforePlugins?: string[] | undefined;
|
|
34
|
+
runAfterPlugins?: string[] | undefined;
|
|
35
|
+
dispose?(): void;
|
|
36
|
+
run?(): Promise<void>;
|
|
37
|
+
readonly pluginName: string;
|
|
38
|
+
private count;
|
|
39
|
+
private initObs?;
|
|
40
|
+
init(obs: Observable): Promise<void>;
|
|
41
|
+
abc(a: number, b: number, c: number, d: number): Promise<void>;
|
|
42
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
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.testClient = void 0;
|
|
30
|
+
const __1 = require("../..");
|
|
31
|
+
class testClient extends __1.BSBServiceClient {
|
|
32
|
+
initBeforePlugins;
|
|
33
|
+
initAfterPlugins;
|
|
34
|
+
runBeforePlugins;
|
|
35
|
+
runAfterPlugins;
|
|
36
|
+
pluginName = "service-default1";
|
|
37
|
+
count = 0;
|
|
38
|
+
initObs;
|
|
39
|
+
async init(obs) {
|
|
40
|
+
this.initObs = obs;
|
|
41
|
+
// Handle emittable events
|
|
42
|
+
this.events.onEvent("onEmittable", obs, async (obs, input) => {
|
|
43
|
+
obs.log.warn("onEmittable ({a},{b})", { a: input.a, b: input.b });
|
|
44
|
+
});
|
|
45
|
+
// Handle returnable events
|
|
46
|
+
this.events.onReturnableEvent("onReverseReturnable", obs, async (obs, input) => {
|
|
47
|
+
this.count++;
|
|
48
|
+
obs.log.warn("onReverseReturnable ({a},{b})", { a: input.a, b: input.b });
|
|
49
|
+
return input.a * input.b;
|
|
50
|
+
});
|
|
51
|
+
// Emit receivable event
|
|
52
|
+
await this.events.emitEvent("onReceivable", obs, { a: 56, b: 7 });
|
|
53
|
+
}
|
|
54
|
+
async abc(a, b, c, d) {
|
|
55
|
+
const obs = this.initObs.startSpan('abc', { component: 'test' });
|
|
56
|
+
try {
|
|
57
|
+
const result = await this.events.emitEventAndReturn("onReturnable", obs, { a: c, b: d }, 5);
|
|
58
|
+
obs.log.warn("TESTING onReturnable ({result})", { result });
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
obs.error(error instanceof Error ? error : new Error(String(error)));
|
|
62
|
+
throw error;
|
|
63
|
+
}
|
|
64
|
+
finally {
|
|
65
|
+
obs.end();
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
exports.testClient = testClient;
|
|
70
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/plugins/service-default1/client.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;;;AAEH,6BAAyC;AAIzC,MAAa,UAAW,SAAQ,oBAAwB;IAC/C,iBAAiB,CAAwB;IACzC,gBAAgB,CAAwB;IACxC,gBAAgB,CAAwB;IACxC,eAAe,CAAwB;IAG9B,UAAU,GAAW,kBAAkB,CAAC;IAChD,KAAK,GAAG,CAAC,CAAC;IACV,OAAO,CAAc;IAEtB,KAAK,CAAC,IAAI,CAAC,GAAe;QAC/B,IAAI,CAAC,OAAO,GAAG,GAAG,CAAC;QACnB,0BAA0B;QAC1B,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,aAAa,EAAE,GAAG,EAAE,KAAK,EAAE,GAAe,EAAE,KAAU,EAAE,EAAE;YAC5E,GAAG,CAAC,GAAG,CAAC,IAAI,CAAE,uBAAuB,EAAE,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;QACrE,CAAC,CAAC,CAAC;QAEH,2BAA2B;QAC3B,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,qBAAqB,EAAE,GAAG,EAAE,KAAK,EAAE,GAAe,EAAE,KAAU,EAAE,EAAE;YAC9F,IAAI,CAAC,KAAK,EAAE,CAAC;YACb,GA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