@jrmc/adonis-attachment 5.2.1 → 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 -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 +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 +79 -75
  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
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @jrmc/adonis-attachment
3
+ *
4
+ * @license MIT
5
+ * @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
6
+ */
7
+ export type CreateLegacyAttachmentMigrationScriptOptions = {
8
+ directory: string;
9
+ defaultDisk?: string;
10
+ timestamp?: number;
11
+ };
12
+ export declare function createLegacyAttachmentMigrationScript(options: CreateLegacyAttachmentMigrationScriptOptions): Promise<string>;
13
+ //# sourceMappingURL=create_legacy_attachment_migration_script.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create_legacy_attachment_migration_script.d.ts","sourceRoot":"","sources":["../../../../src/integrations/lucid/create_legacy_attachment_migration_script.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH,MAAM,MAAM,4CAA4C,GAAG;IACzD,SAAS,EAAE,MAAM,CAAA;IACjB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,wBAAsB,qCAAqC,CACzD,OAAO,EAAE,4CAA4C,GACpD,OAAO,CAAC,MAAM,CAAC,CAWjB"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * @jrmc/adonis-attachment
3
+ *
4
+ * @license MIT
5
+ * @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
6
+ */
7
+ import { mkdir, writeFile } from 'node:fs/promises';
8
+ import { dirname, join } from 'node:path';
9
+ import { renderLegacyAttachmentMigrationScript } from './render_legacy_attachment_migration_script.js';
10
+ export async function createLegacyAttachmentMigrationScript(options) {
11
+ const timestamp = options.timestamp ?? Date.now();
12
+ const filePath = join(options.directory, `${timestamp}_migrate_v5_attachments.ts`);
13
+ const contents = renderLegacyAttachmentMigrationScript({
14
+ ...(options.defaultDisk ? { defaultDisk: options.defaultDisk } : {}),
15
+ });
16
+ await mkdir(dirname(filePath), { recursive: true });
17
+ await writeFile(filePath, contents, 'utf8');
18
+ return filePath;
19
+ }
20
+ //# sourceMappingURL=create_legacy_attachment_migration_script.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create_legacy_attachment_migration_script.js","sourceRoot":"","sources":["../../../../src/integrations/lucid/create_legacy_attachment_migration_script.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACnD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEzC,OAAO,EAAE,qCAAqC,EAAE,MAAM,gDAAgD,CAAA;AAQtG,MAAM,CAAC,KAAK,UAAU,qCAAqC,CACzD,OAAqD;IAErD,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,IAAI,CAAC,GAAG,EAAE,CAAA;IACjD,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,GAAG,SAAS,4BAA4B,CAAC,CAAA;IAClF,MAAM,QAAQ,GAAG,qCAAqC,CAAC;QACrD,GAAG,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACrE,CAAC,CAAA;IAEF,MAAM,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;IACnD,MAAM,SAAS,CAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAA;IAE3C,OAAO,QAAQ,CAAA;AACjB,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * @jrmc/adonis-attachment
3
+ *
4
+ * @license MIT
5
+ * @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
6
+ */
7
+ export { AttachmentModel } from './attachment_model.js';
8
+ export { attachment } from './attachment_column.js';
9
+ export { LucidAttachmentRepository } from './lucid_attachment_repository.js';
10
+ export { LucidAttachmentStore, type LucidAttachmentWithVariants, } from './lucid_attachment_store.js';
11
+ export { LucidAttachmentLifecycleService, type AttachmentFileService, type LucidAttachmentPersistence, } from './lucid_attachment_lifecycle_service.js';
12
+ export { LucidVariantGenerationService, PersistedAttachmentNotFoundError, type LucidVariantGenerationServiceOptions, } from './lucid_variant_generation_service.js';
13
+ export { createAttachmentOwnerKey, type AttachmentOwner } from './attachment_owner.js';
14
+ export { createAttachmentsTableStubState, type AttachmentsTableStubOptions, type AttachmentsTableStubState, } from './attachments_table_stub.js';
15
+ export { migrateLegacyAttachment, type LegacyAttachment, type LegacyVariant, type MigrateLegacyAttachmentOptions, type MigratedAttachmentRow, } from './migrate_legacy_attachment.js';
16
+ export { migrateLegacyAttachmentRecords, type LegacyAttachmentMigrationRecord, type LegacyAttachmentMigrationResult, type LegacyAttachmentMigrationWriter, type MigrateLegacyAttachmentRecordsOptions, } from './migrate_legacy_attachment_records.js';
17
+ export { createLegacyAttachmentMigrationScript, type CreateLegacyAttachmentMigrationScriptOptions, } from './create_legacy_attachment_migration_script.js';
18
+ export { renderLegacyAttachmentMigrationScript, type RenderLegacyAttachmentMigrationScriptOptions, } from './render_legacy_attachment_migration_script.js';
19
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/integrations/lucid/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AACnD,OAAO,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAA;AAC5E,OAAO,EACL,oBAAoB,EACpB,KAAK,2BAA2B,GACjC,MAAM,6BAA6B,CAAA;AACpC,OAAO,EACL,+BAA+B,EAC/B,KAAK,qBAAqB,EAC1B,KAAK,0BAA0B,GAChC,MAAM,yCAAyC,CAAA;AAChD,OAAO,EACL,6BAA6B,EAC7B,gCAAgC,EAChC,KAAK,oCAAoC,GAC1C,MAAM,uCAAuC,CAAA;AAC9C,OAAO,EAAE,wBAAwB,EAAE,KAAK,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACtF,OAAO,EACL,+BAA+B,EAC/B,KAAK,2BAA2B,EAChC,KAAK,yBAAyB,GAC/B,MAAM,6BAA6B,CAAA;AACpC,OAAO,EACL,uBAAuB,EACvB,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,8BAA8B,EACnC,KAAK,qBAAqB,GAC3B,MAAM,gCAAgC,CAAA;AACvC,OAAO,EACL,8BAA8B,EAC9B,KAAK,+BAA+B,EACpC,KAAK,+BAA+B,EACpC,KAAK,+BAA+B,EACpC,KAAK,qCAAqC,GAC3C,MAAM,wCAAwC,CAAA;AAC/C,OAAO,EACL,qCAAqC,EACrC,KAAK,4CAA4C,GAClD,MAAM,gDAAgD,CAAA;AACvD,OAAO,EACL,qCAAqC,EACrC,KAAK,4CAA4C,GAClD,MAAM,gDAAgD,CAAA"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * @jrmc/adonis-attachment
3
+ *
4
+ * @license MIT
5
+ * @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
6
+ */
7
+ export { AttachmentModel } from './attachment_model.js';
8
+ export { attachment } from './attachment_column.js';
9
+ export { LucidAttachmentRepository } from './lucid_attachment_repository.js';
10
+ export { LucidAttachmentStore, } from './lucid_attachment_store.js';
11
+ export { LucidAttachmentLifecycleService, } from './lucid_attachment_lifecycle_service.js';
12
+ export { LucidVariantGenerationService, PersistedAttachmentNotFoundError, } from './lucid_variant_generation_service.js';
13
+ export { createAttachmentOwnerKey } from './attachment_owner.js';
14
+ export { createAttachmentsTableStubState, } from './attachments_table_stub.js';
15
+ export { migrateLegacyAttachment, } from './migrate_legacy_attachment.js';
16
+ export { migrateLegacyAttachmentRecords, } from './migrate_legacy_attachment_records.js';
17
+ export { createLegacyAttachmentMigrationScript, } from './create_legacy_attachment_migration_script.js';
18
+ export { renderLegacyAttachmentMigrationScript, } from './render_legacy_attachment_migration_script.js';
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/integrations/lucid/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AACnD,OAAO,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAA;AAC5E,OAAO,EACL,oBAAoB,GAErB,MAAM,6BAA6B,CAAA;AACpC,OAAO,EACL,+BAA+B,GAGhC,MAAM,yCAAyC,CAAA;AAChD,OAAO,EACL,6BAA6B,EAC7B,gCAAgC,GAEjC,MAAM,uCAAuC,CAAA;AAC9C,OAAO,EAAE,wBAAwB,EAAwB,MAAM,uBAAuB,CAAA;AACtF,OAAO,EACL,+BAA+B,GAGhC,MAAM,6BAA6B,CAAA;AACpC,OAAO,EACL,uBAAuB,GAKxB,MAAM,gCAAgC,CAAA;AACvC,OAAO,EACL,8BAA8B,GAK/B,MAAM,wCAAwC,CAAA;AAC/C,OAAO,EACL,qCAAqC,GAEtC,MAAM,gDAAgD,CAAA;AACvD,OAAO,EACL,qCAAqC,GAEtC,MAAM,gDAAgD,CAAA"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * @jrmc/adonis-attachment
3
+ *
4
+ * @license MIT
5
+ * @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
6
+ */
7
+ import type { CreateAttachmentInput } from '../../core/attachment.js';
8
+ import type { AttachmentService } from '../../core/attachment_service.js';
9
+ import type { AttachmentOwner } from './attachment_owner.js';
10
+ import { AttachmentModel } from './attachment_model.js';
11
+ import { LucidAttachmentStore } from './lucid_attachment_store.js';
12
+ export type AttachmentFileService = Pick<AttachmentService, 'create' | 'remove'>;
13
+ export type LucidAttachmentPersistence = Pick<LucidAttachmentStore, 'createOriginal' | 'findOriginal' | 'listVariants' | 'releaseOwner' | 'restoreOwner' | 'remove'>;
14
+ export declare class LucidAttachmentLifecycleService {
15
+ #private;
16
+ constructor(attachments: AttachmentFileService, store: LucidAttachmentPersistence);
17
+ attach(owner: AttachmentOwner, input: CreateAttachmentInput): Promise<AttachmentModel>;
18
+ replace(owner: AttachmentOwner, input: CreateAttachmentInput): Promise<AttachmentModel>;
19
+ detach(owner: AttachmentOwner): Promise<void>;
20
+ }
21
+ //# sourceMappingURL=lucid_attachment_lifecycle_service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lucid_attachment_lifecycle_service.d.ts","sourceRoot":"","sources":["../../../../src/integrations/lucid/lucid_attachment_lifecycle_service.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAc,qBAAqB,EAAE,MAAM,0BAA0B,CAAA;AACjF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAA;AACzE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAA;AAElE,MAAM,MAAM,qBAAqB,GAAG,IAAI,CAAC,iBAAiB,EAAE,QAAQ,GAAG,QAAQ,CAAC,CAAA;AAChF,MAAM,MAAM,0BAA0B,GAAG,IAAI,CAC3C,oBAAoB,EACpB,gBAAgB,GAAG,cAAc,GAAG,cAAc,GAAG,cAAc,GAAG,cAAc,GAAG,QAAQ,CAChG,CAAA;AAED,qBAAa,+BAA+B;;gBAI9B,WAAW,EAAE,qBAAqB,EAAE,KAAK,EAAE,0BAA0B;IAK3E,MAAM,CAAC,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE,qBAAqB,GAAG,OAAO,CAAC,eAAe,CAAC;IAWtF,OAAO,CAAC,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE,qBAAqB,GAAG,OAAO,CAAC,eAAe,CAAC;IAiCvF,MAAM,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;CAmBpD"}
@@ -0,0 +1,68 @@
1
+ /**
2
+ * @jrmc/adonis-attachment
3
+ *
4
+ * @license MIT
5
+ * @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
6
+ */
7
+ export class LucidAttachmentLifecycleService {
8
+ #attachments;
9
+ #store;
10
+ constructor(attachments, store) {
11
+ this.#attachments = attachments;
12
+ this.#store = store;
13
+ }
14
+ async attach(owner, input) {
15
+ const attachment = await this.#attachments.create(input);
16
+ try {
17
+ return await this.#store.createOriginal(owner, attachment);
18
+ }
19
+ catch (error) {
20
+ await this.#removeStoredFile(attachment);
21
+ throw error;
22
+ }
23
+ }
24
+ async replace(owner, input) {
25
+ const previous = await this.#store.findOriginal(owner);
26
+ if (!previous) {
27
+ return this.attach(owner, input);
28
+ }
29
+ const attachment = await this.#attachments.create(input);
30
+ let current;
31
+ try {
32
+ await this.#store.releaseOwner(previous);
33
+ current = await this.#store.createOriginal(owner, attachment);
34
+ }
35
+ catch (error) {
36
+ await this.#store.restoreOwner(previous).catch(() => undefined);
37
+ await this.#removeStoredFile(attachment);
38
+ throw error;
39
+ }
40
+ try {
41
+ await this.#store.remove(previous);
42
+ }
43
+ catch (error) {
44
+ await this.#store.remove(current).catch(() => undefined);
45
+ await this.#store.restoreOwner(previous).catch(() => undefined);
46
+ await this.#removeStoredFile(current.toAttachment());
47
+ throw error;
48
+ }
49
+ await this.#removeStoredFile(previous.toAttachment());
50
+ return current;
51
+ }
52
+ async detach(owner) {
53
+ const original = await this.#store.findOriginal(owner);
54
+ if (!original) {
55
+ return;
56
+ }
57
+ const variants = await this.#store.listVariants(original.id);
58
+ await this.#store.remove(original);
59
+ await Promise.all([
60
+ this.#removeStoredFile(original.toAttachment()),
61
+ ...variants.map((variant) => this.#removeStoredFile(variant.toAttachment())),
62
+ ]);
63
+ }
64
+ async #removeStoredFile(attachment) {
65
+ await this.#attachments.remove(attachment);
66
+ }
67
+ }
68
+ //# sourceMappingURL=lucid_attachment_lifecycle_service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lucid_attachment_lifecycle_service.js","sourceRoot":"","sources":["../../../../src/integrations/lucid/lucid_attachment_lifecycle_service.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAcH,MAAM,OAAO,+BAA+B;IACjC,YAAY,CAAuB;IACnC,MAAM,CAA4B;IAE3C,YAAY,WAAkC,EAAE,KAAiC;QAC/E,IAAI,CAAC,YAAY,GAAG,WAAW,CAAA;QAC/B,IAAI,CAAC,MAAM,GAAG,KA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,CAAC,CAAA;IAC5C,CAAC;CACF"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * @jrmc/adonis-attachment
3
+ *
4
+ * @license MIT
5
+ * @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
6
+ */
7
+ import type { Attachment } from '../../core/attachment.js';
8
+ import type { AttachmentRepository } from '../../core/attachment_repository.js';
9
+ import { AttachmentModel } from './attachment_model.js';
10
+ /**
11
+ * Attachment repository used by workers when attachments are persisted by Lucid.
12
+ */
13
+ export declare class LucidAttachmentRepository implements AttachmentRepository {
14
+ #private;
15
+ constructor(model?: typeof AttachmentModel);
16
+ findById(id: string): Promise<Attachment | null>;
17
+ }
18
+ //# sourceMappingURL=lucid_attachment_repository.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lucid_attachment_repository.d.ts","sourceRoot":"","sources":["../../../../src/integrations/lucid/lucid_attachment_repository.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAC1D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAA;AAC/E,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAEvD;;GAEG;AACH,qBAAa,yBAA0B,YAAW,oBAAoB;;gBAGxD,KAAK,GAAE,OAAO,eAAiC;IAIrD,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;CAKvD"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * @jrmc/adonis-attachment
3
+ *
4
+ * @license MIT
5
+ * @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
6
+ */
7
+ import { AttachmentModel } from './attachment_model.js';
8
+ /**
9
+ * Attachment repository used by workers when attachments are persisted by Lucid.
10
+ */
11
+ export class LucidAttachmentRepository {
12
+ #model;
13
+ constructor(model = AttachmentModel) {
14
+ this.#model = model;
15
+ }
16
+ async findById(id) {
17
+ const row = await this.#model.find(id);
18
+ return row?.toAttachment() ?? null;
19
+ }
20
+ }
21
+ //# sourceMappingURL=lucid_attachment_repository.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lucid_attachment_repository.js","sourceRoot":"","sources":["../../../../src/integrations/lucid/lucid_attachment_repository.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAEvD;;GAEG;AACH,MAAM,OAAO,yBAAyB;IAC3B,MAAM,CAAwB;IAEvC,YAAY,QAAgC,eAAe;QACzD,IAAI,CAAC,MAAM,GAAG,KAAK,CAAA;IACrB,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,EAAU;QACvB,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;QAEtC,OAAO,GAAG,EAAE,YAAY,EAAE,IAAI,IAAI,CAAA;IACpC,CAAC;CACF"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * @jrmc/adonis-attachment
3
+ *
4
+ * @license MIT
5
+ * @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
6
+ */
7
+ import type { Attachment } from '../../core/attachment.js';
8
+ import { type AttachmentOwner } from './attachment_owner.js';
9
+ import { AttachmentModel } from './attachment_model.js';
10
+ export type LucidAttachmentWithVariants = {
11
+ original: AttachmentModel;
12
+ variants: AttachmentModel[];
13
+ };
14
+ export declare class LucidAttachmentStore {
15
+ #private;
16
+ constructor(model?: typeof AttachmentModel);
17
+ createOriginal(owner: AttachmentOwner, attachment: Attachment): Promise<AttachmentModel>;
18
+ createVariant(original: AttachmentModel, key: string, attachment: Attachment): Promise<AttachmentModel>;
19
+ releaseOwner(original: AttachmentModel): Promise<void>;
20
+ restoreOwner(original: AttachmentModel): Promise<void>;
21
+ findOriginal(owner: AttachmentOwner): Promise<AttachmentModel | null>;
22
+ findById(id: string): Promise<AttachmentModel | null>;
23
+ findByOwner(owner: AttachmentOwner): Promise<LucidAttachmentWithVariants | null>;
24
+ listVariants(originalId: string): Promise<AttachmentModel[]>;
25
+ remove(original: AttachmentModel): Promise<void>;
26
+ }
27
+ //# sourceMappingURL=lucid_attachment_store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lucid_attachment_store.d.ts","sourceRoot":"","sources":["../../../../src/integrations/lucid/lucid_attachment_store.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAE1D,OAAO,EAA4B,KAAK,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACtF,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAEvD,MAAM,MAAM,2BAA2B,GAAG;IACxC,QAAQ,EAAE,eAAe,CAAA;IACzB,QAAQ,EAAE,eAAe,EAAE,CAAA;CAC5B,CAAA;AAED,qBAAa,oBAAoB;;gBAGnB,KAAK,GAAE,OAAO,eAAiC;IAIrD,cAAc,CAAC,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,eAAe,CAAC;IAgBxF,aAAa,CACjB,QAAQ,EAAE,eAAe,EACzB,GAAG,EAAE,MAAM,EACX,UAAU,EAAE,UAAU,GACrB,OAAO,CAAC,eAAe,CAAC;IAgBrB,YAAY,CAAC,QAAQ,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAKtD,YAAY,CAAC,QAAQ,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAS5D,YAAY,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC;IAUrE,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC;IAI/C,WAAW,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,2BAA2B,GAAG,IAAI,CAAC;IAatF,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;IAItD,MAAM,CAAC,QAAQ,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;CAGvD"}
@@ -0,0 +1,84 @@
1
+ /**
2
+ * @jrmc/adonis-attachment
3
+ *
4
+ * @license MIT
5
+ * @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
6
+ */
7
+ import { markAttachmentPersisted } from '../../core/attachment_state.js';
8
+ import { createAttachmentOwnerKey } from './attachment_owner.js';
9
+ import { AttachmentModel } from './attachment_model.js';
10
+ export class LucidAttachmentStore {
11
+ #model;
12
+ constructor(model = AttachmentModel) {
13
+ this.#model = model;
14
+ }
15
+ async createOriginal(owner, attachment) {
16
+ const row = await this.#model.create({
17
+ ...attachment,
18
+ attachableType: owner.type,
19
+ attachableId: owner.id,
20
+ field: owner.field,
21
+ ownerKey: createAttachmentOwnerKey(owner),
22
+ parentId: null,
23
+ variantKey: null,
24
+ metadata: attachment.metadata ?? null,
25
+ });
26
+ markAttachmentPersisted(attachment);
27
+ return row;
28
+ }
29
+ async createVariant(original, key, attachment) {
30
+ const row = await this.#model.create({
31
+ ...attachment,
32
+ attachableType: original.attachableType,
33
+ attachableId: original.attachableId,
34
+ field: original.field,
35
+ ownerKey: null,
36
+ parentId: original.id,
37
+ variantKey: key,
38
+ metadata: attachment.metadata ?? null,
39
+ });
40
+ markAttachmentPersisted(attachment);
41
+ return row;
42
+ }
43
+ async releaseOwner(original) {
44
+ original.ownerKey = null;
45
+ await original.save();
46
+ }
47
+ async restoreOwner(original) {
48
+ original.ownerKey = createAttachmentOwnerKey({
49
+ type: original.attachableType,
50
+ id: original.attachableId,
51
+ field: original.field,
52
+ });
53
+ await original.save();
54
+ }
55
+ findOriginal(owner) {
56
+ return this.#model
57
+ .query()
58
+ .where('attachable_type', owner.type)
59
+ .where('attachable_id', owner.id)
60
+ .where('field', owner.field)
61
+ .whereNull('parent_id')
62
+ .first();
63
+ }
64
+ findById(id) {
65
+ return this.#model.find(id);
66
+ }
67
+ async findByOwner(owner) {
68
+ const original = await this.findOriginal(owner);
69
+ if (!original) {
70
+ return null;
71
+ }
72
+ return {
73
+ original,
74
+ variants: await this.listVariants(original.id),
75
+ };
76
+ }
77
+ listVariants(originalId) {
78
+ return this.#model.query().where('parent_id', originalId);
79
+ }
80
+ async remove(original) {
81
+ await original.delete();
82
+ }
83
+ }
84
+ //# sourceMappingURL=lucid_attachment_store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lucid_attachment_store.js","sourceRoot":"","sources":["../../../../src/integrations/lucid/lucid_attachment_store.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAA;AACxE,OAAO,EAAE,wBAAwB,EAAwB,MAAM,uBAAuB,CAAA;AACtF,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAOvD,MAAM,OAAO,oBAAoB;IACtB,MAAM,CAAwB;IAEvC,YAAY,QAAgC,eAAe;QACzD,IAAI,CAAC,MAAM,GAAG,KAAK,CAAA;IACrB,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,KAAsB,EAAE,UAAsB;QACjE,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;YACnC,GAAG,UAAU;YACb,cAAc,EAAE,KAAK,CAAC,IAAI;YAC1B,YAAY,EAAE,KAAK,CAAC,EAAE;YACtB,KAAK,EAAE,KAAK,CAAC,KAAK;YAClB,QAAQ,EAAE,wBAAwB,CAAC,KAAK,CAAC;YACzC,QAAQ,EAAE,IAAI;YACd,UAAU,EAAE,IAAI;YAChB,QAAQ,EAAE,UAAU,CAAC,QAAQ,IAAI,IAAI;SACtC,CAAC,CAAA;QAEF,uBAAuB,CAAC,UAAU,CAAC,CAAA;QACnC,OAAO,GAAG,CAAA;IACZ,CAAC;IAED,KAAK,CAAC,aAAa,CACjB,QAAyB,EACzB,GAAW,EACX,UAA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7B,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,KAAsB;QACtC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,CAAA;QAE/C,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,OAAO,IAAI,CAAA;QACb,CAAC;QAED,OAAO;YACL,QAAQ;YACR,QAAQ,EAAE,MAAM,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,EAAE,CAAC;SAC/C,CAAA;IACH,CAAC;IAED,YAAY,CAAC,UAAkB;QAC7B,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,WAAW,EAAE,UAAU,CAAC,CAAA;IAC3D,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,QAAyB;QACpC,MAAM,QAAQ,CAAC,MAAM,EAAE,CAAA;IACzB,CAAC;CACF"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * @jrmc/adonis-attachment
3
+ *
4
+ * @license MIT
5
+ * @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
6
+ */
7
+ import type { AttachmentService } from '../../core/attachment_service.js';
8
+ import type { VariantGenerationRequest, VariantGenerator } from '../../core/attachment_job_processor.js';
9
+ import type { VariantGenerationService } from '../../variants/variant_generation_service.js';
10
+ import { LucidAttachmentStore } from './lucid_attachment_store.js';
11
+ export type LucidVariantGenerationServiceOptions = {
12
+ generator: Pick<VariantGenerationService, 'generateAll'>;
13
+ attachments: Pick<AttachmentService, 'remove'>;
14
+ store: Pick<LucidAttachmentStore, 'findById' | 'createVariant'>;
15
+ };
16
+ export declare class LucidVariantGenerationService implements VariantGenerator {
17
+ #private;
18
+ constructor(options: LucidVariantGenerationServiceOptions);
19
+ generate(request: VariantGenerationRequest): Promise<void>;
20
+ }
21
+ export declare class PersistedAttachmentNotFoundError extends Error {
22
+ constructor(id: string);
23
+ }
24
+ //# sourceMappingURL=lucid_variant_generation_service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lucid_variant_generation_service.d.ts","sourceRoot":"","sources":["../../../../src/integrations/lucid/lucid_variant_generation_service.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAA;AACzE,OAAO,KAAK,EAAE,wBAAwB,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAA;AACxG,OAAO,KAAK,EAAoB,wBAAwB,EAAE,MAAM,8CAA8C,CAAA;AAE9G,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAA;AAElE,MAAM,MAAM,oCAAoC,GAAG;IACjD,SAAS,EAAE,IAAI,CAAC,wBAAwB,EAAE,aAAa,CAAC,CAAA;IACxD,WAAW,EAAE,IAAI,CAAC,iBAAiB,EAAE,QAAQ,CAAC,CAAA;IAC9C,KAAK,EAAE,IAAI,CAAC,oBAAoB,EAAE,UAAU,GAAG,eAAe,CAAC,CAAA;CAChE,CAAA;AAED,qBAAa,6BAA8B,YAAW,gBAAgB;;gBAKxD,OAAO,EAAE,oCAAoC;IAMnD,QAAQ,CAAC,OAAO,EAAE,wBAAwB,GAAG,OAAO,CAAC,IAAI,CAAC;CAqBjE;AAED,qBAAa,gCAAiC,SAAQ,KAAK;gBAC7C,EAAE,EAAE,MAAM;CAIvB"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * @jrmc/adonis-attachment
3
+ *
4
+ * @license MIT
5
+ * @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
6
+ */
7
+ export class LucidVariantGenerationService {
8
+ #generator;
9
+ #attachments;
10
+ #store;
11
+ constructor(options) {
12
+ this.#generator = options.generator;
13
+ this.#attachments = options.attachments;
14
+ this.#store = options.store;
15
+ }
16
+ async generate(request) {
17
+ const original = await this.#store.findById(request.attachment.id);
18
+ if (!original) {
19
+ throw new PersistedAttachmentNotFoundError(request.attachment.id);
20
+ }
21
+ const variants = await this.#generator.generateAll(request);
22
+ for (const variant of variants) {
23
+ await this.#persist(original, variant);
24
+ }
25
+ }
26
+ async #persist(original, variant) {
27
+ try {
28
+ await this.#store.createVariant(original, variant.key, variant.attachment);
29
+ }
30
+ catch (error) {
31
+ await this.#attachments.remove(variant.attachment);
32
+ throw error;
33
+ }
34
+ }
35
+ }
36
+ export class PersistedAttachmentNotFoundError extends Error {
37
+ constructor(id) {
38
+ super(`Persisted attachment "${id}" was not found`);
39
+ this.name = 'PersistedAttachmentNotFoundError';
40
+ }
41
+ }
42
+ //# sourceMappingURL=lucid_variant_generation_service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lucid_variant_generation_service.js","sourceRoot":"","sources":["../../../../src/integrations/lucid/lucid_variant_generation_service.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAcH,MAAM,OAAO,6BAA6B;IAC/B,UAAU,CAA+C;IACzD,YAAY,CAAmC;IAC/C,MAAM,CAA0D;IAEzE,YAAY,OAA6C;QACvD,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,SAAS,CAAA;QACnC,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,WAAW,CAAA;QACvC,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,KAAK,CAAA;IAC7B,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,OAAiC;QAC9C,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC,CAAA;QAElE,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,MAAM,IAAI,gCAAgC,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC,CAAA;QACnE,CAAC;QAED,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,OAAO,CAAC,CAAA;QAC3D,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;YAC/B,MAAM,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;QACxC,CAAC;IACH,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,QAAyB,EAAE,OAAyB;QACjE,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,QAAQ,EAAE,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,UAAU,CAAC,CAAA;QAC5E,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;YAClD,MAAM,KAAK,CAAA;QACb,CAAC;IACH,CAAC;CACF;AAED,MAAM,OAAO,gCAAiC,SAAQ,KAAK;IACzD,YAAY,EAAU;QACpB,KAAK,CAAC,yBAAyB,EAAE,iBAAiB,CAAC,CAAA;QACnD,IAAI,CAAC,IAAI,GAAG,kCAAkC,CAAA;IAChD,CAAC;CACF"}
@@ -0,0 +1,57 @@
1
+ /**
2
+ * @jrmc/adonis-attachment
3
+ *
4
+ * @license MIT
5
+ * @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
6
+ */
7
+ export type LegacyAttachment = {
8
+ name: string;
9
+ originalName?: string;
10
+ size: number;
11
+ extname: string;
12
+ mimeType: string;
13
+ disk?: string;
14
+ path?: string;
15
+ meta?: Record<string, unknown>;
16
+ variants?: LegacyVariant[];
17
+ };
18
+ export type LegacyVariant = {
19
+ key: string;
20
+ name: string;
21
+ size: number;
22
+ extname: string;
23
+ mimeType: string;
24
+ disk?: string;
25
+ path?: string;
26
+ meta?: Record<string, unknown>;
27
+ };
28
+ import { type AttachmentOwner } from './attachment_owner.js';
29
+ export type { AttachmentOwner } from './attachment_owner.js';
30
+ export type MigratedAttachmentRow = {
31
+ id: string;
32
+ attachableType: string;
33
+ attachableId: string;
34
+ field: string;
35
+ ownerKey: string | null;
36
+ parentId: string | null;
37
+ variantKey: string | null;
38
+ disk: string;
39
+ path: string;
40
+ name: string;
41
+ originalName: string;
42
+ mimeType: string;
43
+ extname: string;
44
+ size: number;
45
+ metadata: Record<string, unknown> | null;
46
+ };
47
+ export type MigrateLegacyAttachmentOptions = {
48
+ owner: AttachmentOwner;
49
+ defaultDisk: string;
50
+ createId: () => string;
51
+ };
52
+ /**
53
+ * Converts one v5 JSON attachment document into rows for the polymorphic table.
54
+ * Callers can run it from an Ace command, another ORM migration, or a one-off script.
55
+ */
56
+ export declare function migrateLegacyAttachment(value: LegacyAttachment | string, options: MigrateLegacyAttachmentOptions): MigratedAttachmentRow[];
57
+ //# sourceMappingURL=migrate_legacy_attachment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migrate_legacy_attachment.d.ts","sourceRoot":"","sources":["../../../../src/integrations/lucid/migrate_legacy_attachment.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EAAE,MAAM,CAAA;IACZ,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC9B,QAAQ,CAAC,EAAE,aAAa,EAAE,CAAA;CAC3B,CAAA;AAED,MAAM,MAAM,aAAa,GAAG;IAC1B,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC/B,CAAA;AAED,OAAO,EAA4B,KAAK,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAEtF,YAAY,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAE5D,MAAM,MAAM,qBAAqB,GAAG;IAClC,EAAE,EAAE,MAAM,CAAA;IACV,cAAc,EAAE,MAAM,CAAA;IACtB,YAAY,EAAE,MAAM,CAAA;IACpB,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,YAAY,EAAE,MAAM,CAAA;IACpB,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAA;CACzC,CAAA;AAED,MAAM,MAAM,8BAA8B,GAAG;IAC3C,KAAK,EAAE,eAAe,CAAA;IACtB,WAAW,EAAE,MAAM,CAAA;IACnB,QAAQ,EAAE,MAAM,MAAM,CAAA;CACvB,CAAA;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,gBAAgB,GAAG,MAAM,EAChC,OAAO,EAAE,8BAA8B,GACtC,qBAAqB,EAAE,CA8BzB"}
@@ -0,0 +1,67 @@
1
+ /**
2
+ * @jrmc/adonis-attachment
3
+ *
4
+ * @license MIT
5
+ * @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
6
+ */
7
+ import { createAttachmentOwnerKey } from './attachment_owner.js';
8
+ /**
9
+ * Converts one v5 JSON attachment document into rows for the polymorphic table.
10
+ * Callers can run it from an Ace command, another ORM migration, or a one-off script.
11
+ */
12
+ export function migrateLegacyAttachment(value, options) {
13
+ const attachment = typeof value === 'string' ? parseLegacyAttachment(value) : value;
14
+ const id = options.createId();
15
+ const originalName = attachment.originalName ?? attachment.name;
16
+ const original = toRow({
17
+ id,
18
+ attachment,
19
+ owner: options.owner,
20
+ ownerKey: createAttachmentOwnerKey(options.owner),
21
+ parentId: null,
22
+ variantKey: null,
23
+ originalName,
24
+ defaultDisk: options.defaultDisk,
25
+ });
26
+ return [
27
+ original,
28
+ ...(attachment.variants ?? []).map((variant) => toRow({
29
+ id: options.createId(),
30
+ attachment: variant,
31
+ owner: options.owner,
32
+ ownerKey: null,
33
+ parentId: id,
34
+ variantKey: variant.key,
35
+ originalName,
36
+ defaultDisk: options.defaultDisk,
37
+ })),
38
+ ];
39
+ }
40
+ function parseLegacyAttachment(value) {
41
+ try {
42
+ return JSON.parse(value);
43
+ }
44
+ catch {
45
+ throw new Error('Legacy attachment value must be valid JSON');
46
+ }
47
+ }
48
+ function toRow({ id, attachment, owner, ownerKey, parentId, variantKey, originalName, defaultDisk, }) {
49
+ return {
50
+ id,
51
+ attachableType: owner.type,
52
+ attachableId: owner.id,
53
+ field: owner.field,
54
+ ownerKey,
55
+ parentId,
56
+ variantKey,
57
+ disk: attachment.disk ?? defaultDisk,
58
+ path: attachment.path ?? attachment.name,
59
+ name: attachment.name,
60
+ originalName,
61
+ mimeType: attachment.mimeType,
62
+ extname: attachment.extname,
63
+ size: attachment.size,
64
+ metadata: attachment.meta ?? null,
65
+ };
66
+ }
67
+ //# sourceMappingURL=migrate_legacy_attachment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migrate_legacy_attachment.js","sourceRoot":"","sources":["../../../../src/integrations/lucid/migrate_legacy_attachment.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAyBH,OAAO,EAAE,wBAAwB,EAAwB,MAAM,uBAAuB,CAAA;AA4BtF;;;GAGG;AACH,MAAM,UAAU,uBAAuB,CACrC,KAAgC,EAChC,OAAuC;IAEvC,MAAM,UAAU,GAAG,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,qBAAqB,C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,CAAC,IAAI;QAC1B,YAAY,EAAE,KAAK,CAAC,EAAE;QACtB,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,QAAQ;QACR,QAAQ;QACR,UAAU;QACV,IAAI,EAAE,UAAU,CAAC,IAAI,IAAI,WAAW;QACpC,IAAI,EAAE,UAAU,CAAC,IAAI,IAAI,UAAU,CAAC,IAAI;QACxC,IAAI,EAAE,UAAU,CAAC,IAAI;QACrB,YAAY;QACZ,QAAQ,EAAE,UAAU,CAAC,QAAQ;QAC7B,OAAO,EAAE,UAAU,CAAC,OAAO;QAC3B,IAAI,EAAE,UAAU,CAAC,IAAI;QACrB,QAAQ,EAAE,UAAU,CAAC,IAAI,IAAI,IAAI;KAClC,CAAA;AACH,CAAC"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * @jrmc/adonis-attachment
3
+ *
4
+ * @license MIT
5
+ * @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
6
+ */
7
+ import type { AttachmentOwner } from './attachment_owner.js';
8
+ import { type LegacyAttachment, type MigratedAttachmentRow } from './migrate_legacy_attachment.js';
9
+ export type LegacyAttachmentMigrationRecord = {
10
+ owner: AttachmentOwner;
11
+ value: LegacyAttachment | string | null | undefined;
12
+ };
13
+ export type LegacyAttachmentMigrationWriter = {
14
+ insert(rows: readonly MigratedAttachmentRow[]): Promise<void>;
15
+ };
16
+ export type MigrateLegacyAttachmentRecordsOptions = {
17
+ records: Iterable<LegacyAttachmentMigrationRecord> | AsyncIterable<LegacyAttachmentMigrationRecord>;
18
+ defaultDisk: string;
19
+ createId: () => string;
20
+ writer: LegacyAttachmentMigrationWriter;
21
+ batchSize?: number;
22
+ };
23
+ export type LegacyAttachmentMigrationResult = {
24
+ attachments: number;
25
+ variants: number;
26
+ skipped: number;
27
+ };
28
+ /**
29
+ * Migrates a stream of legacy v5 JSON values into attachment-table rows.
30
+ * The caller owns source-model iteration and database transactions; this keeps
31
+ * the migration compatible with custom Lucid models and other persistence layouts.
32
+ */
33
+ export declare function migrateLegacyAttachmentRecords(options: MigrateLegacyAttachmentRecordsOptions): Promise<LegacyAttachmentMigrationResult>;
34
+ //# sourceMappingURL=migrate_legacy_attachment_records.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migrate_legacy_attachment_records.d.ts","sourceRoot":"","sources":["../../../../src/integrations/lucid/migrate_legacy_attachment_records.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAC5D,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,qBAAqB,EAC3B,MAAM,gCAAgC,CAAA;AAEvC,MAAM,MAAM,+BAA+B,GAAG;IAC5C,KAAK,EAAE,eAAe,CAAA;IACtB,KAAK,EAAE,gBAAgB,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;CACpD,CAAA;AAED,MAAM,MAAM,+BAA+B,GAAG;IAC5C,MAAM,CAAC,IAAI,EAAE,SAAS,qBAAqB,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CAC9D,CAAA;AAED,MAAM,MAAM,qCAAqC,GAAG;IAClD,OAAO,EAAE,QAAQ,CAAC,+BAA+B,CAAC,GAAG,aAAa,CAAC,+BAA+B,CAAC,CAAA;IACnG,WAAW,EAAE,MAAM,CAAA;IACnB,QAAQ,EAAE,MAAM,MAAM,CAAA;IACtB,MAAM,EAAE,+BAA+B,CAAA;IACvC,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,MAAM,MAAM,+BAA+B,GAAG;IAC5C,WAAW,EAAE,MAAM,CAAA;IACnB,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,MAAM,CAAA;CAChB,CAAA;AAED;;;;GAIG;AACH,wBAAsB,8BAA8B,CAClD,OAAO,EAAE,qCAAqC,GAC7C,OAAO,CAAC,+BAA+B,CAAC,CAyC1C"}