@bsb/observable-graylog 9.0.1 → 9.1.1

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/index.d.ts CHANGED
@@ -24,4 +24,4 @@
24
24
  * You should have received a copy of the GNU Affero General Public License
25
25
  * along with this program. If not, see <https://www.gnu.org/licenses/>.
26
26
  */
27
- export { GraylogConfigSchema, type GraylogConfig, Config, Plugin, } from "./plugins/observable-graylog";
27
+ export { GraylogConfigSchema, type GraylogConfig, Config, Plugin, } from "./plugins/observable-graylog/index.js";
package/lib/index.js CHANGED
@@ -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,9 +24,4 @@
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
- Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.Plugin = exports.Config = exports.GraylogConfigSchema = void 0;
30
- var observable_graylog_1 = require("./plugins/observable-graylog");
31
- Object.defineProperty(exports, "GraylogConfigSchema", { enumerable: true, get: function () { return observable_graylog_1.GraylogConfigSchema; } });
32
- Object.defineProperty(exports, "Config", { enumerable: true, get: function () { return observable_graylog_1.Config; } });
33
- Object.defineProperty(exports, "Plugin", { enumerable: true, get: function () { return observable_graylog_1.Plugin; } });
27
+ export { GraylogConfigSchema, Config, Plugin, } from "./plugins/observable-graylog/index.js";
@@ -26,72 +26,60 @@
26
26
  */
27
27
  import { BSBObservable, BSBObservableConstructor, BSBError } from "@bsb/base";
28
28
  import { DTrace, LogMeta } from "@bsb/base";
29
- import { z } from "zod";
29
+ import * as av from "@anyvali/js";
30
30
  /**
31
31
  * Configuration schema for Graylog observable
32
32
  */
33
- export declare const GraylogConfigSchema: z.ZodObject<{
34
- host: z.ZodDefault<z.ZodString>;
35
- port: z.ZodDefault<z.ZodNumber>;
36
- protocol: z.ZodDefault<z.ZodEnum<{
37
- udp: "udp";
38
- tcp: "tcp";
39
- http: "http";
40
- }>>;
41
- httpEndpoint: z.ZodOptional<z.ZodString>;
42
- facility: z.ZodDefault<z.ZodString>;
43
- additionalFields: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
44
- compress: z.ZodDefault<z.ZodBoolean>;
45
- levels: z.ZodObject<{
46
- debug: z.ZodDefault<z.ZodBoolean>;
47
- info: z.ZodDefault<z.ZodBoolean>;
48
- warn: z.ZodDefault<z.ZodBoolean>;
49
- error: z.ZodDefault<z.ZodBoolean>;
50
- }, z.core.$strip>;
51
- }, z.core.$strip>;
52
- export type GraylogConfig = z.infer<typeof GraylogConfigSchema>;
53
- export declare const Config: import("@bsb/base").BSBPluginConfigClass<z.ZodObject<{
54
- host: z.ZodDefault<z.ZodString>;
55
- port: z.ZodDefault<z.ZodNumber>;
56
- protocol: z.ZodDefault<z.ZodEnum<{
57
- udp: "udp";
58
- tcp: "tcp";
59
- http: "http";
60
- }>>;
61
- httpEndpoint: z.ZodOptional<z.ZodString>;
62
- facility: z.ZodDefault<z.ZodString>;
63
- additionalFields: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
64
- compress: z.ZodDefault<z.ZodBoolean>;
65
- levels: z.ZodObject<{
66
- debug: z.ZodDefault<z.ZodBoolean>;
67
- info: z.ZodDefault<z.ZodBoolean>;
68
- warn: z.ZodDefault<z.ZodBoolean>;
69
- error: z.ZodDefault<z.ZodBoolean>;
70
- }, z.core.$strip>;
71
- }, z.core.$strip>>;
33
+ export declare const GraylogConfigSchema: av.ObjectSchema<{
34
+ host: av.OptionalSchema<av.StringSchema>;
35
+ port: av.OptionalSchema<av.Int32Schema>;
36
+ protocol: av.OptionalSchema<av.EnumSchema<string[]>>;
37
+ httpEndpoint: av.OptionalSchema<av.StringSchema>;
38
+ facility: av.OptionalSchema<av.StringSchema>;
39
+ additionalFields: av.OptionalSchema<av.RecordSchema<av.UnionSchema<[av.StringSchema, av.NumberSchema, av.BoolSchema]>>>;
40
+ compress: av.OptionalSchema<av.BoolSchema>;
41
+ levels: av.ObjectSchema<{
42
+ debug: av.OptionalSchema<av.BoolSchema>;
43
+ info: av.OptionalSchema<av.BoolSchema>;
44
+ warn: av.OptionalSchema<av.BoolSchema>;
45
+ error: av.OptionalSchema<av.BoolSchema>;
46
+ }>;
47
+ }>;
48
+ export type GraylogConfig = av.Infer<typeof GraylogConfigSchema>;
49
+ export declare const Config: import("@bsb/base").BSBPluginConfigClass<av.ObjectSchema<{
50
+ host: av.OptionalSchema<av.StringSchema>;
51
+ port: av.OptionalSchema<av.Int32Schema>;
52
+ protocol: av.OptionalSchema<av.EnumSchema<string[]>>;
53
+ httpEndpoint: av.OptionalSchema<av.StringSchema>;
54
+ facility: av.OptionalSchema<av.StringSchema>;
55
+ additionalFields: av.OptionalSchema<av.RecordSchema<av.UnionSchema<[av.StringSchema, av.NumberSchema, av.BoolSchema]>>>;
56
+ compress: av.OptionalSchema<av.BoolSchema>;
57
+ levels: av.ObjectSchema<{
58
+ debug: av.OptionalSchema<av.BoolSchema>;
59
+ info: av.OptionalSchema<av.BoolSchema>;
60
+ warn: av.OptionalSchema<av.BoolSchema>;
61
+ error: av.OptionalSchema<av.BoolSchema>;
62
+ }>;
63
+ }>>;
72
64
  /**
73
65
  * Graylog (GELF) observable plugin - sends logs to Graylog servers
74
66
  */
75
67
  export declare class Plugin extends BSBObservable<InstanceType<typeof Config>> {
76
- static Config: import("@bsb/base").BSBPluginConfigClass<z.ZodObject<{
77
- host: z.ZodDefault<z.ZodString>;
78
- port: z.ZodDefault<z.ZodNumber>;
79
- protocol: z.ZodDefault<z.ZodEnum<{
80
- udp: "udp";
81
- tcp: "tcp";
82
- http: "http";
83
- }>>;
84
- httpEndpoint: z.ZodOptional<z.ZodString>;
85
- facility: z.ZodDefault<z.ZodString>;
86
- additionalFields: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
87
- compress: z.ZodDefault<z.ZodBoolean>;
88
- levels: z.ZodObject<{
89
- debug: z.ZodDefault<z.ZodBoolean>;
90
- info: z.ZodDefault<z.ZodBoolean>;
91
- warn: z.ZodDefault<z.ZodBoolean>;
92
- error: z.ZodDefault<z.ZodBoolean>;
93
- }, z.core.$strip>;
94
- }, z.core.$strip>>;
68
+ static Config: import("@bsb/base").BSBPluginConfigClass<av.ObjectSchema<{
69
+ host: av.OptionalSchema<av.StringSchema>;
70
+ port: av.OptionalSchema<av.Int32Schema>;
71
+ protocol: av.OptionalSchema<av.EnumSchema<string[]>>;
72
+ httpEndpoint: av.OptionalSchema<av.StringSchema>;
73
+ facility: av.OptionalSchema<av.StringSchema>;
74
+ additionalFields: av.OptionalSchema<av.RecordSchema<av.UnionSchema<[av.StringSchema, av.NumberSchema, av.BoolSchema]>>>;
75
+ compress: av.OptionalSchema<av.BoolSchema>;
76
+ levels: av.ObjectSchema<{
77
+ debug: av.OptionalSchema<av.BoolSchema>;
78
+ info: av.OptionalSchema<av.BoolSchema>;
79
+ warn: av.OptionalSchema<av.BoolSchema>;
80
+ error: av.OptionalSchema<av.BoolSchema>;
81
+ }>;
82
+ }>>;
95
83
  private logFormatter;
96
84
  private isDisposed;
97
85
  constructor(config: BSBObservableConstructor<InstanceType<typeof Config>>);
@@ -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,79 +24,39 @@
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
- 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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
40
- Object.defineProperty(o, "default", { enumerable: true, value: v });
41
- }) : function(o, v) {
42
- o["default"] = v;
43
- });
44
- var __importStar = (this && this.__importStar) || (function () {
45
- var ownKeys = function(o) {
46
- ownKeys = Object.getOwnPropertyNames || function (o) {
47
- var ar = [];
48
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
49
- return ar;
50
- };
51
- return ownKeys(o);
52
- };
53
- return function (mod) {
54
- if (mod && mod.__esModule) return mod;
55
- var result = {};
56
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
57
- __setModuleDefault(result, mod);
58
- return result;
59
- };
60
- })();
61
- Object.defineProperty(exports, "__esModule", { value: true });
62
- exports.Plugin = exports.Config = exports.GraylogConfigSchema = void 0;
63
- const base_1 = require("@bsb/base");
64
- const zod_1 = require("zod");
65
- const gelfPro = __importStar(require("gelf-pro"));
27
+ import { BSBObservable, createConfigSchema, LogFormatter, BSBError } from "@bsb/base";
28
+ import * as av from "@anyvali/js";
29
+ import * as gelfPro from "gelf-pro";
66
30
  /**
67
31
  * Configuration schema for Graylog observable
68
32
  */
69
- exports.GraylogConfigSchema = zod_1.z.object({
70
- host: zod_1.z.string().default("localhost"),
71
- port: zod_1.z.number().int().min(1).max(65535).default(12201),
72
- protocol: zod_1.z.enum(["udp", "tcp", "http"]).default("udp"),
73
- // HTTP-specific settings
74
- httpEndpoint: zod_1.z.string().url().optional(),
75
- // GELF settings
76
- facility: zod_1.z.string().default("bsb"),
77
- // Additional fields to include in all messages
78
- additionalFields: zod_1.z.record(zod_1.z.string(), zod_1.z.union([
79
- zod_1.z.string(),
80
- zod_1.z.number(),
81
- zod_1.z.boolean(),
82
- ])).default({}),
83
- // Compression (for UDP/TCP)
84
- compress: zod_1.z.boolean().default(true),
85
- // Log level filtering
86
- levels: zod_1.z.object({
87
- debug: zod_1.z.boolean().default(true),
88
- info: zod_1.z.boolean().default(true),
89
- warn: zod_1.z.boolean().default(true),
90
- error: zod_1.z.boolean().default(true),
91
- }),
92
- });
93
- exports.Config = (0, base_1.createConfigSchema)({
33
+ export const GraylogConfigSchema = av.object({
34
+ host: av.optional(av.string()).default("localhost"),
35
+ port: av.optional(av.int32().min(1).max(65535)).default(12201),
36
+ protocol: av.optional(av.enum_(["udp", "tcp", "http"])).default("udp"),
37
+ httpEndpoint: av.optional(av.string().format("url")),
38
+ facility: av.optional(av.string()).default("bsb"),
39
+ additionalFields: av.optional(av.record(av.union([
40
+ av.string(),
41
+ av.number(),
42
+ av.bool(),
43
+ ]))).default({}),
44
+ compress: av.optional(av.bool()).default(true),
45
+ levels: av.object({
46
+ debug: av.optional(av.bool()).default(true),
47
+ info: av.optional(av.bool()).default(true),
48
+ warn: av.optional(av.bool()).default(true),
49
+ error: av.optional(av.bool()).default(true),
50
+ }, { unknownKeys: "strip" }),
51
+ }, { unknownKeys: "strip" });
52
+ export const Config = createConfigSchema({
94
53
  name: 'observable-graylog',
95
54
  description: 'Graylog GELF observable plugin for centralized log ingestion',
96
55
  version: '9.0.0',
97
56
  image: './observable-graylog.png',
98
57
  tags: ['graylog', 'gelf', 'observability', 'logging'],
99
58
  documentation: ['./docs/plugin.md'],
100
- }, exports.GraylogConfigSchema);
59
+ }, GraylogConfigSchema);
101
60
  /**
102
61
  * Convert BSB log level to GELF/syslog severity level
103
62
  */
@@ -120,9 +79,9 @@ function bsbLevelToGelfLevel(level) {
120
79
  /**
121
80
  * Graylog (GELF) observable plugin - sends logs to Graylog servers
122
81
  */
123
- class Plugin extends base_1.BSBObservable {
124
- static Config = exports.Config;
125
- logFormatter = new base_1.LogFormatter();
82
+ export class Plugin extends BSBObservable {
83
+ static Config = Config;
84
+ logFormatter = new LogFormatter();
126
85
  isDisposed = false;
127
86
  constructor(config) {
128
87
  super(config);
@@ -211,7 +170,7 @@ class Plugin extends base_1.BSBObservable {
211
170
  if (!this.config.levels.error) {
212
171
  return;
213
172
  }
214
- if (message instanceof base_1.BSBError) {
173
+ if (message instanceof BSBError) {
215
174
  if (message.raw !== null) {
216
175
  this.sendLog("error", message.raw.trace, pluginName, message.raw.message, message.raw.meta);
217
176
  }
@@ -228,4 +187,3 @@ class Plugin extends base_1.BSBObservable {
228
187
  // gelf-pro doesn't require explicit cleanup
229
188
  }
230
189
  }
231
- exports.Plugin = Plugin;
@@ -2,101 +2,6 @@
2
2
  "pluginName": "observable-graylog",
3
3
  "version": "9.0.0",
4
4
  "events": {},
5
- "configSchema": {
6
- "$schema": "https://json-schema.org/draft/2020-12/schema",
7
- "type": "object",
8
- "properties": {
9
- "host": {
10
- "default": "localhost",
11
- "type": "string"
12
- },
13
- "port": {
14
- "default": 12201,
15
- "type": "integer",
16
- "minimum": 1,
17
- "maximum": 65535
18
- },
19
- "protocol": {
20
- "default": "udp",
21
- "type": "string",
22
- "enum": [
23
- "udp",
24
- "tcp",
25
- "http"
26
- ]
27
- },
28
- "httpEndpoint": {
29
- "type": "string",
30
- "format": "uri"
31
- },
32
- "facility": {
33
- "default": "bsb",
34
- "type": "string"
35
- },
36
- "additionalFields": {
37
- "default": {},
38
- "type": "object",
39
- "propertyNames": {
40
- "type": "string"
41
- },
42
- "additionalProperties": {
43
- "anyOf": [
44
- {
45
- "type": "string"
46
- },
47
- {
48
- "type": "number"
49
- },
50
- {
51
- "type": "boolean"
52
- }
53
- ]
54
- }
55
- },
56
- "compress": {
57
- "default": true,
58
- "type": "boolean"
59
- },
60
- "levels": {
61
- "type": "object",
62
- "properties": {
63
- "debug": {
64
- "default": true,
65
- "type": "boolean"
66
- },
67
- "info": {
68
- "default": true,
69
- "type": "boolean"
70
- },
71
- "warn": {
72
- "default": true,
73
- "type": "boolean"
74
- },
75
- "error": {
76
- "default": true,
77
- "type": "boolean"
78
- }
79
- },
80
- "required": [
81
- "debug",
82
- "info",
83
- "warn",
84
- "error"
85
- ],
86
- "additionalProperties": false
87
- }
88
- },
89
- "required": [
90
- "host",
91
- "port",
92
- "protocol",
93
- "facility",
94
- "additionalFields",
95
- "compress",
96
- "levels"
97
- ],
98
- "additionalProperties": false
99
- },
100
5
  "pluginType": "observable",
101
6
  "capabilities": {
102
7
  "logging": {
@@ -14,100 +14,5 @@
14
14
  "./docs/plugin.md"
15
15
  ],
16
16
  "dependencies": [],
17
- "image": "./observable-graylog.png",
18
- "configSchema": {
19
- "$schema": "https://json-schema.org/draft/2020-12/schema",
20
- "type": "object",
21
- "properties": {
22
- "host": {
23
- "default": "localhost",
24
- "type": "string"
25
- },
26
- "port": {
27
- "default": 12201,
28
- "type": "integer",
29
- "minimum": 1,
30
- "maximum": 65535
31
- },
32
- "protocol": {
33
- "default": "udp",
34
- "type": "string",
35
- "enum": [
36
- "udp",
37
- "tcp",
38
- "http"
39
- ]
40
- },
41
- "httpEndpoint": {
42
- "type": "string",
43
- "format": "uri"
44
- },
45
- "facility": {
46
- "default": "bsb",
47
- "type": "string"
48
- },
49
- "additionalFields": {
50
- "default": {},
51
- "type": "object",
52
- "propertyNames": {
53
- "type": "string"
54
- },
55
- "additionalProperties": {
56
- "anyOf": [
57
- {
58
- "type": "string"
59
- },
60
- {
61
- "type": "number"
62
- },
63
- {
64
- "type": "boolean"
65
- }
66
- ]
67
- }
68
- },
69
- "compress": {
70
- "default": true,
71
- "type": "boolean"
72
- },
73
- "levels": {
74
- "type": "object",
75
- "properties": {
76
- "debug": {
77
- "default": true,
78
- "type": "boolean"
79
- },
80
- "info": {
81
- "default": true,
82
- "type": "boolean"
83
- },
84
- "warn": {
85
- "default": true,
86
- "type": "boolean"
87
- },
88
- "error": {
89
- "default": true,
90
- "type": "boolean"
91
- }
92
- },
93
- "required": [
94
- "debug",
95
- "info",
96
- "warn",
97
- "error"
98
- ],
99
- "additionalProperties": false
100
- }
101
- },
102
- "required": [
103
- "host",
104
- "port",
105
- "protocol",
106
- "facility",
107
- "additionalFields",
108
- "compress",
109
- "levels"
110
- ],
111
- "additionalProperties": false
112
- }
17
+ "image": "./observable-graylog.png"
113
18
  }
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@bsb/observable-graylog",
3
- "version": "9.0.1",
3
+ "version": "9.1.1",
4
+ "type": "module",
4
5
  "license": "(AGPL-3.0-only OR Commercial)",
5
6
  "author": {
6
7
  "name": "BetterCorp (PTY) Ltd",
@@ -40,11 +41,11 @@
40
41
  "@bsb/base": "^9.0.0"
41
42
  },
42
43
  "dependencies": {
43
- "gelf-pro": "^1.3.2",
44
- "zod": "^4.3.6"
44
+ "@anyvali/js": "^0.2.0",
45
+ "gelf-pro": "^1.3.2"
45
46
  },
46
47
  "devDependencies": {
47
- "@bsb/base": "file:../../../nodejs",
48
+ "@bsb/base": "^9.0.0",
48
49
  "@types/node": "^25.0.0",
49
50
  "mocha": "^11.0.0",
50
51
  "typescript": "^5.9.0"
@@ -55,7 +56,3 @@
55
56
  },
56
57
  "homepage": "https://io.bsbcode.dev/packages/nodejs/@bsb/observable-graylog"
57
58
  }
58
-
59
-
60
-
61
-