(
ownerWorkspaceId: string,
target: WorkspaceLifecycleTarget,
options: WorkspaceLifecycleOptions = {}
)
| 5834 | } |
| 5835 | |
| 5836 | async archiveOwnedWorkspaceTurnWorkspace( |
| 5837 | ownerWorkspaceId: string, |
| 5838 | target: WorkspaceLifecycleTarget, |
| 5839 | options: WorkspaceLifecycleOptions = {} |
| 5840 | ): Promise<Result<WorkspaceLifecycleResult, string>> { |
| 5841 | assert(ownerWorkspaceId.trim().length > 0, "archive lifecycle requires ownerWorkspaceId"); |
| 5842 | const resolved = await this.resolveOwnedWorkspaceLifecycleTarget( |
| 5843 | ownerWorkspaceId, |
| 5844 | "archive", |
| 5845 | target |
| 5846 | ); |
| 5847 | if ("status" in resolved) return Ok(resolved); |
| 5848 | |
| 5849 | return await this.withWorkspaceLifecycleLock(resolved, async (resolved) => { |
| 5850 | if (resolved.metadata == null) { |
| 5851 | return Ok({ |
| 5852 | status: "not_found", |
| 5853 | action: "archive", |
| 5854 | ...this.lifecycleTargetFields(resolved), |
| 5855 | note: "Owned workspace metadata is already absent.", |
| 5856 | }); |
| 5857 | } |
| 5858 | if (isWorkspaceArchived(resolved.metadata.archivedAt, resolved.metadata.unarchivedAt)) { |
| 5859 | return Ok({ |
| 5860 | status: "already_archived", |
| 5861 | action: "archive", |
| 5862 | ...this.lifecycleTargetFields(resolved), |
| 5863 | }); |
| 5864 | } |
| 5865 | |
| 5866 | const active = await this.handleActiveWorkspaceLifecycleTurns( |
| 5867 | ownerWorkspaceId, |
| 5868 | resolved, |
| 5869 | options.interruptActive === true |
| 5870 | ); |
| 5871 | if (active != null) return Ok(active); |
| 5872 | |
| 5873 | const acknowledgedUntrackedPaths = |
| 5874 | options.acknowledgedUntrackedPaths ?? |
| 5875 | options.acknowledgedUntrackedPathsByWorkspaceId?.[resolved.workspaceId]; |
| 5876 | const result = await this.workspaceService.archive( |
| 5877 | resolved.workspaceId, |
| 5878 | acknowledgedUntrackedPaths |
| 5879 | ); |
| 5880 | if (!result.success) { |
| 5881 | return Ok({ |
| 5882 | status: "error", |
| 5883 | action: "archive", |
| 5884 | ...this.lifecycleTargetFields(resolved), |
| 5885 | error: result.error, |
| 5886 | }); |
| 5887 | } |
| 5888 | if (result.data.kind === "confirm-lossy-untracked-files") { |
| 5889 | return Ok({ |
| 5890 | status: "requires_confirmation", |
| 5891 | action: "archive", |
| 5892 | ...this.lifecycleTargetFields(resolved), |
| 5893 | paths: result.data.paths, |
no test coverage detected