mirror of
https://github.com/documize/community.git
synced 2025-07-18 20:59:43 +02:00
[WIP] new schema implementation
This commit is contained in:
parent
9c2594b1b4
commit
28342fcf5e
27 changed files with 1413 additions and 1158 deletions
|
@ -18,9 +18,9 @@ type UserActivity struct {
|
|||
ID uint64 `json:"id"`
|
||||
OrgID string `json:"orgId"`
|
||||
UserID string `json:"userId"`
|
||||
LabelID string `json:"folderId"`
|
||||
SpaceID string `json:"folderId"`
|
||||
DocumentID string `json:"documentId"`
|
||||
PageID string `json:"pageId"`
|
||||
SectionID string `json:"pageId"`
|
||||
ActivityType Type `json:"activityType"`
|
||||
SourceType SourceType `json:"sourceType"`
|
||||
Metadata string `json:"metadata"`
|
||||
|
@ -34,10 +34,10 @@ type UserActivity struct {
|
|||
type DocumentActivity struct {
|
||||
ID uint64 `json:"id"`
|
||||
OrgID string `json:"orgId"`
|
||||
LabelID string `json:"folderId"`
|
||||
SpaceID string `json:"folderId"`
|
||||
DocumentID string `json:"documentId"`
|
||||
PageID string `json:"pageId"`
|
||||
PageTitle string `json:"pageTitle"`
|
||||
SectionID string `json:"pageId"`
|
||||
SectionName string `json:"pageTitle"`
|
||||
UserID string `json:"userId"`
|
||||
Firstname string `json:"firstname"`
|
||||
Lastname string `json:"lastname"`
|
||||
|
|
|
@ -17,11 +17,11 @@ import "github.com/documize/community/model"
|
|||
type Block struct {
|
||||
model.BaseEntity
|
||||
OrgID string `json:"orgId"`
|
||||
LabelID string `json:"folderId"`
|
||||
SpaceID string `json:"folderId"`
|
||||
UserID string `json:"userId"`
|
||||
ContentType string `json:"contentType"`
|
||||
PageType string `json:"pageType"`
|
||||
Title string `json:"title"`
|
||||
Name string `json:"title"`
|
||||
Body string `json:"body"`
|
||||
Excerpt string `json:"excerpt"`
|
||||
RawBody string `json:"rawBody"` // a blob of data
|
||||
|
|
|
@ -16,9 +16,9 @@ import "github.com/documize/community/model"
|
|||
// Category represents a category within a space that is persisted to the database.
|
||||
type Category struct {
|
||||
model.BaseEntity
|
||||
OrgID string `json:"orgId"`
|
||||
LabelID string `json:"folderId"`
|
||||
Category string `json:"category"`
|
||||
OrgID string `json:"orgId"`
|
||||
SpaceID string `json:"folderId"`
|
||||
Name string `json:"category"`
|
||||
}
|
||||
|
||||
// Member represents 0:M association between a document and category, persisted to the database.
|
||||
|
@ -26,7 +26,7 @@ type Member struct {
|
|||
model.BaseEntity
|
||||
OrgID string `json:"orgId"`
|
||||
CategoryID string `json:"categoryId"`
|
||||
LabelID string `json:"folderId"`
|
||||
SpaceID string `json:"folderId"`
|
||||
DocumentID string `json:"documentId"`
|
||||
}
|
||||
|
||||
|
|
|
@ -23,11 +23,11 @@ import (
|
|||
type Document struct {
|
||||
model.BaseEntity
|
||||
OrgID string `json:"orgId"`
|
||||
LabelID string `json:"folderId"`
|
||||
SpaceID string `json:"folderId"`
|
||||
UserID string `json:"userId"`
|
||||
Job string `json:"job"`
|
||||
Location string `json:"location"`
|
||||
Title string `json:"name"`
|
||||
Name string `json:"name"`
|
||||
Excerpt string `json:"excerpt"`
|
||||
Slug string `json:"-"`
|
||||
Tags string `json:"tags"`
|
||||
|
@ -43,19 +43,19 @@ type Document struct {
|
|||
|
||||
// SetDefaults ensures on blanks and cleans.
|
||||
func (d *Document) SetDefaults() {
|
||||
d.Title = strings.TrimSpace(d.Title)
|
||||
d.Name = strings.TrimSpace(d.Name)
|
||||
|
||||
if len(d.Title) == 0 {
|
||||
d.Title = "Document"
|
||||
if len(d.Name) == 0 {
|
||||
d.Name = "Document"
|
||||
}
|
||||
}
|
||||
|
||||
// ByTitle sorts a collection of documents by document title.
|
||||
type ByTitle []Document
|
||||
// ByName sorts a collection of documents by document Name.
|
||||
type ByName []Document
|
||||
|
||||
func (a ByTitle) Len() int { return len(a) }
|
||||
func (a ByTitle) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
|
||||
func (a ByTitle) Less(i, j int) bool { return strings.ToLower(a[i].Title) < strings.ToLower(a[j].Title) }
|
||||
func (a ByName) Len() int { return len(a) }
|
||||
func (a ByName) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
|
||||
func (a ByName) Less(i, j int) bool { return strings.ToLower(a[i].Name) < strings.ToLower(a[j].Name) }
|
||||
|
||||
// DocumentMeta details who viewed the document.
|
||||
type DocumentMeta struct {
|
||||
|
|
|
@ -21,7 +21,7 @@ type Link struct {
|
|||
UserID string `json:"userId"`
|
||||
LinkType string `json:"linkType"`
|
||||
SourceDocumentID string `json:"sourceDocumentId"`
|
||||
SourcePageID string `json:"sourcePageId"`
|
||||
SourceSectionID string `json:"sourcePageId"`
|
||||
TargetDocumentID string `json:"targetDocumentId"`
|
||||
TargetID string `json:"targetId"`
|
||||
ExternalID string `json:"externalId"`
|
||||
|
@ -32,7 +32,7 @@ type Link struct {
|
|||
type Candidate struct {
|
||||
RefID string `json:"id"`
|
||||
LinkType string `json:"linkType"`
|
||||
FolderID string `json:"folderId"`
|
||||
SpaceID string `json:"folderId"`
|
||||
DocumentID string `json:"documentId"`
|
||||
TargetID string `json:"targetId"`
|
||||
Title string `json:"title"` // what we label the link
|
||||
|
|
|
@ -26,12 +26,12 @@ type Page struct {
|
|||
DocumentID string `json:"documentId"`
|
||||
UserID string `json:"userId"`
|
||||
ContentType string `json:"contentType"`
|
||||
PageType string `json:"pageType"`
|
||||
BlockID string `json:"blockId"`
|
||||
Type string `json:"pageType"`
|
||||
TemplateID string `json:"blockId"`
|
||||
Level uint64 `json:"level"`
|
||||
Sequence float64 `json:"sequence"`
|
||||
Numbering string `json:"numbering"`
|
||||
Title string `json:"title"`
|
||||
Name string `json:"title"`
|
||||
Body string `json:"body"`
|
||||
Revisions uint64 `json:"revisions"`
|
||||
Status workflow.ChangeStatus `json:"status"`
|
||||
|
@ -48,17 +48,17 @@ func (p *Page) SetDefaults() {
|
|||
p.Level = 1
|
||||
}
|
||||
|
||||
p.Title = strings.TrimSpace(p.Title)
|
||||
p.Name = strings.TrimSpace(p.Name)
|
||||
}
|
||||
|
||||
// IsSectionType tells us that page is "words"
|
||||
func (p *Page) IsSectionType() bool {
|
||||
return p.PageType == "section"
|
||||
return p.Type == "section"
|
||||
}
|
||||
|
||||
// IsTabType tells us that page is "SaaS data embed"
|
||||
func (p *Page) IsTabType() bool {
|
||||
return p.PageType == "tab"
|
||||
return p.Type == "tab"
|
||||
}
|
||||
|
||||
// Meta holds raw page data that is used to
|
||||
|
@ -70,7 +70,7 @@ type Meta struct {
|
|||
OrgID string `json:"orgId"`
|
||||
UserID string `json:"userId"`
|
||||
DocumentID string `json:"documentId"`
|
||||
PageID string `json:"pageId"`
|
||||
SectionID string `json:"pageId"`
|
||||
RawBody string `json:"rawBody"` // a blob of data
|
||||
Config string `json:"config"` // JSON based custom config for this type
|
||||
ExternalSource bool `json:"externalSource"` // true indicates data sourced externally
|
||||
|
@ -88,12 +88,12 @@ type Revision struct {
|
|||
model.BaseEntity
|
||||
OrgID string `json:"orgId"`
|
||||
DocumentID string `json:"documentId"`
|
||||
PageID string `json:"pageId"`
|
||||
SectionID string `json:"pageId"`
|
||||
OwnerID string `json:"ownerId"`
|
||||
UserID string `json:"userId"`
|
||||
ContentType string `json:"contentType"`
|
||||
PageType string `json:"pageType"`
|
||||
Title string `json:"title"`
|
||||
Type string `json:"pageType"`
|
||||
Name string `json:"title"`
|
||||
Body string `json:"body"`
|
||||
RawBody string `json:"rawBody"`
|
||||
Config string `json:"config"`
|
||||
|
@ -112,14 +112,14 @@ type NewPage struct {
|
|||
|
||||
// SequenceRequest details a page ID and its sequence within the document.
|
||||
type SequenceRequest struct {
|
||||
PageID string `json:"pageId"`
|
||||
Sequence float64 `json:"sequence"`
|
||||
SectionID string `json:"pageId"`
|
||||
Sequence float64 `json:"sequence"`
|
||||
}
|
||||
|
||||
// LevelRequest details a page ID and level.
|
||||
type LevelRequest struct {
|
||||
PageID string `json:"pageId"`
|
||||
Level int `json:"level"`
|
||||
SectionID string `json:"pageId"`
|
||||
Level int `json:"level"`
|
||||
}
|
||||
|
||||
// BulkRequest details page, it's meta, pending page changes.
|
||||
|
|
|
@ -18,8 +18,8 @@ type Pin struct {
|
|||
model.BaseEntity
|
||||
OrgID string `json:"orgId"`
|
||||
UserID string `json:"userId"`
|
||||
FolderID string `json:"folderId"`
|
||||
SpaceID string `json:"folderId"`
|
||||
DocumentID string `json:"documentId"`
|
||||
Pin string `json:"pin"`
|
||||
Name string `json:"pin"`
|
||||
Sequence int `json:"sequence"`
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ func (l *Space) IsRestricted() bool {
|
|||
// Viewer details who can see a particular space
|
||||
type Viewer struct {
|
||||
Name string `json:"name"`
|
||||
LabelID string `json:"folderId"`
|
||||
SpaceID string `json:"folderId"`
|
||||
Type int `json:"folderType"`
|
||||
UserID string `json:"userId"`
|
||||
Firstname string `json:"firstname"`
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue