mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-12 22:56:58 +01:00
Create background job runner and memory refresh jobs
Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
1 parent
22b4d8a176
commit
29f7355291
30 files changed
+18677
-107
No files matched your search
@@ -0,0 +1,48 @@
|
||||
import type {
|
||||
BackgroundJob,
|
||||
BackgroundJobEvent,
|
||||
BackgroundJobRun,
|
||||
CreateBackgroundJob,
|
||||
CreateBackgroundJobRun,
|
||||
ListBackgroundJobRunsQuery,
|
||||
ListBackgroundJobsQuery,
|
||||
} from "@paperclipai/shared";
|
||||
import { api } from "./client";
|
||||
|
||||
function buildQueryString(filters?: Record<string, string | number | boolean | Date | undefined>) {
|
||||
const params = new URLSearchParams();
|
||||
for (const [key, value] of Object.entries(filters ?? {})) {
|
||||
if (value === undefined) continue;
|
||||
params.set(key, value instanceof Date ? value.toISOString() : String(value));
|
||||
}
|
||||
const qs = params.toString();
|
||||
return qs ? `?${qs}` : "";
|
||||
}
|
||||
|
||||
export const backgroundJobsApi = {
|
||||
listJobs: (companyId: string, filters?: Partial<ListBackgroundJobsQuery>) =>
|
||||
api.get<BackgroundJob[]>(
|
||||
`/companies/${encodeURIComponent(companyId)}/background-jobs${buildQueryString(filters)}`,
|
||||
),
|
||||
createJob: (companyId: string, data: CreateBackgroundJob) =>
|
||||
api.post<BackgroundJob>(`/companies/${encodeURIComponent(companyId)}/background-jobs`, data),
|
||||
listRuns: (companyId: string, filters?: Partial<ListBackgroundJobRunsQuery>) =>
|
||||
api.get<BackgroundJobRun[]>(
|
||||
`/companies/${encodeURIComponent(companyId)}/background-job-runs${buildQueryString(filters)}`,
|
||||
),
|
||||
createRun: (companyId: string, data: CreateBackgroundJobRun) =>
|
||||
api.post<BackgroundJobRun>(`/companies/${encodeURIComponent(companyId)}/background-job-runs`, data),
|
||||
getRun: (companyId: string, runId: string) =>
|
||||
api.get<BackgroundJobRun>(
|
||||
`/companies/${encodeURIComponent(companyId)}/background-job-runs/${encodeURIComponent(runId)}`,
|
||||
),
|
||||
listRunEvents: (companyId: string, runId: string, limit?: number) =>
|
||||
api.get<BackgroundJobEvent[]>(
|
||||
`/companies/${encodeURIComponent(companyId)}/background-job-runs/${encodeURIComponent(runId)}/events${buildQueryString({ limit })}`,
|
||||
),
|
||||
cancelRun: (companyId: string, runId: string) =>
|
||||
api.post<BackgroundJobRun>(
|
||||
`/companies/${encodeURIComponent(companyId)}/background-job-runs/${encodeURIComponent(runId)}/cancel`,
|
||||
{},
|
||||
),
|
||||
};
|
||||
@@ -18,3 +18,4 @@ export { sidebarBadgesApi } from "./sidebarBadges";
|
||||
export { inboxDismissalsApi } from "./inboxDismissals";
|
||||
export { companySkillsApi } from "./companySkills";
|
||||
export { memoryApi } from "./memory";
|
||||
export { backgroundJobsApi } from "./backgroundJobs";
|
||||
@@ -9,6 +9,7 @@ import type {
|
||||
MemoryOperation,
|
||||
MemoryProviderDescriptor,
|
||||
MemoryRecord,
|
||||
MemoryRefreshJobResult,
|
||||
MemoryRetentionSweep,
|
||||
MemoryRetentionSweepResult,
|
||||
MemoryReview,
|
||||
@@ -20,6 +21,7 @@ import type {
|
||||
SetCompanyMemoryBinding,
|
||||
SetProjectMemoryBinding,
|
||||
UpdateMemoryBinding,
|
||||
MemoryRefreshJob,
|
||||
} from "@paperclipai/shared";
|
||||
import { api } from "./client";
|
||||
|
||||
@@ -79,4 +81,9 @@ export const memoryApi = {
|
||||
`/companies/${encodeURIComponent(companyId)}/memory/retention/sweep`,
|
||||
data,
|
||||
),
|
||||
startRefreshJob: (companyId: string, data: MemoryRefreshJob) =>
|
||||
api.post<MemoryRefreshJobResult>(
|
||||
`/companies/${encodeURIComponent(companyId)}/memory/refresh-jobs`,
|
||||
data,
|
||||
),
|
||||
};
|
||||
Reference in new issue
Block a user