git-fs-s3 0.4.0 → 0.5.0

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.
Files changed (62) hide show
  1. package/README.md +23 -17
  2. package/dist/{chunk-Z4656PGE.js → chunk-2JP4MS6H.js} +2 -2
  3. package/dist/{chunk-YQFNY6PG.js → chunk-FIFWOMPM.js} +1 -1
  4. package/dist/chunk-FIFWOMPM.js.map +1 -0
  5. package/dist/http.js +3 -3
  6. package/dist/http.js.map +1 -1
  7. package/dist/index.js +2 -3
  8. package/dist/index.js.map +1 -1
  9. package/dist/ops.js +2 -2
  10. package/dist/types/cache.d.ts +81 -0
  11. package/dist/types/edge-utils.d.ts +43 -0
  12. package/dist/types/errors.d.ts +16 -0
  13. package/dist/types/git-errors.d.ts +70 -0
  14. package/dist/types/git-fs.d.ts +60 -0
  15. package/dist/types/git-layout.d.ts +52 -0
  16. package/dist/types/http/index.d.ts +7 -0
  17. package/dist/types/http/info-refs.d.ts +27 -0
  18. package/dist/types/http/pack-reuse.d.ts +26 -0
  19. package/dist/types/http/pkt-line.d.ts +14 -0
  20. package/dist/types/http/reachability.d.ts +36 -0
  21. package/dist/types/http/receive-pack.d.ts +54 -0
  22. package/dist/types/http/repack.d.ts +24 -0
  23. package/dist/types/http/types.d.ts +40 -0
  24. package/dist/types/http/upload-pack.d.ts +21 -0
  25. package/dist/types/index.d.ts +11 -0
  26. package/dist/types/ops/branch.d.ts +38 -0
  27. package/dist/types/ops/commit.d.ts +45 -0
  28. package/dist/types/ops/diff.d.ts +24 -0
  29. package/dist/types/ops/file-history.d.ts +41 -0
  30. package/dist/types/ops/history.d.ts +85 -0
  31. package/dist/types/ops/index.d.ts +9 -0
  32. package/dist/types/ops/last-commit.d.ts +23 -0
  33. package/dist/types/ops/merge.d.ts +28 -0
  34. package/dist/types/ops/tree.d.ts +19 -0
  35. package/dist/{types-BHoHOaQt.d.cts → types/ops/types.d.ts} +7 -9
  36. package/dist/types/pack-files.d.ts +28 -0
  37. package/dist/types/path.d.ts +9 -0
  38. package/dist/types/refs.d.ts +54 -0
  39. package/dist/types/retry.d.ts +52 -0
  40. package/dist/types/stores/memory.d.ts +16 -0
  41. package/dist/{s3.d.ts → types/stores/s3.d.ts} +4 -7
  42. package/dist/{types-dbHzZ4ed.d.ts → types/types.d.ts} +11 -22
  43. package/package.json +18 -22
  44. package/dist/chunk-YQFNY6PG.js.map +0 -1
  45. package/dist/http.cjs +0 -1063
  46. package/dist/http.cjs.map +0 -1
  47. package/dist/http.d.cts +0 -215
  48. package/dist/http.d.ts +0 -215
  49. package/dist/index.cjs +0 -944
  50. package/dist/index.cjs.map +0 -1
  51. package/dist/index.d.cts +0 -479
  52. package/dist/index.d.ts +0 -479
  53. package/dist/ops.cjs +0 -1060
  54. package/dist/ops.cjs.map +0 -1
  55. package/dist/ops.d.cts +0 -302
  56. package/dist/ops.d.ts +0 -302
  57. package/dist/s3.cjs +0 -123
  58. package/dist/s3.cjs.map +0 -1
  59. package/dist/s3.d.cts +0 -36
  60. package/dist/types-BHoHOaQt.d.ts +0 -53
  61. package/dist/types-dbHzZ4ed.d.cts +0 -131
  62. /package/dist/{chunk-Z4656PGE.js.map → chunk-2JP4MS6H.js.map} +0 -0
package/dist/http.d.ts DELETED
@@ -1,215 +0,0 @@
1
- import { R as Repo } from './types-BHoHOaQt.js';
2
- import 'isomorphic-git';
3
-
4
- /**
5
- * Transport-agnostic HTTP response the handlers produce.
6
- *
7
- * `body` is pinned to `Uint8Array<ArrayBuffer>` (not the bare `Uint8Array`,
8
- * whose default type argument isn't consistent across TypeScript versions)
9
- * so it's always assignable to Fetch API `BodyInit` regardless of which
10
- * TypeScript/lib version a consumer compiles against — every producer here
11
- * (`concat`, `pktLine`, `TextEncoder.encode`) is ArrayBuffer-backed already.
12
- */
13
- interface GitHttpResult {
14
- status: number;
15
- headers: Record<string, string>;
16
- body: Uint8Array<ArrayBuffer>;
17
- }
18
- /** Optional instrumentation hooks shared by the /http handlers. */
19
- interface HttpHooks {
20
- /** Wrap a timed sub-step. Default: run directly. */
21
- step?: <T>(label: string, fn: () => Promise<T>) => Promise<T>;
22
- /** Non-fatal problem sink (missing objects, failed repacks). */
23
- onWarn?: (message: string, error?: unknown) => void;
24
- }
25
- /**
26
- * The raw promise-fs surface some /http paths need beyond isomorphic-git's
27
- * plumbing (writing an incoming pack file, listing/deleting pack files).
28
- * Both `node:fs` and this package's `GitFs` satisfy it via `.promises`.
29
- */
30
- interface RawFsPromises {
31
- readFile(path: string): Promise<Uint8Array | string>;
32
- writeFile(path: string, data: Uint8Array | string): Promise<void>;
33
- unlink(path: string): Promise<void>;
34
- readdir(path: string): Promise<string[]>;
35
- mkdir(path: string, options?: {
36
- recursive?: boolean;
37
- }): Promise<unknown>;
38
- stat(path: string): Promise<unknown>;
39
- }
40
- /** Duck-type the `.promises` surface off a repo's fs. */
41
- declare function rawFs(repo: Repo): RawFsPromises;
42
-
43
- type GitService = "git-upload-pack" | "git-receive-pack";
44
- /** All refs with resolved oids, plus the symref HEAD should advertise. */
45
- declare function listAllRefs(repo: Repo, defaultBranch?: string): Promise<{
46
- refs: {
47
- name: string;
48
- oid: string;
49
- }[];
50
- headSymref: string;
51
- }>;
52
- interface InfoRefsOptions {
53
- service: GitService;
54
- defaultBranch?: string;
55
- /** Advertised in the agent capability. Default "git-fs-s3". */
56
- agent?: string;
57
- }
58
- /**
59
- * `GET …/info/refs?service=…` — the ref advertisement. Authentication and
60
- * authorization are the caller's job before invoking this.
61
- *
62
- * Capabilities advertised match what the sibling handlers implement:
63
- * side-band-64k (honored by handleUploadPack's response framing — clients
64
- * like isomorphic-git unconditionally expect it), tip/reachable sha1 wants,
65
- * delete-refs and report-status for pushes.
66
- */
67
- declare function handleInfoRefs(repo: Repo, options: InfoRefsOptions, hooks?: HttpHooks): Promise<GitHttpResult>;
68
-
69
- /**
70
- * Git pkt-line framing (smart HTTP protocol wire format).
71
- *
72
- * Edge-compatible: uses Uint8Array instead of Buffer.
73
- */
74
- /** Flush packet: exactly four zero bytes. */
75
- declare const FLUSH: Uint8Array<ArrayBuffer>;
76
- /** Frame a UTF-8 string as one pkt-line. */
77
- declare function pktLine(data: string): Uint8Array<ArrayBuffer>;
78
- /** Frame raw bytes as one pkt-line. */
79
- declare function pktLineBuffer(body: Uint8Array): Uint8Array<ArrayBuffer>;
80
- /** Decode pkt-lines to strings; `null` marks a flush-pkt. Stops on garbage. */
81
- declare function parsePktLines(buf: Uint8Array): Array<string | null>;
82
- declare function sideBandPackfile(packData: Uint8Array): Uint8Array<ArrayBuffer>;
83
-
84
- interface ReachabilityResult {
85
- oids: string[];
86
- /**
87
- * False if any object in the graph couldn't be read — repack uses this
88
- * (not a raw object-count comparison) to decide whether it's safe to
89
- * delete old packs: counts alone can't distinguish "everything read fine"
90
- * from "some objects silently failed".
91
- */
92
- complete: boolean;
93
- }
94
- /**
95
- * Walk the object graph from `startOids`, returning every reachable oid.
96
- * Concurrent traversal paths are deduplicated promise-per-oid; a missing
97
- * object is retried once, then reported through `hooks.onWarn` and
98
- * reflected in `complete: false`.
99
- *
100
- * `haveOids` bounds the walk: any oid in this set is assumed already
101
- * verified (it was reachable from a ref that existed before this call) and
102
- * is recorded in `seen` without being read or descended into. Without a
103
- * boundary, every call re-walks the *entire* history from scratch — for
104
- * receive-pack validation (see receive-pack.ts) that means every push pays
105
- * for reading every object in the repo, not just the ones it introduced,
106
- * and one transient read failure anywhere in that whole history rejects an
107
- * otherwise-valid push.
108
- *
109
- * Commits, trees and tags are read once each (parsed). Blobs have no
110
- * children, so `verifyBlobs: false` records a blob from its tree entry
111
- * without reading (and inflating) it — for callers that read every blob
112
- * themselves afterwards anyway, like upload-pack's `packObjects`. Leave it
113
- * true wherever the walk *is* the existence check (receive-pack, repack).
114
- */
115
- declare function collectReachableOids(repo: Repo, startOids: string[], hooks?: HttpHooks, haveOids?: ReadonlySet<string> | readonly string[], options?: {
116
- verifyBlobs?: boolean;
117
- }): Promise<ReachabilityResult>;
118
-
119
- /**
120
- * Pack consolidation: merge all packs into one, reusing stored (possibly
121
- * deltified) entries when every object is packed.
122
- *
123
- * Edge-compatible: uses Web Crypto (SHA-1), CompressionStream (deflate),
124
- * and Uint8Array throughout — no node:crypto, node:zlib, or Buffer.
125
- */
126
-
127
- /**
128
- * Default repack threshold. Consolidating is O(total repo object count) —
129
- * so paying it on every push makes push latency grow with repo size forever.
130
- */
131
- declare const REPACK_PACK_COUNT_THRESHOLD = 4;
132
- interface RepackOptions {
133
- /** Skip repacking below this many accumulated packs. Default 4. */
134
- threshold?: number;
135
- }
136
- /**
137
- * Consolidate all pack files into one, returning the gitdir-relative paths
138
- * of the old .pack/.idx files it removed — after syncing the new pack to any
139
- * secondary storage, delete those same paths there too.
140
- */
141
- declare function repackRepository(repo: Repo, options?: RepackOptions, hooks?: HttpHooks): Promise<string[]>;
142
-
143
- interface RefUpdateCommand {
144
- oldOid: string;
145
- newOid: string;
146
- refName: string;
147
- }
148
- interface RefUpdateResult {
149
- refName: string;
150
- ok: boolean;
151
- reason?: string;
152
- }
153
- /** Split a receive-pack body: pkt-line ref commands, flush, then raw PACK. */
154
- declare function parseReceivePackBody(body: Uint8Array): {
155
- refUpdates: RefUpdateCommand[];
156
- packData: Uint8Array;
157
- };
158
- /** Initialize the repo when its HEAD doesn't exist yet (first push). */
159
- declare function ensureRepoInitialized(repo: Repo, defaultBranch?: string): Promise<void>;
160
- /** Write the incoming PACK into objects/pack/ and index it. */
161
- declare function indexIncomingPack(repo: Repo, packData: Uint8Array, hooks?: HttpHooks): Promise<string[]>;
162
- /**
163
- * Apply ref updates, enforcing compare-and-swap against each command's
164
- * claimed oldOid. Every client-supplied refName is validated before any
165
- * filesystem call reads or writes through it.
166
- */
167
- declare function applyRefUpdates(repo: Repo, refUpdates: RefUpdateCommand[], hooks?: HttpHooks): Promise<RefUpdateResult[]>;
168
- /** The report-status response body for a set of ref-update results. */
169
- declare function receivePackResponse(results: RefUpdateResult[]): GitHttpResult;
170
- interface ApplyReceivePackOptions {
171
- defaultBranch?: string;
172
- /**
173
- * Repack tuning, or `false` to skip repacking entirely. The returned
174
- * `stalePackPaths` are gitdir-relative pack files the repack deleted from
175
- * this repo — after syncing to any secondary storage, delete them there
176
- * too.
177
- */
178
- repack?: RepackOptions | false;
179
- }
180
- /**
181
- * The storage half of a push against `repo`: initialize if needed, index the
182
- * incoming pack, CAS-apply ref updates, then repack when enough packs have
183
- * accumulated. Serialize concurrent pushes to the same repo externally (a
184
- * per-repo lock); build the HTTP response afterwards with
185
- * {@link receivePackResponse}.
186
- */
187
- declare function applyReceivePack(repo: Repo, parsed: {
188
- refUpdates: RefUpdateCommand[];
189
- packData: Uint8Array;
190
- }, options?: ApplyReceivePackOptions, hooks?: HttpHooks): Promise<{
191
- results: RefUpdateResult[];
192
- stalePackPaths: string[];
193
- }>;
194
-
195
- interface UploadPackOptions {
196
- /**
197
- * Called once before the reachability walk — wire loose-object detection
198
- * (`GitFs.detectLooseObjects`) here so a fully packed repo's walk doesn't
199
- * pay a doomed loose-object probe per object.
200
- */
201
- beforeWalk?: () => Promise<void>;
202
- }
203
- /**
204
- * `POST …/git-upload-pack` — serve a clone/fetch. Authorization is the
205
- * caller's job. Negotiation is client-driven (no multi_ack advertised):
206
- * "have" batches without "done" get a bare NAK; the final batch gets the
207
- * packfile, side-band-64k framed.
208
- *
209
- * Fast path: a fresh clone (no haves) of a repo consolidated down to a
210
- * single pack serves that pack's bytes directly — skipping the O(objects)
211
- * traversal + repack entirely.
212
- */
213
- declare function handleUploadPack(repo: Repo, body: Uint8Array, options?: UploadPackOptions, hooks?: HttpHooks): Promise<GitHttpResult>;
214
-
215
- export { type ApplyReceivePackOptions, FLUSH, type GitHttpResult, type GitService, type HttpHooks, type InfoRefsOptions, REPACK_PACK_COUNT_THRESHOLD, type RawFsPromises, type ReachabilityResult, type RefUpdateCommand, type RefUpdateResult, type RepackOptions, type UploadPackOptions, applyReceivePack, applyRefUpdates, collectReachableOids, ensureRepoInitialized, handleInfoRefs, handleUploadPack, indexIncomingPack, listAllRefs, parsePktLines, parseReceivePackBody, pktLine, pktLineBuffer, rawFs, receivePackResponse, repackRepository, sideBandPackfile };