publicapi

package
v0.0.0-...-3dffe8b Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2024 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidProject = rerror.NewE(i18n.T("invalid project"))

Functions

func AttachController

func AttachController(ctx context.Context, c *Controller) context.Context

func Echo

func Echo(e *echo.Group)

func PublicApiAsset

func PublicApiAsset() echo.HandlerFunc

func PublicApiItemList

func PublicApiItemList() echo.HandlerFunc

func PublicApiItemOrAsset

func PublicApiItemOrAsset() echo.HandlerFunc

Types

type Asset

type Asset struct {
	Type        string   `json:"type"`
	ID          string   `json:"id,omitempty"`
	URL         string   `json:"url,omitempty"`
	ContentType string   `json:"contentType,omitempty"`
	Files       []string `json:"files,omitempty"`
}

func NewAsset

func NewAsset(a *asset.Asset, f *asset.File, urlResolver asset.URLResolver) Asset

type Controller

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

func GetController

func GetController(ctx context.Context) *Controller

func NewController

func NewController(project repo.Project, usecases *interfaces.Container, aur asset.URLResolver) *Controller

func (*Controller) GetAsset

func (c *Controller) GetAsset(ctx context.Context, prj, i string) (Asset, error)

func (*Controller) GetItem

func (c *Controller) GetItem(ctx context.Context, prj, mkey, i string) (Item, error)

func (*Controller) GetItems

func (c *Controller) GetItems(ctx context.Context, prj, model string, p ListParam) (ListResult[Item], *schema.Schema, error)

type Item

type Item struct {
	ID     string
	Fields ItemFields
}

func NewItem

func NewItem(i *item.Item, sp *schema.Package, assets asset.List, urlResolver asset.URLResolver, refItems []Item) Item

func (Item) MarshalJSON

func (i Item) MarshalJSON() ([]byte, error)

type ItemAsset

type ItemAsset struct {
	Type string `json:"type"`
	ID   string `json:"id,omitempty"`
	URL  string `json:"url,omitempty"`
}

func NewItemAsset

func NewItemAsset(a *asset.Asset, urlResolver asset.URLResolver) ItemAsset

type ItemFields

type ItemFields map[string]any

func NewItemFields

func NewItemFields(fields item.Fields, sfields schema.FieldList, groupFields schema.FieldList, refItems []Item, assets asset.List, urlResolver asset.URLResolver) ItemFields

func (ItemFields) DropEmptyFields

func (i ItemFields) DropEmptyFields() ItemFields

type ListParam

type ListParam struct {
	Pagination *usecasex.Pagination
}

type ListResult

type ListResult[T any] struct {
	Results    []T   `json:"results"`
	TotalCount int64 `json:"totalCount"`
	HasMore    *bool `json:"hasMore,omitempty"`
	// offset base
	Limit  *int64 `json:"limit,omitempty"`
	Offset *int64 `json:"offset,omitempty"`
	Page   *int64 `json:"page,omitempty"`
	// cursor base
	NextCursor *string `json:"nextCursor,omitempty"`
}

func NewListResult

func NewListResult[T any](results []T, pi *usecasex.PageInfo, p *usecasex.Pagination) ListResult[T]

Jump to

Keyboard shortcuts

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