36dd762bf1
Co-authored-by: nova28 <17953305+nova28@users.noreply.github.com> Co-authored-by: Carlos Florencio <carlosmflorencio@gmail.com>
72 lines
2.0 KiB
TypeScript
72 lines
2.0 KiB
TypeScript
import { fetchJson, type ApiRequestOptions } from "../client";
|
|
import type {
|
|
ClarificationInboxHiddenPage,
|
|
ClarificationInboxPage,
|
|
ClarificationInboxSnoozeDuration,
|
|
} from "@/lib/types/clarification-inbox";
|
|
|
|
const BASE = "/api/v1/clarification-inbox";
|
|
|
|
// One canonical parameter set (design-02#Control-flow): every caller passes
|
|
// only workspaceId. No cursor -- v1 never forward-pages.
|
|
export function listClarificationInbox(
|
|
workspaceId: string,
|
|
options?: ApiRequestOptions,
|
|
): Promise<ClarificationInboxPage> {
|
|
return fetchJson<ClarificationInboxPage>(
|
|
`${BASE}?workspace_id=${encodeURIComponent(workspaceId)}`,
|
|
options,
|
|
);
|
|
}
|
|
|
|
export function listHiddenClarificationInbox(
|
|
workspaceId: string,
|
|
options?: ApiRequestOptions,
|
|
): Promise<ClarificationInboxHiddenPage> {
|
|
return fetchJson<ClarificationInboxHiddenPage>(
|
|
`${BASE}/hidden?workspace_id=${encodeURIComponent(workspaceId)}`,
|
|
options,
|
|
);
|
|
}
|
|
|
|
export function dismissClarificationInboxBundle(
|
|
pendingId: string,
|
|
options?: ApiRequestOptions,
|
|
): Promise<void> {
|
|
return fetchJson<void>(`${BASE}/sidecar/${encodeURIComponent(pendingId)}`, {
|
|
...options,
|
|
init: {
|
|
method: "PUT",
|
|
headers: { "Content-Type": "application/json" },
|
|
body: JSON.stringify({ state: "dismissed" }),
|
|
...options?.init,
|
|
},
|
|
});
|
|
}
|
|
|
|
export function snoozeClarificationInboxBundle(
|
|
pendingId: string,
|
|
duration: ClarificationInboxSnoozeDuration,
|
|
options?: ApiRequestOptions,
|
|
): Promise<void> {
|
|
return fetchJson<void>(`${BASE}/sidecar/${encodeURIComponent(pendingId)}`, {
|
|
...options,
|
|
init: {
|
|
method: "PUT",
|
|
headers: { "Content-Type": "application/json" },
|
|
body: JSON.stringify({ state: "snoozed", snooze_duration: duration }),
|
|
...options?.init,
|
|
},
|
|
});
|
|
}
|
|
|
|
export function restoreClarificationInboxBundle(
|
|
pendingId: string,
|
|
options?: ApiRequestOptions,
|
|
): Promise<void> {
|
|
return fetchJson<void>(`${BASE}/sidecar/${encodeURIComponent(pendingId)}`, {
|
|
...options,
|
|
init: { method: "DELETE", ...options?.init },
|
|
});
|
|
}
|