@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.
Files changed (104) hide show
  1. package/CHANGELOG.md +147 -0
  2. package/README.md +39 -14
  3. package/dist/abort--nOBFN4M.js +50 -0
  4. package/dist/ai/index.d.ts +2 -314
  5. package/dist/ai/index.js +3 -7
  6. package/dist/ai-provider/index.d.ts +79 -163
  7. package/dist/ai-provider/index.js +752 -671
  8. package/dist/auth/index.d.ts +27 -27
  9. package/dist/auth/index.js +41 -33
  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 -133
  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 +105 -84
  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 -509
  37. package/dist/dev/index.js +2740 -2873
  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 -125
  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-DIAS8Rsl.d.ts → errors-CRCcErNC.d.ts} +55 -53
  48. package/dist/feedback/index.d.ts +2 -132
  49. package/dist/feedback/index.js +3 -5
  50. package/dist/files/index.d.ts +14 -14
  51. package/dist/files/index.js +41 -24
  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 -221
  56. package/dist/index.js +119 -70
  57. package/dist/logout/index.d.ts +109 -0
  58. package/dist/logout/index.js +264 -0
  59. package/dist/plans/index.d.ts +2 -236
  60. package/dist/plans/index.js +3 -5
  61. package/dist/push/index.d.ts +2 -79
  62. package/dist/push/index.js +3 -5
  63. package/dist/query-BvbCiGWb.js +35 -0
  64. package/dist/react/hooks.d.ts +97 -95
  65. package/dist/react/hooks.js +742 -356
  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 -5
  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 -47
  76. package/dist/webhooks/index.js +150 -127
  77. package/docs/api-reference.md +179 -2
  78. package/docs/dev-server.md +19 -18
  79. package/docs/errors.md +72 -15
  80. package/docs/logout.md +166 -0
  81. package/package.json +10 -5
  82. package/dist/chunk-2Q654O63.js +0 -350
  83. package/dist/chunk-F7BXBTZI.js +0 -54
  84. package/dist/chunk-IJOXTBIE.js +0 -599
  85. package/dist/chunk-JWXUVQRC.js +0 -157
  86. package/dist/chunk-L4DHB36G.js +0 -75
  87. package/dist/chunk-MRQY45U5.js +0 -465
  88. package/dist/chunk-N5JVE4WX.js +0 -449
  89. package/dist/chunk-O3PUWIDJ.js +0 -105
  90. package/dist/chunk-POLKEOYH.js +0 -63
  91. package/dist/chunk-R5CCGDUH.js +0 -49
  92. package/dist/chunk-RBHP7IZF.js +0 -96
  93. package/dist/chunk-REIKXSMY.js +0 -7
  94. package/dist/chunk-T7YTITRJ.js +0 -112
  95. package/dist/chunk-V73GORO3.js +0 -81
  96. package/dist/chunk-VRNBYSWU.js +0 -32
  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
@@ -0,0 +1,83 @@
1
+ import { t as BaseHttpClient } from "./http-client-QKUvvirs.js";
2
+
3
+ //#region 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(config, `/api/v1/brandapp/${config.brandappId}/terms`);
26
+ }
27
+ /**
28
+ * List active terms for this Brandapp with their currently-published
29
+ * version. Works with either Basic Auth (default) or Bearer Auth — when
30
+ * called from a server handler that has the user's access token, pass
31
+ * `accessToken` to avoid sending app credentials.
32
+ *
33
+ * Accepts either an `accessToken` string (legacy) or an options object
34
+ * (`country`/`locale`/`jurisdiction`/`accessToken`) for jurisdiction-aware
35
+ * matching. When `country` / `locale` are omitted, the server falls back to
36
+ * request headers (`x-vercel-ip-country`, `Accept-Language`).
37
+ *
38
+ * Returns the matched terms array. For matching metadata
39
+ * (jurisdiction, locale, source) use {@link listWithMeta}.
40
+ */
41
+ async list(optionsOrToken) {
42
+ return (await this.listWithMeta(optionsOrToken)).terms;
43
+ }
44
+ /**
45
+ * Same as {@link list} but returns the full {@link TermsListResponse} including
46
+ * matched jurisdiction, country and locale — useful for displaying "약관이
47
+ * 어떤 국가 기준으로 적용됐는지" hint in the signup UX.
48
+ */
49
+ async listWithMeta(optionsOrToken) {
50
+ const options = isListOptions(optionsOrToken) ? optionsOrToken : optionsOrToken ? { accessToken: optionsOrToken } : {};
51
+ const path = buildListQuery(options) || "";
52
+ return unwrap(await this.http.fetch("GET", path, void 0, options.accessToken ? { bearerToken: options.accessToken } : void 0));
53
+ }
54
+ /**
55
+ * Fetch the consent history (granted / withdrawn / pendingReConsent) for
56
+ * the OAuth user represented by `accessToken`.
57
+ */
58
+ async listMyConsents(accessToken) {
59
+ return unwrap(await this.http.fetch("GET", "/me/consents", void 0, { bearerToken: accessToken }));
60
+ }
61
+ /**
62
+ * Record consent for one or more terms versions. The server rejects the
63
+ * call with `REQUIRED_NOT_CONSENTED` (422) if any required term is missing
64
+ * or marked as `consented: false`.
65
+ */
66
+ async consent(input, accessToken) {
67
+ return unwrap(await this.http.fetch("POST", "/me/consents", input, { bearerToken: accessToken }));
68
+ }
69
+ /**
70
+ * Withdraw a previously-granted consent. The server returns 409 for
71
+ * required terms or already-withdrawn records.
72
+ */
73
+ async withdraw(consentId, accessToken) {
74
+ return unwrap(await this.http.fetch("DELETE", `/me/consents/${encodeURIComponent(consentId)}`, void 0, { bearerToken: accessToken }));
75
+ }
76
+ };
77
+ function createReoptTermsClient(config) {
78
+ return new ReoptTermsClient(config);
79
+ }
80
+
81
+ //#endregion
82
+ export { createReoptTermsClient as n, ReoptTermsClient as t };
83
+ //# sourceMappingURL=client-B1q5P8rv.js.map
@@ -0,0 +1,77 @@
1
+ import { t as BaseHttpClient } from "./http-client-QKUvvirs.js";
2
+
3
+ //#region 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(config, `/api/v1/brandapp/${config.brandappId}/plans`);
15
+ }
16
+ /**
17
+ * List active plans for this Brandapp (the customer-facing catalog). Works
18
+ * with either Basic Auth (default) or Bearer Auth — pass `accessToken` when
19
+ * calling from a handler that already has the customer's OAuth token to avoid
20
+ * sending app credentials.
21
+ */
22
+ async list(accessToken) {
23
+ return unwrap(await this.http.fetch("GET", "", void 0, accessToken ? { bearerToken: accessToken } : void 0));
24
+ }
25
+ /**
26
+ * Fetch the current plan / entitlement for the OAuth customer represented by
27
+ * `accessToken`. Returns `null` when the customer has no active plan.
28
+ */
29
+ async getMyPlan(accessToken) {
30
+ return unwrap(await this.http.fetch("GET", "/me/plan", void 0, { bearerToken: accessToken }));
31
+ }
32
+ /**
33
+ * Start a hosted checkout to subscribe the current customer (identified by
34
+ * `accessToken`) to `input.planId`, then redirect the browser to the returned
35
+ * `checkoutUrl`. In sandbox mode that URL is a virtual-payment page on
36
+ * id.reopt.ai which activates the subscription and returns to your
37
+ * `successUrl` / `cancelUrl`.
38
+ *
39
+ * @throws {RequiredTermsError} when the plan has required terms the customer
40
+ * has not consented to. Read `missingTermsIds`, collect consent via
41
+ * `sdk.terms`, then call again.
42
+ * @throws {ReoptSDKError} `LIVE_MODE_UNSUPPORTED` (409) when the Brandapp is
43
+ * configured for live **Toss** payments and the plan is priced (use the
44
+ * brandfront checkout). Live Paddle is supported since 3.4.
45
+ */
46
+ async createCheckout(input, accessToken) {
47
+ return unwrap(await this.http.fetch("POST", "/me/checkout", input, { bearerToken: accessToken }));
48
+ }
49
+ /**
50
+ * Poll a checkout session by id (e.g. on your return page) to read its
51
+ * `status` — `completed` means the subscription is active. `checkoutUrl` is
52
+ * `null` here; use the URL from {@link createCheckout} to re-redirect.
53
+ */
54
+ async getCheckout(checkoutId, accessToken) {
55
+ return unwrap(await this.http.fetch("GET", `/me/checkout/${encodeURIComponent(checkoutId)}`, void 0, { bearerToken: accessToken }));
56
+ }
57
+ /**
58
+ * Cancel the current customer's active subscription — sandbox and live
59
+ * (Paddle/Toss/IAP) alike since 3.4. Access is kept until the paid period
60
+ * ends (the billing state becomes `canceled`, `accessUntil` says until when).
61
+ *
62
+ * The local subscription is settled first, so the next recurring charge is
63
+ * always stopped; the provider-side cancellation is best-effort and reported
64
+ * through `providerCanceled`. Apple/Google subscriptions are canceled in the
65
+ * store, so no remote call is made for those.
66
+ */
67
+ async cancel(accessToken) {
68
+ return unwrap(await this.http.fetch("POST", "/me/subscription/cancel", {}, { bearerToken: accessToken }));
69
+ }
70
+ };
71
+ function createReoptPlansClient(config) {
72
+ return new ReoptPlansClient(config);
73
+ }
74
+
75
+ //#endregion
76
+ export { createReoptPlansClient as n, ReoptPlansClient as t };
77
+ //# sourceMappingURL=client-B9QHVhdM.js.map
@@ -0,0 +1,103 @@
1
+ import { A as UpdateEntityInput, C as EavEntity, D as ListRecordsQuery, M as UpsertRecordInput, N as UpsertRecordResult, O as PaginatedResponse, _ as CreateEntityInput, b as EavAttribute, c as InferValues, f as BackfillOptions, g as CreateAttributeInput, h as CountRecordsQuery, j as UpdateRecordInput, k as UpdateAttributeInput, l as SchemaDef, m as BulkUpdateItem, n as ReoptSDKConfig, p as BackfillResult, s as EntityDef, u as AttributeFilter, v as CreateRecordInput, w as EavRecord, y as DeleteWhereInput } from "./config-CRytOPPl.js";
2
+ //#region src/eav/typed-client.d.ts
3
+ /** EavRecord with typed values instead of Record<string, unknown> */
4
+ type TypedEavRecord<V> = Omit<EavRecord, "values"> & {
5
+ values: V;
6
+ };
7
+ /** Entity-scoped client with typed records API */
8
+ type EntityClient<E extends EntityDef> = {
9
+ readonly entityName: string;
10
+ records: {
11
+ list(query?: ListRecordsQuery): Promise<PaginatedResponse<TypedEavRecord<InferValues<E>>>>;
12
+ findOne(query?: Omit<ListRecordsQuery, "page">): Promise<TypedEavRecord<InferValues<E>> | null>;
13
+ create(input: {
14
+ authUserId?: string;
15
+ values: InferValues<E>;
16
+ }): Promise<TypedEavRecord<InferValues<E>>>;
17
+ upsert(input: {
18
+ authUserId?: string;
19
+ filters: AttributeFilter[];
20
+ values: InferValues<E>;
21
+ }): Promise<UpsertRecordResult<TypedEavRecord<InferValues<E>>>>;
22
+ get(recordId: string): Promise<TypedEavRecord<InferValues<E>>>;
23
+ update(recordId: string, input: {
24
+ values: Partial<InferValues<E>>;
25
+ }): Promise<TypedEavRecord<InferValues<E>>>;
26
+ delete(recordId: string): Promise<void>;
27
+ count(query?: CountRecordsQuery): Promise<number>;
28
+ bulkCreate(records: Array<{
29
+ authUserId?: string;
30
+ values: InferValues<E>;
31
+ }>): Promise<TypedEavRecord<InferValues<E>>[]>;
32
+ bulkDelete(ids: string[]): Promise<number>;
33
+ bulkUpdate(updates: BulkUpdateItem[]): Promise<TypedEavRecord<InferValues<E>>[]>;
34
+ deleteWhere(input: DeleteWhereInput): Promise<number>;
35
+ listAll(query?: Omit<ListRecordsQuery, "page">): AsyncGenerator<TypedEavRecord<InferValues<E>>>;
36
+ backfill(opts: BackfillOptions): Promise<BackfillResult>;
37
+ };
38
+ };
39
+ //#endregion
40
+ //#region src/eav/client.d.ts
41
+ /**
42
+ * Reopt EAV Client
43
+ *
44
+ * @example
45
+ * ```ts
46
+ * import { createReoptEavClient } from "@reopt-ai/brandapp-sdk/eav";
47
+ *
48
+ * const eav = createReoptEavClient({
49
+ * clientId: process.env.BRANDAPP_CLIENT_ID!,
50
+ * clientSecret: process.env.BRANDAPP_CLIENT_SECRET!,
51
+ * brandappId: process.env.BRANDAPP_ID!,
52
+ * });
53
+ *
54
+ * const entity = await eav.entities.create({ name: "agent_configs" });
55
+ * ```
56
+ */
57
+ type ReoptEavClient<S extends SchemaDef = SchemaDef> = {
58
+ entities: {
59
+ list(): Promise<EavEntity[]>;
60
+ create(input: CreateEntityInput): Promise<EavEntity>;
61
+ get(entityId: string): Promise<EavEntity & {
62
+ attributes: EavAttribute[];
63
+ }>;
64
+ update(entityId: string, input: UpdateEntityInput): Promise<EavEntity>;
65
+ delete(entityId: string): Promise<void>;
66
+ };
67
+ attributes: {
68
+ create(entityId: string, input: CreateAttributeInput): Promise<EavAttribute>;
69
+ update(entityId: string, attributeId: string, input: UpdateAttributeInput): Promise<EavAttribute>;
70
+ delete(entityId: string, attributeId: string): Promise<void>;
71
+ };
72
+ records: {
73
+ list(entityId: string, query?: ListRecordsQuery): Promise<PaginatedResponse<EavRecord>>;
74
+ create(entityId: string, input: CreateRecordInput): Promise<EavRecord>;
75
+ get(entityId: string, recordId: string): Promise<EavRecord>;
76
+ update(entityId: string, recordId: string, input: UpdateRecordInput): Promise<EavRecord>;
77
+ delete(entityId: string, recordId: string): Promise<void>;
78
+ count(entityId: string, query?: CountRecordsQuery): Promise<number>;
79
+ bulkDelete(entityId: string, ids: string[]): Promise<number>;
80
+ bulkUpdate(entityId: string, updates: BulkUpdateItem[]): Promise<EavRecord[]>;
81
+ findOne(entityId: string, query?: Omit<ListRecordsQuery, "page">): Promise<EavRecord | null>;
82
+ upsert(entityId: string, input: UpsertRecordInput): Promise<UpsertRecordResult<EavRecord>>;
83
+ bulkCreate(entityId: string, records: CreateRecordInput[]): Promise<EavRecord[]>;
84
+ deleteWhere(entityId: string, input: DeleteWhereInput): Promise<number>;
85
+ listAll(entityId: string, query?: Omit<ListRecordsQuery, "page">): AsyncGenerator<EavRecord>;
86
+ backfill(entityId: string, opts: BackfillOptions): Promise<BackfillResult>;
87
+ };
88
+ users: {
89
+ getRecords(authUserId: string, query?: Omit<ListRecordsQuery, "authUserId">): Promise<PaginatedResponse<EavRecord>>;
90
+ };
91
+ schemaHash(): Promise<{
92
+ hash: string;
93
+ schemaCount: number;
94
+ fieldCount: number;
95
+ generatedAt: string;
96
+ }>;
97
+ entity<K extends string & keyof S["entities"]>(name: K): EntityClient<S["entities"][K] extends EntityDef ? S["entities"][K] : EntityDef>;
98
+ invalidateCache(): void;
99
+ };
100
+ declare function createReoptEavClient<S extends SchemaDef = SchemaDef>(config: ReoptSDKConfig<S>): ReoptEavClient<S>;
101
+ //#endregion
102
+ export { TypedEavRecord as i, createReoptEavClient as n, EntityClient as r, ReoptEavClient as t };
103
+ //# sourceMappingURL=client-BGGd_cpV.d.ts.map
@@ -0,0 +1,140 @@
1
+ import { A as mapHttpStatusToError, n as SDK_VERSION, o as validateConfig, x as ReoptSDKError } from "./config-Cw0a3-C8.js";
2
+ import { t as createManagedAbort } from "./abort--nOBFN4M.js";
3
+ import { n as parseFieldErrors, t as BaseHttpClient } from "./http-client-QKUvvirs.js";
4
+
5
+ //#region 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
+ return (await this.http.fetch("GET", `/${encodeURIComponent(fileId)}`)).data;
52
+ }
53
+ /**
54
+ * 파일 삭제
55
+ *
56
+ * @example
57
+ * ```ts
58
+ * await sdk.files.delete("file-uuid");
59
+ * ```
60
+ */
61
+ async delete(fileId) {
62
+ await this.http.fetch("DELETE", `/${encodeURIComponent(fileId)}`);
63
+ }
64
+ /**
65
+ * 파일 업로드
66
+ *
67
+ * FormData(multipart)로 파일을 전송합니다.
68
+ * BaseHttpClient는 JSON 전용이므로 globalThis.fetch를 직접 사용합니다.
69
+ *
70
+ * @example
71
+ * ```ts
72
+ * // Blob 업로드
73
+ * const blob = new Blob(["hello"], { type: "text/plain" });
74
+ * const file = await sdk.files.upload(blob, { name: "hello.txt" });
75
+ *
76
+ * // File 업로드 (브라우저)
77
+ * const file = await sdk.files.upload(inputEl.files[0]);
78
+ *
79
+ * // Buffer 업로드 (Node.js)
80
+ * const buf = fs.readFileSync("image.png");
81
+ * const file = await sdk.files.upload(buf, {
82
+ * name: "image.png",
83
+ * contentType: "image/png",
84
+ * });
85
+ * ```
86
+ */
87
+ async upload(file, options) {
88
+ const formData = new FormData();
89
+ if (file instanceof Blob) {
90
+ const fileName = options?.name ?? ("name" in file ? file.name : "upload");
91
+ formData.append("file", file, fileName);
92
+ } else {
93
+ const arrayBuffer = file.buffer.slice(file.byteOffset, file.byteOffset + file.byteLength);
94
+ const blob = new Blob([arrayBuffer], { type: options?.contentType ?? "application/octet-stream" });
95
+ formData.append("file", blob, options?.name ?? "upload");
96
+ }
97
+ if (options?.name) formData.append("name", options.name);
98
+ if (options?.contentType) formData.append("contentType", options.contentType);
99
+ const url = `${this.http.requestBaseUrl}/upload`;
100
+ const managed = createManagedAbort({
101
+ timeoutMs: options?.timeout ?? this.timeout,
102
+ external: options?.signal
103
+ });
104
+ try {
105
+ const response = await globalThis.fetch(url, {
106
+ method: "POST",
107
+ headers: {
108
+ Authorization: this.http.authorizationHeader,
109
+ "X-SDK-Version": `brandapp-sdk/${SDK_VERSION}`
110
+ },
111
+ body: formData,
112
+ signal: managed.signal
113
+ });
114
+ if (!response.ok) {
115
+ const body = await response.json().catch(() => ({}));
116
+ const errObj = typeof body.error === "object" ? body.error : void 0;
117
+ const msg = errObj?.message ?? (typeof body.error === "string" ? body.error : void 0) ?? `Upload failed with status ${response.status}`;
118
+ const fieldErrors = response.status === 422 ? parseFieldErrors(body) : [];
119
+ throw mapHttpStatusToError(response.status, errObj?.code, msg, {
120
+ method: "POST",
121
+ url
122
+ }, fieldErrors);
123
+ }
124
+ return (await response.json()).data;
125
+ } catch (e) {
126
+ if (e instanceof ReoptSDKError) throw e;
127
+ if (e instanceof Error && e.name === "AbortError") throw new ReoptSDKError("Upload request timed out", 408, "TIMEOUT");
128
+ throw e;
129
+ } finally {
130
+ managed.cleanup();
131
+ }
132
+ }
133
+ };
134
+ function createReoptFileClient(config) {
135
+ return new ReoptFileClient(config);
136
+ }
137
+
138
+ //#endregion
139
+ export { createReoptFileClient as n, ReoptFileClient as t };
140
+ //# sourceMappingURL=client-BJcy1V1a.js.map
@@ -0,0 +1,55 @@
1
+ import { t as BaseHttpClient } from "./http-client-QKUvvirs.js";
2
+ import { t as buildQuery } from "./query-BvbCiGWb.js";
3
+
4
+ //#region src/cms/client.ts
5
+ function createReoptCmsClient(config) {
6
+ const http = new BaseHttpClient(config, `/api/v1/brandapp/${config.brandappId}/cms`);
7
+ return {
8
+ posts: {
9
+ async list(query) {
10
+ const qs = buildQuery(query ?? {});
11
+ return (await http.fetch("GET", `/posts${qs}`)).data;
12
+ },
13
+ async get(postId) {
14
+ return (await http.fetch("GET", `/posts/${encodeURIComponent(postId)}`)).data;
15
+ },
16
+ /**
17
+ * Slug 기반 단건 조회. URL 라우트(`/blog/[slug]`)에서 id 매핑 없이 사용.
18
+ * 같은 slug가 여러 그룹에 있을 수 있는 경우 `groupId` 또는 `groupSlug`로 좁힐 수 있다.
19
+ */
20
+ async getBySlug(slug, opts) {
21
+ const qs = buildQuery({
22
+ groupId: opts?.groupId,
23
+ groupSlug: opts?.groupSlug
24
+ });
25
+ return (await http.fetch("GET", `/posts/by-slug/${encodeURIComponent(slug)}${qs}`)).data;
26
+ }
27
+ },
28
+ postGroups: {
29
+ async list(query) {
30
+ const qs = buildQuery(query ?? {});
31
+ return (await http.fetch("GET", `/post-groups${qs}`)).data;
32
+ },
33
+ async get(groupId) {
34
+ return (await http.fetch("GET", `/post-groups/${encodeURIComponent(groupId)}`)).data;
35
+ },
36
+ /**
37
+ * Slug 기반 그룹 단건 조회. env var(`REOPT_*_GROUP_ID`) 대신 slug 하드코딩
38
+ * 패턴(`CONTENT_GROUPS.blog.slug`)을 권장.
39
+ */
40
+ async getBySlug(slug) {
41
+ return (await http.fetch("GET", `/post-groups/by-slug/${encodeURIComponent(slug)}`)).data;
42
+ }
43
+ },
44
+ tags: {
45
+ /** Brand 범위 안에서 사용된 포스트 태그 목록을 반환. */
46
+ async list(query) {
47
+ const qs = buildQuery(query ?? {});
48
+ return (await http.fetch("GET", `/tags${qs}`)).data;
49
+ } }
50
+ };
51
+ }
52
+
53
+ //#endregion
54
+ export { createReoptCmsClient as t };
55
+ //# sourceMappingURL=client-Beivhucf.js.map
@@ -0,0 +1,147 @@
1
+ import { n as ReoptSDKConfig } from "./config-CRytOPPl.js";
2
+ //#region src/feedback/types.d.ts
3
+ /**
4
+ * Feedback processing status. `reopened` means the customer replied after the
5
+ * staff had answered — the thread is waiting on the workspace again.
6
+ */
7
+ type FeedbackStatus = "new" | "in_progress" | "responded" | "reopened" | "archived";
8
+ /** Who wrote a message in the feedback thread. */
9
+ type FeedbackReplyAuthor = "staff" | "customer";
10
+ /**
11
+ * A message in the feedback thread — either a workspace staff reply or the
12
+ * customer's own follow-up. Only public fields are exposed — the responding
13
+ * staff identity is never included.
14
+ */
15
+ type FeedbackReply = {
16
+ id: string;
17
+ content: string;
18
+ author: FeedbackReplyAuthor;
19
+ /**
20
+ * The customer's usefulness rating of a staff reply
21
+ * (true = helpful, false = not helpful, null = not rated / customer message).
22
+ */
23
+ helpful: boolean | null;
24
+ /** ISO datetime */
25
+ createdAt: string;
26
+ };
27
+ /** A customer feedback item as returned by the Brandapp Feedback API. */
28
+ type Feedback = {
29
+ id: string;
30
+ title: string | null;
31
+ content: string;
32
+ category: string | null;
33
+ /** 1–5, when the feedback carried a rating */
34
+ rating: number | null;
35
+ status: FeedbackStatus;
36
+ /** Linked reopt Customer id (null = anonymous) */
37
+ customerId: string | null;
38
+ /**
39
+ * Number of **staff** replies — the customer's own follow-ups are not counted,
40
+ * so `replyCount > 0` still means "the workspace has answered".
41
+ */
42
+ replyCount: number;
43
+ /** ISO datetime */
44
+ createdAt: string;
45
+ };
46
+ /** Feedback detail including the reply thread. */
47
+ type FeedbackDetail = Feedback & {
48
+ replies: FeedbackReply[];
49
+ };
50
+ type CreateFeedbackInput = {
51
+ /** Feedback body (1–8000 chars). */
52
+ content: string;
53
+ title?: string;
54
+ category?: string;
55
+ /** 1–5 */
56
+ rating?: number;
57
+ /**
58
+ * Customer id to attribute the feedback to (app-credential path only —
59
+ * the server verifies the customer is linked to this brandapp). Ignored
60
+ * on the `me.*` path where the token's customer is used.
61
+ */
62
+ customerId?: string;
63
+ /** Free-form metadata (max 4000 chars serialized). */
64
+ metadata?: Record<string, unknown>;
65
+ };
66
+ type ListFeedbackQuery = {
67
+ status?: FeedbackStatus;
68
+ /** Filter by linked Customer id (app-credential path only). */
69
+ customerId?: string;
70
+ /** 1-based page (default 1). */
71
+ page?: number;
72
+ /** Page size 1–100 (default 20). */
73
+ limit?: number;
74
+ };
75
+ type FeedbackListMeta = {
76
+ page: number;
77
+ limit: number;
78
+ total: number;
79
+ };
80
+ type FeedbackListResult = {
81
+ feedbacks: Feedback[];
82
+ meta: FeedbackListMeta;
83
+ };
84
+ type CreateFeedbackResult = {
85
+ id: string;
86
+ };
87
+ type CreateFeedbackReplyResult = {
88
+ id: string;
89
+ /**
90
+ * Feedback status after the reply. Answered threads flip to `reopened`
91
+ * so the workspace sees the customer is still waiting.
92
+ */
93
+ feedbackStatus: FeedbackStatus;
94
+ /** ISO datetime */
95
+ createdAt: string;
96
+ };
97
+ type RateFeedbackReplyResult = {
98
+ id: string;
99
+ helpful: boolean | null;
100
+ };
101
+ //#endregion
102
+ //#region src/feedback/client.d.ts
103
+ declare class ReoptFeedbackClient {
104
+ private readonly http;
105
+ constructor(config: ReoptSDKConfig);
106
+ /**
107
+ * Create a feedback with app credentials (server-to-server collection).
108
+ * Pass `customerId` to attribute it to a customer linked to this brandapp.
109
+ */
110
+ create(input: CreateFeedbackInput): Promise<CreateFeedbackResult>;
111
+ /** List feedback this brandapp collected (app credentials). */
112
+ list(query?: ListFeedbackQuery): Promise<FeedbackListResult>;
113
+ /** Fetch one feedback with its reply thread (app credentials). */
114
+ get(feedbackId: string): Promise<FeedbackDetail>;
115
+ /** End-user surface — requires the signed-in user's OAuth access token. */
116
+ readonly me: {
117
+ /**
118
+ * Create a feedback as the signed-in user. The server resolves the
119
+ * token's linked customer; unlinked users get 403 `LINK_REQUIRED`
120
+ * (call `sdk.auth.linkCurrentUser` first).
121
+ */
122
+ create: (input: Omit<CreateFeedbackInput, "customerId">, accessToken: string) => Promise<CreateFeedbackResult>;
123
+ /**
124
+ * List the signed-in user's own feedback (all collection sources —
125
+ * brand form submissions included).
126
+ */
127
+ list: (accessToken: string, query?: Omit<ListFeedbackQuery, "customerId">) => Promise<FeedbackListResult>;
128
+ /** Fetch one of the signed-in user's feedback with its thread. */
129
+ get: (feedbackId: string, accessToken: string) => Promise<FeedbackDetail>;
130
+ /**
131
+ * Reply to a staff answer on the signed-in user's own feedback, continuing
132
+ * the thread instead of filing a new feedback. An already-answered feedback
133
+ * flips back to `reopened` and the workspace is notified.
134
+ */
135
+ reply: (feedbackId: string, content: string, accessToken: string) => Promise<CreateFeedbackReplyResult>;
136
+ /**
137
+ * Rate a staff reply's usefulness (`true` helpful / `false` not helpful /
138
+ * `null` to clear). Rating alone does not reopen the feedback — send a
139
+ * `reply` when the customer still needs something.
140
+ */
141
+ rateReply: (feedbackId: string, replyId: string, helpful: boolean | null, accessToken: string) => Promise<RateFeedbackReplyResult>;
142
+ };
143
+ }
144
+ declare function createReoptFeedbackClient(config: ReoptSDKConfig): ReoptFeedbackClient;
145
+ //#endregion
146
+ export { CreateFeedbackResult as a, FeedbackListMeta as c, FeedbackReplyAuthor as d, FeedbackStatus as f, CreateFeedbackReplyResult as i, FeedbackListResult as l, RateFeedbackReplyResult as m, createReoptFeedbackClient as n, Feedback as o, ListFeedbackQuery as p, CreateFeedbackInput as r, FeedbackDetail as s, ReoptFeedbackClient as t, FeedbackReply as u };
147
+ //# sourceMappingURL=client-BruP5_nU.d.ts.map
@@ -0,0 +1,28 @@
1
+ import { t as BaseHttpClient } from "./http-client-QKUvvirs.js";
2
+
3
+ //#region src/push/client.ts
4
+ var ReoptPushClient = class {
5
+ http;
6
+ constructor(config) {
7
+ this.http = new BaseHttpClient(config, `/api/v1/brandapp/${config.brandappId}/push`);
8
+ }
9
+ /** Register (or refresh) the signed-in customer's device push token. */
10
+ async registerDeviceToken(input, accessToken) {
11
+ return (await this.http.fetch("POST", "/me/tokens", input, { bearerToken: accessToken })).data;
12
+ }
13
+ /** Unregister a device token by `token` or `deviceId` (own tokens only). */
14
+ async unregisterDeviceToken(input, accessToken) {
15
+ return (await this.http.fetch("DELETE", "/me/tokens", input, { bearerToken: accessToken })).data;
16
+ }
17
+ /** List the signed-in customer's registered devices (no raw tokens). */
18
+ async listDevices(accessToken) {
19
+ return (await this.http.fetch("GET", "/me/tokens", void 0, { bearerToken: accessToken })).data;
20
+ }
21
+ };
22
+ function createReoptPushClient(config) {
23
+ return new ReoptPushClient(config);
24
+ }
25
+
26
+ //#endregion
27
+ export { createReoptPushClient as n, ReoptPushClient as t };
28
+ //# sourceMappingURL=client-D-yNxNfk.js.map