Files
patch-db/client/lib/types.ts
Matt Hill 86b0768bbb audit fixes, repo restructure, and documentation
Soundness and performance audit (17 fixes):
- See AUDIT.md for full details and @claude comments in code

Repo restructure:
- Inline json-ptr and json-patch submodules as regular directories
- Remove cbor submodule, replace serde_cbor with ciborium
- Rename patch-db/ -> core/, patch-db-macro/ -> macro/,
  patch-db-macro-internals/ -> macro-internals/, patch-db-util/ -> util/
- Purge upstream CI/CD, bench, and release cruft from json-patch
- Remove .gitmodules

Test fixes:
- Fix proptest doesnt_crash (unique file paths, proper close/cleanup)
- Add PatchDb::close() for clean teardown

Documentation:
- Add README.md, ARCHITECTURE.md, CONTRIBUTING.md, CLAUDE.md, AUDIT.md
- Add TSDocs to TypeScript client exports

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 19:06:42 -07:00

38 lines
1.0 KiB
TypeScript

import { Operation } from './json-patch-lib'
/**
* An incremental state change. Contains the revision number and the
* RFC 6902 patch operations needed to transition from the previous state.
*/
export type Revision = {
/** Monotonically increasing revision number. */
id: number
/** The patch operations that produce this revision from the previous one. */
patch: Operation<unknown>[]
}
/**
* A complete snapshot of the database state at a given revision.
*
* @typeParam T - The shape of the stored document.
*/
export type Dump<T> = { id: number; value: T }
/**
* A server message: either a full {@link Dump} (snapshot) or an incremental {@link Revision} (patch).
*
* @typeParam T - The shape of the stored document.
*/
export type Update<T> = Revision | Dump<T>
/**
* The three JSON Patch operation types produced by patch-db.
*
* Only `add`, `remove`, and `replace` are used — `test`, `move`, and `copy` are not produced by the server.
*/
export enum PatchOp {
ADD = 'add',
REMOVE = 'remove',
REPLACE = 'replace',
}