@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,67 @@
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 } from './metrics';
28
+ import { DynamicallyReferencedMethodBase } from "./tools";
29
+ export type DynamicallyReferencedMethodOnIEvents<Interface extends DynamicallyReferencedMethodBase, Method extends keyof Interface, hasReturnable extends boolean = false> = Interface[Method] extends (...a: infer Arguments) => infer Return ? [
30
+ event: Method,
31
+ trace: DTrace,
32
+ listener: {
33
+ (trace: DTrace, ...a: Arguments): hasReturnable extends true ? Return : void | Promise<void>;
34
+ }
35
+ ] : [event: Method, noMatchingEvent: never];
36
+ export type DynamicallyReferencedMethodEmitIEvents<Interface extends DynamicallyReferencedMethodBase, Method extends keyof Interface> = Interface[Method] extends (...a: infer Arguments) => infer Return ? [event: Method, trace: DTrace, ...a: Arguments] : [event: Method, noMatchingEvent: never];
37
+ export type DynamicallyReferencedMethodEmitEARIEvents<Interface extends DynamicallyReferencedMethodBase, Method extends keyof Interface, ArgsReference extends boolean = true> = ArgsReference extends true ? Interface[Method] extends (...a: infer Arguments) => infer Return ? [
38
+ event: Method,
39
+ trace: DTrace,
40
+ timeoutSeconds?: number,
41
+ ...a: Arguments
42
+ ] : [
43
+ event: Method,
44
+ noMatchingEvent: never
45
+ ] : Interface[Method] extends (...a: infer Arguments) => infer Return ? Return extends Promise<unknown> ? Return : Promise<Return> : Promise<never>;
46
+ /**
47
+ * @hidden
48
+ */
49
+ export declare const EventsEventTypesBase: {
50
+ readonly onBroadcast: "onBroadcast";
51
+ readonly emitBroadcast: "emitBroadcast";
52
+ readonly onEvent: "onEvent";
53
+ readonly emitEvent: "emitEvent";
54
+ readonly onReturnableEvent: "onReturnableEvent";
55
+ readonly emitEventAndReturn: "emitEventAndReturn";
56
+ readonly emitEventAndReturnTimed: "emitEventAndReturnTimed";
57
+ readonly receiveStream: "receiveStream";
58
+ readonly sendStream: "sendStream";
59
+ };
60
+ /**
61
+ * @hidden
62
+ */
63
+ export type EventsEventBaseTypes = (typeof EventsEventTypesBase)[keyof typeof EventsEventTypesBase];
64
+ /**
65
+ * @hidden
66
+ */
67
+ export type EventsEventTypes = "onEventSpecific" | "emitEventSpecific" | "onReturnableEventSpecific" | "emitEventAndReturnSpecific" | "emitEventAndReturnTimedSpecific" | EventsEventBaseTypes;
@@ -0,0 +1,44 @@
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.EventsEventTypesBase = void 0;
30
+ /**
31
+ * @hidden
32
+ */
33
+ exports.EventsEventTypesBase = {
34
+ onBroadcast: "onBroadcast",
35
+ emitBroadcast: "emitBroadcast",
36
+ onEvent: "onEvent",
37
+ emitEvent: "emitEvent",
38
+ onReturnableEvent: "onReturnableEvent",
39
+ emitEventAndReturn: "emitEventAndReturn",
40
+ emitEventAndReturnTimed: "emitEventAndReturnTimed",
41
+ receiveStream: "receiveStream",
42
+ sendStream: "sendStream",
43
+ };
44
+ //# sourceMappingURL=events.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/interfaces/events.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;;;AA+CH;;GAEG;AACU,QAAA,oBAAoB,GAAG;IAClC,WAAW,EAAE,aAAa;IAC1B,aAAa,EAAE,eAAe;IAC9B,OAAO,EAAE,SAAS;IAClB,SAAS,EAAE,WAAW;IACtB,iBAAiB,EAAE,mBAAmB;IACtC,kBAAkB,EAAE,oBAAoB;IACxC,uBAAuB,EAAE,yBAAyB;IAClD,aAAa,EAAE,eAAe;IAC9B,UAAU,EAAE,YAAY;CAChB,CAAC"}
@@ -0,0 +1,38 @@
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
+ export * from "./events";
28
+ export * from "./logging";
29
+ export * from "./plugins";
30
+ export * from "./service";
31
+ export * from "./metrics";
32
+ export * from "./result";
33
+ export * from "./options";
34
+ export * from "./schema-events";
35
+ export * from "./schema-types";
36
+ export * from "./observable";
37
+ export * from "./observable-types";
38
+ export { CleanStringStrength, DynamicallyReferencedMethodBase, DynamicallyReferencedMethodType, DynamicallyReferencedMethod, DynamicallyReferencedType, MergeObjectsKey, ParamsFromString, SimpleStatu, generateAppIdHash, generateTimeBasedId } from "./tools";
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ /**
3
+ * BSB (Better-Service-Base) is an event-bus based microservice framework.
4
+ * Copyright (C) 2016 - 2025 BetterCorp (PTY) Ltd
5
+ *
6
+ * This program is free software: you can redistribute it and/or modify
7
+ * it under the terms of the GNU Affero General Public License as published
8
+ * by the Free Software Foundation, either version 3 of the License, or
9
+ * (at your option) any later version.
10
+ *
11
+ * Alternatively, you may obtain a commercial license for this program.
12
+ * The commercial license allows you to use the Program in a closed-source manner,
13
+ * including the right to create derivative works that are not subject to the terms
14
+ * of the AGPL.
15
+ *
16
+ * To obtain a commercial license, please contact the copyright holders at
17
+ * https://www.bettercorp.dev. The terms and conditions of the commercial license
18
+ * will be provided upon request.
19
+ *
20
+ * This program is distributed in the hope that it will be useful,
21
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
22
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
+ * GNU Affero General Public License for more details.
24
+ *
25
+ * You should have received a copy of the GNU Affero General Public License
26
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
27
+ */
28
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
29
+ if (k2 === undefined) k2 = k;
30
+ var desc = Object.getOwnPropertyDescriptor(m, k);
31
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
32
+ desc = { enumerable: true, get: function() { return m[k]; } };
33
+ }
34
+ Object.defineProperty(o, k2, desc);
35
+ }) : (function(o, m, k, k2) {
36
+ if (k2 === undefined) k2 = k;
37
+ o[k2] = m[k];
38
+ }));
39
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
40
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
41
+ };
42
+ Object.defineProperty(exports, "__esModule", { value: true });
43
+ exports.generateTimeBasedId = exports.generateAppIdHash = exports.CleanStringStrength = void 0;
44
+ __exportStar(require("./events"), exports);
45
+ __exportStar(require("./logging"), exports);
46
+ __exportStar(require("./plugins"), exports);
47
+ __exportStar(require("./service"), exports);
48
+ __exportStar(require("./metrics"), exports);
49
+ __exportStar(require("./result"), exports);
50
+ __exportStar(require("./options"), exports);
51
+ __exportStar(require("./schema-events"), exports);
52
+ __exportStar(require("./schema-types"), exports);
53
+ __exportStar(require("./observable"), exports);
54
+ __exportStar(require("./observable-types"), exports);
55
+ var tools_1 = require("./tools");
56
+ Object.defineProperty(exports, "CleanStringStrength", { enumerable: true, get: function () { return tools_1.CleanStringStrength; } });
57
+ Object.defineProperty(exports, "generateAppIdHash", { enumerable: true, get: function () { return tools_1.generateAppIdHash; } });
58
+ Object.defineProperty(exports, "generateTimeBasedId", { enumerable: true, get: function () { return tools_1.generateTimeBasedId; } });
59
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/interfaces/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;;;;;;;;;;;;;;;;;AAEH,2CAAyB;AACzB,4CAA0B;AAC1B,4CAA0B;AAC1B,4CAA0B;AAC1B,4CAA0B;AAC1B,2CAAyB;AACzB,4CAA0B;AAC1B,kDAAgC;AAChC,iDAA+B;AAC/B,+CAA6B;AAC7B,qDAAmC;AACnC,iCAWiB;AAVf,4GAAA,mBAAmB,OAAA;AAQnB,0GAAA,iBAAiB,OAAA;AACjB,4GAAA,mBAAmB,OAAA"}
@@ -0,0 +1,106 @@
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 { BSBError } from "../base";
28
+ import { ParamsFromString } from "./tools";
29
+ import { DTrace } from "./metrics";
30
+ /**
31
+ * The debug mode of the app
32
+ * @see {@link https://bsbcode.dev/languages/nodejs/types/modules.html#module-interfaces_logging | API: interfaces/logging}
33
+ * @example "production" - production mode with no debug
34
+ * @example "production-debug" - production mode with debug
35
+ * @example "development" - development mode with debug
36
+ */
37
+ export type DEBUG_MODE = "production" | "production-debug" | "development";
38
+ export type SafeLogData = string | number | boolean | Array<string | number | boolean> | Object;
39
+ export type UnsafeLogData = {
40
+ value: string | number | boolean | Array<string | number | boolean> | Object;
41
+ safeValue: SafeLogData;
42
+ };
43
+ export type LogMeta<T extends string> = Record<ParamsFromString<T>, UnsafeLogData | SafeLogData>;
44
+ /**
45
+ * If you are going to make an object or something, use LogMeta instead.
46
+ * @see {@link https://bsbcode.dev/languages/nodejs/types/modules.html#module-interfaces_logging | API: interfaces/logging}
47
+ */
48
+ export type SmartLogMeta<T extends string> = ParamsFromString<T> extends never ? [undefined?] : [meta: Record<ParamsFromString<T>, UnsafeLogData | SafeLogData>];
49
+ /**
50
+ * @group Logging
51
+ * @category Plugin Development Tools
52
+ * @see {@link https://bsbcode.dev/languages/nodejs/types/interfaces/IPluginLogging.html | API: IPluginLogging}
53
+ */
54
+ export interface IPluginLogging {
55
+ /**
56
+ * Log an informational message with meta data.
57
+ * @param trace - The trace object.
58
+ * @param message - The message to log.
59
+ * @param meta - The meta data to log.
60
+ * @see {@link https://bsbcode.dev/languages/nodejs/types/interfaces/IPluginLogging.html#info | API: IPluginLogging#info}
61
+ */
62
+ info<T extends string>(trace: DTrace, message: T, ...meta: SmartLogMeta<T>): void;
63
+ /**
64
+ * Log a warning message with meta data.
65
+ * @param trace - The trace object.
66
+ * @param message - The message to log.
67
+ * @param meta - The meta data to log.
68
+ * @see {@link https://bsbcode.dev/languages/nodejs/types/interfaces/IPluginLogging.html#warn | API: IPluginLogging#warn}
69
+ */
70
+ warn<T extends string>(trace: DTrace, message: T, ...meta: SmartLogMeta<T>): void;
71
+ /**
72
+ * Log a debug message with meta data.
73
+ * @param trace - The trace object.
74
+ * @param message - The message to log.
75
+ * @param meta - The meta data to log.
76
+ * @see {@link https://bsbcode.dev/languages/nodejs/types/interfaces/IPluginLogging.html#debug | API: IPluginLogging#debug}
77
+ */
78
+ debug<T extends string>(trace: DTrace, message: T, ...meta: SmartLogMeta<T>): void;
79
+ /**
80
+ * Log an error message with meta data.
81
+ * @param trace - The trace object.
82
+ * @param message - The message to log.
83
+ * @param meta - The meta data to log.
84
+ * @see {@link https://bsbcode.dev/languages/nodejs/types/interfaces/IPluginLogging.html#error | API: IPluginLogging#error}
85
+ */
86
+ error<T extends string>(trace: DTrace, message: T, ...meta: SmartLogMeta<T>): void;
87
+ /**
88
+ * Log an error message with meta data.
89
+ * @param error - The error to log.
90
+ * @see {@link https://bsbcode.dev/languages/nodejs/types/interfaces/IPluginLogging.html#error | API: IPluginLogging#error}
91
+ */
92
+ error<T extends string>(error: BSBError<T>): void;
93
+ }
94
+ /**
95
+ * @hidden
96
+ */
97
+ export declare const LoggingEventTypesBase: {
98
+ readonly debug: "debug";
99
+ readonly info: "info";
100
+ readonly warn: "warn";
101
+ readonly error: "error";
102
+ };
103
+ /**
104
+ * @hidden
105
+ */
106
+ export type LoggingEventTypes = (typeof LoggingEventTypesBase)[keyof typeof LoggingEventTypesBase];
@@ -0,0 +1,39 @@
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.LoggingEventTypesBase = void 0;
30
+ /**
31
+ * @hidden
32
+ */
33
+ exports.LoggingEventTypesBase = {
34
+ debug: "debug",
35
+ info: "info",
36
+ warn: "warn",
37
+ error: "error",
38
+ };
39
+ //# sourceMappingURL=logging.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logging.js","sourceRoot":"","sources":["../../src/interfaces/logging.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;;;AA6FH;;GAEG;AACU,QAAA,qBAAqB,GAAG;IACnC,KAAK,EAAE,OAAO;IACd,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE,OAAO;CACN,CAAC"}