# `PhoenixKitCatalogue.Export`
[🔗](https://github.com/BeamLabEU/phoenix_kit_catalogue/blob/v0.19.0/lib/phoenix_kit_catalogue/export.ex#L1)

Export context for the Catalogue module.

Drives the Export tab: registry of destinations, item selection, and
in-memory file generation. Nothing is persisted to disk.

## Usage

    destinations = Export.destinations()
    items        = Export.list_export_items(catalogue_uuids)

    {filename, content, mime} = Export.build(%{
      destination: :pro100,
      format: :furniture,
      catalogue_uuids: [uuid1, uuid2]
    })

# `build`

```elixir
@spec build(map()) :: {String.t(), iodata(), String.t()}
```

Builds the export file in memory.

`params` is a map with keys:
- `:destination` — atom or string destination key (e.g. `:pro100` or `"pro100"`)
- `:format` — atom or string format key (e.g. `:furniture` or `"furniture"`)
- `:catalogue_uuids` — list of catalogue UUIDs to export
- `:prefix_catalogue` — optional; when truthy, PRO100 text formats prefix each
  item name with its catalogue name (`"<catalogue> / <item>"`). Default false.

Returns `{filename, iodata, mime_type}`.

Raises `ArgumentError` if the destination or format is not recognised, or if
`catalogue_uuids` is nil/missing.

# `destination_by_key`

```elixir
@spec destination_by_key(atom() | String.t()) :: module() | nil
```

Finds a destination module by its atom key, or `nil` if not found.

# `destinations`

```elixir
@spec destinations() :: [module()]
```

Returns the list of registered export destination modules.
Each element implements `PhoenixKitCatalogue.Export.Destination`.

# `list_export_items`

```elixir
@spec list_export_items([Ecto.UUID.t()]) :: [PhoenixKitCatalogue.Schemas.Item.t()]
```

Lists non-deleted items for export across one or more catalogues.

Returns all active items where `catalogue_uuid in ^catalogue_uuids` and
`status != "deleted"`, ordered by catalogue, then category position, then
item position, then name. The `:catalogue` and `:category` associations are
preloaded on every item.

Returns `[]` when `catalogue_uuids` is empty.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
