Documentation
¶
Overview ¶
Package design provides a client for interacting with the AINative Design API.
The design client enables uploading, retrieving, and managing design tokens that represent design decisions as data (colors, typography, spacing, etc.).
Example usage:
// Create a design client
designClient := design.New(
design.WithAPIClient(apiClient),
design.WithProjectID("my-project"),
)
// Upload tokens
tokens := []*design.Token{
{
Name: "primary-color",
Value: "#007bff",
Type: "color",
Category: "colors",
},
}
result, err := designClient.UploadTokens(ctx, tokens, design.ConflictOverwrite, nil)
if err != nil {
log.Fatal(err)
}
fmt.Printf("Uploaded %d tokens\n", result.UploadedCount)
Index ¶
- type Client
- func (c *Client) DeleteToken(ctx context.Context, tokenName string) error
- func (c *Client) GetTokens(ctx context.Context, types []string, category string, limit, offset int) ([]*design.Token, int, error)
- func (c *Client) UploadTokens(ctx context.Context, tokens []*design.Token, ...) (*UploadTokensResponse, error)
- func (c *Client) ValidateTokens(tokens []*design.Token) *design.ValidationResult
- type DeleteTokenRequest
- type DeleteTokenResponse
- type Option
- type ProgressCallback
- type SyncAdapter
- type TokenQueryRequest
- type TokenQueryResponse
- type UploadTokensRequest
- type UploadTokensResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client represents a client for AINative Design API operations.
func (*Client) DeleteToken ¶
DeleteToken deletes a design token from the AINative Design system.
func (*Client) GetTokens ¶
func (c *Client) GetTokens(ctx context.Context, types []string, category string, limit, offset int) ([]*design.Token, int, error)
GetTokens retrieves design tokens from the AINative Design system.
func (*Client) UploadTokens ¶
func (c *Client) UploadTokens(ctx context.Context, tokens []*design.Token, resolution design.ConflictResolutionStrategyUpload, callback ProgressCallback) (*UploadTokensResponse, error)
UploadTokens uploads design tokens to the AINative Design system.
func (*Client) ValidateTokens ¶
func (c *Client) ValidateTokens(tokens []*design.Token) *design.ValidationResult
ValidateTokens validates a batch of design tokens.
type DeleteTokenRequest ¶
type DeleteTokenRequest struct {
ProjectID string `json:"project_id"`
TokenName string `json:"token_name"`
}
DeleteTokenRequest represents a request to delete a token.
type DeleteTokenResponse ¶
type DeleteTokenResponse struct {
Success bool `json:"success"`
Message string `json:"message,omitempty"`
}
DeleteTokenResponse represents the response from deleting a token.
type Option ¶
type Option func(*Client)
Option is a functional option for configuring the Client.
func WithAPIClient ¶
WithAPIClient sets the underlying HTTP API client.
func WithProjectID ¶
WithProjectID sets the project ID for design operations.
type ProgressCallback ¶
type ProgressCallback func(uploaded, total int)
ProgressCallback is called during upload to report progress.
type SyncAdapter ¶
type SyncAdapter struct {
// contains filtered or unexported fields
}
SyncAdapter adapts the Design API client to the sync.DesignClient interface. This adapter bridges the gap between the HTTP client API and the sync engine's expectations.
func NewSyncAdapter ¶
func NewSyncAdapter(client *Client, projectID string) *SyncAdapter
NewSyncAdapter creates a new sync adapter wrapping the design client.
func (*SyncAdapter) DeleteToken ¶
DeleteToken deletes a design token from the remote project. This method implements the sync.DesignClient interface.
func (*SyncAdapter) GetTokens ¶
GetTokens retrieves all design tokens for the project. This method implements the sync.DesignClient interface.
func (*SyncAdapter) UploadTokens ¶
func (a *SyncAdapter) UploadTokens(ctx context.Context, projectID string, tokens []design.Token) error
UploadTokens uploads design tokens to the remote project. This method implements the sync.DesignClient interface.
type TokenQueryRequest ¶
type TokenQueryRequest struct {
ProjectID string `json:"project_id"`
Types []string `json:"types,omitempty"`
Category string `json:"category,omitempty"`
Limit int `json:"limit,omitempty"`
Offset int `json:"offset,omitempty"`
}
TokenQueryRequest represents a request to query tokens.
type TokenQueryResponse ¶
TokenQueryResponse represents the response from querying tokens.
type UploadTokensRequest ¶
type UploadTokensRequest struct {
ProjectID string `json:"project_id"`
Tokens []*design.Token `json:"tokens"`
ConflictResolution design.ConflictResolutionStrategyUpload `json:"conflict_resolution"`
}
UploadTokensRequest represents a request to upload design tokens.
type UploadTokensResponse ¶
type UploadTokensResponse struct {
Success bool `json:"success"`
UploadedCount int `json:"uploaded_count"`
SkippedCount int `json:"skipped_count"`
UpdatedCount int `json:"updated_count"`
Message string `json:"message,omitempty"`
}
UploadTokensResponse represents the response from uploading tokens.