@syncbridge/builtins 0.4.17 → 0.4.18
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/classes/transmit-logger.d.ts +1 -0
- package/classes/transmit-logger.js +3 -0
- package/components/io-client-base.component.d.ts +1 -0
- package/components/io-client-base.component.js +21 -14
- package/components/io-client-base.variables.js +1 -0
- package/components/io-server-base.component.d.ts +1 -0
- package/components/io-server-base.component.js +21 -14
- package/components/io-server-base.variables.js +1 -0
- package/constants.js +1 -1
- package/package.json +2 -2
|
@@ -8,6 +8,7 @@ export declare class TransmitLogger extends EventEmitter {
|
|
|
8
8
|
received(content: Buffer | string, peer?: string): void;
|
|
9
9
|
transmitted(content: Buffer | string, peer?: string): void;
|
|
10
10
|
info(content: string, peer?: string): void;
|
|
11
|
+
close(): void;
|
|
11
12
|
protected _write(direction: string, content: Buffer | string, peer?: string): void;
|
|
12
13
|
protected _getHeader(direction: string, contentSize: number, peer?: string): string;
|
|
13
14
|
}
|
|
@@ -11,6 +11,7 @@ export declare class IoClientBaseComponent<TEvents extends IoClientBaseComponent
|
|
|
11
11
|
values: IoClientComponentVariables;
|
|
12
12
|
protected _init(): Promise<void>;
|
|
13
13
|
write(data: string | Buffer): void;
|
|
14
|
+
protected _configureCommunicationLogs(): void;
|
|
14
15
|
}
|
|
15
16
|
/**
|
|
16
17
|
* @namespace
|
|
@@ -12,10 +12,23 @@ let IoClientBaseComponent = class IoClientBaseComponent extends ComponentBase {
|
|
|
12
12
|
transmitLogger;
|
|
13
13
|
async _init() {
|
|
14
14
|
await super._init();
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
this.on('data', (data, info) => {
|
|
16
|
+
this.transmitLogger?.received(data, info);
|
|
17
|
+
});
|
|
18
|
+
this.on('transmit', (data, info) => {
|
|
19
|
+
this.transmitLogger?.transmitted(data, info);
|
|
20
|
+
});
|
|
21
|
+
this._configureCommunicationLogs();
|
|
22
|
+
}
|
|
23
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
24
|
+
write(data) {
|
|
25
|
+
throw new Error(`"${this.constructor.name}" component do not support write operations.`);
|
|
26
|
+
}
|
|
27
|
+
_configureCommunicationLogs() {
|
|
28
|
+
const { communicationLogs, communicationLogs_enabled } = this.values;
|
|
29
|
+
if (communicationLogs_enabled) {
|
|
30
|
+
const { dataDirectory } = this.processor;
|
|
31
|
+
this.transmitLogger = new TransmitLogger({
|
|
19
32
|
...communicationLogs,
|
|
20
33
|
logDirectory: dataDirectory
|
|
21
34
|
? path.join(dataDirectory, 'comm-logs')
|
|
@@ -23,18 +36,12 @@ let IoClientBaseComponent = class IoClientBaseComponent extends ComponentBase {
|
|
|
23
36
|
name: this.path.replace(/\//g, '-'),
|
|
24
37
|
maxFiles: communicationLogs?.maxFiles,
|
|
25
38
|
maxFileSize: communicationLogs?.maxFileSize,
|
|
26
|
-
}));
|
|
27
|
-
this.on('data', (data, info) => {
|
|
28
|
-
transmitLogger.received(data, info);
|
|
29
|
-
});
|
|
30
|
-
this.on('transmit', (data, info) => {
|
|
31
|
-
transmitLogger.transmitted(data, info);
|
|
32
39
|
});
|
|
33
40
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
41
|
+
else {
|
|
42
|
+
this.transmitLogger?.close();
|
|
43
|
+
this.transmitLogger = undefined;
|
|
44
|
+
}
|
|
38
45
|
}
|
|
39
46
|
};
|
|
40
47
|
__decorate([
|
|
@@ -11,6 +11,7 @@ export declare class IoServerBaseComponent<TEvents extends IoServerBaseComponent
|
|
|
11
11
|
values: IoServerComponentVariables;
|
|
12
12
|
protected _init(): Promise<void>;
|
|
13
13
|
write(data: string | Buffer): void;
|
|
14
|
+
protected _configureCommunicationLogs(): void;
|
|
14
15
|
}
|
|
15
16
|
/**
|
|
16
17
|
* @namespace
|
|
@@ -12,10 +12,23 @@ let IoServerBaseComponent = class IoServerBaseComponent extends ComponentBase {
|
|
|
12
12
|
transmitLogger;
|
|
13
13
|
async _init() {
|
|
14
14
|
await super._init();
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
this.on('data', (data, info) => {
|
|
16
|
+
this.transmitLogger?.received(data, info);
|
|
17
|
+
});
|
|
18
|
+
this.on('transmit', (data, info) => {
|
|
19
|
+
this.transmitLogger?.transmitted(data, info);
|
|
20
|
+
});
|
|
21
|
+
this._configureCommunicationLogs();
|
|
22
|
+
}
|
|
23
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
24
|
+
write(data) {
|
|
25
|
+
throw new Error(`"${this.constructor.name}" component do not support write operations.`);
|
|
26
|
+
}
|
|
27
|
+
_configureCommunicationLogs() {
|
|
28
|
+
const { communicationLogs, communicationLogs_enabled } = this.values;
|
|
29
|
+
if (communicationLogs_enabled) {
|
|
30
|
+
const { dataDirectory } = this.processor;
|
|
31
|
+
this.transmitLogger = new TransmitLogger({
|
|
19
32
|
...communicationLogs,
|
|
20
33
|
logDirectory: dataDirectory
|
|
21
34
|
? path.join(dataDirectory, 'comm-logs')
|
|
@@ -23,18 +36,12 @@ let IoServerBaseComponent = class IoServerBaseComponent extends ComponentBase {
|
|
|
23
36
|
name: this.path.replace(/\//g, '-'),
|
|
24
37
|
maxFiles: communicationLogs?.maxFiles,
|
|
25
38
|
maxFileSize: communicationLogs?.maxFileSize,
|
|
26
|
-
}));
|
|
27
|
-
this.on('data', (data, info) => {
|
|
28
|
-
transmitLogger.received(data, info);
|
|
29
|
-
});
|
|
30
|
-
this.on('transmit', (data, info) => {
|
|
31
|
-
transmitLogger.transmitted(data, info);
|
|
32
39
|
});
|
|
33
40
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
41
|
+
else {
|
|
42
|
+
this.transmitLogger?.close();
|
|
43
|
+
this.transmitLogger = undefined;
|
|
44
|
+
}
|
|
38
45
|
}
|
|
39
46
|
};
|
|
40
47
|
__decorate([
|
package/constants.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@syncbridge/builtins",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.18",
|
|
4
4
|
"description": "SyncBridge builtin extensions",
|
|
5
5
|
"author": "Panates Inc",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"serialport": "^13.0.0"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
|
-
"@syncbridge/common": "^0.5.
|
|
29
|
+
"@syncbridge/common": "^0.5.12",
|
|
30
30
|
"@sqb/builder": ">=4.19.6 <5",
|
|
31
31
|
"@sqb/connect": ">=4.19.6 <5"
|
|
32
32
|
},
|