Documentation
¶
Overview ¶
Package api provides shared schema mapping from Kigae field types to JSON Schema. Used by OpenAPI, MCP, and Chat to generate consistent tool/schema definitions.
Index ¶
- Constants
- Variables
- func CountOtherEnabledAdministrators(ctx context.Context, tx *sql.Tx, dialect kdb.Dialect, site, name string) (int, error)
- func DocTypeToJSONSchema(dt *doctype.DocType, registry *doctype.Registry) map[string]any
- func FieldToJSONSchema(f *doctype.Field) map[string]any
- func GenerateOpenAPISpec(reg *doctype.Registry, siteName string) *openapi3.T
- func NewPrintHandler(src PrintSource) gin.HandlerFunc
- func NewPrintListHandler(src PrintSource) gin.HandlerFunc
- func NewPrintMetaHandler(src PrintSource) gin.HandlerFunc
- func NewScriptProvider(tx *orm.TxManager, registry *doctype.Registry, site string, ...) script.KoraProvider
- func NewSitePrintHandler(h *Handler) gin.HandlerFunc
- func NewSitePrintListHandler(h *Handler) gin.HandlerFunc
- func NewSitePrintMetaHandler(h *Handler) gin.HandlerFunc
- func RegisterAnalyticsRoutes(apiGroup *gin.RouterGroup, registry *doctype.Registry, siteDB *sql.DB, ...)
- func RegisterPublicRoutesOnGroupWithRuntimeServices(apiGroup *gin.RouterGroup, registry *doctype.Registry, ...)
- func RegisterRequestRoutes(group *gin.RouterGroup, services *SiteRuntimeServices)
- func RegisterRoutesOnGroup(apiGroup *gin.RouterGroup, registry *doctype.Registry, ...)
- func RegisterSystemRoutes(apiGroup *gin.RouterGroup, handler *Handler)
- func RegisterWorkflowRoutes(group *gin.RouterGroup, services *SiteRuntimeServices)
- func ReleaseTenantStreamAuthWork(c *gin.Context)
- func ScriptProviderFactory(registry *doctype.Registry, site string, secretStore *secret.Store, ...) func(*orm.TxManager) script.KoraProvider
- func SetAPILimits(def, max int)
- func WorkAdmissionMiddleware(registry *SiteRuntimeServices) gin.HandlerFunc
- type AnalyticsOptions
- type AnalyticsQueryCache
- type AnalyticsQueryCacheSnapshot
- type Branding
- type ConfigurationCheckResult
- type ConfigurationConflict
- type ConfigurationImpactItem
- type ConsoleHandler
- func (h *ConsoleHandler) CloseOnboardingJobs(ctx context.Context) error
- func (h *ConsoleHandler) HandleChangePassword(c *gin.Context)
- func (h *ConsoleHandler) HandleCreateSite(c *gin.Context)
- func (h *ConsoleHandler) HandleDeleteSite(c *gin.Context)
- func (h *ConsoleHandler) HandleListSites(c *gin.Context)
- func (h *ConsoleHandler) HandleLogin(c *gin.Context)
- func (h *ConsoleHandler) HandleOnboard(c *gin.Context)
- func (h *ConsoleHandler) HandleOnboardJobs(c *gin.Context)
- func (h *ConsoleHandler) HandleOnboardStatus(c *gin.Context)
- func (h *ConsoleHandler) HandleResetSitePassword(c *gin.Context)
- func (h *ConsoleHandler) HandleUpdateSite(c *gin.Context)
- func (h *ConsoleHandler) RequireConsoleAuth(c *gin.Context)
- func (h *ConsoleHandler) RequirePlatformWork(c *gin.Context)
- func (h *ConsoleHandler) Start()
- type ConsoleOptions
- type DocTypeNavItem
- type DraftConfigurationRequest
- type DraftPermission
- type ErrorBody
- type ErrorResponse
- type ExperienceCopy
- type ExtensionStore
- type ExtensionStoreOpener
- type Handler
- func (h *Handler) HandleAICancel(c *gin.Context)
- func (h *Handler) HandleAIChatConversation(c *gin.Context)
- func (h *Handler) HandleAIGrantApproval(c *gin.Context)
- func (h *Handler) HandleAIListApprovals(c *gin.Context)
- func (h *Handler) HandleAIResume(c *gin.Context)
- func (h *Handler) HandleAIRetentionCleanup(c *gin.Context)
- func (h *Handler) HandleActiveConfigSnapshot(c *gin.Context)
- func (h *Handler) HandleAgentEffectivePermissions(c *gin.Context)
- func (h *Handler) HandleAgentManifest(c *gin.Context)
- func (h *Handler) HandleAgentManifests(c *gin.Context)
- func (h *Handler) HandleAgentPermissionCatalog(c *gin.Context)
- func (h *Handler) HandleAgentRuns(c *gin.Context)
- func (h *Handler) HandleApplicationCatalog(c *gin.Context)
- func (h *Handler) HandleAuthPolicy(c *gin.Context)
- func (h *Handler) HandleAuthPolicyUpdate(c *gin.Context)
- func (h *Handler) HandleAuthProviderDelete(c *gin.Context)
- func (h *Handler) HandleAuthProviderList(c *gin.Context)
- func (h *Handler) HandleAuthProviderPut(c *gin.Context)
- func (h *Handler) HandleAuthProviders(c *gin.Context)
- func (h *Handler) HandleBusinessReconciliationRead(c *gin.Context)
- func (h *Handler) HandleBusinessReconciliationRepair(c *gin.Context)
- func (h *Handler) HandleBusinessReconciliationRun(c *gin.Context)
- func (h *Handler) HandleBusinessReconciliationSummary(c *gin.Context)
- func (h *Handler) HandleBusinessReconciliationWaive(c *gin.Context)
- func (h *Handler) HandleChannelMutate(c *gin.Context)
- func (h *Handler) HandleChannelQuery(c *gin.Context)
- func (h *Handler) HandleChannelSessionIssue(c *gin.Context)
- func (h *Handler) HandleChannelSessionRevoke(c *gin.Context)
- func (h *Handler) HandleChannelTools(c *gin.Context)
- func (h *Handler) HandleChat(c *gin.Context)
- func (h *Handler) HandleConfigDiff(c *gin.Context)
- func (h *Handler) HandleConfigHeadSnapshot(c *gin.Context)
- func (h *Handler) HandleConfigImport(c *gin.Context)
- func (h *Handler) HandleConfigVersion(c *gin.Context)
- func (h *Handler) HandleConfigVersionActivate(c *gin.Context)
- func (h *Handler) HandleConfigVersionDiscard(c *gin.Context)
- func (h *Handler) HandleConfigVersionPreview(c *gin.Context)
- func (h *Handler) HandleConfigVersionRollback(c *gin.Context)
- func (h *Handler) HandleConfigVersionRollbackPreview(c *gin.Context)
- func (h *Handler) HandleConfigVersionSnapshot(c *gin.Context)
- func (h *Handler) HandleConfigVersions(c *gin.Context)
- func (h *Handler) HandleConfigurationDraft(c *gin.Context)
- func (h *Handler) HandleConfigurationDryRun(c *gin.Context)
- func (h *Handler) HandleConfigurationValidate(c *gin.Context)
- func (h *Handler) HandleCreate(c *gin.Context)
- func (h *Handler) HandleDelete(c *gin.Context)
- func (h *Handler) HandleExecutePublishedOperation(c *gin.Context)
- func (h *Handler) HandleExtensionCreate(c *gin.Context)
- func (h *Handler) HandleExtensionDelete(c *gin.Context)
- func (h *Handler) HandleExtensionDeliveries(c *gin.Context)
- func (h *Handler) HandleExtensionGet(c *gin.Context)
- func (h *Handler) HandleExtensionList(c *gin.Context)
- func (h *Handler) HandleExtensionReplay(c *gin.Context)
- func (h *Handler) HandleExtensionRotateSecret(c *gin.Context)
- func (h *Handler) HandleExtensionUpdate(c *gin.Context)
- func (h *Handler) HandleFileDelete(c *gin.Context)
- func (h *Handler) HandleFileServe(c *gin.Context)
- func (h *Handler) HandleGet(c *gin.Context)
- func (h *Handler) HandleGetPublishedOperationReceipt(c *gin.Context)
- func (h *Handler) HandleImport(c *gin.Context)
- func (h *Handler) HandleKernelOperation(c *gin.Context)
- func (h *Handler) HandleKernelRegistry(c *gin.Context)
- func (h *Handler) HandleList(c *gin.Context)
- func (h *Handler) HandleLookupPublishedOperation(c *gin.Context)
- func (h *Handler) HandleMPesaSTKCallback(c *gin.Context)
- func (h *Handler) HandleManagedChannelClientRevoke(c *gin.Context)
- func (h *Handler) HandleManagedChannelClientRotate(c *gin.Context)
- func (h *Handler) HandleManagedSiteIdentity(c *gin.Context)
- func (h *Handler) HandleMethod(c *gin.Context)
- func (h *Handler) HandleOfflineBootstrapV2(c *gin.Context)
- func (h *Handler) HandleOfflineCapabilitiesV2(c *gin.Context)
- func (h *Handler) HandleOfflineIntentsV2(c *gin.Context)
- func (h *Handler) HandleOfflinePullV2(c *gin.Context)
- func (h *Handler) HandleOpenAPI(c *gin.Context)
- func (h *Handler) HandlePageManifestByRoute(c *gin.Context)
- func (h *Handler) HandlePaymentCallback(c *gin.Context)
- func (h *Handler) HandlePaymentGet(c *gin.Context)
- func (h *Handler) HandlePaymentRequest(c *gin.Context)
- func (h *Handler) HandlePublicCreate(c *gin.Context)
- func (h *Handler) HandlePublicFileServe(c *gin.Context)
- func (h *Handler) HandlePublicGet(c *gin.Context)
- func (h *Handler) HandlePublicList(c *gin.Context)
- func (h *Handler) HandlePublicView(c *gin.Context)
- func (h *Handler) HandlePublishedModuleProjection(c *gin.Context)
- func (h *Handler) HandlePublishedModuleQuery(c *gin.Context)
- func (h *Handler) HandleRebuildPublishedModuleProjection(c *gin.Context)
- func (h *Handler) HandleRecordHistory(c *gin.Context)
- func (h *Handler) HandleScriptCreate(c *gin.Context)
- func (h *Handler) HandleScriptDelete(c *gin.Context)
- func (h *Handler) HandleScriptExecutions(c *gin.Context)
- func (h *Handler) HandleScriptGet(c *gin.Context)
- func (h *Handler) HandleScriptList(c *gin.Context)
- func (h *Handler) HandleScriptUpdate(c *gin.Context)
- func (h *Handler) HandleScriptValidate(c *gin.Context)
- func (h *Handler) HandleSecretDelete(c *gin.Context)
- func (h *Handler) HandleSecretList(c *gin.Context)
- func (h *Handler) HandleSecretSet(c *gin.Context)
- func (h *Handler) HandleSiteSettings(c *gin.Context)
- func (h *Handler) HandleSiteSettingsUpdate(c *gin.Context)
- func (h *Handler) HandleSwaggerUI(c *gin.Context)
- func (h *Handler) HandleSystemAudit(c *gin.Context)
- func (h *Handler) HandleSystemBranding(c *gin.Context)
- func (h *Handler) HandleSystemDoctype(c *gin.Context)
- func (h *Handler) HandleSystemDoctypeCreate(c *gin.Context)
- func (h *Handler) HandleSystemDoctypeDelete(c *gin.Context)
- func (h *Handler) HandleSystemDoctypeDryRun(c *gin.Context)
- func (h *Handler) HandleSystemDoctypeReferences(c *gin.Context)
- func (h *Handler) HandleSystemDoctypeUpdate(c *gin.Context)
- func (h *Handler) HandleSystemDoctypeValidate(c *gin.Context)
- func (h *Handler) HandleSystemDoctypes(c *gin.Context)
- func (h *Handler) HandleSystemExperienceUpdate(c *gin.Context)
- func (h *Handler) HandleSystemGraph(c *gin.Context)
- func (h *Handler) HandleSystemNavigation(c *gin.Context)
- func (h *Handler) HandleSystemPageManifest(c *gin.Context)
- func (h *Handler) HandleSystemPageManifestCreate(c *gin.Context)
- func (h *Handler) HandleSystemPageManifestDelete(c *gin.Context)
- func (h *Handler) HandleSystemPageManifestUpdate(c *gin.Context)
- func (h *Handler) HandleSystemPageManifests(c *gin.Context)
- func (h *Handler) HandleSystemPermissions(c *gin.Context)
- func (h *Handler) HandleSystemPermissionsSave(c *gin.Context)
- func (h *Handler) HandleSystemRealtime(c *gin.Context)
- func (h *Handler) HandleSystemRoleCreate(c *gin.Context)
- func (h *Handler) HandleSystemRoleDelete(c *gin.Context)
- func (h *Handler) HandleSystemRoleUpdate(c *gin.Context)
- func (h *Handler) HandleSystemRoles(c *gin.Context)
- func (h *Handler) HandleSystemView(c *gin.Context)
- func (h *Handler) HandleSystemViewCreate(c *gin.Context)
- func (h *Handler) HandleSystemViewDelete(c *gin.Context)
- func (h *Handler) HandleSystemViewUpdate(c *gin.Context)
- func (h *Handler) HandleSystemViews(c *gin.Context)
- func (h *Handler) HandleUpdate(c *gin.Context)
- func (h *Handler) HandleUpload(c *gin.Context)
- func (h *Handler) HandleUserDirectory(c *gin.Context)
- func (h *Handler) HandleUserGet(c *gin.Context)
- func (h *Handler) HandleUserList(c *gin.Context)
- func (h *Handler) HandleUserUpdate(c *gin.Context)
- func (h *Handler) HandleViewAction(c *gin.Context)
- func (h *Handler) HandleViewByRoute(c *gin.Context)
- func (h *Handler) HandleViewData(c *gin.Context)
- func (h *Handler) HandleViewValidate(c *gin.Context)
- type ManagementCapability
- type ManagementDirectory
- type ManagementInspectHandler
- type ManagementInvitationReconciler
- type ManagementModuleInspector
- type ManagementModuleLifecyclePlanner
- type ManagementOperationRoutes
- type ManagementOperationService
- type ManagementTenantMemberPlanner
- type Meta
- type ModuleGroup
- type NavigationResponse
- type PrintSource
- type RealtimeConnectionOwner
- type RecordHistoryEntry
- type RecordHistoryFieldChange
- type ReferenceInfo
- type Response
- type RouteOptions
- type ScriptCandidate
- type SecretEntry
- type SiteRuntimeService
- type SiteRuntimeServices
- func (s *SiteRuntimeServices) AnalyticsQueryCacheSnapshot() AnalyticsQueryCacheSnapshot
- func (s *SiteRuntimeServices) Get(site string) (SiteRuntimeService, bool)
- func (s *SiteRuntimeServices) Remove(site string)
- func (s *SiteRuntimeServices) Replace(site string, services SiteRuntimeService)
- func (s *SiteRuntimeServices) SetStorage(site string, backend storage.Backend)
- type SystemAuditEntry
- type SystemDoctypeResponse
- type SystemGraphEdge
- type SystemGraphNode
- type SystemGraphResponse
- type TenantConfigRevisionResolver
- type TenantExperience
- type UserAccessUpdate
- type UserDirectoryEntry
- type UserInfo
- type UserResponse
- type ViewNavItem
- type WorkflowActionCapability
- type WorkflowFieldCapability
- type WorkflowTableCapability
- type WorkflowTransitionCapability
Constants ¶
const ( ManagementProvisionCapability = contract.ManagementCapabilityTenantProvision ManagementPackageCapability = contract.ManagementCapabilityTenantPackageApply ManagementPackageRecovery = contract.ManagementCapabilityTenantPackageRetry ManagementStateCapability = contract.ManagementCapabilityTenantStateSet ManagementStateRecovery = contract.ManagementCapabilityTenantStateRetry ManagementProvisionRecovery = contract.ManagementCapabilityTenantProvisionRetry ManagementDeleteCapability = contract.ManagementCapabilityTenantDelete ManagementDeleteRecovery = contract.ManagementCapabilityTenantDeleteRetry ManagementInvitationCapability = contract.ManagementCapabilityTenantInvitation ManagementInvitationRecovery = contract.ManagementCapabilityTenantInvitationRetry ManagementModuleLifecycle = contract.ManagementCapabilityModuleLifecycle ManagementMemberRevoke = contract.ManagementCapabilityTenantMemberRevoke ManagementOperationRead = contract.ManagementCapabilityOperationRead ManagementMemberPlanCapability = contract.ManagementCapabilityTenantMemberPlan ManagementMemberGrantCapability = contract.ManagementCapabilityTenantMemberGrant )
Variables ¶
var ( ErrPrintNotFound = errors.New("print: not found") ErrPrintForbidden = errors.New("print: forbidden") // ErrPrintRenderFailed marks a data source failure that maps to 422. ErrPrintRenderFailed = errors.New("print: render failed") )
Errors a PrintSource returns for the handler to map to HTTP statuses.
var AppBranding = Branding{AppName: "Kigae", PrimaryColor: "#2563eb"}
AppBranding is the global branding config (set from common config at startup).
var BinaryVersion = "dev"
BinaryVersion is set at startup from cli.Version to avoid circular imports. cli/serve.go sets this to its Version value during initialization.
var DefaultLimit = 50
DefaultLimit is the page size used when a list request names none. It is set from common config at startup.
var ErrManagementCapacity = errors.New("management platform work capacity exhausted")
var ErrManagementDirectoryChanged = errors.New("tenant directory changed during routing lookup")
var (
ErrTenantProvisioningCapacity = errors.New("tenant provisioning capacity exhausted")
)
onboardRateLimiter tracks IP → count for self-service site creation.
var MaxLimit = 500
MaxLimit is the largest page size a list request may ask for. It is set from common config at startup.
var PaymentServiceFactory = func(database *sql.DB, dialect kdb.Dialect) *payment.Service { return &payment.Service{Store: &payment.SQLStore{DB: database, Dialect: dialect}, Providers: payment.NewRegistry()} }
PaymentServiceFactory builds the payment service for one site database. The engine installs the production wiring; the default registers cash only.
var SupportedCurrencies = map[string]int{
"AUD": 2, "CAD": 2, "CHF": 2, "CNY": 2, "EUR": 2, "GBP": 2,
"GHS": 2, "INR": 2, "JPY": 0, "KES": 2, "NGN": 2, "RWF": 0,
"TZS": 2, "UGX": 0, "USD": 2, "ZAR": 2,
}
SupportedCurrencies maps each allowed tenant currency to its ISO 4217 minor units (decimal places). Currency affects financial display across a tenant, so arbitrary values must not reach the UI.
Functions ¶
func CountOtherEnabledAdministrators ¶
func CountOtherEnabledAdministrators(ctx context.Context, tx *sql.Tx, dialect kdb.Dialect, site, name string) (int, error)
CountOtherEnabledAdministrators counts enabled users other than name that hold the Administrator role. Roles are stored as a delimited string, so they are split in Go instead of matching with dialect-specific string SQL. The management revoke executor shares it so both paths enforce one last-admin rule.
func DocTypeToJSONSchema ¶
DocTypeToJSONSchema converts a DocType into a JSON Schema object.
func FieldToJSONSchema ¶
FieldToJSONSchema maps a Kigae field definition to a JSON Schema property.
func GenerateOpenAPISpec ¶
GenerateOpenAPISpec builds the full OpenAPI 3.x document from a registry.
func NewPrintHandler ¶
func NewPrintHandler(src PrintSource) gin.HandlerFunc
NewPrintHandler serves GET /api/v1/print/:format_name (as=text|html|pdf).
func NewPrintListHandler ¶
func NewPrintListHandler(src PrintSource) gin.HandlerFunc
NewPrintListHandler serves GET /api/v1/print-formats, optionally filtered by ?record= or ?operation_ref=. Only formats the caller may print are listed.
func NewPrintMetaHandler ¶
func NewPrintMetaHandler(src PrintSource) gin.HandlerFunc
NewPrintMetaHandler serves GET /api/v1/print-formats/:format_name.
func NewScriptProvider ¶
func NewScriptProvider(tx *orm.TxManager, registry *doctype.Registry, site string, secretStore *secret.Store, httpAllowlist []string) script.KoraProvider
NewScriptProvider creates a provider with a scoped HTTP client.
func NewSitePrintHandler ¶
func NewSitePrintHandler(h *Handler) gin.HandlerFunc
NewSitePrintHandler serves GET print/:format_name for the active site.
func NewSitePrintListHandler ¶
func NewSitePrintListHandler(h *Handler) gin.HandlerFunc
NewSitePrintListHandler serves GET print-formats for the active site.
func NewSitePrintMetaHandler ¶
func NewSitePrintMetaHandler(h *Handler) gin.HandlerFunc
NewSitePrintMetaHandler serves GET print-formats/:format_name for the active site.
func RegisterAnalyticsRoutes ¶
func RegisterAnalyticsRoutes(apiGroup *gin.RouterGroup, registry *doctype.Registry, siteDB *sql.DB, dialect db.Dialect, opts AnalyticsOptions)
RegisterAnalyticsRoutes registers analytics API endpoints. siteDB is the fallback DB; per-request DB is resolved from gin context. registry is used to auto-generate metrics from DocType metadata.
func RegisterPublicRoutesOnGroupWithRuntimeServices ¶
func RegisterPublicRoutesOnGroupWithRuntimeServices(apiGroup *gin.RouterGroup, registry *doctype.Registry, txManager *orm.TxManager, siteStorages map[string]storage.Backend, runtimeServices *SiteRuntimeServices)
func RegisterRequestRoutes ¶
func RegisterRequestRoutes(group *gin.RouterGroup, services *SiteRuntimeServices)
RegisterRequestRoutes exposes the generated v2 request contract. Callers must attach the normal tenant authentication, CSRF, routing, and admission middleware to the group before registering these routes.
func RegisterRoutesOnGroup ¶
func RegisterRoutesOnGroup(apiGroup *gin.RouterGroup, registry *doctype.Registry, txManager *orm.TxManager, opts RouteOptions)
RegisterRoutesOnGroup installs the production API routes on apiGroup. The Engine composes it with tenant middleware's pinned service snapshot and an explicit cache owner; registry is the fallback used when a request carries no site registry.
func RegisterSystemRoutes ¶
func RegisterSystemRoutes(apiGroup *gin.RouterGroup, handler *Handler)
RegisterSystemRoutes registers system endpoints on the given API group.
func RegisterWorkflowRoutes ¶
func RegisterWorkflowRoutes(group *gin.RouterGroup, services *SiteRuntimeServices)
RegisterWorkflowRoutes exposes only durable process orchestration APIs. The caller must attach tenant routing, session/CSRF, compression and admission middleware to the group.
func ReleaseTenantStreamAuthWork ¶
ReleaseTenantStreamAuthWork releases the short permit held while a streamed route authenticates. Stream handlers call it after middleware authorization and before storage or realtime streaming begins. Middleware retains a deferred idempotent release for early aborts and handler failures.
func ScriptProviderFactory ¶
func ScriptProviderFactory(registry *doctype.Registry, site string, secretStore *secret.Store, httpAllowlist []string) func(*orm.TxManager) script.KoraProvider
ScriptProviderFactory creates a provider bound to the TxManager supplied by each kernel operation. The provider's HTTP client and transport are shared safely across scoped copies for the owning tenant/request lifetime.
func SetAPILimits ¶
func SetAPILimits(def, max int)
SetAPILimits sets pagination limits from config.
func WorkAdmissionMiddleware ¶
func WorkAdmissionMiddleware(registry *SiteRuntimeServices) gin.HandlerFunc
WorkAdmissionMiddleware bounds concurrent request work for the routed tenant. It is installed once on versioned API groups so nested handler and ORM operations share one admission slot for the whole request.
Types ¶
type AnalyticsOptions ¶
type AnalyticsOptions struct {
// EventBuses maps a site name to its event bus.
EventBuses map[string]analytics.EventBus
// RuntimeServices supplies per-site runtime services (event bus, rebuild
// worker) and the query cache when Cache is nil.
RuntimeServices *SiteRuntimeServices
// Cache is the process-owned semantic query cache. When nil, the cache
// owned by RuntimeServices is used, else the process default.
Cache *AnalyticsQueryCache
}
AnalyticsOptions carries the optional dependencies of RegisterAnalyticsRoutes. The zero value serves analytics with no event buses and the process-default query cache.
type AnalyticsQueryCache ¶
type AnalyticsQueryCache struct {
// contains filtered or unexported fields
}
AnalyticsQueryCache is a process-owned semantic result cache. Tenant service snapshots select keys and permissions, but do not own this shared budget.
func DefaultAnalyticsQueryCache ¶
func DefaultAnalyticsQueryCache() *AnalyticsQueryCache
func NewAnalyticsQueryCache ¶
func NewAnalyticsQueryCache() *AnalyticsQueryCache
func (*AnalyticsQueryCache) AnalyticsQueryCacheSnapshot ¶
func (c *AnalyticsQueryCache) AnalyticsQueryCacheSnapshot() AnalyticsQueryCacheSnapshot
type Branding ¶
type Branding struct {
AppName string `json:"app_name"`
ShortName string `json:"short_name,omitempty"`
LogoURL string `json:"logo_url,omitempty"`
LogoDarkURL string `json:"logo_dark_url,omitempty"`
FaviconURL string `json:"favicon_url,omitempty"`
PrimaryColor string `json:"primary_color"`
AccentColor string `json:"accent_color,omitempty"`
FontFamily string `json:"font_family,omitempty"`
HeadingFont string `json:"heading_font,omitempty"`
DefaultMode string `json:"default_mode,omitempty"`
}
Branding holds per-site branding configuration.
type ConfigurationCheckResult ¶
type ConfigurationCheckResult = contract.ConfigurationCheckV2
ConfigurationCheckResult is the read-only contract used by conversational clients before they ask the Engine to create a draft ConfigVersion.
type ConfigurationConflict ¶
type ConfigurationConflict = contract.ConfigurationConflict
type ConfigurationImpactItem ¶
type ConfigurationImpactItem = contract.ConfigurationImpact
type ConsoleHandler ¶
type ConsoleHandler struct {
SystemGuard *auth.SystemGuard
PlatformWorkAdmission interface {
Acquire(context.Context) (func(), error)
}
TenantSiteAdmission func(context.Context, *site.Config) (func(), error)
SiteRouter *net.SiteRouter
ProvisioningStore *site.OnboardingStore
AllowOnboarding bool
SiteStorages map[string]storage.Backend
RuntimeServices *SiteRuntimeServices
// PrepareRuntime installs the same sidecars used for directory hot-add before
// a newly-created site becomes routable.
PrepareRuntime func(site.DBSiteInfo, *net.LoadedSite) error
// DiscardRuntime releases any sidecars installed by PrepareRuntime when the
// router rejects the new site.
DiscardRuntime func(*net.LoadedSite)
ResolveStorage func(*site.Config) (storage.Backend, error)
// ReloadRuntime publishes the durable directory config through the tenant
// runtime coordinator before this handler reports the update as active.
ReloadRuntime func(context.Context, string) error
PlatformDBType string
PlatformDBHost string
PlatformDBPort int
PlatformDBUser string
PlatformDBPassword string
PlatformDB *sql.DB // Existing platform DB connection (for LibSQL reuse)
// contains filtered or unexported fields
}
ConsoleHandler holds dependencies for console API endpoints.
func NewConsoleHandler ¶
func NewConsoleHandler(guard *auth.SystemGuard, sr *net.SiteRouter, opts ConsoleOptions) *ConsoleHandler
NewConsoleHandler creates a console API handler.
func (*ConsoleHandler) CloseOnboardingJobs ¶
func (h *ConsoleHandler) CloseOnboardingJobs(ctx context.Context) error
CloseOnboardingJobs cancels provisioning jobs and joins them before the process closes the platform database they use.
func (*ConsoleHandler) HandleChangePassword ¶
func (h *ConsoleHandler) HandleChangePassword(c *gin.Context)
HandleChangePassword forces a password change (required on first login with default creds). POST /api/console/change-password
func (*ConsoleHandler) HandleCreateSite ¶
func (h *ConsoleHandler) HandleCreateSite(c *gin.Context)
HandleCreateSite creates a new site: database, config, bootstrap, admin user. POST /api/console/sites Only hostname, admin_email, and admin_password are required. DB fields are optional — platform defaults from env vars are used when empty.
func (*ConsoleHandler) HandleDeleteSite ¶
func (h *ConsoleHandler) HandleDeleteSite(c *gin.Context)
HandleDeleteSite deletes a site and all its data. DELETE /api/console/sites/:name Requires confirmation: {"confirm": "<hostname>"}
func (*ConsoleHandler) HandleListSites ¶
func (h *ConsoleHandler) HandleListSites(c *gin.Context)
HandleListSites returns all loaded sites with status. Falls back to querying the database directly when no sites are loaded (e.g. after container redeploy where site_config.yaml files were lost but DB data persists). GET /api/console/sites
func (*ConsoleHandler) HandleLogin ¶
func (h *ConsoleHandler) HandleLogin(c *gin.Context)
HandleLogin authenticates a console super-admin. POST /api/console/login
func (*ConsoleHandler) HandleOnboard ¶
func (h *ConsoleHandler) HandleOnboard(c *gin.Context)
HandleOnboard creates a site via public self-service (no console auth). POST /api/console/sites/onboard Rate limited: 3 per hour per IP.
func (*ConsoleHandler) HandleOnboardJobs ¶
func (h *ConsoleHandler) HandleOnboardJobs(c *gin.Context)
HandleOnboardJobs lists provisioning jobs for the console. GET /api/console/sites/onboard
func (*ConsoleHandler) HandleOnboardStatus ¶
func (h *ConsoleHandler) HandleOnboardStatus(c *gin.Context)
HandleOnboardStatus returns the current state of a provisioning job. GET /api/console/sites/onboard/:job_id
func (*ConsoleHandler) HandleResetSitePassword ¶
func (h *ConsoleHandler) HandleResetSitePassword(c *gin.Context)
HandleResetSitePassword resets a site user's password. POST /api/console/sites/:name/reset-password
func (*ConsoleHandler) HandleUpdateSite ¶
func (h *ConsoleHandler) HandleUpdateSite(c *gin.Context)
HandleUpdateSite updates site metadata and file storage settings. PUT /api/console/sites/:name
func (*ConsoleHandler) RequireConsoleAuth ¶
func (h *ConsoleHandler) RequireConsoleAuth(c *gin.Context)
RequireConsoleAuth is middleware that validates the console session. Accepts Authorization: Bearer <token> header OR kora_console_sid cookie.
func (*ConsoleHandler) RequirePlatformWork ¶
func (h *ConsoleHandler) RequirePlatformWork(c *gin.Context)
RequirePlatformWork bounds platform console operations that use the administrative database. Authenticate first on protected routes so rejected callers do not consume platform work capacity.
func (*ConsoleHandler) Start ¶
func (h *ConsoleHandler) Start()
Start initializes the durable provisioning store. Rate limiting uses a fixed-window counter and does not require a background sweeper.
type ConsoleOptions ¶
type ConsoleOptions struct {
// DBType, DBHost, DBPort, DBUser and DBPassword locate the platform database
// that new tenant databases are created on.
DBType string
DBHost string
DBPort int
DBUser string
DBPassword string
// PlatformDB is the open platform database connection.
PlatformDB *sql.DB
// AllowOnboarding enables self-service tenant onboarding.
AllowOnboarding bool
}
ConsoleOptions carries the platform database and onboarding settings of the console API. The zero value is a console with no platform database and self-service onboarding off.
type DocTypeNavItem ¶
type DocTypeNavItem struct {
}
DocTypeNavItem is a single DocType entry in the navigation.
type DraftConfigurationRequest ¶
type DraftConfigurationRequest struct {
ProposalID string `json:"proposal_id"`
DraftConfigVersionID string `json:"draft_config_version_id,omitempty"`
ConversationID string `json:"conversation_id,omitempty"`
InterviewSnapshot map[string]any `json:"interview_snapshot,omitempty"`
PrimaryWorkflow string `json:"primary_workflow,omitempty"`
StructuredInput map[string]any `json:"structured_input,omitempty"`
OpenQuestions []string `json:"open_questions,omitempty"`
ChannelOrigin string `json:"channel_origin,omitempty"`
BaseConfigVersionID string `json:"base_config_version_id,omitempty"`
CreatedBy string `json:"created_by,omitempty"` // legacy input; attribution uses verified execution
DocTypes []*doctype.DocType `json:"doctypes"`
Roles []*doctype.Role `json:"roles,omitempty"`
Permissions []*DraftPermission `json:"permissions,omitempty"`
Views []*doctype.View `json:"views,omitempty"`
Scripts []*ScriptCandidate `json:"scripts,omitempty"`
ScheduledJobs []contract.ScheduledJobDefinition `json:"scheduled_jobs,omitempty"`
WorkflowDefinitions []contract.WorkflowDefinition `json:"workflow_definitions,omitempty"`
PublishedBindings []contract.ConfigurationSurfaceBinding `json:"published_bindings,omitempty"`
}
DraftConfigurationRequest is Engine's domain-typed view of the generated configuration-draft wire contract. The complete package is composed into one draft; callers must not create each DocType independently.
type DraftPermission ¶
type DraftPermission struct {
doctype.Permission
Public bool `json:"public,omitempty"`
}
DraftPermission includes the legacy public flag so the Engine can reject an unsupported access grant instead of silently dropping it during decoding.
type ErrorBody ¶
type ErrorBody struct {
Code string `json:"code"`
Message string `json:"message"`
Details map[string]any `json:"details,omitempty"`
}
ErrorBody is the machine-readable error envelope returned to the frontend.
type ErrorResponse ¶
ErrorResponse is the standard error response envelope.
type ExperienceCopy ¶
type ExtensionStore ¶
type ExtensionStore interface {
List(ctx context.Context, site string) ([]extension.Summary, error)
Create(ctx context.Context, registration extension.Registration) error
Delete(ctx context.Context, site, name string) error
RotateSecret(ctx context.Context, rotation extension.SecretRotation) error
}
ExtensionStore is the extension administration persistence these handlers use.
type ExtensionStoreOpener ¶
type ExtensionStoreOpener func(*sql.DB, kdb.QueryDialect) ExtensionStore
ExtensionStoreOpener binds an ExtensionStore to a tenant database.
type Handler ¶
type Handler struct {
// ExtensionStores opens the tenant extension store. Nil uses the SQL store.
// PrintSource backs GET /print/:format_name. Nil answers print.not_configured.
PrintSource PrintSource
ExtensionStores ExtensionStoreOpener
Registry *doctype.Registry
TxManager *orm.TxManager
AuthProviders *auth.ProviderRegistry
RuntimeServices *SiteRuntimeServices
RealtimeConnections *RealtimeConnectionOwner
// SiteEventBuses maps site name → EventBus for analytics/realtime services.
SiteEventBuses map[string]eventstream.Bus
// SiteOutboxes maps site name → outbox.Writer for transactional outbox recording.
// When a site has a writer, its document writes record an event in _kora_outbox
// within the same transaction. Nil for sites (or deployments) without the outbox.
SiteOutboxes map[string]outbox.Writer
// SiteRealtimeProviders maps site name → NATS provider used to source realtime events.
SiteRealtimeProviders map[string]*natsprovider.Provider
// ScriptRunner executes JavaScript hooks (shared across all sites).
ScriptRunner script.Runner
// SiteScriptStores maps site name → *script.Store for script persistence.
SiteScriptStores map[string]*script.Store
// SiteSecretStores maps site name → *secret.Store for secret access from scripts.
SiteSecretStores map[string]*secret.Store
// ScriptHTTPAllowlist controls which domains scripts can call via kora.http.
ScriptHTTPAllowlist []string
// SiteWebhookWorkers maps site name → *webhook.Worker for webhook delivery.
SiteWebhookWorkers map[string]*webhook.Worker
// AsyncHookSink receives after_* hooks for fire-and-forget execution.
AsyncHookSink orm.AsyncHookSink
// SiteStorages maps site name → storage backend for attachments. Storage is a
// fallback used when no site-specific backend is configured.
SiteStorages map[string]storage.Backend
Storage storage.Backend
// KernelCommands carries config-defined command resources (KERNEL-008)
// loaded at startup from application configuration. Nil = built-ins only;
// GET /api/v1/kernel/_registry then reports an empty list.
KernelCommands *kernel.CommandRegistry
AgentStores map[string]*org.AgentStore
}
Handler holds dependencies for API handlers. Registry and TxManager are fallbacks; handlers read site context from the request.
func NewHandler ¶
NewHandler creates a new API handler.
func (*Handler) HandleAICancel ¶
HandleAICancel marks a durable AI run as cancelled.
func (*Handler) HandleAIChatConversation ¶
HandleAIChatConversation returns the persisted transcript for the current user and page context. The server owns transcript history; clients only send the new turn and its current page context.
func (*Handler) HandleAIGrantApproval ¶
HandleAIGrantApproval transitions a durable approval row from pending_approval to granted.
func (*Handler) HandleAIListApprovals ¶
HandleAIListApprovals returns approval rows for the current site.
func (*Handler) HandleAIResume ¶
HandleAIResume transitions a durable AI run back into planning if it is not terminal.
func (*Handler) HandleAIRetentionCleanup ¶
HandleAIRetentionCleanup removes expired AI conversations, runs, messages, and steps.
func (*Handler) HandleActiveConfigSnapshot ¶
HandleActiveConfigSnapshot returns only the configuration version currently activated in the tenant runtime. Consumers that need pending drafts must use the explicit head endpoint and inspect its status.
func (*Handler) HandleAgentEffectivePermissions ¶
HandleAgentEffectivePermissions returns the permission matrix result for an agent.
func (*Handler) HandleAgentManifest ¶
func (*Handler) HandleAgentManifests ¶
func (*Handler) HandleAgentPermissionCatalog ¶
HandleAgentPermissionCatalog exposes DocType-derived operations to Studio.
func (*Handler) HandleAgentRuns ¶
func (*Handler) HandleApplicationCatalog ¶
HandleApplicationCatalog returns the actor-filtered discovery view of the tenant's currently installed module surfaces. It is descriptive only; each execution route continues to authorize independently.
func (*Handler) HandleAuthPolicy ¶
HandleAuthPolicy returns the tenant sign-in policy. GET /api/system/auth/policy
func (*Handler) HandleAuthPolicyUpdate ¶
HandleAuthPolicyUpdate changes the tenant sign-in policy. Local sign-in can only be turned off while at least one provider is enabled. PUT /api/system/auth/policy
func (*Handler) HandleAuthProviderDelete ¶
HandleAuthProviderDelete removes a provider and its client secret. DELETE /api/system/auth/providers/:id
func (*Handler) HandleAuthProviderList ¶
HandleAuthProviderList lists the tenant's sign-in providers without secrets. GET /api/system/auth/providers
func (*Handler) HandleAuthProviderPut ¶
HandleAuthProviderPut creates or replaces an OIDC provider. The client secret is write-only and stored in the secret store. PUT /api/system/auth/providers/:id
func (*Handler) HandleAuthProviders ¶
HandleAuthProviders returns enabled authentication providers. Public endpoint — no auth required.
func (*Handler) HandleBusinessReconciliationRead ¶
func (*Handler) HandleBusinessReconciliationRepair ¶
func (*Handler) HandleBusinessReconciliationRun ¶
func (*Handler) HandleBusinessReconciliationSummary ¶
HandleBusinessReconciliationSummary returns only unresolved business findings for the caller's exact scope. Delivery failures remain a separate inspection surface.
func (*Handler) HandleBusinessReconciliationWaive ¶
func (*Handler) HandleChannelMutate ¶
func (*Handler) HandleChannelQuery ¶
func (*Handler) HandleChannelSessionIssue ¶
func (*Handler) HandleChannelSessionRevoke ¶
func (*Handler) HandleChannelTools ¶
func (*Handler) HandleChat ¶
HandleChat processes one turn through the durable AI chat workflow.
func (*Handler) HandleConfigDiff ¶
HandleConfigDiff returns the diff between two config versions.
func (*Handler) HandleConfigHeadSnapshot ¶
HandleConfigVersionSnapshot returns the full ConfigSnapshot for a version, including ready-to-use YAML pack files for the Template Pack workflow. GET /api/system/config/versions/:id/snapshot
func (*Handler) HandleConfigImport ¶
HandleConfigImport imports a YAML config file and returns parsed DocType JSON. POST /api/system/config/import
func (*Handler) HandleConfigVersion ¶
HandleConfigVersion gets a single config version snapshot.
func (*Handler) HandleConfigVersionActivate ¶
HandleConfigVersionActivate activates a Draft version. POST /api/system/config/versions/:id/activate
func (*Handler) HandleConfigVersionDiscard ¶
HandleConfigVersionDiscard discards a Draft version. POST /api/system/config/versions/:id/discard
func (*Handler) HandleConfigVersionPreview ¶
HandleConfigVersionPreview returns a preview of what activating a version will change. GET /api/system/config/versions/:id/preview
func (*Handler) HandleConfigVersionRollback ¶
HandleConfigVersionRollback activates a Superseded version (rollback). POST /api/system/config/versions/:id/rollback
func (*Handler) HandleConfigVersionRollbackPreview ¶
HandleConfigVersionRollbackPreview returns a preview of what rolling back to a version will change. GET /api/system/config/versions/:id/rollback-preview
func (*Handler) HandleConfigVersionSnapshot ¶
func (*Handler) HandleConfigVersions ¶
HandleConfigVersions lists all config versions.
func (*Handler) HandleConfigurationDraft ¶
HandleConfigurationDraft composes an ordered, validated package into one Draft ConfigVersion. It never writes live DocType tables or activates code.
func (*Handler) HandleConfigurationDryRun ¶
HandleConfigurationDryRun adds impact information to the same read-only check. It deliberately does not create a ConfigVersion.
func (*Handler) HandleConfigurationValidate ¶
HandleConfigurationValidate checks a complete candidate without writing a version, live table, migration, or external side effect.
func (*Handler) HandleCreate ¶
HandleCreate handles POST /api/resource/{doctype}
func (*Handler) HandleDelete ¶
HandleDelete handles DELETE /api/resource/{doctype}/{name}
func (*Handler) HandleExecutePublishedOperation ¶
func (*Handler) HandleExtensionCreate ¶
HandleExtensionCreate registers a new extension.
func (*Handler) HandleExtensionDelete ¶
HandleExtensionDelete removes an extension.
func (*Handler) HandleExtensionDeliveries ¶
HandleExtensionDeliveries returns the delivery log for an extension.
func (*Handler) HandleExtensionGet ¶
HandleExtensionGet returns a single extension.
func (*Handler) HandleExtensionList ¶
HandleExtensionList returns all extensions for the current site.
func (*Handler) HandleExtensionReplay ¶
HandleExtensionReplay replays a specific delivery or all dead-lettered deliveries.
func (*Handler) HandleExtensionRotateSecret ¶
HandleExtensionRotateSecret generates a new signing secret for an extension.
func (*Handler) HandleExtensionUpdate ¶
HandleExtensionUpdate updates an extension.
func (*Handler) HandleFileDelete ¶
HandleFileDelete removes an uploaded attachment. DELETE /files/*path
func (*Handler) HandleFileServe ¶
HandleFileServe serves an uploaded attachment with HTTP Range support so browsers can seek within audio/video. Access is enforced by the SiteGuard middleware. GET /files/*path
func (*Handler) HandleGetPublishedOperationReceipt ¶
func (*Handler) HandleImport ¶
HandleImport serves POST /api/v1/import: a create-only CSV import into a DocType, executed through the kernel bulk executor.
func (*Handler) HandleKernelOperation ¶
HandleKernelOperation routes a canonical command through the operation kernel (first vertical slice: record.create, record.update). All sources share this path; there is no per-adapter mutation logic here.
func (*Handler) HandleKernelRegistry ¶
HandleKernelRegistry lists config-defined command resources available on this runtime (KERNEL-008 introspection): name, version, permission operation, input record, and touched records with their required operations. MCP/AI/SDK catalogs derive from this surface.
func (*Handler) HandleList ¶
HandleList handles GET /api/resource/{doctype}
func (*Handler) HandleLookupPublishedOperation ¶
func (*Handler) HandleMPesaSTKCallback ¶
HandleMPesaSTKCallback accepts Safaricom's asynchronous STK callback. The callback is site-scoped by the public route group and matched by the provider CheckoutRequestID. It is intentionally idempotent: once an operation is terminal, repeated callbacks are recorded but do not mutate the payment again.
func (*Handler) HandleManagedChannelClientRevoke ¶
HandleManagedChannelClientRevoke disables the Cloud-managed credential only if its current token still matches Cloud's expected fingerprint. This makes deletion retries idempotent while preventing a delayed retry from disabling a newer credential rotation.
func (*Handler) HandleManagedChannelClientRotate ¶
HandleManagedChannelClientRotate is the narrow Engine-owned provisioning operation used by Cloud to install or rotate its site-scoped access token. The dedicated service token is accepted only for this exact route by SiteGuard; the credential is returned once and is never logged.
func (*Handler) HandleManagedSiteIdentity ¶
HandleManagedSiteIdentity returns the live runtime identity through the site-scoped route. A successful response includes a tenant DB ping, so Cloud can distinguish a directory row from a serving, healthy Engine runtime.
func (*Handler) HandleMethod ¶
HandleMethod handles POST/GET /api/method/{name} — user-defined custom API endpoints. Scripts registered with script_type='api_method' and matching method_path are executed.
func (*Handler) HandleOfflineBootstrapV2 ¶
func (*Handler) HandleOfflineCapabilitiesV2 ¶
func (*Handler) HandleOfflineIntentsV2 ¶
func (*Handler) HandleOfflinePullV2 ¶
func (*Handler) HandleOpenAPI ¶
HandleOpenAPI returns the OpenAPI 3.x spec for the current site.
func (*Handler) HandlePageManifestByRoute ¶
HandlePageManifestByRoute resolves a manifest by runtime route. GET /api/v1/page-manifests?route=/orders
func (*Handler) HandlePaymentCallback ¶
HandlePaymentCallback serves POST /webhooks/payments/:provider/:token. The token is validated by the provider; bodies and tokens are never logged.
func (*Handler) HandlePaymentGet ¶
HandlePaymentGet serves GET /payments/:id.
func (*Handler) HandlePaymentRequest ¶
HandlePaymentRequest serves POST /payments.
func (*Handler) HandlePublicCreate ¶
HandlePublicCreate handles unauthenticated document creation. POST /v?route=/apply
func (*Handler) HandlePublicFileServe ¶
HandlePublicFileServe serves a site attachment without auth for public assets. GET /public/files/*path
func (*Handler) HandlePublicGet ¶
func (*Handler) HandlePublicList ¶
func (*Handler) HandlePublicView ¶
HandlePublicView resolves a view by route for unauthenticated users. GET /v?route=/catalog Three-layer security check:
- View allows public access for the component
- Component's source doctype has public access enabled
- Component bindings only reference public fields
func (*Handler) HandlePublishedModuleProjection ¶
HandlePublishedModuleProjection serves the latest complete snapshot under the caller's exact business scope. Stale snapshots remain readable and carry their freshness state so reports cannot silently turn source outages into 0.
func (*Handler) HandlePublishedModuleQuery ¶
HandlePublishedModuleQuery executes an owner-published query through the tenant's pinned module provider plan. Actor authorization is performed against the owner module's published query resource before dispatch.
func (*Handler) HandleRebuildPublishedModuleProjection ¶
HandleRebuildPublishedModuleProjection runs an idempotent, revision-pinned snapshot rebuild. Data is published only after every source page validates.
func (*Handler) HandleRecordHistory ¶
HandleRecordHistory returns successful create, update, and delete activity for a record only after applying the same read and row-scope checks as GET.
func (*Handler) HandleScriptCreate ¶
HandleScriptCreate creates a new script.
func (*Handler) HandleScriptDelete ¶
HandleScriptDelete deletes a script.
func (*Handler) HandleScriptExecutions ¶
HandleScriptExecutions returns the execution log for a script.
func (*Handler) HandleScriptGet ¶
HandleScriptGet returns a single script.
func (*Handler) HandleScriptList ¶
HandleScriptList returns all scripts for the current site.
func (*Handler) HandleScriptUpdate ¶
HandleScriptUpdate updates an existing script.
func (*Handler) HandleScriptValidate ¶
HandleScriptValidate validates a script without saving it.
func (*Handler) HandleSecretDelete ¶
HandleSecretDelete deletes a secret by key name. DELETE /api/system/secrets/:key
func (*Handler) HandleSecretList ¶
HandleSecretList returns all secret key names and timestamps for the current site. Values are NEVER returned. GET /api/system/secrets
func (*Handler) HandleSecretSet ¶
HandleSecretSet creates or updates a secret. POST /api/system/secrets
func (*Handler) HandleSiteSettings ¶
HandleSiteSettings returns safe, non-secret settings for the current site. GET /api/system/settings
func (*Handler) HandleSiteSettingsUpdate ¶
HandleSiteSettingsUpdate updates tenant-scoped settings. Settings are kept separate from infrastructure site_config.yaml and from versioned schema. PUT /api/system/settings
func (*Handler) HandleSwaggerUI ¶
HandleSwaggerUI serves the Swagger UI HTML page.
func (*Handler) HandleSystemAudit ¶
HandleSystemAudit returns a redacted operation-audit projection for authorized Studio inspection. It never returns command arguments or business payloads; hashes and actor metadata explain an operation without leaking tenant data.
func (*Handler) HandleSystemBranding ¶
func (*Handler) HandleSystemDoctype ¶
HandleSystemDoctype returns the full DocType schema and permissions. GET /api/system/doctype/:doctype Optional query param: ?format=yaml to get raw YAML output.
func (*Handler) HandleSystemDoctypeCreate ¶
HandleSystemDoctypeCreate creates a new DocType from JSON body. POST /api/system/doctype?activate=true|false
func (*Handler) HandleSystemDoctypeDelete ¶
HandleSystemDoctypeDelete removes a DocType configuration. DELETE /api/system/doctype/:doctype?cleanup=config|full
cleanup=config (default): Delete config rows only. Business tables, analytics, permissions survive. cleanup=full: Full cleanup — also deletes analytics and permissions, and clears Link fields. cleanup=none: Soft delete — only remove from registry.
func (*Handler) HandleSystemDoctypeDryRun ¶
HandleSystemDoctypeDryRun returns the impact analysis for a proposed doctype change. POST /api/system/doctype/dry-run
func (*Handler) HandleSystemDoctypeReferences ¶
HandleSystemDoctypeReferences returns other doctypes that link to the given doctype. GET /api/system/doctype/:doctype/references
func (*Handler) HandleSystemDoctypeUpdate ¶
HandleSystemDoctypeUpdate updates an existing DocType. PUT /api/system/doctype/:doctype?activate=true|false
func (*Handler) HandleSystemDoctypeValidate ¶
HandleSystemDoctypeValidate validates a DocType JSON or YAML body without saving. POST /api/system/doctype/validate Accepts JSON (Content-Type: application/json) or YAML (Content-Type: application/x-yaml). Returns structured errors with line numbers for unknown keys and validation issues.
func (*Handler) HandleSystemDoctypes ¶
HandleSystemDoctypes returns a flat list of all DocTypes with status. GET /api/system/doctypes
func (*Handler) HandleSystemExperienceUpdate ¶
func (*Handler) HandleSystemGraph ¶
HandleSystemGraph returns the canonical DocType-backed inspection graph. GET /api/system/graph
func (*Handler) HandleSystemNavigation ¶
HandleSystemNavigation returns the navigation config (sidebar, branding, user). GET /api/system/navigation
func (*Handler) HandleSystemPageManifest ¶
HandleSystemPageManifest returns a single RFC page manifest by name. GET /api/v1/system/page-manifests/:name
func (*Handler) HandleSystemPageManifestCreate ¶
HandleSystemPageManifestCreate creates a new RFC page manifest. POST /api/v1/system/page-manifests
func (*Handler) HandleSystemPageManifestDelete ¶
HandleSystemPageManifestDelete removes a page manifest by name. DELETE /api/v1/system/page-manifests/:name
func (*Handler) HandleSystemPageManifestUpdate ¶
HandleSystemPageManifestUpdate updates an existing RFC page manifest. PUT /api/v1/system/page-manifests/:name
func (*Handler) HandleSystemPageManifests ¶
HandleSystemPageManifests lists RFC-native page manifests. GET /api/v1/system/page-manifests
func (*Handler) HandleSystemPermissions ¶
HandleSystemPermissions returns all permissions. GET /api/system/permissions
func (*Handler) HandleSystemPermissionsSave ¶
HandleSystemPermissionsSave replaces all permissions. PUT /api/system/permissions
func (*Handler) HandleSystemRealtime ¶
HandleSystemRealtime streams authenticated realtime connection events. It supports WebSocket when the client upgrades, and SSE as a read-only fallback.
func (*Handler) HandleSystemRoleCreate ¶
HandleSystemRoleCreate creates a new role. POST /api/system/roles
func (*Handler) HandleSystemRoleDelete ¶
HandleSystemRoleDelete deletes a role. DELETE /api/system/roles/:name
func (*Handler) HandleSystemRoleUpdate ¶
HandleSystemRoleUpdate updates an existing role. PUT /api/system/roles/:name
func (*Handler) HandleSystemRoles ¶
HandleSystemRoles returns all roles. GET /api/system/roles
func (*Handler) HandleSystemView ¶
HandleSystemView returns a single view by name. GET /api/v1/system/views/:name
func (*Handler) HandleSystemViewCreate ¶
HandleSystemViewCreate creates a new view and returns a config version. POST /api/v1/system/views
func (*Handler) HandleSystemViewDelete ¶
HandleSystemViewDelete removes a view and returns a config version. DELETE /api/v1/system/views/:name
func (*Handler) HandleSystemViewUpdate ¶
HandleSystemViewUpdate updates an existing view and returns a config version. PUT /api/v1/system/views/:name
func (*Handler) HandleSystemViews ¶
HandleSystemViews returns all views for the current site. GET /api/v1/system/views
func (*Handler) HandleUpdate ¶
HandleUpdate handles PUT /api/resource/{doctype}/{name}
func (*Handler) HandleUpload ¶
HandleUpload handles file uploads via multipart form. POST /upload Stores files via the configured storage backend and returns a file reference (path + metadata) for storage in an Attach / Attach Image / Attach Audio field.
func (*Handler) HandleUserDirectory ¶
HandleUserDirectory returns a bounded list of enabled workspace identities for authenticated user pickers. A search term matches the same full name and email labels presented by the UI; results are always scoped to the routed tenant. This is deliberately separate from the administrative user list. GET /api/system/user-directory?q=<name-or-email>&limit=<1..50>
func (*Handler) HandleUserGet ¶
HandleUserGet returns a single user by name (ULID). GET /api/system/users/:name
func (*Handler) HandleUserList ¶
HandleUserList returns all users for the current site. GET /api/system/users
func (*Handler) HandleUserUpdate ¶
HandleUserUpdate updates a user's profile fields. PUT /api/system/users/:name
func (*Handler) HandleViewAction ¶
func (*Handler) HandleViewByRoute ¶
HandleViewByRoute resolves a view by its route for authenticated users. GET /api/v1/views?route=/pos/register Optional: ?version=draft to preview the latest Draft version.
func (*Handler) HandleViewData ¶
HandleViewData returns aggregated data for dashboard/metric components. GET /api/v1/view/data?view=Name&component=id
func (*Handler) HandleViewValidate ¶
HandleViewValidate validates a view config against the registry's doctypes. POST /api/v1/system/views/validate
type ManagementCapability ¶
type ManagementCapability = contract.ManagementCapability
type ManagementDirectory ¶
type ManagementDirectory interface {
GetDescriptorByIDContext(context.Context, string) (site.Descriptor, error)
ResolveDescriptorByAliasContext(context.Context, string) (site.Descriptor, error)
CurrentDirectoryRevisionContext(context.Context) (uint64, error)
}
ManagementDirectory is the credential-free subset of Engine's platform directory needed by the management inspection API.
type ManagementInspectHandler ¶
type ManagementInspectHandler struct {
// contains filtered or unexported fields
}
ManagementInspectHandler serves a safe platform projection. Mutating management endpoints are intentionally registered only when their durable operation executors are part of Engine composition.
func NewManagementInspectHandler ¶
func NewManagementInspectHandler(directory ManagementDirectory, token, deployment string, admissions ...interface { Acquire(context.Context) (func(), error) }) (*ManagementInspectHandler, error)
func (*ManagementInspectHandler) Register ¶
func (h *ManagementInspectHandler) Register(router gin.IRouter)
func (*ManagementInspectHandler) RegisterOperations ¶
func (h *ManagementInspectHandler) RegisterOperations(router gin.IRouter, config ManagementOperationRoutes) error
func (*ManagementInspectHandler) SetTenantConfigRevisionResolver ¶
func (h *ManagementInspectHandler) SetTenantConfigRevisionResolver(resolve TenantConfigRevisionResolver)
SetTenantConfigRevisionResolver installs the Engine-owned tenant DB reader. The platform directory revision remains independent for lifecycle CAS.
type ManagementInvitationReconciler ¶
type ManagementInvitationReconciler interface {
ReconcileInvitation(context.Context, management.Operation, contract.ReconcileTenantInvitationOperation) error
}
type ManagementModuleLifecyclePlanner ¶
type ManagementModuleLifecyclePlanner interface {
Plan(context.Context, contract.TenantID, contract.PlanModuleChange) (contract.ModuleChangePlan, error)
}
type ManagementOperationRoutes ¶
type ManagementOperationRoutes struct {
Service ManagementOperationService
Caller contract.PrincipalID
Capabilities map[ManagementCapability]bool
WorkerReady bool
InvitationReconciler ManagementInvitationReconciler
ModuleLifecyclePlanner ManagementModuleLifecyclePlanner
ModuleInspector ManagementModuleInspector
MemberPlanner ManagementTenantMemberPlanner
}
ManagementOperationRoutes installs only the command routes whose durable executor and verified service grants are present in Engine composition.
type ManagementOperationService ¶
type ManagementOperationService interface {
Accept(context.Context, contract.PrincipalID, any) (management.Operation, error)
AcceptForTenant(context.Context, contract.PrincipalID, contract.TenantID, any) (management.Operation, error)
Get(context.Context, contract.PrincipalID, contract.OperationID) (management.Operation, error)
ReconcileTenantState(context.Context, contract.PrincipalID, contract.OperationID, contract.ReconcileTenantStateOperation) (management.Operation, error)
ReconcileTenantProvision(context.Context, contract.PrincipalID, contract.OperationID, contract.ReconcileTenantProvisionOperation) (management.Operation, error)
ReconcileTenantPackage(context.Context, contract.PrincipalID, contract.OperationID, contract.ReconcileTenantPackageOperation) (management.Operation, error)
ReconcileTenantDelete(context.Context, contract.PrincipalID, contract.OperationID, contract.ReconcileTenantDeleteOperation) (management.Operation, error)
ReconcileTenantInvitation(context.Context, contract.PrincipalID, contract.OperationID, contract.ReconcileTenantInvitationOperation) (management.Operation, error)
}
type ManagementTenantMemberPlanner ¶
type ManagementTenantMemberPlanner interface {
PlanMember(context.Context, contract.TenantID, contract.PlanTenantMember) (contract.TenantMemberPlan, error)
}
ManagementTenantMemberPlanner answers the read-only tenant member check. It has no durable effect and does not create an operation.
type Meta ¶
type Meta struct {
ConfigVersion int `json:"config_version,omitempty"`
DocType string `json:"doctype,omitempty"`
Total int `json:"total,omitempty"`
}
Meta holds response metadata.
type ModuleGroup ¶
type ModuleGroup struct {
Module string `json:"module"`
Label string `json:"label"`
DocTypes []DocTypeNavItem `json:"doctypes"`
}
ModuleGroup is a group of DocTypes under a module.
type NavigationResponse ¶
type NavigationResponse struct {
}
NavigationResponse is the full navigation config for the SPA sidebar.
type PrintSource ¶
type PrintSource interface {
Format(c *gin.Context, name string) (*print.Format, error)
Record(c *gin.Context, doctype, name string) (map[string]any, error)
Receipt(c *gin.Context, ref, executionID string) (receipt, doc map[string]any, err error)
Tenant(c *gin.Context) (map[string]any, print.Options)
// Formats lists the tenant's formats; Authorize applies the render route's
// read rules to a format's targets without needing a record.
Formats(c *gin.Context) []*print.Format
Authorize(c *gin.Context, f *print.Format) error
// Query runs a published query as the viewer; it returns ErrPrintForbidden
// on a denied grant and ErrPrintNotFound for an unknown query.
Query(c *gin.Context, module, name string, input map[string]any) ([]map[string]any, error)
}
PrintSource supplies print formats and permission-checked data. Record and Receipt must enforce read permission / receipt visibility.
type RealtimeConnectionOwner ¶
type RealtimeConnectionOwner struct {
// contains filtered or unexported fields
}
RealtimeConnectionOwner tracks hijacked WebSocket connections, which net/http.Server.Shutdown does not close or wait for. The process owner calls Close before tenant runtimes and their database pools are retired.
func NewRealtimeConnectionOwner ¶
func NewRealtimeConnectionOwner() *RealtimeConnectionOwner
func (*RealtimeConnectionOwner) Close ¶
func (o *RealtimeConnectionOwner) Close()
Close terminates active WebSockets immediately and prevents new streams from surviving process shutdown.
func (*RealtimeConnectionOwner) Register ¶
func (o *RealtimeConnectionOwner) Register(closeStream func()) func()
Register adds a connection and returns an idempotent unregister function. Connections accepted after shutdown begins are closed immediately.
type RecordHistoryEntry ¶
type RecordHistoryEntry struct {
Actor string `json:"actor"`
Action string `json:"action"`
CreatedAt string `json:"created_at"`
Changes []RecordHistoryFieldChange `json:"changes"`
}
RecordHistoryEntry is the user-facing activity projection for one record. It includes only visible field diffs; command payloads and audit hashes stay private to the operation ledger.
type ReferenceInfo ¶
type ReferenceInfo struct {
Doctype string `json:"doctype"`
Fieldname string `json:"fieldname"`
Label string `json:"label"`
}
ReferenceInfo describes a doctype that links to the current doctype via a Link field.
type RouteOptions ¶
type RouteOptions struct {
// EventBuses maps a site to its analytics and realtime event bus.
EventBuses map[string]eventstream.Bus
// RealtimeProviders maps a site to its realtime provider.
RealtimeProviders map[string]*natsprovider.Provider
// ScriptStores maps a site to its script store.
ScriptStores map[string]*script.Store
// SecretStores maps a site to its encrypted secret store.
SecretStores map[string]*secret.Store
// WebhookWorkers maps a site to its outgoing webhook worker.
WebhookWorkers map[string]*webhook.Worker
// Outboxes maps a site to its transactional outbox writer.
Outboxes map[string]outbox.Writer
// Storages maps a site to its attachment storage backend.
Storages map[string]storage.Backend
// ScriptRunner executes extension scripts; nil disables script hooks.
ScriptRunner script.Runner
// HTTPAllowlist lists the domains scripts may call.
HTTPAllowlist []string
// AsyncHookSink receives hooks that run after the request completes.
AsyncHookSink orm.AsyncHookSink
// KernelCommands is the config-defined kernel command registry.
KernelCommands *kernel.CommandRegistry
// RuntimeServices is the pinned per-site service snapshot used for work
// admission. Engine composition leaves it nil and relies on tenant
// middleware.
RuntimeServices *SiteRuntimeServices
// AnalyticsCache is the process-owned analytics query cache; nil selects
// the process default.
AnalyticsCache *AnalyticsQueryCache
// RealtimeConnections owns hijacked WebSocket connections so the Engine can
// close them before retiring tenant runtime generations.
RealtimeConnections *RealtimeConnectionOwner
}
RouteOptions carries the optional dependencies of RegisterRoutesOnGroup. The zero value registers the routes with no per-site registries, no script runner and the process-default analytics cache.
type ScriptCandidate ¶
type ScriptCandidate struct {
Name string `json:"name"`
ScriptType string `json:"script_type"`
DocType string `json:"doctype,omitempty"`
Event string `json:"event,omitempty"`
MethodPath string `json:"method_path,omitempty"`
Schedule string `json:"schedule,omitempty"`
RunAs string `json:"run_as,omitempty"`
TimeoutMs int `json:"timeout_ms,omitempty"`
Source string `json:"source"`
}
type SecretEntry ¶
SecretEntry represents a secret in list responses (value never exposed).
type SiteRuntimeService ¶
type SiteRuntimeService = tenantruntime.Services
SiteRuntimeService is the process-local service bundle for one loaded site.
func RuntimeServiceForContext ¶
func RuntimeServiceForContext(c *gin.Context, registry *SiteRuntimeServices, site string) SiteRuntimeService
RuntimeServiceForContext returns the immutable bundle captured by routing middleware for this request, falling back to the live registry for system handlers that are not bound to a tenant runtime.
type SiteRuntimeServices ¶
type SiteRuntimeServices struct {
// contains filtered or unexported fields
}
SiteRuntimeServices is a source-compatible per-site service fallback for external API consumers. Engine tenant requests use the immutable service bundle pinned in request context instead of consulting this mutable map.
func NewSiteRuntimeServices ¶
func NewSiteRuntimeServices() *SiteRuntimeServices
func NewSiteRuntimeServicesWithAnalyticsQueryCache ¶
func NewSiteRuntimeServicesWithAnalyticsQueryCache(cache *AnalyticsQueryCache) *SiteRuntimeServices
func (*SiteRuntimeServices) AnalyticsQueryCacheSnapshot ¶
func (s *SiteRuntimeServices) AnalyticsQueryCacheSnapshot() AnalyticsQueryCacheSnapshot
AnalyticsQueryCacheSnapshot reports the process router's retained semantic query cache budget for Engine resource metrics.
func (*SiteRuntimeServices) Get ¶
func (s *SiteRuntimeServices) Get(site string) (SiteRuntimeService, bool)
func (*SiteRuntimeServices) Remove ¶
func (s *SiteRuntimeServices) Remove(site string)
Remove atomically retires the handler-visible service bundle for a site.
func (*SiteRuntimeServices) Replace ¶
func (s *SiteRuntimeServices) Replace(site string, services SiteRuntimeService)
Replace publishes the complete bundle for a site atomically.
func (*SiteRuntimeServices) SetStorage ¶
func (s *SiteRuntimeServices) SetStorage(site string, backend storage.Backend)
type SystemAuditEntry ¶
type SystemAuditEntry struct {
ID string `json:"id"`
OperationID string `json:"operation_id"`
CorrelationID string `json:"correlation_id,omitempty"`
CausationID string `json:"causation_id,omitempty"`
Source string `json:"source,omitempty"`
PrincipalType string `json:"principal_type,omitempty"`
PrincipalID string `json:"principal_id,omitempty"`
ActorUser string `json:"actor_user,omitempty"`
Command string `json:"command"`
Doctype string `json:"doctype,omitempty"`
DocName string `json:"doc_name,omitempty"`
Status string `json:"status"`
ErrorCode string `json:"error_code,omitempty"`
PayloadHash string `json:"payload_hash,omitempty"`
BeforeHash string `json:"before_hash,omitempty"`
AfterHash string `json:"after_hash,omitempty"`
CreatedAt string `json:"created_at"`
}
SystemAuditEntry is the redacted, read-only projection of the operation ledger exposed to authorized Studio users. It intentionally excludes command arguments and business payloads; hashes and actor metadata are sufficient to explain an operation without leaking tenant data.
type SystemDoctypeResponse ¶
type SystemDoctypeResponse struct {
DocType *doctype.DocType `json:"doctype"`
Status string `json:"status"` // "Active" or "Draft"
Permissions map[string]bool `json:"permissions"`
ReferencedBy []ReferenceInfo `json:"referenced_by,omitempty"`
}
SystemDoctypeResponse is the full schema response for a single DocType.
type SystemGraphEdge ¶
type SystemGraphNode ¶
type SystemGraphNode struct {
ID string `json:"id"`
Kind string `json:"kind"`
Label string `json:"label"`
Detail string `json:"detail"`
Doctype string `json:"doctype,omitempty"`
}
SystemGraphNode is the canonical, read-only projection used by inspection clients. Business schema nodes are always DocTypes; "entity" is not a registrable runtime kind.
type SystemGraphResponse ¶
type SystemGraphResponse struct {
Nodes []SystemGraphNode `json:"nodes"`
Edges []SystemGraphEdge `json:"edges"`
}
func BuildSystemGraph ¶
func BuildSystemGraph(reg *doctype.Registry) SystemGraphResponse
BuildSystemGraph projects the active DocType registry into a stable inspection graph. It intentionally has no second Entity schema.
type TenantExperience ¶
type TenantExperience struct {
Branding Branding `json:"branding"`
Copy ExperienceCopy `json:"copy"`
}
type UserAccessUpdate ¶
type UserAccessUpdate struct {
Roles []string `json:"roles"`
Enabled *bool `json:"enabled,omitempty"`
}
UserAccessUpdate is the request body for tenant-scoped access changes. Cloud owns account identity and organization membership; Engine owns only workspace roles and whether a provisioned principal is enabled here.
type UserDirectoryEntry ¶
type UserDirectoryEntry struct {
Name string `json:"name"`
Email string `json:"email"`
FullName string `json:"full_name"`
}
UserDirectoryEntry is the minimum tenant-scoped identity shown in user pickers. Administrative roles and account metadata are intentionally omitted.
type UserInfo ¶
type UserInfo struct {
Name string `json:"name"`
FullName string `json:"full_name"`
Email string `json:"email"`
Roles []string `json:"roles"`
}
UserInfo is the current user's public info for the UI.
type UserResponse ¶
type UserResponse struct {
Name string `json:"name"`
Email string `json:"email"`
FullName string `json:"full_name"`
Roles []string `json:"roles"`
Enabled bool `json:"enabled"`
Created string `json:"created"`
Modified string `json:"modified"`
}
UserResponse is the public representation of a user (no password_hash).
type ViewNavItem ¶
type ViewNavItem struct {
}
ViewNavItem is a configured workspace view entry in the navigation.
type WorkflowFieldCapability ¶
type WorkflowTableCapability ¶
type WorkflowTableCapability struct {
Table string `json:"table"`
StateField string `json:"state_field,omitempty"`
InitialState string `json:"initial_state,omitempty"`
AdminRole string `json:"admin_role"`
Triggers []string `json:"triggers"`
Fields []WorkflowFieldCapability `json:"fields"`
Actions []WorkflowActionCapability `json:"actions"`
ApprovalPolicies []string `json:"approval_policies"`
Transitions []WorkflowTransitionCapability `json:"transitions"`
Blockers []string `json:"blockers,omitempty"`
}
Source Files
¶
- admin_guard.go
- agents.go
- ai_runs.go
- analytics.go
- analytics_cache.go
- analytics_permissions.go
- auth_providers.go
- channel_handlers.go
- chat.go
- config_proposal.go
- config_restore_plan.go
- config_validation.go
- console.go
- doctypes_change_gate.go
- execution_context.go
- experience.go
- extension_handlers.go
- graph.go
- import_csv.go
- import_group.go
- import_handler.go
- import_links.go
- import_operation.go
- kernel_handler.go
- management_inspect.go
- management_operations.go
- module_catalog.go
- module_operations.go
- module_projections.go
- module_queries.go
- module_reconciliation.go
- module_references.go
- mpesa_handlers.go
- openapi.go
- page_manifests.go
- payments.go
- print_endpoint.go
- print_link_titles.go
- print_source.go
- provider_identity.go
- public.go
- realtime_auth.go
- realtime_connections.go
- realtime_timestamp.go
- record_history.go
- reference_validation.go
- requests_api.go
- response_dto.go
- router.go
- schema.go
- script_handlers.go
- script_provider.go
- secrets.go
- site_services.go
- site_settings.go
- system.go
- users.go
- views.go
- work_admission.go
- workflow_api.go