@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,297 @@
|
|
|
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: `Past ${mib(eventLimits.undelivered)} undelivered, writes that add events are refused until they're delivered: try again later`,
|
|
135
|
+
hostHint: `The host's events delivery, 'git.deliver' in '${scope}', is failing or behind: fix it, then retry or discard that job`,
|
|
136
|
+
context: { reason: "events-undelivered" }
|
|
137
|
+
});
|
|
138
|
+
const waitsFull = (scope) => fail("RESOURCE_EXHAUSTED", `'${scope}' already waits on 20 repos that had its names`, {
|
|
139
|
+
hint: "Each wait ends once the repo that had the name delivers its events: try again then",
|
|
140
|
+
hostHint: `'git.deliver' in '${scope}' looks for them every 10 seconds`,
|
|
141
|
+
context: { reason: "events-waiting" }
|
|
142
|
+
});
|
|
143
|
+
/**
|
|
144
|
+
* The head a write that opened the repo by `confirmed` starts from, and what it drops: a create's
|
|
145
|
+
* or rename's events are confirmed once the repo is opened by the name they took, and dropped once
|
|
146
|
+
* it's opened by another, since the name was lost and taken back.
|
|
147
|
+
*/
|
|
148
|
+
const settled = (head, confirmed) => {
|
|
149
|
+
const { unconfirmed } = head;
|
|
150
|
+
if (unconfirmed === void 0 || confirmed === void 0) return {
|
|
151
|
+
head,
|
|
152
|
+
put: [],
|
|
153
|
+
delete: []
|
|
154
|
+
};
|
|
155
|
+
if (unconfirmed.name !== confirmed) return {
|
|
156
|
+
...dropUnconfirmed(head),
|
|
157
|
+
head: backOf(head)
|
|
158
|
+
};
|
|
159
|
+
const kept = { ...head };
|
|
160
|
+
delete kept.unconfirmed;
|
|
161
|
+
return {
|
|
162
|
+
head: kept,
|
|
163
|
+
put: [],
|
|
164
|
+
delete: []
|
|
165
|
+
};
|
|
166
|
+
};
|
|
167
|
+
/** The `seq` the first event `appendEvents` adds with these options takes. */
|
|
168
|
+
const firstSeq = (outbox, options) => Math.max(settled(outbox.head, options.confirmed).head.next, options.from ?? 1);
|
|
169
|
+
/**
|
|
170
|
+
* The rows that add `events` to a scope's outbox at `outbox`: each event at the next `seq`, with
|
|
171
|
+
* the commit's `at`, and the head moved past them. Past the undelivered budget the write is
|
|
172
|
+
* refused, unless it's exempt. With no `log`, Git writes no events.
|
|
173
|
+
*/
|
|
174
|
+
const appendEvents = (log, outbox, events, options) => {
|
|
175
|
+
const { delivered } = outbox;
|
|
176
|
+
if (log === void 0 || events.length === 0) return Effect.succeed({
|
|
177
|
+
put: [],
|
|
178
|
+
delete: [],
|
|
179
|
+
jobs: [],
|
|
180
|
+
head: outbox.head
|
|
181
|
+
});
|
|
182
|
+
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`));
|
|
183
|
+
const from = settled(outbox.head, options.confirmed);
|
|
184
|
+
const { head } = from;
|
|
185
|
+
const undelivered = head.bytes - delivered.bytes;
|
|
186
|
+
if (options.exempt !== true && undelivered >= eventLimits.undelivered) return exhausted(options.scope, undelivered);
|
|
187
|
+
const start = Math.max(head.next, options.from ?? 1);
|
|
188
|
+
const internalId = scopeRepo(options.scope);
|
|
189
|
+
const repo = internalId === void 0 ? {} : { internalId };
|
|
190
|
+
const put = [];
|
|
191
|
+
let bytes = head.bytes;
|
|
192
|
+
for (const [index, body] of events.entries()) {
|
|
193
|
+
const seq = start + index;
|
|
194
|
+
const event = {
|
|
195
|
+
...body,
|
|
196
|
+
...repo,
|
|
197
|
+
seq,
|
|
198
|
+
at: options.at
|
|
199
|
+
};
|
|
200
|
+
bytes += eventBytes(event);
|
|
201
|
+
put.push({
|
|
202
|
+
collection: outboxCollections.events,
|
|
203
|
+
id: eventId(seq),
|
|
204
|
+
value: event
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
const next = {
|
|
208
|
+
...head,
|
|
209
|
+
next: start + events.length,
|
|
210
|
+
bytes
|
|
211
|
+
};
|
|
212
|
+
if (options.confirm !== void 0) {
|
|
213
|
+
const before = {
|
|
214
|
+
next: head.next,
|
|
215
|
+
bytes: head.bytes
|
|
216
|
+
};
|
|
217
|
+
if (head.after !== void 0) before.after = head.after;
|
|
218
|
+
next.unconfirmed = {
|
|
219
|
+
seq: start,
|
|
220
|
+
name: options.confirm,
|
|
221
|
+
before
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
const { after } = options;
|
|
225
|
+
if (after !== void 0 && start > 1 && repoScope(after) !== options.scope) {
|
|
226
|
+
const waits = head.after ?? [];
|
|
227
|
+
if (waits.length >= 20) return waitsFull(options.scope);
|
|
228
|
+
next.after = [...waits, {
|
|
229
|
+
internalId: after,
|
|
230
|
+
seq: start - 1,
|
|
231
|
+
from: start
|
|
232
|
+
}];
|
|
233
|
+
}
|
|
234
|
+
put.push({
|
|
235
|
+
...headKey,
|
|
236
|
+
value: next
|
|
237
|
+
});
|
|
238
|
+
const putIds = new Set(put.map((row) => `${row.collection}/${row.id}`));
|
|
239
|
+
const dropped = from.delete.filter((key) => !putIds.has(`${key.collection}/${key.id}`));
|
|
240
|
+
return Effect.succeed({
|
|
241
|
+
put,
|
|
242
|
+
delete: dropped,
|
|
243
|
+
jobs: [log.deliverJob()],
|
|
244
|
+
head: next
|
|
245
|
+
});
|
|
246
|
+
};
|
|
247
|
+
/**
|
|
248
|
+
* What drops a create's or rename's one event once its name is lost: `repo.created` names a repo
|
|
249
|
+
* that never was, and `repo.renamed` a name the repo never had. The head goes back to where it
|
|
250
|
+
* was. Nothing is ever behind that event: each write settles the name before adding its own
|
|
251
|
+
* (Q186), so a lost rename's repo keeps every event written since, under the name it kept.
|
|
252
|
+
*/
|
|
253
|
+
const dropUnconfirmed = (head) => {
|
|
254
|
+
const { unconfirmed } = head;
|
|
255
|
+
if (unconfirmed === void 0) return {
|
|
256
|
+
put: [],
|
|
257
|
+
delete: []
|
|
258
|
+
};
|
|
259
|
+
const dropped = {
|
|
260
|
+
collection: outboxCollections.events,
|
|
261
|
+
id: eventId(unconfirmed.seq)
|
|
262
|
+
};
|
|
263
|
+
return {
|
|
264
|
+
put: [{
|
|
265
|
+
...headKey,
|
|
266
|
+
value: backOf(head)
|
|
267
|
+
}],
|
|
268
|
+
delete: [dropped]
|
|
269
|
+
};
|
|
270
|
+
};
|
|
271
|
+
/** The head as it was before its unconfirmed events. */
|
|
272
|
+
const backOf = (head) => {
|
|
273
|
+
const { unconfirmed } = head;
|
|
274
|
+
if (unconfirmed === void 0) return head;
|
|
275
|
+
const back = {
|
|
276
|
+
...head,
|
|
277
|
+
...unconfirmed.before
|
|
278
|
+
};
|
|
279
|
+
delete back.unconfirmed;
|
|
280
|
+
if (unconfirmed.before.after === void 0) delete back.after;
|
|
281
|
+
return back;
|
|
282
|
+
};
|
|
283
|
+
/** What a call's events say of who made it: IDs only, and no actor for an anonymous caller. */
|
|
284
|
+
const callerEnvelope = (caller) => {
|
|
285
|
+
const envelope = {};
|
|
286
|
+
if (caller === void 0) return envelope;
|
|
287
|
+
if (caller.actor.anonymous !== true) envelope.actor = { id: caller.actor.id };
|
|
288
|
+
if (caller.subject !== void 0) envelope.subject = { id: caller.subject.id };
|
|
289
|
+
if (caller.token !== void 0) envelope.token = caller.token.id;
|
|
290
|
+
return envelope;
|
|
291
|
+
};
|
|
292
|
+
/** A repo event's envelope for a call `caller` made on the repo named `repo`. */
|
|
293
|
+
const repoEnvelope = (caller, repo) => ({
|
|
294
|
+
...callerEnvelope(caller),
|
|
295
|
+
repo
|
|
296
|
+
});
|
|
297
|
+
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,258 @@
|
|
|
1
|
+
import { exitIn, noCall, readableIn, syncIn, uncounted } from "./crossing.mjs";
|
|
2
|
+
import { JobGate } from "@ref0/infra";
|
|
3
|
+
import * as Effect from "effect/Effect";
|
|
4
|
+
import * as Option from "effect/Option";
|
|
5
|
+
import * as Cause from "effect/Cause";
|
|
6
|
+
import * as Exit from "effect/Exit";
|
|
7
|
+
import * as Stream from "effect/Stream";
|
|
8
|
+
import * as EffectDuration from "effect/Duration";
|
|
9
|
+
import * as Scheduler from "effect/Scheduler";
|
|
10
|
+
import * as Data from "effect/Data";
|
|
11
|
+
// src/store/promises.ts
|
|
12
|
+
/** The door of a bridge with no server to close, as a client's own store: it always runs. */
|
|
13
|
+
const openDoor = {
|
|
14
|
+
refusal: () => void 0,
|
|
15
|
+
closing: new AbortController().signal
|
|
16
|
+
};
|
|
17
|
+
/** `door`'s refusal now, thrown: before a run, and after one, so a run the door outlived ends. */
|
|
18
|
+
const askDoor = (door) => {
|
|
19
|
+
const refused = door.refusal();
|
|
20
|
+
if (refused !== void 0) throw refused;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* `readable`, which errors with `closing`'s reason once it aborts, and cancels `readable` then. It
|
|
24
|
+
* stops the stream from in front of it, not inside it. `readableIn` runs the stream at once, so a
|
|
25
|
+
* cancel, even one before the first pull, reaches the bucket's stream the call opened.
|
|
26
|
+
* `Stream.interruptWhen` pulls on a forked fiber, and a cancel before that fiber starts left the
|
|
27
|
+
* bucket's stream open, cancelled by nothing.
|
|
28
|
+
*/
|
|
29
|
+
const untilClosing = (readable, closing) => {
|
|
30
|
+
const reader = readable.getReader();
|
|
31
|
+
let onClose = () => {};
|
|
32
|
+
const stop = () => closing.removeEventListener("abort", onClose);
|
|
33
|
+
reader.closed.then(stop, stop);
|
|
34
|
+
return new ReadableStream({
|
|
35
|
+
start: (controller) => {
|
|
36
|
+
onClose = () => {
|
|
37
|
+
controller.error(closing.reason);
|
|
38
|
+
reader.cancel(closing.reason).catch(() => void 0);
|
|
39
|
+
};
|
|
40
|
+
if (closing.aborted) return onClose();
|
|
41
|
+
closing.addEventListener("abort", onClose, { once: true });
|
|
42
|
+
},
|
|
43
|
+
pull: async (controller) => {
|
|
44
|
+
const next = await reader.read();
|
|
45
|
+
if (closing.aborted) return controller.error(closing.reason);
|
|
46
|
+
if (next.done) return controller.close();
|
|
47
|
+
controller.enqueue(next.value);
|
|
48
|
+
},
|
|
49
|
+
cancel: (reason) => reader.cancel(reason)
|
|
50
|
+
}, { highWaterMark: 0 });
|
|
51
|
+
};
|
|
52
|
+
/** Why a bridge's run takes no call scope: the door that called it counted its call. */
|
|
53
|
+
const bridged = uncounted("a bridge's run: the door that called it counted the call");
|
|
54
|
+
/**
|
|
55
|
+
* How the bridge runs on `context`: as a promise, at once, as an exit, and a stream as Web's. Each
|
|
56
|
+
* asks `door` first. The server's closing stops what's still running, and it ends as the door
|
|
57
|
+
* refuses: a promise rejects and a stream errors, never ending early as if it had finished.
|
|
58
|
+
*/
|
|
59
|
+
const runnerOf = (context, door) => {
|
|
60
|
+
const provided = (effect) => Effect.provideContext(effect, context);
|
|
61
|
+
const signalOf = (signal) => signal === void 0 ? door.closing : AbortSignal.any([signal, door.closing]);
|
|
62
|
+
const runExit = async (effect, signal) => {
|
|
63
|
+
askDoor(door);
|
|
64
|
+
const exit = await exitIn(provided(effect), bridged, signalOf(signal));
|
|
65
|
+
askDoor(door);
|
|
66
|
+
return exit;
|
|
67
|
+
};
|
|
68
|
+
return {
|
|
69
|
+
run: async (effect, signal) => {
|
|
70
|
+
const exit = await runExit(effect, signal);
|
|
71
|
+
if (Exit.isFailure(exit)) throw Cause.squash(exit.cause);
|
|
72
|
+
return exit.value;
|
|
73
|
+
},
|
|
74
|
+
runNow: (effect) => {
|
|
75
|
+
askDoor(door);
|
|
76
|
+
return syncIn(provided(effect), bridged);
|
|
77
|
+
},
|
|
78
|
+
runExit,
|
|
79
|
+
readable: (stream) => {
|
|
80
|
+
const refused = door.refusal();
|
|
81
|
+
if (refused !== void 0) return readableIn(Stream.die(refused), context);
|
|
82
|
+
return untilClosing(readableIn(stream, context), door.closing);
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
/** The store over `Records`, run on `context` through `door`. */
|
|
87
|
+
const promisesStore = (records, context, door) => {
|
|
88
|
+
const { jobs } = records;
|
|
89
|
+
const { run, readable } = runnerOf(context, door);
|
|
90
|
+
return {
|
|
91
|
+
read: (scope, reads, counts) => run(records.read(scope, reads, counts)),
|
|
92
|
+
commit: (scope, change) => run(records.commit(scope, change)),
|
|
93
|
+
add: (scope, addition) => run(records.add(scope, addition)),
|
|
94
|
+
watch: (scope, watch) => readable(Stream.suspend(() => records.watch(scope, watch))),
|
|
95
|
+
claim: (scope, request) => run(jobs.claim(scope, request)),
|
|
96
|
+
settle: (claim, outcome) => run(jobs.settle(claim, outcome)),
|
|
97
|
+
progress: (scope, write) => run(jobs.progress(scope, write)),
|
|
98
|
+
count: (scope) => run(jobs.count(scope)),
|
|
99
|
+
list: (scope, request) => run(jobs.list(scope, request)),
|
|
100
|
+
retry: (scope, job, input) => run(jobs.retry(scope, job, input)),
|
|
101
|
+
discard: (scope, job) => run(jobs.discard(scope, job))
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
/** How long a job's try a closed server holds off waits before the host's queue claims it again. */
|
|
105
|
+
const closedRetry = 6e4;
|
|
106
|
+
/**
|
|
107
|
+
* A job's store through `door`: each call asks it first, a read of the server's state with no
|
|
108
|
+
* await, so a try the closing outlived sends nothing more once one write lands.
|
|
109
|
+
*/
|
|
110
|
+
const doorStore = (store, door) => {
|
|
111
|
+
const wrapped = {
|
|
112
|
+
wake: {
|
|
113
|
+
set: (scope, at) => (askDoor(door), store.wake.set(scope, at)),
|
|
114
|
+
listen: (listener) => store.wake.listen(listener)
|
|
115
|
+
},
|
|
116
|
+
read: (scope, reads, counts) => (askDoor(door), store.read(scope, reads, counts)),
|
|
117
|
+
watch: (scope, watch) => (askDoor(door), store.watch(scope, watch)),
|
|
118
|
+
commit: (scope, change) => (askDoor(door), store.commit(scope, change)),
|
|
119
|
+
add: (scope, addition) => (askDoor(door), store.add(scope, addition)),
|
|
120
|
+
claim: (scope, request) => (askDoor(door), store.claim(scope, request)),
|
|
121
|
+
settle: (claim, outcome) => (askDoor(door), store.settle(claim, outcome)),
|
|
122
|
+
progress: (scope, write) => (askDoor(door), store.progress(scope, write)),
|
|
123
|
+
count: (scope) => (askDoor(door), store.count(scope)),
|
|
124
|
+
list: (scope, request) => (askDoor(door), store.list(scope, request)),
|
|
125
|
+
retry: (scope, job, input) => (askDoor(door), store.retry(scope, job, input)),
|
|
126
|
+
discard: (scope, job) => (askDoor(door), store.discard(scope, job))
|
|
127
|
+
};
|
|
128
|
+
const due = store.due?.bind(store);
|
|
129
|
+
if (due === void 0) return wrapped;
|
|
130
|
+
return {
|
|
131
|
+
...wrapped,
|
|
132
|
+
due: (request) => (askDoor(door), due(request))
|
|
133
|
+
};
|
|
134
|
+
};
|
|
135
|
+
/**
|
|
136
|
+
* The gate around each try of the jobs the server adds: once closed, or once its build failed, a
|
|
137
|
+
* try waits `closedRetry` and spends no attempt, and its `onFailure` doesn't run; each store call asks the
|
|
138
|
+
* door. Both read a flag, so a try's calls take no more turns than they did.
|
|
139
|
+
*/
|
|
140
|
+
const gateOf = (door, now) => ({
|
|
141
|
+
later: () => door.refusal() === void 0 ? void 0 : now() + closedRetry,
|
|
142
|
+
store: (store) => doorStore(store, door)
|
|
143
|
+
});
|
|
144
|
+
/**
|
|
145
|
+
* The queue over `JobQueue`, run on `context`: `register` throws a refused definition, as the
|
|
146
|
+
* promise queue did, and adds each through the server's door.
|
|
147
|
+
*/
|
|
148
|
+
const promisesQueue = (queue, context, door) => {
|
|
149
|
+
const { run, runNow } = runnerOf(context, door);
|
|
150
|
+
const now = () => syncIn(Effect.provideContext(Effect.clockWith((clock) => Effect.sync(() => clock.currentTimeMillisUnsafe())), context), noCall);
|
|
151
|
+
const gate = gateOf(door, now);
|
|
152
|
+
return {
|
|
153
|
+
register: (...definitions) => runNow(queue.addJobs(...definitions).pipe(Effect.provideService(JobGate, gate))),
|
|
154
|
+
run: (scope) => run(queue.run(scope)),
|
|
155
|
+
count: (scope) => run(queue.count(scope)),
|
|
156
|
+
list: (scope, request) => run(queue.list(scope, request)),
|
|
157
|
+
retry: (scope, job) => run(queue.retry(scope, job)),
|
|
158
|
+
discard: (scope, job) => run(queue.discard(scope, job))
|
|
159
|
+
};
|
|
160
|
+
};
|
|
161
|
+
/** A put's body that failed as it was read, carrying its own failure. */
|
|
162
|
+
var BodyFailure = class extends Data.TaggedError("BodyFailure") {};
|
|
163
|
+
const bodyOf = (body) => Stream.fromReadableStream({
|
|
164
|
+
evaluate: () => body,
|
|
165
|
+
onError: (cause) => new BodyFailure({ cause })
|
|
166
|
+
});
|
|
167
|
+
/**
|
|
168
|
+
* The bucket over `Bucket`, with `BucketLinks`' and `BucketUploads`' methods when the runtime has
|
|
169
|
+
* them, run on `context`: git tells a signing bucket by its methods.
|
|
170
|
+
*/
|
|
171
|
+
const promisesBucket = (bucket, links, uploads, context, door) => {
|
|
172
|
+
const { run, runExit, readable } = runnerOf(context, door);
|
|
173
|
+
const dropped = (body) => {
|
|
174
|
+
readableIn(body, context).cancel().catch(() => void 0);
|
|
175
|
+
};
|
|
176
|
+
const face = {
|
|
177
|
+
multipart: bucket.multipart,
|
|
178
|
+
put: (key, body, options) => run(Effect.catchTag(bucket.put(key, bodyOf(body), options), "BodyFailure", (failure) => Effect.die(failure.cause)), options?.signal),
|
|
179
|
+
/**
|
|
180
|
+
* `noted` is the body's single owner from infra's answer until `readable` takes it, in the tick
|
|
181
|
+
* the door last lets the read through. Every other way out, a failure, an interrupt or the door's
|
|
182
|
+
* refusal, cancels it, once.
|
|
183
|
+
*/
|
|
184
|
+
read: async (key, range, options) => {
|
|
185
|
+
const noted = { body: void 0 };
|
|
186
|
+
/**
|
|
187
|
+
* Nothing may yield between infra's answer and `noted`, its single owner, or an interrupt
|
|
188
|
+
* landing at that yield drops the body. So `PreventSchedulerYield` covers the host's whole
|
|
189
|
+
* read, from the bucket call's start to `noted`, and never the body's reading, which
|
|
190
|
+
* `readable` runs on `context`. A host `Bucket` Layer running long synchronous Effect work
|
|
191
|
+
* inside `read` delays other fibers until it returns; a pending promise still suspends. I0-1c's
|
|
192
|
+
* lazy read, which opens the body only when run, deletes this.
|
|
193
|
+
*/
|
|
194
|
+
const noting = Effect.provideService(Effect.uninterruptibleMask((restore) => Effect.tap(restore(bucket.read(key, range)), (found) => Effect.sync(() => {
|
|
195
|
+
noted.body = Option.getOrUndefined(found);
|
|
196
|
+
}))), Scheduler.PreventSchedulerYield, true);
|
|
197
|
+
try {
|
|
198
|
+
const exit = await runExit(noting, options?.signal);
|
|
199
|
+
if (Exit.isFailure(exit)) throw Cause.squash(exit.cause);
|
|
200
|
+
askDoor(door);
|
|
201
|
+
const body = noted.body;
|
|
202
|
+
noted.body = void 0;
|
|
203
|
+
return body === void 0 ? void 0 : readable(body);
|
|
204
|
+
} finally {
|
|
205
|
+
if (noted.body !== void 0) dropped(noted.body);
|
|
206
|
+
}
|
|
207
|
+
},
|
|
208
|
+
delete: (key, options) => run(bucket.remove(key), options?.signal),
|
|
209
|
+
list: (prefix, page, options) => run(bucket.list(prefix, page), options?.signal)
|
|
210
|
+
};
|
|
211
|
+
const signed = Option.match(links, {
|
|
212
|
+
onNone: () => ({}),
|
|
213
|
+
onSome: (links) => ({
|
|
214
|
+
url: (key, options) => run(links.url(key, options), options.signal),
|
|
215
|
+
putUrl: (key, options) => run(links.putUrl(key, options), options.signal),
|
|
216
|
+
head: (key, options) => run(Effect.map(links.head(key), Option.getOrUndefined), options?.signal)
|
|
217
|
+
})
|
|
218
|
+
});
|
|
219
|
+
const parted = Option.match(uploads, {
|
|
220
|
+
onNone: () => ({}),
|
|
221
|
+
onSome: (uploads) => ({
|
|
222
|
+
maxParts: uploads.maxParts,
|
|
223
|
+
beginUpload: (key, options) => run(uploads.beginUpload(key), options?.signal),
|
|
224
|
+
uploadUrl: (key, options) => run(uploads.uploadUrl(key, options), options.signal),
|
|
225
|
+
listParts: (key, upload, options) => run(uploads.listParts(key, upload), options?.signal),
|
|
226
|
+
completeUpload: (key, input, options) => run(uploads.completeUpload(key, input), options?.signal),
|
|
227
|
+
abortUpload: (key, upload, options) => run(uploads.abortUpload(key, upload), options?.signal)
|
|
228
|
+
})
|
|
229
|
+
});
|
|
230
|
+
return {
|
|
231
|
+
...face,
|
|
232
|
+
...signed,
|
|
233
|
+
...parted
|
|
234
|
+
};
|
|
235
|
+
};
|
|
236
|
+
/** The longest one timer waits: a later `until` sleeps in turns. */
|
|
237
|
+
const longestTimer = 2 ** 31 - 1;
|
|
238
|
+
/**
|
|
239
|
+
* The runtime's `Clock` as a promise, run on `context`, counted down by what each sleep asked, as a
|
|
240
|
+
* test's moves. It mirrors infra's `promiseClockOf`, which git can't import: infra's root names no
|
|
241
|
+
* promise face. Both go with the bridges, this one with SV's last step.
|
|
242
|
+
*/
|
|
243
|
+
const promisesClock = (clock, context, door) => {
|
|
244
|
+
const { runExit } = runnerOf(context, door);
|
|
245
|
+
const face = {
|
|
246
|
+
now: () => clock.currentTimeMillisUnsafe(),
|
|
247
|
+
sleep: async (until, signal) => {
|
|
248
|
+
askDoor(door);
|
|
249
|
+
for (let left = until - face.now(); left > 0 && signal?.aborted !== true;) {
|
|
250
|
+
const slept = Math.min(left, longestTimer);
|
|
251
|
+
await runExit(clock.sleep(EffectDuration.millis(slept)), signal);
|
|
252
|
+
left -= slept;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
return face;
|
|
257
|
+
};
|
|
258
|
+
export { openDoor, promisesBucket, promisesClock, promisesQueue, promisesStore };
|
|
@@ -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 };
|