Skip to content

Commit 29bf194

Browse files
committed
Add export-schema to legacy API types; remove hand-written TS duplicates
Add schemars-based export-schema annotations and register_sdk_type! calls for types in: - gitbutler-branch-actions (BaseBranch, RemoteCommit, BranchListing, BranchListingDetails, StackOrder, SeriesOrder, and all upstream integration types) - gitbutler-edit-mode (new export-schema feature + ConflictEntryPresence) - but-api/legacy/modes (HeadAndMode, HeadSha) Also: - Add --source-crates filter to but-ts CLI to avoid false name-collision errors when unrelated crates register types with the same schema name - Remove duplicate author.rs from gitbutler-branch-actions; use but_workspace::ui::Author directly - Remove hand-written TypeScript type definitions that duplicated the Rust types, replacing them with imports from @gitbutler/core/api - Re-export but-ts generated types via packages/core/src/generated/legacy.ts I get this error in CI: ``` Error: Error when registering schema TreeStatus for type gitbutler_branch_actions::upstream_integration::TreeStatus registered at crates/gitbutler-branch-actions/src/upstream_integration.rs:48 Duplicate type but_core::ui::TreeStatus was registered at crates/but-core/src/ui.rs:180. Consider renaming one of the types with either `#[serde(rename = ...)]` or `#[schemars(rename = ...)]`. ``` Let's instead rename the rust type. Sorry, I have typescript errors now. Can you help me fix them? save Sorry, please continue
1 parent f1dc121 commit 29bf194

89 files changed

Lines changed: 965 additions & 769 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Cargo.lock

Lines changed: 5 additions & 30 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ gix = { version = "0.81.0", git = "https://github.com/GitoxideLabs/gitoxide", re
216216
] }
217217
gix-testtools = { version = "0.19.0", git = "https://github.com/GitoxideLabs/gitoxide", rev = "50fb46f17acba7d75d4ed6795b7b9cef484e34c6" }
218218

219-
ts-rs = { version = "11.1.0", features = ["serde-compat", "no-serde-warnings"] }
219+
220220
insta = { version = "1.45.1", features = ["json"] }
221221
git2 = { version = "0.20.4", features = [
222222
"vendored-openssl",

apps/desktop/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
},
2121
"devDependencies": {
2222
"@anthropic-ai/sdk": "^0.80.0",
23+
"@gitbutler/but-sdk": "workspace:*",
2324
"@gitbutler/core": "workspace:*",
2425
"@gitbutler/design-core": "2.0.0",
2526
"@gitbutler/shared": "workspace:*",

apps/desktop/src/components/branchesPage/BranchListCard.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<script lang="ts">
22
import BranchesCardLayout from "$components/branchesPage/BranchesCardLayout.svelte";
3-
import { type BranchListing, type BranchListingDetails } from "$lib/branches/branchListing";
43
import { BRANCH_SERVICE } from "$lib/branches/branchService.svelte";
54
import { GIT_CONFIG_SERVICE } from "$lib/config/gitConfigService";
65
import { getPrStatus } from "$lib/forge/interface/prUtils";
@@ -11,6 +10,7 @@
1110
import { gravatarUrlFromEmail } from "@gitbutler/ui/components/avatar/gravatar";
1211
import type { ReviewUnitInfo } from "$lib/forge/interface/forgePrService";
1312
import type { PullRequest } from "$lib/forge/interface/types";
13+
import type { BranchListing, BranchListingDetails } from "@gitbutler/but-sdk";
1414
1515
interface Props {
1616
reviewUnit: ReviewUnitInfo | undefined;

apps/desktop/src/components/commit/AutoCommitModalContent.svelte

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import { untrack } from "svelte";
1515
import { SvelteMap } from "svelte/reactivity";
1616
import type { AutoCommitModalState } from "$lib/state/uiState.svelte";
17-
import type { Action } from "@gitbutler/core/api";
17+
import type { AutoCommitEvent } from "@gitbutler/but-sdk";
1818
1919
type Props = {
2020
data: AutoCommitModalState;
@@ -27,7 +27,7 @@
2727
const stackService = inject(STACK_SERVICE);
2828
const clipboardService = inject(CLIPBOARD_SERVICE);
2929
30-
let events = $state<Action.AutoCommitEvent[]>([]);
30+
let events = $state<AutoCommitEvent[]>([]);
3131
const commitMessageMap = new SvelteMap<string, string>();
3232
3333
// Listen for auto-commit events and update commit messages
@@ -50,7 +50,7 @@
5050
// Check if generation is complete for a parent commit
5151
function isGenerationComplete(
5252
parentCommitId: string | undefined,
53-
events: Action.AutoCommitEvent[],
53+
events: AutoCommitEvent[],
5454
): boolean {
5555
if (!parentCommitId) return false;
5656

apps/desktop/src/components/forge/GitHubAccountBadge.svelte

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
<script lang="ts">
22
import { Badge } from "@gitbutler/ui";
3-
import type { ButGitHubToken } from "@gitbutler/core/api";
3+
import type { GithubAccountIdentifier } from "@gitbutler/but-sdk";
44
55
type Props = {
6-
account: ButGitHubToken.GithubAccountIdentifier;
6+
account: GithubAccountIdentifier;
77
class?: string;
88
};
99
1010
const { account, class: className }: Props = $props();
1111
1212
// const tooltipText = $derived(account.type === 'enterprise' ? 'GitHub Enterprise' : account.type);
1313
// const badgeText = $derived(account.type === 'enterprise' ? account.info.host : account.type);
14-
export function badgeText(account: ButGitHubToken.GithubAccountIdentifier): string | null {
14+
export function badgeText(account: GithubAccountIdentifier): string | null {
1515
switch (account.type) {
1616
case "oAuthUsername":
1717
return null;
@@ -22,7 +22,7 @@
2222
}
2323
}
2424
25-
export function tooltipText(account: ButGitHubToken.GithubAccountIdentifier): string {
25+
export function tooltipText(account: GithubAccountIdentifier): string {
2626
switch (account.type) {
2727
case "oAuthUsername":
2828
return "";

apps/desktop/src/components/forge/GitLabAccountBadge.svelte

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
<script lang="ts">
22
import { Badge } from "@gitbutler/ui";
3-
import type { ButGitLabToken } from "@gitbutler/core/api";
3+
import type { GitlabAccountIdentifier } from "@gitbutler/but-sdk";
44
55
type Props = {
6-
account: ButGitLabToken.GitlabAccountIdentifier;
6+
account: GitlabAccountIdentifier;
77
class?: string;
88
};
99
1010
const { account, class: className }: Props = $props();
1111
12-
export function badgeText(account: ButGitLabToken.GitlabAccountIdentifier): string | null {
12+
export function badgeText(account: GitlabAccountIdentifier): string | null {
1313
switch (account.type) {
1414
case "patUsername":
1515
return "PAT";
@@ -18,7 +18,7 @@
1818
}
1919
}
2020
21-
export function tooltipText(account: ButGitLabToken.GitlabAccountIdentifier): string {
21+
export function tooltipText(account: GitlabAccountIdentifier): string {
2222
switch (account.type) {
2323
case "patUsername":
2424
return "Personal Access Token";

apps/desktop/src/components/projectSettings/ForgeForm.svelte

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
2121
import type { ForgeName } from "$lib/forge/interface/forge";
2222
import type { Project } from "$lib/project/project";
23-
import type { ButGitHubToken, ButGitLabToken } from "@gitbutler/core/api";
23+
import type { GithubAccountIdentifier, GitlabAccountIdentifier } from "@gitbutler/but-sdk";
2424
2525
const FORGE_OPTIONS: { label: string; value: ForgeName }[] = [
2626
{ label: "None", value: "default" },
@@ -62,20 +62,14 @@
6262
projectsService.updateProject(mutableProject);
6363
}
6464
65-
function updatePreferredGitHubAccount(
66-
projectId: string,
67-
account: ButGitHubToken.GithubAccountIdentifier,
68-
) {
65+
function updatePreferredGitHubAccount(projectId: string, account: GithubAccountIdentifier) {
6966
projectsService.updatePreferredForgeUser(projectId, {
7067
provider: "github",
7168
details: account,
7269
});
7370
}
7471
75-
function updatePreferredGitLabAccount(
76-
projectId: string,
77-
account: ButGitLabToken.GitlabAccountIdentifier,
78-
) {
72+
function updatePreferredGitLabAccount(projectId: string, account: GitlabAccountIdentifier) {
7973
projectsService.updatePreferredForgeUser(projectId, {
8074
provider: "gitlab",
8175
details: account,

apps/desktop/src/components/settings/GithubUserLoginState.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
import { inject } from "@gitbutler/core/context";
66
import { ForgeUserCard } from "@gitbutler/ui";
77
import { QueryStatus } from "@reduxjs/toolkit/query";
8-
import type { ButGitHubToken } from "@gitbutler/core/api";
8+
import type { GithubAccountIdentifier } from "@gitbutler/but-sdk";
99
1010
type Props = {
11-
account: ButGitHubToken.GithubAccountIdentifier;
11+
account: GithubAccountIdentifier;
1212
};
1313
1414
const { account }: Props = $props();

apps/desktop/src/components/settings/GitlabUserLoginState.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
import { inject } from "@gitbutler/core/context";
66
import { ForgeUserCard } from "@gitbutler/ui";
77
import { QueryStatus } from "@reduxjs/toolkit/query";
8-
import type { ButGitLabToken } from "@gitbutler/core/api";
8+
import type { GitlabAccountIdentifier } from "@gitbutler/but-sdk";
99
1010
type Props = {
11-
account: ButGitLabToken.GitlabAccountIdentifier;
11+
account: GitlabAccountIdentifier;
1212
};
1313
1414
const { account }: Props = $props();

0 commit comments

Comments
 (0)