just-git 1.3.7 → 1.4.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/README.md +17 -8
- package/dist/{hooks-DNBNCTgb.d.ts → hooks-C7c_BLqp.d.ts} +18 -62
- package/dist/index.d.ts +2 -2
- package/dist/index.js +322 -322
- package/dist/repo/index.d.ts +3 -148
- package/dist/repo/index.js +11 -11
- package/dist/server/index.d.ts +115 -78
- package/dist/server/index.js +70 -69
- package/dist/writing-CnM1ufDP.d.ts +204 -0
- package/package.json +1 -1
package/dist/server/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { i as ObjectId,
|
|
1
|
+
import { i as ObjectId, W as RawObject, X as Ref, g as GitRepo, $ as Rejection, N as NetworkPolicy } from '../hooks-C7c_BLqp.js';
|
|
2
|
+
import { b as CommitOptions } from '../writing-CnM1ufDP.js';
|
|
2
3
|
|
|
3
4
|
/** Shallow boundary delta: what to add/remove from `.git/shallow`. */
|
|
4
5
|
interface ShallowUpdate {
|
|
@@ -143,13 +144,13 @@ interface GcResult {
|
|
|
143
144
|
}
|
|
144
145
|
|
|
145
146
|
/**
|
|
146
|
-
* Default
|
|
147
|
-
* no custom `
|
|
147
|
+
* Default auth context type, produced by the built-in auth provider when
|
|
148
|
+
* no custom `auth` config is provided to `createServer`.
|
|
148
149
|
*
|
|
149
150
|
* HTTP requests produce `{ transport: "http", request }`.
|
|
150
151
|
* SSH sessions produce `{ transport: "ssh", username }`.
|
|
151
152
|
*/
|
|
152
|
-
interface
|
|
153
|
+
interface Auth {
|
|
153
154
|
transport: "http" | "ssh";
|
|
154
155
|
/** Authenticated username, when available. */
|
|
155
156
|
username?: string;
|
|
@@ -157,53 +158,53 @@ interface Session {
|
|
|
157
158
|
request?: Request;
|
|
158
159
|
}
|
|
159
160
|
/**
|
|
160
|
-
*
|
|
161
|
-
*
|
|
161
|
+
* Auth provider that transforms raw transport input into a typed
|
|
162
|
+
* auth context threaded through all hooks.
|
|
162
163
|
*
|
|
163
164
|
* Both properties are optional — provide only the transports you use.
|
|
164
|
-
* TypeScript infers `
|
|
165
|
+
* TypeScript infers `A` from whichever callbacks are present.
|
|
165
166
|
*
|
|
166
|
-
* If a transport is used at runtime but its
|
|
167
|
+
* If a transport is used at runtime but its callback is missing, the
|
|
167
168
|
* server returns an error (HTTP 501 / SSH exit 128).
|
|
168
169
|
*
|
|
169
170
|
* ```ts
|
|
170
171
|
* // HTTP-only — no need to provide ssh
|
|
171
172
|
* const server = createServer({
|
|
172
173
|
* storage: new BunSqliteStorage(db),
|
|
173
|
-
*
|
|
174
|
+
* auth: {
|
|
174
175
|
* http: (req) => ({
|
|
175
176
|
* userId: parseJwt(req).sub,
|
|
176
177
|
* roles: parseJwt(req).roles,
|
|
177
178
|
* }),
|
|
178
179
|
* },
|
|
179
180
|
* hooks: {
|
|
180
|
-
* preReceive: ({
|
|
181
|
-
* //
|
|
182
|
-
* if (!
|
|
181
|
+
* preReceive: ({ auth }) => {
|
|
182
|
+
* // auth is { userId: string, roles: string[] } — inferred!
|
|
183
|
+
* if (!auth.roles.includes("push"))
|
|
183
184
|
* return { reject: true, message: "forbidden" };
|
|
184
185
|
* },
|
|
185
186
|
* },
|
|
186
187
|
* });
|
|
187
188
|
* ```
|
|
188
189
|
*/
|
|
189
|
-
interface
|
|
190
|
+
interface AuthProvider<A> {
|
|
190
191
|
/**
|
|
191
|
-
*
|
|
192
|
+
* Authenticate an HTTP request.
|
|
192
193
|
*
|
|
193
|
-
* Return `
|
|
194
|
+
* Return `A` to proceed, or return a `Response` to short-circuit
|
|
194
195
|
* the request (e.g. 401 with `WWW-Authenticate` header). This is
|
|
195
196
|
* the primary mechanism for HTTP auth — no separate middleware needed.
|
|
196
197
|
*
|
|
197
198
|
* When omitted, HTTP requests receive a 501 response.
|
|
198
199
|
*/
|
|
199
|
-
http?: (request: Request) =>
|
|
200
|
+
http?: (request: Request) => A | Response | Promise<A | Response>;
|
|
200
201
|
/**
|
|
201
|
-
*
|
|
202
|
+
* Authenticate an SSH session.
|
|
202
203
|
*
|
|
203
204
|
* When omitted, SSH sessions receive exit code 128 with a
|
|
204
205
|
* diagnostic message.
|
|
205
206
|
*/
|
|
206
|
-
ssh?: (info: SshSessionInfo) =>
|
|
207
|
+
ssh?: (info: SshSessionInfo) => A | Promise<A>;
|
|
207
208
|
}
|
|
208
209
|
/** Information about the SSH session passed to `handleSession`. */
|
|
209
210
|
interface SshSessionInfo {
|
|
@@ -212,7 +213,7 @@ interface SshSessionInfo {
|
|
|
212
213
|
/**
|
|
213
214
|
* Arbitrary metadata from the SSH auth layer.
|
|
214
215
|
* Stash key fingerprints, client IPs, roles, etc. here —
|
|
215
|
-
* the
|
|
216
|
+
* the auth provider can extract and type them.
|
|
216
217
|
*/
|
|
217
218
|
metadata?: Record<string, unknown>;
|
|
218
219
|
}
|
|
@@ -251,8 +252,8 @@ interface NodeHttpResponse {
|
|
|
251
252
|
/**
|
|
252
253
|
* Declarative push rules applied before user-provided hooks.
|
|
253
254
|
*
|
|
254
|
-
* These are git-level constraints that don't depend on the
|
|
255
|
-
* For
|
|
255
|
+
* These are git-level constraints that don't depend on the caller's
|
|
256
|
+
* identity. For auth-dependent logic, use hooks directly.
|
|
256
257
|
*/
|
|
257
258
|
interface ServerPolicy {
|
|
258
259
|
/** Branches that cannot be force-pushed to or deleted. */
|
|
@@ -264,15 +265,17 @@ interface ServerPolicy {
|
|
|
264
265
|
/** Tags are immutable — no deletion, no overwrite once created. */
|
|
265
266
|
immutableTags?: boolean;
|
|
266
267
|
}
|
|
267
|
-
interface GitServerConfig<
|
|
268
|
+
interface GitServerConfig<A = Auth> {
|
|
268
269
|
/**
|
|
269
270
|
* Storage backend for git object and ref persistence.
|
|
270
271
|
*
|
|
271
272
|
* The server calls `createStorageAdapter(storage)` internally to build the
|
|
272
273
|
* git-aware adapter. Users provide the storage backend; they never see
|
|
273
274
|
* the `StorageAdapter` interface.
|
|
275
|
+
*
|
|
276
|
+
* Defaults to {@link MemoryStorage} when omitted.
|
|
274
277
|
*/
|
|
275
|
-
storage
|
|
278
|
+
storage?: Storage;
|
|
276
279
|
/**
|
|
277
280
|
* Map a request path to a repo ID.
|
|
278
281
|
*
|
|
@@ -293,22 +296,22 @@ interface GitServerConfig<S = Session> {
|
|
|
293
296
|
defaultBranch?: string;
|
|
294
297
|
};
|
|
295
298
|
/** Server-side hooks. All optional. */
|
|
296
|
-
hooks?: ServerHooks<
|
|
299
|
+
hooks?: ServerHooks<A>;
|
|
297
300
|
/**
|
|
298
301
|
* Declarative push policy. Rules run before user-provided hooks.
|
|
299
302
|
*
|
|
300
|
-
* For
|
|
303
|
+
* For auth-dependent logic (permissions, post-push actions), use `hooks`.
|
|
301
304
|
*/
|
|
302
305
|
policy?: ServerPolicy;
|
|
303
306
|
/**
|
|
304
|
-
*
|
|
307
|
+
* Auth provider. Provide `http`, `ssh`, or both —
|
|
305
308
|
* the server calls whichever is present for that transport.
|
|
306
|
-
* If a transport is used but its
|
|
309
|
+
* If a transport is used but its callback is missing, the server
|
|
307
310
|
* returns an error (HTTP 501 / SSH exit 128).
|
|
308
311
|
*
|
|
309
|
-
* When omitted entirely, the built-in `
|
|
312
|
+
* When omitted entirely, the built-in `Auth` type is used.
|
|
310
313
|
*/
|
|
311
|
-
|
|
314
|
+
auth?: AuthProvider<A>;
|
|
312
315
|
/** Base path prefix to strip from HTTP URLs (e.g. "/git"). */
|
|
313
316
|
basePath?: string;
|
|
314
317
|
/**
|
|
@@ -340,13 +343,13 @@ interface GitServerConfig<S = Session> {
|
|
|
340
343
|
* Override to integrate with your own logging, or set to `false` to
|
|
341
344
|
* suppress all error output.
|
|
342
345
|
*/
|
|
343
|
-
onError?: false | ((err: unknown,
|
|
346
|
+
onError?: false | ((err: unknown, auth?: A) => void);
|
|
344
347
|
}
|
|
345
348
|
/**
|
|
346
349
|
* A ref update request for {@link GitServer.updateRefs}.
|
|
347
350
|
*
|
|
348
|
-
* In-process
|
|
349
|
-
*
|
|
351
|
+
* In-process ref update with CAS protection. Objects must already
|
|
352
|
+
* exist in the repo's object store.
|
|
350
353
|
*/
|
|
351
354
|
interface RefUpdateRequest {
|
|
352
355
|
/** Full ref name (e.g. `"refs/heads/main"`, `"refs/tags/v1.0"`). */
|
|
@@ -364,7 +367,7 @@ interface RefUpdateRequest {
|
|
|
364
367
|
*/
|
|
365
368
|
oldHash?: string | null;
|
|
366
369
|
}
|
|
367
|
-
interface GitServer
|
|
370
|
+
interface GitServer {
|
|
368
371
|
/** Standard fetch-API handler for HTTP: (Request) => Response */
|
|
369
372
|
fetch(request: Request): Promise<Response>;
|
|
370
373
|
/**
|
|
@@ -401,14 +404,15 @@ interface GitServer<S = Session> {
|
|
|
401
404
|
*/
|
|
402
405
|
handleSession(command: string, channel: SshChannel, session?: SshSessionInfo): Promise<number>;
|
|
403
406
|
/**
|
|
404
|
-
* Update refs in-process with
|
|
407
|
+
* Update refs in-process with CAS protection.
|
|
405
408
|
*
|
|
406
|
-
*
|
|
407
|
-
*
|
|
408
|
-
*
|
|
409
|
+
* Applies compare-and-swap ref updates without transport overhead.
|
|
410
|
+
* Does NOT fire hooks (`preReceive`, `update`, `postReceive`) —
|
|
411
|
+
* hooks are a transport boundary concern. For hook enforcement,
|
|
412
|
+
* push through {@link asNetwork} instead.
|
|
409
413
|
*
|
|
410
|
-
*
|
|
411
|
-
*
|
|
414
|
+
* Objects must already exist in the repo's object store (e.g. via
|
|
415
|
+
* `createCommit` or `buildCommit` from `just-git/repo`).
|
|
412
416
|
*
|
|
413
417
|
* ```ts
|
|
414
418
|
* import { createCommit, writeBlob, writeTree } from "just-git/repo";
|
|
@@ -425,7 +429,36 @@ interface GitServer<S = Session> {
|
|
|
425
429
|
*
|
|
426
430
|
* @throws If the repo does not exist or the server is shutting down.
|
|
427
431
|
*/
|
|
428
|
-
updateRefs(repoId: string, refs: RefUpdateRequest[]
|
|
432
|
+
updateRefs(repoId: string, refs: RefUpdateRequest[]): Promise<RefUpdateResult>;
|
|
433
|
+
/**
|
|
434
|
+
* Commit files to a branch with CAS protection.
|
|
435
|
+
*
|
|
436
|
+
* High-level convenience that combines object creation ({@link buildCommit}
|
|
437
|
+
* from `just-git/repo`) with CAS-protected ref advancement
|
|
438
|
+
* ({@link updateRefs}). This is the recommended API for trusted
|
|
439
|
+
* server-side writes (bots, scripts, platform features).
|
|
440
|
+
*
|
|
441
|
+
* Does NOT fire hooks — hooks are a transport boundary concern.
|
|
442
|
+
* For hook enforcement (auth, policy), push through
|
|
443
|
+
* {@link asNetwork} instead.
|
|
444
|
+
*
|
|
445
|
+
* ```ts
|
|
446
|
+
* const hash = await server.commit("my-repo", {
|
|
447
|
+
* files: { "README.md": "# Hello\n" },
|
|
448
|
+
* message: "auto-fix",
|
|
449
|
+
* author: { name: "Bot", email: "bot@example.com" },
|
|
450
|
+
* branch: "main",
|
|
451
|
+
* });
|
|
452
|
+
* ```
|
|
453
|
+
*
|
|
454
|
+
* For lower-level control (e.g. constructing trees manually, multi-ref
|
|
455
|
+
* updates), use `buildCommit()` + {@link updateRefs} directly.
|
|
456
|
+
*
|
|
457
|
+
* @returns The new commit's hash.
|
|
458
|
+
* @throws If the repo does not exist, the server is shutting down,
|
|
459
|
+
* or a concurrent write moved the branch.
|
|
460
|
+
*/
|
|
461
|
+
commit(repoId: string, options: CommitOptions): Promise<string>;
|
|
429
462
|
/**
|
|
430
463
|
* Node.js `http.createServer` compatible handler.
|
|
431
464
|
*
|
|
@@ -488,31 +521,31 @@ interface GitServer<S = Session> {
|
|
|
488
521
|
*/
|
|
489
522
|
asNetwork(baseUrl?: string): NetworkPolicy;
|
|
490
523
|
}
|
|
491
|
-
interface ServerHooks<
|
|
524
|
+
interface ServerHooks<A = Auth> {
|
|
492
525
|
/**
|
|
493
526
|
* Called after objects are unpacked but before any refs update.
|
|
494
527
|
* Receives ALL ref updates as a batch. Return a Rejection to abort
|
|
495
528
|
* the entire push. Auth, branch protection, and repo-wide policy
|
|
496
529
|
* belong here.
|
|
497
530
|
*/
|
|
498
|
-
preReceive?: (event: PreReceiveEvent<
|
|
531
|
+
preReceive?: (event: PreReceiveEvent<A>) => void | Rejection | Promise<void | Rejection>;
|
|
499
532
|
/**
|
|
500
533
|
* Called per-ref, after preReceive passes.
|
|
501
534
|
* Return a Rejection to block this specific ref update while
|
|
502
535
|
* allowing others. Per-branch rules belong here.
|
|
503
536
|
*/
|
|
504
|
-
update?: (event: UpdateEvent<
|
|
537
|
+
update?: (event: UpdateEvent<A>) => void | Rejection | Promise<void | Rejection>;
|
|
505
538
|
/**
|
|
506
539
|
* Called after all ref updates succeed. Cannot reject.
|
|
507
540
|
* CI triggers, webhooks, notifications belong here.
|
|
508
541
|
*/
|
|
509
|
-
postReceive?: (event: PostReceiveEvent<
|
|
542
|
+
postReceive?: (event: PostReceiveEvent<A>) => void | Promise<void>;
|
|
510
543
|
/**
|
|
511
544
|
* Called when a client wants to fetch or push (during ref advertisement).
|
|
512
545
|
* Return a filtered ref list to hide branches, a Rejection to deny
|
|
513
546
|
* access entirely, or void to advertise all refs.
|
|
514
547
|
*/
|
|
515
|
-
advertiseRefs?: (event: AdvertiseRefsEvent<
|
|
548
|
+
advertiseRefs?: (event: AdvertiseRefsEvent<A>) => RefAdvertisement[] | void | Rejection | Promise<RefAdvertisement[] | void | Rejection>;
|
|
516
549
|
}
|
|
517
550
|
/** A single ref update within a push. */
|
|
518
551
|
interface RefUpdate {
|
|
@@ -530,48 +563,48 @@ interface RefUpdate {
|
|
|
530
563
|
isDelete: boolean;
|
|
531
564
|
}
|
|
532
565
|
/** Fired after objects are unpacked but before refs are updated. */
|
|
533
|
-
interface PreReceiveEvent<
|
|
566
|
+
interface PreReceiveEvent<A = Auth> {
|
|
534
567
|
repo: GitRepo;
|
|
535
568
|
/** Resolved repo ID (the value returned by `resolve`, or the raw path when `resolve` is not set). */
|
|
536
569
|
repoId: string;
|
|
537
570
|
updates: readonly RefUpdate[];
|
|
538
|
-
/**
|
|
539
|
-
|
|
571
|
+
/** Auth context from the transport's auth provider. Always present — hooks only fire from HTTP/SSH transport. */
|
|
572
|
+
auth: A;
|
|
540
573
|
}
|
|
541
574
|
/** Fired per-ref after preReceive passes. */
|
|
542
|
-
interface UpdateEvent<
|
|
575
|
+
interface UpdateEvent<A = Auth> {
|
|
543
576
|
repo: GitRepo;
|
|
544
577
|
/** Resolved repo ID (the value returned by `resolve`, or the raw path when `resolve` is not set). */
|
|
545
578
|
repoId: string;
|
|
546
579
|
update: RefUpdate;
|
|
547
|
-
/**
|
|
548
|
-
|
|
580
|
+
/** Auth context from the transport's auth provider. Always present — hooks only fire from HTTP/SSH transport. */
|
|
581
|
+
auth: A;
|
|
549
582
|
}
|
|
550
583
|
/** Fired after all ref updates succeed. */
|
|
551
|
-
interface PostReceiveEvent<
|
|
584
|
+
interface PostReceiveEvent<A = Auth> {
|
|
552
585
|
repo: GitRepo;
|
|
553
586
|
/** Resolved repo ID (the value returned by `resolve`, or the raw path when `resolve` is not set). */
|
|
554
587
|
repoId: string;
|
|
555
588
|
updates: readonly RefUpdate[];
|
|
556
|
-
/**
|
|
557
|
-
|
|
589
|
+
/** Auth context from the transport's auth provider. Always present — hooks only fire from HTTP/SSH transport. */
|
|
590
|
+
auth: A;
|
|
558
591
|
}
|
|
559
592
|
/** Fired during ref advertisement (info/refs). */
|
|
560
|
-
interface AdvertiseRefsEvent<
|
|
593
|
+
interface AdvertiseRefsEvent<A = Auth> {
|
|
561
594
|
repo: GitRepo;
|
|
562
595
|
/** Resolved repo ID (the value returned by `resolve`, or the raw path when `resolve` is not set). */
|
|
563
596
|
repoId: string;
|
|
564
597
|
refs: RefAdvertisement[];
|
|
565
598
|
service: "git-upload-pack" | "git-receive-pack";
|
|
566
|
-
/**
|
|
567
|
-
|
|
599
|
+
/** Auth context from the transport's auth provider. Always present — hooks only fire from HTTP/SSH transport. */
|
|
600
|
+
auth: A;
|
|
568
601
|
}
|
|
569
602
|
/** A ref name and hash advertised to clients during fetch/push discovery. */
|
|
570
603
|
interface RefAdvertisement {
|
|
571
604
|
name: string;
|
|
572
605
|
hash: string;
|
|
573
606
|
}
|
|
574
|
-
/** Per-ref result from a push or {@link GitServer.
|
|
607
|
+
/** Per-ref result from a push, {@link GitServer.updateRefs}, or {@link GitServer.commit} call. */
|
|
575
608
|
interface RefResult {
|
|
576
609
|
ref: string;
|
|
577
610
|
ok: boolean;
|
|
@@ -592,10 +625,7 @@ interface RefUpdateResult {
|
|
|
592
625
|
* works with any SSH library (ssh2, etc.) through a thin adapter.
|
|
593
626
|
*
|
|
594
627
|
* ```ts
|
|
595
|
-
* const server = createServer({
|
|
596
|
-
* storage: new MemoryStorage(),
|
|
597
|
-
* autoCreate: true,
|
|
598
|
-
* });
|
|
628
|
+
* const server = createServer({ autoCreate: true });
|
|
599
629
|
* await server.createRepo("my-repo");
|
|
600
630
|
*
|
|
601
631
|
* // HTTP
|
|
@@ -608,7 +638,6 @@ interface RefUpdateResult {
|
|
|
608
638
|
*
|
|
609
639
|
* ```ts
|
|
610
640
|
* const server = createServer({
|
|
611
|
-
* storage: new MemoryStorage(),
|
|
612
641
|
* autoCreate: true,
|
|
613
642
|
* });
|
|
614
643
|
* await server.createRepo("my-repo");
|
|
@@ -620,7 +649,7 @@ interface RefUpdateResult {
|
|
|
620
649
|
* server.handleSession(command, channel, { username });
|
|
621
650
|
* ```
|
|
622
651
|
*/
|
|
623
|
-
declare function createServer<
|
|
652
|
+
declare function createServer<A = Auth>(config?: GitServerConfig<A>): GitServer;
|
|
624
653
|
/**
|
|
625
654
|
* Compose multiple hook sets into a single `ServerHooks` object.
|
|
626
655
|
*
|
|
@@ -632,7 +661,7 @@ declare function createServer<S = Session>(config: GitServerConfig<S>): GitServe
|
|
|
632
661
|
* refs returned by the previous one. Short-circuits on `Rejection`.
|
|
633
662
|
* Returning void passes through unchanged.
|
|
634
663
|
*/
|
|
635
|
-
declare function composeHooks<
|
|
664
|
+
declare function composeHooks<A = Auth>(...hookSets: (ServerHooks<A> | undefined)[]): ServerHooks<A>;
|
|
636
665
|
|
|
637
666
|
/**
|
|
638
667
|
* Server-side Git protocol helpers.
|
|
@@ -816,7 +845,7 @@ interface AdvertiseResult {
|
|
|
816
845
|
* Both HTTP and SSH code paths use this — the caller handles the
|
|
817
846
|
* transport-specific response (HTTP 403 vs SSH exit 128).
|
|
818
847
|
*/
|
|
819
|
-
declare function advertiseRefsWithHooks<
|
|
848
|
+
declare function advertiseRefsWithHooks<A>(repo: GitRepo, repoId: string, service: "git-upload-pack" | "git-receive-pack", hooks: ServerHooks<A> | undefined, auth: A): Promise<AdvertiseResult | Rejection>;
|
|
820
849
|
interface UploadPackOptions {
|
|
821
850
|
/** Pack cache instance. When provided, full clones (no haves) are cached. */
|
|
822
851
|
cache?: PackCache;
|
|
@@ -858,24 +887,32 @@ declare function ingestReceivePack(repo: GitRepo, requestBody: Uint8Array): Prom
|
|
|
858
887
|
* pkt-line commands.
|
|
859
888
|
*/
|
|
860
889
|
declare function ingestReceivePackFromStream(repo: GitRepo, commands: PushCommand[], capabilities: string[], packStream: AsyncIterable<Uint8Array>, sawFlush?: boolean): Promise<ReceivePackResult>;
|
|
861
|
-
|
|
890
|
+
/**
|
|
891
|
+
* Apply ref updates with CAS protection only — no hooks.
|
|
892
|
+
*
|
|
893
|
+
* Validates ref format, checks object existence, and performs
|
|
894
|
+
* `compareAndSwapRef` per ref. Used directly by in-process APIs
|
|
895
|
+
* (`server.updateRefs`, `server.commit`) and internally by
|
|
896
|
+
* {@link applyReceivePack} for the transport path.
|
|
897
|
+
*/
|
|
898
|
+
declare function applyCasRefUpdates(repo: GitRepo, updates: readonly RefUpdate[]): Promise<RefUpdateResult>;
|
|
899
|
+
interface ApplyReceivePackOptions<A = unknown> {
|
|
862
900
|
repo: GitRepo;
|
|
863
901
|
repoId: string;
|
|
864
902
|
ingestResult: ReceivePackResult;
|
|
865
|
-
hooks?: ServerHooks<
|
|
866
|
-
|
|
867
|
-
session?: S;
|
|
903
|
+
hooks?: ServerHooks<A>;
|
|
904
|
+
auth: A;
|
|
868
905
|
}
|
|
869
906
|
/**
|
|
870
907
|
* Run the full receive-pack lifecycle: preReceive hook, per-ref update
|
|
871
908
|
* hook with ref format validation, CAS ref application, and postReceive
|
|
872
|
-
* hook. Transport-
|
|
909
|
+
* hook. Transport-only — used by HTTP and SSH push handlers.
|
|
873
910
|
*
|
|
874
911
|
* Returns per-ref results and the list of successfully applied updates.
|
|
875
912
|
* Does NOT handle unpack failures — the caller should check
|
|
876
913
|
* `ingestResult.unpackOk` and short-circuit before calling this.
|
|
877
914
|
*/
|
|
878
|
-
declare function applyReceivePack<
|
|
915
|
+
declare function applyReceivePack<A = unknown>(options: ApplyReceivePackOptions<A>): Promise<RefUpdateResult>;
|
|
879
916
|
/**
|
|
880
917
|
* Resolve `RefUpdateRequest[]` into fully computed `RefUpdate[]`.
|
|
881
918
|
*
|
|
@@ -889,7 +926,7 @@ declare function buildV2CapabilityAdvertisementBytes(): Uint8Array;
|
|
|
889
926
|
* then builds a v2 ls-refs response respecting the client's requested
|
|
890
927
|
* attributes (symrefs, peel, ref-prefix, unborn).
|
|
891
928
|
*/
|
|
892
|
-
declare function handleLsRefs<
|
|
929
|
+
declare function handleLsRefs<A>(repo: GitRepo, repoId: string, args: string[], hooks: ServerHooks<A> | undefined, auth: A): Promise<Uint8Array | Rejection>;
|
|
893
930
|
/**
|
|
894
931
|
* Handle a v2 `fetch` command. Parses fetch args, performs object
|
|
895
932
|
* enumeration and pack building via the shared pipeline, then
|
|
@@ -904,10 +941,9 @@ declare function handleV2Fetch(repo: GitRepo, args: string[], options?: UploadPa
|
|
|
904
941
|
* Data is lost when the process exits.
|
|
905
942
|
*
|
|
906
943
|
* ```ts
|
|
907
|
-
*
|
|
908
|
-
*
|
|
909
|
-
* });
|
|
910
|
-
* await server.createRepo("my-repo");
|
|
944
|
+
* // MemoryStorage is the default — these are equivalent:
|
|
945
|
+
* const server = createServer();
|
|
946
|
+
* const server2 = createServer({ storage: new MemoryStorage() });
|
|
911
947
|
* ```
|
|
912
948
|
*/
|
|
913
949
|
declare class MemoryStorage implements Storage {
|
|
@@ -933,6 +969,7 @@ declare class MemoryStorage implements Storage {
|
|
|
933
969
|
removeRef(repoId: string, name: string): void;
|
|
934
970
|
listRefs(repoId: string, prefix?: string): RawRefEntry[];
|
|
935
971
|
atomicRefUpdate<T>(repoId: string, fn: (ops: RefOps) => T): T;
|
|
972
|
+
/** List all created repo IDs. Convenience for tests and debugging. */
|
|
936
973
|
repoIds(): string[];
|
|
937
974
|
private getObjMap;
|
|
938
975
|
private getRefMap;
|
|
@@ -1082,4 +1119,4 @@ declare class PgStorage implements Storage {
|
|
|
1082
1119
|
atomicRefUpdate<T>(repoId: string, fn: (ops: RefOps) => Promise<T> | T): Promise<T>;
|
|
1083
1120
|
}
|
|
1084
1121
|
|
|
1085
|
-
export { type AdvertiseRefsEvent, type AdvertiseResult, type ApplyReceivePackOptions, type BetterSqlite3Database, BetterSqlite3Storage, type BunSqliteDatabase, BunSqliteStorage, type CreateRepoOptions, type GcOptions, type GcResult, GitRepo, type GitServer, type GitServerConfig, type MaybeAsync, MemoryStorage, type NodeHttpRequest, type NodeHttpResponse, type PgPool, PgStorage, type PostReceiveEvent, type PreReceiveEvent, type PushCommand, RawObject, type RawRefEntry, type ReceivePackResult, Ref, type RefAdvertisement, type RefOps, type RefResult, type RefUpdate, type RefUpdateRequest, type RefUpdateResult, Rejection, type ServerHooks, type ServerPolicy, type
|
|
1122
|
+
export { type AdvertiseRefsEvent, type AdvertiseResult, type ApplyReceivePackOptions, type Auth, type AuthProvider, type BetterSqlite3Database, BetterSqlite3Storage, type BunSqliteDatabase, BunSqliteStorage, type CreateRepoOptions, type GcOptions, type GcResult, GitRepo, type GitServer, type GitServerConfig, type MaybeAsync, MemoryStorage, type NodeHttpRequest, type NodeHttpResponse, type PgPool, PgStorage, type PostReceiveEvent, type PreReceiveEvent, type PushCommand, RawObject, type RawRefEntry, type ReceivePackResult, Ref, type RefAdvertisement, type RefOps, type RefResult, type RefUpdate, type RefUpdateRequest, type RefUpdateResult, Rejection, type ServerHooks, type ServerPolicy, type SshChannel, type SshSessionInfo, type Storage, type UpdateEvent, type V2CommandRequest, type V2FetchRequest, type V2FetchResponseOptions, type V2LsRefsRef, advertiseRefsWithHooks, applyCasRefUpdates, applyReceivePack, buildRefAdvertisementBytes, buildRefListBytes, buildRefListPktLines, buildV2CapabilityAdvertisement, buildV2CapabilityAdvertisementBytes, buildV2FetchResponse, buildV2LsRefsResponse, collectRefs, composeHooks, createServer, handleLsRefs, handleUploadPack, handleV2Fetch, ingestReceivePack, ingestReceivePackFromStream, parseV2CommandRequest, parseV2FetchArgs, resolveRefUpdates };
|