@ref0/git 0.7.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/access/private-refs.mjs +0 -2
- package/dist/auth/authorize.mjs +31 -24
- package/dist/auth/bridge.mjs +8 -8
- package/dist/auth/fences.d.mts +0 -1
- package/dist/auth/fences.mjs +1 -1
- package/dist/auth/grants.d.mts +0 -1
- package/dist/auth/grants.mjs +2 -2
- package/dist/auth/host-function.d.mts +1 -7
- package/dist/auth/host-function.mjs +38 -38
- package/dist/auth/identify.d.mts +0 -1
- package/dist/auth/identify.mjs +1 -1
- package/dist/auth/policy.d.mts +7 -4
- package/dist/auth/policy.mjs +13 -10
- package/dist/auth/token-rows.mjs +2 -5
- package/dist/auth/tokens-layer.d.mts +0 -2
- package/dist/auth/tokens-public.d.mts +3 -3
- package/dist/auth/tokens-public.mjs +4 -2
- package/dist/auth/tokens.d.mts +6 -1
- package/dist/auth/tokens.mjs +7 -1
- package/dist/client/client.d.mts +22 -15
- package/dist/client/client.mjs +31 -27
- package/dist/client/git-http.mjs +22 -5
- package/dist/client/local.mjs +1 -1
- package/dist/client/namespace.d.mts +2 -0
- package/dist/client/push-upload.d.mts +1 -0
- package/dist/client/push-upload.mjs +169 -2
- package/dist/client/remote-helper.mjs +2 -4
- package/dist/client/remote.mjs +37 -15
- package/dist/client/run-remote-helper.mjs +4 -4
- package/dist/client/transport.mjs +26 -19
- package/dist/contracts/actors.d.mts +57 -28
- package/dist/contracts/actors.mjs +38 -2
- package/dist/contracts/authorize.d.mts +21 -15
- package/dist/contracts/callers.mjs +40 -0
- package/dist/contracts/calls-spent.d.mts +2 -12
- package/dist/contracts/calls-spent.mjs +4 -5
- package/dist/contracts/client.d.mts +16 -9
- package/dist/contracts/events.d.mts +82 -14
- package/dist/contracts/events.mjs +35 -9
- package/dist/contracts/files.d.mts +42 -42
- package/dist/contracts/forks.d.mts +0 -24
- package/dist/contracts/git-hooks.d.mts +217 -0
- package/dist/contracts/git-hooks.mjs +3 -1
- package/dist/contracts/git.d.mts +13 -3
- package/dist/contracts/grants.d.mts +46 -27
- package/dist/contracts/lfs.d.mts +17 -4
- package/dist/contracts/merges.d.mts +7 -7
- package/dist/contracts/objects.d.mts +38 -4
- package/dist/contracts/opaque.mjs +19 -1
- package/dist/contracts/operations.d.mts +8 -1
- package/dist/contracts/operations.mjs +209 -0
- package/dist/contracts/queue.d.mts +6 -5
- package/dist/contracts/queue.mjs +9 -20
- package/dist/contracts/remote.d.mts +13 -4
- package/dist/contracts/remote.mjs +3 -3
- package/dist/contracts/repos.d.mts +11 -40
- package/dist/contracts/repos.mjs +11 -10
- package/dist/contracts/result.d.mts +28 -11
- package/dist/contracts/result.mjs +32 -2
- package/dist/contracts/rules.d.mts +706 -46
- package/dist/contracts/rules.mjs +81 -2
- package/dist/contracts/server.d.mts +5 -275
- package/dist/contracts/services.d.mts +0 -3
- package/dist/contracts/services.mjs +1 -3
- package/dist/contracts/signin.d.mts +2 -2
- package/dist/contracts/signin.mjs +4 -5
- package/dist/contracts/sync.d.mts +1 -4
- package/dist/contracts/tokens.d.mts +29 -17
- package/dist/contracts/tokens.mjs +14 -3
- package/dist/contracts/topics.d.mts +38 -11
- package/dist/contracts/topics.mjs +8 -2
- package/dist/core/access.d.mts +0 -2
- package/dist/core/access.mjs +15 -4
- package/dist/core/ancestry.mjs +5 -4
- package/dist/core/events/deliver.mjs +19 -1
- package/dist/core/forks.mjs +30 -11
- package/dist/core/hooks/groups.d.mts +0 -1
- package/dist/core/hooks/groups.mjs +8 -9
- package/dist/core/index-job.mjs +23 -1
- package/dist/core/index-lost.d.mts +11 -0
- package/dist/core/index-lost.mjs +55 -0
- package/dist/core/loose-tally.mjs +46 -0
- package/dist/core/objects/commit-writes.mjs +1 -1
- package/dist/core/objects/commits.mjs +10 -9
- package/dist/core/objects/merges.mjs +1 -1
- package/dist/core/objects/reading.mjs +28 -13
- package/dist/core/objects/trees.mjs +1 -1
- package/dist/core/objects/writing.mjs +1 -0
- package/dist/core/parts.d.mts +7 -0
- package/dist/core/promise.mjs +1 -15
- package/dist/core/publish.mjs +9 -5
- package/dist/core/purge.mjs +30 -12
- package/dist/core/push.mjs +39 -16
- package/dist/core/ref-view.mjs +14 -6
- package/dist/core/repack.mjs +54 -27
- package/dist/core/repo-info.mjs +8 -6
- package/dist/core/repos.mjs +1 -0
- package/dist/core/rules/check.mjs +10 -10
- package/dist/core/rules/context.d.mts +3 -1
- package/dist/core/rules/context.mjs +16 -13
- package/dist/core/rules/fetch.mjs +17 -23
- package/dist/core/tokens.mjs +2 -1
- package/dist/core/view.d.mts +10 -1
- package/dist/core/view.mjs +15 -6
- package/dist/effect.d.mts +3 -6
- package/dist/effect.mjs +3 -6
- package/dist/engine/commits.mjs +23 -50
- package/dist/engine/failures.d.mts +1 -2
- package/dist/engine/failures.mjs +1 -3
- package/dist/engine/merge-base-walk.mjs +57 -142
- package/dist/engine/merge-bases.mjs +9 -7
- package/dist/engine/merge.mjs +20 -17
- package/dist/engine/parts.d.mts +1 -0
- package/dist/engine/parts.mjs +1 -1
- package/dist/engine/walk.mjs +15 -11
- package/dist/extend.d.mts +1 -2
- package/dist/extend.mjs +1 -2
- package/dist/http/core-parts.mjs +18 -10
- package/dist/http/handler.mjs +11 -31
- package/dist/http/parts.d.mts +0 -1
- package/dist/index.d.mts +29 -22
- package/dist/index.mjs +5 -2
- package/dist/lfs/base.d.mts +6 -3
- package/dist/lfs/base.mjs +2 -1
- package/dist/lfs/layer.d.mts +4 -3
- package/dist/lfs/layer.mjs +23 -9
- package/dist/lfs/objects.mjs +93 -41
- package/dist/lfs/pointers.mjs +69 -18
- package/dist/lfs/purge.mjs +6 -2
- package/dist/lfs/rows.mjs +24 -7
- package/dist/lfs/service.d.mts +6 -3
- package/dist/lfs/service.mjs +8 -2
- package/dist/lfs/upkeep.mjs +47 -28
- package/dist/lfs/upload-most.mjs +47 -0
- package/dist/lfs/uploaded.mjs +59 -0
- package/dist/protocol/bytes/sha256-hasher.mjs +51 -0
- package/dist/protocol/bytes/streams.mjs +84 -2
- package/dist/protocol/bytes/text.mjs +6 -1
- package/dist/protocol/diff/read.d.mts +1 -0
- package/dist/protocol/diff/read.mjs +5 -2
- package/dist/protocol/objects/commit.d.mts +7 -0
- package/dist/protocol/objects/commit.mjs +5 -1
- package/dist/protocol/objects/fsck.mjs +6 -3
- package/dist/queue/advance.mjs +77 -18
- package/dist/queue/calls.mjs +4 -14
- package/dist/queue/host.d.mts +4 -0
- package/dist/queue/lanes.mjs +1 -1
- package/dist/queue/layer.mjs +4 -2
- package/dist/queue/limits.mjs +18 -2
- package/dist/queue/rows.mjs +10 -1
- package/dist/queue/schedule.mjs +1 -1
- package/dist/queue/search.mjs +3 -4
- package/dist/queue/trim.mjs +2 -2
- package/dist/rest/client-namespace.d.mts +2 -0
- package/dist/rest/client.d.mts +32 -8
- package/dist/rest/client.mjs +308 -382
- package/dist/rest/commits.d.mts +150 -150
- package/dist/rest/files.d.mts +18 -18
- package/dist/rest/forks.d.mts +77 -89
- package/dist/rest/handlers.mjs +2 -1
- package/dist/rest/listen.d.mts +8 -6
- package/dist/rest/listen.mjs +31 -75
- package/dist/rest/me.d.mts +2 -2
- package/dist/rest/merges.d.mts +7 -7
- package/dist/rest/refs.d.mts +27 -27
- package/dist/rest/repos.d.mts +40 -52
- package/dist/rest/tokens.d.mts +12 -12
- package/dist/rest/topics.d.mts +13 -13
- package/dist/rest/trees.d.mts +66 -66
- package/dist/rest/wire.d.mts +20 -2
- package/dist/rest/work.d.mts +39 -39
- package/dist/rest.d.mts +1 -7
- package/dist/rest.mjs +1 -5
- package/dist/server/git-layer.d.mts +10 -2
- package/dist/server/git-layer.mjs +29 -10
- package/dist/server/joined.d.mts +12 -6
- package/dist/server/joined.mjs +3 -2
- package/dist/server/registry.mjs +11 -5
- package/dist/server/server.d.mts +0 -1
- package/dist/server/server.mjs +42 -49
- package/dist/signin/context.d.mts +0 -1
- package/dist/signin/context.mjs +5 -9
- package/dist/storage/clean-up.mjs +3 -1
- package/dist/storage/fsck.mjs +12 -2
- package/dist/storage/graph-rebuild.mjs +262 -0
- package/dist/storage/index-bitmaps.mjs +16 -10
- package/dist/storage/index-build.mjs +160 -24
- package/dist/storage/index-graph.d.mts +1 -0
- package/dist/storage/index-graph.mjs +29 -5
- package/dist/storage/index-layers.d.mts +1 -0
- package/dist/storage/index-layers.mjs +5 -2
- package/dist/storage/index-reach.mjs +7 -5
- package/dist/storage/index-remap.mjs +5 -5
- package/dist/storage/index-visible.mjs +16 -5
- package/dist/storage/lfs-pointers.d.mts +5 -5
- package/dist/storage/lfs-pointers.mjs +37 -11
- package/dist/storage/links.mjs +3 -3
- package/dist/storage/loose.mjs +4 -1
- package/dist/storage/memory-budget.mjs +1 -1
- package/dist/storage/merge-fence.mjs +81 -19
- package/dist/storage/merge-most.mjs +1 -0
- package/dist/storage/merge-row.mjs +16 -4
- package/dist/storage/merge-stream.mjs +9 -6
- package/dist/storage/object-rows.mjs +17 -1
- package/dist/storage/pack-order.d.mts +1 -0
- package/dist/storage/pack-order.mjs +18 -1
- package/dist/storage/pack-receive.mjs +10 -6
- package/dist/storage/packs.mjs +58 -27
- package/dist/storage/prune-walk.mjs +5 -2
- package/dist/storage/prune.mjs +168 -70
- package/dist/storage/ready.d.mts +1 -1
- package/dist/storage/ready.mjs +12 -3
- package/dist/storage/receive-bounds.mjs +3 -2
- package/dist/storage/receive-state.mjs +1 -1
- package/dist/storage/repack-contained.mjs +22 -14
- package/dist/storage/repack.d.mts +1 -1
- package/dist/storage/repack.mjs +3 -2
- package/dist/storage/unpack.mjs +7 -0
- package/dist/storage/visible.mjs +3 -2
- package/dist/storage/walk.d.mts +1 -0
- package/dist/storage/walk.mjs +9 -5
- package/dist/storage/wants.mjs +17 -11
- package/dist/store/call-count.d.mts +31 -3
- package/dist/store/call-count.mjs +51 -20
- package/dist/store/errors.d.mts +7 -1
- package/dist/store/errors.mjs +7 -1
- package/dist/store/job-try.mjs +3 -1
- package/dist/store/records.mjs +26 -5
- package/dist/store/repo-record.mjs +36 -12
- package/dist/store/scopes.mjs +15 -2
- package/dist/sync/bound.d.mts +1 -1
- package/dist/sync/import.mjs +15 -3
- package/dist/sync/layer.d.mts +5 -1
- package/dist/sync/layer.mjs +11 -9
- package/dist/sync/mirror.mjs +1 -1
- package/dist/sync/step.mjs +15 -15
- package/dist/topics/advance.mjs +11 -10
- package/dist/topics/layer.mjs +1 -1
- package/dist/topics/members.mjs +38 -9
- package/package.json +3 -3
- package/dist/engine/merge-base-walk.d.mts +0 -3
- package/dist/server/routes.d.mts +0 -32
- package/dist/server/routes.mjs +0 -69
- package/dist/sync/bridge.d.mts +0 -6
- package/dist/sync/bridge.mjs +0 -29
package/dist/sync/import.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { fail, gitError } from "../contracts/result.mjs";
|
|
2
2
|
import { openRepo } from "../core/access.mjs";
|
|
3
3
|
import { CoreParts, QueueParts } from "../core/parts.mjs";
|
|
4
|
+
import { creatingRefView } from "../core/ref-view.mjs";
|
|
4
5
|
import { createWith, repoCalls } from "../core/repos.mjs";
|
|
5
6
|
import { hostRecordOf } from "../store/catalogue.mjs";
|
|
6
7
|
import { importJobName } from "../store/records.mjs";
|
|
@@ -13,6 +14,16 @@ import { cancelKey, importEndDeletes, importRow, readImport } from "../core/impo
|
|
|
13
14
|
import * as Effect from "effect/Effect";
|
|
14
15
|
import * as Schema from "effect/Schema";
|
|
15
16
|
// src/sync/import.ts
|
|
17
|
+
/**
|
|
18
|
+
* An importer who doesn't read every private pattern, refused for good (#2103): an import writes
|
|
19
|
+
* the repo's whole history, so who starts it sees the whole repo. `import` refuses one before it
|
|
20
|
+
* records anything, and each step asks again, as a view may narrow between them. Names no pattern.
|
|
21
|
+
*/
|
|
22
|
+
const partialImporter = () => gitError("NOT_ALLOWED", "An import into a repo with private branches needs an importer who reads them all", { hint: "Import as a caller who reads every private pattern" });
|
|
23
|
+
/** `caller`, refused as `partialImporter` unless their view of the repo `name` will be is whole. */
|
|
24
|
+
const wholeImporter = /* @__PURE__ */ Effect.fnUntraced(function* (caller, name) {
|
|
25
|
+
if (!(yield* creatingRefView(caller, name)).whole) return yield* Effect.fail(partialImporter());
|
|
26
|
+
});
|
|
16
27
|
/** The longest `import` waits between reads of the import's record. */
|
|
17
28
|
const pollMost = 2e3;
|
|
18
29
|
/** `sync.import`'s one key in each repo's scope. */
|
|
@@ -117,10 +128,11 @@ const importWith = /* @__PURE__ */ Effect.fnUntraced(function* (bound, input) {
|
|
|
117
128
|
source.repo
|
|
118
129
|
],
|
|
119
130
|
put: [importRow(startRow(bound, input, by))],
|
|
120
|
-
jobs: [bound.importJob.
|
|
131
|
+
jobs: [bound.importJob.encodedJob({
|
|
121
132
|
key: importJobKey,
|
|
122
133
|
data
|
|
123
|
-
})]
|
|
134
|
+
})],
|
|
135
|
+
check: (name) => wholeImporter(caller, name)
|
|
124
136
|
});
|
|
125
137
|
return yield* awaited(bound, input, internalId).pipe(Effect.mapError(afterWrites));
|
|
126
138
|
});
|
|
@@ -146,4 +158,4 @@ const cancelWith = /* @__PURE__ */ Effect.fnUntraced(function* (_bound, input) {
|
|
|
146
158
|
delete: importEndDeletes(read.row)
|
|
147
159
|
})).pipe(Effect.flatMap((committed) => committed.ok ? Effect.void : fail("UNAVAILABLE", `Other writes moved '${input.repo}'`, { hint: "Cancel again" })));
|
|
148
160
|
});
|
|
149
|
-
export { cancelWith, importJobKey, importWith };
|
|
161
|
+
export { cancelWith, importJobKey, importWith, partialImporter };
|
package/dist/sync/layer.d.mts
CHANGED
|
@@ -5,5 +5,9 @@ import { SyncBase } from "../core/parts.mjs";
|
|
|
5
5
|
import "./bound.mjs";
|
|
6
6
|
import * as HttpClient from "effect/http/HttpClient";
|
|
7
7
|
import * as Layer from "effect/Layer";
|
|
8
|
-
/**
|
|
8
|
+
/**
|
|
9
|
+
* Import and mirroring: registers sync and builds both jobs before Git seals its registry. Its
|
|
10
|
+
* provider calls go through the host's `HttpClient`, one with no retry middleware, since each
|
|
11
|
+
* request counts against its try's budget and sync's own retries sit above the charge.
|
|
12
|
+
*/
|
|
9
13
|
export declare const layer: (options: SyncLayerOptions) => Layer.Layer<Sync, GitError, Git | SyncBase | HttpClient.HttpClient>;
|
package/dist/sync/layer.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { fail } from "../contracts/result.mjs";
|
|
|
3
3
|
import { ImportJobData, MirrorJobData, Sync } from "../contracts/sync.mjs";
|
|
4
4
|
import { SyncBase } from "../core/parts.mjs";
|
|
5
5
|
import { withAudienceMemo } from "../core/ref-view.mjs";
|
|
6
|
-
import {
|
|
6
|
+
import { CallBudget } from "../store/call-count.mjs";
|
|
7
7
|
import { importJobName, mirrorJobName } from "../store/records.mjs";
|
|
8
8
|
import { importTryTimeout } from "../storage/receive-bounds.mjs";
|
|
9
9
|
import { SyncState, importLimits } from "./bound.mjs";
|
|
@@ -37,9 +37,7 @@ const layerWith = (options, limits) => Layer.effectContext(Effect.gen(function*
|
|
|
37
37
|
}
|
|
38
38
|
const base = yield* SyncBase;
|
|
39
39
|
const registration = yield* register({ name: "sync" });
|
|
40
|
-
const http = yield* HttpClient.HttpClient;
|
|
41
|
-
const importJob = gitJob(Import, () => importTry(bound), { onFailure: (_data, failure) => importFailed(bound, failure) });
|
|
42
|
-
const mirrorJob = gitJob(Mirror, (data) => mirrorTry(bound, data));
|
|
40
|
+
const http = CallBudget.charged(yield* HttpClient.HttpClient);
|
|
43
41
|
const bound = {
|
|
44
42
|
needs: Context.add(base.needs, HttpClient.HttpClient, http),
|
|
45
43
|
providers,
|
|
@@ -48,11 +46,11 @@ const layerWith = (options, limits) => Layer.effectContext(Effect.gen(function*
|
|
|
48
46
|
...limits,
|
|
49
47
|
publishBatch: Math.min(limits.publishBatch, base.pushRefsMost)
|
|
50
48
|
},
|
|
51
|
-
importJob,
|
|
52
|
-
mirrorJob
|
|
49
|
+
importJob: Import,
|
|
50
|
+
mirrorJob: Mirror
|
|
53
51
|
};
|
|
54
|
-
yield* registration.addJob(
|
|
55
|
-
yield* registration.addJob(
|
|
52
|
+
yield* registration.addJob(Import, () => importTry(bound), { onFailure: (_data, failure) => importFailed(bound, failure) });
|
|
53
|
+
yield* registration.addJob(Mirror, (data) => mirrorTry(bound, data));
|
|
56
54
|
const run = (effect) => base.through(withAudienceMemo(Effect.provide(effect, bound.needs)));
|
|
57
55
|
return Context.make(SyncState, bound).pipe(Context.add(Sync, {
|
|
58
56
|
import: (input) => run(importWith(bound, input)),
|
|
@@ -63,6 +61,10 @@ const layerWith = (options, limits) => Layer.effectContext(Effect.gen(function*
|
|
|
63
61
|
publishImported: (input) => run(publishWith(bound, input))
|
|
64
62
|
}));
|
|
65
63
|
}));
|
|
66
|
-
/**
|
|
64
|
+
/**
|
|
65
|
+
* Import and mirroring: registers sync and builds both jobs before Git seals its registry. Its
|
|
66
|
+
* provider calls go through the host's `HttpClient`, one with no retry middleware, since each
|
|
67
|
+
* request counts against its try's budget and sync's own retries sit above the charge.
|
|
68
|
+
*/
|
|
67
69
|
const layer = (options) => layerWith(options, importLimits);
|
|
68
70
|
export { layer, layerWith };
|
package/dist/sync/mirror.mjs
CHANGED
|
@@ -106,7 +106,7 @@ const mirrorWith = /* @__PURE__ */ Effect.fnUntraced(function* (bound, input) {
|
|
|
106
106
|
};
|
|
107
107
|
const bytes = jsonBytes(mirrorRow(ref, largest));
|
|
108
108
|
if (bytes > mirrorLimits.rowBytes) return yield* fail("INVALID_ARGUMENT", `The mirror of '${ref}' takes ${bytes} bytes: a mirror takes at most ${mirrorLimits.rowBytes}`, { hint: "Name a shorter destination or ref" });
|
|
109
|
-
const job = bound.mirrorJob.
|
|
109
|
+
const job = bound.mirrorJob.encodedJob({
|
|
110
110
|
key: ref,
|
|
111
111
|
data: { ref }
|
|
112
112
|
});
|
package/dist/sync/step.mjs
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import "../contracts/ids.mjs";
|
|
2
2
|
import { gitError, gitErrorFrom } from "../contracts/result.mjs";
|
|
3
|
+
import { partialImporter } from "./import.mjs";
|
|
3
4
|
import { importedPullRefs } from "../contracts/sync.mjs";
|
|
4
5
|
import { push } from "../core/push.mjs";
|
|
5
6
|
import { refusedLead } from "../client/answer.mjs";
|
|
6
7
|
import { isRefName } from "../core/names.mjs";
|
|
7
|
-
import { utf8 } from "../protocol/bytes/text.mjs";
|
|
8
|
+
import { cutWords, utf8 } from "../protocol/bytes/text.mjs";
|
|
8
9
|
import { negotiate } from "../client/negotiate.mjs";
|
|
9
10
|
import { discover, fetchTerms, remoteRefsAndHeadOf } from "../client/remote.mjs";
|
|
10
11
|
import { objectsFace, oneShotReads, scopedReceiveStep } from "../storage/calls.mjs";
|
|
@@ -124,10 +125,13 @@ const finalRefusal = (failure) => {
|
|
|
124
125
|
if (failure.code === "RESOURCE_EXHAUSTED" && failure.context?.reason === "object-too-large") return failure;
|
|
125
126
|
if (failure.code !== "INVALID_ARGUMENT") return void 0;
|
|
126
127
|
const { context } = failure;
|
|
127
|
-
if (context?.reason === "fsck")
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
128
|
+
if (context?.reason === "fsck") {
|
|
129
|
+
const named = context.msgId === "duplicateEntries";
|
|
130
|
+
return gitErrorFrom(failure, {
|
|
131
|
+
message: named ? failure.message : `An object of the import fails Git's ${context.msgId} check`,
|
|
132
|
+
hint: `An object in the source's history fails Git's checks (${context.msgId}), so this repo can't be imported as it is. Delete this repo to clear it.`
|
|
133
|
+
});
|
|
134
|
+
}
|
|
131
135
|
if (context?.reason === "ofs-delta") return gitErrorFrom(failure, { hint: "The remote sent OFS_DELTA entries without being asked, so this repo can't be imported from that remote. Delete this repo to clear it." });
|
|
132
136
|
if (finalReasons.has(context?.reason)) return failure;
|
|
133
137
|
};
|
|
@@ -138,11 +142,6 @@ const refusedWordsMost = 512;
|
|
|
138
142
|
* bytes as UTF-8, well under a record's 1 MiB, so no refusal's words keep a record from failing.
|
|
139
143
|
*/
|
|
140
144
|
const failedMessageMost = 1024;
|
|
141
|
-
/** `text`'s first `most` UTF-16 units, the first half of a surrogate pair the cut splits dropped. */
|
|
142
|
-
const cutWords = (text, most) => {
|
|
143
|
-
const cut = text.slice(0, most);
|
|
144
|
-
return /[\uD800-\uDBFF]$/u.test(cut) ? cut.slice(0, -1) : cut;
|
|
145
|
-
};
|
|
146
145
|
/**
|
|
147
146
|
* Whether a remote's words may be shown: the import reached `remote` through the platform's own
|
|
148
147
|
* `fetch` with no credential, its own or in its URL. A remote's words may echo a credential, and a
|
|
@@ -377,7 +376,7 @@ const stepAfter = (step, bytes, most) => bytes < most / 4 ? Math.min(step * 2, s
|
|
|
377
376
|
* root is no longer one needs them, in its pack or the repo, whatever its answer claims, so no ref
|
|
378
377
|
* is published on a commit whose parents the repo lacks.
|
|
379
378
|
*/
|
|
380
|
-
const fetchSegment = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, row, cut, remote
|
|
379
|
+
const fetchSegment = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, row, cut, remote) {
|
|
381
380
|
const { bound, context } = attempt;
|
|
382
381
|
const most = bound.limits.packBytes;
|
|
383
382
|
const { store } = yield* CoreParts;
|
|
@@ -406,7 +405,7 @@ const fetchSegment = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, row,
|
|
|
406
405
|
request,
|
|
407
406
|
objects: oneShotReads(objects),
|
|
408
407
|
listed: opened.listed,
|
|
409
|
-
tips: [...new Set(
|
|
408
|
+
tips: [...new Set(opened.refs.values())],
|
|
410
409
|
held: row.deepest > 0 ? tips : []
|
|
411
410
|
}).pipe(Effect.mapError(fromRemote("negotiate a fetch")));
|
|
412
411
|
yield* report(context, "receive", row);
|
|
@@ -764,15 +763,16 @@ const stepIn = /* @__PURE__ */ Effect.fnUntraced(function* (attempt) {
|
|
|
764
763
|
const viewed = yield* importerView(attempt, row.by);
|
|
765
764
|
if (viewed === void 0) return void 0;
|
|
766
765
|
if (viewed.kind === "refused") return yield* forGood(viewed.error);
|
|
767
|
-
return yield*
|
|
766
|
+
if (!viewed.view.whole) return yield* forGood(partialImporter());
|
|
767
|
+
return yield* asSync(stepAs(attempt, read, row));
|
|
768
768
|
});
|
|
769
769
|
/** The step the record says is next, once who started the import is asked again. */
|
|
770
|
-
const stepAs = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, read, row
|
|
770
|
+
const stepAs = /* @__PURE__ */ Effect.fnUntraced(function* (attempt, read, row) {
|
|
771
771
|
if (row.receiving !== void 0) return yield* resumed(attempt, row, row.receiving, read.cut);
|
|
772
772
|
if (row.copied) return yield* publish(attempt, row);
|
|
773
773
|
const remote = yield* remoteOf(attempt.bound, row.source, attempt.context.signal, "read");
|
|
774
774
|
if (row.tipPages === void 0) return yield* listTips(attempt, read.version, row, remote);
|
|
775
|
-
return yield* fetchSegment(attempt, row, read.cut, remote
|
|
775
|
+
return yield* fetchSegment(attempt, row, read.cut, remote);
|
|
776
776
|
});
|
|
777
777
|
/**
|
|
778
778
|
* Who started the import, asked again as they are now, as `viewAgainOf` asks: their view of the
|
package/dist/topics/advance.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { millis } from "../contracts/promises.mjs";
|
|
|
2
2
|
import { hostCall, hostEffect } from "../auth/host-function.mjs";
|
|
3
3
|
import { checkPublish } from "../queue/advance.mjs";
|
|
4
4
|
import { advanceRow } from "../store/queue-jobs.mjs";
|
|
5
|
-
import {
|
|
5
|
+
import { jobParts } from "../store/job-try.mjs";
|
|
6
6
|
import { storeCall } from "../store/errors.mjs";
|
|
7
7
|
import { untilAborted } from "../store/crossing.mjs";
|
|
8
8
|
import { repoScope, topicScope } from "../store/scopes.mjs";
|
|
@@ -12,7 +12,8 @@ import { TopicsHost, saveMargin } from "./host.mjs";
|
|
|
12
12
|
import { addMember, candidateAt, memberRead, releaseMember, reserveMember } from "./members.mjs";
|
|
13
13
|
import { unwaited } from "./rows.mjs";
|
|
14
14
|
import { commitTopic, currentSet, durationWords, entriesOf, failureOf, readTopic, setKeyOf, topicOf } from "./topic.mjs";
|
|
15
|
-
import {
|
|
15
|
+
import { QueueParts, overStore } from "../core/parts.mjs";
|
|
16
|
+
import { checkedAnswer, plainAnswer } from "../core/rules/context.mjs";
|
|
16
17
|
import * as Clock$1 from "effect/Clock";
|
|
17
18
|
import * as Effect from "effect/Effect";
|
|
18
19
|
import * as Result from "effect/Result";
|
|
@@ -104,8 +105,7 @@ const requiredOf = /* @__PURE__ */ Effect.fnUntraced(function* (host, read) {
|
|
|
104
105
|
topic: read.id,
|
|
105
106
|
entries: entriesOf(read.row)
|
|
106
107
|
};
|
|
107
|
-
const
|
|
108
|
-
const asked = yield* Effect.result(hostCall(reports, "topics.required", {}, () => required(question)));
|
|
108
|
+
const asked = yield* Effect.result(hostCall("topics.required", {}, () => required(question)));
|
|
109
109
|
if (Result.isSuccess(asked)) return asked.success;
|
|
110
110
|
yield* block(read, hostError(asked.failure));
|
|
111
111
|
});
|
|
@@ -287,9 +287,11 @@ const beforeDecision = /* @__PURE__ */ Effect.fnUntraced(function* (host, read,
|
|
|
287
287
|
yield* block(read, ended);
|
|
288
288
|
return "again";
|
|
289
289
|
}
|
|
290
|
+
const waited = row.waitingSince ?? row.heldSince;
|
|
291
|
+
const freeze = waited !== void 0 && now - waited >= millis(waitTimeout) / 2;
|
|
290
292
|
if (row.state === "reserving") {
|
|
291
293
|
for (const member of inOrder(row.members)) {
|
|
292
|
-
const reserved = yield* reserveMember(member, { topic: read.id });
|
|
294
|
+
const reserved = yield* reserveMember(member, { topic: read.id }, freeze);
|
|
293
295
|
if (reserved.held && row.heldSince !== void 0) continue;
|
|
294
296
|
if (reserved.held) return yield* heldFrom(read, reserved.since);
|
|
295
297
|
if (!sameWait(reserved.waiting, row.waitingOn)) {
|
|
@@ -590,8 +592,7 @@ const prepareStep = /* @__PURE__ */ Effect.fnUntraced(function* (host, job) {
|
|
|
590
592
|
key: set,
|
|
591
593
|
attempt: job.attempt
|
|
592
594
|
};
|
|
593
|
-
const
|
|
594
|
-
const answered = yield* hostEffect(reports, "topics.prepare", {}, Effect.suspend(() => prepare.handler(input)), { timeout: prepare.timeout }).pipe(Effect.result);
|
|
595
|
+
const answered = yield* hostEffect("topics.prepare", {}, checkedAnswer("The topic's prepare", plainAnswer, () => prepare.handler(input)), { timeout: prepare.timeout }).pipe(Effect.result);
|
|
595
596
|
answer = Result.isFailure(answered) ? {
|
|
596
597
|
kind: "failed",
|
|
597
598
|
failure: hostError(answered.failure)
|
|
@@ -679,9 +680,9 @@ const topicJobs = (host) => {
|
|
|
679
680
|
timeout: (host.prepare?.timeout ?? 0) + saveMargin
|
|
680
681
|
});
|
|
681
682
|
return [
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
683
|
+
jobParts(AdvanceJob, (data) => overCore(host, data, (job) => advance(host, job))),
|
|
684
|
+
jobParts(PrepareJob, (data) => overCore(host, data, (job) => prepareStep(host, job)), { onFailure: (data) => prepareFailed(host, data) }),
|
|
685
|
+
jobParts(ReportTimeoutJob, (data) => overCore(host, data, (job) => reportTimeoutStep(host, job)))
|
|
685
686
|
];
|
|
686
687
|
};
|
|
687
688
|
export { addMissing, block, inOrder, outOfTries, pollEvery, saysFailed, topicJobs };
|
package/dist/topics/layer.mjs
CHANGED
|
@@ -42,7 +42,7 @@ const topicsRegistration = /* @__PURE__ */ Effect.fnUntraced(function* (registra
|
|
|
42
42
|
remove: (id, input, by) => Effect.provideContext(acting(by, over(by).remove(id, input)), needs),
|
|
43
43
|
report: (id, input, by) => Effect.provideContext(acting(by, over(by).report(id, input)), needs)
|
|
44
44
|
};
|
|
45
|
-
for (const job of topicJobs(host)) yield* registration.addJob
|
|
45
|
+
for (const job of topicJobs(host)) yield* job(registration.addJob);
|
|
46
46
|
yield* (yield* TopicsBase).attach(service);
|
|
47
47
|
return Topics.of(service);
|
|
48
48
|
});
|
package/dist/topics/members.mjs
CHANGED
|
@@ -98,16 +98,20 @@ const memberWrite = (member, plan) => queueWrite(Effect.gen(function* () {
|
|
|
98
98
|
* Reserves `member`'s target for `own`: `held` once it's the topic's, `since` the commit that took
|
|
99
99
|
* it, which saved that time with the reservation, else what it waits on first. Not yet while
|
|
100
100
|
* another live topic holds it, or while a candidate or a hold is open on it, which the reservation
|
|
101
|
-
* would stop from publishing: the queue opens none past a waiting member, so the target drains.
|
|
102
|
-
*
|
|
101
|
+
* would stop from publishing: the queue opens none past a waiting member, so the target drains.
|
|
102
|
+
* With `freeze`, once the member has waited half its `waitTimeout`, candidates open on the target
|
|
103
|
+
* freeze it for `own`, unless another live topic froze it first: its queue opens none in another
|
|
104
|
+
* lane or ahead of the member by priority, so it drains within a check (Q1159). A reservation of
|
|
105
|
+
* an ended topic is free, and taken over.
|
|
103
106
|
*/
|
|
104
|
-
const reserveMember = (member, own) => memberWrite(member, (state) => Effect.gen(function* () {
|
|
105
|
-
const { reserved, open, holds, stalled } = state.row;
|
|
107
|
+
const reserveMember = (member, own, freeze = false) => memberWrite(member, (state) => Effect.gen(function* () {
|
|
108
|
+
const { reserved, open, holds, stalled, frozen } = state.row;
|
|
106
109
|
if (reserved?.topic === own.topic) return { answer: {
|
|
107
110
|
held: true,
|
|
108
111
|
since: reserved.since
|
|
109
112
|
} };
|
|
110
|
-
const
|
|
113
|
+
const { store } = yield* CoreParts;
|
|
114
|
+
const taken = reserved !== void 0 && (yield* isLive(store, reserved));
|
|
111
115
|
const at = {
|
|
112
116
|
repo: member.repo,
|
|
113
117
|
target: member.target
|
|
@@ -127,14 +131,35 @@ const reserveMember = (member, own) => memberWrite(member, (state) => Effect.gen
|
|
|
127
131
|
hold
|
|
128
132
|
}
|
|
129
133
|
} };
|
|
130
|
-
|
|
134
|
+
const waits = { answer: {
|
|
131
135
|
held: false,
|
|
132
136
|
waiting: at
|
|
133
137
|
} };
|
|
138
|
+
if (stalled === true) return waits;
|
|
139
|
+
if (open.length > 0) {
|
|
140
|
+
const mine = frozen?.topic === own.topic;
|
|
141
|
+
const other = frozen !== void 0 && !mine && (yield* isLive(store, frozen));
|
|
142
|
+
if (!freeze || mine || other) return waits;
|
|
143
|
+
const now = yield* Clock$1.currentTimeMillis;
|
|
144
|
+
const plan = new QueuePlan(state, now);
|
|
145
|
+
plan.setTarget({
|
|
146
|
+
...plan.row,
|
|
147
|
+
frozen: {
|
|
148
|
+
...own,
|
|
149
|
+
next: plan.next
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
return {
|
|
153
|
+
...waits,
|
|
154
|
+
plan
|
|
155
|
+
};
|
|
156
|
+
}
|
|
134
157
|
const since = yield* Clock$1.currentTimeMillis;
|
|
135
158
|
const plan = new QueuePlan(state, since);
|
|
159
|
+
const { frozen: _ended, ...unfrozen } = plan.row;
|
|
160
|
+
const row = frozen?.topic === own.topic ? unfrozen : plan.row;
|
|
136
161
|
plan.setTarget({
|
|
137
|
-
...
|
|
162
|
+
...row,
|
|
138
163
|
reserved: {
|
|
139
164
|
...own,
|
|
140
165
|
since
|
|
@@ -150,8 +175,8 @@ const reserveMember = (member, own) => memberWrite(member, (state) => Effect.gen
|
|
|
150
175
|
};
|
|
151
176
|
}));
|
|
152
177
|
/**
|
|
153
|
-
* Lets go of what `topic` holds on `member`'s target: its reservation,
|
|
154
|
-
* still open, which leaves the queue `removed` and frees every lane it held.
|
|
178
|
+
* Lets go of what `topic` holds on `member`'s target: its reservation, its freeze, and its
|
|
179
|
+
* member's entry, if still open, which leaves the queue `removed` and frees every lane it held.
|
|
155
180
|
*/
|
|
156
181
|
const releaseMember = /* @__PURE__ */ Effect.fnUntraced(function* (member, topic) {
|
|
157
182
|
const found = (yield* memberRead(member))?.state;
|
|
@@ -167,6 +192,10 @@ const releaseMember = /* @__PURE__ */ Effect.fnUntraced(function* (member, topic
|
|
|
167
192
|
const { reserved: _released, ...free } = plan.row;
|
|
168
193
|
plan.setTarget(free);
|
|
169
194
|
}
|
|
195
|
+
if (plan.row.frozen?.topic === topic.topic) {
|
|
196
|
+
const { frozen: _released, ...free } = plan.row;
|
|
197
|
+
plan.setTarget(free);
|
|
198
|
+
}
|
|
170
199
|
const id = owned.entry;
|
|
171
200
|
const entry = id === void 0 ? void 0 : state.entries.get(id);
|
|
172
201
|
const own = entry !== void 0 && isOpen(entry) && entry.topic?.topic === topic.topic;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ref0/git",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.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",
|
|
@@ -62,12 +62,12 @@
|
|
|
62
62
|
}
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"@ref0/infra": "0.
|
|
65
|
+
"@ref0/infra": "0.9.0",
|
|
66
66
|
"pako": "2.1.0"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
69
|
"@effect/vitest": "4.1.7",
|
|
70
|
-
"@ref0/xdiff-wasm": "0.
|
|
70
|
+
"@ref0/xdiff-wasm": "0.9.0",
|
|
71
71
|
"effect": "4.1.7",
|
|
72
72
|
"vite-plus": "1.8.0",
|
|
73
73
|
"vitest": "5.1.1"
|
package/dist/server/routes.d.mts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { Policy } from "../auth/policy.mjs";
|
|
2
|
-
import { LfsFeature } from "../contracts/lfs.mjs";
|
|
3
|
-
import { ObjectsFactory } from "../contracts/objects.mjs";
|
|
4
|
-
import { GitServerOptions, ServerCalls } from "../contracts/server.mjs";
|
|
5
|
-
import { EffectCalls } from "../contracts/services.mjs";
|
|
6
|
-
import { Bucket, CallLimits, JobQueue, Records } from "@ref0/infra";
|
|
7
|
-
import * as Context from "effect/Context";
|
|
8
|
-
import * as Layer from "effect/Layer";
|
|
9
|
-
import * as HttpRouter from "effect/http/HttpRouter";
|
|
10
|
-
/** What `GitServer.routes` takes: `createGitServer`'s options but those its services give. */
|
|
11
|
-
export interface GitRoutesOptions<Objects extends ObjectsFactory = ObjectsFactory, Lfs extends LfsFeature | undefined = LfsFeature | undefined> extends Omit<GitServerOptions, 'adapter' | 'auth' | 'authorize' | 'objects' | 'lfs'> {
|
|
12
|
-
readonly objects: Objects;
|
|
13
|
-
readonly lfs?: Lfs;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* What the routes need: the host's records, jobs, call limits and `Policy`, and a bucket unless
|
|
17
|
-
* `loose()` without `lfs()`. `Auth` is optional, read if it's there. Any other service the host
|
|
18
|
-
* gives, as `BucketUploads`, the server takes too.
|
|
19
|
-
*/
|
|
20
|
-
export type GitRoutesServices<Objects extends ObjectsFactory, Lfs extends LfsFeature | undefined = undefined> = HttpRouter.HttpRouter | Records.Records | JobQueue.JobQueue | CallLimits.CallLimits | Policy | (Objects extends ObjectsFactory<false> ? [Lfs] extends [undefined] ? never : Bucket.Bucket : Bucket.Bucket);
|
|
21
|
-
/**
|
|
22
|
-
* Git's routes on a host's `HttpRouter`: the server `createGitServer` makes from `options`, over
|
|
23
|
-
* the host's services, its `Records`, `JobQueue`, `CallLimits` and `Bucket`, deciding with its `Policy` and `Auth`.
|
|
24
|
-
* Every URL under `basePath` answers as `createRestHandler`'s `fetch` does: REST's, then Git's
|
|
25
|
-
* protocol, then a JSON `404`. The server closes with the Layer.
|
|
26
|
-
*/
|
|
27
|
-
declare const routes: <Objects extends ObjectsFactory, Lfs extends LfsFeature | undefined = undefined>(options: GitRoutesOptions<Objects, Lfs>) => Layer.Layer<never, never, GitRoutesServices<Objects, Lfs>>;
|
|
28
|
-
/** The server's calls as Effects, and its routes as a Layer a host's router serves. */
|
|
29
|
-
export declare const GitServer: Context.Service<EffectCalls<ServerCalls, never>, EffectCalls<ServerCalls, never>> & {
|
|
30
|
-
routes: typeof routes;
|
|
31
|
-
};
|
|
32
|
-
export {};
|
package/dist/server/routes.mjs
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { Auth } from "../auth/auth.mjs";
|
|
2
|
-
import { hostAuth, hostPolicy } from "../auth/bridge.mjs";
|
|
3
|
-
import { Policy } from "../auth/policy.mjs";
|
|
4
|
-
import { createRestHandler } from "../rest/handler.mjs";
|
|
5
|
-
import { serverWith } from "./server.mjs";
|
|
6
|
-
import * as Effect from "effect/Effect";
|
|
7
|
-
import * as Option from "effect/Option";
|
|
8
|
-
import { Bucket } from "@ref0/infra";
|
|
9
|
-
import * as Context from "effect/Context";
|
|
10
|
-
import * as Layer from "effect/Layer";
|
|
11
|
-
import * as HttpServerResponse from "effect/http/HttpServerResponse";
|
|
12
|
-
import * as HttpRouter from "effect/http/HttpRouter";
|
|
13
|
-
import * as HttpServerRequest from "effect/http/HttpServerRequest";
|
|
14
|
-
// src/server/routes.ts
|
|
15
|
-
/** Every path under `base`, as the router matches it. */
|
|
16
|
-
const pathUnder = (base) => {
|
|
17
|
-
const trimmed = base.replace(/^\/+|\/+$/g, "");
|
|
18
|
-
return trimmed === "" ? "*" : `/${trimmed}/*`;
|
|
19
|
-
};
|
|
20
|
-
/** Objects that need no bucket, as `needsBucket` says: `createGitServer` checks it again. */
|
|
21
|
-
const looseOnly = (objects) => {
|
|
22
|
-
if (objects.needsBucket) throw new TypeError("GitServer.routes' objects need a Bucket: provide one");
|
|
23
|
-
return {
|
|
24
|
-
...objects,
|
|
25
|
-
needsBucket: false
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
/** The options of a server with a bucket, with `lfs` only when the host passed `lfs()`. */
|
|
29
|
-
const withBucket = ({ lfs, ...rest }) => lfs === void 0 ? rest : {
|
|
30
|
-
...rest,
|
|
31
|
-
lfs
|
|
32
|
-
};
|
|
33
|
-
/** The options of a server with no bucket, which `lfs()` needs: `createGitServer` checks it again. */
|
|
34
|
-
const withoutLfs = ({ lfs, ...rest }) => {
|
|
35
|
-
if (lfs !== void 0) throw new TypeError("GitServer.routes' lfs() needs a Bucket: provide one");
|
|
36
|
-
return rest;
|
|
37
|
-
};
|
|
38
|
-
/**
|
|
39
|
-
* Git's routes on a host's `HttpRouter`: the server `createGitServer` makes from `options`, over
|
|
40
|
-
* the host's services, its `Records`, `JobQueue`, `CallLimits` and `Bucket`, deciding with its `Policy` and `Auth`.
|
|
41
|
-
* Every URL under `basePath` answers as `createRestHandler`'s `fetch` does: REST's, then Git's
|
|
42
|
-
* protocol, then a JSON `404`. The server closes with the Layer.
|
|
43
|
-
*/
|
|
44
|
-
const routes = (options) => HttpRouter.use((router) => Effect.gen(function* () {
|
|
45
|
-
const context = yield* Effect.context();
|
|
46
|
-
const adapter = Layer.succeedContext(context);
|
|
47
|
-
const bucket = Context.getOrUndefined(context, Bucket.Bucket);
|
|
48
|
-
const policy = yield* Policy;
|
|
49
|
-
const auth = Option.getOrUndefined(yield* Effect.serviceOption(Auth));
|
|
50
|
-
const deciders = (reports) => ({
|
|
51
|
-
policy: hostPolicy(policy, reports),
|
|
52
|
-
auth: hostAuth(auth, reports)
|
|
53
|
-
});
|
|
54
|
-
const made = () => bucket === void 0 ? serverWith({
|
|
55
|
-
...withoutLfs(options),
|
|
56
|
-
objects: looseOnly(options.objects),
|
|
57
|
-
adapter
|
|
58
|
-
}, deciders) : serverWith({
|
|
59
|
-
...withBucket(options),
|
|
60
|
-
adapter: Layer.merge(adapter, Layer.succeed(Bucket.Bucket, bucket))
|
|
61
|
-
}, deciders);
|
|
62
|
-
const git = yield* Effect.acquireRelease(Effect.sync(made), (made) => Effect.promise(() => made.close()));
|
|
63
|
-
const rest = createRestHandler(git);
|
|
64
|
-
const serve = (request) => Effect.orDie(HttpServerRequest.toWeb(request)).pipe(Effect.flatMap((web) => Effect.promise(() => rest.fetch(web))), Effect.map((response) => HttpServerResponse.raw(response)));
|
|
65
|
-
yield* router.add("*", pathUnder(options.basePath ?? ""), serve);
|
|
66
|
-
}));
|
|
67
|
-
/** The server's calls as Effects, and its routes as a Layer a host's router serves. */
|
|
68
|
-
const GitServer = Object.assign(Context.Service("@ref0/git/GitServer"), { routes });
|
|
69
|
-
export { GitServer };
|
package/dist/sync/bridge.d.mts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { GitError, Result } from "../contracts/result.mjs";
|
|
2
|
-
import { Sync } from "../contracts/sync.mjs";
|
|
3
|
-
import { GitServer } from "../contracts/server.mjs";
|
|
4
|
-
import * as Effect from "effect/Effect";
|
|
5
|
-
/** The temporary Promise bridge for createGitServer's worlds; step 2c-1b deletes it. */
|
|
6
|
-
export declare const syncOn: <A>(git: GitServer, effect: Effect.Effect<A, GitError, Sync>, signal?: AbortSignal) => Promise<Result<A>>;
|
package/dist/sync/bridge.mjs
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { Sync } from "../contracts/sync.mjs";
|
|
2
|
-
import { fail } from "../contracts/result.mjs";
|
|
3
|
-
import { seamOf } from "../core/seam.mjs";
|
|
4
|
-
import { exitOn, resultIn, uncounted } from "../store/crossing.mjs";
|
|
5
|
-
import { openDoor, throughBridge } from "../store/promises.mjs";
|
|
6
|
-
import * as Effect from "effect/Effect";
|
|
7
|
-
import * as Option from "effect/Option";
|
|
8
|
-
import * as Exit from "effect/Exit";
|
|
9
|
-
import * as Result from "effect/Result";
|
|
10
|
-
// src/sync/bridge.ts
|
|
11
|
-
/** The temporary Promise bridge for createGitServer's worlds; step 2c-1b deletes it. */
|
|
12
|
-
const syncOn = (git, effect, signal) => {
|
|
13
|
-
const seam = seamOf(git);
|
|
14
|
-
const call = Effect.flatMap(Effect.serviceOption(Sync), (sync) => Option.isSome(sync) ? Effect.provideService(effect, Sync, sync.value) : noSync());
|
|
15
|
-
return resultIn(throughBridge(seam?.door ?? openDoor)(Effect.gen(function* () {
|
|
16
|
-
yield* seam?.parts ?? Effect.void;
|
|
17
|
-
const exit = yield* Effect.promise((stopped) => exitOn(git.runtime, Effect.result(call), uncounted("a host's sync call: no Git request"), stopped));
|
|
18
|
-
if (Exit.isFailure(exit)) return yield* Effect.orDie(Effect.failCause(exit.cause));
|
|
19
|
-
const result = exit.value;
|
|
20
|
-
return yield* Result.isSuccess(result) ? Effect.succeed(result.success) : Effect.fail(result.failure);
|
|
21
|
-
})), uncounted("a host's sync call: no Git request"), signal);
|
|
22
|
-
};
|
|
23
|
-
/** The feature-off answer, read before a world can call the feature. */
|
|
24
|
-
const noSync = () => fail("NOT_FOUND", "This server doesn't offer import or mirroring", {
|
|
25
|
-
hint: "This server doesn't offer import or mirroring",
|
|
26
|
-
hostHint: "Compose Sync.layer({ providers }) with Git.layer to offer import or mirroring",
|
|
27
|
-
context: { reason: "no-sync" }
|
|
28
|
-
});
|
|
29
|
-
export { syncOn };
|