Documentation
¶
Overview ¶
Package document defines a document struct and contains logic for working with these documents.
Index ¶
- func GetStringSliceValue(in map[string]any, key string) ([]string, error)
- func GetStringValue(in map[string]any, key string) (string, error)
- type CustomDocTypeField
- type CustomField
- type Document
- func (d *Document) DeleteFileRevision(revisionID string)
- func (doc *Document) ReplaceHeader(baseURL string, isDraft bool, s *gw.Service) error
- func (d *Document) SetFileRevision(revisionID, revisionName string)
- func (d Document) ToAlgoliaObject(removeCustomEditableFields bool) (map[string]any, error)
- func (d Document) ToDatabaseModels(docTypes []*config.DocumentType, products []*config.Product) (models.Document, models.DocumentReviews, error)
- func (d *Document) UpsertCustomField(cf CustomField) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetStringSliceValue ¶
Types ¶
type CustomDocTypeField ¶
type CustomDocTypeField struct {
// DisplayName is the display name of the custom document-type field.
DisplayName string `json:"displayName"`
// Type is the type of the custom document-type field. It is used by the
// frontend to display the proper input component.
// Valid values: "PEOPLE", "STRING".
Type string `json:"type"`
}
type CustomField ¶
type CustomField struct {
// Name is the name of the custom field.
// TODO: consolidate with DisplayName and make corresponding frontend changes
// to support this.
Name string `json:"name"`
// DisplayName is the display name of the custom field.
DisplayName string `json:"displayName"`
// Type is the type of the custom field. It is used by the frontend to display
// the proper input component.
// Valid values: "PEOPLE", "STRING".
Type string `json:"type"`
// Value is the value of the custom field.
Value any
}
type Document ¶
type Document struct {
// ObjectID is the Google Drive file ID for the document.
ObjectID string `json:"objectID,omitempty"`
// Title is the title of the document. It does not contain the document number
// (e.g., "TF-123").
Title string `json:"title,omitempty"`
// DocType is the type of document (e.g., "RFC", "PRD").
DocType string `json:"docType,omitempty"`
// DocNumber is a unique document identifier containing a product/area
// abbreviation and a unique number (e.g., "TF-123").
DocNumber string `json:"docNumber,omitempty"`
// AppCreated should be set to true if the document was created through this
// application, and false if created directly in Google Docs and indexed
// afterwards.
AppCreated bool `json:"appCreated,omitempty"`
// ApprovedBy is a slice of email address strings for users that have approved
// the document.
ApprovedBy []string `json:"approvedBy,omitempty"`
// Approvers is a slice of email address strings for users whose approvals
// are requested for the document.
Approvers []string `json:"approvers,omitempty"`
// ApproverGroups is a slice of email address strings for groups whose
// approvals are requested for the document.
ApproverGroups []string `json:"approverGroups,omitempty"`
// ChangesRequestedBy is a slice of email address strings for users that have
// requested changes for the document.
ChangesRequestedBy []string `json:"changesRequestedBy,omitempty"`
// Contributors is a slice of email address strings for users who have
// contributed to the document.
Contributors []string `json:"contributors,omitempty"`
// Content is the plaintext content of the document.
Content string `json:"content,omitempty"`
// Created is the UTC time of document creation, in a "Jan 2, 2006" string
// format.
Created string `json:"created,omitempty"`
// CreatedTime is the time of document creation, in Unix time.
CreatedTime int64 `json:"createdTime,omitempty"`
// CustomEditableFields are all document-type-specific fields that are
// editable.
CustomEditableFields map[string]CustomDocTypeField `json:"customEditableFields,omitempty"`
// CustomFields are custom fields that contain values too.
// TODO: consolidate with CustomEditableFields.
CustomFields []CustomField `json:"customFields,omitempty"`
// FileRevisions is a map of file revision IDs to custom names.
FileRevisions map[string]string `json:"fileRevisions,omitempty"`
// TODO: LinkedDocs is not used yet.
LinkedDocs []string `json:"linkedDocs,omitempty"`
// Locked is true if the document is locked for editing.
Locked bool `json:"locked,omitempty"`
// MetaTags contains metadata tags that can be used for filtering in Algolia.
MetaTags []string `json:"_tags,omitempty"`
// Created is the time that the document was last modified, in Unix time.
ModifiedTime int64 `json:"modifiedTime,omitempty"`
// Owners is a slice of email address strings for document owners. Hermes
// generally only uses the first element as the document owner, but this is a
// slice for historical reasons as some HashiCorp documents have had multiple
// owners in the past.
Owners []string `json:"owners,omitempty"`
// OwnerPhotos is a slice of URL strings for the profile photos of the
// document owners (in the same order as the Owners field).
OwnerPhotos []string `json:"ownerPhotos,omitempty"`
// Product is the product or area that the document relates to.
Product string `json:"product,omitempty"`
// Summary is a summary of the document.
Summary string `json:"summary,omitempty"`
// Status is the status of the document (e.g., "WIP", "In-Review", "Approved",
// "Obsolete").
Status string `json:"status,omitempty"`
// Tags is a slice of tags to help users discover the document based on their
// interests.
Tags []string `json:"tags,omitempty"`
// ThumbnailLink is a URL string for the document thumbnail image.
ThumbnailLink string `json:"thumbnailLink,omitempty"`
}
func NewFromAlgoliaObject ¶
NewFromAlgoliaObject creates a document from a document Algolia object.
func NewFromDatabaseModel ¶
func NewFromDatabaseModel( model models.Document, reviews models.DocumentReviews, groupReviews models.DocumentGroupReviews, ) (*Document, error)
NewFromDatabaseModel creates a document from a document database model.
func (*Document) DeleteFileRevision ¶
func (*Document) ReplaceHeader ¶
func (*Document) SetFileRevision ¶
func (Document) ToAlgoliaObject ¶
ToAlgoliaObject converts a document to a document Algolia object.
func (Document) ToDatabaseModels ¶
func (d Document) ToDatabaseModels( docTypes []*config.DocumentType, products []*config.Product, ) ( models.Document, models.DocumentReviews, error, )
ToDatabaseModels converts a document to a document and document reviews database records.
func (*Document) UpsertCustomField ¶
func (d *Document) UpsertCustomField(cf CustomField) error
Click to show internal directories.
Click to hide internal directories.