UNPKG

@instantdb/core

Version:
90 lines 4.29 kB
import { InstantDBAttr } from './attrTypes.ts'; import { LinkIndex } from './utils/linkIndex.ts'; type Triple = [string, string, any, number]; type Attrs = Record<string, InstantDBAttr>; export type Store = { eav: Map<string, Map<string, Map<any, Triple>>>; aev: Map<string, Map<string, Map<any, Triple>>>; vae: Map<any, Map<string, Map<string, Triple>>>; useDateObjects: boolean | null | undefined; cardinalityInference: boolean | null | undefined; }; type StoreJsonVersion0 = { __type: 'store'; attrs: Attrs; triples: Triple[]; cardinalityInference: boolean | null | undefined; linkIndex: LinkIndex | null; useDateObjects: boolean | null | undefined; }; type StoreJsonVersion1 = { triples: Triple[]; cardinalityInference: boolean | null | undefined; useDateObjects: boolean | null | undefined; version: 1; }; export type StoreJson = StoreJsonVersion0 | StoreJsonVersion1; export type AttrsStoreJson = { attrs: Attrs; linkIndex: LinkIndex | null; }; export interface AttrsStore { attrs: Attrs; linkIndex: LinkIndex | null; resetAttrIndexes(): void; addAttr(attr: InstantDBAttr): void; deleteAttr(attrId: string): void; updateAttr(partialAttr: Partial<InstantDBAttr> & { id: string; }): void; getAttr(id: string): InstantDBAttr | undefined; blobAttrs: Map<string, Map<string, InstantDBAttr>>; primaryKeys: Map<string, InstantDBAttr>; forwardIdents: Map<string, Map<string, InstantDBAttr>>; revIdents: Map<string, Map<string, InstantDBAttr>>; toJSON(): AttrsStoreJson; } export declare class AttrsStoreClass implements AttrsStore { attrs: Attrs; linkIndex: LinkIndex | null; private _blobAttrs; private _primaryKeys; private _forwardIdents; private _revIdents; constructor(attrs: Attrs, linkIndex: LinkIndex | null); resetAttrIndexes(): void; addAttr(attr: InstantDBAttr): void; deleteAttr(attrId: string): void; updateAttr(partialAttr: Partial<InstantDBAttr> & { id: string; }): void; getAttr(id: string): InstantDBAttr | undefined; get blobAttrs(): Map<string, Map<string, InstantDBAttr>>; get primaryKeys(): Map<string, InstantDBAttr>; get forwardIdents(): Map<string, Map<string, InstantDBAttr>>; get revIdents(): Map<string, Map<string, InstantDBAttr>>; toJSON(): AttrsStoreJson; } export declare function isBlob(attr: InstantDBAttr): boolean; export declare function getInMap(obj: any, path: any): any; export declare function toJSON(store: Store): StoreJsonVersion1; export declare function fromJSON(attrsStore: AttrsStore, storeJSON: StoreJson): Store; export declare function attrsStoreFromJSON(attrsStoreJSON: AttrsStoreJson | null, storeJSON: StoreJson | null): AttrsStore | undefined; export declare function hasTriple(store: Store, [e, a, v]: [string, string, any]): boolean; export declare function hasEntity(store: Store, e: string): boolean; export declare function createStore(attrsStore: AttrsStore, triples: Triple[], enableCardinalityInference?: boolean | null, useDateObjects?: boolean | null): Store; export declare function retractTriple(store: Store, attrsStore: AttrsStore, rawTriple: Triple): void; export declare function addTriple(store: Store, attrsStore: AttrsStore, rawTriple: Triple): void; export declare function allMapValues(m: any, level: any, res?: any[]): any[]; export declare function getTriples(store: any, [e, a, v]: [any, any, any]): any[]; export declare function getAsObject(store: Store, attrs: Map<string, InstantDBAttr> | undefined, e: string): {}; export declare function getAttrByFwdIdentName(attrsStore: AttrsStore, inputEtype: string, inputLabel: string): InstantDBAttr | undefined; export declare function getAttrByReverseIdentName(attrsStore: AttrsStore, inputEtype: string, inputLabel: string): InstantDBAttr | undefined; export declare function getBlobAttrs(attrsStore: AttrsStore, etype: string): Map<string, InstantDBAttr> | undefined; export declare function getPrimaryKeyAttr(attrsStore: AttrsStore, etype: string): InstantDBAttr | undefined; export declare function transact(store: Store, attrsStore: AttrsStore, txSteps: any): { store: Store; attrsStore: AttrsStore; }; export {}; //# sourceMappingURL=store.d.ts.map