api

package
v1.31.1 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const BaseURLOverrideRequired = "override"
View Source
const BaseURLPlaceholder = "${baseURL}"

Variables

This section is empty.

Functions

func Logout added in v1.30.0

func Logout() error

func SubmitCLILesson added in v1.15.0

func SubmitCLILesson(uuid string, results []CLIStepResult, captureDebug bool) (LessonSubmissionEvent, SubmissionDebugData, error)

Types

type CLICommandJqOutput added in v1.23.0

type CLICommandJqOutput struct {
	Query   string
	Results []string
	Error   string
}

type CLICommandResult added in v1.3.0

type CLICommandResult struct {
	ExitCode     int
	Err          string            `json:"-"`
	FinalCommand string            `json:"-"`
	Command      CLIStepCLICommand `json:"-"`
	Stdout       string
	Stderr       string `json:"-"`
	Variables    map[string]string
	JqOutputs    []CLICommandJqOutput `json:"-"`
}

type CLICommandStdoutVariable added in v1.30.0

type CLICommandStdoutVariable struct {
	Name  string `yaml:"name"`
	Regex string `yaml:"regex"`
}

type CLICommandTest added in v1.15.1

type CLICommandTest struct {
	ExitCode           *int          `yaml:"exitCode"`
	StdoutContainsAll  []string      `yaml:"stdoutContainsAll"`
	StdoutContainsNone []string      `yaml:"stdoutContainsNone"`
	StdoutLinesGT      *int          `yaml:"stdoutLinesGT"`
	StdoutJq           *StdoutJqTest `yaml:"stdoutJq"`
}

type CLIData added in v1.15.0

type CLIData struct {
	// ContainsCompleteDir     bool
	BaseURLDefault          string    `yaml:"baseURLDefault"`
	Steps                   []CLIStep `yaml:"steps"`
	AllowedOperatingSystems []string  `yaml:"allowedOperatingSystems"`
}

type CLIStep added in v1.18.0

type CLIStep struct {
	Description     string              `yaml:"description"`
	CLICommand      *CLIStepCLICommand  `yaml:"cliCommand"`
	HTTPRequest     *CLIStepHTTPRequest `yaml:"httpRequest"`
	NoPenaltyOnFail bool                `yaml:"noPenaltyOnFail"`
}

type CLIStepCLICommand added in v1.15.0

type CLIStepCLICommand struct {
	Command          string                     `yaml:"command"`
	Tests            []CLICommandTest           `yaml:"tests"`
	StdoutVariables  []CLICommandStdoutVariable `yaml:"stdoutVariables"`
	SleepAfterMs     *int                       `yaml:"sleepAfterMs"`
	StdoutFilterTmdl *string                    `yaml:"stdoutFilterTmdl"`
}

type CLIStepHTTPRequest added in v1.15.0

type CLIStepHTTPRequest struct {
	ResponseVariables       []HTTPRequestResponseVariable       `yaml:"responseVariables"`
	ResponseHeaderVariables []HTTPRequestResponseHeaderVariable `yaml:"responseHeaderVariables"`
	Tests                   []HTTPRequestTest                   `yaml:"tests"`
	Request                 HTTPRequest                         `yaml:"request"`
	SleepAfterMs            *int                                `yaml:"sleepAfterMs"`
}

type CLIStepResult added in v1.15.0

type CLIStepResult struct {
	CLICommandResult  *CLICommandResult
	HTTPRequestResult *HTTPRequestResult
}

type CurrentUserResponse added in v1.29.0

type CurrentUserResponse struct {
	Handle string `json:"handle"`
}

func FetchCurrentUser added in v1.29.0

func FetchCurrentUser() (*CurrentUserResponse, error)

type HTTPBasicAuth added in v1.18.0

type HTTPBasicAuth struct {
	Username string `yaml:"username"`
	Password string `yaml:"password"`
}

type HTTPRequest added in v1.18.0

type HTTPRequest struct {
	Method          string            `yaml:"method"`
	FullURL         string            `yaml:"fullURL"`
	Headers         map[string]string `yaml:"headers"`
	BodyJSON        map[string]any    `yaml:"bodyJSON"`
	BodyForm        map[string]string `yaml:"bodyForm"`
	FollowRedirects *bool             `yaml:"followRedirects"`

	BasicAuth *HTTPBasicAuth `yaml:"basicAuth"`
}

type HTTPRequestResponseHeaderVariable added in v1.30.0

type HTTPRequestResponseHeaderVariable struct {
	Name   string `yaml:"name"`
	Header string `yaml:"header"`
	Regex  string `yaml:"regex"`
}

type HTTPRequestResponseVariable added in v1.15.1

type HTTPRequestResponseVariable struct {
	Name      string `yaml:"name"`
	Path      string `yaml:"path"`
	BodyRegex string `yaml:"bodyRegex"`
}

type HTTPRequestResult added in v1.15.0

type HTTPRequestResult struct {
	Err              string `json:"FetchErr,omitempty"`
	StatusCode       int
	ResponseHeaders  map[string]string
	ResponseTrailers map[string]string
	BodyString       string
	Variables        map[string]string
	Request          CLIStepHTTPRequest
}

type HTTPRequestTest added in v1.15.1

type HTTPRequestTest struct {
	StatusCode       *int                      `yaml:"statusCode"`
	BodyContains     *string                   `yaml:"bodyContains"`
	BodyContainsNone *string                   `yaml:"bodyContainsNone"`
	HeadersContain   *HTTPRequestTestHeader    `yaml:"headersContain"`
	TrailersContain  *HTTPRequestTestHeader    `yaml:"trailersContain"`
	JSONValue        *HTTPRequestTestJSONValue `yaml:"jsonValue"`
}

HTTPRequestTest should have only one field set

type HTTPRequestTestHeader added in v1.15.1

type HTTPRequestTestHeader struct {
	Key   string `yaml:"key"`
	Value string `yaml:"value"`
}

type HTTPRequestTestJSONValue added in v1.15.1

type HTTPRequestTestJSONValue struct {
	Path        string       `yaml:"path"`
	Operator    OperatorType `yaml:"operator"`
	IntValue    *int         `yaml:"intValue"`
	StringValue *string      `yaml:"stringValue"`
	BoolValue   *bool        `yaml:"boolValue"`
}

type JqExpectedResult added in v1.23.0

type JqExpectedResult struct {
	Type     JqValueType `yaml:"type"`
	Operator JqOperator  `yaml:"operator"`
	Value    any         `yaml:"value"`
}

type JqOperator added in v1.23.0

type JqOperator string // defined fully on backend

type JqValueType added in v1.23.0

type JqValueType string
const (
	JqTypeString JqValueType = "string"
	JqTypeInt    JqValueType = "int"
	JqTypeBool   JqValueType = "bool"
)

type Lesson added in v1.4.0

type Lesson struct {
	Lesson struct {
		Type          string
		Title         string
		LessonDataCLI *LessonDataCLI
	}
	ChapterNumber int
	LessonNumber  int
}

func FetchLesson added in v1.4.0

func FetchLesson(uuid string) (*Lesson, error)

type LessonDataCLI added in v1.15.0

type LessonDataCLI struct {
	// Readme  string
	CLIData CLIData
}

type LessonSubmissionEvent added in v1.25.0

type LessonSubmissionEvent struct {
	ResultSlug       VerificationResultSlug
	StructuredErrCLI *StructuredErrCLI
	XPReward         int
	XPBreakdown      []XPBreakdownItem
}

type LoginRequest

type LoginRequest struct {
	Otp string `json:"otp"`
}

type LoginResponse

type LoginResponse struct {
	AccessToken  string `json:"access_token"`
	RefreshToken string `json:"refresh_token"`
}

func FetchAccessToken

func FetchAccessToken() (*LoginResponse, error)

func LoginWithCode

func LoginWithCode(code string) (*LoginResponse, error)

type NextCLILesson added in v1.31.0

type NextCLILesson struct {
	LessonUUID    string
	LessonTitle   string
	ChapterTitle  string
	ChapterNumber int
	LessonNumber  int
}

func FetchNextCLILesson added in v1.31.0

func FetchNextCLILesson() (*NextCLILesson, error)

type OperatorType

type OperatorType string
const (
	OpEquals      OperatorType = "eq"
	OpGreaterThan OperatorType = "gt"
	OpContains    OperatorType = "contains"
	OpNotContains OperatorType = "not_contains"
)

type StdoutJqTest added in v1.23.0

type StdoutJqTest struct {
	InputMode       string             `yaml:"inputMode"` // "json" or "jsonl"
	Query           string             `yaml:"query"`
	ExpectedResults []JqExpectedResult `yaml:"expectedResults"`
}

type StructuredErrCLI added in v1.15.0

type StructuredErrCLI struct {
	ErrorMessage    string `json:"Error"`
	FailedStepIndex int    `json:"FailedStepIndex"`
	FailedTestIndex int    `json:"FailedTestIndex"`
}

type SubmissionDebugData added in v1.27.0

type SubmissionDebugData struct {
	Endpoint           string
	RequestBody        string
	ResponseStatusCode int
	ResponseBody       string
}

type VerificationResultSlug added in v1.25.0

type VerificationResultSlug string
const (
	// "noop" is for "noPenaltyOnFail" on the CLI type
	VerificationResultSlugNoop        VerificationResultSlug = "noop"
	VerificationResultSlugSystemError VerificationResultSlug = "system-error"
	VerificationResultSlugSuccess     VerificationResultSlug = "success"
	VerificationResultSlugFailure     VerificationResultSlug = "failure"
)

type XPBreakdownItem added in v1.29.6

type XPBreakdownItem struct {
	Name    string
	Percent float64
	XP      int
}

Jump to

Keyboard shortcuts

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