@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
@@ -0,0 +1,209 @@
1
+ import { RefName, RepoName, TopicId } from "./ids.mjs";
2
+ import { CandidateId, EntryFields, EntryId, HoldId } from "./queue.mjs";
3
+ import { RefEdit, RefSource } from "./refs.mjs";
4
+ import { ActorId } from "./actors.mjs";
5
+ import { TokenCoverage, TokenScope } from "./tokens.mjs";
6
+ import * as Schema from "effect/Schema";
7
+ import { JobRef } from "@ref0/infra";
8
+ // src/contracts/operations.ts
9
+ /** What `authorize` is asked about. */
10
+ const RepoOperation = /* @__PURE__ */ Schema.Struct({
11
+ kind: Schema.Literals([
12
+ "fetch",
13
+ "read",
14
+ "object.create",
15
+ "repo.create",
16
+ "repo.update",
17
+ "repo.delete"
18
+ ]),
19
+ repo: RepoName
20
+ });
21
+ /**
22
+ * Anything that moves a ref. At advertisement, `updates` is empty. Each edit has no kind yet:
23
+ * whether a move is a fast-forward needs the pack, received after. The rules get the kind.
24
+ */
25
+ const PushOperation = /* @__PURE__ */ Schema.Struct({
26
+ kind: Schema.Literal("push"),
27
+ repo: RepoName,
28
+ updates: Schema.Array(RefEdit)
29
+ });
30
+ /**
31
+ * A push with `-o allow-files` that adds or changes `paths` on `ref`, each a file a `Rules.files`
32
+ * rule there refuses: accepted, it lets them through, and the ref's `ref.updated` records them.
33
+ * At most 100 paths, the first refused first.
34
+ */
35
+ const FilesAllowOperation = /* @__PURE__ */ Schema.Struct({
36
+ kind: Schema.Literal("files.allow"),
37
+ repo: RepoName,
38
+ ref: RefName,
39
+ paths: Schema.Array(Schema.String)
40
+ });
41
+ /**
42
+ * A change to `ref` that a `Rules.protect` rule (`protect.bypass`) or a `Rules.lock` rule
43
+ * (`lock.bypass`) there refuses, asked only once the rule would refuse it: accepted, it lifts that
44
+ * rule for this change, and the ref's `ref.updated` records the rule in `bypassed`. `move` is what
45
+ * the rule refuses, never a create, and `source` how the change came, which a rule's `sources`
46
+ * turn on. Git's own `authorize` and the starter's refuse it, for everyone.
47
+ */
48
+ const BypassOperation = /* @__PURE__ */ Schema.Struct({
49
+ kind: Schema.Literals(["protect.bypass", "lock.bypass"]),
50
+ repo: RepoName,
51
+ ref: RefName,
52
+ move: Schema.Literals([
53
+ "fast-forward",
54
+ "force",
55
+ "delete"
56
+ ]),
57
+ source: RefSource
58
+ });
59
+ /**
60
+ * A list of repos under `prefix`. An anonymous caller asks it for the public repos alone, which
61
+ * are all its list reads, so accepting it shows no private name.
62
+ */
63
+ const RepoListOperation = /* @__PURE__ */ Schema.Struct({
64
+ kind: Schema.Literal("repo.list"),
65
+ prefix: Schema.optionalKey(Schema.String)
66
+ });
67
+ const ForkOperation = /* @__PURE__ */ Schema.Struct({
68
+ kind: Schema.Literals(["fork.create", "fork.sync"]),
69
+ repo: RepoName,
70
+ holder: Schema.String
71
+ });
72
+ /**
73
+ * A new token's parties: `subject`, whom it's for and its caller once it's used, and `actor`, who
74
+ * acts for them, named only when it's someone else.
75
+ */
76
+ const TokenParties = /* @__PURE__ */ Schema.Struct({
77
+ subject: ActorId,
78
+ actor: Schema.optionalKey(ActorId)
79
+ });
80
+ /** `TokenCoverage`'s members, one repo or a prefix, which each token operation is over. */
81
+ const [overRepo, overPrefix] = TokenCoverage.members;
82
+ /** A create names the new token's parties and its `scope`, so a host decides who may mint an `admin` token. */
83
+ const tokenCreate = {
84
+ kind: Schema.Literal("token.create"),
85
+ ...TokenParties.fields,
86
+ scope: TokenScope
87
+ };
88
+ const TokenCreateOperation = /* @__PURE__ */ Schema.Union([Schema.Struct({
89
+ ...tokenCreate,
90
+ ...overRepo.fields
91
+ }), Schema.Struct({
92
+ ...tokenCreate,
93
+ ...overPrefix.fields
94
+ })]);
95
+ /**
96
+ * A revoke of one token, by ID, asked of what it covers. `subject` is whom the token is for, read
97
+ * from its stored record before `authorize` is asked, never from the call: so a host may let a
98
+ * person revoke their own token where it lets no one list the tokens beside it.
99
+ */
100
+ const tokenRevoke = {
101
+ kind: Schema.Literal("token.revoke"),
102
+ subject: ActorId
103
+ };
104
+ const TokenRevokeOperation = /* @__PURE__ */ Schema.Union([Schema.Struct({
105
+ ...tokenRevoke,
106
+ ...overRepo.fields
107
+ }), Schema.Struct({
108
+ ...tokenRevoke,
109
+ ...overPrefix.fields
110
+ })]);
111
+ const TokenOperation = /* @__PURE__ */ Schema.Union([
112
+ TokenCreateOperation,
113
+ TokenRevokeOperation,
114
+ Schema.Struct({
115
+ kind: Schema.Literal("token.list"),
116
+ ...overRepo.fields
117
+ }),
118
+ Schema.Struct({
119
+ kind: Schema.Literal("token.list"),
120
+ ...overPrefix.fields
121
+ })
122
+ ]);
123
+ const QueueAddOperation = /* @__PURE__ */ Schema.Struct({
124
+ kind: Schema.Literal("queue.add"),
125
+ repo: RepoName,
126
+ entry: EntryFields
127
+ });
128
+ /** A hold on `target`, or on `entry` there, and a restart of `target`. */
129
+ const QueueTargetOperation = /* @__PURE__ */ Schema.Struct({
130
+ kind: Schema.Literals(["queue.hold", "queue.restart"]),
131
+ repo: RepoName,
132
+ target: RefName,
133
+ entry: Schema.optionalKey(EntryId)
134
+ });
135
+ const QueueEntryOperation = /* @__PURE__ */ Schema.Struct({
136
+ kind: Schema.Literal("queue.remove"),
137
+ repo: RepoName,
138
+ entry: EntryId
139
+ });
140
+ const QueueCandidateOperation = /* @__PURE__ */ Schema.Struct({
141
+ kind: Schema.Literals(["queue.report", "queue.retry"]),
142
+ repo: RepoName,
143
+ candidate: CandidateId
144
+ });
145
+ const QueueReleaseOperation = /* @__PURE__ */ Schema.Struct({
146
+ kind: Schema.Literal("queue.release"),
147
+ repo: RepoName,
148
+ hold: HoldId
149
+ });
150
+ /** A topic's add, removal, report or read; `topic` is left out for an add and a list. */
151
+ const TopicOperation = /* @__PURE__ */ Schema.Struct({
152
+ kind: Schema.Literals([
153
+ "topic.add",
154
+ "topic.remove",
155
+ "topic.report",
156
+ "topic.read"
157
+ ]),
158
+ topic: Schema.optionalKey(TopicId)
159
+ });
160
+ /**
161
+ * Which of a repo's private ref patterns the caller reads and publishes, asked once per caller and
162
+ * repo in a request, never once per ref, when the server was made with `access`. `patterns` is
163
+ * every pattern `privateRefs` was given, as written. Accept with `{ read, publish }`, each a list
164
+ * of those patterns: `read` the patterns whose refs the caller sees, `publish` those whose commits
165
+ * the caller may make reachable from a ref more people see. An answer with neither, `accept()`
166
+ * with no value, or a refusal, sees no private ref and publishes nothing. An import asks it once
167
+ * more before it makes the repo, with no `AuthorizeInput.repo`, as `repo.create` asks.
168
+ */
169
+ const RefsPrivateOperation = /* @__PURE__ */ Schema.Struct({
170
+ kind: Schema.Literal("refs.private"),
171
+ repo: RepoName,
172
+ patterns: Schema.Array(RefName)
173
+ });
174
+ /**
175
+ * `GET <base>/me`: who the caller is, asked with the caller alone before Git shows them their own
176
+ * IDs. A host refuses it to a credential it no longer honours, such as a token whose person has
177
+ * left the org it's over, so a refused token learns nothing at `/me` either.
178
+ */
179
+ const MeOperation = /* @__PURE__ */ Schema.Struct({ kind: Schema.Literal("me") });
180
+ /** A repo's work, or one job of it: `name` and `key` its `JobRef`'s, each left out to mean any. */
181
+ const WorkOperation = /* @__PURE__ */ Schema.Struct({
182
+ kind: Schema.Literals([
183
+ "work.list",
184
+ "work.retry",
185
+ "work.discard"
186
+ ]),
187
+ repo: RepoName,
188
+ name: Schema.optionalKey(JobRef.fields.name),
189
+ key: Schema.optionalKey(JobRef.fields.key)
190
+ });
191
+ const Operation = /* @__PURE__ */ Schema.Union([
192
+ RepoOperation,
193
+ PushOperation,
194
+ FilesAllowOperation,
195
+ BypassOperation,
196
+ RepoListOperation,
197
+ ForkOperation,
198
+ TokenOperation,
199
+ QueueAddOperation,
200
+ QueueTargetOperation,
201
+ QueueEntryOperation,
202
+ QueueCandidateOperation,
203
+ QueueReleaseOperation,
204
+ TopicOperation,
205
+ WorkOperation,
206
+ RefsPrivateOperation,
207
+ MeOperation
208
+ ]);
209
+ export { BypassOperation, FilesAllowOperation, ForkOperation, MeOperation, Operation, PushOperation, QueueAddOperation, QueueCandidateOperation, QueueEntryOperation, QueueReleaseOperation, QueueTargetOperation, RefsPrivateOperation, RepoListOperation, RepoOperation, TokenCreateOperation, TokenOperation, TokenParties, TokenRevokeOperation, TopicOperation, WorkOperation };
@@ -361,7 +361,7 @@ export declare const LanesInput: Schema.Struct<{
361
361
  readonly meta: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>>;
362
362
  }>;
363
363
  readonly signal: Schema.declare<AbortSignal, AbortSignal>;
364
- readonly changes: Schema.declare<() => Promise<readonly TreeChange[]>, unknown>;
364
+ readonly changes: Schema.declare<() => Promise<readonly TreeChange[]>, () => Promise<readonly TreeChange[]>>;
365
365
  }>;
366
366
  export type LanesInput = typeof LanesInput.Type;
367
367
  /**
@@ -399,7 +399,7 @@ export interface ReportOptions {
399
399
  /**
400
400
  * The host's queue. Each function is pure but `join` and `lanes`, whose I/O gets a signal, aborted
401
401
  * after 30 seconds. A throw in `merge` or `lanes` fails the entry `host-error`; one in `bisect` or
402
- * a schedule function takes the default. Either goes to `onError`, as `queue.merge` and the rest.
402
+ * a schedule function takes the default. Either is logged at `Error`, as `queue.merge` and the rest.
403
403
  */
404
404
  export interface MergeQueueOptions {
405
405
  /**
@@ -419,7 +419,7 @@ export interface MergeQueueOptions {
419
419
  * It's asked by each add that finds no entry for its key. Adds of one key that race may each ask
420
420
  * it, and only the add whose write lands keeps its answer, so it must be safe to ask twice for
421
421
  * one key: a read, with no side effect counted per call. A losing add whose `lanes` throws
422
- * answers the error, and `onError` gets `queue.lanes`; its redelivery answers the repeat, with
422
+ * answers the error, logged as `queue.lanes`'s; its redelivery answers the repeat, with
423
423
  * the stored entry and the winner's lanes (Q524).
424
424
  * Within a lane, candidates stack and merge in order; across lanes, they check and merge apart,
425
425
  * and an entry in several waits on each. With candidates open in its lanes, an entry stacks only
@@ -2,12 +2,11 @@ import { Actor, ActorId } from "./actors.mjs";
2
2
  import { CommitMessage } from "./commits.mjs";
3
3
  import { Commit } from "./engine.mjs";
4
4
  import { Oid, RefName, RepoName } from "./ids.mjs";
5
- import { AbortSignalValue } from "./opaque.mjs";
6
- import { ErrorContext, Verdict, isGitErrorCode } from "./result.mjs";
5
+ import { AbortSignalValue, FunctionValue } from "./opaque.mjs";
6
+ import { Verdict, decisionAnswer } from "./result.mjs";
7
7
  import * as Effect from "effect/Effect";
8
8
  import * as Schema from "effect/Schema";
9
9
  import { jsonBytes } from "@ref0/infra";
10
- import * as Predicate from "effect/Predicate";
11
10
  import * as SchemaTransformation from "effect/SchemaTransformation";
12
11
  import * as Context from "effect/Context";
13
12
  // src/contracts/queue.ts
@@ -157,20 +156,8 @@ const MergePlan = /* @__PURE__ */ Schema.Struct({
157
156
  ...CommitMessage.fields,
158
157
  method: MergeMethod
159
158
  }).annotate({ identifier: "MergePlan" });
160
- const JoinErrorCode = /* @__PURE__ */ Schema.String.pipe(Schema.refine(isGitErrorCode));
161
- const JoinAccepted = /* @__PURE__ */ Schema.Struct({
162
- kind: Schema.Literal("accept"),
163
- value: Schema.optional(Schema.Undefined)
164
- });
165
- const JoinRejected = /* @__PURE__ */ Schema.Struct({
166
- kind: Schema.Literal("reject"),
167
- code: Schema.optional(JoinErrorCode),
168
- message: Schema.String,
169
- hint: Schema.optional(Schema.String),
170
- context: Schema.optional(ErrorContext)
171
- });
172
- /** What the host's `join` answers: `accept()` or `reject(...)`, matching `DecisionAnswer`. */
173
- const JoinAnswer = /* @__PURE__ */ Schema.Union([JoinAccepted, JoinRejected]).annotate({ identifier: "JoinAnswer" });
159
+ /** What the host's `join` answers: `accept()` or `reject(...)`, read as `DecisionAnswer`. */
160
+ const JoinAnswer = /* @__PURE__ */ decisionAnswer(Schema.Undefined).annotate({ identifier: "JoinAnswer" });
174
161
  /** A lane's name: well-formed UTF-8, 1 to `queueLaneBytesMost` bytes counted as UTF-8 JSON, quotes aside. */
175
162
  const LaneName = /* @__PURE__ */ Schema.String.check(Schema.makeFilter((lane) => {
176
163
  if (loneSurrogate.test(lane)) return "lanes named a lane UTF-8 can't hold";
@@ -201,7 +188,7 @@ const JoinInput = /* @__PURE__ */ Schema.Struct({
201
188
  entry: EntryFields,
202
189
  signal: AbortSignalValue
203
190
  });
204
- ({ ...JoinInput.fields }), Schema.declare((input) => Predicate.isFunction(input));
191
+ ({ ...JoinInput.fields }), FunctionValue();
205
192
  /** One bisect group: at least one entry, none named twice. */
206
193
  const EntryGroup = /* @__PURE__ */ Schema.Array(EntryId).check(Schema.isMinLength(1), Schema.makeFilter((group) => new Set(group).size === group.length || "a bisect group names no entry twice"));
207
194
  /**
@@ -1,5 +1,6 @@
1
- import { Awaitable, GitError } from "./result.mjs";
2
1
  import { ActorInput } from "./actors.mjs";
2
+ import { Awaitable, GitError, Result } from "./result.mjs";
3
+ import * as Effect from "effect/Effect";
3
4
  import * as Schema from "effect/Schema";
4
5
  /** What a client sends as Basic: Git's own credential, such as `x-access-token` and a token. */
5
6
  export declare const BasicCredential: Schema.Struct<{
@@ -28,7 +29,7 @@ export declare const ClientCredentials: Schema.Union<readonly [Schema.Union<read
28
29
  readonly password: Schema.String;
29
30
  }>, Schema.Struct<{
30
31
  readonly token: Schema.String;
31
- }>]>, Schema.declare<(input: CredentialInput) => Awaitable<ClientCredential>, unknown>]>;
32
+ }>]>, Schema.declare<(input: CredentialInput) => Awaitable<ClientCredential>, (input: CredentialInput) => Awaitable<ClientCredential>>]>;
32
33
  export type ClientCredentials = typeof ClientCredentials.Type;
33
34
  /** A request that failed: its status, or `0` when no answer came, and its error when it sent one. */
34
35
  export declare const TransportFailure: Schema.Struct<{
@@ -67,5 +68,13 @@ export interface RemoteOptions {
67
68
  * either: REST names a repo by its path alone, so a remote couldn't hold a call to one (Q705).
68
69
  */
69
70
  export type WithoutActor<Input> = Input extends ActorInput ? Omit<Input, 'actor' | 'internalId'> : Input;
70
- /** A group of server calls as a remote makes them, each input without `actor`. */
71
- export type RemoteCalls<Calls> = { readonly [Key in keyof Calls]-?: NonNullable<Calls[Key]> extends ((...args: infer Args) => infer Answer) ? (...args: { [Index in keyof Args]: WithoutActor<Args[Index]>; }) => Answer : RemoteCalls<NonNullable<Calls[Key]>>; };
71
+ /** A call's input without `signal`: interrupting the call's fiber stops it. */
72
+ export type WithoutSignal<Input> = Input extends object ? Omit<Input, 'signal'> : Input;
73
+ /** A call's answer as a remote gives it: an Effect that fails with the call's `GitError`. */
74
+ type RemoteAnswer<Answer> = Answer extends Promise<Result<infer A>> ? Effect.Effect<A, GitError> : Answer;
75
+ /**
76
+ * A group of server calls as a remote makes them: each an Effect, its input without `actor` or
77
+ * `signal`.
78
+ */
79
+ export type RemoteCalls<Calls> = { readonly [Key in keyof Calls]-?: NonNullable<Calls[Key]> extends ((...args: infer Args) => infer Answer) ? (...args: { [Index in keyof Args]: WithoutSignal<WithoutActor<Args[Index]>>; }) => RemoteAnswer<Answer> : RemoteCalls<NonNullable<Calls[Key]>>; };
80
+ export {};
@@ -1,6 +1,6 @@
1
+ import { FunctionValue } from "./opaque.mjs";
1
2
  import { GitErrorValue } from "./result.mjs";
2
3
  import * as Schema from "effect/Schema";
3
- import * as Predicate from "effect/Predicate";
4
4
  // src/contracts/remote.ts
5
5
  /** What a client sends as Basic: Git's own credential, such as `x-access-token` and a token. */
6
6
  const BasicCredential = /* @__PURE__ */ Schema.Struct({
@@ -10,9 +10,9 @@ const BasicCredential = /* @__PURE__ */ Schema.Struct({
10
10
  const BearerCredential = /* @__PURE__ */ Schema.Struct({ token: Schema.String });
11
11
  const ClientCredential = /* @__PURE__ */ Schema.Union([BasicCredential, BearerCredential]);
12
12
  /** A value, or a function for short-lived credentials: after a 401 it runs once more. */
13
- const ClientCredentials = /* @__PURE__ */ Schema.Union([ClientCredential, Schema.declare((input) => Predicate.isFunction(input))]);
13
+ const ClientCredentials = /* @__PURE__ */ Schema.Union([ClientCredential, FunctionValue()]);
14
14
  /** A request's sender in place of `fetch`, held as itself. */
15
- const Transport = /* @__PURE__ */ Schema.declare((input) => Predicate.isFunction(input));
15
+ const Transport = /* @__PURE__ */ FunctionValue();
16
16
  /** A request that failed: its status, or `0` when no answer came, and its error when it sent one. */
17
17
  const TransportFailure = /* @__PURE__ */ Schema.Struct({
18
18
  status: Schema.Int,
@@ -15,12 +15,19 @@ type Moment$1 = typeof Moment$1.Type;
15
15
  export declare const RepoStats: Schema.Struct<{
16
16
  readonly repo: Schema.String;
17
17
  readonly refs: Schema.Number;
18
+ /** The packs the repo lists. */
18
19
  readonly packs: Schema.Number;
20
+ /**
21
+ * The bytes of the packs the repo lists, shared with forks or not, and of the pack kept ready for
22
+ * a shallow clone of the default branch, which no list names.
23
+ */
19
24
  readonly packBytes: Schema.Number;
25
+ /**
26
+ * The bytes a quota counts: `packBytes`, and the objects the repo keeps as rows, every object of
27
+ * a `loose()` repo's and a small push's that `packs()` keeps until its next repack, each its row's
28
+ * bytes as the store holds it.
29
+ */
20
30
  readonly ownBytes: Schema.Number;
21
- readonly looseObjects: Schema.Number;
22
- readonly looseBytes: Schema.Number;
23
- readonly leavingBytes: Schema.Number;
24
31
  /**
25
32
  * When the core last committed a move of one of the repo's refs: a push, a write that names a
26
33
  * ref, `refs.update`, a merge or a queue's publish, but not the queue's own refs alone. None
@@ -39,7 +46,7 @@ export type RepoStats = typeof RepoStats.Type;
39
46
  * every field: every caller of a server with no `access`, and one `refs.private` lets read every
40
47
  * pattern of the repo's, as it does on a repo with none. One a private pattern restricts gets only
41
48
  * what its own view counts: `repo`, the `refs` it sees and the `pushedAt` of those refs. The pack
42
- * and object counts, the bytes and `maintainedAt` are left out, never zero, since a push to a ref
49
+ * count, the bytes and `maintainedAt` are left out, never zero, since a push to a ref
43
50
  * it can't see moves them.
44
51
  */
45
52
  export declare const RepoInfoStats: Schema.Struct<{
@@ -51,12 +58,6 @@ export declare const RepoInfoStats: Schema.Struct<{
51
58
  readonly packBytes: Schema.optionalKey<Schema.Number>;
52
59
  /** As `RepoStats` counts it; left out for a caller a private pattern restricts. */
53
60
  readonly ownBytes: Schema.optionalKey<Schema.Number>;
54
- /** As `RepoStats` counts it; left out for a caller a private pattern restricts. */
55
- readonly looseObjects: Schema.optionalKey<Schema.Number>;
56
- /** As `RepoStats` counts it; left out for a caller a private pattern restricts. */
57
- readonly looseBytes: Schema.optionalKey<Schema.Number>;
58
- /** As `RepoStats` counts it; left out for a caller a private pattern restricts. */
59
- readonly leavingBytes: Schema.optionalKey<Schema.Number>;
60
61
  /** When a ref this caller sees last moved: the whole repo's for a caller with the whole view. */
61
62
  readonly pushedAt: Schema.optionalKey<Schema.Number>;
62
63
  /** As `RepoStats` keeps it; left out for a caller a private pattern restricts. */
@@ -116,12 +117,6 @@ export declare const RepoInfo: Schema.Struct<{
116
117
  readonly packBytes: Schema.optionalKey<Schema.Number>;
117
118
  /** As `RepoStats` counts it; left out for a caller a private pattern restricts. */
118
119
  readonly ownBytes: Schema.optionalKey<Schema.Number>;
119
- /** As `RepoStats` counts it; left out for a caller a private pattern restricts. */
120
- readonly looseObjects: Schema.optionalKey<Schema.Number>;
121
- /** As `RepoStats` counts it; left out for a caller a private pattern restricts. */
122
- readonly looseBytes: Schema.optionalKey<Schema.Number>;
123
- /** As `RepoStats` counts it; left out for a caller a private pattern restricts. */
124
- readonly leavingBytes: Schema.optionalKey<Schema.Number>;
125
120
  /** When a ref this caller sees last moved: the whole repo's for a caller with the whole view. */
126
121
  readonly pushedAt: Schema.optionalKey<Schema.Number>;
127
122
  /** As `RepoStats` keeps it; left out for a caller a private pattern restricts. */
@@ -311,9 +306,6 @@ declare const Repos_base: Context.ServiceClass<Repos, "@ref0/git/Repos", EffectC
311
306
  readonly packs?: number;
312
307
  readonly packBytes?: number;
313
308
  readonly ownBytes?: number;
314
- readonly looseObjects?: number;
315
- readonly looseBytes?: number;
316
- readonly leavingBytes?: number;
317
309
  readonly pushedAt?: number;
318
310
  readonly maintainedAt?: number;
319
311
  };
@@ -341,9 +333,6 @@ declare const Repos_base: Context.ServiceClass<Repos, "@ref0/git/Repos", EffectC
341
333
  readonly packs?: number;
342
334
  readonly packBytes?: number;
343
335
  readonly ownBytes?: number;
344
- readonly looseObjects?: number;
345
- readonly looseBytes?: number;
346
- readonly leavingBytes?: number;
347
336
  readonly pushedAt?: number;
348
337
  readonly maintainedAt?: number;
349
338
  };
@@ -372,9 +361,6 @@ declare const Repos_base: Context.ServiceClass<Repos, "@ref0/git/Repos", EffectC
372
361
  readonly packs?: number;
373
362
  readonly packBytes?: number;
374
363
  readonly ownBytes?: number;
375
- readonly looseObjects?: number;
376
- readonly looseBytes?: number;
377
- readonly leavingBytes?: number;
378
364
  readonly pushedAt?: number;
379
365
  readonly maintainedAt?: number;
380
366
  };
@@ -402,9 +388,6 @@ declare const Repos_base: Context.ServiceClass<Repos, "@ref0/git/Repos", EffectC
402
388
  readonly packs?: number;
403
389
  readonly packBytes?: number;
404
390
  readonly ownBytes?: number;
405
- readonly looseObjects?: number;
406
- readonly looseBytes?: number;
407
- readonly leavingBytes?: number;
408
391
  readonly pushedAt?: number;
409
392
  readonly maintainedAt?: number;
410
393
  };
@@ -439,9 +422,6 @@ export declare const create: (input: RepoCreateInput, by?: Caller) => Effect.Eff
439
422
  readonly packs?: number;
440
423
  readonly packBytes?: number;
441
424
  readonly ownBytes?: number;
442
- readonly looseObjects?: number;
443
- readonly looseBytes?: number;
444
- readonly leavingBytes?: number;
445
425
  readonly pushedAt?: number;
446
426
  readonly maintainedAt?: number;
447
427
  };
@@ -469,9 +449,6 @@ export declare const get: (repo: RepoName, input: ActorInput & Pick<RepoInput, '
469
449
  readonly packs?: number;
470
450
  readonly packBytes?: number;
471
451
  readonly ownBytes?: number;
472
- readonly looseObjects?: number;
473
- readonly looseBytes?: number;
474
- readonly leavingBytes?: number;
475
452
  readonly pushedAt?: number;
476
453
  readonly maintainedAt?: number;
477
454
  };
@@ -500,9 +477,6 @@ export declare const update: (repo: RepoName, input: RepoUpdateInput, by?: Calle
500
477
  readonly packs?: number;
501
478
  readonly packBytes?: number;
502
479
  readonly ownBytes?: number;
503
- readonly looseObjects?: number;
504
- readonly looseBytes?: number;
505
- readonly leavingBytes?: number;
506
480
  readonly pushedAt?: number;
507
481
  readonly maintainedAt?: number;
508
482
  };
@@ -530,9 +504,6 @@ export declare const rename: (repo: RepoName, input: RepoRenameInput, by?: Calle
530
504
  readonly packs?: number;
531
505
  readonly packBytes?: number;
532
506
  readonly ownBytes?: number;
533
- readonly looseObjects?: number;
534
- readonly looseBytes?: number;
535
- readonly leavingBytes?: number;
536
507
  readonly pushedAt?: number;
537
508
  readonly maintainedAt?: number;
538
509
  };
@@ -29,12 +29,19 @@ const Moment = Schema.Number;
29
29
  const RepoStats = /* @__PURE__ */ Schema.Struct({
30
30
  repo: RepoName,
31
31
  refs: Schema.Number,
32
+ /** The packs the repo lists. */
32
33
  packs: Schema.Number,
34
+ /**
35
+ * The bytes of the packs the repo lists, shared with forks or not, and of the pack kept ready for
36
+ * a shallow clone of the default branch, which no list names.
37
+ */
33
38
  packBytes: Schema.Number,
39
+ /**
40
+ * The bytes a quota counts: `packBytes`, and the objects the repo keeps as rows, every object of
41
+ * a `loose()` repo's and a small push's that `packs()` keeps until its next repack, each its row's
42
+ * bytes as the store holds it.
43
+ */
34
44
  ownBytes: Schema.Number,
35
- looseObjects: Schema.Number,
36
- looseBytes: Schema.Number,
37
- leavingBytes: Schema.Number,
38
45
  /**
39
46
  * When the core last committed a move of one of the repo's refs: a push, a write that names a
40
47
  * ref, `refs.update`, a merge or a queue's publish, but not the queue's own refs alone. None
@@ -52,7 +59,7 @@ const RepoStats = /* @__PURE__ */ Schema.Struct({
52
59
  * every field: every caller of a server with no `access`, and one `refs.private` lets read every
53
60
  * pattern of the repo's, as it does on a repo with none. One a private pattern restricts gets only
54
61
  * what its own view counts: `repo`, the `refs` it sees and the `pushedAt` of those refs. The pack
55
- * and object counts, the bytes and `maintainedAt` are left out, never zero, since a push to a ref
62
+ * count, the bytes and `maintainedAt` are left out, never zero, since a push to a ref
56
63
  * it can't see moves them.
57
64
  */
58
65
  const RepoInfoStats = /* @__PURE__ */ Schema.Struct({
@@ -64,12 +71,6 @@ const RepoInfoStats = /* @__PURE__ */ Schema.Struct({
64
71
  packBytes: Schema.optionalKey(Schema.Number),
65
72
  /** As `RepoStats` counts it; left out for a caller a private pattern restricts. */
66
73
  ownBytes: Schema.optionalKey(Schema.Number),
67
- /** As `RepoStats` counts it; left out for a caller a private pattern restricts. */
68
- looseObjects: Schema.optionalKey(Schema.Number),
69
- /** As `RepoStats` counts it; left out for a caller a private pattern restricts. */
70
- looseBytes: Schema.optionalKey(Schema.Number),
71
- /** As `RepoStats` counts it; left out for a caller a private pattern restricts. */
72
- leavingBytes: Schema.optionalKey(Schema.Number),
73
74
  /** When a ref this caller sees last moved: the whole repo's for a caller with the whole view. */
74
75
  pushedAt: RepoStats.fields.pushedAt,
75
76
  /** As `RepoStats` keeps it; left out for a caller a private pattern restricts. */
@@ -150,7 +150,7 @@ export declare const DataLossContext: Schema.StructWithRest<Schema.Struct<{
150
150
  reason: Schema.optionalKey<Schema.Union<readonly [Schema.Literals<readonly ["event-version", "graph-length", "merge-incomplete"]>, Schema.decodeTo<Schema.String, Schema.String, never, never>]>>;
151
151
  }>, readonly [Schema.$Record<Schema.String, Schema.Union<readonly [Schema.decodeTo<Schema.String, Schema.String, never, never>, Schema.Number, Schema.Boolean, Schema.$Array<Schema.decodeTo<Schema.String, Schema.String, never, never>>, Schema.Undefined]>>]>;
152
152
  export type DataLossContext = typeof DataLossContext.Type;
153
- /** `id`: the logged host-function failure's, which `onError` receives too. */
153
+ /** `id`: the logged host-function failure's, which its log line is annotated with as `failure`. */
154
154
  export declare const HostErrorContext: Schema.StructWithRest<Schema.Struct<{
155
155
  id: Schema.optionalKey<Schema.decodeTo<Schema.String, Schema.String, never, never>>;
156
156
  }>, readonly [Schema.$Record<Schema.String, Schema.Union<readonly [Schema.decodeTo<Schema.String, Schema.String, never, never>, Schema.Number, Schema.Boolean, Schema.$Array<Schema.decodeTo<Schema.String, Schema.String, never, never>>, Schema.Undefined]>>]>;
@@ -390,19 +390,27 @@ export declare const gitError: <Code extends GitErrorCode>(code: Code, message:
390
390
  /** Whether `told`, a `reason: <told>` line's, is a reason a refusal names. */
391
391
  export declare const isRefusalReason: (told: string) => told is RefusalReason;
392
392
  /** A host function's refusal: `code` is `NOT_ALLOWED` when it's left out. */
393
- export interface RejectInput {
394
- readonly code?: GitErrorCode;
395
- readonly message: string;
396
- readonly hint?: string;
397
- readonly context?: ErrorContext;
398
- }
399
- export interface Rejected extends RejectInput {
400
- readonly kind: 'reject';
401
- }
393
+ export declare const RejectInput: Schema.Struct<{
394
+ readonly code: Schema.decodeTo<Schema.optionalKey<Schema.toType<Schema.Literals<readonly ("ALREADY_EXISTS" | "DATA_LOSS" | "DEADLINE_EXCEEDED" | "FAILED_PRECONDITION" | "INTERNAL" | "INVALID_ARGUMENT" | "NOT_ALLOWED" | "NOT_FOUND" | "RESOURCE_EXHAUSTED" | "UNAUTHENTICATED" | "UNAVAILABLE")[]>>>, Schema.optional<Schema.Literals<readonly ("ALREADY_EXISTS" | "DATA_LOSS" | "DEADLINE_EXCEEDED" | "FAILED_PRECONDITION" | "INTERNAL" | "INVALID_ARGUMENT" | "NOT_ALLOWED" | "NOT_FOUND" | "RESOURCE_EXHAUSTED" | "UNAUTHENTICATED" | "UNAVAILABLE")[]>>, never, never>;
395
+ readonly message: Schema.String;
396
+ readonly hint: Schema.decodeTo<Schema.optionalKey<Schema.toType<Schema.String>>, Schema.optional<Schema.String>, never, never>;
397
+ readonly context: Schema.decodeTo<Schema.optionalKey<Schema.toType<Schema.StructWithRest<Schema.Struct<{}>, readonly [Schema.$Record<Schema.String, Schema.Union<readonly [Schema.decodeTo<Schema.String, Schema.String, never, never>, Schema.Number, Schema.Boolean, Schema.$Array<Schema.decodeTo<Schema.String, Schema.String, never, never>>, Schema.Undefined]>>]>>>, Schema.optional<Schema.StructWithRest<Schema.Struct<{}>, readonly [Schema.$Record<Schema.String, Schema.Union<readonly [Schema.decodeTo<Schema.String, Schema.String, never, never>, Schema.Number, Schema.Boolean, Schema.$Array<Schema.decodeTo<Schema.String, Schema.String, never, never>>, Schema.Undefined]>>]>>, never, never>;
398
+ }>;
399
+ export type RejectInput = typeof RejectInput.Type;
400
+ export declare const Rejected: Schema.Struct<{
401
+ readonly code: Schema.decodeTo<Schema.optionalKey<Schema.toType<Schema.Literals<readonly ("ALREADY_EXISTS" | "DATA_LOSS" | "DEADLINE_EXCEEDED" | "FAILED_PRECONDITION" | "INTERNAL" | "INVALID_ARGUMENT" | "NOT_ALLOWED" | "NOT_FOUND" | "RESOURCE_EXHAUSTED" | "UNAUTHENTICATED" | "UNAVAILABLE")[]>>>, Schema.optional<Schema.Literals<readonly ("ALREADY_EXISTS" | "DATA_LOSS" | "DEADLINE_EXCEEDED" | "FAILED_PRECONDITION" | "INTERNAL" | "INVALID_ARGUMENT" | "NOT_ALLOWED" | "NOT_FOUND" | "RESOURCE_EXHAUSTED" | "UNAUTHENTICATED" | "UNAVAILABLE")[]>>, never, never>;
402
+ readonly message: Schema.String;
403
+ readonly hint: Schema.decodeTo<Schema.optionalKey<Schema.toType<Schema.String>>, Schema.optional<Schema.String>, never, never>;
404
+ readonly context: Schema.decodeTo<Schema.optionalKey<Schema.toType<Schema.StructWithRest<Schema.Struct<{}>, readonly [Schema.$Record<Schema.String, Schema.Union<readonly [Schema.decodeTo<Schema.String, Schema.String, never, never>, Schema.Number, Schema.Boolean, Schema.$Array<Schema.decodeTo<Schema.String, Schema.String, never, never>>, Schema.Undefined]>>]>>>, Schema.optional<Schema.StructWithRest<Schema.Struct<{}>, readonly [Schema.$Record<Schema.String, Schema.Union<readonly [Schema.decodeTo<Schema.String, Schema.String, never, never>, Schema.Number, Schema.Boolean, Schema.$Array<Schema.decodeTo<Schema.String, Schema.String, never, never>>, Schema.Undefined]>>]>>, never, never>;
405
+ readonly kind: Schema.Literal<"reject">;
406
+ }>;
407
+ export type Rejected = typeof Rejected.Type;
408
+ /** An accept: `decisionAnswer` reads one with its value's Schema. */
402
409
  export interface Accepted<Data = undefined> {
403
410
  readonly kind: 'accept';
404
411
  readonly value?: Data;
405
412
  }
413
+ /** A host check's answer: `decisionAnswer` reads one a host's JavaScript gave. */
406
414
  export type DecisionAnswer<Data = undefined> = Accepted<Data> | Rejected;
407
415
  /** With no value, it fits any answer: a fetch rule's as well as a push rule's. */
408
416
  export declare function accept(): Accepted<never>;
@@ -412,7 +420,16 @@ export declare function accept<Data>(value: Data): Accepted<Data>;
412
420
  * `message` off its enumerable keys, so a spread of one would drop it.
413
421
  */
414
422
  export declare const reject: ({ code, message, hint, context }: RejectInput) => Rejected;
415
- export declare const HostFunctionName: Schema.Literals<readonly ["auth", "authorize", "approvalPage", "grants", "rules.push", "rules.fetch", "hooks", "resolve", "join", "queue.merge", "queue.lanes", "queue.bisect", "queue.schedule", "topics.prepare", "topics.required"]>;
423
+ /**
424
+ * The host functions Git runs, by the name its logs give each. When one throws, fails or runs past
425
+ * its timeout, its caller gets a fixed sentence and a failure ID, and the runtime's Logger gets a
426
+ * line at `Error`: `<name> failed` or `<name> ran out of time`, annotated `function`, `failure` (that
427
+ * ID), and `repo` and `operation` (the operation's kind) where the call has them. Its cause is the
428
+ * host's own error, unredacted, so a credential or a private ref name an `Auth`, a grant resolver or
429
+ * a rule puts in its error reaches the Logger as written: cleaning it is the host's Logger's job. A
430
+ * refusal is a line at `Debug`, `<name> refused: <message>`, annotated `code` beside the rest.
431
+ */
432
+ export declare const HostFunctionName: Schema.Literals<readonly ["auth", "authorize", "approvalPage", "grants", "rules.push", "rules.fetch", "hooks", "join", "queue.merge", "queue.lanes", "queue.bisect", "queue.schedule", "topics.prepare", "topics.required"]>;
416
433
  export type HostFunctionName = typeof HostFunctionName.Type;
417
434
  export type Awaitable<T> = T | Promise<T>;
418
435
  export {};
@@ -1,4 +1,5 @@
1
1
  import * as Effect from "effect/Effect";
2
+ import * as Option from "effect/Option";
2
3
  import * as Schema from "effect/Schema";
3
4
  import * as Predicate from "effect/Predicate";
4
5
  import * as SchemaTransformation from "effect/SchemaTransformation";
@@ -251,7 +252,7 @@ const DataLossReason = /* @__PURE__ */ Schema.Literals([
251
252
  "merge-incomplete"
252
253
  ]);
253
254
  const DataLossContext = contextOf({ reason: reasonOf(DataLossReason) });
254
- /** `id`: the logged host-function failure's, which `onError` receives too. */
255
+ /** `id`: the logged host-function failure's, which its log line is annotated with as `failure`. */
255
256
  const HostErrorContext = contextOf({ id: Schema.optionalKey(BodyText) });
256
257
  /**
257
258
  * `busy`: the server's memory, held by other calls, had no room for this one in time.
@@ -388,6 +389,35 @@ const gitErrorFrom = (fields, over = {}) => {
388
389
  const refusalReasons = /* @__PURE__ */ new Set(refusalReasonLists.flatMap((reasons) => reasons.literals));
389
390
  /** Whether `told`, a `reason: <told>` line's, is a reason a refusal names. */
390
391
  const isRefusalReason = (told) => refusalReasons.has(told);
392
+ /**
393
+ * An optional field a host's JavaScript may also answer as `undefined`, which reads as left out: so
394
+ * its type stays the field's own, as `reject()` writes it, and `join`'s explicit `undefined` still
395
+ * refuses (#1877).
396
+ */
397
+ const answeredOptional = (schema) => Schema.optional(schema).pipe(Schema.decodeTo(Schema.optionalKey(Schema.toType(schema)), SchemaTransformation.transformOptional({
398
+ decode: Option.filter(Predicate.isNotUndefined),
399
+ encode: (value) => value
400
+ })));
401
+ /** A host function's refusal: `code` is `NOT_ALLOWED` when it's left out. */
402
+ const RejectInput = /* @__PURE__ */ Schema.Struct({
403
+ code: answeredOptional(GitErrorCode),
404
+ message: Schema.String,
405
+ hint: answeredOptional(Schema.String),
406
+ context: answeredOptional(ErrorContext)
407
+ });
408
+ const Rejected = /* @__PURE__ */ Schema.Struct({
409
+ kind: Schema.Literal("reject"),
410
+ ...RejectInput.fields
411
+ });
412
+ /**
413
+ * A host check's answer, `accept()` with a `value` that `value` reads or `reject()`, as a host's
414
+ * JavaScript may answer anything: a push rule's, a hook group's, a fetch rule's, `join`'s and
415
+ * `prepare`'s. Its type is `DecisionAnswer` of `value`'s.
416
+ */
417
+ const decisionAnswer = (value) => Schema.Union([Schema.Struct({
418
+ kind: Schema.Literal("accept"),
419
+ value: answeredOptional(value)
420
+ }), Rejected]);
391
421
  function accept(...value) {
392
422
  return value.length === 0 ? { kind: "accept" } : {
393
423
  kind: "accept",
@@ -408,4 +438,4 @@ const reject = ({ code, message, hint, context }) => {
408
438
  if (context !== void 0) rejected.context = context;
409
439
  return rejected;
410
440
  };
411
- export { ContextValue, DataLossContext, DataLossReason, ErrorContext, ExistingContext, ExistingReason, GitErrorBody, GitErrorCode, GitErrorTagged, GitErrorValue, HostErrorContext, InvalidInputContext, InvalidInputReason, MissingContext, MissingReason, NotAllowedContext, NotAllowedReason, PreconditionContext, PreconditionReason, ResourceContext, ResourceReason, UnavailableContext, UnavailableReason, Verdict, accept, fail, gitError, gitErrorBodies, gitErrorFrom, httpStatus, isGitError, isGitErrorCode, isRefusalReason, refusalCodeHeader, reject };
441
+ export { ContextValue, DataLossContext, DataLossReason, ErrorContext, ExistingContext, ExistingReason, GitErrorBody, GitErrorCode, GitErrorTagged, GitErrorValue, HostErrorContext, InvalidInputContext, InvalidInputReason, MissingContext, MissingReason, NotAllowedContext, NotAllowedReason, PreconditionContext, PreconditionReason, RejectInput, Rejected, ResourceContext, ResourceReason, UnavailableContext, UnavailableReason, Verdict, accept, decisionAnswer, fail, gitError, gitErrorBodies, gitErrorFrom, httpStatus, isGitError, isGitErrorCode, isRefusalReason, refusalCodeHeader, reject };