@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.
- package/CHANGELOG.md +115 -0
- package/README.md +10 -1
- package/dist/abort--nOBFN4M.js +50 -0
- package/dist/ai/index.d.ts +2 -314
- package/dist/ai/index.js +3 -8
- package/dist/ai-provider/index.d.ts +79 -163
- package/dist/ai-provider/index.js +752 -685
- package/dist/auth/index.d.ts +27 -27
- package/dist/auth/index.js +41 -34
- package/dist/better-auth/client.d.ts +6 -5
- package/dist/better-auth/client.js +28 -5
- package/dist/better-auth/index.d.ts +19 -17
- package/dist/better-auth/index.js +180 -144
- package/dist/client-61ldOHMz.js +503 -0
- package/dist/client-7PCoxVhZ.js +28 -0
- package/dist/client-B7rZQ8Zi.d.ts +272 -0
- package/dist/client-BGGd_cpV.d.ts +103 -0
- package/dist/client-BoIuyx4S.js +273 -0
- package/dist/client-BruP5_nU.d.ts +147 -0
- package/dist/client-BxtZt405.js +305 -0
- package/dist/client-ByN3EQdk.js +83 -0
- package/dist/client-CAghoGD_.js +53 -0
- package/dist/client-C_pHsPlj.js +81 -0
- package/dist/client-D0eBxh8j.d.ts +284 -0
- package/dist/client-D6gs61w8.d.ts +53 -0
- package/dist/client-DDw5yz_h.d.ts +53 -0
- package/dist/client-Dxg8_DIH.d.ts +71 -0
- package/dist/client-aMR4CRB8.d.ts +211 -0
- package/dist/client-lk6wBu_0.d.ts +48 -0
- package/dist/client-wEVKLdly.js +55 -0
- package/dist/client-zF1RG2uA.js +86 -0
- package/dist/cms/index.d.ts +52 -108
- package/dist/cms/index.js +103 -86
- package/dist/config-CRytOPPl.d.ts +394 -0
- package/dist/config-aml9oQpX.js +487 -0
- package/dist/dev/index.d.ts +2 -528
- package/dist/dev/index.js +3047 -2967
- package/dist/eav/coerce.d.ts +3 -1
- package/dist/eav/coerce.js +72 -46
- package/dist/eav/index.d.ts +72 -100
- package/dist/eav/index.js +158 -126
- package/dist/eav/migrate.d.ts +112 -109
- package/dist/eav/migrate.js +230 -196
- package/dist/eav/schema.d.ts +111 -150
- package/dist/eav/schema.js +624 -603
- package/dist/encoding-Bwfm3iaE.js +21 -0
- package/dist/{errors-BjDFIyA6.d.ts → errors-CRCcErNC.d.ts} +55 -53
- package/dist/feedback/index.d.ts +2 -132
- package/dist/feedback/index.js +3 -6
- package/dist/files/index.d.ts +14 -14
- package/dist/files/index.js +41 -25
- package/dist/http-client-BZc2mngq.js +386 -0
- package/dist/index-1j_738qk.d.ts +470 -0
- package/dist/index-CeOLGdyL.d.ts +169 -0
- package/dist/index.d.ts +6 -230
- package/dist/index.js +119 -71
- package/dist/logout/index.d.ts +56 -53
- package/dist/logout/index.js +232 -289
- package/dist/plans/index.d.ts +2 -236
- package/dist/plans/index.js +3 -6
- package/dist/push/index.d.ts +2 -79
- package/dist/push/index.js +3 -6
- package/dist/query-xWqtfkvR.js +35 -0
- package/dist/react/hooks.d.ts +157 -100
- package/dist/react/hooks.js +862 -406
- package/dist/sse-parser-FMjxM7sY.js +86 -0
- package/dist/terms/index.d.ts +3 -79
- package/dist/terms/index.js +3 -6
- package/dist/testing/index.d.ts +52 -104
- package/dist/testing/index.js +94 -72
- package/dist/types-B-SMkH6s.d.ts +26 -0
- package/dist/types-BXDcoJHG.d.ts +131 -0
- package/dist/types-BrghN2rJ.d.ts +105 -0
- package/dist/types-DjDRszNj.js +11 -0
- package/dist/webhooks/index.d.ts +77 -50
- package/dist/webhooks/index.js +150 -127
- package/docs/api-reference.md +121 -8
- package/docs/errors.md +19 -0
- package/docs/files.md +165 -7
- package/package.json +7 -6
- package/dist/chunk-2LSCQHAU.js +0 -21
- package/dist/chunk-4U4ZPPL4.js +0 -599
- package/dist/chunk-55KHY5GH.js +0 -96
- package/dist/chunk-C5VTRZWX.js +0 -458
- package/dist/chunk-F7BXBTZI.js +0 -54
- package/dist/chunk-FJUCWXX3.js +0 -350
- package/dist/chunk-H33OTQEN.js +0 -112
- package/dist/chunk-L4DHB36G.js +0 -75
- package/dist/chunk-OG7R3UAR.js +0 -105
- package/dist/chunk-PF24XU54.js +0 -32
- package/dist/chunk-QN3QD67K.js +0 -49
- package/dist/chunk-REIKXSMY.js +0 -7
- package/dist/chunk-UGBBXCZE.js +0 -157
- package/dist/chunk-UVT2E6KD.js +0 -81
- package/dist/chunk-YPLT3RFL.js +0 -63
- package/dist/chunk-YTKSAWV2.js +0 -463
- package/dist/client-BkcO-0C2.d.ts +0 -216
- package/dist/client-CN5_tNOC.d.ts +0 -147
- package/dist/client-DttyeM_h.d.ts +0 -102
- package/dist/config-CtxyJsDR.d.ts +0 -397
- package/dist/typed-client-BxOVIiMU.d.ts +0 -40
- package/dist/types-6E3ZLL9X.d.ts +0 -24
- package/dist/types-DskYLVb8.d.ts +0 -104
- package/dist/types-ckmDDW3N.d.ts +0 -129
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
import { n as ReoptSDKConfig } from "./config-CRytOPPl.js";
|
|
2
|
+
//#region src/files/types.d.ts
|
|
3
|
+
/** 파일 정보 */
|
|
4
|
+
type FileInfo = {
|
|
5
|
+
/** 파일 ID */
|
|
6
|
+
id: string;
|
|
7
|
+
/** 파일명 */
|
|
8
|
+
name: string;
|
|
9
|
+
/** 파일 URL (Vercel Blob) */
|
|
10
|
+
url: string | null;
|
|
11
|
+
/** 파일 크기 (bytes) */
|
|
12
|
+
size: number;
|
|
13
|
+
/** MIME 타입 */
|
|
14
|
+
contentType: string | null;
|
|
15
|
+
/** 저장 경로 */
|
|
16
|
+
pathname: string;
|
|
17
|
+
/** 소속 폴더 ID — 루트(폴더 밖)면 null. 서버 1.x(폴더 도입 전) 응답엔 없을 수 있다. */
|
|
18
|
+
folderId?: string | null;
|
|
19
|
+
/** 생성일 (ISO 8601) */
|
|
20
|
+
createdAt: string;
|
|
21
|
+
/** 수정일 (ISO 8601) */
|
|
22
|
+
updatedAt: string;
|
|
23
|
+
};
|
|
24
|
+
/** 파일 목록 조회 쿼리 */
|
|
25
|
+
type FileListQuery = {
|
|
26
|
+
/** 페이지 번호 (기본 1) */
|
|
27
|
+
page?: number;
|
|
28
|
+
/** 페이지 당 항목 수 (기본 20) */
|
|
29
|
+
limit?: number;
|
|
30
|
+
/** MIME 타입 필터 (e.g. "image/png", 와일드카드 "image/*") */
|
|
31
|
+
contentType?: string;
|
|
32
|
+
/**
|
|
33
|
+
* 폴더 필터 — 미지정이면 전체(폴더 무시, 하위 호환), `null`이면 루트(폴더
|
|
34
|
+
* 미소속)만, 폴더 ID면 해당 폴더 직속 파일만.
|
|
35
|
+
*/
|
|
36
|
+
folderId?: string | null;
|
|
37
|
+
/** 정렬 기준 */
|
|
38
|
+
sortBy?: "createdAt" | "name" | "size";
|
|
39
|
+
/** 정렬 순서 */
|
|
40
|
+
sortOrder?: "asc" | "desc";
|
|
41
|
+
};
|
|
42
|
+
/** 파일 목록 응답 */
|
|
43
|
+
type FileListResponse = {
|
|
44
|
+
data: FileInfo[];
|
|
45
|
+
meta: {
|
|
46
|
+
page: number;
|
|
47
|
+
limit: number;
|
|
48
|
+
total: number;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
/** 파일 업로드 옵션 */
|
|
52
|
+
type UploadOptions = {
|
|
53
|
+
/** 파일명 (미지정 시 원본 파일명 또는 자동 생성) */
|
|
54
|
+
name?: string;
|
|
55
|
+
/** MIME 타입 (미지정 시 자동 감지) */
|
|
56
|
+
contentType?: string;
|
|
57
|
+
/** 업로드할 폴더 ID (미지정 시 루트) */
|
|
58
|
+
folderId?: string;
|
|
59
|
+
/** 외부 AbortSignal — 업로드 중도 취소용. SDK 타임아웃과 병합됨. */
|
|
60
|
+
signal?: AbortSignal;
|
|
61
|
+
/** 이 호출에만 적용할 타임아웃 (ms). 미지정 시 SDK 기본값. */
|
|
62
|
+
timeout?: number;
|
|
63
|
+
};
|
|
64
|
+
/** 파일 수정 입력 — rename + move (최소 한 필드 필요) */
|
|
65
|
+
type UpdateFileInput = {
|
|
66
|
+
/** 새 파일명 (표시명만 변경 — 저장 경로 pathname은 불변) */
|
|
67
|
+
name?: string;
|
|
68
|
+
/** 이동할 폴더 ID — null이면 루트(폴더 밖)로 이동 */
|
|
69
|
+
folderId?: string | null;
|
|
70
|
+
};
|
|
71
|
+
/** 폴더 정보 */
|
|
72
|
+
type FolderInfo = {
|
|
73
|
+
/** 폴더 ID */
|
|
74
|
+
id: string;
|
|
75
|
+
/** 폴더명 */
|
|
76
|
+
name: string;
|
|
77
|
+
/** 부모 폴더 ID (루트면 null) */
|
|
78
|
+
parentId: string | null;
|
|
79
|
+
/** 직속 하위 폴더 수 */
|
|
80
|
+
childCount: number;
|
|
81
|
+
/** 직속 파일 수 */
|
|
82
|
+
fileCount: number;
|
|
83
|
+
/** 생성일 (ISO 8601) */
|
|
84
|
+
createdAt: string;
|
|
85
|
+
/** 수정일 (ISO 8601) */
|
|
86
|
+
updatedAt: string;
|
|
87
|
+
};
|
|
88
|
+
/** 폴더 목록 조회 쿼리 */
|
|
89
|
+
type FolderListQuery = {
|
|
90
|
+
/** 부모 폴더 ID — 미지정 또는 null이면 루트의 직속 자식 폴더 */
|
|
91
|
+
parentId?: string | null;
|
|
92
|
+
};
|
|
93
|
+
/** 폴더 생성 입력 */
|
|
94
|
+
type CreateFolderInput = {
|
|
95
|
+
name: string;
|
|
96
|
+
/** 부모 폴더 ID (미지정/null = 루트) */
|
|
97
|
+
parentId?: string | null;
|
|
98
|
+
};
|
|
99
|
+
/** 폴더 수정 입력 — rename + move (최소 한 필드 필요) */
|
|
100
|
+
type UpdateFolderInput = {
|
|
101
|
+
name?: string;
|
|
102
|
+
/** 이동할 부모 폴더 ID — null이면 루트로 이동. 자기 자신/자손으로의 이동은 400. */
|
|
103
|
+
parentId?: string | null;
|
|
104
|
+
};
|
|
105
|
+
/**
|
|
106
|
+
* 저장공간 사용량. `usedBytes`/`limitBytes`는 워크스페이스 단위(한도 판정과 동일
|
|
107
|
+
* 소스 — 초과 업로드 402 STORAGE_LIMIT과 정합), `fileCount`는 이 brandapp 스코프.
|
|
108
|
+
*/
|
|
109
|
+
type FileUsageInfo = {
|
|
110
|
+
/** 워크스페이스 전체 사용량 (bytes) */
|
|
111
|
+
usedBytes: number;
|
|
112
|
+
/** 플랜 스토리지 한도 (bytes) — null이면 무제한 */
|
|
113
|
+
limitBytes: number | null;
|
|
114
|
+
/** 이 brandapp 파일 수 */
|
|
115
|
+
fileCount: number;
|
|
116
|
+
};
|
|
117
|
+
//#endregion
|
|
118
|
+
//#region src/files/client.d.ts
|
|
119
|
+
declare class ReoptFileClient {
|
|
120
|
+
private readonly http;
|
|
121
|
+
/** 폴더 계열은 형제 리소스(/folders) — 파일과 같은 인증/에러 계약을 공유 */
|
|
122
|
+
private readonly folderHttp;
|
|
123
|
+
private readonly timeout;
|
|
124
|
+
constructor(config: ReoptSDKConfig);
|
|
125
|
+
/**
|
|
126
|
+
* 파일 목록 조회
|
|
127
|
+
*
|
|
128
|
+
* @example
|
|
129
|
+
* ```ts
|
|
130
|
+
* const { data: files, meta } = await sdk.files.list({
|
|
131
|
+
* page: 1,
|
|
132
|
+
* limit: 20,
|
|
133
|
+
* contentType: "image/*",
|
|
134
|
+
* sortBy: "createdAt",
|
|
135
|
+
* sortOrder: "desc",
|
|
136
|
+
* });
|
|
137
|
+
* console.log(`Total: ${meta.total}`);
|
|
138
|
+
* ```
|
|
139
|
+
*/
|
|
140
|
+
list(query?: FileListQuery): Promise<FileListResponse>;
|
|
141
|
+
/**
|
|
142
|
+
* 단일 파일 조회
|
|
143
|
+
*
|
|
144
|
+
* @example
|
|
145
|
+
* ```ts
|
|
146
|
+
* const file = await sdk.files.get("file-uuid");
|
|
147
|
+
* console.log(file.name, file.url);
|
|
148
|
+
* ```
|
|
149
|
+
*/
|
|
150
|
+
get(fileId: string): Promise<FileInfo>;
|
|
151
|
+
/**
|
|
152
|
+
* 파일 수정 — 이름 변경(rename) + 폴더 이동(move)
|
|
153
|
+
*
|
|
154
|
+
* @example
|
|
155
|
+
* ```ts
|
|
156
|
+
* await sdk.files.update(fileId, { name: "renamed.png" });
|
|
157
|
+
* await sdk.files.update(fileId, { folderId }); // 폴더로 이동
|
|
158
|
+
* await sdk.files.update(fileId, { folderId: null }); // 루트로 이동
|
|
159
|
+
* ```
|
|
160
|
+
*/
|
|
161
|
+
update(fileId: string, input: UpdateFileInput): Promise<FileInfo>;
|
|
162
|
+
/**
|
|
163
|
+
* 텍스트 파일 내용 읽기 (미리보기용)
|
|
164
|
+
*
|
|
165
|
+
* 텍스트 계열(`text/*`, `application/json` 등)만 지원 — 그 외는 415
|
|
166
|
+
* (`UNSUPPORTED_CONTENT_TYPE`), 1MB 초과는 413 (`CONTENT_TOO_LARGE`).
|
|
167
|
+
*
|
|
168
|
+
* @example
|
|
169
|
+
* ```ts
|
|
170
|
+
* const text = await sdk.files.readContent(fileId);
|
|
171
|
+
* ```
|
|
172
|
+
*/
|
|
173
|
+
readContent(fileId: string, options?: {
|
|
174
|
+
signal?: AbortSignal;
|
|
175
|
+
timeout?: number;
|
|
176
|
+
}): Promise<string>;
|
|
177
|
+
/**
|
|
178
|
+
* 저장공간 사용량 조회 — 사용량 미터·"한도 임박" 경고용
|
|
179
|
+
*
|
|
180
|
+
* `usedBytes`/`limitBytes`는 워크스페이스 단위(초과 업로드 402
|
|
181
|
+
* `STORAGE_LIMIT` 판정과 동일 소스), `fileCount`는 이 brandapp 스코프.
|
|
182
|
+
*
|
|
183
|
+
* @example
|
|
184
|
+
* ```ts
|
|
185
|
+
* const { usedBytes, limitBytes } = await sdk.files.usage();
|
|
186
|
+
* if (limitBytes != null && usedBytes / limitBytes > 0.9) warnAlmostFull();
|
|
187
|
+
* ```
|
|
188
|
+
*/
|
|
189
|
+
usage(): Promise<FileUsageInfo>;
|
|
190
|
+
/**
|
|
191
|
+
* 직속 자식 폴더 목록 조회
|
|
192
|
+
*
|
|
193
|
+
* @example
|
|
194
|
+
* ```ts
|
|
195
|
+
* const rootFolders = await sdk.files.listFolders();
|
|
196
|
+
* const children = await sdk.files.listFolders({ parentId: folder.id });
|
|
197
|
+
* ```
|
|
198
|
+
*/
|
|
199
|
+
listFolders(query?: FolderListQuery): Promise<FolderInfo[]>;
|
|
200
|
+
/**
|
|
201
|
+
* 폴더 생성
|
|
202
|
+
*
|
|
203
|
+
* @example
|
|
204
|
+
* ```ts
|
|
205
|
+
* const folder = await sdk.files.createFolder({ name: "invoices" });
|
|
206
|
+
* const child = await sdk.files.createFolder({ name: "2026", parentId: folder.id });
|
|
207
|
+
* ```
|
|
208
|
+
*/
|
|
209
|
+
createFolder(input: CreateFolderInput): Promise<FolderInfo>;
|
|
210
|
+
/**
|
|
211
|
+
* 폴더 수정 — 이름 변경(rename) + 이동(move)
|
|
212
|
+
*
|
|
213
|
+
* 자기 자신/자손으로의 이동은 400으로 거부된다 (cycle 방지).
|
|
214
|
+
*
|
|
215
|
+
* @example
|
|
216
|
+
* ```ts
|
|
217
|
+
* await sdk.files.updateFolder(folderId, { name: "archive" });
|
|
218
|
+
* await sdk.files.updateFolder(folderId, { parentId: otherFolderId });
|
|
219
|
+
* ```
|
|
220
|
+
*/
|
|
221
|
+
updateFolder(folderId: string, input: UpdateFolderInput): Promise<FolderInfo>;
|
|
222
|
+
/**
|
|
223
|
+
* 폴더 삭제 — 비어있어야 한다 (아니면 409 `FOLDER_NOT_EMPTY`)
|
|
224
|
+
*
|
|
225
|
+
* @example
|
|
226
|
+
* ```ts
|
|
227
|
+
* await sdk.files.deleteFolder(folderId);
|
|
228
|
+
* ```
|
|
229
|
+
*/
|
|
230
|
+
deleteFolder(folderId: string): Promise<void>;
|
|
231
|
+
/**
|
|
232
|
+
* 파일 삭제
|
|
233
|
+
*
|
|
234
|
+
* @example
|
|
235
|
+
* ```ts
|
|
236
|
+
* await sdk.files.delete("file-uuid");
|
|
237
|
+
* ```
|
|
238
|
+
*/
|
|
239
|
+
delete(fileId: string): Promise<void>;
|
|
240
|
+
/**
|
|
241
|
+
* 파일 업로드
|
|
242
|
+
*
|
|
243
|
+
* FormData(multipart)로 파일을 전송합니다.
|
|
244
|
+
* BaseHttpClient는 JSON 전용이므로 globalThis.fetch를 직접 사용합니다.
|
|
245
|
+
*
|
|
246
|
+
* TODO(files): 업로드 진행률(onProgress) 미지원 — fetch 단일 요청이라 진행
|
|
247
|
+
* 이벤트가 없다. XHR 기반 onProgress 또는 presigned 2-step 업로드(10MB 상한
|
|
248
|
+
* 완화 동반)는 서버 계약 변경이 필요해 별도 RFC로 다룬다.
|
|
249
|
+
*
|
|
250
|
+
* @example
|
|
251
|
+
* ```ts
|
|
252
|
+
* // Blob 업로드
|
|
253
|
+
* const blob = new Blob(["hello"], { type: "text/plain" });
|
|
254
|
+
* const file = await sdk.files.upload(blob, { name: "hello.txt" });
|
|
255
|
+
*
|
|
256
|
+
* // File 업로드 (브라우저)
|
|
257
|
+
* const file = await sdk.files.upload(inputEl.files[0]);
|
|
258
|
+
*
|
|
259
|
+
* // Buffer 업로드 (Node.js)
|
|
260
|
+
* const buf = fs.readFileSync("image.png");
|
|
261
|
+
* const file = await sdk.files.upload(buf, {
|
|
262
|
+
* name: "image.png",
|
|
263
|
+
* contentType: "image/png",
|
|
264
|
+
* });
|
|
265
|
+
* ```
|
|
266
|
+
*/
|
|
267
|
+
upload(file: Blob | Uint8Array | File, options?: UploadOptions): Promise<FileInfo>;
|
|
268
|
+
}
|
|
269
|
+
declare function createReoptFileClient(config: ReoptSDKConfig): ReoptFileClient;
|
|
270
|
+
//#endregion
|
|
271
|
+
export { FileListQuery as a, FolderInfo as c, UpdateFolderInput as d, UploadOptions as f, FileInfo as i, FolderListQuery as l, createReoptFileClient as n, FileListResponse as o, CreateFolderInput as r, FileUsageInfo as s, ReoptFileClient as t, UpdateFileInput as u };
|
|
272
|
+
//# sourceMappingURL=client-B7rZQ8Zi.d.ts.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,273 @@
|
|
|
1
|
+
import { A as mapHttpStatusToError, n as SDK_VERSION, o as validateConfig, x as ReoptSDKError } from "./config-aml9oQpX.js";
|
|
2
|
+
import { t as createManagedAbort } from "./abort--nOBFN4M.js";
|
|
3
|
+
import { n as parseFieldErrors, t as BaseHttpClient } from "./http-client-BZc2mngq.js";
|
|
4
|
+
|
|
5
|
+
//#region src/files/client.ts
|
|
6
|
+
var ReoptFileClient = class {
|
|
7
|
+
http;
|
|
8
|
+
/** 폴더 계열은 형제 리소스(/folders) — 파일과 같은 인증/에러 계약을 공유 */
|
|
9
|
+
folderHttp;
|
|
10
|
+
timeout;
|
|
11
|
+
constructor(config) {
|
|
12
|
+
validateConfig(config);
|
|
13
|
+
const pathPrefix = `/api/v1/brandapp/${config.brandappId}/files`;
|
|
14
|
+
this.http = new BaseHttpClient(config, pathPrefix);
|
|
15
|
+
this.folderHttp = new BaseHttpClient(config, `/api/v1/brandapp/${config.brandappId}/folders`);
|
|
16
|
+
this.timeout = config.timeout ?? 3e4;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* 파일 목록 조회
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```ts
|
|
23
|
+
* const { data: files, meta } = await sdk.files.list({
|
|
24
|
+
* page: 1,
|
|
25
|
+
* limit: 20,
|
|
26
|
+
* contentType: "image/*",
|
|
27
|
+
* sortBy: "createdAt",
|
|
28
|
+
* sortOrder: "desc",
|
|
29
|
+
* });
|
|
30
|
+
* console.log(`Total: ${meta.total}`);
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
async list(query) {
|
|
34
|
+
const params = new URLSearchParams();
|
|
35
|
+
if (query?.page != null) params.set("page", String(query.page));
|
|
36
|
+
if (query?.limit != null) params.set("limit", String(query.limit));
|
|
37
|
+
if (query?.contentType) params.set("contentType", query.contentType);
|
|
38
|
+
if (query?.folderId !== void 0) params.set("folderId", query.folderId ?? "");
|
|
39
|
+
if (query?.sortBy) params.set("sortBy", query.sortBy);
|
|
40
|
+
if (query?.sortOrder) params.set("sortOrder", query.sortOrder);
|
|
41
|
+
const qs = params.toString();
|
|
42
|
+
const path = qs ? `?${qs}` : "";
|
|
43
|
+
return this.http.fetch("GET", path);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* 단일 파일 조회
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```ts
|
|
50
|
+
* const file = await sdk.files.get("file-uuid");
|
|
51
|
+
* console.log(file.name, file.url);
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
async get(fileId) {
|
|
55
|
+
return (await this.http.fetch("GET", `/${encodeURIComponent(fileId)}`)).data;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* 파일 수정 — 이름 변경(rename) + 폴더 이동(move)
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```ts
|
|
62
|
+
* await sdk.files.update(fileId, { name: "renamed.png" });
|
|
63
|
+
* await sdk.files.update(fileId, { folderId }); // 폴더로 이동
|
|
64
|
+
* await sdk.files.update(fileId, { folderId: null }); // 루트로 이동
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
async update(fileId, input) {
|
|
68
|
+
return (await this.http.fetch("PATCH", `/${encodeURIComponent(fileId)}`, input)).data;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* 텍스트 파일 내용 읽기 (미리보기용)
|
|
72
|
+
*
|
|
73
|
+
* 텍스트 계열(`text/*`, `application/json` 등)만 지원 — 그 외는 415
|
|
74
|
+
* (`UNSUPPORTED_CONTENT_TYPE`), 1MB 초과는 413 (`CONTENT_TOO_LARGE`).
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```ts
|
|
78
|
+
* const text = await sdk.files.readContent(fileId);
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
async readContent(fileId, options) {
|
|
82
|
+
const url = `${this.http.requestBaseUrl}/${encodeURIComponent(fileId)}/content`;
|
|
83
|
+
const managed = createManagedAbort({
|
|
84
|
+
timeoutMs: options?.timeout ?? this.timeout,
|
|
85
|
+
external: options?.signal
|
|
86
|
+
});
|
|
87
|
+
try {
|
|
88
|
+
const response = await globalThis.fetch(url, {
|
|
89
|
+
method: "GET",
|
|
90
|
+
headers: {
|
|
91
|
+
Authorization: this.http.authorizationHeader,
|
|
92
|
+
"X-SDK-Version": `brandapp-sdk/${SDK_VERSION}`
|
|
93
|
+
},
|
|
94
|
+
signal: managed.signal
|
|
95
|
+
});
|
|
96
|
+
if (!response.ok) {
|
|
97
|
+
const body = await response.json().catch(() => ({}));
|
|
98
|
+
const errObj = typeof body.error === "object" ? body.error : void 0;
|
|
99
|
+
const msg = errObj?.message ?? (typeof body.error === "string" ? body.error : void 0) ?? `Content read failed with status ${response.status}`;
|
|
100
|
+
throw mapHttpStatusToError(response.status, errObj?.code, msg, {
|
|
101
|
+
method: "GET",
|
|
102
|
+
url
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
return await response.text();
|
|
106
|
+
} catch (e) {
|
|
107
|
+
if (e instanceof ReoptSDKError) throw e;
|
|
108
|
+
if (e instanceof Error && e.name === "AbortError") throw new ReoptSDKError("Content read timed out", 408, "TIMEOUT");
|
|
109
|
+
throw e;
|
|
110
|
+
} finally {
|
|
111
|
+
managed.cleanup();
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* 저장공간 사용량 조회 — 사용량 미터·"한도 임박" 경고용
|
|
116
|
+
*
|
|
117
|
+
* `usedBytes`/`limitBytes`는 워크스페이스 단위(초과 업로드 402
|
|
118
|
+
* `STORAGE_LIMIT` 판정과 동일 소스), `fileCount`는 이 brandapp 스코프.
|
|
119
|
+
*
|
|
120
|
+
* @example
|
|
121
|
+
* ```ts
|
|
122
|
+
* const { usedBytes, limitBytes } = await sdk.files.usage();
|
|
123
|
+
* if (limitBytes != null && usedBytes / limitBytes > 0.9) warnAlmostFull();
|
|
124
|
+
* ```
|
|
125
|
+
*/
|
|
126
|
+
async usage() {
|
|
127
|
+
return (await this.http.fetch("GET", "/usage")).data;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* 직속 자식 폴더 목록 조회
|
|
131
|
+
*
|
|
132
|
+
* @example
|
|
133
|
+
* ```ts
|
|
134
|
+
* const rootFolders = await sdk.files.listFolders();
|
|
135
|
+
* const children = await sdk.files.listFolders({ parentId: folder.id });
|
|
136
|
+
* ```
|
|
137
|
+
*/
|
|
138
|
+
async listFolders(query) {
|
|
139
|
+
const params = new URLSearchParams();
|
|
140
|
+
if (query?.parentId) params.set("parentId", query.parentId);
|
|
141
|
+
const qs = params.toString();
|
|
142
|
+
return (await this.folderHttp.fetch("GET", qs ? `?${qs}` : "")).data;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* 폴더 생성
|
|
146
|
+
*
|
|
147
|
+
* @example
|
|
148
|
+
* ```ts
|
|
149
|
+
* const folder = await sdk.files.createFolder({ name: "invoices" });
|
|
150
|
+
* const child = await sdk.files.createFolder({ name: "2026", parentId: folder.id });
|
|
151
|
+
* ```
|
|
152
|
+
*/
|
|
153
|
+
async createFolder(input) {
|
|
154
|
+
return (await this.folderHttp.fetch("POST", "", input)).data;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* 폴더 수정 — 이름 변경(rename) + 이동(move)
|
|
158
|
+
*
|
|
159
|
+
* 자기 자신/자손으로의 이동은 400으로 거부된다 (cycle 방지).
|
|
160
|
+
*
|
|
161
|
+
* @example
|
|
162
|
+
* ```ts
|
|
163
|
+
* await sdk.files.updateFolder(folderId, { name: "archive" });
|
|
164
|
+
* await sdk.files.updateFolder(folderId, { parentId: otherFolderId });
|
|
165
|
+
* ```
|
|
166
|
+
*/
|
|
167
|
+
async updateFolder(folderId, input) {
|
|
168
|
+
return (await this.folderHttp.fetch("PATCH", `/${encodeURIComponent(folderId)}`, input)).data;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* 폴더 삭제 — 비어있어야 한다 (아니면 409 `FOLDER_NOT_EMPTY`)
|
|
172
|
+
*
|
|
173
|
+
* @example
|
|
174
|
+
* ```ts
|
|
175
|
+
* await sdk.files.deleteFolder(folderId);
|
|
176
|
+
* ```
|
|
177
|
+
*/
|
|
178
|
+
async deleteFolder(folderId) {
|
|
179
|
+
await this.folderHttp.fetch("DELETE", `/${encodeURIComponent(folderId)}`);
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* 파일 삭제
|
|
183
|
+
*
|
|
184
|
+
* @example
|
|
185
|
+
* ```ts
|
|
186
|
+
* await sdk.files.delete("file-uuid");
|
|
187
|
+
* ```
|
|
188
|
+
*/
|
|
189
|
+
async delete(fileId) {
|
|
190
|
+
await this.http.fetch("DELETE", `/${encodeURIComponent(fileId)}`);
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* 파일 업로드
|
|
194
|
+
*
|
|
195
|
+
* FormData(multipart)로 파일을 전송합니다.
|
|
196
|
+
* BaseHttpClient는 JSON 전용이므로 globalThis.fetch를 직접 사용합니다.
|
|
197
|
+
*
|
|
198
|
+
* TODO(files): 업로드 진행률(onProgress) 미지원 — fetch 단일 요청이라 진행
|
|
199
|
+
* 이벤트가 없다. XHR 기반 onProgress 또는 presigned 2-step 업로드(10MB 상한
|
|
200
|
+
* 완화 동반)는 서버 계약 변경이 필요해 별도 RFC로 다룬다.
|
|
201
|
+
*
|
|
202
|
+
* @example
|
|
203
|
+
* ```ts
|
|
204
|
+
* // Blob 업로드
|
|
205
|
+
* const blob = new Blob(["hello"], { type: "text/plain" });
|
|
206
|
+
* const file = await sdk.files.upload(blob, { name: "hello.txt" });
|
|
207
|
+
*
|
|
208
|
+
* // File 업로드 (브라우저)
|
|
209
|
+
* const file = await sdk.files.upload(inputEl.files[0]);
|
|
210
|
+
*
|
|
211
|
+
* // Buffer 업로드 (Node.js)
|
|
212
|
+
* const buf = fs.readFileSync("image.png");
|
|
213
|
+
* const file = await sdk.files.upload(buf, {
|
|
214
|
+
* name: "image.png",
|
|
215
|
+
* contentType: "image/png",
|
|
216
|
+
* });
|
|
217
|
+
* ```
|
|
218
|
+
*/
|
|
219
|
+
async upload(file, options) {
|
|
220
|
+
const formData = new FormData();
|
|
221
|
+
if (file instanceof Blob) {
|
|
222
|
+
const fileName = options?.name ?? ("name" in file ? file.name : "upload");
|
|
223
|
+
formData.append("file", file, fileName);
|
|
224
|
+
} else {
|
|
225
|
+
const arrayBuffer = file.buffer.slice(file.byteOffset, file.byteOffset + file.byteLength);
|
|
226
|
+
const blob = new Blob([arrayBuffer], { type: options?.contentType ?? "application/octet-stream" });
|
|
227
|
+
formData.append("file", blob, options?.name ?? "upload");
|
|
228
|
+
}
|
|
229
|
+
if (options?.name) formData.append("name", options.name);
|
|
230
|
+
if (options?.contentType) formData.append("contentType", options.contentType);
|
|
231
|
+
if (options?.folderId) formData.append("folderId", options.folderId);
|
|
232
|
+
const url = `${this.http.requestBaseUrl}/upload`;
|
|
233
|
+
const managed = createManagedAbort({
|
|
234
|
+
timeoutMs: options?.timeout ?? this.timeout,
|
|
235
|
+
external: options?.signal
|
|
236
|
+
});
|
|
237
|
+
try {
|
|
238
|
+
const response = await globalThis.fetch(url, {
|
|
239
|
+
method: "POST",
|
|
240
|
+
headers: {
|
|
241
|
+
Authorization: this.http.authorizationHeader,
|
|
242
|
+
"X-SDK-Version": `brandapp-sdk/${SDK_VERSION}`
|
|
243
|
+
},
|
|
244
|
+
body: formData,
|
|
245
|
+
signal: managed.signal
|
|
246
|
+
});
|
|
247
|
+
if (!response.ok) {
|
|
248
|
+
const body = await response.json().catch(() => ({}));
|
|
249
|
+
const errObj = typeof body.error === "object" ? body.error : void 0;
|
|
250
|
+
const msg = errObj?.message ?? (typeof body.error === "string" ? body.error : void 0) ?? `Upload failed with status ${response.status}`;
|
|
251
|
+
const fieldErrors = response.status === 422 ? parseFieldErrors(body) : [];
|
|
252
|
+
throw mapHttpStatusToError(response.status, errObj?.code, msg, {
|
|
253
|
+
method: "POST",
|
|
254
|
+
url
|
|
255
|
+
}, fieldErrors);
|
|
256
|
+
}
|
|
257
|
+
return (await response.json()).data;
|
|
258
|
+
} catch (e) {
|
|
259
|
+
if (e instanceof ReoptSDKError) throw e;
|
|
260
|
+
if (e instanceof Error && e.name === "AbortError") throw new ReoptSDKError("Upload request timed out", 408, "TIMEOUT");
|
|
261
|
+
throw e;
|
|
262
|
+
} finally {
|
|
263
|
+
managed.cleanup();
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
};
|
|
267
|
+
function createReoptFileClient(config) {
|
|
268
|
+
return new ReoptFileClient(config);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
//#endregion
|
|
272
|
+
export { createReoptFileClient as n, ReoptFileClient as t };
|
|
273
|
+
//# sourceMappingURL=client-BoIuyx4S.js.map
|