entity-server-client 0.2.5 → 0.2.6

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 (44) hide show
  1. package/README.md +0 -1
  2. package/build.mjs +4 -1
  3. package/dist/EntityServerClient.d.ts +705 -199
  4. package/dist/client/base.d.ts +59 -0
  5. package/dist/client/packet.d.ts +8 -6
  6. package/dist/client/request.d.ts +0 -1
  7. package/dist/client/utils.d.ts +5 -1
  8. package/dist/index.js +1 -1
  9. package/dist/index.js.map +4 -4
  10. package/dist/mixins/alimtalk.d.ts +56 -0
  11. package/dist/mixins/auth.d.ts +167 -0
  12. package/dist/mixins/email.d.ts +51 -0
  13. package/dist/mixins/entity.d.ts +119 -0
  14. package/dist/mixins/file.d.ts +78 -0
  15. package/dist/mixins/identity.d.ts +52 -0
  16. package/dist/mixins/pg.d.ts +63 -0
  17. package/dist/mixins/push.d.ts +110 -0
  18. package/dist/mixins/sms.d.ts +55 -0
  19. package/dist/mixins/smtp.d.ts +44 -0
  20. package/dist/mixins/utils.d.ts +70 -0
  21. package/dist/react.js +1 -1
  22. package/dist/react.js.map +4 -4
  23. package/dist/types.d.ts +165 -1
  24. package/docs/apis.md +5 -12
  25. package/docs/react.md +6 -7
  26. package/package.json +2 -1
  27. package/src/EntityServerClient.ts +54 -546
  28. package/src/client/base.ts +246 -0
  29. package/src/client/packet.ts +14 -27
  30. package/src/client/request.ts +2 -11
  31. package/src/client/utils.ts +18 -2
  32. package/src/hooks/useEntityServer.ts +3 -4
  33. package/src/mixins/alimtalk.ts +35 -0
  34. package/src/mixins/auth.ts +287 -0
  35. package/src/mixins/email.ts +46 -0
  36. package/src/mixins/entity.ts +205 -0
  37. package/src/mixins/file.ts +99 -0
  38. package/src/mixins/identity.ts +35 -0
  39. package/src/mixins/pg.ts +58 -0
  40. package/src/mixins/push.ts +132 -0
  41. package/src/mixins/sms.ts +46 -0
  42. package/src/mixins/smtp.ts +20 -0
  43. package/src/mixins/utils.ts +75 -0
  44. package/src/types.ts +203 -1
@@ -0,0 +1,287 @@
1
+ import type { GConstructor, EntityServerClientBase } from "../client/base";
2
+
3
+ export function AuthMixin<TBase extends GConstructor<EntityServerClientBase>>(
4
+ Base: TBase,
5
+ ) {
6
+ return class AuthMixinClass extends Base {
7
+ // ─── 인증 ─────────────────────────────────────────────────────────────
8
+
9
+ /**
10
+ * 서버 헬스 체크를 수행하고 패킷 암호화 활성 여부를 자동으로 감지합니다.
11
+ *
12
+ * 서버가 `packet_encryption: true`를 응답하면 이후 모든 요청에 암호화가 자동 적용됩니다.
13
+ *
14
+ * ```ts
15
+ * await client.checkHealth();
16
+ * await client.login(email, password);
17
+ * ```
18
+ */
19
+ async checkHealth(): Promise<{
20
+ ok: boolean;
21
+ packet_encryption?: boolean;
22
+ }> {
23
+ const res = await fetch(`${this.baseUrl}/v1/health`, {
24
+ signal: AbortSignal.timeout(3000),
25
+ });
26
+ const data = (await res.json()) as {
27
+ ok: boolean;
28
+ packet_encryption?: boolean;
29
+ };
30
+ if (data.packet_encryption) this.encryptRequests = true;
31
+ return data;
32
+ }
33
+
34
+ /** 로그인 후 `access_token`을 내부 상태에 저장합니다. */
35
+ async login(
36
+ email: string,
37
+ password: string,
38
+ ): Promise<{
39
+ access_token: string;
40
+ refresh_token: string;
41
+ expires_in: number;
42
+ }> {
43
+ const data = await this._request<{
44
+ data: {
45
+ access_token: string;
46
+ refresh_token: string;
47
+ expires_in: number;
48
+ };
49
+ }>("POST", "/v1/auth/login", { email, passwd: password }, false);
50
+ this.token = data.data.access_token;
51
+ if (this.keepSession)
52
+ this._scheduleKeepSession(
53
+ data.data.refresh_token,
54
+ data.data.expires_in,
55
+ (rt) => this.refreshToken(rt),
56
+ );
57
+ return data.data;
58
+ }
59
+
60
+ /** Refresh Token으로 Access Token을 재발급받아 내부 토큰을 교체합니다. */
61
+ async refreshToken(
62
+ refreshToken: string,
63
+ ): Promise<{ access_token: string; expires_in: number }> {
64
+ const data = await this._request<{
65
+ data: { access_token: string; expires_in: number };
66
+ }>(
67
+ "POST",
68
+ "/v1/auth/refresh",
69
+ { refresh_token: refreshToken },
70
+ false,
71
+ );
72
+ this.token = data.data.access_token;
73
+ if (this.keepSession)
74
+ this._scheduleKeepSession(
75
+ refreshToken,
76
+ data.data.expires_in,
77
+ (rt) => this.refreshToken(rt),
78
+ );
79
+ return data.data;
80
+ }
81
+
82
+ /**
83
+ * 서버에 로그아웃을 요청하고 내부 토큰을 초기화합니다.
84
+ * refresh_token을 서버에 전달해 무효화합니다.
85
+ */
86
+ async logout(refreshToken: string): Promise<{ ok: boolean }> {
87
+ this.stopKeepSession();
88
+ const data = await this._request<{ ok: boolean }>(
89
+ "POST",
90
+ "/v1/auth/logout",
91
+ { refresh_token: refreshToken },
92
+ false,
93
+ );
94
+ this.token = "";
95
+ return data;
96
+ }
97
+
98
+ /** 현재 로그인된 사용자 정보를 반환합니다. */
99
+ me<T = Record<string, unknown>>(): Promise<{ ok: boolean; data: T }> {
100
+ return this._request("GET", "/v1/auth/me");
101
+ }
102
+
103
+ /** 비밀번호를 변경합니다. */
104
+ changePassword(
105
+ currentPasswd: string,
106
+ newPasswd: string,
107
+ ): Promise<{ ok: boolean }> {
108
+ return this._request("POST", "/v1/auth/change-password", {
109
+ current_passwd: currentPasswd,
110
+ new_passwd: newPasswd,
111
+ });
112
+ }
113
+
114
+ /** 회원 탈퇴를 요청합니다. */
115
+ withdraw(passwd?: string): Promise<{ ok: boolean }> {
116
+ return this._request(
117
+ "POST",
118
+ "/v1/auth/withdraw",
119
+ passwd ? { passwd } : {},
120
+ );
121
+ }
122
+
123
+ /**
124
+ * 휴면 계정을 재활성화합니다.
125
+ * 비밀번호 또는 OAuth(provider + code)로 본인 확인합니다.
126
+ */
127
+ reactivate(params: {
128
+ email: string;
129
+ passwd?: string;
130
+ provider?: string;
131
+ code?: string;
132
+ }): Promise<{
133
+ access_token: string;
134
+ refresh_token: string;
135
+ expires_in: number;
136
+ }> {
137
+ return this._request("POST", "/v1/auth/reactivate", params, false);
138
+ }
139
+
140
+ /** 비밀번호 재설정 메일을 요청합니다. */
141
+ passwordResetRequest(email: string): Promise<{ ok: boolean }> {
142
+ return this._request(
143
+ "POST",
144
+ "/v1/auth/password-reset",
145
+ { email },
146
+ false,
147
+ );
148
+ }
149
+
150
+ /** 이메일로 전달된 토큰으로 비밀번호를 재설정합니다. */
151
+ passwordResetConfirm(
152
+ token: string,
153
+ newPasswd: string,
154
+ ): Promise<{ ok: boolean }> {
155
+ return this._request(
156
+ "POST",
157
+ "/v1/auth/password-reset/confirm",
158
+ { token, new_passwd: newPasswd },
159
+ false,
160
+ );
161
+ }
162
+
163
+ // ─── OAuth 연동 ───────────────────────────────────────────────────────
164
+
165
+ /** OAuth 프로바이더를 현재 계정에 연동합니다. */
166
+ oauthLink(
167
+ provider: string,
168
+ code: string,
169
+ state?: string,
170
+ ): Promise<{ ok: boolean; message: string; provider: string }> {
171
+ return this._request("POST", "/v1/auth/oauth/link", {
172
+ provider,
173
+ code,
174
+ ...(state ? { state } : {}),
175
+ });
176
+ }
177
+
178
+ /** OAuth 프로바이더 연동을 해제합니다. */
179
+ oauthUnlink(
180
+ provider: string,
181
+ ): Promise<{ ok: boolean; message: string; provider: string }> {
182
+ return this._request("DELETE", `/v1/auth/oauth/link/${provider}`);
183
+ }
184
+
185
+ /** 현재 계정에 연동된 OAuth 프로바이더 목록을 반환합니다. */
186
+ oauthProviders(): Promise<{
187
+ ok: boolean;
188
+ data: Array<{
189
+ provider: string;
190
+ email?: string;
191
+ linked_at?: string;
192
+ }>;
193
+ }> {
194
+ return this._request("GET", "/v1/auth/oauth/providers");
195
+ }
196
+
197
+ /** 특정 OAuth 프로바이더의 액세스 토큰을 갱신합니다. */
198
+ oauthTokenRefresh(provider: string): Promise<{
199
+ ok: boolean;
200
+ access_token: string;
201
+ expires_at?: string;
202
+ }> {
203
+ return this._request("POST", `/v1/auth/oauth/refresh/${provider}`);
204
+ }
205
+
206
+ // ─── 2단계 인증 (2FA) ─────────────────────────────────────────────────
207
+
208
+ /** 2FA 설정을 시작하고 QR 코드 / 시크릿을 반환합니다. */
209
+ twoFactorSetup(): Promise<{
210
+ ok: boolean;
211
+ setup_token: string;
212
+ qr_url: string;
213
+ secret: string;
214
+ }> {
215
+ return this._request("POST", "/v1/auth/2fa/setup");
216
+ }
217
+
218
+ /** TOTP 코드로 2FA 설정을 완료합니다. */
219
+ twoFactorSetupVerify(
220
+ code: string,
221
+ setupToken: string,
222
+ ): Promise<{ ok: boolean; recovery_codes: string[] }> {
223
+ return this._request("POST", "/v1/auth/2fa/setup/verify", {
224
+ code,
225
+ setup_token: setupToken,
226
+ });
227
+ }
228
+
229
+ /** 2FA를 비활성화합니다. */
230
+ twoFactorDisable(code: string): Promise<{ ok: boolean }> {
231
+ return this._request("DELETE", "/v1/auth/2fa", { code });
232
+ }
233
+
234
+ /** 2FA 활성화 여부를 조회합니다. */
235
+ twoFactorStatus(): Promise<{ ok: boolean; enabled: boolean }> {
236
+ return this._request("GET", "/v1/auth/2fa/status");
237
+ }
238
+
239
+ /** 임시 토큰으로 TOTP 코드를 검증하여 최종 JWT를 발급받습니다. */
240
+ twoFactorVerify(
241
+ twoFactorToken: string,
242
+ code: string,
243
+ ): Promise<{
244
+ ok: boolean;
245
+ access_token: string;
246
+ refresh_token: string;
247
+ expires_in: number;
248
+ }> {
249
+ return this._request(
250
+ "POST",
251
+ "/v1/auth/2fa/verify",
252
+ { two_factor_token: twoFactorToken, code },
253
+ false,
254
+ );
255
+ }
256
+
257
+ /** 복구 코드로 2FA를 우회하여 최종 JWT를 발급받습니다. */
258
+ twoFactorRecovery(
259
+ twoFactorToken: string,
260
+ recoveryCode: string,
261
+ ): Promise<{
262
+ ok: boolean;
263
+ access_token: string;
264
+ refresh_token: string;
265
+ expires_in: number;
266
+ }> {
267
+ return this._request(
268
+ "POST",
269
+ "/v1/auth/2fa/recovery",
270
+ {
271
+ two_factor_token: twoFactorToken,
272
+ recovery_code: recoveryCode,
273
+ },
274
+ false,
275
+ );
276
+ }
277
+
278
+ /** 복구 코드를 재생성합니다. */
279
+ twoFactorRegenerateRecovery(
280
+ code: string,
281
+ ): Promise<{ ok: boolean; recovery_codes: string[] }> {
282
+ return this._request("POST", "/v1/auth/2fa/recovery/regenerate", {
283
+ code,
284
+ });
285
+ }
286
+ };
287
+ }
@@ -0,0 +1,46 @@
1
+ import type { GConstructor, EntityServerClientBase } from "../client/base";
2
+
3
+ export function EmailMixin<TBase extends GConstructor<EntityServerClientBase>>(
4
+ Base: TBase,
5
+ ) {
6
+ return class EmailMixinClass extends Base {
7
+ // ─── 이메일 인증 / 변경 ───────────────────────────────────────────────
8
+
9
+ /** 이메일 인증 코드 또는 링크를 발송합니다. */
10
+ emailVerificationSend(email: string): Promise<{ ok: boolean }> {
11
+ return this._request(
12
+ "POST",
13
+ "/v1/email/verification/send",
14
+ { email },
15
+ false,
16
+ );
17
+ }
18
+
19
+ /** 이메일 인증 코드를 확인합니다. */
20
+ emailVerificationConfirm(token: string): Promise<{ ok: boolean }> {
21
+ return this._request(
22
+ "POST",
23
+ "/v1/email/verification/confirm",
24
+ { token },
25
+ false,
26
+ );
27
+ }
28
+
29
+ /** 현재 계정의 이메일 인증 상태를 조회합니다. (JWT 필요) */
30
+ emailVerificationStatus(): Promise<{
31
+ ok: boolean;
32
+ verified: boolean;
33
+ email?: string;
34
+ }> {
35
+ return this._request("GET", "/v1/email/verification/status");
36
+ }
37
+
38
+ /** 이메일 주소를 변경합니다. (JWT + 인증 코드 필요) */
39
+ emailChange(newEmail: string, code?: string): Promise<{ ok: boolean }> {
40
+ return this._request("POST", "/v1/email/change", {
41
+ new_email: newEmail,
42
+ ...(code ? { code } : {}),
43
+ });
44
+ }
45
+ };
46
+ }
@@ -0,0 +1,205 @@
1
+ import type {
2
+ EntityHistoryRecord,
3
+ EntityListParams,
4
+ EntityListResult,
5
+ EntityQueryRequest,
6
+ } from "../types";
7
+ import { buildQuery } from "../client/utils";
8
+ import type { GConstructor, EntityServerClientBase } from "../client/base";
9
+
10
+ export function EntityMixin<TBase extends GConstructor<EntityServerClientBase>>(
11
+ Base: TBase,
12
+ ) {
13
+ return class EntityMixinClass extends Base {
14
+ // ─── 트랜잭션 ─────────────────────────────────────────────────────────
15
+
16
+ /** 트랜잭션을 시작하고 활성 트랜잭션 ID를 저장합니다. */
17
+ async transStart(): Promise<string> {
18
+ const res = await this._request<{
19
+ ok: boolean;
20
+ transaction_id: string;
21
+ }>("POST", "/v1/transaction/start", undefined, false);
22
+ this.activeTxId = res.transaction_id;
23
+ return this.activeTxId;
24
+ }
25
+
26
+ /** 활성 트랜잭션(또는 전달된 transactionId)을 롤백합니다. */
27
+ transRollback(transactionId?: string): Promise<{ ok: boolean }> {
28
+ const txId = transactionId ?? this.activeTxId;
29
+ if (!txId)
30
+ return Promise.reject(
31
+ new Error(
32
+ "No active transaction. Call transStart() first.",
33
+ ),
34
+ );
35
+ this.activeTxId = null;
36
+ return this._request("POST", `/v1/transaction/rollback/${txId}`);
37
+ }
38
+
39
+ /**
40
+ * 활성 트랜잭션(또는 전달된 transactionId)을 커밋합니다.
41
+ *
42
+ * @returns `results` 배열: commit된 각 작업의 `entity`, `action`, `seq`
43
+ */
44
+ transCommit(transactionId?: string): Promise<{
45
+ ok: boolean;
46
+ results: Array<{ entity: string; action: string; seq: number }>;
47
+ }> {
48
+ const txId = transactionId ?? this.activeTxId;
49
+ if (!txId)
50
+ return Promise.reject(
51
+ new Error(
52
+ "No active transaction. Call transStart() first.",
53
+ ),
54
+ );
55
+ this.activeTxId = null;
56
+ return this._request("POST", `/v1/transaction/commit/${txId}`);
57
+ }
58
+
59
+ // ─── 엔티티 CRUD ──────────────────────────────────────────────────────
60
+
61
+ /** 시퀀스 ID로 엔티티 단건을 조회합니다. */
62
+ get<T = unknown>(
63
+ entity: string,
64
+ seq: number,
65
+ opts: { skipHooks?: boolean } = {},
66
+ ): Promise<{ ok: boolean; data: T }> {
67
+ const q = opts.skipHooks ? "?skipHooks=true" : "";
68
+ return this._request("GET", `/v1/entity/${entity}/${seq}${q}`);
69
+ }
70
+
71
+ /** 조건으로 엔티티 단건을 조회합니다. data 컬럼을 완전히 복호화하여 반환합니다. */
72
+ find<T = unknown>(
73
+ entity: string,
74
+ conditions?: Record<string, unknown>,
75
+ opts: { skipHooks?: boolean } = {},
76
+ ): Promise<{ ok: boolean; data: T }> {
77
+ const q = opts.skipHooks ? "?skipHooks=true" : "";
78
+ return this._request(
79
+ "POST",
80
+ `/v1/entity/${entity}/find${q}`,
81
+ conditions ?? {},
82
+ );
83
+ }
84
+
85
+ /** 페이지네이션/정렬/필터 조건으로 엔티티 목록을 조회합니다. */
86
+ list<T = unknown>(
87
+ entity: string,
88
+ params: EntityListParams = {},
89
+ ): Promise<{ ok: boolean; data: EntityListResult<T> }> {
90
+ const { conditions, fields, orderDir, orderBy, ...rest } = params;
91
+ const queryObj: Record<string, unknown> = {
92
+ page: 1,
93
+ limit: 20,
94
+ ...rest,
95
+ };
96
+ if (orderBy)
97
+ queryObj.orderBy =
98
+ orderDir === "DESC" ? `-${orderBy}` : orderBy;
99
+ if (fields?.length) queryObj.fields = fields.join(",");
100
+ return this._request(
101
+ "POST",
102
+ `/v1/entity/${entity}/list?${buildQuery(queryObj)}`,
103
+ conditions ?? {},
104
+ );
105
+ }
106
+
107
+ /**
108
+ * 엔티티 총 건수를 조회합니다.
109
+ *
110
+ * @param conditions 필터 조건 (예: `{ status: "active" }`)
111
+ */
112
+ count(
113
+ entity: string,
114
+ conditions?: Record<string, unknown>,
115
+ ): Promise<{ ok: boolean; count: number }> {
116
+ return this._request(
117
+ "POST",
118
+ `/v1/entity/${entity}/count`,
119
+ conditions ?? {},
120
+ );
121
+ }
122
+
123
+ /**
124
+ * 커스텀 SQL로 엔티티를 조회합니다.
125
+ *
126
+ * SELECT 전용이며 인덱스 테이블만 조회 가능합니다. JOIN 지원.
127
+ */
128
+ query<T = unknown>(
129
+ entity: string,
130
+ req: EntityQueryRequest,
131
+ ): Promise<{ ok: boolean; data: { items: T[]; count: number } }> {
132
+ return this._request("POST", `/v1/entity/${entity}/query`, req);
133
+ }
134
+
135
+ /** 엔티티 데이터를 생성/수정(Submit)합니다. `seq`가 없으면 INSERT, 있으면 UPDATE입니다. */
136
+ submit(
137
+ entity: string,
138
+ data: Record<string, unknown>,
139
+ opts: { transactionId?: string; skipHooks?: boolean } = {},
140
+ ): Promise<{ ok: boolean; seq: number }> {
141
+ const txId = opts.transactionId ?? this.activeTxId;
142
+ const extraHeaders = txId
143
+ ? { "X-Transaction-ID": txId }
144
+ : undefined;
145
+ const q = opts.skipHooks ? "?skipHooks=true" : "";
146
+ return this._request(
147
+ "POST",
148
+ `/v1/entity/${entity}/submit${q}`,
149
+ data,
150
+ true,
151
+ extraHeaders,
152
+ );
153
+ }
154
+
155
+ /** 시퀀스 ID로 엔티티를 삭제합니다(`hard=true`면 하드 삭제, 기본은 소프트 삭제). */
156
+ delete(
157
+ entity: string,
158
+ seq: number,
159
+ opts: {
160
+ transactionId?: string;
161
+ hard?: boolean;
162
+ skipHooks?: boolean;
163
+ } = {},
164
+ ): Promise<{ ok: boolean; deleted: number }> {
165
+ const params = new URLSearchParams();
166
+ if (opts.hard) params.set("hard", "true");
167
+ if (opts.skipHooks) params.set("skipHooks", "true");
168
+ const q = params.size ? `?${params}` : "";
169
+ const txId = opts.transactionId ?? this.activeTxId;
170
+ const extraHeaders = txId
171
+ ? { "X-Transaction-ID": txId }
172
+ : undefined;
173
+ return this._request(
174
+ "POST",
175
+ `/v1/entity/${entity}/delete/${seq}${q}`,
176
+ undefined,
177
+ true,
178
+ extraHeaders,
179
+ );
180
+ }
181
+
182
+ /** 엔티티 단건의 변경 이력을 조회합니다. */
183
+ history<T = unknown>(
184
+ entity: string,
185
+ seq: number,
186
+ params: Pick<EntityListParams, "page" | "limit"> = {},
187
+ ): Promise<{
188
+ ok: boolean;
189
+ data: EntityListResult<EntityHistoryRecord<T>>;
190
+ }> {
191
+ return this._request(
192
+ "GET",
193
+ `/v1/entity/${entity}/history/${seq}?${buildQuery({ page: 1, limit: 50, ...params })}`,
194
+ );
195
+ }
196
+
197
+ /** 특정 이력 시점으로 엔티티를 롤백합니다. */
198
+ rollback(entity: string, historySeq: number): Promise<{ ok: boolean }> {
199
+ return this._request(
200
+ "POST",
201
+ `/v1/entity/${entity}/rollback/${historySeq}`,
202
+ );
203
+ }
204
+ };
205
+ }
@@ -0,0 +1,99 @@
1
+ import type { FileMeta, FileUploadOptions } from "../types";
2
+ import type { GConstructor, EntityServerClientBase } from "../client/base";
3
+
4
+ export function FileMixin<TBase extends GConstructor<EntityServerClientBase>>(
5
+ Base: TBase,
6
+ ) {
7
+ return class FileMixinClass extends Base {
8
+ // ─── 파일 관리 ────────────────────────────────────────────────────────
9
+
10
+ /**
11
+ * 파일을 업로드합니다. (multipart/form-data)
12
+ *
13
+ * ```ts
14
+ * const input = document.querySelector('input[type="file"]');
15
+ * const result = await client.fileUpload("product", input.files[0]);
16
+ * console.log(result.data.uuid);
17
+ * ```
18
+ */
19
+ async fileUpload(
20
+ entity: string,
21
+ file: File | Blob,
22
+ opts: FileUploadOptions = {},
23
+ ): Promise<{ ok: boolean; uuid: string; data: FileMeta }> {
24
+ const form = new FormData();
25
+ form.append(
26
+ "file",
27
+ file,
28
+ file instanceof File ? file.name : "upload",
29
+ );
30
+ if (opts.refSeq != null)
31
+ form.append("ref_seq", String(opts.refSeq));
32
+ if (opts.isPublic != null)
33
+ form.append("is_public", opts.isPublic ? "true" : "false");
34
+ return this._requestForm(
35
+ "POST",
36
+ `/v1/files/${entity}/upload`,
37
+ form,
38
+ );
39
+ }
40
+
41
+ /** 파일을 다운로드합니다. `ArrayBuffer`를 반환합니다. */
42
+ fileDownload(entity: string, uuid: string): Promise<ArrayBuffer> {
43
+ return this._requestBinary(
44
+ "POST",
45
+ `/v1/files/${entity}/download/${uuid}`,
46
+ {},
47
+ );
48
+ }
49
+
50
+ /** 파일을 삭제합니다. */
51
+ fileDelete(
52
+ entity: string,
53
+ uuid: string,
54
+ ): Promise<{ ok: boolean; uuid: string; deleted: boolean }> {
55
+ return this._request(
56
+ "POST",
57
+ `/v1/files/${entity}/delete/${uuid}`,
58
+ {},
59
+ );
60
+ }
61
+
62
+ /** 엔티티에 연결된 파일 목록을 조회합니다. */
63
+ fileList(
64
+ entity: string,
65
+ opts: { refSeq?: number } = {},
66
+ ): Promise<{
67
+ ok: boolean;
68
+ data: { items: FileMeta[]; total: number };
69
+ }> {
70
+ return this._request(
71
+ "POST",
72
+ `/v1/files/${entity}/list`,
73
+ opts.refSeq ? { ref_seq: opts.refSeq } : {},
74
+ );
75
+ }
76
+
77
+ /** 파일 메타 정보를 조회합니다. */
78
+ fileMeta(
79
+ entity: string,
80
+ uuid: string,
81
+ ): Promise<{ ok: boolean; data: FileMeta }> {
82
+ return this._request(
83
+ "POST",
84
+ `/v1/files/${entity}/meta/${uuid}`,
85
+ {},
86
+ );
87
+ }
88
+
89
+ /** 임시 파일 접근 토큰을 발급합니다. */
90
+ fileToken(uuid: string): Promise<{ ok: boolean; token: string }> {
91
+ return this._request("POST", `/v1/files/token/${uuid}`, {});
92
+ }
93
+
94
+ /** 파일 인라인 뷰 URL을 반환합니다. (fetch 없음, URL 조합만) */
95
+ fileUrl(uuid: string): string {
96
+ return `${this.baseUrl}/v1/files/${uuid}`;
97
+ }
98
+ };
99
+ }
@@ -0,0 +1,35 @@
1
+ import type { IdentityRequestOptions } from "../types";
2
+ import type { GConstructor, EntityServerClientBase } from "../client/base";
3
+
4
+ export function IdentityMixin<
5
+ TBase extends GConstructor<EntityServerClientBase>,
6
+ >(Base: TBase) {
7
+ return class IdentityMixinClass extends Base {
8
+ // ─── 본인인증 ─────────────────────────────────────────────────────────
9
+
10
+ /** 본인인증 요청을 생성합니다. */
11
+ identityRequest(
12
+ opts: IdentityRequestOptions,
13
+ ): Promise<{ ok: boolean; data: Record<string, unknown> }> {
14
+ return this._request("POST", "/v1/identity/request", opts);
15
+ }
16
+
17
+ /** 본인인증 결과를 조회합니다. */
18
+ identityResult(requestId: string): Promise<{
19
+ ok: boolean;
20
+ data: Record<string, unknown>;
21
+ }> {
22
+ return this._request("GET", `/v1/identity/result/${requestId}`);
23
+ }
24
+
25
+ /** CI 해시 중복 여부를 확인합니다. */
26
+ identityVerifyCI(ciHash: string): Promise<{
27
+ ok: boolean;
28
+ data: { exists: boolean; account_seq?: number };
29
+ }> {
30
+ return this._request("POST", "/v1/identity/verify-ci", {
31
+ ci_hash: ciHash,
32
+ });
33
+ }
34
+ };
35
+ }