dsh-git-ui 0.0.1

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,74 @@
1
+ /**
2
+ * dsh-git-ui host data model. This file is the authoritative type source;
3
+ * the client half mirrors it with zod schemas (see src/client/remote.ts) and
4
+ * `tests/remote.spec.ts` keeps the two in sync.
5
+ */
6
+
7
+ /** Wire request: the browser never sends paths — only the session identity. */
8
+ export interface GitSnapshotRequest {
9
+ readonly sessionId: string
10
+ }
11
+
12
+ /** Discriminated outcome of one snapshot attempt. */
13
+ export type GitSnapshotResult =
14
+ | { readonly ok: true; readonly value: GitSnapshot }
15
+ | { readonly ok: false; readonly error: GitSnapshotFailure }
16
+
17
+ export type GitSnapshotFailure =
18
+ | { readonly code: 'session-not-found'; readonly sessionId: string }
19
+ | { readonly code: 'cwd-unavailable'; readonly sessionId: string }
20
+ | { readonly code: 'path-not-found'; readonly path: string }
21
+ | { readonly code: 'git-unavailable'; readonly detail: string }
22
+ | { readonly code: 'timeout' }
23
+ | { readonly code: 'not-a-git-repo' }
24
+
25
+ /** Immutable frozen snapshot of one repository's status at `checkedAt`. */
26
+ export interface GitSnapshot {
27
+ /** Realpath of the repository root (work tree top). */
28
+ readonly root: string
29
+ /** Current branch name; null when detached. */
30
+ readonly branch: string | null
31
+ /** Short HEAD hash; null when the repository has no commits (unborn). */
32
+ readonly head: string | null
33
+ /** True when the repository has no commits yet. */
34
+ readonly unborn: boolean
35
+ /** staged + modified + untracked > 0. */
36
+ readonly dirty: boolean
37
+ readonly staged: number
38
+ readonly modified: number
39
+ readonly untracked: number
40
+ readonly ahead: number
41
+ readonly behind: number
42
+ readonly lastCommit: GitCommit | null
43
+ readonly recentCommits: readonly GitCommit[]
44
+ readonly changes: readonly GitChange[]
45
+ /** True when `changes` was capped at maxChanges or status output overflowed. */
46
+ readonly truncated: boolean
47
+ /** Polling interval the client should use after this snapshot (0 = off). */
48
+ readonly refreshIntervalMs: number
49
+ /** Epoch millis of the snapshot. */
50
+ readonly checkedAt: number
51
+ }
52
+
53
+ export interface GitCommit {
54
+ readonly hash: string
55
+ readonly shortHash: string
56
+ readonly subject: string
57
+ readonly author: string
58
+ readonly dateIso: string
59
+ }
60
+
61
+ export interface GitChange {
62
+ readonly path: string
63
+ readonly status: GitChangeStatus
64
+ readonly staged: boolean
65
+ }
66
+
67
+ export type GitChangeStatus =
68
+ | 'added'
69
+ | 'modified'
70
+ | 'deleted'
71
+ | 'renamed'
72
+ | 'untracked'
73
+ | 'conflicted'
74
+ | 'typechange'