|
1 | 1 | import { contextBridge, type IpcRendererEvent, ipcRenderer } from "electron"; |
2 | | -import type { |
3 | | - CloudRegion, |
4 | | - OAuthTokenResponse, |
5 | | - StoredOAuthTokens, |
6 | | -} from "../shared/types/oauth"; |
| 2 | +import type { CloudRegion, OAuthTokenResponse } from "../shared/types/oauth"; |
7 | 3 | import type { |
8 | 4 | FolderContextMenuResult, |
9 | 5 | SplitContextMenuResult, |
@@ -47,16 +43,6 @@ contextBridge.exposeInMainWorld("electronAPI", { |
47 | 43 | region: CloudRegion, |
48 | 44 | ): Promise<{ success: boolean; data?: OAuthTokenResponse; error?: string }> => |
49 | 45 | ipcRenderer.invoke("oauth:start-flow", region), |
50 | | - oauthEncryptTokens: ( |
51 | | - tokens: StoredOAuthTokens, |
52 | | - ): Promise<{ success: boolean; encrypted?: string; error?: string }> => |
53 | | - ipcRenderer.invoke("oauth:encrypt-tokens", tokens), |
54 | | - oauthRetrieveTokens: ( |
55 | | - encrypted: string, |
56 | | - ): Promise<{ success: boolean; data?: StoredOAuthTokens; error?: string }> => |
57 | | - ipcRenderer.invoke("oauth:retrieve-tokens", encrypted), |
58 | | - oauthDeleteTokens: (): Promise<{ success: boolean }> => |
59 | | - ipcRenderer.invoke("oauth:delete-tokens"), |
60 | 46 | oauthRefreshToken: ( |
61 | 47 | refreshToken: string, |
62 | 48 | region: CloudRegion, |
@@ -367,5 +353,133 @@ contextBridge.exposeInMainWorld("electronAPI", { |
367 | 353 | updateFolderAccessed: (folderId: string): Promise<void> => |
368 | 354 | ipcRenderer.invoke("update-folder-accessed", folderId), |
369 | 355 | clearAllData: (): Promise<void> => ipcRenderer.invoke("clear-all-data"), |
| 356 | + getTaskAssociations: (): Promise< |
| 357 | + Array<{ |
| 358 | + taskId: string; |
| 359 | + folderId: string; |
| 360 | + folderPath: string; |
| 361 | + worktree?: { |
| 362 | + worktreePath: string; |
| 363 | + worktreeName: string; |
| 364 | + branchName: string; |
| 365 | + baseBranch: string; |
| 366 | + createdAt: string; |
| 367 | + }; |
| 368 | + }> |
| 369 | + > => ipcRenderer.invoke("get-task-associations"), |
| 370 | + getTaskAssociation: ( |
| 371 | + taskId: string, |
| 372 | + ): Promise<{ |
| 373 | + taskId: string; |
| 374 | + folderId: string; |
| 375 | + folderPath: string; |
| 376 | + worktree?: { |
| 377 | + worktreePath: string; |
| 378 | + worktreeName: string; |
| 379 | + branchName: string; |
| 380 | + baseBranch: string; |
| 381 | + createdAt: string; |
| 382 | + }; |
| 383 | + } | null> => ipcRenderer.invoke("get-task-association", taskId), |
| 384 | + setTaskAssociation: ( |
| 385 | + taskId: string, |
| 386 | + folderId: string, |
| 387 | + folderPath: string, |
| 388 | + worktree?: { |
| 389 | + worktreePath: string; |
| 390 | + worktreeName: string; |
| 391 | + branchName: string; |
| 392 | + baseBranch: string; |
| 393 | + createdAt: string; |
| 394 | + }, |
| 395 | + ): Promise<{ |
| 396 | + taskId: string; |
| 397 | + folderId: string; |
| 398 | + folderPath: string; |
| 399 | + worktree?: { |
| 400 | + worktreePath: string; |
| 401 | + worktreeName: string; |
| 402 | + branchName: string; |
| 403 | + baseBranch: string; |
| 404 | + createdAt: string; |
| 405 | + }; |
| 406 | + }> => |
| 407 | + ipcRenderer.invoke( |
| 408 | + "set-task-association", |
| 409 | + taskId, |
| 410 | + folderId, |
| 411 | + folderPath, |
| 412 | + worktree, |
| 413 | + ), |
| 414 | + updateTaskWorktree: ( |
| 415 | + taskId: string, |
| 416 | + worktree: { |
| 417 | + worktreePath: string; |
| 418 | + worktreeName: string; |
| 419 | + branchName: string; |
| 420 | + baseBranch: string; |
| 421 | + createdAt: string; |
| 422 | + }, |
| 423 | + ): Promise<{ |
| 424 | + taskId: string; |
| 425 | + folderId: string; |
| 426 | + folderPath: string; |
| 427 | + worktree?: { |
| 428 | + worktreePath: string; |
| 429 | + worktreeName: string; |
| 430 | + branchName: string; |
| 431 | + baseBranch: string; |
| 432 | + createdAt: string; |
| 433 | + }; |
| 434 | + } | null> => ipcRenderer.invoke("update-task-worktree", taskId, worktree), |
| 435 | + removeTaskAssociation: (taskId: string): Promise<void> => |
| 436 | + ipcRenderer.invoke("remove-task-association", taskId), |
| 437 | + clearTaskWorktree: (taskId: string): Promise<void> => |
| 438 | + ipcRenderer.invoke("clear-task-worktree", taskId), |
| 439 | + }, |
| 440 | + // Worktree API |
| 441 | + worktree: { |
| 442 | + create: ( |
| 443 | + mainRepoPath: string, |
| 444 | + ): Promise<{ |
| 445 | + worktreePath: string; |
| 446 | + worktreeName: string; |
| 447 | + branchName: string; |
| 448 | + baseBranch: string; |
| 449 | + createdAt: string; |
| 450 | + }> => ipcRenderer.invoke("worktree-create", mainRepoPath), |
| 451 | + delete: (mainRepoPath: string, worktreePath: string): Promise<void> => |
| 452 | + ipcRenderer.invoke("worktree-delete", mainRepoPath, worktreePath), |
| 453 | + getInfo: ( |
| 454 | + mainRepoPath: string, |
| 455 | + worktreePath: string, |
| 456 | + ): Promise<{ |
| 457 | + worktreePath: string; |
| 458 | + worktreeName: string; |
| 459 | + branchName: string; |
| 460 | + baseBranch: string; |
| 461 | + createdAt: string; |
| 462 | + } | null> => |
| 463 | + ipcRenderer.invoke("worktree-get-info", mainRepoPath, worktreePath), |
| 464 | + exists: (mainRepoPath: string, name: string): Promise<boolean> => |
| 465 | + ipcRenderer.invoke("worktree-exists", mainRepoPath, name), |
| 466 | + list: ( |
| 467 | + mainRepoPath: string, |
| 468 | + ): Promise< |
| 469 | + Array<{ |
| 470 | + worktreePath: string; |
| 471 | + worktreeName: string; |
| 472 | + branchName: string; |
| 473 | + baseBranch: string; |
| 474 | + createdAt: string; |
| 475 | + }> |
| 476 | + > => ipcRenderer.invoke("worktree-list", mainRepoPath), |
| 477 | + isWorktree: (mainRepoPath: string, repoPath: string): Promise<boolean> => |
| 478 | + ipcRenderer.invoke("worktree-is-worktree", mainRepoPath, repoPath), |
| 479 | + getMainRepoPath: ( |
| 480 | + mainRepoPath: string, |
| 481 | + worktreePath: string, |
| 482 | + ): Promise<string | null> => |
| 483 | + ipcRenderer.invoke("worktree-get-main-repo", mainRepoPath, worktreePath), |
370 | 484 | }, |
371 | 485 | }); |
0 commit comments