@jrmc/adonis-attachment 5.2.1 → 6.0.0-alpha.1
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 +26 -10
- package/build/index.d.ts.map +1 -1
- package/build/index.js +16 -9
- 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 +70 -0
- package/build/src/core/attachment.d.ts.map +1 -0
- package/build/src/core/attachment.js +150 -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_options.d.ts +32 -0
- package/build/src/core/attachment_options.d.ts.map +1 -0
- package/build/src/core/attachment_options.js +24 -0
- package/build/src/core/attachment_options.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 +34 -0
- package/build/src/core/attachment_service.d.ts.map +1 -0
- package/build/src/core/attachment_service.js +93 -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 +14 -0
- package/build/src/core/index.d.ts.map +1 -0
- package/build/src/core/index.js +11 -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 +39 -20
- package/build/src/define_config.d.ts.map +1 -1
- package/build/src/define_config.js +46 -24
- package/build/src/define_config.js.map +1 -0
- package/build/src/integrations/lucid/attachment_column.d.ts +18 -0
- package/build/src/integrations/lucid/attachment_column.d.ts.map +1 -0
- package/build/src/integrations/lucid/attachment_column.js +151 -0
- package/build/src/integrations/lucid/attachment_column.js.map +1 -0
- package/build/src/integrations/lucid/attachment_model.d.ts +37 -0
- package/build/src/integrations/lucid/attachment_model.d.ts.map +1 -0
- package/build/src/integrations/lucid/attachment_model.js +99 -0
- package/build/src/integrations/lucid/attachment_model.js.map +1 -0
- package/build/src/integrations/lucid/attachment_owner.d.ts +18 -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/attachment_relation.d.ts +60 -0
- package/build/src/integrations/lucid/attachment_relation.d.ts.map +1 -0
- package/build/src/integrations/lucid/attachment_relation.js +163 -0
- package/build/src/integrations/lucid/attachment_relation.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 +20 -0
- package/build/src/integrations/lucid/index.d.ts.map +1 -0
- package/build/src/integrations/lucid/index.js +20 -0
- package/build/src/integrations/lucid/index.js.map +1 -0
- package/build/src/integrations/lucid/lucid_attachment_lifecycle_service.d.ts +30 -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 +188 -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 +36 -0
- package/build/src/integrations/lucid/lucid_attachment_store.d.ts.map +1 -0
- package/build/src/integrations/lucid/lucid_attachment_store.js +179 -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 +64 -0
- package/build/src/integrations/lucid/migrate_legacy_attachment.d.ts.map +1 -0
- package/build/src/integrations/lucid/migrate_legacy_attachment.js +89 -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 +53 -0
- package/build/src/sources/attachment_manager.d.ts.map +1 -0
- package/build/src/sources/attachment_manager.js +177 -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 +39 -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 +131 -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_options.spec.d.ts +2 -0
- package/build/tests/attachment_options.spec.d.ts.map +1 -0
- package/build/tests/attachment_options.spec.js +31 -0
- package/build/tests/attachment_options.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 +146 -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 +66 -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 +203 -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 +52 -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_collection_store.spec.d.ts +2 -0
- package/build/tests/lucid_attachment_collection_store.spec.d.ts.map +1 -0
- package/build/tests/lucid_attachment_collection_store.spec.js +52 -0
- package/build/tests/lucid_attachment_collection_store.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 +193 -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 +378 -0
- package/build/tests/lucid_attachment_lifecycle_service.spec.js.map +1 -0
- package/build/tests/lucid_attachment_relation.spec.d.ts +8 -0
- package/build/tests/lucid_attachment_relation.spec.d.ts.map +1 -0
- package/build/tests/lucid_attachment_relation.spec.js +216 -0
- package/build/tests/lucid_attachment_relation.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 +73 -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 +133 -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 +82 -76
- 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,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @jrmc/adonis-attachment
|
|
3
|
-
*
|
|
4
|
-
* @license MIT
|
|
5
|
-
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
-
*/
|
|
7
|
-
import { Verrou } from '@verrou/core';
|
|
8
|
-
import { memoryStore } from '@verrou/core/drivers/memory';
|
|
9
|
-
export const verrou = (lock) => {
|
|
10
|
-
if (lock) {
|
|
11
|
-
return lock;
|
|
12
|
-
}
|
|
13
|
-
else {
|
|
14
|
-
return new Verrou({
|
|
15
|
-
default: 'memory',
|
|
16
|
-
stores: {
|
|
17
|
-
memory: { driver: memoryStore() },
|
|
18
|
-
},
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @jrmc/adonis-attachment
|
|
3
|
-
*
|
|
4
|
-
* @license MIT
|
|
5
|
-
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
-
*/
|
|
7
|
-
import { Meta } from '../types/input.js';
|
|
8
|
-
export declare function metaFromBuffer(input: Buffer): Promise<Meta>;
|
|
9
|
-
export declare function metaFromFile(input: string, filename: string): Promise<Meta>;
|
|
10
|
-
//# sourceMappingURL=meta.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"meta.d.ts","sourceRoot":"","sources":["../../../src/adapters/meta.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAA;AAuBxC,wBAAsB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAYjE;AAED,wBAAsB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAiBjF"}
|
|
@@ -1,49 +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 fs from 'node:fs/promises';
|
|
9
|
-
import { fileTypeFromBuffer, fileTypeFromFile } from 'file-type';
|
|
10
|
-
import mime from 'mime-types';
|
|
11
|
-
function getFileExtension(filename) {
|
|
12
|
-
if (!filename) {
|
|
13
|
-
return '';
|
|
14
|
-
}
|
|
15
|
-
const ext = path.extname(filename).slice(1);
|
|
16
|
-
return ext && /^[a-zA-Z0-9]+$/.test(ext) ? ext : '';
|
|
17
|
-
}
|
|
18
|
-
function metaByFileName(filename) {
|
|
19
|
-
return {
|
|
20
|
-
ext: getFileExtension(filename),
|
|
21
|
-
mime: mime.lookup(filename) || '',
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
export async function metaFromBuffer(input) {
|
|
25
|
-
let fileType = await fileTypeFromBuffer(input);
|
|
26
|
-
if (input.toString('utf8').includes('<svg')) {
|
|
27
|
-
fileType = { mime: 'image/svg+xml', ext: 'svg' };
|
|
28
|
-
}
|
|
29
|
-
return {
|
|
30
|
-
extname: fileType?.ext || '',
|
|
31
|
-
mimeType: fileType?.mime || '',
|
|
32
|
-
size: input.length,
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
export async function metaFromFile(input, filename) {
|
|
36
|
-
let fileType;
|
|
37
|
-
let size = 0;
|
|
38
|
-
fileType = metaByFileName(filename);
|
|
39
|
-
if (fileType.ext === '' || fileType.mime === '') {
|
|
40
|
-
fileType = await fileTypeFromFile(input);
|
|
41
|
-
}
|
|
42
|
-
const stats = await fs.stat(input);
|
|
43
|
-
size = stats.size;
|
|
44
|
-
return {
|
|
45
|
-
extname: fileType?.ext || '',
|
|
46
|
-
mimeType: fileType?.mime || '',
|
|
47
|
-
size,
|
|
48
|
-
};
|
|
49
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @jrmc/adonis-attachment
|
|
3
|
-
*
|
|
4
|
-
* @license MIT
|
|
5
|
-
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
-
*/
|
|
7
|
-
import { PopplerMetadata } from '../types/metadata.js';
|
|
8
|
-
export default class Poppler {
|
|
9
|
-
#private;
|
|
10
|
-
private input;
|
|
11
|
-
constructor(input: string);
|
|
12
|
-
pdfToPpm(options: {
|
|
13
|
-
page: number;
|
|
14
|
-
dpi: number;
|
|
15
|
-
}): Promise<string>;
|
|
16
|
-
pdfInfo(): Promise<PopplerMetadata>;
|
|
17
|
-
setPdfToPpmPath(pdftoppm: string): Promise<void>;
|
|
18
|
-
setPdfInfoPath(pdfinfo: string): Promise<void>;
|
|
19
|
-
}
|
|
20
|
-
//# sourceMappingURL=poppler.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"poppler.d.ts","sourceRoot":"","sources":["../../../src/adapters/poppler.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAGtD,MAAM,CAAC,OAAO,OAAO,OAAO;;IAMd,OAAO,CAAC,KAAK;gBAAL,KAAK,EAAE,MAAM;IAuB3B,QAAQ,CAAC,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE;IAuB/C,OAAO,IAAI,OAAO,CAAC,eAAe,CAAC;IA0DnC,eAAe,CAAC,QAAQ,EAAE,MAAM;IAIhC,cAAc,CAAC,OAAO,EAAE,MAAM;CAGrC"}
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @jrmc/adonis-attachment
|
|
3
|
-
*
|
|
4
|
-
* @license MIT
|
|
5
|
-
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
-
*/
|
|
7
|
-
import os from 'node:os';
|
|
8
|
-
import path from 'node:path';
|
|
9
|
-
import { $ } from 'execa';
|
|
10
|
-
import { uuid } from '../utils/helpers.js';
|
|
11
|
-
import logger from '@adonisjs/core/services/logger';
|
|
12
|
-
import { attachmentManager } from '@jrmc/adonis-attachment';
|
|
13
|
-
import { DateTime } from 'luxon';
|
|
14
|
-
export default class Poppler {
|
|
15
|
-
input;
|
|
16
|
-
#pdfToPpmPath;
|
|
17
|
-
#pdfInfoPath;
|
|
18
|
-
#timeout;
|
|
19
|
-
#TIMEOUT;
|
|
20
|
-
constructor(input) {
|
|
21
|
-
this.input = input;
|
|
22
|
-
this.#pdfToPpmPath = 'pdftoppm';
|
|
23
|
-
this.#pdfInfoPath = 'pdfinfo';
|
|
24
|
-
this.#timeout = null;
|
|
25
|
-
this.#TIMEOUT = attachmentManager.getConfig().timeout || 30_000;
|
|
26
|
-
}
|
|
27
|
-
#createAbortController() {
|
|
28
|
-
this.#cleanup();
|
|
29
|
-
const controller = new AbortController();
|
|
30
|
-
this.#timeout = setTimeout(() => {
|
|
31
|
-
controller.abort();
|
|
32
|
-
}, this.#TIMEOUT);
|
|
33
|
-
return controller;
|
|
34
|
-
}
|
|
35
|
-
#cleanup() {
|
|
36
|
-
if (this.#timeout) {
|
|
37
|
-
clearTimeout(this.#timeout);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
async pdfToPpm(options) {
|
|
41
|
-
const output = path.join(os.tmpdir(), uuid());
|
|
42
|
-
try {
|
|
43
|
-
await $({
|
|
44
|
-
cancelSignal: this.#createAbortController().signal,
|
|
45
|
-
gracefulCancel: true,
|
|
46
|
-
timeout: this.#TIMEOUT,
|
|
47
|
-
}) `${this.#pdfToPpmPath} -f ${options.page.toString()} -l ${options.page.toString()} -r ${options.dpi.toString()} -jpeg ${this.input} ${output}`;
|
|
48
|
-
const pdfInfo = await this.pdfInfo();
|
|
49
|
-
const pageNumberFormat = '0'.repeat(String(pdfInfo.pages).length - String(options.page).length);
|
|
50
|
-
return `${output}-${pageNumberFormat}${options.page}.jpg`;
|
|
51
|
-
}
|
|
52
|
-
catch (error) {
|
|
53
|
-
logger.error('Error while converting PDF to PPM:', error);
|
|
54
|
-
throw error;
|
|
55
|
-
}
|
|
56
|
-
finally {
|
|
57
|
-
this.#cleanup();
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
async pdfInfo() {
|
|
61
|
-
try {
|
|
62
|
-
const { stdout } = await $({
|
|
63
|
-
cancelSignal: this.#createAbortController().signal,
|
|
64
|
-
gracefulCancel: true,
|
|
65
|
-
timeout: this.#TIMEOUT,
|
|
66
|
-
}) `${this.#pdfInfoPath} ${this.input}`;
|
|
67
|
-
const metadata = {};
|
|
68
|
-
stdout.split('\n').forEach((line) => {
|
|
69
|
-
const colonIndex = line.indexOf(':');
|
|
70
|
-
if (colonIndex > 0) {
|
|
71
|
-
const key = line.substring(0, colonIndex).trim();
|
|
72
|
-
const value = line.substring(colonIndex + 1).trim();
|
|
73
|
-
if (key && value) {
|
|
74
|
-
metadata[key.toLowerCase()] = value;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
const pageSizeMatch = metadata['page size']?.match(/(\d+)\s*x\s*(\d+)/);
|
|
79
|
-
const [width, height] = pageSizeMatch
|
|
80
|
-
? [parseInt(pageSizeMatch[1]), parseInt(pageSizeMatch[2])]
|
|
81
|
-
: [0, 0];
|
|
82
|
-
const fileSizeMatch = metadata['file size']?.match(/(\d+)/);
|
|
83
|
-
const size = fileSizeMatch ? parseInt(fileSizeMatch[1]) : 0;
|
|
84
|
-
const version = metadata['pdf version'] || '';
|
|
85
|
-
const pages = parseInt(metadata['pages'] || '0');
|
|
86
|
-
let creationDate = '';
|
|
87
|
-
if (metadata['creationdate']) {
|
|
88
|
-
const dateStr = metadata['creationdate'];
|
|
89
|
-
const date = DateTime.fromFormat(dateStr, 'EEE MMM dd HH:mm:ss yyyy z', { zone: 'UTC' });
|
|
90
|
-
if (date.isValid) {
|
|
91
|
-
creationDate = date.toFormat("yyyy-MM-dd'T'HH:mm:ss");
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
return {
|
|
95
|
-
size,
|
|
96
|
-
version,
|
|
97
|
-
width,
|
|
98
|
-
height,
|
|
99
|
-
pages,
|
|
100
|
-
creationDate,
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
catch (error) {
|
|
104
|
-
logger.error('Error while retrieving metadata:', error);
|
|
105
|
-
throw error;
|
|
106
|
-
}
|
|
107
|
-
finally {
|
|
108
|
-
this.#cleanup();
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
async setPdfToPpmPath(pdftoppm) {
|
|
112
|
-
this.#pdfToPpmPath = pdftoppm;
|
|
113
|
-
}
|
|
114
|
-
async setPdfInfoPath(pdfinfo) {
|
|
115
|
-
this.#pdfInfoPath = pdfinfo;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @jrmc/adonis-attachment
|
|
3
|
-
*
|
|
4
|
-
* @license MIT
|
|
5
|
-
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
-
*/
|
|
7
|
-
export default class Soffice {
|
|
8
|
-
#private;
|
|
9
|
-
private input;
|
|
10
|
-
constructor(input: string);
|
|
11
|
-
convert(): Promise<string>;
|
|
12
|
-
setSofficePath(sofficePath: string): Promise<void>;
|
|
13
|
-
}
|
|
14
|
-
//# sourceMappingURL=soffice.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"soffice.d.ts","sourceRoot":"","sources":["../../../src/adapters/soffice.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH,MAAM,CAAC,OAAO,OAAO,OAAO;;IAKd,OAAO,CAAC,KAAK;gBAAL,KAAK,EAAE,MAAM;IAsB3B,OAAO;IA2BP,cAAc,CAAC,WAAW,EAAE,MAAM;CAGzC"}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @jrmc/adonis-attachment
|
|
3
|
-
*
|
|
4
|
-
* @license MIT
|
|
5
|
-
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
-
*/
|
|
7
|
-
import os from 'node:os';
|
|
8
|
-
import path from 'node:path';
|
|
9
|
-
import { $ } from 'execa';
|
|
10
|
-
import logger from '@adonisjs/core/services/logger';
|
|
11
|
-
import { attachmentManager } from '@jrmc/adonis-attachment';
|
|
12
|
-
export default class Soffice {
|
|
13
|
-
input;
|
|
14
|
-
#sofficePath;
|
|
15
|
-
#timeout;
|
|
16
|
-
#TIMEOUT;
|
|
17
|
-
constructor(input) {
|
|
18
|
-
this.input = input;
|
|
19
|
-
this.#sofficePath = 'soffice';
|
|
20
|
-
this.#timeout = null;
|
|
21
|
-
this.#TIMEOUT = attachmentManager.getConfig().timeout || 30_000;
|
|
22
|
-
}
|
|
23
|
-
#createAbortController() {
|
|
24
|
-
this.#cleanup();
|
|
25
|
-
const controller = new AbortController();
|
|
26
|
-
this.#timeout = setTimeout(() => {
|
|
27
|
-
controller.abort();
|
|
28
|
-
}, this.#TIMEOUT);
|
|
29
|
-
return controller;
|
|
30
|
-
}
|
|
31
|
-
#cleanup() {
|
|
32
|
-
if (this.#timeout) {
|
|
33
|
-
clearTimeout(this.#timeout);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
async convert() {
|
|
37
|
-
const output = os.tmpdir();
|
|
38
|
-
try {
|
|
39
|
-
const { stderr } = await $({
|
|
40
|
-
cancelSignal: this.#createAbortController().signal,
|
|
41
|
-
gracefulCancel: true,
|
|
42
|
-
timeout: this.#TIMEOUT,
|
|
43
|
-
}) `${this.#sofficePath} --headless --writer --convert-to jpg ${this.input} --outdir ${output}`;
|
|
44
|
-
if (stderr) {
|
|
45
|
-
logger.error('Error while converting Document to Image:', stderr);
|
|
46
|
-
throw stderr;
|
|
47
|
-
}
|
|
48
|
-
const ext = path.extname(this.input);
|
|
49
|
-
const baseName = path.basename(this.input, ext);
|
|
50
|
-
const imagePath = path.join(output, baseName + '.jpg');
|
|
51
|
-
return imagePath;
|
|
52
|
-
}
|
|
53
|
-
catch (error) {
|
|
54
|
-
logger.error('Error while converting Document to Image:', error);
|
|
55
|
-
throw error;
|
|
56
|
-
}
|
|
57
|
-
finally {
|
|
58
|
-
this.#cleanup();
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
async setSofficePath(sofficePath) {
|
|
62
|
-
this.#sofficePath = sofficePath;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @jrmc/adonis-attachment
|
|
3
|
-
*
|
|
4
|
-
* @license MIT
|
|
5
|
-
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
-
*/
|
|
7
|
-
import type { SignedURLOptions } from '@adonisjs/drive/types';
|
|
8
|
-
import type { MultipartFile } from '@adonisjs/core/bodyparser';
|
|
9
|
-
import type { LockService } from './types/lock.js';
|
|
10
|
-
import type { Drive } from './types/drive.js';
|
|
11
|
-
import type { AttachmentAttributes, AttachmentBase, Attachment as AttachmentType } from './types/attachment.js';
|
|
12
|
-
import type { ResolvedAttachmentConfig } from './define_config.js';
|
|
13
|
-
import { DeferQueue } from '@poppinss/defer';
|
|
14
|
-
import Converter from './converters/converter.js';
|
|
15
|
-
export declare class AttachmentManager<KnownConverters extends Record<string, Converter>> {
|
|
16
|
-
#private;
|
|
17
|
-
queue: DeferQueue;
|
|
18
|
-
constructor(config: ResolvedAttachmentConfig<KnownConverters>, drive: Drive, lock: LockService);
|
|
19
|
-
createFromDbResponse(response?: string | JSON): AttachmentType | null;
|
|
20
|
-
createFromFile(input: MultipartFile): Promise<AttachmentType>;
|
|
21
|
-
createFromFiles(inputs: MultipartFile[]): Promise<(AttachmentBase & {
|
|
22
|
-
originalName: string;
|
|
23
|
-
variants?: import("./types/attachment.js").Variant[];
|
|
24
|
-
createVariant(key: string, input: import("./types/input.js").Input, options?: {
|
|
25
|
-
basePath?: string;
|
|
26
|
-
ignoreFolder?: boolean;
|
|
27
|
-
}): Promise<import("./types/attachment.js").Variant>;
|
|
28
|
-
getVariant(variantName: string): import("./types/attachment.js").Variant | null;
|
|
29
|
-
getUrl(variantName?: string): Promise<string>;
|
|
30
|
-
getSignedUrl(variantNameOrOptions?: string | SignedURLOptions, signedUrlOptions?: SignedURLOptions): Promise<string>;
|
|
31
|
-
preComputeUrl(): Promise<void>;
|
|
32
|
-
moveFileForDelete(): Promise<void>;
|
|
33
|
-
rollbackMoveFileForDelete(): Promise<void>;
|
|
34
|
-
remove(): Promise<void>;
|
|
35
|
-
toObject(): AttachmentAttributes;
|
|
36
|
-
})[]>;
|
|
37
|
-
createFromPath(input: string, name?: string): Promise<AttachmentType>;
|
|
38
|
-
createFromBuffer(input: Buffer, name?: string): Promise<AttachmentType>;
|
|
39
|
-
createFromBase64(input: string, name?: string): Promise<AttachmentType>;
|
|
40
|
-
createFromUrl(input: URL, name?: string): Promise<AttachmentType>;
|
|
41
|
-
createFromStream(stream: NodeJS.ReadableStream, name?: string): Promise<AttachmentType>;
|
|
42
|
-
computeUrl(attachment: AttachmentType | AttachmentBase, signedUrlOptions?: SignedURLOptions): Promise<void>;
|
|
43
|
-
preComputeUrl(attachment: AttachmentType): Promise<void>;
|
|
44
|
-
write(attachment: AttachmentBase): Promise<void>;
|
|
45
|
-
remove(attachment: AttachmentBase): Promise<void>;
|
|
46
|
-
get lock(): LockService;
|
|
47
|
-
getConfig(): ResolvedAttachmentConfig<KnownConverters>;
|
|
48
|
-
getConverter(key: string): Promise<void | Converter>;
|
|
49
|
-
}
|
|
50
|
-
//# sourceMappingURL=attachment_manager.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"attachment_manager.d.ts","sourceRoot":"","sources":["../../src/attachment_manager.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAC7D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAC9D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAClD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AAE7C,OAAO,KAAK,EACV,oBAAoB,EACpB,cAAc,EACd,UAAU,IAAI,cAAc,EAC7B,MAAM,uBAAuB,CAAA;AAC9B,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAA;AAGlE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAG5C,OAAO,SAAS,MAAM,2BAA2B,CAAA;AAQjD,qBAAa,iBAAiB,CAAC,eAAe,SAAS,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC;;IAC9E,KAAK,aAAA;gBAKO,MAAM,EAAE,wBAAwB,CAAC,eAAe,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,WAAW;IAU9F,oBAAoB,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI;IAiBvC,cAAc,CAAC,KAAK,EAAE,aAAa;IAgBnC,eAAe,CAAC,MAAM,EAAE,aAAa,EAAE;;;;oBA5BxC,CAAC;wBAAsB,CAAC;;;;;;;;;;;IAgCvB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM;IAiB3C,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM;IAgB7C,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM;IAW7C,aAAa,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE,MAAM;IAMvC,gBAAgB,CAAC,MAAM,EAAE,MAAM,CAAC,cAAc,EAAE,IAAI,CAAC,EAAE,MAAM;IAM7D,UAAU,CACd,UAAU,EAAE,cAAc,GAAG,cAAc,EAC3C,gBAAgB,CAAC,EAAE,gBAAgB;IAK/B,aAAa,CAAC,UAAU,EAAE,cAAc;IAIxC,KAAK,CAAC,UAAU,EAAE,cAAc;IAchC,MAAM,CAAC,UAAU,EAAE,cAAc;IAMvC,IAAI,IAAI,gBAEP;IAED,SAAS;IAIH,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,GAAG,SAAS,CAAC;CAuB3D"}
|
|
@@ -1,145 +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 { DeferQueue } from '@poppinss/defer';
|
|
9
|
-
import * as errors from './errors.js';
|
|
10
|
-
import { Attachment } from './attachments/attachment.js';
|
|
11
|
-
import { downloadToTempFile, isBase64, streamToTempFile } from './utils/helpers.js';
|
|
12
|
-
import ExifAdapter from './adapters/exif.js';
|
|
13
|
-
import { metaFromBuffer, metaFromFile } from './adapters/meta.js';
|
|
14
|
-
import { uuid } from './utils/helpers.js';
|
|
15
|
-
const REQUIRED_ATTRIBUTES = ['name', 'size', 'extname', 'mimeType'];
|
|
16
|
-
export class AttachmentManager {
|
|
17
|
-
queue;
|
|
18
|
-
#config;
|
|
19
|
-
#drive;
|
|
20
|
-
#lock;
|
|
21
|
-
constructor(config, drive, lock) {
|
|
22
|
-
this.#drive = drive;
|
|
23
|
-
this.#lock = lock;
|
|
24
|
-
this.#config = config;
|
|
25
|
-
const concurrency = this.#config.queue?.concurrency || 1;
|
|
26
|
-
this.queue = new DeferQueue({ concurrency });
|
|
27
|
-
}
|
|
28
|
-
createFromDbResponse(response) {
|
|
29
|
-
if (response === null) {
|
|
30
|
-
return null;
|
|
31
|
-
}
|
|
32
|
-
const attributes = typeof response === 'string' ? JSON.parse(response) : response;
|
|
33
|
-
REQUIRED_ATTRIBUTES.forEach((attribute) => {
|
|
34
|
-
if (attributes[attribute] === undefined) {
|
|
35
|
-
throw new errors.E_CANNOT_CREATE_ATTACHMENT([attribute]);
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
const attachment = new Attachment(this.#drive.driveManager, attributes);
|
|
39
|
-
return this.#configureAttachment(attachment);
|
|
40
|
-
}
|
|
41
|
-
async createFromFile(input) {
|
|
42
|
-
const attributes = {
|
|
43
|
-
originalName: input.clientName,
|
|
44
|
-
extname: input.extname || '',
|
|
45
|
-
mimeType: input.type && input.subtype ? `${input.type}/${input.subtype}` : '',
|
|
46
|
-
size: input.size,
|
|
47
|
-
};
|
|
48
|
-
if (!input.tmpPath) {
|
|
49
|
-
throw new errors.ENOENT();
|
|
50
|
-
}
|
|
51
|
-
const attachment = new Attachment(this.#drive.driveManager, attributes, input.tmpPath);
|
|
52
|
-
return this.#configureAttachment(attachment);
|
|
53
|
-
}
|
|
54
|
-
async createFromFiles(inputs) {
|
|
55
|
-
return Promise.all(inputs.map((input) => this.createFromFile(input)));
|
|
56
|
-
}
|
|
57
|
-
async createFromPath(input, name) {
|
|
58
|
-
const meta = await metaFromFile(input, name || input);
|
|
59
|
-
if (meta.extname === '') {
|
|
60
|
-
meta.extname = 'tmp';
|
|
61
|
-
meta.mimeType = 'application/x-temp';
|
|
62
|
-
}
|
|
63
|
-
const attributes = {
|
|
64
|
-
...meta,
|
|
65
|
-
originalName: name?.replace('tmp', meta.extname) || path.basename(input),
|
|
66
|
-
};
|
|
67
|
-
const attachment = new Attachment(this.#drive.driveManager, attributes, input);
|
|
68
|
-
return this.#configureAttachment(attachment);
|
|
69
|
-
}
|
|
70
|
-
async createFromBuffer(input, name) {
|
|
71
|
-
if (!Buffer.isBuffer(input)) {
|
|
72
|
-
throw new errors.E_ISNOT_BUFFER();
|
|
73
|
-
}
|
|
74
|
-
const meta = await metaFromBuffer(input);
|
|
75
|
-
const ext = meta.extname || 'tmp';
|
|
76
|
-
const attributes = {
|
|
77
|
-
...meta,
|
|
78
|
-
originalName: name || `${uuid()}.${ext}`,
|
|
79
|
-
};
|
|
80
|
-
const attachment = new Attachment(this.#drive.driveManager, attributes, input);
|
|
81
|
-
return this.#configureAttachment(attachment);
|
|
82
|
-
}
|
|
83
|
-
async createFromBase64(input, name) {
|
|
84
|
-
const base64Data = input.replace(/^data:([A-Za-z-+\/]+);base64,/, '');
|
|
85
|
-
if (!isBase64(base64Data)) {
|
|
86
|
-
throw new errors.E_ISNOT_BASE64();
|
|
87
|
-
}
|
|
88
|
-
const buffer = Buffer.from(base64Data, 'base64');
|
|
89
|
-
return this.createFromBuffer(buffer, name);
|
|
90
|
-
}
|
|
91
|
-
async createFromUrl(input, name) {
|
|
92
|
-
const tmpPath = await downloadToTempFile(input);
|
|
93
|
-
return this.createFromPath(tmpPath, name || path.basename(input.pathname));
|
|
94
|
-
}
|
|
95
|
-
async createFromStream(stream, name) {
|
|
96
|
-
const tmpPath = await streamToTempFile(stream);
|
|
97
|
-
return this.createFromPath(tmpPath, name || path.basename(tmpPath));
|
|
98
|
-
}
|
|
99
|
-
async computeUrl(attachment, signedUrlOptions) {
|
|
100
|
-
await attachment.computeUrl(signedUrlOptions);
|
|
101
|
-
}
|
|
102
|
-
async preComputeUrl(attachment) {
|
|
103
|
-
await attachment.preComputeUrl();
|
|
104
|
-
}
|
|
105
|
-
async write(attachment) {
|
|
106
|
-
if (attachment.options?.meta) {
|
|
107
|
-
attachment.meta = await ExifAdapter.exif(attachment.input, this.#config);
|
|
108
|
-
}
|
|
109
|
-
else {
|
|
110
|
-
attachment.meta = undefined;
|
|
111
|
-
}
|
|
112
|
-
if (this.#drive.diskDefault !== undefined && attachment.disk === undefined) {
|
|
113
|
-
attachment.setOptions({ disk: attachment.options?.disk ?? this.#drive.diskDefault });
|
|
114
|
-
}
|
|
115
|
-
await attachment.put();
|
|
116
|
-
}
|
|
117
|
-
async remove(attachment) {
|
|
118
|
-
await attachment.remove();
|
|
119
|
-
}
|
|
120
|
-
// getters
|
|
121
|
-
get lock() {
|
|
122
|
-
return this.#lock;
|
|
123
|
-
}
|
|
124
|
-
getConfig() {
|
|
125
|
-
return this.#config;
|
|
126
|
-
}
|
|
127
|
-
async getConverter(key) {
|
|
128
|
-
if (this.#config.converters) {
|
|
129
|
-
return this.#config.converters[key];
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
// private methods
|
|
133
|
-
#configureAttachment(attachment) {
|
|
134
|
-
if (this.#config.meta !== undefined) {
|
|
135
|
-
attachment.setOptions({ meta: this.#config.meta });
|
|
136
|
-
}
|
|
137
|
-
if (this.#config.rename !== undefined) {
|
|
138
|
-
attachment.setOptions({ rename: this.#config.rename });
|
|
139
|
-
}
|
|
140
|
-
if (this.#config.preComputeUrl !== undefined) {
|
|
141
|
-
attachment.setOptions({ preComputeUrl: this.#config.preComputeUrl });
|
|
142
|
-
}
|
|
143
|
-
return attachment;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
@@ -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"}
|