~bigbes/sr-ht-spec

ref: 471d9706ec6f3b9bdb5c2726b9f6c4fbf90ddca4 sr-ht-spec/graph/model/models.go -rw-r--r-- 2.5 KiB
471d9706 — Eugene Blikh chrome: the resolved favicon and the queue as a shared table 9 days ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
// Package model holds the Go types the GraphQL schema binds to.
//
// They are hand-written rather than generated so that the wire shape is
// reviewable in one file, and they are deliberately their own types rather than
// aliases of service/'s: a GraphQL type is a published contract, and binding it
// straight onto an internal struct means every field added below the API layer
// appears in the schema by accident.
//
// Fields gqlgen resolves with a call rather than a struct read — Space.approvedRev,
// Project.spaces — are absent here on purpose. Their absence is what makes gqlgen
// generate a resolver for them, so the repository is only opened, and the
// membership only listed, when a query actually asks.
package model

import "time"

// Space is one space: a bare git repository addressed ~owner/name.
type Space struct {
	Owner   string
	Name    string
	Ref     string
	Created time.Time
}

// Document is one document at one revision.
//
// The optional frontmatter fields are plain strings, with the empty string
// meaning "the frontmatter does not carry this key". DocID is the exception and
// is a pointer, because there the distinction is load-bearing: a null DocID is
// exactly the case where ID fell back to the document's path, which is what an
// agent about to propose an edit has to know.
type Document struct {
	Space      string
	ID         string
	DocID      *string
	Path       string
	Rev        string
	Blob       string
	Pinned     bool
	Title      string
	Status     string
	Section    string
	Summary    string
	Type       string
	Supersedes string
	Tags       []string
	Owners     []string
	Markdown   string
}

// Project is one project: a saved filter over the one global index.
type Project struct {
	Owner string
	Name  string
	Ref   string
	Meta  bool
}

// SearchResults is one page of ranked hits.
type SearchResults struct {
	Total int
	Took  string
	Hits  []*SearchHit
}

// SearchHit is one ranked document.
type SearchHit struct {
	Space   string
	ID      string
	Rev     string
	Path    string
	Anchor  string
	Title   string
	Section string
	Lang    string
	Score   float64
	Snippet string
}

// Proposal is one proposal as the read schema reports it.
type Proposal struct {
	ID           int
	Space        string
	Title        string
	Rationale    string
	BaseRev      string
	Branch       string
	State        ProposalState
	Approval     *Approval
	MergedRev    *string
	Agent        string
	AgentSession string
	Created      time.Time
	Resolved     *time.Time
}