@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,416 @@
|
|
|
1
|
+
import { crc32Update } from "../protocol/bytes/crc32.mjs";
|
|
2
|
+
import { deflateWhole } from "../protocol/bytes/deflate.mjs";
|
|
3
|
+
import { Sha1 } from "../protocol/bytes/sha1.mjs";
|
|
4
|
+
import { readCommitGraph, writeCommitGraph } from "../protocol/packs/graph.mjs";
|
|
5
|
+
import { readEntryHeader } from "../protocol/packs/reader.mjs";
|
|
6
|
+
import { writePackIndex } from "../protocol/packs/rev.mjs";
|
|
7
|
+
import { fixedRoom } from "../protocol/packs/indexer.mjs";
|
|
8
|
+
import { entryHeader } from "../protocol/packs/writer.mjs";
|
|
9
|
+
import { gitError } from "../store/errors.mjs";
|
|
10
|
+
import { bucketPut, bucketStart, bucketTry } from "./calls.mjs";
|
|
11
|
+
import { packFiles } from "./layout.mjs";
|
|
12
|
+
import { linksOf } from "./links.mjs";
|
|
13
|
+
import { headerLimits, packIndexerLimits, packObjects, readCacheBytes, readWhole } from "./pack-reads.mjs";
|
|
14
|
+
import { dropRefused, openQuarantine } from "./quarantine.mjs";
|
|
15
|
+
import * as Effect from "effect/Effect";
|
|
16
|
+
import * as Hex from "effect/encoding/Hex";
|
|
17
|
+
// src/storage/merge.ts
|
|
18
|
+
/** The order a merged pack keeps its objects in, by kind: history first, as Git writes it. */
|
|
19
|
+
const kindOrder = [
|
|
20
|
+
"commit",
|
|
21
|
+
"tag",
|
|
22
|
+
"tree",
|
|
23
|
+
"blob"
|
|
24
|
+
];
|
|
25
|
+
const lost = (message) => gitError("DATA_LOSS", message);
|
|
26
|
+
/**
|
|
27
|
+
* Every entry of one input pack, in its offset order, each delta's kind its base's. A stored pack
|
|
28
|
+
* holds only whole entries and `REF_DELTA`s whose base is in the same pack and before it, as a
|
|
29
|
+
* receive checks and each writer keeps. A whole entry may be a file up to `packFileBytes`,
|
|
30
|
+
* which the merge copies as stored.
|
|
31
|
+
*/
|
|
32
|
+
const entriesOf = Effect.fnUntraced(function* (blocks, indexed, input) {
|
|
33
|
+
const { pack, index } = indexed;
|
|
34
|
+
const placed = Array.from({ length: index.count }, (_, rank) => index.object(rank)).sort((a, b) => a.offset - b.offset);
|
|
35
|
+
const read = [];
|
|
36
|
+
for (const [at, object] of placed.entries()) {
|
|
37
|
+
const end = placed[at + 1]?.offset ?? pack.bytes - 20;
|
|
38
|
+
const head = yield* blocks.headAt(pack, object.offset);
|
|
39
|
+
const header = readEntryHeader(head, head.byteLength, object.offset, headerLimits);
|
|
40
|
+
if (header.kind !== "entry" || header.type === "ofs") return yield* Effect.fail(lost(`Pack ${pack.id} has an entry at ${object.offset} no merge takes`));
|
|
41
|
+
const base = header.base?.kind === "oid" ? header.base.oid : void 0;
|
|
42
|
+
const size = base === void 0 ? 0 : header.size;
|
|
43
|
+
read.push({
|
|
44
|
+
...object,
|
|
45
|
+
input,
|
|
46
|
+
length: end - object.offset,
|
|
47
|
+
kind: header.type,
|
|
48
|
+
base,
|
|
49
|
+
size
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
const byOid = new Map(read.map((entry) => [entry.oid, entry]));
|
|
53
|
+
const chainOf = (entry) => {
|
|
54
|
+
let at = entry;
|
|
55
|
+
for (let depth = 0; at !== void 0 && depth <= read.length; depth += 1) {
|
|
56
|
+
if (at.kind !== "ref") return {
|
|
57
|
+
kind: at.kind,
|
|
58
|
+
depth
|
|
59
|
+
};
|
|
60
|
+
at = at.base === void 0 ? void 0 : byOid.get(at.base);
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
const entries = [];
|
|
64
|
+
for (const entry of read) {
|
|
65
|
+
const chain = chainOf(entry);
|
|
66
|
+
if (chain === void 0) return yield* Effect.fail(lost(`Pack ${pack.id}'s delta ${entry.oid} has no base in it`));
|
|
67
|
+
entries.push({
|
|
68
|
+
...entry,
|
|
69
|
+
...chain
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
return entries;
|
|
73
|
+
});
|
|
74
|
+
/**
|
|
75
|
+
* Which entries a merge writes, and in what order: each object's entry whose chain in its own pack
|
|
76
|
+
* is shortest, the first such across the inputs, in their order then their offsets'; only those
|
|
77
|
+
* `keep` says, by kind, and each delta after its base when the base is kept too. A delta whose
|
|
78
|
+
* base isn't kept is written whole, as `planOf` says, so a merge never carries an object it
|
|
79
|
+
* wasn't asked for, whose own links it wouldn't hold. A chain is then no deeper than any input's:
|
|
80
|
+
* a delta's base is the one of least depth, so at most its own pack's base's, and a base is
|
|
81
|
+
* always shallower than its delta, so no chain loops.
|
|
82
|
+
*/
|
|
83
|
+
const ordered = (inputs, keep) => {
|
|
84
|
+
const first = /* @__PURE__ */ new Map();
|
|
85
|
+
for (const entries of inputs) for (const entry of entries) {
|
|
86
|
+
const held = first.get(entry.oid);
|
|
87
|
+
if (held === void 0 || entry.depth < held.depth) first.set(entry.oid, entry);
|
|
88
|
+
}
|
|
89
|
+
const kept = new Set([...first.keys()].filter(keep));
|
|
90
|
+
const written = /* @__PURE__ */ new Set();
|
|
91
|
+
const order = [];
|
|
92
|
+
const emit = (entry) => {
|
|
93
|
+
const chain = [];
|
|
94
|
+
for (let at = entry; at !== void 0 && !written.has(at.oid);) {
|
|
95
|
+
chain.push(at);
|
|
96
|
+
written.add(at.oid);
|
|
97
|
+
at = at.base === void 0 || !kept.has(at.base) ? void 0 : first.get(at.base);
|
|
98
|
+
}
|
|
99
|
+
order.push(...chain.reverse());
|
|
100
|
+
};
|
|
101
|
+
for (const kind of kindOrder) for (const entry of first.values()) if (entry.kind === kind && kept.has(entry.oid)) emit(entry);
|
|
102
|
+
return {
|
|
103
|
+
order,
|
|
104
|
+
held: new Set(first.keys())
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
/** An object as a whole entry: its header and one zlib member, and their CRC-32. */
|
|
108
|
+
const wholeEntry = Effect.fnUntraced(function* (object) {
|
|
109
|
+
const header = entryHeader(object.type, object.bytes.byteLength);
|
|
110
|
+
const body = yield* deflateWhole(object.bytes).pipe(Effect.mapError((error) => lost(`Object ${object.oid} won't deflate: ${error.message}`)));
|
|
111
|
+
return {
|
|
112
|
+
header,
|
|
113
|
+
body,
|
|
114
|
+
crc32: crc32Update(crc32Update(0, header), body)
|
|
115
|
+
};
|
|
116
|
+
});
|
|
117
|
+
/** The most deltas one chain of a merged pack holds: a read resolves no deeper. */
|
|
118
|
+
const deepestChain = packIndexerLimits.chainReads - 1;
|
|
119
|
+
/**
|
|
120
|
+
* What a merge writes, by kind: `order`'s entries of each kind, then the rows' objects of it. A
|
|
121
|
+
* delta whose base is another pack's entry may make a chain of more instructions than any
|
|
122
|
+
* input's; one past `deltaBytes` of them, or past `deepestChain` deltas, which `ordered` keeps
|
|
123
|
+
* from happening, is resolved from its own pack and written whole, so the chain starts again. So
|
|
124
|
+
* is a delta whose base the merge doesn't write. Each whole entry is deflated here only to learn
|
|
125
|
+
* its length and CRC-32, then let go.
|
|
126
|
+
*/
|
|
127
|
+
const planOf = Effect.fnUntraced(function* (wholeAt, inputs, order, rows) {
|
|
128
|
+
const chains = /* @__PURE__ */ new Map();
|
|
129
|
+
const plan = [];
|
|
130
|
+
const whole = Effect.fnUntraced(function* (oid, from) {
|
|
131
|
+
const object = yield* objectOf(wholeAt, inputs, from);
|
|
132
|
+
const { header, body, crc32 } = yield* wholeEntry(object);
|
|
133
|
+
const bytes = header.byteLength + body.byteLength;
|
|
134
|
+
plan.push({
|
|
135
|
+
kind: "whole",
|
|
136
|
+
oid,
|
|
137
|
+
type: object.type,
|
|
138
|
+
from,
|
|
139
|
+
bytes,
|
|
140
|
+
crc32
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
for (const kind of kindOrder) {
|
|
144
|
+
for (const entry of order) {
|
|
145
|
+
if (entry.kind !== kind) continue;
|
|
146
|
+
const below = entry.base === void 0 ? void 0 : chains.get(entry.base);
|
|
147
|
+
const chain = below === void 0 ? {
|
|
148
|
+
depth: 0,
|
|
149
|
+
bytes: 0
|
|
150
|
+
} : {
|
|
151
|
+
depth: below.depth + 1,
|
|
152
|
+
bytes: below.bytes + entry.size
|
|
153
|
+
};
|
|
154
|
+
if ((entry.base === void 0 || below !== void 0) && chain.depth <= deepestChain && chain.bytes <= packIndexerLimits.deltaBytes) {
|
|
155
|
+
chains.set(entry.oid, chain);
|
|
156
|
+
plan.push({
|
|
157
|
+
kind: "copy",
|
|
158
|
+
entry
|
|
159
|
+
});
|
|
160
|
+
continue;
|
|
161
|
+
}
|
|
162
|
+
chains.set(entry.oid, {
|
|
163
|
+
depth: 0,
|
|
164
|
+
bytes: 0
|
|
165
|
+
});
|
|
166
|
+
const { oid, input, offset } = entry;
|
|
167
|
+
yield* whole(oid, {
|
|
168
|
+
kind: "pack",
|
|
169
|
+
oid,
|
|
170
|
+
input,
|
|
171
|
+
offset
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
for (const row of rows) if (row.type === kind) yield* whole(row.oid, {
|
|
175
|
+
kind: "row",
|
|
176
|
+
object: row
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
return plan;
|
|
180
|
+
});
|
|
181
|
+
/** A whole entry's object: its row's, or resolved from its pack. */
|
|
182
|
+
const objectOf = Effect.fnUntraced(function* (wholeAt, inputs, from) {
|
|
183
|
+
if (from.kind === "row") return from.object;
|
|
184
|
+
const indexed = inputs[from.input];
|
|
185
|
+
if (indexed === void 0) return yield* Effect.die(/* @__PURE__ */ new Error("an entry of no input"));
|
|
186
|
+
return yield* wholeAt(from.oid, indexed, from.offset);
|
|
187
|
+
});
|
|
188
|
+
const plannedBytes = (item) => item.kind === "copy" ? item.entry.length : item.bytes;
|
|
189
|
+
/**
|
|
190
|
+
* A put to `key` of the bytes as they're written, each write awaited, so a slow bucket slows the
|
|
191
|
+
* writer. The put starts at once, its calls counted as its parts go, so its failure ends the next
|
|
192
|
+
* write. With no `options.size`, the bucket takes the bytes as they come, buffering at most
|
|
193
|
+
* `options.atMost` of them a part.
|
|
194
|
+
*/
|
|
195
|
+
const startPut = (bucket, key, options) => bucketStart(bucket, options, (charges) => {
|
|
196
|
+
const { readable, writable } = new TransformStream();
|
|
197
|
+
const writer = writable.getWriter();
|
|
198
|
+
const put = bucket.put(key, readable, {
|
|
199
|
+
...options,
|
|
200
|
+
retrying: charges.retrying
|
|
201
|
+
});
|
|
202
|
+
const ended = put.then(() => void 0, (cause) => ({ cause }));
|
|
203
|
+
let early;
|
|
204
|
+
let failWrite;
|
|
205
|
+
ended.then((end) => {
|
|
206
|
+
early = end?.cause ?? /* @__PURE__ */ new Error("The bucket ended the put early");
|
|
207
|
+
failWrite?.(early);
|
|
208
|
+
});
|
|
209
|
+
const write = (bytes) => Effect.andThen(charges.sending(bytes.byteLength), bucketTry(async () => {
|
|
210
|
+
if (early !== void 0) throw early;
|
|
211
|
+
await new Promise((resolve, reject) => {
|
|
212
|
+
failWrite = reject;
|
|
213
|
+
writer.ready.then(async () => await writer.write(bytes)).then(resolve, reject);
|
|
214
|
+
}).catch(async (cause) => {
|
|
215
|
+
throw (await ended)?.cause ?? cause;
|
|
216
|
+
}).finally(() => {
|
|
217
|
+
failWrite = void 0;
|
|
218
|
+
});
|
|
219
|
+
}));
|
|
220
|
+
return {
|
|
221
|
+
write,
|
|
222
|
+
finish: Effect.uninterruptible(bucketTry(async () => {
|
|
223
|
+
const closed = writer.close();
|
|
224
|
+
closed.catch(() => void 0);
|
|
225
|
+
await put;
|
|
226
|
+
await closed;
|
|
227
|
+
})),
|
|
228
|
+
abort: Effect.promise(async () => {
|
|
229
|
+
writer.abort(/* @__PURE__ */ new Error("The put stopped")).catch(() => void 0);
|
|
230
|
+
await ended;
|
|
231
|
+
})
|
|
232
|
+
};
|
|
233
|
+
});
|
|
234
|
+
/** The commits of each input's `.graph` that the merge writes, and those of its rows. */
|
|
235
|
+
const graphOf = Effect.fnUntraced(function* (bucket, inputs, written, rows) {
|
|
236
|
+
const commits = /* @__PURE__ */ new Map();
|
|
237
|
+
for (const { pack } of inputs) {
|
|
238
|
+
const bytes = yield* readWhole(bucket, packFiles(pack.id).graph);
|
|
239
|
+
if (bytes === void 0) return yield* Effect.fail(lost(`Pack ${pack.id} has no .graph`));
|
|
240
|
+
const graph = yield* readCommitGraph(bytes).pipe(Effect.mapError((error) => lost(`Pack ${pack.id}'s .graph is unreadable: ${error.message}`)));
|
|
241
|
+
for (const commit of graph) if (written.has(commit.oid)) commits.set(commit.oid, commit);
|
|
242
|
+
}
|
|
243
|
+
for (const row of rows) {
|
|
244
|
+
if (row.type !== "commit") continue;
|
|
245
|
+
const links = yield* Effect.fromResult(linksOf(row));
|
|
246
|
+
commits.set(row.oid, {
|
|
247
|
+
oid: row.oid,
|
|
248
|
+
parents: links.slice(1).map((link) => link.oid)
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
return writeCommitGraph([...commits.values()]);
|
|
252
|
+
});
|
|
253
|
+
/** `plan`'s kinds, and its `REF_DELTA`s as `.bases` rows, each by its place in the plan. */
|
|
254
|
+
const indexedOf = (plan) => {
|
|
255
|
+
const kinds = {
|
|
256
|
+
commit: 0,
|
|
257
|
+
tag: 0,
|
|
258
|
+
tree: 0,
|
|
259
|
+
blob: 0
|
|
260
|
+
};
|
|
261
|
+
const placed = /* @__PURE__ */ new Map();
|
|
262
|
+
const rows = [];
|
|
263
|
+
for (const [position, item] of plan.entries()) {
|
|
264
|
+
const oid = item.kind === "copy" ? item.entry.oid : item.oid;
|
|
265
|
+
kinds[item.kind === "copy" ? item.entry.kind : item.type] += 1;
|
|
266
|
+
placed.set(oid, position);
|
|
267
|
+
const base = item.kind === "copy" ? item.entry.base : void 0;
|
|
268
|
+
if (base === void 0) continue;
|
|
269
|
+
const at = placed.get(base);
|
|
270
|
+
if (at === void 0) return void 0;
|
|
271
|
+
rows.push(position, at);
|
|
272
|
+
}
|
|
273
|
+
return {
|
|
274
|
+
kinds,
|
|
275
|
+
bases: Uint32Array.from(rows)
|
|
276
|
+
};
|
|
277
|
+
};
|
|
278
|
+
/** What a merge of `inputs` and `rows` would write: each entry's plan, and the pack's size. */
|
|
279
|
+
const planned = Effect.fnUntraced(function* (input) {
|
|
280
|
+
const { blocks, inputs } = input;
|
|
281
|
+
const keep = input.keep ?? (() => true);
|
|
282
|
+
const entries = yield* Effect.forEach(inputs, (indexed, at) => entriesOf(blocks, indexed, at));
|
|
283
|
+
const { order, held } = ordered(entries, keep);
|
|
284
|
+
const folded = input.rows.filter((row) => !held.has(row.oid) && keep(row.oid));
|
|
285
|
+
const wholeAt = packObjects(blocks, fixedRoom(readCacheBytes));
|
|
286
|
+
const plan = yield* planOf(wholeAt, inputs, order, folded);
|
|
287
|
+
const bytes = 12 + plan.reduce((sum, item) => sum + plannedBytes(item), 0) + 20;
|
|
288
|
+
return {
|
|
289
|
+
plan,
|
|
290
|
+
wholeAt,
|
|
291
|
+
order,
|
|
292
|
+
folded,
|
|
293
|
+
objects: plan.length,
|
|
294
|
+
bytes
|
|
295
|
+
};
|
|
296
|
+
});
|
|
297
|
+
/**
|
|
298
|
+
* The objects and bytes `writeMerged` would write for these inputs, planned as it plans them,
|
|
299
|
+
* whole objects included, with nothing written.
|
|
300
|
+
*/
|
|
301
|
+
const mergedSize = Effect.fnUntraced(function* (input) {
|
|
302
|
+
const { objects, bytes } = yield* planned(input);
|
|
303
|
+
return {
|
|
304
|
+
objects,
|
|
305
|
+
bytes
|
|
306
|
+
};
|
|
307
|
+
});
|
|
308
|
+
/**
|
|
309
|
+
* One pack of `inputs`' entries and `rows`' objects, no object twice, by kind: commits, tags,
|
|
310
|
+
* trees, then blobs, each delta after its base and each row after its kind's entries. Entries are
|
|
311
|
+
* copied as they're stored, so every delta stays a `REF_DELTA` and keeps its CRC-32, unless its
|
|
312
|
+
* chain takes too many instructions, as `planOf` says; a row is deflated whole. The pack opens its
|
|
313
|
+
* `quarantine` row and marker first, as a push's does, then streams its bytes, then its `.idx`,
|
|
314
|
+
* `.rev` and `.graph`; listing it is its step's commit. `undefined` when it would hold nothing,
|
|
315
|
+
* and `'too big'`, before anything is written, when it would pass `most` bytes.
|
|
316
|
+
*/
|
|
317
|
+
const writeMerged = Effect.fnUntraced(function* (input) {
|
|
318
|
+
const { store, bucket, blocks, repo, at, prune, inputs } = input;
|
|
319
|
+
const { plan, wholeAt, order, folded, objects: count, bytes: size } = yield* planned(input);
|
|
320
|
+
if (count === 0) return void 0;
|
|
321
|
+
if (size > input.most) return "too big";
|
|
322
|
+
const laid = indexedOf(plan);
|
|
323
|
+
if (laid === void 0) return yield* Effect.die(/* @__PURE__ */ new Error("a delta planned before its base"));
|
|
324
|
+
const opened = yield* openQuarantine({
|
|
325
|
+
store,
|
|
326
|
+
bucket,
|
|
327
|
+
repo,
|
|
328
|
+
at,
|
|
329
|
+
prune
|
|
330
|
+
});
|
|
331
|
+
const files = packFiles(opened.pack);
|
|
332
|
+
const sha = new Sha1();
|
|
333
|
+
const upload = yield* startPut(bucket, files.pack, { size });
|
|
334
|
+
const indexed = [];
|
|
335
|
+
let offset = 0;
|
|
336
|
+
const send = (bytes) => {
|
|
337
|
+
sha.update(bytes);
|
|
338
|
+
offset += bytes.byteLength;
|
|
339
|
+
return upload.write(bytes);
|
|
340
|
+
};
|
|
341
|
+
const stream = Effect.gen(function* () {
|
|
342
|
+
const header = /* @__PURE__ */ new Uint8Array(12);
|
|
343
|
+
header.set([
|
|
344
|
+
80,
|
|
345
|
+
65,
|
|
346
|
+
67,
|
|
347
|
+
75
|
|
348
|
+
]);
|
|
349
|
+
new DataView(header.buffer).setUint32(4, 2);
|
|
350
|
+
new DataView(header.buffer).setUint32(8, count);
|
|
351
|
+
yield* send(header);
|
|
352
|
+
for (const item of plan) {
|
|
353
|
+
if (item.kind === "whole") {
|
|
354
|
+
const { header, body, crc32 } = yield* wholeEntry(yield* objectOf(wholeAt, inputs, item.from));
|
|
355
|
+
if (header.byteLength + body.byteLength !== item.bytes || crc32 !== item.crc32) return yield* Effect.fail(lost(`Object ${item.oid} deflated differently a second time`));
|
|
356
|
+
indexed.push({
|
|
357
|
+
oid: item.oid,
|
|
358
|
+
offset,
|
|
359
|
+
crc32
|
|
360
|
+
});
|
|
361
|
+
yield* send(header);
|
|
362
|
+
yield* send(body);
|
|
363
|
+
continue;
|
|
364
|
+
}
|
|
365
|
+
const { entry } = item;
|
|
366
|
+
const pack = inputs[entry.input]?.pack;
|
|
367
|
+
if (pack === void 0) return yield* Effect.die(/* @__PURE__ */ new Error("an entry of no input"));
|
|
368
|
+
indexed.push({
|
|
369
|
+
oid: entry.oid,
|
|
370
|
+
offset,
|
|
371
|
+
crc32: entry.crc32
|
|
372
|
+
});
|
|
373
|
+
const source = blocks.sourceAt(pack, entry.offset);
|
|
374
|
+
for (let left = entry.length; left > 0;) {
|
|
375
|
+
const piece = yield* source.read;
|
|
376
|
+
if (piece === void 0) return yield* Effect.fail(lost(`Pack ${pack.id} ended early`));
|
|
377
|
+
const taken = piece.subarray(0, Math.min(left, piece.byteLength));
|
|
378
|
+
yield* send(taken);
|
|
379
|
+
left -= taken.byteLength;
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
const trailer = sha.digest();
|
|
383
|
+
yield* upload.write(trailer);
|
|
384
|
+
yield* upload.finish;
|
|
385
|
+
return Hex.encode(trailer);
|
|
386
|
+
}).pipe(Effect.onError(() => upload.abort));
|
|
387
|
+
yield* Effect.gen(function* () {
|
|
388
|
+
const checksum = yield* stream;
|
|
389
|
+
const written = yield* writePackIndex(indexed, checksum).pipe(Effect.mapError((error) => lost(`The merged pack won't index: ${error.message}`)));
|
|
390
|
+
const commits = new Set(order.filter((entry) => entry.kind === "commit").map((e) => e.oid));
|
|
391
|
+
const graph = yield* graphOf(bucket, inputs, commits, folded);
|
|
392
|
+
const putFile = (key, bytes) => bucketPut(bucket, (retrying) => bucket.put(key, new Blob([new Uint8Array(bytes)]).stream(), {
|
|
393
|
+
size: bytes.byteLength,
|
|
394
|
+
retrying
|
|
395
|
+
}));
|
|
396
|
+
yield* putFile(files.idx, written.index);
|
|
397
|
+
yield* putFile(files.rev, written.reverse);
|
|
398
|
+
yield* putFile(files.pos, written.positions);
|
|
399
|
+
yield* putFile(files.graph, graph);
|
|
400
|
+
}).pipe(Effect.onError(() => dropRefused({
|
|
401
|
+
store,
|
|
402
|
+
bucket,
|
|
403
|
+
repo,
|
|
404
|
+
pack: opened.pack
|
|
405
|
+
})));
|
|
406
|
+
return {
|
|
407
|
+
pack: {
|
|
408
|
+
id: opened.pack,
|
|
409
|
+
objects: count,
|
|
410
|
+
bytes: size
|
|
411
|
+
},
|
|
412
|
+
quarantine: opened.quarantine,
|
|
413
|
+
...laid
|
|
414
|
+
};
|
|
415
|
+
});
|
|
416
|
+
export { mergedSize, startPut, writeMerged };
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import { streamOf } from "../protocol/bytes/streams.mjs";
|
|
2
|
+
import { emptyTree, objectId, objectTypes } from "../protocol/objects/object.mjs";
|
|
3
|
+
import { fail } from "../store/errors.mjs";
|
|
4
|
+
import { repoScope } from "../store/scopes.mjs";
|
|
5
|
+
import { objectCollections } from "./layout.mjs";
|
|
6
|
+
import { limits } from "@ref0/infra";
|
|
7
|
+
import * as Effect from "effect/Effect";
|
|
8
|
+
import * as Result from "effect/Result";
|
|
9
|
+
import * as Schema from "effect/Schema";
|
|
10
|
+
import * as Option from "effect/Option";
|
|
11
|
+
import * as Base64 from "effect/encoding/Base64";
|
|
12
|
+
// src/storage/object-rows.ts
|
|
13
|
+
/** One object as a row, by its ID: its type and its body as base64, the header left out. */
|
|
14
|
+
const ObjectRow = Schema.Struct({
|
|
15
|
+
type: Schema.Literals(objectTypes),
|
|
16
|
+
data: Schema.String
|
|
17
|
+
});
|
|
18
|
+
/**
|
|
19
|
+
* A row's value's bytes as JSON writes it: its type and its base64 need no escape, so it's its
|
|
20
|
+
* fields' lengths and the JSON around them, each character one byte.
|
|
21
|
+
*/
|
|
22
|
+
const rowValueBytes = (value) => 21 + value.type.length + value.data.length;
|
|
23
|
+
const decodeObjectRow = Schema.decodeUnknownOption(ObjectRow);
|
|
24
|
+
const objectKey = (oid) => ({
|
|
25
|
+
collection: objectCollections.objects,
|
|
26
|
+
id: oid
|
|
27
|
+
});
|
|
28
|
+
const objectRow = (object) => ({
|
|
29
|
+
...objectKey(object.oid),
|
|
30
|
+
value: {
|
|
31
|
+
type: object.type,
|
|
32
|
+
data: Base64.encode(object.bytes)
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
/**
|
|
36
|
+
* A stored object row, its body hashed again against its ID: a row that doesn't decode, or
|
|
37
|
+
* whose bytes name another object, is `DATA_LOSS`.
|
|
38
|
+
*/
|
|
39
|
+
const objectOfRow = Effect.fnUntraced(function* (row) {
|
|
40
|
+
const what = `Object ${row.id}`;
|
|
41
|
+
const stored = decodeObjectRow(row.value);
|
|
42
|
+
if (Option.isNone(stored)) return yield* fail("DATA_LOSS", `${what} is unreadable`);
|
|
43
|
+
const decoded = Base64.decode(stored.value.data);
|
|
44
|
+
if (Result.isFailure(decoded)) return yield* fail("DATA_LOSS", `${what} isn't base64`);
|
|
45
|
+
const bytes = new Uint8Array(decoded.success);
|
|
46
|
+
const type = stored.value.type;
|
|
47
|
+
const oid = yield* objectId({
|
|
48
|
+
type,
|
|
49
|
+
bytes
|
|
50
|
+
});
|
|
51
|
+
if (oid !== row.id) return yield* fail("DATA_LOSS", `${what}'s bytes hash to ${oid}`);
|
|
52
|
+
return {
|
|
53
|
+
oid,
|
|
54
|
+
type,
|
|
55
|
+
bytes
|
|
56
|
+
};
|
|
57
|
+
});
|
|
58
|
+
/**
|
|
59
|
+
* A stored object row's type, and its body's size from its base64's length, padded as `objectRow`
|
|
60
|
+
* writes it: the body neither decoded nor hashed, as a pack entry's header is trusted for its
|
|
61
|
+
* size. A row that doesn't decode, or whose base64 can't be a body's, is `DATA_LOSS`.
|
|
62
|
+
*/
|
|
63
|
+
const headerOfRow = Effect.fnUntraced(function* (row) {
|
|
64
|
+
const what = `Object ${row.id}`;
|
|
65
|
+
const stored = decodeObjectRow(row.value);
|
|
66
|
+
if (Option.isNone(stored)) return yield* fail("DATA_LOSS", `${what} is unreadable`);
|
|
67
|
+
const { data } = stored.value;
|
|
68
|
+
if (data.length % 4 !== 0) return yield* fail("DATA_LOSS", `${what} isn't base64`);
|
|
69
|
+
const padding = data.endsWith("==") ? 2 : data.endsWith("=") ? 1 : 0;
|
|
70
|
+
return {
|
|
71
|
+
type: stored.value.type,
|
|
72
|
+
size: data.length / 4 * 3 - padding
|
|
73
|
+
};
|
|
74
|
+
});
|
|
75
|
+
/** A whole object as the contract's, its bytes one piece of a stream. */
|
|
76
|
+
const gitObjectOf = (object) => ({
|
|
77
|
+
oid: object.oid,
|
|
78
|
+
type: object.type,
|
|
79
|
+
size: object.bytes.byteLength,
|
|
80
|
+
bytes: streamOf(object.bytes.slice())
|
|
81
|
+
});
|
|
82
|
+
/**
|
|
83
|
+
* The object rows a receive's change puts, by ID, readable before the commit that writes them:
|
|
84
|
+
* so a push's walk reads the new tips it carries.
|
|
85
|
+
*/
|
|
86
|
+
const receivedRows = (change) => new Map((change?.put ?? []).flatMap((row) => row.collection === objectCollections.objects ? [[row.id, row]] : []));
|
|
87
|
+
/**
|
|
88
|
+
* Object rows a store read refused as too large is cut into: as many of the largest as one answer
|
|
89
|
+
* holds, each row's key and version aside, so no read of them passes its 16 MiB.
|
|
90
|
+
*/
|
|
91
|
+
const largeBatch = Math.floor(limits.answerBytes / limits.valueBytes) - 1;
|
|
92
|
+
/** The empty tree, which every repo holds without storing it. */
|
|
93
|
+
const emptyTreeObject = {
|
|
94
|
+
oid: emptyTree,
|
|
95
|
+
type: "tree",
|
|
96
|
+
bytes: /* @__PURE__ */ new Uint8Array(0)
|
|
97
|
+
};
|
|
98
|
+
const tooLargeRead = (error) => error.code === "RESOURCE_EXHAUSTED" && error.context?.["reason"] === "too-large";
|
|
99
|
+
/**
|
|
100
|
+
* Each of `ids`' object rows the repo holds, a store read's answer at a time, with the version it's
|
|
101
|
+
* read at: `rowReadBatch` to a read, or `largeBatch` where those rows passed one answer's 16 MiB. Only
|
|
102
|
+
* one read's rows are held, and the reads end once `each` answers `false`.
|
|
103
|
+
*/
|
|
104
|
+
const eachRead = (store, repo, ids, each) => {
|
|
105
|
+
const read = (keys) => store.read({
|
|
106
|
+
scope: repoScope(repo),
|
|
107
|
+
reads: keys
|
|
108
|
+
});
|
|
109
|
+
const readAll = Effect.fnUntraced(function* (keys) {
|
|
110
|
+
const answer = yield* read(keys).pipe(Effect.catchIf(tooLargeRead, () => Effect.succeed(void 0)));
|
|
111
|
+
if (answer !== void 0) return yield* each(answer.results.flat(), answer.version);
|
|
112
|
+
for (let at = 0; at < keys.length; at += largeBatch) {
|
|
113
|
+
const cut = yield* read(keys.slice(at, at + largeBatch));
|
|
114
|
+
if (!(yield* each(cut.results.flat(), cut.version))) return false;
|
|
115
|
+
}
|
|
116
|
+
return true;
|
|
117
|
+
});
|
|
118
|
+
return Effect.gen(function* () {
|
|
119
|
+
const asked = [...new Set(ids)].filter((id) => id !== emptyTree);
|
|
120
|
+
for (let at = 0; at < asked.length; at += 100) {
|
|
121
|
+
const keys = asked.slice(at, at + 100).map((id) => ({
|
|
122
|
+
collection: objectCollections.objects,
|
|
123
|
+
id
|
|
124
|
+
}));
|
|
125
|
+
if (!(yield* readAll(keys))) return;
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
};
|
|
129
|
+
/** Each of `oids`' rows the repo holds, handed to `each` a store read at a time, as `eachRead` reads. */
|
|
130
|
+
const eachRow = (store, listed, oids, each) => eachRead(store, listed.repo, oids, Effect.fnUntraced(function* (rows) {
|
|
131
|
+
for (const row of rows) yield* each(row);
|
|
132
|
+
return true;
|
|
133
|
+
}));
|
|
134
|
+
/**
|
|
135
|
+
* Which of `ids` a repo holds as object rows, read by key as `eachRead` reads, each read at
|
|
136
|
+
* `version`: `undefined` once one answers at another, since the repo moved after the read the
|
|
137
|
+
* answer joins, and that read is taken again.
|
|
138
|
+
*/
|
|
139
|
+
const heldIdsAt = Effect.fnUntraced(function* (store, repo, version, ids) {
|
|
140
|
+
const held = /* @__PURE__ */ new Set();
|
|
141
|
+
let moved = false;
|
|
142
|
+
yield* eachRead(store, repo, ids, (rows, at) => Effect.sync(() => {
|
|
143
|
+
moved = at !== version;
|
|
144
|
+
if (!moved) for (const { id } of rows) held.add(id);
|
|
145
|
+
return !moved;
|
|
146
|
+
}));
|
|
147
|
+
return moved ? void 0 : held;
|
|
148
|
+
});
|
|
149
|
+
/**
|
|
150
|
+
* Each page of a repo's object rows, in ID order, handed to `each` before the next is read, every
|
|
151
|
+
* page read at `version`: `rowReadBatch` rows to a read, or `largeBatch` where those passed one
|
|
152
|
+
* answer's 16 MiB. `true` once every row is read; `false` once a page answers at another version,
|
|
153
|
+
* since the repo moved after the read it joins, or once `each` answers `false`.
|
|
154
|
+
*/
|
|
155
|
+
const eachPageAt = Effect.fnUntraced(function* (store, repo, version, each) {
|
|
156
|
+
const page = (after, limit) => {
|
|
157
|
+
const read = {
|
|
158
|
+
collection: objectCollections.objects,
|
|
159
|
+
limit
|
|
160
|
+
};
|
|
161
|
+
if (after !== void 0) read.after = after;
|
|
162
|
+
return Effect.map(store.read({
|
|
163
|
+
scope: repoScope(repo),
|
|
164
|
+
reads: [read]
|
|
165
|
+
}), ({ version: at, results }) => ({
|
|
166
|
+
at,
|
|
167
|
+
rows: results[0] ?? [],
|
|
168
|
+
limit
|
|
169
|
+
}));
|
|
170
|
+
};
|
|
171
|
+
let after;
|
|
172
|
+
for (;;) {
|
|
173
|
+
const { at, rows, limit } = yield* page(after, 100).pipe(Effect.catchIf(tooLargeRead, () => page(after, largeBatch)));
|
|
174
|
+
if (at !== version || !(yield* each(rows))) return false;
|
|
175
|
+
const last = rows.at(-1);
|
|
176
|
+
if (last === void 0 || rows.length < limit) return true;
|
|
177
|
+
after = last.id;
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
/** A repo's object rows `oids` names, each handed on as it's read: the empty tree among them. */
|
|
181
|
+
const eachHeldRow = (store, listed) => (oids, each) => Effect.gen(function* () {
|
|
182
|
+
if (oids.includes("4b825dc642cb6eb9a060e54bf8d69288fbee4904")) yield* each(emptyTreeObject);
|
|
183
|
+
yield* eachRow(store, listed, oids, (row) => Effect.flatMap(objectOfRow(row), each));
|
|
184
|
+
});
|
|
185
|
+
/** A repo's object rows by ID, read whole: those it holds, the empty tree among them. */
|
|
186
|
+
const heldRows = (store, listed) => (oids) => Effect.gen(function* () {
|
|
187
|
+
const held = /* @__PURE__ */ new Map();
|
|
188
|
+
yield* eachHeldRow(store, listed)(oids, (object) => Effect.sync(() => void held.set(object.oid, object)));
|
|
189
|
+
return held;
|
|
190
|
+
});
|
|
191
|
+
/**
|
|
192
|
+
* The type and size of each of `oids`' rows the repo holds, the empty tree's among them, the size
|
|
193
|
+
* from each row's base64: no body decoded or hashed, though each row is read whole, as the store
|
|
194
|
+
* has no part read.
|
|
195
|
+
*/
|
|
196
|
+
const rowHeaders = (store, listed) => (oids) => Effect.gen(function* () {
|
|
197
|
+
const headers = /* @__PURE__ */ new Map();
|
|
198
|
+
if (oids.includes("4b825dc642cb6eb9a060e54bf8d69288fbee4904")) headers.set(emptyTree, {
|
|
199
|
+
type: "tree",
|
|
200
|
+
size: 0
|
|
201
|
+
});
|
|
202
|
+
const asked = new Map(oids.map((oid) => [oid, oid]));
|
|
203
|
+
yield* eachRow(store, listed, oids, (row) => Effect.map(headerOfRow(row), (header) => {
|
|
204
|
+
const oid = asked.get(row.id);
|
|
205
|
+
if (oid !== void 0) headers.set(oid, header);
|
|
206
|
+
}));
|
|
207
|
+
return headers;
|
|
208
|
+
});
|
|
209
|
+
/** The size of each of `oids`' rows the repo holds, as `rowHeaders` reads it. */
|
|
210
|
+
const rowSizes = (store, listed) => (oids) => Effect.map(rowHeaders(store, listed)(oids), (headers) => new Map([...headers].map(([oid, { size }]) => [oid, size])));
|
|
211
|
+
export { ObjectRow, eachHeldRow, eachPageAt, emptyTreeObject, gitObjectOf, heldIdsAt, heldRows, largeBatch, objectKey, objectOfRow, objectRow, receivedRows, rowHeaders, rowSizes, rowValueBytes, tooLargeRead };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import "../contracts/objects.mjs";
|
|
2
|
+
import "../protocol/packs/indexer.mjs";
|
|
3
|
+
import "../protocol/packs/step.mjs";
|
|
4
|
+
import "../contracts/calls-spent.mjs";
|
|
5
|
+
import "./pack-reads.mjs";
|
|
6
|
+
import "./pack-ranges.mjs";
|
|
7
|
+
import "../contracts/promises.mjs";
|
|
8
|
+
import "effect/Effect";
|