# Docstore API reference

> Exports of @dev-bench/docstore.

Source: https://gitapp.n.yatsyk.com/docs/docstore/jsdoc

## Types

### ReadResult

```ts
type ReadResult = { kind?: "found"; path?: string; content?: string; versionToken?: string; } | { kind?: "missing"; path?: string; }
```

### DocEntry

```ts
type DocEntry = { path?: string; type?: "doc" | "dir"; versionToken?: string; }
```

### IfMatch

```ts
type IfMatch = { kind?: "any"; } | { kind?: "absent"; } | { kind?: "version"; token?: string; }
```

### JsonPatchOp

```ts
type JsonPatchOp = { value?: JsonValue; path?: string; op?: "add"; } | { path?: string; op?: "remove"; } | { value?: JsonValue; path?: string; op?: "replace"; } | { value?: JsonValue; path?: string; op?: "test"; }
```

### FrontmatterBody

```ts
type FrontmatterBody = { kind?: "preserve"; } | { kind?: "replace"; value?: string; }
```

### IfMissing

```ts
type IfMissing = "create-empty" | "fail"
```

### Mutation

```ts
type Mutation = { kind?: "put"; path?: string; content?: string; ifMatch?: { kind?: "any"; } | { kind?: "absent"; } | { kind?: "version"; token?: string; }; } | { kind?: "delete"; path?: string; ifMatch?: { kind?: "any"; } | { kind?: "absent"; } | { kind?: "version"; token?: string; }; } | { kind?: "json-patch"; path?: string; ifMatch?: { kind?: "any"; } | { kind?: "absent"; } | { kind?: "version"; token?: string; }; ops?: ({ value?: JsonValue; path?: string; op?: "add"; } | { path?: string; op?: "remove"; } | { value?: JsonValue; path?: string; op?: "replace"; } | { value?: JsonValue; path?: string; op?: "test"; })[]; ifMissing?: "create-empty" | "fail"; } | { kind?: "upsert-frontmatter"; path?: string; set?: Record<string, unknown>; ifMatch?: { kind?: "any"; } | { kind?: "absent"; } | { kind?: "version"; token?: string; }; body?: { kind?: "preserve"; } | { kind?: "replace"; value?: string; }; }
```

### ConflictPolicy

```ts
type ConflictPolicy = { kind?: "fail"; } | { kind?: "retry-after-pull"; maxAttempts?: number; } | { kind?: "rebase-mutations"; maxAttempts?: number; }
```

### Transaction

```ts
type Transaction = { message?: string; mutations?: ({ kind?: "put"; path?: string; content?: string; ifMatch?: { kind?: "any"; } | { kind?: "absent"; } | { kind?: "version"; token?: string; }; } | { kind?: "delete"; path?: string; ifMatch?: { kind?: "any"; } | { kind?: "absent"; } | { kind?: "version"; token?: string; }; } | { kind?: "json-patch"; path?: string; ifMatch?: { kind?: "any"; } | { kind?: "absent"; } | { kind?: "version"; token?: string; }; ops?: ({ value?: JsonValue; path?: string; op?: "add"; } | { path?: string; op?: "remove"; } | { value?: JsonValue; path?: string; op?: "replace"; } | { value?: JsonValue; path?: string; op?: "test"; })[]; ifMissing?: "create-empty" | "fail"; } | { kind?: "upsert-frontmatter"; path?: string; set?: Record<string, unknown>; ifMatch?: { kind?: "any"; } | { kind?: "absent"; } | { kind?: "version"; token?: string; }; body?: { kind?: "preserve"; } | { kind?: "replace"; value?: string; }; })[]; onConflict?: { kind?: "fail"; } | { kind?: "retry-after-pull"; maxAttempts?: number; } | { kind?: "rebase-mutations"; maxAttempts?: number; }; }
```

### TransactionResult

```ts
type TransactionResult = { kind?: "committed"; commitId?: string; } | { kind?: "conflict"; conflictingPaths?: string[]; } | { kind?: "auth-error"; reason?: string; } | { kind?: "not-found"; reason?: string; } | { kind?: "network-error"; reason?: string; retriable?: boolean; } | { kind?: "validation-error"; errors?: string[]; } | { kind?: "if-match-failed"; path?: string; expected?: { kind?: "any"; } | { kind?: "absent"; } | { kind?: "version"; token?: string; }; }
```

### WatchEvent

```ts
type WatchEvent = { kind?: "changed"; commitId?: string; paths?: string[]; } | { kind?: "resync"; reason?: string; }
```

### SyncInResult

```ts
type SyncInResult = { kind?: "up-to-date"; } | { kind?: "applied"; commitId?: string; paths?: string[]; } | { kind?: "diverged"; reason?: string; } | { kind?: "auth-error"; reason?: string; } | { kind?: "not-found"; reason?: string; } | { kind?: "network-error"; reason?: string; retriable?: boolean; }
```

## Interfaces

### DocStore

```ts
interface DocStore
```

- `read: (path: string) => Promise<ReadResult>` — Read a single document. Returns missing if absent — never throws.
- `list: (prefix: string) => Promise<ReadonlyArray<DocEntry>>` — Recursive list of `prefix` (empty string lists root). Returns empty
array if prefix doesn't exist — never throws.
- `runTransaction: (tx: Transaction) => Promise<TransactionResult>` — Run a transaction. All mutations apply or none do (atomic).
Result is a discriminated union; caller branches with ts-pattern.
- `watch: (prefix: string, cb: (event: WatchEvent) => void) => () => void` — Subscribe to remote-driven changes under `prefix`. Returns the
unsubscribe fn. The callback fires when a sync-in applies commits
that touch matching paths. Local writes do NOT echo through watch.
- `syncIn: () => Promise<SyncInResult>` — Force a pull-then-emit-watches cycle. UI "refresh" affordance.
- `drain: () => Promise<void>` — Wait for any internal queueing to settle. Tests call this after a
series of fire-and-forget runTransaction() to await completion.

## Constants

### ReadResultSchema

```ts
const ReadResultSchema: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{ kind: z.ZodLiteral<"found">; path: z.ZodString; content: z.ZodString; versionToken: z.ZodString; }, "strip", z.ZodTypeAny, { kind?: "found"; path?: string; content?: string; versionToken?: string; }, { kind?: "found"; path?: string; content?: string; versionToken?: string; }>, z.ZodObject<{ kind: z.ZodLiteral<"missing">; path: z.ZodString; }, "strip", z.ZodTypeAny, { kind?: "missing"; path?: string; }, { kind?: "missing"; path?: string; }>]>
```

### DocEntrySchema

```ts
const DocEntrySchema: z.ZodObject<{ path: z.ZodString; type: z.ZodEnum<["doc", "dir"]>; versionToken: z.ZodString; }, "strip", z.ZodTypeAny, { path?: string; type?: "doc" | "dir"; versionToken?: string; }, { path?: string; type?: "doc" | "dir"; versionToken?: string; }>
```

### IfMatchSchema

```ts
const IfMatchSchema: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{ kind: z.ZodLiteral<"any">; }, "strip", z.ZodTypeAny, { kind?: "any"; }, { kind?: "any"; }>, z.ZodObject<{ kind: z.ZodLiteral<"absent">; }, "strip", z.ZodTypeAny, { kind?: "absent"; }, { kind?: "absent"; }>, z.ZodObject<{ kind: z.ZodLiteral<"version">; token: z.ZodString; }, "strip", z.ZodTypeAny, { kind?: "version"; token?: string; }, { kind?: "version"; token?: string; }>]>
```

### JsonPatchOpSchema

```ts
const JsonPatchOpSchema: z.ZodDiscriminatedUnion<"op", [z.ZodObject<{ op: z.ZodLiteral<"add">; path: z.ZodString; value: z.ZodType<JsonValue, z.ZodTypeDef, JsonValue>; }, "strip", z.ZodTypeAny, { value?: JsonValue; path?: string; op?: "add"; }, { value?: JsonValue; path?: string; op?: "add"; }>, z.ZodObject<{ op: z.ZodLiteral<"remove">; path: z.ZodString; }, "strip", z.ZodTypeAny, { path?: string; op?: "remove"; }, { path?: string; op?: "remove"; }>, z.ZodObject<{ op: z.ZodLiteral<"replace">; path: z.ZodString; value: z.ZodType<JsonValue, z.ZodTypeDef, JsonValue>; }, "strip", z.ZodTypeAny, { value?: JsonValue; path?: string; op?: "replace"; }, { value?: JsonValue; path?: string; op?: "replace"; }>, z.ZodObject<{ op: z.ZodLiteral<"test">; path: z.ZodString; value: z.ZodType<JsonValue, z.ZodTypeDef, JsonValue>; }, "strip", z.ZodTypeAny, { value?: JsonValue; path?: string; op?: "test"; }, { value?: JsonValue; path?: string; op?: "test"; }>]>
```

### FrontmatterBodySchema

```ts
const FrontmatterBodySchema: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{ kind: z.ZodLiteral<"preserve">; }, "strip", z.ZodTypeAny, { kind?: "preserve"; }, { kind?: "preserve"; }>, z.ZodObject<{ kind: z.ZodLiteral<"replace">; value: z.ZodString; }, "strip", z.ZodTypeAny, { kind?: "replace"; value?: string; }, { kind?: "replace"; value?: string; }>]>
```

### IfMissingSchema

```ts
const IfMissingSchema: z.ZodEnum<["create-empty", "fail"]>
```

### MutationSchema

```ts
const MutationSchema: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{ kind: z.ZodLiteral<"put">; path: z.ZodString; content: z.ZodString; ifMatch: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{ kind: z.ZodLiteral<"any">; }, "strip", z.ZodTypeAny, { kind?: "any"; }, { kind?: "any"; }>, z.ZodObject<{ kind: z.ZodLiteral<"absent">; }, "strip", z.ZodTypeAny, { kind?: "absent"; }, { kind?: "absent"; }>, z.ZodObject<{ kind: z.ZodLiteral<"version">; token: z.ZodString; }, "strip", z.ZodTypeAny, { kind?: "version"; token?: string; }, { kind?: "version"; token?: string; }>]>; }, "strip", z.ZodTypeAny, { kind?: "put"; path?: string; content?: string; ifMatch?: { kind?: "any"; } | { kind?: "absent"; } | { kind?: "version"; token?: string; }; }, { kind?: "put"; path?: string; content?: string; ifMatch?: { kind?: "any"; } | { kind?: "absent"; } | { kind?: "version"; token?: string; }; }>, z.ZodObject<{ kind: z.ZodLiteral<"delete">; path: z.ZodString; ifMatch: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{ kind: z.ZodLiteral<"any">; }, "strip", z.ZodTypeAny, { kind?: "any"; }, { kind?: "any"; }>, z.ZodObject<{ kind: z.ZodLiteral<"absent">; }, "strip", z.ZodTypeAny, { kind?: "absent"; }, { kind?: "absent"; }>, z.ZodObject<{ kind: z.ZodLiteral<"version">; token: z.ZodString; }, "strip", z.ZodTypeAny, { kind?: "version"; token?: string; }, { kind?: "version"; token?: string; }>]>; }, "strip", z.ZodTypeAny, { kind?: "delete"; path?: string; ifMatch?: { kind?: "any"; } | { kind?: "absent"; } | { kind?: "version"; token?: string; }; }, { kind?: "delete"; path?: string; ifMatch?: { kind?: "any"; } | { kind?: "absent"; } | { kind?: "version"; token?: string; }; }>, z.ZodObject<{ kind: z.ZodLiteral<"json-patch">; path: z.ZodString; ops: z.ZodArray<z.ZodDiscriminatedUnion<"op", [z.ZodObject<{ op: z.ZodLiteral<"add">; path: z.ZodString; value: z.ZodType<JsonValue, z.ZodTypeDef, JsonValue>; }, "strip", z.ZodTypeAny, { value?: JsonValue; path?: string; op?: "add"; }, { value?: JsonValue; path?: string; op?: "add"; }>, z.ZodObject<{ op: z.ZodLiteral<"remove">; path: z.ZodString; }, "strip", z.ZodTypeAny, { path?: string; op?: "remove"; }, { path?: string; op?: "remove"; }>, z.ZodObject<{ op: z.ZodLiteral<"replace">; path: z.ZodString; value: z.ZodType<JsonValue, z.ZodTypeDef, JsonValue>; }, "strip", z.ZodTypeAny, { value?: JsonValue; path?: string; op?: "replace"; }, { value?: JsonValue; path?: string; op?: "replace"; }>, z.ZodObject<{ op: z.ZodLiteral<"test">; path: z.ZodString; value: z.ZodType<JsonValue, z.ZodTypeDef, JsonValue>; }, "strip", z.ZodTypeAny, { value?: JsonValue; path?: string; op?: "test"; }, { value?: JsonValue; path?: string; op?: "test"; }>]>, "many">; ifMissing: z.ZodEnum<["create-empty", "fail"]>; ifMatch: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{ kind: z.ZodLiteral<"any">; }, "strip", z.ZodTypeAny, { kind?: "any"; }, { kind?: "any"; }>, z.ZodObject<{ kind: z.ZodLiteral<"absent">; }, "strip", z.ZodTypeAny, { kind?: "absent"; }, { kind?: "absent"; }>, z.ZodObject<{ kind: z.ZodLiteral<"version">; token: z.ZodString; }, "strip", z.ZodTypeAny, { kind?: "version"; token?: string; }, { kind?: "version"; token?: string; }>]>; }, "strip", z.ZodTypeAny, { kind?: "json-patch"; path?: string; ifMatch?: { kind?: "any"; } | { kind?: "absent"; } | { kind?: "version"; token?: string; }; ops?: ({ value?: JsonValue; path?: string; op?: "add"; } | { path?: string; op?: "remove"; } | { value?: JsonValue; path?: string; op?: "replace"; } | { value?: JsonValue; path?: string; op?: "test"; })[]; ifMissing?: "create-empty" | "fail"; }, { kind?: "json-patch"; path?: string; ifMatch?: { kind?: "any"; } | { kind?: "absent"; } | { kind?: "version"; token?: string; }; ops?: ({ value?: JsonValue; path?: string; op?: "add"; } | { path?: string; op?: "remove"; } | { value?: JsonValue; path?: string; op?: "replace"; } | { value?: JsonValue; path?: string; op?: "test"; })[]; ifMissing?: "create-empty" | "fail"; }>, z.ZodObject<{ kind: z.ZodLiteral<"upsert-frontmatter">; path: z.ZodString; set: z.ZodRecord<z.ZodString, z.ZodUnknown>; body: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{ kind: z.ZodLiteral<"preserve">; }, "strip", z.ZodTypeAny, { kind?: "preserve"; }, { kind?: "preserve"; }>, z.ZodObject<{ kind: z.ZodLiteral<"replace">; value: z.ZodString; }, "strip", z.ZodTypeAny, { kind?: "replace"; value?: string; }, { kind?: "replace"; value?: string; }>]>; ifMatch: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{ kind: z.ZodLiteral<"any">; }, "strip", z.ZodTypeAny, { kind?: "any"; }, { kind?: "any"; }>, z.ZodObject<{ kind: z.ZodLiteral<"absent">; }, "strip", z.ZodTypeAny, { kind?: "absent"; }, { kind?: "absent"; }>, z.ZodObject<{ kind: z.ZodLiteral<"version">; token: z.ZodString; }, "strip", z.ZodTypeAny, { kind?: "version"; token?: string; }, { kind?: "version"; token?: string; }>]>; }, "strip", z.ZodTypeAny, { kind?: "upsert-frontmatter"; path?: string; set?: Record<string, unknown>; ifMatch?: { kind?: "any"; } | { kind?: "absent"; } | { kind?: "version"; token?: string; }; body?: { kind?: "preserve"; } | { kind?: "replace"; value?: string; }; }, { kind?: "upsert-frontmatter"; path?: string; set?: Record<string, unknown>; ifMatch?: { kind?: "any"; } | { kind?: "absent"; } | { kind?: "version"; token?: string; }; body?: { kind?: "preserve"; } | { kind?: "replace"; value?: string; }; }>]>
```

### ConflictPolicySchema

```ts
const ConflictPolicySchema: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{ kind: z.ZodLiteral<"fail">; }, "strip", z.ZodTypeAny, { kind?: "fail"; }, { kind?: "fail"; }>, z.ZodObject<{ kind: z.ZodLiteral<"retry-after-pull">; maxAttempts: z.ZodNumber; }, "strip", z.ZodTypeAny, { kind?: "retry-after-pull"; maxAttempts?: number; }, { kind?: "retry-after-pull"; maxAttempts?: number; }>, z.ZodObject<{ kind: z.ZodLiteral<"rebase-mutations">; maxAttempts: z.ZodNumber; }, "strip", z.ZodTypeAny, { kind?: "rebase-mutations"; maxAttempts?: number; }, { kind?: "rebase-mutations"; maxAttempts?: number; }>]>
```

### TransactionSchema

```ts
const TransactionSchema: z.ZodObject<{ mutations: z.ZodArray<z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{ kind: z.ZodLiteral<"put">; path: z.ZodString; content: z.ZodString; ifMatch: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{ kind: z.ZodLiteral<"any">; }, "strip", z.ZodTypeAny, { kind?: "any"; }, { kind?: "any"; }>, z.ZodObject<{ kind: z.ZodLiteral<"absent">; }, "strip", z.ZodTypeAny, { kind?: "absent"; }, { kind?: "absent"; }>, z.ZodObject<{ kind: z.ZodLiteral<"version">; token: z.ZodString; }, "strip", z.ZodTypeAny, { kind?: "version"; token?: string; }, { kind?: "version"; token?: string; }>]>; }, "strip", z.ZodTypeAny, { kind?: "put"; path?: string; content?: string; ifMatch?: { kind?: "any"; } | { kind?: "absent"; } | { kind?: "version"; token?: string; }; }, { kind?: "put"; path?: string; content?: string; ifMatch?: { kind?: "any"; } | { kind?: "absent"; } | { kind?: "version"; token?: string; }; }>, z.ZodObject<{ kind: z.ZodLiteral<"delete">; path: z.ZodString; ifMatch: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{ kind: z.ZodLiteral<"any">; }, "strip", z.ZodTypeAny, { kind?: "any"; }, { kind?: "any"; }>, z.ZodObject<{ kind: z.ZodLiteral<"absent">; }, "strip", z.ZodTypeAny, { kind?: "absent"; }, { kind?: "absent"; }>, z.ZodObject<{ kind: z.ZodLiteral<"version">; token: z.ZodString; }, "strip", z.ZodTypeAny, { kind?: "version"; token?: string; }, { kind?: "version"; token?: string; }>]>; }, "strip", z.ZodTypeAny, { kind?: "delete"; path?: string; ifMatch?: { kind?: "any"; } | { kind?: "absent"; } | { kind?: "version"; token?: string; }; }, { kind?: "delete"; path?: string; ifMatch?: { kind?: "any"; } | { kind?: "absent"; } | { kind?: "version"; token?: string; }; }>, z.ZodObject<{ kind: z.ZodLiteral<"json-patch">; path: z.ZodString; ops: z.ZodArray<z.ZodDiscriminatedUnion<"op", [z.ZodObject<{ op: z.ZodLiteral<"add">; path: z.ZodString; value: z.ZodType<JsonValue, z.ZodTypeDef, JsonValue>; }, "strip", z.ZodTypeAny, { value?: JsonValue; path?: string; op?: "add"; }, { value?: JsonValue; path?: string; op?: "add"; }>, z.ZodObject<{ op: z.ZodLiteral<"remove">; path: z.ZodString; }, "strip", z.ZodTypeAny, { path?: string; op?: "remove"; }, { path?: string; op?: "remove"; }>, z.ZodObject<{ op: z.ZodLiteral<"replace">; path: z.ZodString; value: z.ZodType<JsonValue, z.ZodTypeDef, JsonValue>; }, "strip", z.ZodTypeAny, { value?: JsonValue; path?: string; op?: "replace"; }, { value?: JsonValue; path?: string; op?: "replace"; }>, z.ZodObject<{ op: z.ZodLiteral<"test">; path: z.ZodString; value: z.ZodType<JsonValue, z.ZodTypeDef, JsonValue>; }, "strip", z.ZodTypeAny, { value?: JsonValue; path?: string; op?: "test"; }, { value?: JsonValue; path?: string; op?: "test"; }>]>, "many">; ifMissing: z.ZodEnum<["create-empty", "fail"]>; ifMatch: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{ kind: z.ZodLiteral<"any">; }, "strip", z.ZodTypeAny, { kind?: "any"; }, { kind?: "any"; }>, z.ZodObject<{ kind: z.ZodLiteral<"absent">; }, "strip", z.ZodTypeAny, { kind?: "absent"; }, { kind?: "absent"; }>, z.ZodObject<{ kind: z.ZodLiteral<"version">; token: z.ZodString; }, "strip", z.ZodTypeAny, { kind?: "version"; token?: string; }, { kind?: "version"; token?: string; }>]>; }, "strip", z.ZodTypeAny, { kind?: "json-patch"; path?: string; ifMatch?: { kind?: "any"; } | { kind?: "absent"; } | { kind?: "version"; token?: string; }; ops?: ({ value?: JsonValue; path?: string; op?: "add"; } | { path?: string; op?: "remove"; } | { value?: JsonValue; path?: string; op?: "replace"; } | { value?: JsonValue; path?: string; op?: "test"; })[]; ifMissing?: "create-empty" | "fail"; }, { kind?: "json-patch"; path?: string; ifMatch?: { kind?: "any"; } | { kind?: "absent"; } | { kind?: "version"; token?: string; }; ops?: ({ value?: JsonValue; path?: string; op?: "add"; } | { path?: string; op?: "remove"; } | { value?: JsonValue; path?: string; op?: "replace"; } | { value?: JsonValue; path?: string; op?: "test"; })[]; ifMissing?: "create-empty" | "fail"; }>, z.ZodObject<{ kind: z.ZodLiteral<"upsert-frontmatter">; path: z.ZodString; set: z.ZodRecord<z.ZodString, z.ZodUnknown>; body: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{ kind: z.ZodLiteral<"preserve">; }, "strip", z.ZodTypeAny, { kind?: "preserve"; }, { kind?: "preserve"; }>, z.ZodObject<{ kind: z.ZodLiteral<"replace">; value: z.ZodString; }, "strip", z.ZodTypeAny, { kind?: "replace"; value?: string; }, { kind?: "replace"; value?: string; }>]>; ifMatch: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{ kind: z.ZodLiteral<"any">; }, "strip", z.ZodTypeAny, { kind?: "any"; }, { kind?: "any"; }>, z.ZodObject<{ kind: z.ZodLiteral<"absent">; }, "strip", z.ZodTypeAny, { kind?: "absent"; }, { kind?: "absent"; }>, z.ZodObject<{ kind: z.ZodLiteral<"version">; token: z.ZodString; }, "strip", z.ZodTypeAny, { kind?: "version"; token?: string; }, { kind?: "version"; token?: string; }>]>; }, "strip", z.ZodTypeAny, { kind?: "upsert-frontmatter"; path?: string; set?: Record<string, unknown>; ifMatch?: { kind?: "any"; } | { kind?: "absent"; } | { kind?: "version"; token?: string; }; body?: { kind?: "preserve"; } | { kind?: "replace"; value?: string; }; }, { kind?: "upsert-frontmatter"; path?: string; set?: Record<string, unknown>; ifMatch?: { kind?: "any"; } | { kind?: "absent"; } | { kind?: "version"; token?: string; }; body?: { kind?: "preserve"; } | { kind?: "replace"; value?: string; }; }>]>, "many">; message: z.ZodString; onConflict: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{ kind: z.ZodLiteral<"fail">; }, "strip", z.ZodTypeAny, { kind?: "fail"; }, { kind?: "fail"; }>, z.ZodObject<{ kind: z.ZodLiteral<"retry-after-pull">; maxAttempts: z.ZodNumber; }, "strip", z.ZodTypeAny, { kind?: "retry-after-pull"; maxAttempts?: number; }, { kind?: "retry-after-pull"; maxAttempts?: number; }>, z.ZodObject<{ kind: z.ZodLiteral<"rebase-mutations">; maxAttempts: z.ZodNumber; }, "strip", z.ZodTypeAny, { kind?: "rebase-mutations"; maxAttempts?: number; }, { kind?: "rebase-mutations"; maxAttempts?: number; }>]>; }, "strip", z.ZodTypeAny, { message?: string; mutations?: ({ kind?: "put"; path?: string; content?: string; ifMatch?: { kind?: "any"; } | { kind?: "absent"; } | { kind?: "version"; token?: string; }; } | { kind?: "delete"; path?: string; ifMatch?: { kind?: "any"; } | { kind?: "absent"; } | { kind?: "version"; token?: string; }; } | { kind?: "json-patch"; path?: string; ifMatch?: { kind?: "any"; } | { kind?: "absent"; } | { kind?: "version"; token?: string; }; ops?: ({ value?: JsonValue; path?: string; op?: "add"; } | { path?: string; op?: "remove"; } | { value?: JsonValue; path?: string; op?: "replace"; } | { value?: JsonValue; path?: string; op?: "test"; })[]; ifMissing?: "create-empty" | "fail"; } | { kind?: "upsert-frontmatter"; path?: string; set?: Record<string, unknown>; ifMatch?: { kind?: "any"; } | { kind?: "absent"; } | { kind?: "version"; token?: string; }; body?: { kind?: "preserve"; } | { kind?: "replace"; value?: string; }; })[]; onConflict?: { kind?: "fail"; } | { kind?: "retry-after-pull"; maxAttempts?: number; } | { kind?: "rebase-mutations"; maxAttempts?: number; }; }, { message?: string; mutations?: ({ kind?: "put"; path?: string; content?: string; ifMatch?: { kind?: "any"; } | { kind?: "absent"; } | { kind?: "version"; token?: string; }; } | { kind?: "delete"; path?: string; ifMatch?: { kind?: "any"; } | { kind?: "absent"; } | { kind?: "version"; token?: string; }; } | { kind?: "json-patch"; path?: string; ifMatch?: { kind?: "any"; } | { kind?: "absent"; } | { kind?: "version"; token?: string; }; ops?: ({ value?: JsonValue; path?: string; op?: "add"; } | { path?: string; op?: "remove"; } | { value?: JsonValue; path?: string; op?: "replace"; } | { value?: JsonValue; path?: string; op?: "test"; })[]; ifMissing?: "create-empty" | "fail"; } | { kind?: "upsert-frontmatter"; path?: string; set?: Record<string, unknown>; ifMatch?: { kind?: "any"; } | { kind?: "absent"; } | { kind?: "version"; token?: string; }; body?: { kind?: "preserve"; } | { kind?: "replace"; value?: string; }; })[]; onConflict?: { kind?: "fail"; } | { kind?: "retry-after-pull"; maxAttempts?: number; } | { kind?: "rebase-mutations"; maxAttempts?: number; }; }>
```

### TransactionResultSchema

```ts
const TransactionResultSchema: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{ kind: z.ZodLiteral<"committed">; commitId: z.ZodString; }, "strip", z.ZodTypeAny, { kind?: "committed"; commitId?: string; }, { kind?: "committed"; commitId?: string; }>, z.ZodObject<{ kind: z.ZodLiteral<"conflict">; conflictingPaths: z.ZodArray<z.ZodString, "many">; }, "strip", z.ZodTypeAny, { kind?: "conflict"; conflictingPaths?: string[]; }, { kind?: "conflict"; conflictingPaths?: string[]; }>, z.ZodObject<{ kind: z.ZodLiteral<"auth-error">; reason: z.ZodString; }, "strip", z.ZodTypeAny, { kind?: "auth-error"; reason?: string; }, { kind?: "auth-error"; reason?: string; }>, z.ZodObject<{ kind: z.ZodLiteral<"not-found">; reason: z.ZodString; }, "strip", z.ZodTypeAny, { kind?: "not-found"; reason?: string; }, { kind?: "not-found"; reason?: string; }>, z.ZodObject<{ kind: z.ZodLiteral<"network-error">; retriable: z.ZodBoolean; reason: z.ZodString; }, "strip", z.ZodTypeAny, { kind?: "network-error"; reason?: string; retriable?: boolean; }, { kind?: "network-error"; reason?: string; retriable?: boolean; }>, z.ZodObject<{ kind: z.ZodLiteral<"validation-error">; errors: z.ZodArray<z.ZodString, "many">; }, "strip", z.ZodTypeAny, { kind?: "validation-error"; errors?: string[]; }, { kind?: "validation-error"; errors?: string[]; }>, z.ZodObject<{ kind: z.ZodLiteral<"if-match-failed">; path: z.ZodString; expected: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{ kind: z.ZodLiteral<"any">; }, "strip", z.ZodTypeAny, { kind?: "any"; }, { kind?: "any"; }>, z.ZodObject<{ kind: z.ZodLiteral<"absent">; }, "strip", z.ZodTypeAny, { kind?: "absent"; }, { kind?: "absent"; }>, z.ZodObject<{ kind: z.ZodLiteral<"version">; token: z.ZodString; }, "strip", z.ZodTypeAny, { kind?: "version"; token?: string; }, { kind?: "version"; token?: string; }>]>; }, "strip", z.ZodTypeAny, { kind?: "if-match-failed"; path?: string; expected?: { kind?: "any"; } | { kind?: "absent"; } | { kind?: "version"; token?: string; }; }, { kind?: "if-match-failed"; path?: string; expected?: { kind?: "any"; } | { kind?: "absent"; } | { kind?: "version"; token?: string; }; }>]>
```

### WatchEventSchema

```ts
const WatchEventSchema: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{ kind: z.ZodLiteral<"changed">; paths: z.ZodArray<z.ZodString, "many">; commitId: z.ZodString; }, "strip", z.ZodTypeAny, { kind?: "changed"; commitId?: string; paths?: string[]; }, { kind?: "changed"; commitId?: string; paths?: string[]; }>, z.ZodObject<{ kind: z.ZodLiteral<"resync">; reason: z.ZodString; }, "strip", z.ZodTypeAny, { kind?: "resync"; reason?: string; }, { kind?: "resync"; reason?: string; }>]>
```

### SyncInResultSchema

```ts
const SyncInResultSchema: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{ kind: z.ZodLiteral<"up-to-date">; }, "strip", z.ZodTypeAny, { kind?: "up-to-date"; }, { kind?: "up-to-date"; }>, z.ZodObject<{ kind: z.ZodLiteral<"applied">; paths: z.ZodArray<z.ZodString, "many">; commitId: z.ZodString; }, "strip", z.ZodTypeAny, { kind?: "applied"; commitId?: string; paths?: string[]; }, { kind?: "applied"; commitId?: string; paths?: string[]; }>, z.ZodObject<{ kind: z.ZodLiteral<"diverged">; reason: z.ZodString; }, "strip", z.ZodTypeAny, { kind?: "diverged"; reason?: string; }, { kind?: "diverged"; reason?: string; }>, z.ZodObject<{ kind: z.ZodLiteral<"auth-error">; reason: z.ZodString; }, "strip", z.ZodTypeAny, { kind?: "auth-error"; reason?: string; }, { kind?: "auth-error"; reason?: string; }>, z.ZodObject<{ kind: z.ZodLiteral<"not-found">; reason: z.ZodString; }, "strip", z.ZodTypeAny, { kind?: "not-found"; reason?: string; }, { kind?: "not-found"; reason?: string; }>, z.ZodObject<{ kind: z.ZodLiteral<"network-error">; retriable: z.ZodBoolean; reason: z.ZodString; }, "strip", z.ZodTypeAny, { kind?: "network-error"; reason?: string; retriable?: boolean; }, { kind?: "network-error"; reason?: string; retriable?: boolean; }>]>
```
