graph

package
v0.0.0-...-74adf86 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2026 License: AGPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CatalogCategoryToGraphQL

func CatalogCategoryToGraphQL(c *catalog.Category) *model.Category

CatalogCategoryToGraphQL converts a catalog category to a GraphQL category

func CatalogCollectionToGraphQL

func CatalogCollectionToGraphQL(c *catalog.Collection) *model.Collection

CatalogCollectionToGraphQL converts a catalog collection to a GraphQL collection

func CatalogProductToGraphQL

func CatalogProductToGraphQL(p *catalog.Product) *model.Product

CatalogProductToGraphQL converts a catalog product to a GraphQL product

func IsVersionMismatchError

func IsVersionMismatchError(err error) bool

IsVersionMismatchError checks if an error is a version mismatch error

func PaginateCategories

func PaginateCategories(
	categories []*catalog.Category,
	first *int32,
	after *string,
	last *int32,
	before *string,
) ([]*catalog.Category, error)

PaginateCategories applies pagination to categories (future extension)

func PaginateCollections

func PaginateCollections(
	collections []*catalog.Collection,
	first *int32,
	after *string,
	last *int32,
	before *string,
) ([]*catalog.Collection, error)

PaginateCollections applies pagination to collections (future extension)

func PaginateProducts

func PaginateProducts(
	products []*catalog.Product,
	first *int32,
	after *string,
	last *int32,
	before *string,
) (*model.ProductConnection, error)

PaginateProducts applies Relay-style cursor pagination to a product list

Types

type CategoryOrderInput

type CategoryOrderInput struct {
	ID           string
	DisplayOrder int
}

CategoryOrderInput represents a category and its new display order

type Change

type Change struct {
	Type    ChangeType
	Content string
	LineNo  int
}

Change represents a single change in the diff

type ChangeType

type ChangeType string

ChangeType indicates the type of change

const (
	ChangeTypeAdd    ChangeType = "add"
	ChangeTypeDelete ChangeType = "delete"
	ChangeTypeEqual  ChangeType = "equal"
)

type CollectionOrderInput

type CollectionOrderInput struct {
	ID           string
	DisplayOrder int
}

CollectionOrderInput represents a collection and its new display order

type ConflictDetails

type ConflictDetails struct {
	EntityType      string
	EntityID        string
	ExpectedVersion string
	ActualVersion   string
	HasConflict     bool
	Message         string
}

ConflictDetails contains information about a version conflict

func GetConflictDetails

func GetConflictDetails(err error) *ConflictDetails

GetConflictDetails extracts conflict information from a version mismatch error

type ConflictDiff

type ConflictDiff struct {
	BaseContent   string
	LocalContent  string
	RemoteContent string
	LocalDiff     *DiffResult
	RemoteDiff    *DiffResult
	HasConflict   bool
}

ConflictDiff represents a three-way merge conflict

func (*ConflictDiff) GetConflictSummary

func (cd *ConflictDiff) GetConflictSummary() string

GetConflictSummary generates a human-readable summary of the conflict

type CreateCategoryInput

type CreateCategoryInput struct {
	ClientMutationID *string
	Name             string
	Slug             string
	ParentID         *string
	DisplayOrder     *int
	Body             *string
}

CreateCategoryInput represents the input for creating a category

type CreateCategoryPayload

type CreateCategoryPayload struct {
	ClientMutationID *string
	Category         *models.CategoryMutation
}

CreateCategoryPayload represents the payload returned from createCategory

type CreateCollectionInput

type CreateCollectionInput struct {
	ClientMutationID *string
	Name             string
	Slug             string
	DisplayOrder     *int
	Body             *string
}

CreateCollectionInput represents the input for creating a collection

type CreateCollectionPayload

type CreateCollectionPayload struct {
	ClientMutationID *string
	Collection       *models.CollectionMutation
}

CreateCollectionPayload represents the payload returned from createCollection

type CreateProductInput

type CreateProductInput struct {
	ClientMutationID  *string
	SKU               string
	Title             string
	Body              *string
	Price             float64
	Currency          *string
	InventoryStatus   *string
	InventoryQuantity *int
	CategoryID        string
	CollectionIDs     []string
	Images            []string
	Metadata          map[string]interface{}
}

CreateProductInput represents the input for creating a product

type CreateProductPayload

type CreateProductPayload struct {
	ClientMutationID *string
	Product          *models.Product
}

CreateProductPayload represents the payload returned from createProduct

type DeleteCategoryInput

type DeleteCategoryInput struct {
	ClientMutationID *string
	ID               string
}

DeleteCategoryInput represents the input for deleting a category

type DeleteCategoryPayload

type DeleteCategoryPayload struct {
	ClientMutationID  *string
	DeletedCategoryID *string
}

DeleteCategoryPayload represents the payload returned from deleteCategory

type DeleteCollectionInput

type DeleteCollectionInput struct {
	ClientMutationID *string
	ID               string
}

DeleteCollectionInput represents the input for deleting a collection

type DeleteCollectionPayload

type DeleteCollectionPayload struct {
	ClientMutationID    *string
	DeletedCollectionID *string
}

DeleteCollectionPayload represents the payload returned from deleteCollection

type DeleteProductInput

type DeleteProductInput struct {
	ClientMutationID *string
	ID               string
}

DeleteProductInput represents the input for deleting a product

type DeleteProductPayload

type DeleteProductPayload struct {
	ClientMutationID *string
	DeletedProductID *string
}

DeleteProductPayload represents the payload returned from deleteProduct

type DiffGenerator

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

DiffGenerator generates diffs between file versions for conflict resolution

func NewDiffGenerator

func NewDiffGenerator() *DiffGenerator

NewDiffGenerator creates a new diff generator

func (*DiffGenerator) GenerateConflictDiff

func (dg *DiffGenerator) GenerateConflictDiff(baseContent, localContent, remoteContent string) *ConflictDiff

GenerateConflictDiff creates a three-way diff for conflict resolution Shows the common base, user's changes, and server's changes

func (*DiffGenerator) GenerateDiff

func (dg *DiffGenerator) GenerateDiff(oldContent, newContent string) *DiffResult

GenerateDiff creates a diff between two content versions

type DiffResult

type DiffResult struct {
	OldContent  string
	NewContent  string
	UnifiedDiff string
	Changes     []Change
	HasChanges  bool
}

DiffResult contains the diff between two versions

func (*DiffResult) FormatDiffForDisplay

func (dr *DiffResult) FormatDiffForDisplay() string

FormatDiffForDisplay formats the diff for display in UI

func (*DiffResult) GetChangedSections

func (dr *DiffResult) GetChangedSections() []Change

GetChangedSections returns only the sections with changes (ignoring equal parts)

func (*DiffResult) GetDiffSummary

func (dr *DiffResult) GetDiffSummary() *DiffSummary

GetDiffSummary calculates statistics about the diff

func (*DiffResult) HasAdditions

func (dr *DiffResult) HasAdditions() bool

HasAdditions checks if the diff contains any additions

func (*DiffResult) HasDeletions

func (dr *DiffResult) HasDeletions() bool

HasDeletions checks if the diff contains any deletions

type DiffSummary

type DiffSummary struct {
	AddedLines   int
	DeletedLines int
	ChangedLines int
	TotalChanges int
}

DiffSummary provides a brief summary of changes

type OptimisticLockConflict

type OptimisticLockConflict struct {
	Detected         bool
	CurrentVersion   string
	AttemptedVersion string
	CurrentProduct   *models.Product
	Diff             string
}

OptimisticLockConflict contains information about a version conflict

type ProductMutationService

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

ProductMutationService handles product mutation operations

func NewProductMutationService

func NewProductMutationService(repoPath, remoteURL string) *ProductMutationService

NewProductMutationService creates a new product mutation service

func (*ProductMutationService) CreateCategory

CreateCategory creates a new category and commits it to git

func (*ProductMutationService) CreateCollection

CreateCollection creates a new collection and commits it to git

func (*ProductMutationService) CreateProduct

CreateProduct creates a new product and commits it to git

func (*ProductMutationService) DeleteCategory

DeleteCategory deletes an existing category

func (*ProductMutationService) DeleteCollection

DeleteCollection deletes an existing collection

func (*ProductMutationService) DeleteProduct

DeleteProduct deletes an existing product

func (*ProductMutationService) PublishCatalog

PublishCatalog commits all changes, pushes to remote, and creates a release tag

func (*ProductMutationService) ReorderCategories

ReorderCategories updates the display order of multiple categories in a single transaction

func (*ProductMutationService) ReorderCollections

ReorderCollections updates the display order of multiple collections in a single transaction

func (*ProductMutationService) UpdateCategory

UpdateCategory updates an existing category with optimistic locking

func (*ProductMutationService) UpdateCollection

UpdateCollection updates an existing collection with optimistic locking

func (*ProductMutationService) UpdateProduct

UpdateProduct updates an existing product with optimistic locking

type PublishCatalogInput

type PublishCatalogInput struct {
	ClientMutationID *string
	TagName          *string // Optional: custom tag name (defaults to auto-generated semver)
	Message          *string // Optional: custom tag message
}

PublishCatalogInput represents the input for publishing the catalog

type PublishCatalogPayload

type PublishCatalogPayload struct {
	ClientMutationID *string
	TagName          string
	CommitHash       string
	Success          bool
}

PublishCatalogPayload represents the payload returned from publishCatalog

type ReorderCategoriesInput

type ReorderCategoriesInput struct {
	ClientMutationID *string
	Orders           []CategoryOrderInput
}

ReorderCategoriesInput represents the input for reordering categories

type ReorderCategoriesPayload

type ReorderCategoriesPayload struct {
	ClientMutationID *string
	Categories       []*models.CategoryMutation
}

ReorderCategoriesPayload represents the payload returned from reorderCategories

type ReorderCollectionsInput

type ReorderCollectionsInput struct {
	ClientMutationID *string
	Orders           []CollectionOrderInput
}

ReorderCollectionsInput represents the input for reordering collections

type ReorderCollectionsPayload

type ReorderCollectionsPayload struct {
	ClientMutationID *string
	Collections      []*models.CollectionMutation
}

ReorderCollectionsPayload represents the payload returned from reorderCollections

type Resolver

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

Resolver is the root GraphQL resolver

func NewResolver

func NewResolver(cacheManager *cache.Manager, repoPath string, gitServerURL string) *Resolver

NewResolver creates a new GraphQL resolver

func (*Resolver) Category

func (r *Resolver) Category() generated.CategoryResolver

Category returns generated.CategoryResolver implementation.

func (*Resolver) Collection

func (r *Resolver) Collection() generated.CollectionResolver

Collection returns generated.CollectionResolver implementation.

func (*Resolver) Mutation

func (r *Resolver) Mutation() generated.MutationResolver

Mutation returns generated.MutationResolver implementation.

func (*Resolver) Product

func (r *Resolver) Product() generated.ProductResolver

Product returns generated.ProductResolver implementation.

func (*Resolver) Query

func (r *Resolver) Query() generated.QueryResolver

Query returns generated.QueryResolver implementation.

type Service

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

Service provides business logic for GraphQL operations

func NewService

func NewService(cacheManager *cache.Manager, repoPath string, gitServerURL string, logger *zap.Logger) *Service

NewService creates a new service instance

func (*Service) CreateProduct

func (s *Service) CreateProduct(ctx context.Context, input map[string]interface{}) (*catalog.Product, error)

CreateProduct creates a new product and commits to git

func (*Service) DeleteProduct

func (s *Service) DeleteProduct(ctx context.Context, id string) error

DeleteProduct deletes a product

func (*Service) GetCatalog

func (s *Service) GetCatalog(ctx context.Context) (*catalog.Catalog, error)

GetCatalog retrieves the current catalog from cache

func (*Service) GetCategories

func (s *Service) GetCategories(ctx context.Context) ([]*catalog.Category, error)

GetCategories returns all categories

func (*Service) GetCategoryByID

func (s *Service) GetCategoryByID(ctx context.Context, id string) (*catalog.Category, error)

GetCategoryByID returns a category by ID

func (*Service) GetCategoryBySlug

func (s *Service) GetCategoryBySlug(ctx context.Context, slug string) (*catalog.Category, error)

GetCategoryBySlug returns a category by slug

func (*Service) GetCollectionByID

func (s *Service) GetCollectionByID(ctx context.Context, id string) (*catalog.Collection, error)

GetCollectionByID returns a collection by ID

func (*Service) GetCollectionBySlug

func (s *Service) GetCollectionBySlug(ctx context.Context, slug string) (*catalog.Collection, error)

GetCollectionBySlug returns a collection by slug

func (*Service) GetCollections

func (s *Service) GetCollections(ctx context.Context) ([]*catalog.Collection, error)

GetCollections returns all collections

func (*Service) GetProductByID

func (s *Service) GetProductByID(ctx context.Context, id string) (*catalog.Product, error)

GetProductByID retrieves a product by ID

func (*Service) GetProductBySKU

func (s *Service) GetProductBySKU(ctx context.Context, sku string) (*catalog.Product, error)

GetProductBySKU retrieves a product by SKU

func (*Service) GetProducts

func (s *Service) GetProducts(ctx context.Context, categoryID *string) ([]*catalog.Product, error)

GetProducts retrieves all products from catalog with optional filtering

func (*Service) UpdateProduct

func (s *Service) UpdateProduct(ctx context.Context, id string, input map[string]interface{}) (*catalog.Product, error)

UpdateProduct updates an existing product

type UpdateCategoryInput

type UpdateCategoryInput struct {
	ClientMutationID *string
	ID               string
	Name             *string
	Slug             *string
	ParentID         *string
	DisplayOrder     *int
	Body             *string
	Version          string // For optimistic locking
}

UpdateCategoryInput represents the input for updating a category

type UpdateCategoryPayload

type UpdateCategoryPayload struct {
	ClientMutationID *string
	Category         *models.CategoryMutation
	Conflict         *OptimisticLockConflict
}

UpdateCategoryPayload represents the payload returned from updateCategory

type UpdateCollectionInput

type UpdateCollectionInput struct {
	ClientMutationID *string
	ID               string
	Name             *string
	Slug             *string
	DisplayOrder     *int
	Body             *string
	Version          string // For optimistic locking
}

UpdateCollectionInput represents the input for updating a collection

type UpdateCollectionPayload

type UpdateCollectionPayload struct {
	ClientMutationID *string
	Collection       *models.CollectionMutation
	Conflict         *OptimisticLockConflict
}

UpdateCollectionPayload represents the payload returned from updateCollection

type UpdateProductInput

type UpdateProductInput struct {
	ClientMutationID  *string
	ID                string
	SKU               *string
	Title             *string
	Body              *string
	Price             *float64
	Currency          *string
	InventoryStatus   *string
	InventoryQuantity *int
	CategoryID        *string
	CollectionIDs     []string
	Images            []string
	Metadata          map[string]interface{}
	Version           string // For optimistic locking
}

UpdateProductInput represents the input for updating a product

type UpdateProductPayload

type UpdateProductPayload struct {
	ClientMutationID *string
	Product          *models.Product
	Conflict         *OptimisticLockConflict
}

UpdateProductPayload represents the payload returned from updateProduct

type VersionChecker

type VersionChecker struct{}

VersionChecker handles optimistic locking version verification

func NewVersionChecker

func NewVersionChecker() *VersionChecker

NewVersionChecker creates a new version checker

func (*VersionChecker) CalculateVersion

func (vc *VersionChecker) CalculateVersion(content string) string

CalculateVersion computes a version hash from entity content This hash represents the state of the entity and changes when content changes

func (*VersionChecker) CalculateVersionShort

func (vc *VersionChecker) CalculateVersionShort(content string) string

CalculateVersionShort returns a shortened version hash (first 12 characters) Suitable for display in UIs and error messages

func (*VersionChecker) CheckVersion

func (vc *VersionChecker) CheckVersion(expectedVersion, currentContent, entityType, entityID string) error

CheckVersion verifies that the expected version matches the current version

func (*VersionChecker) CheckVersionShort

func (vc *VersionChecker) CheckVersionShort(expectedVersion, currentContent, entityType, entityID string) error

CheckVersionShort is a convenience method that works with shortened versions

func (*VersionChecker) CompareVersions

func (vc *VersionChecker) CompareVersions(v1, v2 string) int

CompareVersions compares two version hashes Returns: -1 if v1 < v2, 0 if equal, 1 if v1 > v2 Note: This is primarily for ordering, not semantic versioning

type VersionMismatchError

type VersionMismatchError struct {
	EntityType      string
	EntityID        string
	ExpectedVersion string
	ActualVersion   string
	Message         string
}

VersionMismatchError represents a concurrent modification conflict

func ExtractVersionMismatchError

func ExtractVersionMismatchError(err error) (*VersionMismatchError, bool)

ExtractVersionMismatchError extracts version mismatch details from an error

func (*VersionMismatchError) Error

func (e *VersionMismatchError) Error() string

type VersionedEntity

type VersionedEntity struct {
	ID      string
	Content string
	Version string
}

VersionedEntity represents an entity with version tracking

func NewVersionedEntity

func NewVersionedEntity(id string, content string) *VersionedEntity

NewVersionedEntity creates a versioned entity from content

func (*VersionedEntity) GetVersionShort

func (ve *VersionedEntity) GetVersionShort() string

GetVersionShort returns the shortened version hash

func (*VersionedEntity) UpdateContent

func (ve *VersionedEntity) UpdateContent(newContent string)

UpdateContent updates the entity content and recalculates version

func (*VersionedEntity) ValidateUpdate

func (ve *VersionedEntity) ValidateUpdate(expectedVersion string, entityType string) error

ValidateUpdate checks if an update with the given expected version is valid

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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