@jrmc/adonis-attachment 5.2.1 → 6.0.0-alpha.1

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 (424) hide show
  1. package/README.md +10 -81
  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 +26 -10
  19. package/build/index.d.ts.map +1 -1
  20. package/build/index.js +16 -9
  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 +70 -0
  43. package/build/src/core/attachment.d.ts.map +1 -0
  44. package/build/src/core/attachment.js +150 -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_options.d.ts +32 -0
  51. package/build/src/core/attachment_options.d.ts.map +1 -0
  52. package/build/src/core/attachment_options.js +24 -0
  53. package/build/src/core/attachment_options.js.map +1 -0
  54. package/build/src/core/attachment_repository.d.ts +15 -0
  55. package/build/src/core/attachment_repository.d.ts.map +1 -0
  56. package/build/src/core/attachment_repository.js +8 -0
  57. package/build/src/core/attachment_repository.js.map +1 -0
  58. package/build/src/core/attachment_service.d.ts +34 -0
  59. package/build/src/core/attachment_service.d.ts.map +1 -0
  60. package/build/src/core/attachment_service.js +93 -0
  61. package/build/src/core/attachment_service.js.map +1 -0
  62. package/build/src/core/attachment_state.d.ts +11 -0
  63. package/build/src/core/attachment_state.d.ts.map +1 -0
  64. package/build/src/core/attachment_state.js +17 -0
  65. package/build/src/core/attachment_state.js.map +1 -0
  66. package/build/src/core/index.d.ts +14 -0
  67. package/build/src/core/index.d.ts.map +1 -0
  68. package/build/src/core/index.js +11 -0
  69. package/build/src/core/index.js.map +1 -0
  70. package/build/src/core/queue.d.ts +20 -0
  71. package/build/src/core/queue.d.ts.map +1 -0
  72. package/build/src/{types/event.js → core/queue.js} +1 -0
  73. package/build/src/core/queue.js.map +1 -0
  74. package/build/src/core/storage.d.ts +23 -0
  75. package/build/src/core/storage.d.ts.map +1 -0
  76. package/build/src/{types/config.js → core/storage.js} +1 -0
  77. package/build/src/core/storage.js.map +1 -0
  78. package/build/src/define_config.d.ts +39 -20
  79. package/build/src/define_config.d.ts.map +1 -1
  80. package/build/src/define_config.js +46 -24
  81. package/build/src/define_config.js.map +1 -0
  82. package/build/src/integrations/lucid/attachment_column.d.ts +18 -0
  83. package/build/src/integrations/lucid/attachment_column.d.ts.map +1 -0
  84. package/build/src/integrations/lucid/attachment_column.js +151 -0
  85. package/build/src/integrations/lucid/attachment_column.js.map +1 -0
  86. package/build/src/integrations/lucid/attachment_model.d.ts +37 -0
  87. package/build/src/integrations/lucid/attachment_model.d.ts.map +1 -0
  88. package/build/src/integrations/lucid/attachment_model.js +99 -0
  89. package/build/src/integrations/lucid/attachment_model.js.map +1 -0
  90. package/build/src/integrations/lucid/attachment_owner.d.ts +18 -0
  91. package/build/src/integrations/lucid/attachment_owner.d.ts.map +1 -0
  92. package/build/src/integrations/lucid/attachment_owner.js +15 -0
  93. package/build/src/integrations/lucid/attachment_owner.js.map +1 -0
  94. package/build/src/integrations/lucid/attachment_relation.d.ts +60 -0
  95. package/build/src/integrations/lucid/attachment_relation.d.ts.map +1 -0
  96. package/build/src/integrations/lucid/attachment_relation.js +163 -0
  97. package/build/src/integrations/lucid/attachment_relation.js.map +1 -0
  98. package/build/src/integrations/lucid/attachments_table_stub.d.ts +21 -0
  99. package/build/src/integrations/lucid/attachments_table_stub.d.ts.map +1 -0
  100. package/build/src/integrations/lucid/attachments_table_stub.js +26 -0
  101. package/build/src/integrations/lucid/attachments_table_stub.js.map +1 -0
  102. package/build/src/integrations/lucid/create_legacy_attachment_migration_script.d.ts +13 -0
  103. package/build/src/integrations/lucid/create_legacy_attachment_migration_script.d.ts.map +1 -0
  104. package/build/src/integrations/lucid/create_legacy_attachment_migration_script.js +20 -0
  105. package/build/src/integrations/lucid/create_legacy_attachment_migration_script.js.map +1 -0
  106. package/build/src/integrations/lucid/index.d.ts +20 -0
  107. package/build/src/integrations/lucid/index.d.ts.map +1 -0
  108. package/build/src/integrations/lucid/index.js +20 -0
  109. package/build/src/integrations/lucid/index.js.map +1 -0
  110. package/build/src/integrations/lucid/lucid_attachment_lifecycle_service.d.ts +30 -0
  111. package/build/src/integrations/lucid/lucid_attachment_lifecycle_service.d.ts.map +1 -0
  112. package/build/src/integrations/lucid/lucid_attachment_lifecycle_service.js +188 -0
  113. package/build/src/integrations/lucid/lucid_attachment_lifecycle_service.js.map +1 -0
  114. package/build/src/integrations/lucid/lucid_attachment_repository.d.ts +18 -0
  115. package/build/src/integrations/lucid/lucid_attachment_repository.d.ts.map +1 -0
  116. package/build/src/integrations/lucid/lucid_attachment_repository.js +21 -0
  117. package/build/src/integrations/lucid/lucid_attachment_repository.js.map +1 -0
  118. package/build/src/integrations/lucid/lucid_attachment_store.d.ts +36 -0
  119. package/build/src/integrations/lucid/lucid_attachment_store.d.ts.map +1 -0
  120. package/build/src/integrations/lucid/lucid_attachment_store.js +179 -0
  121. package/build/src/integrations/lucid/lucid_attachment_store.js.map +1 -0
  122. package/build/src/integrations/lucid/lucid_variant_generation_service.d.ts +24 -0
  123. package/build/src/integrations/lucid/lucid_variant_generation_service.d.ts.map +1 -0
  124. package/build/src/integrations/lucid/lucid_variant_generation_service.js +42 -0
  125. package/build/src/integrations/lucid/lucid_variant_generation_service.js.map +1 -0
  126. package/build/src/integrations/lucid/migrate_legacy_attachment.d.ts +64 -0
  127. package/build/src/integrations/lucid/migrate_legacy_attachment.d.ts.map +1 -0
  128. package/build/src/integrations/lucid/migrate_legacy_attachment.js +89 -0
  129. package/build/src/integrations/lucid/migrate_legacy_attachment.js.map +1 -0
  130. package/build/src/integrations/lucid/migrate_legacy_attachment_records.d.ts +34 -0
  131. package/build/src/integrations/lucid/migrate_legacy_attachment_records.d.ts.map +1 -0
  132. package/build/src/integrations/lucid/migrate_legacy_attachment_records.js +47 -0
  133. package/build/src/integrations/lucid/migrate_legacy_attachment_records.js.map +1 -0
  134. package/build/src/integrations/lucid/render_legacy_attachment_migration_script.d.ts +11 -0
  135. package/build/src/integrations/lucid/render_legacy_attachment_migration_script.d.ts.map +1 -0
  136. package/build/src/integrations/lucid/render_legacy_attachment_migration_script.js +41 -0
  137. package/build/src/integrations/lucid/render_legacy_attachment_migration_script.js.map +1 -0
  138. package/build/src/queues/adonis_queue.d.ts +27 -0
  139. package/build/src/queues/adonis_queue.d.ts.map +1 -0
  140. package/build/src/queues/adonis_queue.js +22 -0
  141. package/build/src/queues/adonis_queue.js.map +1 -0
  142. package/build/src/queues/memory_queue.d.ts +22 -0
  143. package/build/src/queues/memory_queue.d.ts.map +1 -0
  144. package/build/src/queues/memory_queue.js +67 -0
  145. package/build/src/queues/memory_queue.js.map +1 -0
  146. package/build/src/sources/attachment_manager.d.ts +53 -0
  147. package/build/src/sources/attachment_manager.d.ts.map +1 -0
  148. package/build/src/sources/attachment_manager.js +177 -0
  149. package/build/src/sources/attachment_manager.js.map +1 -0
  150. package/build/src/variants/variant_converter.d.ts +23 -0
  151. package/build/src/variants/variant_converter.d.ts.map +1 -0
  152. package/build/src/{types/converter.js → variants/variant_converter.js} +1 -0
  153. package/build/src/variants/variant_converter.js.map +1 -0
  154. package/build/src/variants/variant_generation_service.d.ts +28 -0
  155. package/build/src/variants/variant_generation_service.d.ts.map +1 -0
  156. package/build/src/variants/variant_generation_service.js +44 -0
  157. package/build/src/variants/variant_generation_service.js.map +1 -0
  158. package/build/stubs/config/attachment.stub +12 -0
  159. package/build/stubs/main.d.ts.map +1 -1
  160. package/build/stubs/main.js +1 -0
  161. package/build/stubs/main.js.map +1 -0
  162. package/build/stubs/migrations/attachments_table.stub +39 -0
  163. package/build/tests/adonis_drive_storage.spec.d.ts +8 -0
  164. package/build/tests/adonis_drive_storage.spec.d.ts.map +1 -0
  165. package/build/tests/adonis_drive_storage.spec.js +69 -0
  166. package/build/tests/adonis_drive_storage.spec.js.map +1 -0
  167. package/build/{src/types/attachment.js → tests/adonis_queue.spec.d.ts} +1 -0
  168. package/build/tests/adonis_queue.spec.d.ts.map +1 -0
  169. package/build/tests/adonis_queue.spec.js +52 -0
  170. package/build/tests/adonis_queue.spec.js.map +1 -0
  171. package/build/tests/attachment_job_processor.spec.d.ts +8 -0
  172. package/build/tests/attachment_job_processor.spec.d.ts.map +1 -0
  173. package/build/tests/attachment_job_processor.spec.js +89 -0
  174. package/build/tests/attachment_job_processor.spec.js.map +1 -0
  175. package/build/tests/attachment_manager.spec.d.ts +8 -0
  176. package/build/tests/attachment_manager.spec.d.ts.map +1 -0
  177. package/build/tests/attachment_manager.spec.js +131 -0
  178. package/build/tests/attachment_manager.spec.js.map +1 -0
  179. package/build/tests/attachment_manager_service.spec.d.ts +8 -0
  180. package/build/tests/attachment_manager_service.spec.d.ts.map +1 -0
  181. package/build/tests/attachment_manager_service.spec.js +47 -0
  182. package/build/tests/attachment_manager_service.spec.js.map +1 -0
  183. package/build/tests/attachment_options.spec.d.ts +2 -0
  184. package/build/tests/attachment_options.spec.d.ts.map +1 -0
  185. package/build/tests/attachment_options.spec.js +31 -0
  186. package/build/tests/attachment_options.spec.js.map +1 -0
  187. package/build/tests/attachment_provider.spec.d.ts +8 -0
  188. package/build/tests/attachment_provider.spec.d.ts.map +1 -0
  189. package/build/tests/attachment_provider.spec.js +71 -0
  190. package/build/tests/attachment_provider.spec.js.map +1 -0
  191. package/build/tests/attachment_service.spec.d.ts +8 -0
  192. package/build/tests/attachment_service.spec.d.ts.map +1 -0
  193. package/build/tests/attachment_service.spec.js +146 -0
  194. package/build/tests/attachment_service.spec.js.map +1 -0
  195. package/build/tests/attachments_controller.spec.d.ts +8 -0
  196. package/build/tests/attachments_controller.spec.d.ts.map +1 -0
  197. package/build/tests/attachments_controller.spec.js +34 -0
  198. package/build/tests/attachments_controller.spec.js.map +1 -0
  199. package/build/tests/attachments_table_stub.spec.d.ts +2 -0
  200. package/build/tests/attachments_table_stub.spec.d.ts.map +1 -0
  201. package/build/tests/attachments_table_stub.spec.js +66 -0
  202. package/build/tests/attachments_table_stub.spec.js.map +1 -0
  203. package/build/tests/configure.spec.d.ts +2 -0
  204. package/build/tests/configure.spec.d.ts.map +1 -0
  205. package/build/tests/configure.spec.js +38 -0
  206. package/build/tests/configure.spec.js.map +1 -0
  207. package/build/tests/container_bindings.types.d.ts +8 -0
  208. package/build/tests/container_bindings.types.d.ts.map +1 -0
  209. package/build/tests/container_bindings.types.js +9 -0
  210. package/build/tests/container_bindings.types.js.map +1 -0
  211. package/build/tests/create_legacy_attachment_migration_script.spec.d.ts +8 -0
  212. package/build/tests/create_legacy_attachment_migration_script.spec.d.ts.map +1 -0
  213. package/build/tests/create_legacy_attachment_migration_script.spec.js +31 -0
  214. package/build/tests/create_legacy_attachment_migration_script.spec.js.map +1 -0
  215. package/build/tests/define_config.spec.d.ts +8 -0
  216. package/build/tests/define_config.spec.d.ts.map +1 -0
  217. package/build/tests/define_config.spec.js +203 -0
  218. package/build/tests/define_config.spec.js.map +1 -0
  219. package/build/tests/helpers/lucid_test_database.d.ts +9 -0
  220. package/build/tests/helpers/lucid_test_database.d.ts.map +1 -0
  221. package/build/tests/helpers/lucid_test_database.js +52 -0
  222. package/build/tests/helpers/lucid_test_database.js.map +1 -0
  223. package/build/tests/local_file_storage.spec.d.ts +8 -0
  224. package/build/tests/local_file_storage.spec.d.ts.map +1 -0
  225. package/build/tests/local_file_storage.spec.js +44 -0
  226. package/build/tests/local_file_storage.spec.js.map +1 -0
  227. package/build/tests/lucid_attachment_collection_store.spec.d.ts +2 -0
  228. package/build/tests/lucid_attachment_collection_store.spec.d.ts.map +1 -0
  229. package/build/tests/lucid_attachment_collection_store.spec.js +52 -0
  230. package/build/tests/lucid_attachment_collection_store.spec.js.map +1 -0
  231. package/build/tests/lucid_attachment_column.spec.d.ts +8 -0
  232. package/build/tests/lucid_attachment_column.spec.d.ts.map +1 -0
  233. package/build/tests/lucid_attachment_column.spec.js +193 -0
  234. package/build/tests/lucid_attachment_column.spec.js.map +1 -0
  235. package/build/tests/lucid_attachment_lifecycle_service.spec.d.ts +8 -0
  236. package/build/tests/lucid_attachment_lifecycle_service.spec.d.ts.map +1 -0
  237. package/build/tests/lucid_attachment_lifecycle_service.spec.js +378 -0
  238. package/build/tests/lucid_attachment_lifecycle_service.spec.js.map +1 -0
  239. package/build/tests/lucid_attachment_relation.spec.d.ts +8 -0
  240. package/build/tests/lucid_attachment_relation.spec.d.ts.map +1 -0
  241. package/build/tests/lucid_attachment_relation.spec.js +216 -0
  242. package/build/tests/lucid_attachment_relation.spec.js.map +1 -0
  243. package/build/tests/lucid_attachment_repository.spec.d.ts +8 -0
  244. package/build/tests/lucid_attachment_repository.spec.d.ts.map +1 -0
  245. package/build/tests/lucid_attachment_repository.spec.js +50 -0
  246. package/build/tests/lucid_attachment_repository.spec.js.map +1 -0
  247. package/build/tests/lucid_attachment_store.spec.d.ts +8 -0
  248. package/build/tests/lucid_attachment_store.spec.d.ts.map +1 -0
  249. package/build/tests/lucid_attachment_store.spec.js +73 -0
  250. package/build/tests/lucid_attachment_store.spec.js.map +1 -0
  251. package/build/tests/lucid_sqlite_integration.spec.d.ts +8 -0
  252. package/build/tests/lucid_sqlite_integration.spec.d.ts.map +1 -0
  253. package/build/tests/lucid_sqlite_integration.spec.js +103 -0
  254. package/build/tests/lucid_sqlite_integration.spec.js.map +1 -0
  255. package/build/tests/lucid_variant_generation_service.spec.d.ts +8 -0
  256. package/build/tests/lucid_variant_generation_service.spec.d.ts.map +1 -0
  257. package/build/tests/lucid_variant_generation_service.spec.js +56 -0
  258. package/build/tests/lucid_variant_generation_service.spec.js.map +1 -0
  259. package/build/tests/memory_queue.spec.d.ts +8 -0
  260. package/build/tests/memory_queue.spec.d.ts.map +1 -0
  261. package/build/tests/memory_queue.spec.js +52 -0
  262. package/build/tests/memory_queue.spec.js.map +1 -0
  263. package/build/tests/migrate_legacy_attachment.spec.d.ts +8 -0
  264. package/build/tests/migrate_legacy_attachment.spec.d.ts.map +1 -0
  265. package/build/tests/migrate_legacy_attachment.spec.js +133 -0
  266. package/build/tests/migrate_legacy_attachment.spec.js.map +1 -0
  267. package/build/tests/migrate_legacy_attachment_records.spec.d.ts +8 -0
  268. package/build/tests/migrate_legacy_attachment_records.spec.d.ts.map +1 -0
  269. package/build/tests/migrate_legacy_attachment_records.spec.js +66 -0
  270. package/build/tests/migrate_legacy_attachment_records.spec.js.map +1 -0
  271. package/build/tests/package_exports.spec.d.ts +8 -0
  272. package/build/tests/package_exports.spec.d.ts.map +1 -0
  273. package/build/tests/package_exports.spec.js +31 -0
  274. package/build/tests/package_exports.spec.js.map +1 -0
  275. package/build/tests/variant_generation_service.spec.d.ts +8 -0
  276. package/build/tests/variant_generation_service.spec.d.ts.map +1 -0
  277. package/build/tests/variant_generation_service.spec.js +79 -0
  278. package/build/tests/variant_generation_service.spec.js.map +1 -0
  279. package/package.json +82 -76
  280. package/build/commands/make/converter.d.ts.map +0 -1
  281. package/build/commands/make/converter.js +0 -28
  282. package/build/services/regenerate_service.d.ts +0 -9
  283. package/build/services/regenerate_service.d.ts.map +0 -1
  284. package/build/services/regenerate_service.js +0 -29
  285. package/build/src/adapters/blurhash.d.ts +0 -11
  286. package/build/src/adapters/blurhash.d.ts.map +0 -1
  287. package/build/src/adapters/blurhash.js +0 -12
  288. package/build/src/adapters/exif.d.ts +0 -15
  289. package/build/src/adapters/exif.d.ts.map +0 -1
  290. package/build/src/adapters/exif.js +0 -165
  291. package/build/src/adapters/ffmpeg.d.ts +0 -19
  292. package/build/src/adapters/ffmpeg.d.ts.map +0 -1
  293. package/build/src/adapters/ffmpeg.js +0 -115
  294. package/build/src/adapters/lock.d.ts +0 -9
  295. package/build/src/adapters/lock.d.ts.map +0 -1
  296. package/build/src/adapters/lock.js +0 -21
  297. package/build/src/adapters/meta.d.ts +0 -10
  298. package/build/src/adapters/meta.d.ts.map +0 -1
  299. package/build/src/adapters/meta.js +0 -49
  300. package/build/src/adapters/poppler.d.ts +0 -20
  301. package/build/src/adapters/poppler.d.ts.map +0 -1
  302. package/build/src/adapters/poppler.js +0 -117
  303. package/build/src/adapters/soffice.d.ts +0 -14
  304. package/build/src/adapters/soffice.d.ts.map +0 -1
  305. package/build/src/adapters/soffice.js +0 -64
  306. package/build/src/attachment_manager.d.ts +0 -50
  307. package/build/src/attachment_manager.d.ts.map +0 -1
  308. package/build/src/attachment_manager.js +0 -145
  309. package/build/src/attachments/attachment.d.ts +0 -42
  310. package/build/src/attachments/attachment.d.ts.map +0 -1
  311. package/build/src/attachments/attachment.js +0 -233
  312. package/build/src/attachments/attachment_base.d.ts +0 -59
  313. package/build/src/attachments/attachment_base.d.ts.map +0 -1
  314. package/build/src/attachments/attachment_base.js +0 -211
  315. package/build/src/attachments/variant_attachment.d.ts +0 -27
  316. package/build/src/attachments/variant_attachment.d.ts.map +0 -1
  317. package/build/src/attachments/variant_attachment.js +0 -40
  318. package/build/src/converters/autodetect_converter.d.ts +0 -13
  319. package/build/src/converters/autodetect_converter.d.ts.map +0 -1
  320. package/build/src/converters/autodetect_converter.js +0 -77
  321. package/build/src/converters/converter.d.ts +0 -14
  322. package/build/src/converters/converter.d.ts.map +0 -1
  323. package/build/src/converters/converter.js +0 -14
  324. package/build/src/converters/document_thumbnail_converter.d.ts +0 -14
  325. package/build/src/converters/document_thumbnail_converter.d.ts.map +0 -1
  326. package/build/src/converters/document_thumbnail_converter.js +0 -36
  327. package/build/src/converters/image_converter.d.ts +0 -13
  328. package/build/src/converters/image_converter.d.ts.map +0 -1
  329. package/build/src/converters/image_converter.js +0 -27
  330. package/build/src/converters/pdf_thumbnail_converter.d.ts +0 -14
  331. package/build/src/converters/pdf_thumbnail_converter.d.ts.map +0 -1
  332. package/build/src/converters/pdf_thumbnail_converter.js +0 -39
  333. package/build/src/converters/video_thumbnail_converter.d.ts +0 -14
  334. package/build/src/converters/video_thumbnail_converter.d.ts.map +0 -1
  335. package/build/src/converters/video_thumbnail_converter.js +0 -40
  336. package/build/src/decorators/attachment.d.ts +0 -15
  337. package/build/src/decorators/attachment.d.ts.map +0 -1
  338. package/build/src/decorators/attachment.js +0 -103
  339. package/build/src/errors.d.ts +0 -67
  340. package/build/src/errors.d.ts.map +0 -1
  341. package/build/src/errors.js +0 -68
  342. package/build/src/services/attachment/attachment_detachment_service.d.ts +0 -19
  343. package/build/src/services/attachment/attachment_detachment_service.d.ts.map +0 -1
  344. package/build/src/services/attachment/attachment_detachment_service.js +0 -66
  345. package/build/src/services/attachment/attachment_persister_service.d.ts +0 -22
  346. package/build/src/services/attachment/attachment_persister_service.d.ts.map +0 -1
  347. package/build/src/services/attachment/attachment_persister_service.js +0 -96
  348. package/build/src/services/attachment/attachment_recorder_service.d.ts +0 -68
  349. package/build/src/services/attachment/attachment_recorder_service.d.ts.map +0 -1
  350. package/build/src/services/attachment/attachment_recorder_service.js +0 -121
  351. package/build/src/services/attachment/attachment_transaction_service.d.ts +0 -26
  352. package/build/src/services/attachment/attachment_transaction_service.d.ts.map +0 -1
  353. package/build/src/services/attachment/attachment_transaction_service.js +0 -46
  354. package/build/src/services/attachment/attachment_utils.d.ts +0 -35
  355. package/build/src/services/attachment/attachment_utils.d.ts.map +0 -1
  356. package/build/src/services/attachment/attachment_utils.js +0 -71
  357. package/build/src/services/attachment/attachment_variant_service.d.ts +0 -17
  358. package/build/src/services/attachment/attachment_variant_service.d.ts.map +0 -1
  359. package/build/src/services/attachment/attachment_variant_service.js +0 -99
  360. package/build/src/services/attachment/index.d.ts +0 -15
  361. package/build/src/services/attachment/index.d.ts.map +0 -1
  362. package/build/src/services/attachment/index.js +0 -15
  363. package/build/src/services/attachment_service.d.ts +0 -8
  364. package/build/src/services/attachment_service.d.ts.map +0 -1
  365. package/build/src/services/attachment_service.js +0 -7
  366. package/build/src/services/variant/variant_generator_service.d.ts +0 -24
  367. package/build/src/services/variant/variant_generator_service.d.ts.map +0 -1
  368. package/build/src/services/variant/variant_generator_service.js +0 -101
  369. package/build/src/services/variant/variant_persister_service.d.ts +0 -24
  370. package/build/src/services/variant/variant_persister_service.d.ts.map +0 -1
  371. package/build/src/services/variant/variant_persister_service.js +0 -59
  372. package/build/src/services/variant/variant_purger_service.d.ts +0 -15
  373. package/build/src/services/variant/variant_purger_service.d.ts.map +0 -1
  374. package/build/src/services/variant/variant_purger_service.js +0 -47
  375. package/build/src/services/variant_service.d.ts +0 -13
  376. package/build/src/services/variant_service.d.ts.map +0 -1
  377. package/build/src/services/variant_service.js +0 -63
  378. package/build/src/types/attachment.d.ts +0 -100
  379. package/build/src/types/attachment.d.ts.map +0 -1
  380. package/build/src/types/config.d.ts +0 -58
  381. package/build/src/types/config.d.ts.map +0 -1
  382. package/build/src/types/converter.d.ts +0 -144
  383. package/build/src/types/converter.d.ts.map +0 -1
  384. package/build/src/types/drive.d.ts +0 -6
  385. package/build/src/types/drive.d.ts.map +0 -1
  386. package/build/src/types/drive.js +0 -1
  387. package/build/src/types/event.d.ts +0 -16
  388. package/build/src/types/event.d.ts.map +0 -1
  389. package/build/src/types/index.d.ts +0 -15
  390. package/build/src/types/index.d.ts.map +0 -1
  391. package/build/src/types/index.js +0 -14
  392. package/build/src/types/input.d.ts +0 -35
  393. package/build/src/types/input.d.ts.map +0 -1
  394. package/build/src/types/input.js +0 -7
  395. package/build/src/types/lock.d.ts +0 -14
  396. package/build/src/types/lock.d.ts.map +0 -1
  397. package/build/src/types/lock.js +0 -7
  398. package/build/src/types/metadata.d.ts +0 -24
  399. package/build/src/types/metadata.d.ts.map +0 -1
  400. package/build/src/types/metadata.js +0 -7
  401. package/build/src/types/mixin.d.ts +0 -17
  402. package/build/src/types/mixin.d.ts.map +0 -1
  403. package/build/src/types/mixin.js +0 -7
  404. package/build/src/types/regenerate.d.ts +0 -12
  405. package/build/src/types/regenerate.d.ts.map +0 -1
  406. package/build/src/types/regenerate.js +0 -7
  407. package/build/src/types/service.d.ts +0 -25
  408. package/build/src/types/service.d.ts.map +0 -1
  409. package/build/src/types/service.js +0 -7
  410. package/build/src/utils/default_values.d.ts +0 -20
  411. package/build/src/utils/default_values.d.ts.map +0 -1
  412. package/build/src/utils/default_values.js +0 -19
  413. package/build/src/utils/helpers.d.ts +0 -19
  414. package/build/src/utils/helpers.d.ts.map +0 -1
  415. package/build/src/utils/helpers.js +0 -131
  416. package/build/src/utils/hooks.d.ts +0 -12
  417. package/build/src/utils/hooks.d.ts.map +0 -1
  418. package/build/src/utils/hooks.js +0 -42
  419. package/build/src/utils/symbols.d.ts +0 -8
  420. package/build/src/utils/symbols.d.ts.map +0 -1
  421. package/build/src/utils/symbols.js +0 -7
  422. package/build/stubs/config.stub +0 -140
  423. package/build/stubs/make/converter/main.stub +0 -20
  424. package/build/tsconfig.tsbuildinfo +0 -1
@@ -1,233 +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 { AttachmentBase } from './attachment_base.js';
9
- import { Variant } from './variant_attachment.js';
10
- import { metaFromBuffer, metaFromFile } from '../adapters/meta.js';
11
- export class Attachment extends AttachmentBase {
12
- originalName;
13
- variants;
14
- constructor(drive, attributes, input) {
15
- super(drive, attributes, input);
16
- this.originalName = attributes.originalName;
17
- if (attributes.disk) {
18
- this.disk = attributes.disk;
19
- }
20
- if (attributes.variants) {
21
- this.variants = [];
22
- attributes.variants.forEach((v) => {
23
- const variant = new Variant(this.drive, v);
24
- variant.disk = this.disk;
25
- this.variants.push(variant);
26
- });
27
- }
28
- }
29
- /**
30
- * Methods
31
- */
32
- async createVariant(key, input, options) {
33
- let meta;
34
- let folder;
35
- if (Buffer.isBuffer(input)) {
36
- meta = await metaFromBuffer(input);
37
- }
38
- else {
39
- meta = await metaFromFile(input, this.name);
40
- }
41
- if (options?.basePath && !options?.ignoreFolder) {
42
- folder = path.join(options.basePath, this.folder, this.name);
43
- }
44
- else if (options?.basePath && options?.ignoreFolder) {
45
- folder = path.join(options.basePath, this.name);
46
- }
47
- else if (options?.ignoreFolder) {
48
- folder = this.name;
49
- }
50
- else {
51
- folder = path.join(this.folder, 'variants', this.name);
52
- }
53
- const attributes = {
54
- ...meta,
55
- key,
56
- folder,
57
- };
58
- const variant = new Variant(this.drive, attributes, input);
59
- variant.setOptions(this.options);
60
- if (this.variants === undefined) {
61
- this.variants = [];
62
- }
63
- this.variants.push(variant);
64
- return variant;
65
- }
66
- getVariant(variantName) {
67
- return this.variants?.find((v) => v.key === variantName) ?? null;
68
- }
69
- async getUrl(variantName) {
70
- if (variantName) {
71
- const variant = this.getVariant(variantName);
72
- if (variant) {
73
- variant.setOptions(this.options);
74
- const url = await variant.getUrl();
75
- if (url) {
76
- return url;
77
- }
78
- }
79
- }
80
- return super.getUrl();
81
- }
82
- async getSignedUrl(variantNameOrOptions, signedUrlOptions) {
83
- let variantName;
84
- let options = signedUrlOptions;
85
- if (typeof variantNameOrOptions === 'string') {
86
- variantName = variantNameOrOptions;
87
- }
88
- else if (variantNameOrOptions && !signedUrlOptions) {
89
- options = variantNameOrOptions;
90
- }
91
- if (variantName) {
92
- const variant = this.getVariant(variantName);
93
- if (variant) {
94
- variant.setOptions(this.options);
95
- const url = variant.getSignedUrl(options);
96
- if (url) {
97
- return url;
98
- }
99
- }
100
- }
101
- return super.getSignedUrl(options);
102
- }
103
- setOptions(options) {
104
- this.options = {
105
- ...this.options,
106
- ...options,
107
- };
108
- if (!this.disk && options?.disk) {
109
- this.disk = options.disk;
110
- }
111
- if (this.variants) {
112
- this.variants.forEach((v) => {
113
- if (!v.disk) {
114
- v.disk = this.disk;
115
- }
116
- v.setOptions({
117
- ...this.options,
118
- variants: [],
119
- });
120
- });
121
- }
122
- return this;
123
- }
124
- /**
125
- * Actions
126
- */
127
- async preComputeUrl() {
128
- if (this.options?.preComputeUrl === false) {
129
- return;
130
- }
131
- await this.computeUrl();
132
- if (this.variants) {
133
- for (const key in this.variants) {
134
- if (Object.prototype.hasOwnProperty.call(this.variants, key)) {
135
- await this.variants[key].computeUrl();
136
- }
137
- }
138
- }
139
- }
140
- async makeName(record, attributeName) {
141
- return super.makeName(record, attributeName, this.originalName);
142
- }
143
- async moveFileForDelete() {
144
- if (this.options && this.options.rename !== true) {
145
- const originalPath = this.path;
146
- this.name = `${this.name}.trash`;
147
- const trashPath = this.path;
148
- this.originalPath = trashPath;
149
- try {
150
- await this.getDisk().move(originalPath, trashPath);
151
- }
152
- catch {
153
- // move() failed (e.g. S3 provider without ACL support): delete the original directly
154
- // so the file is cleaned up without relying on the .trash mechanism
155
- try {
156
- await this.getDisk().delete(originalPath);
157
- }
158
- catch (_) { }
159
- }
160
- }
161
- }
162
- async rollbackMoveFileForDelete() {
163
- if (this.options && this.options.rename !== true) {
164
- const trashPath = this.path;
165
- this.name = this.name.replace('.trash', '');
166
- const originalPath = this.path;
167
- this.originalPath = originalPath;
168
- await this.getDisk().move(trashPath, originalPath);
169
- }
170
- }
171
- async remove() {
172
- await super.remove();
173
- if (this.variants) {
174
- for (const key in this.variants) {
175
- if (Object.prototype.hasOwnProperty.call(this.variants, key)) {
176
- await this.variants[key].remove();
177
- }
178
- }
179
- // Try deleteAll to clean up empty directory (fs only), ignore errors on S3 providers
180
- const variantPath = this.variants[0].folder;
181
- try {
182
- await this.getDisk().deleteAll(variantPath);
183
- }
184
- catch (_) { }
185
- }
186
- }
187
- /**
188
- *
189
- */
190
- toObject() {
191
- const variants = this.variants?.map((v) => v.toObject());
192
- return {
193
- ...super.toObject(),
194
- disk: this.disk,
195
- originalName: this.originalName,
196
- variants,
197
- };
198
- }
199
- toJSON() {
200
- const data = {
201
- keyId: this.getKeyId(),
202
- name: this.name,
203
- originalName: this.originalName,
204
- size: this.size,
205
- extname: this.extname,
206
- mimeType: this.mimeType,
207
- meta: this.meta,
208
- };
209
- if (this.variants) {
210
- this.variants.map(async (v) => {
211
- data[v.key] = {
212
- name: v.name,
213
- extname: v.extname,
214
- mimeType: v.mimeType,
215
- meta: v.meta,
216
- size: v.size,
217
- blurhash: v.blurhash,
218
- };
219
- });
220
- }
221
- if (this.url) {
222
- data.url = this.url;
223
- }
224
- if (this.variants) {
225
- this.variants.map(async (v) => {
226
- if (v.url) {
227
- data[v.key].url = v.url;
228
- }
229
- });
230
- }
231
- return data;
232
- }
233
- }
@@ -1,59 +0,0 @@
1
- /**
2
- * @jrmc/adonis-attachment
3
- *
4
- * @license MIT
5
- * @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
6
- */
7
- import type { LucidRow } from '@adonisjs/lucid/types/model';
8
- import type { DriveService, SignedURLOptions } from '@adonisjs/drive/types';
9
- import type { LucidOptions, AttachmentBaseAttributes, AttachmentBase as AttachmentBaseInterface } from '../types/attachment.js';
10
- import type { Exif, Input } from '../types/input.js';
11
- export declare class AttachmentBase implements AttachmentBaseInterface {
12
- #private;
13
- drive: DriveService;
14
- disk?: string;
15
- input?: Input;
16
- size: number;
17
- extname: string;
18
- mimeType: string;
19
- meta?: Exif;
20
- originalPath?: string;
21
- url?: string;
22
- options: LucidOptions;
23
- constructor(drive: DriveService, attributes: AttachmentBaseAttributes, input?: Input);
24
- /**
25
- * Getters / Setters
26
- */
27
- get name(): string;
28
- set name(name: string);
29
- get folder(): string | undefined;
30
- get path(): string;
31
- /**
32
- * Methods
33
- */
34
- getDisk(): import("flydrive").Disk;
35
- getBytes(): Promise<Uint8Array<ArrayBufferLike>>;
36
- getBuffer(): Promise<Buffer<ArrayBuffer>>;
37
- getStream(): Promise<import("node:stream").Readable>;
38
- getUrl(): Promise<string>;
39
- getSignedUrl(signedUrlOptions?: SignedURLOptions): Promise<string>;
40
- getKeyId(): string | undefined;
41
- setKeyId(keyId: string): this;
42
- setOptions(options: LucidOptions): this;
43
- /**
44
- * Actions
45
- */
46
- computeUrl(signedUrlOptions?: SignedURLOptions): Promise<void>;
47
- preComputeUrl(): Promise<void>;
48
- makeName(record?: LucidRow, attributeName?: string, originalName?: string): Promise<this>;
49
- makeFolder(record?: LucidRow): Promise<this>;
50
- put(): Promise<void>;
51
- remove(): Promise<void>;
52
- /**
53
- *
54
- */
55
- toObject(): AttachmentBaseAttributes;
56
- toDbString(): string;
57
- toJSON(): Object;
58
- }
59
- //# sourceMappingURL=attachment_base.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"attachment_base.d.ts","sourceRoot":"","sources":["../../../src/attachments/attachment_base.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AAE3D,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAC3E,OAAO,KAAK,EACV,YAAY,EACZ,wBAAwB,EACxB,cAAc,IAAI,uBAAuB,EAC1C,MAAM,wBAAwB,CAAA;AAC/B,OAAO,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAOpD,qBAAa,cAAe,YAAW,uBAAuB;;IAC5D,KAAK,EAAE,YAAY,CAAA;IACnB,IAAI,CAAC,EAAE,MAAM,CAAA;IAEb,KAAK,CAAC,EAAE,KAAK,CAAA;IAMb,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,CAAC,EAAE,IAAI,CAAA;IACX,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,GAAG,CAAC,EAAE,MAAM,CAAA;IAEZ,OAAO,EAAE,YAAY,CAAA;gBAET,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,wBAAwB,EAAE,KAAK,CAAC,EAAE,KAAK;IAsBpF;;OAEG;IAEH,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,IAAI,IAAI,CAAC,IAAI,EAAE,MAAM,EAEpB;IAED,IAAI,MAAM,IAAI,MAAM,GAAG,SAAS,CAW/B;IAED,IAAI,IAAI,IAAI,MAAM,CAMjB;IAED;;OAEG;IAEH,OAAO;IAIP,QAAQ;IAIF,SAAS;IAKf,SAAS;IAIT,MAAM;IAIN,YAAY,CAAC,gBAAgB,CAAC,EAAE,gBAAgB;IAIhD,QAAQ;IAIR,QAAQ,CAAC,KAAK,EAAE,MAAM;IAKtB,UAAU,CAAC,OAAO,EAAE,YAAY;IAQhC;;OAEG;IAEG,UAAU,CAAC,gBAAgB,CAAC,EAAE,gBAAgB;IAW9C,aAAa;IAQb,QAAQ,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,aAAa,CAAC,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM;IA8BzE,UAAU,CAAC,MAAM,CAAC,EAAE,QAAQ;IA0B5B,GAAG;IAQH,MAAM;IASZ;;OAEG;IAEH,QAAQ,IAAI,wBAAwB;IAYpC,UAAU,IAAI,MAAM;IAKpB,MAAM,IAAI,MAAM;CAUjB"}
@@ -1,211 +0,0 @@
1
- /**
2
- * @jrmc/adonis-attachment
3
- *
4
- * @license MIT
5
- * @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
6
- */
7
- import string from '@adonisjs/core/helpers/string';
8
- import path from 'node:path';
9
- import { uuid } from '../utils/helpers.js';
10
- import { defaultOptionsDecorator } from '../utils/default_values.js';
11
- import { extractPathParameters } from '../utils/helpers.js';
12
- export class AttachmentBase {
13
- drive;
14
- disk;
15
- input;
16
- #keyId;
17
- #name;
18
- #folder;
19
- size;
20
- extname;
21
- mimeType;
22
- meta;
23
- originalPath;
24
- url;
25
- options;
26
- constructor(drive, attributes, input) {
27
- this.input = input;
28
- this.size = attributes.size;
29
- this.meta = attributes.meta;
30
- this.extname = attributes.extname;
31
- this.mimeType = attributes.mimeType;
32
- this.originalPath = attributes.path;
33
- this.#folder = attributes.folder;
34
- this.setOptions({ folder: attributes.folder });
35
- if (attributes.name) {
36
- this.#name = attributes.name;
37
- }
38
- else {
39
- this.#name = `${uuid()}.${this.extname}`;
40
- }
41
- this.options = defaultOptionsDecorator;
42
- this.drive = drive;
43
- }
44
- /**
45
- * Getters / Setters
46
- */
47
- get name() {
48
- return this.#name;
49
- }
50
- set name(name) {
51
- this.#name = name;
52
- }
53
- get folder() {
54
- if (this.#folder) {
55
- return this.#folder;
56
- }
57
- if (typeof this.options.folder === 'string') {
58
- const parameters = extractPathParameters(this.options.folder);
59
- if (!parameters.length) {
60
- return this.options.folder;
61
- }
62
- }
63
- }
64
- get path() {
65
- if (!this.folder && this.originalPath) {
66
- return this.originalPath;
67
- }
68
- return path.join(this.folder, this.name);
69
- }
70
- /**
71
- * Methods
72
- */
73
- getDisk() {
74
- return this.drive.use(this.disk ?? this.options?.disk);
75
- }
76
- getBytes() {
77
- return this.getDisk().getBytes(this.path);
78
- }
79
- async getBuffer() {
80
- const arrayBuffer = await this.getBytes();
81
- return Buffer.from(arrayBuffer);
82
- }
83
- getStream() {
84
- return this.getDisk().getStream(this.path);
85
- }
86
- getUrl() {
87
- return this.getDisk().getUrl(this.path);
88
- }
89
- getSignedUrl(signedUrlOptions) {
90
- return this.getDisk().getSignedUrl(this.path, signedUrlOptions);
91
- }
92
- getKeyId() {
93
- return this.#keyId;
94
- }
95
- setKeyId(keyId) {
96
- this.#keyId = keyId;
97
- return this;
98
- }
99
- setOptions(options) {
100
- this.options = {
101
- ...this.options,
102
- ...options,
103
- };
104
- return this;
105
- }
106
- /**
107
- * Actions
108
- */
109
- async computeUrl(signedUrlOptions) {
110
- const disk = this.getDisk();
111
- const fileVisibility = await disk.getVisibility(this.path);
112
- if (fileVisibility === 'private') {
113
- this.url = await this.getSignedUrl(signedUrlOptions);
114
- }
115
- else {
116
- this.url = await this.getUrl();
117
- }
118
- }
119
- async preComputeUrl() {
120
- if (this.options?.preComputeUrl === false) {
121
- return;
122
- }
123
- await this.computeUrl();
124
- }
125
- async makeName(record, attributeName, originalName) {
126
- if (typeof this.options.rename === 'function' && record) {
127
- this.#name = (await this.options.rename(record, attributeName, originalName));
128
- }
129
- else if (originalName && this.options.rename === false) {
130
- this.#name = originalName;
131
- }
132
- if (this.#name && record) {
133
- const parameters = extractPathParameters(this.#name);
134
- if (parameters) {
135
- parameters.forEach((parameter) => {
136
- const attribute = record.$attributes[parameter];
137
- if (typeof attribute === 'string') {
138
- const name = string.slug(string.noCase(string.escapeHTML(attribute.toLowerCase())));
139
- this.#name = this.#name?.replace(`:${parameter}`, name);
140
- }
141
- });
142
- }
143
- }
144
- return this;
145
- }
146
- async makeFolder(record) {
147
- if (typeof this.options.folder === 'function' && record) {
148
- this.#folder = (await this.options.folder(record));
149
- }
150
- else if (this.options.folder) {
151
- this.#folder = this.options.folder;
152
- }
153
- if (this.#folder && record) {
154
- const parameters = extractPathParameters(this.#folder);
155
- if (parameters) {
156
- parameters.forEach((parameter) => {
157
- const attribute = record.$attributes[parameter];
158
- if (typeof attribute === 'string') {
159
- const name = string.slug(string.noCase(string.escapeHTML(attribute.toLowerCase())));
160
- this.#folder = this.#folder?.replace(`:${parameter}`, name);
161
- }
162
- });
163
- }
164
- }
165
- return this;
166
- }
167
- async put() {
168
- if (Buffer.isBuffer(this.input)) {
169
- await this.getDisk().put(this.path, this.input);
170
- }
171
- else if (this.input) {
172
- await this.getDisk().copyFromFs(this.input, this.path);
173
- }
174
- }
175
- async remove() {
176
- const pathsToDelete = new Set([this.path, this.originalPath].filter(Boolean));
177
- for (const p of pathsToDelete) {
178
- try {
179
- await this.getDisk().delete(p);
180
- }
181
- catch (_) { }
182
- }
183
- }
184
- /**
185
- *
186
- */
187
- toObject() {
188
- return {
189
- keyId: this.getKeyId(),
190
- name: this.name,
191
- extname: this.extname,
192
- size: this.size,
193
- meta: this.meta,
194
- mimeType: this.mimeType,
195
- path: this.path,
196
- };
197
- }
198
- toDbString() {
199
- const { keyId: _, ...obj } = this.toObject();
200
- return JSON.stringify(obj);
201
- }
202
- toJSON() {
203
- if (this.url) {
204
- return {
205
- ...this.toObject(),
206
- url: this.url,
207
- };
208
- }
209
- return this.toObject();
210
- }
211
- }
@@ -1,27 +0,0 @@
1
- /**
2
- * @jrmc/adonis-attachment
3
- *
4
- * @license MIT
5
- * @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
6
- */
7
- import type { DriveService } from '@adonisjs/drive/types';
8
- import type { VariantAttributes, Variant as VariantInterface } from '../types/attachment.js';
9
- import type { Input } from '../types/input.js';
10
- import { AttachmentBase } from './attachment_base.js';
11
- import { BlurhashOptions } from '../types/converter.js';
12
- export declare class Variant extends AttachmentBase implements VariantInterface {
13
- #private;
14
- key: string;
15
- blurhash?: string;
16
- constructor(drive: DriveService, attributes: VariantAttributes, input?: Input);
17
- generateBlurhash(options?: BlurhashOptions): Promise<void>;
18
- /**
19
- * Getters
20
- */
21
- get folder(): string;
22
- /**
23
- *
24
- */
25
- toObject(): VariantAttributes;
26
- }
27
- //# sourceMappingURL=variant_attachment.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"variant_attachment.d.ts","sourceRoot":"","sources":["../../../src/attachments/variant_attachment.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAC5F,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAE9C,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAGvD,qBAAa,OAAQ,SAAQ,cAAe,YAAW,gBAAgB;;IACrE,GAAG,EAAE,MAAM,CAAA;IAEX,QAAQ,CAAC,EAAE,MAAM,CAAA;gBAEL,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,iBAAiB,EAAE,KAAK,CAAC,EAAE,KAAK;IAQvE,gBAAgB,CAAC,OAAO,CAAC,EAAE,eAAe;IAIhD;;OAEG;IAEH,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED;;OAEG;IAEH,QAAQ,IAAI,iBAAiB;CAS9B"}
@@ -1,40 +0,0 @@
1
- /**
2
- * @jrmc/adonis-attachment
3
- *
4
- * @license MIT
5
- * @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
6
- */
7
- import { AttachmentBase } from './attachment_base.js';
8
- import { imageToBlurhash } from '../utils/helpers.js';
9
- export class Variant extends AttachmentBase {
10
- key;
11
- #folder;
12
- blurhash;
13
- constructor(drive, attributes, input) {
14
- super(drive, attributes, input);
15
- this.key = attributes.key;
16
- this.#folder = attributes.folder;
17
- this.blurhash = attributes.blurhash;
18
- }
19
- async generateBlurhash(options) {
20
- this.blurhash = await imageToBlurhash(this.input, options);
21
- }
22
- /**
23
- * Getters
24
- */
25
- get folder() {
26
- return this.#folder;
27
- }
28
- /**
29
- *
30
- */
31
- toObject() {
32
- return {
33
- key: this.key,
34
- folder: this.folder,
35
- name: this.name,
36
- blurhash: this.blurhash,
37
- ...super.toObject(),
38
- };
39
- }
40
- }
@@ -1,13 +0,0 @@
1
- /**
2
- * @jrmc/adonis-attachment
3
- *
4
- * @license MIT
5
- * @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
6
- */
7
- import type { ConverterAttributes } from '../types/converter.js';
8
- import type { Input } from '../types/input.js';
9
- import Converter from './converter.js';
10
- export default class AutodetectConverter extends Converter {
11
- handle({ input, options }: ConverterAttributes): Promise<Input | undefined>;
12
- }
13
- //# sourceMappingURL=autodetect_converter.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"autodetect_converter.d.ts","sourceRoot":"","sources":["../../../src/converters/autodetect_converter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAChE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAG9C,OAAO,SAAS,MAAM,gBAAgB,CAAA;AAMtC,MAAM,CAAC,OAAO,OAAO,mBAAoB,SAAQ,SAAS;IAClD,MAAM,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,mBAAmB,GAAG,OAAO,CAAC,KAAK,GAAG,SAAS,CAAC;CAoElF"}
@@ -1,77 +0,0 @@
1
- /**
2
- * @jrmc/adonis-attachment
3
- *
4
- * @license MIT
5
- * @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
6
- */
7
- import { fileTypeFromBuffer, fileTypeFromFile } from 'file-type';
8
- import Converter from './converter.js';
9
- import ImageConverter from './image_converter.js';
10
- import VideoThumnailConverter from './video_thumbnail_converter.js';
11
- import DocumentThumbnailConverter from './document_thumbnail_converter.js';
12
- import PdfThumbnailConverter from './pdf_thumbnail_converter.js';
13
- export default class AutodetectConverter extends Converter {
14
- async handle({ input, options }) {
15
- let converter;
16
- let fileType;
17
- if (Buffer.isBuffer(input)) {
18
- fileType = await fileTypeFromBuffer(input);
19
- }
20
- else {
21
- fileType = await fileTypeFromFile(input);
22
- }
23
- if (!fileType) {
24
- fileType = {
25
- mime: 'text/plain',
26
- };
27
- }
28
- if (fileType?.mime.includes('image')) {
29
- converter = new ImageConverter(options, this.binPaths);
30
- }
31
- else if (fileType?.mime.includes('video')) {
32
- converter = new VideoThumnailConverter(options, this.binPaths);
33
- }
34
- else if (fileType?.mime.includes('pdf')) {
35
- converter = new PdfThumbnailConverter(options, this.binPaths);
36
- }
37
- else if (
38
- // Documents texte
39
- fileType?.mime.includes('application/vnd.openxmlformats-officedocument.wordprocessingml.document') || // .docx
40
- fileType?.mime.includes('application/vnd.oasis.opendocument.text') || // .odt
41
- fileType?.mime.includes('application/msword') || // .doc
42
- fileType?.mime.includes('application/rtf') || // .rtf
43
- fileType?.mime.includes('text/plain') || // .txt
44
- fileType?.mime.includes('application/xml') || // .xml, .svg
45
- // Feuilles de calcul
46
- fileType?.mime.includes('application/vnd.oasis.opendocument.spreadsheet') || // .ods
47
- fileType?.mime.includes('application/vnd.ms-excel') || // .xls
48
- fileType?.mime.includes('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet') || // .xlsx
49
- fileType?.mime.includes('text/csv') || // .csv
50
- // Présentations
51
- fileType?.mime.includes('application/vnd.oasis.opendocument.presentation') || // .odp
52
- fileType?.mime.includes('application/vnd.ms-powerpoint') || // .ppt
53
- fileType?.mime.includes('application/vnd.openxmlformats-officedocument.presentationml.presentation') || // .pptx
54
- // Dessins
55
- fileType?.mime.includes('application/vnd.oasis.opendocument.graphics') || // .odg
56
- fileType?.mime.includes('application/vnd.visio') || // .vsd
57
- // Formules mathématiques
58
- fileType?.mime.includes('application/vnd.oasis.opendocument.formula') || // .odf
59
- fileType?.mime.includes('application/mathml+xml') || // .mml
60
- // Bases de données
61
- fileType?.mime.includes('application/vnd.oasis.opendocument.database') || // .odb
62
- fileType?.mime.includes('application/x-msaccess') || // .mdb, .accdb
63
- // Autres formats Office
64
- fileType?.mime.includes('application/vnd.ms-office') || // Formats MS Office génériques
65
- fileType?.mime.includes('application/vnd.oasis.opendocument') // Formats OpenDocument génériques
66
- ) {
67
- converter = new DocumentThumbnailConverter(options, this.binPaths);
68
- }
69
- else {
70
- return;
71
- }
72
- return converter.handle({
73
- input,
74
- options,
75
- });
76
- }
77
- }
@@ -1,14 +0,0 @@
1
- /**
2
- * @jrmc/adonis-attachment
3
- *
4
- * @license MIT
5
- * @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
6
- */
7
- import type { BinPaths } from '../types/config.js';
8
- import type { Converter as ConverterInterface, ConverterOptions } from '../types/converter.js';
9
- export default class Converter implements ConverterInterface {
10
- options?: ConverterOptions;
11
- binPaths?: BinPaths;
12
- constructor(options?: ConverterOptions, binPaths?: BinPaths);
13
- }
14
- //# sourceMappingURL=converter.d.ts.map