PhoenixKitCatalogue.Catalogue.Links (PhoenixKitCatalogue v0.1.14)

Copy Markdown View Source

Manufacturer ↔ Supplier many-to-many links.

Add and remove individual links via link_*/unlink_*; sync the full set for one side via sync_*. Bulk syncs run inside a single transaction and emit one summary activity entry (added + removed counts).

Public surface is re-exported from PhoenixKitCatalogue.Catalogue.

Summary

Functions

Creates a many-to-many link between a manufacturer and a supplier.

Returns a list of manufacturer UUIDs linked to a supplier.

Returns a list of supplier UUIDs linked to a manufacturer.

Lists all manufacturers linked to a supplier, ordered by name.

Lists all suppliers linked to a manufacturer, ordered by name.

Syncs the supplier links for a manufacturer to match the given list of supplier UUIDs.

Syncs the manufacturer links for a supplier to match the given list of manufacturer UUIDs.

Removes the link between a manufacturer and a supplier.

Functions

linked_manufacturer_uuids(supplier_uuid)

@spec linked_manufacturer_uuids(Ecto.UUID.t()) :: [Ecto.UUID.t()]

Returns a list of manufacturer UUIDs linked to a supplier.

linked_supplier_uuids(manufacturer_uuid)

@spec linked_supplier_uuids(Ecto.UUID.t()) :: [Ecto.UUID.t()]

Returns a list of supplier UUIDs linked to a manufacturer.

list_manufacturers_for_supplier(supplier_uuid)

@spec list_manufacturers_for_supplier(Ecto.UUID.t()) :: [
  PhoenixKitCatalogue.Schemas.Manufacturer.t()
]

Lists all manufacturers linked to a supplier, ordered by name.

list_suppliers_for_manufacturer(manufacturer_uuid)

@spec list_suppliers_for_manufacturer(Ecto.UUID.t()) :: [
  PhoenixKitCatalogue.Schemas.Supplier.t()
]

Lists all suppliers linked to a manufacturer, ordered by name.

sync_manufacturer_suppliers(manufacturer_uuid, supplier_uuids, opts \\ [])

@spec sync_manufacturer_suppliers(Ecto.UUID.t(), [Ecto.UUID.t()], keyword()) ::
  {:ok, :synced} | {:error, term()}

Syncs the supplier links for a manufacturer to match the given list of supplier UUIDs.

Adds missing links and removes extra ones via set difference. Returns {:ok, :synced} on success or {:error, reason} on the first failure.

sync_supplier_manufacturers(supplier_uuid, manufacturer_uuids, opts \\ [])

@spec sync_supplier_manufacturers(Ecto.UUID.t(), [Ecto.UUID.t()], keyword()) ::
  {:ok, :synced} | {:error, term()}

Syncs the manufacturer links for a supplier to match the given list of manufacturer UUIDs.

Adds missing links and removes extra ones via set difference. Returns {:ok, :synced} on success or {:error, reason} on the first failure.