@reopt-ai/brandapp-sdk 4.7.0-rc.3 → 4.7.0-rc.5

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.
Files changed (46) hide show
  1. package/CHANGELOG.md +47 -0
  2. package/dist/ai/index.js +1 -1
  3. package/dist/ai-provider/index.js +1 -1
  4. package/dist/analytics/index.js +1 -1
  5. package/dist/auth/index.js +1 -1
  6. package/dist/better-auth/index.d.ts +1 -1
  7. package/dist/better-auth/index.js +2 -2
  8. package/dist/{client-Dzux9iCO.js → client-B1oQZrBf.js} +4 -4
  9. package/dist/{client-2CaNRYKb.js → client-BEcJrDub.js} +51 -12
  10. package/dist/{client-COD-OtO6.js → client-BR4DzwcK.js} +2 -2
  11. package/dist/{client-C09GqOsD.js → client-C0WZeTm5.js} +2 -2
  12. package/dist/{client-BeNi8CJ8.js → client-CW4dDKUa.js} +3 -3
  13. package/dist/{client-BO7-GuXP.d.ts → client-C_X-hkb_.d.ts} +28 -4
  14. package/dist/{client-D6WGQQw8.js → client-DDouTFSX.js} +2 -2
  15. package/dist/{client-DHrZcdxq.js → client-DbZHZJXf.js} +3 -3
  16. package/dist/{client-BwFaLqeU.js → client-DkHxtSK1.js} +2 -2
  17. package/dist/{client-Cezzpa3v.js → client-DlKJi-nP.js} +28 -2
  18. package/dist/{client-CnVCMyEO.js → client-DwwSQGMw.js} +2 -2
  19. package/dist/{client-xycvTLR7.js → client-Dx3RjILO.js} +2 -2
  20. package/dist/{client-DWUvj6iA.js → client-_fMnz8Ot.js} +3 -3
  21. package/dist/cms/index.js +1 -1
  22. package/dist/{config-CCPAE9xX.js → config-CasmvpPc.js} +8 -5
  23. package/dist/eav/index.d.ts +1 -1
  24. package/dist/eav/index.js +2 -2
  25. package/dist/{errors-U3TsyWVq.d.ts → errors-D-Va8oeC.d.ts} +5 -2
  26. package/dist/feedback/index.js +1 -1
  27. package/dist/files/index.js +1 -1
  28. package/dist/{http-client-BTrQ0KrQ.js → http-client-D9GG3dtH.js} +2 -2
  29. package/dist/{index-CiZ5VkDS.d.ts → index-B2Jh3WzX.d.ts} +2 -2
  30. package/dist/index.d.ts +2 -2
  31. package/dist/index.js +12 -12
  32. package/dist/installation/index.d.ts +5 -1
  33. package/dist/installation/index.js +14 -9
  34. package/dist/logout/index.js +1 -1
  35. package/dist/machine/index.js +1 -1
  36. package/dist/plans/index.d.ts +1 -1
  37. package/dist/plans/index.js +1 -1
  38. package/dist/push/index.js +1 -1
  39. package/dist/{query-BTPb66iO.js → query-DVNclHZU.js} +2 -2
  40. package/dist/react/hooks.d.ts +2 -2
  41. package/dist/terms/index.js +1 -1
  42. package/dist/testing/index.d.ts +1 -1
  43. package/dist/workspace/index.js +1 -1
  44. package/docs/api-reference.md +18 -0
  45. package/docs/errors.md +37 -0
  46. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -7,6 +7,53 @@ This project adheres to [Semantic Versioning](https://semver.org/).
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [4.7.0-rc.5] — 2026-10-14
11
+
12
+ Pre-release (`npm i @reopt-ai/brandapp-sdk@next`) — 구독 중 플랜 변경(`plans.changePlan`)과 Lemon Squeezy 해지 계약, 5xx 오류 코드 보존.
13
+
14
+ ### Added
15
+
16
+ - `plans.changePlan(planId, accessToken)` — 구독 중인 플랜을 바꾼다(`POST /me/subscription/change`).
17
+ 새 체크아웃 없이 결제사 구독의 가격을 그 자리에서 바꾸므로 구독은 하나이고 갱신일이 이어진다.
18
+ 즉시 적용되고 바뀐 플랜(`getMyPlan`과 같은 모양)을 돌려준다. 올리면 차액을 지금 청구하고 내리면
19
+ 다음 청구서에서 차감한다. Lemon Squeezy 구독만 지원한다.
20
+
21
+ ### Changed
22
+
23
+ - 5xx 오류가 서버가 준 코드와 실제 상태를 담는다 — 상류(결제사) 실패는 `ServerError`이면서 `code`가
24
+ `PROVIDER_ERROR`·`PROVIDER_CANCEL_FAILED`, `status`가 502다. 코드 없는 5xx는 예전처럼 `SERVER_ERROR`이고
25
+ `status`는 실제 응답 상태다(전에는 항상 500).
26
+ - `plans.cancel` — Lemon Squeezy 구독은 결제사 해지가 먼저다. 결제사 해지가 실패하면 아무것도 바뀌지
27
+ 않고 `PROVIDER_CANCEL_FAILED`(HTTP 502)로 실패한다 — 다시 시도하면 된다. 성공하면 `accessUntil`이
28
+ 결제사의 결제 기간 끝이다.
29
+
30
+ ## [4.7.0-rc.4] — 2026-10-14
31
+
32
+ Pre-release (`npm i @reopt-ai/brandapp-sdk@next`) — EAV `listAll()` 커서 훑기와 설치 back-channel 재생 거절 보강.
33
+
34
+ ### Changed
35
+
36
+ - **`eav.records.listAll()`이 커서로 훑는다.** 번호 페이지로 훑으면 필터가 있을 때 서버가 페이지마다 조건에 맞는 행
37
+ 전체를 다시 읽어 그 페이지만 잘랐다 — 훑는 비용이 행 수의 제곱이었다. 이제 `GET …/records?cursor=`로 앞 페이지의
38
+ 마지막 자리 다음부터 그 페이지 분량만 읽는다. 호출부는 바꿀 것이 없다(`backfill()`·typed `entity().listAll()` 포함).
39
+ - 정렬이 `createdAt`(기본)·`updatedAt`일 때만 커서를 쓴다. 커스텀 속성 정렬은 종전대로 번호 페이지다.
40
+ - 커서를 모르는 서버(이전 버전의 reopt, 로컬 dev 서버)는 `cursor`를 무시하고 1페이지를 주므로, 그때는 2페이지부터
41
+ 번호로 이어 간다 — 결과는 같다.
42
+ - 같은 정렬 키를 가진 행들의 순서는 커서 방식에서 id가 정한다(번호 페이지는 createdAt → id). `updatedAt` 정렬로
43
+ 훑는 도중 갱신된 행은 자리를 옮기므로, 전 행을 정확히 한 번씩 읽어야 하면 기본값인 `createdAt`을 쓴다.
44
+ - SQL로 좁혀지지 않는 필터(`neq`·`not_in`·`after`·`before`)로 큰 엔티티를 훑어도 `QUERY_TOO_BROAD`(422)가 나지
45
+ 않는다 — 서버가 요청 한 건이 읽는 행 수를 묶고 커서로 이어 준다.
46
+ - 새 에러 코드 `CURSOR_SCAN_INTERRUPTED`(훑는 도중 커서를 모르는 인스턴스가 응답 — 처음부터 다시),
47
+ `CURSOR_SCAN_STALLED`(서버가 커서를 전진시키지 않음).
48
+
49
+ ### Fixed
50
+
51
+ - **`createInstallationBackchannelHandler`의 재생 거절에 빈틈이 있었다.** 통지의 jti를 `exp`까지만 기억했는데 검증은
52
+ `clockToleranceSeconds`(기본 60초)만큼 더 받아 주므로, `exp` 직후 그 시간 동안은 같은 통지가 다시 통과했다. 이제
53
+ 받아 줄 수 있는 마지막 순간(`exp + clockTolerance`)까지 기억한다.
54
+ - `createMemoryBackchannelReplayStore(now?)` — 시계를 받는다. 핸들러의 `now` 옵션이 기본 메모리 저장소에도 적용돼
55
+ 만료 판정과 기억을 지우는 시점이 같은 시계를 본다(예전에는 저장소만 실제 시계를 봤다).
56
+
10
57
  ## [4.7.0-rc.3] — 2026-10-11
11
58
 
12
59
  Pre-release (`npm i @reopt-ai/brandapp-sdk@next`) — RFC-0034 2·3단계: 리소스 서버 검증기와 운영자 가드.
package/dist/ai/index.js CHANGED
@@ -1,3 +1,3 @@
1
- import { n as createReoptAiClient, t as ReoptAiClient } from "../client-Dzux9iCO.js";
1
+ import { n as createReoptAiClient, t as ReoptAiClient } from "../client-B1oQZrBf.js";
2
2
 
3
3
  export { ReoptAiClient, createReoptAiClient };
@@ -1,4 +1,4 @@
1
- import { i as resolveBaseUrl, j as mapHttpStatusToError, n as SDK_VERSION, o as validateConfig, r as assertBrowserSafe } from "../config-CCPAE9xX.js";
1
+ import { i as resolveBaseUrl, j as mapHttpStatusToError, n as SDK_VERSION, o as validateConfig, r as assertBrowserSafe } from "../config-CasmvpPc.js";
2
2
  import { t as createManagedAbort } from "../abort--nOBFN4M.js";
3
3
  import { t as createAuthHeader } from "../encoding-Bwfm3iaE.js";
4
4
  import { t as createSSELineProcessor } from "../sse-parser-FMjxM7sY.js";
@@ -1,4 +1,4 @@
1
- import { n as createReoptAnalyticsClient, t as ReoptAnalyticsClient } from "../client-xycvTLR7.js";
1
+ import { n as createReoptAnalyticsClient, t as ReoptAnalyticsClient } from "../client-Dx3RjILO.js";
2
2
  import { getInstance, identify, init, pageView, setConsent, track } from "@reopt-ai/data-sdk";
3
3
 
4
4
  //#region src/analytics/browser.ts
@@ -1,4 +1,4 @@
1
- import { n as createReoptAuthClient, t as ReoptAuthClient } from "../client-C09GqOsD.js";
1
+ import { n as createReoptAuthClient, t as ReoptAuthClient } from "../client-C0WZeTm5.js";
2
2
 
3
3
  //#region src/auth/session.ts
4
4
  /**
@@ -1,7 +1,7 @@
1
1
  import { n as ReoptSDKConfig, t as REOPT_BASE_URLS } from "../config-BGT9h1OW.js";
2
2
  import { a as REOPT_PROVIDER_IDS, i as REOPT_PROVIDER_ID, n as AdapterRequestBody, o as REOPT_STEP_UP_PROVIDER_ID, r as REOPT_DEFAULT_SCOPES, s as STEP_UP_MAX_AUTH_AGE_SECONDS, t as AdapterOperation } from "../types-FazBnzhg.js";
3
3
  import { i as ClientPrivateJwk } from "../keys-B2pA8EkU.js";
4
- import { T as isReoptSDKError, _ as RateLimitError, t as AuthError, v as ReoptSDKError, x as ServerError } from "../errors-U3TsyWVq.js";
4
+ import { T as isReoptSDKError, _ as RateLimitError, t as AuthError, v as ReoptSDKError, x as ServerError } from "../errors-D-Va8oeC.js";
5
5
  import { AdapterFactory } from "better-auth/adapters";
6
6
  import { BetterAuthOptions, BetterAuthPlugin } from "better-auth";
7
7
  //#region src/better-auth/adapter.d.ts
@@ -1,5 +1,5 @@
1
- import { O as isReoptSDKError, S as ReoptSDKError, a as resolveIdBaseUrl, s as AuthError, t as REOPT_BASE_URLS, w as ServerError, x as RateLimitError } from "../config-CCPAE9xX.js";
2
- import { t as BaseHttpClient } from "../http-client-BTrQ0KrQ.js";
1
+ import { O as isReoptSDKError, S as ReoptSDKError, a as resolveIdBaseUrl, s as AuthError, t as REOPT_BASE_URLS, w as ServerError, x as RateLimitError } from "../config-CasmvpPc.js";
2
+ import { t as BaseHttpClient } from "../http-client-D9GG3dtH.js";
3
3
  import { o as readClientKeyRing } from "../keys-B_R_lsyF.js";
4
4
  import { a as STEP_UP_MAX_AUTH_AGE_SECONDS, i as REOPT_STEP_UP_PROVIDER_ID, n as REOPT_PROVIDER_ID, r as REOPT_PROVIDER_IDS, t as REOPT_DEFAULT_SCOPES } from "../types-DGAVaUCc.js";
5
5
  import { createAdapterFactory } from "better-auth/adapters";
@@ -1,6 +1,6 @@
1
- import { S as ReoptSDKError, j as mapHttpStatusToError, n as SDK_VERSION, o as validateConfig } from "./config-CCPAE9xX.js";
1
+ import { S as ReoptSDKError, j as mapHttpStatusToError, n as SDK_VERSION, o as validateConfig } from "./config-CasmvpPc.js";
2
2
  import { t as createManagedAbort } from "./abort--nOBFN4M.js";
3
- import { t as BaseHttpClient } from "./http-client-BTrQ0KrQ.js";
3
+ import { t as BaseHttpClient } from "./http-client-D9GG3dtH.js";
4
4
  import { n as parseSSEStream } from "./sse-parser-FMjxM7sY.js";
5
5
 
6
6
  //#region src/ai/client.ts
@@ -231,7 +231,7 @@ var ReoptAiClient = class {
231
231
  }
232
232
  async fetchSSE(options) {
233
233
  const url = `${this.http.requestBaseUrl}/chat/completions`;
234
- const requestId = globalThis.crypto?.randomUUID?.() ?? `sdk-${"4.7.0-rc.3"}-${url.length}`;
234
+ const requestId = globalThis.crypto?.randomUUID?.() ?? `sdk-${"4.7.0-rc.5"}-${url.length}`;
235
235
  const ctx = {
236
236
  method: "POST",
237
237
  url,
@@ -309,4 +309,4 @@ function createReoptAiClient(config) {
309
309
 
310
310
  //#endregion
311
311
  export { createReoptAiClient as n, ReoptAiClient as t };
312
- //# sourceMappingURL=client-Dzux9iCO.js.map
312
+ //# sourceMappingURL=client-B1oQZrBf.js.map
@@ -1,6 +1,6 @@
1
- import { u as BadRequestError } from "./config-CCPAE9xX.js";
2
- import { t as BaseHttpClient } from "./http-client-BTrQ0KrQ.js";
3
- import { t as buildQuery } from "./query-BTPb66iO.js";
1
+ import { S as ReoptSDKError, u as BadRequestError } from "./config-CasmvpPc.js";
2
+ import { t as BaseHttpClient } from "./http-client-D9GG3dtH.js";
3
+ import { t as buildQuery } from "./query-DVNclHZU.js";
4
4
 
5
5
  //#region src/eav/cache.ts
6
6
  var SchemaCache = class {
@@ -99,6 +99,13 @@ function assertPageLimit(limit) {
99
99
  if (Number.isInteger(limit) && limit >= 1 && limit <= 100) return;
100
100
  throw new BadRequestError(`limit must be an integer between 1 and ${100} (got ${limit}). Use records.listAll() to read every record across pages.`);
101
101
  }
102
+ function isCursorPage(data) {
103
+ return "nextCursor" in data;
104
+ }
105
+ /** The server scans by cursor only for its built-in time orders. */
106
+ function isCursorSortable(sortBy) {
107
+ return sortBy === void 0 || sortBy === "createdAt" || sortBy === "updatedAt";
108
+ }
102
109
  /** Page size for the paging helpers, held inside the server's accepted range. */
103
110
  function clampPageLimit(limit) {
104
111
  if (!Number.isFinite(limit)) return 100;
@@ -344,17 +351,49 @@ function createReoptEavClient(config) {
344
351
  * ```
345
352
  */
346
353
  async *listAll(entityId, query) {
347
- let page = 1;
348
354
  const limit = clampPageLimit(query?.limit ?? 100);
349
- while (true) {
350
- const res = await client.records.list(entityId, {
355
+ async function* numberedPages(from, knownLast) {
356
+ let page = from;
357
+ let last = knownLast;
358
+ while (last === void 0 || page <= last) {
359
+ const res = await client.records.list(entityId, {
360
+ ...query,
361
+ page,
362
+ limit
363
+ });
364
+ yield* res.records;
365
+ last = res.totalPages;
366
+ page++;
367
+ }
368
+ }
369
+ if (!isCursorSortable(query?.sortBy)) {
370
+ yield* numberedPages(1);
371
+ return;
372
+ }
373
+ let cursor = "";
374
+ for (;;) {
375
+ const qs = buildQuery({
351
376
  ...query,
352
- page,
353
- limit
377
+ limit,
378
+ cursor
379
+ });
380
+ const data = (await http.fetch("GET", `/entities/${entityId}/records${qs}`)).data;
381
+ if (!isCursorPage(data)) {
382
+ if (cursor !== "") throw new ReoptSDKError("The server stopped honoring the listAll cursor mid-scan. Restart the scan.", 0, "CURSOR_SCAN_INTERRUPTED", void 0, {
383
+ cause: "훑는 도중 커서를 모르는 서버 인스턴스가 응답함(배포 전환 중일 수 있음)",
384
+ fix: "listAll()을 처음부터 다시 실행"
385
+ });
386
+ yield* data.records;
387
+ yield* numberedPages(2, data.totalPages);
388
+ return;
389
+ }
390
+ yield* data.records;
391
+ if (data.nextCursor === null) return;
392
+ if (data.nextCursor === cursor) throw new ReoptSDKError("The listAll cursor did not advance.", 0, "CURSOR_SCAN_STALLED", void 0, {
393
+ cause: "서버가 받은 커서를 그대로 돌려줌 — 계속하면 같은 페이지를 끝없이 읽는다",
394
+ fix: "reopt 서버 버전을 확인하고 재시도"
354
395
  });
355
- for (const record of res.records) yield record;
356
- if (page >= res.totalPages) break;
357
- page++;
396
+ cursor = data.nextCursor;
358
397
  }
359
398
  },
360
399
  /**
@@ -564,4 +603,4 @@ function createReoptEavClient(config) {
564
603
 
565
604
  //#endregion
566
605
  export { RECORDS_PAGE_LIMIT_MAX as i, ATTRIBUTE_FILTER_LIST_MAX as n, ATTRIBUTE_FILTER_OPERATORS as r, createReoptEavClient as t };
567
- //# sourceMappingURL=client-2CaNRYKb.js.map
606
+ //# sourceMappingURL=client-BEcJrDub.js.map
@@ -1,4 +1,4 @@
1
- import { t as BaseHttpClient } from "./http-client-BTrQ0KrQ.js";
1
+ import { t as BaseHttpClient } from "./http-client-D9GG3dtH.js";
2
2
 
3
3
  //#region src/feedback/client.ts
4
4
  function buildListQuery(query) {
@@ -83,4 +83,4 @@ function createReoptFeedbackClient(config) {
83
83
 
84
84
  //#endregion
85
85
  export { createReoptFeedbackClient as n, ReoptFeedbackClient as t };
86
- //# sourceMappingURL=client-COD-OtO6.js.map
86
+ //# sourceMappingURL=client-BR4DzwcK.js.map
@@ -1,4 +1,4 @@
1
- import { t as BaseHttpClient } from "./http-client-BTrQ0KrQ.js";
1
+ import { t as BaseHttpClient } from "./http-client-D9GG3dtH.js";
2
2
 
3
3
  //#region src/auth/client.ts
4
4
  function unwrap(body) {
@@ -50,4 +50,4 @@ function createReoptAuthClient(config) {
50
50
 
51
51
  //#endregion
52
52
  export { createReoptAuthClient as n, ReoptAuthClient as t };
53
- //# sourceMappingURL=client-C09GqOsD.js.map
53
+ //# sourceMappingURL=client-C0WZeTm5.js.map
@@ -1,5 +1,5 @@
1
- import { t as BaseHttpClient } from "./http-client-BTrQ0KrQ.js";
2
- import { t as buildQuery } from "./query-BTPb66iO.js";
1
+ import { t as BaseHttpClient } from "./http-client-D9GG3dtH.js";
2
+ import { t as buildQuery } from "./query-DVNclHZU.js";
3
3
 
4
4
  //#region src/cms/client.ts
5
5
  function createReoptCmsClient(config) {
@@ -52,4 +52,4 @@ async list(query) {
52
52
 
53
53
  //#endregion
54
54
  export { createReoptCmsClient as t };
55
- //# sourceMappingURL=client-BeNi8CJ8.js.map
55
+ //# sourceMappingURL=client-CW4dDKUa.js.map
@@ -96,7 +96,7 @@ type CheckoutSession = {
96
96
  * `getCheckout` 응답에서는 `null`이다(capability token 재노출 방지).
97
97
  */
98
98
  checkoutUrl: string | null;
99
- /** 결제 제공자 — 현재 "sandbox"(가상 결제). */
99
+ /** 결제 제공자 — "sandbox"(가상 결제) 또는 "lemonsqueezy"(실 결제, id 주문 확인 화면을 거친다). */
100
100
  provider: string;
101
101
  status: CheckoutStatus | string;
102
102
  planId: string;
@@ -114,7 +114,7 @@ type CheckoutSession = {
114
114
  type CancelSubscriptionResult = {
115
115
  status: "canceled";
116
116
  /**
117
- * 해지된 구독의 결제 수단 (`sandbox` | `paddle` | `toss` | `apple` | `google` …).
117
+ * 해지된 구독의 결제 수단 (`sandbox` | `lemonsqueezy` | `toss` | `apple` | `google` | 옛 `paddle` …).
118
118
  * 안내 문구를 결제 수단별로 가를 때 쓴다. 구버전 서버는 내려주지 않는다.
119
119
  */
120
120
  provider?: string;
@@ -151,7 +151,7 @@ type CurrentPlan = {
151
151
  /** ISO-8601 문자열. `null`이면 무기한. */
152
152
  planExpiresAt: string | null;
153
153
  /**
154
- * **활성** 결제 연결의 제공자 — "paddle" | "toss" | null.
154
+ * **활성** 결제 연결의 제공자 — "lemonsqueezy" | "toss" | (옛) "paddle" | null.
155
155
  *
156
156
  * ⚠️ "실 결제인가"의 근거로 쓰지 말 것. 해지하면 연결이 보관되어 남은 이용 기간 동안
157
157
  * `null`이 되고, 가상 결제·스토어 구독·운영자 배정도 모두 `null`이다. 그 판정에는
@@ -242,10 +242,34 @@ declare class ReoptPlansClient {
242
242
  * always stopped; the provider-side cancellation is best-effort and reported
243
243
  * through `providerCanceled`. Apple/Google subscriptions are canceled in the
244
244
  * store, so no remote call is made for those.
245
+ *
246
+ * Lemon Squeezy charges renewals on its own, so for those the provider is
247
+ * canceled first: if that fails nothing changes (the subscription stays
248
+ * active) and the call fails with `PROVIDER_CANCEL_FAILED` (HTTP 502) — retry
249
+ * it. On success `accessUntil` is the provider's end of the paid period.
245
250
  */
246
251
  cancel(accessToken: string): Promise<CancelSubscriptionResult>;
252
+ /**
253
+ * Switch the current customer's subscription to another plan — no new
254
+ * checkout: the provider subscription changes price in place, so it stays one
255
+ * subscription and keeps its renewal date. Lemon Squeezy subscriptions only
256
+ * (since 4.7); others fail with `PLAN_CHANGE_UNSUPPORTED` (cancel, then check
257
+ * out the new plan).
258
+ *
259
+ * Takes effect immediately and resolves to the changed plan (same shape as
260
+ * {@link getMyPlan}). Moving to a pricier plan charges the prorated
261
+ * difference now; moving to a cheaper one credits it on the next invoice.
262
+ *
263
+ * Errors (`ReoptSDKError.code`): `NO_ACTIVE_SUBSCRIPTION`, `SAME_PLAN`,
264
+ * `PLAN_NOT_FOUND` (404), `PLAN_INACTIVE`, `PLAN_PRICE_NOT_LINKED`,
265
+ * `TERMS_REQUIRED`, `SUBSCRIPTION_NOT_ACTIVE` (cancel scheduled or past due),
266
+ * `PROVIDER_PORTAL_REQUIRED` (PayPal subscriptions are changed in the
267
+ * provider's customer portal), `PROVIDER_ERROR` (HTTP 502 — nothing changed,
268
+ * retry).
269
+ */
270
+ changePlan(planId: string, accessToken: string): Promise<CurrentPlan>;
247
271
  }
248
272
  declare function createReoptPlansClient(config: ReoptSDKConfig): ReoptPlansClient;
249
273
  //#endregion
250
274
  export { CheckoutStatus as a, MeterPricingMode as c, PlanInterval as d, PlanMeter as f, PlanRequiredTerms as h, CheckoutSession as i, Plan as l, PlanPaymentEnvironment as m, createReoptPlansClient as n, CreateCheckoutInput as o, PlanMeterTier as p, CancelSubscriptionResult as r, CurrentPlan as s, ReoptPlansClient as t, PlanBillingModel as u };
251
- //# sourceMappingURL=client-BO7-GuXP.d.ts.map
275
+ //# sourceMappingURL=client-C_X-hkb_.d.ts.map
@@ -1,4 +1,4 @@
1
- import { a as resolveIdBaseUrl } from "./config-CCPAE9xX.js";
1
+ import { a as resolveIdBaseUrl } from "./config-CasmvpPc.js";
2
2
  import { o as readClientKeyRing, s as toPublicJwk } from "./keys-B_R_lsyF.js";
3
3
  import { createPrivateKeyJwtClientAssertionGetter } from "@better-auth/core/oauth2";
4
4
  import * as jose from "jose";
@@ -191,4 +191,4 @@ function createMachineClient(config) {
191
191
 
192
192
  //#endregion
193
193
  export { createDpopProof as n, createMachineClient as r, MachineTokenError as t };
194
- //# sourceMappingURL=client-D6WGQQw8.js.map
194
+ //# sourceMappingURL=client-DDouTFSX.js.map
@@ -1,6 +1,6 @@
1
- import { S as ReoptSDKError, j as mapHttpStatusToError, n as SDK_VERSION, o as validateConfig } from "./config-CCPAE9xX.js";
1
+ import { S as ReoptSDKError, j as mapHttpStatusToError, n as SDK_VERSION, o as validateConfig } from "./config-CasmvpPc.js";
2
2
  import { t as createManagedAbort } from "./abort--nOBFN4M.js";
3
- import { n as parseFieldErrors, t as BaseHttpClient } from "./http-client-BTrQ0KrQ.js";
3
+ import { n as parseFieldErrors, t as BaseHttpClient } from "./http-client-D9GG3dtH.js";
4
4
 
5
5
  //#region src/files/client.ts
6
6
  var ReoptFileClient = class {
@@ -270,4 +270,4 @@ function createReoptFileClient(config) {
270
270
 
271
271
  //#endregion
272
272
  export { createReoptFileClient as n, ReoptFileClient as t };
273
- //# sourceMappingURL=client-DHrZcdxq.js.map
273
+ //# sourceMappingURL=client-DbZHZJXf.js.map
@@ -1,4 +1,4 @@
1
- import { t as BaseHttpClient } from "./http-client-BTrQ0KrQ.js";
1
+ import { t as BaseHttpClient } from "./http-client-D9GG3dtH.js";
2
2
 
3
3
  //#region src/terms/client.ts
4
4
  function unwrap(body) {
@@ -80,4 +80,4 @@ function createReoptTermsClient(config) {
80
80
 
81
81
  //#endregion
82
82
  export { createReoptTermsClient as n, ReoptTermsClient as t };
83
- //# sourceMappingURL=client-BwFaLqeU.js.map
83
+ //# sourceMappingURL=client-DkHxtSK1.js.map
@@ -1,4 +1,4 @@
1
- import { t as BaseHttpClient } from "./http-client-BTrQ0KrQ.js";
1
+ import { t as BaseHttpClient } from "./http-client-D9GG3dtH.js";
2
2
 
3
3
  //#region src/plans/client.ts
4
4
  function unwrap(body) {
@@ -88,10 +88,36 @@ var ReoptPlansClient = class {
88
88
  * always stopped; the provider-side cancellation is best-effort and reported
89
89
  * through `providerCanceled`. Apple/Google subscriptions are canceled in the
90
90
  * store, so no remote call is made for those.
91
+ *
92
+ * Lemon Squeezy charges renewals on its own, so for those the provider is
93
+ * canceled first: if that fails nothing changes (the subscription stays
94
+ * active) and the call fails with `PROVIDER_CANCEL_FAILED` (HTTP 502) — retry
95
+ * it. On success `accessUntil` is the provider's end of the paid period.
91
96
  */
92
97
  async cancel(accessToken) {
93
98
  return unwrap(await this.http.fetch("POST", "/me/subscription/cancel", {}, { bearerToken: accessToken }));
94
99
  }
100
+ /**
101
+ * Switch the current customer's subscription to another plan — no new
102
+ * checkout: the provider subscription changes price in place, so it stays one
103
+ * subscription and keeps its renewal date. Lemon Squeezy subscriptions only
104
+ * (since 4.7); others fail with `PLAN_CHANGE_UNSUPPORTED` (cancel, then check
105
+ * out the new plan).
106
+ *
107
+ * Takes effect immediately and resolves to the changed plan (same shape as
108
+ * {@link getMyPlan}). Moving to a pricier plan charges the prorated
109
+ * difference now; moving to a cheaper one credits it on the next invoice.
110
+ *
111
+ * Errors (`ReoptSDKError.code`): `NO_ACTIVE_SUBSCRIPTION`, `SAME_PLAN`,
112
+ * `PLAN_NOT_FOUND` (404), `PLAN_INACTIVE`, `PLAN_PRICE_NOT_LINKED`,
113
+ * `TERMS_REQUIRED`, `SUBSCRIPTION_NOT_ACTIVE` (cancel scheduled or past due),
114
+ * `PROVIDER_PORTAL_REQUIRED` (PayPal subscriptions are changed in the
115
+ * provider's customer portal), `PROVIDER_ERROR` (HTTP 502 — nothing changed,
116
+ * retry).
117
+ */
118
+ async changePlan(planId, accessToken) {
119
+ return unwrap(await this.http.fetch("POST", "/me/subscription/change", { planId }, { bearerToken: accessToken }));
120
+ }
95
121
  };
96
122
  function createReoptPlansClient(config) {
97
123
  return new ReoptPlansClient(config);
@@ -99,4 +125,4 @@ function createReoptPlansClient(config) {
99
125
 
100
126
  //#endregion
101
127
  export { createReoptPlansClient as n, ReoptPlansClient as t };
102
- //# sourceMappingURL=client-Cezzpa3v.js.map
128
+ //# sourceMappingURL=client-DlKJi-nP.js.map
@@ -1,4 +1,4 @@
1
- import { t as BaseHttpClient } from "./http-client-BTrQ0KrQ.js";
1
+ import { t as BaseHttpClient } from "./http-client-D9GG3dtH.js";
2
2
 
3
3
  //#region src/push/client.ts
4
4
  var ReoptPushClient = class {
@@ -25,4 +25,4 @@ function createReoptPushClient(config) {
25
25
 
26
26
  //#endregion
27
27
  export { createReoptPushClient as n, ReoptPushClient as t };
28
- //# sourceMappingURL=client-CnVCMyEO.js.map
28
+ //# sourceMappingURL=client-DwwSQGMw.js.map
@@ -1,4 +1,4 @@
1
- import { t as BaseHttpClient } from "./http-client-BTrQ0KrQ.js";
1
+ import { t as BaseHttpClient } from "./http-client-D9GG3dtH.js";
2
2
 
3
3
  //#region src/analytics/client.ts
4
4
  var ReoptAnalyticsClient = class {
@@ -17,4 +17,4 @@ function createReoptAnalyticsClient(config) {
17
17
 
18
18
  //#endregion
19
19
  export { createReoptAnalyticsClient as n, ReoptAnalyticsClient as t };
20
- //# sourceMappingURL=client-xycvTLR7.js.map
20
+ //# sourceMappingURL=client-Dx3RjILO.js.map
@@ -1,6 +1,6 @@
1
- import { n as SDK_VERSION } from "./config-CCPAE9xX.js";
1
+ import { n as SDK_VERSION } from "./config-CasmvpPc.js";
2
2
  import { o as readClientKeyRing } from "./keys-B_R_lsyF.js";
3
- import { r as createMachineClient } from "./client-D6WGQQw8.js";
3
+ import { r as createMachineClient } from "./client-DDouTFSX.js";
4
4
  import { z } from "zod";
5
5
 
6
6
  //#region src/workspace/schemas.ts
@@ -733,4 +733,4 @@ function createPlatformClient(config) {
733
733
 
734
734
  //#endregion
735
735
  export { platformWorkTaskStageChangedEventSchema as $, platformErrorSchema as A, platformPipelineSchema as B, platformBrandappUpsertInputSchema as C, platformEavSchemaApplyInputSchema as D, platformEavEntityResourceSchema as E, platformOAuthClientImportInputSchema as F, platformResourcesV2Schema as G, platformPipelineUpsertInputSchema as H, platformOAuthClientResourceSchema as I, platformTaskStageSchema as J, platformTaskSchema as K, platformOAuthClientUpsertInputSchema as L, platformLockAcquiredSchema as M, platformLockReleasedSchema as N, platformEavSchemaApplyResultSchema as O, platformMeSchema as P, platformWebhookUpsertInputSchema as Q, platformPipelineImportInputSchema as R, platformBrandappResourceSchema as S, platformEavBrandappResourcesSchema as T, platformResourceKeySchema as U, platformPipelineStageInputSchema as V, platformResourcesSchema as W, platformWebhookResourceSchema as X, platformTaskUpsertInputSchema as Y, platformWebhookSchema as Z, PLATFORM_TOKEN_ENDPOINT_AUTH_METHODS as _, createPlatformClient as a, platformBrandResourceSchema as b, PLATFORM_BRANDAPP_STATUSES as c, PLATFORM_OAUTH_APPLICATION_TYPES as d, platformWriteMetaSchema as et, PLATFORM_OAUTH_CLIENT_PURPOSES as f, PLATFORM_TASK_PRIORITIES as g, PLATFORM_TASK_OUTCOMES as h, REOPT_PLATFORM_URLS as i, platformExternalIdSchema as j, platformEavSchemaOperationSchema as k, PLATFORM_DOMAIN_STATUSES as l, PLATFORM_STAGE_COLORS as m, PlatformApiError as n, resolvePlatformUrls as o, PLATFORM_OAUTH_GRANT_TYPES as p, platformTaskStageInputSchema as q, REOPT_PLATFORM_ID_URLS as r, PLATFORM_ADMIN_SCOPE as s, DEFAULT_PLATFORM_SCOPES as t, PLATFORM_MANAGED_BY_VALUES as u, PLATFORM_WEBHOOK_TRIGGERS as v, platformCustomerUpsertInputSchema as w, platformBrandUpsertInputSchema as x, platformBrandImportInputSchema as y, platformPipelineResourceSchema as z };
736
- //# sourceMappingURL=client-DWUvj6iA.js.map
736
+ //# sourceMappingURL=client-_fMnz8Ot.js.map
package/dist/cms/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { t as createReoptCmsClient } from "../client-BeNi8CJ8.js";
1
+ import { t as createReoptCmsClient } from "../client-CW4dDKUa.js";
2
2
 
3
3
  //#region src/cms/helpers.ts
4
4
  function joinUrl(siteUrl, path) {
@@ -35,8 +35,8 @@ var RateLimitError = class extends ReoptSDKError {
35
35
  }
36
36
  };
37
37
  var ServerError = class extends ReoptSDKError {
38
- constructor(message = "Internal server error", context) {
39
- super(message, 500, "SERVER_ERROR", context, {
38
+ constructor(message = "Internal server error", context, reported) {
39
+ super(message, reported?.status ?? 500, reported?.code ?? "SERVER_ERROR", context, {
40
40
  cause: "서버 내부 오류",
41
41
  fix: "잠시 후 재시도. 반복되면 서버 상태 확인",
42
42
  doc: "docs/errors.md#server_error"
@@ -312,14 +312,17 @@ function mapHttpStatusToError(status, code, message, ctx, fieldErrors) {
312
312
  return new ReoptSDKError(message ?? `Request failed with status ${status}`, 422, code ?? "REQUEST_ERROR", ctx);
313
313
  case 429: return new RateLimitError(message ?? "Rate limit exceeded", void 0, ctx);
314
314
  default:
315
- if (status >= 500) return new ServerError(message ?? "Internal server error", ctx);
315
+ if (status >= 500) return new ServerError(message ?? "Internal server error", ctx, {
316
+ status,
317
+ code
318
+ });
316
319
  return new ReoptSDKError(message ?? `Unexpected status: ${status}`, status, code ?? "UNEXPECTED_ERROR", ctx);
317
320
  }
318
321
  }
319
322
 
320
323
  //#endregion
321
324
  //#region src/core/config.ts
322
- const SDK_VERSION = "4.7.0-rc.3";
325
+ const SDK_VERSION = "4.7.0-rc.5";
323
326
  /**
324
327
  * Default API host for EAV / AI / Files / CMS / Terms. Consumers can override
325
328
  * via `config.baseUrl` or the `REOPT_BASE_URL` env var.
@@ -501,4 +504,4 @@ function deriveIdFromBaseUrl(baseUrl) {
501
504
 
502
505
  //#endregion
503
506
  export { isValidationError as A, RequiredTermsError as C, isModelAccessError as D, isCreditLimitError as E, isReoptSDKError as O, ReoptSDKError as S, ValidationError as T, ModelAccessError as _, resolveIdBaseUrl as a, PreconditionFailedError as b, AuthUserNotFoundError as c, ConflictError as d, ContentFilterError as f, LimitExceededError as g, ForbiddenError as h, resolveBaseUrl as i, mapHttpStatusToError as j, isRequiredTermsError as k, AuthUserRecordExistsError as l, DuplicateAuthUserError as m, SDK_VERSION as n, validateConfig as o, CreditLimitError as p, assertBrowserSafe as r, AuthError as s, REOPT_BASE_URLS as t, BadRequestError as u, ModelNotFoundError as v, ServerError as w, RateLimitError as x, NotFoundError as y };
504
- //# sourceMappingURL=config-CCPAE9xX.js.map
507
+ //# sourceMappingURL=config-CasmvpPc.js.map
@@ -1,5 +1,5 @@
1
1
  import { A as ListRecordsQuery, C as EavAttribute, D as EavRecord, E as EavEntity, F as UpdateRecordInput, I as UpsertRecordInput, L as UpsertRecordResult, M as RECORDS_PAGE_LIMIT_MAX, N as UpdateAttributeInput, O as EavSchemaLinkedTo, P as UpdateEntityInput, S as DeleteWhereInput, T as EavDataType, _ as BulkUpdateItem, b as CreateEntityInput, d as ATTRIBUTE_FILTER_OPERATORS, f as AttributeFilter, j as PaginatedResponse, k as EavValidation, m as AttributeFilterOperator, n as ReoptSDKConfig, p as AttributeFilterListValue, u as ATTRIBUTE_FILTER_LIST_MAX, v as CountRecordsQuery, w as EavAttributeOption, x as CreateRecordInput, y as CreateAttributeInput } from "../config-BGT9h1OW.js";
2
- import { c as DuplicateAuthUserError, f as LimitExceededError, n as AuthUserNotFoundError, r as AuthUserRecordExistsError } from "../errors-U3TsyWVq.js";
2
+ import { c as DuplicateAuthUserError, f as LimitExceededError, n as AuthUserNotFoundError, r as AuthUserRecordExistsError } from "../errors-D-Va8oeC.js";
3
3
  import { i as TypedEavRecord, n as createReoptEavClient, r as EntityClient, t as ReoptEavClient } from "../client-CJRjPSf7.js";
4
4
  //#region src/eav/verify.d.ts
5
5
  /**
package/dist/eav/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { c as AuthUserNotFoundError, g as LimitExceededError, l as AuthUserRecordExistsError, m as DuplicateAuthUserError } from "../config-CCPAE9xX.js";
2
- import { i as RECORDS_PAGE_LIMIT_MAX, n as ATTRIBUTE_FILTER_LIST_MAX, r as ATTRIBUTE_FILTER_OPERATORS, t as createReoptEavClient } from "../client-2CaNRYKb.js";
1
+ import { c as AuthUserNotFoundError, g as LimitExceededError, l as AuthUserRecordExistsError, m as DuplicateAuthUserError } from "../config-CasmvpPc.js";
2
+ import { i as RECORDS_PAGE_LIMIT_MAX, n as ATTRIBUTE_FILTER_LIST_MAX, r as ATTRIBUTE_FILTER_OPERATORS, t as createReoptEavClient } from "../client-BEcJrDub.js";
3
3
 
4
4
  //#region src/eav/verify.ts
5
5
  async function verifyEavSchema(input) {
@@ -35,7 +35,10 @@ declare class RateLimitError extends ReoptSDKError {
35
35
  constructor(message?: string, retryAfterMs?: number, context?: ReoptSDKErrorContext);
36
36
  }
37
37
  declare class ServerError extends ReoptSDKError {
38
- constructor(message?: string, context?: ReoptSDKErrorContext);
38
+ constructor(message?: string, context?: ReoptSDKErrorContext, reported?: {
39
+ status?: number;
40
+ code?: string;
41
+ });
39
42
  }
40
43
  /** AI 사용량 잔액 부족 (HTTP 402). */
41
44
  declare class CreditLimitError extends ReoptSDKError {
@@ -186,4 +189,4 @@ declare function isModelAccessError(error: unknown): error is ModelAccessError;
186
189
  declare function mapHttpStatusToError(status: number, code: string | undefined, message: string | undefined, ctx?: ReoptSDKErrorContext, fieldErrors?: FieldError[]): ReoptSDKError;
187
190
  //#endregion
188
191
  export { isCreditLimitError as C, isValidationError as D, isRequiredTermsError as E, mapHttpStatusToError as O, ValidationError as S, isReoptSDKError as T, RateLimitError as _, ConflictError as a, RequiredTermsError as b, DuplicateAuthUserError as c, ForbiddenError as d, LimitExceededError as f, PreconditionFailedError as g, NotFoundError as h, BadRequestError as i, ErrorDiagnostic as l, ModelNotFoundError as m, AuthUserNotFoundError as n, ContentFilterError as o, ModelAccessError as p, AuthUserRecordExistsError as r, CreditLimitError as s, AuthError as t, FieldError as u, ReoptSDKError as v, isModelAccessError as w, ServerError as x, ReoptSDKErrorContext as y };
189
- //# sourceMappingURL=errors-U3TsyWVq.d.ts.map
192
+ //# sourceMappingURL=errors-D-Va8oeC.d.ts.map
@@ -1,3 +1,3 @@
1
- import { n as createReoptFeedbackClient, t as ReoptFeedbackClient } from "../client-COD-OtO6.js";
1
+ import { n as createReoptFeedbackClient, t as ReoptFeedbackClient } from "../client-BR4DzwcK.js";
2
2
 
3
3
  export { ReoptFeedbackClient, createReoptFeedbackClient };
@@ -1,4 +1,4 @@
1
- import { n as createReoptFileClient, t as ReoptFileClient } from "../client-DHrZcdxq.js";
1
+ import { n as createReoptFileClient, t as ReoptFileClient } from "../client-DbZHZJXf.js";
2
2
 
3
3
  //#region src/files/helpers.ts
4
4
  const REOPT_IMAGE_REMOTE_PATTERNS = [{
@@ -1,4 +1,4 @@
1
- import { S as ReoptSDKError, a as resolveIdBaseUrl, i as resolveBaseUrl, j as mapHttpStatusToError, n as SDK_VERSION, o as validateConfig, w as ServerError, x as RateLimitError } from "./config-CCPAE9xX.js";
1
+ import { S as ReoptSDKError, a as resolveIdBaseUrl, i as resolveBaseUrl, j as mapHttpStatusToError, n as SDK_VERSION, o as validateConfig, w as ServerError, x as RateLimitError } from "./config-CasmvpPc.js";
2
2
  import { t as createAuthHeader } from "./encoding-Bwfm3iaE.js";
3
3
 
4
4
  //#region src/core/debug.ts
@@ -389,4 +389,4 @@ function parseFieldErrors(body) {
389
389
 
390
390
  //#endregion
391
391
  export { parseFieldErrors as n, BaseHttpClient as t };
392
- //# sourceMappingURL=http-client-BTrQ0KrQ.js.map
392
+ //# sourceMappingURL=http-client-D9GG3dtH.js.map
@@ -6,7 +6,7 @@ import { t as ReoptCmsClient } from "./client-NUhpPkl2.js";
6
6
  import { t as ReoptEavClient } from "./client-CJRjPSf7.js";
7
7
  import { t as ReoptFeedbackClient } from "./client-DF-tOyrY.js";
8
8
  import { t as ReoptFileClient } from "./client-wNzcgEJu.js";
9
- import { t as ReoptPlansClient } from "./client-BO7-GuXP.js";
9
+ import { t as ReoptPlansClient } from "./client-C_X-hkb_.js";
10
10
  import { t as ReoptPushClient } from "./client-BbmslwWV.js";
11
11
  import { t as ReoptTermsClient } from "./client-Dwf6UuGH.js";
12
12
  //#region src/core/http-client.d.ts
@@ -178,4 +178,4 @@ type ReoptSDK<S extends SchemaDef = SchemaDef> = {
178
178
  declare function createReoptSDK<S extends SchemaDef = SchemaDef>(config: ReoptSDKConfig<S>): ReoptSDK<S>;
179
179
  //#endregion
180
180
  export { initReoptSDK as a, getReoptSDK as i, createReoptSDK as n, resetSDK as o, createLazySDK as r, BaseHttpClient as s, ReoptSDK as t };
181
- //# sourceMappingURL=index-CiZ5VkDS.d.ts.map
181
+ //# sourceMappingURL=index-B2Jh3WzX.d.ts.map
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { a as DebugLogger, i as DebugLevel, n as ReoptSDKConfig, r as resolveBaseUrl, t as REOPT_BASE_URLS } from "./config-BGT9h1OW.js";
2
2
  import { a as CompletionOptions, c as FinishReason, d as MessageRole, f as ModelInfo, i as ChatMessage, l as ImageGenerateOptions, m as StreamEvent, o as CompletionResult, p as StreamDoneData, r as AgentInfo, s as CreditInfo, u as ImageGenerateResult } from "./client-Bi-KSU_r.js";
3
- import { C as isCreditLimitError, D as isValidationError, E as isRequiredTermsError, O as mapHttpStatusToError, S as ValidationError, T as isReoptSDKError, _ as RateLimitError, a as ConflictError, b as RequiredTermsError, c as DuplicateAuthUserError, d as ForbiddenError, f as LimitExceededError, g as PreconditionFailedError, h as NotFoundError, i as BadRequestError, l as ErrorDiagnostic, m as ModelNotFoundError, n as AuthUserNotFoundError, o as ContentFilterError, p as ModelAccessError, r as AuthUserRecordExistsError, s as CreditLimitError, t as AuthError, u as FieldError, v as ReoptSDKError, w as isModelAccessError, x as ServerError, y as ReoptSDKErrorContext } from "./errors-U3TsyWVq.js";
3
+ import { C as isCreditLimitError, D as isValidationError, E as isRequiredTermsError, O as mapHttpStatusToError, S as ValidationError, T as isReoptSDKError, _ as RateLimitError, a as ConflictError, b as RequiredTermsError, c as DuplicateAuthUserError, d as ForbiddenError, f as LimitExceededError, g as PreconditionFailedError, h as NotFoundError, i as BadRequestError, l as ErrorDiagnostic, m as ModelNotFoundError, n as AuthUserNotFoundError, o as ContentFilterError, p as ModelAccessError, r as AuthUserRecordExistsError, s as CreditLimitError, t as AuthError, u as FieldError, v as ReoptSDKError, w as isModelAccessError, x as ServerError, y as ReoptSDKErrorContext } from "./errors-D-Va8oeC.js";
4
4
  import { i as TypedEavRecord, r as EntityClient } from "./client-CJRjPSf7.js";
5
- import { a as initReoptSDK, i as getReoptSDK, n as createReoptSDK, o as resetSDK, r as createLazySDK, s as BaseHttpClient, t as ReoptSDK } from "./index-CiZ5VkDS.js";
5
+ import { a as initReoptSDK, i as getReoptSDK, n as createReoptSDK, o as resetSDK, r as createLazySDK, s as BaseHttpClient, t as ReoptSDK } from "./index-B2Jh3WzX.js";
6
6
  export { type AgentInfo, AuthError, AuthUserNotFoundError, AuthUserRecordExistsError, BadRequestError, BaseHttpClient, type ChatMessage, type CompletionOptions, type CompletionResult, ConflictError, ContentFilterError, type CreditInfo, CreditLimitError, type DebugLevel, type DebugLogger, DuplicateAuthUserError, type EntityClient, type ErrorDiagnostic, type FieldError, type FinishReason, ForbiddenError, type ImageGenerateOptions, type ImageGenerateResult, LimitExceededError, type MessageRole, ModelAccessError, type ModelInfo, ModelNotFoundError, NotFoundError, PreconditionFailedError, REOPT_BASE_URLS, RateLimitError, ReoptSDK, type ReoptSDKConfig, ReoptSDKError, type ReoptSDKErrorContext, RequiredTermsError, ServerError, type StreamDoneData, type StreamEvent, type TypedEavRecord, ValidationError, createLazySDK, createReoptSDK, getReoptSDK, initReoptSDK, isCreditLimitError, isModelAccessError, isReoptSDKError, isRequiredTermsError, isValidationError, mapHttpStatusToError, resetSDK, resolveBaseUrl };
package/dist/index.js CHANGED
@@ -1,15 +1,15 @@
1
- import { A as isValidationError, C as RequiredTermsError, D as isModelAccessError, E as isCreditLimitError, O as isReoptSDKError, S as ReoptSDKError, T as ValidationError, _ as ModelAccessError, b as PreconditionFailedError, c as AuthUserNotFoundError, d as ConflictError, f as ContentFilterError, g as LimitExceededError, h as ForbiddenError, i as resolveBaseUrl, j as mapHttpStatusToError, k as isRequiredTermsError, l as AuthUserRecordExistsError, m as DuplicateAuthUserError, p as CreditLimitError, r as assertBrowserSafe, s as AuthError, t as REOPT_BASE_URLS, u as BadRequestError, v as ModelNotFoundError, w as ServerError, x as RateLimitError, y as NotFoundError } from "./config-CCPAE9xX.js";
2
- import { t as BaseHttpClient } from "./http-client-BTrQ0KrQ.js";
3
- import { n as createReoptAiClient } from "./client-Dzux9iCO.js";
4
- import { n as createReoptAuthClient } from "./client-C09GqOsD.js";
5
- import { t as createReoptCmsClient } from "./client-BeNi8CJ8.js";
6
- import { t as createReoptEavClient } from "./client-2CaNRYKb.js";
7
- import { n as createReoptFeedbackClient } from "./client-COD-OtO6.js";
8
- import { n as createReoptFileClient } from "./client-DHrZcdxq.js";
9
- import { n as createReoptAnalyticsClient } from "./client-xycvTLR7.js";
10
- import { n as createReoptPlansClient } from "./client-Cezzpa3v.js";
11
- import { n as createReoptPushClient } from "./client-CnVCMyEO.js";
12
- import { n as createReoptTermsClient } from "./client-BwFaLqeU.js";
1
+ import { A as isValidationError, C as RequiredTermsError, D as isModelAccessError, E as isCreditLimitError, O as isReoptSDKError, S as ReoptSDKError, T as ValidationError, _ as ModelAccessError, b as PreconditionFailedError, c as AuthUserNotFoundError, d as ConflictError, f as ContentFilterError, g as LimitExceededError, h as ForbiddenError, i as resolveBaseUrl, j as mapHttpStatusToError, k as isRequiredTermsError, l as AuthUserRecordExistsError, m as DuplicateAuthUserError, p as CreditLimitError, r as assertBrowserSafe, s as AuthError, t as REOPT_BASE_URLS, u as BadRequestError, v as ModelNotFoundError, w as ServerError, x as RateLimitError, y as NotFoundError } from "./config-CasmvpPc.js";
2
+ import { t as BaseHttpClient } from "./http-client-D9GG3dtH.js";
3
+ import { n as createReoptAiClient } from "./client-B1oQZrBf.js";
4
+ import { n as createReoptAuthClient } from "./client-C0WZeTm5.js";
5
+ import { t as createReoptCmsClient } from "./client-CW4dDKUa.js";
6
+ import { t as createReoptEavClient } from "./client-BEcJrDub.js";
7
+ import { n as createReoptFeedbackClient } from "./client-BR4DzwcK.js";
8
+ import { n as createReoptFileClient } from "./client-DbZHZJXf.js";
9
+ import { n as createReoptAnalyticsClient } from "./client-Dx3RjILO.js";
10
+ import { n as createReoptPlansClient } from "./client-DlKJi-nP.js";
11
+ import { n as createReoptPushClient } from "./client-DwwSQGMw.js";
12
+ import { n as createReoptTermsClient } from "./client-DkHxtSK1.js";
13
13
 
14
14
  //#region src/singleton.ts
15
15
  let _instance;
@@ -276,7 +276,11 @@ type InstallationEvent = {
276
276
  type BackchannelReplayStore = {
277
277
  reserve(jti: string, expiresAt: Date): Promise<boolean>;
278
278
  };
279
- declare function createMemoryBackchannelReplayStore(): BackchannelReplayStore;
279
+ /**
280
+ * `now`는 핸들러와 **같은 시계**여야 한다 — 만료 판정(서명 검증)과 기억을 지우는 시점이 다른
281
+ * 시계를 보면, 핸들러가 아직 유효하다고 본 통지의 jti를 저장소가 먼저 잊어 재생이 통과한다.
282
+ */
283
+ declare function createMemoryBackchannelReplayStore(now?: () => Date): BackchannelReplayStore;
280
284
  type InstallationBackchannelHandlerOptions = {
281
285
  idBaseUrl: string;
282
286
  /** 매니페스트에 적은 그 URL — `aud`와 대조한다. */
@@ -1,7 +1,7 @@
1
- import { n as SDK_VERSION } from "../config-CCPAE9xX.js";
1
+ import { n as SDK_VERSION } from "../config-CasmvpPc.js";
2
2
  import { o as readClientKeyRing } from "../keys-B_R_lsyF.js";
3
- import { r as createMachineClient } from "../client-D6WGQQw8.js";
4
- import { A as platformErrorSchema, C as platformBrandappUpsertInputSchema, H as platformPipelineUpsertInputSchema, U as platformResourceKeySchema, f as PLATFORM_OAUTH_CLIENT_PURPOSES, n as PlatformApiError, o as resolvePlatformUrls, v as PLATFORM_WEBHOOK_TRIGGERS, x as platformBrandUpsertInputSchema } from "../client-DWUvj6iA.js";
3
+ import { r as createMachineClient } from "../client-DDouTFSX.js";
4
+ import { A as platformErrorSchema, C as platformBrandappUpsertInputSchema, H as platformPipelineUpsertInputSchema, U as platformResourceKeySchema, f as PLATFORM_OAUTH_CLIENT_PURPOSES, n as PlatformApiError, o as resolvePlatformUrls, v as PLATFORM_WEBHOOK_TRIGGERS, x as platformBrandUpsertInputSchema } from "../client-_fMnz8Ot.js";
5
5
  import * as jose from "jose";
6
6
  import { z } from "zod";
7
7
 
@@ -506,11 +506,15 @@ const INSTALLATION_EVENT_NAMES = [
506
506
  "installation.resumed",
507
507
  "installation.revoked"
508
508
  ];
509
- function createMemoryBackchannelReplayStore() {
509
+ /**
510
+ * `now`는 핸들러와 **같은 시계**여야 한다 — 만료 판정(서명 검증)과 기억을 지우는 시점이 다른
511
+ * 시계를 보면, 핸들러가 아직 유효하다고 본 통지의 jti를 저장소가 먼저 잊어 재생이 통과한다.
512
+ */
513
+ function createMemoryBackchannelReplayStore(now = () => /* @__PURE__ */ new Date()) {
510
514
  const seen = /* @__PURE__ */ new Map();
511
515
  return { async reserve(jti, expiresAt) {
512
- const now = Date.now();
513
- for (const [key, until] of seen) if (until <= now) seen.delete(key);
516
+ const current = now().getTime();
517
+ for (const [key, until] of seen) if (until <= current) seen.delete(key);
514
518
  if (seen.has(jti)) return false;
515
519
  seen.set(jti, expiresAt.getTime());
516
520
  return true;
@@ -548,7 +552,8 @@ function createInstallationBackchannelHandler(options) {
548
552
  cacheMaxAge: 6e5,
549
553
  ...options.jwksFetch ? { [jose.customFetch]: options.jwksFetch } : {}
550
554
  });
551
- const replayStore = options.replayStore ?? createMemoryBackchannelReplayStore();
555
+ const clockToleranceSeconds = options.clockToleranceSeconds ?? 60;
556
+ const replayStore = options.replayStore ?? createMemoryBackchannelReplayStore(options.now);
552
557
  return async (request) => {
553
558
  const token = (await request.text()).trim();
554
559
  if (!token || token.split(".").length !== 3) return new Response(null, { status: 400 });
@@ -557,7 +562,7 @@ function createInstallationBackchannelHandler(options) {
557
562
  const verified = await jose.jwtVerify(token, jwks, {
558
563
  issuer,
559
564
  audience: options.backchannelUri,
560
- clockTolerance: options.clockToleranceSeconds ?? 60,
565
+ clockTolerance: clockToleranceSeconds,
561
566
  currentDate: options.now?.()
562
567
  });
563
568
  payload = verified.payload;
@@ -567,7 +572,7 @@ function createInstallationBackchannelHandler(options) {
567
572
  }
568
573
  const event = readEvent(payload);
569
574
  if (!event) return new Response(null, { status: 400 });
570
- const expiresAt = /* @__PURE__ */ new Date((typeof payload.exp === "number" ? payload.exp : event.iat + 300) * 1e3);
575
+ const expiresAt = /* @__PURE__ */ new Date(((typeof payload.exp === "number" ? payload.exp : event.iat + 300) + clockToleranceSeconds) * 1e3);
571
576
  if (!await replayStore.reserve(event.jti, expiresAt)) return new Response(null, { status: 401 });
572
577
  try {
573
578
  await options.onEvent(event);
@@ -1,4 +1,4 @@
1
- import { S as ReoptSDKError, a as resolveIdBaseUrl } from "../config-CCPAE9xX.js";
1
+ import { S as ReoptSDKError, a as resolveIdBaseUrl } from "../config-CasmvpPc.js";
2
2
 
3
3
  //#region src/logout/verify.ts
4
4
  /**
@@ -1,4 +1,4 @@
1
1
  import { a as parseClientPrivateJwk, i as generateClientKeyPair, n as DEFAULT_CLIENT_KEY_ALGORITHM, o as readClientKeyRing, r as buildClientJwks, s as toPublicJwk, t as CLIENT_JWKS_PATH } from "../keys-B_R_lsyF.js";
2
- import { n as createDpopProof, r as createMachineClient, t as MachineTokenError } from "../client-D6WGQQw8.js";
2
+ import { n as createDpopProof, r as createMachineClient, t as MachineTokenError } from "../client-DDouTFSX.js";
3
3
 
4
4
  export { CLIENT_JWKS_PATH, DEFAULT_CLIENT_KEY_ALGORITHM, MachineTokenError, buildClientJwks, createDpopProof, createMachineClient, generateClientKeyPair, parseClientPrivateJwk, readClientKeyRing, toPublicJwk };
@@ -1,2 +1,2 @@
1
- import { a as CheckoutStatus, c as MeterPricingMode, d as PlanInterval, f as PlanMeter, h as PlanRequiredTerms, i as CheckoutSession, l as Plan, m as PlanPaymentEnvironment, n as createReoptPlansClient, o as CreateCheckoutInput, p as PlanMeterTier, r as CancelSubscriptionResult, s as CurrentPlan, t as ReoptPlansClient, u as PlanBillingModel } from "../client-BO7-GuXP.js";
1
+ import { a as CheckoutStatus, c as MeterPricingMode, d as PlanInterval, f as PlanMeter, h as PlanRequiredTerms, i as CheckoutSession, l as Plan, m as PlanPaymentEnvironment, n as createReoptPlansClient, o as CreateCheckoutInput, p as PlanMeterTier, r as CancelSubscriptionResult, s as CurrentPlan, t as ReoptPlansClient, u as PlanBillingModel } from "../client-C_X-hkb_.js";
2
2
  export { type CancelSubscriptionResult, type CheckoutSession, type CheckoutStatus, type CreateCheckoutInput, type CurrentPlan, type MeterPricingMode, type Plan, type PlanBillingModel, type PlanInterval, type PlanMeter, type PlanMeterTier, type PlanPaymentEnvironment, type PlanRequiredTerms, ReoptPlansClient, createReoptPlansClient };
@@ -1,3 +1,3 @@
1
- import { n as createReoptPlansClient, t as ReoptPlansClient } from "../client-Cezzpa3v.js";
1
+ import { n as createReoptPlansClient, t as ReoptPlansClient } from "../client-DlKJi-nP.js";
2
2
 
3
3
  export { ReoptPlansClient, createReoptPlansClient };
@@ -1,3 +1,3 @@
1
- import { n as createReoptPushClient, t as ReoptPushClient } from "../client-CnVCMyEO.js";
1
+ import { n as createReoptPushClient, t as ReoptPushClient } from "../client-DwwSQGMw.js";
2
2
 
3
3
  export { ReoptPushClient, createReoptPushClient };
@@ -1,4 +1,4 @@
1
- import { S as ReoptSDKError } from "./config-CCPAE9xX.js";
1
+ import { S as ReoptSDKError } from "./config-CasmvpPc.js";
2
2
 
3
3
  //#region src/core/query.ts
4
4
  /**
@@ -32,4 +32,4 @@ function buildQuery(params) {
32
32
 
33
33
  //#endregion
34
34
  export { buildQuery as t };
35
- //# sourceMappingURL=query-BTPb66iO.js.map
35
+ //# sourceMappingURL=query-DVNclHZU.js.map
@@ -1,9 +1,9 @@
1
1
  import { A as ListRecordsQuery, C as EavAttribute, D as EavRecord, E as EavEntity, F as UpdateRecordInput, I as UpsertRecordInput, L as UpsertRecordResult, S as DeleteWhereInput, _ as BulkUpdateItem, j as PaginatedResponse, x as CreateRecordInput } from "../config-BGT9h1OW.js";
2
2
  import { a as CompletionOptions, f as ModelInfo, l as ImageGenerateOptions, o as CompletionResult, p as StreamDoneData, r as AgentInfo, s as CreditInfo, u as ImageGenerateResult } from "../client-Bi-KSU_r.js";
3
- import { v as ReoptSDKError } from "../errors-U3TsyWVq.js";
3
+ import { v as ReoptSDKError } from "../errors-D-Va8oeC.js";
4
4
  import { a as ListTagsQuery, c as PostGroup, d as Tag, i as ListPostsQuery, o as Post, r as ListPostGroupsQuery, s as PostDetail, t as CmsPaginatedResponse } from "../types-BXDcoJHG.js";
5
5
  import { a as FileListQuery, c as FolderInfo, d as UpdateFolderInput, f as UploadOptions, i as FileInfo, l as FolderListQuery, o as FileListResponse, r as CreateFolderInput, s as FileUsageInfo, u as UpdateFileInput } from "../client-wNzcgEJu.js";
6
- import { t as ReoptSDK } from "../index-CiZ5VkDS.js";
6
+ import { t as ReoptSDK } from "../index-B2Jh3WzX.js";
7
7
  import { UseInfiniteQueryOptions, UseInfiniteQueryResult, UseMutationOptions, UseMutationResult, UseQueryOptions, UseQueryResult } from "@tanstack/react-query";
8
8
  //#region src/react/use-ai-stream.d.ts
9
9
  type UseAiStreamOptions = {
@@ -1,3 +1,3 @@
1
- import { n as createReoptTermsClient, t as ReoptTermsClient } from "../client-BwFaLqeU.js";
1
+ import { n as createReoptTermsClient, t as ReoptTermsClient } from "../client-DkHxtSK1.js";
2
2
 
3
3
  export { ReoptTermsClient, createReoptTermsClient };
@@ -1,5 +1,5 @@
1
1
  import { a as SeedAllInput, c as SeedPostGroupInput, d as SeedTermsItem, l as SeedPostInput, n as DevServer, o as SeedData, t as DevSchema } from "../index-Dh8XMVFF.js";
2
- import { t as ReoptSDK } from "../index-CiZ5VkDS.js";
2
+ import { t as ReoptSDK } from "../index-B2Jh3WzX.js";
3
3
  //#region src/testing/index.d.ts
4
4
  type TestSDKOptions = {
5
5
  /** EAV schema to seed entities and attributes */
@@ -1,3 +1,3 @@
1
- import { $ as platformWorkTaskStageChangedEventSchema, A as platformErrorSchema, B as platformPipelineSchema, C as platformBrandappUpsertInputSchema, D as platformEavSchemaApplyInputSchema, E as platformEavEntityResourceSchema, F as platformOAuthClientImportInputSchema, G as platformResourcesV2Schema, H as platformPipelineUpsertInputSchema, I as platformOAuthClientResourceSchema, J as platformTaskStageSchema, K as platformTaskSchema, L as platformOAuthClientUpsertInputSchema, M as platformLockAcquiredSchema, N as platformLockReleasedSchema, O as platformEavSchemaApplyResultSchema, P as platformMeSchema, Q as platformWebhookUpsertInputSchema, R as platformPipelineImportInputSchema, S as platformBrandappResourceSchema, T as platformEavBrandappResourcesSchema, U as platformResourceKeySchema, V as platformPipelineStageInputSchema, W as platformResourcesSchema, X as platformWebhookResourceSchema, Y as platformTaskUpsertInputSchema, Z as platformWebhookSchema, _ as PLATFORM_TOKEN_ENDPOINT_AUTH_METHODS, a as createPlatformClient, b as platformBrandResourceSchema, c as PLATFORM_BRANDAPP_STATUSES, d as PLATFORM_OAUTH_APPLICATION_TYPES, et as platformWriteMetaSchema, f as PLATFORM_OAUTH_CLIENT_PURPOSES, g as PLATFORM_TASK_PRIORITIES, h as PLATFORM_TASK_OUTCOMES, i as REOPT_PLATFORM_URLS, j as platformExternalIdSchema, k as platformEavSchemaOperationSchema, l as PLATFORM_DOMAIN_STATUSES, m as PLATFORM_STAGE_COLORS, n as PlatformApiError, o as resolvePlatformUrls, p as PLATFORM_OAUTH_GRANT_TYPES, q as platformTaskStageInputSchema, r as REOPT_PLATFORM_ID_URLS, s as PLATFORM_ADMIN_SCOPE, t as DEFAULT_PLATFORM_SCOPES, u as PLATFORM_MANAGED_BY_VALUES, v as PLATFORM_WEBHOOK_TRIGGERS, w as platformCustomerUpsertInputSchema, x as platformBrandUpsertInputSchema, y as platformBrandImportInputSchema, z as platformPipelineResourceSchema } from "../client-DWUvj6iA.js";
1
+ import { $ as platformWorkTaskStageChangedEventSchema, A as platformErrorSchema, B as platformPipelineSchema, C as platformBrandappUpsertInputSchema, D as platformEavSchemaApplyInputSchema, E as platformEavEntityResourceSchema, F as platformOAuthClientImportInputSchema, G as platformResourcesV2Schema, H as platformPipelineUpsertInputSchema, I as platformOAuthClientResourceSchema, J as platformTaskStageSchema, K as platformTaskSchema, L as platformOAuthClientUpsertInputSchema, M as platformLockAcquiredSchema, N as platformLockReleasedSchema, O as platformEavSchemaApplyResultSchema, P as platformMeSchema, Q as platformWebhookUpsertInputSchema, R as platformPipelineImportInputSchema, S as platformBrandappResourceSchema, T as platformEavBrandappResourcesSchema, U as platformResourceKeySchema, V as platformPipelineStageInputSchema, W as platformResourcesSchema, X as platformWebhookResourceSchema, Y as platformTaskUpsertInputSchema, Z as platformWebhookSchema, _ as PLATFORM_TOKEN_ENDPOINT_AUTH_METHODS, a as createPlatformClient, b as platformBrandResourceSchema, c as PLATFORM_BRANDAPP_STATUSES, d as PLATFORM_OAUTH_APPLICATION_TYPES, et as platformWriteMetaSchema, f as PLATFORM_OAUTH_CLIENT_PURPOSES, g as PLATFORM_TASK_PRIORITIES, h as PLATFORM_TASK_OUTCOMES, i as REOPT_PLATFORM_URLS, j as platformExternalIdSchema, k as platformEavSchemaOperationSchema, l as PLATFORM_DOMAIN_STATUSES, m as PLATFORM_STAGE_COLORS, n as PlatformApiError, o as resolvePlatformUrls, p as PLATFORM_OAUTH_GRANT_TYPES, q as platformTaskStageInputSchema, r as REOPT_PLATFORM_ID_URLS, s as PLATFORM_ADMIN_SCOPE, t as DEFAULT_PLATFORM_SCOPES, u as PLATFORM_MANAGED_BY_VALUES, v as PLATFORM_WEBHOOK_TRIGGERS, w as platformCustomerUpsertInputSchema, x as platformBrandUpsertInputSchema, y as platformBrandImportInputSchema, z as platformPipelineResourceSchema } from "../client-_fMnz8Ot.js";
2
2
 
3
3
  export { DEFAULT_PLATFORM_SCOPES, PLATFORM_ADMIN_SCOPE, PLATFORM_BRANDAPP_STATUSES, PLATFORM_DOMAIN_STATUSES, PLATFORM_MANAGED_BY_VALUES, PLATFORM_OAUTH_APPLICATION_TYPES, PLATFORM_OAUTH_CLIENT_PURPOSES, PLATFORM_OAUTH_GRANT_TYPES, PLATFORM_STAGE_COLORS, PLATFORM_TASK_OUTCOMES, PLATFORM_TASK_PRIORITIES, PLATFORM_TOKEN_ENDPOINT_AUTH_METHODS, PLATFORM_WEBHOOK_TRIGGERS, PlatformApiError, REOPT_PLATFORM_ID_URLS, REOPT_PLATFORM_URLS, createPlatformClient, platformBrandImportInputSchema, platformBrandResourceSchema, platformBrandUpsertInputSchema, platformBrandappResourceSchema, platformBrandappUpsertInputSchema, platformCustomerUpsertInputSchema, platformEavBrandappResourcesSchema, platformEavEntityResourceSchema, platformEavSchemaApplyInputSchema, platformEavSchemaApplyResultSchema, platformEavSchemaOperationSchema, platformErrorSchema, platformExternalIdSchema, platformLockAcquiredSchema, platformLockReleasedSchema, platformMeSchema, platformOAuthClientImportInputSchema, platformOAuthClientResourceSchema, platformOAuthClientUpsertInputSchema, platformPipelineImportInputSchema, platformPipelineResourceSchema, platformPipelineSchema, platformPipelineStageInputSchema, platformPipelineUpsertInputSchema, platformResourceKeySchema, platformResourcesSchema, platformResourcesV2Schema, platformTaskSchema, platformTaskStageInputSchema, platformTaskStageSchema, platformTaskUpsertInputSchema, platformWebhookResourceSchema, platformWebhookSchema, platformWebhookUpsertInputSchema, platformWorkTaskStageChangedEventSchema, platformWriteMetaSchema, resolvePlatformUrls };
@@ -426,6 +426,13 @@ import { RECORDS_PAGE_LIMIT_MAX } from "@reopt-ai/brandapp-sdk/eav"; // 100
426
426
  for await (const record of sdk.eav.records.listAll(entityId)) { ... }
427
427
  ```
428
428
 
429
+ `listAll()`은 커서로 훑는다(`?cursor=`) — 요청마다 앞 페이지의 마지막 자리 다음부터 그 페이지 분량만 읽으므로
430
+ 필터를 걸어도 엔티티 크기에 비례하는 비용으로 끝난다. 엔티티 전체를 읽을 때는 `list()`로 `page`를 직접 돌리지 말고
431
+ 이것을 쓴다(번호 페이지 + 필터는 페이지마다 조건에 맞는 행 전체를 다시 읽는다). 정렬이 `createdAt`(기본)·`updatedAt`일
432
+ 때만 커서를 쓰고 커스텀 속성 정렬은 번호 페이지로 돈다. 커서 방식에서 정렬 키가 같은 행의 순서는 id가 정하며,
433
+ `updatedAt` 정렬로 훑는 도중 갱신된 행은 자리를 옮긴다 — 전 행을 정확히 한 번씩 읽어야 하면 `createdAt`을 쓴다.
434
+ SQL로 좁혀지지 않는 필터로 큰 엔티티를 훑어도 `QUERY_TOO_BROAD`가 나지 않는다(그 상한은 번호 페이지의 것이다).
435
+
429
436
  ## Filter Builder
430
437
 
431
438
  ```typescript
@@ -632,6 +639,17 @@ canceled.providerCanceled; // false → local subscription is definitely over (n
632
639
  // remnant that an operator should check (3.4+)
633
640
  ```
634
641
 
642
+ ```ts
643
+ // Switch plans while subscribed (Lemon Squeezy, 4.7+) — no new checkout.
644
+ // Immediate; resolves to the changed plan (same shape as getMyPlan).
645
+ // Upgrades charge the prorated difference now, downgrades credit the next invoice.
646
+ const plan: CurrentPlan = await sdk.plans.changePlan(teamPlanId, accessToken);
647
+ plan.planId; // teamPlanId
648
+ // e.code: NO_ACTIVE_SUBSCRIPTION | SAME_PLAN | PLAN_NOT_FOUND | PLAN_INACTIVE |
649
+ // PLAN_PRICE_NOT_LINKED | TERMS_REQUIRED | SUBSCRIPTION_NOT_ACTIVE |
650
+ // PROVIDER_PORTAL_REQUIRED (PayPal → provider portal) | PROVIDER_ERROR (502, retry)
651
+ ```
652
+
635
653
  > The three fields added in 3.4 are optional — an older platform deployment
636
654
  > simply omits them. Apple/Google (IAP) subscriptions are canceled in the store,
637
655
  > so no remote call is made and `providerCanceled` stays `false`.
package/docs/errors.md CHANGED
@@ -266,6 +266,27 @@ try {
266
266
  }
267
267
  ```
268
268
 
269
+ ### Plan change & cancel (`sdk.plans.changePlan` / `sdk.plans.cancel`, 4.7+)
270
+
271
+ Refusals come back as `ConflictError` (409) with these `code`s — nothing was
272
+ changed and no provider call was made:
273
+
274
+ | code | meaning | what to do |
275
+ | --------------------------------------- | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------- |
276
+ | `NO_ACTIVE_SUBSCRIPTION` | no subscription to change | check out the plan instead |
277
+ | `SAME_PLAN` | already on that plan | re-read `getMyPlan` — after a retry this means the first call landed |
278
+ | `PLAN_INACTIVE` / `PLAN_SCOPE_MISMATCH` | the target plan is not sellable here | refresh the plan list |
279
+ | `PLAN_CHANGE_UNSUPPORTED` | not a Lemon Squeezy subscription, or a different currency / non-recurring plan | cancel, then check out |
280
+ | `PLAN_PRICE_NOT_LINKED` | the plan has no provider price yet | ask the app operator |
281
+ | `TERMS_REQUIRED` | the new plan needs terms consent | collect consent via `sdk.terms`, retry |
282
+ | `SUBSCRIPTION_NOT_ACTIVE` | cancel scheduled or payment past due | resume / fix payment first |
283
+ | `PROVIDER_PORTAL_REQUIRED` | PayPal subscription — the provider API cannot change it | send the customer to the provider's customer portal (receipt e-mail link) |
284
+
285
+ `PLAN_NOT_FOUND` is a `NotFoundError` (404). A provider-side failure is a
286
+ `ServerError` with `status: 502` and `code: "PROVIDER_ERROR"` (changePlan) or
287
+ `"PROVIDER_CANCEL_FAILED"` (cancel) — nothing changed, retry. POST calls are
288
+ not retried automatically.
289
+
269
290
  ### FORBIDDEN: `Forbidden` / `Model tier not available` (403)
270
291
 
271
292
  - **Cause**: No permission for the resource — e.g. the requested model
@@ -308,6 +329,22 @@ try {
308
329
  - **Fix**: Reduce the number of filters or the size of filter values; split a
309
330
  large query into several smaller calls.
310
331
 
332
+ ### CURSOR_SCAN_INTERRUPTED: the server stopped honoring the `listAll` cursor (0)
333
+
334
+ - **Cause**: `records.listAll()` was scanning by cursor and a response came back
335
+ as a numbered page instead. That answer is page 1 again — typically an older
336
+ server instance answering during a deploy switch-over — and continuing would
337
+ yield every record twice, so the scan stops.
338
+ - **Fix**: Run `listAll()` again from the start. Records already yielded are
339
+ valid; only the remainder was not read.
340
+
341
+ ### CURSOR_SCAN_STALLED: the `listAll` cursor did not advance (0)
342
+
343
+ - **Cause**: The server returned the same `nextCursor` it was given. Continuing
344
+ would read the same page forever.
345
+ - **Fix**: Retry; if it repeats, report it with the request ID — the server is
346
+ not advancing the scan.
347
+
311
348
  ### FILE_NOT_FOUND: `File not found` (404)
312
349
 
313
350
  - **Cause**: The requested file ID does not exist or has been deleted
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reopt-ai/brandapp-sdk",
3
- "version": "4.7.0-rc.3",
3
+ "version": "4.7.0-rc.5",
4
4
  "description": "Reopt Brandapp SDK — Better Auth adapter, OAuth login, and EAV client",
5
5
  "author": "Reopt",
6
6
  "license": "MIT",