feat: 清理openspec

This commit is contained in:
npc0-hue
2026-08-20 17:58:36 +08:00
parent 49669a9d5d
commit 40b35b05c7
522 changed files with 168 additions and 19538 deletions
+15 -58
View File
@@ -1,18 +1,13 @@
package dto
import (
"strings"
"time"
"browser.local/platform/domain"
"browser.local/platform/validator"
)
type ServerDeploymentRequest struct {
RunEndpointID string `json:"runEndpointId,omitempty"`
Mode domain.ServerDeploymentMode `json:"mode"`
ProfileKey string `json:"profileKey,omitempty"`
RuntimeBindings map[string]string `json:"runtimeBindings,omitempty"`
CreateInputs map[string]string `json:"createInputs,omitempty"`
ServerRoot string `json:"serverRoot,omitempty"`
WorkingDirectory string `json:"workingDirectory,omitempty"`
@@ -27,7 +22,6 @@ type ServerDeploymentRequest struct {
type ServerDeploymentResponse struct {
ServerInstanceID string `json:"serverInstanceId"`
Mode domain.ServerDeploymentMode `json:"mode,omitempty"`
ProfileKey string `json:"profileKey,omitempty"`
CreateInputs map[string]string `json:"createInputs,omitempty"`
ServerRootConfigured bool `json:"serverRootConfigured"`
WorkingDirectoryConfigured bool `json:"workingDirectoryConfigured"`
@@ -77,45 +71,12 @@ type ServerDeploymentProjectionBody struct {
}
type ServerLifecycleCreateRequest struct {
ID string `json:"id"`
PluginID string `json:"pluginId"`
DeploymentTargetID string `json:"deploymentTargetId,omitempty"`
RunEndpointID string `json:"runEndpointId,omitempty"`
Name string `json:"name"`
OwnerUserID string `json:"ownerUserId,omitempty"`
IdempotencyKey string `json:"idempotencyKey"`
ProfileKey string `json:"profileKey"`
Bindings map[string]string `json:"bindings,omitempty"`
Deployment ServerDeploymentRequest `json:"deployment,omitempty"`
}
func (request ServerLifecycleCreateRequest) ValidateCreateOnly() error {
var violations []string
if strings.TrimSpace(request.DeploymentTargetID) != "" {
violations = append(violations, "deploymentTargetId must not be provided during server creation")
}
if strings.TrimSpace(request.RunEndpointID) != "" {
violations = append(violations, "runEndpointId must not be provided during server creation")
}
if strings.TrimSpace(request.ProfileKey) != "" {
violations = append(violations, "profileKey must not be provided during server creation")
}
if len(request.Bindings) > 0 {
violations = append(violations, "bindings must not be provided during server creation")
}
if strings.TrimSpace(request.Deployment.RunEndpointID) != "" {
violations = append(violations, "deployment.runEndpointId must not be provided during server creation")
}
if strings.TrimSpace(request.Deployment.ProfileKey) != "" {
violations = append(violations, "deployment.profileKey must not be provided during server creation")
}
if len(request.Deployment.RuntimeBindings) > 0 {
violations = append(violations, "deployment.runtimeBindings must not be provided during server creation")
}
if len(violations) > 0 {
return validator.ValidationError{Violations: violations}
}
return nil
ID string `json:"id"`
PluginID string `json:"pluginId"`
Name string `json:"name"`
OwnerUserID string `json:"ownerUserId,omitempty"`
IdempotencyKey string `json:"idempotencyKey"`
Deployment ServerDeploymentRequest `json:"deployment,omitempty"`
}
type ServerLifecycleCommandRequest struct {
@@ -132,21 +93,17 @@ type ServerLifecycleResponse struct {
func (request ServerLifecycleCreateRequest) ToDomain() domain.ServerLifecycleCreate {
return domain.ServerLifecycleCreate{
ID: request.ID,
PluginID: request.PluginID,
DeploymentTargetID: "",
RunEndpointID: "",
Name: request.Name,
OwnerUserID: request.OwnerUserID,
IdempotencyKey: request.IdempotencyKey,
ProfileKey: "",
Bindings: nil,
Deployment: request.Deployment.deploymentDefinition(),
ID: request.ID,
PluginID: request.PluginID,
Name: request.Name,
OwnerUserID: request.OwnerUserID,
IdempotencyKey: request.IdempotencyKey,
Deployment: request.Deployment.deploymentDefinition(),
}
}
func (request ServerDeploymentRequest) ToDomain() domain.ServerDeploymentUpdate {
update := domain.ServerDeploymentUpdate{RunEndpointID: request.RunEndpointID, Mode: request.Mode, ProfileKey: request.ProfileKey, RuntimeBindings: domain.CopyStringMap(request.RuntimeBindings), CreateInputs: domain.CopyStringMap(request.CreateInputs), ServerRoot: request.ServerRoot, WorkingDirectory: request.WorkingDirectory, InstallCommand: request.InstallCommand, StartCommand: request.StartCommand, StopCommand: request.StopCommand, StatusCommand: request.StatusCommand, ClearFields: domain.CopyStringSlice(request.ClearFields)}
update := domain.ServerDeploymentUpdate{Mode: request.Mode, CreateInputs: domain.CopyStringMap(request.CreateInputs), ServerRoot: request.ServerRoot, WorkingDirectory: request.WorkingDirectory, InstallCommand: request.InstallCommand, StartCommand: request.StartCommand, StopCommand: request.StopCommand, StatusCommand: request.StatusCommand, ClearFields: domain.CopyStringSlice(request.ClearFields)}
if request.Shell != nil {
update.Shell, update.ShellSet = *request.Shell, true
}
@@ -155,11 +112,11 @@ func (request ServerDeploymentRequest) ToDomain() domain.ServerDeploymentUpdate
func (request ServerDeploymentRequest) deploymentDefinition() domain.ServerDeploymentDefinition {
update := request.ToDomain()
return domain.ServerDeploymentDefinition{Mode: update.Mode, ProfileKey: update.ProfileKey, RuntimeBindings: update.RuntimeBindings, CreateInputs: update.CreateInputs, ServerRoot: update.ServerRoot, WorkingDirectory: update.WorkingDirectory, InstallCommand: update.InstallCommand, StartCommand: update.StartCommand, StopCommand: update.StopCommand, StatusCommand: update.StatusCommand, Shell: update.Shell}
return domain.ServerDeploymentDefinition{Mode: update.Mode, CreateInputs: update.CreateInputs, ServerRoot: update.ServerRoot, WorkingDirectory: update.WorkingDirectory, InstallCommand: update.InstallCommand, StartCommand: update.StartCommand, StopCommand: update.StopCommand, StatusCommand: update.StatusCommand, Shell: update.Shell}
}
func ServerDeploymentFromDomain(view domain.ServerDeploymentView) ServerDeploymentResponse {
return ServerDeploymentResponse{ServerInstanceID: view.ServerInstanceID, Mode: view.Mode, ProfileKey: view.ProfileKey, CreateInputs: domain.CopyStringMap(view.CreateInputs), ServerRootConfigured: view.ServerRootConfigured, WorkingDirectoryConfigured: view.WorkingDirectoryConfigured, InstallCommandConfigured: view.InstallCommandConfigured, StartCommandConfigured: view.StartCommandConfigured, StopCommandConfigured: view.StopCommandConfigured, StatusCommandConfigured: view.StatusCommandConfigured, Shell: view.Shell, Revision: view.Revision, UpdatedAt: optionalTime(view.UpdatedAt), Projection: deploymentProjectionFromDomain(view.Projection), LatestDispatch: deploymentDispatchEvidenceFromDomain(view.LatestDispatch)}
return ServerDeploymentResponse{ServerInstanceID: view.ServerInstanceID, Mode: view.Mode, CreateInputs: domain.CopyStringMap(view.CreateInputs), ServerRootConfigured: view.ServerRootConfigured, WorkingDirectoryConfigured: view.WorkingDirectoryConfigured, InstallCommandConfigured: view.InstallCommandConfigured, StartCommandConfigured: view.StartCommandConfigured, StopCommandConfigured: view.StopCommandConfigured, StatusCommandConfigured: view.StatusCommandConfigured, Shell: view.Shell, Revision: view.Revision, UpdatedAt: optionalTime(view.UpdatedAt), Projection: deploymentProjectionFromDomain(view.Projection), LatestDispatch: deploymentDispatchEvidenceFromDomain(view.LatestDispatch)}
}
func ServerDeploymentRevealFromDomain(reveal domain.ServerDeploymentReveal) ServerDeploymentRevealResponse {