appos 0.3.5-0 → 0.3.6-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 (281) hide show
  1. package/dist/bin/main.mjs +2 -2
  2. package/dist/exports/api/adapter-C2mMJKvG.mjs +1504 -0
  3. package/dist/exports/api/{auth-schema.mjs → auth-schema-CON4yFFY.mjs} +2 -3
  4. package/dist/exports/api/bun-sqlite-dialect-CPpPZa23.mjs +155 -0
  5. package/dist/exports/{cli/_virtual/rolldown_runtime.mjs → api/chunk-CyXqrcp_.mjs} +14 -1
  6. package/dist/exports/api/conditions-DjBAWfiK.mjs +116 -0
  7. package/dist/exports/api/dialect-CUUD24Ge.mjs +72 -0
  8. package/dist/exports/api/env-CwT3zhez.mjs +1 -0
  9. package/dist/exports/api/esm-_hkVMulx.mjs +15816 -0
  10. package/dist/exports/api/event-BHFSE6hY.mjs +20983 -0
  11. package/dist/exports/api/extract-blob-metadata-BMgUEPcW.mjs +4 -0
  12. package/dist/exports/api/extract-blob-metadata-_9RUEwoU.mjs +9818 -0
  13. package/dist/exports/api/generate-image-variant-DOIzj1wJ.mjs +4 -0
  14. package/dist/exports/api/generate-image-variant-DxOPoGAk.mjs +118 -0
  15. package/dist/exports/api/generate-preview-CvTFuq58.mjs +160 -0
  16. package/dist/exports/api/generate-preview-Dk3coswZ.mjs +4 -0
  17. package/dist/exports/api/index.d.mts +7347 -20
  18. package/dist/exports/api/index.mjs +146856 -18
  19. package/dist/exports/api/kysely-adapter-CmP2TbkS.mjs +296 -0
  20. package/dist/exports/api/memory-adapter-BzhRhLFK.mjs +212 -0
  21. package/dist/exports/api/node-sqlite-dialect-Bl5suBxl.mjs +155 -0
  22. package/dist/exports/api/orm-CMqufD21.mjs +153690 -0
  23. package/dist/exports/api/orm-DXqYuKvB.d.mts +11 -0
  24. package/dist/exports/api/orm.d.mts +2 -11
  25. package/dist/exports/api/orm.mjs +4 -42
  26. package/dist/exports/api/pdf-YxB2Hm1p.mjs +25822 -0
  27. package/dist/exports/api/purge-attachment-Cf6KH2Jv.mjs +34 -0
  28. package/dist/exports/api/purge-attachment-DIuil7ps.mjs +4 -0
  29. package/dist/exports/{cli/api/workflows/purge-audit-logs.mjs → api/purge-audit-logs-z6j_Pu47.mjs} +3 -3
  30. package/dist/exports/{cli/api/workflows/purge-unattached-blobs.mjs → api/purge-unattached-blobs-B0TfY5Hk.mjs} +1 -1
  31. package/dist/exports/api/react-BYhV5bYt.mjs +1131 -0
  32. package/dist/exports/api/server.node-DyVrQ6cz.mjs +19298 -0
  33. package/dist/exports/api/table-6bTIEqON.mjs +2636 -0
  34. package/dist/exports/api/{workflows/track-db-changes.mjs → track-db-changes-BysaV6nN.mjs} +14 -14
  35. package/dist/exports/api/{workflow.mjs → workflow-BuSWHcX-.mjs} +121 -10
  36. package/dist/exports/api/workflows/auth-schema-BFve3hgZ.mjs +2813 -0
  37. package/dist/exports/api/{_virtual/rolldown_runtime.mjs → workflows/chunk-B36mNPO4.mjs} +5 -1
  38. package/dist/exports/api/workflows/extract-blob-metadata-BcWKvY2K.mjs +9818 -0
  39. package/dist/exports/api/workflows/{generate-image-variant.mjs → generate-image-variant-BAFvL_zV.mjs} +20 -20
  40. package/dist/exports/{cli/api/workflows/generate-preview.mjs → api/workflows/generate-preview-BjlIVYYp.mjs} +6 -6
  41. package/dist/exports/api/workflows/index.d.mts +2011 -1
  42. package/dist/exports/api/workflows/index.mjs +2 -1
  43. package/dist/exports/api/workflows/pdf-DUB8zyIc.mjs +25822 -0
  44. package/dist/exports/{cli/api/workflows/purge-attachment.mjs → api/workflows/purge-attachment-k_sdxTPY.mjs} +3 -3
  45. package/dist/exports/api/workflows/{purge-audit-logs.mjs → purge-audit-logs-zCyWj4Mw.mjs} +12 -3
  46. package/dist/exports/api/workflows/{purge-unattached-blobs.mjs → purge-unattached-blobs-CdsuFAeW.mjs} +1 -1
  47. package/dist/exports/api/workflows/track-db-changes-CiKaI9gT.mjs +20943 -0
  48. package/dist/exports/api/workflows/track-db-changes-DEWQYryO.mjs +4 -0
  49. package/dist/exports/{cli/api/workflow.mjs → api/workflows/workflow-BjM2xCa6.mjs} +23 -3
  50. package/dist/exports/api/workflows/zod-Br0enFWK.mjs +12333 -0
  51. package/dist/exports/api/zod-CdrJdBtV.mjs +12571 -0
  52. package/dist/exports/cli/auth-schema-CNuOqPi-.mjs +2813 -0
  53. package/dist/exports/{api/workflows/_virtual/rolldown_runtime.mjs → cli/chunk-B36mNPO4.mjs} +5 -1
  54. package/dist/exports/cli/extract-blob-metadata-CV1Ke90d.mjs +9818 -0
  55. package/dist/exports/cli/{api/workflows/generate-image-variant.mjs → generate-image-variant-CM1BrVvZ.mjs} +20 -20
  56. package/dist/exports/{api/workflows/generate-preview.mjs → cli/generate-preview-DdHQ3ukz.mjs} +6 -6
  57. package/dist/exports/cli/index.d.mts +2142 -2
  58. package/dist/exports/cli/index.mjs +41 -1
  59. package/dist/exports/cli/pdf-CLUPEIdT.mjs +25822 -0
  60. package/dist/exports/{api/workflows/purge-attachment.mjs → cli/purge-attachment-Dc_J74dG.mjs} +3 -3
  61. package/dist/exports/cli/purge-audit-logs-DFhWh-Bx.mjs +56 -0
  62. package/dist/exports/cli/purge-unattached-blobs-C1MRlM_2.mjs +46 -0
  63. package/dist/exports/cli/track-db-changes-CfneOF2_.mjs +20943 -0
  64. package/dist/exports/{api/workflows/api/workflow.mjs → cli/workflow-DSbbXBMt.mjs} +23 -3
  65. package/dist/exports/cli/zod-7q0_Mtnn.mjs +12333 -0
  66. package/dist/exports/devtools/BaseTanStackRouterDevtoolsPanel-BBz1qLry-DUwdvyLv.js +2090 -0
  67. package/dist/exports/devtools/EIDV623S-B7f6114d.js +2497 -0
  68. package/dist/exports/devtools/FloatingTanStackRouterDevtools-DymJEvfG-BHuQHiRR.js +237 -0
  69. package/dist/exports/devtools/MIMHJGAX-Cb3wf11F.js +10903 -0
  70. package/dist/exports/devtools/Q7LWSL4U-BoEO3rNq.js +37 -0
  71. package/dist/exports/devtools/VLTTJS3N-CIyRc84e.js +44 -0
  72. package/dist/exports/devtools/index.js +1724 -3
  73. package/dist/exports/devtools/utils-YRTCpRgb.js +1670 -0
  74. package/dist/exports/tests/api.d.mts +7354 -5
  75. package/dist/exports/tests/api.mjs +79 -1
  76. package/dist/exports/tests/auth-schema-DUCJw-_2.mjs +1 -0
  77. package/dist/exports/tests/chunk-Cii4FAhs.mjs +1 -0
  78. package/dist/exports/tests/conditions-B0ffVJ5E.mjs +1 -0
  79. package/dist/exports/tests/constants-DHjjg05J.mjs +1 -0
  80. package/dist/exports/tests/dist-D6vgKv3t.mjs +7 -0
  81. package/dist/exports/tests/dist-EfrRkq5c.mjs +296 -0
  82. package/dist/exports/tests/extract-blob-metadata-Dv343Vcn.mjs +169 -0
  83. package/dist/exports/tests/generate-image-variant-cQc8q0kh.mjs +1 -0
  84. package/dist/exports/tests/generate-preview-HaTMd2hS.mjs +1 -0
  85. package/dist/exports/tests/magic-string.es-D6VRmdiF.mjs +14 -0
  86. package/dist/exports/tests/mock-BvkO5nlm.mjs +1 -0
  87. package/dist/exports/tests/mock.mjs +1 -1
  88. package/dist/exports/tests/pdf-BDsS3vjF.mjs +13 -0
  89. package/dist/exports/tests/purge-attachment-D4uOzHRi.mjs +1 -0
  90. package/dist/exports/tests/purge-audit-logs-DiPcc09d.mjs +1 -0
  91. package/dist/exports/tests/purge-unattached-blobs-CqW6tlIC.mjs +1 -0
  92. package/dist/exports/tests/react.mjs +6 -1
  93. package/dist/exports/tests/setup.d.mts +1 -1
  94. package/dist/exports/tests/setup.mjs +34 -1
  95. package/dist/exports/tests/table-CbU04119.mjs +1 -0
  96. package/dist/exports/tests/track-db-changes-Bd4W-P1q.mjs +1 -0
  97. package/dist/exports/tests/vi.2VT5v0um-Cme1b0Dl.mjs +348 -0
  98. package/dist/exports/tests/{api/workflow.mjs → workflow-DwZxTqdH.mjs} +1 -1
  99. package/dist/exports/tests/zod-DcpxsMPz.mjs +23 -0
  100. package/dist/exports/vendors/date.js +13236 -1
  101. package/dist/exports/vendors/toolkit.js +2206 -1
  102. package/dist/exports/vendors/zod.js +12344 -1
  103. package/dist/exports/vite/api-DGRU_RdM.mjs +27 -0
  104. package/dist/exports/vite/build-CxJAu2Bn.mjs +1 -0
  105. package/dist/exports/vite/build2-BMK0OFVt.mjs +16 -0
  106. package/dist/exports/vite/chunk-CxnlK1Zi.mjs +1 -0
  107. package/dist/exports/vite/chunk-PtveFMYu.mjs +1 -0
  108. package/dist/exports/vite/dist-Bxp8DqWh.mjs +114 -0
  109. package/dist/exports/vite/dist-CX51FKbX.mjs +1 -0
  110. package/dist/exports/vite/dist-DcyNr-KR.mjs +1 -0
  111. package/dist/exports/vite/dist-j3-Khlzt.mjs +1 -0
  112. package/dist/exports/vite/experimental-index-3KsfmUbz.mjs +1 -0
  113. package/dist/exports/vite/false-BNJbUKYT.mjs +1 -0
  114. package/dist/exports/vite/false-BvrPEDU6.mjs +1 -0
  115. package/dist/exports/vite/index.d.mts +1 -1
  116. package/dist/exports/vite/index.mjs +26 -1
  117. package/dist/exports/vite/internal-C5cVwRiK.mjs +1 -0
  118. package/dist/exports/vite/jiti-BjSPrFvg.mjs +9 -0
  119. package/dist/exports/vite/lexer-DQCqS3nf-C6xCDOEQ.mjs +3 -0
  120. package/dist/exports/vite/lib-CMv7Sfwa.mjs +1 -0
  121. package/dist/exports/vite/lib-D9TnS-7w.mjs +1 -0
  122. package/dist/exports/vite/lib-DuBRr9dH.mjs +382 -0
  123. package/dist/exports/vite/node-DI8AnY_i.mjs +437 -0
  124. package/dist/exports/vite/postcss-BtmDpj-c.mjs +32 -0
  125. package/dist/exports/vite/postcss-import-Bk_ZCd6c.mjs +5 -0
  126. package/dist/exports/vite/rolldown-build-CNW2eye_-CJNfyXdF.mjs +13 -0
  127. package/dist/exports/vitest/api-CPv6lnxG.mjs +27 -0
  128. package/dist/exports/vitest/build2-28i3OiJ3.mjs +16 -0
  129. package/dist/exports/vitest/chunk-_e2jlDPK.mjs +1 -0
  130. package/dist/exports/vitest/chunk-jwDkFoXW.mjs +1 -0
  131. package/dist/exports/vitest/config.mjs +77 -1
  132. package/dist/exports/vitest/dist-L-OpshPJ.mjs +114 -0
  133. package/dist/exports/vitest/index.mjs +348 -1
  134. package/dist/exports/vitest/jiti-eNGOyHIo.mjs +9 -0
  135. package/dist/exports/vitest/lexer-DQCqS3nf-TWLyIqlY.mjs +3 -0
  136. package/dist/exports/vitest/lib-C3G64csm.mjs +1 -0
  137. package/dist/exports/vitest/magic-string.es-CxM5Ubyl.mjs +14 -0
  138. package/dist/exports/vitest/module-runner-DsF4L04D.mjs +1 -0
  139. package/dist/exports/vitest/postcss-BxLp_Too.mjs +32 -0
  140. package/dist/exports/vitest/postcss-import-5pKj3f5q.mjs +5 -0
  141. package/dist/exports/web/browser-ponyfill-DxTJMXNq.js +443 -0
  142. package/dist/exports/web/chunk-DksrlJLg.js +49 -0
  143. package/dist/exports/web/index.d.ts +2546 -2
  144. package/dist/exports/web/index.js +9295 -6
  145. package/dist/exports/web/plugin-DqTFWG7p.js +250 -0
  146. package/package.json +1 -1
  147. package/dist/exports/api/app-context.d.mts +0 -115
  148. package/dist/exports/api/app-context.mjs +0 -24
  149. package/dist/exports/api/auth-schema.d.mts +0 -4248
  150. package/dist/exports/api/auth.d.mts +0 -402
  151. package/dist/exports/api/auth.mjs +0 -188
  152. package/dist/exports/api/cache.d.mts +0 -44
  153. package/dist/exports/api/cache.mjs +0 -28
  154. package/dist/exports/api/config.d.mts +0 -28
  155. package/dist/exports/api/config.mjs +0 -72
  156. package/dist/exports/api/constants.mjs +0 -92
  157. package/dist/exports/api/container.d.mts +0 -210
  158. package/dist/exports/api/container.mjs +0 -49
  159. package/dist/exports/api/database.d.mts +0 -101
  160. package/dist/exports/api/database.mjs +0 -219
  161. package/dist/exports/api/event.d.mts +0 -235
  162. package/dist/exports/api/event.mjs +0 -236
  163. package/dist/exports/api/i18n.d.mts +0 -34
  164. package/dist/exports/api/i18n.mjs +0 -45
  165. package/dist/exports/api/instrumentation.d.mts +0 -7
  166. package/dist/exports/api/instrumentation.mjs +0 -40
  167. package/dist/exports/api/logger.d.mts +0 -21
  168. package/dist/exports/api/logger.mjs +0 -26
  169. package/dist/exports/api/mailer.d.mts +0 -70
  170. package/dist/exports/api/mailer.mjs +0 -37
  171. package/dist/exports/api/middleware/request-logger.d.mts +0 -24
  172. package/dist/exports/api/middleware.d.mts +0 -39
  173. package/dist/exports/api/middleware.mjs +0 -73
  174. package/dist/exports/api/openapi.d.mts +0 -271
  175. package/dist/exports/api/openapi.mjs +0 -507
  176. package/dist/exports/api/otel.d.mts +0 -40
  177. package/dist/exports/api/otel.mjs +0 -56
  178. package/dist/exports/api/redis.d.mts +0 -34
  179. package/dist/exports/api/redis.mjs +0 -41
  180. package/dist/exports/api/storage-schema.d.mts +0 -707
  181. package/dist/exports/api/storage-schema.mjs +0 -72
  182. package/dist/exports/api/storage.d.mts +0 -506
  183. package/dist/exports/api/storage.mjs +0 -833
  184. package/dist/exports/api/web/auth.mjs +0 -17
  185. package/dist/exports/api/workflow.d.mts +0 -250
  186. package/dist/exports/api/workflows/api/auth-schema.mjs +0 -373
  187. package/dist/exports/api/workflows/api/auth.d.mts +0 -379
  188. package/dist/exports/api/workflows/api/cache.d.mts +0 -44
  189. package/dist/exports/api/workflows/api/config.d.mts +0 -18
  190. package/dist/exports/api/workflows/api/container.d.mts +0 -167
  191. package/dist/exports/api/workflows/api/database.d.mts +0 -47
  192. package/dist/exports/api/workflows/api/event.d.mts +0 -68
  193. package/dist/exports/api/workflows/api/event.mjs +0 -126
  194. package/dist/exports/api/workflows/api/logger.d.mts +0 -21
  195. package/dist/exports/api/workflows/api/mailer.d.mts +0 -70
  196. package/dist/exports/api/workflows/api/orm.d.mts +0 -13
  197. package/dist/exports/api/workflows/api/redis.mjs +0 -3
  198. package/dist/exports/api/workflows/api/storage-schema.d.mts +0 -699
  199. package/dist/exports/api/workflows/api/storage.d.mts +0 -396
  200. package/dist/exports/api/workflows/api/workflow.d.mts +0 -24
  201. package/dist/exports/api/workflows/constants.mjs +0 -23
  202. package/dist/exports/api/workflows/extract-blob-metadata.mjs +0 -132
  203. package/dist/exports/api/workflows/generate-image-variant.d.mts +0 -63
  204. package/dist/exports/api/workflows/track-db-changes.d.mts +0 -72
  205. package/dist/exports/cli/api/auth-schema.mjs +0 -373
  206. package/dist/exports/cli/api/auth.d.mts +0 -379
  207. package/dist/exports/cli/api/cache.d.mts +0 -44
  208. package/dist/exports/cli/api/config.d.mts +0 -18
  209. package/dist/exports/cli/api/container.d.mts +0 -167
  210. package/dist/exports/cli/api/database.d.mts +0 -47
  211. package/dist/exports/cli/api/event.d.mts +0 -68
  212. package/dist/exports/cli/api/event.mjs +0 -126
  213. package/dist/exports/cli/api/logger.d.mts +0 -21
  214. package/dist/exports/cli/api/mailer.d.mts +0 -70
  215. package/dist/exports/cli/api/orm.d.mts +0 -13
  216. package/dist/exports/cli/api/redis.mjs +0 -3
  217. package/dist/exports/cli/api/storage-schema.d.mts +0 -699
  218. package/dist/exports/cli/api/storage.d.mts +0 -396
  219. package/dist/exports/cli/api/workflow.d.mts +0 -2
  220. package/dist/exports/cli/api/workflows/extract-blob-metadata.mjs +0 -132
  221. package/dist/exports/cli/api/workflows/generate-image-variant.d.mts +0 -63
  222. package/dist/exports/cli/api/workflows/track-db-changes.mjs +0 -110
  223. package/dist/exports/cli/command.d.mts +0 -56
  224. package/dist/exports/cli/command.mjs +0 -43
  225. package/dist/exports/cli/constants.mjs +0 -23
  226. package/dist/exports/cli/context.d.mts +0 -170
  227. package/dist/exports/tests/_virtual/rolldown_runtime.mjs +0 -1
  228. package/dist/exports/tests/api/app-context.d.mts +0 -115
  229. package/dist/exports/tests/api/app-context.mjs +0 -1
  230. package/dist/exports/tests/api/auth-schema.d.mts +0 -4248
  231. package/dist/exports/tests/api/auth-schema.mjs +0 -1
  232. package/dist/exports/tests/api/auth.d.mts +0 -402
  233. package/dist/exports/tests/api/cache.d.mts +0 -44
  234. package/dist/exports/tests/api/config.d.mts +0 -28
  235. package/dist/exports/tests/api/container.d.mts +0 -210
  236. package/dist/exports/tests/api/database.d.mts +0 -101
  237. package/dist/exports/tests/api/database.mjs +0 -1
  238. package/dist/exports/tests/api/event.d.mts +0 -235
  239. package/dist/exports/tests/api/event.mjs +0 -1
  240. package/dist/exports/tests/api/i18n.d.mts +0 -34
  241. package/dist/exports/tests/api/index.d.mts +0 -26
  242. package/dist/exports/tests/api/logger.d.mts +0 -21
  243. package/dist/exports/tests/api/mailer.d.mts +0 -70
  244. package/dist/exports/tests/api/middleware/error-handler.mjs +0 -1
  245. package/dist/exports/tests/api/middleware/health.mjs +0 -1
  246. package/dist/exports/tests/api/middleware/i18n.mjs +0 -1
  247. package/dist/exports/tests/api/middleware/request-logger.d.mts +0 -24
  248. package/dist/exports/tests/api/middleware/request-logger.mjs +0 -1
  249. package/dist/exports/tests/api/middleware/shutdown.mjs +0 -1
  250. package/dist/exports/tests/api/middleware/timeout.mjs +0 -1
  251. package/dist/exports/tests/api/middleware.d.mts +0 -39
  252. package/dist/exports/tests/api/middleware.mjs +0 -1
  253. package/dist/exports/tests/api/openapi.d.mts +0 -271
  254. package/dist/exports/tests/api/openapi.mjs +0 -1
  255. package/dist/exports/tests/api/orm.d.mts +0 -13
  256. package/dist/exports/tests/api/otel.d.mts +0 -40
  257. package/dist/exports/tests/api/redis.d.mts +0 -34
  258. package/dist/exports/tests/api/redis.mjs +0 -1
  259. package/dist/exports/tests/api/server.mjs +0 -1
  260. package/dist/exports/tests/api/storage-schema.d.mts +0 -707
  261. package/dist/exports/tests/api/storage.d.mts +0 -506
  262. package/dist/exports/tests/api/workflow.d.mts +0 -250
  263. package/dist/exports/tests/api/workflows/extract-blob-metadata.mjs +0 -1
  264. package/dist/exports/tests/api/workflows/generate-image-variant.d.mts +0 -63
  265. package/dist/exports/tests/api/workflows/generate-image-variant.mjs +0 -1
  266. package/dist/exports/tests/api/workflows/generate-preview.mjs +0 -1
  267. package/dist/exports/tests/api/workflows/purge-attachment.mjs +0 -1
  268. package/dist/exports/tests/api/workflows/purge-audit-logs.mjs +0 -1
  269. package/dist/exports/tests/api/workflows/purge-unattached-blobs.mjs +0 -1
  270. package/dist/exports/tests/api/workflows/track-db-changes.mjs +0 -1
  271. package/dist/exports/tests/constants.mjs +0 -1
  272. package/dist/exports/tests/instrumentation.d.mts +0 -7
  273. package/dist/exports/tests/instrumentation.mjs +0 -1
  274. package/dist/exports/web/api/auth.d.ts +0 -125
  275. package/dist/exports/web/api/database.d.ts +0 -4
  276. package/dist/exports/web/api/logger.d.ts +0 -1
  277. package/dist/exports/web/auth.d.ts +0 -2388
  278. package/dist/exports/web/auth.js +0 -75
  279. package/dist/exports/web/i18n.d.ts +0 -42
  280. package/dist/exports/web/i18n.js +0 -45
  281. /package/dist/exports/tests/{api/middleware/youch-handler.mjs → youch-handler-Ch5yf6im.mjs} +0 -0
@@ -1,396 +0,0 @@
1
- import { StorageBlob, StorageRelationsConfig, StorageTables } from "./storage-schema.mjs";
2
- import { ImageTransformations } from "../generate-image-variant.mjs";
3
- import { NodePgDatabase } from "drizzle-orm/node-postgres";
4
- import { Pool } from "pg";
5
- import { DriveManager } from "flydrive";
6
- import { FSDriverOptions } from "flydrive/drivers/fs/types";
7
- import { S3DriverOptions } from "flydrive/drivers/s3/types";
8
-
9
- //#region src/api/storage.d.ts
10
-
11
- /**
12
- * Database type with storage schema and relations.
13
- */
14
- type DatabaseWithStorage = NodePgDatabase<StorageTables, StorageRelationsConfig> & {
15
- $client: Pool;
16
- };
17
- /**
18
- * Type of the storage service instance.
19
- */
20
- type Storage<TDisks extends Record<string, FSDriverOptions | S3DriverOptions> = Record<string, FSDriverOptions | S3DriverOptions>, TTableNames extends string = string, TAttachments extends Partial<Record<TTableNames, readonly string[]>> = Record<never, never>> = StorageService<Extract<keyof TDisks, string>, TTableNames, TAttachments>;
21
- /**
22
- * Helper type to extract attachment name for a specific table.
23
- */
24
- type AttachmentName<TAttachments extends Partial<Record<string, readonly string[]>>, TTable extends string> = TTable extends keyof TAttachments ? TAttachments[TTable] extends readonly (infer N)[] ? N : string : string;
25
- /**
26
- * Storage service for blob operations.
27
- *
28
- * This service uses a dual-drive architecture when configured:
29
- * - `drive`: For actual file operations (upload, delete, read) using internal endpoints
30
- * - `signedUrlDrive`: For generating browser-accessible signed URLs with public endpoints
31
- *
32
- * This allows containers to use fast internal network for operations while
33
- * generating URLs that work in end-user browsers.
34
- *
35
- * @template TDiskNames - Union of disk names (e.g., "private" | "public")
36
- * @template TTableNames - Union of table names for type-safe attachment methods
37
- * @template TAttachments - Mapping of table names to valid attachment names
38
- */
39
- declare class StorageService<TDiskNames extends string = string, TTableNames extends string = string, TAttachments extends Partial<Record<TTableNames, readonly string[]>> = Record<never, never>> {
40
- /**
41
- * The drive manager for file operations.
42
- */
43
- readonly drive: DriveManager<any>;
44
- /**
45
- * The database instance with storage schema and relations.
46
- */
47
- readonly db: DatabaseWithStorage;
48
- /**
49
- * The default disk name.
50
- */
51
- readonly defaultDisk: TDiskNames;
52
- /**
53
- * Cron expression for unattached blob purge schedule.
54
- *
55
- * @default "0 0 * * *"
56
- */
57
- readonly purgeCron?: string;
58
- /**
59
- * Secret key for signing blob IDs.
60
- */
61
- readonly secret?: string;
62
- /**
63
- * Drive manager for generating signed URLs (public endpoint).
64
- */
65
- readonly signedUrlDrive: DriveManager<any>;
66
- constructor(drive: DriveManager<any>, db: DatabaseWithStorage, defaultDisk: TDiskNames, signedUrlDrive: DriveManager<any>, purgeCron?: string, secret?: string);
67
- /**
68
- * Create a blob record and upload file.
69
- */
70
- createBlob(file: Buffer | Uint8Array, options: {
71
- filename: string;
72
- contentType?: string;
73
- metadata?: Record<string, any>;
74
- serviceName?: TDiskNames;
75
- prefix?: string;
76
- }): Promise<StorageBlob>;
77
- /**
78
- * Get blob by ID.
79
- */
80
- getBlob(id: string): Promise<StorageBlob | null>;
81
- /**
82
- * Download blob content.
83
- */
84
- downloadBlob(id: string): Promise<Buffer | null>;
85
- /**
86
- * Delete blob and its content.
87
- */
88
- deleteBlob(id: string): Promise<boolean>;
89
- /**
90
- * Get signed URL for blob. If blob is on public service, returns permanent
91
- * URL instead.
92
- */
93
- getSignedUrl(id: string, options?: {
94
- expiresIn?: number;
95
- disposition?: "inline" | "attachment";
96
- filename?: string;
97
- }): Promise<string | null>;
98
- /**
99
- * Get permanent public URL (no expiration).
100
- * Works for blobs on public storage service.
101
- */
102
- getPublicUrl(id: string): Promise<string | null>;
103
- /**
104
- * Create attachment between a record and blob.
105
- *
106
- * @param recordType - The table name (e.g., 'users')
107
- * @param recordId - The record ID
108
- * @param blobId - The blob ID to attach
109
- * @param name - The attachment name (e.g., 'avatar')
110
- * @param replaceExisting - If true, replaces existing attachment with same name (for one-to-one)
111
- */
112
- createAttachment(recordType: string, recordId: string, blobId: string, name: string, replaceExisting?: boolean): Promise<{
113
- id: string;
114
- createdAt: string;
115
- name: string;
116
- recordType: string;
117
- recordId: string;
118
- blobId: string;
119
- }>;
120
- /**
121
- * Get attachments for a record with their associated blobs.
122
- */
123
- getAttachments(recordType: string, recordId: string, name?: string): Promise<{
124
- id: string;
125
- createdAt: string;
126
- name: string;
127
- recordType: string;
128
- recordId: string;
129
- blobId: string;
130
- blob: {
131
- metadata: unknown;
132
- id: string;
133
- key: string;
134
- filename: string;
135
- contentType: string | null;
136
- serviceName: string;
137
- byteSize: number;
138
- checksum: string | null;
139
- createdAt: string;
140
- } | null;
141
- }[]>;
142
- /**
143
- * Get attachments by their IDs with associated blobs.
144
- *
145
- * @param attachmentIds - Array of attachment IDs to fetch.
146
- */
147
- getAttachmentsByIds(attachmentIds: string[]): Promise<{
148
- id: string;
149
- createdAt: string;
150
- name: string;
151
- recordType: string;
152
- recordId: string;
153
- blobId: string;
154
- blob: {
155
- metadata: unknown;
156
- id: string;
157
- key: string;
158
- filename: string;
159
- contentType: string | null;
160
- serviceName: string;
161
- byteSize: number;
162
- checksum: string | null;
163
- createdAt: string;
164
- } | null;
165
- }[]>;
166
- /**
167
- * Delete a single attachment by ID.
168
- */
169
- deleteAttachment(attachmentId: string): Promise<boolean>;
170
- /**
171
- * Delete attachments for a record (without deleting the blobs).
172
- */
173
- deleteAttachments(recordType: string, recordId: string, name?: string): Promise<number>;
174
- /**
175
- * Get direct upload credentials (for S3). Also creates a pending blob record
176
- * that will be finalized after upload.
177
- */
178
- getDirectUploadUrl(options: {
179
- contentType?: string;
180
- expiresIn?: number;
181
- filename: string;
182
- metadata?: Record<string, any>;
183
- serviceName?: TDiskNames;
184
- }): Promise<{
185
- blobId: string;
186
- headers?: Record<string, string>;
187
- key: string;
188
- url: string;
189
- } | null>;
190
- /**
191
- * Finalize a direct upload by updating blob metadata. Call this after the
192
- * client has uploaded to S3.
193
- */
194
- finalizeDirectUpload(blobId: string, actualSize: number): Promise<void>;
195
- /**
196
- * Update blob metadata (for automatic extraction).
197
- */
198
- updateBlobMetadata(blobId: string, metadata: Record<string, any>): Promise<void>;
199
- /**
200
- * Get existing variant or return null.
201
- */
202
- getVariant(blobId: string, transformations: ImageTransformations): Promise<StorageBlob | null>;
203
- /**
204
- * Create variant blob and record.
205
- */
206
- createVariant(blobId: string, transformations: ImageTransformations, variantBuffer: Buffer): Promise<StorageBlob>;
207
- /**
208
- * Get blobs that have no attachments (orphaned). Useful for cleanup jobs.
209
- */
210
- getUnattachedBlobs(options?: {
211
- olderThan?: string;
212
- limit?: number;
213
- }): Promise<StorageBlob[]>;
214
- /**
215
- * Get pending blobs that were never finalized (stuck direct uploads).
216
- */
217
- getPendingBlobs(olderThan?: string): Promise<StorageBlob[]>;
218
- /**
219
- * Purge unattached blobs.
220
- */
221
- purgeUnattached(olderThan?: string): Promise<number>;
222
- /**
223
- * Create a signed, tamper-proof reference to a blob.
224
- * Use findSigned() to resolve back to blob.
225
- *
226
- * Algorithm:
227
- * 1. Create payload with blobId and expiration timestamp
228
- * 2. JSON stringify and base64url encode the payload
229
- * 3. Create HMAC-SHA256 signature of the encoded payload
230
- * 4. Return payload.signature format
231
- */
232
- signedId(blobId: string, expiresIn?: number): string;
233
- /**
234
- * Find blob by signed ID. Returns null if invalid or expired.
235
- * Uses constant-time comparison to prevent timing attacks.
236
- *
237
- * Algorithm:
238
- * 1. Split signed ID into payload and signature
239
- * 2. Decode and recompute expected signature
240
- * 3. Use timingSafeEqual for constant-time comparison
241
- * 4. Check expiration timestamp
242
- * 5. Return blob if valid, null otherwise
243
- */
244
- findSigned(signedId: string): Promise<StorageBlob | null>;
245
- /**
246
- * Get a single attachment handle (one-to-one relationship).
247
- * Similar to Rails' `has_one_attached :avatar`.
248
- *
249
- * Algorithm:
250
- * Returns an object with methods to manage a single attachment:
251
- * - attach(): Replace existing attachment with new blob
252
- * - get(): Get attached blob or null
253
- * - url(): Get signed URL
254
- * - variant(): Get/generate image variant
255
- * - purge(): Delete attachment and blob
256
- *
257
- * @template TTable - The table name (must be in TTableNames)
258
- */
259
- one<TTable extends TTableNames>(recordType: TTable, recordId: string, name: AttachmentName<TAttachments, TTable>): {
260
- /**
261
- * Attach a blob to this record (replaces existing).
262
- * Auto-triggers extractBlobMetadata workflow.
263
- */
264
- attach(blobId: string): Promise<{
265
- id: string;
266
- createdAt: string;
267
- name: string;
268
- recordType: string;
269
- recordId: string;
270
- blobId: string;
271
- }>;
272
- /** Get the attached blob or null. */
273
- get(): Promise<StorageBlob | null>;
274
- /** Check if a blob is attached. */
275
- attached(): Promise<boolean>;
276
- /** Get signed URL or null. */
277
- url(options?: {
278
- expiresIn?: number;
279
- disposition?: "inline" | "attachment";
280
- }): Promise<string | null>;
281
- /** Get permanent public URL or null. */
282
- publicUrl(): Promise<string | null>;
283
- /** Get blob metadata or null. */
284
- metadata(): Promise<Record<string, unknown> | null>;
285
- /** Check if metadata has been extracted. */
286
- analyzed(): Promise<boolean>;
287
- /** Check if blob supports preview/variant generation. */
288
- representable(): Promise<boolean>;
289
- /**
290
- * Get variant URL. Auto-enqueues generation if not ready.
291
- * Returns URL if variant exists, null if generating.
292
- */
293
- variant(transformations: ImageTransformations, expiresIn?: number): Promise<string | null>;
294
- /**
295
- * Get preview URL. Auto-enqueues generation if not ready.
296
- * Returns URL if preview exists, null if generating.
297
- */
298
- preview(expiresIn?: number, timeInSeconds?: number): Promise<string | null>;
299
- /** Detach blob from record (keeps blob for reuse). */
300
- detach(): Promise<boolean>;
301
- /** Delete attachment AND blob immediately. */
302
- purge(): Promise<boolean>;
303
- /** Enqueue attachment and blob deletion in background. */
304
- purgeLater(): Promise<boolean>;
305
- /** Download blob content as Buffer. */
306
- download(): Promise<Buffer | null>;
307
- /** Download to temp file, run callback, auto-cleanup. */
308
- open<T>(callback: (filePath: string) => Promise<T> | T): Promise<T | null>;
309
- /**
310
- * Smart representation - variant for images, preview for videos/PDFs.
311
- * Auto-enqueues generation if not ready.
312
- */
313
- representation(transformations: ImageTransformations, expiresIn?: number): Promise<string | null>;
314
- /** Get blob's byte size. */
315
- byteSize(): Promise<number | null>;
316
- /** Get blob's content type. */
317
- contentType(): Promise<string | null>;
318
- /** Get blob's filename. */
319
- filename(): Promise<string | null>;
320
- /** Get signed, tamper-proof ID for the blob. */
321
- signedId(expiresIn?: number): Promise<string | null>;
322
- };
323
- /**
324
- * Get a multiple attachment handle (one-to-many relationship).
325
- * Similar to Rails' `has_many_attached :images`.
326
- *
327
- * Algorithm:
328
- * Returns an object with methods to manage multiple attachments:
329
- * - attach(): Add blobs (doesn't replace existing)
330
- * - list(): Get all attached blobs
331
- * - urls(): Get signed URLs for all
332
- * - variants(): Get/generate variants for all
333
- * - purge(): Delete all or specific attachment
334
- *
335
- * @template TTable - The table name (must be in TTableNames)
336
- */
337
- many<TTable extends TTableNames>(recordType: TTable, recordId: string, name: AttachmentName<TAttachments, TTable>): {
338
- /**
339
- * Attach one or more blobs (adds to existing, doesn't replace).
340
- * Auto-triggers extractBlobMetadata for each blob.
341
- */
342
- attach(blobIds: string | string[]): Promise<{
343
- id: string;
344
- createdAt: string;
345
- name: string;
346
- recordType: string;
347
- recordId: string;
348
- blobId: string;
349
- }[]>;
350
- /** Get all attached blobs. */
351
- list(): Promise<StorageBlob[]>;
352
- /** Count attached blobs. */
353
- count(): Promise<number>;
354
- /** Get signed URLs for all blobs. */
355
- urls(options?: {
356
- expiresIn?: number;
357
- }): Promise<string[]>;
358
- /** Get public URLs for all blobs. */
359
- publicUrls(): Promise<(string | null)[]>;
360
- /** Get metadata for all blobs. */
361
- metadata(): Promise<(Record<string, unknown> | null)[]>;
362
- /** Check which blobs have been analyzed. */
363
- analyzed(): Promise<boolean[]>;
364
- /** Check which blobs support preview/variants. */
365
- representable(): Promise<boolean[]>;
366
- /** Get variant URLs for all blobs. Auto-enqueues if not ready. */
367
- variants(transformations: ImageTransformations, expiresIn?: number): Promise<(string | null)[]>;
368
- /** Get preview URLs for all blobs. Auto-enqueues if not ready. */
369
- previews(expiresIn?: number, timeInSeconds?: number): Promise<(string | null)[]>;
370
- /** Detach specific blob or all blobs (keeps blobs for reuse). */
371
- detach(blobId?: string): Promise<number>;
372
- /** Delete specific or all attachments AND blobs immediately. */
373
- purge(blobId?: string): Promise<number>;
374
- /** Enqueue specific or all attachments for background deletion. */
375
- purgeLater(blobId?: string): Promise<number>;
376
- /** Download all blobs as Buffers. */
377
- download(): Promise<Buffer[]>;
378
- /** Download each blob to temp file, run callback for each. */
379
- open<T>(callback: (filePath: string, blob: StorageBlob) => Promise<T> | T): Promise<T[]>;
380
- /**
381
- * Smart representations - variant for images, preview for videos/PDFs.
382
- * Auto-enqueues generation if not ready.
383
- */
384
- representations(transformations: ImageTransformations, expiresIn?: number): Promise<(string | null)[]>;
385
- /** Get byte sizes for all blobs. */
386
- byteSizes(): Promise<number[]>;
387
- /** Get content types for all blobs. */
388
- contentTypes(): Promise<(string | null)[]>;
389
- /** Get filenames for all blobs. */
390
- filenames(): Promise<string[]>;
391
- /** Get signed IDs for all blobs. */
392
- signedIds(expiresIn?: number): Promise<string[]>;
393
- };
394
- }
395
- //#endregion
396
- export { Storage };
@@ -1,24 +0,0 @@
1
- import "./container.mjs";
2
- import { z } from "zod";
3
-
4
- //#region src/api/workflow.d.ts
5
-
6
- /**
7
- * Handle to a running or completed workflow.
8
- */
9
- interface WorkflowHandle<TOutput> {
10
- /**
11
- * Get the current status of the workflow.
12
- */
13
- getStatus(): Promise<unknown>;
14
- /**
15
- * Wait for the workflow to complete and return its result.
16
- */
17
- getResult(): Promise<TOutput>;
18
- /**
19
- * The unique ID of this workflow execution.
20
- */
21
- workflowId: string;
22
- }
23
- //#endregion
24
- export { WorkflowHandle };
@@ -1,23 +0,0 @@
1
- //#region src/constants.ts
2
- /**
3
- * Directory for public static assets.
4
- *
5
- * Expected structure:
6
- * - `<project-root>/public/` - Public directory root
7
- * - `<project-root>/public/locales/` - i18n translation files
8
- *
9
- * @default "public"
10
- */
11
- const PUBLIC_DIR = process.env.NODE_ENV === "production" ? "client" : "public";
12
- /**
13
- * File extension for code files based on environment.
14
- *
15
- * In development: `.ts` (TypeScript source files)
16
- * In production: `.js` (bundled JavaScript files)
17
- *
18
- * @default "ts" in development, "js" in production
19
- */
20
- const FILE_EXT = process.env.NODE_ENV === "production" ? "js" : "ts";
21
-
22
- //#endregion
23
- export { };
@@ -1,132 +0,0 @@
1
- import { defineWorkflow } from "./api/workflow.mjs";
2
- import z$1 from "zod";
3
- import { join } from "node:path";
4
- import { ALL_FORMATS, BlobSource, Input } from "mediabunny";
5
-
6
- //#region src/api/workflows/extract-blob-metadata.ts
7
- const extractBlobMetadata = defineWorkflow({
8
- input: z$1.object({ blobId: z$1.string() }),
9
- async run({ container, input: { blobId }, step }) {
10
- const blob = await step("fetch-blob", async () => {
11
- return container.storage.primary.getBlob(blobId);
12
- });
13
- if (!blob) throw new Error(`Blob ${blobId} not found`);
14
- const buffer = await step("download-blob", async () => {
15
- return container.storage.primary.downloadBlob(blobId);
16
- });
17
- if (!buffer) throw new Error(`Failed to download blob ${blobId}`);
18
- let metadata = {};
19
- if (blob.contentType?.startsWith("image/")) metadata = await step("extract-image-metadata", async () => {
20
- const sharp = (await import("sharp")).default;
21
- const info = await sharp(buffer).metadata();
22
- return {
23
- width: info.width,
24
- height: info.height,
25
- format: info.format,
26
- hasAlpha: info.hasAlpha,
27
- space: info.space
28
- };
29
- });
30
- else if (blob.contentType?.startsWith("video/") || blob.contentType?.startsWith("audio/")) metadata = await step("extract-media-metadata", async () => {
31
- const uint8Array = new Uint8Array(buffer);
32
- const input = new Input({
33
- source: new BlobSource(new Blob([uint8Array], { type: blob.contentType || "video/mp4" })),
34
- formats: ALL_FORMATS
35
- });
36
- const duration = await input.computeDuration();
37
- const tags = await input.getMetadataTags();
38
- let videoData = {};
39
- let audioData = {};
40
- let hasVideo = false;
41
- let hasAudio = false;
42
- try {
43
- const videoTrack = await input.getPrimaryVideoTrack();
44
- if (videoTrack) {
45
- hasVideo = true;
46
- const displayAspectRatio = videoTrack.displayWidth && videoTrack.displayHeight ? videoTrack.displayWidth / videoTrack.displayHeight : null;
47
- videoData = {
48
- width: videoTrack.displayWidth,
49
- height: videoTrack.displayHeight,
50
- rotation: videoTrack.rotation,
51
- angle: videoTrack.rotation,
52
- displayAspectRatio
53
- };
54
- }
55
- } catch {}
56
- try {
57
- const audioTrack = await input.getPrimaryAudioTrack();
58
- if (audioTrack) {
59
- hasAudio = true;
60
- audioData = {
61
- sampleRate: audioTrack.sampleRate,
62
- channels: audioTrack.numberOfChannels
63
- };
64
- }
65
- } catch {}
66
- return {
67
- duration,
68
- video: hasVideo,
69
- audio: hasAudio,
70
- ...videoData,
71
- ...audioData,
72
- tags
73
- };
74
- });
75
- else if (blob.contentType === "application/pdf") metadata = await step("extract-pdf-metadata", async () => {
76
- try {
77
- const pdfjsLib = await import("pdfjs-dist/legacy/build/pdf.mjs");
78
- const standardFontDataUrl = `${join(process.cwd(), "node_modules/pdfjs-dist/standard_fonts")}/`;
79
- const pdf = await pdfjsLib.getDocument({
80
- data: new Uint8Array(buffer),
81
- standardFontDataUrl
82
- }).promise;
83
- const pdfMetadata = await pdf.getMetadata();
84
- const viewport = (await pdf.getPage(1)).getViewport({ scale: 1 });
85
- const info = pdfMetadata.info;
86
- return {
87
- pageCount: pdf.numPages,
88
- width: viewport.width,
89
- height: viewport.height,
90
- title: info?.Title || null,
91
- author: info?.Author || null,
92
- subject: info?.Subject || null,
93
- keywords: info?.Keywords || null,
94
- creator: info?.Creator || null,
95
- producer: info?.Producer || null,
96
- creationDate: info?.CreationDate || null,
97
- modificationDate: info?.ModDate || null,
98
- pdfVersion: info?.PDFFormatVersion || null
99
- };
100
- } catch (error) {
101
- container.logger.error({
102
- error,
103
- errorMessage: error instanceof Error ? error.message : String(error),
104
- errorStack: error instanceof Error ? error.stack : void 0,
105
- errorCode: error?.code,
106
- blobId
107
- }, "Failed to extract PDF metadata");
108
- return {
109
- error: "Failed to extract PDF metadata",
110
- errorMessage: error instanceof Error ? error.message : String(error)
111
- };
112
- }
113
- });
114
- await step("save-metadata", async () => {
115
- await container.storage.primary.updateBlobMetadata(blobId, {
116
- ...metadata,
117
- analyzed: true
118
- });
119
- });
120
- container.logger.info({
121
- blobId,
122
- metadata
123
- }, "Metadata extracted");
124
- return {
125
- ...metadata,
126
- analyzed: true
127
- };
128
- }
129
- });
130
-
131
- //#endregion
132
- export { extractBlobMetadata };
@@ -1,63 +0,0 @@
1
- import "./api/workflow.mjs";
2
- import "./api/container.mjs";
3
- import { z } from "zod";
4
-
5
- //#region src/api/workflows/generate-image-variant.d.ts
6
-
7
- /**
8
- * Image transformations schema.
9
- * Supports resize, rotate, flip, flop, sharpen, blur, grayscale, format conversion.
10
- */
11
- declare const transformationsSchema: z.ZodObject<{
12
- resize: z.ZodOptional<z.ZodObject<{
13
- width: z.ZodOptional<z.ZodNumber>;
14
- height: z.ZodOptional<z.ZodNumber>;
15
- fit: z.ZodOptional<z.ZodEnum<{
16
- fill: "fill";
17
- cover: "cover";
18
- contain: "contain";
19
- inside: "inside";
20
- outside: "outside";
21
- }>>;
22
- position: z.ZodOptional<z.ZodEnum<{
23
- left: "left";
24
- right: "right";
25
- top: "top";
26
- "right top": "right top";
27
- "right bottom": "right bottom";
28
- bottom: "bottom";
29
- "left bottom": "left bottom";
30
- "left top": "left top";
31
- centre: "centre";
32
- }>>;
33
- kernel: z.ZodOptional<z.ZodEnum<{
34
- nearest: "nearest";
35
- linear: "linear";
36
- cubic: "cubic";
37
- mitchell: "mitchell";
38
- lanczos2: "lanczos2";
39
- lanczos3: "lanczos3";
40
- }>>;
41
- }, z.core.$strip>>;
42
- rotate: z.ZodOptional<z.ZodNumber>;
43
- flip: z.ZodOptional<z.ZodBoolean>;
44
- flop: z.ZodOptional<z.ZodBoolean>;
45
- sharpen: z.ZodOptional<z.ZodBoolean>;
46
- blur: z.ZodOptional<z.ZodNumber>;
47
- grayscale: z.ZodOptional<z.ZodBoolean>;
48
- format: z.ZodOptional<z.ZodEnum<{
49
- jpeg: "jpeg";
50
- png: "png";
51
- webp: "webp";
52
- avif: "avif";
53
- gif: "gif";
54
- }>>;
55
- quality: z.ZodOptional<z.ZodNumber>;
56
- preview: z.ZodOptional<z.ZodLiteral<true>>;
57
- }, z.core.$strip>;
58
- /**
59
- * Types for image transformations.
60
- */
61
- type ImageTransformations = z.infer<typeof transformationsSchema>;
62
- //#endregion
63
- export { ImageTransformations };