// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
package model
import (
"bytes"
"fmt"
"io"
"strconv"
"time"
"sourcecraft.dev/bigbes/sr-ht-core/model"
)
// An access grant on a database.
type ACLEntry struct {
User *User `json:"user"`
Mode AccessMode `json:"mode"`
}
// A branch and the commit it points at.
type Branch struct {
Name string `json:"name"`
Head string `json:"head"`
}
// A column of a table, as the stored schema declares it.
type Column struct {
Name string `json:"name"`
Type string `json:"type"`
PrimaryKey bool `json:"primaryKey"`
Nullable bool `json:"nullable"`
}
// One commit of a database's history.
type Commit struct {
Hash string `json:"hash"`
Author string `json:"author"`
Email string `json:"email"`
Date time.Time `json:"date"`
Message string `json:"message"`
Parents []string `json:"parents"`
}
type CommitCursor struct {
Results []*Commit `json:"results"`
Cursor *model.Cursor `json:"cursor,omitempty"`
}
type DatabaseCursor struct {
Results []*Database `json:"results"`
Cursor *model.Cursor `json:"cursor,omitempty"`
}
type Query struct {
}
// A table at a ref: its schema and how many rows it holds there.
type Table struct {
Name string `json:"name"`
Columns []*Column `json:"columns"`
RowCount int `json:"rowCount"`
}
// A SourceHut account, mirrored from meta.sr.ht.
type User struct {
// The username with no leading "~". This is the name that addresses the account
// in `database(owner:)` and in a clone URL's path.
Username string `json:"username"`
// The username with its leading "~", as SourceHut writes it in prose and in the
// web UI.
CanonicalName string `json:"canonicalName"`
}
// An ACL grant: read-only (browse and clone) or read-write (and push).
type AccessMode string
const (
AccessModeRo AccessMode = "RO"
AccessModeRw AccessMode = "RW"
)
var AllAccessMode = []AccessMode{
AccessModeRo,
AccessModeRw,
}
func (e AccessMode) IsValid() bool {
switch e {
case AccessModeRo, AccessModeRw:
return true
}
return false
}
func (e AccessMode) String() string {
return string(e)
}
func (e *AccessMode) UnmarshalGQL(v any) error {
str, ok := v.(string)
if !ok {
return fmt.Errorf("enums must be strings")
}
*e = AccessMode(str)
if !e.IsValid() {
return fmt.Errorf("%s is not a valid AccessMode", str)
}
return nil
}
func (e AccessMode) MarshalGQL(w io.Writer) {
fmt.Fprint(w, strconv.Quote(e.String()))
}
func (e *AccessMode) UnmarshalJSON(b []byte) error {
s, err := strconv.Unquote(string(b))
if err != nil {
return err
}
return e.UnmarshalGQL(s)
}
func (e AccessMode) MarshalJSON() ([]byte, error) {
var buf bytes.Buffer
e.MarshalGQL(&buf)
return buf.Bytes(), nil
}
// Who may see a database, and how it is listed.
//
// PUBLIC is listed to everyone including anonymous callers. UNLISTED is reachable
// by direct address but never appears in a listing to a stranger. PRIVATE is
// neither: to a caller who may not see it, it does not exist — this schema answers
// null rather than an authorization error, exactly as the web UI answers "no such
// database" rather than "forbidden".
type Visibility string
const (
VisibilityPublic Visibility = "PUBLIC"
VisibilityUnlisted Visibility = "UNLISTED"
VisibilityPrivate Visibility = "PRIVATE"
)
var AllVisibility = []Visibility{
VisibilityPublic,
VisibilityUnlisted,
VisibilityPrivate,
}
func (e Visibility) IsValid() bool {
switch e {
case VisibilityPublic, VisibilityUnlisted, VisibilityPrivate:
return true
}
return false
}
func (e Visibility) String() string {
return string(e)
}
func (e *Visibility) UnmarshalGQL(v any) error {
str, ok := v.(string)
if !ok {
return fmt.Errorf("enums must be strings")
}
*e = Visibility(str)
if !e.IsValid() {
return fmt.Errorf("%s is not a valid Visibility", str)
}
return nil
}
func (e Visibility) MarshalGQL(w io.Writer) {
fmt.Fprint(w, strconv.Quote(e.String()))
}
func (e *Visibility) UnmarshalJSON(b []byte) error {
s, err := strconv.Unquote(string(b))
if err != nil {
return err
}
return e.UnmarshalGQL(s)
}
func (e Visibility) MarshalJSON() ([]byte, error) {
var buf bytes.Buffer
e.MarshalGQL(&buf)
return buf.Bytes(), nil
}