@jrmc/adonis-attachment 5.2.0 → 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 -73
- 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 +82 -78
- 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
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jrmc/adonis-attachment
|
|
3
|
+
*
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
+
*/
|
|
7
|
+
import type { ApplicationService } from '@adonisjs/core/types';
|
|
8
|
+
import type { AttachmentStorage, StorageLocation, WriteAttachmentInput } from '../core/storage.js';
|
|
9
|
+
export type LocalFileStorageOptions = {
|
|
10
|
+
location: string;
|
|
11
|
+
disk?: string;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Stores attachment bytes on the local filesystem without requiring Drive.
|
|
15
|
+
*/
|
|
16
|
+
export declare class LocalFileStorage implements AttachmentStorage {
|
|
17
|
+
#private;
|
|
18
|
+
readonly defaultDisk: string;
|
|
19
|
+
constructor(options: LocalFileStorageOptions);
|
|
20
|
+
static fromApp(app: ApplicationService): LocalFileStorage;
|
|
21
|
+
write(input: WriteAttachmentInput): Promise<void>;
|
|
22
|
+
read(location: StorageLocation): Promise<Uint8Array>;
|
|
23
|
+
remove(location: StorageLocation): Promise<void>;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=local_file_storage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local_file_storage.d.ts","sourceRoot":"","sources":["../../../src/adapters/local_file_storage.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AAE9D,OAAO,KAAK,EAAE,iBAAiB,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAA;AAElG,MAAM,MAAM,uBAAuB,GAAG;IACpC,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,CAAC,EAAE,MAAM,CAAA;CACd,CAAA;AAED;;GAEG;AACH,qBAAa,gBAAiB,YAAW,iBAAiB;;IAExD,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;gBAEhB,OAAO,EAAE,uBAAuB;IAK5C,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,kBAAkB,GAAG,gBAAgB;IAInD,KAAK,CAAC,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;IAejD,IAAI,CAAC,QAAQ,EAAE,eAAe,GAAG,OAAO,CAAC,UAAU,CAAC;IAIpD,MAAM,CAAC,QAAQ,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;CAkBvD"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jrmc/adonis-attachment
|
|
3
|
+
*
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
+
*/
|
|
7
|
+
import { mkdir, readFile, rename, rm, writeFile } from 'node:fs/promises';
|
|
8
|
+
import { dirname, relative, resolve, sep } from 'node:path';
|
|
9
|
+
import { randomUUID } from 'node:crypto';
|
|
10
|
+
/**
|
|
11
|
+
* Stores attachment bytes on the local filesystem without requiring Drive.
|
|
12
|
+
*/
|
|
13
|
+
export class LocalFileStorage {
|
|
14
|
+
#location;
|
|
15
|
+
defaultDisk;
|
|
16
|
+
constructor(options) {
|
|
17
|
+
this.#location = resolve(options.location);
|
|
18
|
+
this.defaultDisk = options.disk ?? 'fs';
|
|
19
|
+
}
|
|
20
|
+
static fromApp(app) {
|
|
21
|
+
return new LocalFileStorage({ location: app.makePath('storage/attachments') });
|
|
22
|
+
}
|
|
23
|
+
async write(input) {
|
|
24
|
+
const filePath = this.#resolve(input);
|
|
25
|
+
const temporaryPath = `${filePath}.${randomUUID()}.tmp`;
|
|
26
|
+
await mkdir(dirname(filePath), { recursive: true });
|
|
27
|
+
try {
|
|
28
|
+
await writeFile(temporaryPath, input.body);
|
|
29
|
+
await rename(temporaryPath, filePath);
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
await rm(temporaryPath, { force: true }).catch(() => undefined);
|
|
33
|
+
throw error;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
async read(location) {
|
|
37
|
+
return new Uint8Array(await readFile(this.#resolve(location)));
|
|
38
|
+
}
|
|
39
|
+
async remove(location) {
|
|
40
|
+
await rm(this.#resolve(location), { force: true });
|
|
41
|
+
}
|
|
42
|
+
#resolve(location) {
|
|
43
|
+
if (location.disk !== this.defaultDisk) {
|
|
44
|
+
throw new Error(`LocalFileStorage cannot access the "${location.disk}" disk`);
|
|
45
|
+
}
|
|
46
|
+
const filePath = resolve(this.#location, location.path);
|
|
47
|
+
const pathFromRoot = relative(this.#location, filePath);
|
|
48
|
+
if (!pathFromRoot || pathFromRoot === '..' || pathFromRoot.startsWith(`..${sep}`)) {
|
|
49
|
+
throw new Error('Attachment paths must stay inside the local storage directory');
|
|
50
|
+
}
|
|
51
|
+
return filePath;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=local_file_storage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local_file_storage.js","sourceRoot":"","sources":["../../../src/adapters/local_file_storage.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACzE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAA;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAWxC;;GAEG;AACH,MAAM,OAAO,gBAAgB;IAClB,SAAS,CAAQ;IACjB,WAAW,CAAQ;IAE5B,YAAY,OAAgC;QAC1C,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAA;QAC1C,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,IAAI,IAAI,IAAI,CAAA;IACzC,CAAC;IAED,MAAM,CAAC,OAAO,CAAC,GAAuB;QACpC,OAAO,IAAI,gBAAgB,CAAC,EAAE,QAAQ,EAAE,GAAG,CAAC,QAAQ,CAAC,qBAAqB,CAAC,EAAE,CAAC,CAAA;IAChF,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,KAA2B;QACrC,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;QACrC,MAAM,aAAa,GAAG,GAAG,QAAQ,IAAI,UAAU,EAAE,MAAM,CAAA;QAEvD,MAAM,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;QAEnD,IAAI,CAAC;YACH,MAAM,SAAS,CAAC,aAAa,EAAE,KAAK,CAAC,IAAI,CAAC,CAAA;YAC1C,MAAM,MAAM,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAA;QACvC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,EAAE,CAAC,aAAa,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAA;YAC/D,MAAM,KAAK,CAAA;QACb,CAAC;IACH,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,QAAyB;QAClC,OAAO,IAAI,UAAU,CAAC,MAAM,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAA;IAChE,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,QAAyB;QACpC,MAAM,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;IACpD,CAAC;IAED,QAAQ,CAAC,QAAyB;QAChC,IAAI,QAAQ,CAAC,IAAI,KAAK,IAAI,CAAC,WAAW,EAAE,CAAC;YACvC,MAAM,IAAI,KAAK,CAAC,uCAAuC,QAAQ,CAAC,IAAI,QAAQ,CAAC,CAAA;QAC/E,CAAC;QAED,MAAM,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAA;QACvD,MAAM,YAAY,GAAG,QAAQ,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAA;QAEvD,IAAI,CAAC,YAAY,IAAI,YAAY,KAAK,IAAI,IAAI,YAAY,CAAC,UAAU,CAAC,KAAK,GAAG,EAAE,CAAC,EAAE,CAAC;YAClF,MAAM,IAAI,KAAK,CAAC,+DAA+D,CAAC,CAAA;QAClF,CAAC;QAED,OAAO,QAAQ,CAAA;IACjB,CAAC;CACF"}
|
|
@@ -1,5 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jrmc/adonis-attachment
|
|
3
|
+
*
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
+
*/
|
|
1
7
|
import type { HttpContext } from '@adonisjs/core/http';
|
|
2
|
-
|
|
3
|
-
|
|
8
|
+
import type { AttachmentService } from '../core/attachment_service.js';
|
|
9
|
+
import type { AttachmentRepository } from '../core/attachment_repository.js';
|
|
10
|
+
export declare class AttachmentsController {
|
|
11
|
+
private readonly attachments;
|
|
12
|
+
private readonly repository;
|
|
13
|
+
constructor(attachments: Pick<AttachmentService, 'read'>, repository: AttachmentRepository);
|
|
14
|
+
handle({ request, response }: HttpContext): Promise<unknown>;
|
|
4
15
|
}
|
|
5
16
|
//# sourceMappingURL=attachments_controller.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attachments_controller.d.ts","sourceRoot":"","sources":["../../../src/controllers/attachments_controller.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"attachments_controller.d.ts","sourceRoot":"","sources":["../../../src/controllers/attachments_controller.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AAEtD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAA;AACtE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAA;AAE5E,qBAAa,qBAAqB;IAE9B,OAAO,CAAC,QAAQ,CAAC,WAAW;IAC5B,OAAO,CAAC,QAAQ,CAAC,UAAU;gBADV,WAAW,EAAE,IAAI,CAAC,iBAAiB,EAAE,MAAM,CAAC,EAC5C,UAAU,EAAE,oBAAoB;IAG7C,MAAM,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC;CAUnE"}
|
|
@@ -1,110 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @jrmc/adonis-attachment
|
|
3
|
+
*
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
+
*/
|
|
7
|
+
export class AttachmentsController {
|
|
8
|
+
attachments;
|
|
9
|
+
repository;
|
|
10
|
+
constructor(attachments, repository) {
|
|
11
|
+
this.attachments = attachments;
|
|
12
|
+
this.repository = repository;
|
|
13
|
+
}
|
|
9
14
|
async handle({ request, response }) {
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
.run(async () => {
|
|
17
|
-
const queryWithTableSelection = await db
|
|
18
|
-
.from(data.model)
|
|
19
|
-
.select(data.attribute)
|
|
20
|
-
.where(data.primaryKey, data.id)
|
|
21
|
-
.first();
|
|
22
|
-
/*
|
|
23
|
-
* 1. Get the Attachment(s)
|
|
24
|
-
*/
|
|
25
|
-
const result = typeof queryWithTableSelection[data.attribute] === 'string'
|
|
26
|
-
? JSON.parse(queryWithTableSelection[data.attribute])
|
|
27
|
-
: queryWithTableSelection[data.attribute];
|
|
28
|
-
const attachments = [];
|
|
29
|
-
let currentAttachment = null;
|
|
30
|
-
if (Array.isArray(result)) {
|
|
31
|
-
multiple = true;
|
|
32
|
-
for (const item of result) {
|
|
33
|
-
item.folder = path.dirname(item.path);
|
|
34
|
-
const attachment = attachmentManager.createFromDbResponse(item);
|
|
35
|
-
if (attachment) {
|
|
36
|
-
attachment.setOptions(data.options);
|
|
37
|
-
attachments.push(attachment);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
currentAttachment = attachments[data.index || 0];
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
result.folder = path.dirname(result.path);
|
|
44
|
-
currentAttachment = attachmentManager.createFromDbResponse(result);
|
|
45
|
-
if (currentAttachment) {
|
|
46
|
-
currentAttachment.setOptions(data.options);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
if (!currentAttachment) {
|
|
50
|
-
return response.notFound();
|
|
51
|
-
}
|
|
52
|
-
/*
|
|
53
|
-
* 2. Get the variant
|
|
54
|
-
*/
|
|
55
|
-
let variant = currentAttachment.getVariant(format);
|
|
56
|
-
/*
|
|
57
|
-
* 3. Get the stream
|
|
58
|
-
* if variant and path, get the stream and return it
|
|
59
|
-
* if not, generate the variant
|
|
60
|
-
* if not, return the default file
|
|
61
|
-
*/
|
|
62
|
-
if (!variant && format) {
|
|
63
|
-
const converter = (await attachmentManager.getConverter(format));
|
|
64
|
-
variant = await new VariantGeneratorService().generateVariant({
|
|
65
|
-
key: format,
|
|
66
|
-
attachment: currentAttachment,
|
|
67
|
-
converter,
|
|
68
|
-
});
|
|
69
|
-
if (variant) {
|
|
70
|
-
const variantPersister = new VariantPersisterService({
|
|
71
|
-
id: data.id,
|
|
72
|
-
modelTable: data.model,
|
|
73
|
-
attributeName: data.attribute,
|
|
74
|
-
multiple,
|
|
75
|
-
primaryKey: data.primaryKey,
|
|
76
|
-
});
|
|
77
|
-
const attachmentsOrCurrent = attachments.length ? attachments : [currentAttachment];
|
|
78
|
-
await variantPersister.persist({
|
|
79
|
-
attachments: attachmentsOrCurrent,
|
|
80
|
-
variants: [variant],
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
/*
|
|
85
|
-
* 5. Get the stream
|
|
86
|
-
*/
|
|
87
|
-
let stream;
|
|
88
|
-
let mimeType;
|
|
89
|
-
if (variant) {
|
|
90
|
-
stream = await variant.getStream();
|
|
91
|
-
mimeType = variant.mimeType;
|
|
92
|
-
}
|
|
93
|
-
else if (currentAttachment) {
|
|
94
|
-
stream = await currentAttachment.getStream();
|
|
95
|
-
mimeType = currentAttachment.mimeType;
|
|
96
|
-
}
|
|
97
|
-
/*
|
|
98
|
-
* 6. Return the stream
|
|
99
|
-
*/
|
|
100
|
-
if (stream && mimeType) {
|
|
101
|
-
const readable = Readable.from(stream);
|
|
102
|
-
response.header('Content-Type', mimeType);
|
|
103
|
-
response.stream(readable);
|
|
104
|
-
}
|
|
105
|
-
else {
|
|
106
|
-
return response.notFound();
|
|
107
|
-
}
|
|
108
|
-
});
|
|
15
|
+
const attachment = await this.repository.findById(request.param('id'));
|
|
16
|
+
if (!attachment) {
|
|
17
|
+
return response.notFound();
|
|
18
|
+
}
|
|
19
|
+
response.header('content-type', attachment.mimeType);
|
|
20
|
+
return response.send(await this.attachments.read(attachment));
|
|
109
21
|
}
|
|
110
22
|
}
|
|
23
|
+
//# sourceMappingURL=attachments_controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachments_controller.js","sourceRoot":"","sources":["../../../src/controllers/attachments_controller.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH,MAAM,OAAO,qBAAqB;IAEb;IACA;IAFnB,YACmB,WAA4C,EAC5C,UAAgC;QADhC,gBAAW,GAAX,WAAW,CAAiC;QAC5C,eAAU,GAAV,UAAU,CAAsB;IAChD,CAAC;IAEJ,KAAK,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAe;QAC7C,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAA;QAEtE,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,OAAO,QAAQ,CAAC,QAAQ,EAAE,CAAA;QAC5B,CAAC;QAED,QAAQ,CAAC,MAAM,CAAC,cAAc,EAAE,UAAU,CAAC,QAAQ,CAAC,CAAA;QACpD,OAAO,QAAQ,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAA;IAC/D,CAAC;CACF"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jrmc/adonis-attachment
|
|
3
|
+
*
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
+
*/
|
|
7
|
+
export type Attachment = Readonly<{
|
|
8
|
+
id: string;
|
|
9
|
+
disk: string;
|
|
10
|
+
name: string;
|
|
11
|
+
originalName: string;
|
|
12
|
+
path: string;
|
|
13
|
+
size: number;
|
|
14
|
+
extname: string;
|
|
15
|
+
mimeType: string;
|
|
16
|
+
metadata?: Record<string, unknown>;
|
|
17
|
+
}>;
|
|
18
|
+
export type CreateAttachmentInput = {
|
|
19
|
+
body: Uint8Array;
|
|
20
|
+
originalName: string;
|
|
21
|
+
mimeType?: string;
|
|
22
|
+
disk?: string;
|
|
23
|
+
folder?: string;
|
|
24
|
+
metadata?: Record<string, unknown>;
|
|
25
|
+
};
|
|
26
|
+
export type AttachmentFactoryOptions = {
|
|
27
|
+
defaultDisk: string;
|
|
28
|
+
createId?: () => string;
|
|
29
|
+
};
|
|
30
|
+
export declare class AttachmentFactory {
|
|
31
|
+
#private;
|
|
32
|
+
constructor(options: AttachmentFactoryOptions);
|
|
33
|
+
create(input: CreateAttachmentInput): Attachment;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=attachment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachment.d.ts","sourceRoot":"","sources":["../../../src/core/attachment.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,MAAM,MAAM,UAAU,GAAG,QAAQ,CAAC;IAChC,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,YAAY,EAAE,MAAM,CAAA;IACpB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACnC,CAAC,CAAA;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,IAAI,EAAE,UAAU,CAAA;IAChB,YAAY,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACnC,CAAA;AAED,MAAM,MAAM,wBAAwB,GAAG;IACrC,WAAW,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,EAAE,MAAM,MAAM,CAAA;CACxB,CAAA;AAED,qBAAa,iBAAiB;;gBAIhB,OAAO,EAAE,wBAAwB;IAK7C,MAAM,CAAC,KAAK,EAAE,qBAAqB,GAAG,UAAU;CAkBjD"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jrmc/adonis-attachment
|
|
3
|
+
*
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
+
*/
|
|
7
|
+
import { randomUUID } from 'node:crypto';
|
|
8
|
+
import { extname } from 'node:path';
|
|
9
|
+
export class AttachmentFactory {
|
|
10
|
+
#defaultDisk;
|
|
11
|
+
#createId;
|
|
12
|
+
constructor(options) {
|
|
13
|
+
this.#defaultDisk = options.defaultDisk;
|
|
14
|
+
this.#createId = options.createId ?? randomUUID;
|
|
15
|
+
}
|
|
16
|
+
create(input) {
|
|
17
|
+
const id = this.#createId();
|
|
18
|
+
const extension = getExtension(input.originalName);
|
|
19
|
+
const name = extension ? `${id}.${extension}` : id;
|
|
20
|
+
const path = joinPath(input.folder, name);
|
|
21
|
+
return {
|
|
22
|
+
id,
|
|
23
|
+
disk: input.disk ?? this.#defaultDisk,
|
|
24
|
+
name,
|
|
25
|
+
originalName: input.originalName,
|
|
26
|
+
path,
|
|
27
|
+
size: input.body.byteLength,
|
|
28
|
+
extname: extension,
|
|
29
|
+
mimeType: input.mimeType ?? 'application/octet-stream',
|
|
30
|
+
...(input.metadata ? { metadata: input.metadata } : {}),
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function getExtension(fileName) {
|
|
35
|
+
return extname(fileName).slice(1).toLowerCase();
|
|
36
|
+
}
|
|
37
|
+
function joinPath(folder, name) {
|
|
38
|
+
if (!folder) {
|
|
39
|
+
return name;
|
|
40
|
+
}
|
|
41
|
+
const normalizedFolder = folder.replaceAll('\\', '/').replace(/^\/+|\/+$/g, '');
|
|
42
|
+
if (!normalizedFolder || normalizedFolder.split('/').includes('..')) {
|
|
43
|
+
throw new Error('Attachment folder must be a relative path without parent segments');
|
|
44
|
+
}
|
|
45
|
+
return `${normalizedFolder}/${name}`;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=attachment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachment.js","sourceRoot":"","sources":["../../../src/core/attachment.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AA4BnC,MAAM,OAAO,iBAAiB;IACnB,YAAY,CAAQ;IACpB,SAAS,CAAc;IAEhC,YAAY,OAAiC;QAC3C,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,WAAW,CAAA;QACvC,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,QAAQ,IAAI,UAAU,CAAA;IACjD,CAAC;IAED,MAAM,CAAC,KAA4B;QACjC,MAAM,EAAE,GAAG,IAAI,CAAC,SAAS,EAAE,CAAA;QAC3B,MAAM,SAAS,GAAG,YAAY,CAAC,KAAK,CAAC,YAAY,CAAC,CAAA;QAClD,MAAM,IAAI,GAAG,SAAS,CAAC,CAAC,CAAC,GAAG,EAAE,IAAI,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAA;QAClD,MAAM,IAAI,GAAG,QAAQ,CAAC,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;QAEzC,OAAO;YACL,EAAE;YACF,IAAI,EAAE,KAAK,CAAC,IAAI,IAAI,IAAI,CAAC,YAAY;YACrC,IAAI;YACJ,YAAY,EAAE,KAAK,CAAC,YAAY;YAChC,IAAI;YACJ,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,UAAU;YAC3B,OAAO,EAAE,SAAS;YAClB,QAAQ,EAAE,KAAK,CAAC,QAAQ,IAAI,0BAA0B;YACtD,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SACxD,CAAA;IACH,CAAC;CACF;AAED,SAAS,YAAY,CAAC,QAAgB;IACpC,OAAO,OAAO,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAA;AACjD,CAAC;AAED,SAAS,QAAQ,CAAC,MAA0B,EAAE,IAAY;IACxD,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,IAAI,CAAA;IACb,CAAC;IAED,MAAM,gBAAgB,GAAG,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,CAAA;IAE/E,IAAI,CAAC,gBAAgB,IAAI,gBAAgB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QACpE,MAAM,IAAI,KAAK,CAAC,mEAAmE,CAAC,CAAA;IACtF,CAAC;IAED,OAAO,GAAG,gBAAgB,IAAI,IAAI,EAAE,CAAA;AACtC,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jrmc/adonis-attachment
|
|
3
|
+
*
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
+
*/
|
|
7
|
+
import type { Attachment } from './attachment.js';
|
|
8
|
+
import type { AttachmentJob } from './queue.js';
|
|
9
|
+
import type { AttachmentRepository } from './attachment_repository.js';
|
|
10
|
+
export type VariantGenerationRequest = {
|
|
11
|
+
attachment: Attachment;
|
|
12
|
+
variantKeys?: readonly string[];
|
|
13
|
+
};
|
|
14
|
+
export interface VariantGenerator {
|
|
15
|
+
generate(request: VariantGenerationRequest): Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
export type VariantGeneratorFactory = () => VariantGenerator | Promise<VariantGenerator>;
|
|
18
|
+
export type AttachmentJobProcessorOptions = {
|
|
19
|
+
attachments: AttachmentRepository;
|
|
20
|
+
variants: VariantGenerator | VariantGeneratorFactory;
|
|
21
|
+
};
|
|
22
|
+
export declare class AttachmentJobProcessor {
|
|
23
|
+
#private;
|
|
24
|
+
constructor(options: AttachmentJobProcessorOptions);
|
|
25
|
+
process(job: AttachmentJob): Promise<void>;
|
|
26
|
+
}
|
|
27
|
+
export declare class AttachmentNotFoundError extends Error {
|
|
28
|
+
constructor(attachmentId: string);
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=attachment_job_processor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachment_job_processor.d.ts","sourceRoot":"","sources":["../../../src/core/attachment_job_processor.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAC/C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAA;AAEtE,MAAM,MAAM,wBAAwB,GAAG;IACrC,UAAU,EAAE,UAAU,CAAA;IACtB,WAAW,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;CAChC,CAAA;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,OAAO,EAAE,wBAAwB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CAC3D;AAED,MAAM,MAAM,uBAAuB,GAAG,MAAM,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAA;AAExF,MAAM,MAAM,6BAA6B,GAAG;IAC1C,WAAW,EAAE,oBAAoB,CAAA;IACjC,QAAQ,EAAE,gBAAgB,GAAG,uBAAuB,CAAA;CACrD,CAAA;AAED,qBAAa,sBAAsB;;gBAKrB,OAAO,EAAE,6BAA6B;IAK5C,OAAO,CAAC,GAAG,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;CA8BjD;AAED,qBAAa,uBAAwB,SAAQ,KAAK;gBACpC,YAAY,EAAE,MAAM;CAIjC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jrmc/adonis-attachment
|
|
3
|
+
*
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
+
*/
|
|
7
|
+
export class AttachmentJobProcessor {
|
|
8
|
+
#attachments;
|
|
9
|
+
#variants;
|
|
10
|
+
#resolvedVariants;
|
|
11
|
+
constructor(options) {
|
|
12
|
+
this.#attachments = options.attachments;
|
|
13
|
+
this.#variants = options.variants;
|
|
14
|
+
}
|
|
15
|
+
async process(job) {
|
|
16
|
+
switch (job.type) {
|
|
17
|
+
case 'generate-variants':
|
|
18
|
+
await this.#generateVariants(job.attachmentId, job.variantKeys);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
async #generateVariants(attachmentId, variantKeys) {
|
|
23
|
+
const attachment = await this.#attachments.findById(attachmentId);
|
|
24
|
+
if (!attachment) {
|
|
25
|
+
throw new AttachmentNotFoundError(attachmentId);
|
|
26
|
+
}
|
|
27
|
+
const variants = await this.#getVariants();
|
|
28
|
+
await variants.generate({
|
|
29
|
+
attachment,
|
|
30
|
+
...(variantKeys ? { variantKeys } : {}),
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
#getVariants() {
|
|
34
|
+
if (typeof this.#variants !== 'function') {
|
|
35
|
+
return Promise.resolve(this.#variants);
|
|
36
|
+
}
|
|
37
|
+
this.#resolvedVariants ??= Promise.resolve(this.#variants());
|
|
38
|
+
return this.#resolvedVariants;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
export class AttachmentNotFoundError extends Error {
|
|
42
|
+
constructor(attachmentId) {
|
|
43
|
+
super(`Attachment "${attachmentId}" was not found`);
|
|
44
|
+
this.name = 'AttachmentNotFoundError';
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=attachment_job_processor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachment_job_processor.js","sourceRoot":"","sources":["../../../src/core/attachment_job_processor.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAsBH,MAAM,OAAO,sBAAsB;IACxB,YAAY,CAAsB;IAClC,SAAS,CAA4C;IAC9D,iBAAiB,CAAuC;IAExD,YAAY,OAAsC;QAChD,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,WAAW,CAAA;QACvC,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,QAAQ,CAAA;IACnC,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,GAAkB;QAC9B,QAAQ,GAAG,CAAC,IAAI,EAAE,CAAC;YACjB,KAAK,mBAAmB;gBACtB,MAAM,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,YAAY,EAAE,GAAG,CAAC,WAAW,CAAC,CAAA;gBAC/D,OAAM;QACV,CAAC;IACH,CAAC;IAED,KAAK,CAAC,iBAAiB,CAAC,YAAoB,EAAE,WAA+B;QAC3E,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAA;QAEjE,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,MAAM,IAAI,uBAAuB,CAAC,YAAY,CAAC,CAAA;QACjD,CAAC;QAED,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,YAAY,EAAE,CAAA;QAC1C,MAAM,QAAQ,CAAC,QAAQ,CAAC;YACtB,UAAU;YACV,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SACxC,CAAC,CAAA;IACJ,CAAC;IAED,YAAY;QACV,IAAI,OAAO,IAAI,CAAC,SAAS,KAAK,UAAU,EAAE,CAAC;YACzC,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;QACxC,CAAC;QAED,IAAI,CAAC,iBAAiB,KAAK,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,CAAA;QAC5D,OAAO,IAAI,CAAC,iBAAiB,CAAA;IAC/B,CAAC;CACF;AAED,MAAM,OAAO,uBAAwB,SAAQ,KAAK;IAChD,YAAY,YAAoB;QAC9B,KAAK,CAAC,eAAe,YAAY,iBAAiB,CAAC,CAAA;QACnD,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAA;IACvC,CAAC;CACF"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jrmc/adonis-attachment
|
|
3
|
+
*
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
+
*/
|
|
7
|
+
import type { Attachment } from './attachment.js';
|
|
8
|
+
/**
|
|
9
|
+
* Read boundary used by asynchronous workers. Lucid, another ORM, or no database
|
|
10
|
+
* can implement it according to the application's persistence model.
|
|
11
|
+
*/
|
|
12
|
+
export interface AttachmentRepository {
|
|
13
|
+
findById(id: string): Promise<Attachment | null>;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=attachment_repository.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachment_repository.d.ts","sourceRoot":"","sources":["../../../src/core/attachment_repository.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAEjD;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAAA;CACjD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachment_repository.js","sourceRoot":"","sources":["../../../src/core/attachment_repository.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jrmc/adonis-attachment
|
|
3
|
+
*
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
+
*/
|
|
7
|
+
import { type Attachment, type CreateAttachmentInput } from './attachment.js';
|
|
8
|
+
import type { AttachmentQueue } from './queue.js';
|
|
9
|
+
import type { AttachmentStorage } from './storage.js';
|
|
10
|
+
export type AttachmentServiceOptions = {
|
|
11
|
+
storage: AttachmentStorage;
|
|
12
|
+
queue: AttachmentQueue;
|
|
13
|
+
defaultDisk: string;
|
|
14
|
+
createId?: () => string;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Creates files and delegates persistence to the configured storage backend.
|
|
18
|
+
* Database persistence deliberately remains the responsibility of the caller.
|
|
19
|
+
*/
|
|
20
|
+
export declare class AttachmentService {
|
|
21
|
+
#private;
|
|
22
|
+
constructor(options: AttachmentServiceOptions);
|
|
23
|
+
create(input: CreateAttachmentInput): Promise<Attachment>;
|
|
24
|
+
remove(attachment: Attachment): Promise<void>;
|
|
25
|
+
read(attachment: Attachment): Promise<Uint8Array>;
|
|
26
|
+
scheduleVariantGeneration(attachment: Attachment, variantKeys?: readonly string[]): Promise<void>;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=attachment_service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachment_service.d.ts","sourceRoot":"","sources":["../../../src/core/attachment_service.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAEL,KAAK,UAAU,EACf,KAAK,qBAAqB,EAC3B,MAAM,iBAAiB,CAAA;AAExB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AACjD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAErD,MAAM,MAAM,wBAAwB,GAAG;IACrC,OAAO,EAAE,iBAAiB,CAAA;IAC1B,KAAK,EAAE,eAAe,CAAA;IACtB,WAAW,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,EAAE,MAAM,MAAM,CAAA;CACxB,CAAA;AAED;;;GAGG;AACH,qBAAa,iBAAiB;;gBAKhB,OAAO,EAAE,wBAAwB;IAMvC,MAAM,CAAC,KAAK,EAAE,qBAAqB,GAAG,OAAO,CAAC,UAAU,CAAC;IAc/D,MAAM,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IAI7C,IAAI,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;IAIjD,yBAAyB,CACvB,UAAU,EAAE,UAAU,EACtB,WAAW,CAAC,EAAE,SAAS,MAAM,EAAE,GAC9B,OAAO,CAAC,IAAI,CAAC;CAOjB"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jrmc/adonis-attachment
|
|
3
|
+
*
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
+
*/
|
|
7
|
+
import { AttachmentFactory, } from './attachment.js';
|
|
8
|
+
import { markAttachmentPending } from './attachment_state.js';
|
|
9
|
+
/**
|
|
10
|
+
* Creates files and delegates persistence to the configured storage backend.
|
|
11
|
+
* Database persistence deliberately remains the responsibility of the caller.
|
|
12
|
+
*/
|
|
13
|
+
export class AttachmentService {
|
|
14
|
+
#storage;
|
|
15
|
+
#queue;
|
|
16
|
+
#factory;
|
|
17
|
+
constructor(options) {
|
|
18
|
+
this.#storage = options.storage;
|
|
19
|
+
this.#queue = options.queue;
|
|
20
|
+
this.#factory = new AttachmentFactory(options);
|
|
21
|
+
}
|
|
22
|
+
async create(input) {
|
|
23
|
+
const attachment = this.#factory.create(input);
|
|
24
|
+
await this.#storage.write({
|
|
25
|
+
disk: attachment.disk,
|
|
26
|
+
path: attachment.path,
|
|
27
|
+
body: input.body,
|
|
28
|
+
mimeType: attachment.mimeType,
|
|
29
|
+
});
|
|
30
|
+
markAttachmentPending(attachment);
|
|
31
|
+
return attachment;
|
|
32
|
+
}
|
|
33
|
+
remove(attachment) {
|
|
34
|
+
return this.#storage.remove(attachment);
|
|
35
|
+
}
|
|
36
|
+
read(attachment) {
|
|
37
|
+
return this.#storage.read({ disk: attachment.disk, path: attachment.path });
|
|
38
|
+
}
|
|
39
|
+
scheduleVariantGeneration(attachment, variantKeys) {
|
|
40
|
+
return this.#queue.enqueue({
|
|
41
|
+
type: 'generate-variants',
|
|
42
|
+
attachmentId: attachment.id,
|
|
43
|
+
...(variantKeys ? { variantKeys } : {}),
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=attachment_service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachment_service.js","sourceRoot":"","sources":["../../../src/core/attachment_service.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,iBAAiB,GAGlB,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAA;AAW7D;;;GAGG;AACH,MAAM,OAAO,iBAAiB;IACnB,QAAQ,CAAmB;IAC3B,MAAM,CAAiB;IACvB,QAAQ,CAAmB;IAEpC,YAAY,OAAiC;QAC3C,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAA;QAC/B,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,KAAK,CAAA;QAC3B,IAAI,CAAC,QAAQ,GAAG,IAAI,iBAAiB,CAAC,OAAO,CAAC,CAAA;IAChD,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,KAA4B;QACvC,MAAM,UAAU,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;QAE9C,MAAM,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;YACxB,IAAI,EAAE,UAAU,CAAC,IAAI;YACrB,IAAI,EAAE,UAAU,CAAC,IAAI;YACrB,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,QAAQ,EAAE,UAAU,CAAC,QAAQ;SAC9B,CAAC,CAAA;QAEF,qBAAqB,CAAC,UAAU,CAAC,CAAA;QACjC,OAAO,UAAU,CAAA;IACnB,CAAC;IAED,MAAM,CAAC,UAAsB;QAC3B,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,CAAA;IACzC,CAAC;IAED,IAAI,CAAC,UAAsB;QACzB,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,UAAU,CAAC,IAAI,EAAE,CAAC,CAAA;IAC7E,CAAC;IAED,yBAAyB,CACvB,UAAsB,EACtB,WAA+B;QAE/B,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC;YACzB,IAAI,EAAE,mBAAmB;YACzB,YAAY,EAAE,UAAU,CAAC,EAAE;YAC3B,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SACxC,CAAC,CAAA;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jrmc/adonis-attachment
|
|
3
|
+
*
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
+
*/
|
|
7
|
+
import type { Attachment } from './attachment.js';
|
|
8
|
+
export declare function markAttachmentPending(attachment: Attachment): void;
|
|
9
|
+
export declare function markAttachmentPersisted(attachment: Attachment): void;
|
|
10
|
+
export declare function isAttachmentPending(attachment: Attachment): boolean;
|
|
11
|
+
//# sourceMappingURL=attachment_state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachment_state.d.ts","sourceRoot":"","sources":["../../../src/core/attachment_state.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAIjD,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,UAAU,GAAG,IAAI,CAElE;AAED,wBAAgB,uBAAuB,CAAC,UAAU,EAAE,UAAU,GAAG,IAAI,CAEpE;AAED,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAEnE"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jrmc/adonis-attachment
|
|
3
|
+
*
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
+
*/
|
|
7
|
+
const pendingAttachments = new WeakSet();
|
|
8
|
+
export function markAttachmentPending(attachment) {
|
|
9
|
+
pendingAttachments.add(attachment);
|
|
10
|
+
}
|
|
11
|
+
export function markAttachmentPersisted(attachment) {
|
|
12
|
+
pendingAttachments.delete(attachment);
|
|
13
|
+
}
|
|
14
|
+
export function isAttachmentPending(attachment) {
|
|
15
|
+
return pendingAttachments.has(attachment);
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=attachment_state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachment_state.js","sourceRoot":"","sources":["../../../src/core/attachment_state.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,MAAM,kBAAkB,GAAG,IAAI,OAAO,EAAc,CAAA;AAEpD,MAAM,UAAU,qBAAqB,CAAC,UAAsB;IAC1D,kBAAkB,CAAC,GAAG,CAAC,UAAU,CAAC,CAAA;AACpC,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,UAAsB;IAC5D,kBAAkB,CAAC,MAAM,CAAC,UAAU,CAAC,CAAA;AACvC,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,UAAsB;IACxD,OAAO,kBAAkB,CAAC,GAAG,CAAC,UAAU,CAAC,CAAA;AAC3C,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jrmc/adonis-attachment
|
|
3
|
+
*
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
+
*/
|
|
7
|
+
export { AttachmentFactory, type Attachment, type AttachmentFactoryOptions, type CreateAttachmentInput, } from './attachment.js';
|
|
8
|
+
export { AttachmentService, type AttachmentServiceOptions } from './attachment_service.js';
|
|
9
|
+
export { AttachmentJobProcessor, AttachmentNotFoundError, type AttachmentJobProcessorOptions, type VariantGenerationRequest, type VariantGenerator, type VariantGeneratorFactory, } from './attachment_job_processor.js';
|
|
10
|
+
export { type AttachmentRepository } from './attachment_repository.js';
|
|
11
|
+
export { type AttachmentJob, type AttachmentJobHandler, type AttachmentQueue, type GenerateVariantsJob, } from './queue.js';
|
|
12
|
+
export { type AttachmentStorage, type StorageLocation, type WriteAttachmentInput, } from './storage.js';
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,iBAAiB,EACjB,KAAK,UAAU,EACf,KAAK,wBAAwB,EAC7B,KAAK,qBAAqB,GAC3B,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,iBAAiB,EAAE,KAAK,wBAAwB,EAAE,MAAM,yBAAyB,CAAA;AAC1F,OAAO,EACL,sBAAsB,EACtB,uBAAuB,EACvB,KAAK,6BAA6B,EAClC,KAAK,wBAAwB,EAC7B,KAAK,gBAAgB,EACrB,KAAK,uBAAuB,GAC7B,MAAM,+BAA+B,CAAA;AACtC,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,4BAA4B,CAAA;AACtE,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,oBAAoB,EACzB,KAAK,eAAe,EACpB,KAAK,mBAAmB,GACzB,MAAM,YAAY,CAAA;AACnB,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,oBAAoB,GAC1B,MAAM,cAAc,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jrmc/adonis-attachment
|
|
3
|
+
*
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
+
*/
|
|
7
|
+
export { AttachmentFactory, } from './attachment.js';
|
|
8
|
+
export { AttachmentService } from './attachment_service.js';
|
|
9
|
+
export { AttachmentJobProcessor, AttachmentNotFoundError, } from './attachment_job_processor.js';
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,iBAAiB,GAIlB,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,iBAAiB,EAAiC,MAAM,yBAAyB,CAAA;AAC1F,OAAO,EACL,sBAAsB,EACtB,uBAAuB,GAKxB,MAAM,+BAA+B,CAAA"}
|