@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
@@ -13,6 +13,7 @@ export type LegacyAttachment = {
13
13
  disk?: string;
14
14
  path?: string;
15
15
  meta?: Record<string, unknown>;
16
+ blurhash?: string;
16
17
  variants?: LegacyVariant[];
17
18
  };
18
19
  export type LegacyVariant = {
@@ -24,16 +25,13 @@ export type LegacyVariant = {
24
25
  disk?: string;
25
26
  path?: string;
26
27
  meta?: Record<string, unknown>;
28
+ blurhash?: string;
27
29
  };
28
- import { type AttachmentOwner } from "./attachment_owner.js";
29
- import type { Attachment } from "../../core/attachment.js";
30
- export type { AttachmentOwner } from "./attachment_owner.js";
31
- export type MigratedAttachmentRow = {
30
+ import { type AttachmentOwner } from "../../relations/attachment_owner.js";
31
+ import type { Attachment } from "../../../../core/attachment.js";
32
+ export type { AttachmentOwner } from "../../relations/attachment_owner.js";
33
+ export type MigratedAttachmentBlob = {
32
34
  id: string;
33
- attachableType: string;
34
- attachableId: string;
35
- field: string;
36
- ownerKey: string | null;
37
35
  parentId: string | null;
38
36
  variantKey: string | null;
39
37
  disk: string;
@@ -43,8 +41,22 @@ export type MigratedAttachmentRow = {
43
41
  mimeType: string;
44
42
  extname: string;
45
43
  size: number;
44
+ blurhash: string | null;
46
45
  metadata: Record<string, unknown> | null;
47
46
  };
47
+ export type MigratedAttachmentLink = {
48
+ id: string;
49
+ attachableType: string;
50
+ attachableId: string;
51
+ field: string;
52
+ ownerKey: string | null;
53
+ position: number | null;
54
+ attachmentId: string;
55
+ };
56
+ export type MigratedAttachmentRows = {
57
+ blobs: MigratedAttachmentBlob[];
58
+ links: MigratedAttachmentLink[];
59
+ };
48
60
  export type MigrateLegacyAttachmentOptions = {
49
61
  owner: AttachmentOwner;
50
62
  defaultDisk: string;
@@ -52,10 +64,10 @@ export type MigrateLegacyAttachmentOptions = {
52
64
  };
53
65
  export type MigrateLegacyAttachmentColumnOptions = Omit<MigrateLegacyAttachmentOptions, "owner">;
54
66
  /**
55
- * Converts one v5 JSON attachment document into rows for the polymorphic table.
67
+ * Converts one v5 JSON attachment document into blob and polymorphic-link rows.
56
68
  * Callers can run it from an Ace command, another ORM migration, or a one-off script.
57
69
  */
58
- export declare function migrateLegacyAttachment(value: LegacyAttachment | string, options: MigrateLegacyAttachmentOptions): MigratedAttachmentRow[];
70
+ export declare function migrateLegacyAttachment(value: LegacyAttachment | string, options: MigrateLegacyAttachmentOptions): MigratedAttachmentRows;
59
71
  /**
60
72
  * Converts one v5 JSON value for a retained single attachment column. Legacy
61
73
  * variants require the polymorphic table and therefore cannot be kept here.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migrate_legacy_attachment.d.ts","sourceRoot":"","sources":["../../../../../../src/integrations/lucid/migrations/legacy/migrate_legacy_attachment.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,aAAa,EAAE,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,OAAO,EAEL,KAAK,eAAe,EACrB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gCAAg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AG,MAAM,EAChC,OAAO,EAAE,8BAA8B,GACtC,sBAAsB,CAwCxB;AAED;;;GAGG;AACH,wBAAgB,6BAA6B,CAC3C,KAAK,EAAE,gBAAgB,GAAG,MAAM,EAChC,OAAO,EAAE,oCAAoC,GAC5C,UAAU,CAwBZ"}
@@ -4,38 +4,48 @@
4
4
  * @license MIT
5
5
  * @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
6
6
  */
7
- import { createAttachmentOwnerKey, } from "./attachment_owner.js";
7
+ import { createAttachmentOwnerKey, } from "../../relations/attachment_owner.js";
8
+ import { AttachmentError } from "../../../../errors.js";
8
9
  /**
9
- * Converts one v5 JSON attachment document into rows for the polymorphic table.
10
+ * Converts one v5 JSON attachment document into blob and polymorphic-link rows.
10
11
  * Callers can run it from an Ace command, another ORM migration, or a one-off script.
11
12
  */
12
13
  export function migrateLegacyAttachment(value, options) {
13
14
  const attachment = typeof value === "string" ? parseLegacyAttachment(value) : value;
14
15
  const id = options.createId();
15
16
  const originalName = attachment.originalName ?? attachment.name;
16
- const original = toRow({
17
+ const original = toBlob({
17
18
  id,
18
19
  attachment,
19
- owner: options.owner,
20
- ownerKey: createAttachmentOwnerKey(options.owner),
21
20
  parentId: null,
22
21
  variantKey: null,
23
22
  originalName,
24
23
  defaultDisk: options.defaultDisk,
25
24
  });
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
- ];
25
+ return {
26
+ blobs: [
27
+ original,
28
+ ...(attachment.variants ?? []).map((variant) => toBlob({
29
+ id: options.createId(),
30
+ attachment: variant,
31
+ parentId: id,
32
+ variantKey: variant.key,
33
+ originalName,
34
+ defaultDisk: options.defaultDisk,
35
+ })),
36
+ ],
37
+ links: [
38
+ {
39
+ id: options.createId(),
40
+ attachableType: options.owner.type,
41
+ attachableId: options.owner.id,
42
+ field: options.owner.field,
43
+ ownerKey: createAttachmentOwnerKey(options.owner),
44
+ position: null,
45
+ attachmentId: id,
46
+ },
47
+ ],
48
+ };
39
49
  }
40
50
  /**
41
51
  * Converts one v5 JSON value for a retained single attachment column. Legacy
@@ -44,7 +54,7 @@ export function migrateLegacyAttachment(value, options) {
44
54
  export function migrateLegacyAttachmentColumn(value, options) {
45
55
  const attachment = typeof value === "string" ? parseLegacyAttachment(value) : value;
46
56
  if (attachment.variants?.length) {
47
- throw new Error("Legacy attachments with variants must migrate to the polymorphic table");
57
+ throw new AttachmentError("Legacy attachments with variants must migrate to the polymorphic table", { code: "E_LEGACY_VARIANTS_REQUIRE_RELATIONS", status: 422 });
48
58
  }
49
59
  const originalName = attachment.originalName ?? attachment.name;
50
60
  return {
@@ -64,16 +74,15 @@ function parseLegacyAttachment(value) {
64
74
  return JSON.parse(value);
65
75
  }
66
76
  catch {
67
- throw new Error("Legacy attachment value must be valid JSON");
77
+ throw new AttachmentError("Legacy attachment value must be valid JSON", {
78
+ code: "E_INVALID_LEGACY_ATTACHMENT",
79
+ status: 400,
80
+ });
68
81
  }
69
82
  }
70
- function toRow({ id, attachment, owner, ownerKey, parentId, variantKey, originalName, defaultDisk, }) {
83
+ function toBlob({ id, attachment, parentId, variantKey, originalName, defaultDisk, }) {
71
84
  return {
72
85
  id,
73
- attachableType: owner.type,
74
- attachableId: owner.id,
75
- field: owner.field,
76
- ownerKey,
77
86
  parentId,
78
87
  variantKey,
79
88
  disk: attachment.disk ?? defaultDisk,
@@ -83,6 +92,7 @@ function toRow({ id, attachment, owner, ownerKey, parentId, variantKey, original
83
92
  mimeType: attachment.mimeType,
84
93
  extname: attachment.extname,
85
94
  size: attachment.size,
95
+ blurhash: attachment.blurhash ?? null,
86
96
  metadata: attachment.meta ?? null,
87
97
  };
88
98
  }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migrate_legacy_attachment.js","sourceRoot":"","sources":["../../../../../../src/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MAAM,IAAI,eAAe,CAAC,4CAA4C,EAAE;YACtE,IAAI,EAAE,6BAA6B;YACnC,MAAM,EAAE,GAAG;SACZ,CAAC,CAAC;IACL,CAAC;AACH,CAAC;AAED,SAAS,MAAM,CAAC,EACd,EAAE,EACF,UAAU,EACV,QAAQ,EACR,UAAU,EACV,YAAY,EACZ,WAAW,GAQZ;IACC,OAAO;QACL,EAAE;QACF,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,QAAQ,IAAI,IAAI;QACrC,QAAQ,EAAE,UAAU,CAAC,IAAI,IAAI,IAAI;KAClC,CAAC;AACJ,CAAC"}
@@ -4,14 +4,14 @@
4
4
  * @license MIT
5
5
  * @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
6
6
  */
7
- import type { AttachmentOwner } from './attachment_owner.js';
8
- import { type LegacyAttachment, type MigratedAttachmentRow } from './migrate_legacy_attachment.js';
7
+ import type { AttachmentOwner } from '../../relations/attachment_owner.js';
8
+ import { type LegacyAttachment, type MigratedAttachmentRows } from './migrate_legacy_attachment.js';
9
9
  export type LegacyAttachmentMigrationRecord = {
10
10
  owner: AttachmentOwner;
11
11
  value: LegacyAttachment | string | null | undefined;
12
12
  };
13
13
  export type LegacyAttachmentMigrationWriter = {
14
- insert(rows: readonly MigratedAttachmentRow[]): Promise<void>;
14
+ insert(rows: MigratedAttachmentRows): Promise<void>;
15
15
  };
16
16
  export type MigrateLegacyAttachmentRecordsOptions = {
17
17
  records: Iterable<LegacyAttachmentMigrationRecord> | AsyncIterable<LegacyAttachmentMigrationRecord>;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migrate_legacy_attachment_records.d.ts","sourceRoot":"","sources":["../../../../../../src/integrations/lucid/migrations/legacy/migrate_legacy_attachment_records.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAA;AAE1E,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,sBAAsB,EAC5B,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,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CACpD,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,CA4C1C"}
@@ -4,6 +4,7 @@
4
4
  * @license MIT
5
5
  * @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
6
6
  */
7
+ import { AttachmentError } from '../../../../errors.js';
7
8
  import { migrateLegacyAttachment, } from './migrate_legacy_attachment.js';
8
9
  /**
9
10
  * Migrates a stream of legacy v5 JSON values into attachment-table rows.
@@ -13,14 +14,16 @@ import { migrateLegacyAttachment, } from './migrate_legacy_attachment.js';
13
14
  export async function migrateLegacyAttachmentRecords(options) {
14
15
  const batchSize = options.batchSize ?? 100;
15
16
  if (!Number.isSafeInteger(batchSize) || batchSize < 1) {
16
- throw new Error('Legacy attachment migration batchSize must be a positive integer');
17
+ throw new AttachmentError('Legacy attachment migration batchSize must be a positive integer', {
18
+ code: 'E_INVALID_LEGACY_MIGRATION_BATCH_SIZE',
19
+ });
17
20
  }
18
21
  const result = {
19
22
  attachments: 0,
20
23
  variants: 0,
21
24
  skipped: 0,
22
25
  };
23
- let batch = [];
26
+ let batch = { blobs: [], links: [] };
24
27
  for await (const record of options.records) {
25
28
  if (record.value === null || record.value === undefined) {
26
29
  result.skipped += 1;
@@ -32,14 +35,15 @@ export async function migrateLegacyAttachmentRecords(options) {
32
35
  createId: options.createId,
33
36
  });
34
37
  result.attachments += 1;
35
- result.variants += rows.length - 1;
36
- batch.push(...rows);
37
- if (batch.length >= batchSize) {
38
+ result.variants += rows.blobs.length - 1;
39
+ batch.blobs.push(...rows.blobs);
40
+ batch.links.push(...rows.links);
41
+ if (batch.blobs.length >= batchSize) {
38
42
  await options.writer.insert(batch);
39
- batch = [];
43
+ batch = { blobs: [], links: [] };
40
44
  }
41
45
  }
42
- if (batch.length > 0) {
46
+ if (batch.blobs.length > 0) {
43
47
  await options.writer.insert(batch);
44
48
  }
45
49
  return result;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migrate_legacy_attachment_records.js","sourceRoot":"","sources":["../../../../../../src/integrations/lucid/migrations/legacy/migrate_legacy_attachment_records.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,EACL,uBAAuB,GAGxB,MAAM,gCAAgC,CAAA;AAyBvC;;;;GAIG;AACH,MAAM,CAAC,KAAK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,EAAE,CAAC;YACpC,MAAM,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;YAClC,KAAK,GAAG,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,CAAA;QAClC,CAAC;IACH,CAAC;IAED,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC3B,MAAM,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;IACpC,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * @jrmc/adonis-attachment
3
+ *
4
+ * @license MIT
5
+ * @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
6
+ */
7
+ import { BaseModel } from '@adonisjs/lucid/orm';
8
+ import type { BelongsTo } from '@adonisjs/lucid/types/relations';
9
+ import type { DateTime } from 'luxon';
10
+ import type { Attachment } from '../../../core/attachment.js';
11
+ import { AttachmentModel } from './attachment_model.js';
12
+ /**
13
+ * Polymorphic relation between an application record and an attachment blob.
14
+ */
15
+ export declare class AttachmentLinkModel extends BaseModel {
16
+ static table: string;
17
+ static selfAssignPrimaryKey: boolean;
18
+ id: string;
19
+ attachableType: string;
20
+ attachableId: string;
21
+ field: string;
22
+ ownerKey: string | null;
23
+ position: number | null;
24
+ attachmentId: string;
25
+ attachment: BelongsTo<typeof AttachmentModel>;
26
+ createdAt: DateTime;
27
+ updatedAt: DateTime;
28
+ toAttachment(): Attachment;
29
+ }
30
+ //# sourceMappingURL=attachment_link_model.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attachment_link_model.d.ts","sourceRoot":"","sources":["../../../../../src/integrations/lucid/models/attachment_link_model.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,SAAS,EAAqB,MAAM,qBAAqB,CAAA;AAClE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAA;AAChE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAErC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAA;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAGvD;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,SAAS;IAChD,MAAM,CAAC,KAAK,SAAqB;IACjC,MAAM,CAAC,oBAAoB,UAAO;IAG1B,EAAE,EAAE,MAAM,CAAA;IAGV,cAAc,EAAE,MAAM,CAAA;IAGtB,YAAY,EAAE,MAAM,CAAA;IAGpB,KAAK,EAAE,MAAM,CAAA;IAGb,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;IAGvB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;IAGvB,YAAY,EAAE,MAAM,CAAA;IAGpB,UAAU,EAAE,SAAS,CAAC,OAAO,eAAe,CAAC,CAAA;IAG7C,SAAS,EAAE,QAAQ,CAAA;IAGnB,SAAS,EAAE,QAAQ,CAAA;IAE3B,YAAY,IAAI,UAAU;CAS3B"}
@@ -0,0 +1,59 @@
1
+ /**
2
+ * @jrmc/adonis-attachment
3
+ *
4
+ * @license MIT
5
+ * @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
6
+ */
7
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
8
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
9
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
10
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
11
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
12
+ };
13
+ import { BaseModel, belongsTo, column } from '@adonisjs/lucid/orm';
14
+ import { AttachmentModel } from './attachment_model.js';
15
+ import { AttachmentConfigurationError } from '../../../errors.js';
16
+ /**
17
+ * Polymorphic relation between an application record and an attachment blob.
18
+ */
19
+ export class AttachmentLinkModel extends BaseModel {
20
+ static table = 'attachment_links';
21
+ static selfAssignPrimaryKey = true;
22
+ toAttachment() {
23
+ if (!this.attachment) {
24
+ throw new AttachmentConfigurationError('Attachment links must load their attachment blob before they can be read');
25
+ }
26
+ return this.attachment.toAttachment();
27
+ }
28
+ }
29
+ __decorate([
30
+ column({ isPrimary: true })
31
+ ], AttachmentLinkModel.prototype, "id", void 0);
32
+ __decorate([
33
+ column()
34
+ ], AttachmentLinkModel.prototype, "attachableType", void 0);
35
+ __decorate([
36
+ column()
37
+ ], AttachmentLinkModel.prototype, "attachableId", void 0);
38
+ __decorate([
39
+ column()
40
+ ], AttachmentLinkModel.prototype, "field", void 0);
41
+ __decorate([
42
+ column({ serializeAs: null })
43
+ ], AttachmentLinkModel.prototype, "ownerKey", void 0);
44
+ __decorate([
45
+ column()
46
+ ], AttachmentLinkModel.prototype, "position", void 0);
47
+ __decorate([
48
+ column()
49
+ ], AttachmentLinkModel.prototype, "attachmentId", void 0);
50
+ __decorate([
51
+ belongsTo(() => AttachmentModel, { foreignKey: 'attachmentId' })
52
+ ], AttachmentLinkModel.prototype, "attachment", void 0);
53
+ __decorate([
54
+ column.dateTime({ autoCreate: true })
55
+ ], AttachmentLinkModel.prototype, "createdAt", void 0);
56
+ __decorate([
57
+ column.dateTime({ autoCreate: true, autoUpdate: true })
58
+ ], AttachmentLinkModel.prototype, "updatedAt", void 0);
59
+ //# sourceMappingURL=attachment_link_model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attachment_link_model.js","sourceRoot":"","sources":["../../../../../src/integrations/lucid/models/attachment_link_model.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;;;;;;;AAEH,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAKlE,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,EAAE,4BAA4B,EAAE,MAAM,oBAAoB,CAAA;AAEjE;;GAEG;AACH,MAAM,OAAO,mBAAoB,SAAQ,SAAS;IAChD,MAAM,CAAC,KAAK,GAAG,kBAAkB,CAAA;IACjC,MAAM,CAAC,oBAAoB,GAAG,IAAI,CAAA;IAgClC,YAAY;QACV,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;YACrB,MAAM,IAAI,4BAA4B,CACpC,0EAA0E,CAC3E,CAAA;QACH,CAAC;QAED,OAAO,IAAI,CAAC,UAAU,CAAC,YAAY,EAAE,CAAA;IACvC,CAAC;;AArCO;IADP,MAAM,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;+CACV;AAGV;IADP,MAAM,EAAE;2DACqB;AAGtB;IADP,MAAM,EAAE;yDACmB;AAGpB;IADP,MAAM,EAAE;kDACY;AAGb;IADP,MAAM,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;qDACC;AAGvB;IADP,MAAM,EAAE;qDACsB;AAGvB;IADP,MAAM,EAAE;yDACmB;AAGpB;IADP,SAAS,CAAC,GAAG,EAAE,CAAC,eAAe,EAAE,EAAE,UAAU,EAAE,cAAc,EAAE,CAAC;uDACZ;AAG7C;IADP,MAAM,CAAC,QAAQ,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;sDACX;AAGnB;IADP,MAAM,CAAC,QAAQ,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;sDAC7B"}
@@ -6,20 +6,16 @@
6
6
  */
7
7
  import { BaseModel } from '@adonisjs/lucid/orm';
8
8
  import type { DateTime } from 'luxon';
9
- import type { Attachment } from '../../core/attachment.js';
9
+ import type { Attachment } from '../../../core/attachment.js';
10
+ import type { AttachmentMetadata } from '../../../media/media_metadata.js';
10
11
  /**
11
- * Default Lucid model for the polymorphic attachments table.
12
+ * Default Lucid model for a stored attachment blob.
12
13
  * Applications may extend this model to add their own scopes and serialization rules.
13
14
  */
14
15
  export declare class AttachmentModel extends BaseModel {
15
16
  static table: string;
16
17
  static selfAssignPrimaryKey: boolean;
17
18
  id: string;
18
- attachableType: string;
19
- attachableId: string;
20
- field: string;
21
- ownerKey: string | null;
22
- position: number | null;
23
19
  parentId: string | null;
24
20
  variantKey: string | null;
25
21
  disk: string;
@@ -29,7 +25,8 @@ export declare class AttachmentModel extends BaseModel {
29
25
  mimeType: string;
30
26
  extname: string;
31
27
  size: number;
32
- metadata: Record<string, unknown> | null;
28
+ blurhash: string | null;
29
+ metadata: AttachmentMetadata | null;
33
30
  createdAt: DateTime;
34
31
  updatedAt: DateTime;
35
32
  toAttachment(): Attachment;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attachment_model.d.ts","sourceRoot":"","sources":["../../../../../src/integrations/lucid/models/attachment_model.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,SAAS,EAAU,MAAM,qBAAqB,CAAA;AACvD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAErC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAA;AAC7D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAA;AAE1E;;;GAGG;AACH,qBAAa,eAAgB,SAAQ,SAAS;IAC5C,MAAM,CAAC,KAAK,SAAgB;IAC5B,MAAM,CAAC,oBAAoB,UAAO;IAG1B,EAAE,EAAE,MAAM,CAAA;IAGV,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;IAGvB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;IAGzB,IAAI,EAAE,MAAM,CAAA;IAGZ,IAAI,EAAE,MAAM,CAAA;IAGZ,IAAI,EAAE,MAAM,CAAA;IAGZ,YAAY,EAAE,MAAM,CAAA;IAGpB,QAAQ,EAAE,MAAM,CAAA;IAGhB,OAAO,EAAE,MAAM,CAAA;IAGf,IAAI,EAAE,MAAM,CAAA;IAGZ,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;IAcvB,QAAQ,EAAE,kBAAkB,GAAG,IAAI,CAAA;IAGnC,SAAS,EAAE,QAAQ,CAAA;IAGnB,SAAS,EAAE,QAAQ,CAAA;IAE3B,YAAY,IAAI,UAAU;CAc3B"}
@@ -12,7 +12,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
12
12
  };
13
13
  import { BaseModel, column } from '@adonisjs/lucid/orm';
14
14
  /**
15
- * Default Lucid model for the polymorphic attachments table.
15
+ * Default Lucid model for a stored attachment blob.
16
16
  * Applications may extend this model to add their own scopes and serialization rules.
17
17
  */
18
18
  export class AttachmentModel extends BaseModel {
@@ -28,6 +28,7 @@ export class AttachmentModel extends BaseModel {
28
28
  mimeType: this.mimeType,
29
29
  extname: this.extname,
30
30
  size: this.size,
31
+ ...(this.blurhash ? { blurhash: this.blurhash } : {}),
31
32
  ...(this.metadata ? { metadata: this.metadata } : {}),
32
33
  };
33
34
  }
@@ -35,21 +36,6 @@ export class AttachmentModel extends BaseModel {
35
36
  __decorate([
36
37
  column({ isPrimary: true })
37
38
  ], AttachmentModel.prototype, "id", void 0);
38
- __decorate([
39
- column()
40
- ], AttachmentModel.prototype, "attachableType", void 0);
41
- __decorate([
42
- column()
43
- ], AttachmentModel.prototype, "attachableId", void 0);
44
- __decorate([
45
- column()
46
- ], AttachmentModel.prototype, "field", void 0);
47
- __decorate([
48
- column({ serializeAs: null })
49
- ], AttachmentModel.prototype, "ownerKey", void 0);
50
- __decorate([
51
- column()
52
- ], AttachmentModel.prototype, "position", void 0);
53
39
  __decorate([
54
40
  column()
55
41
  ], AttachmentModel.prototype, "parentId", void 0);
@@ -77,6 +63,9 @@ __decorate([
77
63
  __decorate([
78
64
  column()
79
65
  ], AttachmentModel.prototype, "size", void 0);
66
+ __decorate([
67
+ column()
68
+ ], AttachmentModel.prototype, "blurhash", void 0);
80
69
  __decorate([
81
70
  column({
82
71
  prepare(value) {
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attachment_model.js","sourceRoot":"","sources":["../../../../../src/integrations/lucid/models/attachment_model.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;;;;;;;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAMvD;;;GAGG;AACH,MAAM,OAAO,eAAgB,SAAQ,SAAS;IAC5C,MAAM,CAAC,KAAK,GAAG,aAAa,CAAA;IAC5B,MAAM,CAAC,oBAAoB,GAAG,IAAI,CAAA;IAuDlC,YAAY;QACV,OAAO;YACL,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACrD,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SACtD,CAAA;IACH,CAAC;;AAjEO;IADP,MAAM,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;2CACV;AAGV;IADP,MAAM,EAAE;iDACsB;AAGvB;IADP,MAAM,EAAE;mDACwB;AAGzB;IADP,MAAM,EAAE;6CACW;AAGZ;IADP,MAAM,EAAE;6CACW;AAGZ;IADP,MAAM,EAAE;6CACW;AAGZ;IADP,MAAM,EAAE;qDACmB;AAGpB;IADP,MAAM,EAAE;iDACe;AAGhB;IADP,MAAM,EAAE;gDACc;AAGf;IADP,MAAM,EAAE;6CACW;AAGZ;IADP,MAAM,EAAE;iDACsB;AAcvB;IAZP,MAAM,CAAC;QACN,OAAO,CAAC,KAAgC;YACtC,OAAO,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAA;QACtD,CAAC;QACD,OAAO,CAAC,KAAc;YACpB,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;gBACvE,OAAO,KAAkC,CAAA;YAC3C,CAAC;YAED,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAuB,CAAA;QAChD,CAAC;KACF,CAAC;iDACyC;AAGnC;IADP,MAAM,CAAC,QAAQ,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;kDACX;AAGnB;IADP,MAAM,CAAC,QAAQ,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;kDAC7B"}
@@ -4,27 +4,31 @@
4
4
  * @license MIT
5
5
  * @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
6
6
  */
7
- import { type AttachmentDraft, type CreateAttachmentInput } from '../../core/attachment.js';
8
- import type { AttachmentService } from '../../core/attachment_service.js';
9
- import type { AttachmentPersistenceOptions } from '../../core/attachment_options.js';
10
- import type { AttachmentOwner } from './attachment_owner.js';
11
- import { AttachmentModel } from './attachment_model.js';
7
+ import { type AttachmentDraft, type CreateAttachmentInput } from '../../../core/attachment.js';
8
+ import type { AttachmentService } from '../../../core/attachment_service.js';
9
+ import type { AttachmentPersistenceOptions } from '../../../core/attachment_options.js';
10
+ import type { AttachmentOwner } from '../relations/attachment_owner.js';
11
+ import { AttachmentLinkModel } from '../models/attachment_link_model.js';
12
+ import { AttachmentModel } from '../models/attachment_model.js';
12
13
  import { LucidAttachmentStore } from './lucid_attachment_store.js';
13
- export type AttachmentFileService = Pick<AttachmentService, 'create' | 'remove'> & Partial<Pick<AttachmentService, 'createDraft'>>;
14
- export type LucidAttachmentPersistence = Pick<LucidAttachmentStore, 'createOriginal' | 'findOriginal' | 'listVariants' | 'releaseOwner' | 'restoreOwner' | 'remove'> & Partial<Pick<LucidAttachmentStore, 'createCollectionItem' | 'findCollectionItem' | 'listCollection' | 'moveCollectionItem' | 'removeCollectionItem'>>;
14
+ export type AttachmentFileService = Pick<AttachmentService, 'create' | 'remove'> & Partial<Pick<AttachmentService, 'createDraft' | 'getVariantKeys' | 'getVariantMetadataEnabled' | 'getMetadataMode' | 'scheduleMetadataExtraction' | 'scheduleVariantGeneration'>>;
15
+ export type LucidAttachmentPersistence = Pick<LucidAttachmentStore, 'createOriginal' | 'findOriginal' | 'listVariants' | 'releaseOwner' | 'restoreOwner' | 'remove' | 'listOwnerLinks'> & Partial<Pick<LucidAttachmentStore, 'createCollectionItem' | 'findCollectionItem' | 'listCollection' | 'moveCollectionItem' | 'removeCollectionItem' | 'createOriginalLink' | 'createCollectionLink'>>;
15
16
  export declare class LucidAttachmentLifecycleService {
16
17
  #private;
17
18
  constructor(attachments: AttachmentFileService, store: LucidAttachmentPersistence);
18
- get(owner: AttachmentOwner): Promise<AttachmentModel | null>;
19
- attach(owner: AttachmentOwner, input: CreateAttachmentInput | AttachmentDraft, options?: AttachmentPersistenceOptions<any>): Promise<AttachmentModel>;
20
- replace(owner: AttachmentOwner, input: CreateAttachmentInput | AttachmentDraft, options?: AttachmentPersistenceOptions<any>): Promise<AttachmentModel>;
19
+ get(owner: AttachmentOwner): Promise<AttachmentLinkModel | null>;
20
+ attach(owner: AttachmentOwner, input: CreateAttachmentInput | AttachmentDraft, options?: AttachmentPersistenceOptions<any>): Promise<AttachmentLinkModel>;
21
+ replace(owner: AttachmentOwner, input: CreateAttachmentInput | AttachmentDraft, options?: AttachmentPersistenceOptions<any>): Promise<AttachmentLinkModel>;
21
22
  detach(owner: AttachmentOwner): Promise<void>;
22
23
  listVariants(owner: AttachmentOwner): Promise<AttachmentModel[]>;
23
- add(owner: AttachmentOwner, input: CreateAttachmentInput | AttachmentDraft, position?: number, options?: AttachmentPersistenceOptions<any>): Promise<AttachmentModel>;
24
- listCollection(owner: AttachmentOwner): Promise<AttachmentModel[]>;
24
+ purgeOwner(owner: AttachmentOwner): Promise<void>;
25
+ add(owner: AttachmentOwner, input: CreateAttachmentInput | AttachmentDraft, position?: number, options?: AttachmentPersistenceOptions<any>): Promise<AttachmentLinkModel>;
26
+ attachExisting(owner: AttachmentOwner, attachmentId: string): Promise<AttachmentLinkModel>;
27
+ addExisting(owner: AttachmentOwner, attachmentId: string, position?: number): Promise<AttachmentLinkModel>;
28
+ listCollection(owner: AttachmentOwner): Promise<AttachmentLinkModel[]>;
25
29
  removeCollectionItem(owner: AttachmentOwner, id: string): Promise<boolean>;
26
30
  clearCollection(owner: AttachmentOwner): Promise<void>;
27
- replaceCollection(owner: AttachmentOwner, inputs: readonly (CreateAttachmentInput | AttachmentDraft)[], options?: AttachmentPersistenceOptions<any>): Promise<AttachmentModel[]>;
28
- moveCollectionItem(owner: AttachmentOwner, id: string, position: number): Promise<AttachmentModel[]>;
31
+ replaceCollection(owner: AttachmentOwner, inputs: readonly (CreateAttachmentInput | AttachmentDraft)[], options?: AttachmentPersistenceOptions<any>): Promise<AttachmentLinkModel[]>;
32
+ moveCollectionItem(owner: AttachmentOwner, id: string, position: number): Promise<AttachmentLinkModel[]>;
29
33
  }
30
34
  //# 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/persistence/lucid_attachment_lifecycle_service.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAGL,KAAK,eAAe,EACpB,KAAK,qBAAqB,EAC3B,MAAM,6BAA6B,CAAA;AACpC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAA;AAC5E,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