feat: add product archive metadata store

This commit is contained in:
2026-09-12 13:04:32 +08:00
parent 0877ae73e8
commit bf24d20be9
3 changed files with 477 additions and 1 deletions
+68 -1
View File
@@ -2,11 +2,78 @@ from __future__ import annotations
from datetime import datetime
from pathlib import Path
from typing import Literal
from typing import Any, Literal
from pydantic import BaseModel, Field
class ProductInput(BaseModel):
source: Literal["manual", "external"]
external_product_id: str | None = None
name: str
sku: str = ""
specification: str = ""
def __init__(
self,
source: Literal["manual", "external"] | None = None,
external_product_id: str | None = None,
name: str | None = None,
sku: str = "",
specification: str = "",
**data: Any,
) -> None:
if source is not None:
data["source"] = source
if external_product_id is not None or "external_product_id" not in data:
data["external_product_id"] = external_product_id
if name is not None:
data["name"] = name
if sku or "sku" not in data:
data["sku"] = sku
if specification or "specification" not in data:
data["specification"] = specification
super().__init__(**data)
class ProductRecord(BaseModel):
product_id: str
source: Literal["manual", "external"]
external_product_id: str | None = None
name: str
sku: str = ""
specification: str = ""
status: Literal["active", "pending_cleanup", "purged"] = "active"
created_at: datetime
updated_at: datetime
purge_after: datetime | None = None
class ProductVersionRecord(BaseModel):
version_id: str
product_id: str
version: str = ""
metadata: dict[str, Any] = Field(default_factory=dict)
created_at: datetime
class ProductImageRecord(BaseModel):
image_id: str
product_id: str
version_id: str
image_path: str = ""
image_type: str = ""
created_at: datetime
class ProductWordcloudArchiveRecord(BaseModel):
archive_id: str
product_id: str
version_id: str
archive_path: str = ""
created_at: datetime
class JobCreateResponse(BaseModel):
job_id: str