@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,581 @@
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.bsb = void 0;
30
+ exports.optional = optional;
31
+ exports.nullable = nullable;
32
+ exports.bsbToJsonSchema = bsbToJsonSchema;
33
+ exports.bsbToZod = bsbToZod;
34
+ const zod_1 = require("zod");
35
+ // ============================================================================
36
+ // Builder API - Fluent Interface for Creating BSB Types
37
+ // ============================================================================
38
+ /**
39
+ * BSB type builder providing a fluent API for creating cross-language type definitions.
40
+ *
41
+ * @example
42
+ * ```typescript
43
+ * import { bsb, optional } from '@bsb/base';
44
+ *
45
+ * const UserSchema = bsb.object({
46
+ * id: bsb.uuid('User unique identifier'),
47
+ * name: bsb.string({ min: 1, max: 100, description: 'User full name' }),
48
+ * email: bsb.string({ description: 'User email address' }),
49
+ * age: optional(bsb.int32({ min: 0, max: 150, description: 'User age' })),
50
+ * });
51
+ * ```
52
+ */
53
+ exports.bsb = {
54
+ /**
55
+ * Create a string type with optional constraints.
56
+ */
57
+ string(options) {
58
+ return {
59
+ _bsb: 'string',
60
+ minLength: options?.min,
61
+ maxLength: options?.max,
62
+ pattern: options?.pattern,
63
+ description: options?.description,
64
+ };
65
+ },
66
+ /**
67
+ * Create a UUID string type (RFC 4122).
68
+ *
69
+ * Format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
70
+ *
71
+ * Language mappings:
72
+ * - JavaScript/TypeScript: string
73
+ * - C#: Guid
74
+ * - Go: uuid.UUID
75
+ * - Java: UUID
76
+ */
77
+ uuid(description) {
78
+ return {
79
+ _bsb: 'string',
80
+ format: 'uuid',
81
+ description,
82
+ };
83
+ },
84
+ /**
85
+ * Create an ISO 8601 datetime string type.
86
+ *
87
+ * Format: 2024-01-01T12:00:00Z
88
+ *
89
+ * Language mappings:
90
+ * - JavaScript/TypeScript: Date | string
91
+ * - C#: DateTime
92
+ * - Go: time.Time
93
+ * - Java: Instant
94
+ */
95
+ datetime(description) {
96
+ return {
97
+ _bsb: 'string',
98
+ format: 'datetime',
99
+ description,
100
+ };
101
+ },
102
+ /**
103
+ * Create an email address string type.
104
+ */
105
+ email(description) {
106
+ return {
107
+ _bsb: 'string',
108
+ format: 'email',
109
+ description,
110
+ };
111
+ },
112
+ /**
113
+ * Create a URI string type.
114
+ */
115
+ uri(description) {
116
+ return {
117
+ _bsb: 'string',
118
+ format: 'uri',
119
+ description,
120
+ };
121
+ },
122
+ /**
123
+ * Create a URL string type.
124
+ */
125
+ url(description) {
126
+ return {
127
+ _bsb: 'string',
128
+ format: 'url',
129
+ description,
130
+ };
131
+ },
132
+ /**
133
+ * Create a 32-bit signed integer type.
134
+ *
135
+ * Range: -2,147,483,648 to 2,147,483,647
136
+ *
137
+ * Language mappings:
138
+ * - JavaScript/TypeScript: number
139
+ * - C#: int
140
+ * - Go: int32
141
+ * - Java: int
142
+ */
143
+ int32(options) {
144
+ return {
145
+ _bsb: 'number',
146
+ numberType: 'int32',
147
+ min: options?.min ?? -2147483648,
148
+ max: options?.max ?? 2147483647,
149
+ description: options?.description,
150
+ };
151
+ },
152
+ /**
153
+ * Create a 64-bit signed integer type.
154
+ *
155
+ * Range: -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
156
+ *
157
+ * Note: JavaScript can only safely represent integers up to 2^53.
158
+ *
159
+ * Language mappings:
160
+ * - JavaScript/TypeScript: number
161
+ * - C#: long
162
+ * - Go: int64
163
+ * - Java: long
164
+ */
165
+ int64(options) {
166
+ return {
167
+ _bsb: 'number',
168
+ numberType: 'int64',
169
+ min: options?.min,
170
+ max: options?.max,
171
+ description: options?.description,
172
+ };
173
+ },
174
+ /**
175
+ * Create a 32-bit floating point number type.
176
+ *
177
+ * Language mappings:
178
+ * - JavaScript/TypeScript: number
179
+ * - C#: float
180
+ * - Go: float32
181
+ * - Java: float
182
+ */
183
+ float(options) {
184
+ return {
185
+ _bsb: 'number',
186
+ numberType: 'float',
187
+ min: options?.min,
188
+ max: options?.max,
189
+ description: options?.description,
190
+ };
191
+ },
192
+ /**
193
+ * Create a 64-bit floating point number type.
194
+ *
195
+ * Language mappings:
196
+ * - JavaScript/TypeScript: number
197
+ * - C#: double
198
+ * - Go: float64
199
+ * - Java: double
200
+ */
201
+ double(options) {
202
+ return {
203
+ _bsb: 'number',
204
+ numberType: 'double',
205
+ min: options?.min,
206
+ max: options?.max,
207
+ description: options?.description,
208
+ };
209
+ },
210
+ /**
211
+ * Create a boolean type.
212
+ *
213
+ * Language mappings:
214
+ * - JavaScript/TypeScript: boolean
215
+ * - C#: bool
216
+ * - Go: bool
217
+ * - Java: boolean
218
+ */
219
+ boolean(description) {
220
+ return {
221
+ _bsb: 'boolean',
222
+ description,
223
+ };
224
+ },
225
+ /**
226
+ * Create a bytes type for binary data.
227
+ * Maps to:
228
+ * - JavaScript/TypeScript: Uint8Array or Buffer
229
+ * - C#: byte[]
230
+ * - Go: []byte
231
+ * - Java: byte[]
232
+ * - Python: bytes
233
+ */
234
+ bytes(description) {
235
+ return {
236
+ _bsb: 'bytes',
237
+ description,
238
+ };
239
+ },
240
+ /**
241
+ * Create an array type with element type and optional size constraints.
242
+ *
243
+ * @example
244
+ * ```typescript
245
+ * const TagsSchema = bsb.array(
246
+ * bsb.string({ max: 50 }),
247
+ * { min: 1, max: 10, description: 'List of tags' }
248
+ * );
249
+ * ```
250
+ */
251
+ array(items, options) {
252
+ return {
253
+ _bsb: 'array',
254
+ items,
255
+ minItems: options?.min,
256
+ maxItems: options?.max,
257
+ description: options?.description,
258
+ };
259
+ },
260
+ /**
261
+ * Create an object type with named properties.
262
+ *
263
+ * Required fields are automatically determined based on the optional flag.
264
+ *
265
+ * @example
266
+ * ```typescript
267
+ * const UserSchema = bsb.object({
268
+ * id: bsb.uuid('User ID'),
269
+ * name: bsb.string({ min: 1, max: 100, description: 'Full name' }),
270
+ * email: optional(bsb.email('Email address')),
271
+ * }, 'User object');
272
+ * ```
273
+ */
274
+ object(properties, description) {
275
+ // Compute required fields (non-optional)
276
+ const required = Object.keys(properties).filter((key) => properties[key].optional !== true);
277
+ return {
278
+ _bsb: 'object',
279
+ properties,
280
+ required,
281
+ description,
282
+ };
283
+ },
284
+ /**
285
+ * Create an enum type with fixed string values.
286
+ *
287
+ * @example
288
+ * ```typescript
289
+ * const StatusSchema = bsb.enum(
290
+ * ['pending', 'in-progress', 'completed', 'failed'],
291
+ * 'Task status'
292
+ * );
293
+ * ```
294
+ */
295
+ enum(values, description) {
296
+ return {
297
+ _bsb: 'enum',
298
+ values: [...values],
299
+ description,
300
+ };
301
+ },
302
+ /**
303
+ * Create a union type representing one of multiple possible types.
304
+ *
305
+ * @example
306
+ * ```typescript
307
+ * const IdSchema = bsb.union([
308
+ * bsb.uuid('UUID identifier'),
309
+ * bsb.int32({ description: 'Numeric identifier' }),
310
+ * ], 'Flexible identifier');
311
+ * ```
312
+ */
313
+ union(types, description) {
314
+ return {
315
+ _bsb: 'union',
316
+ types,
317
+ description,
318
+ };
319
+ },
320
+ /**
321
+ * Create a generic number type (defaults to double for floating point).
322
+ * This is a convenience wrapper for double().
323
+ */
324
+ number(options) {
325
+ return this.double(options);
326
+ },
327
+ /**
328
+ * Create a void type for functions that don't return a value.
329
+ */
330
+ void() {
331
+ return this.union([], 'void');
332
+ },
333
+ /**
334
+ * Create an unknown type for dynamic/any data.
335
+ */
336
+ unknown(description) {
337
+ return this.union([], description || 'unknown');
338
+ },
339
+ /**
340
+ * Create a record/map type with string keys and a value type.
341
+ */
342
+ record(keyType, valueType, description) {
343
+ // Records are represented as objects with dynamic properties
344
+ // For now, we'll use a union as a placeholder
345
+ return this.union([valueType], description || 'record');
346
+ },
347
+ };
348
+ // ============================================================================
349
+ // Type Modifiers
350
+ // ============================================================================
351
+ /**
352
+ * Mark a type as optional.
353
+ * Optional fields are not required in object schemas.
354
+ *
355
+ * @example
356
+ * ```typescript
357
+ * const UserSchema = bsb.object({
358
+ * name: bsb.string(), // Required
359
+ * bio: optional(bsb.string()), // Optional
360
+ * });
361
+ * ```
362
+ */
363
+ function optional(type) {
364
+ return { ...type, optional: true };
365
+ }
366
+ /**
367
+ * Mark a type as nullable.
368
+ * Nullable fields can have null values in addition to their defined type.
369
+ *
370
+ * @example
371
+ * ```typescript
372
+ * const UserSchema = bsb.object({
373
+ * lastLogin: nullable(bsb.datetime('Last login time')),
374
+ * });
375
+ * ```
376
+ */
377
+ function nullable(type) {
378
+ return { ...type, nullable: true };
379
+ }
380
+ // ============================================================================
381
+ // JSON Schema Conversion
382
+ // ============================================================================
383
+ /**
384
+ * Convert BSB type to JSON Schema format.
385
+ * Used for schema export and client code generation.
386
+ */
387
+ function bsbToJsonSchema(type) {
388
+ const base = {};
389
+ if (type.description)
390
+ base.description = type.description;
391
+ switch (type._bsb) {
392
+ case 'string': {
393
+ const schema = { ...base, type: 'string' };
394
+ if (type.format)
395
+ schema.format = type.format;
396
+ if (type.minLength !== undefined)
397
+ schema.minLength = type.minLength;
398
+ if (type.maxLength !== undefined)
399
+ schema.maxLength = type.maxLength;
400
+ if (type.pattern)
401
+ schema.pattern = type.pattern;
402
+ return schema;
403
+ }
404
+ case 'number': {
405
+ const isInteger = type.numberType === 'int32' || type.numberType === 'int64';
406
+ const schema = {
407
+ ...base,
408
+ type: isInteger ? 'integer' : 'number',
409
+ format: type.numberType,
410
+ };
411
+ if (type.min !== undefined)
412
+ schema.minimum = type.min;
413
+ if (type.max !== undefined)
414
+ schema.maximum = type.max;
415
+ return schema;
416
+ }
417
+ case 'boolean':
418
+ return { ...base, type: 'boolean' };
419
+ case 'bytes':
420
+ return {
421
+ ...base,
422
+ type: 'string',
423
+ contentEncoding: 'base64',
424
+ };
425
+ case 'array': {
426
+ const schema = {
427
+ ...base,
428
+ type: 'array',
429
+ items: bsbToJsonSchema(type.items),
430
+ };
431
+ if (type.minItems !== undefined)
432
+ schema.minItems = type.minItems;
433
+ if (type.maxItems !== undefined)
434
+ schema.maxItems = type.maxItems;
435
+ return schema;
436
+ }
437
+ case 'object': {
438
+ const properties = {};
439
+ for (const [key, value] of Object.entries(type.properties)) {
440
+ properties[key] = bsbToJsonSchema(value);
441
+ }
442
+ return {
443
+ ...base,
444
+ type: 'object',
445
+ properties,
446
+ required: type.required,
447
+ };
448
+ }
449
+ case 'enum':
450
+ return {
451
+ ...base,
452
+ type: 'string',
453
+ enum: type.values,
454
+ };
455
+ case 'union':
456
+ return {
457
+ ...base,
458
+ oneOf: type.types.map(bsbToJsonSchema),
459
+ };
460
+ default:
461
+ throw new Error(`Unknown BSB type: ${type._bsb}`);
462
+ }
463
+ }
464
+ // ============================================================================
465
+ // Runtime Validation (Zod Conversion)
466
+ // ============================================================================
467
+ /**
468
+ * Convert BSB type to Zod schema for runtime validation.
469
+ * This is only used in Node.js plugins for runtime validation.
470
+ * Other languages will have their own validation implementations.
471
+ */
472
+ function bsbToZod(type) {
473
+ switch (type._bsb) {
474
+ case 'string': {
475
+ let schema = zod_1.z.string();
476
+ if (type.format === 'uuid')
477
+ schema = schema.uuid();
478
+ if (type.format === 'datetime')
479
+ schema = schema.datetime();
480
+ if (type.format === 'email')
481
+ schema = schema.email();
482
+ if (type.format === 'uri' || type.format === 'url')
483
+ schema = schema.url();
484
+ if (type.minLength !== undefined)
485
+ schema = schema.min(type.minLength);
486
+ if (type.maxLength !== undefined)
487
+ schema = schema.max(type.maxLength);
488
+ if (type.pattern)
489
+ schema = schema.regex(new RegExp(type.pattern));
490
+ if (type.optional)
491
+ return schema.optional();
492
+ if (type.nullable)
493
+ return schema.nullable();
494
+ return schema;
495
+ }
496
+ case 'number': {
497
+ let schema = zod_1.z.number();
498
+ if (type.numberType === 'int32' || type.numberType === 'int64') {
499
+ schema = schema.int();
500
+ }
501
+ if (type.min !== undefined)
502
+ schema = schema.min(type.min);
503
+ if (type.max !== undefined)
504
+ schema = schema.max(type.max);
505
+ if (type.optional)
506
+ return schema.optional();
507
+ if (type.nullable)
508
+ return schema.nullable();
509
+ return schema;
510
+ }
511
+ case 'boolean': {
512
+ let schema = zod_1.z.boolean();
513
+ if (type.optional)
514
+ return schema.optional();
515
+ if (type.nullable)
516
+ return schema.nullable();
517
+ return schema;
518
+ }
519
+ case 'bytes': {
520
+ let schema = zod_1.z.instanceof(Uint8Array);
521
+ if (type.optional)
522
+ return schema.optional();
523
+ if (type.nullable)
524
+ return schema.nullable();
525
+ return schema;
526
+ }
527
+ case 'array': {
528
+ let schema = zod_1.z.array(bsbToZod(type.items));
529
+ if (type.minItems !== undefined)
530
+ schema = schema.min(type.minItems);
531
+ if (type.maxItems !== undefined)
532
+ schema = schema.max(type.maxItems);
533
+ if (type.optional)
534
+ return schema.optional();
535
+ if (type.nullable)
536
+ return schema.nullable();
537
+ return schema;
538
+ }
539
+ case 'object': {
540
+ const shape = {};
541
+ for (const [key, value] of Object.entries(type.properties)) {
542
+ shape[key] = bsbToZod(value);
543
+ }
544
+ let schema = zod_1.z.object(shape);
545
+ if (type.optional)
546
+ return schema.optional();
547
+ if (type.nullable)
548
+ return schema.nullable();
549
+ return schema;
550
+ }
551
+ case 'enum': {
552
+ let schema = zod_1.z.enum(type.values);
553
+ if (type.optional)
554
+ return schema.optional();
555
+ if (type.nullable)
556
+ return schema.nullable();
557
+ return schema;
558
+ }
559
+ case 'union': {
560
+ // Empty union = unknown/any type (used by bsb.unknown() and bsb.void())
561
+ if (type.types.length === 0) {
562
+ let schema = zod_1.z.unknown();
563
+ if (type.optional)
564
+ return schema.optional();
565
+ if (type.nullable)
566
+ return schema.nullable();
567
+ return schema;
568
+ }
569
+ const schemas = type.types.map(bsbToZod);
570
+ let schema = zod_1.z.union(schemas);
571
+ if (type.optional)
572
+ return schema.optional();
573
+ if (type.nullable)
574
+ return schema.nullable();
575
+ return schema;
576
+ }
577
+ default:
578
+ throw new Error(`Unknown BSB type: ${type._bsb}`);
579
+ }
580
+ }
581
+ //# sourceMappingURL=schema-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema-types.js","sourceRoot":"","sources":["../../src/interfaces/schema-types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;;;AAigBH,4BAEC;AAaD,4BAEC;AA0DD,0CA4EC;AAWD,4BAuFC;AAxvBD,6BAAwB;AA0GxB,+EAA+E;AAC/E,wDAAwD;AACxD,+EAA+E;AAE/E;;;;;;;;;;;;;;GAcG;AACU,QAAA,GAAG,GAAG;IACjB;;OAEG;IACH,MAAM,CAAC,OAKN;QACC,OAAO;YACL,IAAI,EAAE,QAAQ;YACd,SAAS,EAAE,OAAO,EAAE,GAAG;YACvB,SAAS,EAAE,OAAO,EAAE,GAAG;YACvB,OAAO,EAAE,OAAO,EAAE,OAAO;YACzB,WAAW,EAAE,OAAO,EAAE,WAAW;SAClC,CAAC;IACJ,CAAC;IAED;;;;;;;;;;OAUG;IACH,IAAI,CAAC,WAAoB;QACvB,OAAO;YACL,IAAI,EAAE,QAAQ;YACd,MAAM,EAAE,MAAM;YACd,WAAW;SACZ,CAAC;IACJ,CAAC;IAED;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,WAAoB;QAC3B,OAAO;YACL,IAAI,EAAE,QAAQ;YACd,MAAM,EAAE,UAAU;YAClB,WAAW;SACZ,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,WAAoB;QACxB,OAAO;YACL,IAAI,EAAE,QAAQ;YACd,MAAM,EAAE,OAAO;YACf,WAAW;SACZ,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,GAAG,CAAC,WAAoB;QACtB,OAAO;YACL,IAAI,EAAE,QAAQ;YACd,MAAM,EAAE,KAAK;YACb,WAAW;SACZ,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,GAAG,CAAC,WAAoB;QACtB,OAAO;YACL,IAAI,E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,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YACzC,IAAI,MAAM,GAAG,OAAC,CAAC,KAAK,CAAC,OAAc,CAAC,CAAC;YACrC,IAAI,IAAI,CAAC,QAAQ;gBAAE,OAAO,MAAM,CAAC,QAAQ,EAAE,CAAC;YAC5C,IAAI,IAAI,CAAC,QAAQ;gBAAE,OAAO,MAAM,CAAC,QAAQ,EAAE,CAAC;YAC5C,OAAO,MAAM,CAAC;QAChB,CAAC;QAED;YACE,MAAM,IAAI,KAAK,CAAC,qBAAsB,IAAY,CAAC,IAAI,EAAE,CAAC,CAAC;IAC/D,CAAC;AACH,CAAC"}
@@ -0,0 +1,48 @@
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
+ /**
29
+ * Base interface for service events
30
+ * @see {@link https://bsbcode.dev/languages/nodejs/types/interfaces/ServiceEventsBase.html | API: ServiceEventsBase}
31
+ */
32
+ export interface ServiceEventsBase {
33
+ [key: string]: (...args: any[]) => Promise<any> | any;
34
+ }
35
+ /**
36
+ * Base interface for callable service events
37
+ * @see {@link https://bsbcode.dev/languages/nodejs/types/interfaces/ServiceEventsCallableBase.html | API: ServiceEventsCallableBase}
38
+ */
39
+ export interface ServiceEventsCallableBase {
40
+ [key: string]: (trace: DTrace, ...args: any[]) => Promise<any> | any;
41
+ }
42
+ /**
43
+ * Default service events interface
44
+ * @see {@link https://bsbcode.dev/languages/nodejs/types/interfaces/ServiceEventsDefault.html | API: ServiceEventsDefault}
45
+ */
46
+ export interface ServiceEventsDefault {
47
+ [key: string]: () => never;
48
+ }
@@ -0,0 +1,29 @@
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
+ //# sourceMappingURL=service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.js","sourceRoot":"","sources":["../../src/interfaces/service.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG"}