Skip to content

Latest commit

ย 

History

History
109 lines (84 loc) ยท 4.05 KB

File metadata and controls

109 lines (84 loc) ยท 4.05 KB

CLAUDE.md

SOLAPI SDK for Node.js โ€” SMS, LMS, MMS, Kakao ๋ฉ”์‹œ์ง€(์•Œ๋ฆผํ†ก/์นœ๊ตฌํ†ก) ๋ฐœ์†ก์„ ์œ„ํ•œ ์„œ๋ฒ„์‚ฌ์ด๋“œ SDK.

Core Principles

  1. Zero Tolerance for Errors โ€” ๋ชจ๋“  ๊ฒ€์ฆ ํ†ต๊ณผ ํ•„์ˆ˜, ๊ฒฝ๊ณ  ๋ฌด์‹œ ๊ธˆ์ง€
  2. Clarity over Cleverness โ€” ๋ช…ํ™•ํ•˜๊ณ  ์œ ์ง€๋ณด์ˆ˜ ๊ฐ€๋Šฅํ•œ ์ฝ”๋“œ ์šฐ์„ 
  3. Conciseness โ€” ์˜๋„๋ฅผ ์™„์ „ํžˆ ํ‘œํ˜„ํ•˜๋Š” ์ตœ์†Œํ•œ์˜ ์ฝ”๋“œ
  4. Reduce Comments โ€” ์ฝ”๋“œ๊ฐ€ ์ž์ฒด ์„ค๋ช…์ ์ด์–ด์•ผ ํ•จ. "why"๋งŒ ์ฃผ์„์œผ๋กœ ๋‚จ๊น€
  5. Read Before Writing โ€” ์ƒˆ ์ฝ”๋“œ ์ž‘์„ฑ ์ „ ๊ธฐ์กด ํŒจํ„ด์„ ๋ฐ˜๋“œ์‹œ ํ™•์ธ

Commands

pnpm dev              # Watch mode (tsup)
pnpm build            # Lint + build (production)
pnpm lint             # Biome check with auto-fix
pnpm test             # Run all tests once
pnpm test:watch       # Watch mode
pnpm vitest run <path>  # Run specific test file
pnpm docs             # Generate TypeDoc documentation

Mandatory Validation

์ฝ”๋“œ ๋ณ€๊ฒฝ ํ›„ ๋ฐ˜๋“œ์‹œ ์ˆœ์„œ๋Œ€๋กœ ์‹คํ–‰:

  1. pnpm lint โ€” Biome ์ž๋™ ์ˆ˜์ •
  2. pnpm test โ€” ์ „์ฒด ํ…Œ์ŠคํŠธ ํ†ต๊ณผ
  3. pnpm build โ€” ํƒ€์ž… ์ฒดํฌ + ๋นŒ๋“œ

์‹คํŒจ ์‹œ ์ˆ˜์ • ํ›„ ์žฌ์‹คํ–‰. ์‹คํŒจ ์ƒํƒœ๋กœ ์ปค๋ฐ‹ ๊ธˆ์ง€.

Architecture

Entry Point & Service Facade

SolapiMessageService (src/index.ts)๊ฐ€ ๋ชจ๋“  ๋„๋ฉ”์ธ ์„œ๋น„์Šค ๋ฉ”์„œ๋“œ๋ฅผ ๋ช…์‹œ์  .bind()๋กœ ์œ„์ž„.

Service Layer

๋ชจ๋“  ์„œ๋น„์Šค๋Š” DefaultService (src/services/defaultService.ts) ์ƒ์†:

  • Base URL: https://api.solapi.com
  • AuthenticationParameter ๊ธฐ๋ฐ˜ ์ธ์ฆ
  • defaultFetcher HTTP ์ถ”์ƒํ™”

๋„๋ฉ”์ธ ์„œ๋น„์Šค: MessageService, GroupService, KakaoChannelService, KakaoTemplateService, CashService, IamService, StorageService

Effect Library

  • ์—๋Ÿฌ: Data.TaggedError + environment-aware toString()
  • ๋น„๋™๊ธฐ: Effect.gen + Effect.tryPromise
  • ๊ฒ€์ฆ: Effect Schema (Schema.filter, Schema.transform)
  • Promise ๋ณ€ํ™˜: runSafePromise()

Path Aliases

@models โ†’ src/models    @lib โ†’ src/lib    @services โ†’ src/services
@errors โ†’ src/errors    @internal-types โ†’ src/types    @ โ†’ src

Code Style

TypeScript

  • any ํƒ€์ž… ์ ˆ๋Œ€ ๊ธˆ์ง€ โ€” unknown + type guards ๋˜๋Š” Effect Schema ์‚ฌ์šฉ
  • noExplicitAny: error (Biome), strict mode ํ™œ์„ฑํ™”
  • ํ•จ์ˆ˜ํ˜• ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์Šคํƒ€์ผ (Effect library)
  • ์ฝ”๋“œ ์ž‘์„ฑ ํ›„ pnpm lint ์‹คํ–‰

Error Handling

  • ์—๋Ÿฌ๋Š” ๋ฐ˜๋“œ์‹œ Data.TaggedError ์‚ฌ์šฉ (raw throw new Error() ๊ธˆ์ง€)
  • Effect ์ฃผ๋ณ€์— try-catch ๊ธˆ์ง€ โ€” Effect.catchTag/Effect.catchAll ์‚ฌ์šฉ
  • Promise ๋ณ€ํ™˜์€ ๋ฐ˜๋“œ์‹œ runSafePromise() ๊ฒฝ์œ 

Testing

์›์น™

  • ์ฝ”๋“œ๋ฅผ ๋จผ์ € ์ฝ๊ณ  ํ…Œ์ŠคํŠธ ์ž‘์„ฑ โ€” ์ฝ”๋“œ๊ฐ€ ์ง„์‹ค์˜ ์›์ฒœ
  • ์„ฑ๊ณต/์‹คํŒจ ๋ชจ๋‘ ํ…Œ์ŠคํŠธ โ€” happy path๋งŒ ํ…Œ์ŠคํŠธ ๊ธˆ์ง€
  • ๋ชจ๋“  ์กฐ๊ฑด ๋ถ„๊ธฐ, ๊ฒฝ๊ณ„๊ฐ’(null, empty, zero, min, max) ํ…Œ์ŠคํŠธ
  • ๋ฒ„๊ทธ ์ˆ˜์ • ์‹œ ๋ฐ˜๋“œ์‹œ ํšŒ๊ท€ ํ…Œ์ŠคํŠธ ์ถ”๊ฐ€
  • ๊ฒฐ์ •์ (deterministic) ํ…Œ์ŠคํŠธ๋งŒ ์ž‘์„ฑ โ€” sleep ๊ธฐ๋ฐ˜ ํƒ€์ด๋ฐ ์˜์กด ๊ธˆ์ง€

๊ฒ€์ฆ ํ•ญ๋ชฉ

  • ์ƒํƒœ ์ผ๊ด€์„ฑ, ๋ถ€์ž‘์šฉ, ๋ฉฑ๋“ฑ์„ฑ, ๋ฆฌ์†Œ์Šค ์ •๋ฆฌ
  • ์˜์กด์„ฑ ์‹คํŒจ ์‹œ๋ฎฌ๋ ˆ์ด์…˜ (๋„คํŠธ์›Œํฌ ์—๋Ÿฌ, ํƒ€์ž„์•„์›ƒ)
  • Effect ํŒŒ์ดํ”„๋ผ์ธ์„ ํ†ตํ•œ ์—๋Ÿฌ ์ „ํŒŒ

ํ…Œ์ŠคํŠธ ํŒจํ„ด

  • Unit: import {describe, expect, it} from 'vitest'
    • Schema ๊ฒ€์ฆ: Schema.decodeUnknownEither() / Schema.decodeUnknownSync()
    • ํ…Œ์ด๋ธ” ๊ธฐ๋ฐ˜: it.each() ํ™œ์šฉ
  • E2E: import {describe, expect, it} from '@effect/vitest'
    • it.effect() + Effect.gen(function* () { ... })
    • Layer ์ œ๊ณต: .pipe(Effect.provide(XxxLive))
    • ์—๋Ÿฌ ํ…Œ์ŠคํŠธ: Effect.either()
    • ํ…Œ์ŠคํŠธ ๋ ˆ์ด์–ด: test/lib/test-layers.ts

ํ…Œ์ŠคํŠธ ๋ช…๋ช…

  • ๋™์ž‘ ๊ธฐ๋ฐ˜: "should return empty string for null"
  • ์—ฃ์ง€ ์ผ€์ด์Šค: "should reject BMS_IMAGE without imageId"
  • ์‹คํŒจ ๋ชจ๋“œ: "should handle network timeout gracefully"

๊ธˆ์ง€ ์‚ฌํ•ญ

  • happy path๋งŒ ํ…Œ์ŠคํŠธ
  • ์—ฃ์ง€ ์ผ€์ด์Šค/์—๋Ÿฌ ๊ฒฝ๋กœ ์ƒ๋žต
  • ๋น„๊ฒฐ์ •์ (non-deterministic) ํ…Œ์ŠคํŠธ
  • ํ•˜๋‚˜์˜ ํ…Œ์ŠคํŠธ์— ์—ฌ๋Ÿฌ ๊ด€์‹ฌ์‚ฌ ๋ณ‘ํ•ฉ
  • ๋ผ์ธ ์ปค๋ฒ„๋ฆฌ์ง€๋งŒ ์˜์กด

์ƒ์„ธํ•œ ์ฝ”๋“œ ํŒจํ„ด๊ณผ ์•ˆํ‹ฐํŒจํ„ด์€ AGENTS.md ์ฐธ์กฐ.