import { ModuleFilePath, PatchId, SerializedSchema } from "@valbuild/core"; import { Operation } from "@valbuild/core/patch"; type AuthorId = string; type IsoDateString = string; export type PatchMetadata = { patchId: PatchId; patchPath: PatchPath; opType: Operation["op"]; schemaTypes: Array; author: AuthorId | null; createdAt: IsoDateString; }; export type PatchSetMetadata = { moduleFilePath: ModuleFilePath; patchPath: PatchPath; patches: PatchMetadata[]; authors: AuthorId[]; opTypes: Operation["op"][]; schemaTypes: Array; lastUpdated: IsoDateString; lastUpdatedBy: AuthorId | null; }; /** * A patch set is a set of patches that are non-independent of each other. This is useful for example when we want to apply a set of patches atomically. * A patch set is identified by a module file path and a json patch path delimited by a '?' character. We call this the patch set path. Example: /file/name.val.ts?/path/to/patch * * * NOTE: the order of patch sets is always newest first. This is because the UX always shows the newest patches first. */ export type SerializedPatchSet = PatchSetMetadata[]; type PatchPath = string[]; /** * Is `inner` strictly nested inside the patch set `outer`? * * A plain `inner.startsWith(outer)` is not enough, and the difference is not * cosmetic. The file part of a key is terminated by the '?' delimiter, but the * segments of the patch path are not terminated by anything, so a raw prefix * test also matches siblings whose *name* merely starts with the same * characters: '/p.val.ts?foobar/title' starts with '/p.val.ts?foo', so removing * record key "foo" and retitling record key "foobar" would be merged into one * patch set. * * That used to only over-group two unrelated changes in the compare view. Now * that patch sets decide what moves between branches as one (whole patch sets, * as `changesToMove` moves them), it means moving one key silently moves its * similarly-named sibling — so the boundary has to be * checked explicitly: '?' when `outer` is a bare module file path, '/' when it * already has a patch path. */ export declare function isInsidePatchSetPath(inner: string, outer: string): boolean; export declare class PatchSets { private insertedPatches; private patchSetMetadata; private orderedInsertKeys; constructor(); reset(): void; getInsertedPatches(): Set; private insertPath; /** * Insert a whole patch. * * Takes the patch rather than one op because the de-duplication below is * per-*patch*: a patch is either known to this instance or it is not. When this * took a single op, callers looped and every call after the first hit the * `insertedPatches` guard and returned — so only a patch's first op ever reached * a patch set. A patch that touched two places (a `move`, or a `file` op sitting * before its source op) was therefore mis-grouped, which is invisible in the * compare view but decides what moves as one. */ insert(moduleFilePath: ModuleFilePath, schema: SerializedSchema | undefined, patch: Operation[], patchId: PatchId, createdAt: IsoDateString, author: AuthorId | null): void; private insertOp; isInserted(patchId: PatchId): boolean; serialize(): SerializedPatchSet; } export {};