Documentation
¶
Index ¶
- Constants
- type AMSState
- type AMSTray
- type AMSUnit
- type ActorType
- type Address
- type Alert
- type AlertDismissal
- type AlertSeverity
- type AlertType
- type AutoDispatchSettings
- type BambuCloudAuth
- type BroadcastEvent
- type Broadcaster
- type BuildVolume
- type ColorSpec
- type ConnectionType
- type CostBreakdown
- type Customer
- type CustomerFilters
- type Design
- type DiscountType
- type DispatchRequest
- type DispatchRequestStatus
- type EtsyIntegration
- type EtsyListing
- type EtsyListingTemplate
- type EtsyOAuthState
- type EtsyReceipt
- type EtsyReceiptItem
- type EtsySyncState
- type EtsyWebhookEvent
- type Expense
- type ExpenseCategory
- type ExpenseItem
- type ExpenseItemAction
- type ExpenseStatus
- type FailureCategory
- type Feedback
- type FilamentMetadata
- type FilamentUsage
- type File
- type FileType
- type HMSError
- type JobEvent
- func (e *JobEvent) WithActor(actorType ActorType, actorID string) *JobEvent
- func (e *JobEvent) WithError(code, message string) *JobEvent
- func (e *JobEvent) WithMetadata(metadata map[string]interface{}) *JobEvent
- func (e *JobEvent) WithPrinter(printerID uuid.UUID) *JobEvent
- func (e *JobEvent) WithProgress(progress float64) *JobEvent
- type JobEventType
- type LightState
- type Material
- type MaterialSnapshot
- type MaterialSpool
- type MaterialType
- type MaterialValidation
- type Order
- type OrderEvent
- type OrderFilters
- type OrderItem
- type OrderProgress
- type OrderSource
- type OrderStatus
- type ParsedReceipt
- type ParsedReceiptItem
- type Part
- type PartStatus
- type PrintEvent
- type PrintEventType
- type PrintJob
- type PrintJobStatus
- type PrintOutcome
- type PrintProfile
- type Printer
- type PrinterAnalytics
- type PrinterConstraints
- type PrinterHealth
- type PrinterROI
- type PrinterState
- type PrinterStatus
- type PrinterUtilization
- type Project
- type ProjectSummary
- type ProjectSupply
- type Quote
- type QuoteEvent
- type QuoteFilters
- type QuoteLineItem
- type QuoteLineItemType
- type QuoteOption
- type QuoteStatus
- type RecipeCostEstimate
- type RecipeMaterial
- type RecipeMaterialCostBreakdown
- type RecipeSupply
- type RecipeSupplyCostBreakdown
- type Sale
- type SalesChannel
- type ShopifyCredentials
- type ShopifyIntegrationStatus
- type ShopifyOrder
- type ShopifyOrderItem
- type ShopifyProductTemplate
- type SliceProfileData
- type SpoolStatus
- type SquarespaceAddress
- type SquarespaceIntegration
- type SquarespaceOrder
- type SquarespaceOrderItem
- type SquarespaceProduct
- type SquarespaceProductTemplate
- type SquarespaceProductVariant
- type SyncResult
- type Tag
- type Task
- type TaskChecklistItem
- type TaskFilters
- type TaskStatus
- type TempRange
- type Template
- type TemplateAnalytics
- type TemplateDesign
- type TimelineItem
Constants ¶
const ( EtsyEventReceiptCreated = "receipt.created" EtsyEventReceiptUpdated = "receipt.updated" EtsyEventListingUpdated = "listing.updated" EtsyEventListingInventoryUpdated = "listing.inventory.updated" )
EtsyWebhookEventType constants for webhook events.
const ( EventJobCreated = JobEventQueued EventJobStarted = JobEventStarted EventJobProgress = JobEventProgress EventJobPaused = JobEventPaused EventJobResumed = JobEventResumed EventJobCompleted = JobEventCompleted EventJobFailed = JobEventFailed EventJobCancelled = JobEventCancelled )
Legacy constants for backward compatibility
const ( EventPrinterStateUpdated = "printer_state_updated" EventPrinterConnected = "printer_connected" EventPrinterDisconnected = "printer_disconnected" )
WebSocket event types for real-time updates.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AMSState ¶
type AMSState struct {
Units []AMSUnit `json:"units"`
CurrentTray string `json:"current_tray,omitempty"`
ExternalSpool *AMSTray `json:"external_spool,omitempty"`
}
AMSState represents the complete AMS (Automatic Material System) state.
type AMSTray ¶
type AMSTray struct {
ID int `json:"id"`
MaterialType string `json:"material_type"`
Color string `json:"color"`
ColorHex string `json:"color_hex,omitempty"`
Remain int `json:"remain"` // Remaining percentage (0-100)
TagUID string `json:"tag_uid,omitempty"`
Brand string `json:"brand,omitempty"`
NozzleTempMin int `json:"nozzle_temp_min,omitempty"`
NozzleTempMax int `json:"nozzle_temp_max,omitempty"`
BedTemp int `json:"bed_temp,omitempty"`
Empty bool `json:"empty"`
}
AMSTray represents a single tray/slot in an AMS unit.
type AMSUnit ¶
type AMSUnit struct {
ID int `json:"id"`
Humidity int `json:"humidity"`
Temp float64 `json:"temp"`
Trays []AMSTray `json:"trays"`
}
AMSUnit represents a single AMS unit (typically holds 4 trays).
type Address ¶
type Address struct {
Line1 string `json:"line1,omitempty"`
Line2 string `json:"line2,omitempty"`
City string `json:"city,omitempty"`
State string `json:"state,omitempty"`
Zip string `json:"zip,omitempty"`
Country string `json:"country,omitempty"`
}
Address is a reusable struct for billing/shipping addresses, stored as JSON TEXT in SQLite.
type Alert ¶
type Alert struct {
ID string `json:"id"`
Type AlertType `json:"type"`
Severity AlertSeverity `json:"severity"`
EntityID uuid.UUID `json:"entity_id"`
EntityType string `json:"entity_type"` // "spool", "order", "job"
Message string `json:"message"`
CreatedAt time.Time `json:"created_at"`
DismissedUntil *time.Time `json:"dismissed_until,omitempty"`
}
Alert represents a system alert for user attention.
type AlertDismissal ¶
type AlertDismissal struct {
ID uuid.UUID `json:"id"`
AlertType AlertType `json:"alert_type"`
EntityID string `json:"entity_id"`
DismissedAt time.Time `json:"dismissed_at"`
DismissedUntil *time.Time `json:"dismissed_until,omitempty"`
}
AlertDismissal records when a user dismissed an alert.
type AlertSeverity ¶
type AlertSeverity string
AlertSeverity indicates how urgent an alert is.
const ( AlertSeverityInfo AlertSeverity = "info" AlertSeverityWarning AlertSeverity = "warning" AlertSeverityCritical AlertSeverity = "critical" )
type AutoDispatchSettings ¶
type AutoDispatchSettings struct {
PrinterID uuid.UUID `json:"printer_id"`
Enabled bool `json:"enabled"`
RequireConfirmation bool `json:"require_confirmation"`
AutoStart bool `json:"auto_start"`
TimeoutMinutes int `json:"timeout_minutes"`
UpdatedAt time.Time `json:"updated_at"`
}
AutoDispatchSettings holds per-printer auto-dispatch configuration.
type BambuCloudAuth ¶
type BambuCloudAuth struct {
ID uuid.UUID `json:"id"`
Email string `json:"email"`
AccessToken string `json:"access_token"`
RefreshToken string `json:"refresh_token,omitempty"`
MQTTUsername string `json:"mqtt_username"`
ExpiresAt *time.Time `json:"expires_at,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
BambuCloudAuth stores authentication credentials for Bambu Cloud API.
func (*BambuCloudAuth) CanRefresh ¶
func (a *BambuCloudAuth) CanRefresh() bool
CanRefresh returns true if a refresh token is available.
type BroadcastEvent ¶
type BroadcastEvent struct {
Type string `json:"type"`
Data interface{} `json:"data"`
}
BroadcastEvent represents an event to be sent to WebSocket clients.
type Broadcaster ¶
type Broadcaster interface {
Broadcast(event BroadcastEvent)
}
Broadcaster defines the interface for broadcasting real-time events. This interface allows the printer package to broadcast without importing realtime.
type BuildVolume ¶
BuildVolume represents the print area dimensions.
type ColorSpec ¶
type ColorSpec struct {
Mode string `json:"mode"` // "exact", "category", "any"
Hex string `json:"hex,omitempty"`
Name string `json:"name,omitempty"`
}
ColorSpec defines how to match material color.
type ConnectionType ¶
type ConnectionType string
ConnectionType represents how a printer is connected.
const ( ConnectionTypeManual ConnectionType = "manual" ConnectionTypeOctoPrint ConnectionType = "octoprint" ConnectionTypeBambuLAN ConnectionType = "bambu_lan" ConnectionTypeBambuCloud ConnectionType = "bambu_cloud" ConnectionTypeMoonraker ConnectionType = "moonraker" ConnectionTypeChiTu ConnectionType = "chitu" // Elegoo, Anycubic, Phrozen resin printers )
type CostBreakdown ¶
type CostBreakdown struct {
MaterialCostCents int `json:"material_cost_cents"`
LaborCostCents int `json:"labor_cost_cents"`
TotalCostCents int `json:"total_cost_cents"`
SalePriceCents int `json:"sale_price_cents"`
GrossMarginCents int `json:"gross_margin_cents"`
GrossMarginPercent float64 `json:"gross_margin_percent"`
// Breakdown details
MaterialGrams float64 `json:"material_grams"`
PrintTimeMinutes int `json:"print_time_minutes"`
LaborMinutes int `json:"labor_minutes"`
}
CostBreakdown contains the cost and margin breakdown for a recipe/order.
type Customer ¶
type Customer struct {
ID uuid.UUID `json:"id"`
Name string `json:"name"`
Email string `json:"email,omitempty"`
Company string `json:"company,omitempty"`
Phone string `json:"phone,omitempty"`
Notes string `json:"notes,omitempty"`
BillingAddress *Address `json:"billing_address,omitempty"`
ShippingAddress *Address `json:"shipping_address,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
Customer represents a customer for quotes and orders.
type CustomerFilters ¶
type CustomerFilters struct {
Search string `json:"search,omitempty"`
Limit int `json:"limit,omitempty"`
Offset int `json:"offset,omitempty"`
}
CustomerFilters defines filter options for listing customers.
type Design ¶
type Design struct {
ID uuid.UUID `json:"id"`
PartID uuid.UUID `json:"part_id"`
Version int `json:"version"`
FileID uuid.UUID `json:"file_id"`
FileName string `json:"file_name"`
FileHash string `json:"file_hash"`
FileSizeBytes int64 `json:"file_size_bytes"`
FileType FileType `json:"file_type"`
Notes string `json:"notes"`
SliceProfile json.RawMessage `json:"slice_profile,omitempty"`
CreatedAt time.Time `json:"created_at"`
Tags []Tag `json:"tags,omitempty"`
}
Design represents a versioned design file for a part.
type DiscountType ¶
type DiscountType string
DiscountType represents the type of discount applied to a quote.
const ( DiscountTypeNone DiscountType = "none" DiscountTypeFlat DiscountType = "flat" DiscountTypePercent DiscountType = "percent" )
type DispatchRequest ¶
type DispatchRequest struct {
ID uuid.UUID `json:"id"`
JobID uuid.UUID `json:"job_id"`
PrinterID uuid.UUID `json:"printer_id"`
Status DispatchRequestStatus `json:"status"`
CreatedAt time.Time `json:"created_at"`
ExpiresAt time.Time `json:"expires_at"`
RespondedAt *time.Time `json:"responded_at,omitempty"`
Reason string `json:"reason,omitempty"`
Job *PrintJob `json:"job,omitempty"`
Printer *Printer `json:"printer,omitempty"`
}
DispatchRequest represents a pending dispatch request awaiting operator confirmation.
type DispatchRequestStatus ¶
type DispatchRequestStatus string
DispatchRequestStatus represents the status of a dispatch request.
const ( DispatchPending DispatchRequestStatus = "pending" DispatchConfirmed DispatchRequestStatus = "confirmed" DispatchRejected DispatchRequestStatus = "rejected" DispatchExpired DispatchRequestStatus = "expired" )
type EtsyIntegration ¶
type EtsyIntegration struct {
ID uuid.UUID `json:"id"`
ShopID int64 `json:"shop_id"`
ShopName string `json:"shop_name"`
UserID int64 `json:"user_id"`
AccessToken string `json:"-"` // Never expose
RefreshToken string `json:"-"` // Never expose
TokenExpiresAt time.Time `json:"token_expires_at"`
Scopes []string `json:"scopes"`
IsActive bool `json:"is_active"`
LastSyncAt *time.Time `json:"last_sync_at,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
EtsyIntegration represents the connected Etsy shop.
type EtsyListing ¶
type EtsyListing struct {
ID uuid.UUID `json:"id"`
EtsyListingID int64 `json:"etsy_listing_id"`
EtsyShopID int64 `json:"etsy_shop_id"`
Title string `json:"title"`
Description string `json:"description,omitempty"`
State string `json:"state"`
Quantity int `json:"quantity"`
URL string `json:"url,omitempty"`
Views int `json:"views"`
NumFavorers int `json:"num_favorers"`
IsCustomizable bool `json:"is_customizable"`
IsPersonalizable bool `json:"is_personalizable"`
Tags json.RawMessage `json:"tags,omitempty"`
HasVariations bool `json:"has_variations"`
PriceCents int `json:"price_cents,omitempty"`
Currency string `json:"currency"`
SKUs json.RawMessage `json:"skus,omitempty"`
SyncedAt time.Time `json:"synced_at"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
LinkedTemplate *Template `json:"linked_template,omitempty"`
}
EtsyListing represents a listing from Etsy.
type EtsyListingTemplate ¶
type EtsyListingTemplate struct {
ID uuid.UUID `json:"id"`
EtsyListingID int64 `json:"etsy_listing_id"`
TemplateID uuid.UUID `json:"template_id"`
SKU string `json:"sku,omitempty"`
SyncInventory bool `json:"sync_inventory"`
CreatedAt time.Time `json:"created_at"`
}
EtsyListingTemplate links an Etsy listing to a template.
type EtsyOAuthState ¶
type EtsyOAuthState struct {
State string
CodeVerifier string
RedirectURI string
CreatedAt time.Time
}
EtsyOAuthState stores pending OAuth state for PKCE verification.
type EtsyReceipt ¶
type EtsyReceipt struct {
ID uuid.UUID `json:"id"`
EtsyReceiptID int64 `json:"etsy_receipt_id"`
EtsyShopID int64 `json:"etsy_shop_id"`
BuyerUserID int64 `json:"buyer_user_id,omitempty"`
BuyerEmail string `json:"buyer_email,omitempty"`
Name string `json:"name"`
Status string `json:"status"`
MessageFromBuyer string `json:"message_from_buyer,omitempty"`
IsShipped bool `json:"is_shipped"`
IsPaid bool `json:"is_paid"`
IsGift bool `json:"is_gift"`
GiftMessage string `json:"gift_message,omitempty"`
GrandtotalCents int `json:"grandtotal_cents"`
SubtotalCents int `json:"subtotal_cents"`
TotalPriceCents int `json:"total_price_cents"`
TotalShippingCostCents int `json:"total_shipping_cost_cents"`
TotalTaxCostCents int `json:"total_tax_cost_cents"`
DiscountCents int `json:"discount_cents"`
Currency string `json:"currency"`
ShippingName string `json:"shipping_name,omitempty"`
ShippingAddressFirstLine string `json:"shipping_address_first_line,omitempty"`
ShippingAddressSecondLine string `json:"shipping_address_second_line,omitempty"`
ShippingCity string `json:"shipping_city,omitempty"`
ShippingState string `json:"shipping_state,omitempty"`
ShippingZip string `json:"shipping_zip,omitempty"`
ShippingCountryCode string `json:"shipping_country_code,omitempty"`
CreateTimestamp *time.Time `json:"create_timestamp,omitempty"`
UpdateTimestamp *time.Time `json:"update_timestamp,omitempty"`
IsProcessed bool `json:"is_processed"`
ProjectID *uuid.UUID `json:"project_id,omitempty"`
SyncedAt time.Time `json:"synced_at"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
Items []EtsyReceiptItem `json:"items,omitempty"`
}
EtsyReceipt represents an order/receipt from Etsy.
type EtsyReceiptItem ¶
type EtsyReceiptItem struct {
ID uuid.UUID `json:"id"`
EtsyReceiptItemID int64 `json:"etsy_receipt_item_id"`
ReceiptID uuid.UUID `json:"receipt_id"`
EtsyListingID int64 `json:"etsy_listing_id"`
EtsyTransactionID int64 `json:"etsy_transaction_id"`
Title string `json:"title"`
Description string `json:"description,omitempty"`
Quantity int `json:"quantity"`
PriceCents int `json:"price_cents"`
ShippingCostCents int `json:"shipping_cost_cents"`
SKU string `json:"sku,omitempty"`
Variations json.RawMessage `json:"variations,omitempty"`
IsDigital bool `json:"is_digital"`
TemplateID *uuid.UUID `json:"template_id,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
EtsyReceiptItem represents a line item in an Etsy receipt.
type EtsySyncState ¶
type EtsySyncState struct {
ID uuid.UUID `json:"id"`
ShopID int64 `json:"shop_id"`
LastReceiptSyncAt *time.Time `json:"last_receipt_sync_at,omitempty"`
LastListingSyncAt *time.Time `json:"last_listing_sync_at,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
EtsySyncState tracks the last sync timestamps for a shop.
type EtsyWebhookEvent ¶
type EtsyWebhookEvent struct {
ID uuid.UUID `json:"id"`
EventType string `json:"event_type"`
ResourceType string `json:"resource_type"`
ResourceID int64 `json:"resource_id,omitempty"`
ShopID int64 `json:"shop_id,omitempty"`
Payload json.RawMessage `json:"payload"`
Signature string `json:"signature,omitempty"`
Processed bool `json:"processed"`
ProcessedAt *time.Time `json:"processed_at,omitempty"`
Error string `json:"error,omitempty"`
ReceivedAt time.Time `json:"received_at"`
CreatedAt time.Time `json:"created_at"`
}
EtsyWebhookEvent represents a webhook event from Etsy.
type Expense ¶
type Expense struct {
ID uuid.UUID `json:"id"`
OccurredAt time.Time `json:"occurred_at"`
Vendor string `json:"vendor"`
SubtotalCents int `json:"subtotal_cents"`
TaxCents int `json:"tax_cents"`
ShippingCents int `json:"shipping_cents"`
TotalCents int `json:"total_cents"`
Currency string `json:"currency"`
Category ExpenseCategory `json:"category"`
Notes string `json:"notes"`
ReceiptFileID *uuid.UUID `json:"receipt_file_id,omitempty"`
ReceiptFilePath string `json:"receipt_file_path,omitempty"`
Status ExpenseStatus `json:"status"`
RawOCRText string `json:"raw_ocr_text,omitempty"`
RawAIResponse json.RawMessage `json:"raw_ai_response,omitempty"`
Confidence int `json:"confidence"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
// Joined data
Items []ExpenseItem `json:"items,omitempty"`
}
Expense represents an expense record.
type ExpenseCategory ¶
type ExpenseCategory string
ExpenseCategory represents categories for expenses.
const ( ExpenseCategoryFilament ExpenseCategory = "filament" ExpenseCategoryParts ExpenseCategory = "parts" ExpenseCategoryTools ExpenseCategory = "tools" ExpenseCategoryShipping ExpenseCategory = "shipping" ExpenseCategoryMarketplaceFees ExpenseCategory = "marketplace_fees" ExpenseCategorySubscription ExpenseCategory = "subscription" ExpenseCategoryAdvertising ExpenseCategory = "advertising" ExpenseCategoryOther ExpenseCategory = "other" )
type ExpenseItem ¶
type ExpenseItem struct {
ID uuid.UUID `json:"id"`
ExpenseID uuid.UUID `json:"expense_id"`
Description string `json:"description"`
Quantity float64 `json:"quantity"`
UnitPriceCents int `json:"unit_price_cents"`
TotalPriceCents int `json:"total_price_cents"`
SKU string `json:"sku,omitempty"`
VendorItemID string `json:"vendor_item_id,omitempty"`
Category ExpenseCategory `json:"category"`
Metadata *FilamentMetadata `json:"metadata,omitempty"`
MatchedSpoolID *uuid.UUID `json:"matched_spool_id,omitempty"`
MatchedMaterialID *uuid.UUID `json:"matched_material_id,omitempty"`
Confidence int `json:"confidence"`
ActionTaken ExpenseItemAction `json:"action_taken"`
CreatedAt time.Time `json:"created_at"`
}
ExpenseItem represents a line item in an expense.
type ExpenseItemAction ¶
type ExpenseItemAction string
ExpenseItemAction represents what action was taken for an expense item.
const ( ExpenseItemActionNone ExpenseItemAction = "none" ExpenseItemActionCreatedSpool ExpenseItemAction = "created_spool" ExpenseItemActionMatchedSpool ExpenseItemAction = "matched_spool" ExpenseItemActionSkipped ExpenseItemAction = "skipped" ExpenseItemActionCreatedSupply ExpenseItemAction = "created_supply" )
type ExpenseStatus ¶
type ExpenseStatus string
ExpenseStatus represents the status of an expense record.
const ( ExpenseStatusPending ExpenseStatus = "pending" ExpenseStatusConfirmed ExpenseStatus = "confirmed" ExpenseStatusRejected ExpenseStatus = "rejected" )
type FailureCategory ¶
type FailureCategory string
FailureCategory categorizes why a print job failed.
const ( FailureMechanical FailureCategory = "mechanical" // printer hardware issue FailureFilament FailureCategory = "filament" // filament jam, runout, tangle FailureAdhesion FailureCategory = "adhesion" // bed adhesion failure FailureThermal FailureCategory = "thermal" // thermal runaway, heating failure FailureNetwork FailureCategory = "network" // connection lost during print FailureUserCancelled FailureCategory = "user_cancelled" // user stopped the print FailureUnknown FailureCategory = "unknown" // unclassified failure )
type Feedback ¶
type Feedback struct {
ID uuid.UUID `json:"id"`
Type string `json:"type"`
Message string `json:"message"`
Contact string `json:"contact,omitempty"`
Page string `json:"page,omitempty"`
AppVersion string `json:"app_version,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
Feedback represents a beta feedback submission.
type FilamentMetadata ¶
type FilamentMetadata struct {
Brand string `json:"brand,omitempty"`
MaterialType string `json:"material_type,omitempty"` // PLA, PETG, ABS, etc.
Color string `json:"color,omitempty"`
ColorHex string `json:"color_hex,omitempty"`
WeightGrams float64 `json:"weight_grams,omitempty"`
DiameterMM float64 `json:"diameter_mm,omitempty"`
}
FilamentMetadata holds parsed attributes for filament items.
type FilamentUsage ¶
type FilamentUsage struct {
Type string `json:"type"`
Color string `json:"color"`
UsedGrams float64 `json:"used_grams"`
UsedMeters float64 `json:"used_meters"`
}
FilamentUsage represents filament usage data from a slice profile.
type File ¶
type File struct {
ID uuid.UUID `json:"id"`
Hash string `json:"hash"`
OriginalName string `json:"original_name"`
ContentType string `json:"content_type"`
SizeBytes int64 `json:"size_bytes"`
StoragePath string `json:"storage_path"`
CreatedAt time.Time `json:"created_at"`
}
File represents a stored file.
type HMSError ¶
type HMSError struct {
Attr int `json:"attr"`
Code int `json:"code"`
Module int `json:"module"`
Severity int `json:"severity"`
}
HMSError represents a Health Management System error from the printer.
type JobEvent ¶
type JobEvent struct {
ID uuid.UUID `json:"id"`
JobID uuid.UUID `json:"job_id"`
EventType JobEventType `json:"event_type"`
OccurredAt time.Time `json:"occurred_at"`
// Status context
Status *PrintJobStatus `json:"status,omitempty"` // resulting status (nil for progress events)
Progress *float64 `json:"progress,omitempty"` // progress at time of event
// Printer context (for assignment/transfer)
PrinterID *uuid.UUID `json:"printer_id,omitempty"`
// Error context (for failures)
ErrorCode string `json:"error_code,omitempty"`
ErrorMessage string `json:"error_message,omitempty"`
// Actor tracking
ActorType ActorType `json:"actor_type"`
ActorID string `json:"actor_id,omitempty"`
// Flexible metadata
Metadata map[string]interface{} `json:"metadata,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
JobEvent represents an immutable event in the print job lifecycle. These are append-only records that form the complete history of a job.
func NewJobEvent ¶
func NewJobEvent(jobID uuid.UUID, eventType JobEventType, status *PrintJobStatus) *JobEvent
NewJobEvent creates a new job event with sensible defaults.
func (*JobEvent) WithMetadata ¶
WithMetadata sets metadata on the event.
func (*JobEvent) WithPrinter ¶
WithPrinter sets the printer context on the event.
func (*JobEvent) WithProgress ¶
WithProgress sets the progress on the event.
type JobEventType ¶
type JobEventType string
JobEventType represents types of job events.
const ( JobEventQueued JobEventType = "queued" // job created and waiting JobEventAssigned JobEventType = "assigned" // assigned to a printer JobEventUploaded JobEventType = "uploaded" // file sent to printer JobEventStarted JobEventType = "started" // print started JobEventProgress JobEventType = "progress" // progress update (no status change) JobEventPaused JobEventType = "paused" // print paused JobEventResumed JobEventType = "resumed" // print resumed JobEventCompleted JobEventType = "completed" // print finished successfully JobEventFailed JobEventType = "failed" // print failed JobEventCancelled JobEventType = "cancelled" // print cancelled by user/system JobEventRetried JobEventType = "retried" // new job created as retry )
type LightState ¶
LightState represents the state of a printer light.
type Material ¶
type Material struct {
ID uuid.UUID `json:"id"`
Name string `json:"name"`
Type MaterialType `json:"type"`
Manufacturer string `json:"manufacturer"`
Color string `json:"color"`
ColorHex string `json:"color_hex"`
Density float64 `json:"density"`
CostPerKg float64 `json:"cost_per_kg"`
PrintTemp *TempRange `json:"print_temp,omitempty"`
BedTemp *TempRange `json:"bed_temp,omitempty"`
Notes string `json:"notes"`
LowThresholdGrams int `json:"low_threshold_grams"` // Alert when spool falls below this
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
Material represents a type of printing material in the catalog.
type MaterialSnapshot ¶
type MaterialSnapshot struct {
CapturedAt time.Time `json:"captured_at"`
SelectedTray int `json:"selected_tray"`
MaterialType string `json:"material_type"`
Color string `json:"color"`
RemainPercent int `json:"remain_percent"`
Brand string `json:"brand,omitempty"`
AMSState *AMSState `json:"ams_state,omitempty"`
}
MaterialSnapshot captures the AMS state at job start for auditing.
type MaterialSpool ¶
type MaterialSpool struct {
ID uuid.UUID `json:"id"`
MaterialID uuid.UUID `json:"material_id"`
InitialWeight float64 `json:"initial_weight"`
RemainingWeight float64 `json:"remaining_weight"`
PurchaseDate *time.Time `json:"purchase_date,omitempty"`
PurchaseCost float64 `json:"purchase_cost"`
Location string `json:"location"`
Status SpoolStatus `json:"status"`
Notes string `json:"notes"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
MaterialSpool represents a physical spool of material (inventory).
type MaterialType ¶
type MaterialType string
MaterialType represents the type of printing material.
const ( MaterialTypePLA MaterialType = "pla" MaterialTypePETG MaterialType = "petg" MaterialTypeABS MaterialType = "abs" MaterialTypeASA MaterialType = "asa" MaterialTypeTPU MaterialType = "tpu" MaterialTypeSupply MaterialType = "supply" )
type MaterialValidation ¶
type MaterialValidation struct {
Valid bool `json:"valid"`
Warnings []string `json:"warnings,omitempty"`
Errors []string `json:"errors,omitempty"`
}
MaterialValidation contains the result of pre-start material checks.
type Order ¶
type Order struct {
ID uuid.UUID `json:"id"`
Source OrderSource `json:"source"`
SourceOrderID string `json:"source_order_id,omitempty"`
CustomerID *uuid.UUID `json:"customer_id,omitempty"`
CustomerName string `json:"customer_name"`
CustomerEmail string `json:"customer_email,omitempty"`
Status OrderStatus `json:"status"`
Priority int `json:"priority"`
DueDate *time.Time `json:"due_date,omitempty"`
Notes string `json:"notes,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
CompletedAt *time.Time `json:"completed_at,omitempty"`
ShippedAt *time.Time `json:"shipped_at,omitempty"`
Items []OrderItem `json:"items,omitempty"`
Tasks []Task `json:"tasks,omitempty"`
Events []OrderEvent `json:"events,omitempty"`
}
Order represents a unified order from any source.
type OrderEvent ¶
type OrderEvent struct {
ID uuid.UUID `json:"id"`
OrderID uuid.UUID `json:"order_id"`
EventType string `json:"event_type"`
Message string `json:"message,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
OrderEvent records an event in the order lifecycle.
type OrderFilters ¶
type OrderFilters struct {
Status *OrderStatus `json:"status,omitempty"`
Source *OrderSource `json:"source,omitempty"`
StartDate *time.Time `json:"start_date,omitempty"`
EndDate *time.Time `json:"end_date,omitempty"`
Limit int `json:"limit,omitempty"`
Offset int `json:"offset,omitempty"`
}
OrderFilters defines filter options for listing orders.
type OrderItem ¶
type OrderItem struct {
ID uuid.UUID `json:"id"`
OrderID uuid.UUID `json:"order_id"`
TemplateID *uuid.UUID `json:"template_id,omitempty"` // Legacy: kept for migration
ProjectID *uuid.UUID `json:"project_id,omitempty"` // Link to project (product catalog)
SKU string `json:"sku,omitempty"`
Quantity int `json:"quantity"`
Notes string `json:"notes,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
OrderItem represents a line item in an order.
type OrderProgress ¶
type OrderProgress struct {
OrderID uuid.UUID `json:"order_id"`
TotalItems int `json:"total_items"`
CompletedItems int `json:"completed_items"`
TotalJobs int `json:"total_jobs"`
CompletedJobs int `json:"completed_jobs"`
ProgressPercent float64 `json:"progress_percent"`
}
OrderProgress represents the completion progress of an order.
type OrderSource ¶
type OrderSource string
OrderSource identifies where an order originated.
const ( OrderSourceManual OrderSource = "manual" OrderSourceEtsy OrderSource = "etsy" OrderSourceSquarespace OrderSource = "squarespace" OrderSourceShopify OrderSource = "shopify" OrderSourceQuote OrderSource = "quote" )
type OrderStatus ¶
type OrderStatus string
OrderStatus represents the status of an order.
const ( OrderStatusPending OrderStatus = "pending" OrderStatusInProgress OrderStatus = "in_progress" OrderStatusCompleted OrderStatus = "completed" OrderStatusShipped OrderStatus = "shipped" OrderStatusCancelled OrderStatus = "cancelled" )
type ParsedReceipt ¶
type ParsedReceipt struct {
Vendor string `json:"vendor"`
Date string `json:"date"`
SubtotalCents int `json:"subtotal_cents"`
TaxCents int `json:"tax_cents"`
ShippingCents int `json:"shipping_cents"`
TotalCents int `json:"total_cents"`
Currency string `json:"currency"`
Items []ParsedReceiptItem `json:"items"`
Confidence int `json:"confidence"`
RawText string `json:"raw_text,omitempty"`
}
ParsedReceipt represents the AI-extracted data from a receipt.
type ParsedReceiptItem ¶
type ParsedReceiptItem struct {
Description string `json:"description"`
Quantity float64 `json:"quantity"`
UnitPriceCents int `json:"unit_price_cents"`
TotalPriceCents int `json:"total_price_cents"`
Category ExpenseCategory `json:"category"`
IsFilament bool `json:"is_filament"`
Filament *FilamentMetadata `json:"filament,omitempty"`
Confidence int `json:"confidence"`
}
ParsedReceiptItem represents a parsed line item from a receipt.
type Part ¶
type Part struct {
ID uuid.UUID `json:"id"`
ProjectID uuid.UUID `json:"project_id"`
Name string `json:"name"`
Description string `json:"description"`
Quantity int `json:"quantity"`
Status PartStatus `json:"status"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
Tags []Tag `json:"tags,omitempty"`
}
Part represents a discrete printable component of a project.
type PartStatus ¶
type PartStatus string
PartStatus represents the status of a part.
const ( PartStatusDesign PartStatus = "design" PartStatusPrinting PartStatus = "printing" PartStatusComplete PartStatus = "complete" )
type PrintEvent ¶
type PrintEvent = JobEvent
type PrintEventType ¶
type PrintEventType = JobEventType
Legacy type aliases for backward compatibility
type PrintJob ¶
type PrintJob struct {
ID uuid.UUID `json:"id"`
DesignID uuid.UUID `json:"design_id"`
PrinterID *uuid.UUID `json:"printer_id,omitempty"`
MaterialSpoolID *uuid.UUID `json:"material_spool_id,omitempty"`
ProjectID *uuid.UUID `json:"project_id,omitempty"`
TaskID *uuid.UUID `json:"task_id,omitempty"` // Link to task (work instance)
Notes string `json:"notes"`
CreatedAt time.Time `json:"created_at"`
// Recipe context (optional, for SKU-based orders)
RecipeID *uuid.UUID `json:"recipe_id,omitempty"`
// Retry tracking
AttemptNumber int `json:"attempt_number"` // 1 = first attempt, 2+ = retries
ParentJobID *uuid.UUID `json:"parent_job_id,omitempty"`
// Failure classification (set when job fails)
FailureCategory *FailureCategory `json:"failure_category,omitempty"`
// Time tracking
EstimatedSeconds *int `json:"estimated_seconds,omitempty"`
ActualSeconds *int `json:"actual_seconds,omitempty"`
// Cost tracking
MaterialUsedGrams *float64 `json:"material_used_grams,omitempty"`
CostCents *int `json:"cost_cents,omitempty"` // Total cost (printer time + material)
PrinterTimeCostCents *int `json:"printer_time_cost_cents,omitempty"` // Snapshot: printer hourly rate * actual hours
MaterialCostCents *int `json:"material_cost_cents,omitempty"` // Snapshot: material cost at completion
// Material snapshot (AMS state captured at job start)
MaterialSnapshot *MaterialSnapshot `json:"material_snapshot,omitempty"`
// Queue management
Priority int `json:"priority"` // Higher values = higher priority
AutoDispatchEnabled bool `json:"auto_dispatch_enabled"` // Whether this job participates in auto-dispatch
// Computed fields (derived from events, not stored in print_jobs table)
Status PrintJobStatus `json:"status"` // computed from latest event
Progress float64 `json:"progress"` // computed from latest event
StartedAt *time.Time `json:"started_at,omitempty"` // computed from first printing event
CompletedAt *time.Time `json:"completed_at,omitempty"` // computed from terminal event
Outcome *PrintOutcome `json:"outcome,omitempty"` // kept for backward compat
Events []JobEvent `json:"events,omitempty"` // full event timeline when requested
}
PrintJob represents an immutable print job instance. Once created, core fields should not change. State changes are recorded as JobEvents.
func (*PrintJob) IsAssigned ¶
IsAssigned returns true if the job has both printer and spool assigned.
func (*PrintJob) NeedsAssignment ¶
NeedsAssignment returns true if the job is missing printer or spool assignment.
type PrintJobStatus ¶
type PrintJobStatus string
PrintJobStatus represents the status of a print job.
const ( PrintJobStatusQueued PrintJobStatus = "queued" PrintJobStatusAssigned PrintJobStatus = "assigned" // assigned to printer PrintJobStatusUploaded PrintJobStatus = "uploaded" // file sent to printer PrintJobStatusPrinting PrintJobStatus = "printing" PrintJobStatusPaused PrintJobStatus = "paused" PrintJobStatusCompleted PrintJobStatus = "completed" PrintJobStatusFailed PrintJobStatus = "failed" PrintJobStatusCancelled PrintJobStatus = "cancelled" )
func (PrintJobStatus) IsTerminal ¶
func (s PrintJobStatus) IsTerminal() bool
IsTerminal returns true if this status is a final state.
type PrintOutcome ¶
type PrintOutcome struct {
Success bool `json:"success"`
QualityRating *int `json:"quality_rating,omitempty"`
ActualWeight *float64 `json:"actual_weight,omitempty"`
ActualTime *int `json:"actual_time,omitempty"`
FailureReason string `json:"failure_reason,omitempty"`
Photos []string `json:"photos,omitempty"`
Notes string `json:"notes,omitempty"`
MaterialUsed float64 `json:"material_used"`
MaterialCost float64 `json:"material_cost"`
}
PrintOutcome captures the result of a print job.
type PrintProfile ¶
type PrintProfile string
PrintProfile represents a symbolic slicer profile.
const ( PrintProfileStandard PrintProfile = "standard" PrintProfileDetailed PrintProfile = "detailed" PrintProfileFast PrintProfile = "fast" PrintProfileStrong PrintProfile = "strong" PrintProfileCustom PrintProfile = "custom" )
type Printer ¶
type Printer struct {
ID uuid.UUID `json:"id"`
Name string `json:"name"`
Model string `json:"model"`
Manufacturer string `json:"manufacturer"`
ConnectionType ConnectionType `json:"connection_type"`
ConnectionURI string `json:"connection_uri"`
APIKey string `json:"api_key,omitempty"`
SerialNumber string `json:"serial_number,omitempty"`
Status PrinterStatus `json:"status"`
BuildVolume *BuildVolume `json:"build_volume,omitempty"`
NozzleDiameter float64 `json:"nozzle_diameter"`
Location string `json:"location"`
Notes string `json:"notes"`
MinMaterialPercent int `json:"min_material_percent"` // Minimum % before warning (default 10)
CostPerHourCents int `json:"cost_per_hour_cents"` // Hourly cost in cents (e.g. 150 = $1.50/hr)
PurchasePriceCents int `json:"purchase_price_cents"` // Purchase price in cents for ROI tracking
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
Printer represents a 3D printer in the farm.
type PrinterAnalytics ¶
type PrinterAnalytics struct {
Utilization []PrinterUtilization `json:"utilization"`
ROI *PrinterROI `json:"roi"`
Health *PrinterHealth `json:"health"`
}
PrinterAnalytics combines utilization, ROI, and health metrics.
type PrinterConstraints ¶
type PrinterConstraints struct {
MinBedSize *BuildVolume `json:"min_bed_size,omitempty"`
NozzleDiameters []float64 `json:"nozzle_diameters,omitempty"`
RequiresEnclosure bool `json:"requires_enclosure"`
RequiresAMS bool `json:"requires_ams"`
PrinterTags []string `json:"printer_tags,omitempty"`
}
PrinterConstraints defines hardware requirements for a recipe.
type PrinterHealth ¶
type PrinterHealth struct {
TotalJobs int `json:"total_jobs"`
CompletedJobs int `json:"completed_jobs"`
FailedJobs int `json:"failed_jobs"`
FailureRate float64 `json:"failure_rate"`
AvgJobDurationSec int `json:"avg_job_duration_sec"`
AvgCostCents int `json:"avg_cost_cents"`
TotalMaterialGrams float64 `json:"total_material_grams"`
TotalCostCents int `json:"total_cost_cents"`
TotalRevenueCents int `json:"total_revenue_cents"`
FailureBreakdown map[string]int `json:"failure_breakdown"`
}
PrinterHealth represents health and performance metrics for a printer.
type PrinterROI ¶
type PrinterROI struct {
PurchasePriceCents int `json:"purchase_price_cents"`
TotalRevenueCents int `json:"total_revenue_cents"`
TotalCostCents int `json:"total_cost_cents"`
LifetimeProfitCents int `json:"lifetime_profit_cents"`
TotalPrintingHours float64 `json:"total_printing_hours"`
RevenuePerHourCents int `json:"revenue_per_hour_cents"`
CostPerHourCents int `json:"cost_per_hour_cents"`
NetPerHourCents int `json:"net_per_hour_cents"`
HoursToBreakEven float64 `json:"hours_to_break_even"`
PrinterAgeHours float64 `json:"printer_age_hours"`
BreakEvenReached bool `json:"break_even_reached"`
}
PrinterROI represents ROI and break-even metrics for a printer.
type PrinterState ¶
type PrinterState struct {
PrinterID uuid.UUID `json:"printer_id"`
Status PrinterStatus `json:"status"`
Progress float64 `json:"progress"`
CurrentFile string `json:"current_file,omitempty"`
TimeLeft int `json:"time_left,omitempty"`
BedTemp float64 `json:"bed_temp,omitempty"`
NozzleTemp float64 `json:"nozzle_temp,omitempty"`
AMS *AMSState `json:"ams,omitempty"`
UpdatedAt time.Time `json:"updated_at"`
// Target temperatures
BedTargetTemp float64 `json:"bed_target_temp,omitempty"`
NozzleTargetTemp float64 `json:"nozzle_target_temp,omitempty"`
ChamberTemp float64 `json:"chamber_temp,omitempty"`
// Layers
LayerNum int `json:"layer_num,omitempty"`
TotalLayerNum int `json:"total_layer_num,omitempty"`
// Fan speeds (0-100%)
CoolingFanSpeed int `json:"cooling_fan_speed,omitempty"`
AuxFanSpeed int `json:"aux_fan_speed,omitempty"`
ChamberFanSpeed int `json:"chamber_fan_speed,omitempty"`
HeatbreakFanSpeed int `json:"heatbreak_fan_speed,omitempty"`
// Speed
SpeedPercent int `json:"speed_percent,omitempty"`
SpeedLevel int `json:"speed_level,omitempty"` // 1=silent, 2=standard, 3=sport, 4=ludicrous
PrintRealSpeed int `json:"print_real_speed,omitempty"`
// Network
WiFiSignal string `json:"wifi_signal,omitempty"`
// Nozzle info
NozzleDiameter string `json:"nozzle_diameter,omitempty"`
NozzleType string `json:"nozzle_type,omitempty"`
// Diagnostics
HMSErrors []HMSError `json:"hms_errors,omitempty"`
Lights []LightState `json:"lights,omitempty"`
// Timing / Job
GcodeStartTime string `json:"gcode_start_time,omitempty"`
SubtaskID string `json:"subtask_id,omitempty"`
TaskID string `json:"task_id,omitempty"`
PrintType string `json:"print_type,omitempty"`
}
PrinterState represents real-time state from a connected printer.
type PrinterStatus ¶
type PrinterStatus string
PrinterStatus represents the current state of a printer.
const ( PrinterStatusIdle PrinterStatus = "idle" PrinterStatusPrinting PrinterStatus = "printing" PrinterStatusPaused PrinterStatus = "paused" PrinterStatusError PrinterStatus = "error" PrinterStatusOffline PrinterStatus = "offline" )
type PrinterUtilization ¶
type PrinterUtilization struct {
Period string `json:"period"`
TotalHours float64 `json:"total_hours"`
PrintingHours float64 `json:"printing_hours"`
FailedHours float64 `json:"failed_hours"`
IdleHours float64 `json:"idle_hours"`
UtilizationPercent float64 `json:"utilization_percent"`
ConfiguredCostPerHourCents int `json:"configured_cost_per_hour_cents"`
ActualRevenuePerHourCents int `json:"actual_revenue_per_hour_cents"`
}
PrinterUtilization represents utilization metrics for a time period.
type Project ¶
type Project struct {
ID uuid.UUID `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
TargetDate *time.Time `json:"target_date,omitempty"`
Tags []string `json:"tags"`
TemplateID *uuid.UUID `json:"template_id,omitempty"` // Legacy: kept for migration
Source string `json:"source"`
ExternalOrderID string `json:"external_order_id,omitempty"`
CustomerNotes string `json:"customer_notes,omitempty"`
// Template-like fields for product catalog
SKU string `json:"sku,omitempty"`
PriceCents *int `json:"price_cents,omitempty"`
PrinterType string `json:"printer_type,omitempty"`
AllowedPrinterIDs []uuid.UUID `json:"allowed_printer_ids,omitempty"`
DefaultSettings map[string]interface{} `json:"default_settings,omitempty"`
Notes string `json:"notes,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
// Aggregated stats from tasks (computed, not stored)
TotalTasks int `json:"total_tasks,omitempty"`
CompletedTasks int `json:"completed_tasks,omitempty"`
}
Project represents a product in the catalog that tracks lifetime performance. Projects now serve as both the product catalog and the blueprint for tasks.
type ProjectSummary ¶
type ProjectSummary struct {
// Revenue (from Sales linked to this project)
TotalRevenueCents int `json:"total_revenue_cents"`
TotalFeesCents int `json:"total_fees_cents"`
NetRevenueCents int `json:"net_revenue_cents"`
SalesCount int `json:"sales_count"`
// Cost breakdown
UnitCostCents int `json:"unit_cost_cents"` // cost to produce one unit
TotalCostCents int `json:"total_cost_cents"` // unit_cost × max(sales_count, 1)
PrinterTimeCostCents int `json:"printer_time_cost_cents"`
MaterialCostCents int `json:"material_cost_cents"`
// Profit
GrossProfitCents int `json:"gross_profit_cents"`
GrossMarginPercent float64 `json:"gross_margin_percent"`
// Print time
TotalPrintSeconds int `json:"total_print_seconds"`
AvgPrintSeconds int `json:"avg_print_seconds"`
ProfitPerHourCents int `json:"profit_per_hour_cents"`
// Performance
JobCount int `json:"job_count"`
CompletedCount int `json:"completed_count"`
FailedCount int `json:"failed_count"`
SuccessRate float64 `json:"success_rate"`
// Material
TotalMaterialGrams float64 `json:"total_material_grams"`
// Estimated values (from slice profiles and supplies)
EstimatedMaterialCostCents int `json:"estimated_material_cost_cents"`
EstimatedMaterialGrams float64 `json:"estimated_material_grams"`
EstimatedPrintSeconds int `json:"estimated_print_seconds"`
SupplyCostCents int `json:"supply_cost_cents"`
}
ProjectSummary is a derived analytics object for a project. All fields are computed from jobs and sales — never stored.
type ProjectSupply ¶
type ProjectSupply struct {
ID uuid.UUID `json:"id"`
ProjectID uuid.UUID `json:"project_id"`
Name string `json:"name"`
UnitCostCents int `json:"unit_cost_cents"`
Quantity int `json:"quantity"`
Notes string `json:"notes"`
MaterialID *uuid.UUID `json:"material_id,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
ProjectSupply represents a non-printed purchased item in a project's bill of materials.
type Quote ¶
type Quote struct {
ID uuid.UUID `json:"id"`
QuoteNumber string `json:"quote_number"`
CustomerID uuid.UUID `json:"customer_id"`
Status QuoteStatus `json:"status"`
Title string `json:"title"`
Notes string `json:"notes,omitempty"`
ValidUntil *time.Time `json:"valid_until,omitempty"`
AcceptedOptionID *uuid.UUID `json:"accepted_option_id,omitempty"`
OrderID *uuid.UUID `json:"order_id,omitempty"`
DiscountType DiscountType `json:"discount_type"`
DiscountValue int `json:"discount_value"`
RushFeeCents int `json:"rush_fee_cents"`
TaxRate int `json:"tax_rate"`
Terms string `json:"terms,omitempty"`
RequestedDueDate *time.Time `json:"requested_due_date,omitempty"`
BillingAddress *Address `json:"billing_address,omitempty"`
ShippingAddress *Address `json:"shipping_address,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
SentAt *time.Time `json:"sent_at,omitempty"`
AcceptedAt *time.Time `json:"accepted_at,omitempty"`
Customer *Customer `json:"customer,omitempty"`
Options []QuoteOption `json:"options,omitempty"`
Events []QuoteEvent `json:"events,omitempty"`
}
Quote represents a customer quote with options.
type QuoteEvent ¶
type QuoteEvent struct {
ID uuid.UUID `json:"id"`
QuoteID uuid.UUID `json:"quote_id"`
EventType string `json:"event_type"`
Message string `json:"message,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
QuoteEvent records an event in the quote lifecycle.
type QuoteFilters ¶
type QuoteFilters struct {
Status *QuoteStatus `json:"status,omitempty"`
CustomerID *uuid.UUID `json:"customer_id,omitempty"`
Limit int `json:"limit,omitempty"`
Offset int `json:"offset,omitempty"`
}
QuoteFilters defines filter options for listing quotes.
type QuoteLineItem ¶
type QuoteLineItem struct {
ID uuid.UUID `json:"id"`
OptionID uuid.UUID `json:"option_id"`
Type QuoteLineItemType `json:"type"`
Description string `json:"description"`
Quantity float64 `json:"quantity"`
Unit string `json:"unit"`
UnitPriceCents int `json:"unit_price_cents"`
TotalCents int `json:"total_cents"`
SortOrder int `json:"sort_order"`
ProjectID *uuid.UUID `json:"project_id,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
QuoteLineItem represents a line item within a quote option.
type QuoteLineItemType ¶
type QuoteLineItemType string
QuoteLineItemType represents the type of a line item.
const ( QuoteLineItemTypePrinting QuoteLineItemType = "printing" QuoteLineItemTypePostProcessing QuoteLineItemType = "post_processing" QuoteLineItemTypeConsulting QuoteLineItemType = "consulting" QuoteLineItemTypeDesign QuoteLineItemType = "design" QuoteLineItemTypeOther QuoteLineItemType = "other" QuoteLineItemTypeLabor QuoteLineItemType = "labor" QuoteLineItemTypeConsumables QuoteLineItemType = "consumables" QuoteLineItemTypeShipping QuoteLineItemType = "shipping" QuoteLineItemTypeFinishing QuoteLineItemType = "finishing" )
type QuoteOption ¶
type QuoteOption struct {
ID uuid.UUID `json:"id"`
QuoteID uuid.UUID `json:"quote_id"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
SortOrder int `json:"sort_order"`
TotalCents int `json:"total_cents"`
CreatedAt time.Time `json:"created_at"`
Items []QuoteLineItem `json:"items,omitempty"`
}
QuoteOption represents one option within a quote.
type QuoteStatus ¶
type QuoteStatus string
QuoteStatus represents the status of a quote.
const ( QuoteStatusDraft QuoteStatus = "draft" QuoteStatusSent QuoteStatus = "sent" QuoteStatusAccepted QuoteStatus = "accepted" QuoteStatusRejected QuoteStatus = "rejected" QuoteStatusExpired QuoteStatus = "expired" )
type RecipeCostEstimate ¶
type RecipeCostEstimate struct {
MaterialCostCents int `json:"material_cost_cents"`
TimeCostCents int `json:"time_cost_cents"`
LaborCostCents int `json:"labor_cost_cents"`
SupplyCostCents int `json:"supply_cost_cents"`
TotalCostCents int `json:"total_cost_cents"`
EstimatedPrintTime int `json:"estimated_print_time_seconds"`
LaborMinutes int `json:"labor_minutes"`
MaterialBreakdown []RecipeMaterialCostBreakdown `json:"material_breakdown"`
SupplyBreakdown []RecipeSupplyCostBreakdown `json:"supply_breakdown,omitempty"`
HourlyRateCents int `json:"hourly_rate_cents"`
LaborRateCents int `json:"labor_rate_cents"`
PrinterName string `json:"printer_name,omitempty"`
// Margin calculation
SalePriceCents int `json:"sale_price_cents"`
GrossMarginCents int `json:"gross_margin_cents"`
GrossMarginPercent float64 `json:"gross_margin_percent"`
ProfitPerHourCents int `json:"profit_per_hour_cents"`
}
RecipeCostEstimate represents the cost breakdown for a recipe.
type RecipeMaterial ¶
type RecipeMaterial struct {
ID uuid.UUID `json:"id"`
RecipeID uuid.UUID `json:"recipe_id"`
MaterialType MaterialType `json:"material_type"`
ColorSpec *ColorSpec `json:"color_spec,omitempty"`
WeightGrams float64 `json:"weight_grams"`
AMSPosition *int `json:"ams_position,omitempty"`
SequenceOrder int `json:"sequence_order"`
Notes string `json:"notes,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
RecipeMaterial represents a material requirement for a recipe.
type RecipeMaterialCostBreakdown ¶
type RecipeMaterialCostBreakdown struct {
MaterialType string `json:"material_type"`
WeightGrams float64 `json:"weight_grams"`
CostCents int `json:"cost_cents"`
ColorName string `json:"color_name,omitempty"`
}
RecipeMaterialCostBreakdown shows cost for each material in a recipe.
type RecipeSupply ¶
type RecipeSupply struct {
ID uuid.UUID `json:"id"`
RecipeID uuid.UUID `json:"recipe_id"`
Name string `json:"name"`
UnitCostCents int `json:"unit_cost_cents"`
Quantity int `json:"quantity"`
MaterialID *uuid.UUID `json:"material_id,omitempty"`
Notes string `json:"notes,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
RecipeSupply represents a non-printed purchased item in a recipe's bill of materials.
type RecipeSupplyCostBreakdown ¶
type RecipeSupplyCostBreakdown struct {
Name string `json:"name"`
UnitCostCents int `json:"unit_cost_cents"`
Quantity int `json:"quantity"`
TotalCents int `json:"total_cents"`
}
RecipeSupplyCostBreakdown shows cost for each supply item in a recipe.
type Sale ¶
type Sale struct {
ID uuid.UUID `json:"id"`
OccurredAt time.Time `json:"occurred_at"`
Channel SalesChannel `json:"channel"`
Platform string `json:"platform"`
GrossCents int `json:"gross_cents"`
FeesCents int `json:"fees_cents"`
ShippingChargedCents int `json:"shipping_charged_cents"`
ShippingCostCents int `json:"shipping_cost_cents"`
TaxCollectedCents int `json:"tax_collected_cents"`
NetCents int `json:"net_cents"`
Currency string `json:"currency"`
ProjectID *uuid.UUID `json:"project_id,omitempty"`
CustomerID *uuid.UUID `json:"customer_id,omitempty"`
OrderReference string `json:"order_reference,omitempty"`
CustomerName string `json:"customer_name,omitempty"`
ItemDescription string `json:"item_description"`
Quantity int `json:"quantity"`
Notes string `json:"notes"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
Sale represents a revenue record.
type SalesChannel ¶
type SalesChannel string
SalesChannel represents where a sale was made.
const ( SalesChannelMarketplace SalesChannel = "marketplace" SalesChannelEtsy SalesChannel = "etsy" SalesChannelWebsite SalesChannel = "website" SalesChannelDirect SalesChannel = "direct" SalesChannelOther SalesChannel = "other" )
type ShopifyCredentials ¶
type ShopifyCredentials struct {
ID uuid.UUID `json:"id"`
ShopDomain string `json:"shop_domain"`
AccessToken string `json:"access_token"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
ShopifyCredentials stores OAuth credentials for a Shopify store.
type ShopifyIntegrationStatus ¶
type ShopifyIntegrationStatus struct {
Connected bool `json:"connected"`
ShopDomain string `json:"shop_domain,omitempty"`
LastSyncAt *time.Time `json:"last_sync_at,omitempty"`
OrderCount int `json:"order_count,omitempty"`
}
ShopifyIntegrationStatus represents the connection status.
type ShopifyOrder ¶
type ShopifyOrder struct {
ID uuid.UUID `json:"id"`
ShopifyOrderID string `json:"shopify_order_id"`
OrderID *uuid.UUID `json:"order_id,omitempty"` // Link to unified Order
ShopDomain string `json:"shop_domain"`
OrderNumber string `json:"order_number"`
CustomerName string `json:"customer_name"`
CustomerEmail string `json:"customer_email"`
TotalCents int `json:"total_cents"`
Status string `json:"status"`
SyncedAt time.Time `json:"synced_at"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
Items []ShopifyOrderItem `json:"items,omitempty"`
}
ShopifyOrder represents a synced Shopify order.
type ShopifyOrderItem ¶
type ShopifyOrderItem struct {
ID uuid.UUID `json:"id"`
ShopifyOrderID uuid.UUID `json:"shopify_order_id"`
ShopifyLineItemID string `json:"shopify_line_item_id"`
SKU string `json:"sku"`
Title string `json:"title"`
Quantity int `json:"quantity"`
PriceCents int `json:"price_cents"`
CreatedAt time.Time `json:"created_at"`
}
ShopifyOrderItem represents a line item in a Shopify order.
type ShopifyProductTemplate ¶
type ShopifyProductTemplate struct {
ID uuid.UUID `json:"id"`
ShopifyProductID string `json:"shopify_product_id"`
TemplateID uuid.UUID `json:"template_id"`
SKU string `json:"sku,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
ShopifyProductTemplate links a Shopify product to a template.
type SliceProfileData ¶
type SliceProfileData struct {
PrintTimeSeconds int `json:"print_time_seconds"`
WeightGrams float64 `json:"weight_grams"`
PrinterModel string `json:"printer_model,omitempty"`
NozzleDiameter float64 `json:"nozzle_diameter,omitempty"`
Filaments []FilamentUsage `json:"filaments"`
}
SliceProfileData represents parsed data from a 3MF slice profile.
type SpoolStatus ¶
type SpoolStatus string
SpoolStatus represents the status of a material spool.
const ( SpoolStatusNew SpoolStatus = "new" SpoolStatusInUse SpoolStatus = "in_use" SpoolStatusLow SpoolStatus = "low" SpoolStatusEmpty SpoolStatus = "empty" SpoolStatusArchived SpoolStatus = "archived" )
type SquarespaceAddress ¶
type SquarespaceAddress struct {
FirstName string `json:"first_name"`
LastName string `json:"last_name"`
Address1 string `json:"address1"`
Address2 string `json:"address2"`
City string `json:"city"`
State string `json:"state"`
PostalCode string `json:"postal_code"`
CountryCode string `json:"country_code"`
Phone string `json:"phone"`
}
SquarespaceAddress represents a billing or shipping address.
type SquarespaceIntegration ¶
type SquarespaceIntegration struct {
ID uuid.UUID `json:"id"`
SiteID string `json:"site_id"`
SiteTitle string `json:"site_title"`
APIKey string `json:"-"` // Never expose
IsActive bool `json:"is_active"`
LastOrderSyncAt *time.Time `json:"last_order_sync_at,omitempty"`
LastProductSyncAt *time.Time `json:"last_product_sync_at,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
SquarespaceIntegration represents the connected Squarespace site.
type SquarespaceOrder ¶
type SquarespaceOrder struct {
ID uuid.UUID `json:"id"`
SquarespaceOrderID string `json:"squarespace_order_id"`
OrderNumber string `json:"order_number"`
CustomerEmail string `json:"customer_email"`
CustomerName string `json:"customer_name"`
Channel string `json:"channel"`
SubtotalCents int `json:"subtotal_cents"`
ShippingCents int `json:"shipping_cents"`
TaxCents int `json:"tax_cents"`
DiscountCents int `json:"discount_cents"`
RefundedCents int `json:"refunded_cents"`
GrandTotalCents int `json:"grand_total_cents"`
Currency string `json:"currency"`
FulfillmentStatus string `json:"fulfillment_status"`
BillingAddress *SquarespaceAddress `json:"billing_address,omitempty"`
ShippingAddress *SquarespaceAddress `json:"shipping_address,omitempty"`
CreatedOn *time.Time `json:"created_on,omitempty"`
ModifiedOn *time.Time `json:"modified_on,omitempty"`
IsProcessed bool `json:"is_processed"`
ProjectID *uuid.UUID `json:"project_id,omitempty"`
Items []SquarespaceOrderItem `json:"items,omitempty"`
SyncedAt time.Time `json:"synced_at"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
SquarespaceOrder represents an order from Squarespace.
type SquarespaceOrderItem ¶
type SquarespaceOrderItem struct {
ID uuid.UUID `json:"id"`
OrderID uuid.UUID `json:"order_id"`
SquarespaceItemID string `json:"squarespace_item_id"`
ProductID string `json:"product_id"`
VariantID string `json:"variant_id"`
ProductName string `json:"product_name"`
SKU string `json:"sku"`
Quantity int `json:"quantity"`
UnitPriceCents int `json:"unit_price_cents"`
Currency string `json:"currency"`
ImageURL string `json:"image_url"`
VariantOptions json.RawMessage `json:"variant_options,omitempty"`
TemplateID *uuid.UUID `json:"template_id,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
SquarespaceOrderItem represents a line item in a Squarespace order.
type SquarespaceProduct ¶
type SquarespaceProduct struct {
ID uuid.UUID `json:"id"`
SquarespaceProductID string `json:"squarespace_product_id"`
Name string `json:"name"`
Description string `json:"description"`
URL string `json:"url"`
Type string `json:"type"`
IsVisible bool `json:"is_visible"`
Tags json.RawMessage `json:"tags,omitempty"`
Variants []SquarespaceProductVariant `json:"variants,omitempty"`
CreatedOn *time.Time `json:"created_on,omitempty"`
ModifiedOn *time.Time `json:"modified_on,omitempty"`
SyncedAt time.Time `json:"synced_at"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
SquarespaceProduct represents a product from Squarespace.
type SquarespaceProductTemplate ¶
type SquarespaceProductTemplate struct {
ID uuid.UUID `json:"id"`
SquarespaceProductID string `json:"squarespace_product_id"`
TemplateID uuid.UUID `json:"template_id"`
SKU string `json:"sku,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
SquarespaceProductTemplate links a Squarespace product to a template.
type SquarespaceProductVariant ¶
type SquarespaceProductVariant struct {
ID uuid.UUID `json:"id"`
ProductID uuid.UUID `json:"product_id"`
SquarespaceVariantID string `json:"squarespace_variant_id"`
SKU string `json:"sku"`
PriceCents int `json:"price_cents"`
SalePriceCents int `json:"sale_price_cents"`
OnSale bool `json:"on_sale"`
StockQuantity int `json:"stock_quantity"`
StockUnlimited bool `json:"stock_unlimited"`
Attributes json.RawMessage `json:"attributes,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
SquarespaceProductVariant represents a variant of a Squarespace product.
type SyncResult ¶
type SyncResult struct {
TotalFetched int `json:"total_fetched"`
Created int `json:"created"`
Updated int `json:"updated"`
Skipped int `json:"skipped"`
Errors int `json:"errors"`
}
SyncResult represents the result of a sync operation.
type Tag ¶
type Tag struct {
ID uuid.UUID `json:"id"`
Name string `json:"name"`
Color string `json:"color"`
CreatedAt time.Time `json:"created_at"`
}
Tag represents a user-defined tag for organization.
type Task ¶
type Task struct {
ID uuid.UUID `json:"id"`
ProjectID uuid.UUID `json:"project_id"`
OrderID *uuid.UUID `json:"order_id,omitempty"`
OrderItemID *uuid.UUID `json:"order_item_id,omitempty"`
Name string `json:"name"`
Status TaskStatus `json:"status"`
Quantity int `json:"quantity"`
Notes string `json:"notes,omitempty"`
PickupDate *time.Time `json:"pickup_date,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
StartedAt *time.Time `json:"started_at,omitempty"`
CompletedAt *time.Time `json:"completed_at,omitempty"`
// Loaded relations
Project *Project `json:"project,omitempty"`
Jobs []PrintJob `json:"jobs,omitempty"`
ChecklistItems []TaskChecklistItem `json:"checklist_items,omitempty"`
Progress float64 `json:"progress,omitempty"`
}
Task represents a work instance created when processing an order. Tasks are created from Projects (the product catalog) and contain PrintJobs.
type TaskChecklistItem ¶
type TaskChecklistItem struct {
ID uuid.UUID `json:"id"`
TaskID uuid.UUID `json:"task_id"`
Name string `json:"name"`
PartID *uuid.UUID `json:"part_id,omitempty"`
SortOrder int `json:"sort_order"`
Completed bool `json:"completed"`
CompletedAt *time.Time `json:"completed_at,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
TaskChecklistItem represents a checklist item for a task.
type TaskFilters ¶
type TaskFilters struct {
ProjectID *uuid.UUID `json:"project_id,omitempty"`
OrderID *uuid.UUID `json:"order_id,omitempty"`
Status *TaskStatus `json:"status,omitempty"`
Limit int `json:"limit,omitempty"`
Offset int `json:"offset,omitempty"`
}
TaskFilters defines filter options for listing tasks.
type TaskStatus ¶
type TaskStatus string
TaskStatus represents the status of a task.
const ( TaskStatusPending TaskStatus = "pending" TaskStatusInProgress TaskStatus = "in_progress" TaskStatusCompleted TaskStatus = "completed" TaskStatusCancelled TaskStatus = "cancelled" )
type Template ¶
type Template struct {
ID uuid.UUID `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
SKU string `json:"sku"`
Tags []string `json:"tags"`
MaterialType MaterialType `json:"material_type"`
EstimatedMaterialGrams float64 `json:"estimated_material_grams"`
PreferredPrinterID *uuid.UUID `json:"preferred_printer_id,omitempty"`
AllowAnyPrinter bool `json:"allow_any_printer"`
QuantityPerOrder int `json:"quantity_per_order"`
PostProcessChecklist []string `json:"post_process_checklist"`
IsActive bool `json:"is_active"`
PrinterConstraints *PrinterConstraints `json:"printer_constraints,omitempty"`
PrintProfile PrintProfile `json:"print_profile"`
EstimatedPrintSeconds int `json:"estimated_print_seconds"`
// Pricing fields for margin calculation
LaborMinutes int `json:"labor_minutes"`
SalePriceCents int `json:"sale_price_cents"`
MaterialCostPerGramCents int `json:"material_cost_per_gram_cents"`
Version int `json:"version"`
ArchivedAt *time.Time `json:"archived_at,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
Designs []TemplateDesign `json:"designs,omitempty"`
Materials []RecipeMaterial `json:"materials,omitempty"`
Supplies []RecipeSupply `json:"supplies,omitempty"`
}
Template represents a reusable project blueprint for order fulfillment (aka Recipe).
type TemplateAnalytics ¶
type TemplateAnalytics struct {
TemplateID uuid.UUID `json:"template_id"`
ProjectCount int `json:"project_count"`
// Revenue
TotalRevenueCents int `json:"total_revenue_cents"`
TotalFeesCents int `json:"total_fees_cents"`
NetRevenueCents int `json:"net_revenue_cents"`
TotalSalesCount int `json:"total_sales_count"`
// Costs
TotalCostCents int `json:"total_cost_cents"`
AvgUnitCostCents int `json:"avg_unit_cost_cents"`
TotalPrinterTimeCost int `json:"total_printer_time_cost"`
TotalMaterialCost int `json:"total_material_cost"`
TotalSupplyCost int `json:"total_supply_cost"`
// Profit
TotalGrossProfitCents int `json:"total_gross_profit_cents"`
AvgGrossMarginPercent float64 `json:"avg_gross_margin_percent"`
ProfitPerHourCents int `json:"profit_per_hour_cents"`
// Performance
TotalJobCount int `json:"total_job_count"`
TotalCompleted int `json:"total_completed"`
TotalFailed int `json:"total_failed"`
SuccessRate float64 `json:"success_rate"`
// Print time
TotalPrintSeconds int `json:"total_print_seconds"`
AvgPrintSeconds int `json:"avg_print_seconds"`
// Material
TotalMaterialGrams float64 `json:"total_material_grams"`
AvgMaterialGrams float64 `json:"avg_material_grams"`
// Estimated vs Actual comparison (from template)
EstimatedPrintSeconds int `json:"estimated_print_seconds"`
EstimatedMaterialGrams float64 `json:"estimated_material_grams"`
EstimatedCostCents int `json:"estimated_cost_cents"`
}
TemplateAnalytics contains aggregated performance metrics from projects created from a template.
type TemplateDesign ¶
type TemplateDesign struct {
ID uuid.UUID `json:"id"`
TemplateID uuid.UUID `json:"template_id"`
DesignID uuid.UUID `json:"design_id"`
IsPrimary bool `json:"is_primary"`
Quantity int `json:"quantity"`
SequenceOrder int `json:"sequence_order"`
Notes string `json:"notes"`
CreatedAt time.Time `json:"created_at"`
Design *Design `json:"design,omitempty"`
}
TemplateDesign represents a design file linked to a template.
type TimelineItem ¶
type TimelineItem struct {
ID uuid.UUID `json:"id"`
Type string `json:"type"` // "order", "project", "job"
Name string `json:"name"`
Status string `json:"status"`
StartDate *time.Time `json:"start_date,omitempty"`
DueDate *time.Time `json:"due_date,omitempty"`
EndDate *time.Time `json:"end_date,omitempty"` // Actual or estimated
Progress float64 `json:"progress"` // 0-100
ParentID *uuid.UUID `json:"parent_id,omitempty"`
Children []TimelineItem `json:"children,omitempty"`
}
TimelineItem represents an item on the timeline/Gantt view.