upload

package
v0.4.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	DesignItemStatusDeleted   = "deleted"
	DesignItemStatusNone      = "none"
	DesignItemStatusDraft     = "draft"
	DesignItemStatusCompleted = "completed"
)

Design item status constants

View Source
const (
	MaxNameLength           = 255
	MaxNameTransLength      = 255
	MaxButtonTypeLength     = 255
	MaxOtherTypeLength      = 255
	MaxFormatLength         = 255
	MaxDefaultValueLength   = 255
	MaxTableNameLength      = 255
	MaxColumnNameLength     = 255
	MaxNavigationNoteLength = 2000
	MaxValidationNoteLength = 2000
	MaxDatabaseNoteLength   = 2000
	MaxDescriptionLength    = 10000
)

Length constraints matching SDK's UpdateSpecDto

Variables

View Source
var AcceptedActionTypes = []string{"on_click", "while_hovering", "key_gamepad", "after_delay"}
View Source
var AcceptedButtonTypes = []string{"icon_text", "toggle", "text_link", "others"}
View Source
var AcceptedDataTypes = []string{
	"array", "boolean", "byte", "character", "string",
	"date", "integer", "long", "short", "float", "double", "nothing",
}
View Source
var AcceptedOptionTypes = []string{
	"button", "checkbox", "radio_button", "dropdown",
	"file_or_image", "video", "date_picker", "pagination",
	"popup_dialog", "label", "text_form", "textarea", "others",
}

Accepted types for validation

View Source
var TypesRequiringDataType = []string{"textarea", "text_form", "others"}

Types requiring specific validations

View Source
var TypesRequiringLength = []string{"textarea", "text_form", "file_or_image", "video", "others"}
View Source
var TypesWithoutValidation = []string{"button", "label"}

Functions

func CompareSpecs

func CompareSpecs(current, previous map[string]interface{}) bool

CompareSpecs returns true if specs are equal

func DetermineSpecStatus

func DetermineSpecStatus(spec *Spec, existingStatus string) (string, []string)

DetermineSpecStatus determines the appropriate status for a spec Returns (status, validationErrors)

func IsSpecContentEmpty

func IsSpecContentEmpty(spec *Spec) bool

IsSpecContentEmpty checks if spec content is empty (only contains structural/metadata fields)

func MapSpecForComparison

func MapSpecForComparison(spec *Spec) map[string]interface{}

MapSpecForComparison extracts fields for comparison Matches SDK's mapSpecForComparison()

func ResolveFiles

func ResolveFiles(args []string, dir string, recursive bool, uploadType string) ([]string, error)

ResolveFiles resolves file paths from arguments, directory, and recursive options Returns a list of CSV file paths that match the expected pattern

func ValidateSpecContent

func ValidateSpecContent(spec *Spec, status string) []string

ValidateSpecContent validates a spec content using the same validation logic as SDK's UpdateSpecDto

Types

type DatabaseSpec

type DatabaseSpec struct {
	TableName  string `json:"tableName,omitempty"`
	ColumnName string `json:"columnName,omitempty"`
	Note       string `json:"note,omitempty"`
}

DatabaseSpec contains database-related spec fields

type ItemSpec

type ItemSpec struct {
	Name       string `json:"name,omitempty"`
	NameTrans  string `json:"nameTrans,omitempty"`
	ButtonType string `json:"buttonType,omitempty"`
	OtherType  string `json:"otherType,omitempty"`
}

ItemSpec contains item-related spec fields

type NavigationSpec struct {
	Action          string `json:"action,omitempty"`
	LinkedFrameID   string `json:"linkedFrameId,omitempty"`
	LinkedFrameName string `json:"linkedFrameName,omitempty"`
	Note            string `json:"note,omitempty"`
}

NavigationSpec contains navigation-related spec fields

type ParsedFilePath

type ParsedFilePath struct {
	Type      string // "testcases" or "specs"
	FileKey   string // Figma file key
	FrameID   string // Frame ID (can contain colons)
	FrameName string // Frame name
}

ParsedFilePath contains extracted parameters from file path

func ParseFilePath

func ParseFilePath(fullFilePath string) (*ParsedFilePath, error)

ParseFilePath extracts metadata from file path Expected format: .momorph/{testcases|specs}/{file_key}/{frame_id}-{frame_name}.csv Example: .momorph/testcases/i09vM3jClQiu8cwXsMo6uy/9276:19907-TOP_Channel.csv

type Spec

type Spec struct {
	No             string `json:"no"`
	DesignItemName string `json:"design_item_name"`
	Name           string `json:"name"`
	NameTrans      string `json:"nameTrans,omitempty"`
	NodeLinkID     string `json:"node_link_id,omitempty"`
	SectionLinkID  string `json:"section_link_id,omitempty"`
	Type           string `json:"type,omitempty"`
	OtherType      string `json:"otherType,omitempty"`
	ButtonType     string `json:"buttonType,omitempty"`
	DataType       string `json:"dataType,omitempty"`
	Required       *bool  `json:"required,omitempty"`
	Format         string `json:"format,omitempty"`
	MinLength      *int   `json:"minLength,omitempty"`
	MaxLength      *int   `json:"maxLength,omitempty"`
	DefaultValue   string `json:"defaultValue,omitempty"`
	ValidationNote string `json:"validationNote,omitempty"`
	Action         string `json:"action,omitempty"`
	LinkedFrameID  string `json:"linkedFrameId,omitempty"`
	NavigationNote string `json:"navigationNote,omitempty"`
	TableName      string `json:"tableName,omitempty"`
	ColumnName     string `json:"columnName,omitempty"`
	DatabaseNote   string `json:"databaseNote,omitempty"`
	Description    string `json:"description,omitempty"`
	IsReviewed     *bool  `json:"is_reviewed,omitempty"`
}

Spec represents a single spec item from CSV

func ParseSpecsCSV

func ParseSpecsCSV(filePath string) ([]Spec, error)

ParseSpecsCSV parses a specs CSV file and returns a slice of Spec

type SpecDetails

type SpecDetails struct {
	Item        *ItemSpec       `json:"item,omitempty"`
	Navigation  *NavigationSpec `json:"navigation,omitempty"`
	Validation  *ValidationSpec `json:"validation,omitempty"`
	Database    *DatabaseSpec   `json:"database,omitempty"`
	Description string          `json:"description,omitempty"`
}

SpecDetails contains the detailed spec information

type SpecPayload

type SpecPayload struct {
	Type          string       `json:"type,omitempty"`
	NodeType      string       `json:"node_type,omitempty"`
	No            string       `json:"no"`
	Name          string       `json:"name"`
	Status        string       `json:"status,omitempty"`
	SectionLinkID string       `json:"section_link_id,omitempty"`
	NodeLinkID    string       `json:"node_link_id,omitempty"`
	FrameID       int          `json:"frame_id,omitempty"`
	FileID        int          `json:"file_id,omitempty"`
	IsReviewed    *bool        `json:"is_reviewed,omitempty"`
	Parent        string       `json:"parent,omitempty"`
	Position      interface{}  `json:"position,omitempty"`
	Specs         *SpecDetails `json:"specs,omitempty"`
}

SpecPayload represents the transformed payload for GraphQL mutation

func TransformSpecToPayload

func TransformSpecToPayload(spec Spec, frameID, fileID int, sectionLinkID, status string) *SpecPayload

TransformSpecToPayload transforms a Spec to SpecPayload for GraphQL mutation Uses type-based conditionals matching SDK's prepareSpecContentPayload

type TestCase

type TestCase struct {
	ID             string `json:"ID"`
	Step           string `json:"step,omitempty"`
	Category       string `json:"category,omitempty"`
	PageName       string `json:"page_name,omitempty"`
	TestArea       string `json:"test_area,omitempty"`
	TestData       string `json:"test_data,omitempty"`
	SubCategory    string `json:"sub_category,omitempty"`
	SubSubCategory string `json:"sub_sub_category,omitempty"`
	PreCondition   string `json:"pre_condition,omitempty"`
	ExpectedResult string `json:"expected_result,omitempty"`
	TCType         string `json:"tc_type,omitempty"`
	Priority       string `json:"priority,omitempty"`
	TestResults    string `json:"test_results,omitempty"`
	ExecutedDate   string `json:"executed_date,omitempty"`
	Tester         string `json:"tester,omitempty"`
	Note           string `json:"note,omitempty"`
}

TestCase represents a single test case item

type TestCaseContent

type TestCaseContent struct {
	ScreenName string     `json:"screen_name"`
	TestCases  []TestCase `json:"test_cases"`
}

TestCaseContent represents the content payload for uploading test cases

func ParseTestcasesCSV

func ParseTestcasesCSV(filePath string) (*TestCaseContent, error)

ParseTestcasesCSV parses a test cases CSV file and returns TestCaseContent

type UploadResult

type UploadResult struct {
	FilePath string
	FileName string
	Status   UploadStatus
	Error    error
	Message  string
}

UploadResult represents the result of uploading a single file

func ValidateFiles

func ValidateFiles(files []string, uploadType string) ([]string, []UploadResult)

ValidateFiles validates that all files exist and match expected pattern

type UploadStatus

type UploadStatus string

UploadStatus represents the status of a file upload

const (
	StatusSuccess UploadStatus = "success"
	StatusFailed  UploadStatus = "failed"
	StatusSkipped UploadStatus = "skipped"
)

type UploadSummary

type UploadSummary struct {
	Total   int
	Success int
	Failed  int
	Skipped int
	Results []UploadResult
}

UploadSummary contains aggregated upload results

func NewUploadSummary

func NewUploadSummary(results []UploadResult) *UploadSummary

NewUploadSummary creates a new UploadSummary from results

type ValidatedSpec

type ValidatedSpec struct {
	Spec
	Status   string   // determined status: none, draft, completed
	IsValid  bool     // whether spec passed validation
	Errors   []string // validation error messages
	Changed  bool     // whether spec differs from existing
	IsNew    bool     // whether this is a new item (not in DB)
	Existing *Spec    // reference to existing spec if any
}

ValidatedSpec represents a spec with validation results

type ValidationSpec

type ValidationSpec struct {
	DataType     string `json:"dataType,omitempty"`
	Required     *bool  `json:"required,omitempty"`
	Format       string `json:"format,omitempty"`
	MinLength    *int   `json:"minLength,omitempty"`
	MaxLength    *int   `json:"maxLength,omitempty"`
	DefaultValue string `json:"defaultValue,omitempty"`
	Note         string `json:"note,omitempty"`
}

ValidationSpec contains validation-related spec fields

Jump to

Keyboard shortcuts

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