@useorbis/db-sdk
Version:
Orbis' Typescript SDK for building open-data experiences.
141 lines (140 loc) • 5.14 kB
TypeScript
import { CeramicClient } from "@ceramicnetwork/http-client";
import { ModelInstanceDocument } from "@ceramicnetwork/stream-model-instance";
import { ModelDefinition } from "@ceramicnetwork/stream-model";
import { ICeramicStorage, CeramicDocument, NewCeramicDocument } from "../types/ceramic.js";
import { CeramicConfig } from "../types/constructor.js";
import { DIDSession } from "did-session";
import { SiwxMessage } from "@didtools/cacao";
import { SupportedChains, DIDAny } from "../index.js";
import { IDidAuth, ISiwxAuth } from "../types/auth.js";
import { KeyDidSession } from "../auth/keyDid.js";
import { StreamID } from "@ceramicnetwork/streamid";
export declare class CeramicStorage implements ICeramicStorage {
#private;
id: string;
userFriendlyName: string;
supportedChains: SupportedChains[];
siwxResources: string[];
client: CeramicClient;
constructor(params: CeramicConfig);
get did(): import("dids").DID | undefined;
get session(): DIDSession | KeyDidSession | false;
connect(): Promise<void>;
authorize({ authenticator, siwxOverwrites, }: {
authenticator: ISiwxAuth | IDidAuth;
siwxOverwrites?: Partial<SiwxMessage>;
}): Promise<KeyDidSession | DIDSession>;
setSession({ session, did, }: {
session: string;
did?: DIDAny;
}): Promise<KeyDidSession | DIDSession>;
clearSession(): Promise<void>;
assertCurrentUser(did: DIDAny): Promise<boolean>;
getDocument(id: string): Promise<CeramicDocument>;
isStreamIdString(streamId: string): boolean;
isStreamId(streamId: string | StreamID): boolean;
createDocument(params: NewCeramicDocument): Promise<CeramicDocument>;
createDocumentSingle(params: NewCeramicDocument): Promise<CeramicDocument>;
createDocumentSet(params: NewCeramicDocument, unique: Array<string>): Promise<CeramicDocument>;
updateDocument(id: string, content: Record<string, any>): Promise<CeramicDocument>;
updateDocumentBySetter(id: string, setter: (document: ModelInstanceDocument) => Promise<Record<string, any>>): Promise<CeramicDocument>;
getModel(id: string): Promise<{
id: string;
schema: ({
version: "1.0";
name: string;
schema: import("json-schema-typed").JSONSchema.Object<any>;
accountRelation: {
type: "list";
} | {
type: "single";
};
} & {
description?: string | undefined;
relations?: {
[x: string]: {
type: "account";
} | {
type: "document";
model: string;
};
} | undefined;
views?: {
[x: string]: {
type: "documentAccount";
} | {
type: "documentVersion";
} | {
type: "relationDocument";
model: string;
property: string;
} | {
type: "relationFrom";
model: string;
property: string;
} | {
type: "relationCountFrom";
model: string;
property: string;
};
} | undefined;
}) | ({
version: "2.0";
name: string;
schema: import("json-schema-typed").JSONSchema.Object<any>;
accountRelation: {
type: "list";
} | {
type: "single";
} | {
type: "none";
} | {
type: "set";
fields: string[];
};
interface: boolean;
implements: string[];
} & {
description?: string | undefined;
relations?: {
[x: string]: {
type: "account";
} | {
type: "document";
model: string | null;
};
} | undefined;
views?: {
[x: string]: {
type: "documentAccount";
} | {
type: "documentVersion";
} | {
type: "relationDocument";
model: string | null;
property: string;
} | {
type: "relationFrom";
model: string;
property: string;
} | {
type: "relationCountFrom";
model: string;
property: string;
} | {
type: "relationSetFrom";
model: string;
property: string;
};
} | undefined;
immutableFields?: string[] | undefined;
});
metadata: {
controller: any;
model: any;
};
}>;
createModel(modelDefinition: ModelDefinition): Promise<{
id: string;
}>;
}