Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Manage digital files and downloads from the dashboard
Damian Legawieca4143dec6335
diff --git a/packages/admin-sdk/src/params.ts b/packages/admin-sdk/src/params.tsindex 68e1de0094..e19f38bbb2 100644--- a/packages/admin-sdk/src/params.ts+++ b/packages/admin-sdk/src/params.ts@@ -72,6 +72,14 @@ export interface StoreUpdateParams {preferred_order_number_suffix?: string/** First sequential order number. Only applies before the store's first order. */preferred_order_number_sequence_start?: number+ /** When false, buyers can download their files as often as they like. */+ preferred_limit_digital_download_count?: boolean+ /** Downloads allowed per purchased file, unless the file overrides it. */+ preferred_digital_asset_authorized_clicks?: number+ /** When false, download links never expire. */+ preferred_limit_digital_download_days?: boolean+ /** Days a download link stays valid, unless the file overrides it. */+ preferred_digital_asset_authorized_days?: number/** Sender address used on all transactional emails (required by the model). */mail_from_address?: string/** Customer-facing reply-to address shown in the storefront/email footer. */@@ -581,6 +589,12 @@ export interface DirectUploadCreateParams {checksum: stringcontent_type: string}+ /**+ * Upload to private storage rather than the public bucket. Needed for files+ * only ever served through a signed link (digital assets) — attaching a blob+ * never moves it between services, so this is decided at upload time.+ */+ private?: boolean}export type MediaType = 'image' | 'video' | 'external_video'diff --git a/packages/admin-sdk/src/types/generated/Store.ts b/packages/admin-sdk/src/types/generated/Store.tsindex d60959cc08..50f9abd8c2 100644--- a/packages/admin-sdk/src/types/generated/Store.ts+++ b/packages/admin-sdk/src/types/generated/Store.ts@@ -1,4 +1,4 @@-// Typelizer digest cbba2cff141ec15159936d17716f76f6+// Typelizer digest f8869482793ad0b975b2258ee740126f//// DO NOT MODIFY: This file was automatically generated by Typelizer.import type {SetupTask} from '@/types'@@ -44,6 +44,10 @@ interface Store {preferred_order_number_prefix: string;preferred_order_number_suffix: string;preferred_order_number_sequence_start: number;+ preferred_limit_digital_download_count: boolean;+ preferred_digital_asset_authorized_clicks: number;+ preferred_limit_digital_download_days: boolean;+ preferred_digital_asset_authorized_days: number;created_at: string;updated_at: string;order_number_sequence_started: boolean;diff --git a/packages/admin-sdk/src/types/generated/index.ts b/packages/admin-sdk/src/types/generated/index.tsindex a813e9ab4e..33ed15c3c2 100644--- a/packages/admin-sdk/src/types/generated/index.ts+++ b/packages/admin-sdk/src/types/generated/index.ts@@ -1,4 +1,4 @@-// Typelizer digest 8c445815bae3ce7c389cf8d6e481f7a1+// Typelizer digest 68675617ca11d85c019637f50ef162ac//// DO NOT MODIFY: This file was automatically generated by Typelizer.export type { default as Address } from './Address'@@ -37,6 +37,7 @@ export type { default as DeliveryProfile } from './DeliveryProfile'export type { default as DeliveryRate } from './DeliveryRate'export type { default as DeliveryZoneMember } from './DeliveryZoneMember'export type { default as DeliveryZone } from './DeliveryZone'+export type { default as DigitalAsset } from './DigitalAsset'export type { default as DigitalLink } from './DigitalLink'export type { default as Discount } from './Discount'export type { default as ExchangeLineItem } from './ExchangeLineItem'diff --git a/packages/dashboard-core/src/hooks/use-direct-upload.ts b/packages/dashboard-core/src/hooks/use-direct-upload.tsindex aaff6b358a..422b1c7377 100644--- a/packages/dashboard-core/src/hooks/use-direct-upload.ts+++ b/packages/dashboard-core/src/hooks/use-direct-upload.ts@@ -51,7 +51,16 @@ function sameOriginIfRailsDisk(url: string): string {}}-export function useDirectUpload() {+interface DirectUploadOptions {+ /**+ * Upload to private storage instead of the public bucket. Required for files+ * that are only ever served through an authorized, signed link — attaching a+ * blob never moves it between services, so this has to be decided up front.+ */+ private?: boolean+}++export function useDirectUpload(options: DirectUploadOptions = {}) {return useMutation({mutationFn: async (file: File): Promise<UploadResult> => {const checksum = await computeMD5Checksum(file)@@ -72,6 +81,7 @@ export function useDirectUpload() {checksum,content_type: file.type || 'application/octet-stream',},+ ...(options.private ? { private: true } : {}),})} catch (err) {throw new Error(`Presign failed: ${err instanceof Error ? err.message : err}`)diff --git a/packages/dashboard/src/components/spree/order-digital-links-card.tsx b/packages/dashboard/src/components/spree/order-digital-links-card.tsxnew file mode 100644index 0000000000..f6652e9882--- /dev/null+++ b/packages/dashboard/src/components/spree/order-digital-links-card.tsx@@ -0,0 +1,107 @@+import type { DigitalLink, Order } from '@spree/admin-sdk'+import { formatStoreDateTime, useStore } from '@spree/dashboard-core'+import {+ Badge,+ Button,+ Card,+ CardContent,+ CardHeader,+ CardTitle,+ Table,+ TableBody,+ TableCell,+ TableHead,+ TableHeader,+ TableRow,+ useConfirm,+} from '@spree/dashboard-ui'+import { RotateCcwIcon } from 'lucide-react'+import { useTranslation } from 'react-i18next'+import { useResetDigitalLink } from '../../hooks/use-digital-assets'++interface LinkRow {+ link: DigitalLink+ itemName: string+}++export function OrderDigitalLinksCard({ order }: { order: Order }) {+ const { t } = useTranslation()+ const { timezone } = useStore()+ const confirm = useConfirm()+ const resetLink = useResetDigitalLink(order.id)++ const rows: LinkRow[] = (order.items ?? []).flatMap((item) =>+ (item.digital_links ?? []).map((link) => ({ link, itemName: item.name })),+ )++ if (rows.length === 0) return null++ async function handleReset(row: LinkRow) {+ const confirmed = await confirm({+ title: t('admin.digital_links.reset_title'),+ message: t('admin.digital_links.reset_description', { name: row.link.filename }),+ })+ if (confirmed) await resetLink.mutateAsync(row.link.id)+ }++ function statusBadge(link: DigitalLink) {+ if (link.expired) {+ return <Badge variant="destructive">{t('admin.digital_links.status.expired')}</Badge>+ }+ if (link.access_limit_exceeded) {+ return <Badge variant="destructive">{t('admin.digital_links.status.used_up')}</Badge>+ }+ return <Badge variant="secondary">{t('admin.digital_links.status.available')}</Badge>+ }++ return (+ <Card>+ <CardHeader>+ <CardTitle>{t('admin.digital_links.title')}</CardTitle>+ </CardHeader>+ <CardContent>+ <div className="overflow-x-auto">+ <Table>+ <TableHeader>+ <TableRow>+ <TableHead>{t('admin.digital_links.columns.file')}</TableHead>+ <TableHead>{t('admin.digital_links.columns.item')}</TableHead>+ <TableHead>{t('admin.digital_links.columns.downloads')}</TableHead>+ <TableHead>{t('admin.digital_links.columns.expires')}</TableHead>+ <TableHead>{t('admin.digital_links.columns.status')}</TableHead>+ <TableHead />+ </TableRow>+ </TableHeader>+ <TableBody>+ {rows.map((row) => (+ <TableRow key={row.link.id}>+ <TableCell className="font-medium">{row.link.filename}</TableCell>+ <TableCell className="text-muted-foreground">{row.itemName}</TableCell>+ <TableCell className="tabular-nums">{row.link.access_counter}</TableCell>+ <TableCell className="text-muted-foreground">+ {row.link.expires_at+ ? formatStoreDateTime(row.link.expires_at, timezone)+ : t('admin.digital_links.never_expires')}+ </TableCell>+ <TableCell>{statusBadge(row.link)}</TableCell>+ <TableCell className="text-right">+ <Button+ type="button"+ variant="ghost"+ size="sm"+ disabled={resetLink.isPending}+ onClick={() => handleReset(row)}+ >+ <RotateCcwIcon className="mr-2 size-4" />+ {t('admin.digital_links.reset')}+ </Button>+ </TableCell>+ </TableRow>+ ))}+ </TableBody>+ </Table>+ </div>+ </CardContent>+ </Card>+ )+}diff --git a/packages/dashboard/src/components/spree/products/digital-assets-card.tsx b/packages/dashboard/src/components/spree/products/digital-assets-card.tsxnew file mode 100644index 0000000000..744848a261--- /dev/null+++ b/packages/dashboard/src/components/spree/products/digital-assets-card.tsx@@ -0,0 +1,234 @@+import type { DigitalAsset, Variant } from '@spree/admin-sdk'+import { useDirectUpload } from '@spree/dashboard-core'+import {+ Button,+ Card,+ CardContent,+ CardHeader,+ CardTitle,+ Input,+ Select,+ SelectContent,+ SelectItem,+ SelectTrigger,+ SelectValue,+ Skeleton,+ Table,+ TableBody,+ TableCell,+ TableHead,+ TableHeader,+ TableRow,+ useConfirm,+} from '@spree/dashboard-ui'+import { FileIcon, Trash2Icon, UploadIcon } from 'lucide-react'+import { useRef, useState } from 'react'+import { useTranslation } from 'react-i18next'+import {+ useCreateDigitalAsset,+ useDeleteDigitalAsset,+ useDigitalAssets,+ useUpdateDigitalAsset,+} from '../../../hooks/use-digital-assets'++function formatFileSize(bytes: number | null | undefined): string {+ if (!bytes) return '—'+ const units = ['B', 'KB', 'MB', 'GB']+ let value = bytes+ let unit = 0+ while (value >= 1024 && unit < units.length - 1) {+ value /= 1024+ unit+++ }+ return `${value.toFixed(unit === 0 ? 0 : 1)} ${units[unit]}`+}++export function DigitalAssetsCard({+ productId,+ variants,+}: {+ productId?: string+ variants?: Variant[]+}) {+ const { t } = useTranslation()+ const confirm = useConfirm()+ const fileInputRef = useRef<HTMLInputElement>(null)+ const [uploadingName, setUploadingName] = useState<string | null>(null)+ const [selectedVariantId, setSelectedVariantId] = useState<string>('')++ // Digital files live on private storage: they are only ever served through an+ // authorized, signed link, never from the public bucket.+ const directUpload = useDirectUpload({ private: true })+ const { data, isLoading } = useDigitalAssets(productId ?? '', Boolean(productId))+ const createAsset = useCreateDigitalAsset(productId ?? '')+ const updateAsset = useUpdateDigitalAsset(productId ?? '')+ const deleteAsset = useDeleteDigitalAsset(productId ?? '')++ const assets: DigitalAsset[] = data?.data ?? []+ const hasVariants = (variants?.length ?? 0) > 1++ async function handleFileSelected(event: React.ChangeEvent<HTMLInputElement>) {+ const file = event.target.files?.[0]+ event.target.value = ''+ if (!file || !productId) return++ setUploadingName(file.name)+ try {+ const { signedId } = await directUpload.mutateAsync(file)+ await createAsset.mutateAsync({+ signed_id: signedId,+ ...(selectedVariantId ? { variant_id: selectedVariantId } : {}),+ })+ } finally {+ setUploadingName(null)+ }+ }++ async function handleDelete(asset: DigitalAsset) {+ const confirmed = await confirm({+ title: t('admin.digital_assets.delete_title'),+ message: t('admin.digital_assets.delete_description', {+ name: asset.filename ?? t('admin.digital_assets.untitled'),+ }),+ variant: 'destructive',+ })+ if (confirmed) await deleteAsset.mutateAsync(asset.id)+ }++ function handleLimitChange(asset: DigitalAsset, field: 'clicks' | 'days', raw: string) {+ const parsed = raw.trim() === '' ? null : Number(raw)+ if (parsed !== null && (!Number.isFinite(parsed) || parsed < 1)) return++ updateAsset.mutate({+ id: asset.id,+ ...(field === 'clicks' ? { authorized_clicks: parsed } : { authorized_days: parsed }),+ })+ }++ if (!productId) return null++ return (+ <Card>+ <CardHeader>+ <CardTitle>{t('admin.digital_assets.title')}</CardTitle>+ </CardHeader>+ <CardContent className="flex flex-col gap-4">+ <p className="text-muted-foreground text-sm">{t('admin.digital_assets.description')}</p>++ {isLoading ? (+ <Skeleton className="h-24 w-full" />+ ) : assets.length === 0 ? (+ <div className="flex flex-col items-center gap-2 rounded-md border border-dashed p-6 text-center">+ <FileIcon className="text-muted-foreground size-6" />+ <p className="text-muted-foreground text-sm">{t('admin.digital_assets.empty')}</p>+ </div>+ ) : (+ <div className="overflow-x-auto">+ <Table>+ <TableHeader>+ <TableRow>+ <TableHead>{t('admin.digital_assets.columns.file')}</TableHead>+ {hasVariants && (+ <TableHead>{t('admin.digital_assets.columns.variant')}</TableHead>+ )}+ <TableHead>{t('admin.digital_assets.columns.size')}</TableHead>+ <TableHead>{t('admin.digital_assets.columns.downloads')}</TableHead>+ <TableHead>{t('admin.digital_assets.columns.days')}</TableHead>+ <TableHead />+ </TableRow>+ </TableHeader>+ <TableBody>+ {assets.map((asset) => (+ <TableRow key={asset.id}>+ <TableCell className="font-medium">+ {asset.filename ?? t('admin.digital_assets.untitled')}+ </TableCell>+ {hasVariants && (+ <TableCell className="text-muted-foreground">+ {variants?.find((v) => v.id === asset.variant_id)?.options_text ?? '—'}+ </TableCell>+ )}+ <TableCell className="tabular-nums">+ {formatFileSize(asset.byte_size)}+ </TableCell>+ <TableCell>+ <Input+ type="number"+ min={1}+ className="w-24"+ defaultValue={asset.authorized_clicks ?? ''}+ placeholder={String(asset.effective_authorized_clicks)}+ aria-label={t('admin.digital_assets.columns.downloads')}+ onBlur={(e) => handleLimitChange(asset, 'clicks', e.target.value)}+ />+ </TableCell>+ <TableCell>+ <Input+ type="number"+ min={1}+ className="w-24"+ defaultValue={asset.authorized_days ?? ''}+ placeholder={String(asset.effective_authorized_days)}+ aria-label={t('admin.digital_assets.columns.days')}+ onBlur={(e) => handleLimitChange(asset, 'days', e.target.value)}+ />+ </TableCell>+ <TableCell className="text-right">+ <Button+ type="button"+ variant="ghost"+ size="icon"+ aria-label={t('admin.common.delete')}+ onClick={() => handleDelete(asset)}+ >+ <Trash2Icon className="size-4" />+ </Button>+ </TableCell>+ </TableRow>+ ))}+ </TableBody>+ </Table>+ </div>+ )}++ <div className="flex flex-wrap items-center gap-2">+ {hasVariants && (+ <Select value={selectedVariantId} onValueChange={setSelectedVariantId}>+ <SelectTrigger className="w-56">+ <SelectValue placeholder={t('admin.digital_assets.all_variants')}>+ {(value) =>+ variants?.find((v) => v.id === value)?.options_text ??+ t('admin.digital_assets.all_variants')+ }+ </SelectValue>+ </SelectTrigger>+ <SelectContent>+ {variants?.map((variant) => (+ <SelectItem key={variant.id} value={variant.id}>+ {variant.options_text || variant.sku}+ </SelectItem>+ ))}+ </SelectContent>+ </Select>+ )}++ <Button+ type="button"+ variant="outline"+ disabled={Boolean(uploadingName)}+ onClick={() => fileInputRef.current?.click()}+ >+ <UploadIcon className="mr-2 size-4" />+ {uploadingName+ ? t('admin.digital_assets.uploading', { name: uploadingName })+ : t('admin.digital_assets.upload')}+ </Button>++ <input ref={fileInputRef} type="file" className="hidden" onChange={handleFileSelected} />+ </div>++ <p className="text-muted-foreground text-xs">{t('admin.digital_assets.limits_help')}</p>+ </CardContent>+ </Card>+ )+}diff --git a/packages/dashboard/src/hooks/use-digital-assets.ts b/packages/dashboard/src/hooks/use-digital-assets.tsnew file mode 100644index 0000000000..a9b0e2d3aa--- /dev/null+++ b/packages/dashboard/src/hooks/use-digital-assets.ts@@ -0,0 +1,59 @@+import { adminClient, i18n, useResourceMutation, useStore } from '@spree/dashboard-core'+import { useQuery } from '@tanstack/react-query'++type DigitalAssetCreateParams = Parameters<typeof adminClient.products.digitalAssets.create>[1]+type DigitalAssetUpdateParams = Parameters<typeof adminClient.products.digitalAssets.update>[2]++export type { DigitalAssetCreateParams, DigitalAssetUpdateParams }++export function useDigitalAssets(productId: string, enabled = true) {+ const { storeId } = useStore()++ return useQuery({+ queryKey: [storeId, 'products', productId, 'digital-assets'],+ queryFn: () => adminClient.products.digitalAssets.list(productId, { per_page: 100 }),+ enabled: enabled && Boolean(productId),+ })+}++export function useCreateDigitalAsset(productId: string) {+ const { storeId } = useStore()++ return useResourceMutation({+ mutationFn: (params: DigitalAssetCreateParams) =>+ adminClient.products.digitalAssets.create(productId, params),+ invalidate: [[storeId, 'products', productId, 'digital-assets']],+ successMessage: i18n.t('admin.messages.digital_asset_saved'),+ })+}++export function useUpdateDigitalAsset(productId: string) {+ const { storeId } = useStore()++ return useResourceMutation({+ mutationFn: ({ id, ...params }: DigitalAssetUpdateParams & { id: string }) =>+ adminClient.products.digitalAssets.update(productId, id, params),+ invalidate: [[storeId, 'products', productId, 'digital-assets']],+ successMessage: i18n.t('admin.messages.digital_asset_saved'),+ })+}++export function useDeleteDigitalAsset(productId: string) {+ const { storeId } = useStore()++ return useResourceMutation({+ mutationFn: (id: string) => adminClient.products.digitalAssets.delete(productId, id),+ invalidate: [[storeId, 'products', productId, 'digital-assets']],+ successMessage: i18n.t('admin.messages.digital_asset_removed'),+ })+}++export function useResetDigitalLink(orderId: string) {+ const { storeId } = useStore()++ return useResourceMutation({+ mutationFn: (id: string) => adminClient.digitalLinks.reset(id),+ invalidate: [[storeId, 'orders', orderId]],+ successMessage: i18n.t('admin.messages.digital_link_reset'),+ })+}diff --git a/packages/dashboard/src/locales/ar.json b/packages/dashboard/src/locales/ar.jsonindex 95464d8821..f1d1f447eb 100644--- a/packages/dashboard/src/locales/ar.json+++ b/packages/dashboard/src/locales/ar.json@@ -842,6 +842,44 @@"to_placeholder": "إلى","toggle_states": "عرض مناطق {{country}}"},+ "digital_assets": {+ "all_variants": "كل المتغيرات",+ "columns": {+ "file": "الملف",+ "variant": "المتغير",+ "size": "الحجم",+ "downloads": "التنزيلات",+ "days": "الأيام"+ },+ "delete_description": "لن يتمكن من اشترى «{{name}}» من تنزيله بعد الآن. يسري هذا فورًا.",+ "delete_title": "حذف هذا الملف؟",+ "description": "ملفات يمكن للمشترين تنزيلها بعد الشراء. أرفقها بمنتج رقمي، أو بمنتج مادي لتسليم دليل أو ضمان مع البضاعة.",+ "empty": "لا توجد ملفات بعد",+ "limits_help": "اترك حدود التنزيل والأيام فارغة لاستخدام إعدادات المتجر.",+ "title": "الملفات الرقمية",+ "untitled": "ملف بدون اسم",+ "upload": "إضافة ملف",+ "uploading": "جارٍ رفع {{name}}…"+ },+ "digital_links": {+ "columns": {+ "file": "الملف",+ "item": "العنصر",+ "downloads": "التنزيلات المستخدمة",+ "expires": "ينتهي في",+ "status": "الحالة"+ },+ "never_expires": "بلا انتهاء",+ "reset": "إعادة تعيين",+ "reset_description": "سيحصل العميل على تنزيلات جديدة لـ «{{name}}» وتبدأ مدة الانتهاء من جديد.",+ "reset_title": "استعادة إمكانية التنزيل؟",+ "status": {+ "available": "متاح",+ "expired": "منتهٍ",+ "used_up": "لا تنزيلات متبقية"+ },+ "title": "التنزيلات"+ },"enterprise": {"learn_more": "تعرّف على Spree Enterprise"},@@ -1891,6 +1929,20 @@"track_price_history": {"help": "الاحتفاظ بالأسعار السابقة ليتمكن المتجر من عرض أقل سعر خلال آخر 30 يومًا، وفقًا لقواعد الاتحاد الأوروبي.","label": "تسجيل سجل الأسعار"+ },+ "limit_digital_download_count": {+ "help": "عند الإيقاف يمكن للمشترين التنزيل بلا حدود.",+ "label": "تحديد عدد التنزيلات"+ },+ "digital_asset_authorized_clicks": {+ "label": "التنزيلات المسموح بها"+ },+ "limit_digital_download_days": {+ "help": "عند الإيقاف لا تنتهي صلاحية روابط التنزيل أبدًا.",+ "label": "تحديد مدة التنزيل"+ },+ "digital_asset_authorized_days": {+ "label": "الأيام المتاحة"}},"store_credit": {@@ -3235,7 +3287,9 @@"tab_payments": "المدفوعات","tab_standards": "المعايير والأشكال","tab_storefront_access": "الوصول إلى المتجر",- "title": "إعدادات المتجر"+ "title": "إعدادات المتجر",+ "tab_downloads": "التنزيلات الرقمية",+ "downloads_help": "مدة صلاحية رابط التنزيل وعدد مرات استخدامه. يمكن لكل ملف تجاوز هذه القيم."},"tax_categories": {"add_sheet_title": "إضافة فئة الضريبة",diff --git a/packages/dashboard/src/locales/de.json b/packages/dashboard/src/locales/de.jsonindex 0e8a64b200..2852466e49 100644--- a/packages/dashboard/src/locales/de.json+++ b/packages/dashboard/src/locales/de.json@@ -825,6 +825,44 @@"to_placeholder": "Bis","toggle_states": "Bundesländer von {{country}} anzeigen"},+ "digital_assets": {+ "all_variants": "Alle Varianten",+ "columns": {+ "file": "Datei",+ "variant": "Variante",+ "size": "Größe",+ "downloads": "Downloads",+ "days": "Tage"+ },+ "delete_description": "„{{name}}“ kann von niemandem mehr heruntergeladen werden, der sie gekauft hat. Dies wirkt sofort.",+ "delete_title": "Diese Datei löschen?",+ "description": "Dateien, die Käufer nach dem Kauf herunterladen können. Fügen Sie sie einem digitalen Produkt hinzu oder einem physischen, um eine Anleitung oder Garantie mitzuliefern.",+ "empty": "Noch keine Dateien",+ "limits_help": "Lassen Sie die Download- und Tageslimits leer, um die Einstellungen des Shops zu verwenden.",+ "title": "Digitale Dateien",+ "untitled": "Unbenannte Datei",+ "upload": "Datei hinzufügen",+ "uploading": "{{name}} wird hochgeladen…"+ },+ "digital_links": {+ "columns": {+ "file": "Datei",+ "item": "Position",+ "downloads": "Genutzte Downloads",+ "expires": "Läuft ab",+ "status": "Status"+ },+ "never_expires": "Kein Ablauf",+ "reset": "Zurücksetzen",+ "reset_description": "Der Kunde erhält neue Downloads für „{{name}}“ und die Ablauffrist beginnt von vorn.",+ "reset_title": "Download-Zugriff wiederherstellen?",+ "status": {+ "available": "Verfügbar",+ "expired": "Abgelaufen",+ "used_up": "Keine Downloads übrig"+ },+ "title": "Downloads"+ },"enterprise": {"learn_more": "Mehr über Spree Enterprise erfahren"},@@ -1874,6 +1912,20 @@"track_price_history": {"help": "Frühere Preise speichern, damit der Shop den niedrigsten Preis der letzten 30 Tage anzeigen kann, wie es EU-Regeln verlangen.","label": "Preisverlauf aufzeichnen"+ },+ "limit_digital_download_count": {+ "help": "Aus bedeutet, dass Käufer beliebig oft herunterladen können.",+ "label": "Anzahl der Downloads begrenzen"+ },+ "digital_asset_authorized_clicks": {+ "label": "Erlaubte Downloads"+ },+ "limit_digital_download_days": {+ "help": "Aus bedeutet, dass Download-Links nie ablaufen.",+ "label": "Download-Zeitraum begrenzen"+ },+ "digital_asset_authorized_days": {+ "label": "Verfügbare Tage"}},"store_credit": {@@ -3219,7 +3271,9 @@"tab_payments": "Zahlungen","tab_standards": "Standards und Formate","tab_storefront_access": "Storefront-Zugriff",- "title": "Shop-Einstellungen"+ "title": "Shop-Einstellungen",+ "tab_downloads": "Digitale Downloads",+ "downloads_help": "Wie lange ein Download-Link gültig ist und wie oft er verwendet werden kann. Einzelne Dateien können diese Werte überschreiben."},"tax_categories": {"add_sheet_title": "Steuerkategorie hinzufügen",diff --git a/packages/dashboard/src/locales/en.json b/packages/dashboard/src/locales/en.jsonindex 2606575ece..7fc8464683 100644--- a/packages/dashboard/src/locales/en.json+++ b/packages/dashboard/src/locales/en.json@@ -825,6 +825,44 @@"to_placeholder": "To","toggle_states": "Show states of {{country}}"},+ "digital_assets": {+ "all_variants": "All variants",+ "columns": {+ "file": "File",+ "variant": "Variant",+ "size": "Size",+ "downloads": "Downloads",+ "days": "Days"+ },+ "delete_description": "\"{{name}}\" will no longer be downloadable by anyone who bought it. This takes effect immediately.",+ "delete_title": "Delete this file?",+ "description": "Files buyers can download after purchase. Attach them to a digital product, or to a physical one to deliver a manual or warranty alongside the goods.",+ "empty": "No files yet",+ "limits_help": "Leave the download and day limits blank to use the store's settings.",+ "title": "Digital files",+ "untitled": "Untitled file",+ "upload": "Add file",+ "uploading": "Uploading {{name}}…"+ },+ "digital_links": {+ "columns": {+ "file": "File",+ "item": "Item",+ "downloads": "Downloads used",+ "expires": "Expires",+ "status": "Status"+ },+ "never_expires": "No expiry",+ "reset": "Reset",+ "reset_description": "The customer gets a fresh set of downloads for \"{{name}}\" and the expiry clock restarts.",+ "reset_title": "Restore download access?",+ "status": {+ "available": "Available",+ "expired": "Expired",+ "used_up": "No downloads left"+ },+ "title": "Downloads"+ },"enterprise": {"learn_more": "Learn about Spree Enterprise"},@@ -1874,6 +1912,20 @@"track_price_history": {"help": "Keep past prices so the storefront can show the lowest price of the last 30 days, as EU rules require.","label": "Record price history"+ },+ "limit_digital_download_count": {+ "help": "Off means buyers can download as often as they like.",+ "label": "Limit number of downloads"+ },+ "digital_asset_authorized_clicks": {+ "label": "Downloads allowed"+ },+ "limit_digital_download_days": {+ "help": "Off means download links never expire.",+ "label": "Limit download period"+ },+ "digital_asset_authorized_days": {+ "label": "Days available"}},"store_credit": {@@ -3219,7 +3271,9 @@"tab_payments": "Payments","tab_standards": "Standards and formats","tab_storefront_access": "Storefront access",- "title": "Store settings"+ "title": "Store settings",+ "tab_downloads": "Digital downloads",+ "downloads_help": "How long a download link works and how many times it can be used. Individual files can override these numbers."},"tax_categories": {"add_sheet_title": "Add tax category",diff --git a/packages/dashboard/src/locales/fr.json b/packages/dashboard/src/locales/fr.jsonindex 4bdb5492b5..3c04773985 100644--- a/packages/dashboard/src/locales/fr.json+++ b/packages/dashboard/src/locales/fr.json@@ -825,6 +825,44 @@"to_placeholder": "À","toggle_states": "Afficher les régions de {{country}}"},+ "digital_assets": {+ "all_variants": "Toutes les variantes",+ "columns": {+ "file": "Fichier",+ "variant": "Variante",+ "size": "Taille",+ "downloads": "Téléchargements",+ "days": "Jours"+ },+ "delete_description": "« {{name}} » ne sera plus téléchargeable par les personnes qui l'ont acheté. Effet immédiat.",+ "delete_title": "Supprimer ce fichier ?",+ "description": "Fichiers que les acheteurs peuvent télécharger après l'achat. Associez-les à un produit numérique, ou à un produit physique pour livrer un manuel ou une garantie.",+ "empty": "Aucun fichier pour le moment",+ "limits_help": "Laissez les limites de téléchargements et de jours vides pour utiliser les paramètres de la boutique.",+ "title": "Fichiers numériques",+ "untitled": "Fichier sans nom",+ "upload": "Ajouter un fichier",+ "uploading": "Téléversement de {{name}}…"+ },+ "digital_links": {+ "columns": {+ "file": "Fichier",+ "item": "Article",+ "downloads": "Téléchargements utilisés",+ "expires": "Expire le",+ "status": "Statut"+ },+ "never_expires": "Pas d'expiration",+ "reset": "Réinitialiser",+ "reset_description": "Le client obtient de nouveaux téléchargements pour « {{name}} » et le délai d'expiration repart à zéro.",+ "reset_title": "Rétablir l'accès au téléchargement ?",+ "status": {+ "available": "Disponible",+ "expired": "Expiré",+ "used_up": "Plus de téléchargements"+ },+ "title": "Téléchargements"+ },"enterprise": {"learn_more": "En savoir plus sur Spree Enterprise"},@@ -1874,6 +1912,20 @@"track_price_history": {"help": "Conserver les anciens prix afin d’afficher le prix le plus bas des 30 derniers jours, comme l’exige la réglementation européenne.","label": "Enregistrer l’historique des prix"+ },+ "limit_digital_download_count": {+ "help": "Désactivé, les acheteurs peuvent télécharger autant de fois qu'ils le souhaitent.",+ "label": "Limiter le nombre de téléchargements"+ },+ "digital_asset_authorized_clicks": {+ "label": "Téléchargements autorisés"+ },+ "limit_digital_download_days": {+ "help": "Désactivé, les liens de téléchargement n'expirent jamais.",+ "label": "Limiter la période de téléchargement"+ },+ "digital_asset_authorized_days": {+ "label": "Jours de disponibilité"}},"store_credit": {@@ -3219,7 +3271,9 @@"tab_payments": "Paiements","tab_standards": "Normes et formats","tab_storefront_access": "Accès à la vitrine",- "title": "Paramètres de la boutique"+ "title": "Paramètres de la boutique",+ "tab_downloads": "Téléchargements numériques",+ "downloads_help": "Durée de validité d'un lien de téléchargement et nombre d'utilisations possibles. Chaque fichier peut remplacer ces valeurs."},"tax_categories": {"add_sheet_title": "Ajouter une catégorie de taxe",diff --git a/packages/dashboard/src/locales/pl.json b/packages/dashboard/src/locales/pl.jsonindex 38e7f11463..c0289aca53 100644--- a/packages/dashboard/src/locales/pl.json+++ b/packages/dashboard/src/locales/pl.json@@ -843,6 +843,44 @@"to_placeholder": "Do","toggle_states": "Pokaż regiony kraju {{country}}"},+ "digital_assets": {+ "all_variants": "Wszystkie warianty",+ "columns": {+ "file": "Plik",+ "variant": "Wariant",+ "size": "Rozmiar",+ "downloads": "Pobrania",+ "days": "Dni"+ },+ "delete_description": "„{{name}}” nie będzie już dostępny do pobrania dla osób, które go kupiły. Zmiana działa natychmiast.",+ "delete_title": "Usunąć ten plik?",+ "description": "Pliki, które kupujący mogą pobrać po zakupie. Dołącz je do produktu cyfrowego lub do fizycznego, aby dostarczyć instrukcję albo gwarancję.",+ "empty": "Brak plików",+ "limits_help": "Pozostaw limity pobrań i dni puste, aby użyć ustawień sklepu.",+ "title": "Pliki cyfrowe",+ "untitled": "Plik bez nazwy",+ "upload": "Dodaj plik",+ "uploading": "Przesyłanie {{name}}…"+ },+ "digital_links": {+ "columns": {+ "file": "Plik",+ "item": "Pozycja",+ "downloads": "Wykorzystane pobrania",+ "expires": "Wygasa",+ "status": "Status"+ },+ "never_expires": "Bez wygaśnięcia",+ "reset": "Zresetuj",+ "reset_description": "Klient otrzyma nowe pobrania pliku „{{name}}”, a czas wygaśnięcia zacznie biec od nowa.",+ "reset_title": "Przywrócić dostęp do pobierania?",+ "status": {+ "available": "Dostępne",+ "expired": "Wygasło",+ "used_up": "Brak pobrań"+ },+ "title": "Pobrania"+ },"enterprise": {"learn_more": "Dowiedz się więcej o Spree Enterprise"},@@ -1892,6 +1930,20 @@"track_price_history": {"help": "Przechowuj poprzednie ceny, aby sklep mógł pokazać najniższą cenę z ostatnich 30 dni, zgodnie z przepisami UE.","label": "Zapisuj historię cen"+ },+ "limit_digital_download_count": {+ "help": "Wyłączone oznacza, że kupujący mogą pobierać dowolną liczbę razy.",+ "label": "Ogranicz liczbę pobrań"+ },+ "digital_asset_authorized_clicks": {+ "label": "Dozwolone pobrania"+ },+ "limit_digital_download_days": {+ "help": "Wyłączone oznacza, że linki do pobrania nigdy nie wygasają.",+ "label": "Ogranicz okres pobierania"+ },+ "digital_asset_authorized_days": {+ "label": "Dostępne dni"}},"store_credit": {@@ -3265,7 +3317,9 @@"tab_payments": "Płatności","tab_standards": "Standardy i formaty","tab_storefront_access": "Dostęp do sklepu",- "title": "Ustawienia sklepu"+ "title": "Ustawienia sklepu",+ "tab_downloads": "Pobrania cyfrowe",+ "downloads_help": "Jak długo działa link do pobrania i ile razy można go użyć. Poszczególne pliki mogą nadpisać te wartości."},"tax_categories": {"add_sheet_title": "Dodaj kategorię podatkową",diff --git a/packages/dashboard/src/locales/zh-CN.json b/packages/dashboard/src/locales/zh-CN.jsonindex 1ad03a2556..2ddfe94444 100644--- a/packages/dashboard/src/locales/zh-CN.json+++ b/packages/dashboard/src/locales/zh-CN.json@@ -820,6 +820,44 @@"to_placeholder": "止","toggle_states": "显示 {{country}} 的省/州"},+ "digital_assets": {+ "all_variants": "所有变体",+ "columns": {+ "file": "文件",+ "variant": "变体",+ "size": "大小",+ "downloads": "下载次数",+ "days": "天数"+ },+ "delete_description": "购买过“{{name}}”的人将无法再下载它。此操作立即生效。",+ "delete_title": "删除此文件?",+ "description": "买家购买后可下载的文件。可附加到数字商品,也可附加到实体商品以随货提供说明书或保修卡。",+ "empty": "暂无文件",+ "limits_help": "将下载次数和天数限制留空即可使用商店设置。",+ "title": "数字文件",+ "untitled": "未命名文件",+ "upload": "添加文件",+ "uploading": "正在上传 {{name}}…"+ },+ "digital_links": {+ "columns": {+ "file": "文件",+ "item": "商品",+ "downloads": "已用下载次数",+ "expires": "到期时间",+ "status": "状态"+ },+ "never_expires": "不过期",+ "reset": "重置",+ "reset_description": "客户将获得“{{name}}”的全新下载次数,过期时间重新开始计算。",+ "reset_title": "恢复下载权限?",+ "status": {+ "available": "可用",+ "expired": "已过期",+ "used_up": "下载次数已用完"+ },+ "title": "下载"+ },"enterprise": {"learn_more": "了解 Spree Enterprise"},@@ -1869,6 +1907,20 @@"track_price_history": {"help": "保留历史价格,以便店铺按欧盟规定显示最近 30 天的最低价。","label": "记录价格历史"+ },+ "limit_digital_download_count": {+ "help": "关闭后,买家可以不限次数下载。",+ "label": "限制下载次数"+ },+ "digital_asset_authorized_clicks": {+ "label": "允许的下载次数"+ },+ "limit_digital_download_days": {+ "help": "关闭后,下载链接永不过期。",+ "label": "限制下载期限"+ },+ "digital_asset_authorized_days": {+ "label": "可用天数"}},"store_credit": {@@ -3211,7 +3263,9 @@"tab_payments": "支付","tab_standards": "标准与格式","tab_storefront_access": "店铺访问权限",- "title": "店铺设置"+ "title": "店铺设置",+ "tab_downloads": "数字下载",+ "downloads_help": "下载链接的有效期以及可使用的次数。单个文件可覆盖这些数值。"},"tax_categories": {"add_sheet_title": "添加税收类别",diff --git a/packages/dashboard/src/routes/_authenticated/$storeId/orders/$orderId/index.tsx b/packages/dashboard/src/routes/_authenticated/$storeId/orders/$orderId/index.tsxindex 1105525886..ad6560c664 100644--- a/packages/dashboard/src/routes/_authenticated/$storeId/orders/$orderId/index.tsx+++ b/packages/dashboard/src/routes/_authenticated/$storeId/orders/$orderId/index.tsx@@ -6,6 +6,7 @@ import {CustomFieldsInlineCard,EditableApiCustomFieldsProvider,} from '../../../../../components/spree/custom-fields/custom-fields-inline'+import { OrderDigitalLinksCard } from '../../../../../components/spree/order-digital-links-card'import {OrderClaimsCard,OrderExchangesCard,@@ -58,6 +59,7 @@ function OrderDetailPage() {main={<><FulfillmentsCard order={order} />+ <OrderDigitalLinksCard order={order} /><OrderReturnsCard order={order} /><OrderExchangesCard order={order} /><OrderClaimsCard order={order} />diff --git a/packages/dashboard/src/routes/_authenticated/$storeId/products/$productId.tsx b/packages/dashboard/src/routes/_authenticated/$storeId/products/$productId.tsxindex 9dc6c1155c..9298bc8705 100644--- a/packages/dashboard/src/routes/_authenticated/$storeId/products/$productId.tsx+++ b/packages/dashboard/src/routes/_authenticated/$storeId/products/$productId.tsx@@ -39,6 +39,7 @@ import { FormProvider, useForm, useWatch } from 'react-hook-form'import { useTranslation } from 'react-i18next'import { CustomFieldsInlineCard } from '../../../../components/spree/custom-fields/custom-fields-inline'import { MediaRichTextEditor } from '../../../../components/spree/media-rich-text-editor'+import { DigitalAssetsCard } from '../../../../components/spree/products/digital-assets-card'import { ProductCustomFieldsProvider } from '../../../../components/spree/products/product-custom-fields-provider'import { ProductReviewActions } from '../../../../components/spree/products/product-review-actions'import { ProductSellerCard } from '../../../../components/spree/products/product-seller-card'@@ -282,6 +283,7 @@ function ProductForm({ product }: { product: Product }) {<GeneralCard form={form} descriptionEditor={MediaRichTextEditor} /><VariantsCard form={form} /><MediaCard productId={productId} variants={assignableVariants} form={form} />+ <DigitalAssetsCard productId={productId} variants={assignableVariants} /><PricesCard form={form} productName={product.name} /><InventoryCardform={form}diff --git a/packages/dashboard/src/routes/_authenticated/$storeId/settings/store.tsx b/packages/dashboard/src/routes/_authenticated/$storeId/settings/store.tsxindex 441234631b..39b67705cd 100644--- a/packages/dashboard/src/routes/_authenticated/$storeId/settings/store.tsx+++ b/packages/dashboard/src/routes/_authenticated/$storeId/settings/store.tsx@@ -148,6 +148,10 @@ function storeToFormValues(store: Store): StoreSettingsFormValues {preferred_order_number_sequence_start: Number(store.preferred_order_number_sequence_start ?? 1001,),+ preferred_limit_digital_download_count: store.preferred_limit_digital_download_count ?? true,+ preferred_digital_asset_authorized_clicks: store.preferred_digital_asset_authorized_clicks ?? 5,+ preferred_limit_digital_download_days: store.preferred_limit_digital_download_days ?? true,+ preferred_digital_asset_authorized_days: store.preferred_digital_asset_authorized_days ?? 7,}}@@ -272,6 +276,10 @@ function StoreSettingsForm({ store }: { store: Store }) {preferred_order_number_prefix: values.preferred_order_number_prefix,preferred_order_number_suffix: values.preferred_order_number_suffix,preferred_order_number_sequence_start: values.preferred_order_number_sequence_start,+ preferred_limit_digital_download_count: values.preferred_limit_digital_download_count,+ preferred_digital_asset_authorized_clicks: values.preferred_digital_asset_authorized_clicks,+ preferred_limit_digital_download_days: values.preferred_limit_digital_download_days,+ preferred_digital_asset_authorized_days: values.preferred_digital_asset_authorized_days,...extensionValues,})toastManager.add({ type: 'success', title: t('admin.messages.store_settings_updated') })@@ -824,6 +832,102 @@ function StoreSettingsForm({ store }: { store: Store }) {</FieldGroup></CardContent></Card>+ <Card>+ <CardHeader>+ <CardTitle>{t('admin.pages.settings.store.tab_downloads')}</CardTitle>+ </CardHeader>+ <CardContent>+ <FieldGroup>+ <p className="text-muted-foreground text-sm">+ {t('admin.pages.settings.store.downloads_help')}+ </p>+ <Field>+ <div className="flex items-start justify-between gap-4">+ <div className="flex flex-col">+ <FieldLabel+ htmlFor="store-limit-download-count"+ className="cursor-pointer"+ >+ {t('admin.fields.store.limit_digital_download_count.label')}+ </FieldLabel>+ <span className="text-muted-foreground text-xs">+ {t('admin.fields.store.limit_digital_download_count.help')}+ </span>+ </div>+ <Controller+ name="preferred_limit_digital_download_count"+ control={form.control}+ render={({ field }) => (+ <Switch+ id="store-limit-download-count"+ checked={!!field.value}+ onCheckedChange={field.onChange}+ />+ )}+ />+ </div>+ </Field>+ {form.watch('preferred_limit_digital_download_count') && (+ <Field>+ <FieldLabel htmlFor="store-authorized-clicks">+ {t('admin.fields.store.digital_asset_authorized_clicks.label')}+ </FieldLabel>+ <Input+ id="store-authorized-clicks"+ type="number"+ min={1}+ {...form.register('preferred_digital_asset_authorized_clicks')}+ />+ <FieldError+ errors={[form.formState.errors.preferred_digital_asset_authorized_clicks]}+ />+ </Field>+ )}+ <Field>+ <div className="flex items-start justify-between gap-4">+ <div className="flex flex-col">+ <FieldLabel+ htmlFor="store-limit-download-days"+ className="cursor-pointer"+ >+ {t('admin.fields.store.limit_digital_download_days.label')}+ </FieldLabel>+ <span className="text-muted-foreground text-xs">+ {t('admin.fields.store.limit_digital_download_days.help')}+ </span>+ </div>+ <Controller+ name="preferred_limit_digital_download_days"+ control={form.control}+ render={({ field }) => (+ <Switch+ id="store-limit-download-days"+ checked={!!field.value}+ onCheckedChange={field.onChange}+ />+ )}+ />+ </div>+ </Field>+ {form.watch('preferred_limit_digital_download_days') && (+ <Field>+ <FieldLabel htmlFor="store-authorized-days">+ {t('admin.fields.store.digital_asset_authorized_days.label')}+ </FieldLabel>+ <Input+ id="store-authorized-days"+ type="number"+ min={1}+ {...form.register('preferred_digital_asset_authorized_days')}+ />+ <FieldError+ errors={[form.formState.errors.preferred_digital_asset_authorized_days]}+ />+ </Field>+ )}+ </FieldGroup>+ </CardContent>+ </Card><Slot name="store.form_main" context={{ store }} /></>}diff --git a/packages/dashboard/src/schemas/store.ts b/packages/dashboard/src/schemas/store.tsindex 7776ff39d8..362bdf5259 100644--- a/packages/dashboard/src/schemas/store.ts+++ b/packages/dashboard/src/schemas/store.ts@@ -74,6 +74,18 @@ export const storeSettingsFormSchema = z.object({.max(10).regex(NUMBER_AFFIX_PATTERN, { error: 'admin.fields.store.order_number_suffix.invalid' }),preferred_order_number_sequence_start: z.coerce.number().int().min(1),+ // Store-wide download allowances. Individual files can override the numbers;+ // switching a limit off here removes it for the whole store.+ preferred_limit_digital_download_count: z.boolean(),+ preferred_digital_asset_authorized_clicks: z.coerce+ .number()+ .int()+ .min(1, { error: requiredMessage('store.preferred_digital_asset_authorized_clicks') }),+ preferred_limit_digital_download_days: z.boolean(),+ preferred_digital_asset_authorized_days: z.coerce+ .number()+ .int()+ .min(1, { error: requiredMessage('store.preferred_digital_asset_authorized_days') }),})export type StoreSettingsFormValues = z.infer<typeof storeSettingsFormSchema>diff --git a/packages/sdk/src/types/generated/index.ts b/packages/sdk/src/types/generated/index.tsindex a87509318c..1990bd3e92 100644--- a/packages/sdk/src/types/generated/index.ts+++ b/packages/sdk/src/types/generated/index.ts@@ -1,4 +1,4 @@-// Typelizer digest df73cbf138735b17d49c9baa3b6a097a+// Typelizer digest 71ba6d932aa5bd91922d19e68b242a92//// DO NOT MODIFY: This file was automatically generated by Typelizer.export type { default as Address } from './Address'diff --git a/spree/api/app/serializers/spree/api/v3/admin/store_serializer.rb b/spree/api/app/serializers/spree/api/v3/admin/store_serializer.rbindex 913d378f40..56d556756a 100644--- a/spree/api/app/serializers/spree/api/v3/admin/store_serializer.rb+++ b/spree/api/app/serializers/spree/api/v3/admin/store_serializer.rb@@ -45,6 +45,10 @@ module Spreepreferred_order_number_suffix: :string,preferred_order_number_sequence_start: :number,order_number_sequence_started: :boolean,+ preferred_limit_digital_download_count: :boolean,+ preferred_digital_asset_authorized_clicks: :number,+ preferred_limit_digital_download_days: :boolean,+ preferred_digital_asset_authorized_days: :number,metadata: 'Record<string, unknown>'attributes :metadata,@@ -86,6 +90,10 @@ module Spree:preferred_order_number_prefix,:preferred_order_number_suffix,:preferred_order_number_sequence_start,+ :preferred_limit_digital_download_count,+ :preferred_digital_asset_authorized_clicks,+ :preferred_limit_digital_download_days,+ :preferred_digital_asset_authorized_days,created_at: :iso8601, updated_at: :iso8601# Once the counter has issued a number the starting value no longer