feat(wizard): /setup — 비개발자용 DSN 없는 DB 연결 flow#230
Merged
Conversation
비개발자가 DSN/터미널 안 보고 Discord 안에서 DB 연결 완료. - adapters/db/dsn_builder.py: 폼 필드 → DSN/extras 조립 (PostgreSQL/MySQL/ Snowflake/BigQuery/DuckDB/D1). 비밀번호 URL-encode, FIELD_SCHEMA로 폼 메타데이터 노출. 순수 함수, 테스트 용이. - adapters/db/factory.py: build_explorer(extras=...) 지원, D1 토큰을 URL 밖에서 받아 D1Explorer에 주입. - frontends/discord/setup_wizard.py: discord.ui Modal + Select. /setup → 드롭다운(DB 종류) → 종류별 폼(5필드 이내) → submit. ephemeral. - frontends/discord/commands.py: register_db_for_guild(identity, db_type, fields) — DSN 조립 → 연결 테스트(list_tables) → EncryptedSecrets 저장 → scope 캐시 무효화. 친절한 에러(드라이버 미설치/연결실패). - frontends/discord/bot.py: /setup 슬래시 명령 등록. - tenancy/concierge.py: per-scope explorer 캐시 + DSN 라우팅. build_context가 guild scope의 db_dsn(+d1_token)을 읽어 explorer 동적 생성/캐시. forget_explorer(scope)로 cache bust. 검증: 106 테스트 통과(93+13), 위저드 import 토큰 없이 OK. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
무엇
비개발자가 DSN/터미널을 한 번도 안 보고 Discord 안에서 DB 연결 완료할 수 있게 하는 `/setup` 슬래시 명령. 드롭다운 → 폼 → 연결 테스트 → 암호화 저장. 그 길드의 다음 메시지부터 그 DB 자동 사용.
왜
v4.1 plan은 "Discord 1급 frontend"인데 `/connect `은 개발자 워크플로우임. 비개발자는 DSN 모름. 폼 UX가 진짜 사용성.
흐름
```
/setup
→ "데이터베이스 종류를 골라주세요" (드롭다운, 6종)
→ "Connect to PostgreSQL" 폼 (host/port/db/user/password)
→ 제출 → 🔌 연결 테스트 → "✅ PostgreSQL 연결 성공! 테이블 12개 발견."
```
DSN을 한 번도 안 봄. 비밀번호는 Fernet으로 암호화 저장 (`EncryptedSecrets`).
포함
아키텍처 원칙
discord.py는 `bot.py`/`setup_wizard.py`에만. 로직(`register_db_for_guild`, `dsn_builder`)은 discord.py 비의존 순수층 → 유닛테스트 가능.
검증
🤖 Generated with Claude Code