Skip to content

features postman import

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

Postman import

Active contributors: Douwe de Vries

Purpose

Postman import reads a collection JSON file, extracts runnable requests and runtime variables, and generates the k6 script used later by the runtime. The frontend starts the flow in src/features/import/useCollectionImport.ts; the backend owns parsing in src-tauri/src/importing/parser.rs.

Directory layout

src/features/import/useCollectionImport.ts
src/lib/tauri/dialog.ts
src/lib/tauri/client.ts
src-tauri/src/commands/collection/
src-tauri/src/importing/

Key abstractions

Abstraction File Description
ImportedCollection src-tauri/src/importing/mod.rs Collection info, generated script, and runtime collection
ParsedCollection src-tauri/src/importing/mod.rs Parser output before frontend projection
RuntimeRequest src-tauri/src/importing/mod.rs Request data embedded in the generated k6 script
CollectionInfo src/lib/loadrift/types.ts Frontend summary of collection name, folders, requests, and variables

How it works

sequenceDiagram
    participant UI
    participant Command
    participant Parser
    participant Script
    participant State
    UI->>Command: import_collection_from_file
    Command->>Parser: parse_collection
    Parser-->>Command: ParsedCollection
    Command->>Script: generate_k6_script
    Command->>State: store script + runtime collection
    Command-->>UI: CollectionInfo
Loading

src-tauri/src/commands/collection/mod.rs reads the selected file and calls import_collection_into_state in src-tauri/src/commands/collection/service.rs. The service rejects imports while a test is busy, parses the collection, stores the generated k6 script and RuntimeCollection, clears latest run state, and returns CollectionInfo.

src-tauri/src/importing/parser.rs handles Postman folder recursion, disabled variables, raw or structured URLs, headers, body formats, runtime variable discovery, and stable request IDs based on request fingerprints.

Integration points

Imported requests feed Request selection, Smoke testing, and k6 runtime. The frontend dialog and command call use the bridge described in Command API bridge.

Entry points for modification

Add Postman parsing behavior in src-tauri/src/importing/parser.rs. Update frontend import UX in src/app/components/CollectionImportSection.tsx. Update import state protection in src-tauri/src/commands/collection/service.rs.

Key source files

File Purpose
src/features/import/useCollectionImport.ts Frontend import hook
src-tauri/src/commands/collection/mod.rs Tauri command for file imports
src-tauri/src/commands/collection/service.rs Import state guard and state mutation
src-tauri/src/importing/parser.rs Postman parser
src-tauri/src/importing/script.rs k6 script generator

Clone this wiki locally