{"openapi":"3.0.3","info":{"title":"Moduł wyliczenia materiałowego i kalkulacji komponentów – API","version":"8.2.0","description":"Interfejs programistyczny modułu. Służy do komunikacji z pozostałymi modułami systemu (silnik GIS / model 3D budynku, moduł doboru parametrów instalacji, platforma sprzedażowa). Wszystkie odpowiedzi w JSON (UTF-8); eksporty w CSV. Dostęp do API wymaga zalogowania (cookie sesji z POST /api/auth/login); role: admin, technolog, handlowiec. Integracje między modułami: nagłówek X-Api-Key (klucze z /api/apikeys) lub Authorization: Bearer <klucz>; zadania asynchroniczne /api/jobs z webhookiem."},"servers":[{"url":"http://localhost:3000"}],"tags":[{"name":"Uwierzytelnianie","description":"Logowanie, sesje, użytkownicy i role"},{"name":"Słowniki","description":"Regiony, konfiguracja, falowniki"},{"name":"Wzorce mikropaneli","description":"Baza ustandaryzowanych schematów wewnętrznych mikropaneli PV"},{"name":"Produkty","description":"Katalog produktów PV producenta, import"},{"name":"Wyliczenia","description":"Zestawienie materiałowe, rozkrój i obróbka profili, schemat elektryczny, uzysk, warianty"},{"name":"Historia","description":"Zapisane wyliczenia"},{"name":"Projekty","description":"Projekty / klienci grupujące wyliczenia"},{"name":"Integracje","description":"Klucze API, zadania asynchroniczne i webhooki"},{"name":"Dach ze zdjęcia","description":"Zadanie 1.1: ortofotomapa, obrysy OSM, segmentacja, bryła 3D"}],"paths":{"/api/health":{"get":{"tags":["Słowniki"],"summary":"Stan usługi","responses":{"200":{"description":"OK"}}}},"/api/regions":{"get":{"tags":["Słowniki"],"summary":"Województwa z parametrami stref śniegowych, wiatrowych i nasłonecznienia","responses":{"200":{"description":"Lista regionów"}}}},"/api/geocode":{"post":{"tags":["Słowniki"],"summary":"Adres inwestycji → współrzędne, województwo, parametry regionu","requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["address"],"properties":{"address":{"type":"string","example":"ul. Puławska 427, Warszawa"}}}}}},"responses":{"200":{"description":"Lokalizacja i region"},"404":{"description":"Nie znaleziono adresu"},"502":{"description":"Geokoder niedostępny"}}}},"/api/config":{"get":{"tags":["Słowniki"],"summary":"Konfiguracja: profile, cennik, kable, falowniki","responses":{"200":{"description":"OK"}}},"put":{"tags":["Słowniki"],"summary":"Aktualizacja cennika / profili","responses":{"200":{"description":"OK"}}}},"/api/inverters":{"get":{"tags":["Słowniki"],"summary":"Katalog falowników","responses":{"200":{"description":"OK"}}},"post":{"tags":["Słowniki"],"summary":"Nowy falownik","responses":{"200":{"description":"OK"}}}},"/api/patterns":{"get":{"tags":["Wzorce mikropaneli"],"summary":"Lista wzorców z parametrami wyprowadzonymi (Wp, Voc, Isc, wymiary) i ścieżką połączeń ogniw","responses":{"200":{"description":"OK"}}},"post":{"tags":["Wzorce mikropaneli"],"summary":"Nowy wzorzec","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Pattern"}}}},"responses":{"200":{"description":"Utworzony"},"400":{"description":"Błąd walidacji"}}}},"/api/patterns/{id}":{"get":{"tags":["Wzorce mikropaneli"],"summary":"Wzorzec","parameters":[{"$ref":"#/components/parameters/id"}],"responses":{"200":{"description":"OK"},"404":{"description":"Brak"}}},"put":{"tags":["Wzorce mikropaneli"],"summary":"Dostosowanie wzorca (edycja pól)","parameters":[{"$ref":"#/components/parameters/id"}],"responses":{"200":{"description":"OK"}}},"delete":{"tags":["Wzorce mikropaneli"],"summary":"Usunięcie wzorca","parameters":[{"$ref":"#/components/parameters/id"}],"responses":{"200":{"description":"OK"}}}},"/api/patterns/{id}/preview":{"post":{"tags":["Wzorce mikropaneli"],"summary":"Podgląd parametrów po zmianie pól (bez zapisu)","parameters":[{"$ref":"#/components/parameters/id"}],"responses":{"200":{"description":"derived + wiringPath"}}}},"/api/patterns/{id}/product":{"post":{"tags":["Wzorce mikropaneli"],"summary":"Utworzenie produktu katalogowego z wzorca","parameters":[{"$ref":"#/components/parameters/id"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"price":{"type":"number"},"kind":{"type":"string","enum":["tile","seam"]}}}}}},"responses":{"200":{"description":"Produkt"}}}},"/api/products":{"get":{"tags":["Produkty"],"summary":"Katalog produktów","responses":{"200":{"description":"OK"}}},"post":{"tags":["Produkty"],"summary":"Nowy produkt","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Product"}}}},"responses":{"200":{"description":"OK"}}}},"/api/products/import":{"post":{"tags":["Produkty"],"summary":"Import produktów producenta (JSON lub CSV); upsert po id","requestBody":{"content":{"application/json":{"schema":{"oneOf":[{"type":"array","items":{"$ref":"#/components/schemas/Product"}},{"type":"object","properties":{"products":{"type":"array","items":{"$ref":"#/components/schemas/Product"}}}},{"type":"object","properties":{"csv":{"type":"string","description":"CSV z nagłówkiem: id;name;w;h;wp;voc;vmp;isc;imp;price;kind"}}}]}}}},"responses":{"200":{"description":"Raport importu {created, updated, errors[]}"}}}},"/api/products/{id}":{"put":{"tags":["Produkty"],"summary":"Edycja produktu","parameters":[{"$ref":"#/components/parameters/id"}],"responses":{"200":{"description":"OK"}}},"delete":{"tags":["Produkty"],"summary":"Usunięcie produktu","parameters":[{"$ref":"#/components/parameters/id"}],"responses":{"200":{"description":"OK"}}}},"/api/calculate":{"post":{"tags":["Wyliczenia"],"summary":"Pełne wyliczenie materiałowe i kalkulacja komponentów","description":"Geometria dachu z parametrów (roof) ALBO połacie z modelu 3D/GIS (slopes). Adres inwestycji (address) lub województwo (voivodeship) jest parametrem wejściowym – wyznacza strefy obciążeń i nasłonecznienie. Parametr ?format=csv|cutlist|modules zwraca eksport CSV. Dodatkowo lat/lon (lub region z geokodowania) włączają uzysk z PVGIS. Dane wejściowe są walidowane (400 z listą błędów w polu details). format=dxf – układ modułów (mm), format=dxf-profiles – odcinki profili z otworami. format=saw – lista pod piłę/CNC; format=dxf-electrical – schemat elektryczny (stringi, wiązki, falownik, AC). format=xlsx – skoroszyt (podsumowanie, BOM, cięcia/obróbka, rozkrój, moduły, stringi, wiązki, lista połączeń); svg-layout / svg-electrical – schematy graficzne SVG; connections / connections-csv – lista połączeń (dane strukturalne).","parameters":[{"name":"format","in":"query","schema":{"type":"string","enum":["json","xlsx","csv","cutlist","modules","saw","svg-layout","svg-electrical","connections","connections-csv","dxf","dxf-profiles","dxf-electrical"]}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CalcInput"},"examples":{"parametry":{"value":{"address":"ul. Puławska 427, Warszawa","roof":{"type":"dwuspadowy","length":12,"width":8,"pitch":35,"overhang":0.5,"azimuth":0,"pvSlopes":1,"rafterSpacing":0.8,"obstacles":[{"name":"komin","w":0.6,"h":0.6}]},"product":{"productId":"pv-tile-s","margin":0.3},"options":{"wastePct":3,"inverterDistance":15}}},"model3d":{"value":{"voivodeship":"mazowieckie","slopes":[{"id":"P1","polygon":[[0,0],[10,0],[10,4],[6,4],[6,6],[0,6]],"pitch":25,"azimuth":-30,"pv":true,"obstacles":[{"name":"okno","x":2,"y":2,"w":1,"h":1.2}],"edges":{"eave":10,"ridge":6,"gable":12}}],"product":{"productId":"pv-tile-m"}}}}}}},"responses":{"200":{"description":"Wynik: summary, slopes (układ modułów), profiles (rozkrój + obróbka), electrical (stringi, MPPT, wiązki, AC, zabezpieczenia), energy, economics, bom, warnings"},"400":{"description":"Błąd danych wejściowych"}}}},"/api/calculate/variants":{"post":{"tags":["Wyliczenia"],"summary":"Warianty rozmieszczenia (połacie, moc docelowa, produkt) do porównania","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CalcInput"}}}},"responses":{"200":{"description":"Lista wariantów z podsumowaniem"}}}},"/api/calculations":{"get":{"tags":["Historia"],"summary":"Lista zapisanych wyliczeń","responses":{"200":{"description":"OK"}}},"post":{"tags":["Historia"],"summary":"Zapis wyliczenia","responses":{"201":{"description":"Zapisano"}}}},"/api/calculations/{id}":{"get":{"tags":["Historia"],"summary":"Zapisane wyliczenie (wejście + pełny wynik)","parameters":[{"$ref":"#/components/parameters/id"},{"name":"format","in":"query","schema":{"type":"string"},"description":"eksport zapisanego wyniku: json | xlsx | csv | cutlist | modules | saw | svg-layout | svg-electrical | connections | connections-csv | dxf | dxf-profiles | dxf-electrical | pdf (oferta) | pdf-production (listy produkcyjne)"}],"responses":{"200":{"description":"OK"}}},"delete":{"tags":["Historia"],"summary":"Usunięcie","parameters":[{"$ref":"#/components/parameters/id"}],"responses":{"200":{"description":"OK"}}},"put":{"tags":["Historia"],"summary":"Edycja zapisanego wyliczenia / oferty: etykieta, projekt, status oferty, nadanie numeru (assignOfferNo)","parameters":[{"$ref":"#/components/parameters/id"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"label":{"type":"string"},"projectId":{"type":"string"},"offerStatus":{"type":"string","enum":["robocza","wysłana","zaakceptowana","odrzucona"]},"assignOfferNo":{"type":"boolean"}}}}}},"responses":{"200":{"description":"OK"}}}},"/api/auth/login":{"post":{"tags":["Uwierzytelnianie"],"summary":"Logowanie (ustawia cookie sesji)","requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["login","password"],"properties":{"login":{"type":"string"},"password":{"type":"string"}}}}}},"responses":{"200":{"description":"Użytkownik"},"401":{"description":"Błędne dane"}}}},"/api/auth/logout":{"post":{"tags":["Uwierzytelnianie"],"summary":"Wylogowanie","responses":{"200":{"description":"OK"}}}},"/api/auth/me":{"get":{"tags":["Uwierzytelnianie"],"summary":"Bieżący użytkownik","responses":{"200":{"description":"{user, engine}"}}}},"/api/auth/password":{"put":{"tags":["Uwierzytelnianie"],"summary":"Zmiana własnego hasła","responses":{"200":{"description":"OK"}}}},"/api/users":{"get":{"tags":["Uwierzytelnianie"],"summary":"Lista użytkowników (admin)","responses":{"200":{"description":"OK"}}},"post":{"tags":["Uwierzytelnianie"],"summary":"Nowy użytkownik (admin)","requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"login":{"type":"string"},"name":{"type":"string"},"role":{"type":"string","enum":["admin","technolog","handlowiec"]},"password":{"type":"string"}}}}}},"responses":{"200":{"description":"OK"}}}},"/api/users/{id}":{"put":{"tags":["Uwierzytelnianie"],"summary":"Edycja użytkownika / reset hasła (admin)","parameters":[{"$ref":"#/components/parameters/id"}],"responses":{"200":{"description":"OK"}}},"delete":{"tags":["Uwierzytelnianie"],"summary":"Usunięcie (admin)","parameters":[{"$ref":"#/components/parameters/id"}],"responses":{"200":{"description":"OK"}}}},"/api/projects":{"get":{"tags":["Projekty"],"summary":"Projekty z listą wyliczeń","responses":{"200":{"description":"OK"}}},"post":{"tags":["Projekty"],"summary":"Nowy projekt","requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["name"],"properties":{"name":{"type":"string"},"status":{"type":"string"},"address":{"type":"string"},"notes":{"type":"string"},"client":{"type":"object","properties":{"name":{"type":"string"},"phone":{"type":"string"},"email":{"type":"string"},"nip":{"type":"string"}}}}}}}},"responses":{"200":{"description":"OK"}}}},"/api/projects/{id}":{"get":{"tags":["Projekty"],"summary":"Projekt","parameters":[{"$ref":"#/components/parameters/id"}],"responses":{"200":{"description":"OK"}}},"put":{"tags":["Projekty"],"summary":"Edycja","parameters":[{"$ref":"#/components/parameters/id"}],"responses":{"200":{"description":"OK"}}},"delete":{"tags":["Projekty"],"summary":"Usunięcie (wyliczenia pozostają)","parameters":[{"$ref":"#/components/parameters/id"}],"responses":{"200":{"description":"OK"}}}},"/api/pvgis":{"get":{"tags":["Słowniki"],"summary":"Uzysk jednostkowy z PVGIS dla współrzędnych (wymaga internetu)","parameters":[{"name":"lat","in":"query","required":true,"schema":{"type":"number"}},{"name":"lon","in":"query","required":true,"schema":{"type":"number"}},{"name":"pitch","in":"query","schema":{"type":"number"}},{"name":"azimuth","in":"query","schema":{"type":"number"}}],"responses":{"200":{"description":"{kwhPerKwp, monthly[]}"},"502":{"description":"PVGIS niedostępny"}}}},"/api/apikeys":{"get":{"tags":["Integracje"],"summary":"Lista kluczy API (admin)","responses":{"200":{"description":"OK"}}},"post":{"tags":["Integracje"],"summary":"Nowy klucz API (admin) – klucz zwracany tylko raz","requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"role":{"type":"string","enum":["admin","technolog","handlowiec"]}}}}}},"responses":{"200":{"description":"{key, id, name, role}"}}}},"/api/apikeys/{id}":{"delete":{"tags":["Integracje"],"summary":"Unieważnienie klucza","parameters":[{"$ref":"#/components/parameters/id"}],"responses":{"200":{"description":"OK"}}}},"/api/jobs":{"get":{"tags":["Integracje"],"summary":"Lista zadań","responses":{"200":{"description":"OK"}}},"post":{"tags":["Integracje"],"summary":"Zlecenie wyliczenia asynchronicznego","description":"Ciało jak CalcInput + opcjonalne callbackUrl (POST JSON po zakończeniu: {jobId, reference, status, summary, resultUrl}; nagłówek X-Signature = HMAC-SHA256 z WEBHOOK_SECRET; 3 próby) i reference (identyfikator po stronie wywołującego).","responses":{"202":{"description":"{id, status, statusUrl}"},"400":{"description":"Błędy danych"}}}},"/api/jobs/{id}":{"get":{"tags":["Integracje"],"summary":"Status / wynik zadania; ?format= jak w /api/calculate","parameters":[{"$ref":"#/components/parameters/id"},{"name":"format","in":"query","schema":{"type":"string"}}],"responses":{"200":{"description":"Zadanie z wynikiem"},"404":{"description":"Brak"}}}},"/api/map/image":{"get":{"tags":["Dach ze zdjęcia"],"summary":"Kafelek ortofotomapy (Geoportal PZGIK → Esri) wokół współrzędnych; ?meta=1 zwraca metadane","parameters":[{"name":"lat","in":"query","required":true,"schema":{"type":"number"}},{"name":"lon","in":"query","required":true,"schema":{"type":"number"}},{"name":"size","in":"query","schema":{"type":"number","default":60},"description":"bok kafelka [m]"},{"name":"px","in":"query","schema":{"type":"integer","default":512}},{"name":"provider","in":"query","schema":{"type":"string","enum":["auto","geoportal","esri"]}}],"responses":{"200":{"description":"image/png (nagłówki X-Map-Provider, X-Map-Mpp, X-Map-Attribution)"},"502":{"description":"źródło niedostępne"}}}},"/api/map/buildings":{"get":{"tags":["Dach ze zdjęcia"],"summary":"Obrysy budynków OSM (Overpass) w pikselach kafelka i metrach","parameters":[{"name":"lat","in":"query","required":true,"schema":{"type":"number"}},{"name":"lon","in":"query","required":true,"schema":{"type":"number"}},{"name":"size","in":"query","schema":{"type":"number"}},{"name":"px","in":"query","schema":{"type":"integer"}}],"responses":{"200":{"description":"{buildings[], attribution}"}}}},"/api/map/segment":{"post":{"tags":["Dach ze zdjęcia"],"summary":"Segmentacja k-średnich i obrys dachu z punktu startowego","requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["width","height"],"properties":{"width":{"type":"integer"},"height":{"type":"integer"},"rgba":{"type":"string","description":"base64 RGBA"},"png":{"type":"string","description":"base64 PNG (8-bit)"},"seed":{"type":"array","items":{"type":"number"}},"k":{"type":"integer","default":6},"tolerance":{"type":"number","default":0.12},"morphRadius":{"type":"integer","default":2},"epsilonPx":{"type":"number","default":2.5},"xyWeight":{"type":"number","default":0.15},"metersPerPixel":{"type":"number"},"reference":{"type":"array","description":"wielokąt referencyjny [px] do IoU"}}}}}},"responses":{"200":{"description":"{segments, areaPx, areaM2, contour, orthogonal, rect, rectM, compactness, iouReference, maskRle, timeMs}"}}}},"/api/map/building":{"post":{"tags":["Dach ze zdjęcia"],"summary":"Obrys [px] + skala → parametry dachu (z azymutem), połacie, bryła 3D; ?format=obj|slopes","requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["outline","metersPerPixel"],"properties":{"outline":{"type":"array"},"rect":{"type":"object"},"metersPerPixel":{"type":"number"},"type":{"type":"string","enum":["dwuspadowy","kopertowy","jednospadowy"]},"pitch":{"type":"number"},"wallHeight":{"type":"number"},"overhang":{"type":"number"},"name":{"type":"string"}}}}}},"responses":{"200":{"description":"{roof, slopes, azimuth, bearingRidge, dims, outlineM, warnings, mesh}"}}}},"/api/map/batch":{"post":{"tags":["Dach ze zdjęcia"],"summary":"Test wsadowy listy adresów (zadanie asynchroniczne): geokodowanie → ortofoto → segmentacja → bryła; IoU z OSM, czasy","requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["addresses"],"properties":{"addresses":{"type":"array","items":{"type":"string"}},"sizeM":{"type":"number"},"px":{"type":"integer"},"callbackUrl":{"type":"string"}}}}}},"responses":{"202":{"description":"{id, statusUrl}"}}}},"/api/map/providers":{"get":{"tags":["Dach ze zdjęcia"],"summary":"Dostawcy kafelków mapy (esri, osm, geoportal WMTS, test)","responses":{"200":{"description":"OK"}}}},"/api/map/tile/{provider}/{z}/{x}/{y}":{"get":{"tags":["Dach ze zdjęcia"],"summary":"Kafelek XYZ 256 px przez serwer (cache); provider=test generuje świat testowy offline","parameters":[{"name":"provider","in":"path","required":true,"schema":{"type":"string"}},{"name":"z","in":"path","required":true,"schema":{"type":"integer"}},{"name":"x","in":"path","required":true,"schema":{"type":"integer"}},{"name":"y","in":"path","required":true,"schema":{"type":"integer"}}],"responses":{"200":{"description":"image/png lub image/jpeg"},"502":{"description":"dostawca niedostępny"}}}},"/api/map/test-world":{"get":{"tags":["Dach ze zdjęcia"],"summary":"Środek i obrysy referencyjne budynków świata testowego","responses":{"200":{"description":"OK"}}}},"/api/geocode/reverse":{"get":{"tags":["Słowniki"],"summary":"Współrzędne → adres i województwo (Nominatim)","parameters":[{"name":"lat","in":"query","required":true,"schema":{"type":"number"}},{"name":"lon","in":"query","required":true,"schema":{"type":"number"}}],"responses":{"200":{"description":"OK"}}}},"/api/calculations/{id}/email":{"post":{"tags":["Historia"],"summary":"Wyślij ofertę PDF e‑mailem do klienta projektu (wymaga konfiguracji SMTP)","parameters":[{"$ref":"#/components/parameters/id"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"to":{"type":"string","description":"adres (domyślnie e‑mail klienta projektu)"},"withProduction":{"type":"boolean"},"message":{"type":"string"}}}}}},"responses":{"200":{"description":"{sent:true, to}"},"400":{"description":"brak SMTP / adresu"}}}},"/api/bookings":{"get":{"tags":["Terminarz"],"summary":"Lista terminów (wizyty, montaże, serwis)","parameters":[{"name":"from","in":"query","schema":{"type":"string","format":"date-time"}},{"name":"to","in":"query","schema":{"type":"string","format":"date-time"}},{"name":"projectId","in":"query","schema":{"type":"string"}}],"responses":{"200":{"description":"OK"}}},"post":{"tags":["Terminarz"],"summary":"Nowy termin (kolizje odrzucane, force=true wymusza)","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Booking"}}}},"responses":{"200":{"description":"OK"}}}},"/api/bookings/slots":{"get":{"tags":["Terminarz"],"summary":"Wolne sloty wg ustawień terminarza","parameters":[{"name":"days","in":"query","schema":{"type":"integer"}}],"responses":{"200":{"description":"OK"}}}},"/api/bookings/{id}":{"put":{"tags":["Terminarz"],"summary":"Edycja terminu","parameters":[{"$ref":"#/components/parameters/id"}],"responses":{"200":{"description":"OK"}}},"delete":{"tags":["Terminarz"],"summary":"Usunięcie terminu","parameters":[{"$ref":"#/components/parameters/id"}],"responses":{"200":{"description":"OK"}}}},"/api/admin/mail-test":{"post":{"tags":["Administracja"],"summary":"Wysyłka testowej wiadomości SMTP (admin)","requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"to":{"type":"string"}}}}}},"responses":{"200":{"description":"OK"}}}},"/api/admin/backups":{"get":{"tags":["Administracja"],"summary":"Lista kopii zapasowych (data/backups, codziennie, 14 ostatnich)","responses":{"200":{"description":"OK"}}},"post":{"tags":["Administracja"],"summary":"Wykonaj kopię teraz","responses":{"200":{"description":"OK"}}}},"/api/admin/backups/{file}":{"get":{"tags":["Administracja"],"summary":"Pobierz plik kopii","parameters":[{"name":"file","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"OK"}}}},"/api/public/info":{"get":{"tags":["Formularz publiczny"],"security":[],"summary":"Ustawienia formularza dla klienta końcowego (bez logowania): firma, motyw, produkty, pytanie kontrolne","responses":{"200":{"description":"OK"}}}},"/api/public/slots":{"get":{"tags":["Formularz publiczny"],"security":[],"summary":"Wolne terminy wizyt (bez logowania)","responses":{"200":{"description":"OK"}}}},"/api/public/lead":{"post":{"tags":["Formularz publiczny"],"security":[],"summary":"Zgłoszenie klienta: tworzy projekt (źródło www), wyliczenie, opcjonalną rezerwację; zwraca wstępną wycenę ±15 %. Limit 5/10 min/IP, zgoda RODO i pytanie kontrolne wymagane.","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Lead"}}}},"responses":{"200":{"description":"{projectId, estimate:{kwp,pvCount,annualKwh,priceFrom,priceTo,paybackYears}, booking}"},"400":{"description":"walidacja"},"429":{"description":"limit zgłoszeń"}}}},"/api/projects/{id}/log":{"post":{"tags":["Projekty"],"summary":"Wpis do dziennika kontaktu (telefon, e-mail, spotkanie, notatka)","parameters":[{"$ref":"#/components/parameters/id"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["text"],"properties":{"kind":{"type":"string"},"text":{"type":"string"},"at":{"type":"string","format":"date-time"}}}}}},"responses":{"200":{"description":"OK"}}}},"/api/dashboard":{"get":{"tags":["Pulpit"],"summary":"KPI: zgłoszenia, oferty, konwersja, kWp zaakceptowane, terminy, projekty bez kontaktu, tygodniowe serie (8 tyg.)","responses":{"200":{"description":"OK"}}}},"/api/bookings/ics":{"get":{"tags":["Terminarz"],"summary":"Eksport terminarza do pliku iCalendar (.ics)","responses":{"200":{"description":"OK"}}}},"/api/bookings/ics-token":{"post":{"tags":["Terminarz"],"summary":"Generuje tajny adres kanału kalendarza (admin)","responses":{"200":{"description":"OK"}}}},"/api/public/calendar/{token}.ics":{"get":{"tags":["Formularz publiczny"],"security":[],"summary":"Kanał iCalendar do subskrypcji (Google/Outlook/iPhone)","parameters":[{"name":"token","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"OK"}}}},"/api/public/offer/{token}":{"get":{"tags":["Formularz publiczny"],"security":[],"summary":"Oferta online dla klienta (dane do strony /oferta/{token})","parameters":[{"name":"token","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"OK"}}}},"/api/public/offer/{token}/pdf":{"get":{"tags":["Formularz publiczny"],"security":[],"summary":"PDF oferty dla klienta","parameters":[{"name":"token","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"OK"}}}},"/api/public/offer/{token}/decision":{"post":{"tags":["Formularz publiczny"],"security":[],"summary":"Akceptacja / odrzucenie oferty przez klienta (zmienia status oferty i projektu, wpis do dziennika, e‑mail do firmy)","parameters":[{"name":"token","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["decision"],"properties":{"decision":{"type":"string","enum":["zaakceptowana","odrzucona"]},"name":{"type":"string"},"consent":{"type":"boolean"},"note":{"type":"string"}}}}}},"responses":{"200":{"description":"OK"},"409":{"description":"już zaakceptowana"}}}}},"components":{"parameters":{"id":{"name":"id","in":"path","required":true,"schema":{"type":"string"}}},"schemas":{"Pattern":{"type":"object","required":["name","cellRows","cellCols","cellW","cellH","cell"],"properties":{"id":{"type":"string"},"name":{"type":"string"},"description":{"type":"string"},"cellRows":{"type":"integer"},"cellCols":{"type":"integer"},"cellW":{"type":"number","description":"mm"},"cellH":{"type":"number","description":"mm"},"cellGap":{"type":"number"},"frame":{"type":"object","properties":{"top":{"type":"number"},"bottom":{"type":"number"},"left":{"type":"number"},"right":{"type":"number"}}},"cell":{"type":"object","properties":{"wp":{"type":"number"},"voc":{"type":"number"},"vmp":{"type":"number"},"isc":{"type":"number"},"imp":{"type":"number"},"tempCoeffVoc":{"type":"number"}}},"parallelGroups":{"type":"integer"},"bypassDiodes":{"type":"integer"},"wiring":{"type":"string","enum":["serpentine","rows"]},"connector":{"type":"object","properties":{"type":{"type":"string"},"position":{"type":"string"}}},"weightPerM2":{"type":"number"}}},"Product":{"type":"object","required":["id","name","w","h","wp","voc","vmp","isc","imp"],"properties":{"id":{"type":"string"},"name":{"type":"string"},"patternId":{"type":"string"},"kind":{"type":"string","enum":["tile","seam"]},"w":{"type":"number","description":"mm"},"h":{"type":"number","description":"mm"},"wp":{"type":"number"},"voc":{"type":"number"},"vmp":{"type":"number"},"isc":{"type":"number"},"imp":{"type":"number"},"tempCoeffVoc":{"type":"number"},"weight":{"type":"number"},"price":{"type":"number"}}},"Obstacle":{"type":"object","properties":{"name":{"type":"string"},"x":{"type":"number"},"y":{"type":"number"},"w":{"type":"number"},"h":{"type":"number"}}},"Roof":{"type":"object","properties":{"type":{"type":"string","enum":["jednospadowy","dwuspadowy","kopertowy"]},"length":{"type":"number"},"width":{"type":"number"},"pitch":{"type":"number"},"overhang":{"type":"number"},"azimuth":{"type":"number","description":"0 = S, 90 = W/E, 180 = N"},"pvSlopes":{"type":"integer"},"rafterSpacing":{"type":"number"},"obstacles":{"type":"array","items":{"$ref":"#/components/schemas/Obstacle"}}}},"Slope":{"type":"object","required":["polygon"],"properties":{"id":{"type":"string"},"name":{"type":"string"},"polygon":{"type":"array","items":{"type":"array","items":{"type":"number"}},"description":"Wierzchołki w układzie połaci [m]: x wzdłuż okapu, y w górę połaci"},"pitch":{"type":"number"},"azimuth":{"type":"number"},"pv":{"type":"boolean"},"obstacles":{"type":"array","items":{"$ref":"#/components/schemas/Obstacle"}},"edges":{"type":"object","properties":{"eave":{"type":"number"},"ridge":{"type":"number"},"gable":{"type":"number"},"hip":{"type":"number"}}}}},"CalcInput":{"type":"object","properties":{"address":{"type":"string"},"voivodeship":{"type":"string"},"roof":{"$ref":"#/components/schemas/Roof"},"slopes":{"type":"array","items":{"$ref":"#/components/schemas/Slope"}},"product":{"type":"object","properties":{"productId":{"type":"string"},"margin":{"type":"number"},"targetKwp":{"type":"number"}}},"options":{"type":"object","properties":{"wastePct":{"type":"number"},"inverterDistance":{"type":"number"},"acDistance":{"type":"number"},"inverterId":{"type":"string"},"shadingLoss":{"type":"number"},"maxDropPct":{"type":"number"},"usePvgis":{"type":"boolean","default":true},"railSplicing":{"type":"boolean","default":true}}},"prices":{"type":"object","description":"Nadpisanie pozycji cennika"},"lat":{"type":"number","description":"Szerokość geograficzna (z geokodowania) – włącza PVGIS"},"lon":{"type":"number"},"callbackUrl":{"type":"string","description":"tylko /api/jobs"},"reference":{"type":"string","description":"tylko /api/jobs"}}},"Booking":{"type":"object","required":["start"],"properties":{"start":{"type":"string","format":"date-time"},"end":{"type":"string","format":"date-time"},"type":{"type":"string","enum":["wizyta","montaż","serwis","inne"]},"status":{"type":"string","enum":["zaplanowane","potwierdzone","zakończone","odwołane"]},"projectId":{"type":"string"},"client":{"type":"object"},"address":{"type":"string"},"notes":{"type":"string"},"force":{"type":"boolean"}}},"Lead":{"type":"object","required":["name","phone","address","consent","antispam","captcha"],"properties":{"name":{"type":"string"},"phone":{"type":"string"},"email":{"type":"string"},"address":{"type":"string"},"voivodeship":{"type":"string"},"roofType":{"type":"string"},"length":{"type":"number"},"width":{"type":"number"},"pitch":{"type":"number"},"azimuth":{"type":"number"},"productId":{"type":"string"},"notes":{"type":"string"},"slot":{"type":"string","format":"date-time"},"consent":{"type":"boolean"},"antispam":{"type":"string"},"captcha":{"type":"string","description":"token z GET /api/public/info (question.token); odpowiedź w antispam"}}}}}}