Documentation
¶
Overview ¶
Package mixin provides Ent mixins for composing CoreForge identity fields into application schemas.
Package mixin provides Ent mixins for composing CoreForge fields into application schemas.
Package mixin provides Ent mixins for composing CoreForge identity fields into application schemas.
Index ¶
- func MembershipRoles() []string
- func PrincipalTypes() []string
- type AgentMixin
- type ApplicationMixin
- 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 ¶ added in v0.3.0
func MembershipRoles() []string
MembershipRoles returns all standard membership roles.
func PrincipalTypes ¶ added in v0.3.0
func PrincipalTypes() []string
PrincipalTypes returns all valid principal types for use in Ent enum fields.
Types ¶
type AgentMixin ¶ added in v0.3.0
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) Fields ¶ added in v0.3.0
func (AgentMixin) Fields() []ent.Field
Fields returns the Agent fields.
func (AgentMixin) Indexes ¶ added in v0.3.0
func (AgentMixin) Indexes() []ent.Index
Indexes returns indexes for the Agent entity.
type ApplicationMixin ¶ added in v0.3.0
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 ¶ added in v0.3.0
func (ApplicationMixin) Fields() []ent.Field
Fields returns the Application fields.
func (ApplicationMixin) Indexes ¶ added in v0.3.0
func (ApplicationMixin) Indexes() []ent.Index
Indexes returns indexes for the Application entity.
type BaseMixin ¶
BaseMixin combines UUID and Timestamp mixins for convenience. This is the most commonly used mixin for CoreForge-compatible entities.
type CreatorOrgMixin ¶ added in v0.3.0
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 ¶ added in v0.3.0
func (CreatorOrgMixin) Fields() []ent.Field
Fields returns the creator organization fields.
type HumanMixin ¶ added in v0.3.0
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) Fields ¶ added in v0.3.0
func (HumanMixin) Fields() []ent.Field
Fields returns the Human fields.
func (HumanMixin) Indexes ¶ added in v0.3.0
func (HumanMixin) Indexes() []ent.Index
Indexes returns indexes for the Human entity.
type LicenseMixin ¶ added in v0.3.0
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 ¶ added in v0.3.0
func (LicenseMixin) Fields() []ent.Field
Fields returns the core license fields.
type ListingMixin ¶ added in v0.3.0
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 ¶ added in v0.3.0
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 CoreForge-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 ¶ added in v0.3.0
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 ¶ added in v0.3.0
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 ¶ added in v0.3.0
func (OAuthAccountMixin) Fields() []ent.Field
Fields returns the OAuthAccount fields.
func (OAuthAccountMixin) Indexes ¶ added in v0.3.0
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 CoreForge-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 ¶ added in v0.3.0
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 ¶ added in v0.3.0
func (PrincipalMembershipMixin) Fields() []ent.Field
Fields returns the PrincipalMembership fields.
func (PrincipalMembershipMixin) Indexes ¶ added in v0.3.0
func (PrincipalMembershipMixin) Indexes() []ent.Index
Indexes returns indexes for the PrincipalMembership entity.
type PrincipalMixin ¶ added in v0.3.0
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 ¶ added in v0.3.0
func (PrincipalMixin) Fields() []ent.Field
Fields returns the Principal fields.
func (PrincipalMixin) Indexes ¶ added in v0.3.0
func (PrincipalMixin) Indexes() []ent.Index
Indexes returns indexes for the Principal entity.
type PrincipalType ¶ added in v0.3.0
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 ¶ added in v0.3.0
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 ¶ added in v0.3.0
func (RefreshTokenMixin) Fields() []ent.Field
Fields returns the RefreshToken fields.
func (RefreshTokenMixin) Indexes ¶ added in v0.3.0
func (RefreshTokenMixin) Indexes() []ent.Index
Indexes returns indexes for the RefreshToken entity.
type SeatAssignmentMixin ¶ added in v0.3.0
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 ¶ added in v0.3.0
func (SeatAssignmentMixin) Fields() []ent.Field
Fields returns the seat assignment fields.
type ServicePrincipalMixin ¶ added in v0.3.0
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 ¶ added in v0.3.0
func (ServicePrincipalMixin) Fields() []ent.Field
Fields returns the ServicePrincipal fields.
func (ServicePrincipalMixin) Indexes ¶ added in v0.3.0
func (ServicePrincipalMixin) Indexes() []ent.Index
Indexes returns indexes for the ServicePrincipal entity.
type SubscriptionMixin ¶ added in v0.3.0
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 ¶ added in v0.3.0
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 CoreForge-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(),
}
}