@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.
Files changed (182) hide show
  1. package/LICENSE +665 -0
  2. package/LICENSE.commercial +32 -0
  3. package/README.md +263 -0
  4. package/bsb-plugin.json +62 -0
  5. package/lib/base/BSBConfig.d.ts +130 -0
  6. package/lib/base/BSBConfig.js +95 -0
  7. package/lib/base/BSBConfig.js.map +1 -0
  8. package/lib/base/BSBEvents.d.ts +207 -0
  9. package/lib/base/BSBEvents.js +101 -0
  10. package/lib/base/BSBEvents.js.map +1 -0
  11. package/lib/base/BSBObservable.d.ts +178 -0
  12. package/lib/base/BSBObservable.js +91 -0
  13. package/lib/base/BSBObservable.js.map +1 -0
  14. package/lib/base/BSBService.d.ts +277 -0
  15. package/lib/base/BSBService.js +366 -0
  16. package/lib/base/BSBService.js.map +1 -0
  17. package/lib/base/BSBServiceClient.d.ts +135 -0
  18. package/lib/base/BSBServiceClient.js +130 -0
  19. package/lib/base/BSBServiceClient.js.map +1 -0
  20. package/lib/base/EventValidator.d.ts +137 -0
  21. package/lib/base/EventValidator.js +210 -0
  22. package/lib/base/EventValidator.js.map +1 -0
  23. package/lib/base/ObservableBackend.d.ts +281 -0
  24. package/lib/base/ObservableBackend.js +515 -0
  25. package/lib/base/ObservableBackend.js.map +1 -0
  26. package/lib/base/PluginConfig.d.ts +196 -0
  27. package/lib/base/PluginConfig.js +96 -0
  28. package/lib/base/PluginConfig.js.map +1 -0
  29. package/lib/base/PluginEvents.d.ts +140 -0
  30. package/lib/base/PluginEvents.js +268 -0
  31. package/lib/base/PluginEvents.js.map +1 -0
  32. package/lib/base/PluginObservable.d.ts +196 -0
  33. package/lib/base/PluginObservable.js +250 -0
  34. package/lib/base/PluginObservable.js.map +1 -0
  35. package/lib/base/ResourceContext.d.ts +70 -0
  36. package/lib/base/ResourceContext.js +54 -0
  37. package/lib/base/ResourceContext.js.map +1 -0
  38. package/lib/base/base.d.ts +264 -0
  39. package/lib/base/base.js +182 -0
  40. package/lib/base/base.js.map +1 -0
  41. package/lib/base/errorMessages.d.ts +56 -0
  42. package/lib/base/errorMessages.js +70 -0
  43. package/lib/base/errorMessages.js.map +1 -0
  44. package/lib/base/factory.d.ts +58 -0
  45. package/lib/base/factory.js +167 -0
  46. package/lib/base/factory.js.map +1 -0
  47. package/lib/base/functions.d.ts +117 -0
  48. package/lib/base/functions.js +152 -0
  49. package/lib/base/functions.js.map +1 -0
  50. package/lib/base/index.d.ts +44 -0
  51. package/lib/base/index.js +64 -0
  52. package/lib/base/index.js.map +1 -0
  53. package/lib/base/logFormatter.d.ts +50 -0
  54. package/lib/base/logFormatter.js +105 -0
  55. package/lib/base/logFormatter.js.map +1 -0
  56. package/lib/base/tools.d.ts +316 -0
  57. package/lib/base/tools.js +666 -0
  58. package/lib/base/tools.js.map +1 -0
  59. package/lib/cli.d.ts +28 -0
  60. package/lib/cli.js +254 -0
  61. package/lib/cli.js.map +1 -0
  62. package/lib/dev.d.ts +27 -0
  63. package/lib/dev.js +200 -0
  64. package/lib/dev.js.map +1 -0
  65. package/lib/index.d.ts +32 -0
  66. package/lib/index.js +49 -0
  67. package/lib/index.js.map +1 -0
  68. package/lib/interfaces/events.d.ts +67 -0
  69. package/lib/interfaces/events.js +44 -0
  70. package/lib/interfaces/events.js.map +1 -0
  71. package/lib/interfaces/index.d.ts +38 -0
  72. package/lib/interfaces/index.js +59 -0
  73. package/lib/interfaces/index.js.map +1 -0
  74. package/lib/interfaces/logging.d.ts +106 -0
  75. package/lib/interfaces/logging.js +39 -0
  76. package/lib/interfaces/logging.js.map +1 -0
  77. package/lib/interfaces/metrics.d.ts +365 -0
  78. package/lib/interfaces/metrics.js +46 -0
  79. package/lib/interfaces/metrics.js.map +1 -0
  80. package/lib/interfaces/observable-types.d.ts +63 -0
  81. package/lib/interfaces/observable-types.js +49 -0
  82. package/lib/interfaces/observable-types.js.map +1 -0
  83. package/lib/interfaces/observable.d.ts +297 -0
  84. package/lib/interfaces/observable.js +29 -0
  85. package/lib/interfaces/observable.js.map +1 -0
  86. package/lib/interfaces/options.d.ts +164 -0
  87. package/lib/interfaces/options.js +56 -0
  88. package/lib/interfaces/options.js.map +1 -0
  89. package/lib/interfaces/plugins.d.ts +143 -0
  90. package/lib/interfaces/plugins.js +45 -0
  91. package/lib/interfaces/plugins.js.map +1 -0
  92. package/lib/interfaces/result.d.ts +129 -0
  93. package/lib/interfaces/result.js +162 -0
  94. package/lib/interfaces/result.js.map +1 -0
  95. package/lib/interfaces/schema-events.d.ts +378 -0
  96. package/lib/interfaces/schema-events.js +247 -0
  97. package/lib/interfaces/schema-events.js.map +1 -0
  98. package/lib/interfaces/schema-types.d.ts +407 -0
  99. package/lib/interfaces/schema-types.js +581 -0
  100. package/lib/interfaces/schema-types.js.map +1 -0
  101. package/lib/interfaces/service.d.ts +48 -0
  102. package/lib/interfaces/service.js +29 -0
  103. package/lib/interfaces/service.js.map +1 -0
  104. package/lib/interfaces/tools.d.ts +65 -0
  105. package/lib/interfaces/tools.js +50 -0
  106. package/lib/interfaces/tools.js.map +1 -0
  107. package/lib/plugins/config-default/index.d.ts +59 -0
  108. package/lib/plugins/config-default/index.js +197 -0
  109. package/lib/plugins/config-default/index.js.map +1 -0
  110. package/lib/plugins/config-default/interfaces.d.ts +92 -0
  111. package/lib/plugins/config-default/interfaces.js +36 -0
  112. package/lib/plugins/config-default/interfaces.js.map +1 -0
  113. package/lib/plugins/events-default/events/broadcast.d.ts +36 -0
  114. package/lib/plugins/events-default/events/broadcast.js +85 -0
  115. package/lib/plugins/events-default/events/broadcast.js.map +1 -0
  116. package/lib/plugins/events-default/events/emit.d.ts +38 -0
  117. package/lib/plugins/events-default/events/emit.js +104 -0
  118. package/lib/plugins/events-default/events/emit.js.map +1 -0
  119. package/lib/plugins/events-default/events/emitAndReturn.d.ts +36 -0
  120. package/lib/plugins/events-default/events/emitAndReturn.js +100 -0
  121. package/lib/plugins/events-default/events/emitAndReturn.js.map +1 -0
  122. package/lib/plugins/events-default/events/emitStreamAndReceiveStream.d.ts +38 -0
  123. package/lib/plugins/events-default/events/emitStreamAndReceiveStream.js +134 -0
  124. package/lib/plugins/events-default/events/emitStreamAndReceiveStream.js.map +1 -0
  125. package/lib/plugins/events-default/events/index.d.ts +30 -0
  126. package/lib/plugins/events-default/events/index.js +38 -0
  127. package/lib/plugins/events-default/events/index.js.map +1 -0
  128. package/lib/plugins/events-default/index.d.ts +57 -0
  129. package/lib/plugins/events-default/index.js +86 -0
  130. package/lib/plugins/events-default/index.js.map +1 -0
  131. package/lib/plugins/observable-default/index.d.ts +43 -0
  132. package/lib/plugins/observable-default/index.js +151 -0
  133. package/lib/plugins/observable-default/index.js.map +1 -0
  134. package/lib/schemas/config-default.json +34 -0
  135. package/lib/schemas/config-default.plugin.json +36 -0
  136. package/lib/schemas/events-default.json +18 -0
  137. package/lib/schemas/events-default.plugin.json +17 -0
  138. package/lib/schemas/observable-default.json +33 -0
  139. package/lib/schemas/observable-default.plugin.json +24 -0
  140. package/lib/scripts/bsb-client-cli.d.ts +21 -0
  141. package/lib/scripts/bsb-client-cli.js +701 -0
  142. package/lib/scripts/bsb-client-cli.js.map +1 -0
  143. package/lib/scripts/bsb-plugin-cli.d.ts +15 -0
  144. package/lib/scripts/bsb-plugin-cli.js +547 -0
  145. package/lib/scripts/bsb-plugin-cli.js.map +1 -0
  146. package/lib/scripts/export-schemas.d.ts +17 -0
  147. package/lib/scripts/export-schemas.js +205 -0
  148. package/lib/scripts/export-schemas.js.map +1 -0
  149. package/lib/scripts/extract-schemas-from-source.d.ts +23 -0
  150. package/lib/scripts/extract-schemas-from-source.js +604 -0
  151. package/lib/scripts/extract-schemas-from-source.js.map +1 -0
  152. package/lib/scripts/generate-client-types.d.ts +22 -0
  153. package/lib/scripts/generate-client-types.js +537 -0
  154. package/lib/scripts/generate-client-types.js.map +1 -0
  155. package/lib/scripts/generate-plugin-json.d.ts +17 -0
  156. package/lib/scripts/generate-plugin-json.js +219 -0
  157. package/lib/scripts/generate-plugin-json.js.map +1 -0
  158. package/lib/serviceBase/config.d.ts +83 -0
  159. package/lib/serviceBase/config.js +236 -0
  160. package/lib/serviceBase/config.js.map +1 -0
  161. package/lib/serviceBase/events.d.ts +91 -0
  162. package/lib/serviceBase/events.js +519 -0
  163. package/lib/serviceBase/events.js.map +1 -0
  164. package/lib/serviceBase/index.d.ts +33 -0
  165. package/lib/serviceBase/index.js +50 -0
  166. package/lib/serviceBase/index.js.map +1 -0
  167. package/lib/serviceBase/observable.d.ts +249 -0
  168. package/lib/serviceBase/observable.js +551 -0
  169. package/lib/serviceBase/observable.js.map +1 -0
  170. package/lib/serviceBase/plugins.d.ts +48 -0
  171. package/lib/serviceBase/plugins.js +184 -0
  172. package/lib/serviceBase/plugins.js.map +1 -0
  173. package/lib/serviceBase/serviceBase.d.ts +228 -0
  174. package/lib/serviceBase/serviceBase.js +420 -0
  175. package/lib/serviceBase/serviceBase.js.map +1 -0
  176. package/lib/serviceBase/services.d.ts +63 -0
  177. package/lib/serviceBase/services.js +346 -0
  178. package/lib/serviceBase/services.js.map +1 -0
  179. package/lib/tests.d.ts +27 -0
  180. package/lib/tests.js +44 -0
  181. package/lib/tests.js.map +1 -0
  182. package/package.json +91 -0
@@ -0,0 +1,86 @@
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.Config = void 0;
30
+ const index_1 = require("../../plugins/events-default/events/index");
31
+ const BSBEvents_1 = require("../../base/BSBEvents");
32
+ const PluginConfig_1 = require("../../base/PluginConfig");
33
+ exports.Config = (0, PluginConfig_1.createConfigSchema)({
34
+ name: "events-default",
35
+ description: "Default in-process events plugin for BSB event routing",
36
+ version: "1.0.0",
37
+ image: "../docs/public/assets/images/bsb-logo.png",
38
+ tags: ["core", "events", "default"],
39
+ documentation: ["./docs/core-plugins/events-default.md"],
40
+ });
41
+ class Plugin extends BSBEvents_1.BSBEvents {
42
+ static Config = exports.Config;
43
+ broadcast;
44
+ emit;
45
+ ear;
46
+ eas;
47
+ constructor(config) {
48
+ super(config);
49
+ this.broadcast = new index_1.broadcast(this.__internalObservable);
50
+ this.emit = new index_1.emit(this.__internalObservable);
51
+ this.ear = new index_1.emitAndReturn(this.__internalObservable);
52
+ this.eas = new index_1.emitStreamAndReceiveStream(this.__internalObservable);
53
+ }
54
+ dispose() {
55
+ this.broadcast.dispose();
56
+ this.emit.dispose();
57
+ this.ear.dispose();
58
+ this.eas.dispose();
59
+ }
60
+ async onBroadcast(obs, pluginName, event, listener) {
61
+ await this.broadcast.onBroadcast(obs, pluginName, event, listener);
62
+ }
63
+ async emitBroadcast(obs, pluginName, event, args) {
64
+ await this.broadcast.emitBroadcast(obs, pluginName, event, args);
65
+ }
66
+ async onEvent(obs, pluginName, event, listener) {
67
+ await this.emit.onEvent(obs, pluginName, event, listener);
68
+ }
69
+ async emitEvent(obs, pluginName, event, args) {
70
+ await this.emit.emitEvent(obs, pluginName, event, args);
71
+ }
72
+ async onReturnableEvent(obs, pluginName, event, listener) {
73
+ await this.ear.onReturnableEvent(obs, pluginName, event, listener);
74
+ }
75
+ async emitEventAndReturn(obs, pluginName, event, timeoutSeconds, args) {
76
+ return await this.ear.emitEventAndReturn(obs, pluginName, event, timeoutSeconds, args);
77
+ }
78
+ async receiveStream(obs, pluginName, event, listener, timeoutSeconds) {
79
+ return this.eas.receiveStream(obs, pluginName, event, listener, timeoutSeconds);
80
+ }
81
+ async sendStream(obs, pluginName, event, streamId, stream) {
82
+ return this.eas.sendStream(obs, pluginName, event, streamId, stream);
83
+ }
84
+ }
85
+ exports.Plugin = Plugin;
86
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/plugins/events-default/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;;;AAGH,qEAKmD;AAEnD,oDAAuE;AACvE,0DAA6D;AAEhD,QAAA,MAAM,GAAG,IAAA,iCAAkB,EACtC;IACE,IAAI,EAAE,gBAAgB;IACtB,WAAW,EAAE,wDAAwD;IACrE,OAAO,EAAE,OAAO;IAChB,KAAK,EAAE,2CAA2C;IAClD,IAAI,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,SAAS,CAAC;IACnC,aAAa,EAAE,CAAC,uCAAuC,CAAC;CACzD,CACF,CAAC;AAEF,MAAa,MACX,SAAQ,qBAAsC;IAC9C,MAAM,CAAC,MAAM,GAAG,cAAM,CAAC;IAGb,SAAS,CAAa;IACtB,IAAI,CAAQ;IACZ,GAAG,CAAiB;IACpB,GAAG,CAA8B;IAE3C,YAAY,MAAyD;QACnE,KAAK,CAAC,MAAM,CAAC,CAAC;QAEd,IAAI,CAAC,SAAS,GAAG,IAAI,iBAAS,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;QAC1D,IAAI,CAAC,IAAI,GAAG,IAAI,YAAI,CAAC,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,EAClB,KAAa,EACb,QAA+D;QAE/D,MAAM,IAAI,CAAC,GAAG,CAAC,iBAAiB,CAAC,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;IACrE,CAAC;IAEM,KAAK,CAAC,kBAAkB,CAC7B,GAAe,EACf,UAAkB,EAClB,KAAa,EACb,cAAsB,EACtB,IAAgB;QAEhB,OAAO,MAAM,IAAI,CAAC,GAAG,CAAC,kBAAkB,CACtC,GAAG,EACH,UAAU,EACV,KAAK,EACL,cAAc,EACd,IAAI,CACL,CAAC;IACJ,CAAC;IAEM,KAAK,CAAC,aAAa,CACxB,GAAe,EACf,UAAkB,EAClB,KAAa,EACb,QAAqF,EACrF,cAAuB;QAEvB,OAAO,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,QAAQ,EAAE,cAAc,CAAC,CAAC;IAClF,CAAC;IAEM,KAAK,CAAC,UAAU,CACrB,GAAe,EACf,UAAkB,EAClB,KAAa,EACb,QAAgB,EAChB,MAAgB;QAEhB,OAAO,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;IACvE,CAAC;;AAzGH,wBA0GC"}
@@ -0,0 +1,43 @@
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 { BSBObservable, BSBObservableConstructor, BSBError } from "../../base";
28
+ import { DTrace, LogMeta } from "../../interfaces";
29
+ import { z } from "zod";
30
+ export declare const Config: import("../../base").BSBPluginConfigClass<z.ZodObject<{}, z.core.$strip>>;
31
+ export declare class Plugin extends BSBObservable<InstanceType<typeof Config>> {
32
+ static Config: import("../../base").BSBPluginConfigClass<z.ZodObject<{}, z.core.$strip>>;
33
+ private logFormatter;
34
+ constructor(config: BSBObservableConstructor<InstanceType<typeof Config>>);
35
+ private formatLog;
36
+ debug(trace: DTrace, pluginName: string, message: string, meta: LogMeta<any>): void;
37
+ info(trace: DTrace, pluginName: string, message: string, meta: LogMeta<any>): void;
38
+ warn(trace: DTrace, pluginName: string, message: string, meta: LogMeta<any>): void;
39
+ error(trace: DTrace, pluginName: string, message: string | BSBError<any>, meta?: LogMeta<any>): void;
40
+ dispose(): void;
41
+ init(): Promise<void>;
42
+ run(): Promise<void>;
43
+ }
@@ -0,0 +1,151 @@
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.Config = void 0;
30
+ const base_1 = require("../../base");
31
+ const zod_1 = require("zod");
32
+ // Console colours for log output
33
+ const CONSOLE_COLOURS = {
34
+ Reset: "\x1b[0m",
35
+ Bright: "\x1b[1m",
36
+ Dim: "\x1b[2m",
37
+ Underscore: "\x1b[4m",
38
+ Blink: "\x1b[5m",
39
+ Reverse: "\x1b[7m",
40
+ Hidden: "\x1b[8m",
41
+ FgBlack: "\x1b[30m",
42
+ FgRed: "\x1b[31m",
43
+ FgGreen: "\x1b[32m",
44
+ FgYellow: "\x1b[33m",
45
+ FgBlue: "\x1b[34m",
46
+ FgMagenta: "\x1b[35m",
47
+ FgCyan: "\x1b[36m",
48
+ FgWhite: "\x1b[37m",
49
+ BgBlack: "\x1b[40m",
50
+ BgRed: "\x1b[41m",
51
+ BgGreen: "\x1b[42m",
52
+ BgYellow: "\x1b[43m",
53
+ BgBlue: "\x1b[44m",
54
+ BgMagenta: "\x1b[45m",
55
+ BgCyan: "\x1b[46m",
56
+ BgWhite: "\x1b[47m",
57
+ };
58
+ const LOG_LEVELS = {
59
+ DEBUG: "debug",
60
+ INFO: "info",
61
+ WARN: "warn",
62
+ ERROR: "error",
63
+ };
64
+ exports.Config = (0, base_1.createConfigSchema)({
65
+ name: "observable-default",
66
+ description: "Default console observable plugin for logging output",
67
+ version: "1.0.0",
68
+ image: "../docs/public/assets/images/bsb-logo.png",
69
+ tags: ["core", "observable", "default", "console"],
70
+ documentation: ["./docs/core-plugins/observable-default.md"],
71
+ }, zod_1.z.object({}));
72
+ class Plugin extends base_1.BSBObservable {
73
+ static Config = exports.Config;
74
+ logFormatter = new base_1.LogFormatter();
75
+ constructor(config) {
76
+ super(config);
77
+ }
78
+ formatLog(level, plugin, trace, message, meta) {
79
+ let formattedMessage = this.logFormatter.formatLog(trace, message, meta);
80
+ formattedMessage = `[${plugin.toUpperCase()}] ${formattedMessage}`;
81
+ let func = console.debug;
82
+ let colour = [];
83
+ switch (level) {
84
+ case LOG_LEVELS.DEBUG:
85
+ formattedMessage = `[DEBUG] ${formattedMessage}`;
86
+ func = console.debug;
87
+ colour = [CONSOLE_COLOURS.BgBlue, CONSOLE_COLOURS.FgWhite];
88
+ break;
89
+ case LOG_LEVELS.INFO:
90
+ formattedMessage = `[INFO] ${formattedMessage}`;
91
+ func = console.log;
92
+ break;
93
+ case LOG_LEVELS.WARN:
94
+ formattedMessage = `[WARN] ${formattedMessage}`;
95
+ func = console.warn;
96
+ colour = [CONSOLE_COLOURS.BgBlack, CONSOLE_COLOURS.FgRed];
97
+ break;
98
+ case LOG_LEVELS.ERROR:
99
+ formattedMessage = `[ERROR] ${formattedMessage}`;
100
+ func = console.error;
101
+ colour = [CONSOLE_COLOURS.BgRed, CONSOLE_COLOURS.FgBlack];
102
+ break;
103
+ }
104
+ const timestamp = new Date().toISOString();
105
+ if (colour.length > 0) {
106
+ func(colour.join("") + "%s" + CONSOLE_COLOURS.Reset, `${timestamp} | ${formattedMessage}`);
107
+ }
108
+ else {
109
+ func(`${timestamp} | ${formattedMessage}`);
110
+ }
111
+ }
112
+ // Logging methods
113
+ debug(trace, pluginName, message, meta) {
114
+ if (this.mode === "production")
115
+ return;
116
+ this.formatLog(LOG_LEVELS.DEBUG, pluginName, trace, message, meta);
117
+ }
118
+ info(trace, pluginName, message, meta) {
119
+ this.formatLog(LOG_LEVELS.INFO, pluginName, trace, message, meta);
120
+ }
121
+ warn(trace, pluginName, message, meta) {
122
+ this.formatLog(LOG_LEVELS.WARN, pluginName, trace, message, meta);
123
+ }
124
+ error(trace, pluginName, message, meta) {
125
+ if (message instanceof base_1.BSBError) {
126
+ if (message.raw !== null) {
127
+ this.formatLog(LOG_LEVELS.ERROR, pluginName, message.raw.trace, message.raw.message, message.raw.meta);
128
+ }
129
+ else {
130
+ this.formatLog(LOG_LEVELS.ERROR, pluginName, trace, message.message);
131
+ }
132
+ }
133
+ else {
134
+ this.formatLog(LOG_LEVELS.ERROR, pluginName, trace, message, meta);
135
+ }
136
+ }
137
+ // Metrics methods - no-op for console plugin (could be implemented to log metrics)
138
+ // Other observable plugins like observable-datadog would implement these properly
139
+ // Lifecycle methods
140
+ dispose() {
141
+ // No resources to cleanup for console logger
142
+ }
143
+ async init() {
144
+ // No initialization needed for console logger
145
+ }
146
+ async run() {
147
+ // No runtime setup needed for console logger
148
+ }
149
+ }
150
+ exports.Plugin = Plugin;
151
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/plugins/observable-default/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;;;AAEH,qCAAiH;AAEjH,6BAAwB;AAExB,iCAAiC;AACjC,MAAM,eAAe,GAAG;IACtB,KAAK,EAAE,SAAS;IAChB,MAAM,EAAE,SAAS;IACjB,GAAG,EAAE,SAAS;IACd,UAAU,EAAE,SAAS;IACrB,KAAK,EAAE,SAAS;IAChB,OAAO,EAAE,SAAS;IAClB,MAAM,EAAE,SAAS;IACjB,OAAO,EAAE,UAAU;IACnB,KAAK,EAAE,UAAU;IACjB,OAAO,EAAE,UAAU;IACnB,QAAQ,EAAE,UAAU;IACpB,MAAM,EAAE,UAAU;IAClB,SAAS,EAAE,UAAU;IACrB,MAAM,EAAE,UAAU;IAClB,OAAO,EAAE,UAAU;IACnB,OAAO,EAAE,UAAU;IACnB,KAAK,EAAE,UAAU;IACjB,OAAO,EAAE,UAAU;IACnB,QAAQ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;QACd,6CAA6C;IAC/C,CAAC;;AA5FH,wBA6FC"}
@@ -0,0 +1,34 @@
1
+ {
2
+ "pluginName": "config-default",
3
+ "version": "1.0.0",
4
+ "events": {},
5
+ "pluginType": "config",
6
+ "capabilities": {
7
+ "configApi": {
8
+ "getObservablePlugins": true,
9
+ "getEventsPlugins": true,
10
+ "getServicePlugins": true,
11
+ "getServicePluginDefinition": true,
12
+ "getPluginConfig": true
13
+ }
14
+ },
15
+ "configSchema": {
16
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
17
+ "type": "object",
18
+ "properties": {
19
+ "BSB_PROFILE": {
20
+ "default": "default",
21
+ "type": "string"
22
+ },
23
+ "BSB_CONFIG_FILE": {
24
+ "default": "./sec-config.yaml",
25
+ "type": "string"
26
+ }
27
+ },
28
+ "required": [
29
+ "BSB_PROFILE",
30
+ "BSB_CONFIG_FILE"
31
+ ],
32
+ "additionalProperties": false
33
+ }
34
+ }
@@ -0,0 +1,36 @@
1
+ {
2
+ "id": "config-default",
3
+ "name": "config-default",
4
+ "version": "9.0.0",
5
+ "description": "Default configuration plugin for profile and plugin resolution",
6
+ "category": "config",
7
+ "tags": [
8
+ "core",
9
+ "config",
10
+ "default"
11
+ ],
12
+ "documentation": [
13
+ "./docs/core-plugins/config-default.md"
14
+ ],
15
+ "dependencies": [],
16
+ "image": "../docs/public/assets/images/bsb-logo.png",
17
+ "configSchema": {
18
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
19
+ "type": "object",
20
+ "properties": {
21
+ "BSB_PROFILE": {
22
+ "default": "default",
23
+ "type": "string"
24
+ },
25
+ "BSB_CONFIG_FILE": {
26
+ "default": "./sec-config.yaml",
27
+ "type": "string"
28
+ }
29
+ },
30
+ "required": [
31
+ "BSB_PROFILE",
32
+ "BSB_CONFIG_FILE"
33
+ ],
34
+ "additionalProperties": false
35
+ }
36
+ }
@@ -0,0 +1,18 @@
1
+ {
2
+ "pluginName": "events-default",
3
+ "version": "1.0.0",
4
+ "events": {},
5
+ "pluginType": "events",
6
+ "capabilities": {
7
+ "eventsApi": {
8
+ "onBroadcast": true,
9
+ "emitBroadcast": true,
10
+ "onEvent": true,
11
+ "emitEvent": true,
12
+ "onReturnableEvent": true,
13
+ "emitEventAndReturn": true,
14
+ "receiveStream": true,
15
+ "sendStream": true
16
+ }
17
+ }
18
+ }
@@ -0,0 +1,17 @@
1
+ {
2
+ "id": "events-default",
3
+ "name": "events-default",
4
+ "version": "9.0.0",
5
+ "description": "Default in-process events plugin for BSB event routing",
6
+ "category": "events",
7
+ "tags": [
8
+ "core",
9
+ "events",
10
+ "default"
11
+ ],
12
+ "documentation": [
13
+ "./docs/core-plugins/events-default.md"
14
+ ],
15
+ "dependencies": [],
16
+ "image": "../docs/public/assets/images/bsb-logo.png"
17
+ }
@@ -0,0 +1,33 @@
1
+ {
2
+ "pluginName": "observable-default",
3
+ "version": "1.0.0",
4
+ "events": {},
5
+ "pluginType": "observable",
6
+ "capabilities": {
7
+ "logging": {
8
+ "debug": true,
9
+ "info": true,
10
+ "warn": true,
11
+ "error": true
12
+ },
13
+ "metrics": {
14
+ "createCounter": false,
15
+ "createGauge": false,
16
+ "createHistogram": false,
17
+ "incrementCounter": false,
18
+ "setGauge": false,
19
+ "observeHistogram": false
20
+ },
21
+ "tracing": {
22
+ "spanStart": false,
23
+ "spanEnd": false,
24
+ "spanError": false
25
+ }
26
+ },
27
+ "configSchema": {
28
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
29
+ "type": "object",
30
+ "properties": {},
31
+ "additionalProperties": false
32
+ }
33
+ }
@@ -0,0 +1,24 @@
1
+ {
2
+ "id": "observable-default",
3
+ "name": "observable-default",
4
+ "version": "9.0.0",
5
+ "description": "Default console observable plugin for logging output",
6
+ "category": "observable",
7
+ "tags": [
8
+ "core",
9
+ "observable",
10
+ "default",
11
+ "console"
12
+ ],
13
+ "documentation": [
14
+ "./docs/core-plugins/observable-default.md"
15
+ ],
16
+ "dependencies": [],
17
+ "image": "../docs/public/assets/images/bsb-logo.png",
18
+ "configSchema": {
19
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
20
+ "type": "object",
21
+ "properties": {},
22
+ "additionalProperties": false
23
+ }
24
+ }
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * BSB Client CLI
4
+ *
5
+ * Commands for interacting with BSB Registry.
6
+ * Provides plugin publishing, searching, and discovery.
7
+ *
8
+ * Usage:
9
+ * bsb-client list - List all plugins from registry
10
+ * bsb-client search <query> - Search plugins
11
+ * bsb-client publish - Publish current plugin(s) to registry
12
+ * bsb-client schema <name> - Get plugin event schema
13
+ * bsb-client info <name> - Get plugin details
14
+ * bsb-client install <name> - Download schema and generate types
15
+ * bsb-client token generate - Generate a new API token
16
+ *
17
+ * Environment:
18
+ * BSB_REGISTRY_URL - Registry URL (default: https://registry.bsbcode.dev)
19
+ * BSB_REGISTRY_TOKEN - API token for authentication
20
+ */
21
+ export {};