browser-git-ops 0.0.1 → 0.0.4
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/README.md +80 -107
- package/dist/git/abstractAdapter.d.ts +183 -0
- package/dist/git/abstractAdapter.d.ts.map +1 -0
- package/dist/git/adapter.d.ts +23 -1
- package/dist/git/adapter.d.ts.map +1 -1
- package/dist/git/githubAdapter.d.ts +354 -35
- package/dist/git/githubAdapter.d.ts.map +1 -1
- package/dist/git/gitlabAdapter.d.ts +297 -20
- package/dist/git/gitlabAdapter.d.ts.map +1 -1
- package/dist/index.d.ts +7 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6336 -13
- package/dist/index.js.map +7 -0
- package/dist/index.mjs +6312 -0
- package/dist/index.mjs.map +7 -0
- package/dist/virtualfs/changeTracker.d.ts +66 -0
- package/dist/virtualfs/changeTracker.d.ts.map +1 -0
- package/dist/virtualfs/conflictManager.d.ts +69 -0
- package/dist/virtualfs/conflictManager.d.ts.map +1 -0
- package/dist/virtualfs/hashUtils.d.ts +13 -0
- package/dist/virtualfs/hashUtils.d.ts.map +1 -0
- package/dist/virtualfs/indexManager.d.ts +57 -0
- package/dist/virtualfs/indexManager.d.ts.map +1 -0
- package/dist/virtualfs/indexedDatabaseStorage.d.ts +7 -0
- package/dist/virtualfs/indexedDatabaseStorage.d.ts.map +1 -0
- package/dist/virtualfs/inmemoryStorage.d.ts +8 -0
- package/dist/virtualfs/inmemoryStorage.d.ts.map +1 -0
- package/dist/virtualfs/localChangeApplier.d.ts +21 -0
- package/dist/virtualfs/localChangeApplier.d.ts.map +1 -0
- package/dist/virtualfs/localFileManager.d.ts +58 -0
- package/dist/virtualfs/localFileManager.d.ts.map +1 -0
- package/dist/virtualfs/metadataManager.d.ts +18 -0
- package/dist/virtualfs/metadataManager.d.ts.map +1 -0
- package/dist/virtualfs/opfsStorage.d.ts +5 -0
- package/dist/virtualfs/opfsStorage.d.ts.map +1 -0
- package/dist/virtualfs/remoteSynchronizer.d.ts +192 -0
- package/dist/virtualfs/remoteSynchronizer.d.ts.map +1 -0
- package/dist/virtualfs/storageBackend.d.ts +97 -0
- package/dist/virtualfs/storageBackend.d.ts.map +1 -0
- package/dist/virtualfs/types.d.ts +37 -0
- package/dist/virtualfs/types.d.ts.map +1 -1
- package/dist/virtualfs/virtualfs.d.ts +294 -90
- package/dist/virtualfs/virtualfs.d.ts.map +1 -1
- package/package.json +39 -10
- package/dist/git/adapter.js +0 -2
- package/dist/git/githubAdapter.js +0 -179
- package/dist/git/gitlabAdapter.js +0 -182
- package/dist/test/e2e/github.spec.d.ts +0 -2
- package/dist/test/e2e/github.spec.d.ts.map +0 -1
- package/dist/test/e2e/github.spec.js +0 -47
- package/dist/test/e2e/gitlab.spec.d.ts +0 -2
- package/dist/test/e2e/gitlab.spec.d.ts.map +0 -1
- package/dist/test/e2e/gitlab.spec.js +0 -34
- package/dist/test/e2e/virtualfs.spec.d.ts +0 -2
- package/dist/test/e2e/virtualfs.spec.d.ts.map +0 -1
- package/dist/test/e2e/virtualfs.spec.js +0 -409
- package/dist/virtualfs/persistence.d.ts +0 -149
- package/dist/virtualfs/persistence.d.ts.map +0 -1
- package/dist/virtualfs/persistence.js +0 -294
- package/dist/virtualfs/types.js +0 -2
- package/dist/virtualfs/virtualfs.js +0 -495
package/README.md
CHANGED
|
@@ -1,146 +1,119 @@
|
|
|
1
|
-
|
|
1
|
+
[](https://deepwiki.com/nojaja/browser-git-ops)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
# browser-git-ops
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
- **仮想ファイルシステム (VirtualFS)**: ローカルワークスペースとベーススナップショットを管理し、変更セット(create/update/delete)を生成します。
|
|
7
|
-
- **Git アダプタ抽象**: `GitAdapter` インターフェースに準拠するアダプタで GitHub/GitLab API を操作できます(サンプル実装あり)。
|
|
8
|
-
- **Idempotent push**: commitKey による冪等処理サポート。
|
|
9
|
-
- **衝突検知とマージ補助**: リモート差分取り込み時にローカルの未コミット変更を検出して conflicts を報告します。
|
|
5
|
+
A browser-native Git operations library that provides a VirtualFS and platform adapters for GitHub and GitLab. It implements multiple persistent backends (OPFS, IndexedDB, and an in-memory backend) and abstracts them behind a common VirtualFS API.
|
|
10
6
|
|
|
11
|
-
|
|
7
|
+
- Live Demo: https://nojaja.github.io/browser-git-ops/
|
|
12
8
|
|
|
13
|
-
|
|
14
|
-
- **src/virtualfs/virtualfs.ts**: VirtualFS 本体(初期化、read/write、push/pull、差分生成) - [src/virtualfs/virtualfs.ts](src/virtualfs/virtualfs.ts)
|
|
15
|
-
- **src/virtualfs/persistence.ts**: ストレージバックエンドの抽象と Node 用実装 - [src/virtualfs/persistence.ts](src/virtualfs/persistence.ts)
|
|
16
|
-
- **src/git/adapter.ts**: `GitAdapter` インターフェース定義 - [src/git/adapter.ts](src/git/adapter.ts)
|
|
17
|
-
- **src/git/githubAdapter.ts**: GitHub 用アダプタ(blob/tree/commit フロー、再試行ロジック) - [src/git/githubAdapter.ts](src/git/githubAdapter.ts)
|
|
18
|
-
- **test/**: ユニット/E2E テスト群(Jest / Playwright) - [test](test)
|
|
9
|
+
**[日本語ドキュメント (Japanese)](README_ja.md)**
|
|
19
10
|
|
|
20
|
-
|
|
21
|
-
-
|
|
22
|
-
-
|
|
23
|
-
-
|
|
24
|
-
- ビルド: `tsc`
|
|
11
|
+
Key features
|
|
12
|
+
- VirtualFS: local workspace snapshoting and change-set generation (create/update/delete).
|
|
13
|
+
- Multiple backends: `OpfsStorage` (OPFS), `IndexedDatabaseStorage` (IndexedDB), and `InMemoryStorage` (testing).
|
|
14
|
+
- Platform adapters: `GitHubAdapter` and `GitLabAdapter` implementing common push/fetch flows via Web APIs, enabling cross-origin operations without CORS proxy workarounds.
|
|
25
15
|
|
|
26
|
-
|
|
27
|
-
|
|
16
|
+
Status summary
|
|
17
|
+
- Core VirtualFS functionality implemented (delta generation, index management, local edits).
|
|
18
|
+
- Persistence backends for OPFS and IndexedDB implemented.
|
|
19
|
+
- GitHubAdapter includes primary push flow; GitLab adapter exists but may require extra environment verification.
|
|
28
20
|
|
|
29
|
-
|
|
21
|
+
Quick Install via npm (library consumers)
|
|
30
22
|
|
|
31
23
|
```bash
|
|
32
|
-
npm
|
|
24
|
+
npm i browser-git-ops
|
|
33
25
|
```
|
|
34
26
|
|
|
35
|
-
|
|
27
|
+
Usage (basic)
|
|
36
28
|
|
|
37
|
-
```
|
|
38
|
-
|
|
29
|
+
```ts
|
|
30
|
+
import { VirtualFS, OpfsStorage, GitHubAdapter } from 'browser-git-ops'
|
|
31
|
+
|
|
32
|
+
async function example() {
|
|
33
|
+
const backend = new lib.OpfsStorage('test01')
|
|
34
|
+
const vfs = new VirtualFS({ backend })
|
|
35
|
+
await vfs.init()
|
|
36
|
+
await vfs.setAdapter(null, { type: 'gitlab', opts: { projectId: 'ORG', host: 'HOST', token: 'token', branch: 'main' } })
|
|
37
|
+
|
|
38
|
+
await vfs.pull()
|
|
39
|
+
const list = await vfs.listPaths()
|
|
40
|
+
await vfs.writeFile('README.md', 'hello world')
|
|
41
|
+
const changes = await vfs.getChangeSet()
|
|
42
|
+
|
|
43
|
+
const idx = await vfs.getIndex()
|
|
44
|
+
const pushInput = { parentSha: idx.head, message: 'Example push', changes: changes }
|
|
45
|
+
const pushRes = await vfs.push(pushInput as any)
|
|
46
|
+
}
|
|
39
47
|
```
|
|
40
48
|
|
|
41
|
-
|
|
49
|
+
install
|
|
42
50
|
|
|
43
51
|
```bash
|
|
44
|
-
|
|
52
|
+
git clone https://github.com/nojaja/browser-git-ops.git
|
|
53
|
+
cd browser-git-ops
|
|
54
|
+
npm ci
|
|
45
55
|
```
|
|
46
56
|
|
|
47
|
-
|
|
57
|
+
Build & test
|
|
48
58
|
|
|
49
59
|
```bash
|
|
50
|
-
npm run build
|
|
60
|
+
npm run build # build browser bundles and types
|
|
61
|
+
npm run test # unit tests (Jest)
|
|
62
|
+
npm run test:e2e # Playwright E2E (runs after build)
|
|
63
|
+
npm run lint # ESLint
|
|
51
64
|
```
|
|
52
65
|
|
|
53
|
-
|
|
54
|
-
**ライブラリ利用ガイド(Library Usage)**
|
|
66
|
+
Project layout (excerpt)
|
|
55
67
|
|
|
56
|
-
|
|
68
|
+
- `src/` — source
|
|
69
|
+
- `virtualfs/virtualfs.ts` — `VirtualFS` core
|
|
70
|
+
- `virtualfs/opfsStorage.ts` — OPFS backend
|
|
71
|
+
- `virtualfs/indexedDatabaseStorage.ts` — IndexedDB backend
|
|
72
|
+
- `virtualfs/inmemoryStorage.ts` — In-memory backend (tests)
|
|
73
|
+
- `git/githubAdapter.ts` — GitHub adapter
|
|
74
|
+
- `git/gitlabAdapter.ts` — GitLab adapter
|
|
75
|
+
- `examples/` — browser sample UI and Playwright scenarios
|
|
76
|
+
- `test/` — Jest unit tests and Playwright E2E tests
|
|
57
77
|
|
|
58
|
-
|
|
78
|
+
Configuration
|
|
59
79
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
import GitHubAdapter from './src/git/githubAdapter'
|
|
80
|
+
- Set `GH_TOKEN` or appropriate credentials when using platform adapters.
|
|
81
|
+
- OPFS availability depends on the browser; polyfills/mocks are used in tests.
|
|
63
82
|
|
|
64
|
-
|
|
65
|
-
const vfs = new VirtualFS({ storageDir: '.apigit' })
|
|
66
|
-
await vfs.init()
|
|
83
|
+
Examples
|
|
67
84
|
|
|
68
|
-
|
|
69
|
-
await vfs.writeWorkspace('foo.txt', 'hello')
|
|
85
|
+
- See the `examples/` directory for a browser sample and Playwright scenarios.
|
|
70
86
|
|
|
71
|
-
|
|
72
|
-
const changes = await vfs.getChangeSet()
|
|
87
|
+
API surface (overview)
|
|
73
88
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
```
|
|
89
|
+
- `new VirtualFS(options?)` — options: `{ storageDir?: string, backend?: StorageBackend }`
|
|
90
|
+
- `init()` — initialize backend and load index
|
|
91
|
+
- `writeFile(path, content)`, `deleteFile(path)`, `renameFile(from,to)` — local edits
|
|
92
|
+
- `getChangeSet()` — returns list of create/update/delete changes
|
|
93
|
+
- `applyBaseSnapshot(snapshot, headSha)` — apply remote snapshot, returns conflicts if any
|
|
80
94
|
|
|
81
|
-
|
|
82
|
-
- `new VirtualFS(options?)` - オプション: `{ storageDir?: string, backend?: StorageBackend }`
|
|
83
|
-
- `init()` - バックエンド初期化と index 読み込み
|
|
84
|
-
- `writeWorkspace(filepath, content)` - ワークスペースにファイルを書き込む
|
|
85
|
-
- `deleteWorkspace(filepath)` - ワークスペース上のファイルを削除(トゥームストーン管理)
|
|
86
|
-
- `renameWorkspace(from, to)` - rename(内部では delete + create)
|
|
87
|
-
- `readWorkspace(filepath)` - ワークスペース/ベースから内容を読み出す
|
|
88
|
-
- `applyBaseSnapshot(snapshot, headSha)` - リモートスナップショットを適用
|
|
89
|
-
- `getIndex()` - 現在の index を返す
|
|
90
|
-
- `listPaths()` - 登録パス一覧
|
|
91
|
-
- `getChangeSet()` - create/update/delete の配列を生成
|
|
92
|
-
- `pull(remoteHead, baseSnapshot)` - リモート差分取り込み(conflicts を返す)
|
|
93
|
-
- `push(input, adapter?)` - 変更をコミットし(adapter があれば)リモートへ反映
|
|
94
|
-
|
|
95
|
-
GitAdapter インターフェース(`src/git/adapter.ts`)
|
|
96
|
-
- `createBlobs(changes, concurrency?)` -> Promise<Record<string,string>>
|
|
97
|
-
- `createTree(changes, baseTreeSha?)` -> Promise<string>
|
|
98
|
-
- `createCommit(message, parentSha, treeSha)` -> Promise<string>
|
|
99
|
-
- `updateRef(ref, commitSha, force?)` -> Promise<void>
|
|
100
|
-
|
|
101
|
-
実装済みアダプタの注意点:
|
|
102
|
-
- `GitHubAdapter` は `blob/tree/commit` フローを実装し、HTTP 再試行ロジックを内蔵しています(5xx, 429 のリトライ等)。実装は [src/git/githubAdapter.ts](src/git/githubAdapter.ts) を参照してください。
|
|
103
|
-
- GitLab 用実装はリポジトリ内に存在しますが、環境差異により API の振る舞いが異なるため本番運用前に検証してください。⚠️
|
|
104
|
-
|
|
105
|
-
--------------------------------------------------
|
|
106
|
-
**開発セットアップ**
|
|
107
|
-
- Node: 任意の recent Node.js(ESM サポート済み)
|
|
108
|
-
- 実行手順
|
|
95
|
+
Testing & CI
|
|
109
96
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
```
|
|
97
|
+
- Run unit tests locally with `npm run test`.
|
|
98
|
+
- `npm run test:e2e` requires a build (`npm run build`) before execution.
|
|
99
|
+
|
|
100
|
+
Contributing
|
|
115
101
|
|
|
116
|
-
-
|
|
117
|
-
|
|
118
|
-
- `npm run test:e2e` : Playwright E2E
|
|
119
|
-
- `npm run lint` : ESLint
|
|
120
|
-
- `npm run build` : TypeScript ビルド
|
|
102
|
+
- Issues and PRs are welcome. Please open an Issue first to discuss design when appropriate.
|
|
103
|
+
- Follow TypeScript + ESLint conventions; include tests for new behavior.
|
|
121
104
|
|
|
122
|
-
|
|
123
|
-
- Jest は ESM を扱うため `node --experimental-vm-modules` を使用するスクリプトが package.json に設定されています。
|
|
105
|
+
Support / Getting help
|
|
124
106
|
|
|
125
|
-
|
|
126
|
-
**現在のステータス**
|
|
127
|
-
- 実装済み: `VirtualFS` のコア機能(差分生成、push/pull シミュレーション、index 管理)、`GitHubAdapter` の主要な API 呼び出し。
|
|
128
|
-
- テスト: unit テストと一部の E2E テストが含まれています(`test/` 配下)。
|
|
129
|
-
- 未確定/要検証: 外部サービス(GitLab)の細かい API 挙動、production 用のエラー・認可ポリシー。
|
|
107
|
+
- Report issues at: https://github.com/nojaja/browser-git-ops/issues
|
|
130
108
|
|
|
131
|
-
|
|
132
|
-
**ライセンスとメタデータ**
|
|
133
|
-
- package name: `browser-git-ops`
|
|
134
|
-
- version: `0.0.0`
|
|
135
|
-
- module type: CommonJS (`type: commonjs`)
|
|
136
|
-
- License: MIT License
|
|
109
|
+
License
|
|
137
110
|
|
|
138
|
-
|
|
139
|
-
追加で欲しいもの
|
|
140
|
-
- サンプルユースケースを示す小さなサンプルリポジトリまたは `examples/` ディレクトリ
|
|
111
|
+
- Licensed under the MIT License — see the `LICENSE` file for details.
|
|
141
112
|
|
|
113
|
+
Maintainers
|
|
142
114
|
|
|
143
|
-
|
|
144
|
-
貢献・問い合わせ
|
|
145
|
-
- PR/Issue を歓迎します。まず issue を立て、簡単な実装提案(変更点の概要)を添えてください。
|
|
115
|
+
- Maintained by `nojaja` (https://github.com/nojaja). See repository for contributors and history.
|
|
146
116
|
|
|
117
|
+
TODO
|
|
118
|
+
- Add code examples that demonstrate push/pull flows end-to-end.
|
|
119
|
+
- Add a CONTRIBUTING.md with contributor guidelines and PR checklist.
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
export type FetchWithRetryFunction = (_input: RequestInfo, _init: RequestInit, _attempts?: number, _baseDelay?: number) => Promise<Response>;
|
|
2
|
+
/**
|
|
3
|
+
* Simple logger interface for dependency injection.
|
|
4
|
+
* If a caller injects an object matching this interface, the adapter
|
|
5
|
+
* will forward debug/info/warn/error messages to it. If no logger is
|
|
6
|
+
* provided, no logging will be performed by the adapter.
|
|
7
|
+
*/
|
|
8
|
+
export interface Logger {
|
|
9
|
+
debug: (..._messages: any[]) => void;
|
|
10
|
+
info: (..._messages: any[]) => void;
|
|
11
|
+
warn: (..._messages: any[]) => void;
|
|
12
|
+
error: (..._messages: any[]) => void;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Compute SHA-1 of string content using Web Crypto
|
|
16
|
+
* @param content The input string
|
|
17
|
+
* @returns Promise resolving to hex-encoded SHA-1
|
|
18
|
+
*/
|
|
19
|
+
export declare function shaOf(content: string): Promise<string>;
|
|
20
|
+
/**
|
|
21
|
+
* Determine whether an HTTP status should be considered retryable
|
|
22
|
+
* @param status HTTP status code
|
|
23
|
+
* @returns true if retryable (5xx or 429)
|
|
24
|
+
*/
|
|
25
|
+
export declare function classifyStatus(status: number): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Calculate delay before retrying based on response or exponential backoff
|
|
28
|
+
* @param response Response or null when not available
|
|
29
|
+
* @param index Attempt index (0-based)
|
|
30
|
+
* @param baseDelay Base delay in ms
|
|
31
|
+
* @returns delay in milliseconds
|
|
32
|
+
*/
|
|
33
|
+
export declare function getDelayForResponse(response: Response | null, index: number, baseDelay: number): number;
|
|
34
|
+
/**
|
|
35
|
+
* Process HTTP response and throw on non-ok. If retryable, delay before throwing.
|
|
36
|
+
* @param response Fetch Response
|
|
37
|
+
* @param index Attempt index
|
|
38
|
+
* @param baseDelay Base delay in ms
|
|
39
|
+
* @returns Promise resolving to the response when ok
|
|
40
|
+
*/
|
|
41
|
+
export declare function processResponseWithDelay(response: Response, index: number, baseDelay: number): Promise<Response>;
|
|
42
|
+
/**
|
|
43
|
+
* Perform fetch with retry/backoff logic
|
|
44
|
+
* @param input RequestInfo
|
|
45
|
+
* @param init RequestInit
|
|
46
|
+
* @param attempts number of attempts
|
|
47
|
+
* @param baseDelay base delay in ms
|
|
48
|
+
* @returns Promise resolving to Response
|
|
49
|
+
*/
|
|
50
|
+
export declare function fetchWithRetry(input: RequestInfo, init: RequestInit, attempts?: number, baseDelay?: number): Promise<Response>;
|
|
51
|
+
/**
|
|
52
|
+
* Error indicating the operation is retryable and may succeed on later attempts.
|
|
53
|
+
*/
|
|
54
|
+
export declare class RetryableError extends Error {
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Error indicating the operation failed in a non-retryable way.
|
|
58
|
+
*/
|
|
59
|
+
export declare class NonRetryableError extends Error {
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Map items with limited concurrency
|
|
63
|
+
* @template T,R
|
|
64
|
+
* @param items Array of items to map
|
|
65
|
+
* @param mapper Async mapper function
|
|
66
|
+
* @param concurrency concurrency limit
|
|
67
|
+
* @returns Promise resolving to array of mapped results
|
|
68
|
+
*/
|
|
69
|
+
export declare function mapWithConcurrency<T, R>(items: T[], mapper: (_t: T) => Promise<R>, concurrency?: number): Promise<R[]>;
|
|
70
|
+
/**
|
|
71
|
+
* Abstract base class providing shared utilities for Git adapters
|
|
72
|
+
*/
|
|
73
|
+
export declare abstract class AbstractGitAdapter {
|
|
74
|
+
protected baseUrl: string;
|
|
75
|
+
protected headers: Record<string, string>;
|
|
76
|
+
protected options: any;
|
|
77
|
+
protected logger?: Logger;
|
|
78
|
+
protected maxRetries: number;
|
|
79
|
+
protected baseBackoff: number;
|
|
80
|
+
/**
|
|
81
|
+
* Construct base adapter
|
|
82
|
+
* @param options adapter options
|
|
83
|
+
*/
|
|
84
|
+
constructor(options?: any);
|
|
85
|
+
/**
|
|
86
|
+
* Delegate to shared shaOf implementation
|
|
87
|
+
* @param content input string
|
|
88
|
+
* @returns hex sha1
|
|
89
|
+
*/
|
|
90
|
+
protected shaOf(content: string): Promise<string>;
|
|
91
|
+
/**
|
|
92
|
+
* Replace or set the logger at runtime.
|
|
93
|
+
* Use this if DI happens after construction.
|
|
94
|
+
* @param logger optional logger instance to set (or undefined to clear)
|
|
95
|
+
* @returns void
|
|
96
|
+
*/
|
|
97
|
+
setLogger(logger: Logger | undefined): void;
|
|
98
|
+
/**
|
|
99
|
+
* Log debug messages when a logger is present.
|
|
100
|
+
* @param _messages messages to log (unused when no logger)
|
|
101
|
+
*/
|
|
102
|
+
protected logDebug(..._messages: any[]): void;
|
|
103
|
+
/**
|
|
104
|
+
* Log an informational message if a logger is present.
|
|
105
|
+
* @param args items to log
|
|
106
|
+
*/
|
|
107
|
+
protected logInfo(..._messages: any[]): void;
|
|
108
|
+
/**
|
|
109
|
+
* Log a warning message if a logger is present.
|
|
110
|
+
* @param args items to log
|
|
111
|
+
*/
|
|
112
|
+
protected logWarn(..._messages: any[]): void;
|
|
113
|
+
/**
|
|
114
|
+
* Log an error message if a logger is present.
|
|
115
|
+
* @param args items to log
|
|
116
|
+
*/
|
|
117
|
+
protected logError(..._messages: any[]): void;
|
|
118
|
+
/**
|
|
119
|
+
* Proxy to shared fetchWithRetry implementation
|
|
120
|
+
* @param input RequestInfo
|
|
121
|
+
* @param init RequestInit
|
|
122
|
+
* @param attempts retry attempts
|
|
123
|
+
* @param baseDelay base delay ms
|
|
124
|
+
* @returns Promise resolving to Response
|
|
125
|
+
*/
|
|
126
|
+
/**
|
|
127
|
+
* Normalize different header-like shapes into a plain object.
|
|
128
|
+
* @param headerLike headers in Headers, array, or plain object form
|
|
129
|
+
* @returns plain header map
|
|
130
|
+
*/
|
|
131
|
+
private normalizeHeaders;
|
|
132
|
+
/**
|
|
133
|
+
* Format a fetch request into a minimal object suitable for logging.
|
|
134
|
+
* @returns formatted request log object
|
|
135
|
+
*/
|
|
136
|
+
private formatRequestForLog;
|
|
137
|
+
/**
|
|
138
|
+
* Format a fetch Response into a minimal object suitable for logging.
|
|
139
|
+
* @returns formatted response log object
|
|
140
|
+
*/
|
|
141
|
+
private formatResponseForLog;
|
|
142
|
+
/**
|
|
143
|
+
* Proxy to shared `fetchWithRetry` implementation while emitting
|
|
144
|
+
* minimal request/response logs for debugging and test inspection.
|
|
145
|
+
* @param input fetch input
|
|
146
|
+
* @param init fetch init
|
|
147
|
+
* @param attempts retry attempts
|
|
148
|
+
* @param baseDelay base delay ms
|
|
149
|
+
* @returns Promise resolving to Response
|
|
150
|
+
*/
|
|
151
|
+
protected fetchWithRetry(input: RequestInfo, init: RequestInit, attempts?: number, baseDelay?: number): Promise<Response>;
|
|
152
|
+
/**
|
|
153
|
+
* Determine if a status code is retryable
|
|
154
|
+
* @param status HTTP status code
|
|
155
|
+
* @returns boolean
|
|
156
|
+
*/
|
|
157
|
+
protected isRetryableStatus(status: number): boolean;
|
|
158
|
+
/**
|
|
159
|
+
* Compute backoff milliseconds for attempt
|
|
160
|
+
* @param attempt attempt number (1..)
|
|
161
|
+
* @returns milliseconds to wait
|
|
162
|
+
*/
|
|
163
|
+
protected backoffMs(attempt: number): number;
|
|
164
|
+
/**
|
|
165
|
+
* Delegate to shared mapWithConcurrency implementation
|
|
166
|
+
* @template T,R
|
|
167
|
+
* @param items items to map
|
|
168
|
+
* @param mapper async mapper
|
|
169
|
+
* @param concurrency concurrency limit
|
|
170
|
+
* @returns Promise resolving to mapped results
|
|
171
|
+
*/
|
|
172
|
+
/**
|
|
173
|
+
* Map items with limited concurrency by delegating to the shared helper.
|
|
174
|
+
* @template T,R
|
|
175
|
+
* @param items items to map
|
|
176
|
+
* @param mapper async mapper
|
|
177
|
+
* @param concurrency concurrency limit
|
|
178
|
+
* @returns Promise resolving to mapped results
|
|
179
|
+
*/
|
|
180
|
+
protected mapWithConcurrency<T, R>(items: T[], mapper: (_t: T) => Promise<R>, concurrency?: number): Promise<R[]>;
|
|
181
|
+
}
|
|
182
|
+
export default AbstractGitAdapter;
|
|
183
|
+
//# sourceMappingURL=abstractAdapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abstractAdapter.d.ts","sourceRoot":"","sources":["../../src/git/abstractAdapter.ts"],"names":[],"mappings":"AACA,MAAM,MAAM,sBAAsB,GAAG,CAAC,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,WAAW,EAAE,SAAS,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAA;AAK5I;;;;;GAKG;AACH,MAAM,WAAW,MAAM;IACrB,KAAK,EAAE,CAAC,GAAG,SAAS,EAAE,GAAG,EAAE,KAAK,IAAI,CAAA;IACpC,IAAI,EAAE,CAAC,GAAG,SAAS,EAAE,GAAG,EAAE,KAAK,IAAI,CAAA;IACnC,IAAI,EAAE,CAAC,GAAG,SAAS,EAAE,GAAG,EAAE,KAAK,IAAI,CAAA;IACnC,KAAK,EAAE,CAAC,GAAG,SAAS,EAAE,GAAG,EAAE,KAAK,IAAI,CAAA;CACrC;AACD;;;;GAIG;AACH,wBAAsB,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAK5D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K,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAIvD;;;;;OAKG;IACI,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS;IAK3C;;;OAGG;IACH,SAAS,CAAC,QAAQ,CAAC,GAAG,SAAS,EAAE,GAAG,EAAE;IAUtC;;;OAGG;IACH,SAAS,CAAC,OAAO,CAAC,GAAG,SAAS,EAAE,GAAG,EAAE;IAUrC;;;OAGG;IACH,SAAS,CAAC,OAAO,CAAC,GAAG,SAAS,EAAE,GAAG,EAAE;IAUrC;;;OAGG;IACH,SAAS,CAAC,QAAQ,CAAC,GAAG,SAAS,EAAE,GAAG,EAAE;IAUtC;;;;;;;OAOG;IACH;;;;OAIG;IACH,OAAO,CAAC,gBAAgB;IAqBxB;;;OAGG;IACH,OAAO,CAAC,mBAAmB;IAQ3B;;;OAGG;YACW,oBAAoB;IAiBlC;;;;;;;;OAQG;cACa,cAAc,CAAC,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,SAAI,EAAE,SAAS,SAAM;IA2BnG;;;;OAIG;IACH,SAAS,CAAC,iBAAiB,CAAC,MAAM,EAAE,MAAM;IAI1C;;;;OAIG;IACH,SAAS,CAAC,SAAS,CAAC,OAAO,EAAE,MAAM;IAMnC;;;;;;;OAOG;IACH;;;;;;;OAOG;IACH,SAAS,CAAC,kBAAkB,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,EAAE,WAAW,SAAI;CAG9F;AAED,eAAe,kBAAkB,CAAA"}
|
package/dist/git/adapter.d.ts
CHANGED
|
@@ -7,10 +7,32 @@ export interface Change {
|
|
|
7
7
|
export interface CommitResult {
|
|
8
8
|
commitSha: string;
|
|
9
9
|
}
|
|
10
|
+
export type CommitHistoryQuery = {
|
|
11
|
+
ref: string;
|
|
12
|
+
perPage?: number;
|
|
13
|
+
page?: number;
|
|
14
|
+
};
|
|
15
|
+
export type CommitSummary = {
|
|
16
|
+
sha: string;
|
|
17
|
+
message: string;
|
|
18
|
+
author: string;
|
|
19
|
+
date: string;
|
|
20
|
+
parents: string[];
|
|
21
|
+
};
|
|
22
|
+
export type CommitHistoryPage = {
|
|
23
|
+
items: CommitSummary[];
|
|
24
|
+
nextPage?: number;
|
|
25
|
+
lastPage?: number;
|
|
26
|
+
};
|
|
10
27
|
export interface GitAdapter {
|
|
11
28
|
createBlobs(_changes: Change[], _concurrency?: number): Promise<Record<string, string>>;
|
|
12
29
|
createTree(_changes: Change[], _baseTreeSha?: string): Promise<string>;
|
|
13
30
|
createCommit(_message: string, _parentSha: string, _treeSha: string): Promise<string>;
|
|
14
|
-
updateRef(
|
|
31
|
+
updateRef(_reference: string, _commitSha: string, _force?: boolean): Promise<void>;
|
|
32
|
+
listCommits?(_query: CommitHistoryQuery): Promise<CommitHistoryPage>;
|
|
33
|
+
listBranches?(_query?: import('../virtualfs/types.ts').BranchListQuery): Promise<import('../virtualfs/types.ts').BranchListPage>;
|
|
34
|
+
getRepositoryMetadata?(): Promise<import('../virtualfs/types.ts').RepositoryMetadata>;
|
|
35
|
+
resolveRef?(_reference: string): Promise<string>;
|
|
36
|
+
createBranch?(_branchName: string, _fromSha: string): Promise<import('../virtualfs/types.ts').CreateBranchResult>;
|
|
15
37
|
}
|
|
16
38
|
//# sourceMappingURL=adapter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../src/git/adapter.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,MAAM;IACrB,IAAI,EAAE,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAA;IACpC,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,WAAW,YAAY;IAC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