@ref0/git 0.7.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (191) hide show
  1. package/dist/access/private-refs.mjs +0 -2
  2. package/dist/auth/authorize.mjs +31 -24
  3. package/dist/auth/bridge.mjs +8 -8
  4. package/dist/auth/fences.d.mts +0 -1
  5. package/dist/auth/fences.mjs +1 -1
  6. package/dist/auth/grants.d.mts +0 -1
  7. package/dist/auth/grants.mjs +2 -2
  8. package/dist/auth/host-function.d.mts +1 -7
  9. package/dist/auth/host-function.mjs +38 -38
  10. package/dist/auth/identify.d.mts +0 -1
  11. package/dist/auth/identify.mjs +1 -1
  12. package/dist/auth/policy.d.mts +7 -4
  13. package/dist/auth/policy.mjs +13 -10
  14. package/dist/auth/token-rows.mjs +2 -5
  15. package/dist/auth/tokens-layer.d.mts +0 -2
  16. package/dist/auth/tokens-public.d.mts +3 -3
  17. package/dist/auth/tokens-public.mjs +4 -2
  18. package/dist/auth/tokens.d.mts +6 -1
  19. package/dist/auth/tokens.mjs +7 -1
  20. package/dist/client/client.d.mts +22 -15
  21. package/dist/client/client.mjs +31 -27
  22. package/dist/client/git-http.mjs +22 -5
  23. package/dist/client/local.mjs +1 -1
  24. package/dist/client/namespace.d.mts +2 -0
  25. package/dist/client/push-upload.d.mts +1 -0
  26. package/dist/client/push-upload.mjs +169 -2
  27. package/dist/client/remote-helper.mjs +2 -4
  28. package/dist/client/remote.mjs +37 -15
  29. package/dist/client/run-remote-helper.mjs +4 -4
  30. package/dist/client/transport.mjs +26 -19
  31. package/dist/contracts/actors.d.mts +57 -28
  32. package/dist/contracts/actors.mjs +38 -2
  33. package/dist/contracts/authorize.d.mts +21 -15
  34. package/dist/contracts/callers.mjs +40 -0
  35. package/dist/contracts/client.d.mts +16 -9
  36. package/dist/contracts/events.d.mts +12 -10
  37. package/dist/contracts/events.mjs +8 -6
  38. package/dist/contracts/files.d.mts +42 -42
  39. package/dist/contracts/forks.d.mts +0 -24
  40. package/dist/contracts/git-hooks.d.mts +217 -0
  41. package/dist/contracts/git-hooks.mjs +3 -1
  42. package/dist/contracts/grants.d.mts +46 -27
  43. package/dist/contracts/lfs.d.mts +17 -4
  44. package/dist/contracts/merges.d.mts +7 -7
  45. package/dist/contracts/objects.d.mts +20 -4
  46. package/dist/contracts/opaque.mjs +19 -1
  47. package/dist/contracts/operations.d.mts +8 -1
  48. package/dist/contracts/operations.mjs +209 -0
  49. package/dist/contracts/queue.d.mts +3 -3
  50. package/dist/contracts/queue.mjs +5 -18
  51. package/dist/contracts/remote.d.mts +13 -4
  52. package/dist/contracts/remote.mjs +3 -3
  53. package/dist/contracts/repos.d.mts +11 -40
  54. package/dist/contracts/repos.mjs +11 -10
  55. package/dist/contracts/result.d.mts +28 -11
  56. package/dist/contracts/result.mjs +32 -2
  57. package/dist/contracts/rules.d.mts +706 -46
  58. package/dist/contracts/rules.mjs +81 -2
  59. package/dist/contracts/server.d.mts +5 -275
  60. package/dist/contracts/services.d.mts +0 -3
  61. package/dist/contracts/services.mjs +1 -3
  62. package/dist/contracts/signin.d.mts +2 -2
  63. package/dist/contracts/signin.mjs +4 -5
  64. package/dist/contracts/sync.d.mts +1 -4
  65. package/dist/contracts/tokens.d.mts +29 -17
  66. package/dist/contracts/tokens.mjs +14 -3
  67. package/dist/contracts/topics.d.mts +38 -11
  68. package/dist/contracts/topics.mjs +8 -2
  69. package/dist/core/access.d.mts +0 -2
  70. package/dist/core/access.mjs +15 -4
  71. package/dist/core/events/deliver.mjs +19 -1
  72. package/dist/core/forks.mjs +30 -11
  73. package/dist/core/hooks/groups.d.mts +0 -1
  74. package/dist/core/hooks/groups.mjs +8 -9
  75. package/dist/core/loose-tally.mjs +46 -0
  76. package/dist/core/objects/writing.mjs +1 -0
  77. package/dist/core/promise.mjs +1 -15
  78. package/dist/core/purge.mjs +14 -9
  79. package/dist/core/push.mjs +13 -6
  80. package/dist/core/ref-view.mjs +14 -6
  81. package/dist/core/repack.mjs +19 -14
  82. package/dist/core/repo-info.mjs +8 -6
  83. package/dist/core/repos.mjs +1 -0
  84. package/dist/core/rules/check.mjs +10 -10
  85. package/dist/core/rules/context.d.mts +3 -1
  86. package/dist/core/rules/context.mjs +16 -13
  87. package/dist/core/rules/fetch.mjs +17 -23
  88. package/dist/core/tokens.mjs +2 -1
  89. package/dist/effect.d.mts +2 -4
  90. package/dist/effect.mjs +2 -4
  91. package/dist/engine/commits.mjs +19 -47
  92. package/dist/engine/failures.d.mts +1 -2
  93. package/dist/engine/failures.mjs +1 -3
  94. package/dist/engine/merge-base-walk.mjs +57 -142
  95. package/dist/engine/merge-bases.mjs +5 -5
  96. package/dist/engine/merge.mjs +16 -14
  97. package/dist/extend.d.mts +1 -2
  98. package/dist/extend.mjs +1 -2
  99. package/dist/http/core-parts.mjs +1 -2
  100. package/dist/http/handler.mjs +11 -31
  101. package/dist/http/parts.d.mts +0 -1
  102. package/dist/index.d.mts +28 -21
  103. package/dist/index.mjs +5 -2
  104. package/dist/lfs/base.d.mts +6 -3
  105. package/dist/lfs/base.mjs +2 -1
  106. package/dist/lfs/layer.d.mts +4 -3
  107. package/dist/lfs/layer.mjs +23 -9
  108. package/dist/lfs/objects.mjs +90 -41
  109. package/dist/lfs/pointers.mjs +69 -18
  110. package/dist/lfs/purge.mjs +6 -2
  111. package/dist/lfs/rows.mjs +24 -7
  112. package/dist/lfs/service.d.mts +6 -3
  113. package/dist/lfs/service.mjs +8 -2
  114. package/dist/lfs/upkeep.mjs +44 -26
  115. package/dist/lfs/upload-most.mjs +41 -0
  116. package/dist/lfs/uploaded.mjs +59 -0
  117. package/dist/protocol/bytes/sha256-hasher.mjs +51 -0
  118. package/dist/protocol/bytes/text.mjs +6 -1
  119. package/dist/protocol/objects/fsck.mjs +6 -3
  120. package/dist/queue/advance.mjs +38 -8
  121. package/dist/queue/calls.mjs +4 -14
  122. package/dist/queue/lanes.mjs +1 -1
  123. package/dist/queue/rows.mjs +8 -0
  124. package/dist/queue/schedule.mjs +1 -1
  125. package/dist/queue/search.mjs +3 -4
  126. package/dist/rest/client-namespace.d.mts +2 -0
  127. package/dist/rest/client.d.mts +32 -8
  128. package/dist/rest/client.mjs +308 -382
  129. package/dist/rest/commits.d.mts +240 -240
  130. package/dist/rest/files.d.mts +18 -18
  131. package/dist/rest/forks.d.mts +45 -57
  132. package/dist/rest/handlers.mjs +2 -1
  133. package/dist/rest/listen.d.mts +8 -6
  134. package/dist/rest/listen.mjs +31 -75
  135. package/dist/rest/me.d.mts +2 -2
  136. package/dist/rest/merges.d.mts +7 -7
  137. package/dist/rest/refs.d.mts +139 -139
  138. package/dist/rest/repos.d.mts +54 -66
  139. package/dist/rest/tokens.d.mts +12 -12
  140. package/dist/rest/topics.d.mts +110 -110
  141. package/dist/rest/trees.d.mts +66 -66
  142. package/dist/rest/wire.d.mts +1 -1
  143. package/dist/rest.d.mts +1 -7
  144. package/dist/rest.mjs +1 -5
  145. package/dist/server/git-layer.d.mts +10 -2
  146. package/dist/server/git-layer.mjs +29 -10
  147. package/dist/server/joined.d.mts +1 -1
  148. package/dist/server/server.d.mts +0 -1
  149. package/dist/server/server.mjs +26 -45
  150. package/dist/signin/context.d.mts +0 -1
  151. package/dist/signin/context.mjs +5 -9
  152. package/dist/storage/clean-up.mjs +3 -1
  153. package/dist/storage/fsck.mjs +12 -2
  154. package/dist/storage/graph-rebuild.mjs +262 -0
  155. package/dist/storage/index-build.mjs +100 -12
  156. package/dist/storage/lfs-pointers.d.mts +5 -5
  157. package/dist/storage/lfs-pointers.mjs +37 -11
  158. package/dist/storage/loose.mjs +4 -1
  159. package/dist/storage/memory-budget.mjs +1 -1
  160. package/dist/storage/merge-fence.mjs +81 -19
  161. package/dist/storage/merge-most.mjs +1 -0
  162. package/dist/storage/merge-row.mjs +16 -4
  163. package/dist/storage/merge-stream.mjs +9 -6
  164. package/dist/storage/object-rows.mjs +17 -1
  165. package/dist/storage/pack-receive.mjs +10 -6
  166. package/dist/storage/packs.mjs +58 -27
  167. package/dist/storage/prune.mjs +68 -40
  168. package/dist/storage/ready.d.mts +1 -1
  169. package/dist/storage/ready.mjs +12 -3
  170. package/dist/storage/receive-state.mjs +1 -1
  171. package/dist/storage/repack-contained.mjs +22 -14
  172. package/dist/storage/repack.d.mts +1 -1
  173. package/dist/storage/repack.mjs +3 -2
  174. package/dist/storage/unpack.mjs +7 -0
  175. package/dist/store/call-count.d.mts +23 -3
  176. package/dist/store/call-count.mjs +36 -13
  177. package/dist/store/records.mjs +10 -4
  178. package/dist/store/repo-record.mjs +29 -12
  179. package/dist/store/scopes.mjs +6 -1
  180. package/dist/sync/import.mjs +14 -2
  181. package/dist/sync/layer.d.mts +5 -1
  182. package/dist/sync/layer.mjs +7 -2
  183. package/dist/sync/step.mjs +15 -15
  184. package/dist/topics/advance.mjs +7 -6
  185. package/dist/topics/members.mjs +38 -9
  186. package/package.json +3 -3
  187. package/dist/engine/merge-base-walk.d.mts +0 -3
  188. package/dist/server/routes.d.mts +0 -32
  189. package/dist/server/routes.mjs +0 -69
  190. package/dist/sync/bridge.d.mts +0 -6
  191. package/dist/sync/bridge.mjs +0 -29
package/dist/index.d.mts CHANGED
@@ -1,72 +1,78 @@
1
1
  import { Actor, ActorId, ActorInput, AnonymousActor, AuthInput, AuthorizeAnswer, AuthorizeInput, CallInput, Caller, CallerGrant, Credentials, CredentialsBasic, CredentialsBearer, GitAuth, GitAuthorize, NamedActor, RepoAccess, WriteInput } from "./contracts/actors.mjs";
2
2
  import { AccessOption, HiddenSpan, RefAudience, RefView } from "./contracts/access.mjs";
3
3
  import { Acting, Blob, BlobCalls, BlobCreateInput, CreatedObject, ObjectInput, blobs_d_exports } from "./contracts/blobs.mjs";
4
- import { ClientAdapter, ClientFetchInput, ClientFetchResult, ClientPushInput, GitClient, GitClientOptions, Localize, PagedInput, RefForced, RemoteRefsInput } from "./contracts/client.mjs";
5
- import { createGitClient, paginate } from "./client/client.mjs";
4
+ import { ClientAdapter, ClientFetchInput, ClientFetchResult, ClientPushInput, GitClientCalls, GitClientOptions, Localize, PagedInput, RefForced, RemoteRefsInput } from "./contracts/client.mjs";
5
+ import "./client/namespace.mjs";
6
+ import "./rest/client-namespace.mjs";
7
+ import { RestClientCalls, RestTokenCalls, client_d_exports as client_d_exports$1 } from "./rest/client.mjs";
8
+ import { ListenInput, RestEvents } from "./rest/listen.mjs";
9
+ import { Me } from "./rest/me.mjs";
10
+ import { CreatedToken, GrantScope, PrefixTarget, TokenCalls, TokenCoverage, TokenCreateInput, TokenFields, TokenId, TokenInfo, TokenListInput, TokenRecord, TokenScope, TokenState, TokenTarget, TokensFeature, TrustedWriteInput, VerifiedToken, grantScopes, tokenScopes, tokenStates } from "./contracts/tokens.mjs";
6
11
  import "./contracts/namespaces.mjs";
7
12
  import "./server/namespaces.mjs";
8
13
  import "./core/namespaces.mjs";
14
+ import { git_events_d_exports } from "./contracts/git-events.mjs";
9
15
  import "./auth/namespaces.mjs";
10
16
  import "./event-streams/namespace.mjs";
11
17
  import "./rest/namespace.mjs";
12
18
  import "./merges/namespace.mjs";
19
+ import { authorize_d_exports } from "./contracts/authorize.mjs";
13
20
  import "./queue/namespace.mjs";
14
21
  import "./lfs/namespace.mjs";
15
- import { mergeQueue } from "./queue/host.mjs";
22
+ import { QueueInternals, mergeQueue } from "./queue/host.mjs";
16
23
  import { CommitCalls, CommitCreateInput, CommitDiffInput, Compare, CompareInput, ComparisonFile, LineCounts, LogInput, RefPublication, Revision, commits_d_exports } from "./contracts/commits.mjs";
17
24
  import { Commit, DiffListing, MergeBaseInput, MergeBases, MergeLabels, MergeTree, ObjectWrite, ObjectWrites, PathObject, ReadOptions, ReadPage, RenamesSkipped, Signature, Tag, TagFields, TreeChange, TreeChanges, TreeDiffInput, TreeMergeInput, WalkInput } from "./contracts/engine.mjs";
18
25
  import { BeforeAfter, CandidateClosed, CandidateClosedFields, CandidateOpened, CandidateReported, EntryAdded, EntryFailed, EntryMerged, EntryRemoved, EntryRetried, EventEnvelope, EventFeature, FeedItem, FenceReason, FencedPack, GitEvent, HoldEvent, HoldEventFields, IndexRefusal, QueueEvent, QueueRestarted, RefPush, RefUpdated, RepoCreated, RepoDeletedEvent, RepoEnvelope, RepoEvent, RepoIndexRefused, RepoJobFailed, RepoMaintained, RepoRenamed, RepoVisibilityChanged, RepoWorkFailed, TokenEvent, TokenEventFields, TopicAdded, TopicEnvelope, TopicEvent, TopicFailed, TopicMerged, TopicOpened, TopicRemoved, TopicReported, TopicWorkFailed, events_d_exports } from "./contracts/events.mjs";
19
26
  import { File, FileCalls, FileDiff, FileReadInput, FilesDiffInput, FilesListInput, FilesRead, files_d_exports } from "./contracts/files.mjs";
20
27
  import { ForkCalls, ForkCreateInput, ForkFetched, ForkGetInput, ForkHolder, ForkListInput, forks_d_exports } from "./contracts/forks.mjs";
21
- import { LfsCalls, LfsFeature, LfsGetInput, LfsObject } from "./contracts/lfs.mjs";
28
+ import { LfsCalls, LfsFeature, LfsGetInput, LfsObject, LfsOptions } from "./contracts/lfs.mjs";
29
+ import { repo_records_d_exports } from "./contracts/repo-records.mjs";
22
30
  import { MergeAnswer, MergeCalls, MergeCreateInput } from "./contracts/merges.mjs";
23
- import { git_events_d_exports } from "./contracts/git-events.mjs";
24
31
  import { HandlerOptions, SavedHandlerOptions } from "./contracts/handlers.mjs";
25
32
  import { Grant, GrantAgainInput, GrantAgainRequest, GrantInput, GrantReachInput, GrantResolver } from "./contracts/grants.mjs";
26
33
  import { GitScope, InternalRepoId, Oid, RefName, RepoName, TopicId, isInternalId, maxActorIdLength, maxRefNameLength } from "./contracts/ids.mjs";
27
- import { authorize_d_exports } from "./contracts/authorize.mjs";
28
- import { Allotment, CopyRow, CopyRowsInput, CopyRowsPage, EffectiveLimits, FetchAnswer, GitObject, GitObjects, HoldingsInput, HoldingsWalked, IndexCalls, IndexReachInput, IndexReached, IndexStatus, IndexTip, IndexTry, IndexTryInput, LinkedObjects, MaintainInput, ObjectHeader, ObjectHeadersInput, ObjectReadInput, ObjectReadResult, ObjectReader, ObjectReaderInput, ObjectSizesInput, ObjectsChange, ObjectsFactory, ObjectsFetchInput, ObjectsOpenInput, ObjectsRead, ObjectsReadInput, ObjectsStarting, ObjectsStartingInput, ObjectsStep, PushedCommit, PushedCommitsInput, Quarantine, ReadObject, ReadObjects, ReceiveInput, ShareInput, StageInput, Staged, StepAnswer, StepInput, WholeObject } from "./contracts/objects.mjs";
34
+ import { Allotment, CopyRow, CopyRowsInput, CopyRowsPage, EffectiveLimits, FetchAnswer, GitObject, GitObjects, HoldingsInput, HoldingsWalked, IndexCalls, IndexReachInput, IndexReached, IndexStatus, IndexTip, IndexTry, IndexTryInput, LinkedObjects, MaintainInput, ObjectHeader, ObjectHeadersInput, ObjectReadInput, ObjectReadResult, ObjectReader, ObjectReaderInput, ObjectSizesInput, ObjectsChange, ObjectsFactory, ObjectsFetchInput, ObjectsOpenInput, ObjectsRead, ObjectsReadInput, ObjectsStarting, ObjectsStartingInput, ObjectsStep, PushedCommit, PushedCommitsInput, Quarantine, ReadObject, ReadObjects, ReceiveInput, RowsMoved, ShareInput, StageInput, Staged, StepAnswer, StepInput, WholeObject } from "./contracts/objects.mjs";
29
35
  import { BypassOperation, FilesAllowOperation, ForkOperation, MeOperation, Operation, OperationKind, PushOperation, QueueAddOperation, QueueCandidateOperation, QueueEntryOperation, QueueReleaseOperation, QueueTargetOperation, RefsPrivateOperation, RepoListOperation, RepoOperation, TokenCreateOperation, TokenOperation, TokenParties, TopicOperation, WorkOperation } from "./contracts/operations.mjs";
36
+ import { client_d_exports } from "./client/client.mjs";
30
37
  import { AddResult, Added, BatchOptions, Bisect, Candidate, CandidateCloseReason, CandidateId, CandidateReportInput, CandidateResult, CandidateState, CandidatesResult, Entry, EntryFailureReason, EntryFields, EntryGroups, EntryHoldInput, EntryHoldsInput, EntryId, EntryResult, EntryState, Held, Hold, HoldFields, HoldId, HoldResult, HoldsResult, JoinInput, Judged, LanesInput, MergeInput, MergeMethod, MergePlan, MergeQueueCalls, MergeQueueLayerOptions, MergeQueueOptions, MetaValue, PreviousQueueSchedule, QueueAddInput, QueueFailureCounts, QueueKeys, QueueListInput, QueueListResult, QueueMeta, QueueOf, QueueRecent, QueueTargetInput, QueueView, ReleaseResult, Released, RemoveResult, Removed, Report, ReportDetails, ReportOptions, ReportResult, Reported, RestartResult, Restarted, Retried, RetryResult, ScheduleOption, TargetHoldInput } from "./contracts/queue.mjs";
38
+ import { RepoStreamEvent } from "./rest/wire.mjs";
31
39
  import { Ref, RefCalls, RefCount, RefCountInput, RefEdit, RefInput, RefListInput, RefProtection, RefSource, RefUpdate, RefUpdateKind, RefsUpdateInput, RefsUpdated, refs_d_exports } from "./contracts/refs.mjs";
32
- import { repo_records_d_exports } from "./contracts/repo-records.mjs";
33
- import { BasicCredential, BearerCredential, ClientCredential, ClientCredentials, CredentialInput, RemoteCalls, RemoteOptions, TransportFailure, TransportRetry, WithoutActor } from "./contracts/remote.mjs";
40
+ import { BasicCredential, BearerCredential, ClientCredential, ClientCredentials, CredentialInput, RemoteCalls, RemoteOptions, TransportFailure, TransportRetry, WithoutActor, WithoutSignal } from "./contracts/remote.mjs";
34
41
  import { PinnedRepo, RepoCalls, RepoCatalogueEntry, RepoCreateInput, RepoDeleted, RepoGetInput, RepoIndexHold, RepoInfo, RepoInfoStats, RepoInput, RepoListInput, RepoListOrder, RepoRecord, RepoRenameInput, RepoStats, RepoUpdateInput, RepoWork, repos_d_exports } from "./contracts/repos.mjs";
35
42
  import { PeelInput, Peeled, TagCalls, TagCreateInput, peelMost, peelTagsMost, tags_d_exports } from "./contracts/tags.mjs";
36
43
  import { Prepare, PrepareInput, Topic, TopicAddInput, TopicCalls, TopicCandidate, TopicEntry, TopicEntryInput, TopicFailure, TopicFailureReason, TopicListInput, TopicMergedEntry, TopicReportInput, TopicReportOptions, TopicReportQuestion, TopicState, TopicTarget, TopicWait, TopicsFactory } from "./contracts/topics.mjs";
37
- import { TreeCalls, TreeCreateInput, TreeEdit, TreeEntry, TreeInput, trees_d_exports } from "./contracts/trees.mjs";
38
44
  import { policy_d_exports } from "./auth/policy.mjs";
39
- import { BlobLimit, BlobNone, Bytes, FetchRequest, Filter, LfsPointers, ObjectType, ReadLimits, TreeFilter, allotmentWithin, objectsReadMost } from "./contracts/object-values.mjs";
45
+ import { TreeCalls, TreeCreateInput, TreeEdit, TreeEntry, TreeInput, trees_d_exports } from "./contracts/trees.mjs";
40
46
  import { event_streams_d_exports } from "./event-streams/event-streams.mjs";
47
+ import { BlobLimit, BlobNone, Bytes, FetchRequest, Filter, LfsPointers, ObjectType, ReadLimits, TreeFilter, allotmentWithin, objectsReadMost } from "./contracts/object-values.mjs";
41
48
  import { Accepted, Awaitable, ContextValue, DataLossContext, DataLossReason, DecisionAnswer, ErrorContext, ExistingContext, ExistingReason, FailureResult, GitError, GitErrorBody, GitErrorCode, GitErrorContexts, GitErrorFields, GitErrorInput, GitErrorTagged, HostErrorContext, HostFunctionName, InvalidInputContext, InvalidInputReason, MissingContext, MissingReason, NotAllowedContext, NotAllowedReason, PreconditionContext, PreconditionReason, RefusalReason, RejectInput, Rejected, ResourceContext, ResourceReason, Result, Success, UnavailableContext, UnavailableReason, Verdict, accept, gitError, httpStatus, isGitError, isRefusalReason, reject } from "./contracts/result.mjs";
42
49
  import { SliceRefusal } from "./client/slice-push.mjs";
43
50
  import { gitPathOf } from "./http/paths.mjs";
44
- import { createGitServer } from "./server/server.mjs";
45
51
  import { git_namespace_d_exports } from "./server/git-namespace.mjs";
52
+ import { createGitServer } from "./server/server.mjs";
46
53
  import { lfs } from "./lfs/service.mjs";
47
54
  import { branchRef, shortTarget } from "./queue/ids.mjs";
48
55
  import { topics } from "./topics/host.mjs";
49
56
  import { lfsPointerOid, maxLfsPointerBytes } from "./protocol/objects/lfs-pointer.mjs";
50
57
  import { LfsPointersBuilder, lfsPointers } from "./storage/lfs-pointers.mjs";
51
- import { loose, looseLimits } from "./storage/loose.mjs";
52
58
  import { objects_namespace_d_exports } from "./core/objects/objects-namespace.mjs";
53
59
  import { saved_callers_public_d_exports } from "./core/saved-callers-public.mjs";
54
- import { PacksOptions, UnpackOptions, packs } from "./storage/packs.mjs";
60
+ import { loose, looseLimits } from "./storage/loose.mjs";
55
61
  import { auth_namespace_d_exports } from "./auth/auth-namespace.mjs";
62
+ import { PacksOptions, UnpackOptions, packs } from "./storage/packs.mjs";
56
63
  import { PacksMemory, packsMemory } from "./storage/packs-memory.mjs";
57
- import { Option, RepackOptions } from "./storage/repack.mjs";
58
64
  import { layer_d_exports } from "./rest/layer.mjs";
59
- import "./core/rules/namespace.mjs";
65
+ import { Option, RepackOptions } from "./storage/repack.mjs";
60
66
  import { public_d_exports as public_d_exports$3 } from "./merges/public.mjs";
61
- import { FetchAdjustment, FetchReadInput, FetchReadTarget, FetchRule, FetchRuleInput, FileRuleOptions, ProtectOptions, PushContext, PushFacts, PushRule, PushRuleInput, RefPatterns, RuleOperation } from "./contracts/rules.mjs";
67
+ import "./core/rules/namespace.mjs";
62
68
  import { public_d_exports as public_d_exports$2 } from "./queue/public.mjs";
63
- import { BeginPushUpload, FinishPushUpload, PushOptions, PushUploadOptions, PushUploadPart, PushUploadStarted } from "./contracts/push-uploads.mjs";
69
+ import { FetchAdjustment, FetchReadInput, FetchReadTarget, FetchRule, FetchRuleInput, FileRuleOptions, ProtectOptions, PushContext, PushFacts, PushRule, PushRuleInput, RefPatterns, RuleOperation } from "./contracts/rules.mjs";
64
70
  import { public_d_exports as public_d_exports$1 } from "./lfs/public.mjs";
65
- import { GitAdapter, GitNeeds, GitServer, GitServerOptions, HostFunctionFailure, ProvidedBy, Refusal, Resolve, ResolveInput, ServerCalls, ServerSetup } from "./contracts/server.mjs";
71
+ import { BeginPushUpload, FinishPushUpload, PushOptions, PushUploadOptions, PushUploadPart, PushUploadStarted } from "./contracts/push-uploads.mjs";
72
+ import { GitAdapter, GitNeeds, GitServer, GitServerOptions, ProvidedBy, ServerCalls, ServerSetup } from "./contracts/server.mjs";
66
73
  import { ImportState } from "./contracts/sync.mjs";
67
74
  import { ApprovalBase, ApprovalDecision, ApprovalPageContext, ApprovalPageInput, ApprovalPrompt, ApprovedGrant, ConfirmApprovalPage, DeniedGrant, DeviceApproval, DeviceCodePage, DeviceCodeRequest, DeviceCodeResponse, DeviceExchange, OAuthClient, OAuthError, OAuthTokenResponse, WebApproval, WebAuthorize, WebExchange } from "./contracts/signin.mjs";
68
75
  import { GitStore, GitStoreAddInput, GitStoreCommitInput, GitStoreReadInput, HeldPack, Holding, Listed, ListedInput, Pack } from "./contracts/store.mjs";
69
- import { CreatedToken, PrefixTarget, TokenCalls, TokenCoverage, TokenCreateInput, TokenFields, TokenId, TokenInfo, TokenListInput, TokenRecord, TokenScope, TokenState, TokenTarget, TokensFeature, TrustedWriteInput, VerifiedToken } from "./contracts/tokens.mjs";
70
76
  import { WorkCalls, WorkItem, WorkListInput, WorkWriteInput, work_d_exports } from "./contracts/work.mjs";
71
77
  import { rules_d_exports } from "./core/rules/rules.mjs";
72
78
  import "./access/namespace.mjs";
@@ -80,4 +86,5 @@ import { public_d_exports } from "./core/hooks/public.mjs";
80
86
  import { PushHookInput } from "./contracts/git-hooks.mjs";
81
87
  import { public_d_exports as public_d_exports$5 } from "./signin/public.mjs";
82
88
  import "./signin/namespace.mjs";
83
- export { type Accepted, type AccessOption, type Acting, type Actor, type ActorId, type ActorInput, type AddResult, type Added, type Allotment, type AnonymousActor, type ApprovalBase, type ApprovalDecision, type ApprovalPageContext, type ApprovalPageInput, type ApprovalPrompt, type ApprovedGrant, auth_namespace_d_exports as Auth, type AuthInput, authorize_d_exports as Authorize, type AuthorizeAnswer, type AuthorizeInput, type Awaitable, type BasicCredential, type BatchOptions, type BearerCredential, type BeforeAfter, BeginPushUpload, type Bisect, type Blob, type BlobCalls, type BlobCreateInput, BlobLimit, BlobNone, blobs_d_exports as Blobs, type BypassOperation, type Bytes, type CallInput, type Caller, type CallerGrant, type Candidate, type CandidateCloseReason, type CandidateClosed, type CandidateClosedFields, type CandidateId, type CandidateOpened, type CandidateReportInput, type CandidateReported, type CandidateResult, type CandidateState, type CandidatesResult, type ClientAdapter, type ClientCredential, type ClientCredentials, type ClientFetchInput, type ClientFetchResult, type ClientPushInput, type Commit, type CommitCalls, type CommitCreateInput, type CommitDiffInput, commits_d_exports as Commits, type Compare, type CompareInput, type ComparisonFile, type ConfirmApprovalPage, ContextValue, type CopyRow, type CopyRowsInput, type CopyRowsPage, type CreatedObject, type CreatedToken, type CredentialInput, type Credentials, type CredentialsBasic, type CredentialsBearer, DataLossContext, DataLossReason, type DecisionAnswer, type DeniedGrant, type DeviceApproval, type DeviceCodePage, type DeviceCodeRequest, type DeviceCodeResponse, type DeviceExchange, type DiffListing, type EffectiveLimits, type Entry, type EntryAdded, type EntryFailed, type EntryFailureReason, type EntryFields, type EntryGroups, type EntryHoldInput, type EntryHoldsInput, type EntryId, type EntryMerged, type EntryRemoved, type EntryResult, type EntryRetried, type EntryState, ErrorContext, type EventEnvelope, type EventFeature, event_streams_d_exports as EventStreams, events_d_exports as Events, ExistingContext, ExistingReason, type FailureResult, type FeedItem, type FenceReason, type FencedPack, type FetchAdjustment, type FetchAnswer, type FetchReadInput, type FetchReadTarget, FetchRequest, type FetchRule, type FetchRuleInput, type File, type FileCalls, type FileDiff, type FileReadInput, type FileRuleOptions, files_d_exports as Files, type FilesAllowOperation, type FilesDiffInput, type FilesListInput, type FilesRead, Filter, FinishPushUpload, type ForkCalls, type ForkCreateInput, type ForkFetched, type ForkGetInput, type ForkHolder, type ForkListInput, type ForkOperation, forks_d_exports as Forks, git_namespace_d_exports as Git, type GitAdapter, type GitAuth, type GitAuthorize, type GitClient, type GitClientOptions, type GitError, GitErrorBody, type GitErrorCode, type GitErrorContexts, type GitErrorFields, type GitErrorInput, type GitErrorTagged, type GitEvent, git_events_d_exports as GitEvents, public_d_exports as GitHooks, type GitNeeds, type GitObject, type GitObjects, type GitScope, type GitServer, type GitServerOptions, type GitStore, type GitStoreAddInput, type GitStoreCommitInput, type GitStoreReadInput, type Grant, type GrantAgainInput, type GrantAgainRequest, type GrantInput, type GrantReachInput, type GrantResolver, type HandlerOptions, type Held, type HeldPack, type HiddenSpan, type Hold, type HoldEvent, type HoldEventFields, type HoldFields, type HoldId, type HoldResult, type Holding, type HoldingsInput, type HoldingsWalked, type HoldsResult, HostErrorContext, type HostFunctionFailure, type HostFunctionName, type ImportState, type IndexCalls, type IndexReachInput, type IndexReached, type IndexRefusal, type IndexStatus, type IndexTip, type IndexTry, type IndexTryInput, InternalRepoId, InvalidInputContext, InvalidInputReason, type JoinInput, type Judged, type LanesInput, public_d_exports$1 as Lfs, type LfsCalls, type LfsFeature, type LfsGetInput, type LfsObject, type LfsPointers, type LfsPointersBuilder, type LineCounts, type LinkedObjects, type Listed, type ListedInput, type Localize, type LogInput, type MaintainInput, type MeOperation, type MergeAnswer, type MergeBaseInput, type MergeBases, type MergeCalls, type MergeCreateInput, type MergeInput, type MergeLabels, type MergeMethod, type MergePlan, public_d_exports$2 as MergeQueue, type MergeQueueCalls, type MergeQueueLayerOptions, type MergeQueueOptions, type MergeTree, public_d_exports$3 as Merges, type MetaValue, MissingContext, MissingReason, type NamedActor, NotAllowedContext, NotAllowedReason, type OAuthClient, type OAuthError, type OAuthTokenResponse, type ObjectHeader, type ObjectHeadersInput, type ObjectInput, type ObjectReadInput, type ObjectReadResult, type ObjectReader, type ObjectReaderInput, type ObjectSizesInput, type ObjectType, type ObjectWrite, type ObjectWrites, objects_namespace_d_exports as Objects, type ObjectsChange, type ObjectsFactory, type ObjectsFetchInput, type ObjectsOpenInput, type ObjectsRead, type ObjectsReadInput, type ObjectsStarting, type ObjectsStartingInput, type ObjectsStep, type Oid, type Operation, type OperationKind, type Option, type Pack, type PacksMemory, type PacksOptions, type PagedInput, type PathObject, type PeelInput, type Peeled, type PinnedRepo, policy_d_exports as Policy, PreconditionContext, PreconditionReason, type PrefixTarget, type Prepare, type PrepareInput, type PreviousQueueSchedule, public_d_exports$4 as PrivateRefs, type ProtectOptions, type ProvidedBy, type PushContext, type PushFacts, type PushHookInput, type PushOperation, type PushOptions, type PushRule, type PushRuleInput, type PushUploadOptions, PushUploadPart, PushUploadStarted, type PushedCommit, type PushedCommitsInput, type Quarantine, type QueueAddInput, type QueueAddOperation, type QueueCandidateOperation, type QueueEntryOperation, type QueueEvent, type QueueFailureCounts, type QueueKeys, type QueueListInput, type QueueListResult, type QueueMeta, type QueueOf, type QueueRecent, type QueueReleaseOperation, type QueueRestarted, type QueueTargetInput, type QueueTargetOperation, type QueueView, type ReadLimits, type ReadObject, type ReadObjects, type ReadOptions, type ReadPage, type ReceiveInput, type Ref, type RefAudience, type RefCalls, type RefCount, type RefCountInput, type RefEdit, type RefForced, type RefInput, type RefListInput, type RefName, type RefPatterns, type RefProtection, type RefPublication, type RefPush, type RefSource, type RefUpdate, type RefUpdateKind, type RefUpdated, type RefView, refs_d_exports as Refs, type RefsPrivateOperation, type RefsUpdateInput, type RefsUpdated, type Refusal, type RefusalReason, type RejectInput, type Rejected, type ReleaseResult, type Released, type RemoteCalls, type RemoteOptions, type RemoteRefsInput, type RemoveResult, type Removed, type RenamesSkipped, type RepackOptions, type RepoAccess, type RepoCalls, type RepoCatalogueEntry, type RepoCreateInput, type RepoCreated, type RepoDeleted, type RepoDeletedEvent, type RepoEnvelope, type RepoEvent, type RepoGetInput, type RepoIndexHold, type RepoIndexRefused, type RepoInfo, type RepoInfoStats, type RepoInput, type RepoJobFailed, type RepoListInput, type RepoListOperation, type RepoListOrder, type RepoMaintained, type RepoName, type RepoOperation, type RepoRecord, repo_records_d_exports as RepoRecords, type RepoRenameInput, type RepoRenamed, type RepoStats, type RepoUpdateInput, type RepoVisibilityChanged, type RepoWork, type RepoWorkFailed, type Report, type ReportDetails, type ReportOptions, type ReportResult, type Reported, repos_d_exports as Repos, type Resolve, type ResolveInput, ResourceContext, ResourceReason, layer_d_exports as Rest, type RestartResult, type Restarted, type Result, type Retried, type RetryResult, type Revision, type RuleOperation, rules_d_exports as Rules, saved_callers_public_d_exports as SavedCallers, type SavedHandlerOptions, type ScheduleOption, type ServerCalls, type ServerSetup, type ShareInput, public_d_exports$5 as SignIn, type Signature, type SliceRefusal, type StageInput, type Staged, type StepAnswer, type StepInput, type Success, type Tag, type TagCalls, type TagCreateInput, type TagFields, tags_d_exports as Tags, type TargetHoldInput, type TokenCalls, type TokenCoverage, type TokenCreateInput, type TokenCreateOperation, type TokenEvent, type TokenEventFields, type TokenFields, type TokenId, type TokenInfo, type TokenListInput, type TokenOperation, type TokenParties, type TokenRecord, type TokenScope, type TokenState, type TokenTarget, tokens_public_d_exports as Tokens, type TokensFeature, type Topic, type TopicAddInput, type TopicAdded, type TopicCalls, type TopicCandidate, type TopicEntry, type TopicEntryInput, type TopicEnvelope, type TopicEvent, type TopicFailed, type TopicFailure, type TopicFailureReason, type TopicId, type TopicListInput, type TopicMerged, type TopicMergedEntry, type TopicOpened, type TopicOperation, type TopicRemoved, type TopicReportInput, type TopicReportOptions, type TopicReportQuestion, type TopicReported, type TopicState, type TopicTarget, type TopicWait, type TopicWorkFailed, public_d_exports$6 as Topics, type TopicsFactory, type TransportFailure, type TransportRetry, type TreeCalls, type TreeChange, type TreeChanges, type TreeCreateInput, type TreeDiffInput, type TreeEdit, type TreeEntry, TreeFilter, type TreeInput, type TreeMergeInput, trees_d_exports as Trees, type TrustedWriteInput, UnavailableContext, UnavailableReason, type UnpackOptions, Verdict, type VerifiedToken, type WalkInput, type WebApproval, type WebAuthorize, type WebExchange, type WholeObject, type WithoutActor, work_d_exports as Work, type WorkCalls, type WorkItem, type WorkListInput, type WorkOperation, type WorkWriteInput, type WriteInput, accept, allotmentWithin, branchRef, createGitClient, createGitServer, gitError, gitPathOf, httpStatus, isGitError, isInternalId, isRefusalReason, lfs, lfsPointerOid, lfsPointers, loose, looseLimits, maxActorIdLength, maxLfsPointerBytes, maxRefNameLength, mergeQueue, objectsReadMost, packs, packsMemory, paginate, peelMost, peelTagsMost, reject, shortTarget, topics };
89
+ import { jobStates } from "@ref0/infra";
90
+ export { type Accepted, type AccessOption, type Acting, type Actor, type ActorId, type ActorInput, type AddResult, type Added, type Allotment, type AnonymousActor, type ApprovalBase, type ApprovalDecision, type ApprovalPageContext, type ApprovalPageInput, type ApprovalPrompt, type ApprovedGrant, auth_namespace_d_exports as Auth, type AuthInput, authorize_d_exports as Authorize, type AuthorizeAnswer, type AuthorizeInput, type Awaitable, type BasicCredential, type BatchOptions, type BearerCredential, type BeforeAfter, BeginPushUpload, type Bisect, type Blob, type BlobCalls, type BlobCreateInput, BlobLimit, BlobNone, blobs_d_exports as Blobs, type BypassOperation, type Bytes, type CallInput, type Caller, type CallerGrant, type Candidate, type CandidateCloseReason, type CandidateClosed, type CandidateClosedFields, type CandidateId, type CandidateOpened, type CandidateReportInput, type CandidateReported, type CandidateResult, type CandidateState, type CandidatesResult, type ClientAdapter, type ClientCredential, type ClientCredentials, type ClientFetchInput, type ClientFetchResult, type ClientPushInput, type Commit, type CommitCalls, type CommitCreateInput, type CommitDiffInput, commits_d_exports as Commits, type Compare, type CompareInput, type ComparisonFile, type ConfirmApprovalPage, ContextValue, type CopyRow, type CopyRowsInput, type CopyRowsPage, type CreatedObject, type CreatedToken, type CredentialInput, type Credentials, type CredentialsBasic, type CredentialsBearer, DataLossContext, DataLossReason, type DecisionAnswer, type DeniedGrant, type DeviceApproval, type DeviceCodePage, type DeviceCodeRequest, type DeviceCodeResponse, type DeviceExchange, type DiffListing, type EffectiveLimits, type Entry, type EntryAdded, type EntryFailed, type EntryFailureReason, type EntryFields, type EntryGroups, type EntryHoldInput, type EntryHoldsInput, type EntryId, type EntryMerged, type EntryRemoved, type EntryResult, type EntryRetried, type EntryState, ErrorContext, type EventEnvelope, type EventFeature, event_streams_d_exports as EventStreams, events_d_exports as Events, ExistingContext, ExistingReason, type FailureResult, type FeedItem, type FenceReason, type FencedPack, type FetchAdjustment, type FetchAnswer, type FetchReadInput, type FetchReadTarget, FetchRequest, type FetchRule, type FetchRuleInput, type File, type FileCalls, type FileDiff, type FileReadInput, type FileRuleOptions, files_d_exports as Files, type FilesAllowOperation, type FilesDiffInput, type FilesListInput, type FilesRead, Filter, FinishPushUpload, type ForkCalls, type ForkCreateInput, type ForkFetched, type ForkGetInput, type ForkHolder, type ForkListInput, type ForkOperation, forks_d_exports as Forks, git_namespace_d_exports as Git, type GitAdapter, type GitAuth, type GitAuthorize, client_d_exports as GitClient, type GitClientCalls, type GitClientOptions, type GitError, GitErrorBody, type GitErrorCode, type GitErrorContexts, type GitErrorFields, type GitErrorInput, type GitErrorTagged, type GitEvent, git_events_d_exports as GitEvents, public_d_exports as GitHooks, type GitNeeds, type GitObject, type GitObjects, type GitScope, type GitServer, type GitServerOptions, type GitStore, type GitStoreAddInput, type GitStoreCommitInput, type GitStoreReadInput, type Grant, type GrantAgainInput, type GrantAgainRequest, type GrantInput, type GrantReachInput, type GrantResolver, type GrantScope, type HandlerOptions, type Held, type HeldPack, type HiddenSpan, type Hold, type HoldEvent, type HoldEventFields, type HoldFields, type HoldId, type HoldResult, type Holding, type HoldingsInput, type HoldingsWalked, type HoldsResult, HostErrorContext, type HostFunctionName, type ImportState, type IndexCalls, type IndexReachInput, type IndexReached, type IndexRefusal, type IndexStatus, type IndexTip, type IndexTry, type IndexTryInput, InternalRepoId, InvalidInputContext, InvalidInputReason, type JoinInput, type Judged, type LanesInput, public_d_exports$1 as Lfs, type LfsCalls, type LfsFeature, type LfsGetInput, type LfsObject, type LfsOptions, type LfsPointers, type LfsPointersBuilder, type LineCounts, type LinkedObjects, type Listed, type ListedInput, type ListenInput, type Localize, type LogInput, type MaintainInput, type Me, type MeOperation, type MergeAnswer, type MergeBaseInput, type MergeBases, type MergeCalls, type MergeCreateInput, type MergeInput, type MergeLabels, type MergeMethod, type MergePlan, public_d_exports$2 as MergeQueue, type MergeQueueCalls, type MergeQueueLayerOptions, type MergeQueueOptions, type MergeTree, public_d_exports$3 as Merges, type MetaValue, MissingContext, MissingReason, type NamedActor, NotAllowedContext, NotAllowedReason, type OAuthClient, type OAuthError, type OAuthTokenResponse, type ObjectHeader, type ObjectHeadersInput, type ObjectInput, type ObjectReadInput, type ObjectReadResult, type ObjectReader, type ObjectReaderInput, type ObjectSizesInput, type ObjectType, type ObjectWrite, type ObjectWrites, objects_namespace_d_exports as Objects, type ObjectsChange, type ObjectsFactory, type ObjectsFetchInput, type ObjectsOpenInput, type ObjectsRead, type ObjectsReadInput, type ObjectsStarting, type ObjectsStartingInput, type ObjectsStep, type Oid, type Operation, type OperationKind, type Option, type Pack, type PacksMemory, type PacksOptions, type PagedInput, type PathObject, type PeelInput, type Peeled, type PinnedRepo, policy_d_exports as Policy, PreconditionContext, PreconditionReason, type PrefixTarget, type Prepare, type PrepareInput, type PreviousQueueSchedule, public_d_exports$4 as PrivateRefs, type ProtectOptions, type ProvidedBy, type PushContext, type PushFacts, type PushHookInput, type PushOperation, type PushOptions, type PushRule, type PushRuleInput, type PushUploadOptions, PushUploadPart, PushUploadStarted, type PushedCommit, type PushedCommitsInput, type Quarantine, type QueueAddInput, type QueueAddOperation, type QueueCandidateOperation, type QueueEntryOperation, type QueueEvent, type QueueFailureCounts, type QueueInternals, type QueueKeys, type QueueListInput, type QueueListResult, type QueueMeta, type QueueOf, type QueueRecent, type QueueReleaseOperation, type QueueRestarted, type QueueTargetInput, type QueueTargetOperation, type QueueView, type ReadLimits, type ReadObject, type ReadObjects, type ReadOptions, type ReadPage, type ReceiveInput, type Ref, type RefAudience, type RefCalls, type RefCount, type RefCountInput, type RefEdit, type RefForced, type RefInput, type RefListInput, type RefName, type RefPatterns, type RefProtection, type RefPublication, type RefPush, type RefSource, type RefUpdate, type RefUpdateKind, type RefUpdated, type RefView, refs_d_exports as Refs, type RefsPrivateOperation, type RefsUpdateInput, type RefsUpdated, type RefusalReason, type RejectInput, type Rejected, type ReleaseResult, type Released, type RemoteCalls, type RemoteOptions, type RemoteRefsInput, type RemoveResult, type Removed, type RenamesSkipped, type RepackOptions, type RepoAccess, type RepoCalls, type RepoCatalogueEntry, type RepoCreateInput, type RepoCreated, type RepoDeleted, type RepoDeletedEvent, type RepoEnvelope, type RepoEvent, type RepoGetInput, type RepoIndexHold, type RepoIndexRefused, type RepoInfo, type RepoInfoStats, type RepoInput, type RepoJobFailed, type RepoListInput, type RepoListOperation, type RepoListOrder, type RepoMaintained, type RepoName, type RepoOperation, type RepoRecord, repo_records_d_exports as RepoRecords, type RepoRenameInput, type RepoRenamed, type RepoStats, type RepoStreamEvent, type RepoUpdateInput, type RepoVisibilityChanged, type RepoWork, type RepoWorkFailed, type Report, type ReportDetails, type ReportOptions, type ReportResult, type Reported, repos_d_exports as Repos, ResourceContext, ResourceReason, layer_d_exports as Rest, client_d_exports$1 as RestClient, type RestClientCalls, type RestEvents, type RestTokenCalls, type RestartResult, type Restarted, type Result, type Retried, type RetryResult, type Revision, type RowsMoved, type RuleOperation, rules_d_exports as Rules, saved_callers_public_d_exports as SavedCallers, type SavedHandlerOptions, type ScheduleOption, type ServerCalls, type ServerSetup, type ShareInput, public_d_exports$5 as SignIn, type Signature, type SliceRefusal, type StageInput, type Staged, type StepAnswer, type StepInput, type Success, type Tag, type TagCalls, type TagCreateInput, type TagFields, tags_d_exports as Tags, type TargetHoldInput, type TokenCalls, type TokenCoverage, type TokenCreateInput, type TokenCreateOperation, type TokenEvent, type TokenEventFields, type TokenFields, type TokenId, type TokenInfo, type TokenListInput, type TokenOperation, type TokenParties, type TokenRecord, type TokenScope, type TokenState, type TokenTarget, tokens_public_d_exports as Tokens, type TokensFeature, type Topic, type TopicAddInput, type TopicAdded, type TopicCalls, type TopicCandidate, type TopicEntry, type TopicEntryInput, type TopicEnvelope, type TopicEvent, type TopicFailed, type TopicFailure, type TopicFailureReason, type TopicId, type TopicListInput, type TopicMerged, type TopicMergedEntry, type TopicOpened, type TopicOperation, type TopicRemoved, type TopicReportInput, type TopicReportOptions, type TopicReportQuestion, type TopicReported, type TopicState, type TopicTarget, type TopicWait, type TopicWorkFailed, public_d_exports$6 as Topics, type TopicsFactory, type TransportFailure, type TransportRetry, type TreeCalls, type TreeChange, type TreeChanges, type TreeCreateInput, type TreeDiffInput, type TreeEdit, type TreeEntry, TreeFilter, type TreeInput, type TreeMergeInput, trees_d_exports as Trees, type TrustedWriteInput, UnavailableContext, UnavailableReason, type UnpackOptions, Verdict, type VerifiedToken, type WalkInput, type WebApproval, type WebAuthorize, type WebExchange, type WholeObject, type WithoutActor, type WithoutSignal, work_d_exports as Work, type WorkCalls, type WorkItem, type WorkListInput, type WorkOperation, type WorkWriteInput, type WriteInput, accept, allotmentWithin, branchRef, createGitServer, gitError, gitPathOf, grantScopes, httpStatus, isGitError, isInternalId, isRefusalReason, jobStates, lfs, lfsPointerOid, lfsPointers, loose, looseLimits, maxActorIdLength, maxLfsPointerBytes, maxRefNameLength, mergeQueue, objectsReadMost, packs, packsMemory, peelMost, peelTagsMost, reject, shortTarget, tokenScopes, tokenStates, topics };
package/dist/index.mjs CHANGED
@@ -1,4 +1,6 @@
1
- import { createGitClient, paginate } from "./client/client.mjs";
1
+ import { client_exports } from "./client/client.mjs";
2
+ import { client_exports as client_exports$1 } from "./rest/client.mjs";
3
+ import { grantScopes, tokenScopes, tokenStates } from "./contracts/tokens.mjs";
2
4
  import { authorize_exports } from "./contracts/authorize.mjs";
3
5
  import { blobs_exports } from "./contracts/blobs.mjs";
4
6
  import { commits_exports } from "./contracts/commits.mjs";
@@ -43,4 +45,5 @@ import { public_exports as public_exports$6 } from "./topics/public.mjs";
43
45
  import { tokens_public_exports } from "./auth/tokens-public.mjs";
44
46
  import { public_exports } from "./core/hooks/public.mjs";
45
47
  import { public_exports as public_exports$5 } from "./signin/public.mjs";
46
- export { auth_namespace_exports as Auth, authorize_exports as Authorize, BeginPushUpload, BlobLimit, BlobNone, blobs_exports as Blobs, commits_exports as Commits, ContextValue, DataLossContext, DataLossReason, ErrorContext, event_streams_exports as EventStreams, events_exports as Events, ExistingContext, ExistingReason, FetchRequest, files_exports as Files, Filter, FinishPushUpload, forks_exports as Forks, git_namespace_exports as Git, GitErrorBody, git_events_exports as GitEvents, public_exports as GitHooks, HostErrorContext, InternalRepoId, InvalidInputContext, InvalidInputReason, public_exports$1 as Lfs, public_exports$2 as MergeQueue, public_exports$3 as Merges, MissingContext, MissingReason, NotAllowedContext, NotAllowedReason, objects_namespace_exports as Objects, policy_exports as Policy, PreconditionContext, PreconditionReason, public_exports$4 as PrivateRefs, PushUploadPart, PushUploadStarted, refs_exports as Refs, repo_records_exports as RepoRecords, repos_exports as Repos, ResourceContext, ResourceReason, layer_exports as Rest, rules_exports as Rules, saved_callers_public_exports as SavedCallers, public_exports$5 as SignIn, tags_exports as Tags, tokens_public_exports as Tokens, public_exports$6 as Topics, TreeFilter, trees_exports as Trees, UnavailableContext, UnavailableReason, Verdict, work_exports as Work, accept, allotmentWithin, branchRef, createGitClient, createGitServer, gitError, gitPathOf, httpStatus, isGitError, isInternalId, isRefusalReason, lfs, lfsPointerOid, lfsPointers, loose, looseLimits, maxActorIdLength, maxLfsPointerBytes, maxRefNameLength, mergeQueue, objectsReadMost, packs, packsMemory, paginate, peelMost, peelTagsMost, reject, shortTarget, topics };
48
+ import { jobStates } from "@ref0/infra";
49
+ export { auth_namespace_exports as Auth, authorize_exports as Authorize, BeginPushUpload, BlobLimit, BlobNone, blobs_exports as Blobs, commits_exports as Commits, ContextValue, DataLossContext, DataLossReason, ErrorContext, event_streams_exports as EventStreams, events_exports as Events, ExistingContext, ExistingReason, FetchRequest, files_exports as Files, Filter, FinishPushUpload, forks_exports as Forks, git_namespace_exports as Git, client_exports as GitClient, GitErrorBody, git_events_exports as GitEvents, public_exports as GitHooks, HostErrorContext, InternalRepoId, InvalidInputContext, InvalidInputReason, public_exports$1 as Lfs, public_exports$2 as MergeQueue, public_exports$3 as Merges, MissingContext, MissingReason, NotAllowedContext, NotAllowedReason, objects_namespace_exports as Objects, policy_exports as Policy, PreconditionContext, PreconditionReason, public_exports$4 as PrivateRefs, PushUploadPart, PushUploadStarted, refs_exports as Refs, repo_records_exports as RepoRecords, repos_exports as Repos, ResourceContext, ResourceReason, layer_exports as Rest, client_exports$1 as RestClient, rules_exports as Rules, saved_callers_public_exports as SavedCallers, public_exports$5 as SignIn, tags_exports as Tags, tokens_public_exports as Tokens, public_exports$6 as Topics, TreeFilter, trees_exports as Trees, UnavailableContext, UnavailableReason, Verdict, work_exports as Work, accept, allotmentWithin, branchRef, createGitServer, gitError, gitPathOf, grantScopes, httpStatus, isGitError, isInternalId, isRefusalReason, jobStates, lfs, lfsPointerOid, lfsPointers, loose, looseLimits, maxActorIdLength, maxLfsPointerBytes, maxRefNameLength, mergeQueue, objectsReadMost, packs, packsMemory, peelMost, peelTagsMost, reject, shortTarget, tokenScopes, tokenStates, topics };
@@ -1,11 +1,12 @@
1
1
  import { LfsObject } from "../contracts/lfs.mjs";
2
2
  import { GitError } from "../contracts/result.mjs";
3
3
  import { RegisteredCheck } from "../core/rules/context.mjs";
4
- import { Bucket, Links } from "../contracts/objects.mjs";
4
+ import { Bucket as Bucket$1, Links } from "../contracts/objects.mjs";
5
5
  import { CoreNeeds } from "../core/parts.mjs";
6
6
  import { ObjectRead } from "./objects.mjs";
7
7
  import { LfsService } from "./service.mjs";
8
8
  import * as Effect from "effect/Effect";
9
+ import { RequestLimits } from "@ref0/infra";
9
10
  import * as Context from "effect/Context";
10
11
  /** A listed object's bytes, as `objectOf` reads them over LFS's parts. */
11
12
  export type LfsRead = (read: ObjectRead) => Effect.Effect<LfsObject, GitError, CoreNeeds>;
@@ -20,13 +21,15 @@ export interface LfsAttached {
20
21
  }
21
22
  declare const LfsBase_base: Context.ServiceClass<LfsBase, "@ref0/git/lfs/LfsBase", {
22
23
  readonly needs: Context.Context<CoreNeeds>;
23
- readonly bucket: Bucket | undefined;
24
+ readonly bucket: Bucket$1 | undefined;
24
25
  readonly links: Links | undefined;
26
+ readonly requestLimits: RequestLimits.RequestLimits['Service'];
25
27
  readonly attach: (lfs: LfsAttached) => Effect.Effect<void>;
26
28
  }>;
27
29
  /**
28
30
  * What `Git.layer` gives `Lfs.layer`: the server's services, the adapter's bucket, each call it
29
- * makes charged, and its links, when it has them; and `attach`, once, before the seal.
31
+ * makes charged, its links, when it has them, and its `RequestLimits`, none when it gives none;
32
+ * and `attach`, once, before the seal.
30
33
  */
31
34
  export declare class LfsBase extends /* @__PURE__ */ LfsBase_base {}
32
35
  export {};
package/dist/lfs/base.mjs CHANGED
@@ -2,7 +2,8 @@ import * as Context from "effect/Context";
2
2
  // src/lfs/base.ts
3
3
  /**
4
4
  * What `Git.layer` gives `Lfs.layer`: the server's services, the adapter's bucket, each call it
5
- * makes charged, and its links, when it has them; and `attach`, once, before the seal.
5
+ * makes charged, its links, when it has them, and its `RequestLimits`, none when it gives none;
6
+ * and `attach`, once, before the seal.
6
7
  */
7
8
  var LfsBase = class extends (/* @__PURE__ */ Context.Service()("@ref0/git/lfs/LfsBase")) {};
8
9
  export { LfsBase };
@@ -1,5 +1,5 @@
1
1
  import { Git } from "../contracts/git.mjs";
2
- import { LfsGetInput, LfsObject } from "../contracts/lfs.mjs";
2
+ import { LfsGetInput, LfsObject, LfsOptions } from "../contracts/lfs.mjs";
3
3
  import { RepoName } from "../contracts/ids.mjs";
4
4
  import { GitError } from "../contracts/result.mjs";
5
5
  import { LfsBase } from "./base.mjs";
@@ -22,7 +22,8 @@ export declare class Lfs extends /* @__PURE__ */ Lfs_base {}
22
22
  /**
23
23
  * Git LFS, a feature over core: it registers `lfs`, keeps its objects in the host's `Bucket`, and
24
24
  * serves git-lfs's API under each repo's `info/lfs/`. With `BucketLinks` its transfers go straight
25
- * to the bucket; without, through the Worker.
25
+ * to the bucket; without, through the Worker, each upload held to what the host's caps let finish:
26
+ * `options`, each winning over the adapter's `RequestLimits`, as `LfsOptions` says.
26
27
  */
27
- export declare const layer: () => Layer.Layer<Lfs, GitError, Git | LfsBase | Bucket.Bucket>;
28
+ export declare const layer: (options?: LfsOptions) => Layer.Layer<Lfs, GitError, Git | LfsBase | Bucket.Bucket>;
28
29
  export {};
@@ -1,11 +1,13 @@
1
1
  import { register } from "../contracts/git.mjs";
2
- import { callerFor } from "../core/access.mjs";
2
+ import { callerFor, resolvedAs } from "../core/access.mjs";
3
+ import { seenIn } from "../core/objects/reading.mjs";
3
4
  import { LfsBase } from "./base.mjs";
4
5
  import { objectOf } from "./objects.mjs";
5
6
  import { pointerCheck } from "./pointers.mjs";
6
7
  import { lfsPurge } from "./purge.mjs";
7
8
  import { lfsService } from "./service.mjs";
8
9
  import { lfsUpkeep } from "./upkeep.mjs";
10
+ import { capsRefusal, uploadMostOf } from "./upload-most.mjs";
9
11
  import * as Effect from "effect/Effect";
10
12
  import { Bucket } from "@ref0/infra";
11
13
  import * as Context from "effect/Context";
@@ -15,16 +17,25 @@ import * as Layer from "effect/Layer";
15
17
  var Lfs = class extends (/* @__PURE__ */ Context.Service()("@ref0/git/Lfs")) {};
16
18
  /**
17
19
  * LFS over `registration`: its routes and pointer check attached to the server, its upkeep and purge on
18
- * the registration, its rows the registration's, under `lfs/`. A server with no bucket is a defect.
20
+ * the registration, its rows the registration's, under `lfs/`. Its uploads through the server are
21
+ * held to the adapter's `RequestLimits`, each of `options` winning over its own. A server with no
22
+ * bucket, or `options` that aren't caps, is a defect.
19
23
  */
20
- const lfsRegistration = /* @__PURE__ */ Effect.fnUntraced(function* (registration) {
24
+ const lfsRegistration = /* @__PURE__ */ Effect.fnUntraced(function* (registration, options = {}) {
21
25
  const base = yield* LfsBase;
22
- const { needs, bucket, links } = base;
26
+ const { needs, bucket, links, requestLimits } = base;
23
27
  if (bucket === void 0) return yield* Effect.die(/* @__PURE__ */ new TypeError("lfs() keeps its objects in the adapter's bucket: give the adapter a bucket"));
28
+ const caps = {
29
+ bodyCap: options.bodyCap ?? requestLimits.bodyBytes,
30
+ cpuMs: options.cpuMs ?? requestLimits.cpuMs
31
+ };
32
+ const refusal = capsRefusal(caps);
33
+ if (refusal !== void 0) return yield* Effect.die(new TypeError(refusal));
24
34
  const parts = {
25
35
  rows: registration.rows,
26
36
  bucket,
27
- signed: links
37
+ signed: links,
38
+ uploadMost: uploadMostOf(caps)
28
39
  };
29
40
  const read = (one) => objectOf(parts, one);
30
41
  const callerOf = callerFor(void 0);
@@ -35,7 +46,9 @@ const lfsRegistration = /* @__PURE__ */ Effect.fnUntraced(function* (registratio
35
46
  band: "post",
36
47
  handler: (input, updates) => pointerCheck(registration.rows, {
37
48
  updates,
38
- objects: input.objects
49
+ objects: input.objects,
50
+ caller: input.caller,
51
+ seen: (blobs) => Effect.provideContext(Effect.flatMap(resolvedAs(input.repo, input.objects.repo), (resolved) => seenIn(input.caller, resolved, blobs)), needs)
39
52
  })
40
53
  },
41
54
  read
@@ -55,11 +68,12 @@ const lfsRegistration = /* @__PURE__ */ Effect.fnUntraced(function* (registratio
55
68
  /**
56
69
  * Git LFS, a feature over core: it registers `lfs`, keeps its objects in the host's `Bucket`, and
57
70
  * serves git-lfs's API under each repo's `info/lfs/`. With `BucketLinks` its transfers go straight
58
- * to the bucket; without, through the Worker.
71
+ * to the bucket; without, through the Worker, each upload held to what the host's caps let finish:
72
+ * `options`, each winning over the adapter's `RequestLimits`, as `LfsOptions` says.
59
73
  */
60
- const layer = () => Layer.effect(Lfs, Effect.gen(function* () {
74
+ const layer = (options = {}) => Layer.effect(Lfs, Effect.gen(function* () {
61
75
  yield* Bucket.Bucket;
62
76
  const registration = yield* register({ name: "lfs" });
63
- return yield* lfsRegistration(registration);
77
+ return yield* lfsRegistration(registration, options);
64
78
  }));
65
79
  export { Lfs, layer, lfsRegistration };
@@ -1,5 +1,7 @@
1
- import { Sha256 } from "../protocol/bytes/sha256.mjs";
1
+ import { nativeSha256Hasher } from "../protocol/bytes/sha256-hasher.mjs";
2
2
  import { contended, openFor } from "../core/access.mjs";
3
+ import { ownWriter } from "../core/own-writes.mjs";
4
+ import { sweepDue } from "../core/receipts.mjs";
3
5
  import { seenIn } from "../core/objects/reading.mjs";
4
6
  import { checkRead, readRefusal } from "../core/rules/fetch.mjs";
5
7
  import { utf8 } from "../protocol/bytes/text.mjs";
@@ -10,6 +12,8 @@ import { bucketCall, bucketDo, bucketFailed, bucketStream } from "../storage/cal
10
12
  import { isLfsOid, lfsPointerText } from "../protocol/objects/lfs-pointer.mjs";
11
13
  import { ListedRow, UploadRow, largestObject, lfsCollections, linkLife, listedKey, listedRead, objectKey, stagingId, stagingKey, stagingRead, streamMost, uploadGrace, uploadKey, uploadRead } from "./rows.mjs";
12
14
  import { BatchRequest, VerifyRequest, batchMost, bodyOf, lfsAnswer } from "./wire.mjs";
15
+ import { uploadedRow } from "./uploaded.mjs";
16
+ import { pastMost } from "./upload-most.mjs";
13
17
  import { fail, gitError, httpStatus } from "../contracts/result.mjs";
14
18
  import * as Clock$1 from "effect/Clock";
15
19
  import * as Effect from "effect/Effect";
@@ -20,10 +24,12 @@ import * as DateTime from "effect/DateTime";
20
24
  // src/lfs/objects.ts
21
25
  /**
22
26
  * Each object's rows, read with the repo's record and the fence's rows at one version, the fence
23
- * checked; `also`'s rows after them. A repo deleted since it opened is `NOT_FOUND`.
27
+ * checked; `also`'s rows after them. An object's upload row is the caller's own, as `uploader`
28
+ * names it. A repo deleted since it opened is `NOT_FOUND`.
24
29
  */
25
30
  const objectRows = /* @__PURE__ */ Effect.fnUntraced(function* (rows, caller, repo, oids, also = []) {
26
- const own = oids.flatMap((oid) => [listedRead(oid), uploadRead(oid)]);
31
+ const uploader = (yield* ownWriter(caller)) ?? "anonymous";
32
+ const own = oids.flatMap((oid) => [listedRead(oid), uploadRead(oid, uploader)]);
27
33
  const { version, results } = yield* rows.readFenced(caller, repo, [...own, ...also]);
28
34
  const found = /* @__PURE__ */ new Map();
29
35
  for (const [at, oid] of oids.entries()) {
@@ -35,6 +41,7 @@ const objectRows = /* @__PURE__ */ Effect.fnUntraced(function* (rows, caller, re
35
41
  }
36
42
  return {
37
43
  version,
44
+ uploader,
38
45
  rows: found,
39
46
  also: results.slice(own.length)
40
47
  };
@@ -141,9 +148,15 @@ const batch = /* @__PURE__ */ Effect.fnUntraced(function* (parts, call) {
141
148
  if (body.objects.length > 1e3) return yield* fail("RESOURCE_EXHAUSTED", `A batch names at most ${batchMost} objects`);
142
149
  const upload = body.operation === "upload";
143
150
  const repo = yield* openFor(call.caller, call.repo, upload);
144
- const valid = body.objects.filter(({ oid, size }) => isLfsOid(oid) && validSize(size));
151
+ const most = upload && parts.signed === void 0 ? parts.uploadMost : void 0;
152
+ const refusalOf = (oid, size) => {
153
+ if (!isLfsOid(oid)) return "An oid is a SHA-256, as 64 lowercase hex digits";
154
+ if (!validSize(size)) return `A size is 0 to ${largestObject} bytes`;
155
+ return most !== void 0 && size > most.bytes ? pastMost(most) : void 0;
156
+ };
157
+ const valid = body.objects.filter(({ oid, size }) => refusalOf(oid, size) === void 0);
145
158
  const answers = upload ? yield* uploads(parts, call, repo, valid) : yield* downloads(parts, call, repo, valid);
146
- const objects = body.objects.map(({ oid, size }) => answers.get(oid) ?? objectError(oid, size, 422, isLfsOid(oid) ? `A size is 0 to ${largestObject} bytes` : "An oid is a SHA-256, as 64 lowercase hex digits"));
159
+ const objects = body.objects.map(({ oid, size }) => answers.get(oid) ?? objectError(oid, size, 422, refusalOf(oid, size) ?? ""));
147
160
  return lfsAnswer(200, {
148
161
  transfer: "basic",
149
162
  objects,
@@ -208,8 +221,9 @@ const downloads = /* @__PURE__ */ Effect.fnUntraced(function* (parts, call, repo
208
221
  /**
209
222
  * Upload links for the objects not yet listed. Each gets its upload row first, in one commit at
210
223
  * the read's version, so upkeep, which deletes an unlisted object's bytes only past its row's
211
- * `removeAt`, never deletes bytes a link given now may still write. A row kept keeps its generation,
212
- * so its links all write one key; a new row gets a new one.
224
+ * `removeAt`, never deletes bytes a link given now may still write. Each row is the caller's own,
225
+ * and a row kept keeps its generation, so its links all write one key no other caller's write; a
226
+ * new row gets a new one.
213
227
  */
214
228
  const uploads = /* @__PURE__ */ Effect.fnUntraced(function* (parts, call, repo, objects) {
215
229
  const oids = objects.map(({ oid }) => oid);
@@ -228,18 +242,21 @@ const uploads = /* @__PURE__ */ Effect.fnUntraced(function* (parts, call, repo,
228
242
  generation: before?.generation ?? randomText(16)
229
243
  };
230
244
  return {
231
- ...uploadKey(oid),
232
- value
245
+ oid,
246
+ row: {
247
+ ...uploadKey(oid, read.uploader),
248
+ value
249
+ }
233
250
  };
234
251
  });
235
252
  if (put.length > 0) {
236
253
  if (!(yield* parts.rows.commit(repo.internalId, read.version, {
237
- put,
254
+ put: put.map(({ row }) => row),
238
255
  wake: removeAt
239
256
  })).ok) continue;
240
257
  }
241
258
  const answers = /* @__PURE__ */ new Map();
242
- const generations = new Map(put.map((row) => [row.id, row.value.generation]));
259
+ const generations = new Map(put.map(({ oid, row }) => [oid, row.value.generation]));
243
260
  for (const { oid, size } of objects) {
244
261
  const generation = generations.get(oid);
245
262
  const key = generation === void 0 ? void 0 : objectKey(repo.internalId, oid, generation);
@@ -272,16 +289,18 @@ const uploadActions = /* @__PURE__ */ Effect.fnUntraced(function* (parts, call,
272
289
  });
273
290
  /**
274
291
  * `POST objects/verify`, after a signed upload: lists the object once the bucket holds bytes at
275
- * its upload row's key that it checked against its oid. The rows are read before the bucket, so
276
- * upkeep's commit that drops the upload row to delete the bytes moves the version this commit
277
- * expects.
292
+ * the caller's own upload row's key that it checked against its oid, which only the caller's links
293
+ * wrote. The rows are read before the bucket, so upkeep's commit that drops the upload row to
294
+ * delete the bytes moves the version this commit expects.
278
295
  */
279
296
  const verify = /* @__PURE__ */ Effect.fnUntraced(function* (parts, call) {
280
297
  const { oid, size } = yield* bodyOf(call.request, VerifyRequest);
281
298
  if (!isLfsOid(oid)) return yield* fail("INVALID_ARGUMENT", "An oid is a SHA-256, as 64 lowercase hex digits");
282
299
  const { rows: registered, signed } = parts;
283
300
  const repo = yield* openFor(call.caller, call.repo, true);
301
+ const writer = yield* ownWriter(call.caller);
284
302
  for (let tries = 0; tries < 5; tries += 1) {
303
+ const at = yield* Clock$1.currentTimeMillis;
285
304
  const read = yield* objectRows(registered, call.caller, repo, [oid]);
286
305
  const rows = read.rows.get(oid);
287
306
  const unseen = (yield* unseenRows(call.caller, repo, [oid], read.rows)).has(oid);
@@ -290,16 +309,21 @@ const verify = /* @__PURE__ */ Effect.fnUntraced(function* (parts, call) {
290
309
  const stored = signed === void 0 || key === void 0 ? void 0 : yield* bucketCall(Effect.map(signed.head(key), Option.getOrUndefined));
291
310
  if (stored?.sha256 !== oid) return yield* fail("FAILED_PRECONDITION", "The bucket holds no bytes for this object", { hint: "Upload it again" });
292
311
  if (stored.size !== size) return yield* fail("INVALID_ARGUMENT", `This object is ${stored.size} bytes, not ${size}`);
293
- if (unseen) return lfsAnswer(200, { message: "Verified" });
294
- if ((yield* registered.commit(repo.internalId, read.version, {
312
+ const own = writer === void 0 ? [] : [uploadedRow(writer, oid, at)];
313
+ const writes = unseen ? { put: own } : {
295
314
  put: [{
296
315
  ...listedKey(oid),
297
316
  value: {
298
317
  size: stored.size,
299
318
  key
300
319
  }
301
- }],
302
- delete: [uploadKey(oid)]
320
+ }, ...own],
321
+ delete: [uploadKey(oid, read.uploader)]
322
+ };
323
+ if (writes.put.length === 0) return lfsAnswer(200, { message: "Verified" });
324
+ if ((yield* registered.commit(repo.internalId, read.version, {
325
+ ...writes,
326
+ wake: sweepDue(at)
303
327
  })).ok) return lfsAnswer(200, { message: "Verified" });
304
328
  }
305
329
  return yield* contended();
@@ -311,6 +335,9 @@ const verify = /* @__PURE__ */ Effect.fnUntraced(function* (parts, call) {
311
335
  */
312
336
  const receive = /* @__PURE__ */ Effect.fnUntraced(function* (parts, call, oid) {
313
337
  if (!isLfsOid(oid)) return yield* fail("INVALID_ARGUMENT", "An oid is a SHA-256, as 64 lowercase hex digits");
338
+ const length = lengthOf(call.request);
339
+ if (length === void 0) return lfsAnswer(411, { message: noLength });
340
+ if (length > parts.uploadMost.bytes) return lfsAnswer(413, { message: pastMost(parts.uploadMost) });
314
341
  const { rows: registered, bucket } = parts;
315
342
  const repo = yield* openFor(call.caller, call.repo, true);
316
343
  const started = yield* Clock$1.currentTimeMillis;
@@ -320,6 +347,7 @@ const receive = /* @__PURE__ */ Effect.fnUntraced(function* (parts, call, oid) {
320
347
  if (rows?.listed !== void 0 && !unseen) return yield* answered(call.request);
321
348
  const upload = rows?.upload;
322
349
  if (upload === void 0 || upload.expiresAt < started) return yield* fail("FAILED_PRECONDITION", "No upload link for this object is live", { hint: "Ask the batch API again" });
350
+ if (upload.size > parts.uploadMost.bytes) return lfsAnswer(413, { message: pastMost(parts.uploadMost) });
323
351
  const id = randomText(16);
324
352
  const key = stagingKey(repo.internalId, id);
325
353
  const staged = stagingId(started + uploadGrace, id);
@@ -335,15 +363,8 @@ const receive = /* @__PURE__ */ Effect.fnUntraced(function* (parts, call, oid) {
335
363
  wake: started + uploadGrace
336
364
  });
337
365
  const hashed = hashing(call.request.body, upload.size);
338
- const body = Stream.fromReadableStream({
339
- evaluate: () => hashed.stream,
340
- onError: (cause) => new Unavailable({
341
- message: bucketFailed,
342
- cause
343
- })
344
- });
345
- yield* Effect.uninterruptible(bucketDo(bucket.put(key, body, { size: upload.size }))).pipe(Effect.mapError((error) => hashed.past() ? pastSize(upload.size) : error));
346
- if (hashed.sha256() !== oid) {
366
+ yield* Effect.uninterruptible(bucketDo(bucket.put(key, hashed.body, { size: upload.size }))).pipe(Effect.mapError((error) => hashed.past() ? pastSize(upload.size) : error));
367
+ if ((yield* hashed.hasher.hex) !== oid) {
347
368
  yield* dropStaged(parts, repo.internalId, key, staged);
348
369
  return yield* fail("INVALID_ARGUMENT", "The bytes' SHA-256 isn't the oid");
349
370
  }
@@ -372,6 +393,14 @@ const dropStaged = /* @__PURE__ */ Effect.fnUntraced(function* (parts, repo, key
372
393
  yield* parts.rows.commit(repo, read.version, { delete: [row] });
373
394
  }));
374
395
  });
396
+ /** Why a PUT with no `content-length` is refused. */
397
+ const noLength = "An upload needs its Content-Length: git-lfs sends one, and this request had none";
398
+ /** A request's `content-length`, or none where it has none, or one that isn't a length. */
399
+ const lengthOf = (request) => {
400
+ const header = request.headers.get("content-length");
401
+ const length = header === null || !/^\d+$/.test(header) ? NaN : Number(header);
402
+ return Number.isSafeInteger(length) ? length : void 0;
403
+ };
375
404
  const pastSize = (size) => gitError("INVALID_ARGUMENT", `The bytes run past the ${size} the batch named`);
376
405
  /**
377
406
  * An answer to a request whose body isn't needed: the body is let go first, and a cancel that
@@ -381,27 +410,46 @@ const answered = (request) => Effect.promise(async () => {
381
410
  await request.body?.cancel();
382
411
  return lfsAnswer(200, { message: "Already uploaded" });
383
412
  });
384
- /** `body` as it streams to the bucket, hashed and counted, erroring past `most` bytes. */
413
+ /**
414
+ * `body` as it streams to the bucket, counted, and hashed through the runtime's own SHA-256, each
415
+ * chunk's write awaited before it goes on, failing past `most` bytes.
416
+ */
385
417
  const hashing = (body, most) => {
386
- const hash = new Sha256();
418
+ const hasher = nativeSha256Hasher();
387
419
  let size = 0;
388
- const counting = new TransformStream({ transform(chunk, controller) {
389
- size += chunk.length;
390
- if (size > most) return controller.error(pastSize(most));
391
- hash.update(chunk);
392
- controller.enqueue(chunk);
393
- } });
420
+ const read = Stream.fromReadableStream({
421
+ evaluate: () => body ?? new ReadableStream({ start: (controller) => controller.close() }),
422
+ onError: (cause) => new Unavailable({
423
+ message: bucketFailed,
424
+ cause
425
+ })
426
+ });
394
427
  return {
395
- stream: (body ?? new ReadableStream({ start: (controller) => controller.close() })).pipeThrough(counting),
428
+ body: Stream.mapEffect(read, (chunk) => {
429
+ size += chunk.length;
430
+ if (size > most) return Effect.fail(pastSize(most));
431
+ return Effect.as(hasher.write(chunk), chunk);
432
+ }),
396
433
  past: () => size > most,
397
- sha256: () => hash.hex()
434
+ hasher
398
435
  };
399
436
  };
400
437
  /** Lists a Worker upload's bytes at their staging key, in the commit that drops its staging row. */
401
438
  const listStaged = /* @__PURE__ */ Effect.fnUntraced(function* (registered, caller, repo, staged) {
439
+ const writer = yield* ownWriter(caller);
402
440
  for (let tries = 0; tries < 5; tries += 1) {
441
+ const at = yield* Clock$1.currentTimeMillis;
442
+ const own = writer === void 0 ? [] : [uploadedRow(writer, staged.oid, at)];
403
443
  const read = yield* objectRows(registered, caller, repo, [staged.oid], [stagingRead(staged.staged)]);
404
- if (read.rows.get(staged.oid)?.listed !== void 0) return lfsAnswer(200, { message: staged.unseen ? "Uploaded" : "Already uploaded" });
444
+ if (read.rows.get(staged.oid)?.listed !== void 0) {
445
+ const answer = lfsAnswer(200, { message: staged.unseen ? "Uploaded" : "Already uploaded" });
446
+ if (own.length === 0) return answer;
447
+ if ((yield* registered.commit(repo.internalId, read.version, {
448
+ put: own,
449
+ wake: sweepDue(at)
450
+ })).ok) return answer;
451
+ continue;
452
+ }
405
453
  if ((read.also[0] ?? []).length === 0 || (yield* Clock$1.currentTimeMillis) > staged.deadline) return yield* fail("DEADLINE_EXCEEDED", "The upload ran too long", { hint: "Upload it again" });
406
454
  if ((yield* registered.commit(repo.internalId, read.version, {
407
455
  put: [{
@@ -410,11 +458,12 @@ const listStaged = /* @__PURE__ */ Effect.fnUntraced(function* (registered, call
410
458
  size: staged.size,
411
459
  key: staged.key
412
460
  }
413
- }],
414
- delete: [uploadKey(staged.oid), {
461
+ }, ...own],
462
+ delete: [uploadKey(staged.oid, read.uploader), {
415
463
  collection: lfsCollections.staging,
416
464
  id: staged.staged
417
- }]
465
+ }],
466
+ wake: sweepDue(at)
418
467
  })).ok) return lfsAnswer(200, { message: "Uploaded" });
419
468
  }
420
469
  return yield* contended();