@jrmc/adonis-attachment 5.2.1 → 6.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -81
- package/build/bin/test.d.ts +2 -0
- package/build/bin/test.d.ts.map +1 -0
- package/build/bin/test.js +9 -0
- package/build/bin/test.js.map +1 -0
- package/build/commands/commands.json +1 -1
- package/build/commands/make/attachment_v5_migration.d.ts +17 -0
- package/build/commands/make/attachment_v5_migration.d.ts.map +1 -0
- package/build/commands/make/attachment_v5_migration.js +26 -0
- package/build/commands/make/attachment_v5_migration.js.map +1 -0
- package/build/commands/make/{converter.d.ts → attachments_table.d.ts} +6 -4
- package/build/commands/make/attachments_table.d.ts.map +1 -0
- package/build/commands/make/attachments_table.js +30 -0
- package/build/commands/make/attachments_table.js.map +1 -0
- package/build/configure.d.ts.map +1 -1
- package/build/configure.js +2 -1
- package/build/configure.js.map +1 -0
- package/build/index.d.ts +23 -8
- package/build/index.d.ts.map +1 -1
- package/build/index.js +13 -7
- package/build/index.js.map +1 -0
- package/build/providers/attachment_provider.d.ts +0 -19
- package/build/providers/attachment_provider.d.ts.map +1 -1
- package/build/providers/attachment_provider.js +30 -26
- package/build/providers/attachment_provider.js.map +1 -0
- package/build/services/main.d.ts +3 -3
- package/build/services/main.d.ts.map +1 -1
- package/build/services/main.js +42 -5
- package/build/services/main.js.map +1 -0
- package/build/src/adapters/adonis_drive_storage.d.ts +33 -0
- package/build/src/adapters/adonis_drive_storage.d.ts.map +1 -0
- package/build/src/adapters/adonis_drive_storage.js +35 -0
- package/build/src/adapters/adonis_drive_storage.js.map +1 -0
- package/build/src/adapters/local_file_storage.d.ts +25 -0
- package/build/src/adapters/local_file_storage.d.ts.map +1 -0
- package/build/src/adapters/local_file_storage.js +54 -0
- package/build/src/adapters/local_file_storage.js.map +1 -0
- package/build/src/controllers/attachments_controller.d.ts +13 -2
- package/build/src/controllers/attachments_controller.d.ts.map +1 -1
- package/build/src/controllers/attachments_controller.js +20 -107
- package/build/src/controllers/attachments_controller.js.map +1 -0
- package/build/src/core/attachment.d.ts +35 -0
- package/build/src/core/attachment.d.ts.map +1 -0
- package/build/src/core/attachment.js +47 -0
- package/build/src/core/attachment.js.map +1 -0
- package/build/src/core/attachment_job_processor.d.ts +30 -0
- package/build/src/core/attachment_job_processor.d.ts.map +1 -0
- package/build/src/core/attachment_job_processor.js +47 -0
- package/build/src/core/attachment_job_processor.js.map +1 -0
- package/build/src/core/attachment_repository.d.ts +15 -0
- package/build/src/core/attachment_repository.d.ts.map +1 -0
- package/build/src/core/attachment_repository.js +8 -0
- package/build/src/core/attachment_repository.js.map +1 -0
- package/build/src/core/attachment_service.d.ts +28 -0
- package/build/src/core/attachment_service.d.ts.map +1 -0
- package/build/src/core/attachment_service.js +47 -0
- package/build/src/core/attachment_service.js.map +1 -0
- package/build/src/core/attachment_state.d.ts +11 -0
- package/build/src/core/attachment_state.d.ts.map +1 -0
- package/build/src/core/attachment_state.js +17 -0
- package/build/src/core/attachment_state.js.map +1 -0
- package/build/src/core/index.d.ts +13 -0
- package/build/src/core/index.d.ts.map +1 -0
- package/build/src/core/index.js +10 -0
- package/build/src/core/index.js.map +1 -0
- package/build/src/core/queue.d.ts +20 -0
- package/build/src/core/queue.d.ts.map +1 -0
- package/build/src/{types/event.js → core/queue.js} +1 -0
- package/build/src/core/queue.js.map +1 -0
- package/build/src/core/storage.d.ts +23 -0
- package/build/src/core/storage.d.ts.map +1 -0
- package/build/src/{types/config.js → core/storage.js} +1 -0
- package/build/src/core/storage.js.map +1 -0
- package/build/src/define_config.d.ts +35 -20
- package/build/src/define_config.d.ts.map +1 -1
- package/build/src/define_config.js +45 -24
- package/build/src/define_config.js.map +1 -0
- package/build/src/integrations/lucid/attachment_column.d.ts +11 -0
- package/build/src/integrations/lucid/attachment_column.d.ts.map +1 -0
- package/build/src/integrations/lucid/attachment_column.js +138 -0
- package/build/src/integrations/lucid/attachment_column.js.map +1 -0
- package/build/src/integrations/lucid/attachment_model.d.ts +36 -0
- package/build/src/integrations/lucid/attachment_model.d.ts.map +1 -0
- package/build/src/integrations/lucid/attachment_model.js +96 -0
- package/build/src/integrations/lucid/attachment_model.js.map +1 -0
- package/build/src/integrations/lucid/attachment_owner.d.ts +17 -0
- package/build/src/integrations/lucid/attachment_owner.d.ts.map +1 -0
- package/build/src/integrations/lucid/attachment_owner.js +15 -0
- package/build/src/integrations/lucid/attachment_owner.js.map +1 -0
- package/build/src/integrations/lucid/attachments_table_stub.d.ts +21 -0
- package/build/src/integrations/lucid/attachments_table_stub.d.ts.map +1 -0
- package/build/src/integrations/lucid/attachments_table_stub.js +26 -0
- package/build/src/integrations/lucid/attachments_table_stub.js.map +1 -0
- package/build/src/integrations/lucid/create_legacy_attachment_migration_script.d.ts +13 -0
- package/build/src/integrations/lucid/create_legacy_attachment_migration_script.d.ts.map +1 -0
- package/build/src/integrations/lucid/create_legacy_attachment_migration_script.js +20 -0
- package/build/src/integrations/lucid/create_legacy_attachment_migration_script.js.map +1 -0
- package/build/src/integrations/lucid/index.d.ts +19 -0
- package/build/src/integrations/lucid/index.d.ts.map +1 -0
- package/build/src/integrations/lucid/index.js +19 -0
- package/build/src/integrations/lucid/index.js.map +1 -0
- package/build/src/integrations/lucid/lucid_attachment_lifecycle_service.d.ts +21 -0
- package/build/src/integrations/lucid/lucid_attachment_lifecycle_service.d.ts.map +1 -0
- package/build/src/integrations/lucid/lucid_attachment_lifecycle_service.js +68 -0
- package/build/src/integrations/lucid/lucid_attachment_lifecycle_service.js.map +1 -0
- package/build/src/integrations/lucid/lucid_attachment_repository.d.ts +18 -0
- package/build/src/integrations/lucid/lucid_attachment_repository.d.ts.map +1 -0
- package/build/src/integrations/lucid/lucid_attachment_repository.js +21 -0
- package/build/src/integrations/lucid/lucid_attachment_repository.js.map +1 -0
- package/build/src/integrations/lucid/lucid_attachment_store.d.ts +27 -0
- package/build/src/integrations/lucid/lucid_attachment_store.d.ts.map +1 -0
- package/build/src/integrations/lucid/lucid_attachment_store.js +84 -0
- package/build/src/integrations/lucid/lucid_attachment_store.js.map +1 -0
- package/build/src/integrations/lucid/lucid_variant_generation_service.d.ts +24 -0
- package/build/src/integrations/lucid/lucid_variant_generation_service.d.ts.map +1 -0
- package/build/src/integrations/lucid/lucid_variant_generation_service.js +42 -0
- package/build/src/integrations/lucid/lucid_variant_generation_service.js.map +1 -0
- package/build/src/integrations/lucid/migrate_legacy_attachment.d.ts +57 -0
- package/build/src/integrations/lucid/migrate_legacy_attachment.d.ts.map +1 -0
- package/build/src/integrations/lucid/migrate_legacy_attachment.js +67 -0
- package/build/src/integrations/lucid/migrate_legacy_attachment.js.map +1 -0
- package/build/src/integrations/lucid/migrate_legacy_attachment_records.d.ts +34 -0
- package/build/src/integrations/lucid/migrate_legacy_attachment_records.d.ts.map +1 -0
- package/build/src/integrations/lucid/migrate_legacy_attachment_records.js +47 -0
- package/build/src/integrations/lucid/migrate_legacy_attachment_records.js.map +1 -0
- package/build/src/integrations/lucid/render_legacy_attachment_migration_script.d.ts +11 -0
- package/build/src/integrations/lucid/render_legacy_attachment_migration_script.d.ts.map +1 -0
- package/build/src/integrations/lucid/render_legacy_attachment_migration_script.js +41 -0
- package/build/src/integrations/lucid/render_legacy_attachment_migration_script.js.map +1 -0
- package/build/src/queues/adonis_queue.d.ts +27 -0
- package/build/src/queues/adonis_queue.d.ts.map +1 -0
- package/build/src/queues/adonis_queue.js +22 -0
- package/build/src/queues/adonis_queue.js.map +1 -0
- package/build/src/queues/memory_queue.d.ts +22 -0
- package/build/src/queues/memory_queue.d.ts.map +1 -0
- package/build/src/queues/memory_queue.js +67 -0
- package/build/src/queues/memory_queue.js.map +1 -0
- package/build/src/sources/attachment_manager.d.ts +51 -0
- package/build/src/sources/attachment_manager.d.ts.map +1 -0
- package/build/src/sources/attachment_manager.js +169 -0
- package/build/src/sources/attachment_manager.js.map +1 -0
- package/build/src/variants/variant_converter.d.ts +23 -0
- package/build/src/variants/variant_converter.d.ts.map +1 -0
- package/build/src/{types/converter.js → variants/variant_converter.js} +1 -0
- package/build/src/variants/variant_converter.js.map +1 -0
- package/build/src/variants/variant_generation_service.d.ts +28 -0
- package/build/src/variants/variant_generation_service.d.ts.map +1 -0
- package/build/src/variants/variant_generation_service.js +44 -0
- package/build/src/variants/variant_generation_service.js.map +1 -0
- package/build/stubs/config/attachment.stub +12 -0
- package/build/stubs/main.d.ts.map +1 -1
- package/build/stubs/main.js +1 -0
- package/build/stubs/main.js.map +1 -0
- package/build/stubs/migrations/attachments_table.stub +38 -0
- package/build/tests/adonis_drive_storage.spec.d.ts +8 -0
- package/build/tests/adonis_drive_storage.spec.d.ts.map +1 -0
- package/build/tests/adonis_drive_storage.spec.js +69 -0
- package/build/tests/adonis_drive_storage.spec.js.map +1 -0
- package/build/{src/types/attachment.js → tests/adonis_queue.spec.d.ts} +1 -0
- package/build/tests/adonis_queue.spec.d.ts.map +1 -0
- package/build/tests/adonis_queue.spec.js +52 -0
- package/build/tests/adonis_queue.spec.js.map +1 -0
- package/build/tests/attachment_job_processor.spec.d.ts +8 -0
- package/build/tests/attachment_job_processor.spec.d.ts.map +1 -0
- package/build/tests/attachment_job_processor.spec.js +89 -0
- package/build/tests/attachment_job_processor.spec.js.map +1 -0
- package/build/tests/attachment_manager.spec.d.ts +8 -0
- package/build/tests/attachment_manager.spec.d.ts.map +1 -0
- package/build/tests/attachment_manager.spec.js +128 -0
- package/build/tests/attachment_manager.spec.js.map +1 -0
- package/build/tests/attachment_manager_service.spec.d.ts +8 -0
- package/build/tests/attachment_manager_service.spec.d.ts.map +1 -0
- package/build/tests/attachment_manager_service.spec.js +47 -0
- package/build/tests/attachment_manager_service.spec.js.map +1 -0
- package/build/tests/attachment_provider.spec.d.ts +8 -0
- package/build/tests/attachment_provider.spec.d.ts.map +1 -0
- package/build/tests/attachment_provider.spec.js +71 -0
- package/build/tests/attachment_provider.spec.js.map +1 -0
- package/build/tests/attachment_service.spec.d.ts +8 -0
- package/build/tests/attachment_service.spec.d.ts.map +1 -0
- package/build/tests/attachment_service.spec.js +91 -0
- package/build/tests/attachment_service.spec.js.map +1 -0
- package/build/tests/attachments_controller.spec.d.ts +8 -0
- package/build/tests/attachments_controller.spec.d.ts.map +1 -0
- package/build/tests/attachments_controller.spec.js +34 -0
- package/build/tests/attachments_controller.spec.js.map +1 -0
- package/build/tests/attachments_table_stub.spec.d.ts +2 -0
- package/build/tests/attachments_table_stub.spec.d.ts.map +1 -0
- package/build/tests/attachments_table_stub.spec.js +65 -0
- package/build/tests/attachments_table_stub.spec.js.map +1 -0
- package/build/tests/configure.spec.d.ts +2 -0
- package/build/tests/configure.spec.d.ts.map +1 -0
- package/build/tests/configure.spec.js +38 -0
- package/build/tests/configure.spec.js.map +1 -0
- package/build/tests/container_bindings.types.d.ts +8 -0
- package/build/tests/container_bindings.types.d.ts.map +1 -0
- package/build/tests/container_bindings.types.js +9 -0
- package/build/tests/container_bindings.types.js.map +1 -0
- package/build/tests/create_legacy_attachment_migration_script.spec.d.ts +8 -0
- package/build/tests/create_legacy_attachment_migration_script.spec.d.ts.map +1 -0
- package/build/tests/create_legacy_attachment_migration_script.spec.js +31 -0
- package/build/tests/create_legacy_attachment_migration_script.spec.js.map +1 -0
- package/build/tests/define_config.spec.d.ts +8 -0
- package/build/tests/define_config.spec.d.ts.map +1 -0
- package/build/tests/define_config.spec.js +191 -0
- package/build/tests/define_config.spec.js.map +1 -0
- package/build/tests/helpers/lucid_test_database.d.ts +9 -0
- package/build/tests/helpers/lucid_test_database.d.ts.map +1 -0
- package/build/tests/helpers/lucid_test_database.js +51 -0
- package/build/tests/helpers/lucid_test_database.js.map +1 -0
- package/build/tests/local_file_storage.spec.d.ts +8 -0
- package/build/tests/local_file_storage.spec.d.ts.map +1 -0
- package/build/tests/local_file_storage.spec.js +44 -0
- package/build/tests/local_file_storage.spec.js.map +1 -0
- package/build/tests/lucid_attachment_column.spec.d.ts +8 -0
- package/build/tests/lucid_attachment_column.spec.d.ts.map +1 -0
- package/build/tests/lucid_attachment_column.spec.js +137 -0
- package/build/tests/lucid_attachment_column.spec.js.map +1 -0
- package/build/tests/lucid_attachment_lifecycle_service.spec.d.ts +8 -0
- package/build/tests/lucid_attachment_lifecycle_service.spec.d.ts.map +1 -0
- package/build/tests/lucid_attachment_lifecycle_service.spec.js +206 -0
- package/build/tests/lucid_attachment_lifecycle_service.spec.js.map +1 -0
- package/build/tests/lucid_attachment_repository.spec.d.ts +8 -0
- package/build/tests/lucid_attachment_repository.spec.d.ts.map +1 -0
- package/build/tests/lucid_attachment_repository.spec.js +50 -0
- package/build/tests/lucid_attachment_repository.spec.js.map +1 -0
- package/build/tests/lucid_attachment_store.spec.d.ts +8 -0
- package/build/tests/lucid_attachment_store.spec.d.ts.map +1 -0
- package/build/tests/lucid_attachment_store.spec.js +71 -0
- package/build/tests/lucid_attachment_store.spec.js.map +1 -0
- package/build/tests/lucid_sqlite_integration.spec.d.ts +8 -0
- package/build/tests/lucid_sqlite_integration.spec.d.ts.map +1 -0
- package/build/tests/lucid_sqlite_integration.spec.js +103 -0
- package/build/tests/lucid_sqlite_integration.spec.js.map +1 -0
- package/build/tests/lucid_variant_generation_service.spec.d.ts +8 -0
- package/build/tests/lucid_variant_generation_service.spec.d.ts.map +1 -0
- package/build/tests/lucid_variant_generation_service.spec.js +56 -0
- package/build/tests/lucid_variant_generation_service.spec.js.map +1 -0
- package/build/tests/memory_queue.spec.d.ts +8 -0
- package/build/tests/memory_queue.spec.d.ts.map +1 -0
- package/build/tests/memory_queue.spec.js +52 -0
- package/build/tests/memory_queue.spec.js.map +1 -0
- package/build/tests/migrate_legacy_attachment.spec.d.ts +8 -0
- package/build/tests/migrate_legacy_attachment.spec.d.ts.map +1 -0
- package/build/tests/migrate_legacy_attachment.spec.js +91 -0
- package/build/tests/migrate_legacy_attachment.spec.js.map +1 -0
- package/build/tests/migrate_legacy_attachment_records.spec.d.ts +8 -0
- package/build/tests/migrate_legacy_attachment_records.spec.d.ts.map +1 -0
- package/build/tests/migrate_legacy_attachment_records.spec.js +66 -0
- package/build/tests/migrate_legacy_attachment_records.spec.js.map +1 -0
- package/build/tests/package_exports.spec.d.ts +8 -0
- package/build/tests/package_exports.spec.d.ts.map +1 -0
- package/build/tests/package_exports.spec.js +31 -0
- package/build/tests/package_exports.spec.js.map +1 -0
- package/build/tests/variant_generation_service.spec.d.ts +8 -0
- package/build/tests/variant_generation_service.spec.d.ts.map +1 -0
- package/build/tests/variant_generation_service.spec.js +79 -0
- package/build/tests/variant_generation_service.spec.js.map +1 -0
- package/package.json +79 -75
- package/build/commands/make/converter.d.ts.map +0 -1
- package/build/commands/make/converter.js +0 -28
- package/build/services/regenerate_service.d.ts +0 -9
- package/build/services/regenerate_service.d.ts.map +0 -1
- package/build/services/regenerate_service.js +0 -29
- package/build/src/adapters/blurhash.d.ts +0 -11
- package/build/src/adapters/blurhash.d.ts.map +0 -1
- package/build/src/adapters/blurhash.js +0 -12
- package/build/src/adapters/exif.d.ts +0 -15
- package/build/src/adapters/exif.d.ts.map +0 -1
- package/build/src/adapters/exif.js +0 -165
- package/build/src/adapters/ffmpeg.d.ts +0 -19
- package/build/src/adapters/ffmpeg.d.ts.map +0 -1
- package/build/src/adapters/ffmpeg.js +0 -115
- package/build/src/adapters/lock.d.ts +0 -9
- package/build/src/adapters/lock.d.ts.map +0 -1
- package/build/src/adapters/lock.js +0 -21
- package/build/src/adapters/meta.d.ts +0 -10
- package/build/src/adapters/meta.d.ts.map +0 -1
- package/build/src/adapters/meta.js +0 -49
- package/build/src/adapters/poppler.d.ts +0 -20
- package/build/src/adapters/poppler.d.ts.map +0 -1
- package/build/src/adapters/poppler.js +0 -117
- package/build/src/adapters/soffice.d.ts +0 -14
- package/build/src/adapters/soffice.d.ts.map +0 -1
- package/build/src/adapters/soffice.js +0 -64
- package/build/src/attachment_manager.d.ts +0 -50
- package/build/src/attachment_manager.d.ts.map +0 -1
- package/build/src/attachment_manager.js +0 -145
- package/build/src/attachments/attachment.d.ts +0 -42
- package/build/src/attachments/attachment.d.ts.map +0 -1
- package/build/src/attachments/attachment.js +0 -233
- package/build/src/attachments/attachment_base.d.ts +0 -59
- package/build/src/attachments/attachment_base.d.ts.map +0 -1
- package/build/src/attachments/attachment_base.js +0 -211
- package/build/src/attachments/variant_attachment.d.ts +0 -27
- package/build/src/attachments/variant_attachment.d.ts.map +0 -1
- package/build/src/attachments/variant_attachment.js +0 -40
- package/build/src/converters/autodetect_converter.d.ts +0 -13
- package/build/src/converters/autodetect_converter.d.ts.map +0 -1
- package/build/src/converters/autodetect_converter.js +0 -77
- package/build/src/converters/converter.d.ts +0 -14
- package/build/src/converters/converter.d.ts.map +0 -1
- package/build/src/converters/converter.js +0 -14
- package/build/src/converters/document_thumbnail_converter.d.ts +0 -14
- package/build/src/converters/document_thumbnail_converter.d.ts.map +0 -1
- package/build/src/converters/document_thumbnail_converter.js +0 -36
- package/build/src/converters/image_converter.d.ts +0 -13
- package/build/src/converters/image_converter.d.ts.map +0 -1
- package/build/src/converters/image_converter.js +0 -27
- package/build/src/converters/pdf_thumbnail_converter.d.ts +0 -14
- package/build/src/converters/pdf_thumbnail_converter.d.ts.map +0 -1
- package/build/src/converters/pdf_thumbnail_converter.js +0 -39
- package/build/src/converters/video_thumbnail_converter.d.ts +0 -14
- package/build/src/converters/video_thumbnail_converter.d.ts.map +0 -1
- package/build/src/converters/video_thumbnail_converter.js +0 -40
- package/build/src/decorators/attachment.d.ts +0 -15
- package/build/src/decorators/attachment.d.ts.map +0 -1
- package/build/src/decorators/attachment.js +0 -103
- package/build/src/errors.d.ts +0 -67
- package/build/src/errors.d.ts.map +0 -1
- package/build/src/errors.js +0 -68
- package/build/src/services/attachment/attachment_detachment_service.d.ts +0 -19
- package/build/src/services/attachment/attachment_detachment_service.d.ts.map +0 -1
- package/build/src/services/attachment/attachment_detachment_service.js +0 -66
- package/build/src/services/attachment/attachment_persister_service.d.ts +0 -22
- package/build/src/services/attachment/attachment_persister_service.d.ts.map +0 -1
- package/build/src/services/attachment/attachment_persister_service.js +0 -96
- package/build/src/services/attachment/attachment_recorder_service.d.ts +0 -68
- package/build/src/services/attachment/attachment_recorder_service.d.ts.map +0 -1
- package/build/src/services/attachment/attachment_recorder_service.js +0 -121
- package/build/src/services/attachment/attachment_transaction_service.d.ts +0 -26
- package/build/src/services/attachment/attachment_transaction_service.d.ts.map +0 -1
- package/build/src/services/attachment/attachment_transaction_service.js +0 -46
- package/build/src/services/attachment/attachment_utils.d.ts +0 -35
- package/build/src/services/attachment/attachment_utils.d.ts.map +0 -1
- package/build/src/services/attachment/attachment_utils.js +0 -71
- package/build/src/services/attachment/attachment_variant_service.d.ts +0 -17
- package/build/src/services/attachment/attachment_variant_service.d.ts.map +0 -1
- package/build/src/services/attachment/attachment_variant_service.js +0 -99
- package/build/src/services/attachment/index.d.ts +0 -15
- package/build/src/services/attachment/index.d.ts.map +0 -1
- package/build/src/services/attachment/index.js +0 -15
- package/build/src/services/attachment_service.d.ts +0 -8
- package/build/src/services/attachment_service.d.ts.map +0 -1
- package/build/src/services/attachment_service.js +0 -7
- package/build/src/services/variant/variant_generator_service.d.ts +0 -24
- package/build/src/services/variant/variant_generator_service.d.ts.map +0 -1
- package/build/src/services/variant/variant_generator_service.js +0 -101
- package/build/src/services/variant/variant_persister_service.d.ts +0 -24
- package/build/src/services/variant/variant_persister_service.d.ts.map +0 -1
- package/build/src/services/variant/variant_persister_service.js +0 -59
- package/build/src/services/variant/variant_purger_service.d.ts +0 -15
- package/build/src/services/variant/variant_purger_service.d.ts.map +0 -1
- package/build/src/services/variant/variant_purger_service.js +0 -47
- package/build/src/services/variant_service.d.ts +0 -13
- package/build/src/services/variant_service.d.ts.map +0 -1
- package/build/src/services/variant_service.js +0 -63
- package/build/src/types/attachment.d.ts +0 -100
- package/build/src/types/attachment.d.ts.map +0 -1
- package/build/src/types/config.d.ts +0 -58
- package/build/src/types/config.d.ts.map +0 -1
- package/build/src/types/converter.d.ts +0 -144
- package/build/src/types/converter.d.ts.map +0 -1
- package/build/src/types/drive.d.ts +0 -6
- package/build/src/types/drive.d.ts.map +0 -1
- package/build/src/types/drive.js +0 -1
- package/build/src/types/event.d.ts +0 -16
- package/build/src/types/event.d.ts.map +0 -1
- package/build/src/types/index.d.ts +0 -15
- package/build/src/types/index.d.ts.map +0 -1
- package/build/src/types/index.js +0 -14
- package/build/src/types/input.d.ts +0 -35
- package/build/src/types/input.d.ts.map +0 -1
- package/build/src/types/input.js +0 -7
- package/build/src/types/lock.d.ts +0 -14
- package/build/src/types/lock.d.ts.map +0 -1
- package/build/src/types/lock.js +0 -7
- package/build/src/types/metadata.d.ts +0 -24
- package/build/src/types/metadata.d.ts.map +0 -1
- package/build/src/types/metadata.js +0 -7
- package/build/src/types/mixin.d.ts +0 -17
- package/build/src/types/mixin.d.ts.map +0 -1
- package/build/src/types/mixin.js +0 -7
- package/build/src/types/regenerate.d.ts +0 -12
- package/build/src/types/regenerate.d.ts.map +0 -1
- package/build/src/types/regenerate.js +0 -7
- package/build/src/types/service.d.ts +0 -25
- package/build/src/types/service.d.ts.map +0 -1
- package/build/src/types/service.js +0 -7
- package/build/src/utils/default_values.d.ts +0 -20
- package/build/src/utils/default_values.d.ts.map +0 -1
- package/build/src/utils/default_values.js +0 -19
- package/build/src/utils/helpers.d.ts +0 -19
- package/build/src/utils/helpers.d.ts.map +0 -1
- package/build/src/utils/helpers.js +0 -131
- package/build/src/utils/hooks.d.ts +0 -12
- package/build/src/utils/hooks.d.ts.map +0 -1
- package/build/src/utils/hooks.js +0 -42
- package/build/src/utils/symbols.d.ts +0 -8
- package/build/src/utils/symbols.d.ts.map +0 -1
- package/build/src/utils/symbols.js +0 -7
- package/build/stubs/config.stub +0 -140
- package/build/stubs/make/converter/main.stub +0 -20
- package/build/tsconfig.tsbuildinfo +0 -1
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import logger from '@adonisjs/core/services/logger';
|
|
2
|
-
import emitter from '@adonisjs/core/services/emitter';
|
|
3
|
-
import attachmentManager from '../../../services/main.js';
|
|
4
|
-
import VariantService from '../variant_service.js';
|
|
5
|
-
import { AttachmentUtils } from './attachment_utils.js';
|
|
6
|
-
import { E_CANNOT_CREATE_VARIANT } from '../../errors.js';
|
|
7
|
-
export class AttachmentVariantService {
|
|
8
|
-
/**
|
|
9
|
-
* Generate variants for all dirty attachment attributes
|
|
10
|
-
*/
|
|
11
|
-
async generateVariants(record) {
|
|
12
|
-
/* this.#row.$dirty is not available in afterSave hooks */
|
|
13
|
-
const attachmentAttributeNames = record.row.$attachments.dirtied;
|
|
14
|
-
for await (const name of attachmentAttributeNames) {
|
|
15
|
-
if (!record.row.$attributes[name]) {
|
|
16
|
-
continue;
|
|
17
|
-
}
|
|
18
|
-
this.#queueVariantGeneration(name, record, {});
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Regenerate variants with specific options
|
|
23
|
-
*/
|
|
24
|
-
async regenerateVariants(record, options = {}) {
|
|
25
|
-
let attachmentAttributeNames;
|
|
26
|
-
if (options.attributes?.length) {
|
|
27
|
-
attachmentAttributeNames = options.attributes;
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
attachmentAttributeNames = AttachmentUtils.getAttributeNamesOfAttachment(record.row);
|
|
31
|
-
}
|
|
32
|
-
for await (const name of attachmentAttributeNames) {
|
|
33
|
-
if (!record.row.$attributes[name]) {
|
|
34
|
-
continue;
|
|
35
|
-
}
|
|
36
|
-
this.#queueVariantGeneration(name, record, { variants: options.variants });
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Queue variant generation with error handling
|
|
41
|
-
*/
|
|
42
|
-
#queueVariantGeneration(name, record, options) {
|
|
43
|
-
attachmentManager.queue.push({
|
|
44
|
-
name: `${record.row.constructor.name}-${name}`,
|
|
45
|
-
async run() {
|
|
46
|
-
const model = record.row.constructor;
|
|
47
|
-
await attachmentManager.lock
|
|
48
|
-
.createLock(`attachment.${model.table}-${name}`)
|
|
49
|
-
.run(async () => {
|
|
50
|
-
const config = AttachmentUtils.getOptionsByAttributeName(record.row, name);
|
|
51
|
-
const emitterPayload = {
|
|
52
|
-
tableName: model.table,
|
|
53
|
-
attributeName: name,
|
|
54
|
-
variants: config?.variants,
|
|
55
|
-
primary: {
|
|
56
|
-
key: model.primaryKey,
|
|
57
|
-
value: record.row.$primaryKeyValue?.toString() || record.row.$attributes['id'],
|
|
58
|
-
},
|
|
59
|
-
};
|
|
60
|
-
emitter.emit('attachment:variant_started', emitterPayload);
|
|
61
|
-
const variantService = new VariantService({
|
|
62
|
-
record,
|
|
63
|
-
attributeName: name,
|
|
64
|
-
options: config,
|
|
65
|
-
filters: {
|
|
66
|
-
variants: options.variants,
|
|
67
|
-
},
|
|
68
|
-
});
|
|
69
|
-
await variantService.run();
|
|
70
|
-
emitter.emit('attachment:variant_completed', emitterPayload);
|
|
71
|
-
});
|
|
72
|
-
},
|
|
73
|
-
}).onError = (error) => {
|
|
74
|
-
this.#handleVariantError(error);
|
|
75
|
-
const config = AttachmentUtils.getOptionsByAttributeName(record.row, name);
|
|
76
|
-
const model = record.row.constructor;
|
|
77
|
-
emitter.emit('attachment:variant_failed', {
|
|
78
|
-
tableName: model.table,
|
|
79
|
-
attributeName: name,
|
|
80
|
-
variants: config?.variants,
|
|
81
|
-
primary: {
|
|
82
|
-
key: model.primaryKey,
|
|
83
|
-
value: record.row.$primaryKeyValue?.toString() || record.row.$attributes['id'],
|
|
84
|
-
},
|
|
85
|
-
});
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Handle variant generation errors
|
|
90
|
-
*/
|
|
91
|
-
#handleVariantError(error) {
|
|
92
|
-
if (error.message) {
|
|
93
|
-
logger.error(error.message);
|
|
94
|
-
}
|
|
95
|
-
else {
|
|
96
|
-
throw new E_CANNOT_CREATE_VARIANT([error]);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @jrmc/adonis-attachment
|
|
3
|
-
*
|
|
4
|
-
* @license MIT
|
|
5
|
-
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
-
*/
|
|
7
|
-
export { default as AttachmentRecordService } from './attachment_recorder_service.js';
|
|
8
|
-
export { AttachmentTransactionService } from './attachment_transaction_service.js';
|
|
9
|
-
export { AttachmentPersisterService } from './attachment_persister_service.js';
|
|
10
|
-
export { AttachmentVariantService } from './attachment_variant_service.js';
|
|
11
|
-
export { AttachmentDetachmentService } from './attachment_detachment_service.js';
|
|
12
|
-
export { AttachmentUtils } from './attachment_utils.js';
|
|
13
|
-
export type { TransactionOptions } from './attachment_transaction_service.js';
|
|
14
|
-
export type { VariantOptions } from './attachment_variant_service.js';
|
|
15
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/services/attachment/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,OAAO,IAAI,uBAAuB,EAAE,MAAM,kCAAkC,CAAA;AAGrF,OAAO,EAAE,4BAA4B,EAAE,MAAM,qCAAqC,CAAA;AAClF,OAAO,EAAE,0BAA0B,EAAE,MAAM,mCAAmC,CAAA;AAC9E,OAAO,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAA;AAC1E,OAAO,EAAE,2BAA2B,EAAE,MAAM,oCAAoC,CAAA;AAGhF,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAGvD,YAAY,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAA;AAC7E,YAAY,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAA"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @jrmc/adonis-attachment
|
|
3
|
-
*
|
|
4
|
-
* @license MIT
|
|
5
|
-
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
-
*/
|
|
7
|
-
// Main service
|
|
8
|
-
export { default as AttachmentRecordService } from './attachment_recorder_service.js';
|
|
9
|
-
// Specialized services
|
|
10
|
-
export { AttachmentTransactionService } from './attachment_transaction_service.js';
|
|
11
|
-
export { AttachmentPersisterService } from './attachment_persister_service.js';
|
|
12
|
-
export { AttachmentVariantService } from './attachment_variant_service.js';
|
|
13
|
-
export { AttachmentDetachmentService } from './attachment_detachment_service.js';
|
|
14
|
-
// Utilities
|
|
15
|
-
export { AttachmentUtils } from './attachment_utils.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"attachment_service.d.ts","sourceRoot":"","sources":["../../../src/services/attachment_service.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,uBAAuB,IAAI,OAAO,EAAE,MAAM,uBAAuB,CAAA"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @jrmc/adonis-attachment
|
|
3
|
-
*
|
|
4
|
-
* @license MIT
|
|
5
|
-
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
-
*/
|
|
7
|
-
import type { Attachment, Variant, LucidOptions } from '../../types/attachment.js';
|
|
8
|
-
import type { Converter } from '../../types/converter.js';
|
|
9
|
-
export default class VariantGeneratorService {
|
|
10
|
-
#private;
|
|
11
|
-
generate({ attachments, options, filters, }: {
|
|
12
|
-
attachments: Attachment[];
|
|
13
|
-
options: LucidOptions;
|
|
14
|
-
filters?: {
|
|
15
|
-
variants?: string[];
|
|
16
|
-
};
|
|
17
|
-
}): Promise<Variant[]>;
|
|
18
|
-
generateVariant({ key, attachment, converter, }: {
|
|
19
|
-
key: string;
|
|
20
|
-
attachment: Attachment;
|
|
21
|
-
converter: Converter;
|
|
22
|
-
}): Promise<Variant | null>;
|
|
23
|
-
}
|
|
24
|
-
//# sourceMappingURL=variant_generator_service.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"variant_generator_service.d.ts","sourceRoot":"","sources":["../../../../src/services/variant/variant_generator_service.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAClF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AAQzD,MAAM,CAAC,OAAO,OAAO,uBAAuB;;IAKpC,QAAQ,CAAC,EACb,WAAW,EACX,OAAO,EACP,OAAO,GACR,EAAE;QACD,WAAW,EAAE,UAAU,EAAE,CAAA;QACzB,OAAO,EAAE,YAAY,CAAA;QACrB,OAAO,CAAC,EAAE;YAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;SAAE,CAAA;KAClC,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAmBhB,eAAe,CAAC,EACpB,GAAG,EACH,UAAU,EACV,SAAS,GACV,EAAE;QACD,GAAG,EAAE,MAAM,CAAA;QACX,UAAU,EAAE,UAAU,CAAA;QACtB,SAAS,EAAE,SAAS,CAAA;KACrB,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;CAoF5B"}
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @jrmc/adonis-attachment
|
|
3
|
-
*
|
|
4
|
-
* @license MIT
|
|
5
|
-
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
-
*/
|
|
7
|
-
import app from '@adonisjs/core/services/app';
|
|
8
|
-
import logger from '@adonisjs/core/services/logger';
|
|
9
|
-
import { streamToTempFile } from '../../utils/helpers.js';
|
|
10
|
-
export default class VariantGeneratorService {
|
|
11
|
-
async #getAttachmentManager() {
|
|
12
|
-
return app.container.make('jrmc.attachment');
|
|
13
|
-
}
|
|
14
|
-
async generate({ attachments, options, filters, }) {
|
|
15
|
-
const variants = [];
|
|
16
|
-
const variantKeys = this.#getVariantKeysToProcess(options, filters);
|
|
17
|
-
for (const key of variantKeys) {
|
|
18
|
-
const converter = await this.#getConverter(key);
|
|
19
|
-
if (!converter)
|
|
20
|
-
continue;
|
|
21
|
-
for (const attachment of attachments) {
|
|
22
|
-
const variant = await this.generateVariant({ key, attachment, converter });
|
|
23
|
-
if (variant) {
|
|
24
|
-
variants.push(variant);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
return variants;
|
|
29
|
-
}
|
|
30
|
-
async generateVariant({ key, attachment, converter, }) {
|
|
31
|
-
try {
|
|
32
|
-
const attachmentManager = await this.#getAttachmentManager();
|
|
33
|
-
const input = await this.#prepareInput(attachment);
|
|
34
|
-
const output = await this.#convertFile(input, converter);
|
|
35
|
-
if (!output) {
|
|
36
|
-
// throw new errors.E_CANNOT_PATH_BY_CONVERTER()
|
|
37
|
-
logger.warn(`Converter returned no output for key: ${key}`);
|
|
38
|
-
return null;
|
|
39
|
-
}
|
|
40
|
-
const basePath = attachmentManager.getConfig().variant?.basePath;
|
|
41
|
-
const ignoreFolder = attachmentManager.getConfig().variant?.ignoreFolder;
|
|
42
|
-
const variant = await attachment.createVariant(key, output, { basePath, ignoreFolder });
|
|
43
|
-
await this.#processBlurhash(variant, converter);
|
|
44
|
-
await attachmentManager.write(variant);
|
|
45
|
-
return variant;
|
|
46
|
-
}
|
|
47
|
-
catch (error) {
|
|
48
|
-
logger.error(`Failed to generate variant ${key} for attachment: ${error.message}`);
|
|
49
|
-
return null;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
#getVariantKeysToProcess(options, filters) {
|
|
53
|
-
if (!options.variants)
|
|
54
|
-
return [];
|
|
55
|
-
return options.variants.filter((key) => filters?.variants === undefined || filters.variants.includes(key));
|
|
56
|
-
}
|
|
57
|
-
async #getConverter(key) {
|
|
58
|
-
try {
|
|
59
|
-
const attachmentManager = await this.#getAttachmentManager();
|
|
60
|
-
return (await attachmentManager.getConverter(key));
|
|
61
|
-
}
|
|
62
|
-
catch (error) {
|
|
63
|
-
logger.error(`Failed to get converter for key ${key}: ${error.message}`);
|
|
64
|
-
return null;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
async #prepareInput(attachment) {
|
|
68
|
-
if (attachment.input) {
|
|
69
|
-
return attachment.input;
|
|
70
|
-
}
|
|
71
|
-
const stream = await attachment.getStream();
|
|
72
|
-
return await streamToTempFile(stream);
|
|
73
|
-
}
|
|
74
|
-
async #convertFile(input, converter) {
|
|
75
|
-
if (!converter.handle) {
|
|
76
|
-
throw new Error('Converter handle method is required');
|
|
77
|
-
}
|
|
78
|
-
if (!converter.options) {
|
|
79
|
-
throw new Error('Converter options are required');
|
|
80
|
-
}
|
|
81
|
-
return await converter.handle({
|
|
82
|
-
input,
|
|
83
|
-
options: converter.options,
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
async #processBlurhash(variant, converter) {
|
|
87
|
-
const blurhashConfig = converter.options?.blurhash;
|
|
88
|
-
if (!blurhashConfig)
|
|
89
|
-
return;
|
|
90
|
-
const shouldGenerate = typeof blurhashConfig === 'boolean' ? blurhashConfig : blurhashConfig.enabled === true;
|
|
91
|
-
if (!shouldGenerate)
|
|
92
|
-
return;
|
|
93
|
-
try {
|
|
94
|
-
const options = typeof blurhashConfig !== 'boolean' ? blurhashConfig : undefined;
|
|
95
|
-
await variant.generateBlurhash(options);
|
|
96
|
-
}
|
|
97
|
-
catch (error) {
|
|
98
|
-
logger.error(`Blurhash generation failed: ${error.message}`);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @jrmc/adonis-attachment
|
|
3
|
-
*
|
|
4
|
-
* @license MIT
|
|
5
|
-
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
-
*/
|
|
7
|
-
import type { Attachment, Variant } from '../../types/attachment.js';
|
|
8
|
-
type PersistAttributes = {
|
|
9
|
-
id: string;
|
|
10
|
-
modelTable: string;
|
|
11
|
-
attributeName: string;
|
|
12
|
-
multiple: boolean;
|
|
13
|
-
primaryKey: string;
|
|
14
|
-
};
|
|
15
|
-
export default class VariantPersisterService {
|
|
16
|
-
#private;
|
|
17
|
-
constructor({ id, modelTable, attributeName, multiple, primaryKey }: PersistAttributes);
|
|
18
|
-
persist({ attachments, variants, }: {
|
|
19
|
-
attachments: Attachment[];
|
|
20
|
-
variants: Variant[];
|
|
21
|
-
}): Promise<void>;
|
|
22
|
-
}
|
|
23
|
-
export {};
|
|
24
|
-
//# sourceMappingURL=variant_persister_service.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"variant_persister_service.d.ts","sourceRoot":"","sources":["../../../../src/services/variant/variant_persister_service.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAA;AAOpE,KAAK,iBAAiB,GAAG;IACvB,EAAE,EAAE,MAAM,CAAA;IACV,UAAU,EAAE,MAAM,CAAA;IAClB,aAAa,EAAE,MAAM,CAAA;IACrB,QAAQ,EAAE,OAAO,CAAA;IACjB,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,MAAM,CAAC,OAAO,OAAO,uBAAuB;;gBAO9B,EAAE,EAAE,EAAE,UAAU,EAAE,aAAa,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,iBAAiB;IAQhF,OAAO,CAAC,EACZ,WAAW,EACX,QAAQ,GACT,EAAE;QACD,WAAW,EAAE,UAAU,EAAE,CAAA;QACzB,QAAQ,EAAE,OAAO,EAAE,CAAA;KACpB,GAAG,OAAO,CAAC,IAAI,CAAC;CAwClB"}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @jrmc/adonis-attachment
|
|
3
|
-
*
|
|
4
|
-
* @license MIT
|
|
5
|
-
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
-
*/
|
|
7
|
-
import logger from '@adonisjs/core/services/logger';
|
|
8
|
-
import string from '@adonisjs/core/helpers/string';
|
|
9
|
-
import db from '@adonisjs/lucid/services/db';
|
|
10
|
-
import attachmentManager from '../../../services/main.js';
|
|
11
|
-
export default class VariantPersisterService {
|
|
12
|
-
#id;
|
|
13
|
-
#modelTable;
|
|
14
|
-
#attributeName;
|
|
15
|
-
#multiple;
|
|
16
|
-
#primaryKey;
|
|
17
|
-
constructor({ id, modelTable, attributeName, multiple, primaryKey }) {
|
|
18
|
-
this.#id = id;
|
|
19
|
-
this.#modelTable = modelTable;
|
|
20
|
-
this.#attributeName = attributeName;
|
|
21
|
-
this.#multiple = multiple;
|
|
22
|
-
this.#primaryKey = primaryKey;
|
|
23
|
-
}
|
|
24
|
-
async persist({ attachments, variants, }) {
|
|
25
|
-
const rollback = () => this.#rollbackVariants(variants);
|
|
26
|
-
const trx = await db.transaction();
|
|
27
|
-
trx.after('rollback', rollback);
|
|
28
|
-
try {
|
|
29
|
-
const data = this.#prepareUpdateData(attachments);
|
|
30
|
-
await this.#executeUpdate(trx, data);
|
|
31
|
-
await trx.commit();
|
|
32
|
-
}
|
|
33
|
-
catch (error) {
|
|
34
|
-
logger.error(`Persist failed: ${error.message}`);
|
|
35
|
-
await trx.rollback();
|
|
36
|
-
throw error;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
#rollbackVariants(variants) {
|
|
40
|
-
variants.forEach((variant) => {
|
|
41
|
-
try {
|
|
42
|
-
attachmentManager.remove(variant);
|
|
43
|
-
}
|
|
44
|
-
catch (error) {
|
|
45
|
-
logger.error(`Rollback failed for variant: ${error.message}`);
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
#prepareUpdateData(attachments) {
|
|
50
|
-
const index = string.snakeCase(this.#attributeName);
|
|
51
|
-
const value = this.#multiple
|
|
52
|
-
? JSON.stringify(attachments.map((att) => JSON.parse(att.toDbString())))
|
|
53
|
-
: (attachments[0]?.toDbString() ?? JSON.stringify(null));
|
|
54
|
-
return { [index]: value };
|
|
55
|
-
}
|
|
56
|
-
async #executeUpdate(trx, data) {
|
|
57
|
-
await trx.query().from(this.#modelTable).where(this.#primaryKey, this.#id).update(data);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @jrmc/adonis-attachment
|
|
3
|
-
*
|
|
4
|
-
* @license MIT
|
|
5
|
-
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
-
*/
|
|
7
|
-
import type { Attachment } from '../../types/attachment.js';
|
|
8
|
-
export default class VariantPurger {
|
|
9
|
-
#private;
|
|
10
|
-
constructor(filters?: {
|
|
11
|
-
variants?: string[];
|
|
12
|
-
});
|
|
13
|
-
purge(attachments: Attachment[]): Promise<void>;
|
|
14
|
-
}
|
|
15
|
-
//# sourceMappingURL=variant_purger_service.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"variant_purger_service.d.ts","sourceRoot":"","sources":["../../../../src/services/variant/variant_purger_service.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAW,MAAM,2BAA2B,CAAA;AAIpE,MAAM,CAAC,OAAO,OAAO,aAAa;;gBAGpB,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;KAAE;IAIvC,KAAK,CAAC,WAAW,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CA0CtD"}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @jrmc/adonis-attachment
|
|
3
|
-
*
|
|
4
|
-
* @license MIT
|
|
5
|
-
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
-
*/
|
|
7
|
-
import attachmentManager from '../../../services/main.js';
|
|
8
|
-
export default class VariantPurger {
|
|
9
|
-
#filters;
|
|
10
|
-
constructor(filters) {
|
|
11
|
-
this.#filters = filters;
|
|
12
|
-
}
|
|
13
|
-
async purge(attachments) {
|
|
14
|
-
const variantsToRemove = this.#getVariantsToRemove(attachments);
|
|
15
|
-
await Promise.all(variantsToRemove.map((variant) => attachmentManager.remove(variant)));
|
|
16
|
-
this.#updateAttachmentVariants(attachments);
|
|
17
|
-
}
|
|
18
|
-
#getVariantsToRemove(attachments) {
|
|
19
|
-
const variants = [];
|
|
20
|
-
attachments.forEach((attachment) => {
|
|
21
|
-
if (attachment.variants) {
|
|
22
|
-
attachment.variants.forEach((variant) => {
|
|
23
|
-
if (this.#shouldRemoveVariant(variant)) {
|
|
24
|
-
variants.push(variant);
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
return variants;
|
|
30
|
-
}
|
|
31
|
-
#updateAttachmentVariants(attachments) {
|
|
32
|
-
attachments.forEach((attachment) => {
|
|
33
|
-
if (attachment.variants) {
|
|
34
|
-
attachment.variants = this.#filterVariants(attachment.variants);
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
#shouldRemoveVariant(variant) {
|
|
39
|
-
return this.#filters?.variants === undefined || this.#filters.variants.includes(variant.key);
|
|
40
|
-
}
|
|
41
|
-
#filterVariants(variants) {
|
|
42
|
-
if (this.#filters?.variants === undefined) {
|
|
43
|
-
return [];
|
|
44
|
-
}
|
|
45
|
-
return variants.filter((variant) => !this.#filters.variants.includes(variant.key));
|
|
46
|
-
}
|
|
47
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @jrmc/adonis-attachment
|
|
3
|
-
*
|
|
4
|
-
* @license MIT
|
|
5
|
-
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
-
*/
|
|
7
|
-
import type { ConverterInitializeAttributes } from '../types/converter.js';
|
|
8
|
-
export default class VariantService {
|
|
9
|
-
#private;
|
|
10
|
-
constructor({ record, attributeName, options, filters }: ConverterInitializeAttributes);
|
|
11
|
-
run(): Promise<import("../types/attachment.js").Variant[] | undefined>;
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=variant_service.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"variant_service.d.ts","sourceRoot":"","sources":["../../../src/services/variant_service.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,uBAAuB,CAAA;AAO1E,MAAM,CAAC,OAAO,OAAO,cAAc;;gBASrB,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,6BAA6B;IAiBhF,GAAG;CAiCV"}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @jrmc/adonis-attachment
|
|
3
|
-
*
|
|
4
|
-
* @license MIT
|
|
5
|
-
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
-
*/
|
|
7
|
-
import logger from '@adonisjs/core/services/logger';
|
|
8
|
-
import VariantGeneratorService from './variant/variant_generator_service.js';
|
|
9
|
-
import VariantPurgerService from './variant/variant_purger_service.js';
|
|
10
|
-
import VariantPersisterService from './variant/variant_persister_service.js';
|
|
11
|
-
export default class VariantService {
|
|
12
|
-
#record;
|
|
13
|
-
#attributeName;
|
|
14
|
-
#options;
|
|
15
|
-
#filters;
|
|
16
|
-
#variantGenerator;
|
|
17
|
-
#variantPurger;
|
|
18
|
-
#variantPersister;
|
|
19
|
-
constructor({ record, attributeName, options, filters }) {
|
|
20
|
-
this.#record = record;
|
|
21
|
-
this.#attributeName = attributeName;
|
|
22
|
-
this.#options = options;
|
|
23
|
-
this.#filters = filters;
|
|
24
|
-
this.#variantGenerator = new VariantGeneratorService();
|
|
25
|
-
this.#variantPurger = new VariantPurgerService(filters);
|
|
26
|
-
this.#variantPersister = new VariantPersisterService({
|
|
27
|
-
id: record.row.$primaryKeyValue?.toString() || record.row.$attributes['id'],
|
|
28
|
-
modelTable: record.row.constructor.table,
|
|
29
|
-
attributeName,
|
|
30
|
-
multiple: Array.isArray(record.row.$original[attributeName]),
|
|
31
|
-
primaryKey: record.row.constructor.primaryKey ?? 'id',
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
async run() {
|
|
35
|
-
try {
|
|
36
|
-
const attachments = await this.#getAttachments();
|
|
37
|
-
if (!this.#shouldProcess(attachments)) {
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
await this.#variantPurger.purge(attachments);
|
|
41
|
-
const variants = await this.#variantGenerator.generate({
|
|
42
|
-
attachments,
|
|
43
|
-
options: this.#options,
|
|
44
|
-
filters: this.#filters,
|
|
45
|
-
});
|
|
46
|
-
await this.#variantPersister.persist({ attachments, variants });
|
|
47
|
-
return variants;
|
|
48
|
-
}
|
|
49
|
-
catch (error) {
|
|
50
|
-
logger.error(`VariantService.run failed: ${error.message}`);
|
|
51
|
-
throw error;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
async #getAttachments() {
|
|
55
|
-
// await this.#record.row.refresh()
|
|
56
|
-
return this.#record.getAttachments({
|
|
57
|
-
attributeName: this.#attributeName,
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
#shouldProcess(attachments) {
|
|
61
|
-
return !!(attachments?.length && this.#options?.variants?.length);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @jrmc/adonis-attachment
|
|
3
|
-
*
|
|
4
|
-
* @license MIT
|
|
5
|
-
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
-
*/
|
|
7
|
-
import type { LucidRow } from '@adonisjs/lucid/types/model';
|
|
8
|
-
import type { DriveService } from '@adonisjs/drive/types';
|
|
9
|
-
import type { Exif, Input } from './input.js';
|
|
10
|
-
import type { Disk } from '@adonisjs/drive';
|
|
11
|
-
import type { SignedURLOptions } from '@adonisjs/drive/types';
|
|
12
|
-
import type { AttachmentVariants } from '@jrmc/adonis-attachment';
|
|
13
|
-
import { BlurhashOptions } from './converter.js';
|
|
14
|
-
export type AttachmentBase = {
|
|
15
|
-
drive: DriveService;
|
|
16
|
-
disk?: string;
|
|
17
|
-
input?: Input;
|
|
18
|
-
name: string;
|
|
19
|
-
folder?: string;
|
|
20
|
-
path?: string;
|
|
21
|
-
size: number;
|
|
22
|
-
extname: string;
|
|
23
|
-
mimeType: string;
|
|
24
|
-
meta?: Exif;
|
|
25
|
-
originalPath?: string;
|
|
26
|
-
url?: string;
|
|
27
|
-
options: LucidOptions;
|
|
28
|
-
getDisk(): Disk;
|
|
29
|
-
getBytes(): Promise<Uint8Array>;
|
|
30
|
-
getBuffer(): Promise<Buffer>;
|
|
31
|
-
getStream(): Promise<NodeJS.ReadableStream>;
|
|
32
|
-
getUrl(): Promise<string>;
|
|
33
|
-
getSignedUrl(signedUrlOptions?: SignedURLOptions): Promise<string>;
|
|
34
|
-
getKeyId(): string | undefined;
|
|
35
|
-
setKeyId(keyId: string): AttachmentBase;
|
|
36
|
-
setOptions(options: LucidOptions): AttachmentBase;
|
|
37
|
-
computeUrl(signedUrlOptions?: SignedURLOptions): Promise<void>;
|
|
38
|
-
preComputeUrl(): Promise<void>;
|
|
39
|
-
makeFolder(record?: LucidRow): void;
|
|
40
|
-
makeName(record?: LucidRow, attributeName?: string, originalName?: string): void;
|
|
41
|
-
put(): Promise<void>;
|
|
42
|
-
remove(): Promise<void>;
|
|
43
|
-
toObject(): AttachmentBaseAttributes;
|
|
44
|
-
toDbString(): string;
|
|
45
|
-
toJSON(): Object;
|
|
46
|
-
};
|
|
47
|
-
export type Attachment = AttachmentBase & {
|
|
48
|
-
originalName: string;
|
|
49
|
-
variants?: Variant[];
|
|
50
|
-
createVariant(key: string, input: Input, options?: {
|
|
51
|
-
basePath?: string;
|
|
52
|
-
ignoreFolder?: boolean;
|
|
53
|
-
}): Promise<Variant>;
|
|
54
|
-
getVariant(variantName: string): Variant | null;
|
|
55
|
-
getUrl(variantName?: string): Promise<string>;
|
|
56
|
-
getSignedUrl(variantNameOrOptions?: string | SignedURLOptions, signedUrlOptions?: SignedURLOptions): Promise<string>;
|
|
57
|
-
preComputeUrl(): Promise<void>;
|
|
58
|
-
moveFileForDelete(): Promise<void>;
|
|
59
|
-
rollbackMoveFileForDelete(): Promise<void>;
|
|
60
|
-
remove(): Promise<void>;
|
|
61
|
-
toObject(): AttachmentAttributes;
|
|
62
|
-
};
|
|
63
|
-
export type Variant = AttachmentBase & {
|
|
64
|
-
key: string;
|
|
65
|
-
folder: string;
|
|
66
|
-
blurhash?: string;
|
|
67
|
-
generateBlurhash(options?: BlurhashOptions): void;
|
|
68
|
-
toObject(): VariantAttributes;
|
|
69
|
-
};
|
|
70
|
-
export type LucidOptions<T = LucidRow> = {
|
|
71
|
-
disk?: string;
|
|
72
|
-
folder?: string | ((record: T) => string) | ((record: T) => Promise<string>);
|
|
73
|
-
rename?: boolean | ((record: T, column?: string, currentName?: string) => string) | ((record: T, column?: string, currentName?: string) => Promise<string>);
|
|
74
|
-
preComputeUrl?: boolean;
|
|
75
|
-
variants?: (keyof AttachmentVariants)[];
|
|
76
|
-
meta?: boolean;
|
|
77
|
-
serialize?: (value?: Attachment) => unknown;
|
|
78
|
-
serializeAs?: string | null;
|
|
79
|
-
};
|
|
80
|
-
export type AttachmentBaseAttributes = {
|
|
81
|
-
keyId?: string;
|
|
82
|
-
name?: string;
|
|
83
|
-
size: number;
|
|
84
|
-
meta?: Exif;
|
|
85
|
-
extname: string;
|
|
86
|
-
mimeType: string;
|
|
87
|
-
folder?: string;
|
|
88
|
-
path?: string;
|
|
89
|
-
};
|
|
90
|
-
export type AttachmentAttributes = AttachmentBaseAttributes & {
|
|
91
|
-
variants?: VariantAttributes[];
|
|
92
|
-
originalName: string;
|
|
93
|
-
disk?: string;
|
|
94
|
-
};
|
|
95
|
-
export type VariantAttributes = AttachmentBaseAttributes & {
|
|
96
|
-
key: string;
|
|
97
|
-
folder: string;
|
|
98
|
-
blurhash?: string;
|
|
99
|
-
};
|
|
100
|
-
//# sourceMappingURL=attachment.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"attachment.d.ts","sourceRoot":"","sources":["../../../src/types/attachment.ts"],"names":[],"mappings":"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"}
|