@ref0/git 0.11.0 → 0.14.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 +8 -7
- package/dist/auth/auth.d.mts +2 -2
- package/dist/auth/auth.mjs +3 -6
- package/dist/auth/authorize.mjs +1 -17
- package/dist/auth/helpers.mjs +3 -11
- package/dist/auth/host-services.mjs +11 -0
- package/dist/auth/policy.d.mts +27 -7
- package/dist/auth/policy.mjs +8 -4
- package/dist/auth/tokens-layer.d.mts +1 -2
- package/dist/auth/tokens-layer.mjs +2 -3
- package/dist/auth/tokens-public.d.mts +3 -3
- package/dist/auth/tokens.d.mts +1 -8
- package/dist/auth/tokens.mjs +1 -8
- package/dist/auth.d.mts +1 -4
- package/dist/auth.mjs +1 -3
- package/dist/client/git-http.mjs +18 -4
- package/dist/client/push-upload.mjs +33 -7
- package/dist/client/remote.mjs +94 -28
- package/dist/client/slice-push.d.mts +1 -1
- package/dist/contracts/access.d.mts +8 -8
- package/dist/contracts/actors.d.mts +2 -34
- package/dist/contracts/blobs.d.mts +2 -2
- package/dist/contracts/client.d.mts +8 -3
- package/dist/contracts/commits.d.mts +10 -2
- package/dist/contracts/commits.mjs +9 -1
- package/dist/contracts/files.d.mts +2 -2
- package/dist/contracts/forks.d.mts +14 -3
- package/dist/contracts/git.d.mts +41 -12
- package/dist/contracts/git.mjs +3 -2
- package/dist/contracts/lfs.d.mts +0 -7
- package/dist/contracts/objects.d.mts +80 -10
- package/dist/contracts/operations.d.mts +3 -0
- package/dist/contracts/operations.mjs +12 -2
- package/dist/contracts/push-uploads.d.mts +44 -5
- package/dist/contracts/push-uploads.mjs +7 -3
- package/dist/contracts/refs.d.mts +28 -6
- package/dist/contracts/remote.mjs +1 -3
- package/dist/contracts/repo-records.d.mts +1 -0
- package/dist/contracts/repos.d.mts +90 -2
- package/dist/contracts/repos.mjs +29 -2
- package/dist/contracts/result.d.mts +30 -23
- package/dist/contracts/result.mjs +24 -9
- package/dist/contracts/rules.d.mts +22 -22
- package/dist/contracts/server.d.mts +28 -77
- package/dist/contracts/signin.d.mts +1 -1
- package/dist/contracts/sync.d.mts +90 -19
- package/dist/contracts/sync.mjs +34 -10
- package/dist/contracts/tokens.d.mts +1 -6
- package/dist/contracts/tokens.mjs +1 -2
- package/dist/contracts/topics.d.mts +0 -5
- package/dist/contracts/work.d.mts +66 -2
- package/dist/contracts/work.mjs +8 -1
- package/dist/core/access.d.mts +1 -0
- package/dist/core/access.mjs +34 -13
- package/dist/core/ancestry.d.mts +9 -0
- package/dist/core/ancestry.mjs +6 -6
- package/dist/core/asked.mjs +68 -0
- package/dist/core/call-names.mjs +1 -0
- package/dist/core/call-services.mjs +2 -1
- package/dist/core/events/deliver.d.mts +1 -0
- package/dist/core/events/deliver.mjs +15 -3
- package/dist/core/forks.mjs +42 -16
- package/dist/core/imports.mjs +156 -13
- package/dist/core/index-job.mjs +9 -6
- package/dist/core/job-view.mjs +8 -9
- package/dist/core/mirror-rows.mjs +19 -4
- package/dist/core/objects/commits.mjs +16 -6
- package/dist/core/objects/reading.mjs +17 -9
- package/dist/core/parts.d.mts +8 -2
- package/dist/core/parts.mjs +1 -4
- package/dist/core/purge.mjs +76 -6
- package/dist/core/push-decide.mjs +1 -1
- package/dist/core/push-files.d.mts +12 -0
- package/dist/core/push-files.mjs +225 -0
- package/dist/core/push-repo.d.mts +8 -0
- package/dist/core/push-repo.mjs +56 -0
- package/dist/core/push.d.mts +17 -0
- package/dist/core/push.mjs +107 -32
- package/dist/core/receipts.mjs +26 -10
- package/dist/core/ref-view.mjs +59 -5
- package/dist/core/refs.mjs +18 -10
- package/dist/core/registered-rows.mjs +7 -5
- package/dist/core/repack.mjs +16 -11
- package/dist/core/repo-info.mjs +16 -9
- package/dist/core/repos.mjs +30 -14
- package/dist/core/saved-caller-views.d.mts +18 -0
- package/dist/core/saved-caller-views.mjs +17 -4
- package/dist/core/saved-callers-public.d.mts +3 -3
- package/dist/core/saved-callers-public.mjs +3 -2
- package/dist/core/saved-callers.d.mts +7 -0
- package/dist/core/seam.mjs +2 -2
- package/dist/core/view.d.mts +6 -0
- package/dist/core/view.mjs +45 -12
- package/dist/core/work.mjs +47 -22
- package/dist/effect.d.mts +3 -1
- package/dist/effect.mjs +3 -1
- package/dist/engine/reads.mjs +13 -6
- package/dist/engine/walk.mjs +4 -4
- package/dist/event-streams/event-streams.d.mts +1 -1
- package/dist/event-streams/event-streams.mjs +1 -1
- package/dist/event-streams/stream.d.mts +1 -1
- package/dist/event-streams/stream.mjs +1 -1
- package/dist/extend.d.mts +4 -3
- package/dist/extend.mjs +3 -2
- package/dist/http/answers.mjs +4 -2
- package/dist/http/core-parts.mjs +64 -15
- package/dist/http/handler.mjs +2 -2
- package/dist/http/node.mjs +5 -4
- package/dist/http/parts.d.mts +1 -0
- package/dist/http/push-upload-job.mjs +503 -0
- package/dist/http/push-uploads.d.mts +1 -0
- package/dist/http/push-uploads.mjs +120 -59
- package/dist/http/upload-pack.mjs +7 -6
- package/dist/index.d.mts +23 -24
- package/dist/index.mjs +4 -7
- package/dist/lfs/base.d.mts +7 -3
- package/dist/lfs/base.mjs +2 -1
- package/dist/lfs/copy.d.mts +46 -0
- package/dist/lfs/copy.mjs +26 -0
- package/dist/lfs/layer.mjs +4 -2
- package/dist/lfs/locks.mjs +14 -9
- package/dist/lfs/objects.d.mts +6 -0
- package/dist/lfs/objects.mjs +95 -61
- package/dist/lfs/rows.d.mts +13 -0
- package/dist/lfs/service.d.mts +1 -7
- package/dist/lfs/service.mjs +1 -9
- package/dist/lfs/upload-most.mjs +5 -5
- package/dist/node.d.mts +2 -2
- package/dist/protocol/bytes/sha256-hasher.d.mts +15 -0
- package/dist/protocol/bytes/sha256.d.mts +32 -0
- package/dist/protocol/bytes/sha256.mjs +105 -49
- package/dist/protocol/wire/advertisement.mjs +9 -4
- package/dist/protocol/wire/lines.d.mts +4 -2
- package/dist/protocol/wire/lines.mjs +11 -5
- package/dist/protocol/wire/push-uploads.mjs +13 -1
- package/dist/protocol/wire/v2.mjs +2 -2
- package/dist/protocol.d.mts +3 -1
- package/dist/protocol.mjs +3 -1
- package/dist/queue/advance.mjs +1 -1
- package/dist/queue/calls.mjs +21 -1
- package/dist/queue/host.d.mts +1 -7
- package/dist/queue/host.mjs +1 -7
- package/dist/queue/layer.mjs +1 -1
- package/dist/queue/trim.mjs +1 -1
- package/dist/rest/blobs.d.mts +16 -8
- package/dist/rest/blobs.mjs +1 -1
- package/dist/rest/caller.d.mts +49 -9
- package/dist/rest/caller.mjs +1 -1
- package/dist/rest/client.d.mts +10 -3
- package/dist/rest/client.mjs +4 -0
- package/dist/rest/commits.d.mts +272 -239
- package/dist/rest/errors.d.mts +24 -4
- package/dist/rest/events.d.mts +9 -6
- package/dist/rest/events.mjs +1 -2
- package/dist/rest/files.d.mts +112 -100
- package/dist/rest/forks.d.mts +146 -122
- package/dist/rest/handler.mjs +4 -57
- package/dist/rest/handlers.d.mts +1 -1
- package/dist/rest/handlers.mjs +18 -4
- package/dist/rest/layer.mjs +10 -2
- package/dist/rest/me.d.mts +8 -4
- package/dist/rest/merges.d.mts +8 -4
- package/dist/rest/paths.mjs +1 -0
- package/dist/rest/queue.d.mts +292 -236
- package/dist/rest/refs.d.mts +98 -69
- package/dist/rest/repos.d.mts +133 -105
- package/dist/rest/tags.d.mts +100 -88
- package/dist/rest/tokens.d.mts +192 -168
- package/dist/rest/topics.d.mts +154 -134
- package/dist/rest/trees.d.mts +32 -16
- package/dist/rest/work.d.mts +467 -20
- package/dist/rest/work.mjs +8 -0
- package/dist/server/edge-node.d.mts +9 -13
- package/dist/server/edge-node.mjs +9 -12
- package/dist/server/git-layer.d.mts +1 -6
- package/dist/server/git-layer.mjs +2 -2
- package/dist/server/git-namespace.d.mts +4 -4
- package/dist/server/joined.d.mts +15 -22
- package/dist/server/joined.mjs +5 -29
- package/dist/server/lifecycle.mjs +107 -23
- package/dist/server/registry.mjs +9 -1
- package/dist/server/server.mjs +139 -216
- package/dist/storage/budget.mjs +2 -2
- package/dist/storage/clean-up.mjs +13 -10
- package/dist/storage/fetch.mjs +13 -8
- package/dist/storage/file-limits.mjs +24 -0
- package/dist/storage/index-build.d.mts +1 -0
- package/dist/storage/index-build.mjs +106 -62
- package/dist/storage/index-fetch.mjs +16 -3
- package/dist/storage/index-reach.mjs +33 -5
- package/dist/storage/index-remap.mjs +8 -1
- package/dist/storage/index-shallow.mjs +5 -3
- package/dist/storage/largest-files.mjs +48 -0
- package/dist/storage/lfs-pointers.mjs +10 -1
- package/dist/storage/loose.mjs +3 -1
- package/dist/storage/memory-budget.mjs +154 -8
- package/dist/storage/merge-cut.mjs +5 -4
- package/dist/storage/pack-reads.mjs +246 -34
- package/dist/storage/pack-receive.mjs +83 -25
- package/dist/storage/packs.mjs +37 -21
- package/dist/storage/prune-keep.mjs +203 -34
- package/dist/storage/prune-seen.mjs +11 -6
- package/dist/storage/prune-walk.mjs +219 -81
- package/dist/storage/prune.mjs +629 -196
- package/dist/storage/push-uploads.mjs +36 -12
- package/dist/storage/quarantine.mjs +9 -7
- package/dist/storage/ready.mjs +47 -19
- package/dist/storage/receive-bounds.mjs +29 -8
- package/dist/storage/receive-state.mjs +8 -0
- package/dist/storage/receive-steps.mjs +71 -18
- package/dist/storage/repack.d.mts +1 -1
- package/dist/storage/repack.mjs +1 -8
- package/dist/storage/rows.mjs +12 -1
- package/dist/storage/shallow.d.mts +1 -0
- package/dist/storage/shallow.mjs +26 -4
- package/dist/storage/stream-whole.mjs +5 -2
- package/dist/storage/visible.mjs +29 -1
- package/dist/storage/walk.mjs +2 -1
- package/dist/store/catalogue.mjs +1 -0
- package/dist/store/cursor-seal-namespace.d.mts +2 -0
- package/dist/store/cursor-seal-public.d.mts +5 -0
- package/dist/store/cursor-seal-public.mjs +5 -0
- package/dist/store/cursor-seal.d.mts +16 -2
- package/dist/store/cursor-seal.mjs +26 -14
- package/dist/store/errors.mjs +9 -1
- package/dist/store/records.d.mts +2 -0
- package/dist/store/records.mjs +9 -6
- package/dist/store/repo-record.d.mts +27 -0
- package/dist/store/repo-record.mjs +141 -4
- package/dist/store/scopes.mjs +10 -2
- package/dist/sync/bound.d.mts +2 -0
- package/dist/sync/bound.mjs +11 -2
- package/dist/sync/github.d.mts +6 -1
- package/dist/sync/github.mjs +63 -42
- package/dist/sync/http.mjs +36 -1
- package/dist/sync/import.mjs +4 -2
- package/dist/sync/layer.mjs +6 -2
- package/dist/sync/lfs-batch.mjs +119 -0
- package/dist/sync/lfs-copy.mjs +251 -0
- package/dist/sync/mirror.mjs +227 -147
- package/dist/sync/said.mjs +204 -0
- package/dist/sync/smart-http.mjs +4 -2
- package/dist/sync/step.mjs +33 -13
- package/dist/sync/tries.mjs +71 -24
- package/dist/sync.d.mts +2 -2
- package/dist/topics/advance.mjs +10 -3
- package/dist/topics/host.mjs +1 -19
- package/dist/topics/layer.mjs +1 -1
- package/package.json +3 -8
- package/dist/auth/bridge.mjs +0 -30
- package/dist/auth/helpers.d.mts +0 -17
- package/dist/core/purge.d.mts +0 -8
- package/dist/core/registered-rows.d.mts +0 -4
- package/dist/core/repack.d.mts +0 -11
- package/dist/http/handler.d.mts +0 -2
- package/dist/rest/handler.d.mts +0 -21
- package/dist/rest.d.mts +0 -2
- package/dist/rest.mjs +0 -1
- package/dist/server/registry.d.mts +0 -16
- package/dist/server/server.d.mts +0 -36
- package/dist/storage/repack-job.d.mts +0 -3
- package/dist/topics/host.d.mts +0 -7
package/dist/rest/handler.mjs
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { gitError } from "../contracts/result.mjs";
|
|
2
|
-
import { lazyParts, seamOf } from "../core/seam.mjs";
|
|
3
2
|
import { RequestCalls, RequestCount } from "../store/call-count.mjs";
|
|
4
3
|
import { isServerClosed } from "../store/closed.mjs";
|
|
5
4
|
import { GitRestApi } from "./api.mjs";
|
|
6
|
-
import {
|
|
5
|
+
import { IncomingRequest } from "./caller.mjs";
|
|
7
6
|
import { jsonError } from "./errors.mjs";
|
|
8
7
|
import { GitRestHandlers } from "./handlers.mjs";
|
|
9
8
|
import { normalBase, restPath, wireRepoPath } from "./paths.mjs";
|
|
10
9
|
import { exitIn, noCall } from "../store/crossing.mjs";
|
|
11
10
|
import { answerSpent } from "../store/errors.mjs";
|
|
12
|
-
import
|
|
11
|
+
import "effect/Effect";
|
|
13
12
|
import * as Option from "effect/Option";
|
|
14
13
|
import * as Cause from "effect/Cause";
|
|
15
14
|
import * as Exit from "effect/Exit";
|
|
@@ -31,11 +30,6 @@ const failed = (cause) => {
|
|
|
31
30
|
onSome: jsonError
|
|
32
31
|
});
|
|
33
32
|
};
|
|
34
|
-
/** `door`'s refusal now, thrown when it's the closed one: a failed build answers as JSON. */
|
|
35
|
-
const askClosed = (door) => {
|
|
36
|
-
const refused = door?.refusal();
|
|
37
|
-
if (refused !== void 0 && isServerClosed(refused)) throw refused;
|
|
38
|
-
};
|
|
39
33
|
const notFound = () => jsonError(gitError("NOT_FOUND", "Nothing is served at this URL"));
|
|
40
34
|
/** A 404 the router sent, not a handler: an owned URL with no route for its method or tail. */
|
|
41
35
|
const isRouterMiss = (response) => response.status === 404 && !(response.headers.get("content-type") ?? "").includes("json");
|
|
@@ -89,58 +83,11 @@ const restApp = (parts) => {
|
|
|
89
83
|
const url = new URL(request.url);
|
|
90
84
|
const path = restPath(base, url.pathname);
|
|
91
85
|
if (path === void 0) return void 0;
|
|
92
|
-
|
|
93
|
-
try {
|
|
94
|
-
return await answer(request, url, path);
|
|
95
|
-
} finally {
|
|
96
|
-
askClosed(parts.door);
|
|
97
|
-
}
|
|
86
|
+
return answer(request, url, path);
|
|
98
87
|
};
|
|
99
88
|
return {
|
|
100
89
|
owned,
|
|
101
90
|
dispose: web.dispose
|
|
102
91
|
};
|
|
103
92
|
};
|
|
104
|
-
|
|
105
|
-
const serveRest = (parts) => {
|
|
106
|
-
const { owned, dispose } = restApp(parts);
|
|
107
|
-
const route = async (request) => await owned(request) ?? await parts.route(request);
|
|
108
|
-
return {
|
|
109
|
-
fetch: async (request) => await route(request) ?? notFound(),
|
|
110
|
-
route,
|
|
111
|
-
dispose
|
|
112
|
-
};
|
|
113
|
-
};
|
|
114
|
-
/**
|
|
115
|
-
* Git's REST API over a server `createGitServer` made: `fetch` answers REST's URLs, then Git's
|
|
116
|
-
* `route`, then a JSON `404`; `route` answers the same and `undefined` outside them.
|
|
117
|
-
*/
|
|
118
|
-
const createRestHandler = (git) => {
|
|
119
|
-
const seam = seamOf(git);
|
|
120
|
-
if (seam === void 0) throw new TypeError("createRestHandler takes a server createGitServer made");
|
|
121
|
-
const { basePath, identify, authorize, callsFor, tokensOn, renamedTo, listen } = lazyParts(seam);
|
|
122
|
-
const { door } = seam;
|
|
123
|
-
const services = Context.make(GitRestServices, {
|
|
124
|
-
basePath,
|
|
125
|
-
identify,
|
|
126
|
-
callsFor,
|
|
127
|
-
tokensOn,
|
|
128
|
-
authorize,
|
|
129
|
-
listen
|
|
130
|
-
});
|
|
131
|
-
const renamedFor = (request, repo) => Effect.flatMap(identify(request), (caller) => renamedTo(caller, repo));
|
|
132
|
-
const requestMost = Effect.map(seam.parts, (built) => built.requestMost);
|
|
133
|
-
const { fetch, route } = serveRest({
|
|
134
|
-
basePath,
|
|
135
|
-
services,
|
|
136
|
-
route: git.route,
|
|
137
|
-
door,
|
|
138
|
-
renamedFor,
|
|
139
|
-
requestMost
|
|
140
|
-
});
|
|
141
|
-
return {
|
|
142
|
-
fetch,
|
|
143
|
-
route
|
|
144
|
-
};
|
|
145
|
-
};
|
|
146
|
-
export { createRestHandler, notFound, restApp, serveRest };
|
|
93
|
+
export { notFound, restApp };
|
package/dist/rest/handlers.d.mts
CHANGED
|
@@ -3,6 +3,6 @@ import * as Layer from "effect/Layer";
|
|
|
3
3
|
/**
|
|
4
4
|
* Every group's handlers and the middleware, over `GitRestServices`: each call decides for the
|
|
5
5
|
* caller `identify` answered. A host that serves REST under its own router provides it from
|
|
6
|
-
* the server's seam, as `
|
|
6
|
+
* the server's seam, as `Rest.layer` does.
|
|
7
7
|
*/
|
|
8
8
|
export declare const GitRestHandlers: Layer.Layer<import("effect/http-api/HttpApiGroup").Service<"git", "blobs"> | import("effect/http-api/HttpApiGroup").Service<"git", "commits"> | import("effect/http-api/HttpApiGroup").Service<"git", "events"> | import("effect/http-api/HttpApiGroup").Service<"git", "files"> | import("effect/http-api/HttpApiGroup").Service<"git", "forks"> | import("effect/http-api/HttpApiGroup").Service<"git", "me"> | import("effect/http-api/HttpApiGroup").Service<"git", "merges"> | import("effect/http-api/HttpApiGroup").Service<"git", "queue"> | import("effect/http-api/HttpApiGroup").Service<"git", "refs"> | import("effect/http-api/HttpApiGroup").Service<"git", "repos"> | import("effect/http-api/HttpApiGroup").Service<"git", "tags"> | import("effect/http-api/HttpApiGroup").Service<"git", "tokens"> | import("effect/http-api/HttpApiGroup").Service<"git", "topics"> | import("effect/http-api/HttpApiGroup").Service<"git", "trees"> | import("effect/http-api/HttpApiGroup").Service<"git", "work">, never, GitRestServices | import("effect/http/HttpRouter").Request<"Requires", GitRestServices>>;
|
package/dist/rest/handlers.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isInternalId } from "../contracts/ids.mjs";
|
|
1
2
|
import { noTokens } from "../auth/tokens-layer.mjs";
|
|
2
3
|
import { tokenParties } from "../auth/tokens.mjs";
|
|
3
4
|
import { treeOrChanges } from "../core/objects/commit-writes.mjs";
|
|
@@ -5,7 +6,7 @@ import { base64Size, jsonSize, responseBytes, responseTooLarge } from "../core/o
|
|
|
5
6
|
import { treeEditOf } from "../core/objects/tree-edits.mjs";
|
|
6
7
|
import { boundedBytes } from "../protocol/bytes/reader.mjs";
|
|
7
8
|
import { tryUnlessSpent } from "../contracts/calls-spent.mjs";
|
|
8
|
-
import { gitError } from "../contracts/result.mjs";
|
|
9
|
+
import { fail, gitError } from "../contracts/result.mjs";
|
|
9
10
|
import { GitCaller } from "../contracts/services.mjs";
|
|
10
11
|
import { Topics } from "../topics/layer.mjs";
|
|
11
12
|
import { GitRestApi } from "./api.mjs";
|
|
@@ -265,6 +266,14 @@ const WorkHandlers = HttpApiBuilder.group(GitRestApi, "work", (handlers) => hand
|
|
|
265
266
|
...listInput(query),
|
|
266
267
|
actor: yield* actor
|
|
267
268
|
});
|
|
269
|
+
})).handle("listById", ({ params, query }) => Effect.gen(function* () {
|
|
270
|
+
const server = yield* callsFor;
|
|
271
|
+
const { internalId } = params;
|
|
272
|
+
if (!isInternalId(internalId)) return yield* fail("NOT_FOUND", `No repo '${internalId}'`);
|
|
273
|
+
return yield* server.work.listById(internalId, {
|
|
274
|
+
...listInput(query),
|
|
275
|
+
actor: yield* actor
|
|
276
|
+
});
|
|
268
277
|
})).handle("retry", ({ params, payload }) => Effect.gen(function* () {
|
|
269
278
|
return yield* (yield* callsFor).work.retry(params.repo, {
|
|
270
279
|
...payload,
|
|
@@ -325,8 +334,13 @@ const TreesHandlers = HttpApiBuilder.group(GitRestApi, "trees", (handlers) => ha
|
|
|
325
334
|
});
|
|
326
335
|
})));
|
|
327
336
|
const CommitsHandlers = HttpApiBuilder.group(GitRestApi, "commits", (handlers) => handlers.handle("list", ({ params, query }) => Effect.gen(function* () {
|
|
328
|
-
|
|
329
|
-
|
|
337
|
+
const server = yield* callsFor;
|
|
338
|
+
const limit = query.limit === void 0 ? {} : { limit: Math.min(query.limit, 200) };
|
|
339
|
+
return yield* server.commits.list(params.repo, {
|
|
340
|
+
...readInput({
|
|
341
|
+
...query,
|
|
342
|
+
...limit
|
|
343
|
+
}),
|
|
330
344
|
actor: yield* actor
|
|
331
345
|
});
|
|
332
346
|
})).handle("get", ({ params, query }) => Effect.gen(function* () {
|
|
@@ -586,7 +600,7 @@ const TopicsHandlers = HttpApiBuilder.group(GitRestApi, "topics", (handlers) =>
|
|
|
586
600
|
/**
|
|
587
601
|
* Every group's handlers and the middleware, over `GitRestServices`: each call decides for the
|
|
588
602
|
* caller `identify` answered. A host that serves REST under its own router provides it from
|
|
589
|
-
* the server's seam, as `
|
|
603
|
+
* the server's seam, as `Rest.layer` does.
|
|
590
604
|
*/
|
|
591
605
|
const GitRestHandlers = Layer.mergeAll(ReposHandlers, ForksHandlers, RefsHandlers, WorkHandlers, TokensHandlers, MeHandlers, BlobsHandlers, TreesHandlers, CommitsHandlers, TagsHandlers, MergesHandlers, FilesHandlers, EventsHandlers, QueueHandlers, TopicsHandlers).pipe(Layer.provide(GitCallerMiddlewareLive));
|
|
592
606
|
export { GitRestHandlers };
|
package/dist/rest/layer.mjs
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { __exportAll } from "../_virtual/_rolldown/runtime.mjs";
|
|
2
2
|
import { register } from "../contracts/git.mjs";
|
|
3
|
+
import { MergeParts, mergePartsOption } from "../core/merge-parts.mjs";
|
|
3
4
|
import { ServerSeam } from "../core/seam.mjs";
|
|
4
5
|
import { GitRestServices } from "./caller.mjs";
|
|
5
6
|
import { notFound, restApp } from "./handler.mjs";
|
|
6
7
|
import * as Effect from "effect/Effect";
|
|
8
|
+
import * as Option from "effect/Option";
|
|
7
9
|
import * as Context from "effect/Context";
|
|
8
10
|
import * as Layer from "effect/Layer";
|
|
9
11
|
// src/rest/layer.ts
|
|
@@ -14,7 +16,8 @@ const restRoots = [
|
|
|
14
16
|
"/repos/*",
|
|
15
17
|
"/tokens/*",
|
|
16
18
|
"/queue/*",
|
|
17
|
-
"/topics/*"
|
|
19
|
+
"/topics/*",
|
|
20
|
+
"/work/*"
|
|
18
21
|
];
|
|
19
22
|
/**
|
|
20
23
|
* Git's REST API as a feature of `Git.layer`: it registers `rest`, and answers its URLs in the `post`
|
|
@@ -24,8 +27,9 @@ const restRoots = [
|
|
|
24
27
|
const layer = () => Layer.effectDiscard(Effect.gen(function* () {
|
|
25
28
|
const built = yield* (yield* ServerSeam).parts;
|
|
26
29
|
const rest = yield* register({ name: "rest" });
|
|
30
|
+
const merges = yield* mergePartsOption;
|
|
27
31
|
const { basePath, identify, callsFor, tokensOn, authorize, listen, renamedTo } = built;
|
|
28
|
-
const
|
|
32
|
+
const own = Context.make(GitRestServices, {
|
|
29
33
|
basePath,
|
|
30
34
|
identify,
|
|
31
35
|
callsFor,
|
|
@@ -33,6 +37,10 @@ const layer = () => Layer.effectDiscard(Effect.gen(function* () {
|
|
|
33
37
|
authorize,
|
|
34
38
|
listen
|
|
35
39
|
});
|
|
40
|
+
const services = Option.match(merges, {
|
|
41
|
+
onNone: () => own,
|
|
42
|
+
onSome: (parts) => Context.add(own, MergeParts, parts)
|
|
43
|
+
});
|
|
36
44
|
const renamedFor = (request, repo) => Effect.flatMap(identify(request), (caller) => renamedTo(caller, repo));
|
|
37
45
|
const { owned } = yield* Effect.acquireRelease(Effect.sync(() => restApp({
|
|
38
46
|
basePath,
|
package/dist/rest/me.d.mts
CHANGED
|
@@ -135,6 +135,7 @@ declare const MeApiGroup_base: HttpApiGroup.HttpApiGroup<"me", HttpApiEndpoint.H
|
|
|
135
135
|
readonly reason?: string;
|
|
136
136
|
readonly packs?: number;
|
|
137
137
|
readonly most?: number;
|
|
138
|
+
readonly retryAfter?: number;
|
|
138
139
|
};
|
|
139
140
|
}, unknown, never, never>, Schema.Codec<{
|
|
140
141
|
readonly code: "ALREADY_EXISTS";
|
|
@@ -240,6 +241,7 @@ declare const MeApiGroup_base: HttpApiGroup.HttpApiGroup<"me", HttpApiEndpoint.H
|
|
|
240
241
|
readonly reason?: string;
|
|
241
242
|
readonly packs?: number;
|
|
242
243
|
readonly most?: number;
|
|
244
|
+
readonly retryAfter?: number;
|
|
243
245
|
};
|
|
244
246
|
}, unknown, never, never>, {
|
|
245
247
|
"ref0-code": Schema.String;
|
|
@@ -315,7 +317,7 @@ declare const MeApiGroup_base: HttpApiGroup.HttpApiGroup<"me", HttpApiEndpoint.H
|
|
|
315
317
|
readonly message: Schema.decodeTo<Schema.String, Schema.String, never, never>;
|
|
316
318
|
readonly hint: Schema.optionalKey<Schema.decodeTo<Schema.String, Schema.String, never, never>>;
|
|
317
319
|
readonly context: Schema.optionalKey<Schema.StructWithRest<Schema.Struct<{
|
|
318
|
-
reason: Schema.optionalKey<Schema.Union<readonly [Schema.Literals<readonly ["too-large", "rate-limited", "walk-limit", "diff-limit", "object-too-large", "delta-too-large", "response-too-large", "too-many-pointers", "fetch-plan-too-large", "too-many-store-calls", "call-budget", "events-undelivered", "events-waiting", "name-churn", "queue-full", "queue-targets-full", "too-many-gitmodules-and-gitattributes", "prune-walk-too-large", "job-step-calls", "job-step-yielded"]>, Schema.decodeTo<Schema.String, Schema.String, never, never>]>>;
|
|
320
|
+
reason: Schema.optionalKey<Schema.Union<readonly [Schema.Literals<readonly ["too-large", "rate-limited", "walk-limit", "diff-limit", "object-too-large", "repo-too-large", "delta-too-large", "response-too-large", "too-many-pointers", "fetch-plan-too-large", "too-many-store-calls", "call-budget", "events-undelivered", "events-waiting", "name-churn", "queue-full", "queue-targets-full", "too-many-gitmodules-and-gitattributes", "prune-walk-too-large", "job-step-calls", "job-step-yielded"]>, Schema.decodeTo<Schema.String, Schema.String, never, never>]>>;
|
|
319
321
|
indexBytes: Schema.optionalKey<Schema.Number>;
|
|
320
322
|
pushBytes: Schema.optionalKey<Schema.Number>;
|
|
321
323
|
most: Schema.optionalKey<Schema.Number>;
|
|
@@ -331,9 +333,10 @@ declare const MeApiGroup_base: HttpApiGroup.HttpApiGroup<"me", HttpApiEndpoint.H
|
|
|
331
333
|
readonly hint: Schema.optionalKey<Schema.decodeTo<Schema.String, Schema.String, never, never>>;
|
|
332
334
|
readonly context: Schema.optionalKey<Schema.StructWithRest<Schema.Struct<{
|
|
333
335
|
id: Schema.optionalKey<Schema.decodeTo<Schema.String, Schema.String, never, never>>;
|
|
334
|
-
reason: Schema.optionalKey<Schema.Union<readonly [Schema.Literals<readonly ["busy", "packs-awaiting-repack", "awaiting-index", "may-have-saved", "too-many-writes"]>, Schema.decodeTo<Schema.String, Schema.String, never, never>]>>;
|
|
336
|
+
reason: Schema.optionalKey<Schema.Union<readonly [Schema.Literals<readonly ["busy", "packs-awaiting-repack", "awaiting-index", "may-have-saved", "too-many-writes", "starting"]>, Schema.decodeTo<Schema.String, Schema.String, never, never>]>>;
|
|
335
337
|
packs: Schema.optionalKey<Schema.Number>;
|
|
336
338
|
most: Schema.optionalKey<Schema.Number>;
|
|
339
|
+
retryAfter: Schema.optionalKey<Schema.Number>;
|
|
337
340
|
}>, readonly [Schema.$Record<Schema.String, Schema.Union<readonly [Schema.decodeTo<Schema.String, Schema.String, never, never>, Schema.Number, Schema.Boolean, Schema.$Array<Schema.decodeTo<Schema.String, Schema.String, never, never>>, Schema.Undefined]>>]>>;
|
|
338
341
|
}>, Schema.Struct<{
|
|
339
342
|
readonly code: Schema.Literal<"ALREADY_EXISTS">;
|
|
@@ -407,7 +410,7 @@ declare const MeApiGroup_base: HttpApiGroup.HttpApiGroup<"me", HttpApiEndpoint.H
|
|
|
407
410
|
readonly message: Schema.decodeTo<Schema.String, Schema.String, never, never>;
|
|
408
411
|
readonly hint: Schema.optionalKey<Schema.decodeTo<Schema.String, Schema.String, never, never>>;
|
|
409
412
|
readonly context: Schema.optionalKey<Schema.StructWithRest<Schema.Struct<{
|
|
410
|
-
reason: Schema.optionalKey<Schema.Union<readonly [Schema.Literals<readonly ["too-large", "rate-limited", "walk-limit", "diff-limit", "object-too-large", "delta-too-large", "response-too-large", "too-many-pointers", "fetch-plan-too-large", "too-many-store-calls", "call-budget", "events-undelivered", "events-waiting", "name-churn", "queue-full", "queue-targets-full", "too-many-gitmodules-and-gitattributes", "prune-walk-too-large", "job-step-calls", "job-step-yielded"]>, Schema.decodeTo<Schema.String, Schema.String, never, never>]>>;
|
|
413
|
+
reason: Schema.optionalKey<Schema.Union<readonly [Schema.Literals<readonly ["too-large", "rate-limited", "walk-limit", "diff-limit", "object-too-large", "repo-too-large", "delta-too-large", "response-too-large", "too-many-pointers", "fetch-plan-too-large", "too-many-store-calls", "call-budget", "events-undelivered", "events-waiting", "name-churn", "queue-full", "queue-targets-full", "too-many-gitmodules-and-gitattributes", "prune-walk-too-large", "job-step-calls", "job-step-yielded"]>, Schema.decodeTo<Schema.String, Schema.String, never, never>]>>;
|
|
411
414
|
indexBytes: Schema.optionalKey<Schema.Number>;
|
|
412
415
|
pushBytes: Schema.optionalKey<Schema.Number>;
|
|
413
416
|
most: Schema.optionalKey<Schema.Number>;
|
|
@@ -423,9 +426,10 @@ declare const MeApiGroup_base: HttpApiGroup.HttpApiGroup<"me", HttpApiEndpoint.H
|
|
|
423
426
|
readonly hint: Schema.optionalKey<Schema.decodeTo<Schema.String, Schema.String, never, never>>;
|
|
424
427
|
readonly context: Schema.optionalKey<Schema.StructWithRest<Schema.Struct<{
|
|
425
428
|
id: Schema.optionalKey<Schema.decodeTo<Schema.String, Schema.String, never, never>>;
|
|
426
|
-
reason: Schema.optionalKey<Schema.Union<readonly [Schema.Literals<readonly ["busy", "packs-awaiting-repack", "awaiting-index", "may-have-saved", "too-many-writes"]>, Schema.decodeTo<Schema.String, Schema.String, never, never>]>>;
|
|
429
|
+
reason: Schema.optionalKey<Schema.Union<readonly [Schema.Literals<readonly ["busy", "packs-awaiting-repack", "awaiting-index", "may-have-saved", "too-many-writes", "starting"]>, Schema.decodeTo<Schema.String, Schema.String, never, never>]>>;
|
|
427
430
|
packs: Schema.optionalKey<Schema.Number>;
|
|
428
431
|
most: Schema.optionalKey<Schema.Number>;
|
|
432
|
+
retryAfter: Schema.optionalKey<Schema.Number>;
|
|
429
433
|
}>, readonly [Schema.$Record<Schema.String, Schema.Union<readonly [Schema.decodeTo<Schema.String, Schema.String, never, never>, Schema.Number, Schema.Boolean, Schema.$Array<Schema.decodeTo<Schema.String, Schema.String, never, never>>, Schema.Undefined]>>]>>;
|
|
430
434
|
}>, {
|
|
431
435
|
"ref0-code": Schema.String;
|
package/dist/rest/merges.d.mts
CHANGED
|
@@ -168,6 +168,7 @@ declare const MergesApiGroup_base: HttpApiGroup.HttpApiGroup<"merges", HttpApiEn
|
|
|
168
168
|
readonly reason?: string;
|
|
169
169
|
readonly packs?: number;
|
|
170
170
|
readonly most?: number;
|
|
171
|
+
readonly retryAfter?: number;
|
|
171
172
|
};
|
|
172
173
|
}, unknown, never, never>, Schema.Codec<{
|
|
173
174
|
readonly code: "ALREADY_EXISTS";
|
|
@@ -273,6 +274,7 @@ declare const MergesApiGroup_base: HttpApiGroup.HttpApiGroup<"merges", HttpApiEn
|
|
|
273
274
|
readonly reason?: string;
|
|
274
275
|
readonly packs?: number;
|
|
275
276
|
readonly most?: number;
|
|
277
|
+
readonly retryAfter?: number;
|
|
276
278
|
};
|
|
277
279
|
}, unknown, never, never>, {
|
|
278
280
|
"ref0-code": Schema.String;
|
|
@@ -348,7 +350,7 @@ declare const MergesApiGroup_base: HttpApiGroup.HttpApiGroup<"merges", HttpApiEn
|
|
|
348
350
|
readonly message: Schema.decodeTo<Schema.String, Schema.String, never, never>;
|
|
349
351
|
readonly hint: Schema.optionalKey<Schema.decodeTo<Schema.String, Schema.String, never, never>>;
|
|
350
352
|
readonly context: Schema.optionalKey<Schema.StructWithRest<Schema.Struct<{
|
|
351
|
-
reason: Schema.optionalKey<Schema.Union<readonly [Schema.Literals<readonly ["too-large", "rate-limited", "walk-limit", "diff-limit", "object-too-large", "delta-too-large", "response-too-large", "too-many-pointers", "fetch-plan-too-large", "too-many-store-calls", "call-budget", "events-undelivered", "events-waiting", "name-churn", "queue-full", "queue-targets-full", "too-many-gitmodules-and-gitattributes", "prune-walk-too-large", "job-step-calls", "job-step-yielded"]>, Schema.decodeTo<Schema.String, Schema.String, never, never>]>>;
|
|
353
|
+
reason: Schema.optionalKey<Schema.Union<readonly [Schema.Literals<readonly ["too-large", "rate-limited", "walk-limit", "diff-limit", "object-too-large", "repo-too-large", "delta-too-large", "response-too-large", "too-many-pointers", "fetch-plan-too-large", "too-many-store-calls", "call-budget", "events-undelivered", "events-waiting", "name-churn", "queue-full", "queue-targets-full", "too-many-gitmodules-and-gitattributes", "prune-walk-too-large", "job-step-calls", "job-step-yielded"]>, Schema.decodeTo<Schema.String, Schema.String, never, never>]>>;
|
|
352
354
|
indexBytes: Schema.optionalKey<Schema.Number>;
|
|
353
355
|
pushBytes: Schema.optionalKey<Schema.Number>;
|
|
354
356
|
most: Schema.optionalKey<Schema.Number>;
|
|
@@ -364,9 +366,10 @@ declare const MergesApiGroup_base: HttpApiGroup.HttpApiGroup<"merges", HttpApiEn
|
|
|
364
366
|
readonly hint: Schema.optionalKey<Schema.decodeTo<Schema.String, Schema.String, never, never>>;
|
|
365
367
|
readonly context: Schema.optionalKey<Schema.StructWithRest<Schema.Struct<{
|
|
366
368
|
id: Schema.optionalKey<Schema.decodeTo<Schema.String, Schema.String, never, never>>;
|
|
367
|
-
reason: Schema.optionalKey<Schema.Union<readonly [Schema.Literals<readonly ["busy", "packs-awaiting-repack", "awaiting-index", "may-have-saved", "too-many-writes"]>, Schema.decodeTo<Schema.String, Schema.String, never, never>]>>;
|
|
369
|
+
reason: Schema.optionalKey<Schema.Union<readonly [Schema.Literals<readonly ["busy", "packs-awaiting-repack", "awaiting-index", "may-have-saved", "too-many-writes", "starting"]>, Schema.decodeTo<Schema.String, Schema.String, never, never>]>>;
|
|
368
370
|
packs: Schema.optionalKey<Schema.Number>;
|
|
369
371
|
most: Schema.optionalKey<Schema.Number>;
|
|
372
|
+
retryAfter: Schema.optionalKey<Schema.Number>;
|
|
370
373
|
}>, readonly [Schema.$Record<Schema.String, Schema.Union<readonly [Schema.decodeTo<Schema.String, Schema.String, never, never>, Schema.Number, Schema.Boolean, Schema.$Array<Schema.decodeTo<Schema.String, Schema.String, never, never>>, Schema.Undefined]>>]>>;
|
|
371
374
|
}>, Schema.Struct<{
|
|
372
375
|
readonly code: Schema.Literal<"ALREADY_EXISTS">;
|
|
@@ -440,7 +443,7 @@ declare const MergesApiGroup_base: HttpApiGroup.HttpApiGroup<"merges", HttpApiEn
|
|
|
440
443
|
readonly message: Schema.decodeTo<Schema.String, Schema.String, never, never>;
|
|
441
444
|
readonly hint: Schema.optionalKey<Schema.decodeTo<Schema.String, Schema.String, never, never>>;
|
|
442
445
|
readonly context: Schema.optionalKey<Schema.StructWithRest<Schema.Struct<{
|
|
443
|
-
reason: Schema.optionalKey<Schema.Union<readonly [Schema.Literals<readonly ["too-large", "rate-limited", "walk-limit", "diff-limit", "object-too-large", "delta-too-large", "response-too-large", "too-many-pointers", "fetch-plan-too-large", "too-many-store-calls", "call-budget", "events-undelivered", "events-waiting", "name-churn", "queue-full", "queue-targets-full", "too-many-gitmodules-and-gitattributes", "prune-walk-too-large", "job-step-calls", "job-step-yielded"]>, Schema.decodeTo<Schema.String, Schema.String, never, never>]>>;
|
|
446
|
+
reason: Schema.optionalKey<Schema.Union<readonly [Schema.Literals<readonly ["too-large", "rate-limited", "walk-limit", "diff-limit", "object-too-large", "repo-too-large", "delta-too-large", "response-too-large", "too-many-pointers", "fetch-plan-too-large", "too-many-store-calls", "call-budget", "events-undelivered", "events-waiting", "name-churn", "queue-full", "queue-targets-full", "too-many-gitmodules-and-gitattributes", "prune-walk-too-large", "job-step-calls", "job-step-yielded"]>, Schema.decodeTo<Schema.String, Schema.String, never, never>]>>;
|
|
444
447
|
indexBytes: Schema.optionalKey<Schema.Number>;
|
|
445
448
|
pushBytes: Schema.optionalKey<Schema.Number>;
|
|
446
449
|
most: Schema.optionalKey<Schema.Number>;
|
|
@@ -456,9 +459,10 @@ declare const MergesApiGroup_base: HttpApiGroup.HttpApiGroup<"merges", HttpApiEn
|
|
|
456
459
|
readonly hint: Schema.optionalKey<Schema.decodeTo<Schema.String, Schema.String, never, never>>;
|
|
457
460
|
readonly context: Schema.optionalKey<Schema.StructWithRest<Schema.Struct<{
|
|
458
461
|
id: Schema.optionalKey<Schema.decodeTo<Schema.String, Schema.String, never, never>>;
|
|
459
|
-
reason: Schema.optionalKey<Schema.Union<readonly [Schema.Literals<readonly ["busy", "packs-awaiting-repack", "awaiting-index", "may-have-saved", "too-many-writes"]>, Schema.decodeTo<Schema.String, Schema.String, never, never>]>>;
|
|
462
|
+
reason: Schema.optionalKey<Schema.Union<readonly [Schema.Literals<readonly ["busy", "packs-awaiting-repack", "awaiting-index", "may-have-saved", "too-many-writes", "starting"]>, Schema.decodeTo<Schema.String, Schema.String, never, never>]>>;
|
|
460
463
|
packs: Schema.optionalKey<Schema.Number>;
|
|
461
464
|
most: Schema.optionalKey<Schema.Number>;
|
|
465
|
+
retryAfter: Schema.optionalKey<Schema.Number>;
|
|
462
466
|
}>, readonly [Schema.$Record<Schema.String, Schema.Union<readonly [Schema.decodeTo<Schema.String, Schema.String, never, never>, Schema.Number, Schema.Boolean, Schema.$Array<Schema.decodeTo<Schema.String, Schema.String, never, never>>, Schema.Undefined]>>]>>;
|
|
463
467
|
}>, {
|
|
464
468
|
"ref0-code": Schema.String;
|
package/dist/rest/paths.mjs
CHANGED
|
@@ -65,6 +65,7 @@ const restPath = (base, pathname) => {
|
|
|
65
65
|
if (segments[0] === "repos") return repoPath(segments.slice(1));
|
|
66
66
|
if (segments[0] === "queue") return { path: under };
|
|
67
67
|
if (segments[0] === "topics") return { path: under };
|
|
68
|
+
if (segments[0] === "work" && segments.length === 2 && segments[1] !== "") return { path: under };
|
|
68
69
|
};
|
|
69
70
|
/** A repo's URL on the wire, its slashes kept: what a 301 names and what the client sends. */
|
|
70
71
|
const wireRepoPath = (repo) => repo.split("/").map(encodeURIComponent).join("/");
|