2024-12-21 21:16:18 -06:00
|
|
|
export type Pointer = {
|
|
|
|
localContext: string,
|
|
|
|
target: string | number | undefined,
|
|
|
|
targetContext?: string
|
|
|
|
};
|
|
|
|
|
2024-12-22 14:00:51 -06:00
|
|
|
export type Delta = {
|
2024-12-21 21:16:18 -06:00
|
|
|
creator: string,
|
|
|
|
host: string,
|
|
|
|
pointers: Pointer[],
|
2024-12-22 14:00:51 -06:00
|
|
|
receivedFrom?: PeerAddress,
|
2024-12-21 21:16:18 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
export type DeltaContext = Delta & {
|
|
|
|
creatorAddress: string;
|
|
|
|
};
|
|
|
|
|
|
|
|
export type Query = {
|
2024-12-22 14:00:51 -06:00
|
|
|
filterExpr: JSON
|
2024-12-21 21:16:18 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
export type QueryResult = {
|
2024-12-22 14:00:51 -06:00
|
|
|
deltas: Delta[]
|
2024-12-21 21:16:18 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
export enum Decision {
|
2024-12-22 14:00:51 -06:00
|
|
|
Accept,
|
|
|
|
Reject,
|
|
|
|
Defer
|
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-22 14:00:51 -06:00
|
|
|
export class PeerAddress {
|
|
|
|
addr: string;
|
|
|
|
port: number;
|
|
|
|
constructor(addr: string, port: number) {
|
|
|
|
this.addr = addr;
|
|
|
|
this.port = port;
|
|
|
|
}
|
|
|
|
static fromString(addrString: string): PeerAddress {
|
|
|
|
const [addr, port] = addrString.trim().split(':');
|
|
|
|
return new PeerAddress(addr, parseInt(port));
|
|
|
|
}
|
|
|
|
toAddrString() {
|
|
|
|
console.log('toAddrStr...', {addr: this.addr, port: this.port});
|
|
|
|
return `${this.addr}:${this.port}`;
|
|
|
|
}
|
|
|
|
toJSON() {
|
|
|
|
console.log('toAddrStr...', {addr: this.addr, port: this.port});
|
|
|
|
return `${this.addr}:${this.port}`;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|