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.
@@ -0,0 +1,121 @@
1
+ /**
2
+ * Minimal key/value object-storage contract the git filesystem is built on.
3
+ *
4
+ * Implement this interface to back git with any storage system. Two
5
+ * implementations ship with the package: {@link ../stores/memory.MemoryObjectStore}
6
+ * and {@link ../stores/s3.S3ObjectStore}.
7
+ */
8
+ interface ObjectStore {
9
+ /** Return the object's bytes, or `null` if the key does not exist. */
10
+ get(key: string): Promise<Uint8Array | null>;
11
+ /** Create or overwrite the object at `key`. */
12
+ put(key: string, data: Uint8Array): Promise<void>;
13
+ /** Delete the object at `key`. Must succeed silently if it does not exist. */
14
+ delete(key: string): Promise<void>;
15
+ /** Return object metadata without fetching the body, or `null` if absent. */
16
+ head(key: string): Promise<ObjectStat | null>;
17
+ /**
18
+ * List keys under `prefix`.
19
+ *
20
+ * With `delimiter: "/"` the result groups keys the way S3 ListObjectsV2
21
+ * does: `objects` holds direct children, `prefixes` holds the common
22
+ * prefixes ("subdirectories"). With `limit`, implementations may return
23
+ * early after finding that many entries (used for cheap existence checks).
24
+ */
25
+ list(prefix: string, options?: ListOptions): Promise<ListResult>;
26
+ }
27
+ interface ObjectStat {
28
+ size: number;
29
+ }
30
+ interface ListOptions {
31
+ delimiter?: string;
32
+ limit?: number;
33
+ }
34
+ interface ListResult {
35
+ objects: {
36
+ key: string;
37
+ size: number;
38
+ }[];
39
+ prefixes: string[];
40
+ }
41
+ /** Options accepted by {@link ../git-fs.createGitFs}. */
42
+ interface GitFsOptions {
43
+ /**
44
+ * Key prefix all paths are stored under, e.g. `"repos/alice/blog"`.
45
+ * Defaults to `""` (paths map directly to keys).
46
+ */
47
+ prefix?: string;
48
+ /**
49
+ * Track, per git directory, whether any loose objects exist at all.
50
+ * Fully packed repositories then skip the doomed round trip probing a
51
+ * loose-object path that is guaranteed to miss — but only after an
52
+ * explicit `detectLooseObjects(gitdir)` call has registered the gitdir.
53
+ * Default false.
54
+ */
55
+ looseObjectHints?: boolean;
56
+ /**
57
+ * Paths (relative to the fs, before `prefix` is applied) that are known
58
+ * never to exist; `readFile`/`stat` answer ENOENT for them with zero
59
+ * store calls. Useful for files git probes on every operation but this
60
+ * backend never writes, such as `packed-refs` or `shallow` under a known
61
+ * gitdir layout. Match precisely — a plain suffix check is wrong, since
62
+ * e.g. `refs/heads/packed-refs` is a legal branch ref.
63
+ */
64
+ isStructurallyAbsent?: (path: string) => boolean;
65
+ /** Time-to-live for loose-object hints in milliseconds. Default 3 600 000. */
66
+ hintTtlMs?: number;
67
+ /** Diagnostic sink for notable fs events (hint detection results). */
68
+ onNote?: (message: string) => void;
69
+ }
70
+ type Encoding = "utf8";
71
+ interface ReadFileOptions {
72
+ encoding?: Encoding;
73
+ }
74
+ interface WriteFileOptions {
75
+ encoding?: Encoding;
76
+ mode?: number;
77
+ }
78
+ /**
79
+ * The stat shape isomorphic-git expects. Object storage has no inodes,
80
+ * owners, or modification times, so numeric fields are zero.
81
+ */
82
+ interface Stat {
83
+ type: "file" | "dir";
84
+ mode: number;
85
+ size: number;
86
+ ino: number;
87
+ mtimeMs: number;
88
+ ctimeMs: number;
89
+ uid: number;
90
+ gid: number;
91
+ dev: number;
92
+ mtime: Date;
93
+ ctime: Date;
94
+ isFile(): boolean;
95
+ isDirectory(): boolean;
96
+ isSymbolicLink(): boolean;
97
+ }
98
+ /**
99
+ * Promise-based filesystem client compatible with isomorphic-git's `fs`
100
+ * option. Declared locally so the package has no dependency on
101
+ * isomorphic-git itself.
102
+ */
103
+ interface GitFsClient {
104
+ promises: {
105
+ readFile(filepath: string, options?: ReadFileOptions | Encoding): Promise<Uint8Array | string>;
106
+ writeFile(filepath: string, data: Uint8Array | string, options?: WriteFileOptions | Encoding): Promise<void>;
107
+ unlink(filepath: string): Promise<void>;
108
+ readdir(dirpath: string): Promise<string[]>;
109
+ mkdir(dirpath: string, options?: {
110
+ mode?: number;
111
+ }): Promise<void>;
112
+ rmdir(dirpath: string): Promise<void>;
113
+ stat(filepath: string): Promise<Stat>;
114
+ lstat(filepath: string): Promise<Stat>;
115
+ readlink(filepath: string): Promise<never>;
116
+ symlink(target: string, filepath: string): Promise<never>;
117
+ chmod(filepath: string, mode: number): Promise<void>;
118
+ };
119
+ }
120
+
121
+ export type { GitFsClient as G, ListOptions as L, ObjectStore as O, Stat as S, GitFsOptions as a, ObjectStat as b, ListResult as c };
@@ -0,0 +1,121 @@
1
+ /**
2
+ * Minimal key/value object-storage contract the git filesystem is built on.
3
+ *
4
+ * Implement this interface to back git with any storage system. Two
5
+ * implementations ship with the package: {@link ../stores/memory.MemoryObjectStore}
6
+ * and {@link ../stores/s3.S3ObjectStore}.
7
+ */
8
+ interface ObjectStore {
9
+ /** Return the object's bytes, or `null` if the key does not exist. */
10
+ get(key: string): Promise<Uint8Array | null>;
11
+ /** Create or overwrite the object at `key`. */
12
+ put(key: string, data: Uint8Array): Promise<void>;
13
+ /** Delete the object at `key`. Must succeed silently if it does not exist. */
14
+ delete(key: string): Promise<void>;
15
+ /** Return object metadata without fetching the body, or `null` if absent. */
16
+ head(key: string): Promise<ObjectStat | null>;
17
+ /**
18
+ * List keys under `prefix`.
19
+ *
20
+ * With `delimiter: "/"` the result groups keys the way S3 ListObjectsV2
21
+ * does: `objects` holds direct children, `prefixes` holds the common
22
+ * prefixes ("subdirectories"). With `limit`, implementations may return
23
+ * early after finding that many entries (used for cheap existence checks).
24
+ */
25
+ list(prefix: string, options?: ListOptions): Promise<ListResult>;
26
+ }
27
+ interface ObjectStat {
28
+ size: number;
29
+ }
30
+ interface ListOptions {
31
+ delimiter?: string;
32
+ limit?: number;
33
+ }
34
+ interface ListResult {
35
+ objects: {
36
+ key: string;
37
+ size: number;
38
+ }[];
39
+ prefixes: string[];
40
+ }
41
+ /** Options accepted by {@link ../git-fs.createGitFs}. */
42
+ interface GitFsOptions {
43
+ /**
44
+ * Key prefix all paths are stored under, e.g. `"repos/alice/blog"`.
45
+ * Defaults to `""` (paths map directly to keys).
46
+ */
47
+ prefix?: string;
48
+ /**
49
+ * Track, per git directory, whether any loose objects exist at all.
50
+ * Fully packed repositories then skip the doomed round trip probing a
51
+ * loose-object path that is guaranteed to miss — but only after an
52
+ * explicit `detectLooseObjects(gitdir)` call has registered the gitdir.
53
+ * Default false.
54
+ */
55
+ looseObjectHints?: boolean;
56
+ /**
57
+ * Paths (relative to the fs, before `prefix` is applied) that are known
58
+ * never to exist; `readFile`/`stat` answer ENOENT for them with zero
59
+ * store calls. Useful for files git probes on every operation but this
60
+ * backend never writes, such as `packed-refs` or `shallow` under a known
61
+ * gitdir layout. Match precisely — a plain suffix check is wrong, since
62
+ * e.g. `refs/heads/packed-refs` is a legal branch ref.
63
+ */
64
+ isStructurallyAbsent?: (path: string) => boolean;
65
+ /** Time-to-live for loose-object hints in milliseconds. Default 3 600 000. */
66
+ hintTtlMs?: number;
67
+ /** Diagnostic sink for notable fs events (hint detection results). */
68
+ onNote?: (message: string) => void;
69
+ }
70
+ type Encoding = "utf8";
71
+ interface ReadFileOptions {
72
+ encoding?: Encoding;
73
+ }
74
+ interface WriteFileOptions {
75
+ encoding?: Encoding;
76
+ mode?: number;
77
+ }
78
+ /**
79
+ * The stat shape isomorphic-git expects. Object storage has no inodes,
80
+ * owners, or modification times, so numeric fields are zero.
81
+ */
82
+ interface Stat {
83
+ type: "file" | "dir";
84
+ mode: number;
85
+ size: number;
86
+ ino: number;
87
+ mtimeMs: number;
88
+ ctimeMs: number;
89
+ uid: number;
90
+ gid: number;
91
+ dev: number;
92
+ mtime: Date;
93
+ ctime: Date;
94
+ isFile(): boolean;
95
+ isDirectory(): boolean;
96
+ isSymbolicLink(): boolean;
97
+ }
98
+ /**
99
+ * Promise-based filesystem client compatible with isomorphic-git's `fs`
100
+ * option. Declared locally so the package has no dependency on
101
+ * isomorphic-git itself.
102
+ */
103
+ interface GitFsClient {
104
+ promises: {
105
+ readFile(filepath: string, options?: ReadFileOptions | Encoding): Promise<Uint8Array | string>;
106
+ writeFile(filepath: string, data: Uint8Array | string, options?: WriteFileOptions | Encoding): Promise<void>;
107
+ unlink(filepath: string): Promise<void>;
108
+ readdir(dirpath: string): Promise<string[]>;
109
+ mkdir(dirpath: string, options?: {
110
+ mode?: number;
111
+ }): Promise<void>;
112
+ rmdir(dirpath: string): Promise<void>;
113
+ stat(filepath: string): Promise<Stat>;
114
+ lstat(filepath: string): Promise<Stat>;
115
+ readlink(filepath: string): Promise<never>;
116
+ symlink(target: string, filepath: string): Promise<never>;
117
+ chmod(filepath: string, mode: number): Promise<void>;
118
+ };
119
+ }
120
+
121
+ export type { GitFsClient as G, ListOptions as L, ObjectStore as O, Stat as S, GitFsOptions as a, ObjectStat as b, ListResult as c };
package/package.json ADDED
@@ -0,0 +1,104 @@
1
+ {
2
+ "name": "git-fs-s3",
3
+ "version": "0.3.5",
4
+ "description": "isomorphic-git filesystem backend for S3-compatible object storage (AWS S3, Cloudflare R2, MinIO) — run git servers without a disk",
5
+ "type": "module",
6
+ "exports": {
7
+ ".": {
8
+ "types": "./dist/index.d.ts",
9
+ "import": "./dist/index.js",
10
+ "require": "./dist/index.cjs"
11
+ },
12
+ "./s3": {
13
+ "types": "./dist/s3.d.ts",
14
+ "import": "./dist/s3.js",
15
+ "require": "./dist/s3.cjs"
16
+ },
17
+ "./ops": {
18
+ "types": "./dist/ops.d.ts",
19
+ "import": "./dist/ops.js",
20
+ "require": "./dist/ops.cjs"
21
+ },
22
+ "./http": {
23
+ "types": "./dist/http.d.ts",
24
+ "import": "./dist/http.js",
25
+ "require": "./dist/http.cjs"
26
+ }
27
+ },
28
+ "files": [
29
+ "dist"
30
+ ],
31
+ "sideEffects": false,
32
+ "scripts": {
33
+ "build": "tsup",
34
+ "test": "vitest run",
35
+ "test:watch": "vitest",
36
+ "coverage": "vitest run --coverage",
37
+ "typecheck": "tsc --noEmit",
38
+ "lint": "biome check src/ test/",
39
+ "lint:fix": "biome check --write src/ test/",
40
+ "format": "biome format --write src/ test/",
41
+ "prepublishOnly": "npm run typecheck && npm test && npm run build"
42
+ },
43
+ "keywords": [
44
+ "git",
45
+ "isomorphic-git",
46
+ "s3",
47
+ "r2",
48
+ "cloudflare-r2",
49
+ "object-storage",
50
+ "serverless",
51
+ "git-server",
52
+ "filesystem",
53
+ "fs"
54
+ ],
55
+ "author": "Nandan Varma",
56
+ "license": "MIT",
57
+ "repository": {
58
+ "type": "git",
59
+ "url": "git+https://github.com/nandan-varma/git-fs-s3.git"
60
+ },
61
+ "bugs": {
62
+ "url": "https://github.com/nandan-varma/git-fs-s3/issues"
63
+ },
64
+ "homepage": "https://github.com/nandan-varma/git-fs-s3#readme",
65
+ "publishConfig": {
66
+ "access": "public"
67
+ },
68
+ "engines": {
69
+ "node": ">=18"
70
+ },
71
+ "dependencies": {
72
+ "lru-cache": "^11.2.1"
73
+ },
74
+ "peerDependencies": {
75
+ "@aws-sdk/client-s3": ">=3.0.0",
76
+ "isomorphic-git": ">=1.24.0",
77
+ "diff": ">=5.0.0"
78
+ },
79
+ "peerDependenciesMeta": {
80
+ "@aws-sdk/client-s3": {
81
+ "optional": true
82
+ },
83
+ "isomorphic-git": {
84
+ "optional": true
85
+ },
86
+ "diff": {
87
+ "optional": true
88
+ }
89
+ },
90
+ "devDependencies": {
91
+ "@aws-sdk/client-s3": "^3.750.0",
92
+ "@biomejs/biome": "^2.3.8",
93
+ "@types/node": "^22.15.21",
94
+ "isomorphic-git": "^1.27.0",
95
+ "tsup": "^8.5.0",
96
+ "typescript": "^5.8.3",
97
+ "vitest": "^3.2.3",
98
+ "diff": "^7.0.0",
99
+ "@types/diff": "^7.0.0"
100
+ },
101
+ "allowScripts": {
102
+ "esbuild@0.27.7": true
103
+ }
104
+ }