Documentation
¶
Index ¶
- Constants
- Variables
- func CloseCursor(cursor arango.Cursor)
- func DefaultListQuery(obj ArangoObject, params ArangoQueryParameters) string
- func DefaultListQueryForUser(obj ArangoObject, params ArangoQueryParameters) string
- func FindArgumentMovedNotifications(db *gorm.DB) *gorm.DB
- func FindContext(ctx *ServerContext, contextArangoId string) (Context, Error)
- func FindContextEdge(ctx *ServerContext, contextArangoKey, claimArangoKey string) (ContextEdge, Error)
- func FindParentArgumentMovedNotifications(db *gorm.DB) *gorm.DB
- func GetVersionedModel(item interface{}) (VersionedModel, Error)
- func InitTestDB() (arango.Client, arango.Database)
- func IsArangoObject(t reflect.Type) bool
- func IsEdge(t reflect.Type) bool
- func IsEmptyValue(v reflect.Value) bool
- func IsLoader(t reflect.Type) bool
- func IsRestrictor(t reflect.Type) bool
- func IsScorer(t reflect.Type) bool
- func IsValidator(t reflect.Type) bool
- func IsVersionedModel(t reflect.Type) bool
- func IsVersioner(t reflect.Type) bool
- func IssueJWTTokenForEmail(uid uint, email string, exp time.Time) (string, error)
- func IssueJWToken(uid string, roles []string, exp time.Time) (string, error)
- func JWTTokenExpirationDate() time.Time
- func JsonToMap(jsonStr string) map[string]interface{}
- func JsonToMapArray(jsonStr string) []map[string]interface{}
- func JsonToModel(jsonStr string, item interface{}) error
- func KeyField(t reflect.Type) (field *reflect.StructField, dbFieldName string)
- func ModelToJson(model interface{}) string
- func ModelToJsonMap(modl interface{}) map[string]interface{}
- func OpenArangoConnection() (arango.Client, error)
- func OpenArangoDatabase(client arango.Client) (arango.Database, error)
- func OpenTestConnection() (arango.Client, error)
- func OrderByBestArgument(db *gorm.DB) *gorm.DB
- func ParentCallerInfo() string
- func SearchContext(ctx *ServerContext, contextText string) ([]Context, Error)
- func SearchContexts(ctx *ServerContext, term string) ([]Context, Error)
- func SetUserID(item interface{}, id string) error
- func TypeHasUserField(t reflect.Type) bool
- func UserIDField(t reflect.Type) (field *reflect.StructField, dbFieldName string)
- func VerifyJWTToken(tokenString, secretKey string) (*jwt.Token, error)
- type ArangoContext
- type ArangoObject
- type ArangoQueryParameters
- type Argument
- func (a Argument) AddArgument(ctx *ServerContext, arg Argument) Error
- func (a Argument) ArangoID() string
- func (a Argument) ArangoKey() string
- func (a Argument) Arguments(ctx *ServerContext) ([]Argument, Error)
- func (a Argument) BaseClaimEdge(ctx *ServerContext) (BaseClaimEdge, Error)
- func (a Argument) CollectionName() string
- func (a *Argument) Create(ctx *ServerContext) Error
- func (a Argument) DefaultQueryParameters() ArangoQueryParameters
- func (a *Argument) Delete(ctx *ServerContext) Error
- func (a Argument) Inference(ctx *ServerContext) (Inference, Error)
- func (a Argument) Inferences(ctx *ServerContext) ([]Inference, Error)
- func (a *Argument) Load(ctx *ServerContext) Error
- func (a *Argument) LoadFull(ctx *ServerContext) Error
- func (a *Argument) LoadTarget(ctx *ServerContext) Error
- func (a *Argument) MoveTo(ctx *ServerContext, target ArangoObject, pro bool) Error
- func (a *Argument) Score(ctx *ServerContext) (float32, Error)
- func (a *Argument) Strength(ctx *ServerContext) (float32, Error)
- func (a *Argument) Update(ctx *ServerContext, updates Updates) Error
- func (a *Argument) UpdateScore(ctx *ServerContext) Error
- func (a Argument) UserCanCreate(ctx *ServerContext) (bool, Error)
- func (a Argument) UserCanDelete(ctx *ServerContext) (bool, Error)
- func (a Argument) UserCanUpdate(ctx *ServerContext, updates Updates) (bool, Error)
- func (a Argument) UserCanView(ctx *ServerContext) (bool, Error)
- func (a Argument) UserScores(ctx *ServerContext) ([]UserScore, Error)
- func (a Argument) ValidateField(f string) Error
- func (a Argument) ValidateForCreate() Error
- func (a Argument) ValidateForDelete() Error
- func (a Argument) ValidateForUpdate(updates Updates) Error
- func (a Argument) ValidateIDs() Error
- type ArgumentOpinion
- type BaseClaimEdge
- func (bc BaseClaimEdge) ArangoID() string
- func (bc BaseClaimEdge) ArangoKey() string
- func (bc BaseClaimEdge) CollectionName() string
- func (bc *BaseClaimEdge) Create(ctx *ServerContext) Error
- func (bc BaseClaimEdge) DefaultQueryParameters() ArangoQueryParameters
- func (bc *BaseClaimEdge) Delete(ctx *ServerContext) Error
- func (bc *BaseClaimEdge) Update(ctx *ServerContext, updates Updates) Error
- type BindVars
- type ChangeLog
- type Claim
- func (c *Claim) AddContext(ctx *ServerContext, context Context) Error
- func (c *Claim) AddPremise(ctx *ServerContext, premise *Claim) Error
- func (c Claim) ArangoID() string
- func (c Claim) ArangoKey() string
- func (c Claim) Arguments(ctx *ServerContext) ([]Argument, Error)
- func (c Claim) ArgumentsBasedOnThisClaim(ctx *ServerContext) ([]Argument, Error)
- func (c Claim) BaseClaimEdges(ctx *ServerContext) ([]BaseClaimEdge, Error)
- func (c Claim) CollectionName() string
- func (c Claim) ContextEdges(ctx *ServerContext) ([]ContextEdge, Error)
- func (c Claim) Contexts(ctx *ServerContext) ([]Context, Error)
- func (c *Claim) ConvertToMultiPremise(ctx *ServerContext) Error
- func (c *Claim) Create(ctx *ServerContext) Error
- func (c Claim) DefaultQueryParameters() ArangoQueryParameters
- func (c *Claim) Delete(ctx *ServerContext) Error
- func (c Claim) EdgesToThisPremise(ctx *ServerContext) ([]PremiseEdge, Error)
- func (c Claim) HasCycle(ctx *ServerContext) (bool, Error)
- func (c Claim) HasPremise(ctx *ServerContext, premiseArangoKey string) (bool, Error)
- func (c Claim) Inferences(ctx *ServerContext) ([]Inference, Error)
- func (c *Claim) Load(ctx *ServerContext) Error
- func (c *Claim) LoadFull(ctx *ServerContext) Error
- func (c Claim) NumberOfPremises(ctx *ServerContext) (int64, Error)
- func (c Claim) ParentArguments(ctx *ServerContext) ([]Argument, Error)
- func (c Claim) PremiseEdges(ctx *ServerContext) ([]PremiseEdge, Error)
- func (c Claim) Premises(ctx *ServerContext) ([]Claim, Error)
- func (c Claim) QueryForTopLevelClaims(params ArangoQueryParameters) string
- func (c *Claim) RemoveContext(ctx *ServerContext, contextArangoKey string) Error
- func (c *Claim) RemovePremise(ctx *ServerContext, premiseId string) Error
- func (c Claim) ReorderPremise(ctx *ServerContext, premise Claim, new int) ([]Claim, Error)
- func (c *Claim) Score(ctx *ServerContext) (float32, Error)
- func (c *Claim) Update(ctx *ServerContext, updates Updates) Error
- func (c *Claim) UpdateScore(ctx *ServerContext) Error
- func (c Claim) UserCanCreate(ctx *ServerContext) (bool, Error)
- func (c Claim) UserCanDelete(ctx *ServerContext) (bool, Error)
- func (c Claim) UserCanUpdate(ctx *ServerContext, updates Updates) (bool, Error)
- func (c Claim) UserCanView(ctx *ServerContext) (bool, Error)
- func (c Claim) UserScores(ctx *ServerContext) ([]UserScore, Error)
- func (c Claim) ValidateField(f string) Error
- func (c Claim) ValidateForCreate() Error
- func (c Claim) ValidateForDelete() Error
- func (c Claim) ValidateForUpdate(updates Updates) Error
- type ClaimOpinion
- type Context
- func (c Context) ArangoID() string
- func (c Context) ArangoKey() string
- func (c Context) CollectionName() string
- func (c *Context) Create(ctx *ServerContext) Error
- func (c Context) DefaultQueryParameters() ArangoQueryParameters
- func (c *Context) Delete(ctx *ServerContext) Error
- func (c *Context) Load(ctx *ServerContext) Error
- func (c *Context) LoadFull(ctx *ServerContext) Error
- func (c Context) NumberOfClaims(ctx *ServerContext) (int64, Error)
- func (c *Context) Update(ctx *ServerContext, updates Updates) Error
- func (c Context) UserCanCreate(ctx *ServerContext) (bool, Error)
- func (c Context) UserCanDelete(ctx *ServerContext) (bool, Error)
- func (c Context) UserCanUpdate(ctx *ServerContext, updates Updates) (bool, Error)
- func (c Context) UserCanView(ctx *ServerContext) (bool, Error)
- func (c Context) ValidateField(f string) Error
- func (c Context) ValidateForCreate() Error
- func (c Context) ValidateForDelete() Error
- func (c Context) ValidateForUpdate(updates Updates) Error
- type ContextEdge
- func (c ContextEdge) ArangoID() string
- func (c ContextEdge) ArangoKey() string
- func (c ContextEdge) CollectionName() string
- func (c *ContextEdge) Create(ctx *ServerContext) Error
- func (c ContextEdge) DefaultQueryParameters() ArangoQueryParameters
- func (c *ContextEdge) Delete(ctx *ServerContext) Error
- func (c *ContextEdge) Update(ctx *ServerContext, updates Updates) Error
- type CoreError
- type Edge
- type Error
- func ClearTransientData(item interface{}, m map[string]interface{}) (map[string]interface{}, Error)
- func ClearTransientFields(item interface{}) Error
- func CreateArangoObject(ctx *ServerContext, obj ArangoObject) Error
- func DeleteArangoObject(ctx *ServerContext, obj ArangoObject) Error
- func DeleteArangoObjects(ctx *ServerContext, collectionName, filter string, bindVars BindVars) Error
- func FindArangoObject(ctx *ServerContext, query string, bindVars BindVars, result interface{}) Error
- func FindArangoObjects(ctx *ServerContext, query string, bindVars BindVars, results interface{}) Error
- func GetFieldByJsonTag(item interface{}, jsonKey string) (field *reflect.StructField, gerr Error)
- func LoadArangoObject(ctx *ServerContext, result interface{}, arangoKey string) Error
- func NewBusinessError(msg string, opts ...interface{}) Error
- func NewError(code, subcode int, location, msg string, data map[string]interface{}) Error
- func NewNotFoundError(msg string, opts ...interface{}) Error
- func NewPermissionError(msg string, opts ...interface{}) Error
- func NewServerError(msg string, opts ...interface{}) Error
- func NewUnauthorizedError(msg string, opts ...interface{}) Error
- func NewWarning(msg string, opts ...interface{}) Error
- func NotifyArgumentMoved(ctx *ServerContext, userId uint64, argId string, oldTargetId string, ...) Error
- func NotifyNewArgument(ctx ServerContext, userId uint64, item interface{}, newArg Argument) Error
- func NotifyParentArgumentMoved(ctx *ServerContext, userId uint64, parentArgId string, oldTargetId string, ...) Error
- func SetByJsonTag(item interface{}, jsonKey string, newVal interface{}) Error
- func SetID(item interface{}, id string) Error
- func SetJsonValuesOnStruct(item interface{}, values map[string]interface{}, abortOnError bool) Error
- func SetKey(item interface{}, key string) Error
- func UpdateArangoObject(ctx *ServerContext, obj ArangoObject, updates Updates) Error
- func ValidateRequiredFields(item interface{}, fields []string) Error
- func ValidateStruct(item interface{}) Error
- func ValidateStructField(item interface{}, f string) Error
- func ValidateStructFields(item interface{}, fs []string) Error
- type Inference
- func (i Inference) ArangoID() string
- func (i Inference) ArangoKey() string
- func (i Inference) CollectionName() string
- func (i *Inference) Create(ctx *ServerContext) Error
- func (i Inference) DefaultQueryParameters() ArangoQueryParameters
- func (i *Inference) Delete(ctx *ServerContext) Error
- func (i *Inference) Update(ctx *ServerContext, updates Updates) Error
- type Link
- type Loader
- type MetaData
- type Model
- type Notification
- type PremiseEdge
- func (p PremiseEdge) ArangoID() string
- func (p PremiseEdge) ArangoKey() string
- func (p PremiseEdge) CollectionName() string
- func (p *PremiseEdge) Create(ctx *ServerContext) Error
- func (p PremiseEdge) DefaultQueryParameters() ArangoQueryParameters
- func (p *PremiseEdge) Delete(ctx *ServerContext) Error
- func (p *PremiseEdge) Update(ctx *ServerContext, updates Updates) Error
- func (p *PremiseEdge) UpdateOrder(ctx *ServerContext, order int) Error
- type ReplaceMany
- type Restrictor
- type Scorer
- type ServerContext
- type Updates
- type User
- func (u User) ArangoID() string
- func (u User) ArangoKey() string
- func (u *User) ChangePassword(ctx *ServerContext, oldPassword string) Error
- func (u User) CollectionName() string
- func (u *User) Create(ctx *ServerContext) Error
- func (u User) DefaultQueryParameters() ArangoQueryParameters
- func (u *User) Delete(ctx *ServerContext) Error
- func (u *User) Load(ctx *ServerContext) Error
- func (u *User) LoadFull(ctx *ServerContext) Error
- func (u User) Score(ctx *ServerContext, target ArangoObject, score float32) Error
- func (u *User) ScoreFor(ctx *ServerContext, target ArangoObject) (*UserScore, Error)
- func (u *User) Update(ctx *ServerContext, updates Updates) Error
- func (u User) UserCanCreate(ctx *ServerContext) (bool, Error)
- func (u User) UserCanDelete(ctx *ServerContext) (bool, Error)
- func (u User) UserCanUpdate(ctx *ServerContext, updates Updates) (bool, Error)
- func (u User) UserCanView(ctx *ServerContext) (bool, Error)
- func (u User) ValidateField(f string) Error
- func (u User) ValidateForCreate() Error
- func (u User) ValidateForDelete() Error
- func (u User) ValidateForUpdate(updates Updates) Error
- func (u *User) VerifyPassword(ctx *ServerContext, password string) (bool, Error)
- type UserScore
- func (u UserScore) ArangoID() string
- func (u UserScore) ArangoKey() string
- func (u UserScore) CollectionName() string
- func (u *UserScore) Create(ctx *ServerContext) Error
- func (u UserScore) DefaultQueryParameters() ArangoQueryParameters
- func (u *UserScore) Delete(ctx *ServerContext) Error
- func (u *UserScore) Update(ctx *ServerContext, updates Updates) Error
- type Validator
- type VersionedModel
- type Versioner
Constants ¶
const CHANGE_TYPE_CLONE_CLAIM int = 21
const CHANGE_TYPE_CREATED_ARGUMENT int = 2
const CHANGE_TYPE_CREATED_CLAIM int = 1
const CHANGE_TYPE_CREATED_CLAIM_AND_ARGUMENT int = 3
const CHANGE_TYPE_MERGE_ARGUMENTS int = 32
const CHANGE_TYPE_MERGE_CLAIMS int = 31
const CHANGE_TYPE_MOVED_ARGUMENT int = 11
const DEFAULT_ARGUMENT_SCORE float32 = 1.00
const DEFAULT_CLAIM_SCORE float32 = 0.50
const ERROR_CODE_BUSINESS_ERROR int = 400
const ERROR_CODE_NOT_FOUND int = 404
const ERROR_CODE_PERMISSION_ERROR int = 403
const ERROR_CODE_SERVER_ERROR int = 500
const ERROR_CODE_UNAUTHORIZED_ERROR int = 401
const ERROR_CODE_WARNING int = 300
const ERROR_SUBCODE_CREDENTIALS_INVALID int = -2009
const ERROR_SUBCODE_EMAIL_FORMAT int = -2006
const ERROR_SUBCODE_EMAIL_TAKEN int = -2005
const ERROR_SUBCODE_PASSWORD_FORMAT int = -2008
const ERROR_SUBCODE_PASSWORD_LENGTH int = -2007
const ERROR_SUBCODE_UNDEFINED int = -1999
const ERROR_SUBCODE_UNDEFINED_IGNORE int = -1000
const ERROR_SUBCODE_USERNAME_FORMAT int = -2004
const ERROR_SUBCODE_USERNAME_LENGTH int = -2003
const ERROR_SUBCODE_USERNAME_TAKEN int = -2002
const JWT_ISS = "gruff"
const NOTIFICATION_TYPE_MOVED int = 1
const NOTIFICATION_TYPE_NEW_ARGUMENT int = 3
const NOTIFICATION_TYPE_PARENT_MOVED int = 2
const OBJECT_TYPE_ARGUMENT int = 2
const OBJECT_TYPE_CLAIM int = 1
const PREMISE_RULE_ALL int = 1
const PREMISE_RULE_ANY int = 2
const PREMISE_RULE_ANY_TWO int = 3
const PREMISE_RULE_NONE int = 0
* A Claim is a proposed statement of fact * * Claims are described in detail in the Canonical Debate White Paper: https://github.com/canonical-debate-lab/paper#311_Claim * * According to David Zarefsky (https://www.thegreatcoursesplus.com/argumentation/argument-analysis-and-diagramming) there are 4 types: * - Fact: Al Gore received more popular votes than George Bush in the 2000 election * - Definition: Capital execution is murder * - Value: Environmental protection is more important than economic growth * - Policy: Congress should pass the president's budget * * Complex Claims: * - Series: Because of X, Y happened, which caused Z --> Not modeled in Gruff * - Convergent: Airline travel is becoming more unpleasant because of X, Y, Z, P, D, and Q --> Supported by standard Gruff structure * - Parallel: Same as convergent, except that any one argument is enough --> Supported by standard Gruff structure * * Complex Claims in the Canonical Debate are known as Multi-Premise Claims: https://github.com/canonical-debate-lab/paper#3115_Multipremise_Claims * They are currently unsupported, but soon will be. *
Variables ¶
var DEFAULT_QUERY_PARAMETERS = ArangoQueryParameters{ Sort: support.StringPtr("obj.start DESC"), Offset: support.IntPtr(0), Limit: support.IntPtr(20), Return: support.StringPtr("obj"), }
QUERY PARAMETERS By convention, simple queries will use "obj" as the collection item reference in order to simplify the basic use cases
Functions ¶
func CloseCursor ¶
func DefaultListQuery ¶
func DefaultListQuery(obj ArangoObject, params ArangoQueryParameters) string
func DefaultListQueryForUser ¶
func DefaultListQueryForUser(obj ArangoObject, params ArangoQueryParameters) string
func FindContext ¶
func FindContext(ctx *ServerContext, contextArangoId string) (Context, Error)
func FindContextEdge ¶
func FindContextEdge(ctx *ServerContext, contextArangoKey, claimArangoKey string) (ContextEdge, Error)
func GetVersionedModel ¶
func GetVersionedModel(item interface{}) (VersionedModel, Error)
func IsEmptyValue ¶
TODO: I think there's a reflect.Zero(Type) method that should simplify this. First, make sure tests are in place.
func IsRestrictor ¶
func IsValidator ¶
func IsVersionedModel ¶
func IsVersioner ¶
func IssueJWTTokenForEmail ¶
func JWTTokenExpirationDate ¶
func JsonToMapArray ¶
func JsonToModel ¶
func ModelToJson ¶
func ModelToJson(model interface{}) string
func ModelToJsonMap ¶
func ModelToJsonMap(modl interface{}) map[string]interface{}
func OpenArangoConnection ¶
func OpenTestConnection ¶
func ParentCallerInfo ¶
func ParentCallerInfo() string
func SearchContext ¶
func SearchContext(ctx *ServerContext, contextText string) ([]Context, Error)
func SearchContexts ¶
func SearchContexts(ctx *ServerContext, term string) ([]Context, Error)
func TypeHasUserField ¶
func UserIDField ¶
func UserIDField(t reflect.Type) (field *reflect.StructField, dbFieldName string)
Types ¶
type ArangoContext ¶
type ArangoContext struct { Context context.Context DB arango.Database Collections map[string]arango.Collection }
func (ArangoContext) Collection ¶
func (ctx ArangoContext) Collection(name string) (arango.Collection, Error)
func (ArangoContext) CollectionFor ¶
func (ctx ArangoContext) CollectionFor(item ArangoObject) (arango.Collection, Error)
func (ArangoContext) Rollback ¶
func (ctx ArangoContext) Rollback() Error
type ArangoObject ¶
type ArangoObject interface { CollectionName() string ArangoKey() string ArangoID() string DefaultQueryParameters() ArangoQueryParameters Create(*ServerContext) Error Update(*ServerContext, Updates) Error Delete(*ServerContext) Error PrepareForCreate(*ServerContext) PrepareForDelete(*ServerContext) }
type ArangoQueryParameters ¶
func (ArangoQueryParameters) Apply ¶
func (aqp ArangoQueryParameters) Apply(query string) string
func (ArangoQueryParameters) Merge ¶
func (aqp ArangoQueryParameters) Merge(params ArangoQueryParameters) ArangoQueryParameters
type Argument ¶
type Argument struct { VersionedModel TargetClaimID *string `json:"targetClaimId,omitempty"` TargetClaim *Claim `json:"targetClaim,omitempty" transient:"true"` TargetArgumentID *string `json:"targetArgId,omitempty"` TargetArgument *Argument `json:"targetArg,omitempty" transient:"true"` ClaimID string `json:"claimId"` Claim *Claim `json:"claim,omitempty" transient:"true"` Title string `json:"title" valid:"length(3|1000)"` Negation string `json:"negation"` Question string `json:"question"` Description string `json:"desc" valid:"length(3|4000)"` Note string `json:"note"` Pro bool `json:"pro"` Relevance float32 `json:"relevance"` Str float32 `json:"strength"` ProArgs []Argument `json:"proargs" transient:"true"` ConArgs []Argument `json:"conargs" transient:"true"` }
func (Argument) AddArgument ¶
func (a Argument) AddArgument(ctx *ServerContext, arg Argument) Error
func (Argument) BaseClaimEdge ¶
func (a Argument) BaseClaimEdge(ctx *ServerContext) (BaseClaimEdge, Error)
func (Argument) CollectionName ¶
func (*Argument) Create ¶
func (a *Argument) Create(ctx *ServerContext) Error
func (Argument) DefaultQueryParameters ¶
func (a Argument) DefaultQueryParameters() ArangoQueryParameters
func (*Argument) Delete ¶
func (a *Argument) Delete(ctx *ServerContext) Error
func (Argument) Inferences ¶
func (a Argument) Inferences(ctx *ServerContext) ([]Inference, Error)
func (*Argument) Load ¶
func (a *Argument) Load(ctx *ServerContext) Error
func (*Argument) LoadFull ¶
func (a *Argument) LoadFull(ctx *ServerContext) Error
func (*Argument) LoadTarget ¶
func (a *Argument) LoadTarget(ctx *ServerContext) Error
func (*Argument) MoveTo ¶
func (a *Argument) MoveTo(ctx *ServerContext, target ArangoObject, pro bool) Error
TODO: Test
func (*Argument) UpdateScore ¶
func (a *Argument) UpdateScore(ctx *ServerContext) Error
func (Argument) UserCanCreate ¶
func (a Argument) UserCanCreate(ctx *ServerContext) (bool, Error)
func (Argument) UserCanDelete ¶
func (a Argument) UserCanDelete(ctx *ServerContext) (bool, Error)
func (Argument) UserCanUpdate ¶
func (a Argument) UserCanUpdate(ctx *ServerContext, updates Updates) (bool, Error)
func (Argument) UserCanView ¶
func (a Argument) UserCanView(ctx *ServerContext) (bool, Error)
Restrictor TODO: Test TODO: Call in CRUD and other methods
func (Argument) UserScores ¶
func (a Argument) UserScores(ctx *ServerContext) ([]UserScore, Error)
func (Argument) ValidateField ¶
func (Argument) ValidateForCreate ¶
func (Argument) ValidateForDelete ¶
func (Argument) ValidateForUpdate ¶
func (Argument) ValidateIDs ¶
type ArgumentOpinion ¶
type ArgumentOpinion struct { Model UserID uint64 `json:"userId"` User *User `json:"user,omitempty"` ArgumentID uuid.UUID `json:"argumentId" sql:"type:uuid"` Argument *Argument `json:"argument,omitempty"` Strength float64 `json:"strength"` }
func (ArgumentOpinion) ValidateField ¶
func (ao ArgumentOpinion) ValidateField(f string) Error
func (ArgumentOpinion) ValidateForCreate ¶
func (ao ArgumentOpinion) ValidateForCreate() Error
func (ArgumentOpinion) ValidateForUpdate ¶
func (ao ArgumentOpinion) ValidateForUpdate() Error
type BaseClaimEdge ¶
type BaseClaimEdge struct {
Edge
}
BaseClaim is an edge pointing from an Argument to the Claim on which it is based (the true/false part of the Argument)
func (BaseClaimEdge) ArangoID ¶
func (bc BaseClaimEdge) ArangoID() string
func (BaseClaimEdge) ArangoKey ¶
func (bc BaseClaimEdge) ArangoKey() string
func (BaseClaimEdge) CollectionName ¶
func (bc BaseClaimEdge) CollectionName() string
func (*BaseClaimEdge) Create ¶
func (bc *BaseClaimEdge) Create(ctx *ServerContext) Error
func (BaseClaimEdge) DefaultQueryParameters ¶
func (bc BaseClaimEdge) DefaultQueryParameters() ArangoQueryParameters
func (*BaseClaimEdge) Delete ¶
func (bc *BaseClaimEdge) Delete(ctx *ServerContext) Error
func (*BaseClaimEdge) Update ¶
func (bc *BaseClaimEdge) Update(ctx *ServerContext, updates Updates) Error
type ChangeLog ¶
type ChangeLog struct { Model UserID uint64 `json:"userId" sql:"not null"` User *User `json:"user,omitempty"` Type int `json:"type" sql:"not null"` ArgumentID *string `json:"argumentId,omitempty" sql:"type:uuid"` Argument *Argument `json:"argument,omitempty"` ClaimID *string `json:"claimId,omitempty" sql:"type:uuid"` Claim Claim `json:"claim"` OldClaimID *string `json:"oldClaimId,omitempty" sql:"type:uuid"` OldClaim *Claim `json:"oldClaim,omitempty"` OldArgID *string `json:"oldArgId,omitempty" sql:"type:uuid"` OldArg *Argument `json:"oldArg,omitempty"` NewClaimID *string `json:"newClaimId,omitempty" sql:"type:uuid"` NewClaim *Claim `json:"newClaim,omitempty"` NewArgID *string `json:"newArgId,omitempty" sql:"type:uuid"` NewArg *Argument `json:"newArg,omitempty"` OldArgType *int `json:"oldArgType,omitempty"` NewArgType *int `json:"newArgType,omitempty"` }
Types of Changes, and fields used: - Created Claim: ClaimID - Created Argument: ArgumentID, NewArgType, NewClaimID or NewArgID (parent) - Created Claim and Argument: ArgumentID, NewArgType, NewClaimID or NewArgID (parent) - Moved Argument: ArgumentID, OldClaimID or OldArgID, NewClaimID or NewArgID (parent), OldArgType, NewArgType - Clone Claim:
- One claim stays
- New claim created, with same values, context, title and description (must be changed before saving)
- Arguments stay with main claim --> Need Change Type add/remove values and contexts --> ClaimID, NewClaimID --> What about opinions?? I guess it would make a copy --> Would there be arguments between old and new claim(s)? ------- E.g. Fidel Castro is nice, and ended Apartheid --> Fidel Castro is nice, Fidel Castro ended Apartheid
- Merge Claims:
- One claim becomes defunct
- Must have "compatible" values/context (TBD)
- All arguments attach to "winning" claim
- Title, description stick with "winning" claim
- All arguments with "losing" claim as base reattach to "winning" claim
- Do we need a change log for each of these? Probably...
- What about opinions? Should also merge...
func (ChangeLog) ValidateField ¶
func (ChangeLog) ValidateForCreate ¶
func (ChangeLog) ValidateForUpdate ¶
type Claim ¶
type Claim struct { VersionedModel Title string `json:"title" valid:"length(3|1000)"` Negation string `json:"negation"` Question string `json:"question"` Description string `json:"desc" valid:"length(3|4000)"` Note string `json:"note"` Image string `json:"img,omitempty"` MultiPremise bool `json:"mp"` PremiseRule int `json:"mprule"` Truth float32 `json:"truth"` // Average score from direct opinions PremiseClaims []Claim `json:"premises,omitempty" transient:"true"` ProArgs []Argument `json:"proargs" transient:"true"` ConArgs []Argument `json:"conargs" transient:"true"` Links []Link `json:"links,omitempty" transient:"true"` ContextElems []Context `json:"contexts" transient:"true"` }
func (*Claim) AddContext ¶
func (c *Claim) AddContext(ctx *ServerContext, context Context) Error
Contexts
func (*Claim) AddPremise ¶
func (c *Claim) AddPremise(ctx *ServerContext, premise *Claim) Error
func (Claim) ArgumentsBasedOnThisClaim ¶
func (c Claim) ArgumentsBasedOnThisClaim(ctx *ServerContext) ([]Argument, Error)
func (Claim) BaseClaimEdges ¶
func (c Claim) BaseClaimEdges(ctx *ServerContext) ([]BaseClaimEdge, Error)
func (Claim) CollectionName ¶
func (Claim) ContextEdges ¶
func (c Claim) ContextEdges(ctx *ServerContext) ([]ContextEdge, Error)
func (*Claim) ConvertToMultiPremise ¶
func (c *Claim) ConvertToMultiPremise(ctx *ServerContext) Error
TODO: Test
func (*Claim) Create ¶
func (c *Claim) Create(ctx *ServerContext) Error
func (Claim) DefaultQueryParameters ¶
func (c Claim) DefaultQueryParameters() ArangoQueryParameters
func (*Claim) Delete ¶
func (c *Claim) Delete(ctx *ServerContext) Error
func (Claim) EdgesToThisPremise ¶
func (c Claim) EdgesToThisPremise(ctx *ServerContext) ([]PremiseEdge, Error)
func (Claim) HasCycle ¶
func (c Claim) HasCycle(ctx *ServerContext) (bool, Error)
TODO: THis could use the named graph debate_map
func (Claim) HasPremise ¶
func (c Claim) HasPremise(ctx *ServerContext, premiseArangoKey string) (bool, Error)
func (Claim) Inferences ¶
func (c Claim) Inferences(ctx *ServerContext) ([]Inference, Error)
func (*Claim) Load ¶
func (c *Claim) Load(ctx *ServerContext) Error
If the Claim object has a key, that exact Claim will be loaded Otherwise, Load will look for Claims matching the ID If QueryAt is a non-nil value, it will load the Claim active at that time (if any) Otherwise, it will return the current active (undeleted) version.
func (*Claim) LoadFull ¶
func (c *Claim) LoadFull(ctx *ServerContext) Error
func (Claim) NumberOfPremises ¶
func (c Claim) NumberOfPremises(ctx *ServerContext) (int64, Error)
func (Claim) ParentArguments ¶
func (c Claim) ParentArguments(ctx *ServerContext) ([]Argument, Error)
func (Claim) PremiseEdges ¶
func (c Claim) PremiseEdges(ctx *ServerContext) ([]PremiseEdge, Error)
func (Claim) QueryForTopLevelClaims ¶
func (c Claim) QueryForTopLevelClaims(params ArangoQueryParameters) string
TODO: Obviously, this is going to have to be denormalized at some point
func (*Claim) RemoveContext ¶
func (c *Claim) RemoveContext(ctx *ServerContext, contextArangoKey string) Error
func (*Claim) RemovePremise ¶
func (c *Claim) RemovePremise(ctx *ServerContext, premiseId string) Error
TODO: Test
func (Claim) ReorderPremise ¶
func (*Claim) UpdateScore ¶
func (c *Claim) UpdateScore(ctx *ServerContext) Error
func (Claim) UserCanCreate ¶
func (c Claim) UserCanCreate(ctx *ServerContext) (bool, Error)
func (Claim) UserCanDelete ¶
func (c Claim) UserCanDelete(ctx *ServerContext) (bool, Error)
func (Claim) UserCanUpdate ¶
func (c Claim) UserCanUpdate(ctx *ServerContext, updates Updates) (bool, Error)
func (Claim) UserCanView ¶
func (c Claim) UserCanView(ctx *ServerContext) (bool, Error)
func (Claim) UserScores ¶
func (c Claim) UserScores(ctx *ServerContext) ([]UserScore, Error)
func (Claim) ValidateField ¶
func (Claim) ValidateForCreate ¶
func (Claim) ValidateForDelete ¶
func (Claim) ValidateForUpdate ¶
type ClaimOpinion ¶
type ClaimOpinion struct { Model UserID uint64 `json:"userId"` User *User `json:"user,omitempty"` ClaimID uuid.UUID `json:"claimId" sql:"type:uuid"` Claim *Claim `json:"claim,omitempty"` Truth float64 `json:"truth"` }
func (ClaimOpinion) ValidateField ¶
func (co ClaimOpinion) ValidateField(f string) Error
func (ClaimOpinion) ValidateForCreate ¶
func (co ClaimOpinion) ValidateForCreate() Error
func (ClaimOpinion) ValidateForUpdate ¶
func (co ClaimOpinion) ValidateForUpdate() Error
type Context ¶
type Context struct { Model ShortName string `json:"name" valid:"length(1|60),required"` Title string `json:"title" sql:"not null" valid:"length(3|1000),required"` Description string `json:"desc" valid:"length(3|4000)"` URL string `json:"url" valid:"url,required"` MID string `json:"mid,omitempty"` // Google KG ID QID string `json:"qid,omitempty"` // Wikidata ID MetaDataURL *MetaData `json:"meta_url,omitempty"` MetaDataGoogle *MetaData `json:"meta_google,omitempty"` MetaDataWikidata *MetaData `json:"meta_wikidata,omitempty"` }
func (Context) CollectionName ¶
func (*Context) Create ¶
func (c *Context) Create(ctx *ServerContext) Error
func (Context) DefaultQueryParameters ¶
func (c Context) DefaultQueryParameters() ArangoQueryParameters
func (*Context) Load ¶
func (c *Context) Load(ctx *ServerContext) Error
func (*Context) LoadFull ¶
func (c *Context) LoadFull(ctx *ServerContext) Error
func (Context) NumberOfClaims ¶
func (c Context) NumberOfClaims(ctx *ServerContext) (int64, Error)
TODO: TEst
func (*Context) Update ¶
func (c *Context) Update(ctx *ServerContext, updates Updates) Error
TODO: Test TODO: generic...
func (Context) UserCanCreate ¶
func (c Context) UserCanCreate(ctx *ServerContext) (bool, Error)
func (Context) UserCanDelete ¶
func (c Context) UserCanDelete(ctx *ServerContext) (bool, Error)
func (Context) UserCanUpdate ¶
func (c Context) UserCanUpdate(ctx *ServerContext, updates Updates) (bool, Error)
func (Context) UserCanView ¶
func (c Context) UserCanView(ctx *ServerContext) (bool, Error)
Restrictor TODO: Test TODO: Call in CRUD and other methods
func (Context) ValidateField ¶
func (Context) ValidateForCreate ¶
func (Context) ValidateForDelete ¶
func (Context) ValidateForUpdate ¶
type ContextEdge ¶
type ContextEdge struct {
Edge
}
A ContextEdge is an edge that goes from a Context to one or more Claims that are made in that Context
func (ContextEdge) ArangoID ¶
func (c ContextEdge) ArangoID() string
func (ContextEdge) ArangoKey ¶
func (c ContextEdge) ArangoKey() string
func (ContextEdge) CollectionName ¶
func (c ContextEdge) CollectionName() string
func (*ContextEdge) Create ¶
func (c *ContextEdge) Create(ctx *ServerContext) Error
func (ContextEdge) DefaultQueryParameters ¶
func (c ContextEdge) DefaultQueryParameters() ArangoQueryParameters
func (*ContextEdge) Delete ¶
func (c *ContextEdge) Delete(ctx *ServerContext) Error
func (*ContextEdge) Update ¶
func (c *ContextEdge) Update(ctx *ServerContext, updates Updates) Error
type CoreError ¶
type Edge ¶
type Edge struct { Key string `json:"_key"` CreatedAt time.Time `json:"start"` DeletedAt *time.Time `json:"end"` CreatedByID string `json:"creator"` From string `json:"_from,omitempty"` To string `json:"_to,omitempty"` }
func (*Edge) PrepareForCreate ¶
func (e *Edge) PrepareForCreate(ctx *ServerContext)
func (*Edge) PrepareForDelete ¶
func (e *Edge) PrepareForDelete(ctx *ServerContext)
func (Edge) ValidateField ¶
func (Edge) ValidateForCreate ¶
type Error ¶
type Error interface { Code() int Subcode() int Error() string Location() string Data() map[string]interface{} IsWarning() bool }
func ClearTransientData ¶
func ClearTransientFields ¶
func ClearTransientFields(item interface{}) Error
func CreateArangoObject ¶
func CreateArangoObject(ctx *ServerContext, obj ArangoObject) Error
func DeleteArangoObject ¶
func DeleteArangoObject(ctx *ServerContext, obj ArangoObject) Error
func DeleteArangoObjects ¶
func DeleteArangoObjects(ctx *ServerContext, collectionName, filter string, bindVars BindVars) Error
Note that this method does NOT check permissions nor perform validations It is up to the calling method to perform the necessary checks The filter must take the form of a match expression (e.g. "obj._id == @claim") TODO: Test
func FindArangoObject ¶
func FindArangoObject(ctx *ServerContext, query string, bindVars BindVars, result interface{}) Error
func FindArangoObjects ¶
func FindArangoObjects(ctx *ServerContext, query string, bindVars BindVars, results interface{}) Error
func GetFieldByJsonTag ¶
func GetFieldByJsonTag(item interface{}, jsonKey string) (field *reflect.StructField, gerr Error)
func LoadArangoObject ¶
func LoadArangoObject(ctx *ServerContext, result interface{}, arangoKey string) Error
func NewBusinessError ¶
func NewNotFoundError ¶
func NewPermissionError ¶
func NewServerError ¶
func NewUnauthorizedError ¶
func NewWarning ¶
func NotifyArgumentMoved ¶
func NotifyNewArgument ¶
func NotifyNewArgument(ctx ServerContext, userId uint64, item interface{}, newArg Argument) Error
func SetByJsonTag ¶
func SetJsonValuesOnStruct ¶
func UpdateArangoObject ¶
func UpdateArangoObject(ctx *ServerContext, obj ArangoObject, updates Updates) Error
func ValidateRequiredFields ¶
func ValidateStruct ¶
func ValidateStruct(item interface{}) Error
func ValidateStructField ¶
func ValidateStructFields ¶
type Inference ¶
type Inference struct {
Edge
}
Inference is an edge from the target (a Claim or Argument) of an Argument to the Argument that is making the inference
func (Inference) CollectionName ¶
func (*Inference) Create ¶
func (i *Inference) Create(ctx *ServerContext) Error
func (Inference) DefaultQueryParameters ¶
func (i Inference) DefaultQueryParameters() ArangoQueryParameters
func (*Inference) Delete ¶
func (i *Inference) Delete(ctx *ServerContext) Error
type Link ¶
type Link struct { VersionedModel Title string `json:"title" sql:"not null" valid:"length(3|1000)"` Description string `json:"desc" valid:"length(3|4000)"` Url string `json:"url" valid:"length(3|4000)"` ClaimID uuid.UUID `json:"claimId" sql:"type:uuid;not null"` Claim *Claim `json:"claim,omitempty"` }
func (Link) ValidateField ¶
func (Link) ValidateForCreate ¶
func (Link) ValidateForDelete ¶
func (Link) ValidateForUpdate ¶
type Loader ¶
type Loader interface { Load(*ServerContext) Error LoadFull(*ServerContext) Error }
type Model ¶
type Model struct { Key string `json:"_key" settable:"false"` CreatedAt time.Time `json:"start" settable:"false"` UpdatedAt time.Time `json:"mod" settable:"false"` DeletedAt *time.Time `json:"end" settable:"false"` }
func (*Model) PrepareForCreate ¶
func (m *Model) PrepareForCreate(ctx *ServerContext)
func (*Model) PrepareForDelete ¶
func (m *Model) PrepareForDelete(ctx *ServerContext)
type Notification ¶
type Notification struct { Model UserID uint64 `json:"userId" sql:"not null"` Type int `json:"type" sql:"not null"` ItemID *string `json:"itemId,omitempty" sql:"type:uuid"` ItemType *int `json:"itemType"` Item interface{} `json:"item,omitempty" gorm:"-"` OldID *string `json:"oldId,omitempty" sql:"type:uuid"` OldType *int `json:"oldType"` NewID *string `json:"newId,omitempty" sql:"type:uuid"` NewType *int `json:"newType"` Viewed bool `json:"viewed" sql:"not null"` }
func (Notification) ValidateField ¶
func (n Notification) ValidateField(f string) Error
func (Notification) ValidateForCreate ¶
func (n Notification) ValidateForCreate() Error
func (Notification) ValidateForUpdate ¶
func (n Notification) ValidateForUpdate() Error
type PremiseEdge ¶
A PremiseEdge is an edge that goes from a Multi-premise Claim to one of the Claims that represents a specific premise
func (PremiseEdge) ArangoID ¶
func (p PremiseEdge) ArangoID() string
func (PremiseEdge) ArangoKey ¶
func (p PremiseEdge) ArangoKey() string
func (PremiseEdge) CollectionName ¶
func (p PremiseEdge) CollectionName() string
func (*PremiseEdge) Create ¶
func (p *PremiseEdge) Create(ctx *ServerContext) Error
func (PremiseEdge) DefaultQueryParameters ¶
func (p PremiseEdge) DefaultQueryParameters() ArangoQueryParameters
func (*PremiseEdge) Delete ¶
func (p *PremiseEdge) Delete(ctx *ServerContext) Error
func (*PremiseEdge) Update ¶
func (p *PremiseEdge) Update(ctx *ServerContext, updates Updates) Error
func (*PremiseEdge) UpdateOrder ¶
func (p *PremiseEdge) UpdateOrder(ctx *ServerContext, order int) Error
TODO: Preserve history...
type ReplaceMany ¶
type ReplaceMany struct {
IDS []uint64 `json:"ids"`
}
type Restrictor ¶
type Restrictor interface { UserCanView(ctx *ServerContext) (bool, Error) UserCanCreate(ctx *ServerContext) (bool, Error) UserCanUpdate(ctx *ServerContext, updates Updates) (bool, Error) UserCanDelete(ctx *ServerContext) (bool, Error) }
UserCanUpdate should be called with the list of values that will be updated,
type Scorer ¶
type Scorer interface { Score(*ServerContext) (float32, Error) UpdateScore(*ServerContext) Error }
type ServerContext ¶
type ServerContext struct { Context context.Context Arango ArangoContext Payload map[string]interface{} Request map[string]interface{} Type reflect.Type ParentType reflect.Type Test bool UserContext User AppName string Method string Path string Endpoint string RequestID string RequestAt *time.Time }
func (*ServerContext) RequestTime ¶
func (ctx *ServerContext) RequestTime() time.Time
func (ServerContext) Rollback ¶
func (ctx ServerContext) Rollback() Error
type User ¶
type User struct { Model Name string `json:"name" sql:"not null" valid:"length(3|50)"` Username string `` /* 127-byte string literal not displayed */ Email string `json:"email" sql:"not null" valid:"email"` Password string `json:"password,omitempty" sql:"-" valid:"length(5|64)"` HashedPassword string `json:"hashed_password"` // TODO: don't return this value via the API Image string `json:"img,omitempty"` Curator bool `json:"curator"` Admin bool `json:"admin"` URL string `json:"url,omitempty"` EmailVerifiedAt *time.Time `json:"-" settable:"false"` }
func (*User) ChangePassword ¶
func (u *User) ChangePassword(ctx *ServerContext, oldPassword string) Error
func (User) CollectionName ¶
func (*User) Create ¶
func (u *User) Create(ctx *ServerContext) Error
func (User) DefaultQueryParameters ¶
func (u User) DefaultQueryParameters() ArangoQueryParameters
func (*User) Load ¶
func (u *User) Load(ctx *ServerContext) Error
func (*User) LoadFull ¶
func (u *User) LoadFull(ctx *ServerContext) Error
func (User) Score ¶
func (u User) Score(ctx *ServerContext, target ArangoObject, score float32) Error
func (*User) ScoreFor ¶
func (u *User) ScoreFor(ctx *ServerContext, target ArangoObject) (*UserScore, Error)
func (User) UserCanCreate ¶
func (u User) UserCanCreate(ctx *ServerContext) (bool, Error)
func (User) UserCanDelete ¶
func (u User) UserCanDelete(ctx *ServerContext) (bool, Error)
func (User) UserCanUpdate ¶
func (u User) UserCanUpdate(ctx *ServerContext, updates Updates) (bool, Error)
func (User) UserCanView ¶
func (u User) UserCanView(ctx *ServerContext) (bool, Error)
Restrictor TODO: Test TODO: Call in CRUD and other methods
func (User) ValidateField ¶
func (User) ValidateForCreate ¶
func (User) ValidateForDelete ¶
func (User) ValidateForUpdate ¶
func (*User) VerifyPassword ¶
func (u *User) VerifyPassword(ctx *ServerContext, password string) (bool, Error)
type UserScore ¶
A UserScore is an edge that goes from a User to either a Claim (truth score) or an Argument (relevance score) UserScore corresponds directly to the "Personal Score" or "Belief Score" described in the Canonical Debate white paper: https://github.com/canonical-debate-lab/paper#33322-belief-scores The Score attribute is a float value from 0 to 1.0, corresponding to a % belief in the truth/relevance of the target (where 0 = 0% and 1.0 = 100%)
func (UserScore) CollectionName ¶
func (*UserScore) Create ¶
func (u *UserScore) Create(ctx *ServerContext) Error
func (UserScore) DefaultQueryParameters ¶
func (u UserScore) DefaultQueryParameters() ArangoQueryParameters
func (*UserScore) Delete ¶
func (u *UserScore) Delete(ctx *ServerContext) Error
type VersionedModel ¶
type VersionedModel struct { Key string `json:"_key" settable:"false"` ID string `json:"id" settable:"false"` CreatedAt time.Time `json:"start" settable:"false"` UpdatedAt time.Time `json:"mod" settable:"false"` DeletedAt *time.Time `json:"end" settable:"false"` CreatedByID string `json:"creator" settable:"false"` UpdatedByID string `json:"editor,omitempty" settable:"false"` QueryAt *time.Time `json:"-"` }
func (VersionedModel) DateFilter ¶
func (vm VersionedModel) DateFilter(bindVars map[string]interface{}) string
func (*VersionedModel) PrepareForCreate ¶
func (vm *VersionedModel) PrepareForCreate(ctx *ServerContext)
func (*VersionedModel) PrepareForDelete ¶
func (vm *VersionedModel) PrepareForDelete(ctx *ServerContext)
func (VersionedModel) QueryDate ¶
func (vm VersionedModel) QueryDate() *time.Time
Source Files
¶
- arango_helpers.go
- argument.go
- argument_opinion.go
- base_claim_edge.go
- change_log.go
- claim.go
- claim_opinion.go
- context.go
- context_edge.go
- edge.go
- error.go
- inference.go
- jwt.go
- link.go
- loader.go
- model.go
- notification.go
- premise_edge.go
- restrictor.go
- scorer.go
- server_context.go
- test_helpers.go
- user.go
- user_score.go
- validator.go
- versioned_model.go