@bsb/base 9.0.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/LICENSE +665 -0
- package/LICENSE.commercial +32 -0
- package/README.md +263 -0
- package/bsb-plugin.json +62 -0
- package/lib/base/BSBConfig.d.ts +130 -0
- package/lib/base/BSBConfig.js +95 -0
- package/lib/base/BSBConfig.js.map +1 -0
- package/lib/base/BSBEvents.d.ts +207 -0
- package/lib/base/BSBEvents.js +101 -0
- package/lib/base/BSBEvents.js.map +1 -0
- package/lib/base/BSBObservable.d.ts +178 -0
- package/lib/base/BSBObservable.js +91 -0
- package/lib/base/BSBObservable.js.map +1 -0
- package/lib/base/BSBService.d.ts +277 -0
- package/lib/base/BSBService.js +366 -0
- package/lib/base/BSBService.js.map +1 -0
- package/lib/base/BSBServiceClient.d.ts +135 -0
- package/lib/base/BSBServiceClient.js +130 -0
- package/lib/base/BSBServiceClient.js.map +1 -0
- package/lib/base/EventValidator.d.ts +137 -0
- package/lib/base/EventValidator.js +210 -0
- package/lib/base/EventValidator.js.map +1 -0
- package/lib/base/ObservableBackend.d.ts +281 -0
- package/lib/base/ObservableBackend.js +515 -0
- package/lib/base/ObservableBackend.js.map +1 -0
- package/lib/base/PluginConfig.d.ts +196 -0
- package/lib/base/PluginConfig.js +96 -0
- package/lib/base/PluginConfig.js.map +1 -0
- package/lib/base/PluginEvents.d.ts +140 -0
- package/lib/base/PluginEvents.js +268 -0
- package/lib/base/PluginEvents.js.map +1 -0
- package/lib/base/PluginObservable.d.ts +196 -0
- package/lib/base/PluginObservable.js +250 -0
- package/lib/base/PluginObservable.js.map +1 -0
- package/lib/base/ResourceContext.d.ts +70 -0
- package/lib/base/ResourceContext.js +54 -0
- package/lib/base/ResourceContext.js.map +1 -0
- package/lib/base/base.d.ts +264 -0
- package/lib/base/base.js +182 -0
- package/lib/base/base.js.map +1 -0
- package/lib/base/errorMessages.d.ts +56 -0
- package/lib/base/errorMessages.js +70 -0
- package/lib/base/errorMessages.js.map +1 -0
- package/lib/base/factory.d.ts +58 -0
- package/lib/base/factory.js +167 -0
- package/lib/base/factory.js.map +1 -0
- package/lib/base/functions.d.ts +117 -0
- package/lib/base/functions.js +152 -0
- package/lib/base/functions.js.map +1 -0
- package/lib/base/index.d.ts +44 -0
- package/lib/base/index.js +64 -0
- package/lib/base/index.js.map +1 -0
- package/lib/base/logFormatter.d.ts +50 -0
- package/lib/base/logFormatter.js +105 -0
- package/lib/base/logFormatter.js.map +1 -0
- package/lib/base/tools.d.ts +316 -0
- package/lib/base/tools.js +666 -0
- package/lib/base/tools.js.map +1 -0
- package/lib/cli.d.ts +28 -0
- package/lib/cli.js +254 -0
- package/lib/cli.js.map +1 -0
- package/lib/dev.d.ts +27 -0
- package/lib/dev.js +200 -0
- package/lib/dev.js.map +1 -0
- package/lib/index.d.ts +32 -0
- package/lib/index.js +49 -0
- package/lib/index.js.map +1 -0
- package/lib/interfaces/events.d.ts +67 -0
- package/lib/interfaces/events.js +44 -0
- package/lib/interfaces/events.js.map +1 -0
- package/lib/interfaces/index.d.ts +38 -0
- package/lib/interfaces/index.js +59 -0
- package/lib/interfaces/index.js.map +1 -0
- package/lib/interfaces/logging.d.ts +106 -0
- package/lib/interfaces/logging.js +39 -0
- package/lib/interfaces/logging.js.map +1 -0
- package/lib/interfaces/metrics.d.ts +365 -0
- package/lib/interfaces/metrics.js +46 -0
- package/lib/interfaces/metrics.js.map +1 -0
- package/lib/interfaces/observable-types.d.ts +63 -0
- package/lib/interfaces/observable-types.js +49 -0
- package/lib/interfaces/observable-types.js.map +1 -0
- package/lib/interfaces/observable.d.ts +297 -0
- package/lib/interfaces/observable.js +29 -0
- package/lib/interfaces/observable.js.map +1 -0
- package/lib/interfaces/options.d.ts +164 -0
- package/lib/interfaces/options.js +56 -0
- package/lib/interfaces/options.js.map +1 -0
- package/lib/interfaces/plugins.d.ts +143 -0
- package/lib/interfaces/plugins.js +45 -0
- package/lib/interfaces/plugins.js.map +1 -0
- package/lib/interfaces/result.d.ts +129 -0
- package/lib/interfaces/result.js +162 -0
- package/lib/interfaces/result.js.map +1 -0
- package/lib/interfaces/schema-events.d.ts +378 -0
- package/lib/interfaces/schema-events.js +247 -0
- package/lib/interfaces/schema-events.js.map +1 -0
- package/lib/interfaces/schema-types.d.ts +407 -0
- package/lib/interfaces/schema-types.js +581 -0
- package/lib/interfaces/schema-types.js.map +1 -0
- package/lib/interfaces/service.d.ts +48 -0
- package/lib/interfaces/service.js +29 -0
- package/lib/interfaces/service.js.map +1 -0
- package/lib/interfaces/tools.d.ts +65 -0
- package/lib/interfaces/tools.js +50 -0
- package/lib/interfaces/tools.js.map +1 -0
- package/lib/plugins/config-default/index.d.ts +59 -0
- package/lib/plugins/config-default/index.js +197 -0
- package/lib/plugins/config-default/index.js.map +1 -0
- package/lib/plugins/config-default/interfaces.d.ts +92 -0
- package/lib/plugins/config-default/interfaces.js +36 -0
- package/lib/plugins/config-default/interfaces.js.map +1 -0
- package/lib/plugins/events-default/events/broadcast.d.ts +36 -0
- package/lib/plugins/events-default/events/broadcast.js +85 -0
- package/lib/plugins/events-default/events/broadcast.js.map +1 -0
- package/lib/plugins/events-default/events/emit.d.ts +38 -0
- package/lib/plugins/events-default/events/emit.js +104 -0
- package/lib/plugins/events-default/events/emit.js.map +1 -0
- package/lib/plugins/events-default/events/emitAndReturn.d.ts +36 -0
- package/lib/plugins/events-default/events/emitAndReturn.js +100 -0
- package/lib/plugins/events-default/events/emitAndReturn.js.map +1 -0
- package/lib/plugins/events-default/events/emitStreamAndReceiveStream.d.ts +38 -0
- package/lib/plugins/events-default/events/emitStreamAndReceiveStream.js +134 -0
- package/lib/plugins/events-default/events/emitStreamAndReceiveStream.js.map +1 -0
- package/lib/plugins/events-default/events/index.d.ts +30 -0
- package/lib/plugins/events-default/events/index.js +38 -0
- package/lib/plugins/events-default/events/index.js.map +1 -0
- package/lib/plugins/events-default/index.d.ts +57 -0
- package/lib/plugins/events-default/index.js +86 -0
- package/lib/plugins/events-default/index.js.map +1 -0
- package/lib/plugins/observable-default/index.d.ts +43 -0
- package/lib/plugins/observable-default/index.js +151 -0
- package/lib/plugins/observable-default/index.js.map +1 -0
- package/lib/schemas/config-default.json +34 -0
- package/lib/schemas/config-default.plugin.json +36 -0
- package/lib/schemas/events-default.json +18 -0
- package/lib/schemas/events-default.plugin.json +17 -0
- package/lib/schemas/observable-default.json +33 -0
- package/lib/schemas/observable-default.plugin.json +24 -0
- package/lib/scripts/bsb-client-cli.d.ts +21 -0
- package/lib/scripts/bsb-client-cli.js +701 -0
- package/lib/scripts/bsb-client-cli.js.map +1 -0
- package/lib/scripts/bsb-plugin-cli.d.ts +15 -0
- package/lib/scripts/bsb-plugin-cli.js +547 -0
- package/lib/scripts/bsb-plugin-cli.js.map +1 -0
- package/lib/scripts/export-schemas.d.ts +17 -0
- package/lib/scripts/export-schemas.js +205 -0
- package/lib/scripts/export-schemas.js.map +1 -0
- package/lib/scripts/extract-schemas-from-source.d.ts +23 -0
- package/lib/scripts/extract-schemas-from-source.js +604 -0
- package/lib/scripts/extract-schemas-from-source.js.map +1 -0
- package/lib/scripts/generate-client-types.d.ts +22 -0
- package/lib/scripts/generate-client-types.js +537 -0
- package/lib/scripts/generate-client-types.js.map +1 -0
- package/lib/scripts/generate-plugin-json.d.ts +17 -0
- package/lib/scripts/generate-plugin-json.js +219 -0
- package/lib/scripts/generate-plugin-json.js.map +1 -0
- package/lib/serviceBase/config.d.ts +83 -0
- package/lib/serviceBase/config.js +236 -0
- package/lib/serviceBase/config.js.map +1 -0
- package/lib/serviceBase/events.d.ts +91 -0
- package/lib/serviceBase/events.js +519 -0
- package/lib/serviceBase/events.js.map +1 -0
- package/lib/serviceBase/index.d.ts +33 -0
- package/lib/serviceBase/index.js +50 -0
- package/lib/serviceBase/index.js.map +1 -0
- package/lib/serviceBase/observable.d.ts +249 -0
- package/lib/serviceBase/observable.js +551 -0
- package/lib/serviceBase/observable.js.map +1 -0
- package/lib/serviceBase/plugins.d.ts +48 -0
- package/lib/serviceBase/plugins.js +184 -0
- package/lib/serviceBase/plugins.js.map +1 -0
- package/lib/serviceBase/serviceBase.d.ts +228 -0
- package/lib/serviceBase/serviceBase.js +420 -0
- package/lib/serviceBase/serviceBase.js.map +1 -0
- package/lib/serviceBase/services.d.ts +63 -0
- package/lib/serviceBase/services.js +346 -0
- package/lib/serviceBase/services.js.map +1 -0
- package/lib/tests.d.ts +27 -0
- package/lib/tests.js +44 -0
- package/lib/tests.js.map +1 -0
- package/package.json +91 -0
|
@@ -0,0 +1,207 @@
|
|
|
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 { Readable } from "node:stream";
|
|
28
|
+
import { BaseWithObservableAndConfig, BaseWithObservableAndConfigConfig } from "./base";
|
|
29
|
+
import { BSBReferencePluginConfigDefinition, BSBReferencePluginConfigType, BSBReferenceConfigType } from "./PluginConfig";
|
|
30
|
+
import { Observable } from '../interfaces/observable';
|
|
31
|
+
export interface BSBEventsConstructor<ReferencedConfig extends BSBReferencePluginConfigType = any> extends BaseWithObservableAndConfigConfig<ReferencedConfig extends null ? null : BSBReferencePluginConfigDefinition<ReferencedConfig> & BSBReferenceConfigType> {
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* @group Events
|
|
35
|
+
* @category Plugins
|
|
36
|
+
* @see {@link https://bsbcode.dev/languages/nodejs/types/classes/BSBEvents.html | API: BSBEvents}
|
|
37
|
+
*/
|
|
38
|
+
export declare abstract class BSBEvents<ReferencedConfig extends BSBReferencePluginConfigType = any> extends BaseWithObservableAndConfig<ReferencedConfig extends null ? null : BSBReferencePluginConfigDefinition<ReferencedConfig> & BSBReferenceConfigType> {
|
|
39
|
+
constructor(config: BSBEventsConstructor<ReferencedConfig>);
|
|
40
|
+
/**
|
|
41
|
+
* Run lifecycle method for events plugins.
|
|
42
|
+
*
|
|
43
|
+
* This method is inherited from the base plugin class but is not used by events plugins.
|
|
44
|
+
* Events plugins are initialized during the init phase and begin processing events
|
|
45
|
+
* immediately. They do not require a separate run phase.
|
|
46
|
+
*
|
|
47
|
+
* @remarks
|
|
48
|
+
* Events plugins establish their event bus connections and listeners during initialization.
|
|
49
|
+
* The event routing is active as soon as init completes. Therefore, this method
|
|
50
|
+
* intentionally performs no operation.
|
|
51
|
+
*
|
|
52
|
+
* @returns void
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```typescript
|
|
56
|
+
* // Events plugins do not need to implement run()
|
|
57
|
+
* // The base class provides this no-op implementation
|
|
58
|
+
* export class MyEventsPlugin extends BSBEvents<MyConfig> {
|
|
59
|
+
* // No run() override needed
|
|
60
|
+
* }
|
|
61
|
+
* ```
|
|
62
|
+
*
|
|
63
|
+
* @see {@link BSBEvents.init} for the initialization lifecycle method
|
|
64
|
+
* @see {@link https://bsbcode.dev/languages/nodejs/types/classes/BSBEvents.html#run | API: BSBEvents#run}
|
|
65
|
+
*/
|
|
66
|
+
run(): void;
|
|
67
|
+
/**
|
|
68
|
+
* Listens for events that are emitted by other plugins
|
|
69
|
+
* Broadcast events are emitted and received by all plugins
|
|
70
|
+
*
|
|
71
|
+
* @param trace - The trace object for tracking the operation
|
|
72
|
+
* @param pluginName - The name of the plugin that is being listened to
|
|
73
|
+
* @param event - The event to listen for
|
|
74
|
+
* @param listener - The function to call when the event is received
|
|
75
|
+
* @returns Promise that resolves when the event listener has been registered
|
|
76
|
+
*
|
|
77
|
+
* @see BSB events-default plugin for an example of how to use this function
|
|
78
|
+
* @see {@link https://github.com/BetterCorp/better-service-base/tree/master/nodejs/src/plugins/events-default | Default Events Plugin}
|
|
79
|
+
* @see {@link https://bsbcode.dev/languages/nodejs/types/classes/BSBEvents.html#onBroadcast | API: BSBEvents#onBroadcast}
|
|
80
|
+
*/
|
|
81
|
+
abstract onBroadcast(trace: Observable, pluginName: string, event: string, listener: {
|
|
82
|
+
(trace: Observable, args: Array<any>): Promise<void>;
|
|
83
|
+
}): Promise<void>;
|
|
84
|
+
/**
|
|
85
|
+
* Emits an event that is received by all plugins
|
|
86
|
+
*
|
|
87
|
+
* @param trace - The trace object for tracking the operation
|
|
88
|
+
* @param pluginName - The name of the plugin that is emitting the event
|
|
89
|
+
* @param event - The event to emit
|
|
90
|
+
* @param args - The arguments to pass to the event listener
|
|
91
|
+
* @returns Promise that resolves when the event has been emitted
|
|
92
|
+
*
|
|
93
|
+
* @see BSB events-default plugin for an example of how to use this function
|
|
94
|
+
* @see {@link https://github.com/BetterCorp/better-service-base/tree/master/nodejs/src/plugins/events-default | Default Events Plugin}
|
|
95
|
+
* @see {@link https://bsbcode.dev/languages/nodejs/types/classes/BSBEvents.html#emitBroadcast | API: BSBEvents#emitBroadcast}
|
|
96
|
+
*/
|
|
97
|
+
abstract emitBroadcast(trace: Observable, pluginName: string, event: string, args: Array<any>): Promise<void>;
|
|
98
|
+
/**
|
|
99
|
+
* Listens for events that are emitted by other plugins
|
|
100
|
+
* Events are emitted and received by a single plugin
|
|
101
|
+
*
|
|
102
|
+
* @param trace - The trace object for tracking the operation
|
|
103
|
+
* @param pluginName - The name of the plugin that is being listened to
|
|
104
|
+
* @param event - The event to listen for
|
|
105
|
+
* @param listener - The function to call when the event is received
|
|
106
|
+
* @returns Promise that resolves when the event listener has been registered
|
|
107
|
+
*
|
|
108
|
+
* @see BSB events-default plugin for an example of how to use this function
|
|
109
|
+
* @see {@link https://github.com/BetterCorp/better-service-base/tree/master/nodejs/src/plugins/events-default | Default Events Plugin}
|
|
110
|
+
* @see {@link https://bsbcode.dev/languages/nodejs/types/classes/BSBEvents.html#onEvent | API: BSBEvents#onEvent}
|
|
111
|
+
*/
|
|
112
|
+
abstract onEvent(trace: Observable, pluginName: string, event: string, listener: {
|
|
113
|
+
(trace: Observable, args: Array<any>): Promise<void>;
|
|
114
|
+
}): Promise<void>;
|
|
115
|
+
/**
|
|
116
|
+
* Emits an event that is received by a single plugin
|
|
117
|
+
*
|
|
118
|
+
* @param trace - The trace object for tracking the operation
|
|
119
|
+
* @param pluginName - The name of the plugin that is emitting the event
|
|
120
|
+
* @param event - The event to emit
|
|
121
|
+
* @param args - The arguments to pass to the event listener
|
|
122
|
+
* @returns Promise that resolves when the event has been emitted
|
|
123
|
+
*
|
|
124
|
+
* @see BSB events-default plugin for an example of how to use this function
|
|
125
|
+
* @see {@link https://github.com/BetterCorp/better-service-base/tree/master/nodejs/src/plugins/events-default | Default Events Plugin}
|
|
126
|
+
* @see {@link https://bsbcode.dev/languages/nodejs/types/classes/BSBEvents.html#emitEvent | API: BSBEvents#emitEvent}
|
|
127
|
+
*/
|
|
128
|
+
abstract emitEvent(trace: Observable, pluginName: string, event: string, args: Array<any>): Promise<void>;
|
|
129
|
+
/**
|
|
130
|
+
* Listens for events that are emitted by other plugins and return a value
|
|
131
|
+
* Events are emitted and received by a single plugin
|
|
132
|
+
*
|
|
133
|
+
* @param trace - The trace object for tracking the operation
|
|
134
|
+
* @param pluginName - The name of the plugin that is being listened to
|
|
135
|
+
* @param event - The event to listen for
|
|
136
|
+
* @param listener - The function to call when the event is received
|
|
137
|
+
* @returns Promise that resolves when the event listener has been registered
|
|
138
|
+
*
|
|
139
|
+
* @see BSB events-default plugin for an example of how to use this function
|
|
140
|
+
* @see {@link https://github.com/BetterCorp/better-service-base/tree/master/nodejs/src/plugins/events-default | Default Events Plugin}
|
|
141
|
+
* @see {@link https://bsbcode.dev/languages/nodejs/types/classes/BSBEvents.html#onReturnableEvent | API: BSBEvents#onReturnableEvent}
|
|
142
|
+
*/
|
|
143
|
+
abstract onReturnableEvent(trace: Observable, pluginName: string, event: string, listener: {
|
|
144
|
+
(trace: Observable, args: Array<any>): Promise<any>;
|
|
145
|
+
}): Promise<void>;
|
|
146
|
+
/**
|
|
147
|
+
* Emits an event that is received by a single plugin and returns a value
|
|
148
|
+
*
|
|
149
|
+
* @param trace - The trace object for tracking the operation
|
|
150
|
+
* @param pluginName - The name of the plugin that is emitting the event
|
|
151
|
+
* @param event - The event to emit
|
|
152
|
+
* @param timeoutSeconds - The number of seconds to wait for the value to be returned
|
|
153
|
+
* @param args - The arguments to pass to the event listener
|
|
154
|
+
* @returns Promise that resolves when the event has been emitted and the value has been returned
|
|
155
|
+
*
|
|
156
|
+
* @see BSB events-default plugin for an example of how to use this function
|
|
157
|
+
* @see {@link https://github.com/BetterCorp/better-service-base/tree/master/nodejs/src/plugins/events-default | Default Events Plugin}
|
|
158
|
+
* @see {@link https://bsbcode.dev/languages/nodejs/types/classes/BSBEvents.html#emitEventAndReturn | API: BSBEvents#emitEventAndReturn}
|
|
159
|
+
*/
|
|
160
|
+
abstract emitEventAndReturn(trace: Observable, pluginName: string, event: string, timeoutSeconds: number, args: Array<any>): Promise<any>;
|
|
161
|
+
/**
|
|
162
|
+
* Sets up a receive stream to receive a stream from another plugin
|
|
163
|
+
*
|
|
164
|
+
* @param trace - The trace object for tracking the operation
|
|
165
|
+
* @param pluginName - The name of the plugin that is emitting the event
|
|
166
|
+
* @param event - The event to listen for
|
|
167
|
+
* @param listener - The function to call when the stream is received
|
|
168
|
+
* @param timeoutSeconds - The number of seconds to wait for the stream to be received
|
|
169
|
+
* @returns Promise that resolves with the stream id that can be used to stream data to the listener
|
|
170
|
+
*
|
|
171
|
+
* @see BSB events-default plugin for an example of how to use this function
|
|
172
|
+
* @see {@link https://github.com/BetterCorp/better-service-base/tree/master/nodejs/src/plugins/events-default | Default Events Plugin}
|
|
173
|
+
* @see {@link https://bsbcode.dev/languages/nodejs/types/classes/BSBEvents.html#receiveStream | API: BSBEvents#receiveStream}
|
|
174
|
+
*/
|
|
175
|
+
abstract receiveStream(trace: Observable, pluginName: string, event: string, listener: (trace: Observable, error: Error | null, stream: Readable) => Promise<void>, timeoutSeconds?: number): Promise<string>;
|
|
176
|
+
/**
|
|
177
|
+
* Sets up a send stream to send a stream to another plugin that created a receive stream
|
|
178
|
+
*
|
|
179
|
+
* @param trace - The trace object for tracking the operation
|
|
180
|
+
* @param pluginName - The name of the plugin that is emitting the event
|
|
181
|
+
* @param event - The event to listen for
|
|
182
|
+
* @param streamId - The id of the stream to send data to
|
|
183
|
+
* @param stream - The stream to send data from
|
|
184
|
+
* @returns Promise that resolves when the stream has been sent
|
|
185
|
+
*
|
|
186
|
+
* @see BSB events-default plugin for an example of how to use this function
|
|
187
|
+
* @see {@link https://github.com/BetterCorp/better-service-base/tree/master/nodejs/src/plugins/events-default | Default Events Plugin}
|
|
188
|
+
* @see {@link https://bsbcode.dev/languages/nodejs/types/classes/BSBEvents.html#sendStream | API: BSBEvents#sendStream}
|
|
189
|
+
*/
|
|
190
|
+
abstract sendStream(trace: Observable, pluginName: string, event: string, streamId: string, stream: Readable): Promise<void>;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* @hidden
|
|
194
|
+
* DO NOT REFERENCE/USE THIS CLASS - IT IS AN INTERNALLY REFERENCED CLASS
|
|
195
|
+
*/
|
|
196
|
+
export declare class BSBEventsRef extends BSBEvents {
|
|
197
|
+
onBroadcast(trace: Observable, pluginName: string, event: string, listener: (trace: Observable, args: any[]) => Promise<void>): Promise<void>;
|
|
198
|
+
emitBroadcast(trace: Observable, pluginName: string, event: string, args: any[]): Promise<void>;
|
|
199
|
+
onEvent(trace: Observable, pluginName: string, event: string, listener: (trace: Observable, args: any[]) => Promise<void>): Promise<void>;
|
|
200
|
+
emitEvent(trace: Observable, pluginName: string, event: string, args: any[]): Promise<void>;
|
|
201
|
+
onReturnableEvent(trace: Observable, pluginName: string, event: string, listener: (trace: Observable, args: any[]) => Promise<any>): Promise<void>;
|
|
202
|
+
emitEventAndReturn(trace: Observable, pluginName: string, event: string, timeoutSeconds: number, args: any[]): Promise<any>;
|
|
203
|
+
receiveStream(trace: Observable, pluginName: string, event: string, listener: (trace: Observable, error: Error | null, stream: Readable) => Promise<void>, timeoutSeconds?: number | undefined): Promise<string>;
|
|
204
|
+
sendStream(trace: Observable, pluginName: string, event: string, streamId: string, stream: Readable): Promise<void>;
|
|
205
|
+
dispose?(): void;
|
|
206
|
+
init?(obs: Observable): void | Promise<void>;
|
|
207
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
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.BSBEventsRef = exports.BSBEvents = void 0;
|
|
30
|
+
const base_1 = require("./base");
|
|
31
|
+
const errorMessages_1 = require("./errorMessages");
|
|
32
|
+
/**
|
|
33
|
+
* @group Events
|
|
34
|
+
* @category Plugins
|
|
35
|
+
* @see {@link https://bsbcode.dev/languages/nodejs/types/classes/BSBEvents.html | API: BSBEvents}
|
|
36
|
+
*/
|
|
37
|
+
class BSBEvents extends base_1.BaseWithObservableAndConfig {
|
|
38
|
+
constructor(config) {
|
|
39
|
+
super(config);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Run lifecycle method for events plugins.
|
|
43
|
+
*
|
|
44
|
+
* This method is inherited from the base plugin class but is not used by events plugins.
|
|
45
|
+
* Events plugins are initialized during the init phase and begin processing events
|
|
46
|
+
* immediately. They do not require a separate run phase.
|
|
47
|
+
*
|
|
48
|
+
* @remarks
|
|
49
|
+
* Events plugins establish their event bus connections and listeners during initialization.
|
|
50
|
+
* The event routing is active as soon as init completes. Therefore, this method
|
|
51
|
+
* intentionally performs no operation.
|
|
52
|
+
*
|
|
53
|
+
* @returns void
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```typescript
|
|
57
|
+
* // Events plugins do not need to implement run()
|
|
58
|
+
* // The base class provides this no-op implementation
|
|
59
|
+
* export class MyEventsPlugin extends BSBEvents<MyConfig> {
|
|
60
|
+
* // No run() override needed
|
|
61
|
+
* }
|
|
62
|
+
* ```
|
|
63
|
+
*
|
|
64
|
+
* @see {@link BSBEvents.init} for the initialization lifecycle method
|
|
65
|
+
* @see {@link https://bsbcode.dev/languages/nodejs/types/classes/BSBEvents.html#run | API: BSBEvents#run}
|
|
66
|
+
*/
|
|
67
|
+
run() { }
|
|
68
|
+
}
|
|
69
|
+
exports.BSBEvents = BSBEvents;
|
|
70
|
+
/**
|
|
71
|
+
* @hidden
|
|
72
|
+
* DO NOT REFERENCE/USE THIS CLASS - IT IS AN INTERNALLY REFERENCED CLASS
|
|
73
|
+
*/
|
|
74
|
+
class BSBEventsRef extends BSBEvents {
|
|
75
|
+
onBroadcast(trace, pluginName, event, listener) {
|
|
76
|
+
throw (0, errorMessages_1.BSB_ERROR_METHOD_NOT_IMPLEMENTED)("BSBEventsRef", "onBroadcast");
|
|
77
|
+
}
|
|
78
|
+
emitBroadcast(trace, pluginName, event, args) {
|
|
79
|
+
throw (0, errorMessages_1.BSB_ERROR_METHOD_NOT_IMPLEMENTED)("BSBEventsRef", "emitBroadcast");
|
|
80
|
+
}
|
|
81
|
+
onEvent(trace, pluginName, event, listener) {
|
|
82
|
+
throw (0, errorMessages_1.BSB_ERROR_METHOD_NOT_IMPLEMENTED)("BSBEventsRef", "onEvent");
|
|
83
|
+
}
|
|
84
|
+
emitEvent(trace, pluginName, event, args) {
|
|
85
|
+
throw (0, errorMessages_1.BSB_ERROR_METHOD_NOT_IMPLEMENTED)("BSBEventsRef", "emitEvent");
|
|
86
|
+
}
|
|
87
|
+
onReturnableEvent(trace, pluginName, event, listener) {
|
|
88
|
+
throw (0, errorMessages_1.BSB_ERROR_METHOD_NOT_IMPLEMENTED)("BSBEventsRef", "onReturnableEvent");
|
|
89
|
+
}
|
|
90
|
+
emitEventAndReturn(trace, pluginName, event, timeoutSeconds, args) {
|
|
91
|
+
throw (0, errorMessages_1.BSB_ERROR_METHOD_NOT_IMPLEMENTED)("BSBEventsRef", "emitEventAndReturn");
|
|
92
|
+
}
|
|
93
|
+
receiveStream(trace, pluginName, event, listener, timeoutSeconds) {
|
|
94
|
+
throw (0, errorMessages_1.BSB_ERROR_METHOD_NOT_IMPLEMENTED)("BSBEventsRef", "receiveStream");
|
|
95
|
+
}
|
|
96
|
+
sendStream(trace, pluginName, event, streamId, stream) {
|
|
97
|
+
throw (0, errorMessages_1.BSB_ERROR_METHOD_NOT_IMPLEMENTED)("BSBEventsRef", "sendStream");
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
exports.BSBEventsRef = BSBEventsRef;
|
|
101
|
+
//# sourceMappingURL=BSBEvents.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BSBEvents.js","sourceRoot":"","sources":["../../src/base/BSBEvents.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;;;AAIH,iCAAwF;AACxF,mDAAmE;AAcnE;;;;GAIG;AACH,MAAsB,SAGlB,SAAQ,kCAIP;IACD,YAAY,MAA8C;QACtD,KAAK,CAAC,MAAM,CAAC,CAAC;IAClB,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACI,GAAG,KAAU,CAAC;CA0KxB;AAhND,8BAgNC;AAED;;;GAGG;AACH,MAAa,YACT,SAAQ,SAAS;IACV,WAAW,CACd,KAAiB,EACjB,UAAkB,EAClB,KAAa,EACb,QAA2D;QAE3D,MAAM,IAAA,gDAAgC,EAAC,cAAc,EAAE,aAAa,CAAC,CAAC;IAC1E,CAAC;IAEM,aAAa,CAChB,KAAiB,EACjB,UAAkB,EAClB,KAAa,EACb,IAAW;QAEX,MAAM,IAAA,gDAAgC,EAAC,cAAc,EAAE,eAAe,CAAC,CAAC;IAC5E,CAAC;IAEM,OAAO,CACV,KAAiB,EACjB,UAAkB,EAClB,KAAa,EACb,QAA2D;QAE3D,MAAM,IAAA,gDAAgC,EAAC,cAAc,EAAE,SAAS,CAAC,CAAC;IACtE,CAAC;IAEM,SAAS,CACZ,KAAiB,EACjB,UAAkB,EAClB,KAAa,EACb,IAAW;QAEX,MAAM,IAAA,gDAAgC,EAAC,cAAc,EAAE,WAAW,CAAC,CAAC;IACxE,CAAC;IAEM,iBAAiB,CACpB,KAAiB,EACjB,UAAkB,EAClB,KAAa,EACb,QAA0D;QAE1D,MAAM,IAAA,gDAAgC,EAAC,cAAc,EAAE,mBAAmB,CAAC,CAAC;IAChF,CAAC;IAEM,kBAAkB,CACrB,KAAiB,EACjB,UAAkB,EAClB,KAAa,EACb,cAAsB,EACtB,IAAW;QAEX,MAAM,IAAA,gDAAgC,EAClC,cAAc,EACd,oBAAoB,CACvB,CAAC;IACN,CAAC;IAEM,aAAa,CAChB,KAAiB,EACjB,UAAkB,EAClB,KAAa,EACb,QAAqF,EACrF,cAAmC;QAEnC,MAAM,IAAA,gDAAgC,EAAC,cAAc,EAAE,eAAe,CAAC,CAAC;IAC5E,CAAC;IAEM,UAAU,CACb,KAAiB,EACjB,UAAkB,EAClB,KAAa,EACb,QAAgB,EAChB,MAAgB;QAEhB,MAAM,IAAA,gDAAgC,EAAC,cAAc,EAAE,YAAY,CAAC,CAAC;IACzE,CAAC;CAKJ;AAnFD,oCAmFC"}
|
|
@@ -0,0 +1,178 @@
|
|
|
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 { DTrace, LogMeta } from "../interfaces";
|
|
28
|
+
import { BaseWithConfig, BaseWithConfigConfig } from "./base";
|
|
29
|
+
import { BSBError } from "./errorMessages";
|
|
30
|
+
import { BSBReferencePluginConfigDefinition, BSBReferencePluginConfigType } from "./PluginConfig";
|
|
31
|
+
export interface BSBObservableConstructor<ReferencedConfig extends BSBReferencePluginConfigType = any> extends BaseWithConfigConfig<ReferencedConfig extends null ? null : BSBReferencePluginConfigDefinition<ReferencedConfig> & any> {
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Unified Observable plugin base class for logging, metrics, and tracing
|
|
35
|
+
* @group Observable
|
|
36
|
+
* @category Plugins
|
|
37
|
+
* @template ReferencedConfig - The type of configuration for the plugin
|
|
38
|
+
* @see {@link https://bsbcode.dev/languages/nodejs/types/classes/BSBObservable.html | API: BSBObservable}
|
|
39
|
+
*/
|
|
40
|
+
export declare abstract class BSBObservable<ReferencedConfig extends BSBReferencePluginConfigType = any> extends BaseWithConfig<ReferencedConfig extends null ? null : BSBReferencePluginConfigDefinition<ReferencedConfig> & any> {
|
|
41
|
+
constructor(config: BSBObservableConstructor<ReferencedConfig>);
|
|
42
|
+
/**
|
|
43
|
+
* Logging: Debug level
|
|
44
|
+
* @param trace - Trace for tracking the operation
|
|
45
|
+
* @param pluginName - Name of the plugin emitting the log
|
|
46
|
+
* @param message - Log message
|
|
47
|
+
* @param meta - Metadata
|
|
48
|
+
*/
|
|
49
|
+
debug?(trace: DTrace, pluginName: string, message: string, meta: LogMeta<any>): void;
|
|
50
|
+
/**
|
|
51
|
+
* Logging: Info level
|
|
52
|
+
* @param trace - Trace for tracking the operation
|
|
53
|
+
* @param pluginName - Name of the plugin emitting the log
|
|
54
|
+
* @param message - Log message
|
|
55
|
+
* @param meta - Metadata
|
|
56
|
+
*/
|
|
57
|
+
info?(trace: DTrace, pluginName: string, message: string, meta: LogMeta<any>): void;
|
|
58
|
+
/**
|
|
59
|
+
* Logging: Warn level
|
|
60
|
+
* @param trace - Trace for tracking the operation
|
|
61
|
+
* @param pluginName - Name of the plugin emitting the log
|
|
62
|
+
* @param message - Log message
|
|
63
|
+
* @param meta - Metadata
|
|
64
|
+
*/
|
|
65
|
+
warn?(trace: DTrace, pluginName: string, message: string, meta: LogMeta<any>): void;
|
|
66
|
+
/**
|
|
67
|
+
* Logging: Error level
|
|
68
|
+
* @param trace - Trace for tracking the operation
|
|
69
|
+
* @param pluginName - Name of the plugin emitting the log
|
|
70
|
+
* @param message - Log message or error object
|
|
71
|
+
* @param meta - Metadata
|
|
72
|
+
*/
|
|
73
|
+
error?(trace: DTrace, pluginName: string, message: string | BSBError<any>, meta?: LogMeta<any>): void;
|
|
74
|
+
/**
|
|
75
|
+
* Metrics: Counter creation
|
|
76
|
+
* @param timestamp - Timestamp of the metric
|
|
77
|
+
* @param pluginName - Name of the plugin emitting the metric
|
|
78
|
+
* @param name - Metric name
|
|
79
|
+
* @param description - Metric description
|
|
80
|
+
* @param help - Help text
|
|
81
|
+
* @param labels - Optional labels
|
|
82
|
+
*/
|
|
83
|
+
createCounter?(timestamp: number, pluginName: string, name: string, description: string, help: string, labels?: string[]): void | Promise<void>;
|
|
84
|
+
/**
|
|
85
|
+
* Metrics: Gauge creation
|
|
86
|
+
* @param timestamp - Timestamp of the metric
|
|
87
|
+
* @param pluginName - Name of the plugin emitting the metric
|
|
88
|
+
* @param name - Metric name
|
|
89
|
+
* @param description - Metric description
|
|
90
|
+
* @param help - Help text
|
|
91
|
+
* @param labels - Optional labels
|
|
92
|
+
*/
|
|
93
|
+
createGauge?(timestamp: number, pluginName: string, name: string, description: string, help: string, labels?: string[]): void | Promise<void>;
|
|
94
|
+
/**
|
|
95
|
+
* Metrics: Histogram creation
|
|
96
|
+
* @param timestamp - Timestamp of the metric
|
|
97
|
+
* @param pluginName - Name of the plugin emitting the metric
|
|
98
|
+
* @param name - Metric name
|
|
99
|
+
* @param description - Metric description
|
|
100
|
+
* @param help - Help text
|
|
101
|
+
* @param boundaries - Histogram boundaries
|
|
102
|
+
* @param labels - Optional labels
|
|
103
|
+
*/
|
|
104
|
+
createHistogram?(timestamp: number, pluginName: string, name: string, description: string, help: string, boundaries?: number[], labels?: string[]): void | Promise<void>;
|
|
105
|
+
/**
|
|
106
|
+
* Metrics: Counter increment
|
|
107
|
+
* @param timestamp - Timestamp of the metric
|
|
108
|
+
* @param pluginName - Name of the plugin emitting the metric
|
|
109
|
+
* @param name - Metric name
|
|
110
|
+
* @param value - Increment value
|
|
111
|
+
* @param labels - Optional label values
|
|
112
|
+
*/
|
|
113
|
+
incrementCounter?(timestamp: number, pluginName: string, name: string, value: number, labels?: Record<string, string>): void | Promise<void>;
|
|
114
|
+
/**
|
|
115
|
+
* Metrics: Gauge set
|
|
116
|
+
* @param timestamp - Timestamp of the metric
|
|
117
|
+
* @param pluginName - Name of the plugin emitting the metric
|
|
118
|
+
* @param name - Metric name
|
|
119
|
+
* @param value - Gauge value
|
|
120
|
+
* @param labels - Optional label values
|
|
121
|
+
*/
|
|
122
|
+
setGauge?(timestamp: number, pluginName: string, name: string, value: number, labels?: Record<string, string>): void | Promise<void>;
|
|
123
|
+
/**
|
|
124
|
+
* Metrics: Histogram observe
|
|
125
|
+
* @param timestamp - Timestamp of the metric
|
|
126
|
+
* @param pluginName - Name of the plugin emitting the metric
|
|
127
|
+
* @param name - Metric name
|
|
128
|
+
* @param value - Observed value
|
|
129
|
+
* @param labels - Optional label values
|
|
130
|
+
*/
|
|
131
|
+
observeHistogram?(timestamp: number, pluginName: string, name: string, value: number, labels?: Record<string, string>): void | Promise<void>;
|
|
132
|
+
/**
|
|
133
|
+
* Tracing: Span start
|
|
134
|
+
* @param trace - Span trace (contains trace ID and new span ID)
|
|
135
|
+
* @param pluginName - Name of the plugin creating the span
|
|
136
|
+
* @param spanName - Name of the span
|
|
137
|
+
* @param parentSpanId - Parent span ID (null for root spans)
|
|
138
|
+
* @param attributes - Span attributes
|
|
139
|
+
*/
|
|
140
|
+
spanStart?(trace: DTrace, pluginName: string, spanName: string, parentSpanId: string | null, attributes?: Record<string, string | number | boolean>): void | Promise<void>;
|
|
141
|
+
/**
|
|
142
|
+
* Tracing: Span end
|
|
143
|
+
* @param trace - Span trace
|
|
144
|
+
* @param pluginName - Name of the plugin ending the span
|
|
145
|
+
* @param attributes - Final attributes
|
|
146
|
+
*/
|
|
147
|
+
spanEnd?(trace: DTrace, pluginName: string, attributes?: Record<string, string | number | boolean>): void | Promise<void>;
|
|
148
|
+
/**
|
|
149
|
+
* Tracing: Span error
|
|
150
|
+
* @param trace - Span trace
|
|
151
|
+
* @param pluginName - Name of the plugin recording the error
|
|
152
|
+
* @param error - Error object
|
|
153
|
+
* @param attributes - Error attributes
|
|
154
|
+
*/
|
|
155
|
+
spanError?(trace: DTrace, pluginName: string, error: Error, attributes?: Record<string, string | number | boolean>): void | Promise<void>;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* @hidden
|
|
159
|
+
* DO NOT REFERENCE/USE THIS CLASS - IT IS AN INTERNALLY REFERENCED CLASS
|
|
160
|
+
*/
|
|
161
|
+
export declare class BSBObservableRef extends BSBObservable {
|
|
162
|
+
dispose?(): void;
|
|
163
|
+
init?(): void | Promise<void>;
|
|
164
|
+
run?(): void | Promise<void>;
|
|
165
|
+
debug(trace: DTrace, pluginName: string, message: string, meta: LogMeta<any>): void;
|
|
166
|
+
info(trace: DTrace, pluginName: string, message: string, meta: LogMeta<any>): void;
|
|
167
|
+
warn(trace: DTrace, pluginName: string, message: string, meta: LogMeta<any>): void;
|
|
168
|
+
error(trace: DTrace, pluginName: string, message: string | BSBError<any>, meta?: LogMeta<any>): void;
|
|
169
|
+
createCounter(timestamp: number, pluginName: string, name: string, description: string, help: string, labels?: string[]): void;
|
|
170
|
+
createGauge(timestamp: number, pluginName: string, name: string, description: string, help: string, labels?: string[]): void;
|
|
171
|
+
createHistogram(timestamp: number, pluginName: string, name: string, description: string, help: string, boundaries?: number[], labels?: string[]): void;
|
|
172
|
+
incrementCounter(timestamp: number, pluginName: string, name: string, value: number, labels?: Record<string, string>): void;
|
|
173
|
+
setGauge(timestamp: number, pluginName: string, name: string, value: number, labels?: Record<string, string>): void;
|
|
174
|
+
observeHistogram(timestamp: number, pluginName: string, name: string, value: number, labels?: Record<string, string>): void;
|
|
175
|
+
spanStart(trace: DTrace, pluginName: string, spanName: string, parentSpanId: string | null, attributes?: Record<string, string | number | boolean>): void;
|
|
176
|
+
spanEnd(trace: DTrace, pluginName: string, attributes?: Record<string, string | number | boolean>): void;
|
|
177
|
+
spanError(trace: DTrace, pluginName: string, error: Error, attributes?: Record<string, string | number | boolean>): void;
|
|
178
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
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.BSBObservableRef = exports.BSBObservable = void 0;
|
|
30
|
+
const base_1 = require("./base");
|
|
31
|
+
const errorMessages_1 = require("./errorMessages");
|
|
32
|
+
/**
|
|
33
|
+
* Unified Observable plugin base class for logging, metrics, and tracing
|
|
34
|
+
* @group Observable
|
|
35
|
+
* @category Plugins
|
|
36
|
+
* @template ReferencedConfig - The type of configuration for the plugin
|
|
37
|
+
* @see {@link https://bsbcode.dev/languages/nodejs/types/classes/BSBObservable.html | API: BSBObservable}
|
|
38
|
+
*/
|
|
39
|
+
class BSBObservable extends base_1.BaseWithConfig {
|
|
40
|
+
constructor(config) {
|
|
41
|
+
super(config);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.BSBObservable = BSBObservable;
|
|
45
|
+
/**
|
|
46
|
+
* @hidden
|
|
47
|
+
* DO NOT REFERENCE/USE THIS CLASS - IT IS AN INTERNALLY REFERENCED CLASS
|
|
48
|
+
*/
|
|
49
|
+
class BSBObservableRef extends BSBObservable {
|
|
50
|
+
debug(trace, pluginName, message, meta) {
|
|
51
|
+
throw (0, errorMessages_1.BSB_ERROR_METHOD_NOT_IMPLEMENTED)("BSBObservableRef", "debug");
|
|
52
|
+
}
|
|
53
|
+
info(trace, pluginName, message, meta) {
|
|
54
|
+
throw (0, errorMessages_1.BSB_ERROR_METHOD_NOT_IMPLEMENTED)("BSBObservableRef", "info");
|
|
55
|
+
}
|
|
56
|
+
warn(trace, pluginName, message, meta) {
|
|
57
|
+
throw (0, errorMessages_1.BSB_ERROR_METHOD_NOT_IMPLEMENTED)("BSBObservableRef", "warn");
|
|
58
|
+
}
|
|
59
|
+
error(trace, pluginName, message, meta) {
|
|
60
|
+
throw (0, errorMessages_1.BSB_ERROR_METHOD_NOT_IMPLEMENTED)("BSBObservableRef", "error");
|
|
61
|
+
}
|
|
62
|
+
createCounter(timestamp, pluginName, name, description, help, labels) {
|
|
63
|
+
throw (0, errorMessages_1.BSB_ERROR_METHOD_NOT_IMPLEMENTED)("BSBObservableRef", "createCounter");
|
|
64
|
+
}
|
|
65
|
+
createGauge(timestamp, pluginName, name, description, help, labels) {
|
|
66
|
+
throw (0, errorMessages_1.BSB_ERROR_METHOD_NOT_IMPLEMENTED)("BSBObservableRef", "createGauge");
|
|
67
|
+
}
|
|
68
|
+
createHistogram(timestamp, pluginName, name, description, help, boundaries, labels) {
|
|
69
|
+
throw (0, errorMessages_1.BSB_ERROR_METHOD_NOT_IMPLEMENTED)("BSBObservableRef", "createHistogram");
|
|
70
|
+
}
|
|
71
|
+
incrementCounter(timestamp, pluginName, name, value, labels) {
|
|
72
|
+
throw (0, errorMessages_1.BSB_ERROR_METHOD_NOT_IMPLEMENTED)("BSBObservableRef", "incrementCounter");
|
|
73
|
+
}
|
|
74
|
+
setGauge(timestamp, pluginName, name, value, labels) {
|
|
75
|
+
throw (0, errorMessages_1.BSB_ERROR_METHOD_NOT_IMPLEMENTED)("BSBObservableRef", "setGauge");
|
|
76
|
+
}
|
|
77
|
+
observeHistogram(timestamp, pluginName, name, value, labels) {
|
|
78
|
+
throw (0, errorMessages_1.BSB_ERROR_METHOD_NOT_IMPLEMENTED)("BSBObservableRef", "observeHistogram");
|
|
79
|
+
}
|
|
80
|
+
spanStart(trace, pluginName, spanName, parentSpanId, attributes) {
|
|
81
|
+
throw (0, errorMessages_1.BSB_ERROR_METHOD_NOT_IMPLEMENTED)("BSBObservableRef", "spanStart");
|
|
82
|
+
}
|
|
83
|
+
spanEnd(trace, pluginName, attributes) {
|
|
84
|
+
throw (0, errorMessages_1.BSB_ERROR_METHOD_NOT_IMPLEMENTED)("BSBObservableRef", "spanEnd");
|
|
85
|
+
}
|
|
86
|
+
spanError(trace, pluginName, error, attributes) {
|
|
87
|
+
throw (0, errorMessages_1.BSB_ERROR_METHOD_NOT_IMPLEMENTED)("BSBObservableRef", "spanError");
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
exports.BSBObservableRef = BSBObservableRef;
|
|
91
|
+
//# sourceMappingURL=BSBObservable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BSBObservable.js","sourceRoot":"","sources":["../../src/base/BSBObservable.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;;;AAIH,iCAA8D;AAC9D,mDAA6E;AAY7E;;;;;;GAMG;AACH,MAAsB,aAEpB,SAAQ,qBAIT;IACC,YAAY,MAAkD;QAC5D,KAAK,CAAC,MAAM,CAAC,CAAC;IAChB,CAAC;CAuLF;AAhMD,sCAgMC;AAED;;;GAGG;AACH,MAAa,gBAAiB,SAAQ,aAAa;IAMjD,KAAK,CAAC,KAAa,EAAE,UAAkB,EAAE,OAAe,EAAE,IAAkB;QAC1E,MAAM,IAAA,gDAAgC,EAAC,kBAAkB,EAAE,OAAO,CAAC,CAAC;IACtE,CAAC;IAED,IAAI,CAAC,KAAa,EAAE,UAAkB,EAAE,OAAe,EAAE,IAAkB;QACzE,MAAM,IAAA,gDAAgC,EAAC,kBAAkB,EAAE,MAAM,CAAC,CAAC;IACrE,CAAC;IAED,IAAI,CAAC,KAAa,EAAE,UAAkB,EAAE,OAAe,EAAE,IAAkB;QACzE,MAAM,IAAA,gDAAgC,EAAC,kBAAkB,EAAE,MAAM,CAAC,CAAC;IACrE,CAAC;IAED,KAAK,CAAC,KAAa,EAAE,UAAkB,EAAE,OAA+B,EAAE,IAAmB;QAC3F,MAAM,IAAA,gDAAgC,EAAC,kBAAkB,EAAE,OAAO,CAAC,CAAC;IACtE,CAAC;IAED,aAAa,CACX,SAAiB,EACjB,UAAkB,EAClB,IAAY,EACZ,WAAmB,EACnB,IAAY,EACZ,MAAiB;QAEjB,MAAM,IAAA,gDAAgC,EAAC,kBAAkB,EAAE,eAAe,CAAC,CAAC;IAC9E,CAAC;IAED,WAAW,CACT,SAAiB,EACjB,UAAkB,EAClB,IAAY,EACZ,WAAmB,EACnB,IAAY,EACZ,MAAiB;QAEjB,MAAM,IAAA,gDAAgC,EAAC,kBAAkB,EAAE,aAAa,CAAC,CAAC;IAC5E,CAAC;IAED,eAAe,CACb,SAAiB,EACjB,UAAkB,EAClB,IAAY,EACZ,WAAmB,EACnB,IAAY,EACZ,UAAqB,EACrB,MAAiB;QAEjB,MAAM,IAAA,gDAAgC,EAAC,kBAAkB,EAAE,iBAAiB,CAAC,CAAC;IAChF,CAAC;IAED,gBAAgB,CACd,SAAiB,EACjB,UAAkB,EAClB,IAAY,EACZ,KAAa,EACb,MAA+B;QAE/B,MAAM,IAAA,gDAAgC,EAAC,kBAAkB,EAAE,kBAAkB,CAAC,CAAC;IACjF,CAAC;IAED,QAAQ,CACN,SAAiB,EACjB,UAAkB,EAClB,IAAY,EACZ,KAAa,EACb,MAA+B;QAE/B,MAAM,IAAA,gDAAgC,EAAC,kBAAkB,EAAE,UAAU,CAAC,CAAC;IACzE,CAAC;IAED,gBAAgB,CACd,SAAiB,EACjB,UAAkB,EAClB,IAAY,EACZ,KAAa,EACb,MAA+B;QAE/B,MAAM,IAAA,gDAAgC,EAAC,kBAAkB,EAAE,kBAAkB,CAAC,CAAC;IACjF,CAAC;IAED,SAAS,CACP,KAAa,EACb,UAAkB,EAClB,QAAgB,EAChB,YAA2B,EAC3B,UAAsD;QAEtD,MAAM,IAAA,gDAAgC,EAAC,kBAAkB,EAAE,WAAW,CAAC,CAAC;IAC1E,CAAC;IAED,OAAO,CACL,KAAa,EACb,UAAkB,EAClB,UAAsD;QAEtD,MAAM,IAAA,gDAAgC,EAAC,kBAAkB,EAAE,SAAS,CAAC,CAAC;IACxE,CAAC;IAED,SAAS,CACP,KAAa,EACb,UAAkB,EAClB,KAAY,EACZ,UAAsD;QAEtD,MAAM,IAAA,gDAAgC,EAAC,kBAAkB,EAAE,WAAW,CAAC,CAAC;IAC1E,CAAC;CACF;AAhHD,4CAgHC"}
|