app

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 13, 2026 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEntityNotFound    = errors.New("entity not found")
	ErrEntityTypeInvalid = errors.New("entity type is not declared by the Pack")
	ErrEntityIDInvalid   = errors.New("entity ID is invalid")
	ErrEntityIDImmutable = errors.New("entity ID is immutable")
	ErrEntityExists      = errors.New("entity already exists")
)
View Source
var (
	ErrConfirmationInvalid = errors.New("release confirmation is invalid")
	ErrIdempotencyRequired = errors.New("idempotency key is required")
)
View Source
var (
	ErrRollbackPreviewInvalid = errors.New("rollback preview is invalid")
	ErrReleaseNotFound        = errors.New("release not found")
	ErrDefaultsFormat         = errors.New("defaults format is invalid")
)
View Source
var (
	ErrLastEnvironment          = errors.New("cannot delete the last environment")
	ErrPackRegistryUnavailable  = errors.New("pack registry is unavailable")
	ErrProviderProjectIDMissing = errors.New("先在环境管理中填写 Firebase 项目 ID")
)
View Source
var ErrRemoteSnapshotUnavailable = errors.New("remote snapshot unavailable")

Functions

func Initialize

func Initialize(workspace string, manifest project.Manifest) (string, error)

Types

type EntityMutation

type EntityMutation struct {
	ExpectedRevision       uint64
	ExpectedSourceRevision string
	Scope                  string
	EntityType             string
	EntityID               string
	Entity                 *EntityRecord
	Action                 string
}

type EntityPresence

type EntityPresence struct {
	Present bool          `json:"present"`
	Value   *EntityRecord `json:"value,omitempty"`
}

func (EntityPresence) MarshalJSON

func (p EntityPresence) MarshalJSON() ([]byte, error)

type EntityRecord

type EntityRecord = entities.Record

EntityRecord is the Pack-neutral record representation exposed by the entity resource. Its runtime collection shape is owned by entities.Record.

type EntityReference

type EntityReference struct {
	EntityRef  string `json:"entity_ref"`
	EntityType string `json:"entity_type"`
	EntityID   string `json:"entity_id"`
	Path       string `json:"path"`
}

type EntityReferencedError

type EntityReferencedError struct {
	Revision   uint64
	References []EntityReference
}

func (*EntityReferencedError) Error

func (e *EntityReferencedError) Error() string

type EntityReferences

type EntityReferences struct {
	EntityRef    string            `json:"entity_ref"`
	ReferencedBy []EntityReference `json:"referenced_by"`
}

type EntityView

type EntityView struct {
	EntityRef      string         `json:"entity_ref"`
	EntityType     string         `json:"entity_type"`
	EntityID       string         `json:"entity_id"`
	Source         EntityPresence `json:"source"`
	Draft          EntityPresence `json:"draft"`
	Resolved       EntityPresence `json:"resolved"`
	Effective      EntityPresence `json:"effective"`
	Origin         string         `json:"origin"`
	SourceRevision string         `json:"source_revision"`
}

type GitPrepareInput

type GitPrepareInput struct {
	EnvironmentID string
	Slug          string
	PlanID        string
}

type PlanInvalidatedError

type PlanInvalidatedError struct{ PlanID, Reason string }

PlanInvalidatedError is the 409 precondition domain for local inputs. Remote ETag conflicts intentionally use RemoteETagMismatchError instead.

func (*PlanInvalidatedError) Error

func (e *PlanInvalidatedError) Error() string

type ProviderInfo

type ProviderInfo struct {
	EnvironmentID          string                `json:"environment_id"`
	ProviderType           string                `json:"provider_type"`
	Status                 string                `json:"status"`
	CredentialsPathDisplay string                `json:"credentials_path_display,omitempty"`
	Capabilities           provider.Capabilities `json:"capabilities"`
}

type ReleaseConfirmation

type ReleaseConfirmation struct {
	Acknowledged            bool
	EnvironmentID           string
	AcknowledgedRiskItemIDs []string
}

type ReleaseRequest

type ReleaseRequest struct {
	PlanID                string
	ExpectedDraftRevision uint64
	ExpectedRemoteETag    string
	Confirmation          ReleaseConfirmation
}

ReleaseRequest is the frozen POST /releases body expressed independently of HTTP. Risk severity and environment kind are intentionally absent.

type RemoteETagMismatchError

type RemoteETagMismatchError struct {
	PlanID, EnvironmentID, Expected string
	Current                         remote.Snapshot
}

RemoteETagMismatchError is the 412 domain used by a publish preflight. It contains only the protected remote summary, never provider credentials.

func (*RemoteETagMismatchError) Error

func (e *RemoteETagMismatchError) Error() string

type RemoteProjection

type RemoteProjection struct {
	EnvironmentID string                  `json:"environment_id"`
	SnapshotETag  string                  `json:"snapshot_etag"`
	ObservedAt    string                  `json:"observed_at"`
	Projections   []RemoteValueProjection `json:"projections"`
}

type RemoteValueProjection

type RemoteValueProjection struct {
	ProjectionID string `json:"projection_id"`
	EntityRef    string `json:"entity_ref"`
	FieldPath    string `json:"field_path"`
	ParameterKey string `json:"parameter_key"`
	ValueSummary string `json:"value_summary"`
	SnapshotETag string `json:"snapshot_etag"`
	ObservedAt   string `json:"observed_at"`
	Availability string `json:"availability"`
	Redacted     bool   `json:"redacted"`
	ReasonCode   string `json:"reason_code,omitempty"`
}

type RollbackRequest

type RollbackRequest struct {
	RollbackPreviewID  string
	ExpectedRemoteETag string
	Confirmation       ReleaseConfirmation
}

type Service

type Service struct {
	// contains filtered or unexported fields
}

func Open

func Open(workspace string) (*Service, error)

func OpenWithPacks

func OpenWithPacks(workspace string, registry *packs.Registry) (*Service, error)

func OpenWithPacksAndProviderFactory

func OpenWithPacksAndProviderFactory(workspace string, registry *packs.Registry, factory func(project.Environment) (provider.Adapter, error)) (*Service, error)

OpenWithPacksAndProviderFactory keeps the application orchestration testable without allowing provider protocol details into the app package.

func (*Service) CheckPlanForPublish

func (s *Service) CheckPlanForPublish(ctx context.Context, id string) (plan.Plan, error)

CheckPlanForPublish is the reusable preflight boundary for Spec 009. It is deliberately not an HTTP endpoint: this Spec creates Plans but does not add publishing. Its typed errors preserve the frozen 409/412 error separation.

func (*Service) CreateEnvironment

func (s *Service) CreateEnvironment(_ context.Context, expectedRevision uint64, environment project.Environment) (project.Snapshot, project.Environment, error)

func (*Service) CreateRollbackPreview

func (s *Service) CreateRollbackPreview(ctx context.Context, environmentID, releaseID string) (operation.Operation, error)

CreateRollbackPreview reads the live provider state before constructing an immutable preview. The protected target template is taken from the release audit store, never from an API caller.

func (*Service) Defaults

func (s *Service) Defaults(_ context.Context, environmentID, format string) ([]byte, string, string, error)

Defaults exports values from the protected current remote snapshot. These values are client defaults already intended for distribution; credentials and provider tokens are not part of the snapshot or this format.

func (*Service) DeleteEnvironment

func (s *Service) DeleteEnvironment(_ context.Context, expectedRevision uint64, environmentID string) (project.Snapshot, error)

func (*Service) Diagnostics

func (s *Service) Diagnostics(ctx context.Context, environmentID string) (validation.Result, uint64, error)

Diagnostics returns the latest stored complete-validation result.

func (*Service) GetDraft

func (s *Service) GetDraft(_ context.Context, environmentID string) (draft.View, uint64, error)

func (*Service) GetEntity

func (s *Service) GetEntity(_ context.Context, environmentID, entityType, entityID string) (EntityView, uint64, error)

func (*Service) GetEntityReferences

func (s *Service) GetEntityReferences(_ context.Context, environmentID, entityType, entityID string) (EntityReferences, uint64, error)

func (*Service) GetEnvironment

func (s *Service) GetEnvironment(ctx context.Context, environmentID string) (project.Snapshot, project.Environment, error)

func (*Service) GetPack

func (s *Service) GetPack(_ context.Context, name, version string) (packs.Definition, uint64, error)

func (*Service) GetPackSchema

func (s *Service) GetPackSchema(_ context.Context, name, version string, requestedVersion *uint64) (packs.Schema, uint64, error)

func (*Service) GetPlan

func (s *Service) GetPlan(ctx context.Context, id string) (plan.Plan, error)

func (*Service) GitCommit

func (s *Service) GitCommit(ctx context.Context, files []string, message, idempotencyKey string) (gitreview.CommitResult, error)

func (*Service) GitCreateBranch

func (s *Service) GitCreateBranch(ctx context.Context, branch, idempotencyKey string) (gitreview.BranchResult, error)

func (*Service) GitPrepare

func (s *Service) GitPrepare(ctx context.Context, input GitPrepareInput) (gitreview.PrepareResult, error)

func (*Service) GitStatus

func (s *Service) GitStatus(ctx context.Context) (gitreview.Status, error)

GitStatus is available only to Git JSON projects. It intentionally exposes workspace-relative paths and commit metadata, never Git credentials.

func (*Service) ImportSource

func (s *Service) ImportSource(ctx context.Context, environmentID string, expectedRevision uint64, expectedSourceRevision string) (draft.View, uint64, error)

ImportSource installs the current source snapshot as explicit target-layer draft replacements. The source itself is never modified by import.

func (*Service) InspectSource

func (s *Service) InspectSource(_ context.Context) (SourceInspectResult, error)

func (*Service) ListEntities

func (s *Service) ListEntities(_ context.Context, environmentID, entityType string) ([]EntityView, uint64, error)

func (*Service) ListPacks

func (s *Service) ListPacks(_ context.Context) packs.Snapshot

func (*Service) MutateDraft

func (s *Service) MutateDraft(_ context.Context, environmentID string, mutation draft.Mutation) (draft.View, uint64, error)

func (*Service) MutateEntity

func (s *Service) MutateEntity(_ context.Context, environmentID string, mutation EntityMutation) (EntityView, uint64, error)

func (*Service) Operation

func (s *Service) Operation(_ context.Context, id string) (operation.Operation, error)

func (*Service) PlanArtifact

func (s *Service) PlanArtifact(ctx context.Context, planID, name string) ([]byte, plan.ArtifactMetadata, plan.Plan, error)

func (*Service) PreviewSourceSave

func (s *Service) PreviewSourceSave(ctx context.Context, environmentID string) (source.Preview, error)

func (*Service) ProviderStatus

func (s *Service) ProviderStatus(ctx context.Context, environmentID string) (ProviderInfo, error)

func (*Service) Release

func (s *Service) Release(ctx context.Context, id string) (release.Release, bool)

func (*Service) ReleaseWithError

func (s *Service) ReleaseWithError(_ context.Context, id string) (release.Release, bool, error)

func (*Service) Releases

func (s *Service) Releases(ctx context.Context, environmentID string) []release.Release

func (*Service) ReleasesPage

func (s *Service) ReleasesPage(_ context.Context, environmentID string, limit int, cursor string) ([]release.Release, error)

func (*Service) RemoteProjection

func (s *Service) RemoteProjection(ctx context.Context, environmentID string) (RemoteProjection, error)

func (*Service) RollbackPreview

func (s *Service) RollbackPreview(_ context.Context, environmentID, releaseID string) (release.RollbackPreview, error)

func (*Service) SaveDraft

func (s *Service) SaveDraft(_ context.Context, environmentID string, expectedRevision uint64, expectedSourceRevision string) (draft.View, uint64, error)

SaveDraft writes the resolved source replacement for the selected view and then consumes that view's draft replacements. The draft Store retains the existing lock/snapshot boundary from Spec 004.

func (*Service) Snapshot

func (s *Service) Snapshot(_ context.Context) (project.Snapshot, error)

func (*Service) SourceInfo

func (s *Service) SourceInfo(_ context.Context) (SourceInfo, error)

func (*Service) StartPlan

func (s *Service) StartPlan(ctx context.Context, environmentID string) (operation.Operation, error)

StartPlan always creates a durable Operation before starting work. The operation store is deliberately the recovery authority for callers that disconnect while this local workflow runs.

func (*Service) StartProviderConnect

func (s *Service) StartProviderConnect(ctx context.Context, environmentID, credentialsPath string) (operation.Operation, error)

func (*Service) StartPull

func (s *Service) StartPull(ctx context.Context, environmentID string) (operation.Operation, error)

func (*Service) StartRelease

func (s *Service) StartRelease(ctx context.Context, environmentID, idempotencyKey string, request ReleaseRequest) (operation.Operation, error)

func (*Service) StartRemoteValidate

func (s *Service) StartRemoteValidate(ctx context.Context, environmentID, planID string) (operation.Operation, error)

func (*Service) StartRollback

func (s *Service) StartRollback(ctx context.Context, environmentID, releaseID, idempotencyKey string, request RollbackRequest) (operation.Operation, error)

func (*Service) UpdateEnvironment

func (s *Service) UpdateEnvironment(_ context.Context, expectedRevision uint64, environmentID string, replacement project.Environment) (project.Snapshot, project.Environment, error)

func (*Service) UpdateProject

func (s *Service) UpdateProject(_ context.Context, expectedRevision uint64, metadata project.Project) (project.Snapshot, error)

func (*Service) ValidateDraft

func (s *Service) ValidateDraft(_ context.Context, environmentID string) (validation.Result, uint64, error)

ValidateDraft runs the complete Spec 007 validation against one captured DraftView and stores the resulting project-level draft revision.

type SourceInfo

type SourceInfo struct {
	Type         string
	Capabilities source.Capabilities
	Status       source.Status
}

type SourceInspectResult

type SourceInspectResult struct {
	Workspace   source.GitWorkspace
	ProfilePath string
	Matched     bool
	Diagnostics []source.MappingDiagnostic
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL