package platform

import (
	"github.com/sirupsen/logrus"
	"github.com/titansys/appy-builder/internal/config"
	"github.com/titansys/appy-builder/internal/models"
)

// PlatformBuilder defines the interface for platform-specific build implementations
type PlatformBuilder interface {
	// Build performs the complete build process
	Build(req models.BuildRequest) (string, error)

	// BuildWithLogs performs the complete build process and returns build logs
	BuildWithLogs(req models.BuildRequest) (string, string, error)

	// PlatformID returns the unique identifier for this platform
	PlatformID() string

	// SetAppyClient sets the Appy client for downloading keystores (supports both static and dynamic modes)
	SetAppyClient(client interface {
		DownloadKeystore(keystoreID string) ([]byte, error)
		DownloadKeystoreDynamic(keystoreID, siteURL, authKey string) ([]byte, error)
	})
}

// Builder is the main interface used by the queue processor
// (alias for backward compatibility)
type Builder = PlatformBuilder

// PlatformFactory creates a PlatformBuilder instance with runtime dependencies.
// This is called during NewRegistry() when config and logger are available.
// Platforms register their factory during init() via RegisterPlatform().
type PlatformFactory func(cfg *config.Config, logger *logrus.Logger) PlatformBuilder
