@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,42 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @jrmc/adonis-attachment
|
|
3
|
-
*
|
|
4
|
-
* @license MIT
|
|
5
|
-
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
-
*/
|
|
7
|
-
import type { DriveService, SignedURLOptions } from '@adonisjs/drive/types';
|
|
8
|
-
import type { AttachmentAttributes, Attachment as AttachmentInterface, LucidOptions } from '../types/attachment.js';
|
|
9
|
-
import type { Input } from '../types/input.js';
|
|
10
|
-
import { AttachmentBase } from './attachment_base.js';
|
|
11
|
-
import { Variant } from './variant_attachment.js';
|
|
12
|
-
import { LucidRow } from '@adonisjs/lucid/types/model';
|
|
13
|
-
export declare class Attachment extends AttachmentBase implements AttachmentInterface {
|
|
14
|
-
originalName: string;
|
|
15
|
-
variants?: Variant[];
|
|
16
|
-
constructor(drive: DriveService, attributes: AttachmentAttributes, input?: Input);
|
|
17
|
-
/**
|
|
18
|
-
* Methods
|
|
19
|
-
*/
|
|
20
|
-
createVariant(key: string, input: Input, options?: {
|
|
21
|
-
basePath?: string;
|
|
22
|
-
ignoreFolder?: boolean;
|
|
23
|
-
}): Promise<Variant>;
|
|
24
|
-
getVariant(variantName: string): Variant | null;
|
|
25
|
-
getUrl(variantName?: string): Promise<string>;
|
|
26
|
-
getSignedUrl(variantNameOrOptions?: string | SignedURLOptions, signedUrlOptions?: SignedURLOptions): Promise<string>;
|
|
27
|
-
setOptions(options: LucidOptions): this;
|
|
28
|
-
/**
|
|
29
|
-
* Actions
|
|
30
|
-
*/
|
|
31
|
-
preComputeUrl(): Promise<void>;
|
|
32
|
-
makeName(record?: LucidRow, attributeName?: string): Promise<this>;
|
|
33
|
-
moveFileForDelete(): Promise<void>;
|
|
34
|
-
rollbackMoveFileForDelete(): Promise<void>;
|
|
35
|
-
remove(): Promise<void>;
|
|
36
|
-
/**
|
|
37
|
-
*
|
|
38
|
-
*/
|
|
39
|
-
toObject(): AttachmentAttributes;
|
|
40
|
-
toJSON(): Object;
|
|
41
|
-
}
|
|
42
|
-
//# sourceMappingURL=attachment.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"attachment.d.ts","sourceRoot":"","sources":["../../../src/attachments/attachment.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAC3E,OAAO,KAAK,EACV,oBAAoB,EACpB,UAAU,IAAI,mBAAmB,EACjC,YAAY,EACb,MAAM,wBAAwB,CAAA;AAC/B,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAG9C,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAA;AAEjD,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AAEtD,qBAAa,UAAW,SAAQ,cAAe,YAAW,mBAAmB;IAC3E,YAAY,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAA;gBAER,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,oBAAoB,EAAE,KAAK,CAAC,EAAE,KAAK;IAoBhF;;OAEG;IAEG,aAAa,CACjB,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,KAAK,EACZ,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,YAAY,CAAC,EAAE,OAAO,CAAA;KAAE,GACtD,OAAO,CAAC,OAAO,CAAC;IAoCnB,UAAU,CAAC,WAAW,EAAE,MAAM;IAIxB,MAAM,CAAC,WAAW,CAAC,EAAE,MAAM;IAe3B,YAAY,CAChB,oBAAoB,CAAC,EAAE,MAAM,GAAG,gBAAgB,EAChD,gBAAgB,CAAC,EAAE,gBAAgB;IAyBrC,UAAU,CAAC,OAAO,EAAE,YAAY;IAyBhC;;OAEG;IAEG,aAAa;IAgBb,QAAQ,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,aAAa,CAAC,EAAE,MAAM;IAIlD,iBAAiB;IAmBjB,yBAAyB;IAWzB,MAAM;IAgBZ;;OAEG;IAEH,QAAQ,IAAI,oBAAoB;IAWhC,MAAM,IAAI,MAAM;CAsCjB"}
|
|
@@ -1,233 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @jrmc/adonis-attachment
|
|
3
|
-
*
|
|
4
|
-
* @license MIT
|
|
5
|
-
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
-
*/
|
|
7
|
-
import path from 'node:path';
|
|
8
|
-
import { AttachmentBase } from './attachment_base.js';
|
|
9
|
-
import { Variant } from './variant_attachment.js';
|
|
10
|
-
import { metaFromBuffer, metaFromFile } from '../adapters/meta.js';
|
|
11
|
-
export class Attachment extends AttachmentBase {
|
|
12
|
-
originalName;
|
|
13
|
-
variants;
|
|
14
|
-
constructor(drive, attributes, input) {
|
|
15
|
-
super(drive, attributes, input);
|
|
16
|
-
this.originalName = attributes.originalName;
|
|
17
|
-
if (attributes.disk) {
|
|
18
|
-
this.disk = attributes.disk;
|
|
19
|
-
}
|
|
20
|
-
if (attributes.variants) {
|
|
21
|
-
this.variants = [];
|
|
22
|
-
attributes.variants.forEach((v) => {
|
|
23
|
-
const variant = new Variant(this.drive, v);
|
|
24
|
-
variant.disk = this.disk;
|
|
25
|
-
this.variants.push(variant);
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Methods
|
|
31
|
-
*/
|
|
32
|
-
async createVariant(key, input, options) {
|
|
33
|
-
let meta;
|
|
34
|
-
let folder;
|
|
35
|
-
if (Buffer.isBuffer(input)) {
|
|
36
|
-
meta = await metaFromBuffer(input);
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
meta = await metaFromFile(input, this.name);
|
|
40
|
-
}
|
|
41
|
-
if (options?.basePath && !options?.ignoreFolder) {
|
|
42
|
-
folder = path.join(options.basePath, this.folder, this.name);
|
|
43
|
-
}
|
|
44
|
-
else if (options?.basePath && options?.ignoreFolder) {
|
|
45
|
-
folder = path.join(options.basePath, this.name);
|
|
46
|
-
}
|
|
47
|
-
else if (options?.ignoreFolder) {
|
|
48
|
-
folder = this.name;
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
folder = path.join(this.folder, 'variants', this.name);
|
|
52
|
-
}
|
|
53
|
-
const attributes = {
|
|
54
|
-
...meta,
|
|
55
|
-
key,
|
|
56
|
-
folder,
|
|
57
|
-
};
|
|
58
|
-
const variant = new Variant(this.drive, attributes, input);
|
|
59
|
-
variant.setOptions(this.options);
|
|
60
|
-
if (this.variants === undefined) {
|
|
61
|
-
this.variants = [];
|
|
62
|
-
}
|
|
63
|
-
this.variants.push(variant);
|
|
64
|
-
return variant;
|
|
65
|
-
}
|
|
66
|
-
getVariant(variantName) {
|
|
67
|
-
return this.variants?.find((v) => v.key === variantName) ?? null;
|
|
68
|
-
}
|
|
69
|
-
async getUrl(variantName) {
|
|
70
|
-
if (variantName) {
|
|
71
|
-
const variant = this.getVariant(variantName);
|
|
72
|
-
if (variant) {
|
|
73
|
-
variant.setOptions(this.options);
|
|
74
|
-
const url = await variant.getUrl();
|
|
75
|
-
if (url) {
|
|
76
|
-
return url;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
return super.getUrl();
|
|
81
|
-
}
|
|
82
|
-
async getSignedUrl(variantNameOrOptions, signedUrlOptions) {
|
|
83
|
-
let variantName;
|
|
84
|
-
let options = signedUrlOptions;
|
|
85
|
-
if (typeof variantNameOrOptions === 'string') {
|
|
86
|
-
variantName = variantNameOrOptions;
|
|
87
|
-
}
|
|
88
|
-
else if (variantNameOrOptions && !signedUrlOptions) {
|
|
89
|
-
options = variantNameOrOptions;
|
|
90
|
-
}
|
|
91
|
-
if (variantName) {
|
|
92
|
-
const variant = this.getVariant(variantName);
|
|
93
|
-
if (variant) {
|
|
94
|
-
variant.setOptions(this.options);
|
|
95
|
-
const url = variant.getSignedUrl(options);
|
|
96
|
-
if (url) {
|
|
97
|
-
return url;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
return super.getSignedUrl(options);
|
|
102
|
-
}
|
|
103
|
-
setOptions(options) {
|
|
104
|
-
this.options = {
|
|
105
|
-
...this.options,
|
|
106
|
-
...options,
|
|
107
|
-
};
|
|
108
|
-
if (!this.disk && options?.disk) {
|
|
109
|
-
this.disk = options.disk;
|
|
110
|
-
}
|
|
111
|
-
if (this.variants) {
|
|
112
|
-
this.variants.forEach((v) => {
|
|
113
|
-
if (!v.disk) {
|
|
114
|
-
v.disk = this.disk;
|
|
115
|
-
}
|
|
116
|
-
v.setOptions({
|
|
117
|
-
...this.options,
|
|
118
|
-
variants: [],
|
|
119
|
-
});
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
return this;
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Actions
|
|
126
|
-
*/
|
|
127
|
-
async preComputeUrl() {
|
|
128
|
-
if (this.options?.preComputeUrl === false) {
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
131
|
-
await this.computeUrl();
|
|
132
|
-
if (this.variants) {
|
|
133
|
-
for (const key in this.variants) {
|
|
134
|
-
if (Object.prototype.hasOwnProperty.call(this.variants, key)) {
|
|
135
|
-
await this.variants[key].computeUrl();
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
async makeName(record, attributeName) {
|
|
141
|
-
return super.makeName(record, attributeName, this.originalName);
|
|
142
|
-
}
|
|
143
|
-
async moveFileForDelete() {
|
|
144
|
-
if (this.options && this.options.rename !== true) {
|
|
145
|
-
const originalPath = this.path;
|
|
146
|
-
this.name = `${this.name}.trash`;
|
|
147
|
-
const trashPath = this.path;
|
|
148
|
-
this.originalPath = trashPath;
|
|
149
|
-
try {
|
|
150
|
-
await this.getDisk().move(originalPath, trashPath);
|
|
151
|
-
}
|
|
152
|
-
catch {
|
|
153
|
-
// move() failed (e.g. S3 provider without ACL support): delete the original directly
|
|
154
|
-
// so the file is cleaned up without relying on the .trash mechanism
|
|
155
|
-
try {
|
|
156
|
-
await this.getDisk().delete(originalPath);
|
|
157
|
-
}
|
|
158
|
-
catch (_) { }
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
async rollbackMoveFileForDelete() {
|
|
163
|
-
if (this.options && this.options.rename !== true) {
|
|
164
|
-
const trashPath = this.path;
|
|
165
|
-
this.name = this.name.replace('.trash', '');
|
|
166
|
-
const originalPath = this.path;
|
|
167
|
-
this.originalPath = originalPath;
|
|
168
|
-
await this.getDisk().move(trashPath, originalPath);
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
async remove() {
|
|
172
|
-
await super.remove();
|
|
173
|
-
if (this.variants) {
|
|
174
|
-
for (const key in this.variants) {
|
|
175
|
-
if (Object.prototype.hasOwnProperty.call(this.variants, key)) {
|
|
176
|
-
await this.variants[key].remove();
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
// Try deleteAll to clean up empty directory (fs only), ignore errors on S3 providers
|
|
180
|
-
const variantPath = this.variants[0].folder;
|
|
181
|
-
try {
|
|
182
|
-
await this.getDisk().deleteAll(variantPath);
|
|
183
|
-
}
|
|
184
|
-
catch (_) { }
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
/**
|
|
188
|
-
*
|
|
189
|
-
*/
|
|
190
|
-
toObject() {
|
|
191
|
-
const variants = this.variants?.map((v) => v.toObject());
|
|
192
|
-
return {
|
|
193
|
-
...super.toObject(),
|
|
194
|
-
disk: this.disk,
|
|
195
|
-
originalName: this.originalName,
|
|
196
|
-
variants,
|
|
197
|
-
};
|
|
198
|
-
}
|
|
199
|
-
toJSON() {
|
|
200
|
-
const data = {
|
|
201
|
-
keyId: this.getKeyId(),
|
|
202
|
-
name: this.name,
|
|
203
|
-
originalName: this.originalName,
|
|
204
|
-
size: this.size,
|
|
205
|
-
extname: this.extname,
|
|
206
|
-
mimeType: this.mimeType,
|
|
207
|
-
meta: this.meta,
|
|
208
|
-
};
|
|
209
|
-
if (this.variants) {
|
|
210
|
-
this.variants.map(async (v) => {
|
|
211
|
-
data[v.key] = {
|
|
212
|
-
name: v.name,
|
|
213
|
-
extname: v.extname,
|
|
214
|
-
mimeType: v.mimeType,
|
|
215
|
-
meta: v.meta,
|
|
216
|
-
size: v.size,
|
|
217
|
-
blurhash: v.blurhash,
|
|
218
|
-
};
|
|
219
|
-
});
|
|
220
|
-
}
|
|
221
|
-
if (this.url) {
|
|
222
|
-
data.url = this.url;
|
|
223
|
-
}
|
|
224
|
-
if (this.variants) {
|
|
225
|
-
this.variants.map(async (v) => {
|
|
226
|
-
if (v.url) {
|
|
227
|
-
data[v.key].url = v.url;
|
|
228
|
-
}
|
|
229
|
-
});
|
|
230
|
-
}
|
|
231
|
-
return data;
|
|
232
|
-
}
|
|
233
|
-
}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @jrmc/adonis-attachment
|
|
3
|
-
*
|
|
4
|
-
* @license MIT
|
|
5
|
-
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
-
*/
|
|
7
|
-
import type { LucidRow } from '@adonisjs/lucid/types/model';
|
|
8
|
-
import type { DriveService, SignedURLOptions } from '@adonisjs/drive/types';
|
|
9
|
-
import type { LucidOptions, AttachmentBaseAttributes, AttachmentBase as AttachmentBaseInterface } from '../types/attachment.js';
|
|
10
|
-
import type { Exif, Input } from '../types/input.js';
|
|
11
|
-
export declare class AttachmentBase implements AttachmentBaseInterface {
|
|
12
|
-
#private;
|
|
13
|
-
drive: DriveService;
|
|
14
|
-
disk?: string;
|
|
15
|
-
input?: Input;
|
|
16
|
-
size: number;
|
|
17
|
-
extname: string;
|
|
18
|
-
mimeType: string;
|
|
19
|
-
meta?: Exif;
|
|
20
|
-
originalPath?: string;
|
|
21
|
-
url?: string;
|
|
22
|
-
options: LucidOptions;
|
|
23
|
-
constructor(drive: DriveService, attributes: AttachmentBaseAttributes, input?: Input);
|
|
24
|
-
/**
|
|
25
|
-
* Getters / Setters
|
|
26
|
-
*/
|
|
27
|
-
get name(): string;
|
|
28
|
-
set name(name: string);
|
|
29
|
-
get folder(): string | undefined;
|
|
30
|
-
get path(): string;
|
|
31
|
-
/**
|
|
32
|
-
* Methods
|
|
33
|
-
*/
|
|
34
|
-
getDisk(): import("flydrive").Disk;
|
|
35
|
-
getBytes(): Promise<Uint8Array<ArrayBufferLike>>;
|
|
36
|
-
getBuffer(): Promise<Buffer<ArrayBuffer>>;
|
|
37
|
-
getStream(): Promise<import("node:stream").Readable>;
|
|
38
|
-
getUrl(): Promise<string>;
|
|
39
|
-
getSignedUrl(signedUrlOptions?: SignedURLOptions): Promise<string>;
|
|
40
|
-
getKeyId(): string | undefined;
|
|
41
|
-
setKeyId(keyId: string): this;
|
|
42
|
-
setOptions(options: LucidOptions): this;
|
|
43
|
-
/**
|
|
44
|
-
* Actions
|
|
45
|
-
*/
|
|
46
|
-
computeUrl(signedUrlOptions?: SignedURLOptions): Promise<void>;
|
|
47
|
-
preComputeUrl(): Promise<void>;
|
|
48
|
-
makeName(record?: LucidRow, attributeName?: string, originalName?: string): Promise<this>;
|
|
49
|
-
makeFolder(record?: LucidRow): Promise<this>;
|
|
50
|
-
put(): Promise<void>;
|
|
51
|
-
remove(): Promise<void>;
|
|
52
|
-
/**
|
|
53
|
-
*
|
|
54
|
-
*/
|
|
55
|
-
toObject(): AttachmentBaseAttributes;
|
|
56
|
-
toDbString(): string;
|
|
57
|
-
toJSON(): Object;
|
|
58
|
-
}
|
|
59
|
-
//# sourceMappingURL=attachment_base.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"attachment_base.d.ts","sourceRoot":"","sources":["../../../src/attachments/attachment_base.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AAE3D,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAC3E,OAAO,KAAK,EACV,YAAY,EACZ,wBAAwB,EACxB,cAAc,IAAI,uBAAuB,EAC1C,MAAM,wBAAwB,CAAA;AAC/B,OAAO,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAOpD,qBAAa,cAAe,YAAW,uBAAuB;;IAC5D,KAAK,EAAE,YAAY,CAAA;IACnB,IAAI,CAAC,EAAE,MAAM,CAAA;IAEb,KAAK,CAAC,EAAE,KAAK,CAAA;IAMb,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,CAAC,EAAE,IAAI,CAAA;IACX,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,GAAG,CAAC,EAAE,MAAM,CAAA;IAEZ,OAAO,EAAE,YAAY,CAAA;gBAET,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,wBAAwB,EAAE,KAAK,CAAC,EAAE,KAAK;IAsBpF;;OAEG;IAEH,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,IAAI,IAAI,CAAC,IAAI,EAAE,MAAM,EAEpB;IAED,IAAI,MAAM,IAAI,MAAM,GAAG,SAAS,CAW/B;IAED,IAAI,IAAI,IAAI,MAAM,CAMjB;IAED;;OAEG;IAEH,OAAO;IAIP,QAAQ;IAIF,SAAS;IAKf,SAAS;IAIT,MAAM;IAIN,YAAY,CAAC,gBAAgB,CAAC,EAAE,gBAAgB;IAIhD,QAAQ;IAIR,QAAQ,CAAC,KAAK,EAAE,MAAM;IAKtB,UAAU,CAAC,OAAO,EAAE,YAAY;IAQhC;;OAEG;IAEG,UAAU,CAAC,gBAAgB,CAAC,EAAE,gBAAgB;IAW9C,aAAa;IAQb,QAAQ,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,aAAa,CAAC,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM;IA8BzE,UAAU,CAAC,MAAM,CAAC,EAAE,QAAQ;IA0B5B,GAAG;IAQH,MAAM;IASZ;;OAEG;IAEH,QAAQ,IAAI,wBAAwB;IAYpC,UAAU,IAAI,MAAM;IAKpB,MAAM,IAAI,MAAM;CAUjB"}
|
|
@@ -1,211 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @jrmc/adonis-attachment
|
|
3
|
-
*
|
|
4
|
-
* @license MIT
|
|
5
|
-
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
-
*/
|
|
7
|
-
import string from '@adonisjs/core/helpers/string';
|
|
8
|
-
import path from 'node:path';
|
|
9
|
-
import { uuid } from '../utils/helpers.js';
|
|
10
|
-
import { defaultOptionsDecorator } from '../utils/default_values.js';
|
|
11
|
-
import { extractPathParameters } from '../utils/helpers.js';
|
|
12
|
-
export class AttachmentBase {
|
|
13
|
-
drive;
|
|
14
|
-
disk;
|
|
15
|
-
input;
|
|
16
|
-
#keyId;
|
|
17
|
-
#name;
|
|
18
|
-
#folder;
|
|
19
|
-
size;
|
|
20
|
-
extname;
|
|
21
|
-
mimeType;
|
|
22
|
-
meta;
|
|
23
|
-
originalPath;
|
|
24
|
-
url;
|
|
25
|
-
options;
|
|
26
|
-
constructor(drive, attributes, input) {
|
|
27
|
-
this.input = input;
|
|
28
|
-
this.size = attributes.size;
|
|
29
|
-
this.meta = attributes.meta;
|
|
30
|
-
this.extname = attributes.extname;
|
|
31
|
-
this.mimeType = attributes.mimeType;
|
|
32
|
-
this.originalPath = attributes.path;
|
|
33
|
-
this.#folder = attributes.folder;
|
|
34
|
-
this.setOptions({ folder: attributes.folder });
|
|
35
|
-
if (attributes.name) {
|
|
36
|
-
this.#name = attributes.name;
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
this.#name = `${uuid()}.${this.extname}`;
|
|
40
|
-
}
|
|
41
|
-
this.options = defaultOptionsDecorator;
|
|
42
|
-
this.drive = drive;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Getters / Setters
|
|
46
|
-
*/
|
|
47
|
-
get name() {
|
|
48
|
-
return this.#name;
|
|
49
|
-
}
|
|
50
|
-
set name(name) {
|
|
51
|
-
this.#name = name;
|
|
52
|
-
}
|
|
53
|
-
get folder() {
|
|
54
|
-
if (this.#folder) {
|
|
55
|
-
return this.#folder;
|
|
56
|
-
}
|
|
57
|
-
if (typeof this.options.folder === 'string') {
|
|
58
|
-
const parameters = extractPathParameters(this.options.folder);
|
|
59
|
-
if (!parameters.length) {
|
|
60
|
-
return this.options.folder;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
get path() {
|
|
65
|
-
if (!this.folder && this.originalPath) {
|
|
66
|
-
return this.originalPath;
|
|
67
|
-
}
|
|
68
|
-
return path.join(this.folder, this.name);
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Methods
|
|
72
|
-
*/
|
|
73
|
-
getDisk() {
|
|
74
|
-
return this.drive.use(this.disk ?? this.options?.disk);
|
|
75
|
-
}
|
|
76
|
-
getBytes() {
|
|
77
|
-
return this.getDisk().getBytes(this.path);
|
|
78
|
-
}
|
|
79
|
-
async getBuffer() {
|
|
80
|
-
const arrayBuffer = await this.getBytes();
|
|
81
|
-
return Buffer.from(arrayBuffer);
|
|
82
|
-
}
|
|
83
|
-
getStream() {
|
|
84
|
-
return this.getDisk().getStream(this.path);
|
|
85
|
-
}
|
|
86
|
-
getUrl() {
|
|
87
|
-
return this.getDisk().getUrl(this.path);
|
|
88
|
-
}
|
|
89
|
-
getSignedUrl(signedUrlOptions) {
|
|
90
|
-
return this.getDisk().getSignedUrl(this.path, signedUrlOptions);
|
|
91
|
-
}
|
|
92
|
-
getKeyId() {
|
|
93
|
-
return this.#keyId;
|
|
94
|
-
}
|
|
95
|
-
setKeyId(keyId) {
|
|
96
|
-
this.#keyId = keyId;
|
|
97
|
-
return this;
|
|
98
|
-
}
|
|
99
|
-
setOptions(options) {
|
|
100
|
-
this.options = {
|
|
101
|
-
...this.options,
|
|
102
|
-
...options,
|
|
103
|
-
};
|
|
104
|
-
return this;
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Actions
|
|
108
|
-
*/
|
|
109
|
-
async computeUrl(signedUrlOptions) {
|
|
110
|
-
const disk = this.getDisk();
|
|
111
|
-
const fileVisibility = await disk.getVisibility(this.path);
|
|
112
|
-
if (fileVisibility === 'private') {
|
|
113
|
-
this.url = await this.getSignedUrl(signedUrlOptions);
|
|
114
|
-
}
|
|
115
|
-
else {
|
|
116
|
-
this.url = await this.getUrl();
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
async preComputeUrl() {
|
|
120
|
-
if (this.options?.preComputeUrl === false) {
|
|
121
|
-
return;
|
|
122
|
-
}
|
|
123
|
-
await this.computeUrl();
|
|
124
|
-
}
|
|
125
|
-
async makeName(record, attributeName, originalName) {
|
|
126
|
-
if (typeof this.options.rename === 'function' && record) {
|
|
127
|
-
this.#name = (await this.options.rename(record, attributeName, originalName));
|
|
128
|
-
}
|
|
129
|
-
else if (originalName && this.options.rename === false) {
|
|
130
|
-
this.#name = originalName;
|
|
131
|
-
}
|
|
132
|
-
if (this.#name && record) {
|
|
133
|
-
const parameters = extractPathParameters(this.#name);
|
|
134
|
-
if (parameters) {
|
|
135
|
-
parameters.forEach((parameter) => {
|
|
136
|
-
const attribute = record.$attributes[parameter];
|
|
137
|
-
if (typeof attribute === 'string') {
|
|
138
|
-
const name = string.slug(string.noCase(string.escapeHTML(attribute.toLowerCase())));
|
|
139
|
-
this.#name = this.#name?.replace(`:${parameter}`, name);
|
|
140
|
-
}
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
return this;
|
|
145
|
-
}
|
|
146
|
-
async makeFolder(record) {
|
|
147
|
-
if (typeof this.options.folder === 'function' && record) {
|
|
148
|
-
this.#folder = (await this.options.folder(record));
|
|
149
|
-
}
|
|
150
|
-
else if (this.options.folder) {
|
|
151
|
-
this.#folder = this.options.folder;
|
|
152
|
-
}
|
|
153
|
-
if (this.#folder && record) {
|
|
154
|
-
const parameters = extractPathParameters(this.#folder);
|
|
155
|
-
if (parameters) {
|
|
156
|
-
parameters.forEach((parameter) => {
|
|
157
|
-
const attribute = record.$attributes[parameter];
|
|
158
|
-
if (typeof attribute === 'string') {
|
|
159
|
-
const name = string.slug(string.noCase(string.escapeHTML(attribute.toLowerCase())));
|
|
160
|
-
this.#folder = this.#folder?.replace(`:${parameter}`, name);
|
|
161
|
-
}
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
return this;
|
|
166
|
-
}
|
|
167
|
-
async put() {
|
|
168
|
-
if (Buffer.isBuffer(this.input)) {
|
|
169
|
-
await this.getDisk().put(this.path, this.input);
|
|
170
|
-
}
|
|
171
|
-
else if (this.input) {
|
|
172
|
-
await this.getDisk().copyFromFs(this.input, this.path);
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
async remove() {
|
|
176
|
-
const pathsToDelete = new Set([this.path, this.originalPath].filter(Boolean));
|
|
177
|
-
for (const p of pathsToDelete) {
|
|
178
|
-
try {
|
|
179
|
-
await this.getDisk().delete(p);
|
|
180
|
-
}
|
|
181
|
-
catch (_) { }
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
/**
|
|
185
|
-
*
|
|
186
|
-
*/
|
|
187
|
-
toObject() {
|
|
188
|
-
return {
|
|
189
|
-
keyId: this.getKeyId(),
|
|
190
|
-
name: this.name,
|
|
191
|
-
extname: this.extname,
|
|
192
|
-
size: this.size,
|
|
193
|
-
meta: this.meta,
|
|
194
|
-
mimeType: this.mimeType,
|
|
195
|
-
path: this.path,
|
|
196
|
-
};
|
|
197
|
-
}
|
|
198
|
-
toDbString() {
|
|
199
|
-
const { keyId: _, ...obj } = this.toObject();
|
|
200
|
-
return JSON.stringify(obj);
|
|
201
|
-
}
|
|
202
|
-
toJSON() {
|
|
203
|
-
if (this.url) {
|
|
204
|
-
return {
|
|
205
|
-
...this.toObject(),
|
|
206
|
-
url: this.url,
|
|
207
|
-
};
|
|
208
|
-
}
|
|
209
|
-
return this.toObject();
|
|
210
|
-
}
|
|
211
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @jrmc/adonis-attachment
|
|
3
|
-
*
|
|
4
|
-
* @license MIT
|
|
5
|
-
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
-
*/
|
|
7
|
-
import type { DriveService } from '@adonisjs/drive/types';
|
|
8
|
-
import type { VariantAttributes, Variant as VariantInterface } from '../types/attachment.js';
|
|
9
|
-
import type { Input } from '../types/input.js';
|
|
10
|
-
import { AttachmentBase } from './attachment_base.js';
|
|
11
|
-
import { BlurhashOptions } from '../types/converter.js';
|
|
12
|
-
export declare class Variant extends AttachmentBase implements VariantInterface {
|
|
13
|
-
#private;
|
|
14
|
-
key: string;
|
|
15
|
-
blurhash?: string;
|
|
16
|
-
constructor(drive: DriveService, attributes: VariantAttributes, input?: Input);
|
|
17
|
-
generateBlurhash(options?: BlurhashOptions): Promise<void>;
|
|
18
|
-
/**
|
|
19
|
-
* Getters
|
|
20
|
-
*/
|
|
21
|
-
get folder(): string;
|
|
22
|
-
/**
|
|
23
|
-
*
|
|
24
|
-
*/
|
|
25
|
-
toObject(): VariantAttributes;
|
|
26
|
-
}
|
|
27
|
-
//# sourceMappingURL=variant_attachment.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"variant_attachment.d.ts","sourceRoot":"","sources":["../../../src/attachments/variant_attachment.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAC5F,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAE9C,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAGvD,qBAAa,OAAQ,SAAQ,cAAe,YAAW,gBAAgB;;IACrE,GAAG,EAAE,MAAM,CAAA;IAEX,QAAQ,CAAC,EAAE,MAAM,CAAA;gBAEL,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,iBAAiB,EAAE,KAAK,CAAC,EAAE,KAAK;IAQvE,gBAAgB,CAAC,OAAO,CAAC,EAAE,eAAe;IAIhD;;OAEG;IAEH,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED;;OAEG;IAEH,QAAQ,IAAI,iBAAiB;CAS9B"}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @jrmc/adonis-attachment
|
|
3
|
-
*
|
|
4
|
-
* @license MIT
|
|
5
|
-
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
-
*/
|
|
7
|
-
import { AttachmentBase } from './attachment_base.js';
|
|
8
|
-
import { imageToBlurhash } from '../utils/helpers.js';
|
|
9
|
-
export class Variant extends AttachmentBase {
|
|
10
|
-
key;
|
|
11
|
-
#folder;
|
|
12
|
-
blurhash;
|
|
13
|
-
constructor(drive, attributes, input) {
|
|
14
|
-
super(drive, attributes, input);
|
|
15
|
-
this.key = attributes.key;
|
|
16
|
-
this.#folder = attributes.folder;
|
|
17
|
-
this.blurhash = attributes.blurhash;
|
|
18
|
-
}
|
|
19
|
-
async generateBlurhash(options) {
|
|
20
|
-
this.blurhash = await imageToBlurhash(this.input, options);
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Getters
|
|
24
|
-
*/
|
|
25
|
-
get folder() {
|
|
26
|
-
return this.#folder;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
*
|
|
30
|
-
*/
|
|
31
|
-
toObject() {
|
|
32
|
-
return {
|
|
33
|
-
key: this.key,
|
|
34
|
-
folder: this.folder,
|
|
35
|
-
name: this.name,
|
|
36
|
-
blurhash: this.blurhash,
|
|
37
|
-
...super.toObject(),
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @jrmc/adonis-attachment
|
|
3
|
-
*
|
|
4
|
-
* @license MIT
|
|
5
|
-
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
-
*/
|
|
7
|
-
import type { ConverterAttributes } from '../types/converter.js';
|
|
8
|
-
import type { Input } from '../types/input.js';
|
|
9
|
-
import Converter from './converter.js';
|
|
10
|
-
export default class AutodetectConverter extends Converter {
|
|
11
|
-
handle({ input, options }: ConverterAttributes): Promise<Input | undefined>;
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=autodetect_converter.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"autodetect_converter.d.ts","sourceRoot":"","sources":["../../../src/converters/autodetect_converter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAChE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAG9C,OAAO,SAAS,MAAM,gBAAgB,CAAA;AAMtC,MAAM,CAAC,OAAO,OAAO,mBAAoB,SAAQ,SAAS;IAClD,MAAM,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,mBAAmB,GAAG,OAAO,CAAC,KAAK,GAAG,SAAS,CAAC;CAoElF"}
|