@atproto/repo
Version:
atproto repo and MST implementation
394 lines • 12 kB
TypeScript
import { CID } from 'multiformats';
import { z } from 'zod';
import { RepoRecord } from '@atproto/lexicon';
import { BlockMap } from './block-map';
import { CidSet } from './cid-set';
declare const unsignedCommit: z.ZodObject<{
did: z.ZodString;
version: z.ZodLiteral<3>;
data: z.ZodEffects<z.ZodUnknown, CID, unknown>;
rev: z.ZodString;
prev: z.ZodNullable<z.ZodEffects<z.ZodUnknown, CID, unknown>>;
}, "strip", z.ZodTypeAny, {
did: string;
version: 3;
data: CID;
rev: string;
prev: CID | null;
}, {
did: string;
version: 3;
rev: string;
data?: unknown;
prev?: unknown;
}>;
export type UnsignedCommit = z.infer<typeof unsignedCommit> & {
sig?: never;
};
declare const commit: z.ZodObject<{
did: z.ZodString;
version: z.ZodLiteral<3>;
data: z.ZodEffects<z.ZodUnknown, CID, unknown>;
rev: z.ZodString;
prev: z.ZodNullable<z.ZodEffects<z.ZodUnknown, CID, unknown>>;
sig: z.ZodType<Uint8Array<ArrayBuffer>, z.ZodTypeDef, Uint8Array<ArrayBuffer>>;
}, "strip", z.ZodTypeAny, {
did: string;
version: 3;
data: CID;
rev: string;
prev: CID | null;
sig: Uint8Array<ArrayBuffer>;
}, {
did: string;
version: 3;
rev: string;
sig: Uint8Array<ArrayBuffer>;
data?: unknown;
prev?: unknown;
}>;
export type Commit = z.infer<typeof commit>;
declare const legacyV2Commit: z.ZodObject<{
did: z.ZodString;
version: z.ZodLiteral<2>;
data: z.ZodEffects<z.ZodUnknown, CID, unknown>;
rev: z.ZodOptional<z.ZodString>;
prev: z.ZodNullable<z.ZodEffects<z.ZodUnknown, CID, unknown>>;
sig: z.ZodType<Uint8Array<ArrayBuffer>, z.ZodTypeDef, Uint8Array<ArrayBuffer>>;
}, "strip", z.ZodTypeAny, {
did: string;
version: 2;
data: CID;
prev: CID | null;
sig: Uint8Array<ArrayBuffer>;
rev?: string | undefined;
}, {
did: string;
version: 2;
sig: Uint8Array<ArrayBuffer>;
data?: unknown;
rev?: string | undefined;
prev?: unknown;
}>;
export type LegacyV2Commit = z.infer<typeof legacyV2Commit>;
declare const versionedCommit: z.ZodDiscriminatedUnion<"version", [z.ZodObject<{
did: z.ZodString;
version: z.ZodLiteral<3>;
data: z.ZodEffects<z.ZodUnknown, CID, unknown>;
rev: z.ZodString;
prev: z.ZodNullable<z.ZodEffects<z.ZodUnknown, CID, unknown>>;
sig: z.ZodType<Uint8Array<ArrayBuffer>, z.ZodTypeDef, Uint8Array<ArrayBuffer>>;
}, "strip", z.ZodTypeAny, {
did: string;
version: 3;
data: CID;
rev: string;
prev: CID | null;
sig: Uint8Array<ArrayBuffer>;
}, {
did: string;
version: 3;
rev: string;
sig: Uint8Array<ArrayBuffer>;
data?: unknown;
prev?: unknown;
}>, z.ZodObject<{
did: z.ZodString;
version: z.ZodLiteral<2>;
data: z.ZodEffects<z.ZodUnknown, CID, unknown>;
rev: z.ZodOptional<z.ZodString>;
prev: z.ZodNullable<z.ZodEffects<z.ZodUnknown, CID, unknown>>;
sig: z.ZodType<Uint8Array<ArrayBuffer>, z.ZodTypeDef, Uint8Array<ArrayBuffer>>;
}, "strip", z.ZodTypeAny, {
did: string;
version: 2;
data: CID;
prev: CID | null;
sig: Uint8Array<ArrayBuffer>;
rev?: string | undefined;
}, {
did: string;
version: 2;
sig: Uint8Array<ArrayBuffer>;
data?: unknown;
rev?: string | undefined;
prev?: unknown;
}>]>;
export type VersionedCommit = z.infer<typeof versionedCommit>;
export declare const schema: {
commit: z.ZodObject<{
did: z.ZodString;
version: z.ZodLiteral<3>;
data: z.ZodEffects<z.ZodUnknown, CID, unknown>;
rev: z.ZodString;
prev: z.ZodNullable<z.ZodEffects<z.ZodUnknown, CID, unknown>>;
sig: z.ZodType<Uint8Array<ArrayBuffer>, z.ZodTypeDef, Uint8Array<ArrayBuffer>>;
}, "strip", z.ZodTypeAny, {
did: string;
version: 3;
data: CID;
rev: string;
prev: CID | null;
sig: Uint8Array<ArrayBuffer>;
}, {
did: string;
version: 3;
rev: string;
sig: Uint8Array<ArrayBuffer>;
data?: unknown;
prev?: unknown;
}>;
legacyV2Commit: z.ZodObject<{
did: z.ZodString;
version: z.ZodLiteral<2>;
data: z.ZodEffects<z.ZodUnknown, CID, unknown>;
rev: z.ZodOptional<z.ZodString>;
prev: z.ZodNullable<z.ZodEffects<z.ZodUnknown, CID, unknown>>;
sig: z.ZodType<Uint8Array<ArrayBuffer>, z.ZodTypeDef, Uint8Array<ArrayBuffer>>;
}, "strip", z.ZodTypeAny, {
did: string;
version: 2;
data: CID;
prev: CID | null;
sig: Uint8Array<ArrayBuffer>;
rev?: string | undefined;
}, {
did: string;
version: 2;
sig: Uint8Array<ArrayBuffer>;
data?: unknown;
rev?: string | undefined;
prev?: unknown;
}>;
versionedCommit: z.ZodDiscriminatedUnion<"version", [z.ZodObject<{
did: z.ZodString;
version: z.ZodLiteral<3>;
data: z.ZodEffects<z.ZodUnknown, CID, unknown>;
rev: z.ZodString;
prev: z.ZodNullable<z.ZodEffects<z.ZodUnknown, CID, unknown>>;
sig: z.ZodType<Uint8Array<ArrayBuffer>, z.ZodTypeDef, Uint8Array<ArrayBuffer>>;
}, "strip", z.ZodTypeAny, {
did: string;
version: 3;
data: CID;
rev: string;
prev: CID | null;
sig: Uint8Array<ArrayBuffer>;
}, {
did: string;
version: 3;
rev: string;
sig: Uint8Array<ArrayBuffer>;
data?: unknown;
prev?: unknown;
}>, z.ZodObject<{
did: z.ZodString;
version: z.ZodLiteral<2>;
data: z.ZodEffects<z.ZodUnknown, CID, unknown>;
rev: z.ZodOptional<z.ZodString>;
prev: z.ZodNullable<z.ZodEffects<z.ZodUnknown, CID, unknown>>;
sig: z.ZodType<Uint8Array<ArrayBuffer>, z.ZodTypeDef, Uint8Array<ArrayBuffer>>;
}, "strip", z.ZodTypeAny, {
did: string;
version: 2;
data: CID;
prev: CID | null;
sig: Uint8Array<ArrayBuffer>;
rev?: string | undefined;
}, {
did: string;
version: 2;
sig: Uint8Array<ArrayBuffer>;
data?: unknown;
rev?: string | undefined;
prev?: unknown;
}>]>;
cid: z.ZodEffects<z.ZodUnknown, CID, unknown>;
carHeader: z.ZodObject<{
version: z.ZodLiteral<1>;
roots: z.ZodArray<z.ZodEffects<z.ZodUnknown, CID, unknown>, "many">;
}, "strip", z.ZodTypeAny, {
version: 1;
roots: CID[];
}, {
version: 1;
roots: unknown[];
}>;
bytes: z.ZodType<Uint8Array<ArrayBuffer>, z.ZodTypeDef, Uint8Array<ArrayBuffer>>;
string: z.ZodString;
array: z.ZodArray<z.ZodUnknown, "many">;
map: z.ZodRecord<z.ZodString, z.ZodUnknown>;
unknown: z.ZodUnknown;
};
export declare const def: {
commit: {
name: string;
schema: z.ZodObject<{
did: z.ZodString;
version: z.ZodLiteral<3>;
data: z.ZodEffects<z.ZodUnknown, CID, unknown>;
rev: z.ZodString;
prev: z.ZodNullable<z.ZodEffects<z.ZodUnknown, CID, unknown>>;
sig: z.ZodType<Uint8Array<ArrayBuffer>, z.ZodTypeDef, Uint8Array<ArrayBuffer>>;
}, "strip", z.ZodTypeAny, {
did: string;
version: 3;
data: CID;
rev: string;
prev: CID | null;
sig: Uint8Array<ArrayBuffer>;
}, {
did: string;
version: 3;
rev: string;
sig: Uint8Array<ArrayBuffer>;
data?: unknown;
prev?: unknown;
}>;
};
versionedCommit: {
name: string;
schema: z.ZodDiscriminatedUnion<"version", [z.ZodObject<{
did: z.ZodString;
version: z.ZodLiteral<3>;
data: z.ZodEffects<z.ZodUnknown, CID, unknown>;
rev: z.ZodString;
prev: z.ZodNullable<z.ZodEffects<z.ZodUnknown, CID, unknown>>;
sig: z.ZodType<Uint8Array<ArrayBuffer>, z.ZodTypeDef, Uint8Array<ArrayBuffer>>;
}, "strip", z.ZodTypeAny, {
did: string;
version: 3;
data: CID;
rev: string;
prev: CID | null;
sig: Uint8Array<ArrayBuffer>;
}, {
did: string;
version: 3;
rev: string;
sig: Uint8Array<ArrayBuffer>;
data?: unknown;
prev?: unknown;
}>, z.ZodObject<{
did: z.ZodString;
version: z.ZodLiteral<2>;
data: z.ZodEffects<z.ZodUnknown, CID, unknown>;
rev: z.ZodOptional<z.ZodString>;
prev: z.ZodNullable<z.ZodEffects<z.ZodUnknown, CID, unknown>>;
sig: z.ZodType<Uint8Array<ArrayBuffer>, z.ZodTypeDef, Uint8Array<ArrayBuffer>>;
}, "strip", z.ZodTypeAny, {
did: string;
version: 2;
data: CID;
prev: CID | null;
sig: Uint8Array<ArrayBuffer>;
rev?: string | undefined;
}, {
did: string;
version: 2;
sig: Uint8Array<ArrayBuffer>;
data?: unknown;
rev?: string | undefined;
prev?: unknown;
}>]>;
};
cid: import("@atproto/common-web/dist/check").Def<CID>;
carHeader: import("@atproto/common-web/dist/check").Def<import("@atproto/common").CarHeader>;
bytes: import("@atproto/common-web/dist/check").Def<Uint8Array>;
string: import("@atproto/common-web/dist/check").Def<string>;
map: import("@atproto/common-web/dist/check").Def<Record<string, unknown>>;
unknown: import("@atproto/common-web/dist/check").Def<unknown>;
};
export declare enum WriteOpAction {
Create = "create",
Update = "update",
Delete = "delete"
}
export type RecordCreateOp = {
action: WriteOpAction.Create;
collection: string;
rkey: string;
record: RepoRecord;
};
export type RecordUpdateOp = {
action: WriteOpAction.Update;
collection: string;
rkey: string;
record: RepoRecord;
};
export type RecordDeleteOp = {
action: WriteOpAction.Delete;
collection: string;
rkey: string;
};
export type RecordWriteOp = RecordCreateOp | RecordUpdateOp | RecordDeleteOp;
export type RecordCreateDescript = {
action: WriteOpAction.Create;
collection: string;
rkey: string;
cid: CID;
};
export type RecordUpdateDescript = {
action: WriteOpAction.Update;
collection: string;
rkey: string;
prev: CID;
cid: CID;
};
export type RecordDeleteDescript = {
action: WriteOpAction.Delete;
collection: string;
rkey: string;
cid: CID;
};
export type RecordWriteDescript = RecordCreateDescript | RecordUpdateDescript | RecordDeleteDescript;
export type WriteLog = RecordWriteDescript[][];
export type CommitData = {
cid: CID;
rev: string;
since: string | null;
prev: CID | null;
newBlocks: BlockMap;
relevantBlocks: BlockMap;
removedCids: CidSet;
};
export type RepoUpdate = CommitData & {
ops: RecordWriteOp[];
};
export type CollectionContents = Record<string, RepoRecord>;
export type RepoContents = Record<string, CollectionContents>;
export type RepoRecordWithCid = {
cid: CID;
value: RepoRecord;
};
export type CollectionContentsWithCids = Record<string, RepoRecordWithCid>;
export type RepoContentsWithCids = Record<string, CollectionContentsWithCids>;
export type DatastoreContents = Record<string, CID>;
export type RecordPath = {
collection: string;
rkey: string;
};
export type RecordCidClaim = {
collection: string;
rkey: string;
cid: CID | null;
};
export type RecordClaim = {
collection: string;
rkey: string;
record: RepoRecord | null;
};
export type VerifiedDiff = {
writes: RecordWriteDescript[];
commit: CommitData;
};
export type VerifiedRepo = {
creates: RecordCreateDescript[];
commit: CommitData;
};
export type CarBlock = {
cid: CID;
bytes: Uint8Array;
};
export {};
//# sourceMappingURL=types.d.ts.map