@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.
- package/dist/access/private-refs.mjs +0 -2
- package/dist/auth/authorize.mjs +31 -24
- package/dist/auth/bridge.mjs +8 -8
- package/dist/auth/fences.d.mts +0 -1
- package/dist/auth/fences.mjs +1 -1
- package/dist/auth/grants.d.mts +0 -1
- package/dist/auth/grants.mjs +2 -2
- package/dist/auth/host-function.d.mts +1 -7
- package/dist/auth/host-function.mjs +38 -38
- package/dist/auth/identify.d.mts +0 -1
- package/dist/auth/identify.mjs +1 -1
- package/dist/auth/policy.d.mts +7 -4
- package/dist/auth/policy.mjs +13 -10
- package/dist/auth/token-rows.mjs +2 -5
- package/dist/auth/tokens-layer.d.mts +0 -2
- package/dist/auth/tokens-public.d.mts +3 -3
- package/dist/auth/tokens-public.mjs +4 -2
- package/dist/auth/tokens.d.mts +6 -1
- package/dist/auth/tokens.mjs +7 -1
- package/dist/client/client.d.mts +22 -15
- package/dist/client/client.mjs +31 -27
- package/dist/client/git-http.mjs +22 -5
- package/dist/client/local.mjs +1 -1
- package/dist/client/namespace.d.mts +2 -0
- package/dist/client/push-upload.d.mts +1 -0
- package/dist/client/push-upload.mjs +169 -2
- package/dist/client/remote-helper.mjs +2 -4
- package/dist/client/remote.mjs +37 -15
- package/dist/client/run-remote-helper.mjs +4 -4
- package/dist/client/transport.mjs +26 -19
- package/dist/contracts/actors.d.mts +57 -28
- package/dist/contracts/actors.mjs +38 -2
- package/dist/contracts/authorize.d.mts +21 -15
- package/dist/contracts/callers.mjs +40 -0
- package/dist/contracts/client.d.mts +16 -9
- package/dist/contracts/events.d.mts +12 -10
- package/dist/contracts/events.mjs +8 -6
- package/dist/contracts/files.d.mts +42 -42
- package/dist/contracts/forks.d.mts +0 -24
- package/dist/contracts/git-hooks.d.mts +217 -0
- package/dist/contracts/git-hooks.mjs +3 -1
- package/dist/contracts/grants.d.mts +46 -27
- package/dist/contracts/lfs.d.mts +17 -4
- package/dist/contracts/merges.d.mts +7 -7
- package/dist/contracts/objects.d.mts +20 -4
- package/dist/contracts/opaque.mjs +19 -1
- package/dist/contracts/operations.d.mts +8 -1
- package/dist/contracts/operations.mjs +209 -0
- package/dist/contracts/queue.d.mts +3 -3
- package/dist/contracts/queue.mjs +5 -18
- package/dist/contracts/remote.d.mts +13 -4
- package/dist/contracts/remote.mjs +3 -3
- package/dist/contracts/repos.d.mts +11 -40
- package/dist/contracts/repos.mjs +11 -10
- package/dist/contracts/result.d.mts +28 -11
- package/dist/contracts/result.mjs +32 -2
- package/dist/contracts/rules.d.mts +706 -46
- package/dist/contracts/rules.mjs +81 -2
- package/dist/contracts/server.d.mts +5 -275
- package/dist/contracts/services.d.mts +0 -3
- package/dist/contracts/services.mjs +1 -3
- package/dist/contracts/signin.d.mts +2 -2
- package/dist/contracts/signin.mjs +4 -5
- package/dist/contracts/sync.d.mts +1 -4
- package/dist/contracts/tokens.d.mts +29 -17
- package/dist/contracts/tokens.mjs +14 -3
- package/dist/contracts/topics.d.mts +38 -11
- package/dist/contracts/topics.mjs +8 -2
- package/dist/core/access.d.mts +0 -2
- package/dist/core/access.mjs +15 -4
- package/dist/core/events/deliver.mjs +19 -1
- package/dist/core/forks.mjs +30 -11
- package/dist/core/hooks/groups.d.mts +0 -1
- package/dist/core/hooks/groups.mjs +8 -9
- package/dist/core/loose-tally.mjs +46 -0
- package/dist/core/objects/writing.mjs +1 -0
- package/dist/core/promise.mjs +1 -15
- package/dist/core/purge.mjs +14 -9
- package/dist/core/push.mjs +13 -6
- package/dist/core/ref-view.mjs +14 -6
- package/dist/core/repack.mjs +19 -14
- package/dist/core/repo-info.mjs +8 -6
- package/dist/core/repos.mjs +1 -0
- package/dist/core/rules/check.mjs +10 -10
- package/dist/core/rules/context.d.mts +3 -1
- package/dist/core/rules/context.mjs +16 -13
- package/dist/core/rules/fetch.mjs +17 -23
- package/dist/core/tokens.mjs +2 -1
- package/dist/effect.d.mts +2 -4
- package/dist/effect.mjs +2 -4
- package/dist/engine/commits.mjs +19 -47
- package/dist/engine/failures.d.mts +1 -2
- package/dist/engine/failures.mjs +1 -3
- package/dist/engine/merge-base-walk.mjs +57 -142
- package/dist/engine/merge-bases.mjs +5 -5
- package/dist/engine/merge.mjs +16 -14
- package/dist/extend.d.mts +1 -2
- package/dist/extend.mjs +1 -2
- package/dist/http/core-parts.mjs +1 -2
- package/dist/http/handler.mjs +11 -31
- package/dist/http/parts.d.mts +0 -1
- package/dist/index.d.mts +28 -21
- package/dist/index.mjs +5 -2
- package/dist/lfs/base.d.mts +6 -3
- package/dist/lfs/base.mjs +2 -1
- package/dist/lfs/layer.d.mts +4 -3
- package/dist/lfs/layer.mjs +23 -9
- package/dist/lfs/objects.mjs +90 -41
- package/dist/lfs/pointers.mjs +69 -18
- package/dist/lfs/purge.mjs +6 -2
- package/dist/lfs/rows.mjs +24 -7
- package/dist/lfs/service.d.mts +6 -3
- package/dist/lfs/service.mjs +8 -2
- package/dist/lfs/upkeep.mjs +44 -26
- package/dist/lfs/upload-most.mjs +41 -0
- package/dist/lfs/uploaded.mjs +59 -0
- package/dist/protocol/bytes/sha256-hasher.mjs +51 -0
- package/dist/protocol/bytes/text.mjs +6 -1
- package/dist/protocol/objects/fsck.mjs +6 -3
- package/dist/queue/advance.mjs +38 -8
- package/dist/queue/calls.mjs +4 -14
- package/dist/queue/lanes.mjs +1 -1
- package/dist/queue/rows.mjs +8 -0
- package/dist/queue/schedule.mjs +1 -1
- package/dist/queue/search.mjs +3 -4
- package/dist/rest/client-namespace.d.mts +2 -0
- package/dist/rest/client.d.mts +32 -8
- package/dist/rest/client.mjs +308 -382
- package/dist/rest/commits.d.mts +240 -240
- package/dist/rest/files.d.mts +18 -18
- package/dist/rest/forks.d.mts +45 -57
- package/dist/rest/handlers.mjs +2 -1
- package/dist/rest/listen.d.mts +8 -6
- package/dist/rest/listen.mjs +31 -75
- package/dist/rest/me.d.mts +2 -2
- package/dist/rest/merges.d.mts +7 -7
- package/dist/rest/refs.d.mts +139 -139
- package/dist/rest/repos.d.mts +54 -66
- package/dist/rest/tokens.d.mts +12 -12
- package/dist/rest/topics.d.mts +110 -110
- package/dist/rest/trees.d.mts +66 -66
- package/dist/rest/wire.d.mts +1 -1
- package/dist/rest.d.mts +1 -7
- package/dist/rest.mjs +1 -5
- package/dist/server/git-layer.d.mts +10 -2
- package/dist/server/git-layer.mjs +29 -10
- package/dist/server/joined.d.mts +1 -1
- package/dist/server/server.d.mts +0 -1
- package/dist/server/server.mjs +26 -45
- package/dist/signin/context.d.mts +0 -1
- package/dist/signin/context.mjs +5 -9
- package/dist/storage/clean-up.mjs +3 -1
- package/dist/storage/fsck.mjs +12 -2
- package/dist/storage/graph-rebuild.mjs +262 -0
- package/dist/storage/index-build.mjs +100 -12
- package/dist/storage/lfs-pointers.d.mts +5 -5
- package/dist/storage/lfs-pointers.mjs +37 -11
- package/dist/storage/loose.mjs +4 -1
- package/dist/storage/memory-budget.mjs +1 -1
- package/dist/storage/merge-fence.mjs +81 -19
- package/dist/storage/merge-most.mjs +1 -0
- package/dist/storage/merge-row.mjs +16 -4
- package/dist/storage/merge-stream.mjs +9 -6
- package/dist/storage/object-rows.mjs +17 -1
- package/dist/storage/pack-receive.mjs +10 -6
- package/dist/storage/packs.mjs +58 -27
- package/dist/storage/prune.mjs +68 -40
- package/dist/storage/ready.d.mts +1 -1
- package/dist/storage/ready.mjs +12 -3
- package/dist/storage/receive-state.mjs +1 -1
- package/dist/storage/repack-contained.mjs +22 -14
- package/dist/storage/repack.d.mts +1 -1
- package/dist/storage/repack.mjs +3 -2
- package/dist/storage/unpack.mjs +7 -0
- package/dist/store/call-count.d.mts +23 -3
- package/dist/store/call-count.mjs +36 -13
- package/dist/store/records.mjs +10 -4
- package/dist/store/repo-record.mjs +29 -12
- package/dist/store/scopes.mjs +6 -1
- package/dist/sync/import.mjs +14 -2
- package/dist/sync/layer.d.mts +5 -1
- package/dist/sync/layer.mjs +7 -2
- package/dist/sync/step.mjs +15 -15
- package/dist/topics/advance.mjs +7 -6
- package/dist/topics/members.mjs +38 -9
- package/package.json +3 -3
- package/dist/engine/merge-base-walk.d.mts +0 -3
- package/dist/server/routes.d.mts +0 -32
- package/dist/server/routes.mjs +0 -69
- package/dist/sync/bridge.d.mts +0 -6
- 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[]>,
|
|
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
|
|
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,
|
|
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
|
package/dist/contracts/queue.mjs
CHANGED
|
@@ -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 {
|
|
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
|
-
|
|
161
|
-
const
|
|
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 }),
|
|
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>,
|
|
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
|
|
71
|
-
export type
|
|
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,
|
|
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__ */
|
|
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
|
-
*
|
|
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
|
};
|
package/dist/contracts/repos.mjs
CHANGED
|
@@ -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
|
-
*
|
|
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
|
|
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
|
|
394
|
-
readonly code
|
|
395
|
-
readonly message:
|
|
396
|
-
readonly hint
|
|
397
|
-
readonly context
|
|
398
|
-
}
|
|
399
|
-
export
|
|
400
|
-
|
|
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
|
-
|
|
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
|
|
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 };
|