@gitgov/core 1.12.0 → 2.0.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.
@@ -0,0 +1,267 @@
1
+ import { R as RecordStore, C as ConfigStore, G as GitGovConfig, S as SessionStore, a as GitGovSession, I as IGitModule, f as CommitInfo, E as ExecOptions, c as ExecResult, d as ChangedFile, e as GetCommitHistoryOptions, g as CommitAuthor } from './index-DMkBFK4C.js';
2
+ export { M as MemoryFileListerOptions } from './index-DMkBFK4C.js';
3
+ export { E as EnvKeyProvider, a as EnvKeyProviderOptions, c as MemoryFileLister, M as MockKeyProvider, b as MockKeyProviderOptions } from './memory_file_lister-D0llxocS.js';
4
+
5
+ /**
6
+ * Options for MemoryRecordStore
7
+ */
8
+ interface MemoryRecordStoreOptions<T> {
9
+ /** Initial data */
10
+ initial?: Map<string, T>;
11
+ /** Clone data on get/put (default: true) */
12
+ deepClone?: boolean;
13
+ }
14
+ /**
15
+ * MemoryRecordStore<T> - In-memory implementation of RecordStore<T>
16
+ *
17
+ * Designed for unit tests and scenarios without persistence.
18
+ * By default, clones values on get/put to prevent accidental mutations.
19
+ *
20
+ * @example
21
+ * // Test setup
22
+ * const store = new MemoryRecordStore<TaskRecord>();
23
+ * await store.put('test-task-1', mockTask);
24
+ *
25
+ * // Assertions
26
+ * expect(await store.exists('test-task-1')).toBe(true);
27
+ * expect(store.size()).toBe(1);
28
+ *
29
+ * // Cleanup
30
+ * store.clear();
31
+ */
32
+ declare class MemoryRecordStore<T> implements RecordStore<T> {
33
+ private readonly data;
34
+ private readonly deepClone;
35
+ constructor(options?: MemoryRecordStoreOptions<T>);
36
+ private clone;
37
+ get(id: string): Promise<T | null>;
38
+ put(id: string, value: T): Promise<void>;
39
+ delete(id: string): Promise<void>;
40
+ list(): Promise<string[]>;
41
+ exists(id: string): Promise<boolean>;
42
+ /** Clears all records from the store */
43
+ clear(): void;
44
+ /** Returns the number of records */
45
+ size(): number;
46
+ /** Returns a copy of the internal Map (for assertions) */
47
+ getAll(): Map<string, T>;
48
+ }
49
+
50
+ /**
51
+ * MemoryConfigStore - In-memory implementation of ConfigStore
52
+ *
53
+ * Useful for testing and serverless environments where filesystem
54
+ * access is not available or not desired.
55
+ *
56
+ * NOTE: Session state is handled by MemorySessionStore, not this class.
57
+ *
58
+ * @see packages/blueprints/03_products/core/specs/modules/config_store_module/memory_config_store_module.md
59
+ * @see packages/blueprints/03_products/protocol/10_appendices/config_file.md
60
+ */
61
+
62
+ /**
63
+ * In-memory ConfigStore implementation for tests.
64
+ *
65
+ * Stores configuration in memory without filesystem I/O.
66
+ * Provides methods to pre-populate data for testing scenarios.
67
+ *
68
+ * @example
69
+ * ```typescript
70
+ * const configStore = new MemoryConfigStore();
71
+ * const sessionStore = new MemorySessionStore();
72
+ *
73
+ * // Pre-populate for testing
74
+ * configStore.setConfig({
75
+ * protocolVersion: '1.0',
76
+ * projectId: 'test-project',
77
+ * projectName: 'Test Project',
78
+ * rootCycle: '1234567890-cycle-test'
79
+ * });
80
+ *
81
+ * // Use in ConfigManager
82
+ * const manager = new ConfigManager(configStore, sessionStore);
83
+ * const config = await manager.loadConfig();
84
+ * ```
85
+ */
86
+ declare class MemoryConfigStore implements ConfigStore {
87
+ private config;
88
+ /**
89
+ * Load configuration from memory
90
+ *
91
+ * [EARS-A1] Returns null if no config set
92
+ * [EARS-A2] Returns config set via setConfig
93
+ * [EARS-A3] Returns config saved via saveConfig
94
+ *
95
+ * @returns GitGovConfig or null if not set
96
+ */
97
+ loadConfig(): Promise<GitGovConfig | null>;
98
+ /**
99
+ * Save configuration to memory
100
+ *
101
+ * [EARS-A4] Persists config in memory, accessible via getConfig()
102
+ */
103
+ saveConfig(config: GitGovConfig): Promise<void>;
104
+ /**
105
+ * Set configuration directly (for test setup)
106
+ *
107
+ * [EARS-B1] Sets config synchronously, available via getConfig()
108
+ * [EARS-B2] Accepts null to clear config
109
+ */
110
+ setConfig(config: GitGovConfig | null): void;
111
+ /**
112
+ * Get current configuration (for test assertions)
113
+ */
114
+ getConfig(): GitGovConfig | null;
115
+ /**
116
+ * Clear all stored data (for test cleanup)
117
+ *
118
+ * [EARS-B3] Resets store to initial state (config = null)
119
+ */
120
+ clear(): void;
121
+ }
122
+
123
+ /**
124
+ * MemorySessionStore - In-memory implementation of SessionStore
125
+ *
126
+ * Useful for testing and serverless environments where filesystem
127
+ * access is not available or not desired.
128
+ *
129
+ * @see packages/blueprints/03_products/protocol/10_appendices/session_state.md
130
+ */
131
+
132
+ /**
133
+ * In-memory SessionStore implementation for tests.
134
+ *
135
+ * Stores session state in memory without filesystem I/O.
136
+ * Provides methods to pre-populate data for testing scenarios.
137
+ *
138
+ * @example
139
+ * ```typescript
140
+ * const store = new MemorySessionStore();
141
+ *
142
+ * // Pre-populate for testing
143
+ * store.setSession({
144
+ * lastSession: { actorId: 'human:test', timestamp: '2024-01-01T00:00:00Z' },
145
+ * actorState: {}
146
+ * });
147
+ *
148
+ * // Use in ConfigManager
149
+ * const manager = new ConfigManager(configStore, store);
150
+ * const session = await manager.loadSession();
151
+ * ```
152
+ */
153
+ declare class MemorySessionStore implements SessionStore {
154
+ private session;
155
+ private keyFiles;
156
+ /**
157
+ * Load session from memory
158
+ * @returns GitGovSession or null if not set
159
+ */
160
+ loadSession(): Promise<GitGovSession | null>;
161
+ /**
162
+ * Save session to memory
163
+ */
164
+ saveSession(session: GitGovSession): Promise<void>;
165
+ /**
166
+ * Detect actor from simulated .key files
167
+ *
168
+ * In MemorySessionStore, .key files are simulated via setKeyFiles().
169
+ *
170
+ * @returns Actor ID or null if no key files configured
171
+ */
172
+ detectActorFromKeyFiles(): Promise<string | null>;
173
+ /**
174
+ * Set session directly (for test setup)
175
+ */
176
+ setSession(session: GitGovSession | null): void;
177
+ /**
178
+ * Get current session (for test assertions)
179
+ */
180
+ getSession(): GitGovSession | null;
181
+ /**
182
+ * Set simulated .key files (for EARS-B9 testing)
183
+ * @param keyFiles - Array of key filenames (e.g., ["human:camilo.key"])
184
+ */
185
+ setKeyFiles(keyFiles: string[]): void;
186
+ /**
187
+ * Clear all stored data (for test cleanup)
188
+ */
189
+ clear(): void;
190
+ }
191
+
192
+ /**
193
+ * MemoryGitModule - In-memory Git implementation for tests
194
+ *
195
+ * This module provides a mock implementation of IGitModule for unit testing.
196
+ * All state is kept in memory with no filesystem operations.
197
+ *
198
+ * Test Helpers:
199
+ * - setBranch(name): Set current branch
200
+ * - setCommits(commits[]): Set commit history
201
+ * - setFiles(files): Set file contents
202
+ * - clear(): Reset all state
203
+ *
204
+ * @module git/memory
205
+ */
206
+
207
+ /**
208
+ * MemoryGitModule - In-memory Git mock for unit tests
209
+ */
210
+ declare class MemoryGitModule implements IGitModule {
211
+ private state;
212
+ constructor(repoRoot?: string);
213
+ setBranch(name: string): void;
214
+ setBranches(names: string[]): void;
215
+ setCommits(commits: CommitInfo[]): void;
216
+ setFiles(files: Record<string, string>): void;
217
+ setFileContent(commitHash: string, filePath: string, content: string): void;
218
+ setStagedFiles(files: string[]): void;
219
+ setRebaseInProgress(inProgress: boolean, conflictedFiles?: string[]): void;
220
+ setRemoteBranches(remote: string, branches: string[]): void;
221
+ clear(): void;
222
+ exec(_command: string, _args: string[], _options?: ExecOptions): Promise<ExecResult>;
223
+ init(): Promise<void>;
224
+ getRepoRoot(): Promise<string>;
225
+ getCurrentBranch(): Promise<string>;
226
+ getCommitHash(ref?: string): Promise<string>;
227
+ setConfig(key: string, value: string, _scope?: 'local' | 'global' | 'system'): Promise<void>;
228
+ getMergeBase(branchA: string, branchB: string): Promise<string>;
229
+ getChangedFiles(_fromCommit: string, _toCommit: string, _pathFilter: string): Promise<ChangedFile[]>;
230
+ getStagedFiles(): Promise<string[]>;
231
+ getFileContent(commitHash: string, filePath: string): Promise<string>;
232
+ getCommitHistory(_branch: string, options?: GetCommitHistoryOptions): Promise<CommitInfo[]>;
233
+ getCommitHistoryRange(fromHash: string, toHash: string, options?: GetCommitHistoryOptions): Promise<CommitInfo[]>;
234
+ getCommitMessage(commitHash: string): Promise<string>;
235
+ hasUncommittedChanges(_pathFilter?: string): Promise<boolean>;
236
+ isRebaseInProgress(): Promise<boolean>;
237
+ branchExists(branchName: string): Promise<boolean>;
238
+ listRemoteBranches(remoteName: string): Promise<string[]>;
239
+ isRemoteConfigured(remoteName: string): Promise<boolean>;
240
+ getBranchRemote(branchName: string): Promise<string | null>;
241
+ getConflictedFiles(): Promise<string[]>;
242
+ checkoutBranch(branchName: string): Promise<void>;
243
+ stash(message?: string): Promise<string | null>;
244
+ stashPop(): Promise<boolean>;
245
+ stashDrop(_stashHash?: string): Promise<void>;
246
+ checkoutOrphanBranch(branchName: string): Promise<void>;
247
+ fetch(_remote: string): Promise<void>;
248
+ pull(_remote: string, _branchName: string): Promise<void>;
249
+ pullRebase(_remote: string, _branchName: string): Promise<void>;
250
+ resetHard(_target: string): Promise<void>;
251
+ checkoutFilesFromBranch(sourceBranch: string, _filePaths: string[]): Promise<void>;
252
+ add(filePaths: string[], _options?: {
253
+ force?: boolean;
254
+ }): Promise<void>;
255
+ rm(filePaths: string[]): Promise<void>;
256
+ commit(message: string, author?: CommitAuthor): Promise<string>;
257
+ commitAllowEmpty(message: string, author?: CommitAuthor): Promise<string>;
258
+ push(_remote: string, branchName: string): Promise<void>;
259
+ pushWithUpstream(_remote: string, branchName: string): Promise<void>;
260
+ setUpstream(branchName: string, _remote: string, _remoteBranch: string): Promise<void>;
261
+ rebaseContinue(): Promise<string>;
262
+ rebaseAbort(): Promise<void>;
263
+ createBranch(branchName: string, _startPoint?: string): Promise<void>;
264
+ rebase(_targetBranch: string): Promise<void>;
265
+ }
266
+
267
+ export { MemoryConfigStore, MemoryGitModule, MemoryRecordStore, MemorySessionStore };