Documentation
¶
Overview ¶
Package mixin provides reusable Ent schema mixins for SystemForge entities.
Package mixin provides Ent mixins for composing SystemForge identity fields into application schemas.
Package mixin provides Ent mixins for composing SystemForge fields into application schemas.
Package mixin provides Ent mixins for composing SystemForge identity fields into application schemas.
Index ¶
- func MembershipRoles() []string
- func PrincipalTypes() []string
- type APIKey
- type AgentMixin
- type ApplicationMixin
- type BFFSession
- type BaseMixin
- type CreatorOrgMixin
- type HumanMixin
- type LicenseMixin
- type ListingMixin
- type MembershipBase
- type MembershipRole
- type OAuthAccountMixin
- type OrganizationBase
- type PrincipalMembershipMixin
- type PrincipalMixin
- type PrincipalType
- type RefreshTokenMixin
- type SeatAssignmentMixin
- type ServicePrincipalMixin
- type SubscriptionMixin
- type TimestampMixin
- type UUIDMixin
- type UserBase
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MembershipRoles ¶
func MembershipRoles() []string
MembershipRoles returns all standard membership roles.
func PrincipalTypes ¶
func PrincipalTypes() []string
PrincipalTypes returns all valid principal types for use in Ent enum fields.
Types ¶
type APIKey ¶
APIKey provides common fields for API key entities. Apps use this mixin in their Ent schema and implement EntClientInterface to connect SystemForge's EntStore to their generated Ent client.
Example usage in app schema:
func (APIKey) Mixin() []ent.Mixin {
return []ent.Mixin{
mixin.APIKey{},
}
}
type AgentMixin ¶
AgentMixin provides fields for the Agent entity (AI agents). Agent extends Principal with AI agent-specific data. Use this mixin for AI agents that act on behalf of humans or organizations.
func (AgentMixin) Indexes ¶
func (AgentMixin) Indexes() []ent.Index
Indexes returns indexes for the Agent entity.
type ApplicationMixin ¶
ApplicationMixin provides fields for the Application entity (OAuth clients). Application extends Principal with OAuth client-specific data. Use this mixin for OAuth2 client applications.
Apps must define:
- principal_id field (FK to Principal)
- Edge from Principal to Application
func (ApplicationMixin) Fields ¶
func (ApplicationMixin) Fields() []ent.Field
Fields returns the Application fields.
func (ApplicationMixin) Indexes ¶
func (ApplicationMixin) Indexes() []ent.Index
Indexes returns indexes for the Application entity.
type BFFSession ¶
BFFSession provides common fields for BFF session entities. Apps use this mixin in their Ent schema and implement EntClientInterface to connect SystemForge's EntStore to their generated Ent client.
Example usage in app schema:
func (BFFSession) Mixin() []ent.Mixin {
return []ent.Mixin{
mixin.BFFSession{},
}
}
func (BFFSession) Indexes ¶
func (BFFSession) Indexes() []ent.Index
Indexes of the BFFSession mixin.
type BaseMixin ¶
BaseMixin combines UUID and Timestamp mixins for convenience. This is the most commonly used mixin for SystemForge-compatible entities.
type CreatorOrgMixin ¶
CreatorOrgMixin provides fields for creator/publisher organizations. Use this mixin for organizations that create and sell products on the marketplace. This is separate from OrganizationBase which is for consumer organizations.
func (CreatorOrgMixin) Fields ¶
func (CreatorOrgMixin) Fields() []ent.Field
Fields returns the creator organization fields.
type HumanMixin ¶
HumanMixin provides fields for the Human entity. Human extends Principal with human-specific data (email, name, avatar, etc.). Use this mixin to create Human entities in your app.
Apps must define:
- principal_id field (FK to Principal)
- Edge from Principal to Human
Example usage:
type Human struct {
ent.Schema
}
func (Human) Mixin() []ent.Mixin {
return []ent.Mixin{
cfmixin.HumanMixin{},
}
}
func (Human) Fields() []ent.Field {
return []ent.Field{
// App-specific fields (e.g., bio, headline, username)
}
}
func (Human) Edges() []ent.Edge {
return []ent.Edge{
edge.From("principal", Principal.Type).
Ref("human").
Field("principal_id").
Unique().
Required().
Immutable(),
}
}
func (HumanMixin) Indexes ¶
func (HumanMixin) Indexes() []ent.Index
Indexes returns indexes for the Human entity.
type LicenseMixin ¶
LicenseMixin provides the core fields for marketplace licenses. Apps can use this mixin to create their own License schema while adding app-specific fields and edges.
func (LicenseMixin) Fields ¶
func (LicenseMixin) Fields() []ent.Field
Fields returns the core license fields.
type ListingMixin ¶
ListingMixin provides the core fields for marketplace listings. Apps can use this mixin to create their own Listing schema while adding app-specific fields and edges.
Example usage:
type Listing struct {
ent.Schema
}
func (Listing) Mixin() []ent.Mixin {
return []ent.Mixin{
mixin.ListingMixin{},
}
}
func (Listing) Fields() []ent.Field {
return []ent.Field{
// App-specific fields
field.UUID("course_id", uuid.UUID{}).Optional(),
}
}
func (ListingMixin) Fields ¶
func (ListingMixin) Fields() []ent.Field
Fields returns the core listing fields.
type MembershipBase ¶
MembershipBase provides the core membership fields for composition. Apps can use this mixin to get SystemForge-compatible membership fields while customizing role values for their domain.
func (MembershipBase) Fields ¶
func (MembershipBase) Fields() []ent.Field
Fields returns the core membership fields.
type MembershipRole ¶
type MembershipRole string
MembershipRole defines the standard roles for organization membership.
const ( // MembershipRoleOwner has full control including billing and deletion. MembershipRoleOwner MembershipRole = "owner" // MembershipRoleAdmin can manage members and most settings. MembershipRoleAdmin MembershipRole = "admin" // MembershipRoleEditor can create and modify content. MembershipRoleEditor MembershipRole = "editor" // MembershipRoleViewer can only view content. MembershipRoleViewer MembershipRole = "viewer" )
type OAuthAccountMixin ¶
OAuthAccountMixin provides fields for the OAuthAccount entity. OAuthAccount stores OAuth provider connections for principals. Use this mixin to create OAuthAccount entities in your app.
Apps must define:
- principal_id field (FK to Principal)
- Edge from Principal to OAuthAccount
Example usage:
type OAuthAccount struct {
ent.Schema
}
func (OAuthAccount) Mixin() []ent.Mixin {
return []ent.Mixin{
cfmixin.OAuthAccountMixin{},
}
}
func (OAuthAccount) Edges() []ent.Edge {
return []ent.Edge{
edge.From("principal", Principal.Type).
Ref("oauth_accounts").
Field("principal_id").
Unique().
Required(),
}
}
func (OAuthAccountMixin) Fields ¶
func (OAuthAccountMixin) Fields() []ent.Field
Fields returns the OAuthAccount fields.
func (OAuthAccountMixin) Indexes ¶
func (OAuthAccountMixin) Indexes() []ent.Index
Indexes returns indexes for the OAuthAccount entity.
type OrganizationBase ¶
OrganizationBase provides the core organization fields for composition. Apps can use this mixin to get SystemForge-compatible organization fields while adding their own custom fields or renaming to match their domain (e.g., Team, Tenant, Workspace).
func (OrganizationBase) Fields ¶
func (OrganizationBase) Fields() []ent.Field
Fields returns the core organization fields.
type PrincipalMembershipMixin ¶
PrincipalMembershipMixin provides fields for the PrincipalMembership entity. PrincipalMembership links Principals to Organizations with roles. Use this mixin to create PrincipalMembership entities in your app.
Apps must define:
- Edges from Principal and Organization to PrincipalMembership
Example usage:
type PrincipalMembership struct {
ent.Schema
}
func (PrincipalMembership) Mixin() []ent.Mixin {
return []ent.Mixin{
cfmixin.PrincipalMembershipMixin{},
}
}
func (PrincipalMembership) Edges() []ent.Edge {
return []ent.Edge{
edge.From("principal", Principal.Type).
Ref("memberships").
Field("principal_id").
Unique().
Required(),
edge.From("organization", Organization.Type).
Ref("principal_memberships").
Field("organization_id").
Unique().
Required(),
}
}
func (PrincipalMembershipMixin) Fields ¶
func (PrincipalMembershipMixin) Fields() []ent.Field
Fields returns the PrincipalMembership fields.
func (PrincipalMembershipMixin) Indexes ¶
func (PrincipalMembershipMixin) Indexes() []ent.Index
Indexes returns indexes for the PrincipalMembership entity.
type PrincipalMixin ¶
PrincipalMixin provides fields for the Principal entity. Principal is the unified identity type representing any actor in the system. Use this mixin to create Principal entities in your app.
Apps must define edges to:
- Human (one-to-one, optional) - for human-specific data
- OAuthAccount (one-to-many) - for OAuth connections
- RefreshToken (one-to-many) - for token management
- PrincipalMembership (one-to-many) - for organization membership
Example usage:
type Principal struct {
ent.Schema
}
func (Principal) Mixin() []ent.Mixin {
return []ent.Mixin{
cfmixin.PrincipalMixin{},
}
}
func (Principal) Fields() []ent.Field {
return []ent.Field{
// App-specific fields if needed
}
}
func (Principal) Edges() []ent.Edge {
return []ent.Edge{
edge.To("human", Human.Type).Unique(),
edge.To("oauth_accounts", OAuthAccount.Type),
edge.To("refresh_tokens", RefreshToken.Type),
edge.To("memberships", PrincipalMembership.Type),
}
}
func (PrincipalMixin) Fields ¶
func (PrincipalMixin) Fields() []ent.Field
Fields returns the Principal fields.
func (PrincipalMixin) Indexes ¶
func (PrincipalMixin) Indexes() []ent.Index
Indexes returns indexes for the Principal entity.
type PrincipalType ¶
type PrincipalType string
PrincipalType defines the types of principals in the identity system.
const ( // PrincipalTypeHuman represents a human user. PrincipalTypeHuman PrincipalType = "human" // PrincipalTypeApplication represents an OAuth application/client. PrincipalTypeApplication PrincipalType = "application" // PrincipalTypeAgent represents an AI agent or automated actor. PrincipalTypeAgent PrincipalType = "agent" // PrincipalTypeService represents a service account for system processes. PrincipalTypeService PrincipalType = "service" )
type RefreshTokenMixin ¶
RefreshTokenMixin provides fields for the RefreshToken entity. RefreshToken stores refresh tokens for token-based authentication. Use this mixin to create RefreshToken entities in your app.
Apps must define:
- principal_id field (FK to Principal)
- Edge from Principal to RefreshToken
Example usage:
type RefreshToken struct {
ent.Schema
}
func (RefreshToken) Mixin() []ent.Mixin {
return []ent.Mixin{
cfmixin.RefreshTokenMixin{},
}
}
func (RefreshToken) Edges() []ent.Edge {
return []ent.Edge{
edge.From("principal", Principal.Type).
Ref("refresh_tokens").
Field("principal_id").
Unique().
Required(),
}
}
func (RefreshTokenMixin) Fields ¶
func (RefreshTokenMixin) Fields() []ent.Field
Fields returns the RefreshToken fields.
func (RefreshTokenMixin) Indexes ¶
func (RefreshTokenMixin) Indexes() []ent.Index
Indexes returns indexes for the RefreshToken entity.
type SeatAssignmentMixin ¶
SeatAssignmentMixin provides the core fields for license seat assignments. Apps can use this mixin to track which principals are assigned to license seats.
func (SeatAssignmentMixin) Fields ¶
func (SeatAssignmentMixin) Fields() []ent.Field
Fields returns the seat assignment fields.
type ServicePrincipalMixin ¶
ServicePrincipalMixin provides fields for the ServicePrincipal entity. ServicePrincipal extends Principal for system service accounts. Use this mixin for background jobs, cron tasks, and system processes.
func (ServicePrincipalMixin) Fields ¶
func (ServicePrincipalMixin) Fields() []ent.Field
Fields returns the ServicePrincipal fields.
func (ServicePrincipalMixin) Indexes ¶
func (ServicePrincipalMixin) Indexes() []ent.Index
Indexes returns indexes for the ServicePrincipal entity.
type SubscriptionMixin ¶
SubscriptionMixin provides the core fields for platform subscriptions. Apps can use this mixin to create their own Subscription schema for tracking organization-level platform access.
func (SubscriptionMixin) Fields ¶
func (SubscriptionMixin) Fields() []ent.Field
Fields returns the core subscription fields.
type TimestampMixin ¶
TimestampMixin provides created_at and updated_at timestamp fields. Use this for automatic timestamp tracking in your schema.
func (TimestampMixin) Fields ¶
func (TimestampMixin) Fields() []ent.Field
Fields returns the timestamp fields.
type UUIDMixin ¶
UUIDMixin provides a UUID primary key field. Use this when you want UUID-based primary keys in your schema.
type UserBase ¶
UserBase provides the core user fields for composition into app schemas. Apps can use this mixin to get SystemForge-compatible user fields while adding their own custom fields.
Example usage:
type User struct {
ent.Schema
}
func (User) Mixin() []ent.Mixin {
return []ent.Mixin{
mixin.UserBase{},
}
}
func (User) Fields() []ent.Field {
return []ent.Field{
// App-specific fields
field.String("username").Unique(),
}
}