| 1 |
|
// Code generated by github.com/99designs/gqlgen, DO NOT EDIT. |
| 2 |
|
|
| 3 |
|
package model |
| 4 |
|
|
| 5 |
|
import ( |
| 6 |
|
"bytes" |
| 7 |
|
"fmt" |
| 8 |
|
"io" |
| 9 |
|
"strconv" |
| 10 |
|
"time" |
| 11 |
|
|
| 12 |
|
"sourcecraft.dev/bigbes/sr-ht-core/model" |
| 13 |
|
) |
| 14 |
|
|
| 15 |
|
// An access grant on a database. |
| 16 |
|
type ACLEntry struct { |
| 17 |
|
User *User `json:"user"` |
| 18 |
|
Mode AccessMode `json:"mode"` |
| 19 |
|
} |
| 20 |
|
|
| 21 |
|
// A branch and the commit it points at. |
| 22 |
|
type Branch struct { |
| 23 |
|
Name string `json:"name"` |
| 24 |
|
Head string `json:"head"` |
| 25 |
|
} |
| 26 |
|
|
| 27 |
|
// A column of a table, as the stored schema declares it. |
| 28 |
|
type Column struct { |
| 29 |
|
Name string `json:"name"` |
| 30 |
|
Type string `json:"type"` |
| 31 |
|
PrimaryKey bool `json:"primaryKey"` |
| 32 |
|
Nullable bool `json:"nullable"` |
| 33 |
|
} |
| 34 |
|
|
| 35 |
|
// One commit of a database's history. |
| 36 |
|
type Commit struct { |
| 37 |
|
Hash string `json:"hash"` |
| 38 |
|
Author string `json:"author"` |
| 39 |
|
Email string `json:"email"` |
| 40 |
|
Date time.Time `json:"date"` |
| 41 |
|
Message string `json:"message"` |
| 42 |
|
Parents []string `json:"parents"` |
| 43 |
|
} |
| 44 |
|
|
| 45 |
|
type CommitCursor struct { |
| 46 |
|
Results []*Commit `json:"results"` |
| 47 |
|
Cursor *model.Cursor `json:"cursor,omitempty"` |
| 48 |
|
} |
| 49 |
|
|
| 50 |
|
type DatabaseCursor struct { |
| 51 |
|
Results []*Database `json:"results"` |
| 52 |
|
Cursor *model.Cursor `json:"cursor,omitempty"` |
| 53 |
|
} |
| 54 |
|
|
| 55 |
|
type Query struct { |
| 56 |
|
} |
| 57 |
|
|
| 58 |
|
// A table at a ref: its schema and how many rows it holds there. |
| 59 |
|
type Table struct { |
| 60 |
|
Name string `json:"name"` |
| 61 |
|
Columns []*Column `json:"columns"` |
| 62 |
|
RowCount int `json:"rowCount"` |
| 63 |
|
} |
| 64 |
|
|
| 65 |
|
// A SourceHut account, mirrored from meta.sr.ht. |
| 66 |
|
type User struct { |
| 67 |
|
// The username with no leading "~". This is the name that addresses the account |
| 68 |
|
// in `database(owner:)` and in a clone URL's path. |
| 69 |
|
Username string `json:"username"` |
| 70 |
|
// The username with its leading "~", as SourceHut writes it in prose and in the |
| 71 |
|
// web UI. |
| 72 |
|
CanonicalName string `json:"canonicalName"` |
| 73 |
|
} |
| 74 |
|
|
| 75 |
|
// An ACL grant: read-only (browse and clone) or read-write (and push). |
| 76 |
|
type AccessMode string |
| 77 |
|
|
| 78 |
|
const ( |
| 79 |
|
AccessModeRo AccessMode = "RO" |
| 80 |
|
AccessModeRw AccessMode = "RW" |
| 81 |
|
) |
| 82 |
|
|
| 83 |
|
var AllAccessMode = []AccessMode{ |
| 84 |
|
AccessModeRo, |
| 85 |
|
AccessModeRw, |
| 86 |
|
} |
| 87 |
|
|
| 88 |
0 |
func (e AccessMode) IsValid() bool { |
| 89 |
0 |
switch e { |
| 90 |
0 |
case AccessModeRo, AccessModeRw: |
| 91 |
0 |
return true |
| 92 |
|
} |
| 93 |
0 |
return false |
| 94 |
|
} |
| 95 |
|
|
| 96 |
0 |
func (e AccessMode) String() string { |
| 97 |
0 |
return string(e) |
| 98 |
0 |
} |
| 99 |
|
|
| 100 |
0 |
func (e *AccessMode) UnmarshalGQL(v any) error { |
| 101 |
0 |
str, ok := v.(string) |
| 102 |
0 |
if !ok { |
| 103 |
0 |
return fmt.Errorf("enums must be strings") |
| 104 |
0 |
} |
| 105 |
|
|
| 106 |
0 |
*e = AccessMode(str) |
| 107 |
0 |
if !e.IsValid() { |
| 108 |
0 |
return fmt.Errorf("%s is not a valid AccessMode", str) |
| 109 |
0 |
} |
| 110 |
0 |
return nil |
| 111 |
|
} |
| 112 |
|
|
| 113 |
0 |
func (e AccessMode) MarshalGQL(w io.Writer) { |
| 114 |
0 |
fmt.Fprint(w, strconv.Quote(e.String())) |
| 115 |
0 |
} |
| 116 |
|
|
| 117 |
0 |
func (e *AccessMode) UnmarshalJSON(b []byte) error { |
| 118 |
0 |
s, err := strconv.Unquote(string(b)) |
| 119 |
0 |
if err != nil { |
| 120 |
0 |
return err |
| 121 |
0 |
} |
| 122 |
0 |
return e.UnmarshalGQL(s) |
| 123 |
|
} |
| 124 |
|
|
| 125 |
0 |
func (e AccessMode) MarshalJSON() ([]byte, error) { |
| 126 |
0 |
var buf bytes.Buffer |
| 127 |
0 |
e.MarshalGQL(&buf) |
| 128 |
0 |
return buf.Bytes(), nil |
| 129 |
0 |
} |
| 130 |
|
|
| 131 |
|
// Who may see a database, and how it is listed. |
| 132 |
|
// |
| 133 |
|
// PUBLIC is listed to everyone including anonymous callers. UNLISTED is reachable |
| 134 |
|
// by direct address but never appears in a listing to a stranger. PRIVATE is |
| 135 |
|
// neither: to a caller who may not see it, it does not exist — this schema answers |
| 136 |
|
// null rather than an authorization error, exactly as the web UI answers "no such |
| 137 |
|
// database" rather than "forbidden". |
| 138 |
|
type Visibility string |
| 139 |
|
|
| 140 |
|
const ( |
| 141 |
|
VisibilityPublic Visibility = "PUBLIC" |
| 142 |
|
VisibilityUnlisted Visibility = "UNLISTED" |
| 143 |
|
VisibilityPrivate Visibility = "PRIVATE" |
| 144 |
|
) |
| 145 |
|
|
| 146 |
|
var AllVisibility = []Visibility{ |
| 147 |
|
VisibilityPublic, |
| 148 |
|
VisibilityUnlisted, |
| 149 |
|
VisibilityPrivate, |
| 150 |
|
} |
| 151 |
|
|
| 152 |
0 |
func (e Visibility) IsValid() bool { |
| 153 |
0 |
switch e { |
| 154 |
0 |
case VisibilityPublic, VisibilityUnlisted, VisibilityPrivate: |
| 155 |
0 |
return true |
| 156 |
|
} |
| 157 |
0 |
return false |
| 158 |
|
} |
| 159 |
|
|
| 160 |
0 |
func (e Visibility) String() string { |
| 161 |
0 |
return string(e) |
| 162 |
0 |
} |
| 163 |
|
|
| 164 |
0 |
func (e *Visibility) UnmarshalGQL(v any) error { |
| 165 |
0 |
str, ok := v.(string) |
| 166 |
0 |
if !ok { |
| 167 |
0 |
return fmt.Errorf("enums must be strings") |
| 168 |
0 |
} |
| 169 |
|
|
| 170 |
0 |
*e = Visibility(str) |
| 171 |
0 |
if !e.IsValid() { |
| 172 |
0 |
return fmt.Errorf("%s is not a valid Visibility", str) |
| 173 |
0 |
} |
| 174 |
0 |
return nil |
| 175 |
|
} |
| 176 |
|
|
| 177 |
0 |
func (e Visibility) MarshalGQL(w io.Writer) { |
| 178 |
0 |
fmt.Fprint(w, strconv.Quote(e.String())) |
| 179 |
0 |
} |
| 180 |
|
|
| 181 |
0 |
func (e *Visibility) UnmarshalJSON(b []byte) error { |
| 182 |
0 |
s, err := strconv.Unquote(string(b)) |
| 183 |
0 |
if err != nil { |
| 184 |
0 |
return err |
| 185 |
0 |
} |
| 186 |
0 |
return e.UnmarshalGQL(s) |
| 187 |
|
} |
| 188 |
|
|
| 189 |
0 |
func (e Visibility) MarshalJSON() ([]byte, error) { |
| 190 |
0 |
var buf bytes.Buffer |
| 191 |
0 |
e.MarshalGQL(&buf) |
| 192 |
0 |
return buf.Bytes(), nil |
| 193 |
0 |
} |