@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
@@ -47,9 +47,11 @@ export declare const Actor: Schema.Union<readonly [Schema.Struct<{
47
47
  * has no `meta`, which was a snapshot of the sign-in at `queue.add`, and replaying it would decide
48
48
  * the publish on what held then.
49
49
  */
50
- export interface QueuedActor extends ActorId {
51
- readonly anonymous?: false;
52
- }
50
+ export declare const QueuedActor: Schema.Struct<{
51
+ readonly id: Schema.String;
52
+ readonly anonymous: Schema.optionalKey<Schema.Literal<false>>;
53
+ }>;
54
+ export type QueuedActor = typeof QueuedActor.Type;
53
55
  /**
54
56
  * Who a check is asked about. `at: 'queued'`: the merge queue's publish of an entry that waited,
55
57
  * asked again as the caller that added it, its actor named by ID alone, with no `meta`. Narrow on
@@ -63,9 +65,10 @@ export type Acting<Meta = unknown> = {
63
65
  readonly at: 'queued';
64
66
  readonly actor: QueuedActor;
65
67
  };
66
- export interface CallInput {
67
- readonly signal?: AbortSignal;
68
- }
68
+ export declare const CallInput: Schema.Struct<{
69
+ readonly signal: Schema.optionalKey<Schema.declare<AbortSignal, AbortSignal>>;
70
+ }>;
71
+ export type CallInput = typeof CallInput.Type;
69
72
  /** Every call names who it acts for, reads included, and `authorize` decides it. */
70
73
  export interface ActorInput<Meta = unknown> extends CallInput {
71
74
  readonly actor: Actor<Meta>;
@@ -81,26 +84,46 @@ export interface ActorInput<Meta = unknown> extends CallInput {
81
84
  * `INVALID_ARGUMENT`, `context.field` naming it.
82
85
  * `tokens.create`'s key is refused for the token's life instead, since its secret is shown once.
83
86
  * A resent fork key answers the fork as it is now, read as `repos.get` reads it for that caller,
84
- * while every other key answers as it first did.
87
+ * while every other key answers as it first did. An object write, such as `blobs.create` or
88
+ * `commits.create`, sent again once its repo is deleted answers `NOT_FOUND`, as any call on the
89
+ * repo does then: its answer reads objects the delete lets go of.
85
90
  */
86
91
  export interface WriteInput<Meta = unknown> extends ActorInput<Meta> {
87
92
  readonly key?: string;
88
93
  }
89
- export interface CredentialsBasic {
90
- readonly kind: 'basic';
91
- readonly username: string;
92
- readonly password: string;
93
- }
94
- export interface CredentialsBearer {
95
- readonly kind: 'bearer';
96
- readonly token: string;
97
- }
98
- export type Credentials = CredentialsBasic | CredentialsBearer;
99
- export interface AuthInput {
100
- readonly request: Request;
101
- readonly credentials?: Credentials;
102
- readonly signal: AbortSignal;
103
- }
94
+ export declare const CredentialsBasic: Schema.Struct<{
95
+ readonly kind: Schema.Literal<"basic">;
96
+ readonly username: Schema.String;
97
+ readonly password: Schema.String;
98
+ }>;
99
+ export type CredentialsBasic = typeof CredentialsBasic.Type;
100
+ export declare const CredentialsBearer: Schema.Struct<{
101
+ readonly kind: Schema.Literal<"bearer">;
102
+ readonly token: Schema.String;
103
+ }>;
104
+ export type CredentialsBearer = typeof CredentialsBearer.Type;
105
+ export declare const Credentials: Schema.Union<readonly [Schema.Struct<{
106
+ readonly kind: Schema.Literal<"basic">;
107
+ readonly username: Schema.String;
108
+ readonly password: Schema.String;
109
+ }>, Schema.Struct<{
110
+ readonly kind: Schema.Literal<"bearer">;
111
+ readonly token: Schema.String;
112
+ }>]>;
113
+ export type Credentials = typeof Credentials.Type;
114
+ export declare const AuthInput: Schema.Struct<{
115
+ readonly request: Schema.declare<Request, Request>;
116
+ readonly credentials: Schema.optionalKey<Schema.Union<readonly [Schema.Struct<{
117
+ readonly kind: Schema.Literal<"basic">;
118
+ readonly username: Schema.String;
119
+ readonly password: Schema.String;
120
+ }>, Schema.Struct<{
121
+ readonly kind: Schema.Literal<"bearer">;
122
+ readonly token: Schema.String;
123
+ }>]>>;
124
+ readonly signal: Schema.declare<AbortSignal, AbortSignal>;
125
+ }>;
126
+ export type AuthInput = typeof AuthInput.Type;
104
127
  /** Who is calling: `undefined` for a credential it doesn't know. */
105
128
  export type GitAuth<Meta = unknown> = (input: AuthInput) => Awaitable<Actor<Meta> | undefined>;
106
129
  /**
@@ -108,14 +131,16 @@ export type GitAuth<Meta = unknown> = (input: AuthInput) => Awaitable<Actor<Meta
108
131
  * never trusts it, so a caller built by hand with it is a plain caller. To keep a caller's grant,
109
132
  * such as a link or a queued entry does, read `Authorize.grantOf`.
110
133
  */
111
- export interface CallerGrant {
112
- readonly resolver: string;
113
- }
134
+ export declare const CallerGrant: Schema.Struct<{
135
+ readonly resolver: Schema.String;
136
+ }>;
137
+ export type CallerGrant = typeof CallerGrant.Type;
114
138
  /**
115
139
  * `subject`: whom the actor acts for. `token`: set when the credential is one of Git's tokens.
116
140
  * `grant`: set when an extension's grant resolver identified the caller, and absent for a token
117
141
  * or the host's `auth`. `at: 'queued'`: the merge queue publishing an entry as the caller that
118
- * added it, its token and grant identified again, its actor with no `meta`.
142
+ * added it, its token and grant identified again, its actor with no `meta`. Its Schema is
143
+ * `callers.ts`' `Caller`.
119
144
  */
120
145
  export interface Caller<Meta = unknown> {
121
146
  readonly actor: Actor<Meta>;
@@ -138,7 +163,8 @@ export type RepoAccess = typeof RepoAccess.Type;
138
163
  /**
139
164
  * `subject` and `token`: the caller's, as `Caller` has them. With `at: 'queued'`, the merge
140
165
  * queue's publish of an entry that waited, asked as the caller that added it, again: its actor
141
- * is its ID alone, with no `meta`, and its token is the one it added with, read again live.
166
+ * is its ID alone, with no `meta`, and its token is the one it added with, read again live. Its
167
+ * Schema is `callers.ts`' `AuthorizeInput`.
142
168
  */
143
169
  export type AuthorizeInput<Meta = unknown> = Acting<Meta> & {
144
170
  readonly subject?: ActorId;
@@ -167,7 +193,10 @@ export type AuthorizeInput<Meta = unknown> = Acting<Meta> & {
167
193
  * Decided 21 Nov by the coordinator.
168
194
  *
169
195
  * A `refs.private` operation, asked only of a server made with `access`, is accepted with the
170
- * caller's `RefAudience`: `accept({ read, publish })`. Any other is accepted with no value.
196
+ * caller's `RefAudience`: `accept({ read, publish })`. Any other is accepted with no value. One
197
+ * asked with no `repo` is an import's, before it makes the repo the operation names: decide it
198
+ * from the caller, the name and the patterns, as `repo.create`, and read no repo, as none is
199
+ * there yet. An importer who reads fewer than every pattern is refused the import.
171
200
  *
172
201
  * Decide about a repo by its `repo.internalId`, the repo the call then acts on. A name can move
173
202
  * between repos while you decide: swap two repos' names and back around one call, and a host that
@@ -1,3 +1,4 @@
1
+ import { AbortSignalValue } from "./opaque.mjs";
1
2
  import { PinnedRepo } from "./repos.mjs";
2
3
  import * as Schema from "effect/Schema";
3
4
  // src/contracts/actors.ts
@@ -20,5 +21,40 @@ const AnonymousActor = /* @__PURE__ */ Schema.Struct({
20
21
  });
21
22
  /** An `Actor` as JSON names one, its `meta` unread. */
22
23
  const Actor = /* @__PURE__ */ Schema.Union([NamedActor, AnonymousActor]);
23
- ({ ...PinnedRepo.fields }), Schema.Boolean;
24
- export { Actor, ActorId, AnonymousActor, NamedActor };
24
+ /**
25
+ * The actor of a merge queue's publish of an entry, asked again after it waited: its ID alone. It
26
+ * has no `meta`, which was a snapshot of the sign-in at `queue.add`, and replaying it would decide
27
+ * the publish on what held then.
28
+ */
29
+ const QueuedActor = /* @__PURE__ */ Schema.Struct({
30
+ ...ActorId.fields,
31
+ anonymous: Schema.optionalKey(Schema.Literal(false))
32
+ });
33
+ const CallInput = /* @__PURE__ */ Schema.Struct({ signal: Schema.optionalKey(AbortSignalValue) });
34
+ const CredentialsBasic = /* @__PURE__ */ Schema.Struct({
35
+ kind: Schema.Literal("basic"),
36
+ username: Schema.String,
37
+ password: Schema.String
38
+ });
39
+ const CredentialsBearer = /* @__PURE__ */ Schema.Struct({
40
+ kind: Schema.Literal("bearer"),
41
+ token: Schema.String
42
+ });
43
+ const Credentials = /* @__PURE__ */ Schema.Union([CredentialsBasic, CredentialsBearer]);
44
+ Schema.optionalKey(Credentials);
45
+ /**
46
+ * The extension's grant resolver that identified a caller, by its `name`, for reading only: Git
47
+ * never trusts it, so a caller built by hand with it is a plain caller. To keep a caller's grant,
48
+ * such as a link or a queued entry does, read `Authorize.grantOf`.
49
+ */
50
+ const CallerGrant = /* @__PURE__ */ Schema.Struct({ resolver: Schema.String });
51
+ /**
52
+ * The repo an operation names, when it exists: its name, its visibility and which repo it is
53
+ * underneath, all read in one snapshot. `internalId` stays with the repo across a rename, so a
54
+ * host that keys its grants by it decides about the repo the call then acts on.
55
+ */
56
+ const RepoAccess = /* @__PURE__ */ Schema.Struct({
57
+ ...PinnedRepo.fields,
58
+ public: Schema.Boolean
59
+ });
60
+ export { Actor, ActorId, AnonymousActor, CallInput, CallerGrant, Credentials, CredentialsBasic, CredentialsBearer, NamedActor, QueuedActor, RepoAccess };
@@ -4,11 +4,11 @@ import { GrantAgainRequest } from "./grants.mjs";
4
4
  import { InternalRepoId, RefName, RepoName } from "./ids.mjs";
5
5
  import { Operation } from "./operations.mjs";
6
6
  import { GitError } from "./result.mjs";
7
- import { TokenScope } from "./tokens.mjs";
7
+ import { GrantScope } from "./tokens.mjs";
8
8
  import * as Effect from "effect/Effect";
9
9
  import * as Context from "effect/Context";
10
10
  declare namespace authorize_d_exports {
11
- export { Authorize, AuthorizeRequest, CeilingInput, audience, ceiling, check, grantAgain, grantOf };
11
+ export { AudienceInput, Authorize, AuthorizeRequest, CeilingInput, audience, ceiling, check, grantAgain, grantOf };
12
12
  }
13
13
  /** What `check` is asked: who acts, what they do, and the repo it names, when it names one. */
14
14
  export interface AuthorizeRequest {
@@ -27,21 +27,31 @@ export interface CeilingInput {
27
27
  readonly repo: RepoName;
28
28
  readonly internalId?: InternalRepoId;
29
29
  }
30
+ /**
31
+ * What `audience` is asked: who acts and the private patterns, about `repo`, a repo that exists,
32
+ * or `creating`, the name of one an import is about to make, which no repo has yet.
33
+ */
34
+ export type AudienceInput = {
35
+ readonly caller: Caller;
36
+ readonly patterns: readonly RefName[];
37
+ } & ({
38
+ readonly repo: RepoAccess;
39
+ readonly creating?: never;
40
+ } | {
41
+ readonly creating: RepoName;
42
+ readonly repo?: never;
43
+ });
30
44
  declare const Authorize_base: Context.ServiceClass<Authorize, "@ref0/git/Authorize", {
31
45
  /** Nothing when `request.caller` may do `request.operation`, else the refusal. */
32
46
  readonly check: (request: AuthorizeRequest) => Effect.Effect<void, GitError>;
33
47
  /** `refs.private`'s answer for `patterns`, for a server with `access`. */
34
- readonly audience: (input: {
35
- readonly caller: Caller;
36
- readonly repo: RepoAccess;
37
- readonly patterns: readonly RefName[];
38
- }) => Effect.Effect<RefAudience, GitError>;
48
+ readonly audience: (input: AudienceInput) => Effect.Effect<RefAudience, GitError>;
39
49
  /**
40
50
  * Git's own ceiling on `caller` for `repo`: its token's scope when the token covers the repo,
41
- * its grant's when the grant reaches it, `undefined` when either doesn't, and `'write'` for a
42
- * caller with neither.
51
+ * its grant's when the grant reaches it, `undefined` when either doesn't, and `'write'` for an
52
+ * `admin` token or a caller with neither.
43
53
  */
44
- readonly ceiling: (input: CeilingInput) => Effect.Effect<TokenScope | undefined, GitError>;
54
+ readonly ceiling: (input: CeilingInput) => Effect.Effect<GrantScope | undefined, GitError>;
45
55
  /** The resolver and grant that gave `caller`, if a grant did. */
46
56
  readonly grantOf: (caller: Caller) => {
47
57
  readonly resolver: string;
@@ -64,11 +74,7 @@ declare const Authorize_base: Context.ServiceClass<Authorize, "@ref0/git/Authori
64
74
  */
65
75
  export declare class Authorize extends /* @__PURE__ */ Authorize_base {}
66
76
  export declare const check: (request: AuthorizeRequest) => Effect.Effect<void, GitError, Authorize>;
67
- export declare const audience: (input: {
68
- readonly caller: Caller;
69
- readonly repo: RepoAccess;
70
- readonly patterns: readonly RefName[];
71
- }) => Effect.Effect<{
77
+ export declare const audience: (input: AudienceInput) => Effect.Effect<{
72
78
  readonly read?: readonly string[];
73
79
  readonly publish?: readonly string[];
74
80
  }, GitError, Authorize>;
@@ -0,0 +1,40 @@
1
+ import { Actor, ActorId, CallInput, CallerGrant, QueuedActor, RepoAccess } from "./actors.mjs";
2
+ import "./opaque.mjs";
3
+ import "./operations.mjs";
4
+ import { TokenInfo } from "./tokens.mjs";
5
+ import * as Schema from "effect/Schema";
6
+ // src/contracts/callers.ts
7
+ /** An `Acting`: by the caller, or queued. */
8
+ const Acting = /* @__PURE__ */ Schema.Union([Schema.Struct({
9
+ at: Schema.optionalKey(Schema.Never),
10
+ actor: Actor
11
+ }), Schema.Struct({
12
+ at: Schema.Literal("queued"),
13
+ actor: QueuedActor
14
+ })]);
15
+ const ActorInput = /* @__PURE__ */ Schema.Struct({
16
+ ...CallInput.fields,
17
+ actor: Actor
18
+ });
19
+ ({ ...ActorInput.fields }), Schema.optionalKey(Schema.String);
20
+ /** A `Caller` as Git identified it. */
21
+ const Caller = /* @__PURE__ */ Schema.Struct({
22
+ actor: Actor,
23
+ subject: Schema.optionalKey(ActorId),
24
+ token: Schema.optionalKey(TokenInfo),
25
+ grant: Schema.optionalKey(CallerGrant),
26
+ at: Schema.optionalKey(Schema.Literal("queued"))
27
+ });
28
+ Schema.optionalKey(ActorId), Schema.optionalKey(TokenInfo), Schema.optionalKey(RepoAccess);
29
+ /**
30
+ * The Schema of a shape typed `Acting & { …fields }`: each arm of `Acting` with `fields`, so a
31
+ * queued arm's actor is read as `QueuedActor`'s.
32
+ */
33
+ const actingWith = (fields) => Schema.Union([Schema.Struct({
34
+ ...Acting.members[0].fields,
35
+ ...fields
36
+ }), Schema.Struct({
37
+ ...Acting.members[1].fields,
38
+ ...fields
39
+ })]);
40
+ export { Acting, ActorInput, Caller, actingWith };
@@ -1,14 +1,14 @@
1
- import { CallInput } from "./actors.mjs";
2
1
  import { BlobCalls } from "./blobs.mjs";
3
2
  import { CommitCalls } from "./commits.mjs";
4
- import { Filter } from "./object-values.mjs";
5
3
  import { FileCalls } from "./files.mjs";
6
4
  import { Oid, RefName, RepoName } from "./ids.mjs";
5
+ import { Filter } from "./object-values.mjs";
7
6
  import { MergeCalls } from "./merges.mjs";
8
7
  import { ObjectsFactory } from "./objects.mjs";
9
8
  import { Ref, RefApplied, RefCalls, RefEdit, RefRejected, RefsUpdated } from "./refs.mjs";
10
- import { RemoteOptions, WithoutActor } from "./remote.mjs";
9
+ import { RemoteOptions, WithoutActor, WithoutSignal } from "./remote.mjs";
11
10
  import { Result } from "./result.mjs";
11
+ import { EffectCalls } from "./services.mjs";
12
12
  import { TagCalls } from "./tags.mjs";
13
13
  import { TreeCalls } from "./trees.mjs";
14
14
  import { Listing, Page, Records } from "@ref0/infra";
@@ -28,7 +28,7 @@ export interface GitClientOptions extends RemoteOptions {
28
28
  readonly adapter?: ClientAdapter;
29
29
  readonly objects?: ObjectsFactory<false>;
30
30
  }
31
- export interface RemoteRefsInput extends CallInput {
31
+ export interface RemoteRefsInput {
32
32
  /** Only refs whose full name starts with it, such as `refs/heads/`. */
33
33
  readonly prefix?: string;
34
34
  readonly page?: Page;
@@ -39,7 +39,7 @@ export interface RemoteRefsInput extends CallInput {
39
39
  * partial fetch, such as `{ kind: 'blob:none' }`. `force`: move a local ref that holds commits
40
40
  * the remote's tip doesn't to that tip anyway, as `git fetch --force` does.
41
41
  */
42
- export interface ClientFetchInput extends CallInput {
42
+ export interface ClientFetchInput {
43
43
  readonly refs?: readonly RefName[];
44
44
  readonly depth?: number;
45
45
  readonly filter?: Filter;
@@ -63,14 +63,15 @@ export interface ClientFetchResult {
63
63
  readonly updates: readonly (RefApplied | RefForced | RefRejected)[];
64
64
  }
65
65
  /** `from` is the remote's tip as last seen; `atomic`: all move or none, where the remote can. */
66
- export interface ClientPushInput extends CallInput {
66
+ export interface ClientPushInput {
67
67
  readonly updates: readonly RefEdit[];
68
68
  readonly atomic?: boolean;
69
69
  readonly pushOptions?: readonly string[];
70
70
  }
71
- /** A server's call group as a client makes it: no repo, and no actor. */
72
- export type Localize<Calls> = { readonly [Key in keyof Calls]: Calls[Key] extends ((repo: RepoName, input: infer Input) => infer Answer) ? (input: WithoutActor<Input>) => Answer : never; };
73
- export interface GitClient {
71
+ /** A server's call group as a client makes it: no repo, no actor, and no `signal`. */
72
+ export type Localize<Calls> = { readonly [Key in keyof Calls]: Calls[Key] extends ((repo: RepoName, input: infer Input) => infer Answer) ? (input: WithoutSignal<WithoutActor<Input>>) => Answer : never; };
73
+ /** A client's calls as their Promise twins describe them: `GitClientCalls` is their Effect face. */
74
+ export interface GitClientPromises {
74
75
  readonly remoteRefs: (input?: RemoteRefsInput) => Promise<Result<Listing<Ref>>>;
75
76
  readonly fetch: (input?: ClientFetchInput) => Promise<Result<ClientFetchResult>>;
76
77
  readonly push: (input: ClientPushInput) => Promise<Result<RefsUpdated>>;
@@ -82,6 +83,12 @@ export interface GitClient {
82
83
  readonly files: Localize<FileCalls>;
83
84
  readonly merges: Localize<MergeCalls>;
84
85
  }
86
+ /**
87
+ * A client of one remote, as `GitClient.make` gives it: `remoteRefs`, `fetch` and `push` on the
88
+ * remote, and the server's calls on its own storage, with no repo. Each call is an Effect that
89
+ * fails with the call's `GitError`.
90
+ */
91
+ export type GitClientCalls = EffectCalls<GitClientPromises>;
85
92
  /** A list call's input: the page it starts from. */
86
93
  export interface PagedInput {
87
94
  readonly page?: Page;
@@ -247,11 +247,12 @@ export type BeforeAfter = typeof BeforeAfter.Type;
247
247
  * Why a geometric merge left a pack out. A fenced pack is left as it is: it stays listed, its
248
248
  * objects read, clone and fetch as before, and nothing is lost. Upkeep never merges it again on its
249
249
  * own while it stays listed, and no prune pass rewrites it, since a pass reads its classes over the
250
- * packs out of the fence and keeps a fenced pack whole. So each reason names what the host can do:
250
+ * packs out of the fence and keeps a fenced pack whole. A fence for calls lifts on its own once a
251
+ * fresh try has more than the one that fenced it. So each reason names what the host can do:
251
252
  * - `open-past-try`: opening a merge of it alone, its choose, its quarantine and its walk's first
252
253
  * reads, takes more calls than a fresh merge try has, about 1.84M objects at R2's charges, fenced
253
- * before the merge reads anything. Raise the host's `callLimits`; a later merge takes the pack
254
- * only once it leaves the listing.
254
+ * before the merge reads anything. Raise the host's `callLimits`, and the next step merges the
255
+ * pack again; one still past the try is fenced again at its calls.
255
256
  * - `entry-past-try`: one of its entries takes more calls to resolve than a merge try has. As for
256
257
  * `open-past-try`.
257
258
  * - `resolve-past-try`: its longest delta chain could take more calls to resolve than a fresh
@@ -259,8 +260,9 @@ export type BeforeAfter = typeof BeforeAfter.Type;
259
260
  * `open-past-try`.
260
261
  * - `graph-length`: its `.graph` reads past the bytes its pack row records, or ends short of them.
261
262
  * - `graph-broken`: its `.graph` is missing or broken, or counts a commit past 4,096 parents, which
262
- * every write refuses. Nothing rebuilds a pack's `.graph` yet: for either `.graph` reason, the
263
- * pack keeps its file as it is.
263
+ * every write refuses. For either `.graph` reason, the next upkeep steps rebuild the file from the
264
+ * pack's commits, a part each step, and then the pack merges again. One whose commits can't be
265
+ * read stays fenced, and no step rebuilds it again.
264
266
  * - `packs-past-most`: the merge would write more than `mergePacksMost` packs, about 418, and this
265
267
  * pack held the step that reached them. A prune that keeps deltas whose bases it drops writes them
266
268
  * whole, so each pack fills a try's calls after a few dozen. The host can do nothing for it yet:
@@ -589,7 +591,7 @@ export declare const TokenEventFields: Schema.Struct<{
589
591
  }>>;
590
592
  readonly type: Schema.Literals<readonly ["token.created", "token.revoked"]>;
591
593
  readonly token: Schema.String;
592
- readonly scope: Schema.Literals<readonly ["read", "report", "write"]>;
594
+ readonly scope: Schema.Literals<readonly ["read", "report", "write", "admin"]>;
593
595
  readonly subject: Schema.Struct<{
594
596
  readonly id: Schema.String;
595
597
  }>;
@@ -604,7 +606,7 @@ export declare const RepoTokenEvent: Schema.Struct<{
604
606
  }>>;
605
607
  readonly type: Schema.Literals<readonly ["token.created", "token.revoked"]>;
606
608
  readonly token: Schema.String;
607
- readonly scope: Schema.Literals<readonly ["read", "report", "write"]>;
609
+ readonly scope: Schema.Literals<readonly ["read", "report", "write", "admin"]>;
608
610
  readonly subject: Schema.Struct<{
609
611
  readonly id: Schema.String;
610
612
  }>;
@@ -622,7 +624,7 @@ export declare const TokenEvent: Schema.Union<readonly [Schema.Struct<{
622
624
  }>>;
623
625
  readonly type: Schema.Literals<readonly ["token.created", "token.revoked"]>;
624
626
  readonly token: Schema.String;
625
- readonly scope: Schema.Literals<readonly ["read", "report", "write"]>;
627
+ readonly scope: Schema.Literals<readonly ["read", "report", "write", "admin"]>;
626
628
  readonly subject: Schema.Struct<{
627
629
  readonly id: Schema.String;
628
630
  }>;
@@ -637,7 +639,7 @@ export declare const TokenEvent: Schema.Union<readonly [Schema.Struct<{
637
639
  }>>;
638
640
  readonly type: Schema.Literals<readonly ["token.created", "token.revoked"]>;
639
641
  readonly token: Schema.String;
640
- readonly scope: Schema.Literals<readonly ["read", "report", "write"]>;
642
+ readonly scope: Schema.Literals<readonly ["read", "report", "write", "admin"]>;
641
643
  readonly subject: Schema.Struct<{
642
644
  readonly id: Schema.String;
643
645
  }>;
@@ -685,7 +687,7 @@ export declare const EntryMerged: Schema.Struct<{
685
687
  readonly commit: Schema.String;
686
688
  }>;
687
689
  export type EntryMerged = typeof EntryMerged.Type;
688
- /** `error`: for `host-error`, the failure's ID, which `onError` got too. */
690
+ /** `error`: for `host-error`, the failure's ID, which the host's log line names too. */
689
691
  export declare const EntryFailed: Schema.Struct<{
690
692
  readonly seq: Schema.Int;
691
693
  readonly at: Schema.Number;
@@ -190,11 +190,12 @@ const BeforeAfter = /* @__PURE__ */ Schema.Struct({
190
190
  * Why a geometric merge left a pack out. A fenced pack is left as it is: it stays listed, its
191
191
  * objects read, clone and fetch as before, and nothing is lost. Upkeep never merges it again on its
192
192
  * own while it stays listed, and no prune pass rewrites it, since a pass reads its classes over the
193
- * packs out of the fence and keeps a fenced pack whole. So each reason names what the host can do:
193
+ * packs out of the fence and keeps a fenced pack whole. A fence for calls lifts on its own once a
194
+ * fresh try has more than the one that fenced it. So each reason names what the host can do:
194
195
  * - `open-past-try`: opening a merge of it alone, its choose, its quarantine and its walk's first
195
196
  * reads, takes more calls than a fresh merge try has, about 1.84M objects at R2's charges, fenced
196
- * before the merge reads anything. Raise the host's `callLimits`; a later merge takes the pack
197
- * only once it leaves the listing.
197
+ * before the merge reads anything. Raise the host's `callLimits`, and the next step merges the
198
+ * pack again; one still past the try is fenced again at its calls.
198
199
  * - `entry-past-try`: one of its entries takes more calls to resolve than a merge try has. As for
199
200
  * `open-past-try`.
200
201
  * - `resolve-past-try`: its longest delta chain could take more calls to resolve than a fresh
@@ -202,8 +203,9 @@ const BeforeAfter = /* @__PURE__ */ Schema.Struct({
202
203
  * `open-past-try`.
203
204
  * - `graph-length`: its `.graph` reads past the bytes its pack row records, or ends short of them.
204
205
  * - `graph-broken`: its `.graph` is missing or broken, or counts a commit past 4,096 parents, which
205
- * every write refuses. Nothing rebuilds a pack's `.graph` yet: for either `.graph` reason, the
206
- * pack keeps its file as it is.
206
+ * every write refuses. For either `.graph` reason, the next upkeep steps rebuild the file from the
207
+ * pack's commits, a part each step, and then the pack merges again. One whose commits can't be
208
+ * read stays fenced, and no step rebuilds it again.
207
209
  * - `packs-past-most`: the merge would write more than `mergePacksMost` packs, about 418, and this
208
210
  * pack held the step that reached them. A prune that keeps deltas whose bases it drops writes them
209
211
  * whole, so each pack fills a try's calls after a few dozen. The host can do nothing for it yet:
@@ -314,7 +316,7 @@ const EntryMerged = /* @__PURE__ */ Schema.Struct({
314
316
  candidate: CandidateId,
315
317
  commit: Oid
316
318
  });
317
- /** `error`: for `host-error`, the failure's ID, which `onError` got too. */
319
+ /** `error`: for `host-error`, the failure's ID, which the host's log line names too. */
318
320
  const EntryFailed = /* @__PURE__ */ Schema.Struct({
319
321
  ...RepoEnvelope.fields,
320
322
  summary: ReportDetails.fields.summary,
@@ -60,11 +60,11 @@ export type FilesList = typeof FilesList.Type;
60
60
  export interface FilesListInput extends ReadPage, FilesList {}
61
61
  /** A diff's files, only those at or under `paths` when given, as a patch or as hunks. */
62
62
  export declare const FilesDiff: Schema.Struct<{
63
- readonly paths: Schema.optionalKey<Schema.$Array<Schema.String>>;
64
- readonly format: Schema.optionalKey<Schema.Literals<readonly ["patch", "hunks"]>>;
65
63
  readonly base: Schema.String;
66
64
  readonly head: Schema.String;
67
65
  readonly renames: Schema.optionalKey<Schema.Boolean>;
66
+ readonly paths: Schema.optionalKey<Schema.$Array<Schema.String>>;
67
+ readonly format: Schema.optionalKey<Schema.Literals<readonly ["patch", "hunks"]>>;
68
68
  }>;
69
69
  export type FilesDiff = typeof FilesDiff.Type;
70
70
  export interface FilesDiffInput extends ReadPage, FilesDiff {}
@@ -97,7 +97,6 @@ export type Hunk = typeof Hunk.Type;
97
97
  * decodes with replacements.
98
98
  */
99
99
  export declare const FileDiff: Schema.Union<readonly [Schema.Struct<{
100
- readonly patch: Schema.String;
101
100
  readonly status: Schema.Literals<readonly ["A", "D", "M", "R", "T"]>;
102
101
  readonly path: Schema.String;
103
102
  readonly from: Schema.optionalKey<Schema.String>;
@@ -116,20 +115,8 @@ export declare const FileDiff: Schema.Union<readonly [Schema.Struct<{
116
115
  readonly added: Schema.Int;
117
116
  readonly deleted: Schema.Int;
118
117
  }>, Schema.Literal<"binary">]>;
118
+ readonly patch: Schema.String;
119
119
  }>, Schema.Struct<{
120
- readonly hunks: Schema.$Array<Schema.Struct<{
121
- readonly oldStart: Schema.Int;
122
- readonly oldLines: Schema.Int;
123
- readonly newStart: Schema.Int;
124
- readonly newLines: Schema.Int;
125
- /** The hunk header's function context, after `@@ ... @@ `: empty when there's none. */
126
- readonly context: Schema.String;
127
- readonly lines: Schema.$Array<Schema.Struct<{
128
- readonly kind: Schema.Literals<readonly ["context", "add", "delete"]>;
129
- readonly text: Schema.String;
130
- readonly noNewline: Schema.optionalKey<Schema.Literal<true>>;
131
- }>>;
132
- }>>;
133
120
  readonly status: Schema.Literals<readonly ["A", "D", "M", "R", "T"]>;
134
121
  readonly path: Schema.String;
135
122
  readonly from: Schema.optionalKey<Schema.String>;
@@ -148,6 +135,19 @@ export declare const FileDiff: Schema.Union<readonly [Schema.Struct<{
148
135
  readonly added: Schema.Int;
149
136
  readonly deleted: Schema.Int;
150
137
  }>, Schema.Literal<"binary">]>;
138
+ readonly hunks: Schema.$Array<Schema.Struct<{
139
+ readonly oldStart: Schema.Int;
140
+ readonly oldLines: Schema.Int;
141
+ readonly newStart: Schema.Int;
142
+ readonly newLines: Schema.Int;
143
+ /** The hunk header's function context, after `@@ ... @@ `: empty when there's none. */
144
+ readonly context: Schema.String;
145
+ readonly lines: Schema.$Array<Schema.Struct<{
146
+ readonly kind: Schema.Literals<readonly ["context", "add", "delete"]>;
147
+ readonly text: Schema.String;
148
+ readonly noNewline: Schema.optionalKey<Schema.Literal<true>>;
149
+ }>>;
150
+ }>>;
151
151
  }>]>;
152
152
  export type FileDiff = typeof FileDiff.Type;
153
153
  export interface FileCalls {
@@ -186,7 +186,6 @@ declare const Files_base: Context.ServiceClass<Files, "@ref0/git/Files", EffectC
186
186
  readonly pathBytes?: Uint8Array<ArrayBufferLike>;
187
187
  }>>>;
188
188
  readonly diff: (repo: string, input: Acting<FilesDiffInput>, by?: Caller<unknown> | undefined) => Promise<Result<DiffListing<{
189
- readonly patch: string;
190
189
  readonly status: "A" | "D" | "M" | "R" | "T";
191
190
  readonly path: string;
192
191
  readonly from?: string;
@@ -205,19 +204,8 @@ declare const Files_base: Context.ServiceClass<Files, "@ref0/git/Files", EffectC
205
204
  readonly added: number;
206
205
  readonly deleted: number;
207
206
  };
207
+ readonly patch: string;
208
208
  } | {
209
- readonly hunks: readonly {
210
- readonly oldStart: number;
211
- readonly oldLines: number;
212
- readonly newStart: number;
213
- readonly newLines: number;
214
- readonly context: string;
215
- readonly lines: readonly {
216
- readonly kind: "add" | "context" | "delete";
217
- readonly text: string;
218
- readonly noNewline?: true;
219
- }[];
220
- }[];
221
209
  readonly status: "A" | "D" | "M" | "R" | "T";
222
210
  readonly path: string;
223
211
  readonly from?: string;
@@ -236,6 +224,18 @@ declare const Files_base: Context.ServiceClass<Files, "@ref0/git/Files", EffectC
236
224
  readonly added: number;
237
225
  readonly deleted: number;
238
226
  };
227
+ readonly hunks: readonly {
228
+ readonly oldStart: number;
229
+ readonly oldLines: number;
230
+ readonly newStart: number;
231
+ readonly newLines: number;
232
+ readonly context: string;
233
+ readonly lines: readonly {
234
+ readonly kind: "add" | "context" | "delete";
235
+ readonly text: string;
236
+ readonly noNewline?: true;
237
+ }[];
238
+ }[];
239
239
  }>>>;
240
240
  }, never>>;
241
241
  /**
@@ -266,7 +266,6 @@ export declare const list: (repo: RepoName, input: Acting<FilesListInput>, by?:
266
266
  readonly pathBytes?: Uint8Array<ArrayBufferLike>;
267
267
  }>, GitError, Files>;
268
268
  export declare const diff: (repo: RepoName, input: Acting<FilesDiffInput>, by?: Caller) => Effect.Effect<DiffListing<{
269
- readonly patch: string;
270
269
  readonly status: "A" | "D" | "M" | "R" | "T";
271
270
  readonly path: string;
272
271
  readonly from?: string;
@@ -285,19 +284,8 @@ export declare const diff: (repo: RepoName, input: Acting<FilesDiffInput>, by?:
285
284
  readonly added: number;
286
285
  readonly deleted: number;
287
286
  };
287
+ readonly patch: string;
288
288
  } | {
289
- readonly hunks: readonly {
290
- readonly oldStart: number;
291
- readonly oldLines: number;
292
- readonly newStart: number;
293
- readonly newLines: number;
294
- readonly context: string;
295
- readonly lines: readonly {
296
- readonly kind: "add" | "context" | "delete";
297
- readonly text: string;
298
- readonly noNewline?: true;
299
- }[];
300
- }[];
301
289
  readonly status: "A" | "D" | "M" | "R" | "T";
302
290
  readonly path: string;
303
291
  readonly from?: string;
@@ -316,5 +304,17 @@ export declare const diff: (repo: RepoName, input: Acting<FilesDiffInput>, by?:
316
304
  readonly added: number;
317
305
  readonly deleted: number;
318
306
  };
307
+ readonly hunks: readonly {
308
+ readonly oldStart: number;
309
+ readonly oldLines: number;
310
+ readonly newStart: number;
311
+ readonly newLines: number;
312
+ readonly context: string;
313
+ readonly lines: readonly {
314
+ readonly kind: "add" | "context" | "delete";
315
+ readonly text: string;
316
+ readonly noNewline?: true;
317
+ }[];
318
+ }[];
319
319
  }>, GitError, Files>;
320
320
  export { files_d_exports };