@reopt-ai/brandapp-sdk 3.1.0 → 3.4.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 +147 -0
- package/README.md +39 -14
- package/dist/abort--nOBFN4M.js +50 -0
- package/dist/ai/index.d.ts +2 -314
- package/dist/ai/index.js +3 -7
- package/dist/ai-provider/index.d.ts +79 -163
- package/dist/ai-provider/index.js +752 -671
- package/dist/auth/index.d.ts +27 -27
- package/dist/auth/index.js +41 -33
- package/dist/better-auth/client.d.ts +6 -5
- package/dist/better-auth/client.js +28 -5
- package/dist/better-auth/index.d.ts +19 -17
- package/dist/better-auth/index.js +180 -133
- package/dist/client-B1q5P8rv.js +83 -0
- package/dist/client-B9QHVhdM.js +77 -0
- package/dist/client-BGGd_cpV.d.ts +103 -0
- package/dist/client-BJcy1V1a.js +140 -0
- package/dist/client-Beivhucf.js +55 -0
- package/dist/client-BruP5_nU.d.ts +147 -0
- package/dist/client-D-yNxNfk.js +28 -0
- package/dist/client-D0eBxh8j.d.ts +284 -0
- package/dist/client-D3RHHUUW.d.ts +207 -0
- package/dist/client-D6gs61w8.d.ts +53 -0
- package/dist/client-DBnK7ooQ.js +86 -0
- package/dist/client-DDw5yz_h.d.ts +53 -0
- package/dist/client-DPmoKuR9.js +305 -0
- package/dist/client-DsdakibF.js +503 -0
- package/dist/client-Dxg8_DIH.d.ts +71 -0
- package/dist/client-EbhUIhHq.js +53 -0
- package/dist/client-lk6wBu_0.d.ts +48 -0
- package/dist/client-p49ol9pg.d.ts +124 -0
- package/dist/cms/index.d.ts +52 -108
- package/dist/cms/index.js +105 -84
- package/dist/config-CRytOPPl.d.ts +394 -0
- package/dist/config-Cw0a3-C8.js +487 -0
- package/dist/dev/index.d.ts +2 -509
- package/dist/dev/index.js +2740 -2873
- package/dist/eav/coerce.d.ts +3 -1
- package/dist/eav/coerce.js +72 -46
- package/dist/eav/index.d.ts +72 -100
- package/dist/eav/index.js +158 -125
- package/dist/eav/migrate.d.ts +112 -109
- package/dist/eav/migrate.js +230 -196
- package/dist/eav/schema.d.ts +111 -150
- package/dist/eav/schema.js +624 -603
- package/dist/encoding-Bwfm3iaE.js +21 -0
- package/dist/{errors-DIAS8Rsl.d.ts → errors-CRCcErNC.d.ts} +55 -53
- package/dist/feedback/index.d.ts +2 -132
- package/dist/feedback/index.js +3 -5
- package/dist/files/index.d.ts +14 -14
- package/dist/files/index.js +41 -24
- package/dist/http-client-QKUvvirs.js +386 -0
- package/dist/index-DrVaKfhs.d.ts +456 -0
- package/dist/index-Z6OGcurJ.d.ts +169 -0
- package/dist/index.d.ts +6 -221
- package/dist/index.js +119 -70
- package/dist/logout/index.d.ts +109 -0
- package/dist/logout/index.js +264 -0
- package/dist/plans/index.d.ts +2 -236
- package/dist/plans/index.js +3 -5
- package/dist/push/index.d.ts +2 -79
- package/dist/push/index.js +3 -5
- package/dist/query-BvbCiGWb.js +35 -0
- package/dist/react/hooks.d.ts +97 -95
- package/dist/react/hooks.js +742 -356
- package/dist/sse-parser-FMjxM7sY.js +86 -0
- package/dist/terms/index.d.ts +3 -79
- package/dist/terms/index.js +3 -5
- package/dist/testing/index.d.ts +52 -104
- package/dist/testing/index.js +94 -72
- package/dist/types-B-SMkH6s.d.ts +26 -0
- package/dist/types-BXDcoJHG.d.ts +131 -0
- package/dist/types-BrghN2rJ.d.ts +105 -0
- package/dist/types-DjDRszNj.js +11 -0
- package/dist/webhooks/index.d.ts +77 -47
- package/dist/webhooks/index.js +150 -127
- package/docs/api-reference.md +179 -2
- package/docs/dev-server.md +19 -18
- package/docs/errors.md +72 -15
- package/docs/logout.md +166 -0
- package/package.json +10 -5
- package/dist/chunk-2Q654O63.js +0 -350
- package/dist/chunk-F7BXBTZI.js +0 -54
- package/dist/chunk-IJOXTBIE.js +0 -599
- package/dist/chunk-JWXUVQRC.js +0 -157
- package/dist/chunk-L4DHB36G.js +0 -75
- package/dist/chunk-MRQY45U5.js +0 -465
- package/dist/chunk-N5JVE4WX.js +0 -449
- package/dist/chunk-O3PUWIDJ.js +0 -105
- package/dist/chunk-POLKEOYH.js +0 -63
- package/dist/chunk-R5CCGDUH.js +0 -49
- package/dist/chunk-RBHP7IZF.js +0 -96
- package/dist/chunk-REIKXSMY.js +0 -7
- package/dist/chunk-T7YTITRJ.js +0 -112
- package/dist/chunk-V73GORO3.js +0 -81
- package/dist/chunk-VRNBYSWU.js +0 -32
- package/dist/client-BkcO-0C2.d.ts +0 -216
- package/dist/client-CN5_tNOC.d.ts +0 -147
- package/dist/client-DttyeM_h.d.ts +0 -102
- package/dist/config-CtxyJsDR.d.ts +0 -397
- package/dist/typed-client-BxOVIiMU.d.ts +0 -40
- package/dist/types-6E3ZLL9X.d.ts +0 -24
- package/dist/types-DskYLVb8.d.ts +0 -104
- package/dist/types-ckmDDW3N.d.ts +0 -129
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
import { n as ReoptSDKConfig } from "./config-CRytOPPl.js";
|
|
2
|
+
//#region src/ai/types.d.ts
|
|
3
|
+
/** 메시지 역할 */
|
|
4
|
+
type MessageRole = "system" | "user" | "assistant";
|
|
5
|
+
/** 채팅 메시지 */
|
|
6
|
+
type ChatMessage = {
|
|
7
|
+
role: MessageRole;
|
|
8
|
+
content: string;
|
|
9
|
+
};
|
|
10
|
+
/** AI completion 요청 옵션 */
|
|
11
|
+
type CompletionOptions = {
|
|
12
|
+
/** 모델 ID (e.g. "anthropic/claude-haiku-4.5"). 미지정 시 BrandApp 기본 모델. */
|
|
13
|
+
model?: string;
|
|
14
|
+
/** 커스텀 에이전트 ID (e.g. "custom:uuid") */
|
|
15
|
+
agentId?: string;
|
|
16
|
+
/** 메시지 배열 */
|
|
17
|
+
messages: ChatMessage[];
|
|
18
|
+
/** 최대 출력 토큰 (기본 4096) */
|
|
19
|
+
maxTokens?: number;
|
|
20
|
+
/** 생성 온도 (0-2) */
|
|
21
|
+
temperature?: number;
|
|
22
|
+
/** BrandappCustomer ID (사용량 추적용) */
|
|
23
|
+
customerId?: string;
|
|
24
|
+
/** AbortSignal for request cancellation */
|
|
25
|
+
signal?: AbortSignal;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* 생성 종료 사유. `unified`는 AI SDK v3 finishReason과 같은 어휘다. 서버가 보고하면
|
|
29
|
+
* 채워지고, 미보고 시 생략된다(소비처는 없으면 정상 종료로 간주).
|
|
30
|
+
*/
|
|
31
|
+
type FinishReason = {
|
|
32
|
+
unified: "stop" | "length" | "content-filter" | "tool-calls" | "error" | "other";
|
|
33
|
+
raw?: string;
|
|
34
|
+
};
|
|
35
|
+
/** AI completion 응답 (non-streaming) */
|
|
36
|
+
type CompletionResult = {
|
|
37
|
+
id: string;
|
|
38
|
+
model: string;
|
|
39
|
+
message: {
|
|
40
|
+
role: "assistant";
|
|
41
|
+
content: string;
|
|
42
|
+
};
|
|
43
|
+
usage: {
|
|
44
|
+
promptTokens: number;
|
|
45
|
+
completionTokens: number;
|
|
46
|
+
creditCost: number;
|
|
47
|
+
};
|
|
48
|
+
creditsRemaining: number;
|
|
49
|
+
/** 생성 종료 사유 (서버가 보고 시) */
|
|
50
|
+
finishReason?: FinishReason;
|
|
51
|
+
/**
|
|
52
|
+
* true면 이 호출은 잔액을 초과해 차감됐다(출력은 이미 생성되어 반환되지만 잔액은
|
|
53
|
+
* 0으로 소진). 다음 호출은 사전 크레딧 체크에서 차단된다 — "1회 후 차단" 의도.
|
|
54
|
+
*/
|
|
55
|
+
creditLimited?: boolean;
|
|
56
|
+
};
|
|
57
|
+
/** 크레딧 잔액 정보 */
|
|
58
|
+
type CreditInfo = {
|
|
59
|
+
balance: number;
|
|
60
|
+
limit: number;
|
|
61
|
+
percentage: number;
|
|
62
|
+
resetAt: string | null;
|
|
63
|
+
status: "normal" | "warning" | "critical" | "exhausted";
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* 사용 가능 모델 정보 — `sdk.ai.models()` / `sdk.ai.imageModels()` 응답 항목.
|
|
67
|
+
*
|
|
68
|
+
* 서버 `AvailableModel`(packages/ai)과 구조가 일치한다 — contract type-test가
|
|
69
|
+
* CI에서 동일성을 강제한다. `isDefault`로 "model 미지정 시 쓰이는 기본 모델"을,
|
|
70
|
+
* `modality`로 chat/image 구분을 사전에 알 수 있다.
|
|
71
|
+
*/
|
|
72
|
+
type ModelInfo = {
|
|
73
|
+
id: string;
|
|
74
|
+
displayName: string;
|
|
75
|
+
description: string;
|
|
76
|
+
provider: string;
|
|
77
|
+
/** chat | image */
|
|
78
|
+
modality: "chat" | "image";
|
|
79
|
+
tier: string;
|
|
80
|
+
tierLabel: string;
|
|
81
|
+
/** credits per 1K input tokens (image-only 모델은 0) */
|
|
82
|
+
inputRate: number;
|
|
83
|
+
/** credits per 1K output tokens (image-only 모델은 0) */
|
|
84
|
+
outputRate: number;
|
|
85
|
+
/** 이미지 생성당 고정 크레딧 (image 모델 전용) */
|
|
86
|
+
creditsPerImage?: number;
|
|
87
|
+
/** 최대 입력 컨텍스트 토큰 */
|
|
88
|
+
contextWindow?: number;
|
|
89
|
+
/** 최대 출력 토큰 */
|
|
90
|
+
maxOutputTokens?: number;
|
|
91
|
+
/** 이미지/파일 입력(비전) 지원 */
|
|
92
|
+
supportsVision?: boolean;
|
|
93
|
+
/** function/tool calling 지원 (외부 brandapp API에서는 미노출이나 메타로 제공) */
|
|
94
|
+
supportsTools?: boolean;
|
|
95
|
+
/** 이 brandapp의 기본 모델인지 (modality별 기본값과 일치) */
|
|
96
|
+
isDefault: boolean;
|
|
97
|
+
};
|
|
98
|
+
/** 이미지 생성 요청 옵션 */
|
|
99
|
+
type ImageGenerateOptions = {
|
|
100
|
+
/** 이미지 설명 프롬프트 */
|
|
101
|
+
prompt: string;
|
|
102
|
+
/** 네거티브 프롬프트 (생성에서 제외할 요소) */
|
|
103
|
+
negativePrompt?: string;
|
|
104
|
+
/** 스타일 (e.g. "watercolor", "photorealistic") */
|
|
105
|
+
style?: string;
|
|
106
|
+
/** 종횡비 (기본 1:1) */
|
|
107
|
+
aspectRatio?: "1:1" | "16:9" | "9:16" | "4:3" | "3:4";
|
|
108
|
+
/** 이미지 모델 (기본: google/gemini-2.5-flash-image) */
|
|
109
|
+
model?: string;
|
|
110
|
+
/** BrandappCustomer ID (사용량 추적용) */
|
|
111
|
+
customerId?: string;
|
|
112
|
+
};
|
|
113
|
+
/** 이미지 생성 결과 */
|
|
114
|
+
type ImageGenerateResult = {
|
|
115
|
+
/** 파일 ID */
|
|
116
|
+
id: string;
|
|
117
|
+
/** 이미지 URL (Vercel Blob) */
|
|
118
|
+
url: string;
|
|
119
|
+
/** 파일 크기 (bytes) */
|
|
120
|
+
size: number;
|
|
121
|
+
/** MIME 타입 */
|
|
122
|
+
contentType: string;
|
|
123
|
+
/** 사용량 */
|
|
124
|
+
usage: {
|
|
125
|
+
creditCost: number;
|
|
126
|
+
};
|
|
127
|
+
/** 남은 크레딧 */
|
|
128
|
+
creditsRemaining: number;
|
|
129
|
+
/** true면 잔액 초과 차감(이미지는 반환되나 잔액 소진, 다음 호출 차단) */
|
|
130
|
+
creditLimited?: boolean;
|
|
131
|
+
};
|
|
132
|
+
/** SSE 스트림 이벤트 */
|
|
133
|
+
type StreamEvent = {
|
|
134
|
+
event: "text-delta";
|
|
135
|
+
data: string;
|
|
136
|
+
} | {
|
|
137
|
+
event: "done";
|
|
138
|
+
data: StreamDoneData;
|
|
139
|
+
} | {
|
|
140
|
+
event: "error";
|
|
141
|
+
data: {
|
|
142
|
+
code: string;
|
|
143
|
+
message: string;
|
|
144
|
+
};
|
|
145
|
+
};
|
|
146
|
+
/** 스트림 완료 메타데이터 */
|
|
147
|
+
type StreamDoneData = {
|
|
148
|
+
usage: {
|
|
149
|
+
promptTokens: number;
|
|
150
|
+
completionTokens: number;
|
|
151
|
+
creditCost: number;
|
|
152
|
+
};
|
|
153
|
+
creditsRemaining: number;
|
|
154
|
+
/** 생성 종료 사유 (서버가 보고 시) */
|
|
155
|
+
finishReason?: FinishReason;
|
|
156
|
+
};
|
|
157
|
+
/** 커스텀 에이전트 정보 */
|
|
158
|
+
type AgentInfo = {
|
|
159
|
+
id: string;
|
|
160
|
+
name: string;
|
|
161
|
+
description: string;
|
|
162
|
+
defaultModel: string;
|
|
163
|
+
};
|
|
164
|
+
//#endregion
|
|
165
|
+
//#region src/ai/client.d.ts
|
|
166
|
+
declare class ReoptAiClient {
|
|
167
|
+
private readonly http;
|
|
168
|
+
/**
|
|
169
|
+
* Idle (inactivity) timeout for streaming, in ms — the maximum gap allowed
|
|
170
|
+
* *between* SSE chunks, not a deadline on the whole generation. A long but
|
|
171
|
+
* healthy generation keeps resetting this; only a genuine stall aborts.
|
|
172
|
+
*/
|
|
173
|
+
private readonly streamIdleTimeout;
|
|
174
|
+
constructor(config: ReoptSDKConfig);
|
|
175
|
+
/**
|
|
176
|
+
* AI 텍스트 생성 (non-streaming)
|
|
177
|
+
*
|
|
178
|
+
* @example
|
|
179
|
+
* ```ts
|
|
180
|
+
* const result = await sdk.ai.complete({
|
|
181
|
+
* messages: [{ role: "user", content: "Hello" }],
|
|
182
|
+
* model: "anthropic/claude-haiku-4.5",
|
|
183
|
+
* maxTokens: 1024,
|
|
184
|
+
* });
|
|
185
|
+
* console.log(result.message.content);
|
|
186
|
+
* ```
|
|
187
|
+
*/
|
|
188
|
+
complete(options: CompletionOptions): Promise<CompletionResult>;
|
|
189
|
+
/**
|
|
190
|
+
* AI 텍스트 생성 (SSE 스트리밍)
|
|
191
|
+
*
|
|
192
|
+
* async generator로 텍스트 청크를 반환합니다.
|
|
193
|
+
* 사용량 메타데이터가 필요하면 `streamWithMetadata()`를 사용하세요.
|
|
194
|
+
*
|
|
195
|
+
* @example
|
|
196
|
+
* ```ts
|
|
197
|
+
* for await (const chunk of sdk.ai.stream({
|
|
198
|
+
* messages: [{ role: "user", content: "Hello" }],
|
|
199
|
+
* })) {
|
|
200
|
+
* process.stdout.write(chunk);
|
|
201
|
+
* }
|
|
202
|
+
* ```
|
|
203
|
+
*/
|
|
204
|
+
stream(options: CompletionOptions): AsyncGenerator<string>;
|
|
205
|
+
/**
|
|
206
|
+
* AI 텍스트 생성 (SSE 스트리밍 + 메타데이터)
|
|
207
|
+
*
|
|
208
|
+
* 텍스트 청크와 함께 최종 사용량/크레딧 메타데이터를 반환합니다.
|
|
209
|
+
*
|
|
210
|
+
* @example
|
|
211
|
+
* ```ts
|
|
212
|
+
* const { textStream, metadata } = sdk.ai.streamWithMetadata({
|
|
213
|
+
* messages: [{ role: "user", content: "Hello" }],
|
|
214
|
+
* });
|
|
215
|
+
*
|
|
216
|
+
* let text = "";
|
|
217
|
+
* for await (const chunk of textStream) {
|
|
218
|
+
* text += chunk;
|
|
219
|
+
* }
|
|
220
|
+
*
|
|
221
|
+
* const meta = await metadata;
|
|
222
|
+
* console.log(`사용 크레딧: ${meta?.usage.creditCost}`);
|
|
223
|
+
* ```
|
|
224
|
+
*/
|
|
225
|
+
streamWithMetadata(options: CompletionOptions): {
|
|
226
|
+
textStream: AsyncGenerator<string>;
|
|
227
|
+
metadata: Promise<StreamDoneData | null>;
|
|
228
|
+
};
|
|
229
|
+
/**
|
|
230
|
+
* 이미지 생성
|
|
231
|
+
*
|
|
232
|
+
* BrandApp의 AI 크레딧으로 이미지를 생성합니다.
|
|
233
|
+
* 생성된 이미지는 자동으로 Vercel Blob에 저장되고 URL이 반환됩니다.
|
|
234
|
+
*
|
|
235
|
+
* @example
|
|
236
|
+
* ```ts
|
|
237
|
+
* const image = await sdk.ai.generateImage({
|
|
238
|
+
* prompt: "브랜드 배너 이미지",
|
|
239
|
+
* style: "minimalist",
|
|
240
|
+
* aspectRatio: "16:9",
|
|
241
|
+
* });
|
|
242
|
+
* console.log(image.url); // https://...blob.vercel-storage.com/...
|
|
243
|
+
* console.log(image.size); // 12345 (bytes)
|
|
244
|
+
* ```
|
|
245
|
+
*/
|
|
246
|
+
generateImage(options: ImageGenerateOptions): Promise<ImageGenerateResult>;
|
|
247
|
+
/**
|
|
248
|
+
* 크레딧 잔액 조회
|
|
249
|
+
*
|
|
250
|
+
* @example
|
|
251
|
+
* ```ts
|
|
252
|
+
* const credits = await sdk.ai.credits();
|
|
253
|
+
* console.log(`${credits.balance} / ${credits.limit} (${credits.status})`);
|
|
254
|
+
* ```
|
|
255
|
+
*/
|
|
256
|
+
credits(): Promise<CreditInfo>;
|
|
257
|
+
/**
|
|
258
|
+
* 사용 가능 모델 목록 조회
|
|
259
|
+
*
|
|
260
|
+
* @example
|
|
261
|
+
* ```ts
|
|
262
|
+
* const models = await sdk.ai.models();
|
|
263
|
+
* models.forEach(m => console.log(`${m.id} (${m.tierLabel})`));
|
|
264
|
+
* ```
|
|
265
|
+
*/
|
|
266
|
+
models(): Promise<ModelInfo[]>;
|
|
267
|
+
/**
|
|
268
|
+
* 사용 가능한 커스텀 에이전트 목록 조회
|
|
269
|
+
*
|
|
270
|
+
* @example
|
|
271
|
+
* ```ts
|
|
272
|
+
* const agents = await sdk.ai.agents();
|
|
273
|
+
* for (const agent of agents) {
|
|
274
|
+
* console.log(`${agent.name}: ${agent.description}`);
|
|
275
|
+
* }
|
|
276
|
+
* ```
|
|
277
|
+
*/
|
|
278
|
+
agents(): Promise<AgentInfo[]>;
|
|
279
|
+
private fetchSSE;
|
|
280
|
+
}
|
|
281
|
+
declare function createReoptAiClient(config: ReoptSDKConfig): ReoptAiClient;
|
|
282
|
+
//#endregion
|
|
283
|
+
export { CompletionOptions as a, FinishReason as c, MessageRole as d, ModelInfo as f, ChatMessage as i, ImageGenerateOptions as l, StreamEvent as m, createReoptAiClient as n, CompletionResult as o, StreamDoneData as p, AgentInfo as r, CreditInfo as s, ReoptAiClient as t, ImageGenerateResult as u };
|
|
284
|
+
//# sourceMappingURL=client-D0eBxh8j.d.ts.map
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { n as ReoptSDKConfig } from "./config-CRytOPPl.js";
|
|
2
|
+
//#region src/plans/types.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Brandapp Plans types.
|
|
5
|
+
*
|
|
6
|
+
* Mirrors the response shape of `/api/v1/brandapp/{brandappId}/plans/*`.
|
|
7
|
+
*/
|
|
8
|
+
/** Prisma `BillingModel` enum. */
|
|
9
|
+
type PlanBillingModel = "recurring" | "usage";
|
|
10
|
+
/** Prisma `PlanInterval` enum. */
|
|
11
|
+
type PlanInterval = "monthly" | "yearly" | "once" | "lifetime";
|
|
12
|
+
/** Prisma `MeterPricingMode` enum. */
|
|
13
|
+
type MeterPricingMode = "flat" | "tiered";
|
|
14
|
+
type PlanMeterTier = {
|
|
15
|
+
/** 이 구간의 상한 수량. `null`이면 마지막(무제한) 구간. */
|
|
16
|
+
upTo: number | null;
|
|
17
|
+
/** 구간 단가 (통화 최소 단위 정수, 예: 원). */
|
|
18
|
+
unitPrice: number;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* usage 과금 플랜의 사용량 미터.
|
|
22
|
+
*
|
|
23
|
+
* ⚠️ 현재 미터는 **read-only 메타데이터**다 — 사용량 집계·리포팅·청구 백엔드는
|
|
24
|
+
* 아직 구현되지 않았다. 플랜 카탈로그에 "무엇을 얼마에 과금하는지" 표시하는
|
|
25
|
+
* 용도로만 노출된다.
|
|
26
|
+
*/
|
|
27
|
+
type PlanMeter = {
|
|
28
|
+
id: string;
|
|
29
|
+
name: string;
|
|
30
|
+
/** API용 미터 키 (영문 소문자+숫자+언더스코어). */
|
|
31
|
+
key: string;
|
|
32
|
+
/** 단위 레이블 (예: "건", "GB"). */
|
|
33
|
+
unitLabel: string;
|
|
34
|
+
/** 포함 무료 수량. */
|
|
35
|
+
includedQty: number;
|
|
36
|
+
pricingMode: MeterPricingMode | string;
|
|
37
|
+
/** flat 모드 단가 (통화 최소 단위 정수). */
|
|
38
|
+
unitPrice: number;
|
|
39
|
+
/** tiered 모드 구간. flat 모드이거나 미설정이면 `null`. */
|
|
40
|
+
tiers: PlanMeterTier[] | null;
|
|
41
|
+
sortOrder: number;
|
|
42
|
+
};
|
|
43
|
+
type PlanRequiredTerms = {
|
|
44
|
+
id: string;
|
|
45
|
+
title: string;
|
|
46
|
+
/** Prisma `BrandappTermsType` (termsOfService/privacyPolicy/marketingConsent/custom). */
|
|
47
|
+
type: string;
|
|
48
|
+
};
|
|
49
|
+
type Plan = {
|
|
50
|
+
id: string;
|
|
51
|
+
name: string;
|
|
52
|
+
description: string | null;
|
|
53
|
+
billingModel: PlanBillingModel | string;
|
|
54
|
+
/** 정기 구독 가격 (통화 최소 단위 정수). usage 플랜은 보통 0. */
|
|
55
|
+
priceAmount: number;
|
|
56
|
+
/** ISO 4217 통화 코드 (예: "KRW", "USD"). */
|
|
57
|
+
currency: string;
|
|
58
|
+
interval: PlanInterval | string;
|
|
59
|
+
/** usage 플랜의 기본 요금 (통화 최소 단위 정수). */
|
|
60
|
+
baseFee: number;
|
|
61
|
+
sortOrder: number;
|
|
62
|
+
features: string[];
|
|
63
|
+
/** usage 플랜의 사용량 미터 (read-only). */
|
|
64
|
+
meters: PlanMeter[];
|
|
65
|
+
/** 구독 전에 동의가 필요한 필수 약관. `sdk.terms`로 본문 조회·동의. */
|
|
66
|
+
requiredTerms: PlanRequiredTerms[];
|
|
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
|
+
/**
|
|
115
|
+
* 해지된 구독의 결제 수단 (`sandbox` | `paddle` | `toss` | `apple` | `google` …).
|
|
116
|
+
* 안내 문구를 결제 수단별로 가를 때 쓴다. 구버전 서버는 내려주지 않는다.
|
|
117
|
+
*/
|
|
118
|
+
provider?: string;
|
|
119
|
+
/**
|
|
120
|
+
* 이 시각(ISO-8601)까지는 계속 이용할 수 있다 — 결제한 기간은 유지된다.
|
|
121
|
+
* `null`이면 무기한 플랜이라 즉시 종료. 구버전 서버는 내려주지 않는다.
|
|
122
|
+
*/
|
|
123
|
+
accessUntil?: string | null;
|
|
124
|
+
/**
|
|
125
|
+
* 결제사 쪽 해지까지 성공했는지. `false`면 로컬 구독은 확실히 종료됐지만
|
|
126
|
+
* (다음 청구 없음) 결제사 대시보드에 잔재가 남아 운영자 확인이 필요할 수 있다.
|
|
127
|
+
* 구버전 서버는 내려주지 않는다.
|
|
128
|
+
*/
|
|
129
|
+
providerCanceled?: boolean;
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* 현재 로그인 고객의 구독 플랜 + 엔타이틀먼트.
|
|
133
|
+
*
|
|
134
|
+
* 결제 상태는 이 고객 본인 소유(brandappCustomer) BillingState/PaymentProviderLink에서
|
|
135
|
+
* 읽는다. 원시 결제 식별자(billingKey, 외부 subscription id)는 노출하지 않는다.
|
|
136
|
+
*/
|
|
137
|
+
type CurrentPlan = {
|
|
138
|
+
planId: string;
|
|
139
|
+
planName: string;
|
|
140
|
+
planDescription: string | null;
|
|
141
|
+
priceAmount: number;
|
|
142
|
+
currency: string;
|
|
143
|
+
interval: PlanInterval | string;
|
|
144
|
+
features: string[];
|
|
145
|
+
/** BillingState.status (예: "active", "trialing", "canceled"). null이면 결제 상태 없음. */
|
|
146
|
+
subscriptionStatus: string | null;
|
|
147
|
+
/** ISO-8601 문자열. */
|
|
148
|
+
planStartedAt: string | null;
|
|
149
|
+
/** ISO-8601 문자열. `null`이면 무기한. */
|
|
150
|
+
planExpiresAt: string | null;
|
|
151
|
+
/** 활성 결제 제공자 — "paddle" | "toss" | null. */
|
|
152
|
+
paymentProvider: string | null;
|
|
153
|
+
};
|
|
154
|
+
//#endregion
|
|
155
|
+
//#region src/plans/client.d.ts
|
|
156
|
+
declare class ReoptPlansClient {
|
|
157
|
+
private readonly http;
|
|
158
|
+
constructor(config: ReoptSDKConfig);
|
|
159
|
+
/**
|
|
160
|
+
* List active plans for this Brandapp (the customer-facing catalog). Works
|
|
161
|
+
* with either Basic Auth (default) or Bearer Auth — pass `accessToken` when
|
|
162
|
+
* calling from a handler that already has the customer's OAuth token to avoid
|
|
163
|
+
* sending app credentials.
|
|
164
|
+
*/
|
|
165
|
+
list(accessToken?: string): Promise<Plan[]>;
|
|
166
|
+
/**
|
|
167
|
+
* Fetch the current plan / entitlement for the OAuth customer represented by
|
|
168
|
+
* `accessToken`. Returns `null` when the customer has no active plan.
|
|
169
|
+
*/
|
|
170
|
+
getMyPlan(accessToken: string): Promise<CurrentPlan | null>;
|
|
171
|
+
/**
|
|
172
|
+
* Start a hosted checkout to subscribe the current customer (identified by
|
|
173
|
+
* `accessToken`) to `input.planId`, then redirect the browser to the returned
|
|
174
|
+
* `checkoutUrl`. In sandbox mode that URL is a virtual-payment page on
|
|
175
|
+
* id.reopt.ai which activates the subscription and returns to your
|
|
176
|
+
* `successUrl` / `cancelUrl`.
|
|
177
|
+
*
|
|
178
|
+
* @throws {RequiredTermsError} when the plan has required terms the customer
|
|
179
|
+
* has not consented to. Read `missingTermsIds`, collect consent via
|
|
180
|
+
* `sdk.terms`, then call again.
|
|
181
|
+
* @throws {ReoptSDKError} `LIVE_MODE_UNSUPPORTED` (409) when the Brandapp is
|
|
182
|
+
* configured for live **Toss** payments and the plan is priced (use the
|
|
183
|
+
* brandfront checkout). Live Paddle is supported since 3.4.
|
|
184
|
+
*/
|
|
185
|
+
createCheckout(input: CreateCheckoutInput, accessToken: string): Promise<CheckoutSession>;
|
|
186
|
+
/**
|
|
187
|
+
* Poll a checkout session by id (e.g. on your return page) to read its
|
|
188
|
+
* `status` — `completed` means the subscription is active. `checkoutUrl` is
|
|
189
|
+
* `null` here; use the URL from {@link createCheckout} to re-redirect.
|
|
190
|
+
*/
|
|
191
|
+
getCheckout(checkoutId: string, accessToken: string): Promise<CheckoutSession>;
|
|
192
|
+
/**
|
|
193
|
+
* Cancel the current customer's active subscription — sandbox and live
|
|
194
|
+
* (Paddle/Toss/IAP) alike since 3.4. Access is kept until the paid period
|
|
195
|
+
* ends (the billing state becomes `canceled`, `accessUntil` says until when).
|
|
196
|
+
*
|
|
197
|
+
* The local subscription is settled first, so the next recurring charge is
|
|
198
|
+
* always stopped; the provider-side cancellation is best-effort and reported
|
|
199
|
+
* through `providerCanceled`. Apple/Google subscriptions are canceled in the
|
|
200
|
+
* store, so no remote call is made for those.
|
|
201
|
+
*/
|
|
202
|
+
cancel(accessToken: string): Promise<CancelSubscriptionResult>;
|
|
203
|
+
}
|
|
204
|
+
declare function createReoptPlansClient(config: ReoptSDKConfig): ReoptPlansClient;
|
|
205
|
+
//#endregion
|
|
206
|
+
export { CheckoutStatus as a, MeterPricingMode as c, PlanInterval as d, PlanMeter as f, CheckoutSession as i, Plan as l, PlanRequiredTerms as m, createReoptPlansClient as n, CreateCheckoutInput as o, PlanMeterTier as p, CancelSubscriptionResult as r, CurrentPlan as s, ReoptPlansClient as t, PlanBillingModel as u };
|
|
207
|
+
//# sourceMappingURL=client-D3RHHUUW.d.ts.map
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { n as ReoptSDKConfig } from "./config-CRytOPPl.js";
|
|
2
|
+
//#region src/push/types.d.ts
|
|
3
|
+
/** Push provider — native token kind. */
|
|
4
|
+
type PushProvider = "fcm" | "apns";
|
|
5
|
+
/** Device platform. */
|
|
6
|
+
type PushPlatform = "ios" | "android" | "web";
|
|
7
|
+
/** Input for registering a device push token. */
|
|
8
|
+
type RegisterPushTokenInput = {
|
|
9
|
+
/** Provider of the native token. */
|
|
10
|
+
provider: PushProvider;
|
|
11
|
+
/** Native device token (FCM registration token / APNs device token). */
|
|
12
|
+
token: string;
|
|
13
|
+
/** Device platform. */
|
|
14
|
+
platform: PushPlatform;
|
|
15
|
+
/** Optional device identifier (helps re-login/refresh upsert + unregister). */
|
|
16
|
+
deviceId?: string;
|
|
17
|
+
};
|
|
18
|
+
type RegisterPushTokenResult = {
|
|
19
|
+
registered: boolean;
|
|
20
|
+
};
|
|
21
|
+
/** Input for unregistering — one of token / deviceId is required. */
|
|
22
|
+
type UnregisterPushTokenInput = {
|
|
23
|
+
token?: string;
|
|
24
|
+
deviceId?: string;
|
|
25
|
+
};
|
|
26
|
+
type UnregisterPushTokenResult = {
|
|
27
|
+
unregistered: boolean;
|
|
28
|
+
};
|
|
29
|
+
/** A device currently registered for the signed-in customer. */
|
|
30
|
+
type RegisteredPushDevice = {
|
|
31
|
+
id: string;
|
|
32
|
+
platform: PushPlatform;
|
|
33
|
+
provider: PushProvider;
|
|
34
|
+
deviceId: string | null;
|
|
35
|
+
createdAt: string;
|
|
36
|
+
lastSeenAt: string;
|
|
37
|
+
};
|
|
38
|
+
//#endregion
|
|
39
|
+
//#region src/push/client.d.ts
|
|
40
|
+
declare class ReoptPushClient {
|
|
41
|
+
private readonly http;
|
|
42
|
+
constructor(config: ReoptSDKConfig);
|
|
43
|
+
/** Register (or refresh) the signed-in customer's device push token. */
|
|
44
|
+
registerDeviceToken(input: RegisterPushTokenInput, accessToken: string): Promise<RegisterPushTokenResult>;
|
|
45
|
+
/** Unregister a device token by `token` or `deviceId` (own tokens only). */
|
|
46
|
+
unregisterDeviceToken(input: UnregisterPushTokenInput, accessToken: string): Promise<UnregisterPushTokenResult>;
|
|
47
|
+
/** List the signed-in customer's registered devices (no raw tokens). */
|
|
48
|
+
listDevices(accessToken: string): Promise<RegisteredPushDevice[]>;
|
|
49
|
+
}
|
|
50
|
+
declare function createReoptPushClient(config: ReoptSDKConfig): ReoptPushClient;
|
|
51
|
+
//#endregion
|
|
52
|
+
export { RegisterPushTokenInput as a, UnregisterPushTokenInput as c, PushProvider as i, UnregisterPushTokenResult as l, createReoptPushClient as n, RegisterPushTokenResult as o, PushPlatform as r, RegisteredPushDevice as s, ReoptPushClient as t };
|
|
53
|
+
//# sourceMappingURL=client-D6gs61w8.d.ts.map
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { t as BaseHttpClient } from "./http-client-QKUvvirs.js";
|
|
2
|
+
|
|
3
|
+
//#region src/feedback/client.ts
|
|
4
|
+
function buildListQuery(query) {
|
|
5
|
+
const params = new URLSearchParams();
|
|
6
|
+
if (query.status) params.set("status", query.status);
|
|
7
|
+
if (query.customerId) params.set("customerId", query.customerId);
|
|
8
|
+
if (query.page != null) params.set("page", String(query.page));
|
|
9
|
+
if (query.limit != null) params.set("limit", String(query.limit));
|
|
10
|
+
const qs = params.toString();
|
|
11
|
+
return qs ? `?${qs}` : "";
|
|
12
|
+
}
|
|
13
|
+
var ReoptFeedbackClient = class {
|
|
14
|
+
http;
|
|
15
|
+
constructor(config) {
|
|
16
|
+
this.http = new BaseHttpClient(config, `/api/v1/brandapp/${config.brandappId}/feedback`);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Create a feedback with app credentials (server-to-server collection).
|
|
20
|
+
* Pass `customerId` to attribute it to a customer linked to this brandapp.
|
|
21
|
+
*/
|
|
22
|
+
async create(input) {
|
|
23
|
+
return (await this.http.fetch("POST", "", input)).data;
|
|
24
|
+
}
|
|
25
|
+
/** List feedback this brandapp collected (app credentials). */
|
|
26
|
+
async list(query = {}) {
|
|
27
|
+
const body = await this.http.fetch("GET", buildListQuery(query));
|
|
28
|
+
return {
|
|
29
|
+
feedbacks: body.data,
|
|
30
|
+
meta: body.meta
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/** Fetch one feedback with its reply thread (app credentials). */
|
|
34
|
+
async get(feedbackId) {
|
|
35
|
+
return (await this.http.fetch("GET", `/${encodeURIComponent(feedbackId)}`)).data;
|
|
36
|
+
}
|
|
37
|
+
/** End-user surface — requires the signed-in user's OAuth access token. */
|
|
38
|
+
me = {
|
|
39
|
+
/**
|
|
40
|
+
* Create a feedback as the signed-in user. The server resolves the
|
|
41
|
+
* token's linked customer; unlinked users get 403 `LINK_REQUIRED`
|
|
42
|
+
* (call `sdk.auth.linkCurrentUser` first).
|
|
43
|
+
*/
|
|
44
|
+
create: async (input, accessToken) => {
|
|
45
|
+
return (await this.http.fetch("POST", "/me", input, { bearerToken: accessToken })).data;
|
|
46
|
+
},
|
|
47
|
+
/**
|
|
48
|
+
* List the signed-in user's own feedback (all collection sources —
|
|
49
|
+
* brand form submissions included).
|
|
50
|
+
*/
|
|
51
|
+
list: async (accessToken, query = {}) => {
|
|
52
|
+
const body = await this.http.fetch("GET", `/me${buildListQuery(query)}`, void 0, { bearerToken: accessToken });
|
|
53
|
+
return {
|
|
54
|
+
feedbacks: body.data,
|
|
55
|
+
meta: body.meta
|
|
56
|
+
};
|
|
57
|
+
},
|
|
58
|
+
/** Fetch one of the signed-in user's feedback with its thread. */
|
|
59
|
+
get: async (feedbackId, accessToken) => {
|
|
60
|
+
return (await this.http.fetch("GET", `/me/${encodeURIComponent(feedbackId)}`, void 0, { bearerToken: accessToken })).data;
|
|
61
|
+
},
|
|
62
|
+
/**
|
|
63
|
+
* Reply to a staff answer on the signed-in user's own feedback, continuing
|
|
64
|
+
* the thread instead of filing a new feedback. An already-answered feedback
|
|
65
|
+
* flips back to `reopened` and the workspace is notified.
|
|
66
|
+
*/
|
|
67
|
+
reply: async (feedbackId, content, accessToken) => {
|
|
68
|
+
return (await this.http.fetch("POST", `/me/${encodeURIComponent(feedbackId)}/replies`, { content }, { bearerToken: accessToken })).data;
|
|
69
|
+
},
|
|
70
|
+
/**
|
|
71
|
+
* Rate a staff reply's usefulness (`true` helpful / `false` not helpful /
|
|
72
|
+
* `null` to clear). Rating alone does not reopen the feedback — send a
|
|
73
|
+
* `reply` when the customer still needs something.
|
|
74
|
+
*/
|
|
75
|
+
rateReply: async (feedbackId, replyId, helpful, accessToken) => {
|
|
76
|
+
return (await this.http.fetch("PUT", `/me/${encodeURIComponent(feedbackId)}/replies/${encodeURIComponent(replyId)}/rating`, { helpful }, { bearerToken: accessToken })).data;
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
function createReoptFeedbackClient(config) {
|
|
81
|
+
return new ReoptFeedbackClient(config);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
//#endregion
|
|
85
|
+
export { createReoptFeedbackClient as n, ReoptFeedbackClient as t };
|
|
86
|
+
//# sourceMappingURL=client-DBnK7ooQ.js.map
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { n as ReoptSDKConfig } from "./config-CRytOPPl.js";
|
|
2
|
+
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";
|
|
3
|
+
//#region src/cms/client.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Reopt CMS Client
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { createReoptSDK } from "@reopt-ai/brandapp-sdk";
|
|
10
|
+
*
|
|
11
|
+
* const sdk = createReoptSDK({
|
|
12
|
+
* clientId: process.env.BRANDAPP_CLIENT_ID!,
|
|
13
|
+
* clientSecret: process.env.BRANDAPP_CLIENT_SECRET!,
|
|
14
|
+
* brandappId: process.env.BRANDAPP_ID!,
|
|
15
|
+
* });
|
|
16
|
+
*
|
|
17
|
+
* const { records: posts } = await sdk.cms.posts.list({ status: "published" });
|
|
18
|
+
* const post = await sdk.cms.posts.get(postId);
|
|
19
|
+
* const post = await sdk.cms.posts.getBySlug("hello-world");
|
|
20
|
+
* const tags = await sdk.cms.tags.list();
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
type ReoptCmsClient = ReturnType<typeof createReoptCmsClient>;
|
|
24
|
+
declare function createReoptCmsClient(config: ReoptSDKConfig): {
|
|
25
|
+
posts: {
|
|
26
|
+
list(query?: ListPostsQuery): Promise<CmsPaginatedResponse<Post>>;
|
|
27
|
+
get(postId: string): Promise<PostDetail>;
|
|
28
|
+
/**
|
|
29
|
+
* Slug 기반 단건 조회. URL 라우트(`/blog/[slug]`)에서 id 매핑 없이 사용.
|
|
30
|
+
* 같은 slug가 여러 그룹에 있을 수 있는 경우 `groupId` 또는 `groupSlug`로 좁힐 수 있다.
|
|
31
|
+
*/
|
|
32
|
+
getBySlug(slug: string, opts?: {
|
|
33
|
+
groupId?: string;
|
|
34
|
+
groupSlug?: string;
|
|
35
|
+
}): Promise<PostDetail>;
|
|
36
|
+
};
|
|
37
|
+
postGroups: {
|
|
38
|
+
list(query?: ListPostGroupsQuery): Promise<CmsPaginatedResponse<PostGroup>>;
|
|
39
|
+
get(groupId: string): Promise<PostGroup>;
|
|
40
|
+
/**
|
|
41
|
+
* Slug 기반 그룹 단건 조회. env var(`REOPT_*_GROUP_ID`) 대신 slug 하드코딩
|
|
42
|
+
* 패턴(`CONTENT_GROUPS.blog.slug`)을 권장.
|
|
43
|
+
*/
|
|
44
|
+
getBySlug(slug: string): Promise<PostGroup>;
|
|
45
|
+
};
|
|
46
|
+
tags: {
|
|
47
|
+
/** Brand 범위 안에서 사용된 포스트 태그 목록을 반환. */
|
|
48
|
+
list(query?: ListTagsQuery): Promise<Tag[]>;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
//#endregion
|
|
52
|
+
export { createReoptCmsClient as n, ReoptCmsClient as t };
|
|
53
|
+
//# sourceMappingURL=client-DDw5yz_h.d.ts.map
|