From 57c3e24503bfa71c53a95769389b760bd69fad45 Mon Sep 17 00:00:00 2001 From: vshnosngh Date: Mon, 26 Oct 2026 14:55:05 +0530 Subject: [PATCH] feat(khira): simplify general form, reorder forms, and refine application form with image upload --- internal/khira/handlers.go | 30 +- internal/khira/store.go | 22 + web/bulk-api-tester/static/css/style.css | 1583 -- .../static/data/docs_apis.json | 15657 ---------------- web/bulk-api-tester/static/js/app.js | 3508 ---- web/bulk-api-tester/static/js/app.js.bak | 2959 --- web/bulk-api-tester/static/js/app.js.bak2 | 2488 --- .../static/js/app.js.bak_beforev20 | 2967 --- .../static/js/app.js.bak_perf_fix | 2930 --- .../static/js/app.js.bak_scroll_fix | 2771 --- .../static/js/app.js.bak_stats_fix | 2767 --- web/bulk-api-tester/static/js/fix_app.py | 34 - web/bulk-api-tester/static/js/parse_render.py | 22 - web/bulk-api-tester/static/js/render.txt | 24 - web/bulk-api-tester/static/js/renderMain.txt | 107 - .../static/js/renderResponse.txt | 3 - .../static/js/renderSidebar.txt | 88 - web/bulk-api-tester/static/js/rewrite.py | 40 - web/khira/app.js | 152 +- web/khira/styles.css | 14 + 20 files changed, 202 insertions(+), 37964 deletions(-) delete mode 100644 web/bulk-api-tester/static/css/style.css delete mode 100644 web/bulk-api-tester/static/data/docs_apis.json delete mode 100644 web/bulk-api-tester/static/js/app.js delete mode 100644 web/bulk-api-tester/static/js/app.js.bak delete mode 100644 web/bulk-api-tester/static/js/app.js.bak2 delete mode 100644 web/bulk-api-tester/static/js/app.js.bak_beforev20 delete mode 100644 web/bulk-api-tester/static/js/app.js.bak_perf_fix delete mode 100644 web/bulk-api-tester/static/js/app.js.bak_scroll_fix delete mode 100644 web/bulk-api-tester/static/js/app.js.bak_stats_fix delete mode 100644 web/bulk-api-tester/static/js/fix_app.py delete mode 100644 web/bulk-api-tester/static/js/parse_render.py delete mode 100644 web/bulk-api-tester/static/js/render.txt delete mode 100644 web/bulk-api-tester/static/js/renderMain.txt delete mode 100644 web/bulk-api-tester/static/js/renderResponse.txt delete mode 100644 web/bulk-api-tester/static/js/renderSidebar.txt delete mode 100644 web/bulk-api-tester/static/js/rewrite.py diff --git a/internal/khira/handlers.go b/internal/khira/handlers.go index 45fe457..f318dab 100644 --- a/internal/khira/handlers.go +++ b/internal/khira/handlers.go @@ -363,9 +363,12 @@ func (s *Server) handleCreateTicket(w http.ResponseWriter, r *http.Request) { Assistance string `json:"assistance"` AdditionalInfo string `json:"additional_info"` Context string `json:"context"` - AssignedTo string `json:"assigned_to"` - AssigneeUsername string `json:"assignee_username"` - Links []string `json:"links"` + AssignedTo string `json:"assigned_to"` + AssigneeUsername string `json:"assignee_username"` + DeveloperAccount string `json:"developer_account"` + ImageURL string `json:"image_url"` + Attachments []Attachment `json:"attachments"` + Links []string `json:"links"` } if err := json.NewDecoder(r.Body).Decode(&req); err != nil { @@ -395,6 +398,9 @@ func (s *Server) handleCreateTicket(w http.ResponseWriter, r *http.Request) { if assignedTo == "" { assignedTo = strings.TrimSpace(req.AssigneeUsername) } + if assignedTo == "" { + assignedTo = strings.TrimSpace(req.DeveloperAccount) + } appName := strings.TrimSpace(req.AppName) if appName == "" { @@ -443,6 +449,23 @@ func (s *Server) handleCreateTicket(w http.ResponseWriter, r *http.Request) { } } + var atts []Attachment + for _, a := range req.Attachments { + if strings.TrimSpace(a.URL) != "" { + atts = append(atts, a) + } + } + if req.ImageURL != "" { + atts = append(atts, Attachment{ + ID: uuid.New().String(), + Name: "screenshot", + URL: strings.TrimSpace(req.ImageURL), + Type: "image", + UploadedBy: actor.Username, + CreatedAt: time.Now(), + }) + } + ticket := &Ticket{ TicketType: ticketType, GeneralCategory: generalCategory, @@ -460,6 +483,7 @@ func (s *Server) handleCreateTicket(w http.ResponseWriter, r *http.Request) { AdditionalInfo: additionalInfo, AssignedTo: assignedTo, Links: req.Links, + Attachments: atts, } created, err := s.Store.CreateTicket(ticket, actor) diff --git a/internal/khira/store.go b/internal/khira/store.go index 825f0dc..187dc51 100644 --- a/internal/khira/store.go +++ b/internal/khira/store.go @@ -356,6 +356,28 @@ func (s *Store) CreateTicket(t *Ticket, actor *User) (*Ticket, error) { } } + // Add Attachments if present + for _, att := range t.Attachments { + if strings.TrimSpace(att.URL) != "" { + attID := att.ID + if attID == "" { + attID = uuid.New().String() + } + attType := att.Type + if attType == "" { + attType = "image" + } + attName := att.Name + if attName == "" { + attName = "uploaded_image" + } + _, _ = tx.Exec(` + INSERT INTO ticket_attachments (id, ticket_id, name, url, size, type, uploaded_by, created_at) + VALUES ($1, $2, $3, $4, $5, $6, $7, $8) + `, attID, t.ID, attName, att.URL, att.Size, attType, actor.Username, t.CreatedAt) + } + } + if err := tx.Commit(); err != nil { return nil, err } diff --git a/web/bulk-api-tester/static/css/style.css b/web/bulk-api-tester/static/css/style.css deleted file mode 100644 index a02d793..0000000 --- a/web/bulk-api-tester/static/css/style.css +++ /dev/null @@ -1,1583 +0,0 @@ -/* ╔══════════════════════════════════════════════════════════════════╗ - ║ PHOENIX — Enterprise API Suite v8.0 · Deep Cosmos Theme ║ - ╚══════════════════════════════════════════════════════════════════╝ */ -@import url('https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,300;0,14..32,400;0,14..32,500;0,14..32,600;0,14..32,700;1,14..32,400&family=JetBrains+Mono:wght@400;500;600&family=Plus+Jakarta+Sans:wght@500;600;700;800&display=swap'); - -/* ═══════════════════════════════════════════════════════════════════ - DESIGN TOKENS -═══════════════════════════════════════════════════════════════════ */ -:root { - /* ── Background Depth Layers ── */ - --bg-void: #06060b; - --bg-base: #09090f; - --bg-app: #0b0b13; - --bg-elevated: #0e0e18; - --bg-surface: #12121d; - --bg-raised: #161622; - --bg-panel: #1a1a27; - --bg-overlay: #1e1e2d; - --bg-card: #131320; - --bg-input: #0d0d1a; - --bg-sidebar: #09090e; - --bg-header: #0c0c15; - - /* ── Glass Layers ── */ - --glass-1: rgba(255,255,255,0.018); - --glass-2: rgba(255,255,255,0.035); - --glass-3: rgba(255,255,255,0.055); - --glass-4: rgba(255,255,255,0.085); - --glass-5: rgba(255,255,255,0.12); - - /* ── Borders ── */ - --border-1: rgba(255,255,255,0.035); - --border-2: rgba(255,255,255,0.065); - --border-3: rgba(255,255,255,0.10); - --border-4: rgba(255,255,255,0.16); - --border-focus: #FF6C37; - - /* ── Phoenix Brand ── */ - --ph: #FF6C37; - --ph-light: #FF8C5A; - --ph-dim: #cc5225; - --ph-alpha: rgba(255,108,55,0.12); - --ph-glow: rgba(255,108,55,0.28); - --ph-shine: rgba(255,108,55,0.55); - - /* ── Semantic Colors ── */ - --success: #0fcea0; - --success-dim: rgba(15,206,160,0.10); - --success-border: rgba(15,206,160,0.22); - --success-glow: rgba(15,206,160,0.3); - - --danger: #ff4569; - --danger-dim: rgba(255,69,105,0.10); - --danger-border: rgba(255,69,105,0.22); - --danger-glow: rgba(255,69,105,0.3); - - --warning: #f5a623; - --warning-dim: rgba(245,166,35,0.10); - --warning-border: rgba(245,166,35,0.22); - - --info: #5ba0f5; - --info-dim: rgba(91,160,245,0.10); - - /* ── HTTP Method Colors ── */ - --m-get: #0fcea0; - --m-post: #f5a623; - --m-put: #5ba0f5; - --m-delete: #ff4569; - --m-patch: #b685fc; - - /* ── Text Hierarchy ── */ - --text-1: #eaedf5; - --text-2: #8d96aa; - --text-3: #555f73; - --text-4: #323a49; - - /* ── Typography ── */ - --font-ui: 'Inter', system-ui, -apple-system, sans-serif; - --font-display: 'Plus Jakarta Sans', system-ui, sans-serif; - --font-mono: 'JetBrains Mono', 'Cascadia Code', monospace; - - /* ── Radius Scale ── */ - --r-2xs: 3px; - --r-xs: 5px; - --r-sm: 7px; - --r-md: 10px; - --r-lg: 13px; - --r-xl: 17px; - --r-2xl: 22px; - --r-full: 9999px; - - /* ── Shadow Scale ── */ - --sh-xs: 0 1px 3px rgba(0,0,0,0.45); - --sh-sm: 0 2px 8px rgba(0,0,0,0.52); - --sh-md: 0 4px 18px rgba(0,0,0,0.58); - --sh-lg: 0 8px 32px rgba(0,0,0,0.62); - --sh-xl: 0 16px 48px rgba(0,0,0,0.68); - --sh-2xl: 0 28px 70px rgba(0,0,0,0.72); - --sh-ph: 0 4px 24px rgba(255,108,55,0.32), 0 0 8px rgba(255,108,55,0.16); - --sh-success: 0 0 16px rgba(15,206,160,0.32); - --sh-danger: 0 0 16px rgba(255,69,105,0.32); - - /* ── Motion ── */ - --ease-out: cubic-bezier(0.00, 0.00, 0.20, 1.00); - --ease-in: cubic-bezier(0.40, 0.00, 1.00, 1.00); - --ease-inout: cubic-bezier(0.40, 0.00, 0.20, 1.00); - --spring: cubic-bezier(0.34, 1.56, 0.64, 1.00); - --bounce: cubic-bezier(0.34, 1.80, 0.64, 1.00); - - --t-instant: 70ms; - --t-fast: 140ms; - --t-normal: 220ms; - --t-slow: 360ms; - --t-slower: 500ms; -} - -/* ═══════════════════════════════════════════════════════════════════ - RESET & BASE -═══════════════════════════════════════════════════════════════════ */ -*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; outline: none; } - -html { font-size: 13px; } - -body { - height: 100vh; - overflow: hidden; - background: var(--bg-app); - color: var(--text-1); - font-family: var(--font-ui); - font-size: 13px; - line-height: 1.5; - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; - letter-spacing: -0.01em; -} - -/* ═══════════════════════════════════════════════════════════════════ - SCROLLBARS -═══════════════════════════════════════════════════════════════════ */ -::-webkit-scrollbar { width: 4px; height: 4px; } -::-webkit-scrollbar-track { background: transparent; } -::-webkit-scrollbar-thumb { - background: rgba(255,255,255,0.07); - border-radius: var(--r-full); -} -::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.15); } - -/* ═══════════════════════════════════════════════════════════════════ - LOADING OVERLAY (existing #loading-overlay, enhanced) -═══════════════════════════════════════════════════════════════════ */ -#loading-overlay { - background: radial-gradient(ellipse at 50% 35%, #0f0f22 0%, #07070d 65%) !important; -} - -/* ═══════════════════════════════════════════════════════════════════ - WORKSPACE SHELL -═══════════════════════════════════════════════════════════════════ */ -.workspace { - display: flex; - height: 100vh; - width: 100vw; - overflow: hidden; - background: var(--bg-app); - animation: wsFadeIn 0.4s var(--ease-out) both; -} -.resizing * { transition: none !important; } - -/* ═══════════════════════════════════════════════════════════════════ - SIDEBAR -═══════════════════════════════════════════════════════════════════ */ -.sidebar { - width: 270px; - flex-shrink: 0; - display: flex; - flex-direction: column; - background: var(--bg-sidebar); - border-right: 1px solid var(--border-2); - overflow: hidden; - position: relative; -} -.sidebar::after { - content: ''; - position: absolute; - top: 0; left: 0; right: 0; - height: 220px; - background: linear-gradient(180deg, rgba(255,108,55,0.035) 0%, transparent 100%); - pointer-events: none; - z-index: 0; -} - -.sidebar-resize-handle { - width: 1px; - cursor: col-resize; - background: var(--border-2); - flex-shrink: 0; - z-index: 10; - transition: width var(--t-fast) var(--ease-out), - background var(--t-fast) var(--ease-out), - box-shadow var(--t-fast) var(--ease-out); -} -.sidebar-resize-handle:hover, -.sidebar-resize-handle.active { - background: var(--ph); - width: 2px; - box-shadow: 0 0 10px var(--ph-glow); -} - -/* ─── Sidebar Header (Workspace) ── */ -.sidebar-header { - position: relative; - z-index: 1; - padding: 14px 14px 10px; - border-bottom: 1px solid var(--border-1); - flex-shrink: 0; - display: flex; - flex-direction: column; - gap: 8px; -} -.sidebar-ws-label-row { - display: flex; - justify-content: space-between; - align-items: center; -} -.sidebar-ws-label-text { - display: flex; - align-items: center; - gap: 6px; - font-size: 9.5px; - font-weight: 700; - text-transform: uppercase; - letter-spacing: 0.1em; - color: var(--text-3); -} -.sidebar-ws-label-text i { color: var(--ph); font-size: 8px; } - -/* ─── Space Switcher Select ── */ -.space-switcher-select { - -webkit-appearance: none; - -moz-appearance: none; - appearance: none; - width: 100%; - padding: 9px 32px 9px 12px; - background: var(--bg-input); - border: 1px solid var(--border-2); - border-radius: var(--r-md); - color: var(--text-1); - font-size: 13px; - font-weight: 600; - font-family: var(--font-ui); - cursor: pointer; - transition: border-color var(--t-fast), background var(--t-fast), box-shadow var(--t-fast); -} -.space-switcher-select:hover { border-color: var(--border-3); } -.space-switcher-select:focus { - border-color: var(--ph); - box-shadow: 0 0 0 3px var(--ph-alpha); -} -.space-switcher-select option { background: var(--bg-panel); color: var(--text-1); } - -/* ─── Collections Header ── */ -.sidebar-collections-header { - display: flex; - align-items: center; - justify-content: space-between; - padding: 10px 14px 6px; - flex-shrink: 0; - position: relative; - z-index: 1; -} -.sidebar-section-label { - display: flex; - align-items: center; - gap: 6px; - font-size: 9.5px; - font-weight: 700; - text-transform: uppercase; - letter-spacing: 0.09em; - color: var(--text-3); -} - -/* ─── Notifications Banner ── */ -.notifications-banner { - display: flex; - align-items: center; - gap: 8px; - padding: 9px 14px; - background: linear-gradient(90deg, var(--warning-dim), transparent); - border-bottom: 1px solid var(--warning-border); - font-size: 11px; - font-weight: 600; - color: var(--warning); - cursor: pointer; - transition: background var(--t-fast) var(--ease-out); - position: relative; - z-index: 1; -} -.notifications-banner:hover { background: linear-gradient(90deg, rgba(245,166,35,0.18), transparent); } -.notifications-banner i { animation: bellShake 3s ease infinite; } - -/* ─── Search ── */ -.sidebar-search-container { - padding: 0 10px 8px; - flex-shrink: 0; - position: relative; - z-index: 1; -} -.sidebar-search-input { - width: 100%; - padding: 7px 30px 7px 28px; - background: var(--bg-input); - border: 1px solid var(--border-2); - border-radius: var(--r-md); - color: var(--text-1); - font-size: 11.5px; - font-family: var(--font-ui); - transition: border-color var(--t-fast), background var(--t-fast), box-shadow var(--t-fast); -} -.sidebar-search-input::placeholder { color: var(--text-3); } -.sidebar-search-input:focus { - border-color: var(--ph); - background: var(--bg-elevated); - box-shadow: 0 0 0 3px var(--ph-alpha); -} - -/* ─── Collections List ── */ -.history-list { - flex: 1; - overflow-y: auto; - padding: 2px 0; - position: relative; - z-index: 1; -} - -/* ─── Collection Group ── */ -.collection-group { - overflow: hidden; - margin-bottom: 1px; -} -.collection-header { - display: flex; - align-items: center; - padding: 7px 12px; - cursor: pointer; - gap: 7px; - font-weight: 600; - font-size: 12px; - color: var(--text-2); - transition: background var(--t-instant), color var(--t-instant); -} -.collection-header:hover { - background: var(--glass-2); - color: var(--text-1); -} -.collection-items { background: transparent; } - -/* ─── Request Items ── */ -.history-item { - padding: 6px 12px 6px 22px; - cursor: pointer; - display: flex; - align-items: center; - gap: 8px; - border-left: 2px solid transparent; - transition: background var(--t-instant), border-color var(--t-instant); - position: relative; -} -.history-item:hover { background: var(--glass-2); } -.history-item.active-request { - background: linear-gradient(90deg, var(--ph-alpha), transparent 80%); - border-left-color: var(--ph); -} - -/* ─── Method Badges ── */ -.method-badge { - font-size: 9.5px; - font-weight: 700; - min-width: 42px; - font-family: var(--font-ui); - letter-spacing: 0.02em; -} -.m-GET { color: var(--m-get); } -.m-POST { color: var(--m-post); } -.m-PUT { color: var(--m-put); } -.m-DELETE { color: var(--m-delete); } -.m-PATCH { color: var(--m-patch); } - -/* ─── Sidebar Footer ── */ -.sidebar-footer-btn { - margin: 10px; -} - -/* ═══════════════════════════════════════════════════════════════════ - MAIN PANEL -═══════════════════════════════════════════════════════════════════ */ -.main-panel { - flex: 1; - display: flex; - flex-direction: column; - min-width: 0; - overflow: hidden; - background: var(--bg-app); -} - -/* ═══════════════════════════════════════════════════════════════════ - APP HEADER -═══════════════════════════════════════════════════════════════════ */ -.app-header { - height: 54px; - flex-shrink: 0; - display: flex; - align-items: center; - padding: 0 16px; - gap: 10px; - background: var(--bg-header); - border-bottom: 1px solid var(--border-2); - position: relative; -} -.app-header::after { - content: ''; - position: absolute; - bottom: -1px; - left: 0; right: 0; - height: 1px; - background: linear-gradient(90deg, var(--ph-alpha), transparent 50%); - pointer-events: none; -} - -/* ─── Brand ── */ -.brand { - font-family: var(--font-display); - font-weight: 800; - font-size: 15px; - letter-spacing: 0.08em; - display: flex; - align-items: center; - gap: 8px; - color: var(--text-1); - flex-shrink: 0; - cursor: pointer; - text-decoration: none; - transition: opacity var(--t-fast); -} -.brand:hover { opacity: 0.82; } -.brand i { color: var(--ph); filter: drop-shadow(0 0 6px var(--ph-glow)); } - -/* ─── URL Bar ── */ -.input-group { - display: flex; - align-items: center; - background: var(--bg-input); - border: 1px solid var(--border-2); - border-radius: var(--r-lg); - overflow: hidden; - transition: border-color var(--t-fast), box-shadow var(--t-fast); - flex: 1; -} -.input-group:focus-within { - border-color: var(--ph); - box-shadow: 0 0 0 3px var(--ph-alpha); -} - -.method-select { - background: transparent; - border: none; - border-right: 1px solid var(--border-2); - color: var(--text-1); - font-weight: 700; - font-size: 11px; - padding: 0 14px; - min-width: 82px; - height: 38px; - cursor: pointer; - font-family: var(--font-ui); - transition: background var(--t-fast); - letter-spacing: 0.03em; -} -.method-select:hover { background: var(--glass-2); } -.method-select option { background: var(--bg-panel); color: var(--text-1); } - -.url-input { - flex: 1; - background: transparent; - border: none; - color: var(--text-1); - padding: 0 14px; - font-family: var(--font-mono); - font-size: 12px; - height: 38px; - min-width: 0; - letter-spacing: 0; -} -.url-input::placeholder { color: var(--text-3); font-family: var(--font-ui); font-size: 12.5px; letter-spacing: -0.01em; } - -/* ═══════════════════════════════════════════════════════════════════ - BUTTONS -═══════════════════════════════════════════════════════════════════ */ -.btn { - display: inline-flex; - align-items: center; - justify-content: center; - gap: 6px; - height: 36px; - padding: 0 18px; - border: none; - border-radius: var(--r-md); - font-family: var(--font-ui); - font-size: 12px; - font-weight: 600; - cursor: pointer; - transition: background var(--t-fast), transform var(--t-instant), box-shadow var(--t-fast), border-color var(--t-fast), color var(--t-fast); - white-space: nowrap; - flex-shrink: 0; - letter-spacing: 0.02em; - position: relative; - overflow: hidden; -} -.btn:active { transform: scale(0.97); } - -/* Primary */ -.btn-primary { - background: linear-gradient(135deg, var(--ph-light) 0%, var(--ph) 55%, var(--ph-dim) 100%); - color: #fff; - border: 1px solid rgba(255,108,55,0.4); - box-shadow: var(--sh-ph), inset 0 1px 0 rgba(255,255,255,0.12); -} -.btn-primary:hover { - background: linear-gradient(135deg, #ffaa80 0%, var(--ph-light) 55%, var(--ph) 100%); - box-shadow: 0 6px 28px rgba(255,108,55,0.42), 0 0 8px rgba(255,108,55,0.2); - transform: translateY(-1px); -} -.btn-primary:active { transform: scale(0.97) translateY(0); } - -/* Danger */ -.btn-danger { - background: var(--danger-dim); - color: var(--danger); - border: 1px solid var(--danger-border); -} -.btn-danger:hover { background: rgba(255,69,105,0.18); border-color: var(--danger); } - -/* Warning */ -.btn-warning { - background: var(--warning-dim); - color: var(--warning); - border: 1px solid var(--warning-border); -} -.btn-warning:hover { background: rgba(245,166,35,0.18); border-color: var(--warning); } - -/* Ghost */ -.btn-ghost { - background: var(--glass-1); - color: var(--text-2); - border: 1px solid var(--border-2); -} -.btn-ghost:hover { - background: var(--glass-3); - color: var(--text-1); - border-color: var(--border-3); -} - -/* Success */ -.btn-success { - background: var(--success-dim); - color: var(--success); - border: 1px solid var(--success-border); -} -.btn-success:hover { background: rgba(15,206,160,0.18); border-color: var(--success); } - -/* ═══════════════════════════════════════════════════════════════════ - TAB STRIP (Multi-tab) -═══════════════════════════════════════════════════════════════════ */ -.main-tab-strip { - display: flex; - align-items: stretch; - background: var(--bg-sidebar); - border-bottom: 1px solid var(--border-2); - overflow-x: auto; - overflow-y: hidden; - flex-shrink: 0; - height: 38px; - min-height: 38px; -} -.main-tab-strip::-webkit-scrollbar { height: 2px; } -.main-tab-strip::-webkit-scrollbar-thumb { background: var(--border-2); } - -/* Individual tabs — layout handled inline from JS for active state, - but base structure is guaranteed here */ -.main-tab { - display: flex; - align-items: center; - gap: 6px; - padding: 0 12px; - min-width: 120px; - max-width: 190px; - height: 100%; - cursor: pointer; - flex-shrink: 0; - position: relative; - overflow: hidden; - user-select: none; - white-space: nowrap; - border-right: 1px solid var(--border-2); - font-size: 12px; - font-weight: 500; - transition: background 0.12s, color 0.12s; -} - -/* ═══════════════════════════════════════════════════════════════════ - REQUEST META SECTION -═══════════════════════════════════════════════════════════════════ */ -.request-meta-section { - padding: 10px 20px; - border-bottom: 1px solid var(--border-1); - background: var(--bg-header); - display: flex; - flex-direction: column; - gap: 6px; - flex-shrink: 0; -} - -/* ═══════════════════════════════════════════════════════════════════ - PARAM/HEADER TABS -═══════════════════════════════════════════════════════════════════ */ -.tabs { - display: flex; - align-items: center; - border-bottom: 1px solid var(--border-2); - padding: 0 16px; - gap: 0; - background: var(--bg-header); - flex-shrink: 0; - height: 44px; -} -.tab { - padding: 0 16px; - height: 100%; - display: flex; - align-items: center; - color: var(--text-3); - cursor: pointer; - border-bottom: 2px solid transparent; - font-size: 10.5px; - font-weight: 700; - transition: color var(--t-fast), border-color var(--t-fast); - white-space: nowrap; - letter-spacing: 0.06em; - text-transform: uppercase; -} -.tab:hover { color: var(--text-2); } -.tab.active { color: var(--text-1); border-bottom-color: var(--ph); } - -/* ═══════════════════════════════════════════════════════════════════ - CONTENT AREA -═══════════════════════════════════════════════════════════════════ */ -.content-area { - flex: 1; - overflow-y: auto; - padding: 16px 20px; - background: var(--bg-app); -} - -/* ═══════════════════════════════════════════════════════════════════ - DATA TABLE -═══════════════════════════════════════════════════════════════════ */ -.data-table { - width: 100%; - border-collapse: separate; - border-spacing: 0; - border: 1px solid var(--border-2); - border-radius: var(--r-md); - overflow: hidden; - background: var(--bg-elevated); -} -.data-table th { - text-align: left; - padding: 9px 12px; - color: var(--text-3); - font-size: 9.5px; - font-weight: 700; - text-transform: uppercase; - letter-spacing: 0.08em; - background: var(--bg-surface); - border-bottom: 1px solid var(--border-2); - border-right: 1px solid var(--border-1); -} -.data-table th:last-child { border-right: none; } -.data-table td { - padding: 0; - border-bottom: 1px solid var(--border-1); - border-right: 1px solid var(--border-1); - transition: background var(--t-instant); -} -.data-table td:last-child { border-right: none; } -.data-table tr:last-child td { border-bottom: none; } -.data-table tbody tr:hover td { background: var(--glass-1); } - -.cell-input { - width: 100%; - background: transparent; - border: none; - padding: 9px 11px; - color: var(--text-1); - font-family: var(--font-mono); - font-size: 11.5px; - border-radius: 0; - transition: background var(--t-instant); -} -.cell-input:focus { background: rgba(255,108,55,0.025); } -.cell-input::placeholder { color: var(--text-4); font-family: var(--font-ui); } - -.type-select { - background: transparent; - color: var(--text-3); - border: none; - font-size: 11px; - padding: 5px 7px; - cursor: pointer; - font-weight: 600; - font-family: var(--font-ui); - transition: color var(--t-fast), background var(--t-fast); - border-radius: var(--r-xs); - margin: 0 4px; -} -.type-select:hover { color: var(--text-1); background: var(--glass-2); } - -.action-col { width: 38px; text-align: center; } -.action-col button { - display: inline-flex; - align-items: center; - justify-content: center; - width: 26px; height: 26px; - background: transparent; - border: none; - border-radius: var(--r-sm); - color: var(--text-3); - font-size: 15px; - cursor: pointer; - transition: background var(--t-instant), color var(--t-instant), transform var(--t-instant); -} -.action-col button:hover { - background: var(--danger-dim); - color: var(--danger); - transform: scale(1.15); -} - -/* ─── File Trigger ── */ -.file-trigger { - width: 100%; - text-align: left; - padding: 7px 12px; - background: var(--glass-1); - border: 1px dashed var(--border-2); - border-radius: var(--r-xs); - color: var(--text-3); - cursor: pointer; - font-size: 11px; - font-family: var(--font-ui); - transition: border-color var(--t-fast), color var(--t-fast), background var(--t-fast); -} -.file-trigger:hover { - border-color: var(--ph); - color: var(--text-1); - background: var(--ph-alpha); -} - -/* ─── Code Editor ── */ -.code-editor { - width: 100%; - height: 240px; - background: var(--bg-input); - color: var(--text-1); - border: 1px solid var(--border-2); - padding: 16px; - font-family: var(--font-mono); - border-radius: var(--r-md); - resize: vertical; - font-size: 12px; - line-height: 1.7; - transition: border-color var(--t-fast), box-shadow var(--t-fast); -} -.code-editor:focus { - border-color: var(--ph); - box-shadow: 0 0 0 3px var(--ph-alpha); -} -.code-block { - padding: 18px 20px; - margin: 0; - font-family: var(--font-mono); - font-size: 12px; - color: var(--text-1); - white-space: pre-wrap; - word-break: break-all; - background: var(--bg-input); - overflow-y: auto; - flex: 1; - line-height: 1.7; -} - -/* ═══════════════════════════════════════════════════════════════════ - PANEL HEADER / TABS -═══════════════════════════════════════════════════════════════════ */ -.panel-header { - height: 46px; - display: flex; - align-items: center; - border-bottom: 1px solid var(--border-2); - padding: 0 12px; - background: var(--bg-header); - gap: 4px; - flex-shrink: 0; -} -.panel-tab { - padding: 0 14px; - height: 100%; - display: flex; - align-items: center; - gap: 7px; - font-size: 12px; - font-weight: 600; - color: var(--text-3); - cursor: pointer; - border-bottom: 2px solid transparent; - transition: color var(--t-fast), border-color var(--t-fast); - white-space: nowrap; -} -.panel-tab:hover { color: var(--text-2); } -.panel-tab.active { color: var(--text-1); border-bottom-color: var(--ph); } - -/* ─── Status Badge ── */ -.status-badge { - padding: 3px 9px; - border-radius: var(--r-xs); - font-weight: 700; - font-size: 11px; - font-family: var(--font-mono); -} - -/* ─── Response Meta ── */ -.response-meta { - padding: 9px 16px; - border-bottom: 1px solid var(--border-1); - display: flex; - align-items: center; - gap: 12px; - background: rgba(0,0,0,0.18); - font-size: 11px; - flex-shrink: 0; -} - -/* ═══════════════════════════════════════════════════════════════════ - BOTTOM RESULTS PANEL -═══════════════════════════════════════════════════════════════════ */ -.bottom-results-panel { - display: flex; - flex-direction: column; - background: var(--bg-sidebar); - border-top: 1px solid var(--border-2); - flex-shrink: 0; - position: relative; - overflow: hidden; -} - -.bottom-panel-body { - flex: 1; - display: flex; - flex-direction: column; - overflow: hidden; - min-height: 0; -} - -/* ─── Progress Bar ── */ -.progress-track { - height: 2px; - background: var(--glass-2); - flex-shrink: 0; - overflow: hidden; -} -.progress-fill { - height: 100%; - border-radius: var(--r-full); - transition: width 0.3s var(--ease-out), background 0.4s var(--ease-inout); - background: var(--success); - position: relative; - overflow: hidden; -} -.progress-fill::after { - content: ''; - position: absolute; - top: 0; left: -100%; - width: 100%; height: 100%; - background: linear-gradient(90deg, transparent, rgba(255,255,255,0.5), transparent); - animation: shimmer 1.8s ease-in-out infinite; -} - -/* ─── Stat Capsules ── */ -.stat-capsule { - padding: 2px 10px; - border-radius: var(--r-full); - font-size: 10px; - font-weight: 600; - background: var(--glass-2); - border: 1px solid var(--border-2); - color: var(--text-2); - white-space: nowrap; - font-family: var(--font-mono); -} -.stat-capsule.success { background: var(--success-dim); border-color: var(--success-border); color: var(--success); } -.stat-capsule.error { background: var(--danger-dim); border-color: var(--danger-border); color: var(--danger); } - -/* ─── Folder Selector ── */ -.folder-selector-container { - display: flex; - align-items: center; - background: var(--bg-input); - border: 1px solid var(--border-2); - border-radius: var(--r-md); - overflow: hidden; - height: 30px; -} -.folder-path-display { - padding: 0 10px; - font-family: var(--font-mono); - font-size: 10px; - color: var(--text-3); - display: flex; - align-items: center; - gap: 5px; - max-width: 150px; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; -} - -/* ═══════════════════════════════════════════════════════════════════ - RESULTS GRID -═══════════════════════════════════════════════════════════════════ */ -.results-grid { - display: grid !important; - grid-template-columns: repeat(4, 1fr) !important; - grid-auto-rows: max-content !important; - gap: 12px !important; - padding: 14px !important; - overflow-y: auto !important; - overflow-x: hidden !important; - align-content: start !important; - width: 100% !important; - flex: 1; -} -@media (max-width: 1200px) { .results-grid { grid-template-columns: repeat(3, 1fr) !important; } } -@media (max-width: 800px) { .results-grid { grid-template-columns: repeat(2, 1fr) !important; } } - -/* ═══════════════════════════════════════════════════════════════════ - RESULT CARDS -═══════════════════════════════════════════════════════════════════ */ -.result-card { - background: var(--bg-card); - border: 1px solid var(--border-2); - border-radius: var(--r-lg); - overflow: hidden; - display: flex; - flex-direction: column; - cursor: pointer; - transition: transform var(--t-normal) var(--spring), - box-shadow var(--t-normal) var(--ease-out), - border-color var(--t-fast); - position: relative; - animation: cardFadeUp 0.28s var(--ease-out) both; -} -.result-card:hover { - transform: translateY(-5px) scale(1.012); - box-shadow: var(--sh-xl), 0 0 0 1px var(--border-3); - border-color: var(--border-3); - z-index: 2; -} -.result-card.status-success { border-left: 2px solid var(--success); } -.result-card.status-error { border-left: 2px solid var(--danger); } -.result-card.is-image { border-left-width: 1px; border-left-color: var(--border-2); } -.result-card.is-image:hover { border-left-color: var(--border-3); } - -/* Card Preview */ -.card-preview-area { - width: 100%; - height: 150px; - background: linear-gradient(135deg, var(--bg-elevated), var(--bg-surface)); - position: relative; - overflow: hidden; - display: flex; - align-items: center; - justify-content: center; - flex-shrink: 0; -} -.result-card.is-image .card-preview-area { height: auto; min-height: 100px; } - -.card-thumb { - width: 100%; height: 100%; - object-fit: cover; - transition: transform 0.38s var(--ease-out); - display: block; -} -.result-card.is-image .card-thumb { - height: auto; - max-height: 260px; - object-fit: contain; - background: var(--bg-void); -} -.result-card:hover .card-thumb { transform: scale(1.06); } -.result-card.is-image:hover .card-thumb { transform: scale(1.025); } - -/* Fullscreen grid image adjustments */ -.fullscreen-results-grid .result-card.is-image .card-preview-area { height: auto; min-height: 100px; } -.fullscreen-results-grid .result-card.is-image .card-thumb { max-height: 360px; object-fit: contain; } - -/* Card Action Overlay */ -.card-action-overlay { - position: absolute; inset: 0; - background: transparent; - display: flex; - align-items: center; - justify-content: center; - gap: 8px; - opacity: 0; - transition: background var(--t-normal), opacity var(--t-normal); -} -.result-card.is-image .card-preview-area { cursor: zoom-in; } -.result-card.is-image:hover .card-action-overlay { - background: rgba(0,0,0,0.38); - opacity: 1; -} -.result-card:not(.is-image):hover .card-action-overlay { - background: rgba(0,0,0,0.65); - opacity: 1; -} - -.action-overlay-btn { - width: 36px; height: 36px; - border-radius: 50%; - border: 1px solid rgba(255,255,255,0.22); - background: rgba(255,255,255,0.09); - color: #fff; - font-size: 13px; - cursor: pointer; - display: flex; - align-items: center; - justify-content: center; - transition: background var(--t-fast), border-color var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast); - backdrop-filter: blur(8px); - transform: translateY(8px); - box-shadow: 0 2px 8px rgba(0,0,0,0.35); -} -.result-card:hover .action-overlay-btn { transform: translateY(0); } -.action-overlay-btn:hover { - background: var(--ph); - border-color: var(--ph); - transform: scale(1.18) !important; - box-shadow: var(--sh-ph); -} - -/* Card Info Area */ -.card-info-area { - padding: 9px 11px; - display: flex; - flex-direction: column; - gap: 4px; - background: rgba(0,0,0,0.22); - flex-shrink: 0; -} -.card-meta-row { display: flex; align-items: center; gap: 6px; } -.card-index { font-size: 9.5px; color: var(--text-3); font-family: var(--font-mono); } -.card-status-badge { - font-size: 9px; - font-weight: 700; - padding: 2px 7px; - border-radius: var(--r-full); - font-family: var(--font-mono); -} -.card-status-badge.status-success { background: var(--success-dim); color: var(--success); border: 1px solid var(--success-border); } -.card-status-badge.status-error { background: var(--danger-dim); color: var(--danger); border: 1px solid var(--danger-border); } -.card-latency { font-size: 9px; color: var(--text-3); margin-left: auto; font-family: var(--font-mono); } -.card-filename { font-size: 10px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } - -/* Card Tiny Footer (image cards) */ -.card-tiny-footer { - display: flex; - align-items: center; - justify-content: center; - padding: 5px 10px; - font-size: 9.5px; - font-family: var(--font-mono); - color: var(--text-3); - background: rgba(0,0,0,0.25); - flex-shrink: 0; - gap: 8px; -} -.tiny-status { - width: 5px; height: 5px; - border-radius: 50%; - background: var(--success); - flex-shrink: 0; - box-shadow: 0 0 5px var(--success-glow); -} -.tiny-status.err { background: var(--danger); box-shadow: 0 0 5px var(--danger-glow); } - -/* Text fallback */ -.card-text-fallback { - padding: 14px; - display: flex; - flex-direction: column; - align-items: center; - justify-content: center; - text-align: center; - width: 100%; height: 100%; - gap: 7px; -} -.fallback-icon { font-size: 24px; color: var(--text-4); } -.fallback-type { - font-size: 8.5px; - font-weight: 700; - letter-spacing: 0.12em; - text-transform: uppercase; - color: var(--text-3); - font-family: var(--font-mono); -} -.fallback-snippet { - font-size: 9.5px; - color: var(--text-3); - font-family: var(--font-mono); - line-height: 1.5; - overflow: hidden; - display: -webkit-box; - -webkit-line-clamp: 3; - -webkit-box-orient: vertical; -} -.card-icon-fallback { display: flex; flex-direction: column; align-items: center; gap: 6px; color: var(--text-3); font-size: 11px; } - -/* ═══════════════════════════════════════════════════════════════════ - FULLSCREEN RESULTS -═══════════════════════════════════════════════════════════════════ */ -.fullscreen-results-overlay { - position: fixed; inset: 0; - background: var(--bg-app); - z-index: 9000; - display: flex; - flex-direction: column; - animation: overlayFadeIn 0.22s var(--ease-out); -} -.fullscreen-results-header { - display: flex; - justify-content: space-between; - align-items: center; - border-bottom: 1px solid var(--border-2); - padding: 14px 24px; - background: var(--bg-header); - flex-shrink: 0; - gap: 16px; -} -.fullscreen-results-grid { - display: grid !important; - grid-template-columns: repeat(4, 1fr) !important; - grid-auto-rows: max-content !important; - gap: 16px !important; - padding: 20px 24px !important; - overflow-y: auto !important; - overflow-x: hidden !important; - align-content: start !important; - flex: 1; -} -@media (max-width: 1200px) { .fullscreen-results-grid { grid-template-columns: repeat(3, 1fr) !important; } } -@media (max-width: 800px) { .fullscreen-results-grid { grid-template-columns: repeat(2, 1fr) !important; } } -.fullscreen-results-grid .result-card { width: 100%; height: auto; } -.fullscreen-results-grid .card-preview-area { height: 200px; } - -/* ═══════════════════════════════════════════════════════════════════ - PREMIUM MODALS -═══════════════════════════════════════════════════════════════════ */ -.premium-modal-overlay { - position: fixed; inset: 0; - background: rgba(0,0,0,0.78); - backdrop-filter: blur(10px); - -webkit-backdrop-filter: blur(10px); - z-index: 9500; - display: flex; - align-items: center; - justify-content: center; - padding: 20px; - animation: overlayFadeIn 0.18s var(--ease-out); -} -.premium-modal-card { - background: var(--bg-card); - border: 1px solid var(--border-3); - border-radius: var(--r-xl); - box-shadow: var(--sh-2xl), 0 0 0 1px rgba(255,255,255,0.04); - overflow: hidden; - display: flex; - flex-direction: column; - max-height: 86vh; - animation: modalSlideUp 0.28s var(--spring); -} -.premium-modal-header { - display: flex; - align-items: center; - justify-content: space-between; - padding: 18px 22px; - border-bottom: 1px solid var(--border-2); - background: linear-gradient(180deg, var(--bg-raised), var(--bg-card)); - flex-shrink: 0; -} -.premium-modal-header h3 { - font-size: 15px; - font-weight: 700; - display: flex; - align-items: center; - gap: 10px; - color: var(--text-1); - font-family: var(--font-display); -} -.premium-modal-body { padding: 20px 22px; overflow-y: auto; flex: 1; } -.premium-modal-footer { - padding: 14px 22px; - border-top: 1px solid var(--border-2); - display: flex; - justify-content: flex-end; - gap: 10px; - background: rgba(0,0,0,0.12); -} - -/* Notification items inside modal */ -.notif-item { - display: flex; - align-items: center; - justify-content: space-between; - gap: 14px; - padding: 14px 16px; - border-radius: var(--r-lg); - border: 1px solid var(--border-2); - background: var(--glass-1); - transition: background var(--t-fast); -} -.notif-item:hover { background: var(--glass-2); } -.notif-details { display: flex; align-items: flex-start; gap: 12px; } -.notif-icon { font-size: 18px; color: var(--ph-light); margin-top: 2px; } -.notif-title { font-size: 11.5px; font-weight: 500; margin-bottom: 3px; color: var(--text-2); } -.notif-col-name { font-size: 13px; font-weight: 700; color: var(--text-1); } -.notif-col-meta { font-size: 10px; color: var(--text-3); } -.notif-actions { display: flex; gap: 8px; flex-shrink: 0; } - -/* ═══════════════════════════════════════════════════════════════════ - TOAST NOTIFICATIONS -═══════════════════════════════════════════════════════════════════ */ -#toast-container { - position: fixed; - bottom: 24px; - right: 24px; - z-index: 99999; - display: flex; - flex-direction: column; - gap: 8px; - pointer-events: none; -} -#toast-container > div { - display: flex; - align-items: center; - gap: 10px; - padding: 12px 16px; - background: var(--bg-raised) !important; - border: 1px solid var(--border-3) !important; - border-radius: var(--r-lg) !important; - box-shadow: var(--sh-lg), 0 0 0 1px rgba(255,255,255,0.04) !important; - font-size: 13px !important; - font-weight: 500; - color: var(--text-1) !important; - pointer-events: all; - min-width: 260px; - max-width: 380px; - backdrop-filter: blur(16px); - animation: toastSlideIn 0.32s var(--spring) both; - position: relative; - overflow: hidden; - font-family: var(--font-ui) !important; -} -#toast-container > div::before { - content: ''; - position: absolute; - left: 0; top: 0; bottom: 0; - width: 3px; -} -/* Toast type variants set via JS classes */ -.ph-toast-success::before { background: var(--success); box-shadow: 0 0 8px var(--success-glow); } -.ph-toast-error::before { background: var(--danger); box-shadow: 0 0 8px var(--danger-glow); } -.ph-toast-warning::before { background: var(--warning); } -.ph-toast-info::before { background: var(--info); } - -/* ═══════════════════════════════════════════════════════════════════ - EMPTY STATE -═══════════════════════════════════════════════════════════════════ */ -.empty-state { - display: flex; - flex-direction: column; - align-items: center; - justify-content: center; - gap: 14px; - height: 100%; - color: var(--text-3); - text-align: center; - padding: 40px; - min-height: 150px; -} -.empty-state i { font-size: 28px; color: var(--text-4); } - -/* ═══════════════════════════════════════════════════════════════════ - SPACES DASHBOARD -═══════════════════════════════════════════════════════════════════ */ -.spaces-dashboard { - padding: 48px; - height: 100%; - overflow-y: auto; - background: radial-gradient(ellipse at 25% 20%, rgba(255,108,55,0.05) 0%, transparent 55%), - radial-gradient(ellipse at 75% 80%, rgba(91,160,245,0.03) 0%, transparent 55%); -} -.spaces-dash-header { margin-bottom: 36px; } -.spaces-dash-header h2 { - font-size: 26px; - font-weight: 800; - color: var(--text-1); - margin-bottom: 8px; - font-family: var(--font-display); - letter-spacing: -0.025em; -} -.spaces-dash-header p { color: var(--text-3); font-size: 14px; line-height: 1.6; } - -.spaces-grid { - display: grid; - grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); - gap: 16px; -} - -.space-card { - background: var(--bg-card); - border: 1px solid var(--border-2); - border-radius: var(--r-xl); - padding: 22px; - cursor: pointer; - transition: transform var(--t-normal) var(--spring), - box-shadow var(--t-normal) var(--ease-out), - border-color var(--t-fast); - display: flex; - flex-direction: column; - gap: 16px; - position: relative; - overflow: hidden; - animation: cardFadeUp 0.4s var(--ease-out) both; -} -.space-card::before { - content: ''; - position: absolute; inset: 0; - background: linear-gradient(135deg, var(--ph-alpha) 0%, transparent 65%); - opacity: 0; - transition: opacity var(--t-normal); - pointer-events: none; -} -.space-card:hover { - transform: translateY(-4px); - border-color: var(--ph); - box-shadow: var(--sh-xl), 0 0 24px var(--ph-alpha); -} -.space-card:hover::before { opacity: 1; } - -.space-card-icon { - width: 46px; height: 46px; - border-radius: var(--r-md); - display: flex; - align-items: center; - justify-content: center; - font-size: 20px; - background: var(--ph-alpha); - color: var(--ph); - position: relative; - border: 1px solid rgba(255,108,55,0.18); -} -.space-card-notif-badge { - position: absolute; - top: -5px; right: -5px; - background: var(--danger); - color: #fff; - font-size: 8px; - font-weight: 800; - width: 17px; height: 17px; - border-radius: 50%; - display: flex; - align-items: center; - justify-content: center; - border: 2px solid var(--bg-card); - box-shadow: 0 0 8px var(--danger-glow); -} -.space-card-info h3 { - font-size: 15px; - font-weight: 700; - color: var(--text-1); - margin-bottom: 3px; - font-family: var(--font-display); -} -.space-card-info span { font-size: 11px; color: var(--text-3); } -.space-card-actions { display: flex; gap: 6px; margin-top: auto; } - -.create-space-card { - border-style: dashed; - border-color: var(--border-2); - background: transparent; -} -.create-space-card:hover { - border-color: var(--ph); - background: var(--ph-alpha); -} -.create-space-card .space-card-icon { - background: var(--glass-2); - color: var(--text-3); - border-color: var(--border-2); -} -.create-space-card:hover .space-card-icon { - background: var(--ph-alpha); - color: var(--ph); - border-color: rgba(255,108,55,0.25); -} - -/* ═══════════════════════════════════════════════════════════════════ - SELECT GLOBAL STYLES -═══════════════════════════════════════════════════════════════════ */ -select { - background: var(--bg-input); - color: var(--text-1); - border: 1px solid var(--border-2); - transition: border-color var(--t-fast); - font-family: var(--font-ui); -} -select option, -.theme-select option, -.method-select option { - background-color: var(--bg-panel) !important; - color: var(--text-1) !important; -} - -/* ═══════════════════════════════════════════════════════════════════ - WORKSPACE STATES -═══════════════════════════════════════════════════════════════════ */ -.workspace.grid-maximized .response-panel { display: none !important; } - -/* ═══════════════════════════════════════════════════════════════════ - KEYFRAMES -═══════════════════════════════════════════════════════════════════ */ -@keyframes wsFadeIn { - from { opacity: 0; } - to { opacity: 1; } -} - -@keyframes overlayFadeIn { - from { opacity: 0; } - to { opacity: 1; } -} - -@keyframes modalSlideUp { - from { opacity: 0; transform: translateY(22px) scale(0.96); } - to { opacity: 1; transform: translateY(0) scale(1.00); } -} - -@keyframes toastSlideIn { - from { opacity: 0; transform: translateX(22px); } - to { opacity: 1; transform: translateX(0); } -} - -@keyframes toastFadeOut { - to { opacity: 0; transform: translateX(14px); } -} - -@keyframes cardFadeUp { - from { opacity: 0; transform: translateY(12px); } - to { opacity: 1; transform: translateY(0); } -} - -@keyframes shimmer { - 0% { left: -100%; } - 100% { left: 200%; } -} - -@keyframes bellShake { - 0%, 88%, 100% { transform: rotate(0deg); } - 91% { transform: rotate(-9deg); } - 95% { transform: rotate(9deg); } -} - -@keyframes spin { - to { transform: rotate(360deg); } -} - -@keyframes pulse { - 0%, 100% { opacity: 0.5; } - 50% { opacity: 1.0; } -} - -/* ═══════════════════════════════════════════════════════════════════ - IMPORT FROM API DOCUMENTATION MODAL - ═══════════════════════════════════════════════════════════════════ */ -.doc-import-card { - background: var(--bg-card); - border: 1px solid var(--border-2); - border-radius: var(--r-lg); - padding: 14px 16px; - cursor: pointer; - transition: all 0.18s ease; - position: relative; - display: flex; - flex-direction: column; - gap: 8px; -} -.doc-import-card:hover { - border-color: var(--primary); - background: rgba(255, 108, 55, 0.04); - transform: translateY(-1px); - box-shadow: 0 4px 16px rgba(0,0,0,0.3); -} -.doc-import-card.active { - border-color: var(--primary); - box-shadow: 0 0 0 1px var(--primary); -} -.doc-cat-pill { - padding: 4px 11px; - border-radius: 20px; - background: var(--bg-input); - border: 1px solid var(--border-2); - color: var(--text-2); - font-size: 11px; - font-weight: 500; - cursor: pointer; - white-space: nowrap; - transition: all 0.15s ease; -} -.doc-cat-pill:hover { - color: var(--text-1); - border-color: var(--border-3); -} -.doc-cat-pill.active { - background: rgba(255,108,55,0.18); - border-color: var(--primary); - color: var(--primary); - font-weight: 600; -} -.doc-param-chip { - display: inline-flex; - align-items: center; - gap: 4px; - font-size: 10px; - font-family: var(--font-mono); - padding: 2px 7px; - border-radius: 4px; - background: var(--bg-input); - border: 1px solid var(--border-1); - color: var(--text-2); -} -.doc-param-chip.param-file { - background: rgba(84, 160, 255, 0.12); - border-color: rgba(84, 160, 255, 0.3); - color: #70a1ff; -} -.doc-param-chip.param-preset { - background: rgba(46, 213, 115, 0.12); - border-color: rgba(46, 213, 115, 0.3); - color: #2ed573; -} -.doc-sub-route-item { - display: flex; - align-items: center; - justify-content: space-between; - gap: 10px; - padding: 8px 12px; - border-radius: var(--r-md); - background: var(--bg-input); - border: 1px solid var(--border-1); - margin-top: 6px; - transition: all 0.15s; -} -.doc-sub-route-item:hover { - border-color: var(--primary); - background: rgba(255,108,55,0.06); -} - diff --git a/web/bulk-api-tester/static/data/docs_apis.json b/web/bulk-api-tester/static/data/docs_apis.json deleted file mode 100644 index b5af5c1..0000000 --- a/web/bulk-api-tester/static/data/docs_apis.json +++ /dev/null @@ -1,15657 +0,0 @@ -{ - "meta": { - "title": "FastAPI Generative AI Backend API Reference", - "heading": "Edit faces, hair and photos over plain HTTP.", - "baseUrl": "https://apigp0006.creinnovations.in", - "intro": "Complete interactive documentation for all 68 production AI services with full direct URLs, categorized multi-route endpoints, and verified preset codes.", - "authNote": "All inference endpoints authenticate using secretKey form-data parameter (default: 'abcdef')." - }, - "sections": [ - { - "id": "sec-flux-fill", - "key": "flux-fill", - "icon": "\ud83c\udfa8", - "title": "FLUX.1-Fill Inpainting", - "tag": "Flow Matching Inpainting", - "lead": "FLUX.1-Fill-dev 12B flow-matching inpainting models specialized in precision portrait manipulation, multi-preset wardrobe restyling, hair color/style changing, and double exposure with automatic Sapiens segmentation.", - "port": "8003 (Backend: 8013)", - "hue": 268, - "eps": [ - { - "id": "api-stable-diffusion-hair-color-changer-and-hair-style-changer", - "api_key": "Stable_Diffusion_Hair_Color_Changer_And_Hair_Style_Changer", - "api_ip_link": "https://apigp0006.creinnovations.in/apis/flxf/flux_fill/hair_color_changer/", - "title": "Stable_Diffusion_Hair_Color_Changer_And_Hair_Style_Changer", - "method": "MULTI", - "path": "/flux_fill/hair_color_changer/image/", - "full_url": "https://apigp0006.creinnovations.in/apis/flxf/flux_fill/hair_color_changer/hair_color_changer/", - "port": "8000", - "resp": "image/png", - "summary": "Inpaints hair with natural dyes, fantasy colors, and dual-tone highlights.", - "desc": "Uses FLUX.1-Fill-dev inpainting to re-color hair while preserving original texture, strand geometry, and lighting. If mask_image is omitted, Sapiens hair segmentation automatically extracts the hair mask.", - "params": [ - { - "n": "image0", - "al": "image", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Input portrait photograph (JPEG/PNG/WEBP). Recommended max resolution 720-1024px." - }, - { - "n": "colorId", - "al": "effectId", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Hair color preset encoding ID. Must match one of the 36 verified presets." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "'abcdef'", - "ds": "\ud83d\udd11 Authentication: Authentication key. Must be 'abcdef'." - }, - { - "n": "mask_image", - "al": "", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": false, - "df": "None (auto-extracted)", - "ds": "Optional alpha mask for hair region. If omitted, Sapiens automatically extracts the hair region." - } - ], - "chips": [ - "C1", - "C10", - "C11", - "C12", - "C13", - "C14", - "C2", - "C3", - "C4", - "C5", - "C6", - "C7", - "C8", - "C9", - "G1", - "G10", - "G11", - "G2", - "G3", - "G4", - "G5", - "G6", - "G7", - "G8", - "G9", - "HL1", - "HL10", - "HL11", - "HL2", - "HL3", - "HL4", - "HL5", - "HL6", - "HL7", - "HL8", - "HL9" - ], - "subs": [], - "curl": "", - "endpoints": [ - { - "id": "ff-hair-color-changer", - "method": "POST", - "subpath": "hair_color_changer/", - "full_url": "https://apigp0006.creinnovations.in/apis/flxf/flux_fill/hair_color_changer/hair_color_changer/", - "path": "/flux_fill/hair_color_changer/image/", - "title": "FLUX.1-Fill Hair Color Changer (36 Presets)", - "summary": "Inpaints hair with natural dyes, fantasy colors, and dual-tone highlights.", - "desc": "Uses FLUX.1-Fill-dev inpainting to re-color hair while preserving original texture, strand geometry, and lighting. If mask_image is omitted, Sapiens hair segmentation automatically extracts the hair mask.", - "params": [ - { - "n": "image0", - "al": "image", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Input portrait photograph (JPEG/PNG/WEBP). Recommended max resolution 720-1024px." - }, - { - "n": "colorId", - "al": "effectId", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Hair color preset encoding ID. Must match one of the 36 verified presets." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "'abcdef'", - "ds": "\ud83d\udd11 Authentication: Authentication key. Must be 'abcdef'." - }, - { - "n": "mask_image", - "al": "", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": false, - "df": "None (auto-extracted)", - "ds": "Optional alpha mask for hair region. If omitted, Sapiens automatically extracts the hair region." - } - ], - "chips": [ - "C1", - "C10", - "C11", - "C12", - "C13", - "C14", - "C2", - "C3", - "C4", - "C5", - "C6", - "C7", - "C8", - "C9", - "G1", - "G10", - "G11", - "G2", - "G3", - "G4", - "G5", - "G6", - "G7", - "G8", - "G9", - "HL1", - "HL10", - "HL11", - "HL2", - "HL3", - "HL4", - "HL5", - "HL6", - "HL7", - "HL8", - "HL9" - ], - "resp": "image/png", - "subs": [], - "curl": "" - }, - { - "id": "ff-hair-style-changer", - "method": "POST", - "subpath": "hair_style_changer/", - "full_url": "https://apigp0006.creinnovations.in/apis/flxf/flux_fill/hair_color_changer/hair_style_changer/", - "path": "/flux_fill/hair_style_changer/image/", - "title": "FLUX.1-Fill Hair Style Changer (60 Presets)", - "summary": "Restyles hair into 60 verified male and female hairstyles.", - "desc": "Applies prompt encodings to transform short, medium, long, curly, braided, and fade haircuts. Performs Sapiens hair segmentation and inpainting blending.", - "params": [ - { - "n": "image0", - "al": "image", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Input portrait image containing visible hair." - }, - { - "n": "effectId", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Hairstyle preset ID: 'HF1'-'HF30' for female styles, 'HM1'-'HM30' for male styles." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "'abcdef'", - "ds": "\ud83d\udd11 Authentication: Backend authentication secret key." - }, - { - "n": "mask_image", - "al": "", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": false, - "df": "None (auto-extracted)", - "ds": "Optional hair mask override." - } - ], - "chips": [ - "HF1", - "HF10", - "HF11", - "HF12", - "HF13", - "HF14", - "HF15", - "HF16", - "HF17", - "HF18", - "HF19", - "HF2", - "HF20", - "HF21", - "HF22", - "HF23", - "HF24", - "HF25", - "HF26", - "HF27", - "HF28", - "HF29", - "HF3", - "HF30", - "HF4", - "HF5", - "HF6", - "HF7", - "HF8", - "HF9", - "HM1", - "HM10", - "HM11", - "HM12", - "HM13", - "HM14", - "HM15", - "HM16", - "HM17", - "HM18", - "HM19", - "HM2", - "HM20", - "HM21", - "HM22", - "HM23", - "HM24", - "HM25", - "HM26", - "HM27", - "HM28", - "HM29", - "HM3", - "HM30", - "HM4", - "HM5", - "HM6", - "HM7", - "HM8", - "HM9" - ], - "resp": "image/png", - "subs": [], - "curl": "" - } - ] - }, - { - "id": "api-stable-diffusion-eye-changer", - "api_key": "Stable_Diffusion_Eye_Changer", - "api_ip_link": "https://apigp0006.creinnovations.in/apis/flxf/flux_fill/eye_changer/", - "title": "Stable_Diffusion_Eye_Changer", - "method": "POST", - "path": "/flux_fill/eye_changer/image/", - "full_url": "https://apigp0006.creinnovations.in/apis/flxf/flux_fill/eye_changer/image/", - "port": "8000", - "resp": "image/png", - "summary": "Inpaints iris eye colors and stylish eyeglasses/sunglasses onto portraits.", - "desc": "Combines eye iris landmark detection with FLUX.1-Fill inpainting. Supports 5 iris colors, 10 men eyewear styles, and 10 women eyewear styles.", - "params": [ - { - "n": "image0", - "al": "image", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Input face portrait image." - }, - { - "n": "effectId", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Preset ID: 'E1', 'E2', 'E5', 'E6', 'E9' (eye colors), 'GM1'-'GM10' (men glasses), 'GW1'-'GW10' (women glasses)." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "'abcdef'", - "ds": "\ud83d\udd11 Authentication: API secret key ('abcdef')." - }, - { - "n": "eye_mask", - "al": "", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": false, - "df": "None (auto-extracted)", - "ds": "Optional mask of the eye region." - } - ], - "chips": [ - "E1", - "E2", - "E5", - "E6", - "E9", - "GM1", - "GM10", - "GM2", - "GM3", - "GM4", - "GM5", - "GM6", - "GM7", - "GM8", - "GM9", - "GW1", - "GW10", - "GW2", - "GW3", - "GW4", - "GW5", - "GW6", - "GW7", - "GW8", - "GW9" - ], - "subs": [], - "curl": "", - "endpoints": [ - { - "id": "ff-eye-changer", - "method": "POST", - "subpath": "image/", - "full_url": "https://apigp0006.creinnovations.in/apis/flxf/flux_fill/eye_changer/image/", - "path": "/flux_fill/eye_changer/image/", - "title": "FLUX.1-Fill Eye Color & Eyewear Inpainting", - "summary": "Inpaints iris eye colors and stylish eyeglasses/sunglasses onto portraits.", - "desc": "Combines eye iris landmark detection with FLUX.1-Fill inpainting. Supports 5 iris colors, 10 men eyewear styles, and 10 women eyewear styles.", - "params": [ - { - "n": "image0", - "al": "image", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Input face portrait image." - }, - { - "n": "effectId", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Preset ID: 'E1', 'E2', 'E5', 'E6', 'E9' (eye colors), 'GM1'-'GM10' (men glasses), 'GW1'-'GW10' (women glasses)." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "'abcdef'", - "ds": "\ud83d\udd11 Authentication: API secret key ('abcdef')." - }, - { - "n": "eye_mask", - "al": "", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": false, - "df": "None (auto-extracted)", - "ds": "Optional mask of the eye region." - } - ], - "chips": [ - "E1", - "E2", - "E5", - "E6", - "E9", - "GM1", - "GM10", - "GM2", - "GM3", - "GM4", - "GM5", - "GM6", - "GM7", - "GM8", - "GM9", - "GW1", - "GW10", - "GW2", - "GW3", - "GW4", - "GW5", - "GW6", - "GW7", - "GW8", - "GW9" - ], - "resp": "image/png", - "subs": [], - "curl": "" - } - ] - }, - { - "id": "api-flux-couple-dress-changer", - "api_key": "Flux_Couple_Dress_Changer", - "api_ip_link": "https://apigp0006.creinnovations.in/apis/flxf/flux_fill/couple_dress_changer/", - "title": "Flux_Couple_Dress_Changer", - "method": "POST", - "path": "/flux_fill/couple_dress_changer/image/", - "full_url": "https://apigp0006.creinnovations.in/apis/flxf/flux_fill/couple_dress_changer/image/", - "port": "8000", - "resp": "image/png", - "summary": "Coordinated double-wardrobe inpainting for couples across 595 paired presets.", - "desc": "Replaces both partners' clothing simultaneously with color-coordinated wedding, casual, party, traditional, or formal outfits.", - "params": [ - { - "n": "image0", - "al": "image", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Input couple photograph containing two subjects." - }, - { - "n": "effectId", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Couple preset ID (e.g. 'CASUAL_C_1' to '50', 'WED_C_1' to '25', 'INDIAN_C_1' to '50')." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "'abcdef'", - "ds": "\ud83d\udd11 Authentication: API secret key ('abcdef')." - }, - { - "n": "mask_image", - "al": "", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": false, - "df": "None (auto-segmented)", - "ds": "Optional dual clothing mask." - } - ], - "chips": [ - "CASUAL_C_1", - "CASUAL_C_10", - "CASUAL_C_11", - "CASUAL_C_12", - "CASUAL_C_13", - "CASUAL_C_14", - "CASUAL_C_15", - "CASUAL_C_16", - "CASUAL_C_17", - "CASUAL_C_18", - "CASUAL_C_19", - "CASUAL_C_2", - "CASUAL_C_20", - "CASUAL_C_21", - "CASUAL_C_22", - "CASUAL_C_23", - "CASUAL_C_24", - "CASUAL_C_25", - "CASUAL_C_26", - "CASUAL_C_27", - "CASUAL_C_28", - "CASUAL_C_29", - "CASUAL_C_3", - "CASUAL_C_30", - "CASUAL_C_31", - "CASUAL_C_32", - "CASUAL_C_33", - "CASUAL_C_34", - "CASUAL_C_35", - "CASUAL_C_36", - "CASUAL_C_37", - "CASUAL_C_38", - "CASUAL_C_39", - "CASUAL_C_4", - "CASUAL_C_40", - "CASUAL_C_41", - "CASUAL_C_42", - "CASUAL_C_43", - "CASUAL_C_44", - "CASUAL_C_45", - "CASUAL_C_46", - "CASUAL_C_47", - "CASUAL_C_48", - "CASUAL_C_49", - "CASUAL_C_5", - "CASUAL_C_50", - "CASUAL_C_6", - "CASUAL_C_7", - "CASUAL_C_8", - "CASUAL_C_9", - "COTTAGECORE_C_1", - "COTTAGECORE_C_10", - "COTTAGECORE_C_11", - "COTTAGECORE_C_12", - "COTTAGECORE_C_13", - "COTTAGECORE_C_14", - "COTTAGECORE_C_15", - "COTTAGECORE_C_16", - "COTTAGECORE_C_17", - "COTTAGECORE_C_18", - "COTTAGECORE_C_19", - "COTTAGECORE_C_2", - "COTTAGECORE_C_20", - "COTTAGECORE_C_21", - "COTTAGECORE_C_22", - "COTTAGECORE_C_23", - "COTTAGECORE_C_24", - "COTTAGECORE_C_25", - "COTTAGECORE_C_3", - "COTTAGECORE_C_4", - "COTTAGECORE_C_5", - "COTTAGECORE_C_6", - "COTTAGECORE_C_7", - "COTTAGECORE_C_8", - "COTTAGECORE_C_9", - "FEST_C_1", - "FEST_C_10", - "FEST_C_11", - "FEST_C_12", - "FEST_C_13", - "FEST_C_14", - "FEST_C_15", - "FEST_C_16", - "FEST_C_17", - "FEST_C_18", - "FEST_C_19", - "FEST_C_2", - "FEST_C_20", - "FEST_C_21", - "FEST_C_22", - "FEST_C_23", - "FEST_C_24", - "FEST_C_25", - "FEST_C_3", - "FEST_C_4", - "FEST_C_5", - "FEST_C_6", - "FEST_C_7", - "FEST_C_8", - "FEST_C_9", - "INDIAN_C_1", - "INDIAN_C_10", - "INDIAN_C_11", - "INDIAN_C_12", - "INDIAN_C_13", - "INDIAN_C_14", - "INDIAN_C_15", - "INDIAN_C_16", - "INDIAN_C_17", - "INDIAN_C_18", - "INDIAN_C_19", - "INDIAN_C_2", - "INDIAN_C_20", - "INDIAN_C_21", - "INDIAN_C_22", - "INDIAN_C_23", - "INDIAN_C_24", - "INDIAN_C_25", - "INDIAN_C_26", - "INDIAN_C_27", - "INDIAN_C_28", - "INDIAN_C_29", - "INDIAN_C_3", - "INDIAN_C_30", - "INDIAN_C_31", - "INDIAN_C_32", - "INDIAN_C_33", - "INDIAN_C_34", - "INDIAN_C_35", - "INDIAN_C_36", - "INDIAN_C_37", - "INDIAN_C_38", - "INDIAN_C_39", - "INDIAN_C_4", - "INDIAN_C_40", - "INDIAN_C_41", - "INDIAN_C_42", - "INDIAN_C_43", - "INDIAN_C_44", - "INDIAN_C_45", - "INDIAN_C_46", - "INDIAN_C_47", - "INDIAN_C_48", - "INDIAN_C_49", - "INDIAN_C_5", - "INDIAN_C_50", - "INDIAN_C_6", - "INDIAN_C_7", - "INDIAN_C_8", - "INDIAN_C_9", - "KPOP_C_1", - "KPOP_C_10", - "KPOP_C_11", - "KPOP_C_12", - "KPOP_C_13", - "KPOP_C_14", - "KPOP_C_15", - "KPOP_C_16", - "KPOP_C_17", - "KPOP_C_18", - "KPOP_C_19", - "KPOP_C_2", - "KPOP_C_20", - "KPOP_C_21", - "KPOP_C_22", - "KPOP_C_23", - "KPOP_C_24", - "KPOP_C_25", - "KPOP_C_26", - "KPOP_C_27", - "KPOP_C_28", - "KPOP_C_29", - "KPOP_C_3", - "KPOP_C_30", - "KPOP_C_31", - "KPOP_C_32", - "KPOP_C_33", - "KPOP_C_34", - "KPOP_C_35", - "KPOP_C_36", - "KPOP_C_37", - "KPOP_C_38", - "KPOP_C_39", - "KPOP_C_4", - "KPOP_C_40", - "KPOP_C_41", - "KPOP_C_42", - "KPOP_C_43", - "KPOP_C_44", - "KPOP_C_45", - "KPOP_C_46", - "KPOP_C_47", - "KPOP_C_48", - "KPOP_C_49", - "KPOP_C_5", - "KPOP_C_50", - "KPOP_C_6", - "KPOP_C_7", - "KPOP_C_8", - "KPOP_C_9", - "NEOWESTERN_C_1", - "NEOWESTERN_C_10", - "NEOWESTERN_C_11", - "NEOWESTERN_C_12", - "NEOWESTERN_C_13", - "NEOWESTERN_C_14", - "NEOWESTERN_C_15", - "NEOWESTERN_C_16", - "NEOWESTERN_C_17", - "NEOWESTERN_C_18", - "NEOWESTERN_C_19", - "NEOWESTERN_C_2", - "NEOWESTERN_C_20", - "NEOWESTERN_C_21", - "NEOWESTERN_C_22", - "NEOWESTERN_C_23", - "NEOWESTERN_C_24", - "NEOWESTERN_C_25", - "NEOWESTERN_C_3", - "NEOWESTERN_C_4", - "NEOWESTERN_C_5", - "NEOWESTERN_C_6", - "NEOWESTERN_C_7", - "NEOWESTERN_C_8", - "NEOWESTERN_C_9", - "OLDMONEY_C_1", - "OLDMONEY_C_10", - "OLDMONEY_C_11", - "OLDMONEY_C_12", - "OLDMONEY_C_13", - "OLDMONEY_C_14", - "OLDMONEY_C_15", - "OLDMONEY_C_16", - "OLDMONEY_C_17", - "OLDMONEY_C_18", - "OLDMONEY_C_19", - "OLDMONEY_C_2", - "OLDMONEY_C_20", - "OLDMONEY_C_21", - "OLDMONEY_C_22", - "OLDMONEY_C_23", - "OLDMONEY_C_24", - "OLDMONEY_C_25", - "OLDMONEY_C_3", - "OLDMONEY_C_4", - "OLDMONEY_C_5", - "OLDMONEY_C_6", - "OLDMONEY_C_7", - "OLDMONEY_C_8", - "OLDMONEY_C_9", - "PARTY_C_1", - "PARTY_C_10", - "PARTY_C_11", - "PARTY_C_12", - "PARTY_C_13", - "PARTY_C_14", - "PARTY_C_15", - "PARTY_C_16", - "PARTY_C_17", - "PARTY_C_18", - "PARTY_C_19", - "PARTY_C_2", - "PARTY_C_20", - "PARTY_C_21", - "PARTY_C_22", - "PARTY_C_23", - "PARTY_C_24", - "PARTY_C_25", - "PARTY_C_3", - "PARTY_C_4", - "PARTY_C_5", - "PARTY_C_6", - "PARTY_C_7", - "PARTY_C_8", - "PARTY_C_9", - "PROF_C_1", - "PROF_C_10", - "PROF_C_11", - "PROF_C_12", - "PROF_C_13", - "PROF_C_14", - "PROF_C_15", - "PROF_C_16", - "PROF_C_17", - "PROF_C_18", - "PROF_C_19", - "PROF_C_2", - "PROF_C_20", - "PROF_C_21", - "PROF_C_22", - "PROF_C_23", - "PROF_C_24", - "PROF_C_25", - "PROF_C_26", - "PROF_C_27", - "PROF_C_28", - "PROF_C_29", - "PROF_C_3", - "PROF_C_30", - "PROF_C_31", - "PROF_C_32", - "PROF_C_33", - "PROF_C_34", - "PROF_C_35", - "PROF_C_36", - "PROF_C_37", - "PROF_C_38", - "PROF_C_39", - "PROF_C_4", - "PROF_C_40", - "PROF_C_41", - "PROF_C_42", - "PROF_C_43", - "PROF_C_44", - "PROF_C_45", - "PROF_C_46", - "PROF_C_47", - "PROF_C_48", - "PROF_C_49", - "PROF_C_5", - "PROF_C_50", - "PROF_C_6", - "PROF_C_7", - "PROF_C_8", - "PROF_C_9", - "ROM_C_1", - "ROM_C_10", - "ROM_C_11", - "ROM_C_12", - "ROM_C_13", - "ROM_C_14", - "ROM_C_15", - "ROM_C_2", - "ROM_C_3", - "ROM_C_4", - "ROM_C_5", - "ROM_C_6", - "ROM_C_7", - "ROM_C_8", - "ROM_C_9", - "SPORT_C_1", - "SPORT_C_10", - "SPORT_C_11", - "SPORT_C_12", - "SPORT_C_13", - "SPORT_C_14", - "SPORT_C_15", - "SPORT_C_16", - "SPORT_C_17", - "SPORT_C_18", - "SPORT_C_19", - "SPORT_C_2", - "SPORT_C_20", - "SPORT_C_21", - "SPORT_C_22", - "SPORT_C_23", - "SPORT_C_24", - "SPORT_C_25", - "SPORT_C_3", - "SPORT_C_4", - "SPORT_C_5", - "SPORT_C_6", - "SPORT_C_7", - "SPORT_C_8", - "SPORT_C_9", - "TRENDY_C_1", - "TRENDY_C_10", - "TRENDY_C_11", - "TRENDY_C_12", - "TRENDY_C_13", - "TRENDY_C_14", - "TRENDY_C_15", - "TRENDY_C_16", - "TRENDY_C_17", - "TRENDY_C_18", - "TRENDY_C_19", - "TRENDY_C_2", - "TRENDY_C_20", - "TRENDY_C_21", - "TRENDY_C_22", - "TRENDY_C_23", - "TRENDY_C_24", - "TRENDY_C_25", - "TRENDY_C_26", - "TRENDY_C_27", - "TRENDY_C_28", - "TRENDY_C_29", - "TRENDY_C_3", - "TRENDY_C_30", - "TRENDY_C_31", - "TRENDY_C_32", - "TRENDY_C_33", - "TRENDY_C_34", - "TRENDY_C_35", - "TRENDY_C_36", - "TRENDY_C_37", - "TRENDY_C_38", - "TRENDY_C_39", - "TRENDY_C_4", - "TRENDY_C_40", - "TRENDY_C_5", - "TRENDY_C_6", - "TRENDY_C_7", - "TRENDY_C_8", - "TRENDY_C_9", - "TWIN_C_1", - "TWIN_C_10", - "TWIN_C_11", - "TWIN_C_12", - "TWIN_C_13", - "TWIN_C_14", - "TWIN_C_15", - "TWIN_C_16", - "TWIN_C_17", - "TWIN_C_18", - "TWIN_C_19", - "TWIN_C_2", - "TWIN_C_20", - "TWIN_C_21", - "TWIN_C_22", - "TWIN_C_23", - "TWIN_C_24", - "TWIN_C_25", - "TWIN_C_3", - "TWIN_C_4", - "TWIN_C_5", - "TWIN_C_6", - "TWIN_C_7", - "TWIN_C_8", - "TWIN_C_9", - "Trendy_C_1", - "Trendy_C_10", - "Trendy_C_11", - "Trendy_C_12", - "Trendy_C_13", - "Trendy_C_14", - "Trendy_C_15", - "Trendy_C_16", - "Trendy_C_17", - "Trendy_C_18", - "Trendy_C_19", - "Trendy_C_2", - "Trendy_C_20", - "Trendy_C_21", - "Trendy_C_22", - "Trendy_C_23", - "Trendy_C_24", - "Trendy_C_25", - "Trendy_C_26", - "Trendy_C_27", - "Trendy_C_28", - "Trendy_C_29", - "Trendy_C_3", - "Trendy_C_30", - "Trendy_C_31", - "Trendy_C_32", - "Trendy_C_33", - "Trendy_C_34", - "Trendy_C_35", - "Trendy_C_36", - "Trendy_C_37", - "Trendy_C_38", - "Trendy_C_39", - "Trendy_C_4", - "Trendy_C_40", - "Trendy_C_5", - "Trendy_C_6", - "Trendy_C_7", - "Trendy_C_8", - "Trendy_C_9", - "VACATION_C_1", - "VACATION_C_10", - "VACATION_C_11", - "VACATION_C_12", - "VACATION_C_13", - "VACATION_C_14", - "VACATION_C_15", - "VACATION_C_16", - "VACATION_C_17", - "VACATION_C_18", - "VACATION_C_19", - "VACATION_C_2", - "VACATION_C_20", - "VACATION_C_21", - "VACATION_C_22", - "VACATION_C_23", - "VACATION_C_24", - "VACATION_C_25", - "VACATION_C_26", - "VACATION_C_27", - "VACATION_C_28", - "VACATION_C_29", - "VACATION_C_3", - "VACATION_C_30", - "VACATION_C_31", - "VACATION_C_32", - "VACATION_C_33", - "VACATION_C_34", - "VACATION_C_35", - "VACATION_C_36", - "VACATION_C_37", - "VACATION_C_38", - "VACATION_C_39", - "VACATION_C_4", - "VACATION_C_40", - "VACATION_C_41", - "VACATION_C_42", - "VACATION_C_43", - "VACATION_C_44", - "VACATION_C_45", - "VACATION_C_46", - "VACATION_C_47", - "VACATION_C_48", - "VACATION_C_49", - "VACATION_C_5", - "VACATION_C_50", - "VACATION_C_6", - "VACATION_C_7", - "VACATION_C_8", - "VACATION_C_9", - "VIN_C_1", - "VIN_C_10", - "VIN_C_11", - "VIN_C_12", - "VIN_C_13", - "VIN_C_14", - "VIN_C_15", - "VIN_C_16", - "VIN_C_17", - "VIN_C_18", - "VIN_C_19", - "VIN_C_2", - "VIN_C_20", - "VIN_C_21", - "VIN_C_22", - "VIN_C_23", - "VIN_C_24", - "VIN_C_25", - "VIN_C_26", - "VIN_C_27", - "VIN_C_28", - "VIN_C_29", - "VIN_C_3", - "VIN_C_30", - "VIN_C_31", - "VIN_C_32", - "VIN_C_33", - "VIN_C_34", - "VIN_C_35", - "VIN_C_36", - "VIN_C_37", - "VIN_C_38", - "VIN_C_39", - "VIN_C_4", - "VIN_C_40", - "VIN_C_41", - "VIN_C_42", - "VIN_C_43", - "VIN_C_44", - "VIN_C_45", - "VIN_C_46", - "VIN_C_47", - "VIN_C_48", - "VIN_C_49", - "VIN_C_5", - "VIN_C_50", - "VIN_C_6", - "VIN_C_7", - "VIN_C_8", - "VIN_C_9", - "WED_C_1", - "WED_C_10", - "WED_C_11", - "WED_C_12", - "WED_C_13", - "WED_C_14", - "WED_C_15", - "WED_C_16", - "WED_C_17", - "WED_C_18", - "WED_C_19", - "WED_C_2", - "WED_C_20", - "WED_C_21", - "WED_C_22", - "WED_C_23", - "WED_C_24", - "WED_C_25", - "WED_C_3", - "WED_C_4", - "WED_C_5", - "WED_C_6", - "WED_C_7", - "WED_C_8", - "WED_C_9" - ], - "subs": [], - "curl": "", - "endpoints": [ - { - "id": "ff-couple-dress-changer", - "method": "POST", - "subpath": "image/", - "full_url": "https://apigp0006.creinnovations.in/apis/flxf/flux_fill/couple_dress_changer/image/", - "path": "/flux_fill/couple_dress_changer/image/", - "title": "FLUX.1-Fill Couple Outfits & Fashion", - "summary": "Coordinated double-wardrobe inpainting for couples across 595 paired presets.", - "desc": "Replaces both partners' clothing simultaneously with color-coordinated wedding, casual, party, traditional, or formal outfits.", - "params": [ - { - "n": "image0", - "al": "image", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Input couple photograph containing two subjects." - }, - { - "n": "effectId", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Couple preset ID (e.g. 'CASUAL_C_1' to '50', 'WED_C_1' to '25', 'INDIAN_C_1' to '50')." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "'abcdef'", - "ds": "\ud83d\udd11 Authentication: API secret key ('abcdef')." - }, - { - "n": "mask_image", - "al": "", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": false, - "df": "None (auto-segmented)", - "ds": "Optional dual clothing mask." - } - ], - "chips": [ - "CASUAL_C_1", - "CASUAL_C_10", - "CASUAL_C_11", - "CASUAL_C_12", - "CASUAL_C_13", - "CASUAL_C_14", - "CASUAL_C_15", - "CASUAL_C_16", - "CASUAL_C_17", - "CASUAL_C_18", - "CASUAL_C_19", - "CASUAL_C_2", - "CASUAL_C_20", - "CASUAL_C_21", - "CASUAL_C_22", - "CASUAL_C_23", - "CASUAL_C_24", - "CASUAL_C_25", - "CASUAL_C_26", - "CASUAL_C_27", - "CASUAL_C_28", - "CASUAL_C_29", - "CASUAL_C_3", - "CASUAL_C_30", - "CASUAL_C_31", - "CASUAL_C_32", - "CASUAL_C_33", - "CASUAL_C_34", - "CASUAL_C_35", - "CASUAL_C_36", - "CASUAL_C_37", - "CASUAL_C_38", - "CASUAL_C_39", - "CASUAL_C_4", - "CASUAL_C_40", - "CASUAL_C_41", - "CASUAL_C_42", - "CASUAL_C_43", - "CASUAL_C_44", - "CASUAL_C_45", - "CASUAL_C_46", - "CASUAL_C_47", - "CASUAL_C_48", - "CASUAL_C_49", - "CASUAL_C_5", - "CASUAL_C_50", - "CASUAL_C_6", - "CASUAL_C_7", - "CASUAL_C_8", - "CASUAL_C_9", - "COTTAGECORE_C_1", - "COTTAGECORE_C_10", - "COTTAGECORE_C_11", - "COTTAGECORE_C_12", - "COTTAGECORE_C_13", - "COTTAGECORE_C_14", - "COTTAGECORE_C_15", - "COTTAGECORE_C_16", - "COTTAGECORE_C_17", - "COTTAGECORE_C_18", - "COTTAGECORE_C_19", - "COTTAGECORE_C_2", - "COTTAGECORE_C_20", - "COTTAGECORE_C_21", - "COTTAGECORE_C_22", - "COTTAGECORE_C_23", - "COTTAGECORE_C_24", - "COTTAGECORE_C_25", - "COTTAGECORE_C_3", - "COTTAGECORE_C_4", - "COTTAGECORE_C_5", - "COTTAGECORE_C_6", - "COTTAGECORE_C_7", - "COTTAGECORE_C_8", - "COTTAGECORE_C_9", - "FEST_C_1", - "FEST_C_10", - "FEST_C_11", - "FEST_C_12", - "FEST_C_13", - "FEST_C_14", - "FEST_C_15", - "FEST_C_16", - "FEST_C_17", - "FEST_C_18", - "FEST_C_19", - "FEST_C_2", - "FEST_C_20", - "FEST_C_21", - "FEST_C_22", - "FEST_C_23", - "FEST_C_24", - "FEST_C_25", - "FEST_C_3", - "FEST_C_4", - "FEST_C_5", - "FEST_C_6", - "FEST_C_7", - "FEST_C_8", - "FEST_C_9", - "INDIAN_C_1", - "INDIAN_C_10", - "INDIAN_C_11", - "INDIAN_C_12", - "INDIAN_C_13", - "INDIAN_C_14", - "INDIAN_C_15", - "INDIAN_C_16", - "INDIAN_C_17", - "INDIAN_C_18", - "INDIAN_C_19", - "INDIAN_C_2", - "INDIAN_C_20", - "INDIAN_C_21", - "INDIAN_C_22", - "INDIAN_C_23", - "INDIAN_C_24", - "INDIAN_C_25", - "INDIAN_C_26", - "INDIAN_C_27", - "INDIAN_C_28", - "INDIAN_C_29", - "INDIAN_C_3", - "INDIAN_C_30", - "INDIAN_C_31", - "INDIAN_C_32", - "INDIAN_C_33", - "INDIAN_C_34", - "INDIAN_C_35", - "INDIAN_C_36", - "INDIAN_C_37", - "INDIAN_C_38", - "INDIAN_C_39", - "INDIAN_C_4", - "INDIAN_C_40", - "INDIAN_C_41", - "INDIAN_C_42", - "INDIAN_C_43", - "INDIAN_C_44", - "INDIAN_C_45", - "INDIAN_C_46", - "INDIAN_C_47", - "INDIAN_C_48", - "INDIAN_C_49", - "INDIAN_C_5", - "INDIAN_C_50", - "INDIAN_C_6", - "INDIAN_C_7", - "INDIAN_C_8", - "INDIAN_C_9", - "KPOP_C_1", - "KPOP_C_10", - "KPOP_C_11", - "KPOP_C_12", - "KPOP_C_13", - "KPOP_C_14", - "KPOP_C_15", - "KPOP_C_16", - "KPOP_C_17", - "KPOP_C_18", - "KPOP_C_19", - "KPOP_C_2", - "KPOP_C_20", - "KPOP_C_21", - "KPOP_C_22", - "KPOP_C_23", - "KPOP_C_24", - "KPOP_C_25", - "KPOP_C_26", - "KPOP_C_27", - "KPOP_C_28", - "KPOP_C_29", - "KPOP_C_3", - "KPOP_C_30", - "KPOP_C_31", - "KPOP_C_32", - "KPOP_C_33", - "KPOP_C_34", - "KPOP_C_35", - "KPOP_C_36", - "KPOP_C_37", - "KPOP_C_38", - "KPOP_C_39", - "KPOP_C_4", - "KPOP_C_40", - "KPOP_C_41", - "KPOP_C_42", - "KPOP_C_43", - "KPOP_C_44", - "KPOP_C_45", - "KPOP_C_46", - "KPOP_C_47", - "KPOP_C_48", - "KPOP_C_49", - "KPOP_C_5", - "KPOP_C_50", - "KPOP_C_6", - "KPOP_C_7", - "KPOP_C_8", - "KPOP_C_9", - "NEOWESTERN_C_1", - "NEOWESTERN_C_10", - "NEOWESTERN_C_11", - "NEOWESTERN_C_12", - "NEOWESTERN_C_13", - "NEOWESTERN_C_14", - "NEOWESTERN_C_15", - "NEOWESTERN_C_16", - "NEOWESTERN_C_17", - "NEOWESTERN_C_18", - "NEOWESTERN_C_19", - "NEOWESTERN_C_2", - "NEOWESTERN_C_20", - "NEOWESTERN_C_21", - "NEOWESTERN_C_22", - "NEOWESTERN_C_23", - "NEOWESTERN_C_24", - "NEOWESTERN_C_25", - "NEOWESTERN_C_3", - "NEOWESTERN_C_4", - "NEOWESTERN_C_5", - "NEOWESTERN_C_6", - "NEOWESTERN_C_7", - "NEOWESTERN_C_8", - "NEOWESTERN_C_9", - "OLDMONEY_C_1", - "OLDMONEY_C_10", - "OLDMONEY_C_11", - "OLDMONEY_C_12", - "OLDMONEY_C_13", - "OLDMONEY_C_14", - "OLDMONEY_C_15", - "OLDMONEY_C_16", - "OLDMONEY_C_17", - "OLDMONEY_C_18", - "OLDMONEY_C_19", - "OLDMONEY_C_2", - "OLDMONEY_C_20", - "OLDMONEY_C_21", - "OLDMONEY_C_22", - "OLDMONEY_C_23", - "OLDMONEY_C_24", - "OLDMONEY_C_25", - "OLDMONEY_C_3", - "OLDMONEY_C_4", - "OLDMONEY_C_5", - "OLDMONEY_C_6", - "OLDMONEY_C_7", - "OLDMONEY_C_8", - "OLDMONEY_C_9", - "PARTY_C_1", - "PARTY_C_10", - "PARTY_C_11", - "PARTY_C_12", - "PARTY_C_13", - "PARTY_C_14", - "PARTY_C_15", - "PARTY_C_16", - "PARTY_C_17", - "PARTY_C_18", - "PARTY_C_19", - "PARTY_C_2", - "PARTY_C_20", - "PARTY_C_21", - "PARTY_C_22", - "PARTY_C_23", - "PARTY_C_24", - "PARTY_C_25", - "PARTY_C_3", - "PARTY_C_4", - "PARTY_C_5", - "PARTY_C_6", - "PARTY_C_7", - "PARTY_C_8", - "PARTY_C_9", - "PROF_C_1", - "PROF_C_10", - "PROF_C_11", - "PROF_C_12", - "PROF_C_13", - "PROF_C_14", - "PROF_C_15", - "PROF_C_16", - "PROF_C_17", - "PROF_C_18", - "PROF_C_19", - "PROF_C_2", - "PROF_C_20", - "PROF_C_21", - "PROF_C_22", - "PROF_C_23", - "PROF_C_24", - "PROF_C_25", - "PROF_C_26", - "PROF_C_27", - "PROF_C_28", - "PROF_C_29", - "PROF_C_3", - "PROF_C_30", - "PROF_C_31", - "PROF_C_32", - "PROF_C_33", - "PROF_C_34", - "PROF_C_35", - "PROF_C_36", - "PROF_C_37", - "PROF_C_38", - "PROF_C_39", - "PROF_C_4", - "PROF_C_40", - "PROF_C_41", - "PROF_C_42", - "PROF_C_43", - "PROF_C_44", - "PROF_C_45", - "PROF_C_46", - "PROF_C_47", - "PROF_C_48", - "PROF_C_49", - "PROF_C_5", - "PROF_C_50", - "PROF_C_6", - "PROF_C_7", - "PROF_C_8", - "PROF_C_9", - "ROM_C_1", - "ROM_C_10", - "ROM_C_11", - "ROM_C_12", - "ROM_C_13", - "ROM_C_14", - "ROM_C_15", - "ROM_C_2", - "ROM_C_3", - "ROM_C_4", - "ROM_C_5", - "ROM_C_6", - "ROM_C_7", - "ROM_C_8", - "ROM_C_9", - "SPORT_C_1", - "SPORT_C_10", - "SPORT_C_11", - "SPORT_C_12", - "SPORT_C_13", - "SPORT_C_14", - "SPORT_C_15", - "SPORT_C_16", - "SPORT_C_17", - "SPORT_C_18", - "SPORT_C_19", - "SPORT_C_2", - "SPORT_C_20", - "SPORT_C_21", - "SPORT_C_22", - "SPORT_C_23", - "SPORT_C_24", - "SPORT_C_25", - "SPORT_C_3", - "SPORT_C_4", - "SPORT_C_5", - "SPORT_C_6", - "SPORT_C_7", - "SPORT_C_8", - "SPORT_C_9", - "TRENDY_C_1", - "TRENDY_C_10", - "TRENDY_C_11", - "TRENDY_C_12", - "TRENDY_C_13", - "TRENDY_C_14", - "TRENDY_C_15", - "TRENDY_C_16", - "TRENDY_C_17", - "TRENDY_C_18", - "TRENDY_C_19", - "TRENDY_C_2", - "TRENDY_C_20", - "TRENDY_C_21", - "TRENDY_C_22", - "TRENDY_C_23", - "TRENDY_C_24", - "TRENDY_C_25", - "TRENDY_C_26", - "TRENDY_C_27", - "TRENDY_C_28", - "TRENDY_C_29", - "TRENDY_C_3", - "TRENDY_C_30", - "TRENDY_C_31", - "TRENDY_C_32", - "TRENDY_C_33", - "TRENDY_C_34", - "TRENDY_C_35", - "TRENDY_C_36", - "TRENDY_C_37", - "TRENDY_C_38", - "TRENDY_C_39", - "TRENDY_C_4", - "TRENDY_C_40", - "TRENDY_C_5", - "TRENDY_C_6", - "TRENDY_C_7", - "TRENDY_C_8", - "TRENDY_C_9", - "TWIN_C_1", - "TWIN_C_10", - "TWIN_C_11", - "TWIN_C_12", - "TWIN_C_13", - "TWIN_C_14", - "TWIN_C_15", - "TWIN_C_16", - "TWIN_C_17", - "TWIN_C_18", - "TWIN_C_19", - "TWIN_C_2", - "TWIN_C_20", - "TWIN_C_21", - "TWIN_C_22", - "TWIN_C_23", - "TWIN_C_24", - "TWIN_C_25", - "TWIN_C_3", - "TWIN_C_4", - "TWIN_C_5", - "TWIN_C_6", - "TWIN_C_7", - "TWIN_C_8", - "TWIN_C_9", - "Trendy_C_1", - "Trendy_C_10", - "Trendy_C_11", - "Trendy_C_12", - "Trendy_C_13", - "Trendy_C_14", - "Trendy_C_15", - "Trendy_C_16", - "Trendy_C_17", - "Trendy_C_18", - "Trendy_C_19", - "Trendy_C_2", - "Trendy_C_20", - "Trendy_C_21", - "Trendy_C_22", - "Trendy_C_23", - "Trendy_C_24", - "Trendy_C_25", - "Trendy_C_26", - "Trendy_C_27", - "Trendy_C_28", - "Trendy_C_29", - "Trendy_C_3", - "Trendy_C_30", - "Trendy_C_31", - "Trendy_C_32", - "Trendy_C_33", - "Trendy_C_34", - "Trendy_C_35", - "Trendy_C_36", - "Trendy_C_37", - "Trendy_C_38", - "Trendy_C_39", - "Trendy_C_4", - "Trendy_C_40", - "Trendy_C_5", - "Trendy_C_6", - "Trendy_C_7", - "Trendy_C_8", - "Trendy_C_9", - "VACATION_C_1", - "VACATION_C_10", - "VACATION_C_11", - "VACATION_C_12", - "VACATION_C_13", - "VACATION_C_14", - "VACATION_C_15", - "VACATION_C_16", - "VACATION_C_17", - "VACATION_C_18", - "VACATION_C_19", - "VACATION_C_2", - "VACATION_C_20", - "VACATION_C_21", - "VACATION_C_22", - "VACATION_C_23", - "VACATION_C_24", - "VACATION_C_25", - "VACATION_C_26", - "VACATION_C_27", - "VACATION_C_28", - "VACATION_C_29", - "VACATION_C_3", - "VACATION_C_30", - "VACATION_C_31", - "VACATION_C_32", - "VACATION_C_33", - "VACATION_C_34", - "VACATION_C_35", - "VACATION_C_36", - "VACATION_C_37", - "VACATION_C_38", - "VACATION_C_39", - "VACATION_C_4", - "VACATION_C_40", - "VACATION_C_41", - "VACATION_C_42", - "VACATION_C_43", - "VACATION_C_44", - "VACATION_C_45", - "VACATION_C_46", - "VACATION_C_47", - "VACATION_C_48", - "VACATION_C_49", - "VACATION_C_5", - "VACATION_C_50", - "VACATION_C_6", - "VACATION_C_7", - "VACATION_C_8", - "VACATION_C_9", - "VIN_C_1", - "VIN_C_10", - "VIN_C_11", - "VIN_C_12", - "VIN_C_13", - "VIN_C_14", - "VIN_C_15", - "VIN_C_16", - "VIN_C_17", - "VIN_C_18", - "VIN_C_19", - "VIN_C_2", - "VIN_C_20", - "VIN_C_21", - "VIN_C_22", - "VIN_C_23", - "VIN_C_24", - "VIN_C_25", - "VIN_C_26", - "VIN_C_27", - "VIN_C_28", - "VIN_C_29", - "VIN_C_3", - "VIN_C_30", - "VIN_C_31", - "VIN_C_32", - "VIN_C_33", - "VIN_C_34", - "VIN_C_35", - "VIN_C_36", - "VIN_C_37", - "VIN_C_38", - "VIN_C_39", - "VIN_C_4", - "VIN_C_40", - "VIN_C_41", - "VIN_C_42", - "VIN_C_43", - "VIN_C_44", - "VIN_C_45", - "VIN_C_46", - "VIN_C_47", - "VIN_C_48", - "VIN_C_49", - "VIN_C_5", - "VIN_C_50", - "VIN_C_6", - "VIN_C_7", - "VIN_C_8", - "VIN_C_9", - "WED_C_1", - "WED_C_10", - "WED_C_11", - "WED_C_12", - "WED_C_13", - "WED_C_14", - "WED_C_15", - "WED_C_16", - "WED_C_17", - "WED_C_18", - "WED_C_19", - "WED_C_2", - "WED_C_20", - "WED_C_21", - "WED_C_22", - "WED_C_23", - "WED_C_24", - "WED_C_25", - "WED_C_3", - "WED_C_4", - "WED_C_5", - "WED_C_6", - "WED_C_7", - "WED_C_8", - "WED_C_9" - ], - "resp": "image/png", - "subs": [], - "curl": "" - } - ] - }, - { - "id": "api-flux-dress-changer", - "api_key": "Flux_Dress_Changer", - "api_ip_link": "https://apigp0006.creinnovations.in/apis/flxf/flux_fill/dress_changer/", - "title": "Flux_Dress_Changer", - "method": "POST", - "path": "/flux_fill/dress_changer/image/", - "full_url": "https://apigp0006.creinnovations.in/apis/flxf/flux_fill/dress_changer/image/", - "port": "8000", - "resp": "image/png", - "summary": "Full-body wardrobe inpainting across 1,676 verified outfits in 16 categories.", - "desc": "Applies high-fashion dresses, traditional attire, business suits, and streetwear onto solo portraits. Uses Sapiens 28-class body parsing to isolate clothing while preserving head, arms, legs, and background.", - "params": [ - { - "n": "image0", - "al": "image", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Input full-body or half-body photograph." - }, - { - "n": "effectId", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Outfit encoding ID. Follows pattern '{THEME}_{GENDER}_{INDEX}' (e.g. 'CASUAL_F_10', 'INDIAN_M_5') or named presets (e.g. 'black_dress', 'formal_suit')." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "'abcdef'", - "ds": "\ud83d\udd11 Authentication: API authentication key ('abcdef')." - }, - { - "n": "mask_image", - "al": "", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": false, - "df": "None (auto-segmented via Sapiens)", - "ds": "Optional clothing mask." - } - ], - "chips": [ - "CASUAL_C_1", - "CASUAL_C_10", - "CASUAL_C_11", - "CASUAL_C_12", - "CASUAL_C_13", - "CASUAL_C_14", - "CASUAL_C_15", - "CASUAL_C_16", - "CASUAL_C_17", - "CASUAL_C_18", - "CASUAL_C_19", - "CASUAL_C_2", - "CASUAL_C_20", - "CASUAL_C_21", - "CASUAL_C_22", - "CASUAL_C_23", - "CASUAL_C_24", - "CASUAL_C_25", - "CASUAL_C_26", - "CASUAL_C_27", - "CASUAL_C_28", - "CASUAL_C_29", - "CASUAL_C_3", - "CASUAL_C_30", - "CASUAL_C_31", - "CASUAL_C_32", - "CASUAL_C_33", - "CASUAL_C_34", - "CASUAL_C_35", - "CASUAL_C_36", - "CASUAL_C_37", - "CASUAL_C_38", - "CASUAL_C_39", - "CASUAL_C_4", - "CASUAL_C_40", - "CASUAL_C_41", - "CASUAL_C_42", - "CASUAL_C_43", - "CASUAL_C_44", - "CASUAL_C_45", - "CASUAL_C_46", - "CASUAL_C_47", - "CASUAL_C_48", - "CASUAL_C_49", - "CASUAL_C_5", - "CASUAL_C_50", - "CASUAL_C_6", - "CASUAL_C_7", - "CASUAL_C_8", - "CASUAL_C_9", - "CASUAL_F_1", - "CASUAL_F_10", - "CASUAL_F_11", - "CASUAL_F_12", - "CASUAL_F_13", - "CASUAL_F_14", - "CASUAL_F_15", - "CASUAL_F_16", - "CASUAL_F_17", - "CASUAL_F_18", - "CASUAL_F_19", - "CASUAL_F_2", - "CASUAL_F_20", - "CASUAL_F_21", - "CASUAL_F_22", - "CASUAL_F_23", - "CASUAL_F_24", - "CASUAL_F_25", - "CASUAL_F_26", - "CASUAL_F_27", - "CASUAL_F_28", - "CASUAL_F_29", - "CASUAL_F_3", - "CASUAL_F_30", - "CASUAL_F_31", - "CASUAL_F_32", - "CASUAL_F_33", - "CASUAL_F_34", - "CASUAL_F_35", - "CASUAL_F_36", - "CASUAL_F_37", - "CASUAL_F_38", - "CASUAL_F_39", - "CASUAL_F_4", - "CASUAL_F_40", - "CASUAL_F_41", - "CASUAL_F_42", - "CASUAL_F_43", - "CASUAL_F_44", - "CASUAL_F_45", - "CASUAL_F_46", - "CASUAL_F_47", - "CASUAL_F_48", - "CASUAL_F_49", - "CASUAL_F_5", - "CASUAL_F_50", - "CASUAL_F_6", - "CASUAL_F_7", - "CASUAL_F_8", - "CASUAL_F_9", - "CASUAL_M_1", - "CASUAL_M_10", - "CASUAL_M_11", - "CASUAL_M_12", - "CASUAL_M_13", - "CASUAL_M_14", - "CASUAL_M_15", - "CASUAL_M_16", - "CASUAL_M_17", - "CASUAL_M_18", - "CASUAL_M_19", - "CASUAL_M_2", - "CASUAL_M_20", - "CASUAL_M_21", - "CASUAL_M_22", - "CASUAL_M_23", - "CASUAL_M_24", - "CASUAL_M_25", - "CASUAL_M_26", - "CASUAL_M_27", - "CASUAL_M_28", - "CASUAL_M_29", - "CASUAL_M_3", - "CASUAL_M_30", - "CASUAL_M_31", - "CASUAL_M_32", - "CASUAL_M_33", - "CASUAL_M_34", - "CASUAL_M_35", - "CASUAL_M_36", - "CASUAL_M_37", - "CASUAL_M_38", - "CASUAL_M_39", - "CASUAL_M_4", - "CASUAL_M_40", - "CASUAL_M_41", - "CASUAL_M_42", - "CASUAL_M_43", - "CASUAL_M_44", - "CASUAL_M_45", - "CASUAL_M_46", - "CASUAL_M_47", - "CASUAL_M_48", - "CASUAL_M_49", - "CASUAL_M_5", - "CASUAL_M_50", - "CASUAL_M_6", - "CASUAL_M_7", - "CASUAL_M_8", - "CASUAL_M_9", - "COTTAGECORE_C_1", - "COTTAGECORE_C_10", - "COTTAGECORE_C_11", - "COTTAGECORE_C_12", - "COTTAGECORE_C_13", - "COTTAGECORE_C_14", - "COTTAGECORE_C_15", - "COTTAGECORE_C_16", - "COTTAGECORE_C_17", - "COTTAGECORE_C_18", - "COTTAGECORE_C_19", - "COTTAGECORE_C_2", - "COTTAGECORE_C_20", - "COTTAGECORE_C_21", - "COTTAGECORE_C_22", - "COTTAGECORE_C_23", - "COTTAGECORE_C_24", - "COTTAGECORE_C_25", - "COTTAGECORE_C_3", - "COTTAGECORE_C_4", - "COTTAGECORE_C_5", - "COTTAGECORE_C_6", - "COTTAGECORE_C_7", - "COTTAGECORE_C_8", - "COTTAGECORE_C_9", - "COTTAGECORE_F_1", - "COTTAGECORE_F_10", - "COTTAGECORE_F_11", - "COTTAGECORE_F_12", - "COTTAGECORE_F_13", - "COTTAGECORE_F_14", - "COTTAGECORE_F_15", - "COTTAGECORE_F_16", - "COTTAGECORE_F_17", - "COTTAGECORE_F_18", - "COTTAGECORE_F_19", - "COTTAGECORE_F_2", - "COTTAGECORE_F_20", - "COTTAGECORE_F_21", - "COTTAGECORE_F_22", - "COTTAGECORE_F_23", - "COTTAGECORE_F_24", - "COTTAGECORE_F_25", - "COTTAGECORE_F_3", - "COTTAGECORE_F_4", - "COTTAGECORE_F_5", - "COTTAGECORE_F_6", - "COTTAGECORE_F_7", - "COTTAGECORE_F_8", - "COTTAGECORE_F_9", - "COTTAGECORE_M_1", - "COTTAGECORE_M_10", - "COTTAGECORE_M_11", - "COTTAGECORE_M_12", - "COTTAGECORE_M_13", - "COTTAGECORE_M_14", - "COTTAGECORE_M_15", - "COTTAGECORE_M_16", - "COTTAGECORE_M_17", - "COTTAGECORE_M_18", - "COTTAGECORE_M_19", - "COTTAGECORE_M_2", - "COTTAGECORE_M_20", - "COTTAGECORE_M_21", - "COTTAGECORE_M_22", - "COTTAGECORE_M_23", - "COTTAGECORE_M_24", - "COTTAGECORE_M_25", - "COTTAGECORE_M_3", - "COTTAGECORE_M_4", - "COTTAGECORE_M_5", - "COTTAGECORE_M_6", - "COTTAGECORE_M_7", - "COTTAGECORE_M_8", - "COTTAGECORE_M_9", - "FEST_C_1", - "FEST_C_10", - "FEST_C_11", - "FEST_C_12", - "FEST_C_13", - "FEST_C_14", - "FEST_C_15", - "FEST_C_16", - "FEST_C_17", - "FEST_C_18", - "FEST_C_19", - "FEST_C_2", - "FEST_C_20", - "FEST_C_21", - "FEST_C_22", - "FEST_C_23", - "FEST_C_24", - "FEST_C_25", - "FEST_C_3", - "FEST_C_4", - "FEST_C_5", - "FEST_C_6", - "FEST_C_7", - "FEST_C_8", - "FEST_C_9", - "FEST_F_1", - "FEST_F_10", - "FEST_F_11", - "FEST_F_12", - "FEST_F_13", - "FEST_F_14", - "FEST_F_15", - "FEST_F_16", - "FEST_F_17", - "FEST_F_18", - "FEST_F_19", - "FEST_F_2", - "FEST_F_20", - "FEST_F_21", - "FEST_F_22", - "FEST_F_23", - "FEST_F_24", - "FEST_F_25", - "FEST_F_3", - "FEST_F_4", - "FEST_F_5", - "FEST_F_6", - "FEST_F_7", - "FEST_F_8", - "FEST_F_9", - "FEST_M_1", - "FEST_M_10", - "FEST_M_11", - "FEST_M_12", - "FEST_M_13", - "FEST_M_14", - "FEST_M_15", - "FEST_M_16", - "FEST_M_17", - "FEST_M_18", - "FEST_M_19", - "FEST_M_2", - "FEST_M_20", - "FEST_M_21", - "FEST_M_22", - "FEST_M_23", - "FEST_M_24", - "FEST_M_25", - "FEST_M_3", - "FEST_M_4", - "FEST_M_5", - "FEST_M_6", - "FEST_M_7", - "FEST_M_8", - "FEST_M_9", - "INDIAN_C_1", - "INDIAN_C_10", - "INDIAN_C_11", - "INDIAN_C_12", - "INDIAN_C_13", - "INDIAN_C_14", - "INDIAN_C_15", - "INDIAN_C_16", - "INDIAN_C_17", - "INDIAN_C_18", - "INDIAN_C_19", - "INDIAN_C_2", - "INDIAN_C_20", - "INDIAN_C_21", - "INDIAN_C_22", - "INDIAN_C_23", - "INDIAN_C_24", - "INDIAN_C_25", - "INDIAN_C_26", - "INDIAN_C_27", - "INDIAN_C_28", - "INDIAN_C_29", - "INDIAN_C_3", - "INDIAN_C_30", - "INDIAN_C_31", - "INDIAN_C_32", - "INDIAN_C_33", - "INDIAN_C_34", - "INDIAN_C_35", - "INDIAN_C_36", - "INDIAN_C_37", - "INDIAN_C_38", - "INDIAN_C_39", - "INDIAN_C_4", - "INDIAN_C_40", - "INDIAN_C_41", - "INDIAN_C_42", - "INDIAN_C_43", - "INDIAN_C_44", - "INDIAN_C_45", - "INDIAN_C_46", - "INDIAN_C_47", - "INDIAN_C_48", - "INDIAN_C_49", - "INDIAN_C_5", - "INDIAN_C_50", - "INDIAN_C_6", - "INDIAN_C_7", - "INDIAN_C_8", - "INDIAN_C_9", - "INDIAN_F_1", - "INDIAN_F_10", - "INDIAN_F_11", - "INDIAN_F_12", - "INDIAN_F_13", - "INDIAN_F_14", - "INDIAN_F_15", - "INDIAN_F_16", - "INDIAN_F_17", - "INDIAN_F_18", - "INDIAN_F_19", - "INDIAN_F_2", - "INDIAN_F_20", - "INDIAN_F_21", - "INDIAN_F_22", - "INDIAN_F_23", - "INDIAN_F_24", - "INDIAN_F_25", - "INDIAN_F_26", - "INDIAN_F_27", - "INDIAN_F_28", - "INDIAN_F_29", - "INDIAN_F_3", - "INDIAN_F_30", - "INDIAN_F_31", - "INDIAN_F_32", - "INDIAN_F_33", - "INDIAN_F_34", - "INDIAN_F_35", - "INDIAN_F_36", - "INDIAN_F_37", - "INDIAN_F_38", - "INDIAN_F_39", - "INDIAN_F_4", - "INDIAN_F_40", - "INDIAN_F_41", - "INDIAN_F_42", - "INDIAN_F_43", - "INDIAN_F_44", - "INDIAN_F_45", - "INDIAN_F_46", - "INDIAN_F_47", - "INDIAN_F_48", - "INDIAN_F_49", - "INDIAN_F_5", - "INDIAN_F_50", - "INDIAN_F_6", - "INDIAN_F_7", - "INDIAN_F_8", - "INDIAN_F_9", - "INDIAN_M_1", - "INDIAN_M_10", - "INDIAN_M_11", - "INDIAN_M_12", - "INDIAN_M_13", - "INDIAN_M_14", - "INDIAN_M_15", - "INDIAN_M_16", - "INDIAN_M_17", - "INDIAN_M_18", - "INDIAN_M_19", - "INDIAN_M_2", - "INDIAN_M_20", - "INDIAN_M_21", - "INDIAN_M_22", - "INDIAN_M_23", - "INDIAN_M_24", - "INDIAN_M_25", - "INDIAN_M_26", - "INDIAN_M_27", - "INDIAN_M_28", - "INDIAN_M_29", - "INDIAN_M_3", - "INDIAN_M_30", - "INDIAN_M_31", - "INDIAN_M_32", - "INDIAN_M_33", - "INDIAN_M_34", - "INDIAN_M_35", - "INDIAN_M_36", - "INDIAN_M_37", - "INDIAN_M_38", - "INDIAN_M_39", - "INDIAN_M_4", - "INDIAN_M_40", - "INDIAN_M_41", - "INDIAN_M_42", - "INDIAN_M_43", - "INDIAN_M_44", - "INDIAN_M_45", - "INDIAN_M_46", - "INDIAN_M_47", - "INDIAN_M_48", - "INDIAN_M_49", - "INDIAN_M_5", - "INDIAN_M_50", - "INDIAN_M_6", - "INDIAN_M_7", - "INDIAN_M_8", - "INDIAN_M_9", - "KPOP_C_1", - "KPOP_C_10", - "KPOP_C_11", - "KPOP_C_12", - "KPOP_C_13", - "KPOP_C_14", - "KPOP_C_15", - "KPOP_C_16", - "KPOP_C_17", - "KPOP_C_18", - "KPOP_C_19", - "KPOP_C_2", - "KPOP_C_20", - "KPOP_C_21", - "KPOP_C_22", - "KPOP_C_23", - "KPOP_C_24", - "KPOP_C_25", - "KPOP_C_26", - "KPOP_C_27", - "KPOP_C_28", - "KPOP_C_29", - "KPOP_C_3", - "KPOP_C_30", - "KPOP_C_31", - "KPOP_C_32", - "KPOP_C_33", - "KPOP_C_34", - "KPOP_C_35", - "KPOP_C_36", - "KPOP_C_37", - "KPOP_C_38", - "KPOP_C_39", - "KPOP_C_4", - "KPOP_C_40", - "KPOP_C_41", - "KPOP_C_42", - "KPOP_C_43", - "KPOP_C_44", - "KPOP_C_45", - "KPOP_C_46", - "KPOP_C_47", - "KPOP_C_48", - "KPOP_C_49", - "KPOP_C_5", - "KPOP_C_50", - "KPOP_C_6", - "KPOP_C_7", - "KPOP_C_8", - "KPOP_C_9", - "KPOP_F_1", - "KPOP_F_10", - "KPOP_F_11", - "KPOP_F_12", - "KPOP_F_13", - "KPOP_F_14", - "KPOP_F_15", - "KPOP_F_16", - "KPOP_F_17", - "KPOP_F_18", - "KPOP_F_19", - "KPOP_F_2", - "KPOP_F_20", - "KPOP_F_21", - "KPOP_F_22", - "KPOP_F_23", - "KPOP_F_24", - "KPOP_F_25", - "KPOP_F_26", - "KPOP_F_27", - "KPOP_F_28", - "KPOP_F_29", - "KPOP_F_3", - "KPOP_F_30", - "KPOP_F_31", - "KPOP_F_32", - "KPOP_F_33", - "KPOP_F_34", - "KPOP_F_35", - "KPOP_F_36", - "KPOP_F_37", - "KPOP_F_38", - "KPOP_F_39", - "KPOP_F_4", - "KPOP_F_40", - "KPOP_F_41", - "KPOP_F_42", - "KPOP_F_43", - "KPOP_F_44", - "KPOP_F_45", - "KPOP_F_46", - "KPOP_F_47", - "KPOP_F_48", - "KPOP_F_49", - "KPOP_F_5", - "KPOP_F_50", - "KPOP_F_6", - "KPOP_F_7", - "KPOP_F_8", - "KPOP_F_9", - "KPOP_M_1", - "KPOP_M_10", - "KPOP_M_11", - "KPOP_M_12", - "KPOP_M_13", - "KPOP_M_14", - "KPOP_M_15", - "KPOP_M_16", - "KPOP_M_17", - "KPOP_M_18", - "KPOP_M_19", - "KPOP_M_2", - "KPOP_M_20", - "KPOP_M_21", - "KPOP_M_22", - "KPOP_M_23", - "KPOP_M_24", - "KPOP_M_25", - "KPOP_M_26", - "KPOP_M_27", - "KPOP_M_28", - "KPOP_M_29", - "KPOP_M_3", - "KPOP_M_30", - "KPOP_M_31", - "KPOP_M_32", - "KPOP_M_33", - "KPOP_M_34", - "KPOP_M_35", - "KPOP_M_36", - "KPOP_M_37", - "KPOP_M_38", - "KPOP_M_39", - "KPOP_M_4", - "KPOP_M_40", - "KPOP_M_41", - "KPOP_M_42", - "KPOP_M_43", - "KPOP_M_44", - "KPOP_M_45", - "KPOP_M_46", - "KPOP_M_47", - "KPOP_M_48", - "KPOP_M_49", - "KPOP_M_5", - "KPOP_M_50", - "KPOP_M_6", - "KPOP_M_7", - "KPOP_M_8", - "KPOP_M_9", - "NEOWESTERN_C_1", - "NEOWESTERN_C_10", - "NEOWESTERN_C_11", - "NEOWESTERN_C_12", - "NEOWESTERN_C_13", - "NEOWESTERN_C_14", - "NEOWESTERN_C_15", - "NEOWESTERN_C_16", - "NEOWESTERN_C_17", - "NEOWESTERN_C_18", - "NEOWESTERN_C_19", - "NEOWESTERN_C_2", - "NEOWESTERN_C_20", - "NEOWESTERN_C_21", - "NEOWESTERN_C_22", - "NEOWESTERN_C_23", - "NEOWESTERN_C_24", - "NEOWESTERN_C_25", - "NEOWESTERN_C_3", - "NEOWESTERN_C_4", - "NEOWESTERN_C_5", - "NEOWESTERN_C_6", - "NEOWESTERN_C_7", - "NEOWESTERN_C_8", - "NEOWESTERN_C_9", - "NEOWESTERN_F_1", - "NEOWESTERN_F_10", - "NEOWESTERN_F_11", - "NEOWESTERN_F_12", - "NEOWESTERN_F_13", - "NEOWESTERN_F_14", - "NEOWESTERN_F_15", - "NEOWESTERN_F_16", - "NEOWESTERN_F_17", - "NEOWESTERN_F_18", - "NEOWESTERN_F_19", - "NEOWESTERN_F_2", - "NEOWESTERN_F_20", - "NEOWESTERN_F_21", - "NEOWESTERN_F_22", - "NEOWESTERN_F_23", - "NEOWESTERN_F_24", - "NEOWESTERN_F_25", - "NEOWESTERN_F_3", - "NEOWESTERN_F_4", - "NEOWESTERN_F_5", - "NEOWESTERN_F_6", - "NEOWESTERN_F_7", - "NEOWESTERN_F_8", - "NEOWESTERN_F_9", - "NEOWESTERN_M_1", - "NEOWESTERN_M_10", - "NEOWESTERN_M_11", - "NEOWESTERN_M_12", - "NEOWESTERN_M_13", - "NEOWESTERN_M_14", - "NEOWESTERN_M_15", - "NEOWESTERN_M_16", - "NEOWESTERN_M_17", - "NEOWESTERN_M_18", - "NEOWESTERN_M_19", - "NEOWESTERN_M_2", - "NEOWESTERN_M_20", - "NEOWESTERN_M_21", - "NEOWESTERN_M_22", - "NEOWESTERN_M_23", - "NEOWESTERN_M_24", - "NEOWESTERN_M_25", - "NEOWESTERN_M_3", - "NEOWESTERN_M_4", - "NEOWESTERN_M_5", - "NEOWESTERN_M_6", - "NEOWESTERN_M_7", - "NEOWESTERN_M_8", - "NEOWESTERN_M_9", - "OLDMONEY_C_1", - "OLDMONEY_C_10", - "OLDMONEY_C_11", - "OLDMONEY_C_12", - "OLDMONEY_C_13", - "OLDMONEY_C_14", - "OLDMONEY_C_15", - "OLDMONEY_C_16", - "OLDMONEY_C_17", - "OLDMONEY_C_18", - "OLDMONEY_C_19", - "OLDMONEY_C_2", - "OLDMONEY_C_20", - "OLDMONEY_C_21", - "OLDMONEY_C_22", - "OLDMONEY_C_23", - "OLDMONEY_C_24", - "OLDMONEY_C_25", - "OLDMONEY_C_3", - "OLDMONEY_C_4", - "OLDMONEY_C_5", - "OLDMONEY_C_6", - "OLDMONEY_C_7", - "OLDMONEY_C_8", - "OLDMONEY_C_9", - "OLDMONEY_F_1", - "OLDMONEY_F_10", - "OLDMONEY_F_11", - "OLDMONEY_F_12", - "OLDMONEY_F_13", - "OLDMONEY_F_14", - "OLDMONEY_F_15", - "OLDMONEY_F_16", - "OLDMONEY_F_17", - "OLDMONEY_F_18", - "OLDMONEY_F_19", - "OLDMONEY_F_2", - "OLDMONEY_F_20", - "OLDMONEY_F_21", - "OLDMONEY_F_22", - "OLDMONEY_F_23", - "OLDMONEY_F_24", - "OLDMONEY_F_25", - "OLDMONEY_F_3", - "OLDMONEY_F_4", - "OLDMONEY_F_5", - "OLDMONEY_F_6", - "OLDMONEY_F_7", - "OLDMONEY_F_8", - "OLDMONEY_F_9", - "OLDMONEY_M_1", - "OLDMONEY_M_10", - "OLDMONEY_M_11", - "OLDMONEY_M_12", - "OLDMONEY_M_13", - "OLDMONEY_M_14", - "OLDMONEY_M_15", - "OLDMONEY_M_16", - "OLDMONEY_M_17", - "OLDMONEY_M_18", - "OLDMONEY_M_19", - "OLDMONEY_M_2", - "OLDMONEY_M_20", - "OLDMONEY_M_21", - "OLDMONEY_M_22", - "OLDMONEY_M_23", - "OLDMONEY_M_24", - "OLDMONEY_M_25", - "OLDMONEY_M_3", - "OLDMONEY_M_4", - "OLDMONEY_M_5", - "OLDMONEY_M_6", - "OLDMONEY_M_7", - "OLDMONEY_M_8", - "OLDMONEY_M_9", - "PARTY_C_1", - "PARTY_C_10", - "PARTY_C_11", - "PARTY_C_12", - "PARTY_C_13", - "PARTY_C_14", - "PARTY_C_15", - "PARTY_C_16", - "PARTY_C_17", - "PARTY_C_18", - "PARTY_C_19", - "PARTY_C_2", - "PARTY_C_20", - "PARTY_C_21", - "PARTY_C_22", - "PARTY_C_23", - "PARTY_C_24", - "PARTY_C_25", - "PARTY_C_3", - "PARTY_C_4", - "PARTY_C_5", - "PARTY_C_6", - "PARTY_C_7", - "PARTY_C_8", - "PARTY_C_9", - "PARTY_F_1", - "PARTY_F_10", - "PARTY_F_11", - "PARTY_F_12", - "PARTY_F_13", - "PARTY_F_14", - "PARTY_F_15", - "PARTY_F_16", - "PARTY_F_17", - "PARTY_F_18", - "PARTY_F_19", - "PARTY_F_2", - "PARTY_F_20", - "PARTY_F_21", - "PARTY_F_22", - "PARTY_F_23", - "PARTY_F_24", - "PARTY_F_25", - "PARTY_F_3", - "PARTY_F_4", - "PARTY_F_5", - "PARTY_F_6", - "PARTY_F_7", - "PARTY_F_8", - "PARTY_F_9", - "PARTY_M_1", - "PARTY_M_10", - "PARTY_M_11", - "PARTY_M_12", - "PARTY_M_13", - "PARTY_M_14", - "PARTY_M_15", - "PARTY_M_16", - "PARTY_M_17", - "PARTY_M_18", - "PARTY_M_19", - "PARTY_M_2", - "PARTY_M_20", - "PARTY_M_21", - "PARTY_M_22", - "PARTY_M_23", - "PARTY_M_24", - "PARTY_M_25", - "PARTY_M_3", - "PARTY_M_4", - "PARTY_M_5", - "PARTY_M_6", - "PARTY_M_7", - "PARTY_M_8", - "PARTY_M_9", - "PROF_C_1", - "PROF_C_10", - "PROF_C_11", - "PROF_C_12", - "PROF_C_13", - "PROF_C_14", - "PROF_C_15", - "PROF_C_16", - "PROF_C_17", - "PROF_C_18", - "PROF_C_19", - "PROF_C_2", - "PROF_C_20", - "PROF_C_21", - "PROF_C_22", - "PROF_C_23", - "PROF_C_24", - "PROF_C_25", - "PROF_C_26", - "PROF_C_27", - "PROF_C_28", - "PROF_C_29", - "PROF_C_3", - "PROF_C_30", - "PROF_C_31", - "PROF_C_32", - "PROF_C_33", - "PROF_C_34", - "PROF_C_35", - "PROF_C_36", - "PROF_C_37", - "PROF_C_38", - "PROF_C_39", - "PROF_C_4", - "PROF_C_40", - "PROF_C_41", - "PROF_C_42", - "PROF_C_43", - "PROF_C_44", - "PROF_C_45", - "PROF_C_46", - "PROF_C_47", - "PROF_C_48", - "PROF_C_49", - "PROF_C_5", - "PROF_C_50", - "PROF_C_6", - "PROF_C_7", - "PROF_C_8", - "PROF_C_9", - "PROF_F_1", - "PROF_F_10", - "PROF_F_11", - "PROF_F_12", - "PROF_F_13", - "PROF_F_14", - "PROF_F_15", - "PROF_F_16", - "PROF_F_17", - "PROF_F_18", - "PROF_F_19", - "PROF_F_2", - "PROF_F_20", - "PROF_F_21", - "PROF_F_22", - "PROF_F_23", - "PROF_F_24", - "PROF_F_25", - "PROF_F_26", - "PROF_F_27", - "PROF_F_28", - "PROF_F_29", - "PROF_F_3", - "PROF_F_30", - "PROF_F_31", - "PROF_F_32", - "PROF_F_33", - "PROF_F_34", - "PROF_F_35", - "PROF_F_36", - "PROF_F_37", - "PROF_F_38", - "PROF_F_39", - "PROF_F_4", - "PROF_F_40", - "PROF_F_41", - "PROF_F_42", - "PROF_F_43", - "PROF_F_44", - "PROF_F_45", - "PROF_F_46", - "PROF_F_47", - "PROF_F_48", - "PROF_F_49", - "PROF_F_5", - "PROF_F_50", - "PROF_F_6", - "PROF_F_7", - "PROF_F_8", - "PROF_F_9", - "PROF_M_1", - "PROF_M_10", - "PROF_M_11", - "PROF_M_12", - "PROF_M_13", - "PROF_M_14", - "PROF_M_15", - "PROF_M_16", - "PROF_M_17", - "PROF_M_18", - "PROF_M_19", - "PROF_M_2", - "PROF_M_20", - "PROF_M_21", - "PROF_M_22", - "PROF_M_23", - "PROF_M_24", - "PROF_M_25", - "PROF_M_26", - "PROF_M_27", - "PROF_M_28", - "PROF_M_29", - "PROF_M_3", - "PROF_M_30", - "PROF_M_31", - "PROF_M_32", - "PROF_M_33", - "PROF_M_34", - "PROF_M_35", - "PROF_M_36", - "PROF_M_37", - "PROF_M_38", - "PROF_M_39", - "PROF_M_4", - "PROF_M_40", - "PROF_M_41", - "PROF_M_42", - "PROF_M_43", - "PROF_M_44", - "PROF_M_45", - "PROF_M_46", - "PROF_M_47", - "PROF_M_48", - "PROF_M_49", - "PROF_M_5", - "PROF_M_50", - "PROF_M_6", - "PROF_M_7", - "PROF_M_8", - "PROF_M_9", - "ROM_C_1", - "ROM_C_10", - "ROM_C_11", - "ROM_C_12", - "ROM_C_13", - "ROM_C_14", - "ROM_C_15", - "ROM_C_2", - "ROM_C_3", - "ROM_C_4", - "ROM_C_5", - "ROM_C_6", - "ROM_C_7", - "ROM_C_8", - "ROM_C_9", - "ROM_F_1", - "ROM_F_10", - "ROM_F_11", - "ROM_F_12", - "ROM_F_13", - "ROM_F_14", - "ROM_F_15", - "ROM_F_2", - "ROM_F_3", - "ROM_F_4", - "ROM_F_5", - "ROM_F_6", - "ROM_F_7", - "ROM_F_8", - "ROM_F_9", - "ROM_M_1", - "ROM_M_10", - "ROM_M_11", - "ROM_M_12", - "ROM_M_13", - "ROM_M_14", - "ROM_M_15", - "ROM_M_2", - "ROM_M_3", - "ROM_M_4", - "ROM_M_5", - "ROM_M_6", - "ROM_M_7", - "ROM_M_8", - "ROM_M_9", - "SPORT_C_1", - "SPORT_C_10", - "SPORT_C_11", - "SPORT_C_12", - "SPORT_C_13", - "SPORT_C_14", - "SPORT_C_15", - "SPORT_C_16", - "SPORT_C_17", - "SPORT_C_18", - "SPORT_C_19", - "SPORT_C_2", - "SPORT_C_20", - "SPORT_C_21", - "SPORT_C_22", - "SPORT_C_23", - "SPORT_C_24", - "SPORT_C_25", - "SPORT_C_3", - "SPORT_C_4", - "SPORT_C_5", - "SPORT_C_6", - "SPORT_C_7", - "SPORT_C_8", - "SPORT_C_9", - "SPORT_F_1", - "SPORT_F_10", - "SPORT_F_11", - "SPORT_F_12", - "SPORT_F_13", - "SPORT_F_14", - "SPORT_F_15", - "SPORT_F_16", - "SPORT_F_17", - "SPORT_F_18", - "SPORT_F_19", - "SPORT_F_2", - "SPORT_F_20", - "SPORT_F_21", - "SPORT_F_22", - "SPORT_F_23", - "SPORT_F_24", - "SPORT_F_25", - "SPORT_F_3", - "SPORT_F_4", - "SPORT_F_5", - "SPORT_F_6", - "SPORT_F_7", - "SPORT_F_8", - "SPORT_F_9", - "SPORT_M_1", - "SPORT_M_10", - "SPORT_M_11", - "SPORT_M_12", - "SPORT_M_13", - "SPORT_M_14", - "SPORT_M_15", - "SPORT_M_16", - "SPORT_M_17", - "SPORT_M_18", - "SPORT_M_19", - "SPORT_M_2", - "SPORT_M_20", - "SPORT_M_21", - "SPORT_M_22", - "SPORT_M_23", - "SPORT_M_24", - "SPORT_M_25", - "SPORT_M_3", - "SPORT_M_4", - "SPORT_M_5", - "SPORT_M_6", - "SPORT_M_7", - "SPORT_M_8", - "SPORT_M_9", - "TRENDY_C_1", - "TRENDY_C_10", - "TRENDY_C_11", - "TRENDY_C_12", - "TRENDY_C_13", - "TRENDY_C_14", - "TRENDY_C_15", - "TRENDY_C_16", - "TRENDY_C_17", - "TRENDY_C_18", - "TRENDY_C_19", - "TRENDY_C_2", - "TRENDY_C_20", - "TRENDY_C_21", - "TRENDY_C_22", - "TRENDY_C_23", - "TRENDY_C_24", - "TRENDY_C_25", - "TRENDY_C_26", - "TRENDY_C_27", - "TRENDY_C_28", - "TRENDY_C_29", - "TRENDY_C_3", - "TRENDY_C_30", - "TRENDY_C_31", - "TRENDY_C_32", - "TRENDY_C_33", - "TRENDY_C_34", - "TRENDY_C_35", - "TRENDY_C_36", - "TRENDY_C_37", - "TRENDY_C_38", - "TRENDY_C_39", - "TRENDY_C_4", - "TRENDY_C_40", - "TRENDY_C_5", - "TRENDY_C_6", - "TRENDY_C_7", - "TRENDY_C_8", - "TRENDY_C_9", - "TRENDY_F_1", - "TRENDY_F_10", - "TRENDY_F_11", - "TRENDY_F_12", - "TRENDY_F_13", - "TRENDY_F_14", - "TRENDY_F_15", - "TRENDY_F_16", - "TRENDY_F_17", - "TRENDY_F_18", - "TRENDY_F_19", - "TRENDY_F_2", - "TRENDY_F_20", - "TRENDY_F_21", - "TRENDY_F_22", - "TRENDY_F_23", - "TRENDY_F_24", - "TRENDY_F_25", - "TRENDY_F_26", - "TRENDY_F_27", - "TRENDY_F_28", - "TRENDY_F_29", - "TRENDY_F_3", - "TRENDY_F_30", - "TRENDY_F_31", - "TRENDY_F_32", - "TRENDY_F_33", - "TRENDY_F_34", - "TRENDY_F_35", - "TRENDY_F_36", - "TRENDY_F_37", - "TRENDY_F_38", - "TRENDY_F_39", - "TRENDY_F_4", - "TRENDY_F_40", - "TRENDY_F_5", - "TRENDY_F_6", - "TRENDY_F_7", - "TRENDY_F_8", - "TRENDY_F_9", - "TRENDY_M_1", - "TRENDY_M_10", - "TRENDY_M_11", - "TRENDY_M_12", - "TRENDY_M_13", - "TRENDY_M_14", - "TRENDY_M_15", - "TRENDY_M_16", - "TRENDY_M_17", - "TRENDY_M_18", - "TRENDY_M_19", - "TRENDY_M_2", - "TRENDY_M_20", - "TRENDY_M_21", - "TRENDY_M_22", - "TRENDY_M_23", - "TRENDY_M_24", - "TRENDY_M_25", - "TRENDY_M_26", - "TRENDY_M_27", - "TRENDY_M_28", - "TRENDY_M_29", - "TRENDY_M_3", - "TRENDY_M_30", - "TRENDY_M_31", - "TRENDY_M_32", - "TRENDY_M_33", - "TRENDY_M_34", - "TRENDY_M_35", - "TRENDY_M_36", - "TRENDY_M_37", - "TRENDY_M_38", - "TRENDY_M_39", - "TRENDY_M_4", - "TRENDY_M_40", - "TRENDY_M_5", - "TRENDY_M_6", - "TRENDY_M_7", - "TRENDY_M_8", - "TRENDY_M_9", - "TWIN_C_1", - "TWIN_C_10", - "TWIN_C_11", - "TWIN_C_12", - "TWIN_C_13", - "TWIN_C_14", - "TWIN_C_15", - "TWIN_C_16", - "TWIN_C_17", - "TWIN_C_18", - "TWIN_C_19", - "TWIN_C_2", - "TWIN_C_20", - "TWIN_C_21", - "TWIN_C_22", - "TWIN_C_23", - "TWIN_C_24", - "TWIN_C_25", - "TWIN_C_3", - "TWIN_C_4", - "TWIN_C_5", - "TWIN_C_6", - "TWIN_C_7", - "TWIN_C_8", - "TWIN_C_9", - "TWIN_F_1", - "TWIN_F_10", - "TWIN_F_11", - "TWIN_F_12", - "TWIN_F_13", - "TWIN_F_14", - "TWIN_F_15", - "TWIN_F_16", - "TWIN_F_17", - "TWIN_F_18", - "TWIN_F_19", - "TWIN_F_2", - "TWIN_F_20", - "TWIN_F_21", - "TWIN_F_22", - "TWIN_F_23", - "TWIN_F_24", - "TWIN_F_25", - "TWIN_F_3", - "TWIN_F_4", - "TWIN_F_5", - "TWIN_F_6", - "TWIN_F_7", - "TWIN_F_8", - "TWIN_F_9", - "TWIN_M_1", - "TWIN_M_10", - "TWIN_M_11", - "TWIN_M_12", - "TWIN_M_13", - "TWIN_M_14", - "TWIN_M_15", - "TWIN_M_16", - "TWIN_M_17", - "TWIN_M_18", - "TWIN_M_19", - "TWIN_M_2", - "TWIN_M_20", - "TWIN_M_21", - "TWIN_M_22", - "TWIN_M_23", - "TWIN_M_24", - "TWIN_M_25", - "TWIN_M_3", - "TWIN_M_4", - "TWIN_M_5", - "TWIN_M_6", - "TWIN_M_7", - "TWIN_M_8", - "TWIN_M_9", - "VACATION_C_1", - "VACATION_C_10", - "VACATION_C_11", - "VACATION_C_12", - "VACATION_C_13", - "VACATION_C_14", - "VACATION_C_15", - "VACATION_C_16", - "VACATION_C_17", - "VACATION_C_18", - "VACATION_C_19", - "VACATION_C_2", - "VACATION_C_20", - "VACATION_C_21", - "VACATION_C_22", - "VACATION_C_23", - "VACATION_C_24", - "VACATION_C_25", - "VACATION_C_26", - "VACATION_C_27", - "VACATION_C_28", - "VACATION_C_29", - "VACATION_C_3", - "VACATION_C_30", - "VACATION_C_31", - "VACATION_C_32", - "VACATION_C_33", - "VACATION_C_34", - "VACATION_C_35", - "VACATION_C_36", - "VACATION_C_37", - "VACATION_C_38", - "VACATION_C_39", - "VACATION_C_4", - "VACATION_C_40", - "VACATION_C_41", - "VACATION_C_42", - "VACATION_C_43", - "VACATION_C_44", - "VACATION_C_45", - "VACATION_C_46", - "VACATION_C_47", - "VACATION_C_48", - "VACATION_C_49", - "VACATION_C_5", - "VACATION_C_50", - "VACATION_C_6", - "VACATION_C_7", - "VACATION_C_8", - "VACATION_C_9", - "VACATION_F_1", - "VACATION_F_10", - "VACATION_F_11", - "VACATION_F_12", - "VACATION_F_13", - "VACATION_F_14", - "VACATION_F_15", - "VACATION_F_16", - "VACATION_F_17", - "VACATION_F_18", - "VACATION_F_19", - "VACATION_F_2", - "VACATION_F_20", - "VACATION_F_21", - "VACATION_F_22", - "VACATION_F_23", - "VACATION_F_24", - "VACATION_F_25", - "VACATION_F_26", - "VACATION_F_27", - "VACATION_F_28", - "VACATION_F_29", - "VACATION_F_3", - "VACATION_F_30", - "VACATION_F_31", - "VACATION_F_32", - "VACATION_F_33", - "VACATION_F_34", - "VACATION_F_35", - "VACATION_F_36", - "VACATION_F_37", - "VACATION_F_38", - "VACATION_F_39", - "VACATION_F_4", - "VACATION_F_40", - "VACATION_F_41", - "VACATION_F_42", - "VACATION_F_43", - "VACATION_F_44", - "VACATION_F_45", - "VACATION_F_46", - "VACATION_F_47", - "VACATION_F_48", - "VACATION_F_49", - "VACATION_F_5", - "VACATION_F_50", - "VACATION_F_6", - "VACATION_F_7", - "VACATION_F_8", - "VACATION_F_9", - "VACATION_M_1", - "VACATION_M_10", - "VACATION_M_11", - "VACATION_M_12", - "VACATION_M_13", - "VACATION_M_14", - "VACATION_M_15", - "VACATION_M_16", - "VACATION_M_17", - "VACATION_M_18", - "VACATION_M_19", - "VACATION_M_2", - "VACATION_M_20", - "VACATION_M_21", - "VACATION_M_22", - "VACATION_M_23", - "VACATION_M_24", - "VACATION_M_25", - "VACATION_M_26", - "VACATION_M_27", - "VACATION_M_28", - "VACATION_M_29", - "VACATION_M_3", - "VACATION_M_30", - "VACATION_M_31", - "VACATION_M_32", - "VACATION_M_33", - "VACATION_M_34", - "VACATION_M_35", - "VACATION_M_36", - "VACATION_M_37", - "VACATION_M_38", - "VACATION_M_39", - "VACATION_M_4", - "VACATION_M_40", - "VACATION_M_41", - "VACATION_M_42", - "VACATION_M_43", - "VACATION_M_44", - "VACATION_M_45", - "VACATION_M_46", - "VACATION_M_47", - "VACATION_M_48", - "VACATION_M_49", - "VACATION_M_5", - "VACATION_M_50", - "VACATION_M_6", - "VACATION_M_7", - "VACATION_M_8", - "VACATION_M_9", - "VIN_C_1", - "VIN_C_10", - "VIN_C_11", - "VIN_C_12", - "VIN_C_13", - "VIN_C_14", - "VIN_C_15", - "VIN_C_16", - "VIN_C_17", - "VIN_C_18", - "VIN_C_19", - "VIN_C_2", - "VIN_C_20", - "VIN_C_21", - "VIN_C_22", - "VIN_C_23", - "VIN_C_24", - "VIN_C_25", - "VIN_C_26", - "VIN_C_27", - "VIN_C_28", - "VIN_C_29", - "VIN_C_3", - "VIN_C_30", - "VIN_C_31", - "VIN_C_32", - "VIN_C_33", - "VIN_C_34", - "VIN_C_35", - "VIN_C_36", - "VIN_C_37", - "VIN_C_38", - "VIN_C_39", - "VIN_C_4", - "VIN_C_40", - "VIN_C_41", - "VIN_C_42", - "VIN_C_43", - "VIN_C_44", - "VIN_C_45", - "VIN_C_46", - "VIN_C_47", - "VIN_C_48", - "VIN_C_49", - "VIN_C_5", - "VIN_C_50", - "VIN_C_6", - "VIN_C_7", - "VIN_C_8", - "VIN_C_9", - "VIN_F_1", - "VIN_F_10", - "VIN_F_11", - "VIN_F_12", - "VIN_F_13", - "VIN_F_14", - "VIN_F_15", - "VIN_F_16", - "VIN_F_17", - "VIN_F_18", - "VIN_F_19", - "VIN_F_2", - "VIN_F_20", - "VIN_F_21", - "VIN_F_22", - "VIN_F_23", - "VIN_F_24", - "VIN_F_25", - "VIN_F_26", - "VIN_F_27", - "VIN_F_28", - "VIN_F_29", - "VIN_F_3", - "VIN_F_30", - "VIN_F_31", - "VIN_F_32", - "VIN_F_33", - "VIN_F_34", - "VIN_F_35", - "VIN_F_36", - "VIN_F_37", - "VIN_F_38", - "VIN_F_39", - "VIN_F_4", - "VIN_F_40", - "VIN_F_41", - "VIN_F_42", - "VIN_F_43", - "VIN_F_44", - "VIN_F_45", - "VIN_F_46", - "VIN_F_47", - "VIN_F_48", - "VIN_F_49", - "VIN_F_5", - "VIN_F_50", - "VIN_F_6", - "VIN_F_7", - "VIN_F_8", - "VIN_F_9", - "VIN_M_1", - "VIN_M_10", - "VIN_M_11", - "VIN_M_12", - "VIN_M_13", - "VIN_M_14", - "VIN_M_15", - "VIN_M_16", - "VIN_M_17", - "VIN_M_18", - "VIN_M_19", - "VIN_M_2", - "VIN_M_20", - "VIN_M_21", - "VIN_M_22", - "VIN_M_23", - "VIN_M_24", - "VIN_M_25", - "VIN_M_26", - "VIN_M_27", - "VIN_M_28", - "VIN_M_29", - "VIN_M_3", - "VIN_M_30", - "VIN_M_31", - "VIN_M_32", - "VIN_M_33", - "VIN_M_34", - "VIN_M_35", - "VIN_M_36", - "VIN_M_37", - "VIN_M_38", - "VIN_M_39", - "VIN_M_4", - "VIN_M_40", - "VIN_M_41", - "VIN_M_42", - "VIN_M_43", - "VIN_M_44", - "VIN_M_45", - "VIN_M_46", - "VIN_M_47", - "VIN_M_48", - "VIN_M_49", - "VIN_M_5", - "VIN_M_50", - "VIN_M_6", - "VIN_M_7", - "VIN_M_8", - "VIN_M_9", - "WED_C_1", - "WED_C_10", - "WED_C_11", - "WED_C_12", - "WED_C_13", - "WED_C_14", - "WED_C_15", - "WED_C_16", - "WED_C_17", - "WED_C_18", - "WED_C_19", - "WED_C_2", - "WED_C_20", - "WED_C_21", - "WED_C_22", - "WED_C_23", - "WED_C_24", - "WED_C_25", - "WED_C_3", - "WED_C_4", - "WED_C_5", - "WED_C_6", - "WED_C_7", - "WED_C_8", - "WED_C_9", - "WED_F_1", - "WED_F_10", - "WED_F_11", - "WED_F_12", - "WED_F_13", - "WED_F_14", - "WED_F_15", - "WED_F_16", - "WED_F_17", - "WED_F_18", - "WED_F_19", - "WED_F_2", - "WED_F_20", - "WED_F_21", - "WED_F_22", - "WED_F_23", - "WED_F_24", - "WED_F_25", - "WED_F_3", - "WED_F_4", - "WED_F_5", - "WED_F_6", - "WED_F_7", - "WED_F_8", - "WED_F_9", - "WED_M_1", - "WED_M_10", - "WED_M_11", - "WED_M_12", - "WED_M_13", - "WED_M_14", - "WED_M_15", - "WED_M_16", - "WED_M_17", - "WED_M_18", - "WED_M_19", - "WED_M_2", - "WED_M_20", - "WED_M_21", - "WED_M_22", - "WED_M_23", - "WED_M_24", - "WED_M_25", - "WED_M_3", - "WED_M_4", - "WED_M_5", - "WED_M_6", - "WED_M_7", - "WED_M_8", - "WED_M_9", - "black_dress", - "black_saree", - "blue_dress", - "casual_jeans", - "floral_dress", - "formal_suit", - "green_dress", - "pink_dress", - "red_dress", - "white_dress", - "yellow_dress" - ], - "subs": [], - "curl": "", - "endpoints": [ - { - "id": "ff-dress-changer", - "method": "POST", - "subpath": "image/", - "full_url": "https://apigp0006.creinnovations.in/apis/flxf/flux_fill/dress_changer/image/", - "path": "/flux_fill/dress_changer/image/", - "title": "FLUX.1-Fill Wardrobe Restyling & Outfits", - "summary": "Full-body wardrobe inpainting across 1,676 verified outfits in 16 categories.", - "desc": "Applies high-fashion dresses, traditional attire, business suits, and streetwear onto solo portraits. Uses Sapiens 28-class body parsing to isolate clothing while preserving head, arms, legs, and background.", - "params": [ - { - "n": "image0", - "al": "image", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Input full-body or half-body photograph." - }, - { - "n": "effectId", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Outfit encoding ID. Follows pattern '{THEME}_{GENDER}_{INDEX}' (e.g. 'CASUAL_F_10', 'INDIAN_M_5') or named presets (e.g. 'black_dress', 'formal_suit')." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "'abcdef'", - "ds": "\ud83d\udd11 Authentication: API authentication key ('abcdef')." - }, - { - "n": "mask_image", - "al": "", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": false, - "df": "None (auto-segmented via Sapiens)", - "ds": "Optional clothing mask." - } - ], - "chips": [ - "CASUAL_C_1", - "CASUAL_C_10", - "CASUAL_C_11", - "CASUAL_C_12", - "CASUAL_C_13", - "CASUAL_C_14", - "CASUAL_C_15", - "CASUAL_C_16", - "CASUAL_C_17", - "CASUAL_C_18", - "CASUAL_C_19", - "CASUAL_C_2", - "CASUAL_C_20", - "CASUAL_C_21", - "CASUAL_C_22", - "CASUAL_C_23", - "CASUAL_C_24", - "CASUAL_C_25", - "CASUAL_C_26", - "CASUAL_C_27", - "CASUAL_C_28", - "CASUAL_C_29", - "CASUAL_C_3", - "CASUAL_C_30", - "CASUAL_C_31", - "CASUAL_C_32", - "CASUAL_C_33", - "CASUAL_C_34", - "CASUAL_C_35", - "CASUAL_C_36", - "CASUAL_C_37", - "CASUAL_C_38", - "CASUAL_C_39", - "CASUAL_C_4", - "CASUAL_C_40", - "CASUAL_C_41", - "CASUAL_C_42", - "CASUAL_C_43", - "CASUAL_C_44", - "CASUAL_C_45", - "CASUAL_C_46", - "CASUAL_C_47", - "CASUAL_C_48", - "CASUAL_C_49", - "CASUAL_C_5", - "CASUAL_C_50", - "CASUAL_C_6", - "CASUAL_C_7", - "CASUAL_C_8", - "CASUAL_C_9", - "CASUAL_F_1", - "CASUAL_F_10", - "CASUAL_F_11", - "CASUAL_F_12", - "CASUAL_F_13", - "CASUAL_F_14", - "CASUAL_F_15", - "CASUAL_F_16", - "CASUAL_F_17", - "CASUAL_F_18", - "CASUAL_F_19", - "CASUAL_F_2", - "CASUAL_F_20", - "CASUAL_F_21", - "CASUAL_F_22", - "CASUAL_F_23", - "CASUAL_F_24", - "CASUAL_F_25", - "CASUAL_F_26", - "CASUAL_F_27", - "CASUAL_F_28", - "CASUAL_F_29", - "CASUAL_F_3", - "CASUAL_F_30", - "CASUAL_F_31", - "CASUAL_F_32", - "CASUAL_F_33", - "CASUAL_F_34", - "CASUAL_F_35", - "CASUAL_F_36", - "CASUAL_F_37", - "CASUAL_F_38", - "CASUAL_F_39", - "CASUAL_F_4", - "CASUAL_F_40", - "CASUAL_F_41", - "CASUAL_F_42", - "CASUAL_F_43", - "CASUAL_F_44", - "CASUAL_F_45", - "CASUAL_F_46", - "CASUAL_F_47", - "CASUAL_F_48", - "CASUAL_F_49", - "CASUAL_F_5", - "CASUAL_F_50", - "CASUAL_F_6", - "CASUAL_F_7", - "CASUAL_F_8", - "CASUAL_F_9", - "CASUAL_M_1", - "CASUAL_M_10", - "CASUAL_M_11", - "CASUAL_M_12", - "CASUAL_M_13", - "CASUAL_M_14", - "CASUAL_M_15", - "CASUAL_M_16", - "CASUAL_M_17", - "CASUAL_M_18", - "CASUAL_M_19", - "CASUAL_M_2", - "CASUAL_M_20", - "CASUAL_M_21", - "CASUAL_M_22", - "CASUAL_M_23", - "CASUAL_M_24", - "CASUAL_M_25", - "CASUAL_M_26", - "CASUAL_M_27", - "CASUAL_M_28", - "CASUAL_M_29", - "CASUAL_M_3", - "CASUAL_M_30", - "CASUAL_M_31", - "CASUAL_M_32", - "CASUAL_M_33", - "CASUAL_M_34", - "CASUAL_M_35", - "CASUAL_M_36", - "CASUAL_M_37", - "CASUAL_M_38", - "CASUAL_M_39", - "CASUAL_M_4", - "CASUAL_M_40", - "CASUAL_M_41", - "CASUAL_M_42", - "CASUAL_M_43", - "CASUAL_M_44", - "CASUAL_M_45", - "CASUAL_M_46", - "CASUAL_M_47", - "CASUAL_M_48", - "CASUAL_M_49", - "CASUAL_M_5", - "CASUAL_M_50", - "CASUAL_M_6", - "CASUAL_M_7", - "CASUAL_M_8", - "CASUAL_M_9", - "COTTAGECORE_C_1", - "COTTAGECORE_C_10", - "COTTAGECORE_C_11", - "COTTAGECORE_C_12", - "COTTAGECORE_C_13", - "COTTAGECORE_C_14", - "COTTAGECORE_C_15", - "COTTAGECORE_C_16", - "COTTAGECORE_C_17", - "COTTAGECORE_C_18", - "COTTAGECORE_C_19", - "COTTAGECORE_C_2", - "COTTAGECORE_C_20", - "COTTAGECORE_C_21", - "COTTAGECORE_C_22", - "COTTAGECORE_C_23", - "COTTAGECORE_C_24", - "COTTAGECORE_C_25", - "COTTAGECORE_C_3", - "COTTAGECORE_C_4", - "COTTAGECORE_C_5", - "COTTAGECORE_C_6", - "COTTAGECORE_C_7", - "COTTAGECORE_C_8", - "COTTAGECORE_C_9", - "COTTAGECORE_F_1", - "COTTAGECORE_F_10", - "COTTAGECORE_F_11", - "COTTAGECORE_F_12", - "COTTAGECORE_F_13", - "COTTAGECORE_F_14", - "COTTAGECORE_F_15", - "COTTAGECORE_F_16", - "COTTAGECORE_F_17", - "COTTAGECORE_F_18", - "COTTAGECORE_F_19", - "COTTAGECORE_F_2", - "COTTAGECORE_F_20", - "COTTAGECORE_F_21", - "COTTAGECORE_F_22", - "COTTAGECORE_F_23", - "COTTAGECORE_F_24", - "COTTAGECORE_F_25", - "COTTAGECORE_F_3", - "COTTAGECORE_F_4", - "COTTAGECORE_F_5", - "COTTAGECORE_F_6", - "COTTAGECORE_F_7", - "COTTAGECORE_F_8", - "COTTAGECORE_F_9", - "COTTAGECORE_M_1", - "COTTAGECORE_M_10", - "COTTAGECORE_M_11", - "COTTAGECORE_M_12", - "COTTAGECORE_M_13", - "COTTAGECORE_M_14", - "COTTAGECORE_M_15", - "COTTAGECORE_M_16", - "COTTAGECORE_M_17", - "COTTAGECORE_M_18", - "COTTAGECORE_M_19", - "COTTAGECORE_M_2", - "COTTAGECORE_M_20", - "COTTAGECORE_M_21", - "COTTAGECORE_M_22", - "COTTAGECORE_M_23", - "COTTAGECORE_M_24", - "COTTAGECORE_M_25", - "COTTAGECORE_M_3", - "COTTAGECORE_M_4", - "COTTAGECORE_M_5", - "COTTAGECORE_M_6", - "COTTAGECORE_M_7", - "COTTAGECORE_M_8", - "COTTAGECORE_M_9", - "FEST_C_1", - "FEST_C_10", - "FEST_C_11", - "FEST_C_12", - "FEST_C_13", - "FEST_C_14", - "FEST_C_15", - "FEST_C_16", - "FEST_C_17", - "FEST_C_18", - "FEST_C_19", - "FEST_C_2", - "FEST_C_20", - "FEST_C_21", - "FEST_C_22", - "FEST_C_23", - "FEST_C_24", - "FEST_C_25", - "FEST_C_3", - "FEST_C_4", - "FEST_C_5", - "FEST_C_6", - "FEST_C_7", - "FEST_C_8", - "FEST_C_9", - "FEST_F_1", - "FEST_F_10", - "FEST_F_11", - "FEST_F_12", - "FEST_F_13", - "FEST_F_14", - "FEST_F_15", - "FEST_F_16", - "FEST_F_17", - "FEST_F_18", - "FEST_F_19", - "FEST_F_2", - "FEST_F_20", - "FEST_F_21", - "FEST_F_22", - "FEST_F_23", - "FEST_F_24", - "FEST_F_25", - "FEST_F_3", - "FEST_F_4", - "FEST_F_5", - "FEST_F_6", - "FEST_F_7", - "FEST_F_8", - "FEST_F_9", - "FEST_M_1", - "FEST_M_10", - "FEST_M_11", - "FEST_M_12", - "FEST_M_13", - "FEST_M_14", - "FEST_M_15", - "FEST_M_16", - "FEST_M_17", - "FEST_M_18", - "FEST_M_19", - "FEST_M_2", - "FEST_M_20", - "FEST_M_21", - "FEST_M_22", - "FEST_M_23", - "FEST_M_24", - "FEST_M_25", - "FEST_M_3", - "FEST_M_4", - "FEST_M_5", - "FEST_M_6", - "FEST_M_7", - "FEST_M_8", - "FEST_M_9", - "INDIAN_C_1", - "INDIAN_C_10", - "INDIAN_C_11", - "INDIAN_C_12", - "INDIAN_C_13", - "INDIAN_C_14", - "INDIAN_C_15", - "INDIAN_C_16", - "INDIAN_C_17", - "INDIAN_C_18", - "INDIAN_C_19", - "INDIAN_C_2", - "INDIAN_C_20", - "INDIAN_C_21", - "INDIAN_C_22", - "INDIAN_C_23", - "INDIAN_C_24", - "INDIAN_C_25", - "INDIAN_C_26", - "INDIAN_C_27", - "INDIAN_C_28", - "INDIAN_C_29", - "INDIAN_C_3", - "INDIAN_C_30", - "INDIAN_C_31", - "INDIAN_C_32", - "INDIAN_C_33", - "INDIAN_C_34", - "INDIAN_C_35", - "INDIAN_C_36", - "INDIAN_C_37", - "INDIAN_C_38", - "INDIAN_C_39", - "INDIAN_C_4", - "INDIAN_C_40", - "INDIAN_C_41", - "INDIAN_C_42", - "INDIAN_C_43", - "INDIAN_C_44", - "INDIAN_C_45", - "INDIAN_C_46", - "INDIAN_C_47", - "INDIAN_C_48", - "INDIAN_C_49", - "INDIAN_C_5", - "INDIAN_C_50", - "INDIAN_C_6", - "INDIAN_C_7", - "INDIAN_C_8", - "INDIAN_C_9", - "INDIAN_F_1", - "INDIAN_F_10", - "INDIAN_F_11", - "INDIAN_F_12", - "INDIAN_F_13", - "INDIAN_F_14", - "INDIAN_F_15", - "INDIAN_F_16", - "INDIAN_F_17", - "INDIAN_F_18", - "INDIAN_F_19", - "INDIAN_F_2", - "INDIAN_F_20", - "INDIAN_F_21", - "INDIAN_F_22", - "INDIAN_F_23", - "INDIAN_F_24", - "INDIAN_F_25", - "INDIAN_F_26", - "INDIAN_F_27", - "INDIAN_F_28", - "INDIAN_F_29", - "INDIAN_F_3", - "INDIAN_F_30", - "INDIAN_F_31", - "INDIAN_F_32", - "INDIAN_F_33", - "INDIAN_F_34", - "INDIAN_F_35", - "INDIAN_F_36", - "INDIAN_F_37", - "INDIAN_F_38", - "INDIAN_F_39", - "INDIAN_F_4", - "INDIAN_F_40", - "INDIAN_F_41", - "INDIAN_F_42", - "INDIAN_F_43", - "INDIAN_F_44", - "INDIAN_F_45", - "INDIAN_F_46", - "INDIAN_F_47", - "INDIAN_F_48", - "INDIAN_F_49", - "INDIAN_F_5", - "INDIAN_F_50", - "INDIAN_F_6", - "INDIAN_F_7", - "INDIAN_F_8", - "INDIAN_F_9", - "INDIAN_M_1", - "INDIAN_M_10", - "INDIAN_M_11", - "INDIAN_M_12", - "INDIAN_M_13", - "INDIAN_M_14", - "INDIAN_M_15", - "INDIAN_M_16", - "INDIAN_M_17", - "INDIAN_M_18", - "INDIAN_M_19", - "INDIAN_M_2", - "INDIAN_M_20", - "INDIAN_M_21", - "INDIAN_M_22", - "INDIAN_M_23", - "INDIAN_M_24", - "INDIAN_M_25", - "INDIAN_M_26", - "INDIAN_M_27", - "INDIAN_M_28", - "INDIAN_M_29", - "INDIAN_M_3", - "INDIAN_M_30", - "INDIAN_M_31", - "INDIAN_M_32", - "INDIAN_M_33", - "INDIAN_M_34", - "INDIAN_M_35", - "INDIAN_M_36", - "INDIAN_M_37", - "INDIAN_M_38", - "INDIAN_M_39", - "INDIAN_M_4", - "INDIAN_M_40", - "INDIAN_M_41", - "INDIAN_M_42", - "INDIAN_M_43", - "INDIAN_M_44", - "INDIAN_M_45", - "INDIAN_M_46", - "INDIAN_M_47", - "INDIAN_M_48", - "INDIAN_M_49", - "INDIAN_M_5", - "INDIAN_M_50", - "INDIAN_M_6", - "INDIAN_M_7", - "INDIAN_M_8", - "INDIAN_M_9", - "KPOP_C_1", - "KPOP_C_10", - "KPOP_C_11", - "KPOP_C_12", - "KPOP_C_13", - "KPOP_C_14", - "KPOP_C_15", - "KPOP_C_16", - "KPOP_C_17", - "KPOP_C_18", - "KPOP_C_19", - "KPOP_C_2", - "KPOP_C_20", - "KPOP_C_21", - "KPOP_C_22", - "KPOP_C_23", - "KPOP_C_24", - "KPOP_C_25", - "KPOP_C_26", - "KPOP_C_27", - "KPOP_C_28", - "KPOP_C_29", - "KPOP_C_3", - "KPOP_C_30", - "KPOP_C_31", - "KPOP_C_32", - "KPOP_C_33", - "KPOP_C_34", - "KPOP_C_35", - "KPOP_C_36", - "KPOP_C_37", - "KPOP_C_38", - "KPOP_C_39", - "KPOP_C_4", - "KPOP_C_40", - "KPOP_C_41", - "KPOP_C_42", - "KPOP_C_43", - "KPOP_C_44", - "KPOP_C_45", - "KPOP_C_46", - "KPOP_C_47", - "KPOP_C_48", - "KPOP_C_49", - "KPOP_C_5", - "KPOP_C_50", - "KPOP_C_6", - "KPOP_C_7", - "KPOP_C_8", - "KPOP_C_9", - "KPOP_F_1", - "KPOP_F_10", - "KPOP_F_11", - "KPOP_F_12", - "KPOP_F_13", - "KPOP_F_14", - "KPOP_F_15", - "KPOP_F_16", - "KPOP_F_17", - "KPOP_F_18", - "KPOP_F_19", - "KPOP_F_2", - "KPOP_F_20", - "KPOP_F_21", - "KPOP_F_22", - "KPOP_F_23", - "KPOP_F_24", - "KPOP_F_25", - "KPOP_F_26", - "KPOP_F_27", - "KPOP_F_28", - "KPOP_F_29", - "KPOP_F_3", - "KPOP_F_30", - "KPOP_F_31", - "KPOP_F_32", - "KPOP_F_33", - "KPOP_F_34", - "KPOP_F_35", - "KPOP_F_36", - "KPOP_F_37", - "KPOP_F_38", - "KPOP_F_39", - "KPOP_F_4", - "KPOP_F_40", - "KPOP_F_41", - "KPOP_F_42", - "KPOP_F_43", - "KPOP_F_44", - "KPOP_F_45", - "KPOP_F_46", - "KPOP_F_47", - "KPOP_F_48", - "KPOP_F_49", - "KPOP_F_5", - "KPOP_F_50", - "KPOP_F_6", - "KPOP_F_7", - "KPOP_F_8", - "KPOP_F_9", - "KPOP_M_1", - "KPOP_M_10", - "KPOP_M_11", - "KPOP_M_12", - "KPOP_M_13", - "KPOP_M_14", - "KPOP_M_15", - "KPOP_M_16", - "KPOP_M_17", - "KPOP_M_18", - "KPOP_M_19", - "KPOP_M_2", - "KPOP_M_20", - "KPOP_M_21", - "KPOP_M_22", - "KPOP_M_23", - "KPOP_M_24", - "KPOP_M_25", - "KPOP_M_26", - "KPOP_M_27", - "KPOP_M_28", - "KPOP_M_29", - "KPOP_M_3", - "KPOP_M_30", - "KPOP_M_31", - "KPOP_M_32", - "KPOP_M_33", - "KPOP_M_34", - "KPOP_M_35", - "KPOP_M_36", - "KPOP_M_37", - "KPOP_M_38", - "KPOP_M_39", - "KPOP_M_4", - "KPOP_M_40", - "KPOP_M_41", - "KPOP_M_42", - "KPOP_M_43", - "KPOP_M_44", - "KPOP_M_45", - "KPOP_M_46", - "KPOP_M_47", - "KPOP_M_48", - "KPOP_M_49", - "KPOP_M_5", - "KPOP_M_50", - "KPOP_M_6", - "KPOP_M_7", - "KPOP_M_8", - "KPOP_M_9", - "NEOWESTERN_C_1", - "NEOWESTERN_C_10", - "NEOWESTERN_C_11", - "NEOWESTERN_C_12", - "NEOWESTERN_C_13", - "NEOWESTERN_C_14", - "NEOWESTERN_C_15", - "NEOWESTERN_C_16", - "NEOWESTERN_C_17", - "NEOWESTERN_C_18", - "NEOWESTERN_C_19", - "NEOWESTERN_C_2", - "NEOWESTERN_C_20", - "NEOWESTERN_C_21", - "NEOWESTERN_C_22", - "NEOWESTERN_C_23", - "NEOWESTERN_C_24", - "NEOWESTERN_C_25", - "NEOWESTERN_C_3", - "NEOWESTERN_C_4", - "NEOWESTERN_C_5", - "NEOWESTERN_C_6", - "NEOWESTERN_C_7", - "NEOWESTERN_C_8", - "NEOWESTERN_C_9", - "NEOWESTERN_F_1", - "NEOWESTERN_F_10", - "NEOWESTERN_F_11", - "NEOWESTERN_F_12", - "NEOWESTERN_F_13", - "NEOWESTERN_F_14", - "NEOWESTERN_F_15", - "NEOWESTERN_F_16", - "NEOWESTERN_F_17", - "NEOWESTERN_F_18", - "NEOWESTERN_F_19", - "NEOWESTERN_F_2", - "NEOWESTERN_F_20", - "NEOWESTERN_F_21", - "NEOWESTERN_F_22", - "NEOWESTERN_F_23", - "NEOWESTERN_F_24", - "NEOWESTERN_F_25", - "NEOWESTERN_F_3", - "NEOWESTERN_F_4", - "NEOWESTERN_F_5", - "NEOWESTERN_F_6", - "NEOWESTERN_F_7", - "NEOWESTERN_F_8", - "NEOWESTERN_F_9", - "NEOWESTERN_M_1", - "NEOWESTERN_M_10", - "NEOWESTERN_M_11", - "NEOWESTERN_M_12", - "NEOWESTERN_M_13", - "NEOWESTERN_M_14", - "NEOWESTERN_M_15", - "NEOWESTERN_M_16", - "NEOWESTERN_M_17", - "NEOWESTERN_M_18", - "NEOWESTERN_M_19", - "NEOWESTERN_M_2", - "NEOWESTERN_M_20", - "NEOWESTERN_M_21", - "NEOWESTERN_M_22", - "NEOWESTERN_M_23", - "NEOWESTERN_M_24", - "NEOWESTERN_M_25", - "NEOWESTERN_M_3", - "NEOWESTERN_M_4", - "NEOWESTERN_M_5", - "NEOWESTERN_M_6", - "NEOWESTERN_M_7", - "NEOWESTERN_M_8", - "NEOWESTERN_M_9", - "OLDMONEY_C_1", - "OLDMONEY_C_10", - "OLDMONEY_C_11", - "OLDMONEY_C_12", - "OLDMONEY_C_13", - "OLDMONEY_C_14", - "OLDMONEY_C_15", - "OLDMONEY_C_16", - "OLDMONEY_C_17", - "OLDMONEY_C_18", - "OLDMONEY_C_19", - "OLDMONEY_C_2", - "OLDMONEY_C_20", - "OLDMONEY_C_21", - "OLDMONEY_C_22", - "OLDMONEY_C_23", - "OLDMONEY_C_24", - "OLDMONEY_C_25", - "OLDMONEY_C_3", - "OLDMONEY_C_4", - "OLDMONEY_C_5", - "OLDMONEY_C_6", - "OLDMONEY_C_7", - "OLDMONEY_C_8", - "OLDMONEY_C_9", - "OLDMONEY_F_1", - "OLDMONEY_F_10", - "OLDMONEY_F_11", - "OLDMONEY_F_12", - "OLDMONEY_F_13", - "OLDMONEY_F_14", - "OLDMONEY_F_15", - "OLDMONEY_F_16", - "OLDMONEY_F_17", - "OLDMONEY_F_18", - "OLDMONEY_F_19", - "OLDMONEY_F_2", - "OLDMONEY_F_20", - "OLDMONEY_F_21", - "OLDMONEY_F_22", - "OLDMONEY_F_23", - "OLDMONEY_F_24", - "OLDMONEY_F_25", - "OLDMONEY_F_3", - "OLDMONEY_F_4", - "OLDMONEY_F_5", - "OLDMONEY_F_6", - "OLDMONEY_F_7", - "OLDMONEY_F_8", - "OLDMONEY_F_9", - "OLDMONEY_M_1", - "OLDMONEY_M_10", - "OLDMONEY_M_11", - "OLDMONEY_M_12", - "OLDMONEY_M_13", - "OLDMONEY_M_14", - "OLDMONEY_M_15", - "OLDMONEY_M_16", - "OLDMONEY_M_17", - "OLDMONEY_M_18", - "OLDMONEY_M_19", - "OLDMONEY_M_2", - "OLDMONEY_M_20", - "OLDMONEY_M_21", - "OLDMONEY_M_22", - "OLDMONEY_M_23", - "OLDMONEY_M_24", - "OLDMONEY_M_25", - "OLDMONEY_M_3", - "OLDMONEY_M_4", - "OLDMONEY_M_5", - "OLDMONEY_M_6", - "OLDMONEY_M_7", - "OLDMONEY_M_8", - "OLDMONEY_M_9", - "PARTY_C_1", - "PARTY_C_10", - "PARTY_C_11", - "PARTY_C_12", - "PARTY_C_13", - "PARTY_C_14", - "PARTY_C_15", - "PARTY_C_16", - "PARTY_C_17", - "PARTY_C_18", - "PARTY_C_19", - "PARTY_C_2", - "PARTY_C_20", - "PARTY_C_21", - "PARTY_C_22", - "PARTY_C_23", - "PARTY_C_24", - "PARTY_C_25", - "PARTY_C_3", - "PARTY_C_4", - "PARTY_C_5", - "PARTY_C_6", - "PARTY_C_7", - "PARTY_C_8", - "PARTY_C_9", - "PARTY_F_1", - "PARTY_F_10", - "PARTY_F_11", - "PARTY_F_12", - "PARTY_F_13", - "PARTY_F_14", - "PARTY_F_15", - "PARTY_F_16", - "PARTY_F_17", - "PARTY_F_18", - "PARTY_F_19", - "PARTY_F_2", - "PARTY_F_20", - "PARTY_F_21", - "PARTY_F_22", - "PARTY_F_23", - "PARTY_F_24", - "PARTY_F_25", - "PARTY_F_3", - "PARTY_F_4", - "PARTY_F_5", - "PARTY_F_6", - "PARTY_F_7", - "PARTY_F_8", - "PARTY_F_9", - "PARTY_M_1", - "PARTY_M_10", - "PARTY_M_11", - "PARTY_M_12", - "PARTY_M_13", - "PARTY_M_14", - "PARTY_M_15", - "PARTY_M_16", - "PARTY_M_17", - "PARTY_M_18", - "PARTY_M_19", - "PARTY_M_2", - "PARTY_M_20", - "PARTY_M_21", - "PARTY_M_22", - "PARTY_M_23", - "PARTY_M_24", - "PARTY_M_25", - "PARTY_M_3", - "PARTY_M_4", - "PARTY_M_5", - "PARTY_M_6", - "PARTY_M_7", - "PARTY_M_8", - "PARTY_M_9", - "PROF_C_1", - "PROF_C_10", - "PROF_C_11", - "PROF_C_12", - "PROF_C_13", - "PROF_C_14", - "PROF_C_15", - "PROF_C_16", - "PROF_C_17", - "PROF_C_18", - "PROF_C_19", - "PROF_C_2", - "PROF_C_20", - "PROF_C_21", - "PROF_C_22", - "PROF_C_23", - "PROF_C_24", - "PROF_C_25", - "PROF_C_26", - "PROF_C_27", - "PROF_C_28", - "PROF_C_29", - "PROF_C_3", - "PROF_C_30", - "PROF_C_31", - "PROF_C_32", - "PROF_C_33", - "PROF_C_34", - "PROF_C_35", - "PROF_C_36", - "PROF_C_37", - "PROF_C_38", - "PROF_C_39", - "PROF_C_4", - "PROF_C_40", - "PROF_C_41", - "PROF_C_42", - "PROF_C_43", - "PROF_C_44", - "PROF_C_45", - "PROF_C_46", - "PROF_C_47", - "PROF_C_48", - "PROF_C_49", - "PROF_C_5", - "PROF_C_50", - "PROF_C_6", - "PROF_C_7", - "PROF_C_8", - "PROF_C_9", - "PROF_F_1", - "PROF_F_10", - "PROF_F_11", - "PROF_F_12", - "PROF_F_13", - "PROF_F_14", - "PROF_F_15", - "PROF_F_16", - "PROF_F_17", - "PROF_F_18", - "PROF_F_19", - "PROF_F_2", - "PROF_F_20", - "PROF_F_21", - "PROF_F_22", - "PROF_F_23", - "PROF_F_24", - "PROF_F_25", - "PROF_F_26", - "PROF_F_27", - "PROF_F_28", - "PROF_F_29", - "PROF_F_3", - "PROF_F_30", - "PROF_F_31", - "PROF_F_32", - "PROF_F_33", - "PROF_F_34", - "PROF_F_35", - "PROF_F_36", - "PROF_F_37", - "PROF_F_38", - "PROF_F_39", - "PROF_F_4", - "PROF_F_40", - "PROF_F_41", - "PROF_F_42", - "PROF_F_43", - "PROF_F_44", - "PROF_F_45", - "PROF_F_46", - "PROF_F_47", - "PROF_F_48", - "PROF_F_49", - "PROF_F_5", - "PROF_F_50", - "PROF_F_6", - "PROF_F_7", - "PROF_F_8", - "PROF_F_9", - "PROF_M_1", - "PROF_M_10", - "PROF_M_11", - "PROF_M_12", - "PROF_M_13", - "PROF_M_14", - "PROF_M_15", - "PROF_M_16", - "PROF_M_17", - "PROF_M_18", - "PROF_M_19", - "PROF_M_2", - "PROF_M_20", - "PROF_M_21", - "PROF_M_22", - "PROF_M_23", - "PROF_M_24", - "PROF_M_25", - "PROF_M_26", - "PROF_M_27", - "PROF_M_28", - "PROF_M_29", - "PROF_M_3", - "PROF_M_30", - "PROF_M_31", - "PROF_M_32", - "PROF_M_33", - "PROF_M_34", - "PROF_M_35", - "PROF_M_36", - "PROF_M_37", - "PROF_M_38", - "PROF_M_39", - "PROF_M_4", - "PROF_M_40", - "PROF_M_41", - "PROF_M_42", - "PROF_M_43", - "PROF_M_44", - "PROF_M_45", - "PROF_M_46", - "PROF_M_47", - "PROF_M_48", - "PROF_M_49", - "PROF_M_5", - "PROF_M_50", - "PROF_M_6", - "PROF_M_7", - "PROF_M_8", - "PROF_M_9", - "ROM_C_1", - "ROM_C_10", - "ROM_C_11", - "ROM_C_12", - "ROM_C_13", - "ROM_C_14", - "ROM_C_15", - "ROM_C_2", - "ROM_C_3", - "ROM_C_4", - "ROM_C_5", - "ROM_C_6", - "ROM_C_7", - "ROM_C_8", - "ROM_C_9", - "ROM_F_1", - "ROM_F_10", - "ROM_F_11", - "ROM_F_12", - "ROM_F_13", - "ROM_F_14", - "ROM_F_15", - "ROM_F_2", - "ROM_F_3", - "ROM_F_4", - "ROM_F_5", - "ROM_F_6", - "ROM_F_7", - "ROM_F_8", - "ROM_F_9", - "ROM_M_1", - "ROM_M_10", - "ROM_M_11", - "ROM_M_12", - "ROM_M_13", - "ROM_M_14", - "ROM_M_15", - "ROM_M_2", - "ROM_M_3", - "ROM_M_4", - "ROM_M_5", - "ROM_M_6", - "ROM_M_7", - "ROM_M_8", - "ROM_M_9", - "SPORT_C_1", - "SPORT_C_10", - "SPORT_C_11", - "SPORT_C_12", - "SPORT_C_13", - "SPORT_C_14", - "SPORT_C_15", - "SPORT_C_16", - "SPORT_C_17", - "SPORT_C_18", - "SPORT_C_19", - "SPORT_C_2", - "SPORT_C_20", - "SPORT_C_21", - "SPORT_C_22", - "SPORT_C_23", - "SPORT_C_24", - "SPORT_C_25", - "SPORT_C_3", - "SPORT_C_4", - "SPORT_C_5", - "SPORT_C_6", - "SPORT_C_7", - "SPORT_C_8", - "SPORT_C_9", - "SPORT_F_1", - "SPORT_F_10", - "SPORT_F_11", - "SPORT_F_12", - "SPORT_F_13", - "SPORT_F_14", - "SPORT_F_15", - "SPORT_F_16", - "SPORT_F_17", - "SPORT_F_18", - "SPORT_F_19", - "SPORT_F_2", - "SPORT_F_20", - "SPORT_F_21", - "SPORT_F_22", - "SPORT_F_23", - "SPORT_F_24", - "SPORT_F_25", - "SPORT_F_3", - "SPORT_F_4", - "SPORT_F_5", - "SPORT_F_6", - "SPORT_F_7", - "SPORT_F_8", - "SPORT_F_9", - "SPORT_M_1", - "SPORT_M_10", - "SPORT_M_11", - "SPORT_M_12", - "SPORT_M_13", - "SPORT_M_14", - "SPORT_M_15", - "SPORT_M_16", - "SPORT_M_17", - "SPORT_M_18", - "SPORT_M_19", - "SPORT_M_2", - "SPORT_M_20", - "SPORT_M_21", - "SPORT_M_22", - "SPORT_M_23", - "SPORT_M_24", - "SPORT_M_25", - "SPORT_M_3", - "SPORT_M_4", - "SPORT_M_5", - "SPORT_M_6", - "SPORT_M_7", - "SPORT_M_8", - "SPORT_M_9", - "TRENDY_C_1", - "TRENDY_C_10", - "TRENDY_C_11", - "TRENDY_C_12", - "TRENDY_C_13", - "TRENDY_C_14", - "TRENDY_C_15", - "TRENDY_C_16", - "TRENDY_C_17", - "TRENDY_C_18", - "TRENDY_C_19", - "TRENDY_C_2", - "TRENDY_C_20", - "TRENDY_C_21", - "TRENDY_C_22", - "TRENDY_C_23", - "TRENDY_C_24", - "TRENDY_C_25", - "TRENDY_C_26", - "TRENDY_C_27", - "TRENDY_C_28", - "TRENDY_C_29", - "TRENDY_C_3", - "TRENDY_C_30", - "TRENDY_C_31", - "TRENDY_C_32", - "TRENDY_C_33", - "TRENDY_C_34", - "TRENDY_C_35", - "TRENDY_C_36", - "TRENDY_C_37", - "TRENDY_C_38", - "TRENDY_C_39", - "TRENDY_C_4", - "TRENDY_C_40", - "TRENDY_C_5", - "TRENDY_C_6", - "TRENDY_C_7", - "TRENDY_C_8", - "TRENDY_C_9", - "TRENDY_F_1", - "TRENDY_F_10", - "TRENDY_F_11", - "TRENDY_F_12", - "TRENDY_F_13", - "TRENDY_F_14", - "TRENDY_F_15", - "TRENDY_F_16", - "TRENDY_F_17", - "TRENDY_F_18", - "TRENDY_F_19", - "TRENDY_F_2", - "TRENDY_F_20", - "TRENDY_F_21", - "TRENDY_F_22", - "TRENDY_F_23", - "TRENDY_F_24", - "TRENDY_F_25", - "TRENDY_F_26", - "TRENDY_F_27", - "TRENDY_F_28", - "TRENDY_F_29", - "TRENDY_F_3", - "TRENDY_F_30", - "TRENDY_F_31", - "TRENDY_F_32", - "TRENDY_F_33", - "TRENDY_F_34", - "TRENDY_F_35", - "TRENDY_F_36", - "TRENDY_F_37", - "TRENDY_F_38", - "TRENDY_F_39", - "TRENDY_F_4", - "TRENDY_F_40", - "TRENDY_F_5", - "TRENDY_F_6", - "TRENDY_F_7", - "TRENDY_F_8", - "TRENDY_F_9", - "TRENDY_M_1", - "TRENDY_M_10", - "TRENDY_M_11", - "TRENDY_M_12", - "TRENDY_M_13", - "TRENDY_M_14", - "TRENDY_M_15", - "TRENDY_M_16", - "TRENDY_M_17", - "TRENDY_M_18", - "TRENDY_M_19", - "TRENDY_M_2", - "TRENDY_M_20", - "TRENDY_M_21", - "TRENDY_M_22", - "TRENDY_M_23", - "TRENDY_M_24", - "TRENDY_M_25", - "TRENDY_M_26", - "TRENDY_M_27", - "TRENDY_M_28", - "TRENDY_M_29", - "TRENDY_M_3", - "TRENDY_M_30", - "TRENDY_M_31", - "TRENDY_M_32", - "TRENDY_M_33", - "TRENDY_M_34", - "TRENDY_M_35", - "TRENDY_M_36", - "TRENDY_M_37", - "TRENDY_M_38", - "TRENDY_M_39", - "TRENDY_M_4", - "TRENDY_M_40", - "TRENDY_M_5", - "TRENDY_M_6", - "TRENDY_M_7", - "TRENDY_M_8", - "TRENDY_M_9", - "TWIN_C_1", - "TWIN_C_10", - "TWIN_C_11", - "TWIN_C_12", - "TWIN_C_13", - "TWIN_C_14", - "TWIN_C_15", - "TWIN_C_16", - "TWIN_C_17", - "TWIN_C_18", - "TWIN_C_19", - "TWIN_C_2", - "TWIN_C_20", - "TWIN_C_21", - "TWIN_C_22", - "TWIN_C_23", - "TWIN_C_24", - "TWIN_C_25", - "TWIN_C_3", - "TWIN_C_4", - "TWIN_C_5", - "TWIN_C_6", - "TWIN_C_7", - "TWIN_C_8", - "TWIN_C_9", - "TWIN_F_1", - "TWIN_F_10", - "TWIN_F_11", - "TWIN_F_12", - "TWIN_F_13", - "TWIN_F_14", - "TWIN_F_15", - "TWIN_F_16", - "TWIN_F_17", - "TWIN_F_18", - "TWIN_F_19", - "TWIN_F_2", - "TWIN_F_20", - "TWIN_F_21", - "TWIN_F_22", - "TWIN_F_23", - "TWIN_F_24", - "TWIN_F_25", - "TWIN_F_3", - "TWIN_F_4", - "TWIN_F_5", - "TWIN_F_6", - "TWIN_F_7", - "TWIN_F_8", - "TWIN_F_9", - "TWIN_M_1", - "TWIN_M_10", - "TWIN_M_11", - "TWIN_M_12", - "TWIN_M_13", - "TWIN_M_14", - "TWIN_M_15", - "TWIN_M_16", - "TWIN_M_17", - "TWIN_M_18", - "TWIN_M_19", - "TWIN_M_2", - "TWIN_M_20", - "TWIN_M_21", - "TWIN_M_22", - "TWIN_M_23", - "TWIN_M_24", - "TWIN_M_25", - "TWIN_M_3", - "TWIN_M_4", - "TWIN_M_5", - "TWIN_M_6", - "TWIN_M_7", - "TWIN_M_8", - "TWIN_M_9", - "VACATION_C_1", - "VACATION_C_10", - "VACATION_C_11", - "VACATION_C_12", - "VACATION_C_13", - "VACATION_C_14", - "VACATION_C_15", - "VACATION_C_16", - "VACATION_C_17", - "VACATION_C_18", - "VACATION_C_19", - "VACATION_C_2", - "VACATION_C_20", - "VACATION_C_21", - "VACATION_C_22", - "VACATION_C_23", - "VACATION_C_24", - "VACATION_C_25", - "VACATION_C_26", - "VACATION_C_27", - "VACATION_C_28", - "VACATION_C_29", - "VACATION_C_3", - "VACATION_C_30", - "VACATION_C_31", - "VACATION_C_32", - "VACATION_C_33", - "VACATION_C_34", - "VACATION_C_35", - "VACATION_C_36", - "VACATION_C_37", - "VACATION_C_38", - "VACATION_C_39", - "VACATION_C_4", - "VACATION_C_40", - "VACATION_C_41", - "VACATION_C_42", - "VACATION_C_43", - "VACATION_C_44", - "VACATION_C_45", - "VACATION_C_46", - "VACATION_C_47", - "VACATION_C_48", - "VACATION_C_49", - "VACATION_C_5", - "VACATION_C_50", - "VACATION_C_6", - "VACATION_C_7", - "VACATION_C_8", - "VACATION_C_9", - "VACATION_F_1", - "VACATION_F_10", - "VACATION_F_11", - "VACATION_F_12", - "VACATION_F_13", - "VACATION_F_14", - "VACATION_F_15", - "VACATION_F_16", - "VACATION_F_17", - "VACATION_F_18", - "VACATION_F_19", - "VACATION_F_2", - "VACATION_F_20", - "VACATION_F_21", - "VACATION_F_22", - "VACATION_F_23", - "VACATION_F_24", - "VACATION_F_25", - "VACATION_F_26", - "VACATION_F_27", - "VACATION_F_28", - "VACATION_F_29", - "VACATION_F_3", - "VACATION_F_30", - "VACATION_F_31", - "VACATION_F_32", - "VACATION_F_33", - "VACATION_F_34", - "VACATION_F_35", - "VACATION_F_36", - "VACATION_F_37", - "VACATION_F_38", - "VACATION_F_39", - "VACATION_F_4", - "VACATION_F_40", - "VACATION_F_41", - "VACATION_F_42", - "VACATION_F_43", - "VACATION_F_44", - "VACATION_F_45", - "VACATION_F_46", - "VACATION_F_47", - "VACATION_F_48", - "VACATION_F_49", - "VACATION_F_5", - "VACATION_F_50", - "VACATION_F_6", - "VACATION_F_7", - "VACATION_F_8", - "VACATION_F_9", - "VACATION_M_1", - "VACATION_M_10", - "VACATION_M_11", - "VACATION_M_12", - "VACATION_M_13", - "VACATION_M_14", - "VACATION_M_15", - "VACATION_M_16", - "VACATION_M_17", - "VACATION_M_18", - "VACATION_M_19", - "VACATION_M_2", - "VACATION_M_20", - "VACATION_M_21", - "VACATION_M_22", - "VACATION_M_23", - "VACATION_M_24", - "VACATION_M_25", - "VACATION_M_26", - "VACATION_M_27", - "VACATION_M_28", - "VACATION_M_29", - "VACATION_M_3", - "VACATION_M_30", - "VACATION_M_31", - "VACATION_M_32", - "VACATION_M_33", - "VACATION_M_34", - "VACATION_M_35", - "VACATION_M_36", - "VACATION_M_37", - "VACATION_M_38", - "VACATION_M_39", - "VACATION_M_4", - "VACATION_M_40", - "VACATION_M_41", - "VACATION_M_42", - "VACATION_M_43", - "VACATION_M_44", - "VACATION_M_45", - "VACATION_M_46", - "VACATION_M_47", - "VACATION_M_48", - "VACATION_M_49", - "VACATION_M_5", - "VACATION_M_50", - "VACATION_M_6", - "VACATION_M_7", - "VACATION_M_8", - "VACATION_M_9", - "VIN_C_1", - "VIN_C_10", - "VIN_C_11", - "VIN_C_12", - "VIN_C_13", - "VIN_C_14", - "VIN_C_15", - "VIN_C_16", - "VIN_C_17", - "VIN_C_18", - "VIN_C_19", - "VIN_C_2", - "VIN_C_20", - "VIN_C_21", - "VIN_C_22", - "VIN_C_23", - "VIN_C_24", - "VIN_C_25", - "VIN_C_26", - "VIN_C_27", - "VIN_C_28", - "VIN_C_29", - "VIN_C_3", - "VIN_C_30", - "VIN_C_31", - "VIN_C_32", - "VIN_C_33", - "VIN_C_34", - "VIN_C_35", - "VIN_C_36", - "VIN_C_37", - "VIN_C_38", - "VIN_C_39", - "VIN_C_4", - "VIN_C_40", - "VIN_C_41", - "VIN_C_42", - "VIN_C_43", - "VIN_C_44", - "VIN_C_45", - "VIN_C_46", - "VIN_C_47", - "VIN_C_48", - "VIN_C_49", - "VIN_C_5", - "VIN_C_50", - "VIN_C_6", - "VIN_C_7", - "VIN_C_8", - "VIN_C_9", - "VIN_F_1", - "VIN_F_10", - "VIN_F_11", - "VIN_F_12", - "VIN_F_13", - "VIN_F_14", - "VIN_F_15", - "VIN_F_16", - "VIN_F_17", - "VIN_F_18", - "VIN_F_19", - "VIN_F_2", - "VIN_F_20", - "VIN_F_21", - "VIN_F_22", - "VIN_F_23", - "VIN_F_24", - "VIN_F_25", - "VIN_F_26", - "VIN_F_27", - "VIN_F_28", - "VIN_F_29", - "VIN_F_3", - "VIN_F_30", - "VIN_F_31", - "VIN_F_32", - "VIN_F_33", - "VIN_F_34", - "VIN_F_35", - "VIN_F_36", - "VIN_F_37", - "VIN_F_38", - "VIN_F_39", - "VIN_F_4", - "VIN_F_40", - "VIN_F_41", - "VIN_F_42", - "VIN_F_43", - "VIN_F_44", - "VIN_F_45", - "VIN_F_46", - "VIN_F_47", - "VIN_F_48", - "VIN_F_49", - "VIN_F_5", - "VIN_F_50", - "VIN_F_6", - "VIN_F_7", - "VIN_F_8", - "VIN_F_9", - "VIN_M_1", - "VIN_M_10", - "VIN_M_11", - "VIN_M_12", - "VIN_M_13", - "VIN_M_14", - "VIN_M_15", - "VIN_M_16", - "VIN_M_17", - "VIN_M_18", - "VIN_M_19", - "VIN_M_2", - "VIN_M_20", - "VIN_M_21", - "VIN_M_22", - "VIN_M_23", - "VIN_M_24", - "VIN_M_25", - "VIN_M_26", - "VIN_M_27", - "VIN_M_28", - "VIN_M_29", - "VIN_M_3", - "VIN_M_30", - "VIN_M_31", - "VIN_M_32", - "VIN_M_33", - "VIN_M_34", - "VIN_M_35", - "VIN_M_36", - "VIN_M_37", - "VIN_M_38", - "VIN_M_39", - "VIN_M_4", - "VIN_M_40", - "VIN_M_41", - "VIN_M_42", - "VIN_M_43", - "VIN_M_44", - "VIN_M_45", - "VIN_M_46", - "VIN_M_47", - "VIN_M_48", - "VIN_M_49", - "VIN_M_5", - "VIN_M_50", - "VIN_M_6", - "VIN_M_7", - "VIN_M_8", - "VIN_M_9", - "WED_C_1", - "WED_C_10", - "WED_C_11", - "WED_C_12", - "WED_C_13", - "WED_C_14", - "WED_C_15", - "WED_C_16", - "WED_C_17", - "WED_C_18", - "WED_C_19", - "WED_C_2", - "WED_C_20", - "WED_C_21", - "WED_C_22", - "WED_C_23", - "WED_C_24", - "WED_C_25", - "WED_C_3", - "WED_C_4", - "WED_C_5", - "WED_C_6", - "WED_C_7", - "WED_C_8", - "WED_C_9", - "WED_F_1", - "WED_F_10", - "WED_F_11", - "WED_F_12", - "WED_F_13", - "WED_F_14", - "WED_F_15", - "WED_F_16", - "WED_F_17", - "WED_F_18", - "WED_F_19", - "WED_F_2", - "WED_F_20", - "WED_F_21", - "WED_F_22", - "WED_F_23", - "WED_F_24", - "WED_F_25", - "WED_F_3", - "WED_F_4", - "WED_F_5", - "WED_F_6", - "WED_F_7", - "WED_F_8", - "WED_F_9", - "WED_M_1", - "WED_M_10", - "WED_M_11", - "WED_M_12", - "WED_M_13", - "WED_M_14", - "WED_M_15", - "WED_M_16", - "WED_M_17", - "WED_M_18", - "WED_M_19", - "WED_M_2", - "WED_M_20", - "WED_M_21", - "WED_M_22", - "WED_M_23", - "WED_M_24", - "WED_M_25", - "WED_M_3", - "WED_M_4", - "WED_M_5", - "WED_M_6", - "WED_M_7", - "WED_M_8", - "WED_M_9", - "black_dress", - "black_saree", - "blue_dress", - "casual_jeans", - "floral_dress", - "formal_suit", - "green_dress", - "pink_dress", - "red_dress", - "white_dress", - "yellow_dress" - ], - "resp": "image/png", - "subs": [], - "curl": "" - } - ] - } - ] - }, - { - "id": "sec-flux-kontext", - "key": "flux-kontext", - "icon": "\u26a1", - "title": "FLUX Kontext Stylization", - "tag": "Multi-Preset Kontext", - "lead": "Style transfer and generative transformation using FLUX.1-dev contextual guidance. Supports dozens of verified aesthetic prompts for hairstyles, glasses, retro polaroid looks, sculptures, and 3D figurine caricatures.", - "port": "8000 (Kontext: 8012)", - "hue": 335, - "eps": [ - { - "id": "api-stable-diffusion-headshot", - "api_key": "Stable_Diffusion_Headshot", - "api_ip_link": "https://apigp0006.creinnovations.in/apis/flxk/flux/headshots/", - "title": "Stable_Diffusion_Headshot", - "method": "POST", - "path": "/flux/headshots/image1_1/", - "full_url": "https://apigp0006.creinnovations.in/apis/flxk/flux/headshots/image1_1/", - "port": "8000", - "resp": "image/png", - "summary": "Transforms casual selfies into executive corporate and studio headshots.", - "desc": "Applies professional studio lighting, business attire, and soft-focus office backdrops across 80 presets (40 Female, 40 Male).", - "params": [ - { - "n": "image0", - "al": "image", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Input face portrait image." - }, - { - "n": "effectId", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Headshot preset ID. Can be direct 'female_Bg1'-'Bg40' / 'male_Bg1'-'Bg40', or 'Bg1'-'Bg40' if category/gender is specified." - }, - { - "n": "category", - "al": "gender", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "None", - "ds": "Optional gender parameter: 'female' or 'male'." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "'abcdef'", - "ds": "\ud83d\udd11 Authentication: API secret key ('abcdef')." - } - ], - "chips": [ - "female_Bg1", - "female_Bg10", - "female_Bg11", - "female_Bg12", - "female_Bg13", - "female_Bg14", - "female_Bg15", - "female_Bg16", - "female_Bg17", - "female_Bg18", - "female_Bg19", - "female_Bg2", - "female_Bg20", - "female_Bg21", - "female_Bg22", - "female_Bg23", - "female_Bg24", - "female_Bg25", - "female_Bg26", - "female_Bg27", - "female_Bg28", - "female_Bg29", - "female_Bg3", - "female_Bg30", - "female_Bg31", - "female_Bg32", - "female_Bg33", - "female_Bg34", - "female_Bg35", - "female_Bg36", - "female_Bg37", - "female_Bg38", - "female_Bg39", - "female_Bg4", - "female_Bg40", - "female_Bg5", - "female_Bg6", - "female_Bg7", - "female_Bg8", - "female_Bg9", - "male_Bg1", - "male_Bg10", - "male_Bg11", - "male_Bg12", - "male_Bg13", - "male_Bg14", - "male_Bg15", - "male_Bg16", - "male_Bg17", - "male_Bg18", - "male_Bg19", - "male_Bg2", - "male_Bg20", - "male_Bg21", - "male_Bg22", - "male_Bg23", - "male_Bg24", - "male_Bg25", - "male_Bg26", - "male_Bg27", - "male_Bg28", - "male_Bg29", - "male_Bg3", - "male_Bg30", - "male_Bg31", - "male_Bg32", - "male_Bg33", - "male_Bg34", - "male_Bg35", - "male_Bg36", - "male_Bg37", - "male_Bg38", - "male_Bg39", - "male_Bg4", - "male_Bg40", - "male_Bg5", - "male_Bg6", - "male_Bg7", - "male_Bg8", - "male_Bg9" - ], - "subs": [], - "curl": "", - "endpoints": [ - { - "id": "fk-headshots", - "method": "POST", - "subpath": "image1_1/", - "full_url": "https://apigp0006.creinnovations.in/apis/flxk/flux/headshots/image1_1/", - "path": "/flux/headshots/image1_1/", - "title": "FLUX.1-Kontext Professional Studio Headshots", - "summary": "Transforms casual selfies into executive corporate and studio headshots.", - "desc": "Applies professional studio lighting, business attire, and soft-focus office backdrops across 80 presets (40 Female, 40 Male).", - "params": [ - { - "n": "image0", - "al": "image", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Input face portrait image." - }, - { - "n": "effectId", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Headshot preset ID. Can be direct 'female_Bg1'-'Bg40' / 'male_Bg1'-'Bg40', or 'Bg1'-'Bg40' if category/gender is specified." - }, - { - "n": "category", - "al": "gender", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "None", - "ds": "Optional gender parameter: 'female' or 'male'." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "'abcdef'", - "ds": "\ud83d\udd11 Authentication: API secret key ('abcdef')." - } - ], - "chips": [ - "female_Bg1", - "female_Bg10", - "female_Bg11", - "female_Bg12", - "female_Bg13", - "female_Bg14", - "female_Bg15", - "female_Bg16", - "female_Bg17", - "female_Bg18", - "female_Bg19", - "female_Bg2", - "female_Bg20", - "female_Bg21", - "female_Bg22", - "female_Bg23", - "female_Bg24", - "female_Bg25", - "female_Bg26", - "female_Bg27", - "female_Bg28", - "female_Bg29", - "female_Bg3", - "female_Bg30", - "female_Bg31", - "female_Bg32", - "female_Bg33", - "female_Bg34", - "female_Bg35", - "female_Bg36", - "female_Bg37", - "female_Bg38", - "female_Bg39", - "female_Bg4", - "female_Bg40", - "female_Bg5", - "female_Bg6", - "female_Bg7", - "female_Bg8", - "female_Bg9", - "male_Bg1", - "male_Bg10", - "male_Bg11", - "male_Bg12", - "male_Bg13", - "male_Bg14", - "male_Bg15", - "male_Bg16", - "male_Bg17", - "male_Bg18", - "male_Bg19", - "male_Bg2", - "male_Bg20", - "male_Bg21", - "male_Bg22", - "male_Bg23", - "male_Bg24", - "male_Bg25", - "male_Bg26", - "male_Bg27", - "male_Bg28", - "male_Bg29", - "male_Bg3", - "male_Bg30", - "male_Bg31", - "male_Bg32", - "male_Bg33", - "male_Bg34", - "male_Bg35", - "male_Bg36", - "male_Bg37", - "male_Bg38", - "male_Bg39", - "male_Bg4", - "male_Bg40", - "male_Bg5", - "male_Bg6", - "male_Bg7", - "male_Bg8", - "male_Bg9" - ], - "resp": "image/png", - "subs": [], - "curl": "" - } - ] - }, - { - "id": "api-stable-diffusion-head-cartoon-effects", - "api_key": "Stable_Diffusion_Head_Cartoon_Effects", - "api_ip_link": "https://apigp0006.creinnovations.in/apis/flxk/flux/head_cartoon_effect/", - "title": "Stable_Diffusion_Head_Cartoon_Effects", - "method": "POST", - "path": "/flux/head_cartoon_effect/image/", - "full_url": "https://apigp0006.creinnovations.in/apis/flxk/flux/head_cartoon_effect/image/", - "port": "8000", - "resp": "image/png", - "summary": "Whole-context animated 3D cartoon avatar conversion with C12 preset.", - "desc": "Renders facial features and hair into stylized CGI animation art while preserving recognizable facial identity.", - "params": [ - { - "n": "image0", - "al": "image, src (base64)", - "ty": "file or string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Input facial portrait image." - }, - { - "n": "colorId", - "al": "effectId", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "'C12'", - "ds": "Cartoon style encoding ID ('C12')." - }, - { - "n": "gender", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "'Female'", - "ds": "Subject gender: 'Female' or 'Male'." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "'abcdef'", - "ds": "\ud83d\udd11 Authentication: API secret key ('abcdef')." - } - ], - "chips": [ - "Female_C12", - "Male_C12" - ], - "subs": [], - "curl": "", - "endpoints": [ - { - "id": "fk-head-cartoon-effect", - "method": "POST", - "subpath": "image/", - "full_url": "https://apigp0006.creinnovations.in/apis/flxk/flux/head_cartoon_effect/image/", - "path": "/flux/head_cartoon_effect/image/", - "title": "FLUX.1-Kontext Head Cartoon Effect", - "summary": "Whole-context animated 3D cartoon avatar conversion with C12 preset.", - "desc": "Renders facial features and hair into stylized CGI animation art while preserving recognizable facial identity.", - "params": [ - { - "n": "image0", - "al": "image, src (base64)", - "ty": "file or string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Input facial portrait image." - }, - { - "n": "colorId", - "al": "effectId", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "'C12'", - "ds": "Cartoon style encoding ID ('C12')." - }, - { - "n": "gender", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "'Female'", - "ds": "Subject gender: 'Female' or 'Male'." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "'abcdef'", - "ds": "\ud83d\udd11 Authentication: API secret key ('abcdef')." - } - ], - "chips": [ - "Female_C12", - "Male_C12" - ], - "resp": "image/png", - "subs": [], - "curl": "" - } - ] - }, - { - "id": "api-stable-diffusion-modified-head-cartoon-effects", - "api_key": "Stable_Diffusion_Modified_Head_Cartoon_Effects", - "api_ip_link": "https://apigp0006.creinnovations.in/apis/flxk/flux/modified_head_cartoon_effects", - "title": "Stable_Diffusion_Modified_Head_Cartoon_Effects", - "method": "POST", - "path": "/flux/modified_head_cartoon_effects/image/", - "full_url": "https://apigp0006.creinnovations.in/apis/flxk/flux/modified_head_cartoon_effects/image/", - "port": "8000", - "resp": "image/png", - "summary": "Advanced 3D animation shaders with C7 & C8 character presets.", - "desc": "Enhances characters with refined studio lighting and subsurface skin tones for male and female characters.", - "params": [ - { - "n": "image0", - "al": "image, src (base64)", - "ty": "file or string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Input portrait image." - }, - { - "n": "colorId", - "al": "effectId", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "'C7'", - "ds": "Style ID: 'C7' or 'C8'." - }, - { - "n": "gender", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "'Female'", - "ds": "Subject gender: 'Female' or 'Male'." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "'abcdef'", - "ds": "\ud83d\udd11 Authentication: API secret key ('abcdef')." - } - ], - "chips": [ - "Female_C7", - "Female_C8", - "Male_C7", - "Male_C8" - ], - "subs": [], - "curl": "", - "endpoints": [ - { - "id": "fk-modified-head-cartoon-effects", - "method": "POST", - "subpath": "image/", - "full_url": "https://apigp0006.creinnovations.in/apis/flxk/flux/modified_head_cartoon_effects/image/", - "path": "/flux/modified_head_cartoon_effects/image/", - "title": "FLUX.1-Kontext Modified Head Cartoon Effects", - "summary": "Advanced 3D animation shaders with C7 & C8 character presets.", - "desc": "Enhances characters with refined studio lighting and subsurface skin tones for male and female characters.", - "params": [ - { - "n": "image0", - "al": "image, src (base64)", - "ty": "file or string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Input portrait image." - }, - { - "n": "colorId", - "al": "effectId", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "'C7'", - "ds": "Style ID: 'C7' or 'C8'." - }, - { - "n": "gender", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "'Female'", - "ds": "Subject gender: 'Female' or 'Male'." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "'abcdef'", - "ds": "\ud83d\udd11 Authentication: API secret key ('abcdef')." - } - ], - "chips": [ - "Female_C7", - "Female_C8", - "Male_C7", - "Male_C8" - ], - "resp": "image/png", - "subs": [], - "curl": "" - } - ] - }, - { - "id": "api-stable-diffusion-comic-coverpage-generator", - "api_key": "Stable_Diffusion_Comic_Coverpage_Generator", - "api_ip_link": "https://apigp0006.creinnovations.in/apis/flxk/flux/comic_cover/", - "title": "Stable_Diffusion_Comic_Coverpage_Generator", - "method": "POST", - "path": "/flux/comic_cover/image/", - "full_url": "https://apigp0006.creinnovations.in/apis/flxk/flux/comic_cover/image/", - "port": "8000", - "resp": "image/png", - "summary": "Full-context vintage comic book cover transformation.", - "desc": "Renders subjects into retro comic covers with dynamic poses, comic typography, halftone dot patterns, and illustrated backgrounds.", - "params": [ - { - "n": "image0", - "al": "image", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Input portrait image." - }, - { - "n": "effectId", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "'ComicCover1'", - "ds": "Comic style ID ('ComicCover1' to 'ComicCover16' for female, 'ComicCover1' to 'ComicCover10' for male)." - }, - { - "n": "gender", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "'female'", - "ds": "Gender branch: 'female' or 'male'." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "'abcdef'", - "ds": "\ud83d\udd11 Authentication: API secret key ('abcdef')." - } - ], - "chips": [ - "female_ComicCover1", - "female_ComicCover10", - "female_ComicCover11", - "female_ComicCover12", - "female_ComicCover13", - "female_ComicCover14", - "female_ComicCover15", - "female_ComicCover16", - "female_ComicCover2", - "female_ComicCover3", - "female_ComicCover4", - "female_ComicCover5", - "female_ComicCover6", - "female_ComicCover7", - "female_ComicCover8", - "female_ComicCover9", - "male_ComicCover1", - "male_ComicCover10", - "male_ComicCover2", - "male_ComicCover3", - "male_ComicCover4", - "male_ComicCover5", - "male_ComicCover6", - "male_ComicCover7", - "male_ComicCover8", - "male_ComicCover9" - ], - "subs": [], - "curl": "", - "endpoints": [ - { - "id": "fk-comic-cover", - "method": "POST", - "subpath": "image/", - "full_url": "https://apigp0006.creinnovations.in/apis/flxk/flux/comic_cover/image/", - "path": "/flux/comic_cover/image/", - "title": "FLUX.1-Kontext Comic Cover Art", - "summary": "Full-context vintage comic book cover transformation.", - "desc": "Renders subjects into retro comic covers with dynamic poses, comic typography, halftone dot patterns, and illustrated backgrounds.", - "params": [ - { - "n": "image0", - "al": "image", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Input portrait image." - }, - { - "n": "effectId", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "'ComicCover1'", - "ds": "Comic style ID ('ComicCover1' to 'ComicCover16' for female, 'ComicCover1' to 'ComicCover10' for male)." - }, - { - "n": "gender", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "'female'", - "ds": "Gender branch: 'female' or 'male'." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "'abcdef'", - "ds": "\ud83d\udd11 Authentication: API secret key ('abcdef')." - } - ], - "chips": [ - "female_ComicCover1", - "female_ComicCover10", - "female_ComicCover11", - "female_ComicCover12", - "female_ComicCover13", - "female_ComicCover14", - "female_ComicCover15", - "female_ComicCover16", - "female_ComicCover2", - "female_ComicCover3", - "female_ComicCover4", - "female_ComicCover5", - "female_ComicCover6", - "female_ComicCover7", - "female_ComicCover8", - "female_ComicCover9", - "male_ComicCover1", - "male_ComicCover10", - "male_ComicCover2", - "male_ComicCover3", - "male_ComicCover4", - "male_ComicCover5", - "male_ComicCover6", - "male_ComicCover7", - "male_ComicCover8", - "male_ComicCover9" - ], - "resp": "image/png", - "subs": [], - "curl": "" - } - ] - }, - { - "id": "api-flux-hairstyles", - "api_key": "Flux_Hairstyles", - "api_ip_link": "https://apigp0006.creinnovations.in/apis/flxk/flux/hairstyles/", - "title": "Flux_Hairstyles", - "method": "POST", - "path": "/flux/hairstyles/image/", - "full_url": "https://apigp0006.creinnovations.in/apis/flxk/flux/hairstyles/image/", - "port": "8000", - "resp": "image/png", - "summary": "Full-context hairstyle generation with identity preservation.", - "desc": "Uses FLUX.1-Kontext to adapt head shape, lighting, and hair flow for 60 contemporary male and female hair cuts. Internal pattern: '{category}_{effectId}'.", - "params": [ - { - "n": "image0", - "al": "image", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Input portrait image." - }, - { - "n": "category", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Gender category: 'female' or 'male'." - }, - { - "n": "effectId", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Preset ID: 'HF1'-'HF30' for female styles, 'HM1'-'HM30' for male styles." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "'abcdef'", - "ds": "\ud83d\udd11 Authentication: API secret key ('abcdef')." - } - ], - "chips": [ - "female_HF1", - "female_HF10", - "female_HF11", - "female_HF12", - "female_HF13", - "female_HF14", - "female_HF15", - "female_HF16", - "female_HF17", - "female_HF18", - "female_HF19", - "female_HF2", - "female_HF20", - "female_HF21", - "female_HF22", - "female_HF23", - "female_HF24", - "female_HF25", - "female_HF26", - "female_HF27", - "female_HF28", - "female_HF29", - "female_HF3", - "female_HF30", - "female_HF4", - "female_HF5", - "female_HF6", - "female_HF7", - "female_HF8", - "female_HF9", - "male_HM1", - "male_HM10", - "male_HM11", - "male_HM12", - "male_HM13", - "male_HM14", - "male_HM15", - "male_HM16", - "male_HM17", - "male_HM18", - "male_HM19", - "male_HM2", - "male_HM20", - "male_HM21", - "male_HM22", - "male_HM23", - "male_HM24", - "male_HM25", - "male_HM26", - "male_HM27", - "male_HM28", - "male_HM29", - "male_HM3", - "male_HM30", - "male_HM4", - "male_HM5", - "male_HM6", - "male_HM7", - "male_HM8", - "male_HM9" - ], - "subs": [], - "curl": "", - "endpoints": [ - { - "id": "fk-hairstyles", - "method": "POST", - "subpath": "image/", - "full_url": "https://apigp0006.creinnovations.in/apis/flxk/flux/hairstyles/image/", - "path": "/flux/hairstyles/image/", - "title": "FLUX.1-Kontext Hairstyles Inpainting", - "summary": "Full-context hairstyle generation with identity preservation.", - "desc": "Uses FLUX.1-Kontext to adapt head shape, lighting, and hair flow for 60 contemporary male and female hair cuts. Internal pattern: '{category}_{effectId}'.", - "params": [ - { - "n": "image0", - "al": "image", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Input portrait image." - }, - { - "n": "category", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Gender category: 'female' or 'male'." - }, - { - "n": "effectId", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Preset ID: 'HF1'-'HF30' for female styles, 'HM1'-'HM30' for male styles." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "'abcdef'", - "ds": "\ud83d\udd11 Authentication: API secret key ('abcdef')." - } - ], - "chips": [ - "female_HF1", - "female_HF10", - "female_HF11", - "female_HF12", - "female_HF13", - "female_HF14", - "female_HF15", - "female_HF16", - "female_HF17", - "female_HF18", - "female_HF19", - "female_HF2", - "female_HF20", - "female_HF21", - "female_HF22", - "female_HF23", - "female_HF24", - "female_HF25", - "female_HF26", - "female_HF27", - "female_HF28", - "female_HF29", - "female_HF3", - "female_HF30", - "female_HF4", - "female_HF5", - "female_HF6", - "female_HF7", - "female_HF8", - "female_HF9", - "male_HM1", - "male_HM10", - "male_HM11", - "male_HM12", - "male_HM13", - "male_HM14", - "male_HM15", - "male_HM16", - "male_HM17", - "male_HM18", - "male_HM19", - "male_HM2", - "male_HM20", - "male_HM21", - "male_HM22", - "male_HM23", - "male_HM24", - "male_HM25", - "male_HM26", - "male_HM27", - "male_HM28", - "male_HM29", - "male_HM3", - "male_HM30", - "male_HM4", - "male_HM5", - "male_HM6", - "male_HM7", - "male_HM8", - "male_HM9" - ], - "resp": "image/png", - "subs": [], - "curl": "" - } - ] - }, - { - "id": "api-flux-sculpture-effect", - "api_key": "Flux_Sculpture_Effect", - "api_ip_link": "https://apigp0006.creinnovations.in/apis/flxk/flux/sculptures/", - "title": "Flux_Sculpture_Effect", - "method": "POST", - "path": "/flux/sculptures/image/", - "full_url": "https://apigp0006.creinnovations.in/apis/flxk/flux/sculptures/image/", - "port": "8000", - "resp": "image/png", - "summary": "Transforms human subjects into classical fine-art statues and carved sculptures.", - "desc": "Applies marble, bronze, jade, clay, granite, porcelain, and stone textures with museum gallery spotlighting across 26 verified materials.", - "params": [ - { - "n": "image0", - "al": "image", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Input portrait image." - }, - { - "n": "effectId", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Sculpture material preset ID: 'E1' to 'E26'." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "'abcdef'", - "ds": "\ud83d\udd11 Authentication: API secret key ('abcdef')." - } - ], - "chips": [ - "E1", - "E10", - "E11", - "E12", - "E13", - "E14", - "E15", - "E16", - "E17", - "E18", - "E19", - "E2", - "E20", - "E21", - "E22", - "E23", - "E24", - "E25", - "E26", - "E3", - "E4", - "E5", - "E6", - "E7", - "E8", - "E9" - ], - "subs": [], - "curl": "", - "endpoints": [ - { - "id": "fk-sculptures", - "method": "POST", - "subpath": "image/", - "full_url": "https://apigp0006.creinnovations.in/apis/flxk/flux/sculptures/image/", - "path": "/flux/sculptures/image/", - "title": "FLUX.1-Kontext Classical & Modern Sculpture Stylization", - "summary": "Transforms human subjects into classical fine-art statues and carved sculptures.", - "desc": "Applies marble, bronze, jade, clay, granite, porcelain, and stone textures with museum gallery spotlighting across 26 verified materials.", - "params": [ - { - "n": "image0", - "al": "image", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Input portrait image." - }, - { - "n": "effectId", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Sculpture material preset ID: 'E1' to 'E26'." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "'abcdef'", - "ds": "\ud83d\udd11 Authentication: API secret key ('abcdef')." - } - ], - "chips": [ - "E1", - "E10", - "E11", - "E12", - "E13", - "E14", - "E15", - "E16", - "E17", - "E18", - "E19", - "E2", - "E20", - "E21", - "E22", - "E23", - "E24", - "E25", - "E26", - "E3", - "E4", - "E5", - "E6", - "E7", - "E8", - "E9" - ], - "resp": "image/png", - "subs": [], - "curl": "" - } - ] - }, - { - "id": "api-flux-silhouette-effect", - "api_key": "Flux_Silhouette_Effect", - "api_ip_link": "https://apigp0006.creinnovations.in/apis/flxk/flux/silhouette/", - "title": "Flux_Silhouette_Effect", - "method": "POST", - "path": "/flux/silhouette/image/", - "full_url": "https://apigp0006.creinnovations.in/apis/flxk/flux/silhouette/image/", - "port": "8000", - "resp": "image/png", - "summary": "Transforms portraits into dramatic artistic back-lit sunset silhouettes.", - "desc": "Applies dramatic rim lighting, sunset gradients, and starry silhouettes across 150 verified presets split by demographic category. Internal pattern: '{category}_{effectId}'.", - "params": [ - { - "n": "image0", - "al": "image", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Input photograph with clear subject outline." - }, - { - "n": "category", - "al": "gender", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Demographic category: 'men', 'women', or 'couple'." - }, - { - "n": "effectId", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Preset ID: 'E1' to 'E50'." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "'abcdef'", - "ds": "\ud83d\udd11 Authentication: API secret key ('abcdef')." - } - ], - "chips": [ - "couple_E1", - "couple_E10", - "couple_E11", - "couple_E12", - "couple_E13", - "couple_E14", - "couple_E15", - "couple_E16", - "couple_E17", - "couple_E18", - "couple_E19", - "couple_E2", - "couple_E20", - "couple_E21", - "couple_E22", - "couple_E23", - "couple_E24", - "couple_E25", - "couple_E26", - "couple_E27", - "couple_E28", - "couple_E29", - "couple_E3", - "couple_E30", - "couple_E31", - "couple_E32", - "couple_E33", - "couple_E34", - "couple_E35", - "couple_E36", - "couple_E37", - "couple_E38", - "couple_E39", - "couple_E4", - "couple_E40", - "couple_E41", - "couple_E42", - "couple_E43", - "couple_E44", - "couple_E45", - "couple_E46", - "couple_E47", - "couple_E48", - "couple_E49", - "couple_E5", - "couple_E50", - "couple_E6", - "couple_E7", - "couple_E8", - "couple_E9", - "men_E1", - "men_E10", - "men_E11", - "men_E12", - "men_E13", - "men_E14", - "men_E15", - "men_E16", - "men_E17", - "men_E18", - "men_E19", - "men_E2", - "men_E20", - "men_E21", - "men_E22", - "men_E23", - "men_E24", - "men_E25", - "men_E26", - "men_E27", - "men_E28", - "men_E29", - "men_E3", - "men_E30", - "men_E31", - "men_E32", - "men_E33", - "men_E34", - "men_E35", - "men_E36", - "men_E37", - "men_E38", - "men_E39", - "men_E4", - "men_E40", - "men_E41", - "men_E42", - "men_E43", - "men_E44", - "men_E45", - "men_E46", - "men_E47", - "men_E48", - "men_E49", - "men_E5", - "men_E50", - "men_E6", - "men_E7", - "men_E8", - "men_E9", - "women_E1", - "women_E10", - "women_E11", - "women_E12", - "women_E13", - "women_E14", - "women_E15", - "women_E16", - "women_E17", - "women_E18", - "women_E19", - "women_E2", - "women_E20", - "women_E21", - "women_E22", - "women_E23", - "women_E24", - "women_E25", - "women_E26", - "women_E27", - "women_E28", - "women_E29", - "women_E3", - "women_E30", - "women_E31", - "women_E32", - "women_E33", - "women_E34", - "women_E35", - "women_E36", - "women_E37", - "women_E38", - "women_E39", - "women_E4", - "women_E40", - "women_E41", - "women_E42", - "women_E43", - "women_E44", - "women_E45", - "women_E46", - "women_E47", - "women_E48", - "women_E49", - "women_E5", - "women_E50", - "women_E6", - "women_E7", - "women_E8", - "women_E9" - ], - "subs": [], - "curl": "", - "endpoints": [ - { - "id": "fk-silhouette", - "method": "POST", - "subpath": "image/", - "full_url": "https://apigp0006.creinnovations.in/apis/flxk/flux/silhouette/image/", - "path": "/flux/silhouette/image/", - "title": "FLUX.1-Kontext Artistic Silhouette Maker", - "summary": "Transforms portraits into dramatic artistic back-lit sunset silhouettes.", - "desc": "Applies dramatic rim lighting, sunset gradients, and starry silhouettes across 150 verified presets split by demographic category. Internal pattern: '{category}_{effectId}'.", - "params": [ - { - "n": "image0", - "al": "image", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Input photograph with clear subject outline." - }, - { - "n": "category", - "al": "gender", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Demographic category: 'men', 'women', or 'couple'." - }, - { - "n": "effectId", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Preset ID: 'E1' to 'E50'." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "'abcdef'", - "ds": "\ud83d\udd11 Authentication: API secret key ('abcdef')." - } - ], - "chips": [ - "couple_E1", - "couple_E10", - "couple_E11", - "couple_E12", - "couple_E13", - "couple_E14", - "couple_E15", - "couple_E16", - "couple_E17", - "couple_E18", - "couple_E19", - "couple_E2", - "couple_E20", - "couple_E21", - "couple_E22", - "couple_E23", - "couple_E24", - "couple_E25", - "couple_E26", - "couple_E27", - "couple_E28", - "couple_E29", - "couple_E3", - "couple_E30", - "couple_E31", - "couple_E32", - "couple_E33", - "couple_E34", - "couple_E35", - "couple_E36", - "couple_E37", - "couple_E38", - "couple_E39", - "couple_E4", - "couple_E40", - "couple_E41", - "couple_E42", - "couple_E43", - "couple_E44", - "couple_E45", - "couple_E46", - "couple_E47", - "couple_E48", - "couple_E49", - "couple_E5", - "couple_E50", - "couple_E6", - "couple_E7", - "couple_E8", - "couple_E9", - "men_E1", - "men_E10", - "men_E11", - "men_E12", - "men_E13", - "men_E14", - "men_E15", - "men_E16", - "men_E17", - "men_E18", - "men_E19", - "men_E2", - "men_E20", - "men_E21", - "men_E22", - "men_E23", - "men_E24", - "men_E25", - "men_E26", - "men_E27", - "men_E28", - "men_E29", - "men_E3", - "men_E30", - "men_E31", - "men_E32", - "men_E33", - "men_E34", - "men_E35", - "men_E36", - "men_E37", - "men_E38", - "men_E39", - "men_E4", - "men_E40", - "men_E41", - "men_E42", - "men_E43", - "men_E44", - "men_E45", - "men_E46", - "men_E47", - "men_E48", - "men_E49", - "men_E5", - "men_E50", - "men_E6", - "men_E7", - "men_E8", - "men_E9", - "women_E1", - "women_E10", - "women_E11", - "women_E12", - "women_E13", - "women_E14", - "women_E15", - "women_E16", - "women_E17", - "women_E18", - "women_E19", - "women_E2", - "women_E20", - "women_E21", - "women_E22", - "women_E23", - "women_E24", - "women_E25", - "women_E26", - "women_E27", - "women_E28", - "women_E29", - "women_E3", - "women_E30", - "women_E31", - "women_E32", - "women_E33", - "women_E34", - "women_E35", - "women_E36", - "women_E37", - "women_E38", - "women_E39", - "women_E4", - "women_E40", - "women_E41", - "women_E42", - "women_E43", - "women_E44", - "women_E45", - "women_E46", - "women_E47", - "women_E48", - "women_E49", - "women_E5", - "women_E50", - "women_E6", - "women_E7", - "women_E8", - "women_E9" - ], - "resp": "image/png", - "subs": [], - "curl": "" - } - ] - }, - { - "id": "api-flux-glasses", - "api_key": "Flux_Glasses", - "api_ip_link": "https://apigp0006.creinnovations.in/apis/flxk/flux/glasses_maker/", - "title": "Flux_Glasses", - "method": "POST", - "path": "/flux/glasses_maker/image/", - "full_url": "https://apigp0006.creinnovations.in/apis/flxk/flux/glasses_maker/image/", - "port": "8000", - "resp": "image/png", - "summary": "Renders tailored designer eyewear and luxury sunglasses on faces.", - "desc": "Generates anatomically fitted eyeglasses, wireframes, aviators, cat-eye, and horn-rimmed glasses across 45 verified styles (20 Men, 25 Women).", - "params": [ - { - "n": "image0", - "al": "image", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Input face portrait image." - }, - { - "n": "effectId", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Eyewear preset ID: 'EM1'-'EM20' for men, 'EW1'-'EW25' for women." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "'abcdef'", - "ds": "\ud83d\udd11 Authentication: API secret key ('abcdef')." - } - ], - "chips": [ - "EM1", - "EM10", - "EM11", - "EM12", - "EM13", - "EM14", - "EM15", - "EM16", - "EM17", - "EM18", - "EM19", - "EM2", - "EM20", - "EM3", - "EM4", - "EM5", - "EM6", - "EM7", - "EM8", - "EM9", - "EW1", - "EW10", - "EW11", - "EW12", - "EW13", - "EW14", - "EW15", - "EW16", - "EW17", - "EW18", - "EW19", - "EW2", - "EW20", - "EW21", - "EW22", - "EW23", - "EW24", - "EW25", - "EW3", - "EW4", - "EW5", - "EW6", - "EW7", - "EW8", - "EW9" - ], - "subs": [], - "curl": "", - "endpoints": [ - { - "id": "fk-glasses-maker", - "method": "POST", - "subpath": "image/", - "full_url": "https://apigp0006.creinnovations.in/apis/flxk/flux/glasses_maker/image/", - "path": "/flux/glasses_maker/image/", - "title": "FLUX.1-Kontext Eyewear & Sunglasses Stylizer", - "summary": "Renders tailored designer eyewear and luxury sunglasses on faces.", - "desc": "Generates anatomically fitted eyeglasses, wireframes, aviators, cat-eye, and horn-rimmed glasses across 45 verified styles (20 Men, 25 Women).", - "params": [ - { - "n": "image0", - "al": "image", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Input face portrait image." - }, - { - "n": "effectId", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Eyewear preset ID: 'EM1'-'EM20' for men, 'EW1'-'EW25' for women." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "'abcdef'", - "ds": "\ud83d\udd11 Authentication: API secret key ('abcdef')." - } - ], - "chips": [ - "EM1", - "EM10", - "EM11", - "EM12", - "EM13", - "EM14", - "EM15", - "EM16", - "EM17", - "EM18", - "EM19", - "EM2", - "EM20", - "EM3", - "EM4", - "EM5", - "EM6", - "EM7", - "EM8", - "EM9", - "EW1", - "EW10", - "EW11", - "EW12", - "EW13", - "EW14", - "EW15", - "EW16", - "EW17", - "EW18", - "EW19", - "EW2", - "EW20", - "EW21", - "EW22", - "EW23", - "EW24", - "EW25", - "EW3", - "EW4", - "EW5", - "EW6", - "EW7", - "EW8", - "EW9" - ], - "resp": "image/png", - "subs": [], - "curl": "" - } - ] - }, - { - "id": "api-flux-cartoon", - "api_key": "Flux_Cartoon", - "api_ip_link": "https://apigp0006.creinnovations.in/apis/flxk/flux/cartoon/", - "title": "Flux_Cartoon", - "method": "POST", - "path": "/flux/cartoon/image/", - "full_url": "https://apigp0006.creinnovations.in/apis/flxk/flux/cartoon/image/", - "port": "8000", - "resp": "image/png", - "summary": "Massive library of 215 verified anime, 3D CGI, stylized cartoon aesthetics.", - "desc": "Transforms entire scene into anime, CGI toon, watercolor cartoon, or comic lineart. Verification confirmed 215 pairs: E1-E120 (120), T41-T106 (25), and C41-C110 (70).", - "params": [ - { - "n": "image0", - "al": "image", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Input photograph." - }, - { - "n": "effectId", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Cartoon preset ID: 'E1'-'E120', 'T41'-'T106' (25 presets), or 'C41'-'C110' (70 presets)." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "'abcdef'", - "ds": "\ud83d\udd11 Authentication: API secret key ('abcdef')." - } - ], - "chips": [ - "C100", - "C101", - "C102", - "C103", - "C104", - "C105", - "C106", - "C107", - "C108", - "C109", - "C110", - "C41", - "C42", - "C43", - "C44", - "C45", - "C46", - "C47", - "C48", - "C49", - "C50", - "C51", - "C52", - "C53", - "C54", - "C55", - "C56", - "C57", - "C58", - "C59", - "C60", - "C61", - "C62", - "C63", - "C64", - "C65", - "C66", - "C67", - "C68", - "C69", - "C70", - "C71", - "C72", - "C73", - "C74", - "C75", - "C76", - "C77", - "C78", - "C79", - "C80", - "C81", - "C82", - "C83", - "C84", - "C85", - "C86", - "C87", - "C88", - "C89", - "C90", - "C91", - "C92", - "C93", - "C94", - "C95", - "C96", - "C97", - "C98", - "C99", - "E1", - "E10", - "E100", - "E101", - "E102", - "E103", - "E104", - "E105", - "E106", - "E107", - "E108", - "E109", - "E11", - "E110", - "E111", - "E112", - "E113", - "E114", - "E115", - "E116", - "E117", - "E118", - "E119", - "E12", - "E120", - "E13", - "E14", - "E15", - "E16", - "E17", - "E18", - "E19", - "E2", - "E20", - "E21", - "E22", - "E23", - "E24", - "E25", - "E26", - "E27", - "E28", - "E29", - "E3", - "E30", - "E31", - "E32", - "E33", - "E34", - "E35", - "E36", - "E37", - "E38", - "E39", - "E4", - "E40", - "E41", - "E42", - "E43", - "E44", - "E45", - "E46", - "E47", - "E48", - "E49", - "E5", - "E50", - "E51", - "E52", - "E53", - "E54", - "E55", - "E56", - "E57", - "E58", - "E59", - "E6", - "E60", - "E61", - "E62", - "E63", - "E64", - "E65", - "E66", - "E67", - "E68", - "E69", - "E7", - "E70", - "E71", - "E72", - "E73", - "E74", - "E75", - "E76", - "E77", - "E78", - "E79", - "E8", - "E80", - "E81", - "E82", - "E83", - "E84", - "E85", - "E86", - "E87", - "E88", - "E89", - "E9", - "E90", - "E91", - "E92", - "E93", - "E94", - "E95", - "E96", - "E97", - "E98", - "E99", - "T100", - "T101", - "T104", - "T106", - "T41", - "T43", - "T44", - "T49", - "T50", - "T55", - "T61", - "T62", - "T64", - "T65", - "T66", - "T70", - "T72", - "T73", - "T83", - "T88", - "T94", - "T95", - "T96", - "T97", - "T99" - ], - "subs": [], - "curl": "", - "endpoints": [ - { - "id": "fk-cartoon", - "method": "POST", - "subpath": "image/", - "full_url": "https://apigp0006.creinnovations.in/apis/flxk/flux/cartoon/image/", - "path": "/flux/cartoon/image/", - "title": "FLUX.1-Kontext Stylized Cartoon Effect", - "summary": "Massive library of 215 verified anime, 3D CGI, stylized cartoon aesthetics.", - "desc": "Transforms entire scene into anime, CGI toon, watercolor cartoon, or comic lineart. Verification confirmed 215 pairs: E1-E120 (120), T41-T106 (25), and C41-C110 (70).", - "params": [ - { - "n": "image0", - "al": "image", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Input photograph." - }, - { - "n": "effectId", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Cartoon preset ID: 'E1'-'E120', 'T41'-'T106' (25 presets), or 'C41'-'C110' (70 presets)." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "'abcdef'", - "ds": "\ud83d\udd11 Authentication: API secret key ('abcdef')." - } - ], - "chips": [ - "C100", - "C101", - "C102", - "C103", - "C104", - "C105", - "C106", - "C107", - "C108", - "C109", - "C110", - "C41", - "C42", - "C43", - "C44", - "C45", - "C46", - "C47", - "C48", - "C49", - "C50", - "C51", - "C52", - "C53", - "C54", - "C55", - "C56", - "C57", - "C58", - "C59", - "C60", - "C61", - "C62", - "C63", - "C64", - "C65", - "C66", - "C67", - "C68", - "C69", - "C70", - "C71", - "C72", - "C73", - "C74", - "C75", - "C76", - "C77", - "C78", - "C79", - "C80", - "C81", - "C82", - "C83", - "C84", - "C85", - "C86", - "C87", - "C88", - "C89", - "C90", - "C91", - "C92", - "C93", - "C94", - "C95", - "C96", - "C97", - "C98", - "C99", - "E1", - "E10", - "E100", - "E101", - "E102", - "E103", - "E104", - "E105", - "E106", - "E107", - "E108", - "E109", - "E11", - "E110", - "E111", - "E112", - "E113", - "E114", - "E115", - "E116", - "E117", - "E118", - "E119", - "E12", - "E120", - "E13", - "E14", - "E15", - "E16", - "E17", - "E18", - "E19", - "E2", - "E20", - "E21", - "E22", - "E23", - "E24", - "E25", - "E26", - "E27", - "E28", - "E29", - "E3", - "E30", - "E31", - "E32", - "E33", - "E34", - "E35", - "E36", - "E37", - "E38", - "E39", - "E4", - "E40", - "E41", - "E42", - "E43", - "E44", - "E45", - "E46", - "E47", - "E48", - "E49", - "E5", - "E50", - "E51", - "E52", - "E53", - "E54", - "E55", - "E56", - "E57", - "E58", - "E59", - "E6", - "E60", - "E61", - "E62", - "E63", - "E64", - "E65", - "E66", - "E67", - "E68", - "E69", - "E7", - "E70", - "E71", - "E72", - "E73", - "E74", - "E75", - "E76", - "E77", - "E78", - "E79", - "E8", - "E80", - "E81", - "E82", - "E83", - "E84", - "E85", - "E86", - "E87", - "E88", - "E89", - "E9", - "E90", - "E91", - "E92", - "E93", - "E94", - "E95", - "E96", - "E97", - "E98", - "E99", - "T100", - "T101", - "T104", - "T106", - "T41", - "T43", - "T44", - "T49", - "T50", - "T55", - "T61", - "T62", - "T64", - "T65", - "T66", - "T70", - "T72", - "T73", - "T83", - "T88", - "T94", - "T95", - "T96", - "T97", - "T99" - ], - "resp": "image/png", - "subs": [], - "curl": "" - } - ] - }, - { - "id": "api-flux-background-changer", - "api_key": "Flux_Background_Changer", - "api_ip_link": "https://apigp0006.creinnovations.in/apis/flxk/flux/background_with_depth/", - "title": "Flux_Background_Changer", - "method": "POST", - "path": "/flux/background_with_depth/image/", - "full_url": "https://apigp0006.creinnovations.in/apis/flxk/flux/background_with_depth/image/", - "port": "8000", - "resp": "image/png", - "summary": "Photorealistic depth-aware backdrop synthesis across 193 environments.", - "desc": "Synthesizes studio, lifestyle, architectural, nature, and futuristic depth-mapped environments behind subjects with accurate bokeh blur and contact shadow casting. Also supports POST /flux/background_with_depth/image_bg/.", - "params": [ - { - "n": "image0", - "al": "image", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Input photograph with subject." - }, - { - "n": "effectId", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Environment preset ID across 11 thematic categories." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "'abcdef'", - "ds": "\ud83d\udd11 Authentication: API secret key ('abcdef')." - } - ], - "chips": [ - "c_gallery_1", - "c_gallery_2", - "c_gallery_3", - "c_gallery_4", - "c_gallery_5", - "c_gallery_6", - "c_gallery_7", - "c_gallery_8", - "c_gallery_9", - "cafe_lifestyle_1", - "cafe_lifestyle_10", - "cafe_lifestyle_11", - "cafe_lifestyle_12", - "cafe_lifestyle_13", - "cafe_lifestyle_2", - "cafe_lifestyle_3", - "cafe_lifestyle_4", - "cafe_lifestyle_5", - "cafe_lifestyle_6", - "cafe_lifestyle_7", - "cafe_lifestyle_8", - "cafe_lifestyle_9", - "cyberpunk_1", - "cyberpunk_10", - "cyberpunk_11", - "cyberpunk_12", - "cyberpunk_13", - "cyberpunk_14", - "cyberpunk_2", - "cyberpunk_3", - "cyberpunk_4", - "cyberpunk_5", - "cyberpunk_6", - "cyberpunk_7", - "cyberpunk_8", - "cyberpunk_9", - "fantasy_1", - "fantasy_10", - "fantasy_2", - "fantasy_3", - "fantasy_4", - "fantasy_5", - "fantasy_6", - "fantasy_7", - "fantasy_8", - "fantasy_9", - "festive_1", - "festive_10", - "festive_11", - "festive_2", - "festive_3", - "festive_4", - "festive_5", - "festive_6", - "festive_7", - "festive_8", - "festive_9", - "interiors_1", - "interiors_10", - "interiors_11", - "interiors_12", - "interiors_13", - "interiors_14", - "interiors_15", - "interiors_16", - "interiors_17", - "interiors_18", - "interiors_2", - "interiors_3", - "interiors_4", - "interiors_5", - "interiors_6", - "interiors_7", - "interiors_8", - "interiors_9", - "luxury_1", - "luxury_10", - "luxury_11", - "luxury_2", - "luxury_3", - "luxury_4", - "luxury_5", - "luxury_6", - "luxury_7", - "luxury_8", - "luxury_9", - "nature_1", - "nature_2", - "nature_3", - "nature_4", - "nature_5", - "nature_6", - "nature_7", - "nature_8", - "nature_9", - "product_100", - "product_101", - "product_102", - "product_103", - "product_104", - "product_105", - "product_106", - "product_107", - "product_108", - "product_109", - "product_110", - "product_111", - "product_112", - "product_113", - "product_114", - "product_115", - "product_116", - "product_117", - "product_118", - "product_119", - "product_120", - "product_121", - "product_41", - "product_42", - "product_43", - "product_44", - "product_45", - "product_46", - "product_47", - "product_48", - "product_49", - "product_50", - "product_51", - "product_52", - "product_53", - "product_54", - "product_55", - "product_56", - "product_57", - "product_58", - "product_59", - "product_60", - "product_61", - "product_62", - "product_63", - "product_64", - "product_65", - "product_66", - "product_67", - "product_68", - "product_69", - "product_70", - "product_71", - "product_72", - "product_73", - "product_74", - "product_75", - "product_76", - "product_77", - "product_78", - "product_79", - "product_80", - "product_81", - "product_82", - "product_83", - "product_84", - "product_85", - "product_86", - "product_87", - "product_88", - "product_89", - "product_90", - "product_91", - "product_92", - "product_93", - "product_94", - "product_95", - "product_96", - "product_97", - "product_98", - "product_99", - "professional_1", - "professional_10", - "professional_11", - "professional_12", - "professional_2", - "professional_3", - "professional_4", - "professional_5", - "professional_6", - "professional_7", - "professional_8", - "professional_9", - "sports_1", - "sports_2", - "sports_3", - "sports_4", - "sports_5" - ], - "subs": [], - "curl": "", - "endpoints": [ - { - "id": "fk-background-with-depth", - "method": "POST", - "subpath": "image/", - "full_url": "https://apigp0006.creinnovations.in/apis/flxk/flux/background_with_depth/image/", - "path": "/flux/background_with_depth/image/", - "title": "FLUX.1-Kontext Background With Depth", - "summary": "Photorealistic depth-aware backdrop synthesis across 193 environments.", - "desc": "Synthesizes studio, lifestyle, architectural, nature, and futuristic depth-mapped environments behind subjects with accurate bokeh blur and contact shadow casting. Also supports POST /flux/background_with_depth/image_bg/.", - "params": [ - { - "n": "image0", - "al": "image", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Input photograph with subject." - }, - { - "n": "effectId", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Environment preset ID across 11 thematic categories." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "'abcdef'", - "ds": "\ud83d\udd11 Authentication: API secret key ('abcdef')." - } - ], - "chips": [ - "c_gallery_1", - "c_gallery_2", - "c_gallery_3", - "c_gallery_4", - "c_gallery_5", - "c_gallery_6", - "c_gallery_7", - "c_gallery_8", - "c_gallery_9", - "cafe_lifestyle_1", - "cafe_lifestyle_10", - "cafe_lifestyle_11", - "cafe_lifestyle_12", - "cafe_lifestyle_13", - "cafe_lifestyle_2", - "cafe_lifestyle_3", - "cafe_lifestyle_4", - "cafe_lifestyle_5", - "cafe_lifestyle_6", - "cafe_lifestyle_7", - "cafe_lifestyle_8", - "cafe_lifestyle_9", - "cyberpunk_1", - "cyberpunk_10", - "cyberpunk_11", - "cyberpunk_12", - "cyberpunk_13", - "cyberpunk_14", - "cyberpunk_2", - "cyberpunk_3", - "cyberpunk_4", - "cyberpunk_5", - "cyberpunk_6", - "cyberpunk_7", - "cyberpunk_8", - "cyberpunk_9", - "fantasy_1", - "fantasy_10", - "fantasy_2", - "fantasy_3", - "fantasy_4", - "fantasy_5", - "fantasy_6", - "fantasy_7", - "fantasy_8", - "fantasy_9", - "festive_1", - "festive_10", - "festive_11", - "festive_2", - "festive_3", - "festive_4", - "festive_5", - "festive_6", - "festive_7", - "festive_8", - "festive_9", - "interiors_1", - "interiors_10", - "interiors_11", - "interiors_12", - "interiors_13", - "interiors_14", - "interiors_15", - "interiors_16", - "interiors_17", - "interiors_18", - "interiors_2", - "interiors_3", - "interiors_4", - "interiors_5", - "interiors_6", - "interiors_7", - "interiors_8", - "interiors_9", - "luxury_1", - "luxury_10", - "luxury_11", - "luxury_2", - "luxury_3", - "luxury_4", - "luxury_5", - "luxury_6", - "luxury_7", - "luxury_8", - "luxury_9", - "nature_1", - "nature_2", - "nature_3", - "nature_4", - "nature_5", - "nature_6", - "nature_7", - "nature_8", - "nature_9", - "product_100", - "product_101", - "product_102", - "product_103", - "product_104", - "product_105", - "product_106", - "product_107", - "product_108", - "product_109", - "product_110", - "product_111", - "product_112", - "product_113", - "product_114", - "product_115", - "product_116", - "product_117", - "product_118", - "product_119", - "product_120", - "product_121", - "product_41", - "product_42", - "product_43", - "product_44", - "product_45", - "product_46", - "product_47", - "product_48", - "product_49", - "product_50", - "product_51", - "product_52", - "product_53", - "product_54", - "product_55", - "product_56", - "product_57", - "product_58", - "product_59", - "product_60", - "product_61", - "product_62", - "product_63", - "product_64", - "product_65", - "product_66", - "product_67", - "product_68", - "product_69", - "product_70", - "product_71", - "product_72", - "product_73", - "product_74", - "product_75", - "product_76", - "product_77", - "product_78", - "product_79", - "product_80", - "product_81", - "product_82", - "product_83", - "product_84", - "product_85", - "product_86", - "product_87", - "product_88", - "product_89", - "product_90", - "product_91", - "product_92", - "product_93", - "product_94", - "product_95", - "product_96", - "product_97", - "product_98", - "product_99", - "professional_1", - "professional_10", - "professional_11", - "professional_12", - "professional_2", - "professional_3", - "professional_4", - "professional_5", - "professional_6", - "professional_7", - "professional_8", - "professional_9", - "sports_1", - "sports_2", - "sports_3", - "sports_4", - "sports_5" - ], - "resp": "image/png", - "subs": [], - "curl": "" - } - ] - }, - { - "id": "api-vintage-look", - "api_key": "Vintage_Look", - "api_ip_link": "https://apigp0006.creinnovations.in/apis/flxk/flux/vintage_look/", - "title": "Vintage_Look", - "method": "POST", - "path": "/flux/vintage_look/image/", - "full_url": "https://apigp0006.creinnovations.in/apis/flxk/flux/vintage_look/image/", - "port": "8000", - "resp": "image/png", - "summary": "Historical film stock emulation across 131 vintage photography presets.", - "desc": "Emulates tintype, daguerreotype, 1920s sepia, 1950s Kodachrome, 1970s Polaroid, and 1990s disposable camera film grain across 68 female and 63 male presets.", - "params": [ - { - "n": "image0", - "al": "image", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Input photograph." - }, - { - "n": "effectId", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Vintage film preset ID: 'F1'-'F68' for female portraits, 'M1'-'M63' for male portraits." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "'abcdef'", - "ds": "\ud83d\udd11 Authentication: API secret key ('abcdef')." - } - ], - "chips": [ - "F1", - "F10", - "F11", - "F12", - "F13", - "F14", - "F15", - "F16", - "F17", - "F18", - "F19", - "F2", - "F20", - "F21", - "F22", - "F23", - "F24", - "F25", - "F26", - "F27", - "F28", - "F29", - "F3", - "F30", - "F31", - "F32", - "F33", - "F34", - "F35", - "F36", - "F37", - "F38", - "F39", - "F4", - "F40", - "F41", - "F42", - "F43", - "F44", - "F45", - "F46", - "F47", - "F48", - "F49", - "F5", - "F50", - "F51", - "F52", - "F53", - "F54", - "F55", - "F56", - "F57", - "F58", - "F59", - "F6", - "F60", - "F61", - "F62", - "F63", - "F64", - "F65", - "F66", - "F67", - "F68", - "F7", - "F8", - "F9", - "M1", - "M10", - "M11", - "M12", - "M13", - "M14", - "M15", - "M16", - "M17", - "M18", - "M19", - "M2", - "M20", - "M21", - "M22", - "M23", - "M24", - "M25", - "M26", - "M27", - "M28", - "M29", - "M3", - "M30", - "M31", - "M32", - "M33", - "M34", - "M35", - "M36", - "M37", - "M38", - "M39", - "M4", - "M40", - "M41", - "M42", - "M43", - "M44", - "M45", - "M46", - "M47", - "M48", - "M49", - "M5", - "M50", - "M51", - "M52", - "M53", - "M54", - "M55", - "M56", - "M57", - "M58", - "M59", - "M6", - "M60", - "M61", - "M62", - "M63", - "M7", - "M8", - "M9" - ], - "subs": [], - "curl": "", - "endpoints": [ - { - "id": "fk-vintage-look", - "method": "POST", - "subpath": "image/", - "full_url": "https://apigp0006.creinnovations.in/apis/flxk/flux/vintage_look/image/", - "path": "/flux/vintage_look/image/", - "title": "FLUX.1-Kontext Vintage Film & Retro Emulation", - "summary": "Historical film stock emulation across 131 vintage photography presets.", - "desc": "Emulates tintype, daguerreotype, 1920s sepia, 1950s Kodachrome, 1970s Polaroid, and 1990s disposable camera film grain across 68 female and 63 male presets.", - "params": [ - { - "n": "image0", - "al": "image", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Input photograph." - }, - { - "n": "effectId", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Vintage film preset ID: 'F1'-'F68' for female portraits, 'M1'-'M63' for male portraits." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "'abcdef'", - "ds": "\ud83d\udd11 Authentication: API secret key ('abcdef')." - } - ], - "chips": [ - "F1", - "F10", - "F11", - "F12", - "F13", - "F14", - "F15", - "F16", - "F17", - "F18", - "F19", - "F2", - "F20", - "F21", - "F22", - "F23", - "F24", - "F25", - "F26", - "F27", - "F28", - "F29", - "F3", - "F30", - "F31", - "F32", - "F33", - "F34", - "F35", - "F36", - "F37", - "F38", - "F39", - "F4", - "F40", - "F41", - "F42", - "F43", - "F44", - "F45", - "F46", - "F47", - "F48", - "F49", - "F5", - "F50", - "F51", - "F52", - "F53", - "F54", - "F55", - "F56", - "F57", - "F58", - "F59", - "F6", - "F60", - "F61", - "F62", - "F63", - "F64", - "F65", - "F66", - "F67", - "F68", - "F7", - "F8", - "F9", - "M1", - "M10", - "M11", - "M12", - "M13", - "M14", - "M15", - "M16", - "M17", - "M18", - "M19", - "M2", - "M20", - "M21", - "M22", - "M23", - "M24", - "M25", - "M26", - "M27", - "M28", - "M29", - "M3", - "M30", - "M31", - "M32", - "M33", - "M34", - "M35", - "M36", - "M37", - "M38", - "M39", - "M4", - "M40", - "M41", - "M42", - "M43", - "M44", - "M45", - "M46", - "M47", - "M48", - "M49", - "M5", - "M50", - "M51", - "M52", - "M53", - "M54", - "M55", - "M56", - "M57", - "M58", - "M59", - "M6", - "M60", - "M61", - "M62", - "M63", - "M7", - "M8", - "M9" - ], - "resp": "image/png", - "subs": [], - "curl": "" - } - ] - } - ] - }, - { - "id": "sec-ml-models", - "key": "ml-models", - "icon": "\ud83d\udc41\ufe0f", - "title": "ML Vision Models", - "tag": "High-Throughput Vision", - "lead": "Dedicated discriminative and GAN-based computer vision microservices: Face restoration (CodeFormer), Super-Resolution (Real-ESRGAN), DeOldify colorization, LaMa object removal, P3M alpha matting, and sub-pixel facial landmark mesh extraction.", - "port": "8000", - "hue": 205, - "eps": [ - { - "id": "api-cre-aws-waifu2x-model", - "api_key": "Cre_Aws_Waifu2x_Model", - "api_ip_link": "https://apigp0006.creinnovations.in/apis/mlm/new_enhancer/", - "title": "Cre_Aws_Waifu2x_Model", - "method": "MULTI", - "path": "/new_enhancer/image/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/new_enhancer/image/", - "port": "8000", - "resp": "image/png", - "summary": "Super-resolution upscaling and facial detail reconstruction.", - "desc": "Combines Real-ESRGAN 4x upscaling with CodeFormer/GFPGAN facial restoration to denoise, deblur, sharpen eyelashes/skin texture, and increase pixel density.", - "params": [ - { - "n": "image", - "al": "image0", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Low-resolution, compressed, or blurry portrait." - }, - { - "n": "upscale_factor", - "al": "", - "ty": "integer", - "lc": "multipart/form-data", - "rq": false, - "df": "2", - "ds": "Upscaling multiplication factor (2x, 4x)." - } - ], - "chips": [], - "subs": [], - "curl": "", - "endpoints": [ - { - "id": "ml-new-enhancer", - "method": "POST", - "subpath": "image/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/new_enhancer/image/", - "path": "/new_enhancer/image/", - "title": "Real-ESRGAN + CodeFormer Super-Resolution", - "summary": "Super-resolution upscaling and facial detail reconstruction.", - "desc": "Combines Real-ESRGAN 4x upscaling with CodeFormer/GFPGAN facial restoration to denoise, deblur, sharpen eyelashes/skin texture, and increase pixel density.", - "params": [ - { - "n": "image", - "al": "image0", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Low-resolution, compressed, or blurry portrait." - }, - { - "n": "upscale_factor", - "al": "", - "ty": "integer", - "lc": "multipart/form-data", - "rq": false, - "df": "2", - "ds": "Upscaling multiplication factor (2x, 4x)." - } - ], - "chips": [], - "resp": "image/png", - "subs": [], - "curl": "" - }, - { - "id": "ml-new-enhancer-previous", - "method": "POST", - "subpath": "image_previous/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/new_enhancer/image_previous/", - "path": "/new_enhancer/image_previous/", - "title": "Face & Image Enhancer \u2014 Legacy Alias", - "summary": "Legacy alias for the Real-ESRGAN + GFPGAN enhancement pipeline.", - "desc": "Legacy alias for the Real-ESRGAN + GFPGAN enhancement pipeline. Functionally identical to /new_enhancer/image/ . Accepts base64 image source as alternative to file upload.", - "params": [ - { - "n": "image0", - "al": "image", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Low-resolution, compressed, or blurry portrait." - }, - { - "n": "src", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "None", - "ds": "Base64-encoded image, as an alternative to uploading a file." - }, - { - "n": "scale_ratio", - "al": "", - "ty": "float", - "lc": "multipart/form-data", - "rq": false, - "df": "None", - "ds": "Upscaling multiplication factor." - }, - { - "n": "noise_level", - "al": "", - "ty": "float", - "lc": "multipart/form-data", - "rq": false, - "df": "None", - "ds": "Denoising strength applied during enhancement." - } - ], - "chips": [], - "resp": "image/png", - "subs": [], - "curl": "curl -X POST \"{{base}}:5925/new_enhancer/image_previous/\" \\\n -F \"image0=@image0.jpg\" \\\n -F \"src=value\" \\\n -F \"scale_ratio=value\" \\\n -F \"noise_level=value\"" - } - ] - }, - { - "id": "api-cre-aws-colorization-model", - "api_key": "Cre_Aws_Colorization_Model", - "api_ip_link": "https://apigp0006.creinnovations.in/apis/mlm/colorization/", - "title": "Cre_Aws_Colorization_Model", - "method": "POST", - "path": "/colorization/image/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/colorization/image/", - "port": "8000", - "resp": "image/png", - "summary": "Automatic neural colorization of monochrome and vintage photographs.", - "desc": "Employs deep generative neural networks (DeOldify generator) to infuse historically consistent and vivid RGB color into grayscale portraits and landscape archives.", - "params": [ - { - "n": "image", - "al": "image0", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Grayscale or sepia portrait or vintage scene." - } - ], - "chips": [], - "subs": [], - "curl": "", - "endpoints": [ - { - "id": "ml-colorization", - "method": "POST", - "subpath": "image/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/colorization/image/", - "path": "/colorization/image/", - "title": "DeOldify B&W Photo Colorization", - "summary": "Automatic neural colorization of monochrome and vintage photographs.", - "desc": "Employs deep generative neural networks (DeOldify generator) to infuse historically consistent and vivid RGB color into grayscale portraits and landscape archives.", - "params": [ - { - "n": "image", - "al": "image0", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Grayscale or sepia portrait or vintage scene." - } - ], - "chips": [], - "resp": "image/png", - "subs": [], - "curl": "" - } - ] - }, - { - "id": "api-cre-aws-old-photo-restore-model", - "api_key": "Cre_Aws_Old_Photo_Restore_Model", - "api_ip_link": "https://apigp0006.creinnovations.in/apis/mlm/oldPhotoRestore/", - "title": "Cre_Aws_Old_Photo_Restore_Model", - "method": "POST", - "path": "/oldPhotoRestore/image/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/oldPhotoRestore/image/", - "port": "8000", - "resp": "image/png", - "summary": "Restores vintage degraded photos by repairing tears, scratches, dust, and fading.", - "desc": "Deep learning scratch repair and portrait enhancement. Identifies physical degradation masks (scratches, fold marks, yellowing, sepia grain) and infills cleanly with restored facial features.", - "params": [ - { - "n": "image", - "al": "image0", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Scanned or photographed historical damaged photo." - } - ], - "chips": [], - "subs": [], - "curl": "", - "endpoints": [ - { - "id": "ml-old-photo-restore", - "method": "POST", - "subpath": "image/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/oldPhotoRestore/image/", - "path": "/oldPhotoRestore/image/", - "title": "Scratch, Crease & Fading Restoration", - "summary": "Restores vintage degraded photos by repairing tears, scratches, dust, and fading.", - "desc": "Deep learning scratch repair and portrait enhancement. Identifies physical degradation masks (scratches, fold marks, yellowing, sepia grain) and infills cleanly with restored facial features.", - "params": [ - { - "n": "image", - "al": "image0", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Scanned or photographed historical damaged photo." - } - ], - "chips": [], - "resp": "image/png", - "subs": [], - "curl": "" - } - ] - }, - { - "id": "api-cre-aws-advance-image-segment-anything-dichotomous-model", - "api_key": "Cre_Aws_Advance_Image_Segment_Anything_Dichotomous_Model", - "api_ip_link": "https://apigp0006.creinnovations.in/apis/mlm/advance_image_segment_anything_dichotomous/", - "title": "Cre_Aws_Advance_Image_Segment_Anything_Dichotomous_Model", - "method": "POST", - "path": "/advance_image_segment_anything_dichotomous/image/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/advance_image_segment_anything_dichotomous/image/", - "port": "8000", - "resp": "image/png", - "summary": "Dichotomous Image Segmentation (DIS) capturing ultra-intricate geometry.", - "desc": "High-resolution foreground extraction for complex structures like netting, bicycles, animal fur, jewelry, and lace where standard segmentation models fail.", - "params": [ - { - "n": "image", - "al": "image0", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Intricate high-frequency image." - } - ], - "chips": [], - "subs": [], - "curl": "", - "endpoints": [ - { - "id": "ml-advance-segment-anything", - "method": "POST", - "subpath": "image/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/advance_image_segment_anything_dichotomous/image/", - "path": "/advance_image_segment_anything_dichotomous/image/", - "title": "DIS + SAM Dichotomous Segmentation", - "summary": "Dichotomous Image Segmentation (DIS) capturing ultra-intricate geometry.", - "desc": "High-resolution foreground extraction for complex structures like netting, bicycles, animal fur, jewelry, and lace where standard segmentation models fail.", - "params": [ - { - "n": "image", - "al": "image0", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Intricate high-frequency image." - } - ], - "chips": [], - "resp": "image/png", - "subs": [], - "curl": "" - } - ] - }, - { - "id": "api-cre-aws-cloth-segmentation-model", - "api_key": "Cre_Aws_cloth_segmentation_Model", - "api_ip_link": "https://apigp0006.creinnovations.in/apis/mlm/cloth_segmentation/", - "title": "Cre_Aws_cloth_segmentation_Model", - "method": "POST", - "path": "/cloth_segmentation/image", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/cloth_segmentation/image", - "port": "8000", - "resp": "image/png", - "summary": "U-Net garment parsing segmenting tops, bottoms, and full-length dresses.", - "desc": "Extracts binary masks isolating textile fabric from background and human body anatomy. Prepares masks for virtual try-on and garment color changing.", - "params": [ - { - "n": "image", - "al": "image0", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Full or half body fashion photo." - } - ], - "chips": [], - "subs": [], - "curl": "", - "endpoints": [ - { - "id": "ml-cloth-segmentation", - "method": "POST", - "subpath": "image", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/cloth_segmentation/image", - "path": "/cloth_segmentation/image", - "title": "Cloth Segmentation (Clothing Identifier)", - "summary": "U-Net garment parsing segmenting tops, bottoms, and full-length dresses.", - "desc": "Extracts binary masks isolating textile fabric from background and human body anatomy. Prepares masks for virtual try-on and garment color changing.", - "params": [ - { - "n": "image", - "al": "image0", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Full or half body fashion photo." - } - ], - "chips": [], - "resp": "image/png", - "subs": [], - "curl": "" - } - ] - }, - { - "id": "api-dress-segmentation-auto", - "api_key": "dress_segmentation_auto", - "api_ip_link": "https://apigp0006.creinnovations.in/apis/mlm/dress_segmentation_auto_newurl/", - "title": "dress_segmentation_auto", - "method": "POST", - "path": "/dress_segmentation_auto_newurl/image/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/dress_segmentation_auto_newurl/image/", - "port": "8000", - "resp": "image/png", - "summary": "Automated garment detection with skin protection preserving necklines and arms.", - "desc": "Identifies worn garments while strictly subtracting exposed collarbones, chest, arms, and wrists to prevent dress inpainting from spilling over skin.", - "params": [ - { - "n": "image", - "al": "image0", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Full portrait photo." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "\ud83d\udd11 Authentication: Required secret key (\\\u0007bcdef\\)." - } - ], - "chips": [], - "subs": [], - "curl": "", - "endpoints": [ - { - "id": "ml-cloth-segmentation-auto", - "method": "POST", - "subpath": "image/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/dress_segmentation_auto_newurl/image/", - "path": "/dress_segmentation_auto_newurl/image/", - "title": "Automated Garment Segmentation", - "summary": "Automated garment detection with skin protection preserving necklines and arms.", - "desc": "Identifies worn garments while strictly subtracting exposed collarbones, chest, arms, and wrists to prevent dress inpainting from spilling over skin.", - "params": [ - { - "n": "image", - "al": "image0", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Full portrait photo." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "\ud83d\udd11 Authentication: Required secret key (\\\u0007bcdef\\)." - } - ], - "chips": [], - "resp": "image/png", - "subs": [], - "curl": "" - } - ] - }, - { - "id": "api-cre-aws-lama-cleaner-model", - "api_key": "Cre_Aws_Lama_Cleaner_Model", - "api_ip_link": "https://apigp0006.creinnovations.in/apis/mlm/lamaCleaner/", - "title": "Cre_Aws_Lama_Cleaner_Model", - "method": "POST", - "path": "/lamaCleaner/image/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/lamaCleaner/image/", - "port": "8000", - "resp": "image/png", - "summary": "Large Mask Inpainting (LaMa) for seamless object and watermark removal.", - "desc": "Fast Fourier Transform convolutions allow LaMa to erase photobombers, text watermarks, blemishes, and unwanted objects while synthesizing matching background textures.", - "params": [ - { - "n": "image", - "al": "image0", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Original photo containing unwanted object or watermark." - }, - { - "n": "mask", - "al": "mask_image", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Binary mask image (white pixels = erase and inpaint, black = retain)." - } - ], - "chips": [], - "subs": [], - "curl": "", - "endpoints": [ - { - "id": "ml-lama-cleaner", - "method": "POST", - "subpath": "image/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/lamaCleaner/image/", - "path": "/lamaCleaner/image/", - "title": "LaMa Inpainting Object Remover", - "summary": "Large Mask Inpainting (LaMa) for seamless object and watermark removal.", - "desc": "Fast Fourier Transform convolutions allow LaMa to erase photobombers, text watermarks, blemishes, and unwanted objects while synthesizing matching background textures.", - "params": [ - { - "n": "image", - "al": "image0", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Original photo containing unwanted object or watermark." - }, - { - "n": "mask", - "al": "mask_image", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Binary mask image (white pixels = erase and inpaint, black = retain)." - } - ], - "chips": [], - "resp": "image/png", - "subs": [], - "curl": "" - } - ] - }, - { - "id": "api-cre-aws-background-remover-model", - "api_key": "Cre_Aws_Background_Remover_Model", - "api_ip_link": "https://apigp0006.creinnovations.in/apis/mlm/background_remover_p3m/", - "title": "Cre_Aws_Background_Remover_Model", - "method": "POST", - "path": "/background_remover_p3m/image/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/background_remover_p3m/image/", - "port": "8000", - "resp": "image/png", - "summary": "Deep portrait matting producing transparent alpha cutouts.", - "desc": "High-accuracy portrait matting powered by P3M-Net (Privacy-Preserving Portrait Matting). Extracts subjects with fine alpha masks around wispy hair, translucent garments, and complex edges.", - "params": [ - { - "n": "image", - "al": "image0", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Input photo to extract subject from (JPEG/PNG/WEBP)." - } - ], - "chips": [], - "subs": [], - "curl": "", - "endpoints": [ - { - "id": "ml-background-remover", - "method": "POST", - "subpath": "image/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/background_remover_p3m/image/", - "path": "/background_remover_p3m/image/", - "title": "P3M-Net Alpha Matte Background Remover", - "summary": "Deep portrait matting producing transparent alpha cutouts.", - "desc": "High-accuracy portrait matting powered by P3M-Net (Privacy-Preserving Portrait Matting). Extracts subjects with fine alpha masks around wispy hair, translucent garments, and complex edges.", - "params": [ - { - "n": "image", - "al": "image0", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Input photo to extract subject from (JPEG/PNG/WEBP)." - } - ], - "chips": [], - "resp": "image/png", - "subs": [], - "curl": "" - } - ] - }, - { - "id": "api-cre-aws-cartoon-model", - "api_key": "Cre_Aws_Cartoon_Model", - "api_ip_link": "https://apigp0006.creinnovations.in/apis/mlm/cartoon_effects/", - "title": "Cre_Aws_Cartoon_Model", - "method": "POST", - "path": "/image/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/cartoon_effects/image/", - "port": "8000", - "resp": "image/png", - "summary": "AnimeGAN & Cartoon Effects", - "desc": "AnimeGAN & Cartoon Effects", - "params": [ - { - "n": "image", - "al": "image0", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Input image file." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "'abcdef'", - "ds": "\ud83d\udd11 Authentication secret key." - } - ], - "chips": [], - "subs": [], - "curl": "", - "endpoints": [ - { - "id": "api-cre-aws-cartoon-model", - "method": "POST", - "subpath": "image/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/cartoon_effects/image/", - "path": "/image/", - "title": "AnimeGAN & Cartoon Effects", - "summary": "AnimeGAN & Cartoon Effects", - "desc": "AnimeGAN & Cartoon Effects", - "params": [ - { - "n": "image", - "al": "image0", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Input image file." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "'abcdef'", - "ds": "\ud83d\udd11 Authentication secret key." - } - ], - "chips": [], - "resp": "image/png", - "subs": [], - "curl": "" - } - ] - }, - { - "id": "api-face-coordinates", - "api_key": "Face_Coordinates", - "api_ip_link": "https://apigp0006.creinnovations.in/apis/mlm/face_landmark/", - "title": "Face_Coordinates", - "method": "MULTI", - "path": "/face_landmark/image/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/face_landmark/image/", - "port": "8000", - "resp": "application/json", - "summary": "3D facial mesh and landmark detector for eyes, nose, lips, jawline, and brows.", - "desc": "Computes high-precision facial geometry coordinates. Sub-endpoints provide annotated debug visualizations and raw coordinate matrices.", - "params": [ - { - "n": "image", - "al": "image0", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Portrait photo displaying human face." - } - ], - "chips": [], - "subs": [ - { - "m": "POST", - "p": "/face_landmark/image/", - "d": "Returns JSON landmark coordinate array" - }, - { - "m": "POST", - "p": "/face_landmark/image2/", - "d": "Returns annotated visual overlay on input photo" - } - ], - "curl": "", - "endpoints": [ - { - "id": "ml-face-landmark", - "method": "POST", - "subpath": "image/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/face_landmark/image/", - "path": "/face_landmark/image/", - "title": "68-Point & 468-Point Facial Landmark Detection", - "summary": "3D facial mesh and landmark detector for eyes, nose, lips, jawline, and brows.", - "desc": "Computes high-precision facial geometry coordinates. Sub-endpoints provide annotated debug visualizations and raw coordinate matrices.", - "params": [ - { - "n": "image", - "al": "image0", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Portrait photo displaying human face." - } - ], - "chips": [], - "resp": "application/json", - "subs": [ - { - "m": "POST", - "p": "/face_landmark/image/", - "d": "Returns JSON landmark coordinate array" - }, - { - "m": "POST", - "p": "/face_landmark/image2/", - "d": "Returns annotated visual overlay on input photo" - } - ], - "curl": "" - }, - { - "id": "ml-face-landmark-image2", - "method": "POST", - "subpath": "image2/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/face_landmark/image2/", - "path": "/face_landmark/image2/", - "title": "Face Landmark \u2014 Mesh Array (image2)", - "summary": "Returns 468 MediaPipe Face Mesh landmark coordinates as a flat 2D array of [x, y] pairs in image-pixel space.", - "desc": "Returns 468 MediaPipe Face Mesh landmark coordinates as a flat 2D array of [x, y] pairs in image-pixel space. Variant format compared to /image/ .", - "params": [ - { - "n": "image", - "al": "image0", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Portrait photo displaying a human face." - } - ], - "chips": [], - "resp": "application/json", - "subs": [], - "curl": "curl -X POST \"{{base}}:5925/face_landmark/image2/\" \\\n -F \"image=@image.jpg\"" - }, - { - "id": "ml-face-landmark-image3", - "method": "POST", - "subpath": "image3/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/face_landmark/image3/", - "path": "/face_landmark/image3/", - "title": "Face Landmark \u2014 Contour (image3)", - "summary": "Third landmark detection variant \u2014 returns face contour landmark subset or alternative encoding used for facial-contour drawing tasks.", - "desc": "Third landmark detection variant \u2014 returns face contour landmark subset or alternative encoding used for facial-contour drawing tasks.", - "params": [ - { - "n": "image", - "al": "image0", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Portrait photo displaying a human face." - } - ], - "chips": [], - "resp": "application/json", - "subs": [], - "curl": "curl -X POST \"{{base}}:5925/face_landmark/image3/\" \\\n -F \"image=@image.jpg\"" - }, - { - "id": "ml-face-landmark-image4", - "method": "POST", - "subpath": "image4/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/face_landmark/image4/", - "path": "/face_landmark/image4/", - "title": "Face Landmark \u2014 Variant 4 (image4)", - "summary": "Fourth MediaPipe landmark variant \u2014 used for specific face region extraction or landmark ordering required by downstream compositing effects.", - "desc": "Fourth MediaPipe landmark variant \u2014 used for specific face region extraction or landmark ordering required by downstream compositing effects.", - "params": [ - { - "n": "image", - "al": "image0", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Portrait photo displaying a human face." - } - ], - "chips": [], - "resp": "application/json", - "subs": [], - "curl": "curl -X POST \"{{base}}:5925/face_landmark/image4/\" \\\n -F \"image=@image.jpg\"" - }, - { - "id": "ml-face-landmark-image5", - "method": "POST", - "subpath": "image5/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/face_landmark/image5/", - "path": "/face_landmark/image5/", - "title": "Face Landmark \u2014 Variant 5 (image5)", - "summary": "Fifth landmark variant for specialized geometry extraction tasks.", - "desc": "Fifth landmark variant for specialized geometry extraction tasks.", - "params": [ - { - "n": "image", - "al": "image0", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Portrait photo displaying a human face." - } - ], - "chips": [], - "resp": "application/json", - "subs": [], - "curl": "curl -X POST \"{{base}}:5925/face_landmark/image5/\" \\\n -F \"image=@image.jpg\"" - }, - { - "id": "ml-face-landmark-image6", - "method": "POST", - "subpath": "image6/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/face_landmark/image6/", - "path": "/face_landmark/image6/", - "title": "Face Landmark \u2014 Eye Iris Mask (image6)", - "summary": "Generates a binary eye iris segmentation mask and stores it in a server-side cache.", - "desc": "Generates a binary eye iris segmentation mask and stores it in a server-side cache. Returns a mask_url for fetching via GET /face_landmark/get_eye_mask and the full landmark coordinates.", - "params": [ - { - "n": "image", - "al": "image0", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Portrait photo displaying a human face." - } - ], - "chips": [], - "resp": "application/json", - "subs": [], - "curl": "curl -X POST \"{{base}}:5925/face_landmark/image6/\" \\\n -F \"image=@image.jpg\"" - }, - { - "id": "ml-face-landmark-image7", - "method": "POST", - "subpath": "image7/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/face_landmark/image7/", - "path": "/face_landmark/image7/", - "title": "Face Landmark \u2014 Visualized Overlay PNG (image7)", - "summary": "Returns a PNG image with all 468 MediaPipe landmark dots drawn directly on the face.", - "desc": "Returns a PNG image with all 468 MediaPipe landmark dots drawn directly on the face. Useful for debugging landmark accuracy.", - "params": [ - { - "n": "image", - "al": "image0", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Portrait photo displaying a human face." - } - ], - "chips": [], - "resp": "image/png", - "subs": [], - "curl": "curl -X POST \"{{base}}:5925/face_landmark/image7/\" \\\n -F \"image=@image.jpg\"" - }, - { - "id": "ml-face-landmark-get-eye-mask", - "method": "GET", - "subpath": "get_eye_mask", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/face_landmark/get_eye_mask", - "path": "/face_landmark/get_eye_mask", - "title": "Face Landmark \u2014 Fetch Eye Mask (get_eye_mask)", - "summary": "Retrieves a cached eye iris mask PNG generated by a prior POST /face_landmark/image6/ call.", - "desc": "Retrieves a cached eye iris mask PNG generated by a prior POST /face_landmark/image6/ call. Cache is in-memory; mask is keyed by a UUID returned in the image6 response.", - "params": [ - { - "n": "id", - "al": "", - "ty": "string (UUID)", - "lc": "query string", - "rq": true, - "df": "None", - "ds": "UUID of the cached eye mask, returned by POST /face_landmark/image6/." - } - ], - "chips": [], - "resp": "image/png", - "subs": [], - "curl": "" - } - ] - }, - { - "id": "api-cre-face-with-hair-segment-model", - "api_key": "Cre_Face_With_Hair_Segment_Model", - "api_ip_link": "https://apigp0006.creinnovations.in/apis/mlm/face_hair_segmentation/", - "title": "Cre_Face_With_Hair_Segment_Model", - "method": "POST", - "path": "/face_hair_segmentation/image/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/face_hair_segmentation/image/", - "port": "8000", - "resp": "image/png", - "summary": "Simultaneously segments face, hair, and torso regions for single and couple photos.", - "desc": "Produces multi-channel indexed masks distinguishing face skin from hair strands, ears, and neck. Offers couple photo parsing to segment partners independently.", - "params": [ - { - "n": "image", - "al": "image0", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Single portrait or couple photograph." - } - ], - "chips": [], - "subs": [ - { - "m": "POST", - "p": "/face_hair_segmentation/image/", - "d": "Single portrait face & hair segmentation" - }, - { - "m": "POST", - "p": "/face_hair_segmentation/image_couple/", - "d": "Couple photo face & hair separation" - }, - { - "m": "POST", - "p": "/face_hair_single_segmentation/image/", - "d": "Isolated single head mask" - } - ], - "curl": "", - "endpoints": [ - { - "id": "ml-face-hair-segmentation", - "method": "POST", - "subpath": "image/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/face_hair_segmentation/image/", - "path": "/face_hair_segmentation/image/", - "title": "Dual Face & Hair Multi-Channel Segmentation", - "summary": "Simultaneously segments face, hair, and torso regions for single and couple photos.", - "desc": "Produces multi-channel indexed masks distinguishing face skin from hair strands, ears, and neck. Offers couple photo parsing to segment partners independently.", - "params": [ - { - "n": "image", - "al": "image0", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Single portrait or couple photograph." - } - ], - "chips": [], - "resp": "image/png", - "subs": [ - { - "m": "POST", - "p": "/face_hair_segmentation/image/", - "d": "Single portrait face & hair segmentation" - }, - { - "m": "POST", - "p": "/face_hair_segmentation/image_couple/", - "d": "Couple photo face & hair separation" - }, - { - "m": "POST", - "p": "/face_hair_single_segmentation/image/", - "d": "Isolated single head mask" - } - ], - "curl": "" - } - ] - }, - { - "id": "api-cre-cartoonify-caricature-effects-model", - "api_key": "Cre_Cartoonify_Caricature_Effects_Model", - "api_ip_link": "https://apigp0006.creinnovations.in/apis/mlm/cartoonify_caricature_effects/", - "title": "Cre_Cartoonify_Caricature_Effects_Model", - "method": "POST", - "path": "/cartoonify_caricature_effects/image/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/cartoonify_caricature_effects/image/", - "port": "8000", - "resp": "image/png", - "summary": "Transforms portraits into Hayao Miyazaki / Makoto Shinkai anime aesthetic.", - "desc": "Employs CartoonGAN with edge-promoting adversarial loss to produce high-contrast cel-shaded cartoon anime imagery from natural portraits.", - "params": [ - { - "n": "image", - "al": "image0", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Portrait photograph to cartoonify." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "\ud83d\udd11 Authentication: Authentication key (\\\u0007bcdef\\)." - } - ], - "chips": [], - "subs": [], - "curl": "", - "endpoints": [ - { - "id": "ml-cartoon-gan", - "method": "POST", - "subpath": "image/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/cartoonify_caricature_effects/image/", - "path": "/cartoonify_caricature_effects/image/", - "title": "CartoonGAN & Anime Stylizer", - "summary": "Transforms portraits into Hayao Miyazaki / Makoto Shinkai anime aesthetic.", - "desc": "Employs CartoonGAN with edge-promoting adversarial loss to produce high-contrast cel-shaded cartoon anime imagery from natural portraits.", - "params": [ - { - "n": "image", - "al": "image0", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Portrait photograph to cartoonify." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "\ud83d\udd11 Authentication: Authentication key (\\\u0007bcdef\\)." - } - ], - "chips": [], - "resp": "image/png", - "subs": [], - "curl": "" - } - ] - }, - { - "id": "api-cre-hair-detection-segment-model", - "api_key": "Cre_Hair_Detection_Segment_Model", - "api_ip_link": "https://apigp0006.creinnovations.in/apis/mlm/hair_segmentation/", - "title": "Cre_Hair_Detection_Segment_Model", - "method": "MULTI", - "path": "/hair_segmentation/image/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/hair_segmentation/image/", - "port": "8000", - "resp": "image/png", - "summary": "Alpha-matte hair segmentation extracting individual locks and flyaways.", - "desc": "BiSeNet-based semantic hair segmentation. Isolates hair boundaries from facial skin, clothing, and background for hair recoloring or restyling pipelines.", - "params": [ - { - "n": "image", - "al": "image0", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Portrait photograph displaying hair." - } - ], - "chips": [], - "subs": [], - "curl": "", - "endpoints": [ - { - "id": "ml-hair-segmentation", - "method": "POST", - "subpath": "image/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/hair_segmentation/image/", - "path": "/hair_segmentation/image/", - "title": "High-Precision Hair Segmentation", - "summary": "Alpha-matte hair segmentation extracting individual locks and flyaways.", - "desc": "BiSeNet-based semantic hair segmentation. Isolates hair boundaries from facial skin, clothing, and background for hair recoloring or restyling pipelines.", - "params": [ - { - "n": "image", - "al": "image0", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Portrait photograph displaying hair." - } - ], - "chips": [], - "resp": "image/png", - "subs": [], - "curl": "" - }, - { - "id": "ml-hair-yolo-sam", - "method": "POST", - "subpath": "yolo_sam/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/hair_segmentation/yolo_sam/", - "path": "/hair_segmentation_yolo_sam/image/", - "title": "Hair Segmentation YOLO + SAM", - "summary": "Hybrid YOLO head-bounding-box + Segment Anything (SAM) hair matting.", - "desc": "Combines YOLOv8 head detection bounding prompts with SAM high-resolution zero-shot mask refinement, handling intricate ethnic hairstyles, braids, and curly hair.", - "params": [ - { - "n": "image", - "al": "image0", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Portrait photograph." - } - ], - "chips": [], - "resp": "image/png", - "subs": [], - "curl": "" - } - ] - }, - { - "id": "api-stable-diffusion-hair-segmentation", - "api_key": "Stable_Diffusion_Hair_Segmentation", - "api_ip_link": "https://apigp0006.creinnovations.in/apis/mlm/stable_diffusion_hair_segmentation/", - "title": "Stable_Diffusion_Hair_Segmentation", - "method": "POST", - "path": "/stable_diffusion_hair_segmentation/image/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/stable_diffusion_hair_segmentation/image/", - "port": "8000", - "resp": "image/png", - "summary": "Specialized hair segmentation pre-processor for legacy SD inpainting pipelines.", - "desc": "Outputs hair masks pre-conditioned with dilation and gaussian boundary feathering tailored for stable diffusion inpainting tensors.", - "params": [ - { - "n": "image", - "al": "image0", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Input image." - } - ], - "chips": [], - "subs": [ - { - "m": "POST", - "p": "/stable_diffusion_hair_segmentation/image/", - "d": "Primary hair inpainting mask" - }, - { - "m": "POST", - "p": "/stable_diffusion_hair_segmentation/image1/", - "d": "Secondary dilated hair mask" - }, - { - "m": "POST", - "p": "/stable_diffusion_hair_segmentation/cleanup/", - "d": "Artifact cleanup filter" - } - ], - "curl": "", - "endpoints": [ - { - "id": "ml-sd-hair-segmentation", - "method": "POST", - "subpath": "image/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/stable_diffusion_hair_segmentation/image/", - "path": "/stable_diffusion_hair_segmentation/image/", - "title": "Stable Diffusion Hair Segmentation Router", - "summary": "Specialized hair segmentation pre-processor for legacy SD inpainting pipelines.", - "desc": "Outputs hair masks pre-conditioned with dilation and gaussian boundary feathering tailored for stable diffusion inpainting tensors.", - "params": [ - { - "n": "image", - "al": "image0", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Input image." - } - ], - "chips": [], - "resp": "image/png", - "subs": [ - { - "m": "POST", - "p": "/stable_diffusion_hair_segmentation/image/", - "d": "Primary hair inpainting mask" - }, - { - "m": "POST", - "p": "/stable_diffusion_hair_segmentation/image1/", - "d": "Secondary dilated hair mask" - }, - { - "m": "POST", - "p": "/stable_diffusion_hair_segmentation/cleanup/", - "d": "Artifact cleanup filter" - } - ], - "curl": "" - } - ] - }, - { - "id": "api-eye-bag-remover", - "api_key": "Eye_Bag_Remover", - "api_ip_link": "https://apigp0006.creinnovations.in/apis/mlm/eye_bag_remover/", - "title": "Eye_Bag_Remover", - "method": "POST", - "path": "/eye_bag_remover/image/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/eye_bag_remover/image/", - "port": "8000", - "resp": "image/png", - "summary": "Lightens infraorbital dark circles and smoothes under-eye bags.", - "desc": "Identifies the infraorbital hollow and lower eyelid landmarks, gently lifting shadows and evening out melanin hyperpigmentation without creating artificial flat patches.", - "params": [ - { - "n": "image", - "al": "image0", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Portrait with noticeable dark circles or lower eye puffiness." - } - ], - "chips": [], - "subs": [], - "curl": "", - "endpoints": [ - { - "id": "ml-eye-bag-remover", - "method": "POST", - "subpath": "image/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/eye_bag_remover/image/", - "path": "/eye_bag_remover/image/", - "title": "Under-Eye Bag & Dark Circle Remover", - "summary": "Lightens infraorbital dark circles and smoothes under-eye bags.", - "desc": "Identifies the infraorbital hollow and lower eyelid landmarks, gently lifting shadows and evening out melanin hyperpigmentation without creating artificial flat patches.", - "params": [ - { - "n": "image", - "al": "image0", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Portrait with noticeable dark circles or lower eye puffiness." - } - ], - "chips": [], - "resp": "image/png", - "subs": [], - "curl": "" - } - ] - }, - { - "id": "api-skin-detection", - "api_key": "Skin_Detection", - "api_ip_link": "https://apigp0006.creinnovations.in/apis/mlm/skin_detection/", - "title": "Skin_Detection", - "method": "POST", - "path": "/skin_detection/image/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/skin_detection/image/", - "port": "8000", - "resp": "image/png", - "summary": "Extracts binary skin segmentation masks across face, neck, and exposed limbs.", - "desc": "Uses pixel-level chromatic color models and deep convolutional masks to segment exposed skin regions while omitting hair, eyes, lips, and clothing.", - "params": [ - { - "n": "image", - "al": "image0", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Input photograph with exposed human subjects." - } - ], - "chips": [], - "subs": [], - "curl": "", - "endpoints": [ - { - "id": "ml-skin-detection", - "method": "POST", - "subpath": "image/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/skin_detection/image/", - "path": "/skin_detection/image/", - "title": "Skin Detection & Mask Extractor", - "summary": "Extracts binary skin segmentation masks across face, neck, and exposed limbs.", - "desc": "Uses pixel-level chromatic color models and deep convolutional masks to segment exposed skin regions while omitting hair, eyes, lips, and clothing.", - "params": [ - { - "n": "image", - "al": "image0", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Input photograph with exposed human subjects." - } - ], - "chips": [], - "resp": "image/png", - "subs": [], - "curl": "" - } - ] - }, - { - "id": "api-sky-detection", - "api_key": "Sky_Detection", - "api_ip_link": "https://apigp0006.creinnovations.in/apis/mlm/sky_detection/", - "title": "Sky_Detection", - "method": "POST", - "path": "/sky_detection/image/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/sky_detection/image/", - "port": "8000", - "resp": "image/png", - "summary": "Extracts accurate sky silhouette masks for sky replacement workflows.", - "desc": "Segments open sky, clouds, and atmospheric background behind trees, buildings, and human silhouettes, producing an anti-aliased matte suitable for sky replacement.", - "params": [ - { - "n": "image", - "al": "image0", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Outdoor landscape or urban photograph." - } - ], - "chips": [], - "subs": [], - "curl": "", - "endpoints": [ - { - "id": "ml-sky-detection", - "method": "POST", - "subpath": "image/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/sky_detection/image/", - "path": "/sky_detection/image/", - "title": "Sky Detection & Horizon Mask Extractor", - "summary": "Extracts accurate sky silhouette masks for sky replacement workflows.", - "desc": "Segments open sky, clouds, and atmospheric background behind trees, buildings, and human silhouettes, producing an anti-aliased matte suitable for sky replacement.", - "params": [ - { - "n": "image", - "al": "image0", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Outdoor landscape or urban photograph." - } - ], - "chips": [], - "resp": "image/png", - "subs": [], - "curl": "" - } - ] - }, - { - "id": "api-cloth-segmentation-model-v2", - "api_key": "Cloth_Segmentation_Model_V2", - "api_ip_link": "https://apigp0006.creinnovations.in/apis/mlm/cloth_segmentation_v2/", - "title": "Cloth_Segmentation_Model_V2", - "method": "POST", - "path": "/cloth_segmentation_v2/segment/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/cloth_segmentation_v2/segment/", - "port": "8000", - "resp": "image/png", - "summary": "High-resolution multi-part garment segmentation forwarding to YOLO+SAM ComfyUI.", - "desc": "Proxies to multi_segmentation_yolo_sam with targeted category prompts. Distinguishes between upper body garments (shirts, jackets), lower body garments (pants, skirts), and full dresses.", - "params": [ - { - "n": "image", - "al": "image0", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Photo of dressed person." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "\ud83d\udd11 Authentication: Authentication secret key (\\\u0007bcdef\\)." - }, - { - "n": "cloth_part", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "full", - "ds": "Target garment category: 'upper', 'lower', or 'full'." - } - ], - "chips": [], - "subs": [], - "curl": "", - "endpoints": [ - { - "id": "ml-cloth-segmentation-v2", - "method": "POST", - "subpath": "segment/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/cloth_segmentation_v2/segment/", - "path": "/cloth_segmentation_v2/segment/", - "title": "Cloth Segmentation V2 (Multi-Part Router)", - "summary": "High-resolution multi-part garment segmentation forwarding to YOLO+SAM ComfyUI.", - "desc": "Proxies to multi_segmentation_yolo_sam with targeted category prompts. Distinguishes between upper body garments (shirts, jackets), lower body garments (pants, skirts), and full dresses.", - "params": [ - { - "n": "image", - "al": "image0", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Photo of dressed person." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "\ud83d\udd11 Authentication: Authentication secret key (\\\u0007bcdef\\)." - }, - { - "n": "cloth_part", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "full", - "ds": "Target garment category: 'upper', 'lower', or 'full'." - } - ], - "chips": [], - "resp": "image/png", - "subs": [], - "curl": "" - } - ] - }, - { - "id": "api-pose-detection", - "api_key": "Pose_Detection", - "api_ip_link": "https://apigp0006.creinnovations.in/apis/mlm/pose_detection/", - "title": "Pose_Detection", - "method": "POST", - "path": "/pose_detection/image/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/pose_detection/image/", - "port": "8000", - "resp": "application/json", - "summary": "Detects 33 full-body anatomical skeletal keypoints (joints, wrists, hips, ankles).", - "desc": "Runs real-time human pose estimation to return (x, y, z, visibility) coordinates for skeletal landmarks, supporting gesture validation and ControlNet conditioning.", - "params": [ - { - "n": "image", - "al": "image0", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Input image containing full or partial human figures." - } - ], - "chips": [], - "subs": [], - "curl": "", - "endpoints": [ - { - "id": "ml-pose-detection", - "method": "POST", - "subpath": "image/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/pose_detection/image/", - "path": "/pose_detection/image/", - "title": "MediaPipe & OpenPose Keypoint Detection", - "summary": "Detects 33 full-body anatomical skeletal keypoints (joints, wrists, hips, ankles).", - "desc": "Runs real-time human pose estimation to return (x, y, z, visibility) coordinates for skeletal landmarks, supporting gesture validation and ControlNet conditioning.", - "params": [ - { - "n": "image", - "al": "image0", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Input image containing full or partial human figures." - } - ], - "chips": [], - "resp": "application/json", - "subs": [], - "curl": "" - } - ] - }, - { - "id": "api-caricature-avatar", - "api_key": "Caricature_Avatar", - "api_ip_link": "https://apigp0006.creinnovations.in/apis/mlm/caricature_avatar/", - "title": "Caricature_Avatar", - "method": "MULTI", - "path": "/caricature_avatar/image/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/caricature_avatar/image/", - "port": "8000", - "resp": "image/png", - "summary": "Transforms facial features into exaggerated cartoon caricatures.", - "desc": "Detects facial contours, magnifies eyes and smiles, and composites stylized caricatures for single individuals or couples on themed bodies.", - "params": [ - { - "n": "image", - "al": "image0", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Portrait photograph displaying clear facial expression." - } - ], - "chips": [], - "subs": [ - { - "m": "POST", - "p": "/caricature_avatar/image/", - "d": "Primary single avatar caricature" - }, - { - "m": "POST", - "p": "/caricature_avatar/image1/", - "d": "Alternative caricature style" - }, - { - "m": "POST", - "p": "/caricature_avatar/single_couple_image/", - "d": "Couple caricature avatar composition" - } - ], - "curl": "", - "endpoints": [ - { - "id": "ml-caricature-avatar", - "method": "POST", - "subpath": "image/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/caricature_avatar/image/", - "path": "/caricature_avatar/image/", - "title": "Caricature Avatar Composite Pipeline", - "summary": "Transforms facial features into exaggerated cartoon caricatures.", - "desc": "Detects facial contours, magnifies eyes and smiles, and composites stylized caricatures for single individuals or couples on themed bodies.", - "params": [ - { - "n": "image", - "al": "image0", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Portrait photograph displaying clear facial expression." - } - ], - "chips": [], - "resp": "image/png", - "subs": [ - { - "m": "POST", - "p": "/caricature_avatar/image/", - "d": "Primary single avatar caricature" - }, - { - "m": "POST", - "p": "/caricature_avatar/image1/", - "d": "Alternative caricature style" - }, - { - "m": "POST", - "p": "/caricature_avatar/single_couple_image/", - "d": "Couple caricature avatar composition" - } - ], - "curl": "" - }, - { - "id": "ml-caricature-avatar-couple", - "method": "POST", - "subpath": "image1/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/caricature_avatar/image1/", - "path": "/caricature_avatar/image1/", - "title": "Caricature Avatar \u2014 Couple Composite (image1)", - "summary": "Generates a couple caricature avatar by compositing two source faces onto a themed couple reference template.", - "desc": "Generates a couple caricature avatar by compositing two source faces onto a themed couple reference template. Automatically detects gender from each source image and assigns the male/female side of the couple template accordingly. Both images must be of different genders (HTTP 406 if same).", - "params": [ - { - "n": "source1", - "al": "", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "First person\u2019s portrait. Gender is detected automatically." - }, - { - "n": "source2", - "al": "", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Second person\u2019s portrait. Must be a different gender from the first." - }, - { - "n": "reference", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "test_ref", - "ds": "Reference identifier or style preset key." - }, - { - "n": "app_name", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "test_app", - "ds": "Originating client application tag for tracking." - } - ], - "chips": [], - "resp": "image/jpeg", - "subs": [], - "curl": "curl -X POST \"{{base}}:5925/caricature_avatar/image1/\" \\\n -F \"source1=@source1.jpg\" \\\n -F \"source2=@source2.jpg\" \\\n -F \"reference=value\" \\\n -F \"app_name=value\"" - }, - { - "id": "ml-caricature-avatar-single-couple", - "method": "POST", - "subpath": "single_couple_image/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/caricature_avatar/single_couple_image/", - "path": "/caricature_avatar/single_couple_image/", - "title": "Caricature Avatar \u2014 Single Source Couple Template", - "summary": "Places a single person's face onto one side of a couple-themed reference composite.", - "desc": "Places a single person's face onto one side of a couple-themed reference composite. Used when only one user is uploading but wants the full couple-themed caricature frame.", - "params": [ - { - "n": "source", - "al": "", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Portrait of the person to place in the couple-themed frame." - }, - { - "n": "reference", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "test_ref", - "ds": "Reference identifier or style preset key." - }, - { - "n": "app_name", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "test_app", - "ds": "Originating client application tag for tracking." - } - ], - "chips": [], - "resp": "image/jpeg", - "subs": [], - "curl": "curl -X POST \"{{base}}:5925/caricature_avatar/single_couple_image/\" \\\n -F \"source=@source.jpg\" \\\n -F \"reference=value\" \\\n -F \"app_name=value\"" - } - ] - }, - { - "id": "api-teeth-whitener", - "api_key": "Teeth_Whitener", - "api_ip_link": "https://apigp0006.creinnovations.in/apis/mlm/teeth_whitener/", - "title": "Teeth_Whitener", - "method": "MULTI", - "path": "/teeth_whitener/image/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/teeth_whitener/image/", - "port": "8000", - "resp": "image/png", - "summary": "Photorealistic dental enamel whitening and desaturation via CIELAB color space.", - "desc": "Detects dental enamel masks via BiSeNet/MediaPipe landmarks and converts pixels to CIELAB space to specifically isolate and suppress yellow/red stain chrominance while elevating luminosity.", - "params": [ - { - "n": "image", - "al": "image0", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Portrait photograph displaying teeth." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "\ud83d\udd11 Authentication: Required authentication key (\\\u0007bcdef\\)." - }, - { - "n": "strength", - "al": "", - "ty": "float", - "lc": "multipart/form-data", - "rq": false, - "df": "1.0", - "ds": "Master whitening intensity multiplier (0.1 to 2.0)." - }, - { - "n": "l_boost", - "al": "", - "ty": "float", - "lc": "multipart/form-data", - "rq": false, - "df": "15.0", - "ds": "Lightness channel (L*) gain in CIELAB space." - }, - { - "n": "reduce_yellow", - "al": "", - "ty": "float", - "lc": "multipart/form-data", - "rq": false, - "df": "0.75", - "ds": "Yellow-blue chrominance (b*) desaturation factor." - }, - { - "n": "reduce_red", - "al": "", - "ty": "float", - "lc": "multipart/form-data", - "rq": false, - "df": "0.4", - "ds": "Red-green chrominance (a*) desaturation factor." - }, - { - "n": "passes", - "al": "", - "ty": "float", - "lc": "multipart/form-data", - "rq": false, - "df": "1.0", - "ds": "Number of color transform passes." - }, - { - "n": "max_faces", - "al": "", - "ty": "float", - "lc": "multipart/form-data", - "rq": false, - "df": "1.0", - "ds": "Maximum number of smiling faces to whiten." - }, - { - "n": "target_a", - "al": "", - "ty": "float", - "lc": "multipart/form-data", - "rq": false, - "df": "0.0", - "ds": "Target color balance target for a* channel." - }, - { - "n": "target_b", - "al": "", - "ty": "float", - "lc": "multipart/form-data", - "rq": false, - "df": "0.0", - "ds": "Target color balance target for b* channel." - } - ], - "chips": [], - "subs": [], - "curl": "", - "endpoints": [ - { - "id": "ml-teeth-whitener", - "method": "POST", - "subpath": "image/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/teeth_whitener/image/", - "path": "/teeth_whitener/image/", - "title": "Natural CIELAB Teeth Whitener", - "summary": "Photorealistic dental enamel whitening and desaturation via CIELAB color space.", - "desc": "Detects dental enamel masks via BiSeNet/MediaPipe landmarks and converts pixels to CIELAB space to specifically isolate and suppress yellow/red stain chrominance while elevating luminosity.", - "params": [ - { - "n": "image", - "al": "image0", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Portrait photograph displaying teeth." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "\ud83d\udd11 Authentication: Required authentication key (\\\u0007bcdef\\)." - }, - { - "n": "strength", - "al": "", - "ty": "float", - "lc": "multipart/form-data", - "rq": false, - "df": "1.0", - "ds": "Master whitening intensity multiplier (0.1 to 2.0)." - }, - { - "n": "l_boost", - "al": "", - "ty": "float", - "lc": "multipart/form-data", - "rq": false, - "df": "15.0", - "ds": "Lightness channel (L*) gain in CIELAB space." - }, - { - "n": "reduce_yellow", - "al": "", - "ty": "float", - "lc": "multipart/form-data", - "rq": false, - "df": "0.75", - "ds": "Yellow-blue chrominance (b*) desaturation factor." - }, - { - "n": "reduce_red", - "al": "", - "ty": "float", - "lc": "multipart/form-data", - "rq": false, - "df": "0.4", - "ds": "Red-green chrominance (a*) desaturation factor." - }, - { - "n": "passes", - "al": "", - "ty": "float", - "lc": "multipart/form-data", - "rq": false, - "df": "1.0", - "ds": "Number of color transform passes." - }, - { - "n": "max_faces", - "al": "", - "ty": "float", - "lc": "multipart/form-data", - "rq": false, - "df": "1.0", - "ds": "Maximum number of smiling faces to whiten." - }, - { - "n": "target_a", - "al": "", - "ty": "float", - "lc": "multipart/form-data", - "rq": false, - "df": "0.0", - "ds": "Target color balance target for a* channel." - }, - { - "n": "target_b", - "al": "", - "ty": "float", - "lc": "multipart/form-data", - "rq": false, - "df": "0.0", - "ds": "Target color balance target for b* channel." - } - ], - "chips": [], - "resp": "image/png", - "subs": [], - "curl": "" - }, - { - "id": "ml-teeth-whitener-full", - "method": "POST", - "subpath": "image_full/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/teeth_whitener/image_full/", - "path": "/teeth_whitener/image_full/", - "title": "Full Aggressive Teeth Whitener", - "summary": "Multi-pass aggressive teeth whitening with extended configuration options.", - "desc": "Multi-pass aggressive teeth whitening with extended configuration options. Applies higher-strength whitening passes ( process_teeth_whitening with full mode flag). Accepts tuning parameters for fine-grained control over whitening intensity, color shift, and coverage.", - "params": [ - { - "n": "image", - "al": "image0", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Portrait photograph displaying teeth." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Authentication key." - }, - { - "n": "strength", - "al": "", - "ty": "float", - "lc": "multipart/form-data", - "rq": false, - "df": "1.0", - "ds": "Master whitening intensity multiplier (0.1 to 2.0)." - }, - { - "n": "l_boost", - "al": "", - "ty": "float", - "lc": "multipart/form-data", - "rq": false, - "df": "15.0", - "ds": "Lightness channel (L*) gain in CIELAB space." - }, - { - "n": "reduce_yellow", - "al": "", - "ty": "float", - "lc": "multipart/form-data", - "rq": false, - "df": "0.75", - "ds": "Yellow-blue chrominance (b*) desaturation factor." - }, - { - "n": "reduce_red", - "al": "", - "ty": "float", - "lc": "multipart/form-data", - "rq": false, - "df": "0.4", - "ds": "Red-green chrominance (a*) desaturation factor." - }, - { - "n": "passes", - "al": "", - "ty": "float", - "lc": "multipart/form-data", - "rq": false, - "df": "1.0", - "ds": "Number of color transform passes." - }, - { - "n": "max_faces", - "al": "", - "ty": "float", - "lc": "multipart/form-data", - "rq": false, - "df": "1.0", - "ds": "Maximum number of smiling faces to whiten." - }, - { - "n": "target_a", - "al": "", - "ty": "float", - "lc": "multipart/form-data", - "rq": false, - "df": "0.0", - "ds": "Target color balance target for a* channel." - }, - { - "n": "target_b", - "al": "", - "ty": "float", - "lc": "multipart/form-data", - "rq": false, - "df": "0.0", - "ds": "Target color balance target for b* channel." - } - ], - "chips": [], - "resp": "image/png", - "subs": [], - "curl": "" - } - ] - }, - { - "id": "api-blemish-remover", - "api_key": "Blemish_Remover", - "api_ip_link": "https://apigp0006.creinnovations.in/apis/mlm/blemish_remover/", - "title": "Blemish_Remover", - "method": "MULTI", - "path": "/blemish_remover/image/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/blemish_remover/image/", - "port": "8000", - "resp": "image/png", - "summary": "AI acne, mole, wrinkle, and eye defect removal preserving natural skin pore texture.", - "desc": "Multi-mode dermatological correction pipeline. Detects facial blemishes, acne, scars, and dark spots and applies local texture infilling. Also provides dedicated eye defect correction and overall skin enhancement.", - "params": [ - { - "n": "image", - "al": "image0", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Portrait photograph displaying blemishes or eye flaws." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "\ud83d\udd11 Authentication: Required authentication key (\\\u0007bcdef\\)." - } - ], - "chips": [], - "subs": [ - { - "m": "POST", - "p": "/blemish_remover/image/", - "d": "Primary acne and blemish removal" - }, - { - "m": "POST", - "p": "/blemish_remover/eye_fix/", - "d": "Eye defect, iris clarity, and sclera correction" - }, - { - "m": "POST", - "p": "/blemish_remover/improver/", - "d": "Full skin texture smoothening and pore tone balancing" - } - ], - "curl": "", - "endpoints": [ - { - "id": "ml-blemish-remover", - "method": "POST", - "subpath": "image/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/blemish_remover/image/", - "path": "/blemish_remover/image/", - "title": "Blemish Remover, Eye Fix & Skin Improver", - "summary": "AI acne, mole, wrinkle, and eye defect removal preserving natural skin pore texture.", - "desc": "Multi-mode dermatological correction pipeline. Detects facial blemishes, acne, scars, and dark spots and applies local texture infilling. Also provides dedicated eye defect correction and overall skin enhancement.", - "params": [ - { - "n": "image", - "al": "image0", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Portrait photograph displaying blemishes or eye flaws." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "\ud83d\udd11 Authentication: Required authentication key (\\\u0007bcdef\\)." - } - ], - "chips": [], - "resp": "image/png", - "subs": [ - { - "m": "POST", - "p": "/blemish_remover/image/", - "d": "Primary acne and blemish removal" - }, - { - "m": "POST", - "p": "/blemish_remover/eye_fix/", - "d": "Eye defect, iris clarity, and sclera correction" - }, - { - "m": "POST", - "p": "/blemish_remover/improver/", - "d": "Full skin texture smoothening and pore tone balancing" - } - ], - "curl": "" - }, - { - "id": "ml-blemish-improver-eye-fix", - "method": "POST", - "subpath": "improver/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/blemish_remover/improver/", - "path": "/blemish_remover/improver/", - "title": "Blemish Remover \u2014 Skin Improver & Eye Fix", - "summary": "Dual-alias endpoint \u2014 /improver/ and /eye_fix/ call the same skin-enhancement pipeline that fixes puffy under-eye bags, redness, and overall skin smoothness.", - "desc": "Dual-alias endpoint \u2014 /improver/ and /eye_fix/ call the same skin-enhancement pipeline that fixes puffy under-eye bags, redness, and overall skin smoothness. Applies the process_improver routine. secretKey validation: optional \u2014 invalid key is rejected, absent key is allowed.", - "params": [ - { - "n": "image0", - "al": "image", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Portrait photograph with under-eye bags, redness or uneven skin." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "None", - "ds": "Authentication key. Optional, but an invalid key is rejected." - } - ], - "chips": [], - "resp": "image/jpeg", - "subs": [], - "curl": "curl -X POST \"{{base}}:5925/blemish_remover/improver/\" \\\n -F \"image0=@image0.jpg\" \\\n -F \"secretKey=value\"" - } - ] - }, - { - "id": "api-eye-redness-remover", - "api_key": "Eye_Redness_Remover", - "api_ip_link": "https://apigp0006.creinnovations.in/apis/mlm/eye_redness_remover/", - "title": "Eye_Redness_Remover", - "method": "POST", - "path": "/eye_redness_remover/image/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/eye_redness_remover/image/", - "port": "8000", - "resp": "image/png", - "summary": "Eliminates camera flash red-eye artifacts and bloodshot sclera redness.", - "desc": "Isolates the iris and sclera landmarks via MediaPipe. Desaturates blood vessel erythema and removes camera flash pupil reflections to yield clean, bright, natural eyes.", - "params": [ - { - "n": "image", - "al": "image0", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Portrait containing bloodshot or red-eye flash glare." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "\ud83d\udd11 Authentication: Required authentication key (\\\u0007bcdef\\)." - } - ], - "chips": [], - "subs": [], - "curl": "", - "endpoints": [ - { - "id": "ml-eye-redness-remover", - "method": "POST", - "subpath": "image/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/eye_redness_remover/image/", - "path": "/eye_redness_remover/image/", - "title": "Eye Redness & Flash Sclera Corrector", - "summary": "Eliminates camera flash red-eye artifacts and bloodshot sclera redness.", - "desc": "Isolates the iris and sclera landmarks via MediaPipe. Desaturates blood vessel erythema and removes camera flash pupil reflections to yield clean, bright, natural eyes.", - "params": [ - { - "n": "image", - "al": "image0", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Portrait containing bloodshot or red-eye flash glare." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "\ud83d\udd11 Authentication: Required authentication key (\\\u0007bcdef\\)." - } - ], - "chips": [], - "resp": "image/png", - "subs": [], - "curl": "" - } - ] - }, - { - "id": "api-polaroid-effect", - "api_key": "Polaroid_Effect", - "api_ip_link": "https://apigp0006.creinnovations.in/apis/mlm/polaroid_effect/", - "title": "Polaroid_Effect", - "method": "POST", - "path": "/polaroid_effect/image/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/polaroid_effect/image/", - "port": "8000", - "resp": "image/png", - "summary": "Applies authentic analog instant film color profiles and borders.", - "desc": "Emulates chemical Polaroid dye shifts, slight halation, vignette softness, and compositing within a realistic white instant camera border.", - "params": [ - { - "n": "image", - "al": "image0", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Input photograph." - } - ], - "chips": [], - "subs": [], - "curl": "", - "endpoints": [ - { - "id": "ml-polaroid-effect", - "method": "POST", - "subpath": "image/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/polaroid_effect/image/", - "path": "/polaroid_effect/image/", - "title": "Vintage Polaroid Frame & Film Emulation", - "summary": "Applies authentic analog instant film color profiles and borders.", - "desc": "Emulates chemical Polaroid dye shifts, slight halation, vignette softness, and compositing within a realistic white instant camera border.", - "params": [ - { - "n": "image", - "al": "image0", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Input photograph." - } - ], - "chips": [], - "resp": "image/png", - "subs": [], - "curl": "" - } - ] - }, - { - "id": "api-face-swapper", - "api_key": "Face_Swapper", - "api_ip_link": "https://apigp0006.creinnovations.in/apis/mlm/face_swapper/", - "title": "Face_Swapper", - "method": "MULTI", - "path": "/face_swapper/image/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/face_swapper/image/", - "port": "8000", - "resp": "image/png", - "summary": "High-fidelity identity swapping with SimSwap / InsightFace and face enhancement.", - "desc": "Swaps the facial identity from a source portrait onto a target image while preserving lighting, head angle, expression, and skin tone. Supports single portraits, couple swaps, and specific eye modifications.", - "params": [ - { - "n": "image", - "al": "image0", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Target photo containing the body/scene to receive the face." - }, - { - "n": "source", - "al": "target", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": false, - "df": "None", - "ds": "Source portrait containing the identity to graft onto target." - }, - { - "n": "reference", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "test_ref", - "ds": "Reference identifier or style preset key." - }, - { - "n": "app_name", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "test_app", - "ds": "Originating client application tag for tracking." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "None", - "ds": "\ud83d\udd11 Authentication: API authentication key (if enabled)." - } - ], - "chips": [], - "subs": [ - { - "m": "POST", - "p": "/face_swapper/image/", - "d": "Standard single face swap" - }, - { - "m": "POST", - "p": "/face_swapper/couple_swap/", - "d": "Dual person/couple face swap using source and target images" - }, - { - "m": "POST", - "p": "/face_swapper/eyes/", - "d": "Eye region facial feature replacement" - }, - { - "m": "POST", - "p": "/face_swapper/open_eye_new/", - "d": "Corrects closed eyes in portrait photos" - }, - { - "m": "POST", - "p": "/face_swapper/couple_swap_single/", - "d": "Swap single face within a multi-person photo" - } - ], - "curl": "", - "endpoints": [ - { - "id": "ml-face-swapper", - "method": "POST", - "subpath": "image/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/face_swapper/image/", - "path": "/face_swapper/image/", - "title": "InsightFace Single & Couple Face Swapper", - "summary": "High-fidelity identity swapping with SimSwap / InsightFace and face enhancement.", - "desc": "Swaps the facial identity from a source portrait onto a target image while preserving lighting, head angle, expression, and skin tone. Supports single portraits, couple swaps, and specific eye modifications.", - "params": [ - { - "n": "image", - "al": "image0", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Target photo containing the body/scene to receive the face." - }, - { - "n": "source", - "al": "target", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": false, - "df": "None", - "ds": "Source portrait containing the identity to graft onto target." - }, - { - "n": "reference", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "test_ref", - "ds": "Reference identifier or style preset key." - }, - { - "n": "app_name", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "test_app", - "ds": "Originating client application tag for tracking." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "None", - "ds": "\ud83d\udd11 Authentication: API authentication key (if enabled)." - } - ], - "chips": [], - "resp": "image/png", - "subs": [ - { - "m": "POST", - "p": "/face_swapper/image/", - "d": "Standard single face swap" - }, - { - "m": "POST", - "p": "/face_swapper/couple_swap/", - "d": "Dual person/couple face swap using source and target images" - }, - { - "m": "POST", - "p": "/face_swapper/eyes/", - "d": "Eye region facial feature replacement" - }, - { - "m": "POST", - "p": "/face_swapper/open_eye_new/", - "d": "Corrects closed eyes in portrait photos" - }, - { - "m": "POST", - "p": "/face_swapper/couple_swap_single/", - "d": "Swap single face within a multi-person photo" - } - ], - "curl": "" - }, - { - "id": "ml-face-swapper-couple", - "method": "POST", - "subpath": "couple_swap/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/face_swapper/couple_swap/", - "path": "/face_swapper/couple_swap/", - "title": "Couple Face Swap (Two Source Targets)", - "summary": "Swaps two source faces onto both persons in a pre-stored couple reference template.", - "desc": "Swaps two source faces onto both persons in a pre-stored couple reference template. Both source images are required. Reference template is loaded from server-side storage.", - "params": [ - { - "n": "source1", - "al": "", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "First person\u2019s portrait to place on the couple template." - }, - { - "n": "source2", - "al": "", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Second person\u2019s portrait to place on the couple template." - }, - { - "n": "reference", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "test_ref", - "ds": "Reference identifier or style preset key." - }, - { - "n": "app_name", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "test_app", - "ds": "Originating client application tag for tracking." - } - ], - "chips": [], - "resp": "image/jpeg", - "subs": [], - "curl": "curl -X POST \"{{base}}:5925/face_swapper/couple_swap/\" \\\n -F \"source1=@source1.jpg\" \\\n -F \"source2=@source2.jpg\" \\\n -F \"reference=value\" \\\n -F \"app_name=value\"" - }, - { - "id": "ml-face-swapper-eyes", - "method": "POST", - "subpath": "eyes/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/face_swapper/eyes/", - "path": "/face_swapper/eyes/", - "title": "Eye Region Targeted Swap", - "summary": "Transplants only the eye region (iris, eyelid, and surrounding area) from a source image onto a target image.", - "desc": "Transplants only the eye region (iris, eyelid, and surrounding area) from a source image onto a target image. Useful for open-eye correction when one person's eyes are closed.", - "params": [ - { - "n": "source", - "al": "", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Image providing the open eyes to transplant." - }, - { - "n": "target", - "al": "", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Image receiving the eye region." - }, - { - "n": "reference", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "test_ref", - "ds": "Reference identifier or style preset key." - }, - { - "n": "app_name", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "test_app", - "ds": "Originating client application tag for tracking." - } - ], - "chips": [], - "resp": "image/jpeg", - "subs": [], - "curl": "curl -X POST \"{{base}}:5925/face_swapper/eyes/\" \\\n -F \"source=@source.jpg\" \\\n -F \"target=@target.jpg\" \\\n -F \"reference=value\" \\\n -F \"app_name=value\"" - }, - { - "id": "ml-face-swapper-open-eye", - "method": "POST", - "subpath": "open_eye_new/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/face_swapper/open_eye_new/", - "path": "/face_swapper/open_eye_new/", - "title": "Open Eye Blink Corrector", - "summary": "Improved open-eye synthesis algorithm.", - "desc": "Improved open-eye synthesis algorithm. Replaces closed eyes in the source image with open eyes from the target image. Both images are required for this endpoint.", - "params": [ - { - "n": "source", - "al": "", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Image containing the closed eyes to correct." - }, - { - "n": "target", - "al": "", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Image providing the open eyes." - } - ], - "chips": [], - "resp": "image/jpeg", - "subs": [], - "curl": "curl -X POST \"{{base}}:5925/face_swapper/open_eye_new/\" \\\n -F \"source=@source.jpg\" \\\n -F \"target=@target.jpg\"" - }, - { - "id": "ml-face-swapper-couple-single", - "method": "POST", - "subpath": "couple_swap_single/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/face_swapper/couple_swap_single/", - "path": "/face_swapper/couple_swap_single/", - "title": "Couple Swap (Single Source Template)", - "summary": "Single-source couple composite \u2014 inserts one person's face into a couple reference image, swapping only one side of the couple template while keeping the other side unchanged.", - "desc": "Single-source couple composite \u2014 inserts one person's face into a couple reference image, swapping only one side of the couple template while keeping the other side unchanged.", - "params": [ - { - "n": "source", - "al": "", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Portrait of the person to insert into the couple template." - }, - { - "n": "reference", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "test_ref", - "ds": "Reference identifier or style preset key." - }, - { - "n": "app_name", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "test_app", - "ds": "Originating client application tag for tracking." - } - ], - "chips": [], - "resp": "image/jpeg", - "subs": [], - "curl": "curl -X POST \"{{base}}:5925/face_swapper/couple_swap_single/\" \\\n -F \"source=@source.jpg\" \\\n -F \"reference=value\" \\\n -F \"app_name=value\"" - } - ] - }, - { - "id": "api-stable-diffusion-relighter", - "api_key": "Stable_Diffusion_Relighter", - "api_ip_link": "https://apigp0006.creinnovations.in/apis/mlm/relighting_effect/", - "title": "Stable_Diffusion_Relighter", - "method": "POST", - "path": "/relighting_effect/image/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/relighting_effect/image/", - "port": "8000", - "resp": "image/png", - "summary": "Alters portrait studio lighting angle, direction, temperature, and specular shine.", - "desc": "Computes normal vectors and surface albedo to cast synthetic directional rim lighting, dramatic chiaroscuro shadows, or warm golden-hour illumination onto flat portraits.", - "params": [ - { - "n": "image", - "al": "image0", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Portrait photograph." - } - ], - "chips": [], - "subs": [], - "curl": "", - "endpoints": [ - { - "id": "ml-relighting-effect", - "method": "POST", - "subpath": "image/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/relighting_effect/image/", - "path": "/relighting_effect/image/", - "title": "Neural Studio Relighting & Shadow Synthesizer", - "summary": "Alters portrait studio lighting angle, direction, temperature, and specular shine.", - "desc": "Computes normal vectors and surface albedo to cast synthetic directional rim lighting, dramatic chiaroscuro shadows, or warm golden-hour illumination onto flat portraits.", - "params": [ - { - "n": "image", - "al": "image0", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Portrait photograph." - } - ], - "chips": [], - "resp": "image/png", - "subs": [], - "curl": "" - } - ] - }, - { - "id": "api-face-analyzer", - "api_key": "Face_Analyzer", - "api_ip_link": "https://apigp0006.creinnovations.in/apis/mlm/skin_analyzer/", - "title": "Face_Analyzer", - "method": "POST", - "path": "/skin_analyzer/analyze", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/skin_analyzer/analyze", - "port": "8000", - "resp": "application/json", - "summary": "Quantitative dermatological diagnostic analysis returning JSON scores.", - "desc": "Analyzes portrait images to output detailed JSON metrics covering acne severity, dark circles, wrinkles, skin hydration, oiliness, pore density, and skin age estimation.", - "params": [ - { - "n": "image", - "al": "image0", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Close-up well-lit facial photograph." - } - ], - "chips": [], - "subs": [], - "curl": "", - "endpoints": [ - { - "id": "ml-skin-analyzer", - "method": "POST", - "subpath": "analyze", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/skin_analyzer/analyze", - "path": "/skin_analyzer/analyze", - "title": "Comprehensive AI Skin Health & Metrics Analyzer", - "summary": "Quantitative dermatological diagnostic analysis returning JSON scores.", - "desc": "Analyzes portrait images to output detailed JSON metrics covering acne severity, dark circles, wrinkles, skin hydration, oiliness, pore density, and skin age estimation.", - "params": [ - { - "n": "image", - "al": "image0", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Close-up well-lit facial photograph." - } - ], - "chips": [], - "resp": "application/json", - "subs": [], - "curl": "" - } - ] - }, - { - "id": "api-trendy", - "api_key": "Trendy", - "api_ip_link": "https://apigp0006.creinnovations.in/apis/mlm/trendy/", - "title": "Trendy", - "method": "POST", - "path": "/image/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/trendy/image/", - "port": "8000", - "resp": "image/png", - "summary": "Trendy AI Stylization Filter", - "desc": "Trendy AI Stylization Filter", - "params": [ - { - "n": "image", - "al": "image0", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Input image file." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "'abcdef'", - "ds": "\ud83d\udd11 Authentication secret key." - } - ], - "chips": [], - "subs": [], - "curl": "", - "endpoints": [ - { - "id": "api-trendy", - "method": "POST", - "subpath": "image/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/trendy/image/", - "path": "/image/", - "title": "Trendy AI Stylization Filter", - "summary": "Trendy AI Stylization Filter", - "desc": "Trendy AI Stylization Filter", - "params": [ - { - "n": "image", - "al": "image0", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Input image file." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "'abcdef'", - "ds": "\ud83d\udd11 Authentication secret key." - } - ], - "chips": [], - "resp": "image/png", - "subs": [], - "curl": "" - } - ] - } - ] - }, - { - "id": "sec-comfyui", - "key": "comfyui", - "icon": "\ud83e\udde9", - "title": "ComfyUI Workflows", - "tag": "Headless Node Graphs", - "lead": "Headless ComfyUI workflow pipelines executing multi-stage node graphs. Combines YOLOv8 detection, SAM segmentation, and iterative inpainting with round-robin server routing for complex multi-garment wardrobe transformations.", - "port": "8188", - "hue": 28, - "eps": [ - { - "id": "api-stable-diffusion-dress-changer", - "api_key": "Stable_Diffusion_Dress_Changer", - "api_ip_link": "https://apigp0905.creinnovations.in/apis/cmf/dress-changer/", - "title": "Stable_Diffusion_Dress_Changer", - "method": "POST", - "path": "/dress-changer/image/", - "full_url": "https://apigp0905.creinnovations.in/apis/cmf/dress-changer/image/", - "port": "8000", - "resp": "image/jpeg", - "summary": "State-of-the-art virtual garment replacement with Sapiens 1B skin protection.", - "desc": "Executes a two-tier ComfyUI pipeline: first calls the internal segmentation server (port 19527) running Sapiens 1B full-body skin segmentation to strictly protect arms, neckline, and midriff; then round-robins across dedicated inpainting servers (ports 19528/19529) running SDXL/Realistic inpainting models. Surfaces detailed latency tracking headers (X-Prompt-Used, X-Model-Used, X-Inpaint-Backend).", - "params": [ - { - "n": "image", - "al": "file", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Input photograph of person wearing clothes to replace." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "\ud83d\udd11 Authentication: Authentication secret key (must equal \"abcdef\")." - }, - { - "n": "category", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "Woman", - "ds": "Target gender/demographic category for dress preset lookup (e.g. \"Woman\", \"Man\")." - }, - { - "n": "dress", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "None", - "ds": "Preset garment identifier from GET /dress-changer/presets." - }, - { - "n": "prompt", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "None", - "ds": "Custom text prompt describing the desired garment (overrides preset)." - }, - { - "n": "model", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "epicrealism", - "ds": "Inpainting model checkpoint identifier from GET /dress-changer/models." - }, - { - "n": "mask", - "al": "", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": false, - "df": "None", - "ds": "Optional precomputed garment mask. If omitted, internal Sapiens segmentation generates it automatically." - } - ], - "chips": [], - "subs": [ - { - "m": "GET", - "p": "/dress-changer/presets", - "d": "List all dress presets grouped by category (Woman, Man, etc.)" - }, - { - "m": "GET", - "p": "/dress-changer/models", - "d": "List available inpainting models (epicrealism, cyberrealistic, etc.) and active backends" - }, - { - "m": "POST", - "p": "/dress-changer/image/", - "d": "Active endpoint: Sapiens 1B full-body skin protection, no ControlNet" - }, - { - "m": "POST", - "p": "/dress-changer/image-with-op/", - "d": "Legacy endpoint: FaceMesh face protection + OpenPose ControlNet" - } - ], - "curl": "", - "endpoints": [ - { - "id": "comfy-dress-changer", - "method": "POST", - "subpath": "image/", - "full_url": "https://apigp0905.creinnovations.in/apis/cmf/dress-changer/image/", - "path": "/dress-changer/image/", - "title": "ComfyUI Sapiens Skin-Seg Dress Changer", - "summary": "State-of-the-art virtual garment replacement with Sapiens 1B skin protection.", - "desc": "Executes a two-tier ComfyUI pipeline: first calls the internal segmentation server (port 19527) running Sapiens 1B full-body skin segmentation to strictly protect arms, neckline, and midriff; then round-robins across dedicated inpainting servers (ports 19528/19529) running SDXL/Realistic inpainting models. Surfaces detailed latency tracking headers (X-Prompt-Used, X-Model-Used, X-Inpaint-Backend).", - "params": [ - { - "n": "image", - "al": "file", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Input photograph of person wearing clothes to replace." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "\ud83d\udd11 Authentication: Authentication secret key (must equal \"abcdef\")." - }, - { - "n": "category", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "Woman", - "ds": "Target gender/demographic category for dress preset lookup (e.g. \"Woman\", \"Man\")." - }, - { - "n": "dress", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "None", - "ds": "Preset garment identifier from GET /dress-changer/presets." - }, - { - "n": "prompt", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "None", - "ds": "Custom text prompt describing the desired garment (overrides preset)." - }, - { - "n": "model", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "epicrealism", - "ds": "Inpainting model checkpoint identifier from GET /dress-changer/models." - }, - { - "n": "mask", - "al": "", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": false, - "df": "None", - "ds": "Optional precomputed garment mask. If omitted, internal Sapiens segmentation generates it automatically." - } - ], - "chips": [], - "resp": "image/jpeg", - "subs": [ - { - "m": "GET", - "p": "/dress-changer/presets", - "d": "List all dress presets grouped by category (Woman, Man, etc.)" - }, - { - "m": "GET", - "p": "/dress-changer/models", - "d": "List available inpainting models (epicrealism, cyberrealistic, etc.) and active backends" - }, - { - "m": "POST", - "p": "/dress-changer/image/", - "d": "Active endpoint: Sapiens 1B full-body skin protection, no ControlNet" - }, - { - "m": "POST", - "p": "/dress-changer/image-with-op/", - "d": "Legacy endpoint: FaceMesh face protection + OpenPose ControlNet" - } - ], - "curl": "" - } - ] - }, - { - "id": "api-multi-segmentation-model", - "api_key": "Multi_Segmentation_Model", - "api_ip_link": "https://apigp0006.creinnovations.in/apis/mlm/multi_segmentation_yolo_sam/", - "title": "Multi_Segmentation_Model", - "method": "POST", - "path": "/multi_segmentation_yolo_sam/image/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/multi_segmentation_yolo_sam/image/", - "port": "8000", - "resp": "image/png", - "summary": "Fast semantic segmentation combining YOLO object detector with Segment Anything (SAM).", - "desc": "Uses ComfyUI as an inference engine executing a dual YOLOv8 + SAM workflow. Bounding boxes detected by YOLO condition the Segment Anything Model to extract pixel-precise category masks for hair, garments, accessories, and backgrounds. Achieves ~1.34s steady-state latency.", - "params": [ - { - "n": "image", - "al": "file", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Input photograph to segment (JPEG/PNG/WEBP)." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "\ud83d\udd11 Authentication: ComfyUI API authentication key (must equal \"abcdef\")." - }, - { - "n": "effect_id", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "dress", - "ds": "Target segmentation preset key. Determines which YOLO class and SAM prompt is activated." - }, - { - "n": "custom_prompt", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "None", - "ds": "Optional zero-shot text conditioning prompt to override default YOLO class definition." - } - ], - "chips": [], - "subs": [ - { - "m": "GET", - "p": "/multi_segmentation_yolo_sam/effects", - "d": "Returns JSON list of supported segmentation target categories and default preset" - }, - { - "m": "POST", - "p": "/multi_segmentation_yolo_sam/image/", - "d": "Runs segmentation pipeline and returns binary category alpha mask" - } - ], - "curl": "", - "endpoints": [ - { - "id": "comfy-multi-segmentation", - "method": "POST", - "subpath": "image/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/multi_segmentation_yolo_sam/image/", - "path": "/multi_segmentation_yolo_sam/image/", - "title": "ComfyUI Multi-Segmentation (YOLO + SAM)", - "summary": "Fast semantic segmentation combining YOLO object detector with Segment Anything (SAM).", - "desc": "Uses ComfyUI as an inference engine executing a dual YOLOv8 + SAM workflow. Bounding boxes detected by YOLO condition the Segment Anything Model to extract pixel-precise category masks for hair, garments, accessories, and backgrounds. Achieves ~1.34s steady-state latency.", - "params": [ - { - "n": "image", - "al": "file", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Input photograph to segment (JPEG/PNG/WEBP)." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "\ud83d\udd11 Authentication: ComfyUI API authentication key (must equal \"abcdef\")." - }, - { - "n": "effect_id", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "dress", - "ds": "Target segmentation preset key. Determines which YOLO class and SAM prompt is activated." - }, - { - "n": "custom_prompt", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "None", - "ds": "Optional zero-shot text conditioning prompt to override default YOLO class definition." - } - ], - "chips": [], - "resp": "image/png", - "subs": [ - { - "m": "GET", - "p": "/multi_segmentation_yolo_sam/effects", - "d": "Returns JSON list of supported segmentation target categories and default preset" - }, - { - "m": "POST", - "p": "/multi_segmentation_yolo_sam/image/", - "d": "Runs segmentation pipeline and returns binary category alpha mask" - } - ], - "curl": "" - } - ] - } - ] - }, - { - "id": "sec-sd15", - "key": "sd15", - "icon": "\u2728", - "title": "Stable Diffusion 1.5", - "tag": "Latent Diffusion", - "lead": "Production fine-tuned SD 1.5 checkpoints for artistic styling, caricature generation, comic art, FaceID avatar synthesis, realistic background inpainting, and studio portrait relighting.", - "port": "8000", - "hue": 150, - "eps": [ - { - "id": "api-stable-diffusion-image-to-image-model", - "api_key": "Stable_Diffusion_Image_To_Image_Model", - "api_ip_link": "https://apigp0006.creinnovations.in/apis/mlm/stable_diffusion/", - "title": "Stable_Diffusion_Image_To_Image_Model", - "method": "POST", - "path": "/stable_diffusion/image/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/stable_diffusion/image/", - "port": "8000", - "resp": "image/png", - "summary": "Ported Django SD1.5 inpainting and stylized transformation endpoint.", - "desc": "Applies SD1.5 latent diffusion inpainting based on effectId preset. Backward-compatible drop-in replacement for legacy Django endpoint. Guarded by standard NSFW threshold (0.45).", - "params": [ - { - "n": "image0", - "al": "image", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Input photograph to stylize." - }, - { - "n": "effectId", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "F1", - "ds": "Diffusion preset identifier." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "\ud83d\udd11 Authentication: Authentication key (\"abcdef\")." - }, - { - "n": "width", - "al": "", - "ty": "integer", - "lc": "multipart/form-data", - "rq": false, - "df": "512", - "ds": "Target render width." - }, - { - "n": "height", - "al": "", - "ty": "integer", - "lc": "multipart/form-data", - "rq": false, - "df": "768", - "ds": "Target render height." - } - ], - "chips": [], - "subs": [ - { - "m": "GET", - "p": "/stable_diffusion/ping/", - "d": "Health check returning {status: true}" - }, - { - "m": "POST", - "p": "/stable_diffusion/image/", - "d": "Execute inpainting effect" - } - ], - "curl": "", - "endpoints": [ - { - "id": "sd15-stable-diffusion", - "method": "POST", - "subpath": "image/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/stable_diffusion/image/", - "path": "/stable_diffusion/image/", - "title": "Stable Diffusion 1.5 General Inpainting", - "summary": "Ported Django SD1.5 inpainting and stylized transformation endpoint.", - "desc": "Applies SD1.5 latent diffusion inpainting based on effectId preset. Backward-compatible drop-in replacement for legacy Django endpoint. Guarded by standard NSFW threshold (0.45).", - "params": [ - { - "n": "image0", - "al": "image", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Input photograph to stylize." - }, - { - "n": "effectId", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "F1", - "ds": "Diffusion preset identifier." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "\ud83d\udd11 Authentication: Authentication key (\"abcdef\")." - }, - { - "n": "width", - "al": "", - "ty": "integer", - "lc": "multipart/form-data", - "rq": false, - "df": "512", - "ds": "Target render width." - }, - { - "n": "height", - "al": "", - "ty": "integer", - "lc": "multipart/form-data", - "rq": false, - "df": "768", - "ds": "Target render height." - } - ], - "chips": [], - "resp": "image/png", - "subs": [ - { - "m": "GET", - "p": "/stable_diffusion/ping/", - "d": "Health check returning {status: true}" - }, - { - "m": "POST", - "p": "/stable_diffusion/image/", - "d": "Execute inpainting effect" - } - ], - "curl": "" - } - ] - }, - { - "id": "api-stable-diffusion-realistic-avatar", - "api_key": "Stable_Diffusion_Realistic_Avatar", - "api_ip_link": "https://apigp0006.creinnovations.in/apis/mlm/stable_diffusion_avatar_with_original_face/", - "title": "Stable_Diffusion_Realistic_Avatar", - "method": "POST", - "path": "/stable_diffusion_avatar_with_original_face/image/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/stable_diffusion_avatar_with_original_face/image/", - "port": "8000", - "resp": "image/png", - "summary": "Generates stylized avatars while transplanting the subject original facial features.", - "desc": "txt2img with OpenPose + IP-Adapter FaceID, followed by Roop high-resolution face swapping. Generates stylized fantasy or professional body avatars while keeping the exact real face identity.", - "params": [ - { - "n": "image0", - "al": "image", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Subject portrait photograph." - }, - { - "n": "face_segmented_image", - "al": "mask", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": false, - "df": "None", - "ds": "Segmented face mask. Required on /image/, automatically synthesized via black_face_mask on /image1_1/ and /super/." - }, - { - "n": "effectId", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "F1", - "ds": "Avatar style preset." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "\ud83d\udd11 Authentication: Authentication key (\"abcdef\")." - }, - { - "n": "width", - "al": "", - "ty": "integer", - "lc": "multipart/form-data", - "rq": false, - "df": "512", - "ds": "Render width." - }, - { - "n": "height", - "al": "", - "ty": "integer", - "lc": "multipart/form-data", - "rq": false, - "df": "768", - "ds": "Render height." - } - ], - "chips": [], - "subs": [ - { - "m": "GET", - "p": "/stable_diffusion_avatar_with_original_face/ping/", - "d": "Health ping" - }, - { - "m": "POST", - "p": "/stable_diffusion_avatar_with_original_face/image/", - "d": "Standard avatar generation (requires face_segmented_image mask)" - }, - { - "m": "POST", - "p": "/stable_diffusion_avatar_with_original_face/image1_1/", - "d": "Inpainting avatar variant (auto-generates face mask if omitted)" - }, - { - "m": "POST", - "p": "/stable_diffusion_avatar_with_original_face/super/", - "d": "Super-detail avatar variant (auto-generates face mask if omitted)" - } - ], - "curl": "", - "endpoints": [ - { - "id": "sd15-avatar-original-face", - "method": "POST", - "subpath": "image/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/stable_diffusion_avatar_with_original_face/image/", - "path": "/stable_diffusion_avatar_with_original_face/image/", - "title": "Avatar with Original Face (FaceID + Roop)", - "summary": "Generates stylized avatars while transplanting the subject original facial features.", - "desc": "txt2img with OpenPose + IP-Adapter FaceID, followed by Roop high-resolution face swapping. Generates stylized fantasy or professional body avatars while keeping the exact real face identity.", - "params": [ - { - "n": "image0", - "al": "image", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Subject portrait photograph." - }, - { - "n": "face_segmented_image", - "al": "mask", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": false, - "df": "None", - "ds": "Segmented face mask. Required on /image/, automatically synthesized via black_face_mask on /image1_1/ and /super/." - }, - { - "n": "effectId", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "F1", - "ds": "Avatar style preset." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "\ud83d\udd11 Authentication: Authentication key (\"abcdef\")." - }, - { - "n": "width", - "al": "", - "ty": "integer", - "lc": "multipart/form-data", - "rq": false, - "df": "512", - "ds": "Render width." - }, - { - "n": "height", - "al": "", - "ty": "integer", - "lc": "multipart/form-data", - "rq": false, - "df": "768", - "ds": "Render height." - } - ], - "chips": [], - "resp": "image/png", - "subs": [ - { - "m": "GET", - "p": "/stable_diffusion_avatar_with_original_face/ping/", - "d": "Health ping" - }, - { - "m": "POST", - "p": "/stable_diffusion_avatar_with_original_face/image/", - "d": "Standard avatar generation (requires face_segmented_image mask)" - }, - { - "m": "POST", - "p": "/stable_diffusion_avatar_with_original_face/image1_1/", - "d": "Inpainting avatar variant (auto-generates face mask if omitted)" - }, - { - "m": "POST", - "p": "/stable_diffusion_avatar_with_original_face/super/", - "d": "Super-detail avatar variant (auto-generates face mask if omitted)" - } - ], - "curl": "" - } - ] - }, - { - "id": "api-stable-diffusion-art-style-transfer", - "api_key": "Stable_Diffusion_Art_Style_Transfer", - "api_ip_link": "https://apigp0006.creinnovations.in/apis/mlm/stable_diffusion_art_style_transfer/", - "title": "Stable_Diffusion_Art_Style_Transfer", - "method": "POST", - "path": "/stable_diffusion_art_style_transfer/image/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/stable_diffusion_art_style_transfer/image/", - "port": "8000", - "resp": "image/png", - "summary": "Impressionist, baroque, and modern art painterly style transfer.", - "desc": "Synthesizes fine-art painting styles onto portrait photography using SD1.5 latent blending with relaxed NSFW threshold (0.70).", - "params": [ - { - "n": "image0", - "al": "image", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Input photograph." - }, - { - "n": "artId", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "Art1", - "ds": "Artistic painterly preset ID." - }, - { - "n": "pose", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "None", - "ds": "Optional pose conditioning prompt." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "\ud83d\udd11 Authentication: Authentication key (\"abcdef\")." - }, - { - "n": "width", - "al": "", - "ty": "integer", - "lc": "multipart/form-data", - "rq": false, - "df": "512", - "ds": "Width." - }, - { - "n": "height", - "al": "", - "ty": "integer", - "lc": "multipart/form-data", - "rq": false, - "df": "768", - "ds": "Height." - } - ], - "chips": [], - "subs": [], - "curl": "", - "endpoints": [ - { - "id": "sd15-art-style-transfer", - "method": "POST", - "subpath": "image/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/stable_diffusion_art_style_transfer/image/", - "path": "/stable_diffusion_art_style_transfer/image/", - "title": "Fine-Art Style Transfer (Neural Style)", - "summary": "Impressionist, baroque, and modern art painterly style transfer.", - "desc": "Synthesizes fine-art painting styles onto portrait photography using SD1.5 latent blending with relaxed NSFW threshold (0.70).", - "params": [ - { - "n": "image0", - "al": "image", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Input photograph." - }, - { - "n": "artId", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "Art1", - "ds": "Artistic painterly preset ID." - }, - { - "n": "pose", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "None", - "ds": "Optional pose conditioning prompt." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "\ud83d\udd11 Authentication: Authentication key (\"abcdef\")." - }, - { - "n": "width", - "al": "", - "ty": "integer", - "lc": "multipart/form-data", - "rq": false, - "df": "512", - "ds": "Width." - }, - { - "n": "height", - "al": "", - "ty": "integer", - "lc": "multipart/form-data", - "rq": false, - "df": "768", - "ds": "Height." - } - ], - "chips": [], - "resp": "image/png", - "subs": [], - "curl": "" - } - ] - }, - { - "id": "api-stable-diffusion-reaslistic-background-changer", - "api_key": "Stable_Diffusion_Reaslistic_Background_Changer", - "api_ip_link": "https://apigp0006.creinnovations.in/apis/mlm/stable_diffusion_realistic_background_changer/", - "title": "Stable_Diffusion_Reaslistic_Background_Changer", - "method": "POST", - "path": "/stable_diffusion_realistic_background_changer/image/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/stable_diffusion_realistic_background_changer/image/", - "port": "8000", - "resp": "image/png", - "summary": "Replaces image backgrounds with photorealistic indoor/outdoor environments.", - "desc": "Inpaints background while preserving subject geometry. Accepts pose hint, colorId presets, or translated custom user prompt. Strict NSFW guard (0.35).", - "params": [ - { - "n": "image0", - "al": "image", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Input photograph." - }, - { - "n": "mask_image", - "al": "mask", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Subject cutout mask (white = background to repaint, black = subject to keep)." - }, - { - "n": "colorId", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "Bg1", - "ds": "Background preset identifier." - }, - { - "n": "pose", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "sitting", - "ds": "Subject posture description (e.g. \"sitting\", \"standing\")." - }, - { - "n": "isFromCustomUserPrompt", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "no", - "ds": "Set to \"yes\" to activate userPrompt override." - }, - { - "n": "userPrompt", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "None", - "ds": "Custom scene description (auto-translated to English)." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "\ud83d\udd11 Authentication: Authentication key (\"abcdef\")." - }, - { - "n": "width", - "al": "", - "ty": "integer", - "lc": "multipart/form-data", - "rq": false, - "df": "512", - "ds": "Width." - }, - { - "n": "height", - "al": "", - "ty": "integer", - "lc": "multipart/form-data", - "rq": false, - "df": "768", - "ds": "Height." - } - ], - "chips": [], - "subs": [], - "curl": "", - "endpoints": [ - { - "id": "sd15-realistic-background-changer", - "method": "POST", - "subpath": "image/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/stable_diffusion_realistic_background_changer/image/", - "path": "/stable_diffusion_realistic_background_changer/image/", - "title": "Realistic Background Changer (SD1.5)", - "summary": "Replaces image backgrounds with photorealistic indoor/outdoor environments.", - "desc": "Inpaints background while preserving subject geometry. Accepts pose hint, colorId presets, or translated custom user prompt. Strict NSFW guard (0.35).", - "params": [ - { - "n": "image0", - "al": "image", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Input photograph." - }, - { - "n": "mask_image", - "al": "mask", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Subject cutout mask (white = background to repaint, black = subject to keep)." - }, - { - "n": "colorId", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "Bg1", - "ds": "Background preset identifier." - }, - { - "n": "pose", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "sitting", - "ds": "Subject posture description (e.g. \"sitting\", \"standing\")." - }, - { - "n": "isFromCustomUserPrompt", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "no", - "ds": "Set to \"yes\" to activate userPrompt override." - }, - { - "n": "userPrompt", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "None", - "ds": "Custom scene description (auto-translated to English)." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "\ud83d\udd11 Authentication: Authentication key (\"abcdef\")." - }, - { - "n": "width", - "al": "", - "ty": "integer", - "lc": "multipart/form-data", - "rq": false, - "df": "512", - "ds": "Width." - }, - { - "n": "height", - "al": "", - "ty": "integer", - "lc": "multipart/form-data", - "rq": false, - "df": "768", - "ds": "Height." - } - ], - "chips": [], - "resp": "image/png", - "subs": [], - "curl": "" - } - ] - }, - { - "id": "api-stable-diffusion-silhouette-maker", - "api_key": "Stable_Diffusion_Silhouette_Maker", - "api_ip_link": "https://apigp0006.creinnovations.in/apis/mlm/stable_diffusion_silhouette_maker/", - "title": "Stable_Diffusion_Silhouette_Maker", - "method": "POST", - "path": "/flux/silhouette/image/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/stable_diffusion_silhouette_maker/image/", - "port": "8000", - "resp": "image/png", - "summary": "Transforms portraits into dramatic artistic back-lit sunset silhouettes.", - "desc": "Applies dramatic rim lighting, sunset gradients, and starry silhouettes across 150 verified presets split by demographic category. Internal pattern: '{category}_{effectId}'.", - "params": [ - { - "n": "image0", - "al": "image", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Input photograph with clear subject outline." - }, - { - "n": "category", - "al": "gender", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Demographic category: 'men', 'women', or 'couple'." - }, - { - "n": "effectId", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Preset ID: 'E1' to 'E50'." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "'abcdef'", - "ds": "\ud83d\udd11 Authentication: API secret key ('abcdef')." - } - ], - "chips": [ - "couple_E1", - "couple_E10", - "couple_E11", - "couple_E12", - "couple_E13", - "couple_E14", - "couple_E15", - "couple_E16", - "couple_E17", - "couple_E18", - "couple_E19", - "couple_E2", - "couple_E20", - "couple_E21", - "couple_E22", - "couple_E23", - "couple_E24", - "couple_E25", - "couple_E26", - "couple_E27", - "couple_E28", - "couple_E29", - "couple_E3", - "couple_E30", - "couple_E31", - "couple_E32", - "couple_E33", - "couple_E34", - "couple_E35", - "couple_E36", - "couple_E37", - "couple_E38", - "couple_E39", - "couple_E4", - "couple_E40", - "couple_E41", - "couple_E42", - "couple_E43", - "couple_E44", - "couple_E45", - "couple_E46", - "couple_E47", - "couple_E48", - "couple_E49", - "couple_E5", - "couple_E50", - "couple_E6", - "couple_E7", - "couple_E8", - "couple_E9", - "men_E1", - "men_E10", - "men_E11", - "men_E12", - "men_E13", - "men_E14", - "men_E15", - "men_E16", - "men_E17", - "men_E18", - "men_E19", - "men_E2", - "men_E20", - "men_E21", - "men_E22", - "men_E23", - "men_E24", - "men_E25", - "men_E26", - "men_E27", - "men_E28", - "men_E29", - "men_E3", - "men_E30", - "men_E31", - "men_E32", - "men_E33", - "men_E34", - "men_E35", - "men_E36", - "men_E37", - "men_E38", - "men_E39", - "men_E4", - "men_E40", - "men_E41", - "men_E42", - "men_E43", - "men_E44", - "men_E45", - "men_E46", - "men_E47", - "men_E48", - "men_E49", - "men_E5", - "men_E50", - "men_E6", - "men_E7", - "men_E8", - "men_E9", - "women_E1", - "women_E10", - "women_E11", - "women_E12", - "women_E13", - "women_E14", - "women_E15", - "women_E16", - "women_E17", - "women_E18", - "women_E19", - "women_E2", - "women_E20", - "women_E21", - "women_E22", - "women_E23", - "women_E24", - "women_E25", - "women_E26", - "women_E27", - "women_E28", - "women_E29", - "women_E3", - "women_E30", - "women_E31", - "women_E32", - "women_E33", - "women_E34", - "women_E35", - "women_E36", - "women_E37", - "women_E38", - "women_E39", - "women_E4", - "women_E40", - "women_E41", - "women_E42", - "women_E43", - "women_E44", - "women_E45", - "women_E46", - "women_E47", - "women_E48", - "women_E49", - "women_E5", - "women_E50", - "women_E6", - "women_E7", - "women_E8", - "women_E9" - ], - "subs": [], - "curl": "", - "endpoints": [ - { - "id": "fk-silhouette", - "method": "POST", - "subpath": "image/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/stable_diffusion_silhouette_maker/image/", - "path": "/flux/silhouette/image/", - "title": "Silhouette & Shadow Profile Generator", - "summary": "Transforms portraits into dramatic artistic back-lit sunset silhouettes.", - "desc": "Applies dramatic rim lighting, sunset gradients, and starry silhouettes across 150 verified presets split by demographic category. Internal pattern: '{category}_{effectId}'.", - "params": [ - { - "n": "image0", - "al": "image", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Input photograph with clear subject outline." - }, - { - "n": "category", - "al": "gender", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Demographic category: 'men', 'women', or 'couple'." - }, - { - "n": "effectId", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Preset ID: 'E1' to 'E50'." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "'abcdef'", - "ds": "\ud83d\udd11 Authentication: API secret key ('abcdef')." - } - ], - "chips": [ - "couple_E1", - "couple_E10", - "couple_E11", - "couple_E12", - "couple_E13", - "couple_E14", - "couple_E15", - "couple_E16", - "couple_E17", - "couple_E18", - "couple_E19", - "couple_E2", - "couple_E20", - "couple_E21", - "couple_E22", - "couple_E23", - "couple_E24", - "couple_E25", - "couple_E26", - "couple_E27", - "couple_E28", - "couple_E29", - "couple_E3", - "couple_E30", - "couple_E31", - "couple_E32", - "couple_E33", - "couple_E34", - "couple_E35", - "couple_E36", - "couple_E37", - "couple_E38", - "couple_E39", - "couple_E4", - "couple_E40", - "couple_E41", - "couple_E42", - "couple_E43", - "couple_E44", - "couple_E45", - "couple_E46", - "couple_E47", - "couple_E48", - "couple_E49", - "couple_E5", - "couple_E50", - "couple_E6", - "couple_E7", - "couple_E8", - "couple_E9", - "men_E1", - "men_E10", - "men_E11", - "men_E12", - "men_E13", - "men_E14", - "men_E15", - "men_E16", - "men_E17", - "men_E18", - "men_E19", - "men_E2", - "men_E20", - "men_E21", - "men_E22", - "men_E23", - "men_E24", - "men_E25", - "men_E26", - "men_E27", - "men_E28", - "men_E29", - "men_E3", - "men_E30", - "men_E31", - "men_E32", - "men_E33", - "men_E34", - "men_E35", - "men_E36", - "men_E37", - "men_E38", - "men_E39", - "men_E4", - "men_E40", - "men_E41", - "men_E42", - "men_E43", - "men_E44", - "men_E45", - "men_E46", - "men_E47", - "men_E48", - "men_E49", - "men_E5", - "men_E50", - "men_E6", - "men_E7", - "men_E8", - "men_E9", - "women_E1", - "women_E10", - "women_E11", - "women_E12", - "women_E13", - "women_E14", - "women_E15", - "women_E16", - "women_E17", - "women_E18", - "women_E19", - "women_E2", - "women_E20", - "women_E21", - "women_E22", - "women_E23", - "women_E24", - "women_E25", - "women_E26", - "women_E27", - "women_E28", - "women_E29", - "women_E3", - "women_E30", - "women_E31", - "women_E32", - "women_E33", - "women_E34", - "women_E35", - "women_E36", - "women_E37", - "women_E38", - "women_E39", - "women_E4", - "women_E40", - "women_E41", - "women_E42", - "women_E43", - "women_E44", - "women_E45", - "women_E46", - "women_E47", - "women_E48", - "women_E49", - "women_E5", - "women_E50", - "women_E6", - "women_E7", - "women_E8", - "women_E9" - ], - "resp": "image/png", - "subs": [], - "curl": "" - } - ] - }, - { - "id": "api-stable-diffusion-caricature-effects", - "api_key": "Stable_Diffusion_Caricature_Effects", - "api_ip_link": "https://apigp0006.creinnovations.in/apis/mlm/stable_diffusion_caricature_effects/image/", - "title": "Stable_Diffusion_Caricature_Effects", - "method": "POST", - "path": "/stable_diffusion_caricature_effects/image/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/stable_diffusion_caricature_effects/image/image/", - "port": "8000", - "resp": "image/png", - "summary": "Classic editorial caricature generator with characteristic face exaggeration.", - "desc": "Re-synthesizes portraits in the style of newspaper editorial caricatures and boardwalk sketches.", - "params": [ - { - "n": "image0", - "al": "image", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Input portrait." - }, - { - "n": "effectId", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "CR1", - "ds": "Caricature style identifier." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "\ud83d\udd11 Authentication: Authentication key (\"abcdef\")." - }, - { - "n": "width", - "al": "", - "ty": "integer", - "lc": "multipart/form-data", - "rq": false, - "df": "512", - "ds": "Width." - }, - { - "n": "height", - "al": "", - "ty": "integer", - "lc": "multipart/form-data", - "rq": false, - "df": "768", - "ds": "Height." - } - ], - "chips": [], - "subs": [], - "curl": "", - "endpoints": [ - { - "id": "sd15-caricature-effects", - "method": "POST", - "subpath": "image/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/stable_diffusion_caricature_effects/image/image/", - "path": "/stable_diffusion_caricature_effects/image/", - "title": "Caricature Effects Pipeline", - "summary": "Classic editorial caricature generator with characteristic face exaggeration.", - "desc": "Re-synthesizes portraits in the style of newspaper editorial caricatures and boardwalk sketches.", - "params": [ - { - "n": "image0", - "al": "image", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Input portrait." - }, - { - "n": "effectId", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "CR1", - "ds": "Caricature style identifier." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "\ud83d\udd11 Authentication: Authentication key (\"abcdef\")." - }, - { - "n": "width", - "al": "", - "ty": "integer", - "lc": "multipart/form-data", - "rq": false, - "df": "512", - "ds": "Width." - }, - { - "n": "height", - "al": "", - "ty": "integer", - "lc": "multipart/form-data", - "rq": false, - "df": "768", - "ds": "Height." - } - ], - "chips": [], - "resp": "image/png", - "subs": [], - "curl": "" - } - ] - }, - { - "id": "api-stable-diffusion-comic-generator", - "api_key": "Stable_Diffusion_Comic_Generator", - "api_ip_link": "https://apigp0006.creinnovations.in/apis/mlm/stable_diffusion_comic_generator/", - "title": "Stable_Diffusion_Comic_Generator", - "method": "POST", - "path": "/stable_diffusion_comic_generator/image/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/stable_diffusion_comic_generator/image/", - "port": "8000", - "resp": "image/png", - "summary": "Synthesizes comic storyboard panels with custom user text conditioning.", - "desc": "Blends input character portrait with custom narrative prompts. Prompt is automatically translated to English, conditioned with comic LoRA weights, and verified against strict NSFW guard (0.35).", - "params": [ - { - "n": "image0", - "al": "image", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Character portrait photo." - }, - { - "n": "userPrompt", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Storyline / action description prompt." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "\ud83d\udd11 Authentication: Authentication key (\"abcdef\")." - }, - { - "n": "width", - "al": "", - "ty": "integer", - "lc": "multipart/form-data", - "rq": false, - "df": "512", - "ds": "Render width." - }, - { - "n": "height", - "al": "", - "ty": "integer", - "lc": "multipart/form-data", - "rq": false, - "df": "768", - "ds": "Render height." - } - ], - "chips": [], - "subs": [], - "curl": "", - "endpoints": [ - { - "id": "sd15-comic-generator", - "method": "POST", - "subpath": "image/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/stable_diffusion_comic_generator/image/", - "path": "/stable_diffusion_comic_generator/image/", - "title": "Comic Panel Generator", - "summary": "Synthesizes comic storyboard panels with custom user text conditioning.", - "desc": "Blends input character portrait with custom narrative prompts. Prompt is automatically translated to English, conditioned with comic LoRA weights, and verified against strict NSFW guard (0.35).", - "params": [ - { - "n": "image0", - "al": "image", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Character portrait photo." - }, - { - "n": "userPrompt", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Storyline / action description prompt." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "\ud83d\udd11 Authentication: Authentication key (\"abcdef\")." - }, - { - "n": "width", - "al": "", - "ty": "integer", - "lc": "multipart/form-data", - "rq": false, - "df": "512", - "ds": "Render width." - }, - { - "n": "height", - "al": "", - "ty": "integer", - "lc": "multipart/form-data", - "rq": false, - "df": "768", - "ds": "Render height." - } - ], - "chips": [], - "resp": "image/png", - "subs": [], - "curl": "" - } - ] - }, - { - "id": "api-stable-diffusion-photo-2-caricature", - "api_key": "Stable_Diffusion_Photo_2_Caricature", - "api_ip_link": "https://apigp0006.creinnovations.in/apis/mlm/stable_diffusion_photo_2_caricature/", - "title": "Stable_Diffusion_Photo_2_Caricature", - "method": "POST", - "path": "/stable_diffusion_photo_2_caricature/image/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/stable_diffusion_photo_2_caricature/image/", - "port": "8000", - "resp": "image/png", - "summary": "High-fidelity photographic portrait to stylized caricature conversion.", - "desc": "Converts realistic photographs into whimsical illustrated caricatures while ensuring 100% face likeness retention.", - "params": [ - { - "n": "image0", - "al": "image", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Input portrait." - }, - { - "n": "effectId", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "P2C1", - "ds": "Effect preset ID." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "\ud83d\udd11 Authentication: Authentication key (\"abcdef\")." - }, - { - "n": "width", - "al": "", - "ty": "integer", - "lc": "multipart/form-data", - "rq": false, - "df": "512", - "ds": "Width." - }, - { - "n": "height", - "al": "", - "ty": "integer", - "lc": "multipart/form-data", - "rq": false, - "df": "768", - "ds": "Height." - } - ], - "chips": [], - "subs": [], - "curl": "", - "endpoints": [ - { - "id": "sd15-photo-2-caricature", - "method": "POST", - "subpath": "image/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/stable_diffusion_photo_2_caricature/image/", - "path": "/stable_diffusion_photo_2_caricature/image/", - "title": "Photo to Caricature Converter", - "summary": "High-fidelity photographic portrait to stylized caricature conversion.", - "desc": "Converts realistic photographs into whimsical illustrated caricatures while ensuring 100% face likeness retention.", - "params": [ - { - "n": "image0", - "al": "image", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Input portrait." - }, - { - "n": "effectId", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "P2C1", - "ds": "Effect preset ID." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "\ud83d\udd11 Authentication: Authentication key (\"abcdef\")." - }, - { - "n": "width", - "al": "", - "ty": "integer", - "lc": "multipart/form-data", - "rq": false, - "df": "512", - "ds": "Width." - }, - { - "n": "height", - "al": "", - "ty": "integer", - "lc": "multipart/form-data", - "rq": false, - "df": "768", - "ds": "Height." - } - ], - "chips": [], - "resp": "image/png", - "subs": [], - "curl": "" - } - ] - }, - { - "id": "api-stable-diffusion-caricature-hair-face-effect", - "api_key": "Stable_Diffusion_Caricature_Hair_Face_Effect", - "api_ip_link": "https://apigp0006.creinnovations.in/apis/mlm/stable_diffusion_caricature_hair_face_effect/", - "title": "Stable_Diffusion_Caricature_Hair_Face_Effect", - "method": "POST", - "path": "/stable_diffusion_caricature_hair_face_effect/image/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/stable_diffusion_caricature_hair_face_effect/image/", - "port": "8000", - "resp": "image/png", - "summary": "Dual hair and face caricature transformation with synthetic CHF1 mask generation.", - "desc": "Applies exaggerated caricaturing across both hair and facial structure. When mask is omitted, generates CHF1 face mask automatically.", - "params": [ - { - "n": "image0", - "al": "image", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Input portrait." - }, - { - "n": "mask", - "al": "mask_image", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": false, - "df": "None", - "ds": "Optional face mask (auto-generated if omitted)." - }, - { - "n": "effectId", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "CHF1", - "ds": "Caricature hair/face preset." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "\ud83d\udd11 Authentication: Authentication key (\"abcdef\")." - }, - { - "n": "width", - "al": "", - "ty": "integer", - "lc": "multipart/form-data", - "rq": false, - "df": "512", - "ds": "Width." - }, - { - "n": "height", - "al": "", - "ty": "integer", - "lc": "multipart/form-data", - "rq": false, - "df": "768", - "ds": "Height." - } - ], - "chips": [], - "subs": [], - "curl": "", - "endpoints": [ - { - "id": "sd15-caricature-hair-face", - "method": "POST", - "subpath": "image/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/stable_diffusion_caricature_hair_face_effect/image/", - "path": "/stable_diffusion_caricature_hair_face_effect/image/", - "title": "Caricature Hair & Face Effect", - "summary": "Dual hair and face caricature transformation with synthetic CHF1 mask generation.", - "desc": "Applies exaggerated caricaturing across both hair and facial structure. When mask is omitted, generates CHF1 face mask automatically.", - "params": [ - { - "n": "image0", - "al": "image", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Input portrait." - }, - { - "n": "mask", - "al": "mask_image", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": false, - "df": "None", - "ds": "Optional face mask (auto-generated if omitted)." - }, - { - "n": "effectId", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "CHF1", - "ds": "Caricature hair/face preset." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "\ud83d\udd11 Authentication: Authentication key (\"abcdef\")." - }, - { - "n": "width", - "al": "", - "ty": "integer", - "lc": "multipart/form-data", - "rq": false, - "df": "512", - "ds": "Width." - }, - { - "n": "height", - "al": "", - "ty": "integer", - "lc": "multipart/form-data", - "rq": false, - "df": "768", - "ds": "Height." - } - ], - "chips": [], - "resp": "image/png", - "subs": [], - "curl": "" - } - ] - }, - { - "id": "api-stable-diffusion-new-cartoon effects", - "api_key": "Stable_Diffusion_New_Cartoon Effects", - "api_ip_link": "https://apigp0006.creinnovations.in/apis/mlm/stable_diffusion_new_cartoon_effects/", - "title": "Stable_Diffusion_New_Cartoon Effects", - "method": "POST", - "path": "/stable_diffusion_new_cartoon_effects/image/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/stable_diffusion_new_cartoon_effects/image/", - "port": "8000", - "resp": "image/png", - "summary": "Next-generation anime and hand-drawn cartoon transformations.", - "desc": "Applies hand-painted watercolor cartooning, modern anime cel shading, and graphic illustration filters.", - "params": [ - { - "n": "image0", - "al": "image", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Input portrait photograph." - }, - { - "n": "effectId", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "NC1", - "ds": "Cartoon effect identifier." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "\ud83d\udd11 Authentication: Authentication key (\"abcdef\")." - }, - { - "n": "width", - "al": "", - "ty": "integer", - "lc": "multipart/form-data", - "rq": false, - "df": "512", - "ds": "Width." - }, - { - "n": "height", - "al": "", - "ty": "integer", - "lc": "multipart/form-data", - "rq": false, - "df": "768", - "ds": "Height." - } - ], - "chips": [], - "subs": [], - "curl": "", - "endpoints": [ - { - "id": "sd15-new-cartoon", - "method": "POST", - "subpath": "image/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/stable_diffusion_new_cartoon_effects/image/", - "path": "/stable_diffusion_new_cartoon_effects/image/", - "title": "New Cartoon Effects (Artistic Cel & Anime)", - "summary": "Next-generation anime and hand-drawn cartoon transformations.", - "desc": "Applies hand-painted watercolor cartooning, modern anime cel shading, and graphic illustration filters.", - "params": [ - { - "n": "image0", - "al": "image", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Input portrait photograph." - }, - { - "n": "effectId", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "NC1", - "ds": "Cartoon effect identifier." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "\ud83d\udd11 Authentication: Authentication key (\"abcdef\")." - }, - { - "n": "width", - "al": "", - "ty": "integer", - "lc": "multipart/form-data", - "rq": false, - "df": "512", - "ds": "Width." - }, - { - "n": "height", - "al": "", - "ty": "integer", - "lc": "multipart/form-data", - "rq": false, - "df": "768", - "ds": "Height." - } - ], - "chips": [], - "resp": "image/png", - "subs": [], - "curl": "" - } - ] - }, - { - "id": "api-stable-diffusion-artistic-effects", - "api_key": "Stable_Diffusion_Artistic_Effects", - "api_ip_link": "https://apigp0006.creinnovations.in/apis/mlm/stable_diffusion_artistic_effects/", - "title": "Stable_Diffusion_Artistic_Effects", - "method": "POST", - "path": "/stable_diffusion_artistic_effects/image/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/stable_diffusion_artistic_effects/image/", - "port": "8000", - "resp": "image/png", - "summary": "Thematic artistic stylization with automatic subject gender detection.", - "desc": "Applies aesthetic digital painting effects. If category (gender) is omitted, runs detect_gender() to tailor color grading and prompt tokens to the subject.", - "params": [ - { - "n": "image0", - "al": "image", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Input photograph." - }, - { - "n": "artid", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "A1", - "ds": "Artistic preset identifier." - }, - { - "n": "category", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "auto", - "ds": "Gender category (\"male\", \"female\"). Auto-detected if omitted." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "\ud83d\udd11 Authentication: Authentication key (\"abcdef\")." - }, - { - "n": "width", - "al": "", - "ty": "integer", - "lc": "multipart/form-data", - "rq": false, - "df": "512", - "ds": "Width." - }, - { - "n": "height", - "al": "", - "ty": "integer", - "lc": "multipart/form-data", - "rq": false, - "df": "768", - "ds": "Height." - } - ], - "chips": [], - "subs": [], - "curl": "", - "endpoints": [ - { - "id": "sd15-artistic-effects", - "method": "POST", - "subpath": "image/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/stable_diffusion_artistic_effects/image/", - "path": "/stable_diffusion_artistic_effects/image/", - "title": "Artistic Effects with Gender Detection", - "summary": "Thematic artistic stylization with automatic subject gender detection.", - "desc": "Applies aesthetic digital painting effects. If category (gender) is omitted, runs detect_gender() to tailor color grading and prompt tokens to the subject.", - "params": [ - { - "n": "image0", - "al": "image", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Input photograph." - }, - { - "n": "artid", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "A1", - "ds": "Artistic preset identifier." - }, - { - "n": "category", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "auto", - "ds": "Gender category (\"male\", \"female\"). Auto-detected if omitted." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "\ud83d\udd11 Authentication: Authentication key (\"abcdef\")." - }, - { - "n": "width", - "al": "", - "ty": "integer", - "lc": "multipart/form-data", - "rq": false, - "df": "512", - "ds": "Width." - }, - { - "n": "height", - "al": "", - "ty": "integer", - "lc": "multipart/form-data", - "rq": false, - "df": "768", - "ds": "Height." - } - ], - "chips": [], - "resp": "image/png", - "subs": [], - "curl": "" - } - ] - } - ] - }, - { - "id": "sec-sdxl", - "key": "sdxl", - "icon": "\ud83d\ude80", - "title": "SDXL RealVisXL Inpainting", - "tag": "Photorealistic Diffusion", - "lead": "High-resolution 1024x1024 inpainting with RealVisXL V5.0. Advanced prompt routing, garment pattern synthesis, canvas outpainting, expression modification, and seamless collage generation.", - "port": "8000", - "hue": 232, - "eps": [ - { - "id": "api-stable-diffusion-text-to-image-model", - "api_key": "Stable_Diffusion_Text_To_Image_Model", - "api_ip_link": "https://apigp0905.creinnovations.in/apis/lxds/sdxl/text_to_image/", - "title": "Stable_Diffusion_Text_To_Image_Model", - "method": "POST", - "path": "/sdxl/text_to_image/image/", - "full_url": "https://apigp0905.creinnovations.in/apis/lxds/sdxl/text_to_image/image/", - "port": "8000", - "resp": "image/png", - "summary": "Photorealistic text-to-image synthesis using RealVisXL V5.0.", - "desc": "Simulates text-to-image generation through RealVisXL V5.0 Inpainting backend with all-white mask. Supports 47 precomputed effect presets or arbitrary free-form prompts.", - "params": [ - { - "n": "secretKey", - "al": "secretkey", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "\ud83d\udd11 Authentication: Required secret key (must equal \"abcdef\")." - }, - { - "n": "prompt", - "al": "userPrompt", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "None", - "ds": "Free-form generation prompt (takes precedence over effect_id)." - }, - { - "n": "effect_id", - "al": "effectId", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "backdrop_grey_room", - "ds": "Preset effect identifier from verified list." - }, - { - "n": "width", - "al": "", - "ty": "integer", - "lc": "multipart/form-data", - "rq": false, - "df": "720", - "ds": "Output width in pixels (longest edge capped at 720)." - }, - { - "n": "height", - "al": "", - "ty": "integer", - "lc": "multipart/form-data", - "rq": false, - "df": "720", - "ds": "Output height in pixels (longest edge capped at 720)." - }, - { - "n": "seed", - "al": "", - "ty": "integer", - "lc": "multipart/form-data", - "rq": false, - "df": "-1", - "ds": "Random seed for reproducible outputs (-1 = random)." - }, - { - "n": "output_format", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "png", - "ds": "Image format (png, jpeg, webp)." - }, - { - "n": "steps", - "al": "", - "ty": "integer", - "lc": "multipart/form-data", - "rq": false, - "df": "20", - "ds": "Diffusion inference denoising steps." - }, - { - "n": "cfg_scale", - "al": "", - "ty": "float", - "lc": "multipart/form-data", - "rq": false, - "df": "5.0", - "ds": "Classifier-free guidance scale." - } - ], - "chips": [ - "backdrop_bokeh_lights", - "backdrop_concrete_wall", - "backdrop_dark_room", - "backdrop_grey_room", - "backdrop_marble_surface", - "backdrop_warm_room", - "interior_art_gallery", - "interior_artisan_cafe", - "interior_boho_studio", - "interior_cozy_bedroom", - "interior_executive_office", - "interior_grand_library", - "interior_greenhouse", - "interior_hotel_lobby", - "interior_industrial_loft", - "interior_japandi_bedroom", - "interior_marble_kitchen", - "interior_modern_luxury_living", - "interior_modern_office", - "interior_parisian_bistro", - "interior_rustic_farmhouse_kitchen", - "interior_scandinavian_living", - "landscape_alpine_lake", - "landscape_autumn_forest", - "landscape_canyon_overlook", - "landscape_cherry_blossom_park", - "landscape_desert_dunes", - "landscape_dramatic_coast", - "landscape_lavender_field", - "landscape_misty_mountains", - "landscape_misty_pine_forest", - "landscape_rice_terraces", - "landscape_rolling_countryside", - "landscape_snowy_peaks", - "landscape_tropical_beach", - "landscape_waterfall_jungle", - "sky_aurora_borealis", - "sky_starry_night", - "sky_storm_clouds", - "sky_sunset_clouds", - "urban_city_skyline_night", - "urban_european_alley", - "urban_modern_bridge", - "urban_old_town_square", - "urban_rainy_neon_street", - "urban_rooftop_dusk", - "urban_subway_platform" - ], - "subs": [ - { - "m": "GET", - "p": "/sdxl/text_to_image/effects", - "d": "List all 47 effect presets grouped by category" - }, - { - "m": "GET", - "p": "/sdxl/text_to_image/health", - "d": "Health check for port 8005 backend" - }, - { - "m": "POST", - "p": "/sdxl/text_to_image/image/", - "d": "Generate image from prompt or effect_id" - } - ], - "curl": "", - "endpoints": [ - { - "id": "sdxl-text-to-image", - "method": "POST", - "subpath": "image/", - "full_url": "https://apigp0905.creinnovations.in/apis/lxds/sdxl/text_to_image/image/", - "path": "/sdxl/text_to_image/image/", - "title": "SDXL RealVisXL Text to Image Generation", - "summary": "Photorealistic text-to-image synthesis using RealVisXL V5.0.", - "desc": "Simulates text-to-image generation through RealVisXL V5.0 Inpainting backend with all-white mask. Supports 47 precomputed effect presets or arbitrary free-form prompts.", - "params": [ - { - "n": "secretKey", - "al": "secretkey", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "\ud83d\udd11 Authentication: Required secret key (must equal \"abcdef\")." - }, - { - "n": "prompt", - "al": "userPrompt", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "None", - "ds": "Free-form generation prompt (takes precedence over effect_id)." - }, - { - "n": "effect_id", - "al": "effectId", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "backdrop_grey_room", - "ds": "Preset effect identifier from verified list." - }, - { - "n": "width", - "al": "", - "ty": "integer", - "lc": "multipart/form-data", - "rq": false, - "df": "720", - "ds": "Output width in pixels (longest edge capped at 720)." - }, - { - "n": "height", - "al": "", - "ty": "integer", - "lc": "multipart/form-data", - "rq": false, - "df": "720", - "ds": "Output height in pixels (longest edge capped at 720)." - }, - { - "n": "seed", - "al": "", - "ty": "integer", - "lc": "multipart/form-data", - "rq": false, - "df": "-1", - "ds": "Random seed for reproducible outputs (-1 = random)." - }, - { - "n": "output_format", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "png", - "ds": "Image format (png, jpeg, webp)." - }, - { - "n": "steps", - "al": "", - "ty": "integer", - "lc": "multipart/form-data", - "rq": false, - "df": "20", - "ds": "Diffusion inference denoising steps." - }, - { - "n": "cfg_scale", - "al": "", - "ty": "float", - "lc": "multipart/form-data", - "rq": false, - "df": "5.0", - "ds": "Classifier-free guidance scale." - } - ], - "chips": [ - "backdrop_bokeh_lights", - "backdrop_concrete_wall", - "backdrop_dark_room", - "backdrop_grey_room", - "backdrop_marble_surface", - "backdrop_warm_room", - "interior_art_gallery", - "interior_artisan_cafe", - "interior_boho_studio", - "interior_cozy_bedroom", - "interior_executive_office", - "interior_grand_library", - "interior_greenhouse", - "interior_hotel_lobby", - "interior_industrial_loft", - "interior_japandi_bedroom", - "interior_marble_kitchen", - "interior_modern_luxury_living", - "interior_modern_office", - "interior_parisian_bistro", - "interior_rustic_farmhouse_kitchen", - "interior_scandinavian_living", - "landscape_alpine_lake", - "landscape_autumn_forest", - "landscape_canyon_overlook", - "landscape_cherry_blossom_park", - "landscape_desert_dunes", - "landscape_dramatic_coast", - "landscape_lavender_field", - "landscape_misty_mountains", - "landscape_misty_pine_forest", - "landscape_rice_terraces", - "landscape_rolling_countryside", - "landscape_snowy_peaks", - "landscape_tropical_beach", - "landscape_waterfall_jungle", - "sky_aurora_borealis", - "sky_starry_night", - "sky_storm_clouds", - "sky_sunset_clouds", - "urban_city_skyline_night", - "urban_european_alley", - "urban_modern_bridge", - "urban_old_town_square", - "urban_rainy_neon_street", - "urban_rooftop_dusk", - "urban_subway_platform" - ], - "resp": "image/png", - "subs": [ - { - "m": "GET", - "p": "/sdxl/text_to_image/effects", - "d": "List all 47 effect presets grouped by category" - }, - { - "m": "GET", - "p": "/sdxl/text_to_image/health", - "d": "Health check for port 8005 backend" - }, - { - "m": "POST", - "p": "/sdxl/text_to_image/image/", - "d": "Generate image from prompt or effect_id" - } - ], - "curl": "" - } - ] - }, - { - "id": "api-stable-diffusion-outpainting", - "api_key": "Stable_Diffusion_Outpainting", - "api_ip_link": "https://apigp0905.creinnovations.in/apis/lxds/sdxl/outpainting/", - "title": "Stable_Diffusion_Outpainting", - "method": "POST", - "path": "/sdxl/outpainting/image/", - "full_url": "https://apigp0905.creinnovations.in/apis/lxds/sdxl/outpainting/image/", - "port": "8000", - "resp": "image/png", - "summary": "Expands photo boundaries synthesizing extended environment and scenery.", - "desc": "Outpaints cropped portraits and landscapes into widescreen aspect ratios, synthesizing matching surrounding environment, lighting, and textures.", - "params": [ - { - "n": "original_image", - "al": "image", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Input photograph." - }, - { - "n": "mask_image", - "al": "mask", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Border mask (outer region to synthesize)." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "\ud83d\udd11 Authentication: Authentication key (\"abcdef\")." - }, - { - "n": "prompt", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "None", - "ds": "Environment description." - } - ], - "chips": [], - "subs": [], - "curl": "", - "endpoints": [ - { - "id": "sdxl-outpainting", - "method": "POST", - "subpath": "image/", - "full_url": "https://apigp0905.creinnovations.in/apis/lxds/sdxl/outpainting/image/", - "path": "/sdxl/outpainting/image/", - "title": "SDXL RealVisXL Outpainting & Canvas Extender", - "summary": "Expands photo boundaries synthesizing extended environment and scenery.", - "desc": "Outpaints cropped portraits and landscapes into widescreen aspect ratios, synthesizing matching surrounding environment, lighting, and textures.", - "params": [ - { - "n": "original_image", - "al": "image", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Input photograph." - }, - { - "n": "mask_image", - "al": "mask", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Border mask (outer region to synthesize)." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "\ud83d\udd11 Authentication: Authentication key (\"abcdef\")." - }, - { - "n": "prompt", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "None", - "ds": "Environment description." - } - ], - "chips": [], - "resp": "image/png", - "subs": [], - "curl": "" - } - ] - }, - { - "id": "api-stable-diffusion-inpaint-object-replacer", - "api_key": "Stable_Diffusion_Inpaint_Object_Replacer", - "api_ip_link": "https://apigp0905.creinnovations.in/apis/lxds/sdxl/inpaint_object_replacer/", - "title": "Stable_Diffusion_Inpaint_Object_Replacer", - "method": "POST", - "path": "/sdxl/inpaint_object_replacer/image/", - "full_url": "https://apigp0905.creinnovations.in/apis/lxds/sdxl/inpaint_object_replacer/image/", - "port": "8000", - "resp": "application/json", - "summary": "Replaces any masked region of an image with SDXL-generated content.", - "desc": "Replaces any masked region of an image with SDXL-generated content. General-purpose object replacement via inpainting \u2014 swap furniture, accessories, backgrounds, or objects described by text prompt.", - "params": [ - { - "n": "original_image", - "al": "", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Input photograph." - }, - { - "n": "mask_image", - "al": "", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Region to replace (white = repaint, black = keep)." - }, - { - "n": "prompt", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "None", - "ds": "Free-form text describing what to generate in the masked region." - }, - { - "n": "dress", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "None", - "ds": "Preset ID for the replacement content." - }, - { - "n": "effect_id", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "None", - "ds": "Object preset identifier." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Authentication key." - } - ], - "chips": [], - "subs": [], - "curl": "", - "endpoints": [ - { - "id": "sdxl-inpaint-object-replacer-v2", - "method": "POST", - "subpath": "image/", - "full_url": "https://apigp0905.creinnovations.in/apis/lxds/sdxl/inpaint_object_replacer/image/", - "path": "/sdxl/inpaint_object_replacer/image/", - "title": "SDXL Inpaint Object Replacer", - "summary": "Replaces any masked region of an image with SDXL-generated content.", - "desc": "Replaces any masked region of an image with SDXL-generated content. General-purpose object replacement via inpainting \u2014 swap furniture, accessories, backgrounds, or objects described by text prompt.", - "params": [ - { - "n": "original_image", - "al": "", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Input photograph." - }, - { - "n": "mask_image", - "al": "", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Region to replace (white = repaint, black = keep)." - }, - { - "n": "prompt", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "None", - "ds": "Free-form text describing what to generate in the masked region." - }, - { - "n": "dress", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "None", - "ds": "Preset ID for the replacement content." - }, - { - "n": "effect_id", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "None", - "ds": "Object preset identifier." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Authentication key." - } - ], - "chips": [], - "resp": "application/json", - "subs": [], - "curl": "" - } - ] - }, - { - "id": "api-stable-diffusion-dress-pattern", - "api_key": "Stable_Diffusion_Dress_Pattern", - "api_ip_link": "https://apigp0905.creinnovations.in/apis/lxds/sdxl/advanced_dress_pattern/", - "title": "Stable_Diffusion_Dress_Pattern", - "method": "POST", - "path": "/sdxl/dress_pattern/image/", - "full_url": "https://apigp0905.creinnovations.in/apis/lxds/sdxl/advanced_dress_pattern/image/", - "port": "8000", - "resp": "image/png", - "summary": "Applies intricate fabric patterns onto clothing with 28 textile presets.", - "desc": "Transfers floral, geometric, plaid, houndstooth, and batik textile patterns onto existing garments while preserving natural fabric folds and shadows.", - "params": [ - { - "n": "original_image", - "al": "image", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Input photograph." - }, - { - "n": "mask_image", - "al": "mask", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Fabric mask." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "\ud83d\udd11 Authentication: Authentication key (\"abcdef\")." - }, - { - "n": "effect_id", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "None", - "ds": "Fabric pattern preset from 28 verified encodings." - } - ], - "chips": [ - "1", - "10", - "11", - "12", - "13", - "14", - "15", - "16", - "17", - "18", - "19", - "2", - "20", - "21", - "22", - "23", - "24", - "25", - "26", - "27", - "28", - "3", - "4", - "5", - "6", - "7", - "8", - "9" - ], - "subs": [], - "curl": "", - "endpoints": [ - { - "id": "sdxl-dress-pattern", - "method": "POST", - "subpath": "image/", - "full_url": "https://apigp0905.creinnovations.in/apis/lxds/sdxl/advanced_dress_pattern/image/", - "path": "/sdxl/dress_pattern/image/", - "title": "SDXL Dress Pattern & Fabric Inpainter", - "summary": "Applies intricate fabric patterns onto clothing with 28 textile presets.", - "desc": "Transfers floral, geometric, plaid, houndstooth, and batik textile patterns onto existing garments while preserving natural fabric folds and shadows.", - "params": [ - { - "n": "original_image", - "al": "image", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Input photograph." - }, - { - "n": "mask_image", - "al": "mask", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Fabric mask." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "\ud83d\udd11 Authentication: Authentication key (\"abcdef\")." - }, - { - "n": "effect_id", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "None", - "ds": "Fabric pattern preset from 28 verified encodings." - } - ], - "chips": [ - "1", - "10", - "11", - "12", - "13", - "14", - "15", - "16", - "17", - "18", - "19", - "2", - "20", - "21", - "22", - "23", - "24", - "25", - "26", - "27", - "28", - "3", - "4", - "5", - "6", - "7", - "8", - "9" - ], - "resp": "image/png", - "subs": [], - "curl": "" - } - ] - }, - { - "id": "api-stable-diffusion-blend-collage", - "api_key": "Stable_Diffusion_Blend_Collage", - "api_ip_link": "https://apigp0905.creinnovations.in/apis/lxds/sdxl/blend_collage/", - "title": "Stable_Diffusion_Blend_Collage", - "method": "POST", - "path": "/sdxl/blend_collage/image/", - "full_url": "https://apigp0905.creinnovations.in/apis/lxds/sdxl/blend_collage/image/", - "port": "8000", - "resp": "image/png", - "summary": "Multi-layer photo collage blending with 158 aesthetic background themes.", - "desc": "Blends subject portraits into artistic collage backgrounds. Features 158 verified SDXL encodings for travel, romance, nature, abstract, and vintage magazine layouts.", - "params": [ - { - "n": "original_image", - "al": "image", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Subject portrait." - }, - { - "n": "mask_image", - "al": "mask", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Collage blend boundary mask." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "\ud83d\udd11 Authentication: Authentication key (\"abcdef\")." - }, - { - "n": "effect_id", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "None", - "ds": "Collage theme preset from 158 verified presets." - } - ], - "chips": [ - "10_female", - "10_male", - "11_female", - "11_male", - "12_female", - "12_male", - "13_female", - "13_male", - "14_female", - "14_male", - "15_female", - "15_male", - "16_female", - "16_male", - "17_female", - "17_male", - "18_female", - "18_male", - "19_female", - "19_male", - "1_female", - "1_male", - "20_female", - "20_male", - "21_female", - "21_male", - "22_female", - "22_male", - "23_female", - "23_male", - "24_female", - "24_male", - "25_female", - "25_male", - "26_female", - "26_male", - "27_female", - "27_male", - "28_female", - "28_male", - "29_female", - "29_male", - "2_female", - "2_male", - "30_female", - "30_male", - "31_female", - "31_male", - "32_female", - "32_male", - "33_female", - "33_male", - "34_female", - "34_male", - "35_female", - "35_male", - "36_female", - "36_male", - "37_female", - "37_male", - "38_female", - "38_male", - "39_female", - "39_male", - "3_female", - "3_male", - "40_female", - "40_male", - "4_female", - "4_male", - "5_female", - "5_male", - "6_female", - "6_male", - "7_female", - "7_male", - "8_female", - "8_male", - "9_female", - "9_male", - "Blend10_female", - "Blend10_male", - "Blend11_female", - "Blend11_male", - "Blend12_female", - "Blend12_male", - "Blend13_female", - "Blend13_male", - "Blend14_female", - "Blend14_male", - "Blend15_female", - "Blend15_male", - "Blend16_female", - "Blend16_male", - "Blend17_female", - "Blend17_male", - "Blend18_female", - "Blend18_male", - "Blend19_female", - "Blend19_male", - "Blend1_female", - "Blend1_male", - "Blend20_female", - "Blend20_male", - "Blend21_female", - "Blend21_male", - "Blend22_female", - "Blend22_male", - "Blend23_female", - "Blend23_male", - "Blend24_female", - "Blend24_male", - "Blend25_female", - "Blend25_male", - "Blend26_female", - "Blend26_male", - "Blend27_female", - "Blend27_male", - "Blend28_female", - "Blend28_male", - "Blend29_female", - "Blend29_male", - "Blend2_female", - "Blend2_male", - "Blend30_female", - "Blend30_male", - "Blend31_female", - "Blend31_male", - "Blend32_female", - "Blend32_male", - "Blend33_female", - "Blend33_male", - "Blend34_female", - "Blend34_male", - "Blend35_female", - "Blend35_male", - "Blend36_female", - "Blend36_male", - "Blend37_female", - "Blend37_male", - "Blend38_female", - "Blend38_male", - "Blend39_female", - "Blend39_male", - "Blend3_female", - "Blend3_male", - "Blend4_female", - "Blend4_male", - "Blend5_female", - "Blend5_male", - "Blend6_female", - "Blend6_male", - "Blend7_female", - "Blend7_male", - "Blend8_female", - "Blend8_male", - "Blend9_female", - "Blend9_male" - ], - "subs": [ - { - "m": "GET", - "p": "/sdxl/blend_collage/health", - "d": "Health check" - }, - { - "m": "POST", - "p": "/sdxl/blend_collage/image/", - "d": "Generate blended collage" - } - ], - "curl": "", - "endpoints": [ - { - "id": "sdxl-blend-collage", - "method": "POST", - "subpath": "image/", - "full_url": "https://apigp0905.creinnovations.in/apis/lxds/sdxl/blend_collage/image/", - "path": "/sdxl/blend_collage/image/", - "title": "SDXL RealVisXL Blend Collage", - "summary": "Multi-layer photo collage blending with 158 aesthetic background themes.", - "desc": "Blends subject portraits into artistic collage backgrounds. Features 158 verified SDXL encodings for travel, romance, nature, abstract, and vintage magazine layouts.", - "params": [ - { - "n": "original_image", - "al": "image", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Subject portrait." - }, - { - "n": "mask_image", - "al": "mask", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Collage blend boundary mask." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "\ud83d\udd11 Authentication: Authentication key (\"abcdef\")." - }, - { - "n": "effect_id", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "None", - "ds": "Collage theme preset from 158 verified presets." - } - ], - "chips": [ - "10_female", - "10_male", - "11_female", - "11_male", - "12_female", - "12_male", - "13_female", - "13_male", - "14_female", - "14_male", - "15_female", - "15_male", - "16_female", - "16_male", - "17_female", - "17_male", - "18_female", - "18_male", - "19_female", - "19_male", - "1_female", - "1_male", - "20_female", - "20_male", - "21_female", - "21_male", - "22_female", - "22_male", - "23_female", - "23_male", - "24_female", - "24_male", - "25_female", - "25_male", - "26_female", - "26_male", - "27_female", - "27_male", - "28_female", - "28_male", - "29_female", - "29_male", - "2_female", - "2_male", - "30_female", - "30_male", - "31_female", - "31_male", - "32_female", - "32_male", - "33_female", - "33_male", - "34_female", - "34_male", - "35_female", - "35_male", - "36_female", - "36_male", - "37_female", - "37_male", - "38_female", - "38_male", - "39_female", - "39_male", - "3_female", - "3_male", - "40_female", - "40_male", - "4_female", - "4_male", - "5_female", - "5_male", - "6_female", - "6_male", - "7_female", - "7_male", - "8_female", - "8_male", - "9_female", - "9_male", - "Blend10_female", - "Blend10_male", - "Blend11_female", - "Blend11_male", - "Blend12_female", - "Blend12_male", - "Blend13_female", - "Blend13_male", - "Blend14_female", - "Blend14_male", - "Blend15_female", - "Blend15_male", - "Blend16_female", - "Blend16_male", - "Blend17_female", - "Blend17_male", - "Blend18_female", - "Blend18_male", - "Blend19_female", - "Blend19_male", - "Blend1_female", - "Blend1_male", - "Blend20_female", - "Blend20_male", - "Blend21_female", - "Blend21_male", - "Blend22_female", - "Blend22_male", - "Blend23_female", - "Blend23_male", - "Blend24_female", - "Blend24_male", - "Blend25_female", - "Blend25_male", - "Blend26_female", - "Blend26_male", - "Blend27_female", - "Blend27_male", - "Blend28_female", - "Blend28_male", - "Blend29_female", - "Blend29_male", - "Blend2_female", - "Blend2_male", - "Blend30_female", - "Blend30_male", - "Blend31_female", - "Blend31_male", - "Blend32_female", - "Blend32_male", - "Blend33_female", - "Blend33_male", - "Blend34_female", - "Blend34_male", - "Blend35_female", - "Blend35_male", - "Blend36_female", - "Blend36_male", - "Blend37_female", - "Blend37_male", - "Blend38_female", - "Blend38_male", - "Blend39_female", - "Blend39_male", - "Blend3_female", - "Blend3_male", - "Blend4_female", - "Blend4_male", - "Blend5_female", - "Blend5_male", - "Blend6_female", - "Blend6_male", - "Blend7_female", - "Blend7_male", - "Blend8_female", - "Blend8_male", - "Blend9_female", - "Blend9_male" - ], - "resp": "image/png", - "subs": [ - { - "m": "GET", - "p": "/sdxl/blend_collage/health", - "d": "Health check" - }, - { - "m": "POST", - "p": "/sdxl/blend_collage/image/", - "d": "Generate blended collage" - } - ], - "curl": "" - } - ] - }, - { - "id": "api-stable-diffusion-dress-replacer", - "api_key": "Stable_Diffusion_Dress_Replacer", - "api_ip_link": "https://apigp0905.creinnovations.in/apis/lxds/sdxl/dress_replacer/", - "title": "Stable_Diffusion_Dress_Replacer", - "method": "POST", - "path": "/sdxl/dress_replacer/image/", - "full_url": "https://apigp0905.creinnovations.in/apis/lxds/sdxl/dress_replacer/image/", - "port": "8000", - "resp": "image/png", - "summary": "Garment replacement proxy with prompt catalog.", - "desc": "Provides prompt-driven dress replacement with catalog lookups at /sdxl/dress_replacer/prompts.", - "params": [ - { - "n": "original_image", - "al": "image", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Subject photo." - }, - { - "n": "mask_image", - "al": "mask", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Garment mask." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "\ud83d\udd11 Authentication: Authentication key (\"abcdef\")." - } - ], - "chips": [], - "subs": [ - { - "m": "GET", - "p": "/sdxl/dress_replacer/prompts", - "d": "List dress prompts catalog" - }, - { - "m": "POST", - "p": "/sdxl/dress_replacer/image/", - "d": "Inpaint dress replacement" - } - ], - "curl": "", - "endpoints": [ - { - "id": "sdxl-dress-replacer", - "method": "POST", - "subpath": "image/", - "full_url": "https://apigp0905.creinnovations.in/apis/lxds/sdxl/dress_replacer/image/", - "path": "/sdxl/dress_replacer/image/", - "title": "SDXL RealVisXL Dress Replacer", - "summary": "Garment replacement proxy with prompt catalog.", - "desc": "Provides prompt-driven dress replacement with catalog lookups at /sdxl/dress_replacer/prompts.", - "params": [ - { - "n": "original_image", - "al": "image", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Subject photo." - }, - { - "n": "mask_image", - "al": "mask", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Garment mask." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "\ud83d\udd11 Authentication: Authentication key (\"abcdef\")." - } - ], - "chips": [], - "resp": "image/png", - "subs": [ - { - "m": "GET", - "p": "/sdxl/dress_replacer/prompts", - "d": "List dress prompts catalog" - }, - { - "m": "POST", - "p": "/sdxl/dress_replacer/image/", - "d": "Inpaint dress replacement" - } - ], - "curl": "" - } - ] - }, - { - "id": "api-stable-diffusion-text-to-cartoon-character-generator", - "api_key": "Stable_Diffusion_Text_To_Cartoon_Character_Generator", - "api_ip_link": "https://apigp0905.creinnovations.in/apis/lxds/sdxl/text_to_cartoon/", - "title": "Stable_Diffusion_Text_To_Cartoon_Character_Generator", - "method": "POST", - "path": "/sdxl/text_to_cartoon/image/", - "full_url": "https://apigp0905.creinnovations.in/apis/lxds/sdxl/text_to_cartoon/image/", - "port": "8000", - "resp": "image/png", - "summary": "3D Disney/Pixar cartoon styling with 47 verified animation presets.", - "desc": "Transforms portrait subjects into animated film characters using RealVisXL V5.0 cartoon LoRAs and 47 precomputed character encodings.", - "params": [ - { - "n": "original_image", - "al": "image", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Portrait photograph." - }, - { - "n": "mask_image", - "al": "mask", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Mask." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "\ud83d\udd11 Authentication: Authentication key (\"abcdef\")." - }, - { - "n": "effect_id", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "None", - "ds": "Animation archetype preset." - } - ], - "chips": [ - "backdrop_bokeh_lights", - "backdrop_concrete_wall", - "backdrop_dark_room", - "backdrop_grey_room", - "backdrop_marble_surface", - "backdrop_warm_room", - "interior_art_gallery", - "interior_artisan_cafe", - "interior_boho_studio", - "interior_cozy_bedroom", - "interior_executive_office", - "interior_grand_library", - "interior_greenhouse", - "interior_hotel_lobby", - "interior_industrial_loft", - "interior_japandi_bedroom", - "interior_marble_kitchen", - "interior_modern_luxury_living", - "interior_modern_office", - "interior_parisian_bistro", - "interior_rustic_farmhouse_kitchen", - "interior_scandinavian_living", - "landscape_alpine_lake", - "landscape_autumn_forest", - "landscape_canyon_overlook", - "landscape_cherry_blossom_park", - "landscape_desert_dunes", - "landscape_dramatic_coast", - "landscape_lavender_field", - "landscape_misty_mountains", - "landscape_misty_pine_forest", - "landscape_rice_terraces", - "landscape_rolling_countryside", - "landscape_snowy_peaks", - "landscape_tropical_beach", - "landscape_waterfall_jungle", - "sky_aurora_borealis", - "sky_starry_night", - "sky_storm_clouds", - "sky_sunset_clouds", - "urban_city_skyline_night", - "urban_european_alley", - "urban_modern_bridge", - "urban_old_town_square", - "urban_rainy_neon_street", - "urban_rooftop_dusk", - "urban_subway_platform" - ], - "subs": [], - "curl": "", - "endpoints": [ - { - "id": "sdxl-text-to-cartoon", - "method": "POST", - "subpath": "image/", - "full_url": "https://apigp0905.creinnovations.in/apis/lxds/sdxl/text_to_cartoon/image/", - "path": "/sdxl/text_to_cartoon/image/", - "title": "SDXL Text to Cartoon Character Generator", - "summary": "3D Disney/Pixar cartoon styling with 47 verified animation presets.", - "desc": "Transforms portrait subjects into animated film characters using RealVisXL V5.0 cartoon LoRAs and 47 precomputed character encodings.", - "params": [ - { - "n": "original_image", - "al": "image", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Portrait photograph." - }, - { - "n": "mask_image", - "al": "mask", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Mask." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "\ud83d\udd11 Authentication: Authentication key (\"abcdef\")." - }, - { - "n": "effect_id", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "None", - "ds": "Animation archetype preset." - } - ], - "chips": [ - "backdrop_bokeh_lights", - "backdrop_concrete_wall", - "backdrop_dark_room", - "backdrop_grey_room", - "backdrop_marble_surface", - "backdrop_warm_room", - "interior_art_gallery", - "interior_artisan_cafe", - "interior_boho_studio", - "interior_cozy_bedroom", - "interior_executive_office", - "interior_grand_library", - "interior_greenhouse", - "interior_hotel_lobby", - "interior_industrial_loft", - "interior_japandi_bedroom", - "interior_marble_kitchen", - "interior_modern_luxury_living", - "interior_modern_office", - "interior_parisian_bistro", - "interior_rustic_farmhouse_kitchen", - "interior_scandinavian_living", - "landscape_alpine_lake", - "landscape_autumn_forest", - "landscape_canyon_overlook", - "landscape_cherry_blossom_park", - "landscape_desert_dunes", - "landscape_dramatic_coast", - "landscape_lavender_field", - "landscape_misty_mountains", - "landscape_misty_pine_forest", - "landscape_rice_terraces", - "landscape_rolling_countryside", - "landscape_snowy_peaks", - "landscape_tropical_beach", - "landscape_waterfall_jungle", - "sky_aurora_borealis", - "sky_starry_night", - "sky_storm_clouds", - "sky_sunset_clouds", - "urban_city_skyline_night", - "urban_european_alley", - "urban_modern_bridge", - "urban_old_town_square", - "urban_rainy_neon_street", - "urban_rooftop_dusk", - "urban_subway_platform" - ], - "resp": "image/png", - "subs": [], - "curl": "" - } - ] - }, - { - "id": "api-stable-diffusion-text-to-caricature", - "api_key": "Stable_Diffusion_Text_To_Caricature", - "api_ip_link": "https://apigp0905.creinnovations.in/apis/lxds/sdxl/text_to_caricature/", - "title": "Stable_Diffusion_Text_To_Caricature", - "method": "POST", - "path": "/sdxl/text_to_caricature/image/", - "full_url": "https://apigp0905.creinnovations.in/apis/lxds/sdxl/text_to_caricature/image/", - "port": "8000", - "resp": "image/png", - "summary": "Caricature generation via RealVisXL with 47 character archetype presets.", - "desc": "Produces whimsical caricatures of professions, hobbies, and sports heroes across 47 verified SDXL encodings.", - "params": [ - { - "n": "original_image", - "al": "image", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Portrait photograph." - }, - { - "n": "mask_image", - "al": "mask", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Body/background mask." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "\ud83d\udd11 Authentication: Authentication key (\"abcdef\")." - }, - { - "n": "effect_id", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "None", - "ds": "Caricature archetype preset." - } - ], - "chips": [ - "backdrop_bokeh_lights", - "backdrop_concrete_wall", - "backdrop_dark_room", - "backdrop_grey_room", - "backdrop_marble_surface", - "backdrop_warm_room", - "interior_art_gallery", - "interior_artisan_cafe", - "interior_boho_studio", - "interior_cozy_bedroom", - "interior_executive_office", - "interior_grand_library", - "interior_greenhouse", - "interior_hotel_lobby", - "interior_industrial_loft", - "interior_japandi_bedroom", - "interior_marble_kitchen", - "interior_modern_luxury_living", - "interior_modern_office", - "interior_parisian_bistro", - "interior_rustic_farmhouse_kitchen", - "interior_scandinavian_living", - "landscape_alpine_lake", - "landscape_autumn_forest", - "landscape_canyon_overlook", - "landscape_cherry_blossom_park", - "landscape_desert_dunes", - "landscape_dramatic_coast", - "landscape_lavender_field", - "landscape_misty_mountains", - "landscape_misty_pine_forest", - "landscape_rice_terraces", - "landscape_rolling_countryside", - "landscape_snowy_peaks", - "landscape_tropical_beach", - "landscape_waterfall_jungle", - "sky_aurora_borealis", - "sky_starry_night", - "sky_storm_clouds", - "sky_sunset_clouds", - "urban_city_skyline_night", - "urban_european_alley", - "urban_modern_bridge", - "urban_old_town_square", - "urban_rainy_neon_street", - "urban_rooftop_dusk", - "urban_subway_platform" - ], - "subs": [], - "curl": "", - "endpoints": [ - { - "id": "sdxl-text-to-caricature", - "method": "POST", - "subpath": "image/", - "full_url": "https://apigp0905.creinnovations.in/apis/lxds/sdxl/text_to_caricature/image/", - "path": "/sdxl/text_to_caricature/image/", - "title": "SDXL Text to Caricature Generation", - "summary": "Caricature generation via RealVisXL with 47 character archetype presets.", - "desc": "Produces whimsical caricatures of professions, hobbies, and sports heroes across 47 verified SDXL encodings.", - "params": [ - { - "n": "original_image", - "al": "image", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Portrait photograph." - }, - { - "n": "mask_image", - "al": "mask", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Body/background mask." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "\ud83d\udd11 Authentication: Authentication key (\"abcdef\")." - }, - { - "n": "effect_id", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "None", - "ds": "Caricature archetype preset." - } - ], - "chips": [ - "backdrop_bokeh_lights", - "backdrop_concrete_wall", - "backdrop_dark_room", - "backdrop_grey_room", - "backdrop_marble_surface", - "backdrop_warm_room", - "interior_art_gallery", - "interior_artisan_cafe", - "interior_boho_studio", - "interior_cozy_bedroom", - "interior_executive_office", - "interior_grand_library", - "interior_greenhouse", - "interior_hotel_lobby", - "interior_industrial_loft", - "interior_japandi_bedroom", - "interior_marble_kitchen", - "interior_modern_luxury_living", - "interior_modern_office", - "interior_parisian_bistro", - "interior_rustic_farmhouse_kitchen", - "interior_scandinavian_living", - "landscape_alpine_lake", - "landscape_autumn_forest", - "landscape_canyon_overlook", - "landscape_cherry_blossom_park", - "landscape_desert_dunes", - "landscape_dramatic_coast", - "landscape_lavender_field", - "landscape_misty_mountains", - "landscape_misty_pine_forest", - "landscape_rice_terraces", - "landscape_rolling_countryside", - "landscape_snowy_peaks", - "landscape_tropical_beach", - "landscape_waterfall_jungle", - "sky_aurora_borealis", - "sky_starry_night", - "sky_storm_clouds", - "sky_sunset_clouds", - "urban_city_skyline_night", - "urban_european_alley", - "urban_modern_bridge", - "urban_old_town_square", - "urban_rainy_neon_street", - "urban_rooftop_dusk", - "urban_subway_platform" - ], - "resp": "image/png", - "subs": [], - "curl": "" - } - ] - }, - { - "id": "api-stable-diffusion-face-expressions-changer", - "api_key": "Stable_Diffusion_Face_Expressions_Changer", - "api_ip_link": "https://apigp0905.creinnovations.in/apis/lxds/sdxl/expressions_changer/", - "title": "Stable_Diffusion_Face_Expressions_Changer", - "method": "POST", - "path": "/sdxl/expressions_changer/image/", - "full_url": "https://apigp0905.creinnovations.in/apis/lxds/sdxl/expressions_changer/image/", - "port": "8000", - "resp": "image/png", - "summary": "Modifies facial expressions with 17 emotional state presets.", - "desc": "Inpaints smile, laughter, surprise, wink, smirk, and thoughtful expressions onto portrait faces while maintaining facial identity.", - "params": [ - { - "n": "original_image", - "al": "image", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Input portrait." - }, - { - "n": "mask_image", - "al": "mask", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Facial features mask." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "\ud83d\udd11 Authentication: Authentication key (\"abcdef\")." - }, - { - "n": "effect_id", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "None", - "ds": "Expression preset from 17 verified encodings." - } - ], - "chips": [ - "calm_female", - "calm_group", - "calm_kid", - "calm_male", - "charming_female", - "charming_group", - "charming_kid", - "charming_male", - "cute_female", - "cute_group", - "cute_kid", - "cute_male", - "default", - "happy_female", - "happy_group", - "happy_kid", - "happy_male" - ], - "subs": [], - "curl": "", - "endpoints": [ - { - "id": "sdxl-expressions-changer", - "method": "POST", - "subpath": "image/", - "full_url": "https://apigp0905.creinnovations.in/apis/lxds/sdxl/expressions_changer/image/", - "path": "/sdxl/expressions_changer/image/", - "title": "SDXL Facial Expressions Changer", - "summary": "Modifies facial expressions with 17 emotional state presets.", - "desc": "Inpaints smile, laughter, surprise, wink, smirk, and thoughtful expressions onto portrait faces while maintaining facial identity.", - "params": [ - { - "n": "original_image", - "al": "image", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Input portrait." - }, - { - "n": "mask_image", - "al": "mask", - "ty": "file (binary)", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "Facial features mask." - }, - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": true, - "df": "None", - "ds": "\ud83d\udd11 Authentication: Authentication key (\"abcdef\")." - }, - { - "n": "effect_id", - "al": "", - "ty": "string", - "lc": "multipart/form-data", - "rq": false, - "df": "None", - "ds": "Expression preset from 17 verified encodings." - } - ], - "chips": [ - "calm_female", - "calm_group", - "calm_kid", - "calm_male", - "charming_female", - "charming_group", - "charming_kid", - "charming_male", - "cute_female", - "cute_group", - "cute_kid", - "cute_male", - "default", - "happy_female", - "happy_group", - "happy_kid", - "happy_male" - ], - "resp": "image/png", - "subs": [], - "curl": "" - } - ] - } - ] - }, - { - "id": "sec-other", - "key": "other", - "icon": "\u2699\ufe0f", - "title": "Credits, Reports & System", - "tag": "Gateway Infrastructure", - "lead": "Multi-tenant credit accounting, client feature billing authorization, asynchronous error diagnostic collection, user model quality telemetry, and cluster health liveness probes.", - "port": "5925", - "hue": 45, - "eps": [ - { - "id": "api-feedbacks", - "api_key": "Feedbacks", - "api_ip_link": "https://apigp0006.creinnovations.in/apis/mlm/feedback/", - "title": "Feedbacks", - "method": "POST", - "path": "/feedback/submit/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/feedback/submit/", - "port": "8000", - "resp": "application/json", - "summary": "Collects 1-5 star user satisfaction scores and qualitative quality feedback.", - "desc": "Monitors generative model output quality in production by logging ratings, selected presets, and free-form user comments. Provides admin metric resets.", - "params": [ - { - "n": "rating", - "al": "", - "ty": "integer", - "lc": "application/json", - "rq": true, - "df": "None", - "ds": "User satisfaction rating (1 to 5)." - }, - { - "n": "comment", - "al": "", - "ty": "string", - "lc": "application/json", - "rq": false, - "df": "None", - "ds": "Optional text review or suggestions." - }, - { - "n": "feature", - "al": "", - "ty": "string", - "lc": "application/json", - "rq": false, - "df": "None", - "ds": "Endpoint or feature identifier being reviewed." - } - ], - "chips": [], - "subs": [ - { - "m": "POST", - "p": "/feedback/submit/", - "d": "Submit user rating and comments" - }, - { - "m": "POST", - "p": "/feedback/reset-stats/", - "d": "Reset feedback summary counters (admin only)" - } - ], - "curl": "", - "endpoints": [ - { - "id": "other-feedback", - "method": "POST", - "subpath": "submit/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/feedback/submit/", - "path": "/feedback/submit/", - "title": "User Feedback & Model Quality Rating", - "summary": "Collects 1-5 star user satisfaction scores and qualitative quality feedback.", - "desc": "Monitors generative model output quality in production by logging ratings, selected presets, and free-form user comments. Provides admin metric resets.", - "params": [ - { - "n": "rating", - "al": "", - "ty": "integer", - "lc": "application/json", - "rq": true, - "df": "None", - "ds": "User satisfaction rating (1 to 5)." - }, - { - "n": "comment", - "al": "", - "ty": "string", - "lc": "application/json", - "rq": false, - "df": "None", - "ds": "Optional text review or suggestions." - }, - { - "n": "feature", - "al": "", - "ty": "string", - "lc": "application/json", - "rq": false, - "df": "None", - "ds": "Endpoint or feature identifier being reviewed." - } - ], - "chips": [], - "resp": "application/json", - "subs": [ - { - "m": "POST", - "p": "/feedback/submit/", - "d": "Submit user rating and comments" - }, - { - "m": "POST", - "p": "/feedback/reset-stats/", - "d": "Reset feedback summary counters (admin only)" - } - ], - "curl": "" - } - ] - }, - { - "id": "api-reports", - "api_key": "Reports", - "api_ip_link": "https://apigp0006.creinnovations.in/apis/mlm/reports/", - "title": "Reports", - "method": "POST", - "path": "/reports/data/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/reports/data/", - "port": "8000", - "resp": "application/json", - "summary": "Captures client-side rendering exceptions, error logs, and user bug tickets.", - "desc": "Receives asynchronous client problem reports, crash telemetry, and optional screenshot attachments to track client-side rendering flaws or API communication failures.", - "params": [ - { - "n": "report_type", - "al": "", - "ty": "string", - "lc": "application/json", - "rq": true, - "df": "None", - "ds": "Category of report (\"crash\", \"rendering_defect\", \"user_feedback\")." - }, - { - "n": "description", - "al": "", - "ty": "string", - "lc": "application/json", - "rq": true, - "df": "None", - "ds": "Detailed bug description from user or client log." - }, - { - "n": "metadata", - "al": "", - "ty": "object", - "lc": "application/json", - "rq": false, - "df": "{}", - "ds": "App version, device model, OS, and request tracking ID." - } - ], - "chips": [], - "subs": [], - "curl": "", - "endpoints": [ - { - "id": "other-reports", - "method": "POST", - "subpath": "data/", - "full_url": "https://apigp0006.creinnovations.in/apis/mlm/reports/data/", - "path": "/reports/data/", - "title": "Bug Reports & Diagnostics Collector", - "summary": "Captures client-side rendering exceptions, error logs, and user bug tickets.", - "desc": "Receives asynchronous client problem reports, crash telemetry, and optional screenshot attachments to track client-side rendering flaws or API communication failures.", - "params": [ - { - "n": "report_type", - "al": "", - "ty": "string", - "lc": "application/json", - "rq": true, - "df": "None", - "ds": "Category of report (\"crash\", \"rendering_defect\", \"user_feedback\")." - }, - { - "n": "description", - "al": "", - "ty": "string", - "lc": "application/json", - "rq": true, - "df": "None", - "ds": "Detailed bug description from user or client log." - }, - { - "n": "metadata", - "al": "", - "ty": "object", - "lc": "application/json", - "rq": false, - "df": "{}", - "ds": "App version, device model, OS, and request tracking ID." - } - ], - "chips": [], - "resp": "application/json", - "subs": [], - "curl": "" - } - ] - }, - { - "id": "api-credits-limit", - "api_key": "Credits_Limit", - "api_ip_link": "https://apigp0006.creinnovations.in/apis/flxk/", - "title": "Credits_Limit", - "method": "MULTI", - "path": "/credits/use", - "full_url": "https://apigp0006.creinnovations.in/apis/flxk/credits/use", - "port": "8000", - "resp": "application/json", - "summary": "Deducts feature credits and verifies quota entitlement for client apps.", - "desc": "Enterprise credit governance engine. Evaluates whether a client account and specific end-user have sufficient credit balance to invoke GPU inference features. Deducts credits atomically using PostgreSQL transactions.", - "params": [ - { - "n": "account_id", - "al": "", - "ty": "string", - "lc": "application/json", - "rq": true, - "df": "None", - "ds": "Client enterprise organization UUID." - }, - { - "n": "app_id", - "al": "", - "ty": "string", - "lc": "application/json", - "rq": true, - "df": "None", - "ds": "Registered application identifier." - }, - { - "n": "feature_id", - "al": "", - "ty": "string", - "lc": "application/json", - "rq": true, - "df": "None", - "ds": "AI feature key (e.g. \"flux_fill_hair_color\")." - }, - { - "n": "user_id", - "al": "", - "ty": "string", - "lc": "application/json", - "rq": true, - "df": "None", - "ds": "Unique end-user identifier." - }, - { - "n": "amount", - "al": "", - "ty": "integer", - "lc": "application/json", - "rq": false, - "df": "1", - "ds": "Credit units to debit (defaults to feature base cost)." - } - ], - "chips": [], - "subs": [ - { - "m": "POST", - "p": "/credits/use", - "d": "Authorize and debit user credits for a specific AI feature invocation" - }, - { - "m": "GET", - "p": "/credits/status", - "d": "Query current credit balance, monthly allowance, and plan quota" - } - ], - "curl": "", - "endpoints": [ - { - "id": "other-credits-client", - "method": "POST", - "subpath": "credits/use", - "full_url": "https://apigp0006.creinnovations.in/apis/flxk/credits/use", - "path": "/credits/use", - "title": "Credits & Billing Client API", - "summary": "Deducts feature credits and verifies quota entitlement for client apps.", - "desc": "Enterprise credit governance engine. Evaluates whether a client account and specific end-user have sufficient credit balance to invoke GPU inference features. Deducts credits atomically using PostgreSQL transactions.", - "params": [ - { - "n": "account_id", - "al": "", - "ty": "string", - "lc": "application/json", - "rq": true, - "df": "None", - "ds": "Client enterprise organization UUID." - }, - { - "n": "app_id", - "al": "", - "ty": "string", - "lc": "application/json", - "rq": true, - "df": "None", - "ds": "Registered application identifier." - }, - { - "n": "feature_id", - "al": "", - "ty": "string", - "lc": "application/json", - "rq": true, - "df": "None", - "ds": "AI feature key (e.g. \"flux_fill_hair_color\")." - }, - { - "n": "user_id", - "al": "", - "ty": "string", - "lc": "application/json", - "rq": true, - "df": "None", - "ds": "Unique end-user identifier." - }, - { - "n": "amount", - "al": "", - "ty": "integer", - "lc": "application/json", - "rq": false, - "df": "1", - "ds": "Credit units to debit (defaults to feature base cost)." - } - ], - "chips": [], - "resp": "application/json", - "subs": [ - { - "m": "POST", - "p": "/credits/use", - "d": "Authorize and debit user credits for a specific AI feature invocation" - }, - { - "m": "GET", - "p": "/credits/status", - "d": "Query current credit balance, monthly allowance, and plan quota" - } - ], - "curl": "" - }, - { - "id": "other-credits-admin", - "method": "POST", - "subpath": "credits/admin/api/accounts", - "full_url": "https://apigp0006.creinnovations.in/apis/flxk/credits/admin/api/accounts", - "path": "/credits/admin/api/accounts", - "title": "Credits Admin Portal & REST CRUD API", - "summary": "Full multi-tenant administration: accounts, apps, tiered feature pricing, and analytics.", - "desc": "Secure multi-tenant CRUD API managing client organizations, registered applications, credit allocations, and per-feature pricing models. Protected by session authentication and optional 2FA OTP verification.", - "params": [ - { - "n": "name", - "al": "", - "ty": "string", - "lc": "application/json", - "rq": true, - "df": "None", - "ds": "Organization or app name." - }, - { - "n": "initial_credits", - "al": "", - "ty": "integer", - "lc": "application/json", - "rq": false, - "df": "1000", - "ds": "Starting credit allocation." - }, - { - "n": "monthly_refill", - "al": "", - "ty": "integer", - "lc": "application/json", - "rq": false, - "df": "0", - "ds": "Automatic monthly recurring credit refill quota." - } - ], - "chips": [], - "resp": "application/json", - "subs": [ - { - "m": "GET", - "p": "/credits/admin/", - "d": "HTML Admin Management Dashboard UI" - }, - { - "m": "POST", - "p": "/credits/admin/api/login", - "d": "Authenticate administrator credentials" - }, - { - "m": "POST", - "p": "/credits/admin/api/verify-otp", - "d": "Validate 2FA Time-based One-Time Password" - }, - { - "m": "GET", - "p": "/credits/admin/api/check-auth", - "d": "Validate current admin session cookie" - }, - { - "m": "POST", - "p": "/credits/admin/api/logout", - "d": "Invalidate current admin session" - }, - { - "m": "GET", - "p": "/credits/admin/api/stats", - "d": "Aggregated daily/monthly credit burn and throughput analytics" - }, - { - "m": "GET / POST", - "p": "/credits/admin/api/accounts", - "d": "List all accounts or create a new client account" - }, - { - "m": "PUT / DELETE", - "p": "/credits/admin/api/accounts/{account_id}", - "d": "Update organization credit limits or delete account" - }, - { - "m": "GET / POST", - "p": "/credits/admin/api/accounts/{account_id}/apps", - "d": "Manage client applications registered under an account" - }, - { - "m": "GET / POST / PUT / DELETE", - "p": "/credits/admin/api/accounts/{account_id}/apps/{app_id}/features", - "d": "Configure per-feature credit costs and access rules" - } - ], - "curl": "" - } - ] - }, - { - "id": "other-health", - "api_key": "System_Health", - "api_ip_link": "http://localhost:5925/health", - "title": "System Health & Maintenance Check", - "method": "GET", - "path": "/health", - "full_url": "http://localhost:5925/health", - "port": "5925", - "resp": "application/json", - "summary": "Cluster health check monitoring GPU state, PostgreSQL database, and active services.", - "desc": "Liveness and readiness probe for load balancers. Checks database connectivity and active genre modules.", - "params": [ - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "query string", - "rq": false, - "df": "None", - "ds": "Authentication key, if authentication is enabled on this gateway." - } - ], - "chips": [], - "subs": [], - "curl": "curl http://localhost:5925/health", - "endpoints": [ - { - "id": "other-health", - "method": "GET", - "subpath": "health", - "full_url": "http://localhost:5925/health", - "path": "/health", - "title": "System Health Check", - "summary": "Liveness and readiness probe", - "desc": "Checks server health", - "params": [ - { - "n": "secretKey", - "al": "", - "ty": "string", - "lc": "query string", - "rq": false, - "df": "None", - "ds": "Authentication key, if authentication is enabled on this gateway." - } - ], - "chips": [], - "resp": "application/json", - "subs": [] - } - ] - } - ] - } - ] -} \ No newline at end of file diff --git a/web/bulk-api-tester/static/js/app.js b/web/bulk-api-tester/static/js/app.js deleted file mode 100644 index ab620a3..0000000 --- a/web/bulk-api-tester/static/js/app.js +++ /dev/null @@ -1,3508 +0,0 @@ -/** - * Phoenix App - Advanced Bulk API Tester - * Version: 2.0 (Agentic Edition) - */ - -const App = { - _stateData: { - spaces: [], - activeSpaceId: null, - activeCollectionId: 'default', - - outputFolderPath: '', - gridMaximized: false, - resultsPanelHeight: 300, - sidebarWidth: 270, - searchQuery: '' - }, - - tabs: [], - activeTabIndex: 0, - - get state() { - if (!this._proxyState) { - const props = ['name', 'method', 'url', 'params', 'headers', 'auth', 'bodyType', 'bodyData', 'jsonBody', 'response', 'bulk', 'activeTab', 'responseTab', 'activeRequestId', 'isPreview', 'activeCollectionId']; - this._proxyState = new Proxy(this._stateData, { - get(target, prop) { - if (props.includes(prop)) { - if (App.tabs && App.tabs[App.activeTabIndex]) { - return App.tabs[App.activeTabIndex][prop]; - } - } - return target[prop]; - }, - set(target, prop, value) { - if (props.includes(prop)) { - if (App.tabs && App.tabs[App.activeTabIndex]) { - App.tabs[App.activeTabIndex][prop] = value; - if (prop !== 'activeTab' && prop !== 'responseTab' && prop !== 'activeRequestId') { - App.tabs[App.activeTabIndex].isPreview = false; - } - - // Auto-save to localStorage only (no server call on every keypress) - - return true; - } - } - target[prop] = value; - return true; - } - }); - } - return this._proxyState; - }, - - debouncedSaveToCollection() { - if (this._autoSaveTimeout) clearTimeout(this._autoSaveTimeout); - this._autoSaveTimeout = setTimeout(() => { - this.saveToCollection(); - }, 500); - }, - - createNewTab(reqData, isPreview = false) { - return { - id: 'tab_' + Date.now() + Math.random().toString(36).substr(2, 9), - name: reqData ? reqData.name : 'Untitled Request', - method: reqData ? reqData.method : 'POST', - url: reqData ? reqData.url : '', - params: reqData ? JSON.parse(JSON.stringify(reqData.params || [])) : [], - headers: reqData ? JSON.parse(JSON.stringify(reqData.headers || [])) : [], - auth: reqData ? JSON.parse(JSON.stringify(reqData.auth || {type:'none'})) : {type:'none'}, - bodyType: reqData ? reqData.bodyType : 'none', - bodyData: reqData ? JSON.parse(JSON.stringify(reqData.bodyData || [])) : [], - jsonBody: reqData ? reqData.jsonBody : '', - response: null, - bulk: reqData && reqData.bulk ? JSON.parse(JSON.stringify(reqData.bulk)) : { - strategy: 'consecutive', - running: false, - total: 0, - completed: 0, - success: 0, - error: 0, - concurrency: 1, - delay: 0, - repetitions: 10, - results: [] - }, - activeTab: 'params', - responseTab: 'response', - activeRequestId: reqData ? reqData.id : null, - activeCollectionId: reqData ? reqData.activeCollectionId : 'default', - isPreview: isPreview - }; - }, - - - fileStore: new Map(), // id -> FileList - - dom: {}, - - - _buildShell() { - // Write the complete, permanent DOM structure once. - // Individual regions are updated surgically after this — NEVER the whole mainPanel. - this.dom.sidebar.innerHTML = ` -
- Workspace - -
-
- - -
- - - -
-
- -
- `; - - this.dom.mainPanel.innerHTML = ` - - - - -
-
-
PHOENIX
-
- -
- - -
-
-
- -
- - - -
-
PARAMS
-
HEADERS
-
BODY
-
AUTH
-
-
-
- - -
- -
-
-
-
- - - - - - -
- -
-
-
- -
-
-
- `; - }, - - async init() { - this.loadState(); - this.cacheDOM(); - this._buildShell(); - this._cacheShellDOM(); - this.bindEvents(); - // Bind URL/method input events on cached static elements - if (this.dom.urlInput) { - this.dom.urlInput.addEventListener('input', (e) => { this.state.url = e.target.value; this.saveState(); }); - } - if (this.dom.methodInput) { - this.dom.methodInput.addEventListener('change', (e) => { this.state.method = e.target.value; this.saveState(); }); - } - - // Ensure active tab has at least one param and header row - if (!this.state.params || this.state.params.length === 0) this.addParam('params'); - if (!this.state.headers || this.state.headers.length === 0) this.addParam('headers'); - - // Load spaces from the server to keep them synced - await this.loadSpacesFromServer(); - - // Ensure a workspace is active so collections are always visible - if (!this.state.activeSpaceId && this.state.spaces && this.state.spaces.length > 0) { - this.state.activeSpaceId = this.state.spaces[0].id; - } - - // Apply saved sidebar width - const sidebarEl = document.getElementById('sidebar'); - if (sidebarEl && this._stateData.sidebarWidth) { - sidebarEl.style.width = `${this._stateData.sidebarWidth}px`; - } - - // Attach event listener for horizontal sidebar dragging - const handle = document.getElementById('sidebar-resize-handle'); - if (handle) { - handle.addEventListener('mousedown', (e) => this.startSidebarResize(e)); - } - - this._renderAll(); - - // Remove loader - const loader = document.getElementById('loading-overlay'); - if (loader) loader.remove(); - document.getElementById('app-root').style.visibility = 'visible'; - }, - - // --- Tab Management --- - - openNewTab() { - const newTab = this.createNewTab(); - this.tabs.push(newTab); - this.activeTabIndex = this.tabs.length - 1; - if (!this.state.params || this.state.params.length === 0) this.addParam('params'); - if (!this.state.headers || this.state.headers.length === 0) this.addParam('headers'); - this.saveState(); - this._renderAll(); - }, - - switchTab(index) { - if (index < 0 || index >= this.tabs.length) return; - this.activeTabIndex = index; - this.saveState(); - this._renderAll(); - }, - - closeTab(index) { - if (this.tabs.length <= 1) { - // Can't close last tab; just reset it - this.tabs[0] = this.createNewTab(); - this.activeTabIndex = 0; - this.saveState(); - this._renderAll(); - return; - } - this.tabs.splice(index, 1); - if (this.activeTabIndex >= this.tabs.length) { - this.activeTabIndex = this.tabs.length - 1; - } - this.saveState(); - this._renderAll(); - }, - - cacheDOM() { - this.dom = { - mainPanel: document.getElementById('main-panel'), - sidebar: document.getElementById('sidebar'), - toast: document.getElementById('toast-container') - }; - if (!this.dom.sidebar || !this.dom.mainPanel) { - console.error('Critical DOM missing', this.dom); - alert('Critical Error: DOM missing. Refresh.'); - } - }, - - // Re-cache after shell is built (called after _buildShell) - _cacheShellDOM() { - const d = this.dom; - d.dashboardView = document.getElementById('dashboard-view'); - d.workspaceView = document.getElementById('workspace-view'); - d.spacesGrid = document.getElementById('spaces-grid'); - d.wsSelect = document.getElementById('ws-select'); - d.notifBanner = document.getElementById('notif-banner'); - d.collectionsHeader = document.getElementById('collections-header'); - d.searchWrap = document.getElementById('search-wrap'); - d.collectionsList = document.getElementById('collections-list'); - d.wsBadge = document.getElementById('ws-badge'); - d.themeSelect = document.getElementById('theme-select'); - d.methodSelect = document.getElementById('method-select'); - d.urlInput = document.getElementById('url-input'); - d.actionBtns = document.getElementById('action-btns'); - d.reqTabStrip = document.getElementById('req-tab-strip'); - d.requestMeta = document.getElementById('request-meta'); - d.reqNameInput = document.getElementById('req-name-input'); - d.reqDescInput = document.getElementById('req-desc-input'); - d.bulkControls = document.getElementById('bulk-controls'); - d.contentArea = document.getElementById('content-area'); - d.bottomPanel = document.getElementById('bottom-panel'); - d.ptabResponse = document.getElementById('ptab-response'); - d.ptabResults = document.getElementById('ptab-results'); - d.resultBadge = document.getElementById('result-count-badge'); - d.statSep = document.getElementById('stat-sep'); - d.statCompleted = document.getElementById('stat-completed'); - d.statSuccess = document.getElementById('stat-success'); - d.statError = document.getElementById('stat-error'); - d.bottomRightActions = document.getElementById('bottom-right-actions'); - d.responseView = document.getElementById('response-view'); - d.resultsView = document.getElementById('results-view'); - d.progressTrack = document.getElementById('progress-track'); - d.progressBar = document.getElementById('progress-bar-fill'); - d.resultsGrid = document.getElementById('main-results-grid'); - }, - - // --- State Management --- - - loadState() { - try { - const raw = localStorage.getItem('phoenix-state-v2'); - if (raw) { - const data = JSON.parse(raw); - // Restore _stateData (global state) - if (data.spaces !== undefined) this._stateData.spaces = data.spaces; - if (data.activeSpaceId !== undefined) this._stateData.activeSpaceId = data.activeSpaceId; - if (data.activeCollectionId !== undefined) this._stateData.activeCollectionId = data.activeCollectionId; - if (data.outputFolderPath !== undefined) this._stateData.outputFolderPath = data.outputFolderPath; - if (data.gridMaximized !== undefined) this._stateData.gridMaximized = data.gridMaximized; - if (data.resultsPanelHeight !== undefined) this._stateData.resultsPanelHeight = data.resultsPanelHeight; - if (data.sidebarWidth !== undefined) this._stateData.sidebarWidth = data.sidebarWidth; - if (data.searchQuery !== undefined) this._stateData.searchQuery = data.searchQuery; - - // Restore tabs - if (data.tabs && data.tabs.length > 0) { - this.tabs = data.tabs.map(t => ({ - ...t, - params: t.params || [], - headers: t.headers || [], - bodyData: t.bodyData || [], - auth: t.auth || { type: 'none' }, - bulk: { ...(t.bulk || {}), running: false, results: [] }, - response: null - })); - this.activeTabIndex = Math.min(data.activeTabIndex || 0, this.tabs.length - 1); - } else { - // No saved tabs, create a blank one - this.tabs = [this.createNewTab()]; - this.activeTabIndex = 0; - } - } else { - // Fresh start - this.tabs = [this.createNewTab()]; - this.activeTabIndex = 0; - } - } catch (e) { - console.warn('Failed to load state', e); - this.tabs = [this.createNewTab()]; - this.activeTabIndex = 0; - } - }, - - saveState() { - // Skip expensive localStorage serialization while bulk is actively running. - if (this.state.bulk && this.state.bulk.running) return; - if (this._saveStateTimeout) clearTimeout(this._saveStateTimeout); - this._saveStateTimeout = setTimeout(() => { - try { - const serializedTabs = this.tabs.map(t => ({ - ...t, - bulk: { ...t.bulk, running: false, results: [] }, - response: null - })); - const persistentState = { - spaces: this._stateData.spaces, - activeSpaceId: this._stateData.activeSpaceId, - activeCollectionId: this._stateData.activeCollectionId, - outputFolderPath: this._stateData.outputFolderPath, - gridMaximized: this._stateData.gridMaximized, - resultsPanelHeight: this._stateData.resultsPanelHeight, - sidebarWidth: this._stateData.sidebarWidth, - searchQuery: this._stateData.searchQuery, - tabs: serializedTabs, - activeTabIndex: this.activeTabIndex - }; - localStorage.setItem('phoenix-state-v2', JSON.stringify(persistentState)); - } catch (e) { - console.warn('Failed to save state', e); - } - }, 300); - }, - - async loadLastRunFromServer() { - // Persistence disabled for performance — results are session-only. - }, - - async saveLastRunToServer() { - // Persistence disabled for performance — results are session-only. - }, - - saveLastRunToServerThrottled() { - if (this._saveThrottleTimeout) return; - this._saveThrottleTimeout = setTimeout(async () => { - this._saveThrottleTimeout = null; - await this.saveLastRunToServer(); - }, 1000); - }, - - get collections() { - if (!this.state.activeSpaceId) { - if (this.state.spaces && this.state.spaces.length > 0) { - this.state.activeSpaceId = this.state.spaces[0].id; - } - } - const space = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - return space ? (space.collections || (space.collections = [])) : []; - }, - - set collections(val) { - if (!this.state.activeSpaceId) { - if (this.state.spaces && this.state.spaces.length > 0) { - this.state.activeSpaceId = this.state.spaces[0].id; - } - } - const space = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - if (space) { - space.collections = val; - } - }, - - get notifications() { - if (!this.state.activeSpaceId) return []; - const space = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - return space ? (space.notifications || []) : []; - }, - - set notifications(val) { - if (!this.state.activeSpaceId) return; - const space = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - if (space) { - space.notifications = val; - } - }, - - async loadSpacesFromServer() { - try { - const res = await fetch('/api/spaces'); - const data = await res.json(); - if (Array.isArray(data)) { - // Check if server returned empty or only the default empty spaces - const serverIsEmpty = data.length === 0 || ( - data.length === 2 && - data[0].id === 'personal' && data[0].collections.length === 1 && (!data[0].collections[0].requests || data[0].collections[0].requests.length === 0) && - data[1].id === 'team' && data[1].collections.length === 1 && (!data[1].collections[0].requests || data[1].collections[0].requests.length === 0) - ); - - // Check if client had non-empty legacy collections in localStorage - const clientHasLegacyCollections = this.state.collections && ( - this.state.collections.length > 1 || - (this.state.collections[0] && this.state.collections[0].requests && this.state.collections[0].requests.length > 0) - ); - - if (serverIsEmpty && clientHasLegacyCollections) { - console.log('Migrating local client collections to spaces...'); - this.state.spaces = [ - { - id: 'personal', - name: 'Personal Space', - collections: JSON.parse(JSON.stringify(this.state.collections)) - }, - { - id: 'team', - name: 'Team Space', - collections: JSON.parse(JSON.stringify(this.state.collections)) - } - ]; - delete this.state.collections; - await this._debouncedSaveSpaces(); - } else if (data.length === 0 && this.state.spaces && this.state.spaces.length > 0) { - await this._debouncedSaveSpaces(); - } else if (data.length > 0) { - this.state.spaces = data; - } - - // Validate activeSpaceId - if (this.state.activeSpaceId) { - const spaceExists = this.state.spaces.some(s => s.id === this.state.activeSpaceId); - if (!spaceExists) { - this.state.activeSpaceId = null; - this.state.activeCollectionId = 'default'; - this.state.activeRequestId = null; - } - } - } - } catch (e) { - console.error('Failed to load spaces from server:', e); - } - }, - - async saveSpacesToServer() { - try { - await fetch('/api/spaces', { - method: 'POST', - headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify(this.state.spaces) - }); - } catch (e) { - console.error('Failed to sync spaces with server:', e); - } - }, - - openSpace(spaceId) { - this.state.activeSpaceId = spaceId; - this.state.activeCollectionId = 'default'; - this.state.activeRequestId = null; - this.saveState(); - this._renderAll(); - }, - - showSpacesDashboard() { - this.state.activeSpaceId = null; - this.state.activeCollectionId = 'default'; - this.state.activeRequestId = null; - this.saveState(); - this._renderAll(); - }, - - async createSpace() { - const name = prompt("Enter space name:"); - if (name && name.trim()) { - const id = 'space_' + Date.now(); - this.state.spaces.push({ - id: id, - name: name.trim(), - collections: [{ id: 'default', name: 'My Requests', requests: [] }] - }); - this.state.activeSpaceId = id; - this.saveState(); - await this._debouncedSaveSpaces(); - this._renderAll(); - } - }, - - async deleteSpace(spaceId) { - if (this.state.spaces.length <= 1) { - return this.toast("Cannot delete the last remaining space", "error"); - } - if (confirm("Are you sure you want to delete this space? All collections and requests inside it will be permanently lost.")) { - this.state.spaces = this.state.spaces.filter(s => s.id !== spaceId); - if (this.state.activeSpaceId === spaceId) { - this.state.activeSpaceId = null; - this.state.activeCollectionId = 'default'; - this.state.activeRequestId = null; - } - this.saveState(); - await this._debouncedSaveSpaces(); - this._renderAll(); - } - }, - - renameSpace(spaceId) { - const space = this.state.spaces.find(s => s.id === spaceId); - if (!space) return; - const newName = prompt("Enter new workspace name:", space.name); - if (newName && newName.trim()) { - space.name = newName.trim(); - this.saveState(); - this._debouncedSaveSpaces(); - this._renderAll(); - } - }, - - async setSpaceTheme(themeId) { - const activeSpace = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - if (activeSpace) { - activeSpace.theme = themeId; - this.saveState(); - await this._debouncedSaveSpaces(); - this._renderAll(); - this.toast(`Applied ${themeId} theme to ${activeSpace.name}`); - } - }, - - async shareCollection(colId) { - const otherSpaces = this.state.spaces.filter(s => s.id !== this.state.activeSpaceId); - if (otherSpaces.length === 0) { - return this.toast("No other spaces to share with", "warning"); - } - - const activeSpace = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - const collection = this.collections.find(c => c.id === colId); - if (!collection) return; - - const spacesList = otherSpaces.map((s, idx) => `${idx + 1}. ${s.name}`).join('\n'); - const choice = prompt(`Select workspace to share "${collection.name}" with (enter number):\n${spacesList}`); - if (choice) { - const idx = parseInt(choice) - 1; - if (idx >= 0 && idx < otherSpaces.length) { - const targetSpace = otherSpaces[idx]; - targetSpace.notifications = targetSpace.notifications || []; - - const alreadyShared = targetSpace.notifications.some(n => n.collection.id === colId && n.fromSpaceId === this.state.activeSpaceId); - if (alreadyShared) { - return this.toast("Already shared with this space, pending approval", "warning"); - } - - targetSpace.notifications.push({ - id: 'share_' + Date.now(), - fromSpaceId: this.state.activeSpaceId, - fromSpaceName: activeSpace ? activeSpace.name : 'Unknown Space', - collection: JSON.parse(JSON.stringify(collection)) - }); - - this.saveState(); - await this._debouncedSaveSpaces(); - this.toast(`Shared collection with ${targetSpace.name}!`); - this._renderAll(); - } else { - this.toast("Invalid selection", "error"); - } - } - }, - - openNotificationsModal() { - const activeSpace = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - if (!activeSpace || !activeSpace.notifications || activeSpace.notifications.length === 0) return; - - const modal = document.createElement('div'); - modal.className = 'premium-modal-overlay'; - modal.id = 'notifications-modal'; - - const listHTML = activeSpace.notifications.map(n => ` -
-
- -
-
${this.escapeHTML(n.fromSpaceName)} shared collection:
-
${this.escapeHTML(n.collection.name)}
- ${n.collection.requests ? n.collection.requests.length : 0} Requests -
-
-
- - -
-
- `).join(''); - - modal.innerHTML = ` -
-
-

Share Requests

- -
-
- ${listHTML} -
- -
- `; - document.body.appendChild(modal); - modal.onclick = (e) => { if (e.target === modal) modal.remove(); }; - }, - - async approveShare(notifId) { - const activeSpace = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - if (!activeSpace || !activeSpace.notifications) return; - - const idx = activeSpace.notifications.findIndex(n => n.id === notifId); - if (idx >= 0) { - const notif = activeSpace.notifications[idx]; - const collection = notif.collection; - - let newName = collection.name; - let counter = 1; - while (activeSpace.collections.some(c => c.name === newName)) { - newName = `${collection.name} (${counter++})`; - } - collection.name = newName; - collection.id = 'col_' + Date.now(); - - activeSpace.collections.push(collection); - activeSpace.notifications.splice(idx, 1); - - this.saveState(); - await this._debouncedSaveSpaces(); - this.toast("Collection approved and added!"); - this._renderAll(); - } - }, - - async rejectShare(notifId) { - const activeSpace = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - if (!activeSpace || !activeSpace.notifications) return; - - const idx = activeSpace.notifications.findIndex(n => n.id === notifId); - if (idx >= 0) { - activeSpace.notifications.splice(idx, 1); - this.saveState(); - await this._debouncedSaveSpaces(); - this.toast("Share request rejected"); - this._renderAll(); - } - }, - - startSidebarResize(e) { - e.preventDefault(); - document.body.classList.add('resizing'); - const startX = e.clientX; - const startWidth = this.state.sidebarWidth || 270; - const handle = document.getElementById('sidebar-resize-handle'); - if (handle) handle.classList.add('active'); - - const doDrag = (moveEvent) => { - const deltaX = moveEvent.clientX - startX; - const newWidth = Math.max(180, Math.min(600, startWidth + deltaX)); - this.state.sidebarWidth = newWidth; - const sidebarEl = document.getElementById('sidebar'); - if (sidebarEl) { - sidebarEl.style.width = `${newWidth}px`; - } - }; - - const stopDrag = () => { - document.body.classList.remove('resizing'); - document.removeEventListener('mousemove', doDrag); - document.removeEventListener('mouseup', stopDrag); - if (handle) handle.classList.remove('active'); - this.saveState(); - }; - - document.addEventListener('mousemove', doDrag); - document.addEventListener('mouseup', stopDrag); - }, - - replaceResultCardInDOM(result) { - const newEl = this._buildCardElement(result); - document.querySelectorAll(`.result-card[data-index="${result.index}"]`).forEach(card => { - card.replaceWith(newEl.cloneNode(true)); - }); - }, - - async resendBulkRequest(resultIndex) { - const index = resultIndex - 1; // 0-based index - const bulk = this.state.bulk; - const resultItem = bulk.results.find(r => r.index === resultIndex); - if (!resultItem) return; - - this.toast(`Re-sending request #${resultIndex}...`, 'info'); - - // Recalculate maxFiles and maxList to determine fileIndex and listIndex 1-to-1 - let maxFiles = 0; - let maxList = 0; - - const folders = [ - ...this.state.params.filter(p => p.type === 'folder' && p.enabled && p.key && p.key.trim()), - ...(this.state.bodyType === 'form-data' ? this.state.bodyData.filter(p => p.type === 'folder' && p.enabled && p.key && p.key.trim()) : []) - ]; - if (folders.length > 0) { - for (const f of folders) { - const files = this.fileStore.get(f.id); - if (files && files.length > maxFiles) maxFiles = files.length; - } - } - - const allLists = [ - ...this.state.params.filter(p => p.type === 'list' && p.enabled && p.key && p.key.trim()), - ...(this.state.bodyType === 'form-data' ? this.state.bodyData.filter(p => p.type === 'list' && p.enabled && p.key && p.key.trim()) : []), - ...this.state.headers.filter(h => h.type === 'list' && h.enabled && h.key && h.key.trim()) - ]; - if (allLists.length > 0) { - for (const listParam of allLists) { - const val = listParam.value || ''; - const arr = val.split(/[\n,]+/).map(s => s.trim()).filter(s => s); - if (arr.length > maxList) maxList = arr.length; - } - } - - let fileIndex = index; - let listIndex = index; - if (bulk.strategy === 'cartesian' && maxFiles > 0 && maxList > 0) { - fileIndex = Math.floor(index / maxList); - listIndex = index % maxList; - } - - try { - const res = await this.executeRequest(index, fileIndex, listIndex); - const isSuccess = res.status_code >= 200 && res.status_code < 300; - - // Adjust stats counters - const wasSuccess = resultItem.status >= 200 && resultItem.status < 300; - if (wasSuccess && !isSuccess) { - bulk.success--; - bulk.error++; - } else if (!wasSuccess && isSuccess) { - bulk.success++; - bulk.error--; - } - - // Update item details - resultItem.status = res.status_code; - resultItem.latency = res.latency || 0; - resultItem.data = res.content ? res.content.substring(0, 100) : (res.binary_data ? '[Binary]' : ''); - resultItem.fullContent = res.content; - resultItem.binaryData = res.binary_data; - resultItem.contentType = res.content_type; - resultItem.headers = res.headers; - - if (resultItem.blobUrl && resultItem.blobUrl !== res.blobUrl) { - URL.revokeObjectURL(resultItem.blobUrl); - } - resultItem.blobUrl = res.blobUrl; - resultItem.binaryData = null; - - this.toast(`Request #${resultIndex} completed: ${res.status_code}`, isSuccess ? 'info' : 'error'); - this.updateBulkProgressUI(); - this.replaceResultCardInDOM(resultItem); - await this.saveLastRunToServer(); - } catch (e) { - const wasSuccess = resultItem.status >= 200 && resultItem.status < 300; - if (wasSuccess) { - bulk.success--; - bulk.error++; - } - resultItem.status = 'ERR'; - resultItem.latency = 0; - resultItem.data = e.message; - this.toast(`Request #${resultIndex} failed: ${e.message}`, 'error'); - this.updateBulkProgressUI(); - this.replaceResultCardInDOM(resultItem); - await this.saveLastRunToServer(); - } - }, - - startResultsResize(e) { - e.preventDefault(); - document.body.classList.add('resizing'); - const startY = e.clientY; - const startHeight = this.state.resultsPanelHeight || 300; - - const doDrag = (moveEvent) => { - const deltaY = startY - moveEvent.clientY; - const newHeight = Math.max(120, Math.min(800, startHeight + deltaY)); - this.state.resultsPanelHeight = newHeight; - const panel = document.querySelector('.bottom-results-panel'); - if (panel) { - panel.style.height = `${newHeight}px`; - } - }; - - const stopDrag = () => { - document.body.classList.remove('resizing'); - document.removeEventListener('mousemove', doDrag); - document.removeEventListener('mouseup', stopDrag); - this.saveState(); - }; - - document.addEventListener('mousemove', doDrag); - document.addEventListener('mouseup', stopDrag); - }, - - renderResultCard(result) { - const isImage = (result.contentType || '').toLowerCase().includes('image') && (result.blobUrl || result.binaryData); - const isSuccess = result.status >= 200 && result.status < 300; - const statusClass = isSuccess ? 'status-success' : 'status-error'; - const filename = result.inputFilename || `result_${result.index}`; - const finalFilename = this.getFinalFilename(result); - - let previewHTML = ''; - if (isImage) { - try { - previewHTML = `${filename}`; - } catch (e) { - previewHTML = `
Decode error
`; - } - } else { - let icon = 'fa-file-lines'; - let typeLabel = 'TXT'; - const ct = (result.contentType || '').toLowerCase(); - if (ct.includes('application/json')) { icon = 'fa-file-code'; typeLabel = 'JSON'; } - else if (ct.includes('text/html')) { icon = 'fa-file-code'; typeLabel = 'HTML'; } - else if (result.status === 'ERR') { icon = 'fa-circle-xmark'; typeLabel = 'ERROR'; } - previewHTML = ` -
- - ${typeLabel} -

${this.escapeHTML(result.data || '')}

-
`; - } - - const footerHTML = isImage - ? `` - : `
-
- #${result.index} - ${result.status} - ${result.latency}ms -
-
${finalFilename}
-
`; - - return ` -
-
- ${previewHTML} -
- ${!isImage ? ` - ` : ''} - - - -
-
- ${footerHTML} -
- `; - }, - - _buildCardElement(result) { - const tmp = document.createElement('template'); - tmp.innerHTML = this.renderResultCard(result).trim(); - return tmp.content.firstElementChild; - }, - - appendResultCardToDOM(result) { - const newElement = this._buildCardElement(result); - - const appendToGrid = (grid) => { - if (!grid) return; - const spinner = grid.querySelector('div[style*="fa-spinner"]'); - if (spinner) spinner.remove(); - grid.appendChild(newElement.cloneNode(true)); - // Virtual DOM cap: keep only the most recent 200 cards in the DOM. - // Older results remain accessible in this.state.bulk.results but not rendered. - while (grid.children.length > 200) { - grid.removeChild(grid.firstElementChild); - } - }; - - appendToGrid(this.dom.resultsGrid || document.getElementById('main-results-grid')); - appendToGrid(document.querySelector('.fullscreen-results-grid')); - }, - - updateBulkProgressUI() { - // Direct DOM writes only — no re-render, no querySelectorAll, using cached refs - if (this._rafPending) return; - this._rafPending = true; - requestAnimationFrame(() => { - this._rafPending = false; - const bulk = this.state.bulk; - const pct = bulk.total > 0 ? (bulk.completed / bulk.total) * 100 : 0; - const color = bulk.error > 0 ? (bulk.success > 0 ? 'var(--warning)' : 'var(--danger)') : 'var(--success)'; - - const bar = this.dom.progressBar; - const track = this.dom.progressTrack; - if (bar) { bar.style.width = pct+'%'; bar.style.background = color; } - if (track && bulk.total > 0) track.style.display = ''; - - const sc = this.dom.statCompleted, ss = this.dom.statSuccess, se = this.dom.statError; - const sep = this.dom.statSep, badge = this.dom.resultBadge; - if (sc) { sc.style.display = ''; sc.textContent = `${bulk.completed}/${bulk.total}`; } - if (ss) { ss.style.display = ''; ss.textContent = `${bulk.success} ✓`; } - if (se) { se.style.display = ''; se.textContent = `${bulk.error} ✗`; } - if (sep) sep.style.display = ''; - if (badge) { badge.style.display = ''; badge.textContent = bulk.results.length; } - - // Also update fullscreen if open - document.querySelectorAll('.progress-fill').forEach(b => { b.style.width = pct+'%'; b.style.background = color; }); - document.querySelectorAll('.stat-capsule.success').forEach(el => el.textContent = `${bulk.success} ✓`); - document.querySelectorAll('.stat-capsule.error').forEach(el => el.textContent = `${bulk.error} ✗`); - }); - }, - - - openFullscreenResults() { - const bulk = this.state.bulk; - if (bulk.results.length === 0 && !bulk.running) { - return this.toast("No results to view in fullscreen", "warning"); - } - - let modal = document.getElementById('fullscreen-results-overlay'); - const pct = bulk.total > 0 ? (bulk.completed / bulk.total) * 100 : 0; - const statusColor = bulk.error > 0 ? (bulk.success > 0 ? 'var(--warning)' : 'var(--danger)') : 'var(--success)'; - const folderPath = this.state.outputFolderPath || 'None selected'; - - const contentHTML = ` -
-
- -
-

Fullscreen Batch Processing Grid

-

Real-time execution monitoring and visual results

-
-
- ${bulk.completed} / ${bulk.total} Completed - ${bulk.success} Success - ${bulk.error} Failed -
-
- -
-
- - ${folderPath} - - - -
- - - - -
-
- -
-
-
- -
- `; - - if (!modal) { - modal = document.createElement('div'); - modal.className = 'fullscreen-results-overlay'; - modal.id = 'fullscreen-results-overlay'; - modal.innerHTML = contentHTML; - document.body.appendChild(modal); - } else { - modal.innerHTML = contentHTML; - } - - // Populate the fullscreen grid via DocumentFragment (no re-render of cards) - const fsGrid = document.getElementById('fullscreen-results-inner'); - if (fsGrid) { - const frag = document.createDocumentFragment(); - const shown = bulk.results.slice(-200); - if (shown.length === 0 && bulk.running) { - const ph = document.createElement('div'); - ph.style.cssText = 'grid-column:1/-1;text-align:center;color:var(--text-muted);padding:80px;font-style:italic;'; - ph.innerHTML = 'Running…'; - frag.appendChild(ph); - } else { - shown.forEach(r => frag.appendChild(this._buildCardElement(r))); - } - fsGrid.appendChild(frag); - } - }, - - closeFullscreenResults() { - const modal = document.getElementById('fullscreen-results-overlay'); - if (modal) { - modal.remove(); - } - }, - - async browseServerFolder() { - try { - const res = await fetch('/api/browse_folder', { - method: 'POST' - }); - const data = await res.json(); - if (data.success) { - this.state.outputFolderPath = data.path; - this.saveState(); - this._renderAll(); - this.toast(`Folder selected: ${data.path}`); - } else { - this.toast(data.error || 'Failed to browse folder', 'error'); - } - } catch (e) { - this.toast(`Error browsing folder: ${e.message}`, 'error'); - } - }, - - async saveToServerFolder() { - if (!this.state.bulk.results.length) return this.toast('No results to save', 'error'); - if (!this.state.outputFolderPath) { - this.toast('Please select an output folder first', 'error'); - await this.browseServerFolder(); - if (!this.state.outputFolderPath) return; - } - - try { - this.toast('Saving files to server folder...', 'info'); - - // Build file list from current in-memory blobUrls - const fileItems = []; - for (const r of this.state.bulk.results) { - const filename = this.getFinalFilename(r); - if (r.blobUrl) { - try { - const blob = await fetch(r.blobUrl).then(res => res.blob()); - const ab = await blob.arrayBuffer(); - const b64 = btoa(String.fromCharCode(...new Uint8Array(ab))); - fileItems.push({ filename, is_binary: true, binary_data: b64 }); - } catch (e) { console.warn('blob fetch failed', r.index, e); } - } else if (r.fullContent) { - fileItems.push({ filename, is_binary: false, content: r.fullContent }); - } - } - - if (!fileItems.length) return this.toast('No data available to save', 'error'); - - const res = await fetch('/api/save_folder', { - method: 'POST', - headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ path: this.state.outputFolderPath, results: fileItems }) - }); - - const data = await res.json(); - if (data.success) { - const errMsg = data.errors && data.errors.length > 0 ? ` (${data.errors.length} errors)` : ''; - this.toast(`Saved ${data.count} files to ${this.state.outputFolderPath}${errMsg}`); - } else { - this.toast(`Failed to save: ${data.error}`, 'error'); - } - } catch (e) { - this.toast(`Error saving to folder: ${e.message}`, 'error'); - } - }, - - async saveIndividualToServerFolder(index) { - const result = this.state.bulk.results.find(r => r.index === index); - if (!result) return; - - if (!this.state.outputFolderPath) { - this.toast('Please select an output folder first', 'error'); - await this.browseServerFolder(); - if (!this.state.outputFolderPath) return; - } - - try { - const filename = this.getFinalFilename(result); - let fileItem = null; - if (result.blobUrl) { - const blob = await fetch(result.blobUrl).then(r => r.blob()); - const ab = await blob.arrayBuffer(); - const b64 = btoa(String.fromCharCode(...new Uint8Array(ab))); - fileItem = { filename, is_binary: true, binary_data: b64 }; - } else if (result.fullContent) { - fileItem = { filename, is_binary: false, content: result.fullContent }; - } - if (!fileItem) return this.toast('No data for this result', 'error'); - - const res = await fetch('/api/save_folder', { - method: 'POST', - headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ path: this.state.outputFolderPath, results: [fileItem] }) - }); - - const data = await res.json(); - if (data.success && data.count > 0) { - this.toast(`Saved file #${index} to server folder`); - } else { - this.toast(`Failed to save: ${data.error || (data.errors && data.errors[0]) || 'Unknown error'}`, 'error'); - } - } catch (e) { - this.toast(`Error saving file: ${e.message}`, 'error'); - } - }, - - downloadIndividualResult(index) { - const result = this.state.bulk.results.find(r => r.index === index); - if (!result) return; - - try { - const finalFilename = this.getFinalFilename(result); - let url; - let needsRevoke = false; - - if (result.blobUrl) { - url = result.blobUrl; - } else if (result.fullContent) { - const blob = new Blob([result.fullContent], { type: result.contentType || 'text/plain' }); - url = URL.createObjectURL(blob); - needsRevoke = true; - } else { - return this.toast('No content to download', 'error'); - } - - const a = document.createElement('a'); - a.href = url; - a.download = finalFilename; - document.body.appendChild(a); - a.click(); - document.body.removeChild(a); - if (needsRevoke) { - URL.revokeObjectURL(url); - } - - this.toast(`Downloaded "${finalFilename}"`); - } catch (e) { - this.toast(`Download failed: ${e.message}`, 'error'); - } - }, - - clearBulkResults() { - if (confirm("Are you sure you want to clear all batch results?")) { - // Revoke all blob URLs before clearing to free memory - this.state.bulk.results.forEach(r => { if (r.blobUrl) URL.revokeObjectURL(r.blobUrl); }); - this.state.bulk.results = []; - this.state.bulk.completed = 0; - this.state.bulk.success = 0; - this.state.bulk.error = 0; - this.state.bulk.total = 0; - this.state.bulk.running = false; - this.saveState(); - this.saveLastRunToServer(); - this._renderAll(); - } - }, - - toggleGridMaximized() { - this.state.gridMaximized = !this.state.gridMaximized; - this._renderAll(); - }, - - // --- Actions --- - - addParam(section) { - const item = { id: Date.now().toString() + Math.random(), key: '', value: '', type: 'text', enabled: true }; - if (section === 'params') this.state.params.push(item); - if (section === 'headers') this.state.headers.push(item); - if (section === 'body') this.state.bodyData.push(item); - this._switchContentTab(this.state.activeTab); - this._updateBulkControls(); - this._updateActionBtns(); - this.saveState(); - }, - - removeParam(section, id) { - if (section === 'params') this.state.params = this.state.params.filter(p => p.id !== id); - if (section === 'headers') this.state.headers = this.state.headers.filter(p => p.id !== id); - if (section === 'body') this.state.bodyData = this.state.bodyData.filter(p => p.id !== id); - this._switchContentTab(this.state.activeTab); - this._updateBulkControls(); - this._updateActionBtns(); - this.saveState(); - }, - - updateParam(section, id, field, value) { - const list = section === 'params' ? this.state.params : (section === 'headers' ? this.state.headers : this.state.bodyData); - const item = list.find(p => p.id === id); - if (item) { - item[field] = value; - this.saveState(); - if (field === 'type' || field === 'enabled') { - this._switchContentTab(this.state.activeTab); - this._updateBulkControls(); - this._updateActionBtns(); - } - } - }, - - // --- Request Execution --- - - async sendRequest() { - if (!this.state.url) return this.toast('URL is required', 'error'); - - // Reset bulk results upon sending another single request - this.state.bulk.results = []; - this.state.bulk.completed = 0; - this.state.bulk.success = 0; - this.state.bulk.error = 0; - this.state.bulk.total = 0; - - this.state.response = { status: 'Sending...', headers: {} }; - this.state.responseTab = 'response'; - this._switchBottomTab('response'); - this._updateResponseView(); - - try { - const start = Date.now(); - const res = await this.executeRequest(0); - const latency = Date.now() - start; - - res.latency = latency; - this.state.response = res; - if (res.blobUrl) this.state.response.blobUrl = res.blobUrl; - this.saveToCollection(res.status_code || 500); - } catch (e) { - this.state.response = { error: e.message }; - } - - this._updateResponseView(); - this._updateActionBtns(); - this.saveToCollection(this.state.response.status_code || 500); - this.saveState(); - }, - - // --- Bulk Execution --- - - async runBulk() { - if (!this.state.url) return this.toast('URL is required', 'error'); - - // Calculate total items based on folders or lists - let maxFiles = 0; - let maxList = 0; - const currentRunId = Date.now(); - this.state.bulk.currentRunId = currentRunId; - - // Check folders first - only those that will actually be used - const folders = [ - ...this.state.params.filter(p => p.type === 'folder' && p.enabled && p.key && p.key.trim()), - ...(this.state.bodyType === 'form-data' ? this.state.bodyData.filter(p => p.type === 'folder' && p.enabled && p.key && p.key.trim()) : []) - ]; - - if (folders.length > 0) { - // Find max file count - for (const f of folders) { - const files = this.fileStore.get(f.id); - if (files && files.length > maxFiles) maxFiles = files.length; - } - } - - // Check lists (params, body, headers) - only those with keys - const allLists = [ - ...this.state.params.filter(p => p.type === 'list' && p.enabled && p.key && p.key.trim()), - ...(this.state.bodyType === 'form-data' ? this.state.bodyData.filter(p => p.type === 'list' && p.enabled && p.key && p.key.trim()) : []), - ...this.state.headers.filter(h => h.type === 'list' && h.enabled && h.key && h.key.trim()) - ]; - - if (allLists.length > 0) { - // Find the longest list - for (const listParam of allLists) { - const val = listParam.value || ''; - const arr = val.split(/[\n,]+/).map(s => s.trim()).filter(s => s); - if (arr.length > maxList) maxList = arr.length; - } - } - - let total = 0; - if (this.state.bulk.strategy === 'cartesian' && maxFiles > 0 && maxList > 0) { - total = maxFiles * maxList; - } else { - total = Math.max(maxFiles, maxList); - } - - // If still no total, use the saved repetitions setting - if (total === 0) { - total = Math.max(1, parseInt(this.state.bulk.repetitions) || 10); - } - - if (total <= 0) return this.toast('Invalid bulk count', 'error'); - - // Init Bulk State - if (!this.state.bulk.paused) { - this.state.bulk.total = total; - this.state.bulk.completed = 0; - this.state.bulk.success = 0; - this.state.bulk.error = 0; - this.state.bulk.results = []; - this.state.bulk.nextIndex = 0; - this.state.responseTab = 'results'; - } else { - this.state.bulk.total = total; - } - - this.state.bulk.running = true; - this.state.bulk.paused = false; - - // Surgical init: show results view, update action buttons — no full re-render - this._switchBottomTab('results'); - this._updateActionBtns(); - this._updateBottomStats(); - this._updateBottomRightActions(); - if (this.dom.progressTrack) this.dom.progressTrack.style.display = ''; - // Clear grid for new run - if (this.dom.resultsGrid) this.dom.resultsGrid.innerHTML = ''; - this.saveToCollection('BULK'); - - // Execution Queue - const concurrency = Math.max(1, Math.min(20, this.state.bulk.concurrency || 1)); - let active = 0; - - const worker = async () => { - while (this.state.bulk.nextIndex < this.state.bulk.total && this.state.bulk.running && this.state.bulk.currentRunId === currentRunId) { - const index = this.state.bulk.nextIndex++; - active++; - - let fileIndex = index; - let listIndex = index; - if (this.state.bulk.strategy === 'cartesian' && maxFiles > 0 && maxList > 0) { - fileIndex = Math.floor(index / maxList); - listIndex = index % maxList; - } - - const inputFilename = this.getInputFilename(index, fileIndex, listIndex); - - try { - const res = await this.executeRequest(index, fileIndex, listIndex); - - if (this.state.bulk.currentRunId !== currentRunId) return; - - const isSuccess = res.status_code >= 200 && res.status_code < 300; - if (isSuccess) this.state.bulk.success++; else this.state.bulk.error++; - - this.state.bulk.results.push({ - index: index + 1, - status: res.status_code, - latency: res.latency || 0, - data: res.content ? res.content.substring(0, 100) : (res.binary_data ? '[Binary]' : ''), - // Strip heavy data immediately — blobUrl is a cheap pointer - // fullContent and binaryData are NOT stored to avoid heap bloat - fullContent: null, - binaryData: null, - blobUrl: res.blobUrl, - contentType: res.content_type, - headers: res.headers, - inputFilename: inputFilename - }); - - const newResult = this.state.bulk.results[this.state.bulk.results.length - 1]; - this.appendResultCardToDOM(newResult); - // Cap result memory: revoke blob URL of oldest item when trimming - if (this.state.bulk.results.length > 300) { - const dropped = this.state.bulk.results.shift(); - if (dropped && dropped.blobUrl) URL.revokeObjectURL(dropped.blobUrl); - } - - } catch (e) { - if (this.state.bulk.currentRunId !== currentRunId) return; - this.state.bulk.error++; - this.state.bulk.results.push({ - index: index + 1, - status: 'ERR', - latency: 0, - data: e.message, - inputFilename: inputFilename - }); - const errResult = this.state.bulk.results[this.state.bulk.results.length - 1]; - this.appendResultCardToDOM(errResult); - } finally { - active--; - this.state.bulk.completed++; - if (this.state.bulk.currentRunId === currentRunId) { - this.updateBulkProgressUI(); - } - } - - // Apply inter-request delay (only when concurrency = 1 or after each request) - const delayMs = parseInt(this.state.bulk.delay) || 0; - if (delayMs > 0 && this.state.bulk.running && this.state.bulk.currentRunId === currentRunId) { - await new Promise(r => setTimeout(r, delayMs)); - } - } - - if (active === 0 && this.state.bulk.nextIndex >= this.state.bulk.total && this.state.bulk.currentRunId === currentRunId) { - this.state.bulk.running = false; - this.state.bulk.paused = false; - this.state.bulk.results.sort((a, b) => a.index - b.index); - // Surgical completion: just update action buttons and stats - this._updateActionBtns(); - this._updateBottomStats(); - this._updateBottomRightActions(); - this.toast('Bulk Operation Completed'); - } - }; - - // Spawn workers - for (let i = 0; i < concurrency; i++) { - worker(); - } - }, - - stopBulk() { - this.state.bulk.running = false; - this.state.bulk.paused = false; - this._updateActionBtns(); - this._updateBottomRightActions(); - }, - - pauseBulk() { - if (this.state.bulk.running) { - this.state.bulk.running = false; - this.state.bulk.paused = true; - this._updateActionBtns(); - this.toast('Bulk Operation Paused', 'warning'); - } - }, - - resumeBulk() { - if (this.state.bulk.paused) { - this.runBulk(); - } - }, - - async getImageDimensions(file) { - return new Promise((resolve) => { - if (!file || !file.type.startsWith('image/')) return resolve({width: 0, height: 0}); - const img = new Image(); - const url = URL.createObjectURL(file); - img.onload = () => { - resolve({width: img.width, height: img.height}); - URL.revokeObjectURL(url); - }; - img.onerror = () => { - resolve({width: 0, height: 0}); - URL.revokeObjectURL(url); - }; - img.src = url; - }); - }, - - async executeRequest(index, fileIndex = index, listIndex = index) { - const start = Date.now(); - // Headers - const headers = {}; - this.state.headers.filter(h => h.enabled && h.key && h.key.trim()).forEach(h => { - // Handle list replacement in headers too - let val = h.value; - if (h.type === 'list') { - const arr = val.split(/[\n,]+/).map(s => s.trim()).filter(s => s); - if (arr.length > 0) val = arr[listIndex % arr.length]; - } - headers[h.key.trim()] = val; - }); - - // Auth - const auth = this.state.auth; - if (auth.type === 'bearer') headers['Authorization'] = `Bearer ${auth.token}`; - else if (auth.type === 'basic') headers['Authorization'] = 'Basic ' + btoa(`${auth.username}:${auth.password}`); - else if (auth.type === 'apikey') headers[auth.key] = auth.value; - - // URL Params - const urlObj = new URL(this.state.url); - this.state.params.filter(p => p.enabled && p.key && p.key.trim()).forEach(p => { - let val = p.value; - // List handling - if (p.type === 'list') { - // Try splitting by newline first if present, else comma - const arr = val.split(/[\n,]+/).map(s => s.trim()).filter(s => s); - if (arr.length > 0) val = arr[listIndex % arr.length]; - } - // File logic not applicable for URL params usually, skipping - urlObj.searchParams.append(p.key, val); - }); - - // Payload Construction - const finalData = new FormData(); - finalData.append('method', this.state.method); - finalData.append('url', urlObj.toString()); - finalData.append('headers', JSON.stringify(headers)); - // Add auth config for server-side handling if needed (e.g. Basic Auth via requests arg) - if (auth.type === 'basic') finalData.append('auth', JSON.stringify({ type: 'basic', username: auth.username, password: auth.password })); - - // Body - if (this.state.bodyType === 'json') { - finalData.append('body_type', 'json'); - finalData.append('body', this.state.jsonBody); - } else if (this.state.bodyType === 'form-data') { - finalData.append('body_type', 'form-data'); - - let currentImageFile = null; - const folderParam = this.state.bodyData.find(p => p.enabled && p.type === 'folder'); - if (folderParam) { - const files = this.fileStore.get(folderParam.id); - if (files && files.length > 0) currentImageFile = files[fileIndex % files.length]; - } - if (!currentImageFile) { - const fileParam = this.state.bodyData.find(p => p.enabled && p.type === 'file'); - if (fileParam) { - const files = this.fileStore.get(fileParam.id); - if (files && files.length > 0) currentImageFile = files[0]; - } - } - let imgDims = null; - - const bodyParams = this.state.bodyData.filter(p => p.enabled && (p.type === 'file' || p.type === 'folder' || p.type === 'auto_width' || p.type === 'auto_height' || (p.key && p.key.trim()))); - for (const p of bodyParams) { - if (p.type === 'file' || p.type === 'folder') { - const files = this.fileStore.get(p.id); - if (files && files.length > 0) { - if (p.type === 'folder') { - finalData.append(p.key, files[fileIndex % files.length]); - } else { - for (let f of files) finalData.append(p.key, f); - } - } - } else if (p.type === 'auto_width' || p.type === 'auto_height') { - if (!imgDims) imgDims = await this.getImageDimensions(currentImageFile); - finalData.append(p.key, p.type === 'auto_width' ? imgDims.width : imgDims.height); - } else { - let val = p.value; - if (p.type === 'list') { - const arr = val.split(/[\n,]+/).map(s => s.trim()).filter(s => s); - if (arr.length > 0) val = arr[listIndex % arr.length]; - } - finalData.append(p.key, val); - } - } - } - - const res = await fetch('/api/proxy-request', { - method: 'POST', - body: finalData - }); - - const data = await res.json(); - if (data.binary_data) { - data.blobUrl = await this.base64ToBlobUrlAsync(data.binary_data, data.content_type); - // Immediately null out raw data to free the large string from JS heap. - // The blobUrl is a tiny reference to browser-managed memory. - data.binary_data = null; - } - data.latency = Date.now() - start; - return data; - }, - - saveToCollection(lastStatus) { - if (!this.state.url) return; - - let targetColId = this.state.activeCollectionId || 'default'; - let col = this.collections.find(c => c.id === targetColId); - if (!col) { - col = this.collections.find(c => c.id === 'default'); - if(!col) { - col = { id: 'default', name: 'My Requests', requests: [] }; - this.collections.push(col); - } - targetColId = col.id; - } - - const existingIdx = col.requests.findIndex(r => r.id === this.state.activeRequestId || (r.url === this.state.url && r.method === this.state.method)); - let existingReq = existingIdx >= 0 ? col.requests[existingIdx] : null; - - const reqData = { - id: this.state.activeRequestId || Date.now().toString(), - name: (existingReq && existingReq.name) ? existingReq.name : (this.state.url.split('?')[0].split('/').pop() || 'Root URL'), - method: this.state.method, - url: this.state.url, - params: JSON.parse(JSON.stringify(this.state.params)), - headers: JSON.parse(JSON.stringify(this.state.headers)), - auth: JSON.parse(JSON.stringify(this.state.auth)), - bodyType: this.state.bodyType, - bodyData: JSON.parse(JSON.stringify(this.state.bodyData)), - jsonBody: this.state.jsonBody, - lastStatus: lastStatus !== undefined ? lastStatus : (existingReq ? existingReq.lastStatus : null), - lastTime: new Date().toLocaleTimeString(), - activeCollectionId: targetColId - }; - - if (existingIdx >= 0) { - // Update existing - reqData.id = existingReq.id; // preserve ID - col.requests[existingIdx] = reqData; - } else { - // Add new - col.requests.unshift(reqData); - } - - this.state.activeRequestId = reqData.id; - this.saveState(); - this._debouncedSaveSpaces(); - }, - - _debouncedSaveSpaces() { - if (this._saveSpacesTimer) clearTimeout(this._saveSpacesTimer); - this._saveSpacesTimer = setTimeout(() => this.saveSpacesToServer(), 1000); - }, - - loadRequest(colId, reqId) { - const col = this.collections.find(c => c.id === colId); - if(!col) return; - const req = col.requests.find(r => r.id === reqId); - if(!req) return; - - // Check if this request is already open in any tab - const existingTabIdx = this.tabs.findIndex(t => t.activeRequestId === reqId); - if (existingTabIdx >= 0) { - // Just switch to that tab - this.activeTabIndex = existingTabIdx; - this.saveState(); - this._renderAll(); - return; - } - - // Postman behavior: if the current tab is a "preview" tab (untouched/empty), reuse it; - // otherwise open a new tab - const currTab = this.tabs[this.activeTabIndex]; - const isUntouched = currTab && ( - (!currTab.url || currTab.url === '') && - (!currTab.activeRequestId) && - (!currTab.response) && - (currTab.name === 'Untitled Request' || !currTab.name) - ); - - const reqTabData = { - id: 'tab_' + Date.now() + Math.random().toString(36).substr(2, 9), - name: req.name || (req.url ? req.url.split('/').pop() || req.url : 'Request'), - method: req.method || 'GET', - url: req.url || '', - params: JSON.parse(JSON.stringify(req.params || [{ id: Date.now().toString(), key: '', value: '', type: 'text', enabled: true }])), - headers: JSON.parse(JSON.stringify(req.headers || [{ id: (Date.now()+1).toString(), key: '', value: '', type: 'text', enabled: true }])), - auth: JSON.parse(JSON.stringify(req.auth || {type:'none'})), - bodyType: req.bodyType || 'none', - bodyData: JSON.parse(JSON.stringify(req.bodyData || [])), - jsonBody: req.jsonBody || '', - response: null, - bulk: { strategy: 'consecutive', running: false, total: 0, completed: 0, success: 0, error: 0, concurrency: 1, results: [] }, - activeTab: 'params', - responseTab: 'response', - activeRequestId: reqId, - activeCollectionId: colId, - isPreview: false - }; - - if (isUntouched) { - // Replace current blank tab - this.tabs[this.activeTabIndex] = reqTabData; - } else { - // Open brand new tab - this.tabs.push(reqTabData); - this.activeTabIndex = this.tabs.length - 1; - } - - this.saveState(); - this._renderAll(); - }, - - deleteRequest(colId, reqId) { - const col = this.collections.find(c => c.id === colId); - if(col) col.requests = col.requests.filter(r => r.id !== reqId); - if(this.state.activeRequestId === reqId) this.state.activeRequestId = null; - this.saveState(); - this._debouncedSaveSpaces(); - this._renderAll(); - }, - - createCollection() { - this.openCreateCollectionModal(); - }, - - openCreateCollectionModal() { - const existing = document.getElementById('create-col-modal'); - if (existing) existing.remove(); - - const modal = document.createElement('div'); - modal.className = 'premium-modal-overlay'; - modal.id = 'create-col-modal'; - modal.innerHTML = ` -
-
-

Create New Collection

- -
-
- -
-
-
- -
-
-
- Import from Documentation - Recommended -
-
69 pre-configured Generative AI backend services
-
- - Browse APIs - -
-
- Select an API to automatically populate full URLs, multipart form fields, parameters, and preset values. -
-
- -
-
- or create blank collection -
-
- - -
-
- - -
-
- - -
-
-
-
- `; - document.body.appendChild(modal); - setTimeout(() => { - const inp = document.getElementById('new-col-name-input'); - if (inp) inp.focus(); - }, 50); - }, - - _createBlankCollection(name) { - if (!name) return; - if (!this.state.activeSpaceId && this.state.spaces && this.state.spaces.length > 0) { - this.state.activeSpaceId = this.state.spaces[0].id; - } - let space = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - if (!space) { - space = { id: 'space_' + Date.now(), name: 'My Workspace', collections: [] }; - this.state.spaces.push(space); - this.state.activeSpaceId = space.id; - } - const id = 'col_' + Date.now(); - const newCol = { id, name, requests: [] }; - if (!space.collections) space.collections = []; - space.collections.push(newCol); - this.state.activeCollectionId = id; - this.saveState(); - this.saveSpacesToServer(); - this._renderAll(); - this.toast(`Created collection "${name}"`, "success"); - }, - - getAllCollectionsGrouped() { - const groups = []; - (this.state.spaces || []).forEach(s => { - const cols = s.collections || []; - if (cols.length > 0) { - groups.push({ - spaceId: s.id, - spaceName: s.name, - isCurrent: s.id === this.state.activeSpaceId, - collections: cols - }); - } - }); - groups.sort((a, b) => (b.isCurrent ? 1 : 0) - (a.isCurrent ? 1 : 0)); - return groups; - }, - - findCollectionAcrossSpaces(colId) { - if (!colId) return null; - for (const s of (this.state.spaces || [])) { - const col = (s.collections || []).find(c => c.id === colId); - if (col) return { space: s, collection: col }; - } - return null; - }, - - async getDocsData() { - if (this._cachedDocsData) return this._cachedDocsData; - const urls = [ - '/api/docs-data', - '/static/data/docs_apis.json', - '/docs/data.json' - ]; - for (const url of urls) { - try { - const res = await fetch(url); - if (res.ok) { - const data = await res.json(); - if (data && data.sections) { - this._cachedDocsData = data; - return data; - } - } - } catch(e) {} - } - return null; - }, - - async openImportFromDocModal(targetColId = null) { - this._importTargetColId = targetColId || null; - this._docModalSearch = ''; - this._docModalActiveCategory = 'all'; - - const existing = document.getElementById('import-doc-modal'); - if (existing) existing.remove(); - - const modal = document.createElement('div'); - modal.className = 'premium-modal-overlay'; - modal.id = 'import-doc-modal'; - modal.innerHTML = ` -
-
-
-

Import from API Documentation

-

Click an API to automatically create a collection and pre-fill URLs, parameters, multipart files, and presets.

-
- -
- -
- -
-
- - Destination: - - -
-
Loading APIs…
-
- - -
- - - -
- - -
-
- - -
-
- Loading documentation APIs… -
-
- - -
- `; - document.body.appendChild(modal); - - // Load docs data - const docsData = await this.getDocsData(); - if (!docsData) { - const listEl = document.getElementById('doc-modal-list'); - if (listEl) { - listEl.innerHTML = `
Failed to load documentation APIs. Please try again.
`; - } - return; - } - - // Build index of APIs - const allApis = []; - (docsData.sections || []).forEach(s => { - (s.eps || []).forEach(e => { - allApis.push({ - ...e, - secId: s.id, - secTitle: s.title, - secHue: s.hue - }); - }); - }); - this._docModalApis = allApis; - this._docModalSections = docsData.sections || []; - - this._renderDocModalCategories(); - this._renderDocModalList(); - - setTimeout(() => { - const inp = document.getElementById('doc-api-search-input'); - if (inp) inp.focus(); - }, 50); - }, - - _renderDocModalCategories() { - const catsEl = document.getElementById('doc-modal-cats'); - if (!catsEl || !this._docModalSections) return; - - const totalCount = (this._docModalApis || []).length; - let html = ` - - `; - - this._docModalSections.forEach(s => { - const count = (s.eps || []).length; - const isActive = this._docModalActiveCategory === s.id; - html += ` - - `; - }); - - catsEl.innerHTML = html; - }, - - _selectDocModalCategory(catId) { - this._docModalActiveCategory = catId; - this._renderDocModalCategories(); - this._renderDocModalList(); - }, - - _filterDocModal(query) { - this._docModalSearch = (query || '').toLowerCase().trim(); - const clearBtn = document.getElementById('doc-api-search-clear'); - if (clearBtn) clearBtn.style.display = this._docModalSearch ? 'block' : 'none'; - this._renderDocModalList(); - }, - - _renderDocModalList() { - const listEl = document.getElementById('doc-modal-list'); - const countEl = document.getElementById('doc-modal-count'); - if (!listEl || !this._docModalApis) return; - - const q = this._docModalSearch || ''; - const cat = this._docModalActiveCategory || 'all'; - - const filtered = this._docModalApis.filter(api => { - if (cat !== 'all' && api.secId !== cat) return false; - if (!q) return true; - - const haystack = [ - api.api_key || '', - api.title || '', - api.summary || '', - api.desc || '', - api.full_url || '', - api.path || '', - ...(api.params || []).map(p => p.n || ''), - ...(api.chips || []), - ...(api.endpoints || []).map(sub => (sub.title || '') + ' ' + (sub.subpath || '') + ' ' + (sub.path || '')) - ].join(' ').toLowerCase(); - - return haystack.includes(q); - }); - - if (countEl) { - countEl.textContent = `Showing ${filtered.length} of ${this._docModalApis.length} APIs`; - } - - if (filtered.length === 0) { - listEl.innerHTML = ` -
- - No APIs found matching "${this.escapeHTML(q)}" -
- `; - return; - } - - listEl.innerHTML = filtered.map(api => { - const subEps = (api.endpoints && api.endpoints.length) ? api.endpoints : [api]; - const hasMultiple = subEps.length > 1; - const targetUrl = api.full_url || ('https://apigp0006.creinnovations.in' + (api.path || '')); - const cleanParams = (api.params || []).filter(p => p.n && p.n.trim()); - const chips = api.chips || []; - - return ` -
-
-
- ${api.method} - - ${this.escapeHTML(api.api_key || api.title)} - - - ${this.escapeHTML(api.secTitle)} - -
-
- ${hasMultiple ? `${subEps.length} routes` : ''} - ${chips.length ? `${chips.length} presets` : ''} - -
-
- -
- ${this.escapeHTML(targetUrl)} -
- -
- ${this.escapeHTML(api.summary || api.title)} -
- - -
- Fields: - ${cleanParams.slice(0, 6).map(p => { - const isFile = /file|binary/i.test(p.ty); - const isPreset = chips.length && (/id$/i.test(p.n) || /preset/i.test(p.n)); - const cls = isFile ? 'param-file' : (isPreset ? 'param-preset' : ''); - return ` - - ${isFile ? '' : (isPreset ? '' : '')} - ${this.escapeHTML(p.n)}${p.rq ? ' *' : ''} - - `; - }).join('')} - ${cleanParams.length > 6 ? `+${cleanParams.length - 6} more` : ''} -
- - - ${hasMultiple ? ` -
-
- Available Endpoints: - -
-
- ${subEps.map((sub, sIdx) => ` -
-
- ${sub.method} - ${this.escapeHTML(sub.subpath || sub.path)} - ${this.escapeHTML(sub.title)} -
- -
- `).join('')} -
-
- ` : ''} -
- `; - }).join(''); - }, - - async importFromDoc(apiId, subEpIdx = 0, targetColId = null, customColName = null, importAll = false) { - const api = (this._docModalApis || []).find(a => a.id === apiId); - if (!api) { - this.toast("API not found", "error"); - return; - } - - // Ensure active workspace - if (!this.state.activeSpaceId && this.state.spaces && this.state.spaces.length > 0) { - this.state.activeSpaceId = this.state.spaces[0].id; - } - let activeSpace = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - if (!activeSpace) { - const newSpace = { id: 'workspace_' + Date.now(), name: 'Default Workspace', collections: [] }; - this.state.spaces.push(newSpace); - this.state.activeSpaceId = newSpace.id; - activeSpace = newSpace; - } - - // Determine destination collection: - const selDest = document.getElementById('doc-modal-dest-select'); - let destinationId = targetColId || (selDest && selDest.value ? selDest.value : this._importTargetColId); - - let col = null; - if (destinationId) { - const found = this.findCollectionAcrossSpaces(destinationId); - if (found) { - activeSpace = found.space; - this.state.activeSpaceId = activeSpace.id; - col = found.collection; - } - } - - if (!col) { - // Create new collection - const colName = customColName || api.api_key || api.title || "Imported API"; - const newColId = 'col_' + Date.now(); - col = { - id: newColId, - name: colName, - requests: [] - }; - if (!activeSpace.collections) activeSpace.collections = []; - activeSpace.collections.push(col); - } - - // Always activate and expand this collection in the sidebar! - this.state.activeCollectionId = col.id; - - const subEndpoints = importAll - ? (api.endpoints && api.endpoints.length ? api.endpoints : [api]) - : (subEpIdx !== null && api.endpoints && api.endpoints[subEpIdx] ? [api.endpoints[subEpIdx]] : (api.endpoints && api.endpoints[0] ? [api.endpoints[0]] : [api])); - - let lastCreatedReq = null; - - subEndpoints.forEach((sub, sIdx) => { - const reqId = 'req_' + Date.now() + '_' + sIdx; - const targetUrl = sub.full_url || api.full_url || (sub.path ? ('https://apigp0006.creinnovations.in' + sub.path) : ''); - const method = (sub.method === 'MULTI' ? 'POST' : (sub.method || api.method || 'POST')).toUpperCase(); - - const cleanParams = (sub.params || api.params || []).filter(p => p.n && p.n.trim()); - const queryParams = cleanParams.filter(p => /query/i.test(p.lc)); - const bodyParams = cleanParams.filter(p => !/query/i.test(p.lc)); - - // CRITICAL: Fill ONLY the field and type, DO NOT fill values! - const finalQueryParams = queryParams.length ? queryParams.map(p => ({ - id: (Date.now() + Math.random()).toString(), - key: p.n, - value: '', // Strictly empty! - type: 'text', - enabled: true - })) : [{ id: (Date.now() + Math.random()).toString(), key: '', value: '', type: 'text', enabled: true }]; - - let bodyType = 'none'; - let bodyData = []; - let jsonBody = ''; - - const isJson = bodyParams.some(p => /json|raw/i.test(p.lc) || /application\/json/i.test(p.lc)); - - if (isJson) { - bodyType = 'json'; - jsonBody = ''; // Strictly empty! - } else if (bodyParams.length > 0 || method === 'POST') { - bodyType = 'form-data'; - bodyData = bodyParams.map(p => { - const isFile = /file|binary/i.test(p.ty); - return { - id: (Date.now() + Math.random()).toString(), - key: p.n, - value: '', // Strictly empty! Just key and type! - type: isFile ? 'file' : 'text', - enabled: true - }; - }); - } - - const newReq = { - id: reqId, - name: sub.title || api.title || api.api_key, - method: method, - url: targetUrl, - description: sub.desc || sub.summary || api.desc || api.summary || '', - params: finalQueryParams, - headers: [{ id: (Date.now() + Math.random()).toString(), key: '', value: '', type: 'text', enabled: true }], - auth: { type: 'none' }, - bodyType: bodyType, - bodyData: bodyData, - jsonBody: jsonBody - }; - - col.requests.push(newReq); - lastCreatedReq = newReq; - }); - - if (lastCreatedReq) { - const reqTabData = { - id: 'tab_' + Date.now() + Math.random().toString(36).substr(2, 9), - name: lastCreatedReq.name, - method: lastCreatedReq.method, - url: lastCreatedReq.url, - params: JSON.parse(JSON.stringify(lastCreatedReq.params)), - headers: JSON.parse(JSON.stringify(lastCreatedReq.headers)), - auth: JSON.parse(JSON.stringify(lastCreatedReq.auth)), - bodyType: lastCreatedReq.bodyType, - bodyData: JSON.parse(JSON.stringify(lastCreatedReq.bodyData)), - jsonBody: lastCreatedReq.jsonBody, - response: null, - bulk: { strategy: 'consecutive', running: false, total: 0, completed: 0, success: 0, error: 0, concurrency: 1, results: [] }, - activeTab: lastCreatedReq.bodyType === 'none' ? 'params' : 'body', - responseTab: 'response', - activeRequestId: lastCreatedReq.id, - activeCollectionId: col.id, - isPreview: false - }; - - const currTab = this.tabs[this.activeTabIndex]; - const isUntouched = currTab && (!currTab.url && !currTab.activeRequestId && !currTab.response); - if (isUntouched) { - this.tabs[this.activeTabIndex] = reqTabData; - } else { - this.tabs.push(reqTabData); - this.activeTabIndex = this.tabs.length - 1; - } - - this.state.activeRequestId = lastCreatedReq.id; - } - - // Close modals - const modal = document.getElementById('import-doc-modal'); - if (modal) modal.remove(); - const createModal = document.getElementById('create-col-modal'); - if (createModal) createModal.remove(); - - this.saveState(); - await this.saveSpacesToServer(); - this._renderAll(); - - const successMsg = importAll - ? `Imported all ${subEndpoints.length} routes into "${col.name}"!` - : `Imported "${lastCreatedReq ? lastCreatedReq.name : 'API'}" into "${col.name}"!`; - - this.toast(successMsg, "success"); - }, - - renameCollection(colId) { - const col = this.collections.find(c => c.id === colId); - if(!col) return; - const newName = prompt("Enter new collection name:", col.name); - if(newName && newName.trim()) { - col.name = newName.trim(); - this.saveState(); - this._debouncedSaveSpaces(); - this._renderAll(); - } - }, - - renameRequest(colId, reqId) { - const col = this.collections.find(c => c.id === colId); - if(!col) return; - const req = col.requests.find(r => r.id === reqId); - if(!req) return; - const newName = prompt("Enter new request name:", req.name); - if(newName && newName.trim()) { - req.name = newName.trim(); - this.saveState(); - this._debouncedSaveSpaces(); - this._renderAll(); - } - }, - - deleteCollection(colId) { - if(confirm("Delete this collection and all its requests? This cannot be undone.")) { - this.collections = this.collections.filter(c => c.id !== colId); - // Always keep at least one collection - if (this.collections.length === 0) { - this.collections = [{ id: 'default', name: 'My Requests', requests: [] }]; - } - // If deleted collection was active, switch to first remaining - const stillExists = this.collections.some(c => c.id === this.state.activeCollectionId); - if (!stillExists) { - this.state.activeCollectionId = this.collections[0].id; - this.state.activeRequestId = null; - } - this.saveState(); - this._debouncedSaveSpaces(); - this._renderAll(); - } - }, - - addRequestToCollection(colId) { - const col = this.collections.find(c => c.id === colId); - if (!col) return; - const reqId = 'req_' + Date.now(); - const newReq = { - id: reqId, - name: 'New Request', - method: 'GET', - url: '', - description: '', - params: [{ id: Date.now().toString() + Math.random(), key: '', value: '', type: 'text', enabled: true }], - headers: [{ id: Date.now().toString() + Math.random(), key: '', value: '', type: 'text', enabled: true }], - auth: { type: 'none' }, - bodyType: 'none', - bodyData: [], - jsonBody: '' - }; - col.requests.push(newReq); - - // Open this new request in a new tab - const reqTabData = { - id: 'tab_' + Date.now() + Math.random().toString(36).substr(2, 9), - name: 'New Request', - method: 'GET', - url: '', - params: JSON.parse(JSON.stringify(newReq.params)), - headers: JSON.parse(JSON.stringify(newReq.headers)), - auth: { type: 'none' }, - bodyType: 'none', - bodyData: [], - jsonBody: '', - response: null, - bulk: { strategy: 'consecutive', running: false, total: 0, completed: 0, success: 0, error: 0, concurrency: 1, results: [] }, - activeTab: 'params', - responseTab: 'response', - activeRequestId: reqId, - activeCollectionId: colId, - isPreview: false - }; - this.tabs.push(reqTabData); - this.activeTabIndex = this.tabs.length - 1; - - this.saveState(); - this._debouncedSaveSpaces(); - this._renderAll(); - this.toast("Added new request to collection"); - - }, - - updateActiveRequestName(name) { - const activeSpace = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - const col = activeSpace ? activeSpace.collections.find(c => c.id === this.state.activeCollectionId) : null; - const activeReq = col ? col.requests.find(r => r.id === this.state.activeRequestId) : null; - if (activeReq) { - activeReq.name = name.trim() || 'Untitled Request'; - this.saveState(); - this._debouncedSaveSpaces(); - this._renderAll(); - } - }, - - updateActiveRequestDescription(desc) { - const activeSpace = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - const col = activeSpace ? activeSpace.collections.find(c => c.id === this.state.activeCollectionId) : null; - const activeReq = col ? col.requests.find(r => r.id === this.state.activeRequestId) : null; - if (activeReq) { - activeReq.description = desc; - this.saveState(); - this._debouncedSaveSpaces(); - } - }, - - downloadHistory() { - if (!this.state.bulk.results.length) return; - - const csvContent = "data:text/csv;charset=utf-8," - + "Index,Status,Latency (ms),Snippet\n" - + this.state.bulk.results.map(r => `${r.index},${r.status},${r.latency},"${(r.data || '').replace(/"/g, '""').replace(/\n/g, ' ')}"`).join("\n"); - - const encodedUri = encodeURI(csvContent); - const link = document.createElement("a"); - link.setAttribute("href", encodedUri); - link.setAttribute("download", `bulk_results_${new Date().toISOString()}.csv`); - document.body.appendChild(link); - link.click(); - document.body.removeChild(link); - }, - - // Get the input filename for a given bulk index - getInputFilename(index, fileIndex = index, listIndex = index) { - // Build list of active params that could provide a name - const activeParams = [ - ...this.state.params.filter(p => p.enabled && p.key && p.key.trim()), - ...(this.state.bodyType === 'form-data' ? this.state.bodyData.filter(p => p.enabled && p.key && p.key.trim()) : []) - ]; - - let folderName = null; - // Priority 1: Folder type (usually high-intent for naming) - const folderParam = activeParams.find(p => p.type === 'folder'); - if (folderParam) { - const files = this.fileStore.get(folderParam.id); - if (files && files.length > 0) { - const file = files[fileIndex % files.length]; - folderName = file.webkitRelativePath || file.name; - } - } - - let listName = null; - // Priority 2: List in Body (user's specific request context) - if (this.state.bodyType === 'form-data') { - const bodyList = this.state.bodyData.find(p => p.type === 'list' && p.enabled && p.key && p.key.trim()); - if (bodyList) { - const arr = bodyList.value.split(/[\n,]+/).map(s => s.trim()).filter(s => s); - if (arr.length > 0) listName = arr[listIndex % arr.length]; - } - } - - // Priority 3: Any other list - if (!listName) { - const listParam = activeParams.find(p => p.type === 'list'); - if (listParam) { - const val = listParam.value || ''; - const arr = val.split(/[\n,]+/).map(s => s.trim()).filter(s => s); - if (arr.length > 0) listName = arr[listIndex % arr.length]; - } - } - - if (folderName && listName) { - // Strip extension from folderName, add listName, re-add extension - let base = folderName; - let ext = ''; - const lastDot = folderName.lastIndexOf('.'); - if (lastDot !== -1 && lastDot > 0 && folderName.length - lastDot <= 6) { - base = folderName.substring(0, lastDot); - ext = folderName.substring(lastDot); - } - // Replace any invalid characters in listName just in case, though usually fine - const safeListName = listName.replace(/[\/\\]/g, '_'); - return `${base}_${safeListName}${ext}`; - } else if (folderName) { - return folderName; - } else if (listName) { - return listName; - } - - return `result_${index + 1}`; - }, - - // Get the final filename with appropriate extension if missing - getFinalFilename(result) { - let name = result.inputFilename || `result_${result.index}`; - let originalExt = ''; - - // Extract existing extension if present - const lastDot = name.lastIndexOf('.'); - if (lastDot > 0 && (name.length - lastDot) <= 6) { - originalExt = name.substring(lastDot); - name = name.substring(0, lastDot); - } - - // Map common content types - const ct = (result.contentType || '').toLowerCase(); - if (ct.includes('image/png')) return name + '.png'; - if (ct.includes('image/jpeg') || ct.includes('image/jpg')) return name + '.jpg'; - if (ct.includes('image/gif')) return name + '.gif'; - if (ct.includes('image/webp')) return name + '.webp'; - if (ct.includes('image/svg')) return name + '.svg'; - if (ct.includes('application/pdf')) return name + '.pdf'; - if (ct.includes('application/json')) return name + '.json'; - if (ct.includes('application/xml') || ct.includes('text/xml')) return name + '.xml'; - if (ct.includes('text/html')) return name + '.html'; - if (ct.includes('text/csv')) return name + '.csv'; - if (ct.includes('text/css')) return name + '.css'; - if (ct.includes('text/plain')) return name + '.txt'; - if (ct.includes('application/zip')) return name + '.zip'; - - // Fallback for other binary types: try to extract subtype - if (result.binaryData && ct.includes('/')) { - const subtype = ct.split('/')[1].split(';')[0]; // handle "type/subtype;charset=..." - if (subtype && subtype.length <= 4 && /^[a-z0-9]+$/.test(subtype)) { - return name + '.' + subtype; - } - } - - // Content sniffing for JSON if content type is missing or incorrect - if (!result.binaryData && result.fullContent) { - const trimmed = result.fullContent.trim(); - if ((trimmed.startsWith('{') && trimmed.endsWith('}')) || (trimmed.startsWith('[') && trimmed.endsWith(']'))) { - try { - JSON.parse(trimmed); // Quick validation - return name + '.json'; - } catch(e) {} - } - } - - // If we still don't know the type, fallback to original extension if it existed - if (originalExt) return name + originalExt; - - // Otherwise default based on data format - return result.binaryData ? name + '.bin' : name + '.txt'; - }, - - async saveAsFolder() { - if (!this.state.bulk.results.length) return this.toast('No results to save', 'error'); - - try { - if (!window.showDirectoryPicker) { - return this.toast('Your browser does not support native folder saving. Please use the ZIP button instead.', 'error'); - } - - this.toast('Select a folder to save files...', 'info'); - const dirHandle = await window.showDirectoryPicker({ - mode: 'readwrite' - }); - - let savedCount = 0; - let errors = 0; - const usedNames = new Set(); - - for (const r of this.state.bulk.results) { - try { - let filename = this.getFinalFilename(r); - - let base = filename; - let ext = ''; - const lastDot = filename.lastIndexOf('.'); - if (lastDot !== -1 && lastDot > 0) { - base = filename.substring(0, lastDot); - ext = filename.substring(lastDot); - } - - let counter = 1; - while (usedNames.has(filename)) { - filename = `${base}_${counter}${ext}`; - counter++; - } - usedNames.add(filename); - - // Get the content — prefer blobUrl, fallback to fullContent - let data; - if (r.blobUrl) { - const blob = await fetch(r.blobUrl).then(res => res.blob()); - data = await blob.arrayBuffer(); - } else if (r.fullContent) { - data = r.fullContent; - } else { - continue; // Skip empty results - } - - // Create file and write content - const fileHandle = await dirHandle.getFileHandle(filename, { create: true }); - const writable = await fileHandle.createWritable(); - await writable.write(data); - await writable.close(); - - savedCount++; - } catch (e) { - console.error('Error saving file', r.index, e); - errors++; - } - } - - if (errors > 0) { - this.toast(`Saved ${savedCount} files. Failed to save ${errors} files.`, 'warning'); - } else { - this.toast(`Successfully saved ${savedCount} files to the selected folder.`); - } - - } catch (e) { - console.error(e); - if (e.name === 'AbortError') { - this.toast('Folder selection cancelled.', 'info'); - } else { - this.toast('Failed to save to folder: ' + e.message, 'error'); - } - } - }, - - async saveAllResults() { - if (!this.state.bulk.results.length) return this.toast('No results to save', 'error'); - if (typeof JSZip === 'undefined') return this.toast('JSZip library not loaded. Please refresh.', 'error'); - - this.toast('Building ZIP file...', 'info'); - - const zip = new JSZip(); - let savedCount = 0; - const usedNames = new Set(); - - for (const result of this.state.bulk.results) { - try { - // Use the tracked input filename + auto extension - let filename = this.getFinalFilename(result); - - let base = filename; - let ext = ''; - const lastDot = filename.lastIndexOf('.'); - if (lastDot !== -1 && lastDot > 0) { - base = filename.substring(0, lastDot); - ext = filename.substring(lastDot); - } - - let counter = 1; - while (usedNames.has(filename)) { - filename = `${base}_${counter}${ext}`; - counter++; - } - usedNames.add(filename); - - // Get the content — prefer blobUrl (memory efficient), fallback to fullContent - let data; - if (result.blobUrl) { - const blob = await fetch(result.blobUrl).then(r => r.blob()); - data = await blob.arrayBuffer(); - zip.file(filename, data, { binary: true }); - } else if (result.fullContent) { - data = result.fullContent; - zip.file(filename, data, { binary: false }); - } else { - continue; // Skip empty results - } - savedCount++; - } catch (e) { - console.error('Error adding result to ZIP', result.index, e); - } - } - - if (savedCount === 0) return this.toast('No valid results to save', 'error'); - - // Generate and download ZIP - try { - this.toast('Generating ZIP, please wait...', 'info'); - const blob = await zip.generateAsync({ type: 'blob' }); - const url = URL.createObjectURL(blob); - - const modal = document.createElement('div'); - modal.className = 'premium-modal-overlay'; - modal.style.zIndex = '9999'; - modal.innerHTML = ` -
- -

ZIP Ready!

-

Successfully bundled ${savedCount} files.

- - Click to Download ZIP - - -
- `; - document.body.appendChild(modal); - - // Note: intentionally not revoking the URL immediately so the manual click works! - - } catch (e) { - this.toast('Error generating ZIP: ' + e.message, 'error'); - } - }, - - // --- Rendering --- - - // Debounced render — coalesces rapid successive calls (e.g., keystrokes) - // into a single animation frame to prevent jank. - scheduleRender() { - if (this._renderScheduled) return; - this._renderScheduled = true; - requestAnimationFrame(() => { - this._renderScheduled = false; - this._renderAll(); - }); - }, - - // ── Targeted update helpers ───────────────────────────────────────────── - - _onMethodChange(val) { this.state.method = val; this.saveState(); this._updateActionBtns(); this._updateBulkControls(); }, - _onUrlInput(val) { this.state.url = val; this.saveState(); }, - - _updateRootClasses() { - const root = document.getElementById('app-root'); - if (!root) return; - root.className = 'workspace'; - if (this.state.bulk.results.length > 0 || this.state.bulk.running) root.classList.add('bulk-active'); - if (this.state.gridMaximized || !this.state.activeSpaceId) root.classList.add('grid-maximized'); - if (this.state.activeSpaceId) { - const sp = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - root.classList.add(`theme-${sp && sp.theme ? sp.theme : 'violet'}`); - } - }, - - _updateWorkspaceSelect() { - const sel = this.dom.wsSelect; - if (!sel) return; - sel.innerHTML = `` + - this.state.spaces.map(s => ``).join(''); - }, - - _updateSidebarVisibility() { - const hasSpace = !!this.state.activeSpaceId; - const ch = this.dom.collectionsHeader; - const sw = this.dom.searchWrap; - if (ch) ch.style.display = hasSpace ? 'flex' : 'none'; - if (sw) sw.style.display = hasSpace ? '' : 'none'; - }, - - _updateNotifBanner() { - const b = this.dom.notifBanner; - if (!b) return; - const sp = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - const n = sp && sp.notifications && sp.notifications.length; - if (n) { - b.style.display = ''; - b.className = 'notifications-banner'; - b.innerHTML = `${n} pending share request${n > 1 ? 's' : ''}`; - b.onclick = () => this.openNotificationsModal(); - } else { - b.style.display = 'none'; - } - }, - - _updateWorkspaceBadge() { - const badge = this.dom.wsBadge; - const ts = this.dom.themeSelect; - const sp = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - if (sp && badge) { - badge.innerHTML = `
${this.escapeHTML(sp.name)}
`; - } - if (ts && sp) ts.value = sp.theme || 'violet'; - }, - - _updateUrlBar() { - const ms = this.dom.methodSelect; - const ui = this.dom.urlInput; - if (ms && document.activeElement !== ms) ms.value = this.state.method || 'POST'; - if (ui && document.activeElement !== ui) ui.value = this.state.url || ''; - if (ms) { - const mc = {GET:'var(--m-get)',POST:'var(--m-post)',PUT:'var(--m-put)',DELETE:'var(--m-delete)',PATCH:'var(--m-patch)'}; - ms.style.color = mc[this.state.method] || 'var(--text-1)'; - } - }, - - _updateActionBtns() { - const c = this.dom.actionBtns; - if (!c) return; - const bulk = this.state.bulk; - const isBulkStart = this.checkBulkStart(); - if (bulk.running) { - c.innerHTML = ``; - } else if (bulk.paused) { - c.innerHTML = ``; - } else { - c.innerHTML = ``; - } - }, - - _updateReqTabStrip() { - const strip = this.dom.reqTabStrip; - if (!strip) return; - strip.innerHTML = this.tabs.map((tab, i) => { - const isActive = i === this.activeTabIndex; - const tabName = tab.name || (tab.url ? tab.url.split('/').pop() || 'Request' : 'Untitled'); - const dn = tabName.length > 20 ? tabName.substring(0,20)+'…' : tabName; - const m = tab.method || 'GET'; - const mc = {GET:'var(--m-get)',POST:'var(--m-post)',PUT:'var(--m-put)',DELETE:'var(--m-delete)',PATCH:'var(--m-patch)'}[m]||'var(--text-3)'; - return `
${m}${this.escapeHTML(dn)}
`; - }).join('') + ``; - }, - - _updateRequestMeta() { - const meta = this.dom.requestMeta; - if (!meta) return; - const sp = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - const col = sp ? sp.collections.find(c => c.id === this.state.activeCollectionId) : null; - const req = col ? col.requests.find(r => r.id === this.state.activeRequestId) : null; - meta.style.display = req ? '' : 'none'; - if (req) { - const ni = this.dom.reqNameInput, di = this.dom.reqDescInput; - if (ni && document.activeElement !== ni) ni.value = req.name || ''; - if (di && document.activeElement !== di) di.value = req.description || ''; - } - }, - - _updateBulkControls() { - const c = this.dom.bulkControls; - if (!c) return; - const isBulkStart = this.checkBulkStart(); - const is = 'background:var(--bg-input);border:1px solid var(--border-2);border-radius:var(--r-xs);color:var(--text-1);padding:3px 6px;font-size:11px;text-align:center;font-family:var(--font-ui);'; - c.innerHTML = ` - ${isBulkStart ? `
Strategy
` : ''} -
Repeat
-
Delay ms
-
Workers
- `; - }, - - _switchContentTab(tabName) { - this.state.activeTab = tabName; - ['params','headers','body','auth'].forEach(t => { - const el = document.getElementById('ctab-'+t); - if (el) el.classList.toggle('active', t === tabName); - }); - const ca = this.dom.contentArea; - if (!ca) return; - if (tabName === 'params') ca.innerHTML = this.renderTable(this.state.params, 'params'); - else if (tabName === 'headers') ca.innerHTML = this.renderTable(this.state.headers, 'headers'); - else if (tabName === 'body') ca.innerHTML = this.renderBodyTab(); - else if (tabName === 'auth') ca.innerHTML = this.renderAuthTab(); - this.saveState(); - }, - - _switchBottomTab(tabName) { - this.state.responseTab = tabName; - const isResp = tabName === 'response'; - const pr = this.dom.ptabResponse, prs = this.dom.ptabResults; - if (pr) { pr.style.color = isResp ? 'var(--text-1)' : 'var(--text-3)'; pr.style.borderBottomColor = isResp ? 'var(--ph)' : 'transparent'; } - if (prs) { prs.style.color = !isResp ? 'var(--text-1)' : 'var(--text-3)'; prs.style.borderBottomColor = !isResp ? 'var(--ph)' : 'transparent'; } - const rv = this.dom.responseView, rsv = this.dom.resultsView; - if (rv) rv.style.display = isResp ? 'flex' : 'none'; - if (rsv) rsv.style.display = !isResp ? 'flex' : 'none'; - if (!isResp) this._updateBottomRightActions(); - this.saveState(); - }, - - _updateBottomStats() { - const bulk = this.state.bulk; - const has = bulk.results.length > 0; - const b = this.dom.resultBadge, sep = this.dom.statSep; - const sc = this.dom.statCompleted, ss = this.dom.statSuccess, se = this.dom.statError; - if (b) { b.textContent = bulk.results.length; b.style.display = has ? '' : 'none'; } - if (sep) sep.style.display = has ? '' : 'none'; - if (sc) { sc.style.display = has ? '' : 'none'; sc.textContent = `${bulk.completed}/${bulk.total}`; } - if (ss) { ss.style.display = has ? '' : 'none'; ss.textContent = `${bulk.success} ✓`; } - if (se) { se.style.display = has ? '' : 'none'; se.textContent = `${bulk.error} ✗`; } - }, - - _updateBottomRightActions() { - const c = this.dom.bottomRightActions; - if (!c) return; - const bulk = this.state.bulk; - const isResults = (this.state.responseTab || 'response') === 'results'; - if (isResults && bulk.results.length > 0) { - const fp = this.state.outputFolderPath || 'None selected'; - c.style.display = 'flex'; - c.innerHTML = `
${fp}
`; - } else { - c.style.display = 'none'; - } - }, - - _updateResponseView() { - const rv = this.dom.responseView; - if (!rv) return; - const resp = this.state.response; - if (!resp) { - rv.innerHTML = `
Ready to send request. Click SEND or RUN BATCH.
`; - } else if (resp.status === 'Sending...') { - rv.innerHTML = `
Sending request...
`; - } else if (resp.error) { - rv.innerHTML = `
Error: ${resp.error}
`; - } else { - let content = resp.content; - try { if (content && !resp.blobUrl && content.trim().startsWith('{')) content = JSON.stringify(JSON.parse(content), null, 2); } catch(e){} - rv.innerHTML = `
${resp.status_code}${resp.latency ? resp.latency+'ms' : ''}${resp.content_type||''}
${resp.blobUrl ? `
Response
` : `
${this.escapeHTML(content)}
`}
`; - } - }, - - _updateDashboard() { - const sg = this.dom.spacesGrid; - if (!sg) return; - sg.innerHTML = this.state.spaces.map(s => { - const count = s.collections ? s.collections.length : 0; - const nc = s.notifications ? s.notifications.length : 0; - const theme = s.theme || 'violet'; - return `
${nc > 0 ? `${nc}` : ''}

${this.escapeHTML(s.name)}

${count} Collections
${this.state.spaces.length > 1 ? `` : ''}
`; - }).join('') + `

Create New Space

Add a clean workspace
`; - }, - - // ── THE NEW renderMain: 100% surgical, zero full-panel innerHTML ────────── - renderMain() { - if (!this.state.activeSpaceId) { - // Show dashboard view, hide workspace view - if (this.dom.dashboardView) this.dom.dashboardView.style.display = 'flex'; - if (this.dom.workspaceView) this.dom.workspaceView.style.display = 'none'; - this._updateDashboard(); - return; - } - - // Ensure workspace view is visible - if (this.dom.dashboardView) this.dom.dashboardView.style.display = 'none'; - if (this.dom.workspaceView) this.dom.workspaceView.style.display = 'flex'; - - // Surgical updates — each touches only its own DOM node - this._updateWorkspaceBadge(); - this._updateUrlBar(); - this._updateReqTabStrip(); - this._updateRequestMeta(); - this._updateBulkControls(); - this._updateActionBtns(); - - // Content tab (only the small content-area div gets innerHTML'd) - this._switchContentTab(this.state.activeTab); - - // Bottom panel - switch tab view + update stats + actions - this._switchBottomTab(this.state.responseTab || 'response'); - this._updateBottomStats(); - this._updateResponseView(); - - // Bottom panel height - if (this.dom.bottomPanel) this.dom.bottomPanel.style.height = (this.state.resultsPanelHeight || 300) + 'px'; - - // Results grid: idempotent repopulate - this._repopulateResultsGrid(); - }, - - _repopulateResultsGrid() { - const grid1 = this.dom.resultsGrid || document.getElementById('main-results-grid'); - const grid2 = document.querySelector('.fullscreen-results-grid'); - if (grid1) grid1.innerHTML = ''; - if (grid2) grid2.innerHTML = ''; - if (this.state.bulk.results && this.state.bulk.results.length > 0) { - this.state.bulk.results.forEach(r => this.appendResultCardToDOM(r)); - } else if (grid1) { - grid1.innerHTML = `

Ready for bulk testing
`; - } - }, - - _renderAll() { - this._updateRootClasses(); - this._updateWorkspaceSelect(); - this._updateSidebarVisibility(); - this._updateNotifBanner(); - this.renderSidebar(); - this.renderMain(); - }, - - renderProgress() { - // Optimized partial render for progress bar - const bar = document.getElementById('progress-bar-fill'); - const text = document.getElementById('progress-text'); - if (bar && text) { - const pct = (this.state.bulk.completed / this.state.bulk.total) * 100; - bar.style.width = `${pct}%`; - text.innerText = `${this.state.bulk.completed} / ${this.state.bulk.total}`; - } - }, - - getCollectionsHTML() { - const query = (this.state.searchQuery || '').toLowerCase().trim(); - let collectionsHTML = ''; - - this.collections.forEach(col => { - const isColActive = this.state.activeCollectionId === col.id; - - // Filter requests - const filteredRequests = col.requests.filter(r => { - if (!query) return true; - return ( - (r.name || '').toLowerCase().includes(query) || - (r.url || '').toLowerCase().includes(query) || - (r.description || '').toLowerCase().includes(query) - ); - }); - - // Decide if the collection itself matches - const colMatches = (col.name || '').toLowerCase().includes(query); - - // If neither collection matches nor has matching requests, skip rendering it - if (query && !colMatches && filteredRequests.length === 0) { - return; - } - - // If there's a query and we have matches, auto-expand the collection - const isExpanded = query ? true : isColActive; - - const reqsHTML = (query && colMatches ? col.requests : filteredRequests).map(r => ` -
- ${r.method} -
-
- ${this.escapeHTML(r.name || '')} -
-
- ${this.escapeHTML(r.url || 'No URL')} -
-
- - -
- `).join(''); - - collectionsHTML += ` -
-
- - ${this.escapeHTML(col.name)} - - - - - - -
- ${isExpanded ? `
${reqsHTML || ` -
-
Empty Collection
-
- - -
-
- `}
` : ''} -
- `; - }); - - return collectionsHTML; - }, - - filterSidebarCollections(query) { - this.state.searchQuery = query; - const listEl = this.dom.collectionsList || document.getElementById('collections-list'); - if (listEl) { - listEl.innerHTML = this.getCollectionsHTML(); - } - - // Also update clear button visibility - const clearBtn = document.getElementById('search-clear-btn'); - if (clearBtn) { - clearBtn.style.display = query ? 'block' : 'none'; - } - }, - - renderSidebar() { - // Only update the collections list — never replace the whole sidebar - const cl = this.dom.collectionsList; - if (cl) cl.innerHTML = this.getCollectionsHTML() || ` -
- - No collections in this workspace.
-
- - -
-
`; - }, - - - // --- Helpers --- - - renderTable(items, section) { - if (!Array.isArray(items)) items = []; - return ` - - - - ${items.map(item => ` - - - - - - - `).join('')} - -
KeyValue
- - ${this.renderValueInput(item, section)} -
- - `; - }, - - renderValueInput(item, section) { - if (item.type === 'file' || item.type === 'folder') { - const files = this.fileStore.get(item.id); - const label = files ? (item.type === 'folder' ? `${files.length} Files Selected` : `${files.length} Files`) : 'Select...'; - return ` -
- - -
- `; - } - if (item.type === 'auto_width' || item.type === 'auto_height') { - return ``; - } - return ``; - }, - - renderBodyTab() { - return ` -
-
- - - -
- - ${this.state.bodyType === 'form-data' ? this.renderTable(this.state.bodyData, 'body') : ''} - ${this.state.bodyType === 'json' ? `` : ''} -
- `; - }, - - renderAuthTab() { - const auth = this.state.auth; - const inStyle = 'width:100%;padding:10px 12px;background:var(--bg-input);border:1px solid var(--border-2);border-radius:var(--r-md);color:var(--text-1);font-family:var(--font-mono);font-size:12px;transition:border-color 0.15s,box-shadow 0.15s;'; - const labelStyle = 'display:block;margin-bottom:6px;font-size:9.5px;font-weight:700;text-transform:uppercase;letter-spacing:0.07em;color:var(--text-3);'; - return ` -
- - - - ${auth.type === 'bearer' ? ` -
- - -
- ` : ''} - - ${auth.type === 'basic' ? ` -
-
- - -
-
- - -
-
- ` : ''} - - ${auth.type === 'apikey' ? ` -
-
- - -
-
- - -
-
- ` : ''} -
- `; - }, - - handleFileSelect(input, section, id) { - if (input.files.length > 0) { - // Convert FileList to Array and sort by path to ensure strict processing sequence (natural sorting) - let filesArr = Array.from(input.files); - filesArr.sort((a, b) => { - const pA = a.webkitRelativePath || a.name; - const pB = b.webkitRelativePath || b.name; - return pA.localeCompare(pB, undefined, { numeric: true, sensitivity: 'base' }); - }); - this.fileStore.set(id, filesArr); - this._switchContentTab(this.state.activeTab); - } - }, - - checkBulkStart() { - const hasKeyedFolder = this.state.params.some(p => p.type === 'folder' && p.enabled && p.key && p.key.trim()) - || (this.state.bodyType === 'form-data' && this.state.bodyData.some(p => p.type === 'folder' && p.enabled && p.key && p.key.trim())); - - const hasKeyedList = this.state.params.some(p => p.type === 'list' && p.enabled && p.key && p.key.trim()) - || (this.state.bodyType === 'form-data' && this.state.bodyData.some(p => p.type === 'list' && p.enabled && p.key && p.key.trim())) - || this.state.headers.some(h => h.type === 'list' && h.enabled && h.key && h.key.trim()); - - return hasKeyedFolder || hasKeyedList; - }, - - getStatusColor(code) { - if (code >= 200 && code < 300) return 'var(--success)'; - if (code >= 300 && code < 400) return 'var(--warning)'; - if (code >= 400 || code === 'ERR') return 'var(--danger)'; - return 'var(--text-muted)'; - }, - - toast(msg, type = 'info') { - const icons = { info: 'fa-circle-info', success: 'fa-circle-check', error: 'fa-circle-xmark', warning: 'fa-triangle-exclamation' }; - const iconColors = { info: '#5ba0f5', success: '#0fcea0', error: '#ff4569', warning: '#f5a623' }; - const icon = icons[type] || icons.info; - const color = iconColors[type] || iconColors.info; - const t = document.createElement('div'); - t.className = `ph-toast-${type}`; - t.innerHTML = `${this.escapeHTML(msg)}`; - Object.assign(t.style, { - display: 'flex', - alignItems: 'center', - gap: '10px', - padding: '12px 16px', - borderRadius: '10px', - marginTop: '6px', - fontSize: '13px', - fontFamily: 'var(--font-ui)', - fontWeight: '500', - animation: 'toastSlideIn 0.32s cubic-bezier(0.34,1.56,0.64,1) both', - }); - this.dom.toast.appendChild(t); - const removeDelay = type === 'error' ? 4500 : 3000; - setTimeout(() => { - t.style.animation = 'toastFadeOut 0.2s ease forwards'; - setTimeout(() => t.remove(), 200); - }, removeDelay); - }, - - escapeHTML(str) { - if (!str) return ''; - if (typeof str !== 'string') return String(str); - return str.replace(/&/g, '&') - .replace(//g, '>') - .replace(/"/g, '"') - .replace(/'/g, '''); - }, - - base64ToUint8Array(base64Data) { - if (!base64Data) return new Uint8Array(0); - try { - const byteCharacters = atob(base64Data); - const data = new Uint8Array(byteCharacters.length); - for (let i = 0; i < byteCharacters.length; i++) { - data[i] = byteCharacters.charCodeAt(i); - } - return data; - } catch (e) { - console.error("Base64 to Uint8Array error", e); - return new Uint8Array(0); - } - }, - - async base64ToBlobUrlAsync(base64Data, contentType) { - if (!base64Data) return ''; - try { - const res = await fetch(`data:${contentType || 'application/octet-stream'};base64,${base64Data}`); - const blob = await res.blob(); - return URL.createObjectURL(blob); - } catch (e) { - console.error("Async Base64 decode error", e); - return ''; - } - }, - - base64ToBlobUrl(base64Data, contentType) { - if (!base64Data) return ''; - try { - const byteCharacters = atob(base64Data); - const byteArrays = []; - const sliceSize = 512; - for (let offset = 0; offset < byteCharacters.length; offset += sliceSize) { - const slice = byteCharacters.slice(offset, offset + sliceSize); - const byteNumbers = new Array(slice.length); - for (let i = 0; i < slice.length; i++) { - byteNumbers[i] = slice.charCodeAt(i); - } - const byteArray = new Uint8Array(byteNumbers); - byteArrays.push(byteArray); - } - const blob = new Blob(byteArrays, {type: contentType}); - return URL.createObjectURL(blob); - } catch (e) { - console.error("Base64 decode error", e); - return ''; - } - }, - - bindEvents() { - // Most events are inline (onclick, onchange) for simplicity in this structure - }, - - // Preview a result - previewResult(index) { - const result = this.state.bulk.results.find(r => r.index === index); - if (!result) return; - - const isImage = (result.contentType || '').toLowerCase().includes('image') && (result.blobUrl || result.binaryData); - const finalFilename = this.getFinalFilename(result); - - let contentHTML = ''; - if (isImage) { - try { - contentHTML = `${finalFilename}`; - } catch (e) { - contentHTML = ``; - } - } else { - let prettyContent = result.fullContent || ''; - try { - if (prettyContent.trim().startsWith('{')) { - prettyContent = JSON.stringify(JSON.parse(prettyContent), null, 2); - } - } catch(e) {} - contentHTML = ``; - } - - const modal = document.createElement('div'); - modal.className = 'premium-modal-overlay'; - - modal.innerHTML = ` -
-
-
- -
- ${finalFilename} - Result #${result.index} -
-
-
- ${result.status} - ${result.latency}ms - -
-
-
- ${contentHTML} -
- -
- `; - - document.body.appendChild(modal); - modal.onclick = () => modal.remove(); - }, - - // For manual clicking from history - loadHistoryItem(id) { - const item = this.state.history.find(h => h.id === id); - if (item) { - this.state.method = item.method; - this.state.url = item.url; - this.saveState(); - this._renderAll(); - } - } -}; - - -document.addEventListener('DOMContentLoaded', () => App.init()); - diff --git a/web/bulk-api-tester/static/js/app.js.bak b/web/bulk-api-tester/static/js/app.js.bak deleted file mode 100644 index 38da43e..0000000 --- a/web/bulk-api-tester/static/js/app.js.bak +++ /dev/null @@ -1,2959 +0,0 @@ -/** - * Phoenix App - Advanced Bulk API Tester - * Version: 2.0 (Agentic Edition) - */ - -const App = { - _stateData: { - spaces: [], - activeSpaceId: null, - activeCollectionId: 'default', - - outputFolderPath: '', - gridMaximized: false, - resultsPanelHeight: 300, - sidebarWidth: 270, - searchQuery: '' - }, - - tabs: [], - activeTabIndex: 0, - - get state() { - if (!this._proxyState) { - const props = ['name', 'method', 'url', 'params', 'headers', 'auth', 'bodyType', 'bodyData', 'jsonBody', 'response', 'bulk', 'activeTab', 'responseTab', 'activeRequestId', 'isPreview', 'activeCollectionId']; - this._proxyState = new Proxy(this._stateData, { - get(target, prop) { - if (props.includes(prop)) { - if (App.tabs && App.tabs[App.activeTabIndex]) { - return App.tabs[App.activeTabIndex][prop]; - } - } - return target[prop]; - }, - set(target, prop, value) { - if (props.includes(prop)) { - if (App.tabs && App.tabs[App.activeTabIndex]) { - App.tabs[App.activeTabIndex][prop] = value; - if (prop !== 'activeTab' && prop !== 'responseTab' && prop !== 'activeRequestId') { - App.tabs[App.activeTabIndex].isPreview = false; - } - - // Auto-save to localStorage only (no server call on every keypress) - - return true; - } - } - target[prop] = value; - return true; - } - }); - } - return this._proxyState; - }, - - debouncedSaveToCollection() { - if (this._autoSaveTimeout) clearTimeout(this._autoSaveTimeout); - this._autoSaveTimeout = setTimeout(() => { - this.saveToCollection(); - }, 500); - }, - - createNewTab(reqData, isPreview = false) { - return { - id: 'tab_' + Date.now() + Math.random().toString(36).substr(2, 9), - name: reqData ? reqData.name : 'Untitled Request', - method: reqData ? reqData.method : 'POST', - url: reqData ? reqData.url : '', - params: reqData ? JSON.parse(JSON.stringify(reqData.params || [])) : [], - headers: reqData ? JSON.parse(JSON.stringify(reqData.headers || [])) : [], - auth: reqData ? JSON.parse(JSON.stringify(reqData.auth || {type:'none'})) : {type:'none'}, - bodyType: reqData ? reqData.bodyType : 'none', - bodyData: reqData ? JSON.parse(JSON.stringify(reqData.bodyData || [])) : [], - jsonBody: reqData ? reqData.jsonBody : '', - response: null, - bulk: reqData && reqData.bulk ? JSON.parse(JSON.stringify(reqData.bulk)) : { - strategy: 'consecutive', - running: false, - total: 0, - completed: 0, - success: 0, - error: 0, - concurrency: 1, - delay: 0, - repetitions: 10, - results: [] - }, - activeTab: 'params', - responseTab: 'response', - activeRequestId: reqData ? reqData.id : null, - activeCollectionId: reqData ? reqData.activeCollectionId : 'default', - isPreview: isPreview - }; - }, - - - fileStore: new Map(), // id -> FileList - - dom: {}, - - async init() { - this.loadState(); - this.cacheDOM(); - this.bindEvents(); - - // Ensure active tab has at least one param and header row - if (!this.state.params || this.state.params.length === 0) this.addParam('params'); - if (!this.state.headers || this.state.headers.length === 0) this.addParam('headers'); - - // Load spaces from the server to keep them synced - await this.loadSpacesFromServer(); - - // Apply saved sidebar width - const sidebarEl = document.getElementById('sidebar'); - if (sidebarEl && this._stateData.sidebarWidth) { - sidebarEl.style.width = `${this._stateData.sidebarWidth}px`; - } - - // Attach event listener for horizontal sidebar dragging - const handle = document.getElementById('sidebar-resize-handle'); - if (handle) { - handle.addEventListener('mousedown', (e) => this.startSidebarResize(e)); - } - - this.render(); - - // Remove loader - const loader = document.getElementById('loading-overlay'); - if (loader) loader.remove(); - document.getElementById('app-root').style.visibility = 'visible'; - }, - - // --- Tab Management --- - - openNewTab() { - const newTab = this.createNewTab(); - this.tabs.push(newTab); - this.activeTabIndex = this.tabs.length - 1; - if (!this.state.params || this.state.params.length === 0) this.addParam('params'); - if (!this.state.headers || this.state.headers.length === 0) this.addParam('headers'); - this.saveState(); - this.render(); - }, - - switchTab(index) { - if (index < 0 || index >= this.tabs.length) return; - this.activeTabIndex = index; - this.saveState(); - this.render(); - }, - - closeTab(index) { - if (this.tabs.length <= 1) { - // Can't close last tab; just reset it - this.tabs[0] = this.createNewTab(); - this.activeTabIndex = 0; - this.saveState(); - this.render(); - return; - } - this.tabs.splice(index, 1); - if (this.activeTabIndex >= this.tabs.length) { - this.activeTabIndex = this.tabs.length - 1; - } - this.saveState(); - this.render(); - }, - - cacheDOM() { - this.dom = { - mainPanel: document.getElementById('main-panel'), - sidebar: document.getElementById('sidebar'), - toast: document.getElementById('toast-container') - }; - - if (!this.dom.sidebar || !this.dom.mainPanel) { - console.error('Critical: DOM elements not found', this.dom); - alert('Critical Error: Application DOM structure is missing. Please refresh.'); - } - }, - - // --- State Management --- - - loadState() { - try { - const raw = localStorage.getItem('phoenix-state-v2'); - if (raw) { - const data = JSON.parse(raw); - // Restore _stateData (global state) - if (data.spaces !== undefined) this._stateData.spaces = data.spaces; - if (data.activeSpaceId !== undefined) this._stateData.activeSpaceId = data.activeSpaceId; - if (data.activeCollectionId !== undefined) this._stateData.activeCollectionId = data.activeCollectionId; - if (data.outputFolderPath !== undefined) this._stateData.outputFolderPath = data.outputFolderPath; - if (data.gridMaximized !== undefined) this._stateData.gridMaximized = data.gridMaximized; - if (data.resultsPanelHeight !== undefined) this._stateData.resultsPanelHeight = data.resultsPanelHeight; - if (data.sidebarWidth !== undefined) this._stateData.sidebarWidth = data.sidebarWidth; - if (data.searchQuery !== undefined) this._stateData.searchQuery = data.searchQuery; - - // Restore tabs - if (data.tabs && data.tabs.length > 0) { - this.tabs = data.tabs.map(t => ({ - ...t, - bulk: { ...(t.bulk || {}), running: false, results: [] }, - response: null - })); - this.activeTabIndex = Math.min(data.activeTabIndex || 0, this.tabs.length - 1); - } else { - // No saved tabs, create a blank one - this.tabs = [this.createNewTab()]; - this.activeTabIndex = 0; - } - } else { - // Fresh start - this.tabs = [this.createNewTab()]; - this.activeTabIndex = 0; - } - } catch (e) { - console.warn('Failed to load state', e); - this.tabs = [this.createNewTab()]; - this.activeTabIndex = 0; - } - }, - - saveState() { - // Skip expensive localStorage serialization while bulk is actively running. - if (this.state.bulk && this.state.bulk.running) return; - if (this._saveStateTimeout) clearTimeout(this._saveStateTimeout); - this._saveStateTimeout = setTimeout(() => { - try { - const serializedTabs = this.tabs.map(t => ({ - ...t, - bulk: { ...t.bulk, running: false, results: [] }, - response: null - })); - const persistentState = { - spaces: this._stateData.spaces, - activeSpaceId: this._stateData.activeSpaceId, - activeCollectionId: this._stateData.activeCollectionId, - outputFolderPath: this._stateData.outputFolderPath, - gridMaximized: this._stateData.gridMaximized, - resultsPanelHeight: this._stateData.resultsPanelHeight, - sidebarWidth: this._stateData.sidebarWidth, - searchQuery: this._stateData.searchQuery, - tabs: serializedTabs, - activeTabIndex: this.activeTabIndex - }; - localStorage.setItem('phoenix-state-v2', JSON.stringify(persistentState)); - } catch (e) { - console.warn('Failed to save state', e); - } - }, 300); - }, - - async loadLastRunFromServer() { - // Persistence disabled for performance — results are session-only. - }, - - async saveLastRunToServer() { - // Persistence disabled for performance — results are session-only. - }, - - saveLastRunToServerThrottled() { - if (this._saveThrottleTimeout) return; - this._saveThrottleTimeout = setTimeout(async () => { - this._saveThrottleTimeout = null; - await this.saveLastRunToServer(); - }, 1000); - }, - - get collections() { - if (!this.state.activeSpaceId) return []; - const space = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - return space ? space.collections : []; - }, - - set collections(val) { - if (!this.state.activeSpaceId) return; - const space = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - if (space) { - space.collections = val; - } - }, - - get notifications() { - if (!this.state.activeSpaceId) return []; - const space = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - return space ? (space.notifications || []) : []; - }, - - set notifications(val) { - if (!this.state.activeSpaceId) return; - const space = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - if (space) { - space.notifications = val; - } - }, - - async loadSpacesFromServer() { - try { - const res = await fetch('/api/spaces'); - const data = await res.json(); - if (Array.isArray(data)) { - // Check if server returned empty or only the default empty spaces - const serverIsEmpty = data.length === 0 || ( - data.length === 2 && - data[0].id === 'personal' && data[0].collections.length === 1 && (!data[0].collections[0].requests || data[0].collections[0].requests.length === 0) && - data[1].id === 'team' && data[1].collections.length === 1 && (!data[1].collections[0].requests || data[1].collections[0].requests.length === 0) - ); - - // Check if client had non-empty legacy collections in localStorage - const clientHasLegacyCollections = this.state.collections && ( - this.state.collections.length > 1 || - (this.state.collections[0] && this.state.collections[0].requests && this.state.collections[0].requests.length > 0) - ); - - if (serverIsEmpty && clientHasLegacyCollections) { - console.log('Migrating local client collections to spaces...'); - this.state.spaces = [ - { - id: 'personal', - name: 'Personal Space', - collections: JSON.parse(JSON.stringify(this.state.collections)) - }, - { - id: 'team', - name: 'Team Space', - collections: JSON.parse(JSON.stringify(this.state.collections)) - } - ]; - delete this.state.collections; - await this._debouncedSaveSpaces(); - } else if (data.length === 0 && this.state.spaces && this.state.spaces.length > 0) { - await this._debouncedSaveSpaces(); - } else if (data.length > 0) { - this.state.spaces = data; - } - - // Validate activeSpaceId - if (this.state.activeSpaceId) { - const spaceExists = this.state.spaces.some(s => s.id === this.state.activeSpaceId); - if (!spaceExists) { - this.state.activeSpaceId = null; - this.state.activeCollectionId = 'default'; - this.state.activeRequestId = null; - } - } - } - } catch (e) { - console.error('Failed to load spaces from server:', e); - } - }, - - async saveSpacesToServer() { - try { - await fetch('/api/spaces', { - method: 'POST', - headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify(this.state.spaces) - }); - } catch (e) { - console.error('Failed to sync spaces with server:', e); - } - }, - - openSpace(spaceId) { - this.state.activeSpaceId = spaceId; - this.state.activeCollectionId = 'default'; - this.state.activeRequestId = null; - this.saveState(); - this.render(); - }, - - showSpacesDashboard() { - this.state.activeSpaceId = null; - this.state.activeCollectionId = 'default'; - this.state.activeRequestId = null; - this.saveState(); - this.render(); - }, - - async createSpace() { - const name = prompt("Enter space name:"); - if (name && name.trim()) { - const id = 'space_' + Date.now(); - this.state.spaces.push({ - id: id, - name: name.trim(), - collections: [{ id: 'default', name: 'My Requests', requests: [] }] - }); - this.state.activeSpaceId = id; - this.saveState(); - await this._debouncedSaveSpaces(); - this.render(); - } - }, - - async deleteSpace(spaceId) { - if (this.state.spaces.length <= 1) { - return this.toast("Cannot delete the last remaining space", "error"); - } - if (confirm("Are you sure you want to delete this space? All collections and requests inside it will be permanently lost.")) { - this.state.spaces = this.state.spaces.filter(s => s.id !== spaceId); - if (this.state.activeSpaceId === spaceId) { - this.state.activeSpaceId = null; - this.state.activeCollectionId = 'default'; - this.state.activeRequestId = null; - } - this.saveState(); - await this._debouncedSaveSpaces(); - this.render(); - } - }, - - renameSpace(spaceId) { - const space = this.state.spaces.find(s => s.id === spaceId); - if (!space) return; - const newName = prompt("Enter new workspace name:", space.name); - if (newName && newName.trim()) { - space.name = newName.trim(); - this.saveState(); - this._debouncedSaveSpaces(); - this.render(); - } - }, - - async setSpaceTheme(themeId) { - const activeSpace = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - if (activeSpace) { - activeSpace.theme = themeId; - this.saveState(); - await this._debouncedSaveSpaces(); - this.render(); - this.toast(`Applied ${themeId} theme to ${activeSpace.name}`); - } - }, - - async shareCollection(colId) { - const otherSpaces = this.state.spaces.filter(s => s.id !== this.state.activeSpaceId); - if (otherSpaces.length === 0) { - return this.toast("No other spaces to share with", "warning"); - } - - const activeSpace = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - const collection = this.collections.find(c => c.id === colId); - if (!collection) return; - - const spacesList = otherSpaces.map((s, idx) => `${idx + 1}. ${s.name}`).join('\n'); - const choice = prompt(`Select workspace to share "${collection.name}" with (enter number):\n${spacesList}`); - if (choice) { - const idx = parseInt(choice) - 1; - if (idx >= 0 && idx < otherSpaces.length) { - const targetSpace = otherSpaces[idx]; - targetSpace.notifications = targetSpace.notifications || []; - - const alreadyShared = targetSpace.notifications.some(n => n.collection.id === colId && n.fromSpaceId === this.state.activeSpaceId); - if (alreadyShared) { - return this.toast("Already shared with this space, pending approval", "warning"); - } - - targetSpace.notifications.push({ - id: 'share_' + Date.now(), - fromSpaceId: this.state.activeSpaceId, - fromSpaceName: activeSpace ? activeSpace.name : 'Unknown Space', - collection: JSON.parse(JSON.stringify(collection)) - }); - - this.saveState(); - await this._debouncedSaveSpaces(); - this.toast(`Shared collection with ${targetSpace.name}!`); - this.render(); - } else { - this.toast("Invalid selection", "error"); - } - } - }, - - openNotificationsModal() { - const activeSpace = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - if (!activeSpace || !activeSpace.notifications || activeSpace.notifications.length === 0) return; - - const modal = document.createElement('div'); - modal.className = 'premium-modal-overlay'; - modal.id = 'notifications-modal'; - - const listHTML = activeSpace.notifications.map(n => ` -
-
- -
-
${this.escapeHTML(n.fromSpaceName)} shared collection:
-
${this.escapeHTML(n.collection.name)}
- ${n.collection.requests ? n.collection.requests.length : 0} Requests -
-
-
- - -
-
- `).join(''); - - modal.innerHTML = ` -
-
-

Share Requests

- -
-
- ${listHTML} -
- -
- `; - document.body.appendChild(modal); - modal.onclick = (e) => { if (e.target === modal) modal.remove(); }; - }, - - async approveShare(notifId) { - const activeSpace = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - if (!activeSpace || !activeSpace.notifications) return; - - const idx = activeSpace.notifications.findIndex(n => n.id === notifId); - if (idx >= 0) { - const notif = activeSpace.notifications[idx]; - const collection = notif.collection; - - let newName = collection.name; - let counter = 1; - while (activeSpace.collections.some(c => c.name === newName)) { - newName = `${collection.name} (${counter++})`; - } - collection.name = newName; - collection.id = 'col_' + Date.now(); - - activeSpace.collections.push(collection); - activeSpace.notifications.splice(idx, 1); - - this.saveState(); - await this._debouncedSaveSpaces(); - this.toast("Collection approved and added!"); - this.render(); - } - }, - - async rejectShare(notifId) { - const activeSpace = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - if (!activeSpace || !activeSpace.notifications) return; - - const idx = activeSpace.notifications.findIndex(n => n.id === notifId); - if (idx >= 0) { - activeSpace.notifications.splice(idx, 1); - this.saveState(); - await this._debouncedSaveSpaces(); - this.toast("Share request rejected"); - this.render(); - } - }, - - startSidebarResize(e) { - e.preventDefault(); - document.body.classList.add('resizing'); - const startX = e.clientX; - const startWidth = this.state.sidebarWidth || 270; - const handle = document.getElementById('sidebar-resize-handle'); - if (handle) handle.classList.add('active'); - - const doDrag = (moveEvent) => { - const deltaX = moveEvent.clientX - startX; - const newWidth = Math.max(180, Math.min(600, startWidth + deltaX)); - this.state.sidebarWidth = newWidth; - const sidebarEl = document.getElementById('sidebar'); - if (sidebarEl) { - sidebarEl.style.width = `${newWidth}px`; - } - }; - - const stopDrag = () => { - document.body.classList.remove('resizing'); - document.removeEventListener('mousemove', doDrag); - document.removeEventListener('mouseup', stopDrag); - if (handle) handle.classList.remove('active'); - this.saveState(); - }; - - document.addEventListener('mousemove', doDrag); - document.addEventListener('mouseup', stopDrag); - }, - - replaceResultCardInDOM(result) { - const newEl = this._buildCardElement(result); - document.querySelectorAll(`.result-card[data-index="${result.index}"]`).forEach(card => { - card.replaceWith(newEl.cloneNode(true)); - }); - }, - - async resendBulkRequest(resultIndex) { - const index = resultIndex - 1; // 0-based index - const bulk = this.state.bulk; - const resultItem = bulk.results.find(r => r.index === resultIndex); - if (!resultItem) return; - - this.toast(`Re-sending request #${resultIndex}...`, 'info'); - - // Recalculate maxFiles and maxList to determine fileIndex and listIndex 1-to-1 - let maxFiles = 0; - let maxList = 0; - - const folders = [ - ...this.state.params.filter(p => p.type === 'folder' && p.enabled && p.key && p.key.trim()), - ...(this.state.bodyType === 'form-data' ? this.state.bodyData.filter(p => p.type === 'folder' && p.enabled && p.key && p.key.trim()) : []) - ]; - if (folders.length > 0) { - for (const f of folders) { - const files = this.fileStore.get(f.id); - if (files && files.length > maxFiles) maxFiles = files.length; - } - } - - const allLists = [ - ...this.state.params.filter(p => p.type === 'list' && p.enabled && p.key && p.key.trim()), - ...(this.state.bodyType === 'form-data' ? this.state.bodyData.filter(p => p.type === 'list' && p.enabled && p.key && p.key.trim()) : []), - ...this.state.headers.filter(h => h.type === 'list' && h.enabled && h.key && h.key.trim()) - ]; - if (allLists.length > 0) { - for (const listParam of allLists) { - const val = listParam.value || ''; - const arr = val.split(/[\n,]+/).map(s => s.trim()).filter(s => s); - if (arr.length > maxList) maxList = arr.length; - } - } - - let fileIndex = index; - let listIndex = index; - if (bulk.strategy === 'cartesian' && maxFiles > 0 && maxList > 0) { - fileIndex = Math.floor(index / maxList); - listIndex = index % maxList; - } - - try { - const res = await this.executeRequest(index, fileIndex, listIndex); - const isSuccess = res.status_code >= 200 && res.status_code < 300; - - // Adjust stats counters - const wasSuccess = resultItem.status >= 200 && resultItem.status < 300; - if (wasSuccess && !isSuccess) { - bulk.success--; - bulk.error++; - } else if (!wasSuccess && isSuccess) { - bulk.success++; - bulk.error--; - } - - // Update item details - resultItem.status = res.status_code; - resultItem.latency = res.latency || 0; - resultItem.data = res.content ? res.content.substring(0, 100) : (res.binary_data ? '[Binary]' : ''); - resultItem.fullContent = res.content; - resultItem.binaryData = res.binary_data; - resultItem.contentType = res.content_type; - resultItem.headers = res.headers; - - if (resultItem.blobUrl && resultItem.blobUrl !== res.blobUrl) { - URL.revokeObjectURL(resultItem.blobUrl); - } - resultItem.blobUrl = res.blobUrl; - - this.toast(`Request #${resultIndex} completed: ${res.status_code}`, isSuccess ? 'info' : 'error'); - this.updateBulkProgressUI(); - this.replaceResultCardInDOM(resultItem); - await this.saveLastRunToServer(); - } catch (e) { - const wasSuccess = resultItem.status >= 200 && resultItem.status < 300; - if (wasSuccess) { - bulk.success--; - bulk.error++; - } - resultItem.status = 'ERR'; - resultItem.latency = 0; - resultItem.data = e.message; - this.toast(`Request #${resultIndex} failed: ${e.message}`, 'error'); - this.updateBulkProgressUI(); - this.replaceResultCardInDOM(resultItem); - await this.saveLastRunToServer(); - } - }, - - startResultsResize(e) { - e.preventDefault(); - document.body.classList.add('resizing'); - const startY = e.clientY; - const startHeight = this.state.resultsPanelHeight || 300; - - const doDrag = (moveEvent) => { - const deltaY = startY - moveEvent.clientY; - const newHeight = Math.max(120, Math.min(800, startHeight + deltaY)); - this.state.resultsPanelHeight = newHeight; - const panel = document.querySelector('.bottom-results-panel'); - if (panel) { - panel.style.height = `${newHeight}px`; - } - }; - - const stopDrag = () => { - document.body.classList.remove('resizing'); - document.removeEventListener('mousemove', doDrag); - document.removeEventListener('mouseup', stopDrag); - this.saveState(); - }; - - document.addEventListener('mousemove', doDrag); - document.addEventListener('mouseup', stopDrag); - }, - - _buildCardElement(result) { - const tmp = document.createElement('template'); - tmp.innerHTML = this.renderResultCard(result).trim(); - return tmp.content.firstElementChild; - }, - - appendResultCardToDOM(result) { - const newElement = this._buildCardElement(result); - - const appendToGrid = (grid) => { - if (!grid) return; - const spinner = grid.querySelector('div[style*="fa-spinner"]'); - if (spinner) spinner.remove(); - grid.appendChild(newElement.cloneNode(true)); - // Virtual DOM cap: keep only the most recent 200 cards in the DOM. - // Older results remain accessible in this.state.bulk.results but not rendered. - while (grid.children.length > 200) { - grid.removeChild(grid.firstElementChild); - } - }; - - appendToGrid(document.getElementById('main-results-grid')); - appendToGrid(document.querySelector('.fullscreen-results-grid')); - }, - - updateBulkProgressUI() { - if (this._rafPending) return; - this._rafPending = true; - requestAnimationFrame(() => { - this._rafPending = false; - const bulk = this.state.bulk; - const pct = bulk.total > 0 ? (bulk.completed / bulk.total) * 100 : 0; - const statusColor = bulk.error > 0 ? (bulk.success > 0 ? 'var(--warning)' : 'var(--danger)') : 'var(--success)'; - - document.querySelectorAll('#progress-bar-fill, .progress-fill').forEach(bar => { - bar.style.width = `${pct}%`; - bar.style.background = statusColor; - }); - - document.querySelectorAll('#progress-text').forEach(el => el.innerText = `${bulk.completed} / ${bulk.total} Completed`); - document.querySelectorAll('.stat-capsule').forEach(el => { - if (el.classList.contains('success')) { - el.innerText = `${bulk.success} Success`; - } else if (el.classList.contains('error')) { - el.innerText = `${bulk.error} Failed`; - } else if (el.innerText.includes('Completed')) { - el.innerText = `${bulk.completed} / ${bulk.total} Completed`; - } - }); - // Intentionally NOT calling saveLastRunToServer here to prevent massive JSON stringify lag during execution! - }); - }, - - - openFullscreenResults() { - const bulk = this.state.bulk; - if (bulk.results.length === 0 && !bulk.running) { - return this.toast("No results to view in fullscreen", "warning"); - } - - let modal = document.getElementById('fullscreen-results-overlay'); - const pct = bulk.total > 0 ? (bulk.completed / bulk.total) * 100 : 0; - const statusColor = bulk.error > 0 ? (bulk.success > 0 ? 'var(--warning)' : 'var(--danger)') : 'var(--success)'; - const folderPath = this.state.outputFolderPath || 'None selected'; - - const contentHTML = ` -
-
- -
-

Fullscreen Batch Processing Grid

-

Real-time execution monitoring and visual results

-
-
- ${bulk.completed} / ${bulk.total} Completed - ${bulk.success} Success - ${bulk.error} Failed -
-
- -
-
- - ${folderPath} - - - -
- - - - -
-
- -
-
-
- -
- `; - - if (!modal) { - modal = document.createElement('div'); - modal.className = 'fullscreen-results-overlay'; - modal.id = 'fullscreen-results-overlay'; - modal.innerHTML = contentHTML; - document.body.appendChild(modal); - } else { - modal.innerHTML = contentHTML; - } - - // Populate the fullscreen grid via DocumentFragment (no re-render of cards) - const fsGrid = document.getElementById('fullscreen-results-inner'); - if (fsGrid) { - const frag = document.createDocumentFragment(); - const shown = bulk.results.slice(-200); - if (shown.length === 0 && bulk.running) { - const ph = document.createElement('div'); - ph.style.cssText = 'grid-column:1/-1;text-align:center;color:var(--text-muted);padding:80px;font-style:italic;'; - ph.innerHTML = 'Running…'; - frag.appendChild(ph); - } else { - shown.forEach(r => frag.appendChild(this._buildCardElement(r))); - } - fsGrid.appendChild(frag); - } - }, - - closeFullscreenResults() { - const modal = document.getElementById('fullscreen-results-overlay'); - if (modal) { - modal.remove(); - } - }, - - async browseServerFolder() { - try { - const res = await fetch('/api/browse_folder', { - method: 'POST' - }); - const data = await res.json(); - if (data.success) { - this.state.outputFolderPath = data.path; - this.saveState(); - this.render(); - this.toast(`Folder selected: ${data.path}`); - } else { - this.toast(data.error || 'Failed to browse folder', 'error'); - } - } catch (e) { - this.toast(`Error browsing folder: ${e.message}`, 'error'); - } - }, - - async saveToServerFolder() { - if (!this.state.bulk.results.length) return this.toast('No results to save', 'error'); - if (!this.state.outputFolderPath) { - this.toast('Please select an output folder first', 'error'); - await this.browseServerFolder(); - if (!this.state.outputFolderPath) return; - } - - try { - this.toast('Saving files to server folder...', 'info'); - - // Build file list from current in-memory blobUrls - const fileItems = []; - for (const r of this.state.bulk.results) { - const filename = this.getFinalFilename(r); - if (r.blobUrl) { - try { - const blob = await fetch(r.blobUrl).then(res => res.blob()); - const ab = await blob.arrayBuffer(); - const b64 = btoa(String.fromCharCode(...new Uint8Array(ab))); - fileItems.push({ filename, is_binary: true, binary_data: b64 }); - } catch (e) { console.warn('blob fetch failed', r.index, e); } - } else if (r.fullContent) { - fileItems.push({ filename, is_binary: false, content: r.fullContent }); - } - } - - if (!fileItems.length) return this.toast('No data available to save', 'error'); - - const res = await fetch('/api/save_folder', { - method: 'POST', - headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ path: this.state.outputFolderPath, results: fileItems }) - }); - - const data = await res.json(); - if (data.success) { - const errMsg = data.errors && data.errors.length > 0 ? ` (${data.errors.length} errors)` : ''; - this.toast(`Saved ${data.count} files to ${this.state.outputFolderPath}${errMsg}`); - } else { - this.toast(`Failed to save: ${data.error}`, 'error'); - } - } catch (e) { - this.toast(`Error saving to folder: ${e.message}`, 'error'); - } - }, - - async saveIndividualToServerFolder(index) { - const result = this.state.bulk.results.find(r => r.index === index); - if (!result) return; - - if (!this.state.outputFolderPath) { - this.toast('Please select an output folder first', 'error'); - await this.browseServerFolder(); - if (!this.state.outputFolderPath) return; - } - - try { - const filename = this.getFinalFilename(result); - let fileItem = null; - if (result.blobUrl) { - const blob = await fetch(result.blobUrl).then(r => r.blob()); - const ab = await blob.arrayBuffer(); - const b64 = btoa(String.fromCharCode(...new Uint8Array(ab))); - fileItem = { filename, is_binary: true, binary_data: b64 }; - } else if (result.fullContent) { - fileItem = { filename, is_binary: false, content: result.fullContent }; - } - if (!fileItem) return this.toast('No data for this result', 'error'); - - const res = await fetch('/api/save_folder', { - method: 'POST', - headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ path: this.state.outputFolderPath, results: [fileItem] }) - }); - - const data = await res.json(); - if (data.success && data.count > 0) { - this.toast(`Saved file #${index} to server folder`); - } else { - this.toast(`Failed to save: ${data.error || (data.errors && data.errors[0]) || 'Unknown error'}`, 'error'); - } - } catch (e) { - this.toast(`Error saving file: ${e.message}`, 'error'); - } - }, - - downloadIndividualResult(index) { - const result = this.state.bulk.results.find(r => r.index === index); - if (!result) return; - - try { - const finalFilename = this.getFinalFilename(result); - let url; - let needsRevoke = false; - - if (result.blobUrl) { - url = result.blobUrl; - } else if (result.fullContent) { - const blob = new Blob([result.fullContent], { type: result.contentType || 'text/plain' }); - url = URL.createObjectURL(blob); - needsRevoke = true; - } else { - return this.toast('No content to download', 'error'); - } - - const a = document.createElement('a'); - a.href = url; - a.download = finalFilename; - document.body.appendChild(a); - a.click(); - document.body.removeChild(a); - if (needsRevoke) { - URL.revokeObjectURL(url); - } - - this.toast(`Downloaded "${finalFilename}"`); - } catch (e) { - this.toast(`Download failed: ${e.message}`, 'error'); - } - }, - - clearBulkResults() { - if (confirm("Are you sure you want to clear all batch results?")) { - // Revoke all blob URLs before clearing to free memory - this.state.bulk.results.forEach(r => { if (r.blobUrl) URL.revokeObjectURL(r.blobUrl); }); - this.state.bulk.results = []; - this.state.bulk.completed = 0; - this.state.bulk.success = 0; - this.state.bulk.error = 0; - this.state.bulk.total = 0; - this.state.bulk.running = false; - this.saveState(); - this.saveLastRunToServer(); - this.render(); - } - }, - - toggleGridMaximized() { - this.state.gridMaximized = !this.state.gridMaximized; - this.render(); - }, - - // --- Actions --- - - addParam(section) { - const item = { id: Date.now().toString() + Math.random(), key: '', value: '', type: 'text', enabled: true }; - if (section === 'params') this.state.params.push(item); - if (section === 'headers') this.state.headers.push(item); - if (section === 'body') this.state.bodyData.push(item); - this.render(); - this.saveState(); - }, - - removeParam(section, id) { - if (section === 'params') this.state.params = this.state.params.filter(p => p.id !== id); - if (section === 'headers') this.state.headers = this.state.headers.filter(p => p.id !== id); - if (section === 'body') this.state.bodyData = this.state.bodyData.filter(p => p.id !== id); - this.render(); - this.saveState(); - }, - - updateParam(section, id, field, value) { - const list = section === 'params' ? this.state.params : (section === 'headers' ? this.state.headers : this.state.bodyData); - const item = list.find(p => p.id === id); - if (item) { - item[field] = value; - this.saveState(); - // Re-render if type changes to show/hide file input - if (field === 'type' || field === 'enabled') this.scheduleRender(); - } - }, - - // --- Request Execution --- - - async sendRequest() { - if (!this.state.url) return this.toast('URL is required', 'error'); - - // Reset bulk results upon sending another single request - this.state.bulk.results = []; - this.state.bulk.completed = 0; - this.state.bulk.success = 0; - this.state.bulk.error = 0; - this.state.bulk.total = 0; - - this.state.response = { status: 'Sending...', headers: {} }; - this.state.responseTab = 'response'; // Switch view - this.render(); - this.saveLastRunToServerThrottled(); - - try { - const start = Date.now(); - const res = await this.executeRequest(0); - const latency = Date.now() - start; - - res.latency = latency; - this.state.response = res; - if (res.blobUrl) this.state.response.blobUrl = res.blobUrl; - this.saveToCollection(res.status_code || 500); - } catch (e) { - this.state.response = { error: e.message }; - } - - this.render(); - this.saveState(); - await this.saveLastRunToServer(); - }, - - // --- Bulk Execution --- - - async runBulk() { - if (!this.state.url) return this.toast('URL is required', 'error'); - - // Calculate total items based on folders or lists - let maxFiles = 0; - let maxList = 0; - const currentRunId = Date.now(); - this.state.bulk.currentRunId = currentRunId; - - // Check folders first - only those that will actually be used - const folders = [ - ...this.state.params.filter(p => p.type === 'folder' && p.enabled && p.key && p.key.trim()), - ...(this.state.bodyType === 'form-data' ? this.state.bodyData.filter(p => p.type === 'folder' && p.enabled && p.key && p.key.trim()) : []) - ]; - - if (folders.length > 0) { - // Find max file count - for (const f of folders) { - const files = this.fileStore.get(f.id); - if (files && files.length > maxFiles) maxFiles = files.length; - } - } - - // Check lists (params, body, headers) - only those with keys - const allLists = [ - ...this.state.params.filter(p => p.type === 'list' && p.enabled && p.key && p.key.trim()), - ...(this.state.bodyType === 'form-data' ? this.state.bodyData.filter(p => p.type === 'list' && p.enabled && p.key && p.key.trim()) : []), - ...this.state.headers.filter(h => h.type === 'list' && h.enabled && h.key && h.key.trim()) - ]; - - if (allLists.length > 0) { - // Find the longest list - for (const listParam of allLists) { - const val = listParam.value || ''; - const arr = val.split(/[\n,]+/).map(s => s.trim()).filter(s => s); - if (arr.length > maxList) maxList = arr.length; - } - } - - let total = 0; - if (this.state.bulk.strategy === 'cartesian' && maxFiles > 0 && maxList > 0) { - total = maxFiles * maxList; - } else { - total = Math.max(maxFiles, maxList); - } - - // If still no total, use the saved repetitions setting - if (total === 0) { - total = Math.max(1, parseInt(this.state.bulk.repetitions) || 10); - } - - if (total <= 0) return this.toast('Invalid bulk count', 'error'); - - // Init Bulk State - if (!this.state.bulk.paused) { - this.state.bulk.total = total; - this.state.bulk.completed = 0; - this.state.bulk.success = 0; - this.state.bulk.error = 0; - this.state.bulk.results = []; - this.state.bulk.nextIndex = 0; - this.state.responseTab = 'results'; - } else { - this.state.bulk.total = total; - } - - this.state.bulk.running = true; - this.state.bulk.paused = false; - - this.saveToCollection('BULK'); - this.render(); - - // Execution Queue - const concurrency = Math.max(1, Math.min(20, this.state.bulk.concurrency || 1)); - let active = 0; - - const worker = async () => { - while (this.state.bulk.nextIndex < this.state.bulk.total && this.state.bulk.running && this.state.bulk.currentRunId === currentRunId) { - const index = this.state.bulk.nextIndex++; - active++; - - let fileIndex = index; - let listIndex = index; - if (this.state.bulk.strategy === 'cartesian' && maxFiles > 0 && maxList > 0) { - fileIndex = Math.floor(index / maxList); - listIndex = index % maxList; - } - - const inputFilename = this.getInputFilename(index, fileIndex, listIndex); - - try { - const res = await this.executeRequest(index, fileIndex, listIndex); - - if (this.state.bulk.currentRunId !== currentRunId) return; - - const isSuccess = res.status_code >= 200 && res.status_code < 300; - if (isSuccess) this.state.bulk.success++; else this.state.bulk.error++; - - this.state.bulk.results.push({ - index: index + 1, - status: res.status_code, - latency: res.latency || 0, - data: res.content ? res.content.substring(0, 100) : (res.binary_data ? '[Binary]' : ''), - // Strip heavy data immediately — blobUrl is a cheap pointer - // fullContent and binaryData are NOT stored to avoid heap bloat - fullContent: null, - binaryData: null, - blobUrl: res.blobUrl, - contentType: res.content_type, - headers: res.headers, - inputFilename: inputFilename - }); - - const newResult = this.state.bulk.results[this.state.bulk.results.length - 1]; - this.appendResultCardToDOM(newResult); - // Cap result memory: revoke blob URL of oldest item when trimming - if (this.state.bulk.results.length > 300) { - const dropped = this.state.bulk.results.shift(); - if (dropped && dropped.blobUrl) URL.revokeObjectURL(dropped.blobUrl); - } - - } catch (e) { - if (this.state.bulk.currentRunId !== currentRunId) return; - this.state.bulk.error++; - this.state.bulk.results.push({ - index: index + 1, - status: 'ERR', - latency: 0, - data: e.message, - inputFilename: inputFilename - }); - const errResult = this.state.bulk.results[this.state.bulk.results.length - 1]; - this.appendResultCardToDOM(errResult); - } finally { - active--; - this.state.bulk.completed++; - if (this.state.bulk.currentRunId === currentRunId) { - this.updateBulkProgressUI(); - } - } - - // Apply inter-request delay (only when concurrency = 1 or after each request) - const delayMs = parseInt(this.state.bulk.delay) || 0; - if (delayMs > 0 && this.state.bulk.running && this.state.bulk.currentRunId === currentRunId) { - await new Promise(r => setTimeout(r, delayMs)); - } - } - - if (active === 0 && this.state.bulk.nextIndex >= this.state.bulk.total && this.state.bulk.currentRunId === currentRunId) { - this.state.bulk.running = false; - this.state.bulk.paused = false; - // Sort final results by index before final render - this.state.bulk.results.sort((a, b) => a.index - b.index); - this.render(); - this.toast('Bulk Operation Completed'); - await this.saveLastRunToServer(); - } - }; - - // Spawn workers - for (let i = 0; i < concurrency; i++) { - worker(); - } - }, - - stopBulk() { - this.state.bulk.running = false; - this.state.bulk.paused = false; - this.scheduleRender(); - }, - - pauseBulk() { - if (this.state.bulk.running) { - this.state.bulk.running = false; - this.state.bulk.paused = true; - this.scheduleRender(); - this.toast('Bulk Operation Paused', 'warning'); - } - }, - - resumeBulk() { - if (this.state.bulk.paused) { - this.runBulk(); - } - }, - - async getImageDimensions(file) { - return new Promise((resolve) => { - if (!file || !file.type.startsWith('image/')) return resolve({width: 0, height: 0}); - const img = new Image(); - const url = URL.createObjectURL(file); - img.onload = () => { - resolve({width: img.width, height: img.height}); - URL.revokeObjectURL(url); - }; - img.onerror = () => { - resolve({width: 0, height: 0}); - URL.revokeObjectURL(url); - }; - img.src = url; - }); - }, - - async executeRequest(index, fileIndex = index, listIndex = index) { - const start = Date.now(); - // Headers - const headers = {}; - this.state.headers.filter(h => h.enabled && h.key && h.key.trim()).forEach(h => { - // Handle list replacement in headers too - let val = h.value; - if (h.type === 'list') { - const arr = val.split(/[\n,]+/).map(s => s.trim()).filter(s => s); - if (arr.length > 0) val = arr[listIndex % arr.length]; - } - headers[h.key.trim()] = val; - }); - - // Auth - const auth = this.state.auth; - if (auth.type === 'bearer') headers['Authorization'] = `Bearer ${auth.token}`; - else if (auth.type === 'basic') headers['Authorization'] = 'Basic ' + btoa(`${auth.username}:${auth.password}`); - else if (auth.type === 'apikey') headers[auth.key] = auth.value; - - // URL Params - const urlObj = new URL(this.state.url); - this.state.params.filter(p => p.enabled && p.key && p.key.trim()).forEach(p => { - let val = p.value; - // List handling - if (p.type === 'list') { - // Try splitting by newline first if present, else comma - const arr = val.split(/[\n,]+/).map(s => s.trim()).filter(s => s); - if (arr.length > 0) val = arr[listIndex % arr.length]; - } - // File logic not applicable for URL params usually, skipping - urlObj.searchParams.append(p.key, val); - }); - - // Payload Construction - const finalData = new FormData(); - finalData.append('method', this.state.method); - finalData.append('url', urlObj.toString()); - finalData.append('headers', JSON.stringify(headers)); - // Add auth config for server-side handling if needed (e.g. Basic Auth via requests arg) - if (auth.type === 'basic') finalData.append('auth', JSON.stringify({ type: 'basic', username: auth.username, password: auth.password })); - - // Body - if (this.state.bodyType === 'json') { - finalData.append('body_type', 'json'); - finalData.append('body', this.state.jsonBody); - } else if (this.state.bodyType === 'form-data') { - finalData.append('body_type', 'form-data'); - - let currentImageFile = null; - const folderParam = this.state.bodyData.find(p => p.enabled && p.type === 'folder'); - if (folderParam) { - const files = this.fileStore.get(folderParam.id); - if (files && files.length > 0) currentImageFile = files[fileIndex % files.length]; - } - if (!currentImageFile) { - const fileParam = this.state.bodyData.find(p => p.enabled && p.type === 'file'); - if (fileParam) { - const files = this.fileStore.get(fileParam.id); - if (files && files.length > 0) currentImageFile = files[0]; - } - } - let imgDims = null; - - const bodyParams = this.state.bodyData.filter(p => p.enabled && (p.type === 'file' || p.type === 'folder' || p.type === 'auto_width' || p.type === 'auto_height' || (p.key && p.key.trim()))); - for (const p of bodyParams) { - if (p.type === 'file' || p.type === 'folder') { - const files = this.fileStore.get(p.id); - if (files && files.length > 0) { - if (p.type === 'folder') { - finalData.append(p.key, files[fileIndex % files.length]); - } else { - for (let f of files) finalData.append(p.key, f); - } - } - } else if (p.type === 'auto_width' || p.type === 'auto_height') { - if (!imgDims) imgDims = await this.getImageDimensions(currentImageFile); - finalData.append(p.key, p.type === 'auto_width' ? imgDims.width : imgDims.height); - } else { - let val = p.value; - if (p.type === 'list') { - const arr = val.split(/[\n,]+/).map(s => s.trim()).filter(s => s); - if (arr.length > 0) val = arr[listIndex % arr.length]; - } - finalData.append(p.key, val); - } - } - } - - const res = await fetch('/api/proxy-request', { - method: 'POST', - body: finalData - }); - - const data = await res.json(); - if (data.binary_data) { - data.blobUrl = await this.base64ToBlobUrlAsync(data.binary_data, data.content_type); - // Immediately null out raw data to free the large string from JS heap. - // The blobUrl is a tiny reference to browser-managed memory. - data.binary_data = null; - } - data.latency = Date.now() - start; - return data; - }, - - saveToCollection(lastStatus) { - if (!this.state.url) return; - - let targetColId = this.state.activeCollectionId || 'default'; - let col = this.collections.find(c => c.id === targetColId); - if (!col) { - col = this.collections.find(c => c.id === 'default'); - if(!col) { - col = { id: 'default', name: 'My Requests', requests: [] }; - this.collections.push(col); - } - targetColId = col.id; - } - - const existingIdx = col.requests.findIndex(r => r.id === this.state.activeRequestId || (r.url === this.state.url && r.method === this.state.method)); - let existingReq = existingIdx >= 0 ? col.requests[existingIdx] : null; - - const reqData = { - id: this.state.activeRequestId || Date.now().toString(), - name: (existingReq && existingReq.name) ? existingReq.name : (this.state.url.split('?')[0].split('/').pop() || 'Root URL'), - method: this.state.method, - url: this.state.url, - params: JSON.parse(JSON.stringify(this.state.params)), - headers: JSON.parse(JSON.stringify(this.state.headers)), - auth: JSON.parse(JSON.stringify(this.state.auth)), - bodyType: this.state.bodyType, - bodyData: JSON.parse(JSON.stringify(this.state.bodyData)), - jsonBody: this.state.jsonBody, - lastStatus: lastStatus !== undefined ? lastStatus : (existingReq ? existingReq.lastStatus : null), - lastTime: new Date().toLocaleTimeString(), - activeCollectionId: targetColId - }; - - if (existingIdx >= 0) { - // Update existing - reqData.id = existingReq.id; // preserve ID - col.requests[existingIdx] = reqData; - } else { - // Add new - col.requests.unshift(reqData); - } - - this.state.activeRequestId = reqData.id; - this.saveState(); - this._debouncedSaveSpaces(); - }, - - _debouncedSaveSpaces() { - if (this._saveSpacesTimer) clearTimeout(this._saveSpacesTimer); - this._saveSpacesTimer = setTimeout(() => this._debouncedSaveSpaces(), 3000); - }, - - loadRequest(colId, reqId) { - const col = this.collections.find(c => c.id === colId); - if(!col) return; - const req = col.requests.find(r => r.id === reqId); - if(!req) return; - - // Check if this request is already open in any tab - const existingTabIdx = this.tabs.findIndex(t => t.activeRequestId === reqId); - if (existingTabIdx >= 0) { - // Just switch to that tab - this.activeTabIndex = existingTabIdx; - this.saveState(); - this.render(); - return; - } - - // Postman behavior: if the current tab is a "preview" tab (untouched/empty), reuse it; - // otherwise open a new tab - const currTab = this.tabs[this.activeTabIndex]; - const isUntouched = currTab && ( - (!currTab.url || currTab.url === '') && - (!currTab.activeRequestId) && - (!currTab.response) && - (currTab.name === 'Untitled Request' || !currTab.name) - ); - - const reqTabData = { - id: 'tab_' + Date.now() + Math.random().toString(36).substr(2, 9), - name: req.name || (req.url ? req.url.split('/').pop() || req.url : 'Request'), - method: req.method || 'GET', - url: req.url || '', - params: JSON.parse(JSON.stringify(req.params || [{ id: Date.now().toString(), key: '', value: '', type: 'text', enabled: true }])), - headers: JSON.parse(JSON.stringify(req.headers || [{ id: (Date.now()+1).toString(), key: '', value: '', type: 'text', enabled: true }])), - auth: JSON.parse(JSON.stringify(req.auth || {type:'none'})), - bodyType: req.bodyType || 'none', - bodyData: JSON.parse(JSON.stringify(req.bodyData || [])), - jsonBody: req.jsonBody || '', - response: null, - bulk: { strategy: 'consecutive', running: false, total: 0, completed: 0, success: 0, error: 0, concurrency: 1, results: [] }, - activeTab: 'params', - responseTab: 'response', - activeRequestId: reqId, - activeCollectionId: colId, - isPreview: false - }; - - if (isUntouched) { - // Replace current blank tab - this.tabs[this.activeTabIndex] = reqTabData; - } else { - // Open brand new tab - this.tabs.push(reqTabData); - this.activeTabIndex = this.tabs.length - 1; - } - - this.saveState(); - this.render(); - }, - - deleteRequest(colId, reqId) { - const col = this.collections.find(c => c.id === colId); - if(col) col.requests = col.requests.filter(r => r.id !== reqId); - if(this.state.activeRequestId === reqId) this.state.activeRequestId = null; - this.saveState(); - this._debouncedSaveSpaces(); - this.render(); - }, - - createCollection() { - const name = prompt("Collection Name:"); - if(name) { - const id = 'col_' + Date.now(); - this.collections.push({ id, name, requests: [] }); - this.state.activeCollectionId = id; - this.saveState(); - this._debouncedSaveSpaces(); - this.render(); - } - }, - - renameCollection(colId) { - const col = this.collections.find(c => c.id === colId); - if(!col) return; - const newName = prompt("Enter new collection name:", col.name); - if(newName && newName.trim()) { - col.name = newName.trim(); - this.saveState(); - this._debouncedSaveSpaces(); - this.render(); - } - }, - - renameRequest(colId, reqId) { - const col = this.collections.find(c => c.id === colId); - if(!col) return; - const req = col.requests.find(r => r.id === reqId); - if(!req) return; - const newName = prompt("Enter new request name:", req.name); - if(newName && newName.trim()) { - req.name = newName.trim(); - this.saveState(); - this._debouncedSaveSpaces(); - this.render(); - } - }, - - deleteCollection(colId) { - if(confirm("Delete this collection and all its requests? This cannot be undone.")) { - this.collections = this.collections.filter(c => c.id !== colId); - // Always keep at least one collection - if (this.collections.length === 0) { - this.collections = [{ id: 'default', name: 'My Requests', requests: [] }]; - } - // If deleted collection was active, switch to first remaining - const stillExists = this.collections.some(c => c.id === this.state.activeCollectionId); - if (!stillExists) { - this.state.activeCollectionId = this.collections[0].id; - this.state.activeRequestId = null; - } - this.saveState(); - this._debouncedSaveSpaces(); - this.render(); - } - }, - - addRequestToCollection(colId) { - const col = this.collections.find(c => c.id === colId); - if (!col) return; - const reqId = 'req_' + Date.now(); - const newReq = { - id: reqId, - name: 'New Request', - method: 'GET', - url: '', - description: '', - params: [{ id: Date.now().toString() + Math.random(), key: '', value: '', type: 'text', enabled: true }], - headers: [{ id: Date.now().toString() + Math.random(), key: '', value: '', type: 'text', enabled: true }], - auth: { type: 'none' }, - bodyType: 'none', - bodyData: [], - jsonBody: '' - }; - col.requests.push(newReq); - - // Open this new request in a new tab - const reqTabData = { - id: 'tab_' + Date.now() + Math.random().toString(36).substr(2, 9), - name: 'New Request', - method: 'GET', - url: '', - params: JSON.parse(JSON.stringify(newReq.params)), - headers: JSON.parse(JSON.stringify(newReq.headers)), - auth: { type: 'none' }, - bodyType: 'none', - bodyData: [], - jsonBody: '', - response: null, - bulk: { strategy: 'consecutive', running: false, total: 0, completed: 0, success: 0, error: 0, concurrency: 1, results: [] }, - activeTab: 'params', - responseTab: 'response', - activeRequestId: reqId, - activeCollectionId: colId, - isPreview: false - }; - this.tabs.push(reqTabData); - this.activeTabIndex = this.tabs.length - 1; - - this.saveState(); - this._debouncedSaveSpaces(); - this.render(); - this.toast("Added new request to collection"); - - }, - - updateActiveRequestName(name) { - const activeSpace = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - const col = activeSpace ? activeSpace.collections.find(c => c.id === this.state.activeCollectionId) : null; - const activeReq = col ? col.requests.find(r => r.id === this.state.activeRequestId) : null; - if (activeReq) { - activeReq.name = name.trim() || 'Untitled Request'; - this.saveState(); - this._debouncedSaveSpaces(); - this.render(); - } - }, - - updateActiveRequestDescription(desc) { - const activeSpace = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - const col = activeSpace ? activeSpace.collections.find(c => c.id === this.state.activeCollectionId) : null; - const activeReq = col ? col.requests.find(r => r.id === this.state.activeRequestId) : null; - if (activeReq) { - activeReq.description = desc; - this.saveState(); - this._debouncedSaveSpaces(); - } - }, - - downloadHistory() { - if (!this.state.bulk.results.length) return; - - const csvContent = "data:text/csv;charset=utf-8," - + "Index,Status,Latency (ms),Snippet\n" - + this.state.bulk.results.map(r => `${r.index},${r.status},${r.latency},"${(r.data || '').replace(/"/g, '""').replace(/\n/g, ' ')}"`).join("\n"); - - const encodedUri = encodeURI(csvContent); - const link = document.createElement("a"); - link.setAttribute("href", encodedUri); - link.setAttribute("download", `bulk_results_${new Date().toISOString()}.csv`); - document.body.appendChild(link); - link.click(); - document.body.removeChild(link); - }, - - // Get the input filename for a given bulk index - getInputFilename(index, fileIndex = index, listIndex = index) { - // Build list of active params that could provide a name - const activeParams = [ - ...this.state.params.filter(p => p.enabled && p.key && p.key.trim()), - ...(this.state.bodyType === 'form-data' ? this.state.bodyData.filter(p => p.enabled && p.key && p.key.trim()) : []) - ]; - - let folderName = null; - // Priority 1: Folder type (usually high-intent for naming) - const folderParam = activeParams.find(p => p.type === 'folder'); - if (folderParam) { - const files = this.fileStore.get(folderParam.id); - if (files && files.length > 0) { - const file = files[fileIndex % files.length]; - folderName = file.webkitRelativePath || file.name; - } - } - - let listName = null; - // Priority 2: List in Body (user's specific request context) - if (this.state.bodyType === 'form-data') { - const bodyList = this.state.bodyData.find(p => p.type === 'list' && p.enabled && p.key && p.key.trim()); - if (bodyList) { - const arr = bodyList.value.split(/[\n,]+/).map(s => s.trim()).filter(s => s); - if (arr.length > 0) listName = arr[listIndex % arr.length]; - } - } - - // Priority 3: Any other list - if (!listName) { - const listParam = activeParams.find(p => p.type === 'list'); - if (listParam) { - const val = listParam.value || ''; - const arr = val.split(/[\n,]+/).map(s => s.trim()).filter(s => s); - if (arr.length > 0) listName = arr[listIndex % arr.length]; - } - } - - if (folderName && listName) { - // Strip extension from folderName, add listName, re-add extension - let base = folderName; - let ext = ''; - const lastDot = folderName.lastIndexOf('.'); - if (lastDot !== -1 && lastDot > 0 && folderName.length - lastDot <= 6) { - base = folderName.substring(0, lastDot); - ext = folderName.substring(lastDot); - } - // Replace any invalid characters in listName just in case, though usually fine - const safeListName = listName.replace(/[\/\\]/g, '_'); - return `${base}_${safeListName}${ext}`; - } else if (folderName) { - return folderName; - } else if (listName) { - return listName; - } - - return `result_${index + 1}`; - }, - - // Get the final filename with appropriate extension if missing - getFinalFilename(result) { - let name = result.inputFilename || `result_${result.index}`; - let originalExt = ''; - - // Extract existing extension if present - const lastDot = name.lastIndexOf('.'); - if (lastDot > 0 && (name.length - lastDot) <= 6) { - originalExt = name.substring(lastDot); - name = name.substring(0, lastDot); - } - - // Map common content types - const ct = (result.contentType || '').toLowerCase(); - if (ct.includes('image/png')) return name + '.png'; - if (ct.includes('image/jpeg') || ct.includes('image/jpg')) return name + '.jpg'; - if (ct.includes('image/gif')) return name + '.gif'; - if (ct.includes('image/webp')) return name + '.webp'; - if (ct.includes('image/svg')) return name + '.svg'; - if (ct.includes('application/pdf')) return name + '.pdf'; - if (ct.includes('application/json')) return name + '.json'; - if (ct.includes('application/xml') || ct.includes('text/xml')) return name + '.xml'; - if (ct.includes('text/html')) return name + '.html'; - if (ct.includes('text/csv')) return name + '.csv'; - if (ct.includes('text/css')) return name + '.css'; - if (ct.includes('text/plain')) return name + '.txt'; - if (ct.includes('application/zip')) return name + '.zip'; - - // Fallback for other binary types: try to extract subtype - if (result.binaryData && ct.includes('/')) { - const subtype = ct.split('/')[1].split(';')[0]; // handle "type/subtype;charset=..." - if (subtype && subtype.length <= 4 && /^[a-z0-9]+$/.test(subtype)) { - return name + '.' + subtype; - } - } - - // Content sniffing for JSON if content type is missing or incorrect - if (!result.binaryData && result.fullContent) { - const trimmed = result.fullContent.trim(); - if ((trimmed.startsWith('{') && trimmed.endsWith('}')) || (trimmed.startsWith('[') && trimmed.endsWith(']'))) { - try { - JSON.parse(trimmed); // Quick validation - return name + '.json'; - } catch(e) {} - } - } - - // If we still don't know the type, fallback to original extension if it existed - if (originalExt) return name + originalExt; - - // Otherwise default based on data format - return result.binaryData ? name + '.bin' : name + '.txt'; - }, - - async saveAsFolder() { - if (!this.state.bulk.results.length) return this.toast('No results to save', 'error'); - - try { - if (!window.showDirectoryPicker) { - return this.toast('Your browser does not support native folder saving. Please use the ZIP button instead.', 'error'); - } - - this.toast('Select a folder to save files...', 'info'); - const dirHandle = await window.showDirectoryPicker({ - mode: 'readwrite' - }); - - let savedCount = 0; - let errors = 0; - const usedNames = new Set(); - - for (const r of this.state.bulk.results) { - try { - let filename = this.getFinalFilename(r); - - let base = filename; - let ext = ''; - const lastDot = filename.lastIndexOf('.'); - if (lastDot !== -1 && lastDot > 0) { - base = filename.substring(0, lastDot); - ext = filename.substring(lastDot); - } - - let counter = 1; - while (usedNames.has(filename)) { - filename = `${base}_${counter}${ext}`; - counter++; - } - usedNames.add(filename); - - // Get the content — prefer blobUrl, fallback to fullContent - let data; - if (r.blobUrl) { - const blob = await fetch(r.blobUrl).then(res => res.blob()); - data = await blob.arrayBuffer(); - } else if (r.fullContent) { - data = r.fullContent; - } else { - continue; // Skip empty results - } - - // Create file and write content - const fileHandle = await dirHandle.getFileHandle(filename, { create: true }); - const writable = await fileHandle.createWritable(); - await writable.write(data); - await writable.close(); - - savedCount++; - } catch (e) { - console.error('Error saving file', r.index, e); - errors++; - } - } - - if (errors > 0) { - this.toast(`Saved ${savedCount} files. Failed to save ${errors} files.`, 'warning'); - } else { - this.toast(`Successfully saved ${savedCount} files to the selected folder.`); - } - - } catch (e) { - console.error(e); - if (e.name === 'AbortError') { - this.toast('Folder selection cancelled.', 'info'); - } else { - this.toast('Failed to save to folder: ' + e.message, 'error'); - } - } - }, - - async saveAllResults() { - if (!this.state.bulk.results.length) return this.toast('No results to save', 'error'); - if (typeof JSZip === 'undefined') return this.toast('JSZip library not loaded. Please refresh.', 'error'); - - this.toast('Building ZIP file...', 'info'); - - const zip = new JSZip(); - let savedCount = 0; - const usedNames = new Set(); - - for (const result of this.state.bulk.results) { - try { - // Use the tracked input filename + auto extension - let filename = this.getFinalFilename(result); - - let base = filename; - let ext = ''; - const lastDot = filename.lastIndexOf('.'); - if (lastDot !== -1 && lastDot > 0) { - base = filename.substring(0, lastDot); - ext = filename.substring(lastDot); - } - - let counter = 1; - while (usedNames.has(filename)) { - filename = `${base}_${counter}${ext}`; - counter++; - } - usedNames.add(filename); - - // Get the content — prefer blobUrl (memory efficient), fallback to fullContent - let data; - if (result.blobUrl) { - const blob = await fetch(result.blobUrl).then(r => r.blob()); - data = await blob.arrayBuffer(); - zip.file(filename, data, { binary: true }); - } else if (result.fullContent) { - data = result.fullContent; - zip.file(filename, data, { binary: false }); - } else { - continue; // Skip empty results - } - savedCount++; - } catch (e) { - console.error('Error adding result to ZIP', result.index, e); - } - } - - if (savedCount === 0) return this.toast('No valid results to save', 'error'); - - // Generate and download ZIP - try { - this.toast('Generating ZIP, please wait...', 'info'); - const blob = await zip.generateAsync({ type: 'blob' }); - const url = URL.createObjectURL(blob); - - const modal = document.createElement('div'); - modal.className = 'premium-modal-overlay'; - modal.style.zIndex = '9999'; - modal.innerHTML = ` -
- -

ZIP Ready!

-

Successfully bundled ${savedCount} files.

- - Click to Download ZIP - - -
- `; - document.body.appendChild(modal); - - // Note: intentionally not revoking the URL immediately so the manual click works! - - } catch (e) { - this.toast('Error generating ZIP: ' + e.message, 'error'); - } - }, - - // --- Rendering --- - - // Debounced render — coalesces rapid successive calls (e.g., keystrokes) - // into a single animation frame to prevent jank. - scheduleRender() { - if (this._renderScheduled) return; - this._renderScheduled = true; - requestAnimationFrame(() => { - this._renderScheduled = false; - this.render(); - }); - }, - - render() { - const root = document.getElementById('app-root'); - if (root) { - // Reset base class first to prevent layout/theme clashing - root.className = 'workspace'; - - if (this.state.bulk.results.length > 0 || this.state.bulk.running) { - root.classList.add('bulk-active'); - } - if (this.state.gridMaximized || !this.state.activeSpaceId) { - root.classList.add('grid-maximized'); - } - - // Add theme class for active space - if (this.state.activeSpaceId) { - const activeSpace = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - const theme = activeSpace && activeSpace.theme ? activeSpace.theme : 'violet'; - root.classList.add(`theme-${theme}`); - } - } - this.renderSidebar(); - this.renderMain(); - this.renderResponse(); - }, - - renderProgress() { - // Optimized partial render for progress bar - const bar = document.getElementById('progress-bar-fill'); - const text = document.getElementById('progress-text'); - if (bar && text) { - const pct = (this.state.bulk.completed / this.state.bulk.total) * 100; - bar.style.width = `${pct}%`; - text.innerText = `${this.state.bulk.completed} / ${this.state.bulk.total}`; - } - }, - - getCollectionsHTML() { - const query = (this.state.searchQuery || '').toLowerCase().trim(); - let collectionsHTML = ''; - - this.collections.forEach(col => { - const isColActive = this.state.activeCollectionId === col.id; - - // Filter requests - const filteredRequests = col.requests.filter(r => { - if (!query) return true; - return ( - (r.name || '').toLowerCase().includes(query) || - (r.url || '').toLowerCase().includes(query) || - (r.description || '').toLowerCase().includes(query) - ); - }); - - // Decide if the collection itself matches - const colMatches = (col.name || '').toLowerCase().includes(query); - - // If neither collection matches nor has matching requests, skip rendering it - if (query && !colMatches && filteredRequests.length === 0) { - return; - } - - // If there's a query and we have matches, auto-expand the collection - const isExpanded = query ? true : isColActive; - - const reqsHTML = (query && colMatches ? col.requests : filteredRequests).map(r => ` -
- ${r.method} -
-
- ${this.escapeHTML(r.name || '')} -
-
- ${this.escapeHTML(r.url || 'No URL')} -
-
- - -
- `).join(''); - - collectionsHTML += ` -
-
- - ${this.escapeHTML(col.name)} - - - - - -
- ${isExpanded ? `
${reqsHTML || '
Empty Collection
'}
` : ''} -
- `; - }); - - return collectionsHTML; - }, - - filterSidebarCollections(query) { - this.state.searchQuery = query; - const listEl = document.getElementById('sidebar-collections-list'); - if (listEl) { - listEl.innerHTML = this.getCollectionsHTML(); - } - - // Also update clear button visibility - const clearBtn = document.getElementById('search-clear-btn'); - if (clearBtn) { - clearBtn.style.display = query ? 'block' : 'none'; - } - }, - - renderSidebar() { - const collectionsHTML = this.getCollectionsHTML(); - const activeSpace = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - - let notificationsBannerHTML = ''; - if (activeSpace && activeSpace.notifications && activeSpace.notifications.length > 0) { - notificationsBannerHTML = ` -
- - ${activeSpace.notifications.length} pending share request${activeSpace.notifications.length > 1 ? 's' : ''} -
- `; - } - - const spaceOptionsHTML = ` - - ${this.state.spaces.map(s => ` - - `).join('')} - `; - - this.dom.sidebar.innerHTML = ` - - - - ${activeSpace ? ` - ${notificationsBannerHTML} - - - - - - - - - - ` : ` -
-
- -
Select a workspace
from the dashboard
-
-
- `} - - -
- -
- `; - }, - - - renderMain() { - if (!this.state.activeSpaceId) { - // Render Spaces Dashboard Grid View - const spacesCardsHTML = this.state.spaces.map(s => { - const count = s.collections ? s.collections.length : 0; - const notifCount = s.notifications ? s.notifications.length : 0; - const theme = s.theme || 'violet'; - return ` -
-
- - ${notifCount > 0 ? `${notifCount}` : ''} -
-
-

${this.escapeHTML(s.name)}

- ${count} Collections -
-
- - ${this.state.spaces.length > 1 ? ` - - ` : ''} -
-
- `; - }).join(''); - - const dashboardHTML = ` -
-
-

Workspaces

-

Select a workspace to access its collections, endpoints, and history.

-
- -
- ${spacesCardsHTML} - -
-
-
-

Create New Space

- Add a clean workspace -
-
-
-
- `; - - const headerHTML = ` -
-
PHOENIX
-
- Workspace Dashboard -
-
-
- `; - - this.dom.mainPanel.innerHTML = headerHTML + dashboardHTML; - return; - } - - const isBulkStart = this.checkBulkStart(); - const bulk = this.state.bulk; - const activeSpace = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - - // Tab Strip (Postman-like) - const tabStripHTML = ` -
- ${this.tabs.map((tab, i) => { - const isActive = i === this.activeTabIndex; - const tabName = tab.name || (tab.url ? tab.url.split('/').pop() || 'Request' : 'Untitled'); - const displayName = tabName.length > 20 ? tabName.substring(0, 20) + '…' : tabName; - const method = tab.method || 'GET'; - const mc = { GET:'var(--m-get)', POST:'var(--m-post)', PUT:'var(--m-put)', DELETE:'var(--m-delete)', PATCH:'var(--m-patch)' }[method] || 'var(--text-3)'; - return ` -
- ${method} - ${this.escapeHTML(displayName)} - -
- `; - }).join('')} - -
- `; - - // Header with Active Space name/switcher - const headerHTML = ` -
-
- PHOENIX -
-
- - ${this.escapeHTML(activeSpace ? activeSpace.name : '')} - -
- - - - - -
- - -
- - -
- ${bulk.running - ? ` - ` - : bulk.paused - ? ` - ` - : `` - } -
-
- ${tabStripHTML} - `; - - // Request Name & Description Section - const col = activeSpace ? activeSpace.collections.find(c => c.id === this.state.activeCollectionId) : null; - const activeReq = col ? col.requests.find(r => r.id === this.state.activeRequestId) : null; - - const requestMetaHTML = activeReq ? ` -
-
- Name - -
-
- Description - -
-
- ` : ''; - - // Tabs bar (PARAMS / HEADERS / BODY / AUTH + Bulk controls) - const inputStyle = 'background:var(--bg-input);border:1px solid var(--border-2);border-radius:var(--r-xs);color:var(--text-1);padding:3px 6px;font-size:11px;text-align:center;font-family:var(--font-ui);'; - const tabsHTML = ` -
- ${['params', 'headers', 'body', 'auth'].map(t => ` -
${t.toUpperCase()}
- `).join('')} -
-
- ${isBulkStart ? ` -
- Strategy - - -
- ` : ''} -
- Repeat - -
-
- Delay ms - -
-
- Workers - -
-
-
- `; - - - // Content - let contentHTML = ''; - if (this.state.activeTab === 'params') contentHTML = this.renderTable(this.state.params, 'params'); - else if (this.state.activeTab === 'headers') contentHTML = this.renderTable(this.state.headers, 'headers'); - else if (this.state.activeTab === 'body') contentHTML = this.renderBodyTab(); - else if (this.state.activeTab === 'auth') contentHTML = this.renderAuthTab(); - - // Bottom Results & Response Panel (Always Rendered) - const pct = bulk.total > 0 ? (bulk.completed / bulk.total) * 100 : 0; - const statusColor = bulk.error > 0 ? (bulk.success > 0 ? 'var(--warning)' : 'var(--danger)') : 'var(--success)'; - const folderPath = this.state.outputFolderPath || 'None selected'; - const activeBottomTab = this.state.responseTab || 'response'; - - let bottomTabContentHTML = ''; - if (activeBottomTab === 'response') { - const resp = this.state.response; - if (!resp) { - bottomTabContentHTML = `
Ready to send request. Click SEND to execute a single request, or RUN BATCH for bulk.
`; - } else if (resp.status === 'Sending...') { - bottomTabContentHTML = `
Sending request...
`; - } else if (resp.error) { - bottomTabContentHTML = `
Error: ${resp.error}
`; - } else { - let content = resp.content; - try { - if (content && !resp.binary_data && content.trim().startsWith('{')) { - content = JSON.stringify(JSON.parse(content), null, 2); - } - } catch(e){} - - bottomTabContentHTML = ` -
- ${resp.status_code} - ${resp.latency ? resp.latency + ' ms' : ''} - ${resp.content_type || 'Unknown Type'} -
-
- ${resp.binary_data - ? `
- Binary Content -
` - : `
${this.escapeHTML(content)}
` - } -
- `; - } - } else { - if (bulk.results.length === 0) { - bottomTabContentHTML = ` -
- - No batch results yet. Run a batch to see results in a grid. -
- `; - } else { - bottomTabContentHTML = ` -
-
-
-
- `; - } - } - - bottomPanelHTML = ` -
-
- -
-
- - - ${bulk.results.length > 0 ? ` -
- ${bulk.completed}/${bulk.total} - ${bulk.success} ✓ - ${bulk.error} ✗ - ` : ''} -
- - ${activeBottomTab === 'results' && bulk.results.length > 0 ? ` -
-
- - ${folderPath} - - - -
- - - - -
- ` : ''} -
- -
- ${bottomTabContentHTML} -
-
- `; - - this.dom.mainPanel.innerHTML = headerHTML + requestMetaHTML + tabsHTML + `
${contentHTML}
` + bottomPanelHTML; - - // After writing the skeleton, repopulate the results grid from our cached fragment - // This avoids re-rendering 200+ cards on every render() call. - this._repopulateResultsGrid(); - }, - - _repopulateResultsGrid() { - const grid = document.getElementById('main-results-grid'); - if (!grid || !this.state.bulk.results.length) return; - // Idempotent: only add cards that aren't already rendered. - // This prevents rebuilding 200+ cards on every render(). - const existing = grid.querySelectorAll('.result-card'); - const renderedIndices = new Set(); - existing.forEach(el => { const i = parseInt(el.dataset.index); if (!isNaN(i)) renderedIndices.add(i); }); - - const shown = this.state.bulk.results.slice(-200); - // Only append cards that are missing from the DOM - const missing = shown.filter(r => !renderedIndices.has(r.index)); - if (!missing.length) return; - - const frag = document.createDocumentFragment(); - missing.forEach(result => { - const el = this._buildCardElement(result); - frag.appendChild(el); - }); - grid.appendChild(frag); - }, - - renderResultCard(result) { - const isImage = (result.contentType || '').toLowerCase().includes('image') && (result.blobUrl || result.binaryData); - const isSuccess = result.status >= 200 && result.status < 300; - const statusClass = isSuccess ? 'status-success' : 'status-error'; - const filename = result.inputFilename || `result_${result.index}`; - const finalFilename = this.getFinalFilename(result); - - let previewHTML = ''; - if (isImage) { - try { - previewHTML = `${filename}`; - } catch (e) { - previewHTML = `
Decode error
`; - } - } else { - let icon = 'fa-file-lines'; - let typeLabel = 'TXT'; - const ct = (result.contentType || '').toLowerCase(); - if (ct.includes('application/json')) { icon = 'fa-file-code'; typeLabel = 'JSON'; } - else if (ct.includes('text/html')) { icon = 'fa-file-code'; typeLabel = 'HTML'; } - else if (result.status === 'ERR') { icon = 'fa-circle-xmark'; typeLabel = 'ERROR'; } - previewHTML = ` -
- - ${typeLabel} -

${this.escapeHTML(result.data || '')}

-
`; - } - - const footerHTML = isImage - ? `` - : `
-
- #${result.index} - ${result.status} - ${result.latency}ms -
-
${finalFilename}
-
`; - - return ` -
-
- ${previewHTML} -
- ${!isImage ? ` - ` : ''} - - - -
-
- ${footerHTML} -
- `; - }, - - renderResponse() { - // No-op: Single response and bulk results have been consolidated into renderMain()'s bottom panel. - }, - - renderTable(items, section) { - return ` - - - - ${items.map(item => ` - - - - - - - `).join('')} - -
KeyValue
- - ${this.renderValueInput(item, section)} -
- - `; - }, - - renderValueInput(item, section) { - if (item.type === 'file' || item.type === 'folder') { - const files = this.fileStore.get(item.id); - const label = files ? (item.type === 'folder' ? `${files.length} Files Selected` : `${files.length} Files`) : 'Select...'; - return ` -
- - -
- `; - } - if (item.type === 'auto_width' || item.type === 'auto_height') { - return ``; - } - return ``; - }, - - renderBodyTab() { - return ` -
-
- - - -
- - ${this.state.bodyType === 'form-data' ? this.renderTable(this.state.bodyData, 'body') : ''} - ${this.state.bodyType === 'json' ? `` : ''} -
- `; - }, - - renderAuthTab() { - const auth = this.state.auth; - const inStyle = 'width:100%;padding:10px 12px;background:var(--bg-input);border:1px solid var(--border-2);border-radius:var(--r-md);color:var(--text-1);font-family:var(--font-mono);font-size:12px;transition:border-color 0.15s,box-shadow 0.15s;'; - const labelStyle = 'display:block;margin-bottom:6px;font-size:9.5px;font-weight:700;text-transform:uppercase;letter-spacing:0.07em;color:var(--text-3);'; - return ` -
- - - - ${auth.type === 'bearer' ? ` -
- - -
- ` : ''} - - ${auth.type === 'basic' ? ` -
-
- - -
-
- - -
-
- ` : ''} - - ${auth.type === 'apikey' ? ` -
-
- - -
-
- - -
-
- ` : ''} -
- `; - }, - - // --- Helpers --- - - handleFileSelect(input, section, id) { - if (input.files.length > 0) { - // Convert FileList to Array and sort by path to ensure strict processing sequence (natural sorting) - let filesArr = Array.from(input.files); - filesArr.sort((a, b) => { - const pA = a.webkitRelativePath || a.name; - const pB = b.webkitRelativePath || b.name; - return pA.localeCompare(pB, undefined, { numeric: true, sensitivity: 'base' }); - }); - this.fileStore.set(id, filesArr); - this.render(); // update label - } - }, - - checkBulkStart() { - const hasKeyedFolder = this.state.params.some(p => p.type === 'folder' && p.enabled && p.key && p.key.trim()) - || (this.state.bodyType === 'form-data' && this.state.bodyData.some(p => p.type === 'folder' && p.enabled && p.key && p.key.trim())); - - const hasKeyedList = this.state.params.some(p => p.type === 'list' && p.enabled && p.key && p.key.trim()) - || (this.state.bodyType === 'form-data' && this.state.bodyData.some(p => p.type === 'list' && p.enabled && p.key && p.key.trim())) - || this.state.headers.some(h => h.type === 'list' && h.enabled && h.key && h.key.trim()); - - return hasKeyedFolder || hasKeyedList; - }, - - getStatusColor(code) { - if (code >= 200 && code < 300) return 'var(--success)'; - if (code >= 300 && code < 400) return 'var(--warning)'; - if (code >= 400 || code === 'ERR') return 'var(--danger)'; - return 'var(--text-muted)'; - }, - - toast(msg, type = 'info') { - const icons = { info: 'fa-circle-info', success: 'fa-circle-check', error: 'fa-circle-xmark', warning: 'fa-triangle-exclamation' }; - const iconColors = { info: '#5ba0f5', success: '#0fcea0', error: '#ff4569', warning: '#f5a623' }; - const icon = icons[type] || icons.info; - const color = iconColors[type] || iconColors.info; - const t = document.createElement('div'); - t.className = `ph-toast-${type}`; - t.innerHTML = `${this.escapeHTML(msg)}`; - Object.assign(t.style, { - display: 'flex', - alignItems: 'center', - gap: '10px', - padding: '12px 16px', - borderRadius: '10px', - marginTop: '6px', - fontSize: '13px', - fontFamily: 'var(--font-ui)', - fontWeight: '500', - animation: 'toastSlideIn 0.32s cubic-bezier(0.34,1.56,0.64,1) both', - }); - this.dom.toast.appendChild(t); - const removeDelay = type === 'error' ? 4500 : 3000; - setTimeout(() => { - t.style.animation = 'toastFadeOut 0.2s ease forwards'; - setTimeout(() => t.remove(), 200); - }, removeDelay); - }, - - escapeHTML(str) { - if (!str) return ''; - if (typeof str !== 'string') return String(str); - return str.replace(/&/g, '&') - .replace(//g, '>') - .replace(/"/g, '"') - .replace(/'/g, '''); - }, - - base64ToUint8Array(base64Data) { - if (!base64Data) return new Uint8Array(0); - try { - const byteCharacters = atob(base64Data); - const data = new Uint8Array(byteCharacters.length); - for (let i = 0; i < byteCharacters.length; i++) { - data[i] = byteCharacters.charCodeAt(i); - } - return data; - } catch (e) { - console.error("Base64 to Uint8Array error", e); - return new Uint8Array(0); - } - }, - - async base64ToBlobUrlAsync(base64Data, contentType) { - if (!base64Data) return ''; - try { - const res = await fetch(`data:${contentType || 'application/octet-stream'};base64,${base64Data}`); - const blob = await res.blob(); - return URL.createObjectURL(blob); - } catch (e) { - console.error("Async Base64 decode error", e); - return ''; - } - }, - - base64ToBlobUrl(base64Data, contentType) { - if (!base64Data) return ''; - try { - const byteCharacters = atob(base64Data); - const byteArrays = []; - const sliceSize = 512; - for (let offset = 0; offset < byteCharacters.length; offset += sliceSize) { - const slice = byteCharacters.slice(offset, offset + sliceSize); - const byteNumbers = new Array(slice.length); - for (let i = 0; i < slice.length; i++) { - byteNumbers[i] = slice.charCodeAt(i); - } - const byteArray = new Uint8Array(byteNumbers); - byteArrays.push(byteArray); - } - const blob = new Blob(byteArrays, {type: contentType}); - return URL.createObjectURL(blob); - } catch (e) { - console.error("Base64 decode error", e); - return ''; - } - }, - - bindEvents() { - // Most events are inline (onclick, onchange) for simplicity in this structure - }, - - // Preview a result - previewResult(index) { - const result = this.state.bulk.results.find(r => r.index === index); - if (!result) return; - - const isImage = (result.contentType || '').toLowerCase().includes('image') && (result.blobUrl || result.binaryData); - const finalFilename = this.getFinalFilename(result); - - let contentHTML = ''; - if (isImage) { - try { - contentHTML = `${finalFilename}`; - } catch (e) { - contentHTML = ``; - } - } else { - let prettyContent = result.fullContent || ''; - try { - if (prettyContent.trim().startsWith('{')) { - prettyContent = JSON.stringify(JSON.parse(prettyContent), null, 2); - } - } catch(e) {} - contentHTML = ``; - } - - const modal = document.createElement('div'); - modal.className = 'premium-modal-overlay'; - - modal.innerHTML = ` -
-
-
- -
- ${finalFilename} - Result #${result.index} -
-
-
- ${result.status} - ${result.latency}ms - -
-
-
- ${contentHTML} -
- -
- `; - - document.body.appendChild(modal); - modal.onclick = () => modal.remove(); - }, - - // For manual clicking from history - loadHistoryItem(id) { - const item = this.state.history.find(h => h.id === id); - if (item) { - this.state.method = item.method; - this.state.url = item.url; - this.saveState(); - this.render(); - } - } -}; - - -document.addEventListener('DOMContentLoaded', () => App.init()); - diff --git a/web/bulk-api-tester/static/js/app.js.bak2 b/web/bulk-api-tester/static/js/app.js.bak2 deleted file mode 100644 index b424627..0000000 --- a/web/bulk-api-tester/static/js/app.js.bak2 +++ /dev/null @@ -1,2488 +0,0 @@ -/** - * Phoenix App - Advanced Bulk API Tester - * Version: 2.0 (Agentic Edition) - */ - -const App = { - _stateData: { - spaces: [], - activeSpaceId: null, - activeCollectionId: 'default', - - outputFolderPath: '', - gridMaximized: false, - resultsPanelHeight: 300, - sidebarWidth: 270, - searchQuery: '' - }, - - tabs: [], - activeTabIndex: 0, - - get state() { - if (!this._proxyState) { - const props = ['name', 'method', 'url', 'params', 'headers', 'auth', 'bodyType', 'bodyData', 'jsonBody', 'response', 'bulk', 'activeTab', 'responseTab', 'activeRequestId', 'isPreview']; - this._proxyState = new Proxy(this._stateData, { - get(target, prop) { - if (props.includes(prop)) { - if (App.tabs && App.tabs[App.activeTabIndex]) { - return App.tabs[App.activeTabIndex][prop]; - } - } - return target[prop]; - }, - set(target, prop, value) { - if (props.includes(prop)) { - if (App.tabs && App.tabs[App.activeTabIndex]) { - App.tabs[App.activeTabIndex][prop] = value; - if (prop !== 'activeTab' && prop !== 'responseTab' && prop !== 'activeRequestId') { - App.tabs[App.activeTabIndex].isPreview = false; - } - return true; - } - } - target[prop] = value; - return true; - } - }); - } - return this._proxyState; - }, - - createNewTab(reqData, isPreview = false) { - return { - id: 'tab_' + Date.now() + Math.random().toString(36).substr(2, 9), - name: reqData ? reqData.name : 'Untitled Request', - method: reqData ? reqData.method : 'POST', - url: reqData ? reqData.url : '', - params: reqData ? JSON.parse(JSON.stringify(reqData.params || [])) : [], - headers: reqData ? JSON.parse(JSON.stringify(reqData.headers || [])) : [], - auth: reqData ? JSON.parse(JSON.stringify(reqData.auth || {type:'none'})) : {type:'none'}, - bodyType: reqData ? reqData.bodyType : 'none', - bodyData: reqData ? JSON.parse(JSON.stringify(reqData.bodyData || [])) : [], - jsonBody: reqData ? reqData.jsonBody : '', - response: null, - bulk: reqData && reqData.bulk ? JSON.parse(JSON.stringify(reqData.bulk)) : { - strategy: 'consecutive', - running: false, - total: 0, - completed: 0, - success: 0, - error: 0, - concurrency: 1, - results: [] - }, - activeTab: 'params', - responseTab: 'response', - activeRequestId: reqData ? reqData.id : null, - isPreview: isPreview - }; - }, - - - fileStore: new Map(), // id -> FileList - - dom: {}, - - async init() { - this.loadState(); - this.cacheDOM(); - this.bindEvents(); - - if (this.state.params.length === 0) this.addParam('params'); - if (this.state.headers.length === 0) this.addParam('headers'); - - // Load spaces from the server to keep them synced - await this.loadSpacesFromServer(); - - // Load the last run results/response from the server - await this.loadLastRunFromServer(); - - // Apply saved sidebar width - const sidebarEl = document.getElementById('sidebar'); - if (sidebarEl && this.state.sidebarWidth) { - sidebarEl.style.width = `${this.state.sidebarWidth}px`; - } - - // Attach event listener for horizontal sidebar dragging - const handle = document.getElementById('sidebar-resize-handle'); - if (handle) { - handle.addEventListener('mousedown', (e) => this.startSidebarResize(e)); - } - - this.render(); - - // Remove loader - const loader = document.getElementById('loading-overlay'); - if (loader) loader.remove(); - document.getElementById('app-root').style.visibility = 'visible'; - }, - - cacheDOM() { - this.dom = { - mainPanel: document.getElementById('main-panel'), - sidebar: document.getElementById('sidebar'), - toast: document.getElementById('toast-container') - }; - - if (!this.dom.sidebar || !this.dom.mainPanel) { - console.error('Critical: DOM elements not found', this.dom); - alert('Critical Error: Application DOM structure is missing. Please refresh.'); - } - }, - - // --- State Management --- - - loadState() { - try { - const raw = localStorage.getItem('phoenix-state-v2'); - if (raw) { - const data = JSON.parse(raw); - this.state = { ...this.state, ...data }; - // Keep volatile fields clean on reload, loaded separately from server - this.state.bulk.running = false; - this.state.bulk.results = []; - this.state.response = null; - } - } catch (e) { - console.warn('Failed to load state', e); - } - }, - - saveState() { - try { - const { bulk, response, ...persistent } = this.state; - const persistentState = { - ...persistent, - bulk: { ...this.state.bulk, running: false, results: [] } - }; - localStorage.setItem('phoenix-state-v2', JSON.stringify(persistentState)); - } catch (e) { - console.warn('Failed to save state', e); - } - }, - - async loadLastRunFromServer() { - try { - const res = await fetch('/api/last-run'); - if (res.ok) { - const data = await res.json(); - if (data) { - if (data.bulk) { - this.state.bulk = { ...this.state.bulk, ...data.bulk, running: false }; - } - if (data.response !== undefined) { - this.state.response = data.response; - } - if (data.responseTab) { - this.state.responseTab = data.responseTab; - } - } - } - } catch (e) { - console.error('Failed to load last run from server', e); - } - }, - - async saveLastRunToServer() { - try { - const payload = { - bulk: { ...this.state.bulk, running: false }, - response: this.state.response, - responseTab: this.state.responseTab - }; - await fetch('/api/last-run', { - method: 'POST', - headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify(payload) - }); - } catch (e) { - console.error('Failed to save last run to server', e); - } - }, - - saveLastRunToServerThrottled() { - if (this._saveThrottleTimeout) return; - this._saveThrottleTimeout = setTimeout(async () => { - this._saveThrottleTimeout = null; - await this.saveLastRunToServer(); - }, 1000); - }, - - get collections() { - if (!this.state.activeSpaceId) return []; - const space = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - return space ? space.collections : []; - }, - - set collections(val) { - if (!this.state.activeSpaceId) return; - const space = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - if (space) { - space.collections = val; - } - }, - - get notifications() { - if (!this.state.activeSpaceId) return []; - const space = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - return space ? (space.notifications || []) : []; - }, - - set notifications(val) { - if (!this.state.activeSpaceId) return; - const space = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - if (space) { - space.notifications = val; - } - }, - - async loadSpacesFromServer() { - try { - const res = await fetch('/api/spaces'); - const data = await res.json(); - if (Array.isArray(data)) { - // Check if server returned empty or only the default empty spaces - const serverIsEmpty = data.length === 0 || ( - data.length === 2 && - data[0].id === 'personal' && data[0].collections.length === 1 && (!data[0].collections[0].requests || data[0].collections[0].requests.length === 0) && - data[1].id === 'team' && data[1].collections.length === 1 && (!data[1].collections[0].requests || data[1].collections[0].requests.length === 0) - ); - - // Check if client had non-empty legacy collections in localStorage - const clientHasLegacyCollections = this.state.collections && ( - this.state.collections.length > 1 || - (this.state.collections[0] && this.state.collections[0].requests && this.state.collections[0].requests.length > 0) - ); - - if (serverIsEmpty && clientHasLegacyCollections) { - console.log('Migrating local client collections to spaces...'); - this.state.spaces = [ - { - id: 'personal', - name: 'Personal Space', - collections: JSON.parse(JSON.stringify(this.state.collections)) - }, - { - id: 'team', - name: 'Team Space', - collections: JSON.parse(JSON.stringify(this.state.collections)) - } - ]; - delete this.state.collections; - await this.saveSpacesToServer(); - } else if (data.length === 0 && this.state.spaces && this.state.spaces.length > 0) { - await this.saveSpacesToServer(); - } else if (data.length > 0) { - this.state.spaces = data; - } - - // Validate activeSpaceId - if (this.state.activeSpaceId) { - const spaceExists = this.state.spaces.some(s => s.id === this.state.activeSpaceId); - if (!spaceExists) { - this.state.activeSpaceId = null; - this.state.activeCollectionId = 'default'; - this.state.activeRequestId = null; - } - } - } - } catch (e) { - console.error('Failed to load spaces from server:', e); - } - }, - - async saveSpacesToServer() { - try { - await fetch('/api/spaces', { - method: 'POST', - headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify(this.state.spaces) - }); - } catch (e) { - console.error('Failed to sync spaces with server:', e); - } - }, - - openSpace(spaceId) { - this.state.activeSpaceId = spaceId; - this.state.activeCollectionId = 'default'; - this.state.activeRequestId = null; - this.saveState(); - this.render(); - }, - - showSpacesDashboard() { - this.state.activeSpaceId = null; - this.state.activeCollectionId = 'default'; - this.state.activeRequestId = null; - this.saveState(); - this.render(); - }, - - async createSpace() { - const name = prompt("Enter space name:"); - if (name && name.trim()) { - const id = 'space_' + Date.now(); - this.state.spaces.push({ - id: id, - name: name.trim(), - collections: [{ id: 'default', name: 'My Requests', requests: [] }] - }); - this.state.activeSpaceId = id; - this.saveState(); - await this.saveSpacesToServer(); - this.render(); - } - }, - - async deleteSpace(spaceId) { - if (this.state.spaces.length <= 1) { - return this.toast("Cannot delete the last remaining space", "error"); - } - if (confirm("Are you sure you want to delete this space? All collections and requests inside it will be permanently lost.")) { - this.state.spaces = this.state.spaces.filter(s => s.id !== spaceId); - if (this.state.activeSpaceId === spaceId) { - this.state.activeSpaceId = null; - this.state.activeCollectionId = 'default'; - this.state.activeRequestId = null; - } - this.saveState(); - await this.saveSpacesToServer(); - this.render(); - } - }, - - renameSpace(spaceId) { - const space = this.state.spaces.find(s => s.id === spaceId); - if (!space) return; - const newName = prompt("Enter new workspace name:", space.name); - if (newName && newName.trim()) { - space.name = newName.trim(); - this.saveState(); - this.saveSpacesToServer(); - this.render(); - } - }, - - async setSpaceTheme(themeId) { - const activeSpace = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - if (activeSpace) { - activeSpace.theme = themeId; - this.saveState(); - await this.saveSpacesToServer(); - this.render(); - this.toast(`Applied ${themeId} theme to ${activeSpace.name}`); - } - }, - - async shareCollection(colId) { - const otherSpaces = this.state.spaces.filter(s => s.id !== this.state.activeSpaceId); - if (otherSpaces.length === 0) { - return this.toast("No other spaces to share with", "warning"); - } - - const activeSpace = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - const collection = this.collections.find(c => c.id === colId); - if (!collection) return; - - const spacesList = otherSpaces.map((s, idx) => `${idx + 1}. ${s.name}`).join('\n'); - const choice = prompt(`Select workspace to share "${collection.name}" with (enter number):\n${spacesList}`); - if (choice) { - const idx = parseInt(choice) - 1; - if (idx >= 0 && idx < otherSpaces.length) { - const targetSpace = otherSpaces[idx]; - targetSpace.notifications = targetSpace.notifications || []; - - const alreadyShared = targetSpace.notifications.some(n => n.collection.id === colId && n.fromSpaceId === this.state.activeSpaceId); - if (alreadyShared) { - return this.toast("Already shared with this space, pending approval", "warning"); - } - - targetSpace.notifications.push({ - id: 'share_' + Date.now(), - fromSpaceId: this.state.activeSpaceId, - fromSpaceName: activeSpace ? activeSpace.name : 'Unknown Space', - collection: JSON.parse(JSON.stringify(collection)) - }); - - this.saveState(); - await this.saveSpacesToServer(); - this.toast(`Shared collection with ${targetSpace.name}!`); - this.render(); - } else { - this.toast("Invalid selection", "error"); - } - } - }, - - openNotificationsModal() { - const activeSpace = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - if (!activeSpace || !activeSpace.notifications || activeSpace.notifications.length === 0) return; - - const modal = document.createElement('div'); - modal.className = 'premium-modal-overlay'; - modal.id = 'notifications-modal'; - - const listHTML = activeSpace.notifications.map(n => ` -
-
- -
-
${this.escapeHTML(n.fromSpaceName)} shared collection:
-
${this.escapeHTML(n.collection.name)}
- ${n.collection.requests ? n.collection.requests.length : 0} Requests -
-
-
- - -
-
- `).join(''); - - modal.innerHTML = ` -
-
-

Share Requests

- -
-
- ${listHTML} -
- -
- `; - document.body.appendChild(modal); - modal.onclick = (e) => { if (e.target === modal) modal.remove(); }; - }, - - async approveShare(notifId) { - const activeSpace = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - if (!activeSpace || !activeSpace.notifications) return; - - const idx = activeSpace.notifications.findIndex(n => n.id === notifId); - if (idx >= 0) { - const notif = activeSpace.notifications[idx]; - const collection = notif.collection; - - let newName = collection.name; - let counter = 1; - while (activeSpace.collections.some(c => c.name === newName)) { - newName = `${collection.name} (${counter++})`; - } - collection.name = newName; - collection.id = 'col_' + Date.now(); - - activeSpace.collections.push(collection); - activeSpace.notifications.splice(idx, 1); - - this.saveState(); - await this.saveSpacesToServer(); - this.toast("Collection approved and added!"); - this.render(); - } - }, - - async rejectShare(notifId) { - const activeSpace = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - if (!activeSpace || !activeSpace.notifications) return; - - const idx = activeSpace.notifications.findIndex(n => n.id === notifId); - if (idx >= 0) { - activeSpace.notifications.splice(idx, 1); - this.saveState(); - await this.saveSpacesToServer(); - this.toast("Share request rejected"); - this.render(); - } - }, - - startSidebarResize(e) { - e.preventDefault(); - document.body.classList.add('resizing'); - const startX = e.clientX; - const startWidth = this.state.sidebarWidth || 270; - const handle = document.getElementById('sidebar-resize-handle'); - if (handle) handle.classList.add('active'); - - const doDrag = (moveEvent) => { - const deltaX = moveEvent.clientX - startX; - const newWidth = Math.max(180, Math.min(600, startWidth + deltaX)); - this.state.sidebarWidth = newWidth; - const sidebarEl = document.getElementById('sidebar'); - if (sidebarEl) { - sidebarEl.style.width = `${newWidth}px`; - } - }; - - const stopDrag = () => { - document.body.classList.remove('resizing'); - document.removeEventListener('mousemove', doDrag); - document.removeEventListener('mouseup', stopDrag); - if (handle) handle.classList.remove('active'); - this.saveState(); - }; - - document.addEventListener('mousemove', doDrag); - document.addEventListener('mouseup', stopDrag); - }, - - async resendBulkRequest(resultIndex) { - const index = resultIndex - 1; // 0-based index - const bulk = this.state.bulk; - const resultItem = bulk.results.find(r => r.index === resultIndex); - if (!resultItem) return; - - this.toast(`Re-sending request #${resultIndex}...`, 'info'); - - // Recalculate maxFiles and maxList to determine fileIndex and listIndex 1-to-1 - let maxFiles = 0; - let maxList = 0; - - const folders = [ - ...this.state.params.filter(p => p.type === 'folder' && p.enabled && p.key && p.key.trim()), - ...(this.state.bodyType === 'form-data' ? this.state.bodyData.filter(p => p.type === 'folder' && p.enabled && p.key && p.key.trim()) : []) - ]; - if (folders.length > 0) { - for (const f of folders) { - const files = this.fileStore.get(f.id); - if (files && files.length > maxFiles) maxFiles = files.length; - } - } - - const allLists = [ - ...this.state.params.filter(p => p.type === 'list' && p.enabled && p.key && p.key.trim()), - ...(this.state.bodyType === 'form-data' ? this.state.bodyData.filter(p => p.type === 'list' && p.enabled && p.key && p.key.trim()) : []), - ...this.state.headers.filter(h => h.type === 'list' && h.enabled && h.key && h.key.trim()) - ]; - if (allLists.length > 0) { - for (const listParam of allLists) { - const val = listParam.value || ''; - const arr = val.split(/[\n,]+/).map(s => s.trim()).filter(s => s); - if (arr.length > maxList) maxList = arr.length; - } - } - - let fileIndex = index; - let listIndex = index; - if (bulk.strategy === 'cartesian' && maxFiles > 0 && maxList > 0) { - fileIndex = Math.floor(index / maxList); - listIndex = index % maxList; - } - - try { - const res = await this.executeRequest(index, fileIndex, listIndex); - const isSuccess = res.status_code >= 200 && res.status_code < 300; - - // Adjust stats counters - const wasSuccess = resultItem.status >= 200 && resultItem.status < 300; - if (wasSuccess && !isSuccess) { - bulk.success--; - bulk.error++; - } else if (!wasSuccess && isSuccess) { - bulk.success++; - bulk.error--; - } - - // Update item details - resultItem.status = res.status_code; - resultItem.latency = res.latency || 0; - resultItem.data = res.content ? res.content.substring(0, 100) : (res.binary_data ? '[Binary]' : ''); - resultItem.fullContent = res.content; - resultItem.binaryData = res.binary_data; - resultItem.contentType = res.content_type; - resultItem.headers = res.headers; - - this.toast(`Request #${resultIndex} completed: ${res.status_code}`, isSuccess ? 'info' : 'error'); - this.updateBulkProgressUI(); - await this.saveLastRunToServer(); - } catch (e) { - const wasSuccess = resultItem.status >= 200 && resultItem.status < 300; - if (wasSuccess) { - bulk.success--; - bulk.error++; - } - resultItem.status = 'ERR'; - resultItem.latency = 0; - resultItem.data = e.message; - this.toast(`Request #${resultIndex} failed: ${e.message}`, 'error'); - this.updateBulkProgressUI(); - await this.saveLastRunToServer(); - } - }, - - startResultsResize(e) { - e.preventDefault(); - document.body.classList.add('resizing'); - const startY = e.clientY; - const startHeight = this.state.resultsPanelHeight || 300; - - const doDrag = (moveEvent) => { - const deltaY = startY - moveEvent.clientY; - const newHeight = Math.max(120, Math.min(800, startHeight + deltaY)); - this.state.resultsPanelHeight = newHeight; - const panel = document.querySelector('.bottom-results-panel'); - if (panel) { - panel.style.height = `${newHeight}px`; - } - }; - - const stopDrag = () => { - document.body.classList.remove('resizing'); - document.removeEventListener('mousemove', doDrag); - document.removeEventListener('mouseup', stopDrag); - this.saveState(); - }; - - document.addEventListener('mousemove', doDrag); - document.addEventListener('mouseup', stopDrag); - }, - - updateBulkProgressUI() { - const bulk = this.state.bulk; - const pct = bulk.total > 0 ? (bulk.completed / bulk.total) * 100 : 0; - const statusColor = bulk.error > 0 ? (bulk.success > 0 ? 'var(--warning)' : 'var(--danger)') : 'var(--success)'; - - const bar = document.getElementById('progress-bar-fill'); - if (bar) { - bar.style.width = `${pct}%`; - bar.style.background = statusColor; - } - - const text = document.getElementById('progress-text'); - if (text) { - text.innerText = `${bulk.completed} / ${bulk.total} Completed`; - } - - // Update stats - const successStat = document.querySelector('.stat-capsule.success'); - if (successStat) { - successStat.innerText = `${bulk.success} Success`; - } - const errorStat = document.querySelector('.stat-capsule.error'); - if (errorStat) { - errorStat.innerText = `${bulk.error} Failed`; - } - - // Update the grid - const grid = document.querySelector('.results-grid'); - if (grid) { - const cardsHTML = bulk.results.map(r => this.renderResultCard(r)).join(''); - grid.innerHTML = cardsHTML || `
Executing batch requests, processing results...
`; - } - - // Update the fullscreen grid overlay if active - if (document.getElementById('fullscreen-results-overlay')) { - this.openFullscreenResults(); - } - - // Enable/disable buttons based on results - const saveFolderBtn = document.querySelector('[onclick="App.saveToServerFolder()"]'); - if (saveFolderBtn) { - saveFolderBtn.disabled = bulk.results.length === 0; - } - const zipBtn = document.querySelector('[onclick="App.saveAllResults()"]'); - if (zipBtn) { - zipBtn.disabled = bulk.results.length === 0; - } - const csvBtn = document.querySelector('[onclick="App.downloadHistory()"]'); - if (csvBtn) { - csvBtn.disabled = bulk.results.length === 0; - } - - // Throttle state saves to the server to ensure perfect persistence during refreshes - this.saveLastRunToServerThrottled(); - }, - - openFullscreenResults() { - const bulk = this.state.bulk; - if (bulk.results.length === 0 && !bulk.running) { - return this.toast("No results to view in fullscreen", "warning"); - } - - let modal = document.getElementById('fullscreen-results-overlay'); - const pct = bulk.total > 0 ? (bulk.completed / bulk.total) * 100 : 0; - const statusColor = bulk.error > 0 ? (bulk.success > 0 ? 'var(--warning)' : 'var(--danger)') : 'var(--success)'; - const cardsHTML = bulk.results.map(r => this.renderResultCard(r)).join(''); - const folderPath = this.state.outputFolderPath || 'None selected'; - - const contentHTML = ` -
-
- -
-

Fullscreen Batch Processing Grid

-

Real-time execution monitoring and visual results

-
-
- ${bulk.completed} / ${bulk.total} Completed - ${bulk.success} Success - ${bulk.error} Failed -
-
- -
-
- - ${folderPath} - - - -
- - - - -
-
- -
-
-
- -
- ${cardsHTML || `
Executing batch requests, processing results...
`} -
- `; - - if (!modal) { - modal = document.createElement('div'); - modal.className = 'fullscreen-results-overlay'; - modal.id = 'fullscreen-results-overlay'; - modal.innerHTML = contentHTML; - document.body.appendChild(modal); - } else { - modal.innerHTML = contentHTML; - } - }, - - closeFullscreenResults() { - const modal = document.getElementById('fullscreen-results-overlay'); - if (modal) { - modal.remove(); - } - }, - - async browseServerFolder() { - try { - const res = await fetch('/api/browse_folder', { - method: 'POST' - }); - const data = await res.json(); - if (data.success) { - this.state.outputFolderPath = data.path; - this.saveState(); - this.render(); - this.toast(`Folder selected: ${data.path}`); - } else { - this.toast(data.error || 'Failed to browse folder', 'error'); - } - } catch (e) { - this.toast(`Error browsing folder: ${e.message}`, 'error'); - } - }, - - async saveToServerFolder() { - if (!this.state.bulk.results.length) return this.toast('No results to save', 'error'); - if (!this.state.outputFolderPath) { - this.toast('Please select an output folder first', 'error'); - await this.browseServerFolder(); - if (!this.state.outputFolderPath) return; - } - - try { - this.toast('Saving files to server folder...', 'info'); - - // First ensure the latest run is persisted on the server - await this.saveLastRunToServer(); - - // Ask the server to save from its own copy (avoids sending huge binary payloads) - const res = await fetch('/api/save_folder_from_lastrun', { - method: 'POST', - headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ path: this.state.outputFolderPath }) - }); - - const data = await res.json(); - if (data.success) { - const errMsg = data.errors && data.errors.length > 0 ? ` (${data.errors.length} errors)` : ''; - this.toast(`Saved ${data.count} files to ${this.state.outputFolderPath}${errMsg}`); - if (data.errors && data.errors.length > 0) { - console.warn('Save errors:', data.errors); - } - } else { - this.toast(`Failed to save: ${data.error}`, 'error'); - } - } catch (e) { - this.toast(`Error saving to folder: ${e.message}`, 'error'); - } - }, - - async saveIndividualToServerFolder(index) { - const result = this.state.bulk.results.find(r => r.index === index); - if (!result) return; - - if (!this.state.outputFolderPath) { - this.toast('Please select an output folder first', 'error'); - await this.browseServerFolder(); - if (!this.state.outputFolderPath) return; - } - - try { - // Ensure server has latest run data - await this.saveLastRunToServer(); - - const res = await fetch('/api/save_folder_from_lastrun', { - method: 'POST', - headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ - path: this.state.outputFolderPath, - indices: [index] - }) - }); - - const data = await res.json(); - if (data.success && data.count > 0) { - this.toast(`Saved file #${index} to server folder`); - } else { - this.toast(`Failed to save: ${data.error || (data.errors && data.errors[0]) || 'Unknown error'}`, 'error'); - } - } catch (e) { - this.toast(`Error saving file: ${e.message}`, 'error'); - } - }, - - downloadIndividualResult(index) { - const result = this.state.bulk.results.find(r => r.index === index); - if (!result) return; - - try { - const finalFilename = this.getFinalFilename(result); - let blob; - - if (result.binaryData) { - const bytes = new Uint8Array(result.binaryData.match(/.{1,2}/g).map(byte => parseInt(byte, 16))); - blob = new Blob([bytes], { type: result.contentType || 'application/octet-stream' }); - } else if (result.fullContent) { - blob = new Blob([result.fullContent], { type: result.contentType || 'text/plain' }); - } else { - return this.toast('No content to download', 'error'); - } - - const url = URL.createObjectURL(blob); - const a = document.createElement('a'); - a.href = url; - a.download = finalFilename; - document.body.appendChild(a); - a.click(); - document.body.removeChild(a); - URL.revokeObjectURL(url); - - this.toast(`Downloaded "${finalFilename}"`); - } catch (e) { - this.toast(`Download failed: ${e.message}`, 'error'); - } - }, - - clearBulkResults() { - if (confirm("Are you sure you want to clear all batch results?")) { - this.state.bulk.results = []; - this.state.bulk.completed = 0; - this.state.bulk.success = 0; - this.state.bulk.error = 0; - this.state.bulk.total = 0; - this.state.bulk.running = false; - this.saveState(); - this.saveLastRunToServer(); - this.render(); - } - }, - - toggleGridMaximized() { - this.state.gridMaximized = !this.state.gridMaximized; - this.render(); - }, - - // --- Actions --- - - addParam(section) { - const item = { id: Date.now().toString() + Math.random(), key: '', value: '', type: 'text', enabled: true }; - if (section === 'params') this.state.params.push(item); - if (section === 'headers') this.state.headers.push(item); - if (section === 'body') this.state.bodyData.push(item); - this.render(); - this.saveState(); - }, - - removeParam(section, id) { - if (section === 'params') this.state.params = this.state.params.filter(p => p.id !== id); - if (section === 'headers') this.state.headers = this.state.headers.filter(p => p.id !== id); - if (section === 'body') this.state.bodyData = this.state.bodyData.filter(p => p.id !== id); - this.render(); - this.saveState(); - }, - - updateParam(section, id, field, value) { - const list = section === 'params' ? this.state.params : (section === 'headers' ? this.state.headers : this.state.bodyData); - const item = list.find(p => p.id === id); - if (item) { - item[field] = value; - this.saveState(); - // Re-render if type changes to show/hide file input - if (field === 'type' || field === 'enabled') this.render(); - } - }, - - // --- Request Execution --- - - async sendRequest() { - if (!this.state.url) return this.toast('URL is required', 'error'); - - // Reset bulk results upon sending another single request - this.state.bulk.results = []; - this.state.bulk.completed = 0; - this.state.bulk.success = 0; - this.state.bulk.error = 0; - this.state.bulk.total = 0; - - this.state.response = { status: 'Sending...', headers: {} }; - this.state.responseTab = 'response'; // Switch view - this.render(); - this.saveLastRunToServerThrottled(); - - try { - const start = Date.now(); - const res = await this.executeRequest(0); - const latency = Date.now() - start; - - res.latency = latency; - this.state.response = res; - this.saveToCollection(res.status_code || 500); - } catch (e) { - this.state.response = { error: e.message }; - } - - this.render(); - this.saveState(); - await this.saveLastRunToServer(); - }, - - // --- Bulk Execution --- - - async runBulk() { - if (!this.state.url) return this.toast('URL is required', 'error'); - - // Calculate total items based on folders or lists - let maxFiles = 0; - let maxList = 0; - const currentRunId = Date.now(); - this.state.bulk.currentRunId = currentRunId; - - // Check folders first - only those that will actually be used - const folders = [ - ...this.state.params.filter(p => p.type === 'folder' && p.enabled && p.key && p.key.trim()), - ...(this.state.bodyType === 'form-data' ? this.state.bodyData.filter(p => p.type === 'folder' && p.enabled && p.key && p.key.trim()) : []) - ]; - - if (folders.length > 0) { - // Find max file count - for (const f of folders) { - const files = this.fileStore.get(f.id); - if (files && files.length > maxFiles) maxFiles = files.length; - } - } - - // Check lists (params, body, headers) - only those with keys - const allLists = [ - ...this.state.params.filter(p => p.type === 'list' && p.enabled && p.key && p.key.trim()), - ...(this.state.bodyType === 'form-data' ? this.state.bodyData.filter(p => p.type === 'list' && p.enabled && p.key && p.key.trim()) : []), - ...this.state.headers.filter(h => h.type === 'list' && h.enabled && h.key && h.key.trim()) - ]; - - if (allLists.length > 0) { - // Find the longest list - for (const listParam of allLists) { - const val = listParam.value || ''; - const arr = val.split(/[\n,]+/).map(s => s.trim()).filter(s => s); - if (arr.length > maxList) maxList = arr.length; - } - } - - let total = 0; - if (this.state.bulk.strategy === 'cartesian' && maxFiles > 0 && maxList > 0) { - total = maxFiles * maxList; - } else { - total = Math.max(maxFiles, maxList); - } - - // If still no total, ask user - if (total === 0) { - const p = prompt('Enter number of repetitions:', '10'); - total = parseInt(p) || 0; - } - - if (total <= 0) return this.toast('Invalid bulk count', 'error'); - - // Init Bulk State - this.state.bulk.running = true; - this.state.bulk.total = total; - this.state.bulk.completed = 0; - this.state.bulk.success = 0; - this.state.bulk.error = 0; - this.state.bulk.results = []; - this.state.responseTab = 'results'; - - this.saveToCollection('BULK'); - this.render(); - - // Execution Queue - const concurrency = Math.max(1, Math.min(20, this.state.bulk.concurrency || 1)); - let active = 0; - let nextIndex = 0; - - const worker = async () => { - while (nextIndex < total && this.state.bulk.running && this.state.bulk.currentRunId === currentRunId) { - const index = nextIndex++; - active++; - - let fileIndex = index; - let listIndex = index; - if (this.state.bulk.strategy === 'cartesian' && maxFiles > 0 && maxList > 0) { - fileIndex = Math.floor(index / maxList); - listIndex = index % maxList; - } - - // Determine input filename for this index - const inputFilename = this.getInputFilename(index, fileIndex, listIndex); - - try { - const res = await this.executeRequest(index, fileIndex, listIndex); - - // Safety: if run was stopped or restarted, discard - if (this.state.bulk.currentRunId !== currentRunId) return; - - const isSuccess = res.status_code >= 200 && res.status_code < 300; - if (isSuccess) this.state.bulk.success++; else this.state.bulk.error++; - - this.state.bulk.results.push({ - index: index + 1, - status: res.status_code, - latency: res.latency || 0, - data: res.content ? res.content.substring(0, 100) : (res.binary_data ? '[Binary]' : ''), - fullContent: res.content, - binaryData: res.binary_data, - contentType: res.content_type, - headers: res.headers, - inputFilename: inputFilename - }); - - // Sort by index to maintain perfect sequence in UI and saved folders - this.state.bulk.results.sort((a, b) => a.index - b.index); - - // Limit result history to last 1000 to prevent memory issues - if (this.state.bulk.results.length > 1000) this.state.bulk.results.shift(); - - } catch (e) { - if (this.state.bulk.currentRunId !== currentRunId) return; - this.state.bulk.error++; - this.state.bulk.results.push({ - index: index + 1, - status: 'ERR', - latency: 0, - data: e.message, - inputFilename: inputFilename - }); - this.state.bulk.results.sort((a, b) => a.index - b.index); - } finally { - active--; - this.state.bulk.completed++; - - // Update the UI completely in real-time - if (this.state.bulk.currentRunId === currentRunId) { - this.updateBulkProgressUI(); - } - } - } - - if (active === 0 && nextIndex >= total && this.state.bulk.currentRunId === currentRunId) { - this.state.bulk.running = false; - this.render(); // Final render - this.toast('Bulk Operation Completed'); - await this.saveLastRunToServer(); - } - }; - - // Spawn workers - for (let i = 0; i < concurrency; i++) { - worker(); - } - }, - - stopBulk() { - this.state.bulk.running = false; - this.render(); - }, - - async executeRequest(index, fileIndex = index, listIndex = index) { - const start = Date.now(); - // Headers - const headers = {}; - this.state.headers.filter(h => h.enabled && h.key && h.key.trim()).forEach(h => { - // Handle list replacement in headers too - let val = h.value; - if (h.type === 'list') { - const arr = val.split(/[\n,]+/).map(s => s.trim()).filter(s => s); - if (arr.length > 0) val = arr[listIndex % arr.length]; - } - headers[h.key.trim()] = val; - }); - - // Auth - const auth = this.state.auth; - if (auth.type === 'bearer') headers['Authorization'] = `Bearer ${auth.token}`; - else if (auth.type === 'basic') headers['Authorization'] = 'Basic ' + btoa(`${auth.username}:${auth.password}`); - else if (auth.type === 'apikey') headers[auth.key] = auth.value; - - // URL Params - const urlObj = new URL(this.state.url); - this.state.params.filter(p => p.enabled && p.key && p.key.trim()).forEach(p => { - let val = p.value; - // List handling - if (p.type === 'list') { - // Try splitting by newline first if present, else comma - const arr = val.split(/[\n,]+/).map(s => s.trim()).filter(s => s); - if (arr.length > 0) val = arr[listIndex % arr.length]; - } - // File logic not applicable for URL params usually, skipping - urlObj.searchParams.append(p.key, val); - }); - - // Payload Construction - const finalData = new FormData(); - finalData.append('method', this.state.method); - finalData.append('url', urlObj.toString()); - finalData.append('headers', JSON.stringify(headers)); - // Add auth config for server-side handling if needed (e.g. Basic Auth via requests arg) - if (auth.type === 'basic') finalData.append('auth', JSON.stringify({ type: 'basic', username: auth.username, password: auth.password })); - - // Body - if (this.state.bodyType === 'json') { - finalData.append('body_type', 'json'); - finalData.append('body', this.state.jsonBody); - } else if (this.state.bodyType === 'form-data') { - finalData.append('body_type', 'form-data'); - this.state.bodyData.filter(p => p.enabled && (p.type === 'file' || p.type === 'folder' || (p.key && p.key.trim()))).forEach(p => { - if (p.type === 'file' || p.type === 'folder') { - const files = this.fileStore.get(p.id); - if (files && files.length > 0) { - if (p.type === 'folder') { - // Folder iteration - finalData.append(p.key, files[fileIndex % files.length]); - } else { - // Single file input: send all files attached? or iterate? - // If it's a "File" type but multiple files selected, usually implies multi-upload. - // If bulk mode, maybe we want to iterate? - // Current logic: Send ALL files in the input for this request. - for (let f of files) finalData.append(p.key, f); - } - } - } else { - let val = p.value; - if (p.type === 'list') { - const arr = val.split(/[\n,]+/).map(s => s.trim()).filter(s => s); - if (arr.length > 0) val = arr[listIndex % arr.length]; - } - finalData.append(p.key, val); - } - }); - } - - const res = await fetch('/api/proxy-request', { - method: 'POST', - body: finalData - }); - - const data = await res.json(); - data.latency = Date.now() - start; - return data; - }, - - saveToCollection(lastStatus) { - if (!this.state.url) return; - - // Find or create default collection - let col = this.collections.find(c => c.id === this.state.activeCollectionId); - if (!col) { - col = this.collections.find(c => c.id === 'default'); - if(!col) { - col = { id: 'default', name: 'My Requests', requests: [] }; - this.collections.push(col); - } - this.state.activeCollectionId = col.id; - } - - // Deep copy current request data - const reqData = { - id: this.state.activeRequestId || Date.now().toString(), - name: this.state.url.split('?')[0].split('/').pop() || 'Root URL', - method: this.state.method, - url: this.state.url, - params: JSON.parse(JSON.stringify(this.state.params)), - headers: JSON.parse(JSON.stringify(this.state.headers)), - auth: JSON.parse(JSON.stringify(this.state.auth)), - bodyType: this.state.bodyType, - bodyData: JSON.parse(JSON.stringify(this.state.bodyData)), - jsonBody: this.state.jsonBody, - lastStatus: lastStatus, - lastTime: new Date().toLocaleTimeString() - }; - - const existingIdx = col.requests.findIndex(r => r.id === reqData.id || (r.url === reqData.url && r.method === reqData.method)); - - if (existingIdx >= 0) { - // Update existing - reqData.id = col.requests[existingIdx].id; // preserve ID - reqData.name = col.requests[existingIdx].name; // preserve custom name - col.requests[existingIdx] = reqData; - } else { - // Add new - col.requests.unshift(reqData); - } - - this.state.activeRequestId = reqData.id; - this.saveState(); - this.saveSpacesToServer(); - }, - - loadRequest(colId, reqId) { - const col = this.collections.find(c => c.id === colId); - if(!col) return; - const req = col.requests.find(r => r.id === reqId); - if(!req) return; - - this.state.activeCollectionId = colId; - this.state.activeRequestId = reqId; - this.state.method = req.method; - this.state.url = req.url; - this.state.params = JSON.parse(JSON.stringify(req.params || [])); - this.state.headers = JSON.parse(JSON.stringify(req.headers || [])); - this.state.auth = JSON.parse(JSON.stringify(req.auth || {type:'none'})); - this.state.bodyType = req.bodyType || 'none'; - this.state.bodyData = JSON.parse(JSON.stringify(req.bodyData || [])); - this.state.jsonBody = req.jsonBody || ''; - this.state.response = null; - - this.render(); - }, - - deleteRequest(colId, reqId) { - const col = this.collections.find(c => c.id === colId); - if(col) col.requests = col.requests.filter(r => r.id !== reqId); - if(this.state.activeRequestId === reqId) this.state.activeRequestId = null; - this.saveState(); - this.saveSpacesToServer(); - this.render(); - }, - - createCollection() { - const name = prompt("Collection Name:"); - if(name) { - const id = 'col_' + Date.now(); - this.collections.push({ id, name, requests: [] }); - this.state.activeCollectionId = id; - this.saveState(); - this.saveSpacesToServer(); - this.render(); - } - }, - - renameCollection(colId) { - if(colId === 'default') return this.toast("Cannot rename default collection", "error"); - const col = this.collections.find(c => c.id === colId); - if(!col) return; - const newName = prompt("Enter new collection name:", col.name); - if(newName && newName.trim()) { - col.name = newName.trim(); - this.saveState(); - this.saveSpacesToServer(); - this.render(); - } - }, - - renameRequest(colId, reqId) { - const col = this.collections.find(c => c.id === colId); - if(!col) return; - const req = col.requests.find(r => r.id === reqId); - if(!req) return; - const newName = prompt("Enter new request name:", req.name); - if(newName && newName.trim()) { - req.name = newName.trim(); - this.saveState(); - this.saveSpacesToServer(); - this.render(); - } - }, - - deleteCollection(colId) { - if(colId === 'default') return this.toast("Cannot delete default collection", "error"); - if(confirm("Delete this collection entirely?")) { - this.collections = this.collections.filter(c => c.id !== colId); - if(this.state.activeCollectionId === colId) this.state.activeCollectionId = 'default'; - this.saveState(); - this.saveSpacesToServer(); - this.render(); - } - }, - - addRequestToCollection(colId) { - const col = this.collections.find(c => c.id === colId); - if (!col) return; - const reqId = 'req_' + Date.now(); - const newReq = { - id: reqId, - name: 'New Request', - method: 'GET', - url: '', - description: '', - params: [{ id: Date.now().toString() + Math.random(), key: '', value: '', type: 'text', enabled: true }], - headers: [{ id: Date.now().toString() + Math.random(), key: '', value: '', type: 'text', enabled: true }], - auth: { type: 'none' }, - bodyType: 'none', - bodyData: [], - jsonBody: '' - }; - col.requests.push(newReq); - - // Auto-select this request - this.state.activeCollectionId = colId; - this.state.activeRequestId = reqId; - this.state.method = newReq.method; - this.state.url = newReq.url; - this.state.params = newReq.params; - this.state.headers = newReq.headers; - this.state.auth = newReq.auth; - this.state.bodyType = newReq.bodyType; - this.state.bodyData = newReq.bodyData; - this.state.jsonBody = newReq.jsonBody; - this.state.response = null; - - this.saveState(); - this.saveSpacesToServer(); - this.render(); - this.toast("Added new request to collection"); - }, - - updateActiveRequestName(name) { - const activeSpace = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - const col = activeSpace ? activeSpace.collections.find(c => c.id === this.state.activeCollectionId) : null; - const activeReq = col ? col.requests.find(r => r.id === this.state.activeRequestId) : null; - if (activeReq) { - activeReq.name = name.trim() || 'Untitled Request'; - this.saveState(); - this.saveSpacesToServer(); - this.render(); - } - }, - - updateActiveRequestDescription(desc) { - const activeSpace = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - const col = activeSpace ? activeSpace.collections.find(c => c.id === this.state.activeCollectionId) : null; - const activeReq = col ? col.requests.find(r => r.id === this.state.activeRequestId) : null; - if (activeReq) { - activeReq.description = desc; - this.saveState(); - this.saveSpacesToServer(); - } - }, - - downloadHistory() { - if (!this.state.bulk.results.length) return; - - const csvContent = "data:text/csv;charset=utf-8," - + "Index,Status,Latency (ms),Snippet\n" - + this.state.bulk.results.map(r => `${r.index},${r.status},${r.latency},"${(r.data || '').replace(/"/g, '""').replace(/\n/g, ' ')}"`).join("\n"); - - const encodedUri = encodeURI(csvContent); - const link = document.createElement("a"); - link.setAttribute("href", encodedUri); - link.setAttribute("download", `bulk_results_${new Date().toISOString()}.csv`); - document.body.appendChild(link); - link.click(); - document.body.removeChild(link); - }, - - // Get the input filename for a given bulk index - getInputFilename(index, fileIndex = index, listIndex = index) { - // Build list of active params that could provide a name - const activeParams = [ - ...this.state.params.filter(p => p.enabled && p.key && p.key.trim()), - ...(this.state.bodyType === 'form-data' ? this.state.bodyData.filter(p => p.enabled && p.key && p.key.trim()) : []) - ]; - - let folderName = null; - // Priority 1: Folder type (usually high-intent for naming) - const folderParam = activeParams.find(p => p.type === 'folder'); - if (folderParam) { - const files = this.fileStore.get(folderParam.id); - if (files && files.length > 0) { - const file = files[fileIndex % files.length]; - folderName = file.webkitRelativePath || file.name; - } - } - - let listName = null; - // Priority 2: List in Body (user's specific request context) - if (this.state.bodyType === 'form-data') { - const bodyList = this.state.bodyData.find(p => p.type === 'list' && p.enabled && p.key && p.key.trim()); - if (bodyList) { - const arr = bodyList.value.split(/[\n,]+/).map(s => s.trim()).filter(s => s); - if (arr.length > 0) listName = arr[listIndex % arr.length]; - } - } - - // Priority 3: Any other list - if (!listName) { - const listParam = activeParams.find(p => p.type === 'list'); - if (listParam) { - const val = listParam.value || ''; - const arr = val.split(/[\n,]+/).map(s => s.trim()).filter(s => s); - if (arr.length > 0) listName = arr[listIndex % arr.length]; - } - } - - if (folderName && listName) { - // Strip extension from folderName, add listName, re-add extension - let base = folderName; - let ext = ''; - const lastDot = folderName.lastIndexOf('.'); - if (lastDot !== -1 && lastDot > 0 && folderName.length - lastDot <= 6) { - base = folderName.substring(0, lastDot); - ext = folderName.substring(lastDot); - } - // Replace any invalid characters in listName just in case, though usually fine - const safeListName = listName.replace(/[\/\\]/g, '_'); - return `${base}_${safeListName}${ext}`; - } else if (folderName) { - return folderName; - } else if (listName) { - return listName; - } - - return `result_${index + 1}`; - }, - - // Get the final filename with appropriate extension if missing - getFinalFilename(result) { - let name = result.inputFilename || `result_${result.index}`; - - // Check if name already has a likely extension (last dot within 5 chars of end) - const parts = name.split('.'); - const hasExt = parts.length > 1 && parts[parts.length-1].length <= 5; - if (hasExt) return name; - - // Map common content types - const ct = (result.contentType || '').toLowerCase(); - if (ct.includes('image/png')) return name + '.png'; - if (ct.includes('image/jpeg') || ct.includes('image/jpg')) return name + '.jpg'; - if (ct.includes('image/gif')) return name + '.gif'; - if (ct.includes('image/webp')) return name + '.webp'; - if (ct.includes('image/svg')) return name + '.svg'; - if (ct.includes('application/pdf')) return name + '.pdf'; - if (ct.includes('application/json')) return name + '.json'; - if (ct.includes('application/xml') || ct.includes('text/xml')) return name + '.xml'; - if (ct.includes('text/html')) return name + '.html'; - if (ct.includes('text/csv')) return name + '.csv'; - if (ct.includes('text/css')) return name + '.css'; - if (ct.includes('text/plain')) return name + '.txt'; - if (ct.includes('application/zip')) return name + '.zip'; - - // Fallback for other binary types: try to extract subtype - if (result.binaryData && ct.includes('/')) { - const subtype = ct.split('/')[1].split(';')[0]; // handle "type/subtype;charset=..." - if (subtype && subtype.length <= 4 && /^[a-z0-9]+$/.test(subtype)) { - return name + '.' + subtype; - } - } - - return name; - }, - - async saveAsFolder() { - if (!this.state.bulk.results.length) return this.toast('No results to save', 'error'); - - try { - if (!window.showDirectoryPicker) { - return this.toast('Your browser does not support native folder saving. Please use the ZIP button instead.', 'error'); - } - - this.toast('Select a folder to save files...', 'info'); - const dirHandle = await window.showDirectoryPicker({ - mode: 'readwrite' - }); - - let savedCount = 0; - let errors = 0; - const usedNames = new Set(); - - for (const r of this.state.bulk.results) { - try { - let filename = this.getFinalFilename(r); - - let base = filename; - let ext = ''; - const lastDot = filename.lastIndexOf('.'); - if (lastDot !== -1 && lastDot > 0) { - base = filename.substring(0, lastDot); - ext = filename.substring(lastDot); - } - - let counter = 1; - while (usedNames.has(filename)) { - filename = `${base}_${counter}${ext}`; - counter++; - } - usedNames.add(filename); - - // Get the content as binary data - let data; - if (r.binaryData) { - // Convert hex string to Uint8Array - data = new Uint8Array(r.binaryData.match(/.{1,2}/g).map(byte => parseInt(byte, 16))); - } else if (r.fullContent) { - data = r.fullContent; - } else { - continue; // Skip empty results - } - - // Create file and write content - const fileHandle = await dirHandle.getFileHandle(filename, { create: true }); - const writable = await fileHandle.createWritable(); - await writable.write(data); - await writable.close(); - - savedCount++; - } catch (e) { - console.error('Error saving file', r.index, e); - errors++; - } - } - - if (errors > 0) { - this.toast(`Saved ${savedCount} files. Failed to save ${errors} files.`, 'warning'); - } else { - this.toast(`Successfully saved ${savedCount} files to the selected folder.`); - } - - } catch (e) { - console.error(e); - if (e.name === 'AbortError') { - this.toast('Folder selection cancelled.', 'info'); - } else { - this.toast('Failed to save to folder: ' + e.message, 'error'); - } - } - }, - - async saveAllResults() { - if (!this.state.bulk.results.length) return this.toast('No results to save', 'error'); - if (typeof JSZip === 'undefined') return this.toast('JSZip library not loaded. Please refresh.', 'error'); - - this.toast('Building ZIP file...', 'info'); - - const zip = new JSZip(); - let savedCount = 0; - const usedNames = new Set(); - - for (const result of this.state.bulk.results) { - try { - // Use the tracked input filename + auto extension - let filename = this.getFinalFilename(result); - - let base = filename; - let ext = ''; - const lastDot = filename.lastIndexOf('.'); - if (lastDot !== -1 && lastDot > 0) { - base = filename.substring(0, lastDot); - ext = filename.substring(lastDot); - } - - let counter = 1; - while (usedNames.has(filename)) { - filename = `${base}_${counter}${ext}`; - counter++; - } - usedNames.add(filename); - - // Get the content as binary data - let data; - if (result.binaryData) { - // Convert hex string to Uint8Array - data = new Uint8Array(result.binaryData.match(/.{1,2}/g).map(byte => parseInt(byte, 16))); - } else if (result.fullContent) { - data = result.fullContent; - } else { - continue; // Skip empty results - } - - // Add to ZIP (JSZip handles folder creation from path automatically) - zip.file(filename, data, { binary: !!result.binaryData }); - savedCount++; - } catch (e) { - console.error('Error adding result to ZIP', result.index, e); - } - } - - if (savedCount === 0) return this.toast('No valid results to save', 'error'); - - // Generate and download ZIP - try { - const blob = await zip.generateAsync({ type: 'blob' }); - const url = URL.createObjectURL(blob); - const a = document.createElement('a'); - a.href = url; - a.download = `bulk_results_${new Date().toISOString().replace(/[:.]/g, '-')}.zip`; - document.body.appendChild(a); - a.click(); - document.body.removeChild(a); - URL.revokeObjectURL(url); - - this.toast(`ZIP saved with ${savedCount} files`, 'info'); - } catch (e) { - this.toast('Error generating ZIP: ' + e.message, 'error'); - } - }, - - // --- Rendering --- - - render() { - const root = document.getElementById('app-root'); - if (root) { - // Reset base class first to prevent layout/theme clashing - root.className = 'workspace'; - - if (this.state.bulk.results.length > 0 || this.state.bulk.running) { - root.classList.add('bulk-active'); - } - if (this.state.gridMaximized || !this.state.activeSpaceId) { - root.classList.add('grid-maximized'); - } - - // Add theme class for active space - if (this.state.activeSpaceId) { - const activeSpace = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - const theme = activeSpace && activeSpace.theme ? activeSpace.theme : 'violet'; - root.classList.add(`theme-${theme}`); - } - } - this.renderSidebar(); - this.renderMain(); - this.renderResponse(); - }, - - renderProgress() { - // Optimized partial render for progress bar - const bar = document.getElementById('progress-bar-fill'); - const text = document.getElementById('progress-text'); - if (bar && text) { - const pct = (this.state.bulk.completed / this.state.bulk.total) * 100; - bar.style.width = `${pct}%`; - text.innerText = `${this.state.bulk.completed} / ${this.state.bulk.total}`; - } - }, - - getCollectionsHTML() { - const query = (this.state.searchQuery || '').toLowerCase().trim(); - let collectionsHTML = ''; - - this.collections.forEach(col => { - const isColActive = this.state.activeCollectionId === col.id; - - // Filter requests - const filteredRequests = col.requests.filter(r => { - if (!query) return true; - return ( - (r.name || '').toLowerCase().includes(query) || - (r.url || '').toLowerCase().includes(query) || - (r.description || '').toLowerCase().includes(query) - ); - }); - - // Decide if the collection itself matches - const colMatches = (col.name || '').toLowerCase().includes(query); - - // If neither collection matches nor has matching requests, skip rendering it - if (query && !colMatches && filteredRequests.length === 0) { - return; - } - - // If there's a query and we have matches, auto-expand the collection - const isExpanded = query ? true : isColActive; - - const reqsHTML = (query && colMatches ? col.requests : filteredRequests).map(r => ` -
- ${r.method} -
-
- ${this.escapeHTML(r.name || '')} -
-
- ${this.escapeHTML(r.url || 'No URL')} -
-
- - -
- `).join(''); - - collectionsHTML += ` -
-
- - ${this.escapeHTML(col.name)} - - - - ${col.id !== 'default' ? ` - - - ` : ''} -
- ${isExpanded ? `
${reqsHTML || '
Empty Collection
'}
` : ''} -
- `; - }); - - return collectionsHTML; - }, - - filterSidebarCollections(query) { - this.state.searchQuery = query; - const listEl = document.getElementById('sidebar-collections-list'); - if (listEl) { - listEl.innerHTML = this.getCollectionsHTML(); - } - - // Also update clear button visibility - const clearBtn = document.getElementById('search-clear-btn'); - if (clearBtn) { - clearBtn.style.display = query ? 'block' : 'none'; - } - }, - - renderSidebar() { - const collectionsHTML = this.getCollectionsHTML(); - const activeSpace = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - - let notificationsBannerHTML = ''; - if (activeSpace && activeSpace.notifications && activeSpace.notifications.length > 0) { - notificationsBannerHTML = ` -
- - You have ${activeSpace.notifications.length} pending share request${activeSpace.notifications.length > 1 ? 's' : ''} -
- `; - } - - const spaceOptionsHTML = ` - - ${this.state.spaces.map(s => ` - - `).join('')} - `; - - const sidebarHeaderHTML = ` - - `; - - this.dom.sidebar.innerHTML = ` - ${sidebarHeaderHTML} - - ${activeSpace ? ` - ${notificationsBannerHTML} - - - - - - ` : ` -
- Select a workspace from the dashboard to view collections -
- `} - -
- -
- `; - }, - - renderMain() { - if (!this.state.activeSpaceId) { - // Render Spaces Dashboard Grid View - const spacesCardsHTML = this.state.spaces.map(s => { - const count = s.collections ? s.collections.length : 0; - const notifCount = s.notifications ? s.notifications.length : 0; - const theme = s.theme || 'violet'; - return ` -
-
- - ${notifCount > 0 ? `${notifCount}` : ''} -
-
-

${this.escapeHTML(s.name)}

- ${count} Collections -
-
- - ${this.state.spaces.length > 1 ? ` - - ` : ''} -
-
- `; - }).join(''); - - const dashboardHTML = ` -
-
-

Workspaces

-

Select a workspace to access its collections, endpoints, and history.

-
- -
- ${spacesCardsHTML} - -
-
-
-

Create New Space

- Add a clean workspace -
-
-
-
- `; - - const headerHTML = ` -
-
PHOENIX
-
- Workspace Dashboard -
-
-
- `; - - this.dom.mainPanel.innerHTML = headerHTML + dashboardHTML; - return; - } - - const isBulkStart = this.checkBulkStart(); - const bulk = this.state.bulk; - const activeSpace = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - - // Header with Active Space name/switcher - const headerHTML = ` -
-
- PHOENIX -
-
- ${this.escapeHTML(activeSpace ? activeSpace.name : '')} - -
- - -
- -
- -
- - -
- -
- ${bulk.running - ? `` - : `` - } -
-
- `; - - // Request Name & Description Details Section - const col = activeSpace ? activeSpace.collections.find(c => c.id === this.state.activeCollectionId) : null; - const activeReq = col ? col.requests.find(r => r.id === this.state.activeRequestId) : null; - - const requestMetaHTML = activeReq ? ` -
-
- Request Name: - -
-
- Description: - -
-
- ` : ''; - - // Tabs - const tabsHTML = ` -
- ${['params', 'headers', 'body', 'auth'].map(t => ` -
${t.toUpperCase()}
- `).join('')} -
- ${isBulkStart ? ` -
-
- Strategy: - - -
-
- Concurrency: - -
-
- ` : ''} -
- `; - - // Content - let contentHTML = ''; - if (this.state.activeTab === 'params') contentHTML = this.renderTable(this.state.params, 'params'); - else if (this.state.activeTab === 'headers') contentHTML = this.renderTable(this.state.headers, 'headers'); - else if (this.state.activeTab === 'body') contentHTML = this.renderBodyTab(); - else if (this.state.activeTab === 'auth') contentHTML = this.renderAuthTab(); - - // Bottom Results & Response Panel (Always Rendered) - const pct = bulk.total > 0 ? (bulk.completed / bulk.total) * 100 : 0; - const statusColor = bulk.error > 0 ? (bulk.success > 0 ? 'var(--warning)' : 'var(--danger)') : 'var(--success)'; - const cardsHTML = bulk.results.map(r => this.renderResultCard(r)).join(''); - const folderPath = this.state.outputFolderPath || 'None selected'; - const activeBottomTab = this.state.responseTab || 'response'; - - let bottomTabContentHTML = ''; - if (activeBottomTab === 'response') { - const resp = this.state.response; - if (!resp) { - bottomTabContentHTML = `
Ready to send request. Click SEND to execute a single request, or RUN BATCH for bulk.
`; - } else if (resp.status === 'Sending...') { - bottomTabContentHTML = `
Sending request...
`; - } else if (resp.error) { - bottomTabContentHTML = `
Error: ${resp.error}
`; - } else { - let content = resp.content; - try { - if (content && !resp.binary_data && content.trim().startsWith('{')) { - content = JSON.stringify(JSON.parse(content), null, 2); - } - } catch(e){} - - bottomTabContentHTML = ` -
- ${resp.status_code} - ${resp.latency ? resp.latency + ' ms' : ''} - ${resp.content_type || 'Unknown Type'} -
-
- ${resp.binary_data - ? `
- Binary Content -
` - : `
${this.escapeHTML(content)}
` - } -
- `; - } - } else { - if (bulk.results.length === 0) { - bottomTabContentHTML = ` -
- - No batch results yet. Run a batch to see results in a grid. -
- `; - } else { - bottomTabContentHTML = ` -
-
-
-
- ${cardsHTML} -
- `; - } - } - - bottomPanelHTML = ` -
-
-
- -
-
-
- - -
- - ${bulk.results.length > 0 ? ` -
- ${bulk.completed} / ${bulk.total} Completed - ${bulk.success} Success - ${bulk.error} Failed -
- ` : ''} -
- - ${activeBottomTab === 'results' && bulk.results.length > 0 ? ` -
-
- - ${folderPath} - - - -
- - - - - -
- ` : ''} -
- -
- ${bottomTabContentHTML} -
-
- `; - - this.dom.mainPanel.innerHTML = headerHTML + requestMetaHTML + tabsHTML + `
${contentHTML}
` + bottomPanelHTML; - }, - - renderResultCard(result) { - const isImage = (result.contentType || '').toLowerCase().includes('image') && result.binaryData; - const isSuccess = result.status >= 200 && result.status < 300; - const statusClass = isSuccess ? 'status-success' : 'status-error'; - const filename = result.inputFilename || `result_${result.index}`; - const finalFilename = this.getFinalFilename(result); - - let previewHTML = ''; - if (isImage) { - try { - const base64Data = this.hexToBase64(result.binaryData); - previewHTML = `${filename}`; - } catch (e) { - previewHTML = `
Decode error
`; - } - } else { - let icon = 'fa-file-lines'; - let typeLabel = 'TXT'; - const ct = (result.contentType || '').toLowerCase(); - if (ct.includes('application/json')) { icon = 'fa-file-code'; typeLabel = 'JSON'; } - else if (ct.includes('text/html')) { icon = 'fa-file-code'; typeLabel = 'HTML'; } - else if (result.status === 'ERR') { icon = 'fa-circle-xmark'; typeLabel = 'ERROR'; } - previewHTML = ` -
- - ${typeLabel} -

${this.escapeHTML(result.data || '')}

-
`; - } - - const footerHTML = isImage - ? `` - : `
-
- #${result.index} - ${result.status} - ${result.latency}ms -
-
${finalFilename}
-
`; - - return ` -
-
- ${previewHTML} -
- ${!isImage ? ` - ` : ''} - - - -
-
- ${footerHTML} -
- `; - }, - - renderResponse() { - // No-op: Single response and bulk results have been consolidated into renderMain()'s bottom panel. - }, - - renderTable(items, section) { - return ` - - - - ${items.map(item => ` - - - - - - - `).join('')} - -
KeyValue
- - ${this.renderValueInput(item, section)} -
- - `; - }, - - renderValueInput(item, section) { - if (item.type === 'file' || item.type === 'folder') { - const files = this.fileStore.get(item.id); - const label = files ? (item.type === 'folder' ? `${files.length} Files Selected` : `${files.length} Files`) : 'Select...'; - return ` -
- - -
- `; - } - return ``; - }, - - renderBodyTab() { - return ` -
-
- - - -
- - ${this.state.bodyType === 'form-data' ? this.renderTable(this.state.bodyData, 'body') : ''} - ${this.state.bodyType === 'json' ? `` : ''} -
- `; - }, - - renderAuthTab() { - const auth = this.state.auth; - return ` -
- - - - ${auth.type === 'bearer' ? ` -
- - -
- ` : ''} - - ${auth.type === 'basic' ? ` -
-
-
-
- ` : ''} - - ${auth.type === 'apikey' ? ` -
-
-
-
- ` : ''} -
- `; - }, - - // --- Helpers --- - - handleFileSelect(input, section, id) { - if (input.files.length > 0) { - // Convert FileList to Array and sort by path to ensure strict processing sequence (natural sorting) - let filesArr = Array.from(input.files); - filesArr.sort((a, b) => { - const pA = a.webkitRelativePath || a.name; - const pB = b.webkitRelativePath || b.name; - return pA.localeCompare(pB, undefined, { numeric: true, sensitivity: 'base' }); - }); - this.fileStore.set(id, filesArr); - this.render(); // update label - } - }, - - checkBulkStart() { - const hasKeyedFolder = this.state.params.some(p => p.type === 'folder' && p.enabled && p.key && p.key.trim()) - || (this.state.bodyType === 'form-data' && this.state.bodyData.some(p => p.type === 'folder' && p.enabled && p.key && p.key.trim())); - - const hasKeyedList = this.state.params.some(p => p.type === 'list' && p.enabled && p.key && p.key.trim()) - || (this.state.bodyType === 'form-data' && this.state.bodyData.some(p => p.type === 'list' && p.enabled && p.key && p.key.trim())) - || this.state.headers.some(h => h.type === 'list' && h.enabled && h.key && h.key.trim()); - - return hasKeyedFolder || hasKeyedList; - }, - - getStatusColor(code) { - if (code >= 200 && code < 300) return 'var(--success)'; - if (code >= 300 && code < 400) return 'var(--warning)'; - if (code >= 400 || code === 'ERR') return 'var(--danger)'; - return 'var(--text-muted)'; - }, - - toast(msg, type = 'info') { - const t = document.createElement('div'); - t.innerText = msg; - t.style.cssText = ` - background: ${type === 'error' ? '#EF4444' : '#333'}; - color: white; padding: 10px 20px; border-radius: 6px; margin-top: 10px; - box-shadow: 0 4px 12px rgba(0,0,0,0.5); font-size: 13px; - `; - this.dom.toast.appendChild(t); - setTimeout(() => t.remove(), 3000); - }, - - escapeHTML(str) { - if (!str) return ''; - if (typeof str !== 'string') return String(str); - return str.replace(/&/g, '&') - .replace(//g, '>') - .replace(/"/g, '"') - .replace(/'/g, '''); - }, - - hexToBase64(hexString) { - if (!hexString) return ''; - // Strip any whitespace or non-hex chars - hexString = hexString.replace(/[^0-9a-fA-F]/g, ''); - const len = hexString.length; - const bytes = new Uint8Array(len / 2); - for (let i = 0; i < len; i += 2) { - bytes[i / 2] = parseInt(hexString.substr(i, 2), 16); - } - let binary = ''; - const chunk = 8192; - for (let i = 0; i < bytes.length; i += chunk) { - const subarr = bytes.subarray(i, i + chunk); - binary += String.fromCharCode.apply(null, subarr); - } - return btoa(binary); - }, - - bindEvents() { - // Most events are inline (onclick, onchange) for simplicity in this structure - }, - - // Preview a result - previewResult(index) { - const result = this.state.bulk.results.find(r => r.index === index); - if (!result) return; - - const isImage = (result.contentType || '').toLowerCase().includes('image') && result.binaryData; - const finalFilename = this.getFinalFilename(result); - - let contentHTML = ''; - if (isImage) { - try { - const base64Data = this.hexToBase64(result.binaryData); - contentHTML = `${finalFilename}`; - } catch (e) { - contentHTML = ``; - } - } else { - let prettyContent = result.fullContent || ''; - try { - if (prettyContent.trim().startsWith('{')) { - prettyContent = JSON.stringify(JSON.parse(prettyContent), null, 2); - } - } catch(e) {} - contentHTML = ``; - } - - const modal = document.createElement('div'); - modal.className = 'premium-modal-overlay'; - - modal.innerHTML = ` -
-
-
- -
- ${finalFilename} - Result #${result.index} -
-
-
- ${result.status} - ${result.latency}ms - -
-
-
- ${contentHTML} -
- -
- `; - - document.body.appendChild(modal); - modal.onclick = () => modal.remove(); - }, - - // For manual clicking from history - loadHistoryItem(id) { - const item = this.state.history.find(h => h.id === id); - if (item) { - this.state.method = item.method; - this.state.url = item.url; - this.saveState(); - this.render(); - } - } -}; - - -document.addEventListener('DOMContentLoaded', () => App.init()); - diff --git a/web/bulk-api-tester/static/js/app.js.bak_beforev20 b/web/bulk-api-tester/static/js/app.js.bak_beforev20 deleted file mode 100644 index 25037e2..0000000 --- a/web/bulk-api-tester/static/js/app.js.bak_beforev20 +++ /dev/null @@ -1,2967 +0,0 @@ -/** - * Phoenix App - Advanced Bulk API Tester - * Version: 2.0 (Agentic Edition) - */ - -const App = { - _stateData: { - spaces: [], - activeSpaceId: null, - activeCollectionId: 'default', - - outputFolderPath: '', - gridMaximized: false, - resultsPanelHeight: 300, - sidebarWidth: 270, - searchQuery: '' - }, - - tabs: [], - activeTabIndex: 0, - - get state() { - if (!this._proxyState) { - const props = ['name', 'method', 'url', 'params', 'headers', 'auth', 'bodyType', 'bodyData', 'jsonBody', 'response', 'bulk', 'activeTab', 'responseTab', 'activeRequestId', 'isPreview', 'activeCollectionId']; - this._proxyState = new Proxy(this._stateData, { - get(target, prop) { - if (props.includes(prop)) { - if (App.tabs && App.tabs[App.activeTabIndex]) { - return App.tabs[App.activeTabIndex][prop]; - } - } - return target[prop]; - }, - set(target, prop, value) { - if (props.includes(prop)) { - if (App.tabs && App.tabs[App.activeTabIndex]) { - App.tabs[App.activeTabIndex][prop] = value; - if (prop !== 'activeTab' && prop !== 'responseTab' && prop !== 'activeRequestId') { - App.tabs[App.activeTabIndex].isPreview = false; - } - - // Auto-save to localStorage only (no server call on every keypress) - - return true; - } - } - target[prop] = value; - return true; - } - }); - } - return this._proxyState; - }, - - debouncedSaveToCollection() { - if (this._autoSaveTimeout) clearTimeout(this._autoSaveTimeout); - this._autoSaveTimeout = setTimeout(() => { - this.saveToCollection(); - }, 500); - }, - - createNewTab(reqData, isPreview = false) { - return { - id: 'tab_' + Date.now() + Math.random().toString(36).substr(2, 9), - name: reqData ? reqData.name : 'Untitled Request', - method: reqData ? reqData.method : 'POST', - url: reqData ? reqData.url : '', - params: reqData ? JSON.parse(JSON.stringify(reqData.params || [])) : [], - headers: reqData ? JSON.parse(JSON.stringify(reqData.headers || [])) : [], - auth: reqData ? JSON.parse(JSON.stringify(reqData.auth || {type:'none'})) : {type:'none'}, - bodyType: reqData ? reqData.bodyType : 'none', - bodyData: reqData ? JSON.parse(JSON.stringify(reqData.bodyData || [])) : [], - jsonBody: reqData ? reqData.jsonBody : '', - response: null, - bulk: reqData && reqData.bulk ? JSON.parse(JSON.stringify(reqData.bulk)) : { - strategy: 'consecutive', - running: false, - total: 0, - completed: 0, - success: 0, - error: 0, - concurrency: 1, - delay: 0, - repetitions: 10, - results: [] - }, - activeTab: 'params', - responseTab: 'response', - activeRequestId: reqData ? reqData.id : null, - activeCollectionId: reqData ? reqData.activeCollectionId : 'default', - isPreview: isPreview - }; - }, - - - fileStore: new Map(), // id -> FileList - - dom: {}, - - async init() { - this.loadState(); - this.cacheDOM(); - this.bindEvents(); - - // Ensure active tab has at least one param and header row - if (!this.state.params || this.state.params.length === 0) this.addParam('params'); - if (!this.state.headers || this.state.headers.length === 0) this.addParam('headers'); - - // Load spaces from the server to keep them synced - await this.loadSpacesFromServer(); - - // Load the last run results/response from the server - await this.loadLastRunFromServer(); - - // Apply saved sidebar width - const sidebarEl = document.getElementById('sidebar'); - if (sidebarEl && this._stateData.sidebarWidth) { - sidebarEl.style.width = `${this._stateData.sidebarWidth}px`; - } - - // Attach event listener for horizontal sidebar dragging - const handle = document.getElementById('sidebar-resize-handle'); - if (handle) { - handle.addEventListener('mousedown', (e) => this.startSidebarResize(e)); - } - - this.render(); - - // Remove loader - const loader = document.getElementById('loading-overlay'); - if (loader) loader.remove(); - document.getElementById('app-root').style.visibility = 'visible'; - }, - - // --- Tab Management --- - - openNewTab() { - const newTab = this.createNewTab(); - this.tabs.push(newTab); - this.activeTabIndex = this.tabs.length - 1; - if (!this.state.params || this.state.params.length === 0) this.addParam('params'); - if (!this.state.headers || this.state.headers.length === 0) this.addParam('headers'); - this.saveState(); - this.render(); - }, - - switchTab(index) { - if (index < 0 || index >= this.tabs.length) return; - this.activeTabIndex = index; - this.saveState(); - this.render(); - }, - - closeTab(index) { - if (this.tabs.length <= 1) { - // Can't close last tab; just reset it - this.tabs[0] = this.createNewTab(); - this.activeTabIndex = 0; - this.saveState(); - this.render(); - return; - } - this.tabs.splice(index, 1); - if (this.activeTabIndex >= this.tabs.length) { - this.activeTabIndex = this.tabs.length - 1; - } - this.saveState(); - this.render(); - }, - - cacheDOM() { - this.dom = { - mainPanel: document.getElementById('main-panel'), - sidebar: document.getElementById('sidebar'), - toast: document.getElementById('toast-container') - }; - - if (!this.dom.sidebar || !this.dom.mainPanel) { - console.error('Critical: DOM elements not found', this.dom); - alert('Critical Error: Application DOM structure is missing. Please refresh.'); - } - }, - - // --- State Management --- - - loadState() { - try { - const raw = localStorage.getItem('phoenix-state-v2'); - if (raw) { - const data = JSON.parse(raw); - // Restore _stateData (global state) - if (data.spaces !== undefined) this._stateData.spaces = data.spaces; - if (data.activeSpaceId !== undefined) this._stateData.activeSpaceId = data.activeSpaceId; - if (data.activeCollectionId !== undefined) this._stateData.activeCollectionId = data.activeCollectionId; - if (data.outputFolderPath !== undefined) this._stateData.outputFolderPath = data.outputFolderPath; - if (data.gridMaximized !== undefined) this._stateData.gridMaximized = data.gridMaximized; - if (data.resultsPanelHeight !== undefined) this._stateData.resultsPanelHeight = data.resultsPanelHeight; - if (data.sidebarWidth !== undefined) this._stateData.sidebarWidth = data.sidebarWidth; - if (data.searchQuery !== undefined) this._stateData.searchQuery = data.searchQuery; - - // Restore tabs - if (data.tabs && data.tabs.length > 0) { - this.tabs = data.tabs.map(t => ({ - ...t, - bulk: { ...(t.bulk || {}), running: false, results: [] }, - response: null - })); - this.activeTabIndex = Math.min(data.activeTabIndex || 0, this.tabs.length - 1); - } else { - // No saved tabs, create a blank one - this.tabs = [this.createNewTab()]; - this.activeTabIndex = 0; - } - } else { - // Fresh start - this.tabs = [this.createNewTab()]; - this.activeTabIndex = 0; - } - } catch (e) { - console.warn('Failed to load state', e); - this.tabs = [this.createNewTab()]; - this.activeTabIndex = 0; - } - }, - - saveState() { - // Skip expensive localStorage serialization while bulk is actively running. - if (this.state.bulk && this.state.bulk.running) return; - if (this._saveStateTimeout) clearTimeout(this._saveStateTimeout); - this._saveStateTimeout = setTimeout(() => { - try { - const serializedTabs = this.tabs.map(t => ({ - ...t, - bulk: { ...t.bulk, running: false, results: [] }, - response: null - })); - const persistentState = { - spaces: this._stateData.spaces, - activeSpaceId: this._stateData.activeSpaceId, - activeCollectionId: this._stateData.activeCollectionId, - outputFolderPath: this._stateData.outputFolderPath, - gridMaximized: this._stateData.gridMaximized, - resultsPanelHeight: this._stateData.resultsPanelHeight, - sidebarWidth: this._stateData.sidebarWidth, - searchQuery: this._stateData.searchQuery, - tabs: serializedTabs, - activeTabIndex: this.activeTabIndex - }; - localStorage.setItem('phoenix-state-v2', JSON.stringify(persistentState)); - } catch (e) { - console.warn('Failed to save state', e); - } - }, 300); - }, - - async loadLastRunFromServer() { - try { - const res = await fetch('/api/last-run'); - if (res.ok) { - const data = await res.json(); - if (data) { - if (data.bulk) { - this.state.bulk = { ...this.state.bulk, ...data.bulk, running: false }; - } - if (data.response !== undefined) { - this.state.response = data.response; - } - if (data.responseTab) { - this.state.responseTab = data.responseTab; - } - } - } - } catch (e) { - console.error('Failed to load last run from server', e); - } - }, - - async saveLastRunToServer() { - try { - const lightweightResults = this.state.bulk.results.map(r => ({ - ...r, - binaryData: null, - fullContent: null - })); - - const payload = { - bulk: { ...this.state.bulk, running: false, results: lightweightResults }, - response: this.state.response, - responseTab: this.state.responseTab - }; - await fetch('/api/last-run', { - method: 'POST', - headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify(payload) - }); - } catch (e) { - console.error('Failed to save last run to server', e); - } - }, - - saveLastRunToServerThrottled() { - if (this._saveThrottleTimeout) return; - this._saveThrottleTimeout = setTimeout(async () => { - this._saveThrottleTimeout = null; - await this.saveLastRunToServer(); - }, 1000); - }, - - get collections() { - if (!this.state.activeSpaceId) return []; - const space = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - return space ? space.collections : []; - }, - - set collections(val) { - if (!this.state.activeSpaceId) return; - const space = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - if (space) { - space.collections = val; - } - }, - - get notifications() { - if (!this.state.activeSpaceId) return []; - const space = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - return space ? (space.notifications || []) : []; - }, - - set notifications(val) { - if (!this.state.activeSpaceId) return; - const space = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - if (space) { - space.notifications = val; - } - }, - - async loadSpacesFromServer() { - try { - const res = await fetch('/api/spaces'); - const data = await res.json(); - if (Array.isArray(data)) { - // Check if server returned empty or only the default empty spaces - const serverIsEmpty = data.length === 0 || ( - data.length === 2 && - data[0].id === 'personal' && data[0].collections.length === 1 && (!data[0].collections[0].requests || data[0].collections[0].requests.length === 0) && - data[1].id === 'team' && data[1].collections.length === 1 && (!data[1].collections[0].requests || data[1].collections[0].requests.length === 0) - ); - - // Check if client had non-empty legacy collections in localStorage - const clientHasLegacyCollections = this.state.collections && ( - this.state.collections.length > 1 || - (this.state.collections[0] && this.state.collections[0].requests && this.state.collections[0].requests.length > 0) - ); - - if (serverIsEmpty && clientHasLegacyCollections) { - console.log('Migrating local client collections to spaces...'); - this.state.spaces = [ - { - id: 'personal', - name: 'Personal Space', - collections: JSON.parse(JSON.stringify(this.state.collections)) - }, - { - id: 'team', - name: 'Team Space', - collections: JSON.parse(JSON.stringify(this.state.collections)) - } - ]; - delete this.state.collections; - await this._debouncedSaveSpaces(); - } else if (data.length === 0 && this.state.spaces && this.state.spaces.length > 0) { - await this._debouncedSaveSpaces(); - } else if (data.length > 0) { - this.state.spaces = data; - } - - // Validate activeSpaceId - if (this.state.activeSpaceId) { - const spaceExists = this.state.spaces.some(s => s.id === this.state.activeSpaceId); - if (!spaceExists) { - this.state.activeSpaceId = null; - this.state.activeCollectionId = 'default'; - this.state.activeRequestId = null; - } - } - } - } catch (e) { - console.error('Failed to load spaces from server:', e); - } - }, - - async saveSpacesToServer() { - try { - await fetch('/api/spaces', { - method: 'POST', - headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify(this.state.spaces) - }); - } catch (e) { - console.error('Failed to sync spaces with server:', e); - } - }, - - openSpace(spaceId) { - this.state.activeSpaceId = spaceId; - this.state.activeCollectionId = 'default'; - this.state.activeRequestId = null; - this.saveState(); - this.render(); - }, - - showSpacesDashboard() { - this.state.activeSpaceId = null; - this.state.activeCollectionId = 'default'; - this.state.activeRequestId = null; - this.saveState(); - this.render(); - }, - - async createSpace() { - const name = prompt("Enter space name:"); - if (name && name.trim()) { - const id = 'space_' + Date.now(); - this.state.spaces.push({ - id: id, - name: name.trim(), - collections: [{ id: 'default', name: 'My Requests', requests: [] }] - }); - this.state.activeSpaceId = id; - this.saveState(); - await this._debouncedSaveSpaces(); - this.render(); - } - }, - - async deleteSpace(spaceId) { - if (this.state.spaces.length <= 1) { - return this.toast("Cannot delete the last remaining space", "error"); - } - if (confirm("Are you sure you want to delete this space? All collections and requests inside it will be permanently lost.")) { - this.state.spaces = this.state.spaces.filter(s => s.id !== spaceId); - if (this.state.activeSpaceId === spaceId) { - this.state.activeSpaceId = null; - this.state.activeCollectionId = 'default'; - this.state.activeRequestId = null; - } - this.saveState(); - await this._debouncedSaveSpaces(); - this.render(); - } - }, - - renameSpace(spaceId) { - const space = this.state.spaces.find(s => s.id === spaceId); - if (!space) return; - const newName = prompt("Enter new workspace name:", space.name); - if (newName && newName.trim()) { - space.name = newName.trim(); - this.saveState(); - this._debouncedSaveSpaces(); - this.render(); - } - }, - - async setSpaceTheme(themeId) { - const activeSpace = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - if (activeSpace) { - activeSpace.theme = themeId; - this.saveState(); - await this._debouncedSaveSpaces(); - this.render(); - this.toast(`Applied ${themeId} theme to ${activeSpace.name}`); - } - }, - - async shareCollection(colId) { - const otherSpaces = this.state.spaces.filter(s => s.id !== this.state.activeSpaceId); - if (otherSpaces.length === 0) { - return this.toast("No other spaces to share with", "warning"); - } - - const activeSpace = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - const collection = this.collections.find(c => c.id === colId); - if (!collection) return; - - const spacesList = otherSpaces.map((s, idx) => `${idx + 1}. ${s.name}`).join('\n'); - const choice = prompt(`Select workspace to share "${collection.name}" with (enter number):\n${spacesList}`); - if (choice) { - const idx = parseInt(choice) - 1; - if (idx >= 0 && idx < otherSpaces.length) { - const targetSpace = otherSpaces[idx]; - targetSpace.notifications = targetSpace.notifications || []; - - const alreadyShared = targetSpace.notifications.some(n => n.collection.id === colId && n.fromSpaceId === this.state.activeSpaceId); - if (alreadyShared) { - return this.toast("Already shared with this space, pending approval", "warning"); - } - - targetSpace.notifications.push({ - id: 'share_' + Date.now(), - fromSpaceId: this.state.activeSpaceId, - fromSpaceName: activeSpace ? activeSpace.name : 'Unknown Space', - collection: JSON.parse(JSON.stringify(collection)) - }); - - this.saveState(); - await this._debouncedSaveSpaces(); - this.toast(`Shared collection with ${targetSpace.name}!`); - this.render(); - } else { - this.toast("Invalid selection", "error"); - } - } - }, - - openNotificationsModal() { - const activeSpace = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - if (!activeSpace || !activeSpace.notifications || activeSpace.notifications.length === 0) return; - - const modal = document.createElement('div'); - modal.className = 'premium-modal-overlay'; - modal.id = 'notifications-modal'; - - const listHTML = activeSpace.notifications.map(n => ` -
-
- -
-
${this.escapeHTML(n.fromSpaceName)} shared collection:
-
${this.escapeHTML(n.collection.name)}
- ${n.collection.requests ? n.collection.requests.length : 0} Requests -
-
-
- - -
-
- `).join(''); - - modal.innerHTML = ` -
-
-

Share Requests

- -
-
- ${listHTML} -
- -
- `; - document.body.appendChild(modal); - modal.onclick = (e) => { if (e.target === modal) modal.remove(); }; - }, - - async approveShare(notifId) { - const activeSpace = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - if (!activeSpace || !activeSpace.notifications) return; - - const idx = activeSpace.notifications.findIndex(n => n.id === notifId); - if (idx >= 0) { - const notif = activeSpace.notifications[idx]; - const collection = notif.collection; - - let newName = collection.name; - let counter = 1; - while (activeSpace.collections.some(c => c.name === newName)) { - newName = `${collection.name} (${counter++})`; - } - collection.name = newName; - collection.id = 'col_' + Date.now(); - - activeSpace.collections.push(collection); - activeSpace.notifications.splice(idx, 1); - - this.saveState(); - await this._debouncedSaveSpaces(); - this.toast("Collection approved and added!"); - this.render(); - } - }, - - async rejectShare(notifId) { - const activeSpace = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - if (!activeSpace || !activeSpace.notifications) return; - - const idx = activeSpace.notifications.findIndex(n => n.id === notifId); - if (idx >= 0) { - activeSpace.notifications.splice(idx, 1); - this.saveState(); - await this._debouncedSaveSpaces(); - this.toast("Share request rejected"); - this.render(); - } - }, - - startSidebarResize(e) { - e.preventDefault(); - document.body.classList.add('resizing'); - const startX = e.clientX; - const startWidth = this.state.sidebarWidth || 270; - const handle = document.getElementById('sidebar-resize-handle'); - if (handle) handle.classList.add('active'); - - const doDrag = (moveEvent) => { - const deltaX = moveEvent.clientX - startX; - const newWidth = Math.max(180, Math.min(600, startWidth + deltaX)); - this.state.sidebarWidth = newWidth; - const sidebarEl = document.getElementById('sidebar'); - if (sidebarEl) { - sidebarEl.style.width = `${newWidth}px`; - } - }; - - const stopDrag = () => { - document.body.classList.remove('resizing'); - document.removeEventListener('mousemove', doDrag); - document.removeEventListener('mouseup', stopDrag); - if (handle) handle.classList.remove('active'); - this.saveState(); - }; - - document.addEventListener('mousemove', doDrag); - document.addEventListener('mouseup', stopDrag); - }, - - replaceResultCardInDOM(result) { - const newEl = this._buildCardElement(result); - document.querySelectorAll(`.result-card[data-index="${result.index}"]`).forEach(card => { - card.replaceWith(newEl.cloneNode(true)); - }); - }, - - async resendBulkRequest(resultIndex) { - const index = resultIndex - 1; // 0-based index - const bulk = this.state.bulk; - const resultItem = bulk.results.find(r => r.index === resultIndex); - if (!resultItem) return; - - this.toast(`Re-sending request #${resultIndex}...`, 'info'); - - // Recalculate maxFiles and maxList to determine fileIndex and listIndex 1-to-1 - let maxFiles = 0; - let maxList = 0; - - const folders = [ - ...this.state.params.filter(p => p.type === 'folder' && p.enabled && p.key && p.key.trim()), - ...(this.state.bodyType === 'form-data' ? this.state.bodyData.filter(p => p.type === 'folder' && p.enabled && p.key && p.key.trim()) : []) - ]; - if (folders.length > 0) { - for (const f of folders) { - const files = this.fileStore.get(f.id); - if (files && files.length > maxFiles) maxFiles = files.length; - } - } - - const allLists = [ - ...this.state.params.filter(p => p.type === 'list' && p.enabled && p.key && p.key.trim()), - ...(this.state.bodyType === 'form-data' ? this.state.bodyData.filter(p => p.type === 'list' && p.enabled && p.key && p.key.trim()) : []), - ...this.state.headers.filter(h => h.type === 'list' && h.enabled && h.key && h.key.trim()) - ]; - if (allLists.length > 0) { - for (const listParam of allLists) { - const val = listParam.value || ''; - const arr = val.split(/[\n,]+/).map(s => s.trim()).filter(s => s); - if (arr.length > maxList) maxList = arr.length; - } - } - - let fileIndex = index; - let listIndex = index; - if (bulk.strategy === 'cartesian' && maxFiles > 0 && maxList > 0) { - fileIndex = Math.floor(index / maxList); - listIndex = index % maxList; - } - - try { - const res = await this.executeRequest(index, fileIndex, listIndex); - const isSuccess = res.status_code >= 200 && res.status_code < 300; - - // Adjust stats counters - const wasSuccess = resultItem.status >= 200 && resultItem.status < 300; - if (wasSuccess && !isSuccess) { - bulk.success--; - bulk.error++; - } else if (!wasSuccess && isSuccess) { - bulk.success++; - bulk.error--; - } - - // Update item details - resultItem.status = res.status_code; - resultItem.latency = res.latency || 0; - resultItem.data = res.content ? res.content.substring(0, 100) : (res.binary_data ? '[Binary]' : ''); - resultItem.fullContent = res.content; - resultItem.binaryData = res.binary_data; - resultItem.contentType = res.content_type; - resultItem.headers = res.headers; - - if (resultItem.blobUrl && resultItem.blobUrl !== res.blobUrl) { - URL.revokeObjectURL(resultItem.blobUrl); - } - resultItem.blobUrl = res.blobUrl; - - this.toast(`Request #${resultIndex} completed: ${res.status_code}`, isSuccess ? 'info' : 'error'); - this.updateBulkProgressUI(); - this.replaceResultCardInDOM(resultItem); - await this.saveLastRunToServer(); - } catch (e) { - const wasSuccess = resultItem.status >= 200 && resultItem.status < 300; - if (wasSuccess) { - bulk.success--; - bulk.error++; - } - resultItem.status = 'ERR'; - resultItem.latency = 0; - resultItem.data = e.message; - this.toast(`Request #${resultIndex} failed: ${e.message}`, 'error'); - this.updateBulkProgressUI(); - this.replaceResultCardInDOM(resultItem); - await this.saveLastRunToServer(); - } - }, - - startResultsResize(e) { - e.preventDefault(); - document.body.classList.add('resizing'); - const startY = e.clientY; - const startHeight = this.state.resultsPanelHeight || 300; - - const doDrag = (moveEvent) => { - const deltaY = startY - moveEvent.clientY; - const newHeight = Math.max(120, Math.min(800, startHeight + deltaY)); - this.state.resultsPanelHeight = newHeight; - const panel = document.querySelector('.bottom-results-panel'); - if (panel) { - panel.style.height = `${newHeight}px`; - } - }; - - const stopDrag = () => { - document.body.classList.remove('resizing'); - document.removeEventListener('mousemove', doDrag); - document.removeEventListener('mouseup', stopDrag); - this.saveState(); - }; - - document.addEventListener('mousemove', doDrag); - document.addEventListener('mouseup', stopDrag); - }, - - _buildCardElement(result) { - const tmp = document.createElement('template'); - tmp.innerHTML = this.renderResultCard(result).trim(); - return tmp.content.firstElementChild; - }, - - appendResultCardToDOM(result) { - const newElement = this._buildCardElement(result); - - const appendToGrid = (grid) => { - if (!grid) return; - const spinner = grid.querySelector('div[style*="fa-spinner"]'); - if (spinner) spinner.remove(); - grid.appendChild(newElement.cloneNode(true)); - // Virtual cap: drop oldest cards past 500 to prevent runaway DOM - while (grid.children.length > 500) { - grid.removeChild(grid.firstElementChild); - } - }; - - appendToGrid(document.getElementById('main-results-grid')); - appendToGrid(document.querySelector('.fullscreen-results-grid')); - }, - - updateBulkProgressUI() { - if (this._rafPending) return; - this._rafPending = true; - requestAnimationFrame(() => { - this._rafPending = false; - const bulk = this.state.bulk; - const pct = bulk.total > 0 ? (bulk.completed / bulk.total) * 100 : 0; - const statusColor = bulk.error > 0 ? (bulk.success > 0 ? 'var(--warning)' : 'var(--danger)') : 'var(--success)'; - - document.querySelectorAll('#progress-bar-fill, .progress-fill').forEach(bar => { - bar.style.width = `${pct}%`; - bar.style.background = statusColor; - }); - - document.querySelectorAll('#progress-text').forEach(el => el.innerText = `${bulk.completed} / ${bulk.total} Completed`); - document.querySelectorAll('.stat-capsule').forEach(el => { - if (el.classList.contains('success')) { - el.innerText = `${bulk.success} Success`; - } else if (el.classList.contains('error')) { - el.innerText = `${bulk.error} Failed`; - } else if (el.innerText.includes('Completed')) { - el.innerText = `${bulk.completed} / ${bulk.total} Completed`; - } - }); - // Intentionally NOT calling saveLastRunToServer here to prevent massive JSON stringify lag during execution! - }); - }, - - - openFullscreenResults() { - const bulk = this.state.bulk; - if (bulk.results.length === 0 && !bulk.running) { - return this.toast("No results to view in fullscreen", "warning"); - } - - let modal = document.getElementById('fullscreen-results-overlay'); - const pct = bulk.total > 0 ? (bulk.completed / bulk.total) * 100 : 0; - const statusColor = bulk.error > 0 ? (bulk.success > 0 ? 'var(--warning)' : 'var(--danger)') : 'var(--success)'; - const folderPath = this.state.outputFolderPath || 'None selected'; - - const contentHTML = ` -
-
- -
-

Fullscreen Batch Processing Grid

-

Real-time execution monitoring and visual results

-
-
- ${bulk.completed} / ${bulk.total} Completed - ${bulk.success} Success - ${bulk.error} Failed -
-
- -
-
- - ${folderPath} - - - -
- - - - -
-
- -
-
-
- -
- `; - - if (!modal) { - modal = document.createElement('div'); - modal.className = 'fullscreen-results-overlay'; - modal.id = 'fullscreen-results-overlay'; - modal.innerHTML = contentHTML; - document.body.appendChild(modal); - } else { - modal.innerHTML = contentHTML; - } - - // Populate the fullscreen grid via DocumentFragment (no re-render of cards) - const fsGrid = document.getElementById('fullscreen-results-inner'); - if (fsGrid) { - const frag = document.createDocumentFragment(); - const shown = bulk.results.slice(-200); - if (shown.length === 0 && bulk.running) { - const ph = document.createElement('div'); - ph.style.cssText = 'grid-column:1/-1;text-align:center;color:var(--text-muted);padding:80px;font-style:italic;'; - ph.innerHTML = 'Running…'; - frag.appendChild(ph); - } else { - shown.forEach(r => frag.appendChild(this._buildCardElement(r))); - } - fsGrid.appendChild(frag); - } - }, - - closeFullscreenResults() { - const modal = document.getElementById('fullscreen-results-overlay'); - if (modal) { - modal.remove(); - } - }, - - async browseServerFolder() { - try { - const res = await fetch('/api/browse_folder', { - method: 'POST' - }); - const data = await res.json(); - if (data.success) { - this.state.outputFolderPath = data.path; - this.saveState(); - this.render(); - this.toast(`Folder selected: ${data.path}`); - } else { - this.toast(data.error || 'Failed to browse folder', 'error'); - } - } catch (e) { - this.toast(`Error browsing folder: ${e.message}`, 'error'); - } - }, - - async saveToServerFolder() { - if (!this.state.bulk.results.length) return this.toast('No results to save', 'error'); - if (!this.state.outputFolderPath) { - this.toast('Please select an output folder first', 'error'); - await this.browseServerFolder(); - if (!this.state.outputFolderPath) return; - } - - try { - this.toast('Saving files to server folder...', 'info'); - - // First ensure the latest run is persisted on the server - await this.saveLastRunToServer(); - - // Ask the server to save from its own copy (avoids sending huge binary payloads) - const res = await fetch('/api/save_folder_from_lastrun', { - method: 'POST', - headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ path: this.state.outputFolderPath }) - }); - - const data = await res.json(); - if (data.success) { - const errMsg = data.errors && data.errors.length > 0 ? ` (${data.errors.length} errors)` : ''; - this.toast(`Saved ${data.count} files to ${this.state.outputFolderPath}${errMsg}`); - if (data.errors && data.errors.length > 0) { - console.warn('Save errors:', data.errors); - } - } else { - this.toast(`Failed to save: ${data.error}`, 'error'); - } - } catch (e) { - this.toast(`Error saving to folder: ${e.message}`, 'error'); - } - }, - - async saveIndividualToServerFolder(index) { - const result = this.state.bulk.results.find(r => r.index === index); - if (!result) return; - - if (!this.state.outputFolderPath) { - this.toast('Please select an output folder first', 'error'); - await this.browseServerFolder(); - if (!this.state.outputFolderPath) return; - } - - try { - // Ensure server has latest run data - await this.saveLastRunToServer(); - - const res = await fetch('/api/save_folder_from_lastrun', { - method: 'POST', - headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ - path: this.state.outputFolderPath, - indices: [index] - }) - }); - - const data = await res.json(); - if (data.success && data.count > 0) { - this.toast(`Saved file #${index} to server folder`); - } else { - this.toast(`Failed to save: ${data.error || (data.errors && data.errors[0]) || 'Unknown error'}`, 'error'); - } - } catch (e) { - this.toast(`Error saving file: ${e.message}`, 'error'); - } - }, - - downloadIndividualResult(index) { - const result = this.state.bulk.results.find(r => r.index === index); - if (!result) return; - - try { - const finalFilename = this.getFinalFilename(result); - let url; - let needsRevoke = false; - - if (result.binaryData) { - if (result.blobUrl) { - url = result.blobUrl; - } else { - url = this.base64ToBlobUrl(result.binaryData, result.contentType || 'application/octet-stream'); - needsRevoke = true; - } - } else if (result.fullContent) { - const blob = new Blob([result.fullContent], { type: result.contentType || 'text/plain' }); - url = URL.createObjectURL(blob); - needsRevoke = true; - } else { - return this.toast('No content to download', 'error'); - } - - const a = document.createElement('a'); - a.href = url; - a.download = finalFilename; - document.body.appendChild(a); - a.click(); - document.body.removeChild(a); - if (needsRevoke) { - URL.revokeObjectURL(url); - } - - this.toast(`Downloaded "${finalFilename}"`); - } catch (e) { - this.toast(`Download failed: ${e.message}`, 'error'); - } - }, - - clearBulkResults() { - if (confirm("Are you sure you want to clear all batch results?")) { - this.state.bulk.results = []; - this.state.bulk.completed = 0; - this.state.bulk.success = 0; - this.state.bulk.error = 0; - this.state.bulk.total = 0; - this.state.bulk.running = false; - this.saveState(); - this.saveLastRunToServer(); - this.render(); - } - }, - - toggleGridMaximized() { - this.state.gridMaximized = !this.state.gridMaximized; - this.render(); - }, - - // --- Actions --- - - addParam(section) { - const item = { id: Date.now().toString() + Math.random(), key: '', value: '', type: 'text', enabled: true }; - if (section === 'params') this.state.params.push(item); - if (section === 'headers') this.state.headers.push(item); - if (section === 'body') this.state.bodyData.push(item); - this.render(); - this.saveState(); - }, - - removeParam(section, id) { - if (section === 'params') this.state.params = this.state.params.filter(p => p.id !== id); - if (section === 'headers') this.state.headers = this.state.headers.filter(p => p.id !== id); - if (section === 'body') this.state.bodyData = this.state.bodyData.filter(p => p.id !== id); - this.render(); - this.saveState(); - }, - - updateParam(section, id, field, value) { - const list = section === 'params' ? this.state.params : (section === 'headers' ? this.state.headers : this.state.bodyData); - const item = list.find(p => p.id === id); - if (item) { - item[field] = value; - this.saveState(); - // Re-render if type changes to show/hide file input - if (field === 'type' || field === 'enabled') this.scheduleRender(); - } - }, - - // --- Request Execution --- - - async sendRequest() { - if (!this.state.url) return this.toast('URL is required', 'error'); - - // Reset bulk results upon sending another single request - this.state.bulk.results = []; - this.state.bulk.completed = 0; - this.state.bulk.success = 0; - this.state.bulk.error = 0; - this.state.bulk.total = 0; - - this.state.response = { status: 'Sending...', headers: {} }; - this.state.responseTab = 'response'; // Switch view - this.render(); - this.saveLastRunToServerThrottled(); - - try { - const start = Date.now(); - const res = await this.executeRequest(0); - const latency = Date.now() - start; - - res.latency = latency; - this.state.response = res; - if (res.blobUrl) this.state.response.blobUrl = res.blobUrl; - this.saveToCollection(res.status_code || 500); - } catch (e) { - this.state.response = { error: e.message }; - } - - this.render(); - this.saveState(); - await this.saveLastRunToServer(); - }, - - // --- Bulk Execution --- - - async runBulk() { - if (!this.state.url) return this.toast('URL is required', 'error'); - - // Calculate total items based on folders or lists - let maxFiles = 0; - let maxList = 0; - const currentRunId = Date.now(); - this.state.bulk.currentRunId = currentRunId; - - // Check folders first - only those that will actually be used - const folders = [ - ...this.state.params.filter(p => p.type === 'folder' && p.enabled && p.key && p.key.trim()), - ...(this.state.bodyType === 'form-data' ? this.state.bodyData.filter(p => p.type === 'folder' && p.enabled && p.key && p.key.trim()) : []) - ]; - - if (folders.length > 0) { - // Find max file count - for (const f of folders) { - const files = this.fileStore.get(f.id); - if (files && files.length > maxFiles) maxFiles = files.length; - } - } - - // Check lists (params, body, headers) - only those with keys - const allLists = [ - ...this.state.params.filter(p => p.type === 'list' && p.enabled && p.key && p.key.trim()), - ...(this.state.bodyType === 'form-data' ? this.state.bodyData.filter(p => p.type === 'list' && p.enabled && p.key && p.key.trim()) : []), - ...this.state.headers.filter(h => h.type === 'list' && h.enabled && h.key && h.key.trim()) - ]; - - if (allLists.length > 0) { - // Find the longest list - for (const listParam of allLists) { - const val = listParam.value || ''; - const arr = val.split(/[\n,]+/).map(s => s.trim()).filter(s => s); - if (arr.length > maxList) maxList = arr.length; - } - } - - let total = 0; - if (this.state.bulk.strategy === 'cartesian' && maxFiles > 0 && maxList > 0) { - total = maxFiles * maxList; - } else { - total = Math.max(maxFiles, maxList); - } - - // If still no total, use the saved repetitions setting - if (total === 0) { - total = Math.max(1, parseInt(this.state.bulk.repetitions) || 10); - } - - if (total <= 0) return this.toast('Invalid bulk count', 'error'); - - // Init Bulk State - if (!this.state.bulk.paused) { - this.state.bulk.total = total; - this.state.bulk.completed = 0; - this.state.bulk.success = 0; - this.state.bulk.error = 0; - this.state.bulk.results = []; - this.state.bulk.nextIndex = 0; - this.state.responseTab = 'results'; - } else { - this.state.bulk.total = total; - } - - this.state.bulk.running = true; - this.state.bulk.paused = false; - - this.saveToCollection('BULK'); - this.render(); - - // Execution Queue - const concurrency = Math.max(1, Math.min(20, this.state.bulk.concurrency || 1)); - let active = 0; - - const worker = async () => { - while (this.state.bulk.nextIndex < this.state.bulk.total && this.state.bulk.running && this.state.bulk.currentRunId === currentRunId) { - const index = this.state.bulk.nextIndex++; - active++; - - let fileIndex = index; - let listIndex = index; - if (this.state.bulk.strategy === 'cartesian' && maxFiles > 0 && maxList > 0) { - fileIndex = Math.floor(index / maxList); - listIndex = index % maxList; - } - - const inputFilename = this.getInputFilename(index, fileIndex, listIndex); - - try { - const res = await this.executeRequest(index, fileIndex, listIndex); - - if (this.state.bulk.currentRunId !== currentRunId) return; - - const isSuccess = res.status_code >= 200 && res.status_code < 300; - if (isSuccess) this.state.bulk.success++; else this.state.bulk.error++; - - this.state.bulk.results.push({ - index: index + 1, - status: res.status_code, - latency: res.latency || 0, - data: res.content ? res.content.substring(0, 100) : (res.binary_data ? '[Binary]' : ''), - fullContent: res.content, - binaryData: res.binary_data, - blobUrl: res.blobUrl, - contentType: res.content_type, - headers: res.headers, - inputFilename: inputFilename - }); - - const newResult = this.state.bulk.results[this.state.bulk.results.length - 1]; - this.appendResultCardToDOM(newResult); - if (this.state.bulk.results.length > 1000) this.state.bulk.results.shift(); - - } catch (e) { - if (this.state.bulk.currentRunId !== currentRunId) return; - this.state.bulk.error++; - this.state.bulk.results.push({ - index: index + 1, - status: 'ERR', - latency: 0, - data: e.message, - inputFilename: inputFilename - }); - const errResult = this.state.bulk.results[this.state.bulk.results.length - 1]; - this.appendResultCardToDOM(errResult); - } finally { - active--; - this.state.bulk.completed++; - if (this.state.bulk.currentRunId === currentRunId) { - this.updateBulkProgressUI(); - } - } - - // Apply inter-request delay (only when concurrency = 1 or after each request) - const delayMs = parseInt(this.state.bulk.delay) || 0; - if (delayMs > 0 && this.state.bulk.running && this.state.bulk.currentRunId === currentRunId) { - await new Promise(r => setTimeout(r, delayMs)); - } - } - - if (active === 0 && this.state.bulk.nextIndex >= this.state.bulk.total && this.state.bulk.currentRunId === currentRunId) { - this.state.bulk.running = false; - this.state.bulk.paused = false; - // Sort final results by index before final render - this.state.bulk.results.sort((a, b) => a.index - b.index); - this.render(); - this.toast('Bulk Operation Completed'); - await this.saveLastRunToServer(); - } - }; - - // Spawn workers - for (let i = 0; i < concurrency; i++) { - worker(); - } - }, - - stopBulk() { - this.state.bulk.running = false; - this.state.bulk.paused = false; - this.render(); - }, - - pauseBulk() { - if (this.state.bulk.running) { - this.state.bulk.running = false; - this.state.bulk.paused = true; - this.render(); - this.toast('Bulk Operation Paused', 'warning'); - } - }, - - resumeBulk() { - if (this.state.bulk.paused) { - this.runBulk(); - } - }, - - async getImageDimensions(file) { - return new Promise((resolve) => { - if (!file || !file.type.startsWith('image/')) return resolve({width: 0, height: 0}); - const img = new Image(); - const url = URL.createObjectURL(file); - img.onload = () => { - resolve({width: img.width, height: img.height}); - URL.revokeObjectURL(url); - }; - img.onerror = () => { - resolve({width: 0, height: 0}); - URL.revokeObjectURL(url); - }; - img.src = url; - }); - }, - - async executeRequest(index, fileIndex = index, listIndex = index) { - const start = Date.now(); - // Headers - const headers = {}; - this.state.headers.filter(h => h.enabled && h.key && h.key.trim()).forEach(h => { - // Handle list replacement in headers too - let val = h.value; - if (h.type === 'list') { - const arr = val.split(/[\n,]+/).map(s => s.trim()).filter(s => s); - if (arr.length > 0) val = arr[listIndex % arr.length]; - } - headers[h.key.trim()] = val; - }); - - // Auth - const auth = this.state.auth; - if (auth.type === 'bearer') headers['Authorization'] = `Bearer ${auth.token}`; - else if (auth.type === 'basic') headers['Authorization'] = 'Basic ' + btoa(`${auth.username}:${auth.password}`); - else if (auth.type === 'apikey') headers[auth.key] = auth.value; - - // URL Params - const urlObj = new URL(this.state.url); - this.state.params.filter(p => p.enabled && p.key && p.key.trim()).forEach(p => { - let val = p.value; - // List handling - if (p.type === 'list') { - // Try splitting by newline first if present, else comma - const arr = val.split(/[\n,]+/).map(s => s.trim()).filter(s => s); - if (arr.length > 0) val = arr[listIndex % arr.length]; - } - // File logic not applicable for URL params usually, skipping - urlObj.searchParams.append(p.key, val); - }); - - // Payload Construction - const finalData = new FormData(); - finalData.append('method', this.state.method); - finalData.append('url', urlObj.toString()); - finalData.append('headers', JSON.stringify(headers)); - // Add auth config for server-side handling if needed (e.g. Basic Auth via requests arg) - if (auth.type === 'basic') finalData.append('auth', JSON.stringify({ type: 'basic', username: auth.username, password: auth.password })); - - // Body - if (this.state.bodyType === 'json') { - finalData.append('body_type', 'json'); - finalData.append('body', this.state.jsonBody); - } else if (this.state.bodyType === 'form-data') { - finalData.append('body_type', 'form-data'); - - let currentImageFile = null; - const folderParam = this.state.bodyData.find(p => p.enabled && p.type === 'folder'); - if (folderParam) { - const files = this.fileStore.get(folderParam.id); - if (files && files.length > 0) currentImageFile = files[fileIndex % files.length]; - } - if (!currentImageFile) { - const fileParam = this.state.bodyData.find(p => p.enabled && p.type === 'file'); - if (fileParam) { - const files = this.fileStore.get(fileParam.id); - if (files && files.length > 0) currentImageFile = files[0]; - } - } - let imgDims = null; - - const bodyParams = this.state.bodyData.filter(p => p.enabled && (p.type === 'file' || p.type === 'folder' || p.type === 'auto_width' || p.type === 'auto_height' || (p.key && p.key.trim()))); - for (const p of bodyParams) { - if (p.type === 'file' || p.type === 'folder') { - const files = this.fileStore.get(p.id); - if (files && files.length > 0) { - if (p.type === 'folder') { - finalData.append(p.key, files[fileIndex % files.length]); - } else { - for (let f of files) finalData.append(p.key, f); - } - } - } else if (p.type === 'auto_width' || p.type === 'auto_height') { - if (!imgDims) imgDims = await this.getImageDimensions(currentImageFile); - finalData.append(p.key, p.type === 'auto_width' ? imgDims.width : imgDims.height); - } else { - let val = p.value; - if (p.type === 'list') { - const arr = val.split(/[\n,]+/).map(s => s.trim()).filter(s => s); - if (arr.length > 0) val = arr[listIndex % arr.length]; - } - finalData.append(p.key, val); - } - } - } - - const res = await fetch('/api/proxy-request', { - method: 'POST', - body: finalData - }); - - const data = await res.json(); - if (data.binary_data) { - data.blobUrl = await this.base64ToBlobUrlAsync(data.binary_data, data.content_type); - } - data.latency = Date.now() - start; - return data; - }, - - saveToCollection(lastStatus) { - if (!this.state.url) return; - - let targetColId = this.state.activeCollectionId || 'default'; - let col = this.collections.find(c => c.id === targetColId); - if (!col) { - col = this.collections.find(c => c.id === 'default'); - if(!col) { - col = { id: 'default', name: 'My Requests', requests: [] }; - this.collections.push(col); - } - targetColId = col.id; - } - - const existingIdx = col.requests.findIndex(r => r.id === this.state.activeRequestId || (r.url === this.state.url && r.method === this.state.method)); - let existingReq = existingIdx >= 0 ? col.requests[existingIdx] : null; - - const reqData = { - id: this.state.activeRequestId || Date.now().toString(), - name: (existingReq && existingReq.name) ? existingReq.name : (this.state.url.split('?')[0].split('/').pop() || 'Root URL'), - method: this.state.method, - url: this.state.url, - params: JSON.parse(JSON.stringify(this.state.params)), - headers: JSON.parse(JSON.stringify(this.state.headers)), - auth: JSON.parse(JSON.stringify(this.state.auth)), - bodyType: this.state.bodyType, - bodyData: JSON.parse(JSON.stringify(this.state.bodyData)), - jsonBody: this.state.jsonBody, - lastStatus: lastStatus !== undefined ? lastStatus : (existingReq ? existingReq.lastStatus : null), - lastTime: new Date().toLocaleTimeString(), - activeCollectionId: targetColId - }; - - if (existingIdx >= 0) { - // Update existing - reqData.id = existingReq.id; // preserve ID - col.requests[existingIdx] = reqData; - } else { - // Add new - col.requests.unshift(reqData); - } - - this.state.activeRequestId = reqData.id; - this.saveState(); - this._debouncedSaveSpaces(); - }, - - _debouncedSaveSpaces() { - if (this._saveSpacesTimer) clearTimeout(this._saveSpacesTimer); - this._saveSpacesTimer = setTimeout(() => this._debouncedSaveSpaces(), 3000); - }, - - loadRequest(colId, reqId) { - const col = this.collections.find(c => c.id === colId); - if(!col) return; - const req = col.requests.find(r => r.id === reqId); - if(!req) return; - - // Check if this request is already open in any tab - const existingTabIdx = this.tabs.findIndex(t => t.activeRequestId === reqId); - if (existingTabIdx >= 0) { - // Just switch to that tab - this.activeTabIndex = existingTabIdx; - this.saveState(); - this.render(); - return; - } - - // Postman behavior: if the current tab is a "preview" tab (untouched/empty), reuse it; - // otherwise open a new tab - const currTab = this.tabs[this.activeTabIndex]; - const isUntouched = currTab && ( - (!currTab.url || currTab.url === '') && - (!currTab.activeRequestId) && - (!currTab.response) && - (currTab.name === 'Untitled Request' || !currTab.name) - ); - - const reqTabData = { - id: 'tab_' + Date.now() + Math.random().toString(36).substr(2, 9), - name: req.name || (req.url ? req.url.split('/').pop() || req.url : 'Request'), - method: req.method || 'GET', - url: req.url || '', - params: JSON.parse(JSON.stringify(req.params || [{ id: Date.now().toString(), key: '', value: '', type: 'text', enabled: true }])), - headers: JSON.parse(JSON.stringify(req.headers || [{ id: (Date.now()+1).toString(), key: '', value: '', type: 'text', enabled: true }])), - auth: JSON.parse(JSON.stringify(req.auth || {type:'none'})), - bodyType: req.bodyType || 'none', - bodyData: JSON.parse(JSON.stringify(req.bodyData || [])), - jsonBody: req.jsonBody || '', - response: null, - bulk: { strategy: 'consecutive', running: false, total: 0, completed: 0, success: 0, error: 0, concurrency: 1, results: [] }, - activeTab: 'params', - responseTab: 'response', - activeRequestId: reqId, - activeCollectionId: colId, - isPreview: false - }; - - if (isUntouched) { - // Replace current blank tab - this.tabs[this.activeTabIndex] = reqTabData; - } else { - // Open brand new tab - this.tabs.push(reqTabData); - this.activeTabIndex = this.tabs.length - 1; - } - - this.saveState(); - this.render(); - }, - - deleteRequest(colId, reqId) { - const col = this.collections.find(c => c.id === colId); - if(col) col.requests = col.requests.filter(r => r.id !== reqId); - if(this.state.activeRequestId === reqId) this.state.activeRequestId = null; - this.saveState(); - this._debouncedSaveSpaces(); - this.render(); - }, - - createCollection() { - const name = prompt("Collection Name:"); - if(name) { - const id = 'col_' + Date.now(); - this.collections.push({ id, name, requests: [] }); - this.state.activeCollectionId = id; - this.saveState(); - this._debouncedSaveSpaces(); - this.render(); - } - }, - - renameCollection(colId) { - const col = this.collections.find(c => c.id === colId); - if(!col) return; - const newName = prompt("Enter new collection name:", col.name); - if(newName && newName.trim()) { - col.name = newName.trim(); - this.saveState(); - this._debouncedSaveSpaces(); - this.render(); - } - }, - - renameRequest(colId, reqId) { - const col = this.collections.find(c => c.id === colId); - if(!col) return; - const req = col.requests.find(r => r.id === reqId); - if(!req) return; - const newName = prompt("Enter new request name:", req.name); - if(newName && newName.trim()) { - req.name = newName.trim(); - this.saveState(); - this._debouncedSaveSpaces(); - this.render(); - } - }, - - deleteCollection(colId) { - if(confirm("Delete this collection and all its requests? This cannot be undone.")) { - this.collections = this.collections.filter(c => c.id !== colId); - // Always keep at least one collection - if (this.collections.length === 0) { - this.collections = [{ id: 'default', name: 'My Requests', requests: [] }]; - } - // If deleted collection was active, switch to first remaining - const stillExists = this.collections.some(c => c.id === this.state.activeCollectionId); - if (!stillExists) { - this.state.activeCollectionId = this.collections[0].id; - this.state.activeRequestId = null; - } - this.saveState(); - this._debouncedSaveSpaces(); - this.render(); - } - }, - - addRequestToCollection(colId) { - const col = this.collections.find(c => c.id === colId); - if (!col) return; - const reqId = 'req_' + Date.now(); - const newReq = { - id: reqId, - name: 'New Request', - method: 'GET', - url: '', - description: '', - params: [{ id: Date.now().toString() + Math.random(), key: '', value: '', type: 'text', enabled: true }], - headers: [{ id: Date.now().toString() + Math.random(), key: '', value: '', type: 'text', enabled: true }], - auth: { type: 'none' }, - bodyType: 'none', - bodyData: [], - jsonBody: '' - }; - col.requests.push(newReq); - - // Open this new request in a new tab - const reqTabData = { - id: 'tab_' + Date.now() + Math.random().toString(36).substr(2, 9), - name: 'New Request', - method: 'GET', - url: '', - params: JSON.parse(JSON.stringify(newReq.params)), - headers: JSON.parse(JSON.stringify(newReq.headers)), - auth: { type: 'none' }, - bodyType: 'none', - bodyData: [], - jsonBody: '', - response: null, - bulk: { strategy: 'consecutive', running: false, total: 0, completed: 0, success: 0, error: 0, concurrency: 1, results: [] }, - activeTab: 'params', - responseTab: 'response', - activeRequestId: reqId, - activeCollectionId: colId, - isPreview: false - }; - this.tabs.push(reqTabData); - this.activeTabIndex = this.tabs.length - 1; - - this.saveState(); - this._debouncedSaveSpaces(); - this.render(); - this.toast("Added new request to collection"); - - }, - - updateActiveRequestName(name) { - const activeSpace = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - const col = activeSpace ? activeSpace.collections.find(c => c.id === this.state.activeCollectionId) : null; - const activeReq = col ? col.requests.find(r => r.id === this.state.activeRequestId) : null; - if (activeReq) { - activeReq.name = name.trim() || 'Untitled Request'; - this.saveState(); - this._debouncedSaveSpaces(); - this.render(); - } - }, - - updateActiveRequestDescription(desc) { - const activeSpace = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - const col = activeSpace ? activeSpace.collections.find(c => c.id === this.state.activeCollectionId) : null; - const activeReq = col ? col.requests.find(r => r.id === this.state.activeRequestId) : null; - if (activeReq) { - activeReq.description = desc; - this.saveState(); - this._debouncedSaveSpaces(); - } - }, - - downloadHistory() { - if (!this.state.bulk.results.length) return; - - const csvContent = "data:text/csv;charset=utf-8," - + "Index,Status,Latency (ms),Snippet\n" - + this.state.bulk.results.map(r => `${r.index},${r.status},${r.latency},"${(r.data || '').replace(/"/g, '""').replace(/\n/g, ' ')}"`).join("\n"); - - const encodedUri = encodeURI(csvContent); - const link = document.createElement("a"); - link.setAttribute("href", encodedUri); - link.setAttribute("download", `bulk_results_${new Date().toISOString()}.csv`); - document.body.appendChild(link); - link.click(); - document.body.removeChild(link); - }, - - // Get the input filename for a given bulk index - getInputFilename(index, fileIndex = index, listIndex = index) { - // Build list of active params that could provide a name - const activeParams = [ - ...this.state.params.filter(p => p.enabled && p.key && p.key.trim()), - ...(this.state.bodyType === 'form-data' ? this.state.bodyData.filter(p => p.enabled && p.key && p.key.trim()) : []) - ]; - - let folderName = null; - // Priority 1: Folder type (usually high-intent for naming) - const folderParam = activeParams.find(p => p.type === 'folder'); - if (folderParam) { - const files = this.fileStore.get(folderParam.id); - if (files && files.length > 0) { - const file = files[fileIndex % files.length]; - folderName = file.webkitRelativePath || file.name; - } - } - - let listName = null; - // Priority 2: List in Body (user's specific request context) - if (this.state.bodyType === 'form-data') { - const bodyList = this.state.bodyData.find(p => p.type === 'list' && p.enabled && p.key && p.key.trim()); - if (bodyList) { - const arr = bodyList.value.split(/[\n,]+/).map(s => s.trim()).filter(s => s); - if (arr.length > 0) listName = arr[listIndex % arr.length]; - } - } - - // Priority 3: Any other list - if (!listName) { - const listParam = activeParams.find(p => p.type === 'list'); - if (listParam) { - const val = listParam.value || ''; - const arr = val.split(/[\n,]+/).map(s => s.trim()).filter(s => s); - if (arr.length > 0) listName = arr[listIndex % arr.length]; - } - } - - if (folderName && listName) { - // Strip extension from folderName, add listName, re-add extension - let base = folderName; - let ext = ''; - const lastDot = folderName.lastIndexOf('.'); - if (lastDot !== -1 && lastDot > 0 && folderName.length - lastDot <= 6) { - base = folderName.substring(0, lastDot); - ext = folderName.substring(lastDot); - } - // Replace any invalid characters in listName just in case, though usually fine - const safeListName = listName.replace(/[\/\\]/g, '_'); - return `${base}_${safeListName}${ext}`; - } else if (folderName) { - return folderName; - } else if (listName) { - return listName; - } - - return `result_${index + 1}`; - }, - - // Get the final filename with appropriate extension if missing - getFinalFilename(result) { - let name = result.inputFilename || `result_${result.index}`; - let originalExt = ''; - - // Extract existing extension if present - const lastDot = name.lastIndexOf('.'); - if (lastDot > 0 && (name.length - lastDot) <= 6) { - originalExt = name.substring(lastDot); - name = name.substring(0, lastDot); - } - - // Map common content types - const ct = (result.contentType || '').toLowerCase(); - if (ct.includes('image/png')) return name + '.png'; - if (ct.includes('image/jpeg') || ct.includes('image/jpg')) return name + '.jpg'; - if (ct.includes('image/gif')) return name + '.gif'; - if (ct.includes('image/webp')) return name + '.webp'; - if (ct.includes('image/svg')) return name + '.svg'; - if (ct.includes('application/pdf')) return name + '.pdf'; - if (ct.includes('application/json')) return name + '.json'; - if (ct.includes('application/xml') || ct.includes('text/xml')) return name + '.xml'; - if (ct.includes('text/html')) return name + '.html'; - if (ct.includes('text/csv')) return name + '.csv'; - if (ct.includes('text/css')) return name + '.css'; - if (ct.includes('text/plain')) return name + '.txt'; - if (ct.includes('application/zip')) return name + '.zip'; - - // Fallback for other binary types: try to extract subtype - if (result.binaryData && ct.includes('/')) { - const subtype = ct.split('/')[1].split(';')[0]; // handle "type/subtype;charset=..." - if (subtype && subtype.length <= 4 && /^[a-z0-9]+$/.test(subtype)) { - return name + '.' + subtype; - } - } - - // Content sniffing for JSON if content type is missing or incorrect - if (!result.binaryData && result.fullContent) { - const trimmed = result.fullContent.trim(); - if ((trimmed.startsWith('{') && trimmed.endsWith('}')) || (trimmed.startsWith('[') && trimmed.endsWith(']'))) { - try { - JSON.parse(trimmed); // Quick validation - return name + '.json'; - } catch(e) {} - } - } - - // If we still don't know the type, fallback to original extension if it existed - if (originalExt) return name + originalExt; - - // Otherwise default based on data format - return result.binaryData ? name + '.bin' : name + '.txt'; - }, - - async saveAsFolder() { - if (!this.state.bulk.results.length) return this.toast('No results to save', 'error'); - - try { - if (!window.showDirectoryPicker) { - return this.toast('Your browser does not support native folder saving. Please use the ZIP button instead.', 'error'); - } - - this.toast('Select a folder to save files...', 'info'); - const dirHandle = await window.showDirectoryPicker({ - mode: 'readwrite' - }); - - let savedCount = 0; - let errors = 0; - const usedNames = new Set(); - - for (const r of this.state.bulk.results) { - try { - let filename = this.getFinalFilename(r); - - let base = filename; - let ext = ''; - const lastDot = filename.lastIndexOf('.'); - if (lastDot !== -1 && lastDot > 0) { - base = filename.substring(0, lastDot); - ext = filename.substring(lastDot); - } - - let counter = 1; - while (usedNames.has(filename)) { - filename = `${base}_${counter}${ext}`; - counter++; - } - usedNames.add(filename); - - // Get the content as binary data - let data; - if (r.binaryData) { - // Convert base64 string to Uint8Array - data = this.base64ToUint8Array(r.binaryData); - } else if (r.fullContent) { - data = r.fullContent; - } else { - continue; // Skip empty results - } - - // Create file and write content - const fileHandle = await dirHandle.getFileHandle(filename, { create: true }); - const writable = await fileHandle.createWritable(); - await writable.write(data); - await writable.close(); - - savedCount++; - } catch (e) { - console.error('Error saving file', r.index, e); - errors++; - } - } - - if (errors > 0) { - this.toast(`Saved ${savedCount} files. Failed to save ${errors} files.`, 'warning'); - } else { - this.toast(`Successfully saved ${savedCount} files to the selected folder.`); - } - - } catch (e) { - console.error(e); - if (e.name === 'AbortError') { - this.toast('Folder selection cancelled.', 'info'); - } else { - this.toast('Failed to save to folder: ' + e.message, 'error'); - } - } - }, - - async saveAllResults() { - if (!this.state.bulk.results.length) return this.toast('No results to save', 'error'); - if (typeof JSZip === 'undefined') return this.toast('JSZip library not loaded. Please refresh.', 'error'); - - this.toast('Building ZIP file...', 'info'); - - const zip = new JSZip(); - let savedCount = 0; - const usedNames = new Set(); - - for (const result of this.state.bulk.results) { - try { - // Use the tracked input filename + auto extension - let filename = this.getFinalFilename(result); - - let base = filename; - let ext = ''; - const lastDot = filename.lastIndexOf('.'); - if (lastDot !== -1 && lastDot > 0) { - base = filename.substring(0, lastDot); - ext = filename.substring(lastDot); - } - - let counter = 1; - while (usedNames.has(filename)) { - filename = `${base}_${counter}${ext}`; - counter++; - } - usedNames.add(filename); - - // Get the content as binary data - let data; - if (result.binaryData) { - // Convert base64 string to Uint8Array - data = this.base64ToUint8Array(result.binaryData); - } else if (result.fullContent) { - data = result.fullContent; - } else { - continue; // Skip empty results - } - - // Add to ZIP (JSZip handles folder creation from path automatically) - zip.file(filename, data, { binary: !!result.binaryData }); - savedCount++; - } catch (e) { - console.error('Error adding result to ZIP', result.index, e); - } - } - - if (savedCount === 0) return this.toast('No valid results to save', 'error'); - - // Generate and download ZIP - try { - this.toast('Generating ZIP, please wait...', 'info'); - const blob = await zip.generateAsync({ type: 'blob' }); - const url = URL.createObjectURL(blob); - - const modal = document.createElement('div'); - modal.className = 'premium-modal-overlay'; - modal.style.zIndex = '9999'; - modal.innerHTML = ` -
- -

ZIP Ready!

-

Successfully bundled ${savedCount} files.

- - Click to Download ZIP - - -
- `; - document.body.appendChild(modal); - - // Note: intentionally not revoking the URL immediately so the manual click works! - - } catch (e) { - this.toast('Error generating ZIP: ' + e.message, 'error'); - } - }, - - // --- Rendering --- - - // Debounced render — coalesces rapid successive calls (e.g., keystrokes) - // into a single animation frame to prevent jank. - scheduleRender() { - if (this._renderScheduled) return; - this._renderScheduled = true; - requestAnimationFrame(() => { - this._renderScheduled = false; - this.render(); - }); - }, - - render() { - const root = document.getElementById('app-root'); - if (root) { - // Reset base class first to prevent layout/theme clashing - root.className = 'workspace'; - - if (this.state.bulk.results.length > 0 || this.state.bulk.running) { - root.classList.add('bulk-active'); - } - if (this.state.gridMaximized || !this.state.activeSpaceId) { - root.classList.add('grid-maximized'); - } - - // Add theme class for active space - if (this.state.activeSpaceId) { - const activeSpace = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - const theme = activeSpace && activeSpace.theme ? activeSpace.theme : 'violet'; - root.classList.add(`theme-${theme}`); - } - } - this.renderSidebar(); - this.renderMain(); - this.renderResponse(); - }, - - renderProgress() { - // Optimized partial render for progress bar - const bar = document.getElementById('progress-bar-fill'); - const text = document.getElementById('progress-text'); - if (bar && text) { - const pct = (this.state.bulk.completed / this.state.bulk.total) * 100; - bar.style.width = `${pct}%`; - text.innerText = `${this.state.bulk.completed} / ${this.state.bulk.total}`; - } - }, - - getCollectionsHTML() { - const query = (this.state.searchQuery || '').toLowerCase().trim(); - let collectionsHTML = ''; - - this.collections.forEach(col => { - const isColActive = this.state.activeCollectionId === col.id; - - // Filter requests - const filteredRequests = col.requests.filter(r => { - if (!query) return true; - return ( - (r.name || '').toLowerCase().includes(query) || - (r.url || '').toLowerCase().includes(query) || - (r.description || '').toLowerCase().includes(query) - ); - }); - - // Decide if the collection itself matches - const colMatches = (col.name || '').toLowerCase().includes(query); - - // If neither collection matches nor has matching requests, skip rendering it - if (query && !colMatches && filteredRequests.length === 0) { - return; - } - - // If there's a query and we have matches, auto-expand the collection - const isExpanded = query ? true : isColActive; - - const reqsHTML = (query && colMatches ? col.requests : filteredRequests).map(r => ` -
- ${r.method} -
-
- ${this.escapeHTML(r.name || '')} -
-
- ${this.escapeHTML(r.url || 'No URL')} -
-
- - -
- `).join(''); - - collectionsHTML += ` -
-
- - ${this.escapeHTML(col.name)} - - - - - -
- ${isExpanded ? `
${reqsHTML || '
Empty Collection
'}
` : ''} -
- `; - }); - - return collectionsHTML; - }, - - filterSidebarCollections(query) { - this.state.searchQuery = query; - const listEl = document.getElementById('sidebar-collections-list'); - if (listEl) { - listEl.innerHTML = this.getCollectionsHTML(); - } - - // Also update clear button visibility - const clearBtn = document.getElementById('search-clear-btn'); - if (clearBtn) { - clearBtn.style.display = query ? 'block' : 'none'; - } - }, - - renderSidebar() { - const collectionsHTML = this.getCollectionsHTML(); - const activeSpace = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - - let notificationsBannerHTML = ''; - if (activeSpace && activeSpace.notifications && activeSpace.notifications.length > 0) { - notificationsBannerHTML = ` -
- - ${activeSpace.notifications.length} pending share request${activeSpace.notifications.length > 1 ? 's' : ''} -
- `; - } - - const spaceOptionsHTML = ` - - ${this.state.spaces.map(s => ` - - `).join('')} - `; - - this.dom.sidebar.innerHTML = ` - - - - ${activeSpace ? ` - ${notificationsBannerHTML} - - - - - - - - - - ` : ` -
-
- -
Select a workspace
from the dashboard
-
-
- `} - - -
- -
- `; - }, - - - renderMain() { - if (!this.state.activeSpaceId) { - // Render Spaces Dashboard Grid View - const spacesCardsHTML = this.state.spaces.map(s => { - const count = s.collections ? s.collections.length : 0; - const notifCount = s.notifications ? s.notifications.length : 0; - const theme = s.theme || 'violet'; - return ` -
-
- - ${notifCount > 0 ? `${notifCount}` : ''} -
-
-

${this.escapeHTML(s.name)}

- ${count} Collections -
-
- - ${this.state.spaces.length > 1 ? ` - - ` : ''} -
-
- `; - }).join(''); - - const dashboardHTML = ` -
-
-

Workspaces

-

Select a workspace to access its collections, endpoints, and history.

-
- -
- ${spacesCardsHTML} - -
-
-
-

Create New Space

- Add a clean workspace -
-
-
-
- `; - - const headerHTML = ` -
-
PHOENIX
-
- Workspace Dashboard -
-
-
- `; - - this.dom.mainPanel.innerHTML = headerHTML + dashboardHTML; - return; - } - - const isBulkStart = this.checkBulkStart(); - const bulk = this.state.bulk; - const activeSpace = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - - // Tab Strip (Postman-like) - const tabStripHTML = ` -
- ${this.tabs.map((tab, i) => { - const isActive = i === this.activeTabIndex; - const tabName = tab.name || (tab.url ? tab.url.split('/').pop() || 'Request' : 'Untitled'); - const displayName = tabName.length > 20 ? tabName.substring(0, 20) + '…' : tabName; - const method = tab.method || 'GET'; - const mc = { GET:'var(--m-get)', POST:'var(--m-post)', PUT:'var(--m-put)', DELETE:'var(--m-delete)', PATCH:'var(--m-patch)' }[method] || 'var(--text-3)'; - return ` -
- ${method} - ${this.escapeHTML(displayName)} - -
- `; - }).join('')} - -
- `; - - // Header with Active Space name/switcher - const headerHTML = ` -
-
- PHOENIX -
-
- - ${this.escapeHTML(activeSpace ? activeSpace.name : '')} - -
- - - - - -
- - -
- - -
- ${bulk.running - ? ` - ` - : bulk.paused - ? ` - ` - : `` - } -
-
- ${tabStripHTML} - `; - - // Request Name & Description Section - const col = activeSpace ? activeSpace.collections.find(c => c.id === this.state.activeCollectionId) : null; - const activeReq = col ? col.requests.find(r => r.id === this.state.activeRequestId) : null; - - const requestMetaHTML = activeReq ? ` -
-
- Name - -
-
- Description - -
-
- ` : ''; - - // Tabs bar (PARAMS / HEADERS / BODY / AUTH + Bulk controls) - const inputStyle = 'background:var(--bg-input);border:1px solid var(--border-2);border-radius:var(--r-xs);color:var(--text-1);padding:3px 6px;font-size:11px;text-align:center;font-family:var(--font-ui);'; - const tabsHTML = ` -
- ${['params', 'headers', 'body', 'auth'].map(t => ` -
${t.toUpperCase()}
- `).join('')} -
-
- ${isBulkStart ? ` -
- Strategy - - -
- ` : ''} -
- Repeat - -
-
- Delay ms - -
-
- Workers - -
-
-
- `; - - - // Content - let contentHTML = ''; - if (this.state.activeTab === 'params') contentHTML = this.renderTable(this.state.params, 'params'); - else if (this.state.activeTab === 'headers') contentHTML = this.renderTable(this.state.headers, 'headers'); - else if (this.state.activeTab === 'body') contentHTML = this.renderBodyTab(); - else if (this.state.activeTab === 'auth') contentHTML = this.renderAuthTab(); - - // Bottom Results & Response Panel (Always Rendered) - const pct = bulk.total > 0 ? (bulk.completed / bulk.total) * 100 : 0; - const statusColor = bulk.error > 0 ? (bulk.success > 0 ? 'var(--warning)' : 'var(--danger)') : 'var(--success)'; - const folderPath = this.state.outputFolderPath || 'None selected'; - const activeBottomTab = this.state.responseTab || 'response'; - - let bottomTabContentHTML = ''; - if (activeBottomTab === 'response') { - const resp = this.state.response; - if (!resp) { - bottomTabContentHTML = `
Ready to send request. Click SEND to execute a single request, or RUN BATCH for bulk.
`; - } else if (resp.status === 'Sending...') { - bottomTabContentHTML = `
Sending request...
`; - } else if (resp.error) { - bottomTabContentHTML = `
Error: ${resp.error}
`; - } else { - let content = resp.content; - try { - if (content && !resp.binary_data && content.trim().startsWith('{')) { - content = JSON.stringify(JSON.parse(content), null, 2); - } - } catch(e){} - - bottomTabContentHTML = ` -
- ${resp.status_code} - ${resp.latency ? resp.latency + ' ms' : ''} - ${resp.content_type || 'Unknown Type'} -
-
- ${resp.binary_data - ? `
- Binary Content -
` - : `
${this.escapeHTML(content)}
` - } -
- `; - } - } else { - if (bulk.results.length === 0) { - bottomTabContentHTML = ` -
- - No batch results yet. Run a batch to see results in a grid. -
- `; - } else { - bottomTabContentHTML = ` -
-
-
-
- `; - } - } - - bottomPanelHTML = ` -
-
- -
-
- - - ${bulk.results.length > 0 ? ` -
- ${bulk.completed}/${bulk.total} - ${bulk.success} ✓ - ${bulk.error} ✗ - ` : ''} -
- - ${activeBottomTab === 'results' && bulk.results.length > 0 ? ` -
-
- - ${folderPath} - - - -
- - - - -
- ` : ''} -
- -
- ${bottomTabContentHTML} -
-
- `; - - this.dom.mainPanel.innerHTML = headerHTML + requestMetaHTML + tabsHTML + `
${contentHTML}
` + bottomPanelHTML; - - // After writing the skeleton, repopulate the results grid from our cached fragment - // This avoids re-rendering 200+ cards on every render() call. - this._repopulateResultsGrid(); - }, - - _repopulateResultsGrid() { - const grid = document.getElementById('main-results-grid'); - if (!grid || !this.state.bulk.results.length) return; - // Use a DocumentFragment to batch all DOM insertions into a single paint - const frag = document.createDocumentFragment(); - const shown = this.state.bulk.results.slice(-200); - shown.forEach(result => { - const el = this._buildCardElement(result); - frag.appendChild(el); - }); - grid.appendChild(frag); - }, - - renderResultCard(result) { - const isImage = (result.contentType || '').toLowerCase().includes('image') && result.binaryData; - const isSuccess = result.status >= 200 && result.status < 300; - const statusClass = isSuccess ? 'status-success' : 'status-error'; - const filename = result.inputFilename || `result_${result.index}`; - const finalFilename = this.getFinalFilename(result); - - let previewHTML = ''; - if (isImage) { - try { - previewHTML = `${filename}`; - } catch (e) { - previewHTML = `
Decode error
`; - } - } else { - let icon = 'fa-file-lines'; - let typeLabel = 'TXT'; - const ct = (result.contentType || '').toLowerCase(); - if (ct.includes('application/json')) { icon = 'fa-file-code'; typeLabel = 'JSON'; } - else if (ct.includes('text/html')) { icon = 'fa-file-code'; typeLabel = 'HTML'; } - else if (result.status === 'ERR') { icon = 'fa-circle-xmark'; typeLabel = 'ERROR'; } - previewHTML = ` -
- - ${typeLabel} -

${this.escapeHTML(result.data || '')}

-
`; - } - - const footerHTML = isImage - ? `` - : `
-
- #${result.index} - ${result.status} - ${result.latency}ms -
-
${finalFilename}
-
`; - - return ` -
-
- ${previewHTML} -
- ${!isImage ? ` - ` : ''} - - - -
-
- ${footerHTML} -
- `; - }, - - renderResponse() { - // No-op: Single response and bulk results have been consolidated into renderMain()'s bottom panel. - }, - - renderTable(items, section) { - return ` - - - - ${items.map(item => ` - - - - - - - `).join('')} - -
KeyValue
- - ${this.renderValueInput(item, section)} -
- - `; - }, - - renderValueInput(item, section) { - if (item.type === 'file' || item.type === 'folder') { - const files = this.fileStore.get(item.id); - const label = files ? (item.type === 'folder' ? `${files.length} Files Selected` : `${files.length} Files`) : 'Select...'; - return ` -
- - -
- `; - } - if (item.type === 'auto_width' || item.type === 'auto_height') { - return ``; - } - return ``; - }, - - renderBodyTab() { - return ` -
-
- - - -
- - ${this.state.bodyType === 'form-data' ? this.renderTable(this.state.bodyData, 'body') : ''} - ${this.state.bodyType === 'json' ? `` : ''} -
- `; - }, - - renderAuthTab() { - const auth = this.state.auth; - const inStyle = 'width:100%;padding:10px 12px;background:var(--bg-input);border:1px solid var(--border-2);border-radius:var(--r-md);color:var(--text-1);font-family:var(--font-mono);font-size:12px;transition:border-color 0.15s,box-shadow 0.15s;'; - const labelStyle = 'display:block;margin-bottom:6px;font-size:9.5px;font-weight:700;text-transform:uppercase;letter-spacing:0.07em;color:var(--text-3);'; - return ` -
- - - - ${auth.type === 'bearer' ? ` -
- - -
- ` : ''} - - ${auth.type === 'basic' ? ` -
-
- - -
-
- - -
-
- ` : ''} - - ${auth.type === 'apikey' ? ` -
-
- - -
-
- - -
-
- ` : ''} -
- `; - }, - - // --- Helpers --- - - handleFileSelect(input, section, id) { - if (input.files.length > 0) { - // Convert FileList to Array and sort by path to ensure strict processing sequence (natural sorting) - let filesArr = Array.from(input.files); - filesArr.sort((a, b) => { - const pA = a.webkitRelativePath || a.name; - const pB = b.webkitRelativePath || b.name; - return pA.localeCompare(pB, undefined, { numeric: true, sensitivity: 'base' }); - }); - this.fileStore.set(id, filesArr); - this.render(); // update label - } - }, - - checkBulkStart() { - const hasKeyedFolder = this.state.params.some(p => p.type === 'folder' && p.enabled && p.key && p.key.trim()) - || (this.state.bodyType === 'form-data' && this.state.bodyData.some(p => p.type === 'folder' && p.enabled && p.key && p.key.trim())); - - const hasKeyedList = this.state.params.some(p => p.type === 'list' && p.enabled && p.key && p.key.trim()) - || (this.state.bodyType === 'form-data' && this.state.bodyData.some(p => p.type === 'list' && p.enabled && p.key && p.key.trim())) - || this.state.headers.some(h => h.type === 'list' && h.enabled && h.key && h.key.trim()); - - return hasKeyedFolder || hasKeyedList; - }, - - getStatusColor(code) { - if (code >= 200 && code < 300) return 'var(--success)'; - if (code >= 300 && code < 400) return 'var(--warning)'; - if (code >= 400 || code === 'ERR') return 'var(--danger)'; - return 'var(--text-muted)'; - }, - - toast(msg, type = 'info') { - const icons = { info: 'fa-circle-info', success: 'fa-circle-check', error: 'fa-circle-xmark', warning: 'fa-triangle-exclamation' }; - const iconColors = { info: '#5ba0f5', success: '#0fcea0', error: '#ff4569', warning: '#f5a623' }; - const icon = icons[type] || icons.info; - const color = iconColors[type] || iconColors.info; - const t = document.createElement('div'); - t.className = `ph-toast-${type}`; - t.innerHTML = `${this.escapeHTML(msg)}`; - Object.assign(t.style, { - display: 'flex', - alignItems: 'center', - gap: '10px', - padding: '12px 16px', - borderRadius: '10px', - marginTop: '6px', - fontSize: '13px', - fontFamily: 'var(--font-ui)', - fontWeight: '500', - animation: 'toastSlideIn 0.32s cubic-bezier(0.34,1.56,0.64,1) both', - }); - this.dom.toast.appendChild(t); - const removeDelay = type === 'error' ? 4500 : 3000; - setTimeout(() => { - t.style.animation = 'toastFadeOut 0.2s ease forwards'; - setTimeout(() => t.remove(), 200); - }, removeDelay); - }, - - escapeHTML(str) { - if (!str) return ''; - if (typeof str !== 'string') return String(str); - return str.replace(/&/g, '&') - .replace(//g, '>') - .replace(/"/g, '"') - .replace(/'/g, '''); - }, - - base64ToUint8Array(base64Data) { - if (!base64Data) return new Uint8Array(0); - try { - const byteCharacters = atob(base64Data); - const data = new Uint8Array(byteCharacters.length); - for (let i = 0; i < byteCharacters.length; i++) { - data[i] = byteCharacters.charCodeAt(i); - } - return data; - } catch (e) { - console.error("Base64 to Uint8Array error", e); - return new Uint8Array(0); - } - }, - - async base64ToBlobUrlAsync(base64Data, contentType) { - if (!base64Data) return ''; - try { - const res = await fetch(`data:${contentType || 'application/octet-stream'};base64,${base64Data}`); - const blob = await res.blob(); - return URL.createObjectURL(blob); - } catch (e) { - console.error("Async Base64 decode error", e); - return ''; - } - }, - - base64ToBlobUrl(base64Data, contentType) { - if (!base64Data) return ''; - try { - const byteCharacters = atob(base64Data); - const byteArrays = []; - const sliceSize = 512; - for (let offset = 0; offset < byteCharacters.length; offset += sliceSize) { - const slice = byteCharacters.slice(offset, offset + sliceSize); - const byteNumbers = new Array(slice.length); - for (let i = 0; i < slice.length; i++) { - byteNumbers[i] = slice.charCodeAt(i); - } - const byteArray = new Uint8Array(byteNumbers); - byteArrays.push(byteArray); - } - const blob = new Blob(byteArrays, {type: contentType}); - return URL.createObjectURL(blob); - } catch (e) { - console.error("Base64 decode error", e); - return ''; - } - }, - - bindEvents() { - // Most events are inline (onclick, onchange) for simplicity in this structure - }, - - // Preview a result - previewResult(index) { - const result = this.state.bulk.results.find(r => r.index === index); - if (!result) return; - - const isImage = (result.contentType || '').toLowerCase().includes('image') && result.binaryData; - const finalFilename = this.getFinalFilename(result); - - let contentHTML = ''; - if (isImage) { - try { - contentHTML = `${finalFilename}`; - } catch (e) { - contentHTML = ``; - } - } else { - let prettyContent = result.fullContent || ''; - try { - if (prettyContent.trim().startsWith('{')) { - prettyContent = JSON.stringify(JSON.parse(prettyContent), null, 2); - } - } catch(e) {} - contentHTML = ``; - } - - const modal = document.createElement('div'); - modal.className = 'premium-modal-overlay'; - - modal.innerHTML = ` -
-
-
- -
- ${finalFilename} - Result #${result.index} -
-
-
- ${result.status} - ${result.latency}ms - -
-
-
- ${contentHTML} -
- -
- `; - - document.body.appendChild(modal); - modal.onclick = () => modal.remove(); - }, - - // For manual clicking from history - loadHistoryItem(id) { - const item = this.state.history.find(h => h.id === id); - if (item) { - this.state.method = item.method; - this.state.url = item.url; - this.saveState(); - this.render(); - } - } -}; - - -document.addEventListener('DOMContentLoaded', () => App.init()); - diff --git a/web/bulk-api-tester/static/js/app.js.bak_perf_fix b/web/bulk-api-tester/static/js/app.js.bak_perf_fix deleted file mode 100644 index 8154540..0000000 --- a/web/bulk-api-tester/static/js/app.js.bak_perf_fix +++ /dev/null @@ -1,2930 +0,0 @@ -/** - * Phoenix App - Advanced Bulk API Tester - * Version: 2.0 (Agentic Edition) - */ - -const App = { - _stateData: { - spaces: [], - activeSpaceId: null, - activeCollectionId: 'default', - - outputFolderPath: '', - gridMaximized: false, - resultsPanelHeight: 300, - sidebarWidth: 270, - searchQuery: '' - }, - - tabs: [], - activeTabIndex: 0, - - get state() { - if (!this._proxyState) { - const props = ['name', 'method', 'url', 'params', 'headers', 'auth', 'bodyType', 'bodyData', 'jsonBody', 'response', 'bulk', 'activeTab', 'responseTab', 'activeRequestId', 'isPreview', 'activeCollectionId']; - this._proxyState = new Proxy(this._stateData, { - get(target, prop) { - if (props.includes(prop)) { - if (App.tabs && App.tabs[App.activeTabIndex]) { - return App.tabs[App.activeTabIndex][prop]; - } - } - return target[prop]; - }, - set(target, prop, value) { - if (props.includes(prop)) { - if (App.tabs && App.tabs[App.activeTabIndex]) { - App.tabs[App.activeTabIndex][prop] = value; - if (prop !== 'activeTab' && prop !== 'responseTab' && prop !== 'activeRequestId') { - App.tabs[App.activeTabIndex].isPreview = false; - } - - // Auto-save logic - const autoSaveProps = ['name', 'method', 'url', 'params', 'headers', 'auth', 'bodyType', 'bodyData', 'jsonBody', 'bulk']; - if (autoSaveProps.includes(prop) && App.tabs[App.activeTabIndex].activeRequestId) { - if (App.debouncedSaveToCollection) { - App.debouncedSaveToCollection(); - } - } - - return true; - } - } - target[prop] = value; - return true; - } - }); - } - return this._proxyState; - }, - - debouncedSaveToCollection() { - if (this._autoSaveTimeout) clearTimeout(this._autoSaveTimeout); - this._autoSaveTimeout = setTimeout(() => { - this.saveToCollection(); - }, 500); - }, - - createNewTab(reqData, isPreview = false) { - return { - id: 'tab_' + Date.now() + Math.random().toString(36).substr(2, 9), - name: reqData ? reqData.name : 'Untitled Request', - method: reqData ? reqData.method : 'POST', - url: reqData ? reqData.url : '', - params: reqData ? JSON.parse(JSON.stringify(reqData.params || [])) : [], - headers: reqData ? JSON.parse(JSON.stringify(reqData.headers || [])) : [], - auth: reqData ? JSON.parse(JSON.stringify(reqData.auth || {type:'none'})) : {type:'none'}, - bodyType: reqData ? reqData.bodyType : 'none', - bodyData: reqData ? JSON.parse(JSON.stringify(reqData.bodyData || [])) : [], - jsonBody: reqData ? reqData.jsonBody : '', - response: null, - bulk: reqData && reqData.bulk ? JSON.parse(JSON.stringify(reqData.bulk)) : { - strategy: 'consecutive', - running: false, - total: 0, - completed: 0, - success: 0, - error: 0, - concurrency: 1, - delay: 0, - repetitions: 10, - results: [] - }, - activeTab: 'params', - responseTab: 'response', - activeRequestId: reqData ? reqData.id : null, - activeCollectionId: reqData ? reqData.activeCollectionId : 'default', - isPreview: isPreview - }; - }, - - - fileStore: new Map(), // id -> FileList - - dom: {}, - - async init() { - this.loadState(); - this.cacheDOM(); - this.bindEvents(); - - // Ensure active tab has at least one param and header row - if (!this.state.params || this.state.params.length === 0) this.addParam('params'); - if (!this.state.headers || this.state.headers.length === 0) this.addParam('headers'); - - // Load spaces from the server to keep them synced - await this.loadSpacesFromServer(); - - // Load the last run results/response from the server - await this.loadLastRunFromServer(); - - // Apply saved sidebar width - const sidebarEl = document.getElementById('sidebar'); - if (sidebarEl && this._stateData.sidebarWidth) { - sidebarEl.style.width = `${this._stateData.sidebarWidth}px`; - } - - // Attach event listener for horizontal sidebar dragging - const handle = document.getElementById('sidebar-resize-handle'); - if (handle) { - handle.addEventListener('mousedown', (e) => this.startSidebarResize(e)); - } - - this.render(); - - // Remove loader - const loader = document.getElementById('loading-overlay'); - if (loader) loader.remove(); - document.getElementById('app-root').style.visibility = 'visible'; - }, - - // --- Tab Management --- - - openNewTab() { - const newTab = this.createNewTab(); - this.tabs.push(newTab); - this.activeTabIndex = this.tabs.length - 1; - if (!this.state.params || this.state.params.length === 0) this.addParam('params'); - if (!this.state.headers || this.state.headers.length === 0) this.addParam('headers'); - this.saveState(); - this.render(); - }, - - switchTab(index) { - if (index < 0 || index >= this.tabs.length) return; - this.activeTabIndex = index; - this.saveState(); - this.render(); - }, - - closeTab(index) { - if (this.tabs.length <= 1) { - // Can't close last tab; just reset it - this.tabs[0] = this.createNewTab(); - this.activeTabIndex = 0; - this.saveState(); - this.render(); - return; - } - this.tabs.splice(index, 1); - if (this.activeTabIndex >= this.tabs.length) { - this.activeTabIndex = this.tabs.length - 1; - } - this.saveState(); - this.render(); - }, - - cacheDOM() { - this.dom = { - mainPanel: document.getElementById('main-panel'), - sidebar: document.getElementById('sidebar'), - toast: document.getElementById('toast-container') - }; - - if (!this.dom.sidebar || !this.dom.mainPanel) { - console.error('Critical: DOM elements not found', this.dom); - alert('Critical Error: Application DOM structure is missing. Please refresh.'); - } - }, - - // --- State Management --- - - loadState() { - try { - const raw = localStorage.getItem('phoenix-state-v2'); - if (raw) { - const data = JSON.parse(raw); - // Restore _stateData (global state) - if (data.spaces !== undefined) this._stateData.spaces = data.spaces; - if (data.activeSpaceId !== undefined) this._stateData.activeSpaceId = data.activeSpaceId; - if (data.activeCollectionId !== undefined) this._stateData.activeCollectionId = data.activeCollectionId; - if (data.outputFolderPath !== undefined) this._stateData.outputFolderPath = data.outputFolderPath; - if (data.gridMaximized !== undefined) this._stateData.gridMaximized = data.gridMaximized; - if (data.resultsPanelHeight !== undefined) this._stateData.resultsPanelHeight = data.resultsPanelHeight; - if (data.sidebarWidth !== undefined) this._stateData.sidebarWidth = data.sidebarWidth; - if (data.searchQuery !== undefined) this._stateData.searchQuery = data.searchQuery; - - // Restore tabs - if (data.tabs && data.tabs.length > 0) { - this.tabs = data.tabs.map(t => ({ - ...t, - bulk: { ...(t.bulk || {}), running: false, results: [] }, - response: null - })); - this.activeTabIndex = Math.min(data.activeTabIndex || 0, this.tabs.length - 1); - } else { - // No saved tabs, create a blank one - this.tabs = [this.createNewTab()]; - this.activeTabIndex = 0; - } - } else { - // Fresh start - this.tabs = [this.createNewTab()]; - this.activeTabIndex = 0; - } - } catch (e) { - console.warn('Failed to load state', e); - this.tabs = [this.createNewTab()]; - this.activeTabIndex = 0; - } - }, - - saveState() { - if (this._saveStateTimeout) clearTimeout(this._saveStateTimeout); - this._saveStateTimeout = setTimeout(() => { - try { - const serializedTabs = this.tabs.map(t => ({ - ...t, - bulk: { ...t.bulk, running: false, results: [] }, - response: null - })); - const persistentState = { - spaces: this._stateData.spaces, - activeSpaceId: this._stateData.activeSpaceId, - activeCollectionId: this._stateData.activeCollectionId, - outputFolderPath: this._stateData.outputFolderPath, - gridMaximized: this._stateData.gridMaximized, - resultsPanelHeight: this._stateData.resultsPanelHeight, - sidebarWidth: this._stateData.sidebarWidth, - searchQuery: this._stateData.searchQuery, - tabs: serializedTabs, - activeTabIndex: this.activeTabIndex - }; - localStorage.setItem('phoenix-state-v2', JSON.stringify(persistentState)); - } catch (e) { - console.warn('Failed to save state', e); - } - }, 300); - }, - - async loadLastRunFromServer() { - try { - const res = await fetch('/api/last-run'); - if (res.ok) { - const data = await res.json(); - if (data) { - if (data.bulk) { - this.state.bulk = { ...this.state.bulk, ...data.bulk, running: false }; - } - if (data.response !== undefined) { - this.state.response = data.response; - } - if (data.responseTab) { - this.state.responseTab = data.responseTab; - } - } - } - } catch (e) { - console.error('Failed to load last run from server', e); - } - }, - - async saveLastRunToServer() { - try { - const lightweightResults = this.state.bulk.results.map(r => ({ - ...r, - binaryData: null, - fullContent: null - })); - - const payload = { - bulk: { ...this.state.bulk, running: false, results: lightweightResults }, - response: this.state.response, - responseTab: this.state.responseTab - }; - await fetch('/api/last-run', { - method: 'POST', - headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify(payload) - }); - } catch (e) { - console.error('Failed to save last run to server', e); - } - }, - - saveLastRunToServerThrottled() { - if (this._saveThrottleTimeout) return; - this._saveThrottleTimeout = setTimeout(async () => { - this._saveThrottleTimeout = null; - await this.saveLastRunToServer(); - }, 1000); - }, - - get collections() { - if (!this.state.activeSpaceId) return []; - const space = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - return space ? space.collections : []; - }, - - set collections(val) { - if (!this.state.activeSpaceId) return; - const space = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - if (space) { - space.collections = val; - } - }, - - get notifications() { - if (!this.state.activeSpaceId) return []; - const space = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - return space ? (space.notifications || []) : []; - }, - - set notifications(val) { - if (!this.state.activeSpaceId) return; - const space = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - if (space) { - space.notifications = val; - } - }, - - async loadSpacesFromServer() { - try { - const res = await fetch('/api/spaces'); - const data = await res.json(); - if (Array.isArray(data)) { - // Check if server returned empty or only the default empty spaces - const serverIsEmpty = data.length === 0 || ( - data.length === 2 && - data[0].id === 'personal' && data[0].collections.length === 1 && (!data[0].collections[0].requests || data[0].collections[0].requests.length === 0) && - data[1].id === 'team' && data[1].collections.length === 1 && (!data[1].collections[0].requests || data[1].collections[0].requests.length === 0) - ); - - // Check if client had non-empty legacy collections in localStorage - const clientHasLegacyCollections = this.state.collections && ( - this.state.collections.length > 1 || - (this.state.collections[0] && this.state.collections[0].requests && this.state.collections[0].requests.length > 0) - ); - - if (serverIsEmpty && clientHasLegacyCollections) { - console.log('Migrating local client collections to spaces...'); - this.state.spaces = [ - { - id: 'personal', - name: 'Personal Space', - collections: JSON.parse(JSON.stringify(this.state.collections)) - }, - { - id: 'team', - name: 'Team Space', - collections: JSON.parse(JSON.stringify(this.state.collections)) - } - ]; - delete this.state.collections; - await this.saveSpacesToServer(); - } else if (data.length === 0 && this.state.spaces && this.state.spaces.length > 0) { - await this.saveSpacesToServer(); - } else if (data.length > 0) { - this.state.spaces = data; - } - - // Validate activeSpaceId - if (this.state.activeSpaceId) { - const spaceExists = this.state.spaces.some(s => s.id === this.state.activeSpaceId); - if (!spaceExists) { - this.state.activeSpaceId = null; - this.state.activeCollectionId = 'default'; - this.state.activeRequestId = null; - } - } - } - } catch (e) { - console.error('Failed to load spaces from server:', e); - } - }, - - async saveSpacesToServer() { - try { - await fetch('/api/spaces', { - method: 'POST', - headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify(this.state.spaces) - }); - } catch (e) { - console.error('Failed to sync spaces with server:', e); - } - }, - - openSpace(spaceId) { - this.state.activeSpaceId = spaceId; - this.state.activeCollectionId = 'default'; - this.state.activeRequestId = null; - this.saveState(); - this.render(); - }, - - showSpacesDashboard() { - this.state.activeSpaceId = null; - this.state.activeCollectionId = 'default'; - this.state.activeRequestId = null; - this.saveState(); - this.render(); - }, - - async createSpace() { - const name = prompt("Enter space name:"); - if (name && name.trim()) { - const id = 'space_' + Date.now(); - this.state.spaces.push({ - id: id, - name: name.trim(), - collections: [{ id: 'default', name: 'My Requests', requests: [] }] - }); - this.state.activeSpaceId = id; - this.saveState(); - await this.saveSpacesToServer(); - this.render(); - } - }, - - async deleteSpace(spaceId) { - if (this.state.spaces.length <= 1) { - return this.toast("Cannot delete the last remaining space", "error"); - } - if (confirm("Are you sure you want to delete this space? All collections and requests inside it will be permanently lost.")) { - this.state.spaces = this.state.spaces.filter(s => s.id !== spaceId); - if (this.state.activeSpaceId === spaceId) { - this.state.activeSpaceId = null; - this.state.activeCollectionId = 'default'; - this.state.activeRequestId = null; - } - this.saveState(); - await this.saveSpacesToServer(); - this.render(); - } - }, - - renameSpace(spaceId) { - const space = this.state.spaces.find(s => s.id === spaceId); - if (!space) return; - const newName = prompt("Enter new workspace name:", space.name); - if (newName && newName.trim()) { - space.name = newName.trim(); - this.saveState(); - this.saveSpacesToServer(); - this.render(); - } - }, - - async setSpaceTheme(themeId) { - const activeSpace = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - if (activeSpace) { - activeSpace.theme = themeId; - this.saveState(); - await this.saveSpacesToServer(); - this.render(); - this.toast(`Applied ${themeId} theme to ${activeSpace.name}`); - } - }, - - async shareCollection(colId) { - const otherSpaces = this.state.spaces.filter(s => s.id !== this.state.activeSpaceId); - if (otherSpaces.length === 0) { - return this.toast("No other spaces to share with", "warning"); - } - - const activeSpace = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - const collection = this.collections.find(c => c.id === colId); - if (!collection) return; - - const spacesList = otherSpaces.map((s, idx) => `${idx + 1}. ${s.name}`).join('\n'); - const choice = prompt(`Select workspace to share "${collection.name}" with (enter number):\n${spacesList}`); - if (choice) { - const idx = parseInt(choice) - 1; - if (idx >= 0 && idx < otherSpaces.length) { - const targetSpace = otherSpaces[idx]; - targetSpace.notifications = targetSpace.notifications || []; - - const alreadyShared = targetSpace.notifications.some(n => n.collection.id === colId && n.fromSpaceId === this.state.activeSpaceId); - if (alreadyShared) { - return this.toast("Already shared with this space, pending approval", "warning"); - } - - targetSpace.notifications.push({ - id: 'share_' + Date.now(), - fromSpaceId: this.state.activeSpaceId, - fromSpaceName: activeSpace ? activeSpace.name : 'Unknown Space', - collection: JSON.parse(JSON.stringify(collection)) - }); - - this.saveState(); - await this.saveSpacesToServer(); - this.toast(`Shared collection with ${targetSpace.name}!`); - this.render(); - } else { - this.toast("Invalid selection", "error"); - } - } - }, - - openNotificationsModal() { - const activeSpace = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - if (!activeSpace || !activeSpace.notifications || activeSpace.notifications.length === 0) return; - - const modal = document.createElement('div'); - modal.className = 'premium-modal-overlay'; - modal.id = 'notifications-modal'; - - const listHTML = activeSpace.notifications.map(n => ` -
-
- -
-
${this.escapeHTML(n.fromSpaceName)} shared collection:
-
${this.escapeHTML(n.collection.name)}
- ${n.collection.requests ? n.collection.requests.length : 0} Requests -
-
-
- - -
-
- `).join(''); - - modal.innerHTML = ` -
-
-

Share Requests

- -
-
- ${listHTML} -
- -
- `; - document.body.appendChild(modal); - modal.onclick = (e) => { if (e.target === modal) modal.remove(); }; - }, - - async approveShare(notifId) { - const activeSpace = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - if (!activeSpace || !activeSpace.notifications) return; - - const idx = activeSpace.notifications.findIndex(n => n.id === notifId); - if (idx >= 0) { - const notif = activeSpace.notifications[idx]; - const collection = notif.collection; - - let newName = collection.name; - let counter = 1; - while (activeSpace.collections.some(c => c.name === newName)) { - newName = `${collection.name} (${counter++})`; - } - collection.name = newName; - collection.id = 'col_' + Date.now(); - - activeSpace.collections.push(collection); - activeSpace.notifications.splice(idx, 1); - - this.saveState(); - await this.saveSpacesToServer(); - this.toast("Collection approved and added!"); - this.render(); - } - }, - - async rejectShare(notifId) { - const activeSpace = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - if (!activeSpace || !activeSpace.notifications) return; - - const idx = activeSpace.notifications.findIndex(n => n.id === notifId); - if (idx >= 0) { - activeSpace.notifications.splice(idx, 1); - this.saveState(); - await this.saveSpacesToServer(); - this.toast("Share request rejected"); - this.render(); - } - }, - - startSidebarResize(e) { - e.preventDefault(); - document.body.classList.add('resizing'); - const startX = e.clientX; - const startWidth = this.state.sidebarWidth || 270; - const handle = document.getElementById('sidebar-resize-handle'); - if (handle) handle.classList.add('active'); - - const doDrag = (moveEvent) => { - const deltaX = moveEvent.clientX - startX; - const newWidth = Math.max(180, Math.min(600, startWidth + deltaX)); - this.state.sidebarWidth = newWidth; - const sidebarEl = document.getElementById('sidebar'); - if (sidebarEl) { - sidebarEl.style.width = `${newWidth}px`; - } - }; - - const stopDrag = () => { - document.body.classList.remove('resizing'); - document.removeEventListener('mousemove', doDrag); - document.removeEventListener('mouseup', stopDrag); - if (handle) handle.classList.remove('active'); - this.saveState(); - }; - - document.addEventListener('mousemove', doDrag); - document.addEventListener('mouseup', stopDrag); - }, - - replaceResultCardInDOM(result) { - const cardHTML = this.renderResultCard(result); - document.querySelectorAll(`.result-card[data-index="${result.index}"]`).forEach(card => { - const tmp = document.createElement('div'); - tmp.innerHTML = cardHTML; - card.replaceWith(tmp.firstElementChild); - }); - }, - - async resendBulkRequest(resultIndex) { - const index = resultIndex - 1; // 0-based index - const bulk = this.state.bulk; - const resultItem = bulk.results.find(r => r.index === resultIndex); - if (!resultItem) return; - - this.toast(`Re-sending request #${resultIndex}...`, 'info'); - - // Recalculate maxFiles and maxList to determine fileIndex and listIndex 1-to-1 - let maxFiles = 0; - let maxList = 0; - - const folders = [ - ...this.state.params.filter(p => p.type === 'folder' && p.enabled && p.key && p.key.trim()), - ...(this.state.bodyType === 'form-data' ? this.state.bodyData.filter(p => p.type === 'folder' && p.enabled && p.key && p.key.trim()) : []) - ]; - if (folders.length > 0) { - for (const f of folders) { - const files = this.fileStore.get(f.id); - if (files && files.length > maxFiles) maxFiles = files.length; - } - } - - const allLists = [ - ...this.state.params.filter(p => p.type === 'list' && p.enabled && p.key && p.key.trim()), - ...(this.state.bodyType === 'form-data' ? this.state.bodyData.filter(p => p.type === 'list' && p.enabled && p.key && p.key.trim()) : []), - ...this.state.headers.filter(h => h.type === 'list' && h.enabled && h.key && h.key.trim()) - ]; - if (allLists.length > 0) { - for (const listParam of allLists) { - const val = listParam.value || ''; - const arr = val.split(/[\n,]+/).map(s => s.trim()).filter(s => s); - if (arr.length > maxList) maxList = arr.length; - } - } - - let fileIndex = index; - let listIndex = index; - if (bulk.strategy === 'cartesian' && maxFiles > 0 && maxList > 0) { - fileIndex = Math.floor(index / maxList); - listIndex = index % maxList; - } - - try { - const res = await this.executeRequest(index, fileIndex, listIndex); - const isSuccess = res.status_code >= 200 && res.status_code < 300; - - // Adjust stats counters - const wasSuccess = resultItem.status >= 200 && resultItem.status < 300; - if (wasSuccess && !isSuccess) { - bulk.success--; - bulk.error++; - } else if (!wasSuccess && isSuccess) { - bulk.success++; - bulk.error--; - } - - // Update item details - resultItem.status = res.status_code; - resultItem.latency = res.latency || 0; - resultItem.data = res.content ? res.content.substring(0, 100) : (res.binary_data ? '[Binary]' : ''); - resultItem.fullContent = res.content; - resultItem.binaryData = res.binary_data; - resultItem.contentType = res.content_type; - resultItem.headers = res.headers; - - if (resultItem.blobUrl && resultItem.blobUrl !== res.blobUrl) { - URL.revokeObjectURL(resultItem.blobUrl); - } - resultItem.blobUrl = res.blobUrl; - - this.toast(`Request #${resultIndex} completed: ${res.status_code}`, isSuccess ? 'info' : 'error'); - this.updateBulkProgressUI(); - this.replaceResultCardInDOM(resultItem); - await this.saveLastRunToServer(); - } catch (e) { - const wasSuccess = resultItem.status >= 200 && resultItem.status < 300; - if (wasSuccess) { - bulk.success--; - bulk.error++; - } - resultItem.status = 'ERR'; - resultItem.latency = 0; - resultItem.data = e.message; - this.toast(`Request #${resultIndex} failed: ${e.message}`, 'error'); - this.updateBulkProgressUI(); - this.replaceResultCardInDOM(resultItem); - await this.saveLastRunToServer(); - } - }, - - startResultsResize(e) { - e.preventDefault(); - document.body.classList.add('resizing'); - const startY = e.clientY; - const startHeight = this.state.resultsPanelHeight || 300; - - const doDrag = (moveEvent) => { - const deltaY = startY - moveEvent.clientY; - const newHeight = Math.max(120, Math.min(800, startHeight + deltaY)); - this.state.resultsPanelHeight = newHeight; - const panel = document.querySelector('.bottom-results-panel'); - if (panel) { - panel.style.height = `${newHeight}px`; - } - }; - - const stopDrag = () => { - document.body.classList.remove('resizing'); - document.removeEventListener('mousemove', doDrag); - document.removeEventListener('mouseup', stopDrag); - this.saveState(); - }; - - document.addEventListener('mousemove', doDrag); - document.addEventListener('mouseup', stopDrag); - }, - - appendResultCardToDOM(result) { - const cardHTML = this.renderResultCard(result); - - const appendToGrid = (selector) => { - const grid = document.querySelector(selector); - if (!grid) return; - - const spinner = grid.querySelector('div[style*="fa-spinner"]'); - if (spinner) spinner.remove(); - - const tmp = document.createElement('div'); - tmp.innerHTML = cardHTML; - const newElement = tmp.firstElementChild; - grid.appendChild(newElement); - - while (grid.children.length > 1000) { - grid.removeChild(grid.firstElementChild); - } - }; - - appendToGrid('.results-grid'); - appendToGrid('.fullscreen-results-grid'); - }, - - updateBulkProgressUI() { - if (this._rafPending) return; - this._rafPending = true; - requestAnimationFrame(() => { - this._rafPending = false; - const bulk = this.state.bulk; - const pct = bulk.total > 0 ? (bulk.completed / bulk.total) * 100 : 0; - const statusColor = bulk.error > 0 ? (bulk.success > 0 ? 'var(--warning)' : 'var(--danger)') : 'var(--success)'; - - document.querySelectorAll('#progress-bar-fill, .progress-fill').forEach(bar => { - bar.style.width = `${pct}%`; - bar.style.background = statusColor; - }); - - document.querySelectorAll('#progress-text').forEach(el => el.innerText = `${bulk.completed} / ${bulk.total} Completed`); - document.querySelectorAll('.stat-capsule').forEach(el => { - if (el.classList.contains('success')) { - el.innerText = `${bulk.success} Success`; - } else if (el.classList.contains('error')) { - el.innerText = `${bulk.error} Failed`; - } else if (el.innerText.includes('Completed')) { - el.innerText = `${bulk.completed} / ${bulk.total} Completed`; - } - }); - // Intentionally NOT calling saveLastRunToServer here to prevent massive JSON stringify lag during execution! - }); - }, - - - openFullscreenResults() { - const bulk = this.state.bulk; - if (bulk.results.length === 0 && !bulk.running) { - return this.toast("No results to view in fullscreen", "warning"); - } - - let modal = document.getElementById('fullscreen-results-overlay'); - const pct = bulk.total > 0 ? (bulk.completed / bulk.total) * 100 : 0; - const statusColor = bulk.error > 0 ? (bulk.success > 0 ? 'var(--warning)' : 'var(--danger)') : 'var(--success)'; - const cardsHTML = bulk.results.slice(-200).map(r => this.renderResultCard(r)).join(''); - const folderPath = this.state.outputFolderPath || 'None selected'; - - const contentHTML = ` -
-
- -
-

Fullscreen Batch Processing Grid

-

Real-time execution monitoring and visual results

-
-
- ${bulk.completed} / ${bulk.total} Completed - ${bulk.success} Success - ${bulk.error} Failed -
-
- -
-
- - ${folderPath} - - - -
- - - - -
-
- -
-
-
- -
- ${cardsHTML || `
Executing batch requests, processing results...
`} -
- `; - - if (!modal) { - modal = document.createElement('div'); - modal.className = 'fullscreen-results-overlay'; - modal.id = 'fullscreen-results-overlay'; - modal.innerHTML = contentHTML; - document.body.appendChild(modal); - } else { - modal.innerHTML = contentHTML; - } - }, - - closeFullscreenResults() { - const modal = document.getElementById('fullscreen-results-overlay'); - if (modal) { - modal.remove(); - } - }, - - async browseServerFolder() { - try { - const res = await fetch('/api/browse_folder', { - method: 'POST' - }); - const data = await res.json(); - if (data.success) { - this.state.outputFolderPath = data.path; - this.saveState(); - this.render(); - this.toast(`Folder selected: ${data.path}`); - } else { - this.toast(data.error || 'Failed to browse folder', 'error'); - } - } catch (e) { - this.toast(`Error browsing folder: ${e.message}`, 'error'); - } - }, - - async saveToServerFolder() { - if (!this.state.bulk.results.length) return this.toast('No results to save', 'error'); - if (!this.state.outputFolderPath) { - this.toast('Please select an output folder first', 'error'); - await this.browseServerFolder(); - if (!this.state.outputFolderPath) return; - } - - try { - this.toast('Saving files to server folder...', 'info'); - - // First ensure the latest run is persisted on the server - await this.saveLastRunToServer(); - - // Ask the server to save from its own copy (avoids sending huge binary payloads) - const res = await fetch('/api/save_folder_from_lastrun', { - method: 'POST', - headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ path: this.state.outputFolderPath }) - }); - - const data = await res.json(); - if (data.success) { - const errMsg = data.errors && data.errors.length > 0 ? ` (${data.errors.length} errors)` : ''; - this.toast(`Saved ${data.count} files to ${this.state.outputFolderPath}${errMsg}`); - if (data.errors && data.errors.length > 0) { - console.warn('Save errors:', data.errors); - } - } else { - this.toast(`Failed to save: ${data.error}`, 'error'); - } - } catch (e) { - this.toast(`Error saving to folder: ${e.message}`, 'error'); - } - }, - - async saveIndividualToServerFolder(index) { - const result = this.state.bulk.results.find(r => r.index === index); - if (!result) return; - - if (!this.state.outputFolderPath) { - this.toast('Please select an output folder first', 'error'); - await this.browseServerFolder(); - if (!this.state.outputFolderPath) return; - } - - try { - // Ensure server has latest run data - await this.saveLastRunToServer(); - - const res = await fetch('/api/save_folder_from_lastrun', { - method: 'POST', - headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ - path: this.state.outputFolderPath, - indices: [index] - }) - }); - - const data = await res.json(); - if (data.success && data.count > 0) { - this.toast(`Saved file #${index} to server folder`); - } else { - this.toast(`Failed to save: ${data.error || (data.errors && data.errors[0]) || 'Unknown error'}`, 'error'); - } - } catch (e) { - this.toast(`Error saving file: ${e.message}`, 'error'); - } - }, - - downloadIndividualResult(index) { - const result = this.state.bulk.results.find(r => r.index === index); - if (!result) return; - - try { - const finalFilename = this.getFinalFilename(result); - let url; - let needsRevoke = false; - - if (result.binaryData) { - if (result.blobUrl) { - url = result.blobUrl; - } else { - url = this.base64ToBlobUrl(result.binaryData, result.contentType || 'application/octet-stream'); - needsRevoke = true; - } - } else if (result.fullContent) { - const blob = new Blob([result.fullContent], { type: result.contentType || 'text/plain' }); - url = URL.createObjectURL(blob); - needsRevoke = true; - } else { - return this.toast('No content to download', 'error'); - } - - const a = document.createElement('a'); - a.href = url; - a.download = finalFilename; - document.body.appendChild(a); - a.click(); - document.body.removeChild(a); - if (needsRevoke) { - URL.revokeObjectURL(url); - } - - this.toast(`Downloaded "${finalFilename}"`); - } catch (e) { - this.toast(`Download failed: ${e.message}`, 'error'); - } - }, - - clearBulkResults() { - if (confirm("Are you sure you want to clear all batch results?")) { - this.state.bulk.results = []; - this.state.bulk.completed = 0; - this.state.bulk.success = 0; - this.state.bulk.error = 0; - this.state.bulk.total = 0; - this.state.bulk.running = false; - this.saveState(); - this.saveLastRunToServer(); - this.render(); - } - }, - - toggleGridMaximized() { - this.state.gridMaximized = !this.state.gridMaximized; - this.render(); - }, - - // --- Actions --- - - addParam(section) { - const item = { id: Date.now().toString() + Math.random(), key: '', value: '', type: 'text', enabled: true }; - if (section === 'params') this.state.params.push(item); - if (section === 'headers') this.state.headers.push(item); - if (section === 'body') this.state.bodyData.push(item); - this.render(); - this.saveState(); - }, - - removeParam(section, id) { - if (section === 'params') this.state.params = this.state.params.filter(p => p.id !== id); - if (section === 'headers') this.state.headers = this.state.headers.filter(p => p.id !== id); - if (section === 'body') this.state.bodyData = this.state.bodyData.filter(p => p.id !== id); - this.render(); - this.saveState(); - }, - - updateParam(section, id, field, value) { - const list = section === 'params' ? this.state.params : (section === 'headers' ? this.state.headers : this.state.bodyData); - const item = list.find(p => p.id === id); - if (item) { - item[field] = value; - this.saveState(); - // Re-render if type changes to show/hide file input - if (field === 'type' || field === 'enabled') this.render(); - } - }, - - // --- Request Execution --- - - async sendRequest() { - if (!this.state.url) return this.toast('URL is required', 'error'); - - // Reset bulk results upon sending another single request - this.state.bulk.results = []; - this.state.bulk.completed = 0; - this.state.bulk.success = 0; - this.state.bulk.error = 0; - this.state.bulk.total = 0; - - this.state.response = { status: 'Sending...', headers: {} }; - this.state.responseTab = 'response'; // Switch view - this.render(); - this.saveLastRunToServerThrottled(); - - try { - const start = Date.now(); - const res = await this.executeRequest(0); - const latency = Date.now() - start; - - res.latency = latency; - this.state.response = res; - if (res.blobUrl) this.state.response.blobUrl = res.blobUrl; - this.saveToCollection(res.status_code || 500); - } catch (e) { - this.state.response = { error: e.message }; - } - - this.render(); - this.saveState(); - await this.saveLastRunToServer(); - }, - - // --- Bulk Execution --- - - async runBulk() { - if (!this.state.url) return this.toast('URL is required', 'error'); - - // Calculate total items based on folders or lists - let maxFiles = 0; - let maxList = 0; - const currentRunId = Date.now(); - this.state.bulk.currentRunId = currentRunId; - - // Check folders first - only those that will actually be used - const folders = [ - ...this.state.params.filter(p => p.type === 'folder' && p.enabled && p.key && p.key.trim()), - ...(this.state.bodyType === 'form-data' ? this.state.bodyData.filter(p => p.type === 'folder' && p.enabled && p.key && p.key.trim()) : []) - ]; - - if (folders.length > 0) { - // Find max file count - for (const f of folders) { - const files = this.fileStore.get(f.id); - if (files && files.length > maxFiles) maxFiles = files.length; - } - } - - // Check lists (params, body, headers) - only those with keys - const allLists = [ - ...this.state.params.filter(p => p.type === 'list' && p.enabled && p.key && p.key.trim()), - ...(this.state.bodyType === 'form-data' ? this.state.bodyData.filter(p => p.type === 'list' && p.enabled && p.key && p.key.trim()) : []), - ...this.state.headers.filter(h => h.type === 'list' && h.enabled && h.key && h.key.trim()) - ]; - - if (allLists.length > 0) { - // Find the longest list - for (const listParam of allLists) { - const val = listParam.value || ''; - const arr = val.split(/[\n,]+/).map(s => s.trim()).filter(s => s); - if (arr.length > maxList) maxList = arr.length; - } - } - - let total = 0; - if (this.state.bulk.strategy === 'cartesian' && maxFiles > 0 && maxList > 0) { - total = maxFiles * maxList; - } else { - total = Math.max(maxFiles, maxList); - } - - // If still no total, use the saved repetitions setting - if (total === 0) { - total = Math.max(1, parseInt(this.state.bulk.repetitions) || 10); - } - - if (total <= 0) return this.toast('Invalid bulk count', 'error'); - - // Init Bulk State - if (!this.state.bulk.paused) { - this.state.bulk.total = total; - this.state.bulk.completed = 0; - this.state.bulk.success = 0; - this.state.bulk.error = 0; - this.state.bulk.results = []; - this.state.bulk.nextIndex = 0; - this.state.responseTab = 'results'; - } else { - this.state.bulk.total = total; - } - - this.state.bulk.running = true; - this.state.bulk.paused = false; - - this.saveToCollection('BULK'); - this.render(); - - // Execution Queue - const concurrency = Math.max(1, Math.min(20, this.state.bulk.concurrency || 1)); - let active = 0; - - const worker = async () => { - while (this.state.bulk.nextIndex < this.state.bulk.total && this.state.bulk.running && this.state.bulk.currentRunId === currentRunId) { - const index = this.state.bulk.nextIndex++; - active++; - - let fileIndex = index; - let listIndex = index; - if (this.state.bulk.strategy === 'cartesian' && maxFiles > 0 && maxList > 0) { - fileIndex = Math.floor(index / maxList); - listIndex = index % maxList; - } - - const inputFilename = this.getInputFilename(index, fileIndex, listIndex); - - try { - const res = await this.executeRequest(index, fileIndex, listIndex); - - if (this.state.bulk.currentRunId !== currentRunId) return; - - const isSuccess = res.status_code >= 200 && res.status_code < 300; - if (isSuccess) this.state.bulk.success++; else this.state.bulk.error++; - - this.state.bulk.results.push({ - index: index + 1, - status: res.status_code, - latency: res.latency || 0, - data: res.content ? res.content.substring(0, 100) : (res.binary_data ? '[Binary]' : ''), - fullContent: res.content, - binaryData: res.binary_data, - blobUrl: res.blobUrl, - contentType: res.content_type, - headers: res.headers, - inputFilename: inputFilename - }); - - const newResult = this.state.bulk.results[this.state.bulk.results.length - 1]; - this.appendResultCardToDOM(newResult); - if (this.state.bulk.results.length > 1000) this.state.bulk.results.shift(); - - } catch (e) { - if (this.state.bulk.currentRunId !== currentRunId) return; - this.state.bulk.error++; - this.state.bulk.results.push({ - index: index + 1, - status: 'ERR', - latency: 0, - data: e.message, - inputFilename: inputFilename - }); - const errResult = this.state.bulk.results[this.state.bulk.results.length - 1]; - this.appendResultCardToDOM(errResult); - } finally { - active--; - this.state.bulk.completed++; - if (this.state.bulk.currentRunId === currentRunId) { - this.updateBulkProgressUI(); - } - } - - // Apply inter-request delay (only when concurrency = 1 or after each request) - const delayMs = parseInt(this.state.bulk.delay) || 0; - if (delayMs > 0 && this.state.bulk.running && this.state.bulk.currentRunId === currentRunId) { - await new Promise(r => setTimeout(r, delayMs)); - } - } - - if (active === 0 && this.state.bulk.nextIndex >= this.state.bulk.total && this.state.bulk.currentRunId === currentRunId) { - this.state.bulk.running = false; - this.state.bulk.paused = false; - // Sort final results by index before final render - this.state.bulk.results.sort((a, b) => a.index - b.index); - this.render(); - this.toast('Bulk Operation Completed'); - await this.saveLastRunToServer(); - } - }; - - // Spawn workers - for (let i = 0; i < concurrency; i++) { - worker(); - } - }, - - stopBulk() { - this.state.bulk.running = false; - this.state.bulk.paused = false; - this.render(); - }, - - pauseBulk() { - if (this.state.bulk.running) { - this.state.bulk.running = false; - this.state.bulk.paused = true; - this.render(); - this.toast('Bulk Operation Paused', 'warning'); - } - }, - - resumeBulk() { - if (this.state.bulk.paused) { - this.runBulk(); - } - }, - - async getImageDimensions(file) { - return new Promise((resolve) => { - if (!file || !file.type.startsWith('image/')) return resolve({width: 0, height: 0}); - const img = new Image(); - const url = URL.createObjectURL(file); - img.onload = () => { - resolve({width: img.width, height: img.height}); - URL.revokeObjectURL(url); - }; - img.onerror = () => { - resolve({width: 0, height: 0}); - URL.revokeObjectURL(url); - }; - img.src = url; - }); - }, - - async executeRequest(index, fileIndex = index, listIndex = index) { - const start = Date.now(); - // Headers - const headers = {}; - this.state.headers.filter(h => h.enabled && h.key && h.key.trim()).forEach(h => { - // Handle list replacement in headers too - let val = h.value; - if (h.type === 'list') { - const arr = val.split(/[\n,]+/).map(s => s.trim()).filter(s => s); - if (arr.length > 0) val = arr[listIndex % arr.length]; - } - headers[h.key.trim()] = val; - }); - - // Auth - const auth = this.state.auth; - if (auth.type === 'bearer') headers['Authorization'] = `Bearer ${auth.token}`; - else if (auth.type === 'basic') headers['Authorization'] = 'Basic ' + btoa(`${auth.username}:${auth.password}`); - else if (auth.type === 'apikey') headers[auth.key] = auth.value; - - // URL Params - const urlObj = new URL(this.state.url); - this.state.params.filter(p => p.enabled && p.key && p.key.trim()).forEach(p => { - let val = p.value; - // List handling - if (p.type === 'list') { - // Try splitting by newline first if present, else comma - const arr = val.split(/[\n,]+/).map(s => s.trim()).filter(s => s); - if (arr.length > 0) val = arr[listIndex % arr.length]; - } - // File logic not applicable for URL params usually, skipping - urlObj.searchParams.append(p.key, val); - }); - - // Payload Construction - const finalData = new FormData(); - finalData.append('method', this.state.method); - finalData.append('url', urlObj.toString()); - finalData.append('headers', JSON.stringify(headers)); - // Add auth config for server-side handling if needed (e.g. Basic Auth via requests arg) - if (auth.type === 'basic') finalData.append('auth', JSON.stringify({ type: 'basic', username: auth.username, password: auth.password })); - - // Body - if (this.state.bodyType === 'json') { - finalData.append('body_type', 'json'); - finalData.append('body', this.state.jsonBody); - } else if (this.state.bodyType === 'form-data') { - finalData.append('body_type', 'form-data'); - - let currentImageFile = null; - const folderParam = this.state.bodyData.find(p => p.enabled && p.type === 'folder'); - if (folderParam) { - const files = this.fileStore.get(folderParam.id); - if (files && files.length > 0) currentImageFile = files[fileIndex % files.length]; - } - if (!currentImageFile) { - const fileParam = this.state.bodyData.find(p => p.enabled && p.type === 'file'); - if (fileParam) { - const files = this.fileStore.get(fileParam.id); - if (files && files.length > 0) currentImageFile = files[0]; - } - } - let imgDims = null; - - const bodyParams = this.state.bodyData.filter(p => p.enabled && (p.type === 'file' || p.type === 'folder' || p.type === 'auto_width' || p.type === 'auto_height' || (p.key && p.key.trim()))); - for (const p of bodyParams) { - if (p.type === 'file' || p.type === 'folder') { - const files = this.fileStore.get(p.id); - if (files && files.length > 0) { - if (p.type === 'folder') { - finalData.append(p.key, files[fileIndex % files.length]); - } else { - for (let f of files) finalData.append(p.key, f); - } - } - } else if (p.type === 'auto_width' || p.type === 'auto_height') { - if (!imgDims) imgDims = await this.getImageDimensions(currentImageFile); - finalData.append(p.key, p.type === 'auto_width' ? imgDims.width : imgDims.height); - } else { - let val = p.value; - if (p.type === 'list') { - const arr = val.split(/[\n,]+/).map(s => s.trim()).filter(s => s); - if (arr.length > 0) val = arr[listIndex % arr.length]; - } - finalData.append(p.key, val); - } - } - } - - const res = await fetch('/api/proxy-request', { - method: 'POST', - body: finalData - }); - - const data = await res.json(); - if (data.binary_data) { - data.blobUrl = await this.base64ToBlobUrlAsync(data.binary_data, data.content_type); - } - data.latency = Date.now() - start; - return data; - }, - - saveToCollection(lastStatus) { - if (!this.state.url) return; - - let targetColId = this.state.activeCollectionId || 'default'; - let col = this.collections.find(c => c.id === targetColId); - if (!col) { - col = this.collections.find(c => c.id === 'default'); - if(!col) { - col = { id: 'default', name: 'My Requests', requests: [] }; - this.collections.push(col); - } - targetColId = col.id; - } - - const existingIdx = col.requests.findIndex(r => r.id === this.state.activeRequestId || (r.url === this.state.url && r.method === this.state.method)); - let existingReq = existingIdx >= 0 ? col.requests[existingIdx] : null; - - const reqData = { - id: this.state.activeRequestId || Date.now().toString(), - name: (existingReq && existingReq.name) ? existingReq.name : (this.state.url.split('?')[0].split('/').pop() || 'Root URL'), - method: this.state.method, - url: this.state.url, - params: JSON.parse(JSON.stringify(this.state.params)), - headers: JSON.parse(JSON.stringify(this.state.headers)), - auth: JSON.parse(JSON.stringify(this.state.auth)), - bodyType: this.state.bodyType, - bodyData: JSON.parse(JSON.stringify(this.state.bodyData)), - jsonBody: this.state.jsonBody, - lastStatus: lastStatus !== undefined ? lastStatus : (existingReq ? existingReq.lastStatus : null), - lastTime: new Date().toLocaleTimeString(), - activeCollectionId: targetColId - }; - - if (existingIdx >= 0) { - // Update existing - reqData.id = existingReq.id; // preserve ID - col.requests[existingIdx] = reqData; - } else { - // Add new - col.requests.unshift(reqData); - } - - this.state.activeRequestId = reqData.id; - this.saveState(); - this.saveSpacesToServer(); - }, - - loadRequest(colId, reqId) { - const col = this.collections.find(c => c.id === colId); - if(!col) return; - const req = col.requests.find(r => r.id === reqId); - if(!req) return; - - // Check if this request is already open in any tab - const existingTabIdx = this.tabs.findIndex(t => t.activeRequestId === reqId); - if (existingTabIdx >= 0) { - // Just switch to that tab - this.activeTabIndex = existingTabIdx; - this.saveState(); - this.render(); - return; - } - - // Postman behavior: if the current tab is a "preview" tab (untouched/empty), reuse it; - // otherwise open a new tab - const currTab = this.tabs[this.activeTabIndex]; - const isUntouched = currTab && ( - (!currTab.url || currTab.url === '') && - (!currTab.activeRequestId) && - (!currTab.response) && - (currTab.name === 'Untitled Request' || !currTab.name) - ); - - const reqTabData = { - id: 'tab_' + Date.now() + Math.random().toString(36).substr(2, 9), - name: req.name || (req.url ? req.url.split('/').pop() || req.url : 'Request'), - method: req.method || 'GET', - url: req.url || '', - params: JSON.parse(JSON.stringify(req.params || [{ id: Date.now().toString(), key: '', value: '', type: 'text', enabled: true }])), - headers: JSON.parse(JSON.stringify(req.headers || [{ id: (Date.now()+1).toString(), key: '', value: '', type: 'text', enabled: true }])), - auth: JSON.parse(JSON.stringify(req.auth || {type:'none'})), - bodyType: req.bodyType || 'none', - bodyData: JSON.parse(JSON.stringify(req.bodyData || [])), - jsonBody: req.jsonBody || '', - response: null, - bulk: { strategy: 'consecutive', running: false, total: 0, completed: 0, success: 0, error: 0, concurrency: 1, results: [] }, - activeTab: 'params', - responseTab: 'response', - activeRequestId: reqId, - activeCollectionId: colId, - isPreview: false - }; - - if (isUntouched) { - // Replace current blank tab - this.tabs[this.activeTabIndex] = reqTabData; - } else { - // Open brand new tab - this.tabs.push(reqTabData); - this.activeTabIndex = this.tabs.length - 1; - } - - this.saveState(); - this.render(); - }, - - deleteRequest(colId, reqId) { - const col = this.collections.find(c => c.id === colId); - if(col) col.requests = col.requests.filter(r => r.id !== reqId); - if(this.state.activeRequestId === reqId) this.state.activeRequestId = null; - this.saveState(); - this.saveSpacesToServer(); - this.render(); - }, - - createCollection() { - const name = prompt("Collection Name:"); - if(name) { - const id = 'col_' + Date.now(); - this.collections.push({ id, name, requests: [] }); - this.state.activeCollectionId = id; - this.saveState(); - this.saveSpacesToServer(); - this.render(); - } - }, - - renameCollection(colId) { - const col = this.collections.find(c => c.id === colId); - if(!col) return; - const newName = prompt("Enter new collection name:", col.name); - if(newName && newName.trim()) { - col.name = newName.trim(); - this.saveState(); - this.saveSpacesToServer(); - this.render(); - } - }, - - renameRequest(colId, reqId) { - const col = this.collections.find(c => c.id === colId); - if(!col) return; - const req = col.requests.find(r => r.id === reqId); - if(!req) return; - const newName = prompt("Enter new request name:", req.name); - if(newName && newName.trim()) { - req.name = newName.trim(); - this.saveState(); - this.saveSpacesToServer(); - this.render(); - } - }, - - deleteCollection(colId) { - if(confirm("Delete this collection and all its requests? This cannot be undone.")) { - this.collections = this.collections.filter(c => c.id !== colId); - // Always keep at least one collection - if (this.collections.length === 0) { - this.collections = [{ id: 'default', name: 'My Requests', requests: [] }]; - } - // If deleted collection was active, switch to first remaining - const stillExists = this.collections.some(c => c.id === this.state.activeCollectionId); - if (!stillExists) { - this.state.activeCollectionId = this.collections[0].id; - this.state.activeRequestId = null; - } - this.saveState(); - this.saveSpacesToServer(); - this.render(); - } - }, - - addRequestToCollection(colId) { - const col = this.collections.find(c => c.id === colId); - if (!col) return; - const reqId = 'req_' + Date.now(); - const newReq = { - id: reqId, - name: 'New Request', - method: 'GET', - url: '', - description: '', - params: [{ id: Date.now().toString() + Math.random(), key: '', value: '', type: 'text', enabled: true }], - headers: [{ id: Date.now().toString() + Math.random(), key: '', value: '', type: 'text', enabled: true }], - auth: { type: 'none' }, - bodyType: 'none', - bodyData: [], - jsonBody: '' - }; - col.requests.push(newReq); - - // Open this new request in a new tab - const reqTabData = { - id: 'tab_' + Date.now() + Math.random().toString(36).substr(2, 9), - name: 'New Request', - method: 'GET', - url: '', - params: JSON.parse(JSON.stringify(newReq.params)), - headers: JSON.parse(JSON.stringify(newReq.headers)), - auth: { type: 'none' }, - bodyType: 'none', - bodyData: [], - jsonBody: '', - response: null, - bulk: { strategy: 'consecutive', running: false, total: 0, completed: 0, success: 0, error: 0, concurrency: 1, results: [] }, - activeTab: 'params', - responseTab: 'response', - activeRequestId: reqId, - activeCollectionId: colId, - isPreview: false - }; - this.tabs.push(reqTabData); - this.activeTabIndex = this.tabs.length - 1; - - this.saveState(); - this.saveSpacesToServer(); - this.render(); - this.toast("Added new request to collection"); - - }, - - updateActiveRequestName(name) { - const activeSpace = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - const col = activeSpace ? activeSpace.collections.find(c => c.id === this.state.activeCollectionId) : null; - const activeReq = col ? col.requests.find(r => r.id === this.state.activeRequestId) : null; - if (activeReq) { - activeReq.name = name.trim() || 'Untitled Request'; - this.saveState(); - this.saveSpacesToServer(); - this.render(); - } - }, - - updateActiveRequestDescription(desc) { - const activeSpace = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - const col = activeSpace ? activeSpace.collections.find(c => c.id === this.state.activeCollectionId) : null; - const activeReq = col ? col.requests.find(r => r.id === this.state.activeRequestId) : null; - if (activeReq) { - activeReq.description = desc; - this.saveState(); - this.saveSpacesToServer(); - } - }, - - downloadHistory() { - if (!this.state.bulk.results.length) return; - - const csvContent = "data:text/csv;charset=utf-8," - + "Index,Status,Latency (ms),Snippet\n" - + this.state.bulk.results.map(r => `${r.index},${r.status},${r.latency},"${(r.data || '').replace(/"/g, '""').replace(/\n/g, ' ')}"`).join("\n"); - - const encodedUri = encodeURI(csvContent); - const link = document.createElement("a"); - link.setAttribute("href", encodedUri); - link.setAttribute("download", `bulk_results_${new Date().toISOString()}.csv`); - document.body.appendChild(link); - link.click(); - document.body.removeChild(link); - }, - - // Get the input filename for a given bulk index - getInputFilename(index, fileIndex = index, listIndex = index) { - // Build list of active params that could provide a name - const activeParams = [ - ...this.state.params.filter(p => p.enabled && p.key && p.key.trim()), - ...(this.state.bodyType === 'form-data' ? this.state.bodyData.filter(p => p.enabled && p.key && p.key.trim()) : []) - ]; - - let folderName = null; - // Priority 1: Folder type (usually high-intent for naming) - const folderParam = activeParams.find(p => p.type === 'folder'); - if (folderParam) { - const files = this.fileStore.get(folderParam.id); - if (files && files.length > 0) { - const file = files[fileIndex % files.length]; - folderName = file.webkitRelativePath || file.name; - } - } - - let listName = null; - // Priority 2: List in Body (user's specific request context) - if (this.state.bodyType === 'form-data') { - const bodyList = this.state.bodyData.find(p => p.type === 'list' && p.enabled && p.key && p.key.trim()); - if (bodyList) { - const arr = bodyList.value.split(/[\n,]+/).map(s => s.trim()).filter(s => s); - if (arr.length > 0) listName = arr[listIndex % arr.length]; - } - } - - // Priority 3: Any other list - if (!listName) { - const listParam = activeParams.find(p => p.type === 'list'); - if (listParam) { - const val = listParam.value || ''; - const arr = val.split(/[\n,]+/).map(s => s.trim()).filter(s => s); - if (arr.length > 0) listName = arr[listIndex % arr.length]; - } - } - - if (folderName && listName) { - // Strip extension from folderName, add listName, re-add extension - let base = folderName; - let ext = ''; - const lastDot = folderName.lastIndexOf('.'); - if (lastDot !== -1 && lastDot > 0 && folderName.length - lastDot <= 6) { - base = folderName.substring(0, lastDot); - ext = folderName.substring(lastDot); - } - // Replace any invalid characters in listName just in case, though usually fine - const safeListName = listName.replace(/[\/\\]/g, '_'); - return `${base}_${safeListName}${ext}`; - } else if (folderName) { - return folderName; - } else if (listName) { - return listName; - } - - return `result_${index + 1}`; - }, - - // Get the final filename with appropriate extension if missing - getFinalFilename(result) { - let name = result.inputFilename || `result_${result.index}`; - let originalExt = ''; - - // Extract existing extension if present - const lastDot = name.lastIndexOf('.'); - if (lastDot > 0 && (name.length - lastDot) <= 6) { - originalExt = name.substring(lastDot); - name = name.substring(0, lastDot); - } - - // Map common content types - const ct = (result.contentType || '').toLowerCase(); - if (ct.includes('image/png')) return name + '.png'; - if (ct.includes('image/jpeg') || ct.includes('image/jpg')) return name + '.jpg'; - if (ct.includes('image/gif')) return name + '.gif'; - if (ct.includes('image/webp')) return name + '.webp'; - if (ct.includes('image/svg')) return name + '.svg'; - if (ct.includes('application/pdf')) return name + '.pdf'; - if (ct.includes('application/json')) return name + '.json'; - if (ct.includes('application/xml') || ct.includes('text/xml')) return name + '.xml'; - if (ct.includes('text/html')) return name + '.html'; - if (ct.includes('text/csv')) return name + '.csv'; - if (ct.includes('text/css')) return name + '.css'; - if (ct.includes('text/plain')) return name + '.txt'; - if (ct.includes('application/zip')) return name + '.zip'; - - // Fallback for other binary types: try to extract subtype - if (result.binaryData && ct.includes('/')) { - const subtype = ct.split('/')[1].split(';')[0]; // handle "type/subtype;charset=..." - if (subtype && subtype.length <= 4 && /^[a-z0-9]+$/.test(subtype)) { - return name + '.' + subtype; - } - } - - // Content sniffing for JSON if content type is missing or incorrect - if (!result.binaryData && result.fullContent) { - const trimmed = result.fullContent.trim(); - if ((trimmed.startsWith('{') && trimmed.endsWith('}')) || (trimmed.startsWith('[') && trimmed.endsWith(']'))) { - try { - JSON.parse(trimmed); // Quick validation - return name + '.json'; - } catch(e) {} - } - } - - // If we still don't know the type, fallback to original extension if it existed - if (originalExt) return name + originalExt; - - // Otherwise default based on data format - return result.binaryData ? name + '.bin' : name + '.txt'; - }, - - async saveAsFolder() { - if (!this.state.bulk.results.length) return this.toast('No results to save', 'error'); - - try { - if (!window.showDirectoryPicker) { - return this.toast('Your browser does not support native folder saving. Please use the ZIP button instead.', 'error'); - } - - this.toast('Select a folder to save files...', 'info'); - const dirHandle = await window.showDirectoryPicker({ - mode: 'readwrite' - }); - - let savedCount = 0; - let errors = 0; - const usedNames = new Set(); - - for (const r of this.state.bulk.results) { - try { - let filename = this.getFinalFilename(r); - - let base = filename; - let ext = ''; - const lastDot = filename.lastIndexOf('.'); - if (lastDot !== -1 && lastDot > 0) { - base = filename.substring(0, lastDot); - ext = filename.substring(lastDot); - } - - let counter = 1; - while (usedNames.has(filename)) { - filename = `${base}_${counter}${ext}`; - counter++; - } - usedNames.add(filename); - - // Get the content as binary data - let data; - if (r.binaryData) { - // Convert base64 string to Uint8Array - data = this.base64ToUint8Array(r.binaryData); - } else if (r.fullContent) { - data = r.fullContent; - } else { - continue; // Skip empty results - } - - // Create file and write content - const fileHandle = await dirHandle.getFileHandle(filename, { create: true }); - const writable = await fileHandle.createWritable(); - await writable.write(data); - await writable.close(); - - savedCount++; - } catch (e) { - console.error('Error saving file', r.index, e); - errors++; - } - } - - if (errors > 0) { - this.toast(`Saved ${savedCount} files. Failed to save ${errors} files.`, 'warning'); - } else { - this.toast(`Successfully saved ${savedCount} files to the selected folder.`); - } - - } catch (e) { - console.error(e); - if (e.name === 'AbortError') { - this.toast('Folder selection cancelled.', 'info'); - } else { - this.toast('Failed to save to folder: ' + e.message, 'error'); - } - } - }, - - async saveAllResults() { - if (!this.state.bulk.results.length) return this.toast('No results to save', 'error'); - if (typeof JSZip === 'undefined') return this.toast('JSZip library not loaded. Please refresh.', 'error'); - - this.toast('Building ZIP file...', 'info'); - - const zip = new JSZip(); - let savedCount = 0; - const usedNames = new Set(); - - for (const result of this.state.bulk.results) { - try { - // Use the tracked input filename + auto extension - let filename = this.getFinalFilename(result); - - let base = filename; - let ext = ''; - const lastDot = filename.lastIndexOf('.'); - if (lastDot !== -1 && lastDot > 0) { - base = filename.substring(0, lastDot); - ext = filename.substring(lastDot); - } - - let counter = 1; - while (usedNames.has(filename)) { - filename = `${base}_${counter}${ext}`; - counter++; - } - usedNames.add(filename); - - // Get the content as binary data - let data; - if (result.binaryData) { - // Convert base64 string to Uint8Array - data = this.base64ToUint8Array(result.binaryData); - } else if (result.fullContent) { - data = result.fullContent; - } else { - continue; // Skip empty results - } - - // Add to ZIP (JSZip handles folder creation from path automatically) - zip.file(filename, data, { binary: !!result.binaryData }); - savedCount++; - } catch (e) { - console.error('Error adding result to ZIP', result.index, e); - } - } - - if (savedCount === 0) return this.toast('No valid results to save', 'error'); - - // Generate and download ZIP - try { - this.toast('Generating ZIP, please wait...', 'info'); - const blob = await zip.generateAsync({ type: 'blob' }); - const url = URL.createObjectURL(blob); - - const modal = document.createElement('div'); - modal.className = 'premium-modal-overlay'; - modal.style.zIndex = '9999'; - modal.innerHTML = ` -
- -

ZIP Ready!

-

Successfully bundled ${savedCount} files.

- - Click to Download ZIP - - -
- `; - document.body.appendChild(modal); - - // Note: intentionally not revoking the URL immediately so the manual click works! - - } catch (e) { - this.toast('Error generating ZIP: ' + e.message, 'error'); - } - }, - - // --- Rendering --- - - render() { - const root = document.getElementById('app-root'); - if (root) { - // Reset base class first to prevent layout/theme clashing - root.className = 'workspace'; - - if (this.state.bulk.results.length > 0 || this.state.bulk.running) { - root.classList.add('bulk-active'); - } - if (this.state.gridMaximized || !this.state.activeSpaceId) { - root.classList.add('grid-maximized'); - } - - // Add theme class for active space - if (this.state.activeSpaceId) { - const activeSpace = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - const theme = activeSpace && activeSpace.theme ? activeSpace.theme : 'violet'; - root.classList.add(`theme-${theme}`); - } - } - this.renderSidebar(); - this.renderMain(); - this.renderResponse(); - }, - - renderProgress() { - // Optimized partial render for progress bar - const bar = document.getElementById('progress-bar-fill'); - const text = document.getElementById('progress-text'); - if (bar && text) { - const pct = (this.state.bulk.completed / this.state.bulk.total) * 100; - bar.style.width = `${pct}%`; - text.innerText = `${this.state.bulk.completed} / ${this.state.bulk.total}`; - } - }, - - getCollectionsHTML() { - const query = (this.state.searchQuery || '').toLowerCase().trim(); - let collectionsHTML = ''; - - this.collections.forEach(col => { - const isColActive = this.state.activeCollectionId === col.id; - - // Filter requests - const filteredRequests = col.requests.filter(r => { - if (!query) return true; - return ( - (r.name || '').toLowerCase().includes(query) || - (r.url || '').toLowerCase().includes(query) || - (r.description || '').toLowerCase().includes(query) - ); - }); - - // Decide if the collection itself matches - const colMatches = (col.name || '').toLowerCase().includes(query); - - // If neither collection matches nor has matching requests, skip rendering it - if (query && !colMatches && filteredRequests.length === 0) { - return; - } - - // If there's a query and we have matches, auto-expand the collection - const isExpanded = query ? true : isColActive; - - const reqsHTML = (query && colMatches ? col.requests : filteredRequests).map(r => ` -
- ${r.method} -
-
- ${this.escapeHTML(r.name || '')} -
-
- ${this.escapeHTML(r.url || 'No URL')} -
-
- - -
- `).join(''); - - collectionsHTML += ` -
-
- - ${this.escapeHTML(col.name)} - - - - - -
- ${isExpanded ? `
${reqsHTML || '
Empty Collection
'}
` : ''} -
- `; - }); - - return collectionsHTML; - }, - - filterSidebarCollections(query) { - this.state.searchQuery = query; - const listEl = document.getElementById('sidebar-collections-list'); - if (listEl) { - listEl.innerHTML = this.getCollectionsHTML(); - } - - // Also update clear button visibility - const clearBtn = document.getElementById('search-clear-btn'); - if (clearBtn) { - clearBtn.style.display = query ? 'block' : 'none'; - } - }, - - renderSidebar() { - const collectionsHTML = this.getCollectionsHTML(); - const activeSpace = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - - let notificationsBannerHTML = ''; - if (activeSpace && activeSpace.notifications && activeSpace.notifications.length > 0) { - notificationsBannerHTML = ` -
- - ${activeSpace.notifications.length} pending share request${activeSpace.notifications.length > 1 ? 's' : ''} -
- `; - } - - const spaceOptionsHTML = ` - - ${this.state.spaces.map(s => ` - - `).join('')} - `; - - this.dom.sidebar.innerHTML = ` - - - - ${activeSpace ? ` - ${notificationsBannerHTML} - - - - - - - - - - ` : ` -
-
- -
Select a workspace
from the dashboard
-
-
- `} - - -
- -
- `; - }, - - - renderMain() { - if (!this.state.activeSpaceId) { - // Render Spaces Dashboard Grid View - const spacesCardsHTML = this.state.spaces.map(s => { - const count = s.collections ? s.collections.length : 0; - const notifCount = s.notifications ? s.notifications.length : 0; - const theme = s.theme || 'violet'; - return ` -
-
- - ${notifCount > 0 ? `${notifCount}` : ''} -
-
-

${this.escapeHTML(s.name)}

- ${count} Collections -
-
- - ${this.state.spaces.length > 1 ? ` - - ` : ''} -
-
- `; - }).join(''); - - const dashboardHTML = ` -
-
-

Workspaces

-

Select a workspace to access its collections, endpoints, and history.

-
- -
- ${spacesCardsHTML} - -
-
-
-

Create New Space

- Add a clean workspace -
-
-
-
- `; - - const headerHTML = ` -
-
PHOENIX
-
- Workspace Dashboard -
-
-
- `; - - this.dom.mainPanel.innerHTML = headerHTML + dashboardHTML; - return; - } - - const isBulkStart = this.checkBulkStart(); - const bulk = this.state.bulk; - const activeSpace = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - - // Tab Strip (Postman-like) - const tabStripHTML = ` -
- ${this.tabs.map((tab, i) => { - const isActive = i === this.activeTabIndex; - const tabName = tab.name || (tab.url ? tab.url.split('/').pop() || 'Request' : 'Untitled'); - const displayName = tabName.length > 20 ? tabName.substring(0, 20) + '…' : tabName; - const method = tab.method || 'GET'; - const mc = { GET:'var(--m-get)', POST:'var(--m-post)', PUT:'var(--m-put)', DELETE:'var(--m-delete)', PATCH:'var(--m-patch)' }[method] || 'var(--text-3)'; - return ` -
- ${method} - ${this.escapeHTML(displayName)} - -
- `; - }).join('')} - -
- `; - - // Header with Active Space name/switcher - const headerHTML = ` -
-
- PHOENIX -
-
- - ${this.escapeHTML(activeSpace ? activeSpace.name : '')} - -
- - - - - -
- - -
- - -
- ${bulk.running - ? ` - ` - : bulk.paused - ? ` - ` - : `` - } -
-
- ${tabStripHTML} - `; - - // Request Name & Description Section - const col = activeSpace ? activeSpace.collections.find(c => c.id === this.state.activeCollectionId) : null; - const activeReq = col ? col.requests.find(r => r.id === this.state.activeRequestId) : null; - - const requestMetaHTML = activeReq ? ` -
-
- Name - -
-
- Description - -
-
- ` : ''; - - // Tabs bar (PARAMS / HEADERS / BODY / AUTH + Bulk controls) - const inputStyle = 'background:var(--bg-input);border:1px solid var(--border-2);border-radius:var(--r-xs);color:var(--text-1);padding:3px 6px;font-size:11px;text-align:center;font-family:var(--font-ui);'; - const tabsHTML = ` -
- ${['params', 'headers', 'body', 'auth'].map(t => ` -
${t.toUpperCase()}
- `).join('')} -
-
- ${isBulkStart ? ` -
- Strategy - - -
- ` : ''} -
- Repeat - -
-
- Delay ms - -
-
- Workers - -
-
-
- `; - - - // Content - let contentHTML = ''; - if (this.state.activeTab === 'params') contentHTML = this.renderTable(this.state.params, 'params'); - else if (this.state.activeTab === 'headers') contentHTML = this.renderTable(this.state.headers, 'headers'); - else if (this.state.activeTab === 'body') contentHTML = this.renderBodyTab(); - else if (this.state.activeTab === 'auth') contentHTML = this.renderAuthTab(); - - // Bottom Results & Response Panel (Always Rendered) - const pct = bulk.total > 0 ? (bulk.completed / bulk.total) * 100 : 0; - const statusColor = bulk.error > 0 ? (bulk.success > 0 ? 'var(--warning)' : 'var(--danger)') : 'var(--success)'; - const cardsHTML = bulk.results.slice(-200).map(r => this.renderResultCard(r)).join(''); - const folderPath = this.state.outputFolderPath || 'None selected'; - const activeBottomTab = this.state.responseTab || 'response'; - - let bottomTabContentHTML = ''; - if (activeBottomTab === 'response') { - const resp = this.state.response; - if (!resp) { - bottomTabContentHTML = `
Ready to send request. Click SEND to execute a single request, or RUN BATCH for bulk.
`; - } else if (resp.status === 'Sending...') { - bottomTabContentHTML = `
Sending request...
`; - } else if (resp.error) { - bottomTabContentHTML = `
Error: ${resp.error}
`; - } else { - let content = resp.content; - try { - if (content && !resp.binary_data && content.trim().startsWith('{')) { - content = JSON.stringify(JSON.parse(content), null, 2); - } - } catch(e){} - - bottomTabContentHTML = ` -
- ${resp.status_code} - ${resp.latency ? resp.latency + ' ms' : ''} - ${resp.content_type || 'Unknown Type'} -
-
- ${resp.binary_data - ? `
- Binary Content -
` - : `
${this.escapeHTML(content)}
` - } -
- `; - } - } else { - if (bulk.results.length === 0) { - bottomTabContentHTML = ` -
- - No batch results yet. Run a batch to see results in a grid. -
- `; - } else { - bottomTabContentHTML = ` -
-
-
-
- ${cardsHTML} -
- `; - } - } - - bottomPanelHTML = ` -
-
- -
-
- - - ${bulk.results.length > 0 ? ` -
- ${bulk.completed}/${bulk.total} - ${bulk.success} ✓ - ${bulk.error} ✗ - ` : ''} -
- - ${activeBottomTab === 'results' && bulk.results.length > 0 ? ` -
-
- - ${folderPath} - - - -
- - - - -
- ` : ''} -
- -
- ${bottomTabContentHTML} -
-
- `; - - this.dom.mainPanel.innerHTML = headerHTML + requestMetaHTML + tabsHTML + `
${contentHTML}
` + bottomPanelHTML; - }, - - renderResultCard(result) { - const isImage = (result.contentType || '').toLowerCase().includes('image') && result.binaryData; - const isSuccess = result.status >= 200 && result.status < 300; - const statusClass = isSuccess ? 'status-success' : 'status-error'; - const filename = result.inputFilename || `result_${result.index}`; - const finalFilename = this.getFinalFilename(result); - - let previewHTML = ''; - if (isImage) { - try { - previewHTML = `${filename}`; - } catch (e) { - previewHTML = `
Decode error
`; - } - } else { - let icon = 'fa-file-lines'; - let typeLabel = 'TXT'; - const ct = (result.contentType || '').toLowerCase(); - if (ct.includes('application/json')) { icon = 'fa-file-code'; typeLabel = 'JSON'; } - else if (ct.includes('text/html')) { icon = 'fa-file-code'; typeLabel = 'HTML'; } - else if (result.status === 'ERR') { icon = 'fa-circle-xmark'; typeLabel = 'ERROR'; } - previewHTML = ` -
- - ${typeLabel} -

${this.escapeHTML(result.data || '')}

-
`; - } - - const footerHTML = isImage - ? `` - : `
-
- #${result.index} - ${result.status} - ${result.latency}ms -
-
${finalFilename}
-
`; - - return ` -
-
- ${previewHTML} -
- ${!isImage ? ` - ` : ''} - - - -
-
- ${footerHTML} -
- `; - }, - - renderResponse() { - // No-op: Single response and bulk results have been consolidated into renderMain()'s bottom panel. - }, - - renderTable(items, section) { - return ` - - - - ${items.map(item => ` - - - - - - - `).join('')} - -
KeyValue
- - ${this.renderValueInput(item, section)} -
- - `; - }, - - renderValueInput(item, section) { - if (item.type === 'file' || item.type === 'folder') { - const files = this.fileStore.get(item.id); - const label = files ? (item.type === 'folder' ? `${files.length} Files Selected` : `${files.length} Files`) : 'Select...'; - return ` -
- - -
- `; - } - if (item.type === 'auto_width' || item.type === 'auto_height') { - return ``; - } - return ``; - }, - - renderBodyTab() { - return ` -
-
- - - -
- - ${this.state.bodyType === 'form-data' ? this.renderTable(this.state.bodyData, 'body') : ''} - ${this.state.bodyType === 'json' ? `` : ''} -
- `; - }, - - renderAuthTab() { - const auth = this.state.auth; - const inStyle = 'width:100%;padding:10px 12px;background:var(--bg-input);border:1px solid var(--border-2);border-radius:var(--r-md);color:var(--text-1);font-family:var(--font-mono);font-size:12px;transition:border-color 0.15s,box-shadow 0.15s;'; - const labelStyle = 'display:block;margin-bottom:6px;font-size:9.5px;font-weight:700;text-transform:uppercase;letter-spacing:0.07em;color:var(--text-3);'; - return ` -
- - - - ${auth.type === 'bearer' ? ` -
- - -
- ` : ''} - - ${auth.type === 'basic' ? ` -
-
- - -
-
- - -
-
- ` : ''} - - ${auth.type === 'apikey' ? ` -
-
- - -
-
- - -
-
- ` : ''} -
- `; - }, - - // --- Helpers --- - - handleFileSelect(input, section, id) { - if (input.files.length > 0) { - // Convert FileList to Array and sort by path to ensure strict processing sequence (natural sorting) - let filesArr = Array.from(input.files); - filesArr.sort((a, b) => { - const pA = a.webkitRelativePath || a.name; - const pB = b.webkitRelativePath || b.name; - return pA.localeCompare(pB, undefined, { numeric: true, sensitivity: 'base' }); - }); - this.fileStore.set(id, filesArr); - this.render(); // update label - } - }, - - checkBulkStart() { - const hasKeyedFolder = this.state.params.some(p => p.type === 'folder' && p.enabled && p.key && p.key.trim()) - || (this.state.bodyType === 'form-data' && this.state.bodyData.some(p => p.type === 'folder' && p.enabled && p.key && p.key.trim())); - - const hasKeyedList = this.state.params.some(p => p.type === 'list' && p.enabled && p.key && p.key.trim()) - || (this.state.bodyType === 'form-data' && this.state.bodyData.some(p => p.type === 'list' && p.enabled && p.key && p.key.trim())) - || this.state.headers.some(h => h.type === 'list' && h.enabled && h.key && h.key.trim()); - - return hasKeyedFolder || hasKeyedList; - }, - - getStatusColor(code) { - if (code >= 200 && code < 300) return 'var(--success)'; - if (code >= 300 && code < 400) return 'var(--warning)'; - if (code >= 400 || code === 'ERR') return 'var(--danger)'; - return 'var(--text-muted)'; - }, - - toast(msg, type = 'info') { - const icons = { info: 'fa-circle-info', success: 'fa-circle-check', error: 'fa-circle-xmark', warning: 'fa-triangle-exclamation' }; - const iconColors = { info: '#5ba0f5', success: '#0fcea0', error: '#ff4569', warning: '#f5a623' }; - const icon = icons[type] || icons.info; - const color = iconColors[type] || iconColors.info; - const t = document.createElement('div'); - t.className = `ph-toast-${type}`; - t.innerHTML = `${this.escapeHTML(msg)}`; - Object.assign(t.style, { - display: 'flex', - alignItems: 'center', - gap: '10px', - padding: '12px 16px', - borderRadius: '10px', - marginTop: '6px', - fontSize: '13px', - fontFamily: 'var(--font-ui)', - fontWeight: '500', - animation: 'toastSlideIn 0.32s cubic-bezier(0.34,1.56,0.64,1) both', - }); - this.dom.toast.appendChild(t); - const removeDelay = type === 'error' ? 4500 : 3000; - setTimeout(() => { - t.style.animation = 'toastFadeOut 0.2s ease forwards'; - setTimeout(() => t.remove(), 200); - }, removeDelay); - }, - - escapeHTML(str) { - if (!str) return ''; - if (typeof str !== 'string') return String(str); - return str.replace(/&/g, '&') - .replace(//g, '>') - .replace(/"/g, '"') - .replace(/'/g, '''); - }, - - base64ToUint8Array(base64Data) { - if (!base64Data) return new Uint8Array(0); - try { - const byteCharacters = atob(base64Data); - const data = new Uint8Array(byteCharacters.length); - for (let i = 0; i < byteCharacters.length; i++) { - data[i] = byteCharacters.charCodeAt(i); - } - return data; - } catch (e) { - console.error("Base64 to Uint8Array error", e); - return new Uint8Array(0); - } - }, - - async base64ToBlobUrlAsync(base64Data, contentType) { - if (!base64Data) return ''; - try { - const res = await fetch(`data:${contentType || 'application/octet-stream'};base64,${base64Data}`); - const blob = await res.blob(); - return URL.createObjectURL(blob); - } catch (e) { - console.error("Async Base64 decode error", e); - return ''; - } - }, - - base64ToBlobUrl(base64Data, contentType) { - if (!base64Data) return ''; - try { - const byteCharacters = atob(base64Data); - const byteArrays = []; - const sliceSize = 512; - for (let offset = 0; offset < byteCharacters.length; offset += sliceSize) { - const slice = byteCharacters.slice(offset, offset + sliceSize); - const byteNumbers = new Array(slice.length); - for (let i = 0; i < slice.length; i++) { - byteNumbers[i] = slice.charCodeAt(i); - } - const byteArray = new Uint8Array(byteNumbers); - byteArrays.push(byteArray); - } - const blob = new Blob(byteArrays, {type: contentType}); - return URL.createObjectURL(blob); - } catch (e) { - console.error("Base64 decode error", e); - return ''; - } - }, - - bindEvents() { - // Most events are inline (onclick, onchange) for simplicity in this structure - }, - - // Preview a result - previewResult(index) { - const result = this.state.bulk.results.find(r => r.index === index); - if (!result) return; - - const isImage = (result.contentType || '').toLowerCase().includes('image') && result.binaryData; - const finalFilename = this.getFinalFilename(result); - - let contentHTML = ''; - if (isImage) { - try { - contentHTML = `${finalFilename}`; - } catch (e) { - contentHTML = ``; - } - } else { - let prettyContent = result.fullContent || ''; - try { - if (prettyContent.trim().startsWith('{')) { - prettyContent = JSON.stringify(JSON.parse(prettyContent), null, 2); - } - } catch(e) {} - contentHTML = ``; - } - - const modal = document.createElement('div'); - modal.className = 'premium-modal-overlay'; - - modal.innerHTML = ` -
-
-
- -
- ${finalFilename} - Result #${result.index} -
-
-
- ${result.status} - ${result.latency}ms - -
-
-
- ${contentHTML} -
- -
- `; - - document.body.appendChild(modal); - modal.onclick = () => modal.remove(); - }, - - // For manual clicking from history - loadHistoryItem(id) { - const item = this.state.history.find(h => h.id === id); - if (item) { - this.state.method = item.method; - this.state.url = item.url; - this.saveState(); - this.render(); - } - } -}; - - -document.addEventListener('DOMContentLoaded', () => App.init()); - diff --git a/web/bulk-api-tester/static/js/app.js.bak_scroll_fix b/web/bulk-api-tester/static/js/app.js.bak_scroll_fix deleted file mode 100644 index 4cf3b1b..0000000 --- a/web/bulk-api-tester/static/js/app.js.bak_scroll_fix +++ /dev/null @@ -1,2771 +0,0 @@ -/** - * Phoenix App - Advanced Bulk API Tester - * Version: 2.0 (Agentic Edition) - */ - -const App = { - _stateData: { - spaces: [], - activeSpaceId: null, - activeCollectionId: 'default', - - outputFolderPath: '', - gridMaximized: false, - resultsPanelHeight: 300, - sidebarWidth: 270, - searchQuery: '' - }, - - tabs: [], - activeTabIndex: 0, - - get state() { - if (!this._proxyState) { - const props = ['name', 'method', 'url', 'params', 'headers', 'auth', 'bodyType', 'bodyData', 'jsonBody', 'response', 'bulk', 'activeTab', 'responseTab', 'activeRequestId', 'isPreview', 'activeCollectionId']; - this._proxyState = new Proxy(this._stateData, { - get(target, prop) { - if (props.includes(prop)) { - if (App.tabs && App.tabs[App.activeTabIndex]) { - return App.tabs[App.activeTabIndex][prop]; - } - } - return target[prop]; - }, - set(target, prop, value) { - if (props.includes(prop)) { - if (App.tabs && App.tabs[App.activeTabIndex]) { - App.tabs[App.activeTabIndex][prop] = value; - if (prop !== 'activeTab' && prop !== 'responseTab' && prop !== 'activeRequestId') { - App.tabs[App.activeTabIndex].isPreview = false; - } - - // Auto-save logic - const autoSaveProps = ['name', 'method', 'url', 'params', 'headers', 'auth', 'bodyType', 'bodyData', 'jsonBody', 'bulk']; - if (autoSaveProps.includes(prop) && App.tabs[App.activeTabIndex].activeRequestId) { - if (App.debouncedSaveToCollection) { - App.debouncedSaveToCollection(); - } - } - - return true; - } - } - target[prop] = value; - return true; - } - }); - } - return this._proxyState; - }, - - debouncedSaveToCollection() { - if (this._autoSaveTimeout) clearTimeout(this._autoSaveTimeout); - this._autoSaveTimeout = setTimeout(() => { - this.saveToCollection(); - }, 500); - }, - - createNewTab(reqData, isPreview = false) { - return { - id: 'tab_' + Date.now() + Math.random().toString(36).substr(2, 9), - name: reqData ? reqData.name : 'Untitled Request', - method: reqData ? reqData.method : 'POST', - url: reqData ? reqData.url : '', - params: reqData ? JSON.parse(JSON.stringify(reqData.params || [])) : [], - headers: reqData ? JSON.parse(JSON.stringify(reqData.headers || [])) : [], - auth: reqData ? JSON.parse(JSON.stringify(reqData.auth || {type:'none'})) : {type:'none'}, - bodyType: reqData ? reqData.bodyType : 'none', - bodyData: reqData ? JSON.parse(JSON.stringify(reqData.bodyData || [])) : [], - jsonBody: reqData ? reqData.jsonBody : '', - response: null, - bulk: reqData && reqData.bulk ? JSON.parse(JSON.stringify(reqData.bulk)) : { - strategy: 'consecutive', - running: false, - total: 0, - completed: 0, - success: 0, - error: 0, - concurrency: 1, - delay: 0, - repetitions: 10, - results: [] - }, - activeTab: 'params', - responseTab: 'response', - activeRequestId: reqData ? reqData.id : null, - activeCollectionId: reqData ? reqData.activeCollectionId : 'default', - isPreview: isPreview - }; - }, - - - fileStore: new Map(), // id -> FileList - - dom: {}, - - async init() { - this.loadState(); - this.cacheDOM(); - this.bindEvents(); - - // Ensure active tab has at least one param and header row - if (!this.state.params || this.state.params.length === 0) this.addParam('params'); - if (!this.state.headers || this.state.headers.length === 0) this.addParam('headers'); - - // Load spaces from the server to keep them synced - await this.loadSpacesFromServer(); - - // Load the last run results/response from the server - await this.loadLastRunFromServer(); - - // Apply saved sidebar width - const sidebarEl = document.getElementById('sidebar'); - if (sidebarEl && this._stateData.sidebarWidth) { - sidebarEl.style.width = `${this._stateData.sidebarWidth}px`; - } - - // Attach event listener for horizontal sidebar dragging - const handle = document.getElementById('sidebar-resize-handle'); - if (handle) { - handle.addEventListener('mousedown', (e) => this.startSidebarResize(e)); - } - - this.render(); - - // Remove loader - const loader = document.getElementById('loading-overlay'); - if (loader) loader.remove(); - document.getElementById('app-root').style.visibility = 'visible'; - }, - - // --- Tab Management --- - - openNewTab() { - const newTab = this.createNewTab(); - this.tabs.push(newTab); - this.activeTabIndex = this.tabs.length - 1; - if (!this.state.params || this.state.params.length === 0) this.addParam('params'); - if (!this.state.headers || this.state.headers.length === 0) this.addParam('headers'); - this.saveState(); - this.render(); - }, - - switchTab(index) { - if (index < 0 || index >= this.tabs.length) return; - this.activeTabIndex = index; - this.saveState(); - this.render(); - }, - - closeTab(index) { - if (this.tabs.length <= 1) { - // Can't close last tab; just reset it - this.tabs[0] = this.createNewTab(); - this.activeTabIndex = 0; - this.saveState(); - this.render(); - return; - } - this.tabs.splice(index, 1); - if (this.activeTabIndex >= this.tabs.length) { - this.activeTabIndex = this.tabs.length - 1; - } - this.saveState(); - this.render(); - }, - - cacheDOM() { - this.dom = { - mainPanel: document.getElementById('main-panel'), - sidebar: document.getElementById('sidebar'), - toast: document.getElementById('toast-container') - }; - - if (!this.dom.sidebar || !this.dom.mainPanel) { - console.error('Critical: DOM elements not found', this.dom); - alert('Critical Error: Application DOM structure is missing. Please refresh.'); - } - }, - - // --- State Management --- - - loadState() { - try { - const raw = localStorage.getItem('phoenix-state-v2'); - if (raw) { - const data = JSON.parse(raw); - // Restore _stateData (global state) - if (data.spaces !== undefined) this._stateData.spaces = data.spaces; - if (data.activeSpaceId !== undefined) this._stateData.activeSpaceId = data.activeSpaceId; - if (data.activeCollectionId !== undefined) this._stateData.activeCollectionId = data.activeCollectionId; - if (data.outputFolderPath !== undefined) this._stateData.outputFolderPath = data.outputFolderPath; - if (data.gridMaximized !== undefined) this._stateData.gridMaximized = data.gridMaximized; - if (data.resultsPanelHeight !== undefined) this._stateData.resultsPanelHeight = data.resultsPanelHeight; - if (data.sidebarWidth !== undefined) this._stateData.sidebarWidth = data.sidebarWidth; - if (data.searchQuery !== undefined) this._stateData.searchQuery = data.searchQuery; - - // Restore tabs - if (data.tabs && data.tabs.length > 0) { - this.tabs = data.tabs.map(t => ({ - ...t, - bulk: { ...(t.bulk || {}), running: false, results: [] }, - response: null - })); - this.activeTabIndex = Math.min(data.activeTabIndex || 0, this.tabs.length - 1); - } else { - // No saved tabs, create a blank one - this.tabs = [this.createNewTab()]; - this.activeTabIndex = 0; - } - } else { - // Fresh start - this.tabs = [this.createNewTab()]; - this.activeTabIndex = 0; - } - } catch (e) { - console.warn('Failed to load state', e); - this.tabs = [this.createNewTab()]; - this.activeTabIndex = 0; - } - }, - - saveState() { - try { - const serializedTabs = this.tabs.map(t => ({ - ...t, - bulk: { ...t.bulk, running: false, results: [] }, - response: null - })); - const persistentState = { - spaces: this._stateData.spaces, - activeSpaceId: this._stateData.activeSpaceId, - activeCollectionId: this._stateData.activeCollectionId, - outputFolderPath: this._stateData.outputFolderPath, - gridMaximized: this._stateData.gridMaximized, - resultsPanelHeight: this._stateData.resultsPanelHeight, - sidebarWidth: this._stateData.sidebarWidth, - searchQuery: this._stateData.searchQuery, - tabs: serializedTabs, - activeTabIndex: this.activeTabIndex - }; - localStorage.setItem('phoenix-state-v2', JSON.stringify(persistentState)); - } catch (e) { - console.warn('Failed to save state', e); - } - }, - - async loadLastRunFromServer() { - try { - const res = await fetch('/api/last-run'); - if (res.ok) { - const data = await res.json(); - if (data) { - if (data.bulk) { - this.state.bulk = { ...this.state.bulk, ...data.bulk, running: false }; - } - if (data.response !== undefined) { - this.state.response = data.response; - } - if (data.responseTab) { - this.state.responseTab = data.responseTab; - } - } - } - } catch (e) { - console.error('Failed to load last run from server', e); - } - }, - - async saveLastRunToServer() { - try { - const payload = { - bulk: { ...this.state.bulk, running: false }, - response: this.state.response, - responseTab: this.state.responseTab - }; - await fetch('/api/last-run', { - method: 'POST', - headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify(payload) - }); - } catch (e) { - console.error('Failed to save last run to server', e); - } - }, - - saveLastRunToServerThrottled() { - if (this._saveThrottleTimeout) return; - this._saveThrottleTimeout = setTimeout(async () => { - this._saveThrottleTimeout = null; - await this.saveLastRunToServer(); - }, 1000); - }, - - get collections() { - if (!this.state.activeSpaceId) return []; - const space = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - return space ? space.collections : []; - }, - - set collections(val) { - if (!this.state.activeSpaceId) return; - const space = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - if (space) { - space.collections = val; - } - }, - - get notifications() { - if (!this.state.activeSpaceId) return []; - const space = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - return space ? (space.notifications || []) : []; - }, - - set notifications(val) { - if (!this.state.activeSpaceId) return; - const space = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - if (space) { - space.notifications = val; - } - }, - - async loadSpacesFromServer() { - try { - const res = await fetch('/api/spaces'); - const data = await res.json(); - if (Array.isArray(data)) { - // Check if server returned empty or only the default empty spaces - const serverIsEmpty = data.length === 0 || ( - data.length === 2 && - data[0].id === 'personal' && data[0].collections.length === 1 && (!data[0].collections[0].requests || data[0].collections[0].requests.length === 0) && - data[1].id === 'team' && data[1].collections.length === 1 && (!data[1].collections[0].requests || data[1].collections[0].requests.length === 0) - ); - - // Check if client had non-empty legacy collections in localStorage - const clientHasLegacyCollections = this.state.collections && ( - this.state.collections.length > 1 || - (this.state.collections[0] && this.state.collections[0].requests && this.state.collections[0].requests.length > 0) - ); - - if (serverIsEmpty && clientHasLegacyCollections) { - console.log('Migrating local client collections to spaces...'); - this.state.spaces = [ - { - id: 'personal', - name: 'Personal Space', - collections: JSON.parse(JSON.stringify(this.state.collections)) - }, - { - id: 'team', - name: 'Team Space', - collections: JSON.parse(JSON.stringify(this.state.collections)) - } - ]; - delete this.state.collections; - await this.saveSpacesToServer(); - } else if (data.length === 0 && this.state.spaces && this.state.spaces.length > 0) { - await this.saveSpacesToServer(); - } else if (data.length > 0) { - this.state.spaces = data; - } - - // Validate activeSpaceId - if (this.state.activeSpaceId) { - const spaceExists = this.state.spaces.some(s => s.id === this.state.activeSpaceId); - if (!spaceExists) { - this.state.activeSpaceId = null; - this.state.activeCollectionId = 'default'; - this.state.activeRequestId = null; - } - } - } - } catch (e) { - console.error('Failed to load spaces from server:', e); - } - }, - - async saveSpacesToServer() { - try { - await fetch('/api/spaces', { - method: 'POST', - headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify(this.state.spaces) - }); - } catch (e) { - console.error('Failed to sync spaces with server:', e); - } - }, - - openSpace(spaceId) { - this.state.activeSpaceId = spaceId; - this.state.activeCollectionId = 'default'; - this.state.activeRequestId = null; - this.saveState(); - this.render(); - }, - - showSpacesDashboard() { - this.state.activeSpaceId = null; - this.state.activeCollectionId = 'default'; - this.state.activeRequestId = null; - this.saveState(); - this.render(); - }, - - async createSpace() { - const name = prompt("Enter space name:"); - if (name && name.trim()) { - const id = 'space_' + Date.now(); - this.state.spaces.push({ - id: id, - name: name.trim(), - collections: [{ id: 'default', name: 'My Requests', requests: [] }] - }); - this.state.activeSpaceId = id; - this.saveState(); - await this.saveSpacesToServer(); - this.render(); - } - }, - - async deleteSpace(spaceId) { - if (this.state.spaces.length <= 1) { - return this.toast("Cannot delete the last remaining space", "error"); - } - if (confirm("Are you sure you want to delete this space? All collections and requests inside it will be permanently lost.")) { - this.state.spaces = this.state.spaces.filter(s => s.id !== spaceId); - if (this.state.activeSpaceId === spaceId) { - this.state.activeSpaceId = null; - this.state.activeCollectionId = 'default'; - this.state.activeRequestId = null; - } - this.saveState(); - await this.saveSpacesToServer(); - this.render(); - } - }, - - renameSpace(spaceId) { - const space = this.state.spaces.find(s => s.id === spaceId); - if (!space) return; - const newName = prompt("Enter new workspace name:", space.name); - if (newName && newName.trim()) { - space.name = newName.trim(); - this.saveState(); - this.saveSpacesToServer(); - this.render(); - } - }, - - async setSpaceTheme(themeId) { - const activeSpace = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - if (activeSpace) { - activeSpace.theme = themeId; - this.saveState(); - await this.saveSpacesToServer(); - this.render(); - this.toast(`Applied ${themeId} theme to ${activeSpace.name}`); - } - }, - - async shareCollection(colId) { - const otherSpaces = this.state.spaces.filter(s => s.id !== this.state.activeSpaceId); - if (otherSpaces.length === 0) { - return this.toast("No other spaces to share with", "warning"); - } - - const activeSpace = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - const collection = this.collections.find(c => c.id === colId); - if (!collection) return; - - const spacesList = otherSpaces.map((s, idx) => `${idx + 1}. ${s.name}`).join('\n'); - const choice = prompt(`Select workspace to share "${collection.name}" with (enter number):\n${spacesList}`); - if (choice) { - const idx = parseInt(choice) - 1; - if (idx >= 0 && idx < otherSpaces.length) { - const targetSpace = otherSpaces[idx]; - targetSpace.notifications = targetSpace.notifications || []; - - const alreadyShared = targetSpace.notifications.some(n => n.collection.id === colId && n.fromSpaceId === this.state.activeSpaceId); - if (alreadyShared) { - return this.toast("Already shared with this space, pending approval", "warning"); - } - - targetSpace.notifications.push({ - id: 'share_' + Date.now(), - fromSpaceId: this.state.activeSpaceId, - fromSpaceName: activeSpace ? activeSpace.name : 'Unknown Space', - collection: JSON.parse(JSON.stringify(collection)) - }); - - this.saveState(); - await this.saveSpacesToServer(); - this.toast(`Shared collection with ${targetSpace.name}!`); - this.render(); - } else { - this.toast("Invalid selection", "error"); - } - } - }, - - openNotificationsModal() { - const activeSpace = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - if (!activeSpace || !activeSpace.notifications || activeSpace.notifications.length === 0) return; - - const modal = document.createElement('div'); - modal.className = 'premium-modal-overlay'; - modal.id = 'notifications-modal'; - - const listHTML = activeSpace.notifications.map(n => ` -
-
- -
-
${this.escapeHTML(n.fromSpaceName)} shared collection:
-
${this.escapeHTML(n.collection.name)}
- ${n.collection.requests ? n.collection.requests.length : 0} Requests -
-
-
- - -
-
- `).join(''); - - modal.innerHTML = ` -
-
-

Share Requests

- -
-
- ${listHTML} -
- -
- `; - document.body.appendChild(modal); - modal.onclick = (e) => { if (e.target === modal) modal.remove(); }; - }, - - async approveShare(notifId) { - const activeSpace = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - if (!activeSpace || !activeSpace.notifications) return; - - const idx = activeSpace.notifications.findIndex(n => n.id === notifId); - if (idx >= 0) { - const notif = activeSpace.notifications[idx]; - const collection = notif.collection; - - let newName = collection.name; - let counter = 1; - while (activeSpace.collections.some(c => c.name === newName)) { - newName = `${collection.name} (${counter++})`; - } - collection.name = newName; - collection.id = 'col_' + Date.now(); - - activeSpace.collections.push(collection); - activeSpace.notifications.splice(idx, 1); - - this.saveState(); - await this.saveSpacesToServer(); - this.toast("Collection approved and added!"); - this.render(); - } - }, - - async rejectShare(notifId) { - const activeSpace = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - if (!activeSpace || !activeSpace.notifications) return; - - const idx = activeSpace.notifications.findIndex(n => n.id === notifId); - if (idx >= 0) { - activeSpace.notifications.splice(idx, 1); - this.saveState(); - await this.saveSpacesToServer(); - this.toast("Share request rejected"); - this.render(); - } - }, - - startSidebarResize(e) { - e.preventDefault(); - document.body.classList.add('resizing'); - const startX = e.clientX; - const startWidth = this.state.sidebarWidth || 270; - const handle = document.getElementById('sidebar-resize-handle'); - if (handle) handle.classList.add('active'); - - const doDrag = (moveEvent) => { - const deltaX = moveEvent.clientX - startX; - const newWidth = Math.max(180, Math.min(600, startWidth + deltaX)); - this.state.sidebarWidth = newWidth; - const sidebarEl = document.getElementById('sidebar'); - if (sidebarEl) { - sidebarEl.style.width = `${newWidth}px`; - } - }; - - const stopDrag = () => { - document.body.classList.remove('resizing'); - document.removeEventListener('mousemove', doDrag); - document.removeEventListener('mouseup', stopDrag); - if (handle) handle.classList.remove('active'); - this.saveState(); - }; - - document.addEventListener('mousemove', doDrag); - document.addEventListener('mouseup', stopDrag); - }, - - async resendBulkRequest(resultIndex) { - const index = resultIndex - 1; // 0-based index - const bulk = this.state.bulk; - const resultItem = bulk.results.find(r => r.index === resultIndex); - if (!resultItem) return; - - this.toast(`Re-sending request #${resultIndex}...`, 'info'); - - // Recalculate maxFiles and maxList to determine fileIndex and listIndex 1-to-1 - let maxFiles = 0; - let maxList = 0; - - const folders = [ - ...this.state.params.filter(p => p.type === 'folder' && p.enabled && p.key && p.key.trim()), - ...(this.state.bodyType === 'form-data' ? this.state.bodyData.filter(p => p.type === 'folder' && p.enabled && p.key && p.key.trim()) : []) - ]; - if (folders.length > 0) { - for (const f of folders) { - const files = this.fileStore.get(f.id); - if (files && files.length > maxFiles) maxFiles = files.length; - } - } - - const allLists = [ - ...this.state.params.filter(p => p.type === 'list' && p.enabled && p.key && p.key.trim()), - ...(this.state.bodyType === 'form-data' ? this.state.bodyData.filter(p => p.type === 'list' && p.enabled && p.key && p.key.trim()) : []), - ...this.state.headers.filter(h => h.type === 'list' && h.enabled && h.key && h.key.trim()) - ]; - if (allLists.length > 0) { - for (const listParam of allLists) { - const val = listParam.value || ''; - const arr = val.split(/[\n,]+/).map(s => s.trim()).filter(s => s); - if (arr.length > maxList) maxList = arr.length; - } - } - - let fileIndex = index; - let listIndex = index; - if (bulk.strategy === 'cartesian' && maxFiles > 0 && maxList > 0) { - fileIndex = Math.floor(index / maxList); - listIndex = index % maxList; - } - - try { - const res = await this.executeRequest(index, fileIndex, listIndex); - const isSuccess = res.status_code >= 200 && res.status_code < 300; - - // Adjust stats counters - const wasSuccess = resultItem.status >= 200 && resultItem.status < 300; - if (wasSuccess && !isSuccess) { - bulk.success--; - bulk.error++; - } else if (!wasSuccess && isSuccess) { - bulk.success++; - bulk.error--; - } - - // Update item details - resultItem.status = res.status_code; - resultItem.latency = res.latency || 0; - resultItem.data = res.content ? res.content.substring(0, 100) : (res.binary_data ? '[Binary]' : ''); - resultItem.fullContent = res.content; - resultItem.binaryData = res.binary_data; - resultItem.contentType = res.content_type; - resultItem.headers = res.headers; - - this.toast(`Request #${resultIndex} completed: ${res.status_code}`, isSuccess ? 'info' : 'error'); - this.updateBulkProgressUI(); - await this.saveLastRunToServer(); - } catch (e) { - const wasSuccess = resultItem.status >= 200 && resultItem.status < 300; - if (wasSuccess) { - bulk.success--; - bulk.error++; - } - resultItem.status = 'ERR'; - resultItem.latency = 0; - resultItem.data = e.message; - this.toast(`Request #${resultIndex} failed: ${e.message}`, 'error'); - this.updateBulkProgressUI(); - await this.saveLastRunToServer(); - } - }, - - startResultsResize(e) { - e.preventDefault(); - document.body.classList.add('resizing'); - const startY = e.clientY; - const startHeight = this.state.resultsPanelHeight || 300; - - const doDrag = (moveEvent) => { - const deltaY = startY - moveEvent.clientY; - const newHeight = Math.max(120, Math.min(800, startHeight + deltaY)); - this.state.resultsPanelHeight = newHeight; - const panel = document.querySelector('.bottom-results-panel'); - if (panel) { - panel.style.height = `${newHeight}px`; - } - }; - - const stopDrag = () => { - document.body.classList.remove('resizing'); - document.removeEventListener('mousemove', doDrag); - document.removeEventListener('mouseup', stopDrag); - this.saveState(); - }; - - document.addEventListener('mousemove', doDrag); - document.addEventListener('mouseup', stopDrag); - }, - - updateBulkProgressUI() { - // Throttle via rAF so rapid-fire results don't block the main thread - if (this._rafPending) return; - this._rafPending = true; - requestAnimationFrame(() => { - this._rafPending = false; - const bulk = this.state.bulk; - const pct = bulk.total > 0 ? (bulk.completed / bulk.total) * 100 : 0; - const statusColor = bulk.error > 0 ? (bulk.success > 0 ? 'var(--warning)' : 'var(--danger)') : 'var(--success)'; - - const bar = document.getElementById('progress-bar-fill'); - if (bar) { bar.style.width = `${pct}%`; bar.style.background = statusColor; } - - const text = document.getElementById('progress-text'); - if (text) text.innerText = `${bulk.completed} / ${bulk.total} Completed`; - - const successStat = document.querySelector('.stat-capsule.success'); - if (successStat) successStat.innerText = `${bulk.success} Success`; - const errorStat = document.querySelector('.stat-capsule.error'); - if (errorStat) errorStat.innerText = `${bulk.error} Failed`; - - // Grid: only append new cards, don't rebuild the whole grid on every frame - const grid = document.querySelector('.results-grid'); - if (grid) { - const rendered = grid.querySelectorAll('.result-card').length; - const all = bulk.results; - if (rendered === 0) { - // First paint — render all - grid.innerHTML = all.map(r => this.renderResultCard(r)).join('') - || `
Executing batch requests...
`; - } else if (all.length > rendered) { - // Append only new cards - const fragment = document.createDocumentFragment(); - const tmp = document.createElement('div'); - for (let i = rendered; i < all.length; i++) { - tmp.innerHTML = this.renderResultCard(all[i]); - fragment.appendChild(tmp.firstElementChild); - } - grid.appendChild(fragment); - } - } - - // Fullscreen overlay — throttled rebuild only every 500ms - const overlay = document.getElementById('fullscreen-results-overlay'); - if (overlay) { - const now = Date.now(); - if (!this._lastFullscreenUpdate || now - this._lastFullscreenUpdate > 500) { - this._lastFullscreenUpdate = now; - this.openFullscreenResults(); - } - } - - // Throttle server saves - this.saveLastRunToServerThrottled(); - }); - }, - - - openFullscreenResults() { - const bulk = this.state.bulk; - if (bulk.results.length === 0 && !bulk.running) { - return this.toast("No results to view in fullscreen", "warning"); - } - - let modal = document.getElementById('fullscreen-results-overlay'); - const pct = bulk.total > 0 ? (bulk.completed / bulk.total) * 100 : 0; - const statusColor = bulk.error > 0 ? (bulk.success > 0 ? 'var(--warning)' : 'var(--danger)') : 'var(--success)'; - const cardsHTML = bulk.results.map(r => this.renderResultCard(r)).join(''); - const folderPath = this.state.outputFolderPath || 'None selected'; - - const contentHTML = ` -
-
- -
-

Fullscreen Batch Processing Grid

-

Real-time execution monitoring and visual results

-
-
- ${bulk.completed} / ${bulk.total} Completed - ${bulk.success} Success - ${bulk.error} Failed -
-
- -
-
- - ${folderPath} - - - -
- - - - -
-
- -
-
-
- -
- ${cardsHTML || `
Executing batch requests, processing results...
`} -
- `; - - if (!modal) { - modal = document.createElement('div'); - modal.className = 'fullscreen-results-overlay'; - modal.id = 'fullscreen-results-overlay'; - modal.innerHTML = contentHTML; - document.body.appendChild(modal); - } else { - modal.innerHTML = contentHTML; - } - }, - - closeFullscreenResults() { - const modal = document.getElementById('fullscreen-results-overlay'); - if (modal) { - modal.remove(); - } - }, - - async browseServerFolder() { - try { - const res = await fetch('/api/browse_folder', { - method: 'POST' - }); - const data = await res.json(); - if (data.success) { - this.state.outputFolderPath = data.path; - this.saveState(); - this.render(); - this.toast(`Folder selected: ${data.path}`); - } else { - this.toast(data.error || 'Failed to browse folder', 'error'); - } - } catch (e) { - this.toast(`Error browsing folder: ${e.message}`, 'error'); - } - }, - - async saveToServerFolder() { - if (!this.state.bulk.results.length) return this.toast('No results to save', 'error'); - if (!this.state.outputFolderPath) { - this.toast('Please select an output folder first', 'error'); - await this.browseServerFolder(); - if (!this.state.outputFolderPath) return; - } - - try { - this.toast('Saving files to server folder...', 'info'); - - // First ensure the latest run is persisted on the server - await this.saveLastRunToServer(); - - // Ask the server to save from its own copy (avoids sending huge binary payloads) - const res = await fetch('/api/save_folder_from_lastrun', { - method: 'POST', - headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ path: this.state.outputFolderPath }) - }); - - const data = await res.json(); - if (data.success) { - const errMsg = data.errors && data.errors.length > 0 ? ` (${data.errors.length} errors)` : ''; - this.toast(`Saved ${data.count} files to ${this.state.outputFolderPath}${errMsg}`); - if (data.errors && data.errors.length > 0) { - console.warn('Save errors:', data.errors); - } - } else { - this.toast(`Failed to save: ${data.error}`, 'error'); - } - } catch (e) { - this.toast(`Error saving to folder: ${e.message}`, 'error'); - } - }, - - async saveIndividualToServerFolder(index) { - const result = this.state.bulk.results.find(r => r.index === index); - if (!result) return; - - if (!this.state.outputFolderPath) { - this.toast('Please select an output folder first', 'error'); - await this.browseServerFolder(); - if (!this.state.outputFolderPath) return; - } - - try { - // Ensure server has latest run data - await this.saveLastRunToServer(); - - const res = await fetch('/api/save_folder_from_lastrun', { - method: 'POST', - headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ - path: this.state.outputFolderPath, - indices: [index] - }) - }); - - const data = await res.json(); - if (data.success && data.count > 0) { - this.toast(`Saved file #${index} to server folder`); - } else { - this.toast(`Failed to save: ${data.error || (data.errors && data.errors[0]) || 'Unknown error'}`, 'error'); - } - } catch (e) { - this.toast(`Error saving file: ${e.message}`, 'error'); - } - }, - - downloadIndividualResult(index) { - const result = this.state.bulk.results.find(r => r.index === index); - if (!result) return; - - try { - const finalFilename = this.getFinalFilename(result); - let blob; - - if (result.binaryData) { - const bytes = new Uint8Array(result.binaryData.match(/.{1,2}/g).map(byte => parseInt(byte, 16))); - blob = new Blob([bytes], { type: result.contentType || 'application/octet-stream' }); - } else if (result.fullContent) { - blob = new Blob([result.fullContent], { type: result.contentType || 'text/plain' }); - } else { - return this.toast('No content to download', 'error'); - } - - const url = URL.createObjectURL(blob); - const a = document.createElement('a'); - a.href = url; - a.download = finalFilename; - document.body.appendChild(a); - a.click(); - document.body.removeChild(a); - URL.revokeObjectURL(url); - - this.toast(`Downloaded "${finalFilename}"`); - } catch (e) { - this.toast(`Download failed: ${e.message}`, 'error'); - } - }, - - clearBulkResults() { - if (confirm("Are you sure you want to clear all batch results?")) { - this.state.bulk.results = []; - this.state.bulk.completed = 0; - this.state.bulk.success = 0; - this.state.bulk.error = 0; - this.state.bulk.total = 0; - this.state.bulk.running = false; - this.saveState(); - this.saveLastRunToServer(); - this.render(); - } - }, - - toggleGridMaximized() { - this.state.gridMaximized = !this.state.gridMaximized; - this.render(); - }, - - // --- Actions --- - - addParam(section) { - const item = { id: Date.now().toString() + Math.random(), key: '', value: '', type: 'text', enabled: true }; - if (section === 'params') this.state.params.push(item); - if (section === 'headers') this.state.headers.push(item); - if (section === 'body') this.state.bodyData.push(item); - this.render(); - this.saveState(); - }, - - removeParam(section, id) { - if (section === 'params') this.state.params = this.state.params.filter(p => p.id !== id); - if (section === 'headers') this.state.headers = this.state.headers.filter(p => p.id !== id); - if (section === 'body') this.state.bodyData = this.state.bodyData.filter(p => p.id !== id); - this.render(); - this.saveState(); - }, - - updateParam(section, id, field, value) { - const list = section === 'params' ? this.state.params : (section === 'headers' ? this.state.headers : this.state.bodyData); - const item = list.find(p => p.id === id); - if (item) { - item[field] = value; - this.saveState(); - // Re-render if type changes to show/hide file input - if (field === 'type' || field === 'enabled') this.render(); - } - }, - - // --- Request Execution --- - - async sendRequest() { - if (!this.state.url) return this.toast('URL is required', 'error'); - - // Reset bulk results upon sending another single request - this.state.bulk.results = []; - this.state.bulk.completed = 0; - this.state.bulk.success = 0; - this.state.bulk.error = 0; - this.state.bulk.total = 0; - - this.state.response = { status: 'Sending...', headers: {} }; - this.state.responseTab = 'response'; // Switch view - this.render(); - this.saveLastRunToServerThrottled(); - - try { - const start = Date.now(); - const res = await this.executeRequest(0); - const latency = Date.now() - start; - - res.latency = latency; - this.state.response = res; - this.saveToCollection(res.status_code || 500); - } catch (e) { - this.state.response = { error: e.message }; - } - - this.render(); - this.saveState(); - await this.saveLastRunToServer(); - }, - - // --- Bulk Execution --- - - async runBulk() { - if (!this.state.url) return this.toast('URL is required', 'error'); - - // Calculate total items based on folders or lists - let maxFiles = 0; - let maxList = 0; - const currentRunId = Date.now(); - this.state.bulk.currentRunId = currentRunId; - - // Check folders first - only those that will actually be used - const folders = [ - ...this.state.params.filter(p => p.type === 'folder' && p.enabled && p.key && p.key.trim()), - ...(this.state.bodyType === 'form-data' ? this.state.bodyData.filter(p => p.type === 'folder' && p.enabled && p.key && p.key.trim()) : []) - ]; - - if (folders.length > 0) { - // Find max file count - for (const f of folders) { - const files = this.fileStore.get(f.id); - if (files && files.length > maxFiles) maxFiles = files.length; - } - } - - // Check lists (params, body, headers) - only those with keys - const allLists = [ - ...this.state.params.filter(p => p.type === 'list' && p.enabled && p.key && p.key.trim()), - ...(this.state.bodyType === 'form-data' ? this.state.bodyData.filter(p => p.type === 'list' && p.enabled && p.key && p.key.trim()) : []), - ...this.state.headers.filter(h => h.type === 'list' && h.enabled && h.key && h.key.trim()) - ]; - - if (allLists.length > 0) { - // Find the longest list - for (const listParam of allLists) { - const val = listParam.value || ''; - const arr = val.split(/[\n,]+/).map(s => s.trim()).filter(s => s); - if (arr.length > maxList) maxList = arr.length; - } - } - - let total = 0; - if (this.state.bulk.strategy === 'cartesian' && maxFiles > 0 && maxList > 0) { - total = maxFiles * maxList; - } else { - total = Math.max(maxFiles, maxList); - } - - // If still no total, use the saved repetitions setting - if (total === 0) { - total = Math.max(1, parseInt(this.state.bulk.repetitions) || 10); - } - - if (total <= 0) return this.toast('Invalid bulk count', 'error'); - - // Init Bulk State - if (!this.state.bulk.paused) { - this.state.bulk.total = total; - this.state.bulk.completed = 0; - this.state.bulk.success = 0; - this.state.bulk.error = 0; - this.state.bulk.results = []; - this.state.bulk.nextIndex = 0; - this.state.responseTab = 'results'; - } else { - this.state.bulk.total = total; - } - - this.state.bulk.running = true; - this.state.bulk.paused = false; - - this.saveToCollection('BULK'); - this.render(); - - // Execution Queue - const concurrency = Math.max(1, Math.min(20, this.state.bulk.concurrency || 1)); - let active = 0; - - const worker = async () => { - while (this.state.bulk.nextIndex < this.state.bulk.total && this.state.bulk.running && this.state.bulk.currentRunId === currentRunId) { - const index = this.state.bulk.nextIndex++; - active++; - - let fileIndex = index; - let listIndex = index; - if (this.state.bulk.strategy === 'cartesian' && maxFiles > 0 && maxList > 0) { - fileIndex = Math.floor(index / maxList); - listIndex = index % maxList; - } - - const inputFilename = this.getInputFilename(index, fileIndex, listIndex); - - try { - const res = await this.executeRequest(index, fileIndex, listIndex); - - if (this.state.bulk.currentRunId !== currentRunId) return; - - const isSuccess = res.status_code >= 200 && res.status_code < 300; - if (isSuccess) this.state.bulk.success++; else this.state.bulk.error++; - - this.state.bulk.results.push({ - index: index + 1, - status: res.status_code, - latency: res.latency || 0, - data: res.content ? res.content.substring(0, 100) : (res.binary_data ? '[Binary]' : ''), - fullContent: res.content, - binaryData: res.binary_data, - contentType: res.content_type, - headers: res.headers, - inputFilename: inputFilename - }); - - this.state.bulk.results.sort((a, b) => a.index - b.index); - if (this.state.bulk.results.length > 1000) this.state.bulk.results.shift(); - - } catch (e) { - if (this.state.bulk.currentRunId !== currentRunId) return; - this.state.bulk.error++; - this.state.bulk.results.push({ - index: index + 1, - status: 'ERR', - latency: 0, - data: e.message, - inputFilename: inputFilename - }); - this.state.bulk.results.sort((a, b) => a.index - b.index); - } finally { - active--; - this.state.bulk.completed++; - if (this.state.bulk.currentRunId === currentRunId) { - this.updateBulkProgressUI(); - } - } - - // Apply inter-request delay (only when concurrency = 1 or after each request) - const delayMs = parseInt(this.state.bulk.delay) || 0; - if (delayMs > 0 && this.state.bulk.running && this.state.bulk.currentRunId === currentRunId) { - await new Promise(r => setTimeout(r, delayMs)); - } - } - - if (active === 0 && this.state.bulk.nextIndex >= this.state.bulk.total && this.state.bulk.currentRunId === currentRunId) { - this.state.bulk.running = false; - this.state.bulk.paused = false; - this.render(); - this.toast('Bulk Operation Completed'); - await this.saveLastRunToServer(); - } - }; - - // Spawn workers - for (let i = 0; i < concurrency; i++) { - worker(); - } - }, - - stopBulk() { - this.state.bulk.running = false; - this.state.bulk.paused = false; - this.render(); - }, - - pauseBulk() { - if (this.state.bulk.running) { - this.state.bulk.running = false; - this.state.bulk.paused = true; - this.render(); - this.toast('Bulk Operation Paused', 'warning'); - } - }, - - resumeBulk() { - if (this.state.bulk.paused) { - this.runBulk(); - } - }, - - async getImageDimensions(file) { - return new Promise((resolve) => { - if (!file || !file.type.startsWith('image/')) return resolve({width: 0, height: 0}); - const img = new Image(); - const url = URL.createObjectURL(file); - img.onload = () => { - resolve({width: img.width, height: img.height}); - URL.revokeObjectURL(url); - }; - img.onerror = () => { - resolve({width: 0, height: 0}); - URL.revokeObjectURL(url); - }; - img.src = url; - }); - }, - - async executeRequest(index, fileIndex = index, listIndex = index) { - const start = Date.now(); - // Headers - const headers = {}; - this.state.headers.filter(h => h.enabled && h.key && h.key.trim()).forEach(h => { - // Handle list replacement in headers too - let val = h.value; - if (h.type === 'list') { - const arr = val.split(/[\n,]+/).map(s => s.trim()).filter(s => s); - if (arr.length > 0) val = arr[listIndex % arr.length]; - } - headers[h.key.trim()] = val; - }); - - // Auth - const auth = this.state.auth; - if (auth.type === 'bearer') headers['Authorization'] = `Bearer ${auth.token}`; - else if (auth.type === 'basic') headers['Authorization'] = 'Basic ' + btoa(`${auth.username}:${auth.password}`); - else if (auth.type === 'apikey') headers[auth.key] = auth.value; - - // URL Params - const urlObj = new URL(this.state.url); - this.state.params.filter(p => p.enabled && p.key && p.key.trim()).forEach(p => { - let val = p.value; - // List handling - if (p.type === 'list') { - // Try splitting by newline first if present, else comma - const arr = val.split(/[\n,]+/).map(s => s.trim()).filter(s => s); - if (arr.length > 0) val = arr[listIndex % arr.length]; - } - // File logic not applicable for URL params usually, skipping - urlObj.searchParams.append(p.key, val); - }); - - // Payload Construction - const finalData = new FormData(); - finalData.append('method', this.state.method); - finalData.append('url', urlObj.toString()); - finalData.append('headers', JSON.stringify(headers)); - // Add auth config for server-side handling if needed (e.g. Basic Auth via requests arg) - if (auth.type === 'basic') finalData.append('auth', JSON.stringify({ type: 'basic', username: auth.username, password: auth.password })); - - // Body - if (this.state.bodyType === 'json') { - finalData.append('body_type', 'json'); - finalData.append('body', this.state.jsonBody); - } else if (this.state.bodyType === 'form-data') { - finalData.append('body_type', 'form-data'); - - let currentImageFile = null; - const folderParam = this.state.bodyData.find(p => p.enabled && p.type === 'folder'); - if (folderParam) { - const files = this.fileStore.get(folderParam.id); - if (files && files.length > 0) currentImageFile = files[fileIndex % files.length]; - } - if (!currentImageFile) { - const fileParam = this.state.bodyData.find(p => p.enabled && p.type === 'file'); - if (fileParam) { - const files = this.fileStore.get(fileParam.id); - if (files && files.length > 0) currentImageFile = files[0]; - } - } - let imgDims = null; - - const bodyParams = this.state.bodyData.filter(p => p.enabled && (p.type === 'file' || p.type === 'folder' || p.type === 'auto_width' || p.type === 'auto_height' || (p.key && p.key.trim()))); - for (const p of bodyParams) { - if (p.type === 'file' || p.type === 'folder') { - const files = this.fileStore.get(p.id); - if (files && files.length > 0) { - if (p.type === 'folder') { - finalData.append(p.key, files[fileIndex % files.length]); - } else { - for (let f of files) finalData.append(p.key, f); - } - } - } else if (p.type === 'auto_width' || p.type === 'auto_height') { - if (!imgDims) imgDims = await this.getImageDimensions(currentImageFile); - finalData.append(p.key, p.type === 'auto_width' ? imgDims.width : imgDims.height); - } else { - let val = p.value; - if (p.type === 'list') { - const arr = val.split(/[\n,]+/).map(s => s.trim()).filter(s => s); - if (arr.length > 0) val = arr[listIndex % arr.length]; - } - finalData.append(p.key, val); - } - } - } - - const res = await fetch('/api/proxy-request', { - method: 'POST', - body: finalData - }); - - const data = await res.json(); - data.latency = Date.now() - start; - return data; - }, - - saveToCollection(lastStatus) { - if (!this.state.url) return; - - let targetColId = this.state.activeCollectionId || 'default'; - let col = this.collections.find(c => c.id === targetColId); - if (!col) { - col = this.collections.find(c => c.id === 'default'); - if(!col) { - col = { id: 'default', name: 'My Requests', requests: [] }; - this.collections.push(col); - } - targetColId = col.id; - } - - const existingIdx = col.requests.findIndex(r => r.id === this.state.activeRequestId || (r.url === this.state.url && r.method === this.state.method)); - let existingReq = existingIdx >= 0 ? col.requests[existingIdx] : null; - - const reqData = { - id: this.state.activeRequestId || Date.now().toString(), - name: (existingReq && existingReq.name) ? existingReq.name : (this.state.url.split('?')[0].split('/').pop() || 'Root URL'), - method: this.state.method, - url: this.state.url, - params: JSON.parse(JSON.stringify(this.state.params)), - headers: JSON.parse(JSON.stringify(this.state.headers)), - auth: JSON.parse(JSON.stringify(this.state.auth)), - bodyType: this.state.bodyType, - bodyData: JSON.parse(JSON.stringify(this.state.bodyData)), - jsonBody: this.state.jsonBody, - lastStatus: lastStatus !== undefined ? lastStatus : (existingReq ? existingReq.lastStatus : null), - lastTime: new Date().toLocaleTimeString(), - activeCollectionId: targetColId - }; - - if (existingIdx >= 0) { - // Update existing - reqData.id = existingReq.id; // preserve ID - col.requests[existingIdx] = reqData; - } else { - // Add new - col.requests.unshift(reqData); - } - - this.state.activeRequestId = reqData.id; - this.saveState(); - this.saveSpacesToServer(); - }, - - loadRequest(colId, reqId) { - const col = this.collections.find(c => c.id === colId); - if(!col) return; - const req = col.requests.find(r => r.id === reqId); - if(!req) return; - - // Check if this request is already open in any tab - const existingTabIdx = this.tabs.findIndex(t => t.activeRequestId === reqId); - if (existingTabIdx >= 0) { - // Just switch to that tab - this.activeTabIndex = existingTabIdx; - this.saveState(); - this.render(); - return; - } - - // Postman behavior: if the current tab is a "preview" tab (untouched/empty), reuse it; - // otherwise open a new tab - const currTab = this.tabs[this.activeTabIndex]; - const isUntouched = currTab && ( - (!currTab.url || currTab.url === '') && - (!currTab.activeRequestId) && - (!currTab.response) && - (currTab.name === 'Untitled Request' || !currTab.name) - ); - - const reqTabData = { - id: 'tab_' + Date.now() + Math.random().toString(36).substr(2, 9), - name: req.name || (req.url ? req.url.split('/').pop() || req.url : 'Request'), - method: req.method || 'GET', - url: req.url || '', - params: JSON.parse(JSON.stringify(req.params || [{ id: Date.now().toString(), key: '', value: '', type: 'text', enabled: true }])), - headers: JSON.parse(JSON.stringify(req.headers || [{ id: (Date.now()+1).toString(), key: '', value: '', type: 'text', enabled: true }])), - auth: JSON.parse(JSON.stringify(req.auth || {type:'none'})), - bodyType: req.bodyType || 'none', - bodyData: JSON.parse(JSON.stringify(req.bodyData || [])), - jsonBody: req.jsonBody || '', - response: null, - bulk: { strategy: 'consecutive', running: false, total: 0, completed: 0, success: 0, error: 0, concurrency: 1, results: [] }, - activeTab: 'params', - responseTab: 'response', - activeRequestId: reqId, - activeCollectionId: colId, - isPreview: false - }; - - if (isUntouched) { - // Replace current blank tab - this.tabs[this.activeTabIndex] = reqTabData; - } else { - // Open brand new tab - this.tabs.push(reqTabData); - this.activeTabIndex = this.tabs.length - 1; - } - - this.saveState(); - this.render(); - }, - - deleteRequest(colId, reqId) { - const col = this.collections.find(c => c.id === colId); - if(col) col.requests = col.requests.filter(r => r.id !== reqId); - if(this.state.activeRequestId === reqId) this.state.activeRequestId = null; - this.saveState(); - this.saveSpacesToServer(); - this.render(); - }, - - createCollection() { - const name = prompt("Collection Name:"); - if(name) { - const id = 'col_' + Date.now(); - this.collections.push({ id, name, requests: [] }); - this.state.activeCollectionId = id; - this.saveState(); - this.saveSpacesToServer(); - this.render(); - } - }, - - renameCollection(colId) { - const col = this.collections.find(c => c.id === colId); - if(!col) return; - const newName = prompt("Enter new collection name:", col.name); - if(newName && newName.trim()) { - col.name = newName.trim(); - this.saveState(); - this.saveSpacesToServer(); - this.render(); - } - }, - - renameRequest(colId, reqId) { - const col = this.collections.find(c => c.id === colId); - if(!col) return; - const req = col.requests.find(r => r.id === reqId); - if(!req) return; - const newName = prompt("Enter new request name:", req.name); - if(newName && newName.trim()) { - req.name = newName.trim(); - this.saveState(); - this.saveSpacesToServer(); - this.render(); - } - }, - - deleteCollection(colId) { - if(confirm("Delete this collection and all its requests? This cannot be undone.")) { - this.collections = this.collections.filter(c => c.id !== colId); - // Always keep at least one collection - if (this.collections.length === 0) { - this.collections = [{ id: 'default', name: 'My Requests', requests: [] }]; - } - // If deleted collection was active, switch to first remaining - const stillExists = this.collections.some(c => c.id === this.state.activeCollectionId); - if (!stillExists) { - this.state.activeCollectionId = this.collections[0].id; - this.state.activeRequestId = null; - } - this.saveState(); - this.saveSpacesToServer(); - this.render(); - } - }, - - addRequestToCollection(colId) { - const col = this.collections.find(c => c.id === colId); - if (!col) return; - const reqId = 'req_' + Date.now(); - const newReq = { - id: reqId, - name: 'New Request', - method: 'GET', - url: '', - description: '', - params: [{ id: Date.now().toString() + Math.random(), key: '', value: '', type: 'text', enabled: true }], - headers: [{ id: Date.now().toString() + Math.random(), key: '', value: '', type: 'text', enabled: true }], - auth: { type: 'none' }, - bodyType: 'none', - bodyData: [], - jsonBody: '' - }; - col.requests.push(newReq); - - // Open this new request in a new tab - const reqTabData = { - id: 'tab_' + Date.now() + Math.random().toString(36).substr(2, 9), - name: 'New Request', - method: 'GET', - url: '', - params: JSON.parse(JSON.stringify(newReq.params)), - headers: JSON.parse(JSON.stringify(newReq.headers)), - auth: { type: 'none' }, - bodyType: 'none', - bodyData: [], - jsonBody: '', - response: null, - bulk: { strategy: 'consecutive', running: false, total: 0, completed: 0, success: 0, error: 0, concurrency: 1, results: [] }, - activeTab: 'params', - responseTab: 'response', - activeRequestId: reqId, - activeCollectionId: colId, - isPreview: false - }; - this.tabs.push(reqTabData); - this.activeTabIndex = this.tabs.length - 1; - - this.saveState(); - this.saveSpacesToServer(); - this.render(); - this.toast("Added new request to collection"); - - }, - - updateActiveRequestName(name) { - const activeSpace = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - const col = activeSpace ? activeSpace.collections.find(c => c.id === this.state.activeCollectionId) : null; - const activeReq = col ? col.requests.find(r => r.id === this.state.activeRequestId) : null; - if (activeReq) { - activeReq.name = name.trim() || 'Untitled Request'; - this.saveState(); - this.saveSpacesToServer(); - this.render(); - } - }, - - updateActiveRequestDescription(desc) { - const activeSpace = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - const col = activeSpace ? activeSpace.collections.find(c => c.id === this.state.activeCollectionId) : null; - const activeReq = col ? col.requests.find(r => r.id === this.state.activeRequestId) : null; - if (activeReq) { - activeReq.description = desc; - this.saveState(); - this.saveSpacesToServer(); - } - }, - - downloadHistory() { - if (!this.state.bulk.results.length) return; - - const csvContent = "data:text/csv;charset=utf-8," - + "Index,Status,Latency (ms),Snippet\n" - + this.state.bulk.results.map(r => `${r.index},${r.status},${r.latency},"${(r.data || '').replace(/"/g, '""').replace(/\n/g, ' ')}"`).join("\n"); - - const encodedUri = encodeURI(csvContent); - const link = document.createElement("a"); - link.setAttribute("href", encodedUri); - link.setAttribute("download", `bulk_results_${new Date().toISOString()}.csv`); - document.body.appendChild(link); - link.click(); - document.body.removeChild(link); - }, - - // Get the input filename for a given bulk index - getInputFilename(index, fileIndex = index, listIndex = index) { - // Build list of active params that could provide a name - const activeParams = [ - ...this.state.params.filter(p => p.enabled && p.key && p.key.trim()), - ...(this.state.bodyType === 'form-data' ? this.state.bodyData.filter(p => p.enabled && p.key && p.key.trim()) : []) - ]; - - let folderName = null; - // Priority 1: Folder type (usually high-intent for naming) - const folderParam = activeParams.find(p => p.type === 'folder'); - if (folderParam) { - const files = this.fileStore.get(folderParam.id); - if (files && files.length > 0) { - const file = files[fileIndex % files.length]; - folderName = file.webkitRelativePath || file.name; - } - } - - let listName = null; - // Priority 2: List in Body (user's specific request context) - if (this.state.bodyType === 'form-data') { - const bodyList = this.state.bodyData.find(p => p.type === 'list' && p.enabled && p.key && p.key.trim()); - if (bodyList) { - const arr = bodyList.value.split(/[\n,]+/).map(s => s.trim()).filter(s => s); - if (arr.length > 0) listName = arr[listIndex % arr.length]; - } - } - - // Priority 3: Any other list - if (!listName) { - const listParam = activeParams.find(p => p.type === 'list'); - if (listParam) { - const val = listParam.value || ''; - const arr = val.split(/[\n,]+/).map(s => s.trim()).filter(s => s); - if (arr.length > 0) listName = arr[listIndex % arr.length]; - } - } - - if (folderName && listName) { - // Strip extension from folderName, add listName, re-add extension - let base = folderName; - let ext = ''; - const lastDot = folderName.lastIndexOf('.'); - if (lastDot !== -1 && lastDot > 0 && folderName.length - lastDot <= 6) { - base = folderName.substring(0, lastDot); - ext = folderName.substring(lastDot); - } - // Replace any invalid characters in listName just in case, though usually fine - const safeListName = listName.replace(/[\/\\]/g, '_'); - return `${base}_${safeListName}${ext}`; - } else if (folderName) { - return folderName; - } else if (listName) { - return listName; - } - - return `result_${index + 1}`; - }, - - // Get the final filename with appropriate extension if missing - getFinalFilename(result) { - let name = result.inputFilename || `result_${result.index}`; - let originalExt = ''; - - // Extract existing extension if present - const lastDot = name.lastIndexOf('.'); - if (lastDot > 0 && (name.length - lastDot) <= 6) { - originalExt = name.substring(lastDot); - name = name.substring(0, lastDot); - } - - // Map common content types - const ct = (result.contentType || '').toLowerCase(); - if (ct.includes('image/png')) return name + '.png'; - if (ct.includes('image/jpeg') || ct.includes('image/jpg')) return name + '.jpg'; - if (ct.includes('image/gif')) return name + '.gif'; - if (ct.includes('image/webp')) return name + '.webp'; - if (ct.includes('image/svg')) return name + '.svg'; - if (ct.includes('application/pdf')) return name + '.pdf'; - if (ct.includes('application/json')) return name + '.json'; - if (ct.includes('application/xml') || ct.includes('text/xml')) return name + '.xml'; - if (ct.includes('text/html')) return name + '.html'; - if (ct.includes('text/csv')) return name + '.csv'; - if (ct.includes('text/css')) return name + '.css'; - if (ct.includes('text/plain')) return name + '.txt'; - if (ct.includes('application/zip')) return name + '.zip'; - - // Fallback for other binary types: try to extract subtype - if (result.binaryData && ct.includes('/')) { - const subtype = ct.split('/')[1].split(';')[0]; // handle "type/subtype;charset=..." - if (subtype && subtype.length <= 4 && /^[a-z0-9]+$/.test(subtype)) { - return name + '.' + subtype; - } - } - - // Content sniffing for JSON if content type is missing or incorrect - if (!result.binaryData && result.fullContent) { - const trimmed = result.fullContent.trim(); - if ((trimmed.startsWith('{') && trimmed.endsWith('}')) || (trimmed.startsWith('[') && trimmed.endsWith(']'))) { - try { - JSON.parse(trimmed); // Quick validation - return name + '.json'; - } catch(e) {} - } - } - - // If we still don't know the type, fallback to original extension if it existed - if (originalExt) return name + originalExt; - - // Otherwise default based on data format - return result.binaryData ? name + '.bin' : name + '.txt'; - }, - - async saveAsFolder() { - if (!this.state.bulk.results.length) return this.toast('No results to save', 'error'); - - try { - if (!window.showDirectoryPicker) { - return this.toast('Your browser does not support native folder saving. Please use the ZIP button instead.', 'error'); - } - - this.toast('Select a folder to save files...', 'info'); - const dirHandle = await window.showDirectoryPicker({ - mode: 'readwrite' - }); - - let savedCount = 0; - let errors = 0; - const usedNames = new Set(); - - for (const r of this.state.bulk.results) { - try { - let filename = this.getFinalFilename(r); - - let base = filename; - let ext = ''; - const lastDot = filename.lastIndexOf('.'); - if (lastDot !== -1 && lastDot > 0) { - base = filename.substring(0, lastDot); - ext = filename.substring(lastDot); - } - - let counter = 1; - while (usedNames.has(filename)) { - filename = `${base}_${counter}${ext}`; - counter++; - } - usedNames.add(filename); - - // Get the content as binary data - let data; - if (r.binaryData) { - // Convert hex string to Uint8Array - data = new Uint8Array(r.binaryData.match(/.{1,2}/g).map(byte => parseInt(byte, 16))); - } else if (r.fullContent) { - data = r.fullContent; - } else { - continue; // Skip empty results - } - - // Create file and write content - const fileHandle = await dirHandle.getFileHandle(filename, { create: true }); - const writable = await fileHandle.createWritable(); - await writable.write(data); - await writable.close(); - - savedCount++; - } catch (e) { - console.error('Error saving file', r.index, e); - errors++; - } - } - - if (errors > 0) { - this.toast(`Saved ${savedCount} files. Failed to save ${errors} files.`, 'warning'); - } else { - this.toast(`Successfully saved ${savedCount} files to the selected folder.`); - } - - } catch (e) { - console.error(e); - if (e.name === 'AbortError') { - this.toast('Folder selection cancelled.', 'info'); - } else { - this.toast('Failed to save to folder: ' + e.message, 'error'); - } - } - }, - - async saveAllResults() { - if (!this.state.bulk.results.length) return this.toast('No results to save', 'error'); - if (typeof JSZip === 'undefined') return this.toast('JSZip library not loaded. Please refresh.', 'error'); - - this.toast('Building ZIP file...', 'info'); - - const zip = new JSZip(); - let savedCount = 0; - const usedNames = new Set(); - - for (const result of this.state.bulk.results) { - try { - // Use the tracked input filename + auto extension - let filename = this.getFinalFilename(result); - - let base = filename; - let ext = ''; - const lastDot = filename.lastIndexOf('.'); - if (lastDot !== -1 && lastDot > 0) { - base = filename.substring(0, lastDot); - ext = filename.substring(lastDot); - } - - let counter = 1; - while (usedNames.has(filename)) { - filename = `${base}_${counter}${ext}`; - counter++; - } - usedNames.add(filename); - - // Get the content as binary data - let data; - if (result.binaryData) { - // Convert hex string to Uint8Array - data = new Uint8Array(result.binaryData.match(/.{1,2}/g).map(byte => parseInt(byte, 16))); - } else if (result.fullContent) { - data = result.fullContent; - } else { - continue; // Skip empty results - } - - // Add to ZIP (JSZip handles folder creation from path automatically) - zip.file(filename, data, { binary: !!result.binaryData }); - savedCount++; - } catch (e) { - console.error('Error adding result to ZIP', result.index, e); - } - } - - if (savedCount === 0) return this.toast('No valid results to save', 'error'); - - // Generate and download ZIP - try { - const blob = await zip.generateAsync({ type: 'blob' }); - const url = URL.createObjectURL(blob); - const a = document.createElement('a'); - a.href = url; - a.download = `bulk_results_${new Date().toISOString().replace(/[:.]/g, '-')}.zip`; - document.body.appendChild(a); - a.click(); - document.body.removeChild(a); - URL.revokeObjectURL(url); - - this.toast(`ZIP saved with ${savedCount} files`, 'info'); - } catch (e) { - this.toast('Error generating ZIP: ' + e.message, 'error'); - } - }, - - // --- Rendering --- - - render() { - const root = document.getElementById('app-root'); - if (root) { - // Reset base class first to prevent layout/theme clashing - root.className = 'workspace'; - - if (this.state.bulk.results.length > 0 || this.state.bulk.running) { - root.classList.add('bulk-active'); - } - if (this.state.gridMaximized || !this.state.activeSpaceId) { - root.classList.add('grid-maximized'); - } - - // Add theme class for active space - if (this.state.activeSpaceId) { - const activeSpace = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - const theme = activeSpace && activeSpace.theme ? activeSpace.theme : 'violet'; - root.classList.add(`theme-${theme}`); - } - } - this.renderSidebar(); - this.renderMain(); - this.renderResponse(); - }, - - renderProgress() { - // Optimized partial render for progress bar - const bar = document.getElementById('progress-bar-fill'); - const text = document.getElementById('progress-text'); - if (bar && text) { - const pct = (this.state.bulk.completed / this.state.bulk.total) * 100; - bar.style.width = `${pct}%`; - text.innerText = `${this.state.bulk.completed} / ${this.state.bulk.total}`; - } - }, - - getCollectionsHTML() { - const query = (this.state.searchQuery || '').toLowerCase().trim(); - let collectionsHTML = ''; - - this.collections.forEach(col => { - const isColActive = this.state.activeCollectionId === col.id; - - // Filter requests - const filteredRequests = col.requests.filter(r => { - if (!query) return true; - return ( - (r.name || '').toLowerCase().includes(query) || - (r.url || '').toLowerCase().includes(query) || - (r.description || '').toLowerCase().includes(query) - ); - }); - - // Decide if the collection itself matches - const colMatches = (col.name || '').toLowerCase().includes(query); - - // If neither collection matches nor has matching requests, skip rendering it - if (query && !colMatches && filteredRequests.length === 0) { - return; - } - - // If there's a query and we have matches, auto-expand the collection - const isExpanded = query ? true : isColActive; - - const reqsHTML = (query && colMatches ? col.requests : filteredRequests).map(r => ` -
- ${r.method} -
-
- ${this.escapeHTML(r.name || '')} -
-
- ${this.escapeHTML(r.url || 'No URL')} -
-
- - -
- `).join(''); - - collectionsHTML += ` -
-
- - ${this.escapeHTML(col.name)} - - - - - -
- ${isExpanded ? `
${reqsHTML || '
Empty Collection
'}
` : ''} -
- `; - }); - - return collectionsHTML; - }, - - filterSidebarCollections(query) { - this.state.searchQuery = query; - const listEl = document.getElementById('sidebar-collections-list'); - if (listEl) { - listEl.innerHTML = this.getCollectionsHTML(); - } - - // Also update clear button visibility - const clearBtn = document.getElementById('search-clear-btn'); - if (clearBtn) { - clearBtn.style.display = query ? 'block' : 'none'; - } - }, - - renderSidebar() { - const collectionsHTML = this.getCollectionsHTML(); - const activeSpace = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - - let notificationsBannerHTML = ''; - if (activeSpace && activeSpace.notifications && activeSpace.notifications.length > 0) { - notificationsBannerHTML = ` -
- - You have ${activeSpace.notifications.length} pending share request${activeSpace.notifications.length > 1 ? 's' : ''} -
- `; - } - - const spaceOptionsHTML = ` - - ${this.state.spaces.map(s => ` - - `).join('')} - `; - - const sidebarHeaderHTML = ` - - `; - - this.dom.sidebar.innerHTML = ` - ${sidebarHeaderHTML} - - ${activeSpace ? ` - ${notificationsBannerHTML} - - - - - - ` : ` -
- Select a workspace from the dashboard to view collections -
- `} - -
- -
- `; - }, - - renderMain() { - if (!this.state.activeSpaceId) { - // Render Spaces Dashboard Grid View - const spacesCardsHTML = this.state.spaces.map(s => { - const count = s.collections ? s.collections.length : 0; - const notifCount = s.notifications ? s.notifications.length : 0; - const theme = s.theme || 'violet'; - return ` -
-
- - ${notifCount > 0 ? `${notifCount}` : ''} -
-
-

${this.escapeHTML(s.name)}

- ${count} Collections -
-
- - ${this.state.spaces.length > 1 ? ` - - ` : ''} -
-
- `; - }).join(''); - - const dashboardHTML = ` -
-
-

Workspaces

-

Select a workspace to access its collections, endpoints, and history.

-
- -
- ${spacesCardsHTML} - -
-
-
-

Create New Space

- Add a clean workspace -
-
-
-
- `; - - const headerHTML = ` -
-
PHOENIX
-
- Workspace Dashboard -
-
-
- `; - - this.dom.mainPanel.innerHTML = headerHTML + dashboardHTML; - return; - } - - const isBulkStart = this.checkBulkStart(); - const bulk = this.state.bulk; - const activeSpace = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - - // Tab Strip (Postman-like) - const tabStripHTML = ` -
- ${this.tabs.map((tab, i) => { - const isActive = i === this.activeTabIndex; - const tabName = tab.name || (tab.url ? tab.url.split('/').pop() || 'Request' : 'Untitled'); - const displayName = tabName.length > 22 ? tabName.substring(0, 22) + '…' : tabName; - const method = tab.method || 'GET'; - const methodColors = { GET:'#10b981', POST:'#6366f1', PUT:'#f59e0b', DELETE:'#ef4444', PATCH:'#8b5cf6' }; - const mc = methodColors[method] || '#888'; - return ` -
- ${method} - ${this.escapeHTML(displayName)} - -
- `; - }).join('')} - -
- `; - - // Header with Active Space name/switcher - const headerHTML = ` -
-
- PHOENIX -
-
- ${this.escapeHTML(activeSpace ? activeSpace.name : '')} - -
- - -
- -
- -
- - -
- -
- ${bulk.running - ? ` - ` - : bulk.paused - ? ` - ` - : `` - } -
-
- ${tabStripHTML} - `; - - // Request Name & Description Details Section - const col = activeSpace ? activeSpace.collections.find(c => c.id === this.state.activeCollectionId) : null; - const activeReq = col ? col.requests.find(r => r.id === this.state.activeRequestId) : null; - - const requestMetaHTML = activeReq ? ` -
-
- Request Name: - -
-
- Description: - -
-
- ` : ''; - - // Tabs (PARAMS / HEADERS / BODY / AUTH) + Bulk controls always visible - const tabsHTML = ` -
- ${['params', 'headers', 'body', 'auth'].map(t => ` -
${t.toUpperCase()}
- `).join('')} -
-
- ${isBulkStart ? ` -
- Strategy: - - -
- ` : ''} -
- Repeat: - -
-
- Delay (ms): - -
-
- Concurrency: - -
-
-
- `; - - - // Content - let contentHTML = ''; - if (this.state.activeTab === 'params') contentHTML = this.renderTable(this.state.params, 'params'); - else if (this.state.activeTab === 'headers') contentHTML = this.renderTable(this.state.headers, 'headers'); - else if (this.state.activeTab === 'body') contentHTML = this.renderBodyTab(); - else if (this.state.activeTab === 'auth') contentHTML = this.renderAuthTab(); - - // Bottom Results & Response Panel (Always Rendered) - const pct = bulk.total > 0 ? (bulk.completed / bulk.total) * 100 : 0; - const statusColor = bulk.error > 0 ? (bulk.success > 0 ? 'var(--warning)' : 'var(--danger)') : 'var(--success)'; - const cardsHTML = bulk.results.map(r => this.renderResultCard(r)).join(''); - const folderPath = this.state.outputFolderPath || 'None selected'; - const activeBottomTab = this.state.responseTab || 'response'; - - let bottomTabContentHTML = ''; - if (activeBottomTab === 'response') { - const resp = this.state.response; - if (!resp) { - bottomTabContentHTML = `
Ready to send request. Click SEND to execute a single request, or RUN BATCH for bulk.
`; - } else if (resp.status === 'Sending...') { - bottomTabContentHTML = `
Sending request...
`; - } else if (resp.error) { - bottomTabContentHTML = `
Error: ${resp.error}
`; - } else { - let content = resp.content; - try { - if (content && !resp.binary_data && content.trim().startsWith('{')) { - content = JSON.stringify(JSON.parse(content), null, 2); - } - } catch(e){} - - bottomTabContentHTML = ` -
- ${resp.status_code} - ${resp.latency ? resp.latency + ' ms' : ''} - ${resp.content_type || 'Unknown Type'} -
-
- ${resp.binary_data - ? `
- Binary Content -
` - : `
${this.escapeHTML(content)}
` - } -
- `; - } - } else { - if (bulk.results.length === 0) { - bottomTabContentHTML = ` -
- - No batch results yet. Run a batch to see results in a grid. -
- `; - } else { - bottomTabContentHTML = ` -
-
-
-
- ${cardsHTML} -
- `; - } - } - - bottomPanelHTML = ` -
-
-
- -
-
-
- - -
- - ${bulk.results.length > 0 ? ` -
- ${bulk.completed} / ${bulk.total} Completed - ${bulk.success} Success - ${bulk.error} Failed -
- ` : ''} -
- - ${activeBottomTab === 'results' && bulk.results.length > 0 ? ` -
-
- - ${folderPath} - - - -
- - - - - -
- ` : ''} -
- -
- ${bottomTabContentHTML} -
-
- `; - - this.dom.mainPanel.innerHTML = headerHTML + requestMetaHTML + tabsHTML + `
${contentHTML}
` + bottomPanelHTML; - }, - - renderResultCard(result) { - const isImage = (result.contentType || '').toLowerCase().includes('image') && result.binaryData; - const isSuccess = result.status >= 200 && result.status < 300; - const statusClass = isSuccess ? 'status-success' : 'status-error'; - const filename = result.inputFilename || `result_${result.index}`; - const finalFilename = this.getFinalFilename(result); - - let previewHTML = ''; - if (isImage) { - try { - const base64Data = this.hexToBase64(result.binaryData); - previewHTML = `${filename}`; - } catch (e) { - previewHTML = `
Decode error
`; - } - } else { - let icon = 'fa-file-lines'; - let typeLabel = 'TXT'; - const ct = (result.contentType || '').toLowerCase(); - if (ct.includes('application/json')) { icon = 'fa-file-code'; typeLabel = 'JSON'; } - else if (ct.includes('text/html')) { icon = 'fa-file-code'; typeLabel = 'HTML'; } - else if (result.status === 'ERR') { icon = 'fa-circle-xmark'; typeLabel = 'ERROR'; } - previewHTML = ` -
- - ${typeLabel} -

${this.escapeHTML(result.data || '')}

-
`; - } - - const footerHTML = isImage - ? `` - : `
-
- #${result.index} - ${result.status} - ${result.latency}ms -
-
${finalFilename}
-
`; - - return ` -
-
- ${previewHTML} -
- ${!isImage ? ` - ` : ''} - - - -
-
- ${footerHTML} -
- `; - }, - - renderResponse() { - // No-op: Single response and bulk results have been consolidated into renderMain()'s bottom panel. - }, - - renderTable(items, section) { - return ` - - - - ${items.map(item => ` - - - - - - - `).join('')} - -
KeyValue
- - ${this.renderValueInput(item, section)} -
- - `; - }, - - renderValueInput(item, section) { - if (item.type === 'file' || item.type === 'folder') { - const files = this.fileStore.get(item.id); - const label = files ? (item.type === 'folder' ? `${files.length} Files Selected` : `${files.length} Files`) : 'Select...'; - return ` -
- - -
- `; - } - if (item.type === 'auto_width' || item.type === 'auto_height') { - return ``; - } - return ``; - }, - - renderBodyTab() { - return ` -
-
- - - -
- - ${this.state.bodyType === 'form-data' ? this.renderTable(this.state.bodyData, 'body') : ''} - ${this.state.bodyType === 'json' ? `` : ''} -
- `; - }, - - renderAuthTab() { - const auth = this.state.auth; - return ` -
- - - - ${auth.type === 'bearer' ? ` -
- - -
- ` : ''} - - ${auth.type === 'basic' ? ` -
-
-
-
- ` : ''} - - ${auth.type === 'apikey' ? ` -
-
-
-
- ` : ''} -
- `; - }, - - // --- Helpers --- - - handleFileSelect(input, section, id) { - if (input.files.length > 0) { - // Convert FileList to Array and sort by path to ensure strict processing sequence (natural sorting) - let filesArr = Array.from(input.files); - filesArr.sort((a, b) => { - const pA = a.webkitRelativePath || a.name; - const pB = b.webkitRelativePath || b.name; - return pA.localeCompare(pB, undefined, { numeric: true, sensitivity: 'base' }); - }); - this.fileStore.set(id, filesArr); - this.render(); // update label - } - }, - - checkBulkStart() { - const hasKeyedFolder = this.state.params.some(p => p.type === 'folder' && p.enabled && p.key && p.key.trim()) - || (this.state.bodyType === 'form-data' && this.state.bodyData.some(p => p.type === 'folder' && p.enabled && p.key && p.key.trim())); - - const hasKeyedList = this.state.params.some(p => p.type === 'list' && p.enabled && p.key && p.key.trim()) - || (this.state.bodyType === 'form-data' && this.state.bodyData.some(p => p.type === 'list' && p.enabled && p.key && p.key.trim())) - || this.state.headers.some(h => h.type === 'list' && h.enabled && h.key && h.key.trim()); - - return hasKeyedFolder || hasKeyedList; - }, - - getStatusColor(code) { - if (code >= 200 && code < 300) return 'var(--success)'; - if (code >= 300 && code < 400) return 'var(--warning)'; - if (code >= 400 || code === 'ERR') return 'var(--danger)'; - return 'var(--text-muted)'; - }, - - toast(msg, type = 'info') { - const t = document.createElement('div'); - t.innerText = msg; - t.style.cssText = ` - background: ${type === 'error' ? '#EF4444' : '#333'}; - color: white; padding: 10px 20px; border-radius: 6px; margin-top: 10px; - box-shadow: 0 4px 12px rgba(0,0,0,0.5); font-size: 13px; - `; - this.dom.toast.appendChild(t); - setTimeout(() => t.remove(), 3000); - }, - - escapeHTML(str) { - if (!str) return ''; - if (typeof str !== 'string') return String(str); - return str.replace(/&/g, '&') - .replace(//g, '>') - .replace(/"/g, '"') - .replace(/'/g, '''); - }, - - hexToBase64(hexString) { - if (!hexString) return ''; - // Strip any whitespace or non-hex chars - hexString = hexString.replace(/[^0-9a-fA-F]/g, ''); - const len = hexString.length; - const bytes = new Uint8Array(len / 2); - for (let i = 0; i < len; i += 2) { - bytes[i / 2] = parseInt(hexString.substr(i, 2), 16); - } - let binary = ''; - const chunk = 8192; - for (let i = 0; i < bytes.length; i += chunk) { - const subarr = bytes.subarray(i, i + chunk); - binary += String.fromCharCode.apply(null, subarr); - } - return btoa(binary); - }, - - bindEvents() { - // Most events are inline (onclick, onchange) for simplicity in this structure - }, - - // Preview a result - previewResult(index) { - const result = this.state.bulk.results.find(r => r.index === index); - if (!result) return; - - const isImage = (result.contentType || '').toLowerCase().includes('image') && result.binaryData; - const finalFilename = this.getFinalFilename(result); - - let contentHTML = ''; - if (isImage) { - try { - const base64Data = this.hexToBase64(result.binaryData); - contentHTML = `${finalFilename}`; - } catch (e) { - contentHTML = ``; - } - } else { - let prettyContent = result.fullContent || ''; - try { - if (prettyContent.trim().startsWith('{')) { - prettyContent = JSON.stringify(JSON.parse(prettyContent), null, 2); - } - } catch(e) {} - contentHTML = ``; - } - - const modal = document.createElement('div'); - modal.className = 'premium-modal-overlay'; - - modal.innerHTML = ` -
-
-
- -
- ${finalFilename} - Result #${result.index} -
-
-
- ${result.status} - ${result.latency}ms - -
-
-
- ${contentHTML} -
- -
- `; - - document.body.appendChild(modal); - modal.onclick = () => modal.remove(); - }, - - // For manual clicking from history - loadHistoryItem(id) { - const item = this.state.history.find(h => h.id === id); - if (item) { - this.state.method = item.method; - this.state.url = item.url; - this.saveState(); - this.render(); - } - } -}; - - -document.addEventListener('DOMContentLoaded', () => App.init()); - diff --git a/web/bulk-api-tester/static/js/app.js.bak_stats_fix b/web/bulk-api-tester/static/js/app.js.bak_stats_fix deleted file mode 100644 index 69eb3e2..0000000 --- a/web/bulk-api-tester/static/js/app.js.bak_stats_fix +++ /dev/null @@ -1,2767 +0,0 @@ -/** - * Phoenix App - Advanced Bulk API Tester - * Version: 2.0 (Agentic Edition) - */ - -const App = { - _stateData: { - spaces: [], - activeSpaceId: null, - activeCollectionId: 'default', - - outputFolderPath: '', - gridMaximized: false, - resultsPanelHeight: 300, - sidebarWidth: 270, - searchQuery: '' - }, - - tabs: [], - activeTabIndex: 0, - - get state() { - if (!this._proxyState) { - const props = ['name', 'method', 'url', 'params', 'headers', 'auth', 'bodyType', 'bodyData', 'jsonBody', 'response', 'bulk', 'activeTab', 'responseTab', 'activeRequestId', 'isPreview', 'activeCollectionId']; - this._proxyState = new Proxy(this._stateData, { - get(target, prop) { - if (props.includes(prop)) { - if (App.tabs && App.tabs[App.activeTabIndex]) { - return App.tabs[App.activeTabIndex][prop]; - } - } - return target[prop]; - }, - set(target, prop, value) { - if (props.includes(prop)) { - if (App.tabs && App.tabs[App.activeTabIndex]) { - App.tabs[App.activeTabIndex][prop] = value; - if (prop !== 'activeTab' && prop !== 'responseTab' && prop !== 'activeRequestId') { - App.tabs[App.activeTabIndex].isPreview = false; - } - - // Auto-save logic - const autoSaveProps = ['name', 'method', 'url', 'params', 'headers', 'auth', 'bodyType', 'bodyData', 'jsonBody', 'bulk']; - if (autoSaveProps.includes(prop) && App.tabs[App.activeTabIndex].activeRequestId) { - if (App.debouncedSaveToCollection) { - App.debouncedSaveToCollection(); - } - } - - return true; - } - } - target[prop] = value; - return true; - } - }); - } - return this._proxyState; - }, - - debouncedSaveToCollection() { - if (this._autoSaveTimeout) clearTimeout(this._autoSaveTimeout); - this._autoSaveTimeout = setTimeout(() => { - this.saveToCollection(); - }, 500); - }, - - createNewTab(reqData, isPreview = false) { - return { - id: 'tab_' + Date.now() + Math.random().toString(36).substr(2, 9), - name: reqData ? reqData.name : 'Untitled Request', - method: reqData ? reqData.method : 'POST', - url: reqData ? reqData.url : '', - params: reqData ? JSON.parse(JSON.stringify(reqData.params || [])) : [], - headers: reqData ? JSON.parse(JSON.stringify(reqData.headers || [])) : [], - auth: reqData ? JSON.parse(JSON.stringify(reqData.auth || {type:'none'})) : {type:'none'}, - bodyType: reqData ? reqData.bodyType : 'none', - bodyData: reqData ? JSON.parse(JSON.stringify(reqData.bodyData || [])) : [], - jsonBody: reqData ? reqData.jsonBody : '', - response: null, - bulk: reqData && reqData.bulk ? JSON.parse(JSON.stringify(reqData.bulk)) : { - strategy: 'consecutive', - running: false, - total: 0, - completed: 0, - success: 0, - error: 0, - concurrency: 1, - delay: 0, - repetitions: 10, - results: [] - }, - activeTab: 'params', - responseTab: 'response', - activeRequestId: reqData ? reqData.id : null, - activeCollectionId: reqData ? reqData.activeCollectionId : 'default', - isPreview: isPreview - }; - }, - - - fileStore: new Map(), // id -> FileList - - dom: {}, - - async init() { - this.loadState(); - this.cacheDOM(); - this.bindEvents(); - - // Ensure active tab has at least one param and header row - if (!this.state.params || this.state.params.length === 0) this.addParam('params'); - if (!this.state.headers || this.state.headers.length === 0) this.addParam('headers'); - - // Load spaces from the server to keep them synced - await this.loadSpacesFromServer(); - - // Load the last run results/response from the server - await this.loadLastRunFromServer(); - - // Apply saved sidebar width - const sidebarEl = document.getElementById('sidebar'); - if (sidebarEl && this._stateData.sidebarWidth) { - sidebarEl.style.width = `${this._stateData.sidebarWidth}px`; - } - - // Attach event listener for horizontal sidebar dragging - const handle = document.getElementById('sidebar-resize-handle'); - if (handle) { - handle.addEventListener('mousedown', (e) => this.startSidebarResize(e)); - } - - this.render(); - - // Remove loader - const loader = document.getElementById('loading-overlay'); - if (loader) loader.remove(); - document.getElementById('app-root').style.visibility = 'visible'; - }, - - // --- Tab Management --- - - openNewTab() { - const newTab = this.createNewTab(); - this.tabs.push(newTab); - this.activeTabIndex = this.tabs.length - 1; - if (!this.state.params || this.state.params.length === 0) this.addParam('params'); - if (!this.state.headers || this.state.headers.length === 0) this.addParam('headers'); - this.saveState(); - this.render(); - }, - - switchTab(index) { - if (index < 0 || index >= this.tabs.length) return; - this.activeTabIndex = index; - this.saveState(); - this.render(); - }, - - closeTab(index) { - if (this.tabs.length <= 1) { - // Can't close last tab; just reset it - this.tabs[0] = this.createNewTab(); - this.activeTabIndex = 0; - this.saveState(); - this.render(); - return; - } - this.tabs.splice(index, 1); - if (this.activeTabIndex >= this.tabs.length) { - this.activeTabIndex = this.tabs.length - 1; - } - this.saveState(); - this.render(); - }, - - cacheDOM() { - this.dom = { - mainPanel: document.getElementById('main-panel'), - sidebar: document.getElementById('sidebar'), - toast: document.getElementById('toast-container') - }; - - if (!this.dom.sidebar || !this.dom.mainPanel) { - console.error('Critical: DOM elements not found', this.dom); - alert('Critical Error: Application DOM structure is missing. Please refresh.'); - } - }, - - // --- State Management --- - - loadState() { - try { - const raw = localStorage.getItem('phoenix-state-v2'); - if (raw) { - const data = JSON.parse(raw); - // Restore _stateData (global state) - if (data.spaces !== undefined) this._stateData.spaces = data.spaces; - if (data.activeSpaceId !== undefined) this._stateData.activeSpaceId = data.activeSpaceId; - if (data.activeCollectionId !== undefined) this._stateData.activeCollectionId = data.activeCollectionId; - if (data.outputFolderPath !== undefined) this._stateData.outputFolderPath = data.outputFolderPath; - if (data.gridMaximized !== undefined) this._stateData.gridMaximized = data.gridMaximized; - if (data.resultsPanelHeight !== undefined) this._stateData.resultsPanelHeight = data.resultsPanelHeight; - if (data.sidebarWidth !== undefined) this._stateData.sidebarWidth = data.sidebarWidth; - if (data.searchQuery !== undefined) this._stateData.searchQuery = data.searchQuery; - - // Restore tabs - if (data.tabs && data.tabs.length > 0) { - this.tabs = data.tabs.map(t => ({ - ...t, - bulk: { ...(t.bulk || {}), running: false, results: [] }, - response: null - })); - this.activeTabIndex = Math.min(data.activeTabIndex || 0, this.tabs.length - 1); - } else { - // No saved tabs, create a blank one - this.tabs = [this.createNewTab()]; - this.activeTabIndex = 0; - } - } else { - // Fresh start - this.tabs = [this.createNewTab()]; - this.activeTabIndex = 0; - } - } catch (e) { - console.warn('Failed to load state', e); - this.tabs = [this.createNewTab()]; - this.activeTabIndex = 0; - } - }, - - saveState() { - try { - const serializedTabs = this.tabs.map(t => ({ - ...t, - bulk: { ...t.bulk, running: false, results: [] }, - response: null - })); - const persistentState = { - spaces: this._stateData.spaces, - activeSpaceId: this._stateData.activeSpaceId, - activeCollectionId: this._stateData.activeCollectionId, - outputFolderPath: this._stateData.outputFolderPath, - gridMaximized: this._stateData.gridMaximized, - resultsPanelHeight: this._stateData.resultsPanelHeight, - sidebarWidth: this._stateData.sidebarWidth, - searchQuery: this._stateData.searchQuery, - tabs: serializedTabs, - activeTabIndex: this.activeTabIndex - }; - localStorage.setItem('phoenix-state-v2', JSON.stringify(persistentState)); - } catch (e) { - console.warn('Failed to save state', e); - } - }, - - async loadLastRunFromServer() { - try { - const res = await fetch('/api/last-run'); - if (res.ok) { - const data = await res.json(); - if (data) { - if (data.bulk) { - this.state.bulk = { ...this.state.bulk, ...data.bulk, running: false }; - } - if (data.response !== undefined) { - this.state.response = data.response; - } - if (data.responseTab) { - this.state.responseTab = data.responseTab; - } - } - } - } catch (e) { - console.error('Failed to load last run from server', e); - } - }, - - async saveLastRunToServer() { - try { - const payload = { - bulk: { ...this.state.bulk, running: false }, - response: this.state.response, - responseTab: this.state.responseTab - }; - await fetch('/api/last-run', { - method: 'POST', - headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify(payload) - }); - } catch (e) { - console.error('Failed to save last run to server', e); - } - }, - - saveLastRunToServerThrottled() { - if (this._saveThrottleTimeout) return; - this._saveThrottleTimeout = setTimeout(async () => { - this._saveThrottleTimeout = null; - await this.saveLastRunToServer(); - }, 1000); - }, - - get collections() { - if (!this.state.activeSpaceId) return []; - const space = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - return space ? space.collections : []; - }, - - set collections(val) { - if (!this.state.activeSpaceId) return; - const space = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - if (space) { - space.collections = val; - } - }, - - get notifications() { - if (!this.state.activeSpaceId) return []; - const space = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - return space ? (space.notifications || []) : []; - }, - - set notifications(val) { - if (!this.state.activeSpaceId) return; - const space = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - if (space) { - space.notifications = val; - } - }, - - async loadSpacesFromServer() { - try { - const res = await fetch('/api/spaces'); - const data = await res.json(); - if (Array.isArray(data)) { - // Check if server returned empty or only the default empty spaces - const serverIsEmpty = data.length === 0 || ( - data.length === 2 && - data[0].id === 'personal' && data[0].collections.length === 1 && (!data[0].collections[0].requests || data[0].collections[0].requests.length === 0) && - data[1].id === 'team' && data[1].collections.length === 1 && (!data[1].collections[0].requests || data[1].collections[0].requests.length === 0) - ); - - // Check if client had non-empty legacy collections in localStorage - const clientHasLegacyCollections = this.state.collections && ( - this.state.collections.length > 1 || - (this.state.collections[0] && this.state.collections[0].requests && this.state.collections[0].requests.length > 0) - ); - - if (serverIsEmpty && clientHasLegacyCollections) { - console.log('Migrating local client collections to spaces...'); - this.state.spaces = [ - { - id: 'personal', - name: 'Personal Space', - collections: JSON.parse(JSON.stringify(this.state.collections)) - }, - { - id: 'team', - name: 'Team Space', - collections: JSON.parse(JSON.stringify(this.state.collections)) - } - ]; - delete this.state.collections; - await this.saveSpacesToServer(); - } else if (data.length === 0 && this.state.spaces && this.state.spaces.length > 0) { - await this.saveSpacesToServer(); - } else if (data.length > 0) { - this.state.spaces = data; - } - - // Validate activeSpaceId - if (this.state.activeSpaceId) { - const spaceExists = this.state.spaces.some(s => s.id === this.state.activeSpaceId); - if (!spaceExists) { - this.state.activeSpaceId = null; - this.state.activeCollectionId = 'default'; - this.state.activeRequestId = null; - } - } - } - } catch (e) { - console.error('Failed to load spaces from server:', e); - } - }, - - async saveSpacesToServer() { - try { - await fetch('/api/spaces', { - method: 'POST', - headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify(this.state.spaces) - }); - } catch (e) { - console.error('Failed to sync spaces with server:', e); - } - }, - - openSpace(spaceId) { - this.state.activeSpaceId = spaceId; - this.state.activeCollectionId = 'default'; - this.state.activeRequestId = null; - this.saveState(); - this.render(); - }, - - showSpacesDashboard() { - this.state.activeSpaceId = null; - this.state.activeCollectionId = 'default'; - this.state.activeRequestId = null; - this.saveState(); - this.render(); - }, - - async createSpace() { - const name = prompt("Enter space name:"); - if (name && name.trim()) { - const id = 'space_' + Date.now(); - this.state.spaces.push({ - id: id, - name: name.trim(), - collections: [{ id: 'default', name: 'My Requests', requests: [] }] - }); - this.state.activeSpaceId = id; - this.saveState(); - await this.saveSpacesToServer(); - this.render(); - } - }, - - async deleteSpace(spaceId) { - if (this.state.spaces.length <= 1) { - return this.toast("Cannot delete the last remaining space", "error"); - } - if (confirm("Are you sure you want to delete this space? All collections and requests inside it will be permanently lost.")) { - this.state.spaces = this.state.spaces.filter(s => s.id !== spaceId); - if (this.state.activeSpaceId === spaceId) { - this.state.activeSpaceId = null; - this.state.activeCollectionId = 'default'; - this.state.activeRequestId = null; - } - this.saveState(); - await this.saveSpacesToServer(); - this.render(); - } - }, - - renameSpace(spaceId) { - const space = this.state.spaces.find(s => s.id === spaceId); - if (!space) return; - const newName = prompt("Enter new workspace name:", space.name); - if (newName && newName.trim()) { - space.name = newName.trim(); - this.saveState(); - this.saveSpacesToServer(); - this.render(); - } - }, - - async setSpaceTheme(themeId) { - const activeSpace = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - if (activeSpace) { - activeSpace.theme = themeId; - this.saveState(); - await this.saveSpacesToServer(); - this.render(); - this.toast(`Applied ${themeId} theme to ${activeSpace.name}`); - } - }, - - async shareCollection(colId) { - const otherSpaces = this.state.spaces.filter(s => s.id !== this.state.activeSpaceId); - if (otherSpaces.length === 0) { - return this.toast("No other spaces to share with", "warning"); - } - - const activeSpace = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - const collection = this.collections.find(c => c.id === colId); - if (!collection) return; - - const spacesList = otherSpaces.map((s, idx) => `${idx + 1}. ${s.name}`).join('\n'); - const choice = prompt(`Select workspace to share "${collection.name}" with (enter number):\n${spacesList}`); - if (choice) { - const idx = parseInt(choice) - 1; - if (idx >= 0 && idx < otherSpaces.length) { - const targetSpace = otherSpaces[idx]; - targetSpace.notifications = targetSpace.notifications || []; - - const alreadyShared = targetSpace.notifications.some(n => n.collection.id === colId && n.fromSpaceId === this.state.activeSpaceId); - if (alreadyShared) { - return this.toast("Already shared with this space, pending approval", "warning"); - } - - targetSpace.notifications.push({ - id: 'share_' + Date.now(), - fromSpaceId: this.state.activeSpaceId, - fromSpaceName: activeSpace ? activeSpace.name : 'Unknown Space', - collection: JSON.parse(JSON.stringify(collection)) - }); - - this.saveState(); - await this.saveSpacesToServer(); - this.toast(`Shared collection with ${targetSpace.name}!`); - this.render(); - } else { - this.toast("Invalid selection", "error"); - } - } - }, - - openNotificationsModal() { - const activeSpace = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - if (!activeSpace || !activeSpace.notifications || activeSpace.notifications.length === 0) return; - - const modal = document.createElement('div'); - modal.className = 'premium-modal-overlay'; - modal.id = 'notifications-modal'; - - const listHTML = activeSpace.notifications.map(n => ` -
-
- -
-
${this.escapeHTML(n.fromSpaceName)} shared collection:
-
${this.escapeHTML(n.collection.name)}
- ${n.collection.requests ? n.collection.requests.length : 0} Requests -
-
-
- - -
-
- `).join(''); - - modal.innerHTML = ` -
-
-

Share Requests

- -
-
- ${listHTML} -
- -
- `; - document.body.appendChild(modal); - modal.onclick = (e) => { if (e.target === modal) modal.remove(); }; - }, - - async approveShare(notifId) { - const activeSpace = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - if (!activeSpace || !activeSpace.notifications) return; - - const idx = activeSpace.notifications.findIndex(n => n.id === notifId); - if (idx >= 0) { - const notif = activeSpace.notifications[idx]; - const collection = notif.collection; - - let newName = collection.name; - let counter = 1; - while (activeSpace.collections.some(c => c.name === newName)) { - newName = `${collection.name} (${counter++})`; - } - collection.name = newName; - collection.id = 'col_' + Date.now(); - - activeSpace.collections.push(collection); - activeSpace.notifications.splice(idx, 1); - - this.saveState(); - await this.saveSpacesToServer(); - this.toast("Collection approved and added!"); - this.render(); - } - }, - - async rejectShare(notifId) { - const activeSpace = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - if (!activeSpace || !activeSpace.notifications) return; - - const idx = activeSpace.notifications.findIndex(n => n.id === notifId); - if (idx >= 0) { - activeSpace.notifications.splice(idx, 1); - this.saveState(); - await this.saveSpacesToServer(); - this.toast("Share request rejected"); - this.render(); - } - }, - - startSidebarResize(e) { - e.preventDefault(); - document.body.classList.add('resizing'); - const startX = e.clientX; - const startWidth = this.state.sidebarWidth || 270; - const handle = document.getElementById('sidebar-resize-handle'); - if (handle) handle.classList.add('active'); - - const doDrag = (moveEvent) => { - const deltaX = moveEvent.clientX - startX; - const newWidth = Math.max(180, Math.min(600, startWidth + deltaX)); - this.state.sidebarWidth = newWidth; - const sidebarEl = document.getElementById('sidebar'); - if (sidebarEl) { - sidebarEl.style.width = `${newWidth}px`; - } - }; - - const stopDrag = () => { - document.body.classList.remove('resizing'); - document.removeEventListener('mousemove', doDrag); - document.removeEventListener('mouseup', stopDrag); - if (handle) handle.classList.remove('active'); - this.saveState(); - }; - - document.addEventListener('mousemove', doDrag); - document.addEventListener('mouseup', stopDrag); - }, - - async resendBulkRequest(resultIndex) { - const index = resultIndex - 1; // 0-based index - const bulk = this.state.bulk; - const resultItem = bulk.results.find(r => r.index === resultIndex); - if (!resultItem) return; - - this.toast(`Re-sending request #${resultIndex}...`, 'info'); - - // Recalculate maxFiles and maxList to determine fileIndex and listIndex 1-to-1 - let maxFiles = 0; - let maxList = 0; - - const folders = [ - ...this.state.params.filter(p => p.type === 'folder' && p.enabled && p.key && p.key.trim()), - ...(this.state.bodyType === 'form-data' ? this.state.bodyData.filter(p => p.type === 'folder' && p.enabled && p.key && p.key.trim()) : []) - ]; - if (folders.length > 0) { - for (const f of folders) { - const files = this.fileStore.get(f.id); - if (files && files.length > maxFiles) maxFiles = files.length; - } - } - - const allLists = [ - ...this.state.params.filter(p => p.type === 'list' && p.enabled && p.key && p.key.trim()), - ...(this.state.bodyType === 'form-data' ? this.state.bodyData.filter(p => p.type === 'list' && p.enabled && p.key && p.key.trim()) : []), - ...this.state.headers.filter(h => h.type === 'list' && h.enabled && h.key && h.key.trim()) - ]; - if (allLists.length > 0) { - for (const listParam of allLists) { - const val = listParam.value || ''; - const arr = val.split(/[\n,]+/).map(s => s.trim()).filter(s => s); - if (arr.length > maxList) maxList = arr.length; - } - } - - let fileIndex = index; - let listIndex = index; - if (bulk.strategy === 'cartesian' && maxFiles > 0 && maxList > 0) { - fileIndex = Math.floor(index / maxList); - listIndex = index % maxList; - } - - try { - const res = await this.executeRequest(index, fileIndex, listIndex); - const isSuccess = res.status_code >= 200 && res.status_code < 300; - - // Adjust stats counters - const wasSuccess = resultItem.status >= 200 && resultItem.status < 300; - if (wasSuccess && !isSuccess) { - bulk.success--; - bulk.error++; - } else if (!wasSuccess && isSuccess) { - bulk.success++; - bulk.error--; - } - - // Update item details - resultItem.status = res.status_code; - resultItem.latency = res.latency || 0; - resultItem.data = res.content ? res.content.substring(0, 100) : (res.binary_data ? '[Binary]' : ''); - resultItem.fullContent = res.content; - resultItem.binaryData = res.binary_data; - resultItem.contentType = res.content_type; - resultItem.headers = res.headers; - - this.toast(`Request #${resultIndex} completed: ${res.status_code}`, isSuccess ? 'info' : 'error'); - this.updateBulkProgressUI(); - await this.saveLastRunToServer(); - } catch (e) { - const wasSuccess = resultItem.status >= 200 && resultItem.status < 300; - if (wasSuccess) { - bulk.success--; - bulk.error++; - } - resultItem.status = 'ERR'; - resultItem.latency = 0; - resultItem.data = e.message; - this.toast(`Request #${resultIndex} failed: ${e.message}`, 'error'); - this.updateBulkProgressUI(); - await this.saveLastRunToServer(); - } - }, - - startResultsResize(e) { - e.preventDefault(); - document.body.classList.add('resizing'); - const startY = e.clientY; - const startHeight = this.state.resultsPanelHeight || 300; - - const doDrag = (moveEvent) => { - const deltaY = startY - moveEvent.clientY; - const newHeight = Math.max(120, Math.min(800, startHeight + deltaY)); - this.state.resultsPanelHeight = newHeight; - const panel = document.querySelector('.bottom-results-panel'); - if (panel) { - panel.style.height = `${newHeight}px`; - } - }; - - const stopDrag = () => { - document.body.classList.remove('resizing'); - document.removeEventListener('mousemove', doDrag); - document.removeEventListener('mouseup', stopDrag); - this.saveState(); - }; - - document.addEventListener('mousemove', doDrag); - document.addEventListener('mouseup', stopDrag); - }, - - appendResultCardToDOM(result) { - const cardHTML = this.renderResultCard(result); - - const appendToGrid = (selector) => { - const grid = document.querySelector(selector); - if (!grid) return; - - const spinner = grid.querySelector('div[style*="fa-spinner"]'); - if (spinner) spinner.remove(); - - const tmp = document.createElement('div'); - tmp.innerHTML = cardHTML; - const newElement = tmp.firstElementChild; - grid.appendChild(newElement); - - while (grid.children.length > 1000) { - grid.removeChild(grid.firstElementChild); - } - }; - - appendToGrid('.results-grid'); - appendToGrid('.fullscreen-results-grid'); - }, - - updateBulkProgressUI() { - if (this._rafPending) return; - this._rafPending = true; - requestAnimationFrame(() => { - this._rafPending = false; - const bulk = this.state.bulk; - const pct = bulk.total > 0 ? (bulk.completed / bulk.total) * 100 : 0; - const statusColor = bulk.error > 0 ? (bulk.success > 0 ? 'var(--warning)' : 'var(--danger)') : 'var(--success)'; - - const bar = document.getElementById('progress-bar-fill'); - if (bar) { bar.style.width = `${pct}%`; bar.style.background = statusColor; } - - const text = document.getElementById('progress-text'); - if (text) text.innerText = `${bulk.completed} / ${bulk.total} Completed`; - - const successStat = document.querySelector('.stat-capsule.success'); - if (successStat) successStat.innerText = `${bulk.success} Success`; - const errorStat = document.querySelector('.stat-capsule.error'); - if (errorStat) errorStat.innerText = `${bulk.error} Failed`; - - // Throttle server saves - this.saveLastRunToServerThrottled(); - }); - }, - - - openFullscreenResults() { - const bulk = this.state.bulk; - if (bulk.results.length === 0 && !bulk.running) { - return this.toast("No results to view in fullscreen", "warning"); - } - - let modal = document.getElementById('fullscreen-results-overlay'); - const pct = bulk.total > 0 ? (bulk.completed / bulk.total) * 100 : 0; - const statusColor = bulk.error > 0 ? (bulk.success > 0 ? 'var(--warning)' : 'var(--danger)') : 'var(--success)'; - const cardsHTML = bulk.results.slice(-200).map(r => this.renderResultCard(r)).join(''); - const folderPath = this.state.outputFolderPath || 'None selected'; - - const contentHTML = ` -
-
- -
-

Fullscreen Batch Processing Grid

-

Real-time execution monitoring and visual results

-
-
- ${bulk.completed} / ${bulk.total} Completed - ${bulk.success} Success - ${bulk.error} Failed -
-
- -
-
- - ${folderPath} - - - -
- - - - -
-
- -
-
-
- -
- ${cardsHTML || `
Executing batch requests, processing results...
`} -
- `; - - if (!modal) { - modal = document.createElement('div'); - modal.className = 'fullscreen-results-overlay'; - modal.id = 'fullscreen-results-overlay'; - modal.innerHTML = contentHTML; - document.body.appendChild(modal); - } else { - modal.innerHTML = contentHTML; - } - }, - - closeFullscreenResults() { - const modal = document.getElementById('fullscreen-results-overlay'); - if (modal) { - modal.remove(); - } - }, - - async browseServerFolder() { - try { - const res = await fetch('/api/browse_folder', { - method: 'POST' - }); - const data = await res.json(); - if (data.success) { - this.state.outputFolderPath = data.path; - this.saveState(); - this.render(); - this.toast(`Folder selected: ${data.path}`); - } else { - this.toast(data.error || 'Failed to browse folder', 'error'); - } - } catch (e) { - this.toast(`Error browsing folder: ${e.message}`, 'error'); - } - }, - - async saveToServerFolder() { - if (!this.state.bulk.results.length) return this.toast('No results to save', 'error'); - if (!this.state.outputFolderPath) { - this.toast('Please select an output folder first', 'error'); - await this.browseServerFolder(); - if (!this.state.outputFolderPath) return; - } - - try { - this.toast('Saving files to server folder...', 'info'); - - // First ensure the latest run is persisted on the server - await this.saveLastRunToServer(); - - // Ask the server to save from its own copy (avoids sending huge binary payloads) - const res = await fetch('/api/save_folder_from_lastrun', { - method: 'POST', - headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ path: this.state.outputFolderPath }) - }); - - const data = await res.json(); - if (data.success) { - const errMsg = data.errors && data.errors.length > 0 ? ` (${data.errors.length} errors)` : ''; - this.toast(`Saved ${data.count} files to ${this.state.outputFolderPath}${errMsg}`); - if (data.errors && data.errors.length > 0) { - console.warn('Save errors:', data.errors); - } - } else { - this.toast(`Failed to save: ${data.error}`, 'error'); - } - } catch (e) { - this.toast(`Error saving to folder: ${e.message}`, 'error'); - } - }, - - async saveIndividualToServerFolder(index) { - const result = this.state.bulk.results.find(r => r.index === index); - if (!result) return; - - if (!this.state.outputFolderPath) { - this.toast('Please select an output folder first', 'error'); - await this.browseServerFolder(); - if (!this.state.outputFolderPath) return; - } - - try { - // Ensure server has latest run data - await this.saveLastRunToServer(); - - const res = await fetch('/api/save_folder_from_lastrun', { - method: 'POST', - headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ - path: this.state.outputFolderPath, - indices: [index] - }) - }); - - const data = await res.json(); - if (data.success && data.count > 0) { - this.toast(`Saved file #${index} to server folder`); - } else { - this.toast(`Failed to save: ${data.error || (data.errors && data.errors[0]) || 'Unknown error'}`, 'error'); - } - } catch (e) { - this.toast(`Error saving file: ${e.message}`, 'error'); - } - }, - - downloadIndividualResult(index) { - const result = this.state.bulk.results.find(r => r.index === index); - if (!result) return; - - try { - const finalFilename = this.getFinalFilename(result); - let blob; - - if (result.binaryData) { - const bytes = new Uint8Array(result.binaryData.match(/.{1,2}/g).map(byte => parseInt(byte, 16))); - blob = new Blob([bytes], { type: result.contentType || 'application/octet-stream' }); - } else if (result.fullContent) { - blob = new Blob([result.fullContent], { type: result.contentType || 'text/plain' }); - } else { - return this.toast('No content to download', 'error'); - } - - const url = URL.createObjectURL(blob); - const a = document.createElement('a'); - a.href = url; - a.download = finalFilename; - document.body.appendChild(a); - a.click(); - document.body.removeChild(a); - URL.revokeObjectURL(url); - - this.toast(`Downloaded "${finalFilename}"`); - } catch (e) { - this.toast(`Download failed: ${e.message}`, 'error'); - } - }, - - clearBulkResults() { - if (confirm("Are you sure you want to clear all batch results?")) { - this.state.bulk.results = []; - this.state.bulk.completed = 0; - this.state.bulk.success = 0; - this.state.bulk.error = 0; - this.state.bulk.total = 0; - this.state.bulk.running = false; - this.saveState(); - this.saveLastRunToServer(); - this.render(); - } - }, - - toggleGridMaximized() { - this.state.gridMaximized = !this.state.gridMaximized; - this.render(); - }, - - // --- Actions --- - - addParam(section) { - const item = { id: Date.now().toString() + Math.random(), key: '', value: '', type: 'text', enabled: true }; - if (section === 'params') this.state.params.push(item); - if (section === 'headers') this.state.headers.push(item); - if (section === 'body') this.state.bodyData.push(item); - this.render(); - this.saveState(); - }, - - removeParam(section, id) { - if (section === 'params') this.state.params = this.state.params.filter(p => p.id !== id); - if (section === 'headers') this.state.headers = this.state.headers.filter(p => p.id !== id); - if (section === 'body') this.state.bodyData = this.state.bodyData.filter(p => p.id !== id); - this.render(); - this.saveState(); - }, - - updateParam(section, id, field, value) { - const list = section === 'params' ? this.state.params : (section === 'headers' ? this.state.headers : this.state.bodyData); - const item = list.find(p => p.id === id); - if (item) { - item[field] = value; - this.saveState(); - // Re-render if type changes to show/hide file input - if (field === 'type' || field === 'enabled') this.render(); - } - }, - - // --- Request Execution --- - - async sendRequest() { - if (!this.state.url) return this.toast('URL is required', 'error'); - - // Reset bulk results upon sending another single request - this.state.bulk.results = []; - this.state.bulk.completed = 0; - this.state.bulk.success = 0; - this.state.bulk.error = 0; - this.state.bulk.total = 0; - - this.state.response = { status: 'Sending...', headers: {} }; - this.state.responseTab = 'response'; // Switch view - this.render(); - this.saveLastRunToServerThrottled(); - - try { - const start = Date.now(); - const res = await this.executeRequest(0); - const latency = Date.now() - start; - - res.latency = latency; - this.state.response = res; - this.saveToCollection(res.status_code || 500); - } catch (e) { - this.state.response = { error: e.message }; - } - - this.render(); - this.saveState(); - await this.saveLastRunToServer(); - }, - - // --- Bulk Execution --- - - async runBulk() { - if (!this.state.url) return this.toast('URL is required', 'error'); - - // Calculate total items based on folders or lists - let maxFiles = 0; - let maxList = 0; - const currentRunId = Date.now(); - this.state.bulk.currentRunId = currentRunId; - - // Check folders first - only those that will actually be used - const folders = [ - ...this.state.params.filter(p => p.type === 'folder' && p.enabled && p.key && p.key.trim()), - ...(this.state.bodyType === 'form-data' ? this.state.bodyData.filter(p => p.type === 'folder' && p.enabled && p.key && p.key.trim()) : []) - ]; - - if (folders.length > 0) { - // Find max file count - for (const f of folders) { - const files = this.fileStore.get(f.id); - if (files && files.length > maxFiles) maxFiles = files.length; - } - } - - // Check lists (params, body, headers) - only those with keys - const allLists = [ - ...this.state.params.filter(p => p.type === 'list' && p.enabled && p.key && p.key.trim()), - ...(this.state.bodyType === 'form-data' ? this.state.bodyData.filter(p => p.type === 'list' && p.enabled && p.key && p.key.trim()) : []), - ...this.state.headers.filter(h => h.type === 'list' && h.enabled && h.key && h.key.trim()) - ]; - - if (allLists.length > 0) { - // Find the longest list - for (const listParam of allLists) { - const val = listParam.value || ''; - const arr = val.split(/[\n,]+/).map(s => s.trim()).filter(s => s); - if (arr.length > maxList) maxList = arr.length; - } - } - - let total = 0; - if (this.state.bulk.strategy === 'cartesian' && maxFiles > 0 && maxList > 0) { - total = maxFiles * maxList; - } else { - total = Math.max(maxFiles, maxList); - } - - // If still no total, use the saved repetitions setting - if (total === 0) { - total = Math.max(1, parseInt(this.state.bulk.repetitions) || 10); - } - - if (total <= 0) return this.toast('Invalid bulk count', 'error'); - - // Init Bulk State - if (!this.state.bulk.paused) { - this.state.bulk.total = total; - this.state.bulk.completed = 0; - this.state.bulk.success = 0; - this.state.bulk.error = 0; - this.state.bulk.results = []; - this.state.bulk.nextIndex = 0; - this.state.responseTab = 'results'; - } else { - this.state.bulk.total = total; - } - - this.state.bulk.running = true; - this.state.bulk.paused = false; - - this.saveToCollection('BULK'); - this.render(); - - // Execution Queue - const concurrency = Math.max(1, Math.min(20, this.state.bulk.concurrency || 1)); - let active = 0; - - const worker = async () => { - while (this.state.bulk.nextIndex < this.state.bulk.total && this.state.bulk.running && this.state.bulk.currentRunId === currentRunId) { - const index = this.state.bulk.nextIndex++; - active++; - - let fileIndex = index; - let listIndex = index; - if (this.state.bulk.strategy === 'cartesian' && maxFiles > 0 && maxList > 0) { - fileIndex = Math.floor(index / maxList); - listIndex = index % maxList; - } - - const inputFilename = this.getInputFilename(index, fileIndex, listIndex); - - try { - const res = await this.executeRequest(index, fileIndex, listIndex); - - if (this.state.bulk.currentRunId !== currentRunId) return; - - const isSuccess = res.status_code >= 200 && res.status_code < 300; - if (isSuccess) this.state.bulk.success++; else this.state.bulk.error++; - - this.state.bulk.results.push({ - index: index + 1, - status: res.status_code, - latency: res.latency || 0, - data: res.content ? res.content.substring(0, 100) : (res.binary_data ? '[Binary]' : ''), - fullContent: res.content, - binaryData: res.binary_data, - contentType: res.content_type, - headers: res.headers, - inputFilename: inputFilename - }); - - const newResult = this.state.bulk.results[this.state.bulk.results.length - 1]; - this.appendResultCardToDOM(newResult); - if (this.state.bulk.results.length > 1000) this.state.bulk.results.shift(); - - } catch (e) { - if (this.state.bulk.currentRunId !== currentRunId) return; - this.state.bulk.error++; - this.state.bulk.results.push({ - index: index + 1, - status: 'ERR', - latency: 0, - data: e.message, - inputFilename: inputFilename - }); - const errResult = this.state.bulk.results[this.state.bulk.results.length - 1]; - this.appendResultCardToDOM(errResult); - } finally { - active--; - this.state.bulk.completed++; - if (this.state.bulk.currentRunId === currentRunId) { - this.updateBulkProgressUI(); - } - } - - // Apply inter-request delay (only when concurrency = 1 or after each request) - const delayMs = parseInt(this.state.bulk.delay) || 0; - if (delayMs > 0 && this.state.bulk.running && this.state.bulk.currentRunId === currentRunId) { - await new Promise(r => setTimeout(r, delayMs)); - } - } - - if (active === 0 && this.state.bulk.nextIndex >= this.state.bulk.total && this.state.bulk.currentRunId === currentRunId) { - this.state.bulk.running = false; - this.state.bulk.paused = false; - // Sort final results by index before final render - this.state.bulk.results.sort((a, b) => a.index - b.index); - this.render(); - this.toast('Bulk Operation Completed'); - await this.saveLastRunToServer(); - } - }; - - // Spawn workers - for (let i = 0; i < concurrency; i++) { - worker(); - } - }, - - stopBulk() { - this.state.bulk.running = false; - this.state.bulk.paused = false; - this.render(); - }, - - pauseBulk() { - if (this.state.bulk.running) { - this.state.bulk.running = false; - this.state.bulk.paused = true; - this.render(); - this.toast('Bulk Operation Paused', 'warning'); - } - }, - - resumeBulk() { - if (this.state.bulk.paused) { - this.runBulk(); - } - }, - - async getImageDimensions(file) { - return new Promise((resolve) => { - if (!file || !file.type.startsWith('image/')) return resolve({width: 0, height: 0}); - const img = new Image(); - const url = URL.createObjectURL(file); - img.onload = () => { - resolve({width: img.width, height: img.height}); - URL.revokeObjectURL(url); - }; - img.onerror = () => { - resolve({width: 0, height: 0}); - URL.revokeObjectURL(url); - }; - img.src = url; - }); - }, - - async executeRequest(index, fileIndex = index, listIndex = index) { - const start = Date.now(); - // Headers - const headers = {}; - this.state.headers.filter(h => h.enabled && h.key && h.key.trim()).forEach(h => { - // Handle list replacement in headers too - let val = h.value; - if (h.type === 'list') { - const arr = val.split(/[\n,]+/).map(s => s.trim()).filter(s => s); - if (arr.length > 0) val = arr[listIndex % arr.length]; - } - headers[h.key.trim()] = val; - }); - - // Auth - const auth = this.state.auth; - if (auth.type === 'bearer') headers['Authorization'] = `Bearer ${auth.token}`; - else if (auth.type === 'basic') headers['Authorization'] = 'Basic ' + btoa(`${auth.username}:${auth.password}`); - else if (auth.type === 'apikey') headers[auth.key] = auth.value; - - // URL Params - const urlObj = new URL(this.state.url); - this.state.params.filter(p => p.enabled && p.key && p.key.trim()).forEach(p => { - let val = p.value; - // List handling - if (p.type === 'list') { - // Try splitting by newline first if present, else comma - const arr = val.split(/[\n,]+/).map(s => s.trim()).filter(s => s); - if (arr.length > 0) val = arr[listIndex % arr.length]; - } - // File logic not applicable for URL params usually, skipping - urlObj.searchParams.append(p.key, val); - }); - - // Payload Construction - const finalData = new FormData(); - finalData.append('method', this.state.method); - finalData.append('url', urlObj.toString()); - finalData.append('headers', JSON.stringify(headers)); - // Add auth config for server-side handling if needed (e.g. Basic Auth via requests arg) - if (auth.type === 'basic') finalData.append('auth', JSON.stringify({ type: 'basic', username: auth.username, password: auth.password })); - - // Body - if (this.state.bodyType === 'json') { - finalData.append('body_type', 'json'); - finalData.append('body', this.state.jsonBody); - } else if (this.state.bodyType === 'form-data') { - finalData.append('body_type', 'form-data'); - - let currentImageFile = null; - const folderParam = this.state.bodyData.find(p => p.enabled && p.type === 'folder'); - if (folderParam) { - const files = this.fileStore.get(folderParam.id); - if (files && files.length > 0) currentImageFile = files[fileIndex % files.length]; - } - if (!currentImageFile) { - const fileParam = this.state.bodyData.find(p => p.enabled && p.type === 'file'); - if (fileParam) { - const files = this.fileStore.get(fileParam.id); - if (files && files.length > 0) currentImageFile = files[0]; - } - } - let imgDims = null; - - const bodyParams = this.state.bodyData.filter(p => p.enabled && (p.type === 'file' || p.type === 'folder' || p.type === 'auto_width' || p.type === 'auto_height' || (p.key && p.key.trim()))); - for (const p of bodyParams) { - if (p.type === 'file' || p.type === 'folder') { - const files = this.fileStore.get(p.id); - if (files && files.length > 0) { - if (p.type === 'folder') { - finalData.append(p.key, files[fileIndex % files.length]); - } else { - for (let f of files) finalData.append(p.key, f); - } - } - } else if (p.type === 'auto_width' || p.type === 'auto_height') { - if (!imgDims) imgDims = await this.getImageDimensions(currentImageFile); - finalData.append(p.key, p.type === 'auto_width' ? imgDims.width : imgDims.height); - } else { - let val = p.value; - if (p.type === 'list') { - const arr = val.split(/[\n,]+/).map(s => s.trim()).filter(s => s); - if (arr.length > 0) val = arr[listIndex % arr.length]; - } - finalData.append(p.key, val); - } - } - } - - const res = await fetch('/api/proxy-request', { - method: 'POST', - body: finalData - }); - - const data = await res.json(); - data.latency = Date.now() - start; - return data; - }, - - saveToCollection(lastStatus) { - if (!this.state.url) return; - - let targetColId = this.state.activeCollectionId || 'default'; - let col = this.collections.find(c => c.id === targetColId); - if (!col) { - col = this.collections.find(c => c.id === 'default'); - if(!col) { - col = { id: 'default', name: 'My Requests', requests: [] }; - this.collections.push(col); - } - targetColId = col.id; - } - - const existingIdx = col.requests.findIndex(r => r.id === this.state.activeRequestId || (r.url === this.state.url && r.method === this.state.method)); - let existingReq = existingIdx >= 0 ? col.requests[existingIdx] : null; - - const reqData = { - id: this.state.activeRequestId || Date.now().toString(), - name: (existingReq && existingReq.name) ? existingReq.name : (this.state.url.split('?')[0].split('/').pop() || 'Root URL'), - method: this.state.method, - url: this.state.url, - params: JSON.parse(JSON.stringify(this.state.params)), - headers: JSON.parse(JSON.stringify(this.state.headers)), - auth: JSON.parse(JSON.stringify(this.state.auth)), - bodyType: this.state.bodyType, - bodyData: JSON.parse(JSON.stringify(this.state.bodyData)), - jsonBody: this.state.jsonBody, - lastStatus: lastStatus !== undefined ? lastStatus : (existingReq ? existingReq.lastStatus : null), - lastTime: new Date().toLocaleTimeString(), - activeCollectionId: targetColId - }; - - if (existingIdx >= 0) { - // Update existing - reqData.id = existingReq.id; // preserve ID - col.requests[existingIdx] = reqData; - } else { - // Add new - col.requests.unshift(reqData); - } - - this.state.activeRequestId = reqData.id; - this.saveState(); - this.saveSpacesToServer(); - }, - - loadRequest(colId, reqId) { - const col = this.collections.find(c => c.id === colId); - if(!col) return; - const req = col.requests.find(r => r.id === reqId); - if(!req) return; - - // Check if this request is already open in any tab - const existingTabIdx = this.tabs.findIndex(t => t.activeRequestId === reqId); - if (existingTabIdx >= 0) { - // Just switch to that tab - this.activeTabIndex = existingTabIdx; - this.saveState(); - this.render(); - return; - } - - // Postman behavior: if the current tab is a "preview" tab (untouched/empty), reuse it; - // otherwise open a new tab - const currTab = this.tabs[this.activeTabIndex]; - const isUntouched = currTab && ( - (!currTab.url || currTab.url === '') && - (!currTab.activeRequestId) && - (!currTab.response) && - (currTab.name === 'Untitled Request' || !currTab.name) - ); - - const reqTabData = { - id: 'tab_' + Date.now() + Math.random().toString(36).substr(2, 9), - name: req.name || (req.url ? req.url.split('/').pop() || req.url : 'Request'), - method: req.method || 'GET', - url: req.url || '', - params: JSON.parse(JSON.stringify(req.params || [{ id: Date.now().toString(), key: '', value: '', type: 'text', enabled: true }])), - headers: JSON.parse(JSON.stringify(req.headers || [{ id: (Date.now()+1).toString(), key: '', value: '', type: 'text', enabled: true }])), - auth: JSON.parse(JSON.stringify(req.auth || {type:'none'})), - bodyType: req.bodyType || 'none', - bodyData: JSON.parse(JSON.stringify(req.bodyData || [])), - jsonBody: req.jsonBody || '', - response: null, - bulk: { strategy: 'consecutive', running: false, total: 0, completed: 0, success: 0, error: 0, concurrency: 1, results: [] }, - activeTab: 'params', - responseTab: 'response', - activeRequestId: reqId, - activeCollectionId: colId, - isPreview: false - }; - - if (isUntouched) { - // Replace current blank tab - this.tabs[this.activeTabIndex] = reqTabData; - } else { - // Open brand new tab - this.tabs.push(reqTabData); - this.activeTabIndex = this.tabs.length - 1; - } - - this.saveState(); - this.render(); - }, - - deleteRequest(colId, reqId) { - const col = this.collections.find(c => c.id === colId); - if(col) col.requests = col.requests.filter(r => r.id !== reqId); - if(this.state.activeRequestId === reqId) this.state.activeRequestId = null; - this.saveState(); - this.saveSpacesToServer(); - this.render(); - }, - - createCollection() { - const name = prompt("Collection Name:"); - if(name) { - const id = 'col_' + Date.now(); - this.collections.push({ id, name, requests: [] }); - this.state.activeCollectionId = id; - this.saveState(); - this.saveSpacesToServer(); - this.render(); - } - }, - - renameCollection(colId) { - const col = this.collections.find(c => c.id === colId); - if(!col) return; - const newName = prompt("Enter new collection name:", col.name); - if(newName && newName.trim()) { - col.name = newName.trim(); - this.saveState(); - this.saveSpacesToServer(); - this.render(); - } - }, - - renameRequest(colId, reqId) { - const col = this.collections.find(c => c.id === colId); - if(!col) return; - const req = col.requests.find(r => r.id === reqId); - if(!req) return; - const newName = prompt("Enter new request name:", req.name); - if(newName && newName.trim()) { - req.name = newName.trim(); - this.saveState(); - this.saveSpacesToServer(); - this.render(); - } - }, - - deleteCollection(colId) { - if(confirm("Delete this collection and all its requests? This cannot be undone.")) { - this.collections = this.collections.filter(c => c.id !== colId); - // Always keep at least one collection - if (this.collections.length === 0) { - this.collections = [{ id: 'default', name: 'My Requests', requests: [] }]; - } - // If deleted collection was active, switch to first remaining - const stillExists = this.collections.some(c => c.id === this.state.activeCollectionId); - if (!stillExists) { - this.state.activeCollectionId = this.collections[0].id; - this.state.activeRequestId = null; - } - this.saveState(); - this.saveSpacesToServer(); - this.render(); - } - }, - - addRequestToCollection(colId) { - const col = this.collections.find(c => c.id === colId); - if (!col) return; - const reqId = 'req_' + Date.now(); - const newReq = { - id: reqId, - name: 'New Request', - method: 'GET', - url: '', - description: '', - params: [{ id: Date.now().toString() + Math.random(), key: '', value: '', type: 'text', enabled: true }], - headers: [{ id: Date.now().toString() + Math.random(), key: '', value: '', type: 'text', enabled: true }], - auth: { type: 'none' }, - bodyType: 'none', - bodyData: [], - jsonBody: '' - }; - col.requests.push(newReq); - - // Open this new request in a new tab - const reqTabData = { - id: 'tab_' + Date.now() + Math.random().toString(36).substr(2, 9), - name: 'New Request', - method: 'GET', - url: '', - params: JSON.parse(JSON.stringify(newReq.params)), - headers: JSON.parse(JSON.stringify(newReq.headers)), - auth: { type: 'none' }, - bodyType: 'none', - bodyData: [], - jsonBody: '', - response: null, - bulk: { strategy: 'consecutive', running: false, total: 0, completed: 0, success: 0, error: 0, concurrency: 1, results: [] }, - activeTab: 'params', - responseTab: 'response', - activeRequestId: reqId, - activeCollectionId: colId, - isPreview: false - }; - this.tabs.push(reqTabData); - this.activeTabIndex = this.tabs.length - 1; - - this.saveState(); - this.saveSpacesToServer(); - this.render(); - this.toast("Added new request to collection"); - - }, - - updateActiveRequestName(name) { - const activeSpace = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - const col = activeSpace ? activeSpace.collections.find(c => c.id === this.state.activeCollectionId) : null; - const activeReq = col ? col.requests.find(r => r.id === this.state.activeRequestId) : null; - if (activeReq) { - activeReq.name = name.trim() || 'Untitled Request'; - this.saveState(); - this.saveSpacesToServer(); - this.render(); - } - }, - - updateActiveRequestDescription(desc) { - const activeSpace = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - const col = activeSpace ? activeSpace.collections.find(c => c.id === this.state.activeCollectionId) : null; - const activeReq = col ? col.requests.find(r => r.id === this.state.activeRequestId) : null; - if (activeReq) { - activeReq.description = desc; - this.saveState(); - this.saveSpacesToServer(); - } - }, - - downloadHistory() { - if (!this.state.bulk.results.length) return; - - const csvContent = "data:text/csv;charset=utf-8," - + "Index,Status,Latency (ms),Snippet\n" - + this.state.bulk.results.map(r => `${r.index},${r.status},${r.latency},"${(r.data || '').replace(/"/g, '""').replace(/\n/g, ' ')}"`).join("\n"); - - const encodedUri = encodeURI(csvContent); - const link = document.createElement("a"); - link.setAttribute("href", encodedUri); - link.setAttribute("download", `bulk_results_${new Date().toISOString()}.csv`); - document.body.appendChild(link); - link.click(); - document.body.removeChild(link); - }, - - // Get the input filename for a given bulk index - getInputFilename(index, fileIndex = index, listIndex = index) { - // Build list of active params that could provide a name - const activeParams = [ - ...this.state.params.filter(p => p.enabled && p.key && p.key.trim()), - ...(this.state.bodyType === 'form-data' ? this.state.bodyData.filter(p => p.enabled && p.key && p.key.trim()) : []) - ]; - - let folderName = null; - // Priority 1: Folder type (usually high-intent for naming) - const folderParam = activeParams.find(p => p.type === 'folder'); - if (folderParam) { - const files = this.fileStore.get(folderParam.id); - if (files && files.length > 0) { - const file = files[fileIndex % files.length]; - folderName = file.webkitRelativePath || file.name; - } - } - - let listName = null; - // Priority 2: List in Body (user's specific request context) - if (this.state.bodyType === 'form-data') { - const bodyList = this.state.bodyData.find(p => p.type === 'list' && p.enabled && p.key && p.key.trim()); - if (bodyList) { - const arr = bodyList.value.split(/[\n,]+/).map(s => s.trim()).filter(s => s); - if (arr.length > 0) listName = arr[listIndex % arr.length]; - } - } - - // Priority 3: Any other list - if (!listName) { - const listParam = activeParams.find(p => p.type === 'list'); - if (listParam) { - const val = listParam.value || ''; - const arr = val.split(/[\n,]+/).map(s => s.trim()).filter(s => s); - if (arr.length > 0) listName = arr[listIndex % arr.length]; - } - } - - if (folderName && listName) { - // Strip extension from folderName, add listName, re-add extension - let base = folderName; - let ext = ''; - const lastDot = folderName.lastIndexOf('.'); - if (lastDot !== -1 && lastDot > 0 && folderName.length - lastDot <= 6) { - base = folderName.substring(0, lastDot); - ext = folderName.substring(lastDot); - } - // Replace any invalid characters in listName just in case, though usually fine - const safeListName = listName.replace(/[\/\\]/g, '_'); - return `${base}_${safeListName}${ext}`; - } else if (folderName) { - return folderName; - } else if (listName) { - return listName; - } - - return `result_${index + 1}`; - }, - - // Get the final filename with appropriate extension if missing - getFinalFilename(result) { - let name = result.inputFilename || `result_${result.index}`; - let originalExt = ''; - - // Extract existing extension if present - const lastDot = name.lastIndexOf('.'); - if (lastDot > 0 && (name.length - lastDot) <= 6) { - originalExt = name.substring(lastDot); - name = name.substring(0, lastDot); - } - - // Map common content types - const ct = (result.contentType || '').toLowerCase(); - if (ct.includes('image/png')) return name + '.png'; - if (ct.includes('image/jpeg') || ct.includes('image/jpg')) return name + '.jpg'; - if (ct.includes('image/gif')) return name + '.gif'; - if (ct.includes('image/webp')) return name + '.webp'; - if (ct.includes('image/svg')) return name + '.svg'; - if (ct.includes('application/pdf')) return name + '.pdf'; - if (ct.includes('application/json')) return name + '.json'; - if (ct.includes('application/xml') || ct.includes('text/xml')) return name + '.xml'; - if (ct.includes('text/html')) return name + '.html'; - if (ct.includes('text/csv')) return name + '.csv'; - if (ct.includes('text/css')) return name + '.css'; - if (ct.includes('text/plain')) return name + '.txt'; - if (ct.includes('application/zip')) return name + '.zip'; - - // Fallback for other binary types: try to extract subtype - if (result.binaryData && ct.includes('/')) { - const subtype = ct.split('/')[1].split(';')[0]; // handle "type/subtype;charset=..." - if (subtype && subtype.length <= 4 && /^[a-z0-9]+$/.test(subtype)) { - return name + '.' + subtype; - } - } - - // Content sniffing for JSON if content type is missing or incorrect - if (!result.binaryData && result.fullContent) { - const trimmed = result.fullContent.trim(); - if ((trimmed.startsWith('{') && trimmed.endsWith('}')) || (trimmed.startsWith('[') && trimmed.endsWith(']'))) { - try { - JSON.parse(trimmed); // Quick validation - return name + '.json'; - } catch(e) {} - } - } - - // If we still don't know the type, fallback to original extension if it existed - if (originalExt) return name + originalExt; - - // Otherwise default based on data format - return result.binaryData ? name + '.bin' : name + '.txt'; - }, - - async saveAsFolder() { - if (!this.state.bulk.results.length) return this.toast('No results to save', 'error'); - - try { - if (!window.showDirectoryPicker) { - return this.toast('Your browser does not support native folder saving. Please use the ZIP button instead.', 'error'); - } - - this.toast('Select a folder to save files...', 'info'); - const dirHandle = await window.showDirectoryPicker({ - mode: 'readwrite' - }); - - let savedCount = 0; - let errors = 0; - const usedNames = new Set(); - - for (const r of this.state.bulk.results) { - try { - let filename = this.getFinalFilename(r); - - let base = filename; - let ext = ''; - const lastDot = filename.lastIndexOf('.'); - if (lastDot !== -1 && lastDot > 0) { - base = filename.substring(0, lastDot); - ext = filename.substring(lastDot); - } - - let counter = 1; - while (usedNames.has(filename)) { - filename = `${base}_${counter}${ext}`; - counter++; - } - usedNames.add(filename); - - // Get the content as binary data - let data; - if (r.binaryData) { - // Convert hex string to Uint8Array - data = new Uint8Array(r.binaryData.match(/.{1,2}/g).map(byte => parseInt(byte, 16))); - } else if (r.fullContent) { - data = r.fullContent; - } else { - continue; // Skip empty results - } - - // Create file and write content - const fileHandle = await dirHandle.getFileHandle(filename, { create: true }); - const writable = await fileHandle.createWritable(); - await writable.write(data); - await writable.close(); - - savedCount++; - } catch (e) { - console.error('Error saving file', r.index, e); - errors++; - } - } - - if (errors > 0) { - this.toast(`Saved ${savedCount} files. Failed to save ${errors} files.`, 'warning'); - } else { - this.toast(`Successfully saved ${savedCount} files to the selected folder.`); - } - - } catch (e) { - console.error(e); - if (e.name === 'AbortError') { - this.toast('Folder selection cancelled.', 'info'); - } else { - this.toast('Failed to save to folder: ' + e.message, 'error'); - } - } - }, - - async saveAllResults() { - if (!this.state.bulk.results.length) return this.toast('No results to save', 'error'); - if (typeof JSZip === 'undefined') return this.toast('JSZip library not loaded. Please refresh.', 'error'); - - this.toast('Building ZIP file...', 'info'); - - const zip = new JSZip(); - let savedCount = 0; - const usedNames = new Set(); - - for (const result of this.state.bulk.results) { - try { - // Use the tracked input filename + auto extension - let filename = this.getFinalFilename(result); - - let base = filename; - let ext = ''; - const lastDot = filename.lastIndexOf('.'); - if (lastDot !== -1 && lastDot > 0) { - base = filename.substring(0, lastDot); - ext = filename.substring(lastDot); - } - - let counter = 1; - while (usedNames.has(filename)) { - filename = `${base}_${counter}${ext}`; - counter++; - } - usedNames.add(filename); - - // Get the content as binary data - let data; - if (result.binaryData) { - // Convert hex string to Uint8Array - data = new Uint8Array(result.binaryData.match(/.{1,2}/g).map(byte => parseInt(byte, 16))); - } else if (result.fullContent) { - data = result.fullContent; - } else { - continue; // Skip empty results - } - - // Add to ZIP (JSZip handles folder creation from path automatically) - zip.file(filename, data, { binary: !!result.binaryData }); - savedCount++; - } catch (e) { - console.error('Error adding result to ZIP', result.index, e); - } - } - - if (savedCount === 0) return this.toast('No valid results to save', 'error'); - - // Generate and download ZIP - try { - const blob = await zip.generateAsync({ type: 'blob' }); - const url = URL.createObjectURL(blob); - const a = document.createElement('a'); - a.href = url; - a.download = `bulk_results_${new Date().toISOString().replace(/[:.]/g, '-')}.zip`; - document.body.appendChild(a); - a.click(); - document.body.removeChild(a); - URL.revokeObjectURL(url); - - this.toast(`ZIP saved with ${savedCount} files`, 'info'); - } catch (e) { - this.toast('Error generating ZIP: ' + e.message, 'error'); - } - }, - - // --- Rendering --- - - render() { - const root = document.getElementById('app-root'); - if (root) { - // Reset base class first to prevent layout/theme clashing - root.className = 'workspace'; - - if (this.state.bulk.results.length > 0 || this.state.bulk.running) { - root.classList.add('bulk-active'); - } - if (this.state.gridMaximized || !this.state.activeSpaceId) { - root.classList.add('grid-maximized'); - } - - // Add theme class for active space - if (this.state.activeSpaceId) { - const activeSpace = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - const theme = activeSpace && activeSpace.theme ? activeSpace.theme : 'violet'; - root.classList.add(`theme-${theme}`); - } - } - this.renderSidebar(); - this.renderMain(); - this.renderResponse(); - }, - - renderProgress() { - // Optimized partial render for progress bar - const bar = document.getElementById('progress-bar-fill'); - const text = document.getElementById('progress-text'); - if (bar && text) { - const pct = (this.state.bulk.completed / this.state.bulk.total) * 100; - bar.style.width = `${pct}%`; - text.innerText = `${this.state.bulk.completed} / ${this.state.bulk.total}`; - } - }, - - getCollectionsHTML() { - const query = (this.state.searchQuery || '').toLowerCase().trim(); - let collectionsHTML = ''; - - this.collections.forEach(col => { - const isColActive = this.state.activeCollectionId === col.id; - - // Filter requests - const filteredRequests = col.requests.filter(r => { - if (!query) return true; - return ( - (r.name || '').toLowerCase().includes(query) || - (r.url || '').toLowerCase().includes(query) || - (r.description || '').toLowerCase().includes(query) - ); - }); - - // Decide if the collection itself matches - const colMatches = (col.name || '').toLowerCase().includes(query); - - // If neither collection matches nor has matching requests, skip rendering it - if (query && !colMatches && filteredRequests.length === 0) { - return; - } - - // If there's a query and we have matches, auto-expand the collection - const isExpanded = query ? true : isColActive; - - const reqsHTML = (query && colMatches ? col.requests : filteredRequests).map(r => ` -
- ${r.method} -
-
- ${this.escapeHTML(r.name || '')} -
-
- ${this.escapeHTML(r.url || 'No URL')} -
-
- - -
- `).join(''); - - collectionsHTML += ` -
-
- - ${this.escapeHTML(col.name)} - - - - - -
- ${isExpanded ? `
${reqsHTML || '
Empty Collection
'}
` : ''} -
- `; - }); - - return collectionsHTML; - }, - - filterSidebarCollections(query) { - this.state.searchQuery = query; - const listEl = document.getElementById('sidebar-collections-list'); - if (listEl) { - listEl.innerHTML = this.getCollectionsHTML(); - } - - // Also update clear button visibility - const clearBtn = document.getElementById('search-clear-btn'); - if (clearBtn) { - clearBtn.style.display = query ? 'block' : 'none'; - } - }, - - renderSidebar() { - const collectionsHTML = this.getCollectionsHTML(); - const activeSpace = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - - let notificationsBannerHTML = ''; - if (activeSpace && activeSpace.notifications && activeSpace.notifications.length > 0) { - notificationsBannerHTML = ` -
- - You have ${activeSpace.notifications.length} pending share request${activeSpace.notifications.length > 1 ? 's' : ''} -
- `; - } - - const spaceOptionsHTML = ` - - ${this.state.spaces.map(s => ` - - `).join('')} - `; - - const sidebarHeaderHTML = ` - - `; - - this.dom.sidebar.innerHTML = ` - ${sidebarHeaderHTML} - - ${activeSpace ? ` - ${notificationsBannerHTML} - - - - - - ` : ` -
- Select a workspace from the dashboard to view collections -
- `} - -
- -
- `; - }, - - renderMain() { - if (!this.state.activeSpaceId) { - // Render Spaces Dashboard Grid View - const spacesCardsHTML = this.state.spaces.map(s => { - const count = s.collections ? s.collections.length : 0; - const notifCount = s.notifications ? s.notifications.length : 0; - const theme = s.theme || 'violet'; - return ` -
-
- - ${notifCount > 0 ? `${notifCount}` : ''} -
-
-

${this.escapeHTML(s.name)}

- ${count} Collections -
-
- - ${this.state.spaces.length > 1 ? ` - - ` : ''} -
-
- `; - }).join(''); - - const dashboardHTML = ` -
-
-

Workspaces

-

Select a workspace to access its collections, endpoints, and history.

-
- -
- ${spacesCardsHTML} - -
-
-
-

Create New Space

- Add a clean workspace -
-
-
-
- `; - - const headerHTML = ` -
-
PHOENIX
-
- Workspace Dashboard -
-
-
- `; - - this.dom.mainPanel.innerHTML = headerHTML + dashboardHTML; - return; - } - - const isBulkStart = this.checkBulkStart(); - const bulk = this.state.bulk; - const activeSpace = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - - // Tab Strip (Postman-like) - const tabStripHTML = ` -
- ${this.tabs.map((tab, i) => { - const isActive = i === this.activeTabIndex; - const tabName = tab.name || (tab.url ? tab.url.split('/').pop() || 'Request' : 'Untitled'); - const displayName = tabName.length > 22 ? tabName.substring(0, 22) + '…' : tabName; - const method = tab.method || 'GET'; - const methodColors = { GET:'#10b981', POST:'#6366f1', PUT:'#f59e0b', DELETE:'#ef4444', PATCH:'#8b5cf6' }; - const mc = methodColors[method] || '#888'; - return ` -
- ${method} - ${this.escapeHTML(displayName)} - -
- `; - }).join('')} - -
- `; - - // Header with Active Space name/switcher - const headerHTML = ` -
-
- PHOENIX -
-
- ${this.escapeHTML(activeSpace ? activeSpace.name : '')} - -
- - -
- -
- -
- - -
- -
- ${bulk.running - ? ` - ` - : bulk.paused - ? ` - ` - : `` - } -
-
- ${tabStripHTML} - `; - - // Request Name & Description Details Section - const col = activeSpace ? activeSpace.collections.find(c => c.id === this.state.activeCollectionId) : null; - const activeReq = col ? col.requests.find(r => r.id === this.state.activeRequestId) : null; - - const requestMetaHTML = activeReq ? ` -
-
- Request Name: - -
-
- Description: - -
-
- ` : ''; - - // Tabs (PARAMS / HEADERS / BODY / AUTH) + Bulk controls always visible - const tabsHTML = ` -
- ${['params', 'headers', 'body', 'auth'].map(t => ` -
${t.toUpperCase()}
- `).join('')} -
-
- ${isBulkStart ? ` -
- Strategy: - - -
- ` : ''} -
- Repeat: - -
-
- Delay (ms): - -
-
- Concurrency: - -
-
-
- `; - - - // Content - let contentHTML = ''; - if (this.state.activeTab === 'params') contentHTML = this.renderTable(this.state.params, 'params'); - else if (this.state.activeTab === 'headers') contentHTML = this.renderTable(this.state.headers, 'headers'); - else if (this.state.activeTab === 'body') contentHTML = this.renderBodyTab(); - else if (this.state.activeTab === 'auth') contentHTML = this.renderAuthTab(); - - // Bottom Results & Response Panel (Always Rendered) - const pct = bulk.total > 0 ? (bulk.completed / bulk.total) * 100 : 0; - const statusColor = bulk.error > 0 ? (bulk.success > 0 ? 'var(--warning)' : 'var(--danger)') : 'var(--success)'; - const cardsHTML = bulk.results.slice(-200).map(r => this.renderResultCard(r)).join(''); - const folderPath = this.state.outputFolderPath || 'None selected'; - const activeBottomTab = this.state.responseTab || 'response'; - - let bottomTabContentHTML = ''; - if (activeBottomTab === 'response') { - const resp = this.state.response; - if (!resp) { - bottomTabContentHTML = `
Ready to send request. Click SEND to execute a single request, or RUN BATCH for bulk.
`; - } else if (resp.status === 'Sending...') { - bottomTabContentHTML = `
Sending request...
`; - } else if (resp.error) { - bottomTabContentHTML = `
Error: ${resp.error}
`; - } else { - let content = resp.content; - try { - if (content && !resp.binary_data && content.trim().startsWith('{')) { - content = JSON.stringify(JSON.parse(content), null, 2); - } - } catch(e){} - - bottomTabContentHTML = ` -
- ${resp.status_code} - ${resp.latency ? resp.latency + ' ms' : ''} - ${resp.content_type || 'Unknown Type'} -
-
- ${resp.binary_data - ? `
- Binary Content -
` - : `
${this.escapeHTML(content)}
` - } -
- `; - } - } else { - if (bulk.results.length === 0) { - bottomTabContentHTML = ` -
- - No batch results yet. Run a batch to see results in a grid. -
- `; - } else { - bottomTabContentHTML = ` -
-
-
-
- ${cardsHTML} -
- `; - } - } - - bottomPanelHTML = ` -
-
-
- -
-
-
- - -
- - ${bulk.results.length > 0 ? ` -
- ${bulk.completed} / ${bulk.total} Completed - ${bulk.success} Success - ${bulk.error} Failed -
- ` : ''} -
- - ${activeBottomTab === 'results' && bulk.results.length > 0 ? ` -
-
- - ${folderPath} - - - -
- - - - - -
- ` : ''} -
- -
- ${bottomTabContentHTML} -
-
- `; - - this.dom.mainPanel.innerHTML = headerHTML + requestMetaHTML + tabsHTML + `
${contentHTML}
` + bottomPanelHTML; - }, - - renderResultCard(result) { - const isImage = (result.contentType || '').toLowerCase().includes('image') && result.binaryData; - const isSuccess = result.status >= 200 && result.status < 300; - const statusClass = isSuccess ? 'status-success' : 'status-error'; - const filename = result.inputFilename || `result_${result.index}`; - const finalFilename = this.getFinalFilename(result); - - let previewHTML = ''; - if (isImage) { - try { - const base64Data = this.hexToBase64(result.binaryData); - previewHTML = `${filename}`; - } catch (e) { - previewHTML = `
Decode error
`; - } - } else { - let icon = 'fa-file-lines'; - let typeLabel = 'TXT'; - const ct = (result.contentType || '').toLowerCase(); - if (ct.includes('application/json')) { icon = 'fa-file-code'; typeLabel = 'JSON'; } - else if (ct.includes('text/html')) { icon = 'fa-file-code'; typeLabel = 'HTML'; } - else if (result.status === 'ERR') { icon = 'fa-circle-xmark'; typeLabel = 'ERROR'; } - previewHTML = ` -
- - ${typeLabel} -

${this.escapeHTML(result.data || '')}

-
`; - } - - const footerHTML = isImage - ? `` - : `
-
- #${result.index} - ${result.status} - ${result.latency}ms -
-
${finalFilename}
-
`; - - return ` -
-
- ${previewHTML} -
- ${!isImage ? ` - ` : ''} - - - -
-
- ${footerHTML} -
- `; - }, - - renderResponse() { - // No-op: Single response and bulk results have been consolidated into renderMain()'s bottom panel. - }, - - renderTable(items, section) { - return ` - - - - ${items.map(item => ` - - - - - - - `).join('')} - -
KeyValue
- - ${this.renderValueInput(item, section)} -
- - `; - }, - - renderValueInput(item, section) { - if (item.type === 'file' || item.type === 'folder') { - const files = this.fileStore.get(item.id); - const label = files ? (item.type === 'folder' ? `${files.length} Files Selected` : `${files.length} Files`) : 'Select...'; - return ` -
- - -
- `; - } - if (item.type === 'auto_width' || item.type === 'auto_height') { - return ``; - } - return ``; - }, - - renderBodyTab() { - return ` -
-
- - - -
- - ${this.state.bodyType === 'form-data' ? this.renderTable(this.state.bodyData, 'body') : ''} - ${this.state.bodyType === 'json' ? `` : ''} -
- `; - }, - - renderAuthTab() { - const auth = this.state.auth; - return ` -
- - - - ${auth.type === 'bearer' ? ` -
- - -
- ` : ''} - - ${auth.type === 'basic' ? ` -
-
-
-
- ` : ''} - - ${auth.type === 'apikey' ? ` -
-
-
-
- ` : ''} -
- `; - }, - - // --- Helpers --- - - handleFileSelect(input, section, id) { - if (input.files.length > 0) { - // Convert FileList to Array and sort by path to ensure strict processing sequence (natural sorting) - let filesArr = Array.from(input.files); - filesArr.sort((a, b) => { - const pA = a.webkitRelativePath || a.name; - const pB = b.webkitRelativePath || b.name; - return pA.localeCompare(pB, undefined, { numeric: true, sensitivity: 'base' }); - }); - this.fileStore.set(id, filesArr); - this.render(); // update label - } - }, - - checkBulkStart() { - const hasKeyedFolder = this.state.params.some(p => p.type === 'folder' && p.enabled && p.key && p.key.trim()) - || (this.state.bodyType === 'form-data' && this.state.bodyData.some(p => p.type === 'folder' && p.enabled && p.key && p.key.trim())); - - const hasKeyedList = this.state.params.some(p => p.type === 'list' && p.enabled && p.key && p.key.trim()) - || (this.state.bodyType === 'form-data' && this.state.bodyData.some(p => p.type === 'list' && p.enabled && p.key && p.key.trim())) - || this.state.headers.some(h => h.type === 'list' && h.enabled && h.key && h.key.trim()); - - return hasKeyedFolder || hasKeyedList; - }, - - getStatusColor(code) { - if (code >= 200 && code < 300) return 'var(--success)'; - if (code >= 300 && code < 400) return 'var(--warning)'; - if (code >= 400 || code === 'ERR') return 'var(--danger)'; - return 'var(--text-muted)'; - }, - - toast(msg, type = 'info') { - const t = document.createElement('div'); - t.innerText = msg; - t.style.cssText = ` - background: ${type === 'error' ? '#EF4444' : '#333'}; - color: white; padding: 10px 20px; border-radius: 6px; margin-top: 10px; - box-shadow: 0 4px 12px rgba(0,0,0,0.5); font-size: 13px; - `; - this.dom.toast.appendChild(t); - setTimeout(() => t.remove(), 3000); - }, - - escapeHTML(str) { - if (!str) return ''; - if (typeof str !== 'string') return String(str); - return str.replace(/&/g, '&') - .replace(//g, '>') - .replace(/"/g, '"') - .replace(/'/g, '''); - }, - - hexToBase64(hexString) { - if (!hexString) return ''; - // Strip any whitespace or non-hex chars - hexString = hexString.replace(/[^0-9a-fA-F]/g, ''); - const len = hexString.length; - const bytes = new Uint8Array(len / 2); - for (let i = 0; i < len; i += 2) { - bytes[i / 2] = parseInt(hexString.substr(i, 2), 16); - } - let binary = ''; - const chunk = 8192; - for (let i = 0; i < bytes.length; i += chunk) { - const subarr = bytes.subarray(i, i + chunk); - binary += String.fromCharCode.apply(null, subarr); - } - return btoa(binary); - }, - - bindEvents() { - // Most events are inline (onclick, onchange) for simplicity in this structure - }, - - // Preview a result - previewResult(index) { - const result = this.state.bulk.results.find(r => r.index === index); - if (!result) return; - - const isImage = (result.contentType || '').toLowerCase().includes('image') && result.binaryData; - const finalFilename = this.getFinalFilename(result); - - let contentHTML = ''; - if (isImage) { - try { - const base64Data = this.hexToBase64(result.binaryData); - contentHTML = `${finalFilename}`; - } catch (e) { - contentHTML = ``; - } - } else { - let prettyContent = result.fullContent || ''; - try { - if (prettyContent.trim().startsWith('{')) { - prettyContent = JSON.stringify(JSON.parse(prettyContent), null, 2); - } - } catch(e) {} - contentHTML = ``; - } - - const modal = document.createElement('div'); - modal.className = 'premium-modal-overlay'; - - modal.innerHTML = ` -
-
-
- -
- ${finalFilename} - Result #${result.index} -
-
-
- ${result.status} - ${result.latency}ms - -
-
-
- ${contentHTML} -
- -
- `; - - document.body.appendChild(modal); - modal.onclick = () => modal.remove(); - }, - - // For manual clicking from history - loadHistoryItem(id) { - const item = this.state.history.find(h => h.id === id); - if (item) { - this.state.method = item.method; - this.state.url = item.url; - this.saveState(); - this.render(); - } - } -}; - - -document.addEventListener('DOMContentLoaded', () => App.init()); - diff --git a/web/bulk-api-tester/static/js/fix_app.py b/web/bulk-api-tester/static/js/fix_app.py deleted file mode 100644 index d185b68..0000000 --- a/web/bulk-api-tester/static/js/fix_app.py +++ /dev/null @@ -1,34 +0,0 @@ -import re - -with open('app.js', 'r') as f: - code = f.read() - -# 1. _buildShell -shell = """ - _buildShell() { - if (!this.dom.mainPanel) return; - this.dom.mainPanel.innerHTML = ` -
-
- `; - }, -""" -code = code.replace('async init() {', shell + '\n async init() {') -code = code.replace('this.cacheDOM();', 'this.cacheDOM();\n this._buildShell();') - -# 2. Rename render() to _renderAll() -code = code.replace('render() {', '_renderAll() {') - -# 3. Targeted updates -code = code.replace('this.render();', 'this._renderAll();') - -# 4. Results: binaryData ALWAYS nulled after blobUrl created -code = re.sub(r'(resultItem\.blobUrl = res\.blobUrl;)', r'\1\n resultItem.binaryData = null;', code) - -# 5. saveState skip during bulk -# Already in code: if (this.state.bulk && this.state.bulk.running) return; - -with open('app.js', 'w') as f: - f.write(code) - -print("Rewrite done via Python") diff --git a/web/bulk-api-tester/static/js/parse_render.py b/web/bulk-api-tester/static/js/parse_render.py deleted file mode 100644 index 1a36ff3..0000000 --- a/web/bulk-api-tester/static/js/parse_render.py +++ /dev/null @@ -1,22 +0,0 @@ -import re - -with open('app.js', 'r') as f: - content = f.read() - -for func in ['renderSidebar', 'renderMain', 'renderResponse']: - match = re.search(fr'{func}\(\)\s*\{{', content) - if match: - start = match.start() - brace_count = 0 - started = False - for i in range(start, len(content)): - if content[i] == '{': - brace_count += 1 - started = True - elif content[i] == '}': - brace_count -= 1 - if started and brace_count == 0: - end = i + 1 - break - with open(f'{func}.txt', 'w') as out: - out.write(content[start:end]) diff --git a/web/bulk-api-tester/static/js/render.txt b/web/bulk-api-tester/static/js/render.txt deleted file mode 100644 index 538385e..0000000 --- a/web/bulk-api-tester/static/js/render.txt +++ /dev/null @@ -1,24 +0,0 @@ -render() { - const root = document.getElementById('app-root'); - if (root) { - // Reset base class first to prevent layout/theme clashing - root.className = 'workspace'; - - if (this.state.bulk.results.length > 0 || this.state.bulk.running) { - root.classList.add('bulk-active'); - } - if (this.state.gridMaximized || !this.state.activeSpaceId) { - root.classList.add('grid-maximized'); - } - - // Add theme class for active space - if (this.state.activeSpaceId) { - const activeSpace = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - const theme = activeSpace && activeSpace.theme ? activeSpace.theme : 'violet'; - root.classList.add(`theme-${theme}`); - } - } - this.renderSidebar(); - this.renderMain(); - this.renderResponse(); - } diff --git a/web/bulk-api-tester/static/js/renderMain.txt b/web/bulk-api-tester/static/js/renderMain.txt deleted file mode 100644 index 6038a29..0000000 --- a/web/bulk-api-tester/static/js/renderMain.txt +++ /dev/null @@ -1,107 +0,0 @@ -renderMain() { - if (!this.state.activeSpaceId) { - // Render Spaces Dashboard Grid View - const spacesCardsHTML = this.state.spaces.map(s => { - const count = s.collections ? s.collections.length : 0; - const notifCount = s.notifications ? s.notifications.length : 0; - const theme = s.theme || 'violet'; - return ` -
-
- - ${notifCount > 0 ? `${notifCount}` : ''} -
-
-

${this.escapeHTML(s.name)}

- ${count} Collections -
-
- - ${this.state.spaces.length > 1 ? ` - - ` : ''} -
-
- `; - }).join(''); - - const dashboardHTML = ` -
-
-

Workspaces

-

Select a workspace to access its collections, endpoints, and history.

-
- -
- ${spacesCardsHTML} - -
-
-
-

Create New Space

- Add a clean workspace -
-
-
-
- `; - - const headerHTML = ` -
-
PHOENIX
-
- Workspace Dashboard -
-
-
- `; - - this.dom.mainPanel.innerHTML = headerHTML + dashboardHTML; - return; - } - - const isBulkStart = this.checkBulkStart(); - const bulk = this.state.bulk; - const activeSpace = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - - // Tab Strip (Postman-like) - const tabStripHTML = ` -
- ${this.tabs.map((tab, i) => { - const isActive = i === this.activeTabIndex; - const tabName = tab.name || (tab.url ? tab.url.split('/').pop() || 'Request' : 'Untitled'); - const displayName = tabName.length > 20 ? tabName.substring(0, 20) + '…' : tabName; - const method = tab.method || 'GET'; - const mc = { GET:'var(--m-get)', POST:'var(--m-post)', PUT:'var(--m-put)', DELETE:'var(--m-delete)', PATCH:'var(--m-patch)' }[method] || 'var(--text-3)'; - return ` -
- ${method} - ${this.escapeHTML(displayName)} - -
- `; - }).join('')} \ No newline at end of file diff --git a/web/bulk-api-tester/static/js/renderResponse.txt b/web/bulk-api-tester/static/js/renderResponse.txt deleted file mode 100644 index 6c47a29..0000000 --- a/web/bulk-api-tester/static/js/renderResponse.txt +++ /dev/null @@ -1,3 +0,0 @@ -renderResponse() { - // No-op: Single response and bulk results have been consolidated into renderMain()'s bottom panel. - } \ No newline at end of file diff --git a/web/bulk-api-tester/static/js/renderSidebar.txt b/web/bulk-api-tester/static/js/renderSidebar.txt deleted file mode 100644 index 2974bc1..0000000 --- a/web/bulk-api-tester/static/js/renderSidebar.txt +++ /dev/null @@ -1,88 +0,0 @@ -renderSidebar() { - const collectionsHTML = this.getCollectionsHTML(); - const activeSpace = this.state.spaces.find(s => s.id === this.state.activeSpaceId); - - let notificationsBannerHTML = ''; - if (activeSpace && activeSpace.notifications && activeSpace.notifications.length > 0) { - notificationsBannerHTML = ` -
- - ${activeSpace.notifications.length} pending share request${activeSpace.notifications.length > 1 ? 's' : ''} -
- `; - } - - const spaceOptionsHTML = ` - - ${this.state.spaces.map(s => ` - - `).join('')} - `; - - this.dom.sidebar.innerHTML = ` - - - - ${activeSpace ? ` - ${notificationsBannerHTML} - - - - - - - - - - ` : ` -
-
- -
Select a workspace
from the dashboard
-
-
- `} - - -
- -
- `; - } \ No newline at end of file diff --git a/web/bulk-api-tester/static/js/rewrite.py b/web/bulk-api-tester/static/js/rewrite.py deleted file mode 100644 index baae70f..0000000 --- a/web/bulk-api-tester/static/js/rewrite.py +++ /dev/null @@ -1,40 +0,0 @@ -import re -import sys - -with open('app.js', 'r') as f: - content = f.read() - -# 1. Add _buildShell() -shell_html = """ - _buildShell() { - const root = document.getElementById('app-root'); - if (!root) return; - - root.innerHTML = ` - - -
-
- `; - }, -""" - -# Find init() and insert _buildShell() call and definition -init_idx = content.find('async init() {') -if init_idx != -1: - content = content[:init_idx] + shell_html + content[init_idx:] - content = content.replace('this.loadState();', 'this.loadState();\n this._buildShell();') - -# 2. _renderAll() instead of render() -content = content.replace('render() {', '_renderAll() {') - -# 3. Surgical updates -# We can replace 'this.render();' with selective calls, but the prompt says: -# "6. Full _renderAll() called only on: tab switch, space switch, page init, bulk complete." -# "5. saveState() must skip during bulk run." (already in code: if (this.state.bulk && this.state.bulk.running) return;) -# "4. Results: binaryData ALWAYS nulled after blobUrl created" -# "7. No this.dom.mainPanel.innerHTML = ... after init, except for Spaces Dashboard view" -# "8. No this.dom.sidebar.innerHTML = ... after init." - -with open('/tmp/app_new.js', 'w') as f: - f.write(content) diff --git a/web/khira/app.js b/web/khira/app.js index 1e645f2..6fcd49b 100644 --- a/web/khira/app.js +++ b/web/khira/app.js @@ -304,8 +304,19 @@ function nav(sec){ function sheet(id){ const t=S.t.find(x=>x.id===id);if(!t)return;S.tid=id; const p=pri(t),s=st(t),g=t.ticket_type==='general',rem=t.remarks||[],links=(t.links||[]).map(l=>l.url||l); + const atts=t.attachments||[]; const kv=(k,v,m)=>`
${k}
${m==='html'?v:esc(v||'—')}
`; - const meta=g?kv('Category',t.general_category)+kv('Department',t.department):kv('Application',t.app||t.app_name)+kv('Version',t.version)+kv('Feature',t.feature||t.feature_name)+kv('API key / route',t.api_key,1); + + let meta=''; + if(g){ + meta=kv('Reported by',who(t.reporter||{name:t.created_by_name,username:t.created_by,role:t.created_by_role},t.created_by_name),'html'); + }else{ + meta=(t.app||t.app_name?kv('Application',t.app||t.app_name):'') + +(t.version?kv('Version',t.version):'') + +(t.feature||t.feature_name?kv('Feature',t.feature||t.feature_name):'') + +(t.api_key?kv('API key / route',t.api_key,1):'') + +kv('Reported by',who(t.reporter||{name:t.created_by_name,username:t.created_by,role:t.created_by_role},t.created_by_name),'html'); + } const isAdmin=S.u?.username==='admin'||S.u?.role==='team_lead'||S.u?.role==='lead'; const isCreator=S.u?.username && (S.u.username.toLowerCase()===(t.created_by||t.reporter?.username||'').toLowerCase()); @@ -316,9 +327,15 @@ function sheet(id){ $('#sheet').innerHTML=`
${esc(t.id)}${p}${t.archived?'archiveArchived':`${STAT[s]||esc(s)}`}

${esc(t.title)}

${fld('a','Assignee',{t:'select',opts:usOpts(),v:t.assignee?.username||t.assigned_to||'',d:'data-act="assign"'})}${fld('p','Priority',{t:'select',opts:PRI,v:p,d:'data-act="prio"'})}
-
${meta}${kv('Reported by',who(t.reporter||{name:t.created_by_name,username:t.created_by,role:t.created_by_role},t.created_by_name),'html')}
-
Assistance required

${esc(t.assistance||t.assistance_required||'—')}

-
Diagnostic context
${esc(t.context||t.additional_info||'No logs provided')}
+
${meta}
+
Description

${esc(t.description||'No description provided')}

+${atts.length?`
Attached Images / Files
${atts.map(a=>{ + const isImg=a.type==='image'||/\.(png|jpe?g|webp|gif|svg)$/i.test(a.url); + return isImg?`
${esc(a.name)}${esc(a.name)}
` + :``; +}).join('')}
`:''} +${(t.assistance||t.assistance_required)?`
Assistance required

${esc(t.assistance||t.assistance_required)}

`:''} +${(t.context||t.additional_info)?`
Diagnostic context
${esc(t.context||t.additional_info)}
`:''} ${links.length?`
Links
${links.map(u=>`${esc(String(u).replace(/^https?:\/\//,''))}`).join('')}
`:''}
Activity · ${rem.length}
${rem.map(r=>{const sys=r.system||['created','hold','complete','reassigned','priority','resume','archive','unarchive'].includes(r.type);return`
${sys?'Khira':who(r.author||{name:r.author_name,username:r.author_username,role:r.author_role},r.author_name)}${ago(r.created_at)}

${esc(r.text||r.body)}

`}).join('')}
@@ -361,18 +378,127 @@ function deleteTicketD(id){ /* ── create ticket ── */ function newTicket(){ + const appOpts=[['','Select application'],...Array.from(new Set([...APPS,...(S.t||[]).map(t=>t.app||t.app_name),...(S.e||[]).map(e=>e.app||e.app_name)].filter(Boolean)))]; + dlg({wide:1,title:'New ticket',sub:`Reporting as ${esc(S.u.name)}`,ok:'Create ticket', - body:`${rad('type',[['application','Application'],['general','General']],'application')} -${fld('assignee_username','Assignee',{t:'select',opts:usOpts(1),req:1})}${fld('title','Title',{req:1})} -
${fld('app','Application',{t:'select',opts:[['','Select'],...APPS],req:1})}
${fld('version','Version',{req:1})}${fld('feature','Feature',{req:1})}
${fld('api_key','API key / route')}${fld('issue_type','Issue type',{t:'select',opts:[['','Select'],...ISS],req:1})}
- -

Priority

${rad('priority',PRI,'P1')}
-${fld('description','Description',{t:'area',rows:4,req:1})}${fld('assistance','Assistance required',{req:1})}${fld('context','Context (cURL, logs, stack trace)',{t:'area',rows:4,mono:1})}${fld('link','Reference link',{t:'url'})}`, - init:f=>{const sw=()=>{const g=f.querySelector('[name=type]:checked').value;f.querySelectorAll('.grp').forEach(x=>{const on=x.dataset.g===g;x.hidden=!on;x.disabled=!on})};f.querySelectorAll('[name=type]').forEach(r=>r.onchange=sw);sw()}, + body:`${rad('type',[['general','General'],['application','Application']],'general')} +
+ ${fld('assignee_username','Choose assignee',{t:'select',opts:usOpts(1),req:1})} + ${fld('title','Write title',{req:1})} + ${fld('description','Description',{t:'area',rows:5,req:1})} +
+`, + init:f=>{ + let selectedImageFile=null; + const sw=()=>{ + const g=f.querySelector('[name=type]:checked')?.value||'general'; + f.querySelectorAll('.grp').forEach(x=>{ + const on=x.dataset.g===g; + x.hidden=!on; + x.disabled=!on; + }); + }; + f.querySelectorAll('[name=type]').forEach(r=>r.onchange=sw); + sw(); + + const imgInput=f.querySelector('#appImgInput'); + const previewWrap=f.querySelector('#imgPreviewWrap'); + const previewImg=f.querySelector('#imgPreview'); + const uploadTxt=f.querySelector('#imgUploadTxt'); + const removeBtn=f.querySelector('#btnRemoveImg'); + + if(imgInput){ + imgInput.onchange=e=>{ + const file=e.target.files&&e.target.files[0]; + if(!file)return; + selectedImageFile=file; + const reader=new FileReader(); + reader.onload=ev=>{ + previewImg.src=ev.target.result; + previewWrap.style.display='flex'; + uploadTxt.textContent=file.name; + }; + reader.readAsDataURL(file); + }; + } + + if(removeBtn){ + removeBtn.onclick=()=>{ + selectedImageFile=null; + if(imgInput)imgInput.value=''; + previewImg.src=''; + previewWrap.style.display='none'; + uploadTxt.textContent='Upload image (Optional)'; + }; + } + + f._getSelectedFile=()=>selectedImageFile; + }, go:async v=>{ + const f=$('#dlg form'); + const file=f._getSelectedFile?f._getSelectedFile():null; + let uploadedAtt=null; + if(file){ + const fd=new FormData(); + fd.append('file',file); + const un=S.u?.username||ls('khira_active_user')||'admin'; + try{ + const upRes=await fetch('/khira/api/upload',{method:'POST',headers:{'X-Khira-User':un},body:fd}); + const upData=await upRes.json(); + if(upData.attachment){ + uploadedAtt=upData.attachment; + }else if(upData.url){ + uploadedAtt={url:upData.url,name:file.name,type:'image'}; + } + }catch(err){ + console.error('Upload failed',err); + } + } + const g=v.type==='general'; - const b=g?{ticket_type:'general',general_category:v.general_category,department:v.department,assignee_username:v.assignee_username,title:v.title,app:'General / Non-App',feature:v.general_category,priority:v.priority,description:v.description,assistance:v.assistance,context:v.context,links:v.link?[v.link]:[],files:[]} - :{ticket_type:'application',assignee_username:v.assignee_username,title:v.title,app:v.app,version:v.version,feature:v.feature,api_key:v.api_key,issue_type:v.issue_type,priority:v.priority,description:v.description,assistance:v.assistance,context:v.context,links:v.link?[v.link]:[]}; + const b=g?{ + ticket_type:'general', + assignee_username:v.assignee_username, + title:v.title, + description:v.description, + general_category:'General', + department:'General', + priority:'P2' + }:{ + ticket_type:'application', + developer_account:v.assignee_username, + assignee_username:v.assignee_username, + app:v.app, + app_name:v.app, + version:v.version, + feature:v.feature||'', + feature_name:v.feature||'', + api_key:v.api_key||'', + title:v.title, + description:v.description, + priority:'P2', + attachments:uploadedAtt?[uploadedAtt]:[] + }; + const r=await api('/khira/api/tickets','POST',b); if(!r.ticket){toast(r.error||'Could not create ticket','err');return false} toast(`${r.ticket.id} created`);await refresh();nav('tickets');sheet(r.ticket.id); diff --git a/web/khira/styles.css b/web/khira/styles.css index 8a0fb6f..f53cefe 100644 --- a/web/khira/styles.css +++ b/web/khira/styles.css @@ -363,6 +363,20 @@ dt{font-size:12px;color:var(--on-sv)}dd{word-break:break-word} .cont-banner p{margin:2px 0 0;font-size:12px;color:var(--on-sv)} .cont-badge{display:inline-flex;align-items:center;gap:6px;background:var(--sec-c);color:var(--on-s);padding:2px 8px;border-radius:12px;font-size:11px;font-weight:600} +/* Ticket Image Upload & Attachments */ +.fld-upload{display:grid;gap:10px;margin:4px 0} +.img-preview-wrap{position:relative;width:fit-content;max-width:100%;border-radius:12px;overflow:hidden;border:1px solid var(--out-v);background:var(--sc-hi);padding:6px;display:flex;align-items:center;gap:8px} +.img-preview-wrap img{max-height:140px;max-width:240px;object-fit:cover;border-radius:8px;display:block} +.img-preview-wrap .rm-btn{position:absolute;top:10px;right:10px;background:rgba(0,0,0,0.65);color:#fff;width:28px;height:28px;border-radius:50%;border:none;display:grid;place-items:center;cursor:pointer} +.img-preview-wrap .rm-btn:hover{background:rgba(0,0,0,0.85)} + +.att-row{display:flex;flex-wrap:wrap;gap:12px;margin-top:8px} +.att-card{display:flex;flex-direction:column;gap:4px;width:140px} +.att-thumb{width:140px;height:90px;object-fit:cover;border-radius:8px;border:1px solid var(--out-v);background:var(--sc-hi);transition:transform .2s;display:block} +.att-thumb:hover{transform:scale(1.03)} +.att-card .ell{font-size:12px;color:var(--on-sv)} + +