Read-only queries for sequences, sequence versions, and steps.
Complements DripDrop.SequenceAuthoring, which owns writes for the same
aggregates. Sequence reads take an explicit tenant_key because a sequence
key is only unique within its tenant scope (or globally, when
tenant_key is nil). Sequence version and step reads are looked up by
id, so they inherit tenant scope implicitly from the row they belong to.
Summary
Functions
Fetches a sequence's currently active version, or nil when none is active.
Fetches a sequence's currently active version, raising when none is active.
Fetches a sequence by key within a tenant scope.
Fetches the most recently authored step for a key across all of a
sequence's versions, or nil when no version has ever contained that step.
Returns the highest version number authored for a sequence, or 0 when the
sequence has no versions yet.
Lists a sequence version's steps, ordered by their position in the cadence.
Maps a sequence version's steps by their key (e.g. "invitation").
Functions
@spec get_active_sequence_version(Ecto.UUID.t()) :: DripDrop.SequenceVersion.t() | nil
Fetches a sequence's currently active version, or nil when none is active.
A half-provisioned sequence (row created, activation never completed) has no active version; callers use this non-raising read to detect that.
@spec get_active_sequence_version!(Ecto.UUID.t()) :: DripDrop.SequenceVersion.t()
Fetches a sequence's currently active version, raising when none is active.
@spec get_sequence(binary() | nil, String.t()) :: Ecto.Schema.t() | nil
Fetches a sequence by key within a tenant scope.
Pass nil for tenant_key to look up a global (tenant-less) sequence.
Returns nil when no such sequence has been provisioned.
@spec latest_step_by_key(Ecto.UUID.t(), String.t()) :: DripDrop.Step.t() | nil
Fetches the most recently authored step for a key across all of a
sequence's versions, or nil when no version has ever contained that step.
A step disabled in (or absent from) the active version is recovered from the newest prior version that still carries it.
@spec max_version_number(Ecto.UUID.t()) :: non_neg_integer()
Returns the highest version number authored for a sequence, or 0 when the
sequence has no versions yet.
Useful for computing the next version number when authoring a fresh
version, so a re-versioned sequence never collides with a lingering draft
on the unique (sequence, version) index.
@spec ordered_steps(Ecto.UUID.t()) :: [DripDrop.Step.t()]
Lists a sequence version's steps, ordered by their position in the cadence.
@spec steps_by_key(Ecto.UUID.t()) :: %{required(String.t()) => DripDrop.Step.t()}
Maps a sequence version's steps by their key (e.g. "invitation").