workers

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CloudflareClient

type CloudflareClient interface {
	RunAPI(method, endpoint, body string) (string, error)
	RunAPIWithContext(ctx context.Context, method, endpoint, body string) (string, error)
	RunWrangler(args ...string) (string, error)
	RunWranglerWithContext(ctx context.Context, args ...string) (string, error)
	GetAccountID() string
}

CloudflareClient defines the interface for Cloudflare operations

type Command

type Command struct {
	Args     []string          `json:"args"`
	Reason   string            `json:"reason"`
	Produces map[string]string `json:"produces,omitempty"`
}

Command represents a single Workers command (maker-compatible format)

type D1Database

type D1Database struct {
	UUID      string    `json:"uuid"`
	Name      string    `json:"name"`
	Version   string    `json:"version,omitempty"`
	NumTables int       `json:"num_tables,omitempty"`
	FileSize  int64     `json:"file_size,omitempty"`
	CreatedAt time.Time `json:"created_at,omitempty"`
}

D1Database represents a D1 database

type KVNamespace

type KVNamespace struct {
	ID                  string `json:"id"`
	Title               string `json:"title"`
	SupportsURLEncoding bool   `json:"supports_url_encoding,omitempty"`
}

KVNamespace represents a Workers KV namespace

type PagesDeployment

type PagesDeployment struct {
	ID          string    `json:"id"`
	Environment string    `json:"environment"` // production, preview
	URL         string    `json:"url"`
	CreatedOn   time.Time `json:"created_on,omitempty"`
	ModifiedOn  time.Time `json:"modified_on,omitempty"`
}

PagesDeployment represents a Pages deployment

type PagesProject

type PagesProject struct {
	ID               string           `json:"id"`
	Name             string           `json:"name"`
	Subdomain        string           `json:"subdomain"`
	ProductionBranch string           `json:"production_branch,omitempty"`
	CreatedOn        time.Time        `json:"created_on,omitempty"`
	Domains          []string         `json:"domains,omitempty"`
	Source           *PagesSource     `json:"source,omitempty"`
	LatestDeployment *PagesDeployment `json:"latest_deployment,omitempty"`
}

PagesProject represents a Cloudflare Pages project

type PagesSource

type PagesSource struct {
	Type   string             `json:"type"` // github, gitlab, etc.
	Config *PagesSourceConfig `json:"config,omitempty"`
}

PagesSource represents the source configuration for a Pages project

type PagesSourceConfig

type PagesSourceConfig struct {
	Owner              string `json:"owner,omitempty"`
	RepoName           string `json:"repo_name,omitempty"`
	ProductionBranch   string `json:"production_branch,omitempty"`
	DeploymentsEnabled bool   `json:"deployments_enabled,omitempty"`
}

PagesSourceConfig contains source-specific configuration

type Plan

type Plan struct {
	Version   int       `json:"version"`
	CreatedAt string    `json:"createdAt"`
	Provider  string    `json:"provider"`
	Question  string    `json:"question,omitempty"`
	Summary   string    `json:"summary"`
	Commands  []Command `json:"commands"`
	Notes     []string  `json:"notes,omitempty"`
}

Plan represents a Workers modification plan (maker-compatible format)

type QueryAnalysis

type QueryAnalysis struct {
	IsReadOnly   bool
	Operation    string // list, get, create, delete, deploy
	ResourceType string // worker, kv, d1, r2, pages
	ResourceName string
}

QueryAnalysis contains the result of analyzing a Workers query

type QueryOptions

type QueryOptions struct {
	AccountID string `json:"account_id,omitempty"`
}

QueryOptions contains options for Workers queries

type R2Bucket

type R2Bucket struct {
	Name         string    `json:"name"`
	CreationDate time.Time `json:"creation_date,omitempty"`
	Location     string    `json:"location,omitempty"`
}

R2Bucket represents an R2 storage bucket

type Response

type Response struct {
	Type    ResponseType `json:"type"`
	Result  string       `json:"result,omitempty"`
	Plan    *Plan        `json:"plan,omitempty"`
	Error   error        `json:"error,omitempty"`
	Message string       `json:"message,omitempty"`
}

Response represents the result of a Workers operation

type ResponseType

type ResponseType string

ResponseType indicates the type of response

const (
	ResponseTypeResult ResponseType = "result"
	ResponseTypePlan   ResponseType = "plan"
	ResponseTypeError  ResponseType = "error"
)

type SubAgent

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

SubAgent handles Workers-related operations

func NewSubAgent

func NewSubAgent(client CloudflareClient, debug bool) *SubAgent

NewSubAgent creates a new Workers sub-agent

func (*SubAgent) HandleQuery

func (s *SubAgent) HandleQuery(ctx context.Context, query string, opts QueryOptions) (*Response, error)

HandleQuery processes Workers-related queries

type Worker

type Worker struct {
	ID         string          `json:"id"`
	Name       string          `json:"script_name,omitempty"`
	Etag       string          `json:"etag,omitempty"`
	Size       int             `json:"size,omitempty"`
	Handlers   []string        `json:"handlers,omitempty"`
	CreatedOn  time.Time       `json:"created_on,omitempty"`
	ModifiedOn time.Time       `json:"modified_on,omitempty"`
	Bindings   []WorkerBinding `json:"bindings,omitempty"`
}

Worker represents a Cloudflare Worker

type WorkerBinding

type WorkerBinding struct {
	Name string `json:"name"`
	Type string `json:"type"` // kv_namespace, r2_bucket, d1, durable_object, etc.
}

WorkerBinding represents a binding to a Worker

Jump to

Keyboard shortcuts

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