30 lines
1.6 KiB
TypeScript
30 lines
1.6 KiB
TypeScript
import type { QxObjectRef } from "./references.js";
|
|||
|
|
import type { RelationshipCollection, RelationshipEntry } from "./index.js";
|
||
|
|
type Key = string | boolean | bigint;
|
||
|
|
type Port<T extends QxObjectRef> = {
|
||
|
|
collection(): Promise<RelationshipCollection<T>>;
|
||
|
|
replace(entries: RelationshipEntry<T>[], expectedRevision: bigint): Promise<RelationshipCollection<T>>;
|
||
|
|
};
|
||
|
|
/** Helpers never retry a failed CAS or silently overwrite concurrent edits. */
|
||
|
|
export declare const relationshipMap: <T extends QxObjectRef, K extends Key = Key>(port: Port<T>) => {
|
||
|
|
read: () => Promise<RelationshipCollection<T>>;
|
||
|
|
get(key: K): Promise<{
|
||
|
|
revision: bigint;
|
||
|
|
value: T | undefined;
|
||
|
|
}>;
|
||
|
|
set(key: K, target: T, expectedRevision: bigint): Promise<RelationshipCollection<T>>;
|
||
|
|
delete(key: K, expectedRevision: bigint): Promise<RelationshipCollection<T>>;
|
||
|
|
};
|
||
|
|
export declare const relationshipList: <T extends QxObjectRef>(port: Port<T>) => {
|
||
|
|
read: () => Promise<RelationshipCollection<T>>;
|
||
|
|
insert(index: number, target: T, expectedRevision: bigint): Promise<RelationshipCollection<T>>;
|
||
|
|
move(edgeId: string, index: number, expectedRevision: bigint): Promise<RelationshipCollection<T>>;
|
||
|
|
delete(edgeId: string, expectedRevision: bigint): Promise<RelationshipCollection<T>>;
|
||
|
|
};
|
||
|
|
export declare const relationshipSet: <T extends QxObjectRef>(port: Port<T>) => {
|
||
|
|
read: () => Promise<RelationshipCollection<T>>;
|
||
|
|
add(target: T, expectedRevision: bigint): Promise<RelationshipCollection<T>>;
|
||
|
|
delete(target: T, expectedRevision: bigint): Promise<RelationshipCollection<T>>;
|
||
|
|
};
|
||
|
|
export {};
|
||
|
|
//# sourceMappingURL=relationships.d.ts.map
|