@reopt-ai/brandapp-sdk 3.4.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.
- package/CHANGELOG.md +48 -0
- package/dist/ai/index.js +1 -1
- package/dist/ai-provider/index.js +1 -1
- package/dist/auth/index.js +1 -1
- package/dist/better-auth/index.js +2 -2
- package/dist/{client-DsdakibF.js → client-61ldOHMz.js} +3 -3
- package/dist/{client-D-yNxNfk.js → client-7PCoxVhZ.js} +2 -2
- package/dist/client-B7rZQ8Zi.d.ts +272 -0
- package/dist/client-BoIuyx4S.js +273 -0
- package/dist/{client-DPmoKuR9.js → client-BxtZt405.js} +4 -4
- package/dist/{client-B1q5P8rv.js → client-ByN3EQdk.js} +2 -2
- package/dist/{client-EbhUIhHq.js → client-CAghoGD_.js} +2 -2
- package/dist/{client-B9QHVhdM.js → client-C_pHsPlj.js} +11 -7
- package/dist/{client-D3RHHUUW.d.ts → client-aMR4CRB8.d.ts} +10 -6
- package/dist/{client-Beivhucf.js → client-wEVKLdly.js} +3 -3
- package/dist/{client-DBnK7ooQ.js → client-zF1RG2uA.js} +2 -2
- package/dist/cms/index.js +1 -1
- package/dist/{config-Cw0a3-C8.js → config-aml9oQpX.js} +2 -2
- package/dist/dev/index.d.ts +1 -1
- package/dist/dev/index.js +318 -2
- package/dist/eav/index.js +2 -2
- package/dist/feedback/index.js +1 -1
- package/dist/files/index.d.ts +2 -2
- package/dist/files/index.js +1 -1
- package/dist/{http-client-QKUvvirs.js → http-client-BZc2mngq.js} +2 -2
- package/dist/{index-DrVaKfhs.d.ts → index-1j_738qk.d.ts} +15 -1
- package/dist/{index-Z6OGcurJ.d.ts → index-CeOLGdyL.d.ts} +3 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.js +11 -11
- package/dist/logout/index.js +1 -1
- package/dist/plans/index.d.ts +1 -1
- package/dist/plans/index.js +1 -1
- package/dist/push/index.js +1 -1
- package/dist/{query-BvbCiGWb.js → query-xWqtfkvR.js} +2 -2
- package/dist/react/hooks.d.ts +62 -3
- package/dist/react/hooks.js +121 -3
- package/dist/terms/index.js +1 -1
- package/dist/testing/index.d.ts +2 -2
- package/docs/api-reference.md +34 -2
- package/docs/errors.md +19 -0
- package/docs/files.md +165 -7
- package/package.json +2 -2
- package/dist/client-BJcy1V1a.js +0 -140
- package/dist/client-p49ol9pg.d.ts +0 -124
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as BaseHttpClient } from "./http-client-
|
|
1
|
+
import { t as BaseHttpClient } from "./http-client-BZc2mngq.js";
|
|
2
2
|
|
|
3
3
|
//#region src/terms/client.ts
|
|
4
4
|
function unwrap(body) {
|
|
@@ -80,4 +80,4 @@ function createReoptTermsClient(config) {
|
|
|
80
80
|
|
|
81
81
|
//#endregion
|
|
82
82
|
export { createReoptTermsClient as n, ReoptTermsClient as t };
|
|
83
|
-
//# sourceMappingURL=client-
|
|
83
|
+
//# sourceMappingURL=client-ByN3EQdk.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as BaseHttpClient } from "./http-client-
|
|
1
|
+
import { t as BaseHttpClient } from "./http-client-BZc2mngq.js";
|
|
2
2
|
|
|
3
3
|
//#region src/auth/client.ts
|
|
4
4
|
function unwrap(body) {
|
|
@@ -50,4 +50,4 @@ function createReoptAuthClient(config) {
|
|
|
50
50
|
|
|
51
51
|
//#endregion
|
|
52
52
|
export { createReoptAuthClient as n, ReoptAuthClient as t };
|
|
53
|
-
//# sourceMappingURL=client-
|
|
53
|
+
//# sourceMappingURL=client-CAghoGD_.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as BaseHttpClient } from "./http-client-
|
|
1
|
+
import { t as BaseHttpClient } from "./http-client-BZc2mngq.js";
|
|
2
2
|
|
|
3
3
|
//#region src/plans/client.ts
|
|
4
4
|
function unwrap(body) {
|
|
@@ -32,13 +32,17 @@ var ReoptPlansClient = class {
|
|
|
32
32
|
/**
|
|
33
33
|
* Start a hosted checkout to subscribe the current customer (identified by
|
|
34
34
|
* `accessToken`) to `input.planId`, then redirect the browser to the returned
|
|
35
|
-
* `checkoutUrl`.
|
|
36
|
-
*
|
|
35
|
+
* `checkoutUrl`. That URL is an order-review page on id.reopt.ai showing the
|
|
36
|
+
* server-truth plan details (price, features, renewal terms) and collecting
|
|
37
|
+
* any required-terms consent **before** payment, then returning to your
|
|
37
38
|
* `successUrl` / `cancelUrl`.
|
|
38
39
|
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
40
|
+
* Missing required-terms consent no longer fails this call — consent is
|
|
41
|
+
* collected on the hosted order-review page. Pre-collecting via `sdk.terms`
|
|
42
|
+
* still works (the page skips already-consented terms), and
|
|
43
|
+
* `RequiredTermsError` remains for backward compatibility with older
|
|
44
|
+
* servers.
|
|
45
|
+
*
|
|
42
46
|
* @throws {ReoptSDKError} `LIVE_MODE_UNSUPPORTED` (409) when the Brandapp is
|
|
43
47
|
* configured for live **Toss** payments and the plan is priced (use the
|
|
44
48
|
* brandfront checkout). Live Paddle is supported since 3.4.
|
|
@@ -74,4 +78,4 @@ function createReoptPlansClient(config) {
|
|
|
74
78
|
|
|
75
79
|
//#endregion
|
|
76
80
|
export { createReoptPlansClient as n, ReoptPlansClient as t };
|
|
77
|
-
//# sourceMappingURL=client-
|
|
81
|
+
//# sourceMappingURL=client-C_pHsPlj.js.map
|
|
@@ -171,13 +171,17 @@ declare class ReoptPlansClient {
|
|
|
171
171
|
/**
|
|
172
172
|
* Start a hosted checkout to subscribe the current customer (identified by
|
|
173
173
|
* `accessToken`) to `input.planId`, then redirect the browser to the returned
|
|
174
|
-
* `checkoutUrl`.
|
|
175
|
-
*
|
|
174
|
+
* `checkoutUrl`. That URL is an order-review page on id.reopt.ai showing the
|
|
175
|
+
* server-truth plan details (price, features, renewal terms) and collecting
|
|
176
|
+
* any required-terms consent **before** payment, then returning to your
|
|
176
177
|
* `successUrl` / `cancelUrl`.
|
|
177
178
|
*
|
|
178
|
-
*
|
|
179
|
-
*
|
|
180
|
-
*
|
|
179
|
+
* Missing required-terms consent no longer fails this call — consent is
|
|
180
|
+
* collected on the hosted order-review page. Pre-collecting via `sdk.terms`
|
|
181
|
+
* still works (the page skips already-consented terms), and
|
|
182
|
+
* `RequiredTermsError` remains for backward compatibility with older
|
|
183
|
+
* servers.
|
|
184
|
+
*
|
|
181
185
|
* @throws {ReoptSDKError} `LIVE_MODE_UNSUPPORTED` (409) when the Brandapp is
|
|
182
186
|
* configured for live **Toss** payments and the plan is priced (use the
|
|
183
187
|
* brandfront checkout). Live Paddle is supported since 3.4.
|
|
@@ -204,4 +208,4 @@ declare class ReoptPlansClient {
|
|
|
204
208
|
declare function createReoptPlansClient(config: ReoptSDKConfig): ReoptPlansClient;
|
|
205
209
|
//#endregion
|
|
206
210
|
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-
|
|
211
|
+
//# sourceMappingURL=client-aMR4CRB8.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as BaseHttpClient } from "./http-client-
|
|
2
|
-
import { t as buildQuery } from "./query-
|
|
1
|
+
import { t as BaseHttpClient } from "./http-client-BZc2mngq.js";
|
|
2
|
+
import { t as buildQuery } from "./query-xWqtfkvR.js";
|
|
3
3
|
|
|
4
4
|
//#region src/cms/client.ts
|
|
5
5
|
function createReoptCmsClient(config) {
|
|
@@ -52,4 +52,4 @@ async list(query) {
|
|
|
52
52
|
|
|
53
53
|
//#endregion
|
|
54
54
|
export { createReoptCmsClient as t };
|
|
55
|
-
//# sourceMappingURL=client-
|
|
55
|
+
//# sourceMappingURL=client-wEVKLdly.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as BaseHttpClient } from "./http-client-
|
|
1
|
+
import { t as BaseHttpClient } from "./http-client-BZc2mngq.js";
|
|
2
2
|
|
|
3
3
|
//#region src/feedback/client.ts
|
|
4
4
|
function buildListQuery(query) {
|
|
@@ -83,4 +83,4 @@ function createReoptFeedbackClient(config) {
|
|
|
83
83
|
|
|
84
84
|
//#endregion
|
|
85
85
|
export { createReoptFeedbackClient as n, ReoptFeedbackClient as t };
|
|
86
|
-
//# sourceMappingURL=client-
|
|
86
|
+
//# sourceMappingURL=client-zF1RG2uA.js.map
|
package/dist/cms/index.js
CHANGED
|
@@ -305,7 +305,7 @@ function mapHttpStatusToError(status, code, message, ctx, fieldErrors) {
|
|
|
305
305
|
|
|
306
306
|
//#endregion
|
|
307
307
|
//#region src/core/config.ts
|
|
308
|
-
const SDK_VERSION = "3.
|
|
308
|
+
const SDK_VERSION = "3.5.0";
|
|
309
309
|
/**
|
|
310
310
|
* Default API host for EAV / AI / Files / CMS / Terms. Consumers can override
|
|
311
311
|
* via `config.baseUrl` or the `REOPT_BASE_URL` env var.
|
|
@@ -484,4 +484,4 @@ function deriveIdFromBaseUrl(baseUrl) {
|
|
|
484
484
|
|
|
485
485
|
//#endregion
|
|
486
486
|
export { mapHttpStatusToError as A, ServerError as C, isReoptSDKError as D, isModelAccessError as E, isRequiredTermsError as O, RequiredTermsError as S, isCreditLimitError as T, ModelAccessError as _, resolveIdBaseUrl as a, RateLimitError as b, AuthUserNotFoundError as c, ConflictError as d, ContentFilterError as f, LimitExceededError as g, ForbiddenError as h, resolveBaseUrl as i, isValidationError as k, AuthUserRecordExistsError as l, DuplicateAuthUserError as m, SDK_VERSION as n, validateConfig as o, CreditLimitError as p, assertBrowserSafe as r, AuthError as s, REOPT_BASE_URLS as t, BadRequestError as u, ModelNotFoundError as v, ValidationError as w, ReoptSDKError as x, NotFoundError as y };
|
|
487
|
-
//# sourceMappingURL=config-
|
|
487
|
+
//# sourceMappingURL=config-aml9oQpX.js.map
|
package/dist/dev/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { _ as DevPost, a as SeedAllInput, b as InMemoryStore, c as SeedPostGroupInput, d as SeedTermsItem, f as createDevServer, g as DevEntity, h as DevAttribute, i as ProxyConfig, l as SeedPostInput, m as markdownToEditorSpecMany, n as DevServer, o as SeedData, p as markdownToEditorSpec, r as DevServerOptions, s as SeedOptions, t as DevSchema, u as SeedRecordInput, v as DevPostGroup, x as StoreSnapshot, y as DevRecord } from "../index-
|
|
1
|
+
import { _ as DevPost, a as SeedAllInput, b as InMemoryStore, c as SeedPostGroupInput, d as SeedTermsItem, f as createDevServer, g as DevEntity, h as DevAttribute, i as ProxyConfig, l as SeedPostInput, m as markdownToEditorSpecMany, n as DevServer, o as SeedData, p as markdownToEditorSpec, r as DevServerOptions, s as SeedOptions, t as DevSchema, u as SeedRecordInput, v as DevPostGroup, x as StoreSnapshot, y as DevRecord } from "../index-1j_738qk.js";
|
|
2
2
|
export { type DevAttribute, type DevEntity, type DevPost, type DevPostGroup, type DevRecord, DevSchema, DevServer, DevServerOptions, InMemoryStore, ProxyConfig, SeedAllInput, SeedData, SeedOptions, SeedPostGroupInput, SeedPostInput, SeedRecordInput, SeedTermsItem, type StoreSnapshot, createDevServer, markdownToEditorSpec, markdownToEditorSpecMany };
|
package/dist/dev/index.js
CHANGED
|
@@ -20,6 +20,7 @@ var InMemoryStore = class {
|
|
|
20
20
|
authAccounts = /* @__PURE__ */ new Map();
|
|
21
21
|
authVerifications = /* @__PURE__ */ new Map();
|
|
22
22
|
files = /* @__PURE__ */ new Map();
|
|
23
|
+
folders = /* @__PURE__ */ new Map();
|
|
23
24
|
posts = /* @__PURE__ */ new Map();
|
|
24
25
|
postGroups = /* @__PURE__ */ new Map();
|
|
25
26
|
terms = /* @__PURE__ */ new Map();
|
|
@@ -72,6 +73,7 @@ var InMemoryStore = class {
|
|
|
72
73
|
authAccounts: clone(this.authAccounts.values()),
|
|
73
74
|
authVerifications: clone(this.authVerifications.values()),
|
|
74
75
|
files: clone(this.files.values()),
|
|
76
|
+
folders: clone(this.folders.values()),
|
|
75
77
|
posts: clone(this.posts.values()),
|
|
76
78
|
postGroups: clone(this.postGroups.values()),
|
|
77
79
|
terms: clone(this.terms.values()),
|
|
@@ -131,8 +133,15 @@ var InMemoryStore = class {
|
|
|
131
133
|
for (const f of snapshot.files) {
|
|
132
134
|
f.createdAt = toDate(f.createdAt);
|
|
133
135
|
f.updatedAt = toDate(f.updatedAt);
|
|
136
|
+
f.folderId = f.folderId ?? null;
|
|
134
137
|
this.files.set(f.id, f);
|
|
135
138
|
}
|
|
139
|
+
for (const folder of snapshot.folders ?? []) {
|
|
140
|
+
folder.createdAt = toDate(folder.createdAt);
|
|
141
|
+
folder.updatedAt = toDate(folder.updatedAt);
|
|
142
|
+
folder.parentId = folder.parentId ?? null;
|
|
143
|
+
this.folders.set(folder.id, folder);
|
|
144
|
+
}
|
|
136
145
|
for (const p of snapshot.posts) {
|
|
137
146
|
p.createdAt = toDate(p.createdAt);
|
|
138
147
|
p.updatedAt = toDate(p.updatedAt);
|
|
@@ -200,6 +209,7 @@ var InMemoryStore = class {
|
|
|
200
209
|
this.authAccounts.clear();
|
|
201
210
|
this.authVerifications.clear();
|
|
202
211
|
this.files.clear();
|
|
212
|
+
this.folders.clear();
|
|
203
213
|
this.posts.clear();
|
|
204
214
|
this.postGroups.clear();
|
|
205
215
|
this.terms.clear();
|
|
@@ -1375,6 +1385,15 @@ function createAiRoutes() {
|
|
|
1375
1385
|
* `ok()` helpers): `{ data, meta? }` for success and `{ error: { code,
|
|
1376
1386
|
* message } }` for failures — so the SDK's `FileListResponse` type and its
|
|
1377
1387
|
* `sdk.files.get()` / `sdk.files.upload()` unwrappers work unchanged.
|
|
1388
|
+
*
|
|
1389
|
+
* Endpoint parity with `apps/web/server/hono/routes/brandapp-files.ts`:
|
|
1390
|
+
* GET / — list (?folderId=, contentType incl. wildcard)
|
|
1391
|
+
* GET /usage — storage usage (in-memory size sum)
|
|
1392
|
+
* GET /:fileId — detail
|
|
1393
|
+
* GET /:fileId/content — text content read (text whitelist + 1MB cap)
|
|
1394
|
+
* PATCH /:fileId — rename / move
|
|
1395
|
+
* DELETE /:fileId — delete
|
|
1396
|
+
* POST /upload — upload (folderId form field supported)
|
|
1378
1397
|
*/
|
|
1379
1398
|
function toFileInfo(f) {
|
|
1380
1399
|
return {
|
|
@@ -1384,17 +1403,51 @@ function toFileInfo(f) {
|
|
|
1384
1403
|
size: f.size,
|
|
1385
1404
|
contentType: f.contentType,
|
|
1386
1405
|
pathname: `dev/${f.id}/${f.name}`,
|
|
1406
|
+
folderId: f.folderId,
|
|
1387
1407
|
createdAt: f.createdAt.toISOString(),
|
|
1388
1408
|
updatedAt: f.updatedAt.toISOString()
|
|
1389
1409
|
};
|
|
1390
1410
|
}
|
|
1411
|
+
/** production `contentTypeWhere` 미러 — "image/*" 와일드카드 = prefix 매치 */
|
|
1412
|
+
function matchesContentType(fileType, filter) {
|
|
1413
|
+
if (!filter) return true;
|
|
1414
|
+
if (filter.endsWith("/*")) return fileType.startsWith(filter.slice(0, -1));
|
|
1415
|
+
return fileType === filter;
|
|
1416
|
+
}
|
|
1417
|
+
/** production `isTextReadableContentType` 미러 */
|
|
1418
|
+
const TEXT_READABLE_MIME = /* @__PURE__ */ new Set([
|
|
1419
|
+
"application/json",
|
|
1420
|
+
"application/x-ndjson",
|
|
1421
|
+
"application/javascript",
|
|
1422
|
+
"application/typescript",
|
|
1423
|
+
"application/yaml",
|
|
1424
|
+
"application/x-yaml",
|
|
1425
|
+
"application/toml"
|
|
1426
|
+
]);
|
|
1427
|
+
function isTextReadableContentType(contentType) {
|
|
1428
|
+
const base = (contentType ?? "").split(";")[0]?.trim().toLowerCase() ?? "";
|
|
1429
|
+
if (!base) return false;
|
|
1430
|
+
if (base.startsWith("text/")) return true;
|
|
1431
|
+
return TEXT_READABLE_MIME.has(base);
|
|
1432
|
+
}
|
|
1433
|
+
const MAX_TEXT_CONTENT_SIZE = 1024 * 1024;
|
|
1391
1434
|
function createFilesRoutes(store, brandappId) {
|
|
1392
1435
|
const fileContents = /* @__PURE__ */ new Map();
|
|
1393
1436
|
const app = new Hono();
|
|
1394
1437
|
app.get("/", (c) => {
|
|
1395
1438
|
const page = Number(c.req.query("page") || "1");
|
|
1396
1439
|
const limit = Math.min(Number(c.req.query("limit") || "50"), 100);
|
|
1397
|
-
const
|
|
1440
|
+
const contentType = c.req.query("contentType");
|
|
1441
|
+
const folderIdRaw = c.req.query("folderId");
|
|
1442
|
+
const files = store.findMany(store.files, (f) => {
|
|
1443
|
+
if (f.brandappId !== brandappId) return false;
|
|
1444
|
+
if (!matchesContentType(f.contentType, contentType)) return false;
|
|
1445
|
+
if (folderIdRaw !== void 0) {
|
|
1446
|
+
const wanted = folderIdRaw === "" ? null : folderIdRaw;
|
|
1447
|
+
if (f.folderId !== wanted) return false;
|
|
1448
|
+
}
|
|
1449
|
+
return true;
|
|
1450
|
+
}).sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime());
|
|
1398
1451
|
const total = files.length;
|
|
1399
1452
|
const paged = files.slice((page - 1) * limit, page * limit);
|
|
1400
1453
|
return c.json({
|
|
@@ -1406,6 +1459,15 @@ function createFilesRoutes(store, brandappId) {
|
|
|
1406
1459
|
}
|
|
1407
1460
|
});
|
|
1408
1461
|
});
|
|
1462
|
+
app.get("/usage", (c) => {
|
|
1463
|
+
const files = store.findMany(store.files, (f) => f.brandappId === brandappId);
|
|
1464
|
+
const usedBytes = files.reduce((sum, f) => sum + f.size, 0);
|
|
1465
|
+
return c.json({ data: {
|
|
1466
|
+
usedBytes,
|
|
1467
|
+
limitBytes: null,
|
|
1468
|
+
fileCount: files.length
|
|
1469
|
+
} });
|
|
1470
|
+
});
|
|
1409
1471
|
app.get("/:fileId", (c) => {
|
|
1410
1472
|
const fileId = c.req.param("fileId");
|
|
1411
1473
|
const file = store.files.get(fileId);
|
|
@@ -1415,13 +1477,83 @@ function createFilesRoutes(store, brandappId) {
|
|
|
1415
1477
|
} }, 404);
|
|
1416
1478
|
return c.json({ data: toFileInfo(file) });
|
|
1417
1479
|
});
|
|
1480
|
+
app.get("/:fileId/content", (c) => {
|
|
1481
|
+
const fileId = c.req.param("fileId");
|
|
1482
|
+
const file = store.files.get(fileId);
|
|
1483
|
+
if (!file || file.brandappId !== brandappId) return c.json({ error: {
|
|
1484
|
+
code: "NOT_FOUND",
|
|
1485
|
+
message: "File not found"
|
|
1486
|
+
} }, 404);
|
|
1487
|
+
if (!isTextReadableContentType(file.contentType)) return c.json({ error: {
|
|
1488
|
+
code: "UNSUPPORTED_CONTENT_TYPE",
|
|
1489
|
+
message: `Content read is only supported for text files (got: ${file.contentType || "unknown"})`
|
|
1490
|
+
} }, 415);
|
|
1491
|
+
if (file.size > MAX_TEXT_CONTENT_SIZE) return c.json({ error: {
|
|
1492
|
+
code: "CONTENT_TOO_LARGE",
|
|
1493
|
+
message: "File exceeds content read limit of 1MB"
|
|
1494
|
+
} }, 413);
|
|
1495
|
+
const buffer = fileContents.get(fileId);
|
|
1496
|
+
if (!buffer) return c.json({ error: {
|
|
1497
|
+
code: "NOT_FOUND",
|
|
1498
|
+
message: "File content not found"
|
|
1499
|
+
} }, 404);
|
|
1500
|
+
const baseType = file.contentType.split(";")[0]?.trim() || "text/plain";
|
|
1501
|
+
return c.newResponse(new TextDecoder().decode(buffer), 200, {
|
|
1502
|
+
"Content-Type": `${baseType}; charset=utf-8`,
|
|
1503
|
+
"X-Content-Type-Options": "nosniff"
|
|
1504
|
+
});
|
|
1505
|
+
});
|
|
1506
|
+
app.patch("/:fileId", async (c) => {
|
|
1507
|
+
const fileId = c.req.param("fileId");
|
|
1508
|
+
const file = store.files.get(fileId);
|
|
1509
|
+
if (!file || file.brandappId !== brandappId) return c.json({ error: {
|
|
1510
|
+
code: "NOT_FOUND",
|
|
1511
|
+
message: "File not found"
|
|
1512
|
+
} }, 404);
|
|
1513
|
+
let body;
|
|
1514
|
+
try {
|
|
1515
|
+
body = await c.req.json();
|
|
1516
|
+
} catch {
|
|
1517
|
+
return c.json({ error: {
|
|
1518
|
+
code: "BAD_REQUEST",
|
|
1519
|
+
message: "Invalid JSON body"
|
|
1520
|
+
} }, 400);
|
|
1521
|
+
}
|
|
1522
|
+
const hasName = body.name !== void 0;
|
|
1523
|
+
const hasFolderId = body.folderId !== void 0;
|
|
1524
|
+
if (!hasName && !hasFolderId) return c.json({ error: {
|
|
1525
|
+
code: "BAD_REQUEST",
|
|
1526
|
+
message: "At least one of \"name\" or \"folderId\" is required"
|
|
1527
|
+
} }, 400);
|
|
1528
|
+
if (hasName && (typeof body.name !== "string" || !body.name.trim())) return c.json({ error: {
|
|
1529
|
+
code: "BAD_REQUEST",
|
|
1530
|
+
message: "Invalid name"
|
|
1531
|
+
} }, 400);
|
|
1532
|
+
if (hasFolderId && body.folderId !== null) {
|
|
1533
|
+
if (typeof body.folderId !== "string") return c.json({ error: {
|
|
1534
|
+
code: "BAD_REQUEST",
|
|
1535
|
+
message: "Invalid folderId"
|
|
1536
|
+
} }, 400);
|
|
1537
|
+
const folder = store.folders.get(body.folderId);
|
|
1538
|
+
if (!folder || folder.brandappId !== brandappId) return c.json({ error: {
|
|
1539
|
+
code: "NOT_FOUND",
|
|
1540
|
+
message: "Folder not found"
|
|
1541
|
+
} }, 404);
|
|
1542
|
+
}
|
|
1543
|
+
if (hasName) file.name = body.name.trim();
|
|
1544
|
+
if (hasFolderId) file.folderId = body.folderId;
|
|
1545
|
+
file.updatedAt = store.now();
|
|
1546
|
+
return c.json({ data: toFileInfo(file) });
|
|
1547
|
+
});
|
|
1418
1548
|
app.post("/upload", async (c) => {
|
|
1419
1549
|
const contentType = c.req.header("content-type") || "";
|
|
1420
1550
|
let name = "untitled";
|
|
1421
1551
|
let fileContentType = "application/octet-stream";
|
|
1552
|
+
let folderId = null;
|
|
1422
1553
|
let buffer;
|
|
1423
1554
|
if (contentType.includes("multipart/form-data")) {
|
|
1424
|
-
const
|
|
1555
|
+
const formData = await c.req.formData();
|
|
1556
|
+
const file = formData.get("file");
|
|
1425
1557
|
if (!file) return c.json({ error: {
|
|
1426
1558
|
code: "VALIDATION_ERROR",
|
|
1427
1559
|
message: "No file provided"
|
|
@@ -1429,6 +1561,15 @@ function createFilesRoutes(store, brandappId) {
|
|
|
1429
1561
|
name = file.name;
|
|
1430
1562
|
fileContentType = file.type || "application/octet-stream";
|
|
1431
1563
|
buffer = await file.arrayBuffer();
|
|
1564
|
+
const folderIdField = formData.get("folderId");
|
|
1565
|
+
if (typeof folderIdField === "string" && folderIdField.length > 0) {
|
|
1566
|
+
const folder = store.folders.get(folderIdField);
|
|
1567
|
+
if (!folder || folder.brandappId !== brandappId) return c.json({ error: {
|
|
1568
|
+
code: "NOT_FOUND",
|
|
1569
|
+
message: "Folder not found"
|
|
1570
|
+
} }, 404);
|
|
1571
|
+
folderId = folder.id;
|
|
1572
|
+
}
|
|
1432
1573
|
} else {
|
|
1433
1574
|
buffer = await c.req.arrayBuffer();
|
|
1434
1575
|
name = c.req.query("name") || "untitled";
|
|
@@ -1442,6 +1583,7 @@ function createFilesRoutes(store, brandappId) {
|
|
|
1442
1583
|
contentType: fileContentType,
|
|
1443
1584
|
size: buffer.byteLength,
|
|
1444
1585
|
url: `http://localhost/dev-files/${store.generateId()}`,
|
|
1586
|
+
folderId,
|
|
1445
1587
|
createdAt: now,
|
|
1446
1588
|
updatedAt: now
|
|
1447
1589
|
};
|
|
@@ -1463,6 +1605,178 @@ function createFilesRoutes(store, brandappId) {
|
|
|
1463
1605
|
return app;
|
|
1464
1606
|
}
|
|
1465
1607
|
|
|
1608
|
+
//#endregion
|
|
1609
|
+
//#region src/dev/folders-handler.ts
|
|
1610
|
+
/**
|
|
1611
|
+
* Folders Handler for Dev Server
|
|
1612
|
+
*
|
|
1613
|
+
* In-memory mirror of `apps/web/server/hono/routes/brandapp-folders.ts`:
|
|
1614
|
+
* GET / — direct children (?parentId=, empty/absent = root)
|
|
1615
|
+
* POST / — create { name, parentId? } (sibling name conflict → 409)
|
|
1616
|
+
* PATCH /:folderId — rename + move (self/descendant move → 400)
|
|
1617
|
+
* DELETE /:folderId — delete (non-empty → 409 FOLDER_NOT_EMPTY)
|
|
1618
|
+
*/
|
|
1619
|
+
function toFolderInfo(store, folder) {
|
|
1620
|
+
const childCount = store.count(store.folders, (f) => f.brandappId === folder.brandappId && f.parentId === folder.id);
|
|
1621
|
+
const fileCount = store.count(store.files, (f) => f.brandappId === folder.brandappId && f.folderId === folder.id);
|
|
1622
|
+
return {
|
|
1623
|
+
id: folder.id,
|
|
1624
|
+
name: folder.name,
|
|
1625
|
+
parentId: folder.parentId,
|
|
1626
|
+
childCount,
|
|
1627
|
+
fileCount,
|
|
1628
|
+
createdAt: folder.createdAt.toISOString(),
|
|
1629
|
+
updatedAt: folder.updatedAt.toISOString()
|
|
1630
|
+
};
|
|
1631
|
+
}
|
|
1632
|
+
/** production `wouldCreateFolderCycle` 미러 — 조상 체인 역주행 */
|
|
1633
|
+
function wouldCreateCycle(store, folderId, newParentId) {
|
|
1634
|
+
let cursor = newParentId;
|
|
1635
|
+
let guard = 0;
|
|
1636
|
+
while (cursor && guard < 1e4) {
|
|
1637
|
+
if (cursor === folderId) return true;
|
|
1638
|
+
cursor = store.folders.get(cursor)?.parentId ?? null;
|
|
1639
|
+
guard++;
|
|
1640
|
+
}
|
|
1641
|
+
return false;
|
|
1642
|
+
}
|
|
1643
|
+
function hasSiblingNameConflict(store, brandappId, parentId, name, excludeId) {
|
|
1644
|
+
return store.findFirst(store.folders, (f) => f.brandappId === brandappId && f.parentId === parentId && f.name === name && f.id !== excludeId) !== null;
|
|
1645
|
+
}
|
|
1646
|
+
function createFoldersRoutes(store, brandappId) {
|
|
1647
|
+
const app = new Hono();
|
|
1648
|
+
app.get("/", (c) => {
|
|
1649
|
+
const parentIdRaw = c.req.query("parentId");
|
|
1650
|
+
const parentId = parentIdRaw ? parentIdRaw : null;
|
|
1651
|
+
if (parentId && !isScopedFolder(store, brandappId, parentId)) return c.json({ error: {
|
|
1652
|
+
code: "NOT_FOUND",
|
|
1653
|
+
message: "Folder not found"
|
|
1654
|
+
} }, 404);
|
|
1655
|
+
const folders = store.findMany(store.folders, (f) => f.brandappId === brandappId && f.parentId === parentId).sort((a, b) => a.name.localeCompare(b.name));
|
|
1656
|
+
return c.json({ data: folders.map((f) => toFolderInfo(store, f)) });
|
|
1657
|
+
});
|
|
1658
|
+
app.post("/", async (c) => {
|
|
1659
|
+
let body;
|
|
1660
|
+
try {
|
|
1661
|
+
body = await c.req.json();
|
|
1662
|
+
} catch {
|
|
1663
|
+
return c.json({ error: {
|
|
1664
|
+
code: "BAD_REQUEST",
|
|
1665
|
+
message: "Invalid JSON body"
|
|
1666
|
+
} }, 400);
|
|
1667
|
+
}
|
|
1668
|
+
const name = typeof body.name === "string" ? body.name.trim() : "";
|
|
1669
|
+
if (!name || name.length > 255) return c.json({ error: {
|
|
1670
|
+
code: "BAD_REQUEST",
|
|
1671
|
+
message: "Invalid folder name"
|
|
1672
|
+
} }, 400);
|
|
1673
|
+
let parentId = null;
|
|
1674
|
+
if (body.parentId != null) {
|
|
1675
|
+
if (typeof body.parentId !== "string" || !isScopedFolder(store, brandappId, body.parentId)) return c.json({ error: {
|
|
1676
|
+
code: "NOT_FOUND",
|
|
1677
|
+
message: "Parent folder not found"
|
|
1678
|
+
} }, 404);
|
|
1679
|
+
parentId = body.parentId;
|
|
1680
|
+
}
|
|
1681
|
+
if (hasSiblingNameConflict(store, brandappId, parentId, name)) return c.json({ error: {
|
|
1682
|
+
code: "CONFLICT",
|
|
1683
|
+
message: "A folder with the same name already exists here"
|
|
1684
|
+
} }, 409);
|
|
1685
|
+
const now = store.now();
|
|
1686
|
+
const folder = {
|
|
1687
|
+
id: store.generateId(),
|
|
1688
|
+
brandappId,
|
|
1689
|
+
name,
|
|
1690
|
+
parentId,
|
|
1691
|
+
createdAt: now,
|
|
1692
|
+
updatedAt: now
|
|
1693
|
+
};
|
|
1694
|
+
store.folders.set(folder.id, folder);
|
|
1695
|
+
return c.json({ data: toFolderInfo(store, folder) }, 201);
|
|
1696
|
+
});
|
|
1697
|
+
app.patch("/:folderId", async (c) => {
|
|
1698
|
+
const folderId = c.req.param("folderId");
|
|
1699
|
+
const folder = store.folders.get(folderId);
|
|
1700
|
+
if (!folder || folder.brandappId !== brandappId) return c.json({ error: {
|
|
1701
|
+
code: "NOT_FOUND",
|
|
1702
|
+
message: "Folder not found"
|
|
1703
|
+
} }, 404);
|
|
1704
|
+
let body;
|
|
1705
|
+
try {
|
|
1706
|
+
body = await c.req.json();
|
|
1707
|
+
} catch {
|
|
1708
|
+
return c.json({ error: {
|
|
1709
|
+
code: "BAD_REQUEST",
|
|
1710
|
+
message: "Invalid JSON body"
|
|
1711
|
+
} }, 400);
|
|
1712
|
+
}
|
|
1713
|
+
const hasName = body.name !== void 0;
|
|
1714
|
+
const hasParentId = body.parentId !== void 0;
|
|
1715
|
+
if (!hasName && !hasParentId) return c.json({ error: {
|
|
1716
|
+
code: "BAD_REQUEST",
|
|
1717
|
+
message: "At least one of \"name\" or \"parentId\" is required"
|
|
1718
|
+
} }, 400);
|
|
1719
|
+
let nextName = folder.name;
|
|
1720
|
+
if (hasName) {
|
|
1721
|
+
nextName = typeof body.name === "string" ? body.name.trim() : "";
|
|
1722
|
+
if (!nextName || nextName.length > 255) return c.json({ error: {
|
|
1723
|
+
code: "BAD_REQUEST",
|
|
1724
|
+
message: "Invalid folder name"
|
|
1725
|
+
} }, 400);
|
|
1726
|
+
}
|
|
1727
|
+
let nextParentId = folder.parentId;
|
|
1728
|
+
if (hasParentId) if (body.parentId === null) nextParentId = null;
|
|
1729
|
+
else {
|
|
1730
|
+
if (typeof body.parentId !== "string") return c.json({ error: {
|
|
1731
|
+
code: "BAD_REQUEST",
|
|
1732
|
+
message: "Invalid parentId"
|
|
1733
|
+
} }, 400);
|
|
1734
|
+
if (body.parentId === folderId) return c.json({ error: {
|
|
1735
|
+
code: "BAD_REQUEST",
|
|
1736
|
+
message: "Cannot move a folder into itself"
|
|
1737
|
+
} }, 400);
|
|
1738
|
+
if (!isScopedFolder(store, brandappId, body.parentId)) return c.json({ error: {
|
|
1739
|
+
code: "NOT_FOUND",
|
|
1740
|
+
message: "Parent folder not found"
|
|
1741
|
+
} }, 404);
|
|
1742
|
+
if (wouldCreateCycle(store, folderId, body.parentId)) return c.json({ error: {
|
|
1743
|
+
code: "BAD_REQUEST",
|
|
1744
|
+
message: "Cannot move a folder into its own descendant"
|
|
1745
|
+
} }, 400);
|
|
1746
|
+
nextParentId = body.parentId;
|
|
1747
|
+
}
|
|
1748
|
+
if (hasSiblingNameConflict(store, brandappId, nextParentId, nextName, folderId)) return c.json({ error: {
|
|
1749
|
+
code: "CONFLICT",
|
|
1750
|
+
message: "A folder with the same name already exists here"
|
|
1751
|
+
} }, 409);
|
|
1752
|
+
folder.name = nextName;
|
|
1753
|
+
folder.parentId = nextParentId;
|
|
1754
|
+
folder.updatedAt = store.now();
|
|
1755
|
+
return c.json({ data: toFolderInfo(store, folder) });
|
|
1756
|
+
});
|
|
1757
|
+
app.delete("/:folderId", (c) => {
|
|
1758
|
+
const folderId = c.req.param("folderId");
|
|
1759
|
+
const folder = store.folders.get(folderId);
|
|
1760
|
+
if (!folder || folder.brandappId !== brandappId) return c.json({ error: {
|
|
1761
|
+
code: "NOT_FOUND",
|
|
1762
|
+
message: "Folder not found"
|
|
1763
|
+
} }, 404);
|
|
1764
|
+
const childCount = store.count(store.folders, (f) => f.brandappId === brandappId && f.parentId === folderId);
|
|
1765
|
+
const fileCount = store.count(store.files, (f) => f.brandappId === brandappId && f.folderId === folderId);
|
|
1766
|
+
if (childCount > 0 || fileCount > 0) return c.json({ error: {
|
|
1767
|
+
code: "FOLDER_NOT_EMPTY",
|
|
1768
|
+
message: `Folder is not empty: ${fileCount} file(s), ${childCount} subfolder(s). Move or delete the contents first`
|
|
1769
|
+
} }, 409);
|
|
1770
|
+
store.folders.delete(folderId);
|
|
1771
|
+
return c.json({ data: { deleted: true } });
|
|
1772
|
+
});
|
|
1773
|
+
return app;
|
|
1774
|
+
}
|
|
1775
|
+
function isScopedFolder(store, brandappId, folderId) {
|
|
1776
|
+
const folder = store.folders.get(folderId);
|
|
1777
|
+
return !!folder && folder.brandappId === brandappId;
|
|
1778
|
+
}
|
|
1779
|
+
|
|
1466
1780
|
//#endregion
|
|
1467
1781
|
//#region src/dev/cms-handler.ts
|
|
1468
1782
|
/**
|
|
@@ -2440,12 +2754,14 @@ async function createDevServer(options = {}) {
|
|
|
2440
2754
|
app.route(`${basePath}/auth`, routeFor("auth", createAuthRoutes(store, brandappId)));
|
|
2441
2755
|
app.route(`${basePath}/ai`, routeFor("ai", createAiRoutes()));
|
|
2442
2756
|
app.route(`${basePath}/files`, routeFor("files", createFilesRoutes(store, brandappId)));
|
|
2757
|
+
app.route(`${basePath}/folders`, routeFor("files", createFoldersRoutes(store, brandappId)));
|
|
2443
2758
|
app.route(`${basePath}/cms`, routeFor("cms", createCmsRoutes(store, brandappId)));
|
|
2444
2759
|
app.route(`${basePath}/terms`, routeFor("terms", createTermsRoutes(store, brandappId)));
|
|
2445
2760
|
app.route("/api/v1/brandapp/:brandappId/eav", routeFor("eav", createEavRoutes(store, brandappId)));
|
|
2446
2761
|
app.route("/api/v1/brandapp/:brandappId/auth", routeFor("auth", createAuthRoutes(store, brandappId)));
|
|
2447
2762
|
app.route("/api/v1/brandapp/:brandappId/ai", routeFor("ai", createAiRoutes()));
|
|
2448
2763
|
app.route("/api/v1/brandapp/:brandappId/files", routeFor("files", createFilesRoutes(store, brandappId)));
|
|
2764
|
+
app.route("/api/v1/brandapp/:brandappId/folders", routeFor("files", createFoldersRoutes(store, brandappId)));
|
|
2449
2765
|
app.route("/api/v1/brandapp/:brandappId/cms", routeFor("cms", createCmsRoutes(store, brandappId)));
|
|
2450
2766
|
app.route("/api/v1/brandapp/:brandappId/terms", routeFor("terms", createTermsRoutes(store, brandappId)));
|
|
2451
2767
|
app.get("/", (c) => {
|
package/dist/eav/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as AuthUserNotFoundError, g as LimitExceededError, l as AuthUserRecordExistsError, m as DuplicateAuthUserError } from "../config-
|
|
2
|
-
import { t as createReoptEavClient } from "../client-
|
|
1
|
+
import { c as AuthUserNotFoundError, g as LimitExceededError, l as AuthUserRecordExistsError, m as DuplicateAuthUserError } from "../config-aml9oQpX.js";
|
|
2
|
+
import { t as createReoptEavClient } from "../client-61ldOHMz.js";
|
|
3
3
|
|
|
4
4
|
//#region src/eav/verify.ts
|
|
5
5
|
async function verifyEavSchema(input) {
|
package/dist/feedback/index.js
CHANGED
package/dist/files/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as
|
|
1
|
+
import { a as FileListQuery, c as FolderInfo, d as UpdateFolderInput, f as UploadOptions, i as FileInfo, l as FolderListQuery, n as createReoptFileClient, o as FileListResponse, r as CreateFolderInput, s as FileUsageInfo, t as ReoptFileClient, u as UpdateFileInput } from "../client-B7rZQ8Zi.js";
|
|
2
2
|
//#region src/files/helpers.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* 이미지 URL 헬퍼 — Next.js `<Image>`와 결합해 사용.
|
|
@@ -50,5 +50,5 @@ declare function optimizeUrl(src: string, opts: OptimizeUrlOptions): string;
|
|
|
50
50
|
*/
|
|
51
51
|
declare function createImageLoader(defaults?: OptimizeUrlOptions): ({ src, width, quality }: ImageLoaderArgs) => string;
|
|
52
52
|
//#endregion
|
|
53
|
-
export { type FileInfo, type FileListQuery, type FileListResponse, type ImageLoaderArgs, type ImageRemotePattern, type OptimizeUrlOptions, REOPT_IMAGE_REMOTE_PATTERNS, ReoptFileClient, type UploadOptions, createImageLoader, createReoptFileClient, optimizeUrl };
|
|
53
|
+
export { type CreateFolderInput, type FileInfo, type FileListQuery, type FileListResponse, type FileUsageInfo, type FolderInfo, type FolderListQuery, type ImageLoaderArgs, type ImageRemotePattern, type OptimizeUrlOptions, REOPT_IMAGE_REMOTE_PATTERNS, ReoptFileClient, type UpdateFileInput, type UpdateFolderInput, type UploadOptions, createImageLoader, createReoptFileClient, optimizeUrl };
|
|
54
54
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/files/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as mapHttpStatusToError, C as ServerError, a as resolveIdBaseUrl, b as RateLimitError, i as resolveBaseUrl, n as SDK_VERSION, o as validateConfig, x as ReoptSDKError } from "./config-
|
|
1
|
+
import { A as mapHttpStatusToError, C as ServerError, a as resolveIdBaseUrl, b as RateLimitError, i as resolveBaseUrl, n as SDK_VERSION, o as validateConfig, x as ReoptSDKError } from "./config-aml9oQpX.js";
|
|
2
2
|
import { t as createAuthHeader } from "./encoding-Bwfm3iaE.js";
|
|
3
3
|
|
|
4
4
|
//#region src/core/debug.ts
|
|
@@ -383,4 +383,4 @@ function parseFieldErrors(body) {
|
|
|
383
383
|
|
|
384
384
|
//#endregion
|
|
385
385
|
export { parseFieldErrors as n, BaseHttpClient as t };
|
|
386
|
-
//# sourceMappingURL=http-client-
|
|
386
|
+
//# sourceMappingURL=http-client-BZc2mngq.js.map
|
|
@@ -94,6 +94,17 @@ type DevFile = {
|
|
|
94
94
|
contentType: string;
|
|
95
95
|
size: number;
|
|
96
96
|
url: string;
|
|
97
|
+
/** 소속 폴더 ID (루트면 null) — production FileInfo.folderId 미러 */
|
|
98
|
+
folderId: string | null;
|
|
99
|
+
createdAt: Date;
|
|
100
|
+
updatedAt: Date;
|
|
101
|
+
};
|
|
102
|
+
/** production FolderInfo 미러 — 카운트는 응답 시점에 계산 */
|
|
103
|
+
type DevFolder = {
|
|
104
|
+
id: string;
|
|
105
|
+
brandappId: string;
|
|
106
|
+
name: string;
|
|
107
|
+
parentId: string | null;
|
|
97
108
|
createdAt: Date;
|
|
98
109
|
updatedAt: Date;
|
|
99
110
|
};
|
|
@@ -205,6 +216,8 @@ type StoreSnapshot = {
|
|
|
205
216
|
authAccounts: DevAuthAccount[];
|
|
206
217
|
authVerifications: DevAuthVerification[];
|
|
207
218
|
files: DevFile[];
|
|
219
|
+
/** 스냅샷 하위 호환 — 폴더 도입 전 스냅샷엔 없다 */
|
|
220
|
+
folders?: DevFolder[];
|
|
208
221
|
posts: DevPost[];
|
|
209
222
|
postGroups: DevPostGroup[];
|
|
210
223
|
terms: DevTerms[];
|
|
@@ -220,6 +233,7 @@ declare class InMemoryStore {
|
|
|
220
233
|
authAccounts: Map<string, DevAuthAccount>;
|
|
221
234
|
authVerifications: Map<string, DevAuthVerification>;
|
|
222
235
|
files: Map<string, DevFile>;
|
|
236
|
+
folders: Map<string, DevFolder>;
|
|
223
237
|
posts: Map<string, DevPost>;
|
|
224
238
|
postGroups: Map<string, DevPostGroup>;
|
|
225
239
|
terms: Map<string, DevTerms>;
|
|
@@ -453,4 +467,4 @@ type DevServer = {
|
|
|
453
467
|
declare function createDevServer(options?: DevServerOptions): Promise<DevServer>;
|
|
454
468
|
//#endregion
|
|
455
469
|
export { DevPost as _, SeedAllInput as a, InMemoryStore as b, SeedPostGroupInput as c, SeedTermsItem as d, createDevServer as f, DevEntity as g, DevAttribute as h, ProxyConfig as i, SeedPostInput as l, markdownToEditorSpecMany as m, DevServer as n, SeedData as o, markdownToEditorSpec as p, DevServerOptions as r, SeedOptions as s, DevSchema as t, SeedRecordInput as u, DevPostGroup as v, StoreSnapshot as x, DevRecord as y };
|
|
456
|
-
//# sourceMappingURL=index-
|
|
470
|
+
//# sourceMappingURL=index-1j_738qk.d.ts.map
|