@ref0/git 0.7.0 → 0.9.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 +0 -2
- package/dist/auth/authorize.mjs +31 -24
- package/dist/auth/bridge.mjs +8 -8
- package/dist/auth/fences.d.mts +0 -1
- package/dist/auth/fences.mjs +1 -1
- package/dist/auth/grants.d.mts +0 -1
- package/dist/auth/grants.mjs +2 -2
- package/dist/auth/host-function.d.mts +1 -7
- package/dist/auth/host-function.mjs +38 -38
- package/dist/auth/identify.d.mts +0 -1
- package/dist/auth/identify.mjs +1 -1
- package/dist/auth/policy.d.mts +7 -4
- package/dist/auth/policy.mjs +13 -10
- package/dist/auth/token-rows.mjs +2 -5
- package/dist/auth/tokens-layer.d.mts +0 -2
- package/dist/auth/tokens-public.d.mts +3 -3
- package/dist/auth/tokens-public.mjs +4 -2
- package/dist/auth/tokens.d.mts +6 -1
- package/dist/auth/tokens.mjs +7 -1
- package/dist/client/client.d.mts +22 -15
- package/dist/client/client.mjs +31 -27
- package/dist/client/git-http.mjs +22 -5
- package/dist/client/local.mjs +1 -1
- package/dist/client/namespace.d.mts +2 -0
- package/dist/client/push-upload.d.mts +1 -0
- package/dist/client/push-upload.mjs +169 -2
- package/dist/client/remote-helper.mjs +2 -4
- package/dist/client/remote.mjs +37 -15
- package/dist/client/run-remote-helper.mjs +4 -4
- package/dist/client/transport.mjs +26 -19
- package/dist/contracts/actors.d.mts +57 -28
- package/dist/contracts/actors.mjs +38 -2
- package/dist/contracts/authorize.d.mts +21 -15
- package/dist/contracts/callers.mjs +40 -0
- package/dist/contracts/calls-spent.d.mts +2 -12
- package/dist/contracts/calls-spent.mjs +4 -5
- package/dist/contracts/client.d.mts +16 -9
- package/dist/contracts/events.d.mts +82 -14
- package/dist/contracts/events.mjs +35 -9
- package/dist/contracts/files.d.mts +42 -42
- package/dist/contracts/forks.d.mts +0 -24
- package/dist/contracts/git-hooks.d.mts +217 -0
- package/dist/contracts/git-hooks.mjs +3 -1
- package/dist/contracts/git.d.mts +13 -3
- package/dist/contracts/grants.d.mts +46 -27
- package/dist/contracts/lfs.d.mts +17 -4
- package/dist/contracts/merges.d.mts +7 -7
- package/dist/contracts/objects.d.mts +38 -4
- package/dist/contracts/opaque.mjs +19 -1
- package/dist/contracts/operations.d.mts +8 -1
- package/dist/contracts/operations.mjs +209 -0
- package/dist/contracts/queue.d.mts +6 -5
- package/dist/contracts/queue.mjs +9 -20
- package/dist/contracts/remote.d.mts +13 -4
- package/dist/contracts/remote.mjs +3 -3
- package/dist/contracts/repos.d.mts +11 -40
- package/dist/contracts/repos.mjs +11 -10
- package/dist/contracts/result.d.mts +28 -11
- package/dist/contracts/result.mjs +32 -2
- package/dist/contracts/rules.d.mts +706 -46
- package/dist/contracts/rules.mjs +81 -2
- package/dist/contracts/server.d.mts +5 -275
- package/dist/contracts/services.d.mts +0 -3
- package/dist/contracts/services.mjs +1 -3
- package/dist/contracts/signin.d.mts +2 -2
- package/dist/contracts/signin.mjs +4 -5
- package/dist/contracts/sync.d.mts +1 -4
- package/dist/contracts/tokens.d.mts +29 -17
- package/dist/contracts/tokens.mjs +14 -3
- package/dist/contracts/topics.d.mts +38 -11
- package/dist/contracts/topics.mjs +8 -2
- package/dist/core/access.d.mts +0 -2
- package/dist/core/access.mjs +15 -4
- package/dist/core/ancestry.mjs +5 -4
- package/dist/core/events/deliver.mjs +19 -1
- package/dist/core/forks.mjs +30 -11
- package/dist/core/hooks/groups.d.mts +0 -1
- package/dist/core/hooks/groups.mjs +8 -9
- package/dist/core/index-job.mjs +23 -1
- package/dist/core/index-lost.d.mts +11 -0
- package/dist/core/index-lost.mjs +55 -0
- package/dist/core/loose-tally.mjs +46 -0
- package/dist/core/objects/commit-writes.mjs +1 -1
- package/dist/core/objects/commits.mjs +10 -9
- package/dist/core/objects/merges.mjs +1 -1
- package/dist/core/objects/reading.mjs +28 -13
- package/dist/core/objects/trees.mjs +1 -1
- package/dist/core/objects/writing.mjs +1 -0
- package/dist/core/parts.d.mts +7 -0
- package/dist/core/promise.mjs +1 -15
- package/dist/core/publish.mjs +9 -5
- package/dist/core/purge.mjs +30 -12
- package/dist/core/push.mjs +39 -16
- package/dist/core/ref-view.mjs +14 -6
- package/dist/core/repack.mjs +54 -27
- package/dist/core/repo-info.mjs +8 -6
- package/dist/core/repos.mjs +1 -0
- package/dist/core/rules/check.mjs +10 -10
- package/dist/core/rules/context.d.mts +3 -1
- package/dist/core/rules/context.mjs +16 -13
- package/dist/core/rules/fetch.mjs +17 -23
- package/dist/core/tokens.mjs +2 -1
- package/dist/core/view.d.mts +10 -1
- package/dist/core/view.mjs +15 -6
- package/dist/effect.d.mts +3 -6
- package/dist/effect.mjs +3 -6
- package/dist/engine/commits.mjs +23 -50
- package/dist/engine/failures.d.mts +1 -2
- package/dist/engine/failures.mjs +1 -3
- package/dist/engine/merge-base-walk.mjs +57 -142
- package/dist/engine/merge-bases.mjs +9 -7
- package/dist/engine/merge.mjs +20 -17
- package/dist/engine/parts.d.mts +1 -0
- package/dist/engine/parts.mjs +1 -1
- package/dist/engine/walk.mjs +15 -11
- package/dist/extend.d.mts +1 -2
- package/dist/extend.mjs +1 -2
- package/dist/http/core-parts.mjs +18 -10
- package/dist/http/handler.mjs +11 -31
- package/dist/http/parts.d.mts +0 -1
- package/dist/index.d.mts +29 -22
- package/dist/index.mjs +5 -2
- package/dist/lfs/base.d.mts +6 -3
- package/dist/lfs/base.mjs +2 -1
- package/dist/lfs/layer.d.mts +4 -3
- package/dist/lfs/layer.mjs +23 -9
- package/dist/lfs/objects.mjs +93 -41
- package/dist/lfs/pointers.mjs +69 -18
- package/dist/lfs/purge.mjs +6 -2
- package/dist/lfs/rows.mjs +24 -7
- package/dist/lfs/service.d.mts +6 -3
- package/dist/lfs/service.mjs +8 -2
- package/dist/lfs/upkeep.mjs +47 -28
- package/dist/lfs/upload-most.mjs +47 -0
- package/dist/lfs/uploaded.mjs +59 -0
- package/dist/protocol/bytes/sha256-hasher.mjs +51 -0
- package/dist/protocol/bytes/streams.mjs +84 -2
- package/dist/protocol/bytes/text.mjs +6 -1
- package/dist/protocol/diff/read.d.mts +1 -0
- package/dist/protocol/diff/read.mjs +5 -2
- package/dist/protocol/objects/commit.d.mts +7 -0
- package/dist/protocol/objects/commit.mjs +5 -1
- package/dist/protocol/objects/fsck.mjs +6 -3
- package/dist/queue/advance.mjs +77 -18
- package/dist/queue/calls.mjs +4 -14
- package/dist/queue/host.d.mts +4 -0
- package/dist/queue/lanes.mjs +1 -1
- package/dist/queue/layer.mjs +4 -2
- package/dist/queue/limits.mjs +18 -2
- package/dist/queue/rows.mjs +10 -1
- package/dist/queue/schedule.mjs +1 -1
- package/dist/queue/search.mjs +3 -4
- package/dist/queue/trim.mjs +2 -2
- package/dist/rest/client-namespace.d.mts +2 -0
- package/dist/rest/client.d.mts +32 -8
- package/dist/rest/client.mjs +308 -382
- package/dist/rest/commits.d.mts +150 -150
- package/dist/rest/files.d.mts +18 -18
- package/dist/rest/forks.d.mts +77 -89
- package/dist/rest/handlers.mjs +2 -1
- package/dist/rest/listen.d.mts +8 -6
- package/dist/rest/listen.mjs +31 -75
- package/dist/rest/me.d.mts +2 -2
- package/dist/rest/merges.d.mts +7 -7
- package/dist/rest/refs.d.mts +27 -27
- package/dist/rest/repos.d.mts +40 -52
- package/dist/rest/tokens.d.mts +12 -12
- package/dist/rest/topics.d.mts +13 -13
- package/dist/rest/trees.d.mts +66 -66
- package/dist/rest/wire.d.mts +20 -2
- package/dist/rest/work.d.mts +39 -39
- package/dist/rest.d.mts +1 -7
- package/dist/rest.mjs +1 -5
- package/dist/server/git-layer.d.mts +10 -2
- package/dist/server/git-layer.mjs +29 -10
- package/dist/server/joined.d.mts +12 -6
- package/dist/server/joined.mjs +3 -2
- package/dist/server/registry.mjs +11 -5
- package/dist/server/server.d.mts +0 -1
- package/dist/server/server.mjs +42 -49
- package/dist/signin/context.d.mts +0 -1
- package/dist/signin/context.mjs +5 -9
- package/dist/storage/clean-up.mjs +3 -1
- package/dist/storage/fsck.mjs +12 -2
- package/dist/storage/graph-rebuild.mjs +262 -0
- package/dist/storage/index-bitmaps.mjs +16 -10
- package/dist/storage/index-build.mjs +160 -24
- package/dist/storage/index-graph.d.mts +1 -0
- package/dist/storage/index-graph.mjs +29 -5
- package/dist/storage/index-layers.d.mts +1 -0
- package/dist/storage/index-layers.mjs +5 -2
- package/dist/storage/index-reach.mjs +7 -5
- package/dist/storage/index-remap.mjs +5 -5
- package/dist/storage/index-visible.mjs +16 -5
- package/dist/storage/lfs-pointers.d.mts +5 -5
- package/dist/storage/lfs-pointers.mjs +37 -11
- package/dist/storage/links.mjs +3 -3
- package/dist/storage/loose.mjs +4 -1
- package/dist/storage/memory-budget.mjs +1 -1
- package/dist/storage/merge-fence.mjs +81 -19
- package/dist/storage/merge-most.mjs +1 -0
- package/dist/storage/merge-row.mjs +16 -4
- package/dist/storage/merge-stream.mjs +9 -6
- package/dist/storage/object-rows.mjs +17 -1
- package/dist/storage/pack-order.d.mts +1 -0
- package/dist/storage/pack-order.mjs +18 -1
- package/dist/storage/pack-receive.mjs +10 -6
- package/dist/storage/packs.mjs +58 -27
- package/dist/storage/prune-walk.mjs +5 -2
- package/dist/storage/prune.mjs +168 -70
- package/dist/storage/ready.d.mts +1 -1
- package/dist/storage/ready.mjs +12 -3
- package/dist/storage/receive-bounds.mjs +3 -2
- package/dist/storage/receive-state.mjs +1 -1
- package/dist/storage/repack-contained.mjs +22 -14
- package/dist/storage/repack.d.mts +1 -1
- package/dist/storage/repack.mjs +3 -2
- package/dist/storage/unpack.mjs +7 -0
- package/dist/storage/visible.mjs +3 -2
- package/dist/storage/walk.d.mts +1 -0
- package/dist/storage/walk.mjs +9 -5
- package/dist/storage/wants.mjs +17 -11
- package/dist/store/call-count.d.mts +31 -3
- package/dist/store/call-count.mjs +51 -20
- package/dist/store/errors.d.mts +7 -1
- package/dist/store/errors.mjs +7 -1
- package/dist/store/job-try.mjs +3 -1
- package/dist/store/records.mjs +26 -5
- package/dist/store/repo-record.mjs +36 -12
- package/dist/store/scopes.mjs +15 -2
- package/dist/sync/bound.d.mts +1 -1
- package/dist/sync/import.mjs +15 -3
- package/dist/sync/layer.d.mts +5 -1
- package/dist/sync/layer.mjs +11 -9
- package/dist/sync/mirror.mjs +1 -1
- package/dist/sync/step.mjs +15 -15
- package/dist/topics/advance.mjs +11 -10
- package/dist/topics/layer.mjs +1 -1
- package/dist/topics/members.mjs +38 -9
- package/package.json +3 -3
- package/dist/engine/merge-base-walk.d.mts +0 -3
- package/dist/server/routes.d.mts +0 -32
- package/dist/server/routes.mjs +0 -69
- package/dist/sync/bridge.d.mts +0 -6
- package/dist/sync/bridge.mjs +0 -29
|
@@ -21,8 +21,11 @@ import { JoinedCalls } from "./joined.mjs";
|
|
|
21
21
|
import { UploadsBase } from "./uploads.mjs";
|
|
22
22
|
import { BucketUploads } from "@ref0/infra";
|
|
23
23
|
import * as Layer from "effect/Layer";
|
|
24
|
-
/**
|
|
25
|
-
|
|
24
|
+
/**
|
|
25
|
+
* `Git.layer`'s options: settings only (Q834, Q1006), with a platform's `maxDuration` (Q1190). Push
|
|
26
|
+
* uploads are `Git.layerUploads`'.
|
|
27
|
+
*/
|
|
28
|
+
export interface GitOptions extends Pick<GitServerOptions, 'fetchLimits' | 'basePath' | 'maxDuration'> {}
|
|
26
29
|
/**
|
|
27
30
|
* Core's services, which every feature may require and `Git.layer` provides: `Git`, the repos'
|
|
28
31
|
* records, `authorize`, refs, objects, events, the calls and the bases features build on.
|
|
@@ -36,6 +39,11 @@ export type GitServices = GitNeeds | Policy | Storage;
|
|
|
36
39
|
* Git: core's services over the host's, then `features` over them, then the seal. A feature's
|
|
37
40
|
* Layer registers a name and adds its hooks as it builds; a registration after the seal is a defect, and a
|
|
38
41
|
* clash fails the build. `Bucket`, `Auth` and the rest of the host's services stay optional.
|
|
42
|
+
*
|
|
43
|
+
* Git logs through the runtime's Logger, its jobs' tries too. A host function's failure is at `Error`,
|
|
44
|
+
* with its cause as the host's code gave it, unredacted, and the `failure` ID its caller is told; a
|
|
45
|
+
* refusal is at `Debug`, with its `code`. A host whose functions' errors may carry a credential or a
|
|
46
|
+
* private name redacts them in its own Logger, as `HostFunctionName` says.
|
|
39
47
|
*/
|
|
40
48
|
export declare const layer: <ROut = never, E = never, RIn = never>(options?: GitOptions, features?: Layer.Layer<ROut, E, RIn>) => Layer.Layer<CoreServices | ROut, GitError | E, GitServices | Exclude<RIn, CoreServices>>;
|
|
41
49
|
/**
|
|
@@ -25,18 +25,32 @@ const after = /* @__PURE__ */ new Set(["post"]);
|
|
|
25
25
|
/** A registration's answer: a `GitError` it fails with answers as Git's protocol refuses. */
|
|
26
26
|
const answered = ({ handle, request }) => Effect.map(Effect.catch(handle(request), (error) => Effect.succeed(refusal(error))), Option.some);
|
|
27
27
|
/**
|
|
28
|
-
* `
|
|
29
|
-
*
|
|
28
|
+
* `request` again with `signal`: the request itself, whose headers a browser's `Request` copies
|
|
29
|
+
* whole, `Content-Length` among them. Next.js hands a route a Proxy over its request, which
|
|
30
|
+
* `new Request` reads as a URL and refuses before it touches the body; that one is copied from its
|
|
31
|
+
* fields. The body passed again, the same stream, so `request` stays readable when no one reads it.
|
|
32
|
+
* `duplex` is the fetch spec's, which a stream body needs and the DOM types don't name yet.
|
|
30
33
|
*/
|
|
31
|
-
const
|
|
32
|
-
const interrupted = new AbortController();
|
|
34
|
+
const withSignal = (request, signal) => {
|
|
33
35
|
const init = {
|
|
34
|
-
signal
|
|
36
|
+
signal,
|
|
35
37
|
body: request.body,
|
|
36
38
|
duplex: "half"
|
|
37
39
|
};
|
|
38
|
-
|
|
39
|
-
|
|
40
|
+
return Effect.try(() => new Request(request, init)).pipe(Effect.orElseSucceed(() => new Request(request.url, {
|
|
41
|
+
...init,
|
|
42
|
+
method: request.method,
|
|
43
|
+
headers: request.headers
|
|
44
|
+
})));
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* `use` of `request` with a signal that also aborts when its fiber is interrupted: the server
|
|
48
|
+
* stops only by its request's signal, which an interrupt of `Effect.promise` never reaches.
|
|
49
|
+
*/
|
|
50
|
+
const bound = (request, use) => Effect.suspend(() => {
|
|
51
|
+
const interrupted = new AbortController();
|
|
52
|
+
const signal = AbortSignal.any([request.signal, interrupted.signal]);
|
|
53
|
+
return Effect.flatMap(withSignal(request, signal), (signalled) => Effect.onInterrupt(use(signalled), () => Effect.sync(() => interrupted.abort())));
|
|
40
54
|
});
|
|
41
55
|
/** Core: the server over the host's services, sealing `later`, and the `Git` service over it. */
|
|
42
56
|
const core = (options) => Layer.effectContext(Effect.gen(function* () {
|
|
@@ -53,9 +67,9 @@ const core = (options) => Layer.effectContext(Effect.gen(function* () {
|
|
|
53
67
|
};
|
|
54
68
|
const policy = Context.get(context, Policy);
|
|
55
69
|
const auth = Option.getOrUndefined(yield* Effect.serviceOption(Auth));
|
|
56
|
-
const deciders = (
|
|
57
|
-
policy: hostPolicy(policy
|
|
58
|
-
auth: hostAuth(auth
|
|
70
|
+
const deciders = () => ({
|
|
71
|
+
policy: hostPolicy(policy),
|
|
72
|
+
auth: hostAuth(auth)
|
|
59
73
|
});
|
|
60
74
|
const hostRules = Context.getOption(context, Rules);
|
|
61
75
|
const rules = Option.match(hostRules, {
|
|
@@ -109,6 +123,11 @@ const sealing = () => Layer.effectContext(Effect.gen(function* () {
|
|
|
109
123
|
* Git: core's services over the host's, then `features` over them, then the seal. A feature's
|
|
110
124
|
* Layer registers a name and adds its hooks as it builds; a registration after the seal is a defect, and a
|
|
111
125
|
* clash fails the build. `Bucket`, `Auth` and the rest of the host's services stay optional.
|
|
126
|
+
*
|
|
127
|
+
* Git logs through the runtime's Logger, its jobs' tries too. A host function's failure is at `Error`,
|
|
128
|
+
* with its cause as the host's code gave it, unredacted, and the `failure` ID its caller is told; a
|
|
129
|
+
* refusal is at `Debug`, with its `code`. A host whose functions' errors may carry a credential or a
|
|
130
|
+
* private name redacts them in its own Logger, as `HostFunctionName` says.
|
|
112
131
|
*/
|
|
113
132
|
const layer = (options = {}, features) => {
|
|
114
133
|
const added = features ?? Layer.empty;
|
package/dist/server/joined.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Caller } from "../contracts/actors.mjs";
|
|
2
2
|
import { InternalRepoId, RepoName } from "../contracts/ids.mjs";
|
|
3
|
-
import { Bucket } from "../contracts/objects.mjs";
|
|
3
|
+
import { Bucket, EffectiveLimits } from "../contracts/objects.mjs";
|
|
4
4
|
import { Clock, Store } from "../contracts/promises.mjs";
|
|
5
5
|
import { QueueKeys } from "../contracts/queue.mjs";
|
|
6
6
|
import { RepoRecord } from "../contracts/repos.mjs";
|
|
@@ -24,16 +24,22 @@ export interface JoinedAdapter {
|
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
26
|
* What a package joined to a `createGitServer` server reads beside Git's services: the calls
|
|
27
|
-
* `RepoRecords`, `Authorize` and `Refs` don't make, each through the server's door.
|
|
28
|
-
*
|
|
27
|
+
* `RepoRecords`, `Authorize` and `Refs` don't make, each through the server's door. `Git.layer`
|
|
28
|
+
* provides it to the drop-in; the bridge, `joinLayer`, goes with `createGitServer` in 2c-3b.
|
|
29
29
|
*/
|
|
30
30
|
export interface Joined {
|
|
31
|
-
/** The server itself, for what goes through its own `fetch
|
|
31
|
+
/** The server itself, for what goes through its own `fetch`. */
|
|
32
32
|
readonly server: GitServer;
|
|
33
33
|
readonly basePath: string;
|
|
34
34
|
/** The server's one queue's `keys`, or `undefined` with no queue. */
|
|
35
35
|
readonly queueKeys: QueueKeys | undefined;
|
|
36
36
|
readonly adapter: JoinedAdapter;
|
|
37
|
+
/**
|
|
38
|
+
* The server's `fetchLimits`: core's purge drops a deleted repo's scopes, its joined package's
|
|
39
|
+
* too, no sooner than `milliseconds` past the delete, so a write that read the repo live and
|
|
40
|
+
* commits within that, less `jobLeaseMargin`, commits before the drop.
|
|
41
|
+
*/
|
|
42
|
+
readonly fetchLimits: EffectiveLimits;
|
|
37
43
|
/**
|
|
38
44
|
* A request's budget: the adapter's `callLimits`, named `request`. Made before `identify`, so the
|
|
39
45
|
* sign-in read counts into it too (#725).
|
|
@@ -75,8 +81,8 @@ export interface Joining<ROut> {
|
|
|
75
81
|
}
|
|
76
82
|
/**
|
|
77
83
|
* Builds `layer` in `git`'s build, over Git's services and `JoinedCalls`, after the server's own
|
|
78
|
-
* features and before its seal, so what it registers is sealed with Git's:
|
|
79
|
-
*
|
|
84
|
+
* features and before its seal, so what it registers is sealed with Git's: a bridge, which 2c-3b
|
|
85
|
+
* removes with `createGitServer`. Refused after the tick
|
|
80
86
|
* that made the server.
|
|
81
87
|
*/
|
|
82
88
|
export declare const joinLayer: <ROut, RIn>(git: GitServer, layer: Layer.Layer<ROut, GitError, RIn>) => Joining<ROut>;
|
package/dist/server/joined.mjs
CHANGED
|
@@ -50,6 +50,7 @@ const joinedOf = (git, built) => {
|
|
|
50
50
|
return attached.queueKeys;
|
|
51
51
|
},
|
|
52
52
|
adapter: built.adapter,
|
|
53
|
+
fetchLimits: attached.fetchLimits,
|
|
53
54
|
request: () => syncIn(requestBudget(built.parts.requestMost), noCall),
|
|
54
55
|
identify: attached.identify,
|
|
55
56
|
callsFor: attached.callsFor,
|
|
@@ -70,8 +71,8 @@ const joinedOf = (git, built) => {
|
|
|
70
71
|
const lateJoin = (call) => `${call} joins a server in the tick createGitServer made it in: call it where the server is made, before any await`;
|
|
71
72
|
/**
|
|
72
73
|
* Builds `layer` in `git`'s build, over Git's services and `JoinedCalls`, after the server's own
|
|
73
|
-
* features and before its seal, so what it registers is sealed with Git's:
|
|
74
|
-
*
|
|
74
|
+
* features and before its seal, so what it registers is sealed with Git's: a bridge, which 2c-3b
|
|
75
|
+
* removes with `createGitServer`. Refused after the tick
|
|
75
76
|
* that made the server.
|
|
76
77
|
*/
|
|
77
78
|
const joinLayer = (git, layer) => {
|
package/dist/server/registry.mjs
CHANGED
|
@@ -7,8 +7,10 @@ import { bindHookGroups } from "../core/hooks/groups.mjs";
|
|
|
7
7
|
import { bandRank, byOrder, orderedOf } from "../core/hooks/order.mjs";
|
|
8
8
|
import { upkeepsOf } from "../core/repack.mjs";
|
|
9
9
|
import { gitsOwnRefs, registeredRow } from "../protocol/wire/lines.mjs";
|
|
10
|
+
import { gitJob } from "../store/job-try.mjs";
|
|
10
11
|
import { answersMethod, bySpecificity, matchPath, routePath } from "./route-match.mjs";
|
|
11
12
|
import * as Effect from "effect/Effect";
|
|
13
|
+
import * as Context from "effect/Context";
|
|
12
14
|
// src/server/registry.ts
|
|
13
15
|
const sealedDefect = () => /* @__PURE__ */ new Error("Git's registry is sealed");
|
|
14
16
|
/** A clash, as the build fails with it. */
|
|
@@ -201,12 +203,15 @@ const openRegistry = (basePath = "") => {
|
|
|
201
203
|
purges.push(orderedOf(name, step));
|
|
202
204
|
}),
|
|
203
205
|
addRoute: (route) => adding(() => routeClash(name, route)),
|
|
204
|
-
addJob: (
|
|
206
|
+
addJob: (job, handler, options) => Effect.flatMap(Effect.context(), (context) => adding(() => {
|
|
207
|
+
const within = (effect) => Effect.updateContext(effect, (current) => Context.merge(context, current));
|
|
208
|
+
const onFailure = options?.onFailure;
|
|
209
|
+
const definition = gitJob(job, (data) => within(handler(data)), onFailure === void 0 ? {} : { onFailure: (data, failure) => within(onFailure(data, failure)) });
|
|
205
210
|
if (!definition.name.startsWith(`${name}.`)) return clash(`${name}'s jobs are named '${name}.…': got '${definition.name}'`);
|
|
206
211
|
const found = jobClash(definition);
|
|
207
212
|
if (found === void 0) pending.push(definition);
|
|
208
213
|
return found;
|
|
209
|
-
}),
|
|
214
|
+
})),
|
|
210
215
|
addGrant: (resolver) => adding(() => grantClash(name, resolver))
|
|
211
216
|
};
|
|
212
217
|
const answer = owner === void 0 ? made : {
|
|
@@ -268,10 +273,11 @@ const openRegistry = (basePath = "") => {
|
|
|
268
273
|
pushRules: () => rules,
|
|
269
274
|
pushChecks: () => ordered(checks),
|
|
270
275
|
hookGroups: () => ordered(hookGroups),
|
|
271
|
-
upkeep: (store, repo, at) => upkeepsOf(ordered(upkeeps).map(({ handler }) => () => handler({
|
|
276
|
+
upkeep: (store, repo, at, deleted) => upkeepsOf(ordered(upkeeps).map(({ handler }) => () => handler({
|
|
272
277
|
repo,
|
|
273
|
-
at
|
|
274
|
-
|
|
278
|
+
at,
|
|
279
|
+
deleted
|
|
280
|
+
})))(store, repo, at, deleted),
|
|
275
281
|
purge: Effect.fnUntraced(function* (_store, repo) {
|
|
276
282
|
for (const { handler } of ordered(purges)) {
|
|
277
283
|
const step = yield* handler({ repo });
|
package/dist/server/server.d.mts
CHANGED
|
@@ -9,7 +9,6 @@ import "../contracts/rules.mjs";
|
|
|
9
9
|
import { GitAdapter, GitServer, ProvidedBy, ServerSetup } from "../contracts/server.mjs";
|
|
10
10
|
import "../contracts/services.mjs";
|
|
11
11
|
import "../auth/auth.mjs";
|
|
12
|
-
import "../auth/host-function.mjs";
|
|
13
12
|
import "../auth/identify.mjs";
|
|
14
13
|
import "../auth/policy.mjs";
|
|
15
14
|
import "../auth/tokens-layer.mjs";
|
package/dist/server/server.mjs
CHANGED
|
@@ -32,6 +32,7 @@ import { Events, keepsEvents } from "../contracts/events.mjs";
|
|
|
32
32
|
import { callServices } from "../core/call-services.mjs";
|
|
33
33
|
import { repackJob, repackJobRow, upkeepsOf } from "../core/repack.mjs";
|
|
34
34
|
import { indexJob, indexJobRow } from "../core/index-job.mjs";
|
|
35
|
+
import { indexLostAsk } from "../core/index-lost.mjs";
|
|
35
36
|
import { purgeJob, purgeJobRow } from "../core/purge.mjs";
|
|
36
37
|
import { refIndexJob, refIndexJobRow } from "../core/ref-index-job.mjs";
|
|
37
38
|
import { forkCalls } from "../core/forks.mjs";
|
|
@@ -66,13 +67,14 @@ import { countedBucket } from "../storage/counted-bucket.mjs";
|
|
|
66
67
|
import { hostFailures, hostLinks, hostUploads } from "../storage/host-bucket.mjs";
|
|
67
68
|
import { pushUploadUpkeep } from "../storage/push-uploads.mjs";
|
|
68
69
|
import { checkedLimits, countedMost, hookCallsBefore, lessBefore, noScope } from "../store/call-count.mjs";
|
|
69
|
-
import { jobLimitsOf, jobsWithin } from "../store/job-try.mjs";
|
|
70
|
+
import { gitJob, jobLimitsOf, jobsWithin } from "../store/job-try.mjs";
|
|
70
71
|
import { exitOn, noCall, syncIn, uncounted } from "../store/crossing.mjs";
|
|
71
72
|
import { pruneFloor } from "../storage/rows.mjs";
|
|
72
73
|
import { queueJobs } from "../queue/advance.mjs";
|
|
73
74
|
import { queueCalls } from "../queue/calls.mjs";
|
|
74
75
|
import { QueueBase, QueueInternals, queueKeysOf, queueOptions } from "../queue/host.mjs";
|
|
75
76
|
import { queuePush } from "../queue/push-option.mjs";
|
|
77
|
+
import { buildMillisecondsOf } from "../queue/limits.mjs";
|
|
76
78
|
import { topicsOptions } from "../topics/host.mjs";
|
|
77
79
|
import { TopicsBase, topicsRegistration } from "../topics/layer.mjs";
|
|
78
80
|
import { MergeQueue } from "../contracts/queue.mjs";
|
|
@@ -95,9 +97,10 @@ import * as Option from "effect/Option";
|
|
|
95
97
|
import * as Cause from "effect/Cause";
|
|
96
98
|
import * as Exit from "effect/Exit";
|
|
97
99
|
import * as EffectResult from "effect/Result";
|
|
98
|
-
import { Bucket, BucketLinks, BucketUploads, CallLimits, JobQueue, Records } from "@ref0/infra";
|
|
100
|
+
import { Bucket, BucketLinks, BucketUploads, CallLimits, JobQueue, Records, RequestLimits } from "@ref0/infra";
|
|
99
101
|
import * as Context from "effect/Context";
|
|
100
102
|
import * as Layer from "effect/Layer";
|
|
103
|
+
import * as References from "effect/References";
|
|
101
104
|
import * as ManagedRuntime from "effect/ManagedRuntime";
|
|
102
105
|
// src/server/server.ts
|
|
103
106
|
/**
|
|
@@ -147,7 +150,7 @@ const namesOf = (optional, tokensOn, queueOn) => {
|
|
|
147
150
|
const partsOnce = (loaded) => {
|
|
148
151
|
const parts = Effect.map(loaded, (context) => Context.get(context, MergeParts));
|
|
149
152
|
return {
|
|
150
|
-
mergeTrees: (read, input, allot, call) => Effect.flatMap(parts, (one) => one.mergeTrees(read, input, allot, call)),
|
|
153
|
+
mergeTrees: (read, input, allot, call, roots) => Effect.flatMap(parts, (one) => one.mergeTrees(read, input, allot, call, roots)),
|
|
151
154
|
lineDiff: (allot) => Effect.flatMap(parts, (one) => one.lineDiff(allot))
|
|
152
155
|
};
|
|
153
156
|
};
|
|
@@ -162,7 +165,7 @@ const bridged = (setup) => ({
|
|
|
162
165
|
features: Effect.fnUntraced(function* (services, registry) {
|
|
163
166
|
if (setup.lfs !== void 0) {
|
|
164
167
|
const registration = yield* registry.register({ name: "lfs" });
|
|
165
|
-
yield* Effect.provideContext(lfsRegistration(registration), services);
|
|
168
|
+
yield* Effect.provideContext(lfsRegistration(registration, setup.lfs), services);
|
|
166
169
|
}
|
|
167
170
|
if (setup.topics !== void 0) {
|
|
168
171
|
const registration = yield* registry.register({
|
|
@@ -186,7 +189,7 @@ const bridged = (setup) => ({
|
|
|
186
189
|
});
|
|
187
190
|
/** Git's own wiring over the adapter's services, as the runtime's build runs it. */
|
|
188
191
|
const wireServer = (options, wiring) => {
|
|
189
|
-
const { adapter, merges, optional, fetchLimits,
|
|
192
|
+
const { adapter, merges, optional, fetchLimits, deciders, grants, extensions, guard, through, closing } = wiring;
|
|
190
193
|
const runtimeClock = wiring.clock;
|
|
191
194
|
const queueOf = optional.queue;
|
|
192
195
|
const { store, jobs, records: rawRecords } = adapter;
|
|
@@ -212,16 +215,7 @@ const wireServer = (options, wiring) => {
|
|
|
212
215
|
store,
|
|
213
216
|
now
|
|
214
217
|
});
|
|
215
|
-
|
|
216
|
-
deliveries: 0,
|
|
217
|
-
sealed: false
|
|
218
|
-
};
|
|
219
|
-
registry.bindDeliveries((registered) => {
|
|
220
|
-
const made = events.fill(registered);
|
|
221
|
-
seen.sealed = true;
|
|
222
|
-
seen.deliveries = events.deliveries.length;
|
|
223
|
-
return made;
|
|
224
|
-
});
|
|
218
|
+
registry.bindDeliveries((registered) => events.fill(registered));
|
|
225
219
|
const onFailure = workFailed(events, now);
|
|
226
220
|
const upkeep = upkeepsOf([...counted === void 0 ? [] : [pushUploadUpkeep(counted, adapter.uploads)], registry.upkeep]);
|
|
227
221
|
const index = objects.index === void 0 ? void 0 : indexJob({
|
|
@@ -261,12 +255,10 @@ const wireServer = (options, wiring) => {
|
|
|
261
255
|
jobs.register(...jobsWithin(jobLimits, own));
|
|
262
256
|
const decides = {
|
|
263
257
|
policy: deciders.policy,
|
|
264
|
-
reports,
|
|
265
258
|
grants
|
|
266
259
|
};
|
|
267
260
|
const authorize = authorizer(decides);
|
|
268
261
|
const checks = {
|
|
269
|
-
reports,
|
|
270
262
|
added: () => registry.pushRules(),
|
|
271
263
|
registered: () => registry.pushChecks(),
|
|
272
264
|
groups: () => registry.hookGroups()
|
|
@@ -274,7 +266,6 @@ const wireServer = (options, wiring) => {
|
|
|
274
266
|
const fences = grantFences({
|
|
275
267
|
store,
|
|
276
268
|
now,
|
|
277
|
-
reports,
|
|
278
269
|
grants
|
|
279
270
|
});
|
|
280
271
|
const repackRow = (at) => repackJobRow(repack, at);
|
|
@@ -297,6 +288,13 @@ const wireServer = (options, wiring) => {
|
|
|
297
288
|
cursors: cursorSeal(store)
|
|
298
289
|
};
|
|
299
290
|
if (indexRow !== void 0) parts.indexJobRow = indexRow;
|
|
291
|
+
const status = SealedObjects.indexStatus(sealed);
|
|
292
|
+
if (indexRow !== void 0 && status !== void 0) parts.indexLost = indexLostAsk({
|
|
293
|
+
store,
|
|
294
|
+
indexJobRow: indexRow,
|
|
295
|
+
status,
|
|
296
|
+
now
|
|
297
|
+
});
|
|
300
298
|
parts.purgeJobRow = (at) => purgeJobRow(purge, at + fetchLimits.milliseconds);
|
|
301
299
|
if (refIndex !== void 0) parts.refIndex = refIndex;
|
|
302
300
|
if (rebuild !== void 0) parts.refIndexJobRow = () => refIndexJobRow(rebuild);
|
|
@@ -304,9 +302,9 @@ const wireServer = (options, wiring) => {
|
|
|
304
302
|
const decider = {
|
|
305
303
|
check: authorize,
|
|
306
304
|
audience: audienceOf(decides),
|
|
307
|
-
ceiling: ({ caller, repo, internalId }) => accessOf(
|
|
305
|
+
ceiling: ({ caller, repo, internalId }) => accessOf(grants, store, caller, repo, internalId),
|
|
308
306
|
grantOf: grants.nameOf,
|
|
309
|
-
grantAgain: ({ resolver, request }) => grantAgain(grants,
|
|
307
|
+
grantAgain: ({ resolver, request }) => grantAgain(grants, registry.grants(), resolver, request)
|
|
310
308
|
};
|
|
311
309
|
const records = Context.make(RepoRecords, {
|
|
312
310
|
pin: (name) => pinOf(store, name),
|
|
@@ -316,7 +314,7 @@ const wireServer = (options, wiring) => {
|
|
|
316
314
|
objects: sealed,
|
|
317
315
|
fetchLimits
|
|
318
316
|
}), Context.add(Objects, objectsOverViews), Context.add(Changes, changes));
|
|
319
|
-
const base = Context.make(CoreParts, parts).pipe(Context.add(Rules, wiring.rules), Context.merge(indexed === void 0 ? stored : Context.add(stored, IndexedStorage, indexed)), Context.add(QueueParts, { jobs }), Context.add(Authorize, decider), Context.add(Clock$1.Clock, runtimeClock));
|
|
317
|
+
const base = Context.make(CoreParts, parts).pipe(Context.add(Rules, wiring.rules), Context.merge(indexed === void 0 ? stored : Context.add(stored, IndexedStorage, indexed)), Context.add(QueueParts, { jobs }), Context.add(Authorize, decider), Context.add(Clock$1.Clock, runtimeClock), Context.merge(wiring.logging));
|
|
320
318
|
const merging = merges === void 0 ? base : Context.merge(base, merges);
|
|
321
319
|
const viewed = Context.add(merging, View, viewOver(merging));
|
|
322
320
|
const needs = Context.add(viewed, Refs, providedCalls(refsCalls, viewed));
|
|
@@ -330,7 +328,8 @@ const wireServer = (options, wiring) => {
|
|
|
330
328
|
needs,
|
|
331
329
|
records: rawRecords,
|
|
332
330
|
options: queueOf,
|
|
333
|
-
keys: wiring.optional.queueKeys
|
|
331
|
+
keys: wiring.optional.queueKeys,
|
|
332
|
+
buildMilliseconds: buildMillisecondsOf(adapter.requestLimits.cpuMs)
|
|
334
333
|
};
|
|
335
334
|
const queueHeld = wiring.queue;
|
|
336
335
|
queueHeld.host = queueHost;
|
|
@@ -338,6 +337,7 @@ const wireServer = (options, wiring) => {
|
|
|
338
337
|
records: rawRecords,
|
|
339
338
|
needs,
|
|
340
339
|
onFailure,
|
|
340
|
+
cpuMs: adapter.requestLimits.cpuMs,
|
|
341
341
|
attach: (host) => Effect.suspend(() => {
|
|
342
342
|
if (queueHeld.host !== void 0) return Effect.die(/* @__PURE__ */ new TypeError("The server has a merge queue: provide MergeQueue.layer once"));
|
|
343
343
|
queueHeld.host = host;
|
|
@@ -349,6 +349,7 @@ const wireServer = (options, wiring) => {
|
|
|
349
349
|
needs,
|
|
350
350
|
bucket: counted,
|
|
351
351
|
links: adapter.links,
|
|
352
|
+
requestLimits: adapter.requestLimits,
|
|
352
353
|
attach: (lfs) => Effect.suspend(() => {
|
|
353
354
|
if (lfsAttached !== void 0) return Effect.die(/* @__PURE__ */ new TypeError("The server has Git LFS: provide Lfs.layer once"));
|
|
354
355
|
lfsAttached = lfs;
|
|
@@ -371,7 +372,7 @@ const wireServer = (options, wiring) => {
|
|
|
371
372
|
});
|
|
372
373
|
if (queueHost !== void 0) {
|
|
373
374
|
registry.bridge("queue", "refs/queue/");
|
|
374
|
-
const queueJobList = queueJobs(queueHost, onFailure);
|
|
375
|
+
const queueJobList = queueJobs(queueHost, onFailure).map((job) => job(gitJob));
|
|
375
376
|
gits.knowJobs(queueJobList);
|
|
376
377
|
jobs.register(...jobsWithin(jobLimits, queueJobList));
|
|
377
378
|
}
|
|
@@ -395,7 +396,6 @@ const wireServer = (options, wiring) => {
|
|
|
395
396
|
tokens: tokensHeld.calls,
|
|
396
397
|
store,
|
|
397
398
|
now,
|
|
398
|
-
reports,
|
|
399
399
|
through,
|
|
400
400
|
refuse: (error) => refusal(error, true)
|
|
401
401
|
})
|
|
@@ -415,7 +415,6 @@ const wireServer = (options, wiring) => {
|
|
|
415
415
|
auth: deciders.auth,
|
|
416
416
|
grants: registry.grants,
|
|
417
417
|
held: grants,
|
|
418
|
-
reports,
|
|
419
418
|
now
|
|
420
419
|
});
|
|
421
420
|
const decided = Context.add(records, Authorize, decider).pipe(Context.add(Refs, Context.get(needs, Refs)), Context.add(Rules, wiring.rules), Context.add(Objects, objectsOverViews), Context.merge(callServices(needs)), Context.add(Events, { log: events }), Context.add(QueueBase, queueBase), Context.add(SyncBase, {
|
|
@@ -475,24 +474,19 @@ const wireServer = (options, wiring) => {
|
|
|
475
474
|
identify: (request) => through(identify(request)),
|
|
476
475
|
authorize: (input) => through(Effect.provideContext(seamAuthorize(input), needs)),
|
|
477
476
|
renamedTo: (caller, repo) => through(Effect.provideContext(renamedTo(caller, repo), needs)),
|
|
478
|
-
listen: (caller, repo, after) => through(Effect.suspend(() => !keepsEvents(events) ? fail("FAILED_PRECONDITION", "This server keeps no events", {
|
|
479
|
-
hostHint: "Its host registers a delivery, with Git.register, to keep them",
|
|
480
|
-
hint: `Deliveries: ${seen.deliveries}. Sealed: ${seen.sealed ? "yes" : "no"}.`
|
|
481
|
-
}) : streams.open(caller, repo, after))),
|
|
477
|
+
listen: (caller, repo, after) => through(Effect.suspend(() => !keepsEvents(events) ? fail("FAILED_PRECONDITION", "This server keeps no events", { hostHint: "Its host registers a delivery, with Git.register, to keep them" }) : streams.open(caller, repo, after))),
|
|
482
478
|
requestMost
|
|
483
479
|
};
|
|
484
480
|
const httpOptions = { queue: queuePush(() => queueHeld.host) };
|
|
485
|
-
if (options.resolve !== void 0) httpOptions.resolve = options.resolve;
|
|
486
481
|
if (options.maxDuration !== void 0) httpOptions.maxDuration = millis(options.maxDuration);
|
|
487
482
|
if (objects.pushObjectsMost !== void 0) httpOptions.pushObjectsMost = objects.pushObjectsMost;
|
|
488
|
-
const
|
|
489
|
-
const fetchHooks = resolves + (wiring.rules.fetch.length === 0 ? 0 : 1);
|
|
483
|
+
const fetchHooks = wiring.rules.fetch.length === 0 ? 0 : 1;
|
|
490
484
|
const before = (hooks) => (most) => boundOf(lessBefore(most, {
|
|
491
485
|
bucket: hooks * hookCallsBefore.bucket,
|
|
492
486
|
subrequests: hooks * hookCallsBefore.subrequests
|
|
493
487
|
}));
|
|
494
488
|
httpOptions.calls = before(fetchHooks)(countedMost(objects) ?? callLimits);
|
|
495
|
-
httpOptions.pushCalls = before(
|
|
489
|
+
httpOptions.pushCalls = before(0)(callLimits);
|
|
496
490
|
httpOptions.lfs = () => lfsAttached?.service;
|
|
497
491
|
httpOptions.uploads = () => uploadsAttached;
|
|
498
492
|
const http = gitHttp(coreHttpParts(served, httpOptions));
|
|
@@ -527,16 +521,14 @@ const isLayers = (adapter) => Array.isArray(adapter);
|
|
|
527
521
|
* runtime builds the adapter's Layers and Git's wiring once the tick that made it ends, which
|
|
528
522
|
* registers Git's jobs on the adapter's queue, and never runs them: the host starts them.
|
|
529
523
|
*/
|
|
530
|
-
const createGitServer = (options) =>
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
auth: authOf(options.auth, reports)
|
|
535
|
-
}), features);
|
|
524
|
+
const createGitServer = (options) => serverWith(options, () => ({
|
|
525
|
+
policy: policyOf(options.authorize),
|
|
526
|
+
auth: authOf(options.auth)
|
|
527
|
+
}));
|
|
536
528
|
/**
|
|
537
|
-
* `createGitServer` deciding with `decidersOf`'s answer, which it asks once
|
|
538
|
-
*
|
|
539
|
-
*
|
|
529
|
+
* `createGitServer` deciding with `decidersOf`'s answer, which it asks once as the server builds:
|
|
530
|
+
* `createGitServer` gives its options' hooks. Internal: no entry exports it, so a host
|
|
531
|
+
* gives a `Policy` only through `Git.layer`.
|
|
540
532
|
*/
|
|
541
533
|
const serverWith = (options, decidersOf, features) => openServer(options, decidersOf, "build", features).server;
|
|
542
534
|
/**
|
|
@@ -554,10 +546,7 @@ const openServer = (options, decidersOf, sealing, features) => {
|
|
|
554
546
|
if (setup.topics !== void 0 && queueOf === void 0) throw new TypeError("topics merge through each repo’s queue: pass queue too");
|
|
555
547
|
if (queueOf !== void 0 && setup.xdiff === void 0) throw new TypeError("the merge queue merges trees: pass xdiff too");
|
|
556
548
|
const fetchLimits = fetchLimitsOf(setup.fetchLimits);
|
|
557
|
-
const reports = {};
|
|
558
549
|
const grants = heldGrants();
|
|
559
|
-
if (setup.onError !== void 0) reports.onError = setup.onError;
|
|
560
|
-
if (setup.onRefused !== void 0) reports.onRefused = setup.onRefused;
|
|
561
550
|
const basePath = normalBase(setup.basePath ?? "");
|
|
562
551
|
const extensions = openExtensions(basePath);
|
|
563
552
|
const joins = [];
|
|
@@ -604,10 +593,12 @@ const openServer = (options, decidersOf, sealing, features) => {
|
|
|
604
593
|
const records = yield* Records.Records;
|
|
605
594
|
const queue = yield* JobQueue.JobQueue;
|
|
606
595
|
const callLimits = yield* CallLimits.CallLimits;
|
|
596
|
+
const requestLimits = yield* Effect.serviceOption(RequestLimits.RequestLimits);
|
|
607
597
|
const bucket = yield* Effect.serviceOption(Bucket.Bucket);
|
|
608
598
|
const links = yield* Effect.serviceOption(BucketLinks.BucketLinks);
|
|
609
599
|
const uploads = yield* Effect.serviceOption(BucketUploads.BucketUploads);
|
|
610
600
|
const clock = yield* Effect.clockWith(Effect.succeed);
|
|
601
|
+
const logging = Context.make(References.CurrentLoggers, yield* References.CurrentLoggers).pipe(Context.add(References.MinimumLogLevel, yield* References.MinimumLogLevel));
|
|
611
602
|
const xdiff = setup.xdiff;
|
|
612
603
|
const loaded = xdiff === void 0 ? void 0 : yield* Effect.cached(Effect.flatMap(Effect.promise(() => import("../merges/merges.mjs")), ({ mergesContext }) => mergesContext({ xdiff }, objectsOverViews)));
|
|
613
604
|
const merges = loaded === void 0 ? void 0 : Context.make(MergeParts, partsOnce(loaded));
|
|
@@ -625,7 +616,8 @@ const openServer = (options, decidersOf, sealing, features) => {
|
|
|
625
616
|
links: Option.isSome(links) ? doorLinks(hostLinks(links.value), context, door) : void 0,
|
|
626
617
|
uploads: Option.isSome(uploads) ? doorUploads(hostUploads(uploads.value), context, door) : void 0,
|
|
627
618
|
clock: promisesClock(clock, context, door),
|
|
628
|
-
callLimits
|
|
619
|
+
callLimits,
|
|
620
|
+
requestLimits: Option.getOrElse(requestLimits, () => ({}))
|
|
629
621
|
};
|
|
630
622
|
const given = {
|
|
631
623
|
adapter,
|
|
@@ -635,12 +627,12 @@ const openServer = (options, decidersOf, sealing, features) => {
|
|
|
635
627
|
tokens: tokensHeld,
|
|
636
628
|
queue: queueHeld,
|
|
637
629
|
fetchLimits,
|
|
638
|
-
|
|
639
|
-
deciders: decidersOf(reports),
|
|
630
|
+
deciders: decidersOf(),
|
|
640
631
|
grants,
|
|
641
632
|
extensions,
|
|
642
633
|
basePath,
|
|
643
634
|
clock,
|
|
635
|
+
logging,
|
|
644
636
|
access: Option.getOrUndefined(yield* Effect.serviceOption(PrivateRefs))
|
|
645
637
|
};
|
|
646
638
|
const wired = yield* Effect.sync(() => wireServer(setup, {
|
|
@@ -778,6 +770,7 @@ const openServer = (options, decidersOf, sealing, features) => {
|
|
|
778
770
|
attachJoins(server, {
|
|
779
771
|
admit: life.admit,
|
|
780
772
|
basePath,
|
|
773
|
+
fetchLimits,
|
|
781
774
|
get queueKeys() {
|
|
782
775
|
return queueHeld.host?.keys;
|
|
783
776
|
},
|
|
@@ -825,4 +818,4 @@ const openServer = (options, decidersOf, sealing, features) => {
|
|
|
825
818
|
seal
|
|
826
819
|
};
|
|
827
820
|
};
|
|
828
|
-
export { createGitServer, openServer, serverWith
|
|
821
|
+
export { createGitServer, openServer, serverWith };
|
package/dist/signin/context.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { gitError } from "../contracts/result.mjs";
|
|
2
|
-
import { hostEffect,
|
|
2
|
+
import { hostEffect, logRefusal } from "../auth/host-function.mjs";
|
|
3
3
|
import { readTarget, tokenExpiry } from "../auth/tokens.mjs";
|
|
4
4
|
import { oauthAnswer, oauthError } from "./forms.mjs";
|
|
5
5
|
import { approvalOf } from "./grants.mjs";
|
|
@@ -10,8 +10,8 @@ import * as Schema from "effect/Schema";
|
|
|
10
10
|
/** `gh`'s OAuth client ID, which the device flow takes beside the registered clients. */
|
|
11
11
|
const ghClientId = "178c6fc778ccc68e1d6a";
|
|
12
12
|
/**
|
|
13
|
-
* The page in the caller's fiber: explicit failures keep Git's status and code, and
|
|
14
|
-
* `
|
|
13
|
+
* The page in the caller's fiber: explicit failures keep Git's status and code, and are logged at
|
|
14
|
+
* `Debug` as every host function's refusal is. A decide's store failure keeps the plain
|
|
15
15
|
* unavailable page; a defect is reported as a host failure. Each invocation receives its own
|
|
16
16
|
* unread request body.
|
|
17
17
|
*/
|
|
@@ -29,12 +29,8 @@ const approvalPage = /* @__PURE__ */ Effect.fnUntraced(function* (signIn, reques
|
|
|
29
29
|
...page,
|
|
30
30
|
request: request.clone(),
|
|
31
31
|
signal
|
|
32
|
-
})).pipe(Effect.catch((error) => Effect.sync(() => {
|
|
33
|
-
|
|
34
|
-
reportRefusal(signIn.reports, "approvalPage", {}, error);
|
|
35
|
-
return signIn.refuse(error);
|
|
36
|
-
})));
|
|
37
|
-
return yield* hostEffect(signIn.reports, "approvalPage", {}, answer).pipe(Effect.onInterrupt(() => Effect.sync(() => controller.abort())));
|
|
32
|
+
})).pipe(Effect.catch((error) => failedDecisions.has(error) ? Effect.sync(() => unavailablePage(error)) : Effect.map(logRefusal("approvalPage", {}, error), () => signIn.refuse(error))));
|
|
33
|
+
return yield* hostEffect("approvalPage", {}, answer).pipe(Effect.onInterrupt(() => Effect.sync(() => controller.abort())));
|
|
38
34
|
});
|
|
39
35
|
/**
|
|
40
36
|
* What a browser sees when sign-in failed: a 503 to try again, or a 500 for a store the host didn't
|
|
@@ -2,6 +2,7 @@ import { repoScope } from "../store/scopes.mjs";
|
|
|
2
2
|
import { bucketDo } from "./calls.mjs";
|
|
3
3
|
import { markerKey, markerPrefix, objectCollections } from "./layout.mjs";
|
|
4
4
|
import { mergeKey } from "./merge-row.mjs";
|
|
5
|
+
import { noRows } from "./object-rows.mjs";
|
|
5
6
|
import { deletePackFiles } from "./quarantine.mjs";
|
|
6
7
|
import { deleteStaged, receiveKey, stagedRow } from "./receive-steps.mjs";
|
|
7
8
|
import { QuarantineRow, StagedRow, decodeHeld, decodeLeft, quarantineKey, quarantineRow, stagedKey } from "./rows.mjs";
|
|
@@ -187,7 +188,8 @@ const cleanUp = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
|
187
188
|
const step = {
|
|
188
189
|
change: {
|
|
189
190
|
put,
|
|
190
|
-
delete: ended
|
|
191
|
+
delete: ended,
|
|
192
|
+
rows: noRows
|
|
191
193
|
},
|
|
192
194
|
more
|
|
193
195
|
};
|
package/dist/storage/fsck.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { gitError } from "../contracts/result.mjs";
|
|
2
2
|
import { checkedBlobs, checkedTableBytes } from "../protocol/objects/checked-blobs.mjs";
|
|
3
3
|
import { checkedBlobFault } from "../protocol/objects/fsck.mjs";
|
|
4
|
+
import { cutWords, quoted } from "../protocol/bytes/text.mjs";
|
|
4
5
|
import { mostParents } from "../protocol/objects/object-rules.mjs";
|
|
5
6
|
import { oidBytes } from "../protocol/packs/idx.mjs";
|
|
6
7
|
import * as Effect from "effect/Effect";
|
|
@@ -17,14 +18,23 @@ const tooManyParents = (what, parents) => gitError("INVALID_ARGUMENT", `${what}
|
|
|
17
18
|
given: parents
|
|
18
19
|
}
|
|
19
20
|
});
|
|
20
|
-
/**
|
|
21
|
-
|
|
21
|
+
/**
|
|
22
|
+
* A push refused for an object Git 2.53 would refuse it for, under git-fsck's msg-id. A tree that
|
|
23
|
+
* names an entry twice is named with the entry's name too, which Git's message leaves out.
|
|
24
|
+
*/
|
|
25
|
+
const fsckRefusal = (oid, fault) => fault.parents === void 0 ? gitError("INVALID_ARGUMENT", `object ${oid}: ${fault.msgId}: ${fault.message}${namedIn(fault)}`, {
|
|
22
26
|
hint: "Fix the object, then push again",
|
|
23
27
|
context: {
|
|
24
28
|
reason: "fsck",
|
|
25
29
|
msgId: fault.msgId
|
|
26
30
|
}
|
|
27
31
|
}) : tooManyParents(`object ${oid}`, fault.parents);
|
|
32
|
+
const namedIn = (fault) => {
|
|
33
|
+
if (fault.name === void 0) return "";
|
|
34
|
+
const shown = cutWords(fault.name, 256);
|
|
35
|
+
const cut = shown.length < fault.name.length ? ` (its first ${shown.length} characters)` : "";
|
|
36
|
+
return `, ${quoted(shown)}${cut} twice`;
|
|
37
|
+
};
|
|
28
38
|
/**
|
|
29
39
|
* What a push's `.gitmodules` and `.gitattributes` hold, however many its trees name: each blob
|
|
30
40
|
* they name as one is kept to check once the pack is read, at most `most` of them. A tree naming
|