Expose project version history
This commit is contained in:
@@ -12,6 +12,9 @@ import type {
|
||||
ProjectDeviceCommandResultDto,
|
||||
ProjectDeviceDto,
|
||||
ProjectHistoryStateDto,
|
||||
ProjectRevisionPageDto,
|
||||
ProjectSnapshotMetadataDto,
|
||||
ProjectSnapshotRestoreResultDto,
|
||||
ProjectDeviceSyncCommandResultDto,
|
||||
ProjectDeviceSyncPreviewDto,
|
||||
ProjectDto,
|
||||
@@ -82,6 +85,62 @@ export function getProjectHistory(projectId: string) {
|
||||
);
|
||||
}
|
||||
|
||||
export function listProjectRevisions(
|
||||
projectId: string,
|
||||
input: { limit?: number; beforeRevision?: number } = {}
|
||||
) {
|
||||
const query = new URLSearchParams();
|
||||
if (input.limit !== undefined) {
|
||||
query.set("limit", String(input.limit));
|
||||
}
|
||||
if (input.beforeRevision !== undefined) {
|
||||
query.set("beforeRevision", String(input.beforeRevision));
|
||||
}
|
||||
const suffix = query.size ? `?${query.toString()}` : "";
|
||||
return request<ProjectRevisionPageDto>(
|
||||
`/api/projects/${projectId}/history/revisions${suffix}`
|
||||
);
|
||||
}
|
||||
|
||||
export function listProjectSnapshots(projectId: string) {
|
||||
return request<ProjectSnapshotMetadataDto[]>(
|
||||
`/api/projects/${projectId}/snapshots`
|
||||
);
|
||||
}
|
||||
|
||||
export function createNamedProjectSnapshot(
|
||||
projectId: string,
|
||||
expectedRevision: number,
|
||||
name: string,
|
||||
description?: string
|
||||
) {
|
||||
return request<ProjectSnapshotMetadataDto>(
|
||||
`/api/projects/${projectId}/snapshots`,
|
||||
{
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
expectedRevision,
|
||||
name,
|
||||
...(description ? { description } : {}),
|
||||
}),
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
export function restoreProjectSnapshot(
|
||||
projectId: string,
|
||||
snapshotId: string,
|
||||
expectedRevision: number
|
||||
) {
|
||||
return request<ProjectSnapshotRestoreResultDto>(
|
||||
`/api/projects/${projectId}/snapshots/${snapshotId}/restore`,
|
||||
{
|
||||
method: "POST",
|
||||
body: JSON.stringify({ expectedRevision }),
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
export function executeProjectCommand(
|
||||
projectId: string,
|
||||
expectedRevision: number,
|
||||
|
||||
Reference in New Issue
Block a user