Skip to content

features paste and quick workflows

Douwe de Vries edited this page Jul 1, 2026 · 1 revision

Paste and quick workflows

Active contributors: Douwe de Vries

Purpose

Paste and quick workflows handle small direct inputs that do not need the streaming CSV file path. Paste mode analyzes and transforms a pasted sample while preserving its structure where possible. Quick mode generates protected values for a selected data type and strategy without requiring source data from the user.

Directory layout

Path Role
frontend/src/components/PasteDataWorkflowView.tsx Paste sample UI for content entry, format selection, field detection, selection, preview, transform, copy, and report
frontend/src/components/QuickDataTypeWorkflowView.tsx Quick generation UI for data type, strategy, count, output, copy, and report
crates/csv-anonymizer-core/src/direct_input/mod.rs Dispatcher for paste analysis, preview, transform, and quick generation
crates/csv-anonymizer-core/src/direct_input/csv_text.rs CSV text analysis, preview, and transform
crates/csv-anonymizer-core/src/direct_input/documents.rs JSON and YAML scalar field discovery, preview, and transform
crates/csv-anonymizer-core/src/direct_input/xml.rs XML text and attribute discovery, preview, and transform
crates/csv-anonymizer-core/src/direct_input/text.rs Plain text and log token detection, preview, and replacement
crates/csv-anonymizer-core/src/direct_input/quick.rs Quick value generation and quick value anonymization

Key abstractions

Abstraction Source Notes
PasteDataFormat crates/csv-anonymizer-core/src/types.rs and frontend/src/types.ts Supports auto, CSV, JSON, XML, YAML, plain text, and logs.
Field samples crates/csv-anonymizer-core/src/direct_input/shared.rs Normalizes nested or tokenized input into field-like rows for metadata and preview.
Source path documents.rs and xml.rs Connects nested JSON, YAML, or XML values back to their original location.
Direct-input strategies frontend/src/dataOptions.ts Paste supports auto, pseudonymize, tokenize, Smart replacement, mask, redact, and pass through.
Quick generation quick.rs Builds synthetic source values by data type, then transforms them when the selected strategy requires it.
Paste limit direct_input/shared.rs and frontend/src/limits Keeps pasted input bounded at 5 MiB and directs larger CSVs to the file workflow.

How it works

flowchart TD
    PasteUI[PasteDataWorkflowView] --> Analyze[analyze_pasted_data]
    Analyze --> Resolve[Resolve format]
    Resolve --> Csv[CSV text parser]
    Resolve --> Docs[JSON or YAML document parser]
    Resolve --> Xml[XML parser]
    Resolve --> Text[Plain text or logs scanner]
    Csv --> Shared[Field metadata and strategies]
    Docs --> Shared
    Xml --> Shared
    Text --> Shared
    Shared --> Preview[preview_pasted_data]
    Shared --> Transform[anonymize_pasted_data]
    QuickUI[QuickDataTypeWorkflowView] --> Quick[generate_quick_values]
    Quick --> Report[Privacy report]
    Transform --> Report
Loading

Paste workflow

PasteDataWorkflowView owns the paste content, requested format, analysis, selected fields, preview, result, busy state, and copy status. The current frontend selector exposes a smaller explicit subset: Auto detect, CSV text, and JSON. The shared frontend type and Rust core also support XML, YAML, plain text, and logs, and Auto detect can resolve to those formats.

The view calls analyzePasteData when the user clicks Detect Fields or leaves the paste field before analysis exists. The core validates the content size, resolves the format, extracts field samples, builds metadata, and returns detected columns. The UI auto-selects high and medium detector-risk fields and lets the user review strategy controls.

Preview calls previewPasteData, which re-parses the input, prepares selected metadata, prepares Smart replacements when selected, and returns sample transforms plus warnings. Transform calls transformPasteData, reuses preview Smart replacements when available, transforms selected fields, returns the protected output string, and includes a privacy report. The UI can copy the output and renders PrivacyReportSummary.

Direct-input parsers

CSV text uses csv_text.rs, which reuses csv_io sample reading, row counting, and CSV text processing. JSON and YAML use documents.rs, which parses to serde_json::Value, walks scalar values, records stable source paths such as json/k:user/k:email, and writes transformed scalar values back while preserving document shape where possible. XML uses xml.rs, which records text nodes and attributes, then streams events back through quick_xml. Plain text and logs use text.rs, which relies on collect_privacy_spans, skips overlapping matches, and replaces only selected token ranges in the original content.

Shared helpers in direct_input/shared.rs enforce limits, turn field samples into rows, build metadata, apply selection and controls, generate previews, and build privacy reports.

Quick workflow

QuickDataTypeWorkflowView lets users choose a data type, strategy, and quantity from 1 to 1,000. It calls generateQuickValues and then displays newline-separated values with copy support and a privacy report.

quick.rs generates source-like values for each supported data type, builds a selected ColumnMetadata, prepares Smart replacements when the strategy is Smart replacement, and transforms the generated values when the selected strategy requires it. Quick generation supports auto, pseudonymize, tokenize, and Smart replacement. Mask, redact, and pass through are intentionally not exposed in the quick generator strategy list.

Integration points

  • Desktop app hosts the paste and quick mode panels.
  • CSV file workflow should be used for larger CSV inputs and shares strategy, preview, Smart replacement, and report behavior.
  • Local AI Smart replacement supplies the optional provider used by paste and quick Smart replacement.
  • Privacy reporting describes the result report rendered after paste transform and quick generation.

Entry points for modification

  • Change paste UI state or visible steps in frontend/src/components/PasteDataWorkflowView.tsx.
  • Change quick UI state or limits in frontend/src/components/QuickDataTypeWorkflowView.tsx.
  • Add a selectable paste format in the frontend selector and ensure PasteDataFormat and core dispatch already support it.
  • Change format detection in crates/csv-anonymizer-core/src/direct_input/format_detection.rs.
  • Change direct-input limits, metadata shaping, preview, or shared row transforms in crates/csv-anonymizer-core/src/direct_input/shared.rs.
  • Change parser-specific behavior in csv_text.rs, documents.rs, xml.rs, or text.rs.
  • Change quick data generation in crates/csv-anonymizer-core/src/direct_input/quick.rs.

Key source files

File Why it matters
frontend/src/components/PasteDataWorkflowView.tsx Paste workflow UI and state.
frontend/src/components/QuickDataTypeWorkflowView.tsx Quick generation UI and state.
crates/csv-anonymizer-core/src/direct_input/mod.rs Direct-input public dispatcher.
crates/csv-anonymizer-core/src/direct_input/csv_text.rs CSV paste behavior.
crates/csv-anonymizer-core/src/direct_input/documents.rs JSON and YAML behavior.
crates/csv-anonymizer-core/src/direct_input/xml.rs XML behavior.
crates/csv-anonymizer-core/src/direct_input/text.rs Plain text and log behavior.
crates/csv-anonymizer-core/src/direct_input/quick.rs Quick value generation and transformation.

Clone this wiki locally