@ref0/git 0.0.0-stage → 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 +88 -3
- package/README.md +0 -3
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
import { decodeRow, fail } from "./errors.mjs";
|
|
2
|
+
import { versionId } from "./records.mjs";
|
|
3
|
+
import { repoScope, scopeRepo } from "./scopes.mjs";
|
|
4
|
+
import * as Effect from "effect/Effect";
|
|
5
|
+
import * as Schema from "effect/Schema";
|
|
6
|
+
// src/store/outbox.ts
|
|
7
|
+
/** A scope's outbox rows: its events by padded `seq`, its head, and its delivery cursor. */
|
|
8
|
+
const outboxCollections = {
|
|
9
|
+
events: "events",
|
|
10
|
+
outbox: "outbox",
|
|
11
|
+
/** Add-only: each cursor is a new row, by its inverted `seq`, so the newest reads first. */
|
|
12
|
+
delivered: "delivered"
|
|
13
|
+
};
|
|
14
|
+
const headKey = {
|
|
15
|
+
collection: outboxCollections.outbox,
|
|
16
|
+
id: "head"
|
|
17
|
+
};
|
|
18
|
+
/** The row naming the event a failed `git.deliver`'s last try sent, which a discard skips. */
|
|
19
|
+
const failedKey = {
|
|
20
|
+
collection: outboxCollections.outbox,
|
|
21
|
+
id: "failed"
|
|
22
|
+
};
|
|
23
|
+
/** The largest `seq` a cursor row's ID inverts. */
|
|
24
|
+
const lastSeq = 10 ** 15;
|
|
25
|
+
const eventId = (seq) => versionId(seq);
|
|
26
|
+
const cursorId = (seq) => versionId(lastSeq - seq);
|
|
27
|
+
const Seq = Schema.Int.check(Schema.isGreaterThanOrEqualTo(0));
|
|
28
|
+
const InternalRepoId = Schema.TemplateLiteral(["r_", Schema.String]);
|
|
29
|
+
/**
|
|
30
|
+
* A scope that held a name's sequence before this one, the last `seq` it wrote under it, and the
|
|
31
|
+
* `seq` here from which this scope's events wait for it: the first that goes on with the name.
|
|
32
|
+
*/
|
|
33
|
+
const Follows = Schema.Struct({
|
|
34
|
+
internalId: InternalRepoId,
|
|
35
|
+
seq: Seq,
|
|
36
|
+
from: Seq
|
|
37
|
+
});
|
|
38
|
+
/** The head as it was before a create's or rename's events, while the name may yet be lost. */
|
|
39
|
+
const HeadBefore = Schema.Struct({
|
|
40
|
+
next: Seq,
|
|
41
|
+
bytes: Seq,
|
|
42
|
+
after: Schema.optionalKey(Schema.Array(Follows))
|
|
43
|
+
});
|
|
44
|
+
/**
|
|
45
|
+
* A scope's outbox head, written by each commit that adds events. `next` is the next event's
|
|
46
|
+
* `seq`, `bytes` every event's size added up and `trimmed` the trimmed ones'. `unconfirmed`: the
|
|
47
|
+
* event at `seq`, the last, is a create's or a rename's that takes `name`, which delivery holds
|
|
48
|
+
* until the catalogue gives the repo that name, and drops, back to `before`, if it doesn't.
|
|
49
|
+
* `after`: the scopes that held this scope's names' sequences before, each of which delivers up
|
|
50
|
+
* to its `seq` before this one delivers its events from that entry's `from` on. Each `seq` was
|
|
51
|
+
* written before the event at `from`, so no two scopes wait on each other.
|
|
52
|
+
*/
|
|
53
|
+
const OutboxHead = Schema.Struct({
|
|
54
|
+
next: Seq,
|
|
55
|
+
bytes: Seq,
|
|
56
|
+
trimmed: Seq,
|
|
57
|
+
unconfirmed: Schema.optionalKey(Schema.Struct({
|
|
58
|
+
seq: Seq,
|
|
59
|
+
name: Schema.String,
|
|
60
|
+
before: HeadBefore
|
|
61
|
+
})),
|
|
62
|
+
after: Schema.optionalKey(Schema.Array(Follows))
|
|
63
|
+
});
|
|
64
|
+
/** The delivery cursor: every event up to `seq` is delivered or skipped, `bytes` their sizes. */
|
|
65
|
+
const Delivered = Schema.Struct({
|
|
66
|
+
seq: Seq,
|
|
67
|
+
bytes: Seq
|
|
68
|
+
});
|
|
69
|
+
/**
|
|
70
|
+
* A failed `git.deliver`'s last try, by the `claim` its job lists with, and the first event of the
|
|
71
|
+
* batch it sent: none when it failed before it sent one, or its process can't tell, as when the
|
|
72
|
+
* try's claim lapsed and the one after it had no try left.
|
|
73
|
+
*/
|
|
74
|
+
const FailedTry = Schema.Struct({
|
|
75
|
+
claim: Seq,
|
|
76
|
+
seq: Schema.optionalKey(Seq)
|
|
77
|
+
});
|
|
78
|
+
const emptyHead = {
|
|
79
|
+
next: 1,
|
|
80
|
+
bytes: 0,
|
|
81
|
+
trimmed: 0
|
|
82
|
+
};
|
|
83
|
+
const nothingDelivered = {
|
|
84
|
+
seq: 0,
|
|
85
|
+
bytes: 0
|
|
86
|
+
};
|
|
87
|
+
/** What a write reads, beside its own reads, to add events: the head and the newest cursor. */
|
|
88
|
+
const outboxReads = [{
|
|
89
|
+
collection: headKey.collection,
|
|
90
|
+
id: headKey.id
|
|
91
|
+
}, {
|
|
92
|
+
collection: outboxCollections.delivered,
|
|
93
|
+
limit: 1
|
|
94
|
+
}];
|
|
95
|
+
/** A new scope's outbox, for a write that reads none. */
|
|
96
|
+
const emptyOutbox = {
|
|
97
|
+
head: emptyHead,
|
|
98
|
+
delivered: nothingDelivered
|
|
99
|
+
};
|
|
100
|
+
/** The outbox from `outboxReads`' two results. */
|
|
101
|
+
const decodeOutbox = Effect.fnUntraced(function* (results) {
|
|
102
|
+
const [headRow] = results[0] ?? [];
|
|
103
|
+
const [cursorRow] = results[1] ?? [];
|
|
104
|
+
return {
|
|
105
|
+
head: headRow === void 0 ? emptyHead : yield* decodeRow(OutboxHead, headRow, "The outbox head"),
|
|
106
|
+
delivered: cursorRow === void 0 ? nothingDelivered : yield* decodeRow(Delivered, cursorRow, "The delivery cursor")
|
|
107
|
+
};
|
|
108
|
+
});
|
|
109
|
+
const StoredEvent = Schema.Struct({
|
|
110
|
+
type: Schema.String,
|
|
111
|
+
seq: Schema.Int,
|
|
112
|
+
at: Schema.Number
|
|
113
|
+
});
|
|
114
|
+
const isStoredEvent = Schema.is(StoredEvent);
|
|
115
|
+
/** The events rows, as Git wrote them: a row that isn't one is `DATA_LOSS`. */
|
|
116
|
+
const decodeEvents = (rows) => {
|
|
117
|
+
const events = [];
|
|
118
|
+
for (const row of rows) {
|
|
119
|
+
if (!isStoredEvent(row.value)) return fail("DATA_LOSS", `The event '${row.id}' is unreadable`);
|
|
120
|
+
events.push(row.value);
|
|
121
|
+
}
|
|
122
|
+
return Effect.succeed(events);
|
|
123
|
+
};
|
|
124
|
+
const encoder = new TextEncoder();
|
|
125
|
+
/** An event's size, as UTF-8 JSON: what the budgets count. */
|
|
126
|
+
const eventBytes = (event) => encoder.encode(JSON.stringify(event)).length;
|
|
127
|
+
/** The undelivered and delivered bytes a scope may hold: decision 10's 1 GiB and 256 MiB. */
|
|
128
|
+
const eventLimits = {
|
|
129
|
+
undelivered: 1024 ** 3,
|
|
130
|
+
kept: 256 * 1024 ** 2
|
|
131
|
+
};
|
|
132
|
+
const mib = (bytes) => `${Math.round(bytes / 1024 ** 2)} MiB`;
|
|
133
|
+
const exhausted = (scope, undelivered) => fail("RESOURCE_EXHAUSTED", `${mib(undelivered)} of events in '${scope}' wait for delivery`, {
|
|
134
|
+
hint: `The host's events delivery, 'git.deliver' in '${scope}', is failing or behind: fix it, then retry or discard that job. Past ${mib(eventLimits.undelivered)} undelivered, writes that add events are refused`,
|
|
135
|
+
context: { reason: "events-undelivered" }
|
|
136
|
+
});
|
|
137
|
+
const waitsFull = (scope) => fail("RESOURCE_EXHAUSTED", `'${scope}' already waits on 20 repos that had its names`, {
|
|
138
|
+
hint: `Each wait ends once the repo that had the name delivers its events, which 'git.deliver' in '${scope}' looks for every 10 seconds: try again then`,
|
|
139
|
+
context: { reason: "events-waiting" }
|
|
140
|
+
});
|
|
141
|
+
/**
|
|
142
|
+
* The head a write that opened the repo by `confirmed` starts from, and what it drops: a create's
|
|
143
|
+
* or rename's events are confirmed once the repo is opened by the name they took, and dropped once
|
|
144
|
+
* it's opened by another, since the name was lost and taken back.
|
|
145
|
+
*/
|
|
146
|
+
const settled = (head, confirmed) => {
|
|
147
|
+
const { unconfirmed } = head;
|
|
148
|
+
if (unconfirmed === void 0 || confirmed === void 0) return {
|
|
149
|
+
head,
|
|
150
|
+
put: [],
|
|
151
|
+
delete: []
|
|
152
|
+
};
|
|
153
|
+
if (unconfirmed.name !== confirmed) return {
|
|
154
|
+
...dropUnconfirmed(head),
|
|
155
|
+
head: backOf(head)
|
|
156
|
+
};
|
|
157
|
+
const kept = { ...head };
|
|
158
|
+
delete kept.unconfirmed;
|
|
159
|
+
return {
|
|
160
|
+
head: kept,
|
|
161
|
+
put: [],
|
|
162
|
+
delete: []
|
|
163
|
+
};
|
|
164
|
+
};
|
|
165
|
+
/** The `seq` the first event `appendEvents` adds with these options takes. */
|
|
166
|
+
const firstSeq = (outbox, options) => Math.max(settled(outbox.head, options.confirmed).head.next, options.from ?? 1);
|
|
167
|
+
/**
|
|
168
|
+
* The rows that add `events` to a scope's outbox at `outbox`: each event at the next `seq`, with
|
|
169
|
+
* the commit's `at`, and the head moved past them. Past the undelivered budget the write is
|
|
170
|
+
* refused, unless it's exempt. With no `log`, Git writes no events.
|
|
171
|
+
*/
|
|
172
|
+
const appendEvents = (log, outbox, events, options) => {
|
|
173
|
+
const { delivered } = outbox;
|
|
174
|
+
if (log === void 0 || events.length === 0) return Effect.succeed({
|
|
175
|
+
put: [],
|
|
176
|
+
delete: [],
|
|
177
|
+
jobs: [],
|
|
178
|
+
head: outbox.head
|
|
179
|
+
});
|
|
180
|
+
if (outbox.head.unconfirmed !== void 0 && options.confirmed === void 0) return Effect.die(/* @__PURE__ */ new TypeError(`Events in '${options.scope}' were added behind a name not yet settled`));
|
|
181
|
+
const from = settled(outbox.head, options.confirmed);
|
|
182
|
+
const { head } = from;
|
|
183
|
+
const undelivered = head.bytes - delivered.bytes;
|
|
184
|
+
if (options.exempt !== true && undelivered >= eventLimits.undelivered) return exhausted(options.scope, undelivered);
|
|
185
|
+
const start = Math.max(head.next, options.from ?? 1);
|
|
186
|
+
const internalId = scopeRepo(options.scope);
|
|
187
|
+
const repo = internalId === void 0 ? {} : { internalId };
|
|
188
|
+
const put = [];
|
|
189
|
+
let bytes = head.bytes;
|
|
190
|
+
for (const [index, body] of events.entries()) {
|
|
191
|
+
const seq = start + index;
|
|
192
|
+
const event = {
|
|
193
|
+
...body,
|
|
194
|
+
...repo,
|
|
195
|
+
seq,
|
|
196
|
+
at: options.at
|
|
197
|
+
};
|
|
198
|
+
bytes += eventBytes(event);
|
|
199
|
+
put.push({
|
|
200
|
+
collection: outboxCollections.events,
|
|
201
|
+
id: eventId(seq),
|
|
202
|
+
value: event
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
const next = {
|
|
206
|
+
...head,
|
|
207
|
+
next: start + events.length,
|
|
208
|
+
bytes
|
|
209
|
+
};
|
|
210
|
+
if (options.confirm !== void 0) {
|
|
211
|
+
const before = {
|
|
212
|
+
next: head.next,
|
|
213
|
+
bytes: head.bytes
|
|
214
|
+
};
|
|
215
|
+
if (head.after !== void 0) before.after = head.after;
|
|
216
|
+
next.unconfirmed = {
|
|
217
|
+
seq: start,
|
|
218
|
+
name: options.confirm,
|
|
219
|
+
before
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
const { after } = options;
|
|
223
|
+
if (after !== void 0 && start > 1 && repoScope(after) !== options.scope) {
|
|
224
|
+
const waits = head.after ?? [];
|
|
225
|
+
if (waits.length >= 20) return waitsFull(options.scope);
|
|
226
|
+
next.after = [...waits, {
|
|
227
|
+
internalId: after,
|
|
228
|
+
seq: start - 1,
|
|
229
|
+
from: start
|
|
230
|
+
}];
|
|
231
|
+
}
|
|
232
|
+
put.push({
|
|
233
|
+
...headKey,
|
|
234
|
+
value: next
|
|
235
|
+
});
|
|
236
|
+
const putIds = new Set(put.map((row) => `${row.collection}/${row.id}`));
|
|
237
|
+
const dropped = from.delete.filter((key) => !putIds.has(`${key.collection}/${key.id}`));
|
|
238
|
+
return Effect.succeed({
|
|
239
|
+
put,
|
|
240
|
+
delete: dropped,
|
|
241
|
+
jobs: [log.deliverJob()],
|
|
242
|
+
head: next
|
|
243
|
+
});
|
|
244
|
+
};
|
|
245
|
+
/**
|
|
246
|
+
* What drops a create's or rename's one event once its name is lost: `repo.created` names a repo
|
|
247
|
+
* that never was, and `repo.renamed` a name the repo never had. The head goes back to where it
|
|
248
|
+
* was. Nothing is ever behind that event: each write settles the name before adding its own
|
|
249
|
+
* (Q186), so a lost rename's repo keeps every event written since, under the name it kept.
|
|
250
|
+
*/
|
|
251
|
+
const dropUnconfirmed = (head) => {
|
|
252
|
+
const { unconfirmed } = head;
|
|
253
|
+
if (unconfirmed === void 0) return {
|
|
254
|
+
put: [],
|
|
255
|
+
delete: []
|
|
256
|
+
};
|
|
257
|
+
const dropped = {
|
|
258
|
+
collection: outboxCollections.events,
|
|
259
|
+
id: eventId(unconfirmed.seq)
|
|
260
|
+
};
|
|
261
|
+
return {
|
|
262
|
+
put: [{
|
|
263
|
+
...headKey,
|
|
264
|
+
value: backOf(head)
|
|
265
|
+
}],
|
|
266
|
+
delete: [dropped]
|
|
267
|
+
};
|
|
268
|
+
};
|
|
269
|
+
/** The head as it was before its unconfirmed events. */
|
|
270
|
+
const backOf = (head) => {
|
|
271
|
+
const { unconfirmed } = head;
|
|
272
|
+
if (unconfirmed === void 0) return head;
|
|
273
|
+
const back = {
|
|
274
|
+
...head,
|
|
275
|
+
...unconfirmed.before
|
|
276
|
+
};
|
|
277
|
+
delete back.unconfirmed;
|
|
278
|
+
if (unconfirmed.before.after === void 0) delete back.after;
|
|
279
|
+
return back;
|
|
280
|
+
};
|
|
281
|
+
/** What a call's events say of who made it: IDs only, and no actor for an anonymous caller. */
|
|
282
|
+
const callerEnvelope = (caller) => {
|
|
283
|
+
const envelope = {};
|
|
284
|
+
if (caller === void 0) return envelope;
|
|
285
|
+
if (caller.actor.anonymous !== true) envelope.actor = { id: caller.actor.id };
|
|
286
|
+
if (caller.subject !== void 0) envelope.subject = { id: caller.subject.id };
|
|
287
|
+
if (caller.token !== void 0) envelope.token = caller.token.id;
|
|
288
|
+
return envelope;
|
|
289
|
+
};
|
|
290
|
+
/** A repo event's envelope for a call `caller` made on the repo named `repo`. */
|
|
291
|
+
const repoEnvelope = (caller, repo) => ({
|
|
292
|
+
...callerEnvelope(caller),
|
|
293
|
+
repo
|
|
294
|
+
});
|
|
295
|
+
export { Delivered, FailedTry, OutboxHead, appendEvents, callerEnvelope, cursorId, decodeEvents, decodeOutbox, dropUnconfirmed, emptyHead, emptyOutbox, eventBytes, eventId, eventLimits, failedKey, firstSeq, headKey, nothingDelivered, outboxCollections, outboxReads, repoEnvelope };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { defineJob } from "@ref0/infra";
|
|
2
|
+
import * as Schema from "effect/Schema";
|
|
3
|
+
// src/store/queue-jobs.ts
|
|
4
|
+
/**
|
|
5
|
+
* The merge queue's jobs' names, data and rows, which the queue's writes save, and a push from
|
|
6
|
+
* outside the queue saves `git.queue.advance` with, when it moves a branch a queue targets.
|
|
7
|
+
*/
|
|
8
|
+
const advanceName = "git.queue.advance";
|
|
9
|
+
const buildName = "git.queue.build";
|
|
10
|
+
const timeoutName = "git.queue.report-timeout";
|
|
11
|
+
const AdvanceData = Schema.Struct({ target: Schema.String });
|
|
12
|
+
const CandidateData = Schema.Struct({ candidate: Schema.String });
|
|
13
|
+
/**
|
|
14
|
+
* Makes a queue job's rows, beside the rows that need it. The server's definitions, with the same
|
|
15
|
+
* names and schemas, run them; these are never registered.
|
|
16
|
+
*/
|
|
17
|
+
const rowsOf = (name, schema) => defineJob({
|
|
18
|
+
name,
|
|
19
|
+
schema: Schema.toStandardSchemaV1(schema),
|
|
20
|
+
handler: () => {
|
|
21
|
+
throw new TypeError(`'${name}' runs under the server's definition`);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
const advanceRows = rowsOf(advanceName, AdvanceData);
|
|
25
|
+
const buildRows = rowsOf(buildName, CandidateData);
|
|
26
|
+
const timeoutRows = rowsOf(timeoutName, CandidateData);
|
|
27
|
+
/** `git.queue.advance` for `target`, due now: one row a target, which a later save leaves due. */
|
|
28
|
+
const advanceRow = (target) => advanceRows.job({
|
|
29
|
+
key: target,
|
|
30
|
+
data: { target }
|
|
31
|
+
});
|
|
32
|
+
/** `git.queue.build` for a candidate just opened. */
|
|
33
|
+
const buildRow = (candidate) => buildRows.job({
|
|
34
|
+
key: candidate,
|
|
35
|
+
data: { candidate }
|
|
36
|
+
});
|
|
37
|
+
/** `git.queue.report-timeout` for a candidate opened for checks, due when its report is late. */
|
|
38
|
+
const timeoutRow = (candidate, at) => timeoutRows.job({
|
|
39
|
+
key: candidate,
|
|
40
|
+
data: { candidate },
|
|
41
|
+
at
|
|
42
|
+
});
|
|
43
|
+
export { AdvanceData, CandidateData, advanceName, advanceRow, buildName, buildRow, timeoutName, timeoutRow };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// src/store/random.ts
|
|
2
|
+
const toBase64Url = (bytes) => btoa(String.fromCharCode(...bytes)).replaceAll("+", "-").replaceAll("/", "_").replace(/=+$/, "");
|
|
3
|
+
/** base64url's bytes, or `undefined` for text that isn't base64url. */
|
|
4
|
+
const bytesFromBase64Url = (text) => {
|
|
5
|
+
if (!/^[A-Za-z0-9_-]*$/.test(text) || text.length % 4 === 1) return void 0;
|
|
6
|
+
const padded = text.replaceAll("-", "+").replaceAll("_", "/");
|
|
7
|
+
const binary = atob(padded + "=".repeat((4 - padded.length % 4) % 4));
|
|
8
|
+
return Uint8Array.from(binary, (char) => char.charCodeAt(0));
|
|
9
|
+
};
|
|
10
|
+
/** `bytes` as UTF-8 text, or `undefined` for bytes that aren't UTF-8. */
|
|
11
|
+
const utf8Of = (bytes) => {
|
|
12
|
+
try {
|
|
13
|
+
return new TextDecoder("utf-8", {
|
|
14
|
+
fatal: true,
|
|
15
|
+
ignoreBOM: false
|
|
16
|
+
}).decode(bytes);
|
|
17
|
+
} catch {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
/** base64url's text as UTF-8, or `undefined` for text that isn't both. */
|
|
22
|
+
const fromBase64Url = (text) => {
|
|
23
|
+
const bytes = bytesFromBase64Url(text);
|
|
24
|
+
return bytes === void 0 ? void 0 : utf8Of(bytes);
|
|
25
|
+
};
|
|
26
|
+
/** `count` random bytes, from the platform's secure source, as base64url. */
|
|
27
|
+
const randomText = (count) => toBase64Url(crypto.getRandomValues(new Uint8Array(count)));
|
|
28
|
+
export { bytesFromBase64Url, fromBase64Url, randomText, toBase64Url, utf8Of };
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import { collections } from "./scopes.mjs";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import * as Schema from "effect/Schema";
|
|
4
|
+
import * as Hex from "effect/encoding/Hex";
|
|
5
|
+
// src/store/records.ts
|
|
6
|
+
/** A repo's `InternalRepoId`, as rows store it. */
|
|
7
|
+
const InternalRepoId = Schema.TemplateLiteral(["r_", Schema.String]);
|
|
8
|
+
const Revision = Schema.Int;
|
|
9
|
+
/** The `seq` a name's next event takes, kept on its tombstone so a repo made again goes on from it. */
|
|
10
|
+
const NextSeq = Schema.Int.check(Schema.isGreaterThanOrEqualTo(1));
|
|
11
|
+
/**
|
|
12
|
+
* A repo that held a name before its entry's, `until` its receipts can no longer answer:
|
|
13
|
+
* `keyKept` past when it was moved off the name.
|
|
14
|
+
*/
|
|
15
|
+
const HeldBefore = Schema.Struct({
|
|
16
|
+
internalId: InternalRepoId,
|
|
17
|
+
until: Schema.Int
|
|
18
|
+
});
|
|
19
|
+
/**
|
|
20
|
+
* A name's entry in `git/repos`: `RepoCatalogueEntry`, as it's stored. `before` holds the repos
|
|
21
|
+
* that held the name before, newest first, so a write sent again by name finds the receipt its
|
|
22
|
+
* key left, whichever repo holds the name now.
|
|
23
|
+
*/
|
|
24
|
+
const CatalogueEntry = Schema.Struct({
|
|
25
|
+
internalId: InternalRepoId,
|
|
26
|
+
sourceRevision: Revision,
|
|
27
|
+
deleted: Schema.optionalKey(Schema.Literal(true)),
|
|
28
|
+
renamedTo: Schema.optionalKey(Schema.String),
|
|
29
|
+
before: Schema.optionalKey(Schema.Array(HeldBefore)),
|
|
30
|
+
nextSeq: Schema.optionalKey(NextSeq)
|
|
31
|
+
});
|
|
32
|
+
/**
|
|
33
|
+
* A repo's place in create order, in `git/repos`: the name it has now, which a rename rewrites
|
|
34
|
+
* under the same key, so the repo keeps its place.
|
|
35
|
+
*/
|
|
36
|
+
const CreatedRow = Schema.Struct({ name: Schema.String });
|
|
37
|
+
/**
|
|
38
|
+
* How long a write's key answers as it first did, in milliseconds: 24 hours, for every keyed
|
|
39
|
+
* write. From `at`, a write sent again answers as a new one.
|
|
40
|
+
*/
|
|
41
|
+
const keyKept = 864e5;
|
|
42
|
+
/** A repo write's first answer, `RepoInfo`, as its key keeps it. */
|
|
43
|
+
const KeptRepoInfo = Schema.Struct({
|
|
44
|
+
id: Schema.String,
|
|
45
|
+
defaultBranch: Schema.optionalKey(Schema.String),
|
|
46
|
+
public: Schema.Boolean,
|
|
47
|
+
upstream: Schema.optionalKey(Schema.String),
|
|
48
|
+
stats: Schema.Struct({
|
|
49
|
+
repo: Schema.String,
|
|
50
|
+
refs: Schema.Int,
|
|
51
|
+
packs: Schema.Int,
|
|
52
|
+
packBytes: Schema.Int,
|
|
53
|
+
ownBytes: Schema.Int,
|
|
54
|
+
looseObjects: Schema.Int,
|
|
55
|
+
looseBytes: Schema.Int,
|
|
56
|
+
leavingBytes: Schema.Int,
|
|
57
|
+
pushedAt: Schema.optionalKey(Schema.Int),
|
|
58
|
+
maintainedAt: Schema.optionalKey(Schema.Int)
|
|
59
|
+
}),
|
|
60
|
+
work: Schema.Struct({
|
|
61
|
+
waiting: Schema.Int,
|
|
62
|
+
oldestDue: Schema.optionalKey(Schema.Int),
|
|
63
|
+
failed: Schema.Int,
|
|
64
|
+
oldestFailed: Schema.optionalKey(Schema.Int)
|
|
65
|
+
})
|
|
66
|
+
});
|
|
67
|
+
/** A part of a caller's key with no `:` in it: `%` and `:` escaped, `~` first when there is one. */
|
|
68
|
+
const keyPart = (part) => part === void 0 ? "" : `~${part.replaceAll("%", "%25").replaceAll(":", "%3A")}`;
|
|
69
|
+
/**
|
|
70
|
+
* `key` as `caller` sent it: the actor's ID, the token's when the caller came with one, then the
|
|
71
|
+
* key, joined by `:`, which no part holds. Two callers' keys never meet, so Pip's and Mo's
|
|
72
|
+
* writes with one key both apply.
|
|
73
|
+
*/
|
|
74
|
+
const callerKey = (caller, key) => [
|
|
75
|
+
keyPart(caller.actor.anonymous === true ? void 0 : caller.actor.id),
|
|
76
|
+
keyPart(caller.token?.id),
|
|
77
|
+
keyPart(key)
|
|
78
|
+
].join(":");
|
|
79
|
+
/**
|
|
80
|
+
* The SHA-256 of `key` as `caller` sent it, as lowercase hex: all a receipt keeps of the key, so
|
|
81
|
+
* each receipt's ID is the same length however long its key, and a page of them stays small. It
|
|
82
|
+
* hashes the key as JSON, which spells out a lone surrogate that UTF-8 would turn into U+FFFD.
|
|
83
|
+
*/
|
|
84
|
+
const keyDigest = (caller, key) => {
|
|
85
|
+
const bytes = new TextEncoder().encode(JSON.stringify(callerKey(caller, key)));
|
|
86
|
+
return Effect.promise(() => crypto.subtle.digest("SHA-256", bytes)).pipe(Effect.map((digest) => Hex.encode(new Uint8Array(digest))));
|
|
87
|
+
};
|
|
88
|
+
/** The key `caller` sent a write with at `at`, kept beside `input`: its kind and what it asked. */
|
|
89
|
+
const keptKey = (caller, key, input, at) => key === void 0 ? Effect.succeed(void 0) : Effect.map(keyDigest(caller, key), (digest) => ({
|
|
90
|
+
key: digest,
|
|
91
|
+
input: JSON.stringify(input),
|
|
92
|
+
at
|
|
93
|
+
}));
|
|
94
|
+
/** Whether a key taken at `taken` still answers at `at`: until `keyKept` has passed. */
|
|
95
|
+
const keyLive = (taken, at) => at < taken + keyKept;
|
|
96
|
+
/**
|
|
97
|
+
* The name a repo left on its last rename, at the revision its tombstone takes, and the `seq` that
|
|
98
|
+
* name's next event takes. `receipt`: a keyed rename's receipt row, which a takeback deletes, so
|
|
99
|
+
* the rename sent again is refused as the lost one was.
|
|
100
|
+
*/
|
|
101
|
+
const RenamedFrom = Schema.Struct({
|
|
102
|
+
name: Schema.String,
|
|
103
|
+
revision: Revision,
|
|
104
|
+
nextSeq: Schema.optionalKey(NextSeq),
|
|
105
|
+
receipt: Schema.optionalKey(Schema.String)
|
|
106
|
+
});
|
|
107
|
+
/**
|
|
108
|
+
* What a fork's record keeps of its source: `upstreamInternalId`, which follows it across renames,
|
|
109
|
+
* so its name is read from its record when a read names it, and `holder`, whom the fork is for.
|
|
110
|
+
*/
|
|
111
|
+
const ForkOf = Schema.Struct({
|
|
112
|
+
upstreamInternalId: InternalRepoId,
|
|
113
|
+
holder: Schema.String
|
|
114
|
+
});
|
|
115
|
+
/** A fork's row in `git/repos`' `forks`: the holder's fork, by its source's ID and the holder. */
|
|
116
|
+
const ForkRow = Schema.Struct({ internalId: InternalRepoId });
|
|
117
|
+
/**
|
|
118
|
+
* A repo's own record, `repo/self` in its scope: the source `git/repos` is projected from. `name`
|
|
119
|
+
* and `revision` are its name's, and `renamedFrom` the name it left; `deleted` marks a repo
|
|
120
|
+
* deleted, or a create that lost its name to another. `changedAt` is when the record was last
|
|
121
|
+
* written, which its projection dates the repos it moves off a name by. A deleted repo's `nextSeq`
|
|
122
|
+
* is the `seq` its name's next event takes, which its tombstone keeps. A fork's `fork` says
|
|
123
|
+
* what it was made from.
|
|
124
|
+
*/
|
|
125
|
+
const StoredRepo = Schema.Struct({
|
|
126
|
+
name: Schema.String,
|
|
127
|
+
revision: Revision,
|
|
128
|
+
defaultBranch: Schema.String,
|
|
129
|
+
public: Schema.Boolean,
|
|
130
|
+
fork: Schema.optionalKey(ForkOf),
|
|
131
|
+
createdAt: Schema.Int,
|
|
132
|
+
changedAt: Schema.Int,
|
|
133
|
+
deleted: Schema.optionalKey(Schema.Literal(true)),
|
|
134
|
+
renamedFrom: Schema.optionalKey(RenamedFrom),
|
|
135
|
+
nextSeq: Schema.optionalKey(NextSeq)
|
|
136
|
+
});
|
|
137
|
+
/**
|
|
138
|
+
* A rename's record once it lost its new name to a repo made there first: the name it left, which
|
|
139
|
+
* its entry still holds, since a rename leaves its old name only when it wins the new one, at a
|
|
140
|
+
* revision past the tombstone a win would have left there, with the rename's receipt and its index row deleted.
|
|
141
|
+
* `undefined` for any other record.
|
|
142
|
+
*/
|
|
143
|
+
const takenBack = (record) => {
|
|
144
|
+
const { renamedFrom, ...rest } = record;
|
|
145
|
+
if (renamedFrom === void 0 || record.deleted === true) return void 0;
|
|
146
|
+
const back = {
|
|
147
|
+
...rest,
|
|
148
|
+
name: renamedFrom.name,
|
|
149
|
+
revision: renamedFrom.revision + 1
|
|
150
|
+
};
|
|
151
|
+
const { receipt } = renamedFrom;
|
|
152
|
+
return {
|
|
153
|
+
record: back,
|
|
154
|
+
delete: receipt === void 0 ? [] : [{
|
|
155
|
+
collection: collections.receipts,
|
|
156
|
+
id: receipt
|
|
157
|
+
}, {
|
|
158
|
+
collection: collections.receiptIndex,
|
|
159
|
+
id: receipt
|
|
160
|
+
}]
|
|
161
|
+
};
|
|
162
|
+
};
|
|
163
|
+
/** The repo's `pruned` mark in `upkeep`: the ID the last prune that dropped objects gave it. */
|
|
164
|
+
const PrunedMark = Schema.Struct({ id: Schema.String });
|
|
165
|
+
Schema.Struct({ since: Schema.Number });
|
|
166
|
+
/**
|
|
167
|
+
* A mirror's row in `mirrors`, by its ref's full name: where it pushes, by provider name, and
|
|
168
|
+
* whether it's paused. A push that moves the ref saves the mirror's job while it's `active`.
|
|
169
|
+
*/
|
|
170
|
+
const MirrorRow = Schema.Struct({
|
|
171
|
+
destination: Schema.Struct({
|
|
172
|
+
provider: Schema.String,
|
|
173
|
+
repo: Schema.String
|
|
174
|
+
}),
|
|
175
|
+
state: Schema.Literals(["active", "paused"]),
|
|
176
|
+
paused: Schema.optionalKey(Schema.Literals(["diverged", "refused"]))
|
|
177
|
+
});
|
|
178
|
+
/** The job a push saves for each ref an active mirror names, keyed by the ref. */
|
|
179
|
+
const mirrorJobName = "git.sync.mirror";
|
|
180
|
+
/**
|
|
181
|
+
* A time in `stats`, `pushed` or `maintained`: put at the later of the time it held and the
|
|
182
|
+
* committing try's clock, so it never moves back when another isolate's clock is behind.
|
|
183
|
+
*/
|
|
184
|
+
const StatsTime = Schema.Struct({ at: Schema.Int });
|
|
185
|
+
/** A pack's row in `packs`, by its ID: how many objects it holds, and its bytes. */
|
|
186
|
+
const PackRow = Schema.Struct({
|
|
187
|
+
objects: Schema.Int,
|
|
188
|
+
bytes: Schema.Int
|
|
189
|
+
});
|
|
190
|
+
/** A row's ID by its sequence number, zero-padded so the rows read in order. */
|
|
191
|
+
const versionId = (sequence) => String(sequence).padStart(16, "0");
|
|
192
|
+
export { CatalogueEntry, CreatedRow, ForkOf, ForkRow, InternalRepoId, KeptRepoInfo, MirrorRow, PackRow, PrunedMark, RenamedFrom, StatsTime, StoredRepo, callerKey, keptKey, keyDigest, keyKept, keyLive, mirrorJobName, takenBack, versionId };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { decodeRow } from "./errors.mjs";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import * as Schema from "effect/Schema";
|
|
4
|
+
// src/store/ref-rows.ts
|
|
5
|
+
/** A ref's row in `refs`, keyed by its full name, such as `refs/heads/main`. */
|
|
6
|
+
const RefRow = Schema.Struct({ oid: Schema.String.check(Schema.isPattern(/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/)) });
|
|
7
|
+
/**
|
|
8
|
+
* Leave to read every ref of a repo, whoever the caller is. A call made for a caller reads refs
|
|
9
|
+
* through its `RepoView`, which leaves out the refs the caller doesn't see, and only the readers
|
|
10
|
+
* that need every ref hold one of these: the view itself, the push's decide, forks' copy, the
|
|
11
|
+
* queue's state, sync, upkeep, the index's build, the client's own repo and storage's prune. `lint/view-boundary.test.ts`
|
|
12
|
+
* lists the files that mint one, so a new reader that skips the view is a change that test sees.
|
|
13
|
+
*/
|
|
14
|
+
var WholeRepo = class WholeRepo {
|
|
15
|
+
#whole = true;
|
|
16
|
+
constructor() {}
|
|
17
|
+
/** Leave for one of the readers above. */
|
|
18
|
+
static mint() {
|
|
19
|
+
return new WholeRepo();
|
|
20
|
+
}
|
|
21
|
+
/** Whether `value` is leave from `mint`. */
|
|
22
|
+
static is(value) {
|
|
23
|
+
return value instanceof WholeRepo && value.#whole;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
/** One ref row's tip, read with `whole`. */
|
|
27
|
+
const wholeRef = (_whole, row, what = `Ref '${row.id}'`) => Effect.map(decodeRow(RefRow, row, what), ({ oid }) => oid);
|
|
28
|
+
/** A repo's refs by name, every one of them, from its `refs` rows, read with `whole`. */
|
|
29
|
+
const wholeRefs = (whole, rows) => Effect.map(Effect.forEach(rows, (row) => Effect.map(wholeRef(whole, row), (oid) => [row.id, oid])), (entries) => new Map(entries));
|
|
30
|
+
export { WholeRepo, wholeRef, wholeRefs };
|