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.
Digital Assets: Rename, Admin Management, Delivery
Status: Waves 1–6 complete and shipping in 6.0 (waves 1–5 shipped 2026-08-10, hardened + rebased 2026-08-12; wave 6 provider-backed assets shipped 2026-08-12; OpenAPI regenerated + dashboard E2E added 2026-08-27, branch mergeable). Wave 7 (license-code pools) deferred to 6.1 — its design is finalized (2026-08-12) but it is purely additive: a new Spree::LicenseCode table and a LicensePool provider built on the shipped wave-6 provider mechanism, changing no wave-1–6 behavior, so it lands after 6.0 without a migration to the shipped surface.
Target: Spree 6.0
Depends on: 6.0-fulfillment-and-delivery.md (Digital fulfillment provider, shipped), 6.0-admin-api.md (endpoint conventions), 6.0-admin-spa.md (dashboard architecture), 6.0-admin-rbac.md (permission catalog), 6.0-store-scoped-configuration.md (preference conventions)
Author: Damian Legawiec
Last updated: 2026-10-24
Summary
Spree ships a complete digital products engine in core: Spree::Digital (a file on a variant, private storage, many per variant) and Spree::DigitalLink (a per-purchase token with click and day limits), auto-fulfilled at order completion — including digital files riding on physically shipped items. But the engine is invisible: there is no Admin API, no dashboard page (the legacy Rails admin UI was deleted with that engine), no email ever delivers a download link, and downloads publish no events, so a merchant needs a console to sell an ebook and a customer never receives a file unless the storefront wires it up. This plan renames the model to Spree::DigitalAsset (the name the docs, the store preferences, and the legacy admin already use), builds the Admin API v3 + dashboard management surface, adds a delivery mailer, a customer downloads endpoint, download events, per-asset limit overrides, and signed-URL download transport — closing the gap between what the engine does and what merchants and customers can see.
Key Decisions (do not deviate without discussion)
- Rename
Spree::Digital→Spree::DigitalAsset(2026-08-10). The model name finally matches the docs, the store preferences (digital_asset_*), and the legacy admin's vocabulary.Spree::DigitalLinkkeeps its name — it reads correctly next toDigitalAsset. Prefixed ID staysdig_. - Full table rename (2026-08-10):
spree_digitals→spree_digital_assets,spree_digital_links.digital_id→digital_asset_id. 6.0 is the breaking window and the categories rename set the precedent; class, table, and FK all match with no pinning. Accepted cost: one schema migration every host runs, one more upgrade-guide step. - Deprecation bridges everywhere, per the standard convention:
Spree::Digital = Spree::DigitalAssetconstant alias with a warning for one release;variant.digitals/product.digitals/digital_link.digitalkept as deprecated twin associations (deprecated: true); internal code uses the new names only. - Lifecycle events dual-emit for one release: new canonical
digital_asset.*events, legacydigital.*twins emitted alongside (same pattern as the fulfillment rename). - Store download route: canonical becomes
GET /api/v3/store/digital_links/:token(the resource being fetched IS the link); the legacyGET /api/v3/store/digitals/:tokenpath keeps working for one release because emailed/bookmarked URLs live in the wild. - Dedicated delivery mailer (2026-08-10):
Spree::DigitalAssetMailerwithfiles_ready_email(sent on order completion when digital links exist) andfile_updated_email(opt-in, on attachment replacement), rather than a section in the order confirmation. Rationale: works for mixed orders, resendable from admin as a standalone action, and survives headless shops replacing the confirmation email. Accepted cost: a second email in the inbox for digital orders. - Per-asset limit overrides (2026-08-10): nullable
authorized_clicks/authorized_daysonspree_digital_assets; null falls back to the store setting. Lets one catalog mix re-download-forever items with time-limited ones. This is an explicit, documented exception to the "store preference is authoritative, no runtime fallback" rule in6.0-store-scoped-configuration.md— the fallback here is record-level (asset → its store's setting), never a chain through global config, and the store setting remains the single authoritative default. - Signed-URL download transport (2026-08-10): the store download action calls
authorize!then redirects to a short-lived signed storage URL instead of proxying bytes throughsend_data, freeing Puma workers for large files. The previously deaddigital_asset_link_expire_timestore preference (default 300) becomes the signed-URL TTL — kept and documented instead of deleted. Accepted cost: clients that expected file bytes on the token URL must follow the redirect (one-release note in the changelog). - Permission catalog placement:
Spree::DigitalAssetjoins the:productscatalog resource (ridesread_products/write_products— catalog data managed from the product page);Spree::DigitalLinkmanagement (reset) joins:orders(write_orders— a per-purchase order artifact). No new catalog resource; digital assets are notsettings-sensitive. - Admin API shape: nested index + create under products (
/admin/products/:product_id/digital_assets), shallow show/update/destroy (/admin/digital_assets/:id), matching existing nested-resource conventions. File upload via direct-upload signed blob (same mechanism as CSV import), never multipart through the API request. - Download visibility ships as an event, not a log table: successful downloads publish a
digital_link.downloadeddomain event (webhook-visible). The dashboard surfacesaccess_counterand last-download time (already tracked —authorize!increments withtouch: true). A persisted per-download log table is deferred until someone needs per-download rows (IP, user agent). - Replacing an asset's file must never break past purchases. Tokens resolve through the link to the current attachment, so replacement transparently updates for every past buyer — this existing behavior becomes a tested guarantee.
- Phantom
:digitalparam removed from the admin products controllerpermitted_params—spree_productshas no such column;digital?is derived from the product type.
Wave 6 — provider-backed assets (design finalized 2026-08-12)
- Ships in 6.0, not 6.1 (2026-08-12). The first prospective customer is a licensing business whose products are entitlements granted by their own system, not files, and they want to launch on 6.0. So provider-backed assets move out of the deferred list into a sixth wave of this plan. The 6.0 model was built for exactly this: the download flow already routes through
DigitalAsset#downloadable?/#download_urland the store controller already redirectsallow_other_host: true, so the change is aprovider_typecolumn plus a small strategy, not a rewrite. - No
kindcolumn — the provider IS the discriminator (2026-08-12, revised from the initialkind-column sketch). Every asset always has a provider; an uploaded file is just the default one. A nullableprovider_typestring column: blank meansSpree::DigitalAssetProvider::File(signs a storage URL, today's behaviour), a class name means that provider. This is exactly howDeliveryMethod#provider_classresolves (fulfillment_provider.presence || DEFAULT), so it is an established pattern, not a new one. A separatekindstring would be redundant state —provider_typealready answers every questionkindwould, and the download flow callsprovider.deliver(link)with no branch at all. Consequence: the three things that genuinely differ by type — record validation, the file-metadata columns, and the admin create form — key offprovider_class, not akindstring. The provider class declares whether it needs an attachment (File#requires_attachment? == true) so validation and the form ask the class rather than switch on a string. - One column:
provider_type(2026-08-12). Just a nullable class-name string. Nointegration_id. - No
Spree::Integrationbinding (2026-08-12, revised). The delivery-rate/tax providers resolve credentials through a storeIntegrationbecause they connect to marketplace services (EasyPost, Avalara) a merchant self-connects. A digital-asset provider here is not that: it is bespoke glue into one company's internal/legacy software, written once in the host app. So the provider owns its own configuration however that app needs it — an env var, a hardcoded endpoint, a Rails credential — and Spree imposes no integration abstraction. The asset names the provider; the provider knows how to reach the legacy system. This drops the integration picker, therequires_integration?predicate, and theintegrationFK entirely. - Provider strategy mirrors the delivery-rate/tax shape, not their credential model (2026-08-12):
Spree::DigitalAssetProvider::Base, stored as theprovider_typeclass-name string on the asset, registered viaSpree.digital_asset_providers. Core ships theFileprovider (the default) as the one concrete implementation; a licensing provider is host-app code that self-configures. - Deliverable is a URL or an inline value (2026-08-12).
deliverreturns aSpree::DigitalDeliveryvalue object (ActiveModel::Model, per the no-Struct rule) carrying either aredirect_urlor aninline_value+content_type. Licensing systems commonly vend a key to display, not a link to follow — forcing everything into a redirect (adata:URI or a Spree-hosted page) would be awkward. Accepted cost: the store download endpoint gains a second response shape (302 vs a 200 body), and a storefront consuming the token URL must handle a non-redirect response. Documented in the store API. - Seam + docs, only the
Fileprovider in core (2026-08-12). Ship the base class, theFiledefault provider (which is just today's download behaviour expressed as a provider), the registry, and a provider-authoring guide — matching how delivery-rate and tax providers began before their reference gems. A third-party-resolving provider is specific to the licensing system and lives in the host app. Accepted cost: nothing runnable out of the box for the licensing case; that provider's author writes Ruby against the documenteddelivercontract. - Link-per-unit, resolve on download (2026-08-12). Order completion still creates one
DigitalLinkper unit (theFulfillmentProvider::Digitalcode is unchanged); the provider is called only when the customer actually downloads. Noon_fulfillmentprovider hook — that would add a second entry point whose failure lands after money is taken (a support incident, not a clean error). A provider that needs to pre-reserve a key does so on first authorized download. Accepted cost: for consumable keys, a link exists before a key is reserved; reservation happens at first download, which suits typical licensing flows. - A provider failure must refuse, not 500, and must not spend the click. The 6.0 controller already settles every refusal before
authorize!increments the counter; wave 6 extends that so a provider exception is caught and returns the same 403 as an expired link, leaving the customer's allowance intact.
Seller panel (decided 2026-10-24, GitHub #14965)
- Sellers manage the files on their own products. The Seller API mirrors the operator's nested endpoint under
/api/v3/seller/products/:product_id/digital_assets, rooted in the seller's own catalog, so any other product is a 404. Changing files is a change to the product, so writes need:updateon it. - Uploads only, no providers. A provider is the operator's integration into their own systems; a seller can neither choose one nor read its settings. An operator-created provider asset on a seller's product is still listed.
- Per-file download limits are the seller's to set, with the same fallback to the store's settings.
- Edit page only. The card needs a saved product; attaching files on the seller's new-product form is deferred until requested.
- One card for both panels. The Digital files card lives in
@spree/dashboard-coreand talks through the registered panel client; the admin registersproviders, the seller panel does not, and the card hides the provider menu. - Seller uploads are off until the marketplace opens them (
seller_digital_assets_enabled, default false, like the two auto-approve settings): a file a buyer downloads under the marketplace's name is one it vouches for. Off, the seller panel shows the operator's files read-only and the Seller API refuses create and replace. - A seller's file must be of an accepted content type (
seller_digital_asset_content_types), checked against the signature Marcel reads from the bytes where the format has one, never the file name; signature-less formats (plain text) keep their declared type. The default list covers documents, ebooks, archives, audio, video, images and plain text; executables, scripts, SVG and unrecognised binaries are out. The operator's own uploads are not restricted. This is policy, not scanning: ZIP is on the list. - A file change on an approved listing reopens its review (
review_seller_digital_asset_changes, default true). Adding or replacing a file, not changing limits or deleting.Products::Proposegains areason:that admits an active product and lands on the submission row's metadata (digital_asset_changed) with who did it, so the queue says why. Moot when seller products auto-approve. Asset-level quarantine (the old file serving until the new one is approved) was considered and deferred to the uploads scanning work, since it needs file versioning. - Every digital asset write runs through a workflow.
DigitalAssets::CreateandUpdate, declared by both controllers and called by the nesteddigital_assetslist on a product write, withvalidate/after_create/after_updatehooks. The seller rules are steps in them, keyed on aseller:argument the seller controller passes; a host's upload scanner registers ondigital_assets.create.validate(the bytes are already in storage) orafter_create.
Wave 7 — license-code pools (design finalized 2026-08-12; deferred to 6.1)
- A license pool is its own wave, and open source (2026-08-12). Selling a finite batch of codes (game keys, gift cards) is the common merchant case that needs no external system — the opposite of wave 6. It is built as a
LicensePoolprovider on the wave-6 seam, so it reusesdeliver/DigitalDeliverywhole, but it is a real stateful feature: aSpree::LicenseCodetable, reservation logic, CSV import, and admin. Ships in core, unlike the wave-6 licensing provider. - Redeemed state is a nullable FK, not a flag (2026-08-12).
LicenseCode#digital_link_idnull means available, set means redeemed by that purchase. "Remaining" is one query; "who redeemed it" is the link's order. No separate boolean. - Text or image, reusing the wave-6 shapes (2026-08-12). A code carries either a
value(rendered as aninline_valuetext body) or an attached scan/photo (served as a signedredirect_url). Both shapes already exist from wave 6 — code selling was, unplanned, the second consumer that validated the two-shape deliverable. - Claim once, pin to the link, re-show the same code (2026-08-12). The first authorized download claims a code and pins it to the
DigitalLink; every later view returns that same code. The click limit caps views, never burns a second code. This forks the download flow from the file case (which re-signs each time), and the fork is the behaviour most worth testing. - CSV import via
Spree::Import, text codes only (2026-08-12). ALicenseCodesRowProcessorturns each row into a code — bulk-paste keys. Images can't ride a CSV row; scans upload individually. This matches merchant behaviour and avoids inventing a binary-CSV path. - Pool count IS the variant's stock (2026-08-12, the sharpest decision). A pool-backed variant tracks inventory with
count_on_handsynced tocodes.available.count, so the existingcan_supply?/add-to-cart path makes it sell out and forbids the "paid but got no code" oversell — no new checkout code. Accepted cost: import and redemption must keep the count in sync transactionally; drift blocks sellable stock or permits an oversell, so the sync is the one delicate piece and gets dedicated tests. This is a real integration withStock::Quantifier, not a flag — today a digital variant returnsINFINITYon-hand; a pool variant must return its finite code count instead.
Design Details
Model rename
spree/core/app/models/spree/digital.rb → digital_asset.rb, class Spree::DigitalAsset. One migration renames the table and the FK column. Associations gain explicit class_name. Spree::DigitalLink gets belongs_to :digital_asset plus deprecated digital reader/writer delegates. Variant#digital_assets, Product#digital_assets (through variants), scope with_digital_assets unchanged in behavior. The optional Spree::Security::DigitalLinks include point is untouched.
New nullable override columns on spree_digital_assets: authorized_clicks, authorized_days (integers, no defaults — null means "use the store setting"). DigitalLink#expired? / #access_limit_exceeded? read the effective value through the asset.
Serializers: DigitalSerializer → DigitalAssetSerializer (store, stays minimal and unmounted), new Admin::DigitalAssetSerializer extending it with variant_id (prefixed), filename, content_type, byte_size, the override fields, timestamps. Dependencies registration renamed with the legacy key readable one release.
Admin API v3
GET /api/v3/admin/products/:product_id/digital_assets— list, includes variant info for the picker.POST /api/v3/admin/products/:product_id/digital_assets— params:variant_id(prefixed; defaults to the product's default variant when absent, mirroring the legacy admin's auto-assign),attachment(signed blob id),authorized_clicks,authorized_days.GET/PATCH/DELETE /api/v3/admin/digital_assets/:id— PATCH acceptsvariant_id, the override fields, and a replacementattachmentblob (which may triggerfile_updated_email, opt-in per request).POST /api/v3/admin/digital_links/:id/reset— zeroes the counter and restarts the expiry clock (DigitalLink#reset!, which has existed since 2021 without a caller).POST /api/v3/admin/orders/:id/resend_digital_links— re-sendsfiles_ready_email.
All lookups scoped through current_store (assets via the product association chain, links via current_store.digital_links).
Dashboard
- Product page — "Digital files" card: listed for products whose type includes the
digitalfulfillment type (and any product that already has assets, so legacy data stays reachable). Upload with progress (direct upload), variant picker, filename + human file size + variant columns, per-file "Custom limits" toggle exposing the two override fields, replace, delete behinduseConfirm({ variant: 'destructive' }). - Order page — links on digital line items: per-link status (clicks used / effective limit, expires-at or expired badge), reset action behind a confirm explaining that it re-opens access, resend-email action.
- Store settings — Downloads section: fields for
limit_digital_download_count,digital_asset_authorized_clicks,limit_digital_download_days,digital_asset_authorized_days,digital_asset_link_expire_time. @spree/admin-sdk:digitalAssetsresource,digitalLinks.reset, order resend; translations in all locale files.
Delivery email
Spree::DigitalAssetMailer in spree/emails, triggered by a subscriber on order completion when the order has digital links (after the auto-fulfill steps in Orders::Complete have created them). files_ready_email lists each purchased file with its download URL; file_updated_email notifies past buyers when an asset's attachment is replaced — opt-in at replacement time, never automatic. Both resendable from the admin order page.
Customer downloads
GET /api/v3/store/account/digital_links — authenticated customer, lists links across their completed orders with product/variant/filename context and authorizability state. Store SDK gains a digitalLinks resource (list + a download-URL helper); today the SDK ships generated types but no methods, so storefronts hand-build URLs.
Download transport and events
The store download action (GET /api/v3/store/digital_links/:token) calls authorize! and redirects (302, allow_other_host: true) to a signed storage URL with expires_in: store.preferred_digital_asset_link_expire_time.seconds and attachment disposition. On success it publishes digital_link.downloaded (payload: prefixed link id, asset id, order id, access counter) — the first domain event in this area, making downloads webhook-visible. Failure keeps the existing 403 with code digital_link_expired.
Wave 6 — provider-backed assets (shipped 2026-08-12)
No kind — every asset has a provider. spree_digital_assets gains a single nullable provider_type (string, class name). DigitalAsset#provider_class resolves (provider_type.presence || DEFAULT).safe_constantize, where DEFAULT is Spree::DigitalAssetProvider::File — identical to DeliveryMethod#provider_class. Existing rows have a blank provider_type and so are File assets, unchanged. There is no discriminator column and no if kind == anywhere.
Validation asks the provider class, not a string. The provider class declares whether it needs an uploaded file — File.requires_attachment? == true, a licensing provider's == false. DigitalAsset validates conditionally: validates :attachment, attached: true, if: -> { provider_class.requires_attachment? }. The click/day limits apply to every asset regardless. This keeps the "what does this type need" knowledge on the type, so a new provider brings its own answer. A provider needing configuration (an endpoint, a credential) reads it from wherever the host app put it — not from a Spree column.
The delivery seam. DigitalAsset#downloadable? and #download_url generalize into a single deliver(digital_link, expires_in:) that delegates straight to the provider — no branch:
def deliver(digital_link, expires_in:)
provider_class.new(self).deliver(digital_link, expires_in: expires_in)
end
It returns a Spree::DigitalDelivery value object:
class Spree::DigitalDelivery
include ActiveModel::Model
include ActiveModel::Attributes
attribute :redirect_url, :string # 302 here …
attribute :inline_value, :string # … or render this body
attribute :content_type, :string
def redirect? = redirect_url.present?
end
The provider strategy. File is the default and the one concrete provider in core:
module Spree
module DigitalAssetProvider
class Base
def self.requires_attachment? = false
def initialize(digital_asset) = @digital_asset = digital_asset
# @return [Spree::DigitalDelivery]
def deliver(digital_link, expires_in:) = raise NotImplementedError
end
class File < Base
def self.requires_attachment? = true
def deliver(_digital_link, expires_in:)
return unless @digital_asset.attachment.attached?
Spree::DigitalDelivery.new(
redirect_url: @digital_asset.attachment.url(expires_in: expires_in, disposition: :attachment)
)
end
end
end
end
Registered via Spree.digital_asset_providers (mirrors Spree.delivery_rate_providers); File registers itself. A licensing provider (SpreeCCLI::LicenseProvider) is host-app code — it self-configures (endpoint, credentials — its own concern) and returns whichever shape fits: a freshly-minted signed link, or an inline_value license key.
The download flow. DigitalLinksController#show calls @resource.digital_asset.deliver(@resource, expires_in: window) inside the same "settle before incrementing" guard. A redirect delivery → 302 as today; an inline delivery → a 200 body with its content type. A provider raising is rescued to the existing 403 — the click is not spent. digital_link.downloaded fires on success regardless of shape. Because File is the default, the file path runs the exact same code today's controller does, now expressed through the provider.
Admin + API. The admin DigitalAsset serializer and params gain provider_type and provider_settings (no kind, no integration_id). The filename/content_type/byte_size attributes already null-out when no attachment is attached, so a provider asset serializes them as null with no serializer change. The dashboard files card's Add file flow gains a source choice: Upload a file (the File provider, shows the file input) or a provider from the registry (shows just a provider selector — no integration picker, since a provider self-configures). The selector is fed by a digital_asset_providers discovery endpoint (same shape as the delivery-provider types endpoint), which returns only the registered providers; a host with no licensing provider registered sees just "Upload a file," so the UI degrades to today's behaviour with nothing extra to explain. The store serializer is unchanged — the customer still sees only download_url, never the provider.
Per-asset provider settings (shipped 2026-08-12). Two kinds of provider configuration, split clean: shared config (an endpoint, a credential — the same for every asset) stays the provider's own concern (env var, Rails credentials), never a Spree column; per-asset config (which license pool this asset draws from, which external product it maps to) is declared by the provider and stored on the asset. A provider declares fields with a class-level setting :key, :type, default:, in: DSL (Base.settings_schema returns the same [{key,type,default}] wire shape as PreferenceSchema#serialized_preference_schema, but is NOT Preferable — the provider is a stateless per-call strategy, not a persisted record, so the values can't live on it). Field types are primitives only: :string, :number, :boolean, :select (no record-reference pickers — a SKU is typed as a string). Values live on the DigitalAsset under one key in metadata (DigitalAsset gains Spree::Metadata + a metadata column; provider_settings reads/writes metadata['provider']), read back in deliver via digital_asset.provider_settings. The providers discovery endpoint carries each provider's settings_schema; picking a provider with a non-empty schema opens a sheet rendering one generic field per entry (a settings-free provider still creates in one click), and the edit sheet shows the same fields for a provider-backed asset. No provider ships dashboard code — the field list is data. Constraint: provider settings are per-asset values only; shared credentials/endpoints never become a setting (that path is the provider's own configuration), and the settings storage stays namespaced under metadata['provider'] so it never collides with other developer metadata.
Wave 7 — license-code pools (deferred to 6.1)
A merchant sells game keys, gift-card codes, activation strings — a finite batch Spree owns and hands out one at a time. Unlike wave 6 (which asks an external system), the pool is fully internal and stateful: it is the open-source "sell codes" feature. It is built as a provider on the wave-6 seam, so it reuses the deliver / DigitalDelivery mechanism whole — including the text-or-image split, which is exactly what code selling needs (a key string, or a scan/photo of a card).
The Spree::LicenseCode model. A new spree_license_codes table:
belongs_to :digital_asset
value :string # the code text — OR —
has_one_attached :attachment # a scan/photo of a card
belongs_to :digital_link, optional: true # null = available; set = redeemed
The nullable digital_link_id IS the redeemed state — no separate flag. "Codes remaining" is codes.where(digital_link_id: nil).count; "who got this code" is the link's order. A code carries either a value or an attachment, never both.
The LicensePool provider (DigitalAssetProvider::LicensePool, ships in core). requires_attachment? == false (the codes carry the payload, not the asset). On deliver(link):
- If the link already has a claimed code (re-download), return that same code — claim once, pin to link, re-show (settled 2026-08-12). A code is consumed per purchased unit exactly once; the click limit still caps views but never burns a second code.
- Otherwise claim the next available code under a row lock (
codes.available.lock.first), set itsdigital_link_id, and return it. - Return shape: a text code →
DigitalDelivery.new(inline_value: code.value, content_type: 'text/plain'); an image code →DigitalDelivery.new(redirect_url: signed_attachment_url). Both shapes already exist from wave 6.
The claim runs in the same "settle before incrementing" guard as every other download, so a pool that has run dry refuses cleanly (403) without spending the click — and never hands out a half-claimed code.
CSV import — reuse Spree::Import. A LicenseCodesRowProcessor (the row_processors/ directory already has a base + siblings) turns each CSV line into a LicenseCode on the target asset — paste a thousand keys, one per row. Images are not bulk-CSV-importable (a row can't carry a binary); scans upload individually on the asset, which matches how merchants work (bulk keys, occasional scans).
Stock coupling — pool count IS the variant's stock (settled 2026-08-12; the sharpest edge). Today a digital variant's Stock::Quantifier#total_on_hand returns INFINITY (infinite copies). A pool-backed variant needs the opposite — finite supply equal to its unredeemed-code count — so it sells out naturally and cannot oversell (the "paid but got no code" failure). This is a real integration with the stock system, not a flag: the pool keeps the variant tracking inventory with count_on_hand synced to codes.available.count — incremented on import, decremented on redemption — so the existing can_supply? / in_stock / add-to-cart path enforces it with no new checkout code. Accepted cost: import and redemption must keep the count in sync transactionally; a drift between codes-available and count_on_hand would either block sellable stock or permit an oversell. This sync is the one genuinely delicate piece of wave 7 and gets its own tests.
Admin. The files card's source choice gains License codes; a pool asset shows a codes-remaining count, an Import codes (CSV) action, and a per-code list (value or image thumbnail, redeemed/available, which order redeemed it). The store serializer is still unchanged — a customer sees only download_url.
Migration Path
Step numbers continue the shipped sequence; the design waves map to steps as: wave 6 (provider) = step 7, wave 7 (pools) = step 8.
Rename wave (core) — shipped 2026-08-10: migration (table + FK rename, override columns), model/file/serializer rename, constant alias + deprecated twin associations, dual-emit events, dependencies key bridge, effective-limit readers. Also landed opportunistically because they touched the same files: the canonical
digital_links/:tokenroute with the legacy path bridged, signed-URL download transport (resurrectingdigital_asset_link_expire_timeas the TTL), thedigital_link.downloadedevent, removal of the phantom:digitalproduct param, and the use-case doc correction. Core (7406 examples) and API (2714 examples) suites green; types, Zod schemas and OpenAPI regenerated.Admin API wave — shipped 2026-08-10: catalog entries (
DigitalAsset→:products, link reset →:orders), controllers + routes + serializers, remove the phantom:digitalproduct param, integration specs, typelizer + OpenAPI regeneration.Dashboard wave — shipped 2026-08-10: admin-sdk resources, product-page Digital files card (upload to private storage, per-file limit overrides, delete), order-page links card (status, reset, resend), store settings Downloads section, translations in all six locales. The product card was reworked on 2026-08-12 — see step 6. No e2e spec yet — the card is covered by API-level specs; add browser coverage when the digital-product flow gets an e2e pass.
Delivery wave — shipped 2026-08-10: mailer + subscriber, customer downloads endpoint + store SDK resource, signed-URL transport +
digital_link.downloadedevent, canonical route + legacy route bridge.Docs correction — shipped 2026-08-10:
admin-capabilities.mdxwas trimmed to reality in wave 1, then re-expanded as the waves landed; the upgrade guide records the renames, the transport change, the new email and the customer endpoint; the webhook reference documentsdigital_asset.*as canonical withdigital.*marked deprecated. The generated OpenAPI specs were regenerated 2026-08-22 with the reproducible swaggerize pass (deterministic since spree/spree#14480).Post-wave hardening — shipped 2026-08-12: three defects found by review after the waves landed. A cross-tenant write (the client's
variant_idwent into mass assignment, so a file could be attached to any product in any store and would then be issued and emailed to that store's customers) is closed by resolving the id through the parent product. The admin listing returned a 500 on PostgreSQL — assets reach a product through its variants, so the association carried the variants'ORDER BY, which is invalid alongside the listing'sDISTINCT; it now orders by its own table. The card itself was rebuilt to read as a listing: values not inputs, editing in a sheet behind the row menu, an admin-only download link and a type icon per file.Provider-backed assets — pending, targeted for 6.0: migration adding
provider_typeonly (nokind, nointegration_id);provider_classresolution + provider-declared validation; thedeliverseam +Spree::DigitalDeliveryvalue object;DigitalAssetProvider::Base+ theFiledefault provider +Spree.digital_asset_providersregistry; the download controller's two-shape response; admin serializer/params/validations + adigital_asset_providersdiscovery endpoint; the dashboard source selector on the files card; the provider-authoring developer guide. Only theFileprovider ships in core; the licensing customer's provider lives in their own app and self-configures. Order (each step green before the next): provider base +File+ registry → migration + model resolution/validation → delivery seam + controller → API → dashboard → docs. (Provider base first soFileexists as the default the migration's model code resolves to.)License-code pools — deferred to 6.1, open source:
spree_license_codesmigration (value / attachment / nullabledigital_link_id); theLicensePoolprovider (claim-once-pin-to-link, text or image); theLicenseCodesRowProcessoron the existingSpree::Importpipeline; the stock sync (count_on_hand←codes.available.count, transactional on import + redeem) wired throughStock::Quantifier; admin (codes-remaining, import action, per-code list); docs. Builds on wave 6's provider seam, so it lands after it, in order:LicenseCodemodel + migration →LicensePoolprovider + the pin-then-reshow flow → stock sync → CSV import → admin → docs. The stock sync lands with its own test battery — it is the piece most able to drift.Seller panel management — in progress 2026-10-24 (GitHub #14965): Seller API nested endpoint, Seller SDK resource, the Digital files card moved to
@spree/dashboard-coreand mounted on the seller product page, a shared request shape and serializer fields for both branches. Extended the same day with the marketplace's rules for a seller's file:DigitalAssets::Create/Updateworkflows (the nested product payload and both endpoints run through them), three store settings on the Marketplace settings page, the seller/meresponse carrying them understore, andProducts::Proposereopening review with areason.
Constraints on Current Work
- New code (including the admin API and dashboard work on this branch) uses
Spree::DigitalAssetanddigital_assetsassociation names only; the legacy names are for the bridge layer. - Any new admin controller touching these models must land with its permission catalog entry (RBAC plan constraint applies).
- The per-asset fallback is the only sanctioned fallback: never add a chain through global
Spree::Config, and new digital behavior settings are born on Store (or the asset), never global. - Do not build a per-download log table, PDF stamping, or streaming features ad hoc — the
digital_link.downloadedevent is the extension point until a real need arrives. - Wave 7: keep a pool variant's
count_on_handand its unredeemed-code count in sync transactionally — import and redeem both write both, in one transaction. A drift silently blocks sellable stock or permits an oversell. Never compute one from the other lazily at read time in the checkout path. - The seller branch never accepts
provider_typeorprovider_settingsand never serializesprovider_settings; a provider stays the operator's own integration. - Digital assets are written only through
Spree.digital_asset_create_workflow/update_workflow— neverDigitalAsset.new+attachin a controller, importer or seed — so a host's upload scanner and the marketplace's seller rules see every file. The seller rules are steps in the workflow keyed onseller:, never checks in a controller. - Do not assume
DigitalAsset#attachmentis present anywhere outside the model — a provider-backed asset has none. Reach fordeliver/downloadable?, neverattachmentdirectly. (The 6.0 model already followed this; wave 6 is why it mattered.) - Wave 6 download-flow code treats the deliverable as opaque (a
DigitalDelivery— URL or inline value), never as a storage URL. A digital-asset provider owns its own configuration (it is host-app glue into internal software) — do NOT add anIntegrationFK or credential surface toDigitalAsset. This deliberately differs from delivery-rate/tax providers, which connect to marketplace services; see the wave 6 decision. - Emailed download URLs are long-lived customer-facing artifacts: any route change must keep old URLs working for at least one release.
Open Questions
Waves 1–5 shipped; wave 6 (provider-backed assets) is designed and pending implementation. Genuinely deferred:
- An
external_urlprovider (a merchant pastes a public URL) — not built now, and needs no schema when it is: it is just anotherDigitalAssetProvidersubclass (requires_attachment? == false) reading a URL off the asset's metadata. Register it and it appears in the source selector. Add when a merchant asks. - License-code pools — designed as wave 7 (see the "Wave 7 — license-code pools" Key Decisions and Design blocks, and Migration Path step 8), deferred to 6.1. A first-class
Spree::LicenseCodepool: CSV-import a batch, one consumed per purchase, text or image, stock-coupled so it sells out. Ships open source. - Per-download log rows (IP, user agent, per-download timestamps) — revisit if merchants ask for more than the counter + event; the event payload is designed so a subscriber can build this externally today.
References
- Plans:
6.0-admin-api.md(the four unchecked digital-asset endpoints this plan implements),6.0-product-types.md(variant-level fulfillment-type gap, 6.1 relief valve),6.0-multi-vendor-marketplace.md(vendor-owned digital catalogs intersect at 6.1),6.0-store-scoped-configuration.md(preference rule this plan records an exception to),6.0-delivery-rate-provider.md/6.0-tax-provider.md(the provider-strategy shape wave 6 mirrors — but NOT theirSpree::Integrationcredential model, which wave 6 deliberately drops),docs/plans/decisions.md2026-08-10 and 2026-08-12. - Code:
spree/core/app/models/spree/digital_asset.rb,digital_link.rb,spree/core/app/models/concerns/spree/purchase/digital_items.rb,spree/core/app/models/spree/fulfillment_provider/digital.rb,spree/core/app/workflows/spree/orders/complete.rb,spree/api/app/controllers/spree/api/v3/store/digital_links_controller.rb,spree/core/lib/spree/core/permission_configuration.rb.