@ref0/git 0.3.0 → 0.4.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/_virtual/_rolldown/runtime.mjs +12 -0
- package/dist/access/private-refs.d.mts +12 -9
- package/dist/access/private-refs.mjs +69 -46
- package/dist/auth/access-jwt.mjs +7 -7
- package/dist/auth/auth.d.mts +41 -0
- package/dist/auth/auth.mjs +39 -0
- package/dist/auth/authorize.mjs +57 -80
- package/dist/auth/bridge.mjs +30 -0
- package/dist/auth/fences.d.mts +22 -2
- package/dist/auth/fences.mjs +3 -3
- package/dist/auth/grants.d.mts +25 -0
- package/dist/auth/grants.mjs +29 -34
- package/dist/auth/helpers.mjs +4 -4
- package/dist/auth/host-function.d.mts +9 -2
- package/dist/auth/host-function.mjs +35 -8
- package/dist/auth/identify.d.mts +3 -0
- package/dist/auth/identify.mjs +9 -11
- package/dist/auth/namespaces.d.mts +3 -0
- package/dist/auth/policy.d.mts +57 -0
- package/dist/auth/policy.mjs +56 -0
- package/dist/auth/token-rows.mjs +6 -6
- package/dist/auth/token-text.mjs +16 -4
- package/dist/auth/tokens.d.mts +3 -0
- package/dist/auth/tokens.mjs +51 -13
- package/dist/auth.d.mts +2 -1
- package/dist/auth.mjs +2 -1
- package/dist/client/answer.mjs +49 -11
- package/dist/client/client.d.mts +2 -2
- package/dist/client/client.mjs +3 -3
- package/dist/client/git-http.d.mts +6 -0
- package/dist/client/git-http.mjs +23 -36
- package/dist/client/helper-node.d.mts +12 -0
- package/dist/client/helper-node.mjs +108 -5
- package/dist/client/local.mjs +94 -99
- package/dist/client/negotiate.mjs +10 -8
- package/dist/client/push-upload.d.mts +14 -0
- package/dist/client/push-upload.mjs +12 -12
- package/dist/client/remote-helper.mjs +22 -20
- package/dist/client/remote.mjs +28 -22
- package/dist/client/run-remote-helper.d.mts +40 -16
- package/dist/client/run-remote-helper.mjs +147 -154
- package/dist/client/scrub.d.mts +8 -2
- package/dist/client/scrub.mjs +76 -4
- package/dist/client/slice-push.d.mts +77 -0
- package/dist/client/slice-push.mjs +169 -0
- package/dist/client/slice-report.mjs +188 -0
- package/dist/client/slices.d.mts +44 -0
- package/dist/client/slices.mjs +131 -0
- package/dist/client/transport.d.mts +1 -0
- package/dist/client/transport.mjs +30 -26
- package/dist/contracts/access.d.mts +36 -9
- package/dist/contracts/actors.d.mts +28 -10
- package/dist/contracts/actors.mjs +17 -0
- package/dist/contracts/authorize.d.mts +77 -0
- package/dist/contracts/authorize.mjs +25 -0
- package/dist/contracts/blobs.d.mts +48 -15
- package/dist/contracts/blobs.mjs +30 -0
- package/dist/contracts/calls-spent.d.mts +1 -0
- package/dist/contracts/calls-spent.mjs +58 -18
- package/dist/contracts/client.d.mts +14 -16
- package/dist/contracts/commits.d.mts +558 -76
- package/dist/contracts/commits.mjs +147 -0
- package/dist/contracts/engine.d.mts +91 -55
- package/dist/contracts/engine.mjs +103 -0
- package/dist/contracts/events.d.mts +1382 -205
- package/dist/contracts/events.mjs +485 -0
- package/dist/contracts/files.d.mts +295 -50
- package/dist/contracts/files.mjs +100 -0
- package/dist/contracts/forks.d.mts +306 -25
- package/dist/contracts/forks.mjs +39 -0
- package/dist/contracts/git.d.mts +107 -0
- package/dist/contracts/git.mjs +23 -0
- package/dist/contracts/grants.d.mts +2 -2
- package/dist/contracts/ids.d.mts +23 -8
- package/dist/contracts/ids.mjs +40 -5
- package/dist/contracts/lfs.d.mts +9 -4
- package/dist/contracts/merges.d.mts +68 -16
- package/dist/contracts/merges.mjs +27 -0
- package/dist/contracts/namespaces.d.mts +14 -0
- package/dist/contracts/object-values.d.mts +96 -0
- package/dist/contracts/object-values.mjs +104 -0
- package/dist/contracts/objects.d.mts +323 -87
- package/dist/contracts/operations.d.mts +24 -16
- package/dist/contracts/promises.d.mts +13 -2
- package/dist/contracts/push-uploads.d.mts +39 -24
- package/dist/contracts/push-uploads.mjs +54 -0
- package/dist/contracts/queue.d.mts +444 -139
- package/dist/contracts/queue.mjs +197 -0
- package/dist/contracts/refs.d.mts +248 -45
- package/dist/contracts/refs.mjs +117 -0
- package/dist/contracts/repo-records.d.mts +34 -0
- package/dist/contracts/repo-records.mjs +18 -0
- package/dist/contracts/repos.d.mts +411 -58
- package/dist/contracts/repos.mjs +136 -0
- package/dist/contracts/result.d.mts +335 -69
- package/dist/contracts/result.mjs +350 -5
- package/dist/contracts/rules.d.mts +60 -48
- package/dist/contracts/rules.mjs +9 -0
- package/dist/contracts/server.d.mts +113 -47
- package/dist/contracts/services.d.mts +15 -24
- package/dist/contracts/services.mjs +5 -9
- package/dist/contracts/signin.d.mts +64 -31
- package/dist/contracts/signin.mjs +18 -0
- package/dist/contracts/store.d.mts +45 -5
- package/dist/contracts/store.mjs +31 -0
- package/dist/contracts/sync.d.mts +81 -46
- package/dist/contracts/sync.mjs +41 -2
- package/dist/contracts/tags.d.mts +204 -22
- package/dist/contracts/tags.mjs +51 -1
- package/dist/contracts/tokens.d.mts +32 -7
- package/dist/contracts/tokens.mjs +31 -1
- package/dist/contracts/topics.d.mts +123 -67
- package/dist/contracts/topics.mjs +109 -0
- package/dist/contracts/trees.d.mts +132 -52
- package/dist/contracts/trees.mjs +105 -0
- package/dist/contracts/work.d.mts +127 -20
- package/dist/contracts/work.mjs +69 -0
- package/dist/core/access.d.mts +25 -14
- package/dist/core/access.mjs +77 -108
- package/dist/core/ancestry.mjs +86 -18
- package/dist/core/call-names.mjs +1 -0
- package/dist/core/call-services.mjs +73 -0
- package/dist/core/changes.d.mts +31 -0
- package/dist/core/changes.mjs +5 -0
- package/dist/core/clock.mjs +3 -3
- package/dist/core/events/deliver.mjs +119 -33
- package/dist/core/events/seen.mjs +124 -0
- package/dist/core/forks.mjs +371 -159
- package/dist/core/hooks/order.d.mts +9 -0
- package/dist/core/hooks/order.mjs +25 -0
- package/dist/core/hooks/post-receive.mjs +13 -12
- package/dist/core/hooks/pre-receive.d.mts +8 -1
- package/dist/core/hooks/pre-receive.mjs +8 -6
- package/dist/core/imports.mjs +212 -0
- package/dist/core/index-job.mjs +131 -38
- package/dist/core/merge-parts.d.mts +30 -0
- package/dist/core/merge-parts.mjs +31 -0
- package/dist/core/names.mjs +4 -16
- package/dist/core/namespaces.d.mts +2 -0
- package/dist/core/objects/blobs.mjs +4 -4
- package/dist/core/objects/commit-writes.mjs +19 -17
- package/dist/core/objects/commits.mjs +12 -12
- package/dist/core/objects/files.mjs +10 -11
- package/dist/core/objects/lines.mjs +15 -32
- package/dist/core/objects/merges.mjs +4 -4
- package/dist/core/objects/objects-layer.d.mts +21 -0
- package/dist/core/objects/objects-layer.mjs +47 -0
- package/dist/core/objects/objects-namespace.d.mts +6 -0
- package/dist/core/objects/objects-namespace.mjs +13 -0
- package/dist/core/objects/objects.d.mts +49 -0
- package/dist/core/objects/objects.mjs +18 -0
- package/dist/core/objects/peel.mjs +3 -3
- package/dist/core/objects/reading.mjs +135 -40
- package/dist/core/objects/tags.mjs +7 -7
- package/dist/core/objects/tree-edits.mjs +40 -27
- package/dist/core/objects/trees.mjs +23 -18
- package/dist/core/objects/writing.mjs +43 -44
- package/dist/core/own-writes.mjs +3 -3
- package/dist/core/parts.d.mts +125 -0
- package/dist/core/parts.mjs +59 -0
- package/dist/core/promise.mjs +13 -9
- package/dist/core/publish.mjs +27 -17
- package/dist/core/purge.mjs +242 -0
- package/dist/core/push-decide.mjs +93 -28
- package/dist/core/push.mjs +300 -156
- package/dist/core/receipts.d.mts +4 -3
- package/dist/core/receipts.mjs +20 -12
- package/dist/core/ref-conflicts.mjs +70 -4
- package/dist/core/ref-index-job.mjs +181 -0
- package/dist/core/ref-index.d.mts +25 -0
- package/dist/core/ref-index.mjs +136 -0
- package/dist/core/ref-view.mjs +166 -0
- package/dist/core/refs.mjs +313 -95
- package/dist/core/repack.d.mts +10 -0
- package/dist/core/repack.mjs +261 -81
- package/dist/core/repo-info.mjs +99 -0
- package/dist/core/repos.mjs +114 -80
- package/dist/core/rules/changes.mjs +48 -20
- package/dist/core/rules/check.mjs +29 -22
- package/dist/core/rules/commit-changes.d.mts +13 -0
- package/dist/core/rules/commit-changes.mjs +100 -91
- package/dist/core/rules/context.d.mts +67 -8
- package/dist/core/rules/context.mjs +88 -51
- package/dist/core/rules/facts.mjs +1 -1
- package/dist/core/rules/fetch.mjs +24 -26
- package/dist/core/rules/files.d.mts +13 -0
- package/dist/core/rules/files.mjs +27 -28
- package/dist/core/rules/namespace.d.mts +2 -0
- package/dist/core/rules/patterns.mjs +29 -5
- package/dist/core/rules/protect.d.mts +12 -6
- package/dist/core/rules/protect.mjs +22 -20
- package/dist/core/rules/rules-layer.d.mts +17 -0
- package/dist/core/rules/rules-layer.mjs +26 -0
- package/dist/core/rules/rules.d.mts +8 -0
- package/dist/core/rules/rules.mjs +16 -0
- package/dist/core/rules/service.mjs +18 -0
- package/dist/core/seam.d.mts +8 -5
- package/dist/core/seam.mjs +19 -15
- package/dist/core/tokens.mjs +29 -23
- package/dist/core/view.d.mts +105 -6
- package/dist/core/view.mjs +211 -109
- package/dist/core/work.mjs +40 -14
- package/dist/effect.d.mts +3 -4
- package/dist/effect.mjs +2 -3
- package/dist/engine/allotted-xdiff.d.mts +1 -0
- package/dist/engine/allotted-xdiff.mjs +1 -1
- package/dist/engine/attributes.mjs +1 -1
- package/dist/engine/combined.d.mts +18 -0
- package/dist/engine/combined.mjs +39 -44
- package/dist/engine/commits.mjs +5 -4
- package/dist/engine/content.d.mts +3 -2
- package/dist/engine/content.mjs +2 -2
- package/dist/engine/failures.d.mts +2 -2
- package/dist/engine/failures.mjs +2 -9
- package/dist/engine/merge-base-walk.d.mts +3 -2
- package/dist/engine/merge-base-walk.mjs +1 -1
- package/dist/engine/merge-bases.mjs +3 -2
- package/dist/engine/merge.mjs +568 -566
- package/dist/engine/parts.d.mts +3 -2
- package/dist/engine/parts.mjs +40 -7
- package/dist/engine/reads.d.mts +1 -0
- package/dist/engine/reads.mjs +5 -5
- package/dist/engine/walk.mjs +23 -24
- package/dist/engine/xdiff.d.mts +2 -33
- package/dist/engine/xdiff.mjs +6 -3
- package/dist/event-streams/event-streams.d.mts +25 -0
- package/dist/event-streams/event-streams.mjs +22 -0
- package/dist/event-streams/namespace.d.mts +2 -0
- package/dist/event-streams/stream.d.mts +42 -0
- package/dist/{core/events → event-streams}/stream.mjs +106 -49
- package/dist/extend.d.mts +4 -2
- package/dist/http/answers.mjs +8 -4
- package/dist/http/bodies.mjs +84 -56
- package/dist/http/core-parts.mjs +206 -60
- package/dist/http/handler.d.mts +2 -0
- package/dist/http/handler.mjs +17 -11
- package/dist/http/node.mjs +10 -6
- package/dist/http/parts.d.mts +12 -0
- package/dist/http/push-uploads.d.mts +9 -0
- package/dist/http/push-uploads.mjs +76 -66
- package/dist/http/receive-pack.mjs +162 -28
- package/dist/http/upload-pack.mjs +106 -81
- package/dist/index.d.mts +48 -28
- package/dist/index.mjs +29 -7
- package/dist/lfs/calls.mjs +2 -2
- package/dist/lfs/locks.mjs +24 -20
- package/dist/lfs/objects.d.mts +7 -0
- package/dist/lfs/objects.mjs +31 -26
- package/dist/lfs/pointers.mjs +7 -7
- package/dist/lfs/purge.mjs +50 -0
- package/dist/lfs/repo.mjs +5 -5
- package/dist/lfs/rows.mjs +8 -8
- package/dist/lfs/service.d.mts +9 -0
- package/dist/lfs/service.mjs +32 -25
- package/dist/lfs/upkeep.mjs +5 -5
- package/dist/lfs/wire.mjs +80 -38
- package/dist/merges/merges.d.mts +20 -0
- package/dist/merges/merges.mjs +32 -0
- package/dist/merges/namespace.d.mts +2 -0
- package/dist/merges/public.d.mts +6 -0
- package/dist/merges/public.mjs +10 -0
- package/dist/node.d.mts +1 -2
- package/dist/node.mjs +1 -3
- package/dist/protocol/bytes/buffers.d.mts +9 -3
- package/dist/protocol/bytes/buffers.mjs +11 -5
- package/dist/protocol/bytes/deflate.d.mts +7 -5
- package/dist/protocol/bytes/deflate.mjs +59 -23
- package/dist/protocol/bytes/inflate.d.mts +4 -3
- package/dist/protocol/bytes/inflate.mjs +61 -26
- package/dist/protocol/bytes/reader.mjs +61 -0
- package/dist/protocol/bytes/sha1-hasher.d.mts +3 -1
- package/dist/protocol/bytes/sha1-hasher.mjs +13 -3
- package/dist/protocol/bytes/sha1.d.mts +1 -1
- package/dist/protocol/bytes/sha1.mjs +5 -5
- package/dist/protocol/bytes/streams.mjs +16 -6
- package/dist/protocol/diff/patch.d.mts +4 -0
- package/dist/protocol/diff/patch.mjs +1 -1
- package/dist/protocol/diff/paths.mjs +1 -1
- package/dist/protocol/diff/read.d.mts +1 -1
- package/dist/protocol/diff/read.mjs +102 -90
- package/dist/protocol/framing/pkt-line.d.mts +1 -0
- package/dist/protocol/framing/pkt-line.mjs +40 -6
- package/dist/protocol/objects/checked-blobs.d.mts +1 -0
- package/dist/protocol/objects/fsck.mjs +7 -1
- package/dist/protocol/objects/held.mjs +5 -11
- package/dist/protocol/objects/ident.mjs +1 -1
- package/dist/protocol/objects/object-rules.mjs +15 -7
- package/dist/protocol/objects/object.d.mts +6 -2
- package/dist/protocol/objects/object.mjs +5 -2
- package/dist/protocol/objects/tag.d.mts +3 -1
- package/dist/protocol/objects/tag.mjs +27 -1
- package/dist/protocol/objects/tree.mjs +1 -1
- package/dist/protocol/packs/delta.d.mts +1 -1
- package/dist/protocol/packs/delta.mjs +2 -2
- package/dist/protocol/packs/graph.mjs +55 -56
- package/dist/protocol/packs/idx.d.mts +4 -2
- package/dist/protocol/packs/idx.mjs +156 -63
- package/dist/protocol/packs/indexer.d.mts +22 -4
- package/dist/protocol/packs/indexer.mjs +14 -35
- package/dist/protocol/packs/parts.mjs +5 -5
- package/dist/protocol/packs/pos.mjs +12 -5
- package/dist/protocol/packs/reader.d.mts +19 -12
- package/dist/protocol/packs/reader.mjs +252 -25
- package/dist/protocol/packs/rev.d.mts +1 -1
- package/dist/protocol/packs/rev.mjs +42 -24
- package/dist/protocol/packs/types-file.mjs +85 -0
- package/dist/protocol/packs/write-error.d.mts +1 -1
- package/dist/protocol/packs/write-error.mjs +2 -2
- package/dist/protocol/packs/writer.d.mts +40 -15
- package/dist/protocol/packs/writer.mjs +142 -49
- package/dist/protocol/wire/advertisement.d.mts +39 -14
- package/dist/protocol/wire/advertisement.mjs +127 -31
- package/dist/protocol/wire/fetch.d.mts +57 -19
- package/dist/protocol/wire/fetch.mjs +57 -26
- package/dist/protocol/wire/json.mjs +25 -0
- package/dist/protocol/wire/lines.d.mts +10 -0
- package/dist/protocol/wire/lines.mjs +20 -6
- package/dist/protocol/wire/push-limits.d.mts +6 -0
- package/dist/protocol/wire/push-limits.mjs +88 -0
- package/dist/protocol/wire/push-uploads.mjs +3 -28
- package/dist/protocol/wire/receive-pack.d.mts +30 -14
- package/dist/protocol/wire/receive-pack.mjs +29 -2
- package/dist/protocol/wire/report-status.d.mts +30 -11
- package/dist/protocol/wire/report-status.mjs +21 -2
- package/dist/protocol/wire/v2.d.mts +56 -29
- package/dist/protocol/wire/v2.mjs +91 -16
- package/dist/protocol.d.mts +4 -3
- package/dist/protocol.mjs +7 -6
- package/dist/queue/advance.mjs +189 -120
- package/dist/queue/callers.mjs +12 -9
- package/dist/queue/calls.mjs +311 -155
- package/dist/queue/commit.mjs +70 -26
- package/dist/queue/host.d.mts +39 -12
- package/dist/queue/host.mjs +36 -38
- package/dist/queue/lanes.mjs +1 -1
- package/dist/queue/layer.d.mts +14 -0
- package/dist/queue/layer.mjs +55 -0
- package/dist/queue/limits.mjs +13 -2
- package/dist/queue/namespace.d.mts +2 -0
- package/dist/queue/pages.mjs +1 -1
- package/dist/queue/public.d.mts +6 -0
- package/dist/queue/public.mjs +21 -0
- package/dist/queue/push-option.mjs +49 -30
- package/dist/queue/rows.mjs +24 -16
- package/dist/queue/schedule.mjs +22 -22
- package/dist/queue/search.mjs +8 -7
- package/dist/queue/state.mjs +49 -13
- package/dist/queue/steps.mjs +6 -3
- package/dist/remote-helper.d.mts +5 -2
- package/dist/remote-helper.mjs +5 -2
- package/dist/rest/api.d.mts +1 -1
- package/dist/rest/blobs.d.mts +790 -23
- package/dist/rest/blobs.mjs +4 -4
- package/dist/rest/caller.d.mts +4163 -36
- package/dist/rest/caller.mjs +2 -2
- package/dist/rest/client.mjs +80 -70
- package/dist/rest/commits.d.mts +3315 -244
- package/dist/rest/commits.mjs +18 -64
- package/dist/rest/errors.d.mts +2082 -22
- package/dist/rest/errors.mjs +46 -89
- package/dist/rest/events.d.mts +394 -11
- package/dist/rest/events.mjs +13 -9
- package/dist/rest/files.d.mts +1265 -114
- package/dist/rest/files.mjs +11 -42
- package/dist/rest/forks.d.mts +2005 -62
- package/dist/rest/forks.mjs +10 -13
- package/dist/rest/handler.d.mts +3 -0
- package/dist/rest/handler.mjs +22 -14
- package/dist/rest/handlers.mjs +53 -60
- package/dist/rest/listen.d.mts +5 -8
- package/dist/rest/listen.mjs +23 -29
- package/dist/rest/me.d.mts +393 -10
- package/dist/rest/me.mjs +2 -2
- package/dist/rest/merges.d.mts +399 -16
- package/dist/rest/merges.mjs +3 -17
- package/dist/rest/paths.mjs +1 -0
- package/dist/rest/queue.d.mts +5615 -240
- package/dist/rest/queue.mjs +15 -130
- package/dist/rest/refs.d.mts +2859 -132
- package/dist/rest/refs.mjs +19 -39
- package/dist/rest/repos.d.mts +2421 -93
- package/dist/rest/repos.mjs +10 -33
- package/dist/rest/tags.d.mts +1205 -54
- package/dist/rest/tags.mjs +6 -34
- package/dist/rest/tokens.d.mts +2369 -66
- package/dist/rest/tokens.mjs +7 -4
- package/dist/rest/topics.d.mts +2060 -113
- package/dist/rest/topics.mjs +23 -71
- package/dist/rest/trees.d.mts +1610 -75
- package/dist/rest/trees.mjs +16 -57
- package/dist/rest/wire.d.mts +402 -0
- package/dist/rest/wire.mjs +32 -46
- package/dist/rest/work.d.mts +1204 -63
- package/dist/rest/work.mjs +7 -51
- package/dist/rest.d.mts +3 -3
- package/dist/server/extension.d.mts +6 -2
- package/dist/server/extension.mjs +54 -30
- package/dist/server/git-layer.d.mts +23 -0
- package/dist/server/git-layer.mjs +107 -0
- package/dist/server/git-namespace.d.mts +6 -0
- package/dist/server/git-namespace.mjs +15 -0
- package/dist/server/lifecycle.d.mts +1 -2
- package/dist/server/lifecycle.mjs +8 -15
- package/dist/server/namespaces.d.mts +2 -0
- package/dist/server/registry.d.mts +9 -0
- package/dist/server/registry.mjs +167 -0
- package/dist/server/route-match.mjs +88 -0
- package/dist/server/routes.d.mts +12 -8
- package/dist/server/routes.mjs +27 -18
- package/dist/server/server.d.mts +19 -0
- package/dist/server/server.mjs +281 -198
- package/dist/signin/codes.mjs +9 -6
- package/dist/signin/context.d.mts +1 -0
- package/dist/signin/context.mjs +4 -4
- package/dist/signin/device.mjs +8 -8
- package/dist/signin/forms.mjs +11 -29
- package/dist/signin/grants.d.mts +4 -2
- package/dist/signin/grants.mjs +20 -19
- package/dist/signin/route.mjs +2 -2
- package/dist/signin/web.mjs +7 -7
- package/dist/signin/wire.mjs +6 -6
- package/dist/storage/budget.mjs +51 -18
- package/dist/storage/calls.d.mts +22 -4
- package/dist/storage/calls.mjs +347 -110
- package/dist/storage/clean-up.mjs +80 -35
- package/dist/storage/counted-bucket.mjs +115 -0
- package/dist/storage/fetch.d.mts +2 -0
- package/dist/storage/fetch.mjs +243 -100
- package/dist/storage/fsck.mjs +56 -7
- package/dist/storage/held-types.d.mts +7 -0
- package/dist/storage/held-types.mjs +263 -0
- package/dist/storage/host-bucket.mjs +28 -0
- package/dist/storage/id-mix.d.mts +1 -0
- package/dist/storage/id-mix.mjs +55 -0
- package/dist/storage/index-bitmaps.d.mts +2 -1
- package/dist/storage/index-bitmaps.mjs +233 -101
- package/dist/storage/index-build.d.mts +7 -3
- package/dist/storage/index-build.mjs +650 -164
- package/dist/storage/index-fetch.d.mts +3 -1
- package/dist/storage/index-fetch.mjs +297 -195
- package/dist/storage/index-files.mjs +25 -27
- package/dist/storage/index-graph.d.mts +2 -1
- package/dist/storage/index-graph.mjs +127 -91
- package/dist/storage/index-layers.d.mts +11 -0
- package/dist/storage/index-layers.mjs +258 -78
- package/dist/storage/index-reach.mjs +181 -75
- package/dist/storage/index-remap.mjs +74 -32
- package/dist/storage/index-shallow.mjs +311 -0
- package/dist/storage/index-visible.mjs +168 -0
- package/dist/storage/layout.d.mts +1 -0
- package/dist/storage/layout.mjs +39 -8
- package/dist/storage/lfs-pointers.d.mts +3 -1
- package/dist/storage/lfs-pointers.mjs +25 -9
- package/dist/storage/link-join.d.mts +4 -0
- package/dist/storage/link-join.mjs +50 -12
- package/dist/storage/links.mjs +89 -4
- package/dist/storage/listed-ids.mjs +10 -0
- package/dist/storage/loose.d.mts +11 -4
- package/dist/storage/loose.mjs +102 -69
- package/dist/storage/memory-budget.d.mts +5 -0
- package/dist/storage/memory-budget.mjs +530 -102
- package/dist/storage/merge-choose.mjs +258 -0
- package/dist/storage/merge-cut.mjs +47 -0
- package/dist/storage/merge-fence.mjs +89 -0
- package/dist/storage/merge-index.mjs +347 -0
- package/dist/storage/merge-most.mjs +202 -0
- package/dist/storage/merge-plan.mjs +171 -0
- package/dist/storage/merge-row.mjs +258 -0
- package/dist/storage/merge-stream.mjs +497 -0
- package/dist/storage/merge-walk.mjs +199 -0
- package/dist/storage/merge-write.mjs +129 -0
- package/dist/storage/merge.d.mts +10 -0
- package/dist/storage/merge.mjs +82 -306
- package/dist/storage/object-rows.d.mts +4 -2
- package/dist/storage/object-rows.mjs +101 -17
- package/dist/storage/pack-order.d.mts +1 -1
- package/dist/storage/pack-order.mjs +69 -54
- package/dist/storage/pack-ranges.d.mts +1 -1
- package/dist/storage/pack-ranges.mjs +396 -60
- package/dist/storage/pack-reads.d.mts +6 -2
- package/dist/storage/pack-reads.mjs +598 -126
- package/dist/storage/pack-receive.d.mts +5 -0
- package/dist/storage/pack-receive.mjs +820 -237
- package/dist/storage/packs-memory.d.mts +25 -0
- package/dist/storage/packs-memory.mjs +49 -0
- package/dist/storage/packs.d.mts +7 -5
- package/dist/storage/packs.mjs +554 -213
- package/dist/storage/placed-reads.mjs +205 -0
- package/dist/storage/promise-calls.mjs +29 -0
- package/dist/storage/prune-keep.mjs +164 -0
- package/dist/storage/prune-walk.mjs +578 -0
- package/dist/storage/prune.mjs +739 -332
- package/dist/storage/push-allotment.mjs +3 -3
- package/dist/storage/push-uploads.mjs +22 -13
- package/dist/storage/pushed-commits.mjs +8 -9
- package/dist/storage/quarantine.d.mts +10 -0
- package/dist/storage/quarantine.mjs +28 -25
- package/dist/storage/range-cache.mjs +71 -0
- package/dist/storage/raw-ids.mjs +20 -1
- package/dist/storage/ready.d.mts +4 -2
- package/dist/storage/ready.mjs +109 -48
- package/dist/storage/receive-admission.mjs +67 -0
- package/dist/storage/receive-bounds.d.mts +1 -0
- package/dist/storage/receive-bounds.mjs +202 -0
- package/dist/storage/receive-files.mjs +248 -0
- package/dist/storage/receive-links.mjs +281 -244
- package/dist/storage/receive-state.d.mts +9 -0
- package/dist/storage/receive-state.mjs +150 -0
- package/dist/storage/receive-steps.mjs +344 -0
- package/dist/storage/receive-sweep.mjs +160 -0
- package/dist/storage/receive-table.d.mts +3 -0
- package/dist/storage/receive-table.mjs +197 -0
- package/dist/storage/repack-backlog.mjs +70 -0
- package/dist/storage/repack-contained.mjs +269 -0
- package/dist/storage/repack-job.d.mts +3 -0
- package/dist/storage/repack-job.mjs +24 -7
- package/dist/storage/repack.d.mts +4 -4
- package/dist/storage/repack.mjs +156 -77
- package/dist/storage/roots.mjs +23 -7
- package/dist/storage/rows.d.mts +4 -2
- package/dist/storage/rows.mjs +40 -7
- package/dist/storage/runs.d.mts +8 -0
- package/dist/storage/runs.mjs +731 -0
- package/dist/storage/send-list.d.mts +2 -1
- package/dist/storage/send-list.mjs +261 -76
- package/dist/storage/shallow.d.mts +3 -2
- package/dist/storage/shallow.mjs +7 -7
- package/dist/storage/single-flight.mjs +47 -0
- package/dist/storage/stream-whole.mjs +121 -54
- package/dist/storage/swap-walk.mjs +188 -0
- package/dist/storage/unpack.mjs +52 -23
- package/dist/storage/visible.mjs +58 -39
- package/dist/storage/walk.d.mts +2 -0
- package/dist/storage/walk.mjs +20 -7
- package/dist/storage/wants.mjs +185 -33
- package/dist/storage/written-bases.mjs +172 -0
- package/dist/store/call-count.d.mts +69 -4
- package/dist/store/call-count.mjs +193 -51
- package/dist/store/catalogue.d.mts +17 -3
- package/dist/store/catalogue.mjs +135 -48
- package/dist/store/crossing.mjs +2 -4
- package/dist/store/cursor-seal.d.mts +12 -1
- package/dist/store/cursor-seal.mjs +7 -6
- package/dist/store/errors.d.mts +2 -2
- package/dist/store/errors.mjs +112 -24
- package/dist/store/git-store.mjs +21 -2
- package/dist/store/list-job.mjs +5 -5
- package/dist/store/outbox.d.mts +15 -5
- package/dist/store/outbox.mjs +106 -28
- package/dist/store/promises.d.mts +3 -2
- package/dist/store/promises.mjs +94 -35
- package/dist/store/queue-jobs.mjs +12 -12
- package/dist/store/records.d.mts +64 -1
- package/dist/store/records.mjs +101 -32
- package/dist/store/ref-rows.d.mts +18 -2
- package/dist/store/ref-rows.mjs +62 -5
- package/dist/store/repo-record.mjs +11 -9
- package/dist/store/reservations.mjs +9 -8
- package/dist/store/scopes.mjs +13 -1
- package/dist/store/settle.mjs +1 -1
- package/dist/store/topic-jobs.mjs +4 -4
- package/dist/sync/bound.d.mts +5 -3
- package/dist/sync/bound.mjs +32 -3
- package/dist/sync/github.mjs +7 -7
- package/dist/sync/import.d.mts +2 -0
- package/dist/sync/import.mjs +46 -50
- package/dist/sync/jobs.mjs +15 -23
- package/dist/sync/mirror.d.mts +5 -1
- package/dist/sync/mirror.mjs +121 -44
- package/dist/sync/publish.d.mts +1 -0
- package/dist/sync/publish.mjs +10 -12
- package/dist/sync/step.mjs +439 -71
- package/dist/sync/tries.mjs +50 -32
- package/dist/sync.d.mts +3 -3
- package/dist/sync.mjs +2 -2
- package/dist/topics/advance.mjs +103 -86
- package/dist/topics/calls.mjs +97 -67
- package/dist/topics/directory.mjs +31 -11
- package/dist/topics/host.d.mts +0 -1
- package/dist/topics/host.mjs +2 -12
- package/dist/topics/members.mjs +30 -24
- package/dist/topics/rows.mjs +10 -9
- package/dist/topics/topic.mjs +20 -9
- package/package.json +8 -15
- package/dist/auth/authorize.d.mts +0 -5
- package/dist/contracts/objects.mjs +0 -54
- package/dist/core/events/stream.d.mts +0 -19
- package/dist/core/rules/define.d.mts +0 -5
- package/dist/core/rules/define.mjs +0 -13
- package/dist/core/rules/fetch.d.mts +0 -5
- package/dist/core/sight.mjs +0 -99
- package/dist/engine/engine.d.mts +0 -25
- package/dist/engine/engine.mjs +0 -49
- package/dist/engine/xdiff/NOTICE.md +0 -63
- package/dist/engine/xdiff/compiled.d.mts +0 -7
- package/dist/engine/xdiff/compiled.mjs +0 -9
- package/dist/engine/xdiff/embedded.mjs +0 -4
- package/dist/engine/xdiff/node.d.mts +0 -7
- package/dist/engine/xdiff/node.mjs +0 -10
- package/dist/engine/xdiff/upstream/LGPL-2.1 +0 -511
- package/dist/engine/xdiff/xdiff.wasm +0 -0
- package/dist/engine.d.mts +0 -3
- package/dist/engine.mjs +0 -3
- package/dist/storage/distinct-ids.mjs +0 -39
- package/dist/storage/held-memo.mjs +0 -188
- package/dist/storage/index-remap.d.mts +0 -8
- package/dist/sync/records.mjs +0 -73
|
@@ -1,4 +1,293 @@
|
|
|
1
|
+
import * as Schema from "effect/Schema";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import * as Predicate from "effect/Predicate";
|
|
4
|
+
import * as SchemaTransformation from "effect/SchemaTransformation";
|
|
1
5
|
// src/contracts/result.ts
|
|
6
|
+
/** What a refusal's body puts in place of a secret it would carry. */
|
|
7
|
+
const redactedText = "<redacted>";
|
|
8
|
+
/** Git's token text, `gt_<place>.<random>.<secret>`, anywhere in a string. */
|
|
9
|
+
const tokenTexts = /gt_[\w-]+\.[\w-]+\.[\w-]+/g;
|
|
10
|
+
/**
|
|
11
|
+
* A credential as an `Authorization` header carries it, read as `requestCredentials` reads one:
|
|
12
|
+
* its scheme, any whitespace, then every character up to the next.
|
|
13
|
+
*/
|
|
14
|
+
const headerCredentials = /\b(Bearer|Basic)\s+\S+/gi;
|
|
15
|
+
/**
|
|
16
|
+
* A URL, its userinfo and its query apart: either may carry a credential or a signature. The
|
|
17
|
+
* userinfo runs to the authority's last `@`, since a password may hold one.
|
|
18
|
+
*/
|
|
19
|
+
const urlParts = /([a-z][a-z\d+.-]*:\/\/)([^\s/?#]*@)?([^\s?#]*)(\?[^\s#]*)?/gi;
|
|
20
|
+
/** `text` without anything secret-shaped: a token, a header's credential, a URL's userinfo or query. */
|
|
21
|
+
const withoutSecrets = (text) => text.replace(tokenTexts, redactedText).replace(headerCredentials, (_, scheme) => `${scheme} ${redactedText}`).replace(urlParts, (_, scheme, user, rest, query) => `${scheme}${user === void 0 ? "" : `${redactedText}@`}${rest}${query === void 0 ? "" : `?${redactedText}`}`);
|
|
22
|
+
/**
|
|
23
|
+
* Text a refusal's body carries: read as it came, and written without anything secret-shaped, so
|
|
24
|
+
* a host's context or message that quotes a credential or a signed link never crosses HTTP with it.
|
|
25
|
+
*/
|
|
26
|
+
const BodyText = Schema.String.pipe(Schema.decodeTo(Schema.String, SchemaTransformation.transform({
|
|
27
|
+
decode: (text) => text,
|
|
28
|
+
encode: withoutSecrets
|
|
29
|
+
})));
|
|
30
|
+
/** What an error's context holds: plain values, so it crosses HTTP as it is, less its secrets. */
|
|
31
|
+
const ContextValue = /* @__PURE__ */ Schema.Union([
|
|
32
|
+
BodyText,
|
|
33
|
+
Schema.Number,
|
|
34
|
+
Schema.Boolean,
|
|
35
|
+
Schema.Array(BodyText),
|
|
36
|
+
Schema.Undefined
|
|
37
|
+
]);
|
|
38
|
+
/** A code's context: `fields`, each optional, beside any other key a host's refusal names. */
|
|
39
|
+
const contextOf = (fields) => Schema.StructWithRest(Schema.Struct(fields), [Schema.Record(Schema.String, ContextValue)]);
|
|
40
|
+
const ErrorContext = contextOf({});
|
|
41
|
+
/**
|
|
42
|
+
* A code's `reason`: one of ours, from the code's own Literals list (`NotAllowedReason` for
|
|
43
|
+
* `NOT_ALLOWED`, and so on), which OpenAPI lists; or any string a host passes, which a host
|
|
44
|
+
* function's `reject` may name in its context. So a `reason` types as a string, and a caller
|
|
45
|
+
* tells ours apart with the code's list.
|
|
46
|
+
*/
|
|
47
|
+
const reasonOf = (reasons) => Schema.optionalKey(Schema.Union([reasons, BodyText]));
|
|
48
|
+
const Paths = /* @__PURE__ */ Schema.optionalKey(Schema.mutable(Schema.Array(BodyText)));
|
|
49
|
+
const Count = /* @__PURE__ */ Schema.optionalKey(Schema.Number);
|
|
50
|
+
/**
|
|
51
|
+
* `provider-unknown`: a sync source names a provider `syncJobs` wasn't given. `body-ended`: a
|
|
52
|
+
* request's body ended before all of it came, on a connection that's still there.
|
|
53
|
+
* `link-wrong-type`: a pushed object links to an object of another type than its link says.
|
|
54
|
+
* `tag-target-missing`: a partial pack's tag names an object neither it nor the repo holds.
|
|
55
|
+
* `object-missing`: a pack names an object neither it nor the repo holds.
|
|
56
|
+
* `boundary-not-in-pack`: an import segment's boundary names a commit its pack doesn't hold.
|
|
57
|
+
* `too-many-short-ids`: a call names more distinct short IDs than `most`, `given` of them.
|
|
58
|
+
* `too-many-parents`: a pushed, imported or created commit has `given` parents, past `most`.
|
|
59
|
+
* `fsck`: an object Git 2.53's fsck refuses, pushed or written, by its git-fsck msg-id in `msgId`.
|
|
60
|
+
*/
|
|
61
|
+
const InvalidInputReason = /* @__PURE__ */ Schema.Literals([
|
|
62
|
+
"ofs-delta",
|
|
63
|
+
"fsck",
|
|
64
|
+
"provider-unknown",
|
|
65
|
+
"body-ended",
|
|
66
|
+
"link-wrong-type",
|
|
67
|
+
"tag-target-missing",
|
|
68
|
+
"object-missing",
|
|
69
|
+
"boundary-not-in-pack",
|
|
70
|
+
"too-many-short-ids",
|
|
71
|
+
"too-many-parents"
|
|
72
|
+
]);
|
|
73
|
+
const InvalidInputContext = contextOf({
|
|
74
|
+
reason: reasonOf(InvalidInputReason),
|
|
75
|
+
msgId: Schema.optionalKey(BodyText),
|
|
76
|
+
most: Count,
|
|
77
|
+
given: Count
|
|
78
|
+
});
|
|
79
|
+
/**
|
|
80
|
+
* `files-refused`: a `Rules.files` rule refuses files the push adds or changes on the ref: `paths`
|
|
81
|
+
* holds the first, and `total` how many there are. `entry-unpublishable`: a merge queue's
|
|
82
|
+
* publish, refused for `entries` alone.
|
|
83
|
+
*/
|
|
84
|
+
const NotAllowedReason = /* @__PURE__ */ Schema.Literals(["files-refused", "entry-unpublishable"]);
|
|
85
|
+
const NotAllowedContext = contextOf({
|
|
86
|
+
reason: reasonOf(NotAllowedReason),
|
|
87
|
+
entries: Paths,
|
|
88
|
+
paths: Paths,
|
|
89
|
+
total: Count
|
|
90
|
+
});
|
|
91
|
+
/** A merge queue's report on a candidate. */
|
|
92
|
+
const Verdict = /* @__PURE__ */ Schema.Literals([
|
|
93
|
+
"pass",
|
|
94
|
+
"fail",
|
|
95
|
+
"cancel"
|
|
96
|
+
]);
|
|
97
|
+
const ExistingReason = /* @__PURE__ */ Schema.Literals(["key-reused"]);
|
|
98
|
+
const ExistingContext = contextOf({
|
|
99
|
+
reason: reasonOf(ExistingReason),
|
|
100
|
+
verdict: Schema.optionalKey(Verdict.pick(["pass", "fail"]))
|
|
101
|
+
});
|
|
102
|
+
/**
|
|
103
|
+
* `no-queue`: the repo is there, with no merge queue, so a caller never reads it as a missing
|
|
104
|
+
* repo. `no-topics`: the server runs no topics. `ambiguous`: a short ID starts more than one
|
|
105
|
+
* object, so it names none. `target` is the one the call or push named, when it named one.
|
|
106
|
+
*/
|
|
107
|
+
const MissingReason = /* @__PURE__ */ Schema.Literals([
|
|
108
|
+
"no-queue",
|
|
109
|
+
"no-topics",
|
|
110
|
+
"ambiguous"
|
|
111
|
+
]);
|
|
112
|
+
const MissingContext = contextOf({
|
|
113
|
+
reason: reasonOf(MissingReason),
|
|
114
|
+
target: Schema.optionalKey(BodyText)
|
|
115
|
+
});
|
|
116
|
+
/**
|
|
117
|
+
* `atomic-partner`: an atomic push refused this ref, fine itself, since another ref of the push
|
|
118
|
+
* was refused for its own reason. A host's push rule may answer it too; a caller that reads it
|
|
119
|
+
* then reads the rule's refusal as a partner's, as the rule asked. `stage-gone`: a receive in
|
|
120
|
+
* steps found its staged pack gone, since clean-up ended its quarantine; stage the segment again.
|
|
121
|
+
* `no-copy-rows`: a fork's create, sync or fetch over objects without `copyRows`, which no copy
|
|
122
|
+
* reads. `merges-off`: the server runs no `Merges`, so it merges no trees and writes no patches.
|
|
123
|
+
*/
|
|
124
|
+
const PreconditionReason = /* @__PURE__ */ Schema.Literals([
|
|
125
|
+
"cursor-expired",
|
|
126
|
+
"diverged",
|
|
127
|
+
"merge-conflict",
|
|
128
|
+
"candidate-superseded",
|
|
129
|
+
"candidate-cancelled",
|
|
130
|
+
"entry-gone",
|
|
131
|
+
"ref-conflict",
|
|
132
|
+
"newer-format",
|
|
133
|
+
"changed-while-checked",
|
|
134
|
+
"unsupported-attribute",
|
|
135
|
+
"unrelated-histories",
|
|
136
|
+
"unsupported-virtual-base",
|
|
137
|
+
"own-repo",
|
|
138
|
+
"not-a-fork",
|
|
139
|
+
"no-copy-rows",
|
|
140
|
+
"shallow-root",
|
|
141
|
+
"shallow-upload",
|
|
142
|
+
"sync-unbound",
|
|
143
|
+
"import-cancelled",
|
|
144
|
+
"importing",
|
|
145
|
+
"history-not-imported",
|
|
146
|
+
"stage-gone",
|
|
147
|
+
"remote-refused",
|
|
148
|
+
"atomic-partner",
|
|
149
|
+
"merges-off"
|
|
150
|
+
]);
|
|
151
|
+
/**
|
|
152
|
+
* `importState` is a `history-not-imported`'s: where the repo's `git.sync.import` stands, short of
|
|
153
|
+
* `done`. `attribute` is an `unsupported-attribute`'s, as `.gitattributes` writes it: `merge=lfs`,
|
|
154
|
+
* or `ident`. `tip` is a `diverged` ref's: the tip it was to move to, which holds none of its own
|
|
155
|
+
* commits.
|
|
156
|
+
*/
|
|
157
|
+
const PreconditionContext = contextOf({
|
|
158
|
+
reason: reasonOf(PreconditionReason),
|
|
159
|
+
importState: Schema.optionalKey(Schema.Literals([
|
|
160
|
+
"running",
|
|
161
|
+
"cancelled",
|
|
162
|
+
"failed"
|
|
163
|
+
])),
|
|
164
|
+
attribute: Schema.optionalKey(BodyText),
|
|
165
|
+
paths: Paths,
|
|
166
|
+
total: Count,
|
|
167
|
+
tip: Schema.optionalKey(BodyText)
|
|
168
|
+
});
|
|
169
|
+
/**
|
|
170
|
+
* `prune-walk-too-large` is upkeep's prune pass, refused at one of three bounds its message names:
|
|
171
|
+
* - its walk's history past `pruneCommitsMost`, 1,000,000 commits and tags, which no option
|
|
172
|
+
* raises: only deleting refs, till what the rest reach is under it, mends it;
|
|
173
|
+
* - its walk's charge past the step's allotment: raise `packs()`' `memory` past its default of
|
|
174
|
+
* 128,000,000 bytes, on a host with the room, such as Node; a Worker's isolate has no more;
|
|
175
|
+
* - one step of the walk past a try's calls: raise the adapter's `callLimits`, on Cloudflare its
|
|
176
|
+
* `subrequests` up to the Worker's own `limits.subrequests`, and `packs()`' `callLimits` where
|
|
177
|
+
* it sets lower ones.
|
|
178
|
+
* A host sees it in the `repo.work.failed` of `git.repack`'s `prune` row, which fails at its
|
|
179
|
+
* first try. A later `repack` run retries the row once it has stayed failed a prune period, so at
|
|
180
|
+
* most once a period but for a host's own retry, and a retry still refused fails it again, with a
|
|
181
|
+
* fresh `repo.work.failed`; once the cause is mended, the retry's pass lands. Only a `repack` run
|
|
182
|
+
* retries it, so a repo with no run due waits for one, as does a repo with more failed jobs listed
|
|
183
|
+
* before the row than one run reads, and
|
|
184
|
+
* `work.retry(repo, { name: 'git.repack', key: 'prune' })` runs the pass at once.
|
|
185
|
+
*/
|
|
186
|
+
const ResourceReason = /* @__PURE__ */ Schema.Literals([
|
|
187
|
+
"too-large",
|
|
188
|
+
"rate-limited",
|
|
189
|
+
"walk-limit",
|
|
190
|
+
"diff-limit",
|
|
191
|
+
"object-too-large",
|
|
192
|
+
"delta-too-large",
|
|
193
|
+
"response-too-large",
|
|
194
|
+
"too-many-pointers",
|
|
195
|
+
"fetch-plan-too-large",
|
|
196
|
+
"too-many-store-calls",
|
|
197
|
+
"call-budget",
|
|
198
|
+
"events-undelivered",
|
|
199
|
+
"events-waiting",
|
|
200
|
+
"name-churn",
|
|
201
|
+
"queue-full",
|
|
202
|
+
"too-many-gitmodules-and-gitattributes",
|
|
203
|
+
"prune-walk-too-large"
|
|
204
|
+
]);
|
|
205
|
+
/**
|
|
206
|
+
* A push refused `too-large` by the repo's pack indexes it reads: those indexes' bytes in
|
|
207
|
+
* `indexBytes`, the push's own beside them in `pushBytes`, and the most the server's memory could
|
|
208
|
+
* give it in `most`.
|
|
209
|
+
*/
|
|
210
|
+
const ResourceContext = contextOf({
|
|
211
|
+
reason: reasonOf(ResourceReason),
|
|
212
|
+
indexBytes: Count,
|
|
213
|
+
pushBytes: Count,
|
|
214
|
+
most: Count
|
|
215
|
+
});
|
|
216
|
+
/**
|
|
217
|
+
* `graph-length`: `pack`'s `.graph` reads past the bytes its pack row records, or ends whole, its
|
|
218
|
+
* trailer its SHA-1, short of them; a file cut short is refused as broken, without it. The
|
|
219
|
+
* merge fences that pack: it stays readable, left out of merges, so the person has nothing to run
|
|
220
|
+
* (`before-production.md`, a pack the merge fence leaves out stays unmerged). `merge-incomplete`:
|
|
221
|
+
* a repack's remap found an object its merged pack doesn't place, so `git.repack`'s step fails,
|
|
222
|
+
* commits nothing and is tried again; the repo reads as before, and the person has nothing to run.
|
|
223
|
+
*/
|
|
224
|
+
const DataLossReason = /* @__PURE__ */ Schema.Literals(["graph-length", "merge-incomplete"]);
|
|
225
|
+
const DataLossContext = contextOf({ reason: reasonOf(DataLossReason) });
|
|
226
|
+
/** `id`: the logged host-function failure's, which `onError` receives too. */
|
|
227
|
+
const HostErrorContext = contextOf({ id: Schema.optionalKey(BodyText) });
|
|
228
|
+
/**
|
|
229
|
+
* `busy`: the server's memory, held by other calls, had no room for this one in time.
|
|
230
|
+
* `packs-awaiting-repack`: a push to a repo whose listed packs, piled up between repacks, are more
|
|
231
|
+
* than its links can be checked against, refused before its body is read. `packs` is how many the
|
|
232
|
+
* repo lists, and `most` how many a push's links can be checked against; `git.repack` merging them
|
|
233
|
+
* lets the same push land. `awaiting-index`: a fetch past what one fetch's walk holds, refused
|
|
234
|
+
* while `git.index` will build the index it can be sent from, or under private branches a
|
|
235
|
+
* `refs.list` or `refs.count` by a caller who doesn't read every pattern, while the repo's ref
|
|
236
|
+
* index is rebuilt for the server's patterns: the same call is served once the index is built.
|
|
237
|
+
* `may-have-saved`: the write may have landed, so read it back before sending it again.
|
|
238
|
+
* `too-many-writes`: other writes won every try, so no ref changed; sending the same request again
|
|
239
|
+
* is safe.
|
|
240
|
+
*/
|
|
241
|
+
const UnavailableReason = /* @__PURE__ */ Schema.Literals([
|
|
242
|
+
"busy",
|
|
243
|
+
"packs-awaiting-repack",
|
|
244
|
+
"awaiting-index",
|
|
245
|
+
"may-have-saved",
|
|
246
|
+
"too-many-writes"
|
|
247
|
+
]).annotate({ description: "`may-have-saved`: the write may have landed; read it back before you send it again. `too-many-writes`: other writes won every try, so no ref changed; sending the same request again is safe." });
|
|
248
|
+
const UnavailableContext = contextOf({
|
|
249
|
+
id: Schema.optionalKey(BodyText),
|
|
250
|
+
reason: reasonOf(UnavailableReason),
|
|
251
|
+
packs: Count,
|
|
252
|
+
most: Count
|
|
253
|
+
});
|
|
254
|
+
/**
|
|
255
|
+
* A code's refusal as it crosses HTTP: its fields by name, so neither its tag nor what HTTP strips,
|
|
256
|
+
* `cause` and `hostHint`, reaches the wire.
|
|
257
|
+
*/
|
|
258
|
+
const bodyOf = (code, context) => Schema.Struct({
|
|
259
|
+
code: Schema.Literal(code),
|
|
260
|
+
message: BodyText,
|
|
261
|
+
hint: Schema.optionalKey(BodyText),
|
|
262
|
+
context: Schema.optionalKey(context)
|
|
263
|
+
}).annotate({ identifier: `GitError.${code}` });
|
|
264
|
+
/** Each code's refusal body. */
|
|
265
|
+
const gitErrorBodies = {
|
|
266
|
+
INVALID_ARGUMENT: bodyOf("INVALID_ARGUMENT", InvalidInputContext),
|
|
267
|
+
UNAUTHENTICATED: bodyOf("UNAUTHENTICATED", ErrorContext),
|
|
268
|
+
NOT_ALLOWED: bodyOf("NOT_ALLOWED", NotAllowedContext),
|
|
269
|
+
NOT_FOUND: bodyOf("NOT_FOUND", MissingContext),
|
|
270
|
+
ALREADY_EXISTS: bodyOf("ALREADY_EXISTS", ExistingContext),
|
|
271
|
+
FAILED_PRECONDITION: bodyOf("FAILED_PRECONDITION", PreconditionContext),
|
|
272
|
+
RESOURCE_EXHAUSTED: bodyOf("RESOURCE_EXHAUSTED", ResourceContext),
|
|
273
|
+
DEADLINE_EXCEEDED: bodyOf("DEADLINE_EXCEEDED", HostErrorContext),
|
|
274
|
+
UNAVAILABLE: bodyOf("UNAVAILABLE", UnavailableContext),
|
|
275
|
+
DATA_LOSS: bodyOf("DATA_LOSS", DataLossContext),
|
|
276
|
+
INTERNAL: bodyOf("INTERNAL", ErrorContext)
|
|
277
|
+
};
|
|
278
|
+
/** A refused call's body, of any code: what REST answers and a client reads. */
|
|
279
|
+
const GitErrorBody = Schema.Union(Object.values(gitErrorBodies));
|
|
280
|
+
/** Every reason a refusal names, each once, by code: what `ref0-push-reasons` tells. */
|
|
281
|
+
const refusalReasonLists = [
|
|
282
|
+
InvalidInputReason,
|
|
283
|
+
NotAllowedReason,
|
|
284
|
+
ExistingReason,
|
|
285
|
+
MissingReason,
|
|
286
|
+
PreconditionReason,
|
|
287
|
+
ResourceReason,
|
|
288
|
+
UnavailableReason,
|
|
289
|
+
DataLossReason
|
|
290
|
+
];
|
|
2
291
|
/** Each code's HTTP status. `RESOURCE_EXHAUSTED` is 429 when its reason is `rate-limited`. */
|
|
3
292
|
const httpStatus = {
|
|
4
293
|
INVALID_ARGUMENT: 400,
|
|
@@ -13,6 +302,22 @@ const httpStatus = {
|
|
|
13
302
|
DATA_LOSS: 500,
|
|
14
303
|
INTERNAL: 500
|
|
15
304
|
};
|
|
305
|
+
const gitErrorCodes = Object.keys(httpStatus);
|
|
306
|
+
/**
|
|
307
|
+
* Git's error as a value, tagged `GitError`, so Effect code can `catchTag` it. `gitError` makes
|
|
308
|
+
* each one; its `context` is typed by its code, as the `GitError` type says. Exported as a type so
|
|
309
|
+
* a declaration can name it where TypeScript writes `GitError` out by its members.
|
|
310
|
+
*/
|
|
311
|
+
var GitErrorTagged = class extends Schema.TaggedError()("GitError", {
|
|
312
|
+
code: Schema.Literals(gitErrorCodes),
|
|
313
|
+
message: Schema.String,
|
|
314
|
+
hint: Schema.optionalKey(Schema.String),
|
|
315
|
+
hostHint: Schema.optionalKey(Schema.String),
|
|
316
|
+
cause: Schema.optionalKey(Schema.Unknown),
|
|
317
|
+
context: Schema.optionalKey(Schema.Unknown)
|
|
318
|
+
}) {};
|
|
319
|
+
/** Whether `value` is Git's error, by its tag. */
|
|
320
|
+
const isGitError = (value) => Predicate.isTagged(value, "GitError");
|
|
16
321
|
/**
|
|
17
322
|
* The header each refusal a `GitError` makes names its code in, over HTTP, beside a status two
|
|
18
323
|
* codes may share, such as 409 for `ALREADY_EXISTS` and `FAILED_PRECONDITION`. A client reads it
|
|
@@ -21,14 +326,54 @@ const httpStatus = {
|
|
|
21
326
|
const refusalCodeHeader = "ref0-code";
|
|
22
327
|
/** Whether `value` is a code Git refuses with. */
|
|
23
328
|
const isGitErrorCode = (value) => Object.hasOwn(httpStatus, value);
|
|
329
|
+
/** Git's error: `code`'s, in `message`'s words, with what `input` adds. */
|
|
330
|
+
const gitError = (code, message, input = {}) => new GitErrorTagged({
|
|
331
|
+
code,
|
|
332
|
+
message,
|
|
333
|
+
...input
|
|
334
|
+
});
|
|
335
|
+
/** An Effect failing with `gitError`'s error. */
|
|
336
|
+
const fail = (code, message, input) => Effect.fail(gitError(code, message, input));
|
|
337
|
+
/**
|
|
338
|
+
* Git's error from `fields`, a `GitError`'s or a body's that a client read, with `over`'s fields,
|
|
339
|
+
* its message among them, over them. A `GitError` keeps `message` and `cause` off its enumerable
|
|
340
|
+
* keys, as an `Error` does, so a spread of one would drop them: this reads each field by name.
|
|
341
|
+
*/
|
|
342
|
+
const gitErrorFrom = (fields, over = {}) => {
|
|
343
|
+
const { hint, hostHint, cause, context } = fields;
|
|
344
|
+
const held = Object.entries({
|
|
345
|
+
hint,
|
|
346
|
+
hostHint,
|
|
347
|
+
cause,
|
|
348
|
+
context
|
|
349
|
+
}).filter(([, v]) => v !== void 0);
|
|
350
|
+
const { message = fields.message, ...input } = over;
|
|
351
|
+
return gitError(fields.code, message, {
|
|
352
|
+
...Object.fromEntries(held),
|
|
353
|
+
...input
|
|
354
|
+
});
|
|
355
|
+
};
|
|
356
|
+
const refusalReasons = /* @__PURE__ */ new Set(refusalReasonLists.flatMap((reasons) => reasons.literals));
|
|
357
|
+
/** Whether `told`, a `reason: <told>` line's, is a reason a refusal names. */
|
|
358
|
+
const isRefusalReason = (told) => refusalReasons.has(told);
|
|
24
359
|
function accept(...value) {
|
|
25
360
|
return value.length === 0 ? { kind: "accept" } : {
|
|
26
361
|
kind: "accept",
|
|
27
362
|
value: value[0]
|
|
28
363
|
};
|
|
29
364
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
365
|
+
/**
|
|
366
|
+
* A host function's refusal of `input`, read field by field: a `GitError` given as `input` keeps
|
|
367
|
+
* `message` off its enumerable keys, so a spread of one would drop it.
|
|
368
|
+
*/
|
|
369
|
+
const reject = ({ code, message, hint, context }) => {
|
|
370
|
+
const rejected = {
|
|
371
|
+
kind: "reject",
|
|
372
|
+
message
|
|
373
|
+
};
|
|
374
|
+
if (code !== void 0) rejected.code = code;
|
|
375
|
+
if (hint !== void 0) rejected.hint = hint;
|
|
376
|
+
if (context !== void 0) rejected.context = context;
|
|
377
|
+
return rejected;
|
|
378
|
+
};
|
|
379
|
+
export { ContextValue, DataLossContext, DataLossReason, ErrorContext, ExistingContext, ExistingReason, GitErrorBody, GitErrorTagged, HostErrorContext, InvalidInputContext, InvalidInputReason, MissingContext, MissingReason, NotAllowedContext, NotAllowedReason, PreconditionContext, PreconditionReason, ResourceContext, ResourceReason, UnavailableContext, UnavailableReason, Verdict, accept, fail, gitError, gitErrorBodies, gitErrorFrom, httpStatus, isGitError, isGitErrorCode, isRefusalReason, refusalCodeHeader, reject };
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import { Acting, ActorId, ActorInput } from "./actors.mjs";
|
|
2
2
|
import { TreeChange } from "./engine.mjs";
|
|
3
3
|
import { HandlerOptions, SavedHandlerOptions } from "./handlers.mjs";
|
|
4
|
-
import { Oid, RefName,
|
|
4
|
+
import { Oid, RefName, RepoName } from "./ids.mjs";
|
|
5
5
|
import { BypassOperation, FilesAllowOperation } from "./operations.mjs";
|
|
6
|
-
import { FetchRequest } from "./
|
|
6
|
+
import { FetchRequest } from "./object-values.mjs";
|
|
7
|
+
import "./objects.mjs";
|
|
7
8
|
import { RefSource, RefUpdate } from "./refs.mjs";
|
|
8
9
|
import { RepoStats } from "./repos.mjs";
|
|
9
|
-
import { Awaitable, DecisionAnswer } from "./result.mjs";
|
|
10
|
+
import { Awaitable, DecisionAnswer, GitError } from "./result.mjs";
|
|
11
|
+
import * as Effect from "effect/Effect";
|
|
12
|
+
import * as Context from "effect/Context";
|
|
13
|
+
import * as Stream from "effect/Stream";
|
|
10
14
|
export interface PushFacts {
|
|
11
15
|
readonly bytes: number;
|
|
12
16
|
readonly objects: number;
|
|
@@ -19,7 +23,7 @@ export interface PushFacts {
|
|
|
19
23
|
* for `meta`'s absence.
|
|
20
24
|
*/
|
|
21
25
|
export type PushContext = Acting & {
|
|
22
|
-
readonly repo:
|
|
26
|
+
readonly repo: RepoName;
|
|
23
27
|
readonly subject?: ActorId;
|
|
24
28
|
/** How the change came in, set by Git: never by anything a caller sends. */
|
|
25
29
|
readonly source: RefSource;
|
|
@@ -32,20 +36,24 @@ export type PushContext = Acting & {
|
|
|
32
36
|
readonly stats: RepoStats;
|
|
33
37
|
readonly request?: Request;
|
|
34
38
|
readonly pushOptions?: readonly string[];
|
|
35
|
-
readonly changes: () => Promise<readonly TreeChange[]>;
|
|
36
39
|
/**
|
|
37
|
-
* The push
|
|
40
|
+
* The files the push changes on its refs, read once, whichever check runs it first. It runs in the
|
|
41
|
+
* push's call scope, so a hook that runs it as a Promise counts its reads into the push.
|
|
42
|
+
*/
|
|
43
|
+
readonly changes: Effect.Effect<readonly TreeChange[], GitError>;
|
|
44
|
+
/**
|
|
45
|
+
* The push's changes commit by commit, read only as it's pulled, in the push's call scope: each commit the push brings, and
|
|
38
46
|
* in each the paths whose entry differs from every parent's that the push brings or that's the
|
|
39
47
|
* ref's old tip, names only, one commit at a time, a commit with none counted as a root. A ref
|
|
40
48
|
* moved onto a commit the push doesn't bring, and a write through the API, list the ref's tip
|
|
41
49
|
* diff instead, credited to the new tip, so what the tip takes from a commit no rule saw, such
|
|
42
|
-
* as a merge commit's other parent, is listed as its own. `
|
|
50
|
+
* as a merge commit's other parent, is listed as its own. `Rules.files` also counts a parent at
|
|
43
51
|
* the tip of a ref it covers, and, on a refusal, one on the first-parent chain of the ref's old
|
|
44
52
|
* tip or of a default branch it covers, 1,000 commits back (Q732, Q734). A push of several refs
|
|
45
|
-
* lists its commits once, for each ref.
|
|
53
|
+
* lists its commits once, for each ref. A walk past its allotment fails with the allotment's
|
|
54
|
+
* refusal, which `Rules.files` answers as its own.
|
|
46
55
|
*/
|
|
47
|
-
readonly commitChanges:
|
|
48
|
-
readonly signal: AbortSignal;
|
|
56
|
+
readonly commitChanges: Stream.Stream<CommitChange, GitError>;
|
|
49
57
|
};
|
|
50
58
|
/** A path one commit the push brings adds or changes, against every parent. */
|
|
51
59
|
export interface CommitChange {
|
|
@@ -58,29 +66,31 @@ export type PushRuleInput = PushContext & {
|
|
|
58
66
|
readonly update: RefUpdate;
|
|
59
67
|
/**
|
|
60
68
|
* Asks the server's `authorize`, after the caller's credential's ceiling, whether the caller may
|
|
61
|
-
* do `operation`: its answer, a refusal's message as the host gave it. A
|
|
62
|
-
*
|
|
69
|
+
* do `operation`: its answer, a refusal's message as the host gave it. A failure is the host's,
|
|
70
|
+
* which refuses the ref.
|
|
63
71
|
*/
|
|
64
|
-
readonly authorize: (operation: RuleOperation) =>
|
|
72
|
+
readonly authorize: (operation: RuleOperation) => Effect.Effect<DecisionAnswer, GitError>;
|
|
65
73
|
};
|
|
66
74
|
/**
|
|
67
|
-
* What a push rule may ask `authorize`: a `
|
|
68
|
-
* `
|
|
75
|
+
* What a push rule may ask `authorize`: a `Rules.files` rule's `-o allow-files`, and a
|
|
76
|
+
* `Rules.protect` or `Rules.lock` rule's bypass of a change it refuses.
|
|
69
77
|
*/
|
|
70
78
|
export type RuleOperation = FilesAllowOperation | BypassOperation;
|
|
71
79
|
/**
|
|
72
80
|
* Runs per ref, in the push decide: one `reject()` refuses that ref. Its answer holds only for the
|
|
73
81
|
* repo facts it saw. Git asks it once of each ref, but asks again of a ref it refused as a `force`
|
|
74
|
-
* when Git's exact walk finds the ref a fast-forward, so a rule must be safe to ask twice.
|
|
82
|
+
* when Git's exact walk finds the ref a fast-forward, so a rule must be safe to ask twice. It runs
|
|
83
|
+
* in the push's fiber: a failure or a defect refuses the ref as the host's failure, `UNAVAILABLE`,
|
|
84
|
+
* which `onError` hears of, and the push's end interrupts it. Make one with `Rules.push`.
|
|
75
85
|
*/
|
|
76
86
|
export interface PushRule {
|
|
87
|
+
readonly kind: 'push';
|
|
77
88
|
readonly name: string;
|
|
78
|
-
readonly check: (input: PushRuleInput) =>
|
|
89
|
+
readonly check: (input: PushRuleInput) => Effect.Effect<DecisionAnswer, GitError>;
|
|
79
90
|
}
|
|
80
|
-
export interface FetchRuleInput extends FetchRequest, ActorInput {
|
|
81
|
-
readonly repo:
|
|
91
|
+
export interface FetchRuleInput extends FetchRequest, Omit<ActorInput, 'signal'> {
|
|
92
|
+
readonly repo: RepoName;
|
|
82
93
|
readonly request: Request;
|
|
83
|
-
readonly signal: AbortSignal;
|
|
84
94
|
}
|
|
85
95
|
/** A depth is all a fetch rule may set: a client that asked for no filter is never given one. */
|
|
86
96
|
export interface FetchAdjustment {
|
|
@@ -91,53 +101,42 @@ export interface FetchAdjustment {
|
|
|
91
101
|
* fetch that asked for a depth gets the lesser of its own and the rules'; over v2, so does a
|
|
92
102
|
* clone that asked for none, and a v2 fetch that holds history is sent what it lacks. A v0 fetch
|
|
93
103
|
* that asked for none is refused, since its client reads no shallow lines: it's never sent more
|
|
94
|
-
* than a rule allows.
|
|
104
|
+
* than a rule allows. It runs in the fetch's fiber, and fails as a push rule does. Make one with
|
|
105
|
+
* `Rules.fetch`.
|
|
95
106
|
*/
|
|
96
107
|
export interface FetchRule {
|
|
108
|
+
readonly kind: 'fetch';
|
|
97
109
|
readonly name: string;
|
|
98
|
-
readonly check: (input: FetchRuleInput) =>
|
|
110
|
+
readonly check: (input: FetchRuleInput) => Effect.Effect<DecisionAnswer<FetchAdjustment>, GitError>;
|
|
99
111
|
}
|
|
100
112
|
export interface ProtectOptions {
|
|
101
113
|
/** The sources that may change the ref; with none named, any may. */
|
|
102
114
|
readonly sources?: readonly RefSource[];
|
|
103
115
|
}
|
|
104
|
-
/**
|
|
116
|
+
/**
|
|
117
|
+
* A ref, or several: a bare name means `refs/heads/<name>`. As in GitHub's branch rules, `*`
|
|
118
|
+
* matches any run of characters but `/`, so `release/*` takes `release/a` but not `release/a/b`,
|
|
119
|
+
* and a last segment of `**` covers a whole folder, however deep: `release/**` takes both.
|
|
120
|
+
*/
|
|
105
121
|
export type RefPatterns = RefName | readonly RefName[];
|
|
106
122
|
export interface FileRuleOptions {
|
|
107
123
|
/** Paths, in `.gitignore`'s syntax: `*`, `**`, and `!` to take one back out. */
|
|
108
124
|
readonly refuse: readonly string[];
|
|
109
125
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
readonly protect: (refs: RefPatterns, options?: ProtectOptions) => PushRule;
|
|
116
|
-
/**
|
|
117
|
-
* `protect` with `sources: []`: the ref, once it exists, never moves or goes away. A change it
|
|
118
|
-
* refuses asks `authorize` for `lock.bypass` first.
|
|
119
|
-
*/
|
|
120
|
-
readonly lock: (refs: RefPatterns) => PushRule;
|
|
121
|
-
/**
|
|
122
|
-
* On these refs, a push that adds or changes a file `refuse` matches is refused, by its path
|
|
123
|
-
* alone, its contents never read. `git push -o allow-files` asks `authorize` instead, with
|
|
124
|
-
* `files.allow`. A delete isn't refused.
|
|
125
|
-
*/
|
|
126
|
-
readonly files: (refs: RefPatterns, options: FileRuleOptions) => PushRule;
|
|
127
|
-
}
|
|
128
|
-
export interface GitRules {
|
|
129
|
-
/** The host's, which run before any a package built on Git adds. */
|
|
130
|
-
readonly push?: readonly PushRule[];
|
|
131
|
-
readonly fetch?: readonly FetchRule[];
|
|
132
|
-
}
|
|
126
|
+
/**
|
|
127
|
+
* `hooks.preReceive`'s input: its `changes` and `commitChanges` are the rules', Effects a hook runs
|
|
128
|
+
* as Promises, and its `signal` aborts when the hook runs past its timeout, until 2a2-H makes the
|
|
129
|
+
* hooks Effects.
|
|
130
|
+
*/
|
|
133
131
|
export type PushHookInput = PushContext & {
|
|
134
132
|
readonly atomic: boolean;
|
|
133
|
+
readonly signal: AbortSignal;
|
|
135
134
|
};
|
|
136
135
|
export interface PostReceiveInput extends ActorInput {
|
|
137
136
|
/** The push's own ID: the same on every try, so a host's work can be keyed by it. */
|
|
138
137
|
readonly pushId: string;
|
|
139
138
|
/** The repo's name when it was pushed to. */
|
|
140
|
-
readonly repo:
|
|
139
|
+
readonly repo: RepoName;
|
|
141
140
|
readonly subject?: ActorId;
|
|
142
141
|
readonly source: RefSource;
|
|
143
142
|
readonly updates: readonly RefUpdate[];
|
|
@@ -156,4 +155,17 @@ export type PostReceive = (input: PostReceiveInput) => Awaitable<void>;
|
|
|
156
155
|
export interface GitHooks {
|
|
157
156
|
readonly preReceive?: PreReceive | HandlerOptions<PreReceive>;
|
|
158
157
|
readonly postReceive?: PostReceive | SavedHandlerOptions<PostReceive>;
|
|
159
|
-
}
|
|
158
|
+
}
|
|
159
|
+
/** The host's rules, as `Rules.layer` builds them: each kind in the order the host listed it. */
|
|
160
|
+
export interface RulesService {
|
|
161
|
+
readonly push: readonly PushRule[];
|
|
162
|
+
readonly fetch: readonly FetchRule[];
|
|
163
|
+
}
|
|
164
|
+
declare const Rules_base: Context.ServiceClass<Rules, "@ref0/git/Rules", RulesService>;
|
|
165
|
+
/**
|
|
166
|
+
* The host's push and fetch rules. Core reads it with `Effect.serviceOption` where it reads the
|
|
167
|
+
* rules, after its own checks: a server with none runs none. Only core reads it, so it has no
|
|
168
|
+
* accessors, as `Policy` has none.
|
|
169
|
+
*/
|
|
170
|
+
export declare class Rules extends /* @__PURE__ */ Rules_base {}
|
|
171
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as Context from "effect/Context";
|
|
2
|
+
// src/contracts/rules.ts
|
|
3
|
+
/**
|
|
4
|
+
* The host's push and fetch rules. Core reads it with `Effect.serviceOption` where it reads the
|
|
5
|
+
* rules, after its own checks: a server with none runs none. Only core reads it, so it has no
|
|
6
|
+
* accessors, as `Policy` has none.
|
|
7
|
+
*/
|
|
8
|
+
var Rules = class extends (/* @__PURE__ */ Context.Service()("@ref0/git/Rules")) {};
|
|
9
|
+
export { Rules };
|