Format the codebase using prettier

This commit is contained in:
Adrian Jagielak
2025-07-24 16:34:58 +02:00
parent 7b4309a596
commit 3c56a30d01
69 changed files with 984 additions and 895 deletions

View File

@@ -11,26 +11,37 @@ export class DemoFimpMqttClient implements IMqttClient {
private onceConnectHandlers: (() => void)[] = [];
private onceErrorHandlers: OnErrorCallback[] = [];
connect(_url: string, _options: {
port: number;
username: string;
password: string;
protocolVersion: 4;
}): void {
connect(
_url: string,
_options: {
port: number;
username: string;
password: string;
protocolVersion: 4;
},
): void {
setTimeout(() => {
this.onceConnectHandlers.forEach((h) => h());
}, 100);
}
subscribe(topicObject: string, opts?: { qos: 0 | 1 | 2 }, callback?: (err: Error | null) => void): void;
subscribe(_topic: string, _opts?: any, _callback?: any): void { }
subscribe(
topicObject: string,
opts?: { qos: 0 | 1 | 2 },
callback?: (err: Error | null) => void,
): void;
subscribe(_topic: string, _opts?: any, _callback?: any): void {}
publish(topic: string, value: string, _options: {
retain?: boolean;
qos: 0 | 1 | 2;
}): void {
publish(
topic: string,
value: string,
_options: {
retain?: boolean;
qos: 0 | 1 | 2;
},
): void {
setTimeout(() => {
const msg = JSON.parse(value)
const msg = JSON.parse(value);
const sendResponse = (response: FimpResponse) => {
response.corid = response.corid ?? msg.uid;
@@ -38,14 +49,35 @@ export class DemoFimpMqttClient implements IMqttClient {
for (const handler of this.messageHandlers) {
handler(topic, buffer, { retain: false } as any);
}
}
};
if (msg.serv == 'vinculum' && msg.type == 'cmd.pd7.request' && msg.val?.param?.components?.includes('house')) {
sendResponse({ type: 'evt.pd7.response', val: { param: { house: { hubId: '000000004c38b232' } } } })
} else if (msg.serv == 'vinculum' && msg.type == 'cmd.pd7.request' && msg.val?.param?.components?.includes('device')) {
sendResponse({ type: 'evt.pd7.response', val: { param: { device: demo_data__device } } });
} else if (msg.serv == 'vinculum' && msg.type == 'cmd.pd7.request' && msg.val?.param?.components?.includes('state')) {
sendResponse({ type: 'evt.pd7.response', val: { param: { state: { devices: demo_data__state } } } })
if (
msg.serv == 'vinculum' &&
msg.type == 'cmd.pd7.request' &&
msg.val?.param?.components?.includes('house')
) {
sendResponse({
type: 'evt.pd7.response',
val: { param: { house: { hubId: '000000004c38b232' } } },
});
} else if (
msg.serv == 'vinculum' &&
msg.type == 'cmd.pd7.request' &&
msg.val?.param?.components?.includes('device')
) {
sendResponse({
type: 'evt.pd7.response',
val: { param: { device: demo_data__device } },
});
} else if (
msg.serv == 'vinculum' &&
msg.type == 'cmd.pd7.request' &&
msg.val?.param?.components?.includes('state')
) {
sendResponse({
type: 'evt.pd7.response',
val: { param: { state: { devices: demo_data__state } } },
});
}
}, 100);
}
@@ -92,4 +124,4 @@ export class DemoFimpMqttClient implements IMqttClient {
this.onceErrorHandlers.forEach((h) => h(err));
this.onceErrorHandlers = [];
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -474,9 +474,7 @@
{
"ts": "2022-02-19 16:19:10 +0100",
"val": {
"members": [
"3_1"
]
"members": ["3_1"]
},
"val_t": "object"
}
@@ -972,9 +970,7 @@
{
"ts": "2023-01-05 00:31:29 +0100",
"val": {
"members": [
"3_1"
]
"members": ["3_1"]
},
"val_t": "object"
}

View File

@@ -1,20 +1,31 @@
import { IPublishPacket, OnErrorCallback, OnMessageCallback } from "mqtt/*";
import { IPublishPacket, OnErrorCallback, OnMessageCallback } from 'mqtt/*';
export interface IMqttClient {
connect(url: string, options: {
port: number;
username: string;
password: string;
protocolVersion: 4;
}): void;
connect(
url: string,
options: {
port: number;
username: string;
password: string;
protocolVersion: 4;
},
): void;
subscribe(topic: string): void;
subscribe(topicObject: string, opts?: { qos: 0 | 1 | 2 }, callback?: (err: Error | null) => void): void;
subscribe(
topicObject: string,
opts?: { qos: 0 | 1 | 2 },
callback?: (err: Error | null) => void,
): void;
publish(topic: string, value: string, options: {
retain?: boolean;
qos: 0 | 1 | 2;
}): void;
publish(
topic: string,
value: string,
options: {
retain?: boolean;
qos: 0 | 1 | 2;
},
): void;
on(event: 'message', handler: OnMessageCallback): void;
on(event: 'error', handler: OnErrorCallback): void;
@@ -22,8 +33,11 @@ export interface IMqttClient {
off(event: 'message', handler: OnMessageCallback): void;
off(event: 'error', handler: OnErrorCallback): void;
removeListener(event: 'message', handler: (topic: string, payload: Buffer, packet: IPublishPacket) => void): void;
removeListener(
event: 'message',
handler: (topic: string, payload: Buffer, packet: IPublishPacket) => void,
): void;
once(event: 'connect', handler: () => void): void;
once(event: 'error', handler: OnErrorCallback): void;
}
}

View File

@@ -8,16 +8,23 @@ export class RealMqttClient implements IMqttClient {
this.client = {} as MqttClient; // gets initialized in connect()
}
connect(url: string, options: {
port: number;
username: string;
password: string;
protocolVersion: 4;
}): void {
connect(
url: string,
options: {
port: number;
username: string;
password: string;
protocolVersion: 4;
},
): void {
this.client = connect(url, options);
}
subscribe(topicObject: string, opts?: { qos: 0 | 1 | 2 }, callback?: (err: Error | null) => void): void;
subscribe(
topicObject: string,
opts?: { qos: 0 | 1 | 2 },
callback?: (err: Error | null) => void,
): void;
subscribe(topic: string, opts?: any, callback?: any): void {
if (opts) {
this.client.subscribe(topic, opts, callback);
@@ -26,10 +33,14 @@ export class RealMqttClient implements IMqttClient {
}
}
publish(topic: string, value: string, options: {
retain?: boolean;
qos: 0 | 1 | 2;
}): void {
publish(
topic: string,
value: string,
options: {
retain?: boolean;
qos: 0 | 1 | 2;
},
): void {
this.client.publish(topic, value, options);
}