archive

package
v0.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 24, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Package archive 提供 OFD 文档的档案预检、清单和归档准备辅助功能。 它不会修改源 OFD,也不宣称文档符合法律或合规要求。

Index

Constants

View Source
const (
	SchemaVersion = "1"
	ToolVersion   = "0.0.1"

	StatusPassed      = "passed"
	StatusWarning     = "warning"
	StatusFailed      = "failed"
	StatusNotAssessed = "not_assessed"
	StatusUnsupported = "unsupported"
)
View Source
const (
	MatrixSchemaVersion = "1"
	MatrixStandard      = "GB/T 42133-2022"

	MatrixPassed        = "passed"
	MatrixFailed        = "failed"
	MatrixWarning       = "warning"
	MatrixManualReview  = "manual_review"
	MatrixNotApplicable = "not_applicable"
	MatrixNotAssessed   = "not_assessed"
	MatrixUnsupported   = "unsupported"
)

Variables

This section is empty.

Functions

func BuildManifest

func BuildManifest(ctx context.Context, input string, metadata Metadata, profile string, options Options) (Manifest, Report, error)

BuildManifest 创建技术和档案清单,且不会修改输入文件。

func RenderJSON

func RenderJSON(writer io.Writer, report any, pretty bool) error

func RenderMarkdown

func RenderMarkdown(writer io.Writer, report Report) error

RenderMarkdown 将归档预检报告输出为 Markdown。

func RenderMatrixMarkdown

func RenderMatrixMarkdown(writer io.Writer, matrix MatrixReport) error

RenderMatrixMarkdown 将完整矩阵渲染为便于人工审阅的 Markdown。

func RenderMatrixXLSX

func RenderMatrixXLSX(writer io.Writer, matrix MatrixReport) error

RenderMatrixXLSX 将条文矩阵写入 Office Open XML 工作簿。

func RenderText

func RenderText(writer io.Writer, report Report) error

Types

type Attachment

type Attachment struct {
	DocumentIndex int    `json:"document_index"`
	ID            string `json:"id"`
	Name          string `json:"name"`
	Format        string `json:"format,omitempty"`
	SourcePath    string `json:"source_path"`
	ArchivePath   string `json:"archive_path,omitempty"`
	Size          uint64 `json:"size,omitempty"`
	SHA256        string `json:"sha256,omitempty"`
	Exists        bool   `json:"exists"`
	Copied        bool   `json:"copied"`
	Conversion    string `json:"conversion,omitempty"`
}

type FeatureSummary

type FeatureSummary struct {
	Actions    int `json:"actions,omitempty"`
	Audio      int `json:"audio,omitempty"`
	Video      int `json:"video,omitempty"`
	Media      int `json:"media,omitempty"`
	Encryption int `json:"encryption,omitempty"`
	Extensions int `json:"extensions,omitempty"`
}

type FileInfo

type FileInfo struct {
	Path      string `json:"path"`
	Size      int64  `json:"size"`
	SHA256    string `json:"sha256"`
	Algorithm string `json:"algorithm"`
}

type Issue

type Issue struct {
	Severity string `json:"severity"`
	Code     string `json:"code"`
	Message  string `json:"message"`
	Hint     string `json:"hint,omitempty"`
	Path     string `json:"path,omitempty"`
}

func VerifyFixity

func VerifyFixity(root string) ([]Issue, error)

VerifyFixity 根据归档根目录中的普通文件校验 fixity/manifest.sha256。

type Manifest

type Manifest struct {
	SchemaVersion string       `json:"schema_version"`
	Tool          ToolInfo     `json:"tool"`
	CreatedAt     time.Time    `json:"created_at"`
	Source        FileInfo     `json:"source"`
	Metadata      Metadata     `json:"metadata"`
	Profile       string       `json:"profile,omitempty"`
	Report        string       `json:"report"`
	Analysis      string       `json:"analysis"`
	Fixity        string       `json:"fixity"`
	Attachments   []Attachment `json:"attachments"`
	Files         []FileInfo   `json:"files"`
}

type MatrixClause

type MatrixClause struct {
	ID            string   `json:"clause"`
	Title         string   `json:"title"`
	Requirement   string   `json:"requirement"`
	Applicability string   `json:"applicability"`
	Status        string   `json:"status"`
	Assessment    string   `json:"assessment"`
	Evidence      []string `json:"evidence,omitempty"`
	Detector      string   `json:"detector,omitempty"`
	ManualReview  bool     `json:"manual_review,omitempty"`
	Limitations   string   `json:"limitations,omitempty"`
}

MatrixClause 表示条文级符合性矩阵中的一行。

type MatrixReport

type MatrixReport struct {
	SchemaVersion string         `json:"schema_version"`
	Standard      string         `json:"standard"`
	Source        string         `json:"source"`
	GeneratedAt   time.Time      `json:"generated_at"`
	Input         FileInfo       `json:"input"`
	OverallStatus string         `json:"overall_status"`
	Summary       MatrixSummary  `json:"summary"`
	Clauses       []MatrixClause `json:"clauses"`
	Preflight     Report         `json:"preflight"`
}

MatrixReport 包含针对指定整理版条款目录生成的完整矩阵。 它是评估辅助工具,不构成法律或认证结论。

func BuildMatrix

func BuildMatrix(ctx context.Context, input string, options Options) (MatrixReport, error)

BuildMatrix 执行技术预检,并评估指定整理版条款目录中的每一条条款。 没有客观检测器的条款保持为 manual_review,而不是 passed。

type MatrixSummary

type MatrixSummary struct {
	Total         int `json:"total"`
	Passed        int `json:"passed"`
	Failed        int `json:"failed"`
	Warnings      int `json:"warnings"`
	ManualReview  int `json:"manual_review"`
	NotApplicable int `json:"not_applicable"`
	NotAssessed   int `json:"not_assessed"`
	Unsupported   int `json:"unsupported"`
}

type Metadata

type Metadata struct {
	ArchiveCode            string `json:"archive_code" yaml:"archive_code"`
	FondsCode              string `json:"fonds_code" yaml:"fonds_code"`
	RetentionPeriod        string `json:"retention_period" yaml:"retention_period"`
	SecurityClassification string `json:"security_classification" yaml:"security_classification"`
	OpenStatus             string `json:"open_status" yaml:"open_status"`
}

func LoadMetadata

func LoadMetadata(filename string) (Metadata, error)

LoadMetadata 从 JSON、YAML 或类 YAML 文件中加载档案描述元数据。

type Options

type Options struct {
	ValidatorOptions  []validator.Option
	AnalyzerOptions   []analyzer.Option
	FailOnWarning     bool
	HashAlgorithm     string
	MaxAttachmentSize int64
	MaxXMLBytes       int64
}

func DefaultOptions

func DefaultOptions() Options

type Profile

type Profile struct {
	Name           string   `json:"name" yaml:"name"`
	RequiredFields []string `json:"required_fields" yaml:"required_fields"`
}

type Report

type Report struct {
	SchemaVersion   string           `json:"schema_version"`
	Tool            ToolInfo         `json:"tool"`
	Input           FileInfo         `json:"input"`
	Status          string           `json:"status"`
	StartedAt       time.Time        `json:"started_at"`
	DurationMS      int64            `json:"duration_ms"`
	Issues          []Issue          `json:"issues"`
	Features        FeatureSummary   `json:"features"`
	Attachments     []Attachment     `json:"attachments"`
	ValidatorReport validator.Report `json:"validator_report"`
	AnalysisReport  analyzer.Report  `json:"analysis_report"`
}

func Check

func Check(ctx context.Context, input string, options Options) (Report, error)

func Prepare

func Prepare(ctx context.Context, input, output string, metadata Metadata, profile string, options Options) (Report, error)

Prepare 复制源 OFD,并写入自包含的归档目录。

func Verify

func Verify(root string) (Report, error)

type ToolInfo

type ToolInfo struct {
	Name    string `json:"name"`
	Version string `json:"version"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL