@ref0/git 0.6.0 → 0.8.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/access/namespace.d.mts +2 -0
- package/dist/access/private-refs.d.mts +6 -29
- package/dist/access/private-refs.mjs +26 -13
- package/dist/access/public.d.mts +6 -0
- package/dist/access/public.mjs +9 -0
- package/dist/auth/access-jwt.d.mts +10 -6
- package/dist/auth/access-jwt.mjs +59 -40
- package/dist/auth/auth-namespace.d.mts +6 -0
- package/dist/auth/auth-namespace.mjs +12 -0
- package/dist/auth/auth.d.mts +3 -6
- package/dist/auth/auth.mjs +2 -9
- package/dist/auth/authorize.mjs +35 -29
- package/dist/auth/bridge.mjs +8 -8
- package/dist/auth/fences.d.mts +1 -2
- package/dist/auth/fences.mjs +1 -1
- package/dist/auth/grants.d.mts +0 -1
- package/dist/auth/grants.mjs +2 -2
- package/dist/auth/host-function.d.mts +1 -7
- package/dist/auth/host-function.mjs +51 -42
- package/dist/auth/identify.d.mts +0 -1
- package/dist/auth/identify.mjs +3 -2
- package/dist/auth/namespaces.d.mts +2 -2
- package/dist/auth/policy.d.mts +7 -4
- package/dist/auth/policy.mjs +13 -10
- package/dist/auth/token-rows.mjs +3 -6
- package/dist/auth/tokens-layer.d.mts +40 -0
- package/dist/auth/tokens-layer.mjs +29 -0
- package/dist/auth/tokens-namespace.d.mts +2 -0
- package/dist/auth/tokens-public.d.mts +6 -0
- package/dist/auth/tokens-public.mjs +31 -0
- package/dist/auth/tokens.d.mts +19 -7
- package/dist/auth/tokens.mjs +12 -6
- package/dist/auth.d.mts +2 -2
- package/dist/auth.mjs +2 -2
- package/dist/client/client.d.mts +22 -15
- package/dist/client/client.mjs +31 -27
- package/dist/client/git-http.mjs +23 -6
- package/dist/client/local.mjs +5 -4
- package/dist/client/namespace.d.mts +2 -0
- package/dist/client/push-upload.d.mts +1 -0
- package/dist/client/push-upload.mjs +169 -2
- package/dist/client/remote-helper.mjs +5 -12
- package/dist/client/remote.mjs +63 -22
- package/dist/client/run-remote-helper.d.mts +1 -1
- package/dist/client/run-remote-helper.mjs +6 -6
- package/dist/client/slice-push.d.mts +1 -1
- package/dist/client/transport.mjs +26 -19
- package/dist/contracts/access.d.mts +18 -10
- package/dist/contracts/access.mjs +17 -0
- package/dist/contracts/actors.d.mts +73 -28
- package/dist/contracts/actors.mjs +45 -2
- package/dist/contracts/authorize.d.mts +26 -17
- package/dist/contracts/blobs.d.mts +1 -1
- package/dist/contracts/blobs.mjs +1 -1
- package/dist/contracts/callers.mjs +40 -0
- package/dist/contracts/calls-spent.d.mts +6 -4
- package/dist/contracts/calls-spent.mjs +10 -8
- package/dist/contracts/client.d.mts +16 -9
- package/dist/contracts/commits.d.mts +2 -2
- package/dist/contracts/commits.mjs +1 -1
- package/dist/contracts/engine.d.mts +1 -1
- package/dist/contracts/events.d.mts +45 -32
- package/dist/contracts/events.mjs +21 -10
- package/dist/contracts/files.d.mts +44 -44
- package/dist/contracts/files.mjs +1 -1
- package/dist/contracts/forks.d.mts +34 -58
- package/dist/contracts/forks.mjs +1 -1
- package/dist/contracts/git-events.d.mts +50 -0
- package/dist/contracts/git-events.mjs +23 -0
- package/dist/contracts/git-hooks.d.mts +254 -0
- package/dist/contracts/git-hooks.mjs +12 -0
- package/dist/contracts/git.d.mts +93 -42
- package/dist/contracts/git.mjs +6 -5
- package/dist/contracts/grants.d.mts +46 -27
- package/dist/contracts/ids.d.mts +16 -0
- package/dist/contracts/ids.mjs +19 -4
- package/dist/contracts/lfs.d.mts +19 -4
- package/dist/contracts/merges.d.mts +7 -7
- package/dist/contracts/namespaces.d.mts +2 -2
- package/dist/contracts/objects.d.mts +21 -5
- package/dist/contracts/opaque.mjs +27 -0
- package/dist/contracts/operations.d.mts +301 -101
- package/dist/contracts/operations.mjs +209 -0
- package/dist/contracts/promises.d.mts +2 -0
- package/dist/contracts/push-uploads.d.mts +4 -1
- package/dist/contracts/push-uploads.mjs +9 -4
- package/dist/contracts/queue.d.mts +220 -49
- package/dist/contracts/queue.mjs +68 -6
- package/dist/contracts/refs.d.mts +30 -8
- package/dist/contracts/refs.mjs +1 -1
- package/dist/contracts/remote.d.mts +53 -23
- package/dist/contracts/remote.mjs +22 -0
- package/dist/contracts/repo-records.d.mts +2 -2
- package/dist/contracts/repos.d.mts +100 -82
- package/dist/contracts/repos.mjs +47 -8
- package/dist/contracts/result.d.mts +73 -41
- package/dist/contracts/result.mjs +74 -17
- package/dist/contracts/rules.d.mts +734 -68
- package/dist/contracts/rules.mjs +84 -1
- package/dist/contracts/server.d.mts +20 -206
- package/dist/contracts/services.d.mts +1 -10
- package/dist/contracts/services.mjs +1 -5
- package/dist/contracts/signin.d.mts +140 -43
- package/dist/contracts/signin.mjs +36 -3
- package/dist/contracts/store.d.mts +1 -1
- package/dist/contracts/sync.d.mts +109 -90
- package/dist/contracts/sync.mjs +34 -7
- package/dist/contracts/tags.d.mts +1 -1
- package/dist/contracts/tags.mjs +1 -1
- package/dist/contracts/tokens.d.mts +247 -60
- package/dist/contracts/tokens.mjs +93 -21
- package/dist/contracts/topics.d.mts +59 -20
- package/dist/contracts/topics.mjs +14 -5
- package/dist/contracts/trees.d.mts +2 -2
- package/dist/contracts/trees.mjs +1 -1
- package/dist/contracts/work.d.mts +2 -2
- package/dist/contracts/work.mjs +2 -2
- package/dist/core/access.d.mts +10 -12
- package/dist/core/access.mjs +45 -11
- package/dist/core/clock.mjs +1 -1
- package/dist/core/events/deliver.d.mts +3 -2
- package/dist/core/events/deliver.mjs +188 -92
- package/dist/core/forks.mjs +78 -34
- package/dist/core/hooks/groups.d.mts +26 -0
- package/dist/core/hooks/groups.mjs +73 -0
- package/dist/core/hooks/namespace.d.mts +2 -0
- package/dist/core/hooks/order.d.mts +2 -2
- package/dist/core/hooks/order.mjs +6 -6
- package/dist/core/hooks/public.d.mts +7 -0
- package/dist/core/hooks/public.mjs +5 -0
- package/dist/core/imports.mjs +94 -10
- package/dist/core/index-job.mjs +11 -8
- package/dist/core/loose-tally.mjs +46 -0
- package/dist/core/merge-parts.d.mts +1 -1
- package/dist/core/merge-parts.mjs +1 -1
- package/dist/core/mirror-rows.mjs +18 -0
- package/dist/core/names.mjs +1 -1
- package/dist/core/namespaces.d.mts +2 -1
- package/dist/core/objects/commit-writes.mjs +5 -5
- package/dist/core/objects/merges.mjs +1 -1
- package/dist/core/objects/objects-layer.mjs +1 -1
- package/dist/core/objects/reading.mjs +52 -7
- package/dist/core/objects/tree-edits.mjs +13 -28
- package/dist/core/objects/trees.mjs +4 -4
- package/dist/core/objects/writing.mjs +4 -3
- package/dist/core/own-writes.mjs +1 -1
- package/dist/core/parts.d.mts +22 -3
- package/dist/core/parts.mjs +5 -3
- package/dist/core/promise.mjs +23 -17
- package/dist/core/purge.d.mts +2 -2
- package/dist/core/purge.mjs +89 -34
- package/dist/core/push.mjs +67 -79
- package/dist/core/receipts.d.mts +2 -2
- package/dist/core/receipts.mjs +28 -4
- package/dist/core/ref-index-job.mjs +4 -4
- package/dist/core/ref-view.mjs +16 -8
- package/dist/core/refs.mjs +41 -10
- package/dist/core/registered-records.mjs +30 -0
- package/dist/core/{claim-rows.mjs → registered-rows.mjs} +6 -6
- package/dist/core/repack.d.mts +2 -2
- package/dist/core/repack.mjs +30 -23
- package/dist/core/repo-info.mjs +62 -26
- package/dist/core/repos.mjs +18 -11
- package/dist/core/rules/changes.mjs +2 -2
- package/dist/core/rules/check.mjs +10 -10
- package/dist/core/rules/commit-changes.mjs +1 -1
- package/dist/core/rules/context.d.mts +7 -6
- package/dist/core/rules/context.mjs +18 -16
- package/dist/core/rules/fetch.mjs +78 -31
- package/dist/core/saved-caller-views.d.mts +72 -0
- package/dist/core/saved-caller-views.mjs +123 -0
- package/dist/core/saved-callers-public.d.mts +5 -0
- package/dist/core/saved-callers-public.mjs +10 -0
- package/dist/core/saved-callers.mjs +95 -0
- package/dist/core/seam.d.mts +12 -1
- package/dist/core/seam.mjs +4 -2
- package/dist/core/tokens.mjs +7 -2
- package/dist/core/view.d.mts +1 -1
- package/dist/core/view.mjs +1 -1
- package/dist/core/work.mjs +6 -5
- package/dist/effect.d.mts +2 -4
- package/dist/effect.mjs +2 -4
- package/dist/engine/commits.mjs +19 -47
- package/dist/engine/content.d.mts +2 -2
- package/dist/engine/content.mjs +1 -1
- package/dist/engine/diff.mjs +2 -2
- package/dist/engine/failures.d.mts +1 -2
- package/dist/engine/failures.mjs +1 -3
- package/dist/engine/merge-base-walk.mjs +57 -142
- package/dist/engine/merge-bases.mjs +5 -5
- package/dist/engine/merge-renames.mjs +1 -1
- package/dist/engine/merge.mjs +16 -14
- package/dist/engine/reads.d.mts +2 -2
- package/dist/engine/reads.mjs +1 -1
- package/dist/engine/xdiff.d.mts +1 -1
- package/dist/engine/xdiff.mjs +2 -2
- package/dist/event-streams/event-streams.d.mts +6 -2
- package/dist/event-streams/event-streams.mjs +6 -2
- package/dist/event-streams/stream.mjs +5 -2
- package/dist/extend.d.mts +2 -3
- package/dist/extend.mjs +2 -2
- package/dist/http/answers.mjs +4 -3
- package/dist/http/core-parts.mjs +3 -4
- package/dist/http/handler.mjs +12 -32
- package/dist/http/parts.d.mts +1 -1
- package/dist/http/push-uploads.mjs +7 -5
- package/dist/http/receive-pack.mjs +3 -3
- package/dist/http/upload-pack.mjs +6 -5
- package/dist/index.d.mts +44 -24
- package/dist/index.mjs +17 -8
- package/dist/lfs/base.d.mts +8 -5
- package/dist/lfs/base.mjs +2 -1
- package/dist/lfs/calls.mjs +3 -2
- package/dist/lfs/layer.d.mts +9 -7
- package/dist/lfs/layer.mjs +37 -22
- package/dist/lfs/locks.mjs +3 -3
- package/dist/lfs/objects.d.mts +3 -2
- package/dist/lfs/objects.mjs +235 -71
- package/dist/lfs/pointers.mjs +70 -19
- package/dist/lfs/purge.mjs +7 -3
- package/dist/lfs/rows.mjs +25 -8
- package/dist/lfs/service.d.mts +6 -3
- package/dist/lfs/service.mjs +8 -2
- package/dist/lfs/upkeep.mjs +53 -31
- package/dist/lfs/upload-most.mjs +41 -0
- package/dist/lfs/uploaded.mjs +59 -0
- package/dist/lfs/wire.mjs +1 -1
- package/dist/protocol/bytes/buffers.d.mts +1 -1
- package/dist/protocol/bytes/buffers.mjs +1 -1
- package/dist/protocol/bytes/deflate.d.mts +1 -1
- package/dist/protocol/bytes/deflate.mjs +1 -1
- package/dist/protocol/bytes/hmac-sha256.mjs +3 -6
- package/dist/protocol/bytes/inflate.d.mts +1 -1
- package/dist/protocol/bytes/inflate.mjs +1 -1
- package/dist/protocol/bytes/sha1.d.mts +1 -1
- package/dist/protocol/bytes/sha1.mjs +2 -2
- package/dist/protocol/bytes/sha256-hasher.mjs +51 -0
- package/dist/protocol/bytes/text.mjs +6 -1
- package/dist/protocol/diff/read.d.mts +1 -1
- package/dist/protocol/diff/read.mjs +1 -1
- package/dist/protocol/diff/tree-diff.d.mts +1 -1
- package/dist/protocol/diff/tree-diff.mjs +11 -11
- package/dist/protocol/objects/fsck.mjs +6 -3
- package/dist/protocol/objects/lfs-pointer.mjs +6 -1
- package/dist/protocol/objects/tag.mjs +1 -1
- package/dist/protocol/objects/tree.mjs +1 -1
- package/dist/protocol/packs/graph.mjs +1 -1
- package/dist/protocol/packs/idx.d.mts +1 -1
- package/dist/protocol/packs/idx.mjs +1 -1
- package/dist/protocol/packs/parts.mjs +1 -1
- package/dist/protocol/packs/reader.d.mts +1 -1
- package/dist/protocol/packs/reader.mjs +2 -2
- package/dist/protocol/packs/write-error.d.mts +1 -1
- package/dist/protocol/packs/write-error.mjs +1 -1
- package/dist/protocol/packs/writer.mjs +4 -4
- package/dist/protocol/wire/advertisement.d.mts +1 -1
- package/dist/protocol/wire/advertisement.mjs +1 -1
- package/dist/protocol/wire/fetch.d.mts +1 -1
- package/dist/protocol/wire/fetch.mjs +1 -1
- package/dist/protocol/wire/lines.d.mts +1 -1
- package/dist/protocol/wire/lines.mjs +2 -2
- package/dist/protocol/wire/push-uploads.mjs +4 -2
- package/dist/protocol/wire/receive-pack.d.mts +1 -1
- package/dist/protocol/wire/receive-pack.mjs +1 -1
- package/dist/protocol/wire/report-status.d.mts +1 -1
- package/dist/protocol/wire/report-status.mjs +1 -1
- package/dist/protocol/wire/v2.d.mts +2 -2
- package/dist/protocol/wire/v2.mjs +2 -2
- package/dist/queue/advance.mjs +190 -68
- package/dist/queue/callers.mjs +56 -69
- package/dist/queue/calls.mjs +10 -11
- package/dist/queue/commit.mjs +28 -22
- package/dist/queue/host.d.mts +10 -11
- package/dist/queue/host.mjs +15 -7
- package/dist/queue/lanes.mjs +9 -18
- package/dist/queue/layer.d.mts +3 -3
- package/dist/queue/layer.mjs +11 -10
- package/dist/queue/limits.mjs +17 -5
- package/dist/queue/rows.mjs +13 -10
- package/dist/queue/schedule.mjs +7 -6
- package/dist/queue/search.mjs +11 -17
- package/dist/queue/state.mjs +7 -2
- package/dist/queue/trim.mjs +10 -5
- package/dist/rest/api.d.mts +1 -1
- package/dist/rest/blobs.d.mts +20 -20
- package/dist/rest/caller.d.mts +22 -20
- package/dist/rest/client-namespace.d.mts +2 -0
- package/dist/rest/client.d.mts +32 -8
- package/dist/rest/client.mjs +314 -388
- package/dist/rest/commits.d.mts +284 -284
- package/dist/rest/errors.d.mts +10 -10
- package/dist/rest/errors.mjs +1 -1
- package/dist/rest/events.d.mts +13 -11
- package/dist/rest/events.mjs +3 -1
- package/dist/rest/files.d.mts +48 -48
- package/dist/rest/forks.d.mts +131 -143
- package/dist/rest/handler.mjs +4 -3
- package/dist/rest/handlers.mjs +15 -8
- package/dist/rest/layer.d.mts +3 -3
- package/dist/rest/layer.mjs +8 -7
- package/dist/rest/listen.d.mts +8 -6
- package/dist/rest/listen.mjs +33 -77
- package/dist/rest/me.d.mts +18 -20
- package/dist/rest/me.mjs +1 -1
- package/dist/rest/merges.d.mts +17 -17
- package/dist/rest/queue.d.mts +140 -140
- package/dist/rest/queue.mjs +1 -1
- package/dist/rest/refs.d.mts +214 -214
- package/dist/rest/refs.mjs +1 -1
- package/dist/rest/repos.d.mts +123 -135
- package/dist/rest/tags.d.mts +30 -30
- package/dist/rest/tokens.d.mts +250 -260
- package/dist/rest/tokens.mjs +10 -42
- package/dist/rest/topics.d.mts +162 -162
- package/dist/rest/topics.mjs +1 -1
- package/dist/rest/trees.d.mts +117 -117
- package/dist/rest/wire.d.mts +7 -5
- package/dist/rest/wire.mjs +4 -3
- package/dist/rest/work.d.mts +69 -69
- package/dist/rest/work.mjs +1 -1
- package/dist/rest.d.mts +1 -7
- package/dist/rest.mjs +1 -5
- package/dist/server/check-fetch.mjs +9 -0
- package/dist/server/extension.mjs +3 -115
- package/dist/server/git-layer.d.mts +30 -5
- package/dist/server/git-layer.mjs +59 -29
- package/dist/server/git-namespace.d.mts +4 -4
- package/dist/server/git-namespace.mjs +6 -4
- package/dist/server/joined.d.mts +83 -0
- package/dist/server/joined.mjs +91 -0
- package/dist/server/registry.d.mts +7 -3
- package/dist/server/registry.mjs +135 -31
- package/dist/server/server.d.mts +9 -3
- package/dist/server/server.mjs +277 -208
- package/dist/signin/context.d.mts +2 -2
- package/dist/signin/context.mjs +28 -37
- package/dist/signin/device.mjs +5 -5
- package/dist/signin/forms.mjs +1 -1
- package/dist/signin/grants.d.mts +2 -3
- package/dist/signin/grants.mjs +5 -5
- package/dist/signin/layer.d.mts +9 -0
- package/dist/signin/layer.mjs +41 -0
- package/dist/signin/namespace.d.mts +2 -0
- package/dist/signin/public.d.mts +6 -0
- package/dist/signin/public.mjs +5 -0
- package/dist/signin/route.mjs +47 -21
- package/dist/signin/web.mjs +3 -3
- package/dist/signin/wire.mjs +1 -1
- package/dist/storage/calls.d.mts +1 -1
- package/dist/storage/calls.mjs +4 -4
- package/dist/storage/clean-up.mjs +15 -6
- package/dist/storage/counted-bucket.mjs +34 -51
- package/dist/storage/fetch.mjs +1 -1
- package/dist/storage/fsck.mjs +12 -2
- package/dist/storage/graph-rebuild.mjs +262 -0
- package/dist/storage/host-bucket.mjs +1 -1
- package/dist/storage/index-build.d.mts +2 -2
- package/dist/storage/index-build.mjs +103 -15
- package/dist/storage/index-fetch.mjs +10 -6
- package/dist/storage/index-graph.mjs +1 -1
- package/dist/storage/index-layers.mjs +1 -1
- package/dist/storage/index-visible.mjs +1 -1
- package/dist/storage/lfs-pointers.d.mts +5 -5
- package/dist/storage/lfs-pointers.mjs +37 -11
- package/dist/storage/loose.mjs +4 -1
- package/dist/storage/memory-budget.mjs +8 -2
- package/dist/storage/merge-cut.mjs +24 -1
- package/dist/storage/merge-fence.mjs +82 -20
- package/dist/storage/merge-most.mjs +1 -0
- package/dist/storage/merge-plan.mjs +5 -2
- package/dist/storage/merge-row.mjs +17 -5
- package/dist/storage/merge-stream.mjs +25 -13
- package/dist/storage/merge-write.mjs +1 -1
- package/dist/storage/merge.d.mts +2 -2
- package/dist/storage/merge.mjs +1 -1
- package/dist/storage/object-rows.d.mts +2 -2
- package/dist/storage/object-rows.mjs +20 -4
- package/dist/storage/pack-ranges.d.mts +3 -1
- package/dist/storage/pack-ranges.mjs +168 -69
- package/dist/storage/pack-reads.mjs +4 -4
- package/dist/storage/pack-receive.d.mts +1 -1
- package/dist/storage/pack-receive.mjs +17 -15
- package/dist/storage/packs.d.mts +1 -1
- package/dist/storage/packs.mjs +103 -79
- package/dist/storage/placed-reads.mjs +81 -15
- package/dist/storage/prune-seen.mjs +126 -0
- package/dist/storage/prune-walk.mjs +87 -99
- package/dist/storage/prune.mjs +113 -50
- package/dist/storage/push-uploads.mjs +4 -2
- package/dist/storage/quarantine.d.mts +2 -2
- package/dist/storage/ready.d.mts +2 -2
- package/dist/storage/ready.mjs +15 -6
- package/dist/storage/receive-files.mjs +1 -1
- package/dist/storage/receive-links.mjs +1 -1
- package/dist/storage/receive-state.d.mts +2 -2
- package/dist/storage/receive-state.mjs +2 -2
- package/dist/storage/receive-steps.mjs +1 -1
- package/dist/storage/repack-contained.mjs +24 -16
- package/dist/storage/repack-job.d.mts +2 -2
- package/dist/storage/repack-job.mjs +5 -4
- package/dist/storage/repack.d.mts +2 -2
- package/dist/storage/repack.mjs +12 -5
- package/dist/storage/rows.d.mts +2 -2
- package/dist/storage/rows.mjs +1 -1
- package/dist/storage/runs.d.mts +2 -2
- package/dist/storage/runs.mjs +15 -6
- package/dist/storage/send-list.mjs +6 -6
- package/dist/storage/single-flight.mjs +2 -2
- package/dist/storage/swap-walk.mjs +1 -1
- package/dist/storage/unpack.mjs +8 -1
- package/dist/store/call-count.d.mts +24 -4
- package/dist/store/call-count.mjs +158 -44
- package/dist/store/catalogue.d.mts +1 -1
- package/dist/store/catalogue.mjs +2 -2
- package/dist/store/crossing.mjs +2 -6
- package/dist/store/cursor-seal.mjs +1 -1
- package/dist/store/errors.d.mts +7 -3
- package/dist/store/errors.mjs +41 -13
- package/dist/store/job-try.mjs +119 -15
- package/dist/store/list-job.mjs +5 -5
- package/dist/store/outbox.d.mts +2 -2
- package/dist/store/outbox.mjs +75 -16
- package/dist/store/promises.d.mts +2 -2
- package/dist/store/promises.mjs +31 -6
- package/dist/store/queue-jobs.mjs +1 -1
- package/dist/store/records.d.mts +2 -2
- package/dist/store/records.mjs +22 -24
- package/dist/store/ref-rows.d.mts +2 -2
- package/dist/store/ref-rows.mjs +6 -6
- package/dist/store/repo-record.mjs +29 -12
- package/dist/store/reservations.mjs +35 -8
- package/dist/store/scopes.mjs +12 -5
- package/dist/store/topic-jobs.mjs +8 -8
- package/dist/sync/bound.d.mts +1 -3
- package/dist/sync/bound.mjs +30 -42
- package/dist/sync/github.d.mts +5 -6
- package/dist/sync/github.mjs +37 -42
- package/dist/sync/http.mjs +15 -0
- package/dist/sync/import.mjs +30 -19
- package/dist/sync/layer.d.mts +13 -0
- package/dist/sync/layer.mjs +73 -0
- package/dist/sync/mirror.mjs +137 -58
- package/dist/sync/publish.mjs +3 -6
- package/dist/sync/step.mjs +223 -85
- package/dist/sync/tries.mjs +22 -15
- package/dist/sync.d.mts +3 -6
- package/dist/sync.mjs +3 -6
- package/dist/topics/advance.mjs +210 -94
- package/dist/topics/calls.mjs +8 -8
- package/dist/topics/directory.mjs +35 -12
- package/dist/topics/host.d.mts +5 -8
- package/dist/topics/host.mjs +42 -19
- package/dist/topics/layer.d.mts +381 -0
- package/dist/topics/layer.mjs +62 -0
- package/dist/topics/members.mjs +39 -10
- package/dist/topics/namespace.d.mts +2 -0
- package/dist/topics/public.d.mts +6 -0
- package/dist/topics/public.mjs +13 -0
- package/dist/topics/rows.mjs +12 -3
- package/dist/topics/topic.mjs +11 -10
- package/package.json +8 -13
- package/dist/access.d.mts +0 -2
- package/dist/access.mjs +0 -1
- package/dist/core/hooks/post-receive.mjs +0 -216
- package/dist/core/hooks/pre-receive.d.mts +0 -12
- package/dist/core/hooks/pre-receive.mjs +0 -36
- package/dist/engine/merge-base-walk.d.mts +0 -3
- package/dist/server/extension.d.mts +0 -21
- package/dist/server/routes.d.mts +0 -32
- package/dist/server/routes.mjs +0 -69
- package/dist/sync/import.d.mts +0 -10
- package/dist/sync/jobs.d.mts +0 -9
- package/dist/sync/jobs.mjs +0 -75
- package/dist/sync/mirror.d.mts +0 -13
- package/dist/sync/publish.d.mts +0 -6
- /package/dist/core/{claim-rows.d.mts → registered-rows.d.mts} +0 -0
package/dist/lfs/layer.mjs
CHANGED
|
@@ -1,64 +1,79 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { callerFor } from "../core/access.mjs";
|
|
1
|
+
import { register } from "../contracts/git.mjs";
|
|
2
|
+
import { callerFor, resolvedAs } from "../core/access.mjs";
|
|
3
|
+
import { seenIn } from "../core/objects/reading.mjs";
|
|
3
4
|
import { LfsBase } from "./base.mjs";
|
|
4
5
|
import { objectOf } from "./objects.mjs";
|
|
5
6
|
import { pointerCheck } from "./pointers.mjs";
|
|
6
7
|
import { lfsPurge } from "./purge.mjs";
|
|
7
8
|
import { lfsService } from "./service.mjs";
|
|
8
9
|
import { lfsUpkeep } from "./upkeep.mjs";
|
|
9
|
-
import {
|
|
10
|
+
import { capsRefusal, uploadMostOf } from "./upload-most.mjs";
|
|
10
11
|
import * as Effect from "effect/Effect";
|
|
12
|
+
import { Bucket } from "@ref0/infra";
|
|
11
13
|
import * as Context from "effect/Context";
|
|
12
14
|
import * as Layer from "effect/Layer";
|
|
13
15
|
// src/lfs/layer.ts
|
|
14
16
|
/** Git LFS's objects, read as a call rather than over git-lfs's own HTTP API. */
|
|
15
17
|
var Lfs = class extends (/* @__PURE__ */ Context.Service()("@ref0/git/Lfs")) {};
|
|
16
18
|
/**
|
|
17
|
-
* LFS over `
|
|
18
|
-
* the
|
|
19
|
+
* LFS over `registration`: its routes and pointer check attached to the server, its upkeep and purge on
|
|
20
|
+
* the registration, its rows the registration's, under `lfs/`. Its uploads through the server are
|
|
21
|
+
* held to the adapter's `RequestLimits`, each of `options` winning over its own. A server with no
|
|
22
|
+
* bucket, or `options` that aren't caps, is a defect.
|
|
19
23
|
*/
|
|
20
|
-
const
|
|
24
|
+
const lfsRegistration = /* @__PURE__ */ Effect.fnUntraced(function* (registration, options = {}) {
|
|
21
25
|
const base = yield* LfsBase;
|
|
22
|
-
const { needs, bucket, links } = base;
|
|
26
|
+
const { needs, bucket, links, requestLimits } = base;
|
|
23
27
|
if (bucket === void 0) return yield* Effect.die(/* @__PURE__ */ new TypeError("lfs() keeps its objects in the adapter's bucket: give the adapter a bucket"));
|
|
28
|
+
const caps = {
|
|
29
|
+
bodyCap: options.bodyCap ?? requestLimits.bodyBytes,
|
|
30
|
+
cpuMs: options.cpuMs ?? requestLimits.cpuMs
|
|
31
|
+
};
|
|
32
|
+
const refusal = capsRefusal(caps);
|
|
33
|
+
if (refusal !== void 0) return yield* Effect.die(new TypeError(refusal));
|
|
24
34
|
const parts = {
|
|
25
|
-
rows:
|
|
35
|
+
rows: registration.rows,
|
|
26
36
|
bucket,
|
|
27
|
-
signed: links
|
|
37
|
+
signed: links,
|
|
38
|
+
uploadMost: uploadMostOf(caps)
|
|
28
39
|
};
|
|
29
40
|
const read = (one) => objectOf(parts, one);
|
|
30
41
|
const callerOf = callerFor(void 0);
|
|
31
42
|
yield* base.attach({
|
|
32
43
|
service: lfsService(needs, parts),
|
|
33
44
|
check: {
|
|
34
|
-
|
|
45
|
+
registration: registration.name,
|
|
35
46
|
band: "post",
|
|
36
|
-
handler: (input, updates) => pointerCheck(
|
|
47
|
+
handler: (input, updates) => pointerCheck(registration.rows, {
|
|
37
48
|
updates,
|
|
38
|
-
objects: input.objects
|
|
49
|
+
objects: input.objects,
|
|
50
|
+
caller: input.caller,
|
|
51
|
+
seen: (blobs) => Effect.provideContext(Effect.flatMap(resolvedAs(input.repo, input.objects.repo), (resolved) => seenIn(input.caller, resolved, blobs)), needs)
|
|
39
52
|
})
|
|
40
53
|
},
|
|
41
54
|
read
|
|
42
55
|
});
|
|
43
|
-
yield*
|
|
44
|
-
yield*
|
|
45
|
-
return Lfs.of({ get: (repo, { oid, size, signal, internalId, ...input }) => Effect.provideContext(read({
|
|
56
|
+
yield* registration.addUpkeep(lfsUpkeep(registration.rows, bucket, links !== void 0));
|
|
57
|
+
yield* registration.addPurge(lfsPurge(registration.rows, bucket));
|
|
58
|
+
return Lfs.of({ get: (repo, { oid, size, signal, internalId, request, ...input }) => Effect.provideContext(read({
|
|
46
59
|
caller: callerOf(input),
|
|
47
60
|
repo,
|
|
48
61
|
oid,
|
|
49
62
|
size,
|
|
50
63
|
signal,
|
|
51
|
-
internalId
|
|
64
|
+
internalId,
|
|
65
|
+
request
|
|
52
66
|
}), needs) });
|
|
53
67
|
});
|
|
54
68
|
/**
|
|
55
|
-
* Git LFS, a feature over core: it
|
|
69
|
+
* Git LFS, a feature over core: it registers `lfs`, keeps its objects in the host's `Bucket`, and
|
|
56
70
|
* serves git-lfs's API under each repo's `info/lfs/`. With `BucketLinks` its transfers go straight
|
|
57
|
-
* to the bucket; without, through the Worker
|
|
71
|
+
* to the bucket; without, through the Worker, each upload held to what the host's caps let finish:
|
|
72
|
+
* `options`, each winning over the adapter's `RequestLimits`, as `LfsOptions` says.
|
|
58
73
|
*/
|
|
59
|
-
const layer = () => Layer.effect(Lfs, Effect.gen(function* () {
|
|
74
|
+
const layer = (options = {}) => Layer.effect(Lfs, Effect.gen(function* () {
|
|
60
75
|
yield* Bucket.Bucket;
|
|
61
|
-
const
|
|
62
|
-
return yield*
|
|
76
|
+
const registration = yield* register({ name: "lfs" });
|
|
77
|
+
return yield* lfsRegistration(registration, options);
|
|
63
78
|
}));
|
|
64
|
-
export { Lfs, layer,
|
|
79
|
+
export { Lfs, layer, lfsRegistration };
|
package/dist/lfs/locks.mjs
CHANGED
|
@@ -6,9 +6,9 @@ import { decodeRow } from "../store/errors.mjs";
|
|
|
6
6
|
import { randomText } from "../store/random.mjs";
|
|
7
7
|
import { LockRow, lfsCollections, lockKey, lockRead } from "./rows.mjs";
|
|
8
8
|
import { LockCreate, LockQuery, LockVerify, Unlock, bodyOf, lfsAnswer } from "./wire.mjs";
|
|
9
|
-
import * as Schema from "effect/Schema";
|
|
10
|
-
import * as Effect from "effect/Effect";
|
|
11
9
|
import * as Clock$1 from "effect/Clock";
|
|
10
|
+
import * as Effect from "effect/Effect";
|
|
11
|
+
import * as Schema from "effect/Schema";
|
|
12
12
|
import * as DateTime from "effect/DateTime";
|
|
13
13
|
// src/lfs/locks.ts
|
|
14
14
|
/**
|
|
@@ -142,7 +142,7 @@ const unlock = /* @__PURE__ */ Effect.fnUntraced(function* (parts, call, id) {
|
|
|
142
142
|
if ((yield* openRepo(call.caller, {
|
|
143
143
|
kind: "repo.update",
|
|
144
144
|
repo: call.repo
|
|
145
|
-
})).internalId !== repo.internalId) return yield* fail("UNAVAILABLE", "The repo moved while this call ran", { hint: "Try again" });
|
|
145
|
+
}, [], void 0, "skip")).internalId !== repo.internalId) return yield* fail("UNAVAILABLE", "The repo moved while this call ran", { hint: "Try again" });
|
|
146
146
|
}
|
|
147
147
|
if ((yield* parts.rows.commit(repo.internalId, read.version, { delete: [lockKey(rowId)] })).ok) return lfsAnswer(200, { lock });
|
|
148
148
|
}
|
package/dist/lfs/objects.d.mts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import "../contracts/result.mjs";
|
|
2
|
-
import "../contracts/authorize.mjs";
|
|
3
1
|
import "../core/parts.mjs";
|
|
4
2
|
import "../contracts/objects.mjs";
|
|
5
3
|
import { Caller } from "../contracts/actors.mjs";
|
|
6
4
|
import "../contracts/git.mjs";
|
|
7
5
|
import { InternalRepoId, RepoName } from "../contracts/ids.mjs";
|
|
6
|
+
import "../contracts/result.mjs";
|
|
8
7
|
import "effect/Effect";
|
|
9
8
|
/** One request to a repo's `info/lfs/`, from a caller `identify` answered. */
|
|
10
9
|
export interface LfsCall {
|
|
@@ -23,4 +22,6 @@ export interface ObjectRead {
|
|
|
23
22
|
readonly signal?: AbortSignal | undefined;
|
|
24
23
|
/** The repo the caller resolved `repo` to, as `RepoInput` says. */
|
|
25
24
|
readonly internalId?: InternalRepoId | undefined;
|
|
25
|
+
/** The HTTP request the read came by, for the host's fetch rules. */
|
|
26
|
+
readonly request?: Request | undefined;
|
|
26
27
|
}
|
package/dist/lfs/objects.mjs
CHANGED
|
@@ -1,25 +1,35 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { nativeSha256Hasher } from "../protocol/bytes/sha256-hasher.mjs";
|
|
2
2
|
import { contended, openFor } from "../core/access.mjs";
|
|
3
|
-
import {
|
|
3
|
+
import { ownWriter } from "../core/own-writes.mjs";
|
|
4
|
+
import { sweepDue } from "../core/receipts.mjs";
|
|
5
|
+
import { seenIn } from "../core/objects/reading.mjs";
|
|
6
|
+
import { checkRead, readRefusal } from "../core/rules/fetch.mjs";
|
|
7
|
+
import { utf8 } from "../protocol/bytes/text.mjs";
|
|
8
|
+
import { objectId } from "../protocol/objects/object.mjs";
|
|
9
|
+
import { bestEffort, decodeRow } from "../store/errors.mjs";
|
|
4
10
|
import { randomText } from "../store/random.mjs";
|
|
5
11
|
import { bucketCall, bucketDo, bucketFailed, bucketStream } from "../storage/calls.mjs";
|
|
6
|
-
import { isLfsOid } from "../protocol/objects/lfs-pointer.mjs";
|
|
12
|
+
import { isLfsOid, lfsPointerText } from "../protocol/objects/lfs-pointer.mjs";
|
|
7
13
|
import { ListedRow, UploadRow, largestObject, lfsCollections, linkLife, listedKey, listedRead, objectKey, stagingId, stagingKey, stagingRead, streamMost, uploadGrace, uploadKey, uploadRead } from "./rows.mjs";
|
|
8
14
|
import { BatchRequest, VerifyRequest, batchMost, bodyOf, lfsAnswer } from "./wire.mjs";
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import
|
|
15
|
+
import { uploadedRow } from "./uploaded.mjs";
|
|
16
|
+
import { pastMost } from "./upload-most.mjs";
|
|
17
|
+
import { fail, gitError, httpStatus } from "../contracts/result.mjs";
|
|
12
18
|
import * as Clock$1 from "effect/Clock";
|
|
19
|
+
import * as Effect from "effect/Effect";
|
|
13
20
|
import * as Option from "effect/Option";
|
|
21
|
+
import { Unavailable } from "@ref0/infra";
|
|
14
22
|
import * as Stream from "effect/Stream";
|
|
15
23
|
import * as DateTime from "effect/DateTime";
|
|
16
24
|
// src/lfs/objects.ts
|
|
17
25
|
/**
|
|
18
26
|
* Each object's rows, read with the repo's record and the fence's rows at one version, the fence
|
|
19
|
-
* checked; `also`'s rows after them.
|
|
27
|
+
* checked; `also`'s rows after them. An object's upload row is the caller's own, as `uploader`
|
|
28
|
+
* names it. A repo deleted since it opened is `NOT_FOUND`.
|
|
20
29
|
*/
|
|
21
30
|
const objectRows = /* @__PURE__ */ Effect.fnUntraced(function* (rows, caller, repo, oids, also = []) {
|
|
22
|
-
const
|
|
31
|
+
const uploader = (yield* ownWriter(caller)) ?? "anonymous";
|
|
32
|
+
const own = oids.flatMap((oid) => [listedRead(oid), uploadRead(oid, uploader)]);
|
|
23
33
|
const { version, results } = yield* rows.readFenced(caller, repo, [...own, ...also]);
|
|
24
34
|
const found = /* @__PURE__ */ new Map();
|
|
25
35
|
for (const [at, oid] of oids.entries()) {
|
|
@@ -31,6 +41,7 @@ const objectRows = /* @__PURE__ */ Effect.fnUntraced(function* (rows, caller, re
|
|
|
31
41
|
}
|
|
32
42
|
return {
|
|
33
43
|
version,
|
|
44
|
+
uploader,
|
|
34
45
|
rows: found,
|
|
35
46
|
also: results.slice(own.length)
|
|
36
47
|
};
|
|
@@ -51,24 +62,64 @@ const listedOf = /* @__PURE__ */ Effect.fnUntraced(function* (rows, repo, oids)
|
|
|
51
62
|
return listed;
|
|
52
63
|
});
|
|
53
64
|
/**
|
|
54
|
-
* The listed rows of `oids` a download from `repo` reads: its own, then,
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
65
|
+
* The listed rows of `oids` a download from `repo` reads: its own, then its source's, up the fork
|
|
66
|
+
* chain by internal ID for at most `forkReads` sources. The first listing wins, so a fork's own
|
|
67
|
+
* upload shadows its source's. Each source's rows of every one of `oids` are read, found sooner or
|
|
68
|
+
* not, so the reads made are the same whichever of them are listed, as `unseenOf` needs. A deleted
|
|
69
|
+
* source's rows are read too: its LFS rows and bytes stay while a fork's row names it, since
|
|
70
|
+
* `git.purge` waits on one.
|
|
58
71
|
*/
|
|
59
72
|
const chainListed = /* @__PURE__ */ Effect.fnUntraced(function* (rows, repo, oids) {
|
|
60
73
|
const listed = yield* listedOf(rows, repo, oids);
|
|
74
|
+
if (oids.length === 0) return listed;
|
|
61
75
|
let from = repo;
|
|
62
76
|
for (let read = 0; read < 16; read += 1) {
|
|
63
|
-
const missing = oids.filter((oid) => !listed.has(oid));
|
|
64
|
-
if (missing.length === 0) break;
|
|
65
77
|
const source = yield* rows.source(from);
|
|
66
78
|
if (source === void 0) break;
|
|
67
|
-
for (const [oid, row] of yield* listedOf(rows, source,
|
|
79
|
+
for (const [oid, row] of yield* listedOf(rows, source, oids)) if (!listed.has(oid)) listed.set(oid, row);
|
|
68
80
|
from = source;
|
|
69
81
|
}
|
|
70
82
|
return listed;
|
|
71
83
|
});
|
|
84
|
+
/**
|
|
85
|
+
* Which of `listed`'s objects `caller` mayn't know `repo` lists. A caller whose view of it is
|
|
86
|
+
* narrowed (`RepoView.narrowed`), as under `access` one who doesn't read every pattern is, knows of
|
|
87
|
+
* a listed object only when a ref it sees reaches its pointer as git-lfs writes it
|
|
88
|
+
* (`lfsPointerText`), so an object only a hidden ref's tree points at answers as one never
|
|
89
|
+
* uploaded. So does one only a pointer of another text names, with an extension or blank lines.
|
|
90
|
+
* The view is asked of a pointer for each of `oids`, listed or not, by the listed size or else 0,
|
|
91
|
+
* so the calls it makes are the same whichever of them are listed. Any other caller knows of every
|
|
92
|
+
* one: its view answers that it isn't narrowed, and nothing more is read.
|
|
93
|
+
*/
|
|
94
|
+
const unseenOf = /* @__PURE__ */ Effect.fnUntraced(function* (caller, repo, oids, listed) {
|
|
95
|
+
const unseen = /* @__PURE__ */ new Set();
|
|
96
|
+
const pointers = /* @__PURE__ */ new Map();
|
|
97
|
+
for (const oid of new Set(oids)) {
|
|
98
|
+
const text = lfsPointerText({
|
|
99
|
+
oid,
|
|
100
|
+
size: listed.get(oid)?.size ?? 0
|
|
101
|
+
});
|
|
102
|
+
pointers.set(yield* objectId({
|
|
103
|
+
type: "blob",
|
|
104
|
+
bytes: utf8(text)
|
|
105
|
+
}), oid);
|
|
106
|
+
}
|
|
107
|
+
const seen = yield* seenIn(caller, repo, [...pointers.keys()]);
|
|
108
|
+
if (seen === void 0) return unseen;
|
|
109
|
+
for (const [pointer, oid] of pointers) if (listed.has(oid) && !seen.has(pointer)) unseen.add(oid);
|
|
110
|
+
return unseen;
|
|
111
|
+
});
|
|
112
|
+
/** `listed`, less what `caller` mayn't know of, asked for each of `oids`, as `unseenOf` says. */
|
|
113
|
+
const seenListed = /* @__PURE__ */ Effect.fnUntraced(function* (caller, repo, oids, listed) {
|
|
114
|
+
const unseen = yield* unseenOf(caller, repo, oids, listed);
|
|
115
|
+
return unseen.size === 0 ? listed : new Map([...listed].filter(([oid]) => !unseen.has(oid)));
|
|
116
|
+
});
|
|
117
|
+
/** Which of `rows`' objects `caller` mayn't know are listed, asked for each of `oids`, as `unseenOf` says. */
|
|
118
|
+
const unseenRows = (caller, repo, oids, rows) => {
|
|
119
|
+
const listed = /* @__PURE__ */ new Map();
|
|
120
|
+
for (const [oid, { listed: row }] of rows) if (row !== void 0) listed.set(oid, row);
|
|
121
|
+
return unseenOf(caller, repo, oids, listed);
|
|
122
|
+
};
|
|
72
123
|
const isoOf = (at) => DateTime.formatIso(DateTime.makeUnsafe(at));
|
|
73
124
|
/** An action back to this server, sending the request's own credentials. */
|
|
74
125
|
const ownAction = (call, path, expiresAt) => {
|
|
@@ -97,9 +148,15 @@ const batch = /* @__PURE__ */ Effect.fnUntraced(function* (parts, call) {
|
|
|
97
148
|
if (body.objects.length > 1e3) return yield* fail("RESOURCE_EXHAUSTED", `A batch names at most ${batchMost} objects`);
|
|
98
149
|
const upload = body.operation === "upload";
|
|
99
150
|
const repo = yield* openFor(call.caller, call.repo, upload);
|
|
100
|
-
const
|
|
151
|
+
const most = upload && parts.signed === void 0 ? parts.uploadMost : void 0;
|
|
152
|
+
const refusalOf = (oid, size) => {
|
|
153
|
+
if (!isLfsOid(oid)) return "An oid is a SHA-256, as 64 lowercase hex digits";
|
|
154
|
+
if (!validSize(size)) return `A size is 0 to ${largestObject} bytes`;
|
|
155
|
+
return most !== void 0 && size > most.bytes ? pastMost(most) : void 0;
|
|
156
|
+
};
|
|
157
|
+
const valid = body.objects.filter(({ oid, size }) => refusalOf(oid, size) === void 0);
|
|
101
158
|
const answers = upload ? yield* uploads(parts, call, repo, valid) : yield* downloads(parts, call, repo, valid);
|
|
102
|
-
const objects = body.objects.map(({ oid, size }) => answers.get(oid) ?? objectError(oid, size, 422,
|
|
159
|
+
const objects = body.objects.map(({ oid, size }) => answers.get(oid) ?? objectError(oid, size, 422, refusalOf(oid, size) ?? ""));
|
|
103
160
|
return lfsAnswer(200, {
|
|
104
161
|
transfer: "basic",
|
|
105
162
|
objects,
|
|
@@ -107,9 +164,32 @@ const batch = /* @__PURE__ */ Effect.fnUntraced(function* (parts, call) {
|
|
|
107
164
|
});
|
|
108
165
|
});
|
|
109
166
|
const validSize = (size) => Number.isSafeInteger(size) && size >= 0 && size <= largestObject;
|
|
167
|
+
/**
|
|
168
|
+
* The host's fetch rules' refusals of `listed`'s objects, each listed object the caller knows of
|
|
169
|
+
* asked once, before any link is signed. A host's failure fails the whole batch.
|
|
170
|
+
*/
|
|
171
|
+
const refusedOf = /* @__PURE__ */ Effect.fnUntraced(function* (call, listed) {
|
|
172
|
+
const refused = /* @__PURE__ */ new Map();
|
|
173
|
+
for (const [oid, { size }] of listed) {
|
|
174
|
+
const target = {
|
|
175
|
+
kind: "lfs",
|
|
176
|
+
oid,
|
|
177
|
+
size
|
|
178
|
+
};
|
|
179
|
+
const refusal = yield* readRefusal(call.repo, {
|
|
180
|
+
caller: call.caller,
|
|
181
|
+
target,
|
|
182
|
+
request: call.request
|
|
183
|
+
});
|
|
184
|
+
if (refusal !== void 0) refused.set(oid, refusal);
|
|
185
|
+
}
|
|
186
|
+
return refused;
|
|
187
|
+
});
|
|
110
188
|
const downloads = /* @__PURE__ */ Effect.fnUntraced(function* (parts, call, repo, objects) {
|
|
111
189
|
const oids = objects.map(({ oid }) => oid);
|
|
112
|
-
const
|
|
190
|
+
const chained = yield* chainListed(parts.rows, repo.internalId, oids);
|
|
191
|
+
const listed = yield* seenListed(call.caller, repo, oids, chained);
|
|
192
|
+
const refused = yield* refusedOf(call, listed);
|
|
113
193
|
const expiresAt = (yield* Clock$1.currentTimeMillis) + linkLife;
|
|
114
194
|
const answers = /* @__PURE__ */ new Map();
|
|
115
195
|
for (const { oid, size } of objects) {
|
|
@@ -118,6 +198,11 @@ const downloads = /* @__PURE__ */ Effect.fnUntraced(function* (parts, call, repo
|
|
|
118
198
|
answers.set(oid, objectError(oid, size, 404, "Object does not exist"));
|
|
119
199
|
continue;
|
|
120
200
|
}
|
|
201
|
+
const refusal = refused.get(oid);
|
|
202
|
+
if (refusal !== void 0) {
|
|
203
|
+
answers.set(oid, objectError(oid, size, httpStatus[refusal.code], refusal.message));
|
|
204
|
+
continue;
|
|
205
|
+
}
|
|
121
206
|
const key = row.key;
|
|
122
207
|
const signed = parts.signed;
|
|
123
208
|
const download = signed === void 0 ? ownAction(call, `objects/${oid}`, expiresAt) : {
|
|
@@ -136,17 +221,19 @@ const downloads = /* @__PURE__ */ Effect.fnUntraced(function* (parts, call, repo
|
|
|
136
221
|
/**
|
|
137
222
|
* Upload links for the objects not yet listed. Each gets its upload row first, in one commit at
|
|
138
223
|
* the read's version, so upkeep, which deletes an unlisted object's bytes only past its row's
|
|
139
|
-
* `removeAt`, never deletes bytes a link given now may still write.
|
|
140
|
-
* so its links all write one key
|
|
224
|
+
* `removeAt`, never deletes bytes a link given now may still write. Each row is the caller's own,
|
|
225
|
+
* and a row kept keeps its generation, so its links all write one key no other caller's write; a
|
|
226
|
+
* new row gets a new one.
|
|
141
227
|
*/
|
|
142
228
|
const uploads = /* @__PURE__ */ Effect.fnUntraced(function* (parts, call, repo, objects) {
|
|
143
229
|
const oids = objects.map(({ oid }) => oid);
|
|
144
230
|
for (let tries = 0; tries < 5; tries += 1) {
|
|
145
231
|
const at = yield* Clock$1.currentTimeMillis;
|
|
146
232
|
const read = yield* objectRows(parts.rows, call.caller, repo, oids);
|
|
233
|
+
const unseen = yield* unseenRows(call.caller, repo, oids, read.rows);
|
|
147
234
|
const expiresAt = at + linkLife;
|
|
148
235
|
const removeAt = expiresAt + uploadGrace;
|
|
149
|
-
const put = objects.filter(({ oid }) => read.rows.get(oid)?.listed === void 0).map(({ oid, size }) => {
|
|
236
|
+
const put = objects.filter(({ oid }) => read.rows.get(oid)?.listed === void 0 || unseen.has(oid)).map(({ oid, size }) => {
|
|
150
237
|
const before = read.rows.get(oid)?.upload;
|
|
151
238
|
const value = {
|
|
152
239
|
size,
|
|
@@ -155,18 +242,21 @@ const uploads = /* @__PURE__ */ Effect.fnUntraced(function* (parts, call, repo,
|
|
|
155
242
|
generation: before?.generation ?? randomText(16)
|
|
156
243
|
};
|
|
157
244
|
return {
|
|
158
|
-
|
|
159
|
-
|
|
245
|
+
oid,
|
|
246
|
+
row: {
|
|
247
|
+
...uploadKey(oid, read.uploader),
|
|
248
|
+
value
|
|
249
|
+
}
|
|
160
250
|
};
|
|
161
251
|
});
|
|
162
252
|
if (put.length > 0) {
|
|
163
253
|
if (!(yield* parts.rows.commit(repo.internalId, read.version, {
|
|
164
|
-
put,
|
|
254
|
+
put: put.map(({ row }) => row),
|
|
165
255
|
wake: removeAt
|
|
166
256
|
})).ok) continue;
|
|
167
257
|
}
|
|
168
258
|
const answers = /* @__PURE__ */ new Map();
|
|
169
|
-
const generations = new Map(put.map((row) => [
|
|
259
|
+
const generations = new Map(put.map(({ oid, row }) => [oid, row.value.generation]));
|
|
170
260
|
for (const { oid, size } of objects) {
|
|
171
261
|
const generation = generations.get(oid);
|
|
172
262
|
const key = generation === void 0 ? void 0 : objectKey(repo.internalId, oid, generation);
|
|
@@ -199,32 +289,41 @@ const uploadActions = /* @__PURE__ */ Effect.fnUntraced(function* (parts, call,
|
|
|
199
289
|
});
|
|
200
290
|
/**
|
|
201
291
|
* `POST objects/verify`, after a signed upload: lists the object once the bucket holds bytes at
|
|
202
|
-
*
|
|
203
|
-
* upkeep's commit that drops the upload row to
|
|
204
|
-
* expects.
|
|
292
|
+
* the caller's own upload row's key that it checked against its oid, which only the caller's links
|
|
293
|
+
* wrote. The rows are read before the bucket, so upkeep's commit that drops the upload row to
|
|
294
|
+
* delete the bytes moves the version this commit expects.
|
|
205
295
|
*/
|
|
206
296
|
const verify = /* @__PURE__ */ Effect.fnUntraced(function* (parts, call) {
|
|
207
297
|
const { oid, size } = yield* bodyOf(call.request, VerifyRequest);
|
|
208
298
|
if (!isLfsOid(oid)) return yield* fail("INVALID_ARGUMENT", "An oid is a SHA-256, as 64 lowercase hex digits");
|
|
209
|
-
const { rows:
|
|
299
|
+
const { rows: registered, signed } = parts;
|
|
210
300
|
const repo = yield* openFor(call.caller, call.repo, true);
|
|
301
|
+
const writer = yield* ownWriter(call.caller);
|
|
211
302
|
for (let tries = 0; tries < 5; tries += 1) {
|
|
212
|
-
const
|
|
303
|
+
const at = yield* Clock$1.currentTimeMillis;
|
|
304
|
+
const read = yield* objectRows(registered, call.caller, repo, [oid]);
|
|
213
305
|
const rows = read.rows.get(oid);
|
|
214
|
-
|
|
306
|
+
const unseen = (yield* unseenRows(call.caller, repo, [oid], read.rows)).has(oid);
|
|
307
|
+
if (rows?.listed !== void 0 && !unseen) return lfsAnswer(200, { message: "Verified" });
|
|
215
308
|
const key = rows?.upload === void 0 ? void 0 : objectKey(repo.internalId, oid, rows.upload.generation);
|
|
216
309
|
const stored = signed === void 0 || key === void 0 ? void 0 : yield* bucketCall(Effect.map(signed.head(key), Option.getOrUndefined));
|
|
217
310
|
if (stored?.sha256 !== oid) return yield* fail("FAILED_PRECONDITION", "The bucket holds no bytes for this object", { hint: "Upload it again" });
|
|
218
311
|
if (stored.size !== size) return yield* fail("INVALID_ARGUMENT", `This object is ${stored.size} bytes, not ${size}`);
|
|
219
|
-
|
|
312
|
+
const own = writer === void 0 ? [] : [uploadedRow(writer, oid, at)];
|
|
313
|
+
const writes = unseen ? { put: own } : {
|
|
220
314
|
put: [{
|
|
221
315
|
...listedKey(oid),
|
|
222
316
|
value: {
|
|
223
317
|
size: stored.size,
|
|
224
318
|
key
|
|
225
319
|
}
|
|
226
|
-
}],
|
|
227
|
-
delete: [uploadKey(oid)]
|
|
320
|
+
}, ...own],
|
|
321
|
+
delete: [uploadKey(oid, read.uploader)]
|
|
322
|
+
};
|
|
323
|
+
if (writes.put.length === 0) return lfsAnswer(200, { message: "Verified" });
|
|
324
|
+
if ((yield* registered.commit(repo.internalId, read.version, {
|
|
325
|
+
...writes,
|
|
326
|
+
wake: sweepDue(at)
|
|
228
327
|
})).ok) return lfsAnswer(200, { message: "Verified" });
|
|
229
328
|
}
|
|
230
329
|
return yield* contended();
|
|
@@ -236,17 +335,23 @@ const verify = /* @__PURE__ */ Effect.fnUntraced(function* (parts, call) {
|
|
|
236
335
|
*/
|
|
237
336
|
const receive = /* @__PURE__ */ Effect.fnUntraced(function* (parts, call, oid) {
|
|
238
337
|
if (!isLfsOid(oid)) return yield* fail("INVALID_ARGUMENT", "An oid is a SHA-256, as 64 lowercase hex digits");
|
|
239
|
-
const
|
|
338
|
+
const length = lengthOf(call.request);
|
|
339
|
+
if (length === void 0) return lfsAnswer(411, { message: noLength });
|
|
340
|
+
if (length > parts.uploadMost.bytes) return lfsAnswer(413, { message: pastMost(parts.uploadMost) });
|
|
341
|
+
const { rows: registered, bucket } = parts;
|
|
240
342
|
const repo = yield* openFor(call.caller, call.repo, true);
|
|
241
343
|
const started = yield* Clock$1.currentTimeMillis;
|
|
242
|
-
const
|
|
243
|
-
|
|
344
|
+
const read = yield* objectRows(registered, call.caller, repo, [oid]);
|
|
345
|
+
const rows = read.rows.get(oid);
|
|
346
|
+
const unseen = (yield* unseenRows(call.caller, repo, [oid], read.rows)).has(oid);
|
|
347
|
+
if (rows?.listed !== void 0 && !unseen) return yield* answered(call.request);
|
|
244
348
|
const upload = rows?.upload;
|
|
245
349
|
if (upload === void 0 || upload.expiresAt < started) return yield* fail("FAILED_PRECONDITION", "No upload link for this object is live", { hint: "Ask the batch API again" });
|
|
350
|
+
if (upload.size > parts.uploadMost.bytes) return lfsAnswer(413, { message: pastMost(parts.uploadMost) });
|
|
246
351
|
const id = randomText(16);
|
|
247
352
|
const key = stagingKey(repo.internalId, id);
|
|
248
353
|
const staged = stagingId(started + uploadGrace, id);
|
|
249
|
-
yield*
|
|
354
|
+
yield* registered.add(repo.internalId, {
|
|
250
355
|
put: [{
|
|
251
356
|
collection: lfsCollections.staging,
|
|
252
357
|
id: staged,
|
|
@@ -258,23 +363,44 @@ const receive = /* @__PURE__ */ Effect.fnUntraced(function* (parts, call, oid) {
|
|
|
258
363
|
wake: started + uploadGrace
|
|
259
364
|
});
|
|
260
365
|
const hashed = hashing(call.request.body, upload.size);
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
});
|
|
268
|
-
yield* Effect.uninterruptible(bucketDo(bucket.put(key, body, { size: upload.size }))).pipe(Effect.mapError((error) => hashed.past() ? pastSize(upload.size) : error));
|
|
269
|
-
if (hashed.sha256() !== oid) return yield* fail("INVALID_ARGUMENT", "The bytes' SHA-256 isn't the oid");
|
|
270
|
-
return yield* listStaged(claimed, call.caller, repo, {
|
|
366
|
+
yield* Effect.uninterruptible(bucketDo(bucket.put(key, hashed.body, { size: upload.size }))).pipe(Effect.mapError((error) => hashed.past() ? pastSize(upload.size) : error));
|
|
367
|
+
if ((yield* hashed.hasher.hex) !== oid) {
|
|
368
|
+
yield* dropStaged(parts, repo.internalId, key, staged);
|
|
369
|
+
return yield* fail("INVALID_ARGUMENT", "The bytes' SHA-256 isn't the oid");
|
|
370
|
+
}
|
|
371
|
+
return yield* listStaged(registered, call.caller, repo, {
|
|
271
372
|
oid,
|
|
272
373
|
size: upload.size,
|
|
273
374
|
key,
|
|
274
375
|
staged,
|
|
275
|
-
deadline: started + streamMost
|
|
376
|
+
deadline: started + streamMost,
|
|
377
|
+
unseen
|
|
276
378
|
});
|
|
277
379
|
});
|
|
380
|
+
/**
|
|
381
|
+
* Deletes refused bytes at once, then their staging row at the version it's read at (#1940). A
|
|
382
|
+
* failure of either leaves the row, whose wake has upkeep delete the bytes at its removeAt, and is
|
|
383
|
+
* no reason to answer it in place of the refusal.
|
|
384
|
+
*/
|
|
385
|
+
const dropStaged = /* @__PURE__ */ Effect.fnUntraced(function* (parts, repo, key, staged) {
|
|
386
|
+
const row = {
|
|
387
|
+
collection: lfsCollections.staging,
|
|
388
|
+
id: staged
|
|
389
|
+
};
|
|
390
|
+
yield* bestEffort(Effect.gen(function* () {
|
|
391
|
+
yield* bucketDo(parts.bucket.remove(key));
|
|
392
|
+
const read = yield* parts.rows.read(repo, [row]);
|
|
393
|
+
yield* parts.rows.commit(repo, read.version, { delete: [row] });
|
|
394
|
+
}));
|
|
395
|
+
});
|
|
396
|
+
/** Why a PUT with no `content-length` is refused. */
|
|
397
|
+
const noLength = "An upload needs its Content-Length: git-lfs sends one, and this request had none";
|
|
398
|
+
/** A request's `content-length`, or none where it has none, or one that isn't a length. */
|
|
399
|
+
const lengthOf = (request) => {
|
|
400
|
+
const header = request.headers.get("content-length");
|
|
401
|
+
const length = header === null || !/^\d+$/.test(header) ? NaN : Number(header);
|
|
402
|
+
return Number.isSafeInteger(length) ? length : void 0;
|
|
403
|
+
};
|
|
278
404
|
const pastSize = (size) => gitError("INVALID_ARGUMENT", `The bytes run past the ${size} the batch named`);
|
|
279
405
|
/**
|
|
280
406
|
* An answer to a request whose body isn't needed: the body is let go first, and a cancel that
|
|
@@ -284,54 +410,86 @@ const answered = (request) => Effect.promise(async () => {
|
|
|
284
410
|
await request.body?.cancel();
|
|
285
411
|
return lfsAnswer(200, { message: "Already uploaded" });
|
|
286
412
|
});
|
|
287
|
-
/**
|
|
413
|
+
/**
|
|
414
|
+
* `body` as it streams to the bucket, counted, and hashed through the runtime's own SHA-256, each
|
|
415
|
+
* chunk's write awaited before it goes on, failing past `most` bytes.
|
|
416
|
+
*/
|
|
288
417
|
const hashing = (body, most) => {
|
|
289
|
-
const
|
|
418
|
+
const hasher = nativeSha256Hasher();
|
|
290
419
|
let size = 0;
|
|
291
|
-
const
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
420
|
+
const read = Stream.fromReadableStream({
|
|
421
|
+
evaluate: () => body ?? new ReadableStream({ start: (controller) => controller.close() }),
|
|
422
|
+
onError: (cause) => new Unavailable({
|
|
423
|
+
message: bucketFailed,
|
|
424
|
+
cause
|
|
425
|
+
})
|
|
426
|
+
});
|
|
297
427
|
return {
|
|
298
|
-
|
|
428
|
+
body: Stream.mapEffect(read, (chunk) => {
|
|
429
|
+
size += chunk.length;
|
|
430
|
+
if (size > most) return Effect.fail(pastSize(most));
|
|
431
|
+
return Effect.as(hasher.write(chunk), chunk);
|
|
432
|
+
}),
|
|
299
433
|
past: () => size > most,
|
|
300
|
-
|
|
434
|
+
hasher
|
|
301
435
|
};
|
|
302
436
|
};
|
|
303
437
|
/** Lists a Worker upload's bytes at their staging key, in the commit that drops its staging row. */
|
|
304
|
-
const listStaged = /* @__PURE__ */ Effect.fnUntraced(function* (
|
|
438
|
+
const listStaged = /* @__PURE__ */ Effect.fnUntraced(function* (registered, caller, repo, staged) {
|
|
439
|
+
const writer = yield* ownWriter(caller);
|
|
305
440
|
for (let tries = 0; tries < 5; tries += 1) {
|
|
306
|
-
const
|
|
307
|
-
|
|
441
|
+
const at = yield* Clock$1.currentTimeMillis;
|
|
442
|
+
const own = writer === void 0 ? [] : [uploadedRow(writer, staged.oid, at)];
|
|
443
|
+
const read = yield* objectRows(registered, caller, repo, [staged.oid], [stagingRead(staged.staged)]);
|
|
444
|
+
if (read.rows.get(staged.oid)?.listed !== void 0) {
|
|
445
|
+
const answer = lfsAnswer(200, { message: staged.unseen ? "Uploaded" : "Already uploaded" });
|
|
446
|
+
if (own.length === 0) return answer;
|
|
447
|
+
if ((yield* registered.commit(repo.internalId, read.version, {
|
|
448
|
+
put: own,
|
|
449
|
+
wake: sweepDue(at)
|
|
450
|
+
})).ok) return answer;
|
|
451
|
+
continue;
|
|
452
|
+
}
|
|
308
453
|
if ((read.also[0] ?? []).length === 0 || (yield* Clock$1.currentTimeMillis) > staged.deadline) return yield* fail("DEADLINE_EXCEEDED", "The upload ran too long", { hint: "Upload it again" });
|
|
309
|
-
if ((yield*
|
|
454
|
+
if ((yield* registered.commit(repo.internalId, read.version, {
|
|
310
455
|
put: [{
|
|
311
456
|
...listedKey(staged.oid),
|
|
312
457
|
value: {
|
|
313
458
|
size: staged.size,
|
|
314
459
|
key: staged.key
|
|
315
460
|
}
|
|
316
|
-
}],
|
|
317
|
-
delete: [uploadKey(staged.oid), {
|
|
461
|
+
}, ...own],
|
|
462
|
+
delete: [uploadKey(staged.oid, read.uploader), {
|
|
318
463
|
collection: lfsCollections.staging,
|
|
319
464
|
id: staged.staged
|
|
320
|
-
}]
|
|
465
|
+
}],
|
|
466
|
+
wake: sweepDue(at)
|
|
321
467
|
})).ok) return lfsAnswer(200, { message: "Uploaded" });
|
|
322
468
|
}
|
|
323
469
|
return yield* contended();
|
|
324
470
|
});
|
|
325
471
|
/**
|
|
326
|
-
* A listed object's bytes, the repo's own or a source's, once the caller may read the repo
|
|
327
|
-
* `
|
|
472
|
+
* A listed object's bytes, the repo's own or a source's, once the caller may read the repo and
|
|
473
|
+
* knows of the object, as `unseenOf` says: else it answers as one never uploaded. The host's fetch
|
|
474
|
+
* rules are asked of it then, before the bucket's stream opens, and their refusal or failure is
|
|
475
|
+
* the read's. `signal` aborted cancels the bucket's stream, opening or open.
|
|
328
476
|
*/
|
|
329
477
|
const objectOf = /* @__PURE__ */ Effect.fnUntraced(function* (parts, read) {
|
|
330
478
|
const { oid, size, signal } = read;
|
|
331
479
|
if (!isLfsOid(oid)) return yield* fail("NOT_FOUND", "Object does not exist");
|
|
332
480
|
const repo = yield* openFor(read.caller, read.repo, false, read.internalId);
|
|
333
|
-
const
|
|
481
|
+
const chained = yield* chainListed(parts.rows, repo.internalId, [oid]);
|
|
482
|
+
const listed = (yield* seenListed(read.caller, repo, [oid], chained)).get(oid);
|
|
334
483
|
if (listed === void 0 || size !== void 0 && size !== listed.size) return yield* fail("NOT_FOUND", "Object does not exist");
|
|
484
|
+
yield* checkRead(read.repo, {
|
|
485
|
+
caller: read.caller,
|
|
486
|
+
target: {
|
|
487
|
+
kind: "lfs",
|
|
488
|
+
oid,
|
|
489
|
+
size: listed.size
|
|
490
|
+
},
|
|
491
|
+
request: read.request
|
|
492
|
+
});
|
|
335
493
|
const stream = yield* bucketStream(parts.bucket, listed.key);
|
|
336
494
|
if (stream === void 0) return yield* fail("DATA_LOSS", `LFS object ${oid}'s bytes are missing`);
|
|
337
495
|
const bytes = signal === void 0 ? stream : stream.pipeThrough(new TransformStream(), { signal });
|
|
@@ -341,12 +499,18 @@ const objectOf = /* @__PURE__ */ Effect.fnUntraced(function* (parts, read) {
|
|
|
341
499
|
bytes
|
|
342
500
|
};
|
|
343
501
|
});
|
|
344
|
-
/**
|
|
502
|
+
/**
|
|
503
|
+
* `GET objects/<oid>`, a Worker download: a listed object's bytes, the repo's own or a source's,
|
|
504
|
+
* as `objectOf` reads them. Its fetch rules are asked again, though the batch that gave the link
|
|
505
|
+
* asked them: the link outlives that answer, and a signed bucket's link, which the bucket serves,
|
|
506
|
+
* is asked only at the batch.
|
|
507
|
+
*/
|
|
345
508
|
const send = /* @__PURE__ */ Effect.fnUntraced(function* (parts, call, oid) {
|
|
346
509
|
const object = yield* objectOf(parts, {
|
|
347
510
|
caller: call.caller,
|
|
348
511
|
repo: call.repo,
|
|
349
|
-
oid
|
|
512
|
+
oid,
|
|
513
|
+
request: call.request
|
|
350
514
|
});
|
|
351
515
|
return new Response(object.bytes, {
|
|
352
516
|
status: 200,
|