PhoenixKitManufacturing.Comments (PhoenixKitManufacturing v0.3.2)

Copy Markdown View Source

Thin isolation layer over the optional PhoenixKitComments module for Manufacturing resources.

A simplified adaptation of PhoenixKitWarehouse.Comments: same kind-parameterized shape, but with a single resource kind (:machine) today. The parameterization is kept (rather than collapsing to machine-only functions) so a future :operation/:defect_reason kind can be added here without reshaping callers — mirrors the precedent.

Every function degrades gracefully when phoenix_kit_comments 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 resource. Returns 0 when unavailable.

Comment counts for many resources 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 resource kind.

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

Unsubscribes the calling process from the given resource uuids.

Types

kind()

@type kind() :: :machine

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 resource. Returns 0 when unavailable.

counts(kind, uuids)

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

Comment counts for many resources 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 resource kind.

subscribe(kind, uuids)

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

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

unsubscribe(kind, uuids)

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

Unsubscribes the calling process from the given resource uuids.