* public-gh/master: (55 commits) fix(issue-documents): address greptile review Update packages/shared/src/validators/issue.ts feat(ui): add issue document copy and download actions fix(ui): unify new issue upload action feat(ui): stage issue files before create feat(ui): handle issue document edit conflicts fix(ui): refresh issue documents from live events feat(ui): deep link issue documents fix(ui): streamline issue document chrome fix(ui): collapse empty document and attachment states fix(ui): simplify document card body layout fix(issues): address document review comments feat(issues): add issue documents and inline editing docs: add agent evals framework plan fix(cli): quote env values with special characters Fix worktree seed source selection fix: address greptile follow-up docs: add paperclip skill tightening plan fix: isolate codex home in worktrees Add worktree UI branding ... # Conflicts: # packages/db/src/migrations/meta/0028_snapshot.json # packages/db/src/migrations/meta/_journal.json # packages/shared/src/index.ts # server/src/routes/issues.ts # ui/src/api/issues.ts # ui/src/components/NewIssueDialog.tsx # ui/src/pages/IssueDetail.tsx
100 lines
4.6 KiB
TypeScript
100 lines
4.6 KiB
TypeScript
import type {
|
|
Approval,
|
|
DocumentRevision,
|
|
Issue,
|
|
IssueAttachment,
|
|
IssueComment,
|
|
IssueDocument,
|
|
IssueLabel,
|
|
IssueWorkProduct,
|
|
UpsertIssueDocument,
|
|
} from "@paperclipai/shared";
|
|
import { api } from "./client";
|
|
|
|
export const issuesApi = {
|
|
list: (
|
|
companyId: string,
|
|
filters?: {
|
|
status?: string;
|
|
projectId?: string;
|
|
assigneeAgentId?: string;
|
|
assigneeUserId?: string;
|
|
touchedByUserId?: string;
|
|
unreadForUserId?: string;
|
|
labelId?: string;
|
|
q?: string;
|
|
},
|
|
) => {
|
|
const params = new URLSearchParams();
|
|
if (filters?.status) params.set("status", filters.status);
|
|
if (filters?.projectId) params.set("projectId", filters.projectId);
|
|
if (filters?.assigneeAgentId) params.set("assigneeAgentId", filters.assigneeAgentId);
|
|
if (filters?.assigneeUserId) params.set("assigneeUserId", filters.assigneeUserId);
|
|
if (filters?.touchedByUserId) params.set("touchedByUserId", filters.touchedByUserId);
|
|
if (filters?.unreadForUserId) params.set("unreadForUserId", filters.unreadForUserId);
|
|
if (filters?.labelId) params.set("labelId", filters.labelId);
|
|
if (filters?.q) params.set("q", filters.q);
|
|
const qs = params.toString();
|
|
return api.get<Issue[]>(`/companies/${companyId}/issues${qs ? `?${qs}` : ""}`);
|
|
},
|
|
listLabels: (companyId: string) => api.get<IssueLabel[]>(`/companies/${companyId}/labels`),
|
|
createLabel: (companyId: string, data: { name: string; color: string }) =>
|
|
api.post<IssueLabel>(`/companies/${companyId}/labels`, data),
|
|
deleteLabel: (id: string) => api.delete<IssueLabel>(`/labels/${id}`),
|
|
get: (id: string) => api.get<Issue>(`/issues/${id}`),
|
|
markRead: (id: string) => api.post<{ id: string; lastReadAt: Date }>(`/issues/${id}/read`, {}),
|
|
create: (companyId: string, data: Record<string, unknown>) =>
|
|
api.post<Issue>(`/companies/${companyId}/issues`, data),
|
|
update: (id: string, data: Record<string, unknown>) => api.patch<Issue>(`/issues/${id}`, data),
|
|
remove: (id: string) => api.delete<Issue>(`/issues/${id}`),
|
|
checkout: (id: string, agentId: string) =>
|
|
api.post<Issue>(`/issues/${id}/checkout`, {
|
|
agentId,
|
|
expectedStatuses: ["todo", "backlog", "blocked"],
|
|
}),
|
|
release: (id: string) => api.post<Issue>(`/issues/${id}/release`, {}),
|
|
listComments: (id: string) => api.get<IssueComment[]>(`/issues/${id}/comments`),
|
|
addComment: (id: string, body: string, reopen?: boolean, interrupt?: boolean) =>
|
|
api.post<IssueComment>(
|
|
`/issues/${id}/comments`,
|
|
{
|
|
body,
|
|
...(reopen === undefined ? {} : { reopen }),
|
|
...(interrupt === undefined ? {} : { interrupt }),
|
|
},
|
|
),
|
|
listDocuments: (id: string) => api.get<IssueDocument[]>(`/issues/${id}/documents`),
|
|
getDocument: (id: string, key: string) => api.get<IssueDocument>(`/issues/${id}/documents/${encodeURIComponent(key)}`),
|
|
upsertDocument: (id: string, key: string, data: UpsertIssueDocument) =>
|
|
api.put<IssueDocument>(`/issues/${id}/documents/${encodeURIComponent(key)}`, data),
|
|
listDocumentRevisions: (id: string, key: string) =>
|
|
api.get<DocumentRevision[]>(`/issues/${id}/documents/${encodeURIComponent(key)}/revisions`),
|
|
deleteDocument: (id: string, key: string) =>
|
|
api.delete<{ ok: true }>(`/issues/${id}/documents/${encodeURIComponent(key)}`),
|
|
listAttachments: (id: string) => api.get<IssueAttachment[]>(`/issues/${id}/attachments`),
|
|
uploadAttachment: (
|
|
companyId: string,
|
|
issueId: string,
|
|
file: File,
|
|
issueCommentId?: string | null,
|
|
) => {
|
|
const form = new FormData();
|
|
form.append("file", file);
|
|
if (issueCommentId) {
|
|
form.append("issueCommentId", issueCommentId);
|
|
}
|
|
return api.postForm<IssueAttachment>(`/companies/${companyId}/issues/${issueId}/attachments`, form);
|
|
},
|
|
deleteAttachment: (id: string) => api.delete<{ ok: true }>(`/attachments/${id}`),
|
|
listApprovals: (id: string) => api.get<Approval[]>(`/issues/${id}/approvals`),
|
|
linkApproval: (id: string, approvalId: string) =>
|
|
api.post<Approval[]>(`/issues/${id}/approvals`, { approvalId }),
|
|
unlinkApproval: (id: string, approvalId: string) =>
|
|
api.delete<{ ok: true }>(`/issues/${id}/approvals/${approvalId}`),
|
|
listWorkProducts: (id: string) => api.get<IssueWorkProduct[]>(`/issues/${id}/work-products`),
|
|
createWorkProduct: (id: string, data: Record<string, unknown>) =>
|
|
api.post<IssueWorkProduct>(`/issues/${id}/work-products`, data),
|
|
updateWorkProduct: (id: string, data: Record<string, unknown>) =>
|
|
api.patch<IssueWorkProduct>(`/work-products/${id}`, data),
|
|
deleteWorkProduct: (id: string) => api.delete<IssueWorkProduct>(`/work-products/${id}`),
|
|
};
|