1036 lines
47 KiB
Go
1036 lines
47 KiB
Go
package model
|
|
|
|
import (
|
|
"time"
|
|
|
|
"browser.local/platform/domain"
|
|
)
|
|
|
|
type User struct {
|
|
// ID is the stable platform user identifier.
|
|
ID string `json:"id" db:"id"`
|
|
// DisplayName is the user-visible account name.
|
|
DisplayName string `json:"displayName" db:"display_name"`
|
|
// Email is the optional login email.
|
|
Email string `json:"email,omitempty" db:"email"`
|
|
// Status is the user lifecycle status.
|
|
Status domain.UserStatus `json:"status" db:"status"`
|
|
// Roles stores assigned role keys.
|
|
Roles []string `json:"roles" db:"roles"`
|
|
// PasswordHash stores a platform-owned password verifier.
|
|
PasswordHash string `json:"passwordHash" db:"password_hash"`
|
|
// Profile stores bounded user contact metadata.
|
|
Profile domain.UserProfile `json:"profile" db:"profile"`
|
|
// Theme stores the user's persisted console theme preference.
|
|
Theme domain.UserThemePreference `json:"theme" db:"theme"`
|
|
// CreatedAt is the record creation timestamp.
|
|
CreatedAt time.Time `json:"createdAt" db:"created_at"`
|
|
// UpdatedAt is the last update timestamp.
|
|
UpdatedAt time.Time `json:"updatedAt" db:"updated_at"`
|
|
}
|
|
|
|
func (User) TableName() string { return "users" }
|
|
|
|
type AuthSession struct {
|
|
// ID is a non-secret stable session record identifier.
|
|
ID string `json:"id" db:"id"`
|
|
// UserID owns the authenticated session.
|
|
UserID string `json:"userId" db:"user_id"`
|
|
// TokenHash is a one-way verifier; the bearer token is never persisted.
|
|
TokenHash string `json:"tokenHash" db:"token_hash"`
|
|
// Status tracks active or revoked lifecycle state.
|
|
Status domain.AuthSessionStatus `json:"status" db:"status"`
|
|
// Generation increments when a user rotates a session.
|
|
Generation int `json:"generation" db:"generation"`
|
|
IssuedAt time.Time `json:"issuedAt" db:"issued_at"`
|
|
ExpiresAt time.Time `json:"expiresAt" db:"expires_at"`
|
|
LastSeenAt time.Time `json:"lastSeenAt" db:"last_seen_at"`
|
|
RevokedAt time.Time `json:"revokedAt,omitempty" db:"revoked_at"`
|
|
}
|
|
|
|
func (AuthSession) TableName() string { return "auth_sessions" }
|
|
|
|
type RunControlSession struct {
|
|
// RunEndpointID is both the endpoint owner and stable session record ID.
|
|
RunEndpointID string `json:"runEndpointId" db:"run_endpoint_id"`
|
|
// SessionTokenHash is a one-way verifier; raw Run tokens are never persisted.
|
|
SessionTokenHash string `json:"sessionTokenHash" db:"session_token_hash"`
|
|
Status domain.AuthSessionStatus `json:"status" db:"status"`
|
|
Generation int `json:"generation" db:"generation"`
|
|
CapabilityFingerprint string `json:"capabilityFingerprint" db:"capability_fingerprint"`
|
|
HeartbeatIntervalSeconds int `json:"heartbeatIntervalSeconds" db:"heartbeat_interval_seconds"`
|
|
CreatedAt time.Time `json:"createdAt" db:"created_at"`
|
|
UpdatedAt time.Time `json:"updatedAt" db:"updated_at"`
|
|
ExpiresAt time.Time `json:"expiresAt" db:"expires_at"`
|
|
RevokedAt time.Time `json:"revokedAt,omitempty" db:"revoked_at"`
|
|
RequireSignedRequests bool `json:"requireSignedRequests" db:"require_signed_requests"`
|
|
UsedNonces []string `json:"usedNonces,omitempty" db:"used_nonces"`
|
|
}
|
|
|
|
func (RunControlSession) TableName() string { return "run_control_sessions" }
|
|
|
|
type AIProvider struct {
|
|
// ID is the stable AI provider identifier.
|
|
ID string `json:"id" db:"id"`
|
|
// Name is the display name shown to operators.
|
|
Name string `json:"name" db:"name"`
|
|
// Kind identifies the provider protocol family.
|
|
Kind domain.AIProviderKind `json:"kind" db:"kind"`
|
|
// BaseURL is the provider or relay endpoint.
|
|
BaseURL string `json:"baseUrl" db:"base_url"`
|
|
// APIKeyRef references secret storage and never stores raw key material.
|
|
APIKeyRef string `json:"apiKeyRef" db:"api_key_ref"`
|
|
// Models lists allowed model identifiers.
|
|
Models []string `json:"models" db:"models"`
|
|
// DefaultModel is the optional default model identifier.
|
|
DefaultModel string `json:"defaultModel,omitempty" db:"default_model"`
|
|
// RelayMode controls direct, relay, or local routing.
|
|
RelayMode domain.AIRelayMode `json:"relayMode" db:"relay_mode"`
|
|
// TimeoutMS is the provider request timeout in milliseconds.
|
|
TimeoutMS int `json:"timeoutMs" db:"timeout_ms"`
|
|
// Status is the provider lifecycle status.
|
|
Status domain.AIProviderStatus `json:"status" db:"status"`
|
|
// RedactionPolicy identifies prompt/input/output redaction behavior.
|
|
RedactionPolicy string `json:"redactionPolicy" db:"redaction_policy"`
|
|
}
|
|
|
|
func (AIProvider) TableName() string { return "ai_providers" }
|
|
|
|
type PluginPermissions struct {
|
|
// AI allows platform-mediated AI requests.
|
|
AI bool `json:"ai" db:"ai"`
|
|
// Logs allows scoped log queries.
|
|
Logs bool `json:"logs" db:"logs"`
|
|
// Files allows scoped file/artifact operations.
|
|
Files bool `json:"files" db:"files"`
|
|
// Jobs allows lifecycle job dispatch.
|
|
Jobs bool `json:"jobs" db:"jobs"`
|
|
// Artifacts allows artifact metadata and transfer references.
|
|
Artifacts bool `json:"artifacts" db:"artifacts"`
|
|
// RemoteAccess allows platform-mediated remote server operations.
|
|
RemoteAccess bool `json:"remoteAccess" db:"remote_access"`
|
|
}
|
|
|
|
type GamePluginRemoteAccess struct {
|
|
// Methods lists declared remote access transports such as ftp, rsync, or run.
|
|
Methods []string `json:"methods" db:"methods"`
|
|
// RunCapabilities lists remote run job capabilities enabled by the plugin.
|
|
RunCapabilities []string `json:"runCapabilities" db:"run_capabilities"`
|
|
// DatabaseEngines lists database engines supported through run-mediated reads.
|
|
DatabaseEngines []string `json:"databaseEngines" db:"database_engines"`
|
|
// RCON indicates that platform-mediated RCON commands are supported.
|
|
RCON bool `json:"rcon" db:"rcon"`
|
|
// LogTransfer indicates that run-mediated log transfer is supported.
|
|
LogTransfer bool `json:"logTransfer" db:"log_transfer"`
|
|
}
|
|
|
|
type PluginLifecycleActions struct {
|
|
// Install references the install action contract.
|
|
Install string `json:"install" db:"install"`
|
|
// Start references the start action contract.
|
|
Start string `json:"start" db:"start"`
|
|
// Stop references the stop action contract.
|
|
Stop string `json:"stop" db:"stop"`
|
|
// Restart references the optional restart action contract.
|
|
Restart string `json:"restart,omitempty" db:"restart"`
|
|
// Status references the optional status action contract.
|
|
Status string `json:"status,omitempty" db:"status"`
|
|
}
|
|
|
|
type GamePluginPage struct {
|
|
// Key is stable within the plugin manifest.
|
|
Key string `json:"key" db:"key"`
|
|
// Title is the page label shown by platform clients.
|
|
Title string `json:"title" db:"title"`
|
|
// Path is the plugin-local page route.
|
|
Path string `json:"path" db:"path"`
|
|
// Permissions lists scoped platform bridge permissions required by the page.
|
|
Permissions []string `json:"permissions" db:"permissions"`
|
|
}
|
|
|
|
type GamePlugin struct {
|
|
// ID is the installed game management plugin identifier.
|
|
ID string `json:"id" db:"id"`
|
|
// Name is the plugin display name.
|
|
Name string `json:"name" db:"name"`
|
|
// Description is bounded marketplace metadata from the manifest.
|
|
Description string `json:"description,omitempty" db:"description"`
|
|
// Version is the installed plugin version.
|
|
Version string `json:"version" db:"version"`
|
|
// ServerType is the game/server type key this plugin manages.
|
|
ServerType string `json:"serverType" db:"server_type"`
|
|
// ServerDisplayName is the user-visible server type name.
|
|
ServerDisplayName string `json:"serverDisplayName,omitempty" db:"server_display_name"`
|
|
// SupportedOS lists run operating systems declared by the plugin.
|
|
SupportedOS []string `json:"supportedOs" db:"supported_os"`
|
|
// ManifestRef points to the immutable manifest artifact.
|
|
ManifestRef string `json:"manifestRef" db:"manifest_ref"`
|
|
// CreateFormSchemaRef points to the create form schema artifact.
|
|
CreateFormSchemaRef string `json:"createFormSchemaRef" db:"create_form_schema_ref"`
|
|
// RequiredRunCapabilities lists run capabilities needed by this plugin.
|
|
RequiredRunCapabilities []string `json:"requiredRunCapabilities" db:"required_run_capabilities"`
|
|
// DeclaredPermissions lists scoped manifest permission keys.
|
|
DeclaredPermissions []string `json:"declaredPermissions" db:"declared_permissions"`
|
|
// Permissions declares platform-mediated plugin abilities.
|
|
Permissions PluginPermissions `json:"permissions" db:"permissions"`
|
|
// LifecycleActions stores manifest lifecycle action references.
|
|
LifecycleActions PluginLifecycleActions `json:"lifecycleActions" db:"lifecycle_actions"`
|
|
// LifecycleAssets stores plugin-owned lifecycle files packaged into generated Run workspaces.
|
|
LifecycleAssets []domain.PluginAssetFile `json:"lifecycleAssets,omitempty" db:"lifecycle_assets"`
|
|
// Pages stores plugin-local page metadata.
|
|
Pages []GamePluginPage `json:"pages" db:"pages"`
|
|
// Tags stores bounded catalog tags.
|
|
Tags []string `json:"tags" db:"tags"`
|
|
// AIPurposes stores platform-mediated AI usage purposes.
|
|
AIPurposes []string `json:"aiPurposes" db:"ai_purposes"`
|
|
// ProductionLifecycle stores declared server-bound plugin lifecycle governance.
|
|
ProductionLifecycle domain.GamePluginProductionLifecycle `json:"productionLifecycle" db:"production_lifecycle"`
|
|
// RemoteAccess stores plugin-declared remote access metadata.
|
|
RemoteAccess GamePluginRemoteAccess `json:"remoteAccess" db:"remote_access"`
|
|
// RuntimeProfiles stores validated manifest-declared runtime contracts.
|
|
RuntimeProfiles domain.GamePluginRuntimeProfiles `json:"runtimeProfiles" db:"runtime_profiles"`
|
|
// ValidationViolations stores safe validation findings for invalid plugins.
|
|
ValidationViolations []string `json:"validationViolations" db:"validation_violations"`
|
|
// Status is the plugin lifecycle status.
|
|
Status domain.GamePluginStatus `json:"status" db:"status"`
|
|
}
|
|
|
|
func (GamePlugin) TableName() string { return "game_plugins" }
|
|
|
|
type ServerInstance struct {
|
|
// ID is the stable server instance identifier.
|
|
ID string `json:"id" db:"id"`
|
|
// PluginID references the installed game management plugin.
|
|
PluginID string `json:"pluginId" db:"plugin_id"`
|
|
// PluginVersion records the plugin version used for creation or reconcile.
|
|
PluginVersion string `json:"pluginVersion" db:"plugin_version"`
|
|
// DeploymentTargetID references an optional post-creation deployment target;
|
|
// platform-owned distribution builds never use it as a builder selector.
|
|
DeploymentTargetID string `json:"deploymentTargetId,omitempty" db:"deployment_target_id"`
|
|
// RunEndpointID references the dedicated server Run endpoint.
|
|
RunEndpointID string `json:"runEndpointId" db:"run_endpoint_id"`
|
|
// Name is the server display name.
|
|
Name string `json:"name" db:"name"`
|
|
// OwnerUserID identifies the server owner account.
|
|
OwnerUserID string `json:"ownerUserId" db:"owner_user_id"`
|
|
// AdminUserIDs identifies server-scoped administrator accounts.
|
|
AdminUserIDs []string `json:"adminUserIds" db:"admin_user_ids"`
|
|
// State is the server lifecycle state.
|
|
State domain.ServerInstanceState `json:"state" db:"state"`
|
|
// ConfigVersion is the platform-managed optimistic concurrency version.
|
|
ConfigVersion int `json:"configVersion" db:"config_version"`
|
|
// ConfigKey is the logical configuration target, never a host path.
|
|
ConfigKey string `json:"configKey,omitempty" db:"config_key"`
|
|
// ConfigContent is the last platform-approved bounded configuration body.
|
|
ConfigContent string `json:"configContent,omitempty" db:"config_content"`
|
|
// ConfigChecksum is the SHA-256 checksum of ConfigContent.
|
|
ConfigChecksum string `json:"configChecksum,omitempty" db:"config_checksum"`
|
|
// ConfigUpdatedAt records the last accepted config execution result.
|
|
ConfigUpdatedAt time.Time `json:"configUpdatedAt,omitempty" db:"config_updated_at"`
|
|
// CreatedAt is the record creation timestamp.
|
|
CreatedAt time.Time `json:"createdAt" db:"created_at"`
|
|
// UpdatedAt is the last update timestamp.
|
|
UpdatedAt time.Time `json:"updatedAt" db:"updated_at"`
|
|
}
|
|
|
|
func (ServerInstance) TableName() string { return "server_instances" }
|
|
|
|
type RunCapacity struct {
|
|
// MaxJobs is the advertised job concurrency.
|
|
MaxJobs int `json:"maxJobs" db:"max_jobs"`
|
|
// RunningJobs is the current running job count.
|
|
RunningJobs int `json:"runningJobs" db:"running_jobs"`
|
|
// QueuedJobs is the current queued job count.
|
|
QueuedJobs int `json:"queuedJobs" db:"queued_jobs"`
|
|
// Summary is a bounded human-readable capacity summary.
|
|
Summary string `json:"summary,omitempty" db:"summary"`
|
|
}
|
|
|
|
type RunEndpoint struct {
|
|
// ID is the stable run endpoint identifier.
|
|
ID string `json:"id" db:"id"`
|
|
// DisplayName is the visible executor name.
|
|
DisplayName string `json:"displayName" db:"display_name"`
|
|
// Version is the run binary version.
|
|
Version string `json:"version" db:"version"`
|
|
// Platform is the endpoint operating system.
|
|
Platform string `json:"platform" db:"platform"`
|
|
// Architecture is the endpoint CPU architecture.
|
|
Architecture string `json:"architecture" db:"architecture"`
|
|
// Status is the current endpoint status.
|
|
Status domain.RunEndpointStatus `json:"status" db:"status"`
|
|
// Capabilities lists advertised run capability keys.
|
|
Capabilities []string `json:"capabilities" db:"capabilities"`
|
|
// Capacity stores current queue and resource summary.
|
|
Capacity RunCapacity `json:"capacity" db:"capacity"`
|
|
// LastHeartbeatAt is the latest control heartbeat timestamp.
|
|
LastHeartbeatAt time.Time `json:"lastHeartbeatAt" db:"last_heartbeat_at"`
|
|
}
|
|
|
|
func (RunEndpoint) TableName() string { return "run_endpoints" }
|
|
|
|
type JobProgress struct {
|
|
// Percent is bounded from 0 to 100.
|
|
Percent int `json:"percent" db:"percent"`
|
|
// Message is a bounded progress summary.
|
|
Message string `json:"message,omitempty" db:"message"`
|
|
}
|
|
|
|
type JobRetryPolicy struct {
|
|
// MaxAttempts bounds total claims, including the first attempt.
|
|
MaxAttempts int `json:"maxAttempts" db:"max_attempts"`
|
|
// InitialBackoffSeconds is the first retry delay.
|
|
InitialBackoffSeconds int `json:"initialBackoffSeconds" db:"initial_backoff_seconds"`
|
|
// MaxBackoffSeconds caps exponential retry delay.
|
|
MaxBackoffSeconds int `json:"maxBackoffSeconds" db:"max_backoff_seconds"`
|
|
}
|
|
|
|
type JobExecutionInput struct {
|
|
WorkspaceScope string `json:"workspaceScope,omitempty" db:"workspace_scope"`
|
|
Content string `json:"content,omitempty" db:"content"`
|
|
ExpectedVersion int `json:"expectedVersion,omitempty" db:"expected_version"`
|
|
ExpectedChecksum string `json:"expectedChecksum,omitempty" db:"expected_checksum"`
|
|
MaxReadBytes int `json:"maxReadBytes,omitempty" db:"max_read_bytes"`
|
|
RemoteAdapterKey string `json:"remoteAdapterKey,omitempty" db:"remote_adapter_key"`
|
|
RemoteAdapterKind string `json:"remoteAdapterKind,omitempty" db:"remote_adapter_kind"`
|
|
TimeoutSeconds int `json:"timeoutSeconds,omitempty" db:"timeout_seconds"`
|
|
PluginID string `json:"pluginId,omitempty" db:"plugin_id"`
|
|
LifecycleOperation string `json:"lifecycleOperation,omitempty" db:"lifecycle_operation"`
|
|
TargetVersion string `json:"targetVersion,omitempty" db:"target_version"`
|
|
Inputs map[string]string `json:"inputs,omitempty" db:"inputs"`
|
|
// DLLExtensions is the frozen, ready-only DLL plan delivered to a scoped start job.
|
|
DLLExtensions []domain.RuntimeDLLExtensionPlan `json:"dllExtensions,omitempty" db:"dll_extensions"`
|
|
// SourceRCON is secret-free connection metadata for a one-time Run command.
|
|
SourceRCON *domain.RuntimeSourceRCONPlan `json:"sourceRcon,omitempty" db:"source_rcon"`
|
|
// Deployment is protected lifecycle execution material delivered only to Run.
|
|
Deployment *domain.ServerDeploymentDefinition `json:"deployment,omitempty" db:"deployment"`
|
|
// ServerDeploymentPlan is the legacy generic deployment-plan payload.
|
|
ServerDeploymentPlan *domain.ServerDeploymentPlan `json:"serverDeploymentPlan,omitempty" db:"server_deployment_plan"`
|
|
}
|
|
|
|
type JobExecutionResult struct {
|
|
Kind string `json:"kind,omitempty" db:"kind"`
|
|
ProcessState string `json:"processState,omitempty" db:"process_state"`
|
|
ExitClassification string `json:"exitClassification,omitempty" db:"exit_classification"`
|
|
ExitCode int `json:"exitCode,omitempty" db:"exit_code"`
|
|
Version int `json:"version,omitempty" db:"version"`
|
|
Checksum string `json:"checksum,omitempty" db:"checksum"`
|
|
SizeBytes int64 `json:"sizeBytes,omitempty" db:"size_bytes"`
|
|
AuditSummary string `json:"auditSummary,omitempty" db:"audit_summary"`
|
|
Content string `json:"content,omitempty" db:"content"`
|
|
}
|
|
|
|
type Job struct {
|
|
// ID is the stable job identifier.
|
|
ID string `json:"id" db:"id"`
|
|
// ServerInstanceID optionally references the target server.
|
|
ServerInstanceID string `json:"serverInstanceId,omitempty" db:"server_instance_id"`
|
|
// RunEndpointID references the target run endpoint.
|
|
RunEndpointID string `json:"runEndpointId" db:"run_endpoint_id"`
|
|
// Capability is the requested run capability key.
|
|
Capability string `json:"capability" db:"capability"`
|
|
// TargetKey is a logical config/file key, never a host path.
|
|
TargetKey string `json:"targetKey,omitempty" db:"target_key"`
|
|
// InputRef points to a platform-scoped write payload or artifact.
|
|
InputRef string `json:"inputRef,omitempty" db:"input_ref"`
|
|
// IdempotencyKey detects duplicate job requests per run endpoint.
|
|
IdempotencyKey string `json:"idempotencyKey" db:"idempotency_key"`
|
|
// State is the job lifecycle state.
|
|
State domain.JobState `json:"state" db:"state"`
|
|
// Progress stores bounded progress metadata.
|
|
Progress JobProgress `json:"progress" db:"progress"`
|
|
// ResultRef references the terminal result artifact or summary.
|
|
ResultRef string `json:"resultRef,omitempty" db:"result_ref"`
|
|
// ExecutionInput is private approved input delivered only to fenced Run assignments.
|
|
ExecutionInput JobExecutionInput `json:"executionInput,omitempty" db:"execution_input"`
|
|
// ExecutionResult stores typed execution evidence; private content is not user-projected.
|
|
ExecutionResult JobExecutionResult `json:"executionResult,omitempty" db:"execution_result"`
|
|
// RetryPolicy stores bounded durable retry settings.
|
|
RetryPolicy JobRetryPolicy `json:"retryPolicy" db:"retry_policy"`
|
|
// Attempt is the current monotonic per-job attempt.
|
|
Attempt int `json:"attempt" db:"attempt"`
|
|
// QueueEligibleAt is the first time queued work may be claimed.
|
|
QueueEligibleAt time.Time `json:"queueEligibleAt,omitempty" db:"queue_eligible_at"`
|
|
// NextAttemptAt is the durable retry eligibility time.
|
|
NextAttemptAt time.Time `json:"nextAttemptAt,omitempty" db:"next_attempt_at"`
|
|
// LeaseTokenHash stores a one-way verifier, never the raw lease token.
|
|
LeaseTokenHash string `json:"leaseTokenHash,omitempty" db:"lease_token_hash"`
|
|
// LeaseSessionGen fences the attempt to an authenticated Run session generation.
|
|
LeaseSessionGen int `json:"leaseSessionGeneration,omitempty" db:"lease_session_generation"`
|
|
// AckDeadlineAt bounds how long Run has to acknowledge a claim.
|
|
AckDeadlineAt time.Time `json:"ackDeadlineAt,omitempty" db:"ack_deadline_at"`
|
|
// LeaseExpiresAt bounds execution without progress or reconciliation.
|
|
LeaseExpiresAt time.Time `json:"leaseExpiresAt,omitempty" db:"lease_expires_at"`
|
|
// LastProgressSeq rejects reordered progress updates.
|
|
LastProgressSeq uint64 `json:"lastProgressSequence,omitempty" db:"last_progress_sequence"`
|
|
// CancelReason and timestamps persist cancellation intent and result.
|
|
CancelReason string `json:"cancelReason,omitempty" db:"cancel_reason"`
|
|
CancelRequestedAt time.Time `json:"cancelRequestedAt,omitempty" db:"cancel_requested_at"`
|
|
CancelCompletedAt time.Time `json:"cancelCompletedAt,omitempty" db:"cancel_completed_at"`
|
|
// TerminalAt and TerminalFingerprint make terminal replay durable and idempotent.
|
|
TerminalAt time.Time `json:"terminalAt,omitempty" db:"terminal_at"`
|
|
TerminalFingerprint string `json:"terminalFingerprint,omitempty" db:"terminal_fingerprint"`
|
|
// Reconciliation fields provide restart recovery evidence.
|
|
LastReconciledAt time.Time `json:"lastReconciledAt,omitempty" db:"last_reconciled_at"`
|
|
ReconcileCount int `json:"reconcileCount,omitempty" db:"reconcile_count"`
|
|
ReconcileOutcome string `json:"reconcileOutcome,omitempty" db:"reconcile_outcome"`
|
|
// CreatedAt is the record creation timestamp.
|
|
CreatedAt time.Time `json:"createdAt" db:"created_at"`
|
|
// UpdatedAt is the last update timestamp.
|
|
UpdatedAt time.Time `json:"updatedAt" db:"updated_at"`
|
|
}
|
|
|
|
func (Job) TableName() string { return "jobs" }
|
|
|
|
type Artifact struct {
|
|
// ID is the stable artifact identifier.
|
|
ID string `json:"id" db:"id"`
|
|
// OwnerKind identifies the owning resource class.
|
|
OwnerKind domain.ArtifactOwnerKind `json:"ownerKind" db:"owner_kind"`
|
|
// OwnerID identifies the owning resource.
|
|
OwnerID string `json:"ownerId" db:"owner_id"`
|
|
// SizeBytes stores the expected or final artifact size.
|
|
SizeBytes int64 `json:"sizeBytes" db:"size_bytes"`
|
|
// Checksum stores the final checksum.
|
|
Checksum string `json:"checksum" db:"checksum"`
|
|
// State is the artifact lifecycle state.
|
|
State domain.ArtifactState `json:"state" db:"state"`
|
|
// CreatedAt is the record creation timestamp.
|
|
CreatedAt time.Time `json:"createdAt" db:"created_at"`
|
|
// UpdatedAt is the last update timestamp.
|
|
UpdatedAt time.Time `json:"updatedAt" db:"updated_at"`
|
|
}
|
|
|
|
func (Artifact) TableName() string { return "artifacts" }
|
|
|
|
type LogStream struct {
|
|
// ID is the stable log stream identifier.
|
|
ID string `json:"id" db:"id"`
|
|
// ServerInstanceID references the target server.
|
|
ServerInstanceID string `json:"serverInstanceId" db:"server_instance_id"`
|
|
// Source identifies process, file, plugin, or custom source.
|
|
Source domain.LogStreamSource `json:"source" db:"source"`
|
|
// StreamKey is stable within the server instance.
|
|
StreamKey string `json:"streamKey" db:"stream_key"`
|
|
// LatestSeq is the latest accepted sequence number.
|
|
LatestSeq uint64 `json:"latestSeq" db:"latest_seq"`
|
|
// StorageBackend identifies the log body backend.
|
|
StorageBackend domain.LogStorageBackend `json:"storageBackend" db:"storage_backend"`
|
|
// RetentionPolicy identifies retention behavior.
|
|
RetentionPolicy string `json:"retentionPolicy" db:"retention_policy"`
|
|
// CreatedAt is the record creation timestamp.
|
|
CreatedAt time.Time `json:"createdAt" db:"created_at"`
|
|
// UpdatedAt is the last update timestamp.
|
|
UpdatedAt time.Time `json:"updatedAt" db:"updated_at"`
|
|
}
|
|
|
|
func (LogStream) TableName() string { return "log_streams" }
|
|
|
|
type AuditEvent struct {
|
|
// ID is the stable audit event identifier.
|
|
ID string `json:"id" db:"id"`
|
|
// ActorID references the user or system actor.
|
|
ActorID string `json:"actorId" db:"actor_id"`
|
|
// Action is the stable action key.
|
|
Action string `json:"action" db:"action"`
|
|
// ResourceKind identifies the audited resource type.
|
|
ResourceKind string `json:"resourceKind" db:"resource_kind"`
|
|
// ResourceID identifies the audited resource.
|
|
ResourceID string `json:"resourceId" db:"resource_id"`
|
|
// Result is the audit outcome.
|
|
Result domain.AuditResult `json:"result" db:"result"`
|
|
// Summary is a bounded redacted summary.
|
|
Summary string `json:"summary" db:"summary"`
|
|
// CreatedAt is the audit timestamp.
|
|
CreatedAt time.Time `json:"createdAt" db:"created_at"`
|
|
}
|
|
|
|
func (AuditEvent) TableName() string { return "audit_events" }
|
|
|
|
type Alert struct {
|
|
ID string `json:"id" db:"id"`
|
|
SourceKind string `json:"sourceKind" db:"source_kind"`
|
|
SourceID string `json:"sourceId" db:"source_id"`
|
|
RuleKey string `json:"ruleKey" db:"rule_key"`
|
|
Severity domain.AlertSeverity `json:"severity" db:"severity"`
|
|
State domain.AlertState `json:"state" db:"state"`
|
|
Title string `json:"title" db:"title"`
|
|
Message string `json:"message" db:"message"`
|
|
OccurrenceCount int `json:"occurrenceCount" db:"occurrence_count"`
|
|
Retryable bool `json:"retryable" db:"retryable"`
|
|
RetryAfterSeconds int `json:"retryAfterSeconds" db:"retry_after_seconds"`
|
|
LastJobID string `json:"lastJobId,omitempty" db:"last_job_id"`
|
|
LastAuditEventID string `json:"lastAuditEventId,omitempty" db:"last_audit_event_id"`
|
|
LastSeenAt time.Time `json:"lastSeenAt" db:"last_seen_at"`
|
|
AcknowledgedBy string `json:"acknowledgedBy,omitempty" db:"acknowledged_by"`
|
|
AcknowledgedAt time.Time `json:"acknowledgedAt,omitempty" db:"acknowledged_at"`
|
|
ResolvedBy string `json:"resolvedBy,omitempty" db:"resolved_by"`
|
|
ResolvedAt time.Time `json:"resolvedAt,omitempty" db:"resolved_at"`
|
|
ResolutionNote string `json:"resolutionNote,omitempty" db:"resolution_note"`
|
|
CreatedAt time.Time `json:"createdAt" db:"created_at"`
|
|
UpdatedAt time.Time `json:"updatedAt" db:"updated_at"`
|
|
}
|
|
|
|
func (Alert) TableName() string { return "alerts" }
|
|
|
|
type PluginLifecycleInstallation struct {
|
|
ID string `json:"id" db:"id"`
|
|
PluginID string `json:"pluginId" db:"plugin_id"`
|
|
ServerInstanceID string `json:"serverInstanceId" db:"server_instance_id"`
|
|
CurrentVersion string `json:"currentVersion,omitempty" db:"current_version"`
|
|
TargetVersion string `json:"targetVersion,omitempty" db:"target_version"`
|
|
PreviousVersion string `json:"previousVersion,omitempty" db:"previous_version"`
|
|
DesiredState domain.PluginLifecycleState `json:"desiredState" db:"desired_state"`
|
|
CurrentState domain.PluginLifecycleState `json:"currentState" db:"current_state"`
|
|
LastOperation domain.PluginLifecycleOperation `json:"lastOperation,omitempty" db:"last_operation"`
|
|
Compatibility string `json:"compatibility" db:"compatibility"`
|
|
DependencyState domain.DependencyState `json:"dependencyState" db:"dependency_state"`
|
|
JobID string `json:"jobId,omitempty" db:"job_id"`
|
|
AlertID string `json:"alertId,omitempty" db:"alert_id"`
|
|
AuditEventID string `json:"auditEventId,omitempty" db:"audit_event_id"`
|
|
FailureReason string `json:"failureReason,omitempty" db:"failure_reason"`
|
|
IdempotencyKey string `json:"idempotencyKey" db:"idempotency_key"`
|
|
CreatedAt time.Time `json:"createdAt" db:"created_at"`
|
|
UpdatedAt time.Time `json:"updatedAt" db:"updated_at"`
|
|
}
|
|
|
|
func (PluginLifecycleInstallation) TableName() string { return "plugin_lifecycle_installations" }
|
|
|
|
type AIConfigDiff struct {
|
|
ID string `json:"id" db:"id"`
|
|
RequestID string `json:"requestId" db:"request_id"`
|
|
CreatedBy string `json:"createdBy" db:"created_by"`
|
|
ServerInstanceID string `json:"serverInstanceId" db:"server_instance_id"`
|
|
PluginID string `json:"pluginId,omitempty" db:"plugin_id"`
|
|
ProviderID string `json:"providerId,omitempty" db:"provider_id"`
|
|
Model string `json:"model,omitempty" db:"model"`
|
|
Key string `json:"key" db:"key"`
|
|
ConfigVersion int `json:"configVersion" db:"config_version"`
|
|
CurrentConfigChecksum string `json:"currentConfigChecksum" db:"current_config_checksum"`
|
|
ProposedConfig string `json:"proposedConfig" db:"proposed_config"`
|
|
DiffSummary string `json:"diffSummary" db:"diff_summary"`
|
|
State domain.AIConfigDiffState `json:"state" db:"state"`
|
|
ExpiresAt time.Time `json:"expiresAt" db:"expires_at"`
|
|
ApprovedBy string `json:"approvedBy,omitempty" db:"approved_by"`
|
|
ApprovedAt time.Time `json:"approvedAt,omitempty" db:"approved_at"`
|
|
ApprovalIdempotencyKey string `json:"approvalIdempotencyKey,omitempty" db:"approval_idempotency_key"`
|
|
CancelledBy string `json:"cancelledBy,omitempty" db:"cancelled_by"`
|
|
CancelledAt time.Time `json:"cancelledAt,omitempty" db:"cancelled_at"`
|
|
JobID string `json:"jobId,omitempty" db:"job_id"`
|
|
CreatedAt time.Time `json:"createdAt" db:"created_at"`
|
|
UpdatedAt time.Time `json:"updatedAt" db:"updated_at"`
|
|
}
|
|
|
|
func (AIConfigDiff) TableName() string { return "ai_config_diffs" }
|
|
|
|
func UserFromDomain(user domain.User) User {
|
|
user = domain.CopyUser(user)
|
|
return User{
|
|
ID: user.ID,
|
|
DisplayName: user.DisplayName,
|
|
Email: user.Email,
|
|
Status: user.Status,
|
|
Roles: user.Roles,
|
|
PasswordHash: user.PasswordHash,
|
|
Profile: user.Profile,
|
|
Theme: user.Theme,
|
|
CreatedAt: user.CreatedAt,
|
|
UpdatedAt: user.UpdatedAt,
|
|
}
|
|
}
|
|
|
|
func (user User) ToDomain() domain.User {
|
|
return domain.User{
|
|
ID: user.ID,
|
|
DisplayName: user.DisplayName,
|
|
Email: user.Email,
|
|
Status: user.Status,
|
|
Roles: domain.CopyStringSlice(user.Roles),
|
|
PasswordHash: user.PasswordHash,
|
|
Profile: user.Profile,
|
|
Theme: user.Theme,
|
|
CreatedAt: user.CreatedAt,
|
|
UpdatedAt: user.UpdatedAt,
|
|
}
|
|
}
|
|
|
|
func AIProviderFromDomain(provider domain.AIProvider) AIProvider {
|
|
provider = domain.CopyAIProvider(provider)
|
|
return AIProvider{
|
|
ID: provider.ID,
|
|
Name: provider.Name,
|
|
Kind: provider.Kind,
|
|
BaseURL: provider.BaseURL,
|
|
APIKeyRef: provider.APIKeyRef,
|
|
Models: provider.Models,
|
|
DefaultModel: provider.DefaultModel,
|
|
RelayMode: provider.RelayMode,
|
|
TimeoutMS: provider.TimeoutMS,
|
|
Status: provider.Status,
|
|
RedactionPolicy: provider.RedactionPolicy,
|
|
}
|
|
}
|
|
|
|
func (provider AIProvider) ToDomain() domain.AIProvider {
|
|
return domain.AIProvider{
|
|
ID: provider.ID,
|
|
Name: provider.Name,
|
|
Kind: provider.Kind,
|
|
BaseURL: provider.BaseURL,
|
|
APIKeyRef: provider.APIKeyRef,
|
|
Models: domain.CopyStringSlice(provider.Models),
|
|
DefaultModel: provider.DefaultModel,
|
|
RelayMode: provider.RelayMode,
|
|
TimeoutMS: provider.TimeoutMS,
|
|
Status: provider.Status,
|
|
RedactionPolicy: provider.RedactionPolicy,
|
|
}
|
|
}
|
|
|
|
func GamePluginFromDomain(plugin domain.GamePlugin) GamePlugin {
|
|
plugin = domain.CopyGamePlugin(plugin)
|
|
return GamePlugin{
|
|
ID: plugin.ID,
|
|
Name: plugin.Name,
|
|
Description: plugin.Description,
|
|
Version: plugin.Version,
|
|
ServerType: plugin.ServerType,
|
|
ServerDisplayName: plugin.ServerDisplayName,
|
|
SupportedOS: plugin.SupportedOS,
|
|
ManifestRef: plugin.ManifestRef,
|
|
CreateFormSchemaRef: plugin.CreateFormSchemaRef,
|
|
RequiredRunCapabilities: plugin.RequiredRunCapabilities,
|
|
DeclaredPermissions: plugin.DeclaredPermissions,
|
|
Permissions: permissionsFromDomain(plugin.Permissions),
|
|
LifecycleActions: lifecycleActionsFromDomain(plugin.LifecycleActions),
|
|
LifecycleAssets: domain.CopyPluginAssetFiles(plugin.LifecycleAssets),
|
|
Pages: pagesFromDomain(plugin.Pages),
|
|
Tags: plugin.Tags,
|
|
AIPurposes: plugin.AIPurposes,
|
|
ProductionLifecycle: domain.CopyGamePluginProductionLifecycle(plugin.ProductionLifecycle),
|
|
RemoteAccess: remoteAccessFromDomain(plugin.RemoteAccess),
|
|
RuntimeProfiles: domain.CopyGamePluginRuntimeProfiles(plugin.RuntimeProfiles),
|
|
ValidationViolations: plugin.ValidationViolations,
|
|
Status: plugin.Status,
|
|
}
|
|
}
|
|
|
|
func (plugin GamePlugin) ToDomain() domain.GamePlugin {
|
|
return domain.GamePlugin{
|
|
ID: plugin.ID,
|
|
Name: plugin.Name,
|
|
Description: plugin.Description,
|
|
Version: plugin.Version,
|
|
ServerType: plugin.ServerType,
|
|
ServerDisplayName: plugin.ServerDisplayName,
|
|
SupportedOS: domain.CopyStringSlice(plugin.SupportedOS),
|
|
ManifestRef: plugin.ManifestRef,
|
|
CreateFormSchemaRef: plugin.CreateFormSchemaRef,
|
|
RequiredRunCapabilities: domain.CopyStringSlice(plugin.RequiredRunCapabilities),
|
|
DeclaredPermissions: domain.CopyStringSlice(plugin.DeclaredPermissions),
|
|
Permissions: plugin.Permissions.ToDomain(),
|
|
LifecycleActions: plugin.LifecycleActions.ToDomain(),
|
|
LifecycleAssets: domain.CopyPluginAssetFiles(plugin.LifecycleAssets),
|
|
Pages: pagesToDomain(plugin.Pages),
|
|
Tags: domain.CopyStringSlice(plugin.Tags),
|
|
AIPurposes: domain.CopyStringSlice(plugin.AIPurposes),
|
|
ProductionLifecycle: domain.CopyGamePluginProductionLifecycle(plugin.ProductionLifecycle),
|
|
RemoteAccess: plugin.RemoteAccess.ToDomain(),
|
|
RuntimeProfiles: domain.CopyGamePluginRuntimeProfiles(plugin.RuntimeProfiles),
|
|
ValidationViolations: domain.CopyStringSlice(plugin.ValidationViolations),
|
|
Status: plugin.Status,
|
|
}
|
|
}
|
|
|
|
func (actions PluginLifecycleActions) ToDomain() domain.PluginLifecycleActions {
|
|
return domain.PluginLifecycleActions{
|
|
Install: actions.Install,
|
|
Start: actions.Start,
|
|
Stop: actions.Stop,
|
|
Restart: actions.Restart,
|
|
Status: actions.Status,
|
|
}
|
|
}
|
|
|
|
func lifecycleActionsFromDomain(actions domain.PluginLifecycleActions) PluginLifecycleActions {
|
|
return PluginLifecycleActions{
|
|
Install: actions.Install,
|
|
Start: actions.Start,
|
|
Stop: actions.Stop,
|
|
Restart: actions.Restart,
|
|
Status: actions.Status,
|
|
}
|
|
}
|
|
|
|
func pagesToDomain(pages []GamePluginPage) []domain.GamePluginPage {
|
|
if pages == nil {
|
|
return nil
|
|
}
|
|
out := make([]domain.GamePluginPage, len(pages))
|
|
for i, page := range pages {
|
|
out[i] = domain.GamePluginPage{
|
|
Key: page.Key,
|
|
Title: page.Title,
|
|
Path: page.Path,
|
|
Permissions: domain.CopyStringSlice(page.Permissions),
|
|
}
|
|
}
|
|
return out
|
|
}
|
|
|
|
func pagesFromDomain(pages []domain.GamePluginPage) []GamePluginPage {
|
|
if pages == nil {
|
|
return nil
|
|
}
|
|
out := make([]GamePluginPage, len(pages))
|
|
for i, page := range pages {
|
|
out[i] = GamePluginPage{
|
|
Key: page.Key,
|
|
Title: page.Title,
|
|
Path: page.Path,
|
|
Permissions: domain.CopyStringSlice(page.Permissions),
|
|
}
|
|
}
|
|
return out
|
|
}
|
|
|
|
func (permissions PluginPermissions) ToDomain() domain.PluginPermissions {
|
|
return domain.PluginPermissions{
|
|
AI: permissions.AI,
|
|
Logs: permissions.Logs,
|
|
Files: permissions.Files,
|
|
Jobs: permissions.Jobs,
|
|
Artifacts: permissions.Artifacts,
|
|
RemoteAccess: permissions.RemoteAccess,
|
|
}
|
|
}
|
|
|
|
func permissionsFromDomain(permissions domain.PluginPermissions) PluginPermissions {
|
|
return PluginPermissions{
|
|
AI: permissions.AI,
|
|
Logs: permissions.Logs,
|
|
Files: permissions.Files,
|
|
Jobs: permissions.Jobs,
|
|
Artifacts: permissions.Artifacts,
|
|
RemoteAccess: permissions.RemoteAccess,
|
|
}
|
|
}
|
|
|
|
func (remote GamePluginRemoteAccess) ToDomain() domain.GamePluginRemoteAccess {
|
|
return domain.GamePluginRemoteAccess{
|
|
Methods: domain.CopyStringSlice(remote.Methods),
|
|
RunCapabilities: domain.CopyStringSlice(remote.RunCapabilities),
|
|
DatabaseEngines: domain.CopyStringSlice(remote.DatabaseEngines),
|
|
RCON: remote.RCON,
|
|
LogTransfer: remote.LogTransfer,
|
|
}
|
|
}
|
|
|
|
func remoteAccessFromDomain(remote domain.GamePluginRemoteAccess) GamePluginRemoteAccess {
|
|
remote = domain.CopyGamePluginRemoteAccess(remote)
|
|
return GamePluginRemoteAccess{
|
|
Methods: remote.Methods,
|
|
RunCapabilities: remote.RunCapabilities,
|
|
DatabaseEngines: remote.DatabaseEngines,
|
|
RCON: remote.RCON,
|
|
LogTransfer: remote.LogTransfer,
|
|
}
|
|
}
|
|
|
|
func ServerInstanceFromDomain(instance domain.ServerInstance) ServerInstance {
|
|
return ServerInstance{
|
|
ID: instance.ID,
|
|
PluginID: instance.PluginID,
|
|
PluginVersion: instance.PluginVersion,
|
|
DeploymentTargetID: instance.DeploymentTargetID,
|
|
RunEndpointID: instance.RunEndpointID,
|
|
Name: instance.Name,
|
|
OwnerUserID: instance.OwnerUserID,
|
|
AdminUserIDs: domain.CopyStringSlice(instance.AdminUserIDs),
|
|
State: instance.State,
|
|
ConfigVersion: instance.ConfigVersion,
|
|
ConfigKey: instance.ConfigKey,
|
|
ConfigContent: instance.ConfigContent,
|
|
ConfigChecksum: instance.ConfigChecksum,
|
|
ConfigUpdatedAt: instance.ConfigUpdatedAt,
|
|
CreatedAt: instance.CreatedAt,
|
|
UpdatedAt: instance.UpdatedAt,
|
|
}
|
|
}
|
|
|
|
func (instance ServerInstance) ToDomain() domain.ServerInstance {
|
|
return domain.ServerInstance{
|
|
ID: instance.ID,
|
|
PluginID: instance.PluginID,
|
|
PluginVersion: instance.PluginVersion,
|
|
DeploymentTargetID: instance.DeploymentTargetID,
|
|
RunEndpointID: instance.RunEndpointID,
|
|
Name: instance.Name,
|
|
OwnerUserID: instance.OwnerUserID,
|
|
AdminUserIDs: domain.CopyStringSlice(instance.AdminUserIDs),
|
|
State: instance.State,
|
|
ConfigVersion: instance.ConfigVersion,
|
|
ConfigKey: instance.ConfigKey,
|
|
ConfigContent: instance.ConfigContent,
|
|
ConfigChecksum: instance.ConfigChecksum,
|
|
ConfigUpdatedAt: instance.ConfigUpdatedAt,
|
|
CreatedAt: instance.CreatedAt,
|
|
UpdatedAt: instance.UpdatedAt,
|
|
}
|
|
}
|
|
|
|
func RunEndpointFromDomain(endpoint domain.RunEndpoint) RunEndpoint {
|
|
endpoint = domain.CopyRunEndpoint(endpoint)
|
|
return RunEndpoint{
|
|
ID: endpoint.ID,
|
|
DisplayName: endpoint.DisplayName,
|
|
Version: endpoint.Version,
|
|
Platform: endpoint.Platform,
|
|
Architecture: endpoint.Architecture,
|
|
Status: endpoint.Status,
|
|
Capabilities: endpoint.Capabilities,
|
|
Capacity: capacityFromDomain(endpoint.Capacity),
|
|
LastHeartbeatAt: endpoint.LastHeartbeatAt,
|
|
}
|
|
}
|
|
|
|
func (endpoint RunEndpoint) ToDomain() domain.RunEndpoint {
|
|
return domain.RunEndpoint{
|
|
ID: endpoint.ID,
|
|
DisplayName: endpoint.DisplayName,
|
|
Version: endpoint.Version,
|
|
Platform: endpoint.Platform,
|
|
Architecture: endpoint.Architecture,
|
|
Status: endpoint.Status,
|
|
Capabilities: domain.CopyStringSlice(endpoint.Capabilities),
|
|
Capacity: endpoint.Capacity.ToDomain(),
|
|
LastHeartbeatAt: endpoint.LastHeartbeatAt,
|
|
}
|
|
}
|
|
|
|
func (capacity RunCapacity) ToDomain() domain.RunCapacity {
|
|
return domain.RunCapacity{
|
|
MaxJobs: capacity.MaxJobs,
|
|
RunningJobs: capacity.RunningJobs,
|
|
QueuedJobs: capacity.QueuedJobs,
|
|
Summary: capacity.Summary,
|
|
}
|
|
}
|
|
|
|
func capacityFromDomain(capacity domain.RunCapacity) RunCapacity {
|
|
return RunCapacity{
|
|
MaxJobs: capacity.MaxJobs,
|
|
RunningJobs: capacity.RunningJobs,
|
|
QueuedJobs: capacity.QueuedJobs,
|
|
Summary: capacity.Summary,
|
|
}
|
|
}
|
|
|
|
func JobFromDomain(job domain.Job) Job {
|
|
return Job{
|
|
ID: job.ID,
|
|
ServerInstanceID: job.ServerInstanceID,
|
|
RunEndpointID: job.RunEndpointID,
|
|
Capability: job.Capability,
|
|
TargetKey: job.TargetKey,
|
|
InputRef: job.InputRef,
|
|
IdempotencyKey: job.IdempotencyKey,
|
|
State: job.State,
|
|
Progress: progressFromDomain(job.Progress),
|
|
ResultRef: job.ResultRef,
|
|
ExecutionInput: executionInputFromDomain(job.ExecutionInput),
|
|
ExecutionResult: executionResultFromDomain(job.ExecutionResult),
|
|
RetryPolicy: retryPolicyFromDomain(job.RetryPolicy),
|
|
Attempt: job.Attempt,
|
|
QueueEligibleAt: job.QueueEligibleAt,
|
|
NextAttemptAt: job.NextAttemptAt,
|
|
LeaseTokenHash: job.LeaseTokenHash,
|
|
LeaseSessionGen: job.LeaseSessionGen,
|
|
AckDeadlineAt: job.AckDeadlineAt,
|
|
LeaseExpiresAt: job.LeaseExpiresAt,
|
|
LastProgressSeq: job.LastProgressSeq,
|
|
CancelReason: job.CancelReason,
|
|
CancelRequestedAt: job.CancelRequestedAt,
|
|
CancelCompletedAt: job.CancelCompletedAt,
|
|
TerminalAt: job.TerminalAt,
|
|
TerminalFingerprint: job.TerminalFingerprint,
|
|
LastReconciledAt: job.LastReconciledAt,
|
|
ReconcileCount: job.ReconcileCount,
|
|
ReconcileOutcome: job.ReconcileOutcome,
|
|
CreatedAt: job.CreatedAt,
|
|
UpdatedAt: job.UpdatedAt,
|
|
}
|
|
}
|
|
|
|
func (job Job) ToDomain() domain.Job {
|
|
return domain.Job{
|
|
ID: job.ID,
|
|
ServerInstanceID: job.ServerInstanceID,
|
|
RunEndpointID: job.RunEndpointID,
|
|
Capability: job.Capability,
|
|
TargetKey: job.TargetKey,
|
|
InputRef: job.InputRef,
|
|
IdempotencyKey: job.IdempotencyKey,
|
|
State: job.State,
|
|
Progress: job.Progress.ToDomain(),
|
|
ResultRef: job.ResultRef,
|
|
ExecutionInput: job.ExecutionInput.ToDomain(),
|
|
ExecutionResult: job.ExecutionResult.ToDomain(),
|
|
RetryPolicy: job.RetryPolicy.ToDomain(),
|
|
Attempt: job.Attempt,
|
|
QueueEligibleAt: job.QueueEligibleAt,
|
|
NextAttemptAt: job.NextAttemptAt,
|
|
LeaseTokenHash: job.LeaseTokenHash,
|
|
LeaseSessionGen: job.LeaseSessionGen,
|
|
AckDeadlineAt: job.AckDeadlineAt,
|
|
LeaseExpiresAt: job.LeaseExpiresAt,
|
|
LastProgressSeq: job.LastProgressSeq,
|
|
CancelReason: job.CancelReason,
|
|
CancelRequestedAt: job.CancelRequestedAt,
|
|
CancelCompletedAt: job.CancelCompletedAt,
|
|
TerminalAt: job.TerminalAt,
|
|
TerminalFingerprint: job.TerminalFingerprint,
|
|
LastReconciledAt: job.LastReconciledAt,
|
|
ReconcileCount: job.ReconcileCount,
|
|
ReconcileOutcome: job.ReconcileOutcome,
|
|
CreatedAt: job.CreatedAt,
|
|
UpdatedAt: job.UpdatedAt,
|
|
}
|
|
}
|
|
|
|
func executionInputFromDomain(input domain.JobExecutionInput) JobExecutionInput {
|
|
var deployment *domain.ServerDeploymentDefinition
|
|
if input.Deployment != nil {
|
|
copy := domain.CopyServerDeploymentDefinition(*input.Deployment)
|
|
deployment = ©
|
|
}
|
|
return JobExecutionInput{WorkspaceScope: input.WorkspaceScope, Content: input.Content, ExpectedVersion: input.ExpectedVersion, ExpectedChecksum: input.ExpectedChecksum, MaxReadBytes: input.MaxReadBytes, RemoteAdapterKey: input.RemoteAdapterKey, RemoteAdapterKind: input.RemoteAdapterKind, TimeoutSeconds: input.TimeoutSeconds, PluginID: input.PluginID, LifecycleOperation: input.LifecycleOperation, TargetVersion: input.TargetVersion, Inputs: domain.CopyStringMap(input.Inputs), DLLExtensions: append([]domain.RuntimeDLLExtensionPlan(nil), input.DLLExtensions...), SourceRCON: domain.CopyRuntimeSourceRCONPlan(input.SourceRCON), Deployment: deployment, ServerDeploymentPlan: domain.CopyServerDeploymentPlan(input.ServerDeploymentPlan)}
|
|
}
|
|
|
|
func (input JobExecutionInput) ToDomain() domain.JobExecutionInput {
|
|
var deployment *domain.ServerDeploymentDefinition
|
|
if input.Deployment != nil {
|
|
copy := domain.CopyServerDeploymentDefinition(*input.Deployment)
|
|
deployment = ©
|
|
}
|
|
return domain.JobExecutionInput{WorkspaceScope: input.WorkspaceScope, Content: input.Content, ExpectedVersion: input.ExpectedVersion, ExpectedChecksum: input.ExpectedChecksum, MaxReadBytes: input.MaxReadBytes, RemoteAdapterKey: input.RemoteAdapterKey, RemoteAdapterKind: input.RemoteAdapterKind, TimeoutSeconds: input.TimeoutSeconds, PluginID: input.PluginID, LifecycleOperation: input.LifecycleOperation, TargetVersion: input.TargetVersion, Inputs: domain.CopyStringMap(input.Inputs), DLLExtensions: append([]domain.RuntimeDLLExtensionPlan(nil), input.DLLExtensions...), SourceRCON: domain.CopyRuntimeSourceRCONPlan(input.SourceRCON), Deployment: deployment, ServerDeploymentPlan: domain.CopyServerDeploymentPlan(input.ServerDeploymentPlan)}
|
|
}
|
|
|
|
func executionResultFromDomain(result domain.JobExecutionResult) JobExecutionResult {
|
|
return JobExecutionResult{Kind: result.Kind, ProcessState: result.ProcessState, ExitClassification: result.ExitClassification, ExitCode: result.ExitCode, Version: result.Version, Checksum: result.Checksum, SizeBytes: result.SizeBytes, AuditSummary: result.AuditSummary, Content: result.Content}
|
|
}
|
|
|
|
func (result JobExecutionResult) ToDomain() domain.JobExecutionResult {
|
|
return domain.JobExecutionResult{Kind: result.Kind, ProcessState: result.ProcessState, ExitClassification: result.ExitClassification, ExitCode: result.ExitCode, Version: result.Version, Checksum: result.Checksum, SizeBytes: result.SizeBytes, AuditSummary: result.AuditSummary, Content: result.Content}
|
|
}
|
|
|
|
func (policy JobRetryPolicy) ToDomain() domain.JobRetryPolicy {
|
|
return domain.JobRetryPolicy{
|
|
MaxAttempts: policy.MaxAttempts,
|
|
InitialBackoffSeconds: policy.InitialBackoffSeconds,
|
|
MaxBackoffSeconds: policy.MaxBackoffSeconds,
|
|
}
|
|
}
|
|
|
|
func retryPolicyFromDomain(policy domain.JobRetryPolicy) JobRetryPolicy {
|
|
return JobRetryPolicy{
|
|
MaxAttempts: policy.MaxAttempts,
|
|
InitialBackoffSeconds: policy.InitialBackoffSeconds,
|
|
MaxBackoffSeconds: policy.MaxBackoffSeconds,
|
|
}
|
|
}
|
|
|
|
func (progress JobProgress) ToDomain() domain.JobProgress {
|
|
return domain.JobProgress{
|
|
Percent: progress.Percent,
|
|
Message: progress.Message,
|
|
}
|
|
}
|
|
|
|
func progressFromDomain(progress domain.JobProgress) JobProgress {
|
|
return JobProgress{
|
|
Percent: progress.Percent,
|
|
Message: progress.Message,
|
|
}
|
|
}
|
|
|
|
func ArtifactFromDomain(artifact domain.Artifact) Artifact {
|
|
return Artifact{
|
|
ID: artifact.ID,
|
|
OwnerKind: artifact.OwnerKind,
|
|
OwnerID: artifact.OwnerID,
|
|
SizeBytes: artifact.SizeBytes,
|
|
Checksum: artifact.Checksum,
|
|
State: artifact.State,
|
|
CreatedAt: artifact.CreatedAt,
|
|
UpdatedAt: artifact.UpdatedAt,
|
|
}
|
|
}
|
|
|
|
func (artifact Artifact) ToDomain() domain.Artifact {
|
|
return domain.Artifact{
|
|
ID: artifact.ID,
|
|
OwnerKind: artifact.OwnerKind,
|
|
OwnerID: artifact.OwnerID,
|
|
SizeBytes: artifact.SizeBytes,
|
|
Checksum: artifact.Checksum,
|
|
State: artifact.State,
|
|
CreatedAt: artifact.CreatedAt,
|
|
UpdatedAt: artifact.UpdatedAt,
|
|
}
|
|
}
|
|
|
|
func LogStreamFromDomain(stream domain.LogStream) LogStream {
|
|
return LogStream{
|
|
ID: stream.ID,
|
|
ServerInstanceID: stream.ServerInstanceID,
|
|
Source: stream.Source,
|
|
StreamKey: stream.StreamKey,
|
|
LatestSeq: stream.LatestSeq,
|
|
StorageBackend: stream.StorageBackend,
|
|
RetentionPolicy: stream.RetentionPolicy,
|
|
CreatedAt: stream.CreatedAt,
|
|
UpdatedAt: stream.UpdatedAt,
|
|
}
|
|
}
|
|
|
|
func (stream LogStream) ToDomain() domain.LogStream {
|
|
return domain.LogStream{
|
|
ID: stream.ID,
|
|
ServerInstanceID: stream.ServerInstanceID,
|
|
Source: stream.Source,
|
|
StreamKey: stream.StreamKey,
|
|
LatestSeq: stream.LatestSeq,
|
|
StorageBackend: stream.StorageBackend,
|
|
RetentionPolicy: stream.RetentionPolicy,
|
|
CreatedAt: stream.CreatedAt,
|
|
UpdatedAt: stream.UpdatedAt,
|
|
}
|
|
}
|
|
|
|
func AuditEventFromDomain(event domain.AuditEvent) AuditEvent {
|
|
return AuditEvent{
|
|
ID: event.ID,
|
|
ActorID: event.ActorID,
|
|
Action: event.Action,
|
|
ResourceKind: event.ResourceKind,
|
|
ResourceID: event.ResourceID,
|
|
Result: event.Result,
|
|
Summary: event.Summary,
|
|
CreatedAt: event.CreatedAt,
|
|
}
|
|
}
|
|
|
|
func (event AuditEvent) ToDomain() domain.AuditEvent {
|
|
return domain.AuditEvent{
|
|
ID: event.ID,
|
|
ActorID: event.ActorID,
|
|
Action: event.Action,
|
|
ResourceKind: event.ResourceKind,
|
|
ResourceID: event.ResourceID,
|
|
Result: event.Result,
|
|
Summary: event.Summary,
|
|
CreatedAt: event.CreatedAt,
|
|
}
|
|
}
|