git-fs-s3 0.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/ops.d.ts ADDED
@@ -0,0 +1,290 @@
1
+ import { R as Repo, O as OpsHooks } from './types-BHoHOaQt.js';
2
+ export { I as IsoGitFs, a as ResultCache, r as resultKeyPrefixes } from './types-BHoHOaQt.js';
3
+ import * as git from 'isomorphic-git';
4
+
5
+ interface Branch {
6
+ name: string;
7
+ commit: string;
8
+ isDefault: boolean;
9
+ }
10
+ /**
11
+ * Defense in depth for every branch-name argument below: `git.deleteBranch`
12
+ * and raw resolveRef/writeRef reads don't validate ref names internally the
13
+ * way `git.branch` does (see refs.ts) — guard at the point the primitives are
14
+ * actually called, not just at an API boundary far above.
15
+ */
16
+ declare function assertSafeBranchName(name: string): void;
17
+ /** All branches with their tip commits; [] for an empty repository. */
18
+ declare function listBranches(repo: Repo): Promise<Branch[]>;
19
+ /** Create `name` pointing at the tip of `startPoint` (no checkout). */
20
+ declare function createBranchFrom(repo: Repo, name: string, startPoint?: string): Promise<void>;
21
+ /** Delete a branch ref (validated — deleteBranch has no internal ref check). */
22
+ declare function deleteBranchByName(repo: Repo, name: string): Promise<void>;
23
+ /** Throws (NotFoundError) unless the branch resolves. */
24
+ declare function assertBranchExists(repo: Repo, name: string): Promise<void>;
25
+
26
+ interface CommitAuthor {
27
+ name: string;
28
+ email: string;
29
+ timestamp: number;
30
+ timezoneOffset: number;
31
+ }
32
+ /** An author stamped with the current time. */
33
+ declare function authorNow(name: string, email: string): CommitAuthor;
34
+ /**
35
+ * Write a commit directly to a bare repository — no worktree, no checkout.
36
+ * `buildTree` receives the parent commit's tree oid (undefined on an empty
37
+ * repo / unborn branch) and returns the new root tree oid; this function
38
+ * writes the commit object and force-updates `refs/heads/<branch>`.
39
+ *
40
+ * Serialize concurrent writers externally (a per-repo lock): the
41
+ * resolve-ref → write-ref sequence is not atomic on object storage.
42
+ */
43
+ declare function writeCommitToBare(repo: Repo, options: {
44
+ branch: string;
45
+ message: string;
46
+ author: CommitAuthor;
47
+ buildTree: (parentTreeOid: string | undefined) => Promise<string>;
48
+ }): Promise<string>;
49
+ /**
50
+ * Commit a set of files onto a branch, straight to the bare repo. Each blob
51
+ * is written to its own content-addressed key — no shared state between
52
+ * files, so they're written in parallel.
53
+ */
54
+ declare function commitFilesToBare(repo: Repo, options: {
55
+ branch: string;
56
+ message: string;
57
+ author: CommitAuthor;
58
+ files: Array<{
59
+ path: string;
60
+ content: string | Uint8Array;
61
+ }>;
62
+ }): Promise<string>;
63
+ /** Commit the removal of one file from a branch, straight to the bare repo. */
64
+ declare function deleteFileFromBare(repo: Repo, options: {
65
+ branch: string;
66
+ filePath: string;
67
+ message: string;
68
+ author: CommitAuthor;
69
+ }): Promise<string>;
70
+
71
+ interface DiffFile {
72
+ path: string;
73
+ status: "added" | "modified" | "deleted" | "renamed";
74
+ additions: number;
75
+ deletions: number;
76
+ patch: string;
77
+ oldPath?: string;
78
+ isBinary?: boolean;
79
+ oldContent?: string;
80
+ newContent?: string;
81
+ oldSize?: number;
82
+ newSize?: number;
83
+ }
84
+ interface DiffResult {
85
+ files: DiffFile[];
86
+ totalAdditions: number;
87
+ totalDeletions: number;
88
+ totalFiles: number;
89
+ }
90
+ /** The diff a single commit introduced (against its first parent). */
91
+ declare function getCommitDiff(repo: Repo, commitSha: string): Promise<DiffResult>;
92
+ /** The diff between two refs (base -> compare). */
93
+ declare function getDiffBetweenRefs(repo: Repo, baseRef: string, compareRef: string): Promise<DiffResult>;
94
+
95
+ interface FileHistoryEntry {
96
+ sha: string;
97
+ message: string;
98
+ authorName: string;
99
+ authorEmail: string;
100
+ createdAt: string;
101
+ }
102
+ interface FileHistoryResult {
103
+ entries: FileHistoryEntry[];
104
+ /**
105
+ * True when the walk hit its depth budget (or the requested `limit`)
106
+ * before exhausting the branch's full commit chain — there may be older
107
+ * commits touching this file that a deeper walk would surface.
108
+ */
109
+ truncated: boolean;
110
+ }
111
+ /**
112
+ * Default walk bound for a caller that actually wants deep history (a file's
113
+ * "History" tab). Walking the full chain is round-trip-bound on object
114
+ * storage, so cap how far back a single request will look.
115
+ */
116
+ declare const HISTORY_WALK_DEPTH = 400;
117
+ /**
118
+ * Much shallower default for a "latest commit touching this file" banner that
119
+ * only displays `entries[0]` — trades "always finds the true last-touching
120
+ * commit" for "finds it if it's reasonably recent", the right call for a
121
+ * banner with a full History view a click away.
122
+ */
123
+ declare const BANNER_WALK_DEPTH = 60;
124
+ /**
125
+ * All commits (newest first) that changed a single file's blob oid, walking
126
+ * the first-parent chain — same approach as getLastCommitsForTree but for one
127
+ * path and collecting every match instead of stopping at the first.
128
+ */
129
+ declare function getFileHistory(repo: Repo, options: {
130
+ ref: string;
131
+ filePath: string;
132
+ limit?: number;
133
+ maxDepth?: number;
134
+ }, hooks?: OpsHooks): Promise<FileHistoryResult>;
135
+
136
+ interface TreeEntry {
137
+ path: string;
138
+ mode: string;
139
+ type: "blob" | "tree";
140
+ oid: string;
141
+ size?: number;
142
+ }
143
+ /**
144
+ * Build/update a git tree by overlaying new blobs onto an existing tree,
145
+ * returning the new root tree oid. `entries` maps relative paths to blob oids.
146
+ */
147
+ declare function upsertTree(repo: Repo, treeOid: string | undefined, entries: Map<string, string>): Promise<string>;
148
+ /** Remove a file path from a tree, returning the new root tree oid. */
149
+ declare function deleteFromTree(repo: Repo, treeOid: string, filePath: string): Promise<string>;
150
+ /** Resolve a path inside a tree to its entry, or null when absent. */
151
+ declare function findTreeEntry(repo: Repo, rootTreeOid: string, treePath: string): Promise<TreeEntry | null>;
152
+ /** List a tree's direct entries, with paths prefixed by `prefix`. */
153
+ declare function listTreeEntries(repo: Repo, treeOid: string, prefix?: string): Promise<TreeEntry[]>;
154
+
155
+ interface CommitInfo {
156
+ oid: string;
157
+ commit: {
158
+ message: string;
159
+ tree: string;
160
+ parent: string[];
161
+ author: {
162
+ name: string;
163
+ email: string;
164
+ timestamp: number;
165
+ timezoneOffset: number;
166
+ };
167
+ committer: {
168
+ name: string;
169
+ email: string;
170
+ timestamp: number;
171
+ timezoneOffset: number;
172
+ };
173
+ };
174
+ payload: string;
175
+ }
176
+ /**
177
+ * Resolve a branch name / full ref / sha to its commit. The ref not
178
+ * resolving (unborn branch, genuinely empty repo) and the ref resolving but
179
+ * its commit object being unreadable (storage inconsistency — see
180
+ * `wrapMissingObject` above) are different failures with different meanings,
181
+ * so only the first is left as a raw isomorphic-git NotFoundError for
182
+ * callers to treat as "empty"; the second is wrapped into
183
+ * GitObjectNotFoundError specifically so it can't be mistaken for the first
184
+ * by an `isNotFound`-style check downstream (see getTreeFromRef/getCommitLog).
185
+ */
186
+ declare function resolveCommit(repo: Repo, ref: string): Promise<{
187
+ oid: string;
188
+ commit: git.CommitObject;
189
+ }>;
190
+ /** Read a blob's bytes by oid. */
191
+ declare function getBlob(repo: Repo, sha: string): Promise<Uint8Array>;
192
+ /** Read a file's bytes at a ref. Throws GitPathNotFoundError when absent. */
193
+ declare function getFileContent(repo: Repo, filePath: string, ref?: string): Promise<Uint8Array>;
194
+ /** Read one commit by sha. */
195
+ declare function getCommit(repo: Repo, sha: string): Promise<CommitInfo>;
196
+ interface CommitLogOptions {
197
+ ref?: string;
198
+ depth?: number;
199
+ /**
200
+ * Pass the head sha when the caller already resolved `ref` — resolveRef
201
+ * tries several candidate paths in sequence and misses the first few every
202
+ * time for a normal branch name, which is pure waste when the sha is known.
203
+ */
204
+ knownHeadSha?: string;
205
+ }
206
+ /**
207
+ * The commit chain from a ref, newest first. Walking is inherently sequential
208
+ * (each commit's oid is only discoverable by reading its child first) and
209
+ * network-round-trip-bound against object storage, so the deepest walk seen
210
+ * per head is memoized in `hooks.resultCache` and sliced for shallower or
211
+ * repeated requests — don't bypass this by calling `git.log` directly.
212
+ */
213
+ declare function getCommitLog(repo: Repo, options?: CommitLogOptions, hooks?: OpsHooks): Promise<CommitInfo[]>;
214
+ /** A file at a ref, decoded for display: utf8 text or base64 when binary. */
215
+ declare function getFileFromRef(repo: Repo, filePath: string, ref: string): Promise<{
216
+ content: string;
217
+ size: number;
218
+ isBinary: boolean;
219
+ }>;
220
+ /**
221
+ * List a directory at the tip of a ref. Returns [] for an empty repo/unborn
222
+ * branch; throws GitPathNotFoundError when `treePath` doesn't exist. Results
223
+ * are memoized per head sha (auto-invalidates on push).
224
+ */
225
+ declare function getTreeFromRef(repo: Repo, options?: {
226
+ ref?: string;
227
+ treePath?: string;
228
+ }, hooks?: OpsHooks): Promise<TreeEntry[]>;
229
+ /**
230
+ * A page of commit history from a branch tip. Memoized per head sha; builds
231
+ * on {@link getCommitLog}'s walk cache for the underlying chain.
232
+ */
233
+ declare function getCommitHistory(repo: Repo, options: {
234
+ ref: string;
235
+ limit?: number;
236
+ skip?: number;
237
+ }, hooks?: OpsHooks): Promise<CommitInfo[]>;
238
+
239
+ interface LastCommitInfo {
240
+ sha: string;
241
+ message: string;
242
+ authorName: string;
243
+ authorEmail: string;
244
+ createdAt: string;
245
+ }
246
+ /**
247
+ * For each direct child of `treePath` (at the tip of `ref`), find the most
248
+ * recent commit that changed it — the tree view's "last commit" column. Walks
249
+ * history newest-to-oldest, comparing the directory's tree oid
250
+ * commit-to-commit and only descending one level to diff child oids when
251
+ * something under the directory actually changed. Preserve the two-phase
252
+ * structure (parallel prefetch, then sequential resolve) when touching this —
253
+ * the "which entries are still unresolved" state must advance
254
+ * commit-by-commit.
255
+ */
256
+ declare function getLastCommitsForTree(repo: Repo, options: {
257
+ ref: string;
258
+ treePath?: string;
259
+ depth?: number;
260
+ }, hooks?: OpsHooks): Promise<Record<string, LastCommitInfo>>;
261
+
262
+ interface MergeAnalysis {
263
+ canMerge: boolean;
264
+ hasConflicts: boolean;
265
+ conflictingFiles: string[];
266
+ fastForward: boolean;
267
+ }
268
+ /**
269
+ * Cheap pre-merge check: do both branches exist, and is this a fast-forward?
270
+ * `canMerge`/`fastForward` are the only fields this actually determines —
271
+ * `hasConflicts`/`conflictingFiles` are NOT a real content-conflict check
272
+ * (isomorphic-git's `git.merge` doesn't expose a dry-run), they only ever
273
+ * reflect "one of the branches couldn't be resolved" (`canMerge: false`).
274
+ * Real merge conflicts are only discoverable by actually attempting the
275
+ * merge.
276
+ */
277
+ declare function analyzeMerge(repo: Repo, sourceBranch: string, targetBranch: string): Promise<MergeAnalysis>;
278
+ /**
279
+ * Attempt a fast-forward merge directly against the bare repo: when source is
280
+ * a descendant of target, just move the target ref — no worktree, no new
281
+ * commit. Returns null when the merge is not a fast-forward (callers fall
282
+ * back to a real three-way merge, which needs a worktree). Serialize with a
283
+ * per-repo lock: resolve → writeRef is not atomic.
284
+ */
285
+ declare function fastForwardMerge(repo: Repo, sourceBranch: string, targetBranch: string): Promise<{
286
+ success: true;
287
+ commitSha: string;
288
+ } | null>;
289
+
290
+ export { BANNER_WALK_DEPTH, type Branch, type CommitAuthor, type CommitInfo, type CommitLogOptions, type DiffFile, type DiffResult, type FileHistoryEntry, type FileHistoryResult, HISTORY_WALK_DEPTH, type LastCommitInfo, type MergeAnalysis, OpsHooks, Repo, type TreeEntry, analyzeMerge, assertBranchExists, assertSafeBranchName, authorNow, commitFilesToBare, createBranchFrom, deleteBranchByName, deleteFileFromBare, deleteFromTree, fastForwardMerge, findTreeEntry, getBlob, getCommit, getCommitDiff, getCommitHistory, getCommitLog, getDiffBetweenRefs, getFileContent, getFileFromRef, getFileHistory, getLastCommitsForTree, getTreeFromRef, listBranches, listTreeEntries, resolveCommit, upsertTree, writeCommitToBare };