@jrmc/adonis-attachment 5.2.0 → 6.0.0-alpha.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 (404) hide show
  1. package/README.md +10 -73
  2. package/build/bin/test.d.ts +2 -0
  3. package/build/bin/test.d.ts.map +1 -0
  4. package/build/bin/test.js +9 -0
  5. package/build/bin/test.js.map +1 -0
  6. package/build/commands/commands.json +1 -1
  7. package/build/commands/make/attachment_v5_migration.d.ts +17 -0
  8. package/build/commands/make/attachment_v5_migration.d.ts.map +1 -0
  9. package/build/commands/make/attachment_v5_migration.js +26 -0
  10. package/build/commands/make/attachment_v5_migration.js.map +1 -0
  11. package/build/commands/make/{converter.d.ts → attachments_table.d.ts} +6 -4
  12. package/build/commands/make/attachments_table.d.ts.map +1 -0
  13. package/build/commands/make/attachments_table.js +30 -0
  14. package/build/commands/make/attachments_table.js.map +1 -0
  15. package/build/configure.d.ts.map +1 -1
  16. package/build/configure.js +2 -1
  17. package/build/configure.js.map +1 -0
  18. package/build/index.d.ts +23 -8
  19. package/build/index.d.ts.map +1 -1
  20. package/build/index.js +13 -7
  21. package/build/index.js.map +1 -0
  22. package/build/providers/attachment_provider.d.ts +0 -19
  23. package/build/providers/attachment_provider.d.ts.map +1 -1
  24. package/build/providers/attachment_provider.js +30 -26
  25. package/build/providers/attachment_provider.js.map +1 -0
  26. package/build/services/main.d.ts +3 -3
  27. package/build/services/main.d.ts.map +1 -1
  28. package/build/services/main.js +42 -5
  29. package/build/services/main.js.map +1 -0
  30. package/build/src/adapters/adonis_drive_storage.d.ts +33 -0
  31. package/build/src/adapters/adonis_drive_storage.d.ts.map +1 -0
  32. package/build/src/adapters/adonis_drive_storage.js +35 -0
  33. package/build/src/adapters/adonis_drive_storage.js.map +1 -0
  34. package/build/src/adapters/local_file_storage.d.ts +25 -0
  35. package/build/src/adapters/local_file_storage.d.ts.map +1 -0
  36. package/build/src/adapters/local_file_storage.js +54 -0
  37. package/build/src/adapters/local_file_storage.js.map +1 -0
  38. package/build/src/controllers/attachments_controller.d.ts +13 -2
  39. package/build/src/controllers/attachments_controller.d.ts.map +1 -1
  40. package/build/src/controllers/attachments_controller.js +20 -107
  41. package/build/src/controllers/attachments_controller.js.map +1 -0
  42. package/build/src/core/attachment.d.ts +35 -0
  43. package/build/src/core/attachment.d.ts.map +1 -0
  44. package/build/src/core/attachment.js +47 -0
  45. package/build/src/core/attachment.js.map +1 -0
  46. package/build/src/core/attachment_job_processor.d.ts +30 -0
  47. package/build/src/core/attachment_job_processor.d.ts.map +1 -0
  48. package/build/src/core/attachment_job_processor.js +47 -0
  49. package/build/src/core/attachment_job_processor.js.map +1 -0
  50. package/build/src/core/attachment_repository.d.ts +15 -0
  51. package/build/src/core/attachment_repository.d.ts.map +1 -0
  52. package/build/src/core/attachment_repository.js +8 -0
  53. package/build/src/core/attachment_repository.js.map +1 -0
  54. package/build/src/core/attachment_service.d.ts +28 -0
  55. package/build/src/core/attachment_service.d.ts.map +1 -0
  56. package/build/src/core/attachment_service.js +47 -0
  57. package/build/src/core/attachment_service.js.map +1 -0
  58. package/build/src/core/attachment_state.d.ts +11 -0
  59. package/build/src/core/attachment_state.d.ts.map +1 -0
  60. package/build/src/core/attachment_state.js +17 -0
  61. package/build/src/core/attachment_state.js.map +1 -0
  62. package/build/src/core/index.d.ts +13 -0
  63. package/build/src/core/index.d.ts.map +1 -0
  64. package/build/src/core/index.js +10 -0
  65. package/build/src/core/index.js.map +1 -0
  66. package/build/src/core/queue.d.ts +20 -0
  67. package/build/src/core/queue.d.ts.map +1 -0
  68. package/build/src/{types/event.js → core/queue.js} +1 -0
  69. package/build/src/core/queue.js.map +1 -0
  70. package/build/src/core/storage.d.ts +23 -0
  71. package/build/src/core/storage.d.ts.map +1 -0
  72. package/build/src/{types/config.js → core/storage.js} +1 -0
  73. package/build/src/core/storage.js.map +1 -0
  74. package/build/src/define_config.d.ts +35 -20
  75. package/build/src/define_config.d.ts.map +1 -1
  76. package/build/src/define_config.js +45 -24
  77. package/build/src/define_config.js.map +1 -0
  78. package/build/src/integrations/lucid/attachment_column.d.ts +11 -0
  79. package/build/src/integrations/lucid/attachment_column.d.ts.map +1 -0
  80. package/build/src/integrations/lucid/attachment_column.js +138 -0
  81. package/build/src/integrations/lucid/attachment_column.js.map +1 -0
  82. package/build/src/integrations/lucid/attachment_model.d.ts +36 -0
  83. package/build/src/integrations/lucid/attachment_model.d.ts.map +1 -0
  84. package/build/src/integrations/lucid/attachment_model.js +96 -0
  85. package/build/src/integrations/lucid/attachment_model.js.map +1 -0
  86. package/build/src/integrations/lucid/attachment_owner.d.ts +17 -0
  87. package/build/src/integrations/lucid/attachment_owner.d.ts.map +1 -0
  88. package/build/src/integrations/lucid/attachment_owner.js +15 -0
  89. package/build/src/integrations/lucid/attachment_owner.js.map +1 -0
  90. package/build/src/integrations/lucid/attachments_table_stub.d.ts +21 -0
  91. package/build/src/integrations/lucid/attachments_table_stub.d.ts.map +1 -0
  92. package/build/src/integrations/lucid/attachments_table_stub.js +26 -0
  93. package/build/src/integrations/lucid/attachments_table_stub.js.map +1 -0
  94. package/build/src/integrations/lucid/create_legacy_attachment_migration_script.d.ts +13 -0
  95. package/build/src/integrations/lucid/create_legacy_attachment_migration_script.d.ts.map +1 -0
  96. package/build/src/integrations/lucid/create_legacy_attachment_migration_script.js +20 -0
  97. package/build/src/integrations/lucid/create_legacy_attachment_migration_script.js.map +1 -0
  98. package/build/src/integrations/lucid/index.d.ts +19 -0
  99. package/build/src/integrations/lucid/index.d.ts.map +1 -0
  100. package/build/src/integrations/lucid/index.js +19 -0
  101. package/build/src/integrations/lucid/index.js.map +1 -0
  102. package/build/src/integrations/lucid/lucid_attachment_lifecycle_service.d.ts +21 -0
  103. package/build/src/integrations/lucid/lucid_attachment_lifecycle_service.d.ts.map +1 -0
  104. package/build/src/integrations/lucid/lucid_attachment_lifecycle_service.js +68 -0
  105. package/build/src/integrations/lucid/lucid_attachment_lifecycle_service.js.map +1 -0
  106. package/build/src/integrations/lucid/lucid_attachment_repository.d.ts +18 -0
  107. package/build/src/integrations/lucid/lucid_attachment_repository.d.ts.map +1 -0
  108. package/build/src/integrations/lucid/lucid_attachment_repository.js +21 -0
  109. package/build/src/integrations/lucid/lucid_attachment_repository.js.map +1 -0
  110. package/build/src/integrations/lucid/lucid_attachment_store.d.ts +27 -0
  111. package/build/src/integrations/lucid/lucid_attachment_store.d.ts.map +1 -0
  112. package/build/src/integrations/lucid/lucid_attachment_store.js +84 -0
  113. package/build/src/integrations/lucid/lucid_attachment_store.js.map +1 -0
  114. package/build/src/integrations/lucid/lucid_variant_generation_service.d.ts +24 -0
  115. package/build/src/integrations/lucid/lucid_variant_generation_service.d.ts.map +1 -0
  116. package/build/src/integrations/lucid/lucid_variant_generation_service.js +42 -0
  117. package/build/src/integrations/lucid/lucid_variant_generation_service.js.map +1 -0
  118. package/build/src/integrations/lucid/migrate_legacy_attachment.d.ts +57 -0
  119. package/build/src/integrations/lucid/migrate_legacy_attachment.d.ts.map +1 -0
  120. package/build/src/integrations/lucid/migrate_legacy_attachment.js +67 -0
  121. package/build/src/integrations/lucid/migrate_legacy_attachment.js.map +1 -0
  122. package/build/src/integrations/lucid/migrate_legacy_attachment_records.d.ts +34 -0
  123. package/build/src/integrations/lucid/migrate_legacy_attachment_records.d.ts.map +1 -0
  124. package/build/src/integrations/lucid/migrate_legacy_attachment_records.js +47 -0
  125. package/build/src/integrations/lucid/migrate_legacy_attachment_records.js.map +1 -0
  126. package/build/src/integrations/lucid/render_legacy_attachment_migration_script.d.ts +11 -0
  127. package/build/src/integrations/lucid/render_legacy_attachment_migration_script.d.ts.map +1 -0
  128. package/build/src/integrations/lucid/render_legacy_attachment_migration_script.js +41 -0
  129. package/build/src/integrations/lucid/render_legacy_attachment_migration_script.js.map +1 -0
  130. package/build/src/queues/adonis_queue.d.ts +27 -0
  131. package/build/src/queues/adonis_queue.d.ts.map +1 -0
  132. package/build/src/queues/adonis_queue.js +22 -0
  133. package/build/src/queues/adonis_queue.js.map +1 -0
  134. package/build/src/queues/memory_queue.d.ts +22 -0
  135. package/build/src/queues/memory_queue.d.ts.map +1 -0
  136. package/build/src/queues/memory_queue.js +67 -0
  137. package/build/src/queues/memory_queue.js.map +1 -0
  138. package/build/src/sources/attachment_manager.d.ts +51 -0
  139. package/build/src/sources/attachment_manager.d.ts.map +1 -0
  140. package/build/src/sources/attachment_manager.js +169 -0
  141. package/build/src/sources/attachment_manager.js.map +1 -0
  142. package/build/src/variants/variant_converter.d.ts +23 -0
  143. package/build/src/variants/variant_converter.d.ts.map +1 -0
  144. package/build/src/{types/converter.js → variants/variant_converter.js} +1 -0
  145. package/build/src/variants/variant_converter.js.map +1 -0
  146. package/build/src/variants/variant_generation_service.d.ts +28 -0
  147. package/build/src/variants/variant_generation_service.d.ts.map +1 -0
  148. package/build/src/variants/variant_generation_service.js +44 -0
  149. package/build/src/variants/variant_generation_service.js.map +1 -0
  150. package/build/stubs/config/attachment.stub +12 -0
  151. package/build/stubs/main.d.ts.map +1 -1
  152. package/build/stubs/main.js +1 -0
  153. package/build/stubs/main.js.map +1 -0
  154. package/build/stubs/migrations/attachments_table.stub +38 -0
  155. package/build/tests/adonis_drive_storage.spec.d.ts +8 -0
  156. package/build/tests/adonis_drive_storage.spec.d.ts.map +1 -0
  157. package/build/tests/adonis_drive_storage.spec.js +69 -0
  158. package/build/tests/adonis_drive_storage.spec.js.map +1 -0
  159. package/build/{src/types/attachment.js → tests/adonis_queue.spec.d.ts} +1 -0
  160. package/build/tests/adonis_queue.spec.d.ts.map +1 -0
  161. package/build/tests/adonis_queue.spec.js +52 -0
  162. package/build/tests/adonis_queue.spec.js.map +1 -0
  163. package/build/tests/attachment_job_processor.spec.d.ts +8 -0
  164. package/build/tests/attachment_job_processor.spec.d.ts.map +1 -0
  165. package/build/tests/attachment_job_processor.spec.js +89 -0
  166. package/build/tests/attachment_job_processor.spec.js.map +1 -0
  167. package/build/tests/attachment_manager.spec.d.ts +8 -0
  168. package/build/tests/attachment_manager.spec.d.ts.map +1 -0
  169. package/build/tests/attachment_manager.spec.js +128 -0
  170. package/build/tests/attachment_manager.spec.js.map +1 -0
  171. package/build/tests/attachment_manager_service.spec.d.ts +8 -0
  172. package/build/tests/attachment_manager_service.spec.d.ts.map +1 -0
  173. package/build/tests/attachment_manager_service.spec.js +47 -0
  174. package/build/tests/attachment_manager_service.spec.js.map +1 -0
  175. package/build/tests/attachment_provider.spec.d.ts +8 -0
  176. package/build/tests/attachment_provider.spec.d.ts.map +1 -0
  177. package/build/tests/attachment_provider.spec.js +71 -0
  178. package/build/tests/attachment_provider.spec.js.map +1 -0
  179. package/build/tests/attachment_service.spec.d.ts +8 -0
  180. package/build/tests/attachment_service.spec.d.ts.map +1 -0
  181. package/build/tests/attachment_service.spec.js +91 -0
  182. package/build/tests/attachment_service.spec.js.map +1 -0
  183. package/build/tests/attachments_controller.spec.d.ts +8 -0
  184. package/build/tests/attachments_controller.spec.d.ts.map +1 -0
  185. package/build/tests/attachments_controller.spec.js +34 -0
  186. package/build/tests/attachments_controller.spec.js.map +1 -0
  187. package/build/tests/attachments_table_stub.spec.d.ts +2 -0
  188. package/build/tests/attachments_table_stub.spec.d.ts.map +1 -0
  189. package/build/tests/attachments_table_stub.spec.js +65 -0
  190. package/build/tests/attachments_table_stub.spec.js.map +1 -0
  191. package/build/tests/configure.spec.d.ts +2 -0
  192. package/build/tests/configure.spec.d.ts.map +1 -0
  193. package/build/tests/configure.spec.js +38 -0
  194. package/build/tests/configure.spec.js.map +1 -0
  195. package/build/tests/container_bindings.types.d.ts +8 -0
  196. package/build/tests/container_bindings.types.d.ts.map +1 -0
  197. package/build/tests/container_bindings.types.js +9 -0
  198. package/build/tests/container_bindings.types.js.map +1 -0
  199. package/build/tests/create_legacy_attachment_migration_script.spec.d.ts +8 -0
  200. package/build/tests/create_legacy_attachment_migration_script.spec.d.ts.map +1 -0
  201. package/build/tests/create_legacy_attachment_migration_script.spec.js +31 -0
  202. package/build/tests/create_legacy_attachment_migration_script.spec.js.map +1 -0
  203. package/build/tests/define_config.spec.d.ts +8 -0
  204. package/build/tests/define_config.spec.d.ts.map +1 -0
  205. package/build/tests/define_config.spec.js +191 -0
  206. package/build/tests/define_config.spec.js.map +1 -0
  207. package/build/tests/helpers/lucid_test_database.d.ts +9 -0
  208. package/build/tests/helpers/lucid_test_database.d.ts.map +1 -0
  209. package/build/tests/helpers/lucid_test_database.js +51 -0
  210. package/build/tests/helpers/lucid_test_database.js.map +1 -0
  211. package/build/tests/local_file_storage.spec.d.ts +8 -0
  212. package/build/tests/local_file_storage.spec.d.ts.map +1 -0
  213. package/build/tests/local_file_storage.spec.js +44 -0
  214. package/build/tests/local_file_storage.spec.js.map +1 -0
  215. package/build/tests/lucid_attachment_column.spec.d.ts +8 -0
  216. package/build/tests/lucid_attachment_column.spec.d.ts.map +1 -0
  217. package/build/tests/lucid_attachment_column.spec.js +137 -0
  218. package/build/tests/lucid_attachment_column.spec.js.map +1 -0
  219. package/build/tests/lucid_attachment_lifecycle_service.spec.d.ts +8 -0
  220. package/build/tests/lucid_attachment_lifecycle_service.spec.d.ts.map +1 -0
  221. package/build/tests/lucid_attachment_lifecycle_service.spec.js +206 -0
  222. package/build/tests/lucid_attachment_lifecycle_service.spec.js.map +1 -0
  223. package/build/tests/lucid_attachment_repository.spec.d.ts +8 -0
  224. package/build/tests/lucid_attachment_repository.spec.d.ts.map +1 -0
  225. package/build/tests/lucid_attachment_repository.spec.js +50 -0
  226. package/build/tests/lucid_attachment_repository.spec.js.map +1 -0
  227. package/build/tests/lucid_attachment_store.spec.d.ts +8 -0
  228. package/build/tests/lucid_attachment_store.spec.d.ts.map +1 -0
  229. package/build/tests/lucid_attachment_store.spec.js +71 -0
  230. package/build/tests/lucid_attachment_store.spec.js.map +1 -0
  231. package/build/tests/lucid_sqlite_integration.spec.d.ts +8 -0
  232. package/build/tests/lucid_sqlite_integration.spec.d.ts.map +1 -0
  233. package/build/tests/lucid_sqlite_integration.spec.js +103 -0
  234. package/build/tests/lucid_sqlite_integration.spec.js.map +1 -0
  235. package/build/tests/lucid_variant_generation_service.spec.d.ts +8 -0
  236. package/build/tests/lucid_variant_generation_service.spec.d.ts.map +1 -0
  237. package/build/tests/lucid_variant_generation_service.spec.js +56 -0
  238. package/build/tests/lucid_variant_generation_service.spec.js.map +1 -0
  239. package/build/tests/memory_queue.spec.d.ts +8 -0
  240. package/build/tests/memory_queue.spec.d.ts.map +1 -0
  241. package/build/tests/memory_queue.spec.js +52 -0
  242. package/build/tests/memory_queue.spec.js.map +1 -0
  243. package/build/tests/migrate_legacy_attachment.spec.d.ts +8 -0
  244. package/build/tests/migrate_legacy_attachment.spec.d.ts.map +1 -0
  245. package/build/tests/migrate_legacy_attachment.spec.js +91 -0
  246. package/build/tests/migrate_legacy_attachment.spec.js.map +1 -0
  247. package/build/tests/migrate_legacy_attachment_records.spec.d.ts +8 -0
  248. package/build/tests/migrate_legacy_attachment_records.spec.d.ts.map +1 -0
  249. package/build/tests/migrate_legacy_attachment_records.spec.js +66 -0
  250. package/build/tests/migrate_legacy_attachment_records.spec.js.map +1 -0
  251. package/build/tests/package_exports.spec.d.ts +8 -0
  252. package/build/tests/package_exports.spec.d.ts.map +1 -0
  253. package/build/tests/package_exports.spec.js +31 -0
  254. package/build/tests/package_exports.spec.js.map +1 -0
  255. package/build/tests/variant_generation_service.spec.d.ts +8 -0
  256. package/build/tests/variant_generation_service.spec.d.ts.map +1 -0
  257. package/build/tests/variant_generation_service.spec.js +79 -0
  258. package/build/tests/variant_generation_service.spec.js.map +1 -0
  259. package/package.json +82 -78
  260. package/build/commands/make/converter.d.ts.map +0 -1
  261. package/build/commands/make/converter.js +0 -28
  262. package/build/services/regenerate_service.d.ts +0 -9
  263. package/build/services/regenerate_service.d.ts.map +0 -1
  264. package/build/services/regenerate_service.js +0 -29
  265. package/build/src/adapters/blurhash.d.ts +0 -11
  266. package/build/src/adapters/blurhash.d.ts.map +0 -1
  267. package/build/src/adapters/blurhash.js +0 -12
  268. package/build/src/adapters/exif.d.ts +0 -15
  269. package/build/src/adapters/exif.d.ts.map +0 -1
  270. package/build/src/adapters/exif.js +0 -165
  271. package/build/src/adapters/ffmpeg.d.ts +0 -19
  272. package/build/src/adapters/ffmpeg.d.ts.map +0 -1
  273. package/build/src/adapters/ffmpeg.js +0 -115
  274. package/build/src/adapters/lock.d.ts +0 -9
  275. package/build/src/adapters/lock.d.ts.map +0 -1
  276. package/build/src/adapters/lock.js +0 -21
  277. package/build/src/adapters/meta.d.ts +0 -10
  278. package/build/src/adapters/meta.d.ts.map +0 -1
  279. package/build/src/adapters/meta.js +0 -49
  280. package/build/src/adapters/poppler.d.ts +0 -20
  281. package/build/src/adapters/poppler.d.ts.map +0 -1
  282. package/build/src/adapters/poppler.js +0 -117
  283. package/build/src/adapters/soffice.d.ts +0 -14
  284. package/build/src/adapters/soffice.d.ts.map +0 -1
  285. package/build/src/adapters/soffice.js +0 -64
  286. package/build/src/attachment_manager.d.ts +0 -50
  287. package/build/src/attachment_manager.d.ts.map +0 -1
  288. package/build/src/attachment_manager.js +0 -145
  289. package/build/src/attachments/attachment.d.ts +0 -42
  290. package/build/src/attachments/attachment.d.ts.map +0 -1
  291. package/build/src/attachments/attachment.js +0 -233
  292. package/build/src/attachments/attachment_base.d.ts +0 -59
  293. package/build/src/attachments/attachment_base.d.ts.map +0 -1
  294. package/build/src/attachments/attachment_base.js +0 -211
  295. package/build/src/attachments/variant_attachment.d.ts +0 -27
  296. package/build/src/attachments/variant_attachment.d.ts.map +0 -1
  297. package/build/src/attachments/variant_attachment.js +0 -40
  298. package/build/src/converters/autodetect_converter.d.ts +0 -13
  299. package/build/src/converters/autodetect_converter.d.ts.map +0 -1
  300. package/build/src/converters/autodetect_converter.js +0 -77
  301. package/build/src/converters/converter.d.ts +0 -14
  302. package/build/src/converters/converter.d.ts.map +0 -1
  303. package/build/src/converters/converter.js +0 -14
  304. package/build/src/converters/document_thumbnail_converter.d.ts +0 -14
  305. package/build/src/converters/document_thumbnail_converter.d.ts.map +0 -1
  306. package/build/src/converters/document_thumbnail_converter.js +0 -36
  307. package/build/src/converters/image_converter.d.ts +0 -13
  308. package/build/src/converters/image_converter.d.ts.map +0 -1
  309. package/build/src/converters/image_converter.js +0 -27
  310. package/build/src/converters/pdf_thumbnail_converter.d.ts +0 -14
  311. package/build/src/converters/pdf_thumbnail_converter.d.ts.map +0 -1
  312. package/build/src/converters/pdf_thumbnail_converter.js +0 -39
  313. package/build/src/converters/video_thumbnail_converter.d.ts +0 -14
  314. package/build/src/converters/video_thumbnail_converter.d.ts.map +0 -1
  315. package/build/src/converters/video_thumbnail_converter.js +0 -40
  316. package/build/src/decorators/attachment.d.ts +0 -15
  317. package/build/src/decorators/attachment.d.ts.map +0 -1
  318. package/build/src/decorators/attachment.js +0 -103
  319. package/build/src/errors.d.ts +0 -67
  320. package/build/src/errors.d.ts.map +0 -1
  321. package/build/src/errors.js +0 -68
  322. package/build/src/services/attachment/attachment_detachment_service.d.ts +0 -19
  323. package/build/src/services/attachment/attachment_detachment_service.d.ts.map +0 -1
  324. package/build/src/services/attachment/attachment_detachment_service.js +0 -66
  325. package/build/src/services/attachment/attachment_persister_service.d.ts +0 -22
  326. package/build/src/services/attachment/attachment_persister_service.d.ts.map +0 -1
  327. package/build/src/services/attachment/attachment_persister_service.js +0 -96
  328. package/build/src/services/attachment/attachment_recorder_service.d.ts +0 -68
  329. package/build/src/services/attachment/attachment_recorder_service.d.ts.map +0 -1
  330. package/build/src/services/attachment/attachment_recorder_service.js +0 -121
  331. package/build/src/services/attachment/attachment_transaction_service.d.ts +0 -26
  332. package/build/src/services/attachment/attachment_transaction_service.d.ts.map +0 -1
  333. package/build/src/services/attachment/attachment_transaction_service.js +0 -46
  334. package/build/src/services/attachment/attachment_utils.d.ts +0 -35
  335. package/build/src/services/attachment/attachment_utils.d.ts.map +0 -1
  336. package/build/src/services/attachment/attachment_utils.js +0 -71
  337. package/build/src/services/attachment/attachment_variant_service.d.ts +0 -17
  338. package/build/src/services/attachment/attachment_variant_service.d.ts.map +0 -1
  339. package/build/src/services/attachment/attachment_variant_service.js +0 -99
  340. package/build/src/services/attachment/index.d.ts +0 -15
  341. package/build/src/services/attachment/index.d.ts.map +0 -1
  342. package/build/src/services/attachment/index.js +0 -15
  343. package/build/src/services/attachment_service.d.ts +0 -8
  344. package/build/src/services/attachment_service.d.ts.map +0 -1
  345. package/build/src/services/attachment_service.js +0 -7
  346. package/build/src/services/variant/variant_generator_service.d.ts +0 -24
  347. package/build/src/services/variant/variant_generator_service.d.ts.map +0 -1
  348. package/build/src/services/variant/variant_generator_service.js +0 -101
  349. package/build/src/services/variant/variant_persister_service.d.ts +0 -24
  350. package/build/src/services/variant/variant_persister_service.d.ts.map +0 -1
  351. package/build/src/services/variant/variant_persister_service.js +0 -59
  352. package/build/src/services/variant/variant_purger_service.d.ts +0 -15
  353. package/build/src/services/variant/variant_purger_service.d.ts.map +0 -1
  354. package/build/src/services/variant/variant_purger_service.js +0 -47
  355. package/build/src/services/variant_service.d.ts +0 -13
  356. package/build/src/services/variant_service.d.ts.map +0 -1
  357. package/build/src/services/variant_service.js +0 -63
  358. package/build/src/types/attachment.d.ts +0 -100
  359. package/build/src/types/attachment.d.ts.map +0 -1
  360. package/build/src/types/config.d.ts +0 -58
  361. package/build/src/types/config.d.ts.map +0 -1
  362. package/build/src/types/converter.d.ts +0 -144
  363. package/build/src/types/converter.d.ts.map +0 -1
  364. package/build/src/types/drive.d.ts +0 -6
  365. package/build/src/types/drive.d.ts.map +0 -1
  366. package/build/src/types/drive.js +0 -1
  367. package/build/src/types/event.d.ts +0 -16
  368. package/build/src/types/event.d.ts.map +0 -1
  369. package/build/src/types/index.d.ts +0 -15
  370. package/build/src/types/index.d.ts.map +0 -1
  371. package/build/src/types/index.js +0 -14
  372. package/build/src/types/input.d.ts +0 -35
  373. package/build/src/types/input.d.ts.map +0 -1
  374. package/build/src/types/input.js +0 -7
  375. package/build/src/types/lock.d.ts +0 -14
  376. package/build/src/types/lock.d.ts.map +0 -1
  377. package/build/src/types/lock.js +0 -7
  378. package/build/src/types/metadata.d.ts +0 -24
  379. package/build/src/types/metadata.d.ts.map +0 -1
  380. package/build/src/types/metadata.js +0 -7
  381. package/build/src/types/mixin.d.ts +0 -17
  382. package/build/src/types/mixin.d.ts.map +0 -1
  383. package/build/src/types/mixin.js +0 -7
  384. package/build/src/types/regenerate.d.ts +0 -12
  385. package/build/src/types/regenerate.d.ts.map +0 -1
  386. package/build/src/types/regenerate.js +0 -7
  387. package/build/src/types/service.d.ts +0 -25
  388. package/build/src/types/service.d.ts.map +0 -1
  389. package/build/src/types/service.js +0 -7
  390. package/build/src/utils/default_values.d.ts +0 -20
  391. package/build/src/utils/default_values.d.ts.map +0 -1
  392. package/build/src/utils/default_values.js +0 -19
  393. package/build/src/utils/helpers.d.ts +0 -19
  394. package/build/src/utils/helpers.d.ts.map +0 -1
  395. package/build/src/utils/helpers.js +0 -131
  396. package/build/src/utils/hooks.d.ts +0 -12
  397. package/build/src/utils/hooks.d.ts.map +0 -1
  398. package/build/src/utils/hooks.js +0 -42
  399. package/build/src/utils/symbols.d.ts +0 -8
  400. package/build/src/utils/symbols.d.ts.map +0 -1
  401. package/build/src/utils/symbols.js +0 -7
  402. package/build/stubs/config.stub +0 -140
  403. package/build/stubs/make/converter/main.stub +0 -20
  404. package/build/tsconfig.tsbuildinfo +0 -1
@@ -1,115 +0,0 @@
1
- /**
2
- * @jrmc/adonis-attachment
3
- *
4
- * @license MIT
5
- * @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
6
- */
7
- import os from 'node:os';
8
- import path from 'node:path';
9
- import { $, ExecaError } from 'execa';
10
- import { uuid } from '../utils/helpers.js';
11
- import logger from '@adonisjs/core/services/logger';
12
- import { attachmentManager } from '@jrmc/adonis-attachment';
13
- import { secondsToTimeFormat } from '../utils/helpers.js';
14
- export default class FFmpeg {
15
- input;
16
- #ffmpegPath;
17
- #ffprobePath;
18
- #timeout;
19
- #TIMEOUT;
20
- constructor(input) {
21
- this.input = input;
22
- this.#ffmpegPath = 'ffmpeg';
23
- this.#ffprobePath = 'ffprobe';
24
- this.#timeout = null;
25
- this.#TIMEOUT = attachmentManager.getConfig().timeout || 30_000;
26
- }
27
- #createAbortController() {
28
- this.#cleanup();
29
- const controller = new AbortController();
30
- this.#timeout = setTimeout(() => {
31
- controller.abort();
32
- }, this.#TIMEOUT);
33
- return controller;
34
- }
35
- #cleanup() {
36
- if (this.#timeout) {
37
- clearTimeout(this.#timeout);
38
- }
39
- }
40
- async screenshots(options) {
41
- const folder = os.tmpdir();
42
- const filename = `${uuid()}.jpg`;
43
- const { time } = options;
44
- const output = path.join(folder, filename);
45
- const timestamp = secondsToTimeFormat(time);
46
- try {
47
- const { stderr } = await $({
48
- cancelSignal: this.#createAbortController().signal,
49
- gracefulCancel: true,
50
- timeout: this.#TIMEOUT,
51
- }) `${this.#ffmpegPath} -y -i ${this.input} -ss ${timestamp} -vframes 1 -q:v 2 ${output}`;
52
- if (stderr.includes('Output file is empty, nothing was encoded')) {
53
- const durationMatch = stderr.match(/Duration: (\d{2}:\d{2}:\d{2}\.\d{2})/);
54
- if (durationMatch) {
55
- const videoDuration = durationMatch[1];
56
- logger.error(`Video is not long enough. Duration: ${videoDuration}, Requested timestamp: ${timestamp}`);
57
- throw new Error(`Video is not long enough. Duration: ${videoDuration}, Requested timestamp: ${timestamp}`);
58
- }
59
- }
60
- return output;
61
- }
62
- catch (error) {
63
- if (error instanceof ExecaError) {
64
- if (error.failed) {
65
- const stderr = error.stderr;
66
- if (stderr) {
67
- logger.error(stderr.split('\n').pop());
68
- }
69
- throw error;
70
- }
71
- }
72
- else {
73
- logger.error(error);
74
- throw error;
75
- }
76
- }
77
- finally {
78
- this.#cleanup();
79
- }
80
- }
81
- async exif() {
82
- try {
83
- const { stdout } = await $({
84
- cancelSignal: this.#createAbortController().signal,
85
- gracefulCancel: true,
86
- timeout: this.#TIMEOUT,
87
- }) `${this.#ffprobePath} -v quiet -print_format json -show_format -show_streams ${this.input}`;
88
- const metadata = JSON.parse(stdout);
89
- const videoStream = metadata.streams.find((stream) => stream.codec_type === 'video');
90
- const audioStream = metadata.streams.find((stream) => stream.codec_type === 'audio');
91
- return {
92
- types: metadata.streams.map((stream) => stream.codec_type),
93
- width: videoStream?.width,
94
- height: videoStream?.height,
95
- videoCodec: videoStream?.codec_name,
96
- audioCodec: audioStream?.codec_name,
97
- duration: +metadata.format.duration,
98
- size: +metadata.format.size,
99
- };
100
- }
101
- catch (error) {
102
- logger.error(error);
103
- throw error;
104
- }
105
- finally {
106
- this.#cleanup();
107
- }
108
- }
109
- async setFfmpegPath(ffmpegPath) {
110
- this.#ffmpegPath = ffmpegPath;
111
- }
112
- async setFfprobePath(ffprobePath) {
113
- this.#ffprobePath = ffprobePath;
114
- }
115
- }
@@ -1,9 +0,0 @@
1
- /**
2
- * @jrmc/adonis-attachment
3
- *
4
- * @license MIT
5
- * @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
6
- */
7
- import type { LockService } from '../types/lock.js';
8
- export declare const verrou: (lock?: LockService) => LockService;
9
- //# sourceMappingURL=lock.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"lock.d.ts","sourceRoot":"","sources":["../../../src/adapters/lock.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAKnD,eAAO,MAAM,MAAM,GAAI,OAAO,WAAW,KAAG,WAW3C,CAAA"}
@@ -1,21 +0,0 @@
1
- /**
2
- * @jrmc/adonis-attachment
3
- *
4
- * @license MIT
5
- * @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
6
- */
7
- import { Verrou } from '@verrou/core';
8
- import { memoryStore } from '@verrou/core/drivers/memory';
9
- export const verrou = (lock) => {
10
- if (lock) {
11
- return lock;
12
- }
13
- else {
14
- return new Verrou({
15
- default: 'memory',
16
- stores: {
17
- memory: { driver: memoryStore() },
18
- },
19
- });
20
- }
21
- };
@@ -1,10 +0,0 @@
1
- /**
2
- * @jrmc/adonis-attachment
3
- *
4
- * @license MIT
5
- * @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
6
- */
7
- import { Meta } from '../types/input.js';
8
- export declare function metaFromBuffer(input: Buffer): Promise<Meta>;
9
- export declare function metaFromFile(input: string, filename: string): Promise<Meta>;
10
- //# sourceMappingURL=meta.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"meta.d.ts","sourceRoot":"","sources":["../../../src/adapters/meta.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAA;AAuBxC,wBAAsB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAYjE;AAED,wBAAsB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAiBjF"}
@@ -1,49 +0,0 @@
1
- /**
2
- * @jrmc/adonis-attachment
3
- *
4
- * @license MIT
5
- * @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
6
- */
7
- import path from 'node:path';
8
- import fs from 'node:fs/promises';
9
- import { fileTypeFromBuffer, fileTypeFromFile } from 'file-type';
10
- import mime from 'mime-types';
11
- function getFileExtension(filename) {
12
- if (!filename) {
13
- return '';
14
- }
15
- const ext = path.extname(filename).slice(1);
16
- return ext && /^[a-zA-Z0-9]+$/.test(ext) ? ext : '';
17
- }
18
- function metaByFileName(filename) {
19
- return {
20
- ext: getFileExtension(filename),
21
- mime: mime.lookup(filename) || '',
22
- };
23
- }
24
- export async function metaFromBuffer(input) {
25
- let fileType = await fileTypeFromBuffer(input);
26
- if (input.toString('utf8').includes('<svg')) {
27
- fileType = { mime: 'image/svg+xml', ext: 'svg' };
28
- }
29
- return {
30
- extname: fileType?.ext || '',
31
- mimeType: fileType?.mime || '',
32
- size: input.length,
33
- };
34
- }
35
- export async function metaFromFile(input, filename) {
36
- let fileType;
37
- let size = 0;
38
- fileType = metaByFileName(filename);
39
- if (fileType.ext === '' || fileType.mime === '') {
40
- fileType = await fileTypeFromFile(input);
41
- }
42
- const stats = await fs.stat(input);
43
- size = stats.size;
44
- return {
45
- extname: fileType?.ext || '',
46
- mimeType: fileType?.mime || '',
47
- size,
48
- };
49
- }
@@ -1,20 +0,0 @@
1
- /**
2
- * @jrmc/adonis-attachment
3
- *
4
- * @license MIT
5
- * @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
6
- */
7
- import { PopplerMetadata } from '../types/metadata.js';
8
- export default class Poppler {
9
- #private;
10
- private input;
11
- constructor(input: string);
12
- pdfToPpm(options: {
13
- page: number;
14
- dpi: number;
15
- }): Promise<string>;
16
- pdfInfo(): Promise<PopplerMetadata>;
17
- setPdfToPpmPath(pdftoppm: string): Promise<void>;
18
- setPdfInfoPath(pdfinfo: string): Promise<void>;
19
- }
20
- //# sourceMappingURL=poppler.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"poppler.d.ts","sourceRoot":"","sources":["../../../src/adapters/poppler.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAGtD,MAAM,CAAC,OAAO,OAAO,OAAO;;IAMd,OAAO,CAAC,KAAK;gBAAL,KAAK,EAAE,MAAM;IAuB3B,QAAQ,CAAC,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE;IAuB/C,OAAO,IAAI,OAAO,CAAC,eAAe,CAAC;IA0DnC,eAAe,CAAC,QAAQ,EAAE,MAAM;IAIhC,cAAc,CAAC,OAAO,EAAE,MAAM;CAGrC"}
@@ -1,117 +0,0 @@
1
- /**
2
- * @jrmc/adonis-attachment
3
- *
4
- * @license MIT
5
- * @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
6
- */
7
- import os from 'node:os';
8
- import path from 'node:path';
9
- import { $ } from 'execa';
10
- import { uuid } from '../utils/helpers.js';
11
- import logger from '@adonisjs/core/services/logger';
12
- import { attachmentManager } from '@jrmc/adonis-attachment';
13
- import { DateTime } from 'luxon';
14
- export default class Poppler {
15
- input;
16
- #pdfToPpmPath;
17
- #pdfInfoPath;
18
- #timeout;
19
- #TIMEOUT;
20
- constructor(input) {
21
- this.input = input;
22
- this.#pdfToPpmPath = 'pdftoppm';
23
- this.#pdfInfoPath = 'pdfinfo';
24
- this.#timeout = null;
25
- this.#TIMEOUT = attachmentManager.getConfig().timeout || 30_000;
26
- }
27
- #createAbortController() {
28
- this.#cleanup();
29
- const controller = new AbortController();
30
- this.#timeout = setTimeout(() => {
31
- controller.abort();
32
- }, this.#TIMEOUT);
33
- return controller;
34
- }
35
- #cleanup() {
36
- if (this.#timeout) {
37
- clearTimeout(this.#timeout);
38
- }
39
- }
40
- async pdfToPpm(options) {
41
- const output = path.join(os.tmpdir(), uuid());
42
- try {
43
- await $({
44
- cancelSignal: this.#createAbortController().signal,
45
- gracefulCancel: true,
46
- timeout: this.#TIMEOUT,
47
- }) `${this.#pdfToPpmPath} -f ${options.page.toString()} -l ${options.page.toString()} -r ${options.dpi.toString()} -jpeg ${this.input} ${output}`;
48
- const pdfInfo = await this.pdfInfo();
49
- const pageNumberFormat = '0'.repeat(String(pdfInfo.pages).length - String(options.page).length);
50
- return `${output}-${pageNumberFormat}${options.page}.jpg`;
51
- }
52
- catch (error) {
53
- logger.error('Error while converting PDF to PPM:', error);
54
- throw error;
55
- }
56
- finally {
57
- this.#cleanup();
58
- }
59
- }
60
- async pdfInfo() {
61
- try {
62
- const { stdout } = await $({
63
- cancelSignal: this.#createAbortController().signal,
64
- gracefulCancel: true,
65
- timeout: this.#TIMEOUT,
66
- }) `${this.#pdfInfoPath} ${this.input}`;
67
- const metadata = {};
68
- stdout.split('\n').forEach((line) => {
69
- const colonIndex = line.indexOf(':');
70
- if (colonIndex > 0) {
71
- const key = line.substring(0, colonIndex).trim();
72
- const value = line.substring(colonIndex + 1).trim();
73
- if (key && value) {
74
- metadata[key.toLowerCase()] = value;
75
- }
76
- }
77
- });
78
- const pageSizeMatch = metadata['page size']?.match(/(\d+)\s*x\s*(\d+)/);
79
- const [width, height] = pageSizeMatch
80
- ? [parseInt(pageSizeMatch[1]), parseInt(pageSizeMatch[2])]
81
- : [0, 0];
82
- const fileSizeMatch = metadata['file size']?.match(/(\d+)/);
83
- const size = fileSizeMatch ? parseInt(fileSizeMatch[1]) : 0;
84
- const version = metadata['pdf version'] || '';
85
- const pages = parseInt(metadata['pages'] || '0');
86
- let creationDate = '';
87
- if (metadata['creationdate']) {
88
- const dateStr = metadata['creationdate'];
89
- const date = DateTime.fromFormat(dateStr, 'EEE MMM dd HH:mm:ss yyyy z', { zone: 'UTC' });
90
- if (date.isValid) {
91
- creationDate = date.toFormat("yyyy-MM-dd'T'HH:mm:ss");
92
- }
93
- }
94
- return {
95
- size,
96
- version,
97
- width,
98
- height,
99
- pages,
100
- creationDate,
101
- };
102
- }
103
- catch (error) {
104
- logger.error('Error while retrieving metadata:', error);
105
- throw error;
106
- }
107
- finally {
108
- this.#cleanup();
109
- }
110
- }
111
- async setPdfToPpmPath(pdftoppm) {
112
- this.#pdfToPpmPath = pdftoppm;
113
- }
114
- async setPdfInfoPath(pdfinfo) {
115
- this.#pdfInfoPath = pdfinfo;
116
- }
117
- }
@@ -1,14 +0,0 @@
1
- /**
2
- * @jrmc/adonis-attachment
3
- *
4
- * @license MIT
5
- * @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
6
- */
7
- export default class Soffice {
8
- #private;
9
- private input;
10
- constructor(input: string);
11
- convert(): Promise<string>;
12
- setSofficePath(sofficePath: string): Promise<void>;
13
- }
14
- //# sourceMappingURL=soffice.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"soffice.d.ts","sourceRoot":"","sources":["../../../src/adapters/soffice.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH,MAAM,CAAC,OAAO,OAAO,OAAO;;IAKd,OAAO,CAAC,KAAK;gBAAL,KAAK,EAAE,MAAM;IAsB3B,OAAO;IA2BP,cAAc,CAAC,WAAW,EAAE,MAAM;CAGzC"}
@@ -1,64 +0,0 @@
1
- /**
2
- * @jrmc/adonis-attachment
3
- *
4
- * @license MIT
5
- * @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
6
- */
7
- import os from 'node:os';
8
- import path from 'node:path';
9
- import { $ } from 'execa';
10
- import logger from '@adonisjs/core/services/logger';
11
- import { attachmentManager } from '@jrmc/adonis-attachment';
12
- export default class Soffice {
13
- input;
14
- #sofficePath;
15
- #timeout;
16
- #TIMEOUT;
17
- constructor(input) {
18
- this.input = input;
19
- this.#sofficePath = 'soffice';
20
- this.#timeout = null;
21
- this.#TIMEOUT = attachmentManager.getConfig().timeout || 30_000;
22
- }
23
- #createAbortController() {
24
- this.#cleanup();
25
- const controller = new AbortController();
26
- this.#timeout = setTimeout(() => {
27
- controller.abort();
28
- }, this.#TIMEOUT);
29
- return controller;
30
- }
31
- #cleanup() {
32
- if (this.#timeout) {
33
- clearTimeout(this.#timeout);
34
- }
35
- }
36
- async convert() {
37
- const output = os.tmpdir();
38
- try {
39
- const { stderr } = await $({
40
- cancelSignal: this.#createAbortController().signal,
41
- gracefulCancel: true,
42
- timeout: this.#TIMEOUT,
43
- }) `${this.#sofficePath} --headless --writer --convert-to jpg ${this.input} --outdir ${output}`;
44
- if (stderr) {
45
- logger.error('Error while converting Document to Image:', stderr);
46
- throw stderr;
47
- }
48
- const ext = path.extname(this.input);
49
- const baseName = path.basename(this.input, ext);
50
- const imagePath = path.join(output, baseName + '.jpg');
51
- return imagePath;
52
- }
53
- catch (error) {
54
- logger.error('Error while converting Document to Image:', error);
55
- throw error;
56
- }
57
- finally {
58
- this.#cleanup();
59
- }
60
- }
61
- async setSofficePath(sofficePath) {
62
- this.#sofficePath = sofficePath;
63
- }
64
- }
@@ -1,50 +0,0 @@
1
- /**
2
- * @jrmc/adonis-attachment
3
- *
4
- * @license MIT
5
- * @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
6
- */
7
- import type { SignedURLOptions } from '@adonisjs/drive/types';
8
- import type { MultipartFile } from '@adonisjs/core/bodyparser';
9
- import type { LockService } from './types/lock.js';
10
- import type { Drive } from './types/drive.js';
11
- import type { AttachmentAttributes, AttachmentBase, Attachment as AttachmentType } from './types/attachment.js';
12
- import type { ResolvedAttachmentConfig } from './define_config.js';
13
- import { DeferQueue } from '@poppinss/defer';
14
- import Converter from './converters/converter.js';
15
- export declare class AttachmentManager<KnownConverters extends Record<string, Converter>> {
16
- #private;
17
- queue: DeferQueue;
18
- constructor(config: ResolvedAttachmentConfig<KnownConverters>, drive: Drive, lock: LockService);
19
- createFromDbResponse(response?: string | JSON): AttachmentType | null;
20
- createFromFile(input: MultipartFile): Promise<AttachmentType>;
21
- createFromFiles(inputs: MultipartFile[]): Promise<(AttachmentBase & {
22
- originalName: string;
23
- variants?: import("./types/attachment.js").Variant[];
24
- createVariant(key: string, input: import("./types/input.js").Input, options?: {
25
- basePath?: string;
26
- ignoreFolder?: boolean;
27
- }): Promise<import("./types/attachment.js").Variant>;
28
- getVariant(variantName: string): import("./types/attachment.js").Variant | null;
29
- getUrl(variantName?: string): Promise<string>;
30
- getSignedUrl(variantNameOrOptions?: string | SignedURLOptions, signedUrlOptions?: SignedURLOptions): Promise<string>;
31
- preComputeUrl(): Promise<void>;
32
- moveFileForDelete(): Promise<void>;
33
- rollbackMoveFileForDelete(): Promise<void>;
34
- remove(): Promise<void>;
35
- toObject(): AttachmentAttributes;
36
- })[]>;
37
- createFromPath(input: string, name?: string): Promise<AttachmentType>;
38
- createFromBuffer(input: Buffer, name?: string): Promise<AttachmentType>;
39
- createFromBase64(input: string, name?: string): Promise<AttachmentType>;
40
- createFromUrl(input: URL, name?: string): Promise<AttachmentType>;
41
- createFromStream(stream: NodeJS.ReadableStream, name?: string): Promise<AttachmentType>;
42
- computeUrl(attachment: AttachmentType | AttachmentBase, signedUrlOptions?: SignedURLOptions): Promise<void>;
43
- preComputeUrl(attachment: AttachmentType): Promise<void>;
44
- write(attachment: AttachmentBase): Promise<void>;
45
- remove(attachment: AttachmentBase): Promise<void>;
46
- get lock(): LockService;
47
- getConfig(): ResolvedAttachmentConfig<KnownConverters>;
48
- getConverter(key: string): Promise<void | Converter>;
49
- }
50
- //# sourceMappingURL=attachment_manager.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"attachment_manager.d.ts","sourceRoot":"","sources":["../../src/attachment_manager.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAC7D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAC9D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAClD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AAE7C,OAAO,KAAK,EACV,oBAAoB,EACpB,cAAc,EACd,UAAU,IAAI,cAAc,EAC7B,MAAM,uBAAuB,CAAA;AAC9B,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAA;AAGlE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAG5C,OAAO,SAAS,MAAM,2BAA2B,CAAA;AAQjD,qBAAa,iBAAiB,CAAC,eAAe,SAAS,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC;;IAC9E,KAAK,aAAA;gBAKO,MAAM,EAAE,wBAAwB,CAAC,eAAe,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,WAAW;IAU9F,oBAAoB,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI;IAiBvC,cAAc,CAAC,KAAK,EAAE,aAAa;IAgBnC,eAAe,CAAC,MAAM,EAAE,aAAa,EAAE;;;;oBA5BxC,CAAC;wBAAsB,CAAC;;;;;;;;;;;IAgCvB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM;IAiB3C,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM;IAgB7C,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM;IAW7C,aAAa,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE,MAAM;IAMvC,gBAAgB,CAAC,MAAM,EAAE,MAAM,CAAC,cAAc,EAAE,IAAI,CAAC,EAAE,MAAM;IAM7D,UAAU,CACd,UAAU,EAAE,cAAc,GAAG,cAAc,EAC3C,gBAAgB,CAAC,EAAE,gBAAgB;IAK/B,aAAa,CAAC,UAAU,EAAE,cAAc;IAIxC,KAAK,CAAC,UAAU,EAAE,cAAc;IAchC,MAAM,CAAC,UAAU,EAAE,cAAc;IAMvC,IAAI,IAAI,gBAEP;IAED,SAAS;IAIH,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,GAAG,SAAS,CAAC;CAuB3D"}
@@ -1,145 +0,0 @@
1
- /**
2
- * @jrmc/adonis-attachment
3
- *
4
- * @license MIT
5
- * @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
6
- */
7
- import path from 'node:path';
8
- import { DeferQueue } from '@poppinss/defer';
9
- import * as errors from './errors.js';
10
- import { Attachment } from './attachments/attachment.js';
11
- import { downloadToTempFile, isBase64, streamToTempFile } from './utils/helpers.js';
12
- import ExifAdapter from './adapters/exif.js';
13
- import { metaFromBuffer, metaFromFile } from './adapters/meta.js';
14
- import { uuid } from './utils/helpers.js';
15
- const REQUIRED_ATTRIBUTES = ['name', 'size', 'extname', 'mimeType'];
16
- export class AttachmentManager {
17
- queue;
18
- #config;
19
- #drive;
20
- #lock;
21
- constructor(config, drive, lock) {
22
- this.#drive = drive;
23
- this.#lock = lock;
24
- this.#config = config;
25
- const concurrency = this.#config.queue?.concurrency || 1;
26
- this.queue = new DeferQueue({ concurrency });
27
- }
28
- createFromDbResponse(response) {
29
- if (response === null) {
30
- return null;
31
- }
32
- const attributes = typeof response === 'string' ? JSON.parse(response) : response;
33
- REQUIRED_ATTRIBUTES.forEach((attribute) => {
34
- if (attributes[attribute] === undefined) {
35
- throw new errors.E_CANNOT_CREATE_ATTACHMENT([attribute]);
36
- }
37
- });
38
- const attachment = new Attachment(this.#drive.driveManager, attributes);
39
- return this.#configureAttachment(attachment);
40
- }
41
- async createFromFile(input) {
42
- const attributes = {
43
- originalName: input.clientName,
44
- extname: input.extname || '',
45
- mimeType: input.type && input.subtype ? `${input.type}/${input.subtype}` : '',
46
- size: input.size,
47
- };
48
- if (!input.tmpPath) {
49
- throw new errors.ENOENT();
50
- }
51
- const attachment = new Attachment(this.#drive.driveManager, attributes, input.tmpPath);
52
- return this.#configureAttachment(attachment);
53
- }
54
- async createFromFiles(inputs) {
55
- return Promise.all(inputs.map((input) => this.createFromFile(input)));
56
- }
57
- async createFromPath(input, name) {
58
- const meta = await metaFromFile(input, name || input);
59
- if (meta.extname === '') {
60
- meta.extname = 'tmp';
61
- meta.mimeType = 'application/x-temp';
62
- }
63
- const attributes = {
64
- ...meta,
65
- originalName: name?.replace('tmp', meta.extname) || path.basename(input),
66
- };
67
- const attachment = new Attachment(this.#drive.driveManager, attributes, input);
68
- return this.#configureAttachment(attachment);
69
- }
70
- async createFromBuffer(input, name) {
71
- if (!Buffer.isBuffer(input)) {
72
- throw new errors.E_ISNOT_BUFFER();
73
- }
74
- const meta = await metaFromBuffer(input);
75
- const ext = meta.extname || 'tmp';
76
- const attributes = {
77
- ...meta,
78
- originalName: name || `${uuid()}.${ext}`,
79
- };
80
- const attachment = new Attachment(this.#drive.driveManager, attributes, input);
81
- return this.#configureAttachment(attachment);
82
- }
83
- async createFromBase64(input, name) {
84
- const base64Data = input.replace(/^data:([A-Za-z-+\/]+);base64,/, '');
85
- if (!isBase64(base64Data)) {
86
- throw new errors.E_ISNOT_BASE64();
87
- }
88
- const buffer = Buffer.from(base64Data, 'base64');
89
- return this.createFromBuffer(buffer, name);
90
- }
91
- async createFromUrl(input, name) {
92
- const tmpPath = await downloadToTempFile(input);
93
- return this.createFromPath(tmpPath, name || path.basename(input.pathname));
94
- }
95
- async createFromStream(stream, name) {
96
- const tmpPath = await streamToTempFile(stream);
97
- return this.createFromPath(tmpPath, name || path.basename(tmpPath));
98
- }
99
- async computeUrl(attachment, signedUrlOptions) {
100
- await attachment.computeUrl(signedUrlOptions);
101
- }
102
- async preComputeUrl(attachment) {
103
- await attachment.preComputeUrl();
104
- }
105
- async write(attachment) {
106
- if (attachment.options?.meta) {
107
- attachment.meta = await ExifAdapter.exif(attachment.input, this.#config);
108
- }
109
- else {
110
- attachment.meta = undefined;
111
- }
112
- if (this.#drive.diskDefault !== undefined && attachment.disk === undefined) {
113
- attachment.setOptions({ disk: attachment.options?.disk ?? this.#drive.diskDefault });
114
- }
115
- await attachment.put();
116
- }
117
- async remove(attachment) {
118
- await attachment.remove();
119
- }
120
- // getters
121
- get lock() {
122
- return this.#lock;
123
- }
124
- getConfig() {
125
- return this.#config;
126
- }
127
- async getConverter(key) {
128
- if (this.#config.converters) {
129
- return this.#config.converters[key];
130
- }
131
- }
132
- // private methods
133
- #configureAttachment(attachment) {
134
- if (this.#config.meta !== undefined) {
135
- attachment.setOptions({ meta: this.#config.meta });
136
- }
137
- if (this.#config.rename !== undefined) {
138
- attachment.setOptions({ rename: this.#config.rename });
139
- }
140
- if (this.#config.preComputeUrl !== undefined) {
141
- attachment.setOptions({ preComputeUrl: this.#config.preComputeUrl });
142
- }
143
- return attachment;
144
- }
145
- }