mirror of
https://github.com/documize/community.git
synced 2025-07-24 07:39:43 +02:00
still moving codebase to new API (WIP)
This commit is contained in:
parent
72b14def6d
commit
d90b3249c3
44 changed files with 5276 additions and 336 deletions
73
model/activity/activity.go
Normal file
73
model/activity/activity.go
Normal file
|
@ -0,0 +1,73 @@
|
|||
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
||||
//
|
||||
// This software (Documize Community Edition) is licensed under
|
||||
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
||||
//
|
||||
// You can operate outside the AGPL restrictions by purchasing
|
||||
// Documize Enterprise Edition and obtaining a commercial license
|
||||
// by contacting <sales@documize.com>.
|
||||
//
|
||||
// https://documize.com
|
||||
|
||||
package activity
|
||||
|
||||
import "time"
|
||||
|
||||
// UserActivity represents an activity undertaken by a user.
|
||||
type UserActivity struct {
|
||||
ID uint64 `json:"-"`
|
||||
OrgID string `json:"orgId"`
|
||||
UserID string `json:"userId"`
|
||||
LabelID string `json:"folderId"`
|
||||
SourceID string `json:"sourceId"`
|
||||
SourceName string `json:"sourceName"` // e.g. Document or Space name
|
||||
SourceType SourceType `json:"sourceType"`
|
||||
ActivityType Type `json:"activityType"`
|
||||
Created time.Time `json:"created"`
|
||||
}
|
||||
|
||||
// SourceType details where the activity occured.
|
||||
type SourceType int
|
||||
|
||||
// Type determines type of user activity
|
||||
type Type int
|
||||
|
||||
const (
|
||||
// SourceTypeSpace indicates activity against a space.
|
||||
SourceTypeSpace SourceType = 1
|
||||
|
||||
// SourceTypeDocument indicates activity against a document.
|
||||
SourceTypeDocument SourceType = 2
|
||||
)
|
||||
|
||||
const (
|
||||
// TypeCreated records user document creation
|
||||
TypeCreated Type = 1
|
||||
|
||||
// TypeRead states user has read document
|
||||
TypeRead Type = 2
|
||||
|
||||
// TypeEdited states user has editing document
|
||||
TypeEdited Type = 3
|
||||
|
||||
// TypeDeleted records user deleting space/document
|
||||
TypeDeleted Type = 4
|
||||
|
||||
// TypeArchived records user archiving space/document
|
||||
TypeArchived Type = 5
|
||||
|
||||
// TypeApproved records user approval of document
|
||||
TypeApproved Type = 6
|
||||
|
||||
// TypeReverted records user content roll-back to previous version
|
||||
TypeReverted Type = 7
|
||||
|
||||
// TypePublishedTemplate records user creating new document template
|
||||
TypePublishedTemplate Type = 8
|
||||
|
||||
// TypePublishedBlock records user creating reusable content block
|
||||
TypePublishedBlock Type = 9
|
||||
|
||||
// TypeFeedback records user providing document feedback
|
||||
TypeFeedback Type = 10
|
||||
)
|
26
model/attachment/attachment.go
Normal file
26
model/attachment/attachment.go
Normal file
|
@ -0,0 +1,26 @@
|
|||
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
||||
//
|
||||
// This software (Documize Community Edition) is licensed under
|
||||
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
||||
//
|
||||
// You can operate outside the AGPL restrictions by purchasing
|
||||
// Documize Enterprise Edition and obtaining a commercial license
|
||||
// by contacting <sales@documize.com>.
|
||||
//
|
||||
// https://documize.com
|
||||
|
||||
package attachment
|
||||
|
||||
import "github.com/documize/community/model"
|
||||
|
||||
// Attachment represents an attachment to a document.
|
||||
type Attachment struct {
|
||||
model.BaseEntity
|
||||
OrgID string `json:"orgId"`
|
||||
DocumentID string `json:"documentId"`
|
||||
Job string `json:"job"`
|
||||
FileID string `json:"fileId"`
|
||||
Filename string `json:"filename"`
|
||||
Data []byte `json:"-"`
|
||||
Extension string `json:"extension"`
|
||||
}
|
20
model/auth/auth.go
Normal file
20
model/auth/auth.go
Normal file
|
@ -0,0 +1,20 @@
|
|||
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
||||
//
|
||||
// This software (Documize Community Edition) is licensed under
|
||||
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
||||
//
|
||||
// You can operate outside the AGPL restrictions by purchasing
|
||||
// Documize Enterprise Edition and obtaining a commercial license
|
||||
// by contacting <sales@documize.com>.
|
||||
//
|
||||
// https://documize.com
|
||||
|
||||
package auth
|
||||
|
||||
import "github.com/documize/community/model/user"
|
||||
|
||||
// AuthenticationModel details authentication token and user details.
|
||||
type AuthenticationModel struct {
|
||||
Token string `json:"token"`
|
||||
User user.User `json:"user"`
|
||||
}
|
52
model/auth/keycloak.go
Normal file
52
model/auth/keycloak.go
Normal file
|
@ -0,0 +1,52 @@
|
|||
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
||||
//
|
||||
// This software (Documize Community Edition) is licensed under
|
||||
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
||||
//
|
||||
// You can operate outside the AGPL restrictions by purchasing
|
||||
// Documize Enterprise Edition and obtaining a commercial license
|
||||
// by contacting <sales@documize.com>.
|
||||
//
|
||||
// https://documize.com
|
||||
|
||||
package auth
|
||||
|
||||
// KeycloakAuthRequest data received via Keycloak client library
|
||||
type KeycloakAuthRequest struct {
|
||||
Domain string `json:"domain"`
|
||||
Token string `json:"token"`
|
||||
RemoteID string `json:"remoteId"`
|
||||
Email string `json:"email"`
|
||||
Username string `json:"username"`
|
||||
Firstname string `json:"firstname"`
|
||||
Lastname string `json:"lastname"`
|
||||
Enabled bool `json:"enabled"`
|
||||
}
|
||||
|
||||
// KeycloakConfig server configuration
|
||||
type KeycloakConfig struct {
|
||||
URL string `json:"url"`
|
||||
Realm string `json:"realm"`
|
||||
ClientID string `json:"clientId"`
|
||||
PublicKey string `json:"publicKey"`
|
||||
AdminUser string `json:"adminUser"`
|
||||
AdminPassword string `json:"adminPassword"`
|
||||
Group string `json:"group"`
|
||||
DisableLogout bool `json:"disableLogout"`
|
||||
DefaultPermissionAddSpace bool `json:"defaultPermissionAddSpace"`
|
||||
}
|
||||
|
||||
// KeycloakAPIAuth is returned when authenticating with Keycloak REST API.
|
||||
type KeycloakAPIAuth struct {
|
||||
AccessToken string `json:"access_token"`
|
||||
}
|
||||
|
||||
// KeycloakUser details user record returned by Keycloak
|
||||
type KeycloakUser struct {
|
||||
ID string `json:"id"`
|
||||
Username string `json:"username"`
|
||||
Email string `json:"email"`
|
||||
Firstname string `json:"firstName"`
|
||||
Lastname string `json:"lastName"`
|
||||
Enabled bool `json:"enabled"`
|
||||
}
|
82
model/doc/doc.go
Normal file
82
model/doc/doc.go
Normal file
|
@ -0,0 +1,82 @@
|
|||
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
||||
//
|
||||
// This software (Documize Community Edition) is licensed under
|
||||
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
||||
//
|
||||
// You can operate outside the AGPL restrictions by purchasing
|
||||
// Documize Enterprise Edition and obtaining a commercial license
|
||||
// by contacting <sales@documize.com>.
|
||||
//
|
||||
// https://documize.com
|
||||
|
||||
package doc
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/documize/community/model"
|
||||
)
|
||||
|
||||
// Document represents the purpose of Documize.
|
||||
type Document struct {
|
||||
model.BaseEntity
|
||||
OrgID string `json:"orgId"`
|
||||
LabelID string `json:"folderId"`
|
||||
UserID string `json:"userId"`
|
||||
Job string `json:"job"`
|
||||
Location string `json:"location"`
|
||||
Title string `json:"name"`
|
||||
Excerpt string `json:"excerpt"`
|
||||
Slug string `json:"-"`
|
||||
Tags string `json:"tags"`
|
||||
Template bool `json:"template"`
|
||||
Layout string `json:"layout"`
|
||||
}
|
||||
|
||||
// SetDefaults ensures on blanks and cleans.
|
||||
func (d *Document) SetDefaults() {
|
||||
d.Title = strings.TrimSpace(d.Title)
|
||||
|
||||
if len(d.Title) == 0 {
|
||||
d.Title = "Document"
|
||||
}
|
||||
}
|
||||
|
||||
// DocumentMeta details who viewed the document.
|
||||
type DocumentMeta struct {
|
||||
Viewers []DocumentMetaViewer `json:"viewers"`
|
||||
Editors []DocumentMetaEditor `json:"editors"`
|
||||
}
|
||||
|
||||
// DocumentMetaViewer contains the "view" metatdata content.
|
||||
type DocumentMetaViewer struct {
|
||||
UserID string `json:"userId"`
|
||||
Created time.Time `json:"created"`
|
||||
Firstname string `json:"firstname"`
|
||||
Lastname string `json:"lastname"`
|
||||
}
|
||||
|
||||
// DocumentMetaEditor contains the "edit" metatdata content.
|
||||
type DocumentMetaEditor struct {
|
||||
PageID string `json:"pageId"`
|
||||
UserID string `json:"userId"`
|
||||
Action string `json:"action"`
|
||||
Created time.Time `json:"created"`
|
||||
Firstname string `json:"firstname"`
|
||||
Lastname string `json:"lastname"`
|
||||
}
|
||||
|
||||
// UploadModel details the job ID of an uploaded document.
|
||||
type UploadModel struct {
|
||||
JobID string `json:"jobId"`
|
||||
}
|
||||
|
||||
// SitemapDocument details a document that can be exposed via Sitemap.
|
||||
type SitemapDocument struct {
|
||||
DocumentID string
|
||||
Document string
|
||||
FolderID string
|
||||
Folder string
|
||||
Revised time.Time
|
||||
}
|
39
model/link/link.go
Normal file
39
model/link/link.go
Normal file
|
@ -0,0 +1,39 @@
|
|||
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
||||
//
|
||||
// This software (Documize Community Edition) is licensed under
|
||||
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
||||
//
|
||||
// You can operate outside the AGPL restrictions by purchasing
|
||||
// Documize Enterprise Edition and obtaining a commercial license
|
||||
// by contacting <sales@documize.com>.
|
||||
//
|
||||
// https://documize.com
|
||||
|
||||
package link
|
||||
|
||||
import "github.com/documize/community/model"
|
||||
|
||||
// Link defines a reference between a section and another document/section/attachment.
|
||||
type Link struct {
|
||||
model.BaseEntity
|
||||
OrgID string `json:"orgId"`
|
||||
FolderID string `json:"folderId"`
|
||||
UserID string `json:"userId"`
|
||||
LinkType string `json:"linkType"`
|
||||
SourceDocumentID string `json:"sourceDocumentId"`
|
||||
SourcePageID string `json:"sourcePageId"`
|
||||
TargetDocumentID string `json:"targetDocumentId"`
|
||||
TargetID string `json:"targetId"`
|
||||
Orphan bool `json:"orphan"`
|
||||
}
|
||||
|
||||
// Candidate defines a potential link to a document/section/attachment.
|
||||
type Candidate struct {
|
||||
RefID string `json:"id"`
|
||||
LinkType string `json:"linkType"`
|
||||
FolderID string `json:"folderId"`
|
||||
DocumentID string `json:"documentId"`
|
||||
TargetID string `json:"targetId"`
|
||||
Title string `json:"title"` // what we label the link
|
||||
Context string `json:"context"` // additional context (e.g. excerpt, parent, file extension)
|
||||
}
|
38
model/org/meta.go
Normal file
38
model/org/meta.go
Normal file
|
@ -0,0 +1,38 @@
|
|||
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
||||
//
|
||||
// This software (Documize Community Edition) is licensed under
|
||||
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
||||
//
|
||||
// You can operate outside the AGPL restrictions by purchasing
|
||||
// Documize Enterprise Edition and obtaining a commercial license
|
||||
// by contacting <sales@documize.com>.
|
||||
//
|
||||
// https://documize.com
|
||||
|
||||
package org
|
||||
|
||||
import "time"
|
||||
|
||||
// SitemapDocument details a document that can be exposed via Sitemap.
|
||||
type SitemapDocument struct {
|
||||
DocumentID string
|
||||
Document string
|
||||
FolderID string
|
||||
Folder string
|
||||
Revised time.Time
|
||||
}
|
||||
|
||||
// SiteMeta holds information associated with an Organization.
|
||||
type SiteMeta struct {
|
||||
OrgID string `json:"orgId"`
|
||||
Title string `json:"title"`
|
||||
Message string `json:"message"`
|
||||
URL string `json:"url"`
|
||||
AllowAnonymousAccess bool `json:"allowAnonymousAccess"`
|
||||
AuthProvider string `json:"authProvider"`
|
||||
AuthConfig string `json:"authConfig"`
|
||||
Version string `json:"version"`
|
||||
Edition string `json:"edition"`
|
||||
Valid bool `json:"valid"`
|
||||
ConversionEndpoint string `json:"conversionEndpoint"`
|
||||
}
|
116
model/page/page.go
Normal file
116
model/page/page.go
Normal file
|
@ -0,0 +1,116 @@
|
|||
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
||||
//
|
||||
// This software (Documize Community Edition) is licensed under
|
||||
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
||||
//
|
||||
// You can operate outside the AGPL restrictions by purchasing
|
||||
// Documize Enterprise Edition and obtaining a commercial license
|
||||
// by contacting <sales@documize.com>.
|
||||
//
|
||||
// https://documize.com
|
||||
|
||||
package page
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/documize/community/model"
|
||||
)
|
||||
|
||||
// Page represents a section within a document.
|
||||
type Page struct {
|
||||
model.BaseEntity
|
||||
OrgID string `json:"orgId"`
|
||||
DocumentID string `json:"documentId"`
|
||||
UserID string `json:"userId"`
|
||||
ContentType string `json:"contentType"`
|
||||
PageType string `json:"pageType"`
|
||||
BlockID string `json:"blockId"`
|
||||
Level uint64 `json:"level"`
|
||||
Sequence float64 `json:"sequence"`
|
||||
Title string `json:"title"`
|
||||
Body string `json:"body"`
|
||||
Revisions uint64 `json:"revisions"`
|
||||
}
|
||||
|
||||
// SetDefaults ensures no blank values.
|
||||
func (p *Page) SetDefaults() {
|
||||
if len(p.ContentType) == 0 {
|
||||
p.ContentType = "wysiwyg"
|
||||
}
|
||||
|
||||
p.Title = strings.TrimSpace(p.Title)
|
||||
}
|
||||
|
||||
// IsSectionType tells us that page is "words"
|
||||
func (p *Page) IsSectionType() bool {
|
||||
return p.PageType == "section"
|
||||
}
|
||||
|
||||
// IsTabType tells us that page is "SaaS data embed"
|
||||
func (p *Page) IsTabType() bool {
|
||||
return p.PageType == "tab"
|
||||
}
|
||||
|
||||
// Meta holds raw page data that is used to
|
||||
// render the actual page data.
|
||||
type Meta struct {
|
||||
ID uint64 `json:"id"`
|
||||
Created time.Time `json:"created"`
|
||||
Revised time.Time `json:"revised"`
|
||||
OrgID string `json:"orgId"`
|
||||
UserID string `json:"userId"`
|
||||
DocumentID string `json:"documentId"`
|
||||
PageID 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
|
||||
}
|
||||
|
||||
// SetDefaults ensures no blank values.
|
||||
func (p *Meta) SetDefaults() {
|
||||
if len(p.Config) == 0 {
|
||||
p.Config = "{}"
|
||||
}
|
||||
}
|
||||
|
||||
// Revision holds the previous version of a Page.
|
||||
type Revision struct {
|
||||
model.BaseEntity
|
||||
OrgID string `json:"orgId"`
|
||||
DocumentID string `json:"documentId"`
|
||||
PageID string `json:"pageId"`
|
||||
OwnerID string `json:"ownerId"`
|
||||
UserID string `json:"userId"`
|
||||
ContentType string `json:"contentType"`
|
||||
PageType string `json:"pageType"`
|
||||
Title string `json:"title"`
|
||||
Body string `json:"body"`
|
||||
RawBody string `json:"rawBody"`
|
||||
Config string `json:"config"`
|
||||
Email string `json:"email"`
|
||||
Firstname string `json:"firstname"`
|
||||
Lastname string `json:"lastname"`
|
||||
Initials string `json:"initials"`
|
||||
Revisions int `json:"revisions"`
|
||||
}
|
||||
|
||||
// Block represents a section that has been published as a reusable content block.
|
||||
type Block struct {
|
||||
model.BaseEntity
|
||||
OrgID string `json:"orgId"`
|
||||
LabelID string `json:"folderId"`
|
||||
UserID string `json:"userId"`
|
||||
ContentType string `json:"contentType"`
|
||||
PageType string `json:"pageType"`
|
||||
Title string `json:"title"`
|
||||
Body string `json:"body"`
|
||||
Excerpt string `json:"excerpt"`
|
||||
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
|
||||
Used uint64 `json:"used"`
|
||||
Firstname string `json:"firstname"`
|
||||
Lastname string `json:"lastname"`
|
||||
}
|
43
model/search/search.go
Normal file
43
model/search/search.go
Normal file
|
@ -0,0 +1,43 @@
|
|||
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
||||
//
|
||||
// This software (Documize Community Edition) is licensed under
|
||||
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
||||
//
|
||||
// You can operate outside the AGPL restrictions by purchasing
|
||||
// Documize Enterprise Edition and obtaining a commercial license
|
||||
// by contacting <sales@documize.com>.
|
||||
//
|
||||
// https://documize.com
|
||||
|
||||
package search
|
||||
|
||||
import "time"
|
||||
|
||||
// Search holds raw search results.
|
||||
type Search struct {
|
||||
ID string `json:"id"`
|
||||
Created time.Time `json:"created"`
|
||||
Revised time.Time `json:"revised"`
|
||||
OrgID string
|
||||
DocumentID string
|
||||
Level uint64
|
||||
Sequence float64
|
||||
DocumentTitle string
|
||||
Slug string
|
||||
PageTitle string
|
||||
Body string
|
||||
}
|
||||
|
||||
// DocumentSearch represents 'presentable' search results.
|
||||
type DocumentSearch struct {
|
||||
ID string `json:"id"`
|
||||
DocumentID string `json:"documentId"`
|
||||
DocumentTitle string `json:"documentTitle"`
|
||||
DocumentSlug string `json:"documentSlug"`
|
||||
DocumentExcerpt string `json:"documentExcerpt"`
|
||||
Tags string `json:"documentTags"`
|
||||
PageTitle string `json:"pageTitle"`
|
||||
LabelID string `json:"folderId"`
|
||||
LabelName string `json:"folderName"`
|
||||
FolderSlug string `json:"folderSlug"`
|
||||
}
|
54
model/template/template.go
Normal file
54
model/template/template.go
Normal file
|
@ -0,0 +1,54 @@
|
|||
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
||||
//
|
||||
// This software (Documize Community Edition) is licensed under
|
||||
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
||||
//
|
||||
// You can operate outside the AGPL restrictions by purchasing
|
||||
// Documize Enterprise Edition and obtaining a commercial license
|
||||
// by contacting <sales@documize.com>.
|
||||
//
|
||||
// https://documize.com
|
||||
|
||||
package template
|
||||
|
||||
import "time"
|
||||
|
||||
// Template is used to create a new document.
|
||||
// Template can consist of content, attachments and
|
||||
// have associated meta data indentifying author, version
|
||||
// contact details and more.
|
||||
type Template struct {
|
||||
ID string `json:"id"`
|
||||
Title string `json:"title"`
|
||||
Description string `json:"description"`
|
||||
Author string `json:"author"`
|
||||
Type Type `json:"type"`
|
||||
Dated time.Time `json:"dated"`
|
||||
}
|
||||
|
||||
// Type determines who can see a template.
|
||||
type Type int
|
||||
|
||||
const (
|
||||
// TypePublic means anyone can see the template.
|
||||
TypePublic Type = 1
|
||||
// TypePrivate means only the owner can see the template.
|
||||
TypePrivate Type = 2
|
||||
// TypeRestricted means selected users can see the template.
|
||||
TypeRestricted Type = 3
|
||||
)
|
||||
|
||||
// IsPublic means anyone can see the template.
|
||||
func (t *Template) IsPublic() bool {
|
||||
return t.Type == TypePublic
|
||||
}
|
||||
|
||||
// IsPrivate means only the owner can see the template.
|
||||
func (t *Template) IsPrivate() bool {
|
||||
return t.Type == TypePrivate
|
||||
}
|
||||
|
||||
// IsRestricted means selected users can see the template.
|
||||
func (t *Template) IsRestricted() bool {
|
||||
return t.Type == TypeRestricted
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue