@reopt-ai/brandapp-sdk 3.0.0 → 3.1.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 +31 -3
- package/dist/ai/index.js +3 -3
- package/dist/ai-provider/index.js +1 -1
- package/dist/auth/index.js +3 -3
- package/dist/better-auth/index.d.ts +1 -1
- package/dist/better-auth/index.js +3 -3
- package/dist/{chunk-KU2LN5SE.js → chunk-2Q654O63.js} +4 -4
- package/dist/{chunk-E457LO5A.js → chunk-IJOXTBIE.js} +4 -4
- package/dist/{chunk-YRGLBM6V.js → chunk-JWXUVQRC.js} +4 -4
- package/dist/{chunk-J5Y2GSJF.js → chunk-MRQY45U5.js} +26 -4
- package/dist/{chunk-DI6QJPTQ.js → chunk-N5JVE4WX.js} +3 -3
- package/dist/chunk-O3PUWIDJ.js +105 -0
- package/dist/{chunk-PJZB4VP7.js → chunk-POLKEOYH.js} +3 -3
- package/dist/{chunk-6KPKZ7ZB.js → chunk-R5CCGDUH.js} +3 -3
- package/dist/{chunk-K3YVJE6E.js → chunk-RBHP7IZF.js} +3 -3
- package/dist/{chunk-TUKIYH4Q.js → chunk-T7YTITRJ.js} +3 -3
- package/dist/{chunk-WSEROZVO.js → chunk-V73GORO3.js} +4 -4
- package/dist/{chunk-6FLYVNZI.js → chunk-VRNBYSWU.js} +3 -3
- package/dist/cms/index.js +4 -4
- package/dist/eav/index.d.ts +1 -1
- package/dist/eav/index.js +4 -4
- package/dist/{errors-5hd5ZR-M.d.ts → errors-DIAS8Rsl.d.ts} +23 -1
- package/dist/feedback/index.js +3 -3
- package/dist/files/index.js +3 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.js +13 -13
- package/dist/plans/index.d.ts +107 -11
- package/dist/plans/index.js +3 -3
- package/dist/push/index.js +3 -3
- package/dist/react/hooks.d.ts +1 -1
- package/dist/terms/index.js +3 -3
- package/dist/testing/index.d.ts +1 -1
- package/docs/api-reference.md +1 -1
- package/docs/cms.md +0 -1
- package/package.json +3 -1
- package/dist/chunk-T2WXHAAC.js +0 -54
package/CHANGELOG.md
CHANGED
|
@@ -5,9 +5,37 @@ All notable changes to `@reopt-ai/brandapp-sdk` are documented here.
|
|
|
5
5
|
The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
|
6
6
|
This project adheres to [Semantic Versioning](https://semver.org/).
|
|
7
7
|
|
|
8
|
+
## [3.1.0] — 2026-07-15
|
|
9
|
+
|
|
10
|
+
플랜 구독 결제를 SDK로 완결 — `plans`가 read-only에서 **hosted checkout**(구독·결제·취소)까지
|
|
11
|
+
확장. 실 결제(Toss/Paddle) 미설정 시 id.reopt.ai 가상 결제(샌드박스) 흐름으로 "카탈로그 →
|
|
12
|
+
구독 → 결제 → 엔타이틀먼트" 전 과정을 코드 설정 없이 테스트할 수 있다. 전부 additive(minor).
|
|
13
|
+
|
|
14
|
+
### Added — `sdk.plans` checkout
|
|
15
|
+
|
|
16
|
+
- **`plans.createCheckout({ planId, successUrl, cancelUrl }, accessToken)`** — hosted checkout
|
|
17
|
+
세션을 만들고 `CheckoutSession`을 반환한다. `checkoutUrl`로 브라우저를 리다이렉트하면 샌드박스
|
|
18
|
+
모드에서 id.reopt.ai 가상 결제 페이지가 구독을 활성화하고 `successUrl`/`cancelUrl`로 복귀시킨다.
|
|
19
|
+
- **`plans.getCheckout(checkoutId, accessToken)`** — 체크아웃 세션 상태 폴링(복귀 페이지에서 확인).
|
|
20
|
+
- **`plans.cancel(accessToken)`** — 현재 샌드박스 구독 취소(결제 기간까지 접근 유지).
|
|
21
|
+
- 새 타입: `CheckoutSession`, `CreateCheckoutInput`, `CheckoutStatus`, `CancelSubscriptionResult`
|
|
22
|
+
(`@reopt-ai/brandapp-sdk/plans`).
|
|
23
|
+
|
|
24
|
+
### Added — `RequiredTermsError`
|
|
25
|
+
|
|
26
|
+
- **`RequiredTermsError`**(`isRequiredTermsError` 가드 동반) — `createCheckout`가 플랜 필수 약관
|
|
27
|
+
미동의 시 던진다. `error.missingTermsIds`로 어떤 약관인지 알아내 `sdk.terms.list()`+
|
|
28
|
+
`sdk.terms.consent()`로 동의를 수집한 뒤 재시도한다. HTTP 422 `REQUIRED_TERMS` 매핑.
|
|
29
|
+
|
|
30
|
+
### Notes
|
|
31
|
+
|
|
32
|
+
- 실 Toss/Paddle checkout은 아직 SDK로 구동하지 않는다(브라우저 SDK+호스트 콜백 필요 →
|
|
33
|
+
first-party brandfront 흐름 유지). 브랜드앱이 live 결제로 설정되면 `createCheckout`는 409
|
|
34
|
+
`LIVE_MODE_UNSUPPORTED`를 반환한다. usage 미터는 여전히 read-only 메타데이터.
|
|
35
|
+
|
|
8
36
|
## [3.0.0] — 2026-06-26
|
|
9
37
|
|
|
10
|
-
보안 리뷰(BRANDAPP_SDK_REVIEW.md) 후속 — 인증·자격증명·웹훅 강화. 웹훅 검증 계약과
|
|
38
|
+
보안 리뷰(docs/reviews/BRANDAPP_SDK_REVIEW.md) 후속 — 인증·자격증명·웹훅 강화. 웹훅 검증 계약과
|
|
11
39
|
`verifySignature` 시그니처가 바뀌어 메이저 범프.
|
|
12
40
|
|
|
13
41
|
### BREAKING — 웹훅 검증을 실제 플랫폼 송신부에 정렬 (F-2)
|
|
@@ -360,8 +388,8 @@ EAV 에러 분기를 ergonomic하게 — 1:1 메타 충돌, authUser 미등록,
|
|
|
360
388
|
> `cms.postGroups.{create,update,delete}` + 동일 이름의 React 훅과 입력 타입)이
|
|
361
389
|
> 제거됐다. 1.7.x에서도 production 백엔드는 해당 endpoint를 노출하지 않았고
|
|
362
390
|
> dev 서버에서만 동작했기 때문에 사실상 dead surface였으며, 알려진 외부 npm
|
|
363
|
-
> 소비자가 없어 minor bump로 처리한다. cms를
|
|
364
|
-
>
|
|
391
|
+
> 소비자가 없어 minor bump로 처리한다. 당시 cms를 호출하던 reopt-ai 내부
|
|
392
|
+
> 소비 앱도 본 릴리즈에 함께 정렬됐다. 외부 소비자가
|
|
365
393
|
> write 호출에 의존하고 있다면 [`docs/migration.md`](./docs/migration.md)의
|
|
366
394
|
> 1.7 → 1.8 가이드를 따라 read-only로 전환하거나 1.7.x에 핀 고정.
|
|
367
395
|
|
package/dist/ai/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { ReoptAiClient, createReoptAiClient } from '../chunk-
|
|
1
|
+
export { ReoptAiClient, createReoptAiClient } from '../chunk-2Q654O63.js';
|
|
2
2
|
import '../chunk-L4DHB36G.js';
|
|
3
3
|
import '../chunk-F7BXBTZI.js';
|
|
4
|
-
import '../chunk-
|
|
5
|
-
import '../chunk-
|
|
4
|
+
import '../chunk-N5JVE4WX.js';
|
|
5
|
+
import '../chunk-MRQY45U5.js';
|
|
6
6
|
//# sourceMappingURL=index.js.map
|
|
7
7
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createSSELineProcessor } from '../chunk-L4DHB36G.js';
|
|
2
2
|
import { createManagedAbort } from '../chunk-F7BXBTZI.js';
|
|
3
|
-
import { assertBrowserSafe, validateConfig, resolveBaseUrl, createAuthHeader, SDK_VERSION, mapHttpStatusToError } from '../chunk-
|
|
3
|
+
import { assertBrowserSafe, validateConfig, resolveBaseUrl, createAuthHeader, SDK_VERSION, mapHttpStatusToError } from '../chunk-MRQY45U5.js';
|
|
4
4
|
import { NoSuchModelError, APICallError } from '@ai-sdk/provider';
|
|
5
5
|
|
|
6
6
|
function newRequestId(sdkVersion) {
|
package/dist/auth/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { ReoptAuthClient, createReoptAuthClient } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
3
|
-
import '../chunk-
|
|
1
|
+
export { ReoptAuthClient, createReoptAuthClient } from '../chunk-POLKEOYH.js';
|
|
2
|
+
import '../chunk-N5JVE4WX.js';
|
|
3
|
+
import '../chunk-MRQY45U5.js';
|
|
4
4
|
|
|
5
5
|
// src/auth/session.ts
|
|
6
6
|
async function getSessionFromCookies(cookieHeader, opts) {
|
|
@@ -3,7 +3,7 @@ import { BetterAuthOptions, BetterAuthPlugin } from 'better-auth';
|
|
|
3
3
|
import { q as ReoptSDKConfig } from '../config-CtxyJsDR.js';
|
|
4
4
|
export { R as REOPT_BASE_URLS } from '../config-CtxyJsDR.js';
|
|
5
5
|
export { A as AdapterOperation, a as AdapterRequestBody, R as REOPT_DEFAULT_SCOPES, b as REOPT_PROVIDER_ID } from '../types-6E3ZLL9X.js';
|
|
6
|
-
export { A as AuthError, R as RateLimitError, g as ReoptSDKError, S as ServerError,
|
|
6
|
+
export { A as AuthError, R as RateLimitError, g as ReoptSDKError, S as ServerError, l as isReoptSDKError } from '../errors-DIAS8Rsl.js';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Reopt Better Auth Remote Database Adapter
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { REOPT_PROVIDER_ID, REOPT_DEFAULT_SCOPES } from '../chunk-REIKXSMY.js';
|
|
2
2
|
export { REOPT_DEFAULT_SCOPES, REOPT_PROVIDER_ID } from '../chunk-REIKXSMY.js';
|
|
3
|
-
import { BaseHttpClient } from '../chunk-
|
|
4
|
-
import { resolveIdBaseUrl } from '../chunk-
|
|
5
|
-
export { AuthError, REOPT_BASE_URLS, RateLimitError, ReoptSDKError, ServerError, isReoptSDKError } from '../chunk-
|
|
3
|
+
import { BaseHttpClient } from '../chunk-N5JVE4WX.js';
|
|
4
|
+
import { resolveIdBaseUrl } from '../chunk-MRQY45U5.js';
|
|
5
|
+
export { AuthError, REOPT_BASE_URLS, RateLimitError, ReoptSDKError, ServerError, isReoptSDKError } from '../chunk-MRQY45U5.js';
|
|
6
6
|
import { createAdapterFactory } from 'better-auth/adapters';
|
|
7
7
|
import { genericOAuth } from 'better-auth/plugins';
|
|
8
8
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { parseSSEStream } from './chunk-L4DHB36G.js';
|
|
2
2
|
import { createManagedAbort } from './chunk-F7BXBTZI.js';
|
|
3
|
-
import { BaseHttpClient } from './chunk-
|
|
4
|
-
import { validateConfig, ReoptSDKError, mapHttpStatusToError, SDK_VERSION } from './chunk-
|
|
3
|
+
import { BaseHttpClient } from './chunk-N5JVE4WX.js';
|
|
4
|
+
import { validateConfig, ReoptSDKError, mapHttpStatusToError, SDK_VERSION } from './chunk-MRQY45U5.js';
|
|
5
5
|
|
|
6
6
|
// src/ai/client.ts
|
|
7
7
|
var ReoptAiClient = class {
|
|
@@ -346,5 +346,5 @@ function createReoptAiClient(config) {
|
|
|
346
346
|
}
|
|
347
347
|
|
|
348
348
|
export { ReoptAiClient, createReoptAiClient };
|
|
349
|
-
//# sourceMappingURL=chunk-
|
|
350
|
-
//# sourceMappingURL=chunk-
|
|
349
|
+
//# sourceMappingURL=chunk-2Q654O63.js.map
|
|
350
|
+
//# sourceMappingURL=chunk-2Q654O63.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { buildQuery } from './chunk-
|
|
2
|
-
import { BaseHttpClient } from './chunk-
|
|
1
|
+
import { buildQuery } from './chunk-VRNBYSWU.js';
|
|
2
|
+
import { BaseHttpClient } from './chunk-N5JVE4WX.js';
|
|
3
3
|
|
|
4
4
|
// src/eav/cache.ts
|
|
5
5
|
var SchemaCache = class {
|
|
@@ -595,5 +595,5 @@ function createReoptEavClient(config) {
|
|
|
595
595
|
}
|
|
596
596
|
|
|
597
597
|
export { createReoptEavClient };
|
|
598
|
-
//# sourceMappingURL=chunk-
|
|
599
|
-
//# sourceMappingURL=chunk-
|
|
598
|
+
//# sourceMappingURL=chunk-IJOXTBIE.js.map
|
|
599
|
+
//# sourceMappingURL=chunk-IJOXTBIE.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createManagedAbort } from './chunk-F7BXBTZI.js';
|
|
2
|
-
import { BaseHttpClient, parseFieldErrors } from './chunk-
|
|
3
|
-
import { validateConfig, SDK_VERSION, mapHttpStatusToError, ReoptSDKError } from './chunk-
|
|
2
|
+
import { BaseHttpClient, parseFieldErrors } from './chunk-N5JVE4WX.js';
|
|
3
|
+
import { validateConfig, SDK_VERSION, mapHttpStatusToError, ReoptSDKError } from './chunk-MRQY45U5.js';
|
|
4
4
|
|
|
5
5
|
// src/files/client.ts
|
|
6
6
|
var ReoptFileClient = class {
|
|
@@ -153,5 +153,5 @@ function createReoptFileClient(config) {
|
|
|
153
153
|
}
|
|
154
154
|
|
|
155
155
|
export { ReoptFileClient, createReoptFileClient };
|
|
156
|
-
//# sourceMappingURL=chunk-
|
|
157
|
-
//# sourceMappingURL=chunk-
|
|
156
|
+
//# sourceMappingURL=chunk-JWXUVQRC.js.map
|
|
157
|
+
//# sourceMappingURL=chunk-JWXUVQRC.js.map
|
|
@@ -150,6 +150,21 @@ var LimitExceededError = class extends ReoptSDKError {
|
|
|
150
150
|
this.name = "LimitExceededError";
|
|
151
151
|
}
|
|
152
152
|
};
|
|
153
|
+
var RequiredTermsError = class extends ReoptSDKError {
|
|
154
|
+
missingTermsIds;
|
|
155
|
+
constructor(message = "\uD544\uC218 \uC57D\uAD00 \uB3D9\uC758\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4", missingTermsIds = [], context) {
|
|
156
|
+
super(message, 422, "REQUIRED_TERMS", context, {
|
|
157
|
+
cause: "\uC774 \uD50C\uB79C \uAD6C\uB3C5 \uC804\uC5D0 \uB3D9\uC758\uD574\uC57C \uD558\uB294 \uD544\uC218 \uC57D\uAD00\uC774 \uB0A8\uC544 \uC788\uC74C",
|
|
158
|
+
fix: "sdk.terms.list()\uB85C \uC57D\uAD00\uC744 \uC870\uD68C\uD558\uACE0 sdk.terms.consent()\uB85C \uB3D9\uC758\uD55C \uB4A4 \uB2E4\uC2DC \uACB0\uC81C\uB97C \uC2DC\uC791",
|
|
159
|
+
doc: "docs/errors.md#required_terms"
|
|
160
|
+
});
|
|
161
|
+
this.name = "RequiredTermsError";
|
|
162
|
+
this.missingTermsIds = missingTermsIds;
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
function isRequiredTermsError(error) {
|
|
166
|
+
return error instanceof Error && error.name === "RequiredTermsError" && "missingTermsIds" in error;
|
|
167
|
+
}
|
|
153
168
|
var ValidationError = class extends ReoptSDKError {
|
|
154
169
|
fieldErrors;
|
|
155
170
|
constructor(message, fieldErrors, context) {
|
|
@@ -241,6 +256,13 @@ function mapHttpStatusToError(status, code, message, ctx, fieldErrors) {
|
|
|
241
256
|
}
|
|
242
257
|
return new ConflictError(message ?? "Conflict", ctx, code ?? "CONFLICT");
|
|
243
258
|
case 422:
|
|
259
|
+
if (code === "REQUIRED_TERMS") {
|
|
260
|
+
return new RequiredTermsError(
|
|
261
|
+
message ?? "\uD544\uC218 \uC57D\uAD00 \uB3D9\uC758\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4",
|
|
262
|
+
(fieldErrors ?? []).map((f) => f.field),
|
|
263
|
+
ctx
|
|
264
|
+
);
|
|
265
|
+
}
|
|
244
266
|
if (fieldErrors && fieldErrors.length > 0) {
|
|
245
267
|
return new ValidationError(
|
|
246
268
|
message ?? "Validation failed",
|
|
@@ -290,7 +312,7 @@ function mapHttpStatusToError(status, code, message, ctx, fieldErrors) {
|
|
|
290
312
|
}
|
|
291
313
|
|
|
292
314
|
// src/core/config.ts
|
|
293
|
-
var SDK_VERSION = "3.
|
|
315
|
+
var SDK_VERSION = "3.1.0" ;
|
|
294
316
|
var REOPT_BASE_URLS = {
|
|
295
317
|
production: "https://brandapp.reopt.ai",
|
|
296
318
|
development: "https://brand.reopt.de:3443"
|
|
@@ -438,6 +460,6 @@ function createAuthHeader(config) {
|
|
|
438
460
|
);
|
|
439
461
|
}
|
|
440
462
|
|
|
441
|
-
export { AuthError, AuthUserNotFoundError, AuthUserRecordExistsError, BadRequestError, ConflictError, ContentFilterError, CreditLimitError, DuplicateAuthUserError, ForbiddenError, LimitExceededError, ModelAccessError, ModelNotFoundError, NotFoundError, REOPT_BASE_URLS, RateLimitError, ReoptSDKError, SDK_VERSION, ServerError, ValidationError, assertBrowserSafe, createAuthHeader, isCreditLimitError, isModelAccessError, isReoptSDKError, isValidationError, mapHttpStatusToError, resolveBaseUrl, resolveIdBaseUrl, validateConfig };
|
|
442
|
-
//# sourceMappingURL=chunk-
|
|
443
|
-
//# sourceMappingURL=chunk-
|
|
463
|
+
export { AuthError, AuthUserNotFoundError, AuthUserRecordExistsError, BadRequestError, ConflictError, ContentFilterError, CreditLimitError, DuplicateAuthUserError, ForbiddenError, LimitExceededError, ModelAccessError, ModelNotFoundError, NotFoundError, REOPT_BASE_URLS, RateLimitError, ReoptSDKError, RequiredTermsError, SDK_VERSION, ServerError, ValidationError, assertBrowserSafe, createAuthHeader, isCreditLimitError, isModelAccessError, isReoptSDKError, isRequiredTermsError, isValidationError, mapHttpStatusToError, resolveBaseUrl, resolveIdBaseUrl, validateConfig };
|
|
464
|
+
//# sourceMappingURL=chunk-MRQY45U5.js.map
|
|
465
|
+
//# sourceMappingURL=chunk-MRQY45U5.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { validateConfig, resolveIdBaseUrl, resolveBaseUrl, createAuthHeader, SDK_VERSION, mapHttpStatusToError, ReoptSDKError, RateLimitError, ServerError } from './chunk-
|
|
1
|
+
import { validateConfig, resolveIdBaseUrl, resolveBaseUrl, createAuthHeader, SDK_VERSION, mapHttpStatusToError, ReoptSDKError, RateLimitError, ServerError } from './chunk-MRQY45U5.js';
|
|
2
2
|
|
|
3
3
|
// src/core/debug.ts
|
|
4
4
|
function resolveLevel(configDebug) {
|
|
@@ -445,5 +445,5 @@ function parseFieldErrors(body) {
|
|
|
445
445
|
}
|
|
446
446
|
|
|
447
447
|
export { BaseHttpClient, parseFieldErrors };
|
|
448
|
-
//# sourceMappingURL=chunk-
|
|
449
|
-
//# sourceMappingURL=chunk-
|
|
448
|
+
//# sourceMappingURL=chunk-N5JVE4WX.js.map
|
|
449
|
+
//# sourceMappingURL=chunk-N5JVE4WX.js.map
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { BaseHttpClient } from './chunk-N5JVE4WX.js';
|
|
2
|
+
|
|
3
|
+
// src/plans/client.ts
|
|
4
|
+
function unwrap(body) {
|
|
5
|
+
if (body && typeof body === "object" && "data" in body) {
|
|
6
|
+
const withData = body;
|
|
7
|
+
if (withData.data !== void 0) return withData.data;
|
|
8
|
+
}
|
|
9
|
+
return body;
|
|
10
|
+
}
|
|
11
|
+
var ReoptPlansClient = class {
|
|
12
|
+
http;
|
|
13
|
+
constructor(config) {
|
|
14
|
+
this.http = new BaseHttpClient(
|
|
15
|
+
config,
|
|
16
|
+
`/api/v1/brandapp/${config.brandappId}/plans`
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* List active plans for this Brandapp (the customer-facing catalog). Works
|
|
21
|
+
* with either Basic Auth (default) or Bearer Auth — pass `accessToken` when
|
|
22
|
+
* calling from a handler that already has the customer's OAuth token to avoid
|
|
23
|
+
* sending app credentials.
|
|
24
|
+
*/
|
|
25
|
+
async list(accessToken) {
|
|
26
|
+
const body = await this.http.fetch(
|
|
27
|
+
"GET",
|
|
28
|
+
"",
|
|
29
|
+
void 0,
|
|
30
|
+
accessToken ? { bearerToken: accessToken } : void 0
|
|
31
|
+
);
|
|
32
|
+
return unwrap(body);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Fetch the current plan / entitlement for the OAuth customer represented by
|
|
36
|
+
* `accessToken`. Returns `null` when the customer has no active plan.
|
|
37
|
+
*/
|
|
38
|
+
async getMyPlan(accessToken) {
|
|
39
|
+
const body = await this.http.fetch(
|
|
40
|
+
"GET",
|
|
41
|
+
"/me/plan",
|
|
42
|
+
void 0,
|
|
43
|
+
{ bearerToken: accessToken }
|
|
44
|
+
);
|
|
45
|
+
return unwrap(body);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Start a hosted checkout to subscribe the current customer (identified by
|
|
49
|
+
* `accessToken`) to `input.planId`, then redirect the browser to the returned
|
|
50
|
+
* `checkoutUrl`. In sandbox mode that URL is a virtual-payment page on
|
|
51
|
+
* id.reopt.ai which activates the subscription and returns to your
|
|
52
|
+
* `successUrl` / `cancelUrl`.
|
|
53
|
+
*
|
|
54
|
+
* @throws {RequiredTermsError} when the plan has required terms the customer
|
|
55
|
+
* has not consented to. Read `missingTermsIds`, collect consent via
|
|
56
|
+
* `sdk.terms`, then call again.
|
|
57
|
+
* @throws {ReoptSDKError} `LIVE_MODE_UNSUPPORTED` (409) when the Brandapp is
|
|
58
|
+
* configured for live Toss/Paddle payments (use the brandfront checkout).
|
|
59
|
+
*/
|
|
60
|
+
async createCheckout(input, accessToken) {
|
|
61
|
+
const body = await this.http.fetch(
|
|
62
|
+
"POST",
|
|
63
|
+
"/me/checkout",
|
|
64
|
+
input,
|
|
65
|
+
{ bearerToken: accessToken }
|
|
66
|
+
);
|
|
67
|
+
return unwrap(body);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Poll a checkout session by id (e.g. on your return page) to read its
|
|
71
|
+
* `status` — `completed` means the subscription is active. `checkoutUrl` is
|
|
72
|
+
* `null` here; use the URL from {@link createCheckout} to re-redirect.
|
|
73
|
+
*/
|
|
74
|
+
async getCheckout(checkoutId, accessToken) {
|
|
75
|
+
const body = await this.http.fetch(
|
|
76
|
+
"GET",
|
|
77
|
+
`/me/checkout/${encodeURIComponent(checkoutId)}`,
|
|
78
|
+
void 0,
|
|
79
|
+
{ bearerToken: accessToken }
|
|
80
|
+
);
|
|
81
|
+
return unwrap(body);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Cancel the current customer's active **sandbox** subscription. Access is
|
|
85
|
+
* kept until the paid period ends (the billing state becomes `canceled`).
|
|
86
|
+
* Real Toss/Paddle subscriptions are not affected — those use the provider
|
|
87
|
+
* flow.
|
|
88
|
+
*/
|
|
89
|
+
async cancel(accessToken) {
|
|
90
|
+
const body = await this.http.fetch(
|
|
91
|
+
"POST",
|
|
92
|
+
"/me/subscription/cancel",
|
|
93
|
+
{},
|
|
94
|
+
{ bearerToken: accessToken }
|
|
95
|
+
);
|
|
96
|
+
return unwrap(body);
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
function createReoptPlansClient(config) {
|
|
100
|
+
return new ReoptPlansClient(config);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export { ReoptPlansClient, createReoptPlansClient };
|
|
104
|
+
//# sourceMappingURL=chunk-O3PUWIDJ.js.map
|
|
105
|
+
//# sourceMappingURL=chunk-O3PUWIDJ.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseHttpClient } from './chunk-
|
|
1
|
+
import { BaseHttpClient } from './chunk-N5JVE4WX.js';
|
|
2
2
|
|
|
3
3
|
// src/auth/client.ts
|
|
4
4
|
function unwrap(body) {
|
|
@@ -59,5 +59,5 @@ function createReoptAuthClient(config) {
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
export { ReoptAuthClient, createReoptAuthClient };
|
|
62
|
-
//# sourceMappingURL=chunk-
|
|
63
|
-
//# sourceMappingURL=chunk-
|
|
62
|
+
//# sourceMappingURL=chunk-POLKEOYH.js.map
|
|
63
|
+
//# sourceMappingURL=chunk-POLKEOYH.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseHttpClient } from './chunk-
|
|
1
|
+
import { BaseHttpClient } from './chunk-N5JVE4WX.js';
|
|
2
2
|
|
|
3
3
|
// src/push/client.ts
|
|
4
4
|
var ReoptPushClient = class {
|
|
@@ -45,5 +45,5 @@ function createReoptPushClient(config) {
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
export { ReoptPushClient, createReoptPushClient };
|
|
48
|
-
//# sourceMappingURL=chunk-
|
|
49
|
-
//# sourceMappingURL=chunk-
|
|
48
|
+
//# sourceMappingURL=chunk-R5CCGDUH.js.map
|
|
49
|
+
//# sourceMappingURL=chunk-R5CCGDUH.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseHttpClient } from './chunk-
|
|
1
|
+
import { BaseHttpClient } from './chunk-N5JVE4WX.js';
|
|
2
2
|
|
|
3
3
|
// src/feedback/client.ts
|
|
4
4
|
function buildListQuery(query) {
|
|
@@ -92,5 +92,5 @@ function createReoptFeedbackClient(config) {
|
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
export { ReoptFeedbackClient, createReoptFeedbackClient };
|
|
95
|
-
//# sourceMappingURL=chunk-
|
|
96
|
-
//# sourceMappingURL=chunk-
|
|
95
|
+
//# sourceMappingURL=chunk-RBHP7IZF.js.map
|
|
96
|
+
//# sourceMappingURL=chunk-RBHP7IZF.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseHttpClient } from './chunk-
|
|
1
|
+
import { BaseHttpClient } from './chunk-N5JVE4WX.js';
|
|
2
2
|
|
|
3
3
|
// src/terms/client.ts
|
|
4
4
|
function unwrap(body) {
|
|
@@ -108,5 +108,5 @@ function createReoptTermsClient(config) {
|
|
|
108
108
|
}
|
|
109
109
|
|
|
110
110
|
export { ReoptTermsClient, createReoptTermsClient };
|
|
111
|
-
//# sourceMappingURL=chunk-
|
|
112
|
-
//# sourceMappingURL=chunk-
|
|
111
|
+
//# sourceMappingURL=chunk-T7YTITRJ.js.map
|
|
112
|
+
//# sourceMappingURL=chunk-T7YTITRJ.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { buildQuery } from './chunk-
|
|
2
|
-
import { BaseHttpClient } from './chunk-
|
|
1
|
+
import { buildQuery } from './chunk-VRNBYSWU.js';
|
|
2
|
+
import { BaseHttpClient } from './chunk-N5JVE4WX.js';
|
|
3
3
|
|
|
4
4
|
// src/cms/client.ts
|
|
5
5
|
function createReoptCmsClient(config) {
|
|
@@ -77,5 +77,5 @@ function createReoptCmsClient(config) {
|
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
export { createReoptCmsClient };
|
|
80
|
-
//# sourceMappingURL=chunk-
|
|
81
|
-
//# sourceMappingURL=chunk-
|
|
80
|
+
//# sourceMappingURL=chunk-V73GORO3.js.map
|
|
81
|
+
//# sourceMappingURL=chunk-V73GORO3.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ReoptSDKError } from './chunk-
|
|
1
|
+
import { ReoptSDKError } from './chunk-MRQY45U5.js';
|
|
2
2
|
|
|
3
3
|
// src/core/query.ts
|
|
4
4
|
var MAX_QUERY_STRING_LENGTH = 7500;
|
|
@@ -28,5 +28,5 @@ function buildQuery(params) {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
export { buildQuery };
|
|
31
|
-
//# sourceMappingURL=chunk-
|
|
32
|
-
//# sourceMappingURL=chunk-
|
|
31
|
+
//# sourceMappingURL=chunk-VRNBYSWU.js.map
|
|
32
|
+
//# sourceMappingURL=chunk-VRNBYSWU.js.map
|
package/dist/cms/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { createReoptCmsClient } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
3
|
-
import '../chunk-
|
|
4
|
-
import '../chunk-
|
|
1
|
+
export { createReoptCmsClient } from '../chunk-V73GORO3.js';
|
|
2
|
+
import '../chunk-VRNBYSWU.js';
|
|
3
|
+
import '../chunk-N5JVE4WX.js';
|
|
4
|
+
import '../chunk-MRQY45U5.js';
|
|
5
5
|
|
|
6
6
|
// src/cms/helpers.ts
|
|
7
7
|
function joinUrl(siteUrl, path) {
|
package/dist/eav/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export { c as createReoptEavClient } from '../client-BkcO-0C2.js';
|
|
|
3
3
|
import { a as AttributeFilter } from '../config-CtxyJsDR.js';
|
|
4
4
|
export { b as AttributeFilterOperator, d as BulkUpdateItem, C as CountRecordsQuery, e as CreateAttributeInput, f as CreateEntityInput, g as CreateRecordInput, i as DeleteWhereInput, E as EavAttribute, j as EavAttributeOption, k as EavDataType, l as EavEntity, m as EavRecord, n as EavSchemaLinkedTo, o as EavValidation, L as ListRecordsQuery, P as PaginatedResponse, q as ReoptSDKConfig, U as UpdateAttributeInput, r as UpdateEntityInput, s as UpdateRecordInput, t as UpsertRecordInput, u as UpsertRecordResult } from '../config-CtxyJsDR.js';
|
|
5
5
|
export { E as EntityClient, T as TypedEavRecord } from '../typed-client-BxOVIiMU.js';
|
|
6
|
-
export { a as AuthUserNotFoundError, b as AuthUserRecordExistsError, D as DuplicateAuthUserError, L as LimitExceededError } from '../errors-
|
|
6
|
+
export { a as AuthUserNotFoundError, b as AuthUserRecordExistsError, D as DuplicateAuthUserError, L as LimitExceededError } from '../errors-DIAS8Rsl.js';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Runtime drift check between a deployed bundle and the live server schema
|
package/dist/eav/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { createReoptEavClient } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
3
|
-
import '../chunk-
|
|
4
|
-
export { AuthUserNotFoundError, AuthUserRecordExistsError, DuplicateAuthUserError, LimitExceededError } from '../chunk-
|
|
1
|
+
export { createReoptEavClient } from '../chunk-IJOXTBIE.js';
|
|
2
|
+
import '../chunk-VRNBYSWU.js';
|
|
3
|
+
import '../chunk-N5JVE4WX.js';
|
|
4
|
+
export { AuthUserNotFoundError, AuthUserRecordExistsError, DuplicateAuthUserError, LimitExceededError } from '../chunk-MRQY45U5.js';
|
|
5
5
|
|
|
6
6
|
// src/eav/verify.ts
|
|
7
7
|
async function verifyEavSchema(input) {
|
|
@@ -89,6 +89,28 @@ declare class AuthUserNotFoundError extends ReoptSDKError {
|
|
|
89
89
|
declare class LimitExceededError extends ReoptSDKError {
|
|
90
90
|
constructor(message: string, code: "LIMIT_EXCEEDED_ENTITIES" | "LIMIT_EXCEEDED_ATTRIBUTES" | "LIMIT_EXCEEDED_RECORDS", context?: ReoptSDKErrorContext);
|
|
91
91
|
}
|
|
92
|
+
/**
|
|
93
|
+
* 플랜 구독(checkout) 전에 동의해야 하는 필수 약관이 미동의 상태 (HTTP 422,
|
|
94
|
+
* `REQUIRED_TERMS`). `missingTermsIds`로 어떤 약관에 동의가 필요한지 알 수 있다 —
|
|
95
|
+
* `sdk.terms.list()` + `sdk.terms.consent()`로 동의를 수집한 뒤 checkout을 재시도한다.
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* ```ts
|
|
99
|
+
* try {
|
|
100
|
+
* await sdk.plans.createCheckout({ planId, successUrl, cancelUrl }, token);
|
|
101
|
+
* } catch (e) {
|
|
102
|
+
* if (isRequiredTermsError(e)) {
|
|
103
|
+
* // e.missingTermsIds 에 해당하는 약관 동의 UI를 띄운다
|
|
104
|
+
* }
|
|
105
|
+
* }
|
|
106
|
+
* ```
|
|
107
|
+
*/
|
|
108
|
+
declare class RequiredTermsError extends ReoptSDKError {
|
|
109
|
+
readonly missingTermsIds: string[];
|
|
110
|
+
constructor(message?: string, missingTermsIds?: string[], context?: ReoptSDKErrorContext);
|
|
111
|
+
}
|
|
112
|
+
/** Bundle-safe type guard for RequiredTermsError */
|
|
113
|
+
declare function isRequiredTermsError(error: unknown): error is RequiredTermsError;
|
|
92
114
|
/** 필드 수준 검증 에러 */
|
|
93
115
|
type FieldError = {
|
|
94
116
|
/** 필드 이름 (attribute name) */
|
|
@@ -155,4 +177,4 @@ declare function isModelAccessError(error: unknown): error is ModelAccessError;
|
|
|
155
177
|
*/
|
|
156
178
|
declare function mapHttpStatusToError(status: number, code: string | undefined, message: string | undefined, ctx?: ReoptSDKErrorContext, fieldErrors?: FieldError[]): ReoptSDKError;
|
|
157
179
|
|
|
158
|
-
export { AuthError as A, BadRequestError as B, ConflictError as C, DuplicateAuthUserError as D, type ErrorDiagnostic as E, type FieldError as F, LimitExceededError as L, ModelAccessError as M, NotFoundError as N, RateLimitError as R, ServerError as S, ValidationError as V, AuthUserNotFoundError as a, AuthUserRecordExistsError as b, ContentFilterError as c, CreditLimitError as d, ForbiddenError as e, ModelNotFoundError as f, ReoptSDKError as g, type ReoptSDKErrorContext as h,
|
|
180
|
+
export { AuthError as A, BadRequestError as B, ConflictError as C, DuplicateAuthUserError as D, type ErrorDiagnostic as E, type FieldError as F, LimitExceededError as L, ModelAccessError as M, NotFoundError as N, RateLimitError as R, ServerError as S, ValidationError as V, AuthUserNotFoundError as a, AuthUserRecordExistsError as b, ContentFilterError as c, CreditLimitError as d, ForbiddenError as e, ModelNotFoundError as f, ReoptSDKError as g, type ReoptSDKErrorContext as h, RequiredTermsError as i, isCreditLimitError as j, isModelAccessError as k, isReoptSDKError as l, isRequiredTermsError as m, isValidationError as n, mapHttpStatusToError as o };
|
package/dist/feedback/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { ReoptFeedbackClient, createReoptFeedbackClient } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
3
|
-
import '../chunk-
|
|
1
|
+
export { ReoptFeedbackClient, createReoptFeedbackClient } from '../chunk-RBHP7IZF.js';
|
|
2
|
+
import '../chunk-N5JVE4WX.js';
|
|
3
|
+
import '../chunk-MRQY45U5.js';
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
|
5
5
|
//# sourceMappingURL=index.js.map
|
package/dist/files/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { ReoptFileClient, createReoptFileClient } from '../chunk-
|
|
1
|
+
export { ReoptFileClient, createReoptFileClient } from '../chunk-JWXUVQRC.js';
|
|
2
2
|
import '../chunk-F7BXBTZI.js';
|
|
3
|
-
import '../chunk-
|
|
4
|
-
import '../chunk-
|
|
3
|
+
import '../chunk-N5JVE4WX.js';
|
|
4
|
+
import '../chunk-MRQY45U5.js';
|
|
5
5
|
|
|
6
6
|
// src/files/helpers.ts
|
|
7
7
|
var REOPT_IMAGE_REMOTE_PATTERNS = [
|
package/dist/index.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ import { a as ListPostsQuery, C as CmsPaginatedResponse, P as Post, c as PostDet
|
|
|
9
9
|
import { R as ReoptAuthClient } from './client-DttyeM_h.js';
|
|
10
10
|
import { ReoptAiClient } from './ai/index.js';
|
|
11
11
|
export { AgentInfo, ChatMessage, CompletionOptions, CompletionResult, CreditInfo, FinishReason, ImageGenerateOptions, ImageGenerateResult, MessageRole, ModelInfo, StreamDoneData, StreamEvent } from './ai/index.js';
|
|
12
|
-
export { A as AuthError, a as AuthUserNotFoundError, b as AuthUserRecordExistsError, B as BadRequestError, C as ConflictError, c as ContentFilterError, d as CreditLimitError, D as DuplicateAuthUserError, E as ErrorDiagnostic, F as FieldError, e as ForbiddenError, L as LimitExceededError, M as ModelAccessError, f as ModelNotFoundError, N as NotFoundError, R as RateLimitError, g as ReoptSDKError, h as ReoptSDKErrorContext, S as ServerError, V as ValidationError,
|
|
12
|
+
export { A as AuthError, a as AuthUserNotFoundError, b as AuthUserRecordExistsError, B as BadRequestError, C as ConflictError, c as ContentFilterError, d as CreditLimitError, D as DuplicateAuthUserError, E as ErrorDiagnostic, F as FieldError, e as ForbiddenError, L as LimitExceededError, M as ModelAccessError, f as ModelNotFoundError, N as NotFoundError, R as RateLimitError, g as ReoptSDKError, h as ReoptSDKErrorContext, i as RequiredTermsError, S as ServerError, V as ValidationError, j as isCreditLimitError, k as isModelAccessError, l as isReoptSDKError, m as isRequiredTermsError, n as isValidationError, o as mapHttpStatusToError } from './errors-DIAS8Rsl.js';
|
|
13
13
|
import { E as EntityClient } from './typed-client-BxOVIiMU.js';
|
|
14
14
|
export { T as TypedEavRecord } from './typed-client-BxOVIiMU.js';
|
|
15
15
|
import './types-DskYLVb8.js';
|
package/dist/index.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { createReoptPushClient } from './chunk-
|
|
2
|
-
import { createReoptTermsClient } from './chunk-
|
|
3
|
-
import { createReoptEavClient } from './chunk-
|
|
4
|
-
import { createReoptFeedbackClient } from './chunk-
|
|
5
|
-
import { createReoptFileClient } from './chunk-
|
|
6
|
-
import { createReoptPlansClient } from './chunk-
|
|
7
|
-
import { createReoptAiClient } from './chunk-
|
|
1
|
+
import { createReoptPushClient } from './chunk-R5CCGDUH.js';
|
|
2
|
+
import { createReoptTermsClient } from './chunk-T7YTITRJ.js';
|
|
3
|
+
import { createReoptEavClient } from './chunk-IJOXTBIE.js';
|
|
4
|
+
import { createReoptFeedbackClient } from './chunk-RBHP7IZF.js';
|
|
5
|
+
import { createReoptFileClient } from './chunk-JWXUVQRC.js';
|
|
6
|
+
import { createReoptPlansClient } from './chunk-O3PUWIDJ.js';
|
|
7
|
+
import { createReoptAiClient } from './chunk-2Q654O63.js';
|
|
8
8
|
import './chunk-L4DHB36G.js';
|
|
9
9
|
import './chunk-F7BXBTZI.js';
|
|
10
|
-
import { createReoptAuthClient } from './chunk-
|
|
11
|
-
import { createReoptCmsClient } from './chunk-
|
|
12
|
-
import './chunk-
|
|
13
|
-
export { BaseHttpClient } from './chunk-
|
|
14
|
-
import { assertBrowserSafe } from './chunk-
|
|
15
|
-
export { AuthError, AuthUserNotFoundError, AuthUserRecordExistsError, BadRequestError, ConflictError, ContentFilterError, CreditLimitError, DuplicateAuthUserError, ForbiddenError, LimitExceededError, ModelAccessError, ModelNotFoundError, NotFoundError, REOPT_BASE_URLS, RateLimitError, ReoptSDKError, ServerError, ValidationError, isCreditLimitError, isModelAccessError, isReoptSDKError, isValidationError, mapHttpStatusToError, resolveBaseUrl } from './chunk-
|
|
10
|
+
import { createReoptAuthClient } from './chunk-POLKEOYH.js';
|
|
11
|
+
import { createReoptCmsClient } from './chunk-V73GORO3.js';
|
|
12
|
+
import './chunk-VRNBYSWU.js';
|
|
13
|
+
export { BaseHttpClient } from './chunk-N5JVE4WX.js';
|
|
14
|
+
import { assertBrowserSafe } from './chunk-MRQY45U5.js';
|
|
15
|
+
export { AuthError, AuthUserNotFoundError, AuthUserRecordExistsError, BadRequestError, ConflictError, ContentFilterError, CreditLimitError, DuplicateAuthUserError, ForbiddenError, LimitExceededError, ModelAccessError, ModelNotFoundError, NotFoundError, REOPT_BASE_URLS, RateLimitError, ReoptSDKError, RequiredTermsError, ServerError, ValidationError, isCreditLimitError, isModelAccessError, isReoptSDKError, isRequiredTermsError, isValidationError, mapHttpStatusToError, resolveBaseUrl } from './chunk-MRQY45U5.js';
|
|
16
16
|
|
|
17
17
|
// src/singleton.ts
|
|
18
18
|
var _instance;
|
package/dist/plans/index.d.ts
CHANGED
|
@@ -65,6 +65,53 @@ type Plan = {
|
|
|
65
65
|
/** 구독 전에 동의가 필요한 필수 약관. `sdk.terms`로 본문 조회·동의. */
|
|
66
66
|
requiredTerms: PlanRequiredTerms[];
|
|
67
67
|
};
|
|
68
|
+
/** Prisma `BrandappCheckoutStatus`. */
|
|
69
|
+
type CheckoutStatus = "pending" | "completed" | "canceled" | "expired" | "failed";
|
|
70
|
+
/** `plans.createCheckout` 입력. */
|
|
71
|
+
type CreateCheckoutInput = {
|
|
72
|
+
/** 구독할 플랜 ID (`plans.list()`가 반환하는 `Plan.id`). */
|
|
73
|
+
planId: string;
|
|
74
|
+
/**
|
|
75
|
+
* 결제 성공 후 고객을 돌려보낼 **절대** URL (내 앱의 복귀 페이지). 이 브랜드앱
|
|
76
|
+
* OAuth 클라이언트에 등록된 redirect URI와 동일 origin이거나 reopt 호스트여야 한다.
|
|
77
|
+
*/
|
|
78
|
+
successUrl: string;
|
|
79
|
+
/** 결제 취소 시 돌려보낼 절대 URL (successUrl과 동일 검증). */
|
|
80
|
+
cancelUrl: string;
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* hosted-checkout 세션.
|
|
84
|
+
*
|
|
85
|
+
* `createCheckout`가 반환하면 `checkoutUrl`로 브라우저를 리다이렉트한다. 샌드박스
|
|
86
|
+
* 모드에서 이 URL은 id.reopt.ai의 가상 결제 페이지이며, 결제를 승인하면 구독이
|
|
87
|
+
* 활성화되고 `successUrl`(취소 시 `cancelUrl`)로 복귀한다. 복귀 후
|
|
88
|
+
* `getCheckout(checkoutId)` 또는 `getMyPlan(token)`으로 결과를 확인한다.
|
|
89
|
+
*/
|
|
90
|
+
type CheckoutSession = {
|
|
91
|
+
checkoutId: string;
|
|
92
|
+
/**
|
|
93
|
+
* 브라우저를 리다이렉트할 결제 URL. `createCheckout` 응답에만 존재하고
|
|
94
|
+
* `getCheckout` 응답에서는 `null`이다(capability token 재노출 방지).
|
|
95
|
+
*/
|
|
96
|
+
checkoutUrl: string | null;
|
|
97
|
+
/** 결제 제공자 — 현재 "sandbox"(가상 결제). */
|
|
98
|
+
provider: string;
|
|
99
|
+
status: CheckoutStatus | string;
|
|
100
|
+
planId: string;
|
|
101
|
+
planName: string;
|
|
102
|
+
/** 결제 금액 (통화 최소 단위 정수). */
|
|
103
|
+
amount: number;
|
|
104
|
+
currency: string;
|
|
105
|
+
interval: PlanInterval | string;
|
|
106
|
+
/** ISO-8601 만료 시각 (pending 세션 TTL). */
|
|
107
|
+
expiresAt: string;
|
|
108
|
+
/** ISO-8601 완료 시각. 미완료면 `null`. */
|
|
109
|
+
completedAt: string | null;
|
|
110
|
+
};
|
|
111
|
+
/** `plans.cancel` 결과. */
|
|
112
|
+
type CancelSubscriptionResult = {
|
|
113
|
+
status: "canceled";
|
|
114
|
+
};
|
|
68
115
|
/**
|
|
69
116
|
* 현재 로그인 고객의 구독 플랜 + 엔타이틀먼트.
|
|
70
117
|
*
|
|
@@ -90,19 +137,28 @@ type CurrentPlan = {
|
|
|
90
137
|
};
|
|
91
138
|
|
|
92
139
|
/**
|
|
93
|
-
* Brandapp Plans client
|
|
94
|
-
*
|
|
95
|
-
* Lets a Brandapp read the subscription plans it offers to its own customers,
|
|
96
|
-
* and the signed-in customer's current plan / entitlement.
|
|
140
|
+
* Brandapp Plans client — read the plan catalog, the current customer's plan,
|
|
141
|
+
* and drive a hosted checkout to subscribe & pay.
|
|
97
142
|
*
|
|
98
143
|
* - `list()` — Basic or Bearer. Active plans (catalog).
|
|
99
144
|
* - `getMyPlan(accessToken)` — Bearer. The current customer's plan, or `null`.
|
|
145
|
+
* - `createCheckout(input, accessToken)` — Bearer. Start a hosted checkout;
|
|
146
|
+
* redirect the browser to the returned `checkoutUrl`.
|
|
147
|
+
* - `getCheckout(checkoutId, accessToken)` — Bearer. Poll a checkout session.
|
|
148
|
+
* - `cancel(accessToken)` — Bearer. Cancel the current sandbox subscription.
|
|
100
149
|
*
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
*
|
|
150
|
+
* ### Sandbox checkout (payment disabled)
|
|
151
|
+
* When the Brandapp has real payment disabled (the default), `createCheckout`
|
|
152
|
+
* returns a **sandbox** `checkoutUrl` — a virtual-payment page on id.reopt.ai
|
|
153
|
+
* that activates the subscription without any real charge and redirects back to
|
|
154
|
+
* your `successUrl`/`cancelUrl`. This is the built-in way to build and test the
|
|
155
|
+
* full "list → subscribe → pay → entitlement" flow with no Toss/Paddle setup.
|
|
156
|
+
*
|
|
157
|
+
* ⚠️ Live Toss/Paddle checkout is **not** driven through the SDK yet (it needs
|
|
158
|
+
* the provider browser SDK + host callbacks and stays in the first-party
|
|
159
|
+
* brandfront flow) — `createCheckout` returns HTTP 409 `LIVE_MODE_UNSUPPORTED`
|
|
160
|
+
* when the Brandapp is set to live payments. usage-model meters remain
|
|
161
|
+
* read-only metadata (usage billing not implemented).
|
|
106
162
|
*
|
|
107
163
|
* @example
|
|
108
164
|
* ```ts
|
|
@@ -111,7 +167,20 @@ type CurrentPlan = {
|
|
|
111
167
|
* // Render the plan catalog (no user context required):
|
|
112
168
|
* const plans = await sdk.plans.list();
|
|
113
169
|
*
|
|
114
|
-
* // After the customer signs in via OAuth:
|
|
170
|
+
* // After the customer signs in via OAuth, subscribe & pay:
|
|
171
|
+
* try {
|
|
172
|
+
* const checkout = await sdk.plans.createCheckout(
|
|
173
|
+
* { planId: plans[0].id, successUrl, cancelUrl },
|
|
174
|
+
* accessToken,
|
|
175
|
+
* );
|
|
176
|
+
* redirect(checkout.checkoutUrl!); // → sandbox payment page, then back to successUrl
|
|
177
|
+
* } catch (e) {
|
|
178
|
+
* if (isRequiredTermsError(e)) {
|
|
179
|
+
* // collect consent for e.missingTermsIds via sdk.terms, then retry
|
|
180
|
+
* }
|
|
181
|
+
* }
|
|
182
|
+
*
|
|
183
|
+
* // On the return page, confirm the entitlement:
|
|
115
184
|
* const current = await sdk.plans.getMyPlan(accessToken);
|
|
116
185
|
* if (current?.subscriptionStatus === "active") {
|
|
117
186
|
* // grant entitlement…
|
|
@@ -134,7 +203,34 @@ declare class ReoptPlansClient {
|
|
|
134
203
|
* `accessToken`. Returns `null` when the customer has no active plan.
|
|
135
204
|
*/
|
|
136
205
|
getMyPlan(accessToken: string): Promise<CurrentPlan | null>;
|
|
206
|
+
/**
|
|
207
|
+
* Start a hosted checkout to subscribe the current customer (identified by
|
|
208
|
+
* `accessToken`) to `input.planId`, then redirect the browser to the returned
|
|
209
|
+
* `checkoutUrl`. In sandbox mode that URL is a virtual-payment page on
|
|
210
|
+
* id.reopt.ai which activates the subscription and returns to your
|
|
211
|
+
* `successUrl` / `cancelUrl`.
|
|
212
|
+
*
|
|
213
|
+
* @throws {RequiredTermsError} when the plan has required terms the customer
|
|
214
|
+
* has not consented to. Read `missingTermsIds`, collect consent via
|
|
215
|
+
* `sdk.terms`, then call again.
|
|
216
|
+
* @throws {ReoptSDKError} `LIVE_MODE_UNSUPPORTED` (409) when the Brandapp is
|
|
217
|
+
* configured for live Toss/Paddle payments (use the brandfront checkout).
|
|
218
|
+
*/
|
|
219
|
+
createCheckout(input: CreateCheckoutInput, accessToken: string): Promise<CheckoutSession>;
|
|
220
|
+
/**
|
|
221
|
+
* Poll a checkout session by id (e.g. on your return page) to read its
|
|
222
|
+
* `status` — `completed` means the subscription is active. `checkoutUrl` is
|
|
223
|
+
* `null` here; use the URL from {@link createCheckout} to re-redirect.
|
|
224
|
+
*/
|
|
225
|
+
getCheckout(checkoutId: string, accessToken: string): Promise<CheckoutSession>;
|
|
226
|
+
/**
|
|
227
|
+
* Cancel the current customer's active **sandbox** subscription. Access is
|
|
228
|
+
* kept until the paid period ends (the billing state becomes `canceled`).
|
|
229
|
+
* Real Toss/Paddle subscriptions are not affected — those use the provider
|
|
230
|
+
* flow.
|
|
231
|
+
*/
|
|
232
|
+
cancel(accessToken: string): Promise<CancelSubscriptionResult>;
|
|
137
233
|
}
|
|
138
234
|
declare function createReoptPlansClient(config: ReoptSDKConfig): ReoptPlansClient;
|
|
139
235
|
|
|
140
|
-
export { type CurrentPlan, type MeterPricingMode, type Plan, type PlanBillingModel, type PlanInterval, type PlanMeter, type PlanMeterTier, type PlanRequiredTerms, ReoptPlansClient, createReoptPlansClient };
|
|
236
|
+
export { type CancelSubscriptionResult, type CheckoutSession, type CheckoutStatus, type CreateCheckoutInput, type CurrentPlan, type MeterPricingMode, type Plan, type PlanBillingModel, type PlanInterval, type PlanMeter, type PlanMeterTier, type PlanRequiredTerms, ReoptPlansClient, createReoptPlansClient };
|
package/dist/plans/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { ReoptPlansClient, createReoptPlansClient } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
3
|
-
import '../chunk-
|
|
1
|
+
export { ReoptPlansClient, createReoptPlansClient } from '../chunk-O3PUWIDJ.js';
|
|
2
|
+
import '../chunk-N5JVE4WX.js';
|
|
3
|
+
import '../chunk-MRQY45U5.js';
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
|
5
5
|
//# sourceMappingURL=index.js.map
|
package/dist/push/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { ReoptPushClient, createReoptPushClient } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
3
|
-
import '../chunk-
|
|
1
|
+
export { ReoptPushClient, createReoptPushClient } from '../chunk-R5CCGDUH.js';
|
|
2
|
+
import '../chunk-N5JVE4WX.js';
|
|
3
|
+
import '../chunk-MRQY45U5.js';
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
|
5
5
|
//# sourceMappingURL=index.js.map
|
package/dist/react/hooks.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import * as _tanstack_react_query from '@tanstack/react-query';
|
|
|
2
2
|
import { UseQueryOptions, UseMutationOptions, UseInfiniteQueryOptions } from '@tanstack/react-query';
|
|
3
3
|
import { ReoptSDK } from '../index.js';
|
|
4
4
|
import { StreamDoneData, CompletionOptions, AgentInfo, CompletionResult, CreditInfo, ImageGenerateResult, ImageGenerateOptions, ModelInfo } from '../ai/index.js';
|
|
5
|
-
import { g as ReoptSDKError } from '../errors-
|
|
5
|
+
import { g as ReoptSDKError } from '../errors-DIAS8Rsl.js';
|
|
6
6
|
import { L as ListRecordsQuery, m as EavRecord, g as CreateRecordInput, d as BulkUpdateItem, i as DeleteWhereInput, l as EavEntity, P as PaginatedResponse, s as UpdateRecordInput, u as UpsertRecordResult, t as UpsertRecordInput } from '../config-CtxyJsDR.js';
|
|
7
7
|
import { a as ListPostsQuery, L as ListPostGroupsQuery, b as ListTagsQuery, T as Tag, c as PostDetail, d as PostGroup, C as CmsPaginatedResponse, P as Post } from '../types-ckmDDW3N.js';
|
|
8
8
|
import { a as FileListQuery, F as FileInfo, b as FileListResponse, U as UploadOptions } from '../client-CN5_tNOC.js';
|
package/dist/terms/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { ReoptTermsClient, createReoptTermsClient } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
3
|
-
import '../chunk-
|
|
1
|
+
export { ReoptTermsClient, createReoptTermsClient } from '../chunk-T7YTITRJ.js';
|
|
2
|
+
import '../chunk-N5JVE4WX.js';
|
|
3
|
+
import '../chunk-MRQY45U5.js';
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
|
5
5
|
//# sourceMappingURL=index.js.map
|
package/dist/testing/index.d.ts
CHANGED
package/docs/api-reference.md
CHANGED
|
@@ -462,7 +462,7 @@ export function PostBody({ contentRich }: { contentRich: EditorSpec }) {
|
|
|
462
462
|
}
|
|
463
463
|
```
|
|
464
464
|
|
|
465
|
-
자세한 데모는 [`docs/cms.md`](./cms.md)
|
|
465
|
+
자세한 데모는 [`docs/cms.md`](./cms.md) 참고.
|
|
466
466
|
|
|
467
467
|
## Terms Client (`sdk.terms`)
|
|
468
468
|
|
package/docs/cms.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reopt-ai/brandapp-sdk",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "Reopt Brandapp SDK — Better Auth adapter, OAuth login, and EAV client",
|
|
5
5
|
"author": "Reopt",
|
|
6
6
|
"license": "MIT",
|
|
@@ -167,7 +167,9 @@
|
|
|
167
167
|
"dev": "tsup --watch",
|
|
168
168
|
"type-check": "tsc --noEmit",
|
|
169
169
|
"test": "vitest run",
|
|
170
|
+
"test:coverage": "vitest run --coverage",
|
|
170
171
|
"test:critical": "vitest run __tests__/eav-client.test.ts __tests__/http-client.test.ts",
|
|
172
|
+
"test:e2e": "pnpm run build && vitest run --config vitest.e2e.config.ts",
|
|
171
173
|
"clean": "rm -rf dist"
|
|
172
174
|
}
|
|
173
175
|
}
|
package/dist/chunk-T2WXHAAC.js
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { BaseHttpClient } from './chunk-DI6QJPTQ.js';
|
|
2
|
-
|
|
3
|
-
// src/plans/client.ts
|
|
4
|
-
function unwrap(body) {
|
|
5
|
-
if (body && typeof body === "object" && "data" in body) {
|
|
6
|
-
const withData = body;
|
|
7
|
-
if (withData.data !== void 0) return withData.data;
|
|
8
|
-
}
|
|
9
|
-
return body;
|
|
10
|
-
}
|
|
11
|
-
var ReoptPlansClient = class {
|
|
12
|
-
http;
|
|
13
|
-
constructor(config) {
|
|
14
|
-
this.http = new BaseHttpClient(
|
|
15
|
-
config,
|
|
16
|
-
`/api/v1/brandapp/${config.brandappId}/plans`
|
|
17
|
-
);
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* List active plans for this Brandapp (the customer-facing catalog). Works
|
|
21
|
-
* with either Basic Auth (default) or Bearer Auth — pass `accessToken` when
|
|
22
|
-
* calling from a handler that already has the customer's OAuth token to avoid
|
|
23
|
-
* sending app credentials.
|
|
24
|
-
*/
|
|
25
|
-
async list(accessToken) {
|
|
26
|
-
const body = await this.http.fetch(
|
|
27
|
-
"GET",
|
|
28
|
-
"",
|
|
29
|
-
void 0,
|
|
30
|
-
accessToken ? { bearerToken: accessToken } : void 0
|
|
31
|
-
);
|
|
32
|
-
return unwrap(body);
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Fetch the current plan / entitlement for the OAuth customer represented by
|
|
36
|
-
* `accessToken`. Returns `null` when the customer has no active plan.
|
|
37
|
-
*/
|
|
38
|
-
async getMyPlan(accessToken) {
|
|
39
|
-
const body = await this.http.fetch(
|
|
40
|
-
"GET",
|
|
41
|
-
"/me/plan",
|
|
42
|
-
void 0,
|
|
43
|
-
{ bearerToken: accessToken }
|
|
44
|
-
);
|
|
45
|
-
return unwrap(body);
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
function createReoptPlansClient(config) {
|
|
49
|
-
return new ReoptPlansClient(config);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export { ReoptPlansClient, createReoptPlansClient };
|
|
53
|
-
//# sourceMappingURL=chunk-T2WXHAAC.js.map
|
|
54
|
-
//# sourceMappingURL=chunk-T2WXHAAC.js.map
|