@ref0/git 0.4.0 → 0.6.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/dist/access/private-refs.mjs +3 -4
- package/dist/auth/authorize.mjs +9 -4
- package/dist/auth/identify.d.mts +5 -3
- package/dist/auth/tokens.mjs +12 -11
- package/dist/client/local.mjs +2 -0
- package/dist/client/slice-push.d.mts +1 -1
- package/dist/contracts/access.d.mts +6 -2
- package/dist/contracts/authorize.d.mts +14 -10
- package/dist/contracts/events.d.mts +32 -5
- package/dist/contracts/events.mjs +14 -3
- package/dist/contracts/git.d.mts +68 -3
- package/dist/contracts/grants.d.mts +6 -1
- package/dist/contracts/lfs.d.mts +5 -2
- package/dist/contracts/objects.d.mts +7 -2
- package/dist/contracts/promises.d.mts +2 -14
- package/dist/contracts/push-uploads.d.mts +1 -1
- package/dist/contracts/queue.d.mts +15 -7
- package/dist/contracts/refs.d.mts +1 -1
- package/dist/contracts/result.d.mts +9 -5
- package/dist/contracts/result.mjs +5 -0
- package/dist/contracts/server.d.mts +13 -6
- package/dist/contracts/work.d.mts +1 -1
- package/dist/core/access.mjs +17 -1
- package/dist/core/call-names.d.mts +3 -1
- package/dist/core/claim-rows.d.mts +4 -0
- package/dist/core/claim-rows.mjs +53 -0
- package/dist/core/events/deliver.d.mts +12 -0
- package/dist/core/events/deliver.mjs +367 -145
- package/dist/core/events/seen.mjs +17 -3
- package/dist/core/forks.mjs +82 -20
- package/dist/core/hooks/post-receive.mjs +20 -17
- package/dist/core/index-job.mjs +23 -17
- package/dist/core/parts.d.mts +6 -0
- package/dist/core/purge.d.mts +8 -0
- package/dist/core/purge.mjs +16 -21
- package/dist/core/push-decide.mjs +26 -4
- package/dist/core/push.mjs +57 -20
- package/dist/core/ref-index-job.mjs +9 -14
- package/dist/core/ref-index.d.mts +1 -0
- package/dist/core/ref-index.mjs +28 -8
- package/dist/core/ref-view.mjs +14 -9
- package/dist/core/refs.mjs +13 -11
- package/dist/core/repack.d.mts +2 -1
- package/dist/core/repack.mjs +66 -118
- package/dist/core/repos.mjs +5 -5
- package/dist/core/rules/check.mjs +7 -6
- package/dist/core/rules/context.d.mts +1 -1
- package/dist/core/seam.d.mts +56 -9
- package/dist/core/seam.mjs +7 -1
- package/dist/core/still-takes.mjs +75 -0
- package/dist/core/view.d.mts +1 -0
- package/dist/core/view.mjs +8 -9
- package/dist/core/work.mjs +1 -1
- package/dist/extend.d.mts +2 -1
- package/dist/http/core-parts.mjs +19 -11
- package/dist/http/handler.mjs +2 -2
- package/dist/http/node.d.mts +2 -23
- package/dist/http/parts.d.mts +1 -0
- package/dist/http/push-uploads.d.mts +10 -2
- package/dist/http/push-uploads.mjs +31 -34
- package/dist/http/receive-pack.mjs +5 -3
- package/dist/http/upload-pack.mjs +2 -2
- package/dist/index.d.mts +11 -7
- package/dist/index.mjs +5 -3
- package/dist/lfs/base.d.mts +32 -0
- package/dist/lfs/base.mjs +8 -0
- package/dist/lfs/calls.mjs +21 -12
- package/dist/lfs/layer.d.mts +27 -0
- package/dist/lfs/layer.mjs +64 -0
- package/dist/lfs/locks.mjs +13 -27
- package/dist/lfs/namespace.d.mts +2 -0
- package/dist/lfs/objects.d.mts +23 -4
- package/dist/lfs/objects.mjs +65 -81
- package/dist/lfs/pointers.mjs +8 -6
- package/dist/lfs/public.d.mts +5 -0
- package/dist/lfs/public.mjs +8 -0
- package/dist/lfs/purge.mjs +19 -25
- package/dist/lfs/rows.mjs +22 -10
- package/dist/lfs/service.d.mts +9 -4
- package/dist/lfs/service.mjs +3 -12
- package/dist/lfs/upkeep.mjs +34 -49
- package/dist/node.d.mts +3 -2
- package/dist/node.mjs +1 -1
- package/dist/protocol/wire/advertisement.d.mts +4 -10
- package/dist/protocol/wire/advertisement.mjs +16 -12
- package/dist/protocol/wire/lines.d.mts +14 -2
- package/dist/protocol/wire/lines.mjs +32 -21
- package/dist/protocol/wire/v2.d.mts +4 -15
- package/dist/protocol/wire/v2.mjs +16 -14
- package/dist/queue/advance.mjs +78 -55
- package/dist/queue/calls.mjs +4 -2
- package/dist/queue/commit.mjs +20 -13
- package/dist/queue/host.d.mts +2 -2
- package/dist/queue/layer.d.mts +4 -2
- package/dist/queue/layer.mjs +8 -3
- package/dist/queue/limits.mjs +36 -6
- package/dist/queue/rows.mjs +14 -5
- package/dist/queue/state.mjs +19 -5
- package/dist/queue/steps.mjs +10 -4
- package/dist/queue/trim.mjs +284 -0
- package/dist/rest/blobs.d.mts +19 -19
- package/dist/rest/caller.d.mts +4 -4
- package/dist/rest/commits.d.mts +96 -96
- package/dist/rest/errors.d.mts +2 -2
- package/dist/rest/events.d.mts +2 -2
- package/dist/rest/files.d.mts +54 -54
- package/dist/rest/forks.d.mts +87 -87
- package/dist/rest/handler.mjs +13 -5
- package/dist/rest/layer.d.mts +14 -0
- package/dist/rest/layer.mjs +52 -0
- package/dist/rest/me.d.mts +2 -2
- package/dist/rest/merges.d.mts +2 -2
- package/dist/rest/namespace.d.mts +2 -0
- package/dist/rest/queue.d.mts +208 -208
- package/dist/rest/refs.d.mts +131 -131
- package/dist/rest/repos.d.mts +12 -12
- package/dist/rest/tags.d.mts +70 -70
- package/dist/rest/tokens.d.mts +23 -23
- package/dist/rest/topics.d.mts +111 -111
- package/dist/rest/trees.d.mts +57 -57
- package/dist/rest/wire.d.mts +2 -0
- package/dist/rest/wire.mjs +2 -2
- package/dist/rest/work.d.mts +6 -6
- package/dist/server/edge-node.d.mts +20 -0
- package/dist/server/edge-node.mjs +20 -0
- package/dist/server/edge.d.mts +10 -0
- package/dist/server/edge.mjs +23 -0
- package/dist/server/extension.mjs +1 -1
- package/dist/server/git-layer.d.mts +15 -4
- package/dist/server/git-layer.mjs +13 -2
- package/dist/server/git-namespace.d.mts +5 -4
- package/dist/server/git-namespace.mjs +6 -3
- package/dist/server/registry.d.mts +3 -0
- package/dist/server/registry.mjs +58 -7
- package/dist/server/server.d.mts +3 -0
- package/dist/server/server.mjs +81 -39
- package/dist/server/uploads.d.mts +14 -0
- package/dist/server/uploads.mjs +15 -0
- package/dist/storage/calls.d.mts +7 -8
- package/dist/storage/calls.mjs +14 -14
- package/dist/storage/clean-up.mjs +59 -29
- package/dist/storage/host-bucket.mjs +16 -1
- package/dist/storage/index-build.d.mts +1 -1
- package/dist/storage/layout.mjs +5 -0
- package/dist/storage/merge.d.mts +1 -1
- package/dist/storage/push-uploads.mjs +12 -16
- package/dist/storage/quarantine.d.mts +1 -1
- package/dist/storage/quarantine.mjs +51 -12
- package/dist/storage/receive-bounds.d.mts +1 -1
- package/dist/storage/repack-job.d.mts +1 -1
- package/dist/storage/repack-job.mjs +7 -14
- package/dist/storage/rows.mjs +42 -3
- package/dist/storage/runs.d.mts +1 -1
- package/dist/store/job-try.mjs +26 -0
- package/dist/store/list-job.mjs +22 -16
- package/dist/store/outbox.mjs +38 -12
- package/dist/store/promises.d.mts +6 -1
- package/dist/store/promises.mjs +74 -89
- package/dist/store/queue-jobs.mjs +22 -1
- package/dist/store/scopes.mjs +0 -10
- package/dist/sync/mirror.d.mts +1 -1
- package/dist/sync/mirror.mjs +1 -1
- package/dist/sync/publish.mjs +12 -7
- package/dist/sync/step.mjs +4 -0
- package/package.json +3 -3
- package/dist/lfs/repo.mjs +0 -42
- package/dist/storage/promise-calls.mjs +0 -29
package/dist/lfs/purge.mjs
CHANGED
|
@@ -1,50 +1,44 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { decodeRow
|
|
3
|
-
import {
|
|
4
|
-
import { ListedRow } from "./rows.mjs";
|
|
1
|
+
import { bucketDo } from "../storage/calls.mjs";
|
|
2
|
+
import { decodeRow } from "../store/errors.mjs";
|
|
3
|
+
import { ListedRow, lfsCollections } from "./rows.mjs";
|
|
5
4
|
import * as Effect from "effect/Effect";
|
|
6
|
-
/** LFS's purge over `bucket`,
|
|
7
|
-
const lfsPurge = (bucket) => /* @__PURE__ */ Effect.fnUntraced(function* (
|
|
8
|
-
const
|
|
9
|
-
const snapshot = yield* storeCall(() => store.read(scope, [
|
|
5
|
+
/** LFS's claim's purge over its `rows` and `bucket`, which charges each call. */
|
|
6
|
+
const lfsPurge = (rows, bucket) => /* @__PURE__ */ Effect.fnUntraced(function* ({ repo }) {
|
|
7
|
+
const snapshot = yield* rows.read(repo, [
|
|
10
8
|
{
|
|
11
|
-
collection:
|
|
9
|
+
collection: lfsCollections.uploads,
|
|
12
10
|
limit: 1
|
|
13
11
|
},
|
|
14
12
|
{
|
|
15
|
-
collection:
|
|
13
|
+
collection: lfsCollections.staging,
|
|
16
14
|
limit: 1
|
|
17
15
|
},
|
|
18
16
|
{
|
|
19
|
-
collection:
|
|
17
|
+
collection: lfsCollections.ending,
|
|
20
18
|
limit: 1
|
|
21
19
|
},
|
|
22
20
|
{
|
|
23
|
-
collection:
|
|
21
|
+
collection: lfsCollections.objects,
|
|
24
22
|
limit: 500
|
|
25
23
|
},
|
|
26
24
|
{
|
|
27
|
-
collection:
|
|
25
|
+
collection: lfsCollections.locks,
|
|
28
26
|
limit: 500
|
|
29
27
|
}
|
|
30
|
-
])
|
|
28
|
+
]);
|
|
31
29
|
const [uploads = [], staging = [], ending = [], listed = [], locks = []] = snapshot.results;
|
|
32
30
|
if (uploads.length + staging.length + ending.length > 0) return "waits";
|
|
33
|
-
const
|
|
34
|
-
if (
|
|
31
|
+
const found = listed.length > 0 ? listed : locks;
|
|
32
|
+
if (found.length === 0) return "done";
|
|
35
33
|
const keys = yield* Effect.forEach(listed, (row) => Effect.map(decodeRow(ListedRow, row, `LFS object ${row.id}`), (object) => object.key));
|
|
36
|
-
yield* Effect.forEach(keys, (key) =>
|
|
34
|
+
yield* Effect.forEach(keys, (key) => bucketDo(bucket.remove(key)), {
|
|
37
35
|
concurrency: 8,
|
|
38
36
|
discard: true
|
|
39
37
|
});
|
|
40
|
-
yield*
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
collection: row.collection,
|
|
45
|
-
id: row.id
|
|
46
|
-
}))
|
|
47
|
-
}));
|
|
38
|
+
yield* rows.commit(repo, snapshot.version, { delete: found.map((row) => ({
|
|
39
|
+
collection: row.collection,
|
|
40
|
+
id: row.id
|
|
41
|
+
})) });
|
|
48
42
|
return "did";
|
|
49
43
|
});
|
|
50
44
|
export { lfsPurge };
|
package/dist/lfs/rows.mjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { millis } from "../contracts/promises.mjs";
|
|
2
|
-
import { collections } from "../store/scopes.mjs";
|
|
3
2
|
import * as Schema from "effect/Schema";
|
|
4
3
|
// src/lfs/rows.ts
|
|
5
4
|
/**
|
|
@@ -8,6 +7,19 @@ import * as Schema from "effect/Schema";
|
|
|
8
7
|
* SHA-256 ever reach. A repo serves only the objects it lists, and lists one only after its bytes
|
|
9
8
|
* were checked at its key.
|
|
10
9
|
*/
|
|
10
|
+
/** LFS's collections in a repo's scope: its claim's rows, under `lfs/`. */
|
|
11
|
+
const lfsCollections = {
|
|
12
|
+
/** Each LFS object the repo lists, by its oid. Only a deleted repo unlists. */
|
|
13
|
+
objects: "lfs/objects",
|
|
14
|
+
/** Each LFS object an upload link was given for, by its oid, until listed. */
|
|
15
|
+
uploads: "lfs/uploads",
|
|
16
|
+
/** A Worker upload's staging key, by its due `removeAt` and its ID. */
|
|
17
|
+
staging: "lfs/staging",
|
|
18
|
+
/** An LFS object upkeep is deleting, by its oid, which no verify lists. */
|
|
19
|
+
ending: "lfs/ending",
|
|
20
|
+
/** Each LFS lock, by its path's SHA-256. */
|
|
21
|
+
locks: "lfs/locks"
|
|
22
|
+
};
|
|
11
23
|
/**
|
|
12
24
|
* The largest object LFS takes: R2's largest put in one request, 5 GiB less 5 MiB, since a
|
|
13
25
|
* multipart upload's result has no SHA-256 to check it by.
|
|
@@ -71,38 +83,38 @@ const objectKey = (repo, oid, generation) => `lfs/${repo}/${oid}.${generation}`;
|
|
|
71
83
|
/** A Worker upload's bytes as they stream, before they're checked. */
|
|
72
84
|
const stagingKey = (repo, id) => `lfs/${repo}/staging/${id}`;
|
|
73
85
|
const listedKey = (oid) => ({
|
|
74
|
-
collection:
|
|
86
|
+
collection: lfsCollections.objects,
|
|
75
87
|
id: oid
|
|
76
88
|
});
|
|
77
89
|
const uploadKey = (oid) => ({
|
|
78
|
-
collection:
|
|
90
|
+
collection: lfsCollections.uploads,
|
|
79
91
|
id: oid
|
|
80
92
|
});
|
|
81
93
|
/** An ending row's key: its upload's oid and generation, so two generations' rows never meet. */
|
|
82
94
|
const endingKey = (oid, generation) => ({
|
|
83
|
-
collection:
|
|
95
|
+
collection: lfsCollections.ending,
|
|
84
96
|
id: `${oid}.${generation}`
|
|
85
97
|
});
|
|
86
98
|
const lockKey = (id) => ({
|
|
87
|
-
collection:
|
|
99
|
+
collection: lfsCollections.locks,
|
|
88
100
|
id
|
|
89
101
|
});
|
|
90
102
|
/** A staging row's ID: its `removeAt`, padded so the soonest sorts first, then its own. */
|
|
91
103
|
const stagingId = (removeAt, id) => `${String(removeAt).padStart(16, "0")}.${id}`;
|
|
92
104
|
const lockRead = (id) => ({
|
|
93
|
-
collection:
|
|
105
|
+
collection: lfsCollections.locks,
|
|
94
106
|
id
|
|
95
107
|
});
|
|
96
108
|
const stagingRead = (id) => ({
|
|
97
|
-
collection:
|
|
109
|
+
collection: lfsCollections.staging,
|
|
98
110
|
id
|
|
99
111
|
});
|
|
100
112
|
const listedRead = (oid) => ({
|
|
101
|
-
collection:
|
|
113
|
+
collection: lfsCollections.objects,
|
|
102
114
|
id: oid
|
|
103
115
|
});
|
|
104
116
|
const uploadRead = (oid) => ({
|
|
105
|
-
collection:
|
|
117
|
+
collection: lfsCollections.uploads,
|
|
106
118
|
id: oid
|
|
107
119
|
});
|
|
108
|
-
export { EndingRow, ListedRow, LockRow, StagingRow, UploadRow, endingKey, largestObject, linkLife, listedKey, listedRead, lockKey, lockRead, objectKey, stagingId, stagingKey, stagingRead, streamMost, uploadGrace, uploadKey, uploadRead };
|
|
120
|
+
export { EndingRow, ListedRow, LockRow, StagingRow, UploadRow, endingKey, largestObject, lfsCollections, linkLife, listedKey, listedRead, lockKey, lockRead, objectKey, stagingId, stagingKey, stagingRead, streamMost, uploadGrace, uploadKey, uploadRead };
|
package/dist/lfs/service.d.mts
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
import "../contracts/promises.mjs";
|
|
2
1
|
import { LfsFeature } from "../contracts/lfs.mjs";
|
|
3
|
-
import "../contracts/result.mjs";
|
|
2
|
+
import { GitError } from "../contracts/result.mjs";
|
|
4
3
|
import "../core/parts.mjs";
|
|
5
|
-
import "./objects.mjs";
|
|
6
|
-
import "effect/Effect";
|
|
4
|
+
import { LfsCall } from "./objects.mjs";
|
|
5
|
+
import * as Effect from "effect/Effect";
|
|
7
6
|
import "effect/Context";
|
|
7
|
+
/** A request under a repo's `info/lfs/`: `route` is the rest of its path, as `objects/batch`. */
|
|
8
|
+
export interface LfsRoute extends LfsCall {
|
|
9
|
+
readonly route: string;
|
|
10
|
+
}
|
|
11
|
+
/** Git LFS's API for a server's repos, its objects in `bucket`. */
|
|
12
|
+
export type LfsService = (call: LfsRoute) => Effect.Effect<Response, GitError>;
|
|
8
13
|
/** Turns on Git LFS, its objects in the adapter's bucket: a server without it has no LFS. */
|
|
9
14
|
export declare const lfs: () => LfsFeature;
|
package/dist/lfs/service.mjs
CHANGED
|
@@ -1,23 +1,14 @@
|
|
|
1
1
|
import { fail } from "../contracts/result.mjs";
|
|
2
|
-
import { CoreParts } from "../core/parts.mjs";
|
|
3
2
|
import { createLock, listLocks, unlock, verifyLocks } from "./locks.mjs";
|
|
4
|
-
import { batch, receive, send,
|
|
3
|
+
import { batch, receive, send, verify } from "./objects.mjs";
|
|
5
4
|
import { lfsAnswer } from "./wire.mjs";
|
|
6
5
|
import * as Effect from "effect/Effect";
|
|
7
6
|
// src/lfs/service.ts
|
|
8
7
|
/** Turns on Git LFS, its objects in the adapter's bucket: a server without it has no LFS. */
|
|
9
8
|
const lfs = () => ({ kind: "lfs" });
|
|
10
9
|
const methodNotAllowed = (allow) => Effect.succeed(lfsAnswer(405, { message: "Method not allowed" }, { allow }));
|
|
11
|
-
/** LFS's routes over `needs`, the server's services,
|
|
12
|
-
const lfsService = (needs,
|
|
13
|
-
const signed = signingOf(bucket);
|
|
14
|
-
const routed = (call) => Effect.flatMap(Effect.service(CoreParts), (core) => served({
|
|
15
|
-
core,
|
|
16
|
-
bucket,
|
|
17
|
-
signed
|
|
18
|
-
}, call));
|
|
19
|
-
return (call) => Effect.provideContext(routed(call), needs);
|
|
20
|
-
};
|
|
10
|
+
/** LFS's routes over `parts`, provided `needs`, the server's services, which `openRepo` reads. */
|
|
11
|
+
const lfsService = (needs, parts) => (call) => Effect.provideContext(served(parts, call), needs);
|
|
21
12
|
/** `call`'s answer, by its route and method. */
|
|
22
13
|
const served = (parts, call) => {
|
|
23
14
|
const { route } = call;
|
package/dist/lfs/upkeep.mjs
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { decodeRow
|
|
3
|
-
import {
|
|
4
|
-
import { signingOf } from "./objects.mjs";
|
|
5
|
-
import { EndingRow, StagingRow, UploadRow, endingKey, listedRead, objectKey, uploadKey, uploadRead } from "./rows.mjs";
|
|
1
|
+
import { bucketDo } from "../storage/calls.mjs";
|
|
2
|
+
import { decodeRow } from "../store/errors.mjs";
|
|
3
|
+
import { EndingRow, StagingRow, UploadRow, endingKey, lfsCollections, listedRead, objectKey, uploadKey, uploadRead } from "./rows.mjs";
|
|
6
4
|
import * as Effect from "effect/Effect";
|
|
7
5
|
// src/lfs/upkeep.ts
|
|
8
6
|
/**
|
|
@@ -18,17 +16,17 @@ import * as Effect from "effect/Effect";
|
|
|
18
16
|
*/
|
|
19
17
|
/** The most rows of each kind a step ends. */
|
|
20
18
|
const upkeepPage = 500;
|
|
21
|
-
/**
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
};
|
|
19
|
+
/**
|
|
20
|
+
* LFS's claim's upkeep over its `rows` and `bucket`'s objects: `bucket` charges each call, and
|
|
21
|
+
* `signed` says the host signs LFS's links, so its uploads have upload rows to end.
|
|
22
|
+
*/
|
|
23
|
+
const lfsUpkeep = (rows, bucket, signed) => ({ repo, at }) => upkeepStep({
|
|
24
|
+
rows,
|
|
25
|
+
bucket,
|
|
26
|
+
signed,
|
|
27
|
+
repo,
|
|
28
|
+
at
|
|
29
|
+
});
|
|
32
30
|
const did = { more: true };
|
|
33
31
|
const earliest = (a, b) => a === void 0 ? b : b === void 0 ? a : Math.min(a, b);
|
|
34
32
|
/**
|
|
@@ -36,14 +34,13 @@ const earliest = (a, b) => a === void 0 ? b : b === void 0 ? a : Math.min(a, b);
|
|
|
36
34
|
* and answers `more`; with nothing due, it answers when the soonest row is.
|
|
37
35
|
*/
|
|
38
36
|
const upkeepStep = /* @__PURE__ */ Effect.fnUntraced(function* (upkeep) {
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
collection: collections.lfsEnding,
|
|
37
|
+
const snapshot = yield* upkeep.rows.read(upkeep.repo, [{
|
|
38
|
+
collection: lfsCollections.ending,
|
|
42
39
|
limit: upkeepPage
|
|
43
40
|
}, {
|
|
44
|
-
collection:
|
|
41
|
+
collection: lfsCollections.staging,
|
|
45
42
|
limit: upkeepPage
|
|
46
|
-
}])
|
|
43
|
+
}]);
|
|
47
44
|
const [ending = [], staging = []] = snapshot.results;
|
|
48
45
|
const endings = yield* Effect.forEach(ending, (row) => Effect.map(decodeRow(EndingRow, row, `LFS ending row ${row.id}`), (decoded) => ({
|
|
49
46
|
id: row.id,
|
|
@@ -66,51 +63,42 @@ const upkeepStep = /* @__PURE__ */ Effect.fnUntraced(function* (upkeep) {
|
|
|
66
63
|
});
|
|
67
64
|
/** Deletes each ending row's key, then the row, at `version`. */
|
|
68
65
|
const endObjects = /* @__PURE__ */ Effect.fnUntraced(function* (upkeep, version, rows) {
|
|
69
|
-
yield* Effect.forEach(rows, (row) =>
|
|
66
|
+
yield* Effect.forEach(rows, (row) => bucketDo(upkeep.bucket.remove(row.key)), {
|
|
70
67
|
concurrency: 8,
|
|
71
68
|
discard: true
|
|
72
69
|
});
|
|
73
|
-
yield*
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
collection: collections.lfsEnding,
|
|
78
|
-
id: row.id
|
|
79
|
-
}))
|
|
80
|
-
}));
|
|
70
|
+
yield* upkeep.rows.commit(upkeep.repo, version, { delete: rows.map((row) => ({
|
|
71
|
+
collection: lfsCollections.ending,
|
|
72
|
+
id: row.id
|
|
73
|
+
})) });
|
|
81
74
|
return did;
|
|
82
75
|
});
|
|
83
76
|
/** Deletes each due staging key, then its row, at `version`. */
|
|
84
77
|
const endStages = /* @__PURE__ */ Effect.fnUntraced(function* (upkeep, version, stages) {
|
|
85
|
-
yield* Effect.forEach(stages, (stage) =>
|
|
78
|
+
yield* Effect.forEach(stages, (stage) => bucketDo(upkeep.bucket.remove(stage.key)), {
|
|
86
79
|
concurrency: 8,
|
|
87
80
|
discard: true
|
|
88
81
|
});
|
|
89
|
-
yield*
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
collection: collections.lfsStaging,
|
|
94
|
-
id: stage.id
|
|
95
|
-
}))
|
|
96
|
-
}));
|
|
82
|
+
yield* upkeep.rows.commit(upkeep.repo, version, { delete: stages.map((stage) => ({
|
|
83
|
+
collection: lfsCollections.staging,
|
|
84
|
+
id: stage.id
|
|
85
|
+
})) });
|
|
97
86
|
return did;
|
|
98
87
|
});
|
|
99
88
|
/** Up to a page of the upload rows that are due, and when the soonest of the rest is. */
|
|
100
89
|
const dueUploads = /* @__PURE__ */ Effect.fnUntraced(function* (upkeep) {
|
|
101
|
-
const scope = repoScope(upkeep.repo);
|
|
102
90
|
const oids = [];
|
|
103
91
|
let next;
|
|
104
92
|
let after;
|
|
105
93
|
for (;;) {
|
|
106
94
|
const read = {
|
|
107
|
-
collection:
|
|
95
|
+
collection: lfsCollections.uploads,
|
|
108
96
|
limit: upkeepPage
|
|
109
97
|
};
|
|
110
|
-
const rows = (yield*
|
|
98
|
+
const rows = (yield* upkeep.rows.read(upkeep.repo, [after === void 0 ? read : {
|
|
111
99
|
...read,
|
|
112
100
|
after
|
|
113
|
-
}]))
|
|
101
|
+
}])).results[0] ?? [];
|
|
114
102
|
for (const row of rows) {
|
|
115
103
|
const upload = yield* uploadOf(row);
|
|
116
104
|
if (upload.removeAt > upkeep.at) next = earliest(next, upload.removeAt);
|
|
@@ -130,8 +118,7 @@ const uploadOf = (row) => decodeRow(UploadRow, row, `LFS object ${row.id}'s uplo
|
|
|
130
118
|
* staging keys, which their own rows end.
|
|
131
119
|
*/
|
|
132
120
|
const endUploads = /* @__PURE__ */ Effect.fnUntraced(function* (upkeep, oids) {
|
|
133
|
-
const
|
|
134
|
-
const snapshot = yield* storeCall(() => upkeep.store.read(scope, oids.flatMap((oid) => [uploadRead(oid), listedRead(oid)])));
|
|
121
|
+
const snapshot = yield* upkeep.rows.read(upkeep.repo, oids.flatMap((oid) => [uploadRead(oid), listedRead(oid)]));
|
|
135
122
|
const dropped = [];
|
|
136
123
|
const ended = [];
|
|
137
124
|
for (const [index, oid] of oids.entries()) {
|
|
@@ -146,16 +133,14 @@ const endUploads = /* @__PURE__ */ Effect.fnUntraced(function* (upkeep, oids) {
|
|
|
146
133
|
});
|
|
147
134
|
}
|
|
148
135
|
if (dropped.length === 0) return did;
|
|
149
|
-
const committed = yield*
|
|
150
|
-
id: newChangeId(),
|
|
151
|
-
expect: snapshot.version,
|
|
136
|
+
const committed = yield* upkeep.rows.commit(upkeep.repo, snapshot.version, {
|
|
152
137
|
put: ended.map(({ collection, id, key }) => ({
|
|
153
138
|
collection,
|
|
154
139
|
id,
|
|
155
140
|
value: { key }
|
|
156
141
|
})),
|
|
157
142
|
delete: dropped.map(uploadKey)
|
|
158
|
-
})
|
|
143
|
+
});
|
|
159
144
|
if (!committed.ok || ended.length === 0) return did;
|
|
160
145
|
return yield* endObjects(upkeep, committed.version, ended);
|
|
161
146
|
});
|
package/dist/node.d.mts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { NodeAnswerer, toNodeHandler, toNodeMiddleware } from "./server/edge-node.mjs";
|
|
2
|
+
import { NodeHandler, NodeMiddleware, NodeNext, NodeRequest, NodeResponse } from "./http/node.mjs";
|
|
3
|
+
export { type NodeAnswerer, type NodeHandler, type NodeMiddleware, type NodeNext, type NodeRequest, type NodeResponse, toNodeHandler, toNodeMiddleware };
|
package/dist/node.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { toNodeHandler, toNodeMiddleware } from "./
|
|
1
|
+
export { toNodeHandler, toNodeMiddleware } from "./server/edge-node.mjs";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Oid } from "../../contracts/ids.mjs";
|
|
2
2
|
import { WireDecodeError, WireEncodeError } from "../bytes/errors.mjs";
|
|
3
|
+
import "./lines.mjs";
|
|
3
4
|
import { PushLimits } from "./push-limits.mjs";
|
|
4
5
|
import * as Schema from "effect/Schema";
|
|
5
6
|
import * as Effect from "effect/Effect";
|
|
@@ -51,17 +52,10 @@ export declare const receivePackCapabilities: (agent: string, offers?: {
|
|
|
51
52
|
}) => string[];
|
|
52
53
|
/**
|
|
53
54
|
* `info/refs` for `service` in v0, as `git http-backend` answers it: the service line and a
|
|
54
|
-
* flush, then `served`'s refs with `capabilities` on the first
|
|
55
|
-
* break its line is refused.
|
|
55
|
+
* flush, then `served`'s refs with `capabilities` on the first, never one under Git's own
|
|
56
|
+
* `refs/import/`. A ref or a capability that would break its line is refused.
|
|
56
57
|
*/
|
|
57
|
-
export declare const encodeAdvertisement: (service: GitService, served:
|
|
58
|
-
readonly head?: string;
|
|
59
|
-
readonly refs: readonly {
|
|
60
|
-
readonly name: string;
|
|
61
|
-
readonly oid: string;
|
|
62
|
-
readonly peeled?: string;
|
|
63
|
-
}[];
|
|
64
|
-
}, capabilities: readonly string[]) => Effect.Effect<Uint8Array<ArrayBuffer>, WireEncodeError, never>;
|
|
58
|
+
export declare const encodeAdvertisement: (service: GitService, served: ServedRefs, capabilities: ReadonlyArray<string>) => Effect.Effect<Uint8Array<ArrayBuffer>, WireEncodeError>;
|
|
65
59
|
/** What a client reads of a source's advertisement: the refs it keeps, and the branch `HEAD` names. */
|
|
66
60
|
export type SourceRefs = {
|
|
67
61
|
readonly kind: 'read';
|
|
@@ -2,7 +2,7 @@ import { Oid } from "../../contracts/ids.mjs";
|
|
|
2
2
|
import { joinedBytes } from "../bytes/joined.mjs";
|
|
3
3
|
import { isOid, quoted } from "../bytes/text.mjs";
|
|
4
4
|
import { pktText, readPkt } from "../framing/pkt-line.mjs";
|
|
5
|
-
import { byName, decoded, encodeErr, isWord, listsRef, refusedText, textLines, unwritable } from "./lines.mjs";
|
|
5
|
+
import { byName, decoded, encodeErr, gitsOwnRefs, isWord, listsRef, refusedText, textLines, unwritable } from "./lines.mjs";
|
|
6
6
|
import { pushLimitOffers } from "./push-limits.mjs";
|
|
7
7
|
import { pushUploadOffer } from "./push-uploads.mjs";
|
|
8
8
|
import * as Schema from "effect/Schema";
|
|
@@ -81,22 +81,26 @@ const receivePackCapabilities = (agent, offers = {}) => [
|
|
|
81
81
|
...offers.uploadAbove === void 0 ? [] : [pushUploadOffer(offers.uploadAbove)],
|
|
82
82
|
...pushLimitOffers(offers.limits ?? {})
|
|
83
83
|
];
|
|
84
|
-
/** The refs v0 lists, by Git's order: never one under a `hiddenRefs` prefix. */
|
|
85
|
-
const listed = (served) => served.refs.filter((ref) => listsRef(ref.name, [])).toSorted((a, b) => byName(a.name, b.name));
|
|
86
84
|
/**
|
|
87
|
-
* `info/refs` for `service` in v0, as `
|
|
88
|
-
*
|
|
89
|
-
* break its line is refused.
|
|
85
|
+
* `info/refs` for `service` in v0, as `encodeAdvertisement` writes it, with none of the refs under
|
|
86
|
+
* `table`'s prefixes: a server's own, its registered prefixes among them.
|
|
90
87
|
*/
|
|
91
|
-
const
|
|
88
|
+
const advertisementOf = /* @__PURE__ */ Effect.fnUntraced(function* (service, served, capabilities, table) {
|
|
92
89
|
const head = headOf(served);
|
|
93
|
-
const lines = advertisementPages(service, service === "git-upload-pack" && head !== void 0 ? { headRef: head } : {}, capabilities);
|
|
90
|
+
const lines = advertisementPages(service, service === "git-upload-pack" && head !== void 0 ? { headRef: head } : {}, capabilities, table);
|
|
91
|
+
const refs = served.refs.toSorted((a, b) => byName(a.name, b.name));
|
|
94
92
|
return joinedBytes([
|
|
95
93
|
yield* lines.start,
|
|
96
|
-
yield* lines.page(
|
|
94
|
+
yield* lines.page(refs),
|
|
97
95
|
yield* lines.end
|
|
98
96
|
]);
|
|
99
97
|
});
|
|
98
|
+
/**
|
|
99
|
+
* `info/refs` for `service` in v0, as `git http-backend` answers it: the service line and a
|
|
100
|
+
* flush, then `served`'s refs with `capabilities` on the first, never one under Git's own
|
|
101
|
+
* `refs/import/`. A ref or a capability that would break its line is refused.
|
|
102
|
+
*/
|
|
103
|
+
const encodeAdvertisement = (service, served, capabilities) => advertisementOf(service, served, capabilities, gitsOwnRefs);
|
|
100
104
|
/** `served`'s view of a streamed listing's head, for what reads `HEAD` from its refs. */
|
|
101
105
|
const servedHead = (listed) => {
|
|
102
106
|
const refs = listed.headRef === void 0 ? [] : [listed.headRef];
|
|
@@ -115,7 +119,7 @@ const onLines = (what, texts) => {
|
|
|
115
119
|
* each page's refs, `capabilities` on the first line written, each tag's peel after it for
|
|
116
120
|
* `git-upload-pack`, and a ref-less line for the capabilities when no ref came, then the flush.
|
|
117
121
|
*/
|
|
118
|
-
const advertisementPages = (service, listed, capabilities) => {
|
|
122
|
+
const advertisementPages = (service, listed, capabilities, table) => {
|
|
119
123
|
const uploading = service === "git-upload-pack";
|
|
120
124
|
const caps = capabilities.join(" ");
|
|
121
125
|
let first = true;
|
|
@@ -132,7 +136,7 @@ const advertisementPages = (service, listed, capabilities) => {
|
|
|
132
136
|
return {
|
|
133
137
|
start: Effect.andThen(onLines("advertisement", capabilities), () => Effect.map(Effect.all([serviceLine, textLines(lines(head), false)]), joinedBytes)),
|
|
134
138
|
page: (refs) => {
|
|
135
|
-
const shown = refs.filter((ref) => listsRef(ref.name, []));
|
|
139
|
+
const shown = refs.filter((ref) => listsRef(table, ref.name, []));
|
|
136
140
|
return Effect.andThen(onLines("advertisement", shown.map((ref) => ref.name)), () => textLines(lines(shown), false));
|
|
137
141
|
},
|
|
138
142
|
end: Effect.suspend(() => textLines(first ? [`${zero} capabilities^{}\0${caps}\n`] : [], true))
|
|
@@ -254,4 +258,4 @@ const advertisedLines = (bytes) => decoded("advertisement", () => {
|
|
|
254
258
|
const advertisedHead = (bytes) => Effect.map(advertisedLines(bytes), (lines) => lines.find((line) => line.name === "HEAD")?.id);
|
|
255
259
|
/** Every ref advertised, by name, each at its own object: an annotated tag's is the tag's. */
|
|
256
260
|
const advertisedRefs = (bytes) => Effect.map(advertisedLines(bytes), (lines) => new Map(lines.filter((line) => line.name.startsWith("refs/") && !line.name.endsWith("^{}")).map((line) => [line.name, line.id])));
|
|
257
|
-
export { AdvertisedRef, ServedRefs, advertisedHead, advertisedRefs, advertisedSource, advertisementPages, encodeAdvertisement, encodeRefusedAdvertisement, headOf, pastServiceLine, receivePackCapabilities, servedHead, uploadPackCapabilities };
|
|
261
|
+
export { AdvertisedRef, ServedRefs, advertisedHead, advertisedRefs, advertisedSource, advertisementOf, advertisementPages, encodeAdvertisement, encodeRefusedAdvertisement, headOf, pastServiceLine, receivePackCapabilities, servedHead, uploadPackCapabilities };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { WireEncodeError } from "../bytes/errors.mjs";
|
|
2
|
-
import "../../contracts/
|
|
2
|
+
import { RefOwner } from "../../contracts/git.mjs";
|
|
3
3
|
import * as Effect from "effect/Effect";
|
|
4
4
|
import "effect/Result";
|
|
5
5
|
/**
|
|
@@ -7,4 +7,16 @@ import "effect/Result";
|
|
|
7
7
|
* alike. It ends without a newline, as `gitprotocol-pack`'s `error-line` does and Git writes it. A
|
|
8
8
|
* message holding a newline is refused, since the line would end early.
|
|
9
9
|
*/
|
|
10
|
-
export declare const encodeErr: (message: string) => Effect.Effect<Uint8Array<ArrayBuffer>, WireEncodeError>;
|
|
10
|
+
export declare const encodeErr: (message: string) => Effect.Effect<Uint8Array<ArrayBuffer>, WireEncodeError>;
|
|
11
|
+
/**
|
|
12
|
+
* A prefix whose refs are Git's own: only `owner`, the claim that registered it or an import,
|
|
13
|
+
* moves one, and no push or API call does. v0 never advertises them. v2's `ls-refs`, and
|
|
14
|
+
* `refs.list`, list one only for an asked prefix under it when `underPrefix` is `listed`, and never
|
|
15
|
+
* when it's `hidden`, nor does a fetch reach a commit only a `hidden` one holds.
|
|
16
|
+
*/
|
|
17
|
+
export interface HiddenRefs {
|
|
18
|
+
readonly owner: RefOwner;
|
|
19
|
+
readonly underPrefix: 'listed' | 'hidden';
|
|
20
|
+
/** Who moves them, as a refusal says it. */
|
|
21
|
+
readonly mover: string;
|
|
22
|
+
}
|
|
@@ -79,43 +79,54 @@ function byName(a, b) {
|
|
|
79
79
|
}
|
|
80
80
|
/** Whether a line can hold `text` as one word: no NUL, newline or space to end it early. */
|
|
81
81
|
const isWord = (text) => !/[\0\n ]/.test(text);
|
|
82
|
-
/**
|
|
83
|
-
const
|
|
84
|
-
prefix: "refs/queue/",
|
|
85
|
-
owner: "queue",
|
|
86
|
-
underPrefix: "listed",
|
|
87
|
-
mover: "the merge queue"
|
|
88
|
-
}, {
|
|
82
|
+
/** An import's owner: where it stages what it publishes, which only sync's writes move. */
|
|
83
|
+
const importOwner = Object.freeze({
|
|
89
84
|
prefix: "refs/import/",
|
|
90
|
-
owner: "import"
|
|
85
|
+
owner: "import"
|
|
86
|
+
});
|
|
87
|
+
/**
|
|
88
|
+
* Git's own rows, beside each registered prefix's, which a server's registry adds at its seal: a
|
|
89
|
+
* client's table, and the one this module's public encoders read.
|
|
90
|
+
*/
|
|
91
|
+
const gitsOwnRefs = [{
|
|
92
|
+
owner: importOwner,
|
|
91
93
|
underPrefix: "hidden",
|
|
92
94
|
mover: "an import"
|
|
93
95
|
}];
|
|
94
|
-
/** The hidden prefix `name` is under, if any. */
|
|
95
|
-
const hiddenUnder = (name) => hiddenRefs.find((hidden) => name.startsWith(hidden.prefix));
|
|
96
96
|
/**
|
|
97
|
-
*
|
|
98
|
-
*
|
|
97
|
+
* A registered prefix's row, as the registry adds it for a claim with `refs`: listed for a prefix
|
|
98
|
+
* under it, and moved only by the claim, which a refusal names.
|
|
99
|
+
*/
|
|
100
|
+
const registeredRow = (owner) => ({
|
|
101
|
+
owner,
|
|
102
|
+
underPrefix: "listed",
|
|
103
|
+
mover: `the ${owner.owner} feature`
|
|
104
|
+
});
|
|
105
|
+
/** `table`'s hidden prefix `name` is under, if any. */
|
|
106
|
+
const hiddenUnder = (table, name) => table.find((hidden) => name.startsWith(hidden.owner.prefix));
|
|
107
|
+
/**
|
|
108
|
+
* Whether `ref` is Git's own and `as` its owner, the very one the registry made or `importOwner`:
|
|
109
|
+
* a move of it no rule, hook, `ref.updated` or index update sees, and that owner's view sees it.
|
|
99
110
|
*/
|
|
100
|
-
const gitsOwnMove = (
|
|
111
|
+
const gitsOwnMove = (table, as, ref) => as !== void 0 && hiddenUnder(table, ref)?.owner === as;
|
|
101
112
|
/**
|
|
102
113
|
* Whether a host's own listing for `prefix` shows `name`, as `refs.list` does: a ref under a
|
|
103
114
|
* hidden prefix only for a prefix under it, of either kind, since the host's code asks for it.
|
|
104
115
|
*/
|
|
105
|
-
const hostLists = (name, prefix) => {
|
|
106
|
-
const hidden = hiddenUnder(name);
|
|
107
|
-
return hidden === void 0 || prefix !== void 0 && prefix.startsWith(hidden.prefix);
|
|
116
|
+
const hostLists = (table, name, prefix) => {
|
|
117
|
+
const hidden = hiddenUnder(table, name);
|
|
118
|
+
return hidden === void 0 || prefix !== void 0 && prefix.startsWith(hidden.owner.prefix);
|
|
108
119
|
};
|
|
109
120
|
/** Whether a fetch reaches what `name` holds: every ref but one whose prefix is `hidden`. */
|
|
110
|
-
const fetchReaches = (name) => hiddenUnder(name)?.underPrefix !== "hidden";
|
|
121
|
+
const fetchReaches = (table, name) => hiddenUnder(table, name)?.underPrefix !== "hidden";
|
|
111
122
|
/**
|
|
112
123
|
* Whether a client's listing for `prefixes` shows `name`: every ref not under a hidden prefix when there
|
|
113
124
|
* are none, and otherwise those that start with one, a hidden one only for a prefix under it whose
|
|
114
125
|
* refs are `listed`.
|
|
115
126
|
*/
|
|
116
|
-
const listsRef = (name, prefixes) => {
|
|
117
|
-
const hidden = hiddenUnder(name);
|
|
127
|
+
const listsRef = (table, name, prefixes) => {
|
|
128
|
+
const hidden = hiddenUnder(table, name);
|
|
118
129
|
if (prefixes.length === 0) return hidden === void 0;
|
|
119
|
-
return prefixes.some((prefix) => name.startsWith(prefix) && (hidden === void 0 || hidden.underPrefix === "listed" && prefix.startsWith(hidden.prefix)));
|
|
130
|
+
return prefixes.some((prefix) => name.startsWith(prefix) && (hidden === void 0 || hidden.underPrefix === "listed" && prefix.startsWith(hidden.owner.prefix)));
|
|
120
131
|
};
|
|
121
|
-
export { byName, decoded, encodeErr, fetchReaches, gitsOwnMove,
|
|
132
|
+
export { byName, decoded, encodeErr, fetchReaches, gitsOwnMove, gitsOwnRefs, hiddenUnder, hostLists, importOwner, isWord, listsRef, readSection, refusedText, registeredRow, textLines, unwritable };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { WireDecodeError, WireEncodeError } from "../bytes/errors.mjs";
|
|
2
|
-
import "./advertisement.mjs";
|
|
2
|
+
import { ServedRefs } from "./advertisement.mjs";
|
|
3
|
+
import "./lines.mjs";
|
|
3
4
|
import * as Schema from "effect/Schema";
|
|
4
5
|
import * as Effect from "effect/Effect";
|
|
5
6
|
/**
|
|
@@ -52,21 +53,9 @@ export declare const readLsRefs: (request: V2Request) => Effect.Effect<LsRefs, W
|
|
|
52
53
|
* `ls-refs`'s answer, as Git's: `HEAD` first when it resolves, or `unborn HEAD` when it doesn't
|
|
53
54
|
* and both `unborn` and `symrefs` were asked, then each listed ref in Git's order, each line
|
|
54
55
|
* `<oid> <name>`, with `symref-target:` for `HEAD` and `peeled:` for an annotated tag as asked,
|
|
55
|
-
* then a flush.
|
|
56
|
+
* then a flush. It hides only Git's own `refs/import/`: a server hides each claim's prefix too.
|
|
56
57
|
*/
|
|
57
|
-
export declare const encodeLsRefs: (served:
|
|
58
|
-
readonly head?: string;
|
|
59
|
-
readonly refs: readonly {
|
|
60
|
-
readonly name: string;
|
|
61
|
-
readonly oid: string;
|
|
62
|
-
readonly peeled?: string;
|
|
63
|
-
}[];
|
|
64
|
-
}, asked: {
|
|
65
|
-
readonly peel: boolean;
|
|
66
|
-
readonly symrefs: boolean;
|
|
67
|
-
readonly unborn: boolean;
|
|
68
|
-
readonly prefixes: readonly string[];
|
|
69
|
-
}) => Effect.Effect<Uint8Array<ArrayBuffer>, WireEncodeError, never>;
|
|
58
|
+
export declare const encodeLsRefs: (served: ServedRefs, asked: LsRefs) => Effect.Effect<Uint8Array<ArrayBuffer>, WireEncodeError>;
|
|
70
59
|
/**
|
|
71
60
|
* What a v2 `info/refs` answer says: `v2` with its capabilities when it starts `version 2`, as a
|
|
72
61
|
* server that speaks v2 answers a client that asked for it, else `v0`, an advertisement of refs.
|