@ref0/git 0.12.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 +3 -3
- 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 +11 -1
- package/dist/contracts/git.d.mts +18 -7
- 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 +23 -18
- package/dist/contracts/result.mjs +17 -4
- 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 +79 -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.mjs +27 -5
- package/dist/core/ancestry.d.mts +9 -0
- package/dist/core/ancestry.mjs +6 -6
- package/dist/core/asked.mjs +42 -4
- package/dist/core/call-names.mjs +1 -0
- package/dist/core/call-services.mjs +2 -1
- package/dist/core/events/deliver.mjs +10 -2
- package/dist/core/forks.mjs +3 -3
- package/dist/core/imports.mjs +147 -9
- 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/parts.d.mts +6 -1
- 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 +98 -26
- package/dist/core/receipts.mjs +26 -10
- package/dist/core/ref-view.mjs +59 -5
- package/dist/core/refs.mjs +13 -8
- package/dist/core/repack.mjs +11 -8
- package/dist/core/repo-info.mjs +16 -9
- package/dist/core/repos.mjs +30 -14
- 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 +3 -3
- package/dist/extend.mjs +2 -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 +114 -56
- 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/objects.d.mts +6 -0
- package/dist/lfs/objects.mjs +68 -41
- 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/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 +31 -23
- 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 +273 -240
- 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 +127 -115
- package/dist/rest/forks.d.mts +121 -97
- 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 +2 -1
- 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 +282 -226
- package/dist/rest/refs.d.mts +205 -176
- package/dist/rest/repos.d.mts +108 -80
- package/dist/rest/tags.d.mts +24 -12
- package/dist/rest/tokens.d.mts +235 -211
- package/dist/rest/topics.d.mts +53 -33
- package/dist/rest/trees.d.mts +105 -89
- 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 +3 -3
- 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 +133 -212
- 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 +28 -4
- package/dist/storage/pack-reads.mjs +8 -8
- 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-walk.mjs +54 -16
- package/dist/storage/prune.mjs +629 -196
- package/dist/storage/push-uploads.mjs +36 -12
- package/dist/storage/quarantine.mjs +9 -9
- 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 +9 -7
- package/dist/store/repo-record.mjs +102 -19
- 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 +55 -43
- package/dist/sync/http.mjs +36 -1
- package/dist/sync/import.mjs +1 -0
- 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 +210 -137
- package/dist/sync/smart-http.mjs +4 -2
- package/dist/sync/step.mjs +25 -5
- package/dist/sync/tries.mjs +45 -14
- package/dist/sync.d.mts +2 -2
- 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 -5
- 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
|
@@ -6,11 +6,18 @@ import { RepoInfo, RepoInput } from "./repos.mjs";
|
|
|
6
6
|
import * as Effect from "effect/Effect";
|
|
7
7
|
import * as Schema from "effect/Schema";
|
|
8
8
|
import * as Context from "effect/Context";
|
|
9
|
+
/**
|
|
10
|
+
* A sync remote's sender of one request, in place of Git's own client: an Effect, run in the try's
|
|
11
|
+
* fiber, so Git charges each call of it to the try's `CallBudget` as one subrequest before it
|
|
12
|
+
* runs, and a request it sends again, as a retry, charges that one itself, through
|
|
13
|
+
* `CallBudget.charged`. A failure is the remote's: the try fails, and the job tries again.
|
|
14
|
+
*/
|
|
15
|
+
export declare const SyncTransport: Schema.declare<(request: Request) => Effect.Effect<Response, GitError>, (request: Request) => Effect.Effect<Response, GitError>>;
|
|
16
|
+
export type SyncTransport = typeof SyncTransport.Type;
|
|
9
17
|
/**
|
|
10
18
|
* A remote as one try reaches it. Its `credentials` are short-lived: a provider makes them again
|
|
11
19
|
* for each try, and Git never stores or logs them. `transport` sends its requests in place of
|
|
12
|
-
*
|
|
13
|
-
* own `fetch`.
|
|
20
|
+
* Git's client: a service binding's `fetch`, say, or another server's own.
|
|
14
21
|
*/
|
|
15
22
|
export declare const SyncRemote: Schema.Struct<{
|
|
16
23
|
readonly url: Schema.String;
|
|
@@ -20,7 +27,7 @@ export declare const SyncRemote: Schema.Struct<{
|
|
|
20
27
|
}>, Schema.Struct<{
|
|
21
28
|
readonly token: Schema.String;
|
|
22
29
|
}>]>, Schema.declare<(input: CredentialInput) => Awaitable<ClientCredential>, (input: CredentialInput) => Awaitable<ClientCredential>>]>>;
|
|
23
|
-
readonly transport: Schema.optionalKey<Schema.declare<(request: Request) =>
|
|
30
|
+
readonly transport: Schema.optionalKey<Schema.declare<(request: Request) => Effect.Effect<Response, GitError>, (request: Request) => Effect.Effect<Response, GitError>>>;
|
|
24
31
|
}>;
|
|
25
32
|
export type SyncRemote = typeof SyncRemote.Type;
|
|
26
33
|
/** What a provider's webhook says moved: `repo` is the provider's own name for the remote. */
|
|
@@ -32,14 +39,16 @@ export declare const SyncTrigger: Schema.Struct<{
|
|
|
32
39
|
export type SyncTrigger = typeof SyncTrigger.Type;
|
|
33
40
|
/**
|
|
34
41
|
* A kind of remote, as the host sets it up once: `smartHttp()` or `github({ app })`. `remote`
|
|
35
|
-
* answers the URL and fresh credentials for one of its repos, and runs again at every try
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
42
|
+
* answers the URL and fresh credentials for one of its repos, and runs again at every try, in the
|
|
43
|
+
* try's fiber, so a request it sends to mint them is charged to the try's `CallBudget` through
|
|
44
|
+
* `CallBudget.charged`. One that fails or dies, or answers no credentials where the remote asks for
|
|
45
|
+
* them, fails that try, and the job's retry tries again; interrupting the try interrupts it.
|
|
46
|
+
* `access` is what the try does there: an import's reads, a mirror's pushes, so a provider mints
|
|
47
|
+
* credentials for that and no more.
|
|
39
48
|
*/
|
|
40
49
|
export interface SyncProvider {
|
|
41
50
|
readonly name: string;
|
|
42
|
-
readonly remote: (repo: string, access: 'read' | 'write'
|
|
51
|
+
readonly remote: (repo: string, access: 'read' | 'write') => Effect.Effect<SyncRemote, GitError>;
|
|
43
52
|
/**
|
|
44
53
|
* The top-level string fields of its remote's JSON refusal, status 400 or more, that a sync
|
|
45
54
|
* error may keep, such as `['message']`: each one the remote never fills with the request's
|
|
@@ -74,12 +83,15 @@ export type SyncSource = typeof SyncSource.Type;
|
|
|
74
83
|
* a host such as the GitHub drop-in publishes from the pull's record with `publishImported`.
|
|
75
84
|
*/
|
|
76
85
|
export declare const importedPullRefs = "refs/import/pull/";
|
|
77
|
-
/**
|
|
78
|
-
|
|
86
|
+
/**
|
|
87
|
+
* An import's phases, in order: `fetch` from the remote, `receive` into the repo, copy its Git LFS
|
|
88
|
+
* objects, `lfs`, on a server with `Lfs.layer`, and `publish` its refs.
|
|
89
|
+
*/
|
|
90
|
+
export declare const ImportPhase: Schema.Literals<readonly ["fetch", "receive", "lfs", "publish"]>;
|
|
79
91
|
export type ImportPhase = typeof ImportPhase.Type;
|
|
80
92
|
/** At most four measures, as `context.progress` takes them. */
|
|
81
93
|
export declare const ImportProgress: Schema.Struct<{
|
|
82
|
-
readonly phase: Schema.Literals<readonly ["fetch", "receive", "publish"]>;
|
|
94
|
+
readonly phase: Schema.Literals<readonly ["fetch", "receive", "lfs", "publish"]>;
|
|
83
95
|
readonly measures: Schema.$Array<Schema.Struct<{
|
|
84
96
|
readonly unit: Schema.Literals<readonly ["bytes", "objects", "entries", "packs"]>;
|
|
85
97
|
readonly completed: Schema.Number;
|
|
@@ -105,11 +117,17 @@ export interface SyncImportInput extends Omit<WriteInput, 'signal'> {
|
|
|
105
117
|
* for a paused mirror, it resumes it. A `destination` naming a provider `Sync.layer` wasn't given is
|
|
106
118
|
* refused `INVALID_ARGUMENT`, reason `provider-unknown`, and so is a `ref` only Git's own writers
|
|
107
119
|
* move, such as one under `refs/queue/` or `refs/import/`. It takes no `key`: sent again, it saves
|
|
108
|
-
* the same mirror.
|
|
120
|
+
* the same mirror, as this call says, so one sent without `deletes` deletes no more.
|
|
109
121
|
*/
|
|
110
122
|
export interface SyncMirrorInput extends Omit<ActorInput, 'signal'>, RepoInput {
|
|
111
123
|
readonly destination: SyncSource;
|
|
112
124
|
readonly ref?: RefName;
|
|
125
|
+
/**
|
|
126
|
+
* Deletes the upstream's ref once `ref` is deleted here, as `git push --mirror` does, while the
|
|
127
|
+
* upstream is still at the mirror's last push: one pushed there since pauses it `diverged`.
|
|
128
|
+
* Left out, the upstream keeps its copy.
|
|
129
|
+
*/
|
|
130
|
+
readonly deletes?: boolean;
|
|
113
131
|
}
|
|
114
132
|
/**
|
|
115
133
|
* Why a mirror stopped: `diverged`, the upstream holds commits the ref doesn't; `refused`, the
|
|
@@ -121,16 +139,18 @@ export interface SyncMirrorInput extends Omit<ActorInput, 'signal'>, RepoInput {
|
|
|
121
139
|
export declare const MirrorPause: Schema.Literals<readonly ["diverged", "refused", "unseen"]>;
|
|
122
140
|
export type MirrorPause = typeof MirrorPause.Type;
|
|
123
141
|
/**
|
|
124
|
-
* A mirror of `ref`: `active`, or `paused` and why
|
|
125
|
-
*
|
|
142
|
+
* A mirror of `ref`: `active`, or `paused` and why, and `deletes` when `mirror` saved it so, left
|
|
143
|
+
* out otherwise. `lastPushed` is the last push its upstream took, kept across pauses and resumes to
|
|
144
|
+
* the same destination, and left out until one lands.
|
|
126
145
|
*/
|
|
127
146
|
export declare const MirrorState: Schema.Struct<{
|
|
128
147
|
readonly repo: Schema.String;
|
|
129
148
|
readonly ref: Schema.String;
|
|
130
149
|
readonly state: Schema.Literals<readonly ["active", "paused"]>;
|
|
150
|
+
readonly deletes: Schema.optionalKey<Schema.Literal<true>>;
|
|
131
151
|
readonly paused: Schema.optionalKey<Schema.Literals<readonly ["diverged", "refused", "unseen"]>>;
|
|
132
152
|
readonly lastPushed: Schema.optionalKey<Schema.Struct<{
|
|
133
|
-
readonly oid: Schema.String
|
|
153
|
+
readonly oid: Schema.NullOr<Schema.String>;
|
|
134
154
|
readonly at: Schema.Int;
|
|
135
155
|
}>>;
|
|
136
156
|
}>;
|
|
@@ -199,9 +219,15 @@ export declare const ImportJobData: Schema.Struct<{
|
|
|
199
219
|
}>;
|
|
200
220
|
}>;
|
|
201
221
|
export type ImportJobData = typeof ImportJobData.Type;
|
|
202
|
-
/**
|
|
222
|
+
/**
|
|
223
|
+
* `sync.mirror`, one a destination, in the repo's scope, keyed by the destination's digest: each
|
|
224
|
+
* try pushes every ref whose mirror names it.
|
|
225
|
+
*/
|
|
203
226
|
export declare const MirrorJobData: Schema.Struct<{
|
|
204
|
-
readonly
|
|
227
|
+
readonly destination: Schema.Struct<{
|
|
228
|
+
readonly provider: Schema.String;
|
|
229
|
+
readonly repo: Schema.String;
|
|
230
|
+
}>;
|
|
205
231
|
}>;
|
|
206
232
|
export type MirrorJobData = typeof MirrorJobData.Type;
|
|
207
233
|
/**
|
|
@@ -210,6 +236,37 @@ export type MirrorJobData = typeof MirrorJobData.Type;
|
|
|
210
236
|
* failed, and `done` once its history is published. Only `done` holds the source's history.
|
|
211
237
|
*/
|
|
212
238
|
export type ImportState = 'running' | 'cancelled' | 'failed' | 'done';
|
|
239
|
+
/** Why an import kept no copy of a Git LFS object its history points at. */
|
|
240
|
+
export declare const ImportLfsReason: Schema.Literals<readonly ["not-found", "refused", "other-bytes", "too-large", "no-lfs"]>;
|
|
241
|
+
export type ImportLfsReason = typeof ImportLfsReason.Type;
|
|
242
|
+
/**
|
|
243
|
+
* An LFS object the source didn't give, `ImportStatus.lfs.missed` names: `not-found` where the
|
|
244
|
+
* source's batch said it holds none, `refused` where it answered another error for it, as one
|
|
245
|
+
* past its own size limit, `other-bytes` where the bytes it sent weren't the oid's, `too-large`
|
|
246
|
+
* where the pointer names more than LFS keeps, and `no-lfs` where the source serves no LFS API.
|
|
247
|
+
* The repo answers it as one never uploaded.
|
|
248
|
+
*/
|
|
249
|
+
export interface ImportLfsMissed {
|
|
250
|
+
readonly oid: string;
|
|
251
|
+
readonly size: number;
|
|
252
|
+
readonly reason: ImportLfsReason;
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* A repo's import as `JoinedCalls.importState` reads it: its `state`, and, on a server with
|
|
256
|
+
* `Lfs.layer`, the Git LFS objects its history points at that it has copied, `copied` of them
|
|
257
|
+
* and `bytes`, and those it couldn't, `missing`, the first `importLfsMissedMost` of them by oid in
|
|
258
|
+
* `missed`. An import whose source misses an object still completes: the pointer is published,
|
|
259
|
+
* and the object answers 404, as it did at the source.
|
|
260
|
+
*/
|
|
261
|
+
export interface ImportStatus {
|
|
262
|
+
readonly state: ImportState;
|
|
263
|
+
readonly lfs?: {
|
|
264
|
+
readonly copied: number;
|
|
265
|
+
readonly bytes: number;
|
|
266
|
+
readonly missing: number;
|
|
267
|
+
readonly missed: readonly ImportLfsMissed[];
|
|
268
|
+
};
|
|
269
|
+
}
|
|
213
270
|
/** The feature's calls, bound to the server that built its Layer. */
|
|
214
271
|
export interface SyncCalls {
|
|
215
272
|
readonly import: (input: SyncImportInput) => Effect.Effect<RepoInfo, GitError>;
|
|
@@ -227,6 +284,7 @@ export declare const importRepo: (input: SyncImportInput) => Effect.Effect<{
|
|
|
227
284
|
readonly defaultBranch?: string;
|
|
228
285
|
readonly public: boolean;
|
|
229
286
|
readonly upstream?: string;
|
|
287
|
+
readonly shallow: boolean;
|
|
230
288
|
readonly stats: {
|
|
231
289
|
readonly repo: string;
|
|
232
290
|
readonly refs: number;
|
|
@@ -254,9 +312,10 @@ export declare const mirror: (input: SyncMirrorInput) => Effect.Effect<{
|
|
|
254
312
|
readonly repo: string;
|
|
255
313
|
readonly ref: string;
|
|
256
314
|
readonly state: "active" | "paused";
|
|
315
|
+
readonly deletes?: true;
|
|
257
316
|
readonly paused?: "diverged" | "refused" | "unseen";
|
|
258
317
|
readonly lastPushed?: {
|
|
259
|
-
readonly oid: string;
|
|
318
|
+
readonly oid: string | null;
|
|
260
319
|
readonly at: number;
|
|
261
320
|
};
|
|
262
321
|
}, GitError, Sync>;
|
|
@@ -264,9 +323,10 @@ export declare const mirrors: (input: SyncMirrorsInput) => Effect.Effect<readonl
|
|
|
264
323
|
readonly repo: string;
|
|
265
324
|
readonly ref: string;
|
|
266
325
|
readonly state: "active" | "paused";
|
|
326
|
+
readonly deletes?: true;
|
|
267
327
|
readonly paused?: "diverged" | "refused" | "unseen";
|
|
268
328
|
readonly lastPushed?: {
|
|
269
|
-
readonly oid: string;
|
|
329
|
+
readonly oid: string | null;
|
|
270
330
|
readonly at: number;
|
|
271
331
|
};
|
|
272
332
|
}[], GitError, Sync>;
|
package/dist/contracts/sync.mjs
CHANGED
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
import { Oid, RefName } from "./ids.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { FunctionValue } from "./opaque.mjs";
|
|
3
|
+
import { ClientCredentials } from "./remote.mjs";
|
|
3
4
|
import { WorkMeasure } from "./work.mjs";
|
|
4
5
|
import * as Effect from "effect/Effect";
|
|
5
6
|
import * as Schema from "effect/Schema";
|
|
6
7
|
import * as Context from "effect/Context";
|
|
7
|
-
|
|
8
|
+
// src/contracts/sync.ts
|
|
9
|
+
/**
|
|
10
|
+
* A sync remote's sender of one request, in place of Git's own client: an Effect, run in the try's
|
|
11
|
+
* fiber, so Git charges each call of it to the try's `CallBudget` as one subrequest before it
|
|
12
|
+
* runs, and a request it sends again, as a retry, charges that one itself, through
|
|
13
|
+
* `CallBudget.charged`. A failure is the remote's: the try fails, and the job tries again.
|
|
14
|
+
*/
|
|
15
|
+
const SyncTransport = /* @__PURE__ */ FunctionValue();
|
|
16
|
+
Schema.String, Schema.optionalKey(ClientCredentials), Schema.optionalKey(SyncTransport);
|
|
8
17
|
Schema.String;
|
|
9
18
|
/**
|
|
10
19
|
* A remote repo by its provider's `name` and the provider's own name for it, such as
|
|
@@ -21,10 +30,14 @@ const SyncSource = /* @__PURE__ */ Schema.Struct({
|
|
|
21
30
|
* a host such as the GitHub drop-in publishes from the pull's record with `publishImported`.
|
|
22
31
|
*/
|
|
23
32
|
const importedPullRefs = "refs/import/pull/";
|
|
24
|
-
/**
|
|
33
|
+
/**
|
|
34
|
+
* An import's phases, in order: `fetch` from the remote, `receive` into the repo, copy its Git LFS
|
|
35
|
+
* objects, `lfs`, on a server with `Lfs.layer`, and `publish` its refs.
|
|
36
|
+
*/
|
|
25
37
|
const ImportPhase = /* @__PURE__ */ Schema.Literals([
|
|
26
38
|
"fetch",
|
|
27
39
|
"receive",
|
|
40
|
+
"lfs",
|
|
28
41
|
"publish"
|
|
29
42
|
]);
|
|
30
43
|
Schema.Array(WorkMeasure);
|
|
@@ -41,14 +54,14 @@ const MirrorPause = /* @__PURE__ */ Schema.Literals([
|
|
|
41
54
|
"unseen"
|
|
42
55
|
]);
|
|
43
56
|
/**
|
|
44
|
-
* A mirror's last push its upstream took: the ID the ref moved to there,
|
|
45
|
-
* the mirror sent it, or first found the upstream already at it.
|
|
57
|
+
* A mirror's last push its upstream took: the ID the ref moved to there, `null` for a delete, and
|
|
58
|
+
* when, by `Clock`: when the mirror sent it, or first found the upstream already at it.
|
|
46
59
|
*/
|
|
47
60
|
const MirrorPush = /* @__PURE__ */ Schema.Struct({
|
|
48
|
-
oid: Oid,
|
|
61
|
+
oid: Schema.NullOr(Oid),
|
|
49
62
|
at: Schema.Int
|
|
50
63
|
});
|
|
51
|
-
Schema.Literals(["active", "paused"]), Schema.optionalKey(MirrorPause), Schema.optionalKey(MirrorPush);
|
|
64
|
+
Schema.Literals(["active", "paused"]), Schema.optionalKey(Schema.Literal(true)), Schema.optionalKey(MirrorPause), Schema.optionalKey(MirrorPush);
|
|
52
65
|
Schema.Struct({
|
|
53
66
|
from: RefName,
|
|
54
67
|
oid: Oid,
|
|
@@ -61,8 +74,19 @@ Schema.Struct({
|
|
|
61
74
|
});
|
|
62
75
|
/** `sync.import`, keyed `import`, in the repo's scope. */
|
|
63
76
|
const ImportJobData = /* @__PURE__ */ Schema.Struct({ source: SyncSource });
|
|
64
|
-
/**
|
|
65
|
-
|
|
77
|
+
/**
|
|
78
|
+
* `sync.mirror`, one a destination, in the repo's scope, keyed by the destination's digest: each
|
|
79
|
+
* try pushes every ref whose mirror names it.
|
|
80
|
+
*/
|
|
81
|
+
const MirrorJobData = /* @__PURE__ */ Schema.Struct({ destination: SyncSource });
|
|
82
|
+
/** Why an import kept no copy of a Git LFS object its history points at. */
|
|
83
|
+
const ImportLfsReason = /* @__PURE__ */ Schema.Literals([
|
|
84
|
+
"not-found",
|
|
85
|
+
"refused",
|
|
86
|
+
"other-bytes",
|
|
87
|
+
"too-large",
|
|
88
|
+
"no-lfs"
|
|
89
|
+
]);
|
|
66
90
|
/** Import and mirroring, present only when the host composes Sync.layer. */
|
|
67
91
|
var Sync = class extends (/* @__PURE__ */ Context.Service()("@ref0/git/Sync")) {};
|
|
68
92
|
const importRepo = (input) => Effect.flatMap(Sync, (sync) => sync.import(input));
|
|
@@ -71,4 +95,4 @@ const mirror = (input) => Effect.flatMap(Sync, (sync) => sync.mirror(input));
|
|
|
71
95
|
const mirrors = (input) => Effect.flatMap(Sync, (sync) => sync.mirrors(input));
|
|
72
96
|
const removeMirror = (input) => Effect.flatMap(Sync, (sync) => sync.removeMirror(input));
|
|
73
97
|
const publishImported = (input) => Effect.flatMap(Sync, (sync) => sync.publishImported(input));
|
|
74
|
-
export { ImportJobData, ImportPhase, MirrorJobData, MirrorPause, MirrorPush, Sync, SyncSource, cancelImport, importRepo, importedPullRefs, mirror, mirrors, publishImported, removeMirror };
|
|
98
|
+
export { ImportJobData, ImportLfsReason, ImportPhase, MirrorJobData, MirrorPause, MirrorPush, Sync, SyncSource, SyncTransport, cancelImport, importRepo, importedPullRefs, mirror, mirrors, publishImported, removeMirror };
|
|
@@ -194,15 +194,10 @@ export interface VerifiedToken {
|
|
|
194
194
|
readonly actor: NamedActor;
|
|
195
195
|
readonly scope: TokenScope;
|
|
196
196
|
}
|
|
197
|
-
/** Turns on Git's tokens: `tokens()`, from `@ref0/git/auth`. */
|
|
198
|
-
export interface TokensFeature {
|
|
199
|
-
readonly kind: 'tokens';
|
|
200
|
-
}
|
|
201
197
|
declare const Tokens_base: Context.ServiceClass<Tokens, "@ref0/git/Tokens", EffectCalls<TokenCalls, never>>;
|
|
202
198
|
/**
|
|
203
199
|
* Git's own tokens: `TokenCalls` as Effects, deciding for no caller, as host code's do.
|
|
204
|
-
* `Tokens.layer()` provides it
|
|
205
|
-
* neither it isn't there, so code that may run without it reads it with `Effect.serviceOption`.
|
|
200
|
+
* `Tokens.layer()` provides it. Without it it isn't there, so code that may run without it reads it with `Effect.serviceOption`.
|
|
206
201
|
*/
|
|
207
202
|
export declare class Tokens extends /* @__PURE__ */ Tokens_base {}
|
|
208
203
|
export declare const create: (target: TokenTarget, input: TokenCreateInput) => Effect.Effect<{
|
|
@@ -105,8 +105,7 @@ const TokenList = /* @__PURE__ */ Schema.Struct({
|
|
|
105
105
|
});
|
|
106
106
|
/**
|
|
107
107
|
* Git's own tokens: `TokenCalls` as Effects, deciding for no caller, as host code's do.
|
|
108
|
-
* `Tokens.layer()` provides it
|
|
109
|
-
* neither it isn't there, so code that may run without it reads it with `Effect.serviceOption`.
|
|
108
|
+
* `Tokens.layer()` provides it. Without it it isn't there, so code that may run without it reads it with `Effect.serviceOption`.
|
|
110
109
|
*/
|
|
111
110
|
var Tokens = class extends (/* @__PURE__ */ Context.Service()("@ref0/git/Tokens")) {};
|
|
112
111
|
const create = (target, input) => Effect.flatMap(Effect.service(Tokens), (tokens) => tokens.create(target, input));
|
|
@@ -267,9 +267,4 @@ export interface TopicsLayerOptions {
|
|
|
267
267
|
* drains of what's open.
|
|
268
268
|
*/
|
|
269
269
|
readonly waitTimeout?: Duration;
|
|
270
|
-
}
|
|
271
|
-
/** What `topics()` returns: the options it checked, which only `createGitServer` reads. */
|
|
272
|
-
export interface TopicsFactory {
|
|
273
|
-
readonly kind: 'topics';
|
|
274
|
-
readonly options: TopicsLayerOptions;
|
|
275
270
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { EffectCalls } from "./services.mjs";
|
|
2
2
|
import { GitError, Result } from "./result.mjs";
|
|
3
3
|
import { ActorInput, Caller } from "./actors.mjs";
|
|
4
|
-
import { RepoName } from "./ids.mjs";
|
|
4
|
+
import { InternalRepoId, RepoName } from "./ids.mjs";
|
|
5
5
|
import { RepoInput } from "./repos.mjs";
|
|
6
6
|
import * as Effect from "effect/Effect";
|
|
7
7
|
import * as Schema from "effect/Schema";
|
|
8
8
|
import { JobListRequest, JobRef, Listing } from "@ref0/infra";
|
|
9
9
|
import * as Context from "effect/Context";
|
|
10
10
|
declare namespace work_d_exports {
|
|
11
|
-
export { JobState, ProgressSample, Work, WorkCalls, WorkItem, WorkListInput, WorkMeasure, WorkWrite, WorkWriteInput, discard, list, retry };
|
|
11
|
+
export { JobState, ProgressSample, Work, WorkByIdInput, WorkCalls, WorkItem, WorkListInput, WorkMeasure, WorkWrite, WorkWriteInput, discard, list, listById, retry };
|
|
12
12
|
}
|
|
13
13
|
/** A job's state, as `@ref0/infra` lists them. */
|
|
14
14
|
export declare const JobState: Schema.Literals<readonly ["waiting", "running", "failed"]>;
|
|
@@ -70,9 +70,20 @@ export interface WorkListInput extends ActorInput, Omit<JobListRequest, 'name'>,
|
|
|
70
70
|
* kept, or sent again while the first still runs, calls the queue again, and answers as it does.
|
|
71
71
|
*/
|
|
72
72
|
export interface WorkWriteInput extends ActorInput, JobRef, Pick<RepoInput, 'internalId'>, WorkWrite {}
|
|
73
|
+
/** `list`'s input for a repo named by its internal ID, which needs no pin to its name. */
|
|
74
|
+
export interface WorkByIdInput extends ActorInput, Omit<JobListRequest, 'name'> {}
|
|
73
75
|
/** A repo's jobs, over infra's job calls. */
|
|
74
76
|
export interface WorkCalls {
|
|
75
77
|
readonly list: (repo: RepoName, input: WorkListInput) => Promise<Result<Listing<WorkItem>>>;
|
|
78
|
+
/**
|
|
79
|
+
* Admin-only: a repo's jobs by its internal ID, and works on a deleted record, whose purge and
|
|
80
|
+
* repacks still run after its name answers `NOT_FOUND`. The default policy, `Policy.signedIn`,
|
|
81
|
+
* refuses it to everyone, `NOT_ALLOWED`: only a host's own policy grants it, as
|
|
82
|
+
* `ref0-git init`'s does for its admin. No token scope's ceiling names it either, so a `read`,
|
|
83
|
+
* `report` or `write` token is refused `NOT_ALLOWED` whatever the policy says. An ID that names
|
|
84
|
+
* no record, or that REST's path holds and isn't an ID, answers `NOT_FOUND`.
|
|
85
|
+
*/
|
|
86
|
+
readonly listById: (internalId: InternalRepoId, input: WorkByIdInput) => Promise<Result<Listing<WorkItem>>>;
|
|
76
87
|
readonly retry: (repo: RepoName, input: WorkWriteInput) => Promise<Result<void>>;
|
|
77
88
|
readonly discard: (repo: RepoName, input: WorkWriteInput) => Promise<Result<void>>;
|
|
78
89
|
}
|
|
@@ -101,6 +112,30 @@ declare const Work_base: Context.ServiceClass<Work, "@ref0/git/Work", EffectCall
|
|
|
101
112
|
readonly at: number;
|
|
102
113
|
};
|
|
103
114
|
}>>>;
|
|
115
|
+
readonly listById: (internalId: `r_${string}`, input: WorkByIdInput, by?: Caller<unknown> | undefined) => Promise<Result<Listing<{
|
|
116
|
+
readonly scope: string;
|
|
117
|
+
readonly name: string;
|
|
118
|
+
readonly key: string;
|
|
119
|
+
readonly data: unknown;
|
|
120
|
+
readonly due: number;
|
|
121
|
+
readonly attempt: number;
|
|
122
|
+
readonly trace?: string;
|
|
123
|
+
readonly firstTry?: number;
|
|
124
|
+
readonly claim?: number;
|
|
125
|
+
readonly state: "failed" | "running" | "waiting";
|
|
126
|
+
readonly error?: string;
|
|
127
|
+
readonly failedAt?: number;
|
|
128
|
+
readonly progress?: {
|
|
129
|
+
readonly phase: string;
|
|
130
|
+
readonly measures: readonly {
|
|
131
|
+
readonly unit: "bytes" | "entries" | "objects" | "packs";
|
|
132
|
+
readonly completed: number;
|
|
133
|
+
readonly total?: number;
|
|
134
|
+
}[];
|
|
135
|
+
readonly attempt: number;
|
|
136
|
+
readonly at: number;
|
|
137
|
+
};
|
|
138
|
+
}>>>;
|
|
104
139
|
readonly retry: (repo: string, input: WorkWriteInput, by?: Caller<unknown> | undefined) => Promise<Result<void>>;
|
|
105
140
|
readonly discard: (repo: string, input: WorkWriteInput, by?: Caller<unknown> | undefined) => Promise<Result<void>>;
|
|
106
141
|
}, never>>;
|
|
@@ -133,6 +168,35 @@ export declare const list: (repo: RepoName, input: WorkListInput, by?: Caller) =
|
|
|
133
168
|
readonly at: number;
|
|
134
169
|
};
|
|
135
170
|
}>, GitError, Work>;
|
|
171
|
+
/**
|
|
172
|
+
* Admin-only, and works on a deleted record: `WorkCalls.listById`. `Policy.signedIn` refuses it to
|
|
173
|
+
* everyone, `NOT_ALLOWED`; only a host's own policy grants it, as `ref0-git init`'s does for its
|
|
174
|
+
* admin.
|
|
175
|
+
*/
|
|
176
|
+
export declare const listById: (internalId: InternalRepoId, input: WorkByIdInput, by?: Caller) => Effect.Effect<Listing<{
|
|
177
|
+
readonly scope: string;
|
|
178
|
+
readonly name: string;
|
|
179
|
+
readonly key: string;
|
|
180
|
+
readonly data: unknown;
|
|
181
|
+
readonly due: number;
|
|
182
|
+
readonly attempt: number;
|
|
183
|
+
readonly trace?: string;
|
|
184
|
+
readonly firstTry?: number;
|
|
185
|
+
readonly claim?: number;
|
|
186
|
+
readonly state: "failed" | "running" | "waiting";
|
|
187
|
+
readonly error?: string;
|
|
188
|
+
readonly failedAt?: number;
|
|
189
|
+
readonly progress?: {
|
|
190
|
+
readonly phase: string;
|
|
191
|
+
readonly measures: readonly {
|
|
192
|
+
readonly unit: "bytes" | "entries" | "objects" | "packs";
|
|
193
|
+
readonly completed: number;
|
|
194
|
+
readonly total?: number;
|
|
195
|
+
}[];
|
|
196
|
+
readonly attempt: number;
|
|
197
|
+
readonly at: number;
|
|
198
|
+
};
|
|
199
|
+
}>, GitError, Work>;
|
|
136
200
|
export declare const retry: (repo: RepoName, input: WorkWriteInput, by?: Caller) => Effect.Effect<void, GitError, Work>;
|
|
137
201
|
export declare const discard: (repo: RepoName, input: WorkWriteInput, by?: Caller) => Effect.Effect<void, GitError, Work>;
|
|
138
202
|
export { work_d_exports };
|
package/dist/contracts/work.mjs
CHANGED
|
@@ -14,6 +14,7 @@ var work_exports = /* @__PURE__ */ __exportAll({
|
|
|
14
14
|
WorkWrite: () => WorkWrite,
|
|
15
15
|
discard: () => discard,
|
|
16
16
|
list: () => list,
|
|
17
|
+
listById: () => listById,
|
|
17
18
|
retry: () => retry
|
|
18
19
|
});
|
|
19
20
|
/** A job's state, as `@ref0/infra` lists them. */
|
|
@@ -64,6 +65,12 @@ const WorkWrite = /* @__PURE__ */ Schema.Struct({
|
|
|
64
65
|
*/
|
|
65
66
|
var Work = class extends (/* @__PURE__ */ Context.Service()("@ref0/git/Work")) {};
|
|
66
67
|
const list = (repo, input, by) => Effect.flatMap(Effect.service(Work), (calls) => calls.list(repo, input, by));
|
|
68
|
+
/**
|
|
69
|
+
* Admin-only, and works on a deleted record: `WorkCalls.listById`. `Policy.signedIn` refuses it to
|
|
70
|
+
* everyone, `NOT_ALLOWED`; only a host's own policy grants it, as `ref0-git init`'s does for its
|
|
71
|
+
* admin.
|
|
72
|
+
*/
|
|
73
|
+
const listById = (internalId, input, by) => Effect.flatMap(Effect.service(Work), (calls) => calls.listById(internalId, input, by));
|
|
67
74
|
const retry = (repo, input, by) => Effect.flatMap(Effect.service(Work), (calls) => calls.retry(repo, input, by));
|
|
68
75
|
const discard = (repo, input, by) => Effect.flatMap(Effect.service(Work), (calls) => calls.discard(repo, input, by));
|
|
69
|
-
export { JobState, ProgressSample, Work, WorkItem, WorkMeasure, WorkWrite, discard, list, retry, work_exports };
|
|
76
|
+
export { JobState, ProgressSample, Work, WorkItem, WorkMeasure, WorkWrite, discard, list, listById, retry, work_exports };
|
package/dist/core/access.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isHost } from "../contracts/git.mjs";
|
|
2
|
+
import { fail, gitError, isGitError } from "../contracts/result.mjs";
|
|
2
3
|
import { check } from "../contracts/authorize.mjs";
|
|
3
|
-
import { asAsked } from "./asked.mjs";
|
|
4
|
+
import { asAsked, askedBy, takeMove } from "./asked.mjs";
|
|
4
5
|
import { entryOf, nameOf, namedRecordOf, redirectOf, resolveRepo } from "../store/catalogue.mjs";
|
|
5
6
|
import { afterWrites, isLimitRefusal } from "../store/errors.mjs";
|
|
6
7
|
import { readRecord } from "../store/repo-record.mjs";
|
|
@@ -8,7 +9,7 @@ import { collections } from "../store/scopes.mjs";
|
|
|
8
9
|
import { readyKey } from "../storage/ready.mjs";
|
|
9
10
|
import { liveReceipt, matchedReceipt, receiptReads } from "./receipts.mjs";
|
|
10
11
|
import { rebuildDue } from "./ref-index.mjs";
|
|
11
|
-
import { CoreParts } from "./parts.mjs";
|
|
12
|
+
import { CoreParts, asHost } from "./parts.mjs";
|
|
12
13
|
import * as Effect from "effect/Effect";
|
|
13
14
|
// src/core/access.ts
|
|
14
15
|
/**
|
|
@@ -139,7 +140,9 @@ const authorized = /* @__PURE__ */ Effect.fnUntraced(function* (caller, operatio
|
|
|
139
140
|
operation,
|
|
140
141
|
repo: repoAccess(resolved)
|
|
141
142
|
});
|
|
142
|
-
if (confirm
|
|
143
|
+
if (confirm === "skip") return resolved;
|
|
144
|
+
askedBy(resolved, caller);
|
|
145
|
+
if (confirm === "first-read") return resolved;
|
|
143
146
|
yield* confirmed(resolved);
|
|
144
147
|
return resolved;
|
|
145
148
|
});
|
|
@@ -182,6 +185,25 @@ const readableRedirect = (caller, to) => openRepo(caller, {
|
|
|
182
185
|
repo: to
|
|
183
186
|
}).pipe(Effect.as(to), Effect.catch((error) => error.code === "UNAVAILABLE" ? Effect.fail(error) : Effect.succeed(void 0)));
|
|
184
187
|
/**
|
|
188
|
+
* `effect`, whose confirm's refusal of a repo renamed while `authorize` decided answers as a call
|
|
189
|
+
* after the rename would: `NOT_FOUND` with `renamedTo`, to a caller `readableRedirect` tells, and
|
|
190
|
+
* nothing more to anyone else. Nothing runs again (#2184). One redirect per refusal: the boundary
|
|
191
|
+
* that takes the move answers it, so one around it, refused or not, asks no second time, and the
|
|
192
|
+
* redirect's own open, whose confirm may refuse a second move, answers its caller nothing, never
|
|
193
|
+
* another redirect, as `readableRedirect` catches it. Any other failure is as it came.
|
|
194
|
+
*/
|
|
195
|
+
const answerMoved = (effect) => Effect.catch(effect, (error) => {
|
|
196
|
+
if (!isGitError(error)) return Effect.fail(error);
|
|
197
|
+
const moved = takeMove(error);
|
|
198
|
+
if (moved === void 0) return Effect.fail(error);
|
|
199
|
+
return Effect.flatMap(readableRedirect(moved.caller, moved.to), (to) => Effect.fail(to === void 0 ? error : gitError("NOT_FOUND", error.message, { context: { renamedTo: to } })));
|
|
200
|
+
});
|
|
201
|
+
/**
|
|
202
|
+
* `effect` as `by` makes it: host code's, as `asHost` says, when `by` is `Git.host`. A repo it
|
|
203
|
+
* opened that moved while `authorize` decided is answered as `answerMoved` says.
|
|
204
|
+
*/
|
|
205
|
+
const acting = (by, effect) => isHost(by) ? asHost(answerMoved(effect)) : answerMoved(effect);
|
|
206
|
+
/**
|
|
185
207
|
* A missing name's `NOT_FOUND`, naming where it went only to a caller `readableRedirect` tells: the
|
|
186
208
|
* repo `internalId` names, by its name now, when the call named one, as a rename took it away.
|
|
187
209
|
*/
|
|
@@ -277,4 +299,4 @@ const contended = () => fail("UNAVAILABLE", "Too many writes reached this repo a
|
|
|
277
299
|
* it back before it sends the same call again (#1462).
|
|
278
300
|
*/
|
|
279
301
|
const contendedAfterWrites = () => Effect.fail(afterWrites(gitError("UNAVAILABLE", "Too many writes reached this repo at once")));
|
|
280
|
-
export { alreadyExists, callerFor, confirmed, contended, contendedAfterWrites, headOf, hiddenCodes, indexDeleteJobs, indexJobs, keyedRecord, liveAsAsked, nameMoved, openFor, openKeyed, openRepo, purgeJobs, readableRedirect, refIndexJobs, repoAccess, resolvedAs, sizedRead, statsReads, unlessHidden };
|
|
302
|
+
export { acting, alreadyExists, callerFor, confirmed, contended, contendedAfterWrites, headOf, hiddenCodes, indexDeleteJobs, indexJobs, keyedRecord, liveAsAsked, nameMoved, openFor, openKeyed, openRepo, purgeJobs, readableRedirect, refIndexJobs, repoAccess, resolvedAs, sizedRead, statsReads, unlessHidden };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import "../contracts/ids.mjs";
|
|
2
|
+
import "../contracts/objects.mjs";
|
|
3
|
+
import "../contracts/refs.mjs";
|
|
4
|
+
import "../contracts/result.mjs";
|
|
5
|
+
import "../contracts/store.mjs";
|
|
6
|
+
import "../storage/calls.mjs";
|
|
7
|
+
import "../protocol/objects/commit.mjs";
|
|
8
|
+
import "../store/call-count.mjs";
|
|
9
|
+
import "effect/Effect";
|
package/dist/core/ancestry.mjs
CHANGED
|
@@ -71,15 +71,15 @@ const callsPast = (spent, ref) => {
|
|
|
71
71
|
});
|
|
72
72
|
};
|
|
73
73
|
/**
|
|
74
|
-
*
|
|
75
|
-
* as a budget each of
|
|
76
|
-
* for a request with no bound, as on Node.
|
|
74
|
+
* A walk's share of the request's calls, `fraction` of what it has left of each kind,
|
|
75
|
+
* `ancestryCallsShare` for the history walks, as a budget each of its stored reads is handed,
|
|
76
|
+
* nested in the budget in scope; or `undefined` for a request with no bound, as on Node.
|
|
77
77
|
*/
|
|
78
|
-
const walkBudgetOf = /* @__PURE__ */ Effect.fnUntraced(function* (request) {
|
|
78
|
+
const walkBudgetOf = /* @__PURE__ */ Effect.fnUntraced(function* (request, fraction = ancestryCallsShare) {
|
|
79
79
|
const most = request?.most;
|
|
80
80
|
if (request === void 0 || most === void 0) return void 0;
|
|
81
81
|
const made = request.made();
|
|
82
|
-
const share = (bound, spent) => Math.floor(Math.max(0, bound - spent) *
|
|
82
|
+
const share = (bound, spent) => Math.floor(Math.max(0, bound - spent) * fraction);
|
|
83
83
|
return yield* CallBudget.make({
|
|
84
84
|
bucket: share(most.bucket, made.bucket),
|
|
85
85
|
subrequests: share(most.subrequests, made.subrequests)
|
|
@@ -301,4 +301,4 @@ const kindsOf = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
|
301
301
|
exact: exactOf(seen, limit)
|
|
302
302
|
};
|
|
303
303
|
});
|
|
304
|
-
export { ancestryBytes, ancestryCallsShare, ancestryLimit, kindsOf };
|
|
304
|
+
export { ancestryBytes, ancestryCallsShare, ancestryLimit, kindsOf, walkBudgetOf };
|
package/dist/core/asked.mjs
CHANGED
|
@@ -1,18 +1,56 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { gitError } from "../contracts/result.mjs";
|
|
2
2
|
import { storeCall } from "../store/errors.mjs";
|
|
3
3
|
import { readRecord } from "../store/repo-record.mjs";
|
|
4
4
|
import { repoScope } from "../store/scopes.mjs";
|
|
5
5
|
import * as Effect from "effect/Effect";
|
|
6
6
|
// src/core/asked.ts
|
|
7
|
+
/** The caller each open asked `authorize` for, by the repo it opened, as `askedBy` keeps it. */
|
|
8
|
+
const callers = /* @__PURE__ */ new WeakMap();
|
|
9
|
+
/** The repo each confirm's refusal held, where it went, as `asAsked` keeps it. */
|
|
10
|
+
const moves = /* @__PURE__ */ new WeakMap();
|
|
11
|
+
/**
|
|
12
|
+
* Keeps `caller` as the one `authorize` was asked for of `repo`, the open's own answer, so a
|
|
13
|
+
* confirm's refusal on it knows whom to tell where the repo went, as `takeMove` says. Keyed by the
|
|
14
|
+
* object, it leaves nothing for another call or another open: `repo` is the one `resolveRepo` built
|
|
15
|
+
* for this open alone, never cached, memoized or handed to another call, so two calls opening one
|
|
16
|
+
* repo at once keep two callers.
|
|
17
|
+
*/
|
|
18
|
+
const askedBy = (repo, caller) => {
|
|
19
|
+
callers.set(repo, caller);
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Where the repo whose confirm refused `error` went, and whom to tell: only for the very refusal
|
|
23
|
+
* `asAsked` failed with, so any other `NOT_FOUND`, a name with no repo or one a call made of its
|
|
24
|
+
* own, has none. It's taken once: the first to take it answers the move, and `error` keeps
|
|
25
|
+
* nothing, so a call boundary around another, as `refs.get`'s around `View.open`'s, asks of the
|
|
26
|
+
* new name no second time.
|
|
27
|
+
*/
|
|
28
|
+
const takeMove = (error) => {
|
|
29
|
+
const move = moves.get(error);
|
|
30
|
+
moves.delete(error);
|
|
31
|
+
return move;
|
|
32
|
+
};
|
|
7
33
|
/**
|
|
8
34
|
* Succeeds when `record`, read after `authorize` answered, still holds what `repo` was asked of:
|
|
9
35
|
* live, with the name and the visibility the record read before held, as git-services' core
|
|
10
36
|
* confirm says. A host's `authorize` may take long enough for a rename, a delete or a visibility
|
|
11
37
|
* change to land, so nothing is answered from a record the repo no longer has. It compares records,
|
|
12
38
|
* never the catalogue's name, which a rename's entry gives a moment after its record. One that
|
|
13
|
-
* moved is `NOT_FOUND` for the name, as
|
|
39
|
+
* moved is `NOT_FOUND` for the name, as a call after the move would find it. A rename, live with
|
|
40
|
+
* the visibility asked of, keeps where it went for `answerMoved`, which the call answers with,
|
|
41
|
+
* told only to a caller who may read it there. A delete or a visibility change keeps nothing.
|
|
14
42
|
*/
|
|
15
|
-
const asAsked = (repo, record) =>
|
|
43
|
+
const asAsked = (repo, record) => {
|
|
44
|
+
const live = record !== void 0 && record.deleted !== true;
|
|
45
|
+
if (live && record.public === repo.record.public && record.name === repo.record.name) return Effect.void;
|
|
46
|
+
const refusal = gitError("NOT_FOUND", `No repo '${repo.name}'`);
|
|
47
|
+
const caller = callers.get(repo);
|
|
48
|
+
if (live && record.public === repo.record.public && caller !== void 0) moves.set(refusal, {
|
|
49
|
+
caller,
|
|
50
|
+
to: record.name
|
|
51
|
+
});
|
|
52
|
+
return Effect.fail(refusal);
|
|
53
|
+
};
|
|
16
54
|
/**
|
|
17
55
|
* `reads` and `counts` of `internalId`'s scope at one version. With `asked`, its `self` is read in
|
|
18
56
|
* the same call and held to it, as `asAsked` says: the open that skipped its own confirm for
|
|
@@ -27,4 +65,4 @@ const readAsked = /* @__PURE__ */ Effect.fnUntraced(function* (store, internalId
|
|
|
27
65
|
results: snapshot.results.slice(1)
|
|
28
66
|
};
|
|
29
67
|
});
|
|
30
|
-
export { asAsked, readAsked };
|
|
68
|
+
export { asAsked, askedBy, readAsked, takeMove };
|
package/dist/core/call-names.mjs
CHANGED
|
@@ -12,7 +12,7 @@ import { commitCalls } from "./objects/commits.mjs";
|
|
|
12
12
|
import { fileCalls } from "./objects/files.mjs";
|
|
13
13
|
import { tagCalls } from "./objects/tags.mjs";
|
|
14
14
|
import { treeCalls } from "./objects/trees.mjs";
|
|
15
|
-
import { acting } from "./
|
|
15
|
+
import { acting } from "./access.mjs";
|
|
16
16
|
import { providedCalls } from "./promise.mjs";
|
|
17
17
|
import { repoCalls } from "./repos.mjs";
|
|
18
18
|
import { workCalls } from "./work.mjs";
|
|
@@ -35,6 +35,7 @@ const forks = {
|
|
|
35
35
|
};
|
|
36
36
|
const work = {
|
|
37
37
|
list: (repo, input, by) => acting(by, workCalls(by).list(repo, input)),
|
|
38
|
+
listById: (internalId, input, by) => acting(by, workCalls(by).listById(internalId, input)),
|
|
38
39
|
retry: (repo, input, by) => acting(by, workCalls(by).retry(repo, input)),
|
|
39
40
|
discard: (repo, input, by) => acting(by, workCalls(by).discard(repo, input))
|
|
40
41
|
};
|