Documentation
¶
Overview ¶
Package draft holds the Outbox drafts: posts the loop proposes and the user approves before they reach a provider.
Index ¶
Constants ¶
const ( WithdrawAssigned = "assigned" WithdrawMoot = "moot" )
The reasons a workflow withdraws a draft it proposed, as Reason of the discarded draft: its person was assigned the items, or it is moot.
Variables ¶
var ApprovalModes = []ApprovalMode{Send, Delay, Wait, DryRun}
ApprovalModes are the draft approval's modes.
ConversationKinds are the kinds slack_draft offers on a conversation: all but a review comment and an edit, which slack_edit makes at once.
var ErrTransition = errors.New("draft: transition not allowed")
ErrTransition is wrapped by Can.
var Open = []State{Held, Queued, Sending}
Open are the states in which a draft may still be posted.
Functions ¶
func SettledAt ¶ added in v0.2.0
SettledAt is the newest UpdatedAt of the drafts of ds that workflow proposed on subject and that settled, sent or dropped (withdrawn ones included; a failed draft may still be approved again); zero when none. A draft is on a task subject when it serves that task, and on any other subject when it is on that unit.
Types ¶
type Approval ¶
type Approval struct {
Mode ApprovalMode
Window time.Duration // Mode "delay" only, > 0
}
type ApprovalMode ¶
type ApprovalMode string // "wait" (default), "delay", "send", "dry_run"
const ( Wait ApprovalMode = "wait" Delay ApprovalMode = "delay" Send ApprovalMode = "send" DryRun ApprovalMode = "dry_run" )
func ModeOf ¶ added in v0.3.0
func ModeOf(m gate.Mode) ApprovalMode
ModeOf is a gate's approval mode as a draft's: send and run send it.
func (ApprovalMode) Releases ¶ added in v0.2.0
func (m ApprovalMode) Releases() bool
Releases says whether m sends a draft with no person approving it.
type Condition ¶ added in v0.2.0
Condition is a rule's compiled when over the facts RuleFacts and the unit's facts give.
type Decision ¶ added in v0.2.0
type Decision struct {
Approval Approval
// Rule is the index of the rule that matched; -1 for none.
Rule int
// PostReleased says that a rule naming d's delivery released a draft
// whose delivery posts, the only way one is sent with no person
// approving it.
PostReleased bool
}
Decision is the approval Decide picked and why.
type Delivery ¶ added in v0.2.0
type Delivery string // "message", "reaction", "comment", "edit"
Delivery is how a draft reaches the provider.
type Draft ¶
type Draft struct {
ID ID
Unit unit.Unit
Items []string // item ids of Unit; may be empty
Task string // the task it serves, "" none; the Outbox row of the draft itself is "draft:<ID>"
Kind Kind
Purpose string // what it is for: "nudge", "close", "ask_owner", or any label its proposer names
Delivery Delivery // how it is posted
Effects []string // applied when it is sent, such as "task.nudged"
Target string // plugin target grammar; "" means the unit itself (its thread, its PR)
Text string // standard Markdown with mentions as @{<person key>}; the Effects implementation converts both
Reaction string // Kind "react" only: emoji name without colons
Replaced string // Kind "edit" only: the text the edit replaced
Original string // Text as proposed
Edited bool // Text != Original
Origin Origin
State State
Evidence Evidence // State "sent" only
Error string // State "failed" only, never a token
Reason string // State "dropped": "user", "assigned", "moot", "dry_run", ...
Rev int64 // the stored row's version; every Update bumps it
// EffectsAppliedAt is when the Effects of a sent draft were applied;
// zero while they are not.
EffectsAppliedAt time.Time
CreatedAt, UpdatedAt, SendingAt time.Time
}
type Kind ¶
type Kind string // "reply", "nudge", "close", "react", "ask_owner", "comment", "edit"
type Origin ¶
type Origin struct {
Kind OriginKind
TurnSeq int64 // Kind "turn": the turn (session or headless) that proposed it; Kind "session": the handle's newest turn on the unit, 0 none
Intent string // the proposing turn's intent ("" for auto and user)
Workflow string // the workflow that started the proposing turn (turn.Turn.Workflow), "" none
Rule string // Kind "auto": the core or plugin rule, e.g. "stalled-nudge", "closure", "ask-owner", "github-nudge"
Key string // Kind "auto": the rule's dedupe key, e.g. "stalled-nudge:<task>:<person key>"
// Unit is the unit of the proposing turn when it is not the draft's, such
// as a pull request whose turn drafts in a Slack thread; zero when it is.
Unit unit.Unit
}
type OriginKind ¶
type OriginKind string // "turn", "session", "auto", "user"
const ( OriginTurn OriginKind = "turn" OriginSession OriginKind = "session" OriginAuto OriginKind = "auto" OriginUser OriginKind = "user" )
type Policy ¶ added in v0.2.0
type Policy struct {
Default Approval
Rules []Rule
// Scope is the workflow whose scoped facts of the subject the rules
// read; "" reads the unit's facts unscoped.
Scope string
}
Policy is the approval of a proposer's drafts: the first Rule whose When holds, else Default.
func (Policy) Decide ¶ added in v0.2.0
Decide is d's approval under p over the facts of its subject s; posts says that d's delivery reaches people, as its plugin's manifest declares it. A rule applies only when the facts it reads are of s's slot, a rule that releases applies to a draft that posts only when it names d's delivery, and a draft that posts no such rule releases waits for a person unless the approval is dry_run.
func (Policy) ReadsSubject ¶ added in v0.2.0
ReadsSubject says whether a rule of p reads a fact of the draft's subject.
type Rule ¶ added in v0.2.0
type Rule struct {
When Condition
Approval Approval
// Names is the delivery When holds for alone, which its top-level
// conjunction pins; "" for none. A rule releases a draft whose delivery
// posts only when it names that delivery.
Names Delivery
// Subjects are the slots of the subject facts When reads; the rule
// applies only to a draft whose subject is of that slot.
Subjects []string
}
Rule is one [gates.approval] rule of a draft gate.