design

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2026 License: MIT Imports: 6 Imported by: 0

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

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 New

func New(opts ...Option) *Client

New creates a new Design client with the specified options.

func (*Client) DeleteToken

func (c *Client) DeleteToken(ctx context.Context, tokenName string) error

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

func WithAPIClient(apiClient *client.Client) Option

WithAPIClient sets the underlying HTTP API client.

func WithProjectID

func WithProjectID(projectID string) Option

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

func (a *SyncAdapter) DeleteToken(ctx context.Context, projectID string, tokenName string) error

DeleteToken deletes a design token from the remote project. This method implements the sync.DesignClient interface.

func (*SyncAdapter) GetTokens

func (a *SyncAdapter) GetTokens(ctx context.Context, projectID string) ([]design.Token, error)

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

type TokenQueryResponse struct {
	Tokens []*design.Token `json:"tokens"`
	Total  int             `json:"total"`
}

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.

Jump to

Keyboard shortcuts

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