package governance import ( "encoding/json" "time" ) type SourceType string const ( SourceTypePP SourceType = "pp" SourceTypeAList SourceType = "alist" SourceTypeDingTalk SourceType = "dingtalk" SourceTypeManual SourceType = "manual" ) func (sourceType SourceType) Valid() bool { switch sourceType { case SourceTypePP, SourceTypeAList, SourceTypeDingTalk, SourceTypeManual: return true default: return false } } type ItemType string const ( ItemTypeDocument ItemType = "document" ItemTypeFile ItemType = "file" ItemTypeLink ItemType = "link" ItemTypeVideo ItemType = "video" ) type Visibility string const ( VisibilityInternal Visibility = "internal" VisibilityExternal Visibility = "external" VisibilityBoth Visibility = "both" VisibilityBlocked Visibility = "blocked" ) type VisibilityOrigin string const ( VisibilityOriginPPPublicTag VisibilityOrigin = "pp_public_tag" VisibilityOriginConfiguredScope VisibilityOrigin = "configured_scope" VisibilityOriginManual VisibilityOrigin = "manual" ) type SourceChange string const ( SourceChangeUnchanged SourceChange = "unchanged" SourceChangeAdded SourceChange = "added" SourceChangeUpdated SourceChange = "updated" SourceChangeDeleted SourceChange = "deleted" SourceChangeUnavailable SourceChange = "unavailable" ) func (state SourceChange) Valid() bool { switch state { case SourceChangeUnchanged, SourceChangeAdded, SourceChangeUpdated, SourceChangeDeleted, SourceChangeUnavailable: return true default: return false } } type ReviewState string const ( ReviewPending ReviewState = "pending" ReviewApproved ReviewState = "approved" ReviewRejected ReviewState = "rejected" ReviewNotRequired ReviewState = "not_required" ) func (state ReviewState) Valid() bool { switch state { case ReviewPending, ReviewApproved, ReviewRejected, ReviewNotRequired: return true default: return false } } type ContentState string const ( ContentUnknown ContentState = "unknown" ContentDownloading ContentState = "downloading" ContentVerified ContentState = "verified" ContentInvalid ContentState = "invalid" ContentOverLimit ContentState = "over_limit" ContentFailed ContentState = "failed" ) func (state ContentState) Valid() bool { switch state { case ContentUnknown, ContentDownloading, ContentVerified, ContentInvalid, ContentOverLimit, ContentFailed: return true default: return false } } type IngestState string const ( IngestPending IngestState = "pending" IngestUploading IngestState = "uploading" IngestUploaded IngestState = "uploaded" IngestFailed IngestState = "failed" ) func (state IngestState) Valid() bool { switch state { case IngestPending, IngestUploading, IngestUploaded, IngestFailed: return true default: return false } } type ProcessingState string const ( ProcessingPending ProcessingState = "pending" ProcessingProcessing ProcessingState = "processing" ProcessingFinalizing ProcessingState = "finalizing" ProcessingCompleted ProcessingState = "completed" ProcessingFailed ProcessingState = "failed" ProcessingStalled ProcessingState = "stalled" // ProcessingCancelled is the operator's "stop trying" decision on a // permanently failing document (e.g. an empty DingTalk export). The // publication leaves the attention lane; source data is untouched. ProcessingCancelled ProcessingState = "cancelled" ) func (state ProcessingState) Valid() bool { switch state { case ProcessingPending, ProcessingProcessing, ProcessingFinalizing, ProcessingCompleted, ProcessingFailed, ProcessingStalled, ProcessingCancelled: return true default: return false } } type RetrievalState string const ( RetrievalUnpublished RetrievalState = "unpublished" RetrievalEnabled RetrievalState = "enabled" RetrievalDisabling RetrievalState = "disabling" RetrievalDisabled RetrievalState = "disabled" RetrievalEnabling RetrievalState = "enabling" RetrievalFailed RetrievalState = "failed" ) func (state RetrievalState) Valid() bool { switch state { case RetrievalUnpublished, RetrievalEnabled, RetrievalDisabling, RetrievalDisabled, RetrievalEnabling, RetrievalFailed: return true default: return false } } type AcceptanceState string const ( AcceptancePending AcceptanceState = "pending" AcceptancePassed AcceptanceState = "passed" AcceptanceFailed AcceptanceState = "failed" AcceptanceManualRequired AcceptanceState = "manual_required" ) func (state AcceptanceState) Valid() bool { switch state { case AcceptancePending, AcceptancePassed, AcceptanceFailed, AcceptanceManualRequired: return true default: return false } } func ValidSHA256(value string) bool { if len(value) != 64 { return false } for _, character := range value { if !((character >= '0' && character <= '9') || (character >= 'a' && character <= 'f')) { return false } } return true } type SourceConnection struct { ID string Type SourceType Name string BaseURL string SecretRef string Enabled bool Schedule json.RawMessage LastHealth json.RawMessage CreatedAt time.Time UpdatedAt time.Time } type SourceItem struct { ID string SourceConnectionID string StableExternalID string CanonicalURIHash string ParentExternalID string NormalizedPath string Title string ItemType ItemType SizeBytes *int64 MIME string Revision string UpdatedAtSource *time.Time Visibility Visibility VisibilityOrigin VisibilityOrigin LastSeenScanID string SourceChange SourceChange AbsenceStreak int CreatedAt time.Time UpdatedAt time.Time } type ContentObject struct { ID string SHA256 string SizeBytes int64 MIME string ValidatedFormat string LocalSpoolRef string State ContentState FirstDiscoveredAt time.Time LastDiscoveredAt time.Time CreatedAt time.Time UpdatedAt time.Time } type SourceItemVersion struct { ID string SourceItemID string Revision string ContentObjectID *string ContentState ContentState DownloadError string RawRecordSummary json.RawMessage SourceUpdatedAt *time.Time CreatedAt time.Time UpdatedAt time.Time } type Publication struct { ID string SourceItemVersionID string TestKBID string KnowledgeID string IngestState IngestState ProcessingState ProcessingState RetrievalState RetrievalState ParserGeneration string IndexGeneration string LastError string RetryCount int CreatedAt time.Time UpdatedAt time.Time } type AcceptanceResult struct { ID string PublicationID string RunID string CheckType string State AcceptanceState PolicyVersion string EvidenceSummary json.RawMessage ObservedAt time.Time CreatedAt time.Time }