@ref0/git 0.12.0 → 0.20.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/private-refs.mjs +3 -3
- package/dist/auth/access-jwt.mjs +2 -2
- package/dist/auth/auth.d.mts +2 -2
- package/dist/auth/auth.mjs +3 -6
- package/dist/auth/authorize.mjs +4 -20
- package/dist/auth/fences.d.mts +1 -2
- package/dist/auth/fences.mjs +3 -3
- package/dist/auth/grants.mjs +4 -4
- package/dist/auth/helpers.mjs +3 -11
- package/dist/auth/host-function.mjs +18 -1
- package/dist/auth/host-services.mjs +11 -0
- package/dist/auth/identify.d.mts +1 -1
- package/dist/auth/identify.mjs +3 -3
- package/dist/auth/policy.d.mts +27 -7
- package/dist/auth/policy.mjs +8 -4
- package/dist/auth/token-cleanup.mjs +67 -0
- package/dist/auth/token-rows.mjs +1 -1
- package/dist/auth/token-text.mjs +9 -1
- package/dist/auth/tokens-base.d.mts +35 -0
- package/dist/auth/tokens-base.mjs +13 -0
- package/dist/auth/tokens-layer.d.mts +2 -28
- package/dist/auth/tokens-layer.mjs +6 -12
- package/dist/auth/tokens-public.d.mts +3 -3
- package/dist/auth/tokens.d.mts +7 -17
- package/dist/auth/tokens.mjs +9 -87
- package/dist/auth.d.mts +1 -4
- package/dist/auth.mjs +1 -3
- package/dist/client/answer.mjs +21 -42
- package/dist/client/client.d.mts +2 -4
- package/dist/client/git-http.mjs +35 -11
- package/dist/client/local.mjs +14 -13
- package/dist/client/push-upload.mjs +39 -12
- package/dist/client/remote.mjs +95 -31
- package/dist/client/run-remote-helper.d.mts +1 -0
- package/dist/client/run-remote-helper.mjs +58 -24
- package/dist/client/slice-push.d.mts +1 -1
- package/dist/client/transport.mjs +105 -46
- package/dist/contracts/access.d.mts +8 -8
- package/dist/contracts/actors.d.mts +2 -34
- package/dist/contracts/blobs.d.mts +57 -10
- package/dist/contracts/blobs.mjs +16 -2
- package/dist/contracts/call-allowance.d.mts +13 -0
- package/dist/contracts/call-allowance.mjs +44 -0
- package/dist/contracts/calls-spent.mjs +8 -3
- package/dist/contracts/client.d.mts +23 -19
- package/dist/contracts/commits.d.mts +34 -26
- package/dist/contracts/commits.mjs +9 -1
- package/dist/contracts/engine.d.mts +6 -1
- package/dist/contracts/engine.mjs +10 -1
- package/dist/contracts/files.d.mts +12 -12
- package/dist/contracts/forks.d.mts +27 -17
- package/dist/contracts/git-events.d.mts +29 -1
- package/dist/contracts/git-hooks.d.mts +1 -1
- package/dist/contracts/git.d.mts +39 -7
- package/dist/contracts/git.mjs +3 -2
- package/dist/contracts/grants.d.mts +24 -4
- package/dist/contracts/handlers.d.mts +1 -1
- package/dist/contracts/lfs.d.mts +28 -9
- package/dist/contracts/merges.d.mts +3 -2
- package/dist/contracts/objects.d.mts +103 -35
- package/dist/contracts/operations.d.mts +3 -0
- package/dist/contracts/operations.mjs +12 -2
- package/dist/contracts/push-uploads.d.mts +44 -5
- package/dist/contracts/push-uploads.mjs +7 -3
- package/dist/contracts/queue.d.mts +40 -12
- package/dist/contracts/queue.mjs +3 -4
- package/dist/contracts/refs.d.mts +50 -25
- package/dist/contracts/remote.d.mts +6 -7
- package/dist/contracts/remote.mjs +5 -4
- package/dist/contracts/repo-records.d.mts +1 -0
- package/dist/contracts/repos.d.mts +106 -127
- package/dist/contracts/repos.mjs +33 -4
- package/dist/contracts/result.d.mts +49 -25
- package/dist/contracts/result.mjs +52 -11
- package/dist/contracts/rules.d.mts +22 -22
- package/dist/contracts/server.d.mts +37 -111
- package/dist/contracts/services.d.mts +1 -1
- package/dist/contracts/signin.d.mts +1 -1
- package/dist/contracts/store.d.mts +6 -5
- package/dist/contracts/sync.d.mts +90 -26
- package/dist/contracts/sync.mjs +45 -11
- package/dist/contracts/tags.d.mts +10 -10
- package/dist/contracts/time.d.mts +3 -0
- package/dist/contracts/{promises.mjs → time.mjs} +1 -1
- package/dist/contracts/tokens.d.mts +15 -22
- package/dist/contracts/tokens.mjs +3 -3
- package/dist/contracts/topics.d.mts +1 -6
- package/dist/contracts/trees.d.mts +12 -12
- package/dist/contracts/work.d.mts +87 -12
- package/dist/contracts/work.mjs +8 -1
- package/dist/core/access.d.mts +1 -2
- package/dist/core/access.mjs +46 -13
- package/dist/core/ancestry.d.mts +10 -0
- package/dist/core/ancestry.mjs +6 -6
- package/dist/core/asked.mjs +43 -5
- package/dist/core/call-names.mjs +7 -1
- package/dist/core/call-services.mjs +13 -4
- package/dist/core/events/deliver.d.mts +1 -2
- package/dist/core/events/deliver.mjs +48 -33
- package/dist/core/events/retired.mjs +119 -0
- package/dist/core/forks.mjs +931 -435
- package/dist/core/hooks/groups.mjs +1 -1
- package/dist/core/imports.mjs +159 -15
- package/dist/core/index-job.mjs +128 -37
- package/dist/core/index-lost.d.mts +1 -2
- package/dist/core/index-lost.mjs +2 -2
- package/dist/core/job-view.mjs +8 -9
- package/dist/core/loose-tally.mjs +1 -1
- package/dist/core/mirror-rows.mjs +19 -4
- package/dist/core/objects/blobs.mjs +129 -3
- package/dist/core/objects/commits.mjs +16 -6
- package/dist/core/objects/lines.mjs +2 -2
- package/dist/core/objects/merges.mjs +4 -1
- package/dist/core/objects/objects-layer.d.mts +1 -1
- package/dist/core/objects/objects-layer.mjs +3 -3
- package/dist/core/objects/reading.mjs +24 -13
- package/dist/core/objects/tags.mjs +4 -1
- package/dist/core/objects/trees.mjs +2 -2
- package/dist/core/objects/writing.mjs +2 -2
- package/dist/core/own-writes.mjs +1 -1
- package/dist/core/parts.d.mts +10 -6
- package/dist/core/parts.mjs +3 -11
- package/dist/core/promise.mjs +9 -12
- package/dist/core/purge.mjs +316 -42
- package/dist/core/push-decide.mjs +3 -1
- package/dist/core/push-files.d.mts +12 -0
- package/dist/core/push-files.mjs +225 -0
- package/dist/core/push-repo.d.mts +8 -0
- package/dist/core/push-repo.mjs +56 -0
- package/dist/core/push.d.mts +17 -0
- package/dist/core/push.mjs +153 -70
- package/dist/core/receipts.mjs +34 -13
- package/dist/core/ref-index-job.mjs +4 -4
- package/dist/core/ref-view.mjs +61 -7
- package/dist/core/refs.mjs +18 -13
- package/dist/core/registered-rows.mjs +2 -2
- package/dist/core/repack.mjs +46 -28
- package/dist/core/repo-info.mjs +19 -12
- package/dist/core/repos.mjs +50 -22
- package/dist/core/rules/commit-changes.d.mts +0 -1
- package/dist/core/saved-caller-views.d.mts +7 -2
- package/dist/core/saved-caller-views.mjs +2 -2
- package/dist/core/saved-callers.d.mts +19 -2
- package/dist/core/seam.d.mts +16 -26
- package/dist/core/seam.mjs +7 -28
- package/dist/core/tokens.mjs +1 -1
- package/dist/core/view.d.mts +6 -0
- package/dist/core/view.mjs +51 -26
- package/dist/core/work.mjs +105 -35
- package/dist/effect.d.mts +5 -12
- package/dist/effect.mjs +3 -10
- package/dist/engine/failures.mjs +2 -1
- package/dist/engine/reads.mjs +17 -10
- package/dist/engine/walk.mjs +4 -4
- package/dist/event-streams/event-streams.d.mts +1 -1
- package/dist/event-streams/event-streams.mjs +1 -1
- package/dist/event-streams/stream.d.mts +3 -3
- package/dist/event-streams/stream.mjs +38 -15
- package/dist/extend.d.mts +4 -5
- package/dist/extend.mjs +3 -2
- package/dist/http/answers.mjs +12 -7
- package/dist/http/core-parts.mjs +129 -64
- package/dist/http/handler.mjs +36 -9
- package/dist/http/node.d.mts +14 -1
- package/dist/http/node.mjs +61 -31
- package/dist/http/parts.d.mts +2 -0
- package/dist/http/push-upload-job.mjs +507 -0
- package/dist/http/push-uploads.d.mts +1 -0
- package/dist/http/push-uploads.mjs +142 -69
- package/dist/http/upload-pack.mjs +10 -9
- package/dist/index.d.mts +27 -28
- package/dist/index.mjs +5 -8
- package/dist/lfs/answer.mjs +37 -0
- package/dist/lfs/base.d.mts +9 -3
- package/dist/lfs/base.mjs +27 -2
- package/dist/lfs/copy.d.mts +60 -0
- package/dist/lfs/copy.mjs +109 -0
- package/dist/lfs/layer.d.mts +15 -1
- package/dist/lfs/layer.mjs +28 -13
- package/dist/lfs/locks.mjs +2 -2
- package/dist/lfs/objects.d.mts +7 -0
- package/dist/lfs/objects.mjs +152 -55
- package/dist/lfs/pointers.mjs +2 -2
- package/dist/lfs/rows.d.mts +13 -0
- package/dist/lfs/rows.mjs +42 -8
- package/dist/lfs/service.d.mts +1 -7
- package/dist/lfs/service.mjs +1 -9
- package/dist/lfs/upkeep.mjs +48 -14
- package/dist/lfs/upload-most.mjs +5 -5
- package/dist/lfs/wire.mjs +6 -31
- package/dist/merges/merges.mjs +2 -2
- package/dist/node.d.mts +3 -3
- package/dist/protocol/bytes/buffers.mjs +13 -5
- package/dist/protocol/bytes/reader.mjs +6 -1
- package/dist/protocol/bytes/sha256-hasher.d.mts +15 -0
- package/dist/protocol/bytes/sha256.d.mts +32 -0
- package/dist/protocol/bytes/sha256.mjs +105 -49
- package/dist/protocol/bytes/streams.mjs +27 -1
- package/dist/protocol/diff/read.d.mts +4 -3
- package/dist/protocol/diff/read.mjs +8 -3
- package/dist/protocol/objects/lfs-pointer.d.mts +14 -2
- package/dist/protocol/objects/lfs-pointer.mjs +1 -3
- package/dist/protocol/objects/links-raw.mjs +24 -10
- package/dist/protocol/objects/tag.d.mts +1 -1
- package/dist/protocol/objects/tree.mjs +23 -6
- package/dist/protocol/packs/delta.d.mts +6 -3
- package/dist/protocol/packs/delta.mjs +96 -32
- package/dist/protocol/packs/idx.d.mts +2 -1
- package/dist/protocol/packs/idx.mjs +22 -3
- package/dist/protocol/packs/parts.d.mts +4 -1
- package/dist/protocol/packs/parts.mjs +10 -7
- package/dist/protocol/packs/reader.d.mts +5 -0
- package/dist/protocol/packs/reader.mjs +3 -2
- package/dist/protocol/packs/writer.mjs +26 -8
- package/dist/protocol/wire/advertisement.mjs +9 -4
- package/dist/protocol/wire/lines.d.mts +4 -2
- package/dist/protocol/wire/lines.mjs +11 -5
- package/dist/protocol/wire/push-uploads.mjs +13 -1
- package/dist/protocol/wire/v2.mjs +2 -2
- package/dist/protocol.d.mts +3 -1
- package/dist/protocol.mjs +3 -1
- package/dist/queue/advance.mjs +22 -25
- package/dist/queue/base.d.mts +55 -0
- package/dist/queue/base.mjs +44 -0
- package/dist/queue/calls.mjs +51 -54
- package/dist/queue/commit.mjs +1 -1
- package/dist/queue/host.d.mts +2 -22
- package/dist/queue/host.mjs +2 -13
- package/dist/queue/layer.d.mts +2 -1
- package/dist/queue/layer.mjs +11 -4
- package/dist/queue/limits.mjs +2 -0
- package/dist/queue/push-option.mjs +9 -24
- package/dist/queue/schedule.mjs +1 -1
- package/dist/queue/state.mjs +2 -10
- package/dist/queue/trim.mjs +6 -4
- package/dist/rest/blobs.mjs +29 -5
- package/dist/rest/caller.d.mts +4 -4231
- package/dist/rest/caller.mjs +5 -1
- package/dist/rest/client.d.mts +15 -5
- package/dist/rest/client.mjs +23 -2
- package/dist/rest/events.mjs +1 -2
- package/dist/rest/handler.mjs +4 -57
- package/dist/rest/handlers.mjs +68 -9
- package/dist/rest/layer.d.mts +2 -2
- package/dist/rest/layer.mjs +7 -13
- package/dist/rest/me.d.mts +3 -428
- package/dist/rest/paths.mjs +1 -0
- package/dist/rest/work.mjs +8 -0
- package/dist/server/check-fetch.mjs +3 -3
- package/dist/server/edge-node.d.mts +14 -15
- package/dist/server/edge-node.mjs +12 -12
- package/dist/server/edge.d.mts +21 -7
- package/dist/server/edge.mjs +32 -11
- package/dist/server/extension.mjs +1 -1
- package/dist/server/git-layer.d.mts +6 -11
- package/dist/server/git-layer.mjs +29 -23
- package/dist/server/git-namespace.d.mts +5 -4
- package/dist/server/git-namespace.mjs +3 -2
- package/dist/server/joined.d.mts +21 -40
- package/dist/server/joined.mjs +11 -62
- package/dist/server/lifecycle.mjs +65 -69
- package/dist/server/registry.mjs +28 -3
- package/dist/server/server.mjs +245 -465
- package/dist/signin/context.d.mts +1 -2
- package/dist/signin/layer.d.mts +1 -1
- package/dist/signin/layer.mjs +1 -1
- package/dist/storage/allotted.mjs +18 -3
- package/dist/storage/batch-upkeep.mjs +274 -0
- package/dist/{core/purge.d.mts → storage/batches.d.mts} +4 -4
- package/dist/storage/batches.mjs +344 -0
- package/dist/storage/budget.mjs +2 -2
- package/dist/storage/calls.d.mts +1 -2
- package/dist/storage/calls.mjs +144 -158
- package/dist/storage/chunks.d.mts +9 -0
- package/dist/storage/chunks.mjs +297 -0
- package/dist/storage/clean-up.mjs +85 -19
- package/dist/storage/counted-bucket.mjs +4 -4
- package/dist/storage/fetch.d.mts +1 -0
- package/dist/storage/fetch.mjs +298 -216
- package/dist/storage/file-limits.mjs +24 -0
- package/dist/storage/host-bucket.mjs +1 -2
- package/dist/storage/id-mix.mjs +19 -5
- package/dist/storage/index-bitmaps.mjs +9 -2
- package/dist/storage/index-build.d.mts +1 -1
- package/dist/storage/index-build.mjs +185 -84
- package/dist/storage/index-fetch.mjs +128 -74
- package/dist/storage/index-files.d.mts +3 -0
- package/dist/storage/index-files.mjs +10 -5
- package/dist/storage/index-graph.mjs +72 -22
- package/dist/storage/index-reach.mjs +33 -5
- package/dist/storage/index-remap.mjs +208 -65
- package/dist/storage/index-shallow.mjs +5 -3
- package/dist/storage/index-whole.mjs +127 -0
- package/dist/storage/largest-files.mjs +48 -0
- package/dist/storage/layout.mjs +23 -0
- package/dist/storage/lfs-pointers.mjs +10 -1
- package/dist/storage/loose.d.mts +7 -4
- package/dist/storage/loose.mjs +214 -67
- package/dist/storage/memory-budget.mjs +44 -8
- package/dist/storage/merge-plan.mjs +3 -2
- package/dist/storage/merge-row.mjs +7 -1
- package/dist/storage/merge-stream.mjs +164 -25
- package/dist/storage/merge-walk.mjs +8 -4
- package/dist/storage/merge-write.mjs +1 -1
- package/dist/storage/merge.d.mts +1 -1
- package/dist/storage/merge.mjs +1 -1
- package/dist/storage/object-rows.d.mts +1 -0
- package/dist/storage/object-rows.mjs +385 -65
- package/dist/storage/oid-table.mjs +171 -0
- package/dist/storage/pack-order.mjs +8 -4
- package/dist/storage/pack-ranges.d.mts +1 -2
- package/dist/storage/pack-ranges.mjs +4 -5
- package/dist/storage/pack-reads.d.mts +2 -1
- package/dist/storage/pack-reads.mjs +165 -49
- package/dist/storage/pack-receive.d.mts +1 -1
- package/dist/storage/pack-receive.mjs +85 -27
- package/dist/storage/packs.d.mts +1 -1
- package/dist/storage/packs.mjs +172 -86
- package/dist/storage/placed-reads.mjs +1 -1
- package/dist/storage/plan-columns.d.mts +4 -0
- package/dist/storage/plan-columns.mjs +238 -0
- package/dist/storage/prune-keep.mjs +299 -37
- package/dist/storage/prune-walk.mjs +240 -62
- package/dist/storage/prune.mjs +749 -213
- package/dist/storage/push-allotment.mjs +91 -12
- package/dist/storage/push-uploads.mjs +40 -16
- package/dist/storage/pushed-commits.mjs +4 -2
- package/dist/storage/quarantine.d.mts +1 -1
- package/dist/storage/quarantine.mjs +9 -9
- package/dist/storage/range-cache.mjs +125 -8
- package/dist/storage/ready.d.mts +1 -1
- package/dist/storage/ready.mjs +55 -25
- package/dist/storage/receive-bounds.mjs +51 -15
- package/dist/storage/receive-state.mjs +8 -0
- package/dist/storage/receive-steps.mjs +71 -18
- package/dist/storage/repack-backlog.mjs +6 -3
- package/dist/storage/repack.d.mts +2 -2
- package/dist/storage/repack.mjs +1 -8
- package/dist/storage/rows.d.mts +1 -1
- package/dist/storage/rows.mjs +13 -2
- package/dist/storage/runs.mjs +195 -43
- package/dist/storage/send-list.d.mts +1 -0
- package/dist/storage/send-list.mjs +54 -10
- package/dist/storage/shallow.d.mts +1 -0
- package/dist/storage/shallow.mjs +26 -4
- package/dist/storage/single-flight.mjs +13 -7
- package/dist/storage/stream-whole.mjs +132 -28
- package/dist/storage/unpack.mjs +371 -79
- package/dist/storage/visible.mjs +31 -3
- package/dist/storage/walk.mjs +194 -39
- package/dist/storage/wants.mjs +5 -5
- package/dist/store/bodies.mjs +38 -0
- package/dist/store/call-count.d.mts +8 -12
- package/dist/store/call-count.mjs +34 -46
- package/dist/store/catalogue.d.mts +2 -2
- package/dist/store/catalogue.mjs +146 -35
- package/dist/store/crossing.mjs +1 -3
- package/dist/store/cursor-seal-namespace.d.mts +2 -0
- package/dist/store/cursor-seal-public.d.mts +5 -0
- package/dist/store/cursor-seal-public.mjs +5 -0
- package/dist/store/cursor-seal.d.mts +16 -3
- package/dist/store/cursor-seal.mjs +40 -18
- package/dist/store/door.mjs +183 -0
- package/dist/store/errors.d.mts +3 -4
- package/dist/store/errors.mjs +24 -34
- package/dist/store/git-store.mjs +25 -7
- package/dist/store/job-try.mjs +9 -32
- package/dist/store/list-job.mjs +44 -8
- package/dist/store/records.d.mts +5 -0
- package/dist/store/records.mjs +12 -6
- package/dist/store/repo-record.d.mts +10 -9
- package/dist/store/repo-record.mjs +123 -28
- package/dist/store/reservations.mjs +1 -1
- package/dist/store/scopes.mjs +21 -2
- package/dist/store/settle.mjs +4 -4
- package/dist/sync/bound.d.mts +2 -0
- package/dist/sync/bound.mjs +11 -2
- package/dist/sync/github.d.mts +6 -1
- package/dist/sync/github.mjs +56 -44
- package/dist/sync/http.mjs +36 -1
- package/dist/sync/import.mjs +32 -18
- package/dist/sync/layer.mjs +6 -2
- package/dist/sync/lfs-batch.mjs +118 -0
- package/dist/sync/lfs-copy.mjs +262 -0
- package/dist/sync/mirror.mjs +227 -151
- package/dist/sync/said.mjs +16 -37
- package/dist/sync/smart-http.mjs +4 -2
- package/dist/sync/step.mjs +58 -30
- package/dist/sync/tries.mjs +52 -21
- package/dist/sync.d.mts +2 -2
- package/dist/topics/advance.mjs +10 -11
- package/dist/topics/base.d.mts +15 -0
- package/dist/topics/base.mjs +8 -0
- package/dist/topics/host.mjs +2 -20
- package/dist/topics/layer.d.mts +4 -9
- package/dist/topics/layer.mjs +3 -4
- package/dist/topics/members.mjs +4 -4
- package/dist/topics/public.d.mts +2 -1
- package/dist/topics/topic.mjs +2 -2
- package/package.json +5 -9
- package/dist/auth/bridge.mjs +0 -30
- package/dist/auth/helpers.d.mts +0 -17
- package/dist/contracts/promises.d.mts +0 -39
- package/dist/core/call-names.d.mts +0 -3
- package/dist/core/clock.mjs +0 -18
- package/dist/core/registered-rows.d.mts +0 -5
- package/dist/core/repack.d.mts +0 -11
- package/dist/http/handler.d.mts +0 -2
- package/dist/lfs/calls.mjs +0 -26
- package/dist/rest/api.d.mts +0 -23
- package/dist/rest/blobs.d.mts +0 -825
- package/dist/rest/commits.d.mts +0 -3510
- package/dist/rest/errors.d.mts +0 -2104
- package/dist/rest/events.d.mts +0 -423
- package/dist/rest/files.d.mts +0 -1330
- package/dist/rest/forks.d.mts +0 -2136
- package/dist/rest/handler.d.mts +0 -21
- package/dist/rest/handlers.d.mts +0 -8
- package/dist/rest/merges.d.mts +0 -473
- package/dist/rest/queue.d.mts +0 -5861
- package/dist/rest/refs.d.mts +0 -2959
- package/dist/rest/repos.d.mts +0 -2539
- package/dist/rest/tags.d.mts +0 -1304
- package/dist/rest/tokens.d.mts +0 -2590
- package/dist/rest/topics.d.mts +0 -2204
- package/dist/rest/trees.d.mts +0 -1693
- package/dist/rest/work.d.mts +0 -1248
- package/dist/rest.d.mts +0 -2
- package/dist/rest.mjs +0 -1
- package/dist/server/lifecycle.d.mts +0 -2
- package/dist/server/registry.d.mts +0 -16
- package/dist/server/server.d.mts +0 -36
- package/dist/storage/repack-job.d.mts +0 -3
- package/dist/store/promises.d.mts +0 -11
- package/dist/store/promises.mjs +0 -327
- package/dist/topics/host.d.mts +0 -7
package/dist/server/server.mjs
CHANGED
|
@@ -1,30 +1,29 @@
|
|
|
1
1
|
import { PrivateRefs } from "../contracts/access.mjs";
|
|
2
2
|
import { pushRefLimitOf } from "../core/push-decide.mjs";
|
|
3
|
-
import { millis } from "../contracts/
|
|
3
|
+
import { millis } from "../contracts/time.mjs";
|
|
4
4
|
import { fail } from "../contracts/result.mjs";
|
|
5
|
-
import { Tokens } from "../contracts/tokens.mjs";
|
|
6
5
|
import { Authorize } from "../contracts/authorize.mjs";
|
|
7
6
|
import { RepoRecords } from "../contracts/repo-records.mjs";
|
|
8
|
-
import {
|
|
7
|
+
import { host } from "../contracts/git.mjs";
|
|
9
8
|
import { Refs } from "../contracts/refs.mjs";
|
|
10
9
|
import { Rules } from "../contracts/rules.mjs";
|
|
11
10
|
import { accessOf, audienceOf, authorizer } from "../auth/authorize.mjs";
|
|
12
|
-
import { authOf, policyOf } from "../auth/bridge.mjs";
|
|
13
11
|
import { grantFences } from "../auth/fences.mjs";
|
|
14
12
|
import { grantAgain, heldGrants } from "../auth/grants.mjs";
|
|
15
13
|
import { identifier } from "../auth/identify.mjs";
|
|
16
|
-
import {
|
|
17
|
-
import { TokensBase, noTokens } from "../auth/tokens-
|
|
14
|
+
import { tokenCleanupJob } from "../auth/token-cleanup.mjs";
|
|
15
|
+
import { TokensBase, noTokens } from "../auth/tokens-base.mjs";
|
|
18
16
|
import { blobCalls } from "../core/objects/blobs.mjs";
|
|
19
17
|
import { commitCalls } from "../core/objects/commits.mjs";
|
|
20
18
|
import { fileCalls } from "../core/objects/files.mjs";
|
|
21
19
|
import { mergeCalls } from "../core/objects/merges.mjs";
|
|
22
20
|
import { tagCalls } from "../core/objects/tags.mjs";
|
|
23
21
|
import { treeCalls } from "../core/objects/trees.mjs";
|
|
22
|
+
import { acting } from "../core/access.mjs";
|
|
24
23
|
import { refIndexOf } from "../core/ref-index.mjs";
|
|
25
24
|
import { callNames } from "../core/call-names.mjs";
|
|
26
|
-
import { clocksOf } from "../core/clock.mjs";
|
|
27
25
|
import { deliveryLog, workFailed } from "../core/events/deliver.mjs";
|
|
26
|
+
import { checkRetired, newRetireStart, writeRetired } from "../core/events/retired.mjs";
|
|
28
27
|
import { servedSources } from "../core/rules/protect.mjs";
|
|
29
28
|
import { rulesOf } from "../core/rules/service.mjs";
|
|
30
29
|
import { refsAs, refsCalls } from "../core/refs.mjs";
|
|
@@ -38,70 +37,57 @@ import { refIndexJob, refIndexJobRow } from "../core/ref-index-job.mjs";
|
|
|
38
37
|
import { forkCalls } from "../core/forks.mjs";
|
|
39
38
|
import { repoCalls } from "../core/repos.mjs";
|
|
40
39
|
import { EventStreams } from "../event-streams/event-streams.mjs";
|
|
41
|
-
import { MergeParts } from "../core/merge-parts.mjs";
|
|
42
40
|
import { streamsOver } from "../event-streams/stream.mjs";
|
|
43
|
-
import {
|
|
41
|
+
import { renamedTo, seamAuthorize } from "../core/seam.mjs";
|
|
44
42
|
import { checkFetchOver } from "./check-fetch.mjs";
|
|
45
43
|
import { tokenCallsAs } from "../core/tokens.mjs";
|
|
46
44
|
import { workCalls } from "../core/work.mjs";
|
|
47
|
-
import {
|
|
45
|
+
import { make } from "../http/core-parts.mjs";
|
|
48
46
|
import { refusal } from "../http/answers.mjs";
|
|
49
|
-
import { LfsBase } from "../lfs/base.mjs";
|
|
50
|
-
import { UploadsBase
|
|
51
|
-
import {
|
|
52
|
-
import {
|
|
53
|
-
import {
|
|
54
|
-
import {
|
|
55
|
-
import { pushUploads } from "../http/push-uploads.mjs";
|
|
56
|
-
import { signInRegistration } from "../signin/layer.mjs";
|
|
57
|
-
import { signInPaths } from "../signin/wire.mjs";
|
|
47
|
+
import { LfsBase, lfsCalls } from "../lfs/base.mjs";
|
|
48
|
+
import { UploadsBase } from "./uploads.mjs";
|
|
49
|
+
import { make as make$1 } from "../http/handler.mjs";
|
|
50
|
+
import { normalBase } from "../http/paths.mjs";
|
|
51
|
+
import { pushUploadJob } from "../http/push-upload-job.mjs";
|
|
52
|
+
import { make as make$2 } from "../http/push-uploads.mjs";
|
|
58
53
|
import { hostRecordOf, pinOf } from "../store/catalogue.mjs";
|
|
59
|
-
import { answerOf } from "../contracts/calls-spent.mjs";
|
|
60
54
|
import { closedError } from "../store/closed.mjs";
|
|
61
|
-
import { clientWentAway
|
|
55
|
+
import { clientWentAway } from "../store/errors.mjs";
|
|
62
56
|
import { cursorSeal } from "../store/cursor-seal.mjs";
|
|
63
57
|
import { gitStore } from "../store/git-store.mjs";
|
|
64
|
-
import { doorBucket, doorLinks, doorRecords, doorUploads,
|
|
58
|
+
import { doorBucket, doorLinks, doorQueue, doorRecords, doorUploads, throughBridge } from "../store/door.mjs";
|
|
65
59
|
import { defaultFetchLimits } from "../storage/fetch.mjs";
|
|
66
60
|
import { countedBucket } from "../storage/counted-bucket.mjs";
|
|
67
61
|
import { hostFailures, hostLinks, hostUploads } from "../storage/host-bucket.mjs";
|
|
68
62
|
import { pushUploadUpkeep } from "../storage/push-uploads.mjs";
|
|
69
|
-
import { checkedLimits, countedMost, hookCallsBefore, lessBefore
|
|
70
|
-
import {
|
|
71
|
-
import { exitOn, noCall, syncIn, uncounted } from "../store/crossing.mjs";
|
|
63
|
+
import { checkedLimits, countedMost, hookCallsBefore, lessBefore } from "../store/call-count.mjs";
|
|
64
|
+
import { jobLimitsOf, jobsWithin } from "../store/job-try.mjs";
|
|
72
65
|
import { pruneFloor } from "../storage/rows.mjs";
|
|
73
|
-
import {
|
|
74
|
-
import {
|
|
75
|
-
import { QueueBase, QueueInternals, queueKeysOf, queueOptions } from "../queue/host.mjs";
|
|
76
|
-
import { queuePush } from "../queue/push-option.mjs";
|
|
77
|
-
import { buildMillisecondsOf } from "../queue/limits.mjs";
|
|
78
|
-
import { topicsOptions } from "../topics/host.mjs";
|
|
79
|
-
import { TopicsBase, topicsRegistration } from "../topics/layer.mjs";
|
|
80
|
-
import { MergeQueue } from "../contracts/queue.mjs";
|
|
81
|
-
import { queueService } from "../queue/layer.mjs";
|
|
66
|
+
import { QueueBase, noQueuePush } from "../queue/base.mjs";
|
|
67
|
+
import { TopicsBase } from "../topics/base.mjs";
|
|
82
68
|
import { listJob } from "../store/list-job.mjs";
|
|
83
69
|
import { openExtensions } from "./extension.mjs";
|
|
84
|
-
import {
|
|
85
|
-
import {
|
|
86
|
-
import { aroundCalls, callOrMissing, guardedCalls, heldGroup, lazyGroups, providedCalls
|
|
87
|
-
import { CoreParts, ObjectsParts, QueueParts, SyncBase
|
|
70
|
+
import { joinedOf } from "./joined.mjs";
|
|
71
|
+
import { retireErrors, retryDelay } from "./lifecycle.mjs";
|
|
72
|
+
import { aroundCalls, callOrMissing, guardedCall, guardedCalls, heldGroup, lazyGroups, providedCalls } from "../core/promise.mjs";
|
|
73
|
+
import { CoreParts, ObjectsParts, QueueParts, SyncBase } from "../core/parts.mjs";
|
|
88
74
|
import { SavedCallers, savedCallersOf } from "../core/saved-caller-views.mjs";
|
|
89
75
|
import { withAudienceMemo } from "../core/ref-view.mjs";
|
|
90
76
|
import { Changes } from "../core/changes.mjs";
|
|
91
77
|
import { changes } from "../core/rules/changes.mjs";
|
|
92
78
|
import { SealedObjects, View, objectsOverViews, viewOver } from "../core/view.mjs";
|
|
93
79
|
import { IndexedStorage, Objects, Storage } from "../core/objects/objects.mjs";
|
|
94
|
-
import
|
|
80
|
+
import { pushFilesOf } from "../core/push-files.mjs";
|
|
81
|
+
import { pushRepoOf } from "../core/push-repo.mjs";
|
|
82
|
+
import * as Clock from "effect/Clock";
|
|
95
83
|
import * as Effect from "effect/Effect";
|
|
96
84
|
import * as Option from "effect/Option";
|
|
97
85
|
import * as Cause from "effect/Cause";
|
|
98
|
-
import * as Exit from "effect/Exit";
|
|
99
86
|
import * as EffectResult from "effect/Result";
|
|
100
87
|
import { Bucket, BucketLinks, BucketUploads, CallLimits, JobQueue, Records, RequestLimits } from "@ref0/infra";
|
|
101
88
|
import * as Context from "effect/Context";
|
|
102
|
-
import * as Layer from "effect/Layer";
|
|
103
89
|
import * as References from "effect/References";
|
|
104
|
-
import * as
|
|
90
|
+
import * as Duration from "effect/Duration";
|
|
105
91
|
// src/server/server.ts
|
|
106
92
|
/**
|
|
107
93
|
* The server's `fetchLimits`, or a `TypeError` naming the one that isn't a whole number above 0,
|
|
@@ -124,84 +110,31 @@ const fetchLimitsOf = (given) => {
|
|
|
124
110
|
milliseconds: given.milliseconds
|
|
125
111
|
};
|
|
126
112
|
};
|
|
127
|
-
/** `factory`'s objects, as they keep their index: `
|
|
113
|
+
/** `factory`'s objects, as they keep their index: `access` is read only over them. */
|
|
128
114
|
const indexedOpen = (factory, input) => factory.open(input);
|
|
129
115
|
/** `most` as a count's bound: each kind it leaves out unbound. */
|
|
130
116
|
const boundOf = (most) => ({
|
|
131
117
|
bucket: most?.bucket ?? Number.POSITIVE_INFINITY,
|
|
132
118
|
subrequests: most?.subrequests ?? Number.POSITIVE_INFINITY
|
|
133
119
|
});
|
|
134
|
-
/**
|
|
135
|
-
const
|
|
136
|
-
/** The server's wiring, in its runtime: built once, with the runtime. */
|
|
137
|
-
const Wired = /* @__PURE__ */ Context.Service("@ref0/git/server/Wired");
|
|
138
|
-
/**
|
|
139
|
-
* The groups a face names: every group, less the optional ones `optional` leaves off, `tokens`
|
|
140
|
-
* unless `tokensOn`, and `queue` unless `queueOn` or `optional` names one.
|
|
141
|
-
*/
|
|
142
|
-
const namesOf = (optional, tokensOn, queueOn) => {
|
|
120
|
+
/** The groups a joined face names: every group less `topics`, which is the `Topics` service's. */
|
|
121
|
+
const joinedNamesOf = () => {
|
|
143
122
|
const names = { ...callNames };
|
|
144
|
-
|
|
145
|
-
if (!queueOn && optional.queue === void 0) delete names.queue;
|
|
146
|
-
if (optional.topics === void 0) delete names.topics;
|
|
123
|
+
delete names.topics;
|
|
147
124
|
return names;
|
|
148
125
|
};
|
|
149
|
-
/** `Merges`' part over the one `loaded` makes: each call waits on that load, which runs once. */
|
|
150
|
-
const partsOnce = (loaded) => {
|
|
151
|
-
const parts = Effect.map(loaded, (context) => Context.get(context, MergeParts));
|
|
152
|
-
return {
|
|
153
|
-
mergeTrees: (read, input, allot, call, roots) => Effect.flatMap(parts, (one) => one.mergeTrees(read, input, allot, call, roots)),
|
|
154
|
-
lineDiff: (allot) => Effect.flatMap(parts, (one) => one.lineDiff(allot))
|
|
155
|
-
};
|
|
156
|
-
};
|
|
157
|
-
/**
|
|
158
|
-
* `createGitServer`'s options onto the Layers that replace them, run once its wiring is built and
|
|
159
|
-
* before the seal, in one list: core's inputs first, then the features, `lfs` building
|
|
160
|
-
* `Lfs.layer()`, `topics` `Topics.layer` and `pushes.upload` `Git.layerUploads`. 2c-3b deletes
|
|
161
|
-
* it, with `createGitServer`.
|
|
162
|
-
*/
|
|
163
|
-
const bridged = (setup) => ({
|
|
164
|
-
inputs: setup.access === void 0 ? Layer.empty : Layer.succeed(PrivateRefs, setup.access),
|
|
165
|
-
features: Effect.fnUntraced(function* (services, registry) {
|
|
166
|
-
if (setup.lfs !== void 0) {
|
|
167
|
-
const registration = yield* registry.register({ name: "lfs" });
|
|
168
|
-
yield* Effect.provideContext(lfsRegistration(registration, setup.lfs), services);
|
|
169
|
-
}
|
|
170
|
-
if (setup.topics !== void 0) {
|
|
171
|
-
const registration = yield* registry.register({
|
|
172
|
-
name: "topics",
|
|
173
|
-
scopes: ["git/topic/", "git/topics"]
|
|
174
|
-
});
|
|
175
|
-
const queue = Context.getOrUndefined(services, QueueInternals);
|
|
176
|
-
if (queue === void 0) return yield* Effect.die(/* @__PURE__ */ new Error("The topics bridge requires a queue"));
|
|
177
|
-
yield* Effect.provideContext(topicsRegistration(registration, topicsOptions(setup.topics)).pipe(Effect.provideService(QueueInternals, queue), Effect.provideService(MergeQueue, queueService(queue))), services);
|
|
178
|
-
}
|
|
179
|
-
if (setup.signIn !== void 0) {
|
|
180
|
-
const registration = yield* registry.register({
|
|
181
|
-
name: "signin",
|
|
182
|
-
scopes: ["git/signin"]
|
|
183
|
-
});
|
|
184
|
-
yield* Effect.provideContext(signInRegistration(registration, setup.signIn), services);
|
|
185
|
-
}
|
|
186
|
-
const upload = setup.pushes?.upload;
|
|
187
|
-
if (upload !== void 0 && Context.get(services, UploadsBase).staging !== void 0) yield* Effect.provideContext(attachUploads(upload), services);
|
|
188
|
-
})
|
|
189
|
-
});
|
|
190
126
|
/** Git's own wiring over the adapter's services, as the runtime's build runs it. */
|
|
191
127
|
const wireServer = (options, wiring) => {
|
|
192
|
-
const { adapter,
|
|
128
|
+
const { adapter, fetchLimits, files, repo, deciders, grants, extensions, guard, through, closing } = wiring;
|
|
193
129
|
const runtimeClock = wiring.clock;
|
|
194
|
-
const
|
|
195
|
-
const
|
|
196
|
-
const { clock, now } = clocksOf(adapter.clock);
|
|
130
|
+
const { jobs, records: store } = adapter;
|
|
131
|
+
const now = Effect.sync(() => runtimeClock.currentTimeMillisUnsafe());
|
|
197
132
|
const counted = adapter.bucket === void 0 ? void 0 : countedBucket(adapter.bucket);
|
|
198
|
-
if (options.lfs !== void 0 && counted === void 0) throw new TypeError("lfs() keeps its objects in the adapter's bucket: give the adapter a bucket");
|
|
199
133
|
const callLimits = lessBefore(checkedLimits(adapter.callLimits, "The adapter's callLimits."));
|
|
200
|
-
const jobLimits = jobLimitsOf(adapter.callLimits);
|
|
201
134
|
const opening = {
|
|
202
135
|
store: gitStore(store),
|
|
203
136
|
bucket: adapter.objectsBucket,
|
|
204
|
-
clock,
|
|
137
|
+
clock: runtimeClock,
|
|
205
138
|
fetchLimits,
|
|
206
139
|
callLimits
|
|
207
140
|
};
|
|
@@ -209,24 +142,31 @@ const wireServer = (options, wiring) => {
|
|
|
209
142
|
const indexed = wiring.access === void 0 ? void 0 : indexedOpen(options.objects, opening);
|
|
210
143
|
const objects = indexed ?? options.objects.open(opening);
|
|
211
144
|
const sealed = indexed === void 0 ? new SealedObjects(objects) : SealedObjects.indexed(indexed);
|
|
212
|
-
const cleanup = tokenCleanupJob(now);
|
|
145
|
+
const cleanup = tokenCleanupJob(store, now);
|
|
213
146
|
const { registry } = extensions;
|
|
214
147
|
const events = deliveryLog({
|
|
215
148
|
store,
|
|
216
149
|
now,
|
|
217
150
|
fetchLimits
|
|
218
151
|
});
|
|
219
|
-
|
|
220
|
-
|
|
152
|
+
const retired = options.events?.retired ?? [];
|
|
153
|
+
registry.bindDeliveries((registered) => {
|
|
154
|
+
checkRetired(registered.map((delivery) => delivery.name), retired);
|
|
155
|
+
return events.fill(registered);
|
|
156
|
+
});
|
|
157
|
+
const onFailure = workFailed(store, events, now);
|
|
221
158
|
const upkeep = upkeepsOf([...counted === void 0 ? [] : [pushUploadUpkeep(counted, adapter.uploads)], registry.upkeep]);
|
|
222
159
|
const index = objects.index === void 0 ? void 0 : indexJob({
|
|
160
|
+
store,
|
|
223
161
|
objects: sealed,
|
|
224
162
|
now,
|
|
225
163
|
events,
|
|
226
|
-
repackJobRow: () => repackJobRow(repack)
|
|
164
|
+
repackJobRow: () => repackJobRow(repack),
|
|
165
|
+
cpuMs: adapter.requestLimits.cpuMs
|
|
227
166
|
});
|
|
228
167
|
const indexRow = index === void 0 ? void 0 : (round) => indexJobRow(index, round);
|
|
229
168
|
const repack = repackJob({
|
|
169
|
+
store,
|
|
230
170
|
objects: sealed,
|
|
231
171
|
now,
|
|
232
172
|
fetchLimits,
|
|
@@ -236,15 +176,20 @@ const wireServer = (options, wiring) => {
|
|
|
236
176
|
indexJobRow: indexRow
|
|
237
177
|
});
|
|
238
178
|
const refIndex = refIndexOf(wiring.access, registry.hiddenRefs);
|
|
239
|
-
const rebuild = refIndex === void 0 ? void 0 : refIndexJob({
|
|
179
|
+
const rebuild = refIndex === void 0 ? void 0 : refIndexJob({
|
|
180
|
+
store,
|
|
181
|
+
index: refIndex
|
|
182
|
+
});
|
|
240
183
|
const purge = purgeJob({
|
|
184
|
+
store,
|
|
241
185
|
now,
|
|
242
186
|
fetchLimits,
|
|
243
187
|
parts: [registry.purge],
|
|
244
|
-
scopes: registry.repoScopes
|
|
188
|
+
scopes: registry.repoScopes,
|
|
189
|
+
deliveries: events.deliveries
|
|
245
190
|
});
|
|
246
191
|
const own = [
|
|
247
|
-
listJob,
|
|
192
|
+
listJob(store),
|
|
248
193
|
repack,
|
|
249
194
|
purge
|
|
250
195
|
];
|
|
@@ -253,7 +198,6 @@ const wireServer = (options, wiring) => {
|
|
|
253
198
|
own.push(cleanup);
|
|
254
199
|
const gits = registry.bridge("git");
|
|
255
200
|
gits.knowJobs(own);
|
|
256
|
-
jobs.register(...jobsWithin(jobLimits, own));
|
|
257
201
|
const decides = {
|
|
258
202
|
policy: deciders.policy,
|
|
259
203
|
grants
|
|
@@ -314,35 +258,28 @@ const wireServer = (options, wiring) => {
|
|
|
314
258
|
});
|
|
315
259
|
const stored = Context.make(Storage, objects).pipe(Context.add(ObjectsParts, {
|
|
316
260
|
objects: sealed,
|
|
317
|
-
fetchLimits
|
|
261
|
+
fetchLimits,
|
|
262
|
+
files,
|
|
263
|
+
repo
|
|
318
264
|
}), Context.add(Objects, objectsOverViews), Context.add(Changes, changes));
|
|
319
|
-
const base = Context.make(CoreParts, parts).pipe(Context.add(Rules, wiring.rules), Context.merge(indexed === void 0 ? stored : Context.add(stored, IndexedStorage, indexed)), Context.add(QueueParts, { jobs }), Context.add(Authorize, decider), Context.add(Clock
|
|
320
|
-
const
|
|
321
|
-
const viewed = Context.add(merging, View, viewOver(merging));
|
|
265
|
+
const base = Context.make(CoreParts, parts).pipe(Context.add(Rules, wiring.rules), Context.merge(indexed === void 0 ? stored : Context.add(stored, IndexedStorage, indexed)), Context.add(QueueParts, { jobs }), Context.add(Authorize, decider), Context.add(Clock.Clock, runtimeClock), Context.merge(wiring.logging));
|
|
266
|
+
const viewed = Context.add(base, View, viewOver(base));
|
|
322
267
|
const needs = Context.add(viewed, Refs, providedCalls(refsCalls, viewed));
|
|
323
268
|
const streams = streamsOver({
|
|
324
|
-
clock,
|
|
269
|
+
clock: runtimeClock,
|
|
325
270
|
guard,
|
|
326
271
|
closing,
|
|
327
272
|
through
|
|
328
273
|
}, needs);
|
|
329
|
-
const queueHost = queueOf === void 0 ? void 0 : {
|
|
330
|
-
needs,
|
|
331
|
-
records: rawRecords,
|
|
332
|
-
options: queueOf,
|
|
333
|
-
keys: wiring.optional.queueKeys,
|
|
334
|
-
buildMilliseconds: buildMillisecondsOf(adapter.requestLimits.cpuMs)
|
|
335
|
-
};
|
|
336
274
|
const queueHeld = wiring.queue;
|
|
337
|
-
queueHeld.host = queueHost;
|
|
338
275
|
const queueBase = QueueBase.of({
|
|
339
|
-
records:
|
|
276
|
+
records: store,
|
|
340
277
|
needs,
|
|
341
278
|
onFailure,
|
|
342
279
|
cpuMs: adapter.requestLimits.cpuMs,
|
|
343
|
-
attach: (
|
|
344
|
-
if (queueHeld.
|
|
345
|
-
queueHeld.
|
|
280
|
+
attach: (queue) => Effect.suspend(() => {
|
|
281
|
+
if (queueHeld.attached !== void 0) return Effect.die(/* @__PURE__ */ new TypeError("The server has a merge queue: provide MergeQueue.layer once"));
|
|
282
|
+
queueHeld.attached = queue;
|
|
346
283
|
return Effect.void;
|
|
347
284
|
})
|
|
348
285
|
});
|
|
@@ -356,43 +293,52 @@ const wireServer = (options, wiring) => {
|
|
|
356
293
|
if (lfsAttached !== void 0) return Effect.die(/* @__PURE__ */ new TypeError("The server has Git LFS: provide Lfs.layer once"));
|
|
357
294
|
lfsAttached = lfs;
|
|
358
295
|
return registry.addCheck(lfs.check);
|
|
359
|
-
})
|
|
296
|
+
}),
|
|
297
|
+
copy: Effect.sync(() => lfsAttached?.copy)
|
|
360
298
|
});
|
|
361
299
|
const { uploads } = adapter;
|
|
362
300
|
const staging = counted === void 0 || uploads === void 0 ? void 0 : {
|
|
363
301
|
bucket: counted,
|
|
364
302
|
uploads
|
|
365
303
|
};
|
|
304
|
+
let httpParts;
|
|
305
|
+
const stepping = staging !== void 0 && objects.stage !== void 0 && objects.receiveStep !== void 0;
|
|
306
|
+
if (stepping) {
|
|
307
|
+
const stepJobs = [pushUploadJob({
|
|
308
|
+
...staging,
|
|
309
|
+
needs,
|
|
310
|
+
cpuMs: adapter.requestLimits.cpuMs,
|
|
311
|
+
http: () => {
|
|
312
|
+
if (httpParts === void 0) throw new TypeError("A push upload landed before its server was built");
|
|
313
|
+
return httpParts;
|
|
314
|
+
}
|
|
315
|
+
})];
|
|
316
|
+
gits.knowJobs(stepJobs);
|
|
317
|
+
own.push(...stepJobs);
|
|
318
|
+
}
|
|
366
319
|
let uploadsAttached;
|
|
367
320
|
const uploadsBase = UploadsBase.of({
|
|
368
321
|
staging,
|
|
369
322
|
attach: (above) => Effect.suspend(() => {
|
|
370
323
|
if (staging === void 0 || uploadsAttached !== void 0) return Effect.die(/* @__PURE__ */ new TypeError("The server takes push uploads: provide Git.layerUploads once"));
|
|
371
|
-
uploadsAttached =
|
|
324
|
+
uploadsAttached = make$2(needs, staging, above, adapter.requestLimits.cpuMs);
|
|
372
325
|
return Effect.void;
|
|
373
326
|
})
|
|
374
327
|
});
|
|
375
|
-
if (queueHost !== void 0) {
|
|
376
|
-
registry.bridge("queue", "refs/queue/");
|
|
377
|
-
const queueJobList = queueJobs(queueHost, onFailure).map((job) => job(gitJob));
|
|
378
|
-
gits.knowJobs(queueJobList);
|
|
379
|
-
jobs.register(...jobsWithin(jobLimits, queueJobList));
|
|
380
|
-
}
|
|
381
328
|
let topicsAttached;
|
|
382
329
|
const topicsBase = TopicsBase.of({ attach: (service) => Effect.sync(() => {
|
|
383
330
|
topicsAttached = service;
|
|
384
331
|
}) });
|
|
385
332
|
const tokensHeld = wiring.tokens;
|
|
386
333
|
const tokensBase = TokensBase.of({
|
|
387
|
-
|
|
334
|
+
store,
|
|
335
|
+
now,
|
|
336
|
+
cleanup,
|
|
337
|
+
events,
|
|
338
|
+
attach: (calls) => Effect.suspend(() => {
|
|
388
339
|
if (tokensHeld.calls !== void 0) return Effect.die(/* @__PURE__ */ new TypeError("The server has Git's own tokens: provide Tokens.layer() once"));
|
|
389
|
-
tokensHeld.calls =
|
|
390
|
-
|
|
391
|
-
now,
|
|
392
|
-
cleanup,
|
|
393
|
-
events
|
|
394
|
-
});
|
|
395
|
-
return Effect.succeed(tokensHeld.calls);
|
|
340
|
+
tokensHeld.calls = calls;
|
|
341
|
+
return Effect.void;
|
|
396
342
|
}),
|
|
397
343
|
held: Effect.sync(() => tokensHeld.calls === void 0 ? void 0 : {
|
|
398
344
|
tokens: tokensHeld.calls,
|
|
@@ -402,15 +348,6 @@ const wireServer = (options, wiring) => {
|
|
|
402
348
|
refuse: (error) => refusal(error, true)
|
|
403
349
|
})
|
|
404
350
|
});
|
|
405
|
-
if (optional.tokens !== void 0) {
|
|
406
|
-
registry.bridge("tokens");
|
|
407
|
-
tokensHeld.calls = tokenCalls({
|
|
408
|
-
store,
|
|
409
|
-
now,
|
|
410
|
-
cleanup,
|
|
411
|
-
events
|
|
412
|
-
});
|
|
413
|
-
}
|
|
414
351
|
const identify = identifier({
|
|
415
352
|
store,
|
|
416
353
|
tokens: () => tokensHeld.calls !== void 0,
|
|
@@ -419,20 +356,17 @@ const wireServer = (options, wiring) => {
|
|
|
419
356
|
held: grants,
|
|
420
357
|
now
|
|
421
358
|
});
|
|
422
|
-
const decided = Context.add(records, Authorize, decider).pipe(Context.add(Refs, Context.get(needs, Refs)), Context.add(Rules, wiring.rules), Context.add(Objects, objectsOverViews), Context.merge(callServices(needs)), Context.add(Events, { log: events }), Context.add(QueueBase, queueBase), Context.add(SyncBase, {
|
|
359
|
+
const decided = Context.add(records, Authorize, decider).pipe(Context.add(Refs, Context.get(needs, Refs)), Context.add(Rules, wiring.rules), Context.add(Objects, objectsOverViews), Context.merge(callServices(needs, (effect) => withAudienceMemo(guardedCall(wiring.through)(effect)))), Context.add(Events, { log: events }), Context.add(QueueBase, queueBase), Context.add(SyncBase, {
|
|
423
360
|
needs,
|
|
424
361
|
pushRefsMost: pushRefLimitOf(refIndex),
|
|
425
362
|
through: wiring.through
|
|
426
|
-
}), Context.add(SavedCallers, savedCallersOf(needs,
|
|
427
|
-
const
|
|
428
|
-
const withTokens = tokensHeld.calls === void 0 ? queuedServices : Context.add(queuedServices, Tokens, tokensHeld.calls);
|
|
429
|
-
const streamed = Context.add(withTokens, EventStreams, { feed: streams.feed });
|
|
430
|
-
const services = merges === void 0 ? streamed : Context.merge(streamed, merges);
|
|
363
|
+
}), Context.add(SavedCallers, savedCallersOf(needs, (entry) => queueHeld.attached === void 0 ? Effect.succeed(void 0) : queueHeld.attached.entryAdder(entry))), Context.add(LfsBase, lfsBase), Context.add(UploadsBase, uploadsBase), Context.add(TopicsBase, topicsBase), Context.add(TokensBase, tokensBase));
|
|
364
|
+
const services = Context.add(decided, EventStreams, { feed: streams.feed });
|
|
431
365
|
/**
|
|
432
366
|
* Every group of the server's calls deciding for `bound`, over `needs`: the one list `callsAs`
|
|
433
367
|
* and `hostCalls` both build from, so a group added to one is in the other. `Git.host`'s are host
|
|
434
|
-
* code's, as `asHost` says. An optional group is there
|
|
435
|
-
*
|
|
368
|
+
* code's, as `asHost` says. An optional group is there once its feature attached, as
|
|
369
|
+
* `tokensHeld` and `queueHeld` hold it.
|
|
436
370
|
*/
|
|
437
371
|
const groupsOf = (bound) => {
|
|
438
372
|
const over = (calls) => aroundCalls(calls, (effect) => Effect.provideContext(acting(bound, effect), needs));
|
|
@@ -449,8 +383,8 @@ const wireServer = (options, wiring) => {
|
|
|
449
383
|
merges: over(mergeCalls(bound)),
|
|
450
384
|
lfs: over(lfsCalls(() => lfsAttached?.read, bound))
|
|
451
385
|
};
|
|
452
|
-
const queue = queueHeld.
|
|
453
|
-
if (queue !== void 0) groups.queue = aroundCalls(
|
|
386
|
+
const queue = queueHeld.attached;
|
|
387
|
+
if (queue !== void 0) groups.queue = aroundCalls(queue.calls(bound), (effect) => Effect.provideContext(acting(bound, effect), queue.host.needs));
|
|
454
388
|
if (topicsAttached !== void 0) {
|
|
455
389
|
const topics = topicsAttached;
|
|
456
390
|
groups.topics = {
|
|
@@ -468,18 +402,18 @@ const wireServer = (options, wiring) => {
|
|
|
468
402
|
const callsAs = (bound) => groupsOf(bound);
|
|
469
403
|
const { basePath } = wiring;
|
|
470
404
|
const requestMost = boundOf(adapter.callLimits);
|
|
471
|
-
const
|
|
405
|
+
const clockedIdentify = (request) => Effect.provideService(identify(request), Clock.Clock, runtimeClock);
|
|
406
|
+
const rest = {
|
|
472
407
|
basePath,
|
|
473
|
-
needs,
|
|
474
408
|
callsFor: (caller) => aroundCalls(guardedCalls(callsAs(caller), through), withAudienceMemo),
|
|
475
|
-
tokensOn: Effect.sync(() => tokensHeld.calls !== void 0),
|
|
476
|
-
identify: (request) => through(
|
|
409
|
+
tokensOn: through(Effect.sync(() => tokensHeld.calls !== void 0)),
|
|
410
|
+
identify: (request) => through(clockedIdentify(request)),
|
|
477
411
|
authorize: (input) => through(Effect.provideContext(seamAuthorize(input), needs)),
|
|
478
412
|
renamedTo: (caller, repo) => through(Effect.provideContext(renamedTo(caller, repo), needs)),
|
|
479
413
|
listen: (caller, repo, after) => through(Effect.suspend(() => !keepsEvents(events) ? fail("FAILED_PRECONDITION", "This server keeps no events", { hostHint: "Its host registers a delivery, with Git.register, to keep them" }) : streams.open(caller, repo, after))),
|
|
480
414
|
requestMost
|
|
481
415
|
};
|
|
482
|
-
const httpOptions = { queue:
|
|
416
|
+
const httpOptions = { queue: (...push) => (queueHeld.attached?.push ?? noQueuePush)(...push) };
|
|
483
417
|
if (options.maxDuration !== void 0) httpOptions.maxDuration = millis(options.maxDuration);
|
|
484
418
|
if (objects.pushObjectsMost !== void 0) httpOptions.pushObjectsMost = objects.pushObjectsMost;
|
|
485
419
|
const fetchHooks = wiring.rules.fetch.length === 0 ? 0 : 1;
|
|
@@ -490,334 +424,180 @@ const wireServer = (options, wiring) => {
|
|
|
490
424
|
httpOptions.calls = before(fetchHooks)(countedMost(objects) ?? callLimits);
|
|
491
425
|
httpOptions.pushCalls = before(0)(callLimits);
|
|
492
426
|
httpOptions.lfs = () => lfsAttached?.service;
|
|
493
|
-
httpOptions.uploads = () => uploadsAttached;
|
|
494
|
-
|
|
427
|
+
httpOptions.uploads = () => stepping ? uploadsAttached : void 0;
|
|
428
|
+
httpParts = make({
|
|
429
|
+
basePath,
|
|
430
|
+
identify: rest.identify,
|
|
431
|
+
renamedTo: rest.renamedTo
|
|
432
|
+
}, httpOptions);
|
|
433
|
+
const http = make$1(httpParts);
|
|
495
434
|
return {
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
clock: adapter.clock
|
|
501
|
-
},
|
|
502
|
-
get calls() {
|
|
503
|
-
return callsAs();
|
|
504
|
-
},
|
|
435
|
+
rest,
|
|
436
|
+
needs,
|
|
437
|
+
requestMost,
|
|
438
|
+
adapter: { bucket: adapter.bucket },
|
|
505
439
|
callsAs,
|
|
506
440
|
get hostCalls() {
|
|
507
441
|
return groupsOf(host);
|
|
508
442
|
},
|
|
509
|
-
identify,
|
|
443
|
+
identify: clockedIdentify,
|
|
510
444
|
http,
|
|
511
445
|
services,
|
|
512
446
|
checkSources: () => {
|
|
513
|
-
if (queueHeld.
|
|
514
|
-
}
|
|
447
|
+
if (queueHeld.attached === void 0) servedSources(wiring.rules.push);
|
|
448
|
+
},
|
|
449
|
+
retire: Effect.map(newRetireStart(), (start) => writeRetired(store, retired, start)),
|
|
450
|
+
ownJobs: own
|
|
515
451
|
};
|
|
516
452
|
};
|
|
517
|
-
/**
|
|
518
|
-
const
|
|
519
|
-
const
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
* registers Git's jobs on the adapter's queue, and never runs them: the host starts them.
|
|
525
|
-
*/
|
|
526
|
-
const createGitServer = (options) => serverWith(options, () => ({
|
|
527
|
-
policy: policyOf(options.authorize),
|
|
528
|
-
auth: authOf(options.auth)
|
|
529
|
-
}));
|
|
530
|
-
/**
|
|
531
|
-
* `createGitServer` deciding with `decidersOf`'s answer, which it asks once as the server builds:
|
|
532
|
-
* `createGitServer` gives its options' hooks. Internal: no entry exports it, so a host
|
|
533
|
-
* gives a `Policy` only through `Git.layer`.
|
|
534
|
-
*/
|
|
535
|
-
const serverWith = (options, decidersOf, features) => openServer(options, decidersOf, "build", features).server;
|
|
453
|
+
/** Interrupts as `signal` aborts, as a client that went away or a server that closed stops its run. */
|
|
454
|
+
const interruptedBy = (signal) => Effect.callback((resume) => {
|
|
455
|
+
const interrupt = () => resume(Effect.interrupt);
|
|
456
|
+
if (signal.aborted) return interrupt();
|
|
457
|
+
signal.addEventListener("abort", interrupt, { once: true });
|
|
458
|
+
return Effect.sync(() => signal.removeEventListener("abort", interrupt));
|
|
459
|
+
});
|
|
536
460
|
/**
|
|
537
|
-
*
|
|
538
|
-
*
|
|
461
|
+
* The server, built in the host's own build: its wiring over the host's services, with no runtime
|
|
462
|
+
* of its own, so its build's failure is the host's, and its close is the host's scope's. A call in
|
|
463
|
+
* flight as the scope closes dies with the closed error, as a joined package's does.
|
|
539
464
|
*/
|
|
540
|
-
const
|
|
541
|
-
const setup = options;
|
|
542
|
-
const bridges = bridged(setup);
|
|
543
|
-
if (setup.signIn !== void 0 && setup.tokens === void 0) throw new TypeError("signIn mints tokens: pass tokens() too");
|
|
544
|
-
if (setup.access !== void 0 && setup.objects.indexed !== true) throw new TypeError("access hides refs, which needs objects that follow them: pass packs()");
|
|
545
|
-
const queueOf = setup.queue === void 0 ? void 0 : queueOptions(setup.queue);
|
|
546
|
-
const listed = (setup.rules ?? []).filter((rule) => !Effect.isEffect(rule) && rule.kind === "push");
|
|
547
|
-
if (queueOf === void 0 && sealing === "build") servedSources(listed);
|
|
548
|
-
if (setup.topics !== void 0 && queueOf === void 0) throw new TypeError("topics merge through each repo’s queue: pass queue too");
|
|
549
|
-
if (queueOf !== void 0 && setup.xdiff === void 0) throw new TypeError("the merge queue merges trees: pass xdiff too");
|
|
465
|
+
const buildServer = /* @__PURE__ */ Effect.fnUntraced(function* (setup, decidersOf) {
|
|
550
466
|
const fetchLimits = fetchLimitsOf(setup.fetchLimits);
|
|
467
|
+
const files = pushFilesOf(setup.pushes?.files);
|
|
468
|
+
const repo = pushRepoOf(setup.pushes?.repo);
|
|
551
469
|
const grants = heldGrants();
|
|
552
470
|
const basePath = normalBase(setup.basePath ?? "");
|
|
553
|
-
const
|
|
554
|
-
const
|
|
555
|
-
|
|
556
|
-
const isClosed = () =>
|
|
471
|
+
const closer = new AbortController();
|
|
472
|
+
const closing = closer.signal;
|
|
473
|
+
yield* Effect.addFinalizer(() => Effect.sync(() => closer.abort(closedError())));
|
|
474
|
+
const isClosed = () => closing.aborted;
|
|
557
475
|
const guard = Effect.suspend(() => isClosed() ? Effect.die(closedError()) : Effect.void);
|
|
558
476
|
const door = {
|
|
559
|
-
refusal: () =>
|
|
560
|
-
closing
|
|
561
|
-
};
|
|
562
|
-
const through = throughDoor(life);
|
|
563
|
-
const closingWith = (signal) => signal === void 0 ? life.closing : AbortSignal.any([signal, life.closing]);
|
|
564
|
-
const optional = {
|
|
565
|
-
queue: queueOf,
|
|
566
|
-
queueKeys: setup.queue === void 0 ? void 0 : queueKeysOf(setup.queue),
|
|
567
|
-
topics: setup.topics,
|
|
568
|
-
tokens: setup.tokens
|
|
477
|
+
refusal: () => isClosed() ? closedError() : void 0,
|
|
478
|
+
closing
|
|
569
479
|
};
|
|
480
|
+
const through = throughBridge(door);
|
|
481
|
+
const closingWith = (signal) => signal === void 0 ? closing : AbortSignal.any([signal, closing]);
|
|
570
482
|
const tokensHeld = { calls: void 0 };
|
|
571
|
-
const queueHeld = {
|
|
572
|
-
const
|
|
573
|
-
const
|
|
574
|
-
const queueOn = () => queueOf !== void 0 || queueHeld.host !== void 0;
|
|
483
|
+
const queueHeld = { attached: void 0 };
|
|
484
|
+
const joinedNames = joinedNamesOf();
|
|
485
|
+
const queueOn = () => queueHeld.attached !== void 0;
|
|
575
486
|
const joinedCall = (calls, group, name) => callOrMissing(calls, group, name, () => Effect.fail(noTokens));
|
|
576
|
-
const
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
let registerLater;
|
|
584
|
-
let checkLater;
|
|
585
|
-
const seal = Effect.suspend(() => {
|
|
586
|
-
const register = registerLater;
|
|
587
|
-
const check = checkLater;
|
|
588
|
-
if (register === void 0 || check === void 0) return Effect.die(/* @__PURE__ */ new Error("Git's registry seals after the server's build"));
|
|
589
|
-
return Effect.flatMap(extensions.registry.seal(), (jobs) => Effect.sync(() => {
|
|
590
|
-
check();
|
|
591
|
-
register(jobs);
|
|
592
|
-
}));
|
|
487
|
+
const records = yield* Records.Records;
|
|
488
|
+
const queue = yield* JobQueue.JobQueue;
|
|
489
|
+
const callLimits = yield* CallLimits.CallLimits;
|
|
490
|
+
const extensions = openExtensions({
|
|
491
|
+
basePath,
|
|
492
|
+
fetchWindow: Duration.millis(fetchLimits.milliseconds),
|
|
493
|
+
requestMost: boundOf(callLimits)
|
|
593
494
|
});
|
|
594
|
-
const
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
records: guardedRecords,
|
|
614
|
-
store: promisesStore(records, context, door),
|
|
615
|
-
jobs: promisesQueue(queue, context, door),
|
|
616
|
-
bucket: Option.isSome(bucket) ? doorBucket(hostFailures(bucket.value), context, door) : void 0,
|
|
617
|
-
objectsBucket: Option.isSome(bucket) ? doorBucket(bucket.value, context, door) : void 0,
|
|
618
|
-
links: Option.isSome(links) ? doorLinks(hostLinks(links.value), context, door) : void 0,
|
|
619
|
-
uploads: Option.isSome(uploads) ? doorUploads(hostUploads(uploads.value), context, door) : void 0,
|
|
620
|
-
clock: promisesClock(clock, context, door),
|
|
621
|
-
callLimits,
|
|
622
|
-
requestLimits: Option.getOrElse(requestLimits, () => ({}))
|
|
623
|
-
};
|
|
624
|
-
const given = {
|
|
625
|
-
adapter,
|
|
626
|
-
merges,
|
|
627
|
-
rules,
|
|
628
|
-
optional,
|
|
629
|
-
tokens: tokensHeld,
|
|
630
|
-
queue: queueHeld,
|
|
631
|
-
fetchLimits,
|
|
632
|
-
deciders: decidersOf(),
|
|
633
|
-
grants,
|
|
634
|
-
extensions,
|
|
635
|
-
basePath,
|
|
636
|
-
clock,
|
|
637
|
-
logging,
|
|
638
|
-
access: Option.getOrUndefined(yield* Effect.serviceOption(PrivateRefs))
|
|
639
|
-
};
|
|
640
|
-
const wired = yield* Effect.sync(() => wireServer(setup, {
|
|
641
|
-
...given,
|
|
642
|
-
guard,
|
|
643
|
-
closing: life.closing,
|
|
644
|
-
through,
|
|
645
|
-
runtime
|
|
646
|
-
}));
|
|
647
|
-
yield* bridges.features(wired.services, extensions.registry);
|
|
648
|
-
const over = wired.services.pipe(Context.add(Git, {
|
|
649
|
-
register: extensions.registry.register,
|
|
650
|
-
route: (request) => Effect.map(Effect.promise(() => server.route(request)), Option.fromUndefinedOr),
|
|
651
|
-
handle: (request) => Effect.promise(() => server.fetch(request)),
|
|
652
|
-
identify: (request) => resultCall(() => server.identify(request)),
|
|
653
|
-
checkFetch: checkFetchOver(Effect.succeed(wired.parts))
|
|
654
|
-
}), Context.add(JoinedCalls, joinedOf(server, wired)));
|
|
655
|
-
const featureServices = features === void 0 ? Context.empty() : yield* Layer.build(features).pipe(Effect.provide(over), Effect.mapError(legacyError));
|
|
656
|
-
const joinedOver = Context.merge(over, featureServices).pipe(Context.merge(loaded === void 0 ? Context.empty() : yield* loaded));
|
|
657
|
-
for (const join of joins) {
|
|
658
|
-
const exit = yield* join.build(joinedOver);
|
|
659
|
-
if (Exit.isFailure(exit)) return yield* Effect.mapError(Effect.failCause(exit.cause), legacyError);
|
|
660
|
-
}
|
|
661
|
-
const jobLimits = jobLimitsOf(callLimits);
|
|
662
|
-
const register = (jobs) => adapter.jobs.register(...jobsWithin(jobLimits, jobs));
|
|
663
|
-
if (sealing === "build") {
|
|
664
|
-
yield* Effect.sync(wired.checkSources);
|
|
665
|
-
register(yield* extensions.registry.seal());
|
|
666
|
-
} else {
|
|
667
|
-
registerLater = register;
|
|
668
|
-
checkLater = wired.checkSources;
|
|
669
|
-
}
|
|
670
|
-
const built = Context.merge(Context.add(wired.services, Wired, wired), featureServices);
|
|
671
|
-
return loaded === void 0 ? built : Context.merge(built, yield* loaded);
|
|
672
|
-
}));
|
|
673
|
-
const { adapter } = setup;
|
|
674
|
-
const merged = isLayers(adapter) ? Layer.mergeAll(Layer.empty, ...adapter) : adapter;
|
|
675
|
-
const host = Layer.provideMerge(bridges.inputs, merged);
|
|
676
|
-
const runtime = ManagedRuntime.make(Layer.suspend(() => {
|
|
677
|
-
life.move({ kind: "building" });
|
|
678
|
-
return Layer.provideMerge(wiring, host);
|
|
679
|
-
}).pipe(Layer.tap((built) => Effect.sync(() => {
|
|
680
|
-
life.move({
|
|
681
|
-
kind: "built",
|
|
682
|
-
wired: Context.get(built, Wired)
|
|
683
|
-
});
|
|
684
|
-
})), Layer.tapCause((cause) => life.move({
|
|
685
|
-
kind: "failed",
|
|
686
|
-
cause
|
|
687
|
-
}) ? Effect.logError("The Git server failed to start", cause) : Effect.void)));
|
|
688
|
-
/**
|
|
689
|
-
* The server's build as the door answers it, every call's way in: built, or failed, starting or
|
|
690
|
-
* joining the build while it isn't settled. A closed server throws, before the build or after.
|
|
691
|
-
*/
|
|
692
|
-
const enter = async () => {
|
|
693
|
-
const settled = () => {
|
|
694
|
-
const admitted = life.admit("call");
|
|
695
|
-
if (admitted === "closed") throw closedError();
|
|
696
|
-
const now = life.now();
|
|
697
|
-
if (admitted === "run" && now.kind === "built") return Exit.succeed(now.wired);
|
|
698
|
-
return admitted === "unavailable" && now.kind === "failed" ? Exit.failCause(now.cause) : void 0;
|
|
699
|
-
};
|
|
700
|
-
const before = settled();
|
|
701
|
-
if (before !== void 0) return before;
|
|
702
|
-
const exit = await exitOn(runtime, Effect.service(Wired), noCall);
|
|
703
|
-
return settled() ?? exit;
|
|
495
|
+
const requestLimits = yield* Effect.serviceOption(RequestLimits.RequestLimits);
|
|
496
|
+
const bucket = yield* Effect.serviceOption(Bucket.Bucket);
|
|
497
|
+
const links = yield* Effect.serviceOption(BucketLinks.BucketLinks);
|
|
498
|
+
const uploads = yield* Effect.serviceOption(BucketUploads.BucketUploads);
|
|
499
|
+
const clock = yield* Effect.clockWith(Effect.succeed);
|
|
500
|
+
const logging = Context.make(References.CurrentLoggers, yield* References.CurrentLoggers).pipe(Context.add(References.MinimumLogLevel, yield* References.MinimumLogLevel));
|
|
501
|
+
const rules = yield* rulesOf(setup.rules ?? []);
|
|
502
|
+
const host = Context.omit(Rules)(yield* Effect.context());
|
|
503
|
+
const guardedRecords = doorRecords(records, host, door);
|
|
504
|
+
extensions.registry.bindRecords(guardedRecords);
|
|
505
|
+
const adapter = {
|
|
506
|
+
records: guardedRecords,
|
|
507
|
+
jobs: doorQueue(queue, host, door, () => clock.currentTimeMillisUnsafe()),
|
|
508
|
+
bucket: Option.isSome(bucket) ? doorBucket(hostFailures(bucket.value), host, door) : void 0,
|
|
509
|
+
objectsBucket: Option.isSome(bucket) ? doorBucket(bucket.value, host, door) : void 0,
|
|
510
|
+
links: Option.isSome(links) ? doorLinks(hostLinks(links.value), host, door) : void 0,
|
|
511
|
+
uploads: Option.isSome(uploads) ? doorUploads(hostUploads(uploads.value), host, door) : void 0,
|
|
512
|
+
callLimits,
|
|
513
|
+
requestLimits: Option.getOrElse(requestLimits, () => ({}))
|
|
704
514
|
};
|
|
705
|
-
const
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
515
|
+
const access = Option.getOrUndefined(yield* Effect.serviceOption(PrivateRefs));
|
|
516
|
+
const wired = yield* Effect.sync(() => wireServer(setup, {
|
|
517
|
+
adapter,
|
|
518
|
+
rules,
|
|
519
|
+
tokens: tokensHeld,
|
|
520
|
+
queue: queueHeld,
|
|
521
|
+
fetchLimits,
|
|
522
|
+
files,
|
|
523
|
+
repo,
|
|
524
|
+
deciders: decidersOf(),
|
|
525
|
+
grants,
|
|
526
|
+
extensions,
|
|
527
|
+
basePath,
|
|
528
|
+
clock,
|
|
529
|
+
logging,
|
|
530
|
+
access,
|
|
531
|
+
guard,
|
|
532
|
+
closing,
|
|
533
|
+
through
|
|
534
|
+
}));
|
|
535
|
+
const jobLimits = jobLimitsOf(callLimits);
|
|
536
|
+
yield* Effect.orDie(adapter.jobs.addJobs(...jobsWithin(jobLimits, wired.ownJobs)));
|
|
537
|
+
const seal = Effect.flatMap(extensions.registry.seal(), (jobs) => Effect.sync(wired.checkSources).pipe(Effect.andThen(Effect.all(extensions.registry.sealChecks(), { discard: true })), Effect.andThen(Effect.orDie(adapter.jobs.addJobs(...jobsWithin(jobLimits, jobs))))));
|
|
723
538
|
/**
|
|
724
|
-
* `answering`'s answer to `request
|
|
725
|
-
*
|
|
726
|
-
*
|
|
539
|
+
* `answering`'s answer to `request`, in the caller's fiber, stopped as the client goes away or the
|
|
540
|
+
* server closes. A client that went away, by its signal or mid-body, gets an empty 499, as
|
|
541
|
+
* Effect's HTTP server answers one, logged once at info with the path alone: an archive's link
|
|
542
|
+
* carries its token in the query. A closed server dies with the closed error.
|
|
727
543
|
*/
|
|
728
|
-
const
|
|
729
|
-
|
|
730
|
-
const exit = await exitOn(runtime, withAudienceMemo(answering), uncounted("a request: each Git route sets its own count, and sign-in's and the event stream's none"), closingWith(request.signal));
|
|
731
|
-
if (isClosed()) throw closedError();
|
|
732
|
-
if (Exit.isSuccess(exit)) return exit.value;
|
|
733
|
-
if (!Cause.hasInterruptsOnly(exit.cause) || !clientWentAway(request)) throw Cause.squash(exit.cause);
|
|
734
|
-
const path = new URL(request.url).pathname;
|
|
735
|
-
syncIn(Effect.logInfo("The client went away before its answer").pipe(Effect.annotateLogs({
|
|
544
|
+
const answering = (request, effect) => {
|
|
545
|
+
const gone = Effect.suspend(() => Effect.logInfo("The client went away before its answer").pipe(Effect.annotateLogs({
|
|
736
546
|
method: request.method,
|
|
737
|
-
path
|
|
738
|
-
}))
|
|
739
|
-
return
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
if (Exit.isFailure(built)) {
|
|
745
|
-
const url = new URL(request.url);
|
|
746
|
-
return gitUrlOf(url, basePath) !== void 0 || setup.signIn !== void 0 && signInPathSet.has(url.pathname) || extensions.registry.routeOf(/* @__PURE__ */ new Set([
|
|
747
|
-
"pre",
|
|
748
|
-
"plain",
|
|
749
|
-
"post"
|
|
750
|
-
]), request, url.pathname) !== void 0 ? refusal(unavailable(built.cause)) : void 0;
|
|
751
|
-
}
|
|
752
|
-
const path = new URL(request.url).pathname;
|
|
753
|
-
const first = extensions.registry.routeOf(/* @__PURE__ */ new Set(["pre", "plain"]), request, path);
|
|
754
|
-
if (first !== void 0) return answerTo(request, first.handle(first.request));
|
|
755
|
-
const { http } = built.value;
|
|
756
|
-
const answered = await answerTo(request, http.route(request));
|
|
757
|
-
if (answered !== void 0) return answered;
|
|
758
|
-
const last = extensions.registry.routeOf(/* @__PURE__ */ new Set(["post"]), request, path);
|
|
759
|
-
return last === void 0 ? void 0 : answerTo(request, last.handle(last.request));
|
|
547
|
+
path: new URL(request.url).pathname
|
|
548
|
+
})));
|
|
549
|
+
return Effect.suspend(() => isClosed() ? Effect.die(closedError()) : Effect.void).pipe(Effect.andThen(Effect.raceFirst(withAudienceMemo(effect), interruptedBy(closingWith(request.signal)))), Effect.catchCause((cause) => {
|
|
550
|
+
if (isClosed()) return Effect.die(closedError());
|
|
551
|
+
if (!Cause.hasInterruptsOnly(cause) || !clientWentAway(request)) return Effect.die(Cause.squash(cause));
|
|
552
|
+
return Effect.as(gone, new Response(null, { status: 499 }));
|
|
553
|
+
}), Effect.onInterrupt(() => Effect.andThen(Effect.yieldNow, Effect.suspend(() => !isClosed() && clientWentAway(request) ? gone : Effect.void))), Effect.tap(() => isClosed() ? Effect.die(closedError()) : Effect.void));
|
|
760
554
|
};
|
|
761
|
-
const
|
|
762
|
-
|
|
763
|
-
fetch: async (request) => await route(request) ?? new Response("Not found", { status: 404 }),
|
|
764
|
-
route,
|
|
765
|
-
identify: (request) => run((built) => built.identify(request), uncounted("a host's identify: no Git request"), request.signal),
|
|
766
|
-
runtime,
|
|
767
|
-
close: async () => {
|
|
768
|
-
life.move({ kind: "closed" });
|
|
769
|
-
await runtime.dispose();
|
|
770
|
-
}
|
|
771
|
-
};
|
|
772
|
-
attachJoins(server, {
|
|
773
|
-
admit: life.admit,
|
|
555
|
+
const joined = joinedOf({
|
|
556
|
+
addSealCheck: extensions.registry.addSealCheck,
|
|
774
557
|
basePath,
|
|
775
558
|
fetchLimits,
|
|
776
559
|
get queueKeys() {
|
|
777
|
-
return queueHeld.host
|
|
560
|
+
return queueHeld.attached?.host.keys;
|
|
778
561
|
},
|
|
779
|
-
built: wired,
|
|
780
562
|
through,
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
},
|
|
785
|
-
callsFor: (caller, budget) => {
|
|
786
|
-
let calls;
|
|
787
|
-
return heldGroup(callsOver((built) => {
|
|
788
|
-
const tokens = tokensHeld.calls !== void 0;
|
|
789
|
-
const queue = queueOn();
|
|
790
|
-
if (calls?.tokens !== tokens || calls.queue !== queue) calls = {
|
|
791
|
-
tokens,
|
|
792
|
-
queue,
|
|
793
|
-
made: built.callsAs(caller)
|
|
794
|
-
};
|
|
795
|
-
return calls.made;
|
|
796
|
-
}, budget, joinedNames), "queue", queueOn);
|
|
797
|
-
},
|
|
798
|
-
hostCalls: heldGroup(callsOver((built) => built.hostCalls, void 0, joinedNames), "queue", queueOn),
|
|
799
|
-
effectHostCalls: heldGroup(aroundCalls(guardedCalls(lazyGroups(joinedNames, (group, name, args) => Effect.flatMap(wired, (built) => joinedCall(built.hostCalls, group, name)(...args))), through), withAudienceMemo), "queue", queueOn),
|
|
800
|
-
identify: (request, budget) => run((built) => built.identify(request), {
|
|
801
|
-
calls: void 0,
|
|
802
|
-
budget
|
|
803
|
-
}, request.signal),
|
|
804
|
-
joins
|
|
805
|
-
});
|
|
806
|
-
attachParts(server, {
|
|
807
|
-
basePath,
|
|
808
|
-
names: joinedNames,
|
|
809
|
-
queueOn,
|
|
810
|
-
door,
|
|
811
|
-
parts: Effect.map(wired, (built) => built.parts)
|
|
812
|
-
});
|
|
813
|
-
queueMicrotask(() => {
|
|
814
|
-
if (life.admit("join") === "join") exitOn(runtime, Effect.void, noCall);
|
|
815
|
-
});
|
|
563
|
+
effectHostCalls: heldGroup(aroundCalls(guardedCalls(lazyGroups(joinedNames, (group, name, args) => Effect.suspend(() => joinedCall(wired.hostCalls, group, name)(...args))), through), withAudienceMemo), "queue", queueOn),
|
|
564
|
+
effectCallsFor: (caller) => heldGroup(lazyGroups(joinedNames, (group, name, args) => guardedCall(through)(Effect.suspend(() => joinedCall(wired.rest.callsFor(caller), group, name)(...args)))), "queue", queueOn)
|
|
565
|
+
}, wired);
|
|
816
566
|
return {
|
|
817
|
-
|
|
818
|
-
built: wired,
|
|
567
|
+
services: wired.services,
|
|
819
568
|
registry: extensions.registry,
|
|
820
|
-
seal
|
|
569
|
+
seal,
|
|
570
|
+
retire: Effect.flatMap(wired.retire, retiring),
|
|
571
|
+
rest: wired.rest,
|
|
572
|
+
needs: wired.needs,
|
|
573
|
+
checkFetch: (repo, input) => through(checkFetchOver(wired.needs)(repo, input)),
|
|
574
|
+
bucket: wired.adapter.bucket,
|
|
575
|
+
joined,
|
|
576
|
+
answer: (request) => answering(request, Effect.provideContext(wired.http.route(request), wired.needs)),
|
|
577
|
+
identify: (request) => guardedCall(through)(withAudienceMemo(wired.identify(request)))
|
|
821
578
|
};
|
|
822
|
-
};
|
|
823
|
-
|
|
579
|
+
});
|
|
580
|
+
/**
|
|
581
|
+
* `write`, the host's `events.retired` as rows for one start, till it lands or a later start's
|
|
582
|
+
* has, which is logged once. A failure is logged with its error, a warning, or
|
|
583
|
+
* an error as `retireErrors` picks, and tried again `retryDelay` later, with no end. A defect, a
|
|
584
|
+
* spent call bound among them, isn't a failure to try again: it ends the write, and `Git.layer`'s
|
|
585
|
+
* fork logs it.
|
|
586
|
+
*/
|
|
587
|
+
const retiring = /* @__PURE__ */ Effect.fnUntraced(function* (write) {
|
|
588
|
+
for (let failures = 1;; failures += 1) {
|
|
589
|
+
const result = yield* Effect.result(write);
|
|
590
|
+
if (EffectResult.isSuccess(result)) {
|
|
591
|
+
if (result.success !== "superseded") return;
|
|
592
|
+
return yield* Effect.logInfo("events.retired's rows weren't written: a later start wrote its own");
|
|
593
|
+
}
|
|
594
|
+
const next = retryDelay(failures);
|
|
595
|
+
const loud = (failures - retireErrors.first) % retireErrors.every === 0;
|
|
596
|
+
yield* (failures >= retireErrors.first && loud ? Effect.logError : Effect.logWarning)("events.retired's rows weren't written, and are written again", Cause.fail(result.failure)).pipe(Effect.annotateLogs({
|
|
597
|
+
failures,
|
|
598
|
+
next
|
|
599
|
+
}));
|
|
600
|
+
yield* Effect.sleep(next);
|
|
601
|
+
}
|
|
602
|
+
});
|
|
603
|
+
export { buildServer };
|