Documentation
¶
Index ¶
- func CatalogCategoryToGraphQL(c *catalog.Category) *model.Category
- func CatalogCollectionToGraphQL(c *catalog.Collection) *model.Collection
- func CatalogProductToGraphQL(p *catalog.Product) *model.Product
- func IsVersionMismatchError(err error) bool
- func PaginateCategories(categories []*catalog.Category, first *int32, after *string, last *int32, ...) ([]*catalog.Category, error)
- func PaginateCollections(collections []*catalog.Collection, first *int32, after *string, last *int32, ...) ([]*catalog.Collection, error)
- func PaginateProducts(products []*catalog.Product, first *int32, after *string, last *int32, ...) (*model.ProductConnection, error)
- type CategoryOrderInput
- type Change
- type ChangeType
- type CollectionOrderInput
- type ConflictDetails
- type ConflictDiff
- type CreateCategoryInput
- type CreateCategoryPayload
- type CreateCollectionInput
- type CreateCollectionPayload
- type CreateProductInput
- type CreateProductPayload
- type DeleteCategoryInput
- type DeleteCategoryPayload
- type DeleteCollectionInput
- type DeleteCollectionPayload
- type DeleteProductInput
- type DeleteProductPayload
- type DiffGenerator
- type DiffResult
- type DiffSummary
- type OptimisticLockConflict
- type ProductMutationService
- func (s *ProductMutationService) CreateCategory(ctx context.Context, input CreateCategoryInput) (*CreateCategoryPayload, error)
- func (s *ProductMutationService) CreateCollection(ctx context.Context, input CreateCollectionInput) (*CreateCollectionPayload, error)
- func (s *ProductMutationService) CreateProduct(ctx context.Context, input CreateProductInput) (*CreateProductPayload, error)
- func (s *ProductMutationService) DeleteCategory(ctx context.Context, input DeleteCategoryInput) (*DeleteCategoryPayload, error)
- func (s *ProductMutationService) DeleteCollection(ctx context.Context, input DeleteCollectionInput) (*DeleteCollectionPayload, error)
- func (s *ProductMutationService) DeleteProduct(ctx context.Context, input DeleteProductInput) (*DeleteProductPayload, error)
- func (s *ProductMutationService) PublishCatalog(ctx context.Context, input PublishCatalogInput) (*PublishCatalogPayload, error)
- func (s *ProductMutationService) ReorderCategories(ctx context.Context, input ReorderCategoriesInput) (*ReorderCategoriesPayload, error)
- func (s *ProductMutationService) ReorderCollections(ctx context.Context, input ReorderCollectionsInput) (*ReorderCollectionsPayload, error)
- func (s *ProductMutationService) UpdateCategory(ctx context.Context, input UpdateCategoryInput) (*UpdateCategoryPayload, error)
- func (s *ProductMutationService) UpdateCollection(ctx context.Context, input UpdateCollectionInput) (*UpdateCollectionPayload, error)
- func (s *ProductMutationService) UpdateProduct(ctx context.Context, input UpdateProductInput) (*UpdateProductPayload, error)
- type PublishCatalogInput
- type PublishCatalogPayload
- type ReorderCategoriesInput
- type ReorderCategoriesPayload
- type ReorderCollectionsInput
- type ReorderCollectionsPayload
- type Resolver
- type Service
- func (s *Service) CreateProduct(ctx context.Context, input map[string]interface{}) (*catalog.Product, error)
- func (s *Service) DeleteProduct(ctx context.Context, id string) error
- func (s *Service) GetCatalog(ctx context.Context) (*catalog.Catalog, error)
- func (s *Service) GetCategories(ctx context.Context) ([]*catalog.Category, error)
- func (s *Service) GetCategoryByID(ctx context.Context, id string) (*catalog.Category, error)
- func (s *Service) GetCategoryBySlug(ctx context.Context, slug string) (*catalog.Category, error)
- func (s *Service) GetCollectionByID(ctx context.Context, id string) (*catalog.Collection, error)
- func (s *Service) GetCollectionBySlug(ctx context.Context, slug string) (*catalog.Collection, error)
- func (s *Service) GetCollections(ctx context.Context) ([]*catalog.Collection, error)
- func (s *Service) GetProductByID(ctx context.Context, id string) (*catalog.Product, error)
- func (s *Service) GetProductBySKU(ctx context.Context, sku string) (*catalog.Product, error)
- func (s *Service) GetProducts(ctx context.Context, categoryID *string) ([]*catalog.Product, error)
- func (s *Service) UpdateProduct(ctx context.Context, id string, input map[string]interface{}) (*catalog.Product, error)
- type UpdateCategoryInput
- type UpdateCategoryPayload
- type UpdateCollectionInput
- type UpdateCollectionPayload
- type UpdateProductInput
- type UpdateProductPayload
- type VersionChecker
- func (vc *VersionChecker) CalculateVersion(content string) string
- func (vc *VersionChecker) CalculateVersionShort(content string) string
- func (vc *VersionChecker) CheckVersion(expectedVersion, currentContent, entityType, entityID string) error
- func (vc *VersionChecker) CheckVersionShort(expectedVersion, currentContent, entityType, entityID string) error
- func (vc *VersionChecker) CompareVersions(v1, v2 string) int
- type VersionMismatchError
- type VersionedEntity
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CatalogCategoryToGraphQL ¶
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 ¶
CatalogProductToGraphQL converts a catalog product to a GraphQL product
func IsVersionMismatchError ¶
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)
Types ¶
type CategoryOrderInput ¶
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 ¶
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 ¶
CreateProductPayload represents the payload returned from createProduct
type DeleteCategoryInput ¶
DeleteCategoryInput represents the input for deleting a category
type DeleteCategoryPayload ¶
DeleteCategoryPayload represents the payload returned from deleteCategory
type DeleteCollectionInput ¶
DeleteCollectionInput represents the input for deleting a collection
type DeleteCollectionPayload ¶
DeleteCollectionPayload represents the payload returned from deleteCollection
type DeleteProductInput ¶
DeleteProductInput represents the input for deleting a product
type DeleteProductPayload ¶
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 ¶
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 ¶
func (s *ProductMutationService) CreateCategory(ctx context.Context, input CreateCategoryInput) (*CreateCategoryPayload, error)
CreateCategory creates a new category and commits it to git
func (*ProductMutationService) CreateCollection ¶
func (s *ProductMutationService) CreateCollection(ctx context.Context, input CreateCollectionInput) (*CreateCollectionPayload, error)
CreateCollection creates a new collection and commits it to git
func (*ProductMutationService) CreateProduct ¶
func (s *ProductMutationService) CreateProduct(ctx context.Context, input CreateProductInput) (*CreateProductPayload, error)
CreateProduct creates a new product and commits it to git
func (*ProductMutationService) DeleteCategory ¶
func (s *ProductMutationService) DeleteCategory(ctx context.Context, input DeleteCategoryInput) (*DeleteCategoryPayload, error)
DeleteCategory deletes an existing category
func (*ProductMutationService) DeleteCollection ¶
func (s *ProductMutationService) DeleteCollection(ctx context.Context, input DeleteCollectionInput) (*DeleteCollectionPayload, error)
DeleteCollection deletes an existing collection
func (*ProductMutationService) DeleteProduct ¶
func (s *ProductMutationService) DeleteProduct(ctx context.Context, input DeleteProductInput) (*DeleteProductPayload, error)
DeleteProduct deletes an existing product
func (*ProductMutationService) PublishCatalog ¶
func (s *ProductMutationService) PublishCatalog(ctx context.Context, input PublishCatalogInput) (*PublishCatalogPayload, error)
PublishCatalog commits all changes, pushes to remote, and creates a release tag
func (*ProductMutationService) ReorderCategories ¶
func (s *ProductMutationService) ReorderCategories(ctx context.Context, input ReorderCategoriesInput) (*ReorderCategoriesPayload, error)
ReorderCategories updates the display order of multiple categories in a single transaction
func (*ProductMutationService) ReorderCollections ¶
func (s *ProductMutationService) ReorderCollections(ctx context.Context, input ReorderCollectionsInput) (*ReorderCollectionsPayload, error)
ReorderCollections updates the display order of multiple collections in a single transaction
func (*ProductMutationService) UpdateCategory ¶
func (s *ProductMutationService) UpdateCategory(ctx context.Context, input UpdateCategoryInput) (*UpdateCategoryPayload, error)
UpdateCategory updates an existing category with optimistic locking
func (*ProductMutationService) UpdateCollection ¶
func (s *ProductMutationService) UpdateCollection(ctx context.Context, input UpdateCollectionInput) (*UpdateCollectionPayload, error)
UpdateCollection updates an existing collection with optimistic locking
func (*ProductMutationService) UpdateProduct ¶
func (s *ProductMutationService) UpdateProduct(ctx context.Context, input UpdateProductInput) (*UpdateProductPayload, error)
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 ¶
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 ¶
DeleteProduct deletes a product
func (*Service) GetCatalog ¶
GetCatalog retrieves the current catalog from cache
func (*Service) GetCategories ¶
GetCategories returns all categories
func (*Service) GetCategoryByID ¶
GetCategoryByID returns a category by ID
func (*Service) GetCategoryBySlug ¶
GetCategoryBySlug returns a category by slug
func (*Service) GetCollectionByID ¶
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 ¶
GetCollections returns all collections
func (*Service) GetProductByID ¶
GetProductByID retrieves a product by ID
func (*Service) GetProductBySKU ¶
GetProductBySKU retrieves a product by SKU
func (*Service) GetProducts ¶
GetProducts retrieves all products from catalog with optional filtering
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 ¶
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