2024-12-21 21:16:18 -06:00
|
|
|
export type JSONLogic = object;
|
|
|
|
|
|
|
|
export type FilterExpr = JSONLogic;
|
|
|
|
|
|
|
|
export type FilterGenerator = () => FilterExpr;
|
|
|
|
|
|
|
|
export type PropertyTypes = string | number | undefined;
|
|
|
|
|
2024-12-26 15:59:03 -06:00
|
|
|
export type DomainEntityID = string;
|
|
|
|
export type PropertyID = string;
|
2024-12-29 17:50:20 -06:00
|
|
|
export type TransactionID = string;
|
2024-12-26 15:59:03 -06:00
|
|
|
|
2024-12-29 14:35:30 -06:00
|
|
|
export type Timestamp = number;
|
2024-12-23 17:29:38 -06:00
|
|
|
|
2024-12-29 14:35:30 -06:00
|
|
|
export type ViewMany<T> = {
|
|
|
|
[key: DomainEntityID]: T;
|
|
|
|
};
|
|
|
|
|
|
|
|
// TODO: Move to ./peers.ts
|
2024-12-22 14:00:51 -06:00
|
|
|
export class PeerAddress {
|
|
|
|
addr: string;
|
|
|
|
port: number;
|
2024-12-25 16:13:48 -06:00
|
|
|
|
2024-12-22 14:00:51 -06:00
|
|
|
constructor(addr: string, port: number) {
|
|
|
|
this.addr = addr;
|
|
|
|
this.port = port;
|
|
|
|
}
|
2024-12-25 16:13:48 -06:00
|
|
|
|
2024-12-22 14:00:51 -06:00
|
|
|
static fromString(addrString: string): PeerAddress {
|
|
|
|
const [addr, port] = addrString.trim().split(':');
|
|
|
|
return new PeerAddress(addr, parseInt(port));
|
|
|
|
}
|
2024-12-25 16:13:48 -06:00
|
|
|
|
2024-12-22 14:00:51 -06:00
|
|
|
toAddrString() {
|
|
|
|
return `${this.addr}:${this.port}`;
|
|
|
|
}
|
2024-12-25 16:13:48 -06:00
|
|
|
|
2024-12-22 14:00:51 -06:00
|
|
|
toJSON() {
|
2024-12-22 14:17:44 -06:00
|
|
|
return this.toAddrString();
|
2024-12-22 14:00:51 -06:00
|
|
|
}
|
2024-12-25 16:13:48 -06:00
|
|
|
|
|
|
|
isEqual(other: PeerAddress) {
|
|
|
|
return this.addr === other.addr && this.port === other.port;
|
|
|
|
}
|
2024-12-22 14:00:51 -06:00
|
|
|
};
|
|
|
|
|