@reopt-ai/brandapp-sdk 3.3.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.
Files changed (102) hide show
  1. package/CHANGELOG.md +67 -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-B1q5P8rv.js +83 -0
  15. package/dist/client-B9QHVhdM.js +77 -0
  16. package/dist/client-BGGd_cpV.d.ts +103 -0
  17. package/dist/client-BJcy1V1a.js +140 -0
  18. package/dist/client-Beivhucf.js +55 -0
  19. package/dist/client-BruP5_nU.d.ts +147 -0
  20. package/dist/client-D-yNxNfk.js +28 -0
  21. package/dist/client-D0eBxh8j.d.ts +284 -0
  22. package/dist/client-D3RHHUUW.d.ts +207 -0
  23. package/dist/client-D6gs61w8.d.ts +53 -0
  24. package/dist/client-DBnK7ooQ.js +86 -0
  25. package/dist/client-DDw5yz_h.d.ts +53 -0
  26. package/dist/client-DPmoKuR9.js +305 -0
  27. package/dist/client-DsdakibF.js +503 -0
  28. package/dist/client-Dxg8_DIH.d.ts +71 -0
  29. package/dist/client-EbhUIhHq.js +53 -0
  30. package/dist/client-lk6wBu_0.d.ts +48 -0
  31. package/dist/client-p49ol9pg.d.ts +124 -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-Cw0a3-C8.js +487 -0
  36. package/dist/dev/index.d.ts +2 -528
  37. package/dist/dev/index.js +2731 -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-QKUvvirs.js +386 -0
  53. package/dist/index-DrVaKfhs.d.ts +456 -0
  54. package/dist/index-Z6OGcurJ.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-BvbCiGWb.js +35 -0
  64. package/dist/react/hooks.d.ts +97 -99
  65. package/dist/react/hooks.js +742 -404
  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 +87 -6
  78. package/package.json +6 -5
  79. package/dist/chunk-2LSCQHAU.js +0 -21
  80. package/dist/chunk-4U4ZPPL4.js +0 -599
  81. package/dist/chunk-55KHY5GH.js +0 -96
  82. package/dist/chunk-C5VTRZWX.js +0 -458
  83. package/dist/chunk-F7BXBTZI.js +0 -54
  84. package/dist/chunk-FJUCWXX3.js +0 -350
  85. package/dist/chunk-H33OTQEN.js +0 -112
  86. package/dist/chunk-L4DHB36G.js +0 -75
  87. package/dist/chunk-OG7R3UAR.js +0 -105
  88. package/dist/chunk-PF24XU54.js +0 -32
  89. package/dist/chunk-QN3QD67K.js +0 -49
  90. package/dist/chunk-REIKXSMY.js +0 -7
  91. package/dist/chunk-UGBBXCZE.js +0 -157
  92. package/dist/chunk-UVT2E6KD.js +0 -81
  93. package/dist/chunk-YPLT3RFL.js +0 -63
  94. package/dist/chunk-YTKSAWV2.js +0 -463
  95. package/dist/client-BkcO-0C2.d.ts +0 -216
  96. package/dist/client-CN5_tNOC.d.ts +0 -147
  97. package/dist/client-DttyeM_h.d.ts +0 -102
  98. package/dist/config-CtxyJsDR.d.ts +0 -397
  99. package/dist/typed-client-BxOVIiMU.d.ts +0 -40
  100. package/dist/types-6E3ZLL9X.d.ts +0 -24
  101. package/dist/types-DskYLVb8.d.ts +0 -104
  102. package/dist/types-ckmDDW3N.d.ts +0 -129
@@ -1,49 +0,0 @@
1
- import { BaseHttpClient } from './chunk-YTKSAWV2.js';
2
-
3
- // src/push/client.ts
4
- var ReoptPushClient = class {
5
- http;
6
- constructor(config) {
7
- this.http = new BaseHttpClient(
8
- config,
9
- `/api/v1/brandapp/${config.brandappId}/push`
10
- );
11
- }
12
- /** Register (or refresh) the signed-in customer's device push token. */
13
- async registerDeviceToken(input, accessToken) {
14
- const body = await this.http.fetch(
15
- "POST",
16
- "/me/tokens",
17
- input,
18
- { bearerToken: accessToken }
19
- );
20
- return body.data;
21
- }
22
- /** Unregister a device token by `token` or `deviceId` (own tokens only). */
23
- async unregisterDeviceToken(input, accessToken) {
24
- const body = await this.http.fetch(
25
- "DELETE",
26
- "/me/tokens",
27
- input,
28
- { bearerToken: accessToken }
29
- );
30
- return body.data;
31
- }
32
- /** List the signed-in customer's registered devices (no raw tokens). */
33
- async listDevices(accessToken) {
34
- const body = await this.http.fetch(
35
- "GET",
36
- "/me/tokens",
37
- void 0,
38
- { bearerToken: accessToken }
39
- );
40
- return body.data;
41
- }
42
- };
43
- function createReoptPushClient(config) {
44
- return new ReoptPushClient(config);
45
- }
46
-
47
- export { ReoptPushClient, createReoptPushClient };
48
- //# sourceMappingURL=chunk-QN3QD67K.js.map
49
- //# sourceMappingURL=chunk-QN3QD67K.js.map
@@ -1,7 +0,0 @@
1
- // src/better-auth/types.ts
2
- var REOPT_PROVIDER_ID = "reopt";
3
- var REOPT_DEFAULT_SCOPES = ["openid", "profile", "email"];
4
-
5
- export { REOPT_DEFAULT_SCOPES, REOPT_PROVIDER_ID };
6
- //# sourceMappingURL=chunk-REIKXSMY.js.map
7
- //# sourceMappingURL=chunk-REIKXSMY.js.map
@@ -1,157 +0,0 @@
1
- import { createManagedAbort } from './chunk-F7BXBTZI.js';
2
- import { BaseHttpClient, parseFieldErrors } from './chunk-YTKSAWV2.js';
3
- import { validateConfig, SDK_VERSION, mapHttpStatusToError, ReoptSDKError } from './chunk-C5VTRZWX.js';
4
-
5
- // src/files/client.ts
6
- var ReoptFileClient = class {
7
- http;
8
- timeout;
9
- constructor(config) {
10
- validateConfig(config);
11
- const pathPrefix = `/api/v1/brandapp/${config.brandappId}/files`;
12
- this.http = new BaseHttpClient(config, pathPrefix);
13
- this.timeout = config.timeout ?? 3e4;
14
- }
15
- /**
16
- * 파일 목록 조회
17
- *
18
- * @example
19
- * ```ts
20
- * const { data: files, meta } = await sdk.files.list({
21
- * page: 1,
22
- * limit: 20,
23
- * contentType: "image/*",
24
- * sortBy: "createdAt",
25
- * sortOrder: "desc",
26
- * });
27
- * console.log(`Total: ${meta.total}`);
28
- * ```
29
- */
30
- async list(query) {
31
- const params = new URLSearchParams();
32
- if (query?.page != null) params.set("page", String(query.page));
33
- if (query?.limit != null) params.set("limit", String(query.limit));
34
- if (query?.contentType) params.set("contentType", query.contentType);
35
- if (query?.sortBy) params.set("sortBy", query.sortBy);
36
- if (query?.sortOrder) params.set("sortOrder", query.sortOrder);
37
- const qs = params.toString();
38
- const path = qs ? `?${qs}` : "";
39
- return this.http.fetch("GET", path);
40
- }
41
- /**
42
- * 단일 파일 조회
43
- *
44
- * @example
45
- * ```ts
46
- * const file = await sdk.files.get("file-uuid");
47
- * console.log(file.name, file.url);
48
- * ```
49
- */
50
- async get(fileId) {
51
- const response = await this.http.fetch(
52
- "GET",
53
- `/${encodeURIComponent(fileId)}`
54
- );
55
- return response.data;
56
- }
57
- /**
58
- * 파일 삭제
59
- *
60
- * @example
61
- * ```ts
62
- * await sdk.files.delete("file-uuid");
63
- * ```
64
- */
65
- async delete(fileId) {
66
- await this.http.fetch("DELETE", `/${encodeURIComponent(fileId)}`);
67
- }
68
- /**
69
- * 파일 업로드
70
- *
71
- * FormData(multipart)로 파일을 전송합니다.
72
- * BaseHttpClient는 JSON 전용이므로 globalThis.fetch를 직접 사용합니다.
73
- *
74
- * @example
75
- * ```ts
76
- * // Blob 업로드
77
- * const blob = new Blob(["hello"], { type: "text/plain" });
78
- * const file = await sdk.files.upload(blob, { name: "hello.txt" });
79
- *
80
- * // File 업로드 (브라우저)
81
- * const file = await sdk.files.upload(inputEl.files[0]);
82
- *
83
- * // Buffer 업로드 (Node.js)
84
- * const buf = fs.readFileSync("image.png");
85
- * const file = await sdk.files.upload(buf, {
86
- * name: "image.png",
87
- * contentType: "image/png",
88
- * });
89
- * ```
90
- */
91
- async upload(file, options) {
92
- const formData = new FormData();
93
- if (file instanceof Blob) {
94
- const fileName = options?.name ?? ("name" in file ? file.name : "upload");
95
- formData.append("file", file, fileName);
96
- } else {
97
- const arrayBuffer = file.buffer.slice(
98
- file.byteOffset,
99
- file.byteOffset + file.byteLength
100
- );
101
- const blob = new Blob([arrayBuffer], {
102
- type: options?.contentType ?? "application/octet-stream"
103
- });
104
- formData.append("file", blob, options?.name ?? "upload");
105
- }
106
- if (options?.name) formData.append("name", options.name);
107
- if (options?.contentType)
108
- formData.append("contentType", options.contentType);
109
- const url = `${this.http.requestBaseUrl}/upload`;
110
- const managed = createManagedAbort({
111
- timeoutMs: options?.timeout ?? this.timeout,
112
- external: options?.signal
113
- });
114
- try {
115
- const response = await globalThis.fetch(url, {
116
- method: "POST",
117
- headers: {
118
- Authorization: this.http.authorizationHeader,
119
- "X-SDK-Version": `brandapp-sdk/${SDK_VERSION}`
120
- // Content-Type은 FormData가 자동 설정 (boundary 포함)
121
- },
122
- body: formData,
123
- signal: managed.signal
124
- });
125
- if (!response.ok) {
126
- const body = await response.json().catch(() => ({}));
127
- const errObj = typeof body.error === "object" ? body.error : void 0;
128
- const msg = errObj?.message ?? (typeof body.error === "string" ? body.error : void 0) ?? `Upload failed with status ${response.status}`;
129
- const fieldErrors = response.status === 422 ? parseFieldErrors(body) : [];
130
- throw mapHttpStatusToError(
131
- response.status,
132
- errObj?.code,
133
- msg,
134
- { method: "POST", url },
135
- fieldErrors
136
- );
137
- }
138
- const result = await response.json();
139
- return result.data;
140
- } catch (e) {
141
- if (e instanceof ReoptSDKError) throw e;
142
- if (e instanceof Error && e.name === "AbortError") {
143
- throw new ReoptSDKError("Upload request timed out", 408, "TIMEOUT");
144
- }
145
- throw e;
146
- } finally {
147
- managed.cleanup();
148
- }
149
- }
150
- };
151
- function createReoptFileClient(config) {
152
- return new ReoptFileClient(config);
153
- }
154
-
155
- export { ReoptFileClient, createReoptFileClient };
156
- //# sourceMappingURL=chunk-UGBBXCZE.js.map
157
- //# sourceMappingURL=chunk-UGBBXCZE.js.map
@@ -1,81 +0,0 @@
1
- import { buildQuery } from './chunk-PF24XU54.js';
2
- import { BaseHttpClient } from './chunk-YTKSAWV2.js';
3
-
4
- // src/cms/client.ts
5
- function createReoptCmsClient(config) {
6
- const http = new BaseHttpClient(
7
- config,
8
- `/api/v1/brandapp/${config.brandappId}/cms`
9
- );
10
- return {
11
- posts: {
12
- async list(query) {
13
- const qs = buildQuery(query ?? {});
14
- const res = await http.fetch(
15
- "GET",
16
- `/posts${qs}`
17
- );
18
- return res.data;
19
- },
20
- async get(postId) {
21
- const res = await http.fetch(
22
- "GET",
23
- `/posts/${encodeURIComponent(postId)}`
24
- );
25
- return res.data;
26
- },
27
- /**
28
- * Slug 기반 단건 조회. URL 라우트(`/blog/[slug]`)에서 id 매핑 없이 사용.
29
- * 같은 slug가 여러 그룹에 있을 수 있는 경우 `groupId` 또는 `groupSlug`로 좁힐 수 있다.
30
- */
31
- async getBySlug(slug, opts) {
32
- const qs = buildQuery({
33
- groupId: opts?.groupId,
34
- groupSlug: opts?.groupSlug
35
- });
36
- const res = await http.fetch(
37
- "GET",
38
- `/posts/by-slug/${encodeURIComponent(slug)}${qs}`
39
- );
40
- return res.data;
41
- }
42
- },
43
- postGroups: {
44
- async list(query) {
45
- const qs = buildQuery(query ?? {});
46
- const res = await http.fetch("GET", `/post-groups${qs}`);
47
- return res.data;
48
- },
49
- async get(groupId) {
50
- const res = await http.fetch(
51
- "GET",
52
- `/post-groups/${encodeURIComponent(groupId)}`
53
- );
54
- return res.data;
55
- },
56
- /**
57
- * Slug 기반 그룹 단건 조회. env var(`REOPT_*_GROUP_ID`) 대신 slug 하드코딩
58
- * 패턴(`CONTENT_GROUPS.blog.slug`)을 권장.
59
- */
60
- async getBySlug(slug) {
61
- const res = await http.fetch(
62
- "GET",
63
- `/post-groups/by-slug/${encodeURIComponent(slug)}`
64
- );
65
- return res.data;
66
- }
67
- },
68
- tags: {
69
- /** Brand 범위 안에서 사용된 포스트 태그 목록을 반환. */
70
- async list(query) {
71
- const qs = buildQuery(query ?? {});
72
- const res = await http.fetch("GET", `/tags${qs}`);
73
- return res.data;
74
- }
75
- }
76
- };
77
- }
78
-
79
- export { createReoptCmsClient };
80
- //# sourceMappingURL=chunk-UVT2E6KD.js.map
81
- //# sourceMappingURL=chunk-UVT2E6KD.js.map
@@ -1,63 +0,0 @@
1
- import { BaseHttpClient } from './chunk-YTKSAWV2.js';
2
-
3
- // src/auth/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 ReoptAuthClient = class {
12
- /**
13
- * Root client for `/api/auth/*` endpoints (OIDC userinfo, etc). Pinned to
14
- * the id server because Better Auth's handler is only mounted there.
15
- */
16
- rootHttp;
17
- /** Brandapp-scoped client — prefixed for per-brandapp endpoints. */
18
- brandappHttp;
19
- constructor(config) {
20
- this.rootHttp = new BaseHttpClient(config, "", { useIdServer: true });
21
- this.brandappHttp = new BaseHttpClient(
22
- config,
23
- `/api/v1/brandapp/${config.brandappId}`
24
- );
25
- }
26
- /**
27
- * Upsert the Customer ↔ reoptUser link for the OAuth user represented by
28
- * the supplied access token.
29
- */
30
- async linkCurrentUser(accessToken) {
31
- const body = await this.brandappHttp.fetch("POST", "/external-auth", {}, { bearerToken: accessToken });
32
- return unwrap(body);
33
- }
34
- /**
35
- * Soft-withdraw the current OAuth user from this Brandapp: BrandappCustomer
36
- * flips to `churned`, the Brand↔Customer junction is removed, all
37
- * terms-consents move to `withdrawn`, and any Stripe subscription is
38
- * cancelled. The Customer record itself is retained so re-linking later
39
- * restores the same customerId (see `linkCurrentUser`).
40
- */
41
- async withdrawCurrentUser(accessToken) {
42
- const body = await this.brandappHttp.fetch("DELETE", "/external-auth", void 0, { bearerToken: accessToken });
43
- return unwrap(body);
44
- }
45
- /**
46
- * Fetch the OIDC userinfo claims for the supplied access token.
47
- */
48
- async getUserInfo(accessToken) {
49
- return this.rootHttp.fetch(
50
- "GET",
51
- "/api/auth/oauth2/userinfo",
52
- void 0,
53
- { bearerToken: accessToken }
54
- );
55
- }
56
- };
57
- function createReoptAuthClient(config) {
58
- return new ReoptAuthClient(config);
59
- }
60
-
61
- export { ReoptAuthClient, createReoptAuthClient };
62
- //# sourceMappingURL=chunk-YPLT3RFL.js.map
63
- //# sourceMappingURL=chunk-YPLT3RFL.js.map