entity-client 1.0.7 → 1.0.8

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 (133) hide show
  1. package/README.md +362 -0
  2. package/dist/EntityAppServerApi.d.ts +1080 -0
  3. package/dist/EntityAppServerApi.js +2 -0
  4. package/dist/EntityAppServerApi.js.map +7 -0
  5. package/dist/{EntityServerClient.d.ts → EntityServerApi.d.ts} +114 -20
  6. package/dist/EntityServerApi.js +2 -0
  7. package/dist/EntityServerApi.js.map +7 -0
  8. package/dist/client/base.d.ts +13 -4
  9. package/dist/client/base.js +1 -1
  10. package/dist/client/base.js.map +3 -3
  11. package/dist/hooks/useEntityAppServer.d.ts +18 -0
  12. package/dist/hooks/useEntityAppServer.js +2 -0
  13. package/dist/hooks/useEntityAppServer.js.map +7 -0
  14. package/dist/hooks/useEntityClient.d.ts +74 -0
  15. package/dist/hooks/useEntityClient.js +2 -0
  16. package/dist/hooks/useEntityClient.js.map +7 -0
  17. package/dist/hooks/useEntityServer.d.ts +5 -88
  18. package/dist/hooks/useEntityServer.js +1 -1
  19. package/dist/hooks/useEntityServer.js.map +3 -3
  20. package/dist/index.d.ts +6 -6
  21. package/dist/index.js +1 -1
  22. package/dist/index.js.map +4 -4
  23. package/dist/mixins/app/index.d.ts +6 -6
  24. package/dist/mixins/app/index.js +1 -1
  25. package/dist/mixins/app/index.js.map +2 -2
  26. package/dist/mixins/app/plugins/alimtalk.d.ts +68 -0
  27. package/dist/mixins/app/plugins/alimtalk.js +2 -0
  28. package/dist/mixins/app/plugins/alimtalk.js.map +7 -0
  29. package/dist/mixins/app/plugins/friendtalk.d.ts +62 -0
  30. package/dist/mixins/app/plugins/friendtalk.js +2 -0
  31. package/dist/mixins/app/plugins/friendtalk.js.map +7 -0
  32. package/dist/mixins/app/plugins/holidays.d.ts +70 -0
  33. package/dist/mixins/app/plugins/holidays.js +2 -0
  34. package/dist/mixins/app/plugins/holidays.js.map +7 -0
  35. package/dist/mixins/app/plugins/identity.d.ts +68 -0
  36. package/dist/mixins/app/plugins/identity.js +2 -0
  37. package/dist/mixins/app/plugins/identity.js.map +7 -0
  38. package/dist/mixins/app/plugins/index.d.ts +10 -0
  39. package/dist/mixins/app/plugins/index.js +2 -0
  40. package/dist/mixins/app/plugins/index.js.map +7 -0
  41. package/dist/mixins/app/plugins/llm.d.ts +130 -0
  42. package/dist/mixins/app/plugins/llm.js +2 -0
  43. package/dist/mixins/app/plugins/llm.js.map +7 -0
  44. package/dist/mixins/app/plugins/ocr.d.ts +76 -0
  45. package/dist/mixins/app/plugins/ocr.js +2 -0
  46. package/dist/mixins/app/plugins/ocr.js.map +7 -0
  47. package/dist/mixins/app/plugins/pg.d.ts +74 -0
  48. package/dist/mixins/app/plugins/pg.js +2 -0
  49. package/dist/mixins/app/plugins/pg.js.map +7 -0
  50. package/dist/mixins/app/plugins/push.d.ts +70 -0
  51. package/dist/mixins/app/plugins/push.js +2 -0
  52. package/dist/mixins/app/plugins/push.js.map +7 -0
  53. package/dist/mixins/app/plugins/sms.d.ts +68 -0
  54. package/dist/mixins/app/plugins/sms.js +2 -0
  55. package/dist/mixins/app/plugins/sms.js.map +7 -0
  56. package/dist/mixins/app/plugins/taxinvoice.d.ts +72 -0
  57. package/dist/mixins/app/plugins/taxinvoice.js +2 -0
  58. package/dist/mixins/app/plugins/taxinvoice.js.map +7 -0
  59. package/dist/mixins/app/{account.d.ts → routes/account.d.ts} +11 -5
  60. package/dist/mixins/app/routes/account.js +2 -0
  61. package/dist/mixins/app/routes/account.js.map +7 -0
  62. package/dist/mixins/app/{board.d.ts → routes/board.d.ts} +11 -5
  63. package/dist/mixins/app/routes/board.js +2 -0
  64. package/dist/mixins/app/routes/board.js.map +7 -0
  65. package/dist/mixins/app/{email-verify.d.ts → routes/email-verify.d.ts} +11 -5
  66. package/dist/mixins/app/routes/email-verify.js +2 -0
  67. package/dist/mixins/app/routes/email-verify.js.map +7 -0
  68. package/dist/mixins/app/{oauth.d.ts → routes/oauth.d.ts} +11 -5
  69. package/dist/mixins/app/routes/oauth.js +2 -0
  70. package/dist/mixins/app/routes/oauth.js.map +7 -0
  71. package/dist/mixins/app/{password-reset.d.ts → routes/password-reset.d.ts} +11 -5
  72. package/dist/mixins/app/routes/password-reset.js +2 -0
  73. package/dist/mixins/app/routes/password-reset.js.map +7 -0
  74. package/dist/mixins/app/{two-factor.d.ts → routes/two-factor.d.ts} +11 -5
  75. package/dist/mixins/app/routes/two-factor.js +2 -0
  76. package/dist/mixins/app/routes/two-factor.js.map +7 -0
  77. package/dist/mixins/server/admin.d.ts +7 -1
  78. package/dist/mixins/server/admin.js +1 -1
  79. package/dist/mixins/server/admin.js.map +2 -2
  80. package/dist/mixins/{auth.d.ts → server/auth.d.ts} +12 -20
  81. package/dist/mixins/{auth.js → server/auth.js} +1 -1
  82. package/dist/mixins/server/auth.js.map +7 -0
  83. package/dist/mixins/{entity.d.ts → server/entity.d.ts} +12 -6
  84. package/dist/mixins/server/entity.js +2 -0
  85. package/dist/mixins/server/entity.js.map +7 -0
  86. package/dist/mixins/{file.d.ts → server/file.d.ts} +12 -6
  87. package/dist/mixins/server/file.js.map +7 -0
  88. package/dist/mixins/server/index.d.ts +7 -6
  89. package/dist/mixins/server/index.js +1 -1
  90. package/dist/mixins/server/index.js.map +3 -3
  91. package/dist/mixins/{push.d.ts → server/push.d.ts} +12 -6
  92. package/dist/mixins/server/push.js.map +7 -0
  93. package/dist/mixins/{smtp.d.ts → server/smtp.d.ts} +14 -6
  94. package/dist/mixins/server/smtp.js +2 -0
  95. package/dist/mixins/server/smtp.js.map +7 -0
  96. package/dist/mixins/server/transaction.d.ts +66 -0
  97. package/dist/mixins/server/transaction.js +2 -0
  98. package/dist/mixins/server/transaction.js.map +7 -0
  99. package/dist/mixins/{utils.d.ts → server/utils.d.ts} +12 -6
  100. package/dist/mixins/server/utils.js +2 -0
  101. package/dist/mixins/server/utils.js.map +7 -0
  102. package/dist/react.d.ts +2 -0
  103. package/dist/react.js +1 -1
  104. package/dist/react.js.map +4 -4
  105. package/package.json +2 -2
  106. package/dist/EntityAppServerClient.d.ts +0 -383
  107. package/dist/EntityAppServerClient.js +0 -2
  108. package/dist/EntityAppServerClient.js.map +0 -7
  109. package/dist/EntityServerClient.js +0 -2
  110. package/dist/EntityServerClient.js.map +0 -7
  111. package/dist/mixins/app/account.js +0 -2
  112. package/dist/mixins/app/account.js.map +0 -7
  113. package/dist/mixins/app/board.js +0 -2
  114. package/dist/mixins/app/board.js.map +0 -7
  115. package/dist/mixins/app/email-verify.js +0 -2
  116. package/dist/mixins/app/email-verify.js.map +0 -7
  117. package/dist/mixins/app/oauth.js +0 -2
  118. package/dist/mixins/app/oauth.js.map +0 -7
  119. package/dist/mixins/app/password-reset.js +0 -2
  120. package/dist/mixins/app/password-reset.js.map +0 -7
  121. package/dist/mixins/app/two-factor.js +0 -2
  122. package/dist/mixins/app/two-factor.js.map +0 -7
  123. package/dist/mixins/auth.js.map +0 -7
  124. package/dist/mixins/entity.js +0 -2
  125. package/dist/mixins/entity.js.map +0 -7
  126. package/dist/mixins/file.js.map +0 -7
  127. package/dist/mixins/push.js.map +0 -7
  128. package/dist/mixins/smtp.js +0 -2
  129. package/dist/mixins/smtp.js.map +0 -7
  130. package/dist/mixins/utils.js +0 -2
  131. package/dist/mixins/utils.js.map +0 -7
  132. /package/dist/mixins/{file.js → server/file.js} +0 -0
  133. /package/dist/mixins/{push.js → server/push.js} +0 -0
@@ -1,85 +1,10 @@
1
- import { EntityAppServerClient, EntityServerClient, type EntityQueryRequest, type EntityServerClientOptions } from "../index.js";
2
- export interface UseEntityServerOptions extends EntityServerClientOptions {
3
- singleton?: boolean;
4
- tokenResolver?: () => string | undefined | null;
5
- /**
6
- * 페이지 새로고침 후 로그인 상태를 복원할 때 사용합니다.
7
- * 이 값이 있으면 마운트 시 `client.refreshToken()`을 호출해 새 access_token을 발급받습니다.
8
- * `keepSession: true`와 함께 사용하면 세션 유지 타이머도 재시작됩니다.
9
- * 갱신 성공 시 `onTokenRefreshed` 콜백이 호출됩니다.
10
- */
11
- resumeSession?: string;
12
- }
13
- export interface UseEntityAppServerOptions extends UseEntityServerOptions {
14
- }
15
- type BaseClient = EntityServerClient | EntityAppServerClient;
16
- interface UseEntityClientResult<TClient extends BaseClient> {
17
- client: TClient;
18
- isPending: boolean;
19
- error: Error | null;
20
- reset: () => void;
21
- submit: (entity: string, data: Record<string, unknown>, opts?: {
22
- transactionId?: string;
23
- skipHooks?: boolean;
24
- }) => Promise<{
25
- ok: boolean;
26
- seq: number;
27
- }>;
28
- del: (entity: string, seq: number, opts?: {
29
- transactionId?: string;
30
- hard?: boolean;
31
- skipHooks?: boolean;
32
- }) => Promise<{
33
- ok: boolean;
34
- deleted: number;
35
- }>;
36
- query: <T = unknown>(entity: string, req: EntityQueryRequest) => Promise<{
37
- ok: boolean;
38
- data: {
39
- items: T[];
40
- count: number;
41
- };
42
- }>;
43
- }
44
- export interface UseEntityServerResult {
45
- /** EntityServerClient 인스턴스 (read 전용 메서드 직접 호출 시 사용) */
46
- client: EntityServerClient;
47
- /** submit 또는 delete 진행 중 여부 */
48
- isPending: boolean;
49
- /** 마지막 mutation 에러 (없으면 null) */
50
- error: Error | null;
51
- /** 에러·결과 상태 초기화 */
52
- reset: () => void;
53
- /** entity 데이터 생성/수정 (seq 없으면 INSERT, 있으면 UPDATE) */
54
- submit: (entity: string, data: Record<string, unknown>, opts?: {
55
- transactionId?: string;
56
- skipHooks?: boolean;
57
- }) => Promise<{
58
- ok: boolean;
59
- seq: number;
60
- }>;
61
- /** entity 데이터 삭제 */
62
- del: (entity: string, seq: number, opts?: {
63
- transactionId?: string;
64
- hard?: boolean;
65
- skipHooks?: boolean;
66
- }) => Promise<{
67
- ok: boolean;
68
- deleted: number;
69
- }>;
70
- /** 커스텀 SQL 조회 */
71
- query: <T = unknown>(entity: string, req: EntityQueryRequest) => Promise<{
72
- ok: boolean;
73
- data: {
74
- items: T[];
75
- count: number;
76
- };
77
- }>;
78
- }
79
- export interface UseEntityAppServerResult extends UseEntityClientResult<EntityAppServerClient> {
1
+ import { EntityServerApi } from "../index.js";
2
+ import { type UseEntityClientResult, type UseEntityServerOptions } from "./useEntityClient.js";
3
+ export type { UseEntityServerOptions };
4
+ export interface UseEntityServerResult extends UseEntityClientResult<EntityServerApi> {
80
5
  }
81
6
  /**
82
- * React 환경에서 EntityServerClient 인스턴스와 mutation 상태를 반환합니다.
7
+ * React 환경에서 EntityServerApi 인스턴스와 mutation 상태를 반환합니다.
83
8
  *
84
9
  * - `singleton=true`(기본): 패키지 전역 `entityServer` 인스턴스를 사용합니다.
85
10
  * - `singleton=false`: 컴포넌트 스코프의 새 인스턴스를 생성합니다.
@@ -94,11 +19,3 @@ export interface UseEntityAppServerResult extends UseEntityClientResult<EntityAp
94
19
  * ```
95
20
  */
96
21
  export declare function useEntityServer(options?: UseEntityServerOptions): UseEntityServerResult;
97
- /**
98
- * React 환경에서 EntityAppServerClient 인스턴스와 mutation 상태를 반환합니다.
99
- *
100
- * - `singleton=true`(기본): 패키지 전역 `entityAppServer` 인스턴스를 사용합니다.
101
- * - `singleton=false`: 컴포넌트 스코프의 새 인스턴스를 생성합니다.
102
- */
103
- export declare function useEntityAppServer(options?: UseEntityAppServerOptions): UseEntityAppServerResult;
104
- export {};
@@ -1,2 +1,2 @@
1
- import{useCallback as l,useEffect as E,useMemo as x,useRef as m,useState as b}from"react";import{EntityAppServerClient as P,EntityServerClient as w,entityAppServer as I,entityServer as A}from"../index.js";function f(i,u){const{singleton:a=!0,tokenResolver:d,baseUrl:c,token:y,resumeSession:v}=i,[k,p]=b(!1),[S,C]=b(null),o=m(!0);E(()=>(o.current=!0,()=>{o.current=!1}),[]);const n=x(()=>{const e=a?u.singletonInstance:new u.ClientClass({baseUrl:c,token:y});a&&e.configure({baseUrl:c,token:y});const t=d?.();return typeof t=="string"&&e.setToken(t),e},[a,d,c,y,u.ClientClass,u.singletonInstance]),g=m(v);E(()=>{const e=g.current;e&&n.refreshToken(e).catch(()=>{})},[n]);const r=l(async e=>{o.current&&(p(!0),C(null));try{return await e()}catch(t){const s=t instanceof Error?t:new Error(String(t));throw o.current&&C(s),s}finally{o.current&&p(!1)}},[]),T=l((e,t,s)=>r(()=>n.submit(e,t,s)),[n,r]),R=l((e,t,s)=>r(()=>n.delete(e,t,s)),[n,r]),U=l((e,t)=>r(()=>n.query(e,t)),[n,r]),q=l(()=>{p(!1),C(null)},[]);return{client:n,isPending:k,error:S,reset:q,submit:T,del:R,query:U}}function B(i={}){return f(i,{singletonInstance:A,ClientClass:w})}function H(i={}){return f(i,{singletonInstance:I,ClientClass:P})}export{H as useEntityAppServer,B as useEntityServer};
1
+ import{EntityServerApi as t,entityServer as n}from"../index.js";import{useEntityClient as r}from"./useEntityClient.js";function y(e={}){return r(e,{singletonInstance:n,ClientClass:t})}export{y as useEntityServer};
2
2
  //# sourceMappingURL=useEntityServer.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/hooks/useEntityServer.ts"],
4
- "sourcesContent": ["import { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport {\n EntityAppServerClient,\n EntityServerClient,\n entityAppServer,\n entityServer,\n type EntityQueryRequest,\n type EntityServerClientOptions,\n} from \"../index.js\";\n\nexport interface UseEntityServerOptions extends EntityServerClientOptions {\n singleton?: boolean;\n tokenResolver?: () => string | undefined | null;\n /**\n * \uD398\uC774\uC9C0 \uC0C8\uB85C\uACE0\uCE68 \uD6C4 \uB85C\uADF8\uC778 \uC0C1\uD0DC\uB97C \uBCF5\uC6D0\uD560 \uB54C \uC0AC\uC6A9\uD569\uB2C8\uB2E4.\n * \uC774 \uAC12\uC774 \uC788\uC73C\uBA74 \uB9C8\uC6B4\uD2B8 \uC2DC `client.refreshToken()`\uC744 \uD638\uCD9C\uD574 \uC0C8 access_token\uC744 \uBC1C\uAE09\uBC1B\uC2B5\uB2C8\uB2E4.\n * `keepSession: true`\uC640 \uD568\uAED8 \uC0AC\uC6A9\uD558\uBA74 \uC138\uC158 \uC720\uC9C0 \uD0C0\uC774\uBA38\uB3C4 \uC7AC\uC2DC\uC791\uB429\uB2C8\uB2E4.\n * \uAC31\uC2E0 \uC131\uACF5 \uC2DC `onTokenRefreshed` \uCF5C\uBC31\uC774 \uD638\uCD9C\uB429\uB2C8\uB2E4.\n */\n resumeSession?: string;\n}\n\nexport interface UseEntityAppServerOptions extends UseEntityServerOptions {}\n\ntype BaseClient = EntityServerClient | EntityAppServerClient;\n\ntype ClientConstructor<TClient extends BaseClient> = new (\n options?: EntityServerClientOptions,\n) => TClient;\n\ninterface UseEntityClientResult<TClient extends BaseClient> {\n client: TClient;\n isPending: boolean;\n error: Error | null;\n reset: () => void;\n submit: (\n entity: string,\n data: Record<string, unknown>,\n opts?: { transactionId?: string; skipHooks?: boolean },\n ) => Promise<{ ok: boolean; seq: number }>;\n del: (\n entity: string,\n seq: number,\n opts?: { transactionId?: string; hard?: boolean; skipHooks?: boolean },\n ) => Promise<{ ok: boolean; deleted: number }>;\n query: <T = unknown>(\n entity: string,\n req: EntityQueryRequest,\n ) => Promise<{ ok: boolean; data: { items: T[]; count: number } }>;\n}\n\nexport interface UseEntityServerResult {\n /** EntityServerClient \uC778\uC2A4\uD134\uC2A4 (read \uC804\uC6A9 \uBA54\uC11C\uB4DC \uC9C1\uC811 \uD638\uCD9C \uC2DC \uC0AC\uC6A9) */\n client: EntityServerClient;\n /** submit \uB610\uB294 delete \uC9C4\uD589 \uC911 \uC5EC\uBD80 */\n isPending: boolean;\n /** \uB9C8\uC9C0\uB9C9 mutation \uC5D0\uB7EC (\uC5C6\uC73C\uBA74 null) */\n error: Error | null;\n /** \uC5D0\uB7EC\u00B7\uACB0\uACFC \uC0C1\uD0DC \uCD08\uAE30\uD654 */\n reset: () => void;\n /** entity \uB370\uC774\uD130 \uC0DD\uC131/\uC218\uC815 (seq \uC5C6\uC73C\uBA74 INSERT, \uC788\uC73C\uBA74 UPDATE) */\n submit: (\n entity: string,\n data: Record<string, unknown>,\n opts?: { transactionId?: string; skipHooks?: boolean },\n ) => Promise<{ ok: boolean; seq: number }>;\n /** entity \uB370\uC774\uD130 \uC0AD\uC81C */\n del: (\n entity: string,\n seq: number,\n opts?: { transactionId?: string; hard?: boolean; skipHooks?: boolean },\n ) => Promise<{ ok: boolean; deleted: number }>;\n /** \uCEE4\uC2A4\uD140 SQL \uC870\uD68C */\n query: <T = unknown>(\n entity: string,\n req: EntityQueryRequest,\n ) => Promise<{ ok: boolean; data: { items: T[]; count: number } }>;\n}\n\nexport interface UseEntityAppServerResult extends UseEntityClientResult<EntityAppServerClient> {}\n\nfunction useEntityClient<TClient extends BaseClient>(\n options: UseEntityServerOptions,\n config: {\n singletonInstance: TClient;\n ClientClass: ClientConstructor<TClient>;\n },\n): UseEntityClientResult<TClient> {\n const {\n singleton = true,\n tokenResolver,\n baseUrl,\n token,\n resumeSession,\n } = options;\n\n const [isPending, setIsPending] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n\n const mountedRef = useRef(true);\n useEffect(() => {\n mountedRef.current = true;\n return () => {\n mountedRef.current = false;\n };\n }, []);\n\n const client = useMemo(() => {\n const instance = singleton\n ? config.singletonInstance\n : new config.ClientClass({ baseUrl, token });\n\n if (singleton) {\n instance.configure({ baseUrl, token });\n }\n\n const resolvedToken = tokenResolver?.();\n if (typeof resolvedToken === \"string\") {\n instance.setToken(resolvedToken);\n }\n\n return instance;\n }, [\n singleton,\n tokenResolver,\n baseUrl,\n token,\n config.ClientClass,\n config.singletonInstance,\n ]);\n\n const resumeTokenRef = useRef(resumeSession);\n useEffect(() => {\n const storedRefreshToken = resumeTokenRef.current;\n if (!storedRefreshToken) return;\n client.refreshToken(storedRefreshToken).catch(() => {\n // refresh_token \uB9CC\uB8CC \uB4F1 \u2014 onSessionExpired \uCF5C\uBC31\uC774 \uC774\uBBF8 \uCC98\uB9AC\n });\n }, [client]);\n\n const run = useCallback(async <T>(fn: () => Promise<T>): Promise<T> => {\n if (mountedRef.current) {\n setIsPending(true);\n setError(null);\n }\n try {\n const result = await fn();\n return result;\n } catch (err) {\n const wrapped = err instanceof Error ? err : new Error(String(err));\n if (mountedRef.current) setError(wrapped);\n throw wrapped;\n } finally {\n if (mountedRef.current) setIsPending(false);\n }\n }, []);\n\n const submit = useCallback<UseEntityClientResult<TClient>[\"submit\"]>(\n (entity, data, opts) => run(() => client.submit(entity, data, opts)),\n [client, run],\n );\n\n const del = useCallback<UseEntityClientResult<TClient>[\"del\"]>(\n (entity, seq, opts) => run(() => client.delete(entity, seq, opts)),\n [client, run],\n );\n\n const query = useCallback<UseEntityClientResult<TClient>[\"query\"]>(\n (entity, req) => run(() => client.query(entity, req)),\n [client, run],\n );\n\n const reset = useCallback(() => {\n setIsPending(false);\n setError(null);\n }, []);\n\n return { client, isPending, error, reset, submit, del, query };\n}\n\n/**\n * React \uD658\uACBD\uC5D0\uC11C EntityServerClient \uC778\uC2A4\uD134\uC2A4\uC640 mutation \uC0C1\uD0DC\uB97C \uBC18\uD658\uD569\uB2C8\uB2E4.\n *\n * - `singleton=true`(\uAE30\uBCF8): \uD328\uD0A4\uC9C0 \uC804\uC5ED `entityServer` \uC778\uC2A4\uD134\uC2A4\uB97C \uC0AC\uC6A9\uD569\uB2C8\uB2E4.\n * - `singleton=false`: \uCEF4\uD3EC\uB10C\uD2B8 \uC2A4\uCF54\uD504\uC758 \uC0C8 \uC778\uC2A4\uD134\uC2A4\uB97C \uC0DD\uC131\uD569\uB2C8\uB2E4.\n *\n * @example\n * ```tsx\n * const { submit, del, isPending, error, reset } = useEntityServer();\n *\n * const handleSave = async () => {\n * await submit(\"account\", { name: \"\uD64D\uAE38\uB3D9\" });\n * };\n * ```\n */\nexport function useEntityServer(\n options: UseEntityServerOptions = {},\n): UseEntityServerResult {\n return useEntityClient(options, {\n singletonInstance: entityServer,\n ClientClass: EntityServerClient,\n });\n}\n\n/**\n * React \uD658\uACBD\uC5D0\uC11C EntityAppServerClient \uC778\uC2A4\uD134\uC2A4\uC640 mutation \uC0C1\uD0DC\uB97C \uBC18\uD658\uD569\uB2C8\uB2E4.\n *\n * - `singleton=true`(\uAE30\uBCF8): \uD328\uD0A4\uC9C0 \uC804\uC5ED `entityAppServer` \uC778\uC2A4\uD134\uC2A4\uB97C \uC0AC\uC6A9\uD569\uB2C8\uB2E4.\n * - `singleton=false`: \uCEF4\uD3EC\uB10C\uD2B8 \uC2A4\uCF54\uD504\uC758 \uC0C8 \uC778\uC2A4\uD134\uC2A4\uB97C \uC0DD\uC131\uD569\uB2C8\uB2E4.\n */\nexport function useEntityAppServer(\n options: UseEntityAppServerOptions = {},\n): UseEntityAppServerResult {\n return useEntityClient(options, {\n singletonInstance: entityAppServer,\n ClientClass: EntityAppServerClient,\n });\n}\n"],
5
- "mappings": "AAAA,OAAS,eAAAA,EAAa,aAAAC,EAAW,WAAAC,EAAS,UAAAC,EAAQ,YAAAC,MAAgB,QAClE,OACI,yBAAAC,EACA,sBAAAC,EACA,mBAAAC,EACA,gBAAAC,MAGG,cAyEP,SAASC,EACLC,EACAC,EAI8B,CAC9B,KAAM,CACF,UAAAC,EAAY,GACZ,cAAAC,EACA,QAAAC,EACA,MAAAC,EACA,cAAAC,CACJ,EAAIN,EAEE,CAACO,EAAWC,CAAY,EAAId,EAAS,EAAK,EAC1C,CAACe,EAAOC,CAAQ,EAAIhB,EAAuB,IAAI,EAE/CiB,EAAalB,EAAO,EAAI,EAC9BF,EAAU,KACNoB,EAAW,QAAU,GACd,IAAM,CACTA,EAAW,QAAU,EACzB,GACD,CAAC,CAAC,EAEL,MAAMC,EAASpB,EAAQ,IAAM,CACzB,MAAMqB,EAAWX,EACXD,EAAO,kBACP,IAAIA,EAAO,YAAY,CAAE,QAAAG,EAAS,MAAAC,CAAM,CAAC,EAE3CH,GACAW,EAAS,UAAU,CAAE,QAAAT,EAAS,MAAAC,CAAM,CAAC,EAGzC,MAAMS,EAAgBX,IAAgB,EACtC,OAAI,OAAOW,GAAkB,UACzBD,EAAS,SAASC,CAAa,EAG5BD,CACX,EAAG,CACCX,EACAC,EACAC,EACAC,EACAJ,EAAO,YACPA,EAAO,iBACX,CAAC,EAEKc,EAAiBtB,EAAOa,CAAa,EAC3Cf,EAAU,IAAM,CACZ,MAAMyB,EAAqBD,EAAe,QACrCC,GACLJ,EAAO,aAAaI,CAAkB,EAAE,MAAM,IAAM,CAEpD,CAAC,CACL,EAAG,CAACJ,CAAM,CAAC,EAEX,MAAMK,EAAM3B,EAAY,MAAU4B,GAAqC,CAC/DP,EAAW,UACXH,EAAa,EAAI,EACjBE,EAAS,IAAI,GAEjB,GAAI,CAEA,OADe,MAAMQ,EAAG,CAE5B,OAASC,EAAK,CACV,MAAMC,EAAUD,aAAe,MAAQA,EAAM,IAAI,MAAM,OAAOA,CAAG,CAAC,EAClE,MAAIR,EAAW,SAASD,EAASU,CAAO,EAClCA,CACV,QAAE,CACMT,EAAW,SAASH,EAAa,EAAK,CAC9C,CACJ,EAAG,CAAC,CAAC,EAECa,EAAS/B,EACX,CAACgC,EAAQC,EAAMC,IAASP,EAAI,IAAML,EAAO,OAAOU,EAAQC,EAAMC,CAAI,CAAC,EACnE,CAACZ,EAAQK,CAAG,CAChB,EAEMQ,EAAMnC,EACR,CAACgC,EAAQI,EAAKF,IAASP,EAAI,IAAML,EAAO,OAAOU,EAAQI,EAAKF,CAAI,CAAC,EACjE,CAACZ,EAAQK,CAAG,CAChB,EAEMU,EAAQrC,EACV,CAACgC,EAAQM,IAAQX,EAAI,IAAML,EAAO,MAAMU,EAAQM,CAAG,CAAC,EACpD,CAAChB,EAAQK,CAAG,CAChB,EAEMY,EAAQvC,EAAY,IAAM,CAC5BkB,EAAa,EAAK,EAClBE,EAAS,IAAI,CACjB,EAAG,CAAC,CAAC,EAEL,MAAO,CAAE,OAAAE,EAAQ,UAAAL,EAAW,MAAAE,EAAO,MAAAoB,EAAO,OAAAR,EAAQ,IAAAI,EAAK,MAAAE,CAAM,CACjE,CAiBO,SAASG,EACZ9B,EAAkC,CAAC,EACd,CACrB,OAAOD,EAAgBC,EAAS,CAC5B,kBAAmBF,EACnB,YAAaF,CACjB,CAAC,CACL,CAQO,SAASmC,EACZ/B,EAAqC,CAAC,EACd,CACxB,OAAOD,EAAgBC,EAAS,CAC5B,kBAAmBH,EACnB,YAAaF,CACjB,CAAC,CACL",
6
- "names": ["useCallback", "useEffect", "useMemo", "useRef", "useState", "EntityAppServerClient", "EntityServerClient", "entityAppServer", "entityServer", "useEntityClient", "options", "config", "singleton", "tokenResolver", "baseUrl", "token", "resumeSession", "isPending", "setIsPending", "error", "setError", "mountedRef", "client", "instance", "resolvedToken", "resumeTokenRef", "storedRefreshToken", "run", "fn", "err", "wrapped", "submit", "entity", "data", "opts", "del", "seq", "query", "req", "reset", "useEntityServer", "useEntityAppServer"]
4
+ "sourcesContent": ["import { EntityServerApi, entityServer } from \"../index.js\";\nimport {\n useEntityClient,\n type UseEntityClientResult,\n type UseEntityServerOptions,\n} from \"./useEntityClient.js\";\n\nexport type { UseEntityServerOptions };\n\nexport interface UseEntityServerResult extends UseEntityClientResult<EntityServerApi> {}\n\n/**\n * React \uD658\uACBD\uC5D0\uC11C EntityServerApi \uC778\uC2A4\uD134\uC2A4\uC640 mutation \uC0C1\uD0DC\uB97C \uBC18\uD658\uD569\uB2C8\uB2E4.\n *\n * - `singleton=true`(\uAE30\uBCF8): \uD328\uD0A4\uC9C0 \uC804\uC5ED `entityServer` \uC778\uC2A4\uD134\uC2A4\uB97C \uC0AC\uC6A9\uD569\uB2C8\uB2E4.\n * - `singleton=false`: \uCEF4\uD3EC\uB10C\uD2B8 \uC2A4\uCF54\uD504\uC758 \uC0C8 \uC778\uC2A4\uD134\uC2A4\uB97C \uC0DD\uC131\uD569\uB2C8\uB2E4.\n *\n * @example\n * ```tsx\n * const { submit, del, isPending, error, reset } = useEntityServer();\n *\n * const handleSave = async () => {\n * await submit(\"account\", { name: \"\uD64D\uAE38\uB3D9\" });\n * };\n * ```\n */\nexport function useEntityServer(\n options: UseEntityServerOptions = {},\n): UseEntityServerResult {\n return useEntityClient(options, {\n singletonInstance: entityServer,\n ClientClass: EntityServerApi,\n });\n}\n"],
5
+ "mappings": "AAAA,OAAS,mBAAAA,EAAiB,gBAAAC,MAAoB,cAC9C,OACI,mBAAAC,MAGG,uBAqBA,SAASC,EACZC,EAAkC,CAAC,EACd,CACrB,OAAOF,EAAgBE,EAAS,CAC5B,kBAAmBH,EACnB,YAAaD,CACjB,CAAC,CACL",
6
+ "names": ["EntityServerApi", "entityServer", "useEntityClient", "useEntityServer", "options"]
7
7
  }
package/dist/index.d.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  export * from "./types.js";
2
- export * from "./EntityServerClient.js";
3
- export * from "./EntityAppServerClient.js";
2
+ export * from "./EntityServerApi.js";
3
+ export * from "./EntityAppServerApi.js";
4
4
  export * from "./mixins/server/index.js";
5
5
  export * from "./mixins/app/index.js";
6
6
  export * from "./packet.js";
7
- import { EntityServerClient } from "./EntityServerClient.js";
8
- import { EntityAppServerClient } from "./EntityAppServerClient.js";
9
- export declare const entityServer: EntityServerClient;
10
- export declare const entityAppServer: EntityAppServerClient;
7
+ import { EntityServerApi } from "./EntityServerApi.js";
8
+ import { EntityAppServerApi } from "./EntityAppServerApi.js";
9
+ export declare const entityServer: EntityServerApi;
10
+ export declare const entityAppServer: EntityAppServerApi;
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- function z(s){let r=import.meta;if(r?.env?.[s]!=null)return r.env[s];let e=globalThis.process;if(e?.env?.[s]!=null)return e.env[s]}function d(s){return Object.entries(s).filter(([,r])=>r!=null).map(([r,e])=>`${encodeURIComponent(r==="orderBy"?"order_by":r)}=${encodeURIComponent(String(e))}`).join("&")}import{xchacha20poly1305 as W}from"@noble/ciphers/chacha";import{sha256 as fe}from"@noble/hashes/sha2";import{hkdf as le}from"@noble/hashes/hkdf";var A=32,B=2,C=14,k=24,he=16,Te="entity-server:hkdf:v1",pe="entity-server:packet-encryption";function y(s){return s instanceof Uint8Array?s:new Uint8Array(s)}function Z(s,r=pe){return le(fe,new TextEncoder().encode(s),new TextEncoder().encode(Te),new TextEncoder().encode(r),A)}function Y(s,r=B,e=C){let t=y(s);return t.length<A?r:r+t[A-1]%e}function ee(s,r,e=B,t=C){let n=y(s),i=y(r),o=Y(i,e,t),a=crypto.getRandomValues(new Uint8Array(o)),u=crypto.getRandomValues(new Uint8Array(k)),l=W(i,u).encrypt(n),h=new Uint8Array(o+k+l.length);return h.set(a,0),h.set(u,o),h.set(l,o+k),h}function te(s,r,e=B,t=C){let n=y(s),i=y(r),o=Y(i,e,t);if(n.length<o+k+he)throw new Error("Encrypted packet too short");let a=n.slice(o,o+k),u=n.slice(o+k);return W(i,a).decrypt(u)}function w(s,r){return Z(s||r)}function re(s,r){return ee(s,r)}function E(s,r){let e=te(s,r);return JSON.parse(new TextDecoder().decode(e))}function ne(s,r,e,t){let n=r.toLowerCase().includes("application/octet-stream");if(e&&!n)throw new Error("Encrypted request required: Content-Type must be application/octet-stream");if(n){if(s==null)throw new Error("Encrypted request body is empty");if(s instanceof ArrayBuffer)return E(s,t);if(s instanceof Uint8Array){let i=s.buffer.slice(s.byteOffset,s.byteOffset+s.byteLength);return E(i,t)}throw new Error("Encrypted request body must be ArrayBuffer or Uint8Array")}return s==null||s===""?{}:typeof s=="string"?JSON.parse(s):s}import{sha256 as ke}from"@noble/hashes/sha2";import{hmac as ge}from"@noble/hashes/hmac";function se(s,r,e,t,n){let i=String(Math.floor(Date.now()/1e3)),o=crypto.randomUUID(),a=new TextEncoder().encode(`${s}|${r}|${i}|${o}|`),u=new Uint8Array(a.length+e.length);u.set(a,0),u.set(e,a.length);let l=[...ge(ke,new TextEncoder().encode(n),u)].map(h=>h.toString(16).padStart(2,"0")).join("");return{"X-API-Key":t,"X-Timestamp":i,"X-Nonce":o,"X-Signature":l}}function Pe(s){return s.hmacSecret||s.token||s.anonymousPacketToken}function ye(s){return s!=="GET"&&s!=="HEAD"&&s!=="OPTIONS"}function we(s,r){return s===403&&/csrf/i.test(r)?!0:/csrf/i.test(r)&&/expired|token validation failed/i.test(r)}async function ie(s){if((s.headers.get("Content-Type")??"").includes("application/json")){let t=await s.json().catch(()=>null);if(t?.error)return t.error;if(t?.message)return t.message}return await s.text().catch(()=>"")||`HTTP ${s.status}`}async function $(s,r,e,t,n=!0,i={},o=!0){let{baseUrl:a,token:u,apiKey:f,hmacSecret:l,encryptRequests:h,anonymousPacketToken:b,csrfEnabled:oe,csrfHeaderName:ae,refreshCsrfToken:v}=s,_=n&&!!(f&&l),ue=Pe(s),x=oe&&ye(r)&&!_,P=s.csrfToken,V="application/json",ce=!u&&!_&&!!b,p=null;if(t!=null)if(h&&!!ue&&r!=="GET"&&r!=="HEAD"){let T=w(l,u||b);p=re(new TextEncoder().encode(JSON.stringify(t)),T),V="application/octet-stream"}else p=JSON.stringify(t);let de=c=>{let T={"Content-Type":V,...i};if(!_&&n&&u&&(T.Authorization=`Bearer ${u}`),ce&&(T["X-Packet-Token"]=b),x&&c&&(T[ae]=c),_){let me=p instanceof Uint8Array?p:typeof p=="string"?new TextEncoder().encode(p):new Uint8Array(0);Object.assign(T,se(r,e,me,f,l))}return T};x&&!P&&v&&(P=await v());let Q=c=>fetch(a+e,{method:r,headers:de(c),...p!=null?{body:p}:{},credentials:"include"}),m=await Q(P);if(!m.ok){let c=await ie(m.clone());if(x&&v&&we(m.status,c))P=await v(),m=await Q(P);else{let T=new Error(c);throw T.status=m.status,T}}if(!m.ok){let c=new Error(await ie(m));throw c.status=m.status,c}let X=m.headers.get("Content-Type")??"";if(X.includes("application/octet-stream")){let c=w(l,u||b);return E(await m.arrayBuffer(),c)}if(!X.includes("application/json"))return await m.text();let q=await m.json();if(o&&!q.ok){let c=new Error(q.message??`EntityServer error (HTTP ${m.status})`);throw c.status=m.status,c}return q}var R=class{baseUrl;token;anonymousPacketToken;apiKey;hmacSecret;encryptRequests;csrfEnabled;csrfToken;csrfHeaderName;csrfRefreshPath;csrfRefreshBuffer;activeTxId=null;keepSession;refreshBuffer;onTokenRefreshed;onSessionExpired;_sessionRefreshToken=null;_refreshTimer=null;_csrfRefreshTimer=null;_csrfRefreshPromise=null;constructor(r={}){let e=z("VITE_ENTITY_SERVER_URL");this.baseUrl=(r.baseUrl??e??"").replace(/\/$/,""),this.token=r.token??"",this.anonymousPacketToken=r.anonymousPacketToken??"",this.apiKey=r.apiKey??"",this.hmacSecret=r.hmacSecret??"",this.encryptRequests=r.encryptRequests??!1,this.csrfEnabled=r.csrfEnabled??!1,this.csrfToken=r.csrfToken??"",this.csrfHeaderName=r.csrfHeaderName??"x-csrf-token",this.csrfRefreshPath=r.csrfRefreshPath??"/v1/csrf-token",this.csrfRefreshBuffer=r.csrfRefreshBuffer??60,this.keepSession=r.keepSession??!1,this.refreshBuffer=r.refreshBuffer??60,this.onTokenRefreshed=r.onTokenRefreshed,this.onSessionExpired=r.onSessionExpired}configure(r){typeof r.baseUrl=="string"&&(this.baseUrl=r.baseUrl.replace(/\/$/,"")),typeof r.token=="string"&&(this.token=r.token),typeof r.anonymousPacketToken=="string"&&(this.anonymousPacketToken=r.anonymousPacketToken),typeof r.encryptRequests=="boolean"&&(this.encryptRequests=r.encryptRequests),typeof r.csrfEnabled=="boolean"&&(this.csrfEnabled=r.csrfEnabled,r.csrfEnabled||(this.csrfToken="",this.stopCsrfRefresh())),typeof r.csrfToken=="string"&&(this.csrfToken=r.csrfToken),typeof r.csrfHeaderName=="string"&&(this.csrfHeaderName=r.csrfHeaderName),typeof r.csrfRefreshPath=="string"&&(this.csrfRefreshPath=r.csrfRefreshPath),typeof r.csrfRefreshBuffer=="number"&&(this.csrfRefreshBuffer=r.csrfRefreshBuffer),typeof r.apiKey=="string"&&(this.apiKey=r.apiKey),typeof r.hmacSecret=="string"&&(this.hmacSecret=r.hmacSecret),typeof r.keepSession=="boolean"&&(this.keepSession=r.keepSession),typeof r.refreshBuffer=="number"&&(this.refreshBuffer=r.refreshBuffer),r.onTokenRefreshed&&(this.onTokenRefreshed=r.onTokenRefreshed),r.onSessionExpired&&(this.onSessionExpired=r.onSessionExpired)}setToken(r){this.token=r}setAnonymousPacketToken(r){this.anonymousPacketToken=r}setApiKey(r){this.apiKey=r}setHmacSecret(r){this.hmacSecret=r}setEncryptRequests(r){this.encryptRequests=r}setCsrfToken(r){this.csrfToken=r}setCsrfEnabled(r){this.csrfEnabled=r,r||(this.csrfToken="",this.stopCsrfRefresh())}_scheduleKeepSession(r,e,t){this._clearRefreshTimer(),this._sessionRefreshToken=r;let n=Math.max((e-this.refreshBuffer)*1e3,0);this._refreshTimer=setTimeout(async()=>{if(this._sessionRefreshToken)try{let i=await t(this._sessionRefreshToken);this.onTokenRefreshed?.(i.access_token,i.expires_in),this._scheduleKeepSession(this._sessionRefreshToken,i.expires_in,t)}catch(i){this._clearRefreshTimer(),this.onSessionExpired?.(i instanceof Error?i:new Error(String(i)))}},n)}_clearRefreshTimer(){this._refreshTimer!==null&&(clearTimeout(this._refreshTimer),this._refreshTimer=null)}stopKeepSession(){this._clearRefreshTimer(),this._sessionRefreshToken=null}_clearCsrfRefreshTimer(){this._csrfRefreshTimer!==null&&(clearTimeout(this._csrfRefreshTimer),this._csrfRefreshTimer=null)}stopCsrfRefresh(){this._clearCsrfRefreshTimer(),this._csrfRefreshPromise=null}_scheduleCsrfRefresh(r){if(this._clearCsrfRefreshTimer(),!this.csrfEnabled||!this.csrfRefreshPath)return;let e=Math.max((r-this.csrfRefreshBuffer)*1e3,0);this._csrfRefreshTimer=setTimeout(()=>{this.refreshCsrfToken().catch(()=>{this._clearCsrfRefreshTimer()})},e)}async refreshCsrfToken(){return!this.csrfEnabled||!this.csrfRefreshPath?"":(this._csrfRefreshPromise||(this._csrfRefreshPromise=(async()=>{let r=await fetch(`${this.baseUrl}${this.csrfRefreshPath}`,{method:"GET",credentials:"include"});if(!r.ok){let n=await r.text().catch(()=>""),i=new Error(n||`HTTP ${r.status}`);throw i.status=r.status,i}let e=await r.json().catch(()=>null),t=e&&typeof e=="object"&&"data"in e?e.data??null:e;if(!t?.enabled||typeof t.token!="string")throw new Error("CSRF token refresh failed");return this._applyCsrfHealth(t),this.csrfToken})().finally(()=>{this._csrfRefreshPromise=null})),this._csrfRefreshPromise)}_applyCsrfHealth(r){if(!r?.enabled){this.setCsrfEnabled(!1);return}this.csrfEnabled=!0,typeof r.token=="string"&&(this.csrfToken=r.token),typeof r.headerName=="string"&&(this.csrfHeaderName=r.headerName),typeof r.refreshPath=="string"&&(this.csrfRefreshPath=r.refreshPath),typeof r.expiresIn=="number"&&r.expiresIn>0&&this._scheduleCsrfRefresh(r.expiresIn)}readRequestBody(r,e="application/json",t=!1){let n=w(this.hmacSecret,this.token||this.anonymousPacketToken);return ne(r,e,t,n)}get _reqOpts(){return{baseUrl:this.baseUrl,token:this.token,anonymousPacketToken:this.anonymousPacketToken,apiKey:this.apiKey,hmacSecret:this.hmacSecret,encryptRequests:this.encryptRequests,csrfEnabled:this.csrfEnabled,csrfToken:this.csrfToken,csrfHeaderName:this.csrfHeaderName,refreshCsrfToken:this.csrfEnabled?()=>this.refreshCsrfToken():null}}requestJson(r,e,t,n=!0,i){return $(this._reqOpts,r,e,t,n,i,!1)}requestBinary(r,e,t,n=!0){return this._requestBinary(r,e,t,n)}requestForm(r,e,t,n=!0){return this._requestForm(r,e,t,n)}requestFormBinary(r,e,t,n=!0){return this._requestFormBinary(r,e,t,n)}_request(r,e,t,n=!0,i){return $(this._reqOpts,r,e,t,n,i,!0)}async _requestBinary(r,e,t,n=!0){let i={"Content-Type":"application/json"};n&&this.token&&(i.Authorization=`Bearer ${this.token}`),this.apiKey&&(i["X-API-Key"]=this.apiKey);let o=await fetch(this.baseUrl+e,{method:r,headers:i,...t!=null?{body:JSON.stringify(t)}:{},credentials:"include"});if(!o.ok){let a=await o.text(),u=new Error(`HTTP ${o.status}: ${a}`);throw u.status=o.status,u}return o.arrayBuffer()}async _requestForm(r,e,t,n=!0){let i={};n&&this.token&&(i.Authorization=`Bearer ${this.token}`),this.apiKey&&(i["X-API-Key"]=this.apiKey);let o=await fetch(this.baseUrl+e,{method:r,headers:i,body:t,credentials:"include"}),a=await o.json();if(!a.ok){let u=new Error(a.message??`EntityServer error (HTTP ${o.status})`);throw u.status=o.status,u}return a}async _requestFormBinary(r,e,t,n=!0){let i={};n&&this.token&&(i.Authorization=`Bearer ${this.token}`),this.apiKey&&(i["X-API-Key"]=this.apiKey);let o=await fetch(this.baseUrl+e,{method:r,headers:i,body:t,credentials:"include"});if(!o.ok){let a=await o.text(),u=new Error(`HTTP ${o.status}: ${a}`);throw u.status=o.status,u}return o.arrayBuffer()}};function O(s){return class extends s{async checkHealth(){let t=await(await fetch(`${this.baseUrl}/v1/health`,{signal:AbortSignal.timeout(3e3),credentials:"include"})).json();return t.packet_encryption&&(this.encryptRequests=!0),typeof t.packet_token=="string"&&(this.anonymousPacketToken=t.packet_token),this._applyCsrfHealth(t.csrf),t}async login(e,t){let n=await this._request("POST","/v1/auth/login",{email:e,passwd:t},!1);return this.token=n.data.access_token,this.keepSession&&this._scheduleKeepSession(n.data.refresh_token,n.data.expires_in,i=>this.refreshToken(i)),n.data}async refreshToken(e){let t=await this._request("POST","/v1/auth/refresh",{refresh_token:e},!1);return this.token=t.data.access_token,this.keepSession&&this._scheduleKeepSession(e,t.data.expires_in,n=>this.refreshToken(n)),t.data}async logout(e){this.stopKeepSession();let t=await this._request("POST","/v1/auth/logout",{refresh_token:e},!1);return this.token="",t}me(){return this._request("GET","/v1/auth/me")}withdraw(e){return this._request("POST","/v1/auth/withdraw",e?{passwd:e}:{})}reactivate(e){return this._request("POST","/v1/auth/reactivate",e,!1)}}}function U(s){return class extends s{async transStart(){let e=await this._request("POST","/v1/transaction/start",void 0,!1);return this.activeTxId=e.transaction_id,this.activeTxId}transRollback(e){let t=e??this.activeTxId;return t?(this.activeTxId=null,this._request("POST",`/v1/transaction/rollback/${t}`)):Promise.reject(new Error("No active transaction. Call transStart() first."))}transCommit(e){let t=e??this.activeTxId;return t?(this.activeTxId=null,this._request("POST",`/v1/transaction/commit/${t}`)):Promise.reject(new Error("No active transaction. Call transStart() first."))}meta(e){return this._request("POST",`/v1/entity/${e}/meta`,{})}validate(e,t){return this.requestJson("POST",`/v1/entity/${e}/validate`,t)}get(e,t,n={}){let i=n.skipHooks?"?skipHooks=true":"";return this._request("GET",`/v1/entity/${e}/${t}${i}`)}find(e,t,n={}){let i=n.skipHooks?"?skipHooks=true":"";return this._request("POST",`/v1/entity/${e}/find${i}`,t??{})}list(e,t={}){let{conditions:n,fields:i,orderDir:o,orderBy:a,...u}=t,f={page:1,limit:20,...u};return a&&(f.orderBy=o==="DESC"?`-${a}`:a),i?.length&&(f.fields=i.join(",")),this._request("POST",`/v1/entity/${e}/list?${d(f)}`,n??{})}count(e,t){return this._request("POST",`/v1/entity/${e}/count`,t??{})}query(e,t){return this._request("POST",`/v1/entity/${e}/query`,t)}submit(e,t,n={}){let i=n.transactionId??this.activeTxId,o=i?{"X-Transaction-ID":i}:void 0,a=n.skipHooks?"?skipHooks=true":"";return this._request("POST",`/v1/entity/${e}/submit${a}`,t,!0,o)}delete(e,t,n={}){let i=new URLSearchParams;n.hard&&i.set("hard","true"),n.skipHooks&&i.set("skipHooks","true");let o=i.size?`?${i}`:"",a=n.transactionId??this.activeTxId,u=a?{"X-Transaction-ID":a}:void 0;return this._request("POST",`/v1/entity/${e}/delete/${t}${o}`,void 0,!0,u)}history(e,t,n={}){return this._request("GET",`/v1/entity/${e}/history/${t}?${d({page:1,limit:50,...n})}`)}rollback(e,t){return this._request("POST",`/v1/entity/${e}/rollback/${t}`)}}}function G(s){return class extends s{async fileUpload(e,t,n={}){let i=new FormData;return i.append("file",t,t instanceof File?t.name:"upload"),n.refSeq!=null&&i.append("ref_seq",String(n.refSeq)),n.isPublic!=null&&i.append("is_public",n.isPublic?"true":"false"),this._requestForm("POST",`/v1/files/${e}/upload`,i)}fileDownload(e,t){return this._requestBinary("POST",`/v1/files/${e}/download/${t}`,{})}fileDelete(e,t){return this._request("POST",`/v1/files/${e}/delete/${t}`,{})}fileList(e,t={}){return this._request("POST",`/v1/files/${e}/list`,t.refSeq?{ref_seq:t.refSeq}:{})}fileMeta(e,t){return this._request("POST",`/v1/files/${e}/meta/${t}`,{})}fileToken(e){return this._request("POST",`/v1/files/token/${e}`,{})}fileViewUrl(e,t={}){let n=t.download?"?download=true":"";return`${this.baseUrl}/v1/files/${e}${n}`}fileUrl(e){return`${this.baseUrl}/v1/files/${e}`}}}function J(s){return class extends s{push(e,t,n={}){return this.submit(e,t,n)}pushLogList(e={}){return this.list("push_log",e)}registerPushDevice(e,t,n,i={}){let{platform:o,deviceType:a,browser:u,browserVersion:f,pushEnabled:l=!0,transactionId:h}=i;return this.submit("account_device",{id:t,account_seq:e,push_token:n,push_enabled:l,...o?{platform:o}:{},...a?{device_type:a}:{},...u?{browser:u}:{},...f?{browser_version:f}:{}},{transactionId:h})}updatePushDeviceToken(e,t,n={}){let{pushEnabled:i=!0,transactionId:o}=n;return this.submit("account_device",{seq:e,push_token:t,push_enabled:i},{transactionId:o})}disablePushDevice(e,t={}){return this.submit("account_device",{seq:e,push_enabled:!1},{transactionId:t.transactionId})}}}function M(s){return class extends s{smtpSend(e){return this._request("POST","/v1/smtp/send",e)}smtpStatus(e){return this._request("POST",`/v1/smtp/status/${e}`,{})}}}function H(s){return class extends s{addressSido(){return this.requestJson("GET","/v1/utils/address/sido",void 0,!1)}addressSigungu(e){let t=new URLSearchParams({sido:e.sido}).toString();return this.requestJson("GET",`/v1/utils/address/sigungu?${t}`,void 0,!1)}addressDong(e){let t=new URLSearchParams({sido:e.sido,sigungu:e.sigungu}).toString();return this.requestJson("GET",`/v1/utils/address/dong?${t}`,void 0,!1)}addressClean(e){let t=new URLSearchParams({q:e.q}).toString();return this.requestJson("GET",`/v1/utils/address/clean?${t}`,void 0,!1)}qrcode(e,t={}){return this._requestBinary("POST","/v1/utils/qrcode",{content:e,...t})}qrcodeBase64(e,t={}){return this._request("POST","/v1/utils/qrcode/base64",{content:e,...t})}qrcodeText(e,t={}){return this._request("POST","/v1/utils/qrcode/text",{content:e,...t})}barcode(e,t={}){return this._requestBinary("POST","/v1/utils/barcode",{content:e,...t})}pdf2png(e,t={}){let n=new FormData;n.append("file",new Blob([e],{type:"application/pdf"}),"document.pdf");let i=new URLSearchParams;t.dpi!=null&&i.set("dpi",String(t.dpi)),t.firstPage!=null&&i.set("first_page",String(t.firstPage)),t.lastPage!=null&&i.set("last_page",String(t.lastPage));let o=i.toString(),a="/v1/utils/pdf2png"+(o?`?${o}`:"");return this._requestFormBinary("POST",a,n)}pdf2pngByFileSeq(e,t={}){return this.requestBinary("POST",`/v1/utils/pdf2png/${e}`,t)}pdf2jpg(e,t={}){let n=new FormData;n.append("file",new Blob([e],{type:"application/pdf"}),"document.pdf");let i=new URLSearchParams;t.dpi!=null&&i.set("dpi",String(t.dpi)),t.firstPage!=null&&i.set("first_page",String(t.firstPage)),t.lastPage!=null&&i.set("last_page",String(t.lastPage));let o=i.toString(),a="/v1/utils/pdf2jpg"+(o?`?${o}`:"");return this._requestFormBinary("POST",a,n)}pdf2jpgByFileSeq(e,t={}){return this.requestBinary("POST",`/v1/utils/pdf2jpg/${e}`,t)}}}function F(s){return class extends s{_adminPath(e){return`/v1/admin${e}`}_adminGet(e){return this.requestJson("GET",this._adminPath(e))}_adminPost(e,t){return this.requestJson("POST",this._adminPath(e),t)}_adminPut(e,t){return this.requestJson("PUT",this._adminPath(e),t)}_adminPatch(e,t){return this.requestJson("PATCH",this._adminPath(e),t)}_adminDelete(e,t){return this.requestJson("DELETE",this._adminPath(e),t)}listAdminEntities(){return this._adminGet("/entities")}getAdminErdSchema(){return this._adminGet("/erd/schema")}batchEnsureAdminEntities(e){return this._adminPost("/entities/batch-ensure",e)}createAdminEntityConfig(e,t){return this._adminPost(`/${e}/create`,t)}getAdminEntityConfig(e){return this._adminGet(`/${e}/config`)}updateAdminEntityConfig(e,t){return this._adminPut(`/${e}/config`,t)}validateAdminEntityConfig(e,t){return this._adminPost(t?`/${t}/validate`:"/entity/validate",e)}normalizeAdminEntityConfig(e,t){return this._adminPost(t?`/${t}/normalize`:"/entity/normalize",e)}getAdminEntityStats(e,t){return this._adminPost(`/${e}/stats`,t)}reindexAdminEntity(e){return this._adminPost(`/${e}/reindex`)}syncAdminEntitySchema(e){return this._adminPost(`/${e}/sync-schema`)}resetAdminEntity(e){return this._adminPost(`/${e}/reset`)}truncateAdminEntity(e){return this._adminPost(`/${e}/truncate`)}dropAdminEntity(e){return this._adminPost(`/${e}/drop`)}resetAllAdmin(e){return this._adminPost("/reset-all",e)}listAdminConfigs(){return this._adminGet("/configs")}getAdminConfig(e){return this._adminGet(`/configs/${e}`)}updateAdminConfig(e,t){return this._adminPatch(`/configs/${e}`,t)}listAdminRoles(){return this._adminGet("/roles")}createAdminRole(e){return this._adminPost("/roles",e)}getAdminRole(e){return this._adminGet(`/roles/${e}`)}updateAdminRole(e,t){return this._adminPatch(`/roles/${e}`,t)}deleteAdminRole(e){return this._adminDelete(`/roles/${e}`)}listAdminApiKeys(){return this._adminGet("/api-keys")}createAdminApiKey(e){return this._adminPost("/api-keys",e)}getAdminApiKey(e){return this._adminGet(`/api-keys/${e}`)}updateAdminApiKey(e,t){return this._adminPatch(`/api-keys/${e}`,t)}deleteAdminApiKey(e){return this._adminDelete(`/api-keys/${e}`)}regenerateAdminApiKeySecret(e){return this._adminPost(`/api-keys/${e}/regenerate-secret`)}listAdminAccounts(){return this._adminGet("/accounts")}createAdminAccount(e){return this._adminPost("/accounts",e)}getAdminAccount(e){return this._adminGet(`/accounts/${e}`)}updateAdminAccount(e,t){return this._adminPatch(`/accounts/${e}`,t)}deleteAdminAccount(e){return this._adminDelete(`/accounts/${e}`)}listAdminLicenses(){return this._adminGet("/licenses")}createAdminLicense(e){return this._adminPost("/licenses",e)}getAdminLicense(e){return this._adminGet(`/licenses/${e}`)}updateAdminLicense(e,t){return this._adminPatch(`/licenses/${e}`,t)}deleteAdminLicense(e){return this._adminDelete(`/licenses/${e}`)}runAdminBackup(e){return this._adminPost("/backup/run",e)}getAdminBackupStatus(e){return this._adminPost("/backup/status",e)}listAdminBackups(e){return this._adminPost("/backup/list",e)}restoreAdminBackup(e){return this._adminPost("/backup/restore",e)}deleteAdminBackup(e){return this._adminPost("/backup/delete",e)}disableAdminAccountTwoFactor(e){return this._adminDelete(`/accounts/${e}/2fa`)}}}var g=class extends H(G(M(J(F(U(O(R))))))){};function I(s){return class extends s{accountRegister(e){return this.requestJson("POST","/v1/account/register",e,!1)}accountWithdraw(e){return this.requestJson("POST","/v1/account/withdraw",e)}accountChangePassword(e){return this.requestJson("POST","/v1/account/change-password",e)}accountReactivate(e){return this.requestJson("POST","/v1/account/reactivate",e,!1)}listAccountBiometrics(){return this.requestJson("GET","/v1/account/biometric")}registerAccountBiometric(e){return this.requestJson("POST","/v1/account/biometric",e)}deleteAccountBiometric(e){return this.requestJson("DELETE",`/v1/account/biometric/${e}`)}}}function K(s){return class extends s{listBoardCategories(e={}){let t=d(e);return this.requestJson("GET",`/v1/board/categories${t?`?${t}`:""}`,void 0,!1)}getBoardCategory(e){return this.requestJson("GET",`/v1/board/categories/${e}`,void 0,!1)}createBoardCategory(e){return this.requestJson("POST","/v1/board/categories",e)}updateBoardCategory(e,t){return this.requestJson("PUT",`/v1/board/categories/${e}`,t)}deleteBoardCategory(e){return this.requestJson("DELETE",`/v1/board/categories/${e}`)}listBoardPosts(e,t={}){let n=d(t);return this.requestJson("GET",`/v1/board/${e}/list${n?`?${n}`:""}`,void 0,!1)}getBoardPost(e){return this.requestJson("GET",`/v1/board/posts/${e}`,void 0,!1)}createBoardPost(e,t){return this.requestJson("POST",`/v1/board/${e}/submit`,t)}updateBoardPost(e,t){return this.requestJson("PUT",`/v1/board/posts/${e}`,t)}deleteBoardPost(e){return this.requestJson("DELETE",`/v1/board/posts/${e}`)}listBoardComments(e,t={}){let n=d(t);return this.requestJson("GET",`/v1/board/posts/${e}/comments${n?`?${n}`:""}`,void 0,!1)}createBoardComment(e,t){return this.requestJson("POST",`/v1/board/posts/${e}/comments/submit`,t)}updateBoardComment(e,t){return this.requestJson("PUT",`/v1/board/comments/${e}`,t)}deleteBoardComment(e){return this.requestJson("DELETE",`/v1/board/comments/${e}`)}listBoardFiles(e){return this.requestJson("GET",`/v1/board/posts/${e}/files`,void 0,!1)}async uploadBoardFile(e,t){let n=new FormData;return n.append("file",t,t instanceof File?t.name:"upload"),this.requestForm("POST",`/v1/board/posts/${e}/files`,n)}boardFileUrl(e){return`${this.baseUrl}/v1/board/files/${e}`}deleteBoardFile(e){return this.requestJson("DELETE",`/v1/board/files/${e}`)}createBoardGuestPost(e,t){return this.requestJson("POST",`/v1/board/${e}/guest-submit`,t,!1)}authenticateBoardGuestPost(e,t){return this.requestJson("POST",`/v1/board/posts/${e}/guest-auth`,t,!1)}toggleBoardPostLike(e){return this.requestJson("POST",`/v1/board/posts/${e}/like`,{})}acceptBoardPost(e){return this.requestJson("POST",`/v1/board/posts/${e}/accept`,{})}rateBoardPost(e,t){return this.requestJson("POST",`/v1/board/posts/${e}/rating`,t)}rateBoardComment(e,t){return this.requestJson("POST",`/v1/board/comments/${e}/rating`,t)}listBoardTags(e={}){let t=d(e);return this.requestJson("GET",`/v1/board/tags${t?`?${t}`:""}`,void 0,!1)}setBoardPostTags(e,t){return this.requestJson("PUT",`/v1/board/posts/${e}/tags`,t)}reportBoardPost(e,t){return this.requestJson("POST",`/v1/board/posts/${e}/report`,t)}reportBoardComment(e,t){return this.requestJson("POST",`/v1/board/comments/${e}/report`,t)}listBoardReports(e={}){let t=d(e);return this.requestJson("GET",`/v1/board/admin/reports${t?`?${t}`:""}`)}updateBoardReport(e,t){return this.requestJson("PATCH",`/v1/board/admin/reports/${e}`,t)}markBoardPostRead(e){return this.requestJson("POST",`/v1/board/posts/${e}/read`,{})}listBoardMentions(e={}){let t=d(e);return this.requestJson("GET",`/v1/board/mentions${t?`?${t}`:""}`)}markBoardMentionRead(e){return this.requestJson("PATCH",`/v1/board/mentions/${e}/read`,{})}}}function L(s){return class extends s{sendEmailVerification(e){return this.requestJson("POST","/v1/email-verify/send",e,!1)}confirmEmailVerification(e){return this.requestJson("POST","/v1/email-verify/confirm",e,!1)}activateEmailVerification(e){let t=d(e);return this.requestJson("GET",`/v1/email-verify/activate${t?`?${t}`:""}`,void 0,!1)}getEmailVerificationStatus(){return this.requestJson("GET","/v1/email-verify/status")}changeVerifiedEmail(e){return this.requestJson("POST","/v1/email-verify/change",e)}}}function j(s){return class extends s{oauthAuthorizeUrl(e,t={}){let n=d(t);return`${this.baseUrl}/v1/oauth/${e}${n?`?${n}`:""}`}oauthCallback(e,t,n="POST"){if(n==="GET"){let i=d(t??{});return this.requestJson("GET",`/v1/oauth/${e}/callback${i?`?${i}`:""}`,void 0,!1)}return this.requestJson("POST",`/v1/oauth/${e}/callback`,t,!1)}linkOAuthAccount(e){return this.requestJson("POST","/v1/account/oauth/link",e)}unlinkOAuthAccount(e){return this.requestJson("DELETE",`/v1/account/oauth/link/${e}`)}listOAuthProviders(){return this.requestJson("GET","/v1/account/oauth/providers")}refreshOAuthProviderToken(e,t){return this.requestJson("POST",`/v1/account/oauth/refresh/${e}`,t)}}}function D(s){return class extends s{requestPasswordReset(e){return this.requestJson("POST","/v1/password-reset/request",e,!1)}validatePasswordResetToken(e){return this.requestJson("GET",`/v1/password-reset/validate/${encodeURIComponent(e)}`,void 0,!1)}verifyPasswordReset(e){return this.requestJson("POST","/v1/password-reset/verify",e,!1)}}}function N(s){return class extends s{setupTwoFactor(e){return this.requestJson("POST","/v1/account/2fa/setup",e)}verifyTwoFactorSetup(e){return this.requestJson("POST","/v1/account/2fa/setup/verify",e,!1)}disableTwoFactor(){return this.requestJson("DELETE","/v1/account/2fa")}getTwoFactorStatus(){return this.requestJson("GET","/v1/account/2fa/status")}regenerateTwoFactorRecoveryCodes(){return this.requestJson("POST","/v1/account/2fa/recovery/regenerate")}verifyTwoFactor(e){return this.requestJson("POST","/v1/account/2fa/verify",e,!1)}recoverTwoFactorAccess(e){return this.requestJson("POST","/v1/account/2fa/recovery",e,!1)}}}var S=class extends j(N(D(L(K(I(g)))))){};var Mt=new g,Ht=new S;export{I as AccountAppMixin,F as AdminMixin,O as AuthMixin,K as BoardMixin,L as EmailVerifyMixin,S as EntityAppServerClient,U as EntityMixin,g as EntityServerClient,G as FileMixin,j as OAuthMixin,Te as PACKET_HKDF_SALT,pe as PACKET_INFO_LABEL,A as PACKET_KEY_SIZE,B as PACKET_MAGIC_MIN,C as PACKET_MAGIC_RANGE,k as PACKET_NONCE_SIZE,he as PACKET_TAG_SIZE,D as PasswordResetMixin,J as PushMixin,M as SmtpMixin,N as TwoFactorMixin,H as UtilsMixin,te as decryptPacket,Z as derivePacketKey,ee as encryptPacket,Ht as entityAppServer,Mt as entityServer,Y as packetMagicLenFromKey};
1
+ function ae(r){let n=import.meta;if(n?.env?.[r]!=null)return n.env[r];let e=globalThis.process;if(e?.env?.[r]!=null)return e.env[r]}function c(r){return Object.entries(r).filter(([,n])=>n!=null).map(([n,e])=>`${encodeURIComponent(n==="orderBy"?"order_by":n)}=${encodeURIComponent(String(e))}`).join("&")}import{xchacha20poly1305 as ue}from"@noble/ciphers/chacha";import{sha256 as be}from"@noble/hashes/sha2";import{hkdf as xe}from"@noble/hashes/hkdf";var E=32,A=2,q=14,k=24,Re=16,Ce="entity-server:hkdf:v1",Se="entity-server:packet-encryption";function w(r){return r instanceof Uint8Array?r:new Uint8Array(r)}function ce(r,n=Se){return xe(be,new TextEncoder().encode(r),new TextEncoder().encode(Ce),new TextEncoder().encode(n),E)}function me(r,n=A,e=q){let t=w(r);return t.length<E?n:n+t[E-1]%e}function le(r,n,e=A,t=q){let s=w(r),i=w(n),o=me(i,e,t),a=crypto.getRandomValues(new Uint8Array(o)),u=crypto.getRandomValues(new Uint8Array(k)),h=ue(i,u).encrypt(s),p=new Uint8Array(o+k+h.length);return p.set(a,0),p.set(u,o),p.set(h,o+k),p}function de(r,n,e=A,t=q){let s=w(r),i=w(n),o=me(i,e,t);if(s.length<o+k+Re)throw new Error("Encrypted packet too short");let a=s.slice(o,o+k),u=s.slice(o+k);return ue(i,a).decrypt(u)}function v(r,n){return ce(r||n)}function he(r,n){return le(r,n)}function C(r,n){let e=de(r,n);return JSON.parse(new TextDecoder().decode(e))}function pe(r,n,e,t){let s=n.toLowerCase().includes("application/octet-stream");if(e&&!s)throw new Error("Encrypted request required: Content-Type must be application/octet-stream");if(s){if(r==null)throw new Error("Encrypted request body is empty");if(r instanceof ArrayBuffer)return C(r,t);if(r instanceof Uint8Array){let i=r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength);return C(i,t)}throw new Error("Encrypted request body must be ArrayBuffer or Uint8Array")}return r==null||r===""?{}:typeof r=="string"?JSON.parse(r):r}import{sha256 as _e}from"@noble/hashes/sha2";import{hmac as Be}from"@noble/hashes/hmac";function fe(r,n,e,t,s){let i=String(Math.floor(Date.now()/1e3)),o=crypto.randomUUID(),a=new TextEncoder().encode(`${r}|${n}|${i}|${o}|`),u=new Uint8Array(a.length+e.length);u.set(a,0),u.set(e,a.length);let h=[...Be(_e,new TextEncoder().encode(s),u)].map(p=>p.toString(16).padStart(2,"0")).join("");return{"X-API-Key":t,"X-Timestamp":i,"X-Nonce":o,"X-Signature":h}}function $e(r){return r.hmacSecret||r.token||r.anonymousPacketToken}function Ee(r){return r!=="GET"&&r!=="HEAD"&&r!=="OPTIONS"}function Ae(r,n){return r===403&&/csrf/i.test(n)?!0:/csrf/i.test(n)&&/expired|token validation failed/i.test(n)}async function Te(r){if((r.headers.get("Content-Type")??"").includes("application/json")){let t=await r.json().catch(()=>null);if(t?.error)return t.error;if(t?.message)return t.message}return await r.text().catch(()=>"")||`HTTP ${r.status}`}async function g(r,n,e,t,s=!0,i={},o=!0){let{baseUrl:a,token:u,apiKey:d,hmacSecret:h,encryptRequests:p,anonymousPacketToken:b,csrfEnabled:ge,csrfHeaderName:ke,refreshCsrfToken:x}=r,R=s&&!!(d&&h),Pe=$e(r),B=ge&&Ee(n)&&!R,y=r.csrfToken,se="application/json",ye=!u&&!R&&!!b,T=null;if(t!=null)if(p&&!!Pe&&n!=="GET"&&n!=="HEAD"){let f=v(h,u||b);T=he(new TextEncoder().encode(JSON.stringify(t)),f),se="application/octet-stream"}else T=JSON.stringify(t);let we=m=>{let f={"Content-Type":se,...i};if(!R&&s&&u&&(f.Authorization=`Bearer ${u}`),ye&&(f["X-Packet-Token"]=b),B&&m&&(f[ke]=m),R){let ve=T instanceof Uint8Array?T:typeof T=="string"?new TextEncoder().encode(T):new Uint8Array(0);Object.assign(f,fe(n,e,ve,d,h))}return f};B&&!y&&x&&(y=await x());let ie=m=>fetch(a+e,{method:n,headers:we(m),...T!=null?{body:T}:{},credentials:"include"}),l=await ie(y);if(!l.ok){let m=await Te(l.clone());if(B&&x&&Ae(l.status,m))y=await x(),l=await ie(y);else{let f=new Error(m);throw f.status=l.status,f}}if(!l.ok){let m=new Error(await Te(l));throw m.status=l.status,m}let oe=l.headers.get("Content-Type")??"";if(oe.includes("application/octet-stream")){let m=v(h,u||b);return C(await l.arrayBuffer(),m)}if(!oe.includes("application/json"))return await l.text();let $=await l.json();if(o&&!$.ok){let m=new Error($.message??`EntityServer error (HTTP ${l.status})`);throw m.status=l.status,m}return $}var S=class{baseUrl;token;anonymousPacketToken;apiKey;hmacSecret;encryptRequests;csrfEnabled;csrfToken;csrfHeaderName;csrfRefreshPath;csrfRefreshBuffer;activeTxId=null;keepSession;refreshBuffer;onTokenRefreshed;onSessionExpired;_sessionRefreshToken=null;_refreshTimer=null;_csrfRefreshTimer=null;_csrfRefreshPromise=null;constructor(n={}){let e=ae("VITE_ENTITY_SERVER_URL");this.baseUrl=(n.baseUrl??e??"").replace(/\/$/,""),this.token=n.token??"",this.anonymousPacketToken=n.anonymousPacketToken??"",this.apiKey=n.apiKey??"",this.hmacSecret=n.hmacSecret??"",this.encryptRequests=n.encryptRequests??!1,this.csrfEnabled=n.csrfEnabled??!1,this.csrfToken=n.csrfToken??"",this.csrfHeaderName=n.csrfHeaderName??"x-csrf-token",this.csrfRefreshPath=n.csrfRefreshPath??"/v1/csrf-token",this.csrfRefreshBuffer=n.csrfRefreshBuffer??60,this.keepSession=n.keepSession??!1,this.refreshBuffer=n.refreshBuffer??60,this.onTokenRefreshed=n.onTokenRefreshed,this.onSessionExpired=n.onSessionExpired}configure(n){typeof n.baseUrl=="string"&&(this.baseUrl=n.baseUrl.replace(/\/$/,"")),typeof n.token=="string"&&(this.token=n.token),typeof n.anonymousPacketToken=="string"&&(this.anonymousPacketToken=n.anonymousPacketToken),typeof n.encryptRequests=="boolean"&&(this.encryptRequests=n.encryptRequests),typeof n.csrfEnabled=="boolean"&&(this.csrfEnabled=n.csrfEnabled,n.csrfEnabled||(this.csrfToken="",this.stopCsrfRefresh())),typeof n.csrfToken=="string"&&(this.csrfToken=n.csrfToken),typeof n.csrfHeaderName=="string"&&(this.csrfHeaderName=n.csrfHeaderName),typeof n.csrfRefreshPath=="string"&&(this.csrfRefreshPath=n.csrfRefreshPath),typeof n.csrfRefreshBuffer=="number"&&(this.csrfRefreshBuffer=n.csrfRefreshBuffer),typeof n.apiKey=="string"&&(this.apiKey=n.apiKey),typeof n.hmacSecret=="string"&&(this.hmacSecret=n.hmacSecret),typeof n.keepSession=="boolean"&&(this.keepSession=n.keepSession),typeof n.refreshBuffer=="number"&&(this.refreshBuffer=n.refreshBuffer),n.onTokenRefreshed&&(this.onTokenRefreshed=n.onTokenRefreshed),n.onSessionExpired&&(this.onSessionExpired=n.onSessionExpired)}setToken(n){this.token=n}setAnonymousPacketToken(n){this.anonymousPacketToken=n}setApiKey(n){this.apiKey=n}setHmacSecret(n){this.hmacSecret=n}setEncryptRequests(n){this.encryptRequests=n}setCsrfToken(n){this.csrfToken=n}setCsrfEnabled(n){this.csrfEnabled=n,n||(this.csrfToken="",this.stopCsrfRefresh())}_scheduleKeepSession(n,e,t){this._clearRefreshTimer(),this._sessionRefreshToken=n;let s=Math.max((e-this.refreshBuffer)*1e3,0);this._refreshTimer=setTimeout(async()=>{if(this._sessionRefreshToken)try{let i=await t(this._sessionRefreshToken);this.onTokenRefreshed?.(i.access_token,i.expires_in),this._scheduleKeepSession(this._sessionRefreshToken,i.expires_in,t)}catch(i){this._clearRefreshTimer(),this.onSessionExpired?.(i instanceof Error?i:new Error(String(i)))}},s)}_clearRefreshTimer(){this._refreshTimer!==null&&(clearTimeout(this._refreshTimer),this._refreshTimer=null)}stopKeepSession(){this._clearRefreshTimer(),this._sessionRefreshToken=null}_clearCsrfRefreshTimer(){this._csrfRefreshTimer!==null&&(clearTimeout(this._csrfRefreshTimer),this._csrfRefreshTimer=null)}stopCsrfRefresh(){this._clearCsrfRefreshTimer(),this._csrfRefreshPromise=null}_scheduleCsrfRefresh(n){if(this._clearCsrfRefreshTimer(),!this.csrfEnabled||!this.csrfRefreshPath)return;let e=Math.max((n-this.csrfRefreshBuffer)*1e3,0);this._csrfRefreshTimer=setTimeout(()=>{this.refreshCsrfToken().catch(()=>{this._clearCsrfRefreshTimer()})},e)}async refreshCsrfToken(){return!this.csrfEnabled||!this.csrfRefreshPath?"":(this._csrfRefreshPromise||(this._csrfRefreshPromise=(async()=>{let n=await fetch(`${this.baseUrl}${this.csrfRefreshPath}`,{method:"GET",credentials:"include"});if(!n.ok){let s=await n.text().catch(()=>""),i=new Error(s||`HTTP ${n.status}`);throw i.status=n.status,i}let e=await n.json().catch(()=>null),t=e&&typeof e=="object"&&"data"in e?e.data??null:e;if(!t?.enabled||typeof t.token!="string")throw new Error("CSRF token refresh failed");return this._applyCsrfHealth(t),this.csrfToken})().finally(()=>{this._csrfRefreshPromise=null})),this._csrfRefreshPromise)}_applyCsrfHealth(n){if(!n?.enabled){this.setCsrfEnabled(!1);return}this.csrfEnabled=!0,typeof n.token=="string"&&(this.csrfToken=n.token),typeof n.headerName=="string"&&(this.csrfHeaderName=n.headerName),typeof n.refreshPath=="string"&&(this.csrfRefreshPath=n.refreshPath),typeof n.expiresIn=="number"&&n.expiresIn>0&&this._scheduleCsrfRefresh(n.expiresIn)}readRequestBody(n,e="application/json",t=!1){let s=v(this.hmacSecret,this.token||this.anonymousPacketToken);return pe(n,e,t,s)}get _reqOpts(){return{baseUrl:this.baseUrl,token:this.token,anonymousPacketToken:this.anonymousPacketToken,apiKey:this.apiKey,hmacSecret:this.hmacSecret,encryptRequests:this.encryptRequests,csrfEnabled:this.csrfEnabled,csrfToken:this.csrfToken,csrfHeaderName:this.csrfHeaderName,refreshCsrfToken:this.csrfEnabled?()=>this.refreshCsrfToken():null}}get http(){let n=this;return{get(e,t=!0,s){return g(n._reqOpts,"GET",e,void 0,t,s,!1)},post(e,t,s=!0,i){return g(n._reqOpts,"POST",e,t,s,i,!1)},put(e,t,s=!0,i){return g(n._reqOpts,"PUT",e,t,s,i,!1)},patch(e,t,s=!0,i){return g(n._reqOpts,"PATCH",e,t,s,i,!1)},delete(e,t,s=!0,i){return g(n._reqOpts,"DELETE",e,t,s,i,!1)}}}requestBinary(n,e,t,s=!0){return this._requestBinary(n,e,t,s)}requestForm(n,e,t,s=!0){return this._requestForm(n,e,t,s)}requestFormBinary(n,e,t,s=!0){return this._requestFormBinary(n,e,t,s)}_request(n,e,t,s=!0,i){return g(this._reqOpts,n,e,t,s,i,!0)}async _requestBinary(n,e,t,s=!0){let i={"Content-Type":"application/json"};s&&this.token&&(i.Authorization=`Bearer ${this.token}`),this.apiKey&&(i["X-API-Key"]=this.apiKey);let o=await fetch(this.baseUrl+e,{method:n,headers:i,...t!=null?{body:JSON.stringify(t)}:{},credentials:"include"});if(!o.ok){let a=await o.text(),u=new Error(`HTTP ${o.status}: ${a}`);throw u.status=o.status,u}return o.arrayBuffer()}async _requestForm(n,e,t,s=!0){let i={};s&&this.token&&(i.Authorization=`Bearer ${this.token}`),this.apiKey&&(i["X-API-Key"]=this.apiKey);let o=await fetch(this.baseUrl+e,{method:n,headers:i,body:t,credentials:"include"}),a=await o.json();if(!a.ok){let u=new Error(a.message??`EntityServer error (HTTP ${o.status})`);throw u.status=o.status,u}return a}async _requestFormBinary(n,e,t,s=!0){let i={};s&&this.token&&(i.Authorization=`Bearer ${this.token}`),this.apiKey&&(i["X-API-Key"]=this.apiKey);let o=await fetch(this.baseUrl+e,{method:n,headers:i,body:t,credentials:"include"});if(!o.ok){let a=await o.text(),u=new Error(`HTTP ${o.status}: ${a}`);throw u.status=o.status,u}return o.arrayBuffer()}};function M(r){return class extends r{async checkHealth(){let t=await(await fetch(`${this.baseUrl}/v1/health`,{signal:AbortSignal.timeout(3e3),credentials:"include"})).json();return t.packet_encryption&&(this.encryptRequests=!0),typeof t.packet_token=="string"&&(this.anonymousPacketToken=t.packet_token),this._applyCsrfHealth(t.csrf),t}async login(e,t){let s=await this._request("POST","/v1/auth/login",{email:e,passwd:t},!1);return this.token=s.data.access_token,this.keepSession&&this._scheduleKeepSession(s.data.refresh_token,s.data.expires_in,i=>this.refreshToken(i)),s.data}async refreshToken(e){let t=await this._request("POST","/v1/auth/refresh",{refresh_token:e},!1);return this.token=t.data.access_token,this.keepSession&&this._scheduleKeepSession(e,t.data.expires_in,s=>this.refreshToken(s)),t.data}async logout(e){this.stopKeepSession();let t=await this._request("POST","/v1/auth/logout",{refresh_token:e},!1);return this.token="",t}me(){return this._request("GET","/v1/auth/me")}withdraw(e){return this._request("POST","/v1/auth/withdraw",e?{passwd:e}:{})}}}function O(r){return class extends r{async transStart(){let e=await this._request("POST","/v1/transaction/start",void 0,!1);return this.activeTxId=e.transaction_id,this.activeTxId}transRollback(e){let t=e??this.activeTxId;return t?(this.activeTxId=null,this._request("POST",`/v1/transaction/rollback/${t}`)):Promise.reject(new Error("No active transaction. Call transStart() first."))}transCommit(e){let t=e??this.activeTxId;return t?(this.activeTxId=null,this._request("POST",`/v1/transaction/commit/${t}`)):Promise.reject(new Error("No active transaction. Call transStart() first."))}meta(e){return this._request("POST",`/v1/entity/${e}/meta`,{})}validate(e,t){return this.http.post(`/v1/entity/${e}/validate`,t)}get(e,t,s={}){let i=s.skipHooks?"?skipHooks=true":"";return this._request("GET",`/v1/entity/${e}/${t}${i}`)}find(e,t,s={}){let i=s.skipHooks?"?skipHooks=true":"";return this._request("POST",`/v1/entity/${e}/find${i}`,t??{})}list(e,t={}){let{conditions:s,fields:i,orderDir:o,orderBy:a,...u}=t,d={page:1,limit:20,...u};return a&&(d.orderBy=o==="DESC"?`-${a}`:a),i?.length&&(d.fields=i.join(",")),this._request("POST",`/v1/entity/${e}/list?${c(d)}`,s??{})}count(e,t){return this._request("POST",`/v1/entity/${e}/count`,t??{})}query(e,t){return this._request("POST",`/v1/entity/${e}/query`,t)}submit(e,t,s={}){let i=s.transactionId??this.activeTxId,o=i?{"X-Transaction-ID":i}:void 0,a=s.skipHooks?"?skipHooks=true":"";return this._request("POST",`/v1/entity/${e}/submit${a}`,t,!0,o)}delete(e,t,s={}){let i=new URLSearchParams;s.hard&&i.set("hard","true"),s.skipHooks&&i.set("skipHooks","true");let o=i.size?`?${i}`:"",a=s.transactionId??this.activeTxId,u=a?{"X-Transaction-ID":a}:void 0;return this._request("POST",`/v1/entity/${e}/delete/${t}${o}`,void 0,!0,u)}history(e,t,s={}){return this._request("GET",`/v1/entity/${e}/history/${t}?${c({page:1,limit:50,...s})}`)}rollback(e,t){return this._request("POST",`/v1/entity/${e}/rollback/${t}`)}}}function U(r){return class extends r{async fileUpload(e,t,s={}){let i=new FormData;return i.append("file",t,t instanceof File?t.name:"upload"),s.refSeq!=null&&i.append("ref_seq",String(s.refSeq)),s.isPublic!=null&&i.append("is_public",s.isPublic?"true":"false"),this._requestForm("POST",`/v1/files/${e}/upload`,i)}fileDownload(e,t){return this._requestBinary("POST",`/v1/files/${e}/download/${t}`,{})}fileDelete(e,t){return this._request("POST",`/v1/files/${e}/delete/${t}`,{})}fileList(e,t={}){return this._request("POST",`/v1/files/${e}/list`,t.refSeq?{ref_seq:t.refSeq}:{})}fileMeta(e,t){return this._request("POST",`/v1/files/${e}/meta/${t}`,{})}fileToken(e){return this._request("POST",`/v1/files/token/${e}`,{})}fileViewUrl(e,t={}){let s=t.download?"?download=true":"";return`${this.baseUrl}/v1/files/${e}${s}`}fileUrl(e){return`${this.baseUrl}/v1/files/${e}`}}}function G(r){return class extends r{push(e,t,s={}){return this.submit(e,t,s)}pushLogList(e={}){return this.list("push_log",e)}registerPushDevice(e,t,s,i={}){let{platform:o,deviceType:a,browser:u,browserVersion:d,pushEnabled:h=!0,transactionId:p}=i;return this.submit("account_device",{id:t,account_seq:e,push_token:s,push_enabled:h,...o?{platform:o}:{},...a?{device_type:a}:{},...u?{browser:u}:{},...d?{browser_version:d}:{}},{transactionId:p})}updatePushDeviceToken(e,t,s={}){let{pushEnabled:i=!0,transactionId:o}=s;return this.submit("account_device",{seq:e,push_token:t,push_enabled:i},{transactionId:o})}disablePushDevice(e,t={}){return this.submit("account_device",{seq:e,push_enabled:!1},{transactionId:t.transactionId})}}}function I(r){return class extends r{smtpSend(e){return this._request("POST","/v1/smtp/send",e)}smtpStatus(e){return this._request("POST",`/v1/smtp/status/${e}`,{})}smtpTemplatePreview(e){let t=e.split("/").map(encodeURIComponent).join("/");return fetch(`${this.baseUrl}/v1/smtp/template/${t}`,{credentials:"include"}).then(s=>s.text())}}}function F(r){return class extends r{transactionStart(e){return this._request("POST","/v1/transaction/start",e??{})}transactionCommit(e){return this._request("POST",`/v1/transaction/commit/${encodeURIComponent(e)}`,{})}transactionRollback(e){return this._request("POST",`/v1/transaction/rollback/${encodeURIComponent(e)}`,{})}}}function H(r){return class extends r{addressSido(){return this.http.get("/v1/utils/address/sido",!1)}addressSigungu(e){let t=new URLSearchParams({sido:e.sido}).toString();return this.http.get(`/v1/utils/address/sigungu?${t}`,!1)}addressDong(e){let t=new URLSearchParams({sido:e.sido,sigungu:e.sigungu}).toString();return this.http.get(`/v1/utils/address/dong?${t}`,!1)}addressClean(e){let t=new URLSearchParams({q:e.q}).toString();return this.http.get(`/v1/utils/address/clean?${t}`,!1)}qrcode(e,t={}){return this._requestBinary("POST","/v1/utils/qrcode",{content:e,...t})}qrcodeBase64(e,t={}){return this._request("POST","/v1/utils/qrcode/base64",{content:e,...t})}qrcodeText(e,t={}){return this._request("POST","/v1/utils/qrcode/text",{content:e,...t})}barcode(e,t={}){return this._requestBinary("POST","/v1/utils/barcode",{content:e,...t})}pdf2png(e,t={}){let s=new FormData;s.append("file",new Blob([e],{type:"application/pdf"}),"document.pdf");let i=new URLSearchParams;t.dpi!=null&&i.set("dpi",String(t.dpi)),t.firstPage!=null&&i.set("first_page",String(t.firstPage)),t.lastPage!=null&&i.set("last_page",String(t.lastPage));let o=i.toString(),a="/v1/utils/pdf2png"+(o?`?${o}`:"");return this._requestFormBinary("POST",a,s)}pdf2pngByFileSeq(e,t={}){return this.requestBinary("POST",`/v1/utils/pdf2png/${e}`,t)}pdf2jpg(e,t={}){let s=new FormData;s.append("file",new Blob([e],{type:"application/pdf"}),"document.pdf");let i=new URLSearchParams;t.dpi!=null&&i.set("dpi",String(t.dpi)),t.firstPage!=null&&i.set("first_page",String(t.firstPage)),t.lastPage!=null&&i.set("last_page",String(t.lastPage));let o=i.toString(),a="/v1/utils/pdf2jpg"+(o?`?${o}`:"");return this._requestFormBinary("POST",a,s)}pdf2jpgByFileSeq(e,t={}){return this.requestBinary("POST",`/v1/utils/pdf2jpg/${e}`,t)}}}function L(r){return class extends r{_adminPath(e){return`/v1/admin${e}`}_adminGet(e){return this.http.get(this._adminPath(e))}_adminPost(e,t){return this.http.post(this._adminPath(e),t)}_adminPut(e,t){return this.http.put(this._adminPath(e),t)}_adminPatch(e,t){return this.http.patch(this._adminPath(e),t)}_adminDelete(e,t){return this.http.delete(this._adminPath(e),t)}listAdminEntities(){return this._adminGet("/entities")}getAdminErdSchema(){return this._adminGet("/erd/schema")}batchEnsureAdminEntities(e){return this._adminPost("/entities/batch-ensure",e)}createAdminEntityConfig(e,t){return this._adminPost(`/${e}/create`,t)}getAdminEntityConfig(e){return this._adminGet(`/${e}/config`)}updateAdminEntityConfig(e,t){return this._adminPut(`/${e}/config`,t)}validateAdminEntityConfig(e,t){return this._adminPost(t?`/${t}/validate`:"/entity/validate",e)}normalizeAdminEntityConfig(e,t){return this._adminPost(t?`/${t}/normalize`:"/entity/normalize",e)}getAdminEntityStats(e,t){return this._adminPost(`/${e}/stats`,t)}reindexAdminEntity(e){return this._adminPost(`/${e}/reindex`)}syncAdminEntitySchema(e){return this._adminPost(`/${e}/sync-schema`)}resetAdminEntity(e){return this._adminPost(`/${e}/reset`)}truncateAdminEntity(e){return this._adminPost(`/${e}/truncate`)}dropAdminEntity(e){return this._adminPost(`/${e}/drop`)}resetAllAdmin(e){return this._adminPost("/reset-all",e)}listAdminConfigs(){return this._adminGet("/configs")}getAdminConfig(e){return this._adminGet(`/configs/${e}`)}updateAdminConfig(e,t){return this._adminPatch(`/configs/${e}`,t)}listAdminRoles(){return this._adminGet("/roles")}createAdminRole(e){return this._adminPost("/roles",e)}getAdminRole(e){return this._adminGet(`/roles/${e}`)}updateAdminRole(e,t){return this._adminPatch(`/roles/${e}`,t)}deleteAdminRole(e){return this._adminDelete(`/roles/${e}`)}listAdminApiKeys(){return this._adminGet("/api-keys")}createAdminApiKey(e){return this._adminPost("/api-keys",e)}getAdminApiKey(e){return this._adminGet(`/api-keys/${e}`)}updateAdminApiKey(e,t){return this._adminPatch(`/api-keys/${e}`,t)}deleteAdminApiKey(e){return this._adminDelete(`/api-keys/${e}`)}regenerateAdminApiKeySecret(e){return this._adminPost(`/api-keys/${e}/regenerate-secret`)}listAdminAccounts(){return this._adminGet("/accounts")}createAdminAccount(e){return this._adminPost("/accounts",e)}getAdminAccount(e){return this._adminGet(`/accounts/${e}`)}updateAdminAccount(e,t){return this._adminPatch(`/accounts/${e}`,t)}deleteAdminAccount(e){return this._adminDelete(`/accounts/${e}`)}listAdminLicenses(){return this._adminGet("/licenses")}createAdminLicense(e){return this._adminPost("/licenses",e)}getAdminLicense(e){return this._adminGet(`/licenses/${e}`)}updateAdminLicense(e,t){return this._adminPatch(`/licenses/${e}`,t)}deleteAdminLicense(e){return this._adminDelete(`/licenses/${e}`)}runAdminBackup(e){return this._adminPost("/backup/run",e)}getAdminBackupStatus(e){return this._adminPost("/backup/status",e)}listAdminBackups(e){return this._adminPost("/backup/list",e)}restoreAdminBackup(e){return this._adminPost("/backup/restore",e)}deleteAdminBackup(e){return this._adminPost("/backup/delete",e)}disableAdminAccountTwoFactor(e){return this._adminDelete(`/accounts/${e}/2fa`)}}}var P=class extends H(F(U(I(G(L(O(M(S)))))))){};function j(r){return class extends r{accountRegister(e){return this.http.post("/v1/account/register",e,!1)}accountWithdraw(e){return this.http.post("/v1/account/withdraw",e)}accountChangePassword(e){return this.http.post("/v1/account/change-password",e)}accountReactivate(e){return this.http.post("/v1/account/reactivate",e,!1)}listAccountBiometrics(){return this.http.get("/v1/account/biometric")}registerAccountBiometric(e){return this.http.post("/v1/account/biometric",e)}deleteAccountBiometric(e){return this.http.delete(`/v1/account/biometric/${e}`)}}}function K(r){return class extends r{listBoardCategories(e={}){let t=c(e);return this.http.get(`/v1/board/categories${t?`?${t}`:""}`,!1)}getBoardCategory(e){return this.http.get(`/v1/board/categories/${e}`,!1)}createBoardCategory(e){return this.http.post("/v1/board/categories",e)}updateBoardCategory(e,t){return this.http.put(`/v1/board/categories/${e}`,t)}deleteBoardCategory(e){return this.http.delete(`/v1/board/categories/${e}`)}listBoardPosts(e,t={}){let s=c(t);return this.http.get(`/v1/board/${e}/list${s?`?${s}`:""}`,!1)}getBoardPost(e){return this.http.get(`/v1/board/posts/${e}`,!1)}createBoardPost(e,t){return this.http.post(`/v1/board/${e}/submit`,t)}updateBoardPost(e,t){return this.http.put(`/v1/board/posts/${e}`,t)}deleteBoardPost(e){return this.http.delete(`/v1/board/posts/${e}`)}listBoardComments(e,t={}){let s=c(t);return this.http.get(`/v1/board/posts/${e}/comments${s?`?${s}`:""}`,!1)}createBoardComment(e,t){return this.http.post(`/v1/board/posts/${e}/comments/submit`,t)}updateBoardComment(e,t){return this.http.put(`/v1/board/comments/${e}`,t)}deleteBoardComment(e){return this.http.delete(`/v1/board/comments/${e}`)}listBoardFiles(e){return this.http.get(`/v1/board/posts/${e}/files`,!1)}async uploadBoardFile(e,t){let s=new FormData;return s.append("file",t,t instanceof File?t.name:"upload"),this.requestForm("POST",`/v1/board/posts/${e}/files`,s)}boardFileUrl(e){return`${this.baseUrl}/v1/board/files/${e}`}deleteBoardFile(e){return this.http.delete(`/v1/board/files/${e}`)}createBoardGuestPost(e,t){return this.http.post(`/v1/board/${e}/guest-submit`,t,!1)}authenticateBoardGuestPost(e,t){return this.http.post(`/v1/board/posts/${e}/guest-auth`,t,!1)}toggleBoardPostLike(e){return this.http.post(`/v1/board/posts/${e}/like`,{})}acceptBoardPost(e){return this.http.post(`/v1/board/posts/${e}/accept`,{})}rateBoardPost(e,t){return this.http.post(`/v1/board/posts/${e}/rating`,t)}rateBoardComment(e,t){return this.http.post(`/v1/board/comments/${e}/rating`,t)}listBoardTags(e={}){let t=c(e);return this.http.get(`/v1/board/tags${t?`?${t}`:""}`,!1)}setBoardPostTags(e,t){return this.http.put(`/v1/board/posts/${e}/tags`,t)}reportBoardPost(e,t){return this.http.post(`/v1/board/posts/${e}/report`,t)}reportBoardComment(e,t){return this.http.post(`/v1/board/comments/${e}/report`,t)}listBoardReports(e={}){let t=c(e);return this.http.get(`/v1/board/admin/reports${t?`?${t}`:""}`)}updateBoardReport(e,t){return this.http.patch(`/v1/board/admin/reports/${e}`,t)}markBoardPostRead(e){return this.http.post(`/v1/board/posts/${e}/read`,{})}listBoardMentions(e={}){let t=c(e);return this.http.get(`/v1/board/mentions${t?`?${t}`:""}`)}markBoardMentionRead(e){return this.http.patch(`/v1/board/mentions/${e}/read`,{})}}}function D(r){return class extends r{sendEmailVerification(e){return this.http.post("/v1/email-verify/send",e,!1)}confirmEmailVerification(e){return this.http.post("/v1/email-verify/confirm",e,!1)}activateEmailVerification(e){let t=c(e);return this.http.get(`/v1/email-verify/activate${t?`?${t}`:""}`,!1)}getEmailVerificationStatus(){return this.http.get("/v1/email-verify/status")}changeVerifiedEmail(e){return this.http.post("/v1/email-verify/change",e)}}}function N(r){return class extends r{oauthAuthorizeUrl(e,t={}){let s=c(t);return`${this.baseUrl}/v1/oauth/${e}${s?`?${s}`:""}`}oauthCallback(e,t,s="POST"){if(s==="GET"){let i=c(t??{});return this.http.get(`/v1/oauth/${e}/callback${i?`?${i}`:""}`,!1)}return this.http.post(`/v1/oauth/${e}/callback`,t,!1)}linkOAuthAccount(e){return this.http.post("/v1/account/oauth/link",e)}unlinkOAuthAccount(e){return this.http.delete(`/v1/account/oauth/link/${e}`)}listOAuthProviders(){return this.http.get("/v1/account/oauth/providers")}refreshOAuthProviderToken(e,t){return this.http.post(`/v1/account/oauth/refresh/${e}`,t)}}}function V(r){return class extends r{requestPasswordReset(e){return this.http.post("/v1/password-reset/request",e,!1)}validatePasswordResetToken(e){return this.http.get(`/v1/password-reset/validate/${encodeURIComponent(e)}`,!1)}verifyPasswordReset(e){return this.http.post("/v1/password-reset/verify",e,!1)}}}function Q(r){return class extends r{setupTwoFactor(e){return this.http.post("/v1/account/2fa/setup",e)}verifyTwoFactorSetup(e){return this.http.post("/v1/account/2fa/setup/verify",e,!1)}disableTwoFactor(){return this.http.delete("/v1/account/2fa")}getTwoFactorStatus(){return this.http.get("/v1/account/2fa/status")}regenerateTwoFactorRecoveryCodes(){return this.http.post("/v1/account/2fa/recovery/regenerate")}verifyTwoFactor(e){return this.http.post("/v1/account/2fa/verify",e,!1)}recoverTwoFactorAccess(e){return this.http.post("/v1/account/2fa/recovery",e,!1)}}}function z(r){return class extends r{alimtalkSend(e){return this.http.post("/v1/alimtalk/send",e)}alimtalkStatus(e){return this.http.get(`/v1/alimtalk/status/${e}`,!1)}listAlimtalkTemplates(){return this.http.get("/v1/alimtalk/templates",!1)}alimtalkWebhook(e,t){return this.http.post(`/v1/alimtalk/webhook/${encodeURIComponent(e)}`,t,!1)}}}function X(r){return class extends r{friendtalkSend(e){return this.http.post("/v1/friendtalk/send",e)}}}function J(r){return class extends r{listHolidays(e={}){let t=c(e);return this.http.get(`/v1/holidays${t?`?${t}`:""}`,!1)}getHolidayByDate(e){return this.http.get(`/v1/holidays/${encodeURIComponent(e)}`,!1)}syncHolidays(e){return this.http.post("/v1/holidays/sync",e)}}}function W(r){return class extends r{identityRequest(e){return this.http.post("/v1/identity/request",e,!1)}identityCallback(e){return this.http.post("/v1/identity/callback",e,!1)}identityResult(e){return this.http.get(`/v1/identity/result/${encodeURIComponent(e)}`,!1)}identityVerifyCI(e){return this.http.post("/v1/identity/verify-ci",e)}}}function Y(r){return class extends r{llmChat(e){return this.http.post("/v1/llm/chat",e)}llmChatStream(e){return this.http.post("/v1/llm/chat/stream",e)}createLlmConversation(e){return this.http.post("/v1/llm/conversations",e)}sendLlmMessage(e,t){return this.http.post(`/v1/llm/conversations/${e}/messages`,t)}listLlmConversations(e={}){let t=c(e);return this.http.get(`/v1/llm/conversations${t?`?${t}`:""}`)}getLlmConversation(e){return this.http.get(`/v1/llm/conversations/${e}`)}updateLlmConversation(e,t){return this.http.patch(`/v1/llm/conversations/${e}`,t)}deleteLlmConversation(e){return this.http.delete(`/v1/llm/conversations/${e}`)}ragUploadDocument(e){return this.requestForm("POST","/v1/llm/rag/documents",e)}ragListDocuments(e={}){let t=c(e);return this.http.get(`/v1/llm/rag/documents${t?`?${t}`:""}`)}ragDeleteDocument(e){return this.http.delete(`/v1/llm/rag/documents/${encodeURIComponent(e)}`)}ragSearch(e){return this.http.post("/v1/llm/rag/search",e)}ragChat(e){return this.http.post("/v1/llm/rag/chat",e)}ragChatStream(e){return this.http.post("/v1/llm/rag/chat/stream",e)}ragRebuildIndex(e){return this.http.post("/v1/llm/rag/rebuild-index",e)}listLlmProviders(){return this.http.get("/v1/llm/providers")}getLlmUsage(e={}){let t=c(e);return this.http.get(`/v1/llm/usage${t?`?${t}`:""}`)}getLlmUsageSummary(e={}){let t=c(e);return this.http.get(`/v1/llm/usage/summary${t?`?${t}`:""}`)}getLlmCacheStats(){return this.http.get("/v1/llm/cache/stats")}clearLlmCache(){return this.http.delete("/v1/llm/cache")}listLlmTemplates(){return this.http.get("/v1/llm/templates")}llmTemplateChat(e,t){return this.http.post(`/v1/llm/${encodeURIComponent(e)}/chat`,t)}llmTemplateChatStream(e,t){return this.http.post(`/v1/llm/${encodeURIComponent(e)}/chat/stream`,t)}listLlmChatbots(e={}){let t=c(e);return this.http.get(`/v1/llm/chatbots${t?`?${t}`:""}`)}createLlmChatbot(e){return this.http.post("/v1/llm/chatbots",e)}getLlmChatbot(e){return this.http.get(`/v1/llm/chatbots/${e}`)}updateLlmChatbot(e,t){return this.http.patch(`/v1/llm/chatbots/${e}`,t)}deleteLlmChatbot(e){return this.http.delete(`/v1/llm/chatbots/${e}`)}llmChatbotChat(e,t){return this.http.post(`/v1/llm/chatbots/${e}/chat`,t)}llmChatbotChatStream(e,t){return this.http.post(`/v1/llm/chatbots/${e}/chat/stream`,t)}listLlmChatbotSessions(e,t={}){let s=c(t);return this.http.get(`/v1/llm/chatbots/${e}/sessions${s?`?${s}`:""}`)}deleteLlmChatbotSession(e,t){return this.http.delete(`/v1/llm/chatbots/${e}/sessions/${t}`)}listLlmProfiles(e={}){let t=c(e);return this.http.get(`/v1/llm/profiles${t?`?${t}`:""}`)}upsertLlmProfile(e){return this.http.post("/v1/llm/profiles",e)}deleteLlmProfile(e){return this.http.delete(`/v1/llm/profiles/${e}`)}}}function Z(r){return class extends r{ocrRecognize(e){return this.requestForm("POST","/v1/ocr/recognize",e)}ocrRecognizeAsync(e){return this.requestForm("POST","/v1/ocr/recognize/async",e)}ocrRecognizeByDocType(e,t){return this.requestForm("POST",`/v1/ocr/${encodeURIComponent(e)}`,t)}listOcrResults(e={}){let t=c(e);return this.http.get(`/v1/ocr/results${t?`?${t}`:""}`)}getOcrResult(e){return this.http.get(`/v1/ocr/results/${encodeURIComponent(e)}`)}getOcrResultText(e){return this.http.get(`/v1/ocr/results/${encodeURIComponent(e)}/text`)}deleteOcrResult(e){return this.http.delete(`/v1/ocr/results/${encodeURIComponent(e)}`)}getOcrQuota(){return this.http.get("/v1/ocr/quota")}}}function ee(r){return class extends r{pgCreateOrder(e){return this.http.post("/v1/pg/orders",e)}pgGetOrder(e){return this.http.get(`/v1/pg/orders/${encodeURIComponent(e)}`)}pgConfirmPayment(e){return this.http.post("/v1/pg/confirm",e)}pgCancelPayment(e,t){return this.http.post(`/v1/pg/orders/${encodeURIComponent(e)}/cancel`,t)}pgSyncPaymentStatus(e,t){return this.http.post(`/v1/pg/orders/${encodeURIComponent(e)}/sync`,t)}pgWebhook(e){return this.http.post("/v1/pg/webhook",e,!1)}pgGetClientConfig(){return this.http.get("/v1/pg/config",!1)}}}function te(r){return class extends r{appPushSend(e){return this.http.post("/v1/push/send",e)}appPushBroadcast(e){return this.http.post("/v1/push/broadcast",e)}appPushStatus(e){return this.http.get(`/v1/push/status/${e}`)}appPushRegisterDevice(e){return this.http.post("/v1/push/device",e)}appPushUnregisterDevice(e){return this.http.delete(`/v1/push/device/${e}`)}}}function ne(r){return class extends r{smsSend(e){return this.http.post("/v1/sms/send",e)}smsStatus(e){return this.http.get(`/v1/sms/status/${e}`,!1)}smsVerificationSend(e){return this.http.post("/v1/sms/verification/send",e,!1)}smsVerificationVerify(e){return this.http.post("/v1/sms/verification/verify",e,!1)}}}function re(r){return class extends r{taxinvoiceRegistIssue(e){return this.http.post("/v1/taxinvoice",e)}taxinvoiceRegister(e){return this.http.post("/v1/taxinvoice/register",e)}taxinvoiceIssue(e){return this.http.post(`/v1/taxinvoice/${e}/issue`,{})}taxinvoiceCancelIssue(e,t){return this.http.post(`/v1/taxinvoice/${e}/cancel`,t)}taxinvoiceGetState(e){return this.http.get(`/v1/taxinvoice/${e}/state`)}taxinvoiceGetDetail(e){return this.http.get(`/v1/taxinvoice/${e}`)}}}var _=class extends z(X(ne(te(ee(re(Z(Y(W(J(N(Q(V(D(K(j(P)))))))))))))))){};var Mn=new P,On=new _;export{j as AccountAppMixin,L as AdminMixin,M as AuthMixin,K as BoardMixin,D as EmailVerifyMixin,_ as EntityAppServerApi,O as EntityMixin,P as EntityServerApi,U as FileMixin,N as OAuthMixin,Ce as PACKET_HKDF_SALT,Se as PACKET_INFO_LABEL,E as PACKET_KEY_SIZE,A as PACKET_MAGIC_MIN,q as PACKET_MAGIC_RANGE,k as PACKET_NONCE_SIZE,Re as PACKET_TAG_SIZE,V as PasswordResetMixin,G as PushMixin,I as SmtpMixin,F as TransactionMixin,Q as TwoFactorMixin,H as UtilsMixin,de as decryptPacket,ce as derivePacketKey,le as encryptPacket,On as entityAppServer,Mn as entityServer,me as packetMagicLenFromKey};
2
2
  //# sourceMappingURL=index.js.map