entity-server-client 0.2.4 → 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 (48) hide show
  1. package/README.md +0 -1
  2. package/build.mjs +4 -1
  3. package/dist/EntityServerClient.d.ts +709 -0
  4. package/dist/client/base.d.ts +59 -0
  5. package/dist/client/hmac.d.ts +8 -0
  6. package/dist/client/packet.d.ts +24 -0
  7. package/dist/client/request.d.ts +15 -0
  8. package/dist/client/utils.d.ts +8 -0
  9. package/dist/index.d.ts +3 -393
  10. package/dist/index.js +1 -1
  11. package/dist/index.js.map +4 -4
  12. package/dist/mixins/alimtalk.d.ts +56 -0
  13. package/dist/mixins/auth.d.ts +167 -0
  14. package/dist/mixins/email.d.ts +51 -0
  15. package/dist/mixins/entity.d.ts +119 -0
  16. package/dist/mixins/file.d.ts +78 -0
  17. package/dist/mixins/identity.d.ts +52 -0
  18. package/dist/mixins/pg.d.ts +63 -0
  19. package/dist/mixins/push.d.ts +110 -0
  20. package/dist/mixins/sms.d.ts +55 -0
  21. package/dist/mixins/smtp.d.ts +44 -0
  22. package/dist/mixins/utils.d.ts +70 -0
  23. package/dist/react.js +1 -1
  24. package/dist/react.js.map +4 -4
  25. package/dist/types.d.ts +329 -0
  26. package/docs/apis.md +5 -12
  27. package/docs/react.md +6 -7
  28. package/package.json +2 -1
  29. package/src/EntityServerClient.ts +54 -0
  30. package/src/client/base.ts +246 -0
  31. package/src/client/hmac.ts +41 -0
  32. package/src/client/packet.ts +100 -0
  33. package/src/client/request.ts +93 -0
  34. package/src/client/utils.ts +34 -0
  35. package/src/hooks/useEntityServer.ts +3 -4
  36. package/src/index.ts +3 -917
  37. package/src/mixins/alimtalk.ts +35 -0
  38. package/src/mixins/auth.ts +287 -0
  39. package/src/mixins/email.ts +46 -0
  40. package/src/mixins/entity.ts +205 -0
  41. package/src/mixins/file.ts +99 -0
  42. package/src/mixins/identity.ts +35 -0
  43. package/src/mixins/pg.ts +58 -0
  44. package/src/mixins/push.ts +132 -0
  45. package/src/mixins/sms.ts +46 -0
  46. package/src/mixins/smtp.ts +20 -0
  47. package/src/mixins/utils.ts +75 -0
  48. package/src/types.ts +388 -0
@@ -0,0 +1,119 @@
1
+ import type { EntityHistoryRecord, EntityListParams, EntityListResult, EntityQueryRequest } from "../types";
2
+ import type { GConstructor, EntityServerClientBase } from "../client/base";
3
+ export declare function EntityMixin<TBase extends GConstructor<EntityServerClientBase>>(Base: TBase): {
4
+ new (...args: any[]): {
5
+ /** 트랜잭션을 시작하고 활성 트랜잭션 ID를 저장합니다. */
6
+ transStart(): Promise<string>;
7
+ /** 활성 트랜잭션(또는 전달된 transactionId)을 롤백합니다. */
8
+ transRollback(transactionId?: string): Promise<{
9
+ ok: boolean;
10
+ }>;
11
+ /**
12
+ * 활성 트랜잭션(또는 전달된 transactionId)을 커밋합니다.
13
+ *
14
+ * @returns `results` 배열: commit된 각 작업의 `entity`, `action`, `seq`
15
+ */
16
+ transCommit(transactionId?: string): Promise<{
17
+ ok: boolean;
18
+ results: Array<{
19
+ entity: string;
20
+ action: string;
21
+ seq: number;
22
+ }>;
23
+ }>;
24
+ /** 시퀀스 ID로 엔티티 단건을 조회합니다. */
25
+ get<T = unknown>(entity: string, seq: number, opts?: {
26
+ skipHooks?: boolean;
27
+ }): Promise<{
28
+ ok: boolean;
29
+ data: T;
30
+ }>;
31
+ /** 조건으로 엔티티 단건을 조회합니다. data 컬럼을 완전히 복호화하여 반환합니다. */
32
+ find<T = unknown>(entity: string, conditions?: Record<string, unknown>, opts?: {
33
+ skipHooks?: boolean;
34
+ }): Promise<{
35
+ ok: boolean;
36
+ data: T;
37
+ }>;
38
+ /** 페이지네이션/정렬/필터 조건으로 엔티티 목록을 조회합니다. */
39
+ list<T = unknown>(entity: string, params?: EntityListParams): Promise<{
40
+ ok: boolean;
41
+ data: EntityListResult<T>;
42
+ }>;
43
+ /**
44
+ * 엔티티 총 건수를 조회합니다.
45
+ *
46
+ * @param conditions 필터 조건 (예: `{ status: "active" }`)
47
+ */
48
+ count(entity: string, conditions?: Record<string, unknown>): Promise<{
49
+ ok: boolean;
50
+ count: number;
51
+ }>;
52
+ /**
53
+ * 커스텀 SQL로 엔티티를 조회합니다.
54
+ *
55
+ * SELECT 전용이며 인덱스 테이블만 조회 가능합니다. JOIN 지원.
56
+ */
57
+ query<T = unknown>(entity: string, req: EntityQueryRequest): Promise<{
58
+ ok: boolean;
59
+ data: {
60
+ items: T[];
61
+ count: number;
62
+ };
63
+ }>;
64
+ /** 엔티티 데이터를 생성/수정(Submit)합니다. `seq`가 없으면 INSERT, 있으면 UPDATE입니다. */
65
+ submit(entity: string, data: Record<string, unknown>, opts?: {
66
+ transactionId?: string;
67
+ skipHooks?: boolean;
68
+ }): Promise<{
69
+ ok: boolean;
70
+ seq: number;
71
+ }>;
72
+ /** 시퀀스 ID로 엔티티를 삭제합니다(`hard=true`면 하드 삭제, 기본은 소프트 삭제). */
73
+ delete(entity: string, seq: number, opts?: {
74
+ transactionId?: string;
75
+ hard?: boolean;
76
+ skipHooks?: boolean;
77
+ }): Promise<{
78
+ ok: boolean;
79
+ deleted: number;
80
+ }>;
81
+ /** 엔티티 단건의 변경 이력을 조회합니다. */
82
+ history<T = unknown>(entity: string, seq: number, params?: Pick<EntityListParams, "page" | "limit">): Promise<{
83
+ ok: boolean;
84
+ data: EntityListResult<EntityHistoryRecord<T>>;
85
+ }>;
86
+ /** 특정 이력 시점으로 엔티티를 롤백합니다. */
87
+ rollback(entity: string, historySeq: number): Promise<{
88
+ ok: boolean;
89
+ }>;
90
+ baseUrl: string;
91
+ token: string;
92
+ apiKey: string;
93
+ hmacSecret: string;
94
+ encryptRequests: boolean;
95
+ activeTxId: string | null;
96
+ keepSession: boolean;
97
+ refreshBuffer: number;
98
+ onTokenRefreshed?: (accessToken: string, expiresIn: number) => void;
99
+ onSessionExpired?: (error: Error) => void;
100
+ _sessionRefreshToken: string | null;
101
+ _refreshTimer: ReturnType<typeof setTimeout> | null;
102
+ configure(options: Partial<import("..").EntityServerClientOptions>): void;
103
+ setToken(token: string): void;
104
+ setApiKey(apiKey: string): void;
105
+ setHmacSecret(secret: string): void;
106
+ setEncryptRequests(value: boolean): void;
107
+ _scheduleKeepSession(refreshToken: string, expiresIn: number, refreshFn: (rt: string) => Promise<{
108
+ access_token: string;
109
+ expires_in: number;
110
+ }>): void;
111
+ _clearRefreshTimer(): void;
112
+ stopKeepSession(): void;
113
+ readRequestBody<T = Record<string, unknown>>(body: ArrayBuffer | Uint8Array | string | T | null | undefined, contentType?: string, requireEncrypted?: boolean): T;
114
+ get _reqOpts(): import("../client/request").RequestOptions;
115
+ _request<T>(method: string, path: string, body?: unknown, withAuth?: boolean, extraHeaders?: Record<string, string>): Promise<T>;
116
+ _requestBinary(method: string, path: string, body?: unknown, withAuth?: boolean): Promise<ArrayBuffer>;
117
+ _requestForm<T>(method: string, path: string, form: FormData, withAuth?: boolean): Promise<T>;
118
+ };
119
+ } & TBase;
@@ -0,0 +1,78 @@
1
+ import type { FileMeta, FileUploadOptions } from "../types";
2
+ import type { GConstructor, EntityServerClientBase } from "../client/base";
3
+ export declare function FileMixin<TBase extends GConstructor<EntityServerClientBase>>(Base: TBase): {
4
+ new (...args: any[]): {
5
+ /**
6
+ * 파일을 업로드합니다. (multipart/form-data)
7
+ *
8
+ * ```ts
9
+ * const input = document.querySelector('input[type="file"]');
10
+ * const result = await client.fileUpload("product", input.files[0]);
11
+ * console.log(result.data.uuid);
12
+ * ```
13
+ */
14
+ fileUpload(entity: string, file: File | Blob, opts?: FileUploadOptions): Promise<{
15
+ ok: boolean;
16
+ uuid: string;
17
+ data: FileMeta;
18
+ }>;
19
+ /** 파일을 다운로드합니다. `ArrayBuffer`를 반환합니다. */
20
+ fileDownload(entity: string, uuid: string): Promise<ArrayBuffer>;
21
+ /** 파일을 삭제합니다. */
22
+ fileDelete(entity: string, uuid: string): Promise<{
23
+ ok: boolean;
24
+ uuid: string;
25
+ deleted: boolean;
26
+ }>;
27
+ /** 엔티티에 연결된 파일 목록을 조회합니다. */
28
+ fileList(entity: string, opts?: {
29
+ refSeq?: number;
30
+ }): Promise<{
31
+ ok: boolean;
32
+ data: {
33
+ items: FileMeta[];
34
+ total: number;
35
+ };
36
+ }>;
37
+ /** 파일 메타 정보를 조회합니다. */
38
+ fileMeta(entity: string, uuid: string): Promise<{
39
+ ok: boolean;
40
+ data: FileMeta;
41
+ }>;
42
+ /** 임시 파일 접근 토큰을 발급합니다. */
43
+ fileToken(uuid: string): Promise<{
44
+ ok: boolean;
45
+ token: string;
46
+ }>;
47
+ /** 파일 인라인 뷰 URL을 반환합니다. (fetch 없음, URL 조합만) */
48
+ fileUrl(uuid: string): string;
49
+ baseUrl: string;
50
+ token: string;
51
+ apiKey: string;
52
+ hmacSecret: string;
53
+ encryptRequests: boolean;
54
+ activeTxId: string | null;
55
+ keepSession: boolean;
56
+ refreshBuffer: number;
57
+ onTokenRefreshed?: (accessToken: string, expiresIn: number) => void;
58
+ onSessionExpired?: (error: Error) => void;
59
+ _sessionRefreshToken: string | null;
60
+ _refreshTimer: ReturnType<typeof setTimeout> | null;
61
+ configure(options: Partial<import("..").EntityServerClientOptions>): void;
62
+ setToken(token: string): void;
63
+ setApiKey(apiKey: string): void;
64
+ setHmacSecret(secret: string): void;
65
+ setEncryptRequests(value: boolean): void;
66
+ _scheduleKeepSession(refreshToken: string, expiresIn: number, refreshFn: (rt: string) => Promise<{
67
+ access_token: string;
68
+ expires_in: number;
69
+ }>): void;
70
+ _clearRefreshTimer(): void;
71
+ stopKeepSession(): void;
72
+ readRequestBody<T = Record<string, unknown>>(body: ArrayBuffer | Uint8Array | string | T | null | undefined, contentType?: string, requireEncrypted?: boolean): T;
73
+ get _reqOpts(): import("../client/request").RequestOptions;
74
+ _request<T>(method: string, path: string, body?: unknown, withAuth?: boolean, extraHeaders?: Record<string, string>): Promise<T>;
75
+ _requestBinary(method: string, path: string, body?: unknown, withAuth?: boolean): Promise<ArrayBuffer>;
76
+ _requestForm<T>(method: string, path: string, form: FormData, withAuth?: boolean): Promise<T>;
77
+ };
78
+ } & TBase;
@@ -0,0 +1,52 @@
1
+ import type { IdentityRequestOptions } from "../types";
2
+ import type { GConstructor, EntityServerClientBase } from "../client/base";
3
+ export declare function IdentityMixin<TBase extends GConstructor<EntityServerClientBase>>(Base: TBase): {
4
+ new (...args: any[]): {
5
+ /** 본인인증 요청을 생성합니다. */
6
+ identityRequest(opts: IdentityRequestOptions): Promise<{
7
+ ok: boolean;
8
+ data: Record<string, unknown>;
9
+ }>;
10
+ /** 본인인증 결과를 조회합니다. */
11
+ identityResult(requestId: string): Promise<{
12
+ ok: boolean;
13
+ data: Record<string, unknown>;
14
+ }>;
15
+ /** CI 해시 중복 여부를 확인합니다. */
16
+ identityVerifyCI(ciHash: string): Promise<{
17
+ ok: boolean;
18
+ data: {
19
+ exists: boolean;
20
+ account_seq?: number;
21
+ };
22
+ }>;
23
+ baseUrl: string;
24
+ token: string;
25
+ apiKey: string;
26
+ hmacSecret: string;
27
+ encryptRequests: boolean;
28
+ activeTxId: string | null;
29
+ keepSession: boolean;
30
+ refreshBuffer: number;
31
+ onTokenRefreshed?: (accessToken: string, expiresIn: number) => void;
32
+ onSessionExpired?: (error: Error) => void;
33
+ _sessionRefreshToken: string | null;
34
+ _refreshTimer: ReturnType<typeof setTimeout> | null;
35
+ configure(options: Partial<import("..").EntityServerClientOptions>): void;
36
+ setToken(token: string): void;
37
+ setApiKey(apiKey: string): void;
38
+ setHmacSecret(secret: string): void;
39
+ setEncryptRequests(value: boolean): void;
40
+ _scheduleKeepSession(refreshToken: string, expiresIn: number, refreshFn: (rt: string) => Promise<{
41
+ access_token: string;
42
+ expires_in: number;
43
+ }>): void;
44
+ _clearRefreshTimer(): void;
45
+ stopKeepSession(): void;
46
+ readRequestBody<T = Record<string, unknown>>(body: ArrayBuffer | Uint8Array | string | T | null | undefined, contentType?: string, requireEncrypted?: boolean): T;
47
+ get _reqOpts(): import("../client/request").RequestOptions;
48
+ _request<T>(method: string, path: string, body?: unknown, withAuth?: boolean, extraHeaders?: Record<string, string>): Promise<T>;
49
+ _requestBinary(method: string, path: string, body?: unknown, withAuth?: boolean): Promise<ArrayBuffer>;
50
+ _requestForm<T>(method: string, path: string, form: FormData, withAuth?: boolean): Promise<T>;
51
+ };
52
+ } & TBase;
@@ -0,0 +1,63 @@
1
+ import type { PgCreateOrderRequest, PgConfirmPaymentRequest, PgCancelPaymentRequest } from "../types";
2
+ import type { GConstructor, EntityServerClientBase } from "../client/base";
3
+ export declare function PgMixin<TBase extends GConstructor<EntityServerClientBase>>(Base: TBase): {
4
+ new (...args: any[]): {
5
+ /** 결제 주문을 생성합니다. */
6
+ pgCreateOrder(req: PgCreateOrderRequest): Promise<{
7
+ ok: boolean;
8
+ data: Record<string, unknown>;
9
+ }>;
10
+ /** 주문 정보를 조회합니다. */
11
+ pgGetOrder(orderId: string): Promise<{
12
+ ok: boolean;
13
+ data: Record<string, unknown>;
14
+ }>;
15
+ /** 결제를 승인합니다. */
16
+ pgConfirmPayment(req: PgConfirmPaymentRequest): Promise<{
17
+ ok: boolean;
18
+ data: Record<string, unknown>;
19
+ }>;
20
+ /** 결제를 취소합니다. */
21
+ pgCancelPayment(orderId: string, req: PgCancelPaymentRequest): Promise<{
22
+ ok: boolean;
23
+ data: Record<string, unknown>;
24
+ }>;
25
+ /** 결제 상태를 외부 PG와 동기화합니다. */
26
+ pgSyncPayment(orderId: string): Promise<{
27
+ ok: boolean;
28
+ }>;
29
+ /** 클라이언트 SDK 설정을 반환합니다 (공개 API, 인증 불필요). */
30
+ pgConfig(): Promise<{
31
+ ok: boolean;
32
+ data: Record<string, unknown>;
33
+ }>;
34
+ baseUrl: string;
35
+ token: string;
36
+ apiKey: string;
37
+ hmacSecret: string;
38
+ encryptRequests: boolean;
39
+ activeTxId: string | null;
40
+ keepSession: boolean;
41
+ refreshBuffer: number;
42
+ onTokenRefreshed?: (accessToken: string, expiresIn: number) => void;
43
+ onSessionExpired?: (error: Error) => void;
44
+ _sessionRefreshToken: string | null;
45
+ _refreshTimer: ReturnType<typeof setTimeout> | null;
46
+ configure(options: Partial<import("..").EntityServerClientOptions>): void;
47
+ setToken(token: string): void;
48
+ setApiKey(apiKey: string): void;
49
+ setHmacSecret(secret: string): void;
50
+ setEncryptRequests(value: boolean): void;
51
+ _scheduleKeepSession(refreshToken: string, expiresIn: number, refreshFn: (rt: string) => Promise<{
52
+ access_token: string;
53
+ expires_in: number;
54
+ }>): void;
55
+ _clearRefreshTimer(): void;
56
+ stopKeepSession(): void;
57
+ readRequestBody<T = Record<string, unknown>>(body: ArrayBuffer | Uint8Array | string | T | null | undefined, contentType?: string, requireEncrypted?: boolean): T;
58
+ get _reqOpts(): import("../client/request").RequestOptions;
59
+ _request<T>(method: string, path: string, body?: unknown, withAuth?: boolean, extraHeaders?: Record<string, string>): Promise<T>;
60
+ _requestBinary(method: string, path: string, body?: unknown, withAuth?: boolean): Promise<ArrayBuffer>;
61
+ _requestForm<T>(method: string, path: string, form: FormData, withAuth?: boolean): Promise<T>;
62
+ };
63
+ } & TBase;
@@ -0,0 +1,110 @@
1
+ import type { EntityListParams, EntityListResult, RegisterPushDeviceOptions, PushSendRequest, PushSendAllRequest } from "../types";
2
+ import type { GConstructor, EntityServerClientBase } from "../client/base";
3
+ type WithSubmit = EntityServerClientBase & {
4
+ submit(entity: string, data: Record<string, unknown>, opts?: {
5
+ transactionId?: string;
6
+ skipHooks?: boolean;
7
+ }): Promise<{
8
+ ok: boolean;
9
+ seq: number;
10
+ }>;
11
+ list<T = unknown>(entity: string, params?: EntityListParams): Promise<{
12
+ ok: boolean;
13
+ data: EntityListResult<T>;
14
+ }>;
15
+ };
16
+ export declare function PushMixin<TBase extends GConstructor<WithSubmit>>(Base: TBase): {
17
+ new (...args: any[]): {
18
+ /**
19
+ * 푸시 관련 엔티티로 payload를 전송(Submit)합니다.
20
+ * 내부적으로 `submit()` 메서드를 호출합니다.
21
+ */
22
+ push(pushEntity: string, payload: Record<string, unknown>, opts?: {
23
+ transactionId?: string;
24
+ }): Promise<{
25
+ ok: boolean;
26
+ seq: number;
27
+ }>;
28
+ /** 푸시 로그 엔티티 목록을 조회합니다. */
29
+ pushLogList<T = unknown>(params?: EntityListParams): Promise<{
30
+ ok: boolean;
31
+ data: EntityListResult<T>;
32
+ }>;
33
+ /** 계정의 푸시 디바이스를 등록합니다. */
34
+ registerPushDevice(accountSeq: number, deviceId: string, pushToken: string, opts?: RegisterPushDeviceOptions): Promise<{
35
+ ok: boolean;
36
+ seq: number;
37
+ }>;
38
+ /** 디바이스 레코드의 푸시 토큰을 갱신합니다. */
39
+ updatePushDeviceToken(deviceSeq: number, pushToken: string, opts?: {
40
+ pushEnabled?: boolean;
41
+ transactionId?: string;
42
+ }): Promise<{
43
+ ok: boolean;
44
+ seq: number;
45
+ }>;
46
+ /** 디바이스의 푸시 수신을 비활성화합니다. */
47
+ disablePushDevice(deviceSeq: number, opts?: {
48
+ transactionId?: string;
49
+ }): Promise<{
50
+ ok: boolean;
51
+ seq: number;
52
+ }>;
53
+ /** 특정 계정에 푸시 알림을 발송합니다. */
54
+ pushSend(req: PushSendRequest): Promise<{
55
+ ok: boolean;
56
+ seq: number;
57
+ }>;
58
+ /** 전체 사용자에게 푸시 알림을 발송합니다. */
59
+ pushSendAll(req: PushSendAllRequest): Promise<{
60
+ ok: boolean;
61
+ sent: number;
62
+ failed: number;
63
+ }>;
64
+ /** 푸시 발송 상태를 조회합니다. */
65
+ pushStatus(seq: number): Promise<{
66
+ ok: boolean;
67
+ status: string;
68
+ }>;
69
+ baseUrl: string;
70
+ token: string;
71
+ apiKey: string;
72
+ hmacSecret: string;
73
+ encryptRequests: boolean;
74
+ activeTxId: string | null;
75
+ keepSession: boolean;
76
+ refreshBuffer: number;
77
+ onTokenRefreshed?: (accessToken: string, expiresIn: number) => void;
78
+ onSessionExpired?: (error: Error) => void;
79
+ _sessionRefreshToken: string | null;
80
+ _refreshTimer: ReturnType<typeof setTimeout> | null;
81
+ configure(options: Partial<import("..").EntityServerClientOptions>): void;
82
+ setToken(token: string): void;
83
+ setApiKey(apiKey: string): void;
84
+ setHmacSecret(secret: string): void;
85
+ setEncryptRequests(value: boolean): void;
86
+ _scheduleKeepSession(refreshToken: string, expiresIn: number, refreshFn: (rt: string) => Promise<{
87
+ access_token: string;
88
+ expires_in: number;
89
+ }>): void;
90
+ _clearRefreshTimer(): void;
91
+ stopKeepSession(): void;
92
+ readRequestBody<T = Record<string, unknown>>(body: ArrayBuffer | Uint8Array | string | T | null | undefined, contentType?: string, requireEncrypted?: boolean): T;
93
+ get _reqOpts(): import("../client/request").RequestOptions;
94
+ _request<T>(method: string, path: string, body?: unknown, withAuth?: boolean, extraHeaders?: Record<string, string>): Promise<T>;
95
+ _requestBinary(method: string, path: string, body?: unknown, withAuth?: boolean): Promise<ArrayBuffer>;
96
+ _requestForm<T>(method: string, path: string, form: FormData, withAuth?: boolean): Promise<T>;
97
+ submit(entity: string, data: Record<string, unknown>, opts?: {
98
+ transactionId?: string;
99
+ skipHooks?: boolean;
100
+ }): Promise<{
101
+ ok: boolean;
102
+ seq: number;
103
+ }>;
104
+ list<T = unknown>(entity: string, params?: EntityListParams): Promise<{
105
+ ok: boolean;
106
+ data: EntityListResult<T>;
107
+ }>;
108
+ };
109
+ } & TBase;
110
+ export {};
@@ -0,0 +1,55 @@
1
+ import type { SmsSendRequest } from "../types";
2
+ import type { GConstructor, EntityServerClientBase } from "../client/base";
3
+ export declare function SmsMixin<TBase extends GConstructor<EntityServerClientBase>>(Base: TBase): {
4
+ new (...args: any[]): {
5
+ /** SMS를 발송합니다. */
6
+ smsSend(req: SmsSendRequest): Promise<{
7
+ ok: boolean;
8
+ seq: number;
9
+ }>;
10
+ /** SMS 발송 상태를 조회합니다. */
11
+ smsStatus(seq: number): Promise<{
12
+ ok: boolean;
13
+ status: string;
14
+ }>;
15
+ /** SMS 인증 코드를 발송합니다. */
16
+ smsVerificationSend(phone: string, opts?: {
17
+ purpose?: string;
18
+ }): Promise<{
19
+ ok: boolean;
20
+ }>;
21
+ /** SMS 인증 코드를 검증합니다. */
22
+ smsVerificationVerify(phone: string, code: string): Promise<{
23
+ ok: boolean;
24
+ verified: boolean;
25
+ }>;
26
+ baseUrl: string;
27
+ token: string;
28
+ apiKey: string;
29
+ hmacSecret: string;
30
+ encryptRequests: boolean;
31
+ activeTxId: string | null;
32
+ keepSession: boolean;
33
+ refreshBuffer: number;
34
+ onTokenRefreshed?: (accessToken: string, expiresIn: number) => void;
35
+ onSessionExpired?: (error: Error) => void;
36
+ _sessionRefreshToken: string | null;
37
+ _refreshTimer: ReturnType<typeof setTimeout> | null;
38
+ configure(options: Partial<import("..").EntityServerClientOptions>): void;
39
+ setToken(token: string): void;
40
+ setApiKey(apiKey: string): void;
41
+ setHmacSecret(secret: string): void;
42
+ setEncryptRequests(value: boolean): void;
43
+ _scheduleKeepSession(refreshToken: string, expiresIn: number, refreshFn: (rt: string) => Promise<{
44
+ access_token: string;
45
+ expires_in: number;
46
+ }>): void;
47
+ _clearRefreshTimer(): void;
48
+ stopKeepSession(): void;
49
+ readRequestBody<T = Record<string, unknown>>(body: ArrayBuffer | Uint8Array | string | T | null | undefined, contentType?: string, requireEncrypted?: boolean): T;
50
+ get _reqOpts(): import("../client/request").RequestOptions;
51
+ _request<T>(method: string, path: string, body?: unknown, withAuth?: boolean, extraHeaders?: Record<string, string>): Promise<T>;
52
+ _requestBinary(method: string, path: string, body?: unknown, withAuth?: boolean): Promise<ArrayBuffer>;
53
+ _requestForm<T>(method: string, path: string, form: FormData, withAuth?: boolean): Promise<T>;
54
+ };
55
+ } & TBase;
@@ -0,0 +1,44 @@
1
+ import type { SmtpSendRequest } from "../types";
2
+ import type { GConstructor, EntityServerClientBase } from "../client/base";
3
+ export declare function SmtpMixin<TBase extends GConstructor<EntityServerClientBase>>(Base: TBase): {
4
+ new (...args: any[]): {
5
+ /** SMTP로 메일을 발송합니다. */
6
+ smtpSend(req: SmtpSendRequest): Promise<{
7
+ ok: boolean;
8
+ seq: number;
9
+ }>;
10
+ /** SMTP 발송 상태를 조회합니다. */
11
+ smtpStatus(seq: number): Promise<{
12
+ ok: boolean;
13
+ status: string;
14
+ }>;
15
+ baseUrl: string;
16
+ token: string;
17
+ apiKey: string;
18
+ hmacSecret: string;
19
+ encryptRequests: boolean;
20
+ activeTxId: string | null;
21
+ keepSession: boolean;
22
+ refreshBuffer: number;
23
+ onTokenRefreshed?: (accessToken: string, expiresIn: number) => void;
24
+ onSessionExpired?: (error: Error) => void;
25
+ _sessionRefreshToken: string | null;
26
+ _refreshTimer: ReturnType<typeof setTimeout> | null;
27
+ configure(options: Partial<import("..").EntityServerClientOptions>): void;
28
+ setToken(token: string): void;
29
+ setApiKey(apiKey: string): void;
30
+ setHmacSecret(secret: string): void;
31
+ setEncryptRequests(value: boolean): void;
32
+ _scheduleKeepSession(refreshToken: string, expiresIn: number, refreshFn: (rt: string) => Promise<{
33
+ access_token: string;
34
+ expires_in: number;
35
+ }>): void;
36
+ _clearRefreshTimer(): void;
37
+ stopKeepSession(): void;
38
+ readRequestBody<T = Record<string, unknown>>(body: ArrayBuffer | Uint8Array | string | T | null | undefined, contentType?: string, requireEncrypted?: boolean): T;
39
+ get _reqOpts(): import("../client/request").RequestOptions;
40
+ _request<T>(method: string, path: string, body?: unknown, withAuth?: boolean, extraHeaders?: Record<string, string>): Promise<T>;
41
+ _requestBinary(method: string, path: string, body?: unknown, withAuth?: boolean): Promise<ArrayBuffer>;
42
+ _requestForm<T>(method: string, path: string, form: FormData, withAuth?: boolean): Promise<T>;
43
+ };
44
+ } & TBase;
@@ -0,0 +1,70 @@
1
+ import type { QRCodeOptions, BarcodeOptions } from "../types";
2
+ import type { GConstructor, EntityServerClientBase } from "../client/base";
3
+ export declare function UtilsMixin<TBase extends GConstructor<EntityServerClientBase>>(Base: TBase): {
4
+ new (...args: any[]): {
5
+ /**
6
+ * QR 코드 PNG를 생성합니다. `ArrayBuffer`를 반환합니다.
7
+ *
8
+ * ```ts
9
+ * const buf = await client.qrcode("https://example.com");
10
+ * const blob = new Blob([buf], { type: "image/png" });
11
+ * img.src = URL.createObjectURL(blob);
12
+ * ```
13
+ */
14
+ qrcode(content: string, opts?: QRCodeOptions): Promise<ArrayBuffer>;
15
+ /**
16
+ * QR 코드를 base64/data URI JSON으로 반환합니다.
17
+ *
18
+ * ```ts
19
+ * const { data_uri } = await client.qrcodeBase64("https://example.com");
20
+ * img.src = data_uri;
21
+ * ```
22
+ */
23
+ qrcodeBase64(content: string, opts?: QRCodeOptions): Promise<{
24
+ ok: boolean;
25
+ data: string;
26
+ data_uri: string;
27
+ }>;
28
+ /** QR 코드를 ASCII 아트 텍스트로 반환합니다. */
29
+ qrcodeText(content: string, opts?: QRCodeOptions): Promise<{
30
+ ok: boolean;
31
+ text: string;
32
+ }>;
33
+ /**
34
+ * 바코드 PNG를 생성합니다. `ArrayBuffer`를 반환합니다.
35
+ *
36
+ * ```ts
37
+ * const buf = await client.barcode("1234567890128", { type: "ean13" });
38
+ * ```
39
+ */
40
+ barcode(content: string, opts?: BarcodeOptions): Promise<ArrayBuffer>;
41
+ baseUrl: string;
42
+ token: string;
43
+ apiKey: string;
44
+ hmacSecret: string;
45
+ encryptRequests: boolean;
46
+ activeTxId: string | null;
47
+ keepSession: boolean;
48
+ refreshBuffer: number;
49
+ onTokenRefreshed?: (accessToken: string, expiresIn: number) => void;
50
+ onSessionExpired?: (error: Error) => void;
51
+ _sessionRefreshToken: string | null;
52
+ _refreshTimer: ReturnType<typeof setTimeout> | null;
53
+ configure(options: Partial<import("..").EntityServerClientOptions>): void;
54
+ setToken(token: string): void;
55
+ setApiKey(apiKey: string): void;
56
+ setHmacSecret(secret: string): void;
57
+ setEncryptRequests(value: boolean): void;
58
+ _scheduleKeepSession(refreshToken: string, expiresIn: number, refreshFn: (rt: string) => Promise<{
59
+ access_token: string;
60
+ expires_in: number;
61
+ }>): void;
62
+ _clearRefreshTimer(): void;
63
+ stopKeepSession(): void;
64
+ readRequestBody<T = Record<string, unknown>>(body: ArrayBuffer | Uint8Array | string | T | null | undefined, contentType?: string, requireEncrypted?: boolean): T;
65
+ get _reqOpts(): import("../client/request").RequestOptions;
66
+ _request<T>(method: string, path: string, body?: unknown, withAuth?: boolean, extraHeaders?: Record<string, string>): Promise<T>;
67
+ _requestBinary(method: string, path: string, body?: unknown, withAuth?: boolean): Promise<ArrayBuffer>;
68
+ _requestForm<T>(method: string, path: string, form: FormData, withAuth?: boolean): Promise<T>;
69
+ };
70
+ } & TBase;