zidane-ui 9.5.3 → 9.6.1
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/adapters/index.d.ts +2 -1
- package/dist/adapters/index.js +2 -1
- package/dist/adapters/server-git-host.js +67 -0
- package/dist/adapters/server-host.js +9 -0
- package/dist/adapters/server-oauth-flow.d.ts +2 -2
- package/dist/adapters/server-oauth-flow.js +1 -1
- package/dist/adapters/server-projects.d.ts +53 -2
- package/dist/adapters/server-projects.js +4 -3
- package/dist/adapters/server-session-host.js +112 -4
- package/dist/channels/BindingEditorDialog.js +1 -1
- package/dist/channels/ChannelDefaultsSection.js +1 -1
- package/dist/channels/ChannelsSettingsSection.js +1 -1
- package/dist/channels/ConnectionSetupDialog.js +1 -1
- package/dist/channels/HeldRepliesList.js +1 -1
- package/dist/channels/ProjectChannelsSection.js +1 -1
- package/dist/chat/HostTranscript.js +1 -0
- package/dist/chat/SessionGroupHeader.js +2 -2
- package/dist/chat/composer/ComposerBadges.d.ts +27 -1
- package/dist/chat/composer/ComposerBadges.js +41 -5
- package/dist/chat/composer/ConversationBadges.d.ts +6 -0
- package/dist/chat/composer/ConversationBadges.js +70 -3
- package/dist/chat/composer/DraftPickers.js +4 -0
- package/dist/chat/composer/ServerScopeToggle.d.ts +16 -1
- package/dist/chat/composer/ServerScopeToggle.js +90 -47
- package/dist/chat/composer/index.d.ts +2 -2
- package/dist/chat/composer/use-draft-target.d.ts +18 -2
- package/dist/chat/composer/use-draft-target.js +74 -7
- package/dist/chat/composer/use-new-session-defaults.d.ts +3 -1
- package/dist/chat/composer/use-new-session-defaults.js +19 -14
- package/dist/chat/composer/use-send-prompt.js +2 -2
- package/dist/chat/headless/composer/index.d.ts +2 -2
- package/dist/chat/headless/composer/index.js +2 -2
- package/dist/chat/headless/composer/labels-chrome.d.ts +7 -0
- package/dist/chat/headless/composer/labels-chrome.js +7 -0
- package/dist/chat/headless/composer/labels-editor.d.ts +4 -0
- package/dist/chat/headless/composer/labels-editor.js +4 -0
- package/dist/chat/headless/composer/models.d.ts +2 -0
- package/dist/chat/headless/composer/new-session-defaults.d.ts +12 -1
- package/dist/chat/headless/composer/new-session-defaults.js +30 -1
- package/dist/chat/headless/draft-target.d.ts +27 -6
- package/dist/chat/headless/draft-target.js +36 -3
- package/dist/chat/headless/host.d.ts +7 -0
- package/dist/chat/headless/index.d.ts +4 -4
- package/dist/chat/headless/index.js +26 -26
- package/dist/chat/headless/labels.d.ts +4 -0
- package/dist/chat/headless/send-flow.d.ts +2 -0
- package/dist/chat/headless/send-flow.js +2 -1
- package/dist/chat/headless/session-list.d.ts +4 -0
- package/dist/chat/headless/sidebar/index.d.ts +2 -2
- package/dist/chat/headless/sidebar/labels.d.ts +9 -1
- package/dist/chat/headless/sidebar/labels.js +4 -0
- package/dist/chat/headless/sidebar/rows.d.ts +48 -7
- package/dist/chat/headless/sidebar/rows.js +121 -22
- package/dist/chat/headless/sidebar/types.d.ts +5 -0
- package/dist/chat/headless/transcript/fold-actions.d.ts +8 -3
- package/dist/chat/headless/transcript/fold-actions.js +29 -1
- package/dist/chat/index.d.ts +2 -2
- package/dist/chat/index.js +2 -2
- package/dist/chat/rich-composer/RichComposer.js +58 -11
- package/dist/chat/rich-composer/composer-controls.d.ts +5 -1
- package/dist/chat/rich-composer/composer-controls.js +4 -4
- package/dist/chat/rich-composer/composer-keys.js +2 -2
- package/dist/chat/rich-composer/draft-collab.d.ts +91 -0
- package/dist/chat/rich-composer/draft-collab.js +310 -0
- package/dist/chat/rich-composer/use-composer-editor.d.ts +2 -0
- package/dist/chat/rich-composer/use-draft-collab.d.ts +53 -0
- package/dist/chat/rich-composer/use-draft-collab.js +92 -0
- package/dist/chat/rich-composer/use-draft-mirror.d.ts +11 -0
- package/dist/chat/rich-composer/use-draft-mirror.js +38 -9
- package/dist/chat/sidebar/InboxList.js +1 -1
- package/dist/chat/sidebar/ProjectIcon.d.ts +6 -2
- package/dist/chat/sidebar/ProjectIcon.js +7 -3
- package/dist/chat/sidebar/SessionSidebar.d.ts +30 -1
- package/dist/chat/sidebar/SessionSidebar.js +79 -7
- package/dist/chat/sidebar/SidebarGroupHeader.d.ts +12 -4
- package/dist/chat/sidebar/SidebarGroupHeader.js +70 -28
- package/dist/chat/sidebar/index.d.ts +2 -2
- package/dist/chat/transcript/actions.d.ts +6 -0
- package/dist/chat/transcript/fold.d.ts +2 -1
- package/dist/chat/transcript/fold.js +26 -1
- package/dist/chat/transcript/index.js +3 -3
- package/dist/chat/transcript/notices.d.ts +5 -2
- package/dist/chat/transcript/notices.js +23 -3
- package/dist/chat/transcript/script-input.d.ts +1 -1
- package/dist/components/Avatar.d.ts +36 -0
- package/dist/components/Avatar.js +56 -0
- package/dist/components/AvatarStack.d.ts +58 -0
- package/dist/components/AvatarStack.js +187 -0
- package/dist/components/Tabs.d.ts +6 -1
- package/dist/components/Tabs.js +43 -39
- package/dist/core.css +19 -1
- package/dist/dist/{index-BsoTsm0E.d.ts → index-ChabiHpR.d.ts} +1 -1
- package/dist/dist/index.d.ts +1 -1
- package/dist/git/headless/environment.d.ts +15 -0
- package/dist/git/headless/environment.js +18 -1
- package/dist/git/headless/github.d.ts +11 -0
- package/dist/git/headless/github.js +15 -0
- package/dist/git/headless/host.d.ts +109 -0
- package/dist/git/headless/index.d.ts +5 -4
- package/dist/git/headless/index.js +4 -3
- package/dist/git/headless/labels.d.ts +16 -1
- package/dist/git/headless/labels.js +25 -1
- package/dist/git/testing/contract.d.ts +22 -4
- package/dist/git/testing/contract.js +173 -3
- package/dist/git/testing/index.d.ts +22 -1
- package/dist/git/testing/index.js +135 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +3 -1
- package/dist/labels.d.ts +4 -0
- package/dist/labels.js +4 -0
- package/dist/onboarding/headless/labels.d.ts +4 -0
- package/dist/session/DraftPeopleStack.d.ts +24 -0
- package/dist/session/DraftPeopleStack.js +48 -0
- package/dist/session/NewProjectDialog.d.ts +28 -8
- package/dist/session/NewProjectDialog.js +225 -40
- package/dist/session/PersonCard.d.ts +29 -0
- package/dist/session/PersonCard.js +199 -0
- package/dist/session/ProjectArtifactsSection.d.ts +4 -1
- package/dist/session/ProjectArtifactsSection.js +149 -34
- package/dist/session/ProjectHome.d.ts +1 -1
- package/dist/session/ProjectHome.js +23 -4
- package/dist/session/ProjectName.d.ts +11 -6
- package/dist/session/ProjectName.js +27 -13
- package/dist/session/ProjectPeopleStack.d.ts +26 -0
- package/dist/session/ProjectPeopleStack.js +56 -0
- package/dist/session/ProjectPublishDialog.js +9 -3
- package/dist/session/ProjectSettingsDialog.d.ts +1 -1
- package/dist/session/ProjectSettingsDialog.js +171 -66
- package/dist/session/ProjectShareDialog.d.ts +1 -1
- package/dist/session/ProjectShareDialog.js +16 -6
- package/dist/session/ProjectToolsSection.js +88 -96
- package/dist/session/ProjectUsage.d.ts +4 -1
- package/dist/session/ProjectUsage.js +13 -4
- package/dist/session/SessionDetailsDialog.d.ts +5 -1
- package/dist/session/SessionDetailsDialog.js +67 -10
- package/dist/session/SessionPeopleStack.js +19 -37
- package/dist/session/SessionProjectPicker.d.ts +54 -0
- package/dist/session/SessionProjectPicker.js +175 -0
- package/dist/session/SessionProvider.d.ts +15 -1
- package/dist/session/SessionProvider.js +28 -6
- package/dist/session/UsageSection.d.ts +2 -4
- package/dist/session/UsageSection.js +57 -55
- package/dist/session/headless/draft-collab.d.ts +55 -0
- package/dist/session/headless/draft-collab.js +127 -0
- package/dist/session/headless/draft-room.d.ts +124 -0
- package/dist/session/headless/draft-room.js +340 -0
- package/dist/session/headless/drafts.d.ts +93 -0
- package/dist/session/headless/drafts.js +79 -0
- package/dist/session/headless/fixture-drafts.d.ts +54 -0
- package/dist/session/headless/fixture-drafts.js +286 -0
- package/dist/session/headless/fixture-host.d.ts +18 -2
- package/dist/session/headless/fixture-host.js +41 -7
- package/dist/session/headless/fixture-projects.d.ts +6 -4
- package/dist/session/headless/fixture-projects.js +25 -4
- package/dist/session/headless/host.d.ts +34 -6
- package/dist/session/headless/index.d.ts +6 -3
- package/dist/session/headless/index.js +6 -3
- package/dist/session/headless/labels.d.ts +47 -2
- package/dist/session/headless/labels.js +17 -1
- package/dist/session/headless/people.d.ts +27 -3
- package/dist/session/headless/people.js +38 -20
- package/dist/session/headless/project-artifact-labels.d.ts +7 -0
- package/dist/session/headless/project-artifact-labels.js +7 -0
- package/dist/session/headless/project-artifacts.d.ts +8 -0
- package/dist/session/headless/project-artifacts.js +15 -1
- package/dist/session/headless/project-labels.d.ts +25 -0
- package/dist/session/headless/project-labels.js +25 -0
- package/dist/session/headless/shared-with.d.ts +28 -0
- package/dist/session/headless/shared-with.js +51 -0
- package/dist/session/host-context.d.ts +11 -0
- package/dist/session/host-context.js +14 -0
- package/dist/session/index.d.ts +7 -3
- package/dist/session/index.js +6 -2
- package/dist/session/new-project-parts.d.ts +67 -0
- package/dist/session/new-project-parts.js +470 -0
- package/dist/session/project-artifact-parts.d.ts +2 -1
- package/dist/session/project-artifact-parts.js +5 -2
- package/dist/session/project-people.d.ts +14 -0
- package/dist/session/project-people.js +86 -0
- package/dist/session/share-people.d.ts +12 -0
- package/dist/session/share-people.js +1 -1
- package/dist/session/testing/contract.d.ts +6 -3
- package/dist/session/testing/contract.js +24 -3
- package/dist/session/testing/drafts.contract.d.ts +30 -0
- package/dist/session/testing/drafts.contract.js +126 -0
- package/dist/session/testing/index.d.ts +2 -1
- package/dist/session/testing/index.js +2 -1
- package/dist/session/use-home-projects.d.ts +11 -2
- package/dist/session/use-home-projects.js +142 -5
- package/dist/session/useDraftCollab.d.ts +24 -0
- package/dist/session/useDraftCollab.js +78 -0
- package/dist/settings/headless/search.d.ts +1 -1
- package/dist/settings/index.js +3 -3
- package/dist/settings/sections/providers/CredentialSources.d.ts +5 -5
- package/dist/settings/sections/providers/CredentialSources.js +5 -22
- package/dist/settings/sections/providers/labels.d.ts +1 -9
- package/dist/settings/sections/providers/labels.js +1 -9
- package/dist/styles.css +20 -9
- package/package.json +4 -3
- package/src/styles/sidebar.css +2 -3
|
@@ -115,6 +115,23 @@ function environmentMachineName(kind) {
|
|
|
115
115
|
return parseMachineKind(kind)?.name;
|
|
116
116
|
}
|
|
117
117
|
/**
|
|
118
|
+
* Where a server's session browses for its folder: the machine its environment runs on (`local@gpu`), found by
|
|
119
|
+
* name in the server's machines; `undefined`: the server itself. `null`: a machine the server does not list,
|
|
120
|
+
* with nothing to browse.
|
|
121
|
+
*
|
|
122
|
+
* @param kind - The session's environment kind; absent: the host's own.
|
|
123
|
+
* @param machines - The server's machines (`useServerMachines`).
|
|
124
|
+
*/
|
|
125
|
+
function sessionFolderMachine(kind, machines) {
|
|
126
|
+
const name = kind ? parseMachineKind(kind)?.name : void 0;
|
|
127
|
+
if (!name) return void 0;
|
|
128
|
+
const machine = machines.find((m) => m.name === name);
|
|
129
|
+
return machine ? {
|
|
130
|
+
id: machine.id,
|
|
131
|
+
name: machine.name
|
|
132
|
+
} : null;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
118
135
|
* The environment kind a default place asks for (`worktree@gpu`, `docker`); `undefined` for the host's default.
|
|
119
136
|
*
|
|
120
137
|
* @param place - Where new chats start.
|
|
@@ -122,4 +139,4 @@ function environmentMachineName(kind) {
|
|
|
122
139
|
function newChatPlaceKind(place) {
|
|
123
140
|
return placeEnvironmentKind(place);
|
|
124
141
|
}
|
|
125
|
-
export { environmentBaseKind, environmentKindIcon, environmentMachineName, folderName, machineEnvironmentKind, machinesOf, newChatPlaceKind, resolveDraftDescriptor, resolveDraftEnvironment, withMachines };
|
|
142
|
+
export { environmentBaseKind, environmentKindIcon, environmentMachineName, folderName, machineEnvironmentKind, machinesOf, newChatPlaceKind, resolveDraftDescriptor, resolveDraftEnvironment, sessionFolderMachine, withMachines };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GitHub's rules for a new repository's name, as `GithubRepos.check` applies them: a field can say a name is
|
|
3
|
+
* invalid before asking the host.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Whether GitHub takes `name` for a new repository: letters, digits, `.`, `-` and `_`, 100 at most, not `.` or
|
|
7
|
+
* `..`, and no `.git` ending.
|
|
8
|
+
*
|
|
9
|
+
* @param name - The name.
|
|
10
|
+
*/
|
|
11
|
+
export declare function isGithubRepoName(name: string): boolean;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// src/git/headless/github.ts
|
|
2
|
+
/**
|
|
3
|
+
* GitHub's rules for a new repository's name, as `GithubRepos.check` applies them: a field can say a name is
|
|
4
|
+
* invalid before asking the host.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Whether GitHub takes `name` for a new repository: letters, digits, `.`, `-` and `_`, 100 at most, not `.` or
|
|
8
|
+
* `..`, and no `.git` ending.
|
|
9
|
+
*
|
|
10
|
+
* @param name - The name.
|
|
11
|
+
*/
|
|
12
|
+
function isGithubRepoName(name) {
|
|
13
|
+
return /^[\w.-]{1,100}$/.test(name) && name !== "." && name !== ".." && !/\.git$/i.test(name);
|
|
14
|
+
}
|
|
15
|
+
export { isGithubRepoName };
|
|
@@ -357,6 +357,110 @@ export type GitFolderSearchResult = {
|
|
|
357
357
|
ok: false;
|
|
358
358
|
error: GitHostError;
|
|
359
359
|
};
|
|
360
|
+
/**
|
|
361
|
+
* Why a GitHub call failed: no usable sign-in, a taken or invalid name, refused by GitHub, GitHub's rate limit, or
|
|
362
|
+
* GitHub (or its MCP server) out of reach. `detail`: GitHub's own words.
|
|
363
|
+
*/
|
|
364
|
+
export interface GithubError {
|
|
365
|
+
/** Which of these it is. */
|
|
366
|
+
kind: 'not-signed-in' | 'name-taken' | 'invalid-name' | 'forbidden' | 'rate-limited' | 'unavailable';
|
|
367
|
+
/** GitHub's own words. */
|
|
368
|
+
detail?: string;
|
|
369
|
+
}
|
|
370
|
+
/** Who the person is on GitHub, or why that is unknown (the feature is then hidden). */
|
|
371
|
+
export type GithubStatus = {
|
|
372
|
+
available: true;
|
|
373
|
+
login: string;
|
|
374
|
+
orgs: readonly string[];
|
|
375
|
+
} | {
|
|
376
|
+
available: false;
|
|
377
|
+
error: GithubError;
|
|
378
|
+
};
|
|
379
|
+
/** One of the person's GitHub repositories. */
|
|
380
|
+
export interface GithubRepo {
|
|
381
|
+
/** `owner/name`. */
|
|
382
|
+
fullName: string;
|
|
383
|
+
/** The user or organization that owns it. */
|
|
384
|
+
owner: string;
|
|
385
|
+
/** Its name, without the owner. */
|
|
386
|
+
name: string;
|
|
387
|
+
/** Its page. */
|
|
388
|
+
url: string;
|
|
389
|
+
/** Whether only invited people see it. */
|
|
390
|
+
private: boolean;
|
|
391
|
+
/** Its description on GitHub. */
|
|
392
|
+
description?: string;
|
|
393
|
+
/** Last update (epoch ms). */
|
|
394
|
+
updatedAt?: number;
|
|
395
|
+
/** The branch it opens on. */
|
|
396
|
+
defaultBranch?: string;
|
|
397
|
+
}
|
|
398
|
+
/** What {@link GithubRepos.search} looks for. */
|
|
399
|
+
export interface GithubRepoQuery {
|
|
400
|
+
/** Words in the repository's name, description or topics (GitHub's search). A word with a `:` qualifier is dropped. */
|
|
401
|
+
query?: string;
|
|
402
|
+
/** Only this owner's. Absent: the person's and their organizations'. */
|
|
403
|
+
owner?: string;
|
|
404
|
+
/** At most this many (1 to 100). Absent: the host's default. */
|
|
405
|
+
limit?: number;
|
|
406
|
+
/** The saved server to ask (hosts that reach several). */
|
|
407
|
+
hostId?: string;
|
|
408
|
+
}
|
|
409
|
+
/** A new repository, for {@link GithubRepos.create}. */
|
|
410
|
+
export interface GithubRepoDraft {
|
|
411
|
+
/** The person's login or one of their organizations. */
|
|
412
|
+
owner: string;
|
|
413
|
+
/** Its name, without the owner. */
|
|
414
|
+
name: string;
|
|
415
|
+
/** Whether only invited people see it. */
|
|
416
|
+
private: boolean;
|
|
417
|
+
/** Its description on GitHub. */
|
|
418
|
+
description?: string;
|
|
419
|
+
/** The saved server to create it through (hosts that reach several). */
|
|
420
|
+
hostId?: string;
|
|
421
|
+
}
|
|
422
|
+
/** What {@link GithubRepos.search} answered, most recently updated first. */
|
|
423
|
+
export type GithubRepoSearchResult = {
|
|
424
|
+
ok: true;
|
|
425
|
+
repos: readonly GithubRepo[];
|
|
426
|
+
} | {
|
|
427
|
+
ok: false;
|
|
428
|
+
error: GithubError;
|
|
429
|
+
};
|
|
430
|
+
/** What {@link GithubRepos.check} says about a new repository's name. */
|
|
431
|
+
export type GithubRepoCheckResult = {
|
|
432
|
+
ok: true;
|
|
433
|
+
verdict: 'available' | 'taken' | 'invalid' | 'forbidden';
|
|
434
|
+
} | {
|
|
435
|
+
ok: false;
|
|
436
|
+
error: GithubError;
|
|
437
|
+
};
|
|
438
|
+
/**
|
|
439
|
+
* What {@link GithubRepos.create} answered. `hasApp`: the server has a GitHub App. `appCovered`: its installation covers
|
|
440
|
+
* the new repository; when `hasApp` and not `appCovered`, the server's sandboxes can not clone or push it yet.
|
|
441
|
+
*/
|
|
442
|
+
export type GithubRepoCreateResult = {
|
|
443
|
+
ok: true;
|
|
444
|
+
url: string;
|
|
445
|
+
fullName: string;
|
|
446
|
+
defaultBranch: string;
|
|
447
|
+
hasApp: boolean;
|
|
448
|
+
appCovered: boolean;
|
|
449
|
+
} | {
|
|
450
|
+
ok: false;
|
|
451
|
+
error: GithubError;
|
|
452
|
+
};
|
|
453
|
+
/** The person's GitHub repositories, through their own GitHub sign-in on the host. */
|
|
454
|
+
export interface GithubRepos {
|
|
455
|
+
/** Whether they have a usable sign-in on `hostId` (hosts that reach several saved servers), and their login and organizations. */
|
|
456
|
+
status: (hostId?: string) => Promise<GithubStatus>;
|
|
457
|
+
/** Their repositories and their organizations'. */
|
|
458
|
+
search: (query?: GithubRepoQuery) => Promise<GithubRepoSearchResult>;
|
|
459
|
+
/** Whether `owner/name` can be created on `hostId` (hosts that reach several saved servers). */
|
|
460
|
+
check: (owner: string, name: string, hostId?: string) => Promise<GithubRepoCheckResult>;
|
|
461
|
+
/** Creates a repository with a first commit. */
|
|
462
|
+
create: (draft: GithubRepoDraft) => Promise<GithubRepoCreateResult>;
|
|
463
|
+
}
|
|
360
464
|
/** The git area's host. Leave a member out and what needs it is not shown. */
|
|
361
465
|
export interface GitHost {
|
|
362
466
|
/** Local branches, most recently committed first. Absent: no branch menu. */
|
|
@@ -414,4 +518,9 @@ export interface GitHost {
|
|
|
414
518
|
cloneOnServer?: (hostId: string, input: string, parent: string) => Promise<GitCloneResult>;
|
|
415
519
|
/** Picks a folder on this computer (a native dialog); `null` when cancelled. Absent: no local folder picking. */
|
|
416
520
|
pickFolder?: () => Promise<string | null>;
|
|
521
|
+
/**
|
|
522
|
+
* The person's GitHub repositories, through their own GitHub sign-in on the host. Absent: not offered. Offered, a
|
|
523
|
+
* `status` that is not `available` hides what needs it too.
|
|
524
|
+
*/
|
|
525
|
+
githubRepos?: GithubRepos;
|
|
417
526
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { DraftEnvironment, EnvironmentMachine, WithMachinesOptions, environmentBaseKind, environmentKindIcon, environmentMachineName, folderName, machineEnvironmentKind, machinesOf, newChatPlaceKind, resolveDraftDescriptor, resolveDraftEnvironment, withMachines } from "./environment.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { DraftEnvironment, EnvironmentMachine, WithMachinesOptions, environmentBaseKind, environmentKindIcon, environmentMachineName, folderName, machineEnvironmentKind, machinesOf, newChatPlaceKind, resolveDraftDescriptor, resolveDraftEnvironment, sessionFolderMachine, withMachines } from "./environment.js";
|
|
2
|
+
import { isGithubRepoName } from "./github.js";
|
|
3
|
+
import { GitActionResult, GitBranch, GitBranchPullRequest, GitCheckoutResult, GitCheckoutTarget, GitClone, GitCloneProgress, GitCloneResult, GitCreateFolderQuery, GitCreateFolderResult, GitEnvironmentQuery, GitFolderAllows, GitFolderEntry, GitFolderListing, GitFolderQuery, GitFolderResult, GitFolderSearchQuery, GitFolderSearchResult, GitHost, GitHostError, GitMoveResult, GitMoveTarget, GitPullRequest, GitPullRequestList, GitPullRequestQuery, GitRepoInfo, GitRepoSpec, GitStatus, GitSyncResult, GithubError, GithubRepo, GithubRepoCheckResult, GithubRepoCreateResult, GithubRepoDraft, GithubRepoQuery, GithubRepoSearchResult, GithubRepos, GithubStatus } from "./host.js";
|
|
4
|
+
import { DEFAULT_GIT_LABELS, GitLabels, gitErrorText, githubErrorText } from "./labels.js";
|
|
4
5
|
import { MoveChoice, MoveSessionSubject, leavesWorktree, moveChoices, moveListingCwd, moveSubject } from "./move.js";
|
|
5
6
|
import { DraftRemoteClone, resolveRemoteClone } from "./remote-clone.js";
|
|
6
7
|
import { SandboxFilter, SandboxesSource, sandboxCounts, sandboxMatches, sandboxSpecs, sortSandboxes } from "./sandboxes.js";
|
|
7
8
|
import { SWITCHER_SECTIONS, SwitcherCache, SwitcherEntry, SwitcherSection, SwitcherSectionId, ageIsDuration, clockTime, compactCount, countInLabel, createSwitcherCache, prMatches, readPullRequests, switcherCacheOf, switcherCreates, switcherKey, switcherSections } from "./switcher.js";
|
|
8
9
|
import { GitSyncAction, syncAction, syncSummary, syncTooltip } from "./sync.js";
|
|
9
10
|
import { TeleportCallView, TeleportOutcome, TeleportProgressView, TeleportRequestView, TeleportTargetView, canTeleportTo, movingCount, shownRows, teleportStoppable, workTarget } from "./teleport.js";
|
|
10
|
-
export { DEFAULT_GIT_LABELS, DraftEnvironment, DraftRemoteClone, EnvironmentMachine, GitActionResult, GitBranch, GitBranchPullRequest, GitCheckoutResult, GitCheckoutTarget, GitClone, GitCloneProgress, GitCloneResult, GitCreateFolderQuery, GitCreateFolderResult, GitEnvironmentQuery, GitFolderAllows, GitFolderEntry, GitFolderListing, GitFolderQuery, GitFolderResult, GitFolderSearchQuery, GitFolderSearchResult, GitHost, GitHostError, GitLabels, GitMoveResult, GitMoveTarget, GitPullRequest, GitPullRequestList, GitPullRequestQuery, GitRepoInfo, GitRepoSpec, GitStatus, GitSyncAction, GitSyncResult, MoveChoice, MoveSessionSubject, SWITCHER_SECTIONS, SandboxFilter, SandboxesSource, SwitcherCache, SwitcherEntry, SwitcherSection, SwitcherSectionId, TeleportCallView, TeleportOutcome, TeleportProgressView, TeleportRequestView, TeleportTargetView, WithMachinesOptions, ageIsDuration, canTeleportTo, clockTime, compactCount, countInLabel, createSwitcherCache, environmentBaseKind, environmentKindIcon, environmentMachineName, folderName, gitErrorText, leavesWorktree, machineEnvironmentKind, machinesOf, moveChoices, moveListingCwd, moveSubject, movingCount, newChatPlaceKind, prMatches, readPullRequests, resolveDraftDescriptor, resolveDraftEnvironment, resolveRemoteClone, sandboxCounts, sandboxMatches, sandboxSpecs, shownRows, sortSandboxes, switcherCacheOf, switcherCreates, switcherKey, switcherSections, syncAction, syncSummary, syncTooltip, teleportStoppable, withMachines, workTarget };
|
|
11
|
+
export { DEFAULT_GIT_LABELS, DraftEnvironment, DraftRemoteClone, EnvironmentMachine, GitActionResult, GitBranch, GitBranchPullRequest, GitCheckoutResult, GitCheckoutTarget, GitClone, GitCloneProgress, GitCloneResult, GitCreateFolderQuery, GitCreateFolderResult, GitEnvironmentQuery, GitFolderAllows, GitFolderEntry, GitFolderListing, GitFolderQuery, GitFolderResult, GitFolderSearchQuery, GitFolderSearchResult, GitHost, GitHostError, GitLabels, GitMoveResult, GitMoveTarget, GitPullRequest, GitPullRequestList, GitPullRequestQuery, GitRepoInfo, GitRepoSpec, GitStatus, GitSyncAction, GitSyncResult, GithubError, GithubRepo, GithubRepoCheckResult, GithubRepoCreateResult, GithubRepoDraft, GithubRepoQuery, GithubRepoSearchResult, GithubRepos, GithubStatus, MoveChoice, MoveSessionSubject, SWITCHER_SECTIONS, SandboxFilter, SandboxesSource, SwitcherCache, SwitcherEntry, SwitcherSection, SwitcherSectionId, TeleportCallView, TeleportOutcome, TeleportProgressView, TeleportRequestView, TeleportTargetView, WithMachinesOptions, ageIsDuration, canTeleportTo, clockTime, compactCount, countInLabel, createSwitcherCache, environmentBaseKind, environmentKindIcon, environmentMachineName, folderName, gitErrorText, githubErrorText, isGithubRepoName, leavesWorktree, machineEnvironmentKind, machinesOf, moveChoices, moveListingCwd, moveSubject, movingCount, newChatPlaceKind, prMatches, readPullRequests, resolveDraftDescriptor, resolveDraftEnvironment, resolveRemoteClone, sandboxCounts, sandboxMatches, sandboxSpecs, sessionFolderMachine, shownRows, sortSandboxes, switcherCacheOf, switcherCreates, switcherKey, switcherSections, syncAction, syncSummary, syncTooltip, teleportStoppable, withMachines, workTarget };
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { environmentBaseKind, environmentKindIcon, environmentMachineName, folderName, machineEnvironmentKind, machinesOf, newChatPlaceKind, resolveDraftDescriptor, resolveDraftEnvironment, withMachines } from "./environment.js";
|
|
2
|
-
import {
|
|
1
|
+
import { environmentBaseKind, environmentKindIcon, environmentMachineName, folderName, machineEnvironmentKind, machinesOf, newChatPlaceKind, resolveDraftDescriptor, resolveDraftEnvironment, sessionFolderMachine, withMachines } from "./environment.js";
|
|
2
|
+
import { isGithubRepoName } from "./github.js";
|
|
3
|
+
import { DEFAULT_GIT_LABELS, gitErrorText, githubErrorText } from "./labels.js";
|
|
3
4
|
import { leavesWorktree, moveChoices, moveListingCwd, moveSubject } from "./move.js";
|
|
4
5
|
import { resolveRemoteClone } from "./remote-clone.js";
|
|
5
6
|
import { sandboxCounts, sandboxMatches, sandboxSpecs, sortSandboxes } from "./sandboxes.js";
|
|
6
7
|
import { SWITCHER_SECTIONS, ageIsDuration, clockTime, compactCount, countInLabel, createSwitcherCache, prMatches, readPullRequests, switcherCacheOf, switcherCreates, switcherKey, switcherSections } from "./switcher.js";
|
|
7
8
|
import { syncAction, syncSummary, syncTooltip } from "./sync.js";
|
|
8
9
|
import { canTeleportTo, movingCount, shownRows, teleportStoppable, workTarget } from "./teleport.js";
|
|
9
|
-
export { DEFAULT_GIT_LABELS, SWITCHER_SECTIONS, ageIsDuration, canTeleportTo, clockTime, compactCount, countInLabel, createSwitcherCache, environmentBaseKind, environmentKindIcon, environmentMachineName, folderName, gitErrorText, leavesWorktree, machineEnvironmentKind, machinesOf, moveChoices, moveListingCwd, moveSubject, movingCount, newChatPlaceKind, prMatches, readPullRequests, resolveDraftDescriptor, resolveDraftEnvironment, resolveRemoteClone, sandboxCounts, sandboxMatches, sandboxSpecs, shownRows, sortSandboxes, switcherCacheOf, switcherCreates, switcherKey, switcherSections, syncAction, syncSummary, syncTooltip, teleportStoppable, withMachines, workTarget };
|
|
10
|
+
export { DEFAULT_GIT_LABELS, SWITCHER_SECTIONS, ageIsDuration, canTeleportTo, clockTime, compactCount, countInLabel, createSwitcherCache, environmentBaseKind, environmentKindIcon, environmentMachineName, folderName, gitErrorText, githubErrorText, isGithubRepoName, leavesWorktree, machineEnvironmentKind, machinesOf, moveChoices, moveListingCwd, moveSubject, movingCount, newChatPlaceKind, prMatches, readPullRequests, resolveDraftDescriptor, resolveDraftEnvironment, resolveRemoteClone, sandboxCounts, sandboxMatches, sandboxSpecs, sessionFolderMachine, shownRows, sortSandboxes, switcherCacheOf, switcherCreates, switcherKey, switcherSections, syncAction, syncSummary, syncTooltip, teleportStoppable, withMachines, workTarget };
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* dictionary an app overrides with `<LabelsProvider>` or the `labels` prop of
|
|
4
4
|
* `GitProvider`. Keys you leave out keep the default English label.
|
|
5
5
|
*/
|
|
6
|
-
import { GitPullRequest } from "./host.js";
|
|
6
|
+
import { GitPullRequest, GithubError } from "./host.js";
|
|
7
7
|
type Checks = NonNullable<GitPullRequest['checks']>;
|
|
8
8
|
/** The default English strings of the git components. */
|
|
9
9
|
export declare const DEFAULT_GIT_LABELS: {
|
|
@@ -251,6 +251,13 @@ export declare const DEFAULT_GIT_LABELS: {
|
|
|
251
251
|
gitFolderListFailed: string;
|
|
252
252
|
gitFolderSearchFailed: string;
|
|
253
253
|
gitFolderCreateFailed: string;
|
|
254
|
+
githubNotSignedIn: string;
|
|
255
|
+
githubNameTaken: string;
|
|
256
|
+
githubInvalidName: string;
|
|
257
|
+
githubForbidden: string;
|
|
258
|
+
githubRateLimited: string;
|
|
259
|
+
githubUnavailable: string;
|
|
260
|
+
githubAppUncovered: string;
|
|
254
261
|
sandboxesFilter: string;
|
|
255
262
|
sandboxesFilterAll: string;
|
|
256
263
|
sandboxesFilterLinked: string;
|
|
@@ -295,4 +302,12 @@ export declare function gitErrorText(error: {
|
|
|
295
302
|
code: 'failed';
|
|
296
303
|
message: string;
|
|
297
304
|
}, labels: Pick<GitLabels, 'gitUnavailable'>): string;
|
|
305
|
+
type GithubErrorLabel = 'githubNotSignedIn' | 'githubNameTaken' | 'githubInvalidName' | 'githubForbidden' | 'githubRateLimited' | 'githubUnavailable';
|
|
306
|
+
/**
|
|
307
|
+
* A GitHub error in words (GitHub's own are its `detail`).
|
|
308
|
+
*
|
|
309
|
+
* @param error - The host's error.
|
|
310
|
+
* @param labels - The labels in effect.
|
|
311
|
+
*/
|
|
312
|
+
export declare function githubErrorText(error: Pick<GithubError, 'kind'>, labels: Pick<GitLabels, GithubErrorLabel>): string;
|
|
298
313
|
export {};
|
|
@@ -253,6 +253,13 @@ const DEFAULT_GIT_LABELS = {
|
|
|
253
253
|
gitFolderListFailed: "Couldn't read this folder.",
|
|
254
254
|
gitFolderSearchFailed: "Couldn't search the folders.",
|
|
255
255
|
gitFolderCreateFailed: "Couldn't create the folder.",
|
|
256
|
+
githubNotSignedIn: "Sign in to GitHub to use your repositories.",
|
|
257
|
+
githubNameTaken: "That name is taken.",
|
|
258
|
+
githubInvalidName: "GitHub does not allow that name.",
|
|
259
|
+
githubForbidden: "GitHub refused the request.",
|
|
260
|
+
githubRateLimited: "You reached the GitHub rate limit. Try again in a moment.",
|
|
261
|
+
githubUnavailable: "Could not reach GitHub. Try again.",
|
|
262
|
+
githubAppUncovered: "The server's GitHub App is not installed on this repository. Install it on the repository, or set its installation to all repositories.",
|
|
256
263
|
sandboxesFilter: "Show sandboxes",
|
|
257
264
|
sandboxesFilterAll: "All",
|
|
258
265
|
sandboxesFilterLinked: "In a session",
|
|
@@ -297,4 +304,21 @@ const DEFAULT_GIT_LABELS = {
|
|
|
297
304
|
function gitErrorText(error, labels) {
|
|
298
305
|
return error.code === "failed" ? error.message : labels.gitUnavailable;
|
|
299
306
|
}
|
|
300
|
-
|
|
307
|
+
const GITHUB_ERRORS = {
|
|
308
|
+
"not-signed-in": "githubNotSignedIn",
|
|
309
|
+
"name-taken": "githubNameTaken",
|
|
310
|
+
"invalid-name": "githubInvalidName",
|
|
311
|
+
"forbidden": "githubForbidden",
|
|
312
|
+
"rate-limited": "githubRateLimited",
|
|
313
|
+
"unavailable": "githubUnavailable"
|
|
314
|
+
};
|
|
315
|
+
/**
|
|
316
|
+
* A GitHub error in words (GitHub's own are its `detail`).
|
|
317
|
+
*
|
|
318
|
+
* @param error - The host's error.
|
|
319
|
+
* @param labels - The labels in effect.
|
|
320
|
+
*/
|
|
321
|
+
function githubErrorText(error, labels) {
|
|
322
|
+
return labels[GITHUB_ERRORS[error.kind]];
|
|
323
|
+
}
|
|
324
|
+
export { DEFAULT_GIT_LABELS, gitErrorText, githubErrorText };
|
|
@@ -4,17 +4,17 @@
|
|
|
4
4
|
*
|
|
5
5
|
* An implementation's test calls {@link describeGitHostContract} with a harness factory. The
|
|
6
6
|
* contract hands it a {@link GitHostContractBackend}: the checkout's branches and pull requests,
|
|
7
|
-
* a branch another worktree holds, the environment kinds, the remote folders,
|
|
8
|
-
* action does there. The harness builds the host over a backend that does exactly that. The
|
|
7
|
+
* a branch another worktree holds, the environment kinds, the remote folders, the person's GitHub
|
|
8
|
+
* repositories, and what each action does there. The harness builds the host over a backend that does exactly that. The
|
|
9
9
|
* capabilities list says which optional members the host offers: the suite checks the others are
|
|
10
10
|
* left out (undefined, never a throwing stub) and skips what needs them.
|
|
11
11
|
*
|
|
12
12
|
* describeGitHostContract('createFixtureGitHost', (backend) => ({ host: … }), ['branches', 'checkout']);
|
|
13
13
|
*/
|
|
14
|
-
import { GitBranch, GitBranchPullRequest, GitCloneProgress, GitHost, GitPullRequest, GitRepoInfo, GitRepoSpec, GitStatus } from "../headless/host.js";
|
|
14
|
+
import { GitBranch, GitBranchPullRequest, GitCloneProgress, GitHost, GitPullRequest, GitRepoInfo, GitRepoSpec, GitStatus, GithubRepo, GithubRepoDraft } from "../headless/host.js";
|
|
15
15
|
import { EnvironmentDescriptor } from "zidane/chat";
|
|
16
16
|
/** An optional `GitHost` member. */
|
|
17
|
-
export type GitHostCapability = 'branches' | 'pullRequests' | 'checkout' | 'createBranch' | 'startWorktree' | 'moveSession' | 'environments' | 'subscribeEnvironments' | 'status' | 'subscribeRefs' | 'listFolders' | 'pickFolder' | 'subscribeActivity' | 'branchPullRequest' | 'sync' | 'clone' | 'createFolder' | 'searchFolders' | 'originUrl' | 'cloneOnServer';
|
|
17
|
+
export type GitHostCapability = 'branches' | 'pullRequests' | 'checkout' | 'createBranch' | 'startWorktree' | 'moveSession' | 'environments' | 'subscribeEnvironments' | 'status' | 'subscribeRefs' | 'listFolders' | 'pickFolder' | 'subscribeActivity' | 'branchPullRequest' | 'sync' | 'clone' | 'createFolder' | 'searchFolders' | 'originUrl' | 'cloneOnServer' | 'githubRepos';
|
|
18
18
|
/** What the backend behind the host holds, and what it does with each action. */
|
|
19
19
|
export interface GitHostContractBackend {
|
|
20
20
|
/** The checkout's folder. */
|
|
@@ -100,6 +100,22 @@ export interface GitHostContractBackend {
|
|
|
100
100
|
input: string;
|
|
101
101
|
parent: string;
|
|
102
102
|
}[];
|
|
103
|
+
/**
|
|
104
|
+
* The person on GitHub: their login, their organizations and the repositories GitHub holds (theirs, their
|
|
105
|
+
* organizations' and others'). A search answers those of the login and the organizations (or of `owner`) whose name
|
|
106
|
+
* holds every word, most recently updated first. A name is invalid when GitHub refuses it (`isGithubRepoName` rules),
|
|
107
|
+
* forbidden in an owner that is neither, and taken when a repository has it (any case). A create of a taken name fails
|
|
108
|
+
* with `takenDetail`; one that lands is recorded in `created`, at `https://github.com/<owner>/<name>` on `main`, and
|
|
109
|
+
* the server's App (it has one) covers it when `appCovers` lists it.
|
|
110
|
+
*/
|
|
111
|
+
github: {
|
|
112
|
+
login: string;
|
|
113
|
+
orgs: string[];
|
|
114
|
+
repos: GithubRepo[];
|
|
115
|
+
appCovers: string[];
|
|
116
|
+
takenDetail: string;
|
|
117
|
+
created: GithubRepoDraft[];
|
|
118
|
+
};
|
|
103
119
|
}
|
|
104
120
|
/** A host built over a backend, and what the suite drives on it. */
|
|
105
121
|
export interface GitHostHarness {
|
|
@@ -111,6 +127,8 @@ export interface GitHostHarness {
|
|
|
111
127
|
changeEnvironments?: () => void;
|
|
112
128
|
/** Has the backend report work by a session that may have moved its checkout (needed for `subscribeActivity`). */
|
|
113
129
|
activity?: (sessionId: string) => void;
|
|
130
|
+
/** Has the person's GitHub sign-in stop working (needed for `githubRepos`). */
|
|
131
|
+
signOutGithub?: () => void;
|
|
114
132
|
/** Closes connections and timers after each test. */
|
|
115
133
|
dispose?: () => void;
|
|
116
134
|
}
|
|
@@ -20,10 +20,11 @@ const CAPABILITIES = [
|
|
|
20
20
|
"createFolder",
|
|
21
21
|
"searchFolders",
|
|
22
22
|
"originUrl",
|
|
23
|
-
"cloneOnServer"
|
|
23
|
+
"cloneOnServer",
|
|
24
|
+
"githubRepos"
|
|
24
25
|
];
|
|
25
26
|
/** The capabilities whose member is an object of methods, not a function. */
|
|
26
|
-
const GROUPS = ["clone"];
|
|
27
|
+
const GROUPS = ["clone", "githubRepos"];
|
|
27
28
|
function contractBackend() {
|
|
28
29
|
const pr = (number, extra) => ({
|
|
29
30
|
number,
|
|
@@ -173,7 +174,49 @@ function contractBackend() {
|
|
|
173
174
|
imageUrl: "https://opengraph.githubassets.com/1/o/r"
|
|
174
175
|
}
|
|
175
176
|
},
|
|
176
|
-
cloned: []
|
|
177
|
+
cloned: [],
|
|
178
|
+
github: {
|
|
179
|
+
login: "alex",
|
|
180
|
+
orgs: ["acme"],
|
|
181
|
+
repos: [
|
|
182
|
+
{
|
|
183
|
+
fullName: "alex/notes",
|
|
184
|
+
owner: "alex",
|
|
185
|
+
name: "notes",
|
|
186
|
+
url: "https://github.com/alex/notes",
|
|
187
|
+
private: false,
|
|
188
|
+
updatedAt: 1e3
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
fullName: "acme/site",
|
|
192
|
+
owner: "acme",
|
|
193
|
+
name: "site",
|
|
194
|
+
url: "https://github.com/acme/site",
|
|
195
|
+
private: true,
|
|
196
|
+
updatedAt: 3e3,
|
|
197
|
+
defaultBranch: "main"
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
fullName: "acme/api",
|
|
201
|
+
owner: "acme",
|
|
202
|
+
name: "api",
|
|
203
|
+
url: "https://github.com/acme/api",
|
|
204
|
+
private: false,
|
|
205
|
+
updatedAt: 2e3
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
fullName: "zed/other",
|
|
209
|
+
owner: "zed",
|
|
210
|
+
name: "other",
|
|
211
|
+
url: "https://github.com/zed/other",
|
|
212
|
+
private: false,
|
|
213
|
+
updatedAt: 4e3
|
|
214
|
+
}
|
|
215
|
+
],
|
|
216
|
+
appCovers: ["acme/tool"],
|
|
217
|
+
takenDetail: "422 Repository creation failed: name already exists on this account",
|
|
218
|
+
created: []
|
|
219
|
+
}
|
|
177
220
|
};
|
|
178
221
|
}
|
|
179
222
|
const waitFor = (check) => vi.waitFor(check, {
|
|
@@ -510,6 +553,133 @@ function describeGitHostContract(name, makeHarness, capabilities) {
|
|
|
510
553
|
conflicts: backend.sync.conflicts
|
|
511
554
|
});
|
|
512
555
|
});
|
|
556
|
+
it.skipIf(!has("githubRepos"))("says who the person is on GitHub, and lists their repositories and their organizations'", async () => {
|
|
557
|
+
const { host } = await setup();
|
|
558
|
+
const github = host.githubRepos;
|
|
559
|
+
expect(await github.status()).toEqual({
|
|
560
|
+
available: true,
|
|
561
|
+
login: "alex",
|
|
562
|
+
orgs: ["acme"]
|
|
563
|
+
});
|
|
564
|
+
const names = async (query) => {
|
|
565
|
+
const found = await github.search(query);
|
|
566
|
+
return found.ok ? found.repos.map((repo) => repo.fullName) : found;
|
|
567
|
+
};
|
|
568
|
+
expect(await names()).toEqual([
|
|
569
|
+
"acme/site",
|
|
570
|
+
"acme/api",
|
|
571
|
+
"alex/notes"
|
|
572
|
+
]);
|
|
573
|
+
expect(await names({ owner: "acme" })).toEqual(["acme/site", "acme/api"]);
|
|
574
|
+
expect(await names({ query: "NOT" })).toEqual(["alex/notes"]);
|
|
575
|
+
expect(await names({ limit: 1 })).toEqual(["acme/site"]);
|
|
576
|
+
const site = await github.search({ query: "site" });
|
|
577
|
+
expect(site.ok && site.repos[0]).toEqual({
|
|
578
|
+
fullName: "acme/site",
|
|
579
|
+
owner: "acme",
|
|
580
|
+
name: "site",
|
|
581
|
+
url: "https://github.com/acme/site",
|
|
582
|
+
private: true,
|
|
583
|
+
updatedAt: 3e3,
|
|
584
|
+
defaultBranch: "main"
|
|
585
|
+
});
|
|
586
|
+
});
|
|
587
|
+
it.skipIf(!has("githubRepos"))("checks a new repository's name: available, taken, invalid or forbidden", async () => {
|
|
588
|
+
const { host } = await setup();
|
|
589
|
+
const github = host.githubRepos;
|
|
590
|
+
expect(await github.check("alex", "fresh")).toEqual({
|
|
591
|
+
ok: true,
|
|
592
|
+
verdict: "available"
|
|
593
|
+
});
|
|
594
|
+
expect(await github.check("acme", "SITE")).toEqual({
|
|
595
|
+
ok: true,
|
|
596
|
+
verdict: "taken"
|
|
597
|
+
});
|
|
598
|
+
expect(await github.check("alex", "no spaces")).toEqual({
|
|
599
|
+
ok: true,
|
|
600
|
+
verdict: "invalid"
|
|
601
|
+
});
|
|
602
|
+
expect(await github.check("zed", "fresh")).toEqual({
|
|
603
|
+
ok: true,
|
|
604
|
+
verdict: "forbidden"
|
|
605
|
+
});
|
|
606
|
+
});
|
|
607
|
+
it.skipIf(!has("githubRepos"))("creates a repository, says whether the server's App covers it, and refuses a taken name", async () => {
|
|
608
|
+
const { host, backend } = await setup();
|
|
609
|
+
const github = host.githubRepos;
|
|
610
|
+
expect(await github.create({
|
|
611
|
+
owner: "acme",
|
|
612
|
+
name: "tool",
|
|
613
|
+
private: true,
|
|
614
|
+
description: "A tool"
|
|
615
|
+
})).toEqual({
|
|
616
|
+
ok: true,
|
|
617
|
+
url: "https://github.com/acme/tool",
|
|
618
|
+
fullName: "acme/tool",
|
|
619
|
+
defaultBranch: "main",
|
|
620
|
+
hasApp: true,
|
|
621
|
+
appCovered: true
|
|
622
|
+
});
|
|
623
|
+
expect(await github.create({
|
|
624
|
+
owner: "alex",
|
|
625
|
+
name: "mine",
|
|
626
|
+
private: false
|
|
627
|
+
})).toEqual({
|
|
628
|
+
ok: true,
|
|
629
|
+
url: "https://github.com/alex/mine",
|
|
630
|
+
fullName: "alex/mine",
|
|
631
|
+
defaultBranch: "main",
|
|
632
|
+
hasApp: true,
|
|
633
|
+
appCovered: false
|
|
634
|
+
});
|
|
635
|
+
expect(backend.github.created).toEqual([{
|
|
636
|
+
owner: "acme",
|
|
637
|
+
name: "tool",
|
|
638
|
+
private: true,
|
|
639
|
+
description: "A tool"
|
|
640
|
+
}, {
|
|
641
|
+
owner: "alex",
|
|
642
|
+
name: "mine",
|
|
643
|
+
private: false
|
|
644
|
+
}]);
|
|
645
|
+
expect(await github.create({
|
|
646
|
+
owner: "alex",
|
|
647
|
+
name: "notes",
|
|
648
|
+
private: false
|
|
649
|
+
})).toEqual({
|
|
650
|
+
ok: false,
|
|
651
|
+
error: {
|
|
652
|
+
kind: "name-taken",
|
|
653
|
+
detail: backend.github.takenDetail
|
|
654
|
+
}
|
|
655
|
+
});
|
|
656
|
+
});
|
|
657
|
+
it.skipIf(!has("githubRepos"))("answers not signed in once the person's sign-in stops working", async () => {
|
|
658
|
+
const { host, harness } = await setup();
|
|
659
|
+
const github = host.githubRepos;
|
|
660
|
+
harness.signOutGithub();
|
|
661
|
+
const out = { kind: "not-signed-in" };
|
|
662
|
+
expect(await github.status()).toEqual({
|
|
663
|
+
available: false,
|
|
664
|
+
error: out
|
|
665
|
+
});
|
|
666
|
+
expect(await github.search()).toEqual({
|
|
667
|
+
ok: false,
|
|
668
|
+
error: out
|
|
669
|
+
});
|
|
670
|
+
expect(await github.check("alex", "fresh")).toEqual({
|
|
671
|
+
ok: false,
|
|
672
|
+
error: out
|
|
673
|
+
});
|
|
674
|
+
expect(await github.create({
|
|
675
|
+
owner: "alex",
|
|
676
|
+
name: "fresh",
|
|
677
|
+
private: true
|
|
678
|
+
})).toEqual({
|
|
679
|
+
ok: false,
|
|
680
|
+
error: out
|
|
681
|
+
});
|
|
682
|
+
});
|
|
513
683
|
it.skipIf(!has("clone"))("parses what was pasted, clones it where asked, and refuses in words", async () => {
|
|
514
684
|
const { host, backend } = await setup();
|
|
515
685
|
const clone = host.clone;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* (`createFixtureGitHost`) and its demo data, for docs, demos and an app's
|
|
4
4
|
* own tests. Not for production hosts.
|
|
5
5
|
*/
|
|
6
|
-
import { GitBranch, GitBranchPullRequest, GitCloneProgress, GitFolderAllows, GitHost, GitPullRequest, GitRepoInfo, GitRepoSpec, GitStatus } from "../headless/host.js";
|
|
6
|
+
import { GitBranch, GitBranchPullRequest, GitCloneProgress, GitFolderAllows, GitHost, GitPullRequest, GitRepoInfo, GitRepoSpec, GitStatus, GithubRepo, GithubRepoDraft } from "../headless/host.js";
|
|
7
7
|
import { WORST_CASE_BRANCH, WORST_CASE_GIT, WORST_CASE_GIT_EMPTY } from "./worst-case.js";
|
|
8
8
|
import { EnvironmentDescriptor } from "zidane/chat";
|
|
9
9
|
/** Demo local branches, most recent first. */
|
|
@@ -25,6 +25,21 @@ export declare const DEMO_GIT_STATUS: GitStatus;
|
|
|
25
25
|
export declare const DEMO_GIT_BRANCH_PULL_REQUESTS: Readonly<Record<string, GitBranchPullRequest>>;
|
|
26
26
|
/** The demo repository import: what it parses, where it lands, and what a clone reports. */
|
|
27
27
|
export declare const DEMO_GIT_CLONE: FixtureClone;
|
|
28
|
+
/** The demo person on GitHub: their login, organization and repositories. */
|
|
29
|
+
export declare const DEMO_GITHUB: FixtureGithub;
|
|
30
|
+
/** The person's GitHub repositories held in memory. */
|
|
31
|
+
export interface FixtureGithub {
|
|
32
|
+
/** Their login. */
|
|
33
|
+
login: string;
|
|
34
|
+
/** Their organizations. */
|
|
35
|
+
orgs: readonly string[];
|
|
36
|
+
/** The repositories GitHub holds: theirs, their organizations' and others'. */
|
|
37
|
+
repos: readonly GithubRepo[];
|
|
38
|
+
/** What the server's GitHub App covers: owners (every repository of theirs) or `owner/name`. Absent: the server has no App. */
|
|
39
|
+
appCovers?: readonly string[];
|
|
40
|
+
/** Create fails with this detail for a taken name. */
|
|
41
|
+
takenDetail?: string;
|
|
42
|
+
}
|
|
28
43
|
/** A repository import held in memory. */
|
|
29
44
|
export interface FixtureClone {
|
|
30
45
|
/** What each accepted input parses to. Anything else is not a repository. */
|
|
@@ -86,6 +101,8 @@ export interface FixtureGitOptions {
|
|
|
86
101
|
} | false;
|
|
87
102
|
/** The repository import, also on a server (`cloneOnServer`, with `folders`). `false`: neither. */
|
|
88
103
|
clone?: FixtureClone | false;
|
|
104
|
+
/** The person's GitHub repositories (`DEMO_GITHUB` for the demo). Absent: no `githubRepos`. */
|
|
105
|
+
githubRepos?: FixtureGithub;
|
|
89
106
|
/** Milliseconds each answer takes. Default: 0. */
|
|
90
107
|
latencyMs?: number;
|
|
91
108
|
}
|
|
@@ -124,6 +141,10 @@ export interface FixtureGitHost extends GitHost {
|
|
|
124
141
|
input: string;
|
|
125
142
|
parent: string;
|
|
126
143
|
}[];
|
|
144
|
+
/** The GitHub repositories created, in order. */
|
|
145
|
+
readonly githubCreated: GithubRepoDraft[];
|
|
146
|
+
/** Has the person's GitHub sign-in stop working: every `githubRepos` call answers `not-signed-in`. */
|
|
147
|
+
signOutGithub: () => void;
|
|
127
148
|
}
|
|
128
149
|
/**
|
|
129
150
|
* Creates a {@link GitHost} held in memory. Switching and starting branches change its current
|