api

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2025 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Overview

Package api provides the HTTP API server for the genealogy application.

Package api provides the HTTP API server for the genealogy application.

Index

Constants

View Source
const (
	CodeBadRequest    = "BAD_REQUEST"
	CodeNotFound      = "NOT_FOUND"
	CodeConflict      = "CONFLICT"
	CodeInternalError = "INTERNAL_ERROR"
	CodeValidation    = "VALIDATION_ERROR"
)

Error codes.

Variables

This section is empty.

Functions

func OpenAPISpec

func OpenAPISpec() []byte

OpenAPISpec returns the embedded OpenAPI specification.

Types

type APIError

type APIError struct {
	Code    string         `json:"code"`
	Message string         `json:"message"`
	Details map[string]any `json:"details,omitempty"`
}

APIError represents a standardized API error response.

func NewAPIError

func NewAPIError(code, message string) *APIError

NewAPIError creates a new API error with the given code and message.

func (*APIError) WithDetails

func (e *APIError) WithDetails(details map[string]any) *APIError

WithDetails adds details to the error.

type AddChildRequest

type AddChildRequest struct {
	ChildID          string  `json:"child_id" validate:"required"`
	RelationshipType *string `json:"relationship_type,omitempty"`
}

type CreateFamilyRequest

type CreateFamilyRequest struct {
	Partner1ID       *string `json:"partner1_id,omitempty"`
	Partner2ID       *string `json:"partner2_id,omitempty"`
	RelationshipType *string `json:"relationship_type,omitempty"`
	MarriageDate     *string `json:"marriage_date,omitempty"`
	MarriagePlace    *string `json:"marriage_place,omitempty"`
}

type CreatePersonRequest

type CreatePersonRequest struct {
	GivenName  string  `json:"given_name" validate:"required,min=1,max=100"`
	Surname    string  `json:"surname" validate:"required,min=1,max=100"`
	Gender     *string `json:"gender,omitempty"`
	BirthDate  *string `json:"birth_date,omitempty"`
	BirthPlace *string `json:"birth_place,omitempty"`
	DeathDate  *string `json:"death_date,omitempty"`
	DeathPlace *string `json:"death_place,omitempty"`
	Notes      *string `json:"notes,omitempty"`
}

type FamilyChildResponse

type FamilyChildResponse struct {
	ID               string `json:"id"`
	Name             string `json:"name"`
	RelationshipType string `json:"relationship_type"`
}

type FamilyDetailResponse

type FamilyDetailResponse struct {
	FamilyResponse
	Children []FamilyChildResponse `json:"children,omitempty"`
}

type FamilyListResponse

type FamilyListResponse struct {
	Items  []FamilyResponse `json:"items"`
	Total  int              `json:"total"`
	Limit  int              `json:"limit"`
	Offset int              `json:"offset"`
}

type FamilyResponse

type FamilyResponse struct {
	ID               string  `json:"id"`
	Partner1ID       *string `json:"partner1_id,omitempty"`
	Partner1Name     *string `json:"partner1_name,omitempty"`
	Partner2ID       *string `json:"partner2_id,omitempty"`
	Partner2Name     *string `json:"partner2_name,omitempty"`
	RelationshipType *string `json:"relationship_type,omitempty"`
	MarriageDate     any     `json:"marriage_date,omitempty"`
	MarriagePlace    *string `json:"marriage_place,omitempty"`
	ChildCount       int     `json:"child_count"`
	Version          int64   `json:"version"`
}

type FamilySummaryResponse

type FamilySummaryResponse struct {
	ID               string  `json:"id"`
	Partner1Name     *string `json:"partner1_name,omitempty"`
	Partner2Name     *string `json:"partner2_name,omitempty"`
	RelationshipType *string `json:"relationship_type,omitempty"`
}

type ImportGedcomResponse

type ImportGedcomResponse struct {
	ImportID         string   `json:"import_id"`
	PersonsImported  int      `json:"persons_imported"`
	FamiliesImported int      `json:"families_imported"`
	Warnings         []string `json:"warnings,omitempty"`
	Errors           []string `json:"errors,omitempty"`
}

ImportGedcomResponse represents the response from a GEDCOM import.

type PedigreeNodeResponse

type PedigreeNodeResponse struct {
	ID         string                `json:"id"`
	GivenName  string                `json:"given_name"`
	Surname    string                `json:"surname"`
	Gender     string                `json:"gender,omitempty"`
	BirthDate  *string               `json:"birth_date,omitempty"`
	BirthPlace *string               `json:"birth_place,omitempty"`
	DeathDate  *string               `json:"death_date,omitempty"`
	DeathPlace *string               `json:"death_place,omitempty"`
	Generation int                   `json:"generation"`
	Father     *PedigreeNodeResponse `json:"father,omitempty"`
	Mother     *PedigreeNodeResponse `json:"mother,omitempty"`
}

PedigreeNodeResponse represents a person in the pedigree tree.

type PedigreeResponse

type PedigreeResponse struct {
	Root           *PedigreeNodeResponse `json:"root"`
	TotalAncestors int                   `json:"total_ancestors"`
	MaxGeneration  int                   `json:"max_generation"`
}

PedigreeResponse represents the pedigree tree for a person.

type PersonDetailResponse

type PersonDetailResponse struct {
	PersonResponse
	FamiliesAsPartner []FamilySummaryResponse `json:"families_as_partner,omitempty"`
	FamilyAsChild     *FamilySummaryResponse  `json:"family_as_child,omitempty"`
}

type PersonListResponse

type PersonListResponse struct {
	Items  []PersonResponse `json:"items"`
	Total  int              `json:"total"`
	Limit  int              `json:"limit"`
	Offset int              `json:"offset"`
}

type PersonResponse

type PersonResponse struct {
	ID         string  `json:"id"`
	GivenName  string  `json:"given_name"`
	Surname    string  `json:"surname"`
	Gender     *string `json:"gender,omitempty"`
	BirthDate  any     `json:"birth_date,omitempty"`
	BirthPlace *string `json:"birth_place,omitempty"`
	DeathDate  any     `json:"death_date,omitempty"`
	DeathPlace *string `json:"death_place,omitempty"`
	Notes      *string `json:"notes,omitempty"`
	Version    int64   `json:"version"`
}

type Server

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

Server wraps the Echo server with application dependencies.

func NewServer

func NewServer(
	cfg *config.Config,
	eventStore repository.EventStore,
	readStore repository.ReadModelStore,
	frontendFS fs.FS,
) *Server

NewServer creates a new API server with all dependencies.

func (*Server) Echo

func (s *Server) Echo() *echo.Echo

Echo returns the underlying Echo instance (for testing).

func (*Server) Shutdown

func (s *Server) Shutdown() error

Shutdown gracefully shuts down the server.

func (*Server) Start

func (s *Server) Start() error

Start starts the HTTP server.

type UpdateFamilyRequest

type UpdateFamilyRequest struct {
	Partner1ID       *string `json:"partner1_id,omitempty"`
	Partner2ID       *string `json:"partner2_id,omitempty"`
	RelationshipType *string `json:"relationship_type,omitempty"`
	MarriageDate     *string `json:"marriage_date,omitempty"`
	MarriagePlace    *string `json:"marriage_place,omitempty"`
	Version          int64   `json:"version" validate:"required"`
}

type UpdatePersonRequest

type UpdatePersonRequest struct {
	GivenName  *string `json:"given_name,omitempty"`
	Surname    *string `json:"surname,omitempty"`
	Gender     *string `json:"gender,omitempty"`
	BirthDate  *string `json:"birth_date,omitempty"`
	BirthPlace *string `json:"birth_place,omitempty"`
	DeathDate  *string `json:"death_date,omitempty"`
	DeathPlace *string `json:"death_place,omitempty"`
	Notes      *string `json:"notes,omitempty"`
	Version    int64   `json:"version" validate:"required"`
}

Jump to

Keyboard shortcuts

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