@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,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jrmc/adonis-attachment
|
|
3
|
+
*
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
+
*/
|
|
7
|
+
import { test } from '@japa/runner';
|
|
8
|
+
import { createAttachmentOwnerKey } from '../src/integrations/lucid/attachment_owner.js';
|
|
9
|
+
import { LucidAttachmentStore } from '../src/integrations/lucid/lucid_attachment_store.js';
|
|
10
|
+
const attachment = {
|
|
11
|
+
id: 'attachment-id',
|
|
12
|
+
disk: 'public',
|
|
13
|
+
path: 'users/42/avatar.jpg',
|
|
14
|
+
name: 'avatar.jpg',
|
|
15
|
+
originalName: 'profile.jpg',
|
|
16
|
+
mimeType: 'image/jpeg',
|
|
17
|
+
extname: 'jpg',
|
|
18
|
+
size: 42,
|
|
19
|
+
};
|
|
20
|
+
test.group('LucidAttachmentStore', () => {
|
|
21
|
+
test('creates an original polymorphic attachment row', async ({ assert }) => {
|
|
22
|
+
const created = [];
|
|
23
|
+
const store = new LucidAttachmentStore({
|
|
24
|
+
async create(attributes) {
|
|
25
|
+
created.push(attributes);
|
|
26
|
+
return attributes;
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
await store.createOriginal({ type: 'users', id: '42', field: 'avatar' }, attachment);
|
|
30
|
+
assert.deepEqual(created, [
|
|
31
|
+
{
|
|
32
|
+
...attachment,
|
|
33
|
+
attachableType: 'users',
|
|
34
|
+
attachableId: '42',
|
|
35
|
+
field: 'avatar',
|
|
36
|
+
ownerKey: createAttachmentOwnerKey({ type: 'users', id: '42', field: 'avatar' }),
|
|
37
|
+
parentId: null,
|
|
38
|
+
variantKey: null,
|
|
39
|
+
metadata: null,
|
|
40
|
+
},
|
|
41
|
+
]);
|
|
42
|
+
});
|
|
43
|
+
test('creates a variant linked to its original attachment', async ({ assert }) => {
|
|
44
|
+
const created = [];
|
|
45
|
+
const store = new LucidAttachmentStore({
|
|
46
|
+
async create(attributes) {
|
|
47
|
+
created.push(attributes);
|
|
48
|
+
return attributes;
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
const original = {
|
|
52
|
+
id: 'original-id',
|
|
53
|
+
attachableType: 'users',
|
|
54
|
+
attachableId: '42',
|
|
55
|
+
field: 'avatar',
|
|
56
|
+
};
|
|
57
|
+
await store.createVariant(original, 'thumbnail', { ...attachment, id: 'variant-id' });
|
|
58
|
+
assert.deepEqual(created[0], {
|
|
59
|
+
...attachment,
|
|
60
|
+
id: 'variant-id',
|
|
61
|
+
attachableType: 'users',
|
|
62
|
+
attachableId: '42',
|
|
63
|
+
field: 'avatar',
|
|
64
|
+
ownerKey: null,
|
|
65
|
+
parentId: 'original-id',
|
|
66
|
+
variantKey: 'thumbnail',
|
|
67
|
+
metadata: null,
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
//# sourceMappingURL=lucid_attachment_store.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lucid_attachment_store.spec.js","sourceRoot":"","sources":["../../tests/lucid_attachment_store.spec.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAGnC,OAAO,EAAE,wBAAwB,EAAE,MAAM,+CAA+C,CAAA;AACxF,OAAO,EAAE,oBAAoB,EAAE,MAAM,qDAAqD,CAAA;AAE1F,MAAM,UAAU,GAAG;IACjB,EAAE,EAAE,eAAe;IACnB,IAAI,EAAE,QAAQ;IACd,IAAI,EAAE,qBAAqB;IAC3B,IAAI,EAAE,YAAY;IAClB,YAAY,EAAE,aAAa;IAC3B,QAAQ,EAAE,YAAY;IACtB,OAAO,EAAE,KAAK;IACd,IAAI,EAAE,EAAE;CACA,CAAA;AAEV,IAAI,CAAC,KAAK,CAAC,sBAAsB,EAAE,GAAG,EAAE;IACtC,IAAI,CAAC,gDAAgD,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;QAC1E,MAAM,OAAO,GAA8B,EAAE,CAAA;QAC7C,MAAM,KAAK,GAAG,IAAI,oBAAoB,CAAC;YACrC,K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AAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;YAC3B,GAAG,UAAU;YACb,EAAE,EAAE,YAAY;YAChB,cAAc,EAAE,OAAO;YACvB,YAAY,EAAE,IAAI;YAClB,KAAK,EAAE,QAAQ;YACf,QAAQ,EAAE,IAAI;YACd,QAAQ,EAAE,aAAa;YACvB,UAAU,EAAE,WAAW;YACvB,QAAQ,EAAE,IAAI;SACf,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lucid_sqlite_integration.spec.d.ts","sourceRoot":"","sources":["../../tests/lucid_sqlite_integration.spec.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jrmc/adonis-attachment
|
|
3
|
+
*
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
+
*/
|
|
7
|
+
import { test } from '@japa/runner';
|
|
8
|
+
import { AttachmentModel } from '../src/integrations/lucid/attachment_model.js';
|
|
9
|
+
import { LucidAttachmentLifecycleService } from '../src/integrations/lucid/lucid_attachment_lifecycle_service.js';
|
|
10
|
+
import { LucidAttachmentRepository } from '../src/integrations/lucid/lucid_attachment_repository.js';
|
|
11
|
+
import { LucidAttachmentStore } from '../src/integrations/lucid/lucid_attachment_store.js';
|
|
12
|
+
import { createLucidTestDatabase } from './helpers/lucid_test_database.js';
|
|
13
|
+
const owner = { type: 'users', id: '42', field: 'avatar' };
|
|
14
|
+
let database;
|
|
15
|
+
function makeAttachment(id, path, metadata) {
|
|
16
|
+
return {
|
|
17
|
+
id,
|
|
18
|
+
disk: 'public',
|
|
19
|
+
path,
|
|
20
|
+
name: path.split('/').at(-1),
|
|
21
|
+
originalName: 'profile.jpg',
|
|
22
|
+
mimeType: 'image/jpeg',
|
|
23
|
+
extname: 'jpg',
|
|
24
|
+
size: 42,
|
|
25
|
+
...(metadata ? { metadata } : {}),
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
test.group('Lucid SQLite integration', (group) => {
|
|
29
|
+
group.setup(async () => {
|
|
30
|
+
database = await createLucidTestDatabase();
|
|
31
|
+
});
|
|
32
|
+
group.each.setup(async () => {
|
|
33
|
+
await database.from('attachments').delete();
|
|
34
|
+
});
|
|
35
|
+
group.teardown(async () => {
|
|
36
|
+
await database.manager.closeAll();
|
|
37
|
+
});
|
|
38
|
+
test('persists original rows and variants using the generated table schema', async ({ assert }) => {
|
|
39
|
+
const store = new LucidAttachmentStore();
|
|
40
|
+
const original = await store.createOriginal(owner, makeAttachment('original-id', 'users/42/avatar.jpg', { width: 800 }));
|
|
41
|
+
const variant = await store.createVariant(original, 'thumbnail', makeAttachment('variant-id', 'users/42/thumbnail.jpg'));
|
|
42
|
+
const reloaded = await AttachmentModel.findOrFail(original.id);
|
|
43
|
+
const persisted = await store.findByOwner(owner);
|
|
44
|
+
assert.equal(reloaded.attachableType, 'users');
|
|
45
|
+
assert.equal(reloaded.attachableId, '42');
|
|
46
|
+
assert.equal(reloaded.field, 'avatar');
|
|
47
|
+
assert.deepEqual(reloaded.metadata, { width: 800 });
|
|
48
|
+
assert.isNotNull(reloaded.createdAt);
|
|
49
|
+
assert.isNotNull(reloaded.updatedAt);
|
|
50
|
+
assert.equal(variant.parentId, original.id);
|
|
51
|
+
assert.equal(variant.variantKey, 'thumbnail');
|
|
52
|
+
assert.equal(persisted?.original.id, original.id);
|
|
53
|
+
assert.deepEqual(persisted?.variants.map((row) => row.id), ['variant-id']);
|
|
54
|
+
});
|
|
55
|
+
test('returns null when no attachment exists for the owner field', async ({ assert }) => {
|
|
56
|
+
const result = await new LucidAttachmentStore().findByOwner(owner);
|
|
57
|
+
assert.isNull(result);
|
|
58
|
+
});
|
|
59
|
+
test('prevents two original attachments for the same owner field', async ({ assert }) => {
|
|
60
|
+
const store = new LucidAttachmentStore();
|
|
61
|
+
await store.createOriginal(owner, makeAttachment('first-id', 'users/42/first.jpg'));
|
|
62
|
+
await assert.rejects(() => store.createOriginal(owner, makeAttachment('second-id', 'users/42/second.jpg')), /UNIQUE constraint failed/);
|
|
63
|
+
});
|
|
64
|
+
test('prevents duplicate variant keys for the same original', async ({ assert }) => {
|
|
65
|
+
const store = new LucidAttachmentStore();
|
|
66
|
+
const original = await store.createOriginal(owner, makeAttachment('original-id', 'users/42/avatar.jpg'));
|
|
67
|
+
await store.createVariant(original, 'thumbnail', makeAttachment('first-variant-id', 'users/42/thumbnail.jpg'));
|
|
68
|
+
await assert.rejects(() => store.createVariant(original, 'thumbnail', makeAttachment('second-variant-id', 'users/42/thumbnail-2.jpg')), /UNIQUE constraint failed/);
|
|
69
|
+
});
|
|
70
|
+
test('uses persisted rows for lifecycle replacement, deletion, and repository reads', async ({ assert }) => {
|
|
71
|
+
const removed = [];
|
|
72
|
+
const attachments = [
|
|
73
|
+
makeAttachment('first-id', 'users/42/first.jpg'),
|
|
74
|
+
makeAttachment('second-id', 'users/42/second.jpg'),
|
|
75
|
+
];
|
|
76
|
+
const lifecycle = new LucidAttachmentLifecycleService({
|
|
77
|
+
async create() {
|
|
78
|
+
return attachments.shift();
|
|
79
|
+
},
|
|
80
|
+
async remove(attachment) {
|
|
81
|
+
removed.push(attachment.id);
|
|
82
|
+
},
|
|
83
|
+
}, new LucidAttachmentStore());
|
|
84
|
+
const first = await lifecycle.attach(owner, {
|
|
85
|
+
body: new Uint8Array(),
|
|
86
|
+
originalName: 'profile.jpg',
|
|
87
|
+
});
|
|
88
|
+
const replacement = await lifecycle.replace(owner, {
|
|
89
|
+
body: new Uint8Array(),
|
|
90
|
+
originalName: 'profile.jpg',
|
|
91
|
+
});
|
|
92
|
+
await new LucidAttachmentStore().createVariant(replacement, 'thumbnail', makeAttachment('variant-id', 'users/42/thumbnail.jpg'));
|
|
93
|
+
const repository = new LucidAttachmentRepository();
|
|
94
|
+
assert.equal((await repository.findById(replacement.id))?.path, 'users/42/second.jpg');
|
|
95
|
+
assert.isNull(await AttachmentModel.find(first.id));
|
|
96
|
+
assert.deepEqual(removed, [first.id]);
|
|
97
|
+
await lifecycle.detach(owner);
|
|
98
|
+
assert.isNull(await AttachmentModel.find(replacement.id));
|
|
99
|
+
assert.isNull(await AttachmentModel.find('variant-id'));
|
|
100
|
+
assert.sameDeepMembers(removed, [first.id, replacement.id, 'variant-id']);
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
//# sourceMappingURL=lucid_sqlite_integration.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lucid_sqlite_integration.spec.js","sourceRoot":"","sources":["../../tests/lucid_sqlite_integration.spec.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAGnC,OAAO,EAAE,eAAe,EAAE,MAAM,+CAA+C,CAAA;AAC/E,OAAO,EAAE,+BAA+B,EAAE,MAAM,iEAAiE,CAAA;AACjH,OAAO,EAAE,yBAAyB,EAAE,MAAM,0DAA0D,CAAA;AACpG,OAAO,EAAE,oBAAoB,EAAE,MAAM,qDAAqD,CAAA;AAC1F,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAA;AAE1E,MAAM,KAAK,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAA;AAC1D,IAAI,QAAkB,CAAA;AAEtB,SAAS,cAAc,CAAC,EAAU,EAAE,IAAY,EAAE,QAAkC;IAClF,OAAO;QACL,EAAE;QACF,IAAI,EAAE,QAAQ;QACd,IAAI;QACJ,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAE;QAC7B,YAAY,EAAE,aAAa;QAC3B,QAAQ,EAAE,YAAY;QACtB,OAAO,EAAE,KAAK;Q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A;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lucid_variant_generation_service.spec.d.ts","sourceRoot":"","sources":["../../tests/lucid_variant_generation_service.spec.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jrmc/adonis-attachment
|
|
3
|
+
*
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
+
*/
|
|
7
|
+
import { test } from '@japa/runner';
|
|
8
|
+
import { LucidVariantGenerationService, PersistedAttachmentNotFoundError, } from '../src/integrations/lucid/lucid_variant_generation_service.js';
|
|
9
|
+
const original = {
|
|
10
|
+
id: 'original-id', disk: 'public', path: 'users/42/avatar.jpg', name: 'avatar.jpg',
|
|
11
|
+
originalName: 'profile.jpg', mimeType: 'image/jpeg', extname: 'jpg', size: 42,
|
|
12
|
+
};
|
|
13
|
+
const variant = { ...original, id: 'variant-id', name: 'thumbnail.webp', extname: 'webp' };
|
|
14
|
+
test.group('LucidVariantGenerationService', () => {
|
|
15
|
+
test('persists generated variants under their original attachment', async ({ assert }) => {
|
|
16
|
+
const persisted = [];
|
|
17
|
+
const service = new LucidVariantGenerationService({
|
|
18
|
+
generator: { async generateAll() { return [{ key: 'thumbnail', attachment: variant }]; } },
|
|
19
|
+
attachments: { async remove() { } },
|
|
20
|
+
store: {
|
|
21
|
+
async findById() { return { id: original.id }; },
|
|
22
|
+
async createVariant(row, key, attachment) {
|
|
23
|
+
persisted.push(`${row.id}:${key}:${attachment.id}`);
|
|
24
|
+
return {};
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
await service.generate({ attachment: original });
|
|
29
|
+
assert.deepEqual(persisted, ['original-id:thumbnail:variant-id']);
|
|
30
|
+
});
|
|
31
|
+
test('removes a generated file when variant persistence fails', async ({ assert }) => {
|
|
32
|
+
const removed = [];
|
|
33
|
+
const service = new LucidVariantGenerationService({
|
|
34
|
+
generator: { async generateAll() { return [{ key: 'thumbnail', attachment: variant }]; } },
|
|
35
|
+
attachments: { async remove(attachment) { removed.push(attachment.id); } },
|
|
36
|
+
store: {
|
|
37
|
+
async findById() { return { id: original.id }; },
|
|
38
|
+
async createVariant() { throw new Error('database unavailable'); },
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
await assert.rejects(() => service.generate({ attachment: original }), 'database unavailable');
|
|
42
|
+
assert.deepEqual(removed, ['variant-id']);
|
|
43
|
+
});
|
|
44
|
+
test('fails when the original is no longer persisted', async ({ assert }) => {
|
|
45
|
+
const service = new LucidVariantGenerationService({
|
|
46
|
+
generator: { async generateAll() { return []; } },
|
|
47
|
+
attachments: { async remove() { } },
|
|
48
|
+
store: {
|
|
49
|
+
async findById() { return null; },
|
|
50
|
+
async createVariant() { return {}; },
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
await assert.rejects(() => service.generate({ attachment: original }), PersistedAttachmentNotFoundError);
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
//# sourceMappingURL=lucid_variant_generation_service.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lucid_variant_generation_service.spec.js","sourceRoot":"","sources":["../../tests/lucid_variant_generation_service.spec.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAInC,OAAO,EACL,6BAA6B,EAC7B,gCAAgC,GACjC,MAAM,+DAA+D,CAAA;AAEtE,MAAM,QAAQ,GAAe;IAC3B,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,qBAAqB,EAAE,IAAI,EAAE,YAAY;IAClF,YAAY,EAAE,aAAa,EAAE,QAAQ,EAAE,YAAY,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;CAC9E,CAA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,OAAO,CAAC,QAAQ,CAAC,EAAE,UAAU,EAAE,QAAQ,EAAE,CAAC,EAAE,gCAAgC,CAAC,CAAA;IAC1G,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory_queue.spec.d.ts","sourceRoot":"","sources":["../../tests/memory_queue.spec.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jrmc/adonis-attachment
|
|
3
|
+
*
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
+
*/
|
|
7
|
+
import { test } from '@japa/runner';
|
|
8
|
+
import { MemoryAttachmentQueue } from '../index.js';
|
|
9
|
+
test('processes queued jobs up to its configured concurrency', async ({ assert }) => {
|
|
10
|
+
let active = 0;
|
|
11
|
+
let maximumActive = 0;
|
|
12
|
+
const completed = [];
|
|
13
|
+
const queue = new MemoryAttachmentQueue({
|
|
14
|
+
concurrency: 2,
|
|
15
|
+
async handler(job) {
|
|
16
|
+
active += 1;
|
|
17
|
+
maximumActive = Math.max(maximumActive, active);
|
|
18
|
+
await new Promise((resolve) => setTimeout(resolve, 5));
|
|
19
|
+
completed.push(job.attachmentId);
|
|
20
|
+
active -= 1;
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
await Promise.all([
|
|
24
|
+
queue.enqueue({ type: 'generate-variants', attachmentId: 'one' }),
|
|
25
|
+
queue.enqueue({ type: 'generate-variants', attachmentId: 'two' }),
|
|
26
|
+
queue.enqueue({ type: 'generate-variants', attachmentId: 'three' }),
|
|
27
|
+
]);
|
|
28
|
+
await queue.drain();
|
|
29
|
+
assert.equal(maximumActive, 2);
|
|
30
|
+
assert.deepEqual(completed.sort(), ['one', 'three', 'two']);
|
|
31
|
+
});
|
|
32
|
+
test('reports failures and continues with subsequent jobs', async ({ assert }) => {
|
|
33
|
+
const failures = [];
|
|
34
|
+
const completed = [];
|
|
35
|
+
const queue = new MemoryAttachmentQueue({
|
|
36
|
+
async handler(job) {
|
|
37
|
+
if (job.attachmentId === 'broken') {
|
|
38
|
+
throw new Error('conversion failed');
|
|
39
|
+
}
|
|
40
|
+
completed.push(job.attachmentId);
|
|
41
|
+
},
|
|
42
|
+
onFailure(job) {
|
|
43
|
+
failures.push(job.attachmentId);
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
await queue.enqueue({ type: 'generate-variants', attachmentId: 'broken' });
|
|
47
|
+
await queue.enqueue({ type: 'generate-variants', attachmentId: 'valid' });
|
|
48
|
+
await queue.drain();
|
|
49
|
+
assert.deepEqual(failures, ['broken']);
|
|
50
|
+
assert.deepEqual(completed, ['valid']);
|
|
51
|
+
});
|
|
52
|
+
//# sourceMappingURL=memory_queue.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory_queue.spec.js","sourceRoot":"","sources":["../../tests/memory_queue.spec.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAEnC,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAEnD,IAAI,CAAC,wDAAwD,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;IAClF,IAAI,MAAM,GAAG,CAAC,CAAA;IACd,IAAI,aAAa,GAAG,CAAC,CAAA;IACrB,MAAM,SAAS,GAAa,EAAE,CAAA;IAC9B,MAAM,KAAK,GAAG,IAAI,qBAAqB,CAAC;QACtC,WAAW,EAAE,CAAC;QACd,KAAK,CAAC,OAAO,CAAC,GAAG;YACf,MAAM,IAAI,CAAC,CAAA;YACX,aAAa,GAAG,IAAI,CAAC,GAAG,CAAC,aAAa,EAAE,MAAM,CAAC,CAAA;YAC/C,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,U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CAAC,CAAA;QACjC,CAAC;KACF,CAAC,CAAA;IAEF,MAAM,KAAK,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,mBAAmB,EAAE,YAAY,EAAE,QAAQ,EAAE,CAAC,CAAA;IAC1E,MAAM,KAAK,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,mBAAmB,EAAE,YAAY,EAAE,OAAO,EAAE,CAAC,CAAA;IACzE,MAAM,KAAK,CAAC,KAAK,EAAE,CAAA;IAEnB,MAAM,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAA;IACtC,MAAM,CAAC,SAAS,CAAC,SAAS,EAAE,CAAC,OAAO,CAAC,CAAC,CAAA;AACxC,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrate_legacy_attachment.spec.d.ts","sourceRoot":"","sources":["../../tests/migrate_legacy_attachment.spec.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jrmc/adonis-attachment
|
|
3
|
+
*
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
+
*/
|
|
7
|
+
import { test } from '@japa/runner';
|
|
8
|
+
import { migrateLegacyAttachment } from '../index.js';
|
|
9
|
+
import { createAttachmentOwnerKey } from '../src/integrations/lucid/attachment_owner.js';
|
|
10
|
+
test.group('migrateLegacyAttachment', () => {
|
|
11
|
+
test('converts an original attachment and its variants to polymorphic rows', ({ assert }) => {
|
|
12
|
+
const ids = ['original-id', 'thumbnail-id'];
|
|
13
|
+
const rows = migrateLegacyAttachment({
|
|
14
|
+
name: 'avatar.jpg',
|
|
15
|
+
originalName: 'profile.jpg',
|
|
16
|
+
size: 42,
|
|
17
|
+
extname: 'jpg',
|
|
18
|
+
mimeType: 'image/jpeg',
|
|
19
|
+
disk: 's3',
|
|
20
|
+
path: 'users/42/avatar.jpg',
|
|
21
|
+
meta: { width: 800 },
|
|
22
|
+
variants: [
|
|
23
|
+
{
|
|
24
|
+
key: 'thumbnail',
|
|
25
|
+
name: 'avatar.webp',
|
|
26
|
+
size: 12,
|
|
27
|
+
extname: 'webp',
|
|
28
|
+
mimeType: 'image/webp',
|
|
29
|
+
path: 'users/42/variants/avatar.webp',
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
}, {
|
|
33
|
+
owner: { type: 'users', id: '42', field: 'avatar' },
|
|
34
|
+
defaultDisk: 'public',
|
|
35
|
+
createId: () => ids.shift(),
|
|
36
|
+
});
|
|
37
|
+
assert.deepEqual(rows, [
|
|
38
|
+
{
|
|
39
|
+
id: 'original-id',
|
|
40
|
+
attachableType: 'users',
|
|
41
|
+
attachableId: '42',
|
|
42
|
+
field: 'avatar',
|
|
43
|
+
ownerKey: createAttachmentOwnerKey({ type: 'users', id: '42', field: 'avatar' }),
|
|
44
|
+
parentId: null,
|
|
45
|
+
variantKey: null,
|
|
46
|
+
disk: 's3',
|
|
47
|
+
path: 'users/42/avatar.jpg',
|
|
48
|
+
name: 'avatar.jpg',
|
|
49
|
+
originalName: 'profile.jpg',
|
|
50
|
+
mimeType: 'image/jpeg',
|
|
51
|
+
extname: 'jpg',
|
|
52
|
+
size: 42,
|
|
53
|
+
metadata: { width: 800 },
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
id: 'thumbnail-id',
|
|
57
|
+
attachableType: 'users',
|
|
58
|
+
attachableId: '42',
|
|
59
|
+
field: 'avatar',
|
|
60
|
+
ownerKey: null,
|
|
61
|
+
parentId: 'original-id',
|
|
62
|
+
variantKey: 'thumbnail',
|
|
63
|
+
disk: 'public',
|
|
64
|
+
path: 'users/42/variants/avatar.webp',
|
|
65
|
+
name: 'avatar.webp',
|
|
66
|
+
originalName: 'profile.jpg',
|
|
67
|
+
mimeType: 'image/webp',
|
|
68
|
+
extname: 'webp',
|
|
69
|
+
size: 12,
|
|
70
|
+
metadata: null,
|
|
71
|
+
},
|
|
72
|
+
]);
|
|
73
|
+
});
|
|
74
|
+
test('accepts a serialized v5 document', ({ assert }) => {
|
|
75
|
+
const rows = migrateLegacyAttachment('{"name":"report.pdf","size":10,"extname":"pdf","mimeType":"application/pdf"}', {
|
|
76
|
+
owner: { type: 'reports', id: 'report-id', field: 'document' },
|
|
77
|
+
defaultDisk: 'public',
|
|
78
|
+
createId: () => 'attachment-id',
|
|
79
|
+
});
|
|
80
|
+
assert.equal(rows[0]?.disk, 'public');
|
|
81
|
+
assert.equal(rows[0]?.originalName, 'report.pdf');
|
|
82
|
+
});
|
|
83
|
+
test('rejects malformed serialized documents', ({ assert }) => {
|
|
84
|
+
assert.throws(() => migrateLegacyAttachment('{not json}', {
|
|
85
|
+
owner: { type: 'reports', id: 'report-id', field: 'document' },
|
|
86
|
+
defaultDisk: 'public',
|
|
87
|
+
createId: () => 'attachment-id',
|
|
88
|
+
}), 'Legacy attachment value must be valid JSON');
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
//# sourceMappingURL=migrate_legacy_attachment.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrate_legacy_attachment.spec.js","sourceRoot":"","sources":["../../tests/migrate_legacy_attachment.spec.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAEnC,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAA;AACrD,OAAO,EAAE,wBAAwB,EAAE,MAAM,+CAA+C,CAAA;AAExF,IAAI,CAAC,KAAK,CAAC,yBAAyB,EAAE,GAAG,EAAE;IACzC,IAAI,CAAC,sEAAsE,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE;QAC1F,MAAM,GAAG,GAAG,CAAC,aAAa,EAAE,cAAc,CAAC,CAAA;QAC3C,MAAM,IAAI,GAAG,uBAAuB,CAClC;YACE,IAAI,EAA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AAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrate_legacy_attachment_records.spec.d.ts","sourceRoot":"","sources":["../../tests/migrate_legacy_attachment_records.spec.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jrmc/adonis-attachment
|
|
3
|
+
*
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
+
*/
|
|
7
|
+
import { test } from '@japa/runner';
|
|
8
|
+
import { migrateLegacyAttachmentRecords } from '../src/integrations/lucid/index.js';
|
|
9
|
+
test.group('migrateLegacyAttachmentRecords', () => {
|
|
10
|
+
test('migrates values in batches and reports skipped records', async ({ assert }) => {
|
|
11
|
+
const ids = ['original-1', 'variant-1', 'original-2'];
|
|
12
|
+
const batches = [];
|
|
13
|
+
const result = await migrateLegacyAttachmentRecords({
|
|
14
|
+
records: [
|
|
15
|
+
{
|
|
16
|
+
owner: { type: 'users', id: '1', field: 'avatar' },
|
|
17
|
+
value: {
|
|
18
|
+
name: 'avatar.jpg',
|
|
19
|
+
size: 10,
|
|
20
|
+
extname: 'jpg',
|
|
21
|
+
mimeType: 'image/jpeg',
|
|
22
|
+
variants: [
|
|
23
|
+
{
|
|
24
|
+
key: 'thumbnail',
|
|
25
|
+
name: 'avatar.webp',
|
|
26
|
+
size: 5,
|
|
27
|
+
extname: 'webp',
|
|
28
|
+
mimeType: 'image/webp',
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
{ owner: { type: 'users', id: '2', field: 'avatar' }, value: null },
|
|
34
|
+
{
|
|
35
|
+
owner: { type: 'users', id: '3', field: 'avatar' },
|
|
36
|
+
value: {
|
|
37
|
+
name: 'avatar.png',
|
|
38
|
+
size: 12,
|
|
39
|
+
extname: 'png',
|
|
40
|
+
mimeType: 'image/png',
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
defaultDisk: 'public',
|
|
45
|
+
createId: () => ids.shift(),
|
|
46
|
+
batchSize: 2,
|
|
47
|
+
writer: {
|
|
48
|
+
async insert(rows) {
|
|
49
|
+
batches.push([...rows]);
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
assert.deepEqual(result, { attachments: 2, variants: 1, skipped: 1 });
|
|
54
|
+
assert.deepEqual(batches.map((batch) => batch.map((row) => row.id)), [['original-1', 'variant-1'], ['original-2']]);
|
|
55
|
+
});
|
|
56
|
+
test('rejects an invalid batch size before processing records', async ({ assert }) => {
|
|
57
|
+
await assert.rejects(() => migrateLegacyAttachmentRecords({
|
|
58
|
+
records: [],
|
|
59
|
+
defaultDisk: 'public',
|
|
60
|
+
createId: () => 'attachment-id',
|
|
61
|
+
batchSize: 0,
|
|
62
|
+
writer: { async insert() { } },
|
|
63
|
+
}), 'Legacy attachment migration batchSize must be a positive integer');
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
//# sourceMappingURL=migrate_legacy_attachment_records.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrate_legacy_attachment_records.spec.js","sourceRoot":"","sources":["../../tests/migrate_legacy_attachment_records.spec.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAEnC,OAAO,EAAE,8BAA8B,EAA8B,MAAM,oCAAoC,CAAA;AAE/G,IAAI,CAAC,KAAK,CAAC,gCAAgC,EAAE,GAAG,EAAE;IAChD,IAAI,CAAC,wDAAwD,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;QAClF,MAAM,GAAG,GAAG,CAAC,YAAY,EAAE,WAAW,EAAE,YAAY,CAAC,CAAA;QACrD,MAAM,OAAO,GAA8B,EAAE,CAAA;QAC7C,MAAM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M,CAAC,SAAS,CACd,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,EAClD,CAAC,CAAC,YAAY,EAAE,WAAW,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC,CAC9C,CAAA;IACH,CAAC,CAAC,CAAA;IAEF,IAAI,CAAC,yDAAyD,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;QACnF,MAAM,MAAM,CAAC,OAAO,CAClB,GAAG,EAAE,CACH,8BAA8B,CAAC;YAC7B,OAAO,EAAE,EAAE;YACX,WAAW,EAAE,QAAQ;YACrB,QAAQ,EAAE,GAAG,EAAE,CAAC,eAAe;YAC/B,SAAS,EAAE,CAAC;YACZ,MAAM,EAAE,EAAE,KAAK,CAAC,MAAM,KAAI,CAAC,EAAE;SAC9B,CAAC,EACJ,kEAAkE,CACnE,CAAA;IACH,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package_exports.spec.d.ts","sourceRoot":"","sources":["../../tests/package_exports.spec.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jrmc/adonis-attachment
|
|
3
|
+
*
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
+
*/
|
|
7
|
+
import { test } from '@japa/runner';
|
|
8
|
+
test('imports every published package entry point', async ({ assert }) => {
|
|
9
|
+
const entryPoints = [
|
|
10
|
+
'@jrmc/adonis-attachment',
|
|
11
|
+
'@jrmc/adonis-attachment/core',
|
|
12
|
+
'@jrmc/adonis-attachment/queues/memory',
|
|
13
|
+
'@jrmc/adonis-attachment/queues/adonis',
|
|
14
|
+
'@jrmc/adonis-attachment/adapters/adonis-drive',
|
|
15
|
+
'@jrmc/adonis-attachment/adapters/local-file',
|
|
16
|
+
'@jrmc/adonis-attachment/lucid',
|
|
17
|
+
'@jrmc/adonis-attachment/attachment_provider',
|
|
18
|
+
'@jrmc/adonis-attachment/configure',
|
|
19
|
+
'@jrmc/adonis-attachment/commands/make/attachments_table',
|
|
20
|
+
'@jrmc/adonis-attachment/commands/make/attachment_v5_migration',
|
|
21
|
+
];
|
|
22
|
+
const modules = await Promise.all(entryPoints.map((entryPoint) => import(entryPoint)));
|
|
23
|
+
assert.lengthOf(modules, entryPoints.length);
|
|
24
|
+
});
|
|
25
|
+
test('exports the Ace configure hook from the package root', async ({ assert }) => {
|
|
26
|
+
const packageExports = await import('@jrmc/adonis-attachment');
|
|
27
|
+
assert.isFunction(packageExports.configure);
|
|
28
|
+
assert.property(packageExports, 'attachmentManager');
|
|
29
|
+
assert.isFunction(packageExports.attachment);
|
|
30
|
+
});
|
|
31
|
+
//# sourceMappingURL=package_exports.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package_exports.spec.js","sourceRoot":"","sources":["../../tests/package_exports.spec.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAEnC,IAAI,CAAC,6CAA6C,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;IACvE,MAAM,WAAW,GAAG;QAClB,yBAAyB;QACzB,8BAA8B;QAC9B,uCAAuC;QACvC,uCAAuC;QACvC,+CAA+C;QAC/C,6CAA6C;QAC7C,+BAA+B;QAC/B,6CAA6C;QAC7C,mCAAmC;QACnC,yDAAyD;QACzD,+DAA+D;KAChE,CAAA;IAED,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAA;IAEtF,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC,MAAM,CAAC,CAAA;AAC9C,CAAC,CAAC,CAAA;AAEF,IAAI,CAAC,sDAAsD,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;IAChF,MAAM,cAAc,GAAG,MAAM,MAAM,CAAC,yBAAyB,CAAC,CAAA;IAE9D,MAAM,CAAC,UAAU,CAAC,cAAc,CAAC,SAAS,CAAC,CAAA;IAC3C,MAAM,CAAC,QAAQ,CAAC,cAAc,EAAE,mBAAmB,CAAC,CAAA;IACpD,MAAM,CAAC,UAAU,CAAC,cAAc,CAAC,UAAU,CAAC,CAAA;AAC9C,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"variant_generation_service.spec.d.ts","sourceRoot":"","sources":["../../tests/variant_generation_service.spec.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
|