onboarding

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package onboarding is a new instance's first run: the claim code that makes the first owner, the getting-started checklist, and the sample data.

Index

Constants

View Source
const ClaimCookie = "skael_claim"

ClaimCookie carries a verified claim code through sign-up, including an OAuth round trip.

View Source
const PingInterval = 24 * time.Hour

PingInterval is how often the leader sends the ping.

View Source
const PingURL = "https://telemetry.skael.dev/v1/ping"

PingURL receives the anonymous install ping.

View Source
const SampleDomain = "@sample.skael.invalid"

SampleDomain marks the sample people.

View Source
const SampleSuite = "sample:onboarding"

SampleSuite marks the sample scores and the sample contest.

Variables

This section is empty.

Functions

func MarkSynced

func MarkSynced(ctx context.Context, pool *pgxpool.Pool)

MarkSynced records the first sync from a CLI.

func RegisterRoutes

func RegisterRoutes(api huma.API, pool *pgxpool.Pool, sample *Sample, facts func() SetupFacts)

RegisterRoutes serves the checklist to everyone signed in, and the sample actions to owners and admins.

func RegisterSetupRoutes

func RegisterSetupRoutes(api huma.API, claim *Claim, enforced bool, cookieSecure bool)

RegisterSetupRoutes serves a fresh instance before anyone signs in. enforced is false where no claim code is required, such as in tests.

func SendPing

func SendPing(ctx context.Context, client *http.Client, url string, p Ping) error

SendPing posts p to url. A failure is not an error for the caller: the ping never affects the server.

Types

type Claim

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

Claim guards a fresh instance: until a person exists, signing up needs the code the server prints to its log.

func NewClaim

func NewClaim(pool *pgxpool.Pool) *Claim

NewClaim returns the guard.

func (*Claim) Claimed

func (c *Claim) Claimed(r *http.Request) bool

Claimed reports whether r carries the verified claim code.

func (*Claim) Ensure

func (c *Claim) Ensure(ctx context.Context) (string, error)

Ensure returns the claim code while the instance has no person, creating it once. It returns "" once someone has signed up.

func (*Claim) Open

func (c *Claim) Open(ctx context.Context) (bool, error)

Open reports whether the instance has no person yet.

func (*Claim) Verify

func (c *Claim) Verify(ctx context.Context, code string) (bool, error)

Verify reports whether code is the claim code.

type OnboardingStatus

type OnboardingStatus struct {
	Steps        []Step `json:"steps"`
	Setup        []Step `json:"setup"`
	SampleLoaded bool   `json:"sample_loaded"`
	// PublicURL is the saved public URL, empty when none is set.
	PublicURL string `json:"public_url"`
}

OnboardingStatus is the checklist toward the first activation and the setup card, which blocks nothing.

func Status

func Status(ctx context.Context, pool *pgxpool.Pool, facts SetupFacts) (*OnboardingStatus, error)

Status reads the checklist. Sample rows never complete a step.

type Ping

type Ping struct {
	InstallID       string `json:"install_id"`
	Version         string `json:"version"`
	PostgresVersion string `json:"postgres_version"`
	Workers         int    `json:"workers"`
	EvalsConfigured bool   `json:"evals_configured"`
}

Ping is everything the install ping sends. Nothing in it names a person, a company, a skill or a host.

func BuildPing

func BuildPing(ctx context.Context, pool *pgxpool.Pool, version string) (Ping, error)

BuildPing reads the ping's fields. Sample rows never count.

type Sample

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

Sample loads and removes the sample workspace.

func NewSample

func NewSample(pool *pgxpool.Pool, skills *skill.Store, publisher *skill.Publisher, q *quality.Store, storage platform.Storage) *Sample

NewSample returns the loader.

func (*Sample) Load

func (s *Sample) Load(ctx context.Context, actor string) error

Load adds the sample skills, scores, a contest verdict, six sample people and 30 days of activations. It refuses when sample data exists.

func (*Sample) Loaded

func (s *Sample) Loaded(ctx context.Context) (bool, error)

Loaded reports whether sample data exists.

func (*Sample) Remove

func (s *Sample) Remove(ctx context.Context, actor string) error

Remove deletes every sample row and archive.

type SetupBody

type SetupBody struct {
	ClaimRequired bool `json:"claim_required"`
}

type SetupClaimBody

type SetupClaimBody struct {
	Code string `json:"code" minLength:"1" maxLength:"32"`
}

type SetupFacts

type SetupFacts struct {
	PublicURL, SMTPHost string
	SignIn              bool
}

SetupFacts are the settings the setup card reads.

type Step

type Step struct {
	ID    string `json:"id"`
	Title string `json:"title"`
	Done  bool   `json:"done"`
}

Step is one checklist or setup item.

Jump to

Keyboard shortcuts

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