ref0-git 0.2.0 → 0.4.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/app/apps/github/.dev.vars.example +2 -1
- package/app/apps/github/generated/git-rest.ts +191 -25
- package/app/apps/github/generated/routeTree.gen.ts +21 -0
- package/app/apps/github/package.json +1 -1
- package/app/apps/github/src/branches/branch-list.tsx +8 -4
- package/app/apps/github/src/branches/branches.ts +10 -5
- package/app/apps/github/src/camo/addresses.ts +120 -0
- package/app/apps/github/src/camo/client.ts +125 -0
- package/app/apps/github/src/camo/fetch.ts +201 -0
- package/app/apps/github/src/camo/lookup.ts +23 -0
- package/app/apps/github/src/camo/node.ts +50 -0
- package/app/apps/github/src/camo/proxy.ts +116 -0
- package/app/apps/github/src/camo/sign-images.ts +307 -0
- package/app/apps/github/src/camo/signing.ts +80 -0
- package/app/apps/github/src/clients/allowed.ts +111 -18
- package/app/apps/github/src/clients/clients.ts +76 -61
- package/app/apps/github/src/clients/transport.ts +13 -0
- package/app/apps/github/src/code/code-tree.tsx +3 -1
- package/app/apps/github/src/code/file-view.tsx +15 -6
- package/app/apps/github/src/code/files.ts +26 -19
- package/app/apps/github/src/code/go-to-file.tsx +2 -1
- package/app/apps/github/src/code/load.ts +41 -23
- package/app/apps/github/src/code/markdown-files.ts +13 -2
- package/app/apps/github/src/code/ref-pages.ts +14 -5
- package/app/apps/github/src/code/ref-switcher.tsx +4 -3
- package/app/apps/github/src/code/refs.ts +42 -8
- package/app/apps/github/src/code/repo-home.tsx +6 -2
- package/app/apps/github/src/code/repo.ts +12 -6
- package/app/apps/github/src/code/saved.ts +5 -3
- package/app/apps/github/src/code/trees.ts +11 -9
- package/app/apps/github/src/components/markdown/markdown.css +6 -0
- package/app/apps/github/src/components/markdown/markdown.tsx +95 -10
- package/app/apps/github/src/components/owner-card.tsx +3 -1
- package/app/apps/github/src/components/repos/your-repos.tsx +3 -1
- package/app/apps/github/src/components/shell/owner-repos.tsx +7 -12
- package/app/apps/github/src/components/shell/repo-switcher.tsx +10 -16
- package/app/apps/github/src/components/signin/device-card.tsx +9 -2
- package/app/apps/github/src/components/user-avatar.tsx +2 -1
- package/app/apps/github/src/context/context.ts +13 -0
- package/app/apps/github/src/diffs/blobs.ts +37 -14
- package/app/apps/github/src/diffs/diff-job.ts +53 -0
- package/app/apps/github/src/diffs/diff-worker.ts +6 -0
- package/app/apps/github/src/diffs/diffing.ts +136 -0
- package/app/apps/github/src/diffs/files.ts +4 -3
- package/app/apps/github/src/diffs/hunks.tsx +101 -53
- package/app/apps/github/src/diffs/patch.ts +20 -11
- package/app/apps/github/src/history/commit-diff.ts +10 -5
- package/app/apps/github/src/history/commit-list.tsx +3 -1
- package/app/apps/github/src/history/commit-page.tsx +4 -2
- package/app/apps/github/src/history/history.ts +12 -10
- package/app/apps/github/src/hooks/allowed.ts +9 -9
- package/app/apps/github/src/hooks/avatars.ts +3 -3
- package/app/apps/github/src/hooks/open-counts.ts +5 -4
- package/app/apps/github/src/hooks/profiles.ts +26 -12
- package/app/apps/github/src/hooks/repos.ts +78 -25
- package/app/apps/github/src/inbox/count.ts +30 -29
- package/app/apps/github/src/inbox/inbox-item.tsx +3 -1
- package/app/apps/github/src/inbox/inbox-page.tsx +5 -2
- package/app/apps/github/src/inbox/marks.ts +26 -15
- package/app/apps/github/src/inbox/release-tags.ts +7 -6
- package/app/apps/github/src/inbox/subjects.ts +5 -4
- package/app/apps/github/src/inbox/subscription-controls.tsx +14 -5
- package/app/apps/github/src/inbox/subscriptions.ts +95 -35
- package/app/apps/github/src/inbox/threads.ts +6 -6
- package/app/apps/github/src/issues/changes.ts +40 -16
- package/app/apps/github/src/issues/counts.ts +8 -5
- package/app/apps/github/src/issues/issue-list.tsx +20 -6
- package/app/apps/github/src/issues/issue-page.tsx +30 -14
- package/app/apps/github/src/issues/issues.ts +195 -46
- package/app/apps/github/src/issues/label-dialog.tsx +8 -11
- package/app/apps/github/src/issues/labels-page.tsx +35 -3
- package/app/apps/github/src/issues/milestone-dialog.tsx +197 -0
- package/app/apps/github/src/issues/milestones-page.tsx +269 -0
- package/app/apps/github/src/issues/new-issue.tsx +3 -1
- package/app/apps/github/src/issues/sidebar.tsx +8 -6
- package/app/apps/github/src/markdown/README.md +22 -17
- package/app/apps/github/src/markdown/context.ts +83 -10
- package/app/apps/github/src/markdown/images.ts +3 -2
- package/app/apps/github/src/markdown/lookup.ts +17 -11
- package/app/apps/github/src/markdown/page-budget.ts +50 -0
- package/app/apps/github/src/markdown/patches.ts +74 -32
- package/app/apps/github/src/markdown/query.ts +7 -2
- package/app/apps/github/src/markdown/remote.ts +106 -0
- package/app/apps/github/src/markdown/render.ts +101 -24
- package/app/apps/github/src/markdown/texts.ts +43 -0
- package/app/apps/github/src/markdown/words-module.d.ts +5 -0
- package/app/apps/github/src/markdown/words-plugin.ts +135 -0
- package/app/apps/github/src/names/repos.ts +1 -1
- package/app/apps/github/src/palette/palette.tsx +28 -10
- package/app/apps/github/src/palette/rows.tsx +93 -40
- package/app/apps/github/src/palette/server.ts +10 -7
- package/app/apps/github/src/palette/targets.ts +1 -0
- package/app/apps/github/src/policy.ts +137 -61
- package/app/apps/github/src/private-repos.ts +5 -5
- package/app/apps/github/src/pulls/compare-page.tsx +6 -3
- package/app/apps/github/src/pulls/files-tab.tsx +480 -214
- package/app/apps/github/src/pulls/held-summary.ts +178 -0
- package/app/apps/github/src/pulls/live.ts +6 -4
- package/app/apps/github/src/pulls/merge-box.tsx +17 -10
- package/app/apps/github/src/pulls/pull-list.tsx +6 -3
- package/app/apps/github/src/pulls/pull-page.tsx +19 -10
- package/app/apps/github/src/pulls/pull.ts +68 -40
- package/app/apps/github/src/pulls/pulls.ts +39 -22
- package/app/apps/github/src/pulls/review-drafts.ts +131 -0
- package/app/apps/github/src/pulls/review.ts +374 -99
- package/app/apps/github/src/pulls/threads.tsx +152 -0
- package/app/apps/github/src/queue/queue-page.tsx +15 -8
- package/app/apps/github/src/queue/queue.ts +35 -20
- package/app/apps/github/src/releases/latest-release.tsx +3 -1
- package/app/apps/github/src/releases/overview.tsx +4 -2
- package/app/apps/github/src/releases/release-form.tsx +8 -5
- package/app/apps/github/src/releases/release-list.tsx +8 -5
- package/app/apps/github/src/releases/release-view.tsx +1 -0
- package/app/apps/github/src/releases/releases.ts +33 -23
- package/app/apps/github/src/releases/tag-list.tsx +3 -1
- package/app/apps/github/src/router.tsx +5 -2
- package/app/apps/github/src/routes/$owner/$repo/_code/blob/$.tsx +7 -1
- package/app/apps/github/src/routes/$owner/$repo/_code/tree/$.tsx +6 -1
- package/app/apps/github/src/routes/$owner/$repo/_releases/releases/index.tsx +2 -1
- package/app/apps/github/src/routes/$owner/$repo/_releases/tags.tsx +1 -1
- package/app/apps/github/src/routes/$owner/$repo/branches.tsx +5 -1
- package/app/apps/github/src/routes/$owner/$repo/commit/$sha.tsx +1 -1
- package/app/apps/github/src/routes/$owner/$repo/commits/$.tsx +6 -1
- package/app/apps/github/src/routes/$owner/$repo/index.tsx +1 -1
- package/app/apps/github/src/routes/$owner/$repo/issues/$number.tsx +4 -2
- package/app/apps/github/src/routes/$owner/$repo/issues/index.tsx +2 -2
- package/app/apps/github/src/routes/$owner/$repo/issues/new.tsx +5 -2
- package/app/apps/github/src/routes/$owner/$repo/labels.tsx +2 -1
- package/app/apps/github/src/routes/$owner/$repo/milestones.tsx +36 -0
- package/app/apps/github/src/routes/$owner/$repo/pull/$number/route.tsx +4 -2
- package/app/apps/github/src/routes/$owner/$repo/pulls/index.tsx +2 -2
- package/app/apps/github/src/routes/$owner/$repo/queue.tsx +2 -1
- package/app/apps/github/src/routes/$owner/$repo/releases/edit/$.tsx +5 -2
- package/app/apps/github/src/routes/$owner/$repo/releases/new.tsx +2 -1
- package/app/apps/github/src/routes/$owner/$repo/releases/tag/$.tsx +4 -2
- package/app/apps/github/src/routes/$owner/$repo/route.tsx +9 -5
- package/app/apps/github/src/routes/$owner/$repo/settings/hooks/index.tsx +3 -1
- package/app/apps/github/src/routes/$owner/$repo/settings/index.tsx +3 -1
- package/app/apps/github/src/routes/-nav.tsx +10 -2
- package/app/apps/github/src/routes/-root-testing.ts +29 -6
- package/app/apps/github/src/routes/__root.tsx +9 -4
- package/app/apps/github/src/routes/index.tsx +3 -1
- package/app/apps/github/src/routes/orgs/$owner/route.tsx +4 -1
- package/app/apps/github/src/routes/orgs/$owner/settings.tsx +4 -1
- package/app/apps/github/src/seed/acme.ts +1 -1
- package/app/apps/github/src/seed/seed.ts +199 -120
- package/app/apps/github/src/server.ts +24 -15
- package/app/apps/github/src/settings/account-avatar.tsx +4 -1
- package/app/apps/github/src/settings/general-settings.tsx +3 -1
- package/app/apps/github/src/settings/general.ts +4 -4
- package/app/apps/github/src/settings/hook-form.tsx +3 -1
- package/app/apps/github/src/settings/hook-list.tsx +5 -2
- package/app/apps/github/src/settings/hooks.ts +7 -7
- package/app/apps/github/src/settings/org-settings.tsx +3 -1
- package/app/apps/github/src/settings/orgs.ts +21 -11
- package/app/apps/github/src/settings/settings-layout.tsx +3 -1
- package/app/apps/github/src/signin/approval.ts +4 -3
- package/app/apps/github/src/signin/auth.ts +9 -2
- package/app/apps/github/src/signin/device-code.ts +8 -3
- package/app/apps/github/src/signin/device-prompt.ts +28 -3
- package/app/apps/github/src/signin/revoke.ts +36 -0
- package/app/apps/github/tsconfig.json +4 -1
- package/app/apps/github/vite.config.ts +8 -0
- package/app/pnpm-workspace.yaml +9 -5
- package/app/tsconfig.base.json +1 -0
- package/dist/cli/child.mjs +1 -1
- package/dist/cli/credentials.mjs +4 -4
- package/dist/cli/documents.mjs +32 -22
- package/dist/cli/events.mjs +1 -1
- package/dist/cli/failure.mjs +20 -7
- package/dist/cli/folders.mjs +2 -2
- package/dist/cli/git-remote-ref0.mjs +47 -22
- package/dist/cli/git.mjs +26 -5
- package/dist/cli/helpers.mjs +168 -35
- package/dist/cli/hosts.mjs +3 -3
- package/dist/cli/output.mjs +2 -2
- package/dist/cli/prompt.mjs +1 -1
- package/dist/cli/queue.mjs +7 -7
- package/dist/cli/ref0-git.mjs +2 -2
- package/dist/cli/repos.mjs +35 -18
- package/dist/cli/resources.mjs +5 -5
- package/dist/cli/retry-after.mjs +8 -0
- package/dist/cli/setup.mjs +172 -66
- package/dist/cli/sign-in.mjs +65 -23
- package/dist/cli/sign-ins.mjs +70 -13
- package/dist/cli/sqlite.mjs +2 -2
- package/dist/cli/tokens.mjs +3 -3
- package/dist/cli/vendor.mjs +1 -1
- package/dist/init/app.mjs +18 -20
- package/dist/init/choices.mjs +1 -1
- package/dist/init/cloudflare.mjs +15 -19
- package/dist/init/create.mjs +4 -3
- package/dist/init/detect.mjs +4 -4
- package/dist/init/files.mjs +121 -9
- package/dist/init/frameworks.mjs +16 -0
- package/dist/init/git-module.mjs +22 -7
- package/dist/init/jsonc.mjs +9 -7
- package/dist/init/metadata.mjs +9 -3
- package/dist/init/mounts.mjs +13 -10
- package/dist/init/next.mjs +3 -5
- package/dist/init/node-app.mjs +3 -3
- package/dist/init/node.mjs +41 -42
- package/dist/init/nuxt.mjs +153 -27
- package/dist/init/stores.mjs +14 -9
- package/dist/init/sveltekit.mjs +4 -2
- package/dist/init/template.mjs +9 -6
- package/dist/init/templates.mjs +64 -48
- package/dist/init/vercel.mjs +37 -36
- package/dist/init/versions.mjs +3 -3
- package/package.json +6 -5
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import { accept,
|
|
1
|
+
import { accept, gitError, Rules, reject } from '@ref0/git';
|
|
2
2
|
import type {
|
|
3
3
|
ActorId,
|
|
4
4
|
AuthorizeInput,
|
|
5
|
+
GitError,
|
|
5
6
|
GitAuthorize,
|
|
6
7
|
NamedActor,
|
|
7
8
|
PushRule,
|
|
8
9
|
RefName,
|
|
9
|
-
|
|
10
|
+
RepoName,
|
|
10
11
|
TokenInfo,
|
|
11
12
|
TokenOperation,
|
|
12
13
|
} from '@ref0/git';
|
|
13
|
-
import { defaultOrg, defaultPeople } from '@ref0/github';
|
|
14
|
+
import { defaultOrg, defaultPeople, People } from '@ref0/github';
|
|
14
15
|
import type {
|
|
15
16
|
GitHubAuthorization,
|
|
16
17
|
GitHubAuthorize,
|
|
@@ -33,6 +34,7 @@ import type {
|
|
|
33
34
|
PeopleUser,
|
|
34
35
|
PeopleViewer,
|
|
35
36
|
} from '@ref0/github';
|
|
37
|
+
import * as Effect from 'effect/Effect';
|
|
36
38
|
|
|
37
39
|
import { type StarterApprovalOptions, starterApprovalPage } from './signin/approval.ts';
|
|
38
40
|
import type { Account, Avatars, Membership } from './context/context.ts';
|
|
@@ -50,7 +52,7 @@ import { orgTokenView, type Orgs } from './signin/orgs.ts';
|
|
|
50
52
|
/** How long a sign-in lasts before the person signs in again. */
|
|
51
53
|
export const tokenDays = 30;
|
|
52
54
|
|
|
53
|
-
const ownerOf = (repo:
|
|
55
|
+
const ownerOf = (repo: RepoName) => repo.split('/', 1)[0];
|
|
54
56
|
|
|
55
57
|
/** A page of one of the directory's lists, as `People` answers one. */
|
|
56
58
|
interface Listed<Item> {
|
|
@@ -87,6 +89,16 @@ const refusedLookup = (input: PeopleInput): PeopleAnswer => {
|
|
|
87
89
|
}
|
|
88
90
|
};
|
|
89
91
|
|
|
92
|
+
/**
|
|
93
|
+
* A read of the starter's own tables, as the directory's Effect: one that rejects fails closed as
|
|
94
|
+
* Git's `UNAVAILABLE`, in fixed words, so neither D1's error nor its words reach the drop-in.
|
|
95
|
+
*/
|
|
96
|
+
const read = <A>(run: () => Promise<A>): Effect.Effect<A, GitError> =>
|
|
97
|
+
Effect.tryPromise({
|
|
98
|
+
try: run,
|
|
99
|
+
catch: () => gitError('UNAVAILABLE', "The starter's directory can't be read now"),
|
|
100
|
+
});
|
|
101
|
+
|
|
90
102
|
/** The orgs' list a directory answers, which the drop-in doesn't name apart. */
|
|
91
103
|
type PeopleOrgs = Extract<PeopleInput, { readonly kind: 'orgs' }>;
|
|
92
104
|
|
|
@@ -117,6 +129,20 @@ const contributions: ReadonlySet<string> = new Set([
|
|
|
117
129
|
'review.create',
|
|
118
130
|
]);
|
|
119
131
|
|
|
132
|
+
/**
|
|
133
|
+
* What the drop-in asks as the author of what it acts on (Q857): an issue's edit, a conversation
|
|
134
|
+
* comment's or a review comment's edit or delete (Q869), and a review thread's resolve, by the
|
|
135
|
+
* pull request's author (Q891).
|
|
136
|
+
*/
|
|
137
|
+
const authorsOwn: ReadonlySet<string> = new Set([
|
|
138
|
+
'issue.update',
|
|
139
|
+
'comment.update',
|
|
140
|
+
'comment.delete',
|
|
141
|
+
'review.update',
|
|
142
|
+
'review.delete',
|
|
143
|
+
'review.resolve',
|
|
144
|
+
]);
|
|
145
|
+
|
|
120
146
|
const signInFirst = reject({ message: 'Sign in first' });
|
|
121
147
|
|
|
122
148
|
/**
|
|
@@ -175,7 +201,7 @@ export type PrivateRepos = (
|
|
|
175
201
|
prefix: string,
|
|
176
202
|
most: number,
|
|
177
203
|
host: GitHubReadableReposInput['host'],
|
|
178
|
-
) => Promise<{ readonly names: readonly
|
|
204
|
+
) => Promise<{ readonly names: readonly RepoName[]; readonly more: boolean }>;
|
|
179
205
|
|
|
180
206
|
/**
|
|
181
207
|
* Where the drop-in's people find an uploaded picture (Q757): the app's origin, whose
|
|
@@ -233,9 +259,11 @@ export const hostPolicy = (orgs: Orgs, options: HostPolicyOptions = {}): HostPol
|
|
|
233
259
|
};
|
|
234
260
|
|
|
235
261
|
/** An org as `defaultOrg` makes it, with its upload's `avatar_url` when it has one. */
|
|
236
|
-
const orgOf =
|
|
237
|
-
|
|
238
|
-
|
|
262
|
+
const orgOf = Effect.fnUntraced(function* (login: string) {
|
|
263
|
+
const org = yield* defaultOrg(login);
|
|
264
|
+
const picture = yield* read(async () => pictureOf(login, await orgs.account(login)));
|
|
265
|
+
|
|
266
|
+
return { ...org, ...picture } satisfies GitHubOrg;
|
|
239
267
|
});
|
|
240
268
|
|
|
241
269
|
/**
|
|
@@ -290,13 +318,16 @@ export const hostPolicy = (orgs: Orgs, options: HostPolicyOptions = {}): HostPol
|
|
|
290
318
|
owner === actor.id || (owner !== undefined && (await belongs(actor, owner)));
|
|
291
319
|
|
|
292
320
|
/**
|
|
293
|
-
* Git's `authorize`: public repos for anyone to read and list,
|
|
294
|
-
* the caller's token still holds.
|
|
321
|
+
* Git's `authorize`: public repos for anyone to read and list, who they are for anyone signed in,
|
|
322
|
+
* and the rest for a repo's owner, once the caller's token still holds.
|
|
295
323
|
*/
|
|
296
324
|
const authorize: GitAuthorize = async (input: AuthorizeInput) => {
|
|
297
325
|
const { actor, operation, repo } = input;
|
|
298
326
|
if (!(await tokenHolds(input))) return tokenEnded;
|
|
299
327
|
|
|
328
|
+
// Who the caller is, at Git's `/me`: theirs, once their token holds.
|
|
329
|
+
if (operation.kind === 'me') return actor.anonymous === true ? signInFirst : accept();
|
|
330
|
+
|
|
300
331
|
const reads = operation.kind === 'read' || operation.kind === 'fetch';
|
|
301
332
|
if (reads && repo?.public === true) return accept();
|
|
302
333
|
|
|
@@ -402,20 +433,24 @@ export const hostPolicy = (orgs: Orgs, options: HostPolicyOptions = {}): HostPol
|
|
|
402
433
|
|
|
403
434
|
/**
|
|
404
435
|
* The drop-in's `authorize`: a public repo's reads for anyone, as Git's, and its contributions
|
|
405
|
-
* for anyone signed in,
|
|
436
|
+
* for anyone signed in, an issue's author's edit of it, and a comment's or a review comment's
|
|
437
|
+
* author's edit or delete of it, for them, but a hook's for its owner. A review's body is its
|
|
438
|
+
* author's alone, as on GitHub: not the owner's, nor the admin's unless they wrote it. An org's members, teams and hooks are its
|
|
406
439
|
* own members' alone, as GitHub shows outsiders only public members and this host keeps none
|
|
407
440
|
* public (#644). A person's own account, such as their notifications, is theirs once signed in.
|
|
408
441
|
* Everything else is the owner's and the admin's. A token that no longer holds gets nothing, as
|
|
409
442
|
* in Git's, its own account included.
|
|
410
443
|
*/
|
|
411
|
-
const authorizeGitHub: GitHubAuthorize =
|
|
444
|
+
const authorizeGitHub: GitHubAuthorize = Effect.fnUntraced(function* (
|
|
445
|
+
input: GitHubAuthorization,
|
|
446
|
+
) {
|
|
412
447
|
const { actor, operation } = input;
|
|
413
|
-
if (!(
|
|
448
|
+
if (!(yield* read(() => tokenHolds(input)))) return tokenEnded;
|
|
414
449
|
|
|
415
450
|
if ('org' in operation) {
|
|
416
451
|
if (actor.anonymous === true) return signInFirst;
|
|
417
452
|
|
|
418
|
-
return actor.id === admin.id || (
|
|
453
|
+
return actor.id === admin.id || (yield* read(() => owns(actor, operation.org)))
|
|
419
454
|
? accept()
|
|
420
455
|
: reject({ message: "Only the org's members may do this" });
|
|
421
456
|
}
|
|
@@ -432,12 +467,25 @@ export const hostPolicy = (orgs: Orgs, options: HostPolicyOptions = {}): HostPol
|
|
|
432
467
|
|
|
433
468
|
if (actor.anonymous === true) return signInFirst;
|
|
434
469
|
|
|
470
|
+
// GitHub lets only a review's author edit its body, so no one else does here, the admin
|
|
471
|
+
// included: the drop-in asks it as the author only once its own read shows the caller wrote it.
|
|
472
|
+
if (operation.kind === 'review.edit') {
|
|
473
|
+
return operation.asAuthor === true
|
|
474
|
+
? accept()
|
|
475
|
+
: reject({ message: "Only a review's author can edit its body" });
|
|
476
|
+
}
|
|
477
|
+
|
|
435
478
|
if (actor.id === admin.id || (visible && contributions.has(operation.kind))) return accept();
|
|
436
479
|
|
|
437
|
-
|
|
480
|
+
// The drop-in asks an issue's edit, or a comment's or a review comment's edit or delete, as its
|
|
481
|
+
// author only once its own read shows the caller wrote it (Q857), so the caller's token
|
|
482
|
+
// holding the repo is all that's left to ask.
|
|
483
|
+
if (operation.asAuthor === true && authorsOwn.has(operation.kind)) return accept();
|
|
484
|
+
|
|
485
|
+
return (yield* read(() => owns(actor, ownerOf(operation.repo))))
|
|
438
486
|
? accept()
|
|
439
487
|
: reject({ message: 'Only the owner may do this' });
|
|
440
|
-
};
|
|
488
|
+
});
|
|
441
489
|
|
|
442
490
|
/**
|
|
443
491
|
* The owner index's hook: every private repo under `owner` for its owner, a person's own login
|
|
@@ -474,63 +522,68 @@ export const hostPolicy = (orgs: Orgs, options: HostPolicyOptions = {}): HostPol
|
|
|
474
522
|
|
|
475
523
|
// A person by the name they go by, as GitHub names someone who set one: a merge the drop-in
|
|
476
524
|
// makes for them is authored under it.
|
|
477
|
-
const user =
|
|
478
|
-
const person =
|
|
525
|
+
const user = Effect.fnUntraced(function* (input: PeopleUser) {
|
|
526
|
+
const person = yield* read(() => orgs.person(input.login));
|
|
479
527
|
if (person === undefined) return undefined;
|
|
480
528
|
|
|
481
|
-
const found =
|
|
529
|
+
const found = yield* base(input);
|
|
482
530
|
if (found === undefined) return undefined;
|
|
483
531
|
|
|
484
|
-
const picture =
|
|
532
|
+
const picture = yield* read(() => pictureOf(input.login, { kind: 'user', id: person.id }));
|
|
485
533
|
|
|
486
|
-
return { ...found, name: person.name, ...picture };
|
|
487
|
-
};
|
|
534
|
+
return { ...found, name: person.name, ...picture } satisfies GitHubUser;
|
|
535
|
+
});
|
|
488
536
|
|
|
489
|
-
const org =
|
|
490
|
-
(
|
|
537
|
+
const org = Effect.fnUntraced(function* (input: PeopleOrg) {
|
|
538
|
+
return (yield* read(() => orgs.org(input.org))) ? yield* orgOf(input.org) : undefined;
|
|
539
|
+
});
|
|
491
540
|
|
|
492
|
-
const members =
|
|
493
|
-
if (input.filter !== 'all') return { items: [] }
|
|
541
|
+
const members = Effect.fnUntraced(function* (input: PeopleMembers) {
|
|
542
|
+
if (input.filter !== 'all') return { items: [] } satisfies Listed<GitHubUser>;
|
|
494
543
|
|
|
495
544
|
const page = { after: input.page?.after, limit: input.page?.limit ?? listedEach };
|
|
496
|
-
const listed =
|
|
497
|
-
const found =
|
|
498
|
-
listed.logins
|
|
545
|
+
const listed = yield* read(() => orgs.members(input.org, { ...page, role: input.role }));
|
|
546
|
+
const found = yield* Effect.forEach(
|
|
547
|
+
listed.logins,
|
|
548
|
+
(login) => user({ ...input, kind: 'user', login }),
|
|
549
|
+
{ concurrency: 'unbounded' },
|
|
499
550
|
);
|
|
500
551
|
const items = found.filter((each) => each !== undefined);
|
|
501
552
|
|
|
502
|
-
return
|
|
503
|
-
|
|
553
|
+
return (
|
|
554
|
+
listed.next === undefined ? { items } : { items, next: listed.next }
|
|
555
|
+
) satisfies Listed<GitHubUser>;
|
|
556
|
+
});
|
|
504
557
|
|
|
505
|
-
const orgsOf =
|
|
506
|
-
|
|
558
|
+
const orgsOf = Effect.fnUntraced(function* (input: PeopleOrgs) {
|
|
559
|
+
const { actor } = input;
|
|
560
|
+
if (actor.anonymous === true) return { items: [] } satisfies Listed<GitHubOrg>;
|
|
507
561
|
|
|
508
562
|
const page = { after: input.page?.after, limit: input.page?.limit ?? listedEach };
|
|
509
|
-
const listed =
|
|
510
|
-
const items =
|
|
511
|
-
listed.logins.filter((login) => reaches(input, login))
|
|
563
|
+
const listed = yield* read(() => orgs.orgsOf(actor.id, page));
|
|
564
|
+
const items = yield* Effect.forEach(
|
|
565
|
+
listed.logins.filter((login) => reaches(input, login)),
|
|
566
|
+
orgOf,
|
|
567
|
+
{ concurrency: 'unbounded' },
|
|
512
568
|
);
|
|
513
569
|
|
|
514
|
-
return
|
|
515
|
-
|
|
570
|
+
return (
|
|
571
|
+
listed.next === undefined ? { items } : { items, next: listed.next }
|
|
572
|
+
) satisfies Listed<GitHubOrg>;
|
|
573
|
+
});
|
|
516
574
|
|
|
517
|
-
function
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
function lookup(input: PeopleMembers | PeopleTeamMembers): Promise<Listed<GitHubUser>>;
|
|
521
|
-
function lookup(input: PeopleTeams): Promise<Listed<GitHubTeam>>;
|
|
522
|
-
function lookup(input: PeopleMembership): Promise<readonly string[]>;
|
|
523
|
-
function lookup(input: PeopleTeam): Promise<GitHubTeam | undefined>;
|
|
524
|
-
function lookup(input: PeopleSearch): Promise<PeopleSearchAnswer>;
|
|
525
|
-
async function lookup(input: PeopleInput): Promise<PeopleAnswer> {
|
|
526
|
-
// A token whose person left the org it's over reads no one and lists nothing: `/user` 404s,
|
|
527
|
-
// as every other use of it is refused.
|
|
528
|
-
if (!(await tokenHolds(input))) return refusedLookup(input);
|
|
575
|
+
const search = Effect.fnUntraced(function* (input: PeopleSearch) {
|
|
576
|
+
// A range of each index, read to the limit: it never stops short of its own accord.
|
|
577
|
+
const found = yield* read(() => orgs.search(input.prefix, input.limit, input.type));
|
|
529
578
|
|
|
579
|
+
return { found, incomplete: false } satisfies PeopleSearchAnswer;
|
|
580
|
+
});
|
|
581
|
+
|
|
582
|
+
const answer = (input: PeopleInput): Effect.Effect<PeopleAnswer, GitError> => {
|
|
530
583
|
switch (input.kind) {
|
|
531
584
|
case 'viewer':
|
|
532
585
|
return input.actor.anonymous === true
|
|
533
|
-
? undefined
|
|
586
|
+
? Effect.succeed(undefined)
|
|
534
587
|
: user({ ...input, kind: 'user', login: input.actor.id });
|
|
535
588
|
case 'user':
|
|
536
589
|
return user(input);
|
|
@@ -539,15 +592,11 @@ export const hostPolicy = (orgs: Orgs, options: HostPolicyOptions = {}): HostPol
|
|
|
539
592
|
case 'orgs':
|
|
540
593
|
return orgsOf(input);
|
|
541
594
|
case 'search':
|
|
542
|
-
|
|
543
|
-
return {
|
|
544
|
-
found: await orgs.search(input.prefix, input.limit, input.type),
|
|
545
|
-
incomplete: false,
|
|
546
|
-
};
|
|
595
|
+
return search(input);
|
|
547
596
|
case 'members':
|
|
548
597
|
return members(input);
|
|
549
598
|
case 'membership':
|
|
550
|
-
return orgs.among(input.org, input.logins);
|
|
599
|
+
return read(() => orgs.among(input.org, input.logins));
|
|
551
600
|
case 'team-members':
|
|
552
601
|
return base(input);
|
|
553
602
|
case 'teams':
|
|
@@ -555,9 +604,30 @@ export const hostPolicy = (orgs: Orgs, options: HostPolicyOptions = {}): HostPol
|
|
|
555
604
|
case 'team':
|
|
556
605
|
return base(input);
|
|
557
606
|
}
|
|
607
|
+
};
|
|
608
|
+
|
|
609
|
+
function lookup(
|
|
610
|
+
input: PeopleViewer | PeopleUser,
|
|
611
|
+
): Effect.Effect<GitHubUser | undefined, GitError>;
|
|
612
|
+
function lookup(input: PeopleOrg): Effect.Effect<GitHubOrg | undefined, GitError>;
|
|
613
|
+
function lookup(input: PeopleOrgs): Effect.Effect<Listed<GitHubOrg>, GitError>;
|
|
614
|
+
function lookup(
|
|
615
|
+
input: PeopleMembers | PeopleTeamMembers,
|
|
616
|
+
): Effect.Effect<Listed<GitHubUser>, GitError>;
|
|
617
|
+
function lookup(input: PeopleTeams): Effect.Effect<Listed<GitHubTeam>, GitError>;
|
|
618
|
+
function lookup(input: PeopleMembership): Effect.Effect<readonly string[], GitError>;
|
|
619
|
+
function lookup(input: PeopleTeam): Effect.Effect<GitHubTeam | undefined, GitError>;
|
|
620
|
+
function lookup(input: PeopleSearch): Effect.Effect<PeopleSearchAnswer, GitError>;
|
|
621
|
+
function lookup(input: PeopleInput): Effect.Effect<PeopleAnswer, GitError> {
|
|
622
|
+
// A token whose person left the org it's over reads no one and lists nothing: `/user` 404s,
|
|
623
|
+
// as every other use of it is refused.
|
|
624
|
+
return Effect.flatMap(
|
|
625
|
+
read(() => tokenHolds(input)),
|
|
626
|
+
(holds) => (holds ? answer(input) : Effect.succeed(refusedLookup(input))),
|
|
627
|
+
);
|
|
558
628
|
}
|
|
559
629
|
|
|
560
|
-
return lookup;
|
|
630
|
+
return People.make(lookup);
|
|
561
631
|
};
|
|
562
632
|
|
|
563
633
|
return { authorize, authorizeGitHub, people, readableRepos };
|
|
@@ -575,12 +645,12 @@ export interface HostRule {
|
|
|
575
645
|
*/
|
|
576
646
|
export const hostRules: readonly HostRule[] = [
|
|
577
647
|
// `main` takes fast-forwards only, so no one, an owner included, force-pushes or deletes it (#193).
|
|
578
|
-
{ rule:
|
|
648
|
+
{ rule: Rules.protect('refs/heads/main'), covers: ['refs/heads/main'] },
|
|
579
649
|
// Every branch and tag refuses a push that adds or changes one of these files, which usually
|
|
580
650
|
// hold secrets. `git push -o allow-files` asks `authorize` instead. Edit the list, or delete
|
|
581
651
|
// the line.
|
|
582
652
|
{
|
|
583
|
-
rule:
|
|
653
|
+
rule: Rules.files(['**', 'refs/tags/**'], {
|
|
584
654
|
refuse: [
|
|
585
655
|
'.env',
|
|
586
656
|
'.env.*',
|
|
@@ -591,10 +661,16 @@ export const hostRules: readonly HostRule[] = [
|
|
|
591
661
|
'**/id_ed25519',
|
|
592
662
|
],
|
|
593
663
|
}),
|
|
594
|
-
covers: ['refs/heads
|
|
664
|
+
covers: ['refs/heads/**', 'refs/tags/**'],
|
|
595
665
|
},
|
|
596
666
|
];
|
|
597
667
|
|
|
668
|
+
/**
|
|
669
|
+
* Git's `identify`, as the approval page asks it. A host's `git.ts` gives its callback this return
|
|
670
|
+
* type, since `createGitServer`'s type is inferred from options that name `git`.
|
|
671
|
+
*/
|
|
672
|
+
export type Identify = StarterApprovalOptions['identify'];
|
|
673
|
+
|
|
598
674
|
/** The device flow's approval page: the person signed in approves a device for themselves. */
|
|
599
675
|
export const approvalPage = (options: Omit<StarterApprovalOptions, 'tokenDays'>) =>
|
|
600
676
|
starterApprovalPage({ ...options, tokenDays });
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Actor, GitServer,
|
|
1
|
+
import type { Actor, GitServer, RepoName } from '@ref0/git';
|
|
2
2
|
|
|
3
3
|
import { admin } from './policy.ts';
|
|
4
4
|
import type { PrivateRepos } from './policy.ts';
|
|
@@ -14,9 +14,9 @@ import type { PrivateRepos } from './policy.ts';
|
|
|
14
14
|
* Its store calls stay within what the search leaves the hook, `most` and 6 more: the signed-out
|
|
15
15
|
* list reads the record of each public name in its page, one call a name, and of the name past
|
|
16
16
|
* it; the host's list reads its created rows and their entries, two; the public index, one; and a
|
|
17
|
-
* server's first sealed cursor reads its key,
|
|
18
|
-
* (`listPublic` and `listCreated` in Git's
|
|
19
|
-
* `store/cursor-seal.ts`).
|
|
17
|
+
* server's first sealed cursor reads its key, one, and adds it when none is stored yet, one more.
|
|
18
|
+
* A server that holds the key reads nothing for it (`listPublic` and `listCreated` in Git's
|
|
19
|
+
* `store/catalogue.ts`, `cursorSeal` in `store/cursor-seal.ts`).
|
|
20
20
|
*/
|
|
21
21
|
export const privateReposOf =
|
|
22
22
|
(git: Pick<GitServer, 'repos'>): PrivateRepos =>
|
|
@@ -40,7 +40,7 @@ export const privateReposOf =
|
|
|
40
40
|
listed(host.list, admin),
|
|
41
41
|
listed(git.repos.list, { anonymous: true }),
|
|
42
42
|
]);
|
|
43
|
-
const open = new Set<
|
|
43
|
+
const open = new Set<RepoName>(shown.names);
|
|
44
44
|
const hidden = all.names.filter((name) => !open.has(name));
|
|
45
45
|
|
|
46
46
|
return { names: hidden, more: !all.whole || !shown.whole };
|
|
@@ -3,6 +3,7 @@ import { useNavigate } from '@tanstack/react-router';
|
|
|
3
3
|
import { ArrowLeftIcon, GitCompareArrowsIcon, GitPullRequestIcon } from 'lucide-react';
|
|
4
4
|
import { useState } from 'react';
|
|
5
5
|
|
|
6
|
+
import { useClients } from '../clients/clients.ts';
|
|
6
7
|
import { Go } from '../code/controls.tsx';
|
|
7
8
|
import { repoHref, type RepoPlace } from '../code/places.ts';
|
|
8
9
|
import { RefSwitcher } from '../code/ref-switcher.tsx';
|
|
@@ -93,6 +94,7 @@ function OpenForm({
|
|
|
93
94
|
readonly basehead: Basehead;
|
|
94
95
|
readonly comparison: Comparison;
|
|
95
96
|
}) {
|
|
97
|
+
const clients = useClients();
|
|
96
98
|
const client = useQueryClient();
|
|
97
99
|
const navigate = useNavigate();
|
|
98
100
|
// One commit's message is the pull request's, as GitHub's form starts it; more name the branch.
|
|
@@ -103,7 +105,7 @@ function OpenForm({
|
|
|
103
105
|
);
|
|
104
106
|
const opened = useMutation({
|
|
105
107
|
mutationFn: (draft: boolean) =>
|
|
106
|
-
openPull(place, { ...basehead, title: title.trim(), body, draft }),
|
|
108
|
+
openPull(clients, place, { ...basehead, title: title.trim(), body, draft }),
|
|
107
109
|
onSuccess: async (number) => {
|
|
108
110
|
await client.invalidateQueries({ queryKey: ['pulls', place.owner, place.repo] });
|
|
109
111
|
await navigate({ href: pullHref(place, number) });
|
|
@@ -184,8 +186,9 @@ function NothingToCompare({ children }: { readonly children: React.ReactNode })
|
|
|
184
186
|
|
|
185
187
|
/** What `basehead`'s comparison shows: the open form or its open pull request, its commits and its diff. */
|
|
186
188
|
function Compared({ place, basehead }: { readonly place: RepoPlace; readonly basehead: Basehead }) {
|
|
187
|
-
const
|
|
188
|
-
const
|
|
189
|
+
const clients = useClients();
|
|
190
|
+
const comparison = useQuery(comparisonOf(clients, place, basehead));
|
|
191
|
+
const open = useQuery(openPullOf(clients, place, basehead));
|
|
189
192
|
const allowed = useAllowed(place);
|
|
190
193
|
const { base, head } = basehead;
|
|
191
194
|
|