Files
archie/internal/app/controlplane/workflow_enablement.go
T
sam dc1b61d394 feat(eda): per-org workflow enable/disable gating bindings
A workflow-enablement control-plane resource lists, per org, the workflows
that org has disabled. A binding targeting a disabled workflow is skipped at
dispatch like an unarmed one, is refused on save, and is flagged on the
binding list; the workflows page toggles it. Bindings now carry the org_id
column they already had in storage, over the State Store wire too.

Org-owned workflow definitions are deferred to a follow-up bead: they need
the caller's org, which the access chain resolves.
2026-09-30 02:59:23 +10:00

39 lines
1.4 KiB
Go

package controlplane
import (
"context"
"encoding/json"
"github.com/samcharles93/archie-core/internal/config"
pb "github.com/samcharles93/archie-core/internal/contracts/controlplane/v1"
"github.com/samcharles93/archie-core/internal/domain/org"
"github.com/samcharles93/archie-core/internal/domain/workflow/task"
"github.com/samcharles93/archie-core/internal/infrastructure/controlplanerpc"
)
const WorkflowEnablementKind = "workflow-enablement"
func workflowEnablementDefinition() Definition {
return Definition{
Kind: WorkflowEnablementKind,
Title: "Workflow enablement",
Document: task.WorkflowEnablement{},
ApplyMode: "live",
Seed: func(config.Config) any { return task.WorkflowEnablement{Orgs: map[org.OrgID]task.OrgWorkflows{}} },
Validate: func(input []byte) error {
return validateAs(input, func(enablement task.WorkflowEnablement) error { return enablement.Validate() })
},
}
}
// WorkflowEnablement returns which workflows each org has disabled.
func (c *Client) WorkflowEnablement(ctx context.Context) (task.WorkflowEnablement, error) {
response, err := c.rpc.Query(ctx, &pb.QueryRequest{Kind: WorkflowEnablementKind})
if err != nil {
return task.WorkflowEnablement{}, controlplanerpc.ClientError(err)
}
var enablement task.WorkflowEnablement
err = json.Unmarshal(response.Resource.ValueJson, &enablement)
return enablement, err
}