Documentation
¶
Index ¶
- Constants
- Variables
- func Delete(id string) error
- func ResolveSchema(schemaType string, category Category, stage Stage, rawPayload []byte) (reflect.Type, string, Category, Stage)
- func ValidateTypeGuard(storedSchemaType string, requestedType reflect.Type) error
- type Artifact
- func CastPayload[T any](raw *RawArtifact) (*Artifact[T], error)
- func CreateAs[T any](meta CreateMetadata, payload T) (*Artifact[T], error)
- func CreateAsInStore[T any](st *Store, meta CreateMetadata, payload T) (*Artifact[T], error)
- func GetAs[T any](id string) (*Artifact[T], error)
- func GetAsFromStore[T any](st *Store, id string) (*Artifact[T], error)
- type Category
- type CreateMetadata
- type CreateReq
- type Filter
- type LineageGraph
- type ListResponse
- type RawArtifact
- func Create(req CreateReq) (*RawArtifact, error)
- func CreateInStore(st *Store, req CreateReq) (*RawArtifact, error)
- func Get(id string) (*RawArtifact, error)
- func GetFromStore(st *Store, id string) (*RawArtifact, error)
- func List(filter Filter) ([]RawArtifact, error)
- func ListFromStore(st *Store, filter Filter) ([]RawArtifact, error)
- func Update(id string, req UpdateReq) (*RawArtifact, error)
- func UpdateInStore(st *Store, id string, req UpdateReq) (*RawArtifact, error)
- type SchemaDescriptor
- type Stage
- type Store
- type UpdateReq
Constants ¶
const CurrentSchemaVersion = "v0.1.18"
CurrentSchemaVersion defines the current imdl schema version stamped on normalized artifacts.
Variables ¶
var ErrArtifactNotFound = errors.New("artifact not found")
ErrArtifactNotFound indicates that the requested artifact ID does not exist in the store.
Functions ¶
Types ¶
type Artifact ¶
type Artifact[T any] struct { Id string `json:"id" example:"art-d0g535l40272926020g0"` Name string `json:"name" validate:"required" example:"ecommerce-prod-plan"` Description string `json:"description,omitempty" example:"Refined migration artifact"` Version string `json:"version,omitempty" example:"1.0.0"` Category Category `json:"category" validate:"required" enums:"infra,software,data" example:"infra"` Stage Stage `json:"stage" validate:"required" enums:"source,planning,target" example:"planning"` SchemaType string `json:"schemaType,omitempty" example:"OnpremInfra"` SchemaVersion string `json:"schemaVersion,omitempty" example:"v0.1.18"` Lineage lineage.MigrationLineage `json:"lineage"` Payload T `json:"payload" validate:"required"` ConversionReport *modelconv.ConversionReport `json:"conversionReport,omitempty"` CreateTime string `json:"createTime" example:"2026-10-23T12:00:00Z"` UpdateTime string `json:"updateTime,omitempty" example:"2026-10-23T12:05:00Z"` }
Artifact is a generic envelope for any migration payload type T.
func CastPayload ¶
func CastPayload[T any](raw *RawArtifact) (*Artifact[T], error)
CastPayload validates schemaType compatibility and upcasts a RawArtifact into a typed Artifact[T].
func CreateAs ¶
func CreateAs[T any](meta CreateMetadata, payload T) (*Artifact[T], error)
CreateAs stores a typed payload T as a normalized Artifact and returns the typed Artifact[T].
func CreateAsInStore ¶
func CreateAsInStore[T any](st *Store, meta CreateMetadata, payload T) (*Artifact[T], error)
CreateAsInStore stores a typed payload T in the specified store and returns the typed Artifact[T].
type CreateMetadata ¶
type CreateMetadata struct {
Id string `json:"id,omitempty"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
Version string `json:"version,omitempty"`
Category Category `json:"category,omitempty"`
Stage Stage `json:"stage,omitempty"`
SchemaType string `json:"schemaType,omitempty"`
ParentId string `json:"parentId,omitempty"`
SourceGroupId string `json:"sourceGroupId,omitempty"`
Lineage lineage.MigrationLineage `json:"lineage,omitempty"`
}
CreateMetadata holds metadata fields used when creating a typed artifact via CreateAs[T].
type CreateReq ¶
type CreateReq struct {
Id string `json:"id,omitempty" example:"art-custom-01"`
Name string `json:"name" validate:"required" example:"ecommerce-source-infra"`
Description string `json:"description,omitempty" example:"Extracted source infrastructure"`
Version string `json:"version,omitempty" example:"1.0.0"`
Category Category `json:"category" validate:"required" enums:"infra,software,data" example:"infra"`
Stage Stage `json:"stage" validate:"required" enums:"source,planning,target" example:"source"`
SchemaType string `json:"schemaType,omitempty" example:"OnpremInfra"`
ParentId string `json:"parentId,omitempty" example:"art-src-01"`
SourceGroupId string `json:"sourceGroupId,omitempty" example:"sg-ecommerce-prod"`
Lineage lineage.MigrationLineage `json:"lineage,omitempty"`
Payload json.RawMessage `json:"payload" validate:"required"`
// Legacy envelope compatibility fields accepted on import and normalized automatically.
LegacyModelType string `json:"modelType,omitempty" swaggerignore:"true"`
LegacyOnpremModel json.RawMessage `json:"onpremiseInfraModel,omitempty" swaggerignore:"true"`
LegacyCloudModel json.RawMessage `json:"cloudInfraModel,omitempty" swaggerignore:"true"`
LegacyRecInfraModel json.RawMessage `json:"recommendedInfraModel,omitempty" swaggerignore:"true"`
}
CreateReq represents the JSON request body for POST /beetle/artifacts.
type Filter ¶
type Filter struct {
Category Category `json:"category,omitempty"`
Stage Stage `json:"stage,omitempty"`
SchemaType string `json:"schemaType,omitempty"`
SourceGroupId string `json:"sourceGroupId,omitempty"`
}
Filter defines query parameters for listing artifacts via GET /beetle/artifacts.
type LineageGraph ¶
type LineageGraph struct {
ArtifactId string `json:"artifactId"`
SourceGroupId string `json:"sourceGroupId,omitempty"`
Lineage lineage.MigrationLineage `json:"lineage"`
SourceArtifact *RawArtifact `json:"sourceArtifact,omitempty"`
PlanningArtifact *RawArtifact `json:"planningArtifact,omitempty"`
TargetArtifact *RawArtifact `json:"targetArtifact,omitempty"`
GroupArtifacts []RawArtifact `json:"groupArtifacts,omitempty"`
}
LineageGraph represents the derivation chain and group-related artifacts for GET /beetle/artifacts/:id/lineage.
func GetLineageGraph ¶
func GetLineageGraph(id string) (*LineageGraph, error)
GetLineageGraph builds the full derivation chain and group-related artifacts for an artifact ID.
func GetLineageGraphFromStore ¶
func GetLineageGraphFromStore(st *Store, id string) (*LineageGraph, error)
GetLineageGraphFromStore builds the full derivation chain from the given store.
type ListResponse ¶
type ListResponse struct {
Count int `json:"count" example:"2"`
Artifacts []RawArtifact `json:"artifacts"`
}
ListResponse wraps a slice of artifacts for consistent REST API responses.
type RawArtifact ¶
type RawArtifact = Artifact[json.RawMessage]
RawArtifact is the untyped storage and wire representation of an Artifact.
func Create ¶
func Create(req CreateReq) (*RawArtifact, error)
Create validates, upcasts, and persists a new artifact in the default store.
func CreateInStore ¶
func CreateInStore(st *Store, req CreateReq) (*RawArtifact, error)
CreateInStore validates, upcasts, and persists a new artifact in the given store.
func Get ¶
func Get(id string) (*RawArtifact, error)
Get retrieves an artifact by ID and ensures its payload is upcasted to the latest registered schema.
func GetFromStore ¶
func GetFromStore(st *Store, id string) (*RawArtifact, error)
GetFromStore retrieves an artifact by ID from the given store and ensures latest schema normalization.
func List ¶
func List(filter Filter) ([]RawArtifact, error)
List returns all artifacts matching Filter from the default store.
func ListFromStore ¶
func ListFromStore(st *Store, filter Filter) ([]RawArtifact, error)
ListFromStore returns all artifacts matching Filter from the given store.
func Update ¶
func Update(id string, req UpdateReq) (*RawArtifact, error)
Update modifies an existing artifact in-place, upcasts the updated payload, and persists it atomically.
func UpdateInStore ¶
func UpdateInStore(st *Store, id string, req UpdateReq) (*RawArtifact, error)
UpdateInStore modifies an existing artifact in the given store.
type SchemaDescriptor ¶
type SchemaDescriptor struct {
SchemaType string
ReflectType reflect.Type
DefaultCategory Category
DefaultStage Stage
}
SchemaDescriptor holds reflection metadata and default classification for a registered schema type.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store manages thread-safe in-memory indexing and atomic JSON file persistence for artifacts.
func GetDefaultStore ¶
GetDefaultStore returns the initialized default Store, or initializes one at ./db/artifacts if nil.
func InitStore ¶
InitStore initializes the package-level default artifact store at the given directory path.
func NewStore ¶
NewStore creates a new Store backed by dirPath and loads existing JSON artifact files into memory.
func (*Store) Delete ¶
Delete removes an artifact file from disk and deletes it from the in-memory index.
func (*Store) Get ¶
func (s *Store) Get(id string) (RawArtifact, error)
Get retrieves a RawArtifact by ID from the in-memory index.
func (*Store) List ¶
func (s *Store) List(filter Filter) []RawArtifact
List returns all artifacts matching Filter, sorted newest first by CreateTime/UpdateTime.
func (*Store) Save ¶
func (s *Store) Save(art RawArtifact) error
Save atomically persists a RawArtifact to disk using Write-Sync-Rename and updates the in-memory index.
type UpdateReq ¶
type UpdateReq struct {
Name string `json:"name,omitempty" example:"ecommerce-plan-v2"`
Description string `json:"description,omitempty" example:"Updated node spec"`
Version string `json:"version,omitempty" example:"1.1.0"`
Category Category `json:"category,omitempty" enums:"infra,software,data" example:"infra"`
Stage Stage `json:"stage,omitempty" enums:"source,planning,target" example:"planning"`
SchemaType string `json:"schemaType,omitempty" example:"OnpremInfra"`
ParentId string `json:"parentId,omitempty"`
SourceGroupId string `json:"sourceGroupId,omitempty"`
Lineage lineage.MigrationLineage `json:"lineage,omitempty"`
Payload json.RawMessage `json:"payload,omitempty"`
// Legacy envelope compatibility fields accepted on update and normalized automatically.
LegacyOnpremModel json.RawMessage `json:"onpremiseInfraModel,omitempty" swaggerignore:"true"`
LegacyCloudModel json.RawMessage `json:"cloudInfraModel,omitempty" swaggerignore:"true"`
LegacyRecInfraModel json.RawMessage `json:"recommendedInfraModel,omitempty" swaggerignore:"true"`
}
UpdateReq represents the JSON request body for PUT /beetle/artifacts/:id.