Skip to content

Commit c7fa8cb

Browse files
committed
Migrate ts-rs to but-ts (schemars) for SDK type generation
Replace ts-rs (export-ts) with schemars-based but-ts for all SDK types, and introduce where missing, removing hand-written TypeScript duplicates and wiring everything through @gitbutler/but-sdk. Types migrated to export-schema / register_sdk_type!: - gitbutler-branch-actions: BranchListingFilter, BranchListing, Author, StackReference, BranchListingDetails, StackOrder, SeriesOrder, and all upstream integration types (NameAndStatus, StackStatus, Resolution, etc.) - gitbutler-edit-mode: ConflictEntryPresence (new export-schema feature) - but-api/legacy/modes: HeadAndMode, HeadSha - but-workspace: StackDetails (added missing register_sdk_type! call) Infrastructure: - Add export-schema feature to gitbutler-branch-actions and gitbutler-edit-mode with conditional schemars guards - Propagate gitbutler-branch/export-schema through but-api export-schema - Add --source-crates filter to but-ts to avoid false name-collision errors - Fix but-ts to emit T | null (not T | null | undefined) for nullable fields, since no SDK types use skip_serializing_if - Remove duplicate author.rs from gitbutler-branch-actions - Fix broken TypeScript imports across ~40 desktop app files to import directly from declaration sites (no re-exports)
1 parent c9f76e7 commit c7fa8cb

226 files changed

Lines changed: 1772 additions & 3008 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.

.github/workflows/push.yaml

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -91,27 +91,6 @@ jobs:
9191
- uses: ./.github/actions/init-env-node
9292
- run: pnpm prettier
9393

94-
generate-ts-definitions:
95-
needs: changes
96-
if: ${{ needs.changes.outputs.node == 'true' || needs.changes.outputs.rust == 'true' }}
97-
runs-on: ubuntu-latest
98-
env:
99-
CARGO_TERM_COLOR: always
100-
steps:
101-
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
102-
with:
103-
persist-credentials: false
104-
- name: Rust Cache
105-
uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
106-
with:
107-
shared-key: ts-def-gen
108-
save-if: ${{ github.ref == 'refs/heads/master' }}
109-
# Node is needed for the formatting of typescript files.
110-
- uses: ./.github/actions/init-env-node
111-
- name: Dependencies for 'keyring'
112-
run: sudo ./scripts/install-minimal-debian-dependencies.sh
113-
- run: ./scripts/generate-ts-definitions-from-rust.sh
114-
11594
lint-node:
11695
needs: changes
11796
if: ${{ needs.changes.outputs.node == 'true' }}

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.2.1",
2526
"@gitbutler/shared": "workspace:*",

apps/desktop/src/components/branch/BranchBadge.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script lang="ts">
22
import { getBranchStatusLabelAndColor } from "$components/lib";
3-
import type { PushStatus } from "$lib/stacks/stack";
3+
import type { PushStatus } from "@gitbutler/but-sdk";
44
55
type Props = {
66
pushStatus: PushStatus;

apps/desktop/src/components/branch/BranchCard.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import { isDefined } from "@gitbutler/ui/utils/typeguards";
2323
import type { BranchIconName } from "$lib/branches/branchIcon";
2424
import type { DropzoneHandler } from "$lib/dragging/handler";
25-
import type { PushStatus } from "$lib/stacks/stack";
25+
import type { PushStatus } from "@gitbutler/but-sdk";
2626
import type { Snippet } from "svelte";
2727
2828
interface BranchCardProps {

apps/desktop/src/components/branch/BranchDetails.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<script lang="ts">
22
import BranchBadge from "$components/branch/BranchBadge.svelte";
3-
import { type BranchDetails } from "$lib/stacks/stack";
43
import { AvatarGroup, Button } from "@gitbutler/ui";
4+
import type { BranchDetails } from "@gitbutler/but-sdk";
55
import type { Snippet } from "svelte";
66
77
type Props = {

apps/desktop/src/components/branch/BranchHeader.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import { DRAG_STATE_SERVICE } from "@gitbutler/ui/drag/dragStateService.svelte";
2020
import { focusable } from "@gitbutler/ui/focus/focusable";
2121
import { slide } from "svelte/transition";
22-
import type { PushStatus } from "$lib/stacks/stack";
22+
import type { PushStatus } from "@gitbutler/but-sdk";
2323
import type { Snippet } from "svelte";
2424
import type { ComponentProps } from "svelte";
2525

apps/desktop/src/components/branch/BranchHeaderContextMenu.svelte

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@
3232
} from "@gitbutler/ui";
3333
3434
import { tick } from "svelte";
35-
import type { AnchorPosition, BranchDetails } from "$lib/stacks/stack";
35+
import type { AnchorPosition } from "$lib/stacks/stack";
36+
import type { BranchDetails } from "@gitbutler/but-sdk";
3637
3738
type Props = {
3839
projectId: string;

apps/desktop/src/components/branch/BranchIntegrationModal.svelte

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,7 @@
22
import CommitTimelineNode from "$components/commit/CommitTimelineNode.svelte";
33
import ReduxResult from "$components/shared/ReduxResult.svelte";
44
import { CLIPBOARD_SERVICE } from "$lib/backend/clipboard";
5-
import {
6-
commitCreatedAtDate,
7-
extractUpstreamCommitId,
8-
isCommit,
9-
type Commit,
10-
type UpstreamCommit,
11-
} from "$lib/branches/v3";
5+
import { commitCreatedAtDate, extractUpstreamCommitId, isCommit } from "$lib/branches/v3";
126
import { STACK_SERVICE } from "$lib/stacks/stackService.svelte";
137
import {
148
canShiftStepDown,
@@ -26,6 +20,7 @@
2620
import { Modal, ModalFooter, Button, ScrollableContainer, SimpleCommitRow } from "@gitbutler/ui";
2721
import { flip } from "svelte/animate";
2822
import type { InteractiveIntegrationStep } from "$lib/stacks/stack";
23+
import type { Commit, UpstreamCommit } from "@gitbutler/but-sdk";
2924
3025
type Props = {
3126
modalRef: Modal | undefined;

0 commit comments

Comments
 (0)