transceiver-db/sql/010-vendor-urls.sql
Rene Fichtmueller 4b452ab49e feat(scrapers+mcp): ATGBICS + ProLabs scrapers, MCP HTTP/SSE server
Scrapers:
- atgbics.ts: PlaywrightCrawler for UK vendor ATGBICS (Shopify store),
  scrapes SFP/SFP+/SFP28/QSFP+/QSFP28/QSFP-DD in GBP, max 50 pages/run
- prolabs.ts: HttpCrawler for ProLabs (Legrand subsidiary), USD pricing,
  category-driven crawl with reach/fiber/speed detection
- Both registered in scheduler (every 8h, staggered) and index.ts CLI

MCP HTTP Server:
- packages/mcp-server/src/http-server.ts: Express + SSEServerTransport
- Exposes all 12 TIP tools via GET /sse + POST /message
- Bearer token auth (MCP_SECRET env), CORS-configurable
- GET /health → { status: "ok", tools: 12 }
- Port: MCP_HTTP_PORT (default 3201)

SQL + tools:
- sql/006-009: seed scripts for whitebox switches, vendors, assets
- switch-docs.ts: MCP tool for switch documentation queries
2026-03-29 02:26:45 +08:00

83 lines
3.9 KiB
SQL

-- 010: Add image_url, product_page_url, datasheet_url columns and populate vendor URLs
-- Run on Erik: PGPASSWORD='tip_prod_2026' psql -h localhost -p 5433 -U tip -d transceiver_db -f sql/010-vendor-urls.sql
-- Add columns (idempotent)
ALTER TABLE transceivers ADD COLUMN IF NOT EXISTS image_url TEXT;
ALTER TABLE transceivers ADD COLUMN IF NOT EXISTS product_page_url TEXT;
ALTER TABLE transceivers ADD COLUMN IF NOT EXISTS datasheet_url TEXT;
ALTER TABLE switches ADD COLUMN IF NOT EXISTS image_url TEXT;
ALTER TABLE switches ADD COLUMN IF NOT EXISTS product_page_url TEXT;
-- FLEXOPTIX product page URLs (strip :variant suffix)
UPDATE transceivers
SET product_page_url = 'https://www.flexoptix.net/en/' ||
LOWER(REPLACE(REPLACE(
CASE
WHEN part_number LIKE '%:%' THEN SPLIT_PART(part_number, ':', 1)
ELSE part_number
END,
'.', '-'), ' ', '-')) || '.html'
WHERE vendor_id = (SELECT id FROM vendors WHERE name = 'FLEXOPTIX')
AND part_number IS NOT NULL
AND product_page_url IS NULL;
-- 10Gtek product page URLs
UPDATE transceivers
SET product_page_url = 'https://www.10gtek.com/transceiver'
WHERE vendor_id = (SELECT id FROM vendors WHERE name = '10Gtek')
AND product_page_url IS NULL;
-- Fluxlight product page URLs (pattern: fluxlight.com/{PART_NUMBER}-FL/)
UPDATE transceivers
SET product_page_url = 'https://fluxlight.com/' || REPLACE(COALESCE(part_number, slug), ' ', '-') || '/'
WHERE vendor_id = (SELECT id FROM vendors WHERE name = 'Fluxlight')
AND part_number IS NOT NULL
AND product_page_url IS NULL;
-- GBICS product page URLs
UPDATE transceivers
SET product_page_url = 'https://gbics.com/compatible-transceivers/'
WHERE vendor_id = (SELECT id FROM vendors WHERE name = 'GBICS')
AND product_page_url IS NULL;
-- SFPcables product page URLs
UPDATE transceivers
SET product_page_url = 'https://www.sfpcables.com/'
WHERE vendor_id = (SELECT id FROM vendors WHERE name = 'SFPcables')
AND product_page_url IS NULL;
-- Juniper Networks product page URLs (generic Juniper optics page)
UPDATE transceivers
SET product_page_url = 'https://www.juniper.net/us/en/products/pluggable-optics.html'
WHERE vendor_id = (SELECT id FROM vendors WHERE name = 'Juniper Networks')
AND product_page_url IS NULL;
-- Switch vendor product page URLs
UPDATE switches SET product_page_url = 'https://www.cisco.com/site/us/en/products/networking/switches/index.html'
WHERE vendor_id = (SELECT id FROM vendors WHERE name = 'Cisco') AND product_page_url IS NULL;
UPDATE switches SET product_page_url = 'https://www.arista.com/en/products/switches'
WHERE vendor_id = (SELECT id FROM vendors WHERE name = 'Arista Networks') AND product_page_url IS NULL;
UPDATE switches SET product_page_url = 'https://www.juniper.net/us/en/products/switches.html'
WHERE vendor_id = (SELECT id FROM vendors WHERE name = 'Juniper Networks') AND product_page_url IS NULL;
UPDATE switches SET product_page_url = 'https://www.nvidia.com/en-us/networking/ethernet-switching/'
WHERE vendor_id = (SELECT id FROM vendors WHERE name = 'NVIDIA') AND product_page_url IS NULL;
UPDATE switches SET product_page_url = 'https://www.edgecore.com/products'
WHERE vendor_id = (SELECT id FROM vendors WHERE name = 'Edgecore') AND product_page_url IS NULL;
UPDATE switches SET product_page_url = 'https://www.celestica.com/open-networking-switches'
WHERE vendor_id = (SELECT id FROM vendors WHERE name = 'Celestica') AND product_page_url IS NULL;
UPDATE switches SET product_page_url = 'https://www.asterfusion.com/products/'
WHERE vendor_id = (SELECT id FROM vendors WHERE name = 'Asterfusion') AND product_page_url IS NULL;
-- Summary
SELECT 'Transceivers with product_page_url' as metric, COUNT(*) as count FROM transceivers WHERE product_page_url IS NOT NULL
UNION ALL
SELECT 'Transceivers with image_url', COUNT(*) FROM transceivers WHERE image_url IS NOT NULL
UNION ALL
SELECT 'Switches with product_page_url', COUNT(*) FROM switches WHERE product_page_url IS NOT NULL;