@reopt-ai/brandapp-sdk 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +574 -0
- package/LICENSE +21 -0
- package/README.md +468 -0
- package/dist/ai/index.d.ts +314 -0
- package/dist/ai/index.js +7 -0
- package/dist/ai-provider/index.d.ts +196 -0
- package/dist/ai-provider/index.js +703 -0
- package/dist/auth/index.d.ts +76 -0
- package/dist/auth/index.js +40 -0
- package/dist/better-auth/client.d.ts +29 -0
- package/dist/better-auth/client.js +10 -0
- package/dist/better-auth/index.d.ts +82 -0
- package/dist/better-auth/index.js +145 -0
- package/dist/chunk-6FLYVNZI.js +32 -0
- package/dist/chunk-6KPKZ7ZB.js +49 -0
- package/dist/chunk-DI6QJPTQ.js +449 -0
- package/dist/chunk-E457LO5A.js +599 -0
- package/dist/chunk-F7BXBTZI.js +54 -0
- package/dist/chunk-J5Y2GSJF.js +443 -0
- package/dist/chunk-K3YVJE6E.js +96 -0
- package/dist/chunk-KU2LN5SE.js +350 -0
- package/dist/chunk-L4DHB36G.js +75 -0
- package/dist/chunk-PJZB4VP7.js +63 -0
- package/dist/chunk-REIKXSMY.js +7 -0
- package/dist/chunk-T2WXHAAC.js +54 -0
- package/dist/chunk-TUKIYH4Q.js +112 -0
- package/dist/chunk-WSEROZVO.js +81 -0
- package/dist/chunk-YRGLBM6V.js +157 -0
- package/dist/client-BkcO-0C2.d.ts +216 -0
- package/dist/client-CN5_tNOC.d.ts +147 -0
- package/dist/client-DttyeM_h.d.ts +102 -0
- package/dist/cms/index.d.ts +137 -0
- package/dist/cms/index.js +101 -0
- package/dist/config-CtxyJsDR.d.ts +397 -0
- package/dist/dev/index.d.ts +509 -0
- package/dist/dev/index.js +3071 -0
- package/dist/eav/coerce.d.ts +42 -0
- package/dist/eav/coerce.js +65 -0
- package/dist/eav/index.d.ts +214 -0
- package/dist/eav/index.js +147 -0
- package/dist/eav/migrate.d.ts +236 -0
- package/dist/eav/migrate.js +219 -0
- package/dist/eav/schema.d.ts +260 -0
- package/dist/eav/schema.js +656 -0
- package/dist/errors-5hd5ZR-M.d.ts +158 -0
- package/dist/feedback/index.d.ts +132 -0
- package/dist/feedback/index.js +5 -0
- package/dist/files/index.d.ts +54 -0
- package/dist/files/index.js +31 -0
- package/dist/index.d.ts +221 -0
- package/dist/index.js +84 -0
- package/dist/plans/index.d.ts +140 -0
- package/dist/plans/index.js +5 -0
- package/dist/push/index.d.ts +79 -0
- package/dist/push/index.js +5 -0
- package/dist/react/hooks.d.ts +376 -0
- package/dist/react/hooks.js +421 -0
- package/dist/terms/index.d.ts +79 -0
- package/dist/terms/index.js +5 -0
- package/dist/testing/index.d.ts +154 -0
- package/dist/testing/index.js +81 -0
- package/dist/typed-client-BxOVIiMU.d.ts +40 -0
- package/dist/types-6E3ZLL9X.d.ts +24 -0
- package/dist/types-DskYLVb8.d.ts +104 -0
- package/dist/types-ckmDDW3N.d.ts +129 -0
- package/dist/webhooks/index.d.ts +140 -0
- package/dist/webhooks/index.js +142 -0
- package/docs/api-reference.md +557 -0
- package/docs/cms.md +318 -0
- package/docs/dev-server.md +164 -0
- package/docs/environment.md +211 -0
- package/docs/errors.md +290 -0
- package/docs/files.md +272 -0
- package/docs/migration.md +315 -0
- package/docs/testing.md +163 -0
- package/package.json +173 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,574 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `@reopt-ai/brandapp-sdk` are documented here.
|
|
4
|
+
|
|
5
|
+
The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
|
6
|
+
This project adheres to [Semantic Versioning](https://semver.org/).
|
|
7
|
+
|
|
8
|
+
## [3.0.0] — 2026-06-26
|
|
9
|
+
|
|
10
|
+
보안 리뷰(BRANDAPP_SDK_REVIEW.md) 후속 — 인증·자격증명·웹훅 강화. 웹훅 검증 계약과
|
|
11
|
+
`verifySignature` 시그니처가 바뀌어 메이저 범프.
|
|
12
|
+
|
|
13
|
+
### BREAKING — 웹훅 검증을 실제 플랫폼 송신부에 정렬 (F-2)
|
|
14
|
+
|
|
15
|
+
- 과거 SDK 웹훅 계약(raw-body hex 서명 + JSON body 내 timestamp + `record.*`/`entity.*`
|
|
16
|
+
이벤트 타입)은 실제 플랫폼 송신부와 불일치해 **프로덕션 웹훅을 전량 401 거부**했다. 이제
|
|
17
|
+
송신부(`sha256=HMAC(secret, "{timestamp}.{body}")` + `x-reopt-timestamp` 헤더)와 일치한다.
|
|
18
|
+
- `verifySignature(body, signature, secret)` → **`verifySignature(timestamp, body, signature, secret)`**
|
|
19
|
+
(timestamp 우선, `sha256=` 접두 허용). preimage가 `"{timestamp}.{body}"`로 변경.
|
|
20
|
+
- `WebhookEventType`: `record.*`/`entity.*`/`subscription.changed`/`customer.created` →
|
|
21
|
+
**`contactCreated`/`contactUpdated`/`contactDeleted`/`workflowRunCompleted`/`workflowRunFailed`**.
|
|
22
|
+
- `WebhookPayload`: `{ id, type, brandappId, workspaceId, timestamp, data }` →
|
|
23
|
+
**`{ id, type, entityType, entityId, createdAt, data }`**.
|
|
24
|
+
- replay 보호는 이제 `x-reopt-timestamp` 헤더(서명에 포함되어 위조 불가)를 사용. timestamp
|
|
25
|
+
헤더 누락 시 401(fail-closed).
|
|
26
|
+
|
|
27
|
+
### Security — 자격증명 보호 (F-3)
|
|
28
|
+
|
|
29
|
+
- **브라우저에서 `clientSecret` 사용 차단** — `createReoptSDK()`/`createBrandappProvider()`가
|
|
30
|
+
브라우저 컨텍스트에서 `clientSecret`을 받으면 `CONFIG_BROWSER_SECRET`로 throw한다(장기 admin
|
|
31
|
+
자격의 클라이언트 번들 유출 방지). 클라이언트 측은 서버가 발급한 단기 토큰을 `{ token }`으로 전달.
|
|
32
|
+
- **token-only 설정 허용 (additive)** — `clientId`/`clientSecret`가 `token` 제공 시 선택사항이
|
|
33
|
+
되어, secret 없는 안전한 클라이언트 측 설정이 가능. 서버 측 기존 설정은 영향 없음.
|
|
34
|
+
- React hooks 문서 예제를 `NEXT_PUBLIC_*` secret 패턴에서 server-minted token 패턴으로 교정.
|
|
35
|
+
|
|
36
|
+
### Security — 로깅·dev 서버
|
|
37
|
+
|
|
38
|
+
- **debug `trace` redaction 확장 (F-6)** — `accessToken`/`refreshToken`/`idToken`/`clientSecret`
|
|
39
|
+
등 camelCase 토큰 키도 마스킹(이전엔 정확히 `token`/`secret`만). AI 사용량 카운트
|
|
40
|
+
(`inputTokens`/`maxTokens` 등)는 의도적으로 보존.
|
|
41
|
+
- **dev 서버 프로덕션 가드 (F-10)** — 인증 없는 인메모리 dev 서버는 `NODE_ENV=production`에서
|
|
42
|
+
시작을 거부한다(`REOPT_DEV_SERVER_ALLOW_PRODUCTION=1`로만 우회).
|
|
43
|
+
|
|
44
|
+
### Removed — deprecated 별칭 정리 (major 정합)
|
|
45
|
+
|
|
46
|
+
오래전 `@deprecated`로 표시됐고 내부 사용이 없는 별칭들을 제거(major 버전이 적정 타이밍).
|
|
47
|
+
이름만 정규형으로 바꾸면 된다.
|
|
48
|
+
|
|
49
|
+
- `ReoptAdapterConfig`, `ReoptEavConfig` → `ReoptSDKConfig`
|
|
50
|
+
- `ReoptAdapterError` → `ReoptSDKError`
|
|
51
|
+
|
|
52
|
+
> 서버 측(플랫폼 API) 동반 강화는 같은 리뷰의 F-1(인증 어댑터 크로스 테넌트 쓰기 차단),
|
|
53
|
+
> F-4(상수 시간 secret 비교), F-8(CMS published 강제), F-9(만료 없는 토큰 거부)로 적용됨 —
|
|
54
|
+
> SDK 외부(`apps/web`)라 이 CHANGELOG 범위 밖.
|
|
55
|
+
|
|
56
|
+
## [2.3.0] — 2026-06-18
|
|
57
|
+
|
|
58
|
+
### Added — AI 표면 정직화·discoverability·에러 통일
|
|
59
|
+
|
|
60
|
+
- **모델 메타데이터 풍부화** — `sdk.ai.models()`의 `ModelInfo`에 `displayName`,
|
|
61
|
+
`description`, `provider`, `modality`(`"chat" | "image"`), `isDefault`,
|
|
62
|
+
`contextWindow`, `maxOutputTokens`, `supportsVision`, `supportsTools`,
|
|
63
|
+
`creditsPerImage` 추가. "model 미지정 시 쓰이는 기본 모델"(`isDefault`)과 chat/image
|
|
64
|
+
구분(`modality`)을 사전에 알 수 있다(additive).
|
|
65
|
+
- **이미지 모델 discoverability** — `sdk.ai.models()`가 image 모델도 `modality: "image"`로
|
|
66
|
+
반환. 이미지 모델 허용/기본값은 BrandApp `defaultImageModel`/`allowedImageModels` 정책으로 제어.
|
|
67
|
+
- **`useAiAgents(sdk)` 훅** — 사용 가능한 커스텀 에이전트 목록(TanStack Query).
|
|
68
|
+
- **신규 에러 타입** — `ModelAccessError`(403 `MODEL_ACCESS_DENIED`),
|
|
69
|
+
`ModelNotFoundError`(404 `MODEL_NOT_FOUND`), `ContentFilterError`(422 `CONTENT_FILTER`)
|
|
70
|
+
- 가드 `isCreditLimitError` / `isModelAccessError`. AI 타입·에러는 패키지 root에서도
|
|
71
|
+
직접 import 가능(이전엔 `/ai` 서브패스 전용).
|
|
72
|
+
- **`finishReason`** — `CompletionResult` / `StreamDoneData`에 optional `finishReason`
|
|
73
|
+
추가. provider는 서버 보고값을 매핑(미보고 시 `stop`).
|
|
74
|
+
|
|
75
|
+
### Changed — 에러 통일·정직한 provider 계약 (동작 변화)
|
|
76
|
+
|
|
77
|
+
- **에러 형태 통일** — HTTP 상태 → typed 에러 매핑을 단일 출처(`mapHttpStatusToError`)로
|
|
78
|
+
통합. 비스트림 HTTP / SSE 스트리밍 / AI SDK provider가 동일한 코드·진단을 갖는 에러를
|
|
79
|
+
생성한다. **스트리밍 402/크레딧 소진이 이제 `CreditLimitError`(`.diagnostic` 포함)로**
|
|
80
|
+
표면화된다(이전엔 `STREAM_ERROR`로 뭉뚱그려짐).
|
|
81
|
+
- **provider 에러 = `APICallError`** — AI SDK provider는 bare `Error` 대신
|
|
82
|
+
`APICallError`를 던진다 → AI SDK 내장 재시도(`isRetryable`)가 동작하고, `error.data.code`
|
|
83
|
+
/ `error.data.diagnostic` / `error.cause`(`ReoptSDKError`)로 `sdk.ai.*`와 동일한 구조화
|
|
84
|
+
정보를 얻는다.
|
|
85
|
+
- **provider는 `ProviderV3` 준수** — registry/`customProvider`에 drop-in. 임베딩·음성·전사
|
|
86
|
+
모델은 `NoSuchModelError`로 정직하게 거부.
|
|
87
|
+
- **정직한 능력 보고** — provider 문서·JSDoc에서 "generateObject 등 모든 AI SDK 함수"
|
|
88
|
+
과대광고 제거. tool calling, 구조화 출력, 비전·파일 입력은 미지원이며 `warnings`로
|
|
89
|
+
알린다. user 메시지의 image/file part 드롭도 이제 경고로 노출(이전엔 silent).
|
|
90
|
+
- **스트리밍 cancel vs timeout 구분** — 외부 signal 취소는 `CANCELLED`, idle 타임아웃은
|
|
91
|
+
`TIMEOUT`(408)로 구분. SSE 경로에 `X-Request-Id` 전파(에러 `context.requestId`).
|
|
92
|
+
- **라이트 클라이언트 idle 타임아웃 기본값 30s → 60s** (provider와 일치).
|
|
93
|
+
- 이미지 provider `aspectRatio`를 `providerOptions.brandapp.aspectRatio`에서도 읽음
|
|
94
|
+
(문서 약속과 일치). 이미지 2차 hop(Blob fetch)에도 타임아웃 적용.
|
|
95
|
+
|
|
96
|
+
### Removed
|
|
97
|
+
|
|
98
|
+
- 죽은 상수 `DEFAULT_AI_MODEL`(`src/ai/constants.ts`, import 0건).
|
|
99
|
+
|
|
100
|
+
## [2.2.0] — 2026-06-18
|
|
101
|
+
|
|
102
|
+
### Changed — 신뢰성·성능·번들 하드닝 (리뷰 후속)
|
|
103
|
+
|
|
104
|
+
확장성·번들·성능 리뷰에서 확정된 핵심 결함을 일괄 개선. 모든 입력/출력 형태는 호환,
|
|
105
|
+
관찰 가능한 동작 변화는 아래에 명시.
|
|
106
|
+
|
|
107
|
+
- **AI 스트리밍 idle 타임아웃** — `sdk.ai.stream()` / `streamWithMetadata()`, AI SDK
|
|
108
|
+
provider(`doStream`)의 타임아웃을 wall-clock → **idle(무활동) 타임아웃**으로 통일.
|
|
109
|
+
`config.timeout`(AI 기본 30s)은 이제 "청크 간 최대 공백"을 의미 — 30초가 넘는 정상
|
|
110
|
+
생성이 스트림 도중 끊기던 문제, provider가 첫 토큰 후 stall 시 무한 hang하던 문제를
|
|
111
|
+
함께 해소. 공통 로직은 신규 `core/abort.ts`(`createManagedAbort`).
|
|
112
|
+
- **비멱등 재시도 차단** — POST/PATCH는 5xx·네트워크·timeout 시 기본적으로 **재시도하지
|
|
113
|
+
않음**(중복 레코드 생성·중복 크레딧 차감·중복 동의 방지). 429(rate limit)는 메서드와
|
|
114
|
+
무관하게 항상 재시도. 옵트인 `config.retryNonIdempotent: true`로 복원 가능. 변이
|
|
115
|
+
요청에는 `Idempotency-Key`(요청 id) 헤더를 부여해 서버측 dedup 연동 가능.
|
|
116
|
+
- **백오프 jitter + cap** — 지수 백오프에 full jitter(`[base/2, base]`)와 30s 상한 추가
|
|
117
|
+
(다중 워커 thundering herd 완화).
|
|
118
|
+
- **EAV `backfill` 배치 처리** — 레코드당 개별 PATCH → `bulkUpdate`(기본 100건/배치)
|
|
119
|
+
트랜잭션으로 묶어 대량 백필의 요청 수를 최대 ~100× 감소. 배치 실패 시 레코드별 개별
|
|
120
|
+
업데이트로 폴백해 `failed[]` 계약 유지. `BackfillOptions.batchSize`(기본 100, `1`은
|
|
121
|
+
레코드당 1요청)·`concurrency`(병렬 배치 flush). onProgress는 배치 flush 단위로 발생.
|
|
122
|
+
- **쿼리 길이 가드** — EAV/CMS의 GET 쿼리스트링이 한도(7,500자)를 넘으면 모호한 414
|
|
123
|
+
대신 `QUERY_TOO_LARGE` 진단 에러. 직렬화 로직은 신규 `core/query.ts`로 통합.
|
|
124
|
+
- **에러 `name` 일관화** — `AuthError`/`RateLimitError`/`ServerError` 및 신규
|
|
125
|
+
`CreditLimitError`(402)가 `error.name`에 구체 클래스명을 노출(로그 집계·Sentry 그룹핑이
|
|
126
|
+
401/429/500/402를 구분). `instanceof`·`.code`·`.status`는 종전과 동일.
|
|
127
|
+
- **`useAiStream` rAF 코알레싱** — 스트리밍 `text` 커밋을 프레임당 1회로 합쳐 빠른
|
|
128
|
+
모델에서의 과도한 리렌더 제거(`onChunk`는 청크마다 그대로 발생, 종료/에러/중단 시 최종
|
|
129
|
+
flush). 언마운트 시 진행 중 스트림 abort + 프레임 취소.
|
|
130
|
+
- **config 형식 검증** — `validateConfig`가 자격증명 공백 트림, `brandappId`의 URL
|
|
131
|
+
위험 문자(공백·`/`·`?`·`#`), `baseUrl`/`idBaseUrl` URL 파싱을 검사(`CONFIG_INVALID`).
|
|
132
|
+
- **번들 위생** — published tarball에서 소스맵 제외(`files: ["!dist/**/*.map"]`),
|
|
133
|
+
unpacked ~1.2MB → ~534KB. 메인 `.` 배럴의 도메인별 import 가이드 추가.
|
|
134
|
+
- **JSON Schema 변환** — 새 `EavDataType` 누락을 컴파일 에러로 잡는 exhaustiveness 가드,
|
|
135
|
+
`minLength/maxLength: 0` 보존, select/multiselect에 `type: "string"` 명시.
|
|
136
|
+
- **provider 헤더** — 호출 불변 헤더를 모델 생성 시 1회 고정.
|
|
137
|
+
|
|
138
|
+
호환성: 공개 API 시그니처·반환 형태 불변. 동작 변화(스트리밍 타임아웃 의미, 비멱등
|
|
139
|
+
재시도 게이트, backfill의 bulkUpdate 사용, onProgress 단위, 에러 `name`)는 위에 명시.
|
|
140
|
+
|
|
141
|
+
## [2.1.0] — 2026-05-20
|
|
142
|
+
|
|
143
|
+
### Added — PostGroup slug 기반 식별 + Dev MDX 시드
|
|
144
|
+
|
|
145
|
+
reopt-www 같은 마케팅 사이트가 `REOPT_*_GROUP_ID` env var 하드코딩 없이 `slug`로
|
|
146
|
+
그룹을 참조하고, MDX 파일을 로컬에서 미리볼 수 있게 하는 변경.
|
|
147
|
+
|
|
148
|
+
- **`PostGroup.slug`** 필드 추가 — brand 범위 안에서 안정적 식별자. nullable(legacy row 호환).
|
|
149
|
+
- `sdk.cms.posts.list({ groupSlug })` — 신규 필터, 기존 `groupId`와 공존
|
|
150
|
+
- `sdk.cms.posts.getBySlug(slug, { groupSlug })` — slug 옵션 추가
|
|
151
|
+
- `sdk.cms.postGroups.getBySlug(slug)` — 신규 단건 조회
|
|
152
|
+
- `sdk.cms.tags.list({ groupSlug })` — 신규 필터
|
|
153
|
+
- `PostGroup.slug: string | null` 응답 필드 추가
|
|
154
|
+
- **Dev server CMS seeder 전면 개편** (`@reopt-ai/brandapp-sdk/dev`)
|
|
155
|
+
- `dev.seedPostGroups(items)` — `(brandappId, slug)` 멱등 upsert
|
|
156
|
+
- `dev.seedPosts(items)` — `(groupSlug, slug)` 멱등 upsert. EditorSpec 직접 받음.
|
|
157
|
+
- `dev.seedAll({ postGroups, posts, entities, terms })` — 한 번에 모든 데이터 시드
|
|
158
|
+
- `DevPost` 타입을 production `Post`와 동등하게 확장 — `publishedAt`,
|
|
159
|
+
`coverImage`, `author`, `seo`, `tags: Tag[]`, `contentRich: EditorSpec | null`
|
|
160
|
+
- dev server CMS 응답이 production SDK Post/PostGroup 형식과 100% 호환됨
|
|
161
|
+
(consumer는 dev/prod 분기 불필요)
|
|
162
|
+
- **`markdownToEditorSpec`** 신규 helper (`@reopt-ai/brandapp-sdk/dev`)
|
|
163
|
+
- `@reopt-ai/opt-editor`의 `markdownToSpec`을 dynamic import로 호출
|
|
164
|
+
- opt-editor는 SDK의 optional peer dependency — dev/test에만 설치 필요
|
|
165
|
+
- production 번들에는 포함되지 않음
|
|
166
|
+
- **`createTestSDK`** 옵션 확장 — `postGroups`, `posts`, `terms`, `seedAll` 지원
|
|
167
|
+
- **Hono CMS 라우트** — `GET /post-groups/by-slug/:slug` 신규, 기존 라우트는 `groupSlug` 쿼리 옵션 추가
|
|
168
|
+
- **Prisma migration** — `PostGroup.slug VARCHAR(255) NULL` + `@@unique([brandId, slug])`
|
|
169
|
+
- 시드 자동 backfill: reopt-www brand 7개 + angski brand 3개 그룹에 alias→slug 매핑
|
|
170
|
+
|
|
171
|
+
호환성: 기존 `groupId` 기반 API는 모두 그대로 동작. consumer 마이그레이션은 [`docs/cms.md`](./docs/cms.md#slug-기반-식별-21) 참고.
|
|
172
|
+
|
|
173
|
+
### Added — Terms 글로벌화 (jurisdiction + locale)
|
|
174
|
+
|
|
175
|
+
reopt 백엔드가 brandapp 약관을 법적 관할권(jurisdiction)과 언어 로케일(locale) 두 축으로 관리한다. SDK도 이를 그대로 표현하도록 확장됐다. 기존 호출자는 변경 없이 동작.
|
|
176
|
+
|
|
177
|
+
- `sdk.terms.list()` 시그니처 확장 — 이제 `accessToken` 문자열 또는 옵션 객체를 받는다:
|
|
178
|
+
|
|
179
|
+
```ts
|
|
180
|
+
// 기존 (그대로 동작)
|
|
181
|
+
await sdk.terms.list();
|
|
182
|
+
await sdk.terms.list(accessToken);
|
|
183
|
+
|
|
184
|
+
// 신규 — 명시적 country / locale / jurisdiction 지정 가능
|
|
185
|
+
await sdk.terms.list({ country: "DE", locale: "de-DE" });
|
|
186
|
+
await sdk.terms.list({ jurisdiction: "EU", accessToken });
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
미지정 시 백엔드가 `x-vercel-ip-country` + `Accept-Language` 헤더에서 자동 추정한다.
|
|
190
|
+
|
|
191
|
+
- `sdk.terms.listWithMeta()` 신규 — 약관 목록과 함께 매칭 메타데이터를 반환:
|
|
192
|
+
|
|
193
|
+
```ts
|
|
194
|
+
const { jurisdiction, jurisdictionSource, country, locale, terms } =
|
|
195
|
+
await sdk.terms.listWithMeta({ country: "DE" });
|
|
196
|
+
// jurisdiction: "EU", jurisdictionSource: "explicit", country: "DE", locale: null
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
가입 화면에 "이 약관은 EU 기준으로 제공됩니다" 같은 안내를 표시할 때 사용.
|
|
200
|
+
|
|
201
|
+
- `sdk.terms.consent()`의 `CreateConsentsRequest`에 법적 증거 필드 추가:
|
|
202
|
+
```ts
|
|
203
|
+
await sdk.terms.consent(
|
|
204
|
+
{
|
|
205
|
+
consents: [...],
|
|
206
|
+
country: "DE", // ISO 3166-1 alpha-2 (법적 증거)
|
|
207
|
+
locale: "de-DE", // BCP 47 (법적 증거)
|
|
208
|
+
userAgent: navigator.userAgent,
|
|
209
|
+
},
|
|
210
|
+
accessToken,
|
|
211
|
+
);
|
|
212
|
+
```
|
|
213
|
+
미제공 시 백엔드가 요청 헤더에서 추정한다. 서버는 동의 row에 `consentCountry`, `consentLocale`, `userAgent`, `contentHash`(SHA-256 of `content`)를 함께 저장해 GDPR 등 법령 요구의 "informed consent" 증거를 보존한다.
|
|
214
|
+
|
|
215
|
+
### Types
|
|
216
|
+
|
|
217
|
+
- `TermsJurisdiction` 신규 — `"global" | "KR" | "US" | "EU" | "GB" | "JP" | "CN" | "BR" | "CA" | "AU"`
|
|
218
|
+
- `TermsItem.jurisdiction` 신규 필드
|
|
219
|
+
- `TermsVersion.locale` 신규 필드 (BCP 47)
|
|
220
|
+
- `ConsentRecord`에 `consentCountry`, `consentLocale` 신규 필드
|
|
221
|
+
- `TermsListResponse` 신규 — `listWithMeta()` 반환 타입
|
|
222
|
+
- `ListTermsOptions` 신규 — `list()` / `listWithMeta()` 인자 타입
|
|
223
|
+
|
|
224
|
+
## [2.0.0] — 2026-05-14
|
|
225
|
+
|
|
226
|
+
### Breaking — 환경변수 의미 기반 재명명
|
|
227
|
+
|
|
228
|
+
consumer 자격 / 플랫폼 호스트 / SDK 동작 제어를 접두사로 구분.
|
|
229
|
+
deprecation alias 없음 — `.env`를 일괄 교체해야 한다.
|
|
230
|
+
|
|
231
|
+
| 이전 | 신규 |
|
|
232
|
+
| --------------------------------- | ------------------------------------ |
|
|
233
|
+
| `REOPT_CLIENT_ID` | `BRANDAPP_CLIENT_ID` |
|
|
234
|
+
| `REOPT_CLIENT_SECRET` | `BRANDAPP_CLIENT_SECRET` |
|
|
235
|
+
| `REOPT_BRANDAPP_ID` | `BRANDAPP_ID` |
|
|
236
|
+
| `REOPT_WEBHOOK_SECRET` | `BRANDAPP_WEBHOOK_SECRET` |
|
|
237
|
+
| `REOPT_SDK_DEBUG` | `BRANDAPP_SDK_DEBUG` |
|
|
238
|
+
| `REOPT_SDK_LOG_FORMAT` | `BRANDAPP_SDK_LOG_FORMAT` |
|
|
239
|
+
| `DEBUG=*reopt*` | `DEBUG=*brandapp*` |
|
|
240
|
+
| `NEXT_PUBLIC_REOPT_CLIENT_ID` | `NEXT_PUBLIC_BRANDAPP_CLIENT_ID` |
|
|
241
|
+
| `NEXT_PUBLIC_REOPT_CLIENT_SECRET` | `NEXT_PUBLIC_BRANDAPP_CLIENT_SECRET` |
|
|
242
|
+
| `NEXT_PUBLIC_REOPT_BRANDAPP_ID` | `NEXT_PUBLIC_BRANDAPP_ID` |
|
|
243
|
+
| `NEXT_PUBLIC_EAV_HASH` | `NEXT_PUBLIC_BRANDAPP_EAV_HASH` |
|
|
244
|
+
|
|
245
|
+
플랫폼 호스트 변수 `REOPT_BASE_URL`과 `REOPT_ID_BASE_URL`은 의미상 정확하므로
|
|
246
|
+
그대로 유지. 상세는 [docs/environment.md](./docs/environment.md).
|
|
247
|
+
|
|
248
|
+
### Docs
|
|
249
|
+
|
|
250
|
+
- 신규: `docs/environment.md` — 환경변수 단일 마스터 reference (필수/선택, 우선순위
|
|
251
|
+
시나리오, 브라우저/Next.js, 트러블슈팅, CI/CD).
|
|
252
|
+
- README `## Environment Variables` 섹션 추가, Configuration 코드 블록 보강
|
|
253
|
+
(`token`, `idBaseUrl`, `debug` 누락 보완), Built-in URLs 표 production host fix
|
|
254
|
+
(`www.reopt.ai` → `brand.reopt.ai`).
|
|
255
|
+
|
|
256
|
+
## [1.12.0] — 2026-05-13
|
|
257
|
+
|
|
258
|
+
RFC-0006 Phase D-2b. SDK가 short-lived service token (`POST /token/mint`로
|
|
259
|
+
발급되는 HS256 JWT)을 그대로 받아서 `Authorization: Bearer`로 사용하도록
|
|
260
|
+
config 옵션을 추가했다.
|
|
261
|
+
|
|
262
|
+
### Added
|
|
263
|
+
|
|
264
|
+
- **`ReoptSDKConfig.token`** — 선택 옵션. 값이 설정되면 `BaseHttpClient`가
|
|
265
|
+
Basic Auth 대신 `Bearer <token>`을 default 헤더로 사용한다.
|
|
266
|
+
`clientId`/`clientSecret`은 여전히 필수 (validateConfig 변경 없음) —
|
|
267
|
+
토큰 만료 시 재발급 또는 mint flow에 그대로 쓰임.
|
|
268
|
+
- 기존 `FetchOptions.bearerToken` per-call override는 config 토큰을 우선
|
|
269
|
+
한다 — `/external-auth` 같은 사용자 OAuth 흐름은 그대로 동작.
|
|
270
|
+
|
|
271
|
+
### Changed
|
|
272
|
+
|
|
273
|
+
- 없음. validateConfig 시그니처 + 기존 API 표면 그대로.
|
|
274
|
+
|
|
275
|
+
## [1.11.0] — 2026-05-13
|
|
276
|
+
|
|
277
|
+
RFC-0005 Phase A.5 + C 발표분. EAV 마이그레이션 atomicity + 런타임 schema 드리프트
|
|
278
|
+
감지 표면을 SDK에 추가했다. 기존 API 표면 변경 없음 (additive only).
|
|
279
|
+
|
|
280
|
+
### Added
|
|
281
|
+
|
|
282
|
+
- **`runMigrationCollecting(eav, migration, opts)`** (`@reopt-ai/brandapp-sdk/eav/migrate`) —
|
|
283
|
+
마이그레이션의 `up()` 함수에서 호출된 `schema.*` 연산을 즉시 실행하는 대신
|
|
284
|
+
배열로 수집해 반환한다. CLI는 이 결과를 서버의 새 `POST /v1/brandapp/{id}/migrations/apply`
|
|
285
|
+
엔드포인트로 전송해 단일 `prisma.$transaction`으로 atomic하게 적용한다.
|
|
286
|
+
부분 실패 시 audit row가 절대 기록되지 않는 것이 보장된다.
|
|
287
|
+
- **`MigrationOperation`** 타입 + `CollectMigrationOptions` / `CollectMigrationResult` —
|
|
288
|
+
서버 batch payload와 동일한 wire 포맷.
|
|
289
|
+
- **`verifyEavSchema({ client, localHash })`** (`@reopt-ai/brandapp-sdk/eav`) —
|
|
290
|
+
배포된 번들과 서버 EAV schema 사이의 드리프트를 `/api/health`에서 감지한다.
|
|
291
|
+
서버의 새 `GET /v1/brandapp/{id}/eav/schema-hash`를 호출해 `localHash`와 비교.
|
|
292
|
+
- **`computeEavSchemaHash` / `canonicalizeEavSchemas` / `hashCanonicalString`** —
|
|
293
|
+
서버와 동일한 canonical-JSON 알고리즘으로 schema fingerprint(SHA-256)를 계산한다.
|
|
294
|
+
빌드 시 `eav.schema.ts`에서 hash를 만들어 `NEXT_PUBLIC_BRANDAPP_EAV_HASH`로 embed하는 패턴 권장.
|
|
295
|
+
- **`client.schemaHash()`** — EAV client에 추가된 메서드. `/schema-hash` 응답을
|
|
296
|
+
`{ hash, schemaCount, fieldCount, generatedAt }` 형태로 반환.
|
|
297
|
+
|
|
298
|
+
### Changed
|
|
299
|
+
|
|
300
|
+
- 없음 — Phase A.5에서 기존 `runMigration`은 그대로 유지된다 (legacy 경로).
|
|
301
|
+
새 atomic 흐름을 쓰려면 `runMigrationCollecting`을 호출하라.
|
|
302
|
+
|
|
303
|
+
## [1.10.0] — 2026-05-12
|
|
304
|
+
|
|
305
|
+
reopt 플랫폼의 brandapp API host가 `brand.reopt.ai`로 분리됐다. Better Auth handler(`/api/auth/*`)는 `id.reopt.ai`에만 마운트되어 있다. 그동안 SDK production default(`https://www.reopt.ai`)가 외부 marketing 사이트(별도 `reopt-www` 프로젝트)로 향하면서 `/api/v1/brandapp/*` 호출이 404를 받고, `getUserInfo()`/`createReoptOAuth()`도 라우트가 없는 호스트를 쳤다. 이번 변경으로 SDK가 두 host를 정확히 분리해 호출한다.
|
|
306
|
+
|
|
307
|
+
### Changed (breaking-ish)
|
|
308
|
+
|
|
309
|
+
- **`REOPT_BASE_URLS.production`**: `https://www.reopt.ai` → **`https://brand.reopt.ai`**.
|
|
310
|
+
- 기존에 `baseUrl`을 명시하지 않고 SDK를 쓰던 prod consumer는 자동으로 새 host로 이동.
|
|
311
|
+
- `baseUrl: "https://www.reopt.ai"`로 명시했던 consumer는 그 값이 외부 marketing 호스트를 가리켰던 것이므로 마찬가지로 `brand.reopt.ai` (또는 own apps/web alias)로 교체해야 한다.
|
|
312
|
+
|
|
313
|
+
### Changed
|
|
314
|
+
|
|
315
|
+
- **`sdk.auth.getUserInfo(token)`** — 이제 `id.<host>` 서버의 `/api/auth/oauth2/userinfo`를 호출한다. 이전에는 `baseUrl/api/auth/oauth2/userinfo`를 호출했고, `baseUrl`이 `www.reopt.ai`인 prod에서는 라우트 부재로 실패했다.
|
|
316
|
+
- **`createReoptOAuth({...})`의 `discoveryUrl`** — `${idBaseUrl}/api/auth/.well-known/openid-configuration`으로 변경. Better Auth OIDC discovery가 id 서버에서 응답한다.
|
|
317
|
+
|
|
318
|
+
이전에 `baseUrl: "https://id.reopt.ai"`로 명시해 우회하던 consumer는 자동 derive로 결과가 같다 (`hostname`이 이미 `id.`로 시작하면 그대로 사용). 자체 reopt 인스턴스를 운영해 web/auth가 단일 호스트인 경우에는 새 `idBaseUrl` 옵션을 명시하라.
|
|
319
|
+
|
|
320
|
+
### Added
|
|
321
|
+
|
|
322
|
+
- **`ReoptSDKConfig.idBaseUrl`** — id (auth) 서버 URL을 명시 override. 미설정 시 `baseUrl` / `isProduction` / `NODE_ENV`로부터 derive.
|
|
323
|
+
- **`REOPT_ID_BASE_URLS`** export — `production: https://id.reopt.ai`, `development: https://id.reopt.de:3443`.
|
|
324
|
+
- **`resolveIdBaseUrl(config)`** / **`deriveIdFromBaseUrl(baseUrl)`** export — id URL 해석 헬퍼.
|
|
325
|
+
- **`BaseHttpClient(config, pathPrefix, { useIdServer: true })`** — 옵션 인자로 id 서버 라우팅 활성화.
|
|
326
|
+
|
|
327
|
+
## [1.9.0] — 2026-05-10
|
|
328
|
+
|
|
329
|
+
EAV 에러 분기를 ergonomic하게 — 1:1 메타 충돌, authUser 미등록, plan 한도 초과를 narrowed 클래스로 직접 잡을 수 있다. 모두 기존 부모 클래스(`ConflictError` / `ReoptSDKError`)를 extend하므로 1.8.x에서 작성한 `instanceof ConflictError` 등 분기는 그대로 유지된다 — non-breaking minor.
|
|
330
|
+
|
|
331
|
+
### Added
|
|
332
|
+
|
|
333
|
+
- **EAV 전용 에러 클래스 4종** (`@reopt-ai/brandapp-sdk` 및 `@reopt-ai/brandapp-sdk/eav` 양쪽에서 export):
|
|
334
|
+
- `AuthUserRecordExistsError` (409, `AUTH_USER_RECORD_EXISTS`) extends `ConflictError` — 1:1 메타 entity에 같은 user의 record가 이미 있을 때. 자동 upsert 전환 분기에 사용.
|
|
335
|
+
- `DuplicateAuthUserError` (409, `DUPLICATE_AUTH_USER`) extends `ConflictError` — bulk create 입력에 같은 authUserId가 중복.
|
|
336
|
+
- `AuthUserNotFoundError` (400/422, `AUTH_USER_NOT_FOUND`) — 참조한 brandappAuthUser가 이 brandapp에 없음. 호출 경로에 따라 status가 다름 (단발 검증은 422, brandapp linkedTo의 createRecord에서는 400).
|
|
337
|
+
- `LimitExceededError` (422, `LIMIT_EXCEEDED_*`) — entity/attribute/record 한도 초과. `code` 필드로 어느 자원이 초과됐는지 분기 (`LIMIT_EXCEEDED_ENTITIES` / `_ATTRIBUTES` / `_RECORDS`).
|
|
338
|
+
- **추가 EAV 에러 코드** — 전용 클래스 없이 일반 `NotFoundError`/`BadRequestError`/`ConflictError` + `e.code`로 분기:
|
|
339
|
+
- `ENTITY_NOT_FOUND` / `ATTRIBUTE_NOT_FOUND` / `RECORD_NOT_FOUND` / `USER_NOT_FOUND` (404)
|
|
340
|
+
- `RECORDS_NOT_FOUND` (400, bulkUpdate에서 일부 record id가 entity에 없음)
|
|
341
|
+
- `DUPLICATE_RECORD_ID` (409, bulkUpdate(brandappAuthUser) 입력에 중복 id)
|
|
342
|
+
- `AUTH_USER_ID_REQUIRED` (400, `linkedTo='brandappAuthUser'` entity 호출에 authUserId 누락)
|
|
343
|
+
|
|
344
|
+
### Changed
|
|
345
|
+
|
|
346
|
+
- 백엔드(`apps/web/server/hono/routes/brandapp-eav*`)가 EAV 에러 응답에 의미 있는 `code`를 부여하도록 정리. 1.8.x까지는 다수 422/409 응답이 `REQUEST_ERROR` 단일 코드였지만 1.9부터는 위에 나열된 세분화된 코드를 받는다. SDK는 status별로 적절한 클래스에 자동 매핑하면서 `code` 필드를 그대로 노출하므로 사용자 코드는 `e.code === 'LIMIT_EXCEEDED_RECORDS'` 같은 분기를 바로 쓸 수 있다.
|
|
347
|
+
- EAV 백엔드의 JSONB merge가 PostgreSQL `||` 연산자로 atomic하게 변경됐다 (lost update 차단). SDK 사용자에게 직접 영향 없으나, 동시에 같은 record / authUser에 다른 키로 update를 보내던 경우 patch가 사라지던 문제가 제거됨.
|
|
348
|
+
- `listAuthUserCandidateRecords` 백엔드가 `customData ?| ARRAY[...]::text[]` push-down으로 변경됨. brandappAuthUser linkedTo entity의 list/count 응답시간이 user 수가 많은 brandapp에서 큰 폭으로 개선.
|
|
349
|
+
|
|
350
|
+
### Migration notes
|
|
351
|
+
|
|
352
|
+
- 1.8.x 코드는 변경 없이 동작. 새 클래스는 모두 기존 부모 클래스를 extend하므로 `instanceof ConflictError` / `BadRequestError` 검사가 새 인스턴스에도 그대로 true.
|
|
353
|
+
- 더 narrow한 분기(자동 upsert 전환, plan 업그레이드 prompt 등)를 원하면 [`docs/errors.md`](./docs/errors.md)의 _EAV-specific branches_ 섹션 참고.
|
|
354
|
+
|
|
355
|
+
## [1.8.0] — 2026-05-07
|
|
356
|
+
|
|
357
|
+
외부 마케팅 사이트(현재 `apps/www`)를 SDK만으로 운영할 수 있도록 CMS read 백엔드, SEO/Sitemap/RSS 헬퍼, 세션 인식, 약관 본문 EditorSpec 전환을 묶었다. SDK는 여전히 headless — UI 컴포넌트는 추가하지 않는다.
|
|
358
|
+
|
|
359
|
+
> ⚠️ **BREAKING (semver 안내)**: CMS의 write 표면(`cms.posts.{create,update,delete}`,
|
|
360
|
+
> `cms.postGroups.{create,update,delete}` + 동일 이름의 React 훅과 입력 타입)이
|
|
361
|
+
> 제거됐다. 1.7.x에서도 production 백엔드는 해당 endpoint를 노출하지 않았고
|
|
362
|
+
> dev 서버에서만 동작했기 때문에 사실상 dead surface였으며, 알려진 외부 npm
|
|
363
|
+
> 소비자가 없어 minor bump로 처리한다. cms를 호출하는 reopt-ai 내부 패키지(
|
|
364
|
+
> `apps/brandapp-playground` 등)는 본 릴리즈에 함께 정렬됐다. 외부 소비자가
|
|
365
|
+
> write 호출에 의존하고 있다면 [`docs/migration.md`](./docs/migration.md)의
|
|
366
|
+
> 1.7 → 1.8 가이드를 따라 read-only로 전환하거나 1.7.x에 핀 고정.
|
|
367
|
+
|
|
368
|
+
### Added
|
|
369
|
+
|
|
370
|
+
- **`cms.posts.getBySlug(slug, opts?: { groupId? })`** — slug 기반 포스트 단건 조회. 블로그 URL 라우트에서 id 매핑 없이 사용.
|
|
371
|
+
- **`cms.tags.list({ groupId? })`** — 브랜드 범위에서 사용된 태그 + 사용 건수.
|
|
372
|
+
- **`EditorSpec` 타입 export (`@reopt-ai/brandapp-sdk/cms`)** — `@reopt-ai/opt-editor`와 구조적으로 호환되는 minimal 정의. opt-editor에 직접 의존하지 않으므로 GitHub Packages 인증을 추가로 요구하지 않는다.
|
|
373
|
+
- **`Post.seo` 필드** — `metaTitle / metaDescription / metaKeywords`. 외부 사이트가 SEO 메타데이터를 한 호출에서 받는다.
|
|
374
|
+
- **CMS 헬퍼** (`toMetadata`, `toSitemapItems`, `toRssFeed`) — Next.js `Metadata`, `app/sitemap.ts`, RSS 2.0 XML 출력으로 한 줄 변환. 모두 순수 함수, Next.js/React 의존 없음.
|
|
375
|
+
- **Files 헬퍼** (`optimizeUrl`, `createImageLoader`, `REOPT_IMAGE_REMOTE_PATTERNS`) — Next.js `<Image>` 결합 패턴. Vercel Blob 호스트를 `next.config.ts` `remotePatterns`에 자동 등록하기 위한 export.
|
|
376
|
+
- **`auth.getSessionFromCookies(cookieHeader, opts)` / `auth.verifySession(request, opts)`** — `.reopt.ai` 서브도메인 쿠키로 reopt 사용자 세션을 외부 사이트에서 인식. apps/id의 Better Auth `/api/auth/get-session`에 위임 검증. Edge runtime / Node 양쪽 호환.
|
|
377
|
+
- **`TermsVersion.contentRich: EditorSpec | null`** — 약관 본문을 opt-editor `StaticRenderer`로 그대로 렌더링 가능.
|
|
378
|
+
- **React 훅** — `usePostBySlug(sdk, slug, opts?)`, `useCmsTags(sdk, query?)`로 신규 cms 표면을 TanStack Query에서도 일관되게 사용.
|
|
379
|
+
|
|
380
|
+
### Changed
|
|
381
|
+
|
|
382
|
+
- **`PostDetail.document.contentRich`**: `unknown` → `EditorSpec`. 외부 사용자가 cast 없이 opt-editor에 넘길 수 있다.
|
|
383
|
+
- 백엔드 신규: `/api/v1/brandapp/:brandappId/cms/*` (read-only) 라우트가 마운트됨. 1.7.x까지는 SDK `cms.*`가 dev 서버에서만 동작했지만 이제 production 백엔드에서도 동작한다. Brand 스코프 격리: `workspaceId + Brandapp.brandId → PostGroup.brandId`.
|
|
384
|
+
- Dev 서버(`@reopt-ai/brandapp-sdk/dev`)의 cms mock에 `/posts/by-slug/:slug`, `/tags`, `slug/tags` 필드, 약관 응답의 `contentRich` paragraph wrapper가 추가됨.
|
|
385
|
+
|
|
386
|
+
### Removed
|
|
387
|
+
|
|
388
|
+
- **CMS write surface** (`cms.posts.{create,update,delete}`, `cms.postGroups.{create,update,delete}`, 그리고 React 훅 `useCreatePost / useUpdatePost / useDeletePost`)이 SDK에서 제거됨. write는 reopt Studio가 담당하며 외부 SDK 소비자가 호출할 필요가 없다. 1.7.x에서도 production 백엔드에 해당 endpoint는 없었고 dev 서버에서만 동작했기 때문에 사실상 dead surface였다. `CreatePostInput / UpdatePostInput / CreatePostGroupInput / UpdatePostGroupInput` 타입도 함께 제거.
|
|
389
|
+
|
|
390
|
+
### Migration notes
|
|
391
|
+
|
|
392
|
+
- 기존 `TermsVersion.content`(plain text)는 schema 마이그레이션이 paragraph 1개짜리 EditorSpec으로 자동 변환해 `contentRich`에 채운다. `content` 필드는 검색/법적 보존용으로 한동안 유지.
|
|
393
|
+
- 1.7.x 호출 코드는 그대로 동작 — 브레이킹 변경 없음.
|
|
394
|
+
|
|
395
|
+
## [1.7.0] — 2026-05-05
|
|
396
|
+
|
|
397
|
+
### Added
|
|
398
|
+
|
|
399
|
+
- `EavSchemaLinkedTo` type and `CreateEntityInput.linkedTo?` option. SDK
|
|
400
|
+
consumers can opt into the BrandappAuthUser 1:1 metadata host
|
|
401
|
+
(`'brandappAuthUser'`) in addition to the default free-form table
|
|
402
|
+
(`'brandapp'`). `EavEntity` responses now include the `linkedTo` field.
|
|
403
|
+
- Dev server (`@reopt-ai/brandapp-sdk/dev`) mirrors the BrandappAuthUser
|
|
404
|
+
branch: 1:1 enforcement with `409` on duplicates and `422` when the host
|
|
405
|
+
BrandappAuthUser is missing. `record.id` deterministically matches
|
|
406
|
+
`authUserId` for these entities.
|
|
407
|
+
|
|
408
|
+
### Changed
|
|
409
|
+
|
|
410
|
+
- The brandapp Hono backend's `entities.create` accepts the new `linkedTo`
|
|
411
|
+
body field and validates the host BrandappAuthUser exists before any
|
|
412
|
+
record write. Existing 1.6.x callers behave identically because
|
|
413
|
+
`linkedTo` defaults to `'brandapp'`.
|
|
414
|
+
|
|
415
|
+
## [1.6.1] — 2026-04-24
|
|
416
|
+
|
|
417
|
+
Polish release following the 1.6.0 production-hardening review. No breaking
|
|
418
|
+
changes — all existing consumer code works unchanged.
|
|
419
|
+
|
|
420
|
+
### Added
|
|
421
|
+
|
|
422
|
+
- React hooks: `useUpsertRecord`, `useBulkCreateRecords`,
|
|
423
|
+
`useBulkUpdateRecords`, `useBulkDeleteRecords`, `useDeleteRecordsWhere`.
|
|
424
|
+
Mutation coverage now matches the underlying `sdk.eav.records.*` surface.
|
|
425
|
+
- `UploadOptions.signal` and `UploadOptions.timeout` — `sdk.files.upload()`
|
|
426
|
+
now accepts a per-call `AbortSignal` and timeout override, matching the
|
|
427
|
+
`FetchOptions` pattern used elsewhere.
|
|
428
|
+
|
|
429
|
+
### Fixed
|
|
430
|
+
|
|
431
|
+
- **`SDK_VERSION` was pinned to `"1.4.2"` in source** while the package
|
|
432
|
+
shipped as 1.6.0, so the `X-SDK-Version` header and AI provider telemetry
|
|
433
|
+
reported a stale version. The constant is now injected at build time from
|
|
434
|
+
`package.json` via tsup/vitest `define`, so it can never drift again.
|
|
435
|
+
- **`ai.stream()` and `ai.streamWithMetadata()` leaked abort listeners**
|
|
436
|
+
on the caller-supplied `AbortSignal`. The listener was registered with
|
|
437
|
+
`{ once: true }` but never removed when the stream ended normally,
|
|
438
|
+
pinning `AbortController` references until the signal itself was GC'd.
|
|
439
|
+
`fetchSSE()` now returns a `cleanup()` callback the stream consumers
|
|
440
|
+
invoke on end/abort/error.
|
|
441
|
+
- **`AuthError` dropped request context**. Every other HTTP error class
|
|
442
|
+
(`BadRequest`, `Forbidden`, `NotFound`, `Conflict`, `Validation`) prefixes
|
|
443
|
+
its message with `[METHOD url]`; 401 responses previously threw a
|
|
444
|
+
context-less `AuthError`. `AuthError` now accepts and forwards `ctx`.
|
|
445
|
+
|
|
446
|
+
### Changed
|
|
447
|
+
|
|
448
|
+
- `BrandappProviderConfig.isProduction` JSDoc corrected to match actual
|
|
449
|
+
behavior (auto-detects from `NODE_ENV`, not "defaults to true").
|
|
450
|
+
- `BrandappImageModel.maxImagesPerCall` behavior clarified via comment —
|
|
451
|
+
AI SDK honors the `1` limit by calling `doGenerate({ n: 1 })` repeatedly,
|
|
452
|
+
and the internal `Promise.all(n)` fan-out is reserved for direct callers
|
|
453
|
+
who pass `n > 1` without going through the AI SDK layer.
|
|
454
|
+
|
|
455
|
+
### Removed
|
|
456
|
+
|
|
457
|
+
- `ReoptSDKConfig.devMode` and the `DevModeOptions` type. The field was
|
|
458
|
+
declared but never consumed by `createReoptSDK`; local dev always goes
|
|
459
|
+
through `createDevServer` + `baseUrl` override (documented path).
|
|
460
|
+
|
|
461
|
+
### Docs
|
|
462
|
+
|
|
463
|
+
- `docs/api-reference.md`: added the missing Auth Client section
|
|
464
|
+
(`sdk.auth.linkCurrentUser`, `withdrawCurrentUser`, `getUserInfo`) and
|
|
465
|
+
the `/auth` entry-point row.
|
|
466
|
+
|
|
467
|
+
### Tests
|
|
468
|
+
|
|
469
|
+
- 365 tests still passing; no new regressions surfaced during the cleanup.
|
|
470
|
+
|
|
471
|
+
## [1.6.0] — 2026-04-17
|
|
472
|
+
|
|
473
|
+
Production-hardening release. See [docs/migration.md](./docs/migration.md) for
|
|
474
|
+
upgrade notes — a small number of existing consumer patterns need adjustment.
|
|
475
|
+
|
|
476
|
+
### Added
|
|
477
|
+
|
|
478
|
+
- New dedicated error classes: `BadRequestError` (400), `ForbiddenError` (403),
|
|
479
|
+
`NotFoundError` (404), `ConflictError` (409). All extend `ReoptSDKError` and
|
|
480
|
+
include diagnostic hints. Existing `instanceof ReoptSDKError` and
|
|
481
|
+
`isReoptSDKError()` checks keep working.
|
|
482
|
+
- `FetchOptions` type — `BaseHttpClient.fetch()` now accepts an optional
|
|
483
|
+
fourth argument `{ signal?, timeout? }` for per-call cancellation and
|
|
484
|
+
timeout override. Merges with any client-level signal.
|
|
485
|
+
- Webhook replay protection: `createWebhookHandler()` accepts `toleranceMs`
|
|
486
|
+
(default `DEFAULT_WEBHOOK_TOLERANCE_MS = 5 * 60_000`). Payloads with
|
|
487
|
+
missing or out-of-window timestamps are rejected (400 / 410). Set
|
|
488
|
+
`toleranceMs: 0` to opt out.
|
|
489
|
+
- `createWebhookHandler({ onError })` may now return `Promise<void>` and is
|
|
490
|
+
awaited before responding.
|
|
491
|
+
- Dev server: multi-tenant mismatch detection. Requests against a different
|
|
492
|
+
`brandappId` than the server was configured for return a structured 404
|
|
493
|
+
explaining the mismatch.
|
|
494
|
+
- Dev server: required-field validation on record create and `bulkCreate`.
|
|
495
|
+
Missing required attributes return 422 with field-level errors matching
|
|
496
|
+
the production envelope.
|
|
497
|
+
- Dev server: bulk 100-record cap on `bulkCreate` / `bulkUpdate` /
|
|
498
|
+
`bulkDelete` (matches production).
|
|
499
|
+
- Dev server: `GET /ai/agents` endpoint, `AI credits` now decrement on each
|
|
500
|
+
chat/image call, responses match the SDK's `CompletionResult` /
|
|
501
|
+
`CreditInfo` / `ModelInfo` shapes.
|
|
502
|
+
- EAV: client-side 100-record cap on `bulkCreate` / `bulkUpdate` /
|
|
503
|
+
`bulkDelete` with a clear error before hitting the network.
|
|
504
|
+
- EAV: concurrent `resolveEntityId()` calls are de-duplicated by a shared
|
|
505
|
+
in-flight promise.
|
|
506
|
+
|
|
507
|
+
### Fixed
|
|
508
|
+
|
|
509
|
+
- **SSE parser was trimming every `data:` value**, which silently dropped
|
|
510
|
+
leading/trailing spaces in streaming AI text (e.g. `" world"` → `"world"`,
|
|
511
|
+
resulting in `"Helloworld"`). The parser now follows the SSE spec,
|
|
512
|
+
consuming only the single optional space after the colon and preserving
|
|
513
|
+
everything else.
|
|
514
|
+
- **Dev server `auth-handler` returned raw payloads** while the Better Auth
|
|
515
|
+
adapter expects `{ data: T }` — every adapter operation was receiving
|
|
516
|
+
`undefined`. All eight operations (`create`, `findOne`, `findMany`,
|
|
517
|
+
`update`, `updateMany`, `delete`, `deleteMany`, `count`) now return the
|
|
518
|
+
envelope shape.
|
|
519
|
+
- `streamWithMetadata()` could resolve its metadata promise multiple times
|
|
520
|
+
when the stream ended after a `done` event. Added an internal latch so
|
|
521
|
+
only the first resolve wins.
|
|
522
|
+
- `createReoptAdapter()` and `createReoptOAuth()` now throw immediately when
|
|
523
|
+
instantiated in a browser runtime (they hold `clientSecret` and must stay
|
|
524
|
+
server-side).
|
|
525
|
+
- EAV schema cache: `invalidate(pattern)` used `String.includes` and would
|
|
526
|
+
match both `"entities"` and `"entity:<id>"` for any substring. It now
|
|
527
|
+
uses prefix matching and exact-key match.
|
|
528
|
+
- EAV: entity mutations (`entities.create/update/delete`, `attributes.*`)
|
|
529
|
+
now invalidate both the `"entities"` list cache and all `"entity:*"`
|
|
530
|
+
per-entity caches in one pass.
|
|
531
|
+
- `dev/store.ts` `toSnapshot()` now returns a `structuredClone()` deep copy;
|
|
532
|
+
previously snapshots shared object references with the store.
|
|
533
|
+
- Webhook signature compare is unchanged (already constant-time via double
|
|
534
|
+
HMAC), but timestamp replay protection is now actually enforced when the
|
|
535
|
+
feature was enabled.
|
|
536
|
+
- `ai-provider` image model generates `n > 1` images in parallel via
|
|
537
|
+
`Promise.all()` instead of serially.
|
|
538
|
+
|
|
539
|
+
### Changed (subtle behavior — see migration guide)
|
|
540
|
+
|
|
541
|
+
- HTTP 400 / 403 / 404 / 409 no longer surface with `err.code === "REQUEST_ERROR"`.
|
|
542
|
+
They now throw the matching dedicated class with codes `BAD_REQUEST`,
|
|
543
|
+
`FORBIDDEN`, `NOT_FOUND`, `CONFLICT`. `instanceof ReoptSDKError` still
|
|
544
|
+
matches.
|
|
545
|
+
- `createWebhookHandler()` now requires a valid `timestamp` on the payload
|
|
546
|
+
by default. Pass `toleranceMs: 0` to restore the previous permissive
|
|
547
|
+
behavior.
|
|
548
|
+
- Dev server AI SSE stream format changed from `data: {"type":"text-delta",...}`
|
|
549
|
+
to the production `event: text-delta\ndata: <text>\n\n` format.
|
|
550
|
+
- Dev server AI JSON response shapes changed to match the SDK types
|
|
551
|
+
(`CompletionResult.message.content`, `CreditInfo.balance`, etc.). Any
|
|
552
|
+
code calling the dev server's AI routes directly via `fetch()` — rather
|
|
553
|
+
than through the SDK — needs updating.
|
|
554
|
+
|
|
555
|
+
### Internal
|
|
556
|
+
|
|
557
|
+
- `better-auth/adapter.ts`: removed all `as any` casts in favor of a
|
|
558
|
+
generic `request<T>()` helper.
|
|
559
|
+
- `core/debug.ts`: query-string values in debug logs are masked (allowlist
|
|
560
|
+
of safe keys like `page`, `limit`, `sort`).
|
|
561
|
+
- `react/use-ai-stream.ts`: `optionsRef` is synced in a `useEffect` rather
|
|
562
|
+
than during render (concurrent-rendering safe).
|
|
563
|
+
- OAuth scopes are de-duplicated when `additionalScopes` are supplied.
|
|
564
|
+
|
|
565
|
+
### Tests
|
|
566
|
+
|
|
567
|
+
- 347 → 365 (+18): adapter ↔ dev-server end-to-end, HTTP error paths
|
|
568
|
+
(401/404/422/5xx), webhook replay cases, SSE whitespace regression,
|
|
569
|
+
brandappId mismatch, required-field validation, bulk 100-record cap,
|
|
570
|
+
AI streaming shape and credit decrement.
|
|
571
|
+
|
|
572
|
+
## [1.5.0] — 2026-04-04
|
|
573
|
+
|
|
574
|
+
See git log for prior history.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Reopt
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|