@ref0/git 0.0.0 → 0.2.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/LICENSE +202 -0
- package/dist/access/private-refs.d.mts +27 -0
- package/dist/access/private-refs.mjs +173 -0
- package/dist/access.d.mts +2 -0
- package/dist/access.mjs +1 -0
- package/dist/auth/access-jwt.d.mts +21 -0
- package/dist/auth/access-jwt.mjs +102 -0
- package/dist/auth/acting.mjs +15 -0
- package/dist/auth/authorize.d.mts +5 -0
- package/dist/auth/authorize.mjs +292 -0
- package/dist/auth/credentials.mjs +57 -0
- package/dist/auth/fences.d.mts +5 -0
- package/dist/auth/fences.mjs +65 -0
- package/dist/auth/grants.mjs +61 -0
- package/dist/auth/helpers.d.mts +17 -0
- package/dist/auth/helpers.mjs +25 -0
- package/dist/auth/host-function.d.mts +4 -0
- package/dist/auth/host-function.mjs +69 -0
- package/dist/auth/identify.d.mts +6 -0
- package/dist/auth/identify.mjs +97 -0
- package/dist/auth/token-rows.mjs +100 -0
- package/dist/auth/token-text.mjs +66 -0
- package/dist/auth/tokens.d.mts +10 -0
- package/dist/auth/tokens.mjs +347 -0
- package/dist/auth.d.mts +7 -0
- package/dist/auth.mjs +6 -0
- package/dist/client/answer.mjs +141 -0
- package/dist/client/client.d.mts +23 -0
- package/dist/client/client.mjs +51 -0
- package/dist/client/git-http.mjs +201 -0
- package/dist/client/helper-node.mjs +19 -0
- package/dist/client/local.mjs +160 -0
- package/dist/client/negotiate.mjs +170 -0
- package/dist/client/push-upload.mjs +53 -0
- package/dist/client/remote-helper.mjs +129 -0
- package/dist/client/remote.mjs +398 -0
- package/dist/client/run-remote-helper.d.mts +35 -0
- package/dist/client/run-remote-helper.mjs +259 -0
- package/dist/client/scrub.d.mts +18 -0
- package/dist/client/scrub.mjs +38 -0
- package/dist/client/transport.d.mts +2 -0
- package/dist/client/transport.mjs +211 -0
- package/dist/contracts/access.d.mts +87 -0
- package/dist/contracts/actors.d.mts +144 -0
- package/dist/contracts/blobs.d.mts +38 -0
- package/dist/contracts/calls-spent.d.mts +11 -0
- package/dist/contracts/calls-spent.mjs +150 -0
- package/dist/contracts/client.d.mts +90 -0
- package/dist/contracts/commits.d.mts +126 -0
- package/dist/contracts/engine.d.mts +134 -0
- package/dist/contracts/events.d.mts +276 -0
- package/dist/contracts/files.d.mts +75 -0
- package/dist/contracts/forks.d.mts +78 -0
- package/dist/contracts/grants.d.mts +60 -0
- package/dist/contracts/handlers.d.mts +10 -0
- package/dist/contracts/ids.d.mts +15 -0
- package/dist/contracts/ids.mjs +15 -0
- package/dist/contracts/lfs.d.mts +27 -0
- package/dist/contracts/merges.d.mts +33 -0
- package/dist/contracts/objects.d.mts +645 -0
- package/dist/contracts/objects.mjs +54 -0
- package/dist/contracts/operations.d.mts +133 -0
- package/dist/contracts/promises.d.mts +63 -0
- package/dist/contracts/push-uploads.d.mts +44 -0
- package/dist/contracts/queue.d.mts +401 -0
- package/dist/contracts/refs.d.mts +95 -0
- package/dist/contracts/remote.d.mts +50 -0
- package/dist/contracts/repos.d.mts +153 -0
- package/dist/contracts/result.d.mts +126 -0
- package/dist/contracts/result.mjs +34 -0
- package/dist/contracts/rules.d.mts +159 -0
- package/dist/contracts/server.d.mts +245 -0
- package/dist/contracts/services.d.mts +36 -0
- package/dist/contracts/services.mjs +13 -0
- package/dist/contracts/signin.d.mts +126 -0
- package/dist/contracts/store.d.mts +41 -0
- package/dist/contracts/sync.d.mts +210 -0
- package/dist/contracts/sync.mjs +8 -0
- package/dist/contracts/tags.d.mts +50 -0
- package/dist/contracts/tags.mjs +6 -0
- package/dist/contracts/tokens.d.mts +87 -0
- package/dist/contracts/tokens.mjs +15 -0
- package/dist/contracts/topics.d.mts +174 -0
- package/dist/contracts/trees.d.mts +84 -0
- package/dist/contracts/work.d.mts +31 -0
- package/dist/core/access.d.mts +22 -0
- package/dist/core/access.mjs +262 -0
- package/dist/core/ancestry.mjs +235 -0
- package/dist/core/clock.mjs +18 -0
- package/dist/core/events/deliver.mjs +468 -0
- package/dist/core/events/stream.d.mts +19 -0
- package/dist/core/events/stream.mjs +290 -0
- package/dist/core/forks.mjs +1027 -0
- package/dist/core/hooks/post-receive.mjs +204 -0
- package/dist/core/hooks/pre-receive.d.mts +5 -0
- package/dist/core/hooks/pre-receive.mjs +34 -0
- package/dist/core/index-job.mjs +198 -0
- package/dist/core/names.mjs +30 -0
- package/dist/core/objects/blobs.mjs +60 -0
- package/dist/core/objects/commit-writes.mjs +185 -0
- package/dist/core/objects/commits.mjs +172 -0
- package/dist/core/objects/files.mjs +211 -0
- package/dist/core/objects/lines.mjs +42 -0
- package/dist/core/objects/merges.mjs +83 -0
- package/dist/core/objects/peel.mjs +166 -0
- package/dist/core/objects/reading.mjs +284 -0
- package/dist/core/objects/tags.mjs +96 -0
- package/dist/core/objects/tree-edits.mjs +266 -0
- package/dist/core/objects/trees.mjs +229 -0
- package/dist/core/objects/writing.mjs +266 -0
- package/dist/core/own-writes.mjs +94 -0
- package/dist/core/promise.mjs +46 -0
- package/dist/core/publish.mjs +142 -0
- package/dist/core/push-decide.mjs +206 -0
- package/dist/core/push.mjs +1069 -0
- package/dist/core/receipts.d.mts +7 -0
- package/dist/core/receipts.mjs +234 -0
- package/dist/core/ref-conflicts.mjs +27 -0
- package/dist/core/refs.mjs +359 -0
- package/dist/core/repack.mjs +521 -0
- package/dist/core/repos.mjs +752 -0
- package/dist/core/rules/changes.mjs +57 -0
- package/dist/core/rules/check.mjs +101 -0
- package/dist/core/rules/commit-changes.mjs +216 -0
- package/dist/core/rules/context.d.mts +9 -0
- package/dist/core/rules/context.mjs +120 -0
- package/dist/core/rules/define.d.mts +5 -0
- package/dist/core/rules/define.mjs +13 -0
- package/dist/core/rules/facts.mjs +13 -0
- package/dist/core/rules/fetch.d.mts +5 -0
- package/dist/core/rules/fetch.mjs +59 -0
- package/dist/core/rules/file-globs.mjs +55 -0
- package/dist/core/rules/files.mjs +142 -0
- package/dist/core/rules/patterns.mjs +23 -0
- package/dist/core/rules/protect.d.mts +9 -0
- package/dist/core/rules/protect.mjs +116 -0
- package/dist/core/seam.d.mts +24 -0
- package/dist/core/seam.mjs +41 -0
- package/dist/core/sight.mjs +99 -0
- package/dist/core/tokens.mjs +95 -0
- package/dist/core/view.d.mts +9 -0
- package/dist/core/view.mjs +221 -0
- package/dist/core/work.mjs +92 -0
- package/dist/effect.d.mts +20 -0
- package/dist/effect.mjs +18 -0
- package/dist/engine/allotted-xdiff.d.mts +4 -0
- package/dist/engine/allotted-xdiff.mjs +80 -0
- package/dist/engine/attribute-patterns.mjs +163 -0
- package/dist/engine/attributes.mjs +226 -0
- package/dist/engine/combined.mjs +653 -0
- package/dist/engine/commits.mjs +90 -0
- package/dist/engine/content.d.mts +4 -0
- package/dist/engine/content.mjs +221 -0
- package/dist/engine/diff.mjs +49 -0
- package/dist/engine/engine.d.mts +25 -0
- package/dist/engine/engine.mjs +49 -0
- package/dist/engine/failures.d.mts +4 -0
- package/dist/engine/failures.mjs +23 -0
- package/dist/engine/line-count.mjs +23 -0
- package/dist/engine/merge-base-walk.d.mts +2 -0
- package/dist/engine/merge-base-walk.mjs +265 -0
- package/dist/engine/merge-bases.mjs +27 -0
- package/dist/engine/merge-renames.mjs +165 -0
- package/dist/engine/merge.mjs +1125 -0
- package/dist/engine/parts.d.mts +8 -0
- package/dist/engine/parts.mjs +9 -0
- package/dist/engine/reads.d.mts +5 -0
- package/dist/engine/reads.mjs +105 -0
- package/dist/engine/walk.mjs +328 -0
- package/dist/engine/xdiff/NOTICE.md +63 -0
- package/dist/engine/xdiff/compiled.d.mts +7 -0
- package/dist/engine/xdiff/compiled.mjs +9 -0
- package/dist/engine/xdiff/embedded.mjs +4 -0
- package/dist/engine/xdiff/node.d.mts +7 -0
- package/dist/engine/xdiff/node.mjs +10 -0
- package/dist/engine/xdiff/upstream/LGPL-2.1 +511 -0
- package/dist/engine/xdiff/xdiff.wasm +0 -0
- package/dist/engine/xdiff.d.mts +34 -0
- package/dist/engine/xdiff.mjs +380 -0
- package/dist/engine.d.mts +3 -0
- package/dist/engine.mjs +3 -0
- package/dist/extend.d.mts +3 -0
- package/dist/extend.mjs +1 -0
- package/dist/http/answers.mjs +74 -0
- package/dist/http/bodies.mjs +143 -0
- package/dist/http/core-parts.mjs +252 -0
- package/dist/http/fetch-depth.mjs +26 -0
- package/dist/http/handler.mjs +94 -0
- package/dist/http/node.d.mts +70 -0
- package/dist/http/node.mjs +178 -0
- package/dist/http/paths.d.mts +9 -0
- package/dist/http/paths.mjs +118 -0
- package/dist/http/push-uploads.mjs +286 -0
- package/dist/http/receive-pack.mjs +235 -0
- package/dist/http/upload-pack.mjs +229 -0
- package/dist/index.d.mts +46 -0
- package/dist/index.mjs +16 -0
- package/dist/lfs/calls.mjs +16 -0
- package/dist/lfs/locks.mjs +161 -0
- package/dist/lfs/objects.mjs +370 -0
- package/dist/lfs/pointers.mjs +141 -0
- package/dist/lfs/repo.mjs +42 -0
- package/dist/lfs/rows.mjs +108 -0
- package/dist/lfs/service.mjs +34 -0
- package/dist/lfs/upkeep.mjs +162 -0
- package/dist/lfs/wire.mjs +102 -0
- package/dist/node.d.mts +3 -0
- package/dist/node.mjs +3 -0
- package/dist/protocol/bytes/buffers.d.mts +38 -0
- package/dist/protocol/bytes/buffers.mjs +62 -0
- package/dist/protocol/bytes/crc32.d.mts +4 -0
- package/dist/protocol/bytes/crc32.mjs +14 -0
- package/dist/protocol/bytes/deflate.d.mts +78 -0
- package/dist/protocol/bytes/deflate.mjs +175 -0
- package/dist/protocol/bytes/errors.d.mts +20 -0
- package/dist/protocol/bytes/errors.mjs +19 -0
- package/dist/protocol/bytes/hex.mjs +16 -0
- package/dist/protocol/bytes/hmac-sha256.mjs +91 -0
- package/dist/protocol/bytes/inflate.d.mts +40 -0
- package/dist/protocol/bytes/inflate.mjs +109 -0
- package/dist/protocol/bytes/joined.d.mts +2 -0
- package/dist/protocol/bytes/joined.mjs +25 -0
- package/dist/protocol/bytes/sha1-hasher.d.mts +20 -0
- package/dist/protocol/bytes/sha1-hasher.mjs +72 -0
- package/dist/protocol/bytes/sha1.d.mts +35 -0
- package/dist/protocol/bytes/sha1.mjs +409 -0
- package/dist/protocol/bytes/sha256.mjs +156 -0
- package/dist/protocol/bytes/streams.mjs +11 -0
- package/dist/protocol/bytes/text.mjs +19 -0
- package/dist/protocol/diff/diff-raw.d.mts +29 -0
- package/dist/protocol/diff/diff-raw.mjs +73 -0
- package/dist/protocol/diff/patch.mjs +92 -0
- package/dist/protocol/diff/paths.mjs +67 -0
- package/dist/protocol/diff/read.d.mts +62 -0
- package/dist/protocol/diff/read.mjs +342 -0
- package/dist/protocol/diff/rename-similarity.mjs +428 -0
- package/dist/protocol/diff/text.mjs +12 -0
- package/dist/protocol/diff/tree-diff.d.mts +41 -0
- package/dist/protocol/diff/tree-diff.mjs +607 -0
- package/dist/protocol/framing/band.d.mts +10 -0
- package/dist/protocol/framing/band.mjs +16 -0
- package/dist/protocol/framing/pkt-line.d.mts +48 -0
- package/dist/protocol/framing/pkt-line.mjs +92 -0
- package/dist/protocol/objects/checked-blobs.mjs +127 -0
- package/dist/protocol/objects/commit.d.mts +25 -0
- package/dist/protocol/objects/commit.mjs +138 -0
- package/dist/protocol/objects/fsck-gitmodules.mjs +296 -0
- package/dist/protocol/objects/fsck-names.mjs +189 -0
- package/dist/protocol/objects/fsck.mjs +297 -0
- package/dist/protocol/objects/headers.mjs +109 -0
- package/dist/protocol/objects/held.mjs +56 -0
- package/dist/protocol/objects/iconv.mjs +145 -0
- package/dist/protocol/objects/ident.mjs +111 -0
- package/dist/protocol/objects/lfs-pointer.d.mts +8 -0
- package/dist/protocol/objects/lfs-pointer.mjs +63 -0
- package/dist/protocol/objects/links-raw.mjs +89 -0
- package/dist/protocol/objects/object-rules.mjs +75 -0
- package/dist/protocol/objects/object.d.mts +16 -0
- package/dist/protocol/objects/object.mjs +29 -0
- package/dist/protocol/objects/tag.d.mts +21 -0
- package/dist/protocol/objects/tag.mjs +96 -0
- package/dist/protocol/objects/tree.d.mts +43 -0
- package/dist/protocol/objects/tree.mjs +162 -0
- package/dist/protocol/objects/utf8-verify.mjs +71 -0
- package/dist/protocol/packs/delta.d.mts +57 -0
- package/dist/protocol/packs/delta.mjs +229 -0
- package/dist/protocol/packs/graph.mjs +78 -0
- package/dist/protocol/packs/idx.d.mts +54 -0
- package/dist/protocol/packs/idx.mjs +274 -0
- package/dist/protocol/packs/indexer.d.mts +167 -0
- package/dist/protocol/packs/indexer.mjs +507 -0
- package/dist/protocol/packs/parts.d.mts +40 -0
- package/dist/protocol/packs/parts.mjs +89 -0
- package/dist/protocol/packs/pos.mjs +51 -0
- package/dist/protocol/packs/reader.d.mts +180 -0
- package/dist/protocol/packs/reader.mjs +414 -0
- package/dist/protocol/packs/rev.d.mts +32 -0
- package/dist/protocol/packs/rev.mjs +99 -0
- package/dist/protocol/packs/step.d.mts +10 -0
- package/dist/protocol/packs/step.mjs +12 -0
- package/dist/protocol/packs/write-error.d.mts +12 -0
- package/dist/protocol/packs/write-error.mjs +27 -0
- package/dist/protocol/packs/writer.d.mts +157 -0
- package/dist/protocol/packs/writer.mjs +353 -0
- package/dist/protocol/wire/advertisement.d.mts +72 -0
- package/dist/protocol/wire/advertisement.mjs +161 -0
- package/dist/protocol/wire/fetch.d.mts +155 -0
- package/dist/protocol/wire/fetch.mjs +458 -0
- package/dist/protocol/wire/lines.mjs +107 -0
- package/dist/protocol/wire/push-uploads.mjs +43 -0
- package/dist/protocol/wire/receive-pack.d.mts +71 -0
- package/dist/protocol/wire/receive-pack.mjs +157 -0
- package/dist/protocol/wire/report-status.d.mts +47 -0
- package/dist/protocol/wire/report-status.mjs +119 -0
- package/dist/protocol/wire/v2.d.mts +90 -0
- package/dist/protocol/wire/v2.mjs +185 -0
- package/dist/protocol.d.mts +31 -0
- package/dist/protocol.mjs +31 -0
- package/dist/queue/advance.mjs +1036 -0
- package/dist/queue/callers.mjs +134 -0
- package/dist/queue/calls.mjs +1154 -0
- package/dist/queue/commit.mjs +85 -0
- package/dist/queue/host.d.mts +15 -0
- package/dist/queue/host.mjs +88 -0
- package/dist/queue/ids.d.mts +5 -0
- package/dist/queue/ids.mjs +21 -0
- package/dist/queue/lanes.mjs +86 -0
- package/dist/queue/limits.mjs +99 -0
- package/dist/queue/pages.mjs +76 -0
- package/dist/queue/push-option.mjs +62 -0
- package/dist/queue/rows.mjs +206 -0
- package/dist/queue/schedule.mjs +132 -0
- package/dist/queue/search.mjs +315 -0
- package/dist/queue/state.mjs +325 -0
- package/dist/queue/steps.mjs +317 -0
- package/dist/remote-helper.d.mts +3 -0
- package/dist/remote-helper.mjs +3 -0
- package/dist/rest/api.d.mts +23 -0
- package/dist/rest/api.mjs +27 -0
- package/dist/rest/blobs.d.mts +58 -0
- package/dist/rest/blobs.mjs +41 -0
- package/dist/rest/caller.d.mts +102 -0
- package/dist/rest/caller.mjs +18 -0
- package/dist/rest/client.d.mts +18 -0
- package/dist/rest/client.mjs +587 -0
- package/dist/rest/commits.d.mts +435 -0
- package/dist/rest/commits.mjs +140 -0
- package/dist/rest/errors.d.mts +44 -0
- package/dist/rest/errors.mjs +186 -0
- package/dist/rest/events.d.mts +38 -0
- package/dist/rest/events.mjs +74 -0
- package/dist/rest/files.d.mts +179 -0
- package/dist/rest/files.mjs +92 -0
- package/dist/rest/forks.d.mts +205 -0
- package/dist/rest/forks.mjs +51 -0
- package/dist/rest/handler.d.mts +17 -0
- package/dist/rest/handler.mjs +106 -0
- package/dist/rest/handlers.d.mts +8 -0
- package/dist/rest/handlers.mjs +592 -0
- package/dist/rest/listen.d.mts +24 -0
- package/dist/rest/listen.mjs +142 -0
- package/dist/rest/me.d.mts +55 -0
- package/dist/rest/me.mjs +21 -0
- package/dist/rest/merges.d.mts +90 -0
- package/dist/rest/merges.mjs +39 -0
- package/dist/rest/paths.mjs +86 -0
- package/dist/rest/queue.d.mts +486 -0
- package/dist/rest/queue.mjs +228 -0
- package/dist/rest/refs.d.mts +232 -0
- package/dist/rest/refs.mjs +86 -0
- package/dist/rest/repos.d.mts +223 -0
- package/dist/rest/repos.mjs +93 -0
- package/dist/rest/tags.d.mts +153 -0
- package/dist/rest/tags.mjs +72 -0
- package/dist/rest/tokens.d.mts +297 -0
- package/dist/rest/tokens.mjs +88 -0
- package/dist/rest/topics.d.mts +257 -0
- package/dist/rest/topics.mjs +116 -0
- package/dist/rest/trees.d.mts +158 -0
- package/dist/rest/trees.mjs +118 -0
- package/dist/rest/wire.mjs +57 -0
- package/dist/rest/work.d.mts +107 -0
- package/dist/rest/work.mjs +77 -0
- package/dist/rest.d.mts +8 -0
- package/dist/rest.mjs +5 -0
- package/dist/server/extension.d.mts +14 -0
- package/dist/server/extension.mjs +85 -0
- package/dist/server/routes.d.mts +25 -0
- package/dist/server/routes.mjs +67 -0
- package/dist/server/server.d.mts +2 -0
- package/dist/server/server.mjs +439 -0
- package/dist/signin/codes.mjs +47 -0
- package/dist/signin/context.d.mts +9 -0
- package/dist/signin/context.mjs +121 -0
- package/dist/signin/device.mjs +122 -0
- package/dist/signin/forms.mjs +157 -0
- package/dist/signin/grants.d.mts +5 -0
- package/dist/signin/grants.mjs +257 -0
- package/dist/signin/route.mjs +68 -0
- package/dist/signin/web.mjs +125 -0
- package/dist/signin/wire.d.mts +42 -0
- package/dist/signin/wire.mjs +43 -0
- package/dist/storage/allotted.mjs +102 -0
- package/dist/storage/budget.mjs +96 -0
- package/dist/storage/calls.d.mts +18 -0
- package/dist/storage/calls.mjs +273 -0
- package/dist/storage/clean-up.mjs +124 -0
- package/dist/storage/distinct-ids.mjs +39 -0
- package/dist/storage/ewah.mjs +97 -0
- package/dist/storage/fetch.d.mts +13 -0
- package/dist/storage/fetch.mjs +792 -0
- package/dist/storage/fsck.mjs +77 -0
- package/dist/storage/held-memo.mjs +188 -0
- package/dist/storage/index-bitmaps.d.mts +4 -0
- package/dist/storage/index-bitmaps.mjs +654 -0
- package/dist/storage/index-build.d.mts +15 -0
- package/dist/storage/index-build.mjs +1433 -0
- package/dist/storage/index-fetch.d.mts +9 -0
- package/dist/storage/index-fetch.mjs +756 -0
- package/dist/storage/index-files.mjs +232 -0
- package/dist/storage/index-graph.d.mts +3 -0
- package/dist/storage/index-graph.mjs +1049 -0
- package/dist/storage/index-layers.mjs +317 -0
- package/dist/storage/index-reach.mjs +216 -0
- package/dist/storage/index-remap.d.mts +8 -0
- package/dist/storage/index-remap.mjs +592 -0
- package/dist/storage/layout.mjs +69 -0
- package/dist/storage/lfs-pointers.d.mts +21 -0
- package/dist/storage/lfs-pointers.mjs +175 -0
- package/dist/storage/link-join.mjs +106 -0
- package/dist/storage/links.mjs +105 -0
- package/dist/storage/loose.d.mts +15 -0
- package/dist/storage/loose.mjs +120 -0
- package/dist/storage/memory-budget.d.mts +8 -0
- package/dist/storage/memory-budget.mjs +546 -0
- package/dist/storage/merge.mjs +416 -0
- package/dist/storage/object-rows.d.mts +6 -0
- package/dist/storage/object-rows.mjs +211 -0
- package/dist/storage/pack-order.d.mts +8 -0
- package/dist/storage/pack-order.mjs +779 -0
- package/dist/storage/pack-ranges.d.mts +5 -0
- package/dist/storage/pack-ranges.mjs +284 -0
- package/dist/storage/pack-reads.d.mts +11 -0
- package/dist/storage/pack-reads.mjs +990 -0
- package/dist/storage/pack-receive.d.mts +11 -0
- package/dist/storage/pack-receive.mjs +449 -0
- package/dist/storage/packs.d.mts +56 -0
- package/dist/storage/packs.mjs +600 -0
- package/dist/storage/prune.mjs +506 -0
- package/dist/storage/push-allotment.mjs +109 -0
- package/dist/storage/push-uploads.mjs +151 -0
- package/dist/storage/pushed-commits.mjs +136 -0
- package/dist/storage/quarantine.mjs +98 -0
- package/dist/storage/raw-ids.mjs +44 -0
- package/dist/storage/ready.d.mts +19 -0
- package/dist/storage/ready.mjs +328 -0
- package/dist/storage/receive-links.mjs +297 -0
- package/dist/storage/repack-job.mjs +48 -0
- package/dist/storage/repack.d.mts +31 -0
- package/dist/storage/repack.mjs +182 -0
- package/dist/storage/roots.mjs +42 -0
- package/dist/storage/rows.d.mts +3 -0
- package/dist/storage/rows.mjs +71 -0
- package/dist/storage/shallow.d.mts +5 -0
- package/dist/storage/shallow.mjs +128 -0
- package/dist/storage/stream-whole.mjs +236 -0
- package/dist/storage/unpack.mjs +236 -0
- package/dist/storage/visible.mjs +137 -0
- package/dist/storage/walk.d.mts +7 -0
- package/dist/storage/walk.mjs +170 -0
- package/dist/storage/wants.mjs +362 -0
- package/dist/store/call-count.d.mts +47 -0
- package/dist/store/call-count.mjs +207 -0
- package/dist/store/catalogue.d.mts +7 -0
- package/dist/store/catalogue.mjs +643 -0
- package/dist/store/crossing.mjs +66 -0
- package/dist/store/cursor-seal.d.mts +2 -0
- package/dist/store/cursor-seal.mjs +85 -0
- package/dist/store/errors.d.mts +12 -0
- package/dist/store/errors.mjs +129 -0
- package/dist/store/git-store.mjs +75 -0
- package/dist/store/list-job.mjs +35 -0
- package/dist/store/outbox.d.mts +7 -0
- package/dist/store/outbox.mjs +295 -0
- package/dist/store/queue-jobs.mjs +43 -0
- package/dist/store/random.mjs +28 -0
- package/dist/store/records.d.mts +4 -0
- package/dist/store/records.mjs +192 -0
- package/dist/store/ref-rows.d.mts +4 -0
- package/dist/store/ref-rows.mjs +30 -0
- package/dist/store/repo-record.mjs +100 -0
- package/dist/store/reservations.mjs +82 -0
- package/dist/store/scopes.mjs +170 -0
- package/dist/store/settle.mjs +63 -0
- package/dist/store/topic-jobs.mjs +62 -0
- package/dist/sync/bound.d.mts +7 -0
- package/dist/sync/bound.mjs +29 -0
- package/dist/sync/github.d.mts +12 -0
- package/dist/sync/github.mjs +297 -0
- package/dist/sync/import.d.mts +8 -0
- package/dist/sync/import.mjs +154 -0
- package/dist/sync/jobs.d.mts +9 -0
- package/dist/sync/jobs.mjs +80 -0
- package/dist/sync/mirror.d.mts +9 -0
- package/dist/sync/mirror.mjs +227 -0
- package/dist/sync/publish.d.mts +5 -0
- package/dist/sync/publish.mjs +117 -0
- package/dist/sync/records.mjs +73 -0
- package/dist/sync/smart-http.d.mts +8 -0
- package/dist/sync/smart-http.mjs +23 -0
- package/dist/sync/step.mjs +334 -0
- package/dist/sync/tries.mjs +126 -0
- package/dist/sync.d.mts +8 -0
- package/dist/sync.mjs +8 -0
- package/dist/topics/advance.mjs +554 -0
- package/dist/topics/calls.mjs +346 -0
- package/dist/topics/directory.mjs +107 -0
- package/dist/topics/host.d.mts +11 -0
- package/dist/topics/host.mjs +71 -0
- package/dist/topics/members.mjs +177 -0
- package/dist/topics/rows.mjs +99 -0
- package/dist/topics/topic.mjs +126 -0
- package/package.json +86 -5
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { joinedBytes } from "../protocol/bytes/joined.mjs";
|
|
2
|
+
import { readPkt } from "../protocol/framing/pkt-line.mjs";
|
|
3
|
+
import { gitError } from "../store/errors.mjs";
|
|
4
|
+
import * as Effect from "effect/Effect";
|
|
5
|
+
// src/client/answer.ts
|
|
6
|
+
/**
|
|
7
|
+
* A Git answer as a client reads it: its start, held until a codec can read it, then its pack,
|
|
8
|
+
* streamed off side-band-64k's band 1 into the local receive, which reads it once. Band 2's
|
|
9
|
+
* progress is dropped, and band 3's error ends the pack with the remote's message.
|
|
10
|
+
*/
|
|
11
|
+
/** The most an answer's start may hold before its pack: its acknowledgments and shallow lines. */
|
|
12
|
+
const answerStartMost = 16777216;
|
|
13
|
+
/** A pack's header: `PACK`, its version, and how many objects it holds. */
|
|
14
|
+
const packHeader = 12;
|
|
15
|
+
const unreadable = (what, reason) => gitError("INTERNAL", `The remote's ${what} can't be read: ${reason}`);
|
|
16
|
+
const tooLong = (what) => gitError("RESOURCE_EXHAUSTED", `The remote's ${what} is over ${answerStartMost} bytes`, { context: {
|
|
17
|
+
reason: "response-too-large",
|
|
18
|
+
limit: answerStartMost
|
|
19
|
+
} });
|
|
20
|
+
const cutShort = (what) => gitError("UNAVAILABLE", `The remote's ${what} ended early`, { hint: "Try again" });
|
|
21
|
+
const arriving = (body) => {
|
|
22
|
+
const reader = body.getReader();
|
|
23
|
+
let held = /* @__PURE__ */ new Uint8Array();
|
|
24
|
+
return {
|
|
25
|
+
bytes: () => held,
|
|
26
|
+
more: async () => {
|
|
27
|
+
const read = await reader.read();
|
|
28
|
+
if (read.done) return false;
|
|
29
|
+
held = held.length === 0 ? read.value : joinedBytes([held, read.value]);
|
|
30
|
+
return true;
|
|
31
|
+
},
|
|
32
|
+
take: (count) => {
|
|
33
|
+
held = held.subarray(count);
|
|
34
|
+
},
|
|
35
|
+
cancel: () => void reader.cancel().catch(() => void 0)
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
/** Awaits `promise`, cancelling `answer` when the call is interrupted. */
|
|
39
|
+
const awaited = (answer, promise, what) => Effect.tryPromise({
|
|
40
|
+
try: async (signal) => {
|
|
41
|
+
signal.addEventListener("abort", answer.cancel, { once: true });
|
|
42
|
+
try {
|
|
43
|
+
return await promise();
|
|
44
|
+
} finally {
|
|
45
|
+
signal.removeEventListener("abort", answer.cancel);
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
catch: (cause) => gitError("UNAVAILABLE", `The remote's ${what} broke off`, { cause })
|
|
49
|
+
});
|
|
50
|
+
/**
|
|
51
|
+
* The answer's start, read by `read` once enough of it has come, up to `answerStartMost` however
|
|
52
|
+
* its bytes arrived: `read` says `incomplete` until then, and its `offset`, where the pack starts,
|
|
53
|
+
* is what it read. An answer that ends first is cut short.
|
|
54
|
+
*/
|
|
55
|
+
const answerStart = (answer, read, what) => Effect.gen(function* () {
|
|
56
|
+
for (let ended = false;;) {
|
|
57
|
+
const start = yield* read(answer.bytes(), ended);
|
|
58
|
+
const done = start.kind !== "incomplete";
|
|
59
|
+
if ((done ? start.offset ?? answer.bytes().length : answer.bytes().length) > 16777216) {
|
|
60
|
+
answer.cancel();
|
|
61
|
+
return yield* Effect.fail(tooLong(what));
|
|
62
|
+
}
|
|
63
|
+
if (done) return start;
|
|
64
|
+
if (ended) return yield* Effect.fail(cutShort(what));
|
|
65
|
+
ended = !(yield* awaited(answer, answer.more, what));
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
/**
|
|
69
|
+
* The pack on side-band-64k from the answer's next line to its flush: band 1's bytes, band 2's
|
|
70
|
+
* dropped, and band 3's message the pack's failure, as Git's own client reads it. Before the
|
|
71
|
+
* pack's header, its lines count against `answerStartMost`, band 2's among them.
|
|
72
|
+
*/
|
|
73
|
+
const packOnBands = (answer) => Effect.gen(function* () {
|
|
74
|
+
let failure;
|
|
75
|
+
/** What the lines before the pack's header may still hold; `undefined` once it's read. */
|
|
76
|
+
let headerRoom = answerStartMost;
|
|
77
|
+
/** Band 1's next bytes, or `undefined` at the flush that ends them. */
|
|
78
|
+
const next = async () => {
|
|
79
|
+
for (;;) {
|
|
80
|
+
const read = readPkt(answer.bytes(), 0);
|
|
81
|
+
if (read.kind === "invalid") throw failure = unreadable("pack", read.reason);
|
|
82
|
+
if (read.kind === "incomplete") {
|
|
83
|
+
if (!await answer.more()) throw failure = cutShort("pack");
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
const { pkt } = read;
|
|
87
|
+
answer.take(read.next);
|
|
88
|
+
if (headerRoom !== void 0) {
|
|
89
|
+
headerRoom -= read.next;
|
|
90
|
+
if (headerRoom < 0) throw failure = tooLong("pack");
|
|
91
|
+
}
|
|
92
|
+
if (pkt.kind === "flush") return void 0;
|
|
93
|
+
if (pkt.kind !== "data") throw failure = unreadable("pack", `a ${pkt.kind} in it`);
|
|
94
|
+
const band = pkt.data[0];
|
|
95
|
+
const payload = pkt.data.subarray(1);
|
|
96
|
+
if (band === 1 && payload.length > 0) return payload;
|
|
97
|
+
if (band === 3) {
|
|
98
|
+
const message = new TextDecoder().decode(payload).trim();
|
|
99
|
+
throw failure = gitError("UNAVAILABLE", `The remote failed: ${message}`);
|
|
100
|
+
}
|
|
101
|
+
if (band !== 1 && band !== 2) throw failure = unreadable("pack", `band ${band}`);
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
const start = yield* awaited(answer, async () => {
|
|
105
|
+
const chunks = [];
|
|
106
|
+
let size = 0;
|
|
107
|
+
while (size < packHeader) {
|
|
108
|
+
const chunk = await next();
|
|
109
|
+
if (chunk === void 0) break;
|
|
110
|
+
chunks.push(chunk);
|
|
111
|
+
size += chunk.length;
|
|
112
|
+
}
|
|
113
|
+
return joinedBytes(chunks);
|
|
114
|
+
}, "pack").pipe(Effect.mapError((error) => failure ?? error), Effect.tapError(() => Effect.sync(answer.cancel)));
|
|
115
|
+
headerRoom = void 0;
|
|
116
|
+
if (!(start.length >= packHeader && new TextDecoder().decode(start.subarray(0, 4)) === "PACK")) {
|
|
117
|
+
answer.cancel();
|
|
118
|
+
return yield* Effect.fail(unreadable("pack", "it doesn't start with a pack's header"));
|
|
119
|
+
}
|
|
120
|
+
const objects = new DataView(start.buffer, start.byteOffset, packHeader).getUint32(8);
|
|
121
|
+
let first = start;
|
|
122
|
+
return {
|
|
123
|
+
objects,
|
|
124
|
+
bytes: new ReadableStream({
|
|
125
|
+
pull: async (controller) => {
|
|
126
|
+
if (first !== void 0) {
|
|
127
|
+
controller.enqueue(first);
|
|
128
|
+
first = void 0;
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
const chunk = await next();
|
|
132
|
+
if (chunk === void 0) controller.close();
|
|
133
|
+
else controller.enqueue(chunk);
|
|
134
|
+
},
|
|
135
|
+
cancel: answer.cancel
|
|
136
|
+
}),
|
|
137
|
+
failure: () => failure,
|
|
138
|
+
cancel: answer.cancel
|
|
139
|
+
};
|
|
140
|
+
});
|
|
141
|
+
export { answerStart, answerStartMost, arriving, packOnBands, unreadable };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { GitClient, GitClientOptions, PagedInput } from "../contracts/client.mjs";
|
|
2
|
+
import { Result } from "../contracts/result.mjs";
|
|
3
|
+
import { EffectCalls } from "../contracts/services.mjs";
|
|
4
|
+
import { Listing } from "@ref0/infra";
|
|
5
|
+
/**
|
|
6
|
+
* A client of one remote, as Effects: its remote calls over Git's smart HTTP, and its local
|
|
7
|
+
* calls on its own storage, which a fetch fills and a push reads. `GitClient` at `/effect` is
|
|
8
|
+
* this, as a service. Each is an edge a host calls, as the server's Effect face is: a spent bound,
|
|
9
|
+
* a `CallBudget`'s or the platform's cap, is answered as its refusal, never a defect.
|
|
10
|
+
*/
|
|
11
|
+
export declare const effectGitClient: (options: GitClientOptions) => EffectCalls<GitClient>;
|
|
12
|
+
/**
|
|
13
|
+
* A client of `options.url`: `remoteRefs`, `fetch` and `push` on the remote, and the server's
|
|
14
|
+
* calls on its own storage, with no repo. Each call answers a `Result`, and stops when its
|
|
15
|
+
* input's `signal` aborts.
|
|
16
|
+
*/
|
|
17
|
+
export declare const createGitClient: (options: GitClientOptions) => GitClient;
|
|
18
|
+
/**
|
|
19
|
+
* Each item `list` answers, a page at a time, from the input's `page` on: the next page asked
|
|
20
|
+
* for only once the last one's items are taken. A refused page throws an `Error` whose `cause` is
|
|
21
|
+
* the page's `GitError`, so a loop over it stops there.
|
|
22
|
+
*/
|
|
23
|
+
export declare function paginate<Args extends unknown[], Input extends PagedInput, Item>(list: (...args: [...Args, Input]) => Promise<Result<Listing<Item>>>, ...args: [...Args, Input]): AsyncIterable<Item>;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { guardedCalls, promiseCalls } from "../core/promise.mjs";
|
|
2
|
+
import { resultIn } from "../store/crossing.mjs";
|
|
3
|
+
import { gitHttp } from "./git-http.mjs";
|
|
4
|
+
import { localSide } from "./local.mjs";
|
|
5
|
+
import { fetchInto, pushFrom, remoteRefs } from "./remote.mjs";
|
|
6
|
+
import * as Effect from "effect/Effect";
|
|
7
|
+
// src/client/client.ts
|
|
8
|
+
/**
|
|
9
|
+
* A client of one remote, as Effects: its remote calls over Git's smart HTTP, and its local
|
|
10
|
+
* calls on its own storage, which a fetch fills and a push reads. `GitClient` at `/effect` is
|
|
11
|
+
* this, as a service. Each is an edge a host calls, as the server's Effect face is: a spent bound,
|
|
12
|
+
* a `CallBudget`'s or the platform's cap, is answered as its refusal, never a defect.
|
|
13
|
+
*/
|
|
14
|
+
const effectGitClient = (options) => {
|
|
15
|
+
const local = localSide(options);
|
|
16
|
+
const http = gitHttp(options);
|
|
17
|
+
return guardedCalls({
|
|
18
|
+
remoteRefs: (input) => remoteRefs(http, input),
|
|
19
|
+
fetch: (input) => fetchInto(http, local, input),
|
|
20
|
+
push: (input) => pushFrom(http, local, input),
|
|
21
|
+
...local.calls
|
|
22
|
+
}, Effect.void);
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* A client of `options.url`: `remoteRefs`, `fetch` and `push` on the remote, and the server's
|
|
26
|
+
* calls on its own storage, with no repo. Each call answers a `Result`, and stops when its
|
|
27
|
+
* input's `signal` aborts.
|
|
28
|
+
*/
|
|
29
|
+
const createGitClient = (options) => promiseCalls(effectGitClient(options), resultIn);
|
|
30
|
+
/**
|
|
31
|
+
* Each item `list` answers, a page at a time, from the input's `page` on: the next page asked
|
|
32
|
+
* for only once the last one's items are taken. A refused page throws an `Error` whose `cause` is
|
|
33
|
+
* the page's `GitError`, so a loop over it stops there.
|
|
34
|
+
*/
|
|
35
|
+
async function* paginate(list, ...args) {
|
|
36
|
+
const head = args.slice(0, -1);
|
|
37
|
+
const input = args.at(-1);
|
|
38
|
+
for (let after = input.page?.after;;) {
|
|
39
|
+
const page = { ...input.page };
|
|
40
|
+
if (after !== void 0) page.after = after;
|
|
41
|
+
const listed = await list(...head, {
|
|
42
|
+
...input,
|
|
43
|
+
page
|
|
44
|
+
});
|
|
45
|
+
if (listed.kind === "error") throw new Error(listed.error.message, { cause: listed.error });
|
|
46
|
+
yield* listed.value.items;
|
|
47
|
+
if (listed.value.next === void 0) return;
|
|
48
|
+
after = listed.value.next;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
export { createGitClient, effectGitClient, paginate };
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { tryUnlessSpent } from "../contracts/calls-spent.mjs";
|
|
2
|
+
import { isGitErrorCode, refusalCodeHeader } from "../contracts/result.mjs";
|
|
3
|
+
import { joinedBytes } from "../protocol/bytes/joined.mjs";
|
|
4
|
+
import { fail, gitError } from "../store/errors.mjs";
|
|
5
|
+
import { bodyText, dropped, remoteFetch } from "./transport.mjs";
|
|
6
|
+
import * as Effect from "effect/Effect";
|
|
7
|
+
// src/client/git-http.ts
|
|
8
|
+
/**
|
|
9
|
+
* Git's smart HTTP as a client sends it, as `gitprotocol-http` says: `info/refs` for a service's
|
|
10
|
+
* advertisement, then a POST to the service, each through `remoteFetch`, so credentials, retries
|
|
11
|
+
* and the one retry after a 401 are REST's. A refusal's code, its status and its line of text are
|
|
12
|
+
* the caller's `GitError`, as a host's `authorize` returned it to the server.
|
|
13
|
+
*/
|
|
14
|
+
/** Each status Git's server answers a refusal with, as the code it told: for an answer that names none. */
|
|
15
|
+
const statusCodes = /* @__PURE__ */ new Map([
|
|
16
|
+
[400, "INVALID_ARGUMENT"],
|
|
17
|
+
[401, "UNAUTHENTICATED"],
|
|
18
|
+
[403, "NOT_ALLOWED"],
|
|
19
|
+
[404, "NOT_FOUND"],
|
|
20
|
+
[409, "FAILED_PRECONDITION"],
|
|
21
|
+
[413, "RESOURCE_EXHAUSTED"],
|
|
22
|
+
[429, "RESOURCE_EXHAUSTED"],
|
|
23
|
+
[502, "UNAVAILABLE"],
|
|
24
|
+
[503, "UNAVAILABLE"],
|
|
25
|
+
[504, "DEADLINE_EXCEEDED"]
|
|
26
|
+
]);
|
|
27
|
+
/** The most of a refusal's text a `GitError` keeps. */
|
|
28
|
+
const toldMost = 1024;
|
|
29
|
+
/** The code `response` names in `refusalCodeHeader`, when it's one Git refuses with. */
|
|
30
|
+
const namedCode = (response) => {
|
|
31
|
+
const named = response.headers.get(refusalCodeHeader);
|
|
32
|
+
return named !== null && isGitErrorCode(named) ? named : void 0;
|
|
33
|
+
};
|
|
34
|
+
/** `response`'s refusal: the code it names, else its status's, with `text`'s first line. */
|
|
35
|
+
const told = (response, text) => {
|
|
36
|
+
const { status } = response;
|
|
37
|
+
const line = text.split("\n", 1)[0]?.trim().slice(0, toldMost) ?? "";
|
|
38
|
+
const message = line === "" ? `The remote answered ${status}` : line;
|
|
39
|
+
const code = namedCode(response) ?? statusCodes.get(status) ?? "INTERNAL";
|
|
40
|
+
const context = status === 429 ? { reason: "rate-limited" } : void 0;
|
|
41
|
+
return code === "RESOURCE_EXHAUSTED" && context !== void 0 ? {
|
|
42
|
+
code,
|
|
43
|
+
message,
|
|
44
|
+
context
|
|
45
|
+
} : gitError(code, message);
|
|
46
|
+
};
|
|
47
|
+
/** The most of a refusal's body read for its line: the rest is cancelled unread. */
|
|
48
|
+
const toldBytesMost = 4 * toldMost;
|
|
49
|
+
/** The start of `response`'s body, at most `toldBytesMost` bytes, its rest cancelled. */
|
|
50
|
+
const toldText = (response) => bodyText(response, toldBytesMost);
|
|
51
|
+
/**
|
|
52
|
+
* What a Git server's refusal said: its status, its code, and its line of plain text. Its body is
|
|
53
|
+
* cancelled once that line is read, or unread when it isn't text.
|
|
54
|
+
*/
|
|
55
|
+
const gitFailure = (response) => {
|
|
56
|
+
const { status } = response;
|
|
57
|
+
const text = (response.headers.get("content-type") ?? "").startsWith("text/plain") ? toldText(response).pipe(Effect.orElseSucceed(() => "")) : Effect.as(dropped(response), "");
|
|
58
|
+
return Effect.map(text, (said) => ({
|
|
59
|
+
status,
|
|
60
|
+
error: told(response, said)
|
|
61
|
+
}));
|
|
62
|
+
};
|
|
63
|
+
/** No answer, for `cause`: what the transport threw, never the request with its credential. */
|
|
64
|
+
const unanswered = (cause) => gitError("UNAVAILABLE", "The remote didn't answer", {
|
|
65
|
+
cause,
|
|
66
|
+
hint: "Try again"
|
|
67
|
+
});
|
|
68
|
+
const tooLong = (what, most) => gitError("RESOURCE_EXHAUSTED", `The remote's ${what} is over ${most} bytes`, { context: {
|
|
69
|
+
reason: "response-too-large",
|
|
70
|
+
limit: most
|
|
71
|
+
} });
|
|
72
|
+
/** A response's body, to read or cancel once: an empty one when it has none. */
|
|
73
|
+
const bodyOf = (response) => response.body ?? new ReadableStream({ start: (controller) => controller.close() });
|
|
74
|
+
/**
|
|
75
|
+
* `body` read whole, at most `most` bytes of it: past that it's cancelled and refused. An
|
|
76
|
+
* interrupted read cancels it, so the connection closes. A push's pack is read from the client's
|
|
77
|
+
* own storage this way, so a read a spent call bound broke stays that bound.
|
|
78
|
+
*/
|
|
79
|
+
const heldBody = (body, most, what) => tryUnlessSpent(async (signal) => {
|
|
80
|
+
const reader = body.getReader();
|
|
81
|
+
const cancel = () => void reader.cancel().catch(() => void 0);
|
|
82
|
+
signal.addEventListener("abort", cancel, { once: true });
|
|
83
|
+
try {
|
|
84
|
+
const chunks = [];
|
|
85
|
+
let size = 0;
|
|
86
|
+
for (let read = await reader.read(); !read.done; read = await reader.read()) {
|
|
87
|
+
size += read.value.length;
|
|
88
|
+
if (size > most) {
|
|
89
|
+
cancel();
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
chunks.push(read.value);
|
|
93
|
+
}
|
|
94
|
+
return joinedBytes(chunks);
|
|
95
|
+
} finally {
|
|
96
|
+
signal.removeEventListener("abort", cancel);
|
|
97
|
+
}
|
|
98
|
+
}, unanswered).pipe(Effect.flatMap((bytes) => bytes === void 0 ? Effect.fail(tooLong(what, most)) : Effect.succeed(bytes)));
|
|
99
|
+
/** A bucket's refusal, as `retry` sees it: its status alone, its body never read. */
|
|
100
|
+
const statusOnly = (response) => Effect.succeed({ status: response.status });
|
|
101
|
+
/**
|
|
102
|
+
* `bytes` PUT to `url` through `options`' transport and `retry`, with no credential, as
|
|
103
|
+
* `GitHttp.putSigned`. Neither the link nor what the transport threw goes in its errors: a link
|
|
104
|
+
* signs its bytes in its query.
|
|
105
|
+
*/
|
|
106
|
+
const putSigned = ({ credentials: _credentials, ...options }) => {
|
|
107
|
+
const bucket = remoteFetch(options, statusOnly);
|
|
108
|
+
return (url, bytes, what) => Effect.gen(function* () {
|
|
109
|
+
const request = yield* Effect.try({
|
|
110
|
+
try: () => new Request(url, {
|
|
111
|
+
method: "PUT",
|
|
112
|
+
body: bytes
|
|
113
|
+
}),
|
|
114
|
+
catch: () => gitError("INTERNAL", `The remote signed ${what} a link that can't be sent`)
|
|
115
|
+
});
|
|
116
|
+
const response = yield* bucket(request).pipe(Effect.mapError(() => gitError("UNAVAILABLE", `The bucket didn't answer ${what}`, { hint: "Push again" })));
|
|
117
|
+
yield* dropped(response);
|
|
118
|
+
if (response.status >= 300) return yield* fail("UNAVAILABLE", `The bucket refused ${what}: ${response.status}`, { hint: "Push again" });
|
|
119
|
+
return response.headers.get("etag") ?? "";
|
|
120
|
+
});
|
|
121
|
+
};
|
|
122
|
+
/** The statuses an `info/refs` redirect answers with. */
|
|
123
|
+
const redirects = /* @__PURE__ */ new Set([
|
|
124
|
+
301,
|
|
125
|
+
302,
|
|
126
|
+
303,
|
|
127
|
+
307,
|
|
128
|
+
308
|
|
129
|
+
]);
|
|
130
|
+
/** The most redirects one `info/refs` follows, as Git's curl does. */
|
|
131
|
+
const redirectsMost = 20;
|
|
132
|
+
/**
|
|
133
|
+
* The repo at `to`, an `info/refs` link that `from`'s redirected to, as Git moves its base after
|
|
134
|
+
* one: on `from`'s origin only, since every later request carries the credential.
|
|
135
|
+
*/
|
|
136
|
+
const movedRepo = (from, to) => {
|
|
137
|
+
const was = new URL(from).origin;
|
|
138
|
+
const at = URL.parse(to);
|
|
139
|
+
if (at === null || !at.pathname.endsWith("/info/refs")) return fail("INTERNAL", "The remote redirected its info/refs somewhere that isn't a repo's");
|
|
140
|
+
const repo = `${at.origin}${at.pathname.slice(0, -10)}`;
|
|
141
|
+
if (at.origin !== was) return fail("FAILED_PRECONDITION", `The repo moved from ${was} to ${at.origin}, and the client follows a redirect on its own origin only`, { hint: `Set the remote's URL to ${repo}` });
|
|
142
|
+
return Effect.succeed(repo);
|
|
143
|
+
};
|
|
144
|
+
/**
|
|
145
|
+
* The remote's smart HTTP at `options.url`, through `options.transport` when it's given. An
|
|
146
|
+
* `info/refs` redirect, which a renamed repo's old name answers, moves where every later request
|
|
147
|
+
* goes, as Git's does, but only on the same origin: one to another origin is refused, and nothing
|
|
148
|
+
* more is sent there. A `fetch` that follows it has already sent that `info/refs` there, without
|
|
149
|
+
* the credential. Any other request's redirect is its refusal, as Git's
|
|
150
|
+
* `http.followRedirects=initial` has it.
|
|
151
|
+
*/
|
|
152
|
+
const gitHttp = (options) => {
|
|
153
|
+
let base = options.url.replace(/\/+$/, "");
|
|
154
|
+
const remote = remoteFetch(options, gitFailure);
|
|
155
|
+
const answer = (request) => remote(request).pipe(Effect.mapError((failed) => failed.kind === "refused" ? failed.error : unanswered(failed.cause)));
|
|
156
|
+
/** `response`'s body, or its refusal: `gitFailure` cancels the body it reads. */
|
|
157
|
+
const answered = (response) => response.ok ? Effect.succeed(bodyOf(response)) : Effect.flatMap(gitFailure(response), (failure) => Effect.fail(failure.error ?? told(response, "")));
|
|
158
|
+
const headers = (protocol, more = {}) => protocol === "v2" ? {
|
|
159
|
+
...more,
|
|
160
|
+
"git-protocol": "version=2"
|
|
161
|
+
} : more;
|
|
162
|
+
const advertisement = (service, protocol) => Effect.gen(function* () {
|
|
163
|
+
let at = base;
|
|
164
|
+
for (let followed = 0;; followed += 1) {
|
|
165
|
+
const asked = `${at}/info/refs?${new URLSearchParams({ service })}`;
|
|
166
|
+
const response = yield* answer(new Request(asked, { headers: headers(protocol) }));
|
|
167
|
+
const went = response.redirected ? response.url : asked;
|
|
168
|
+
const location = redirects.has(response.status) ? response.headers.get("location") : null;
|
|
169
|
+
const to = location === null ? went : URL.parse(location, went)?.href ?? "";
|
|
170
|
+
if (to !== asked) at = yield* movedRepo(asked, to).pipe(Effect.tapError(() => dropped(response)));
|
|
171
|
+
if (location === null) {
|
|
172
|
+
const body = yield* answered(response);
|
|
173
|
+
base = at;
|
|
174
|
+
return body;
|
|
175
|
+
}
|
|
176
|
+
yield* dropped(response);
|
|
177
|
+
if (followed === redirectsMost) return yield* fail("INTERNAL", `The remote redirected its info/refs over ${redirectsMost} times`);
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
/** A POST to `path` under the repo, at the base when it's sent, once an advertisement moved it. */
|
|
181
|
+
const send = (path, init) => Effect.suspend(() => Effect.flatMap(answer(new Request(`${base}/${path}`, {
|
|
182
|
+
method: "POST",
|
|
183
|
+
...init
|
|
184
|
+
})), answered));
|
|
185
|
+
return {
|
|
186
|
+
advertisement,
|
|
187
|
+
post: (service, protocol, body) => send(service, {
|
|
188
|
+
headers: headers(protocol, {
|
|
189
|
+
accept: `application/x-${service}-result`,
|
|
190
|
+
"content-type": `application/x-${service}-request`
|
|
191
|
+
}),
|
|
192
|
+
body
|
|
193
|
+
}),
|
|
194
|
+
postJson: (path, body) => send(path, {
|
|
195
|
+
headers: { "content-type": "application/json" },
|
|
196
|
+
body: JSON.stringify(body)
|
|
197
|
+
}),
|
|
198
|
+
putSigned: putSigned(options)
|
|
199
|
+
};
|
|
200
|
+
};
|
|
201
|
+
export { gitFailure, gitHttp, heldBody };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// src/client/helper-node.ts
|
|
2
|
+
function missingNode() {
|
|
3
|
+
throw new Error("git-remote-ref0 runs in Node");
|
|
4
|
+
}
|
|
5
|
+
/** Node's process and modules, read when the helper runs, never when its entry is imported. */
|
|
6
|
+
const helperNode = () => {
|
|
7
|
+
const process = globalThis.process ?? missingNode();
|
|
8
|
+
return {
|
|
9
|
+
process,
|
|
10
|
+
fs: process.getBuiltinModule("node:fs"),
|
|
11
|
+
open: process.getBuiltinModule("node:fs/promises").open,
|
|
12
|
+
tmpdir: process.getBuiltinModule("node:os").tmpdir
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
/** `chunk` written to `stream`, once it's taken. */
|
|
16
|
+
const written = (stream, chunk) => new Promise((done, failed) => {
|
|
17
|
+
stream.write(chunk, (error) => error === void 0 || error === null ? done() : failed(error));
|
|
18
|
+
});
|
|
19
|
+
export { helperNode, written };
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { clocksOf } from "../core/clock.mjs";
|
|
2
|
+
import { blobCalls } from "../core/objects/blobs.mjs";
|
|
3
|
+
import { commitCalls } from "../core/objects/commits.mjs";
|
|
4
|
+
import { fileCalls } from "../core/objects/files.mjs";
|
|
5
|
+
import { mergeCalls } from "../core/objects/merges.mjs";
|
|
6
|
+
import { tagCalls } from "../core/objects/tags.mjs";
|
|
7
|
+
import { treeCalls } from "../core/objects/trees.mjs";
|
|
8
|
+
import { promiseCalls } from "../core/promise.mjs";
|
|
9
|
+
import { refCalls } from "../core/refs.mjs";
|
|
10
|
+
import { cursorSeal } from "../store/cursor-seal.mjs";
|
|
11
|
+
import { repackJob, repackJobRow } from "../core/repack.mjs";
|
|
12
|
+
import { defaultBranch, newRepoRecord } from "../core/repos.mjs";
|
|
13
|
+
import { SealedObjects } from "../core/view.mjs";
|
|
14
|
+
import { engineParts } from "../engine/parts.mjs";
|
|
15
|
+
import { entryOf } from "../store/catalogue.mjs";
|
|
16
|
+
import { gitError } from "../store/errors.mjs";
|
|
17
|
+
import { gitStore } from "../store/git-store.mjs";
|
|
18
|
+
import { newInternalId } from "../store/scopes.mjs";
|
|
19
|
+
import { resultIn } from "../store/crossing.mjs";
|
|
20
|
+
import { defaultFetchLimits } from "../storage/fetch.mjs";
|
|
21
|
+
import { loose } from "../storage/loose.mjs";
|
|
22
|
+
import * as Effect from "effect/Effect";
|
|
23
|
+
import { memory } from "@ref0/infra/memory";
|
|
24
|
+
// src/client/local.ts
|
|
25
|
+
/** The one repo a client's storage holds, by the name its catalogue lists it under. */
|
|
26
|
+
const localRepo = "local";
|
|
27
|
+
/** Whom a client's local calls act for: its own storage, which nothing else reaches. */
|
|
28
|
+
const localCaller = { actor: { anonymous: true } };
|
|
29
|
+
const noEngine = gitError("FAILED_PRECONDITION", "This call walks, diffs or merges: it needs an engine", { hint: "Pass engine() to createGitClient" });
|
|
30
|
+
/** A client's engine when `createGitClient` names none: each call that needs one refuses. */
|
|
31
|
+
const refusingEngine = {
|
|
32
|
+
calls: {
|
|
33
|
+
merge: () => Effect.fail(noEngine),
|
|
34
|
+
diff: () => Effect.fail(noEngine),
|
|
35
|
+
mergeBase: () => Effect.fail(noEngine),
|
|
36
|
+
walk: () => Effect.fail(noEngine)
|
|
37
|
+
},
|
|
38
|
+
mergeTrees: () => Effect.fail(noEngine),
|
|
39
|
+
load: Effect.fail(noEngine)
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* `calls`, each on the local repo once `ready`, for the local caller: its input as a client gives
|
|
43
|
+
* it, with no actor, which the bound caller stands in for.
|
|
44
|
+
*/
|
|
45
|
+
const localized = (calls, ready) => {
|
|
46
|
+
const entries = Object.entries(calls).map(([name, value]) => {
|
|
47
|
+
const call = value;
|
|
48
|
+
const local = (input) => Effect.andThen(ready, call(localRepo, {
|
|
49
|
+
...input,
|
|
50
|
+
actor: localCaller.actor
|
|
51
|
+
}));
|
|
52
|
+
return [name, local];
|
|
53
|
+
});
|
|
54
|
+
return Object.fromEntries(entries);
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* The local repo, once: its record written, and listed in the catalogue, unless the store holds
|
|
58
|
+
* it already, as an adapter kept from an earlier client's does. A create another client on the
|
|
59
|
+
* same store wins stands aside, through `repos.create`'s own write.
|
|
60
|
+
*/
|
|
61
|
+
const madeRepo = (core) => Effect.gen(function* () {
|
|
62
|
+
const { store } = core;
|
|
63
|
+
const entry = yield* entryOf(store, localRepo);
|
|
64
|
+
if (entry !== void 0 && entry.deleted !== true) return;
|
|
65
|
+
const at = yield* core.now;
|
|
66
|
+
const record = {
|
|
67
|
+
name: localRepo,
|
|
68
|
+
revision: (entry?.sourceRevision ?? 0) + 1,
|
|
69
|
+
defaultBranch,
|
|
70
|
+
public: false,
|
|
71
|
+
createdAt: at,
|
|
72
|
+
changedAt: at
|
|
73
|
+
};
|
|
74
|
+
yield* newRepoRecord(store, newInternalId(), entry, { record });
|
|
75
|
+
});
|
|
76
|
+
/**
|
|
77
|
+
* The repo made once, its first callers sharing the one make; one that fails is made again by
|
|
78
|
+
* the next caller.
|
|
79
|
+
*/
|
|
80
|
+
const once = (make) => {
|
|
81
|
+
let made;
|
|
82
|
+
return Effect.suspend(() => {
|
|
83
|
+
if (made !== void 0) return Effect.promise(() => made ?? Promise.resolve());
|
|
84
|
+
return make.pipe(Effect.tap(() => Effect.sync(() => {
|
|
85
|
+
made = Promise.resolve();
|
|
86
|
+
})));
|
|
87
|
+
});
|
|
88
|
+
};
|
|
89
|
+
/** The engine's parts, or the refusing engine when none is given; a `TypeError` for a stranger. */
|
|
90
|
+
const engineOf = (given) => {
|
|
91
|
+
if (given === void 0) return refusingEngine;
|
|
92
|
+
const parts = engineParts(given);
|
|
93
|
+
if (parts === void 0) throw new TypeError("options.engine must be one engine() made");
|
|
94
|
+
return parts;
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* A client's local side over `adapter`, a memory store when left out, and `objects`, `loose()`
|
|
98
|
+
* when left out: the server's core, with no queue, deciding everything for its own caller.
|
|
99
|
+
*/
|
|
100
|
+
const localSide = (options) => {
|
|
101
|
+
const adapter = options.adapter ?? { store: memory.store() };
|
|
102
|
+
const { store } = adapter;
|
|
103
|
+
const { clock, now } = clocksOf(adapter.clock);
|
|
104
|
+
const objects = (options.objects ?? loose()).open({
|
|
105
|
+
store: promiseCalls(gitStore(store), resultIn),
|
|
106
|
+
bucket: adapter.bucket,
|
|
107
|
+
clock,
|
|
108
|
+
fetchLimits: defaultFetchLimits
|
|
109
|
+
});
|
|
110
|
+
const sealed = new SealedObjects(objects);
|
|
111
|
+
const repack = repackJob({
|
|
112
|
+
objects: sealed,
|
|
113
|
+
now,
|
|
114
|
+
fetchLimits: defaultFetchLimits
|
|
115
|
+
});
|
|
116
|
+
const core = {
|
|
117
|
+
store,
|
|
118
|
+
objects: sealed,
|
|
119
|
+
engine: engineOf(options.engine),
|
|
120
|
+
now,
|
|
121
|
+
authorize: () => Effect.void,
|
|
122
|
+
audience: () => Effect.succeed({}),
|
|
123
|
+
fences: () => ({
|
|
124
|
+
reads: [],
|
|
125
|
+
check: () => Effect.void
|
|
126
|
+
}),
|
|
127
|
+
checks: {
|
|
128
|
+
reports: {},
|
|
129
|
+
rules: () => []
|
|
130
|
+
},
|
|
131
|
+
fetchRules: {
|
|
132
|
+
reports: {},
|
|
133
|
+
rules: []
|
|
134
|
+
},
|
|
135
|
+
repackJobRow: (at) => repackJobRow(repack, at),
|
|
136
|
+
events: void 0,
|
|
137
|
+
partial: true,
|
|
138
|
+
fetchLimits: defaultFetchLimits
|
|
139
|
+
};
|
|
140
|
+
const ready = once(madeRepo(core));
|
|
141
|
+
const calls = {
|
|
142
|
+
refs: localized(refCalls({
|
|
143
|
+
...core,
|
|
144
|
+
cursors: cursorSeal(store)
|
|
145
|
+
}, localCaller), ready),
|
|
146
|
+
blobs: localized(blobCalls(core, localCaller), ready),
|
|
147
|
+
trees: localized(treeCalls(core, localCaller), ready),
|
|
148
|
+
commits: localized(commitCalls(core, localCaller), ready),
|
|
149
|
+
tags: localized(tagCalls(core, localCaller), ready),
|
|
150
|
+
files: localized(fileCalls(core, localCaller), ready),
|
|
151
|
+
merges: localized(mergeCalls(core, localCaller), ready)
|
|
152
|
+
};
|
|
153
|
+
return {
|
|
154
|
+
core,
|
|
155
|
+
caller: localCaller,
|
|
156
|
+
ready,
|
|
157
|
+
calls
|
|
158
|
+
};
|
|
159
|
+
};
|
|
160
|
+
export { localRepo, localSide };
|