@bsb/base 9.0.4 → 9.1.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/lib/base/BSBConfig.d.ts +3 -3
- package/lib/base/BSBConfig.js +9 -14
- package/lib/base/BSBConfig.js.map +1 -1
- package/lib/base/BSBEvents.d.ts +3 -3
- package/lib/base/BSBEvents.js +12 -17
- package/lib/base/BSBEvents.js.map +1 -1
- package/lib/base/BSBObservable.d.ts +4 -4
- package/lib/base/BSBObservable.js +17 -22
- package/lib/base/BSBObservable.js.map +1 -1
- package/lib/base/BSBService.d.ts +7 -8
- package/lib/base/BSBService.js +17 -22
- package/lib/base/BSBService.js.map +1 -1
- package/lib/base/BSBServiceClient.d.ts +4 -4
- package/lib/base/BSBServiceClient.js +12 -18
- package/lib/base/BSBServiceClient.js.map +1 -1
- package/lib/base/EventValidator.d.ts +16 -17
- package/lib/base/EventValidator.js +13 -34
- package/lib/base/EventValidator.js.map +1 -1
- package/lib/base/ObservableBackend.d.ts +2 -2
- package/lib/base/ObservableBackend.js +21 -26
- package/lib/base/ObservableBackend.js.map +1 -1
- package/lib/base/PluginConfig.d.ts +9 -7
- package/lib/base/PluginConfig.js +4 -11
- package/lib/base/PluginConfig.js.map +1 -1
- package/lib/base/PluginEvents.d.ts +4 -4
- package/lib/base/PluginEvents.js +4 -9
- package/lib/base/PluginEvents.js.map +1 -1
- package/lib/base/PluginObservable.d.ts +13 -14
- package/lib/base/PluginObservable.js +4 -8
- package/lib/base/PluginObservable.js.map +1 -1
- package/lib/base/ResourceContext.d.ts +1 -1
- package/lib/base/ResourceContext.js +1 -5
- package/lib/base/ResourceContext.js.map +1 -1
- package/lib/base/base.d.ts +3 -3
- package/lib/base/base.js +10 -18
- package/lib/base/base.js.map +1 -1
- package/lib/base/errorMessages.d.ts +1 -1
- package/lib/base/errorMessages.js +6 -11
- package/lib/base/errorMessages.js.map +1 -1
- package/lib/base/factory.d.ts +1 -1
- package/lib/base/factory.js +19 -22
- package/lib/base/factory.js.map +1 -1
- package/lib/base/functions.d.ts +19 -14
- package/lib/base/functions.js +19 -26
- package/lib/base/functions.js.map +1 -1
- package/lib/base/index.d.ts +18 -18
- package/lib/base/index.js +18 -37
- package/lib/base/index.js.map +1 -1
- package/lib/base/logFormatter.d.ts +1 -1
- package/lib/base/logFormatter.js +10 -14
- package/lib/base/logFormatter.js.map +1 -1
- package/lib/base/module-runtime.d.ts +3 -0
- package/lib/base/module-runtime.js +15 -0
- package/lib/base/module-runtime.js.map +1 -0
- package/lib/base/tools.d.ts +1 -1
- package/lib/base/tools.js +9 -13
- package/lib/base/tools.js.map +1 -1
- package/lib/cli.js +13 -12
- package/lib/cli.js.map +1 -1
- package/lib/dev.js +22 -11
- package/lib/dev.js.map +1 -1
- package/lib/index.d.ts +3 -3
- package/lib/index.js +3 -19
- package/lib/index.js.map +1 -1
- package/lib/interfaces/events.d.ts +2 -2
- package/lib/interfaces/events.js +1 -4
- package/lib/interfaces/events.js.map +1 -1
- package/lib/interfaces/index.d.ts +13 -12
- package/lib/interfaces/index.js +12 -32
- package/lib/interfaces/index.js.map +1 -1
- package/lib/interfaces/logging.d.ts +3 -3
- package/lib/interfaces/logging.js +1 -4
- package/lib/interfaces/logging.js.map +1 -1
- package/lib/interfaces/metrics.d.ts +2 -2
- package/lib/interfaces/metrics.js +1 -5
- package/lib/interfaces/metrics.js.map +1 -1
- package/lib/interfaces/observable-types.d.ts +1 -1
- package/lib/interfaces/observable-types.js +1 -4
- package/lib/interfaces/observable-types.js.map +1 -1
- package/lib/interfaces/observable.d.ts +8 -9
- package/lib/interfaces/observable.js +1 -2
- package/lib/interfaces/observable.js.map +1 -1
- package/lib/interfaces/options.d.ts +15 -6
- package/lib/interfaces/options.js +2 -5
- package/lib/interfaces/options.js.map +1 -1
- package/lib/interfaces/plugins.d.ts +2 -2
- package/lib/interfaces/plugins.js +1 -4
- package/lib/interfaces/plugins.js.map +1 -1
- package/lib/interfaces/result.js +8 -18
- package/lib/interfaces/result.js.map +1 -1
- package/lib/interfaces/schema-events.d.ts +5 -20
- package/lib/interfaces/schema-events.js +7 -14
- package/lib/interfaces/schema-events.js.map +1 -1
- package/lib/interfaces/schema-types.d.ts +32 -352
- package/lib/interfaces/schema-types.js +77 -512
- package/lib/interfaces/schema-types.js.map +1 -1
- package/lib/interfaces/service.d.ts +1 -1
- package/lib/interfaces/service.js +1 -2
- package/lib/interfaces/service.js.map +1 -1
- package/lib/interfaces/tools.js +8 -13
- package/lib/interfaces/tools.js.map +1 -1
- package/lib/plugins/config-default/index.d.ts +16 -14
- package/lib/plugins/config-default/index.js +66 -50
- package/lib/plugins/config-default/index.js.map +1 -1
- package/lib/plugins/config-default/interfaces.d.ts +1 -1
- package/lib/plugins/config-default/interfaces.js +1 -2
- package/lib/plugins/config-default/interfaces.js.map +1 -1
- package/lib/plugins/events-default/events/broadcast.d.ts +1 -1
- package/lib/plugins/events-default/events/broadcast.js +2 -6
- package/lib/plugins/events-default/events/broadcast.js.map +1 -1
- package/lib/plugins/events-default/events/emit.d.ts +1 -1
- package/lib/plugins/events-default/events/emit.js +4 -8
- package/lib/plugins/events-default/events/emit.js.map +1 -1
- package/lib/plugins/events-default/events/emitAndReturn.d.ts +1 -1
- package/lib/plugins/events-default/events/emitAndReturn.js +4 -8
- package/lib/plugins/events-default/events/emitAndReturn.js.map +1 -1
- package/lib/plugins/events-default/events/emitStreamAndReceiveStream.d.ts +1 -1
- package/lib/plugins/events-default/events/emitStreamAndReceiveStream.js +8 -12
- package/lib/plugins/events-default/events/emitStreamAndReceiveStream.js.map +1 -1
- package/lib/plugins/events-default/events/index.d.ts +4 -4
- package/lib/plugins/events-default/events/index.js +4 -11
- package/lib/plugins/events-default/events/index.js.map +1 -1
- package/lib/plugins/events-default/index.d.ts +5 -5
- package/lib/plugins/events-default/index.js +10 -15
- package/lib/plugins/events-default/index.js.map +1 -1
- package/lib/plugins/observable-default/index.d.ts +5 -5
- package/lib/plugins/observable-default/index.js +8 -13
- package/lib/plugins/observable-default/index.js.map +1 -1
- package/lib/plugins/service-benchmarkify/index.d.ts +196 -0
- package/lib/plugins/service-benchmarkify/index.js +133 -0
- package/lib/plugins/service-benchmarkify/index.js.map +1 -0
- package/lib/plugins/service-default0/index.d.ts +189 -0
- package/lib/plugins/service-default0/index.js +113 -0
- package/lib/plugins/service-default0/index.js.map +1 -0
- package/lib/{tests/sb/plugins/events/emitStreamAndReceiveStream.d.ts → plugins/service-default1/client.d.ts} +16 -4
- package/lib/plugins/service-default1/client.js +66 -0
- package/lib/plugins/service-default1/client.js.map +1 -0
- package/lib/plugins/service-default1/index.d.ts +202 -0
- package/lib/plugins/service-default1/index.js +174 -0
- package/lib/plugins/service-default1/index.js.map +1 -0
- package/lib/plugins/service-default2/index.d.ts +217 -0
- package/lib/plugins/service-default2/index.js +132 -0
- package/lib/plugins/service-default2/index.js.map +1 -0
- package/lib/plugins/service-default3/index.d.ts +91 -0
- package/lib/plugins/service-default3/index.js +83 -0
- package/lib/plugins/service-default3/index.js.map +1 -0
- package/lib/plugins/service-default4/index.d.ts +67 -0
- package/lib/{tests.js → plugins/service-default4/index.js} +31 -17
- package/lib/plugins/service-default4/index.js.map +1 -0
- package/lib/schemas/config-default.json +24 -16
- package/lib/schemas/config-default.plugin.json +24 -16
- package/lib/schemas/events-default.json +1 -1
- package/lib/schemas/events-default.plugin.json +1 -1
- package/lib/schemas/observable-default.json +15 -5
- package/lib/schemas/observable-default.plugin.json +15 -5
- package/lib/schemas/service-benchmarkify.json +314 -0
- package/lib/schemas/service-default0.json +279 -0
- package/lib/schemas/service-default1.json +327 -0
- package/lib/schemas/service-default2.json +355 -0
- package/lib/schemas/service-default3.json +107 -0
- package/lib/schemas/service-default4.json +63 -0
- package/lib/scripts/bsb-client-cli.js +9 -9
- package/lib/scripts/bsb-client-cli.js.map +1 -1
- package/lib/scripts/bsb-plugin-cli.js +93 -64
- package/lib/scripts/bsb-plugin-cli.js.map +1 -1
- package/lib/scripts/export-schemas.js +15 -12
- package/lib/scripts/export-schemas.js.map +1 -1
- package/lib/scripts/extract-schemas-from-source.js +73 -56
- package/lib/scripts/extract-schemas-from-source.js.map +1 -1
- package/lib/scripts/generate-client-types.d.ts +1 -16
- package/lib/scripts/generate-client-types.js +120 -313
- package/lib/scripts/generate-client-types.js.map +1 -1
- package/lib/scripts/generate-plugin-json.js +9 -10
- package/lib/scripts/generate-plugin-json.js.map +1 -1
- package/lib/serviceBase/config.d.ts +4 -4
- package/lib/serviceBase/config.js +33 -35
- package/lib/serviceBase/config.js.map +1 -1
- package/lib/serviceBase/events.d.ts +6 -6
- package/lib/serviceBase/events.js +42 -44
- package/lib/serviceBase/events.js.map +1 -1
- package/lib/serviceBase/index.d.ts +7 -7
- package/lib/serviceBase/index.js +7 -23
- package/lib/serviceBase/index.js.map +1 -1
- package/lib/serviceBase/observable.d.ts +5 -5
- package/lib/serviceBase/observable.js +21 -25
- package/lib/serviceBase/observable.js.map +1 -1
- package/lib/serviceBase/plugins.d.ts +3 -3
- package/lib/serviceBase/plugins.js +48 -54
- package/lib/serviceBase/plugins.js.map +1 -1
- package/lib/serviceBase/serviceBase.d.ts +3 -3
- package/lib/serviceBase/serviceBase.js +40 -44
- package/lib/serviceBase/serviceBase.js.map +1 -1
- package/lib/serviceBase/services.d.ts +6 -6
- package/lib/serviceBase/services.js +21 -22
- package/lib/serviceBase/services.js.map +1 -1
- package/package.json +18 -11
- package/lib/tests/mocks.d.ts +0 -37
- package/lib/tests/mocks.js +0 -164
- package/lib/tests/mocks.js.map +0 -1
- package/lib/tests/sb/plugins/events/broadcast.d.ts +0 -30
- package/lib/tests/sb/plugins/events/broadcast.js +0 -357
- package/lib/tests/sb/plugins/events/broadcast.js.map +0 -1
- package/lib/tests/sb/plugins/events/emit.d.ts +0 -30
- package/lib/tests/sb/plugins/events/emit.js +0 -353
- package/lib/tests/sb/plugins/events/emit.js.map +0 -1
- package/lib/tests/sb/plugins/events/emitAndReturn.d.ts +0 -30
- package/lib/tests/sb/plugins/events/emitAndReturn.js +0 -382
- package/lib/tests/sb/plugins/events/emitAndReturn.js.map +0 -1
- package/lib/tests/sb/plugins/events/emitStreamAndReceiveStream.js +0 -298
- package/lib/tests/sb/plugins/events/emitStreamAndReceiveStream.js.map +0 -1
- package/lib/tests/sb/plugins/events/index.d.ts +0 -28
- package/lib/tests/sb/plugins/events/index.js +0 -69
- package/lib/tests/sb/plugins/events/index.js.map +0 -1
- package/lib/tests/trace.d.ts +0 -41
- package/lib/tests/trace.js +0 -85
- package/lib/tests/trace.js.map +0 -1
- package/lib/tests.d.ts +0 -27
- package/lib/tests.js.map +0 -1
|
@@ -0,0 +1,132 @@
|
|
|
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 { ServiceClient } from "../../index.js";
|
|
28
|
+
import { BSBService, createConfigSchema, bsb, optional } from "../../base/index.js";
|
|
29
|
+
import { Plugin as Service1 } from "../service-default1/index.js";
|
|
30
|
+
import { Plugin as Service3 } from "../service-default3/index.js";
|
|
31
|
+
import { createEventSchemas, createFireAndForgetEvent, createReturnableEvent, createBroadcastEvent } from "../../interfaces/schema-events.js";
|
|
32
|
+
import * as av from "@anyvali/js";
|
|
33
|
+
export const Config = createConfigSchema({
|
|
34
|
+
name: 'service-default2',
|
|
35
|
+
description: 'Default service plugin 2 for testing inter-service communication',
|
|
36
|
+
image: '../docs/public/assets/images/bsb-logo.png',
|
|
37
|
+
tags: ['default', 'example', 'test'],
|
|
38
|
+
}, av.optional(av.object({}, { unknownKeys: "strip" })).default({}));
|
|
39
|
+
export const EventSchemas = createEventSchemas({
|
|
40
|
+
// Events this service emits (fire-and-forget, first listener receives)
|
|
41
|
+
emitEvents: {
|
|
42
|
+
'task.completed': createFireAndForgetEvent(bsb.object({
|
|
43
|
+
taskId: bsb.string({ description: 'Task identifier' }),
|
|
44
|
+
duration: bsb.number({ description: 'Task duration in milliseconds' }),
|
|
45
|
+
success: bsb.boolean('Whether the task completed successfully')
|
|
46
|
+
}, 'Task completion parameters'), 'Emitted when a task is completed')
|
|
47
|
+
},
|
|
48
|
+
// Events this service listens to (fire-and-forget)
|
|
49
|
+
onEvents: {
|
|
50
|
+
'task.assigned': createFireAndForgetEvent(bsb.object({
|
|
51
|
+
taskId: bsb.string({ description: 'Task identifier' }),
|
|
52
|
+
type: bsb.string({ description: 'Task type' }),
|
|
53
|
+
priority: bsb.enum(['low', 'medium', 'high', 'urgent'], 'Task priority level')
|
|
54
|
+
}, 'Task assignment parameters'), 'Handle new task assignments')
|
|
55
|
+
},
|
|
56
|
+
// Returnable events this service emits (requests from this service)
|
|
57
|
+
emitReturnableEvents: {
|
|
58
|
+
'resource.request': createReturnableEvent(bsb.object({
|
|
59
|
+
resourceType: bsb.string({ description: 'Type of resource requested' }),
|
|
60
|
+
amount: bsb.number({ description: 'Amount of resources needed' }),
|
|
61
|
+
timeout: optional(bsb.number({ description: 'Request timeout in milliseconds' }))
|
|
62
|
+
}, 'Resource request parameters'), bsb.object({
|
|
63
|
+
allocated: bsb.boolean('Whether resources were allocated'),
|
|
64
|
+
resourceId: optional(bsb.string({ description: 'Allocated resource identifier' })),
|
|
65
|
+
waitTime: optional(bsb.number({ description: 'Wait time in milliseconds' }))
|
|
66
|
+
}, 'Resource allocation response'), 'Request resource allocation')
|
|
67
|
+
},
|
|
68
|
+
// Returnable events this service listens to (requests to this service)
|
|
69
|
+
onReturnableEvents: {
|
|
70
|
+
calculate: createReturnableEvent(bsb.object({
|
|
71
|
+
a: bsb.number({ description: 'First number' }),
|
|
72
|
+
b: bsb.number({ description: 'Second number' })
|
|
73
|
+
}, 'Calculate input parameters'), bsb.number({ description: 'Calculation result' }), 'Calculate with two numbers'),
|
|
74
|
+
'health.check': createReturnableEvent(bsb.object({
|
|
75
|
+
includeDetails: bsb.boolean('Whether to include detailed information')
|
|
76
|
+
}, 'Health check parameters'), bsb.object({
|
|
77
|
+
status: bsb.enum(['healthy', 'degraded', 'unhealthy'], 'Service health status'),
|
|
78
|
+
uptime: bsb.number({ description: 'Service uptime in milliseconds' }),
|
|
79
|
+
details: optional(bsb.record(bsb.string({ description: 'Detail key' }), bsb.unknown('Detail value'), 'Health check details'))
|
|
80
|
+
}, 'Health check response'), 'Perform health check')
|
|
81
|
+
},
|
|
82
|
+
// Broadcast events this service emits (all listeners receive)
|
|
83
|
+
emitBroadcast: {
|
|
84
|
+
'metrics.report': createBroadcastEvent(bsb.object({
|
|
85
|
+
timestamp: bsb.datetime('Metrics timestamp'),
|
|
86
|
+
metrics: bsb.record(bsb.string({ description: 'Metric name' }), bsb.number({ description: 'Metric value' }), 'Performance metrics'),
|
|
87
|
+
period: bsb.string({ description: 'Reporting period' })
|
|
88
|
+
}, 'Metrics report parameters'), 'Broadcast performance metrics')
|
|
89
|
+
},
|
|
90
|
+
// Broadcast events this service listens to
|
|
91
|
+
onBroadcast: {
|
|
92
|
+
'emergency.stop': createBroadcastEvent(bsb.object({
|
|
93
|
+
reason: bsb.string({ description: 'Emergency stop reason' }),
|
|
94
|
+
immediate: bsb.boolean('Whether to stop immediately without cleanup')
|
|
95
|
+
}, 'Emergency stop parameters'), 'Listen for emergency stop broadcasts')
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
export class Plugin extends BSBService {
|
|
99
|
+
static Config = Config;
|
|
100
|
+
static EventSchemas = EventSchemas;
|
|
101
|
+
// PLUGIN_CLIENT auto-generated from Config.metadata
|
|
102
|
+
initBeforePlugins;
|
|
103
|
+
runBeforePlugins;
|
|
104
|
+
runAfterPlugins;
|
|
105
|
+
initAfterPlugins = [];
|
|
106
|
+
service1;
|
|
107
|
+
service3;
|
|
108
|
+
constructor(config) {
|
|
109
|
+
super(config);
|
|
110
|
+
this.service1 = new ServiceClient(Service1, this);
|
|
111
|
+
this.service3 = new ServiceClient(Service3, this);
|
|
112
|
+
}
|
|
113
|
+
async init(obs) {
|
|
114
|
+
this.events.onReturnableEvent("calculate", obs, async (obs, input) => {
|
|
115
|
+
obs.log.info("Calculating {a} * {b}", { a: input.a, b: input.b });
|
|
116
|
+
return input.a * input.b;
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
async run(obs) {
|
|
120
|
+
obs.log.info("Running service-default2");
|
|
121
|
+
const result = await this.service1.events.emitEventAndReturn("calculate", obs, {
|
|
122
|
+
a: 5,
|
|
123
|
+
b: 5
|
|
124
|
+
}, 5);
|
|
125
|
+
await this.service3.events.onReturnableEvent("calculate", obs, async (obs, input) => {
|
|
126
|
+
obs.log.info("Calculating {a} * {b}", { a: input.a, b: input.b });
|
|
127
|
+
return input.a * input.b;
|
|
128
|
+
});
|
|
129
|
+
obs.log.info("Calculation result: {result}", { result });
|
|
130
|
+
}
|
|
131
|
+
}
|
|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,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;YAClE,OAAO,KAAK,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC;QAC3B,CAAC,CAAC,CAAC;IACL,CAAC;IAEM,KAAK,CAAC,GAAG,CAAC,GAAe;QAC9B,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC;QACzC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,kBAAkB,CAAC,WAAW,EAAE,GAAG,EAAE;YAC7E,CAAC,EAAE,CAAC;YACJ,CAAC,EAAE,CAAC;SACL,EAAE,CAAC,CAAC,CAAC;QACN,MAAM,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,iBAAiB,CAAC,WAAW,EAAE,GAAG,EAAE,KAAK,EAAE,GAAe,EAAE,KAAK,EAAE,EAAE;YAC9F,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,uBAAuB,EAAE,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;YAClE,OAAO,KAAK,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC;QAC3B,CAAC,CAAC,CAAC;QACH,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,8BAA8B,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;IAC3D,CAAC"}
|
|
@@ -0,0 +1,91 @@
|
|
|
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 * as av from "@anyvali/js";
|
|
28
|
+
import { BSBService, BSBServiceConstructor } from "../../base/index.js";
|
|
29
|
+
import { Observable } from "../../interfaces/index.js";
|
|
30
|
+
export declare const Config: import("../../base/PluginConfig.js").BSBPluginConfigClass<av.OptionalSchema<av.ObjectSchema<{}>>>;
|
|
31
|
+
export declare const EventSchemas: {
|
|
32
|
+
readonly onReturnableEvents: {
|
|
33
|
+
readonly onReverseReturnable: {
|
|
34
|
+
input: av.ObjectSchema<{
|
|
35
|
+
text: av.StringSchema;
|
|
36
|
+
}>;
|
|
37
|
+
output: av.StringSchema;
|
|
38
|
+
description?: string;
|
|
39
|
+
defaultTimeout?: number;
|
|
40
|
+
readonly __brand: "returnable";
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
readonly emitReturnableEvents: {
|
|
44
|
+
readonly calculate: {
|
|
45
|
+
input: av.ObjectSchema<{
|
|
46
|
+
a: import("../../interfaces/schema-types.js").BSBType;
|
|
47
|
+
b: import("../../interfaces/schema-types.js").BSBType;
|
|
48
|
+
}>;
|
|
49
|
+
output: import("../../interfaces/schema-types.js").BSBType;
|
|
50
|
+
description?: string;
|
|
51
|
+
defaultTimeout?: number;
|
|
52
|
+
readonly __brand: "returnable";
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
export declare class Plugin extends BSBService<InstanceType<typeof Config>, typeof EventSchemas> {
|
|
57
|
+
static Config: import("../../base/PluginConfig.js").BSBPluginConfigClass<av.OptionalSchema<av.ObjectSchema<{}>>>;
|
|
58
|
+
static EventSchemas: {
|
|
59
|
+
readonly onReturnableEvents: {
|
|
60
|
+
readonly onReverseReturnable: {
|
|
61
|
+
input: av.ObjectSchema<{
|
|
62
|
+
text: av.StringSchema;
|
|
63
|
+
}>;
|
|
64
|
+
output: av.StringSchema;
|
|
65
|
+
description?: string;
|
|
66
|
+
defaultTimeout?: number;
|
|
67
|
+
readonly __brand: "returnable";
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
readonly emitReturnableEvents: {
|
|
71
|
+
readonly calculate: {
|
|
72
|
+
input: av.ObjectSchema<{
|
|
73
|
+
a: import("../../interfaces/schema-types.js").BSBType;
|
|
74
|
+
b: import("../../interfaces/schema-types.js").BSBType;
|
|
75
|
+
}>;
|
|
76
|
+
output: import("../../interfaces/schema-types.js").BSBType;
|
|
77
|
+
description?: string;
|
|
78
|
+
defaultTimeout?: number;
|
|
79
|
+
readonly __brand: "returnable";
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
initBeforePlugins?: string[] | undefined;
|
|
84
|
+
runBeforePlugins?: string[] | undefined;
|
|
85
|
+
runAfterPlugins?: string[] | undefined;
|
|
86
|
+
initAfterPlugins: string[];
|
|
87
|
+
dispose?(): void;
|
|
88
|
+
constructor(config: BSBServiceConstructor<InstanceType<typeof Config>, typeof EventSchemas>);
|
|
89
|
+
init(obs: Observable): Promise<void>;
|
|
90
|
+
run(obs: Observable): Promise<void>;
|
|
91
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
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 * as av from "@anyvali/js";
|
|
28
|
+
import { BSBService, createConfigSchema, bsb } from "../../base/index.js";
|
|
29
|
+
import { createEventSchemas, createReturnableEvent } from "../../interfaces/schema-events.js";
|
|
30
|
+
export const Config = createConfigSchema({
|
|
31
|
+
name: 'service-default3',
|
|
32
|
+
description: 'Default service plugin 3 for testing',
|
|
33
|
+
image: '../docs/public/assets/images/bsb-logo.png',
|
|
34
|
+
tags: ['default', 'example', 'test'],
|
|
35
|
+
initAfterPlugins: ['service-default2'],
|
|
36
|
+
}, av.optional(av.object({}, { unknownKeys: "strip" })).default({}));
|
|
37
|
+
export const EventSchemas = createEventSchemas({
|
|
38
|
+
onReturnableEvents: {
|
|
39
|
+
onReverseReturnable: createReturnableEvent(bsb.object({
|
|
40
|
+
text: bsb.string({ description: 'Text to reverse' })
|
|
41
|
+
}, 'Reverse input parameters'), bsb.string({ description: 'Reversed text' }), 'Reverse a string')
|
|
42
|
+
},
|
|
43
|
+
emitReturnableEvents: {
|
|
44
|
+
calculate: createReturnableEvent(bsb.object({
|
|
45
|
+
a: bsb.number({ description: 'First number' }),
|
|
46
|
+
b: bsb.number({ description: 'Second number' })
|
|
47
|
+
}, 'Calculate input parameters'), bsb.number({ description: 'Calculation result' }), 'Calculate with two numbers')
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
export class Plugin extends BSBService {
|
|
51
|
+
static Config = Config;
|
|
52
|
+
static EventSchemas = EventSchemas;
|
|
53
|
+
// PLUGIN_CLIENT auto-generated from Config.metadata
|
|
54
|
+
initBeforePlugins;
|
|
55
|
+
runBeforePlugins;
|
|
56
|
+
runAfterPlugins;
|
|
57
|
+
initAfterPlugins = ["service-default2"];
|
|
58
|
+
constructor(config) {
|
|
59
|
+
super(config);
|
|
60
|
+
}
|
|
61
|
+
async init(obs) {
|
|
62
|
+
obs.log.info("Initializing service-default3");
|
|
63
|
+
await this.events.onReturnableEvent("onReverseReturnable", obs, async (obs, input) => {
|
|
64
|
+
obs.log.warn("onReverseReturnable ({text})", { text: input.text });
|
|
65
|
+
return input.text.split("").reverse().join("");
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
async run(obs) {
|
|
69
|
+
obs.log.info("Running service-default3");
|
|
70
|
+
// NEW API: Use events to calculate with object parameter
|
|
71
|
+
const result = await this.events.emitEventAndReturn("calculate", obs, {
|
|
72
|
+
a: 18,
|
|
73
|
+
b: 19
|
|
74
|
+
}, 5 // timeout
|
|
75
|
+
);
|
|
76
|
+
obs.log.info("Calculation result: {result}", { result });
|
|
77
|
+
obs.log.debug("Debug {a}", { a: "IT IS AN DEBUG!" });
|
|
78
|
+
obs.log.info("Info {a}", { a: "IT IS AN INFO!" });
|
|
79
|
+
obs.log.warn("Warning {a}", { a: "IT IS AN WARNING!" });
|
|
80
|
+
obs.log.error("Error {a}", { a: "IT IS AN ERROR!" });
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/plugins/service-default3/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,KAAK,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,EAAE,UAAU,EAAyB,kBAAkB,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAC;AAEjG,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAE9F,MAAM,CAAC,MAAM,MAAM,GAAG,kBAAkB,CACtC;IACE,IAAI,EAAE,kBAAkB;IACxB,WAAW,EAAE,sCAAsC;IACnD,KAAK,EAAE,2CAA2C;IAClD,IAAI,EAAE,CAAC,SAAS,EAAE,SAAS,EAAE,MAAM,CAAC;IACpC,gBAAgB,EAAE,CAAC,kBAAkB,CAAC;CACvC,EACD,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,WAAW,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CACjE,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAG,kBAAkB,CAAC;IAC7C,kBAAkB,EAAE;QAClB,mBAAmB,EAAE,qBAAqB,CACxC,GAAG,CAAC,MAAM,CAAC;YACT,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,iBAAiB,EAAE,CAAC;SACrD,EAAE,0BAA0B,CAAC,EAC9B,GAAG,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,eAAe,EAAE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GAAe;QAC9B,GAAG,CAAC,GAAG,CAAC,IAAI,CAAE,0BAA0B,CAAC,CAAC;QAE1C,yDAAyD;QACzD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,kBAAkB,CACjD,WAAW,EACX,GAAG,EACH;YACE,CAAC,EAAE,EAAE;YACL,CAAC,EAAE,EAAE;SACN,EACD,CAAC,CAAC,UAAU;SACb,CAAC;QAEF,GAAG,CAAC,GAAG,CAAC,IAAI,CAAE,8BAA8B,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;QAC1D,GAAG,CAAC,GAAG,CAAC,KAAK,CAAE,WAAW,EAAE,EAAE,CAAC,EAAE,iBAAiB,EAAE,CAAC,CAAC;QACtD,GAAG,CAAC,GAAG,CAAC,IAAI,CAAE,UAAU,EAAE,EAAE,CAAC,EAAE,gBAAgB,EAAE,CAAC,CAAC;QACnD,GAAG,CAAC,GAAG,CAAC,IAAI,CAAE,aAAa,EAAE,EAAE,CAAC,EAAE,mBAAmB,EAAE,CAAC,CAAC;QACzD,GAAG,CAAC,GAAG,CAAC,KAAK,CAAE,WAAW,EAAE,EAAE,CAAC,EAAE,iBAAiB,EAAE,CAAC,CAAC;IACxD,CAAC"}
|
|
@@ -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 { Observable } from "../../index.js";
|
|
28
|
+
import { BSBService, BSBServiceConstructor } from "../../base/index.js";
|
|
29
|
+
import * as av from "@anyvali/js";
|
|
30
|
+
export declare const Config: import("../../index.js").BSBPluginConfigClass<av.OptionalSchema<av.ObjectSchema<{}>>>;
|
|
31
|
+
export declare const EventSchemas: {
|
|
32
|
+
readonly emitReturnableEvents: {
|
|
33
|
+
readonly onReverseReturnable: {
|
|
34
|
+
input: av.ObjectSchema<{
|
|
35
|
+
text: av.StringSchema;
|
|
36
|
+
}>;
|
|
37
|
+
output: av.StringSchema;
|
|
38
|
+
description?: string;
|
|
39
|
+
defaultTimeout?: number;
|
|
40
|
+
readonly __brand: "returnable";
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
export declare class Plugin extends BSBService<InstanceType<typeof Config>, typeof EventSchemas> {
|
|
45
|
+
static Config: import("../../index.js").BSBPluginConfigClass<av.OptionalSchema<av.ObjectSchema<{}>>>;
|
|
46
|
+
static EventSchemas: {
|
|
47
|
+
readonly emitReturnableEvents: {
|
|
48
|
+
readonly onReverseReturnable: {
|
|
49
|
+
input: av.ObjectSchema<{
|
|
50
|
+
text: av.StringSchema;
|
|
51
|
+
}>;
|
|
52
|
+
output: av.StringSchema;
|
|
53
|
+
description?: string;
|
|
54
|
+
defaultTimeout?: number;
|
|
55
|
+
readonly __brand: "returnable";
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
initBeforePlugins?: string[] | undefined;
|
|
60
|
+
runBeforePlugins?: string[] | undefined;
|
|
61
|
+
runAfterPlugins?: string[] | undefined;
|
|
62
|
+
initAfterPlugins: string[];
|
|
63
|
+
dispose?(): void;
|
|
64
|
+
init?(): void | Promise<void>;
|
|
65
|
+
constructor(config: BSBServiceConstructor<InstanceType<typeof Config>, typeof EventSchemas>);
|
|
66
|
+
run(obs: Observable): Promise<void>;
|
|
67
|
+
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* BSB (Better-Service-Base) is an event-bus based microservice framework.
|
|
4
3
|
* Copyright (C) 2016 - 2025 BetterCorp (PTY) Ltd
|
|
@@ -25,20 +24,35 @@
|
|
|
25
24
|
* You should have received a copy of the GNU Affero General Public License
|
|
26
25
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
27
26
|
*/
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
27
|
+
import { BSBService, createConfigSchema, bsb } from "../../base/index.js";
|
|
28
|
+
import { createEventSchemas, createReturnableEvent } from "../../interfaces/schema-events.js";
|
|
29
|
+
import * as av from "@anyvali/js";
|
|
30
|
+
export const Config = createConfigSchema({
|
|
31
|
+
name: 'service-default4',
|
|
32
|
+
description: 'Default service plugin 4 for testing',
|
|
33
|
+
image: '../docs/public/assets/images/bsb-logo.png',
|
|
34
|
+
tags: ['default', 'example', 'test'],
|
|
35
|
+
}, av.optional(av.object({}, { unknownKeys: "strip" })).default({}));
|
|
36
|
+
export const EventSchemas = createEventSchemas({
|
|
37
|
+
emitReturnableEvents: {
|
|
38
|
+
onReverseReturnable: createReturnableEvent(bsb.object({
|
|
39
|
+
text: bsb.string({ description: 'Text to reverse' })
|
|
40
|
+
}, 'Reverse input parameters'), bsb.string({ description: 'Reversed text' }), 'Reverse text string')
|
|
33
41
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
});
|
|
43
|
+
export class Plugin extends BSBService {
|
|
44
|
+
static Config = Config;
|
|
45
|
+
static EventSchemas = EventSchemas;
|
|
46
|
+
// PLUGIN_CLIENT auto-generated from Config.metadata
|
|
47
|
+
initBeforePlugins;
|
|
48
|
+
runBeforePlugins;
|
|
49
|
+
runAfterPlugins;
|
|
50
|
+
initAfterPlugins = [];
|
|
51
|
+
constructor(config) {
|
|
52
|
+
super(config);
|
|
53
|
+
}
|
|
54
|
+
async run(obs) {
|
|
55
|
+
obs.log.info("Running service-default4");
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/plugins/service-default4/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAGH,OAAO,EAAE,UAAU,EAAyB,kBAAkB,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAC;AACjG,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC9F,OAAO,KAAK,EAAE,MAAM,aAAa,CAAC;AAElC,MAAM,CAAC,MAAM,MAAM,GAAG,kBAAkB,CACtC;IACE,IAAI,EAAE,kBAAkB;IACxB,WAAW,EAAE,sCAAsC;IACnD,KAAK,EAAE,2CAA2C;IAClD,IAAI,EAAE,CAAC,SAAS,EAAE,SAAS,EAAE,MAAM,CAAC;CACrC,EACD,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,WAAW,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CACjE,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAG,kBAAkB,CAAC;IAC7C,oBAAoB,EAAE;QACpB,mBAAmB,EAAE,qBAAqB,CACxC,GAAG,CAAC,MAAM,CAAC;YACT,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,iBAAiB,EAAE,CAAC;SACrD,EAAE,0BAA0B,CAAC,EAC9B,GAAG,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,eAAe,EAAE,CAAC,EAC5C,qBAAqB,CACtB;KACF;CACF,CAAC,CAAC;AAEH,MAAM,OAAO,MAAO,SAAQ,UAA4D;IACtF,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,MAAM,CAAC,YAAY,GAAG,YAAY,CAAC;IACnC,oDAAoD;IAE7C,iBAAiB,CAAwB;IACzC,gBAAgB,CAAwB;IACxC,eAAe,CAAwB;IAC9B,gBAAgB,GAAa,EAAE,CAAC;IAKhD,YAAY,MAA+E;QACzF,KAAK,CAAC,MAAM,CAAC,CAAC;IAChB,CAAC;IAEe,KAAK,CAAC,GAAG,CAAC,GAAe;QACvC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC;IAC3C,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"pluginName": "config-default",
|
|
3
|
-
"version": "1.0.0",
|
|
4
3
|
"events": {},
|
|
4
|
+
"version": "9.1.0",
|
|
5
5
|
"pluginType": "config",
|
|
6
6
|
"capabilities": {
|
|
7
7
|
"configApi": {
|
|
@@ -13,22 +13,30 @@
|
|
|
13
13
|
}
|
|
14
14
|
},
|
|
15
15
|
"configSchema": {
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
|
|
21
|
-
"
|
|
16
|
+
"anyvaliVersion": "1.0",
|
|
17
|
+
"schemaVersion": "1",
|
|
18
|
+
"root": {
|
|
19
|
+
"kind": "object",
|
|
20
|
+
"properties": {
|
|
21
|
+
"BSB_PROFILE": {
|
|
22
|
+
"kind": "optional",
|
|
23
|
+
"inner": {
|
|
24
|
+
"kind": "string"
|
|
25
|
+
},
|
|
26
|
+
"default": "default"
|
|
27
|
+
},
|
|
28
|
+
"BSB_CONFIG_FILE": {
|
|
29
|
+
"kind": "optional",
|
|
30
|
+
"inner": {
|
|
31
|
+
"kind": "string"
|
|
32
|
+
},
|
|
33
|
+
"default": "./sec-config.yaml"
|
|
34
|
+
}
|
|
22
35
|
},
|
|
23
|
-
"
|
|
24
|
-
|
|
25
|
-
"type": "string"
|
|
26
|
-
}
|
|
36
|
+
"required": [],
|
|
37
|
+
"unknownKeys": "strip"
|
|
27
38
|
},
|
|
28
|
-
"
|
|
29
|
-
|
|
30
|
-
"BSB_CONFIG_FILE"
|
|
31
|
-
],
|
|
32
|
-
"additionalProperties": false
|
|
39
|
+
"definitions": {},
|
|
40
|
+
"extensions": {}
|
|
33
41
|
}
|
|
34
42
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "config-default",
|
|
3
3
|
"name": "config-default",
|
|
4
|
-
"version": "9.0
|
|
4
|
+
"version": "9.1.0",
|
|
5
5
|
"description": "Default configuration plugin for profile and plugin resolution",
|
|
6
6
|
"category": "config",
|
|
7
7
|
"tags": [
|
|
@@ -16,22 +16,30 @@
|
|
|
16
16
|
"dependencies": [],
|
|
17
17
|
"image": "../docs/public/assets/images/bsb-logo.png",
|
|
18
18
|
"configSchema": {
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
|
|
24
|
-
"
|
|
19
|
+
"anyvaliVersion": "1.0",
|
|
20
|
+
"schemaVersion": "1",
|
|
21
|
+
"root": {
|
|
22
|
+
"kind": "object",
|
|
23
|
+
"properties": {
|
|
24
|
+
"BSB_PROFILE": {
|
|
25
|
+
"kind": "optional",
|
|
26
|
+
"inner": {
|
|
27
|
+
"kind": "string"
|
|
28
|
+
},
|
|
29
|
+
"default": "default"
|
|
30
|
+
},
|
|
31
|
+
"BSB_CONFIG_FILE": {
|
|
32
|
+
"kind": "optional",
|
|
33
|
+
"inner": {
|
|
34
|
+
"kind": "string"
|
|
35
|
+
},
|
|
36
|
+
"default": "./sec-config.yaml"
|
|
37
|
+
}
|
|
25
38
|
},
|
|
26
|
-
"
|
|
27
|
-
|
|
28
|
-
"type": "string"
|
|
29
|
-
}
|
|
39
|
+
"required": [],
|
|
40
|
+
"unknownKeys": "strip"
|
|
30
41
|
},
|
|
31
|
-
"
|
|
32
|
-
|
|
33
|
-
"BSB_CONFIG_FILE"
|
|
34
|
-
],
|
|
35
|
-
"additionalProperties": false
|
|
42
|
+
"definitions": {},
|
|
43
|
+
"extensions": {}
|
|
36
44
|
}
|
|
37
45
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"pluginName": "observable-default",
|
|
3
|
-
"version": "1.0.0",
|
|
4
3
|
"events": {},
|
|
4
|
+
"version": "9.1.0",
|
|
5
5
|
"pluginType": "observable",
|
|
6
6
|
"capabilities": {
|
|
7
7
|
"logging": {
|
|
@@ -25,9 +25,19 @@
|
|
|
25
25
|
}
|
|
26
26
|
},
|
|
27
27
|
"configSchema": {
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
|
|
28
|
+
"anyvaliVersion": "1.0",
|
|
29
|
+
"schemaVersion": "1",
|
|
30
|
+
"root": {
|
|
31
|
+
"kind": "optional",
|
|
32
|
+
"inner": {
|
|
33
|
+
"kind": "object",
|
|
34
|
+
"properties": {},
|
|
35
|
+
"required": [],
|
|
36
|
+
"unknownKeys": "strip"
|
|
37
|
+
},
|
|
38
|
+
"default": {}
|
|
39
|
+
},
|
|
40
|
+
"definitions": {},
|
|
41
|
+
"extensions": {}
|
|
32
42
|
}
|
|
33
43
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "observable-default",
|
|
3
3
|
"name": "observable-default",
|
|
4
|
-
"version": "9.0
|
|
4
|
+
"version": "9.1.0",
|
|
5
5
|
"description": "Default console observable plugin for logging output",
|
|
6
6
|
"category": "observable",
|
|
7
7
|
"tags": [
|
|
@@ -17,9 +17,19 @@
|
|
|
17
17
|
"dependencies": [],
|
|
18
18
|
"image": "../docs/public/assets/images/bsb-logo.png",
|
|
19
19
|
"configSchema": {
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
|
|
20
|
+
"anyvaliVersion": "1.0",
|
|
21
|
+
"schemaVersion": "1",
|
|
22
|
+
"root": {
|
|
23
|
+
"kind": "optional",
|
|
24
|
+
"inner": {
|
|
25
|
+
"kind": "object",
|
|
26
|
+
"properties": {},
|
|
27
|
+
"required": [],
|
|
28
|
+
"unknownKeys": "strip"
|
|
29
|
+
},
|
|
30
|
+
"default": {}
|
|
31
|
+
},
|
|
32
|
+
"definitions": {},
|
|
33
|
+
"extensions": {}
|
|
24
34
|
}
|
|
25
35
|
}
|