flowdefinition

package
v1.0.0-alpha.21 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 3, 2026 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package flowdefinition holds shared encoding helpers for the flow_definitions definition JSON column used by v2 dialect statements.

Index

Constants

This section is empty.

Variables

View Source
var Schema = database.NewSchema(map[domain.FlowDefinitionField]database.FieldBinding[domain.FlowDefinition]{
	domain.FlowDefinitionFieldProjectID: {
		SQLName:  "project_id",
		Accessor: func(d *domain.FlowDefinition) any { return d.ProjectID },
		Coerce:   database.CoerceString,
	},
	domain.FlowDefinitionFieldID: {
		SQLName:  "id",
		Accessor: func(d *domain.FlowDefinition) any { return d.ID },
		Coerce:   database.CoerceString,
	},
	domain.FlowDefinitionFieldName: {
		SQLName:  "name",
		Accessor: func(d *domain.FlowDefinition) any { return d.Name },
		Coerce:   database.CoerceString,
	},
	domain.FlowDefinitionFieldSchemaVersion: {
		SQLName:  "schema_version",
		Accessor: func(d *domain.FlowDefinition) any { return d.SchemaVersion },
		Coerce:   database.CoerceString,
	},
	domain.FlowDefinitionFieldStatus: {
		SQLName:   "status",
		Accessor:  func(d *domain.FlowDefinition) any { return d.Status.String() },
		Coerce:    database.CoerceString,
		ParamCast: "::zitadel_nextgen.flow_definition_states",
	},
	domain.FlowDefinitionFieldCreatedAt: {
		SQLName:  "created_at",
		Accessor: func(d *domain.FlowDefinition) any { return d.CreatedAt },
		Coerce:   database.CoerceTime,
	},
	domain.FlowDefinitionFieldUpdatedAt: {
		SQLName:  "updated_at",
		Accessor: func(d *domain.FlowDefinition) any { return d.UpdatedAt },
		Coerce:   database.CoerceTime,
	},
	domain.FlowDefinitionFieldPurposes: {
		SQLName:   "purposes",
		Accessor:  func(d *domain.FlowDefinition) any { return d.Purposes },
		Coerce:    database.CoerceEnumKeyMapAsAny[domain.FlowDefinitionPurpose, string](ParsePurposeKey),
		ParamCast: "::zitadel_nextgen.flow_definition_purposes",
	},
})

Schema binds flow definition list/filter/order fields for both dialects. Nested payload (user schema, audience, steps) lives in the definition JSON column and is handled by Marshal/ToDomain — not as list Schema columns.

Functions

func EnsureListOptions

EnsureListOptions returns opts with the default CreatedAt+ID DESC order when OrderBy is unset. A nil opts becomes an empty ListOptions.

func Marshal

func Marshal(def *domain.FlowDefinition) ([]byte, error)

Marshal converts the domain aggregate's nested fields into JSON for the definition column.

func ParsePurposeKey

func ParsePurposeKey(s string) (domain.FlowDefinitionPurpose, error)

ParsePurposeKey parses a purposes map key from a cursor token.

func PurposeStrings

func PurposeStrings(def *domain.FlowDefinition) []string

PurposeStrings returns the denormalized purposes array column values.

func ToDomain

func ToDomain(
	projectID, id, name, schemaVersion string,
	status domain.FlowDefinitionStatus,
	createdAt, updatedAt time.Time,
	rawDefinition []byte,
) (*domain.FlowDefinition, error)

ToDomain converts scanned row columns plus definition JSON into the domain aggregate.

Types

type ActionJSON

type ActionJSON struct {
	Name    string `json:"name"`
	Kind    string `json:"kind"`
	TextKey string `json:"text_key,omitempty"`
	Primary bool   `json:"primary,omitempty"`
}

type AudienceJSON

type AudienceJSON struct {
	AppIDs  []string `json:"app_ids,omitempty"`
	TeamIDs []string `json:"team_ids,omitempty"`
}

type Content

type Content struct {
	UserSchema string            `json:"user_schema"`
	Purposes   map[string]string `json:"purposes"`
	Audience   AudienceJSON      `json:"audience"`
	Steps      []StepJSON        `json:"steps"`
}

Content is the structure stored inside the definition JSON/JSONB column.

type GateJSON

type GateJSON struct {
	Kind     string         `json:"kind"`
	Provider string         `json:"provider,omitempty"`
	Config   map[string]any `json:"config,omitempty"`
}

type SSOProviderJSON

type SSOProviderJSON struct {
	ID       string `json:"id"`
	Name     string `json:"name"`
	Template string `json:"template"`
}

type StepJSON

type StepJSON struct {
	Name         string                    `json:"name"`
	Fields       []string                  `json:"fields,omitempty"`
	Actions      []ActionJSON              `json:"actions,omitempty"`
	Gates        map[string]GateJSON       `json:"gates,omitempty"`
	SSOProviders []SSOProviderJSON         `json:"sso_providers,omitempty"`
	OnSuccess    *string                   `json:"on_success,omitempty"`
	Complete     *string                   `json:"complete,omitempty"`
	Transitions  map[string]TransitionJSON `json:"transitions,omitempty"`
}

type TransitionJSON

type TransitionJSON struct {
	Action  *string `json:"action,omitempty"`
	Purpose *string `json:"purpose,omitempty"`
	Target  string  `json:"target"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL