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

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 (336) hide show
  1. package/build/commands/commands.json +1 -1
  2. package/build/commands/make/attachment_v5_migration.d.ts.map +1 -1
  3. package/build/commands/make/attachment_v5_migration.js +6 -3
  4. package/build/commands/make/attachment_v5_migration.js.map +1 -1
  5. package/build/commands/make/attachments_table.d.ts.map +1 -1
  6. package/build/commands/make/attachments_table.js +8 -2
  7. package/build/commands/make/attachments_table.js.map +1 -1
  8. package/build/commands/make/converter.d.ts +17 -0
  9. package/build/commands/make/converter.d.ts.map +1 -0
  10. package/build/commands/make/converter.js +27 -0
  11. package/build/commands/make/converter.js.map +1 -0
  12. package/build/index.d.ts +12 -6
  13. package/build/index.d.ts.map +1 -1
  14. package/build/index.js +3 -5
  15. package/build/index.js.map +1 -1
  16. package/build/providers/attachment_provider.d.ts.map +1 -1
  17. package/build/providers/attachment_provider.js +36 -1
  18. package/build/providers/attachment_provider.js.map +1 -1
  19. package/build/services/converters.d.ts +10 -0
  20. package/build/services/converters.d.ts.map +1 -0
  21. package/build/services/converters.js +17 -0
  22. package/build/services/converters.js.map +1 -0
  23. package/build/src/adapters/adonis_drive_storage.d.ts.map +1 -1
  24. package/build/src/adapters/adonis_drive_storage.js +4 -1
  25. package/build/src/adapters/adonis_drive_storage.js.map +1 -1
  26. package/build/src/adapters/local_file_storage.d.ts.map +1 -1
  27. package/build/src/adapters/local_file_storage.js +9 -2
  28. package/build/src/adapters/local_file_storage.js.map +1 -1
  29. package/build/src/converters/autodetect_converter.d.ts +24 -0
  30. package/build/src/converters/autodetect_converter.d.ts.map +1 -0
  31. package/build/src/converters/autodetect_converter.js +113 -0
  32. package/build/src/converters/autodetect_converter.js.map +1 -0
  33. package/build/src/converters/configured_variant_converter_registry.d.ts +36 -0
  34. package/build/src/converters/configured_variant_converter_registry.d.ts.map +1 -0
  35. package/build/src/converters/configured_variant_converter_registry.js +81 -0
  36. package/build/src/converters/configured_variant_converter_registry.js.map +1 -0
  37. package/build/src/converters/converter.d.ts +148 -0
  38. package/build/src/converters/converter.d.ts.map +1 -0
  39. package/build/src/converters/converter.js +24 -0
  40. package/build/src/converters/converter.js.map +1 -0
  41. package/build/src/core/attachment.d.ts +7 -3
  42. package/build/src/core/attachment.d.ts.map +1 -1
  43. package/build/src/core/attachment.js +29 -4
  44. package/build/src/core/attachment.js.map +1 -1
  45. package/build/src/core/attachment_job_processor.d.ts +17 -1
  46. package/build/src/core/attachment_job_processor.d.ts.map +1 -1
  47. package/build/src/core/attachment_job_processor.js +81 -8
  48. package/build/src/core/attachment_job_processor.js.map +1 -1
  49. package/build/src/core/attachment_metadata_persister.d.ts +13 -0
  50. package/build/src/core/attachment_metadata_persister.d.ts.map +1 -0
  51. package/build/{tests/create_legacy_attachment_migration_script.spec.d.ts → src/core/attachment_metadata_persister.js} +1 -1
  52. package/build/src/core/attachment_metadata_persister.js.map +1 -0
  53. package/build/src/core/attachment_options.d.ts +3 -2
  54. package/build/src/core/attachment_options.d.ts.map +1 -1
  55. package/build/src/core/attachment_options.js.map +1 -1
  56. package/build/src/core/attachment_service.d.ts +24 -1
  57. package/build/src/core/attachment_service.d.ts.map +1 -1
  58. package/build/src/core/attachment_service.js +95 -4
  59. package/build/src/core/attachment_service.js.map +1 -1
  60. package/build/src/core/index.d.ts +9 -2
  61. package/build/src/core/index.d.ts.map +1 -1
  62. package/build/src/core/index.js +8 -2
  63. package/build/src/core/index.js.map +1 -1
  64. package/build/src/core/queue.d.ts +11 -1
  65. package/build/src/core/queue.d.ts.map +1 -1
  66. package/build/src/define_config.d.ts +40 -3
  67. package/build/src/define_config.d.ts.map +1 -1
  68. package/build/src/define_config.js +43 -1
  69. package/build/src/define_config.js.map +1 -1
  70. package/build/src/errors.d.ts +57 -0
  71. package/build/src/errors.d.ts.map +1 -0
  72. package/build/src/errors.js +96 -0
  73. package/build/src/errors.js.map +1 -0
  74. package/build/src/events/adonis_attachment_event_emitter.d.ts +17 -0
  75. package/build/src/events/adonis_attachment_event_emitter.d.ts.map +1 -0
  76. package/build/src/events/adonis_attachment_event_emitter.js +17 -0
  77. package/build/src/events/adonis_attachment_event_emitter.js.map +1 -0
  78. package/build/src/events/attachment_events.d.ts +43 -0
  79. package/build/src/events/attachment_events.d.ts.map +1 -0
  80. package/build/src/events/attachment_events.js +32 -0
  81. package/build/src/events/attachment_events.js.map +1 -0
  82. package/build/src/integrations/lucid/{attachment_column.d.ts → column/attachment_column.d.ts} +2 -2
  83. package/build/src/integrations/lucid/column/attachment_column.d.ts.map +1 -0
  84. package/build/src/integrations/lucid/{attachment_column.js → column/attachment_column.js} +2 -2
  85. package/build/src/integrations/lucid/column/attachment_column.js.map +1 -0
  86. package/build/src/integrations/lucid/index.d.ts +17 -13
  87. package/build/src/integrations/lucid/index.d.ts.map +1 -1
  88. package/build/src/integrations/lucid/index.js +17 -13
  89. package/build/src/integrations/lucid/index.js.map +1 -1
  90. package/build/src/integrations/lucid/migrations/legacy/legacy_attachment_migration_stub.d.ts +20 -0
  91. package/build/src/integrations/lucid/migrations/legacy/legacy_attachment_migration_stub.d.ts.map +1 -0
  92. package/build/src/integrations/lucid/migrations/legacy/legacy_attachment_migration_stub.js +18 -0
  93. package/build/src/integrations/lucid/migrations/legacy/legacy_attachment_migration_stub.js.map +1 -0
  94. package/build/src/integrations/lucid/{migrate_legacy_attachment.d.ts → migrations/legacy/migrate_legacy_attachment.d.ts} +22 -10
  95. package/build/src/integrations/lucid/migrations/legacy/migrate_legacy_attachment.d.ts.map +1 -0
  96. package/build/src/integrations/lucid/{migrate_legacy_attachment.js → migrations/legacy/migrate_legacy_attachment.js} +35 -25
  97. package/build/src/integrations/lucid/migrations/legacy/migrate_legacy_attachment.js.map +1 -0
  98. package/build/src/integrations/lucid/{migrate_legacy_attachment_records.d.ts → migrations/legacy/migrate_legacy_attachment_records.d.ts} +3 -3
  99. package/build/src/integrations/lucid/migrations/legacy/migrate_legacy_attachment_records.d.ts.map +1 -0
  100. package/build/src/integrations/lucid/{migrate_legacy_attachment_records.js → migrations/legacy/migrate_legacy_attachment_records.js} +11 -7
  101. package/build/src/integrations/lucid/migrations/legacy/migrate_legacy_attachment_records.js.map +1 -0
  102. package/build/src/integrations/lucid/models/attachment_link_model.d.ts +30 -0
  103. package/build/src/integrations/lucid/models/attachment_link_model.d.ts.map +1 -0
  104. package/build/src/integrations/lucid/models/attachment_link_model.js +59 -0
  105. package/build/src/integrations/lucid/models/attachment_link_model.js.map +1 -0
  106. package/build/src/integrations/lucid/{attachment_model.d.ts → models/attachment_model.d.ts} +5 -8
  107. package/build/src/integrations/lucid/models/attachment_model.d.ts.map +1 -0
  108. package/build/src/integrations/lucid/{attachment_model.js → models/attachment_model.js} +5 -16
  109. package/build/src/integrations/lucid/models/attachment_model.js.map +1 -0
  110. package/build/src/integrations/lucid/{lucid_attachment_lifecycle_service.d.ts → persistence/lucid_attachment_lifecycle_service.d.ts} +18 -14
  111. package/build/src/integrations/lucid/persistence/lucid_attachment_lifecycle_service.d.ts.map +1 -0
  112. package/build/src/integrations/lucid/persistence/lucid_attachment_lifecycle_service.js +252 -0
  113. package/build/src/integrations/lucid/persistence/lucid_attachment_lifecycle_service.js.map +1 -0
  114. package/build/src/integrations/lucid/persistence/lucid_attachment_metadata_persister.d.ts +17 -0
  115. package/build/src/integrations/lucid/persistence/lucid_attachment_metadata_persister.d.ts.map +1 -0
  116. package/build/src/integrations/lucid/persistence/lucid_attachment_metadata_persister.js +18 -0
  117. package/build/src/integrations/lucid/persistence/lucid_attachment_metadata_persister.js.map +1 -0
  118. package/build/src/integrations/lucid/{lucid_attachment_repository.d.ts → persistence/lucid_attachment_repository.d.ts} +3 -3
  119. package/build/src/integrations/lucid/persistence/lucid_attachment_repository.d.ts.map +1 -0
  120. package/build/src/integrations/lucid/{lucid_attachment_repository.js → persistence/lucid_attachment_repository.js} +1 -1
  121. package/build/src/integrations/lucid/persistence/lucid_attachment_repository.js.map +1 -0
  122. package/build/src/integrations/lucid/persistence/lucid_attachment_store.d.ts +48 -0
  123. package/build/src/integrations/lucid/persistence/lucid_attachment_store.d.ts.map +1 -0
  124. package/build/src/integrations/lucid/persistence/lucid_attachment_store.js +226 -0
  125. package/build/src/integrations/lucid/persistence/lucid_attachment_store.js.map +1 -0
  126. package/build/src/integrations/lucid/{lucid_variant_generation_service.d.ts → persistence/lucid_variant_generation_service.d.ts} +8 -5
  127. package/build/src/integrations/lucid/persistence/lucid_variant_generation_service.d.ts.map +1 -0
  128. package/build/src/integrations/lucid/{lucid_variant_generation_service.js → persistence/lucid_variant_generation_service.js} +9 -3
  129. package/build/src/integrations/lucid/persistence/lucid_variant_generation_service.js.map +1 -0
  130. package/build/src/integrations/lucid/relations/attachment_owner.d.ts.map +1 -0
  131. package/build/src/integrations/lucid/relations/attachment_owner.js.map +1 -0
  132. package/build/src/integrations/lucid/{attachment_relation.d.ts → relations/attachment_relation.d.ts} +29 -15
  133. package/build/src/integrations/lucid/relations/attachment_relation.d.ts.map +1 -0
  134. package/build/src/integrations/lucid/relations/attachment_relation.js +273 -0
  135. package/build/src/integrations/lucid/relations/attachment_relation.js.map +1 -0
  136. package/build/src/integrations/lucid/schema/attachment_schema_service.d.ts +28 -0
  137. package/build/src/integrations/lucid/schema/attachment_schema_service.d.ts.map +1 -0
  138. package/build/src/integrations/lucid/schema/attachment_schema_service.js +81 -0
  139. package/build/src/integrations/lucid/schema/attachment_schema_service.js.map +1 -0
  140. package/build/src/integrations/lucid/schema/attachment_table_names.d.ts +15 -0
  141. package/build/src/integrations/lucid/schema/attachment_table_names.d.ts.map +1 -0
  142. package/build/src/integrations/lucid/schema/attachment_table_names.js +23 -0
  143. package/build/src/integrations/lucid/schema/attachment_table_names.js.map +1 -0
  144. package/build/src/integrations/lucid/schema/attachments_table_stub.d.ts.map +1 -0
  145. package/build/src/integrations/lucid/{attachments_table_stub.js → schema/attachments_table_stub.js} +2 -4
  146. package/build/src/integrations/lucid/schema/attachments_table_stub.js.map +1 -0
  147. package/build/src/integrations/lucid/schema/configure_lucid_attachment_tables.d.ts +12 -0
  148. package/build/src/integrations/lucid/schema/configure_lucid_attachment_tables.d.ts.map +1 -0
  149. package/build/src/integrations/lucid/schema/configure_lucid_attachment_tables.js +19 -0
  150. package/build/src/integrations/lucid/schema/configure_lucid_attachment_tables.js.map +1 -0
  151. package/build/src/media/binaries.d.ts +79 -0
  152. package/build/src/media/binaries.d.ts.map +1 -0
  153. package/build/src/media/binaries.js +288 -0
  154. package/build/src/media/binaries.js.map +1 -0
  155. package/build/src/media/blurhash.d.ts +48 -0
  156. package/build/src/media/blurhash.d.ts.map +1 -0
  157. package/build/src/media/blurhash.js +46 -0
  158. package/build/src/media/blurhash.js.map +1 -0
  159. package/build/src/media/exif.d.ts +23 -0
  160. package/build/src/media/exif.d.ts.map +1 -0
  161. package/build/src/media/exif.js +98 -0
  162. package/build/src/media/exif.js.map +1 -0
  163. package/build/src/media/media_metadata.d.ts +55 -0
  164. package/build/src/media/media_metadata.d.ts.map +1 -0
  165. package/build/src/media/media_metadata.js +27 -0
  166. package/build/src/media/media_metadata.js.map +1 -0
  167. package/build/src/media/sharp.d.ts +45 -0
  168. package/build/src/media/sharp.d.ts.map +1 -0
  169. package/build/src/media/sharp.js +76 -0
  170. package/build/src/media/sharp.js.map +1 -0
  171. package/build/src/media/v5_metadata.d.ts +20 -0
  172. package/build/src/media/v5_metadata.d.ts.map +1 -0
  173. package/build/src/media/v5_metadata.js +20 -0
  174. package/build/src/media/v5_metadata.js.map +1 -0
  175. package/build/src/queues/memory_queue.d.ts.map +1 -1
  176. package/build/src/queues/memory_queue.js +4 -1
  177. package/build/src/queues/memory_queue.js.map +1 -1
  178. package/build/src/sources/attachment_manager.d.ts +1 -3
  179. package/build/src/sources/attachment_manager.d.ts.map +1 -1
  180. package/build/src/sources/attachment_manager.js +19 -12
  181. package/build/src/sources/attachment_manager.js.map +1 -1
  182. package/build/src/variants/variant_converter.d.ts +4 -1
  183. package/build/src/variants/variant_converter.d.ts.map +1 -1
  184. package/build/src/variants/variant_generation_service.d.ts +9 -3
  185. package/build/src/variants/variant_generation_service.d.ts.map +1 -1
  186. package/build/src/variants/variant_generation_service.js +47 -6
  187. package/build/src/variants/variant_generation_service.js.map +1 -1
  188. package/build/stubs/config/attachment.stub +23 -2
  189. package/build/stubs/converters/converter.stub +18 -0
  190. package/build/stubs/migrations/attachments_table.stub +7 -25
  191. package/build/{src/integrations/lucid/render_legacy_attachment_migration_script.js → stubs/migrations/legacy_attachment_migration.stub} +13 -15
  192. package/build/tests/adonis_queue.spec.js +56 -1
  193. package/build/tests/adonis_queue.spec.js.map +1 -1
  194. package/build/tests/attachment_events.spec.d.ts +8 -0
  195. package/build/tests/attachment_events.spec.d.ts.map +1 -0
  196. package/build/tests/attachment_events.spec.js +65 -0
  197. package/build/tests/attachment_events.spec.js.map +1 -0
  198. package/build/tests/attachment_job_processor.spec.js +77 -2
  199. package/build/tests/attachment_job_processor.spec.js.map +1 -1
  200. package/build/tests/attachment_provider.spec.js +84 -1
  201. package/build/tests/attachment_provider.spec.js.map +1 -1
  202. package/build/tests/attachment_schema_service.spec.d.ts +8 -0
  203. package/build/tests/attachment_schema_service.spec.d.ts.map +1 -0
  204. package/build/tests/attachment_schema_service.spec.js +52 -0
  205. package/build/tests/attachment_schema_service.spec.js.map +1 -0
  206. package/build/tests/attachment_service.spec.js +81 -2
  207. package/build/tests/attachment_service.spec.js.map +1 -1
  208. package/build/tests/attachment_table_names.spec.d.ts +8 -0
  209. package/build/tests/attachment_table_names.spec.d.ts.map +1 -0
  210. package/build/tests/attachment_table_names.spec.js +36 -0
  211. package/build/tests/attachment_table_names.spec.js.map +1 -0
  212. package/build/tests/attachments_table_stub.spec.js +41 -6
  213. package/build/tests/attachments_table_stub.spec.js.map +1 -1
  214. package/build/tests/autodetect_converter.spec.d.ts +8 -0
  215. package/build/tests/autodetect_converter.spec.d.ts.map +1 -0
  216. package/build/tests/autodetect_converter.spec.js +55 -0
  217. package/build/tests/autodetect_converter.spec.js.map +1 -0
  218. package/build/tests/binary_media.spec.d.ts +8 -0
  219. package/build/tests/binary_media.spec.d.ts.map +1 -0
  220. package/build/tests/binary_media.spec.js +106 -0
  221. package/build/tests/binary_media.spec.js.map +1 -0
  222. package/build/tests/blurhash_media.spec.d.ts +8 -0
  223. package/build/tests/blurhash_media.spec.d.ts.map +1 -0
  224. package/build/tests/blurhash_media.spec.js +40 -0
  225. package/build/tests/blurhash_media.spec.js.map +1 -0
  226. package/build/tests/configure.spec.js +1 -0
  227. package/build/tests/configure.spec.js.map +1 -1
  228. package/build/tests/configured_variant_converter_registry.spec.d.ts +8 -0
  229. package/build/tests/configured_variant_converter_registry.spec.d.ts.map +1 -0
  230. package/build/tests/configured_variant_converter_registry.spec.js +73 -0
  231. package/build/tests/configured_variant_converter_registry.spec.js.map +1 -0
  232. package/build/tests/converter_config.types.d.ts +36 -0
  233. package/build/tests/converter_config.types.d.ts.map +1 -0
  234. package/build/tests/converter_config.types.js +60 -0
  235. package/build/tests/converter_config.types.js.map +1 -0
  236. package/build/tests/define_config.spec.js +113 -0
  237. package/build/tests/define_config.spec.js.map +1 -1
  238. package/build/tests/errors.spec.d.ts +8 -0
  239. package/build/tests/errors.spec.d.ts.map +1 -0
  240. package/build/tests/errors.spec.js +43 -0
  241. package/build/tests/errors.spec.js.map +1 -0
  242. package/build/tests/exif_media.spec.d.ts +8 -0
  243. package/build/tests/exif_media.spec.d.ts.map +1 -0
  244. package/build/tests/exif_media.spec.js +50 -0
  245. package/build/tests/exif_media.spec.js.map +1 -0
  246. package/build/tests/helpers/lucid_test_database.d.ts.map +1 -1
  247. package/build/tests/helpers/lucid_test_database.js +17 -7
  248. package/build/tests/helpers/lucid_test_database.js.map +1 -1
  249. package/build/tests/legacy_attachment_migration_stub.spec.d.ts +8 -0
  250. package/build/tests/legacy_attachment_migration_stub.spec.d.ts.map +1 -0
  251. package/build/tests/legacy_attachment_migration_stub.spec.js +57 -0
  252. package/build/tests/legacy_attachment_migration_stub.spec.js.map +1 -0
  253. package/build/tests/lucid_attachment_collection_store.spec.js +5 -4
  254. package/build/tests/lucid_attachment_collection_store.spec.js.map +1 -1
  255. package/build/tests/lucid_attachment_column.spec.js +1 -1
  256. package/build/tests/lucid_attachment_column.spec.js.map +1 -1
  257. package/build/tests/lucid_attachment_lifecycle_service.spec.js +144 -256
  258. package/build/tests/lucid_attachment_lifecycle_service.spec.js.map +1 -1
  259. package/build/tests/lucid_attachment_metadata_persister.spec.d.ts +8 -0
  260. package/build/tests/lucid_attachment_metadata_persister.spec.d.ts.map +1 -0
  261. package/build/tests/lucid_attachment_metadata_persister.spec.js +34 -0
  262. package/build/tests/lucid_attachment_metadata_persister.spec.js.map +1 -0
  263. package/build/tests/lucid_attachment_relation.spec.js +167 -27
  264. package/build/tests/lucid_attachment_relation.spec.js.map +1 -1
  265. package/build/tests/lucid_attachment_repository.spec.js +1 -1
  266. package/build/tests/lucid_attachment_repository.spec.js.map +1 -1
  267. package/build/tests/lucid_attachment_store.spec.js +24 -52
  268. package/build/tests/lucid_attachment_store.spec.js.map +1 -1
  269. package/build/tests/lucid_sqlite_integration.spec.js +24 -18
  270. package/build/tests/lucid_sqlite_integration.spec.js.map +1 -1
  271. package/build/tests/lucid_variant_generation_service.spec.js +18 -1
  272. package/build/tests/lucid_variant_generation_service.spec.js.map +1 -1
  273. package/build/tests/make_converter.spec.d.ts +8 -0
  274. package/build/tests/make_converter.spec.d.ts.map +1 -0
  275. package/build/tests/make_converter.spec.js +32 -0
  276. package/build/tests/make_converter.spec.js.map +1 -0
  277. package/build/tests/media_metadata.spec.d.ts +8 -0
  278. package/build/tests/media_metadata.spec.d.ts.map +1 -0
  279. package/build/tests/media_metadata.spec.js +51 -0
  280. package/build/tests/media_metadata.spec.js.map +1 -0
  281. package/build/tests/migrate_legacy_attachment.spec.js +62 -47
  282. package/build/tests/migrate_legacy_attachment.spec.js.map +1 -1
  283. package/build/tests/migrate_legacy_attachment_records.spec.js +4 -3
  284. package/build/tests/migrate_legacy_attachment_records.spec.js.map +1 -1
  285. package/build/tests/package_exports.spec.js +18 -2
  286. package/build/tests/package_exports.spec.js.map +1 -1
  287. package/build/tests/sharp_media.spec.d.ts +8 -0
  288. package/build/tests/sharp_media.spec.d.ts.map +1 -0
  289. package/build/tests/sharp_media.spec.js +84 -0
  290. package/build/tests/sharp_media.spec.js.map +1 -0
  291. package/build/tests/v5_metadata.spec.d.ts +8 -0
  292. package/build/tests/v5_metadata.spec.d.ts.map +1 -0
  293. package/build/tests/v5_metadata.spec.js +19 -0
  294. package/build/tests/v5_metadata.spec.js.map +1 -0
  295. package/build/tests/variant_generation_service.spec.js +122 -0
  296. package/build/tests/variant_generation_service.spec.js.map +1 -1
  297. package/package.json +50 -2
  298. package/build/src/integrations/lucid/attachment_column.d.ts.map +0 -1
  299. package/build/src/integrations/lucid/attachment_column.js.map +0 -1
  300. package/build/src/integrations/lucid/attachment_model.d.ts.map +0 -1
  301. package/build/src/integrations/lucid/attachment_model.js.map +0 -1
  302. package/build/src/integrations/lucid/attachment_owner.d.ts.map +0 -1
  303. package/build/src/integrations/lucid/attachment_owner.js.map +0 -1
  304. package/build/src/integrations/lucid/attachment_relation.d.ts.map +0 -1
  305. package/build/src/integrations/lucid/attachment_relation.js +0 -163
  306. package/build/src/integrations/lucid/attachment_relation.js.map +0 -1
  307. package/build/src/integrations/lucid/attachments_table_stub.d.ts.map +0 -1
  308. package/build/src/integrations/lucid/attachments_table_stub.js.map +0 -1
  309. package/build/src/integrations/lucid/create_legacy_attachment_migration_script.d.ts +0 -13
  310. package/build/src/integrations/lucid/create_legacy_attachment_migration_script.d.ts.map +0 -1
  311. package/build/src/integrations/lucid/create_legacy_attachment_migration_script.js +0 -20
  312. package/build/src/integrations/lucid/create_legacy_attachment_migration_script.js.map +0 -1
  313. package/build/src/integrations/lucid/lucid_attachment_lifecycle_service.d.ts.map +0 -1
  314. package/build/src/integrations/lucid/lucid_attachment_lifecycle_service.js +0 -188
  315. package/build/src/integrations/lucid/lucid_attachment_lifecycle_service.js.map +0 -1
  316. package/build/src/integrations/lucid/lucid_attachment_repository.d.ts.map +0 -1
  317. package/build/src/integrations/lucid/lucid_attachment_repository.js.map +0 -1
  318. package/build/src/integrations/lucid/lucid_attachment_store.d.ts +0 -36
  319. package/build/src/integrations/lucid/lucid_attachment_store.d.ts.map +0 -1
  320. package/build/src/integrations/lucid/lucid_attachment_store.js +0 -179
  321. package/build/src/integrations/lucid/lucid_attachment_store.js.map +0 -1
  322. package/build/src/integrations/lucid/lucid_variant_generation_service.d.ts.map +0 -1
  323. package/build/src/integrations/lucid/lucid_variant_generation_service.js.map +0 -1
  324. package/build/src/integrations/lucid/migrate_legacy_attachment.d.ts.map +0 -1
  325. package/build/src/integrations/lucid/migrate_legacy_attachment.js.map +0 -1
  326. package/build/src/integrations/lucid/migrate_legacy_attachment_records.d.ts.map +0 -1
  327. package/build/src/integrations/lucid/migrate_legacy_attachment_records.js.map +0 -1
  328. package/build/src/integrations/lucid/render_legacy_attachment_migration_script.d.ts +0 -11
  329. package/build/src/integrations/lucid/render_legacy_attachment_migration_script.d.ts.map +0 -1
  330. package/build/src/integrations/lucid/render_legacy_attachment_migration_script.js.map +0 -1
  331. package/build/tests/create_legacy_attachment_migration_script.spec.d.ts.map +0 -1
  332. package/build/tests/create_legacy_attachment_migration_script.spec.js +0 -31
  333. package/build/tests/create_legacy_attachment_migration_script.spec.js.map +0 -1
  334. /package/build/src/integrations/lucid/{attachment_owner.d.ts → relations/attachment_owner.d.ts} +0 -0
  335. /package/build/src/integrations/lucid/{attachment_owner.js → relations/attachment_owner.js} +0 -0
  336. /package/build/src/integrations/lucid/{attachments_table_stub.d.ts → schema/attachments_table_stub.d.ts} +0 -0
@@ -0,0 +1,252 @@
1
+ /**
2
+ * @jrmc/adonis-attachment
3
+ *
4
+ * @license MIT
5
+ * @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
6
+ */
7
+ import { isAttachmentDraft, } from '../../../core/attachment.js';
8
+ import { AttachmentConfigurationError } from '../../../errors.js';
9
+ export class LucidAttachmentLifecycleService {
10
+ #attachments;
11
+ #store;
12
+ constructor(attachments, store) {
13
+ this.#attachments = attachments;
14
+ this.#store = store;
15
+ }
16
+ get(owner) {
17
+ return this.#store.findOriginal(owner);
18
+ }
19
+ async attach(owner, input, options) {
20
+ const persisted = await this.#persist(owner, input, options);
21
+ let original;
22
+ try {
23
+ original = await this.#store.createOriginal(owner, persisted.attachment);
24
+ this.#removeOnRollback(owner, [persisted.attachment]);
25
+ }
26
+ catch (error) {
27
+ await this.#removeStoredFile(persisted.attachment);
28
+ throw error;
29
+ }
30
+ await this.#scheduleVariants(owner, persisted, options);
31
+ await this.#scheduleMetadata(owner, persisted, options);
32
+ return original;
33
+ }
34
+ async replace(owner, input, options) {
35
+ const previous = await this.#store.findOriginal(owner);
36
+ if (!previous) {
37
+ return this.attach(owner, input, options);
38
+ }
39
+ const persisted = await this.#persist(owner, input, options);
40
+ let current;
41
+ try {
42
+ await this.#store.releaseOwner(previous);
43
+ current = await this.#store.createOriginal(owner, persisted.attachment);
44
+ }
45
+ catch (error) {
46
+ await this.#store.restoreOwner(previous).catch(() => undefined);
47
+ await this.#removeStoredFile(persisted.attachment);
48
+ throw error;
49
+ }
50
+ try {
51
+ const removed = await this.#store.remove(previous);
52
+ await this.#removeOnCommit(owner, removed.map((item) => item.toAttachment()));
53
+ }
54
+ catch (error) {
55
+ await this.#store.remove(current).catch(() => undefined);
56
+ await this.#store.restoreOwner(previous).catch(() => undefined);
57
+ await this.#removeStoredFile(current.toAttachment());
58
+ throw error;
59
+ }
60
+ this.#removeOnRollback(owner, [current.toAttachment()]);
61
+ await this.#scheduleVariants(owner, persisted, options);
62
+ await this.#scheduleMetadata(owner, persisted, options);
63
+ return current;
64
+ }
65
+ async detach(owner) {
66
+ const original = await this.#store.findOriginal(owner);
67
+ if (!original) {
68
+ return;
69
+ }
70
+ const removed = await this.#store.remove(original);
71
+ await this.#removeOnCommit(owner, removed.map((item) => item.toAttachment()));
72
+ }
73
+ async listVariants(owner) {
74
+ const original = await this.#store.findOriginal(owner);
75
+ return original ? this.#store.listVariants(original.attachmentId) : [];
76
+ }
77
+ async purgeOwner(owner) {
78
+ for (const link of await this.#store.listOwnerLinks(owner)) {
79
+ const removed = await this.#store.remove(link);
80
+ await this.#removeOnCommit(owner, removed.map((attachment) => attachment.toAttachment()));
81
+ }
82
+ }
83
+ async add(owner, input, position, options) {
84
+ const created = await this.#add(owner, input, position, options);
85
+ await this.#scheduleVariants(owner, created.persisted, options);
86
+ await this.#scheduleMetadata(owner, created.persisted, options);
87
+ return created.item;
88
+ }
89
+ async #add(owner, input, position, options) {
90
+ const persisted = await this.#persist(owner, input, options);
91
+ try {
92
+ const item = await this.#collectionStore().createCollectionItem(owner, persisted.attachment, position);
93
+ this.#removeOnRollback(owner, [persisted.attachment]);
94
+ return { item, persisted };
95
+ }
96
+ catch (error) {
97
+ await this.#removeStoredFile(persisted.attachment);
98
+ throw error;
99
+ }
100
+ }
101
+ attachExisting(owner, attachmentId) {
102
+ return this.#linkStore().createOriginalLink(owner, attachmentId);
103
+ }
104
+ addExisting(owner, attachmentId, position) {
105
+ return this.#linkStore().createCollectionLink(owner, attachmentId, position);
106
+ }
107
+ listCollection(owner) {
108
+ return this.#collectionStore().listCollection(owner);
109
+ }
110
+ async removeCollectionItem(owner, id) {
111
+ const item = await this.#collectionStore().findCollectionItem(owner, id);
112
+ if (!item) {
113
+ return false;
114
+ }
115
+ await this.#detachCollectionItem(owner, item);
116
+ return true;
117
+ }
118
+ async clearCollection(owner) {
119
+ for (const item of await this.#collectionStore().listCollection(owner)) {
120
+ await this.#detachCollectionItem(owner, item);
121
+ }
122
+ }
123
+ async replaceCollection(owner, inputs, options) {
124
+ const previous = await this.#collectionStore().listCollection(owner);
125
+ const created = [];
126
+ try {
127
+ for (const input of inputs) {
128
+ created.push(await this.#add(owner, input, undefined, options));
129
+ }
130
+ }
131
+ catch (error) {
132
+ await Promise.all(created.map(({ item }) => this.#detachCollectionItem(owner, item)));
133
+ throw error;
134
+ }
135
+ for (const item of previous) {
136
+ await this.#detachCollectionItem(owner, item);
137
+ }
138
+ for (const item of created) {
139
+ await this.#scheduleVariants(owner, item.persisted, options);
140
+ await this.#scheduleMetadata(owner, item.persisted, options);
141
+ }
142
+ return this.#collectionStore().listCollection(owner);
143
+ }
144
+ moveCollectionItem(owner, id, position) {
145
+ return this.#collectionStore().moveCollectionItem(owner, id, position);
146
+ }
147
+ async #removeStoredFile(attachment) {
148
+ await this.#attachments.remove(attachment);
149
+ }
150
+ async #removeOnCommit(owner, attachments) {
151
+ await this.#afterCommit(owner, () => this.#removeStoredFiles(attachments));
152
+ }
153
+ #removeOnRollback(owner, attachments) {
154
+ const transaction = getOwnerTransaction(owner);
155
+ if (transaction) {
156
+ transaction.after('rollback', () => this.#removeStoredFiles(attachments));
157
+ }
158
+ }
159
+ #removeStoredFiles(attachments) {
160
+ return Promise.all(attachments.map((attachment) => this.#removeStoredFile(attachment))).then(() => undefined);
161
+ }
162
+ async #afterCommit(owner, callback) {
163
+ const transaction = getOwnerTransaction(owner);
164
+ if (transaction) {
165
+ transaction.after('commit', callback);
166
+ return;
167
+ }
168
+ await callback();
169
+ }
170
+ async #detachCollectionItem(owner, item) {
171
+ const removed = await this.#collectionStore().removeCollectionItem(owner, item);
172
+ await this.#removeOnCommit(owner, removed.map((attachment) => attachment.toAttachment()));
173
+ }
174
+ #collectionStore() {
175
+ const store = this.#store;
176
+ if (!store.createCollectionItem ||
177
+ !store.findCollectionItem ||
178
+ !store.listCollection ||
179
+ !store.moveCollectionItem ||
180
+ !store.removeCollectionItem) {
181
+ throw new AttachmentConfigurationError('Lucid attachment collection operations require a collection-capable store');
182
+ }
183
+ return store;
184
+ }
185
+ #linkStore() {
186
+ const store = this.#store;
187
+ if (!store.createOriginalLink || !store.createCollectionLink) {
188
+ throw new AttachmentConfigurationError('Lucid attachment link operations require a link-capable store');
189
+ }
190
+ return store;
191
+ }
192
+ async #persist(owner, input, options) {
193
+ if (isAttachmentDraft(input)) {
194
+ return {
195
+ draft: input,
196
+ attachment: await input.persist({
197
+ ...(options ? { options } : {}),
198
+ context: { model: owner.model, field: owner.field },
199
+ }),
200
+ };
201
+ }
202
+ if (this.#attachments.createDraft) {
203
+ const draft = this.#attachments.createDraft(input);
204
+ return {
205
+ draft,
206
+ attachment: await draft.persist({
207
+ ...(options ? { options } : {}),
208
+ context: { model: owner.model, field: owner.field },
209
+ }),
210
+ };
211
+ }
212
+ return { attachment: await this.#attachments.create(input) };
213
+ }
214
+ async #scheduleVariants(owner, persisted, options) {
215
+ if (!persisted.draft || !this.#attachments.getVariantKeys || !this.#attachments.scheduleVariantGeneration) {
216
+ return;
217
+ }
218
+ const keys = this.#attachments.getVariantKeys(persisted.draft, options);
219
+ if (!keys?.length) {
220
+ return;
221
+ }
222
+ const meta = this.#attachments.getVariantMetadataEnabled?.(persisted.draft, options);
223
+ const eventContext = this.#eventContext(owner);
224
+ await this.#afterCommit(owner, () => this.#attachments.scheduleVariantGeneration(persisted.attachment, keys, meta, eventContext));
225
+ }
226
+ async #scheduleMetadata(owner, persisted, options) {
227
+ if (!persisted.draft || !this.#attachments.getMetadataMode || !this.#attachments.scheduleMetadataExtraction) {
228
+ return;
229
+ }
230
+ if (this.#attachments.getMetadataMode(persisted.draft, options) !== 'deferred') {
231
+ return;
232
+ }
233
+ const eventContext = this.#eventContext(owner);
234
+ await this.#afterCommit(owner, () => this.#attachments.scheduleMetadataExtraction(persisted.attachment, eventContext));
235
+ }
236
+ #eventContext(owner) {
237
+ const model = owner.model;
238
+ return {
239
+ tableName: owner.type,
240
+ attributeName: owner.field,
241
+ primary: {
242
+ key: model?.constructor?.primaryKey ?? 'id',
243
+ value: owner.id,
244
+ },
245
+ };
246
+ }
247
+ }
248
+ function getOwnerTransaction(owner) {
249
+ const model = owner.model;
250
+ return model?.$trx ?? null;
251
+ }
252
+ //# sourceMappingURL=lucid_attachment_lifecycle_service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lucid_attachment_lifecycle_service.js","sourceRoot":"","sources":["../../../../../src/integrations/lucid/persistence/lucid_attachment_lifecycle_service.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,iBAAiB,GAIlB,MAAM,6BAA6B,CAAA;AAOpC,OAAO,EAAE,4BAA4B,EAAE,MAAM,oBAAoB,CAAA;AA4BjE,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,KAAK,CAAA;IACrB,CAAC;IAED,GAAG,CAAC,KAAsB;QACxB,OAAO,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,CAAA;IACxC,CAAC;IAED,KAAK,CAAC,MAAM,CACV,KAAsB,EACtB,KAA8C,EAC9C,OAA2C;QAE3C,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,CAAC,CAAA;QAE5D,IAAI,QAA6B,CAAA;QAEjC,IAAI,CAAC;YACH,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,KAAK,EAAE,SAAS,CAAC,UAAU,CAAC,CAAA;YACxE,IAAI,CAAC,iBAAiB,CAAC,KAAK,EAAE,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,CAAA;QACvD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,IAAI,CAAC,iBAAiB,CAAC,SAAS,CAAC,UAAU,CAAC,CAAA;YAClD,MAAM,KAAK,CAAA;QACb,CAAC;QAED,MAAM,IAAI,CAAC,iBAAiB,CAAC,KAAK,EAAE,SAAS,EAAE,OAAO,CAAC,CAAA;QACvD,MAAM,IAAI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7
+ import type { Attachment } from '../../../core/attachment.js';
8
+ import type { AttachmentMetadataPersister } from '../../../core/attachment_metadata_persister.js';
9
+ import type { AttachmentMetadata } from '../../../media/media_metadata.js';
10
+ import { AttachmentModel } from '../models/attachment_model.js';
11
+ /** Updates metadata for an attachment blob persisted in the Lucid attachments table. */
12
+ export declare class LucidAttachmentMetadataPersister implements AttachmentMetadataPersister {
13
+ #private;
14
+ constructor(model?: typeof AttachmentModel);
15
+ persistMetadata(attachment: Attachment, metadata: AttachmentMetadata): Promise<void>;
16
+ }
17
+ //# sourceMappingURL=lucid_attachment_metadata_persister.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lucid_attachment_metadata_persister.d.ts","sourceRoot":"","sources":["../../../../../src/integrations/lucid/persistence/lucid_attachment_metadata_persister.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAA;AAC7D,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,gDAAgD,CAAA;AACjG,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAA;AAC1E,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAE/D,wFAAwF;AACxF,qBAAa,gCAAiC,YAAW,2BAA2B;;gBAGtE,KAAK,GAAE,OAAO,eAAiC;IAIrD,eAAe,CAAC,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;CAG3F"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * @jrmc/adonis-attachment
3
+ *
4
+ * @license MIT
5
+ * @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
6
+ */
7
+ import { AttachmentModel } from '../models/attachment_model.js';
8
+ /** Updates metadata for an attachment blob persisted in the Lucid attachments table. */
9
+ export class LucidAttachmentMetadataPersister {
10
+ #model;
11
+ constructor(model = AttachmentModel) {
12
+ this.#model = model;
13
+ }
14
+ async persistMetadata(attachment, metadata) {
15
+ await this.#model.query().where('id', attachment.id).update({ metadata });
16
+ }
17
+ }
18
+ //# sourceMappingURL=lucid_attachment_metadata_persister.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lucid_attachment_metadata_persister.js","sourceRoot":"","sources":["../../../../../src/integrations/lucid/persistence/lucid_attachment_metadata_persister.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAE/D,wFAAwF;AACxF,MAAM,OAAO,gCAAgC;IAClC,MAAM,CAAwB;IAEvC,YAAY,QAAgC,eAAe;QACzD,IAAI,CAAC,MAAM,GAAG,KAAK,CAAA;IACrB,CAAC;IAED,KAAK,CAAC,eAAe,CAAC,UAAsB,EAAE,QAA4B;QACxE,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,UAAU,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAA;IAC3E,CAAC;CACF"}
@@ -4,9 +4,9 @@
4
4
  * @license MIT
5
5
  * @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
6
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';
7
+ import type { Attachment } from '../../../core/attachment.js';
8
+ import type { AttachmentRepository } from '../../../core/attachment_repository.js';
9
+ import { AttachmentModel } from '../models/attachment_model.js';
10
10
  /**
11
11
  * Attachment repository used by workers when attachments are persisted by Lucid.
12
12
  */
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lucid_attachment_repository.d.ts","sourceRoot":"","sources":["../../../../../src/integrations/lucid/persistence/lucid_attachment_repository.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAA;AAC7D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wCAAwC,CAAA;AAClF,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAE/D;;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"}
@@ -4,7 +4,7 @@
4
4
  * @license MIT
5
5
  * @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
6
6
  */
7
- import { AttachmentModel } from './attachment_model.js';
7
+ import { AttachmentModel } from '../models/attachment_model.js';
8
8
  /**
9
9
  * Attachment repository used by workers when attachments are persisted by Lucid.
10
10
  */
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lucid_attachment_repository.js","sourceRoot":"","sources":["../../../../../src/integrations/lucid/persistence/lucid_attachment_repository.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAE/D;;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,48 @@
1
+ /**
2
+ * @jrmc/adonis-attachment
3
+ *
4
+ * @license MIT
5
+ * @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
6
+ */
7
+ import type { TransactionClientContract } from '@adonisjs/lucid/types/database';
8
+ import type { Attachment } from '../../../core/attachment.js';
9
+ import { type AttachmentOwner } from '../relations/attachment_owner.js';
10
+ import { AttachmentLinkModel } from '../models/attachment_link_model.js';
11
+ import { AttachmentModel } from '../models/attachment_model.js';
12
+ export type LucidAttachmentWithVariants = {
13
+ original: AttachmentLinkModel;
14
+ variants: AttachmentModel[];
15
+ };
16
+ export type LucidAttachmentStoreOptions = {
17
+ client?: TransactionClientContract;
18
+ linkModel?: typeof AttachmentLinkModel;
19
+ createLinkId?: () => string;
20
+ };
21
+ /**
22
+ * Persists immutable file blobs separately from their polymorphic owner links.
23
+ */
24
+ export declare class LucidAttachmentStore {
25
+ #private;
26
+ constructor(blobModel?: typeof AttachmentModel, options?: LucidAttachmentStoreOptions);
27
+ createOriginal(owner: AttachmentOwner, attachment: Attachment): Promise<AttachmentLinkModel>;
28
+ createCollectionItem(owner: AttachmentOwner, attachment: Attachment, position?: number): Promise<AttachmentLinkModel>;
29
+ createOriginalLink(owner: AttachmentOwner, attachmentId: string): Promise<AttachmentLinkModel>;
30
+ createCollectionLink(owner: AttachmentOwner, attachmentId: string, position?: number): Promise<AttachmentLinkModel>;
31
+ createVariant(original: AttachmentModel, key: string, attachment: Attachment): Promise<AttachmentModel>;
32
+ releaseOwner(original: AttachmentLinkModel): Promise<void>;
33
+ restoreOwner(original: AttachmentLinkModel): Promise<void>;
34
+ findOriginal(owner: AttachmentOwner): Promise<AttachmentLinkModel | null>;
35
+ listCollection(owner: AttachmentOwner): Promise<AttachmentLinkModel[]>;
36
+ findCollectionItem(owner: AttachmentOwner, id: string): Promise<AttachmentLinkModel | null>;
37
+ removeCollectionItem(owner: AttachmentOwner, item: AttachmentLinkModel): Promise<AttachmentModel[]>;
38
+ moveCollectionItem(owner: AttachmentOwner, id: string, position: number): Promise<AttachmentLinkModel[]>;
39
+ findById(id: string): Promise<AttachmentModel | null>;
40
+ findByOwner(owner: AttachmentOwner): Promise<LucidAttachmentWithVariants | null>;
41
+ listVariants(originalId: string): Promise<AttachmentModel[]>;
42
+ /**
43
+ * Deletes a link and returns blobs that became unreferenced and were removed.
44
+ */
45
+ remove(link: AttachmentLinkModel): Promise<AttachmentModel[]>;
46
+ listOwnerLinks(owner: AttachmentOwner): Promise<AttachmentLinkModel[]>;
47
+ }
48
+ //# sourceMappingURL=lucid_attachment_store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lucid_attachment_store.d.ts","sourceRoot":"","sources":["../../../../../src/integrations/lucid/persistence/lucid_attachment_store.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAA;AAE/E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAA;AAE7D,OAAO,EAA4B,KAAK,eAAe,EAAE,MAAM,kCAAkC,CAAA;AACjG,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAA;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAG/D,MAAM,MAAM,2BAA2B,GAAG;IACxC,QAAQ,EAAE,mBAAmB,CAAA;IAC7B,QAAQ,EAAE,eAAe,EAAE,CAAA;CAC5B,CAAA;AAED,MAAM,MAAM,2BAA2B,GAAG;IACxC,MAAM,CAAC,EAAE,yBAAyB,CAAA;IAClC,SAAS,CAAC,EAAE,OAAO,mBAAmB,CAAA;IACtC,YAAY,CAAC,EAAE,MAAM,MAAM,CAAA;CAC5B,CAAA;AAED;;GAEG;AACH,qBAAa,oBAAoB;;gBAO7B,SAAS,GAAE,OAAO,eAAiC,EACnD,OAAO,GAAE,2BAAgC;IAQrC,cAAc,CAAC,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAW5F,oBAAoB,CACxB,KAAK,EAAE,eAAe,EACtB,UAAU,EAAE,UAAU,EACtB,QAAQ,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC,mBAAmB,CAAC;IAczB,kBAAkB,CAAC,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,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AAK,EAAE,eAAe,GAAG,OAAO,CAAC,mBAAmB,EAAE,CAAC;CAkGvE"}
@@ -0,0 +1,226 @@
1
+ /**
2
+ * @jrmc/adonis-attachment
3
+ *
4
+ * @license MIT
5
+ * @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
6
+ */
7
+ import { randomUUID } from 'node:crypto';
8
+ import { markAttachmentPersisted } from '../../../core/attachment_state.js';
9
+ import { createAttachmentOwnerKey } from '../relations/attachment_owner.js';
10
+ import { AttachmentLinkModel } from '../models/attachment_link_model.js';
11
+ import { AttachmentModel } from '../models/attachment_model.js';
12
+ import { AttachmentNotFoundError, AttachmentValidationError } from '../../../errors.js';
13
+ /**
14
+ * Persists immutable file blobs separately from their polymorphic owner links.
15
+ */
16
+ export class LucidAttachmentStore {
17
+ #blobModel;
18
+ #linkModel;
19
+ #client;
20
+ #createLinkId;
21
+ constructor(blobModel = AttachmentModel, options = {}) {
22
+ this.#blobModel = blobModel;
23
+ this.#linkModel = options.linkModel ?? AttachmentLinkModel;
24
+ this.#client = options.client;
25
+ this.#createLinkId = options.createLinkId ?? randomUUID;
26
+ }
27
+ async createOriginal(owner, attachment) {
28
+ const blob = await this.#createBlob(attachment);
29
+ try {
30
+ return await this.#createLink(owner, blob, { ownerKey: createAttachmentOwnerKey(owner) });
31
+ }
32
+ catch (error) {
33
+ await blob.delete().catch(() => undefined);
34
+ throw error;
35
+ }
36
+ }
37
+ async createCollectionItem(owner, attachment, position) {
38
+ const items = await this.listCollection(owner);
39
+ const target = normalizePosition(position, items.length);
40
+ const blob = await this.#createBlob(attachment);
41
+ try {
42
+ await this.#shiftCollection(items, target, 1);
43
+ return await this.#createLink(owner, blob, { position: target });
44
+ }
45
+ catch (error) {
46
+ await blob.delete().catch(() => undefined);
47
+ throw error;
48
+ }
49
+ }
50
+ async createOriginalLink(owner, attachmentId) {
51
+ const blob = await this.#findBlobOrFail(attachmentId);
52
+ return this.#createLink(owner, blob, { ownerKey: createAttachmentOwnerKey(owner) });
53
+ }
54
+ async createCollectionLink(owner, attachmentId, position) {
55
+ const items = await this.listCollection(owner);
56
+ const target = normalizePosition(position, items.length);
57
+ const blob = await this.#findBlobOrFail(attachmentId);
58
+ await this.#shiftCollection(items, target, 1);
59
+ return this.#createLink(owner, blob, { position: target });
60
+ }
61
+ createVariant(original, key, attachment) {
62
+ return this.#createBlob(attachment, { parentId: original.id, variantKey: key });
63
+ }
64
+ async releaseOwner(original) {
65
+ original.ownerKey = null;
66
+ await original.save();
67
+ }
68
+ async restoreOwner(original) {
69
+ original.ownerKey = createAttachmentOwnerKey({
70
+ type: original.attachableType,
71
+ id: original.attachableId,
72
+ field: original.field,
73
+ });
74
+ await original.save();
75
+ }
76
+ findOriginal(owner) {
77
+ return this.#linkQuery()
78
+ .where('attachable_type', owner.type)
79
+ .where('attachable_id', owner.id)
80
+ .where('field', owner.field)
81
+ .whereNotNull('owner_key')
82
+ .first();
83
+ }
84
+ listCollection(owner) {
85
+ return this.#linkQuery()
86
+ .where('attachable_type', owner.type)
87
+ .where('attachable_id', owner.id)
88
+ .where('field', owner.field)
89
+ .whereNull('owner_key')
90
+ .orderBy('position', 'asc');
91
+ }
92
+ findCollectionItem(owner, id) {
93
+ return this.#linkQuery()
94
+ .where('id', id)
95
+ .where('attachable_type', owner.type)
96
+ .where('attachable_id', owner.id)
97
+ .where('field', owner.field)
98
+ .whereNull('owner_key')
99
+ .first();
100
+ }
101
+ async removeCollectionItem(owner, item) {
102
+ const removed = await this.remove(item);
103
+ await this.#normalizeCollection(owner);
104
+ return removed;
105
+ }
106
+ async moveCollectionItem(owner, id, position) {
107
+ const items = await this.listCollection(owner);
108
+ const source = items.findIndex((item) => item.id === id);
109
+ if (source === -1) {
110
+ throw new AttachmentValidationError(`Attachment link "${id}" does not belong to this collection`);
111
+ }
112
+ const target = normalizePosition(position, items.length - 1);
113
+ if (source === target) {
114
+ return items;
115
+ }
116
+ const [item] = items.splice(source, 1);
117
+ items.splice(target, 0, item);
118
+ await this.#reorderCollection(items);
119
+ return items;
120
+ }
121
+ findById(id) {
122
+ return this.#blobQuery().where('id', id).first();
123
+ }
124
+ async findByOwner(owner) {
125
+ const original = await this.findOriginal(owner);
126
+ if (!original) {
127
+ return null;
128
+ }
129
+ return {
130
+ original,
131
+ variants: await this.listVariants(original.attachmentId),
132
+ };
133
+ }
134
+ listVariants(originalId) {
135
+ return this.#blobQuery().where('parent_id', originalId);
136
+ }
137
+ /**
138
+ * Deletes a link and returns blobs that became unreferenced and were removed.
139
+ */
140
+ async remove(link) {
141
+ const attachment = link.attachment ?? (await this.findById(link.attachmentId));
142
+ await link.delete();
143
+ if (!attachment || (await this.#linkQuery().where('attachment_id', attachment.id).first())) {
144
+ return [];
145
+ }
146
+ const variants = await this.listVariants(attachment.id);
147
+ await attachment.delete();
148
+ return [attachment, ...variants];
149
+ }
150
+ listOwnerLinks(owner) {
151
+ return this.#linkQuery()
152
+ .where('attachable_type', owner.type)
153
+ .where('attachable_id', owner.id);
154
+ }
155
+ async #createBlob(attachment, options = {}) {
156
+ const blob = await this.#blobModel.create({
157
+ ...attachment,
158
+ parentId: options.parentId ?? null,
159
+ variantKey: options.variantKey ?? null,
160
+ blurhash: attachment.blurhash ?? null,
161
+ metadata: attachment.metadata ?? null,
162
+ }, this.#client ? { client: this.#client } : undefined);
163
+ markAttachmentPersisted(attachment);
164
+ return blob;
165
+ }
166
+ async #findBlobOrFail(id) {
167
+ const blob = await this.findById(id);
168
+ if (!blob) {
169
+ throw new AttachmentNotFoundError(id);
170
+ }
171
+ return blob;
172
+ }
173
+ async #createLink(owner, attachment, options = {}) {
174
+ const link = await this.#linkModel.create({
175
+ id: this.#createLinkId(),
176
+ attachableType: owner.type,
177
+ attachableId: owner.id,
178
+ field: owner.field,
179
+ ownerKey: options.ownerKey ?? null,
180
+ position: options.position ?? null,
181
+ attachmentId: attachment.id,
182
+ }, this.#client ? { client: this.#client } : undefined);
183
+ return this.#linkQuery().where('id', link.id).firstOrFail();
184
+ }
185
+ async #normalizeCollection(owner) {
186
+ await this.#reorderCollection(await this.listCollection(owner));
187
+ }
188
+ #blobQuery() {
189
+ return this.#blobModel.query(this.#client ? { client: this.#client } : undefined);
190
+ }
191
+ #linkQuery() {
192
+ return this.#linkModel
193
+ .query(this.#client ? { client: this.#client } : undefined)
194
+ .preload('attachment');
195
+ }
196
+ async #shiftCollection(items, from, amount) {
197
+ for (const item of [...items].reverse()) {
198
+ if ((item.position ?? 0) < from) {
199
+ continue;
200
+ }
201
+ item.position = (item.position ?? 0) + amount;
202
+ await item.save();
203
+ }
204
+ }
205
+ async #reorderCollection(items) {
206
+ const offset = items.length + 1;
207
+ for (const item of items) {
208
+ item.position = (item.position ?? 0) + offset;
209
+ await item.save();
210
+ }
211
+ for (const [position, item] of items.entries()) {
212
+ item.position = position;
213
+ await item.save();
214
+ }
215
+ }
216
+ }
217
+ function normalizePosition(position, maximum) {
218
+ if (position === undefined) {
219
+ return maximum;
220
+ }
221
+ if (!Number.isSafeInteger(position) || position < 0) {
222
+ throw new AttachmentValidationError('Attachment collection positions must be non-negative integers');
223
+ }
224
+ return Math.min(position, maximum);
225
+ }
226
+ //# sourceMappingURL=lucid_attachment_store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lucid_attachment_store.js","sourceRoot":"","sources":["../../../../../src/integrations/lucid/persistence/lucid_attachment_store.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAKxC,OAAO,EAAE,uBAAuB,EAAE,MAAM,mCAAmC,CAAA;AAC3E,OAAO,EAAE,wBAAwB,EAAwB,MAAM,kCAAkC,CAAA;AACjG,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAA;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAC/D,OAAO,EAAE,uBAAuB,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAA;AAavF;;GAEG;AACH,MAAM,OAAO,oBAAoB;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