mirror of
https://github.com/Start9Labs/patch-db.git
synced 2026-03-26 18:31:53 +00:00
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>
38 lines
1.0 KiB
TypeScript
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',
|
|
}
|