PhoenixKitWarehouse.Comments (PhoenixKitWarehouse v0.1.0)

Copy Markdown View Source

Thin isolation layer over the optional PhoenixKitComments module for every warehouse document kind.

Consolidates what were 5 near-byte-identical *_comments.ex wrapper modules in Andi (goods_issue_comments.ex, goods_receipt_comments.ex, internal_order_comments.ex, supplier_order_comments.ex, inventory_comments.ex) into one module parameterized by a kind atom. Every function degrades gracefully when the comments module is absent or disabled, so callers never special-case it.

Summary

Functions

True when the comments module is installed and enabled.

Comment count for one document. Returns 0 when unavailable.

Comment counts for many documents of the same kind, as a uuid => count map. Every requested uuid is present (value 0 when it has no comments). Returns an empty map when the module is unavailable.

The comment resource_type string used for the given document kind.

Subscribes the calling process to cross-session comment activity for the given document uuids. No-op when the module is unavailable.

Unsubscribes the calling process from the given document uuids.

Types

kind()

@type kind() ::
  :goods_issue | :goods_receipt | :internal_order | :supplier_order | :inventory

Functions

available?()

@spec available?() :: boolean()

True when the comments module is installed and enabled.

count(kind, uuid)

@spec count(kind(), binary()) :: non_neg_integer()

Comment count for one document. Returns 0 when unavailable.

counts(kind, uuids)

@spec counts(kind(), [binary()]) :: %{optional(binary()) => non_neg_integer()}

Comment counts for many documents of the same kind, as a uuid => count map. Every requested uuid is present (value 0 when it has no comments). Returns an empty map when the module is unavailable.

resource_type(kind)

@spec resource_type(kind()) :: String.t()

The comment resource_type string used for the given document kind.

subscribe(kind, uuids)

@spec subscribe(kind(), [binary()]) :: :ok

Subscribes the calling process to cross-session comment activity for the given document uuids. No-op when the module is unavailable.

unsubscribe(kind, uuids)

@spec unsubscribe(kind(), [binary()]) :: :ok

Unsubscribes the calling process from the given document uuids.