@ref0/git 0.11.0 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/access/private-refs.mjs +8 -7
- package/dist/auth/auth.d.mts +2 -2
- package/dist/auth/auth.mjs +3 -6
- package/dist/auth/authorize.mjs +1 -17
- package/dist/auth/helpers.mjs +3 -11
- package/dist/auth/host-services.mjs +11 -0
- package/dist/auth/policy.d.mts +27 -7
- package/dist/auth/policy.mjs +8 -4
- package/dist/auth/tokens-layer.d.mts +1 -2
- package/dist/auth/tokens-layer.mjs +2 -3
- package/dist/auth/tokens-public.d.mts +3 -3
- package/dist/auth/tokens.d.mts +1 -8
- package/dist/auth/tokens.mjs +1 -8
- package/dist/auth.d.mts +1 -4
- package/dist/auth.mjs +1 -3
- package/dist/client/git-http.mjs +18 -4
- package/dist/client/push-upload.mjs +33 -7
- package/dist/client/remote.mjs +94 -28
- package/dist/client/slice-push.d.mts +1 -1
- package/dist/contracts/access.d.mts +8 -8
- package/dist/contracts/actors.d.mts +2 -34
- package/dist/contracts/blobs.d.mts +2 -2
- package/dist/contracts/client.d.mts +8 -3
- package/dist/contracts/commits.d.mts +10 -2
- package/dist/contracts/commits.mjs +9 -1
- package/dist/contracts/files.d.mts +2 -2
- package/dist/contracts/forks.d.mts +14 -3
- package/dist/contracts/git.d.mts +41 -12
- package/dist/contracts/git.mjs +3 -2
- package/dist/contracts/lfs.d.mts +0 -7
- package/dist/contracts/objects.d.mts +80 -10
- package/dist/contracts/operations.d.mts +3 -0
- package/dist/contracts/operations.mjs +12 -2
- package/dist/contracts/push-uploads.d.mts +44 -5
- package/dist/contracts/push-uploads.mjs +7 -3
- package/dist/contracts/refs.d.mts +28 -6
- package/dist/contracts/remote.mjs +1 -3
- package/dist/contracts/repo-records.d.mts +1 -0
- package/dist/contracts/repos.d.mts +90 -2
- package/dist/contracts/repos.mjs +29 -2
- package/dist/contracts/result.d.mts +30 -23
- package/dist/contracts/result.mjs +24 -9
- package/dist/contracts/rules.d.mts +22 -22
- package/dist/contracts/server.d.mts +28 -77
- package/dist/contracts/signin.d.mts +1 -1
- package/dist/contracts/sync.d.mts +90 -19
- package/dist/contracts/sync.mjs +34 -10
- package/dist/contracts/tokens.d.mts +1 -6
- package/dist/contracts/tokens.mjs +1 -2
- package/dist/contracts/topics.d.mts +0 -5
- package/dist/contracts/work.d.mts +66 -2
- package/dist/contracts/work.mjs +8 -1
- package/dist/core/access.d.mts +1 -0
- package/dist/core/access.mjs +34 -13
- package/dist/core/ancestry.d.mts +9 -0
- package/dist/core/ancestry.mjs +6 -6
- package/dist/core/asked.mjs +68 -0
- package/dist/core/call-names.mjs +1 -0
- package/dist/core/call-services.mjs +2 -1
- package/dist/core/events/deliver.d.mts +1 -0
- package/dist/core/events/deliver.mjs +15 -3
- package/dist/core/forks.mjs +42 -16
- package/dist/core/imports.mjs +156 -13
- package/dist/core/index-job.mjs +9 -6
- package/dist/core/job-view.mjs +8 -9
- package/dist/core/mirror-rows.mjs +19 -4
- package/dist/core/objects/commits.mjs +16 -6
- package/dist/core/objects/reading.mjs +17 -9
- package/dist/core/parts.d.mts +8 -2
- package/dist/core/parts.mjs +1 -4
- package/dist/core/purge.mjs +76 -6
- package/dist/core/push-decide.mjs +1 -1
- package/dist/core/push-files.d.mts +12 -0
- package/dist/core/push-files.mjs +225 -0
- package/dist/core/push-repo.d.mts +8 -0
- package/dist/core/push-repo.mjs +56 -0
- package/dist/core/push.d.mts +17 -0
- package/dist/core/push.mjs +107 -32
- package/dist/core/receipts.mjs +26 -10
- package/dist/core/ref-view.mjs +59 -5
- package/dist/core/refs.mjs +18 -10
- package/dist/core/registered-rows.mjs +7 -5
- package/dist/core/repack.mjs +16 -11
- package/dist/core/repo-info.mjs +16 -9
- package/dist/core/repos.mjs +30 -14
- package/dist/core/saved-caller-views.d.mts +18 -0
- package/dist/core/saved-caller-views.mjs +17 -4
- package/dist/core/saved-callers-public.d.mts +3 -3
- package/dist/core/saved-callers-public.mjs +3 -2
- package/dist/core/saved-callers.d.mts +7 -0
- package/dist/core/seam.mjs +2 -2
- package/dist/core/view.d.mts +6 -0
- package/dist/core/view.mjs +45 -12
- package/dist/core/work.mjs +47 -22
- package/dist/effect.d.mts +3 -1
- package/dist/effect.mjs +3 -1
- package/dist/engine/reads.mjs +13 -6
- package/dist/engine/walk.mjs +4 -4
- package/dist/event-streams/event-streams.d.mts +1 -1
- package/dist/event-streams/event-streams.mjs +1 -1
- package/dist/event-streams/stream.d.mts +1 -1
- package/dist/event-streams/stream.mjs +1 -1
- package/dist/extend.d.mts +4 -3
- package/dist/extend.mjs +3 -2
- package/dist/http/answers.mjs +4 -2
- package/dist/http/core-parts.mjs +64 -15
- package/dist/http/handler.mjs +2 -2
- package/dist/http/node.mjs +5 -4
- package/dist/http/parts.d.mts +1 -0
- package/dist/http/push-upload-job.mjs +503 -0
- package/dist/http/push-uploads.d.mts +1 -0
- package/dist/http/push-uploads.mjs +120 -59
- package/dist/http/upload-pack.mjs +7 -6
- package/dist/index.d.mts +23 -24
- package/dist/index.mjs +4 -7
- package/dist/lfs/base.d.mts +7 -3
- package/dist/lfs/base.mjs +2 -1
- package/dist/lfs/copy.d.mts +46 -0
- package/dist/lfs/copy.mjs +26 -0
- package/dist/lfs/layer.mjs +4 -2
- package/dist/lfs/locks.mjs +14 -9
- package/dist/lfs/objects.d.mts +6 -0
- package/dist/lfs/objects.mjs +95 -61
- package/dist/lfs/rows.d.mts +13 -0
- package/dist/lfs/service.d.mts +1 -7
- package/dist/lfs/service.mjs +1 -9
- package/dist/lfs/upload-most.mjs +5 -5
- package/dist/node.d.mts +2 -2
- package/dist/protocol/bytes/sha256-hasher.d.mts +15 -0
- package/dist/protocol/bytes/sha256.d.mts +32 -0
- package/dist/protocol/bytes/sha256.mjs +105 -49
- package/dist/protocol/wire/advertisement.mjs +9 -4
- package/dist/protocol/wire/lines.d.mts +4 -2
- package/dist/protocol/wire/lines.mjs +11 -5
- package/dist/protocol/wire/push-uploads.mjs +13 -1
- package/dist/protocol/wire/v2.mjs +2 -2
- package/dist/protocol.d.mts +3 -1
- package/dist/protocol.mjs +3 -1
- package/dist/queue/advance.mjs +1 -1
- package/dist/queue/calls.mjs +21 -1
- package/dist/queue/host.d.mts +1 -7
- package/dist/queue/host.mjs +1 -7
- package/dist/queue/layer.mjs +1 -1
- package/dist/queue/trim.mjs +1 -1
- package/dist/rest/blobs.d.mts +16 -8
- package/dist/rest/blobs.mjs +1 -1
- package/dist/rest/caller.d.mts +49 -9
- package/dist/rest/caller.mjs +1 -1
- package/dist/rest/client.d.mts +10 -3
- package/dist/rest/client.mjs +4 -0
- package/dist/rest/commits.d.mts +272 -239
- package/dist/rest/errors.d.mts +24 -4
- package/dist/rest/events.d.mts +9 -6
- package/dist/rest/events.mjs +1 -2
- package/dist/rest/files.d.mts +112 -100
- package/dist/rest/forks.d.mts +146 -122
- package/dist/rest/handler.mjs +4 -57
- package/dist/rest/handlers.d.mts +1 -1
- package/dist/rest/handlers.mjs +18 -4
- package/dist/rest/layer.mjs +10 -2
- package/dist/rest/me.d.mts +8 -4
- package/dist/rest/merges.d.mts +8 -4
- package/dist/rest/paths.mjs +1 -0
- package/dist/rest/queue.d.mts +292 -236
- package/dist/rest/refs.d.mts +98 -69
- package/dist/rest/repos.d.mts +133 -105
- package/dist/rest/tags.d.mts +100 -88
- package/dist/rest/tokens.d.mts +192 -168
- package/dist/rest/topics.d.mts +154 -134
- package/dist/rest/trees.d.mts +32 -16
- package/dist/rest/work.d.mts +467 -20
- package/dist/rest/work.mjs +8 -0
- package/dist/server/edge-node.d.mts +9 -13
- package/dist/server/edge-node.mjs +9 -12
- package/dist/server/git-layer.d.mts +1 -6
- package/dist/server/git-layer.mjs +2 -2
- package/dist/server/git-namespace.d.mts +4 -4
- package/dist/server/joined.d.mts +15 -22
- package/dist/server/joined.mjs +5 -29
- package/dist/server/lifecycle.mjs +107 -23
- package/dist/server/registry.mjs +9 -1
- package/dist/server/server.mjs +139 -216
- package/dist/storage/budget.mjs +2 -2
- package/dist/storage/clean-up.mjs +13 -10
- package/dist/storage/fetch.mjs +13 -8
- package/dist/storage/file-limits.mjs +24 -0
- package/dist/storage/index-build.d.mts +1 -0
- package/dist/storage/index-build.mjs +106 -62
- package/dist/storage/index-fetch.mjs +16 -3
- package/dist/storage/index-reach.mjs +33 -5
- package/dist/storage/index-remap.mjs +8 -1
- package/dist/storage/index-shallow.mjs +5 -3
- package/dist/storage/largest-files.mjs +48 -0
- package/dist/storage/lfs-pointers.mjs +10 -1
- package/dist/storage/loose.mjs +3 -1
- package/dist/storage/memory-budget.mjs +154 -8
- package/dist/storage/merge-cut.mjs +5 -4
- package/dist/storage/pack-reads.mjs +246 -34
- package/dist/storage/pack-receive.mjs +83 -25
- package/dist/storage/packs.mjs +37 -21
- package/dist/storage/prune-keep.mjs +203 -34
- package/dist/storage/prune-seen.mjs +11 -6
- package/dist/storage/prune-walk.mjs +219 -81
- package/dist/storage/prune.mjs +629 -196
- package/dist/storage/push-uploads.mjs +36 -12
- package/dist/storage/quarantine.mjs +9 -7
- package/dist/storage/ready.mjs +47 -19
- package/dist/storage/receive-bounds.mjs +29 -8
- package/dist/storage/receive-state.mjs +8 -0
- package/dist/storage/receive-steps.mjs +71 -18
- package/dist/storage/repack.d.mts +1 -1
- package/dist/storage/repack.mjs +1 -8
- package/dist/storage/rows.mjs +12 -1
- package/dist/storage/shallow.d.mts +1 -0
- package/dist/storage/shallow.mjs +26 -4
- package/dist/storage/stream-whole.mjs +5 -2
- package/dist/storage/visible.mjs +29 -1
- package/dist/storage/walk.mjs +2 -1
- package/dist/store/catalogue.mjs +1 -0
- package/dist/store/cursor-seal-namespace.d.mts +2 -0
- package/dist/store/cursor-seal-public.d.mts +5 -0
- package/dist/store/cursor-seal-public.mjs +5 -0
- package/dist/store/cursor-seal.d.mts +16 -2
- package/dist/store/cursor-seal.mjs +26 -14
- package/dist/store/errors.mjs +9 -1
- package/dist/store/records.d.mts +2 -0
- package/dist/store/records.mjs +9 -6
- package/dist/store/repo-record.d.mts +27 -0
- package/dist/store/repo-record.mjs +141 -4
- package/dist/store/scopes.mjs +10 -2
- package/dist/sync/bound.d.mts +2 -0
- package/dist/sync/bound.mjs +11 -2
- package/dist/sync/github.d.mts +6 -1
- package/dist/sync/github.mjs +63 -42
- package/dist/sync/http.mjs +36 -1
- package/dist/sync/import.mjs +4 -2
- package/dist/sync/layer.mjs +6 -2
- package/dist/sync/lfs-batch.mjs +119 -0
- package/dist/sync/lfs-copy.mjs +251 -0
- package/dist/sync/mirror.mjs +227 -147
- package/dist/sync/said.mjs +204 -0
- package/dist/sync/smart-http.mjs +4 -2
- package/dist/sync/step.mjs +33 -13
- package/dist/sync/tries.mjs +71 -24
- package/dist/sync.d.mts +2 -2
- package/dist/topics/advance.mjs +10 -3
- package/dist/topics/host.mjs +1 -19
- package/dist/topics/layer.mjs +1 -1
- package/package.json +3 -8
- package/dist/auth/bridge.mjs +0 -30
- package/dist/auth/helpers.d.mts +0 -17
- package/dist/core/purge.d.mts +0 -8
- package/dist/core/registered-rows.d.mts +0 -4
- package/dist/core/repack.d.mts +0 -11
- package/dist/http/handler.d.mts +0 -2
- package/dist/rest/handler.d.mts +0 -21
- package/dist/rest.d.mts +0 -2
- package/dist/rest.mjs +0 -1
- package/dist/server/registry.d.mts +0 -16
- package/dist/server/server.d.mts +0 -36
- package/dist/storage/repack-job.d.mts +0 -3
- package/dist/topics/host.d.mts +0 -7
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { cutWords, utf8 } from "../protocol/bytes/text.mjs";
|
|
2
|
+
import * as Option from "effect/Option";
|
|
3
|
+
import * as Schema from "effect/Schema";
|
|
4
|
+
import * as Result from "effect/Result";
|
|
5
|
+
import * as Base64 from "effect/encoding/Base64";
|
|
6
|
+
import * as Base64Url from "effect/encoding/Base64Url";
|
|
7
|
+
// src/sync/said.ts
|
|
8
|
+
/**
|
|
9
|
+
* What a remote said that its provider marks safe to keep: the named top-level string fields of a
|
|
10
|
+
* refusal's JSON body, such as GitHub's `message`, and nothing else of it. The text is made one
|
|
11
|
+
* line, every credential-shaped string in it redacted, then cut to `saidMost`, so a cut never
|
|
12
|
+
* leaves part of a token no pattern still matches. A remote's or a gateway's words may echo the
|
|
13
|
+
* request's credential, which is why the rest stays dropped.
|
|
14
|
+
*/
|
|
15
|
+
/** The most of a refusal's body read for its fields: a longer body is cancelled there, unread. */
|
|
16
|
+
const saidBytesMost = 4096;
|
|
17
|
+
const marker = "[redacted]";
|
|
18
|
+
/** A username shorter than this is redacted only inside its credential, not alone, as `x-` isn't. */
|
|
19
|
+
const nameAloneLeast = 8;
|
|
20
|
+
/**
|
|
21
|
+
* Strings shaped as credentials, whoever's they are: GitHub's token prefixes, Git's own `gt_`
|
|
22
|
+
* tokens, an authorization scheme and its value, a JWT, a URL's userinfo, and any run of 32 or more
|
|
23
|
+
* base64, base64url or hex characters. That last one takes a commit's 40-hex ID too, on purpose:
|
|
24
|
+
* GitHub's older tokens are 40 hex characters, and look the same.
|
|
25
|
+
*/
|
|
26
|
+
const credentialPatterns = [
|
|
27
|
+
[/\b(?:gh[pousr]_|github_pat_)[A-Za-z0-9_]+/g, marker],
|
|
28
|
+
[/\bgt_[\w.~-]+/g, marker],
|
|
29
|
+
[/\b(Bearer|Basic)\s+[^\s"',;]+/gi, `$1 ${marker}`],
|
|
30
|
+
[/\b(token)\s+[\w.~+/=-]{16,}/gi, `$1 ${marker}`],
|
|
31
|
+
[/\beyJ[\w-]*\.[\w-]*\.[\w-]*/g, marker],
|
|
32
|
+
[/\b([a-z][a-z0-9+.-]*:\/\/)[^\s/@]*@/gi, `$1${marker}@`],
|
|
33
|
+
[/[A-Za-z0-9+/_=-]{32,}/g, marker]
|
|
34
|
+
];
|
|
35
|
+
/** `text` as one line: each run of whitespace and control characters one space. */
|
|
36
|
+
const oneLine = (text) => text.replace(/[\s\p{Cc}]+/gu, " ");
|
|
37
|
+
/** `text` as base64 and base64url, padded and not, as a remote may encode a credential's part. */
|
|
38
|
+
const base64Forms = (text) => {
|
|
39
|
+
const bytes = utf8(text);
|
|
40
|
+
const padded = Base64.encode(bytes);
|
|
41
|
+
return [
|
|
42
|
+
padded,
|
|
43
|
+
padded.replace(/=+$/, ""),
|
|
44
|
+
Base64Url.encode(bytes)
|
|
45
|
+
];
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* `secret` as a remote may echo it: as it is, escaped as JSON, as one line, as a kept text is
|
|
49
|
+
* made, and in base64. Its percent-encodings, in any spelling, are `spelledAs`'s.
|
|
50
|
+
*/
|
|
51
|
+
const formsOf = (secret) => [
|
|
52
|
+
secret,
|
|
53
|
+
JSON.stringify(secret).slice(1, -1),
|
|
54
|
+
oneLine(secret),
|
|
55
|
+
...base64Forms(secret)
|
|
56
|
+
];
|
|
57
|
+
/** The parts of a Basic credential, `user:pass`, from its base64: none when it isn't one. */
|
|
58
|
+
const basicParts = (encoded) => {
|
|
59
|
+
const decoded = Base64.decodeString(encoded);
|
|
60
|
+
if (Result.isFailure(decoded)) return [];
|
|
61
|
+
const pair = decoded.success;
|
|
62
|
+
const colon = pair.indexOf(":");
|
|
63
|
+
if (colon < 0) return [pair];
|
|
64
|
+
const name = pair.slice(0, colon);
|
|
65
|
+
return [
|
|
66
|
+
pair,
|
|
67
|
+
pair.slice(colon + 1),
|
|
68
|
+
...name.length >= nameAloneLeast ? [name] : []
|
|
69
|
+
];
|
|
70
|
+
};
|
|
71
|
+
/** `text` percent-decoded, or as it is when it isn't valid percent-encoding. */
|
|
72
|
+
const decoded = (text) => {
|
|
73
|
+
try {
|
|
74
|
+
return decodeURIComponent(text);
|
|
75
|
+
} catch {
|
|
76
|
+
return text;
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Every form the credential `request` carries may take in a remote's words: its `authorization`
|
|
81
|
+
* header whole, the value after its scheme, a Basic value's `user:pass`, its password and a
|
|
82
|
+
* username of `nameAloneLeast` or more, and the userinfo of its URL, each in `formsOf`'s forms.
|
|
83
|
+
* Longest first, so a whole header goes before its parts.
|
|
84
|
+
*/
|
|
85
|
+
const requestSecrets = (request) => {
|
|
86
|
+
const parts = [];
|
|
87
|
+
const header = request.headers.get("authorization");
|
|
88
|
+
if (header !== null) {
|
|
89
|
+
const [scheme = "", value = ""] = header.trim().split(/\s+/, 2);
|
|
90
|
+
parts.push(header, value);
|
|
91
|
+
if (scheme.toLowerCase() === "basic") parts.push(...basicParts(value));
|
|
92
|
+
}
|
|
93
|
+
const url = URL.parse(request.url);
|
|
94
|
+
if (url !== null) {
|
|
95
|
+
parts.push(decoded(url.password), url.password);
|
|
96
|
+
if (url.username.length >= nameAloneLeast) parts.push(decoded(url.username));
|
|
97
|
+
}
|
|
98
|
+
const forms = parts.filter((part) => part !== "").flatMap(formsOf);
|
|
99
|
+
return [...new Set(forms)].toSorted((a, b) => b.length - a.length);
|
|
100
|
+
};
|
|
101
|
+
/** A hex digit in either case. */
|
|
102
|
+
const hexEither = (digit) => /[a-f]/i.test(digit) ? `[${digit.toLowerCase()}${digit.toUpperCase()}]` : digit;
|
|
103
|
+
/**
|
|
104
|
+
* A pattern of `secret` in any spelling a URL's percent-encoding gives it: each character as it
|
|
105
|
+
* is, or as its UTF-8 bytes percent-encoded in either case of hex, a space as `+` too.
|
|
106
|
+
*/
|
|
107
|
+
const spelledAs = (secret) => {
|
|
108
|
+
const characters = Array.from(secret).map((character) => {
|
|
109
|
+
const literal = character.replace(/[.*+?^${}()|[\]\\/-]/g, "\\$&");
|
|
110
|
+
const bytes = [...utf8(character)].map((byte) => `%${byte.toString(16).padStart(2, "0").split("").map(hexEither).join("")}`);
|
|
111
|
+
const space = character === " " ? ["\\+"] : [];
|
|
112
|
+
return `(?:${[
|
|
113
|
+
literal,
|
|
114
|
+
bytes.join(""),
|
|
115
|
+
...space
|
|
116
|
+
].join("|")})`;
|
|
117
|
+
});
|
|
118
|
+
return new RegExp(characters.join(""), "g");
|
|
119
|
+
};
|
|
120
|
+
/** `text` with each of `secrets`, in any percent spelling, then each credential shape, redacted. */
|
|
121
|
+
const redacted = (text, secrets) => {
|
|
122
|
+
const plain = secrets.reduce((words, secret) => words.replace(spelledAs(secret), marker), text);
|
|
123
|
+
return credentialPatterns.reduce((words, [pattern, by]) => words.replace(pattern, by), plain);
|
|
124
|
+
};
|
|
125
|
+
/** A refusal's JSON body: an object, any value under each key. */
|
|
126
|
+
const decodeRefusal = /* @__PURE__ */ Schema.decodeOption(Schema.fromJsonString(Schema.Record(Schema.String, Schema.Json)));
|
|
127
|
+
const isText = /* @__PURE__ */ Schema.is(Schema.String);
|
|
128
|
+
/**
|
|
129
|
+
* The kept text of `text`, a refusal's JSON body: its `fields`' string values in their order,
|
|
130
|
+
* joined, made one line, redacted and cut to `saidMost`. `undefined` when no field holds text, or
|
|
131
|
+
* when a secret still shows once redacted, as one inside the marker would.
|
|
132
|
+
*/
|
|
133
|
+
const keptSaid = (text, fields, secrets) => {
|
|
134
|
+
const body = Option.getOrElse(decodeRefusal(text), () => ({}));
|
|
135
|
+
const texts = fields.flatMap((field) => {
|
|
136
|
+
const value = Object.hasOwn(body, field) ? body[field] : void 0;
|
|
137
|
+
return isText(value) ? [value] : [];
|
|
138
|
+
});
|
|
139
|
+
const line = oneLine(texts.join("; ")).trim();
|
|
140
|
+
if (line === "") return void 0;
|
|
141
|
+
const kept = cutWords(redacted(line, secrets), 256).trim();
|
|
142
|
+
if (kept === "" || secrets.some((secret) => kept.includes(secret))) return void 0;
|
|
143
|
+
return kept;
|
|
144
|
+
};
|
|
145
|
+
/**
|
|
146
|
+
* A provider's own call refused, such as GitHub's mint of a token: its message names the call and
|
|
147
|
+
* the status, and `said` what the refusal's marked fields kept, as `saidOf` keeps them.
|
|
148
|
+
*/
|
|
149
|
+
var ProviderRefused = class extends Error {
|
|
150
|
+
said;
|
|
151
|
+
constructor(message, said) {
|
|
152
|
+
super(message);
|
|
153
|
+
this.said = said;
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
/** Whether `response` is JSON, as `application/json` or a `+json` type. */
|
|
157
|
+
const isJson = (response) => {
|
|
158
|
+
const type = (response.headers.get("content-type") ?? "").split(";", 1)[0]?.trim() ?? "";
|
|
159
|
+
return type === "application/json" || /^application\/[\w.-]+\+json$/.test(type);
|
|
160
|
+
};
|
|
161
|
+
/**
|
|
162
|
+
* The start of `body`, at most `saidBytesMost` bytes, or `undefined` past it or once `signal`
|
|
163
|
+
* aborts, which cancels a read that waits: a refusal that stalls never holds its try. Cancelled
|
|
164
|
+
* after, either way.
|
|
165
|
+
*/
|
|
166
|
+
const bodyStart = async (body, signal) => {
|
|
167
|
+
const reader = body.getReader();
|
|
168
|
+
const stop = () => {
|
|
169
|
+
reader.cancel(signal.reason).catch(() => void 0);
|
|
170
|
+
};
|
|
171
|
+
const decoder = new TextDecoder();
|
|
172
|
+
let text = "";
|
|
173
|
+
let bytes = 0;
|
|
174
|
+
signal.addEventListener("abort", stop, { once: true });
|
|
175
|
+
try {
|
|
176
|
+
while (!signal.aborted) {
|
|
177
|
+
const piece = await reader.read();
|
|
178
|
+
if (piece.done) return signal.aborted ? void 0 : text + decoder.decode();
|
|
179
|
+
bytes += piece.value.byteLength;
|
|
180
|
+
if (bytes > 4096) return void 0;
|
|
181
|
+
text += decoder.decode(piece.value, { stream: true });
|
|
182
|
+
}
|
|
183
|
+
return;
|
|
184
|
+
} finally {
|
|
185
|
+
signal.removeEventListener("abort", stop);
|
|
186
|
+
reader.cancel().catch(() => void 0);
|
|
187
|
+
reader.releaseLock();
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
/**
|
|
191
|
+
* What the refusal `response` to `request` said in `fields`, as `keptSaid` keeps it: its body read
|
|
192
|
+
* only when it's JSON and some field is marked, until `request`'s signal aborts, and always
|
|
193
|
+
* dropped after. A failed or stopped read keeps nothing.
|
|
194
|
+
*/
|
|
195
|
+
const saidOf = async (request, response, fields) => {
|
|
196
|
+
if (fields.length === 0 || response.body === null || !isJson(response)) {
|
|
197
|
+
await response.body?.cancel().catch(() => void 0);
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
const text = await bodyStart(response.body, request.signal).catch(() => void 0);
|
|
201
|
+
if (text === void 0) return void 0;
|
|
202
|
+
return keptSaid(text, fields, requestSecrets(request));
|
|
203
|
+
};
|
|
204
|
+
export { ProviderRefused, keptSaid, requestSecrets, saidBytesMost, saidOf };
|
package/dist/sync/smart-http.mjs
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { fail } from "../contracts/result.mjs";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
1
3
|
// src/sync/smart-http.ts
|
|
2
4
|
const smartHttpName = "smart-http";
|
|
3
5
|
/**
|
|
@@ -12,8 +14,8 @@ const smartHttp = (options) => {
|
|
|
12
14
|
name: smartHttpName,
|
|
13
15
|
remote: (repo) => {
|
|
14
16
|
const url = new URL(repo, base).href;
|
|
15
|
-
if (!url.startsWith(base) || repo.split("/").includes("..")) return
|
|
16
|
-
return
|
|
17
|
+
if (!url.startsWith(base) || repo.split("/").includes("..")) return fail("INVALID_ARGUMENT", `'${repo}' isn't a path under the provider's URL`);
|
|
18
|
+
return Effect.succeed({
|
|
17
19
|
...options,
|
|
18
20
|
url
|
|
19
21
|
});
|
package/dist/sync/step.mjs
CHANGED
|
@@ -21,8 +21,9 @@ import { listJobRow } from "../store/list-job.mjs";
|
|
|
21
21
|
import { StoredRepo } from "../store/records.mjs";
|
|
22
22
|
import { newChangeId, repoScope, selfKey } from "../store/scopes.mjs";
|
|
23
23
|
import { asSync } from "./bound.mjs";
|
|
24
|
+
import { copyLfs, withLfsPages } from "./lfs-copy.mjs";
|
|
24
25
|
import { ImportRow, cancelKey, cutKey, cutRow, failedHint, failedRow, importEndDeletes, importKey, importRow, readImport, readTipPages, stoppedTry, tipPageKey, tipPageRow, tipPagesOf, tipRowBytes } from "../core/imports.mjs";
|
|
25
|
-
import { ForGood, SyncTryError, forGood, fromRemote, httpOf, openedFor, remoteOf, syncObjects, thrownOf, tried } from "./tries.mjs";
|
|
26
|
+
import { ForGood, SyncTryError, forGood, fromRemote, httpOf, keptFieldsOf, openedFor, remoteOf, syncObjects, thrownOf, tried } from "./tries.mjs";
|
|
26
27
|
import { currentRepo } from "../store/job-try.mjs";
|
|
27
28
|
import { CoreParts, ObjectsParts, overStore } from "../core/parts.mjs";
|
|
28
29
|
import { importOwner } from "../protocol/wire/lines.mjs";
|
|
@@ -44,7 +45,9 @@ import { CurrentJob } from "@ref0/infra";
|
|
|
44
45
|
* runs past the limit, or that the storage refuses for a reason in `halvedReasons`, is fetched
|
|
45
46
|
* again at half the depth, and one holding an object the storage refuses as `object-too-large`
|
|
46
47
|
* fails the job on that try, with that refusal;
|
|
47
|
-
* 3.
|
|
48
|
+
* 3. on a server with `Lfs.layer`, copy the LFS objects the history points at, as `copyLfs`
|
|
49
|
+
* says, from the pointers each segment's landing kept;
|
|
50
|
+
* 4. publish: move each page's refs to their tips, a page a try, each in one atomic commit,
|
|
48
51
|
* `source: 'import'`, that moves the record's cursor past it, and mark the import done with
|
|
49
52
|
* the last.
|
|
50
53
|
* A step reads the import's record first, and ends the job for a cancelled import or one that
|
|
@@ -172,7 +175,7 @@ const remoteRefused = (remote, message) => {
|
|
|
172
175
|
* A failure to read the remote's advertisement: its own `ERR` refusal, by its reason, ends the
|
|
173
176
|
* import, since every try meets it; any other is the remote's, tried again.
|
|
174
177
|
*/
|
|
175
|
-
const advertisedFrom = (remote, call) => (error) => error.code === "FAILED_PRECONDITION" && error.context?.reason === "remote-refused" ? new ForGood({ error: remoteRefused(remote, error.message) }) : fromRemote(call)(error);
|
|
178
|
+
const advertisedFrom = (remote, call, heard) => (error) => error.code === "FAILED_PRECONDITION" && error.context?.reason === "remote-refused" ? new ForGood({ error: remoteRefused(remote, error.message) }) : fromRemote(call, heard)(error);
|
|
176
179
|
/** `context.progress`, which a claim taken again refuses: the sample's dropped, and the try goes on. */
|
|
177
180
|
const report = (context, phase, row) => context.progress({
|
|
178
181
|
phase,
|
|
@@ -269,13 +272,13 @@ const pullTips = (refs, own, limits) => {
|
|
|
269
272
|
*/
|
|
270
273
|
const listTips = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, version, row, remote) {
|
|
271
274
|
yield* report(attempt.context, "fetch", row);
|
|
272
|
-
const http = yield* httpOf(remote);
|
|
275
|
+
const { http, heard } = yield* httpOf(remote, keptFieldsOf(attempt.bound, row.source));
|
|
273
276
|
const listed = Effect.flatMap(discover(http), (upload) => remoteRefsAndHeadOf(http, upload, [
|
|
274
277
|
"refs/heads/",
|
|
275
278
|
"refs/tags/",
|
|
276
279
|
"refs/pull/"
|
|
277
280
|
]));
|
|
278
|
-
const { refs: listing, head } = yield* Effect.mapError(listed, advertisedFrom(remote, "list its branches and tags"));
|
|
281
|
+
const { refs: listing, head } = yield* Effect.mapError(listed, advertisedFrom(remote, "list its branches and tags", heard));
|
|
279
282
|
const refs = new Map([...listing].filter(([ref]) => !ref.startsWith("refs/pull/")));
|
|
280
283
|
const unnamed = [...refs.keys()].find((ref) => !isRefName(ref));
|
|
281
284
|
if (unnamed !== void 0) return yield* forGood(unnamedTip(unnamed));
|
|
@@ -386,8 +389,8 @@ const fetchSegment = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, row,
|
|
|
386
389
|
if (opened === void 0) return void 0;
|
|
387
390
|
const objects = objectsFace(syncObjects(yield* ObjectsParts));
|
|
388
391
|
yield* report(context, "fetch", row);
|
|
389
|
-
const http = yield* httpOf(remote);
|
|
390
|
-
const upload = yield* Effect.mapError(discover(http), advertisedFrom(remote, "advertise its refs"));
|
|
392
|
+
const { http, heard } = yield* httpOf(remote, keptFieldsOf(bound, row.source));
|
|
393
|
+
const upload = yield* Effect.mapError(discover(http), advertisedFrom(remote, "advertise its refs", heard));
|
|
391
394
|
const shallow = yield* deepens(upload);
|
|
392
395
|
const wanted = row.deepest + row.step;
|
|
393
396
|
const request = {
|
|
@@ -407,7 +410,7 @@ const fetchSegment = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, row,
|
|
|
407
410
|
listed: opened.listed,
|
|
408
411
|
tips: [...new Set(opened.refs.values())],
|
|
409
412
|
held: row.deepest > 0 ? tips : []
|
|
410
|
-
}).pipe(Effect.mapError(fromRemote("negotiate a fetch")));
|
|
413
|
+
}).pipe(Effect.mapError(fromRemote("negotiate a fetch", heard)));
|
|
411
414
|
yield* report(context, "receive", row);
|
|
412
415
|
const { pack } = negotiated;
|
|
413
416
|
const { stream, seen } = counted(pack.bytes, most);
|
|
@@ -432,6 +435,7 @@ const fetchSegment = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, row,
|
|
|
432
435
|
const { needs, kept } = carriedCut(row.roots, roots, cut);
|
|
433
436
|
if (needs.length > 0) pushedPack.needs = needs;
|
|
434
437
|
pushedPack.cutMost = kept.reduce((left, [, parents]) => left - parents.length, receiveCutParentsMost);
|
|
438
|
+
const copying = (yield* bound.lfs) !== void 0;
|
|
435
439
|
const { restaged: _restaged, ...fetched } = row;
|
|
436
440
|
const next = () => ({
|
|
437
441
|
...fetched,
|
|
@@ -465,8 +469,13 @@ const fetchSegment = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, row,
|
|
|
465
469
|
pack: pushedPack,
|
|
466
470
|
also: (_at, received) => {
|
|
467
471
|
const written = cutAfter(roots, kept, received);
|
|
472
|
+
const paged = withLfsPages(next(), received?.lfsPointers, copying);
|
|
468
473
|
return {
|
|
469
|
-
put: [
|
|
474
|
+
put: [
|
|
475
|
+
importRow(paged.row),
|
|
476
|
+
...written.put,
|
|
477
|
+
...paged.put
|
|
478
|
+
],
|
|
470
479
|
delete: written.delete,
|
|
471
480
|
jobs: []
|
|
472
481
|
};
|
|
@@ -476,7 +485,7 @@ const fetchSegment = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, row,
|
|
|
476
485
|
});
|
|
477
486
|
const pushed = yield* Effect.result(sent.pipe(Effect.mapError((error) => {
|
|
478
487
|
const failure = pack.failure();
|
|
479
|
-
return failure === void 0 ? error : fromRemote("send its pack")(failure);
|
|
488
|
+
return failure === void 0 ? error : fromRemote("send its pack", heard)(failure);
|
|
480
489
|
}), Effect.onInterrupt(() => Effect.sync(() => {
|
|
481
490
|
stopped.abort();
|
|
482
491
|
pack.cancel();
|
|
@@ -578,6 +587,7 @@ const resumedIn = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, row, rec
|
|
|
578
587
|
}
|
|
579
588
|
const answer = stepped.success;
|
|
580
589
|
if ("paused" in answer) return more;
|
|
590
|
+
const copying = (yield* attempt.bound.lfs) !== void 0;
|
|
581
591
|
yield* push({
|
|
582
592
|
caller: attempt.bound.caller,
|
|
583
593
|
repo: opened.name,
|
|
@@ -589,11 +599,13 @@ const resumedIn = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, row, rec
|
|
|
589
599
|
pack: { received: answer.received },
|
|
590
600
|
also: (at, received) => {
|
|
591
601
|
const written = cutAfter(lands.roots, kept, received);
|
|
602
|
+
const paged = withLfsPages(landed(row, lands), received?.lfsPointers, copying);
|
|
592
603
|
return {
|
|
593
604
|
put: [
|
|
594
|
-
importRow(
|
|
605
|
+
importRow(paged.row),
|
|
595
606
|
stagedRow(pack, at, true),
|
|
596
|
-
...written.put
|
|
607
|
+
...written.put,
|
|
608
|
+
...paged.put
|
|
597
609
|
],
|
|
598
610
|
delete: [...written.delete, receiveKey(pack)],
|
|
599
611
|
jobs: []
|
|
@@ -769,7 +781,15 @@ const stepIn = /* @__PURE__ */ Effect.fnUntraced(function* (attempt) {
|
|
|
769
781
|
/** The step the record says is next, once who started the import is asked again. */
|
|
770
782
|
const stepAs = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, read, row) {
|
|
771
783
|
if (row.receiving !== void 0) return yield* resumed(attempt, row, row.receiving, read.cut);
|
|
772
|
-
if (row.copied)
|
|
784
|
+
if (row.copied) {
|
|
785
|
+
const { lfs } = row;
|
|
786
|
+
const copy = lfs !== void 0 && lfs.page < lfs.pages ? yield* attempt.bound.lfs : void 0;
|
|
787
|
+
if (lfs !== void 0 && copy !== void 0) {
|
|
788
|
+
yield* copyLfs(attempt, read.version, row, lfs, copy);
|
|
789
|
+
return more;
|
|
790
|
+
}
|
|
791
|
+
return yield* publish(attempt, row);
|
|
792
|
+
}
|
|
773
793
|
const remote = yield* remoteOf(attempt.bound, row.source, attempt.context.signal, "read");
|
|
774
794
|
if (row.tipPages === void 0) return yield* listTips(attempt, read.version, row, remote);
|
|
775
795
|
return yield* fetchSegment(attempt, row, read.cut, remote);
|
package/dist/sync/tries.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { runnerIn } from "../store/crossing.mjs";
|
|
1
|
+
import { runnerIn, untilAborted } from "../store/crossing.mjs";
|
|
2
2
|
import { gitError, gitErrorFrom, isGitError } from "../contracts/result.mjs";
|
|
3
3
|
import { openRepo } from "../core/access.mjs";
|
|
4
4
|
import { CoreParts } from "../core/parts.mjs";
|
|
@@ -10,11 +10,15 @@ import { answerSpent } from "../store/errors.mjs";
|
|
|
10
10
|
import { decodePacks } from "../store/git-store.mjs";
|
|
11
11
|
import { WholeRepo, wholeRefs } from "../store/ref-rows.mjs";
|
|
12
12
|
import { collections } from "../store/scopes.mjs";
|
|
13
|
+
import { ProviderRefused, saidOf } from "./said.mjs";
|
|
14
|
+
import { quoted } from "../protocol/bytes/text.mjs";
|
|
13
15
|
import { responseToWeb } from "./http.mjs";
|
|
14
|
-
import { callLimitIn,
|
|
16
|
+
import { callLimitIn, spentAt, spentOf, spentRefusalOf } from "../contracts/calls-spent.mjs";
|
|
17
|
+
import { chargeCall } from "../store/call-count.mjs";
|
|
15
18
|
import * as Effect from "effect/Effect";
|
|
16
19
|
import * as HttpClient from "effect/http/HttpClient";
|
|
17
20
|
import * as Schema from "effect/Schema";
|
|
21
|
+
import * as Cause from "effect/Cause";
|
|
18
22
|
import * as Predicate from "effect/Predicate";
|
|
19
23
|
import * as HttpClientRequest from "effect/http/HttpClientRequest";
|
|
20
24
|
// src/sync/tries.ts
|
|
@@ -70,52 +74,95 @@ const unknownProvider = (name) => gitError("INVALID_ARGUMENT", `No provider name
|
|
|
70
74
|
hostHint: `Pass the '${name}' provider to Sync.layer`,
|
|
71
75
|
context: { reason: "provider-unknown" }
|
|
72
76
|
});
|
|
73
|
-
|
|
77
|
+
/** `message`, then what a refusal said when its provider kept some of it, quoted. */
|
|
78
|
+
const withSaid = (message, said) => said === void 0 ? message : `${message}. Its refusal said: ${quoted(said)}`;
|
|
79
|
+
/** The refusal a provider failed with: itself when it died of one, or the cause its `GitError` holds. */
|
|
80
|
+
const refusalIn = (cause) => {
|
|
81
|
+
if (cause instanceof ProviderRefused) return cause;
|
|
82
|
+
return isGitError(cause) && cause.cause instanceof ProviderRefused ? cause.cause : void 0;
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* A provider that failed: what its own call's refusal said when it kept some, as a
|
|
86
|
+
* `ProviderRefused` it failed with or under, else nothing of it.
|
|
87
|
+
*/
|
|
88
|
+
const providerFailed = (name, cause) => gitError("UNAVAILABLE", withSaid(`The '${name}' provider made no remote for this try`, refusalIn(cause)?.said), { hint: "The job tries again" });
|
|
74
89
|
/**
|
|
75
|
-
* The provider's remote for this try
|
|
76
|
-
*
|
|
90
|
+
* The provider's remote for this try, its Effect run in the try's fiber, so the calls it makes are
|
|
91
|
+
* charged to the try's budget, and interrupted once `signal` aborts: a provider that has gone
|
|
92
|
+
* since fails the job for good, naming it, and one that fails or dies fails this try with a
|
|
93
|
+
* message that names no secret. A spent call bound stays the defect it is, so the try stops whole.
|
|
77
94
|
*/
|
|
78
95
|
const remoteOf = /* @__PURE__ */ Effect.fnUntraced(function* (bound, source, signal, access = "read") {
|
|
79
96
|
const { provider: name, repo } = source;
|
|
80
97
|
const provider = bound.providers.get(name);
|
|
81
98
|
if (provider === void 0) return yield* forGood(unknownProvider(name));
|
|
82
|
-
return yield*
|
|
99
|
+
return yield* untilAborted(provider.remote(repo, access), signal).pipe(Effect.catchCause((cause) => {
|
|
100
|
+
if (Cause.hasInterruptsOnly(cause)) return Effect.interrupt;
|
|
101
|
+
const thrown = spentOf(cause) ?? Cause.squash(cause);
|
|
102
|
+
if (spentAt(thrown) !== void 0) return Effect.die(thrown);
|
|
103
|
+
return Effect.fail(providerFailed(name, thrown));
|
|
104
|
+
}));
|
|
83
105
|
});
|
|
84
106
|
/**
|
|
85
|
-
* `send`, each refusal's body dropped
|
|
86
|
-
*
|
|
107
|
+
* `send`, each refusal's body dropped once `heard` keeps what its provider's `fields` said: the
|
|
108
|
+
* rest is the remote's text, or a gateway's, which may echo the request's credential, and a try's
|
|
109
|
+
* error is kept where the job's readers see it.
|
|
87
110
|
*/
|
|
88
|
-
const bodiless = (send) => async (request) => {
|
|
111
|
+
const bodiless = (send, fields, heard) => async (request) => {
|
|
89
112
|
const response = await send(request);
|
|
113
|
+
heard.said = void 0;
|
|
90
114
|
if (response.status < 400) return response;
|
|
91
|
-
await response
|
|
115
|
+
heard.said = await saidOf(request, response, fields);
|
|
92
116
|
return new Response(null, {
|
|
93
117
|
status: response.status,
|
|
94
118
|
headers: response.headers
|
|
95
119
|
});
|
|
96
120
|
};
|
|
97
121
|
/**
|
|
98
|
-
* A failure of a call to the remote, kept by its code and context
|
|
99
|
-
* remote's
|
|
100
|
-
* credential, as a refusal's body may. A spent call bound's
|
|
101
|
-
* objects or a host's transport met the platform's cap, is no
|
|
102
|
-
* the bound's own (#1083).
|
|
122
|
+
* A failure of a call to the remote, kept by its code and context, and what `heard` kept of the
|
|
123
|
+
* refusal it met: its own message may be the remote's text, as an `ERR` line or a status report
|
|
124
|
+
* sent with 200 is, which may echo the credential, as a refusal's body may. A spent call bound's
|
|
125
|
+
* refusal, as a read of the repo's own objects or a host's transport met the platform's cap, is no
|
|
126
|
+
* failure of the remote's: it stays the bound's own (#1083).
|
|
103
127
|
*/
|
|
104
|
-
const fromRemote = (call) => (error) => spentRefusalOf(error) ?? gitErrorFrom(error, {
|
|
105
|
-
message: `The remote failed to ${call} (${error.code})`,
|
|
128
|
+
const fromRemote = (call, heard) => (error) => spentRefusalOf(error) ?? gitErrorFrom(error, {
|
|
129
|
+
message: withSaid(`The remote failed to ${call} (${error.code})`, heard.said),
|
|
106
130
|
hint: "The job tries again"
|
|
107
131
|
});
|
|
108
|
-
/** The
|
|
109
|
-
const
|
|
132
|
+
/** The fields of a refusal's JSON body `source`'s provider marks safe to keep: none it doesn't. */
|
|
133
|
+
const keptFieldsOf = (bound, source) => bound.providers.get(source.provider)?.keptFields ?? [];
|
|
134
|
+
/**
|
|
135
|
+
* Requests to `remote` as sent, no credential added: through the bound's charged client, or
|
|
136
|
+
* `remote.transport`, whose each call is charged one subrequest before it runs, so a host's
|
|
137
|
+
* sender, a service binding's say, is counted as Git's own client is. A body streams through
|
|
138
|
+
* either, never collected.
|
|
139
|
+
*/
|
|
140
|
+
const senderOf = /* @__PURE__ */ Effect.fnUntraced(function* (remote) {
|
|
110
141
|
const client = yield* HttpClient.HttpClient;
|
|
111
|
-
const
|
|
112
|
-
|
|
142
|
+
const { transport } = remote;
|
|
143
|
+
return (request) => transport === void 0 ? client.execute(HttpClientRequest.fromWeb(request)).pipe(Effect.flatMap(responseToWeb)) : Effect.andThen(chargeCall("fetch"), transport(request));
|
|
144
|
+
});
|
|
145
|
+
/**
|
|
146
|
+
* The client's smart HTTP to `remote`, with its credentials, each request run in the caller's
|
|
147
|
+
* context: through the bound's charged client, or `remote.transport`, whose each call is charged
|
|
148
|
+
* one subrequest before it runs, so a host's sender, a service binding's say, is counted as Git's
|
|
149
|
+
* own client is. A request the transport sends again it charges itself. It answers what its
|
|
150
|
+
* refusals said in `fields` beside it, as `bodiless` keeps it.
|
|
151
|
+
*/
|
|
152
|
+
const httpOf = /* @__PURE__ */ Effect.fnUntraced(function* (remote, fields) {
|
|
153
|
+
const sent = yield* senderOf(remote);
|
|
154
|
+
const run = runnerIn(yield* Effect.context());
|
|
155
|
+
const heard = { said: void 0 };
|
|
156
|
+
const send = (request) => run(sent(request), request.signal);
|
|
113
157
|
const options = {
|
|
114
158
|
url: remote.url,
|
|
115
|
-
transport: bodiless(
|
|
159
|
+
transport: bodiless(send, fields, heard)
|
|
116
160
|
};
|
|
117
161
|
if (remote.credentials !== void 0) options.credentials = remote.credentials;
|
|
118
|
-
return
|
|
162
|
+
return {
|
|
163
|
+
http: gitHttp(options),
|
|
164
|
+
heard
|
|
165
|
+
};
|
|
119
166
|
});
|
|
120
167
|
const refsRead = { collection: collections.refs };
|
|
121
168
|
const packsRead = { collection: collections.packs };
|
|
@@ -148,4 +195,4 @@ const openedFor = /* @__PURE__ */ Effect.fnUntraced(function* (caller, internalI
|
|
|
148
195
|
refs
|
|
149
196
|
};
|
|
150
197
|
});
|
|
151
|
-
export { ForGood, SyncTryError, forGood, fromRemote, httpOf, openedFor, remoteOf, syncObjects, syncRetry, syncTryError, syncWhole, thrownOf, tried, unknownProvider };
|
|
198
|
+
export { ForGood, SyncTryError, forGood, fromRemote, httpOf, keptFieldsOf, openedFor, remoteOf, senderOf, syncObjects, syncRetry, syncTryError, syncWhole, thrownOf, tried, unknownProvider };
|
package/dist/sync.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { GitHubAppCredentials, ImportJobData, ImportPhase, ImportProgress, ImportState, ImportedMove, MirrorJobData, MirrorPause, MirrorState, ReportImportProgress, Sync, SyncCancelInput, SyncGitHubOptions, SyncImportInput, SyncLayerOptions, SyncMirrorInput, SyncMirrorsInput, SyncProvider, SyncPublishInput, SyncRemote, SyncRemoveMirrorInput, SyncSource, SyncTrigger, cancelImport, importRepo, importedPullRefs, mirror, mirrors, publishImported, removeMirror } from "./contracts/sync.mjs";
|
|
1
|
+
import { GitHubAppCredentials, ImportJobData, ImportLfsMissed, ImportLfsReason, ImportPhase, ImportProgress, ImportState, ImportStatus, ImportedMove, MirrorJobData, MirrorPause, MirrorState, ReportImportProgress, Sync, SyncCancelInput, SyncGitHubOptions, SyncImportInput, SyncLayerOptions, SyncMirrorInput, SyncMirrorsInput, SyncProvider, SyncPublishInput, SyncRemote, SyncRemoveMirrorInput, SyncSource, SyncTransport, SyncTrigger, cancelImport, importRepo, importedPullRefs, mirror, mirrors, publishImported, removeMirror } from "./contracts/sync.mjs";
|
|
2
2
|
import { github, webhookBodyBytes } from "./sync/github.mjs";
|
|
3
3
|
import { partialImporter } from "./sync/import.mjs";
|
|
4
4
|
import { layer } from "./sync/layer.mjs";
|
|
5
5
|
import { smartHttp } from "./sync/smart-http.mjs";
|
|
6
|
-
export { type GitHubAppCredentials, type ImportJobData, type ImportPhase, type ImportProgress, type ImportState, type ImportedMove, type MirrorJobData, type MirrorPause, type MirrorState, type ReportImportProgress, Sync, type SyncCancelInput, type SyncGitHubOptions, type SyncImportInput, type SyncLayerOptions, type SyncMirrorInput, type SyncMirrorsInput, type SyncProvider, type SyncPublishInput, type SyncRemote, type SyncRemoveMirrorInput, type SyncSource, type SyncTrigger, cancelImport, github, importRepo as import, importedPullRefs, layer, mirror, mirrors, partialImporter, publishImported, removeMirror, smartHttp, webhookBodyBytes };
|
|
6
|
+
export { type GitHubAppCredentials, type ImportJobData, type ImportLfsMissed, type ImportLfsReason, type ImportPhase, type ImportProgress, type ImportState, type ImportStatus, type ImportedMove, type MirrorJobData, type MirrorPause, type MirrorState, type ReportImportProgress, Sync, type SyncCancelInput, type SyncGitHubOptions, type SyncImportInput, type SyncLayerOptions, type SyncMirrorInput, type SyncMirrorsInput, type SyncProvider, type SyncPublishInput, type SyncRemote, type SyncRemoveMirrorInput, type SyncSource, type SyncTransport, type SyncTrigger, cancelImport, github, importRepo as import, importedPullRefs, layer, mirror, mirrors, partialImporter, publishImported, removeMirror, smartHttp, webhookBodyBytes };
|
package/dist/topics/advance.mjs
CHANGED
|
@@ -4,15 +4,16 @@ import { checkPublish } from "../queue/advance.mjs";
|
|
|
4
4
|
import { advanceRow } from "../store/queue-jobs.mjs";
|
|
5
5
|
import { jobParts } from "../store/job-try.mjs";
|
|
6
6
|
import { storeCall } from "../store/errors.mjs";
|
|
7
|
+
import { heldAdd } from "../store/repo-record.mjs";
|
|
7
8
|
import { untilAborted } from "../store/crossing.mjs";
|
|
8
|
-
import {
|
|
9
|
+
import { topicScope } from "../store/scopes.mjs";
|
|
9
10
|
import { CandidateSetData, PrepareData, TopicAdvanceData, prepareName, prepareRow, reportTimeoutName, reportTimeoutRow, topicAdvanceName, topicAdvanceRow } from "../store/topic-jobs.mjs";
|
|
10
11
|
import { projectTopic } from "./directory.mjs";
|
|
11
12
|
import { TopicsHost, saveMargin } from "./host.mjs";
|
|
12
13
|
import { addMember, candidateAt, memberRead, releaseMember, reserveMember } from "./members.mjs";
|
|
13
14
|
import { unwaited } from "./rows.mjs";
|
|
14
15
|
import { commitTopic, currentSet, durationWords, entriesOf, failureOf, readTopic, setKeyOf, topicOf } from "./topic.mjs";
|
|
15
|
-
import { QueueParts, overStore } from "../core/parts.mjs";
|
|
16
|
+
import { ObjectsParts, QueueParts, overStore } from "../core/parts.mjs";
|
|
16
17
|
import { checkedAnswer, plainAnswer } from "../core/rules/context.mjs";
|
|
17
18
|
import * as Clock$1 from "effect/Clock";
|
|
18
19
|
import * as Effect from "effect/Effect";
|
|
@@ -412,6 +413,12 @@ const beforeDecision = /* @__PURE__ */ Effect.fnUntraced(function* (host, read,
|
|
|
412
413
|
const afterDecision = /* @__PURE__ */ Effect.fnUntraced(function* (read) {
|
|
413
414
|
const { row } = read;
|
|
414
415
|
const reads = yield* Effect.forEach(row.members, (member) => memberRead(member));
|
|
416
|
+
const { records } = (yield* TopicsHost).queue;
|
|
417
|
+
const queueStore = {
|
|
418
|
+
read: (scope, wanted) => storeCall(records.read(scope, wanted)),
|
|
419
|
+
add: (scope, addition) => storeCall(records.add(scope, addition))
|
|
420
|
+
};
|
|
421
|
+
const { fetchLimits } = yield* ObjectsParts;
|
|
415
422
|
const merged = [];
|
|
416
423
|
let refused;
|
|
417
424
|
for (const [index, member] of row.members.entries()) {
|
|
@@ -435,7 +442,7 @@ const afterDecision = /* @__PURE__ */ Effect.fnUntraced(function* (read) {
|
|
|
435
442
|
continue;
|
|
436
443
|
}
|
|
437
444
|
const jobs = [advanceRow(member.target)];
|
|
438
|
-
|
|
445
|
+
if (!(yield* heldAdd(queueStore, member.internalId, fetchLimits, { jobs }).pipe(Effect.as(true), Effect.catchTag("RepoGone", () => Effect.succeed(false))))) refused ??= member;
|
|
439
446
|
}
|
|
440
447
|
if (refused !== void 0) {
|
|
441
448
|
const { repo, entry } = refused;
|
package/dist/topics/host.mjs
CHANGED
|
@@ -4,14 +4,6 @@ import "../queue/schedule.mjs";
|
|
|
4
4
|
import * as Predicate from "effect/Predicate";
|
|
5
5
|
import * as Context from "effect/Context";
|
|
6
6
|
// src/topics/host.ts
|
|
7
|
-
/** What `topics()` checked, by the factory it made, so a server takes only those. */
|
|
8
|
-
var TopicsFactoryValue = class {
|
|
9
|
-
kind = "topics";
|
|
10
|
-
options;
|
|
11
|
-
constructor(options) {
|
|
12
|
-
this.options = options;
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
7
|
/** The topics host, private to its calls and jobs. */
|
|
16
8
|
var TopicsHost = class extends (/* @__PURE__ */ Context.Service()("@ref0/git/topics/TopicsHost")) {};
|
|
17
9
|
/** What a `prepare` try may run past its call, to save the answer. */
|
|
@@ -71,14 +63,4 @@ const checkTopics = (options) => {
|
|
|
71
63
|
if (prepare !== void 0) checked.prepare = checkPrepare(prepare);
|
|
72
64
|
return checked;
|
|
73
65
|
};
|
|
74
|
-
|
|
75
|
-
const topics = (options = {}) => {
|
|
76
|
-
checkTopics(options);
|
|
77
|
-
return Object.freeze(new TopicsFactoryValue(options));
|
|
78
|
-
};
|
|
79
|
-
/** The options held by a factory this bridge made; other values are a setup error. */
|
|
80
|
-
const topicsOptions = (factory) => {
|
|
81
|
-
if (!(factory instanceof TopicsFactoryValue)) throw new TypeError("options.topics must be one topics() made");
|
|
82
|
-
return factory.options;
|
|
83
|
-
};
|
|
84
|
-
export { TopicsHost, checkTopics, saveMargin, topics, topicsOptions };
|
|
66
|
+
export { TopicsHost, checkTopics, saveMargin };
|
package/dist/topics/layer.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { Events } from "../contracts/events.mjs";
|
|
|
3
3
|
import { register } from "../contracts/git.mjs";
|
|
4
4
|
import { MergeQueue } from "../contracts/queue.mjs";
|
|
5
5
|
import { gitError } from "../contracts/result.mjs";
|
|
6
|
-
import { acting } from "../core/
|
|
6
|
+
import { acting } from "../core/access.mjs";
|
|
7
7
|
import { QueueInternals } from "../queue/host.mjs";
|
|
8
8
|
import { topicJobs } from "./advance.mjs";
|
|
9
9
|
import { topicCalls } from "./calls.mjs";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ref0/git",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Git hosting as a library: a server, a client and their merges",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -50,11 +50,6 @@
|
|
|
50
50
|
"import": "./dist/remote-helper.mjs",
|
|
51
51
|
"default": "./dist/remote-helper.mjs"
|
|
52
52
|
},
|
|
53
|
-
"./rest": {
|
|
54
|
-
"types": "./dist/rest.d.mts",
|
|
55
|
-
"import": "./dist/rest.mjs",
|
|
56
|
-
"default": "./dist/rest.mjs"
|
|
57
|
-
},
|
|
58
53
|
"./sync": {
|
|
59
54
|
"types": "./dist/sync.d.mts",
|
|
60
55
|
"import": "./dist/sync.mjs",
|
|
@@ -62,12 +57,12 @@
|
|
|
62
57
|
}
|
|
63
58
|
},
|
|
64
59
|
"dependencies": {
|
|
65
|
-
"@ref0/infra": "0.
|
|
60
|
+
"@ref0/infra": "0.14.0",
|
|
66
61
|
"pako": "2.1.0"
|
|
67
62
|
},
|
|
68
63
|
"devDependencies": {
|
|
69
64
|
"@effect/vitest": "4.1.7",
|
|
70
|
-
"@ref0/xdiff-wasm": "0.
|
|
65
|
+
"@ref0/xdiff-wasm": "0.14.0",
|
|
71
66
|
"effect": "4.1.7",
|
|
72
67
|
"vite-plus": "1.8.0",
|
|
73
68
|
"vitest": "5.1.1"
|