@ref0/git 0.0.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/LICENSE +202 -0
- package/dist/access/private-refs.d.mts +27 -0
- package/dist/access/private-refs.mjs +173 -0
- package/dist/access.d.mts +2 -0
- package/dist/access.mjs +1 -0
- package/dist/auth/access-jwt.d.mts +21 -0
- package/dist/auth/access-jwt.mjs +102 -0
- package/dist/auth/acting.mjs +15 -0
- package/dist/auth/authorize.d.mts +5 -0
- package/dist/auth/authorize.mjs +292 -0
- package/dist/auth/credentials.mjs +57 -0
- package/dist/auth/fences.d.mts +5 -0
- package/dist/auth/fences.mjs +65 -0
- package/dist/auth/grants.mjs +61 -0
- package/dist/auth/helpers.d.mts +17 -0
- package/dist/auth/helpers.mjs +25 -0
- package/dist/auth/host-function.d.mts +4 -0
- package/dist/auth/host-function.mjs +69 -0
- package/dist/auth/identify.d.mts +6 -0
- package/dist/auth/identify.mjs +97 -0
- package/dist/auth/token-rows.mjs +100 -0
- package/dist/auth/token-text.mjs +66 -0
- package/dist/auth/tokens.d.mts +10 -0
- package/dist/auth/tokens.mjs +347 -0
- package/dist/auth.d.mts +7 -0
- package/dist/auth.mjs +6 -0
- package/dist/client/answer.mjs +141 -0
- package/dist/client/client.d.mts +23 -0
- package/dist/client/client.mjs +51 -0
- package/dist/client/git-http.mjs +201 -0
- package/dist/client/helper-node.mjs +19 -0
- package/dist/client/local.mjs +160 -0
- package/dist/client/negotiate.mjs +170 -0
- package/dist/client/push-upload.mjs +53 -0
- package/dist/client/remote-helper.mjs +129 -0
- package/dist/client/remote.mjs +398 -0
- package/dist/client/run-remote-helper.d.mts +35 -0
- package/dist/client/run-remote-helper.mjs +259 -0
- package/dist/client/scrub.d.mts +18 -0
- package/dist/client/scrub.mjs +38 -0
- package/dist/client/transport.d.mts +2 -0
- package/dist/client/transport.mjs +211 -0
- package/dist/contracts/access.d.mts +87 -0
- package/dist/contracts/actors.d.mts +144 -0
- package/dist/contracts/blobs.d.mts +38 -0
- package/dist/contracts/calls-spent.d.mts +11 -0
- package/dist/contracts/calls-spent.mjs +150 -0
- package/dist/contracts/client.d.mts +90 -0
- package/dist/contracts/commits.d.mts +126 -0
- package/dist/contracts/engine.d.mts +134 -0
- package/dist/contracts/events.d.mts +276 -0
- package/dist/contracts/files.d.mts +75 -0
- package/dist/contracts/forks.d.mts +78 -0
- package/dist/contracts/grants.d.mts +60 -0
- package/dist/contracts/handlers.d.mts +10 -0
- package/dist/contracts/ids.d.mts +15 -0
- package/dist/contracts/ids.mjs +15 -0
- package/dist/contracts/lfs.d.mts +27 -0
- package/dist/contracts/merges.d.mts +33 -0
- package/dist/contracts/objects.d.mts +645 -0
- package/dist/contracts/objects.mjs +54 -0
- package/dist/contracts/operations.d.mts +133 -0
- package/dist/contracts/promises.d.mts +63 -0
- package/dist/contracts/push-uploads.d.mts +44 -0
- package/dist/contracts/queue.d.mts +401 -0
- package/dist/contracts/refs.d.mts +95 -0
- package/dist/contracts/remote.d.mts +50 -0
- package/dist/contracts/repos.d.mts +153 -0
- package/dist/contracts/result.d.mts +126 -0
- package/dist/contracts/result.mjs +34 -0
- package/dist/contracts/rules.d.mts +159 -0
- package/dist/contracts/server.d.mts +245 -0
- package/dist/contracts/services.d.mts +36 -0
- package/dist/contracts/services.mjs +13 -0
- package/dist/contracts/signin.d.mts +126 -0
- package/dist/contracts/store.d.mts +41 -0
- package/dist/contracts/sync.d.mts +210 -0
- package/dist/contracts/sync.mjs +8 -0
- package/dist/contracts/tags.d.mts +50 -0
- package/dist/contracts/tags.mjs +6 -0
- package/dist/contracts/tokens.d.mts +87 -0
- package/dist/contracts/tokens.mjs +15 -0
- package/dist/contracts/topics.d.mts +174 -0
- package/dist/contracts/trees.d.mts +84 -0
- package/dist/contracts/work.d.mts +31 -0
- package/dist/core/access.d.mts +22 -0
- package/dist/core/access.mjs +262 -0
- package/dist/core/ancestry.mjs +235 -0
- package/dist/core/clock.mjs +18 -0
- package/dist/core/events/deliver.mjs +468 -0
- package/dist/core/events/stream.d.mts +19 -0
- package/dist/core/events/stream.mjs +290 -0
- package/dist/core/forks.mjs +1027 -0
- package/dist/core/hooks/post-receive.mjs +204 -0
- package/dist/core/hooks/pre-receive.d.mts +5 -0
- package/dist/core/hooks/pre-receive.mjs +34 -0
- package/dist/core/index-job.mjs +198 -0
- package/dist/core/names.mjs +30 -0
- package/dist/core/objects/blobs.mjs +60 -0
- package/dist/core/objects/commit-writes.mjs +185 -0
- package/dist/core/objects/commits.mjs +172 -0
- package/dist/core/objects/files.mjs +211 -0
- package/dist/core/objects/lines.mjs +42 -0
- package/dist/core/objects/merges.mjs +83 -0
- package/dist/core/objects/peel.mjs +166 -0
- package/dist/core/objects/reading.mjs +284 -0
- package/dist/core/objects/tags.mjs +96 -0
- package/dist/core/objects/tree-edits.mjs +266 -0
- package/dist/core/objects/trees.mjs +229 -0
- package/dist/core/objects/writing.mjs +266 -0
- package/dist/core/own-writes.mjs +94 -0
- package/dist/core/promise.mjs +46 -0
- package/dist/core/publish.mjs +142 -0
- package/dist/core/push-decide.mjs +206 -0
- package/dist/core/push.mjs +1069 -0
- package/dist/core/receipts.d.mts +7 -0
- package/dist/core/receipts.mjs +234 -0
- package/dist/core/ref-conflicts.mjs +27 -0
- package/dist/core/refs.mjs +359 -0
- package/dist/core/repack.mjs +521 -0
- package/dist/core/repos.mjs +752 -0
- package/dist/core/rules/changes.mjs +57 -0
- package/dist/core/rules/check.mjs +101 -0
- package/dist/core/rules/commit-changes.mjs +216 -0
- package/dist/core/rules/context.d.mts +9 -0
- package/dist/core/rules/context.mjs +120 -0
- package/dist/core/rules/define.d.mts +5 -0
- package/dist/core/rules/define.mjs +13 -0
- package/dist/core/rules/facts.mjs +13 -0
- package/dist/core/rules/fetch.d.mts +5 -0
- package/dist/core/rules/fetch.mjs +59 -0
- package/dist/core/rules/file-globs.mjs +55 -0
- package/dist/core/rules/files.mjs +142 -0
- package/dist/core/rules/patterns.mjs +23 -0
- package/dist/core/rules/protect.d.mts +9 -0
- package/dist/core/rules/protect.mjs +116 -0
- package/dist/core/seam.d.mts +24 -0
- package/dist/core/seam.mjs +41 -0
- package/dist/core/sight.mjs +99 -0
- package/dist/core/tokens.mjs +95 -0
- package/dist/core/view.d.mts +9 -0
- package/dist/core/view.mjs +221 -0
- package/dist/core/work.mjs +92 -0
- package/dist/effect.d.mts +20 -0
- package/dist/effect.mjs +18 -0
- package/dist/engine/allotted-xdiff.d.mts +4 -0
- package/dist/engine/allotted-xdiff.mjs +80 -0
- package/dist/engine/attribute-patterns.mjs +163 -0
- package/dist/engine/attributes.mjs +226 -0
- package/dist/engine/combined.mjs +653 -0
- package/dist/engine/commits.mjs +90 -0
- package/dist/engine/content.d.mts +4 -0
- package/dist/engine/content.mjs +221 -0
- package/dist/engine/diff.mjs +49 -0
- package/dist/engine/engine.d.mts +25 -0
- package/dist/engine/engine.mjs +49 -0
- package/dist/engine/failures.d.mts +4 -0
- package/dist/engine/failures.mjs +23 -0
- package/dist/engine/line-count.mjs +23 -0
- package/dist/engine/merge-base-walk.d.mts +2 -0
- package/dist/engine/merge-base-walk.mjs +265 -0
- package/dist/engine/merge-bases.mjs +27 -0
- package/dist/engine/merge-renames.mjs +165 -0
- package/dist/engine/merge.mjs +1125 -0
- package/dist/engine/parts.d.mts +8 -0
- package/dist/engine/parts.mjs +9 -0
- package/dist/engine/reads.d.mts +5 -0
- package/dist/engine/reads.mjs +105 -0
- package/dist/engine/walk.mjs +328 -0
- package/dist/engine/xdiff/NOTICE.md +63 -0
- package/dist/engine/xdiff/compiled.d.mts +7 -0
- package/dist/engine/xdiff/compiled.mjs +9 -0
- package/dist/engine/xdiff/embedded.mjs +4 -0
- package/dist/engine/xdiff/node.d.mts +7 -0
- package/dist/engine/xdiff/node.mjs +10 -0
- package/dist/engine/xdiff/upstream/LGPL-2.1 +511 -0
- package/dist/engine/xdiff/xdiff.wasm +0 -0
- package/dist/engine/xdiff.d.mts +34 -0
- package/dist/engine/xdiff.mjs +380 -0
- package/dist/engine.d.mts +3 -0
- package/dist/engine.mjs +3 -0
- package/dist/extend.d.mts +3 -0
- package/dist/extend.mjs +1 -0
- package/dist/http/answers.mjs +74 -0
- package/dist/http/bodies.mjs +143 -0
- package/dist/http/core-parts.mjs +252 -0
- package/dist/http/fetch-depth.mjs +26 -0
- package/dist/http/handler.mjs +94 -0
- package/dist/http/node.d.mts +70 -0
- package/dist/http/node.mjs +178 -0
- package/dist/http/paths.d.mts +9 -0
- package/dist/http/paths.mjs +118 -0
- package/dist/http/push-uploads.mjs +286 -0
- package/dist/http/receive-pack.mjs +235 -0
- package/dist/http/upload-pack.mjs +229 -0
- package/dist/index.d.mts +46 -0
- package/dist/index.mjs +16 -0
- package/dist/lfs/calls.mjs +16 -0
- package/dist/lfs/locks.mjs +161 -0
- package/dist/lfs/objects.mjs +370 -0
- package/dist/lfs/pointers.mjs +141 -0
- package/dist/lfs/repo.mjs +42 -0
- package/dist/lfs/rows.mjs +108 -0
- package/dist/lfs/service.mjs +34 -0
- package/dist/lfs/upkeep.mjs +162 -0
- package/dist/lfs/wire.mjs +102 -0
- package/dist/node.d.mts +3 -0
- package/dist/node.mjs +3 -0
- package/dist/protocol/bytes/buffers.d.mts +38 -0
- package/dist/protocol/bytes/buffers.mjs +62 -0
- package/dist/protocol/bytes/crc32.d.mts +4 -0
- package/dist/protocol/bytes/crc32.mjs +14 -0
- package/dist/protocol/bytes/deflate.d.mts +78 -0
- package/dist/protocol/bytes/deflate.mjs +175 -0
- package/dist/protocol/bytes/errors.d.mts +20 -0
- package/dist/protocol/bytes/errors.mjs +19 -0
- package/dist/protocol/bytes/hex.mjs +16 -0
- package/dist/protocol/bytes/hmac-sha256.mjs +91 -0
- package/dist/protocol/bytes/inflate.d.mts +40 -0
- package/dist/protocol/bytes/inflate.mjs +109 -0
- package/dist/protocol/bytes/joined.d.mts +2 -0
- package/dist/protocol/bytes/joined.mjs +25 -0
- package/dist/protocol/bytes/sha1-hasher.d.mts +20 -0
- package/dist/protocol/bytes/sha1-hasher.mjs +72 -0
- package/dist/protocol/bytes/sha1.d.mts +35 -0
- package/dist/protocol/bytes/sha1.mjs +409 -0
- package/dist/protocol/bytes/sha256.mjs +156 -0
- package/dist/protocol/bytes/streams.mjs +11 -0
- package/dist/protocol/bytes/text.mjs +19 -0
- package/dist/protocol/diff/diff-raw.d.mts +29 -0
- package/dist/protocol/diff/diff-raw.mjs +73 -0
- package/dist/protocol/diff/patch.mjs +92 -0
- package/dist/protocol/diff/paths.mjs +67 -0
- package/dist/protocol/diff/read.d.mts +62 -0
- package/dist/protocol/diff/read.mjs +342 -0
- package/dist/protocol/diff/rename-similarity.mjs +428 -0
- package/dist/protocol/diff/text.mjs +12 -0
- package/dist/protocol/diff/tree-diff.d.mts +41 -0
- package/dist/protocol/diff/tree-diff.mjs +607 -0
- package/dist/protocol/framing/band.d.mts +10 -0
- package/dist/protocol/framing/band.mjs +16 -0
- package/dist/protocol/framing/pkt-line.d.mts +48 -0
- package/dist/protocol/framing/pkt-line.mjs +92 -0
- package/dist/protocol/objects/checked-blobs.mjs +127 -0
- package/dist/protocol/objects/commit.d.mts +25 -0
- package/dist/protocol/objects/commit.mjs +138 -0
- package/dist/protocol/objects/fsck-gitmodules.mjs +296 -0
- package/dist/protocol/objects/fsck-names.mjs +189 -0
- package/dist/protocol/objects/fsck.mjs +297 -0
- package/dist/protocol/objects/headers.mjs +109 -0
- package/dist/protocol/objects/held.mjs +56 -0
- package/dist/protocol/objects/iconv.mjs +145 -0
- package/dist/protocol/objects/ident.mjs +111 -0
- package/dist/protocol/objects/lfs-pointer.d.mts +8 -0
- package/dist/protocol/objects/lfs-pointer.mjs +63 -0
- package/dist/protocol/objects/links-raw.mjs +89 -0
- package/dist/protocol/objects/object-rules.mjs +75 -0
- package/dist/protocol/objects/object.d.mts +16 -0
- package/dist/protocol/objects/object.mjs +29 -0
- package/dist/protocol/objects/tag.d.mts +21 -0
- package/dist/protocol/objects/tag.mjs +96 -0
- package/dist/protocol/objects/tree.d.mts +43 -0
- package/dist/protocol/objects/tree.mjs +162 -0
- package/dist/protocol/objects/utf8-verify.mjs +71 -0
- package/dist/protocol/packs/delta.d.mts +57 -0
- package/dist/protocol/packs/delta.mjs +229 -0
- package/dist/protocol/packs/graph.mjs +78 -0
- package/dist/protocol/packs/idx.d.mts +54 -0
- package/dist/protocol/packs/idx.mjs +274 -0
- package/dist/protocol/packs/indexer.d.mts +167 -0
- package/dist/protocol/packs/indexer.mjs +507 -0
- package/dist/protocol/packs/parts.d.mts +40 -0
- package/dist/protocol/packs/parts.mjs +89 -0
- package/dist/protocol/packs/pos.mjs +51 -0
- package/dist/protocol/packs/reader.d.mts +180 -0
- package/dist/protocol/packs/reader.mjs +414 -0
- package/dist/protocol/packs/rev.d.mts +32 -0
- package/dist/protocol/packs/rev.mjs +99 -0
- package/dist/protocol/packs/step.d.mts +10 -0
- package/dist/protocol/packs/step.mjs +12 -0
- package/dist/protocol/packs/write-error.d.mts +12 -0
- package/dist/protocol/packs/write-error.mjs +27 -0
- package/dist/protocol/packs/writer.d.mts +157 -0
- package/dist/protocol/packs/writer.mjs +353 -0
- package/dist/protocol/wire/advertisement.d.mts +72 -0
- package/dist/protocol/wire/advertisement.mjs +161 -0
- package/dist/protocol/wire/fetch.d.mts +155 -0
- package/dist/protocol/wire/fetch.mjs +458 -0
- package/dist/protocol/wire/lines.mjs +107 -0
- package/dist/protocol/wire/push-uploads.mjs +43 -0
- package/dist/protocol/wire/receive-pack.d.mts +71 -0
- package/dist/protocol/wire/receive-pack.mjs +157 -0
- package/dist/protocol/wire/report-status.d.mts +47 -0
- package/dist/protocol/wire/report-status.mjs +119 -0
- package/dist/protocol/wire/v2.d.mts +90 -0
- package/dist/protocol/wire/v2.mjs +185 -0
- package/dist/protocol.d.mts +31 -0
- package/dist/protocol.mjs +31 -0
- package/dist/queue/advance.mjs +1036 -0
- package/dist/queue/callers.mjs +134 -0
- package/dist/queue/calls.mjs +1154 -0
- package/dist/queue/commit.mjs +85 -0
- package/dist/queue/host.d.mts +15 -0
- package/dist/queue/host.mjs +88 -0
- package/dist/queue/ids.d.mts +5 -0
- package/dist/queue/ids.mjs +21 -0
- package/dist/queue/lanes.mjs +86 -0
- package/dist/queue/limits.mjs +99 -0
- package/dist/queue/pages.mjs +76 -0
- package/dist/queue/push-option.mjs +62 -0
- package/dist/queue/rows.mjs +206 -0
- package/dist/queue/schedule.mjs +132 -0
- package/dist/queue/search.mjs +315 -0
- package/dist/queue/state.mjs +325 -0
- package/dist/queue/steps.mjs +317 -0
- package/dist/remote-helper.d.mts +3 -0
- package/dist/remote-helper.mjs +3 -0
- package/dist/rest/api.d.mts +23 -0
- package/dist/rest/api.mjs +27 -0
- package/dist/rest/blobs.d.mts +58 -0
- package/dist/rest/blobs.mjs +41 -0
- package/dist/rest/caller.d.mts +102 -0
- package/dist/rest/caller.mjs +18 -0
- package/dist/rest/client.d.mts +18 -0
- package/dist/rest/client.mjs +587 -0
- package/dist/rest/commits.d.mts +435 -0
- package/dist/rest/commits.mjs +140 -0
- package/dist/rest/errors.d.mts +44 -0
- package/dist/rest/errors.mjs +186 -0
- package/dist/rest/events.d.mts +38 -0
- package/dist/rest/events.mjs +74 -0
- package/dist/rest/files.d.mts +179 -0
- package/dist/rest/files.mjs +92 -0
- package/dist/rest/forks.d.mts +205 -0
- package/dist/rest/forks.mjs +51 -0
- package/dist/rest/handler.d.mts +17 -0
- package/dist/rest/handler.mjs +106 -0
- package/dist/rest/handlers.d.mts +8 -0
- package/dist/rest/handlers.mjs +592 -0
- package/dist/rest/listen.d.mts +24 -0
- package/dist/rest/listen.mjs +142 -0
- package/dist/rest/me.d.mts +55 -0
- package/dist/rest/me.mjs +21 -0
- package/dist/rest/merges.d.mts +90 -0
- package/dist/rest/merges.mjs +39 -0
- package/dist/rest/paths.mjs +86 -0
- package/dist/rest/queue.d.mts +486 -0
- package/dist/rest/queue.mjs +228 -0
- package/dist/rest/refs.d.mts +232 -0
- package/dist/rest/refs.mjs +86 -0
- package/dist/rest/repos.d.mts +223 -0
- package/dist/rest/repos.mjs +93 -0
- package/dist/rest/tags.d.mts +153 -0
- package/dist/rest/tags.mjs +72 -0
- package/dist/rest/tokens.d.mts +297 -0
- package/dist/rest/tokens.mjs +88 -0
- package/dist/rest/topics.d.mts +257 -0
- package/dist/rest/topics.mjs +116 -0
- package/dist/rest/trees.d.mts +158 -0
- package/dist/rest/trees.mjs +118 -0
- package/dist/rest/wire.mjs +57 -0
- package/dist/rest/work.d.mts +107 -0
- package/dist/rest/work.mjs +77 -0
- package/dist/rest.d.mts +8 -0
- package/dist/rest.mjs +5 -0
- package/dist/server/extension.d.mts +14 -0
- package/dist/server/extension.mjs +85 -0
- package/dist/server/routes.d.mts +25 -0
- package/dist/server/routes.mjs +67 -0
- package/dist/server/server.d.mts +2 -0
- package/dist/server/server.mjs +439 -0
- package/dist/signin/codes.mjs +47 -0
- package/dist/signin/context.d.mts +9 -0
- package/dist/signin/context.mjs +121 -0
- package/dist/signin/device.mjs +122 -0
- package/dist/signin/forms.mjs +157 -0
- package/dist/signin/grants.d.mts +5 -0
- package/dist/signin/grants.mjs +257 -0
- package/dist/signin/route.mjs +68 -0
- package/dist/signin/web.mjs +125 -0
- package/dist/signin/wire.d.mts +42 -0
- package/dist/signin/wire.mjs +43 -0
- package/dist/storage/allotted.mjs +102 -0
- package/dist/storage/budget.mjs +96 -0
- package/dist/storage/calls.d.mts +18 -0
- package/dist/storage/calls.mjs +273 -0
- package/dist/storage/clean-up.mjs +124 -0
- package/dist/storage/distinct-ids.mjs +39 -0
- package/dist/storage/ewah.mjs +97 -0
- package/dist/storage/fetch.d.mts +13 -0
- package/dist/storage/fetch.mjs +792 -0
- package/dist/storage/fsck.mjs +77 -0
- package/dist/storage/held-memo.mjs +188 -0
- package/dist/storage/index-bitmaps.d.mts +4 -0
- package/dist/storage/index-bitmaps.mjs +654 -0
- package/dist/storage/index-build.d.mts +15 -0
- package/dist/storage/index-build.mjs +1433 -0
- package/dist/storage/index-fetch.d.mts +9 -0
- package/dist/storage/index-fetch.mjs +756 -0
- package/dist/storage/index-files.mjs +232 -0
- package/dist/storage/index-graph.d.mts +3 -0
- package/dist/storage/index-graph.mjs +1049 -0
- package/dist/storage/index-layers.mjs +317 -0
- package/dist/storage/index-reach.mjs +216 -0
- package/dist/storage/index-remap.d.mts +8 -0
- package/dist/storage/index-remap.mjs +592 -0
- package/dist/storage/layout.mjs +69 -0
- package/dist/storage/lfs-pointers.d.mts +21 -0
- package/dist/storage/lfs-pointers.mjs +175 -0
- package/dist/storage/link-join.mjs +106 -0
- package/dist/storage/links.mjs +105 -0
- package/dist/storage/loose.d.mts +15 -0
- package/dist/storage/loose.mjs +120 -0
- package/dist/storage/memory-budget.d.mts +8 -0
- package/dist/storage/memory-budget.mjs +546 -0
- package/dist/storage/merge.mjs +416 -0
- package/dist/storage/object-rows.d.mts +6 -0
- package/dist/storage/object-rows.mjs +211 -0
- package/dist/storage/pack-order.d.mts +8 -0
- package/dist/storage/pack-order.mjs +779 -0
- package/dist/storage/pack-ranges.d.mts +5 -0
- package/dist/storage/pack-ranges.mjs +284 -0
- package/dist/storage/pack-reads.d.mts +11 -0
- package/dist/storage/pack-reads.mjs +990 -0
- package/dist/storage/pack-receive.d.mts +11 -0
- package/dist/storage/pack-receive.mjs +449 -0
- package/dist/storage/packs.d.mts +56 -0
- package/dist/storage/packs.mjs +600 -0
- package/dist/storage/prune.mjs +506 -0
- package/dist/storage/push-allotment.mjs +109 -0
- package/dist/storage/push-uploads.mjs +151 -0
- package/dist/storage/pushed-commits.mjs +136 -0
- package/dist/storage/quarantine.mjs +98 -0
- package/dist/storage/raw-ids.mjs +44 -0
- package/dist/storage/ready.d.mts +19 -0
- package/dist/storage/ready.mjs +328 -0
- package/dist/storage/receive-links.mjs +297 -0
- package/dist/storage/repack-job.mjs +48 -0
- package/dist/storage/repack.d.mts +31 -0
- package/dist/storage/repack.mjs +182 -0
- package/dist/storage/roots.mjs +42 -0
- package/dist/storage/rows.d.mts +3 -0
- package/dist/storage/rows.mjs +71 -0
- package/dist/storage/shallow.d.mts +5 -0
- package/dist/storage/shallow.mjs +128 -0
- package/dist/storage/stream-whole.mjs +236 -0
- package/dist/storage/unpack.mjs +236 -0
- package/dist/storage/visible.mjs +137 -0
- package/dist/storage/walk.d.mts +7 -0
- package/dist/storage/walk.mjs +170 -0
- package/dist/storage/wants.mjs +362 -0
- package/dist/store/call-count.d.mts +47 -0
- package/dist/store/call-count.mjs +207 -0
- package/dist/store/catalogue.d.mts +7 -0
- package/dist/store/catalogue.mjs +643 -0
- package/dist/store/crossing.mjs +66 -0
- package/dist/store/cursor-seal.d.mts +2 -0
- package/dist/store/cursor-seal.mjs +85 -0
- package/dist/store/errors.d.mts +12 -0
- package/dist/store/errors.mjs +129 -0
- package/dist/store/git-store.mjs +75 -0
- package/dist/store/list-job.mjs +35 -0
- package/dist/store/outbox.d.mts +7 -0
- package/dist/store/outbox.mjs +295 -0
- package/dist/store/queue-jobs.mjs +43 -0
- package/dist/store/random.mjs +28 -0
- package/dist/store/records.d.mts +4 -0
- package/dist/store/records.mjs +192 -0
- package/dist/store/ref-rows.d.mts +4 -0
- package/dist/store/ref-rows.mjs +30 -0
- package/dist/store/repo-record.mjs +100 -0
- package/dist/store/reservations.mjs +82 -0
- package/dist/store/scopes.mjs +170 -0
- package/dist/store/settle.mjs +63 -0
- package/dist/store/topic-jobs.mjs +62 -0
- package/dist/sync/bound.d.mts +7 -0
- package/dist/sync/bound.mjs +29 -0
- package/dist/sync/github.d.mts +12 -0
- package/dist/sync/github.mjs +297 -0
- package/dist/sync/import.d.mts +8 -0
- package/dist/sync/import.mjs +154 -0
- package/dist/sync/jobs.d.mts +9 -0
- package/dist/sync/jobs.mjs +80 -0
- package/dist/sync/mirror.d.mts +9 -0
- package/dist/sync/mirror.mjs +227 -0
- package/dist/sync/publish.d.mts +5 -0
- package/dist/sync/publish.mjs +117 -0
- package/dist/sync/records.mjs +73 -0
- package/dist/sync/smart-http.d.mts +8 -0
- package/dist/sync/smart-http.mjs +23 -0
- package/dist/sync/step.mjs +334 -0
- package/dist/sync/tries.mjs +126 -0
- package/dist/sync.d.mts +8 -0
- package/dist/sync.mjs +8 -0
- package/dist/topics/advance.mjs +554 -0
- package/dist/topics/calls.mjs +346 -0
- package/dist/topics/directory.mjs +107 -0
- package/dist/topics/host.d.mts +11 -0
- package/dist/topics/host.mjs +71 -0
- package/dist/topics/members.mjs +177 -0
- package/dist/topics/rows.mjs +99 -0
- package/dist/topics/topic.mjs +126 -0
- package/package.json +86 -5
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
import { callerFor, openRepo } from "../core/access.mjs";
|
|
2
|
+
import { sightIn } from "../core/sight.mjs";
|
|
3
|
+
import { limitOf } from "../engine/reads.mjs";
|
|
4
|
+
import { checkBytes, jsonSize, queueLimits } from "../queue/limits.mjs";
|
|
5
|
+
import { fail } from "../store/errors.mjs";
|
|
6
|
+
import { topicAdvanceRow } from "../store/topic-jobs.mjs";
|
|
7
|
+
import { addMissing } from "./advance.mjs";
|
|
8
|
+
import { claimKey, indexPage } from "./directory.mjs";
|
|
9
|
+
import { admitMember } from "./members.mjs";
|
|
10
|
+
import { TopicReportRow } from "./rows.mjs";
|
|
11
|
+
import { commitTopic, currentSet, existing, failureOf, hintOf, readTopic, sameMembers, setKeyOf, topicOf } from "./topic.mjs";
|
|
12
|
+
import * as Effect from "effect/Effect";
|
|
13
|
+
import * as Schema from "effect/Schema";
|
|
14
|
+
// src/topics/calls.ts
|
|
15
|
+
/** The most members a topic has, as a candidate's entries. */
|
|
16
|
+
const topicMembers = queueLimits.candidateEntries;
|
|
17
|
+
/**
|
|
18
|
+
* The most a topic's members take as JSON: with each member's candidate beside them, its row stays
|
|
19
|
+
* within a 1 MiB row however its 1,000 members' names run.
|
|
20
|
+
*/
|
|
21
|
+
const membersBytes = 393216;
|
|
22
|
+
/** How many times a topic's call reads and commits again when another write moved it first. */
|
|
23
|
+
const callTries = 8;
|
|
24
|
+
const moved = () => fail("UNAVAILABLE", "The topic is busy", { hint: "Try again" });
|
|
25
|
+
/**
|
|
26
|
+
* A report of a set the topic no longer checks, as the queue's report names it: `entry-gone` once
|
|
27
|
+
* the topic is removed, `candidate-cancelled` once it failed, `candidate-superseded` otherwise.
|
|
28
|
+
*/
|
|
29
|
+
const stale = (topic, row) => {
|
|
30
|
+
const [what, reason, hint] = row.state === "removed" ? [`Topic ${topic} was removed`, "entry-gone"] : row.state === "failed" ? [
|
|
31
|
+
`Topic ${topic} failed`,
|
|
32
|
+
"candidate-cancelled",
|
|
33
|
+
newKey
|
|
34
|
+
] : isOpen(row) ? [
|
|
35
|
+
`Topic ${topic}'s candidates changed`,
|
|
36
|
+
"candidate-superseded",
|
|
37
|
+
"Report the topic’s current candidates, as topics.get lists them"
|
|
38
|
+
] : [`Topic ${topic} is ${row.state}`, "candidate-superseded"];
|
|
39
|
+
const context = { reason };
|
|
40
|
+
const options = hint === void 0 ? { context } : {
|
|
41
|
+
hint,
|
|
42
|
+
context
|
|
43
|
+
};
|
|
44
|
+
return fail("FAILED_PRECONDITION", `${what}: its report is stale`, options);
|
|
45
|
+
};
|
|
46
|
+
const sameReport = Schema.toEquivalence(TopicReportRow);
|
|
47
|
+
const newKey = "Add the change under a new key: a topic never opens again";
|
|
48
|
+
/**
|
|
49
|
+
* An add of `id`'s key with other heads: refused, whatever the topic's state, since a key is one
|
|
50
|
+
* change. A live topic is removed first, before its decision, which always works.
|
|
51
|
+
*/
|
|
52
|
+
const keyUsed = (id, row) => {
|
|
53
|
+
const message = `Key ${row.key} names topic ${id}, ${row.state}, at other heads`;
|
|
54
|
+
const hint = isOpen(row) ? `Remove topic ${id} with topics.remove, then add the change under a new key` : newKey;
|
|
55
|
+
return fail("FAILED_PRECONDITION", message, {
|
|
56
|
+
hint,
|
|
57
|
+
context: { topic: id }
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
const decided = (row) => fail("FAILED_PRECONDITION", `Topic ${row.key} is ${row.state}: its publish decision is saved`, { hint: "A topic withdraws only before its publish decision; add a new key instead" });
|
|
61
|
+
/** An event's actor and subject: none for an anonymous caller. */
|
|
62
|
+
const actorOf = (caller) => {
|
|
63
|
+
if (caller.actor.anonymous === true) return {};
|
|
64
|
+
const by = { actor: { id: caller.actor.id } };
|
|
65
|
+
return caller.subject === void 0 ? by : {
|
|
66
|
+
...by,
|
|
67
|
+
subject: { id: caller.subject.id }
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
const badEntries = (message) => fail("INVALID_ARGUMENT", message, { context: { field: "entries" } });
|
|
71
|
+
const isOpen = (row) => row.state === "checking" || row.state === "reserving";
|
|
72
|
+
/** The members `input` names, each admitted to its repo's queue as `caller`, at most one a target. */
|
|
73
|
+
const admitAll = Effect.fnUntraced(function* (host, caller, input) {
|
|
74
|
+
const { entries } = input;
|
|
75
|
+
if (entries.length === 0 || entries.length > topicMembers) return yield* badEntries(`A topic has 1 to ${topicMembers} entries`);
|
|
76
|
+
yield* checkBytes("key", input.key, queueLimits.nameBytes);
|
|
77
|
+
const members = [];
|
|
78
|
+
const seen = /* @__PURE__ */ new Set();
|
|
79
|
+
for (const entry of entries) {
|
|
80
|
+
const opened = yield* admitMember(host, caller, entry);
|
|
81
|
+
const member = {
|
|
82
|
+
repo: opened.name,
|
|
83
|
+
internalId: opened.internalId,
|
|
84
|
+
target: opened.input.target,
|
|
85
|
+
source: entry.source,
|
|
86
|
+
head: entry.head,
|
|
87
|
+
key: entry.key
|
|
88
|
+
};
|
|
89
|
+
const target = `${member.internalId}\n${member.target}`;
|
|
90
|
+
if (seen.has(target)) {
|
|
91
|
+
const named = `${member.repo} ${member.target}`;
|
|
92
|
+
return yield* badEntries(`A topic has one entry a repo and target: ${named} has two`);
|
|
93
|
+
}
|
|
94
|
+
seen.add(target);
|
|
95
|
+
members.push(member);
|
|
96
|
+
}
|
|
97
|
+
if (jsonSize(members) > 393216) return yield* badEntries(`A topic's entries take ${membersBytes} bytes as JSON at most`);
|
|
98
|
+
return members;
|
|
99
|
+
});
|
|
100
|
+
/** The topic at `read` with every member's entry added, adding those still missing. */
|
|
101
|
+
const withEntries = Effect.fnUntraced(function* (host, read) {
|
|
102
|
+
if (read.row.members.every((member) => member.entry !== void 0)) return read.row;
|
|
103
|
+
for (let attempt = 0; attempt < callTries; attempt += 1) {
|
|
104
|
+
const now = yield* existing(host, read.id);
|
|
105
|
+
if (now.row.members.every((member) => member.entry !== void 0) || !isOpen(now.row)) return now.row;
|
|
106
|
+
const added = yield* addMissing(host, now);
|
|
107
|
+
if (added !== void 0) return added;
|
|
108
|
+
}
|
|
109
|
+
return yield* moved();
|
|
110
|
+
});
|
|
111
|
+
/** The topic calls over `host`, deciding for `bound`, as `callerFor` says. */
|
|
112
|
+
/** A member's or a candidate's place, the one target of one repo it's on. */
|
|
113
|
+
const placeOf = ({ repo, target }) => `${repo}\n${target}`;
|
|
114
|
+
/**
|
|
115
|
+
* `caller`'s sight of the repo a member is on, or `undefined` where it may not read the repo: each
|
|
116
|
+
* repo opened once a call, however many of its targets the topic holds.
|
|
117
|
+
*/
|
|
118
|
+
const sightsOf = (core, caller) => {
|
|
119
|
+
const held = /* @__PURE__ */ new Map();
|
|
120
|
+
return Effect.fnUntraced(function* (member) {
|
|
121
|
+
if (held.has(member.internalId)) return held.get(member.internalId);
|
|
122
|
+
const operation = {
|
|
123
|
+
kind: "read",
|
|
124
|
+
repo: member.repo
|
|
125
|
+
};
|
|
126
|
+
const opened = yield* openRepo(core, caller, operation, [], member.internalId).pipe(Effect.map((resolved) => ({
|
|
127
|
+
id: resolved.name,
|
|
128
|
+
public: resolved.record.public,
|
|
129
|
+
internalId: resolved.internalId
|
|
130
|
+
})), Effect.catchIf((error) => error.code === "NOT_FOUND", () => Effect.succeed(void 0)));
|
|
131
|
+
const sight = opened === void 0 ? void 0 : yield* sightIn(core, caller, opened);
|
|
132
|
+
held.set(member.internalId, sight);
|
|
133
|
+
return sight;
|
|
134
|
+
});
|
|
135
|
+
};
|
|
136
|
+
/** The failures that name a member, by `repo`, and hold nothing of another: shown whole where it's seen. */
|
|
137
|
+
const naming = /* @__PURE__ */ new Set(["entry-failed", "refused"]);
|
|
138
|
+
/**
|
|
139
|
+
* `topic`, of `row`, as `caller` sees it on a server with `access`: only the members on a repo it
|
|
140
|
+
* reads whose source ref it sees, their entries and candidates, and what the topic waits on or
|
|
141
|
+
* failed at only where that names one of them, else left out, a failure keeping its reason and a
|
|
142
|
+
* hint from it alone.
|
|
143
|
+
* With no member left, `undefined`: the topic answers as one that isn't there (piece 3).
|
|
144
|
+
*/
|
|
145
|
+
const seenTopic = Effect.fnUntraced(function* (core, caller, topic, row) {
|
|
146
|
+
if (core.access === void 0) return topic;
|
|
147
|
+
const sightOf = sightsOf(core, caller);
|
|
148
|
+
const places = /* @__PURE__ */ new Set();
|
|
149
|
+
for (const member of row.members) if ((yield* sightOf(member))?.sees(member.source) === true) places.add(placeOf(member));
|
|
150
|
+
if (places.size === 0) return void 0;
|
|
151
|
+
if (places.size === row.members.length) return topic;
|
|
152
|
+
const shown = (place) => places.has(placeOf(place));
|
|
153
|
+
const entries = topic.entries.filter(shown);
|
|
154
|
+
const candidates = topic.candidates.filter(shown);
|
|
155
|
+
const { failure, waitingOn, ...rest } = topic;
|
|
156
|
+
const seen = {
|
|
157
|
+
...rest,
|
|
158
|
+
entries,
|
|
159
|
+
candidates
|
|
160
|
+
};
|
|
161
|
+
if (waitingOn !== void 0 && shown(waitingOn)) seen.waitingOn = waitingOn;
|
|
162
|
+
if (failure !== void 0) {
|
|
163
|
+
const { repo, entry, candidate } = failure;
|
|
164
|
+
seen.failure = naming.has(failure.reason) && repo !== void 0 && row.members.some((member) => member.repo === repo && places.has(placeOf(member))) && (entry === void 0 || entries.some((seenEntry) => seenEntry.entry === entry)) && (candidate === void 0 || candidates.some((seenOne) => seenOne.candidate === candidate)) ? failure : {
|
|
165
|
+
reason: failure.reason,
|
|
166
|
+
hint: hintOf(row, failure.reason)
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
return seen;
|
|
170
|
+
});
|
|
171
|
+
const topicCalls = (host, bound) => {
|
|
172
|
+
const callerOf = callerFor(bound);
|
|
173
|
+
const { core } = host.queue;
|
|
174
|
+
/** The topic `caller` sees of `row`, or `NOT_FOUND`, as for one that isn't there. */
|
|
175
|
+
const answer = Effect.fnUntraced(function* (caller, id, row) {
|
|
176
|
+
const seen = yield* seenTopic(core, caller, topicOf(id, row), row);
|
|
177
|
+
if (seen === void 0) return yield* fail("NOT_FOUND", `No topic '${id}'`);
|
|
178
|
+
return seen;
|
|
179
|
+
});
|
|
180
|
+
return {
|
|
181
|
+
add: Effect.fnUntraced(function* (input) {
|
|
182
|
+
const caller = callerOf(input);
|
|
183
|
+
if (caller.actor.anonymous === true) return yield* fail("UNAUTHENTICATED", "A topic needs an actor: its merges are pushed as it");
|
|
184
|
+
yield* core.authorize({
|
|
185
|
+
caller,
|
|
186
|
+
operation: { kind: "topic.add" }
|
|
187
|
+
});
|
|
188
|
+
const members = yield* admitAll(host, caller, input);
|
|
189
|
+
const id = yield* claimKey(core.store, caller.actor.id, input.key);
|
|
190
|
+
for (let attempt = 0; attempt < callTries; attempt += 1) {
|
|
191
|
+
const read = yield* readTopic(host, id);
|
|
192
|
+
const { row } = read;
|
|
193
|
+
if (row !== void 0 && sameMembers(row, members)) return yield* answer(caller, id, yield* withEntries(host, {
|
|
194
|
+
...read,
|
|
195
|
+
row
|
|
196
|
+
}));
|
|
197
|
+
if (row !== void 0) return yield* keyUsed(id, row);
|
|
198
|
+
const next = {
|
|
199
|
+
key: input.key,
|
|
200
|
+
state: "reserving",
|
|
201
|
+
revision: 0,
|
|
202
|
+
actor: caller.actor.id,
|
|
203
|
+
members,
|
|
204
|
+
candidates: []
|
|
205
|
+
};
|
|
206
|
+
if (caller.subject !== void 0) next.subject = caller.subject.id;
|
|
207
|
+
if ((yield* commitTopic(host, read, next, [], [topicAdvanceRow()])) === void 0) continue;
|
|
208
|
+
const added = yield* withEntries(host, { ...yield* existing(host, id) });
|
|
209
|
+
return yield* answer(caller, id, added);
|
|
210
|
+
}
|
|
211
|
+
return yield* moved();
|
|
212
|
+
}),
|
|
213
|
+
get: Effect.fnUntraced(function* (topic, input) {
|
|
214
|
+
const caller = callerOf(input);
|
|
215
|
+
yield* core.authorize({
|
|
216
|
+
caller,
|
|
217
|
+
operation: {
|
|
218
|
+
kind: "topic.read",
|
|
219
|
+
topic
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
const { row } = yield* existing(host, topic);
|
|
223
|
+
return yield* answer(caller, topic, row);
|
|
224
|
+
}),
|
|
225
|
+
list: Effect.fnUntraced(function* (input) {
|
|
226
|
+
const caller = callerOf(input);
|
|
227
|
+
yield* core.authorize({
|
|
228
|
+
caller,
|
|
229
|
+
operation: { kind: "topic.read" }
|
|
230
|
+
});
|
|
231
|
+
const limit = yield* limitOf(input.page);
|
|
232
|
+
const { ids, next } = yield* indexPage(core.store, input.state, input.page?.after, limit);
|
|
233
|
+
const items = [];
|
|
234
|
+
for (const id of ids) {
|
|
235
|
+
const { row } = yield* readTopic(host, id);
|
|
236
|
+
if (row === void 0 || input.state !== void 0 && row.state !== input.state) continue;
|
|
237
|
+
const seen = yield* seenTopic(core, caller, topicOf(id, row), row);
|
|
238
|
+
if (seen !== void 0) items.push(seen);
|
|
239
|
+
}
|
|
240
|
+
return next === void 0 ? { items } : {
|
|
241
|
+
items,
|
|
242
|
+
next
|
|
243
|
+
};
|
|
244
|
+
}),
|
|
245
|
+
remove: Effect.fnUntraced(function* (topic, input) {
|
|
246
|
+
const caller = callerOf(input);
|
|
247
|
+
yield* core.authorize({
|
|
248
|
+
caller,
|
|
249
|
+
operation: {
|
|
250
|
+
kind: "topic.remove",
|
|
251
|
+
topic
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
for (let attempt = 0; attempt < callTries; attempt += 1) {
|
|
255
|
+
const read = yield* existing(host, topic);
|
|
256
|
+
const { row } = read;
|
|
257
|
+
if (row.state === "removed" || row.state === "failed") return yield* answer(caller, topic, row);
|
|
258
|
+
if (row.state === "publishing" || row.state === "merged") return yield* decided(row);
|
|
259
|
+
const { waitingOn: _waited, ...rest } = row;
|
|
260
|
+
const next = {
|
|
261
|
+
...rest,
|
|
262
|
+
state: "removed"
|
|
263
|
+
};
|
|
264
|
+
const event = {
|
|
265
|
+
type: "topic.removed",
|
|
266
|
+
topic,
|
|
267
|
+
key: row.key,
|
|
268
|
+
reason: "removed",
|
|
269
|
+
...actorOf(caller)
|
|
270
|
+
};
|
|
271
|
+
const committed = yield* commitTopic(host, read, next, [event], [topicAdvanceRow()]);
|
|
272
|
+
if (committed === void 0) continue;
|
|
273
|
+
return yield* answer(caller, topic, committed);
|
|
274
|
+
}
|
|
275
|
+
return yield* moved();
|
|
276
|
+
}),
|
|
277
|
+
report: Effect.fnUntraced(function* (topic, input) {
|
|
278
|
+
const caller = callerOf(input);
|
|
279
|
+
if (input.summary !== void 0 && input.summary.length > queueLimits.summary) {
|
|
280
|
+
const message = `A report's summary holds ${queueLimits.summary} characters at most`;
|
|
281
|
+
return yield* fail("INVALID_ARGUMENT", message, { context: { field: "summary" } });
|
|
282
|
+
}
|
|
283
|
+
yield* checkBytes("url", input.url, queueLimits.urlBytes);
|
|
284
|
+
yield* checkBytes("meta", input.meta, queueLimits.metaBytes);
|
|
285
|
+
yield* core.authorize({
|
|
286
|
+
caller,
|
|
287
|
+
operation: {
|
|
288
|
+
kind: "topic.report",
|
|
289
|
+
topic
|
|
290
|
+
}
|
|
291
|
+
});
|
|
292
|
+
const named = setKeyOf(input.candidates.map((candidate) => ({ candidate })));
|
|
293
|
+
const reported = {
|
|
294
|
+
set: named,
|
|
295
|
+
verdict: input.verdict
|
|
296
|
+
};
|
|
297
|
+
if (input.summary !== void 0) reported.summary = input.summary;
|
|
298
|
+
if (input.url !== void 0) reported.url = input.url;
|
|
299
|
+
if (input.meta !== void 0) reported.meta = input.meta;
|
|
300
|
+
for (let attempt = 0; attempt < callTries; attempt += 1) {
|
|
301
|
+
const read = yield* existing(host, topic);
|
|
302
|
+
const { row } = read;
|
|
303
|
+
const set = currentSet(row);
|
|
304
|
+
if ((set === named || row.state === "failed" && row.report?.set === named) && row.report !== void 0 && row.report.set === named) {
|
|
305
|
+
if (sameReport(row.report, reported)) return { repeat: true };
|
|
306
|
+
if (row.report.verdict === "cancel" || !isOpen(row)) return yield* stale(topic, row);
|
|
307
|
+
const { verdict } = row.report;
|
|
308
|
+
const message = `Topic ${topic} was reported '${verdict}' already`;
|
|
309
|
+
return yield* fail("ALREADY_EXISTS", message, { context: { verdict } });
|
|
310
|
+
}
|
|
311
|
+
if (!isOpen(row) || set !== named) return yield* stale(topic, row);
|
|
312
|
+
const { set: _set, ...details } = reported;
|
|
313
|
+
const events = [{
|
|
314
|
+
type: "topic.reported",
|
|
315
|
+
topic,
|
|
316
|
+
key: row.key,
|
|
317
|
+
...details,
|
|
318
|
+
...actorOf(caller)
|
|
319
|
+
}];
|
|
320
|
+
const written = {
|
|
321
|
+
...row,
|
|
322
|
+
report: reported
|
|
323
|
+
};
|
|
324
|
+
if (input.verdict !== "pass") {
|
|
325
|
+
const { verdict, meta: _meta, ...noted } = details;
|
|
326
|
+
const failure = {
|
|
327
|
+
reason: verdict === "fail" ? "reported" : "cancelled",
|
|
328
|
+
...noted
|
|
329
|
+
};
|
|
330
|
+
written.state = "failed";
|
|
331
|
+
written.failure = failure;
|
|
332
|
+
events.push({
|
|
333
|
+
type: "topic.failed",
|
|
334
|
+
topic,
|
|
335
|
+
key: row.key,
|
|
336
|
+
failure: failureOf(row, failure),
|
|
337
|
+
...actorOf(caller)
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
if ((yield* commitTopic(host, read, written, events, [topicAdvanceRow()])) !== void 0) return { repeat: false };
|
|
341
|
+
}
|
|
342
|
+
return yield* moved();
|
|
343
|
+
})
|
|
344
|
+
};
|
|
345
|
+
};
|
|
346
|
+
export { membersBytes, topicCalls, topicMembers };
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { decodeRow, fail, storeCall } from "../store/errors.mjs";
|
|
2
|
+
import { randomText } from "../store/random.mjs";
|
|
3
|
+
import { collections, newChangeId, topicsScope } from "../store/scopes.mjs";
|
|
4
|
+
import { IndexRow, KeyClaim } from "./rows.mjs";
|
|
5
|
+
import * as Effect from "effect/Effect";
|
|
6
|
+
// src/topics/directory.ts
|
|
7
|
+
/**
|
|
8
|
+
* `git/topics`, the index across topics, as `git/repos` is across repos.
|
|
9
|
+
*
|
|
10
|
+
* - **`topic-keys/<actor and key>`**: written once, by the commit of an actor's first `topics.add`
|
|
11
|
+
* that names the key, before the topic's own first commit: a key is unique per actor, by its ID.
|
|
12
|
+
* Two adds of one actor's key race on it, and the loser goes on with the winner's topic. An add
|
|
13
|
+
* that stopped before its topic's first commit leaves a claim whose topic has no row: only that
|
|
14
|
+
* actor's next add of the key finishes it, under the claimed ID. Nothing else frees a claim, and
|
|
15
|
+
* none needs to: a claim with no topic holds no target, and `topics.list` never shows it.
|
|
16
|
+
* - **`topics/<topic>`** and **`topic-states/<state>/<topic>`**: put by the projection after each of
|
|
17
|
+
* the topic's own commits, only from a revision newer than the one there. A lost projection
|
|
18
|
+
* leaves the rows of an earlier revision, until the topic's next commit or `git.topic.advance`,
|
|
19
|
+
* which projects first each run, brings them into line. So `topics.list` reads each topic's own
|
|
20
|
+
* row before it shows it, and shows that row's state, never the index's.
|
|
21
|
+
*/
|
|
22
|
+
/** How many times a write to `git/topics` reads and commits again when another moved it first. */
|
|
23
|
+
const indexTries = 8;
|
|
24
|
+
/** An actor's key's claim, by the actor's ID, which no rename moves, and the key. */
|
|
25
|
+
const keyRead = (actor, key) => ({
|
|
26
|
+
collection: collections.topicKeys,
|
|
27
|
+
id: JSON.stringify([actor, key])
|
|
28
|
+
});
|
|
29
|
+
const indexKey = (topic) => ({
|
|
30
|
+
collection: collections.topicIndex,
|
|
31
|
+
id: topic
|
|
32
|
+
});
|
|
33
|
+
const stateKey = (state, topic) => ({
|
|
34
|
+
collection: collections.topicStates,
|
|
35
|
+
id: `${state}/${topic}`
|
|
36
|
+
});
|
|
37
|
+
const busy = () => fail("UNAVAILABLE", "The topics’ index is busy", { hint: "Try again" });
|
|
38
|
+
/** A new topic's ID: `t_` and 12 random bytes. */
|
|
39
|
+
const newTopicId = () => `t_${randomText(12)}`;
|
|
40
|
+
/** The topic `actor`'s `key` names: the one its claim names, or a new one, claimed now. */
|
|
41
|
+
const claimKey = Effect.fnUntraced(function* (store, actor, key) {
|
|
42
|
+
for (let attempt = 0; attempt < indexTries; attempt += 1) {
|
|
43
|
+
const { version, results } = yield* storeCall(() => store.read(topicsScope, [keyRead(actor, key)]));
|
|
44
|
+
const [row] = results[0] ?? [];
|
|
45
|
+
if (row !== void 0) return (yield* decodeRow(KeyClaim, row, `Topic key '${key}'`)).topic;
|
|
46
|
+
const topic = newTopicId();
|
|
47
|
+
const put = [{
|
|
48
|
+
...keyRead(actor, key),
|
|
49
|
+
value: { topic }
|
|
50
|
+
}];
|
|
51
|
+
const change = {
|
|
52
|
+
id: newChangeId(),
|
|
53
|
+
expect: version,
|
|
54
|
+
put
|
|
55
|
+
};
|
|
56
|
+
if ((yield* storeCall(() => store.commit("git/topics", change))).ok) return topic;
|
|
57
|
+
}
|
|
58
|
+
return yield* busy();
|
|
59
|
+
});
|
|
60
|
+
/**
|
|
61
|
+
* Brings `topic`'s index rows into line with its own row at `row.revision`: nothing when the index
|
|
62
|
+
* holds that revision or a later one already.
|
|
63
|
+
*/
|
|
64
|
+
const projectTopic = Effect.fnUntraced(function* (store, topic, row) {
|
|
65
|
+
for (let attempt = 0; attempt < indexTries; attempt += 1) {
|
|
66
|
+
const read = yield* storeCall(() => store.read(topicsScope, [indexKey(topic)]));
|
|
67
|
+
const [held] = read.results[0] ?? [];
|
|
68
|
+
const before = held === void 0 ? void 0 : yield* decodeRow(IndexRow, held, topic);
|
|
69
|
+
if (before !== void 0 && before.revision >= row.revision) return;
|
|
70
|
+
const moved = before !== void 0 && before.state !== row.state;
|
|
71
|
+
const change = {
|
|
72
|
+
id: newChangeId(),
|
|
73
|
+
expect: read.version,
|
|
74
|
+
put: [{
|
|
75
|
+
...indexKey(topic),
|
|
76
|
+
value: {
|
|
77
|
+
state: row.state,
|
|
78
|
+
revision: row.revision
|
|
79
|
+
}
|
|
80
|
+
}, {
|
|
81
|
+
...stateKey(row.state, topic),
|
|
82
|
+
value: {}
|
|
83
|
+
}],
|
|
84
|
+
delete: moved ? [stateKey(before.state, topic)] : []
|
|
85
|
+
};
|
|
86
|
+
if ((yield* storeCall(() => store.commit("git/topics", change))).ok) return;
|
|
87
|
+
}
|
|
88
|
+
return yield* busy();
|
|
89
|
+
});
|
|
90
|
+
/** A page of topic IDs from the index, in `state` when it says, and the cursor after it. */
|
|
91
|
+
const indexPage = Effect.fnUntraced(function* (store, state, after, limit) {
|
|
92
|
+
const prefix = state === void 0 ? void 0 : `${state}/`;
|
|
93
|
+
const read = {
|
|
94
|
+
collection: state === void 0 ? collections.topicIndex : collections.topicStates,
|
|
95
|
+
limit: limit + 1
|
|
96
|
+
};
|
|
97
|
+
if (prefix !== void 0) read.prefix = prefix;
|
|
98
|
+
if (after !== void 0) read.after = `${prefix ?? ""}${after}`;
|
|
99
|
+
const { results } = yield* storeCall(() => store.read(topicsScope, [read]));
|
|
100
|
+
const rows = results[0] ?? [];
|
|
101
|
+
const ids = rows.slice(0, limit).map((row) => row.id.slice(prefix?.length ?? 0));
|
|
102
|
+
return {
|
|
103
|
+
ids,
|
|
104
|
+
next: rows.length > limit ? ids.at(-1) : void 0
|
|
105
|
+
};
|
|
106
|
+
});
|
|
107
|
+
export { claimKey, indexPage, projectTopic };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import "../contracts/services.mjs";
|
|
2
|
+
import { TopicsFactory, TopicsOptions } from "../contracts/topics.mjs";
|
|
3
|
+
import "../queue/host.mjs";
|
|
4
|
+
import { Duration } from "@ref0/infra";
|
|
5
|
+
/**
|
|
6
|
+
* Topics across a server's repos: `git.topics`, their jobs and their events. A `timeout` or a
|
|
7
|
+
* `report.timeout` that isn't a duration from 1 millisecond to 365 days, in whole milliseconds, or
|
|
8
|
+
* a `prepare` that isn't a function or `{ handler }`, or one whose `timeout` passes 12 minutes,
|
|
9
|
+
* throws a `TypeError`.
|
|
10
|
+
*/
|
|
11
|
+
export declare const topics: (options?: TopicsOptions) => TopicsFactory;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { checkTimeout, isTimeout } from "../queue/host.mjs";
|
|
2
|
+
import "../queue/schedule.mjs";
|
|
3
|
+
import { millis } from "@ref0/infra";
|
|
4
|
+
import * as Predicate from "effect/Predicate";
|
|
5
|
+
// src/topics/host.ts
|
|
6
|
+
/** What `topics()` checked, by the factory it made, so a server takes only those. */
|
|
7
|
+
const made = /* @__PURE__ */ new WeakMap();
|
|
8
|
+
/** The topics each server's services were created with, as `createGitServer` registered them. */
|
|
9
|
+
const served = /* @__PURE__ */ new WeakMap();
|
|
10
|
+
/** What a `prepare` try may run past its call, to save the answer. */
|
|
11
|
+
const saveMargin = 6e4;
|
|
12
|
+
/** The longest `prepare` may run: a Git job's longest try, 13 minutes (Q188), less `saveMargin`. */
|
|
13
|
+
const prepareMost = 72e4;
|
|
14
|
+
/** How long `prepare` runs unless set. */
|
|
15
|
+
const prepareDefault = 3e4;
|
|
16
|
+
/** `prepare` checked: a function, or `{ handler }` with a timeout to 12 minutes. */
|
|
17
|
+
const checkPrepare = (prepare) => {
|
|
18
|
+
if (Predicate.isFunction(prepare)) return {
|
|
19
|
+
handler: prepare,
|
|
20
|
+
timeout: prepareDefault
|
|
21
|
+
};
|
|
22
|
+
if (!Predicate.isFunction(prepare.handler)) throw new TypeError("options.prepare must be a function, or { handler }");
|
|
23
|
+
const { timeout } = prepare;
|
|
24
|
+
if (timeout === void 0) return {
|
|
25
|
+
handler: prepare.handler,
|
|
26
|
+
timeout: prepareDefault
|
|
27
|
+
};
|
|
28
|
+
if (!isTimeout(timeout) || millis(timeout) > prepareMost) {
|
|
29
|
+
const given = Predicate.isString(timeout) ? `'${timeout}'` : String(timeout);
|
|
30
|
+
throw new TypeError(`options.prepare.timeout must be a duration from 1 millisecond to 12 minutes, not ${given}`);
|
|
31
|
+
}
|
|
32
|
+
return {
|
|
33
|
+
handler: prepare.handler,
|
|
34
|
+
timeout: millis(timeout)
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Topics across a server's repos: `git.topics`, their jobs and their events. A `timeout` or a
|
|
39
|
+
* `report.timeout` that isn't a duration from 1 millisecond to 365 days, in whole milliseconds, or
|
|
40
|
+
* a `prepare` that isn't a function or `{ handler }`, or one whose `timeout` passes 12 minutes,
|
|
41
|
+
* throws a `TypeError`.
|
|
42
|
+
*/
|
|
43
|
+
const topics = (options = {}) => {
|
|
44
|
+
const { prepare, report, timeout = "2 hours" } = options;
|
|
45
|
+
checkTimeout("timeout", timeout);
|
|
46
|
+
checkTimeout("report.timeout", report?.timeout);
|
|
47
|
+
const checked = {
|
|
48
|
+
timeout,
|
|
49
|
+
reportTimeout: report?.timeout ?? "60 minutes"
|
|
50
|
+
};
|
|
51
|
+
if (report?.required !== void 0) checked.required = report.required;
|
|
52
|
+
if (prepare !== void 0) checked.prepare = checkPrepare(prepare);
|
|
53
|
+
const factory = { create: (services) => {
|
|
54
|
+
const created = served.get(services);
|
|
55
|
+
if (created === void 0) throw new TypeError("Topics are created by createGitServer, with its services");
|
|
56
|
+
return created;
|
|
57
|
+
} };
|
|
58
|
+
made.set(factory, checked);
|
|
59
|
+
return factory;
|
|
60
|
+
};
|
|
61
|
+
/** The options `topics()` checked for `factory`: a `TypeError` for one it didn't make. */
|
|
62
|
+
const topicsOptions = (factory) => {
|
|
63
|
+
const options = made.get(factory);
|
|
64
|
+
if (options === void 0) throw new TypeError("options.topics must be one topics() made");
|
|
65
|
+
return options;
|
|
66
|
+
};
|
|
67
|
+
/** `createGitServer`'s record of the topics it serves over `services`. */
|
|
68
|
+
const serveTopics = (services, created) => {
|
|
69
|
+
served.set(services, created);
|
|
70
|
+
};
|
|
71
|
+
export { saveMargin, serveTopics, topics, topicsOptions };
|