appos 0.3.5-0 → 0.3.7-0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (242) hide show
  1. package/dist/bin/main.mjs +3 -3
  2. package/dist/bin/youch-handler-D7REmh8Z.mjs +2 -0
  3. package/dist/exports/api/adapter-C2mMJKvG.mjs +1504 -0
  4. package/dist/exports/api/{auth-schema.mjs → auth-schema-CON4yFFY.mjs} +2 -3
  5. package/dist/exports/api/bun-sqlite-dialect-CPpPZa23.mjs +155 -0
  6. package/dist/exports/{cli/_virtual/rolldown_runtime.mjs → api/chunk-CyXqrcp_.mjs} +14 -1
  7. package/dist/exports/api/conditions-DjBAWfiK.mjs +116 -0
  8. package/dist/exports/api/dialect-CUUD24Ge.mjs +72 -0
  9. package/dist/exports/api/env-CwT3zhez.mjs +1 -0
  10. package/dist/exports/api/esm-_hkVMulx.mjs +15816 -0
  11. package/dist/exports/api/event-BHFSE6hY.mjs +20983 -0
  12. package/dist/exports/api/extract-blob-metadata-BMgUEPcW.mjs +4 -0
  13. package/dist/exports/api/extract-blob-metadata-_9RUEwoU.mjs +9818 -0
  14. package/dist/exports/api/generate-image-variant-DOIzj1wJ.mjs +4 -0
  15. package/dist/exports/api/generate-image-variant-DxOPoGAk.mjs +118 -0
  16. package/dist/exports/api/generate-preview-CvTFuq58.mjs +160 -0
  17. package/dist/exports/api/generate-preview-Dk3coswZ.mjs +4 -0
  18. package/dist/exports/api/index.d.mts +7347 -20
  19. package/dist/exports/api/index.mjs +146856 -18
  20. package/dist/exports/api/kysely-adapter-CmP2TbkS.mjs +296 -0
  21. package/dist/exports/api/memory-adapter-BzhRhLFK.mjs +212 -0
  22. package/dist/exports/api/node-sqlite-dialect-Bl5suBxl.mjs +155 -0
  23. package/dist/exports/api/orm-CMqufD21.mjs +153690 -0
  24. package/dist/exports/api/orm-DXqYuKvB.d.mts +11 -0
  25. package/dist/exports/api/orm.d.mts +2 -11
  26. package/dist/exports/api/orm.mjs +4 -42
  27. package/dist/exports/api/pdf-YxB2Hm1p.mjs +25822 -0
  28. package/dist/exports/api/purge-attachment-Cf6KH2Jv.mjs +34 -0
  29. package/dist/exports/api/purge-attachment-DIuil7ps.mjs +4 -0
  30. package/dist/exports/{cli/api/workflows/purge-audit-logs.mjs → api/purge-audit-logs-z6j_Pu47.mjs} +3 -3
  31. package/dist/exports/{cli/api/workflows/purge-unattached-blobs.mjs → api/purge-unattached-blobs-B0TfY5Hk.mjs} +1 -1
  32. package/dist/exports/api/react-BYhV5bYt.mjs +1131 -0
  33. package/dist/exports/api/server.node-DyVrQ6cz.mjs +19298 -0
  34. package/dist/exports/api/table-6bTIEqON.mjs +2636 -0
  35. package/dist/exports/api/{workflows/track-db-changes.mjs → track-db-changes-BysaV6nN.mjs} +14 -14
  36. package/dist/exports/api/{workflow.mjs → workflow-BuSWHcX-.mjs} +121 -10
  37. package/dist/exports/api/workflows/auth-schema-BFve3hgZ.mjs +2813 -0
  38. package/dist/exports/api/workflows/{_virtual/rolldown_runtime.mjs → chunk-B36mNPO4.mjs} +5 -1
  39. package/dist/exports/api/workflows/extract-blob-metadata-BcWKvY2K.mjs +9818 -0
  40. package/dist/exports/{cli/api/workflows/generate-image-variant.mjs → api/workflows/generate-image-variant-BAFvL_zV.mjs} +20 -20
  41. package/dist/exports/{cli/api/workflows/generate-preview.mjs → api/workflows/generate-preview-BjlIVYYp.mjs} +6 -6
  42. package/dist/exports/api/workflows/index.d.mts +2011 -1
  43. package/dist/exports/api/workflows/index.mjs +2 -1
  44. package/dist/exports/api/workflows/pdf-DUB8zyIc.mjs +25822 -0
  45. package/dist/exports/{cli/api/workflows/purge-attachment.mjs → api/workflows/purge-attachment-k_sdxTPY.mjs} +3 -3
  46. package/dist/exports/api/workflows/{purge-audit-logs.mjs → purge-audit-logs-zCyWj4Mw.mjs} +12 -3
  47. package/dist/exports/api/workflows/{purge-unattached-blobs.mjs → purge-unattached-blobs-CdsuFAeW.mjs} +1 -1
  48. package/dist/exports/api/workflows/track-db-changes-CiKaI9gT.mjs +20943 -0
  49. package/dist/exports/api/workflows/track-db-changes-DEWQYryO.mjs +4 -0
  50. package/dist/exports/{cli/api/workflow.mjs → api/workflows/workflow-BjM2xCa6.mjs} +23 -3
  51. package/dist/exports/api/workflows/zod-Br0enFWK.mjs +12333 -0
  52. package/dist/exports/api/zod-CdrJdBtV.mjs +12571 -0
  53. package/dist/exports/cli/auth-schema-CNuOqPi-.mjs +2813 -0
  54. package/dist/exports/{api/_virtual/rolldown_runtime.mjs → cli/chunk-B36mNPO4.mjs} +5 -1
  55. package/dist/exports/cli/extract-blob-metadata-CV1Ke90d.mjs +9818 -0
  56. package/dist/exports/{api/workflows/generate-image-variant.mjs → cli/generate-image-variant-CM1BrVvZ.mjs} +20 -20
  57. package/dist/exports/{api/workflows/generate-preview.mjs → cli/generate-preview-DdHQ3ukz.mjs} +6 -6
  58. package/dist/exports/cli/index.d.mts +2142 -2
  59. package/dist/exports/cli/index.mjs +41 -1
  60. package/dist/exports/cli/pdf-CLUPEIdT.mjs +25822 -0
  61. package/dist/exports/{api/workflows/purge-attachment.mjs → cli/purge-attachment-Dc_J74dG.mjs} +3 -3
  62. package/dist/exports/cli/purge-audit-logs-DFhWh-Bx.mjs +56 -0
  63. package/dist/exports/cli/purge-unattached-blobs-C1MRlM_2.mjs +46 -0
  64. package/dist/exports/cli/track-db-changes-CfneOF2_.mjs +20943 -0
  65. package/dist/exports/{api/workflows/api/workflow.mjs → cli/workflow-DSbbXBMt.mjs} +23 -3
  66. package/dist/exports/cli/zod-7q0_Mtnn.mjs +12333 -0
  67. package/dist/exports/tests/api.d.mts +7354 -5
  68. package/dist/exports/tests/api.mjs +79 -1
  69. package/dist/exports/tests/auth-schema-B_qHPoa4.mjs +1 -0
  70. package/dist/exports/tests/chunk-Cii4FAhs.mjs +1 -0
  71. package/dist/exports/tests/conditions-BeWxRN_Z.mjs +1 -0
  72. package/dist/exports/tests/constants-D_m07gCJ.mjs +1 -0
  73. package/dist/exports/tests/dist-Cx2HEBOB.mjs +296 -0
  74. package/dist/exports/tests/dist-DnACOvNW.mjs +7 -0
  75. package/dist/exports/tests/extract-blob-metadata-6xQrarjB.mjs +169 -0
  76. package/dist/exports/tests/generate-image-variant-KQITLmCx.mjs +1 -0
  77. package/dist/exports/tests/generate-preview-YnujQo5I.mjs +1 -0
  78. package/dist/exports/tests/mock-BvoS23fi.mjs +1 -0
  79. package/dist/exports/tests/mock.mjs +1 -1
  80. package/dist/exports/tests/pdf-lZ-as2o7.mjs +13 -0
  81. package/dist/exports/tests/purge-attachment-DTSmCl-z.mjs +1 -0
  82. package/dist/exports/tests/purge-audit-logs-D0_UUhN2.mjs +1 -0
  83. package/dist/exports/tests/purge-unattached-blobs-IENmSB8K.mjs +1 -0
  84. package/dist/exports/tests/react.mjs +6 -1
  85. package/dist/exports/tests/setup.d.mts +1 -1
  86. package/dist/exports/tests/setup.mjs +34 -1
  87. package/dist/exports/tests/table-CmPSf_pE.mjs +1 -0
  88. package/dist/exports/tests/track-db-changes-Td9Q3DLd.mjs +1 -0
  89. package/dist/exports/tests/{api/workflow.mjs → workflow-BWRWyC83.mjs} +1 -1
  90. package/dist/exports/tests/youch-handler-efUxKCCs.mjs +1 -0
  91. package/dist/exports/tests/zod-CkJO9qpV.mjs +23 -0
  92. package/dist/exports/vendors/date.js +13236 -1
  93. package/dist/exports/vendors/toolkit.js +2206 -1
  94. package/dist/exports/vendors/zod.js +12344 -1
  95. package/dist/exports/vite/index.d.mts +1 -1
  96. package/dist/exports/vite/index.mjs +26 -1
  97. package/dist/exports/vite/lib-B0s0q6aX.mjs +382 -0
  98. package/dist/exports/vite/lib-BkrbWMaV.mjs +1 -0
  99. package/dist/exports/web/browser-ponyfill-DxTJMXNq.js +443 -0
  100. package/dist/exports/web/chunk-DksrlJLg.js +49 -0
  101. package/dist/exports/web/index.d.ts +2546 -2
  102. package/dist/exports/web/index.js +9295 -6
  103. package/dist/exports/web/plugin-DqTFWG7p.js +250 -0
  104. package/package.json +1 -7
  105. package/dist/bin/youch-handler-DrYdbUhe.mjs +0 -2
  106. package/dist/exports/api/app-context.d.mts +0 -115
  107. package/dist/exports/api/app-context.mjs +0 -24
  108. package/dist/exports/api/auth-schema.d.mts +0 -4248
  109. package/dist/exports/api/auth.d.mts +0 -402
  110. package/dist/exports/api/auth.mjs +0 -188
  111. package/dist/exports/api/cache.d.mts +0 -44
  112. package/dist/exports/api/cache.mjs +0 -28
  113. package/dist/exports/api/config.d.mts +0 -28
  114. package/dist/exports/api/config.mjs +0 -72
  115. package/dist/exports/api/constants.mjs +0 -92
  116. package/dist/exports/api/container.d.mts +0 -210
  117. package/dist/exports/api/container.mjs +0 -49
  118. package/dist/exports/api/database.d.mts +0 -101
  119. package/dist/exports/api/database.mjs +0 -219
  120. package/dist/exports/api/event.d.mts +0 -235
  121. package/dist/exports/api/event.mjs +0 -236
  122. package/dist/exports/api/i18n.d.mts +0 -34
  123. package/dist/exports/api/i18n.mjs +0 -45
  124. package/dist/exports/api/instrumentation.d.mts +0 -7
  125. package/dist/exports/api/instrumentation.mjs +0 -40
  126. package/dist/exports/api/logger.d.mts +0 -21
  127. package/dist/exports/api/logger.mjs +0 -26
  128. package/dist/exports/api/mailer.d.mts +0 -70
  129. package/dist/exports/api/mailer.mjs +0 -37
  130. package/dist/exports/api/middleware/request-logger.d.mts +0 -24
  131. package/dist/exports/api/middleware.d.mts +0 -39
  132. package/dist/exports/api/middleware.mjs +0 -73
  133. package/dist/exports/api/openapi.d.mts +0 -271
  134. package/dist/exports/api/openapi.mjs +0 -507
  135. package/dist/exports/api/otel.d.mts +0 -40
  136. package/dist/exports/api/otel.mjs +0 -56
  137. package/dist/exports/api/redis.d.mts +0 -34
  138. package/dist/exports/api/redis.mjs +0 -41
  139. package/dist/exports/api/storage-schema.d.mts +0 -707
  140. package/dist/exports/api/storage-schema.mjs +0 -72
  141. package/dist/exports/api/storage.d.mts +0 -506
  142. package/dist/exports/api/storage.mjs +0 -833
  143. package/dist/exports/api/web/auth.mjs +0 -17
  144. package/dist/exports/api/workflow.d.mts +0 -250
  145. package/dist/exports/api/workflows/api/auth-schema.mjs +0 -373
  146. package/dist/exports/api/workflows/api/auth.d.mts +0 -379
  147. package/dist/exports/api/workflows/api/cache.d.mts +0 -44
  148. package/dist/exports/api/workflows/api/config.d.mts +0 -18
  149. package/dist/exports/api/workflows/api/container.d.mts +0 -167
  150. package/dist/exports/api/workflows/api/database.d.mts +0 -47
  151. package/dist/exports/api/workflows/api/event.d.mts +0 -68
  152. package/dist/exports/api/workflows/api/event.mjs +0 -126
  153. package/dist/exports/api/workflows/api/logger.d.mts +0 -21
  154. package/dist/exports/api/workflows/api/mailer.d.mts +0 -70
  155. package/dist/exports/api/workflows/api/orm.d.mts +0 -13
  156. package/dist/exports/api/workflows/api/redis.mjs +0 -3
  157. package/dist/exports/api/workflows/api/storage-schema.d.mts +0 -699
  158. package/dist/exports/api/workflows/api/storage.d.mts +0 -396
  159. package/dist/exports/api/workflows/api/workflow.d.mts +0 -24
  160. package/dist/exports/api/workflows/constants.mjs +0 -23
  161. package/dist/exports/api/workflows/extract-blob-metadata.mjs +0 -132
  162. package/dist/exports/api/workflows/generate-image-variant.d.mts +0 -63
  163. package/dist/exports/api/workflows/track-db-changes.d.mts +0 -72
  164. package/dist/exports/cli/api/auth-schema.mjs +0 -373
  165. package/dist/exports/cli/api/auth.d.mts +0 -379
  166. package/dist/exports/cli/api/cache.d.mts +0 -44
  167. package/dist/exports/cli/api/config.d.mts +0 -18
  168. package/dist/exports/cli/api/container.d.mts +0 -167
  169. package/dist/exports/cli/api/database.d.mts +0 -47
  170. package/dist/exports/cli/api/event.d.mts +0 -68
  171. package/dist/exports/cli/api/event.mjs +0 -126
  172. package/dist/exports/cli/api/logger.d.mts +0 -21
  173. package/dist/exports/cli/api/mailer.d.mts +0 -70
  174. package/dist/exports/cli/api/orm.d.mts +0 -13
  175. package/dist/exports/cli/api/redis.mjs +0 -3
  176. package/dist/exports/cli/api/storage-schema.d.mts +0 -699
  177. package/dist/exports/cli/api/storage.d.mts +0 -396
  178. package/dist/exports/cli/api/workflow.d.mts +0 -2
  179. package/dist/exports/cli/api/workflows/extract-blob-metadata.mjs +0 -132
  180. package/dist/exports/cli/api/workflows/generate-image-variant.d.mts +0 -63
  181. package/dist/exports/cli/api/workflows/track-db-changes.mjs +0 -110
  182. package/dist/exports/cli/command.d.mts +0 -56
  183. package/dist/exports/cli/command.mjs +0 -43
  184. package/dist/exports/cli/constants.mjs +0 -23
  185. package/dist/exports/cli/context.d.mts +0 -170
  186. package/dist/exports/devtools/index.d.ts +0 -3
  187. package/dist/exports/devtools/index.js +0 -4
  188. package/dist/exports/tests/_virtual/rolldown_runtime.mjs +0 -1
  189. package/dist/exports/tests/api/app-context.d.mts +0 -115
  190. package/dist/exports/tests/api/app-context.mjs +0 -1
  191. package/dist/exports/tests/api/auth-schema.d.mts +0 -4248
  192. package/dist/exports/tests/api/auth-schema.mjs +0 -1
  193. package/dist/exports/tests/api/auth.d.mts +0 -402
  194. package/dist/exports/tests/api/cache.d.mts +0 -44
  195. package/dist/exports/tests/api/config.d.mts +0 -28
  196. package/dist/exports/tests/api/container.d.mts +0 -210
  197. package/dist/exports/tests/api/database.d.mts +0 -101
  198. package/dist/exports/tests/api/database.mjs +0 -1
  199. package/dist/exports/tests/api/event.d.mts +0 -235
  200. package/dist/exports/tests/api/event.mjs +0 -1
  201. package/dist/exports/tests/api/i18n.d.mts +0 -34
  202. package/dist/exports/tests/api/index.d.mts +0 -26
  203. package/dist/exports/tests/api/logger.d.mts +0 -21
  204. package/dist/exports/tests/api/mailer.d.mts +0 -70
  205. package/dist/exports/tests/api/middleware/error-handler.mjs +0 -1
  206. package/dist/exports/tests/api/middleware/health.mjs +0 -1
  207. package/dist/exports/tests/api/middleware/i18n.mjs +0 -1
  208. package/dist/exports/tests/api/middleware/request-logger.d.mts +0 -24
  209. package/dist/exports/tests/api/middleware/request-logger.mjs +0 -1
  210. package/dist/exports/tests/api/middleware/shutdown.mjs +0 -1
  211. package/dist/exports/tests/api/middleware/timeout.mjs +0 -1
  212. package/dist/exports/tests/api/middleware/youch-handler.mjs +0 -1
  213. package/dist/exports/tests/api/middleware.d.mts +0 -39
  214. package/dist/exports/tests/api/middleware.mjs +0 -1
  215. package/dist/exports/tests/api/openapi.d.mts +0 -271
  216. package/dist/exports/tests/api/openapi.mjs +0 -1
  217. package/dist/exports/tests/api/orm.d.mts +0 -13
  218. package/dist/exports/tests/api/otel.d.mts +0 -40
  219. package/dist/exports/tests/api/redis.d.mts +0 -34
  220. package/dist/exports/tests/api/redis.mjs +0 -1
  221. package/dist/exports/tests/api/server.mjs +0 -1
  222. package/dist/exports/tests/api/storage-schema.d.mts +0 -707
  223. package/dist/exports/tests/api/storage.d.mts +0 -506
  224. package/dist/exports/tests/api/workflow.d.mts +0 -250
  225. package/dist/exports/tests/api/workflows/extract-blob-metadata.mjs +0 -1
  226. package/dist/exports/tests/api/workflows/generate-image-variant.d.mts +0 -63
  227. package/dist/exports/tests/api/workflows/generate-image-variant.mjs +0 -1
  228. package/dist/exports/tests/api/workflows/generate-preview.mjs +0 -1
  229. package/dist/exports/tests/api/workflows/purge-attachment.mjs +0 -1
  230. package/dist/exports/tests/api/workflows/purge-audit-logs.mjs +0 -1
  231. package/dist/exports/tests/api/workflows/purge-unattached-blobs.mjs +0 -1
  232. package/dist/exports/tests/api/workflows/track-db-changes.mjs +0 -1
  233. package/dist/exports/tests/constants.mjs +0 -1
  234. package/dist/exports/tests/instrumentation.d.mts +0 -7
  235. package/dist/exports/tests/instrumentation.mjs +0 -1
  236. package/dist/exports/web/api/auth.d.ts +0 -125
  237. package/dist/exports/web/api/database.d.ts +0 -4
  238. package/dist/exports/web/api/logger.d.ts +0 -1
  239. package/dist/exports/web/auth.d.ts +0 -2388
  240. package/dist/exports/web/auth.js +0 -75
  241. package/dist/exports/web/i18n.d.ts +0 -42
  242. package/dist/exports/web/i18n.js +0 -45
@@ -1,379 +0,0 @@
1
- import { Database, QualifiedTableNames } from "./database.mjs";
2
- import { z } from "zod";
3
- import { betterAuth } from "better-auth";
4
- import { Role, createAccessControl } from "better-auth/plugins/access";
5
-
6
- //#region src/api/auth.d.ts
7
-
8
- /**
9
- * Type for access controller created via createAccessControl().
10
- * Used for RBAC on both server and client.
11
- */
12
- type AccessController = ReturnType<typeof createAccessControl>;
13
- /**
14
- * Type for roles created via ac.newRole().
15
- * Uses Role type from better-auth for compatibility.
16
- */
17
- type AccessControlRoles = Record<string, Role>;
18
- /**
19
- * Type-safe audit log options for defineAuth().
20
- * Generic over db object to provide autocomplete for excludeTables.
21
- *
22
- * @template TDb - Database record type for table name inference
23
- */
24
- type AuditLogOptions<TDb> = {
25
- /**
26
- * Tables to exclude from audit logging.
27
- */
28
- excludeTables?: QualifiedTableNames<TDb>[];
29
- /**
30
- * Cron expression for purge schedule.
31
- *
32
- * @default "0 0 * * *"
33
- */
34
- purgeCron?: string;
35
- /**
36
- * Retention period in days. Audit logs older than this are auto-deleted.
37
- * @default 90
38
- */
39
- retentionDays?: number;
40
- };
41
- /**
42
- * Neutral auth configuration - shared between server and client.
43
- * Contains ONLY fields that affect both sides (UI + server features).
44
- *
45
- * PRESENCE-BASED CONFIG: If a key exists, it's enabled. No redundant `enabled` fields.
46
- * Server-only fields (appName, session) are passed via DefineAuthOptions.
47
- */
48
- interface AuthConfig {
49
- /**
50
- * Base URL where auth server is hosted.
51
- *
52
- * @default "" (same origin - client uses relative URLs)
53
- * @example "http://localhost:8000" for cross-origin
54
- */
55
- baseURL?: string;
56
- /**
57
- * Base path for auth routes.
58
- *
59
- * @default "/auth"
60
- */
61
- basePath?: string;
62
- /** Authentication methods - if defined, it's enabled */
63
- methods?: {
64
- /** Email/password auth. If defined, enabled. */
65
- emailPassword?: {
66
- requireEmailVerification?: boolean;
67
- minPasswordLength?: number;
68
- maxPasswordLength?: number;
69
- };
70
- /** Magic link auth. If defined, enabled. */
71
- magicLink?: {
72
- expiresIn?: number;
73
- };
74
- /** Passkey auth. If defined (even as empty object), enabled. */
75
- passkey?: Record<string, never>;
76
- /** Phone OTP auth. If defined, enabled. */
77
- phoneOtp?: {
78
- otpLength?: number;
79
- expiresIn?: number;
80
- };
81
- /** Email OTP auth. If defined, enabled. */
82
- emailOtp?: {
83
- otpLength?: number;
84
- expiresIn?: number;
85
- };
86
- };
87
- /** OAuth providers - true = enabled, undefined/false = disabled */
88
- oauth?: {
89
- google?: boolean;
90
- github?: boolean;
91
- apple?: boolean;
92
- facebook?: boolean;
93
- };
94
- /** Plugins - if defined, it's enabled */
95
- plugins?: {
96
- /** Admin plugin. If defined, enabled. Includes RBAC for both server and client. */
97
- admin?: {
98
- defaultRole?: string;
99
- adminRoles?: string[];
100
- /** Access controller created via createAccessControl() - shared between server and client */
101
- ac: AccessController;
102
- /** Role definitions created via ac.newRole() - shared between server and client */
103
- roles: AccessControlRoles;
104
- };
105
- /** API key plugin. If defined, enabled. */
106
- apiKey?: {
107
- defaultPrefix?: string;
108
- defaultKeyLength?: number;
109
- rateLimit?: {
110
- maxRequests?: number;
111
- timeWindow?: number;
112
- };
113
- };
114
- /** Two-factor plugin. If defined, enabled. Sub-features also presence-based. */
115
- twoFactor?: {
116
- issuer?: string;
117
- totp?: {
118
- digits?: 6 | 8;
119
- period?: number;
120
- };
121
- otp?: boolean;
122
- backupCodes?: {
123
- amount?: number;
124
- length?: number;
125
- };
126
- };
127
- /** Multi-session plugin. If defined, enabled. */
128
- multiSession?: {
129
- maximumSessions?: number;
130
- };
131
- /** Username plugin. If defined, enabled. */
132
- username?: {
133
- minUsernameLength?: number;
134
- maxUsernameLength?: number;
135
- };
136
- /** Anonymous auth plugin. If defined, enabled. */
137
- anonymous?: {
138
- emailDomainName?: string;
139
- };
140
- /** SSO plugin. If defined, enabled. Import from @better-auth/sso */
141
- sso?: {
142
- providersLimit?: number;
143
- trustEmailVerified?: boolean;
144
- domainVerification?: boolean;
145
- };
146
- };
147
- }
148
- /** Base hook types for reference */
149
- type EmailHook = (params: {
150
- email: string;
151
- url: string;
152
- token: string;
153
- }) => Promise<void>;
154
- type OtpHook = (params: {
155
- email: string;
156
- otp: string;
157
- }) => Promise<void>;
158
- type PhoneOtpHook = (params: {
159
- phoneNumber: string;
160
- otp: string;
161
- }) => Promise<void>;
162
- /**
163
- * Conditionally required hooks based on config.
164
- * Uses PRESENCE-BASED detection - if key exists, hook is REQUIRED.
165
- */
166
- type RequiredHooks<T extends AuthConfig> = (T["methods"] extends {
167
- emailPassword: {
168
- requireEmailVerification: true;
169
- };
170
- } ? {
171
- sendVerificationEmail: EmailHook;
172
- } : {
173
- sendVerificationEmail?: EmailHook;
174
- }) & (T["methods"] extends {
175
- emailPassword: object;
176
- } ? {
177
- sendResetPasswordEmail: EmailHook;
178
- } : {
179
- sendResetPasswordEmail?: EmailHook;
180
- }) & (T["methods"] extends {
181
- magicLink: object;
182
- } ? {
183
- sendMagicLink: EmailHook;
184
- } : {
185
- sendMagicLink?: EmailHook;
186
- }) & (T["methods"] extends {
187
- emailOtp: object;
188
- } ? {
189
- sendEmailOTP: OtpHook;
190
- } : {
191
- sendEmailOTP?: OtpHook;
192
- }) & (T["methods"] extends {
193
- phoneOtp: object;
194
- } ? {
195
- sendPhoneOTP: PhoneOtpHook;
196
- } : {
197
- sendPhoneOTP?: PhoneOtpHook;
198
- }) & (T["plugins"] extends {
199
- twoFactor: {
200
- otp: true;
201
- };
202
- } ? {
203
- send2FAOTP: OtpHook;
204
- } : {
205
- send2FAOTP?: OtpHook;
206
- });
207
- /**
208
- * Conditionally required OAuth credentials based on config.
209
- * If an OAuth provider is enabled in config, its credentials are REQUIRED.
210
- */
211
- type RequiredOAuth<T extends AuthConfig> = (T["oauth"] extends {
212
- google: true;
213
- } ? {
214
- google: {
215
- clientId: string;
216
- clientSecret: string;
217
- };
218
- } : {
219
- google?: {
220
- clientId: string;
221
- clientSecret: string;
222
- };
223
- }) & (T["oauth"] extends {
224
- github: true;
225
- } ? {
226
- github: {
227
- clientId: string;
228
- clientSecret: string;
229
- };
230
- } : {
231
- github?: {
232
- clientId: string;
233
- clientSecret: string;
234
- };
235
- }) & (T["oauth"] extends {
236
- apple: true;
237
- } ? {
238
- apple: {
239
- clientId: string;
240
- clientSecret: string;
241
- };
242
- } : {
243
- apple?: {
244
- clientId: string;
245
- clientSecret: string;
246
- };
247
- }) & (T["oauth"] extends {
248
- facebook: true;
249
- } ? {
250
- facebook: {
251
- clientId: string;
252
- clientSecret: string;
253
- };
254
- } : {
255
- facebook?: {
256
- clientId: string;
257
- clientSecret: string;
258
- };
259
- });
260
- /** Check if any OAuth provider is enabled */
261
- type HasOAuthEnabled<T extends AuthConfig> = T["oauth"] extends {
262
- google: true;
263
- } | {
264
- github: true;
265
- } | {
266
- apple: true;
267
- } | {
268
- facebook: true;
269
- } ? true : false;
270
- /** Check if passkey is enabled */
271
- type HasPasskeyEnabled<T extends AuthConfig> = T["methods"] extends {
272
- passkey: object;
273
- } ? true : false;
274
- /**
275
- * Server-only session configuration.
276
- */
277
- interface AuthSessionConfig {
278
- /**
279
- * Session duration in seconds.
280
- *
281
- * @default 604800 (7 days)
282
- */
283
- expiresIn?: number;
284
- /**
285
- * How often to update session in seconds.
286
- *
287
- * @default 86400 (1 day)
288
- */
289
- updateAge?: number;
290
- /**
291
- * Session freshness in seconds for sensitive ops.
292
- *
293
- * @default 86400 (1 day)
294
- */
295
- freshAge?: number;
296
- }
297
- /**
298
- * Server-only passkey configuration (required if passkey is enabled).
299
- */
300
- interface AuthPasskeyConfig {
301
- /**
302
- * Relying Party ID - domain for passkey (e.g., "example.com" or "localhost").
303
- */
304
- rpID: string;
305
- /**
306
- * Origin URL for passkey verification (e.g., "http://localhost:8000").
307
- */
308
- origin: string;
309
- }
310
- /**
311
- * Fully type-safe options for defineAuth().
312
- *
313
- * Server-only fields:
314
- * - `appName` - Application name for passkey rpName, TOTP issuer, emails
315
- * - `auditLog` - Audit logging configuration
316
- * - `session` - Session duration and freshness settings
317
- *
318
- * Conditional requirements:
319
- * - If config has `oauth.google: true`, then `oauth.google` credentials are REQUIRED
320
- * - If config has `methods.magicLink` defined, then `hooks.sendMagicLink` is REQUIRED
321
- *
322
- * @template T - Auth config type
323
- * @template TDb - Database record type for type-safe excludeTables
324
- */
325
- type DefineAuthOptions<T extends AuthConfig, TDb = unknown> = {
326
- /**
327
- * The application name.
328
- */
329
- appName: string;
330
- /**
331
- * Audit logging configuration (server-only). Use qualified table names: "dbName.tableName".
332
- */
333
- auditLog?: AuditLogOptions<TDb>;
334
- /**
335
- * The neutral auth configuration.
336
- */
337
- config: T;
338
- /**
339
- * Full db object (container.db) for type inference.
340
- */
341
- db: TDb;
342
- /**
343
- * Primary database for Better Auth storage.
344
- */
345
- database: Database;
346
- /**
347
- * Hooks for email sending and OTP delivery.
348
- */
349
- hooks: RequiredHooks<T>;
350
- /**
351
- * Secret key for signing tokens and cookies.
352
- */
353
- secret: string;
354
- /**
355
- * Session configuration.
356
- */
357
- session?: AuthSessionConfig;
358
- } & (HasOAuthEnabled<T> extends true ? {
359
- oauth: RequiredOAuth<T>;
360
- } : {
361
- oauth?: RequiredOAuth<T>;
362
- }) & (HasPasskeyEnabled<T> extends true ? {
363
- passkey: AuthPasskeyConfig;
364
- } : {
365
- passkey?: AuthPasskeyConfig;
366
- });
367
- /**
368
- * Defines Better Auth instance from neutral config + server dependencies.
369
- */
370
- declare function defineAuth<T extends AuthConfig, TDb extends Record<"primary", Database> & Record<string, Database> = Record<"primary", Database> & Record<string, Database>>(opts: DefineAuthOptions<T, TDb>): ReturnType<typeof betterAuth> & {
371
- auditLog?: AuditLogOptions<TDb>;
372
- shouldAudit(tableName: QualifiedTableNames<TDb>): boolean;
373
- };
374
- /**
375
- * The auth instance type.
376
- */
377
- type Auth<TDb extends Record<"primary", Database> & Record<string, Database> = Record<"primary", Database> & Record<string, Database>> = ReturnType<typeof defineAuth<AuthConfig, TDb>>;
378
- //#endregion
379
- export { Auth };
@@ -1,44 +0,0 @@
1
- import { Logger } from "./logger.mjs";
2
- import * as _keyv_redis0 from "@keyv/redis";
3
- import { KeyvRedisOptions } from "@keyv/redis";
4
-
5
- //#region src/api/cache.d.ts
6
- /**
7
- * The cache instance type.
8
- */
9
- type Cache = ReturnType<typeof defineCache>;
10
- /**
11
- * Options for defining the cache.
12
- */
13
- type DefineCacheOptions = {
14
- /**
15
- * Redis URL(s). Single or comma-separated for cluster.
16
- */
17
- url: string;
18
- /**
19
- * The logger instance.
20
- */
21
- logger: Logger;
22
- /**
23
- * The Keyv Redis options.
24
- */
25
- options?: KeyvRedisOptions;
26
- };
27
- /**
28
- * Define the cache instance using shared Redis client.
29
- * Connection is lazy - only connects when first cache operation is performed.
30
- *
31
- * Algorithm:
32
- * 1. Create Redis client using defineRedisClient() (lazy connection)
33
- * 2. Pass client to createKeyv() - connection happens on first use
34
- *
35
- * @param opts - The options for defining the cache.
36
- * @returns The cache instance.
37
- */
38
- declare function defineCache({
39
- url,
40
- logger,
41
- options
42
- }: DefineCacheOptions): _keyv_redis0.Keyv<any>;
43
- //#endregion
44
- export { Cache };
@@ -1,18 +0,0 @@
1
- import { z } from "zod";
2
-
3
- //#region src/api/config.d.ts
4
-
5
- /**
6
- * The config base schema.
7
- */
8
- declare const baseSchema: z.ZodObject<{
9
- APP_NAME: z.ZodDefault<z.ZodString>;
10
- APP_DESC: z.ZodDefault<z.ZodString>;
11
- APP_VERSION: z.ZodDefault<z.ZodString>;
12
- }, z.core.$strip>;
13
- /**
14
- * The configuration type inferred from the merged schema.
15
- */
16
- type Config<T extends z.ZodRawShape = {}> = z.infer<ReturnType<typeof baseSchema.extend<T>>>;
17
- //#endregion
18
- export { Config };
@@ -1,167 +0,0 @@
1
- import { Logger } from "./logger.mjs";
2
- import { Database } from "./database.mjs";
3
- import { Auth } from "./auth.mjs";
4
- import { Cache } from "./cache.mjs";
5
- import { Config } from "./config.mjs";
6
- import { EventBus } from "./event.mjs";
7
- import { Mailer } from "./mailer.mjs";
8
- import { Storage } from "./storage.mjs";
9
- import { CorsOptions } from "cors";
10
- import { Options } from "express-rate-limit";
11
- import { HelmetOptions } from "helmet";
12
- import { i18n } from "i18next";
13
-
14
- //#region src/api/container.d.ts
15
-
16
- /**
17
- * Server configuration for the HTTP server.
18
- */
19
- interface ServerConfig {
20
- /**
21
- * The host address the server will bind to.
22
- *
23
- * @default "0.0.0.0"
24
- */
25
- host?: string;
26
- /**
27
- * The port number the server will listen on.
28
- */
29
- port: number;
30
- /**
31
- * Request timeout in milliseconds. Requests exceeding this duration
32
- * will receive a 408 Request Timeout response.
33
- *
34
- * @default 30000
35
- */
36
- timeout?: number;
37
- /**
38
- * Maximum request body size for JSON and URL-encoded payloads.
39
- * Supports bytes.js format strings (e.g., "1mb", "500kb", "10mb").
40
- *
41
- * @default "1mb"
42
- */
43
- bodyLimit?: string;
44
- /**
45
- * The path for the health check endpoint.
46
- *
47
- * @default "/health"
48
- */
49
- healthPath?: string;
50
- /**
51
- * CORS configuration. Omit or set to undefined to disable.
52
- *
53
- * @example
54
- * cors: { origin: "https://example.com", credentials: true }
55
- */
56
- cors?: CorsOptions;
57
- /**
58
- * Security headers configuration (via helmet). Omit or set to undefined to disable.
59
- * Recommended for production deployments.
60
- *
61
- * @example
62
- * helmet: { contentSecurityPolicy: false } // Enable with CSP disabled
63
- * helmet: {} // Enable with all defaults
64
- */
65
- helmet?: HelmetOptions;
66
- /**
67
- * Rate limiting configuration. Array of express-rate-limit options.
68
- * Each config is applied as a separate middleware - use `skip` function for path-specific limits.
69
- * Redis store is automatically configured if `redisUrl` is provided.
70
- *
71
- * @example
72
- * // Global rate limit
73
- * rateLimit: [{ windowMs: 60000, limit: 100 }]
74
- *
75
- * @example
76
- * // Path-specific rate limits
77
- * rateLimit: [
78
- * { windowMs: 900000, limit: 5, skip: (req) => !req.path.startsWith("/api/auth") },
79
- * { windowMs: 60000, limit: 100 }, // Default for all other routes
80
- * ]
81
- */
82
- rateLimit?: Options[];
83
- /**
84
- * Redis URL for rate limiting store (for multi-instance deployments).
85
- * Server auto-connects and cleans up on shutdown.
86
- * If omitted, uses in-memory store (not suitable for production clusters).
87
- *
88
- * @example
89
- * redisUrl: "redis://localhost:6379"
90
- */
91
- redisUrl?: string;
92
- }
93
- /**
94
- * Worker configuration for the DBOS workflow worker.
95
- */
96
- interface WorkerConfig {
97
- /**
98
- * The system database URL for DBOS.
99
- */
100
- dbUrl: string;
101
- }
102
- /**
103
- * The base application container type that holds required services like
104
- * config, databases, and caches.
105
- */
106
- interface AppContainer<TDb extends Record<"primary", Database> & Record<string, Database> = Record<"primary", Database> & Record<string, Database>> {
107
- /**
108
- * The application auth configuration.
109
- */
110
- auth: Auth<TDb>;
111
- /**
112
- * A map of caches available in the application.
113
- */
114
- cache: Record<string, Cache>;
115
- /**
116
- * The application configuration.
117
- */
118
- config: Config;
119
- /**
120
- * A map of databases available in the application.
121
- */
122
- db: TDb;
123
- /**
124
- * The i18n instance for internationalization.
125
- */
126
- i18n: i18n;
127
- /**
128
- * The logger instance for logging messages.
129
- */
130
- logger: Logger;
131
- /**
132
- * The event bus for in-memory and Redis pub/sub messaging.
133
- */
134
- eventBus: EventBus;
135
- /**
136
- * The mailer instance for sending emails.
137
- */
138
- mailer: Mailer;
139
- /**
140
- * Server configuration for the HTTP server.
141
- */
142
- server: ServerConfig;
143
- /**
144
- * A map of storage services available in the application.
145
- */
146
- storage: Record<"primary", Storage> & Record<string, Storage>;
147
- /**
148
- * Worker configuration for the DBOS workflow worker.
149
- */
150
- worker: WorkerConfig;
151
- }
152
- /**
153
- * Global namespace for user container augmentation.
154
- * Users can extend Container interface in their container.ts file.
155
- */
156
- declare global {
157
- namespace AppOS {
158
- interface Container {}
159
- }
160
- }
161
- /**
162
- * The container type used throughout the application.
163
- * Merges base AppContainer with user's custom Container augmentations.
164
- */
165
- type Container = AppContainer & AppOS.Container;
166
- //#endregion
167
- export { Container };
@@ -1,47 +0,0 @@
1
- import { Logger } from "./logger.mjs";
2
- import { AnyRelations, EmptyRelations } from "drizzle-orm";
3
- import "drizzle-orm/pg-core";
4
- import * as drizzle_orm_node_postgres0 from "drizzle-orm/node-postgres";
5
- import * as pg0 from "pg";
6
- import pg from "pg";
7
-
8
- //#region src/api/database.d.ts
9
- type PoolConfig = pg.PoolConfig;
10
- /**
11
- * Extract qualified table names from db object.
12
- */
13
- type QualifiedTableNames<TDb> = { [K in keyof TDb]: TDb[K] extends {
14
- _: {
15
- fullSchema: infer S;
16
- };
17
- } ? `${K & string}.${keyof S & string}` : never }[keyof TDb];
18
- /**
19
- * Options for defining the database.
20
- */
21
- interface DefineDatabaseOptions<TSchema extends Record<string, unknown> = Record<string, never>, TRelations extends AnyRelations = EmptyRelations> {
22
- logger: Logger;
23
- poolConfig: PoolConfig;
24
- relations?: TRelations;
25
- schema?: TSchema;
26
- }
27
- /**
28
- * The database type.
29
- */
30
- type Database = Awaited<ReturnType<typeof defineDatabase>>;
31
- /**
32
- * Define the database with the provided options.
33
- *
34
- * Algorithm:
35
- * 1. Create a connection pool with sensible defaults
36
- * 2. Initialize drizzle ORM with schema and relations
37
- *
38
- * @param opts The options for defining the database, including pool configuration, relations, and schema.
39
- * @template TSchema The schema type for the database.
40
- * @template TRelations The relations type for the database.
41
- * @returns The defined database instance.
42
- */
43
- declare function defineDatabase<TSchema extends Record<string, unknown> = Record<string, never>, TRelations extends AnyRelations = EmptyRelations>(opts: DefineDatabaseOptions<TSchema, TRelations>): Promise<drizzle_orm_node_postgres0.NodePgDatabase<TSchema, TRelations> & {
44
- $client: pg0.Pool;
45
- }>;
46
- //#endregion
47
- export { Database, QualifiedTableNames };