@pierre/storage 0.9.2 → 1.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.
package/src/types.ts CHANGED
@@ -1,263 +1,272 @@
1
1
  /**
2
2
  * Type definitions for Pierre Git Storage SDK
3
3
  */
4
-
5
4
  import type {
6
- CreateBranchResponseRaw,
7
- GetBranchDiffResponseRaw,
8
- GetCommitDiffResponseRaw,
9
- ListBranchesResponseRaw,
10
- ListCommitsResponseRaw,
11
- ListFilesResponseRaw,
12
- ListReposResponseRaw,
13
- NoteReadResponseRaw,
14
- NoteWriteResponseRaw,
15
- RawBranchInfo as SchemaRawBranchInfo,
16
- RawCommitInfo as SchemaRawCommitInfo,
17
- RawFileDiff as SchemaRawFileDiff,
18
- RawFilteredFile as SchemaRawFilteredFile,
19
- RawRepoBaseInfo as SchemaRawRepoBaseInfo,
20
- RawRepoInfo as SchemaRawRepoInfo,
5
+ CreateBranchResponseRaw,
6
+ GetBranchDiffResponseRaw,
7
+ GetCommitDiffResponseRaw,
8
+ ListBranchesResponseRaw,
9
+ ListCommitsResponseRaw,
10
+ ListFilesResponseRaw,
11
+ ListReposResponseRaw,
12
+ NoteReadResponseRaw,
13
+ NoteWriteResponseRaw,
14
+ RawBranchInfo as SchemaRawBranchInfo,
15
+ RawCommitInfo as SchemaRawCommitInfo,
16
+ RawFileDiff as SchemaRawFileDiff,
17
+ RawFilteredFile as SchemaRawFilteredFile,
18
+ RawRepoBaseInfo as SchemaRawRepoBaseInfo,
19
+ RawRepoInfo as SchemaRawRepoInfo,
21
20
  } from './schemas';
22
21
 
23
22
  export interface OverrideableGitStorageOptions {
24
- apiBaseUrl?: string;
25
- storageBaseUrl?: string;
26
- apiVersion?: ValidAPIVersion;
27
- defaultTTL?: number;
23
+ apiBaseUrl?: string;
24
+ storageBaseUrl?: string;
25
+ apiVersion?: ValidAPIVersion;
26
+ defaultTTL?: number;
28
27
  }
29
28
 
30
29
  export interface GitStorageOptions extends OverrideableGitStorageOptions {
31
- key: string;
32
- name: string;
33
- defaultTTL?: number;
30
+ key: string;
31
+ name: string;
32
+ defaultTTL?: number;
34
33
  }
35
34
 
36
35
  export type ValidAPIVersion = 1;
37
36
 
38
37
  export interface GetRemoteURLOptions {
39
- permissions?: ('git:write' | 'git:read' | 'repo:write' | 'org:read')[];
40
- ttl?: number;
38
+ permissions?: ('git:write' | 'git:read' | 'repo:write' | 'org:read')[];
39
+ ttl?: number;
41
40
  }
42
41
 
43
42
  export interface Repo {
44
- id: string;
45
- defaultBranch: string;
46
- getRemoteURL(options?: GetRemoteURLOptions): Promise<string>;
47
- getEphemeralRemoteURL(options?: GetRemoteURLOptions): Promise<string>;
48
-
49
- getFileStream(options: GetFileOptions): Promise<Response>;
50
- listFiles(options?: ListFilesOptions): Promise<ListFilesResult>;
51
- listBranches(options?: ListBranchesOptions): Promise<ListBranchesResult>;
52
- listCommits(options?: ListCommitsOptions): Promise<ListCommitsResult>;
53
- getNote(options: GetNoteOptions): Promise<GetNoteResult>;
54
- createNote(options: CreateNoteOptions): Promise<NoteWriteResult>;
55
- appendNote(options: AppendNoteOptions): Promise<NoteWriteResult>;
56
- deleteNote(options: DeleteNoteOptions): Promise<NoteWriteResult>;
57
- getBranchDiff(options: GetBranchDiffOptions): Promise<GetBranchDiffResult>;
58
- getCommitDiff(options: GetCommitDiffOptions): Promise<GetCommitDiffResult>;
59
- grep(options: GrepOptions): Promise<GrepResult>;
60
- pullUpstream(options?: PullUpstreamOptions): Promise<void>;
61
- restoreCommit(options: RestoreCommitOptions): Promise<RestoreCommitResult>;
62
- createBranch(options: CreateBranchOptions): Promise<CreateBranchResult>;
63
- createCommit(options: CreateCommitOptions): CommitBuilder;
64
- createCommitFromDiff(options: CreateCommitFromDiffOptions): Promise<CommitResult>;
43
+ id: string;
44
+ defaultBranch: string;
45
+ getRemoteURL(options?: GetRemoteURLOptions): Promise<string>;
46
+ getEphemeralRemoteURL(options?: GetRemoteURLOptions): Promise<string>;
47
+
48
+ getFileStream(options: GetFileOptions): Promise<Response>;
49
+ getArchiveStream(options?: ArchiveOptions): Promise<Response>;
50
+ listFiles(options?: ListFilesOptions): Promise<ListFilesResult>;
51
+ listBranches(options?: ListBranchesOptions): Promise<ListBranchesResult>;
52
+ listCommits(options?: ListCommitsOptions): Promise<ListCommitsResult>;
53
+ getNote(options: GetNoteOptions): Promise<GetNoteResult>;
54
+ createNote(options: CreateNoteOptions): Promise<NoteWriteResult>;
55
+ appendNote(options: AppendNoteOptions): Promise<NoteWriteResult>;
56
+ deleteNote(options: DeleteNoteOptions): Promise<NoteWriteResult>;
57
+ getBranchDiff(options: GetBranchDiffOptions): Promise<GetBranchDiffResult>;
58
+ getCommitDiff(options: GetCommitDiffOptions): Promise<GetCommitDiffResult>;
59
+ grep(options: GrepOptions): Promise<GrepResult>;
60
+ pullUpstream(options?: PullUpstreamOptions): Promise<void>;
61
+ restoreCommit(options: RestoreCommitOptions): Promise<RestoreCommitResult>;
62
+ createBranch(options: CreateBranchOptions): Promise<CreateBranchResult>;
63
+ createCommit(options: CreateCommitOptions): CommitBuilder;
64
+ createCommitFromDiff(
65
+ options: CreateCommitFromDiffOptions
66
+ ): Promise<CommitResult>;
65
67
  }
66
68
 
67
69
  export type ValidMethod = 'GET' | 'POST' | 'PUT' | 'DELETE';
68
70
  type SimplePath = string;
69
71
  type ComplexPath = {
70
- path: string;
71
- params?: Record<string, string | string[]>;
72
- body?: Record<string, any>;
72
+ path: string;
73
+ params?: Record<string, string | string[]>;
74
+ body?: Record<string, any>;
73
75
  };
74
76
  export type ValidPath = SimplePath | ComplexPath;
75
77
 
76
78
  interface GitStorageInvocationOptions {
77
- ttl?: number;
79
+ ttl?: number;
78
80
  }
79
81
 
80
82
  export interface FindOneOptions {
81
- id: string;
83
+ id: string;
82
84
  }
83
85
 
84
86
  export type SupportedRepoProvider = 'github';
85
87
 
86
88
  export interface GitHubBaseRepo {
87
- /**
88
- * @default github
89
- */
90
- provider?: SupportedRepoProvider;
91
- owner: string;
92
- name: string;
93
- defaultBranch?: string;
89
+ /**
90
+ * @default github
91
+ */
92
+ provider?: SupportedRepoProvider;
93
+ owner: string;
94
+ name: string;
95
+ defaultBranch?: string;
94
96
  }
95
97
 
96
98
  export interface ForkBaseRepo {
97
- id: string;
98
- ref?: string;
99
- sha?: string;
99
+ id: string;
100
+ ref?: string;
101
+ sha?: string;
100
102
  }
101
103
 
102
104
  export type BaseRepo = GitHubBaseRepo | ForkBaseRepo;
103
105
 
104
106
  export interface ListReposOptions extends GitStorageInvocationOptions {
105
- cursor?: string;
106
- limit?: number;
107
+ cursor?: string;
108
+ limit?: number;
107
109
  }
108
110
 
109
111
  export type RawRepoBaseInfo = SchemaRawRepoBaseInfo;
110
112
 
111
113
  export interface RepoBaseInfo {
112
- provider: string;
113
- owner: string;
114
- name: string;
114
+ provider: string;
115
+ owner: string;
116
+ name: string;
115
117
  }
116
118
 
117
119
  export type RawRepoInfo = SchemaRawRepoInfo;
118
120
 
119
121
  export interface RepoInfo {
120
- repoId: string;
121
- url: string;
122
- defaultBranch: string;
123
- createdAt: string;
124
- baseRepo?: RepoBaseInfo;
122
+ repoId: string;
123
+ url: string;
124
+ defaultBranch: string;
125
+ createdAt: string;
126
+ baseRepo?: RepoBaseInfo;
125
127
  }
126
128
 
127
129
  export type ListReposResponse = ListReposResponseRaw;
128
130
 
129
131
  export interface ListReposResult {
130
- repos: RepoInfo[];
131
- nextCursor?: string;
132
- hasMore: boolean;
132
+ repos: RepoInfo[];
133
+ nextCursor?: string;
134
+ hasMore: boolean;
133
135
  }
134
136
 
135
137
  export interface CreateRepoOptions extends GitStorageInvocationOptions {
136
- id?: string;
137
- baseRepo?: BaseRepo;
138
- defaultBranch?: string;
138
+ id?: string;
139
+ baseRepo?: BaseRepo;
140
+ defaultBranch?: string;
139
141
  }
140
142
 
141
143
  export interface DeleteRepoOptions extends GitStorageInvocationOptions {
142
- id: string;
144
+ id: string;
143
145
  }
144
146
 
145
147
  export interface DeleteRepoResult {
146
- repoId: string;
147
- message: string;
148
+ repoId: string;
149
+ message: string;
148
150
  }
149
151
 
150
152
  // Get File API types
151
153
  export interface GetFileOptions extends GitStorageInvocationOptions {
152
- path: string;
153
- ref?: string;
154
- ephemeral?: boolean;
155
- ephemeralBase?: boolean;
154
+ path: string;
155
+ ref?: string;
156
+ ephemeral?: boolean;
157
+ ephemeralBase?: boolean;
158
+ }
159
+
160
+ export interface ArchiveOptions extends GitStorageInvocationOptions {
161
+ ref?: string;
162
+ includeGlobs?: string[];
163
+ excludeGlobs?: string[];
164
+ archivePrefix?: string;
156
165
  }
157
166
 
158
167
  export interface PullUpstreamOptions extends GitStorageInvocationOptions {
159
- ref?: string;
168
+ ref?: string;
160
169
  }
161
170
 
162
171
  // List Files API types
163
172
  export interface ListFilesOptions extends GitStorageInvocationOptions {
164
- ref?: string;
165
- ephemeral?: boolean;
173
+ ref?: string;
174
+ ephemeral?: boolean;
166
175
  }
167
176
 
168
177
  export type ListFilesResponse = ListFilesResponseRaw;
169
178
 
170
179
  export interface ListFilesResult {
171
- paths: string[];
172
- ref: string;
180
+ paths: string[];
181
+ ref: string;
173
182
  }
174
183
 
175
184
  // List Branches API types
176
185
  export interface ListBranchesOptions extends GitStorageInvocationOptions {
177
- cursor?: string;
178
- limit?: number;
186
+ cursor?: string;
187
+ limit?: number;
179
188
  }
180
189
 
181
190
  export type RawBranchInfo = SchemaRawBranchInfo;
182
191
 
183
192
  export interface BranchInfo {
184
- cursor: string;
185
- name: string;
186
- headSha: string;
187
- createdAt: string;
193
+ cursor: string;
194
+ name: string;
195
+ headSha: string;
196
+ createdAt: string;
188
197
  }
189
198
 
190
199
  export type ListBranchesResponse = ListBranchesResponseRaw;
191
200
 
192
201
  export interface ListBranchesResult {
193
- branches: BranchInfo[];
194
- nextCursor?: string;
195
- hasMore: boolean;
202
+ branches: BranchInfo[];
203
+ nextCursor?: string;
204
+ hasMore: boolean;
196
205
  }
197
206
 
198
207
  // Create Branch API types
199
208
  export interface CreateBranchOptions extends GitStorageInvocationOptions {
200
- baseBranch: string;
201
- targetBranch: string;
202
- baseIsEphemeral?: boolean;
203
- targetIsEphemeral?: boolean;
209
+ baseBranch: string;
210
+ targetBranch: string;
211
+ baseIsEphemeral?: boolean;
212
+ targetIsEphemeral?: boolean;
204
213
  }
205
214
 
206
215
  export type CreateBranchResponse = CreateBranchResponseRaw;
207
216
 
208
217
  export interface CreateBranchResult {
209
- message: string;
210
- targetBranch: string;
211
- targetIsEphemeral: boolean;
212
- commitSha?: string;
218
+ message: string;
219
+ targetBranch: string;
220
+ targetIsEphemeral: boolean;
221
+ commitSha?: string;
213
222
  }
214
223
 
215
224
  // List Commits API types
216
225
  export interface ListCommitsOptions extends GitStorageInvocationOptions {
217
- branch?: string;
218
- cursor?: string;
219
- limit?: number;
226
+ branch?: string;
227
+ cursor?: string;
228
+ limit?: number;
220
229
  }
221
230
 
222
231
  export type RawCommitInfo = SchemaRawCommitInfo;
223
232
 
224
233
  export interface CommitInfo {
225
- sha: string;
226
- message: string;
227
- authorName: string;
228
- authorEmail: string;
229
- committerName: string;
230
- committerEmail: string;
231
- date: Date;
232
- rawDate: string;
234
+ sha: string;
235
+ message: string;
236
+ authorName: string;
237
+ authorEmail: string;
238
+ committerName: string;
239
+ committerEmail: string;
240
+ date: Date;
241
+ rawDate: string;
233
242
  }
234
243
 
235
244
  export type ListCommitsResponse = ListCommitsResponseRaw;
236
245
 
237
246
  export interface ListCommitsResult {
238
- commits: CommitInfo[];
239
- nextCursor?: string;
240
- hasMore: boolean;
247
+ commits: CommitInfo[];
248
+ nextCursor?: string;
249
+ hasMore: boolean;
241
250
  }
242
251
 
243
252
  // Git notes API types
244
253
  export interface GetNoteOptions extends GitStorageInvocationOptions {
245
- sha: string;
254
+ sha: string;
246
255
  }
247
256
 
248
257
  export type GetNoteResponse = NoteReadResponseRaw;
249
258
 
250
259
  export interface GetNoteResult {
251
- sha: string;
252
- note: string;
253
- refSha: string;
260
+ sha: string;
261
+ note: string;
262
+ refSha: string;
254
263
  }
255
264
 
256
265
  interface NoteWriteBaseOptions extends GitStorageInvocationOptions {
257
- sha: string;
258
- note: string;
259
- expectedRefSha?: string;
260
- author?: CommitSignature;
266
+ sha: string;
267
+ note: string;
268
+ expectedRefSha?: string;
269
+ author?: CommitSignature;
261
270
  }
262
271
 
263
272
  export type CreateNoteOptions = NoteWriteBaseOptions;
@@ -265,126 +274,130 @@ export type CreateNoteOptions = NoteWriteBaseOptions;
265
274
  export type AppendNoteOptions = NoteWriteBaseOptions;
266
275
 
267
276
  export interface DeleteNoteOptions extends GitStorageInvocationOptions {
268
- sha: string;
269
- expectedRefSha?: string;
270
- author?: CommitSignature;
277
+ sha: string;
278
+ expectedRefSha?: string;
279
+ author?: CommitSignature;
271
280
  }
272
281
 
273
282
  export interface NoteWriteResultPayload {
274
- success: boolean;
275
- status: string;
276
- message?: string;
283
+ success: boolean;
284
+ status: string;
285
+ message?: string;
277
286
  }
278
287
 
279
288
  export type NoteWriteResponse = NoteWriteResponseRaw;
280
289
 
281
290
  export interface NoteWriteResult {
282
- sha: string;
283
- targetRef: string;
284
- baseCommit?: string;
285
- newRefSha: string;
286
- result: NoteWriteResultPayload;
291
+ sha: string;
292
+ targetRef: string;
293
+ baseCommit?: string;
294
+ newRefSha: string;
295
+ result: NoteWriteResultPayload;
287
296
  }
288
297
 
289
298
  // Branch Diff API types
290
299
  export interface GetBranchDiffOptions extends GitStorageInvocationOptions {
291
- branch: string;
292
- base?: string;
293
- ephemeral?: boolean;
294
- ephemeralBase?: boolean;
295
- /** Optional paths to filter the diff to specific files */
296
- paths?: string[];
300
+ branch: string;
301
+ base?: string;
302
+ ephemeral?: boolean;
303
+ ephemeralBase?: boolean;
304
+ /** Optional paths to filter the diff to specific files */
305
+ paths?: string[];
297
306
  }
298
307
 
299
308
  export type GetBranchDiffResponse = GetBranchDiffResponseRaw;
300
309
 
301
310
  export interface GetBranchDiffResult {
302
- branch: string;
303
- base: string;
304
- stats: DiffStats;
305
- files: FileDiff[];
306
- filteredFiles: FilteredFile[];
311
+ branch: string;
312
+ base: string;
313
+ stats: DiffStats;
314
+ files: FileDiff[];
315
+ filteredFiles: FilteredFile[];
307
316
  }
308
317
 
309
318
  // Commit Diff API types
310
319
  export interface GetCommitDiffOptions extends GitStorageInvocationOptions {
311
- sha: string;
312
- baseSha?: string;
313
- /** Optional paths to filter the diff to specific files */
314
- paths?: string[];
320
+ sha: string;
321
+ baseSha?: string;
322
+ /** Optional paths to filter the diff to specific files */
323
+ paths?: string[];
315
324
  }
316
325
 
317
326
  export type GetCommitDiffResponse = GetCommitDiffResponseRaw;
318
327
 
319
328
  export interface GetCommitDiffResult {
320
- sha: string;
321
- stats: DiffStats;
322
- files: FileDiff[];
323
- filteredFiles: FilteredFile[];
329
+ sha: string;
330
+ stats: DiffStats;
331
+ files: FileDiff[];
332
+ filteredFiles: FilteredFile[];
324
333
  }
325
334
 
326
335
  // Grep API types
327
336
  export interface GrepOptions extends GitStorageInvocationOptions {
328
- ref?: string;
329
- paths?: string[];
330
- query: {
331
- pattern: string;
332
- /**
333
- * Default is case-sensitive.
334
- * When omitted, the server default is used.
335
- */
336
- caseSensitive?: boolean;
337
- };
338
- fileFilters?: {
339
- includeGlobs?: string[];
340
- excludeGlobs?: string[];
341
- extensionFilters?: string[];
342
- };
343
- context?: {
344
- before?: number;
345
- after?: number;
346
- };
347
- limits?: {
348
- maxLines?: number;
349
- maxMatchesPerFile?: number;
350
- };
351
- pagination?: {
352
- cursor?: string;
353
- limit?: number;
354
- };
337
+ ref?: string;
338
+ /**
339
+ * @deprecated Use ref instead.
340
+ */
341
+ rev?: string;
342
+ paths?: string[];
343
+ query: {
344
+ pattern: string;
345
+ /**
346
+ * Default is case-sensitive.
347
+ * When omitted, the server default is used.
348
+ */
349
+ caseSensitive?: boolean;
350
+ };
351
+ fileFilters?: {
352
+ includeGlobs?: string[];
353
+ excludeGlobs?: string[];
354
+ extensionFilters?: string[];
355
+ };
356
+ context?: {
357
+ before?: number;
358
+ after?: number;
359
+ };
360
+ limits?: {
361
+ maxLines?: number;
362
+ maxMatchesPerFile?: number;
363
+ };
364
+ pagination?: {
365
+ cursor?: string;
366
+ limit?: number;
367
+ };
355
368
  }
356
369
 
357
370
  export interface GrepLine {
358
- lineNumber: number;
359
- text: string;
360
- type: string;
371
+ lineNumber: number;
372
+ text: string;
373
+ type: string;
361
374
  }
362
375
 
363
376
  export interface GrepFileMatch {
364
- path: string;
365
- lines: GrepLine[];
377
+ path: string;
378
+ lines: GrepLine[];
366
379
  }
367
380
 
368
381
  export interface GrepResult {
369
- query: {
370
- pattern: string;
371
- caseSensitive: boolean;
372
- };
373
- repo: {
374
- ref: string;
375
- commit: string;
376
- };
377
- matches: GrepFileMatch[];
378
- nextCursor?: string;
379
- hasMore: boolean;
382
+ query: {
383
+ pattern: string;
384
+ caseSensitive: boolean;
385
+ };
386
+ repo: {
387
+ ref: string;
388
+ commit: string;
389
+ };
390
+ matches: GrepFileMatch[];
391
+ nextCursor?: string;
392
+ hasMore: boolean;
380
393
  }
381
394
 
382
395
  // Shared diff types
383
396
  export interface DiffStats {
384
- files: number;
385
- additions: number;
386
- deletions: number;
387
- changes: number;
397
+ files: number;
398
+ additions: number;
399
+ deletions: number;
400
+ changes: number;
388
401
  }
389
402
 
390
403
  export type RawFileDiff = SchemaRawFileDiff;
@@ -392,243 +405,254 @@ export type RawFileDiff = SchemaRawFileDiff;
392
405
  export type RawFilteredFile = SchemaRawFilteredFile;
393
406
 
394
407
  export type DiffFileState =
395
- | 'added'
396
- | 'modified'
397
- | 'deleted'
398
- | 'renamed'
399
- | 'copied'
400
- | 'type_changed'
401
- | 'unmerged'
402
- | 'unknown';
408
+ | 'added'
409
+ | 'modified'
410
+ | 'deleted'
411
+ | 'renamed'
412
+ | 'copied'
413
+ | 'type_changed'
414
+ | 'unmerged'
415
+ | 'unknown';
403
416
 
404
417
  export interface DiffFileBase {
405
- path: string;
406
- state: DiffFileState;
407
- rawState: string;
408
- oldPath?: string;
409
- bytes: number;
410
- isEof: boolean;
418
+ path: string;
419
+ state: DiffFileState;
420
+ rawState: string;
421
+ oldPath?: string;
422
+ bytes: number;
423
+ isEof: boolean;
411
424
  }
412
425
 
413
426
  export interface FileDiff extends DiffFileBase {
414
- raw: string;
427
+ raw: string;
415
428
  }
416
429
 
417
430
  export interface FilteredFile extends DiffFileBase {}
418
431
 
419
432
  interface CreateCommitBaseOptions extends GitStorageInvocationOptions {
420
- commitMessage: string;
421
- expectedHeadSha?: string;
422
- baseBranch?: string;
423
- ephemeral?: boolean;
424
- ephemeralBase?: boolean;
425
- author: CommitSignature;
426
- committer?: CommitSignature;
427
- signal?: AbortSignal;
433
+ commitMessage: string;
434
+ expectedHeadSha?: string;
435
+ baseBranch?: string;
436
+ ephemeral?: boolean;
437
+ ephemeralBase?: boolean;
438
+ author: CommitSignature;
439
+ committer?: CommitSignature;
440
+ signal?: AbortSignal;
428
441
  }
429
442
 
430
443
  export interface CreateCommitBranchOptions extends CreateCommitBaseOptions {
431
- targetBranch: string;
432
- targetRef?: never;
444
+ targetBranch: string;
445
+ targetRef?: never;
433
446
  }
434
447
 
435
448
  /**
436
449
  * @deprecated Use {@link CreateCommitBranchOptions} instead.
437
450
  */
438
451
  export interface LegacyCreateCommitOptions extends CreateCommitBaseOptions {
439
- targetBranch?: never;
440
- targetRef: string;
452
+ targetBranch?: never;
453
+ targetRef: string;
441
454
  }
442
455
 
443
- export type CreateCommitOptions = CreateCommitBranchOptions | LegacyCreateCommitOptions;
456
+ export type CreateCommitOptions =
457
+ | CreateCommitBranchOptions
458
+ | LegacyCreateCommitOptions;
444
459
 
445
460
  export interface CommitSignature {
446
- name: string;
447
- email: string;
461
+ name: string;
462
+ email: string;
448
463
  }
449
464
 
450
465
  export interface ReadableStreamReaderLike<T> {
451
- read(): Promise<{ value?: T; done: boolean }>;
452
- releaseLock?(): void;
466
+ read(): Promise<{ value?: T; done: boolean }>;
467
+ releaseLock?(): void;
453
468
  }
454
469
 
455
470
  export interface ReadableStreamLike<T> {
456
- getReader(): ReadableStreamReaderLike<T>;
471
+ getReader(): ReadableStreamReaderLike<T>;
457
472
  }
458
473
 
459
474
  export interface BlobLike {
460
- stream(): unknown;
475
+ stream(): unknown;
461
476
  }
462
477
 
463
478
  export interface FileLike extends BlobLike {
464
- name: string;
465
- lastModified?: number;
479
+ name: string;
480
+ lastModified?: number;
466
481
  }
467
482
 
468
483
  export type GitFileMode = '100644' | '100755' | '120000' | '160000';
469
484
 
470
485
  export type TextEncoding =
471
- | 'ascii'
472
- | 'utf8'
473
- | 'utf-8'
474
- | 'utf16le'
475
- | 'utf-16le'
476
- | 'ucs2'
477
- | 'ucs-2'
478
- | 'base64'
479
- | 'base64url'
480
- | 'latin1'
481
- | 'binary'
482
- | 'hex';
486
+ | 'ascii'
487
+ | 'utf8'
488
+ | 'utf-8'
489
+ | 'utf16le'
490
+ | 'utf-16le'
491
+ | 'ucs2'
492
+ | 'ucs-2'
493
+ | 'base64'
494
+ | 'base64url'
495
+ | 'latin1'
496
+ | 'binary'
497
+ | 'hex';
483
498
 
484
499
  export type CommitFileSource =
485
- | string
486
- | Uint8Array
487
- | ArrayBuffer
488
- | BlobLike
489
- | FileLike
490
- | ReadableStreamLike<Uint8Array | ArrayBuffer | ArrayBufferView | string>
491
- | AsyncIterable<Uint8Array | ArrayBuffer | ArrayBufferView | string>
492
- | Iterable<Uint8Array | ArrayBuffer | ArrayBufferView | string>;
500
+ | string
501
+ | Uint8Array
502
+ | ArrayBuffer
503
+ | BlobLike
504
+ | FileLike
505
+ | ReadableStreamLike<Uint8Array | ArrayBuffer | ArrayBufferView | string>
506
+ | AsyncIterable<Uint8Array | ArrayBuffer | ArrayBufferView | string>
507
+ | Iterable<Uint8Array | ArrayBuffer | ArrayBufferView | string>;
493
508
 
494
509
  export interface CommitFileOptions {
495
- mode?: GitFileMode;
510
+ mode?: GitFileMode;
496
511
  }
497
512
 
498
513
  export interface CommitTextFileOptions extends CommitFileOptions {
499
- encoding?: TextEncoding;
514
+ encoding?: TextEncoding;
500
515
  }
501
516
 
502
517
  export interface CommitBuilder {
503
- addFile(path: string, source: CommitFileSource, options?: CommitFileOptions): CommitBuilder;
504
- addFileFromString(path: string, contents: string, options?: CommitTextFileOptions): CommitBuilder;
505
- deletePath(path: string): CommitBuilder;
506
- send(): Promise<CommitResult>;
518
+ addFile(
519
+ path: string,
520
+ source: CommitFileSource,
521
+ options?: CommitFileOptions
522
+ ): CommitBuilder;
523
+ addFileFromString(
524
+ path: string,
525
+ contents: string,
526
+ options?: CommitTextFileOptions
527
+ ): CommitBuilder;
528
+ deletePath(path: string): CommitBuilder;
529
+ send(): Promise<CommitResult>;
507
530
  }
508
531
 
509
532
  export type DiffSource = CommitFileSource;
510
533
 
511
- export interface CreateCommitFromDiffOptions extends GitStorageInvocationOptions {
512
- targetBranch: string;
513
- commitMessage: string;
514
- diff: DiffSource;
515
- expectedHeadSha?: string;
516
- baseBranch?: string;
517
- ephemeral?: boolean;
518
- ephemeralBase?: boolean;
519
- author: CommitSignature;
520
- committer?: CommitSignature;
521
- signal?: AbortSignal;
534
+ export interface CreateCommitFromDiffOptions
535
+ extends GitStorageInvocationOptions {
536
+ targetBranch: string;
537
+ commitMessage: string;
538
+ diff: DiffSource;
539
+ expectedHeadSha?: string;
540
+ baseBranch?: string;
541
+ ephemeral?: boolean;
542
+ ephemeralBase?: boolean;
543
+ author: CommitSignature;
544
+ committer?: CommitSignature;
545
+ signal?: AbortSignal;
522
546
  }
523
547
 
524
548
  export interface RefUpdate {
525
- branch: string;
526
- oldSha: string;
527
- newSha: string;
549
+ branch: string;
550
+ oldSha: string;
551
+ newSha: string;
528
552
  }
529
553
 
530
554
  export type RefUpdateReason =
531
- | 'precondition_failed'
532
- | 'conflict'
533
- | 'not_found'
534
- | 'invalid'
535
- | 'timeout'
536
- | 'unauthorized'
537
- | 'forbidden'
538
- | 'unavailable'
539
- | 'internal'
540
- | 'failed'
541
- | 'unknown';
555
+ | 'precondition_failed'
556
+ | 'conflict'
557
+ | 'not_found'
558
+ | 'invalid'
559
+ | 'timeout'
560
+ | 'unauthorized'
561
+ | 'forbidden'
562
+ | 'unavailable'
563
+ | 'internal'
564
+ | 'failed'
565
+ | 'unknown';
542
566
 
543
567
  export interface CommitResult {
544
- commitSha: string;
545
- treeSha: string;
546
- targetBranch: string;
547
- packBytes: number;
548
- blobCount: number;
549
- refUpdate: RefUpdate;
568
+ commitSha: string;
569
+ treeSha: string;
570
+ targetBranch: string;
571
+ packBytes: number;
572
+ blobCount: number;
573
+ refUpdate: RefUpdate;
550
574
  }
551
575
 
552
576
  export interface RestoreCommitOptions extends GitStorageInvocationOptions {
553
- targetBranch: string;
554
- targetCommitSha: string;
555
- commitMessage?: string;
556
- expectedHeadSha?: string;
557
- author: CommitSignature;
558
- committer?: CommitSignature;
577
+ targetBranch: string;
578
+ targetCommitSha: string;
579
+ commitMessage?: string;
580
+ expectedHeadSha?: string;
581
+ author: CommitSignature;
582
+ committer?: CommitSignature;
559
583
  }
560
584
 
561
585
  export interface RestoreCommitResult {
562
- commitSha: string;
563
- treeSha: string;
564
- targetBranch: string;
565
- packBytes: number;
566
- refUpdate: RefUpdate;
586
+ commitSha: string;
587
+ treeSha: string;
588
+ targetBranch: string;
589
+ packBytes: number;
590
+ refUpdate: RefUpdate;
567
591
  }
568
592
 
569
593
  // Webhook types
570
594
  export interface WebhookValidationOptions {
571
- /**
572
- * Maximum age of webhook in seconds (default: 300 seconds / 5 minutes)
573
- * Set to 0 to disable timestamp validation
574
- */
575
- maxAgeSeconds?: number;
595
+ /**
596
+ * Maximum age of webhook in seconds (default: 300 seconds / 5 minutes)
597
+ * Set to 0 to disable timestamp validation
598
+ */
599
+ maxAgeSeconds?: number;
576
600
  }
577
601
 
578
602
  export interface WebhookValidationResult {
579
- /**
580
- * Whether the webhook signature and timestamp are valid
581
- */
582
- valid: boolean;
583
- /**
584
- * Error message if validation failed
585
- */
586
- error?: string;
587
- /**
588
- * The parsed webhook event type (e.g., "push")
589
- */
590
- eventType?: string;
591
- /**
592
- * The timestamp from the signature (Unix seconds)
593
- */
594
- timestamp?: number;
603
+ /**
604
+ * Whether the webhook signature and timestamp are valid
605
+ */
606
+ valid: boolean;
607
+ /**
608
+ * Error message if validation failed
609
+ */
610
+ error?: string;
611
+ /**
612
+ * The parsed webhook event type (e.g., "push")
613
+ */
614
+ eventType?: string;
615
+ /**
616
+ * The timestamp from the signature (Unix seconds)
617
+ */
618
+ timestamp?: number;
595
619
  }
596
620
 
597
621
  // Webhook event payloads
598
622
  export interface RawWebhookPushEvent {
599
- repository: {
600
- id: string;
601
- url: string;
602
- };
603
- ref: string;
604
- before: string;
605
- after: string;
606
- customer_id: string;
607
- pushed_at: string; // RFC3339 timestamp
623
+ repository: {
624
+ id: string;
625
+ url: string;
626
+ };
627
+ ref: string;
628
+ before: string;
629
+ after: string;
630
+ customer_id: string;
631
+ pushed_at: string; // RFC3339 timestamp
608
632
  }
609
633
 
610
634
  export interface WebhookPushEvent {
611
- type: 'push';
612
- repository: {
613
- id: string;
614
- url: string;
615
- };
616
- ref: string;
617
- before: string;
618
- after: string;
619
- customerId: string;
620
- pushedAt: Date;
621
- rawPushedAt: string;
635
+ type: 'push';
636
+ repository: {
637
+ id: string;
638
+ url: string;
639
+ };
640
+ ref: string;
641
+ before: string;
642
+ after: string;
643
+ customerId: string;
644
+ pushedAt: Date;
645
+ rawPushedAt: string;
622
646
  }
623
647
 
624
648
  export interface WebhookUnknownEvent {
625
- type: string;
626
- raw: unknown;
649
+ type: string;
650
+ raw: unknown;
627
651
  }
628
652
 
629
653
  export type WebhookEventPayload = WebhookPushEvent | WebhookUnknownEvent;
630
654
 
631
655
  export interface ParsedWebhookSignature {
632
- timestamp: string;
633
- signature: string;
656
+ timestamp: string;
657
+ signature: string;
634
658
  }