@ref0/git 0.0.0 → 0.3.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 +50 -0
- package/dist/client/git-http.mjs +201 -0
- package/dist/client/helper-node.mjs +19 -0
- package/dist/client/local.mjs +170 -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 +151 -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 +11 -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 +38 -0
- package/dist/contracts/promises.mjs +13 -0
- package/dist/contracts/push-uploads.d.mts +44 -0
- package/dist/contracts/queue.d.mts +402 -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 +133 -0
- package/dist/contracts/result.mjs +34 -0
- package/dist/contracts/rules.d.mts +159 -0
- package/dist/contracts/server.d.mts +272 -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 +180 -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/call-names.d.mts +1 -0
- package/dist/core/call-names.mjs +93 -0
- package/dist/core/clock.mjs +18 -0
- package/dist/core/events/deliver.mjs +475 -0
- package/dist/core/events/stream.d.mts +19 -0
- package/dist/core/events/stream.mjs +297 -0
- package/dist/core/forks.mjs +1027 -0
- package/dist/core/hooks/post-receive.mjs +212 -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 +64 -0
- package/dist/core/publish.mjs +142 -0
- package/dist/core/push-decide.mjs +206 -0
- package/dist/core/push.mjs +1070 -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 +26 -0
- package/dist/core/seam.mjs +54 -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 +4 -0
- package/dist/extend.mjs +3 -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 +1037 -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 +18 -0
- package/dist/rest/handler.mjs +129 -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 +17 -0
- package/dist/server/extension.mjs +93 -0
- package/dist/server/lifecycle.d.mts +3 -0
- package/dist/server/lifecycle.mjs +89 -0
- package/dist/server/routes.d.mts +28 -0
- package/dist/server/routes.mjs +60 -0
- package/dist/server/server.d.mts +8 -0
- package/dist/server/server.mjs +615 -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/bits.mjs +41 -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 +15 -0
- package/dist/storage/fetch.mjs +998 -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 +1447 -0
- package/dist/storage/index-fetch.d.mts +10 -0
- package/dist/storage/index-fetch.mjs +677 -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 +121 -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 +781 -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 +1007 -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 +603 -0
- package/dist/storage/prune.mjs +506 -0
- package/dist/storage/push-allotment.mjs +109 -0
- package/dist/storage/push-uploads.mjs +152 -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 +4 -0
- package/dist/storage/rows.mjs +71 -0
- package/dist/storage/send-list.d.mts +8 -0
- package/dist/storage/send-list.mjs +319 -0
- package/dist/storage/shallow.d.mts +4 -0
- package/dist/storage/shallow.mjs +128 -0
- package/dist/storage/stream-whole.mjs +236 -0
- package/dist/storage/unpack.mjs +238 -0
- package/dist/storage/visible.mjs +137 -0
- package/dist/storage/walk.d.mts +8 -0
- package/dist/storage/walk.mjs +176 -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/closed.d.mts +21 -0
- package/dist/store/closed.mjs +34 -0
- package/dist/store/crossing.mjs +69 -0
- package/dist/store/cursor-seal.d.mts +2 -0
- package/dist/store/cursor-seal.mjs +88 -0
- package/dist/store/errors.d.mts +12 -0
- package/dist/store/errors.mjs +135 -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 +297 -0
- package/dist/store/promises.d.mts +5 -0
- package/dist/store/promises.mjs +258 -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 +34 -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 +83 -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 +555 -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 +141 -0
- package/package.json +86 -5
|
@@ -0,0 +1,643 @@
|
|
|
1
|
+
import { isInternalId } from "../contracts/ids.mjs";
|
|
2
|
+
import { decodeRow, fail, storeCall } from "./errors.mjs";
|
|
3
|
+
import { CatalogueEntry, CreatedRow, ForkRow, StoredRepo, keyKept, takenBack } from "./records.mjs";
|
|
4
|
+
import { catalogueScope, collections, forkId, newChangeId, repoScope, selfKey } from "./scopes.mjs";
|
|
5
|
+
import { limits } from "@ref0/infra";
|
|
6
|
+
import * as Effect from "effect/Effect";
|
|
7
|
+
// src/store/catalogue.ts
|
|
8
|
+
/** How many times a projection reads and commits again when another name's write moved first. */
|
|
9
|
+
const projectTries = 8;
|
|
10
|
+
const entryRead = (name) => ({
|
|
11
|
+
collection: collections.catalogue,
|
|
12
|
+
id: name
|
|
13
|
+
});
|
|
14
|
+
const decodeEntry = (row) => row === void 0 ? Effect.succeed(void 0) : decodeRow(CatalogueEntry, row, `The catalogue's entry for '${row.id}'`);
|
|
15
|
+
const decodeRecord = (row) => row === void 0 ? Effect.succeed(void 0) : decodeRow(StoredRepo, row, "A repo's record");
|
|
16
|
+
const decodeForkRow = (row) => row === void 0 ? Effect.succeed(void 0) : decodeRow(ForkRow, row, "A fork's row");
|
|
17
|
+
/** The catalogue's entries for `names`, and the fork row `fork` when there is one, at one version. */
|
|
18
|
+
const readCatalogue = Effect.fnUntraced(function* (store, names, fork) {
|
|
19
|
+
const reads = fork === void 0 ? names.map(entryRead) : [...names.map(entryRead), fork];
|
|
20
|
+
const snapshot = yield* storeCall(() => store.read(catalogueScope, reads));
|
|
21
|
+
const entries = yield* Effect.forEach(names, (name, index) => Effect.map(decodeEntry(snapshot.results[index]?.[0]), (entry) => ({
|
|
22
|
+
name,
|
|
23
|
+
entry
|
|
24
|
+
})));
|
|
25
|
+
const row = yield* decodeForkRow(snapshot.results[names.length]?.[0]);
|
|
26
|
+
return {
|
|
27
|
+
version: snapshot.version,
|
|
28
|
+
entries,
|
|
29
|
+
row: fork === void 0 ? void 0 : row
|
|
30
|
+
};
|
|
31
|
+
});
|
|
32
|
+
/** The catalogue's entries for `names`, at one version. */
|
|
33
|
+
const readEntries = (store, names) => readCatalogue(store, names, void 0);
|
|
34
|
+
/** A fork's row in `git/repos`, by its source's internal ID and its holder. */
|
|
35
|
+
const forkKey = (source, holder) => ({
|
|
36
|
+
collection: collections.forks,
|
|
37
|
+
id: forkId(source, holder)
|
|
38
|
+
});
|
|
39
|
+
/** The holder's fork of `source`, by its row: `undefined` when it has none. */
|
|
40
|
+
const forkOf = Effect.fnUntraced(function* (store, source, holder) {
|
|
41
|
+
const { row } = yield* readCatalogue(store, [], forkKey(source, holder));
|
|
42
|
+
return row?.internalId;
|
|
43
|
+
});
|
|
44
|
+
/** Whether a live repo other than `internalId` holds a fork's row: a deleted one's is stale. */
|
|
45
|
+
const heldByOther = (store, internalId, row) => row === void 0 || row.internalId === internalId ? Effect.succeed(false) : Effect.map(recordAt(store, row.internalId), (held) => held !== void 0 && held.record.deleted !== true);
|
|
46
|
+
/**
|
|
47
|
+
* Whether `entry` may replace `held`, the name's entry now. Two rules, each with its reason:
|
|
48
|
+
*
|
|
49
|
+
* - Within a repo or across, only at a newer revision, never a tie, so a name's `sourceRevision`
|
|
50
|
+
* never falls. `nameMoved` reads a change in it as a move, and a create takes it plus one: a lost
|
|
51
|
+
* create's stale record must not land over the winner's newer tombstone.
|
|
52
|
+
* - Across repos, only a live entry over a tombstone: a tombstone, a redirect or a delete never
|
|
53
|
+
* covers another repo's name, and no revision of one repo takes a name another holds live (#416).
|
|
54
|
+
*/
|
|
55
|
+
const lands = (entry, held) => {
|
|
56
|
+
if (held === void 0) return true;
|
|
57
|
+
const newer = entry.sourceRevision > held.sourceRevision;
|
|
58
|
+
if (held.internalId === entry.internalId) return newer;
|
|
59
|
+
return newer && entry.deleted !== true && held.deleted === true;
|
|
60
|
+
};
|
|
61
|
+
/** What a repo's record says the catalogue should hold: its name's entry, and the name it left. */
|
|
62
|
+
const projectionOf = (internalId, record) => {
|
|
63
|
+
const entry = {
|
|
64
|
+
internalId,
|
|
65
|
+
sourceRevision: record.revision
|
|
66
|
+
};
|
|
67
|
+
if (record.deleted === true) entry.deleted = true;
|
|
68
|
+
if (record.deleted === true && record.nextSeq !== void 0) entry.nextSeq = record.nextSeq;
|
|
69
|
+
const own = {
|
|
70
|
+
name: record.name,
|
|
71
|
+
entry
|
|
72
|
+
};
|
|
73
|
+
if (record.renamedFrom === void 0) return [own];
|
|
74
|
+
const { renamedFrom } = record;
|
|
75
|
+
const tombstone = {
|
|
76
|
+
internalId,
|
|
77
|
+
sourceRevision: renamedFrom.revision,
|
|
78
|
+
deleted: true,
|
|
79
|
+
renamedTo: record.name
|
|
80
|
+
};
|
|
81
|
+
if (renamedFrom.nextSeq !== void 0) tombstone.nextSeq = renamedFrom.nextSeq;
|
|
82
|
+
return [own, {
|
|
83
|
+
name: renamedFrom.name,
|
|
84
|
+
entry: tombstone
|
|
85
|
+
}];
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* `entry`, taking `held`'s place at `at`, with the repos that held the name before, newest first,
|
|
89
|
+
* each until its receipts stop answering, so a write sent again finds the repo its key went to
|
|
90
|
+
* whatever repos took the name since.
|
|
91
|
+
*/
|
|
92
|
+
const following = (entry, held, at) => {
|
|
93
|
+
if (held === void 0) return entry;
|
|
94
|
+
const before = [...held.internalId === entry.internalId ? [] : [{
|
|
95
|
+
internalId: held.internalId,
|
|
96
|
+
until: at + keyKept
|
|
97
|
+
}], ...held.before ?? []].filter(({ until }) => until > at);
|
|
98
|
+
return before.length === 0 ? entry : {
|
|
99
|
+
...entry,
|
|
100
|
+
before
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
const encoder = new TextEncoder();
|
|
104
|
+
/**
|
|
105
|
+
* The most a tombstone adds to the live entry it replaces: `deleted`, `renamedTo` at the longest
|
|
106
|
+
* name, and a revision of any length. Its `before` is the live entry's, or fewer once some pass
|
|
107
|
+
* `until`, so a live entry that fits beside this reserve leaves a tombstone that always fits.
|
|
108
|
+
*/
|
|
109
|
+
const tombstoneReserve = {
|
|
110
|
+
sourceRevision: Number.MAX_SAFE_INTEGER,
|
|
111
|
+
deleted: true,
|
|
112
|
+
renamedTo: "x".repeat(200)
|
|
113
|
+
};
|
|
114
|
+
/**
|
|
115
|
+
* `RESOURCE_EXHAUSTED`, reason `name-churn`, when the live entry a create or a rename gives
|
|
116
|
+
* `record`'s name, after the one `held` there, would leave no room for its tombstone within infra's
|
|
117
|
+
* `limits.valueBytes`: more repos left the name in 24 hours than one entry's `before` holds. A
|
|
118
|
+
* write checks it before its first commit, so `before` never drops a repo whose receipts still
|
|
119
|
+
* answer, and the write is taken again once older ones pass `until`. A delete and a rename away
|
|
120
|
+
* write only a tombstone, which the reserve holds room for, so neither is ever refused.
|
|
121
|
+
*/
|
|
122
|
+
const checkChurn = (internalId, record, held) => {
|
|
123
|
+
const own = {
|
|
124
|
+
internalId,
|
|
125
|
+
sourceRevision: record.revision
|
|
126
|
+
};
|
|
127
|
+
const tombstone = {
|
|
128
|
+
...following(own, held, record.changedAt),
|
|
129
|
+
...tombstoneReserve
|
|
130
|
+
};
|
|
131
|
+
if (encoder.encode(JSON.stringify(tombstone)).length <= limits.valueBytes) return Effect.void;
|
|
132
|
+
return fail("RESOURCE_EXHAUSTED", `Too many repos held '${record.name}' in the last 24 hours`, {
|
|
133
|
+
hint: "Try again once a day has passed since the name last changed hands",
|
|
134
|
+
context: { reason: "name-churn" }
|
|
135
|
+
});
|
|
136
|
+
};
|
|
137
|
+
/** The writes of `projected`, by a record written at `at`, that `lands` lets replace those held. */
|
|
138
|
+
const newerWrites = (projected, held, at) => projected.flatMap(({ name, entry }) => {
|
|
139
|
+
const current = held.find((one) => one.name === name)?.entry;
|
|
140
|
+
if (!lands(entry, current)) return [];
|
|
141
|
+
return [{
|
|
142
|
+
collection: collections.catalogue,
|
|
143
|
+
id: name,
|
|
144
|
+
value: following(entry, current, at)
|
|
145
|
+
}];
|
|
146
|
+
});
|
|
147
|
+
/**
|
|
148
|
+
* Digits a `createdKey` pads its time to: `createdAt` plus `Number.MAX_SAFE_INTEGER`, so every safe
|
|
149
|
+
* integer, a clock before 1970's too, is a count from 0 up to twice that, and keys sort by time.
|
|
150
|
+
*/
|
|
151
|
+
const createdDigits = 17;
|
|
152
|
+
/** A repo's place in create order: its offset, padded `createdAt`, then its internal ID for a tie. */
|
|
153
|
+
const createdKey = (internalId, createdAt) => `${String(BigInt(createdAt) + BigInt(Number.MAX_SAFE_INTEGER)).padStart(createdDigits, "0")}.${internalId}`;
|
|
154
|
+
/** Whether `text` is a `createdKey`, as a list in create order takes for its cursor. */
|
|
155
|
+
const isCreatedKey = (text) => /^\d{17}\.r_[A-Za-z0-9_-]{16}$/.test(text);
|
|
156
|
+
/** A fork's holder's row, which makes it its source's one fork for the holder: none for a repo. */
|
|
157
|
+
const holderKey = (record) => record.fork === void 0 ? void 0 : forkKey(record.fork.upstreamInternalId, record.fork.holder);
|
|
158
|
+
/** The folders a name's created rows are kept under: `''` and each one ending in a `/` of it. */
|
|
159
|
+
const foldersOf = (name) => {
|
|
160
|
+
const parts = name.split("/").slice(0, -1);
|
|
161
|
+
return ["", ...parts.map((_, index) => `${parts.slice(0, index + 1).join("/")}/`)];
|
|
162
|
+
};
|
|
163
|
+
/**
|
|
164
|
+
* A folder's created rows' ID prefix: the folder and a `:`, which no repo ID holds, so a read of
|
|
165
|
+
* one folder takes none of the folders under it.
|
|
166
|
+
*/
|
|
167
|
+
const folderPrefix = (folder) => `${folder}:`;
|
|
168
|
+
/**
|
|
169
|
+
* The ID prefix of `source`'s forks' dated rows under `folder`: the source's internal ID, then the
|
|
170
|
+
* folder's prefix, so a read of one folder takes only the forks whose names it holds.
|
|
171
|
+
*/
|
|
172
|
+
const forkFolderPrefix = (source, folder) => `${source}:${folderPrefix(folder)}`;
|
|
173
|
+
/**
|
|
174
|
+
* The created rows a record's projection commits beside the entries it wins, under each folder of
|
|
175
|
+
* its name: its `CreatedRow`, and a fork's dated row under its source too. A live record's are put
|
|
176
|
+
* under each folder of its name, and those of the name a rename left deleted where the new name
|
|
177
|
+
* has none; a deleted record's all deleted. In the entries' own commit, so `git.list` mends a lost
|
|
178
|
+
* one with them. A name has at most 8 segments, so a fork has at most 16 rows, and its rename moves
|
|
179
|
+
* at most 32.
|
|
180
|
+
*/
|
|
181
|
+
const createdWrites = (internalId, record) => {
|
|
182
|
+
const key = createdKey(internalId, record.createdAt);
|
|
183
|
+
const source = record.fork?.upstreamInternalId;
|
|
184
|
+
const folders = foldersOf(record.name);
|
|
185
|
+
const left = record.renamedFrom === void 0 ? [] : foldersOf(record.renamedFrom.name);
|
|
186
|
+
const created = { name: record.name };
|
|
187
|
+
const dated = { internalId };
|
|
188
|
+
const rows = (folder) => [{
|
|
189
|
+
collection: collections.folderCreated,
|
|
190
|
+
id: folderPrefix(folder) + key,
|
|
191
|
+
value: created
|
|
192
|
+
}, ...source === void 0 ? [] : [{
|
|
193
|
+
collection: collections.forksCreated,
|
|
194
|
+
id: forkFolderPrefix(source, folder) + key,
|
|
195
|
+
value: dated
|
|
196
|
+
}]];
|
|
197
|
+
const keys = (folder) => rows(folder).map(({ collection, id }) => ({
|
|
198
|
+
collection,
|
|
199
|
+
id
|
|
200
|
+
}));
|
|
201
|
+
if (record.deleted === true) return {
|
|
202
|
+
put: [],
|
|
203
|
+
delete: [.../* @__PURE__ */ new Set([...folders, ...left])].flatMap(keys)
|
|
204
|
+
};
|
|
205
|
+
return {
|
|
206
|
+
put: folders.flatMap(rows),
|
|
207
|
+
delete: left.filter((folder) => !folders.includes(folder)).flatMap(keys)
|
|
208
|
+
};
|
|
209
|
+
};
|
|
210
|
+
/** The folders a public repo's create-order rows are kept under: `''` and its owner's. */
|
|
211
|
+
const publicFolders = (name) => foldersOf(name).slice(0, 2);
|
|
212
|
+
/**
|
|
213
|
+
* The public index's writes, which a projection commits only beside the entries it wins (#209):
|
|
214
|
+
* a live public record's row by its name and its rows under `''` and its owner, and every other
|
|
215
|
+
* record's deleted, with those of the owner a rename left. The left name's row goes only in the
|
|
216
|
+
* commit that writes that name's tombstone, since a newer repo may hold the name by then. At
|
|
217
|
+
* most 3 puts and 2 deletes, or 5 deletes.
|
|
218
|
+
*/
|
|
219
|
+
const publicWrites = (internalId, record, writes) => {
|
|
220
|
+
const key = createdKey(internalId, record.createdAt);
|
|
221
|
+
const folders = publicFolders(record.name);
|
|
222
|
+
const left = record.renamedFrom?.name;
|
|
223
|
+
const leftFolders = left === void 0 ? [] : publicFolders(left);
|
|
224
|
+
const named = (name) => ({
|
|
225
|
+
collection: collections.publicNames,
|
|
226
|
+
id: name
|
|
227
|
+
});
|
|
228
|
+
const created = (folder) => ({
|
|
229
|
+
collection: collections.publicCreated,
|
|
230
|
+
id: folderPrefix(folder) + key
|
|
231
|
+
});
|
|
232
|
+
const gone = [...(left !== void 0 && writes.some((one) => one.id === left) ? [left] : []).map(named), ...leftFolders.filter((folder) => !folders.includes(folder)).map(created)];
|
|
233
|
+
if (record.deleted === true || !record.public) return {
|
|
234
|
+
put: [],
|
|
235
|
+
delete: [
|
|
236
|
+
named(record.name),
|
|
237
|
+
...folders.map(created),
|
|
238
|
+
...gone
|
|
239
|
+
]
|
|
240
|
+
};
|
|
241
|
+
const row = { internalId };
|
|
242
|
+
const placed = { name: record.name };
|
|
243
|
+
return {
|
|
244
|
+
put: [{
|
|
245
|
+
...named(record.name),
|
|
246
|
+
value: row
|
|
247
|
+
}, ...folders.map((folder) => ({
|
|
248
|
+
...created(folder),
|
|
249
|
+
value: placed
|
|
250
|
+
}))],
|
|
251
|
+
delete: gone
|
|
252
|
+
};
|
|
253
|
+
};
|
|
254
|
+
/** Whether the catalogue gives `name` to this record: its entry is the record's, revision and all. */
|
|
255
|
+
const holdsName = (internalId, record, entry) => entry.internalId === internalId && entry.sourceRevision === record.revision;
|
|
256
|
+
/**
|
|
257
|
+
* Projects a repo's record into `git/repos`, writing each entry only where `lands` lets it:
|
|
258
|
+
* what every repo write does after its own commit, and what `git.list` does when one didn't get
|
|
259
|
+
* that far. A rename leaves its old name only in the commit that wins its new one, so one that
|
|
260
|
+
* loses still holds its old name until it takes it back. A commit that wins the name writes the
|
|
261
|
+
* repo's created rows too, and one that loses writes nothing. Answers whether the record's name is its
|
|
262
|
+
* own once it's done, or lost to another repo's record at the same revision or later.
|
|
263
|
+
*
|
|
264
|
+
* A fork's holder's row commits with the entry that wins its name, so a holder's two creates at
|
|
265
|
+
* once make one fork: one whose row another live fork holds is `taken`, and writes nothing. Its
|
|
266
|
+
* dated rows are among its created rows, and a deleted fork's projection deletes them all. A
|
|
267
|
+
* commit that wins the name writes the public index too, so the index holds a repo exactly while
|
|
268
|
+
* its winning projection said it was live and public.
|
|
269
|
+
*/
|
|
270
|
+
const project = Effect.fnUntraced(function* (store, internalId, record) {
|
|
271
|
+
const projected = projectionOf(internalId, record);
|
|
272
|
+
const names = projected.map(({ name }) => name);
|
|
273
|
+
const fork = holderKey(record);
|
|
274
|
+
const forkRows = fork === void 0 ? [] : [fork];
|
|
275
|
+
const live = record.deleted !== true;
|
|
276
|
+
const created = createdWrites(internalId, record);
|
|
277
|
+
for (let attempt = 0; attempt < projectTries; attempt += 1) {
|
|
278
|
+
const { version, entries, row } = yield* readCatalogue(store, names, fork);
|
|
279
|
+
const newer = newerWrites(projected, entries, record.changedAt);
|
|
280
|
+
const held = entries[0]?.entry;
|
|
281
|
+
const holds = held !== void 0 && holdsName(internalId, record, held);
|
|
282
|
+
const ownRow = row?.internalId === internalId;
|
|
283
|
+
if (live && !holds && (yield* heldByOther(store, internalId, row))) return "taken";
|
|
284
|
+
const wins = holds || newer.some((one) => one.id === record.name);
|
|
285
|
+
const writes = wins ? newer : [];
|
|
286
|
+
const put = (live && wins && !ownRow ? forkRows : []).map((key) => ({
|
|
287
|
+
...key,
|
|
288
|
+
value: { internalId }
|
|
289
|
+
}));
|
|
290
|
+
const deleted = !live && ownRow ? forkRows : [];
|
|
291
|
+
if (writes.length + put.length + deleted.length === 0) return holds ? "won" : "lost";
|
|
292
|
+
const listed = wins ? publicWrites(internalId, record, writes) : {
|
|
293
|
+
put: [],
|
|
294
|
+
delete: []
|
|
295
|
+
};
|
|
296
|
+
const change = {
|
|
297
|
+
id: newChangeId(),
|
|
298
|
+
expect: version,
|
|
299
|
+
put: [
|
|
300
|
+
...writes,
|
|
301
|
+
...put,
|
|
302
|
+
...created.put,
|
|
303
|
+
...listed.put
|
|
304
|
+
],
|
|
305
|
+
delete: [
|
|
306
|
+
...deleted,
|
|
307
|
+
...created.delete,
|
|
308
|
+
...listed.delete
|
|
309
|
+
]
|
|
310
|
+
};
|
|
311
|
+
const committed = yield* storeCall(() => store.commit(catalogueScope, change));
|
|
312
|
+
const won = holds || writes.some((one) => one.id === record.name);
|
|
313
|
+
if (committed.ok) return won ? "won" : "lost";
|
|
314
|
+
}
|
|
315
|
+
return yield* fail("UNAVAILABLE", "The catalogue is busy", { hint: "Try again" });
|
|
316
|
+
});
|
|
317
|
+
/**
|
|
318
|
+
* `git.list`'s work for one repo: its record, projected. A scope with no record has nothing. A
|
|
319
|
+
* rename that lost its new name and stopped before taking its old one back is taken back here,
|
|
320
|
+
* while its old name's entry is still its own live one. A rename that won left that name already,
|
|
321
|
+
* so a newer write that took the new name later doesn't send it back to a name it gave up.
|
|
322
|
+
*/
|
|
323
|
+
const reconcile = Effect.fnUntraced(function* (store, internalId) {
|
|
324
|
+
const snapshot = yield* storeCall(() => store.read(repoScope(internalId), [selfKey]));
|
|
325
|
+
const record = yield* decodeRecord(snapshot.results[0]?.[0]);
|
|
326
|
+
if (record === void 0) return void 0;
|
|
327
|
+
const outcome = yield* project(store, internalId, record);
|
|
328
|
+
const back = outcome === "lost" ? takenBack(record) : void 0;
|
|
329
|
+
if (back === void 0) return outcome;
|
|
330
|
+
const left = yield* entryOf(store, back.record.name);
|
|
331
|
+
if (left?.internalId !== internalId || left.deleted === true) return outcome;
|
|
332
|
+
const put = [{
|
|
333
|
+
...selfKey,
|
|
334
|
+
value: back.record
|
|
335
|
+
}];
|
|
336
|
+
const change = {
|
|
337
|
+
id: newChangeId(),
|
|
338
|
+
expect: snapshot.version,
|
|
339
|
+
put,
|
|
340
|
+
delete: back.delete
|
|
341
|
+
};
|
|
342
|
+
if (!(yield* storeCall(() => store.commit(repoScope(internalId), change))).ok) return yield* fail("UNAVAILABLE", "The repo moved", { hint: "Try again" });
|
|
343
|
+
return yield* project(store, internalId, back.record);
|
|
344
|
+
});
|
|
345
|
+
/** A name's entry, live or a tombstone, or `undefined` for a name never used. */
|
|
346
|
+
const entryOf = Effect.fnUntraced(function* (store, name) {
|
|
347
|
+
const { entries } = yield* readEntries(store, [name]);
|
|
348
|
+
return entries[0]?.entry;
|
|
349
|
+
});
|
|
350
|
+
const notFound = (name, entry) => {
|
|
351
|
+
const renamedTo = entry?.renamedTo;
|
|
352
|
+
if (renamedTo === void 0) return fail("NOT_FOUND", `No repo '${name}'`);
|
|
353
|
+
return fail("NOT_FOUND", `No repo '${name}'`, { context: { renamedTo } });
|
|
354
|
+
};
|
|
355
|
+
/** How many times `resolveRepo` reads again once it settled the name it read. */
|
|
356
|
+
const resolveTries = 3;
|
|
357
|
+
/** `name`, which the catalogue gives `record`: the one constructor of a `SettledName`. */
|
|
358
|
+
const settledName = (name) => name;
|
|
359
|
+
/**
|
|
360
|
+
* The repo `name` names now, read from its scope with `reads` at one version, with the name
|
|
361
|
+
* settled: its entry is the record's, revision and all. One the record doesn't hold yet, such as a
|
|
362
|
+
* write's whose projection hasn't happened, is projected as `git.list` would, and read again.
|
|
363
|
+
* `NOT_FOUND` when the name has no live entry, or its repo's record doesn't agree, or loses the
|
|
364
|
+
* name to another repo: a rename away and back between the two reads may have lost it, and the
|
|
365
|
+
* entry first read doesn't say so (#416). A renamed name's error carries `renamedTo`.
|
|
366
|
+
*/
|
|
367
|
+
const resolveRepo = Effect.fnUntraced(function* (store, name, reads = []) {
|
|
368
|
+
for (let attempt = 0; attempt < resolveTries; attempt += 1) {
|
|
369
|
+
const entry = yield* entryOf(store, name);
|
|
370
|
+
if (entry === void 0 || entry.deleted === true) return yield* notFound(name, entry);
|
|
371
|
+
const { internalId } = entry;
|
|
372
|
+
const snapshot = yield* storeCall(() => store.read(repoScope(internalId), [selfKey, ...reads]));
|
|
373
|
+
const record = yield* decodeRecord(snapshot.results[0]?.[0]);
|
|
374
|
+
if (record === void 0 || record.deleted === true || record.name !== name) return yield* notFound(name, void 0);
|
|
375
|
+
if (holdsName(internalId, record, entry)) return {
|
|
376
|
+
name: settledName(name),
|
|
377
|
+
internalId,
|
|
378
|
+
entry,
|
|
379
|
+
record,
|
|
380
|
+
snapshot
|
|
381
|
+
};
|
|
382
|
+
if ((yield* project(store, internalId, record)) !== "won") return yield* notFound(name, void 0);
|
|
383
|
+
}
|
|
384
|
+
return yield* fail("UNAVAILABLE", "The catalogue is busy", { hint: "Try again" });
|
|
385
|
+
});
|
|
386
|
+
/** The name a tombstone redirects to, while no repo has been made under it again. */
|
|
387
|
+
const redirectOf = Effect.fnUntraced(function* (store, name) {
|
|
388
|
+
const entry = yield* entryOf(store, name);
|
|
389
|
+
return entry?.deleted === true ? entry.renamedTo : void 0;
|
|
390
|
+
});
|
|
391
|
+
/** A repo's internal ID by name, for an extension's own scopes. */
|
|
392
|
+
const internalIdOf = Effect.fnUntraced(function* (store, name) {
|
|
393
|
+
const entry = yield* entryOf(store, name);
|
|
394
|
+
if (entry === void 0 || entry.deleted === true) return yield* notFound(name, entry);
|
|
395
|
+
return entry.internalId;
|
|
396
|
+
});
|
|
397
|
+
/** A repo's record now, from its scope, and the scope's version: `undefined` for an ID of none. */
|
|
398
|
+
const recordAt = Effect.fnUntraced(function* (store, internalId) {
|
|
399
|
+
if (!isInternalId(internalId)) return void 0;
|
|
400
|
+
const snapshot = yield* storeCall(() => store.read(repoScope(internalId), [selfKey]));
|
|
401
|
+
const record = yield* decodeRecord(snapshot.results[0]?.[0]);
|
|
402
|
+
return record === void 0 ? void 0 : {
|
|
403
|
+
record,
|
|
404
|
+
version: snapshot.version
|
|
405
|
+
};
|
|
406
|
+
});
|
|
407
|
+
/** The name a repo's scope is under now, from its record: for a repo token's `TokenInfo`. */
|
|
408
|
+
const nameOf = (store, internalId) => Effect.map(recordAt(store, internalId), (read) => read === void 0 || read.record.deleted === true ? void 0 : read.record.name);
|
|
409
|
+
/**
|
|
410
|
+
* The name the catalogue gives `record` now: its own when its entry is the record's, else, for a
|
|
411
|
+
* rename that lost its new name, the old one while its entry is still the repo's live one.
|
|
412
|
+
* `undefined` when neither is, as while a write's projection hasn't happened yet.
|
|
413
|
+
*/
|
|
414
|
+
const heldName = Effect.fnUntraced(function* (store, internalId, record) {
|
|
415
|
+
const back = takenBack(record);
|
|
416
|
+
const names = back === void 0 ? [record.name] : [record.name, back.record.name];
|
|
417
|
+
const { entries } = yield* readEntries(store, names);
|
|
418
|
+
const [own, left] = entries.map(({ entry }) => entry);
|
|
419
|
+
if (own !== void 0 && holdsName(internalId, record, own)) return record.name;
|
|
420
|
+
return left !== void 0 && left.internalId === internalId && left.deleted !== true ? back?.record.name : void 0;
|
|
421
|
+
});
|
|
422
|
+
/**
|
|
423
|
+
* `heldName` for `record` as a read at `version` found it, read again after: `'moved'` when a
|
|
424
|
+
* write changed the repo between, so the name answered is the one the catalogue gives that very
|
|
425
|
+
* record, never a later one's beside the earlier one's visibility.
|
|
426
|
+
*/
|
|
427
|
+
const heldNameAt = Effect.fnUntraced(function* (store, internalId, record, version) {
|
|
428
|
+
const name = yield* heldName(store, internalId, record);
|
|
429
|
+
return (yield* recordAt(store, internalId))?.version === version ? name : "moved";
|
|
430
|
+
});
|
|
431
|
+
/** How many times `hostRecordOf` reads again when a write moved the repo between its reads. */
|
|
432
|
+
const hostReadTries = 5;
|
|
433
|
+
/**
|
|
434
|
+
* A repo's record as host code reads it, by internal ID: `ExtendedGit.repo`'s answer, `undefined`
|
|
435
|
+
* once it's deleted. Its name is the one the catalogue gives it, read between two reads of its
|
|
436
|
+
* record at one version, so it's never a name another repo holds. When the catalogue gives it
|
|
437
|
+
* neither name, its projection is finished as `git.list` would, and it's read again; still none at
|
|
438
|
+
* the version it reconciled, and it's `undefined`, as for a repo no name reaches. A newer record
|
|
439
|
+
* is reconciled again, within the tries.
|
|
440
|
+
*/
|
|
441
|
+
const hostRecordOf = Effect.fnUntraced(function* (store, internalId) {
|
|
442
|
+
const named = yield* namedRecordOf(store, internalId);
|
|
443
|
+
if (named === void 0) return void 0;
|
|
444
|
+
const { name, record } = named;
|
|
445
|
+
const read = {
|
|
446
|
+
id: name,
|
|
447
|
+
internalId,
|
|
448
|
+
defaultBranch: record.defaultBranch,
|
|
449
|
+
public: record.public,
|
|
450
|
+
createdAt: record.createdAt
|
|
451
|
+
};
|
|
452
|
+
const upstream = yield* upstreamOf(store, record);
|
|
453
|
+
if (upstream !== void 0) read.upstream = upstream;
|
|
454
|
+
if (record.fork !== void 0) read.upstreamInternalId = record.fork.upstreamInternalId;
|
|
455
|
+
return read;
|
|
456
|
+
});
|
|
457
|
+
/**
|
|
458
|
+
* A fork's source's name now, by the internal ID its record keeps, as `hostRecordOf` names a repo,
|
|
459
|
+
* so a rename follows it and a repo that takes its old name never stands in for it: `undefined`
|
|
460
|
+
* for a repo that isn't a fork, and once its source is deleted.
|
|
461
|
+
*/
|
|
462
|
+
const upstreamOf = Effect.fnUntraced(function* (store, record) {
|
|
463
|
+
if (record.fork === void 0) return void 0;
|
|
464
|
+
return (yield* namedRecordOf(store, record.fork.upstreamInternalId))?.name;
|
|
465
|
+
});
|
|
466
|
+
/**
|
|
467
|
+
* A live repo's record and the name the catalogue gives it, by internal ID: `hostRecordOf`'s read,
|
|
468
|
+
* and a fork's as its source lists it, so a rename that lost its new name, with events or
|
|
469
|
+
* without, never answers that name.
|
|
470
|
+
*/
|
|
471
|
+
const namedRecordOf = Effect.fnUntraced(function* (store, internalId) {
|
|
472
|
+
let reconciledAt;
|
|
473
|
+
for (let attempt = 0; attempt < hostReadTries; attempt += 1) {
|
|
474
|
+
const first = yield* recordAt(store, internalId);
|
|
475
|
+
if (first === void 0 || first.record.deleted === true) return void 0;
|
|
476
|
+
const { record } = first;
|
|
477
|
+
const name = yield* heldName(store, internalId, record);
|
|
478
|
+
if ((yield* recordAt(store, internalId))?.version !== first.version) continue;
|
|
479
|
+
if (name === void 0 && reconciledAt === first.version) return void 0;
|
|
480
|
+
if (name === void 0) {
|
|
481
|
+
yield* reconcile(store, internalId);
|
|
482
|
+
reconciledAt = first.version;
|
|
483
|
+
continue;
|
|
484
|
+
}
|
|
485
|
+
return {
|
|
486
|
+
name,
|
|
487
|
+
record
|
|
488
|
+
};
|
|
489
|
+
}
|
|
490
|
+
return yield* fail("UNAVAILABLE", "The repo is busy", { hint: "Try again" });
|
|
491
|
+
});
|
|
492
|
+
/** A page's `limit`, as a caller's `page` asks for it, within `maxListLimit`. */
|
|
493
|
+
const listLimit = (page = {}) => Math.min(Math.max(page.limit ?? 50, 1), 200);
|
|
494
|
+
/** Reads of the catalogue one list makes at most, skipping tombstones and names outside its prefix. */
|
|
495
|
+
const listReads = 4;
|
|
496
|
+
/**
|
|
497
|
+
* Live names under `prefix`, in order, or from the last when `descending`: a page can be short
|
|
498
|
+
* where tombstones were skipped. Each row it reads, a tombstone's too, adds to `tally`, and once
|
|
499
|
+
* it has read `tally.most` rows it ends there, with a `next`.
|
|
500
|
+
*/
|
|
501
|
+
const listNames = Effect.fnUntraced(function* (store, prefix, page = {}, descending = false, tally = { read: 0 }) {
|
|
502
|
+
const limit = listLimit(page);
|
|
503
|
+
const items = [];
|
|
504
|
+
let after = page.after;
|
|
505
|
+
for (let round = 0; round < listReads; round += 1) {
|
|
506
|
+
const room = Math.min(limit - items.length, (tally.most ?? Infinity) - tally.read);
|
|
507
|
+
if (room <= 0) break;
|
|
508
|
+
const read = {
|
|
509
|
+
collection: collections.catalogue,
|
|
510
|
+
prefix,
|
|
511
|
+
limit: room
|
|
512
|
+
};
|
|
513
|
+
if (after !== void 0) read.after = after;
|
|
514
|
+
if (descending) read.reverse = true;
|
|
515
|
+
const rows = (yield* storeCall(() => store.read("git/repos", [read]))).results[0] ?? [];
|
|
516
|
+
tally.read += rows.length;
|
|
517
|
+
for (const row of rows) if ((yield* decodeEntry(row))?.deleted !== true) items.push(row.id);
|
|
518
|
+
const last = rows.at(-1);
|
|
519
|
+
if (rows.length < (read.limit ?? 0) || last === void 0) return { items };
|
|
520
|
+
if (items.length >= limit) return {
|
|
521
|
+
items,
|
|
522
|
+
next: last.id
|
|
523
|
+
};
|
|
524
|
+
after = last.id;
|
|
525
|
+
}
|
|
526
|
+
const listing = { items };
|
|
527
|
+
if (after !== void 0) listing.next = after;
|
|
528
|
+
return listing;
|
|
529
|
+
});
|
|
530
|
+
/**
|
|
531
|
+
* Live names in create order under `reach`, `''` or a folder ending in `/`, from its folder's
|
|
532
|
+
* created rows alone: every row read is a repo under the reach, so a page and its cursor depend on
|
|
533
|
+
* those repos and never on one outside it. Reads one row past the page, so `next` comes only while
|
|
534
|
+
* a row follows, and keeps each name while its entry is its repo's live one. Rows and entries are
|
|
535
|
+
* two reads, so a repo renamed between them is left out of that page, which is then short. Each
|
|
536
|
+
* row of the page it reads, a dropped one's too, adds to `tally`.
|
|
537
|
+
*/
|
|
538
|
+
const listCreated = Effect.fnUntraced(function* (store, reach, newest, page = {}, tally = { read: 0 }) {
|
|
539
|
+
const limit = listLimit(page);
|
|
540
|
+
const prefix = folderPrefix(reach);
|
|
541
|
+
const read = {
|
|
542
|
+
collection: collections.folderCreated,
|
|
543
|
+
prefix,
|
|
544
|
+
limit: limit + 1
|
|
545
|
+
};
|
|
546
|
+
if (page.after !== void 0) read.after = prefix + page.after;
|
|
547
|
+
if (newest) read.reverse = true;
|
|
548
|
+
const snapshot = yield* storeCall(() => store.read(catalogueScope, [read]));
|
|
549
|
+
const rows = (snapshot.results[0] ?? []).slice(0, limit);
|
|
550
|
+
tally.read += rows.length;
|
|
551
|
+
const named = yield* Effect.forEach(rows, (row) => decodeRow(CreatedRow, row, `The created row '${row.id}'`));
|
|
552
|
+
const { entries } = yield* readEntries(store, named.map(({ name }) => name));
|
|
553
|
+
const items = entries.flatMap(({ name, entry }, index) => {
|
|
554
|
+
return entry !== void 0 && (rows[index]?.id ?? "").endsWith(`.${entry.internalId}`) && entry.deleted !== true ? [name] : [];
|
|
555
|
+
});
|
|
556
|
+
const last = rows.at(-1);
|
|
557
|
+
return (snapshot.results[0]?.length ?? 0) > limit && last !== void 0 ? {
|
|
558
|
+
items,
|
|
559
|
+
next: last.id.slice(prefix.length)
|
|
560
|
+
} : { items };
|
|
561
|
+
});
|
|
562
|
+
/** How many of a page's records a signed-out list reads at once, in the page's order. */
|
|
563
|
+
const readsAtOnce = 16;
|
|
564
|
+
/**
|
|
565
|
+
* The name a public index row stands for while its record agrees: live, public, and holding the
|
|
566
|
+
* row's name. A flip to private, a rename and a delete each hide the row from their record's own
|
|
567
|
+
* commit, before the projection that deletes it, and so does a stale row a lost projection left.
|
|
568
|
+
*/
|
|
569
|
+
const publicName = Effect.fnUntraced(function* (store, row, created) {
|
|
570
|
+
const name = created ? (yield* decodeRow(CreatedRow, row, `The public created row '${row.id}'`)).name : row.id;
|
|
571
|
+
const internalId = created ? row.id.slice(row.id.lastIndexOf(".") + 1) : (yield* decodeRow(ForkRow, row, `The public row '${row.id}'`)).internalId;
|
|
572
|
+
if (!isInternalId(internalId)) return [];
|
|
573
|
+
const record = (yield* recordAt(store, internalId))?.record;
|
|
574
|
+
return record !== void 0 && record.deleted !== true && record.public && record.name === name ? [name] : [];
|
|
575
|
+
});
|
|
576
|
+
/**
|
|
577
|
+
* Public repos under `prefix` for a signed-out list (#209), by name or in create order, from the
|
|
578
|
+
* public index alone, so a page reads no private repo's row however many there are: the page's
|
|
579
|
+
* rows and one past it, then each row's record, which `publicName` checks. A row the check leaves
|
|
580
|
+
* out takes no place: the page reads on past it, so its items and `next` are those of an index
|
|
581
|
+
* without it. In create order `prefix` is `''` or an owner's.
|
|
582
|
+
*/
|
|
583
|
+
const listPublic = Effect.fnUntraced(function* (store, prefix, order, page = {}) {
|
|
584
|
+
const limit = listLimit(page);
|
|
585
|
+
const created = order === "oldest" || order === "newest";
|
|
586
|
+
const kept = created ? folderPrefix(prefix) : "";
|
|
587
|
+
const shown = [];
|
|
588
|
+
const shownOf = (row) => publicName(store, row, created);
|
|
589
|
+
let after = page.after === void 0 ? void 0 : kept + page.after;
|
|
590
|
+
while (shown.length <= limit) {
|
|
591
|
+
const wanted = limit + 1 - shown.length;
|
|
592
|
+
const read = {
|
|
593
|
+
collection: created ? collections.publicCreated : collections.publicNames,
|
|
594
|
+
prefix: created ? kept : prefix,
|
|
595
|
+
limit: wanted
|
|
596
|
+
};
|
|
597
|
+
if (after !== void 0) read.after = after;
|
|
598
|
+
if (order === "newest" || order === "nameDescending") read.reverse = true;
|
|
599
|
+
const rows = (yield* storeCall(() => store.read("git/repos", [read]))).results[0] ?? [];
|
|
600
|
+
const names = yield* Effect.forEach(rows, shownOf, { concurrency: readsAtOnce });
|
|
601
|
+
for (const [index, row] of rows.entries()) for (const name of names[index] ?? []) shown.push({
|
|
602
|
+
name,
|
|
603
|
+
next: row.id.slice(kept.length)
|
|
604
|
+
});
|
|
605
|
+
const last = rows.at(-1);
|
|
606
|
+
if (rows.length < wanted || last === void 0) break;
|
|
607
|
+
after = last.id;
|
|
608
|
+
}
|
|
609
|
+
const items = shown.slice(0, limit);
|
|
610
|
+
const next = shown.length > limit ? items.at(-1)?.next : void 0;
|
|
611
|
+
const names = items.map((one) => one.name);
|
|
612
|
+
return next === void 0 ? { items: names } : {
|
|
613
|
+
items: names,
|
|
614
|
+
next
|
|
615
|
+
};
|
|
616
|
+
});
|
|
617
|
+
/**
|
|
618
|
+
* Up to `limit` of `source`'s forks under `folder` after `after`, the newest first, by their dated
|
|
619
|
+
* rows alone: `''` reads every fork, and a folder only those whose names it holds. The caller
|
|
620
|
+
* reads each one's record, and leaves out those it may not read.
|
|
621
|
+
*/
|
|
622
|
+
const forksCreated = Effect.fnUntraced(function* (store, source, folder, limit, after) {
|
|
623
|
+
const prefix = forkFolderPrefix(source, folder);
|
|
624
|
+
const read = {
|
|
625
|
+
collection: collections.forksCreated,
|
|
626
|
+
prefix,
|
|
627
|
+
limit,
|
|
628
|
+
reverse: true
|
|
629
|
+
};
|
|
630
|
+
if (after !== void 0) read.after = prefix + after;
|
|
631
|
+
const rows = (yield* storeCall(() => store.read("git/repos", [read]))).results[0] ?? [];
|
|
632
|
+
const forks = yield* Effect.forEach(rows, (row) => Effect.map(decodeRow(ForkRow, row, `The fork's dated row '${row.id}'`), ({ internalId }) => ({
|
|
633
|
+
internalId,
|
|
634
|
+
key: row.id.slice(prefix.length)
|
|
635
|
+
})));
|
|
636
|
+
const result = { forks };
|
|
637
|
+
const last = forks.at(-1);
|
|
638
|
+
if (rows.length >= limit && last !== void 0) result.next = last.key;
|
|
639
|
+
return result;
|
|
640
|
+
});
|
|
641
|
+
/** A repo's `createdKey`, from its record now: `undefined` for an ID of none. */
|
|
642
|
+
const createdKeyOf = (store, internalId) => Effect.map(recordAt(store, internalId), (read) => read === void 0 ? void 0 : createdKey(internalId, read.record.createdAt));
|
|
643
|
+
export { checkChurn, createdKey, createdKeyOf, decodeRecord, entryOf, folderPrefix, foldersOf, forkFolderPrefix, forkKey, forkOf, forksCreated, heldName, heldNameAt, hostRecordOf, internalIdOf, isCreatedKey, lands, listCreated, listLimit, listNames, listPublic, nameOf, namedRecordOf, project, projectionOf, readEntries, reconcile, recordAt, redirectOf, resolveRepo, upstreamOf };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import "effect/Effect";
|
|
2
|
+
/** The mark every copy of the package gives its closed rejection, by the one global symbol. */
|
|
3
|
+
declare const closedMark: unique symbol;
|
|
4
|
+
/**
|
|
5
|
+
* What a run on a closed Git server rejects with, wherever it runs: a value of its own, so no
|
|
6
|
+
* mapper turns it into a store failure to try again. Each passes it through as it is.
|
|
7
|
+
*/
|
|
8
|
+
export declare class ServerClosed extends Error {
|
|
9
|
+
readonly name = "ServerClosed";
|
|
10
|
+
readonly [closedMark] = true;
|
|
11
|
+
constructor();
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Whether `cause` is a closed server's rejection, which a mapper passes through as it is.
|
|
15
|
+
*
|
|
16
|
+
* A predicate, not the class, because `instanceof` fails when a host loads two copies of the
|
|
17
|
+
* package. A bridge under Q787, as `ready()` is: SV's step 2b deletes it with `ready()`, once the
|
|
18
|
+
* drop-in runs in Git's runtime.
|
|
19
|
+
*/
|
|
20
|
+
export declare const isServerClosed: (cause: unknown) => cause is ServerClosed;
|
|
21
|
+
export {};
|