refactor(terminology): rename user-facing tenant labels to workspace
Align product copy, API docs, Swagger descriptions, and i18n strings with workspace terminology while keeping internal tenant identifiers and headers unchanged for API compatibility.
This commit is contained in:
@@ -96,7 +96,7 @@ const (
|
||||
// {key, value_type, old_value, new_value} — sensitive values are
|
||||
// redacted server-side before logging when is_secret=true (P3+;
|
||||
// for now no setting is marked secret). Audit rows always have
|
||||
// tenant_id=0 because the change is system-scope, not tenant-scope.
|
||||
// tenant_id=0 because the change is system-scope, not workspace-scoped.
|
||||
AuditActionSystemSettingChanged AuditAction = "system.setting_changed"
|
||||
|
||||
// AuditActionSystemAdminPromoted fires when a SystemAdmin grants
|
||||
|
||||
@@ -87,7 +87,7 @@ type CustomAgent struct {
|
||||
DeletedAt gorm.DeletedAt `yaml:"deleted_at" json:"deleted_at" gorm:"index"`
|
||||
|
||||
// CreatorName 由 list handler 在返回前批量回填,作用同 KnowledgeBase.CreatorName:
|
||||
// 让前端列表卡片区分「我创建」与「同租户其他成员创建」。不落库,内建 agent / 老数据
|
||||
// 让前端列表卡片区分「我创建」与「同空间其他成员创建」。不落库,内建 agent / 老数据
|
||||
// 仍可能为空。
|
||||
CreatorName string `yaml:"-" json:"creator_name,omitempty" gorm:"-"`
|
||||
}
|
||||
@@ -162,14 +162,14 @@ type CustomAgentConfig struct {
|
||||
// ===== Image Upload / Multimodal Settings =====
|
||||
// Whether image upload is enabled for this agent (default: false)
|
||||
ImageUploadEnabled bool `yaml:"image_upload_enabled" json:"image_upload_enabled"`
|
||||
// VLM model ID for image analysis (optional, falls back to tenant-level VLM)
|
||||
// VLM model ID for image analysis (optional, falls back to workspace-level VLM)
|
||||
VLMModelID string `yaml:"vlm_model_id" json:"vlm_model_id"`
|
||||
// Whether audio upload (ASR transcription) is enabled for this agent (default: false)
|
||||
AudioUploadEnabled bool `yaml:"audio_upload_enabled" json:"audio_upload_enabled"`
|
||||
// ASR model ID for audio transcription (optional)
|
||||
ASRModelID string `yaml:"asr_model_id" json:"asr_model_id"`
|
||||
// Storage provider for image uploads: "local", "minio", "cos", "tos", "s3", "oss", "ks3".
|
||||
// Empty means use the global/tenant default provider.
|
||||
// Empty means use the global/workspace default provider.
|
||||
ImageStorageProvider string `yaml:"image_storage_provider" json:"image_storage_provider"`
|
||||
|
||||
// ===== File Type Restriction Settings =====
|
||||
@@ -199,7 +199,7 @@ type CustomAgentConfig struct {
|
||||
// Maximum web search results
|
||||
WebSearchMaxResults int `yaml:"web_search_max_results" json:"web_search_max_results"`
|
||||
// WebSearchProviderID references a specific WebSearchProviderEntity.
|
||||
// If empty, the tenant's default provider (is_default=true) is used.
|
||||
// If empty, the workspace's default provider (is_default=true) is used.
|
||||
WebSearchProviderID string `yaml:"web_search_provider_id" json:"web_search_provider_id,omitempty"`
|
||||
// Whether to auto-fetch full page content for reranked web search results
|
||||
WebFetchEnabled bool `yaml:"web_fetch_enabled" json:"web_fetch_enabled"`
|
||||
|
||||
@@ -54,7 +54,7 @@ type DataSource struct {
|
||||
// Unique identifier
|
||||
ID string `json:"id" gorm:"type:varchar(36);primaryKey"`
|
||||
|
||||
// Tenant ID for multi-tenancy
|
||||
// Workspace ID for multi-workspace isolation
|
||||
TenantID uint64 `json:"tenant_id" gorm:"index"`
|
||||
|
||||
// Target knowledge base ID
|
||||
@@ -137,7 +137,7 @@ type SyncLog struct {
|
||||
// Reference to the data source
|
||||
DataSourceID string `json:"data_source_id" gorm:"index"`
|
||||
|
||||
// Tenant ID
|
||||
// Workspace ID
|
||||
TenantID uint64 `json:"tenant_id" gorm:"index"`
|
||||
|
||||
// Sync status: running, success, partial, failed, canceled
|
||||
@@ -369,7 +369,7 @@ type DataSourceSyncPayload struct {
|
||||
// Data source ID to sync
|
||||
DataSourceID string `json:"data_source_id"`
|
||||
|
||||
// Tenant ID
|
||||
// Workspace ID
|
||||
TenantID uint64 `json:"tenant_id"`
|
||||
|
||||
// Sync log ID (for tracking)
|
||||
|
||||
@@ -8,9 +8,9 @@ import (
|
||||
|
||||
// WeKnoraCloudService 处理 WeKnoraCloud 凭证管理
|
||||
type WeKnoraCloudService interface {
|
||||
// SaveCredentials 仅保存 APPID/APPSECRET 凭证到租户配置,不自动创建模型
|
||||
// SaveCredentials 仅保存 APPID/APPSECRET 凭证到空间配置,不自动创建模型
|
||||
SaveCredentials(ctx context.Context, appID, appSecret string) error
|
||||
// CheckStatus 检查当前租户的 WeKnoraCloud 凭证是否可正常解密
|
||||
// CheckStatus 检查当前空间的 WeKnoraCloud 凭证是否可正常解密
|
||||
// needsReinit=true 表示加密状态已损坏(salt 变更等),需要用户重新填写凭证
|
||||
CheckStatus(ctx context.Context) (*types.WeKnoraCloudStatusResult, error)
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ type KnowledgeListFilter struct {
|
||||
type Knowledge struct {
|
||||
// Unique identifier of the knowledge
|
||||
ID string `json:"id" gorm:"type:varchar(36);primaryKey"`
|
||||
// Tenant ID
|
||||
// Workspace ID
|
||||
TenantID uint64 `json:"tenant_id"`
|
||||
// ID of the knowledge base
|
||||
KnowledgeBaseID string `json:"knowledge_base_id"`
|
||||
|
||||
@@ -11,7 +11,7 @@ type KnowledgeProcessOverrides struct {
|
||||
GraphEnabled *bool `json:"graph_enabled,omitempty"`
|
||||
ExtractConfig *ExtractConfig `json:"extract_config,omitempty"`
|
||||
// ParserEngineOverrides passes key-value configuration to docreader parsers
|
||||
// (e.g. pdf_force_scanned=true). Merged with tenant-level overrides in the
|
||||
// (e.g. pdf_force_scanned=true). Merged with workspace-level overrides in the
|
||||
// parse pipeline; per-upload values take priority on conflict.
|
||||
ParserEngineOverrides map[string]string `json:"parser_engine_overrides,omitempty"`
|
||||
}
|
||||
|
||||
@@ -49,13 +49,13 @@ type KnowledgeBase struct {
|
||||
IsTemporary bool `yaml:"is_temporary" json:"is_temporary" gorm:"default:false"`
|
||||
// Description of the knowledge base
|
||||
Description string `yaml:"description" json:"description"`
|
||||
// Tenant ID
|
||||
// Workspace ID
|
||||
TenantID uint64 `yaml:"tenant_id" json:"tenant_id"`
|
||||
// CreatorID records the user ID of whoever originally created the KB.
|
||||
// Used by the tenant-level RBAC middleware to let Contributors edit
|
||||
// Used by the workspace-level RBAC middleware to let Contributors edit
|
||||
// their own KBs without granting them access to everyone else's.
|
||||
// Nullable for backward compatibility with rows created before the
|
||||
// RBAC migration backfilled the column to the tenant Owner.
|
||||
// RBAC migration backfilled the column to the workspace Owner.
|
||||
CreatorID string `yaml:"creator_id" json:"creator_id" gorm:"type:varchar(36);index"`
|
||||
// Chunking configuration
|
||||
ChunkingConfig ChunkingConfig `yaml:"chunking_config" json:"chunking_config" gorm:"type:json"`
|
||||
@@ -69,12 +69,12 @@ type KnowledgeBase struct {
|
||||
VLMConfig VLMConfig `yaml:"vlm_config" json:"vlm_config" gorm:"type:json"`
|
||||
// ASR config (Automatic Speech Recognition)
|
||||
ASRConfig ASRConfig `yaml:"asr_config" json:"asr_config" gorm:"type:json"`
|
||||
// Storage provider config (new): only stores provider selection; credentials from tenant StorageEngineConfig
|
||||
// Storage provider config (new): only stores provider selection; credentials from workspace StorageEngineConfig
|
||||
StorageProviderConfig *StorageProviderConfig `yaml:"storage_provider_config" json:"storage_provider_config" gorm:"column:storage_provider_config;type:jsonb"`
|
||||
// Deprecated: legacy COS config column. Kept for backward compatibility with old data.
|
||||
StorageConfig StorageConfig `yaml:"-" json:"storage_config" gorm:"column:cos_config;type:json"`
|
||||
// VectorStoreID references the VectorStore this knowledge base is bound to.
|
||||
// When nil, the KB falls back to the tenant's effective engines derived from
|
||||
// When nil, the KB falls back to the workspace's effective engines derived from
|
||||
// the RETRIEVE_DRIVER environment variable (env store flow).
|
||||
// This field is set once at creation time and must not be modified afterwards;
|
||||
// enforcement lives at the GORM layer (`<-:create`) plus the service-layer
|
||||
@@ -93,7 +93,7 @@ type KnowledgeBase struct {
|
||||
IndexingStrategy IndexingStrategy `yaml:"indexing_strategy" json:"indexing_strategy" gorm:"column:indexing_strategy;type:json"`
|
||||
// IsPinned and PinnedAt are computed per-caller from user_kb_pins
|
||||
// (see migration 000050). They used to be stored on the row itself,
|
||||
// which made pinning a tenant-wide ordering decision gated behind
|
||||
// which made pinning a workspace-wide ordering decision gated behind
|
||||
// the kb-edit RBAC guard. The columns are still present in legacy
|
||||
// schemas for rollback safety but are no longer read or written by
|
||||
// the application — both fields are tagged `gorm:"-"` so GORM
|
||||
@@ -121,7 +121,7 @@ type KnowledgeBase struct {
|
||||
ShareCount int64 `yaml:"share_count" json:"share_count" gorm:"-"`
|
||||
// CreatorName 是 CreatorID 对应用户的展示名(username / email 等),
|
||||
// 仅在列表场景由 handler 批量回填,不落库;为空表示创建者无法解析(用户已删除、
|
||||
// CreatorID 为空的老数据等)。前端用它在卡片来源徽章上做 mine vs tenant 的二分。
|
||||
// CreatorID 为空的老数据等)。前端用它在卡片来源徽章上做 mine vs workspace 的二分。
|
||||
CreatorName string `yaml:"-" json:"creator_name,omitempty" gorm:"-"`
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ type MCPService struct {
|
||||
AdvancedConfig *MCPAdvancedConfig `json:"advanced_config" gorm:"type:json"`
|
||||
StdioConfig *MCPStdioConfig `json:"stdio_config,omitempty" gorm:"type:json"` // Required for stdio transport
|
||||
EnvVars MCPEnvVars `json:"env_vars,omitempty" gorm:"type:json"` // Environment variables for stdio
|
||||
IsBuiltin bool `json:"is_builtin" gorm:"default:false"` // Whether this is a builtin MCP service (visible to all tenants)
|
||||
IsBuiltin bool `json:"is_builtin" gorm:"default:false"` // Whether this is a builtin MCP service (visible to all workspaces)
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
DeletedAt gorm.DeletedAt `json:"deleted_at" gorm:"index"`
|
||||
|
||||
@@ -115,7 +115,7 @@ type Model struct {
|
||||
// GORM's struct tag is documented to match so AutoMigrate paths
|
||||
// produce the same shape.
|
||||
ID string `yaml:"id" json:"id" gorm:"type:varchar(64);primaryKey"`
|
||||
// Tenant ID
|
||||
// Workspace ID
|
||||
TenantID uint64 `yaml:"tenant_id" json:"tenant_id"`
|
||||
// Name of the model
|
||||
Name string `yaml:"name" json:"name"`
|
||||
|
||||
@@ -122,8 +122,8 @@ type OrganizationTenantMember struct {
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
|
||||
Organization *Organization `json:"organization,omitempty" gorm:"foreignKey:OrganizationID"`
|
||||
RepresentativeUser *User `json:"representative_user,omitempty" gorm:"foreignKey:RepresentativeUserID"`
|
||||
Organization *Organization `json:"organization,omitempty" gorm:"foreignKey:OrganizationID"`
|
||||
RepresentativeUser *User `json:"representative_user,omitempty" gorm:"foreignKey:RepresentativeUserID"`
|
||||
}
|
||||
|
||||
// TableName returns the table name for GORM
|
||||
@@ -256,15 +256,15 @@ func (AgentShare) TableName() string {
|
||||
|
||||
// SharedAgentInfo represents a shared agent with additional sharing info
|
||||
type SharedAgentInfo struct {
|
||||
Agent *CustomAgent `json:"agent"`
|
||||
ShareID string `json:"share_id"`
|
||||
OrganizationID string `json:"organization_id"`
|
||||
OrgName string `json:"org_name"`
|
||||
Permission OrgMemberRole `json:"permission"`
|
||||
SourceTenantID uint64 `json:"source_tenant_id"`
|
||||
SharedAt time.Time `json:"shared_at"`
|
||||
SharedByUserID string `json:"shared_by_user_id,omitempty"`
|
||||
SharedByUsername string `json:"shared_by_username,omitempty"`
|
||||
Agent *CustomAgent `json:"agent"`
|
||||
ShareID string `json:"share_id"`
|
||||
OrganizationID string `json:"organization_id"`
|
||||
OrgName string `json:"org_name"`
|
||||
Permission OrgMemberRole `json:"permission"`
|
||||
SourceTenantID uint64 `json:"source_tenant_id"`
|
||||
SharedAt time.Time `json:"shared_at"`
|
||||
SharedByUserID string `json:"shared_by_user_id,omitempty"`
|
||||
SharedByUsername string `json:"shared_by_username,omitempty"`
|
||||
// DisabledByMe: current tenant has hidden this shared agent from their conversation dropdown (per-user preference)
|
||||
DisabledByMe bool `json:"disabled_by_me"`
|
||||
}
|
||||
@@ -280,7 +280,7 @@ type SourceFromAgentInfo struct {
|
||||
// When SourceFromAgent is set, the KB is from a shared agent's config (no direct KB share); show as read-only and "来自智能体 XXX".
|
||||
type OrganizationSharedKnowledgeBaseItem struct {
|
||||
SharedKnowledgeBaseInfo
|
||||
IsMine bool `json:"is_mine"`
|
||||
IsMine bool `json:"is_mine"`
|
||||
SourceFromAgent *SourceFromAgentInfo `json:"source_from_agent,omitempty"`
|
||||
}
|
||||
|
||||
@@ -363,20 +363,20 @@ type RequestRoleUpgradeRequest struct {
|
||||
Message string `json:"message" binding:"max=500"` // Optional message explaining the reason
|
||||
}
|
||||
|
||||
// InviteMemberRequest represents a request to directly invite a tenant to organization.
|
||||
// InviteMemberRequest represents a request to directly invite a workspace to an organization.
|
||||
//
|
||||
// Plan 3 (#1303) moved membership to the tenant level: an invitation enrols a whole
|
||||
// tenant into the organization, with one user attached purely as the representative
|
||||
// Plan 3 (#1303) moved membership to the workspace level: an invitation enrols a whole
|
||||
// workspace into the organization, with one user attached purely as the representative
|
||||
// (display/audit). Callers SHOULD set TenantID and optionally
|
||||
// RepresentativeUserID. For backward compatibility with older SDK callers that
|
||||
// still send UserID alone, the handler resolves that user's TenantID and uses
|
||||
// the user as the representative.
|
||||
type InviteMemberRequest struct {
|
||||
// TenantID is the tenant to enrol as an org member. Preferred field.
|
||||
// TenantID is the workspace to enrol as an org member. Preferred field.
|
||||
TenantID uint64 `json:"tenant_id"`
|
||||
// RepresentativeUserID identifies the user attached to the OTM row for
|
||||
// display/audit. Optional: when unset, the handler picks a stable default
|
||||
// (the user from the legacy UserID field, or the tenant's owner).
|
||||
// (the user from the legacy UserID field, or the workspace's owner).
|
||||
RepresentativeUserID string `json:"representative_user_id"`
|
||||
// UserID is retained for backward compatibility. When set without
|
||||
// TenantID, the handler resolves the user's TenantID and uses this
|
||||
@@ -403,9 +403,9 @@ type OrganizationResponse struct {
|
||||
Description string `json:"description"`
|
||||
Avatar string `json:"avatar,omitempty"`
|
||||
OwnerID string `json:"owner_id"`
|
||||
// OwnerTenantID is the persisted owner tenant of the organization
|
||||
// OwnerTenantID is the persisted owner workspace of the organization
|
||||
// (Plan 3, migration 000046). Frontend uses this to identify the
|
||||
// "owner row" in the tenant-keyed members list — comparing
|
||||
// "owner row" in the workspace-keyed members list — comparing
|
||||
// member.tenant_id against owner_tenant_id is the post-Plan-3
|
||||
// equivalent of the old member.user_id == owner_id check.
|
||||
OwnerTenantID uint64 `json:"owner_tenant_id"`
|
||||
@@ -453,12 +453,12 @@ type OrganizationMemberResponse struct {
|
||||
// caused this tenant to show up in the search). Multiple users may belong
|
||||
// to the same tenant; deduplication is by TenantID.
|
||||
type TenantInviteCandidate struct {
|
||||
TenantID uint64 `json:"tenant_id"`
|
||||
TenantName string `json:"tenant_name"`
|
||||
RepresentativeUserID string `json:"representative_user_id"`
|
||||
RepresentativeUsername string `json:"representative_username"`
|
||||
RepresentativeEmail string `json:"representative_email"`
|
||||
RepresentativeAvatar string `json:"representative_avatar,omitempty"`
|
||||
TenantID uint64 `json:"tenant_id"`
|
||||
TenantName string `json:"tenant_name"`
|
||||
RepresentativeUserID string `json:"representative_user_id"`
|
||||
RepresentativeUsername string `json:"representative_username"`
|
||||
RepresentativeEmail string `json:"representative_email"`
|
||||
RepresentativeAvatar string `json:"representative_avatar,omitempty"`
|
||||
}
|
||||
|
||||
// KnowledgeBaseShareResponse represents a share record in API responses
|
||||
@@ -496,10 +496,10 @@ type AgentShareResponse struct {
|
||||
MyPermission string `json:"my_permission,omitempty"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
// Agent scope summary for list display (from agent config when available)
|
||||
ScopeKB string `json:"scope_kb,omitempty"` // "all" | "selected" | "none"
|
||||
ScopeKB string `json:"scope_kb,omitempty"` // "all" | "selected" | "none"
|
||||
ScopeKBCount int `json:"scope_kb_count,omitempty"` // when selected
|
||||
ScopeWebSearch bool `json:"scope_web_search,omitempty"`
|
||||
ScopeMCP string `json:"scope_mcp,omitempty"` // "all" | "selected" | "none"
|
||||
ScopeMCP string `json:"scope_mcp,omitempty"` // "all" | "selected" | "none"
|
||||
ScopeMCPCount int `json:"scope_mcp_count,omitempty"` // when selected
|
||||
// Agent avatar (emoji or icon name) for list display
|
||||
AgentAvatar string `json:"agent_avatar,omitempty"`
|
||||
@@ -507,8 +507,8 @@ type AgentShareResponse struct {
|
||||
|
||||
// ListOrganizationsResponse represents the response for listing organizations
|
||||
type ListOrganizationsResponse struct {
|
||||
Organizations []OrganizationResponse `json:"organizations"`
|
||||
Total int64 `json:"total"`
|
||||
Organizations []OrganizationResponse `json:"organizations"`
|
||||
Total int64 `json:"total"`
|
||||
ResourceCounts *ResourceCountsByOrgResponse `json:"resource_counts,omitempty"` // 各空间内知识库/智能体数量,供列表侧栏展示
|
||||
}
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ type Session struct {
|
||||
Title string `json:"title"`
|
||||
// Description
|
||||
Description string `json:"description"`
|
||||
// Tenant ID
|
||||
// Workspace ID
|
||||
TenantID uint64 `json:"tenant_id" gorm:"index"`
|
||||
// UserID is the owner scope for this session. WeKnora user UUIDs, API
|
||||
// external-user principals, and embed visitor principals all use this column.
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// SystemSetting is a platform-wide (NOT tenant-scoped) tunable that
|
||||
// SystemSetting is a platform-wide (NOT workspace-scoped) tunable that
|
||||
// SystemAdmins can edit at runtime via the management UI without
|
||||
// restarting the service. Persisted in the system_settings table
|
||||
// (migration 000053).
|
||||
|
||||
@@ -14,7 +14,7 @@ type KnowledgeTag struct {
|
||||
ID string `json:"id" gorm:"type:varchar(36);primaryKey"`
|
||||
// SeqID is an auto-increment integer ID for external API usage
|
||||
SeqID int64 `json:"seq_id" gorm:"type:bigint;uniqueIndex;autoIncrement"`
|
||||
// Tenant ID
|
||||
// Workspace ID
|
||||
TenantID uint64 `json:"tenant_id"`
|
||||
// Knowledge base ID that this tag belongs to
|
||||
KnowledgeBaseID string `json:"knowledge_base_id" gorm:"type:varchar(36);index"`
|
||||
|
||||
@@ -100,9 +100,9 @@ type Tenant struct {
|
||||
StorageQuota int64 `yaml:"storage_quota" json:"storage_quota" gorm:"default:10737418240"`
|
||||
// Storage used (Bytes)
|
||||
StorageUsed int64 `yaml:"storage_used" json:"storage_used" gorm:"default:0"`
|
||||
// Global Context configuration for this tenant (default for all sessions)
|
||||
// Global Context configuration for this workspace (default for all sessions)
|
||||
ContextConfig *ContextConfig `yaml:"context_config" json:"context_config" gorm:"type:jsonb"`
|
||||
// Global WebSearch configuration for this tenant
|
||||
// Global WebSearch configuration for this workspace
|
||||
WebSearchConfig *WebSearchConfig `yaml:"web_search_config" json:"web_search_config" gorm:"type:jsonb"`
|
||||
// Parser engine config overrides (MinerU endpoint, API key, etc.). Used when parsing documents; overrides env.
|
||||
ParserEngineConfig *ParserEngineConfig `yaml:"parser_engine_config" json:"parser_engine_config" gorm:"type:jsonb"`
|
||||
|
||||
+12
-12
@@ -27,11 +27,11 @@ type UserPreferences struct {
|
||||
// *false / *true = user explicitly set the toggle.
|
||||
EnableMemory *bool `json:"enable_memory,omitempty"`
|
||||
|
||||
// LastActiveTenantID remembers the last tenant the user actively
|
||||
// LastActiveTenantID remembers the last workspace the user actively
|
||||
// switched into, so a fresh login (new device, cleared browser, new
|
||||
// refresh token) lands them back in that workspace instead of always
|
||||
// bouncing to their home tenant. Login / RefreshToken validate that
|
||||
// the tenant still exists and the user still has an active membership
|
||||
// bouncing to their home workspace. Login / RefreshToken validate that
|
||||
// the workspace still exists and the user still has an active membership
|
||||
// (or CanAccessAllTenants) before honouring this preference; an
|
||||
// invalid pointer is best-effort cleared and the user falls back to
|
||||
// home.
|
||||
@@ -40,7 +40,7 @@ type UserPreferences struct {
|
||||
// *0 = "clear preference" sentinel for the partial-update endpoint
|
||||
// (UpdateUserPreferences turns this into nil). Otherwise treat
|
||||
// a stored *0 the same as nil.
|
||||
// *N = preferred tenant id.
|
||||
// *N = preferred workspace id.
|
||||
LastActiveTenantID *uint64 `json:"last_active_tenant_id,omitempty"`
|
||||
}
|
||||
|
||||
@@ -87,13 +87,13 @@ type User struct {
|
||||
PasswordHash string `json:"-" gorm:"type:varchar(255);not null"`
|
||||
// Avatar URL of the user
|
||||
Avatar string `json:"avatar" gorm:"type:varchar(500)"`
|
||||
// Tenant ID that the user belongs to
|
||||
// Workspace ID that the user belongs to
|
||||
TenantID uint64 `json:"tenant_id" gorm:"index"`
|
||||
// Whether the user is active
|
||||
IsActive bool `json:"is_active" gorm:"default:true"`
|
||||
// Whether the user can access all tenants (cross-tenant access)
|
||||
// Whether the user can access all workspaces (cross-workspace access)
|
||||
CanAccessAllTenants bool `json:"can_access_all_tenants" gorm:"default:false"`
|
||||
// Whether the user is a system administrator (independent of tenant roles)
|
||||
// Whether the user is a system administrator (independent of workspace roles)
|
||||
IsSystemAdmin bool `json:"is_system_admin" gorm:"default:false;index"`
|
||||
// Per-user UI/feature preferences (memory toggle, future knobs).
|
||||
// Stored as JSON (jsonb on Postgres, TEXT on SQLite) via the
|
||||
@@ -213,14 +213,14 @@ type LoginResponse struct {
|
||||
Success bool `json:"success"`
|
||||
Message string `json:"message,omitempty"`
|
||||
User *User `json:"user,omitempty"`
|
||||
// ActiveTenant is the tenant whose ID is encoded in the issued JWT;
|
||||
// ActiveTenant is the workspace whose ID is encoded in the issued JWT;
|
||||
// future requests are scoped to it until the client calls /auth/switch-tenant.
|
||||
// Defaults to the user's home tenant on a fresh login.
|
||||
// Defaults to the user's home workspace on a fresh login.
|
||||
ActiveTenant *Tenant `json:"active_tenant,omitempty"`
|
||||
// Memberships lists every tenant the user can authenticate into,
|
||||
// Memberships lists every workspace the user can authenticate into,
|
||||
// along with their role in each. Always populated (length 1 for users
|
||||
// who only belong to their home tenant) so frontends can render a
|
||||
// tenant switcher without a follow-up request. Serialised without
|
||||
// who only belong to their home workspace) so frontends can render a
|
||||
// workspace switcher without a follow-up request. Serialised without
|
||||
// omitempty so the field is always present as a JSON array (possibly
|
||||
// empty) — the "always populated" contract relies on the server side
|
||||
// guaranteeing a non-nil slice.
|
||||
|
||||
@@ -33,13 +33,13 @@ func IsEnvStoreID(id string) bool {
|
||||
// In production: os.Getenv, in tests: custom lookup function.
|
||||
type EnvLookupFunc func(string) string
|
||||
|
||||
// VectorStore represents a configured vector database instance for a tenant.
|
||||
// Each tenant can register multiple VectorStore entries (even of the same engine type)
|
||||
// VectorStore represents a configured vector database instance for a workspace.
|
||||
// Each workspace can register multiple VectorStore entries (even of the same engine type)
|
||||
// to support multi-store scenarios (e.g., ES-hot + ES-warm clusters).
|
||||
type VectorStore struct {
|
||||
// Unique identifier (UUID, auto-generated)
|
||||
ID string `yaml:"id" json:"id" gorm:"type:varchar(36);primaryKey"`
|
||||
// Tenant ID for scoping
|
||||
// Workspace ID for scoping
|
||||
TenantID uint64 `yaml:"tenant_id" json:"tenant_id"`
|
||||
// User-friendly name, e.g., "elasticsearch-hot"
|
||||
Name string `yaml:"name" json:"name" gorm:"type:varchar(255);not null"`
|
||||
|
||||
@@ -25,14 +25,14 @@ const (
|
||||
WebSearchProviderTypeKeenable WebSearchProviderType = "keenable"
|
||||
)
|
||||
|
||||
// WebSearchProviderEntity represents a configured web search provider instance for a tenant.
|
||||
// WebSearchProviderEntity represents a configured web search provider instance for a workspace.
|
||||
// This is a CRUD entity stored in the database, similar to the Model entity.
|
||||
// Each tenant can create multiple provider configurations (e.g., "Production Bing", "Test Google").
|
||||
// Each workspace can create multiple provider configurations (e.g., "Production Bing", "Test Google").
|
||||
// Agents reference these by ID.
|
||||
type WebSearchProviderEntity struct {
|
||||
// Unique identifier (UUID, auto-generated)
|
||||
ID string `yaml:"id" json:"id" gorm:"type:varchar(36);primaryKey"`
|
||||
// Tenant ID for scoping
|
||||
// Workspace ID for scoping
|
||||
TenantID uint64 `yaml:"tenant_id" json:"tenant_id"`
|
||||
// User-friendly name, e.g., "Production Bing Search"
|
||||
Name string `yaml:"name" json:"name" gorm:"type:varchar(255);not null"`
|
||||
@@ -42,7 +42,7 @@ type WebSearchProviderEntity struct {
|
||||
Description string `yaml:"description" json:"description" gorm:"type:text"`
|
||||
// Provider-specific parameters (API key, engine ID, etc.) stored as encrypted JSON
|
||||
Parameters WebSearchProviderParameters `yaml:"parameters" json:"parameters" gorm:"type:json"`
|
||||
// Whether this is the default provider for the tenant
|
||||
// Whether this is the default provider for the workspace
|
||||
IsDefault bool `yaml:"is_default" json:"is_default" gorm:"default:false"`
|
||||
// Timestamps
|
||||
CreatedAt time.Time `yaml:"created_at" json:"created_at"`
|
||||
|
||||
@@ -79,7 +79,7 @@ type WikiLogEntry struct {
|
||||
// frontend pagination uses it as a stable cursor without needing to
|
||||
// disambiguate identical created_at values.
|
||||
ID uint64 `json:"id" gorm:"primaryKey;autoIncrement"`
|
||||
// Tenant scope, mirrored from the enclosing knowledge base.
|
||||
// Workspace scope, mirrored from the enclosing knowledge base.
|
||||
TenantID uint64 `json:"tenant_id" gorm:"index"`
|
||||
// Knowledge base this event belongs to.
|
||||
KnowledgeBaseID string `json:"knowledge_base_id" gorm:"type:varchar(36);index"`
|
||||
|
||||
@@ -146,7 +146,7 @@ const (
|
||||
type WikiPage struct {
|
||||
// Unique identifier (UUID)
|
||||
ID string `json:"id" gorm:"type:varchar(36);primaryKey"`
|
||||
// Tenant ID for multi-tenant isolation
|
||||
// Workspace ID for multi-workspace isolation
|
||||
TenantID uint64 `json:"tenant_id" gorm:"index"`
|
||||
// Knowledge base this page belongs to
|
||||
KnowledgeBaseID string `json:"knowledge_base_id" gorm:"type:varchar(36);index"`
|
||||
|
||||
Reference in New Issue
Block a user