core

package
v1.6.5-beta0 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2025 License: MIT Imports: 18 Imported by: 7

Documentation

Index

Constants

View Source
const (
	RequesterTypeCtxKey      = "cc-requesterType"
	RequesterIdCtxKey        = "cc-requesterId"
	RequesterTagCtxKey       = "cc-requesterTag"
	RequesterDomainCtxKey    = "cc-requesterDomain"
	RequesterDomainTagsKey   = "cc-requesterDomainTags"
	RequesterKeychainKey     = "cc-requesterKeychain"
	RequesterPassportKey     = "cc-requesterPassport"
	RequesterIsRegisteredKey = "cc-requesterIsRegistered"
	CaptchaVerifiedKey       = "cc-captchaVerified"
)
View Source
const (
	RequesterTypeHeader         = "cc-requester-type"
	RequesterIdHeader           = "cc-requester-ccid"
	RequesterTagHeader          = "cc-requester-tag"
	RequesterDomainHeader       = "cc-requester-domain"
	RequesterDomainTagsHeader   = "cc-requester-domain-tags"
	RequesterKeychainHeader     = "cc-requester-keychain"
	RequesterPassportHeader     = "passport"
	RequesterIsRegisteredHeader = "cc-requester-is-registered"
	CaptchaVerifiedHeader       = "cc-captcha-verified"
)
View Source
const (
	Unknown = iota
	LocalUser
	RemoteUser
	RemoteDomain
)
View Source
const (
	JobStatusPending   = "pending"
	JobStatusRunning   = "running"
	JobStatusCompleted = "completed"
	JobStatusFailed    = "failed"
)

Variables

This section is empty.

Functions

func Chunk2ImmediateTime

func Chunk2ImmediateTime(chunk string) time.Time

func Chunk2RecentTime

func Chunk2RecentTime(chunk string) time.Time

func EpochTime

func EpochTime(epoch string) time.Time

func GetHash

func GetHash(bytes []byte) []byte

func IsCCID

func IsCCID(keyID string) bool

func IsCKID

func IsCKID(keyID string) bool

func IsCSID

func IsCSID(keyID string) bool

func JsonPrint

func JsonPrint(tag string, obj interface{})

func NextChunk

func NextChunk(chunk string) string

func PrevChunk

func PrevChunk(chunk string) string

func PrivKeyToAddr

func PrivKeyToAddr(privKeyHex string, hrp string) (string, error)

func PubkeyBytesToAddr

func PubkeyBytesToAddr(pubkeyBytes []byte, hrp string) (string, error)

func PubkeyToAddr

func PubkeyToAddr(pubkeyHex string, hrp string) (string, error)

func RequesterTypeString

func RequesterTypeString(t int) string

func SignBytes

func SignBytes(bytes []byte, privatekey string) ([]byte, error)

func Time2Chunk

func Time2Chunk(t time.Time) string

func TypedIDToType

func TypedIDToType(id string) string

func VerifySignature

func VerifySignature(message []byte, signature []byte, address string) error

Types

type Ack

type Ack struct {
	From      string `json:"from" gorm:"primaryKey;type:char(42)"`
	To        string `json:"to" gorm:"primaryKey;type:char(42)"`
	Document  string `json:"document" gorm:"type:json"`
	Signature string `json:"signature" gorm:"type:char(130)"`
	Valid     bool   `json:"valid" gorm:"type:boolean;default:false"`
}

type AckDocument

type AckDocument struct {
	DocumentBase[any]
	From string `json:"from"`
	To   string `json:"to"`
}

ack

type AckService

type AckService interface {
	Ack(ctx context.Context, mode CommitMode, document, signature string) (Ack, error)
	GetAcker(ctx context.Context, key string) ([]Ack, error)
	GetAcking(ctx context.Context, key string) ([]Ack, error)
}

type AffiliationDocument

type AffiliationDocument struct {
	Domain string `json:"domain"`
	DocumentBase[any]
}

entity

type AgentService

type AgentService interface {
	Boot()
}

type Association

type Association struct {
	ID        string         `json:"id" gorm:"primaryKey;type:char(26)"`
	Author    string         `json:"author" gorm:"type:char(42)"`
	Owner     string         `json:"owner" gorm:"type:char(42)"`
	SchemaID  uint           `json:"-"`
	Schema    string         `json:"schema" gorm:"-"`
	Target    string         `json:"target" gorm:"type:char(27)"`
	Variant   string         `json:"variant" gorm:"type:text"`
	Unique    string         `json:"unique" gorm:"type:char(32);uniqueIndex:uniq_association"`
	Document  string         `json:"document" gorm:"type:json"`
	Signature string         `json:"signature" gorm:"type:char(130)"`
	CDate     time.Time      `json:"cdate" gorm:"->;<-:create;type:timestamp with time zone;not null;default:clock_timestamp()"`
	Timelines pq.StringArray `json:"timelines" gorm:"type:text[]"`
}

Association is one of a concurrent base object immutable

type AssociationDocument

type AssociationDocument[T any] struct {
	DocumentBase[T]
	Timelines []string `json:"timelines"`
	Variant   string   `json:"variant"`
	Target    string   `json:"target"`
}

association

type AssociationService

type AssociationService interface {
	Create(ctx context.Context, mode CommitMode, document, signature string) (Association, []string, error)
	Delete(ctx context.Context, mode CommitMode, document, signature string) (Association, []string, error)

	Clean(ctx context.Context, ccid string) error
	Get(ctx context.Context, id string) (Association, error)
	GetOwn(ctx context.Context, author string) ([]Association, error)
	GetByTarget(ctx context.Context, targetID string) ([]Association, error)
	GetCountsBySchema(ctx context.Context, messageID string) (map[string]int64, error)
	GetBySchema(ctx context.Context, messageID string, schema string) ([]Association, error)
	GetCountsBySchemaAndVariant(ctx context.Context, messageID string, schema string) (map[string]int64, error)
	GetBySchemaAndVariant(ctx context.Context, messageID string, schema string, variant string) ([]Association, error)
	GetOwnByTarget(ctx context.Context, targetID, author string) ([]Association, error)
	Count(ctx context.Context) (int64, error)
}

type AuthService

type AuthService interface {
	IssuePassport(ctx context.Context, requester string, key []Key) (string, error)
	IdentifyIdentity(next echo.HandlerFunc) echo.HandlerFunc
	RateLimiter(configMap RateLimitConfigMap) echo.MiddlewareFunc
}

type BatchResult

type BatchResult struct {
	ID    string
	Error string
}

type Chunk

type Chunk struct {
	Key   string         `json:"key"`
	Epoch string         `json:"epoch"`
	Items []TimelineItem `json:"items"`
}

type Commit

type Commit struct {
	Document  string `json:"document"`
	Signature string `json:"signature"`
	Option    string `json:"option"`
}

type CommitLog

type CommitLog struct {
	ID           uint          `json:"id" gorm:"primaryKey;auto_increment"`
	IP           string        `json:"ip" gorm:"type:text"`
	DocumentID   string        `json:"documentID" gorm:"type:char(26);uniqueIndex:idx_document_id"`
	IsEphemeral  bool          `json:"isEphemeral" gorm:"type:boolean;default:false"`
	Type         string        `json:"type" gorm:"type:text"`
	Document     string        `json:"document" gorm:"type:json"`
	Signature    string        `json:"signature" gorm:"type:char(130)"`
	SignedAt     time.Time     `json:"signedAt" gorm:"type:timestamp with time zone;not null;default:clock_timestamp()"`
	CommitOwners []CommitOwner `json:"commitOwners" gorm:"foreignKey:CommitLogID"`
	Owners       []string      `json:"owners" gorm:"-"`
	CDate        time.Time     `json:"cdate" gorm:"type:timestamp with time zone;not null;default:clock_timestamp()"`
}

type CommitMode

type CommitMode int
const (
	CommitModeUnknown CommitMode = iota
	CommitModeExecute
	CommitModeDryRun
	CommitModeLocalOnlyExec
)

type CommitOwner

type CommitOwner struct {
	ID          uint   `json:"id" gorm:"primaryKey;auto_increment"`
	CommitLogID uint   `json:"commitLogID" gorm:"index;uniqueIndex:idx_commit_owner"`
	Owner       string `json:"owner" gorm:"type:char(42);index;uniqueIndex:idx_commit_owner"`
}

type Config

type Config struct {
	FQDN         string `yaml:"fqdn"`
	PrivateKey   string `yaml:"privatekey"`
	Registration string `yaml:"registration"` // open, invite, close
	SiteKey      string `yaml:"sitekey"`
	Dimension    string `yaml:"dimension"`
	CCID         string `yaml:"ccid"`
	CSID         string `yaml:"csid"`
}

func SetupConfig

func SetupConfig(base ConfigInput) Config

type ConfigInput

type ConfigInput struct {
	FQDN         string `yaml:"fqdn"`
	PrivateKey   string `yaml:"privatekey"`
	Registration string `yaml:"registration"` // open, invite, close
	SiteKey      string `yaml:"sitekey"`
	Dimension    string `yaml:"dimension"`
}

type DeleteDocument

type DeleteDocument struct {
	DocumentBase[any]
	Target string `json:"target"`
}

type DocumentBase

type DocumentBase[T any] struct {
	ID             string    `json:"id,omitempty"`
	Signer         string    `json:"signer"`
	Owner          string    `json:"owner,omitempty"`
	Type           string    `json:"type"`
	Schema         string    `json:"schema,omitempty"`
	Policy         string    `json:"policy,omitempty"`
	PolicyParams   string    `json:"policyParams,omitempty"`
	PolicyDefaults string    `json:"policyDefaults,omitempty"`
	KeyID          string    `json:"keyID,omitempty"`
	Body           T         `json:"body,omitempty"`
	Meta           any       `json:"meta,omitempty"`
	SemanticID     string    `json:"semanticID,omitempty"`
	SignedAt       time.Time `json:"signedAt"`
}

commons

type Domain

type Domain struct {
	ID           string      `json:"fqdn" gorm:"type:text"` // FQDN
	CCID         string      `json:"ccid" gorm:"type:char(42)"`
	CSID         string      `json:"csid" gorm:"type:char(42)"`
	Tag          string      `json:"tag" gorm:"type:text"`
	Score        int         `json:"score" gorm:"type:integer;default:0"`
	Meta         interface{} `json:"meta" gorm:"-"`
	IsScoreFixed bool        `json:"isScoreFixed" gorm:"type:boolean;default:false"`
	Dimension    string      `json:"dimension" gorm:"-"`
	CDate        time.Time   `json:"cdate" gorm:"->;<-:create;type:timestamp with time zone;not null;default:clock_timestamp()"`
	MDate        time.Time   `json:"mdate" gorm:"autoUpdateTime"`
	LastScraped  time.Time   `json:"lastScraped" gorm:"type:timestamp with time zone"`
}

Domain is one of a concurrent base object mutable

type DomainService

type DomainService interface {
	Upsert(ctx context.Context, host Domain) (Domain, error)
	Get(ctx context.Context, key string) (Domain, error)
	GetByFQDN(ctx context.Context, key string) (Domain, error)
	GetByCCID(ctx context.Context, key string) (Domain, error)
	ForceFetch(ctx context.Context, fqdn string) (Domain, error)
	List(ctx context.Context) ([]Domain, error)
	Delete(ctx context.Context, id string) error
	Update(ctx context.Context, host Domain) error
	UpdateScrapeTime(ctx context.Context, id string, scrapeTime time.Time) error
}

type EnactDocument

type EnactDocument struct {
	DocumentBase[any]
	Target string `json:"target"`
	Root   string `json:"root"`
	Parent string `json:"parent"`
}

key

type Entity

type Entity struct {
	ID                   string    `json:"ccid" gorm:"type:char(42)"`
	Domain               string    `json:"domain" gorm:"type:text"`
	Tag                  string    `json:"tag" gorm:"type:text;"`
	Score                int       `json:"score" gorm:"type:integer;default:0"`
	IsScoreFixed         bool      `json:"isScoreFixed" gorm:"type:boolean;default:false"`
	AffiliationDocument  string    `json:"affiliationDocument" gorm:"type:json"`
	AffiliationSignature string    `json:"affiliationSignature" gorm:"type:char(130)"`
	TombstoneDocument    *string   `json:"tombstoneDocument" gorm:"type:json;default:null"`
	TombstoneSignature   *string   `json:"tombstoneSignature" gorm:"type:char(130);default:null"`
	Alias                *string   `json:"alias,omitempty" gorm:"type:text"`
	CDate                time.Time `json:"cdate" gorm:"->;<-:create;type:timestamp with time zone;not null;default:clock_timestamp()"`
	MDate                time.Time `json:"mdate" gorm:"autoUpdateTime"`
}

Entity is one of a concurrent base object mutable

type EntityMeta

type EntityMeta struct {
	ID      string  `json:"ccid" gorm:"type:char(42)"`
	Inviter *string `json:"inviter" gorm:"type:char(42)"`
	Info    string  `json:"info" gorm:"type:json;default:'null'"`
}

type EntityService

type EntityService interface {
	Affiliation(ctx context.Context, mode CommitMode, document, signature, meta string) (Entity, error)
	Tombstone(ctx context.Context, mode CommitMode, document, signature string) (Entity, error)

	Clean(ctx context.Context, ccid string) error
	Get(ctx context.Context, ccid string) (Entity, error)
	GetWithHint(ctx context.Context, ccid, hint string) (Entity, error)
	GetMeta(ctx context.Context, ccid string) (EntityMeta, error)
	GetByAlias(ctx context.Context, alias string) (Entity, error)
	List(ctx context.Context) ([]Entity, error)
	UpdateScore(ctx context.Context, id string, score int) error
	UpdateTag(ctx context.Context, id, tag string) error
	IsUserExists(ctx context.Context, user string) bool
	Delete(ctx context.Context, id string) error
	Count(ctx context.Context) (int64, error)
	PullEntityFromRemote(ctx context.Context, id, domain string) (Entity, error)
}

type ErrorAlreadyDeleted

type ErrorAlreadyDeleted struct {
}

func NewErrorAlreadyDeleted

func NewErrorAlreadyDeleted() ErrorAlreadyDeleted

func (ErrorAlreadyDeleted) Error

func (e ErrorAlreadyDeleted) Error() string

type ErrorAlreadyExists

type ErrorAlreadyExists struct {
}

func NewErrorAlreadyExists

func NewErrorAlreadyExists() ErrorAlreadyExists

func (ErrorAlreadyExists) Error

func (e ErrorAlreadyExists) Error() string

type ErrorNotFound

type ErrorNotFound struct {
}

func NewErrorNotFound

func NewErrorNotFound() ErrorNotFound

func (ErrorNotFound) Error

func (e ErrorNotFound) Error() string

type ErrorPermissionDenied

type ErrorPermissionDenied struct {
}

func NewErrorPermissionDenied

func NewErrorPermissionDenied() ErrorPermissionDenied

func (ErrorPermissionDenied) Error

func (e ErrorPermissionDenied) Error() string

type EvalResult

type EvalResult struct {
	Operator string       `json:"op"`
	Args     []EvalResult `json:"args"`
	Result   any          `json:"result"`
	Error    string       `json:"error"`
}

type Event

type Event struct {
	Timeline  string        `json:"timeline"` // stream full id (ex: <streamID>@<domain>)
	Item      *TimelineItem `json:"item,omitempty"`
	Resource  any           `json:"resource,omitempty"`
	Document  string        `json:"document"`
	Signature string        `json:"signature"`
}

Event is websocket root packet model

type EventDocument

type EventDocument struct {
	DocumentBase[any]
	Timeline  string       `json:"timeline"`
	Item      TimelineItem `json:"item"`
	Resource  any          `json:"resource"`
	Document  string       `json:"document"`
	Signature string       `json:"signature"`
}

type Expr

type Expr struct {
	Operator string `json:"op"`
	Args     []Expr `json:"args"`
	Constant any    `json:"const"`
}

type Job

type Job struct {
	ID          string    `json:"id" gorm:"primaryKey;type:uuid;default:gen_random_uuid()"`
	Author      string    `json:"author" gorm:"type:char(42)"`
	Type        string    `json:"type" gorm:"type:text"`
	Payload     string    `json:"payload" gorm:"type:json"`
	Scheduled   time.Time `json:"scheduled" gorm:"type:timestamp with time zone"`
	Status      string    `json:"status" gorm:"type:text"` // pending, running, completed, failed
	Result      string    `json:"result" gorm:"type:text"`
	CreatedAt   time.Time `json:"createdAt" gorm:"autoCreateTime"`
	CompletedAt time.Time `json:"completedAt" gorm:"autoUpdateTime"`
	TraceID     string    `json:"traceID" gorm:"type:text"`
}

type JobService

type JobService interface {
	List(ctx context.Context, requester string) ([]Job, error)
	Create(ctx context.Context, requester, typ, payload string, scheduled time.Time) (Job, error)
	Dequeue(ctx context.Context) (*Job, error)
	Complete(ctx context.Context, id, status, result string) (Job, error)
	Cancel(ctx context.Context, id string) (Job, error)
}

type Key

type Key struct {
	ID              string    `json:"id" gorm:"primaryKey;type:char(42)"` // e.g. CK...
	Root            string    `json:"root" gorm:"type:char(42)"`
	Parent          string    `json:"parent" gorm:"type:char(42)"`
	EnactDocument   string    `json:"enactDocument" gorm:"type:json"`
	EnactSignature  string    `json:"enactSignature" gorm:"type:char(130)"`
	RevokeDocument  *string   `json:"revokeDocument" gorm:"type:json;default:null"`
	RevokeSignature *string   `json:"revokeSignature" gorm:"type:char(130);default:null"`
	ValidSince      time.Time `json:"validSince" gorm:"type:timestamp with time zone"`
	ValidUntil      time.Time `json:"validUntil" gorm:"type:timestamp with time zone"`
}

type KeyService

type KeyService interface {
	Enact(ctx context.Context, mode CommitMode, payload, signature string) (Key, error)
	Revoke(ctx context.Context, mode CommitMode, payload, signature string) (Key, error)
	Clean(ctx context.Context, ccid string) error
	ResolveSubkey(ctx context.Context, keyID string) (string, error)
	GetKeyResolution(ctx context.Context, keyID string) ([]Key, error)
	GetRemoteKeyResolution(ctx context.Context, remote string, keyID string) ([]Key, error)
	GetAllKeys(ctx context.Context, owner string) ([]Key, error)
}

type Message

type Message struct {
	ID              string         `json:"id" gorm:"primaryKey;type:char(26)"`
	Author          string         `json:"author" gorm:"type:char(42)"`
	SchemaID        uint           `json:"-"`
	Schema          string         `json:"schema" gorm:"-"`
	PolicyID        uint           `json:"-"`
	Policy          string         `json:"policy,omitempty" gorm:"-"`
	PolicyParams    *string        `json:"policyParams,omitempty" gorm:"type:json"`
	PolicyDefaults  *string        `json:"policyDefaults,omitempty" gorm:"type:json"`
	Document        string         `json:"document" gorm:"type:json"`
	Signature       string         `json:"signature" gorm:"type:char(130)"`
	CDate           time.Time      `json:"cdate" gorm:"->;<-:create;type:timestamp with time zone;not null;default:clock_timestamp()"`
	Associations    []Association  `json:"associations,omitempty" gorm:"-"`
	OwnAssociations []Association  `json:"ownAssociations,omitempty" gorm:"-"`
	Timelines       pq.StringArray `json:"timelines" gorm:"type:text[]"`
}

Message is one of a concurrent base object immutable

type MessageDocument

type MessageDocument[T any] struct {
	DocumentBase[T]
	Timelines []string `json:"timelines"`
}

message

type MessageService

type MessageService interface {
	GetAsGuest(ctx context.Context, id string) (Message, error)
	GetAsUser(ctx context.Context, id string, requester Entity) (Message, error)
	GetWithOwnAssociations(ctx context.Context, id string, requester string) (Message, error)
	Clean(ctx context.Context, ccid string) error
	Create(ctx context.Context, mode CommitMode, document string, signature string) (Message, []string, error)
	Delete(ctx context.Context, mode CommitMode, document, signature string) (Message, []string, error)
	Count(ctx context.Context) (int64, error)
}

type NotificationService

type NotificationService interface {
	Subscribe(ctx context.Context, notification NotificationSubscription) (NotificationSubscription, error)
	GetAllSubscriptions(ctx context.Context) ([]NotificationSubscription, error)
	Delete(ctx context.Context, vendorID, owner string) error
	Get(ctx context.Context, vendorID, owner string) (NotificationSubscription, error)
}

type NotificationSubscription

type NotificationSubscription struct {
	VendorID     string         `json:"vendorID" gorm:"primaryKey;type:text"`
	Owner        string         `json:"owner" gorm:"primaryKey;type:text"`
	Schemas      pq.StringArray `json:"schemas" gorm:"type:text[]"`
	Timelines    pq.StringArray `json:"timelines" gorm:"type:text[]"`
	Subscription string         `json:"subscription" gorm:"type:text"`
	CDate        time.Time      `json:"cdate" gorm:"type:timestamp with time zone;not null;default:clock_timestamp()"`
	MDate        time.Time      `json:"mdate" gorm:"autoUpdateTime"`
}

type Passport

type Passport struct {
	Document  string `json:"document"`
	Signature string `json:"signature"`
}

type PassportDocument

type PassportDocument struct {
	DocumentBase[any]
	Domain string `json:"domain"`
	Entity Entity `json:"entity"`
	Keys   []Key  `json:"keys"`
}

type Policy

type Policy struct {
	Statements map[string]Statement `json:"statements"`
	Defaults   map[string]bool      `json:"defaults"`
}

type PolicyDocument

type PolicyDocument struct {
	Name        string            `json:"name"`
	Description string            `json:"description"`
	Versions    map[string]Policy `json:"versions"`
}

type PolicyEvalResult

type PolicyEvalResult int
const (
	PolicyEvalResultDefault PolicyEvalResult = iota
	PolicyEvalResultNever
	PolicyEvalResultDeny
	PolicyEvalResultAllow
	PolicyEvalResultAlways
	PolicyEvalResultError
)

type PolicyService

type PolicyService interface {
	Test(ctx context.Context, policy Policy, context RequestContext, action string) (PolicyEvalResult, error)
	TestWithPolicyURL(ctx context.Context, url string, context RequestContext, action string) (PolicyEvalResult, error)
	TestWithGlobalPolicy(ctx context.Context, context RequestContext, action string) (PolicyEvalResult, error)
	Summerize(results []PolicyEvalResult, action string, overrides *map[string]bool) bool
	AccumulateOr(results []PolicyEvalResult, action string, override *map[string]bool) PolicyEvalResult
}

type Profile

type Profile struct {
	ID           string        `json:"id" gorm:"primaryKey;type:char(26)"`
	Author       string        `json:"author" gorm:"type:char(42)"`
	SchemaID     uint          `json:"-"`
	Schema       string        `json:"schema" gorm:"-"`
	Document     string        `json:"document" gorm:"type:json"`
	Signature    string        `json:"signature" gorm:"type:char(130)"`
	Associations []Association `json:"associations,omitempty" gorm:"-"`
	PolicyID     uint          `json:"-"`
	Policy       string        `json:"policy,omitempty" gorm:"-"`
	PolicyParams *string       `json:"policyParams,omitempty" gorm:"type:json"`
	CDate        time.Time     `json:"cdate" gorm:"->;<-:create;autoCreateTime"`
	MDate        time.Time     `json:"mdate" gorm:"autoUpdateTime"`
}

Profile is one of a Concurrent base object mutable

type ProfileDocument

type ProfileDocument[T any] struct {
	DocumentBase[T]
}

profile

type ProfileService

type ProfileService interface {
	Upsert(ctx context.Context, mode CommitMode, document, signature string) (Profile, error)
	Delete(ctx context.Context, mode CommitMode, document string) (Profile, error)

	Clean(ctx context.Context, ccid string) error
	Count(ctx context.Context) (int64, error)
	Get(ctx context.Context, id string) (Profile, error)
	GetBySemanticID(ctx context.Context, semanticID, owner string) (Profile, error)
	GetByAuthorAndSchema(ctx context.Context, owner string, schema string) ([]Profile, error)
	GetByAuthor(ctx context.Context, owner string) ([]Profile, error)
	GetBySchema(ctx context.Context, schema string) ([]Profile, error)
	Query(ctx context.Context, author, schema string, limit int, since, until time.Time) ([]Profile, error)
}

type RateLimitConfig

type RateLimitConfig struct {
	BucketSize int     `yaml:"bucketSize"`
	RefillSpan float64 `yaml:"refillSpan"`
}

type RateLimitConfigMap

type RateLimitConfigMap map[string]RateLimitConfig

type RequestContext

type RequestContext struct {
	Requester       Entity
	RequesterDomain Domain
	Document        any
	Self            any
	Resource        any
	Params          map[string]any
}

type ResolverType

type ResolverType uint
const (
	ResolverTypeEntity ResolverType = iota
	ResolverTypeDomain
)

type ResponseBase

type ResponseBase[T any] struct {
	Status  string `json:"status"`
	Content T      `json:"content"`
	Error   string `json:"error,omitempty"`
}

type RetractDocument

type RetractDocument struct {
	DocumentBase[any]
	Timeline string `json:"timeline"`
	Target   string `json:"target"`
}

type RevokeDocument

type RevokeDocument struct {
	DocumentBase[any]
	Target string `json:"target"`
}

type Schema

type Schema struct {
	ID  uint   `json:"id" gorm:"primaryKey;auto_increment"`
	URL string `json:"url" gorm:"type:text"`
}

type SchemaService

type SchemaService interface {
	UrlToID(ctx context.Context, url string) (uint, error)
	IDToUrl(ctx context.Context, id uint) (string, error)
}

type SemanticID

type SemanticID struct {
	ID        string    `json:"id" gorm:"primaryKey;type:text"`
	Owner     string    `json:"owner" gorm:"primaryKey;type:char(42)"`
	Target    string    `json:"target" gorm:"type:char(27)"`
	Document  string    `json:"document" gorm:"type:json"`
	Signature string    `json:"signature" gorm:"type:char(130)"`
	CDate     time.Time `json:"cdate" gorm:"->;<-:create;autoCreateTime"`
	MDate     time.Time `json:"mdate" gorm:"autoUpdateTime"`
}

type SemanticIDService

type SemanticIDService interface {
	Name(ctx context.Context, id, owner, target, document, signature string) (SemanticID, error)
	Lookup(ctx context.Context, id, owner string) (string, error)
	Delete(ctx context.Context, id, owner string) error
	Clean(ctx context.Context, ccid string) error
}

type SocketManager

type SocketManager interface {
	Subscribe(conn *websocket.Conn, timelines []string)
	Unsubscribe(conn *websocket.Conn)
	GetAllRemoteSubs() []string
}

type Statement

type Statement struct {
	Dominant       bool `json:"dominant"`
	DefaultOnTrue  bool `json:"defaultOnTrue"`
	DefaultOnFalse bool `json:"defaultOnFalse"`
	Condition      Expr `json:"condition"`
}

type StoreService

type StoreService interface {
	Commit(ctx context.Context, mode CommitMode, document, signature, option string, keys []Key, IP string) (any, error)
	Restore(ctx context.Context, archive io.Reader, from, IP string) ([]BatchResult, error)
	ValidateDocument(ctx context.Context, document, signature string, keys []Key) error
	CleanUserAllData(ctx context.Context, target string) error
	SyncCommitFile(ctx context.Context, owner string) (SyncStatus, error)
	SyncStatus(ctx context.Context, owner string) (SyncStatus, error)
}

type SubscribeDocument

type SubscribeDocument[T any] struct {
	DocumentBase[T]
	Subscription string `json:"subscription"`
	Target       string `json:"target"`
}

type Subscription

type Subscription struct {
	ID           string             `json:"id" gorm:"primaryKey;type:char(26)"`
	Owner        string             `json:"owner" gorm:"type:char(42)"`
	Author       string             `json:"author" gorm:"type:char(42);"`
	Indexable    bool               `json:"indexable" gorm:"type:boolean;default:false"`
	SchemaID     uint               `json:"-"`
	Schema       string             `json:"schema" gorm:"-"`
	PolicyID     uint               `json:"-"`
	Policy       string             `json:"policy,omitempty" gorm:"-"`
	PolicyParams *string            `json:"policyParams,omitempty" gorm:"type:json"`
	Document     string             `json:"document" gorm:"type:json"`
	Signature    string             `json:"signature" gorm:"type:char(130)"`
	Items        []SubscriptionItem `json:"items" gorm:"foreignKey:Subscription"`
	CDate        time.Time          `json:"cdate" gorm:"->;<-:create;type:timestamp with time zone;not null;default:clock_timestamp()"`
	MDate        time.Time          `json:"mdate" gorm:"autoUpdateTime"`

	DomainOwned bool `json:"domainOwned" gorm:"type:boolean;default:false"`
}

Subscription

type SubscriptionDocument

type SubscriptionDocument[T any] struct {
	DocumentBase[T]
	Indexable   bool `json:"indexable"`
	DomainOwned bool `json:"domainOwned"`
}

subscription

type SubscriptionItem

type SubscriptionItem struct {
	ID           string       `json:"id" gorm:"primaryKey;type:text;"`
	Subscription string       `json:"subscription" gorm:"primaryKey;type:char(26)"`
	ResolverType ResolverType `json:"resolverType" gorm:"type:integer"`
	Entity       *string      `json:"entity" gorm:"type:char(42);"`
	Domain       *string      `json:"domain" gorm:"type:text;"`
}

type SubscriptionService

type SubscriptionService interface {
	UpsertSubscription(ctx context.Context, mode CommitMode, document, signature string) (Subscription, error)
	Subscribe(ctx context.Context, mode CommitMode, document string, signature string) (SubscriptionItem, error)
	Unsubscribe(ctx context.Context, mode CommitMode, document string) (SubscriptionItem, error)
	DeleteSubscription(ctx context.Context, mode CommitMode, document string) (Subscription, error)
	Clean(ctx context.Context, ccid string) error

	GetSubscription(ctx context.Context, id string) (Subscription, error)
	GetOwnSubscriptions(ctx context.Context, owner string) ([]Subscription, error)
}

type SyncStatus

type SyncStatus struct {
	Owner string `json:"owner"`
	// "insync", "outofsync", "syncing"
	Status       string    `json:"status"`
	LatestOnFile time.Time `json:"latestOnFile"`
	LatestOnDB   time.Time `json:"latestOnDB"`
	Progress     string    `json:"progress"`
}

type Tags

type Tags struct {
	Body map[string]string
}

func NewTags

func NewTags() Tags

func ParseTags

func ParseTags(input string) Tags

func (*Tags) Add

func (t *Tags) Add(key, value string)

func (*Tags) Get

func (t *Tags) Get(key string) string

func (*Tags) GetAsInt

func (t *Tags) GetAsInt(key string) (int, bool)

func (*Tags) Has

func (t *Tags) Has(key string) bool

func (*Tags) Remove

func (t *Tags) Remove(key string)

func (*Tags) ToString

func (t *Tags) ToString() string

type Timeline

type Timeline struct {
	ID           string    `json:"id" gorm:"primaryKey;type:char(26);"`
	Indexable    bool      `json:"indexable" gorm:"type:boolean;default:false"`
	Owner        string    `json:"owner" gorm:"type:char(42)"`
	Author       string    `json:"author" gorm:"type:char(42)"`
	SchemaID     uint      `json:"-"`
	Schema       string    `json:"schema" gorm:"-"`
	PolicyID     uint      `json:"-"`
	Policy       string    `json:"policy,omitempty" gorm:"-"`
	PolicyParams *string   `json:"policyParams,omitempty" gorm:"type:json"`
	Document     string    `json:"document" gorm:"type:json"`
	Signature    string    `json:"signature" gorm:"type:char(130)"`
	CDate        time.Time `json:"cdate" gorm:"->;<-:create;type:timestamp with time zone;not null;default:clock_timestamp()"`
	MDate        time.Time `json:"mdate" gorm:"autoUpdateTime"`
}

Timeline is one of a base object of concurrent mutable

type TimelineDocument

type TimelineDocument[T any] struct {
	DocumentBase[T]
	Indexable   bool `json:"indexable"`
	DomainOwned bool `json:"domainOwned"`
}

timeline

type TimelineItem

type TimelineItem struct {
	ResourceID string    `json:"resourceID" gorm:"primaryKey;type:char(27);"`
	TimelineID string    `json:"timelineID" gorm:"primaryKey;type:char(26);index:idx_timeline_id_c_date"`
	Owner      string    `json:"owner" gorm:"type:char(42);"`
	Author     *string   `json:"author,omitempty" gorm:"type:char(42);"`
	SchemaID   uint      `json:"-"`
	Schema     string    `json:"schema,omitempty" gorm:"-"`
	CDate      time.Time `` /* 136-byte string literal not displayed */
}

TimelineItem is one of a base object of concurrent immutable

type TimelineService

type TimelineService interface {
	UpsertTimeline(ctx context.Context, mode CommitMode, document, signature string) (Timeline, error)
	DeleteTimeline(ctx context.Context, mode CommitMode, document string) (Timeline, error)
	Event(ctx context.Context, mode CommitMode, document, signature string) (Event, error)

	Clean(ctx context.Context, ccid string) error

	LookupChunkItr(ctx context.Context, timeliens []string, epoch string) (map[string]string, error)
	LoadChunkBody(ctx context.Context, query map[string]string) (map[string]Chunk, error)

	GetRecentItems(ctx context.Context, timelines []string, until time.Time, limit int) ([]TimelineItem, error)
	GetRecentItemsFromSubscription(ctx context.Context, subscription string, until time.Time, limit int) ([]TimelineItem, error)
	GetImmediateItems(ctx context.Context, timelines []string, since time.Time, limit int) ([]TimelineItem, error)
	GetImmediateItemsFromSubscription(ctx context.Context, subscription string, since time.Time, limit int) ([]TimelineItem, error)
	GetItem(ctx context.Context, timeline string, id string) (TimelineItem, error)
	PostItem(ctx context.Context, timeline string, item TimelineItem, document, signature string) (TimelineItem, error)
	Retract(ctx context.Context, mode CommitMode, document, signature string) (TimelineItem, []string, error)
	RemoveItemsByResourceID(ctx context.Context, resourceID string) error

	PublishEvent(ctx context.Context, event Event) error

	GetTimeline(ctx context.Context, key string) (Timeline, error)
	GetTimelineAutoDomain(ctx context.Context, timelineID string) (Timeline, error)

	ListTimelineBySchema(ctx context.Context, schema string) ([]Timeline, error)
	ListTimelineByAuthor(ctx context.Context, author string) ([]Timeline, error)

	GetChunks(ctx context.Context, timelines []string, epoch string) (map[string]Chunk, error)

	ListTimelineSubscriptions(ctx context.Context) (map[string]int64, error)
	Count(ctx context.Context) (int64, error)
	NormalizeTimelineID(ctx context.Context, timeline string) (string, error)
	GetOwners(ctx context.Context, timelines []string) ([]string, error)

	Query(ctx context.Context, timelineID, schema, owner, author string, until time.Time, limit int) ([]TimelineItem, error)

	ListLocalRecentlyRemovedItems(ctx context.Context, timelines []string) (map[string][]string, error)

	Realtime(ctx context.Context, request <-chan []string, response chan<- Event)

	UpdateMetrics()
}

type TombstoneDocument

type TombstoneDocument struct {
	Reason string `json:"reason"`
	DocumentBase[any]
}

type UnackDocument

type UnackDocument struct {
	DocumentBase[any]
	From string `json:"from"`
	To   string `json:"to"`
}

type UnsubscribeDocument

type UnsubscribeDocument struct {
	DocumentBase[any]
	Subscription string `json:"subscription"`
	Target       string `json:"target"`
}

type UserKV

type UserKV struct {
	Owner string `json:"owner" gorm:"primaryKey;type:char(42)"`
	Key   string `json:"key" gorm:"primaryKey;type:text"`
	Value string `json:"value" gorm:"type:text"`
}

Directories

Path Synopsis
Package mock_core is a generated GoMock package.
Package mock_core is a generated GoMock package.

Jump to

Keyboard shortcuts

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