Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7469e58a89 | ||
|
|
70fe14ae39 | ||
|
|
16b45cec41 | ||
|
|
82854785a0 | ||
|
|
14ca71a41c | ||
|
|
a630faea4c | ||
|
|
5936b4dbe2 | ||
|
|
84ffc1c3e3 | ||
|
|
f764f253a9 | ||
|
|
7872ba8cfb | ||
|
|
2304f323b3 | ||
|
|
fbb0c475d0 | ||
|
|
97ffe547ae | ||
|
|
ce5a5d83dc | ||
|
|
8c6fb8b39e | ||
|
|
3d7b3edf49 | ||
|
|
572b2a05c8 | ||
|
|
2ebd13c100 | ||
|
|
739a8c59eb | ||
|
|
15ec6da083 | ||
|
|
e30f41de68 | ||
|
|
3cb58b9f0f | ||
|
|
1393fc465c | ||
|
|
0edb7059c8 | ||
|
|
03e54ad552 | ||
|
|
b2470d80ed | ||
|
|
eb84a72c2f | ||
|
|
fdd2200ae2 | ||
|
|
1888dd6cf3 | ||
|
|
d75144a6ac | ||
|
|
446af2e9b5 | ||
|
|
9a75b02d1a | ||
|
|
d5f8b148b4 | ||
|
|
199e834227 | ||
|
|
1306c43740 | ||
|
|
8ca38f1806 | ||
|
|
621a0cf90d | ||
|
|
799a46f53c | ||
|
|
3b5afba8a1 |
No files matched your search
@@ -5,6 +5,13 @@
|
|||||||
DATA_GO_KR_SERVICE_KEY=
|
DATA_GO_KR_SERVICE_KEY=
|
||||||
# 행사 수집(7일마다) 완료 알림 — Microsoft Teams Workflows 수신 webhook. 비우면 보내지 않는다.
|
# 행사 수집(7일마다) 완료 알림 — Microsoft Teams Workflows 수신 webhook. 비우면 보내지 않는다.
|
||||||
TEAMS_WEBHOOK_URL=
|
TEAMS_WEBHOOK_URL=
|
||||||
|
# 관리자 도구(admin/)가 카드뉴스를 올릴 때 쓰는 비밀값. 백엔드와 admin 이 같은 값을 쓴다. 비우면 관리자 API 는 막힌다.
|
||||||
|
ADMIN_API_KEY=
|
||||||
|
# 인스타그램 올리기 (프로페셔널 계정 + Meta 앱 'Instagram API with Instagram Login'). 비우면 '인스타에 올리기'가 막힌다.
|
||||||
|
INSTAGRAM_ACCESS_TOKEN=
|
||||||
|
INSTAGRAM_USER_ID=
|
||||||
|
# 인스타가 카드 이미지를 받아 갈 공개 주소
|
||||||
|
PUBLIC_BASE_URL=https://weather.o2o.kr
|
||||||
IMAGE_PROXY_HOSTS=tong.visitkorea.or.kr,www.culture.go.kr,culture.seoul.go.kr
|
IMAGE_PROXY_HOSTS=tong.visitkorea.or.kr,www.culture.go.kr,culture.seoul.go.kr
|
||||||
|
|
||||||
# ── 백엔드: DB·Redis (네이티브 실행 기준. compose 안에서는 compose.yaml 이 host·port 를 덮어쓴다)
|
# ── 백엔드: DB·Redis (네이티브 실행 기준. compose 안에서는 compose.yaml 이 host·port 를 덮어쓴다)
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
# Product
|
||||||
|
|
||||||
|
<!-- impeccable:product-schema 1 -->
|
||||||
|
|
||||||
|
## Platform
|
||||||
|
|
||||||
|
web
|
||||||
|
|
||||||
|
## Users
|
||||||
|
|
||||||
|
휴대폰으로 오늘·내일 뭘 할지 정하려는 2040 일반인. 아침이나 외출 전에 잠깐 열어 봐요.
|
||||||
|
|
||||||
|
## Product Purpose
|
||||||
|
|
||||||
|
동네(구) 날씨를 '빨래각·소맥각' 같은 활동 점수로 바꿔 보여 줘요. 피드로 훑어보고 친구에게 보내요.
|
||||||
|
|
||||||
|
## Positioning
|
||||||
|
|
||||||
|
날씨 숫자가 아니라 '지금 ○○하기 좋은지'를 알려 주고, 귀엽고 공유하고 싶은 카드로 보여 줘요.
|
||||||
|
|
||||||
|
## Constraints
|
||||||
|
|
||||||
|
- 모바일 웹 우선(토스 미니앱, 홈 화면 추가).
|
||||||
|
- 로그인은 글쓰기에만 요구해요.
|
||||||
|
- 화면 문구는 반말 없는 '해요'체예요.
|
||||||
@@ -66,6 +66,9 @@
|
|||||||
| [ ] | '○○구 내일 날씨' 검색 태깅 — 스위치 뒤 내용은 눌러야 보여 구글이 읽는지 공식 문서로 확인 필요. 구 페이지(SEO)에 내일 기온·습도 넣는 안과 비교 | 10/21 회의 결정 | `backend/router/v1/seo/` |
|
| [ ] | '○○구 내일 날씨' 검색 태깅 — 스위치 뒤 내용은 눌러야 보여 구글이 읽는지 공식 문서로 확인 필요. 구 페이지(SEO)에 내일 기온·습도 넣는 안과 비교 | 10/21 회의 결정 | `backend/router/v1/seo/` |
|
||||||
| [x] | **운영 DB 반영(10/21 배포 때 init.sql로 적용 확인)** — 댓글 표 `user_id` NULL 허용, `ip_hash`·`region_name` 칸, `idx_comment_ip` (init.sql에 추가, 로컬만 적용). 배포 전에 운영에 ALTER 실행 (운영 영향, 확인 받고) | 익명 댓글 | `backend/postgres-init/init.sql` |
|
| [x] | **운영 DB 반영(10/21 배포 때 init.sql로 적용 확인)** — 댓글 표 `user_id` NULL 허용, `ip_hash`·`region_name` 칸, `idx_comment_ip` (init.sql에 추가, 로컬만 적용). 배포 전에 운영에 ALTER 실행 (운영 영향, 확인 받고) | 익명 댓글 | `backend/postgres-init/init.sql` |
|
||||||
| [ ] | **[결정 필요]** 새 화면 문구 검토: '보냈어요. 링크도 복사해 뒀어요', '글쓰기는 로그인한 뒤에 할 수 있어요.', '오늘'/'내일', '내일 낮 날씨 점수', '내일은 ○○각!'/'내일은 쉬어 가요', '최저'/'최고'/'습도', 익명 이름 '마포구 익명', 단풍 지도 '단풍 전'/'첫 단풍'/'절정'/'단풍'/'은행', '가까운 예측 지점 날짜예요', '지금 절정 ○곳: … 외' | 화면 문구 규칙 | `frontend/src/b/TodayPage.tsx`, `frontend/src/b/Sheets.tsx` |
|
| [ ] | **[결정 필요]** 새 화면 문구 검토: '보냈어요. 링크도 복사해 뒀어요', '글쓰기는 로그인한 뒤에 할 수 있어요.', '오늘'/'내일', '내일 낮 날씨 점수', '내일은 ○○각!'/'내일은 쉬어 가요', '최저'/'최고'/'습도', 익명 이름 '마포구 익명', 단풍 지도 '단풍 전'/'첫 단풍'/'절정'/'단풍'/'은행', '가까운 예측 지점 날짜예요', '지금 절정 ○곳: … 외' | 화면 문구 규칙 | `frontend/src/b/TodayPage.tsx`, `frontend/src/b/Sheets.tsx` |
|
||||||
|
| [ ] | 단풍 지도 페이지(`/foliage`) 검색 등록 — 사이트맵 추가, 미리 그린 HTML(제목·설명), 공식 문서로 확인 후 | 페이지 따로 만든 이유(공유·검색), 사용자 10/23 | `backend/services/seo_service.py`, `frontend/src/b/FoliagePage.tsx` |
|
||||||
|
| [ ] | 단풍 지도 그림 고해상도로 다시(지금 1024px라 확대하면 흐림) — Codex | 단풍 지도 페이지 확대 | `frontend/public/foliage/korea-map.webp` |
|
||||||
|
| [ ] | **[결정 필요]** 단풍 지도 페이지 문구: '단풍 절정'/'은행 절정', '지도 크게 보기 ›', '지금 절정'/'곧 절정'/'아직'/'절정 지남', '전체'/'단풍'/'은행', '절정 예상'/'가까운 지점 날짜', '링크를 복사했어요' | 화면 문구 규칙 | `frontend/src/b/FoliagePage.tsx`, `frontend/src/b/foliageMap.tsx` |
|
||||||
| [ ] | 익명 댓글이 링크·하루 제한에 걸려도 '댓글을 올리지 못했어요'만 나옴 — 이유별 안내 | 익명 댓글 작업 중 발견 | `frontend/src/b/Sheets.tsx` |
|
| [ ] | 익명 댓글이 링크·하루 제한에 걸려도 '댓글을 올리지 못했어요'만 나옴 — 이유별 안내 | 익명 댓글 작업 중 발견 | `frontend/src/b/Sheets.tsx` |
|
||||||
| [ ] | 매일 대표에게 진행 보고 (미완료 포함) | 10/21 회의 결정 | |
|
| [ ] | 매일 대표에게 진행 보고 (미완료 포함) | 10/21 회의 결정 | |
|
||||||
|
|
||||||
@@ -228,3 +231,39 @@
|
|||||||
| [x] | 내가 쓴 글 모아 보기 없음 → 내 정보 창에 '내 글' 목록(10/21) — 새로고침하면 위 고정이 풀리고 전국 최신순에 섞여 6개 안에 못 들면 못 찾음. 내 정보 창에 '내 글' 목록을 둘지 | 피드 정렬 점검 (10/21) | `backend/crud/talk_crud.py`, `frontend/src/b/Sheets.tsx:870` |
|
| [x] | 내가 쓴 글 모아 보기 없음 → 내 정보 창에 '내 글' 목록(10/21) — 새로고침하면 위 고정이 풀리고 전국 최신순에 섞여 6개 안에 못 들면 못 찾음. 내 정보 창에 '내 글' 목록을 둘지 | 피드 정렬 점검 (10/21) | `backend/crud/talk_crud.py`, `frontend/src/b/Sheets.tsx:870` |
|
||||||
| [x] | 사람 글 정렬이 전국 최신순뿐 → 같은 시도 글 12시간 앞당김, 같은 사람 연속 금지(10/21) — 우리 동네 글 우선 없음, 한 사람이 하루 5개 쓰면 피드 사람 글 칸을 거의 다 차지함 | 피드 정렬 점검 (10/21) | `backend/crud/talk_crud.py:27` |
|
| [x] | 사람 글 정렬이 전국 최신순뿐 → 같은 시도 글 12시간 앞당김, 같은 사람 연속 금지(10/21) — 우리 동네 글 우선 없음, 한 사람이 하루 5개 쓰면 피드 사람 글 칸을 거의 다 차지함 | 피드 정렬 점검 (10/21) | `backend/crud/talk_crud.py:27` |
|
||||||
| [ ] | **[결정 필요]** 내 글 문구 검토 — '내 글', '아직 쓴 글이 없어요', '더 보기'를 확인받지 않고 넣음 | 피드 정렬 개선 (10/21) | `frontend/src/b/talk.tsx` `MyTalks` |
|
| [ ] | **[결정 필요]** 내 글 문구 검토 — '내 글', '아직 쓴 글이 없어요', '더 보기'를 확인받지 않고 넣음 | 피드 정렬 개선 (10/21) | `frontend/src/b/talk.tsx` `MyTalks` |
|
||||||
|
|
||||||
|
## 인스타 홍보 (10/20 기획)
|
||||||
|
|
||||||
|
| 상태 | 할 일 | 이유 | 관련 파일 |
|
||||||
|
|---|---|---|---|
|
||||||
|
| [ ] | **[결정 필요]** 인스타 계정 이름·화자 — 토끼·곰 캐릭터를 말하는 사람으로 쓸지 | 인스타 홍보 기획 | `docs/인스타_홍보_기획.html` |
|
||||||
|
| [ ] | **[결정 필요]** '오늘의 각' 카드 기준 지역 — 서울만 / 서울·부산 2장 / 시도별 | 전국 계정인데 각은 동네마다 다름 | `docs/인스타_홍보_기획.html` |
|
||||||
|
| [ ] | **[결정 필요]** '화제 × 날씨'에 쓰지 않을 주제 목록과 올리기 전 검토 담당 | 역풍 위험 (사고·재난·정치·연예인 사생활) | `docs/인스타_홍보_기획.html` |
|
||||||
|
| [ ] | **[결정 필요]** 날씨 타로 카드 앞면 그림(날씨별 한 벌) 제작 담당 — 4주 실험, 보내기·저장·댓글이 계정 평균 못 넘으면 중단 | 운세 결합 판단 (10/20 띠별 대신 타로로 결정) | `docs/인스타_홍보_기획.html` |
|
||||||
|
| [ ] | **[결정 필요]** 인스타 카드 자동 생성 — 공유 이미지 카드를 4:5로 뽑는 기능을 만들지, 처음엔 사람이 만들지 | 매일 게시 비용 | `docs/인스타_홍보_기획.html` |
|
||||||
|
| [ ] | **[결정 필요]** 오늘의 OOTD(아침 카드 2장째) — 캐릭터 옷 그림을 기온 구간별로 한 벌 만들 담당과 구간 기준 (히어로 일교차 '아침엔 겉옷'·주말 옷차림 팁과 같은 기준을 쓸지) | 10/20 OOTD 추가 결정 | `docs/인스타_홍보_기획.html`, `backend/services/hero_stats.py`, `backend/services/weekend_plan.py` |
|
||||||
|
| [ ] | 인스타 매일 자동 생성 — `admin/`이 예보 갱신 직후 날씨각 API에서 각 순위·기온·OOTD 구간을 HTML 틀에 넣어 JPEG(4:5)로 저장, 그림은 미리 만든 한 벌 재사용 (10/20 사용자 결정: 자동 생성 + 승인 + 자동 게시, 저장소 안 관리자 프로젝트 `admin/`의 기능 하나, API는 공용) | 인스타 홍보 7장 | `admin/`, `docs/인스타_홍보_기획.html` |
|
||||||
|
| [ ] | `admin/` 관리자 화면 — (10/21 됨: 인스타 카드 미리보기·문구 수정·JPEG 내려받기, `npm run card` 대화용 명령, 템플릿 3종) 남은 것: 매일 자동 생성 저장·승인/반려·게시 결과, 관리자 로그인(지금은 로그인 없이 로컬에서만), 배포(compose). 10/21 추가로 됨: 지역 콘텐츠 제거(오늘의 각 템플릿 삭제, 서울 예보 기준), 코디 6명, Claude 주제 기획·피드백 재기획(웹·`npm run card --topic`) | 인스타 홍보 7장 | `admin/`, `docs/인스타_홍보_기획.html` |
|
||||||
|
| [ ] | `admin/` 인스타 API 자동 게시 — 승인된 게시물을 정한 시각에 게시, 승인 마감까지 승인 없으면 게시 안 함. 이미지는 공개 주소에 JPEG | 인스타 홍보 7장 | `docs/인스타_홍보_기획.html` |
|
||||||
|
| [ ] | **[결정 필요]** 매일 승인 담당자·승인 마감 시각·게시 시각, 프로페셔널 계정 전환과 Meta 앱 생성 담당(우리 계정만 쓸 때 앱 검수 필요한지 확인) | 인스타 홍보 7장 | `docs/인스타_홍보_기획.html` |
|
||||||
|
| [ ] | **[결정 필요]** 인스타 카드 기본 문구 검토 — 템플릿 3종(`admin/src/cards/templates.tsx` `defaults`)의 기본 문구와 OOTD 기온 구간·옷 이름(`admin/src/cards/ootd.ts`)이 아직 검토 전. 타로 결과 장 문장은 '각 요약 + ○○이 가장 좋아요'라 세 장이 비슷하게 나올 수 있음 | 관리자 프로젝트 첫 구현 (10/21) | `admin/src/cards/templates.tsx`, `admin/src/cards/ootd.ts` |
|
||||||
|
| [x] | OOTD 옷 그림 — 지금은 낮 최고 17~22도 구간 한 장만 있음, 나머지 6구간은 옷 이름만 나감. Codex로 구간별 플랫레이(사람·얼굴 없이) 생성 → 10/21 프롬프트 템플릿(`admin/image-prompts/ootd.json`) + `npm run gen-image`로 7구간 모두 생성, 그림이 있으면 카드에 자동으로 붙음 | 관리자 프로젝트 첫 구현 (10/21) | `admin/src/assets/`, `admin/src/cards/ootd.ts` |
|
||||||
|
| [ ] | 코디 그림 6명 × 7구간(42장) 중 7장만 있음 — 오늘 구간(12~16도) 5장은 Codex 사용 한도로 실패(10/21 14:36 이후 가능). `cd admin && npm run gen-image -- ootd missing` | 코디 6명 나누기 (10/21) | `admin/image-prompts/ootd.json`, `admin/src/assets/ootd/` |
|
||||||
|
| [ ] | 전국 노을 랭킹·주말 나들이 랭킹 템플릿 — 백엔드 API 있음(`/v1/sky/ranking`, `/v1/week/ranking`, 대표 30곳). 디자인은 Codex로, 그 시기에 뜨는 템플릿이 먼저 보이게 | 사용자 요청 (10/21) | `admin/src/cards/templates.tsx`, `backend/router/v1/sky/sky.py`, `backend/router/v1/week/week.py` |
|
||||||
|
| [ ] | **[결정 필요]** 전국 단풍 랭킹 — 백엔드에 전국 단풍 순위 데이터가 없음. 데이터 출처(산림청·기상청 단풍 시기, 단풍각 점수로 대표 30곳 계산 등) 결정 필요 | 사용자 요청 (10/21) | `backend/` |
|
||||||
|
| [ ] | 관리자 '날씨각·인스타에 올리기' 버튼 — 10/23 날씨각 쪽 됨: 카드뉴스 포스트 타입 16·`card_set`/`card_image` 테이블·`/v1/card` API(X-Admin-Key)·피드 이미지 슬라이드·관리자 '지금 올리기/승인 대기로 저장'·`npm run card --post/--post-wait`. 10/23 운영 반영: main 병합·킹서버 배포·`ADMIN_API_KEY` 설정, 관리자에서 로컬·킹서버 골라 올리기. 인스타는 토큰만 넣으면 됨(인스타 연결 행) | 사용자 요청 (10/21) | `admin/src/pages/CardsPage.tsx`, `backend/router/v1/feed/` |
|
||||||
|
| [ ] | 주제별 타로 카드 뒷면 5장(하트·동전·별·클로버·반짝이) — 프롬프트 템플릿 `admin/image-prompts/tarot.json` 준비됨, Codex 한도 풀리면(10/21 14:36~) `cd admin && npm run gen-image -- tarot missing`. 생기면 카드에 자동으로 붙음 | 주제 베리에이션 (10/21) | `admin/image-prompts/tarot.json`, `admin/src/assets/tarot/` |
|
||||||
|
| [x] | 인스타 연결 — 계정 @nalssigak(BUSINESS), Meta 앱 토큰·계정 ID를 로컬 `~/projects/o2o-weather/.env`와 킹서버 `.env`에 넣고 백엔드 재생성(10/23). 관리자 '인스타에 올리기'로 킹서버 카드 1 → 인스타 미디어 18240295243316450 게시 성공. 남은 것: 토큰 60일 갱신(`GET /refresh_access_token?grant_type=ig_refresh_token`, 만료 2026-12-22쯤) 자동화 | 사용자 요청 (10/23) | `backend/services/external/instagram.py` |
|
||||||
|
| [ ] | **[결정 필요]** 인스타 카드 매일 자동화(서버) — 흐름: 매일 아침 서버가 Claude 기획(Claude Code 플랜, `claude setup-token` 토큰) → 카드 이미지까지 생성 → Teams 채널에 미리보기 카드(Workflows 웹훅 + Adaptive Card, 승인 / 고치기 버튼은 우리 서버 링크 — 그날 게시물에만 통하고 기한 지나면 막힘, 이미지는 공개 주소 필요) → 승인 시 정한 시각에 인스타·날씨각 업로드 → 성과 추적. 마감까지 승인 없으면 올리지 않음. 정할 것: 알림 받을 Teams 채널·Workflows 웹훅 만들 계정(만든 사람 소유라 공용 계정 권장)·생성/마감/게시 시각, 서버에 Claude Code CLI·Chrome·admin 설치(운영 변경, 확인 받고), 플랜 토큰을 서버 자동 실행에 쓰는 것이 약관상 괜찮은지 확인 | 사용자 제안 (10/21) | `admin/`, `backend/scheduler/` |
|
||||||
|
| [ ] | 기존 실패 테스트 2개 — `test_feed.py::test_feed_assembles_hero_stories_posts_and_bands`(stories 40 기대, 실제 42: 각 개수 늘어남), `test_weather_today.py::test_today_fetches_stores_and_returns_8_slots`(18시 칸 아이콘이 시각에 따라 sunset/moon). 카드뉴스 작업 전 코드에서도 같은 실패 | 카드뉴스 작업 중 발견 (10/23) | `backend/tests/test_feed.py`, `backend/tests/test_weather_today.py` |
|
||||||
|
| [ ] | 인스타 카드 서버 매일 자동 생성 + Teams 승인 — 서버에 Claude Code CLI(플랜 토큰)·Codex·Chrome·admin 설치, 매일 `npm run card -- tarot --post-wait` 후 Teams 웹훅(이미 있는 `backend/services/external/teams_webhook.py`)으로 미리보기·승인 링크. 운영 변경이라 확인 받고 | 인스타 홍보 7장 | `admin/scripts/card.mjs`, `backend/router/v1/card/card.py` |
|
||||||
|
| [x] | Playwright 끝까지 테스트 — 관리자(5175) → 연애·썸 → 만들기(Claude) → 지금 올리기 → 로컬 날씨각(9812 테스트 DB) 피드 2번째에 '날씨각 카드' 노출·이미지 로드 확인 (10/23 통과). 스크립트는 세션 임시 폴더에만 있음 | 사용자 요청 (10/23) | `admin/`, `frontend/src/b/Post.tsx` |
|
||||||
|
| [ ] | 로컬 Postgres(docker 5440) 반복 크래시 — 10/23 2시간에 4번 복구 모드, 10/20 로그에 'No space left on device'. 도커 VM 디스크 98G 중 46G 사용, 이미지 29G 중 19.8G·볼륨 15.9G 중 13.5G 정리 가능. 다른 프로젝트 공용이라 정리 전 확인 필요 | 테스트 중 발견 (10/23) | docker |
|
||||||
|
| [x] | 킹서버 반영 (10/23) — main 병합·배포 2회(카드뉴스 API·nginx 본문 한도 40m), `ADMIN_API_KEY` 설정, '오늘의 썸 타로' 카드 1 → 포스트 3337로 오늘 피드 2번째에 게시, 이미지 https://weather.o2o.kr/v1/card/1/1.jpg 확인 | 사용자 요청 | `deploy.sh`, `frontend/nginx.conf` |
|
||||||
|
| [ ] | 인스타 토큰 자동 갱신 — 장기 토큰은 60일 만료. 워커에 주 1회 `refresh_access_token` 잡을 넣고 새 토큰을 어디에 둘지(.env는 재생성 필요 → DB/Redis 저장) 결정 | 인스타 연결 (10/23) | `backend/scheduler/`, `backend/services/external/instagram.py` |
|
||||||
|
| [ ] | 킹서버 `.env` 바꾼 뒤 `docker compose restart`는 환경변수를 다시 읽지 않음 — `docker compose up -d --force-recreate <서비스>`로 해야 함. deploy.sh/문서에 적기 | 인스타 연결 중 발견 (10/23) | `deploy.sh`, `backend/docs/README.md` |
|
||||||
|
| [ ] | 어제(10/23) 인스타 썸 타로 글(https://www.instagram.com/p/De1E3uRIKHE/)은 3번 장(드라이브각)이 그림 없이 아이콘 — 드라이브각 그림은 10/24 만들었지만 날짜가 지나 재게시 안 함. 그 글을 앱에서 지울지 그냥 둘지 결정 | 10/24 | — |
|
||||||
|
| [x] | 10/24 나들이 타로(등산각·드라이브각·한강각, 질문 "어느 곳으로 나들이를 가면 좋을까요?") 킹서버 카드 2 → 포스트 3648, 인스타 https://www.instagram.com/p/De3N7LnIJyZ/ 게시. 같은 날 오늘의 코디(캐주얼, mild 구간 그림 재사용) 킹서버 카드 3 → 포스트 3649, 인스타 https://www.instagram.com/p/De3OVz6oC9e/. 그림 생성 모델: `gpt-6-luna`는 그림을 파일로 저장 못 해 실패, `gpt-6-sol`·low로 바꿔 성공(장당 ~28k 토큰) | 사용자 요청 (10/24) | `admin/scripts/gen-image.mjs` |
|
||||||
|
| [x] | 10/24 날씨각 소개 카드(인스타 전용, 8장, `intro` 템플릿 — Codex gpt-6-sol이 설계) 인스타 https://www.instagram.com/p/De3SUTtoDGR/ 게시. 킹서버엔 카드 4로 저장만(승인 대기, 피드엔 안 나감). 해시태그는 `card_set.hashtags`로 인스타 캡션에만 붙음(타로·코디 템플릿도 적용) | 사용자 요청 (10/24) | `admin/src/cards/templates.tsx`, `backend/router/v1/card/card.py` |
|
||||||
|
| [ ] | 인스타 릴스(20초, 2.5D: Codex 3D 렌더풍 배경 + 카메라 패럴랙스, 무료 BGM, API로 업로드) — 백엔드에 mp4 공개 주소 + REELS 게시 추가 필요 | 사용자 요청 (10/24) | `backend/services/external/instagram.py` |
|
||||||
|
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
# Logs
|
||||||
|
logs
|
||||||
|
*.log
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
pnpm-debug.log*
|
||||||
|
lerna-debug.log*
|
||||||
|
|
||||||
|
node_modules
|
||||||
|
dist
|
||||||
|
dist-ssr
|
||||||
|
*.local
|
||||||
|
|
||||||
|
# Editor directories and files
|
||||||
|
.vscode/*
|
||||||
|
!.vscode/extensions.json
|
||||||
|
.idea
|
||||||
|
.DS_Store
|
||||||
|
*.suo
|
||||||
|
*.ntvs*
|
||||||
|
*.njsproj
|
||||||
|
*.sln
|
||||||
|
*.sw?
|
||||||
|
|
||||||
|
# npm run card 결과
|
||||||
|
out
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"$schema": "./node_modules/oxlint/configuration_schema.json",
|
||||||
|
"plugins": ["react", "typescript", "oxc"],
|
||||||
|
"rules": {
|
||||||
|
"react/rules-of-hooks": "error",
|
||||||
|
"react/only-export-components": ["warn", { "allowConstantExport": true }]
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,85 @@
|
|||||||
|
# 날씨각 관리자 (admin/)
|
||||||
|
|
||||||
|
날씨각 운영용 관리자 웹앱. 지금 기능은 **인스타 카드 만들기** 하나다. 날씨 데이터는 날씨각 백엔드 API(`../backend`)를 그대로 쓴다.
|
||||||
|
|
||||||
|
## 켜기
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm install
|
||||||
|
VITE_API_BASE_URL=http://localhost:9810 npm run dev # http://localhost:5175
|
||||||
|
```
|
||||||
|
|
||||||
|
백엔드 주소가 다르면 `VITE_API_BASE_URL`만 바꾼다. 백엔드 API가 바뀌면 `npm run api`로 `src/api/client`를 다시 만든다.
|
||||||
|
|
||||||
|
## 카드 만드는 흐름
|
||||||
|
|
||||||
|
1. **템플릿 고르기**: `tarot`(날씨 타로, 5장) · `ootd`(오늘의 코디, 6장). 코디는 주제·Claude 기획 대신 스타일(캐주얼·세미정장·정장·스트릿·꾸안꾸, copy의 `style`)을 고른다. 지역은 고르지 않는다. 모든 카드는 서울(중구) 오늘 예보로 만들고, 카드에 지역 이름은 넣지 않는다.
|
||||||
|
2. **기획**: 주제(예: 주식, 연애)를 주거나 비워 두면 Claude CLI(`claude -p`, 이 맥 로그인 사용)가 오늘 날씨 사실을 바탕으로 칸별 문구를 기획한다. 규칙은 `scripts/plan.mjs`의 `RULES`.
|
||||||
|
3. **고치기·피드백**: 칸을 직접 고치거나, 피드백을 주고 다시 기획한다.
|
||||||
|
4. **색**: 만들 때마다 6가지 테마(`src/cards/themes.ts`: 노을·하늘·민트·베리·레몬·라벤더) 중 하나가 무작위로 정해진다. 화면의 '색'이나 `--color`로 고를 수 있다.
|
||||||
|
5. **그리기**: 확정한 문구를 같은 템플릿에 넣어 1080×1350 JPEG로 만든다.
|
||||||
|
|
||||||
|
관리자 화면은 열었을 때 아무것도 만들지 않는다. 관리자가 템플릿·주제(코디는 스타일)를 고르고 '만들기'를 눌러야 만든다. `npm run card -- tarot`는 Claude 기획부터 한다.
|
||||||
|
|
||||||
|
템플릿마다 "어떻게 만드는지"(데이터·계산·문구 규칙)는 `src/cards/templates.tsx`의 `how`에 적고, 관리자 화면 '이 카드는 이렇게 만들어요'와 Claude 기획 요청에 같이 쓴다.
|
||||||
|
|
||||||
|
## 날씨 타로 주제
|
||||||
|
|
||||||
|
주제는 `topics.json`의 대주제 > 소주제(연애: 썸·데이트·재회·이별·결혼 / 경제: 주식·재테크·취미·여행 / 일·공부 / 건강 / 관계)에서 고르거나 직접 쓴다. 대주제마다:
|
||||||
|
|
||||||
|
- **꾸밈(skin)**: 반짝이·표지 장식 모양(연애 하트, 경제 동전, 건강 네잎클로버…, `src/cards/cards.css` 맨 아래).
|
||||||
|
- **질문**: 소주제마다 카드가 답할 질문(`questions`).
|
||||||
|
- **리딩 말투**: `scripts/plan.mjs`의 `TAROT_TONE`. 실제 타로 리더 말투(온도타로·타로하는 아율·가문비타로·알라딘타로 유튜브 설명란, 2026-10-23 조사)에서 뽑았다. 질문자 "님"·상대 "그 사람", 해요체+단정 한 문장, 겉과 속 대비 → 다만 → 행동 하나, 폰에서 보이는 디테일. "~이면 ~해요" 공식·같은 어미 반복·"~할 수 있어요" 남발·덕담은 AI 티라 금지. 예시 문구를 바꿀 때도 이 규칙으로.
|
||||||
|
- **카드**: 날씨각 각 카드(`../backend/seed/index_definition.json`, 53장). 오늘 점수가 높은 각 중 질문과 엮이는 3장을 고르고, 각 카드로 질문을 리딩한다. 카드 그림은 그 각의 아이콘.
|
||||||
|
- 대주제·소주제·아이콘을 늘리려면 `topics.json`만 고친다. 새 꾸밈 모양은 CSS와 `image-prompts/tarot.json`에 같이 더한다.
|
||||||
|
|
||||||
|
## 대화로 만들 때 (Claude·Codex)
|
||||||
|
|
||||||
|
사용자가 "오늘 주식 날씨 타로 만들어 줘"처럼 말하면 아래 명령을 실행한다. 관리자 화면(`npm run dev`)이 켜져 있어야 한다.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
VITE_API_BASE_URL=http://localhost:9810 npm run card -- tarot --topic 주식 [--color mint]
|
||||||
|
```
|
||||||
|
|
||||||
|
- 기획안(칸별 문구)이 먼저 출력된다. 사용자에게 보여 주고, 피드백이 오면 출력된 `--copy` 값과 함께 다시 실행한다:
|
||||||
|
`npm run card -- tarot --copy <값> --feedback "2번 더 웃기게"`
|
||||||
|
- 피드백 없이 그대로 그리려면 `--copy <값>`만.
|
||||||
|
- 결과: `out/<날짜>/<날짜>_<템플릿>_<장>.jpg`
|
||||||
|
|
||||||
|
## 날씨각·인스타에 올리기
|
||||||
|
|
||||||
|
- 확인·내보내기 탭 '지금 올리기' → 날씨각 백엔드 `POST /v1/card`(이미지째 저장, 오늘 전국 피드에 게시). '승인 대기로 저장'은 저장만.
|
||||||
|
- 올린 뒤 '인스타(@nalssigak)에도 올리기' → `POST /v1/card/<id>/instagram`. 백엔드가 공개 주소(`PUBLIC_BASE_URL` + `/v1/card/<id>/<n>.jpg`)로 캐러셀을 만들어 게시한다. 서버 `.env`에 `INSTAGRAM_ACCESS_TOKEN`·`INSTAGRAM_USER_ID`가 있어야 한다(발급 순서는 `TODO.md` 인스타 연결 행).
|
||||||
|
- '만든 카드' 탭에서 저장된 카드를 다시 내려받거나, 승인 대기 카드를 올리거나, 인스타에 올린다.
|
||||||
|
- 올릴 곳은 두 개: 로컬 백엔드(`VITE_API_BASE_URL` + `ADMIN_API_KEY`, 피드 주소 `LOCAL_SITE_URL`)와 킹서버(`KING_API_BASE_URL`(기본 https://weather.o2o.kr) + `KING_ADMIN_API_KEY`, `KING_SITE_URL`). 비밀값이 있는 곳만 화면에 나온다. 보통 로컬에서 만들어 둘 다에 올린다.
|
||||||
|
- 관리자 서버가 비밀값을 `/api/post`·`/api/cards`에서만 붙인다. 브라우저엔 안 나간다. 킹서버 키는 킹서버 `.env`의 `ADMIN_API_KEY`와 같은 값.
|
||||||
|
- 켜는 예: `VITE_API_BASE_URL=http://localhost:9810 ADMIN_API_KEY=… KING_ADMIN_API_KEY=… npm run dev`
|
||||||
|
|
||||||
|
## 카드 그림 만들기 (Codex 이미지 생성)
|
||||||
|
|
||||||
|
**그림은 그날 만드는 카드에 필요한 것만 그때 만든다.** 조합(기온 구간 × 스타일 × 사람, 타로 78장)을 미리 일괄로 만들지 않는다. Codex 사용량이 한정돼 있다.
|
||||||
|
|
||||||
|
- 코디: 그날 기온 구간 × 고른 스타일의 6명. 타로는 날씨 아이콘을 써서 만들 그림이 없다.
|
||||||
|
- 관리자 화면: 그림이 없으면 미리보기 위에 'Codex로 그림 N장 만들기' 버튼이 나온다(한 장씩, 한 장에 1~2분).
|
||||||
|
- `npm run card`: 그리기 전에 빠진 그림을 자동으로 만든다(`--no-images`로 건너뜀).
|
||||||
|
- 한 번 만든 그림은 같은 조합에서 다시 쓴다. 새로 그리려면 화면의 '그림 다시 그리기'.
|
||||||
|
- 그림은 프롬프트 템플릿 `image-prompts/<종류>.json`(지금은 ootd)대로만 만든다. 바뀌는 칸(옷 목록, 카드 장면)만 다르고 나머지 문장은 같아서 모양이 통일된다.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run gen-image -- ootd cool casual # 한 구간·한 스타일 6명
|
||||||
|
npm run gen-image -- ootd cool-f20-casual --force # 한 장 다시 그리기
|
||||||
|
```
|
||||||
|
|
||||||
|
- `codex` CLI(로그인 필요)와 `cwebp`가 있어야 한다. 그림 생성은 `gpt-6-sol`(중간 모델)·추론 low 로 고정돼 있다(`CODEX_IMAGE_MODEL`로 바꿀 수 있음). 가장 싼 `gpt-6-luna`는 그림을 만들고도 파일로 저장하지 못하고, Codex 기본 모델(gpt-6-astra·xhigh)을 쓰면 한도를 금방 소진한다.
|
||||||
|
- 결과는 `src/assets/ootd/<구간>-<사람>-<스타일>.webp`이고, 카드에 자동으로 붙는다(`src/cards/ootd.ts`).
|
||||||
|
- 옷 목록(`items`, 영어 프롬프트)과 카드 글자(`labels`·`outer`)는 `image-prompts/ootd.json` 한 파일에 같이 있다. 하나를 바꾸면 다른 쪽도 맞춘다.
|
||||||
|
- 유행: `styles.<스타일>.trends.<사람>`에 요즘 한국 유행(실루엣·색·소재)을, `bands.<구간>.layering`에 기온별 레이어링을 적어 프롬프트에 넣는다. 2026-10-23 조사(무신사·에이블리·29CM·W컨셉·지그재그·크림 기사·보그·엘르). 연령별 판매 자료는 거의 없어 플랫폼 주 고객층(에이블리·지그재그·W컨셉=2030 여성, 무신사·크림=2030 남성)으로 나눈 것이다. 철이 바뀌면 다시 조사해 고친다.
|
||||||
|
- 만든 그림은 직접 열어 사람·얼굴·글자가 없는지 확인한다.
|
||||||
|
|
||||||
|
## 규칙
|
||||||
|
|
||||||
|
- 카드 모양은 `src/cards/templates.tsx`(템플릿)와 `src/cards/cards.css`(모양)에서만 정한다. 웹 화면과 `npm run card`가 같은 템플릿을 쓰므로, 한 번 바꾸면 둘 다 바뀐다. 포스트마다 따로 디자인하지 않는다.
|
||||||
|
- 새 포스트 종류(템플릿)의 디자인은 Codex에게 시켜 만든다. 결과를 `TEMPLATES`에 하나 더하고 `how`를 쓰고, `scripts/card.mjs`의 `SLIDES`에 장 수를 적는다.
|
||||||
|
- 카드 문구 기본값을 바꿀 때는 사용자에게 문구 목록을 먼저 검토받는다.
|
||||||
|
- 그림(타로 카드, 코디 옷)은 그날 필요한 것만 Codex로 만들고, 만든 파일(`src/assets`)은 다시 쓴다. 코디 옷 그림은 사람·얼굴 없이 옷만,
|
||||||
|
- 각 아이콘·캐릭터는 서비스와 같은 `../frontend/public/icons`를 쓴다.
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"about": "날씨 타로 각 카드 앞면 그림. 날씨각 각(backend/seed/index_definition.json)마다 이름·뜻으로 장면을 만들고 나머지 문장은 그대로 써서 모든 카드가 같은 모양으로 나오게 한다. 그날 뽑힌 카드만 Codex로 그리고 결과는 src/assets/gak-card/<각 code>.webp (다시 씀). 없으면 각 아이콘이 나온다.",
|
||||||
|
"deck": "gak",
|
||||||
|
"style": "Use case: stylized-concept. Asset type: text-free tarot-style card FRONT illustration for a playful Korean weather Instagram carousel. ONE portrait card, flat front-on orthographic view, ratio 2:3, filling the entire canvas edge to edge. The card represents the Korean weather-activity card '{name}' which means: {meaning}. Scene: {scene}. Tarot composition: one clear central scene with symbolic framing, a soft arch or rounded window shape behind the scene, small stars and clouds, sky color matching the activity's time of day. Characters, if any, are a cute white rabbit and a cute brown bear clay toys (simple dot eyes, no human faces), no humans. Style: tactile matte clay / soft vinyl 3D illustration, chunky rounded shapes, bright cheerful palette with warm orange #ff7a45, soft blue #4f97e3, ivory #f7fbff and deep ink #28304a accents, soft studio light. Rounded ivory card border with a thin orange double line. Everything inside the card, no mockup, no perspective, no hands holding the card. Text: none. Absolutely NO letters, words, numbers, roman numerals, labels, logos, watermark or pseudo-text anywhere.",
|
||||||
|
"scene": "the rabbit and/or bear happily doing the activity of '{name}' ({meaning}) in a cozy symbolic setting, with the activity's key object shown large like the 3D icon of this card"
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"about": "인스타 릴스(9:16) 배경 그림. 2.5D — 한 장을 깊이별로 레이어처럼 보이게 그려 카메라 패럴랙스를 얹는다. 글자가 올라갈 위쪽 가운데는 비워 둔다. npm run gen-image -- reel-bg <id|missing>",
|
||||||
|
"style": "Use case: stylized-concept. Asset type: text-free VERTICAL 9:16 background illustration for a Korean weather app's Instagram Reel. Look: soft 3D clay render, rounded matte shapes, gentle studio lighting, pastel base with saturated accents (sky blue #4f97e3, orange #ff7a45), matching cute 3D fluent-emoji style icons. Composition: strong depth layering — foreground objects touching the bottom and side edges, a mid-ground subject, a far background; keep the upper-middle 40% of the frame calm and uncluttered so text can be overlaid. No people, no animals, no text, no letters, no numbers, no logos, no UI. Scene: {motif}. Output exactly one portrait image, ratio 9:16.",
|
||||||
|
"items": [
|
||||||
|
{ "id": "sky", "motif": "a dreamy daytime sky with fluffy 3D clouds at several depths, a soft sun upper right, a few floating leaves, and rolling green hills along the bottom edge" },
|
||||||
|
{ "id": "rain-city", "motif": "an overcast rainy city seen from above the rooftops: grey-blue clouds, soft rain streaks, wet rooftops and puddles reflecting lights, muted palette with a single orange accent roof" },
|
||||||
|
{ "id": "beach", "motif": "a sunny beach bay seen from a low grassy hill: turquoise water, pale sand, a striped parasol and a picnic mat in the near corner, big clear sky, Korean east-coast feel" },
|
||||||
|
{ "id": "mountain", "motif": "an autumn mountain trail: red and yellow maple trees, rounded rocks, a blank wooden signpost, misty ridgelines far away, clear blue sky above" },
|
||||||
|
{ "id": "hangang-sunset", "motif": "Seoul Han river at sunset: orange-pink sky, a long bridge silhouette with warm lights, river reflections, a grassy riverbank with a picnic mat in the foreground, Namsan tower silhouette far away" }
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"about": "날씨 타로 배경 그림. 대주제 꾸밈(skin)마다 한 장씩, 한 번 만들어 두고 내용(카드·글)만 갈아 끼운다. 결과는 src/assets/tarot-bg/<skin>.webp. 글이 올라갈 자리를 비워 둔 1080×1350 세로 배경.",
|
||||||
|
"style": "Use case: stylized-concept. Asset type: text-free BACKGROUND illustration for a Korean weather tarot Instagram card, portrait 4:5 (1080x1350), filling the canvas edge to edge. {motif}. Style: tactile matte clay / soft vinyl 3D illustration, chunky rounded shapes, very soft and airy, low contrast, desaturated pastel so dark text stays readable on top. Composition rule: the CENTER band (from 20% to 80% of the height) must be an almost plain, very light, smooth area (like soft fog) with no objects, because a card picture and text will be placed there later; decorative objects live only near the top and bottom edges and are small. No characters, no people, no faces, no hands. Text: none. Absolutely NO letters, numbers, logos, watermark or pseudo-text.",
|
||||||
|
"items": [
|
||||||
|
{
|
||||||
|
"id": "heart",
|
||||||
|
"motif": "soft romantic scene: pastel pink and cream sky, a few floating 3D clay hearts, gentle sunset glow, tiny sparkles; mood: 연애·썸"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "coin",
|
||||||
|
"motif": "warm prosperous scene: soft gold and ivory sky, a few floating 3D clay coins and a tiny rising arrow shape (no numbers), sunrise glow; mood: 경제·돈"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "star",
|
||||||
|
"motif": "calm focused scene: pale blue and lavender sky, a few floating 3D clay stars and a small paper plane, early morning light; mood: 일·공부"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "clover",
|
||||||
|
"motif": "fresh healthy scene: mint and sage green sky, a few small floating 3D clay leaves and one little cloud, bright daylight; mood: 건강"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "sparkle",
|
||||||
|
"motif": "cozy friendly scene: peach and lilac sky, a few small floating 3D clay sparkles and round bubbles, soft afternoon light; mood: 관계·친구"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="ko">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
<meta name="robots" content="noindex, nofollow" />
|
||||||
|
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
||||||
|
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
||||||
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
||||||
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Jua&family=Bagel+Fat+One&display=swap" crossorigin="anonymous" />
|
||||||
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/variable/pretendardvariable-dynamic-subset.min.css" crossorigin="anonymous" />
|
||||||
|
<title>날씨각 관리자</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="root"></div>
|
||||||
|
<script type="module" src="/src/main.tsx"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
import { defineConfig } from '@hey-api/openapi-ts'
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
input: process.env.OPENAPI_INPUT ?? 'http://localhost:9810/openapi.json',
|
||||||
|
output: 'src/api/client',
|
||||||
|
parser: {
|
||||||
|
patch: {
|
||||||
|
// FastAPI operationId("get_feed_v1_feed_get")에서 "_v1_" 앞만 camelCase로 → getFeed / getFeedOptions / addCommentMutation
|
||||||
|
operations: (_method, _path, operation) => {
|
||||||
|
const id = operation.operationId ?? ''
|
||||||
|
const base = id.split('_v1_')[0] || id
|
||||||
|
operation.operationId = base.replace(/_([a-z])/g, (_m, c: string) => c.toUpperCase())
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
plugins: [
|
||||||
|
{ name: '@hey-api/client-fetch', throwOnError: true },
|
||||||
|
{ name: '@hey-api/typescript', enums: 'javascript' },
|
||||||
|
'@hey-api/sdk',
|
||||||
|
'@tanstack/react-query',
|
||||||
|
],
|
||||||
|
})
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
{
|
||||||
|
"name": "admin",
|
||||||
|
"private": true,
|
||||||
|
"version": "0.0.0",
|
||||||
|
"type": "module",
|
||||||
|
"scripts": {
|
||||||
|
"dev": "vite",
|
||||||
|
"build": "tsc -b && vite build",
|
||||||
|
"lint": "oxlint",
|
||||||
|
"preview": "vite preview",
|
||||||
|
"api": "openapi-ts",
|
||||||
|
"card": "node scripts/card.mjs",
|
||||||
|
"gen-image": "node scripts/gen-image.mjs"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@tailwindcss/vite": "^4.3.3",
|
||||||
|
"@tanstack/react-query": "^5.104.0",
|
||||||
|
"modern-screenshot": "^4.7.0",
|
||||||
|
"react": "^19.2.8",
|
||||||
|
"react-dom": "^19.2.8",
|
||||||
|
"react-router": "^8.4.0",
|
||||||
|
"tailwindcss": "^4.3.3"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@hey-api/openapi-ts": "0.99.0",
|
||||||
|
"@types/node": "^24.13.3",
|
||||||
|
"@types/react": "^19.2.18",
|
||||||
|
"@types/react-dom": "^19.2.7",
|
||||||
|
"@vitejs/plugin-react": "^6.1.1",
|
||||||
|
"oxlint": "^1.81.0",
|
||||||
|
"typescript": "~6.0.2",
|
||||||
|
"vite": "^8.3.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
node_modules/
|
||||||
|
.hyperframes/
|
||||||
|
out/
|
||||||
|
*.mp4
|
||||||
@@ -0,0 +1,109 @@
|
|||||||
|
# HyperFrames Composition Project
|
||||||
|
|
||||||
|
This folder is a [HyperFrames](https://hyperframes.heygen.com) video: HTML, CSS and seekable
|
||||||
|
animations (GSAP by default) that the `hyperframes` CLI previews in the browser and renders to
|
||||||
|
MP4.
|
||||||
|
|
||||||
|
## Skills — read these first
|
||||||
|
|
||||||
|
**Invoke the relevant skill before writing or modifying compositions.** Skills encode framework-specific patterns (e.g., `window.__timelines` registration, `data-*` attribute semantics, shader-compatible CSS rules) that generic web docs don't cover, so compositions written without them break.
|
||||||
|
|
||||||
|
**Doing anything with HyperFrames?** Start at `/hyperframes`. Make any video by asking for it; the `/hyperframes` skill carries the contract and the references (each kind of film, story, motion, look, sound, review, captions, overlays). Read it first, especially when there's no project context to orient you.
|
||||||
|
|
||||||
|
- `/hyperframes` — read first for any request to make, edit, animate or render a video, motion graphic, captions or overlays. Holds the render contract and the work loop.
|
||||||
|
- `/hyperframes-cli` — the CLI by job: scaffold, check, look at frames, edit the timeline, preview, render, publish, project history.
|
||||||
|
- `/hyperframes-registry` — ready-made blocks and components installed as editable source. Search it before hand-building any named visual.
|
||||||
|
- `/media-use` — get or make any media (music, sound effects, images, voiceover, avatar and generated video, transcripts, cutouts, colour grades) and mix placed audio.
|
||||||
|
- `/figma` — bring a Figma design, frame, logo or brand into a video.
|
||||||
|
- `/slideshow` — a presentation or pitch deck. Output is a navigable deck, not a rendered MP4.
|
||||||
|
- `/remotion-to-hyperframes` — bring existing video code or footage into HyperFrames (Remotion first; also Motion Canvas, Lottie, Three.js, canvas, or renders from other tools) and verify it frame by frame against the original.
|
||||||
|
|
||||||
|
**Changing how real footage or images look or reveal?** Load `/media-use` and read its `references/media-treatments.md` before editing, even when the request only says dark, flat, boring, retro, private, or “make the reveal cooler.” It governs how footage is treated, never whether media may be used. Use canonical media treatments and seek-safe motion; do not improvise equivalent CSS/SVG filters or overlays.
|
||||||
|
|
||||||
|
> **Tailwind v4 projects** (`hyperframes init --tailwind`): see `hyperframes-cli/references/init-and-scaffold.md` (Tailwind).
|
||||||
|
|
||||||
|
> **Using a HyperFrames plugin?** Load skills from that installed bundle and follow
|
||||||
|
> its `hyperframes/references/plugin-installation.md` execution rules. Update via
|
||||||
|
> the plugin manager, not the standalone commands below.
|
||||||
|
>
|
||||||
|
> **Standalone skill missing or stale?** Run `npx hyperframes skills update <name>` to install/refresh
|
||||||
|
> the specific skill you need, or bare `npx hyperframes skills update` to refresh the core set plus
|
||||||
|
> everything already installed — neither pulls the full set. Restart the agent session so
|
||||||
|
> newly installed skills load.
|
||||||
|
|
||||||
|
## Commands
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run dev # human-operated foreground preview (blocks until stopped)
|
||||||
|
npx hyperframes preview --background # agent-safe persistent Studio preview
|
||||||
|
npx hyperframes preview --status # verify the persistent preview is listening
|
||||||
|
npx hyperframes preview --stop # stop it when review is finished
|
||||||
|
npm run check # lint + runtime + layout + motion + contrast (one command)
|
||||||
|
npx hyperframes snapshot --at 1,3,5 # PNG frames at those seconds, to look at before rendering
|
||||||
|
npm run render # render to MP4
|
||||||
|
npm run publish # publish and get a shareable link
|
||||||
|
npx hyperframes lint --verbose # include info-level findings
|
||||||
|
npx hyperframes lint --json # machine-readable output for CI
|
||||||
|
npx hyperframes docs <topic> # reference docs in terminal
|
||||||
|
```
|
||||||
|
|
||||||
|
> **Agents must use `npx hyperframes preview --background` for Studio handoff.** Do not rely
|
||||||
|
> on a shell/tool `run_in_background` wrapper around `npm run dev`: that foreground process
|
||||||
|
> remains owned by the invoking session and can disappear while the browser stays open,
|
||||||
|
> leaving refreshes at `ERR_CONNECTION_TIMED_OUT`. Verify with `preview --status`, keep it
|
||||||
|
> alive through review, and stop it explicitly with `preview --stop` afterward.
|
||||||
|
|
||||||
|
> **Back from the desktop app.** Once this project was opened in the HyperFrames desktop app, run `npx hyperframes catch-up` before your next change here: it lists what the person asked Framey in the app and which files changed since.
|
||||||
|
|
||||||
|
> **Pinned CLI version.** These scripts pin an exact `hyperframes@X.Y.Z` so this project re-renders identically over time. Weeks later that pin lags fixes shipped since. To move up: `npx hyperframes@latest upgrade --project . --check` (shows the delta), then `npx hyperframes@latest upgrade --project .` to rewrite the pins. Always unpinned — the pinned script re-runs the old version against itself.
|
||||||
|
|
||||||
|
## Documentation
|
||||||
|
|
||||||
|
**For quick reference**, use the local CLI docs command (no network required):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npx hyperframes docs <topic>
|
||||||
|
```
|
||||||
|
|
||||||
|
Topics: `data-attributes`, `gsap`, `compositions`, `rendering`, `examples`, `troubleshooting`
|
||||||
|
|
||||||
|
**For full documentation**, discover pages via the machine-readable index — do NOT guess URLs:
|
||||||
|
|
||||||
|
```
|
||||||
|
https://hyperframes.heygen.com/llms.txt
|
||||||
|
```
|
||||||
|
|
||||||
|
## Project Structure
|
||||||
|
|
||||||
|
- `index.html` — main composition (root timeline)
|
||||||
|
- `compositions/` — sub-compositions referenced via `data-composition-src`
|
||||||
|
- `meta.json` — project metadata (id, name)
|
||||||
|
- `transcript.json` — whisper word-level transcript (if generated)
|
||||||
|
|
||||||
|
## Linting — ALWAYS RUN AFTER CHANGES
|
||||||
|
|
||||||
|
After creating or editing any `.html` composition, **always** run the full check before considering the task complete:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run check
|
||||||
|
```
|
||||||
|
|
||||||
|
Fix all errors before presenting the result. Warnings should be reviewed before rendering.
|
||||||
|
|
||||||
|
Then look at what you changed: `npx hyperframes snapshot --at <seconds>` (or `--range START,END`, `--composition <id>`) at the moments you edited, and read the frames before you reply. A passing check does not show how it looks.
|
||||||
|
|
||||||
|
## Key Rules
|
||||||
|
|
||||||
|
1. Every timed element needs `data-start` and a duration. `data-start` is what marks it as timed; `data-track-index` is an optional Studio display lane the render never reads
|
||||||
|
2. Give timed visual elements `class="clip"`. The framework keys visibility off `data-start`, not the class, but the shared `.clip` CSS is what gives a scene its full-frame box, and `lint` warns without it
|
||||||
|
3. Register one paused root timeline per composition on `window.__timelines`:
|
||||||
|
```js
|
||||||
|
window.__timelines = window.__timelines || {};
|
||||||
|
window.__timelines["composition-id"] = gsap.timeline({ paused: true });
|
||||||
|
```
|
||||||
|
Scene timelines manually added to this root must not be paused. A paused
|
||||||
|
child does not advance when the root is seeked. The runtime activates
|
||||||
|
registered composition siblings, not arbitrary nested scene timelines.
|
||||||
|
4. A video with sound keeps it on the `<video>` (`data-has-audio="true"`, no `muted`). Use a separate `<audio>` for music, voiceover, replacement audio, J/L cuts, or audio detached in Studio. Silent footage and b-roll: `muted`.
|
||||||
|
5. Sub-compositions use `data-composition-src="compositions/file.html"` to reference other HTML files
|
||||||
|
6. Only deterministic logic — no `Date.now()`, no `Math.random()`, no network fetches
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
GOAL: 20~50대가 "날씨를 보면 오늘 할 일을 알려 주는 앱이구나"를 20초 안에 알고, 프로필 링크(또는 토스 검색)로 열어 본다.
|
||||||
|
OUTPUT: HyperFrames, 1080 x 1920, 30 fps
|
||||||
|
TIME: 20 s x 30 = 600 frames. 음악이 있으면 ~110 BPM(16.4 f/beat, 65 f/bar), 장면 전환은 마디에.
|
||||||
|
LOOK: 땅 = Codex 클레이 3D 렌더 배경(assets/bg/*.webp, 1024x1820 → 1080x1920 cover, 위쪽 40%가 하늘이라 글자 자리).
|
||||||
|
브랜드 땅(등장·보상·엔드카드) = 평면 #e3efff, 질감 없음. 잉크 #28304a. 강조 주황 #ff7a45: 한 장면에 한 단어·한 칩.
|
||||||
|
디스플레이 Jua 120 px(H의 6.25%) 흰색, 자간 -2 px, 잉크 그림자 0 6px 18px rgba(40,48,74,.38) — 배경 위에서만 흰색, 브랜드 땅 위에서는 잉크색.
|
||||||
|
본문 Pretendard 700 52 px, 칩 Pretendard 800 72 px(점수) + 48 px(이름). 글자 폭 최대 900 px(오른쪽 액션 레일 피함).
|
||||||
|
깊이: 배경 scale 1.08~1.14 드리프트, 중간층(아이콘) 이동 1.6배, 앞층(흐린 구름·잎) 2.2배 + blur 6 px. 그림자: 아이콘 아래 타원 contact shadow 0.35.
|
||||||
|
OBJECTS: 하늘·구름(assets/bg/sky), 비 오는 도시(rain-city), 해변(beach), 가을 산길(mountain), 한강 노을(hangang-sunset);
|
||||||
|
3D 아이콘: 해 sun.png, 구름 cloud.png, 비 rain.png, 드라이브 drive.png, 산책 walk.png, 한강 hangang.png, 피크닉 picnic.png, 토끼 rabbit.png, 곰 bear.png;
|
||||||
|
앱 아이콘 app-icon.png(실제 apple-touch-icon), 실제 홈 화면 shot-home.webp(390x844)을 폰 틀(검정 8 px, 반지름 44 px) 안에.
|
||||||
|
점수 칩: 흰 배경 둥근 사각(반지름 28 px) + 왼쪽 아이콘 96 px + 이름 + 주황 점수, 그림자 0 10px 30px rgba(40,48,74,.25).
|
||||||
|
MOTION: 등장 expo.out 0.5 s(글자 단어별 blur 8→0, 0.13 s, 0.07 s 간격) · 카메라 power2.inOut · 퇴장 power3.in 0.25 s · 칩 스프링 back.out(1.6) 0.45 s(위치·크기만) · 점수 카운트 0.6 s power2.out.
|
||||||
|
휩 전환 0.25 s(세로, blur 16 px) · 색 플러드 0.4 s power2.inOut · 줌스루 0.35 s power3.in(아이콘 8%→250%).
|
||||||
|
SHOTS: S1 f0–75 하늘. 배경 1.14→1.08 푸시. "오늘 뭐 하기 / 좋은 날이지?" 단어별 맺힘 f9~f30, 해 아이콘 우상단 드리프트, 앞층 구름 좌하단. 읽기창 f30–f70. 소리: 비트 시작. → 휩 업.
|
||||||
|
S2 f75–165 비 도시. 칩 "흐림" "19°" "습도 70%" 스프링 낙하 f81·f84·f87, 구름·비 아이콘 중간층. f114 "…그래서 / 오늘 뭐 하죠?" 맺힘. 읽기창 f120–f158. → 색 플러드(f158–f170) 하늘색.
|
||||||
|
S3 f165–240 브랜드 땅. 앱 아이콘 스프링 f168(0.2→1.0), "날씨각" 글자별 f180(0.1 s 간격), "날씨를 *할 일*로 바꿔 주는 앱" f198. 토끼·곰 아래서 고개 f186. 읽기창 f205–f232. → 아이콘 줌스루 f232–f242.
|
||||||
|
S4 f240–300 해변. 배경 1.15→1.05 안착 0.5 s. 칩 "드라이브각 82" 스프링 f246 + 점수 카운트, drive 아이콘 해안선 따라 x+70 px/2 s. 작은 글 "해안 드라이브 딱 좋은 날" f258. → 휩 업.
|
||||||
|
S5 f300–360 산길. 칩 "산책각 81" + walk 아이콘 걷기(y 흔들림 ±6 px, 0.4 s). "숲길 한 바퀴" f318. → 휩 업.
|
||||||
|
S6 f360–420 한강 노을. 칩 "한강각 85" + hangang·picnic 아이콘. "노을 보며 돗자리" f378. → 폰 캐리(폰이 아래서 올라오며 배경이 하늘색으로 플러드 f414–f426).
|
||||||
|
S7 f420–525 보상. 브랜드 땅. 폰(720 px 폭) 아래서 y 1900→470 power4.out 0.7 s, 실제 홈 화면. 위 "지금 내 동네 / 1위는?" f438. 칩 "68가지 각" f480 스프링. 작은 글 "10.24 서울 기준" 폰 아래. 읽기창 f450–f515. → 폰이 아래로 빠지며(0.3 s) 엔드카드.
|
||||||
|
S8 f525–600 엔드카드. 아이콘 스프링 f528 가운데 위(폭 260 px), "날씨각" f540, "설치 없이 바로, *무료*" f552, "weather.o2o.kr" f564, "토스에서 '날씨각' 검색" f576. f585–600 정지. 음악 페이드.
|
||||||
|
BANNED: 검은 보이드, 글로우·파티클·렌즈플레어, 유리 카드, 보라·파랑 그라데이션, 세 카드 나란히, 코너 로고, 전부 페이드+슬라이드 업, 착지 뒤 떠다니는 제목, 흐린 스크린샷 위 제목, 점수 숫자 지어내기(오늘 API 값만), 사용자 글 노출.
|
||||||
|
QA: f0(썸네일: 하늘+질문 첫 단어 보임), f60(질문 다 읽힘), f150("그래서 뭐 하죠?"), f225(아이콘·워드마크·부제), f270/f330/f390(세 세상 칩·아이콘), f480(폰 전체·칩), f598(엔드카드 네 줄). 360 px 폰 시트에서 모든 글 읽힘. 글자 y 168~1330, x ≤ 900.
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
# 날씨각 소개 릴스 — 스토리라인 세 개 (2026-10-24)
|
||||||
|
|
||||||
|
사용자 지시: 인스타 릴스 20초 안팎, 9:16, 2.5D(Codex 3D 렌더풍 배경 + 기존 3D 아이콘 레이어 + 카메라 패럴랙스), 무료 BGM, 20~50대, 토스 앱 검색 언급, 해시태그. "알아서" → 질문 없이 A를 만든다.
|
||||||
|
|
||||||
|
## A. 질문 하나, 세 세상 (추천) — 질문+입력 장치 × 세상을 나는 카메라
|
||||||
|
하늘 위 큰 글자 "오늘 뭐 하기 좋은 날이지?"로 시작해, 비 오는 도시에서 날씨 숫자만 떠다니다 "그래서 뭐 하죠?"가 막히고, 날씨각 아이콘이 튀어나오며 답이 시작된다. 카메라가 해변·산길·한강 노을 세 세상을 차례로 날아가고, 세상마다 오늘 진짜 점수(드라이브각 82 · 산책각 81 · 한강각 85)가 칩으로 떨어진다. 마지막에 진짜 앱 화면이 올라오고 "설치 없이 바로, 무료 · 토스에서 '날씨각' 검색"으로 닫는다.
|
||||||
|
- 첫 2초: 파란 하늘·구름 3D 배경이 천천히 밀려 들어오고, 흰 Jua 글자가 단어마다 블러로 맺힌다. 해 아이콘이 오른쪽 위에서 살짝 떠 있다.
|
||||||
|
- 비트: 훅(하늘 질문) → 막힘(비 도시, 숫자 칩, "그래서?") → 등장(색 플러드 → 아이콘·워드마크) → 증명(해변→산→한강, 점수 칩 3번) → 보상(진짜 홈 화면) → 한 줄(설치 없이 무료) → 엔드카드(아이콘·주소·토스).
|
||||||
|
- 룩: 배경은 Codex 클레이 3D 렌더, 글자는 흰 Jua + 잉크 그림자, 강조는 주황 한 단어, 브랜드 땅은 연한 하늘색 평면. 패럴랙스 3겹(배경 1.0 · 아이콘 1.6 · 앞 구름 2.2).
|
||||||
|
- 소리: 밝고 가벼운 팝 비트(~110 BPM), 등장 장면에서 음악이 열리고, 엔드카드 아래서 짧게 페이드.
|
||||||
|
- 전환: 휩(세상 사이) · 색 플러드(비→브랜드) · 아이콘 줌스루(브랜드→해변) · 폰이 아래서 올라오는 캐리.
|
||||||
|
|
||||||
|
## B. 토끼와 곰의 하루 — 캐릭터가 일한다 × 물건에서 물건으로
|
||||||
|
토끼가 창밖을 보고, 곰이 폰을 들고, 둘이 점수 칩을 들고 세상 사이를 뛰어다닌다. 귀엽지만 캐릭터가 정지 PNG라 연기가 얕다. (안 만듦)
|
||||||
|
|
||||||
|
## C. 숫자가 글자가 된다 — 타입이 논증 × 한 프레임이 계속 바뀐다
|
||||||
|
"19° 흐림 70%"가 큰 글자로 화면을 채우다 스스로 "한강각 85"로 재배열되는 키네틱 타이포. 배경 그림을 거의 안 써서 2.5D 지시와 어긋난다. (안 만듦)
|
||||||
|
After Width: | Height: | Size: 167 KiB |
|
After Width: | Height: | Size: 162 KiB |
|
After Width: | Height: | Size: 201 KiB |
|
After Width: | Height: | Size: 132 KiB |
|
After Width: | Height: | Size: 99 KiB |
|
After Width: | Height: | Size: 41 KiB |
|
After Width: | Height: | Size: 44 KiB |
|
After Width: | Height: | Size: 33 KiB |
|
After Width: | Height: | Size: 27 KiB |
|
After Width: | Height: | Size: 18 KiB |
|
After Width: | Height: | Size: 33 KiB |
|
After Width: | Height: | Size: 38 KiB |
|
After Width: | Height: | Size: 38 KiB |
|
After Width: | Height: | Size: 26 KiB |
|
After Width: | Height: | Size: 40 KiB |
|
After Width: | Height: | Size: 31 KiB |
|
After Width: | Height: | Size: 30 KiB |
|
After Width: | Height: | Size: 31 KiB |
|
After Width: | Height: | Size: 28 KiB |
|
After Width: | Height: | Size: 34 KiB |
|
After Width: | Height: | Size: 35 KiB |
|
After Width: | Height: | Size: 34 KiB |
|
After Width: | Height: | Size: 24 KiB |
|
After Width: | Height: | Size: 33 KiB |
|
After Width: | Height: | Size: 9.7 KiB |
|
After Width: | Height: | Size: 34 KiB |
|
After Width: | Height: | Size: 27 KiB |
|
After Width: | Height: | Size: 27 KiB |
@@ -0,0 +1,33 @@
|
|||||||
|
<template>
|
||||||
|
<style>
|
||||||
|
@font-face { font-family: 'Jua'; src: url('assets/fonts/Jua-Regular.ttf'); }
|
||||||
|
@font-face { font-family: 'Pretendard'; src: url('assets/fonts/PretendardVariable.woff2'); font-weight: 100 900; }
|
||||||
|
#root { position: absolute; inset: 0; overflow: hidden; background: #cfe3fb; color: #fff; }
|
||||||
|
#s1-world { position: absolute; inset: 0; }
|
||||||
|
#s1-cam { position: absolute; inset: 0; transform-origin: 50% 45%; }
|
||||||
|
#s1-bg { position: absolute; left: 0; top: 0; width: 1080px; height: 1920px; object-fit: cover; }
|
||||||
|
#s1-fog { position: absolute; left: -120px; top: 1450px; width: 620px; filter: blur(6px); opacity: 0.9; }
|
||||||
|
#s1-title { position: absolute; left: 90px; top: 300px; width: 900px; font: 400 120px/1.18 'Jua', sans-serif; letter-spacing: -2px; color: #28304a; text-shadow: 0 0 22px rgba(255, 255, 255, 0.85), 0 4px 14px rgba(255, 255, 255, 0.6); word-break: keep-all; }
|
||||||
|
#s1-title .w { display: inline-block; margin-right: 0.22em; }
|
||||||
|
</style>
|
||||||
|
<div id="root" data-composition-id="s1" data-width="1080" data-height="1920">
|
||||||
|
<div id="s1-world" class="clip" data-start="0" data-duration="2.5">
|
||||||
|
<div id="s1-cam">
|
||||||
|
<img id="s1-bg" src="assets/bg/sky.webp" alt="" />
|
||||||
|
<h1 id="s1-title"><span class="w">오늘</span><span class="w">뭐</span><span class="w">하기</span><br /><span class="w">좋은</span><span class="w">날이지?</span></h1>
|
||||||
|
<img id="s1-fog" src="assets/icons/cloud.png" alt="" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<script>
|
||||||
|
const tl = gsap.timeline({ paused: true });
|
||||||
|
// 카메라: 천천히 밀어 들어감 (배경 1.0, 해 1.6배, 앞 구름 2.2배로 깊이)
|
||||||
|
tl.fromTo("#s1-cam", { scale: 1.14, y: 0, filter: "blur(0px)" }, { scale: 1.08, duration: 2.25, ease: "power2.inOut" }, 0);
|
||||||
|
tl.fromTo("#s1-fog", { x: 40 }, { x: -70, duration: 2.5, ease: "none" }, 0);
|
||||||
|
// 제목: 단어마다 블러로 맺힘, 착지 뒤엔 멈춤
|
||||||
|
tl.fromTo("#s1-title .w", { opacity: 0, filter: "blur(8px)" }, { opacity: 1, filter: "blur(0px)", duration: 0.13, ease: "power4.out", stagger: 0.07 }, 0.05);
|
||||||
|
// 휩 아웃: 다음 세상으로
|
||||||
|
tl.to("#s1-cam", { y: -420, filter: "blur(16px)", duration: 0.25, ease: "power3.in" }, 2.25);
|
||||||
|
window.__timelines["s1"] = tl;
|
||||||
|
</script>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
<template>
|
||||||
|
<style>
|
||||||
|
@font-face { font-family: 'Jua'; src: url('assets/fonts/Jua-Regular.ttf'); }
|
||||||
|
@font-face { font-family: 'Pretendard'; src: url('assets/fonts/PretendardVariable.woff2'); font-weight: 100 900; }
|
||||||
|
#root { position: absolute; inset: 0; overflow: hidden; background: #8e9bb3; color: #fff; }
|
||||||
|
#s2-world { position: absolute; inset: 0; }
|
||||||
|
#s2-cam { position: absolute; inset: 0; transform-origin: 50% 50%; }
|
||||||
|
#s2-bg { position: absolute; left: 0; top: 0; width: 1080px; height: 1920px; object-fit: cover; }
|
||||||
|
#s2-cloud { position: absolute; left: 640px; top: 250px; width: 300px; }
|
||||||
|
#s2-rain { position: absolute; left: 120px; top: 1420px; width: 220px; }
|
||||||
|
.s2-chip { position: absolute; padding: 18px 40px; border-radius: 28px; background: #fff; color: #28304a; font: 800 60px/1 'Pretendard', sans-serif; letter-spacing: -1px; box-shadow: 0 10px 30px rgba(40, 48, 74, 0.25); white-space: nowrap; }
|
||||||
|
#s2-c1 { left: 90px; top: 420px; }
|
||||||
|
#s2-c2 { left: 330px; top: 560px; }
|
||||||
|
#s2-c3 { left: 150px; top: 700px; }
|
||||||
|
#s2-ask { position: absolute; left: 90px; top: 960px; width: 900px; font: 400 112px/1.18 'Jua', sans-serif; letter-spacing: -2px; color: #28304a; text-shadow: 0 0 22px rgba(255, 255, 255, 0.85), 0 4px 14px rgba(255, 255, 255, 0.6); word-break: keep-all; }
|
||||||
|
#s2-ask .w { display: inline-block; margin-right: 0.22em; }
|
||||||
|
#s2-flood { position: absolute; inset: 0; background: #e3efff; }
|
||||||
|
</style>
|
||||||
|
<div id="root" data-composition-id="s2" data-width="1080" data-height="1920">
|
||||||
|
<div id="s2-world" class="clip" data-start="0" data-duration="3">
|
||||||
|
<div id="s2-cam">
|
||||||
|
<img id="s2-bg" src="assets/bg/rain-city.webp" alt="" />
|
||||||
|
<img id="s2-cloud" src="assets/icons/cloud.png" alt="" />
|
||||||
|
<img id="s2-rain" src="assets/icons/rain.png" alt="" />
|
||||||
|
<div id="s2-c1" class="s2-chip">흐림</div>
|
||||||
|
<div id="s2-c2" class="s2-chip">19°</div>
|
||||||
|
<div id="s2-c3" class="s2-chip">습도 70%</div>
|
||||||
|
<h1 id="s2-ask"><span class="w">…그래서</span><br /><span class="w">오늘</span><span class="w">뭐</span><span class="w">하죠?</span></h1>
|
||||||
|
</div>
|
||||||
|
<div id="s2-flood"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<script>
|
||||||
|
const tl = gsap.timeline({ paused: true });
|
||||||
|
// 휩 인: 아래서 올라와 맺힘, 그 뒤 느린 드리프트
|
||||||
|
tl.fromTo("#s2-cam", { y: 420, filter: "blur(16px)", scale: 1.1 }, { y: 0, filter: "blur(0px)", duration: 0.25, ease: "expo.out" }, 0);
|
||||||
|
tl.to("#s2-cam", { scale: 1.04, duration: 2.6, ease: "power2.inOut" }, 0.25);
|
||||||
|
tl.fromTo("#s2-cloud", { x: 30, y: 0 }, { x: -40, y: 12, duration: 3, ease: "none" }, 0);
|
||||||
|
tl.fromTo("#s2-rain", { y: -10 }, { y: 30, duration: 3, ease: "none" }, 0);
|
||||||
|
// 날씨 숫자 칩: 위에서 떨어져 튕김 (위치·크기만 튕기고 투명도는 안 튕김)
|
||||||
|
tl.fromTo(["#s2-c1", "#s2-c2", "#s2-c3"], { y: -220, scale: 0.6, opacity: 0 }, { y: 0, scale: 1, opacity: 1, duration: 0.45, ease: "back.out(1.6)", stagger: 0.1 }, 0.2);
|
||||||
|
// …그래서 뭐 하죠?
|
||||||
|
tl.fromTo("#s2-ask .w", { opacity: 0, filter: "blur(8px)" }, { opacity: 1, filter: "blur(0px)", duration: 0.13, ease: "power4.out", stagger: 0.07 }, 1.3);
|
||||||
|
// 색 플러드: 브랜드 땅이 가운데서 번져 다음 장면으로
|
||||||
|
tl.fromTo("#s2-flood", { clipPath: "circle(0% at 50% 62%)" }, { clipPath: "circle(120% at 50% 62%)", duration: 0.4, ease: "power2.inOut" }, 2.6);
|
||||||
|
window.__timelines["s2"] = tl;
|
||||||
|
</script>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
<template>
|
||||||
|
<style>
|
||||||
|
@font-face { font-family: 'Jua'; src: url('assets/fonts/Jua-Regular.ttf'); }
|
||||||
|
@font-face { font-family: 'Pretendard'; src: url('assets/fonts/PretendardVariable.woff2'); font-weight: 100 900; }
|
||||||
|
#root { position: absolute; inset: 0; overflow: hidden; background: #e3efff; color: #28304a; }
|
||||||
|
#s3-world { position: absolute; inset: 0; }
|
||||||
|
#s3-icon { position: absolute; left: 390px; top: 560px; width: 300px; height: 300px; border-radius: 68px; box-shadow: 0 24px 60px rgba(40, 48, 74, 0.28); transform-origin: 50% 50%; }
|
||||||
|
#s3-name { position: absolute; left: 0; top: 920px; width: 1080px; text-align: center; font: 400 150px/1 'Jua', sans-serif; letter-spacing: -3px; }
|
||||||
|
#s3-name .l { display: inline-block; }
|
||||||
|
#s3-sub { position: absolute; left: 90px; top: 1120px; width: 900px; text-align: center; font: 700 56px/1.3 'Pretendard', sans-serif; letter-spacing: -1px; word-break: keep-all; }
|
||||||
|
#s3-sub b { color: #d4552a; font-weight: 800; }
|
||||||
|
#s3-rabbit { position: absolute; left: 90px; top: 1520px; width: 260px; }
|
||||||
|
#s3-bear { position: absolute; left: 730px; top: 1540px; width: 260px; }
|
||||||
|
</style>
|
||||||
|
<div id="root" data-composition-id="s3" data-width="1080" data-height="1920">
|
||||||
|
<div id="s3-world" class="clip" data-start="0" data-duration="3">
|
||||||
|
<h1 id="s3-name"><span class="l">날</span><span class="l">씨</span><span class="l">각</span></h1>
|
||||||
|
<p id="s3-sub">날씨를 <b>할 일</b>로 바꿔 주는 앱</p>
|
||||||
|
<img id="s3-rabbit" src="assets/icons/rabbit.png" alt="" />
|
||||||
|
<img id="s3-bear" src="assets/icons/bear.png" alt="" />
|
||||||
|
<img id="s3-icon" src="assets/img/app-icon.png" alt="" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<script>
|
||||||
|
const tl = gsap.timeline({ paused: true });
|
||||||
|
// 앱 아이콘이 튀어나오고(스프링), 이름이 글자별로, 부제가 맺힘
|
||||||
|
tl.fromTo("#s3-icon", { scale: 0.2, opacity: 0 }, { scale: 1, opacity: 1, duration: 0.5, ease: "back.out(1.7)" }, 0.1);
|
||||||
|
tl.fromTo("#s3-name .l", { opacity: 0.3, filter: "blur(6px)", y: 14 }, { opacity: 1, filter: "blur(0px)", y: 0, duration: 0.2, ease: "power4.out", stagger: 0.1 }, 0.5);
|
||||||
|
tl.fromTo("#s3-sub", { opacity: 0, filter: "blur(8px)" }, { opacity: 1, filter: "blur(0px)", duration: 0.2, ease: "power4.out" }, 0.8);
|
||||||
|
tl.fromTo(["#s3-rabbit", "#s3-bear"], { y: 240 }, { y: 0, duration: 0.6, ease: "expo.out", stagger: 0.08 }, 0.7);
|
||||||
|
// 줌 스루: 아이콘이 화면을 덮으며 다음 세상으로
|
||||||
|
tl.to("#s3-icon", { scale: 9, duration: 0.35, ease: "power3.in" }, 2.65);
|
||||||
|
tl.to(["#s3-name", "#s3-sub"], { opacity: 0, filter: "blur(8px)", duration: 0.2, ease: "power3.in" }, 2.75);
|
||||||
|
window.__timelines["s3"] = tl;
|
||||||
|
</script>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
<template>
|
||||||
|
<style>
|
||||||
|
@font-face { font-family: 'Jua'; src: url('assets/fonts/Jua-Regular.ttf'); }
|
||||||
|
@font-face { font-family: 'Pretendard'; src: url('assets/fonts/PretendardVariable.woff2'); font-weight: 100 900; }
|
||||||
|
#root { position: absolute; inset: 0; overflow: hidden; background: #cfe3fb; color: #fff; }
|
||||||
|
#s4-world { position: absolute; inset: 0; }
|
||||||
|
#s4-cam { position: absolute; inset: 0; transform-origin: 50% 50%; }
|
||||||
|
#s4-bg { position: absolute; left: 0; top: 0; width: 1080px; height: 1920px; object-fit: cover; }
|
||||||
|
#s4-drive { position: absolute; left: 120px; top: 1120px; width: 320px; }
|
||||||
|
#s4-chip { position: absolute; left: 90px; top: 560px; display: flex; align-items: center; gap: 22px; padding: 22px 40px 22px 24px; border-radius: 32px; background: #fff; color: #28304a; box-shadow: 0 12px 34px rgba(40, 48, 74, 0.28); transform-origin: 0% 50%; }
|
||||||
|
#s4-chip img { width: 110px; height: 110px; }
|
||||||
|
#s4-chip .n { font: 800 54px/1 'Pretendard', sans-serif; letter-spacing: -1px; white-space: nowrap; }
|
||||||
|
#s4-chip .v { font: 800 92px/1 'Pretendard', sans-serif; color: #d4552a; letter-spacing: -2px; min-width: 120px; text-align: right; }
|
||||||
|
#s4-line { position: absolute; left: 90px; top: 760px; width: 900px; font: 400 76px/1.2 'Jua', sans-serif; letter-spacing: -1px; color: #28304a; text-shadow: 0 0 22px rgba(255, 255, 255, 0.85), 0 4px 14px rgba(255, 255, 255, 0.6); word-break: keep-all; }
|
||||||
|
</style>
|
||||||
|
<div id="root" data-composition-id="s4" data-width="1080" data-height="1920">
|
||||||
|
<div id="s4-world" class="clip" data-start="0" data-duration="2">
|
||||||
|
<div id="s4-cam">
|
||||||
|
<img id="s4-bg" src="assets/bg/beach.webp" alt="" />
|
||||||
|
<img id="s4-drive" src="assets/icons/drive.png" alt="" />
|
||||||
|
<div id="s4-chip"><img src="assets/icons/drive.png" alt="" /><span class="n">드라이브각</span><span class="v" id="s4-score">0</span></div>
|
||||||
|
<p id="s4-line">해안 드라이브 딱 좋은 날</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<script>
|
||||||
|
const tl = gsap.timeline({ paused: true });
|
||||||
|
// 줌 스루 끝에서 크게 들어와 안착, 그 뒤 살짝 드리프트
|
||||||
|
tl.fromTo("#s4-cam", { scale: 1.2, filter: "blur(6px)" }, { scale: 1.06, filter: "blur(0px)", duration: 0.55, ease: "power3.out" }, 0);
|
||||||
|
tl.to("#s4-cam", { scale: 1.09, duration: 1.2, ease: "power2.inOut" }, 0.55);
|
||||||
|
tl.fromTo("#s4-drive", { x: -40, y: 10 }, { x: 70, y: -6, duration: 2, ease: "none" }, 0);
|
||||||
|
// 오늘 점수 칩: 튕겨 들어오고 숫자가 올라감 (2026-10-24 서울 중구 API 값)
|
||||||
|
tl.fromTo("#s4-chip", { scale: 0.5, x: -80, opacity: 0 }, { scale: 1, x: 0, opacity: 1, duration: 0.45, ease: "back.out(1.6)" }, 0.15);
|
||||||
|
const score = { v: 0 };
|
||||||
|
tl.to(score, { v: 82, duration: 0.6, ease: "power2.out", onUpdate: () => { document.getElementById("s4-score").textContent = Math.round(score.v); } }, 0.25);
|
||||||
|
tl.fromTo("#s4-line", { opacity: 0, filter: "blur(8px)" }, { opacity: 1, filter: "blur(0px)", duration: 0.2, ease: "power4.out" }, 0.28);
|
||||||
|
tl.to("#s4-cam", { y: -420, filter: "blur(16px)", duration: 0.18, ease: "power3.in" }, 1.84);
|
||||||
|
window.__timelines["s4"] = tl;
|
||||||
|
</script>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
<template>
|
||||||
|
<style>
|
||||||
|
@font-face { font-family: 'Jua'; src: url('assets/fonts/Jua-Regular.ttf'); }
|
||||||
|
@font-face { font-family: 'Pretendard'; src: url('assets/fonts/PretendardVariable.woff2'); font-weight: 100 900; }
|
||||||
|
#root { position: absolute; inset: 0; overflow: hidden; background: #cfe3fb; color: #fff; }
|
||||||
|
#s5-world { position: absolute; inset: 0; }
|
||||||
|
#s5-cam { position: absolute; inset: 0; transform-origin: 50% 50%; }
|
||||||
|
#s5-bg { position: absolute; left: 0; top: 0; width: 1080px; height: 1920px; object-fit: cover; }
|
||||||
|
#s5-walk { position: absolute; left: 620px; top: 1140px; width: 300px; }
|
||||||
|
#s5-chip { position: absolute; left: 90px; top: 560px; display: flex; align-items: center; gap: 22px; padding: 22px 40px 22px 24px; border-radius: 32px; background: #fff; color: #28304a; box-shadow: 0 12px 34px rgba(40, 48, 74, 0.28); transform-origin: 0% 50%; }
|
||||||
|
#s5-chip img { width: 110px; height: 110px; }
|
||||||
|
#s5-chip .n { font: 800 54px/1 'Pretendard', sans-serif; letter-spacing: -1px; white-space: nowrap; }
|
||||||
|
#s5-chip .v { font: 800 92px/1 'Pretendard', sans-serif; color: #d4552a; letter-spacing: -2px; min-width: 120px; text-align: right; }
|
||||||
|
#s5-line { position: absolute; left: 90px; top: 760px; width: 900px; font: 400 76px/1.2 'Jua', sans-serif; letter-spacing: -1px; color: #28304a; text-shadow: 0 0 22px rgba(255, 255, 255, 0.85), 0 4px 14px rgba(255, 255, 255, 0.6); word-break: keep-all; }
|
||||||
|
</style>
|
||||||
|
<div id="root" data-composition-id="s5" data-width="1080" data-height="1920">
|
||||||
|
<div id="s5-world" class="clip" data-start="0" data-duration="2">
|
||||||
|
<div id="s5-cam">
|
||||||
|
<img id="s5-bg" src="assets/bg/mountain.webp" alt="" />
|
||||||
|
<img id="s5-walk" src="assets/icons/walk.png" alt="" />
|
||||||
|
<div id="s5-chip"><img src="assets/icons/walk.png" alt="" /><span class="n">산책각</span><span class="v" id="s5-score">0</span></div>
|
||||||
|
<p id="s5-line">숲길 산책 딱 좋은 날</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<script>
|
||||||
|
const tl = gsap.timeline({ paused: true });
|
||||||
|
tl.fromTo("#s5-cam", { y: 420, filter: "blur(16px)", scale: 1.12 }, { y: 0, filter: "blur(0px)", duration: 0.25, ease: "expo.out" }, 0);
|
||||||
|
tl.to("#s5-cam", { scale: 1.06, duration: 1.5, ease: "power2.inOut" }, 0.25);
|
||||||
|
// 산책 아이콘: 걷는 듯 위아래 (유한 반복)
|
||||||
|
tl.fromTo("#s5-walk", { y: 0, x: 20 }, { y: -8, x: -30, duration: 0.4, ease: "sine.inOut", repeat: 4, yoyo: true }, 0);
|
||||||
|
tl.fromTo("#s5-chip", { scale: 0.5, x: -80, opacity: 0 }, { scale: 1, x: 0, opacity: 1, duration: 0.45, ease: "back.out(1.6)" }, 0.2);
|
||||||
|
const score = { v: 0 };
|
||||||
|
tl.to(score, { v: 81, duration: 0.6, ease: "power2.out", onUpdate: () => { document.getElementById("s5-score").textContent = Math.round(score.v); } }, 0.3);
|
||||||
|
tl.fromTo("#s5-line", { opacity: 0, filter: "blur(8px)" }, { opacity: 1, filter: "blur(0px)", duration: 0.2, ease: "power4.out" }, 0.28);
|
||||||
|
tl.to("#s5-cam", { y: -420, filter: "blur(16px)", duration: 0.18, ease: "power3.in" }, 1.84);
|
||||||
|
window.__timelines["s5"] = tl;
|
||||||
|
</script>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
<template>
|
||||||
|
<style>
|
||||||
|
@font-face { font-family: 'Jua'; src: url('assets/fonts/Jua-Regular.ttf'); }
|
||||||
|
@font-face { font-family: 'Pretendard'; src: url('assets/fonts/PretendardVariable.woff2'); font-weight: 100 900; }
|
||||||
|
#root { position: absolute; inset: 0; overflow: hidden; background: #f7b27a; color: #fff; }
|
||||||
|
#s6-world { position: absolute; inset: 0; }
|
||||||
|
#s6-cam { position: absolute; inset: 0; transform-origin: 50% 50%; }
|
||||||
|
#s6-bg { position: absolute; left: 0; top: 0; width: 1080px; height: 1920px; object-fit: cover; }
|
||||||
|
#s6-hangang { position: absolute; left: 560px; top: 1080px; width: 340px; }
|
||||||
|
#s6-picnic { position: absolute; left: 110px; top: 1300px; width: 220px; }
|
||||||
|
#s6-chip { position: absolute; left: 90px; top: 560px; display: flex; align-items: center; gap: 22px; padding: 22px 40px 22px 24px; border-radius: 32px; background: #fff; color: #28304a; box-shadow: 0 12px 34px rgba(40, 48, 74, 0.28); transform-origin: 0% 50%; }
|
||||||
|
#s6-chip img { width: 110px; height: 110px; }
|
||||||
|
#s6-chip .n { font: 800 54px/1 'Pretendard', sans-serif; letter-spacing: -1px; white-space: nowrap; }
|
||||||
|
#s6-chip .v { font: 800 92px/1 'Pretendard', sans-serif; color: #d4552a; letter-spacing: -2px; min-width: 120px; text-align: right; }
|
||||||
|
#s6-line { position: absolute; left: 90px; top: 760px; width: 900px; font: 400 76px/1.2 'Jua', sans-serif; letter-spacing: -1px; color: #28304a; text-shadow: 0 0 22px rgba(255, 255, 255, 0.85), 0 4px 14px rgba(255, 255, 255, 0.6); word-break: keep-all; }
|
||||||
|
#s6-flood { position: absolute; inset: 0; background: #e3efff; }
|
||||||
|
</style>
|
||||||
|
<div id="root" data-composition-id="s6" data-width="1080" data-height="1920">
|
||||||
|
<div id="s6-world" class="clip" data-start="0" data-duration="2">
|
||||||
|
<div id="s6-cam">
|
||||||
|
<img id="s6-bg" src="assets/bg/hangang-sunset.webp" alt="" />
|
||||||
|
<img id="s6-hangang" src="assets/icons/hangang.png" alt="" />
|
||||||
|
<img id="s6-picnic" src="assets/icons/picnic.png" alt="" />
|
||||||
|
<div id="s6-chip"><img src="assets/icons/hangang.png" alt="" /><span class="n">한강각</span><span class="v" id="s6-score">0</span></div>
|
||||||
|
<p id="s6-line">노을 보며 돗자리 딱</p>
|
||||||
|
</div>
|
||||||
|
<div id="s6-flood"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<script>
|
||||||
|
const tl = gsap.timeline({ paused: true });
|
||||||
|
tl.fromTo("#s6-cam", { y: 420, filter: "blur(16px)", scale: 1.12 }, { y: 0, filter: "blur(0px)", duration: 0.25, ease: "expo.out" }, 0);
|
||||||
|
tl.to("#s6-cam", { scale: 1.06, duration: 1.5, ease: "power2.inOut" }, 0.25);
|
||||||
|
tl.fromTo("#s6-hangang", { x: 20, y: 6 }, { x: -30, y: -10, duration: 2, ease: "none" }, 0);
|
||||||
|
tl.fromTo("#s6-picnic", { x: -20 }, { x: 30, duration: 2, ease: "none" }, 0);
|
||||||
|
tl.fromTo("#s6-chip", { scale: 0.5, x: -80, opacity: 0 }, { scale: 1, x: 0, opacity: 1, duration: 0.45, ease: "back.out(1.6)" }, 0.2);
|
||||||
|
const score = { v: 0 };
|
||||||
|
tl.to(score, { v: 85, duration: 0.6, ease: "power2.out", onUpdate: () => { document.getElementById("s6-score").textContent = Math.round(score.v); } }, 0.3);
|
||||||
|
tl.fromTo("#s6-line", { opacity: 0, filter: "blur(8px)" }, { opacity: 1, filter: "blur(0px)", duration: 0.2, ease: "power4.out" }, 0.28);
|
||||||
|
// 브랜드 땅으로 플러드 (폰이 올라올 자리)
|
||||||
|
tl.fromTo("#s6-flood", { clipPath: "circle(0% at 50% 100%)" }, { clipPath: "circle(140% at 50% 100%)", duration: 0.3, ease: "power2.inOut" }, 1.74);
|
||||||
|
window.__timelines["s6"] = tl;
|
||||||
|
</script>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
<template>
|
||||||
|
<style>
|
||||||
|
@font-face { font-family: 'Jua'; src: url('assets/fonts/Jua-Regular.ttf'); }
|
||||||
|
@font-face { font-family: 'Pretendard'; src: url('assets/fonts/PretendardVariable.woff2'); font-weight: 100 900; }
|
||||||
|
#root { position: absolute; inset: 0; overflow: hidden; background: #e3efff; color: #28304a; }
|
||||||
|
#s7-world { position: absolute; inset: 0; }
|
||||||
|
#s7-title { position: absolute; left: 90px; top: 230px; width: 900px; font: 400 112px/1.18 'Jua', sans-serif; letter-spacing: -2px; word-break: keep-all; }
|
||||||
|
#s7-title .w { display: inline-block; margin-right: 0.22em; }
|
||||||
|
#s7-phone { position: absolute; left: 180px; top: 560px; width: 720px; height: 1500px; padding: 22px; border: 12px solid #28304a; border-radius: 88px; background: #28304a; box-shadow: 0 30px 70px rgba(40, 48, 74, 0.3); overflow: hidden; }
|
||||||
|
#s7-phone img { display: block; width: 100%; border-radius: 52px; }
|
||||||
|
#s7-chip { position: absolute; left: 560px; top: 480px; padding: 18px 36px; border-radius: 28px; background: #d4552a; color: #fff; font: 800 56px/1 'Pretendard', sans-serif; letter-spacing: -1px; box-shadow: 0 12px 34px rgba(212, 85, 42, 0.35); white-space: nowrap; transform-origin: 50% 50%; z-index: 2; }
|
||||||
|
#s7-note { position: absolute; left: 90px; top: 500px; font: 600 36px/1 'Pretendard', sans-serif; color: #546078; }
|
||||||
|
</style>
|
||||||
|
<div id="root" data-composition-id="s7" data-width="1080" data-height="1920">
|
||||||
|
<div id="s7-world" class="clip" data-start="0" data-duration="3" data-layout-allow-overlap>
|
||||||
|
<h1 id="s7-title"><span class="w">지금</span><span class="w">내</span><span class="w">동네</span><br /><span class="w">1위는?</span></h1>
|
||||||
|
<div id="s7-phone"><img src="assets/img/shot-home.webp" alt="날씨각 홈 화면" /></div>
|
||||||
|
<div id="s7-chip">68가지 각</div>
|
||||||
|
<p id="s7-note">실제 화면 · 10.24 마포구</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<script>
|
||||||
|
const tl = gsap.timeline({ paused: true });
|
||||||
|
// 진짜 홈 화면이 아래서 올라오고, 제목이 맺히고, 68가지 칩이 튕김
|
||||||
|
tl.fromTo("#s7-phone", { y: 1400 }, { y: 0, duration: 0.7, ease: "power4.out" }, 0.05);
|
||||||
|
tl.fromTo("#s7-title .w", { opacity: 0, filter: "blur(8px)" }, { opacity: 1, filter: "blur(0px)", duration: 0.13, ease: "power4.out", stagger: 0.07 }, 0.4);
|
||||||
|
tl.fromTo("#s7-chip", { scale: 0.4, opacity: 0, rotate: -8 }, { scale: 1, opacity: 1, rotate: -6, duration: 0.45, ease: "back.out(1.6)" }, 1.2);
|
||||||
|
tl.fromTo("#s7-note", { opacity: 0 }, { opacity: 1, duration: 0.2, ease: "power2.out" }, 0.6);
|
||||||
|
// 폰이 아래로 빠지며 엔드카드로
|
||||||
|
tl.to("#s7-phone", { y: 1500, duration: 0.3, ease: "power3.in" }, 2.7);
|
||||||
|
tl.to(["#s7-title", "#s7-chip", "#s7-note"], { opacity: 0, filter: "blur(8px)", duration: 0.2, ease: "power3.in" }, 2.75);
|
||||||
|
window.__timelines["s7"] = tl;
|
||||||
|
</script>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
<template>
|
||||||
|
<style>
|
||||||
|
@font-face { font-family: 'Jua'; src: url('assets/fonts/Jua-Regular.ttf'); }
|
||||||
|
@font-face { font-family: 'Pretendard'; src: url('assets/fonts/PretendardVariable.woff2'); font-weight: 100 900; }
|
||||||
|
#root { position: absolute; inset: 0; overflow: hidden; background: #e3efff; color: #28304a; }
|
||||||
|
#s8-world { position: absolute; inset: 0; }
|
||||||
|
#s8-icon { position: absolute; left: 410px; top: 520px; width: 260px; height: 260px; border-radius: 60px; box-shadow: 0 24px 60px rgba(40, 48, 74, 0.28); transform-origin: 50% 50%; }
|
||||||
|
#s8-name { position: absolute; left: 0; top: 830px; width: 1080px; text-align: center; font: 400 140px/1 'Jua', sans-serif; letter-spacing: -3px; }
|
||||||
|
#s8-claim { position: absolute; left: 90px; top: 1010px; width: 900px; text-align: center; font: 800 64px/1.2 'Pretendard', sans-serif; letter-spacing: -1px; word-break: keep-all; }
|
||||||
|
#s8-claim b { color: #d4552a; }
|
||||||
|
#s8-url { position: absolute; left: 90px; top: 1125px; width: 900px; text-align: center; font: 700 58px/1.2 'Pretendard', sans-serif; letter-spacing: -1px; color: #2b6cb8; }
|
||||||
|
#s8-toss { position: absolute; left: 90px; top: 1215px; width: 900px; text-align: center; font: 600 50px/1.2 'Pretendard', sans-serif; letter-spacing: -1px; color: #546078; word-break: keep-all; }
|
||||||
|
#s8-rabbit { position: absolute; left: 90px; top: 1520px; width: 260px; }
|
||||||
|
#s8-bear { position: absolute; left: 730px; top: 1540px; width: 260px; }
|
||||||
|
</style>
|
||||||
|
<div id="root" data-composition-id="s8" data-width="1080" data-height="1920">
|
||||||
|
<div id="s8-world" class="clip" data-start="0" data-duration="3.5">
|
||||||
|
<img id="s8-icon" src="assets/img/app-icon.png" alt="" />
|
||||||
|
<h1 id="s8-name">날씨각</h1>
|
||||||
|
<p id="s8-claim">설치 없이 바로, <b>무료</b></p>
|
||||||
|
<p id="s8-url">weather.o2o.kr</p>
|
||||||
|
<p id="s8-toss">토스 앱에서 '날씨각' 검색해도 열려요</p>
|
||||||
|
<img id="s8-rabbit" src="assets/icons/rabbit.png" alt="" />
|
||||||
|
<img id="s8-bear" src="assets/icons/bear.png" alt="" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<script>
|
||||||
|
const tl = gsap.timeline({ paused: true });
|
||||||
|
tl.fromTo("#s8-icon", { scale: 0.2, opacity: 0 }, { scale: 1, opacity: 1, duration: 0.5, ease: "back.out(1.7)" }, 0.1);
|
||||||
|
tl.fromTo("#s8-name", { opacity: 0, filter: "blur(8px)" }, { opacity: 1, filter: "blur(0px)", duration: 0.2, ease: "power4.out" }, 0.4);
|
||||||
|
tl.fromTo("#s8-claim", { opacity: 0, filter: "blur(8px)" }, { opacity: 1, filter: "blur(0px)", duration: 0.2, ease: "power4.out" }, 0.7);
|
||||||
|
tl.fromTo("#s8-url", { opacity: 0, filter: "blur(8px)" }, { opacity: 1, filter: "blur(0px)", duration: 0.2, ease: "power4.out" }, 1.0);
|
||||||
|
tl.fromTo("#s8-toss", { opacity: 0, filter: "blur(8px)" }, { opacity: 1, filter: "blur(0px)", duration: 0.2, ease: "power4.out" }, 1.3);
|
||||||
|
tl.fromTo(["#s8-rabbit", "#s8-bear"], { y: 240 }, { y: 0, duration: 0.6, ease: "expo.out", stagger: 0.08 }, 0.3);
|
||||||
|
// 마지막 0.6초는 정지 (마지막 프레임 유지)
|
||||||
|
tl.to({}, { duration: 0.2 }, 3.3);
|
||||||
|
window.__timelines["s8"] = tl;
|
||||||
|
</script>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://hyperframes.heygen.com/schema/hyperframes.json",
|
||||||
|
"registry": "https://raw.githubusercontent.com/heygen-com/hyperframes/main/registry",
|
||||||
|
"paths": {
|
||||||
|
"blocks": "compositions",
|
||||||
|
"components": "compositions/components",
|
||||||
|
"assets": "assets"
|
||||||
|
},
|
||||||
|
"media": {
|
||||||
|
"autoProxy": true
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="ko">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<meta name="viewport" content="width=1080, height=1920" />
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/gsap@3.14.2/dist/gsap.min.js"></script>
|
||||||
|
<style>
|
||||||
|
* { margin: 0; padding: 0; box-sizing: border-box; }
|
||||||
|
html, body { margin: 0; width: 1080px; height: 1920px; overflow: hidden; background: #e3efff; }
|
||||||
|
#root { position: relative; width: 100%; height: 100%; }
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<!-- 날씨각 소개 릴스 20초. 장면마다 sub-composition 하나 (SPEC.md의 S1~S8) -->
|
||||||
|
<div id="root" data-composition-id="main" data-start="0" data-duration="21" data-width="1080" data-height="1920">
|
||||||
|
<div id="s1" data-composition-id="s1" data-composition-src="compositions/s1.html" data-start="0" data-duration="2.5" data-track-index="1" data-track-kind="graphics" data-width="1080" data-height="1920"></div>
|
||||||
|
<div id="s2" data-composition-id="s2" data-composition-src="compositions/s2.html" data-start="2.5" data-duration="3" data-track-index="1" data-track-kind="graphics" data-width="1080" data-height="1920"></div>
|
||||||
|
<div id="s3" data-composition-id="s3" data-composition-src="compositions/s3.html" data-start="5.5" data-duration="3" data-track-index="1" data-track-kind="graphics" data-width="1080" data-height="1920"></div>
|
||||||
|
<div id="s4" data-composition-id="s4" data-composition-src="compositions/s4.html" data-start="8.5" data-duration="2" data-track-index="1" data-track-kind="graphics" data-width="1080" data-height="1920"></div>
|
||||||
|
<div id="s5" data-composition-id="s5" data-composition-src="compositions/s5.html" data-start="10.5" data-duration="2" data-track-index="1" data-track-kind="graphics" data-width="1080" data-height="1920"></div>
|
||||||
|
<div id="s6" data-composition-id="s6" data-composition-src="compositions/s6.html" data-start="12.5" data-duration="2" data-track-index="1" data-track-kind="graphics" data-width="1080" data-height="1920"></div>
|
||||||
|
<div id="s7" data-composition-id="s7" data-composition-src="compositions/s7.html" data-start="14.5" data-duration="3" data-track-index="1" data-track-kind="graphics" data-width="1080" data-height="1920"></div>
|
||||||
|
<div id="s8" data-composition-id="s8" data-composition-src="compositions/s8.html" data-start="17.5" data-duration="3.5" data-track-index="1" data-track-kind="graphics" data-width="1080" data-height="1920"></div>
|
||||||
|
</div>
|
||||||
|
<script>
|
||||||
|
const tl = gsap.timeline({ paused: true });
|
||||||
|
window.__timelines["main"] = tl;
|
||||||
|
tl.seek(0);
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"id": "intro",
|
||||||
|
"name": "intro",
|
||||||
|
"createdAt": "2026-10-24T09:16:40.854Z"
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"name": "intro",
|
||||||
|
"private": true,
|
||||||
|
"type": "module",
|
||||||
|
"scripts": {
|
||||||
|
"dev": "npx --yes hyperframes@0.8.191 preview",
|
||||||
|
"check": "npx --yes hyperframes@0.8.191 check",
|
||||||
|
"render": "npx --yes hyperframes@0.8.191 render",
|
||||||
|
"publish": "npx --yes hyperframes@0.8.191 publish"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,135 @@
|
|||||||
|
// 인스타 카드를 템플릿대로 JPEG로 만든다. 웹 화면(/render)을 헤드리스 Chrome으로 찍는다.
|
||||||
|
// 사용: npm run card -- <tarot|ootd> [--topic 주제] [--feedback 피드백] [--copy <웹 화면 '대화로 만들기'의 값>] [--out <폴더>]
|
||||||
|
// --topic·--feedback 이 있으면 Claude가 먼저 문구를 기획하고(관리자 서버 /api/plan), 기획안을 출력한 뒤 그 문구로 그린다.
|
||||||
|
// 날씨 타로는 --copy 가 없으면 주제 없이도 Claude가 기획한다. --color <테마>로 색을 고르고, 없으면 무작위.
|
||||||
|
// 그리기 전에 그날 카드에 없는 그림만 Codex로 만든다 (--no-images 로 건너뜀).
|
||||||
|
// --post 면 다 그린 뒤 날씨각 오늘 피드에 바로 올리고, --post-wait 면 승인 대기로 저장한다 (관리자 서버 /api/post).
|
||||||
|
// 지역은 고르지 않는다. 카드는 서울 예보로 만들고 카드에 지역 이름은 나가지 않는다 (src/cards/data.ts BASE_REGION)
|
||||||
|
import { execFileSync } from 'node:child_process'
|
||||||
|
import { existsSync, mkdirSync, readFileSync, rmSync } from 'node:fs'
|
||||||
|
import { resolve } from 'node:path'
|
||||||
|
|
||||||
|
const SLIDES = { tarot: 5, ootd: 6, intro: 8 }
|
||||||
|
// 기본 문구가 서비스 데이터 그대로라 Claude 기획이 꼭 필요한 템플릿 (src/cards/templates.tsx autoPlan)
|
||||||
|
const AUTO_PLAN = ['tarot']
|
||||||
|
// src/cards/themes.ts THEMES 의 id
|
||||||
|
const THEMES = ['sunset', 'sky', 'mint', 'berry', 'lemon', 'lavender']
|
||||||
|
const ADMIN_URL = process.env.ADMIN_URL ?? 'http://localhost:5175'
|
||||||
|
const API_URL = process.env.VITE_API_BASE_URL ?? 'http://localhost:9810'
|
||||||
|
const CHROME = process.env.CHROME_PATH ?? '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'
|
||||||
|
|
||||||
|
function fail(message) {
|
||||||
|
console.error(message)
|
||||||
|
process.exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
const args = process.argv.slice(2)
|
||||||
|
const flag = (name) => {
|
||||||
|
const i = args.indexOf(name)
|
||||||
|
if (i < 0) return null
|
||||||
|
const [, value] = args.splice(i, 2)
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
let copy = flag('--copy')
|
||||||
|
const topic = flag('--topic')
|
||||||
|
const feedback = flag('--feedback')
|
||||||
|
const color = flag('--color')
|
||||||
|
const outArg = flag('--out')
|
||||||
|
const take = (name) => args.includes(name) && args.splice(args.indexOf(name), 1).length > 0
|
||||||
|
const noImages = take('--no-images')
|
||||||
|
const postNow = take('--post')
|
||||||
|
const postWait = take('--post-wait')
|
||||||
|
const [template] = args
|
||||||
|
|
||||||
|
if (!SLIDES[template]) fail(`사용: npm run card -- <${Object.keys(SLIDES).join('|')}> [--topic 주제] [--feedback 피드백] [--color ${THEMES.join('|')}] [--copy 값] [--out 폴더]`)
|
||||||
|
if (color && !THEMES.includes(color)) fail(`색은 ${THEMES.join(', ')} 중 하나예요.`)
|
||||||
|
if (!existsSync(CHROME)) fail(`Chrome을 찾지 못했어요: ${CHROME}\nCHROME_PATH 환경변수로 경로를 알려 주세요.`)
|
||||||
|
|
||||||
|
await fetch(`${API_URL}/v1/region/list`).catch((e) => fail(`날씨각 API(${API_URL})에 연결하지 못했어요. 백엔드가 켜져 있는지 확인하세요. (${e.message})`))
|
||||||
|
await fetch(ADMIN_URL).catch(() => fail(`관리자 화면(${ADMIN_URL})이 꺼져 있어요. admin 폴더에서 npm run dev 를 먼저 켜 주세요.`))
|
||||||
|
|
||||||
|
const decode = (value) => (value ? JSON.parse(Buffer.from(value, 'base64url').toString('utf8')) : {})
|
||||||
|
if (topic !== null || feedback !== null || (!copy && AUTO_PLAN.includes(template))) {
|
||||||
|
const current = decode(copy)
|
||||||
|
console.log('Claude가 기획하는 중…')
|
||||||
|
const res = await fetch(`${ADMIN_URL}/api/plan`, {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: JSON.stringify({ template, topic: topic ?? '', feedback: feedback ?? '', current }),
|
||||||
|
})
|
||||||
|
const body = await res.json()
|
||||||
|
if (!res.ok) fail(`기획하지 못했어요: ${body.error}`)
|
||||||
|
console.log(`주제: ${body.topic}`)
|
||||||
|
for (const [k, v] of Object.entries(body.copy)) console.log(` ${k}: ${v.replaceAll('\n', ' / ')}`)
|
||||||
|
copy = Buffer.from(JSON.stringify({ ...current, ...body.copy })).toString('base64url')
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
const current = decode(copy)
|
||||||
|
const theme = color ?? current.theme ?? THEMES[Math.floor(Math.random() * THEMES.length)]
|
||||||
|
copy = Buffer.from(JSON.stringify({ ...current, theme })).toString('base64url')
|
||||||
|
console.log(`색: ${theme}`)
|
||||||
|
console.log(`다시 그리거나 피드백할 때: --copy ${copy}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 그날 카드에 필요한 그림 중 없는 것만 Codex로 만든다 (관리자 서버 /api/gen-image, 한 장씩)
|
||||||
|
if (!noImages) {
|
||||||
|
const start = await fetch(`${ADMIN_URL}/api/gen-image`, {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: JSON.stringify({ template, copy: decode(copy) }),
|
||||||
|
}).then((r) => r.json())
|
||||||
|
if (start.error) fail(`그림을 만들지 못했어요: ${start.error}`)
|
||||||
|
if (start.status === 'running') {
|
||||||
|
console.log(`그림 ${start.total}장 만드는 중 (Codex, 한 장에 1~2분)…`)
|
||||||
|
let state = start
|
||||||
|
while (state.status === 'running') {
|
||||||
|
await new Promise((r) => setTimeout(r, 5000))
|
||||||
|
state = await fetch(`${ADMIN_URL}/api/gen-image`).then((r) => r.json())
|
||||||
|
}
|
||||||
|
for (const line of state.log) console.log(` ${line}`)
|
||||||
|
if (state.status === 'failed') console.log('일부 그림을 못 만들어 그 장은 아이콘·옷 이름으로 나가요.')
|
||||||
|
// 새 그림이 화면에 반영될 시간
|
||||||
|
await new Promise((r) => setTimeout(r, 3000))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const day = new Date(Date.now() + 9 * 3600_000).toISOString().slice(0, 10)
|
||||||
|
const outDir = resolve(outArg ?? `out/${day}`)
|
||||||
|
mkdirSync(outDir, { recursive: true })
|
||||||
|
|
||||||
|
const files = []
|
||||||
|
for (let slide = 1; slide <= SLIDES[template]; slide++) {
|
||||||
|
const query = new URLSearchParams({ template, slide: String(slide) })
|
||||||
|
if (copy) query.set('copy', copy)
|
||||||
|
const png = resolve(outDir, `${day}_${template}_${slide}.png`)
|
||||||
|
const jpg = png.replace(/\.png$/, '.jpg')
|
||||||
|
execFileSync(CHROME, [
|
||||||
|
'--headless=new',
|
||||||
|
'--disable-gpu',
|
||||||
|
'--hide-scrollbars',
|
||||||
|
'--force-device-scale-factor=1',
|
||||||
|
'--window-size=1080,1350',
|
||||||
|
'--virtual-time-budget=20000',
|
||||||
|
`--screenshot=${png}`,
|
||||||
|
`${ADMIN_URL}/render?${query}`,
|
||||||
|
], { stdio: 'ignore' })
|
||||||
|
execFileSync('sips', ['-s', 'format', 'jpeg', '-s', 'formatOptions', '92', png, '--out', jpg], { stdio: 'ignore' })
|
||||||
|
rmSync(png)
|
||||||
|
files.push(jpg)
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`${template} · ${files.length}장`)
|
||||||
|
for (const f of files) console.log(f)
|
||||||
|
|
||||||
|
if (postNow || postWait) {
|
||||||
|
const images = files.map((f) => readFileSync(f).toString('base64'))
|
||||||
|
const res = await fetch(`${ADMIN_URL}/api/post`, {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: JSON.stringify({ template, texts: decode(copy), images, publish: postNow }),
|
||||||
|
})
|
||||||
|
const body = await res.json()
|
||||||
|
if (!res.ok || body.result?.success === false) fail(`날씨각에 올리지 못했어요: ${body.error ?? body.result?.desc}`)
|
||||||
|
console.log(postNow ? `날씨각 오늘 피드에 올렸어요: 카드 ${body.card_id}, 포스트 ${body.post_id}` : `승인 대기로 저장했어요: 카드 ${body.card_id}`)
|
||||||
|
}
|
||||||
@@ -0,0 +1,99 @@
|
|||||||
|
// 카드 그림을 프롬프트 템플릿(image-prompts/<종류>.json)대로 Codex 이미지 생성으로 만들어 src/assets/<종류>/<id>.webp 에 넣는다.
|
||||||
|
// 넣은 그림은 카드에 자동으로 붙는다. 사용: npm run gen-image -- ootd <구간|스타일|구간-사람-스타일|missing> [스타일] [--force]
|
||||||
|
// 예: ootd cool casual (12~16도 캐주얼 6명) · ootd semi (세미정장 전 구간) · ootd cool-f20-casual · ootd missing formal
|
||||||
|
import { execFileSync } from 'node:child_process'
|
||||||
|
import { existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync } from 'node:fs'
|
||||||
|
import { tmpdir } from 'node:os'
|
||||||
|
import { join, resolve } from 'node:path'
|
||||||
|
|
||||||
|
const IMAGE_MODEL = process.env.CODEX_IMAGE_MODEL ?? 'gpt-6-sol'
|
||||||
|
|
||||||
|
function fail(message) {
|
||||||
|
console.error(message)
|
||||||
|
process.exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
const args = process.argv.slice(2)
|
||||||
|
const force = args.includes('--force')
|
||||||
|
const [kind, target, ...more] = args.filter((a) => !a.startsWith('--'))
|
||||||
|
const styleFilter = more[0]
|
||||||
|
const promptFile = resolve(`image-prompts/${kind}.json`)
|
||||||
|
if (!kind || !target || !existsSync(promptFile)) fail('사용: npm run gen-image -- <ootd|tarot> <id|missing> [--force]')
|
||||||
|
|
||||||
|
const spec = JSON.parse(readFileSync(promptFile, 'utf8'))
|
||||||
|
// 각 카드는 그림 목록을 따로 적지 않고 서비스의 각 목록에서 만든다
|
||||||
|
if (spec.deck === 'gak') {
|
||||||
|
const defs = JSON.parse(readFileSync(resolve('../backend/seed/index_definition.json'), 'utf8'))
|
||||||
|
spec.items = defs.map((g) => ({ id: g.code, motif: spec.scene.replaceAll('{name}', g.name).replaceAll('{meaning}', g.description), name: g.name, meaning: g.description }))
|
||||||
|
}
|
||||||
|
const outDir = resolve(`src/assets/${kind}`)
|
||||||
|
mkdirSync(outDir, { recursive: true })
|
||||||
|
const outPath = (id) => join(outDir, `${id}.webp`)
|
||||||
|
|
||||||
|
// 그림 한 장 = { id, 프롬프트 }. ootd 는 구간 × 스타일 × 사람, tarot 은 주제 꾸밈(skin)마다
|
||||||
|
const jobs = spec.bands
|
||||||
|
? spec.bands.flatMap((b) =>
|
||||||
|
Object.entries(b.outfits).flatMap(([style, byPersona]) =>
|
||||||
|
Object.entries(byPersona).map(([persona, outfit]) => ({
|
||||||
|
id: `${b.id}-${persona}-${style}`,
|
||||||
|
band: b.id,
|
||||||
|
style,
|
||||||
|
prompt: spec.style
|
||||||
|
.replace('{items}', outfit.items)
|
||||||
|
.replace('{persona}', spec.personas[persona].prompt)
|
||||||
|
.replace('{style}', spec.styles[style].prompt)
|
||||||
|
.replace('{trend}', spec.styles[style].trends?.[persona] ?? '')
|
||||||
|
.replace('{layering}', b.layering ?? ''),
|
||||||
|
})),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: spec.items.map((it) => ({
|
||||||
|
id: it.id,
|
||||||
|
band: it.id,
|
||||||
|
prompt: spec.style.replace('{motif}', it.motif).replace('{scene}', it.motif).replaceAll('{name}', it.name ?? '').replaceAll('{meaning}', it.meaning ?? '').replace('{card}', it.card ?? ''),
|
||||||
|
}))
|
||||||
|
// 카드에 필요한 그림만: 정확한 id 를 여러 개 받거나(npm run card·관리자 서버가 씀), 구간·스타일로 좁힌다
|
||||||
|
const exact = [target, ...more].filter((t) => jobs.some((j) => j.id === t))
|
||||||
|
const picked =
|
||||||
|
exact.length > 0 ? jobs.filter((j) => exact.includes(j.id))
|
||||||
|
: target === 'missing' ? jobs.filter((j) => !existsSync(outPath(j.id)))
|
||||||
|
: jobs.filter((j) => j.id === target || j.band === target || j.style === target)
|
||||||
|
const bands = exact.length === 0 && styleFilter ? picked.filter((j) => j.style === styleFilter) : picked
|
||||||
|
if (bands.length === 0) fail(target === 'missing' ? '빠진 그림이 없어요.' : `'${target}' 은 ${promptFile} 에 없어요.${spec.bands ? ` 구간: ${spec.bands.map((b) => b.id).join(', ')} / 스타일: ${Object.keys(spec.styles).join(', ')} / 사람: ${Object.keys(spec.personas).join(', ')}` : ` id: ${spec.items.map((i) => i.id).join(', ')}`}`)
|
||||||
|
|
||||||
|
const failed = []
|
||||||
|
for (const band of bands) {
|
||||||
|
if (existsSync(outPath(band.id)) && !force) {
|
||||||
|
console.log(`${band.id}: 이미 있어요 (다시 만들려면 --force)`)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
const prompt = band.prompt
|
||||||
|
const work = mkdtempSync(join(tmpdir(), `gen-${kind}-${band.id}-`))
|
||||||
|
const task = [
|
||||||
|
'내장 이미지 생성 도구로 아래 프롬프트 그대로 이미지를 만든다 (비율은 프롬프트를 따른다).',
|
||||||
|
'만든 이미지를 직접 열어 확인한다: 사람 얼굴·손·마네킹·글자·숫자·로고가 있거나, 프롬프트의 물건이 빠지거나 잘렸으면 한 번만 다시 만든다 (사용량을 아끼려고 최대 2장).',
|
||||||
|
`통과한 한 장만 이 폴더에 result.png 로 저장한다. 다른 파일은 만들지 않는다.`,
|
||||||
|
'',
|
||||||
|
prompt,
|
||||||
|
].join('\n')
|
||||||
|
console.log(`${band.id}: Codex로 그리는 중…`)
|
||||||
|
try {
|
||||||
|
// 그림은 이미지 생성 도구가 만들고 Codex 는 도구를 부르고 결과를 저장하는 역할뿐이라 중간 모델·낮은 추론으로 고정한다 (가장 싼 gpt-6-luna 는 결과를 파일로 저장하지 못하고, 기본 설정의 gpt-6-astra·xhigh 는 한도를 금방 소진한다)
|
||||||
|
execFileSync('codex', ['exec', '--skip-git-repo-check', '-C', work, '-s', 'workspace-write', '-m', IMAGE_MODEL, '-c', 'model_reasoning_effort="low"', task], { stdio: ['ignore', 'ignore', 'inherit'] })
|
||||||
|
} catch (e) {
|
||||||
|
rmSync(work, { recursive: true, force: true })
|
||||||
|
fail(`${band.id}: Codex 실행이 실패했어요 (${e.message}). 사용 한도나 로그인을 확인하세요.`)
|
||||||
|
}
|
||||||
|
const png = readdirSync(work).find((f) => f === 'result.png') ?? readdirSync(work).find((f) => f.endsWith('.png'))
|
||||||
|
// 저장을 빼먹는 건 그 한 장 문제라 나머지는 계속 만들고 끝에 모아서 알린다 (한도·로그인 실패는 위에서 바로 멈춤)
|
||||||
|
if (!png) {
|
||||||
|
console.error(`${band.id}: Codex가 그림을 저장하지 않았어요. 작업 폴더: ${work}`)
|
||||||
|
failed.push(band.id)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
execFileSync('cwebp', ['-quiet', '-q', '88', '-resize', '1024', '0', join(work, png), '-o', outPath(band.id)])
|
||||||
|
rmSync(work, { recursive: true, force: true })
|
||||||
|
console.log(`${band.id}: ${outPath(band.id)}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (failed.length) fail(`못 만든 그림: ${failed.join(", ")} — 다시: npm run gen-image -- ${kind} ${failed.join(" ")}`)
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
export type PlanContext = {
|
||||||
|
template: { id: string; name: string; about: string; how: string[] }
|
||||||
|
fields: { key: string; label: string }[]
|
||||||
|
current: Record<string, string>
|
||||||
|
weather: unknown
|
||||||
|
}
|
||||||
|
export function runPlan(ctx: PlanContext, opts?: { topic?: string; feedback?: string; fixed?: { question?: string; cards?: string[] } }): Promise<{ topic: string; copy: Record<string, string> }>
|
||||||
@@ -0,0 +1,138 @@
|
|||||||
|
// 카드 문구 기획: 템플릿 칸·오늘 날씨·주제·피드백을 Claude CLI(claude -p)에 넘겨 칸별 문구를 받는다.
|
||||||
|
// 관리자 서버(/api/plan)와 npm run card --topic 이 같이 쓴다. API 키 없이 이 맥에 로그인된 Claude Code를 쓴다.
|
||||||
|
import { execFile } from 'node:child_process'
|
||||||
|
import { readdirSync, readFileSync } from 'node:fs'
|
||||||
|
import { tmpdir } from 'node:os'
|
||||||
|
import { resolve } from 'node:path'
|
||||||
|
|
||||||
|
const pngNames = (dir) =>
|
||||||
|
readdirSync(resolve(import.meta.dirname, dir))
|
||||||
|
.filter((f) => f.endsWith('.png'))
|
||||||
|
.map((f) => f.replace(/\.png$/, ''))
|
||||||
|
// 서비스 각·날씨 아이콘
|
||||||
|
const ICONS = pngNames('../../frontend/public/icons')
|
||||||
|
const TOPICS = JSON.parse(readFileSync(resolve(import.meta.dirname, '../topics.json'), 'utf8')).categories
|
||||||
|
const questionOf = (topic) => {
|
||||||
|
const c = categoryOf(topic)
|
||||||
|
if (!c) return null
|
||||||
|
const sub = c.subtopics.find((x) => topic.includes(x))
|
||||||
|
return c.questions[sub ?? ''] ?? c.questions['']
|
||||||
|
}
|
||||||
|
// 날씨 타로 카드 = 날씨각 각 카드 (서비스와 같은 각 목록)
|
||||||
|
const DECK = JSON.parse(readFileSync(resolve(import.meta.dirname, '../../backend/seed/index_definition.json'), 'utf8')).map((g) => ({ id: g.code, name: g.name, icon: g.icon, meaning: g.description }))
|
||||||
|
const categoryOf = (topic) => TOPICS.find((c) => topic.includes(c.name) || c.subtopics.some((s) => topic.includes(s)))
|
||||||
|
|
||||||
|
const RULES = [
|
||||||
|
'너는 한국 날씨 서비스 "날씨각"의 인스타그램 카드 문구 담당이다.',
|
||||||
|
'오늘 날씨 사실(아래 데이터)을 근거로, 주제와 엮어 재미있게 쓴다. 날씨 사실을 지어내지 않는다.',
|
||||||
|
'날씨를 모르는 사람도 바로 알아듣는 쉬운 말로 쓴다. 숫자만 나열하거나 전문 용어, 점수, 판정 이름을 쓰지 않는다.',
|
||||||
|
'좋은 말과 나쁜 말을 한 문장에 섞지 않는다. 뜻 없는 비교("더 나아요")를 쓰지 않는다.',
|
||||||
|
'카드에 들어가야 하니 칸마다 지금 문구와 비슷한 길이(최대 1.3배)로 쓴다(날씨 타로 리딩은 아래 길이 규칙을 따른다). 줄바꿈은 " ⏎ "로 표시하고, 개수를 지금 문구와 맞춘다.',
|
||||||
|
'강조할 말은 *별표*로 감싼다. 지금 문구에 별표가 있으면 같은 자리에 둔다.',
|
||||||
|
`아이콘 칸(i1·i2·i3)은 다음 중 하나의 파일 이름만 쓴다: ${ICONS.join(', ')}`,
|
||||||
|
'쓰지 않는 것: 투자 권유(종목, 매수·매도, 수익·손실 단정), 건강·의료 단정, 사고·재난·정치, 특정 집단 비하, 욕설.',
|
||||||
|
'"재미로"라는 말이 지금 문구에 있으면 남긴다.',
|
||||||
|
'주제가 있으면 제목·카드 이름·문장을 모두 그 주제의 말로 바꾼다. 오늘 날씨 사실은 주제에 빗대는 근거로만 쓴다.',
|
||||||
|
'날씨각의 각 요약 문장("오전 10시 14°, 바람 조금")을 그대로 옮기지 않는다. 날씨 사실은 쉬운 말로 다시 쓴다.',
|
||||||
|
'템플릿 설명(아래 ## 템플릿 목록)을 반드시 따른다.',
|
||||||
|
].join('\n')
|
||||||
|
|
||||||
|
const isTarot = (ctx) => ctx.template.id === 'tarot'
|
||||||
|
// 각 카드(이름·그림)는 Claude가 쓰지 않고 고른 카드(card1~3)로 채운다
|
||||||
|
const DECK_KEY = /^[cni]\d$/
|
||||||
|
|
||||||
|
// 실제 타로 리더(온도타로·타로하는 아율·가문비타로·알라딘타로 등 유튜브 설명란) 말투에서 뽑은 규칙. 2026-10-23 조사, admin/AGENTS.md 참고
|
||||||
|
const TAROT_TONE = [
|
||||||
|
'## 리딩 말투 (반드시)',
|
||||||
|
'진짜 타로 리더가 한 사람에게 말하듯 쓴다. 질문자는 "님"이라 부르거나 생략하고, 상대는 "그 사람"이라 부른다. "당신·그대"는 쓰지 않는다.',
|
||||||
|
'해요체가 기본이고, 단정할 땐 합니다체 한 문장을 섞는다("~하고 있습니다", "~꺼낼 겁니다"). 카드를 보는 중인 느낌으로 "~네요/~거든요/~죠" 같은 어미를 섞는다.',
|
||||||
|
'구조: ① 그 사람(또는 님)의 지금 상태를 겉모습과 속마음을 대비해서 한 문장("겉으론 평소랑 똑같이 굴어도 말 걸 타이밍만 재는 중이거든요") ② "다만/그런데"로 한 번 꺾기 ③ 오늘 할 행동 딱 하나, 타이밍과 함께. 각 카드의 활동(걷기·커피·바깥 자리)이 그 행동이 된다.',
|
||||||
|
'폰에서 확인할 수 있는 신호(답장 길이, 읽씹, 프사, 말끝 흐림)나 대사 한 줄("잠깐 걸을래?")처럼 구체적인 디테일을 하나 넣는다.',
|
||||||
|
'길이: 3문장, 전체 70~95자. 줄바꿈 없음. 별표 강조는 쓰지 않는다.',
|
||||||
|
'세 장이 같은 틀로 시작하지 않는다. "겉으론 ~ 속으론" 대비는 한 장에만, 다른 장은 상대의 상태 묘사·질문으로 붙잡기("요즘 답장 짧아졌죠?")·단정 한 줄 등으로 다르게 연다. "다만"도 세 장에 다 쓰지 않는다.',
|
||||||
|
'하지 않는 것: "~이면 ~해요/~하면 ~돼요" 공식, 모든 문장이 같은 어미("~해요"만 세 번), "~할 수 있어요/~일 수 있어요" 두 번 이상, "~것이 중요합니다", "도움이 되길", 명사 나열형 조언, 설명조("이 카드는 ~을 뜻해요"는 세 장 통틀어 한 번만), 이모지, 느낌표 두 개 이상, 리딩 본문에 기온·시각 숫자(숫자는 행운 포인트에만), 뻔한 덕담("기대해도 좋은 하루").',
|
||||||
|
'좋은 예: "오늘 그 사람, 님 생각보다 가까이 와 있어요. 겉으론 평소랑 똑같이 굴어도 말 걸 타이밍만 재는 중이거든요. 해 지고 선선해질 때 \'잠깐 걸을래?\' 한마디면 돼요."',
|
||||||
|
'나쁜 예(쓰지 말 것): "커피 한 잔이면 말문이 열려요. 아침 인사부터 먼저 건네요." / "걷다 보면 거리가 가까워져요. 저녁 산책을 먼저 제안해요."',
|
||||||
|
'키워드(k)는 4~8자 명사구("같이 걷는 시간", "먼저 보내는 한 줄"). 행운 포인트(l)는 시간·날씨·행동 한 줄 22자 이내("저녁 8시, 17도로 걷기 딱 좋아요").',
|
||||||
|
]
|
||||||
|
|
||||||
|
function tarotSection(topic) {
|
||||||
|
return [
|
||||||
|
'',
|
||||||
|
'## 각 카드 (이 목록에서만 고른다. card1·card2·card3에 서로 다른 code)',
|
||||||
|
questionOf(topic) ? `표지 질문(question)은 이것을 쓴다(피드백이 바꾸라고 하면 바꾼다): ${questionOf(topic)}` : '표지 질문(question)은 주제에 맞는 "오늘 ~할까요?" 꼴 질문 하나를 쓴다.',
|
||||||
|
'오늘 날씨 데이터의 오늘_각_점수에서 점수가 높은 각(오늘 실제로 하기 좋은 각) 가운데 질문과 엮을 수 있는 것을 고른다. 세 장은 서로 다른 답(하나는 긍정, 하나는 조건부, 하나는 기다리기 같은 식)이 되게 고르고, 되도록 아침·낮·저녁(밤) 각에서 하나씩 골라 세 장이 하루로 이어지게 한다.',
|
||||||
|
...TAROT_TONE,
|
||||||
|
'',
|
||||||
|
...DECK.map((c) => `- ${c.id}: ${c.name} — ${c.meaning}`),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildPrompt(ctx, { topic, feedback, fixed = {} }) {
|
||||||
|
// 줄바꿈은 ⏎ 로 보여 주고 받을 때 되돌린다 (JSON 안의 \\n 을 글자로 따라 쓰는 일을 막는다)
|
||||||
|
const fields = ctx.fields.map((f) => `- ${f.key} (${f.label}): ${String(ctx.current[f.key] ?? '').replaceAll('\n', ' ⏎ ')}`).join('\n')
|
||||||
|
return [
|
||||||
|
RULES,
|
||||||
|
'',
|
||||||
|
`## 템플릿: ${ctx.template.name} — ${ctx.template.about}`,
|
||||||
|
...ctx.template.how.map((h) => `- ${h}`),
|
||||||
|
'',
|
||||||
|
'## 오늘 날씨 (서울)',
|
||||||
|
JSON.stringify(ctx.weather, null, 1),
|
||||||
|
'',
|
||||||
|
'## 지금 문구 (칸 이름: 값)',
|
||||||
|
fields,
|
||||||
|
'',
|
||||||
|
topic ? `## 주제: ${topic}` : `## 주제: 없음 — 다음 대주제·소주제 중 오늘 날씨와 어울리는 것을 하나 골라 topic에 "대주제 소주제"로 적고 그 주제로 쓴다: ${TOPICS.map((c) => `${c.name}(${c.subtopics.join('·')})`).join(', ')}`,
|
||||||
|
feedback ? `## 피드백 (반드시 반영): ${feedback}` : '',
|
||||||
|
'',
|
||||||
|
...(isTarot(ctx) ? tarotSection(topic) : []),
|
||||||
|
fixed.question ? `## 질문은 관리자가 정했다(그대로 쓴다): ${fixed.question}` : '',
|
||||||
|
fixed.cards?.length ? `## 카드는 관리자가 골랐다(card1·card2·card3 순서 그대로): ${fixed.cards.join(', ')}` : '',
|
||||||
|
'모든 칸을 채운 JSON으로만 답한다. topic에는 쓴 주제를 짧게 적는다.',
|
||||||
|
].join('\n')
|
||||||
|
}
|
||||||
|
|
||||||
|
function schema(ctx) {
|
||||||
|
const properties = { topic: { type: 'string' } }
|
||||||
|
for (const f of ctx.fields) if (!(isTarot(ctx) && DECK_KEY.test(f.key))) properties[f.key] = { type: 'string' }
|
||||||
|
if (isTarot(ctx)) for (const k of ['card1', 'card2', 'card3']) properties[k] = { type: 'string', enum: DECK.map((c) => c.id) }
|
||||||
|
return { type: 'object', properties, required: Object.keys(properties), additionalProperties: false }
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @returns {Promise<{ topic: string, copy: Record<string, string> }>} */
|
||||||
|
export function runPlan(ctx, { topic = '', feedback = '', fixed = {} } = {}) {
|
||||||
|
const args = ['-p', buildPrompt(ctx, { topic, feedback, fixed }), '--output-format', 'json', '--json-schema', JSON.stringify(schema(ctx)), '--tools', '', '--no-session-persistence', '--model', 'sonnet']
|
||||||
|
return new Promise((done, fail) => {
|
||||||
|
execFile('claude', args, { cwd: tmpdir(), timeout: 180_000, maxBuffer: 10 * 1024 * 1024 }, (err, stdout) => {
|
||||||
|
if (err) return fail(new Error(`Claude CLI 실행 실패: ${err.message}. 터미널에서 claude 로그인 상태를 확인하세요.`))
|
||||||
|
let out
|
||||||
|
try {
|
||||||
|
out = JSON.parse(stdout)
|
||||||
|
} catch {
|
||||||
|
return fail(new Error(`Claude 답을 읽지 못했어요: ${stdout.slice(0, 300)}`))
|
||||||
|
}
|
||||||
|
const result = out.structured_output ?? (typeof out.result === 'string' ? JSON.parse(out.result) : null)
|
||||||
|
if (out.is_error || !result) return fail(new Error(`Claude가 기획안을 주지 못했어요: ${String(out.result ?? '').slice(0, 300)}`))
|
||||||
|
const copy = {}
|
||||||
|
if (isTarot(ctx)) {
|
||||||
|
if (fixed.question) result.question = fixed.question
|
||||||
|
fixed.cards?.forEach((code, i) => (result[`card${i + 1}`] = code))
|
||||||
|
;['card1', 'card2', 'card3'].forEach((k, i) => {
|
||||||
|
const card = DECK.find((c) => c.id === result[k])
|
||||||
|
if (card) Object.assign(result, { [`c${i + 1}`]: card.id, [`n${i + 1}`]: card.name, [`i${i + 1}`]: card.icon })
|
||||||
|
})
|
||||||
|
}
|
||||||
|
for (const f of ctx.fields) {
|
||||||
|
const value = String(result[f.key] ?? '').replace(/\s*⏎\s*/g, '\n').replace(/\\n/g, '\n').trim()
|
||||||
|
const badIcon = /^i\d$/.test(f.key) && !ICONS.includes(value)
|
||||||
|
copy[f.key] = value && !badIcon ? value : ctx.current[f.key]
|
||||||
|
}
|
||||||
|
const finalTopic = String(result.topic || topic)
|
||||||
|
copy.skin = categoryOf(finalTopic)?.skin ?? 'star'
|
||||||
|
// 각 카드 id·그림은 화면 칸이 아니라 덱에서 채운 값 그대로
|
||||||
|
if (isTarot(ctx)) for (const k of ['c1', 'c2', 'c3', 'i1', 'i2', 'i3']) if (result[k]) copy[k] = result[k]
|
||||||
|
done({ topic: finalTopic, copy })
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
import { BrowserRouter, Route, Routes } from 'react-router'
|
||||||
|
import { AdminLayout } from './pages/AdminLayout'
|
||||||
|
import { CardsPage } from './pages/CardsPage'
|
||||||
|
import { HistoryPage } from './pages/HistoryPage'
|
||||||
|
import { RenderPage } from './pages/RenderPage'
|
||||||
|
|
||||||
|
export default function App() {
|
||||||
|
return (
|
||||||
|
<BrowserRouter>
|
||||||
|
<Routes>
|
||||||
|
{/* npm run card 가 찍는 화면: 카드 한 장만, 1080×1350 */}
|
||||||
|
<Route path="render" element={<RenderPage />} />
|
||||||
|
<Route element={<AdminLayout />}>
|
||||||
|
<Route index element={<CardsPage />} />
|
||||||
|
<Route path="history" element={<HistoryPage />} />
|
||||||
|
<Route path="*" element={<CardsPage />} />
|
||||||
|
</Route>
|
||||||
|
</Routes>
|
||||||
|
</BrowserRouter>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
// This file is auto-generated by @hey-api/openapi-ts
|
||||||
|
|
||||||
|
import { type Client, type ClientOptions, type Config, createClient, createConfig } from './client';
|
||||||
|
import type { ClientOptions as ClientOptions2 } from './types.gen';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The `createClientConfig()` function will be called on client initialization
|
||||||
|
* and the returned object will become the client's initial configuration.
|
||||||
|
*
|
||||||
|
* You may want to initialize your client this way instead of calling
|
||||||
|
* `setConfig()`. This is useful for example if you're using Next.js
|
||||||
|
* to ensure your client always has the correct values.
|
||||||
|
*/
|
||||||
|
export type CreateClientConfig<T extends ClientOptions = ClientOptions2> = (override?: Config<ClientOptions & T>) => Config<Required<ClientOptions> & T>;
|
||||||
|
|
||||||
|
export const client: Client = createClient(createConfig<ClientOptions2>({ throwOnError: true }));
|
||||||
@@ -0,0 +1,277 @@
|
|||||||
|
// This file is auto-generated by @hey-api/openapi-ts
|
||||||
|
|
||||||
|
import { createSseClient } from '../core/serverSentEvents.gen';
|
||||||
|
import type { HttpMethod } from '../core/types.gen';
|
||||||
|
import { getValidRequestBody } from '../core/utils.gen';
|
||||||
|
import type { Client, Config, RequestOptions, ResolvedRequestOptions } from './types.gen';
|
||||||
|
import {
|
||||||
|
buildUrl,
|
||||||
|
createConfig,
|
||||||
|
createInterceptors,
|
||||||
|
getParseAs,
|
||||||
|
mergeConfigs,
|
||||||
|
mergeHeaders,
|
||||||
|
setAuthParams,
|
||||||
|
} from './utils.gen';
|
||||||
|
|
||||||
|
type ReqInit = Omit<RequestInit, 'body' | 'headers'> & {
|
||||||
|
body?: any;
|
||||||
|
headers: ReturnType<typeof mergeHeaders>;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const createClient = (config: Config = {}): Client => {
|
||||||
|
let _config = mergeConfigs(createConfig(), config);
|
||||||
|
|
||||||
|
const getConfig = (): Config => ({ ..._config });
|
||||||
|
|
||||||
|
const setConfig = (config: Config): Config => {
|
||||||
|
_config = mergeConfigs(_config, config);
|
||||||
|
return getConfig();
|
||||||
|
};
|
||||||
|
|
||||||
|
const interceptors = createInterceptors<Request, Response, unknown, ResolvedRequestOptions>();
|
||||||
|
|
||||||
|
const beforeRequest = async <
|
||||||
|
TData = unknown,
|
||||||
|
TResponseStyle extends 'data' | 'fields' = 'fields',
|
||||||
|
ThrowOnError extends boolean = boolean,
|
||||||
|
Url extends string = string,
|
||||||
|
>(
|
||||||
|
options: RequestOptions<TData, TResponseStyle, ThrowOnError, Url>,
|
||||||
|
) => {
|
||||||
|
const opts = {
|
||||||
|
..._config,
|
||||||
|
...options,
|
||||||
|
fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
|
||||||
|
headers: mergeHeaders(_config.headers, options.headers),
|
||||||
|
serializedBody: undefined as string | undefined,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (opts.security) {
|
||||||
|
await setAuthParams(opts);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (opts.requestValidator) {
|
||||||
|
await opts.requestValidator(opts);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (opts.body !== undefined && opts.bodySerializer) {
|
||||||
|
opts.serializedBody = opts.bodySerializer(opts.body) as string | undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
// remove Content-Type header if body is empty to avoid sending invalid requests
|
||||||
|
if (opts.body === undefined || opts.serializedBody === '') {
|
||||||
|
opts.headers.delete('Content-Type');
|
||||||
|
}
|
||||||
|
|
||||||
|
const resolvedOpts = opts as typeof opts &
|
||||||
|
ResolvedRequestOptions<TResponseStyle, ThrowOnError, Url>;
|
||||||
|
const url = buildUrl(resolvedOpts);
|
||||||
|
|
||||||
|
return { opts: resolvedOpts, url };
|
||||||
|
};
|
||||||
|
|
||||||
|
const request: Client['request'] = async (options) => {
|
||||||
|
const throwOnError = options.throwOnError ?? _config.throwOnError;
|
||||||
|
const responseStyle = options.responseStyle ?? _config.responseStyle;
|
||||||
|
|
||||||
|
let request: Request | undefined;
|
||||||
|
let response: Response | undefined;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const { opts, url } = await beforeRequest(options);
|
||||||
|
const requestInit: ReqInit = {
|
||||||
|
redirect: 'follow',
|
||||||
|
...opts,
|
||||||
|
body: getValidRequestBody(opts),
|
||||||
|
};
|
||||||
|
|
||||||
|
request = new Request(url, requestInit);
|
||||||
|
|
||||||
|
for (const fn of interceptors.request.fns) {
|
||||||
|
if (fn) {
|
||||||
|
request = await fn(request, opts);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// fetch must be assigned here, otherwise it would throw the error:
|
||||||
|
// TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation
|
||||||
|
const _fetch = opts.fetch!;
|
||||||
|
|
||||||
|
response = await _fetch(request);
|
||||||
|
|
||||||
|
for (const fn of interceptors.response.fns) {
|
||||||
|
if (fn) {
|
||||||
|
response = await fn(response, request, opts);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const result = {
|
||||||
|
request,
|
||||||
|
response,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (response.ok) {
|
||||||
|
const parseAs =
|
||||||
|
(opts.parseAs === 'auto'
|
||||||
|
? getParseAs(response.headers.get('Content-Type'))
|
||||||
|
: opts.parseAs) ?? 'json';
|
||||||
|
|
||||||
|
if (response.status === 204 || response.headers.get('Content-Length') === '0') {
|
||||||
|
let emptyData: any;
|
||||||
|
switch (parseAs) {
|
||||||
|
case 'arrayBuffer':
|
||||||
|
case 'blob':
|
||||||
|
case 'text':
|
||||||
|
emptyData = await response[parseAs]();
|
||||||
|
break;
|
||||||
|
case 'formData':
|
||||||
|
emptyData = new FormData();
|
||||||
|
break;
|
||||||
|
case 'stream':
|
||||||
|
emptyData = response.body;
|
||||||
|
break;
|
||||||
|
case 'json':
|
||||||
|
default:
|
||||||
|
emptyData = {};
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return opts.responseStyle === 'data'
|
||||||
|
? emptyData
|
||||||
|
: {
|
||||||
|
data: emptyData,
|
||||||
|
...result,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
let data: any;
|
||||||
|
switch (parseAs) {
|
||||||
|
case 'arrayBuffer':
|
||||||
|
case 'blob':
|
||||||
|
case 'formData':
|
||||||
|
case 'text':
|
||||||
|
data = await response[parseAs]();
|
||||||
|
break;
|
||||||
|
case 'json': {
|
||||||
|
// Some servers return 200 with no Content-Length and empty body.
|
||||||
|
// response.json() would throw; read as text and parse if non-empty.
|
||||||
|
const text = await response.text();
|
||||||
|
data = text ? JSON.parse(text) : {};
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'stream':
|
||||||
|
return opts.responseStyle === 'data'
|
||||||
|
? response.body
|
||||||
|
: {
|
||||||
|
data: response.body,
|
||||||
|
...result,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parseAs === 'json') {
|
||||||
|
if (opts.responseValidator) {
|
||||||
|
await opts.responseValidator(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (opts.responseTransformer) {
|
||||||
|
data = await opts.responseTransformer(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return opts.responseStyle === 'data'
|
||||||
|
? data
|
||||||
|
: {
|
||||||
|
data,
|
||||||
|
...result,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const textError = await response.text();
|
||||||
|
let jsonError: unknown;
|
||||||
|
|
||||||
|
try {
|
||||||
|
jsonError = JSON.parse(textError);
|
||||||
|
} catch {
|
||||||
|
// noop
|
||||||
|
}
|
||||||
|
|
||||||
|
throw jsonError ?? textError;
|
||||||
|
} catch (error) {
|
||||||
|
let finalError = error;
|
||||||
|
|
||||||
|
for (const fn of interceptors.error.fns) {
|
||||||
|
if (fn) {
|
||||||
|
finalError = await fn(finalError, response, request, options as ResolvedRequestOptions);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
finalError = finalError || {};
|
||||||
|
|
||||||
|
if (throwOnError) {
|
||||||
|
throw finalError;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: we probably want to return error and improve types
|
||||||
|
return responseStyle === 'data'
|
||||||
|
? undefined
|
||||||
|
: {
|
||||||
|
error: finalError,
|
||||||
|
request,
|
||||||
|
response,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const makeMethodFn = (method: Uppercase<HttpMethod>) => (options: RequestOptions) =>
|
||||||
|
request({ ...options, method });
|
||||||
|
|
||||||
|
const makeSseFn = (method: Uppercase<HttpMethod>) => async (options: RequestOptions) => {
|
||||||
|
const { opts, url } = await beforeRequest(options);
|
||||||
|
return createSseClient({
|
||||||
|
...opts,
|
||||||
|
body: opts.body as BodyInit | null | undefined,
|
||||||
|
method,
|
||||||
|
onRequest: async (url, init) => {
|
||||||
|
let request = new Request(url, init);
|
||||||
|
for (const fn of interceptors.request.fns) {
|
||||||
|
if (fn) {
|
||||||
|
request = await fn(request, opts);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return request;
|
||||||
|
},
|
||||||
|
serializedBody: getValidRequestBody(opts) as BodyInit | null | undefined,
|
||||||
|
url,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const _buildUrl: Client['buildUrl'] = (options) => buildUrl({ ..._config, ...options });
|
||||||
|
|
||||||
|
return {
|
||||||
|
buildUrl: _buildUrl,
|
||||||
|
connect: makeMethodFn('CONNECT'),
|
||||||
|
delete: makeMethodFn('DELETE'),
|
||||||
|
get: makeMethodFn('GET'),
|
||||||
|
getConfig,
|
||||||
|
head: makeMethodFn('HEAD'),
|
||||||
|
interceptors,
|
||||||
|
options: makeMethodFn('OPTIONS'),
|
||||||
|
patch: makeMethodFn('PATCH'),
|
||||||
|
post: makeMethodFn('POST'),
|
||||||
|
put: makeMethodFn('PUT'),
|
||||||
|
request,
|
||||||
|
setConfig,
|
||||||
|
sse: {
|
||||||
|
connect: makeSseFn('CONNECT'),
|
||||||
|
delete: makeSseFn('DELETE'),
|
||||||
|
get: makeSseFn('GET'),
|
||||||
|
head: makeSseFn('HEAD'),
|
||||||
|
options: makeSseFn('OPTIONS'),
|
||||||
|
patch: makeSseFn('PATCH'),
|
||||||
|
post: makeSseFn('POST'),
|
||||||
|
put: makeSseFn('PUT'),
|
||||||
|
trace: makeSseFn('TRACE'),
|
||||||
|
},
|
||||||
|
trace: makeMethodFn('TRACE'),
|
||||||
|
} as Client;
|
||||||
|
};
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
// This file is auto-generated by @hey-api/openapi-ts
|
||||||
|
|
||||||
|
export type { Auth } from '../core/auth.gen';
|
||||||
|
export type { QuerySerializerOptions } from '../core/bodySerializer.gen';
|
||||||
|
export {
|
||||||
|
formDataBodySerializer,
|
||||||
|
jsonBodySerializer,
|
||||||
|
urlSearchParamsBodySerializer,
|
||||||
|
} from '../core/bodySerializer.gen';
|
||||||
|
export { buildClientParams } from '../core/params.gen';
|
||||||
|
export { serializeQueryKeyValue } from '../core/queryKeySerializer.gen';
|
||||||
|
export type { ServerSentEventsResult } from '../core/serverSentEvents.gen';
|
||||||
|
export type { ClientMeta } from '../core/types.gen';
|
||||||
|
export { createClient } from './client.gen';
|
||||||
|
export type {
|
||||||
|
Client,
|
||||||
|
ClientOptions,
|
||||||
|
Config,
|
||||||
|
CreateClientConfig,
|
||||||
|
Options,
|
||||||
|
RequestOptions,
|
||||||
|
RequestResult,
|
||||||
|
ResolvedRequestOptions,
|
||||||
|
ResponseStyle,
|
||||||
|
TDataShape,
|
||||||
|
} from './types.gen';
|
||||||
|
export { createConfig, mergeHeaders } from './utils.gen';
|
||||||
@@ -0,0 +1,218 @@
|
|||||||
|
// This file is auto-generated by @hey-api/openapi-ts
|
||||||
|
|
||||||
|
import type { Auth } from '../core/auth.gen';
|
||||||
|
import type {
|
||||||
|
ServerSentEventsOptions,
|
||||||
|
ServerSentEventsResult,
|
||||||
|
} from '../core/serverSentEvents.gen';
|
||||||
|
import type { Client as CoreClient, Config as CoreConfig } from '../core/types.gen';
|
||||||
|
import type { Middleware } from './utils.gen';
|
||||||
|
|
||||||
|
export type ResponseStyle = 'data' | 'fields';
|
||||||
|
|
||||||
|
export interface Config<T extends ClientOptions = ClientOptions>
|
||||||
|
extends Omit<RequestInit, 'body' | 'headers' | 'method'>, CoreConfig {
|
||||||
|
/**
|
||||||
|
* Base URL for all requests made by this client.
|
||||||
|
*/
|
||||||
|
baseUrl?: T['baseUrl'];
|
||||||
|
/**
|
||||||
|
* Fetch API implementation. You can use this option to provide a custom
|
||||||
|
* fetch instance.
|
||||||
|
*
|
||||||
|
* @default globalThis.fetch
|
||||||
|
*/
|
||||||
|
fetch?: typeof fetch;
|
||||||
|
/**
|
||||||
|
* Please don't use the Fetch client for Next.js applications. The `next`
|
||||||
|
* options won't have any effect.
|
||||||
|
*
|
||||||
|
* Install {@link https://www.npmjs.com/package/@hey-api/client-next `@hey-api/client-next`} instead.
|
||||||
|
*/
|
||||||
|
next?: never;
|
||||||
|
/**
|
||||||
|
* Return the response data parsed in a specified format. By default, `auto`
|
||||||
|
* will infer the appropriate method from the `Content-Type` response header.
|
||||||
|
* You can override this behavior with any of the {@link Body} methods.
|
||||||
|
* Select `stream` if you don't want to parse response data at all.
|
||||||
|
*
|
||||||
|
* @default 'auto'
|
||||||
|
*/
|
||||||
|
parseAs?: 'arrayBuffer' | 'auto' | 'blob' | 'formData' | 'json' | 'stream' | 'text';
|
||||||
|
/**
|
||||||
|
* Should we return only data or multiple fields (data, error, response, etc.)?
|
||||||
|
*
|
||||||
|
* @default 'fields'
|
||||||
|
*/
|
||||||
|
responseStyle?: ResponseStyle;
|
||||||
|
/**
|
||||||
|
* Throw an error instead of returning it in the response?
|
||||||
|
*
|
||||||
|
* @default false
|
||||||
|
*/
|
||||||
|
throwOnError?: T['throwOnError'];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RequestOptions<
|
||||||
|
TData = unknown,
|
||||||
|
TResponseStyle extends ResponseStyle = 'fields',
|
||||||
|
ThrowOnError extends boolean = boolean,
|
||||||
|
Url extends string = string,
|
||||||
|
>
|
||||||
|
extends
|
||||||
|
Config<{
|
||||||
|
responseStyle: TResponseStyle;
|
||||||
|
throwOnError: ThrowOnError;
|
||||||
|
}>,
|
||||||
|
Pick<
|
||||||
|
ServerSentEventsOptions<TData>,
|
||||||
|
| 'onRequest'
|
||||||
|
| 'onSseError'
|
||||||
|
| 'onSseEvent'
|
||||||
|
| 'sseDefaultRetryDelay'
|
||||||
|
| 'sseMaxRetryAttempts'
|
||||||
|
| 'sseMaxRetryDelay'
|
||||||
|
> {
|
||||||
|
/**
|
||||||
|
* Any body that you want to add to your request.
|
||||||
|
*
|
||||||
|
* {@link https://developer.mozilla.org/docs/Web/API/fetch#body}
|
||||||
|
*/
|
||||||
|
body?: unknown;
|
||||||
|
path?: Record<string, unknown>;
|
||||||
|
query?: Record<string, unknown>;
|
||||||
|
/**
|
||||||
|
* Security mechanism(s) to use for the request.
|
||||||
|
*/
|
||||||
|
security?: ReadonlyArray<Auth>;
|
||||||
|
url: Url;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ResolvedRequestOptions<
|
||||||
|
TResponseStyle extends ResponseStyle = 'fields',
|
||||||
|
ThrowOnError extends boolean = boolean,
|
||||||
|
Url extends string = string,
|
||||||
|
> extends RequestOptions<unknown, TResponseStyle, ThrowOnError, Url> {
|
||||||
|
headers: Headers;
|
||||||
|
serializedBody?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type RequestResult<
|
||||||
|
TData = unknown,
|
||||||
|
TError = unknown,
|
||||||
|
ThrowOnError extends boolean = boolean,
|
||||||
|
TResponseStyle extends ResponseStyle = 'fields',
|
||||||
|
> = ThrowOnError extends true
|
||||||
|
? Promise<
|
||||||
|
TResponseStyle extends 'data'
|
||||||
|
? TData extends Record<string, unknown>
|
||||||
|
? TData[keyof TData]
|
||||||
|
: TData
|
||||||
|
: {
|
||||||
|
data: TData extends Record<string, unknown> ? TData[keyof TData] : TData;
|
||||||
|
request: Request;
|
||||||
|
response: Response;
|
||||||
|
}
|
||||||
|
>
|
||||||
|
: Promise<
|
||||||
|
TResponseStyle extends 'data'
|
||||||
|
? (TData extends Record<string, unknown> ? TData[keyof TData] : TData) | undefined
|
||||||
|
: (
|
||||||
|
| {
|
||||||
|
data: TData extends Record<string, unknown> ? TData[keyof TData] : TData;
|
||||||
|
error: undefined;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
data: undefined;
|
||||||
|
error: TError extends Record<string, unknown> ? TError[keyof TError] : TError;
|
||||||
|
}
|
||||||
|
) & {
|
||||||
|
/** request may be undefined, because error may be from building the request object itself */
|
||||||
|
request?: Request;
|
||||||
|
/** response may be undefined, because error may be from building the request object itself or from a network error */
|
||||||
|
response?: Response;
|
||||||
|
}
|
||||||
|
>;
|
||||||
|
|
||||||
|
export interface ClientOptions {
|
||||||
|
baseUrl?: string;
|
||||||
|
responseStyle?: ResponseStyle;
|
||||||
|
throwOnError?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
type MethodFn = <
|
||||||
|
TData = unknown,
|
||||||
|
TError = unknown,
|
||||||
|
ThrowOnError extends boolean = false,
|
||||||
|
TResponseStyle extends ResponseStyle = 'fields',
|
||||||
|
>(
|
||||||
|
options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, 'method'>,
|
||||||
|
) => RequestResult<TData, TError, ThrowOnError, TResponseStyle>;
|
||||||
|
|
||||||
|
type SseFn = <
|
||||||
|
TData = unknown,
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
|
_TError = unknown,
|
||||||
|
ThrowOnError extends boolean = false,
|
||||||
|
TResponseStyle extends ResponseStyle = 'fields',
|
||||||
|
>(
|
||||||
|
options: Omit<RequestOptions<never, TResponseStyle, ThrowOnError>, 'method'>,
|
||||||
|
) => Promise<ServerSentEventsResult<TData>>;
|
||||||
|
|
||||||
|
type RequestFn = <
|
||||||
|
TData = unknown,
|
||||||
|
TError = unknown,
|
||||||
|
ThrowOnError extends boolean = false,
|
||||||
|
TResponseStyle extends ResponseStyle = 'fields',
|
||||||
|
>(
|
||||||
|
options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, 'method'> &
|
||||||
|
Pick<Required<RequestOptions<TData, TResponseStyle, ThrowOnError>>, 'method'>,
|
||||||
|
) => RequestResult<TData, TError, ThrowOnError, TResponseStyle>;
|
||||||
|
|
||||||
|
type BuildUrlFn = <
|
||||||
|
TData extends {
|
||||||
|
body?: unknown;
|
||||||
|
path?: Record<string, unknown>;
|
||||||
|
query?: Record<string, unknown>;
|
||||||
|
url: string;
|
||||||
|
},
|
||||||
|
>(
|
||||||
|
options: TData & Options<TData>,
|
||||||
|
) => string;
|
||||||
|
|
||||||
|
export type Client = CoreClient<RequestFn, Config, MethodFn, BuildUrlFn, SseFn> & {
|
||||||
|
interceptors: Middleware<Request, Response, unknown, ResolvedRequestOptions>;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The `createClientConfig()` function will be called on client initialization
|
||||||
|
* and the returned object will become the client's initial configuration.
|
||||||
|
*
|
||||||
|
* You may want to initialize your client this way instead of calling
|
||||||
|
* `setConfig()`. This is useful for example if you're using Next.js
|
||||||
|
* to ensure your client always has the correct values.
|
||||||
|
*/
|
||||||
|
export type CreateClientConfig<T extends ClientOptions = ClientOptions> = (
|
||||||
|
override?: Config<ClientOptions & T>,
|
||||||
|
) => Config<Required<ClientOptions> & T>;
|
||||||
|
|
||||||
|
export interface TDataShape {
|
||||||
|
body?: unknown;
|
||||||
|
headers?: unknown;
|
||||||
|
path?: unknown;
|
||||||
|
query?: unknown;
|
||||||
|
url: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
type OmitKeys<T, K> = Pick<T, Exclude<keyof T, K>>;
|
||||||
|
|
||||||
|
export type Options<
|
||||||
|
TData extends TDataShape = TDataShape,
|
||||||
|
ThrowOnError extends boolean = boolean,
|
||||||
|
TResponse = unknown,
|
||||||
|
TResponseStyle extends ResponseStyle = 'fields',
|
||||||
|
> = OmitKeys<
|
||||||
|
RequestOptions<TResponse, TResponseStyle, ThrowOnError>,
|
||||||
|
'body' | 'path' | 'query' | 'url'
|
||||||
|
> &
|
||||||
|
([TData] extends [never] ? unknown : Omit<TData, 'url'>);
|
||||||
@@ -0,0 +1,316 @@
|
|||||||
|
// This file is auto-generated by @hey-api/openapi-ts
|
||||||
|
|
||||||
|
import { getAuthToken } from '../core/auth.gen';
|
||||||
|
import type { QuerySerializerOptions } from '../core/bodySerializer.gen';
|
||||||
|
import { jsonBodySerializer } from '../core/bodySerializer.gen';
|
||||||
|
import {
|
||||||
|
serializeArrayParam,
|
||||||
|
serializeObjectParam,
|
||||||
|
serializePrimitiveParam,
|
||||||
|
} from '../core/pathSerializer.gen';
|
||||||
|
import { getUrl } from '../core/utils.gen';
|
||||||
|
import type { Client, ClientOptions, Config, RequestOptions } from './types.gen';
|
||||||
|
|
||||||
|
export const createQuerySerializer = <T = unknown>({
|
||||||
|
parameters = {},
|
||||||
|
...args
|
||||||
|
}: QuerySerializerOptions = {}): ((queryParams: T) => string) => {
|
||||||
|
const querySerializer = (queryParams: T): string => {
|
||||||
|
const search: string[] = [];
|
||||||
|
if (queryParams && typeof queryParams === 'object') {
|
||||||
|
for (const name in queryParams) {
|
||||||
|
const value = queryParams[name];
|
||||||
|
|
||||||
|
if (value === undefined || value === null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const options = parameters[name] || args;
|
||||||
|
|
||||||
|
if (Array.isArray(value)) {
|
||||||
|
const serializedArray = serializeArrayParam({
|
||||||
|
allowReserved: options.allowReserved,
|
||||||
|
explode: true,
|
||||||
|
name,
|
||||||
|
style: 'form',
|
||||||
|
value,
|
||||||
|
...options.array,
|
||||||
|
});
|
||||||
|
if (serializedArray) search.push(serializedArray);
|
||||||
|
} else if (typeof value === 'object') {
|
||||||
|
const serializedObject = serializeObjectParam({
|
||||||
|
allowReserved: options.allowReserved,
|
||||||
|
explode: true,
|
||||||
|
name,
|
||||||
|
style: 'deepObject',
|
||||||
|
value: value as Record<string, unknown>,
|
||||||
|
...options.object,
|
||||||
|
});
|
||||||
|
if (serializedObject) search.push(serializedObject);
|
||||||
|
} else {
|
||||||
|
const serializedPrimitive = serializePrimitiveParam({
|
||||||
|
allowReserved: options.allowReserved,
|
||||||
|
name,
|
||||||
|
value: value as string,
|
||||||
|
});
|
||||||
|
if (serializedPrimitive) search.push(serializedPrimitive);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return search.join('&');
|
||||||
|
};
|
||||||
|
return querySerializer;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Infers parseAs value from provided Content-Type header.
|
||||||
|
*/
|
||||||
|
export const getParseAs = (contentType: string | null): Exclude<Config['parseAs'], 'auto'> => {
|
||||||
|
if (!contentType) {
|
||||||
|
// If no Content-Type header is provided, the best we can do is return the raw response body,
|
||||||
|
// which is effectively the same as the 'stream' option.
|
||||||
|
return 'stream';
|
||||||
|
}
|
||||||
|
|
||||||
|
const cleanContent = contentType.split(';')[0]?.trim();
|
||||||
|
|
||||||
|
if (!cleanContent) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cleanContent.startsWith('application/json') || cleanContent.endsWith('+json')) {
|
||||||
|
return 'json';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cleanContent === 'multipart/form-data') {
|
||||||
|
return 'formData';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
['application/', 'audio/', 'image/', 'video/'].some((type) => cleanContent.startsWith(type))
|
||||||
|
) {
|
||||||
|
return 'blob';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cleanContent.startsWith('text/')) {
|
||||||
|
return 'text';
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
|
const checkForExistence = (
|
||||||
|
options: Pick<RequestOptions, 'auth' | 'query'> & {
|
||||||
|
headers: Headers;
|
||||||
|
},
|
||||||
|
name?: string,
|
||||||
|
): boolean => {
|
||||||
|
if (!name) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
options.headers.has(name) ||
|
||||||
|
options.query?.[name] ||
|
||||||
|
options.headers.get('Cookie')?.includes(`${name}=`)
|
||||||
|
) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
export async function setAuthParams(
|
||||||
|
options: Pick<RequestOptions, 'auth' | 'query' | 'security'> & {
|
||||||
|
headers: Headers;
|
||||||
|
},
|
||||||
|
): Promise<void> {
|
||||||
|
for (const auth of options.security ?? []) {
|
||||||
|
if (checkForExistence(options, auth.name)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const token = await getAuthToken(auth, options.auth);
|
||||||
|
|
||||||
|
if (!token) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const name = auth.name ?? 'Authorization';
|
||||||
|
|
||||||
|
switch (auth.in) {
|
||||||
|
case 'query':
|
||||||
|
if (!options.query) {
|
||||||
|
options.query = {};
|
||||||
|
}
|
||||||
|
options.query[name] = token;
|
||||||
|
break;
|
||||||
|
case 'cookie':
|
||||||
|
options.headers.append('Cookie', `${name}=${token}`);
|
||||||
|
break;
|
||||||
|
case 'header':
|
||||||
|
default:
|
||||||
|
options.headers.set(name, token);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const buildUrl: Client['buildUrl'] = (options) =>
|
||||||
|
getUrl({
|
||||||
|
baseUrl: options.baseUrl as string,
|
||||||
|
path: options.path,
|
||||||
|
query: options.query,
|
||||||
|
querySerializer:
|
||||||
|
typeof options.querySerializer === 'function'
|
||||||
|
? options.querySerializer
|
||||||
|
: createQuerySerializer(options.querySerializer),
|
||||||
|
url: options.url,
|
||||||
|
});
|
||||||
|
|
||||||
|
export const mergeConfigs = (a: Config, b: Config): Config => {
|
||||||
|
const config = { ...a, ...b };
|
||||||
|
if (config.baseUrl?.endsWith('/')) {
|
||||||
|
config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1);
|
||||||
|
}
|
||||||
|
config.headers = mergeHeaders(a.headers, b.headers);
|
||||||
|
return config;
|
||||||
|
};
|
||||||
|
|
||||||
|
const headersEntries = (headers: Headers): Array<[string, string]> => {
|
||||||
|
const entries: Array<[string, string]> = [];
|
||||||
|
headers.forEach((value, key) => {
|
||||||
|
entries.push([key, value]);
|
||||||
|
});
|
||||||
|
return entries;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const mergeHeaders = (
|
||||||
|
...headers: Array<Required<Config>['headers'] | undefined>
|
||||||
|
): Headers => {
|
||||||
|
const mergedHeaders = new Headers();
|
||||||
|
for (const header of headers) {
|
||||||
|
if (!header) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const iterator = header instanceof Headers ? headersEntries(header) : Object.entries(header);
|
||||||
|
|
||||||
|
for (const [key, value] of iterator) {
|
||||||
|
if (value === null) {
|
||||||
|
mergedHeaders.delete(key);
|
||||||
|
} else if (Array.isArray(value)) {
|
||||||
|
for (const v of value) {
|
||||||
|
mergedHeaders.append(key, v as string);
|
||||||
|
}
|
||||||
|
} else if (value !== undefined) {
|
||||||
|
// assume object headers are meant to be JSON stringified, i.e., their
|
||||||
|
// content value in OpenAPI specification is 'application/json'
|
||||||
|
mergedHeaders.set(
|
||||||
|
key,
|
||||||
|
typeof value === 'object' ? JSON.stringify(value) : (value as string),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return mergedHeaders;
|
||||||
|
};
|
||||||
|
|
||||||
|
type ErrInterceptor<Err, Res, Req, Options> = (
|
||||||
|
error: Err,
|
||||||
|
/** response may be undefined due to a network error where no response object is produced */
|
||||||
|
response: Res | undefined,
|
||||||
|
/** request may be undefined, because error may be from building the request object itself */
|
||||||
|
request: Req | undefined,
|
||||||
|
options: Options,
|
||||||
|
) => Err | Promise<Err>;
|
||||||
|
|
||||||
|
type ReqInterceptor<Req, Options> = (request: Req, options: Options) => Req | Promise<Req>;
|
||||||
|
|
||||||
|
type ResInterceptor<Res, Req, Options> = (
|
||||||
|
response: Res,
|
||||||
|
request: Req,
|
||||||
|
options: Options,
|
||||||
|
) => Res | Promise<Res>;
|
||||||
|
|
||||||
|
class Interceptors<Interceptor> {
|
||||||
|
fns: Array<Interceptor | null> = [];
|
||||||
|
|
||||||
|
clear(): void {
|
||||||
|
this.fns = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
eject(id: number | Interceptor): void {
|
||||||
|
const index = this.getInterceptorIndex(id);
|
||||||
|
if (this.fns[index]) {
|
||||||
|
this.fns[index] = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
exists(id: number | Interceptor): boolean {
|
||||||
|
const index = this.getInterceptorIndex(id);
|
||||||
|
return Boolean(this.fns[index]);
|
||||||
|
}
|
||||||
|
|
||||||
|
getInterceptorIndex(id: number | Interceptor): number {
|
||||||
|
if (typeof id === 'number') {
|
||||||
|
return this.fns[id] ? id : -1;
|
||||||
|
}
|
||||||
|
return this.fns.indexOf(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
update(id: number | Interceptor, fn: Interceptor): number | Interceptor | false {
|
||||||
|
const index = this.getInterceptorIndex(id);
|
||||||
|
if (this.fns[index]) {
|
||||||
|
this.fns[index] = fn;
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
use(fn: Interceptor): number {
|
||||||
|
this.fns.push(fn);
|
||||||
|
return this.fns.length - 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Middleware<Req, Res, Err, Options> {
|
||||||
|
error: Interceptors<ErrInterceptor<Err, Res, Req, Options>>;
|
||||||
|
request: Interceptors<ReqInterceptor<Req, Options>>;
|
||||||
|
response: Interceptors<ResInterceptor<Res, Req, Options>>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const createInterceptors = <Req, Res, Err, Options>(): Middleware<
|
||||||
|
Req,
|
||||||
|
Res,
|
||||||
|
Err,
|
||||||
|
Options
|
||||||
|
> => ({
|
||||||
|
error: new Interceptors<ErrInterceptor<Err, Res, Req, Options>>(),
|
||||||
|
request: new Interceptors<ReqInterceptor<Req, Options>>(),
|
||||||
|
response: new Interceptors<ResInterceptor<Res, Req, Options>>(),
|
||||||
|
});
|
||||||
|
|
||||||
|
const defaultQuerySerializer = createQuerySerializer({
|
||||||
|
allowReserved: false,
|
||||||
|
array: {
|
||||||
|
explode: true,
|
||||||
|
style: 'form',
|
||||||
|
},
|
||||||
|
object: {
|
||||||
|
explode: true,
|
||||||
|
style: 'deepObject',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const defaultHeaders = {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
};
|
||||||
|
|
||||||
|
export const createConfig = <T extends ClientOptions = ClientOptions>(
|
||||||
|
override: Config<Omit<ClientOptions, keyof T> & T> = {},
|
||||||
|
): Config<Omit<ClientOptions, keyof T> & T> => ({
|
||||||
|
...jsonBodySerializer,
|
||||||
|
headers: defaultHeaders,
|
||||||
|
parseAs: 'auto',
|
||||||
|
querySerializer: defaultQuerySerializer,
|
||||||
|
...override,
|
||||||
|
});
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
// This file is auto-generated by @hey-api/openapi-ts
|
||||||
|
|
||||||
|
export type AuthToken = string | undefined;
|
||||||
|
|
||||||
|
export interface Auth {
|
||||||
|
/**
|
||||||
|
* Which part of the request do we use to send the auth?
|
||||||
|
*
|
||||||
|
* @default 'header'
|
||||||
|
*/
|
||||||
|
in?: 'header' | 'query' | 'cookie';
|
||||||
|
/**
|
||||||
|
* A unique identifier for the security scheme.
|
||||||
|
*
|
||||||
|
* Defined only when there are multiple security schemes whose `Auth`
|
||||||
|
* shape would otherwise be identical.
|
||||||
|
*/
|
||||||
|
key?: string;
|
||||||
|
/**
|
||||||
|
* Header or query parameter name.
|
||||||
|
*
|
||||||
|
* @default 'Authorization'
|
||||||
|
*/
|
||||||
|
name?: string;
|
||||||
|
scheme?: 'basic' | 'bearer';
|
||||||
|
type: 'apiKey' | 'http';
|
||||||
|
}
|
||||||
|
|
||||||
|
export const getAuthToken = async (
|
||||||
|
auth: Auth,
|
||||||
|
callback: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken,
|
||||||
|
): Promise<string | undefined> => {
|
||||||
|
const token = typeof callback === 'function' ? await callback(auth) : callback;
|
||||||
|
|
||||||
|
if (!token) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (auth.scheme === 'bearer') {
|
||||||
|
return `Bearer ${token}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (auth.scheme === 'basic') {
|
||||||
|
return `Basic ${btoa(token)}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
return token;
|
||||||
|
};
|
||||||
@@ -0,0 +1,82 @@
|
|||||||
|
// This file is auto-generated by @hey-api/openapi-ts
|
||||||
|
|
||||||
|
import type { ArrayStyle, ObjectStyle, SerializerOptions } from './pathSerializer.gen';
|
||||||
|
|
||||||
|
export type QuerySerializer = (query: Record<string, unknown>) => string;
|
||||||
|
|
||||||
|
export type BodySerializer = (body: unknown) => unknown;
|
||||||
|
|
||||||
|
type QuerySerializerOptionsObject = {
|
||||||
|
allowReserved?: boolean;
|
||||||
|
array?: Partial<SerializerOptions<ArrayStyle>>;
|
||||||
|
object?: Partial<SerializerOptions<ObjectStyle>>;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type QuerySerializerOptions = QuerySerializerOptionsObject & {
|
||||||
|
/**
|
||||||
|
* Per-parameter serialization overrides. When provided, these settings
|
||||||
|
* override the global array/object settings for specific parameter names.
|
||||||
|
*/
|
||||||
|
parameters?: Record<string, QuerySerializerOptionsObject>;
|
||||||
|
};
|
||||||
|
|
||||||
|
const serializeFormDataPair = (data: FormData, key: string, value: unknown): void => {
|
||||||
|
if (typeof value === 'string' || value instanceof Blob) {
|
||||||
|
data.append(key, value);
|
||||||
|
} else if (value instanceof Date) {
|
||||||
|
data.append(key, value.toISOString());
|
||||||
|
} else {
|
||||||
|
data.append(key, JSON.stringify(value));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const serializeUrlSearchParamsPair = (data: URLSearchParams, key: string, value: unknown): void => {
|
||||||
|
if (typeof value === 'string') {
|
||||||
|
data.append(key, value);
|
||||||
|
} else {
|
||||||
|
data.append(key, JSON.stringify(value));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const formDataBodySerializer = {
|
||||||
|
bodySerializer: (body: unknown): FormData => {
|
||||||
|
const data = new FormData();
|
||||||
|
|
||||||
|
Object.entries(body as Record<string, unknown>).forEach(([key, value]) => {
|
||||||
|
if (value === undefined || value === null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (Array.isArray(value)) {
|
||||||
|
value.forEach((v) => serializeFormDataPair(data, key, v));
|
||||||
|
} else {
|
||||||
|
serializeFormDataPair(data, key, value);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return data;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export const jsonBodySerializer = {
|
||||||
|
bodySerializer: (body: unknown): string =>
|
||||||
|
JSON.stringify(body, (_key, value) => (typeof value === 'bigint' ? value.toString() : value)),
|
||||||
|
};
|
||||||
|
|
||||||
|
export const urlSearchParamsBodySerializer = {
|
||||||
|
bodySerializer: (body: unknown): string => {
|
||||||
|
const data = new URLSearchParams();
|
||||||
|
|
||||||
|
Object.entries(body as Record<string, unknown>).forEach(([key, value]) => {
|
||||||
|
if (value === undefined || value === null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (Array.isArray(value)) {
|
||||||
|
value.forEach((v) => serializeUrlSearchParamsPair(data, key, v));
|
||||||
|
} else {
|
||||||
|
serializeUrlSearchParamsPair(data, key, value);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return data.toString();
|
||||||
|
},
|
||||||
|
};
|
||||||
@@ -0,0 +1,178 @@
|
|||||||
|
// This file is auto-generated by @hey-api/openapi-ts
|
||||||
|
|
||||||
|
type Slot = 'body' | 'headers' | 'path' | 'query';
|
||||||
|
|
||||||
|
export type Field =
|
||||||
|
| {
|
||||||
|
in: Exclude<Slot, 'body'>;
|
||||||
|
/**
|
||||||
|
* Field name. This is the name we want the user to see and use.
|
||||||
|
*/
|
||||||
|
key: string;
|
||||||
|
/**
|
||||||
|
* Field mapped name. This is the name we want to use in the request.
|
||||||
|
* If omitted, we use the same value as `key`.
|
||||||
|
*/
|
||||||
|
map?: string;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
in: Extract<Slot, 'body'>;
|
||||||
|
/**
|
||||||
|
* Key isn't required for bodies.
|
||||||
|
*/
|
||||||
|
key?: string;
|
||||||
|
map?: string;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
/**
|
||||||
|
* Field name. This is the name we want the user to see and use.
|
||||||
|
*/
|
||||||
|
key: string;
|
||||||
|
/**
|
||||||
|
* Field mapped name. This is the name we want to use in the request.
|
||||||
|
* If `in` is omitted, `map` aliases `key` to the transport layer.
|
||||||
|
*/
|
||||||
|
map: Slot;
|
||||||
|
};
|
||||||
|
|
||||||
|
export interface Fields {
|
||||||
|
allowExtra?: Partial<Record<Slot, boolean>>;
|
||||||
|
args?: ReadonlyArray<Field>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type FieldsConfig = ReadonlyArray<Field | Fields>;
|
||||||
|
|
||||||
|
const extraPrefixesMap: Record<string, Slot> = {
|
||||||
|
$body_: 'body',
|
||||||
|
$headers_: 'headers',
|
||||||
|
$path_: 'path',
|
||||||
|
$query_: 'query',
|
||||||
|
};
|
||||||
|
const extraPrefixes = Object.entries(extraPrefixesMap);
|
||||||
|
|
||||||
|
type KeyMap = Map<
|
||||||
|
string,
|
||||||
|
| {
|
||||||
|
in: Slot;
|
||||||
|
map?: string;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
in?: never;
|
||||||
|
map: Slot;
|
||||||
|
}
|
||||||
|
>;
|
||||||
|
|
||||||
|
function buildKeyMap(fields: FieldsConfig, map?: KeyMap): KeyMap {
|
||||||
|
if (!map) {
|
||||||
|
map = new Map();
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const config of fields) {
|
||||||
|
if ('in' in config) {
|
||||||
|
if (config.key) {
|
||||||
|
map.set(config.key, {
|
||||||
|
in: config.in,
|
||||||
|
map: config.map,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else if ('key' in config) {
|
||||||
|
map.set(config.key, {
|
||||||
|
map: config.map,
|
||||||
|
});
|
||||||
|
} else if (config.args) {
|
||||||
|
buildKeyMap(config.args, map);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Params {
|
||||||
|
body?: unknown;
|
||||||
|
headers: Record<string, unknown>;
|
||||||
|
path: Record<string, unknown>;
|
||||||
|
query: Record<string, unknown>;
|
||||||
|
}
|
||||||
|
|
||||||
|
function stripEmptySlots(params: Params): void {
|
||||||
|
for (const [slot, value] of Object.entries(params)) {
|
||||||
|
if (slot === 'body') continue;
|
||||||
|
if (value && typeof value === 'object' && !Array.isArray(value) && !Object.keys(value).length) {
|
||||||
|
delete params[slot as Slot];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function buildClientParams(args: ReadonlyArray<unknown>, fields: FieldsConfig): Params {
|
||||||
|
const params: Params = {
|
||||||
|
headers: Object.create(null),
|
||||||
|
path: Object.create(null),
|
||||||
|
query: Object.create(null),
|
||||||
|
};
|
||||||
|
|
||||||
|
const map = buildKeyMap(fields);
|
||||||
|
|
||||||
|
function writeSlot(slot: Slot, key: string, value: unknown): void {
|
||||||
|
let record = params[slot] as Record<string, unknown> | undefined;
|
||||||
|
if (record === undefined) {
|
||||||
|
record = Object.create(null) as Record<string, unknown>;
|
||||||
|
params[slot] = record;
|
||||||
|
}
|
||||||
|
record[key] = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
let config: FieldsConfig[number] | undefined;
|
||||||
|
|
||||||
|
for (const [index, arg] of args.entries()) {
|
||||||
|
if (fields[index]) {
|
||||||
|
config = fields[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!config) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ('in' in config) {
|
||||||
|
if (config.key) {
|
||||||
|
const field = map.get(config.key)!;
|
||||||
|
const name = field.map || config.key;
|
||||||
|
if (field.in) {
|
||||||
|
writeSlot(field.in, name, arg);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
params.body = arg;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (const [key, value] of Object.entries(arg ?? {})) {
|
||||||
|
const field = map.get(key);
|
||||||
|
|
||||||
|
if (field) {
|
||||||
|
if (field.in) {
|
||||||
|
const name = field.map || key;
|
||||||
|
writeSlot(field.in, name, value);
|
||||||
|
} else {
|
||||||
|
params[field.map] = value;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
const extra = extraPrefixes.find(([prefix]) => key.startsWith(prefix));
|
||||||
|
|
||||||
|
if (extra) {
|
||||||
|
const [prefix, slot] = extra;
|
||||||
|
writeSlot(slot, key.slice(prefix.length), value);
|
||||||
|
} else if ('allowExtra' in config && config.allowExtra) {
|
||||||
|
for (const [slot, allowed] of Object.entries(config.allowExtra)) {
|
||||||
|
if (allowed) {
|
||||||
|
writeSlot(slot as Slot, key, value);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stripEmptySlots(params);
|
||||||
|
|
||||||
|
return params;
|
||||||
|
}
|
||||||
@@ -0,0 +1,171 @@
|
|||||||
|
// This file is auto-generated by @hey-api/openapi-ts
|
||||||
|
|
||||||
|
interface SerializeOptions<T> extends SerializePrimitiveOptions, SerializerOptions<T> {}
|
||||||
|
|
||||||
|
interface SerializePrimitiveOptions {
|
||||||
|
allowReserved?: boolean;
|
||||||
|
name: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface SerializerOptions<T> {
|
||||||
|
/**
|
||||||
|
* @default true
|
||||||
|
*/
|
||||||
|
explode: boolean;
|
||||||
|
style: T;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited';
|
||||||
|
export type ArraySeparatorStyle = ArrayStyle | MatrixStyle;
|
||||||
|
type MatrixStyle = 'label' | 'matrix' | 'simple';
|
||||||
|
export type ObjectStyle = 'form' | 'deepObject';
|
||||||
|
type ObjectSeparatorStyle = ObjectStyle | MatrixStyle;
|
||||||
|
|
||||||
|
interface SerializePrimitiveParam extends SerializePrimitiveOptions {
|
||||||
|
value: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const separatorArrayExplode = (style: ArraySeparatorStyle): '.' | ';' | ',' | '&' => {
|
||||||
|
switch (style) {
|
||||||
|
case 'label':
|
||||||
|
return '.';
|
||||||
|
case 'matrix':
|
||||||
|
return ';';
|
||||||
|
case 'simple':
|
||||||
|
return ',';
|
||||||
|
default:
|
||||||
|
return '&';
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const separatorArrayNoExplode = (style: ArraySeparatorStyle): ',' | '|' | '%20' => {
|
||||||
|
switch (style) {
|
||||||
|
case 'form':
|
||||||
|
return ',';
|
||||||
|
case 'pipeDelimited':
|
||||||
|
return '|';
|
||||||
|
case 'spaceDelimited':
|
||||||
|
return '%20';
|
||||||
|
default:
|
||||||
|
return ',';
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const separatorObjectExplode = (style: ObjectSeparatorStyle): '.' | ';' | ',' | '&' => {
|
||||||
|
switch (style) {
|
||||||
|
case 'label':
|
||||||
|
return '.';
|
||||||
|
case 'matrix':
|
||||||
|
return ';';
|
||||||
|
case 'simple':
|
||||||
|
return ',';
|
||||||
|
default:
|
||||||
|
return '&';
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const serializeArrayParam = ({
|
||||||
|
allowReserved,
|
||||||
|
explode,
|
||||||
|
name,
|
||||||
|
style,
|
||||||
|
value,
|
||||||
|
}: SerializeOptions<ArraySeparatorStyle> & {
|
||||||
|
value: unknown[];
|
||||||
|
}): string => {
|
||||||
|
if (!explode) {
|
||||||
|
const joinedValues = (
|
||||||
|
allowReserved ? value : value.map((v) => encodeURIComponent(v as string))
|
||||||
|
).join(separatorArrayNoExplode(style));
|
||||||
|
switch (style) {
|
||||||
|
case 'label':
|
||||||
|
return `.${joinedValues}`;
|
||||||
|
case 'matrix':
|
||||||
|
return `;${name}=${joinedValues}`;
|
||||||
|
case 'simple':
|
||||||
|
return joinedValues;
|
||||||
|
default:
|
||||||
|
return `${name}=${joinedValues}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const separator = separatorArrayExplode(style);
|
||||||
|
const joinedValues = value
|
||||||
|
.map((v) => {
|
||||||
|
if (style === 'label' || style === 'simple') {
|
||||||
|
return allowReserved ? v : encodeURIComponent(v as string);
|
||||||
|
}
|
||||||
|
|
||||||
|
return serializePrimitiveParam({
|
||||||
|
allowReserved,
|
||||||
|
name,
|
||||||
|
value: v as string,
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.join(separator);
|
||||||
|
return style === 'label' || style === 'matrix' ? separator + joinedValues : joinedValues;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const serializePrimitiveParam = ({
|
||||||
|
allowReserved,
|
||||||
|
name,
|
||||||
|
value,
|
||||||
|
}: SerializePrimitiveParam): string => {
|
||||||
|
if (value === undefined || value === null) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof value === 'object') {
|
||||||
|
throw new Error(
|
||||||
|
'Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return `${name}=${allowReserved ? value : encodeURIComponent(value)}`;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const serializeObjectParam = ({
|
||||||
|
allowReserved,
|
||||||
|
explode,
|
||||||
|
name,
|
||||||
|
style,
|
||||||
|
value,
|
||||||
|
valueOnly,
|
||||||
|
}: SerializeOptions<ObjectSeparatorStyle> & {
|
||||||
|
value: Record<string, unknown> | Date;
|
||||||
|
valueOnly?: boolean;
|
||||||
|
}): string => {
|
||||||
|
if (value instanceof Date) {
|
||||||
|
return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (style !== 'deepObject' && !explode) {
|
||||||
|
let values: string[] = [];
|
||||||
|
Object.entries(value).forEach(([key, v]) => {
|
||||||
|
values = [...values, key, allowReserved ? (v as string) : encodeURIComponent(v as string)];
|
||||||
|
});
|
||||||
|
const joinedValues = values.join(',');
|
||||||
|
switch (style) {
|
||||||
|
case 'form':
|
||||||
|
return `${name}=${joinedValues}`;
|
||||||
|
case 'label':
|
||||||
|
return `.${joinedValues}`;
|
||||||
|
case 'matrix':
|
||||||
|
return `;${name}=${joinedValues}`;
|
||||||
|
default:
|
||||||
|
return joinedValues;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const separator = separatorObjectExplode(style);
|
||||||
|
const joinedValues = Object.entries(value)
|
||||||
|
.map(([key, v]) =>
|
||||||
|
serializePrimitiveParam({
|
||||||
|
allowReserved,
|
||||||
|
name: style === 'deepObject' ? `${name}[${key}]` : key,
|
||||||
|
value: v as string,
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
.join(separator);
|
||||||
|
return style === 'label' || style === 'matrix' ? separator + joinedValues : joinedValues;
|
||||||
|
};
|
||||||
@@ -0,0 +1,117 @@
|
|||||||
|
// This file is auto-generated by @hey-api/openapi-ts
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JSON-friendly union that mirrors what Pinia Colada can hash.
|
||||||
|
*/
|
||||||
|
export type JsonValue =
|
||||||
|
| null
|
||||||
|
| string
|
||||||
|
| number
|
||||||
|
| boolean
|
||||||
|
| JsonValue[]
|
||||||
|
| { [key: string]: JsonValue };
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replacer that converts non-JSON values (bigint, Date, etc.) to safe substitutes.
|
||||||
|
*/
|
||||||
|
export const queryKeyJsonReplacer = (_key: string, value: unknown): unknown | undefined => {
|
||||||
|
if (value === undefined || typeof value === 'function' || typeof value === 'symbol') {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
if (typeof value === 'bigint') {
|
||||||
|
return value.toString();
|
||||||
|
}
|
||||||
|
if (value instanceof Date) {
|
||||||
|
return value.toISOString();
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Safely stringifies a value and parses it back into a JsonValue.
|
||||||
|
*/
|
||||||
|
export const stringifyToJsonValue = (input: unknown): JsonValue | undefined => {
|
||||||
|
try {
|
||||||
|
const json = JSON.stringify(input, queryKeyJsonReplacer);
|
||||||
|
if (json === undefined) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
return JSON.parse(json) as JsonValue;
|
||||||
|
} catch {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Detects plain objects (including objects with a null prototype).
|
||||||
|
*/
|
||||||
|
const isPlainObject = (value: unknown): value is Record<string, unknown> => {
|
||||||
|
if (value === null || typeof value !== 'object') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
const prototype = Object.getPrototypeOf(value as object);
|
||||||
|
return prototype === Object.prototype || prototype === null;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Turns URLSearchParams into a sorted JSON object for deterministic keys.
|
||||||
|
*/
|
||||||
|
const serializeSearchParams = (params: URLSearchParams): JsonValue => {
|
||||||
|
const entries = Array.from(params.entries()).sort(([a], [b]) => a.localeCompare(b));
|
||||||
|
const result: Record<string, JsonValue> = {};
|
||||||
|
|
||||||
|
for (const [key, value] of entries) {
|
||||||
|
const existing = result[key];
|
||||||
|
if (existing === undefined) {
|
||||||
|
result[key] = value;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Array.isArray(existing)) {
|
||||||
|
(existing as string[]).push(value);
|
||||||
|
} else {
|
||||||
|
result[key] = [existing, value];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Normalizes any accepted value into a JSON-friendly shape for query keys.
|
||||||
|
*/
|
||||||
|
export const serializeQueryKeyValue = (value: unknown): JsonValue | undefined => {
|
||||||
|
if (value === null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (value === undefined || typeof value === 'function' || typeof value === 'symbol') {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof value === 'bigint') {
|
||||||
|
return value.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (value instanceof Date) {
|
||||||
|
return value.toISOString();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Array.isArray(value)) {
|
||||||
|
return stringifyToJsonValue(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof URLSearchParams !== 'undefined' && value instanceof URLSearchParams) {
|
||||||
|
return serializeSearchParams(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isPlainObject(value)) {
|
||||||
|
return stringifyToJsonValue(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return undefined;
|
||||||
|
};
|
||||||
@@ -0,0 +1,242 @@
|
|||||||
|
// This file is auto-generated by @hey-api/openapi-ts
|
||||||
|
|
||||||
|
import type { Config } from './types.gen';
|
||||||
|
|
||||||
|
export type ServerSentEventsOptions<TData = unknown> = Omit<RequestInit, 'method'> &
|
||||||
|
Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & {
|
||||||
|
/**
|
||||||
|
* Fetch API implementation. You can use this option to provide a custom
|
||||||
|
* fetch instance.
|
||||||
|
*
|
||||||
|
* @default globalThis.fetch
|
||||||
|
*/
|
||||||
|
fetch?: typeof fetch;
|
||||||
|
/**
|
||||||
|
* Implementing clients can call request interceptors inside this hook.
|
||||||
|
*/
|
||||||
|
onRequest?: (url: string, init: RequestInit) => Promise<Request>;
|
||||||
|
/**
|
||||||
|
* Callback invoked when a network or parsing error occurs during streaming.
|
||||||
|
*
|
||||||
|
* This option applies only if the endpoint returns a stream of events.
|
||||||
|
*
|
||||||
|
* @param error The error that occurred.
|
||||||
|
*/
|
||||||
|
onSseError?: (error: unknown) => void;
|
||||||
|
/**
|
||||||
|
* Callback invoked when an event is streamed from the server.
|
||||||
|
*
|
||||||
|
* This option applies only if the endpoint returns a stream of events.
|
||||||
|
*
|
||||||
|
* @param event Event streamed from the server.
|
||||||
|
* @returns Nothing (void).
|
||||||
|
*/
|
||||||
|
onSseEvent?: (event: StreamEvent<TData>) => void;
|
||||||
|
serializedBody?: RequestInit['body'];
|
||||||
|
/**
|
||||||
|
* Default retry delay in milliseconds.
|
||||||
|
*
|
||||||
|
* This option applies only if the endpoint returns a stream of events.
|
||||||
|
*
|
||||||
|
* @default 3000
|
||||||
|
*/
|
||||||
|
sseDefaultRetryDelay?: number;
|
||||||
|
/**
|
||||||
|
* Maximum number of retry attempts before giving up.
|
||||||
|
*/
|
||||||
|
sseMaxRetryAttempts?: number;
|
||||||
|
/**
|
||||||
|
* Maximum retry delay in milliseconds.
|
||||||
|
*
|
||||||
|
* Applies only when exponential backoff is used.
|
||||||
|
*
|
||||||
|
* This option applies only if the endpoint returns a stream of events.
|
||||||
|
*
|
||||||
|
* @default 30000
|
||||||
|
*/
|
||||||
|
sseMaxRetryDelay?: number;
|
||||||
|
/**
|
||||||
|
* Optional sleep function for retry backoff.
|
||||||
|
*
|
||||||
|
* Defaults to using `setTimeout`.
|
||||||
|
*/
|
||||||
|
sseSleepFn?: (ms: number) => Promise<void>;
|
||||||
|
url: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export interface StreamEvent<TData = unknown> {
|
||||||
|
data: TData;
|
||||||
|
event?: string;
|
||||||
|
id?: string;
|
||||||
|
retry?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type ServerSentEventsResult<TData = unknown, TReturn = void, TNext = unknown> = {
|
||||||
|
stream: AsyncGenerator<
|
||||||
|
TData extends Record<string, unknown> ? TData[keyof TData] : TData,
|
||||||
|
TReturn,
|
||||||
|
TNext
|
||||||
|
>;
|
||||||
|
};
|
||||||
|
|
||||||
|
export function createSseClient<TData = unknown>({
|
||||||
|
onRequest,
|
||||||
|
onSseError,
|
||||||
|
onSseEvent,
|
||||||
|
responseTransformer,
|
||||||
|
responseValidator,
|
||||||
|
sseDefaultRetryDelay,
|
||||||
|
sseMaxRetryAttempts,
|
||||||
|
sseMaxRetryDelay,
|
||||||
|
sseSleepFn,
|
||||||
|
url,
|
||||||
|
...options
|
||||||
|
}: ServerSentEventsOptions): ServerSentEventsResult<TData> {
|
||||||
|
let lastEventId: string | undefined;
|
||||||
|
|
||||||
|
const sleep = sseSleepFn ?? ((ms: number) => new Promise((resolve) => setTimeout(resolve, ms)));
|
||||||
|
|
||||||
|
const createStream = async function* () {
|
||||||
|
let retryDelay: number = sseDefaultRetryDelay ?? 3000;
|
||||||
|
let attempt = 0;
|
||||||
|
const signal = options.signal ?? new AbortController().signal;
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
if (signal.aborted) break;
|
||||||
|
|
||||||
|
attempt++;
|
||||||
|
|
||||||
|
const headers =
|
||||||
|
options.headers instanceof Headers
|
||||||
|
? options.headers
|
||||||
|
: new Headers(options.headers as Record<string, string> | undefined);
|
||||||
|
|
||||||
|
if (lastEventId !== undefined) {
|
||||||
|
headers.set('Last-Event-ID', lastEventId);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const requestInit: RequestInit = {
|
||||||
|
redirect: 'follow',
|
||||||
|
...options,
|
||||||
|
body: options.serializedBody,
|
||||||
|
headers,
|
||||||
|
signal,
|
||||||
|
};
|
||||||
|
let request = new Request(url, requestInit);
|
||||||
|
if (onRequest) {
|
||||||
|
request = await onRequest(url, requestInit);
|
||||||
|
}
|
||||||
|
// fetch must be assigned here, otherwise it would throw the error:
|
||||||
|
// TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation
|
||||||
|
const _fetch = options.fetch ?? globalThis.fetch;
|
||||||
|
const response = await _fetch(request);
|
||||||
|
|
||||||
|
if (!response.ok) throw new Error(`SSE failed: ${response.status} ${response.statusText}`);
|
||||||
|
|
||||||
|
if (!response.body) throw new Error('No body in SSE response');
|
||||||
|
|
||||||
|
const reader = response.body.pipeThrough(new TextDecoderStream()).getReader();
|
||||||
|
|
||||||
|
let buffer = '';
|
||||||
|
|
||||||
|
const abortHandler = () => {
|
||||||
|
try {
|
||||||
|
reader.cancel();
|
||||||
|
} catch {
|
||||||
|
// noop
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
signal.addEventListener('abort', abortHandler);
|
||||||
|
|
||||||
|
try {
|
||||||
|
while (true) {
|
||||||
|
const { done, value } = await reader.read();
|
||||||
|
if (done) break;
|
||||||
|
buffer += value;
|
||||||
|
buffer = buffer.replace(/\r\n?/g, '\n'); // normalize line endings
|
||||||
|
|
||||||
|
const chunks = buffer.split('\n\n');
|
||||||
|
buffer = chunks.pop() ?? '';
|
||||||
|
|
||||||
|
for (const chunk of chunks) {
|
||||||
|
const lines = chunk.split('\n');
|
||||||
|
const dataLines: Array<string> = [];
|
||||||
|
let eventName: string | undefined;
|
||||||
|
|
||||||
|
for (const line of lines) {
|
||||||
|
if (line.startsWith('data:')) {
|
||||||
|
dataLines.push(line.replace(/^data:\s*/, ''));
|
||||||
|
} else if (line.startsWith('event:')) {
|
||||||
|
eventName = line.replace(/^event:\s*/, '');
|
||||||
|
} else if (line.startsWith('id:')) {
|
||||||
|
lastEventId = line.replace(/^id:\s*/, '');
|
||||||
|
} else if (line.startsWith('retry:')) {
|
||||||
|
const parsed = Number.parseInt(line.replace(/^retry:\s*/, ''), 10);
|
||||||
|
if (!Number.isNaN(parsed)) {
|
||||||
|
retryDelay = parsed;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let data: unknown;
|
||||||
|
let parsedJson = false;
|
||||||
|
|
||||||
|
if (dataLines.length) {
|
||||||
|
const rawData = dataLines.join('\n');
|
||||||
|
try {
|
||||||
|
data = JSON.parse(rawData);
|
||||||
|
parsedJson = true;
|
||||||
|
} catch {
|
||||||
|
data = rawData;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parsedJson) {
|
||||||
|
if (responseValidator) {
|
||||||
|
await responseValidator(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (responseTransformer) {
|
||||||
|
data = await responseTransformer(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onSseEvent?.({
|
||||||
|
data,
|
||||||
|
event: eventName,
|
||||||
|
id: lastEventId,
|
||||||
|
retry: retryDelay,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (dataLines.length) {
|
||||||
|
yield data as any;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
signal.removeEventListener('abort', abortHandler);
|
||||||
|
reader.releaseLock();
|
||||||
|
}
|
||||||
|
|
||||||
|
break; // exit loop on normal completion
|
||||||
|
} catch (error) {
|
||||||
|
// connection failed or aborted; retry after delay
|
||||||
|
onSseError?.(error);
|
||||||
|
|
||||||
|
if (sseMaxRetryAttempts !== undefined && attempt >= sseMaxRetryAttempts) {
|
||||||
|
break; // stop after firing error
|
||||||
|
}
|
||||||
|
|
||||||
|
// exponential backoff: double retry each attempt, cap at 30s
|
||||||
|
const backoff = Math.min(retryDelay * 2 ** (attempt - 1), sseMaxRetryDelay ?? 30000);
|
||||||
|
await sleep(backoff);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const stream = createStream();
|
||||||
|
|
||||||
|
return { stream };
|
||||||
|
}
|
||||||
@@ -0,0 +1,110 @@
|
|||||||
|
// This file is auto-generated by @hey-api/openapi-ts
|
||||||
|
|
||||||
|
import type { Auth, AuthToken } from './auth.gen';
|
||||||
|
import type { BodySerializer, QuerySerializer, QuerySerializerOptions } from './bodySerializer.gen';
|
||||||
|
|
||||||
|
export type HttpMethod =
|
||||||
|
| 'connect'
|
||||||
|
| 'delete'
|
||||||
|
| 'get'
|
||||||
|
| 'head'
|
||||||
|
| 'options'
|
||||||
|
| 'patch'
|
||||||
|
| 'post'
|
||||||
|
| 'put'
|
||||||
|
| 'trace';
|
||||||
|
|
||||||
|
export type Client<
|
||||||
|
RequestFn = never,
|
||||||
|
Config = unknown,
|
||||||
|
MethodFn = never,
|
||||||
|
BuildUrlFn = never,
|
||||||
|
SseFn = never,
|
||||||
|
> = {
|
||||||
|
/**
|
||||||
|
* Returns the final request URL.
|
||||||
|
*/
|
||||||
|
buildUrl: BuildUrlFn;
|
||||||
|
getConfig: () => Config;
|
||||||
|
request: RequestFn;
|
||||||
|
setConfig: (config: Config) => Config;
|
||||||
|
} & {
|
||||||
|
[K in HttpMethod]: MethodFn;
|
||||||
|
} & ([SseFn] extends [never] ? { sse?: never } : { sse: { [K in HttpMethod]: SseFn } });
|
||||||
|
|
||||||
|
export interface Config {
|
||||||
|
/**
|
||||||
|
* Auth token or a function returning auth token. The resolved value will be
|
||||||
|
* added to the request payload as defined by its `security` array.
|
||||||
|
*/
|
||||||
|
auth?: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken;
|
||||||
|
/**
|
||||||
|
* A function for serializing request body parameter. By default,
|
||||||
|
* {@link JSON.stringify()} will be used.
|
||||||
|
*/
|
||||||
|
bodySerializer?: BodySerializer | null;
|
||||||
|
/**
|
||||||
|
* An object containing any HTTP headers that you want to pre-populate your
|
||||||
|
* `Headers` object with.
|
||||||
|
*
|
||||||
|
* {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more}
|
||||||
|
*/
|
||||||
|
headers?:
|
||||||
|
| RequestInit['headers']
|
||||||
|
| Record<
|
||||||
|
string,
|
||||||
|
string | number | boolean | (string | number | boolean)[] | null | undefined | unknown
|
||||||
|
>;
|
||||||
|
/**
|
||||||
|
* The request method.
|
||||||
|
*
|
||||||
|
* {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more}
|
||||||
|
*/
|
||||||
|
method?: Uppercase<HttpMethod>;
|
||||||
|
/**
|
||||||
|
* A function for serializing request query parameters. By default, arrays
|
||||||
|
* will be exploded in form style, objects will be exploded in deepObject
|
||||||
|
* style, and reserved characters are percent-encoded.
|
||||||
|
*
|
||||||
|
* This method will have no effect if the native `paramsSerializer()` Axios
|
||||||
|
* API function is used.
|
||||||
|
*
|
||||||
|
* {@link https://swagger.io/docs/specification/serialization/#query View examples}
|
||||||
|
*/
|
||||||
|
querySerializer?: QuerySerializer | QuerySerializerOptions;
|
||||||
|
/**
|
||||||
|
* A function validating request data. This is useful if you want to ensure
|
||||||
|
* the request conforms to the desired shape, so it can be safely sent to
|
||||||
|
* the server.
|
||||||
|
*/
|
||||||
|
requestValidator?: (data: unknown) => Promise<unknown>;
|
||||||
|
/**
|
||||||
|
* A function transforming response data before it's returned. This is useful
|
||||||
|
* for post-processing data, e.g., converting ISO strings into Date objects.
|
||||||
|
*/
|
||||||
|
responseTransformer?: (data: unknown) => Promise<unknown>;
|
||||||
|
/**
|
||||||
|
* A function validating response data. This is useful if you want to ensure
|
||||||
|
* the response conforms to the desired shape, so it can be safely passed to
|
||||||
|
* the transformers and returned to the user.
|
||||||
|
*/
|
||||||
|
responseValidator?: (data: unknown) => Promise<unknown>;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Arbitrary metadata passed through the `meta` request option.
|
||||||
|
*/
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
||||||
|
export interface ClientMeta {}
|
||||||
|
|
||||||
|
type IsExactlyNeverOrNeverUndefined<T> = [T] extends [never]
|
||||||
|
? true
|
||||||
|
: [T] extends [never | undefined]
|
||||||
|
? [undefined] extends [T]
|
||||||
|
? false
|
||||||
|
: true
|
||||||
|
: false;
|
||||||
|
|
||||||
|
export type OmitNever<T extends Record<string, unknown>> = {
|
||||||
|
[K in keyof T as IsExactlyNeverOrNeverUndefined<T[K]> extends true ? never : K]: T[K];
|
||||||
|
};
|
||||||
@@ -0,0 +1,140 @@
|
|||||||
|
// This file is auto-generated by @hey-api/openapi-ts
|
||||||
|
|
||||||
|
import type { BodySerializer, QuerySerializer } from './bodySerializer.gen';
|
||||||
|
import {
|
||||||
|
type ArraySeparatorStyle,
|
||||||
|
serializeArrayParam,
|
||||||
|
serializeObjectParam,
|
||||||
|
serializePrimitiveParam,
|
||||||
|
} from './pathSerializer.gen';
|
||||||
|
|
||||||
|
export interface PathSerializer {
|
||||||
|
path: Record<string, unknown>;
|
||||||
|
url: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const PATH_PARAM_RE: RegExp = /\{[^{}]+\}/g;
|
||||||
|
|
||||||
|
export const defaultPathSerializer = ({ path, url: _url }: PathSerializer): string => {
|
||||||
|
let url = _url;
|
||||||
|
const matches = _url.match(PATH_PARAM_RE);
|
||||||
|
if (matches) {
|
||||||
|
for (const match of matches) {
|
||||||
|
let explode = false;
|
||||||
|
let name = match.substring(1, match.length - 1);
|
||||||
|
let style: ArraySeparatorStyle = 'simple';
|
||||||
|
|
||||||
|
if (name.endsWith('*')) {
|
||||||
|
explode = true;
|
||||||
|
name = name.substring(0, name.length - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (name.startsWith('.')) {
|
||||||
|
name = name.substring(1);
|
||||||
|
style = 'label';
|
||||||
|
} else if (name.startsWith(';')) {
|
||||||
|
name = name.substring(1);
|
||||||
|
style = 'matrix';
|
||||||
|
}
|
||||||
|
|
||||||
|
const value = path[name];
|
||||||
|
|
||||||
|
if (value === undefined || value === null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Array.isArray(value)) {
|
||||||
|
url = url.replace(match, serializeArrayParam({ explode, name, style, value }));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof value === 'object') {
|
||||||
|
url = url.replace(
|
||||||
|
match,
|
||||||
|
serializeObjectParam({
|
||||||
|
explode,
|
||||||
|
name,
|
||||||
|
style,
|
||||||
|
value: value as Record<string, unknown>,
|
||||||
|
valueOnly: true,
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (style === 'matrix') {
|
||||||
|
url = url.replace(
|
||||||
|
match,
|
||||||
|
`;${serializePrimitiveParam({
|
||||||
|
name,
|
||||||
|
value: value as string,
|
||||||
|
})}`,
|
||||||
|
);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const replaceValue = encodeURIComponent(
|
||||||
|
style === 'label' ? `.${value as string}` : (value as string),
|
||||||
|
);
|
||||||
|
url = url.replace(match, replaceValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return url;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getUrl = ({
|
||||||
|
baseUrl,
|
||||||
|
path,
|
||||||
|
query,
|
||||||
|
querySerializer,
|
||||||
|
url: _url,
|
||||||
|
}: {
|
||||||
|
baseUrl?: string;
|
||||||
|
path?: Record<string, unknown>;
|
||||||
|
query?: Record<string, unknown>;
|
||||||
|
querySerializer: QuerySerializer;
|
||||||
|
url: string;
|
||||||
|
}): string => {
|
||||||
|
const pathUrl = _url.startsWith('/') ? _url : `/${_url}`;
|
||||||
|
let url = (baseUrl ?? '') + pathUrl;
|
||||||
|
if (path) {
|
||||||
|
url = defaultPathSerializer({ path, url });
|
||||||
|
}
|
||||||
|
let search = query ? querySerializer(query) : '';
|
||||||
|
if (search.startsWith('?')) {
|
||||||
|
search = search.substring(1);
|
||||||
|
}
|
||||||
|
if (search) {
|
||||||
|
url += `?${search}`;
|
||||||
|
}
|
||||||
|
return url;
|
||||||
|
};
|
||||||
|
|
||||||
|
export function getValidRequestBody(options: {
|
||||||
|
body?: unknown;
|
||||||
|
bodySerializer?: BodySerializer | null;
|
||||||
|
serializedBody?: unknown;
|
||||||
|
}): unknown {
|
||||||
|
const hasBody = options.body !== undefined;
|
||||||
|
const isSerializedBody = hasBody && options.bodySerializer;
|
||||||
|
|
||||||
|
if (isSerializedBody) {
|
||||||
|
if ('serializedBody' in options) {
|
||||||
|
const hasSerializedBody =
|
||||||
|
options.serializedBody !== undefined && options.serializedBody !== '';
|
||||||
|
|
||||||
|
return hasSerializedBody ? options.serializedBody : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// not all clients implement a serializedBody property (i.e., client-axios)
|
||||||
|
return options.body !== '' ? options.body : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// plain/text body
|
||||||
|
if (hasBody) {
|
||||||
|
return options.body;
|
||||||
|
}
|
||||||
|
|
||||||
|
// no body was provided
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
// This file is auto-generated by @hey-api/openapi-ts
|
||||||
|
|
||||||
|
export { addComment, addMyGak, addTalk, authConfig, blockTalkAuthor, createCard, deleteComment, deleteMyGak, deleteTalk, getArticle, getCardImage, getFeed, getImage, getIndex, getPost, getSeasonWeek, getSky, getSkyRanking, getTalkImage, getTodayGuPage, getTodayPage, getTomorrowGuPage, getTomorrowPage, getWatchSummary, getWeatherNow, getWeatherToday, getWeek, getWeekRanking, googleLogin, healthzHealthzGet, likeComment, likePost, likeTalk, listArticles, listCards, listComments, listEvents, listIndices, listMyGak, listMyTalks, listPlaces, listPresets, listRegions, listSaved, listTalks, login, logout, me, nearestRegion, type Options, publishCard, refresh, rejectCard, reportTalk, savePost, scoreMyGak, signup, talkGroups, unlikeComment, unlikePost, unlikeTalk, unsavePost, updateMe, uploadTalkImage } from './sdk.gen';
|
||||||
|
export { type AddCommentData, type AddCommentError, type AddCommentErrors, type AddCommentResponse, type AddCommentResponses, type AddMyGakData, type AddMyGakError, type AddMyGakErrors, type AddMyGakResponse, type AddMyGakResponses, type AddTalkData, type AddTalkError, type AddTalkErrors, type AddTalkResponse, type AddTalkResponses, type AirData, AirGrade, ArticleCategory, type ArticleSummary, type AuthConfigData, type AuthConfigResponse, type AuthConfigResponses, AuthProvider, type BandArticle, type BandEvent, type Bands, type BestTime, type BlockTalkAuthorData, type BlockTalkAuthorError, type BlockTalkAuthorErrors, type BlockTalkAuthorResponse, type BlockTalkAuthorResponses, type BodyUploadTalkImageV1TalkImagePost, type CardItem, CardStatus, type ClientOptions, type CommentData, type CommuteData, Confidence, type CreateCardData, type CreateCardError, type CreateCardErrors, type CreateCardResponse, type CreateCardResponses, type Cut, type DayData, type DeleteCommentData, type DeleteCommentError, type DeleteCommentErrors, type DeleteCommentResponse, type DeleteCommentResponses, type DeleteMyGakData, type DeleteMyGakError, type DeleteMyGakErrors, type DeleteMyGakResponse, type DeleteMyGakResponses, type DeleteTalkData, type DeleteTalkError, type DeleteTalkErrors, type DeleteTalkResponse, type DeleteTalkResponses, type ErrorInfo, type EventData, type Factor, type GakSlide, type GetArticleData, type GetArticleError, type GetArticleErrors, type GetArticleResponse, type GetArticleResponses, type GetCardImageData, type GetCardImageError, type GetCardImageErrors, type GetCardImageResponses, type GetFeedData, type GetFeedError, type GetFeedErrors, type GetFeedResponse, type GetFeedResponses, type GetImageData, type GetImageError, type GetImageErrors, type GetImageResponses, type GetIndexData, type GetIndexError, type GetIndexErrors, type GetIndexResponse, type GetIndexResponses, type GetPostData, type GetPostError, type GetPostErrors, type GetPostResponse, type GetPostResponses, type GetSeasonWeekData, type GetSeasonWeekResponse, type GetSeasonWeekResponses, type GetSkyData, type GetSkyError, type GetSkyErrors, type GetSkyRankingData, type GetSkyRankingResponse, type GetSkyRankingResponses, type GetSkyResponse, type GetSkyResponses, type GetTalkImageData, type GetTalkImageError, type GetTalkImageErrors, type GetTalkImageResponses, type GetTodayGuPageData, type GetTodayGuPageError, type GetTodayGuPageErrors, type GetTodayGuPageResponse, type GetTodayGuPageResponses, type GetTodayPageData, type GetTodayPageError, type GetTodayPageErrors, type GetTodayPageResponse, type GetTodayPageResponses, type GetTomorrowGuPageData, type GetTomorrowGuPageError, type GetTomorrowGuPageErrors, type GetTomorrowGuPageResponse, type GetTomorrowGuPageResponses, type GetTomorrowPageData, type GetTomorrowPageError, type GetTomorrowPageErrors, type GetTomorrowPageResponse, type GetTomorrowPageResponses, type GetWatchSummaryData, type GetWatchSummaryError, type GetWatchSummaryErrors, type GetWatchSummaryResponse, type GetWatchSummaryResponses, type GetWeatherNowData, type GetWeatherNowError, type GetWeatherNowErrors, type GetWeatherNowResponse, type GetWeatherNowResponses, type GetWeatherTodayData, type GetWeatherTodayError, type GetWeatherTodayErrors, type GetWeatherTodayResponse, type GetWeatherTodayResponses, type GetWeekData, type GetWeekError, type GetWeekErrors, type GetWeekRankingData, type GetWeekRankingResponse, type GetWeekRankingResponses, type GetWeekResponse, type GetWeekResponses, type GoogleLoginData, type GoogleLoginError, type GoogleLoginErrors, type GoogleLoginResponse, type GoogleLoginResponses, type HealthzHealthzGetData, type HealthzHealthzGetResponse, type HealthzHealthzGetResponses, type Hero, type HeroStat, type HeroTomorrow, type HourCell, type HoursSlide, type HttpValidationError, type ImageSlide, IndexCategory, type IndexSummary, type LikeCommentData, type LikeCommentError, type LikeCommentErrors, type LikeCommentResponse, type LikeCommentResponses, type LikePostData, type LikePostError, type LikePostErrors, type LikePostResponse, type LikePostResponses, type LikeTalkData, type LikeTalkError, type LikeTalkErrors, type LikeTalkResponse, type LikeTalkResponses, type ListArticlesData, type ListArticlesError, type ListArticlesErrors, type ListArticlesResponse, type ListArticlesResponses, type ListCardsData, type ListCardsError, type ListCardsErrors, type ListCardsResponse, type ListCardsResponses, type ListCommentsData, type ListCommentsError, type ListCommentsErrors, type ListCommentsResponse, type ListCommentsResponses, type ListEventsData, type ListEventsError, type ListEventsErrors, type ListEventsResponse, type ListEventsResponses, type ListIndicesData, type ListIndicesError, type ListIndicesErrors, type ListIndicesResponse, type ListIndicesResponses, type ListMyGakData, type ListMyGakError, type ListMyGakErrors, type ListMyGakResponse, type ListMyGakResponses, type ListMyTalksData, type ListMyTalksError, type LiLine truncated
|
||||||
@@ -0,0 +1,419 @@
|
|||||||
|
// This file is auto-generated by @hey-api/openapi-ts
|
||||||
|
|
||||||
|
import { type Client, type ClientMeta, formDataBodySerializer, type Options as Options2, type RequestResult, type TDataShape } from './client';
|
||||||
|
import { client } from './client.gen';
|
||||||
|
import type { AddCommentData, AddCommentErrors, AddCommentResponses, AddMyGakData, AddMyGakErrors, AddMyGakResponses, AddTalkData, AddTalkErrors, AddTalkResponses, AuthConfigData, AuthConfigResponses, BlockTalkAuthorData, BlockTalkAuthorErrors, BlockTalkAuthorResponses, CreateCardData, CreateCardErrors, CreateCardResponses, DeleteCommentData, DeleteCommentErrors, DeleteCommentResponses, DeleteMyGakData, DeleteMyGakErrors, DeleteMyGakResponses, DeleteTalkData, DeleteTalkErrors, DeleteTalkResponses, GetArticleData, GetArticleErrors, GetArticleResponses, GetCardImageData, GetCardImageErrors, GetCardImageResponses, GetFeedData, GetFeedErrors, GetFeedResponses, GetImageData, GetImageErrors, GetImageResponses, GetIndexData, GetIndexErrors, GetIndexResponses, GetPostData, GetPostErrors, GetPostResponses, GetSeasonWeekData, GetSeasonWeekResponses, GetSkyData, GetSkyErrors, GetSkyRankingData, GetSkyRankingResponses, GetSkyResponses, GetTalkImageData, GetTalkImageErrors, GetTalkImageResponses, GetTodayGuPageData, GetTodayGuPageErrors, GetTodayGuPageResponses, GetTodayPageData, GetTodayPageErrors, GetTodayPageResponses, GetTomorrowGuPageData, GetTomorrowGuPageErrors, GetTomorrowGuPageResponses, GetTomorrowPageData, GetTomorrowPageErrors, GetTomorrowPageResponses, GetWatchSummaryData, GetWatchSummaryErrors, GetWatchSummaryResponses, GetWeatherNowData, GetWeatherNowErrors, GetWeatherNowResponses, GetWeatherTodayData, GetWeatherTodayErrors, GetWeatherTodayResponses, GetWeekData, GetWeekErrors, GetWeekRankingData, GetWeekRankingResponses, GetWeekResponses, GoogleLoginData, GoogleLoginErrors, GoogleLoginResponses, HealthzHealthzGetData, HealthzHealthzGetResponses, LikeCommentData, LikeCommentErrors, LikeCommentResponses, LikePostData, LikePostErrors, LikePostResponses, LikeTalkData, LikeTalkErrors, LikeTalkResponses, ListArticlesData, ListArticlesErrors, ListArticlesResponses, ListCardsData, ListCardsErrors, ListCardsResponses, ListCommentsData, ListCommentsErrors, ListCommentsResponses, ListEventsData, ListEventsErrors, ListEventsResponses, ListIndicesData, ListIndicesErrors, ListIndicesResponses, ListMyGakData, ListMyGakErrors, ListMyGakResponses, ListMyTalksData, ListMyTalksErrors, ListMyTalksResponses, ListPlacesData, ListPlacesErrors, ListPlacesResponses, ListPresetsData, ListPresetsResponses, ListRegionsData, ListRegionsErrors, ListRegionsResponses, ListSavedData, ListSavedErrors, ListSavedResponses, ListTalksData, ListTalksErrors, ListTalksResponses, LoginData, LoginErrors, LoginResponses, LogoutData, LogoutErrors, LogoutResponses, MeData, MeErrors, MeResponses, NearestRegionData, NearestRegionErrors, NearestRegionResponses, PublishCardData, PublishCardErrors, PublishCardResponses, RefreshData, RefreshErrors, RefreshResponses, RejectCardData, RejectCardErrors, RejectCardResponses, ReportTalkData, ReportTalkErrors, ReportTalkResponses, SavePostData, SavePostErrors, SavePostResponses, ScoreMyGakData, ScoreMyGakErrors, ScoreMyGakResponses, SignupData, SignupErrors, SignupResponses, TalkGroupsData, TalkGroupsErrors, TalkGroupsResponses, UnlikeCommentData, UnlikeCommentErrors, UnlikeCommentResponses, UnlikePostData, UnlikePostErrors, UnlikePostResponses, UnlikeTalkData, UnlikeTalkErrors, UnlikeTalkResponses, UnsavePostData, UnsavePostErrors, UnsavePostResponses, UpdateMeData, UpdateMeErrors, UpdateMeResponses, UploadTalkImageData, UploadTalkImageErrors, UploadTalkImageResponses } from './types.gen';
|
||||||
|
|
||||||
|
export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean, TResponse = unknown> = Options2<TData, ThrowOnError, TResponse> & {
|
||||||
|
/**
|
||||||
|
* You can provide a client instance returned by `createClient()` instead of
|
||||||
|
* individual options. This might be also useful if you want to implement a
|
||||||
|
* custom client.
|
||||||
|
*/
|
||||||
|
client?: Client;
|
||||||
|
/**
|
||||||
|
* You can pass arbitrary values through the `meta` object. This can be
|
||||||
|
* used to access values that aren't defined as part of the SDK function.
|
||||||
|
*/
|
||||||
|
meta?: keyof ClientMeta extends never ? Record<string, unknown> : ClientMeta;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 구 목록
|
||||||
|
*/
|
||||||
|
export const listRegions = <ThrowOnError extends boolean = true>(options?: Options<ListRegionsData, ThrowOnError>): RequestResult<ListRegionsResponses, ListRegionsErrors, ThrowOnError> => (options?.client ?? client).get<ListRegionsResponses, ListRegionsErrors, ThrowOnError>({ url: '/v1/region/list', ...options });
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 위치에서 가장 가까운 구
|
||||||
|
*/
|
||||||
|
export const nearestRegion = <ThrowOnError extends boolean = true>(options: Options<NearestRegionData, ThrowOnError>): RequestResult<NearestRegionResponses, NearestRegionErrors, ThrowOnError> => (options.client ?? client).get<NearestRegionResponses, NearestRegionErrors, ThrowOnError>({ url: '/v1/region/nearest', ...options });
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 오늘(또는 내일) 3시간 칸 날씨
|
||||||
|
*/
|
||||||
|
export const getWeatherToday = <ThrowOnError extends boolean = true>(options: Options<GetWeatherTodayData, ThrowOnError>): RequestResult<GetWeatherTodayResponses, GetWeatherTodayErrors, ThrowOnError> => (options.client ?? client).get<GetWeatherTodayResponses, GetWeatherTodayErrors, ThrowOnError>({ url: '/v1/weather/today', ...options });
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 지금 비 올까: 2시간 비, 내일 출퇴근, 미세먼지, 특보
|
||||||
|
*/
|
||||||
|
export const getWeatherNow = <ThrowOnError extends boolean = true>(options: Options<GetWeatherNowData, ThrowOnError>): RequestResult<GetWeatherNowResponses, GetWeatherNowErrors, ThrowOnError> => (options.client ?? client).get<GetWeatherNowResponses, GetWeatherNowErrors, ThrowOnError>({ url: '/v1/weather/now', ...options });
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 노을 결론(나가 볼 만한지·왜·언제 어디로), 시간표, 앞으로 3일, 가까운 명소
|
||||||
|
*/
|
||||||
|
export const getSky = <ThrowOnError extends boolean = true>(options: Options<GetSkyData, ThrowOnError>): RequestResult<GetSkyResponses, GetSkyErrors, ThrowOnError> => (options.client ?? client).get<GetSkyResponses, GetSkyErrors, ThrowOnError>({ url: '/v1/sky', ...options });
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 전국 노을 순위 (대표 30곳)
|
||||||
|
*/
|
||||||
|
export const getSkyRanking = <ThrowOnError extends boolean = true>(options?: Options<GetSkyRankingData, ThrowOnError>): RequestResult<GetSkyRankingResponses, unknown, ThrowOnError> => (options?.client ?? client).get<GetSkyRankingResponses, unknown, ThrowOnError>({ url: '/v1/sky/ranking', ...options });
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 지수 목록 (지금 구간 점수순, 1~3위, 지금 날씨 점수)
|
||||||
|
*/
|
||||||
|
export const listIndices = <ThrowOnError extends boolean = true>(options: Options<ListIndicesData, ThrowOnError>): RequestResult<ListIndicesResponses, ListIndicesErrors, ThrowOnError> => (options.client ?? client).get<ListIndicesResponses, ListIndicesErrors, ThrowOnError>({ url: '/v1/index/list', ...options });
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 지수 계산 근거
|
||||||
|
*/
|
||||||
|
export const getIndex = <ThrowOnError extends boolean = true>(options: Options<GetIndexData, ThrowOnError>): RequestResult<GetIndexResponses, GetIndexErrors, ThrowOnError> => (options.client ?? client).get<GetIndexResponses, GetIndexErrors, ThrowOnError>({ url: '/v1/index/{index_id}', ...options });
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 7일 날씨와 그날 추천
|
||||||
|
*/
|
||||||
|
export const getWeek = <ThrowOnError extends boolean = true>(options: Options<GetWeekData, ThrowOnError>): RequestResult<GetWeekResponses, GetWeekErrors, ThrowOnError> => (options.client ?? client).get<GetWeekResponses, GetWeekErrors, ThrowOnError>({ url: '/v1/week', ...options });
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 이번 주말 전국 나들이 날씨 순위 (대표 30곳)
|
||||||
|
*/
|
||||||
|
export const getWeekRanking = <ThrowOnError extends boolean = true>(options?: Options<GetWeekRankingData, ThrowOnError>): RequestResult<GetWeekRankingResponses, unknown, ThrowOnError> => (options?.client ?? client).get<GetWeekRankingResponses, unknown, ThrowOnError>({ url: '/v1/week/ranking', ...options });
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 날씨 맞춤 데이트 명소 (구 중심 30km 안, 없으면 가장 가까운 곳)
|
||||||
|
*/
|
||||||
|
export const listPlaces = <ThrowOnError extends boolean = true>(options: Options<ListPlacesData, ThrowOnError>): RequestResult<ListPlacesResponses, ListPlacesErrors, ThrowOnError> => (options.client ?? client).get<ListPlacesResponses, ListPlacesErrors, ThrowOnError>({ url: '/v1/week/place/list', ...options });
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 앞으로 30일 축제·행사
|
||||||
|
*/
|
||||||
|
export const listEvents = <ThrowOnError extends boolean = true>(options: Options<ListEventsData, ThrowOnError>): RequestResult<ListEventsResponses, ListEventsErrors, ThrowOnError> => (options.client ?? client).get<ListEventsResponses, ListEventsErrors, ThrowOnError>({ url: '/v1/week/event/list', ...options });
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 이번 주 계절 책: 시, 절기, 계절 소식
|
||||||
|
*/
|
||||||
|
export const getSeasonWeek = <ThrowOnError extends boolean = true>(options?: Options<GetSeasonWeekData, ThrowOnError>): RequestResult<GetSeasonWeekResponses, unknown, ThrowOnError> => (options?.client ?? client).get<GetSeasonWeekResponses, unknown, ThrowOnError>({ url: '/v1/season/week', ...options });
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 읽을거리 목록
|
||||||
|
*/
|
||||||
|
export const listArticles = <ThrowOnError extends boolean = true>(options?: Options<ListArticlesData, ThrowOnError>): RequestResult<ListArticlesResponses, ListArticlesErrors, ThrowOnError> => (options?.client ?? client).get<ListArticlesResponses, ListArticlesErrors, ThrowOnError>({ url: '/v1/season/article/list', ...options });
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 읽을거리 본문
|
||||||
|
*/
|
||||||
|
export const getArticle = <ThrowOnError extends boolean = true>(options: Options<GetArticleData, ThrowOnError>): RequestResult<GetArticleResponses, GetArticleErrors, ThrowOnError> => (options.client ?? client).get<GetArticleResponses, GetArticleErrors, ThrowOnError>({ url: '/v1/season/article/{article_id}', ...options });
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 메인 피드: 하늘 영역, 오늘의 각, 오늘 포스트 전부, 띠
|
||||||
|
*/
|
||||||
|
export const getFeed = <ThrowOnError extends boolean = true>(options: Options<GetFeedData, ThrowOnError>): RequestResult<GetFeedResponses, GetFeedErrors, ThrowOnError> => (options.client ?? client).get<GetFeedResponses, GetFeedErrors, ThrowOnError>({ url: '/v1/feed', ...options });
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 포스트 하나 (공유 링크로 들어왔을 때)
|
||||||
|
*/
|
||||||
|
export const getPost = <ThrowOnError extends boolean = true>(options: Options<GetPostData, ThrowOnError>): RequestResult<GetPostResponses, GetPostErrors, ThrowOnError> => (options.client ?? client).get<GetPostResponses, GetPostErrors, ThrowOnError>({ url: '/v1/feed/post/{post_id}', ...options });
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 회원가입 (아이디 영문 소문자·숫자·_ 4~20자, 비밀번호 8자 이상, 닉네임 2~12자)
|
||||||
|
*/
|
||||||
|
export const signup = <ThrowOnError extends boolean = true>(options: Options<SignupData, ThrowOnError>): RequestResult<SignupResponses, SignupErrors, ThrowOnError> => (options.client ?? client).post<SignupResponses, SignupErrors, ThrowOnError>({
|
||||||
|
url: '/v1/auth/signup',
|
||||||
|
...options,
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
...options.headers
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 로그인
|
||||||
|
*/
|
||||||
|
export const login = <ThrowOnError extends boolean = true>(options: Options<LoginData, ThrowOnError>): RequestResult<LoginResponses, LoginErrors, ThrowOnError> => (options.client ?? client).post<LoginResponses, LoginErrors, ThrowOnError>({
|
||||||
|
url: '/v1/auth/login',
|
||||||
|
...options,
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
...options.headers
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 구글 로그인 (처음이면 자동 닉네임으로 가입)
|
||||||
|
*/
|
||||||
|
export const googleLogin = <ThrowOnError extends boolean = true>(options: Options<GoogleLoginData, ThrowOnError>): RequestResult<GoogleLoginResponses, GoogleLoginErrors, ThrowOnError> => (options.client ?? client).post<GoogleLoginResponses, GoogleLoginErrors, ThrowOnError>({
|
||||||
|
url: '/v1/auth/google',
|
||||||
|
...options,
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
...options.headers
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 로그인 화면 설정 (구글 클라이언트 ID)
|
||||||
|
*/
|
||||||
|
export const authConfig = <ThrowOnError extends boolean = true>(options?: Options<AuthConfigData, ThrowOnError>): RequestResult<AuthConfigResponses, unknown, ThrowOnError> => (options?.client ?? client).get<AuthConfigResponses, unknown, ThrowOnError>({ url: '/v1/auth/config', ...options });
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 토큰 재발급
|
||||||
|
*/
|
||||||
|
export const refresh = <ThrowOnError extends boolean = true>(options: Options<RefreshData, ThrowOnError>): RequestResult<RefreshResponses, RefreshErrors, ThrowOnError> => (options.client ?? client).post<RefreshResponses, RefreshErrors, ThrowOnError>({
|
||||||
|
url: '/v1/auth/refresh',
|
||||||
|
...options,
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
...options.headers
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 로그아웃 (모든 기기의 토큰 무효)
|
||||||
|
*/
|
||||||
|
export const logout = <ThrowOnError extends boolean = true>(options?: Options<LogoutData, ThrowOnError>): RequestResult<LogoutResponses, LogoutErrors, ThrowOnError> => (options?.client ?? client).post<LogoutResponses, LogoutErrors, ThrowOnError>({ url: '/v1/auth/logout', ...options });
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 내 정보
|
||||||
|
*/
|
||||||
|
export const me = <ThrowOnError extends boolean = true>(options?: Options<MeData, ThrowOnError>): RequestResult<MeResponses, MeErrors, ThrowOnError> => (options?.client ?? client).get<MeResponses, MeErrors, ThrowOnError>({ url: '/v1/auth/me', ...options });
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 내 정보 바꾸기 (닉네임 2~12자, 캐릭터 rabbit·bear·dog·sun·moon·cloud, 배경색 orange·blue·green·purple·pink·brown, 기분 clear·partly·cloudy·rain·thunder·snow·fog·rainbow, 빈 문자열이면 지움)
|
||||||
|
*/
|
||||||
|
export const updateMe = <ThrowOnError extends boolean = true>(options: Options<UpdateMeData, ThrowOnError>): RequestResult<UpdateMeResponses, UpdateMeErrors, ThrowOnError> => (options.client ?? client).patch<UpdateMeResponses, UpdateMeErrors, ThrowOnError>({
|
||||||
|
url: '/v1/auth/me',
|
||||||
|
...options,
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
...options.headers
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 좋아요 취소
|
||||||
|
*/
|
||||||
|
export const unlikePost = <ThrowOnError extends boolean = true>(options: Options<UnlikePostData, ThrowOnError>): RequestResult<UnlikePostResponses, UnlikePostErrors, ThrowOnError> => (options.client ?? client).delete<UnlikePostResponses, UnlikePostErrors, ThrowOnError>({ url: '/v1/reaction/post/{post_id}/like', ...options });
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 좋아요 (로그인 없으면 IP 당 한 번)
|
||||||
|
*/
|
||||||
|
export const likePost = <ThrowOnError extends boolean = true>(options: Options<LikePostData, ThrowOnError>): RequestResult<LikePostResponses, LikePostErrors, ThrowOnError> => (options.client ?? client).post<LikePostResponses, LikePostErrors, ThrowOnError>({ url: '/v1/reaction/post/{post_id}/like', ...options });
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 저장 취소
|
||||||
|
*/
|
||||||
|
export const unsavePost = <ThrowOnError extends boolean = true>(options: Options<UnsavePostData, ThrowOnError>): RequestResult<UnsavePostResponses, UnsavePostErrors, ThrowOnError> => (options.client ?? client).delete<UnsavePostResponses, UnsavePostErrors, ThrowOnError>({ url: '/v1/reaction/post/{post_id}/save', ...options });
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 저장
|
||||||
|
*/
|
||||||
|
export const savePost = <ThrowOnError extends boolean = true>(options: Options<SavePostData, ThrowOnError>): RequestResult<SavePostResponses, SavePostErrors, ThrowOnError> => (options.client ?? client).post<SavePostResponses, SavePostErrors, ThrowOnError>({ url: '/v1/reaction/post/{post_id}/save', ...options });
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 내가 저장한 포스트
|
||||||
|
*/
|
||||||
|
export const listSaved = <ThrowOnError extends boolean = true>(options?: Options<ListSavedData, ThrowOnError>): RequestResult<ListSavedResponses, ListSavedErrors, ThrowOnError> => (options?.client ?? client).get<ListSavedResponses, ListSavedErrors, ThrowOnError>({ url: '/v1/reaction/save/list', ...options });
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 댓글 목록 (로그인 없이 보기)
|
||||||
|
*/
|
||||||
|
export const listComments = <ThrowOnError extends boolean = true>(options: Options<ListCommentsData, ThrowOnError>): RequestResult<ListCommentsResponses, ListCommentsErrors, ThrowOnError> => (options.client ?? client).get<ListCommentsResponses, ListCommentsErrors, ThrowOnError>({ url: '/v1/reaction/post/{post_id}/comment/list', ...options });
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 댓글 쓰기 (60자, 로그인 없으면 '동네 익명'으로 IP 당 하루 20개)
|
||||||
|
*/
|
||||||
|
export const addComment = <ThrowOnError extends boolean = true>(options: Options<AddCommentData, ThrowOnError>): RequestResult<AddCommentResponses, AddCommentErrors, ThrowOnError> => (options.client ?? client).post<AddCommentResponses, AddCommentErrors, ThrowOnError>({
|
||||||
|
url: '/v1/reaction/post/{post_id}/comment',
|
||||||
|
...options,
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
...options.headers
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 내 댓글 지우기 (로그인 없이 쓴 댓글은 같은 IP 에서)
|
||||||
|
*/
|
||||||
|
export const deleteComment = <ThrowOnError extends boolean = true>(options: Options<DeleteCommentData, ThrowOnError>): RequestResult<DeleteCommentResponses, DeleteCommentErrors, ThrowOnError> => (options.client ?? client).delete<DeleteCommentResponses, DeleteCommentErrors, ThrowOnError>({ url: '/v1/reaction/comment/{comment_id}', ...options });
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 댓글 좋아요 취소
|
||||||
|
*/
|
||||||
|
export const unlikeComment = <ThrowOnError extends boolean = true>(options: Options<UnlikeCommentData, ThrowOnError>): RequestResult<UnlikeCommentResponses, UnlikeCommentErrors, ThrowOnError> => (options.client ?? client).delete<UnlikeCommentResponses, UnlikeCommentErrors, ThrowOnError>({ url: '/v1/reaction/comment/{comment_id}/like', ...options });
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 댓글 좋아요 (로그인 없으면 IP 당 한 번)
|
||||||
|
*/
|
||||||
|
export const likeComment = <ThrowOnError extends boolean = true>(options: Options<LikeCommentData, ThrowOnError>): RequestResult<LikeCommentResponses, LikeCommentErrors, ThrowOnError> => (options.client ?? client).post<LikeCommentResponses, LikeCommentErrors, ThrowOnError>({ url: '/v1/reaction/comment/{comment_id}/like', ...options });
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 내 각 목록 (로그인하지 않았으면 빈 목록)
|
||||||
|
*/
|
||||||
|
export const listMyGak = <ThrowOnError extends boolean = true>(options?: Options<ListMyGakData, ThrowOnError>): RequestResult<ListMyGakResponses, ListMyGakErrors, ThrowOnError> => (options?.client ?? client).get<ListMyGakResponses, ListMyGakErrors, ThrowOnError>({ url: '/v1/my-gak', ...options });
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 이름과 날씨 조건으로 내 각 만들기
|
||||||
|
*/
|
||||||
|
export const addMyGak = <ThrowOnError extends boolean = true>(options: Options<AddMyGakData, ThrowOnError>): RequestResult<AddMyGakResponses, AddMyGakErrors, ThrowOnError> => (options.client ?? client).post<AddMyGakResponses, AddMyGakErrors, ThrowOnError>({
|
||||||
|
url: '/v1/my-gak',
|
||||||
|
...options,
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
...options.headers
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 공식 각을 내 각 조건으로 옮긴 목록 (내 각 만들기에서 골라 채우기)
|
||||||
|
*/
|
||||||
|
export const listPresets = <ThrowOnError extends boolean = true>(options?: Options<ListPresetsData, ThrowOnError>): RequestResult<ListPresetsResponses, unknown, ThrowOnError> => (options?.client ?? client).get<ListPresetsResponses, unknown, ThrowOnError>({ url: '/v1/my-gak/presets', ...options });
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 조건들의 그 동네 오늘 점수 (로그인 없이, 받은 링크의 각도)
|
||||||
|
*/
|
||||||
|
export const scoreMyGak = <ThrowOnError extends boolean = true>(options: Options<ScoreMyGakData, ThrowOnError>): RequestResult<ScoreMyGakResponses, ScoreMyGakErrors, ThrowOnError> => (options.client ?? client).post<ScoreMyGakResponses, ScoreMyGakErrors, ThrowOnError>({
|
||||||
|
url: '/v1/my-gak/score',
|
||||||
|
...options,
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
...options.headers
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 내 각 지우기
|
||||||
|
*/
|
||||||
|
export const deleteMyGak = <ThrowOnError extends boolean = true>(options: Options<DeleteMyGakData, ThrowOnError>): RequestResult<DeleteMyGakResponses, DeleteMyGakErrors, ThrowOnError> => (options.client ?? client).delete<DeleteMyGakResponses, DeleteMyGakErrors, ThrowOnError>({ url: '/v1/my-gak/{my_gak_id}', ...options });
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 오늘 피드 묶음 (동네 사람들 + 주제별, 가까운 동네·덜 지난 글 먼저, 한 사람 한 장)
|
||||||
|
*/
|
||||||
|
export const talkGroups = <ThrowOnError extends boolean = true>(options?: Options<TalkGroupsData, ThrowOnError>): RequestResult<TalkGroupsResponses, TalkGroupsErrors, ThrowOnError> => (options?.client ?? client).get<TalkGroupsResponses, TalkGroupsErrors, ThrowOnError>({ url: '/v1/talk/groups', ...options });
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 동네 이야기 (전국 최신순, 보는 동네와 같은 시도 글은 앞으로, 같은 사람 글은 띄움, 로그인 없이 보기)
|
||||||
|
*/
|
||||||
|
export const listTalks = <ThrowOnError extends boolean = true>(options?: Options<ListTalksData, ThrowOnError>): RequestResult<ListTalksResponses, ListTalksErrors, ThrowOnError> => (options?.client ?? client).get<ListTalksResponses, ListTalksErrors, ThrowOnError>({ url: '/v1/talk/list', ...options });
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 내가 쓴 글 (최신순)
|
||||||
|
*/
|
||||||
|
export const listMyTalks = <ThrowOnError extends boolean = true>(options?: Options<ListMyTalksData, ThrowOnError>): RequestResult<ListMyTalksResponses, ListMyTalksErrors, ThrowOnError> => (options?.client ?? client).get<ListMyTalksResponses, ListMyTalksErrors, ThrowOnError>({ url: '/v1/talk/mine', ...options });
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 동네 이야기 쓰기 (링크·전화번호 불가, 하루 5개)
|
||||||
|
*/
|
||||||
|
export const addTalk = <ThrowOnError extends boolean = true>(options: Options<AddTalkData, ThrowOnError>): RequestResult<AddTalkResponses, AddTalkErrors, ThrowOnError> => (options.client ?? client).post<AddTalkResponses, AddTalkErrors, ThrowOnError>({
|
||||||
|
url: '/v1/talk',
|
||||||
|
...options,
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
...options.headers
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 글에 붙일 사진 올리기 (10MB까지, 위치 정보를 지우고 1080px로 줄여 저장)
|
||||||
|
*/
|
||||||
|
export const uploadTalkImage = <ThrowOnError extends boolean = true>(options: Options<UploadTalkImageData, ThrowOnError>): RequestResult<UploadTalkImageResponses, UploadTalkImageErrors, ThrowOnError> => (options.client ?? client).post<UploadTalkImageResponses, UploadTalkImageErrors, ThrowOnError>({
|
||||||
|
...formDataBodySerializer,
|
||||||
|
url: '/v1/talk/image',
|
||||||
|
...options,
|
||||||
|
headers: {
|
||||||
|
'Content-Type': null,
|
||||||
|
...options.headers
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 올린 사진
|
||||||
|
*/
|
||||||
|
export const getTalkImage = <ThrowOnError extends boolean = true>(options: Options<GetTalkImageData, ThrowOnError>): RequestResult<GetTalkImageResponses, GetTalkImageErrors, ThrowOnError> => (options.client ?? client).get<GetTalkImageResponses, GetTalkImageErrors, ThrowOnError>({ url: '/v1/talk/image/{name}', ...options });
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 내 이야기 지우기
|
||||||
|
*/
|
||||||
|
export const deleteTalk = <ThrowOnError extends boolean = true>(options: Options<DeleteTalkData, ThrowOnError>): RequestResult<DeleteTalkResponses, DeleteTalkErrors, ThrowOnError> => (options.client ?? client).delete<DeleteTalkResponses, DeleteTalkErrors, ThrowOnError>({ url: '/v1/talk/{talk_id}', ...options });
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 이야기 좋아요 취소
|
||||||
|
*/
|
||||||
|
export const unlikeTalk = <ThrowOnError extends boolean = true>(options: Options<UnlikeTalkData, ThrowOnError>): RequestResult<UnlikeTalkResponses, UnlikeTalkErrors, ThrowOnError> => (options.client ?? client).delete<UnlikeTalkResponses, UnlikeTalkErrors, ThrowOnError>({ url: '/v1/talk/{talk_id}/like', ...options });
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 이야기 좋아요 (로그인 없으면 IP 당 한 번)
|
||||||
|
*/
|
||||||
|
export const likeTalk = <ThrowOnError extends boolean = true>(options: Options<LikeTalkData, ThrowOnError>): RequestResult<LikeTalkResponses, LikeTalkErrors, ThrowOnError> => (options.client ?? client).post<LikeTalkResponses, LikeTalkErrors, ThrowOnError>({ url: '/v1/talk/{talk_id}/like', ...options });
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 이야기 신고 (서로 다른 3명이면 숨김)
|
||||||
|
*/
|
||||||
|
export const reportTalk = <ThrowOnError extends boolean = true>(options: Options<ReportTalkData, ThrowOnError>): RequestResult<ReportTalkResponses, ReportTalkErrors, ThrowOnError> => (options.client ?? client).post<ReportTalkResponses, ReportTalkErrors, ThrowOnError>({
|
||||||
|
url: '/v1/talk/{talk_id}/report',
|
||||||
|
...options,
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
...options.headers
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 이 글 쓴 사람의 글 안 보기
|
||||||
|
*/
|
||||||
|
export const blockTalkAuthor = <ThrowOnError extends boolean = true>(options: Options<BlockTalkAuthorData, ThrowOnError>): RequestResult<BlockTalkAuthorResponses, BlockTalkAuthorErrors, ThrowOnError> => (options.client ?? client).post<BlockTalkAuthorResponses, BlockTalkAuthorErrors, ThrowOnError>({ url: '/v1/talk/{talk_id}/block', ...options });
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 워치 한 번에: 지금 날씨, 각 1~7위·내 각, 노을, 남은 3시간 칸, 컴플리케이션 시간표
|
||||||
|
*/
|
||||||
|
export const getWatchSummary = <ThrowOnError extends boolean = true>(options: Options<GetWatchSummaryData, ThrowOnError>): RequestResult<GetWatchSummaryResponses, GetWatchSummaryErrors, ThrowOnError> => (options.client ?? client).get<GetWatchSummaryResponses, GetWatchSummaryErrors, ThrowOnError>({ url: '/v1/watch/summary', ...options });
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 행사 사진 대신 받기 (공유 이미지용, 허용한 호스트만)
|
||||||
|
*/
|
||||||
|
export const getImage = <ThrowOnError extends boolean = true>(options: Options<GetImageData, ThrowOnError>): RequestResult<GetImageResponses, GetImageErrors, ThrowOnError> => (options.client ?? client).get<GetImageResponses, GetImageErrors, ThrowOnError>({ url: '/v1/image', ...options });
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 지역 검색 페이지: 정적 HTML 에 오늘 날씨·각을 채워 돌려준다 (nginx 가 /today/... 를 넘김)
|
||||||
|
*/
|
||||||
|
export const getTodayPage = <ThrowOnError extends boolean = true>(options: Options<GetTodayPageData, ThrowOnError>): RequestResult<GetTodayPageResponses, GetTodayPageErrors, ThrowOnError> => (options.client ?? client).get<GetTodayPageResponses, GetTodayPageErrors, ThrowOnError>({ url: '/v1/seo/today/{sido}/{place}', ...options });
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 구로 나뉜 시의 구 페이지 (/today/gyeonggi/seongnam/bundang)
|
||||||
|
*/
|
||||||
|
export const getTodayGuPage = <ThrowOnError extends boolean = true>(options: Options<GetTodayGuPageData, ThrowOnError>): RequestResult<GetTodayGuPageResponses, GetTodayGuPageErrors, ThrowOnError> => (options.client ?? client).get<GetTodayGuPageResponses, GetTodayGuPageErrors, ThrowOnError>({ url: '/v1/seo/today/{sido}/{place}/{gu}', ...options });
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 지역 내일 날씨 페이지: 정적 HTML 에 내일 예보를 채운다 (nginx 가 /tomorrow/... 를 넘김)
|
||||||
|
*/
|
||||||
|
export const getTomorrowPage = <ThrowOnError extends boolean = true>(options: Options<GetTomorrowPageData, ThrowOnError>): RequestResult<GetTomorrowPageResponses, GetTomorrowPageErrors, ThrowOnError> => (options.client ?? client).get<GetTomorrowPageResponses, GetTomorrowPageErrors, ThrowOnError>({ url: '/v1/seo/tomorrow/{sido}/{place}', ...options });
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 구로 나뉜 시의 구 내일 날씨 페이지
|
||||||
|
*/
|
||||||
|
export const getTomorrowGuPage = <ThrowOnError extends boolean = true>(options: Options<GetTomorrowGuPageData, ThrowOnError>): RequestResult<GetTomorrowGuPageResponses, GetTomorrowGuPageErrors, ThrowOnError> => (options.client ?? client).get<GetTomorrowGuPageResponses, GetTomorrowGuPageErrors, ThrowOnError>({ url: '/v1/seo/tomorrow/{sido}/{place}/{gu}', ...options });
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 만든 카드뉴스 목록 (관리자). 다시 내려받거나 올릴 때
|
||||||
|
*/
|
||||||
|
export const listCards = <ThrowOnError extends boolean = true>(options?: Options<ListCardsData, ThrowOnError>): RequestResult<ListCardsResponses, ListCardsErrors, ThrowOnError> => (options?.client ?? client).get<ListCardsResponses, ListCardsErrors, ThrowOnError>({ url: '/v1/card', ...options });
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 카드뉴스 저장 (관리자). publish 면 바로 그날 피드에 올린다
|
||||||
|
*/
|
||||||
|
export const createCard = <ThrowOnError extends boolean = true>(options: Options<CreateCardData, ThrowOnError>): RequestResult<CreateCardResponses, CreateCardErrors, ThrowOnError> => (options.client ?? client).post<CreateCardResponses, CreateCardErrors, ThrowOnError>({
|
||||||
|
url: '/v1/card',
|
||||||
|
...options,
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
...options.headers
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 승인 대기 카드뉴스를 그날 피드에 올리기 (관리자)
|
||||||
|
*/
|
||||||
|
export const publishCard = <ThrowOnError extends boolean = true>(options: Options<PublishCardData, ThrowOnError>): RequestResult<PublishCardResponses, PublishCardErrors, ThrowOnError> => (options.client ?? client).post<PublishCardResponses, PublishCardErrors, ThrowOnError>({ url: '/v1/card/{card_id}/publish', ...options });
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 승인 대기 카드뉴스 반려 (관리자)
|
||||||
|
*/
|
||||||
|
export const rejectCard = <ThrowOnError extends boolean = true>(options: Options<RejectCardData, ThrowOnError>): RequestResult<RejectCardResponses, RejectCardErrors, ThrowOnError> => (options.client ?? client).post<RejectCardResponses, RejectCardErrors, ThrowOnError>({ url: '/v1/card/{card_id}/reject', ...options });
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 카드뉴스 이미지
|
||||||
|
*/
|
||||||
|
export const getCardImage = <ThrowOnError extends boolean = true>(options: Options<GetCardImageData, ThrowOnError>): RequestResult<GetCardImageResponses, GetCardImageErrors, ThrowOnError> => (options.client ?? client).get<GetCardImageResponses, GetCardImageErrors, ThrowOnError>({ url: '/v1/card/{card_id}/{seq}.jpg', ...options });
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 헬스체크
|
||||||
|
*/
|
||||||
|
export const healthzHealthzGet = <ThrowOnError extends boolean = true>(options?: Options<HealthzHealthzGetData, ThrowOnError>): RequestResult<HealthzHealthzGetResponses, unknown, ThrowOnError> => (options?.client ?? client).get<HealthzHealthzGetResponses, unknown, ThrowOnError>({ url: '/healthz', ...options });
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
import { client } from './client/client.gen'
|
||||||
|
|
||||||
|
export const API_BASE_URL: string = import.meta.env.VITE_API_BASE_URL ?? 'http://localhost:9810'
|
||||||
|
|
||||||
|
client.setConfig({ baseUrl: API_BASE_URL, throwOnError: true })
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
import { useQuery } from '@tanstack/react-query'
|
||||||
|
|
||||||
|
/** 올릴 곳 (관리자 서버가 비밀값을 가진 곳만 나온다): 로컬 백엔드, 킹서버 */
|
||||||
|
export type Target = { id: 'local' | 'king'; label: string; site: string; api: string }
|
||||||
|
|
||||||
|
export function useTargets() {
|
||||||
|
return useQuery({
|
||||||
|
queryKey: ['targets'],
|
||||||
|
queryFn: async () => (await (await fetch('/api/targets')).json()) as Target[],
|
||||||
|
staleTime: Infinity,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export type CardSummary = { card_id: number; status: 1 | 2 | 3; post_id?: number; ig_media_id?: string }
|
||||||
|
|
||||||
|
export async function postCard(target: Target['id'], body: unknown): Promise<CardSummary> {
|
||||||
|
const r = await fetch(`/api/post?target=${target}`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body) })
|
||||||
|
const res = await r.json()
|
||||||
|
if (!r.ok || res.result?.success === false) throw new Error(res.error ?? res.msg ?? res.result?.desc ?? `HTTP ${r.status}`)
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function cardAction(target: Target['id'], id: number, what: 'publish' | 'reject' | 'instagram'): Promise<CardSummary> {
|
||||||
|
const r = await fetch(`/api/cards/${id}/${what}?target=${target}`, { method: 'POST' })
|
||||||
|
const res = await r.json()
|
||||||
|
if (!r.ok || res.result?.success === false) throw new Error(res.error ?? res.msg ?? res.result?.desc ?? `HTTP ${r.status}`)
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 202 KiB |
|
After Width: | Height: | Size: 216 KiB |
|
After Width: | Height: | Size: 252 KiB |
|
After Width: | Height: | Size: 222 KiB |
|
After Width: | Height: | Size: 222 KiB |
|
After Width: | Height: | Size: 214 KiB |
|
After Width: | Height: | Size: 34 KiB |
|
After Width: | Height: | Size: 27 KiB |
|
After Width: | Height: | Size: 27 KiB |
|
After Width: | Height: | Size: 42 KiB |
|
After Width: | Height: | Size: 94 KiB |
|
After Width: | Height: | Size: 98 KiB |
|
After Width: | Height: | Size: 96 KiB |
|
After Width: | Height: | Size: 88 KiB |
|
After Width: | Height: | Size: 88 KiB |
|
After Width: | Height: | Size: 94 KiB |