forked from longtao.wu/droboticflow
✨ Show delivery contents in acceptance
This commit is contained in:
parent
e545b16de9
commit
7c04c2bebd
75
internal/api/delivery_package_contents_test.go
Normal file
75
internal/api/delivery_package_contents_test.go
Normal file
@ -0,0 +1,75 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"droboticflow/internal/domain"
|
||||
"droboticflow/internal/store"
|
||||
)
|
||||
|
||||
func TestDeliveryPackageContentsExposeOnlyFinalArtifactsToReviewer(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
dataStore := store.NewMemoryStore()
|
||||
videoPath := filepath.Join(t.TempDir(), "final-001.mp4")
|
||||
if err := os.WriteFile(videoPath, []byte("final-video"), 0o600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
manifestID, videoID := "artifact-manifest", "artifact-video"
|
||||
run := domain.RunRecord{
|
||||
ID: "run-final", OrganizationID: domain.DefaultOrganizationID, WorkflowID: "workflow-final", ProjectID: "project-final", Status: domain.RunStatusCompleted,
|
||||
Artifacts: []domain.ExecutionArtifact{
|
||||
{ID: manifestID, RunID: "run-final", NodeID: "package", Name: "packages-manifest.json", Type: domain.PortTypeJSON, Data: map[string]any{"packageCount": 1, "trainingEnabled": false, "items": []any{map[string]any{"packageName": "slice-package", "clipId": "slice", "clipName": "final-001.mp4", "startSecond": 0.0, "endSecond": 10.2, "duration": 10.2}}}},
|
||||
{ID: videoID, RunID: "run-final", NodeID: "package", Name: "final-001.mp4", Type: domain.PortTypeVideo, Path: videoPath, Size: "11 B", Metadata: &domain.ArtifactMetadata{MimeType: "video/mp4"}},
|
||||
{ID: "artifact-upstream", RunID: "run-parent", NodeID: "human", Name: "annotations.json", Type: domain.PortTypeJSON},
|
||||
},
|
||||
}
|
||||
if err := dataStore.UpsertRun(ctx, run); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
item := domain.DeliveryPackageRecord{
|
||||
ID: "delivery-final", OrganizationID: domain.DefaultOrganizationID, ProjectID: run.ProjectID, WorkflowID: run.WorkflowID,
|
||||
ChildRunID: run.ID, Status: domain.DeliveryPackageAccepted, FinalExportArtifactIDs: []string{manifestID, videoID}, Version: 1,
|
||||
}
|
||||
if err := dataStore.UpsertDeliveryPackage(ctx, item); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
principal := &authenticatedPrincipal{User: domain.UserRecord{ID: "admin", OrganizationID: domain.DefaultOrganizationID, Role: domain.UserRoleAdmin}, Organization: domain.OrganizationRecord{ID: domain.DefaultOrganizationID}}
|
||||
handler := NewHandler(dataStore, nil)
|
||||
|
||||
request := httptest.NewRequest(http.MethodGet, "/api/delivery-packages/"+item.ID+"/contents", nil)
|
||||
request = request.WithContext(context.WithValue(request.Context(), authContextKey{}, principal))
|
||||
recorder := httptest.NewRecorder()
|
||||
handler.ServeHTTP(recorder, request)
|
||||
if recorder.Code != http.StatusOK {
|
||||
t.Fatalf("contents status=%d body=%s", recorder.Code, recorder.Body.String())
|
||||
}
|
||||
var payload struct {
|
||||
Artifacts []domain.ExecutionArtifact `json:"artifacts"`
|
||||
Manifest map[string]any `json:"manifest"`
|
||||
}
|
||||
if err := json.Unmarshal(recorder.Body.Bytes(), &payload); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(payload.Artifacts) != 2 || payload.Manifest["packageCount"] != float64(1) {
|
||||
t.Fatalf("unexpected delivery contents: %#v", payload)
|
||||
}
|
||||
for _, artifact := range payload.Artifacts {
|
||||
if artifact.ID == "artifact-upstream" || artifact.Data["contentURL"] == "" {
|
||||
t.Fatalf("contents leaked an upstream artifact or omitted content URL: %#v", artifact)
|
||||
}
|
||||
}
|
||||
|
||||
contentRequest := httptest.NewRequest(http.MethodGet, "/api/delivery-packages/"+item.ID+"/artifacts/"+videoID+"/content", nil)
|
||||
contentRequest = contentRequest.WithContext(context.WithValue(contentRequest.Context(), authContextKey{}, principal))
|
||||
contentRecorder := httptest.NewRecorder()
|
||||
handler.ServeHTTP(contentRecorder, contentRequest)
|
||||
if contentRecorder.Code != http.StatusOK || contentRecorder.Body.String() != "final-video" {
|
||||
t.Fatalf("video content status=%d body=%q", contentRecorder.Code, contentRecorder.Body.String())
|
||||
}
|
||||
}
|
||||
@ -56,6 +56,98 @@ func (server *server) handleDeliveryPackagesList(writer http.ResponseWriter, req
|
||||
renderJSON(writer, http.StatusOK, map[string]any{"items": items})
|
||||
}
|
||||
|
||||
func (server *server) deliveryPackageForReviewer(writer http.ResponseWriter, request *http.Request) (*domain.DeliveryPackageRecord, bool) {
|
||||
item, err := server.store.GetDeliveryPackage(request.Context(), chi.URLParam(request, "id"))
|
||||
if err != nil {
|
||||
renderError(writer, http.StatusInternalServerError, err)
|
||||
return nil, false
|
||||
}
|
||||
if item == nil {
|
||||
renderJSON(writer, http.StatusNotFound, map[string]string{"error": "Delivery package not found"})
|
||||
return nil, false
|
||||
}
|
||||
if !server.ensureTenantAccess(writer, request, item.OrganizationID, "Delivery package") {
|
||||
return nil, false
|
||||
}
|
||||
if !server.deliveryPackageReviewer(request, *item) {
|
||||
renderJSON(writer, http.StatusForbidden, map[string]string{"error": "acceptance reviewer membership is required"})
|
||||
return nil, false
|
||||
}
|
||||
return item, true
|
||||
}
|
||||
|
||||
func deliveryPackageArtifactAllowed(item *domain.DeliveryPackageRecord, artifactID string) bool {
|
||||
if item == nil || strings.TrimSpace(artifactID) == "" {
|
||||
return false
|
||||
}
|
||||
for _, allowedID := range item.FinalExportArtifactIDs {
|
||||
if allowedID == artifactID {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (server *server) handleDeliveryPackageContents(writer http.ResponseWriter, request *http.Request) {
|
||||
item, ok := server.deliveryPackageForReviewer(writer, request)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
run, err := server.store.GetRun(request.Context(), item.ChildRunID)
|
||||
if err != nil {
|
||||
renderError(writer, http.StatusInternalServerError, err)
|
||||
return
|
||||
}
|
||||
if run == nil {
|
||||
renderJSON(writer, http.StatusNotFound, map[string]string{"error": "Delivery package Run not found"})
|
||||
return
|
||||
}
|
||||
allowed := make(map[string]struct{}, len(item.FinalExportArtifactIDs))
|
||||
for _, artifactID := range item.FinalExportArtifactIDs {
|
||||
allowed[artifactID] = struct{}{}
|
||||
}
|
||||
artifacts := make([]domain.ExecutionArtifact, 0, len(allowed))
|
||||
var manifest map[string]any
|
||||
for _, artifact := range run.Artifacts {
|
||||
if _, exists := allowed[artifact.ID]; !exists || artifact.RunID != run.ID {
|
||||
continue
|
||||
}
|
||||
copy := artifact
|
||||
if copy.Data == nil {
|
||||
copy.Data = make(map[string]any)
|
||||
}
|
||||
contentURL := "/api/delivery-packages/" + item.ID + "/artifacts/" + artifact.ID + "/content"
|
||||
copy.Data["contentURL"] = contentURL
|
||||
if copy.Type == domain.PortTypeVideo || (copy.Metadata != nil && strings.HasPrefix(strings.TrimSpace(copy.Metadata.MimeType), "video/")) {
|
||||
preview := mapValue(copy.Data["preview"])
|
||||
if preview == nil {
|
||||
preview = make(map[string]any)
|
||||
}
|
||||
preview["kind"] = "video"
|
||||
preview["url"] = contentURL
|
||||
copy.Data["preview"] = preview
|
||||
}
|
||||
if copy.Name == "packages-manifest.json" {
|
||||
manifest = artifactStructuredData(&artifact)
|
||||
}
|
||||
artifacts = append(artifacts, copy)
|
||||
}
|
||||
renderJSON(writer, http.StatusOK, map[string]any{"deliveryPackage": item, "artifacts": artifacts, "manifest": manifest})
|
||||
}
|
||||
|
||||
func (server *server) handleDeliveryPackageArtifactContent(writer http.ResponseWriter, request *http.Request) {
|
||||
item, ok := server.deliveryPackageForReviewer(writer, request)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
artifactID := strings.TrimSpace(chi.URLParam(request, "artifactId"))
|
||||
if !deliveryPackageArtifactAllowed(item, artifactID) {
|
||||
renderJSON(writer, http.StatusForbidden, map[string]string{"error": "artifact is not a final delivery output"})
|
||||
return
|
||||
}
|
||||
server.serveRunArtifactContent(writer, request, item.ChildRunID, artifactID)
|
||||
}
|
||||
|
||||
func (server *server) enrichDeliveryPackageAcceptance(request *http.Request, item *domain.DeliveryPackageRecord) error {
|
||||
if item == nil || strings.TrimSpace(item.AcceptanceHumanItemID) == "" {
|
||||
return nil
|
||||
|
||||
@ -1460,6 +1460,9 @@ func NewHandlerWithConfig(dataStore store.Store, aiService ai.Service, appConfig
|
||||
router.Get("/api/packages/{runId}/{packageName}/content", instance.handlePackageContent)
|
||||
router.Get("/api/delivery-packages", instance.handleDeliveryPackagesList)
|
||||
router.Get("/api/delivery-packages/{id}", instance.handleDeliveryPackageGet)
|
||||
router.Get("/api/delivery-packages/{id}/contents", instance.handleDeliveryPackageContents)
|
||||
router.Get("/api/delivery-packages/{id}/artifacts/{artifactId}/content", instance.handleDeliveryPackageArtifactContent)
|
||||
router.Head("/api/delivery-packages/{id}/artifacts/{artifactId}/content", instance.handleDeliveryPackageArtifactContent)
|
||||
router.Group(func(router chi.Router) {
|
||||
router.Use(instance.requireBusinessRole(domain.UserRoleAdmin, domain.UserRoleAcceptanceReviewer))
|
||||
router.Post("/api/delivery-packages/{id}/claim", instance.handleDeliveryPackageClaim)
|
||||
|
||||
@ -20,6 +20,10 @@ import {
|
||||
Video,
|
||||
Eye,
|
||||
ShieldCheck,
|
||||
ChevronDown,
|
||||
ChevronUp,
|
||||
Download,
|
||||
FileJson,
|
||||
} from "lucide-react";
|
||||
import type {
|
||||
AnnotationSegment,
|
||||
@ -31,6 +35,9 @@ import type {
|
||||
HumanReject,
|
||||
HumanItem,
|
||||
DeliveryPackage,
|
||||
DeliveryPackageContents,
|
||||
DeliveryPackageManifestItem,
|
||||
ExecutionData,
|
||||
Project,
|
||||
ProjectAnnotationMembership,
|
||||
SliceOperation,
|
||||
@ -45,6 +52,7 @@ import { projectsApi } from "../services/api/projects";
|
||||
import { normalizeAnnotationSegments, summarizeAnnotationWorkload } from "../lib/annotation-operations.js";
|
||||
import { formatCompactDateTime } from "../lib/datetime";
|
||||
import { getActionErrorMessage } from "../lib/action-errors.js";
|
||||
import { artifactContentPath } from "../lib/artifact-download.js";
|
||||
import AnnotationTimelineEditor from "../components/AnnotationTimelineEditor";
|
||||
import RerunArtifactPreview from "../components/RerunArtifactPreview";
|
||||
import { buildBrowserPlayableVideoURL } from "../lib/video-preview.js";
|
||||
@ -102,6 +110,20 @@ function prepackageAcceptanceStatisticsAreValid(statistics: PrepackageAcceptance
|
||||
);
|
||||
}
|
||||
|
||||
function deliveryArtifactPreviewURL(item: ExecutionData | undefined) {
|
||||
const preview = item?.data?.preview;
|
||||
if (preview && typeof preview === "object" && typeof preview.url === "string") return preview.url;
|
||||
return "";
|
||||
}
|
||||
|
||||
function deliveryArtifactDownloadURL(item: ExecutionData) {
|
||||
return artifactContentPath(item, { download: true });
|
||||
}
|
||||
|
||||
function deliveryActions(item: DeliveryPackageManifestItem) {
|
||||
return Array.isArray(item.annotation?.actions) ? item.annotation.actions : [];
|
||||
}
|
||||
|
||||
const panelClass = "rounded-2xl border border-[#2a2b2f] bg-[#151619]";
|
||||
const inputClass =
|
||||
"w-full rounded-lg border border-[#2a2b2f] bg-[#0a0a0a] px-3 py-2 text-sm text-white outline-none focus:border-blue-500";
|
||||
@ -175,6 +197,10 @@ export default function AnnotationOperations() {
|
||||
const [workload, setWorkload] = useState<AnnotationWorkloadSummary>({ items: [], eventCount: 0 });
|
||||
const [rejects, setRejects] = useState<HumanReject[]>([]);
|
||||
const [deliveryPackages, setDeliveryPackages] = useState<DeliveryPackage[]>([]);
|
||||
const [expandedDeliveryPackageId, setExpandedDeliveryPackageId] = useState("");
|
||||
const [deliveryPackageContents, setDeliveryPackageContents] = useState<Record<string, DeliveryPackageContents>>({});
|
||||
const [deliveryPackageContentsLoading, setDeliveryPackageContentsLoading] = useState("");
|
||||
const [deliveryPackageContentsErrors, setDeliveryPackageContentsErrors] = useState<Record<string, string>>({});
|
||||
const [prepackageAcceptanceItems, setPrepackageAcceptanceItems] = useState<HumanItem[]>([]);
|
||||
const [selectedAcceptanceEvidence, setSelectedAcceptanceEvidence] = useState<{ itemId: string; index: number }>({
|
||||
itemId: "",
|
||||
@ -826,6 +852,28 @@ export default function AnnotationOperations() {
|
||||
}
|
||||
};
|
||||
|
||||
const toggleDeliveryPackageContents = async (item: DeliveryPackage) => {
|
||||
if (expandedDeliveryPackageId === item.id) {
|
||||
setExpandedDeliveryPackageId("");
|
||||
return;
|
||||
}
|
||||
setExpandedDeliveryPackageId(item.id);
|
||||
if (deliveryPackageContents[item.id]) return;
|
||||
setDeliveryPackageContentsLoading(item.id);
|
||||
setDeliveryPackageContentsErrors((current) => ({ ...current, [item.id]: "" }));
|
||||
try {
|
||||
const contents = await deliveryPackagesApi.contents(item.id);
|
||||
setDeliveryPackageContents((current) => ({ ...current, [item.id]: contents }));
|
||||
} catch (loadError) {
|
||||
setDeliveryPackageContentsErrors((current) => ({
|
||||
...current,
|
||||
[item.id]: getActionErrorMessage(loadError, "加载验收内容失败"),
|
||||
}));
|
||||
} finally {
|
||||
setDeliveryPackageContentsLoading("");
|
||||
}
|
||||
};
|
||||
|
||||
const releasePrepackageAcceptance = async (item: HumanItem) => {
|
||||
setSaving(true);
|
||||
setError("");
|
||||
@ -1227,6 +1275,14 @@ export default function AnnotationOperations() {
|
||||
const overallGrade =
|
||||
prePackageAcceptance?.statistics?.overallGrade || item.acceptanceReviews?.at(-1)?.overallGrade || "-";
|
||||
const assignedToMe = item.assignedUserId === currentUser?.id;
|
||||
const isExpanded = expandedDeliveryPackageId === item.id;
|
||||
const contents = deliveryPackageContents[item.id];
|
||||
const manifestItems = contents?.manifest?.items || [];
|
||||
const acceptanceStatistics = (
|
||||
contents?.deliveryPackage.qualitySummary?.prePackageAcceptance as
|
||||
| { statistics?: Record<string, string | number | boolean> }
|
||||
| undefined
|
||||
)?.statistics;
|
||||
return (
|
||||
<div key={item.id} className={`${panelClass} space-y-4 p-5`}>
|
||||
<div className="flex flex-wrap items-center justify-between gap-3">
|
||||
@ -1237,28 +1293,155 @@ export default function AnnotationOperations() {
|
||||
个最终产物 · 状态 {item.status} · 质检等级 {overallGrade}
|
||||
</div>
|
||||
</div>
|
||||
{item.status === "pending_acceptance" && item.acceptanceHumanItemId && !item.assignedUserId ? (
|
||||
<div className="flex flex-wrap gap-2">
|
||||
<button
|
||||
type="button"
|
||||
disabled={saving}
|
||||
onClick={() => void claimDeliveryPackage(item)}
|
||||
className="rounded-lg bg-blue-600 px-4 py-2 text-sm text-white disabled:opacity-50"
|
||||
onClick={() => void toggleDeliveryPackageContents(item)}
|
||||
className="inline-flex items-center gap-2 rounded-lg border border-blue-500/40 px-4 py-2 text-sm text-blue-200 hover:bg-blue-500/10"
|
||||
>
|
||||
领取验收
|
||||
<Eye className="h-4 w-4" />
|
||||
{isExpanded ? "收起验收内容" : "查看验收内容"}
|
||||
{isExpanded ? <ChevronUp className="h-4 w-4" /> : <ChevronDown className="h-4 w-4" />}
|
||||
</button>
|
||||
) : null}
|
||||
{assignedToMe ? (
|
||||
<button
|
||||
type="button"
|
||||
disabled={saving}
|
||||
onClick={() => void releaseDeliveryPackage(item)}
|
||||
className="rounded-lg border border-amber-500/40 px-4 py-2 text-sm text-amber-200 disabled:opacity-50"
|
||||
>
|
||||
释放验收
|
||||
</button>
|
||||
) : null}
|
||||
{item.status === "pending_acceptance" && item.acceptanceHumanItemId && !item.assignedUserId ? (
|
||||
<button
|
||||
type="button"
|
||||
disabled={saving}
|
||||
onClick={() => void claimDeliveryPackage(item)}
|
||||
className="rounded-lg bg-blue-600 px-4 py-2 text-sm text-white disabled:opacity-50"
|
||||
>
|
||||
领取验收
|
||||
</button>
|
||||
) : null}
|
||||
{assignedToMe ? (
|
||||
<button
|
||||
type="button"
|
||||
disabled={saving}
|
||||
onClick={() => void releaseDeliveryPackage(item)}
|
||||
className="rounded-lg border border-amber-500/40 px-4 py-2 text-sm text-amber-200 disabled:opacity-50"
|
||||
>
|
||||
释放验收
|
||||
</button>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{isExpanded ? (
|
||||
<div className="space-y-4 border-t border-[#2a2b2f] pt-4">
|
||||
{deliveryPackageContentsLoading === item.id ? (
|
||||
<div className="flex items-center gap-2 py-8 text-sm text-gray-400">
|
||||
<Loader2 className="h-4 w-4 animate-spin" /> 正在加载验收内容...
|
||||
</div>
|
||||
) : deliveryPackageContentsErrors[item.id] ? (
|
||||
<div className="rounded-lg border border-red-500/30 bg-red-500/10 p-3 text-sm text-red-200">
|
||||
{deliveryPackageContentsErrors[item.id]}
|
||||
</div>
|
||||
) : contents ? (
|
||||
<>
|
||||
<div className="grid gap-3 text-xs sm:grid-cols-2 xl:grid-cols-6">
|
||||
{[
|
||||
["视频质量", acceptanceStatistics?.videoQuality === "qualified" ? "合格" : "-"],
|
||||
["标注准确性", acceptanceStatistics?.annotationAccuracy ?? "-"],
|
||||
["标注完整性", acceptanceStatistics?.annotationCompleteness ?? "-"],
|
||||
["总体等级", acceptanceStatistics?.overallGrade ?? overallGrade],
|
||||
["HeadPose", acceptanceStatistics?.headposeEnabled === false ? "未启用" : "-"],
|
||||
["HandPose", acceptanceStatistics?.handposeEnabled === false ? "未启用" : "-"],
|
||||
].map(([label, value]) => (
|
||||
<div key={String(label)} className="rounded-lg bg-[#101114] p-3">
|
||||
<div className="text-gray-500">{label}</div>
|
||||
<div className="mt-1 text-sm font-medium text-white">{String(value)}</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<div className="grid gap-4 xl:grid-cols-2">
|
||||
{manifestItems.map((packageItem) => {
|
||||
const videoArtifact = contents.artifacts.find(
|
||||
(artifact) => artifact.name === packageItem.clipName,
|
||||
);
|
||||
const videoURL = deliveryArtifactPreviewURL(videoArtifact);
|
||||
const actions = deliveryActions(packageItem);
|
||||
return (
|
||||
<div key={packageItem.clipId} className="space-y-3 rounded-xl bg-[#101114] p-4">
|
||||
<div>
|
||||
<div className="break-all text-sm font-medium text-white">{packageItem.clipName}</div>
|
||||
<div className="mt-1 text-xs text-gray-400">
|
||||
最终边界 {packageItem.startSecond.toFixed(2)}–{packageItem.endSecond.toFixed(2)}s ·
|
||||
时长 {packageItem.duration.toFixed(2)}s
|
||||
</div>
|
||||
</div>
|
||||
{videoURL ? (
|
||||
<video
|
||||
controls
|
||||
preload="metadata"
|
||||
className="max-h-72 w-full rounded-lg bg-black object-contain"
|
||||
src={buildBrowserPlayableVideoURL(videoURL)}
|
||||
/>
|
||||
) : (
|
||||
<div className="rounded-lg border border-[#2a2b2f] p-4 text-xs text-gray-500">
|
||||
当前切片没有可播放视频。
|
||||
</div>
|
||||
)}
|
||||
<div className="space-y-2">
|
||||
{actions.map((action: Record<string, any>, actionIndex: number) => (
|
||||
<div
|
||||
key={String(action.id || actionIndex)}
|
||||
className="rounded-lg border border-emerald-500/20 bg-emerald-500/5 p-3 text-xs"
|
||||
>
|
||||
<div className="font-medium text-emerald-200">
|
||||
{action.labelId} · {action.label}
|
||||
</div>
|
||||
<div className="mt-1 text-gray-400">
|
||||
标注区间 {Number(action.start || 0).toFixed(2)}–
|
||||
{Number(action.end || 0).toFixed(2)}s
|
||||
</div>
|
||||
{Array.isArray(action.phrases) && action.phrases.length > 0 ? (
|
||||
<div className="mt-1 text-gray-500">{action.phrases.join(";")}</div>
|
||||
) : null}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
|
||||
<div className="rounded-xl bg-[#101114]">
|
||||
<div className="border-b border-[#2a2b2f] px-4 py-3 text-sm font-medium text-white">
|
||||
最终交付文件({contents.artifacts.length})
|
||||
</div>
|
||||
<div className="divide-y divide-[#202227]">
|
||||
{contents.artifacts.map((artifact) => (
|
||||
<div
|
||||
key={artifact.id}
|
||||
className="flex flex-wrap items-center justify-between gap-3 px-4 py-3"
|
||||
>
|
||||
<div className="flex min-w-0 items-center gap-3">
|
||||
{artifact.type === "video" ? (
|
||||
<Video className="h-4 w-4 shrink-0 text-blue-300" />
|
||||
) : (
|
||||
<FileJson className="h-4 w-4 shrink-0 text-amber-300" />
|
||||
)}
|
||||
<div className="min-w-0">
|
||||
<div className="truncate text-sm text-gray-200">{artifact.name}</div>
|
||||
<div className="mt-0.5 text-xs text-gray-500">{artifact.size}</div>
|
||||
</div>
|
||||
</div>
|
||||
<a
|
||||
href={deliveryArtifactDownloadURL(artifact)}
|
||||
className="inline-flex items-center gap-1 rounded-md border border-[#2a2b2f] px-3 py-1.5 text-xs text-gray-300 hover:bg-white/5"
|
||||
>
|
||||
<Download className="h-3.5 w-3.5" /> 下载
|
||||
</a>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
) : null}
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
{assignedToMe ? (
|
||||
<div className="space-y-3 rounded-xl border border-[#2a2b2f] bg-[#101114] p-4">
|
||||
<div className="grid gap-3 md:grid-cols-4">
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import type { DeliveryPackage } from "../../types";
|
||||
import type { DeliveryPackage, DeliveryPackageContents } from "../../types";
|
||||
import { apiRequest } from "./client";
|
||||
|
||||
const packageQuery = (values: Record<string, string | undefined>) => {
|
||||
@ -14,6 +14,8 @@ export const deliveryPackagesApi = {
|
||||
list: async (filters: { projectId?: string; workflowId?: string; status?: DeliveryPackage["status"] } = {}) =>
|
||||
(await apiRequest<{ items: DeliveryPackage[] }>(`/api/delivery-packages${packageQuery(filters)}`)).items,
|
||||
get: (id: string) => apiRequest<DeliveryPackage>(`/api/delivery-packages/${encodeURIComponent(id)}`),
|
||||
contents: (id: string) =>
|
||||
apiRequest<DeliveryPackageContents>(`/api/delivery-packages/${encodeURIComponent(id)}/contents`),
|
||||
claim: (id: string, version: number) =>
|
||||
apiRequest<DeliveryPackage>(
|
||||
`/api/delivery-packages/${encodeURIComponent(id)}/claim`,
|
||||
|
||||
21
src/types.ts
21
src/types.ts
@ -1820,3 +1820,24 @@ export interface DeliveryPackage {
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export interface DeliveryPackageManifestItem {
|
||||
packageName: string;
|
||||
clipId: string;
|
||||
clipName: string;
|
||||
startSecond: number;
|
||||
endSecond: number;
|
||||
duration: number;
|
||||
annotation?: Record<string, any>;
|
||||
segmentManifest?: Record<string, any>;
|
||||
}
|
||||
|
||||
export interface DeliveryPackageContents {
|
||||
deliveryPackage: DeliveryPackage;
|
||||
artifacts: ExecutionData[];
|
||||
manifest?: {
|
||||
packageCount?: number;
|
||||
trainingEnabled?: boolean;
|
||||
items?: DeliveryPackageManifestItem[];
|
||||
};
|
||||
}
|
||||
|
||||
@ -34,4 +34,9 @@ test("aggregate confirmation skips pose stages and releases only packaging", asy
|
||||
assert.match(source, /item\.finalExportArtifactIds\?\.length/);
|
||||
assert.match(source, /qualitySummary\?\.prePackageAcceptance/);
|
||||
assert.doesNotMatch(source, /item\.packageName|item\.itemCount|acceptanceHumanItemAssigneeId/);
|
||||
assert.match(source, /查看验收内容/);
|
||||
assert.match(source, /deliveryPackagesApi\.contents/);
|
||||
assert.match(source, /最终边界/);
|
||||
assert.match(source, /最终交付文件/);
|
||||
assert.match(source, /buildBrowserPlayableVideoURL\(videoURL\)/);
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user