@reopt-ai/brandapp-sdk 3.3.0 → 3.5.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.
Files changed (104) hide show
  1. package/CHANGELOG.md +115 -0
  2. package/README.md +10 -1
  3. package/dist/abort--nOBFN4M.js +50 -0
  4. package/dist/ai/index.d.ts +2 -314
  5. package/dist/ai/index.js +3 -8
  6. package/dist/ai-provider/index.d.ts +79 -163
  7. package/dist/ai-provider/index.js +752 -685
  8. package/dist/auth/index.d.ts +27 -27
  9. package/dist/auth/index.js +41 -34
  10. package/dist/better-auth/client.d.ts +6 -5
  11. package/dist/better-auth/client.js +28 -5
  12. package/dist/better-auth/index.d.ts +19 -17
  13. package/dist/better-auth/index.js +180 -144
  14. package/dist/client-61ldOHMz.js +503 -0
  15. package/dist/client-7PCoxVhZ.js +28 -0
  16. package/dist/client-B7rZQ8Zi.d.ts +272 -0
  17. package/dist/client-BGGd_cpV.d.ts +103 -0
  18. package/dist/client-BoIuyx4S.js +273 -0
  19. package/dist/client-BruP5_nU.d.ts +147 -0
  20. package/dist/client-BxtZt405.js +305 -0
  21. package/dist/client-ByN3EQdk.js +83 -0
  22. package/dist/client-CAghoGD_.js +53 -0
  23. package/dist/client-C_pHsPlj.js +81 -0
  24. package/dist/client-D0eBxh8j.d.ts +284 -0
  25. package/dist/client-D6gs61w8.d.ts +53 -0
  26. package/dist/client-DDw5yz_h.d.ts +53 -0
  27. package/dist/client-Dxg8_DIH.d.ts +71 -0
  28. package/dist/client-aMR4CRB8.d.ts +211 -0
  29. package/dist/client-lk6wBu_0.d.ts +48 -0
  30. package/dist/client-wEVKLdly.js +55 -0
  31. package/dist/client-zF1RG2uA.js +86 -0
  32. package/dist/cms/index.d.ts +52 -108
  33. package/dist/cms/index.js +103 -86
  34. package/dist/config-CRytOPPl.d.ts +394 -0
  35. package/dist/config-aml9oQpX.js +487 -0
  36. package/dist/dev/index.d.ts +2 -528
  37. package/dist/dev/index.js +3047 -2967
  38. package/dist/eav/coerce.d.ts +3 -1
  39. package/dist/eav/coerce.js +72 -46
  40. package/dist/eav/index.d.ts +72 -100
  41. package/dist/eav/index.js +158 -126
  42. package/dist/eav/migrate.d.ts +112 -109
  43. package/dist/eav/migrate.js +230 -196
  44. package/dist/eav/schema.d.ts +111 -150
  45. package/dist/eav/schema.js +624 -603
  46. package/dist/encoding-Bwfm3iaE.js +21 -0
  47. package/dist/{errors-BjDFIyA6.d.ts → errors-CRCcErNC.d.ts} +55 -53
  48. package/dist/feedback/index.d.ts +2 -132
  49. package/dist/feedback/index.js +3 -6
  50. package/dist/files/index.d.ts +14 -14
  51. package/dist/files/index.js +41 -25
  52. package/dist/http-client-BZc2mngq.js +386 -0
  53. package/dist/index-1j_738qk.d.ts +470 -0
  54. package/dist/index-CeOLGdyL.d.ts +169 -0
  55. package/dist/index.d.ts +6 -230
  56. package/dist/index.js +119 -71
  57. package/dist/logout/index.d.ts +56 -53
  58. package/dist/logout/index.js +232 -289
  59. package/dist/plans/index.d.ts +2 -236
  60. package/dist/plans/index.js +3 -6
  61. package/dist/push/index.d.ts +2 -79
  62. package/dist/push/index.js +3 -6
  63. package/dist/query-xWqtfkvR.js +35 -0
  64. package/dist/react/hooks.d.ts +157 -100
  65. package/dist/react/hooks.js +862 -406
  66. package/dist/sse-parser-FMjxM7sY.js +86 -0
  67. package/dist/terms/index.d.ts +3 -79
  68. package/dist/terms/index.js +3 -6
  69. package/dist/testing/index.d.ts +52 -104
  70. package/dist/testing/index.js +94 -72
  71. package/dist/types-B-SMkH6s.d.ts +26 -0
  72. package/dist/types-BXDcoJHG.d.ts +131 -0
  73. package/dist/types-BrghN2rJ.d.ts +105 -0
  74. package/dist/types-DjDRszNj.js +11 -0
  75. package/dist/webhooks/index.d.ts +77 -50
  76. package/dist/webhooks/index.js +150 -127
  77. package/docs/api-reference.md +121 -8
  78. package/docs/errors.md +19 -0
  79. package/docs/files.md +165 -7
  80. package/package.json +7 -6
  81. package/dist/chunk-2LSCQHAU.js +0 -21
  82. package/dist/chunk-4U4ZPPL4.js +0 -599
  83. package/dist/chunk-55KHY5GH.js +0 -96
  84. package/dist/chunk-C5VTRZWX.js +0 -458
  85. package/dist/chunk-F7BXBTZI.js +0 -54
  86. package/dist/chunk-FJUCWXX3.js +0 -350
  87. package/dist/chunk-H33OTQEN.js +0 -112
  88. package/dist/chunk-L4DHB36G.js +0 -75
  89. package/dist/chunk-OG7R3UAR.js +0 -105
  90. package/dist/chunk-PF24XU54.js +0 -32
  91. package/dist/chunk-QN3QD67K.js +0 -49
  92. package/dist/chunk-REIKXSMY.js +0 -7
  93. package/dist/chunk-UGBBXCZE.js +0 -157
  94. package/dist/chunk-UVT2E6KD.js +0 -81
  95. package/dist/chunk-YPLT3RFL.js +0 -63
  96. package/dist/chunk-YTKSAWV2.js +0 -463
  97. package/dist/client-BkcO-0C2.d.ts +0 -216
  98. package/dist/client-CN5_tNOC.d.ts +0 -147
  99. package/dist/client-DttyeM_h.d.ts +0 -102
  100. package/dist/config-CtxyJsDR.d.ts +0 -397
  101. package/dist/typed-client-BxOVIiMU.d.ts +0 -40
  102. package/dist/types-6E3ZLL9X.d.ts +0 -24
  103. package/dist/types-DskYLVb8.d.ts +0 -104
  104. package/dist/types-ckmDDW3N.d.ts +0 -129
@@ -1,350 +0,0 @@
1
- import { parseSSEStream } from './chunk-L4DHB36G.js';
2
- import { createManagedAbort } from './chunk-F7BXBTZI.js';
3
- import { BaseHttpClient } from './chunk-YTKSAWV2.js';
4
- import { validateConfig, ReoptSDKError, mapHttpStatusToError, SDK_VERSION } from './chunk-C5VTRZWX.js';
5
-
6
- // src/ai/client.ts
7
- var ReoptAiClient = class {
8
- http;
9
- /**
10
- * Idle (inactivity) timeout for streaming, in ms — the maximum gap allowed
11
- * *between* SSE chunks, not a deadline on the whole generation. A long but
12
- * healthy generation keeps resetting this; only a genuine stall aborts.
13
- */
14
- streamIdleTimeout;
15
- constructor(config) {
16
- validateConfig(config);
17
- const pathPrefix = `/api/v1/brandapp/${config.brandappId}/ai`;
18
- this.http = new BaseHttpClient(config, pathPrefix);
19
- this.streamIdleTimeout = config.timeout ?? 6e4;
20
- }
21
- /**
22
- * AI 텍스트 생성 (non-streaming)
23
- *
24
- * @example
25
- * ```ts
26
- * const result = await sdk.ai.complete({
27
- * messages: [{ role: "user", content: "Hello" }],
28
- * model: "anthropic/claude-haiku-4.5",
29
- * maxTokens: 1024,
30
- * });
31
- * console.log(result.message.content);
32
- * ```
33
- */
34
- async complete(options) {
35
- const response = await this.http.fetch(
36
- "POST",
37
- "/chat/completions",
38
- {
39
- model: options.model,
40
- agentId: options.agentId,
41
- messages: options.messages,
42
- maxTokens: options.maxTokens,
43
- temperature: options.temperature,
44
- stream: false,
45
- customerId: options.customerId
46
- }
47
- );
48
- return response.data;
49
- }
50
- /**
51
- * AI 텍스트 생성 (SSE 스트리밍)
52
- *
53
- * async generator로 텍스트 청크를 반환합니다.
54
- * 사용량 메타데이터가 필요하면 `streamWithMetadata()`를 사용하세요.
55
- *
56
- * @example
57
- * ```ts
58
- * for await (const chunk of sdk.ai.stream({
59
- * messages: [{ role: "user", content: "Hello" }],
60
- * })) {
61
- * process.stdout.write(chunk);
62
- * }
63
- * ```
64
- */
65
- async *stream(options) {
66
- const { response, managed, requestId } = await this.fetchSSE(options);
67
- if (!response.body) {
68
- managed.cleanup();
69
- throw new ReoptSDKError("No response body", 0, "STREAM_ERROR");
70
- }
71
- try {
72
- for await (const { event, data } of parseSSEStream(response.body)) {
73
- managed.kick();
74
- if (event === "text-delta") {
75
- yield data;
76
- } else if (event === "error") {
77
- const ctx = { requestId };
78
- try {
79
- const err = JSON.parse(data);
80
- if (typeof err.status === "number") {
81
- throw mapHttpStatusToError(
82
- err.status,
83
- err.code,
84
- err.message,
85
- ctx
86
- );
87
- }
88
- throw new ReoptSDKError(
89
- err.message ?? "Stream error",
90
- 0,
91
- err.code ?? "STREAM_ERROR",
92
- ctx
93
- );
94
- } catch (e) {
95
- if (e instanceof ReoptSDKError) throw e;
96
- throw new ReoptSDKError(data, 0, "STREAM_ERROR", ctx);
97
- }
98
- }
99
- }
100
- } catch (e) {
101
- throw mapStreamError(e, managed);
102
- } finally {
103
- managed.cleanup();
104
- }
105
- }
106
- /**
107
- * AI 텍스트 생성 (SSE 스트리밍 + 메타데이터)
108
- *
109
- * 텍스트 청크와 함께 최종 사용량/크레딧 메타데이터를 반환합니다.
110
- *
111
- * @example
112
- * ```ts
113
- * const { textStream, metadata } = sdk.ai.streamWithMetadata({
114
- * messages: [{ role: "user", content: "Hello" }],
115
- * });
116
- *
117
- * let text = "";
118
- * for await (const chunk of textStream) {
119
- * text += chunk;
120
- * }
121
- *
122
- * const meta = await metadata;
123
- * console.log(`사용 크레딧: ${meta?.usage.creditCost}`);
124
- * ```
125
- */
126
- streamWithMetadata(options) {
127
- let resolveMeta;
128
- const metadata = new Promise((r) => {
129
- resolveMeta = r;
130
- });
131
- let settled = false;
132
- const settle = (v) => {
133
- if (settled) return;
134
- settled = true;
135
- resolveMeta(v);
136
- };
137
- const self = this;
138
- async function* gen() {
139
- const { response, managed, requestId } = await self.fetchSSE(options);
140
- if (!response.body) {
141
- managed.cleanup();
142
- settle(null);
143
- throw new ReoptSDKError("No response body", 0, "STREAM_ERROR");
144
- }
145
- try {
146
- for await (const { event, data } of parseSSEStream(response.body)) {
147
- managed.kick();
148
- if (event === "text-delta") {
149
- yield data;
150
- } else if (event === "done") {
151
- try {
152
- settle(JSON.parse(data));
153
- } catch {
154
- settle(null);
155
- }
156
- } else if (event === "error") {
157
- const ctx = { requestId };
158
- try {
159
- const err = JSON.parse(data);
160
- if (typeof err.status === "number") {
161
- throw mapHttpStatusToError(
162
- err.status,
163
- err.code,
164
- err.message,
165
- ctx
166
- );
167
- }
168
- throw new ReoptSDKError(
169
- err.message ?? "Stream error",
170
- 0,
171
- err.code ?? "STREAM_ERROR",
172
- ctx
173
- );
174
- } catch (e) {
175
- if (e instanceof ReoptSDKError) throw e;
176
- throw new ReoptSDKError(data, 0, "STREAM_ERROR", ctx);
177
- }
178
- }
179
- }
180
- } catch (e) {
181
- throw mapStreamError(e, managed);
182
- } finally {
183
- settle(null);
184
- managed.cleanup();
185
- }
186
- }
187
- return { textStream: gen(), metadata };
188
- }
189
- /**
190
- * 이미지 생성
191
- *
192
- * BrandApp의 AI 크레딧으로 이미지를 생성합니다.
193
- * 생성된 이미지는 자동으로 Vercel Blob에 저장되고 URL이 반환됩니다.
194
- *
195
- * @example
196
- * ```ts
197
- * const image = await sdk.ai.generateImage({
198
- * prompt: "브랜드 배너 이미지",
199
- * style: "minimalist",
200
- * aspectRatio: "16:9",
201
- * });
202
- * console.log(image.url); // https://...blob.vercel-storage.com/...
203
- * console.log(image.size); // 12345 (bytes)
204
- * ```
205
- */
206
- async generateImage(options) {
207
- const response = await this.http.fetch(
208
- "POST",
209
- "/images/generate",
210
- {
211
- prompt: options.prompt,
212
- negativePrompt: options.negativePrompt,
213
- style: options.style,
214
- aspectRatio: options.aspectRatio ?? "1:1",
215
- model: options.model,
216
- customerId: options.customerId
217
- }
218
- );
219
- return response.data;
220
- }
221
- /**
222
- * 크레딧 잔액 조회
223
- *
224
- * @example
225
- * ```ts
226
- * const credits = await sdk.ai.credits();
227
- * console.log(`${credits.balance} / ${credits.limit} (${credits.status})`);
228
- * ```
229
- */
230
- async credits() {
231
- const response = await this.http.fetch(
232
- "GET",
233
- "/credits"
234
- );
235
- return response.data;
236
- }
237
- /**
238
- * 사용 가능 모델 목록 조회
239
- *
240
- * @example
241
- * ```ts
242
- * const models = await sdk.ai.models();
243
- * models.forEach(m => console.log(`${m.id} (${m.tierLabel})`));
244
- * ```
245
- */
246
- async models() {
247
- const response = await this.http.fetch(
248
- "GET",
249
- "/models"
250
- );
251
- return response.data;
252
- }
253
- /**
254
- * 사용 가능한 커스텀 에이전트 목록 조회
255
- *
256
- * @example
257
- * ```ts
258
- * const agents = await sdk.ai.agents();
259
- * for (const agent of agents) {
260
- * console.log(`${agent.name}: ${agent.description}`);
261
- * }
262
- * ```
263
- */
264
- async agents() {
265
- const response = await this.http.fetch(
266
- "GET",
267
- "/agents"
268
- );
269
- return response.data;
270
- }
271
- // ---------------------------------------------------------------------------
272
- // Internal: SSE fetch (BaseHttpClient는 JSON 전용이므로 직접 fetch)
273
- // ---------------------------------------------------------------------------
274
- async fetchSSE(options) {
275
- const url = `${this.http.requestBaseUrl}/chat/completions`;
276
- const requestId = globalThis.crypto?.randomUUID?.() ?? `sdk-${SDK_VERSION}-${url.length}`;
277
- const ctx = { method: "POST", url, requestId };
278
- const maxConnectAttempts = 2;
279
- let lastConnectError;
280
- for (let attempt = 0; attempt < maxConnectAttempts; attempt++) {
281
- const managed = createManagedAbort({
282
- timeoutMs: this.streamIdleTimeout,
283
- external: options.signal,
284
- idle: true
285
- });
286
- try {
287
- const response = await globalThis.fetch(url, {
288
- method: "POST",
289
- headers: {
290
- Authorization: this.http.authorizationHeader,
291
- "Content-Type": "application/json",
292
- Accept: "text/event-stream",
293
- "X-SDK-Version": `brandapp-sdk/${SDK_VERSION}`,
294
- "X-Request-Id": requestId,
295
- "Idempotency-Key": requestId
296
- },
297
- body: JSON.stringify({
298
- model: options.model,
299
- agentId: options.agentId,
300
- messages: options.messages,
301
- maxTokens: options.maxTokens,
302
- temperature: options.temperature,
303
- stream: true,
304
- customerId: options.customerId
305
- }),
306
- signal: managed.signal
307
- });
308
- if (!response.ok) {
309
- const body = await response.json().catch(() => ({}));
310
- const err = body?.error ?? {};
311
- managed.cleanup();
312
- throw mapHttpStatusToError(
313
- response.status,
314
- err.code,
315
- err.message ?? `HTTP ${response.status}`,
316
- ctx
317
- );
318
- }
319
- return { response, managed, requestId };
320
- } catch (e) {
321
- managed.cleanup();
322
- if (e instanceof ReoptSDKError) throw e;
323
- if (managed.timedOut || options.signal?.aborted) {
324
- throw mapStreamError(e, managed);
325
- }
326
- lastConnectError = e;
327
- if (attempt < maxConnectAttempts - 1) continue;
328
- throw mapStreamError(e, managed);
329
- }
330
- }
331
- throw mapStreamError(lastConnectError, void 0);
332
- }
333
- };
334
- function mapStreamError(e, managed) {
335
- if (e instanceof ReoptSDKError) return e;
336
- if (e instanceof Error && e.name === "AbortError") {
337
- if (managed?.timedOut) {
338
- return new ReoptSDKError("Stream request timed out", 408, "TIMEOUT");
339
- }
340
- return new ReoptSDKError("Stream cancelled by caller", 0, "CANCELLED");
341
- }
342
- return e;
343
- }
344
- function createReoptAiClient(config) {
345
- return new ReoptAiClient(config);
346
- }
347
-
348
- export { ReoptAiClient, createReoptAiClient };
349
- //# sourceMappingURL=chunk-FJUCWXX3.js.map
350
- //# sourceMappingURL=chunk-FJUCWXX3.js.map
@@ -1,112 +0,0 @@
1
- import { BaseHttpClient } from './chunk-YTKSAWV2.js';
2
-
3
- // src/terms/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
- function isListOptions(value) {
12
- return value !== null && typeof value === "object" && !Array.isArray(value);
13
- }
14
- function buildListQuery(options) {
15
- const params = new URLSearchParams();
16
- if (options.country) params.set("country", options.country);
17
- if (options.locale) params.set("locale", options.locale);
18
- if (options.jurisdiction) params.set("jurisdiction", options.jurisdiction);
19
- const qs = params.toString();
20
- return qs ? `?${qs}` : "";
21
- }
22
- var ReoptTermsClient = class {
23
- http;
24
- constructor(config) {
25
- this.http = new BaseHttpClient(
26
- config,
27
- `/api/v1/brandapp/${config.brandappId}/terms`
28
- );
29
- }
30
- /**
31
- * List active terms for this Brandapp with their currently-published
32
- * version. Works with either Basic Auth (default) or Bearer Auth — when
33
- * called from a server handler that has the user's access token, pass
34
- * `accessToken` to avoid sending app credentials.
35
- *
36
- * Accepts either an `accessToken` string (legacy) or an options object
37
- * (`country`/`locale`/`jurisdiction`/`accessToken`) for jurisdiction-aware
38
- * matching. When `country` / `locale` are omitted, the server falls back to
39
- * request headers (`x-vercel-ip-country`, `Accept-Language`).
40
- *
41
- * Returns the matched terms array. For matching metadata
42
- * (jurisdiction, locale, source) use {@link listWithMeta}.
43
- */
44
- async list(optionsOrToken) {
45
- const response = await this.listWithMeta(optionsOrToken);
46
- return response.terms;
47
- }
48
- /**
49
- * Same as {@link list} but returns the full {@link TermsListResponse} including
50
- * matched jurisdiction, country and locale — useful for displaying "약관이
51
- * 어떤 국가 기준으로 적용됐는지" hint in the signup UX.
52
- */
53
- async listWithMeta(optionsOrToken) {
54
- const options = isListOptions(optionsOrToken) ? optionsOrToken : optionsOrToken ? { accessToken: optionsOrToken } : {};
55
- const query = buildListQuery(options);
56
- const path = query || "";
57
- const body = await this.http.fetch(
58
- "GET",
59
- path,
60
- void 0,
61
- options.accessToken ? { bearerToken: options.accessToken } : void 0
62
- );
63
- return unwrap(body);
64
- }
65
- /**
66
- * Fetch the consent history (granted / withdrawn / pendingReConsent) for
67
- * the OAuth user represented by `accessToken`.
68
- */
69
- async listMyConsents(accessToken) {
70
- const body = await this.http.fetch(
71
- "GET",
72
- "/me/consents",
73
- void 0,
74
- { bearerToken: accessToken }
75
- );
76
- return unwrap(body);
77
- }
78
- /**
79
- * Record consent for one or more terms versions. The server rejects the
80
- * call with `REQUIRED_NOT_CONSENTED` (422) if any required term is missing
81
- * or marked as `consented: false`.
82
- */
83
- async consent(input, accessToken) {
84
- const body = await this.http.fetch(
85
- "POST",
86
- "/me/consents",
87
- input,
88
- { bearerToken: accessToken }
89
- );
90
- return unwrap(body);
91
- }
92
- /**
93
- * Withdraw a previously-granted consent. The server returns 409 for
94
- * required terms or already-withdrawn records.
95
- */
96
- async withdraw(consentId, accessToken) {
97
- const body = await this.http.fetch(
98
- "DELETE",
99
- `/me/consents/${encodeURIComponent(consentId)}`,
100
- void 0,
101
- { bearerToken: accessToken }
102
- );
103
- return unwrap(body);
104
- }
105
- };
106
- function createReoptTermsClient(config) {
107
- return new ReoptTermsClient(config);
108
- }
109
-
110
- export { ReoptTermsClient, createReoptTermsClient };
111
- //# sourceMappingURL=chunk-H33OTQEN.js.map
112
- //# sourceMappingURL=chunk-H33OTQEN.js.map
@@ -1,75 +0,0 @@
1
- // src/core/sse-parser.ts
2
- function createSSELineProcessor(onEvent) {
3
- let buffer = "";
4
- let currentEvent = "";
5
- let dataBuffer = "";
6
- function processLine(line) {
7
- const stripped = line.endsWith("\r") ? line.slice(0, -1) : line;
8
- if (stripped.startsWith("event:")) {
9
- const raw = stripped.slice(6);
10
- currentEvent = raw.startsWith(" ") ? raw.slice(1) : raw;
11
- } else if (stripped.startsWith("data:")) {
12
- const raw = stripped.slice(5);
13
- const data = raw.startsWith(" ") ? raw.slice(1) : raw;
14
- dataBuffer = dataBuffer ? dataBuffer + "\n" + data : data;
15
- } else if (stripped === "") {
16
- if (dataBuffer) {
17
- onEvent({ event: currentEvent, data: dataBuffer });
18
- }
19
- currentEvent = "";
20
- dataBuffer = "";
21
- }
22
- }
23
- return {
24
- feed(chunk) {
25
- buffer += chunk;
26
- const lines = buffer.split("\n");
27
- buffer = lines.pop() ?? "";
28
- for (const line of lines) processLine(line);
29
- },
30
- /**
31
- * Flush any buffered input at stream end.
32
- * Processes the last partial line (if any) and emits a final event
33
- * if a data buffer is still pending.
34
- */
35
- flush() {
36
- if (buffer.length > 0) {
37
- processLine(buffer);
38
- buffer = "";
39
- }
40
- if (dataBuffer) {
41
- onEvent({ event: currentEvent, data: dataBuffer });
42
- currentEvent = "";
43
- dataBuffer = "";
44
- }
45
- }
46
- };
47
- }
48
- async function* parseSSEStream(body) {
49
- const reader = body.getReader();
50
- const decoder = new TextDecoder();
51
- const pending = [];
52
- const processor = createSSELineProcessor((event) => {
53
- pending.push(event);
54
- });
55
- try {
56
- while (true) {
57
- const { done, value } = await reader.read();
58
- if (done) break;
59
- processor.feed(decoder.decode(value, { stream: true }));
60
- while (pending.length > 0) {
61
- yield pending.shift();
62
- }
63
- }
64
- processor.flush();
65
- while (pending.length > 0) {
66
- yield pending.shift();
67
- }
68
- } finally {
69
- reader.releaseLock();
70
- }
71
- }
72
-
73
- export { createSSELineProcessor, parseSSEStream };
74
- //# sourceMappingURL=chunk-L4DHB36G.js.map
75
- //# sourceMappingURL=chunk-L4DHB36G.js.map
@@ -1,105 +0,0 @@
1
- import { BaseHttpClient } from './chunk-YTKSAWV2.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-OG7R3UAR.js.map
105
- //# sourceMappingURL=chunk-OG7R3UAR.js.map
@@ -1,32 +0,0 @@
1
- import { ReoptSDKError } from './chunk-C5VTRZWX.js';
2
-
3
- // src/core/query.ts
4
- var MAX_QUERY_STRING_LENGTH = 7500;
5
- function buildQuery(params) {
6
- const entries = Object.entries(params).filter(
7
- ([, v]) => v !== void 0 && v !== null
8
- );
9
- if (entries.length === 0) return "";
10
- const qs = "?" + entries.map(([k, v]) => {
11
- const value = typeof v === "object" ? JSON.stringify(v) : String(v);
12
- return `${k}=${encodeURIComponent(value)}`;
13
- }).join("&");
14
- if (qs.length > MAX_QUERY_STRING_LENGTH) {
15
- throw new ReoptSDKError(
16
- `Query string is too large (${qs.length} chars, limit ${MAX_QUERY_STRING_LENGTH}). Reduce the number of filters or the size of filter values.`,
17
- 0,
18
- "QUERY_TOO_LARGE",
19
- void 0,
20
- {
21
- cause: "GET \uC694\uCCAD\uC758 \uCFFC\uB9AC\uC2A4\uD2B8\uB9C1\uC774 \uC11C\uBC84/\uD504\uB85D\uC2DC\uC758 URL \uAE38\uC774 \uD55C\uB3C4(\uD1B5\uC0C1 8KB)\uB97C \uCD08\uACFC\uD560 \uC704\uD5D8\uC774 \uC788\uC74C",
22
- fix: "filters \uAC1C\uC218\uB97C \uC904\uC774\uAC70\uB098, \uD070 value(\uC608: \uAE34 contains \uBB38\uC790\uC5F4)\uB97C \uBD84\uB9AC/\uCD95\uC18C. \uB300\uB7C9 \uC870\uAC74\uC740 \uC5EC\uB7EC \uBC88 \uB098\uB220 \uC870\uD68C",
23
- doc: "docs/errors.md#query_too_large"
24
- }
25
- );
26
- }
27
- return qs;
28
- }
29
-
30
- export { buildQuery };
31
- //# sourceMappingURL=chunk-PF24XU54.js.map
32
- //# sourceMappingURL=chunk-PF24XU54.js.map