@jrmc/adonis-attachment 5.2.1 → 6.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -81
- package/build/bin/test.d.ts +2 -0
- package/build/bin/test.d.ts.map +1 -0
- package/build/bin/test.js +9 -0
- package/build/bin/test.js.map +1 -0
- package/build/commands/commands.json +1 -1
- package/build/commands/make/attachment_v5_migration.d.ts +17 -0
- package/build/commands/make/attachment_v5_migration.d.ts.map +1 -0
- package/build/commands/make/attachment_v5_migration.js +26 -0
- package/build/commands/make/attachment_v5_migration.js.map +1 -0
- package/build/commands/make/{converter.d.ts → attachments_table.d.ts} +6 -4
- package/build/commands/make/attachments_table.d.ts.map +1 -0
- package/build/commands/make/attachments_table.js +30 -0
- package/build/commands/make/attachments_table.js.map +1 -0
- package/build/configure.d.ts.map +1 -1
- package/build/configure.js +2 -1
- package/build/configure.js.map +1 -0
- package/build/index.d.ts +26 -10
- package/build/index.d.ts.map +1 -1
- package/build/index.js +16 -9
- package/build/index.js.map +1 -0
- package/build/providers/attachment_provider.d.ts +0 -19
- package/build/providers/attachment_provider.d.ts.map +1 -1
- package/build/providers/attachment_provider.js +30 -26
- package/build/providers/attachment_provider.js.map +1 -0
- package/build/services/main.d.ts +3 -3
- package/build/services/main.d.ts.map +1 -1
- package/build/services/main.js +42 -5
- package/build/services/main.js.map +1 -0
- package/build/src/adapters/adonis_drive_storage.d.ts +33 -0
- package/build/src/adapters/adonis_drive_storage.d.ts.map +1 -0
- package/build/src/adapters/adonis_drive_storage.js +35 -0
- package/build/src/adapters/adonis_drive_storage.js.map +1 -0
- package/build/src/adapters/local_file_storage.d.ts +25 -0
- package/build/src/adapters/local_file_storage.d.ts.map +1 -0
- package/build/src/adapters/local_file_storage.js +54 -0
- package/build/src/adapters/local_file_storage.js.map +1 -0
- package/build/src/controllers/attachments_controller.d.ts +13 -2
- package/build/src/controllers/attachments_controller.d.ts.map +1 -1
- package/build/src/controllers/attachments_controller.js +20 -107
- package/build/src/controllers/attachments_controller.js.map +1 -0
- package/build/src/core/attachment.d.ts +70 -0
- package/build/src/core/attachment.d.ts.map +1 -0
- package/build/src/core/attachment.js +150 -0
- package/build/src/core/attachment.js.map +1 -0
- package/build/src/core/attachment_job_processor.d.ts +30 -0
- package/build/src/core/attachment_job_processor.d.ts.map +1 -0
- package/build/src/core/attachment_job_processor.js +47 -0
- package/build/src/core/attachment_job_processor.js.map +1 -0
- package/build/src/core/attachment_options.d.ts +32 -0
- package/build/src/core/attachment_options.d.ts.map +1 -0
- package/build/src/core/attachment_options.js +24 -0
- package/build/src/core/attachment_options.js.map +1 -0
- package/build/src/core/attachment_repository.d.ts +15 -0
- package/build/src/core/attachment_repository.d.ts.map +1 -0
- package/build/src/core/attachment_repository.js +8 -0
- package/build/src/core/attachment_repository.js.map +1 -0
- package/build/src/core/attachment_service.d.ts +34 -0
- package/build/src/core/attachment_service.d.ts.map +1 -0
- package/build/src/core/attachment_service.js +93 -0
- package/build/src/core/attachment_service.js.map +1 -0
- package/build/src/core/attachment_state.d.ts +11 -0
- package/build/src/core/attachment_state.d.ts.map +1 -0
- package/build/src/core/attachment_state.js +17 -0
- package/build/src/core/attachment_state.js.map +1 -0
- package/build/src/core/index.d.ts +14 -0
- package/build/src/core/index.d.ts.map +1 -0
- package/build/src/core/index.js +11 -0
- package/build/src/core/index.js.map +1 -0
- package/build/src/core/queue.d.ts +20 -0
- package/build/src/core/queue.d.ts.map +1 -0
- package/build/src/{types/event.js → core/queue.js} +1 -0
- package/build/src/core/queue.js.map +1 -0
- package/build/src/core/storage.d.ts +23 -0
- package/build/src/core/storage.d.ts.map +1 -0
- package/build/src/{types/config.js → core/storage.js} +1 -0
- package/build/src/core/storage.js.map +1 -0
- package/build/src/define_config.d.ts +39 -20
- package/build/src/define_config.d.ts.map +1 -1
- package/build/src/define_config.js +46 -24
- package/build/src/define_config.js.map +1 -0
- package/build/src/integrations/lucid/attachment_column.d.ts +18 -0
- package/build/src/integrations/lucid/attachment_column.d.ts.map +1 -0
- package/build/src/integrations/lucid/attachment_column.js +151 -0
- package/build/src/integrations/lucid/attachment_column.js.map +1 -0
- package/build/src/integrations/lucid/attachment_model.d.ts +37 -0
- package/build/src/integrations/lucid/attachment_model.d.ts.map +1 -0
- package/build/src/integrations/lucid/attachment_model.js +99 -0
- package/build/src/integrations/lucid/attachment_model.js.map +1 -0
- package/build/src/integrations/lucid/attachment_owner.d.ts +18 -0
- package/build/src/integrations/lucid/attachment_owner.d.ts.map +1 -0
- package/build/src/integrations/lucid/attachment_owner.js +15 -0
- package/build/src/integrations/lucid/attachment_owner.js.map +1 -0
- package/build/src/integrations/lucid/attachment_relation.d.ts +60 -0
- package/build/src/integrations/lucid/attachment_relation.d.ts.map +1 -0
- package/build/src/integrations/lucid/attachment_relation.js +163 -0
- package/build/src/integrations/lucid/attachment_relation.js.map +1 -0
- package/build/src/integrations/lucid/attachments_table_stub.d.ts +21 -0
- package/build/src/integrations/lucid/attachments_table_stub.d.ts.map +1 -0
- package/build/src/integrations/lucid/attachments_table_stub.js +26 -0
- package/build/src/integrations/lucid/attachments_table_stub.js.map +1 -0
- package/build/src/integrations/lucid/create_legacy_attachment_migration_script.d.ts +13 -0
- package/build/src/integrations/lucid/create_legacy_attachment_migration_script.d.ts.map +1 -0
- package/build/src/integrations/lucid/create_legacy_attachment_migration_script.js +20 -0
- package/build/src/integrations/lucid/create_legacy_attachment_migration_script.js.map +1 -0
- package/build/src/integrations/lucid/index.d.ts +20 -0
- package/build/src/integrations/lucid/index.d.ts.map +1 -0
- package/build/src/integrations/lucid/index.js +20 -0
- package/build/src/integrations/lucid/index.js.map +1 -0
- package/build/src/integrations/lucid/lucid_attachment_lifecycle_service.d.ts +30 -0
- package/build/src/integrations/lucid/lucid_attachment_lifecycle_service.d.ts.map +1 -0
- package/build/src/integrations/lucid/lucid_attachment_lifecycle_service.js +188 -0
- package/build/src/integrations/lucid/lucid_attachment_lifecycle_service.js.map +1 -0
- package/build/src/integrations/lucid/lucid_attachment_repository.d.ts +18 -0
- package/build/src/integrations/lucid/lucid_attachment_repository.d.ts.map +1 -0
- package/build/src/integrations/lucid/lucid_attachment_repository.js +21 -0
- package/build/src/integrations/lucid/lucid_attachment_repository.js.map +1 -0
- package/build/src/integrations/lucid/lucid_attachment_store.d.ts +36 -0
- package/build/src/integrations/lucid/lucid_attachment_store.d.ts.map +1 -0
- package/build/src/integrations/lucid/lucid_attachment_store.js +179 -0
- package/build/src/integrations/lucid/lucid_attachment_store.js.map +1 -0
- package/build/src/integrations/lucid/lucid_variant_generation_service.d.ts +24 -0
- package/build/src/integrations/lucid/lucid_variant_generation_service.d.ts.map +1 -0
- package/build/src/integrations/lucid/lucid_variant_generation_service.js +42 -0
- package/build/src/integrations/lucid/lucid_variant_generation_service.js.map +1 -0
- package/build/src/integrations/lucid/migrate_legacy_attachment.d.ts +64 -0
- package/build/src/integrations/lucid/migrate_legacy_attachment.d.ts.map +1 -0
- package/build/src/integrations/lucid/migrate_legacy_attachment.js +89 -0
- package/build/src/integrations/lucid/migrate_legacy_attachment.js.map +1 -0
- package/build/src/integrations/lucid/migrate_legacy_attachment_records.d.ts +34 -0
- package/build/src/integrations/lucid/migrate_legacy_attachment_records.d.ts.map +1 -0
- package/build/src/integrations/lucid/migrate_legacy_attachment_records.js +47 -0
- package/build/src/integrations/lucid/migrate_legacy_attachment_records.js.map +1 -0
- package/build/src/integrations/lucid/render_legacy_attachment_migration_script.d.ts +11 -0
- package/build/src/integrations/lucid/render_legacy_attachment_migration_script.d.ts.map +1 -0
- package/build/src/integrations/lucid/render_legacy_attachment_migration_script.js +41 -0
- package/build/src/integrations/lucid/render_legacy_attachment_migration_script.js.map +1 -0
- package/build/src/queues/adonis_queue.d.ts +27 -0
- package/build/src/queues/adonis_queue.d.ts.map +1 -0
- package/build/src/queues/adonis_queue.js +22 -0
- package/build/src/queues/adonis_queue.js.map +1 -0
- package/build/src/queues/memory_queue.d.ts +22 -0
- package/build/src/queues/memory_queue.d.ts.map +1 -0
- package/build/src/queues/memory_queue.js +67 -0
- package/build/src/queues/memory_queue.js.map +1 -0
- package/build/src/sources/attachment_manager.d.ts +53 -0
- package/build/src/sources/attachment_manager.d.ts.map +1 -0
- package/build/src/sources/attachment_manager.js +177 -0
- package/build/src/sources/attachment_manager.js.map +1 -0
- package/build/src/variants/variant_converter.d.ts +23 -0
- package/build/src/variants/variant_converter.d.ts.map +1 -0
- package/build/src/{types/converter.js → variants/variant_converter.js} +1 -0
- package/build/src/variants/variant_converter.js.map +1 -0
- package/build/src/variants/variant_generation_service.d.ts +28 -0
- package/build/src/variants/variant_generation_service.d.ts.map +1 -0
- package/build/src/variants/variant_generation_service.js +44 -0
- package/build/src/variants/variant_generation_service.js.map +1 -0
- package/build/stubs/config/attachment.stub +12 -0
- package/build/stubs/main.d.ts.map +1 -1
- package/build/stubs/main.js +1 -0
- package/build/stubs/main.js.map +1 -0
- package/build/stubs/migrations/attachments_table.stub +39 -0
- package/build/tests/adonis_drive_storage.spec.d.ts +8 -0
- package/build/tests/adonis_drive_storage.spec.d.ts.map +1 -0
- package/build/tests/adonis_drive_storage.spec.js +69 -0
- package/build/tests/adonis_drive_storage.spec.js.map +1 -0
- package/build/{src/types/attachment.js → tests/adonis_queue.spec.d.ts} +1 -0
- package/build/tests/adonis_queue.spec.d.ts.map +1 -0
- package/build/tests/adonis_queue.spec.js +52 -0
- package/build/tests/adonis_queue.spec.js.map +1 -0
- package/build/tests/attachment_job_processor.spec.d.ts +8 -0
- package/build/tests/attachment_job_processor.spec.d.ts.map +1 -0
- package/build/tests/attachment_job_processor.spec.js +89 -0
- package/build/tests/attachment_job_processor.spec.js.map +1 -0
- package/build/tests/attachment_manager.spec.d.ts +8 -0
- package/build/tests/attachment_manager.spec.d.ts.map +1 -0
- package/build/tests/attachment_manager.spec.js +131 -0
- package/build/tests/attachment_manager.spec.js.map +1 -0
- package/build/tests/attachment_manager_service.spec.d.ts +8 -0
- package/build/tests/attachment_manager_service.spec.d.ts.map +1 -0
- package/build/tests/attachment_manager_service.spec.js +47 -0
- package/build/tests/attachment_manager_service.spec.js.map +1 -0
- package/build/tests/attachment_options.spec.d.ts +2 -0
- package/build/tests/attachment_options.spec.d.ts.map +1 -0
- package/build/tests/attachment_options.spec.js +31 -0
- package/build/tests/attachment_options.spec.js.map +1 -0
- package/build/tests/attachment_provider.spec.d.ts +8 -0
- package/build/tests/attachment_provider.spec.d.ts.map +1 -0
- package/build/tests/attachment_provider.spec.js +71 -0
- package/build/tests/attachment_provider.spec.js.map +1 -0
- package/build/tests/attachment_service.spec.d.ts +8 -0
- package/build/tests/attachment_service.spec.d.ts.map +1 -0
- package/build/tests/attachment_service.spec.js +146 -0
- package/build/tests/attachment_service.spec.js.map +1 -0
- package/build/tests/attachments_controller.spec.d.ts +8 -0
- package/build/tests/attachments_controller.spec.d.ts.map +1 -0
- package/build/tests/attachments_controller.spec.js +34 -0
- package/build/tests/attachments_controller.spec.js.map +1 -0
- package/build/tests/attachments_table_stub.spec.d.ts +2 -0
- package/build/tests/attachments_table_stub.spec.d.ts.map +1 -0
- package/build/tests/attachments_table_stub.spec.js +66 -0
- package/build/tests/attachments_table_stub.spec.js.map +1 -0
- package/build/tests/configure.spec.d.ts +2 -0
- package/build/tests/configure.spec.d.ts.map +1 -0
- package/build/tests/configure.spec.js +38 -0
- package/build/tests/configure.spec.js.map +1 -0
- package/build/tests/container_bindings.types.d.ts +8 -0
- package/build/tests/container_bindings.types.d.ts.map +1 -0
- package/build/tests/container_bindings.types.js +9 -0
- package/build/tests/container_bindings.types.js.map +1 -0
- package/build/tests/create_legacy_attachment_migration_script.spec.d.ts +8 -0
- package/build/tests/create_legacy_attachment_migration_script.spec.d.ts.map +1 -0
- package/build/tests/create_legacy_attachment_migration_script.spec.js +31 -0
- package/build/tests/create_legacy_attachment_migration_script.spec.js.map +1 -0
- package/build/tests/define_config.spec.d.ts +8 -0
- package/build/tests/define_config.spec.d.ts.map +1 -0
- package/build/tests/define_config.spec.js +203 -0
- package/build/tests/define_config.spec.js.map +1 -0
- package/build/tests/helpers/lucid_test_database.d.ts +9 -0
- package/build/tests/helpers/lucid_test_database.d.ts.map +1 -0
- package/build/tests/helpers/lucid_test_database.js +52 -0
- package/build/tests/helpers/lucid_test_database.js.map +1 -0
- package/build/tests/local_file_storage.spec.d.ts +8 -0
- package/build/tests/local_file_storage.spec.d.ts.map +1 -0
- package/build/tests/local_file_storage.spec.js +44 -0
- package/build/tests/local_file_storage.spec.js.map +1 -0
- package/build/tests/lucid_attachment_collection_store.spec.d.ts +2 -0
- package/build/tests/lucid_attachment_collection_store.spec.d.ts.map +1 -0
- package/build/tests/lucid_attachment_collection_store.spec.js +52 -0
- package/build/tests/lucid_attachment_collection_store.spec.js.map +1 -0
- package/build/tests/lucid_attachment_column.spec.d.ts +8 -0
- package/build/tests/lucid_attachment_column.spec.d.ts.map +1 -0
- package/build/tests/lucid_attachment_column.spec.js +193 -0
- package/build/tests/lucid_attachment_column.spec.js.map +1 -0
- package/build/tests/lucid_attachment_lifecycle_service.spec.d.ts +8 -0
- package/build/tests/lucid_attachment_lifecycle_service.spec.d.ts.map +1 -0
- package/build/tests/lucid_attachment_lifecycle_service.spec.js +378 -0
- package/build/tests/lucid_attachment_lifecycle_service.spec.js.map +1 -0
- package/build/tests/lucid_attachment_relation.spec.d.ts +8 -0
- package/build/tests/lucid_attachment_relation.spec.d.ts.map +1 -0
- package/build/tests/lucid_attachment_relation.spec.js +216 -0
- package/build/tests/lucid_attachment_relation.spec.js.map +1 -0
- package/build/tests/lucid_attachment_repository.spec.d.ts +8 -0
- package/build/tests/lucid_attachment_repository.spec.d.ts.map +1 -0
- package/build/tests/lucid_attachment_repository.spec.js +50 -0
- package/build/tests/lucid_attachment_repository.spec.js.map +1 -0
- package/build/tests/lucid_attachment_store.spec.d.ts +8 -0
- package/build/tests/lucid_attachment_store.spec.d.ts.map +1 -0
- package/build/tests/lucid_attachment_store.spec.js +73 -0
- package/build/tests/lucid_attachment_store.spec.js.map +1 -0
- package/build/tests/lucid_sqlite_integration.spec.d.ts +8 -0
- package/build/tests/lucid_sqlite_integration.spec.d.ts.map +1 -0
- package/build/tests/lucid_sqlite_integration.spec.js +103 -0
- package/build/tests/lucid_sqlite_integration.spec.js.map +1 -0
- package/build/tests/lucid_variant_generation_service.spec.d.ts +8 -0
- package/build/tests/lucid_variant_generation_service.spec.d.ts.map +1 -0
- package/build/tests/lucid_variant_generation_service.spec.js +56 -0
- package/build/tests/lucid_variant_generation_service.spec.js.map +1 -0
- package/build/tests/memory_queue.spec.d.ts +8 -0
- package/build/tests/memory_queue.spec.d.ts.map +1 -0
- package/build/tests/memory_queue.spec.js +52 -0
- package/build/tests/memory_queue.spec.js.map +1 -0
- package/build/tests/migrate_legacy_attachment.spec.d.ts +8 -0
- package/build/tests/migrate_legacy_attachment.spec.d.ts.map +1 -0
- package/build/tests/migrate_legacy_attachment.spec.js +133 -0
- package/build/tests/migrate_legacy_attachment.spec.js.map +1 -0
- package/build/tests/migrate_legacy_attachment_records.spec.d.ts +8 -0
- package/build/tests/migrate_legacy_attachment_records.spec.d.ts.map +1 -0
- package/build/tests/migrate_legacy_attachment_records.spec.js +66 -0
- package/build/tests/migrate_legacy_attachment_records.spec.js.map +1 -0
- package/build/tests/package_exports.spec.d.ts +8 -0
- package/build/tests/package_exports.spec.d.ts.map +1 -0
- package/build/tests/package_exports.spec.js +31 -0
- package/build/tests/package_exports.spec.js.map +1 -0
- package/build/tests/variant_generation_service.spec.d.ts +8 -0
- package/build/tests/variant_generation_service.spec.d.ts.map +1 -0
- package/build/tests/variant_generation_service.spec.js +79 -0
- package/build/tests/variant_generation_service.spec.js.map +1 -0
- package/package.json +82 -76
- package/build/commands/make/converter.d.ts.map +0 -1
- package/build/commands/make/converter.js +0 -28
- package/build/services/regenerate_service.d.ts +0 -9
- package/build/services/regenerate_service.d.ts.map +0 -1
- package/build/services/regenerate_service.js +0 -29
- package/build/src/adapters/blurhash.d.ts +0 -11
- package/build/src/adapters/blurhash.d.ts.map +0 -1
- package/build/src/adapters/blurhash.js +0 -12
- package/build/src/adapters/exif.d.ts +0 -15
- package/build/src/adapters/exif.d.ts.map +0 -1
- package/build/src/adapters/exif.js +0 -165
- package/build/src/adapters/ffmpeg.d.ts +0 -19
- package/build/src/adapters/ffmpeg.d.ts.map +0 -1
- package/build/src/adapters/ffmpeg.js +0 -115
- package/build/src/adapters/lock.d.ts +0 -9
- package/build/src/adapters/lock.d.ts.map +0 -1
- package/build/src/adapters/lock.js +0 -21
- package/build/src/adapters/meta.d.ts +0 -10
- package/build/src/adapters/meta.d.ts.map +0 -1
- package/build/src/adapters/meta.js +0 -49
- package/build/src/adapters/poppler.d.ts +0 -20
- package/build/src/adapters/poppler.d.ts.map +0 -1
- package/build/src/adapters/poppler.js +0 -117
- package/build/src/adapters/soffice.d.ts +0 -14
- package/build/src/adapters/soffice.d.ts.map +0 -1
- package/build/src/adapters/soffice.js +0 -64
- package/build/src/attachment_manager.d.ts +0 -50
- package/build/src/attachment_manager.d.ts.map +0 -1
- package/build/src/attachment_manager.js +0 -145
- package/build/src/attachments/attachment.d.ts +0 -42
- package/build/src/attachments/attachment.d.ts.map +0 -1
- package/build/src/attachments/attachment.js +0 -233
- package/build/src/attachments/attachment_base.d.ts +0 -59
- package/build/src/attachments/attachment_base.d.ts.map +0 -1
- package/build/src/attachments/attachment_base.js +0 -211
- package/build/src/attachments/variant_attachment.d.ts +0 -27
- package/build/src/attachments/variant_attachment.d.ts.map +0 -1
- package/build/src/attachments/variant_attachment.js +0 -40
- package/build/src/converters/autodetect_converter.d.ts +0 -13
- package/build/src/converters/autodetect_converter.d.ts.map +0 -1
- package/build/src/converters/autodetect_converter.js +0 -77
- package/build/src/converters/converter.d.ts +0 -14
- package/build/src/converters/converter.d.ts.map +0 -1
- package/build/src/converters/converter.js +0 -14
- package/build/src/converters/document_thumbnail_converter.d.ts +0 -14
- package/build/src/converters/document_thumbnail_converter.d.ts.map +0 -1
- package/build/src/converters/document_thumbnail_converter.js +0 -36
- package/build/src/converters/image_converter.d.ts +0 -13
- package/build/src/converters/image_converter.d.ts.map +0 -1
- package/build/src/converters/image_converter.js +0 -27
- package/build/src/converters/pdf_thumbnail_converter.d.ts +0 -14
- package/build/src/converters/pdf_thumbnail_converter.d.ts.map +0 -1
- package/build/src/converters/pdf_thumbnail_converter.js +0 -39
- package/build/src/converters/video_thumbnail_converter.d.ts +0 -14
- package/build/src/converters/video_thumbnail_converter.d.ts.map +0 -1
- package/build/src/converters/video_thumbnail_converter.js +0 -40
- package/build/src/decorators/attachment.d.ts +0 -15
- package/build/src/decorators/attachment.d.ts.map +0 -1
- package/build/src/decorators/attachment.js +0 -103
- package/build/src/errors.d.ts +0 -67
- package/build/src/errors.d.ts.map +0 -1
- package/build/src/errors.js +0 -68
- package/build/src/services/attachment/attachment_detachment_service.d.ts +0 -19
- package/build/src/services/attachment/attachment_detachment_service.d.ts.map +0 -1
- package/build/src/services/attachment/attachment_detachment_service.js +0 -66
- package/build/src/services/attachment/attachment_persister_service.d.ts +0 -22
- package/build/src/services/attachment/attachment_persister_service.d.ts.map +0 -1
- package/build/src/services/attachment/attachment_persister_service.js +0 -96
- package/build/src/services/attachment/attachment_recorder_service.d.ts +0 -68
- package/build/src/services/attachment/attachment_recorder_service.d.ts.map +0 -1
- package/build/src/services/attachment/attachment_recorder_service.js +0 -121
- package/build/src/services/attachment/attachment_transaction_service.d.ts +0 -26
- package/build/src/services/attachment/attachment_transaction_service.d.ts.map +0 -1
- package/build/src/services/attachment/attachment_transaction_service.js +0 -46
- package/build/src/services/attachment/attachment_utils.d.ts +0 -35
- package/build/src/services/attachment/attachment_utils.d.ts.map +0 -1
- package/build/src/services/attachment/attachment_utils.js +0 -71
- package/build/src/services/attachment/attachment_variant_service.d.ts +0 -17
- package/build/src/services/attachment/attachment_variant_service.d.ts.map +0 -1
- package/build/src/services/attachment/attachment_variant_service.js +0 -99
- package/build/src/services/attachment/index.d.ts +0 -15
- package/build/src/services/attachment/index.d.ts.map +0 -1
- package/build/src/services/attachment/index.js +0 -15
- package/build/src/services/attachment_service.d.ts +0 -8
- package/build/src/services/attachment_service.d.ts.map +0 -1
- package/build/src/services/attachment_service.js +0 -7
- package/build/src/services/variant/variant_generator_service.d.ts +0 -24
- package/build/src/services/variant/variant_generator_service.d.ts.map +0 -1
- package/build/src/services/variant/variant_generator_service.js +0 -101
- package/build/src/services/variant/variant_persister_service.d.ts +0 -24
- package/build/src/services/variant/variant_persister_service.d.ts.map +0 -1
- package/build/src/services/variant/variant_persister_service.js +0 -59
- package/build/src/services/variant/variant_purger_service.d.ts +0 -15
- package/build/src/services/variant/variant_purger_service.d.ts.map +0 -1
- package/build/src/services/variant/variant_purger_service.js +0 -47
- package/build/src/services/variant_service.d.ts +0 -13
- package/build/src/services/variant_service.d.ts.map +0 -1
- package/build/src/services/variant_service.js +0 -63
- package/build/src/types/attachment.d.ts +0 -100
- package/build/src/types/attachment.d.ts.map +0 -1
- package/build/src/types/config.d.ts +0 -58
- package/build/src/types/config.d.ts.map +0 -1
- package/build/src/types/converter.d.ts +0 -144
- package/build/src/types/converter.d.ts.map +0 -1
- package/build/src/types/drive.d.ts +0 -6
- package/build/src/types/drive.d.ts.map +0 -1
- package/build/src/types/drive.js +0 -1
- package/build/src/types/event.d.ts +0 -16
- package/build/src/types/event.d.ts.map +0 -1
- package/build/src/types/index.d.ts +0 -15
- package/build/src/types/index.d.ts.map +0 -1
- package/build/src/types/index.js +0 -14
- package/build/src/types/input.d.ts +0 -35
- package/build/src/types/input.d.ts.map +0 -1
- package/build/src/types/input.js +0 -7
- package/build/src/types/lock.d.ts +0 -14
- package/build/src/types/lock.d.ts.map +0 -1
- package/build/src/types/lock.js +0 -7
- package/build/src/types/metadata.d.ts +0 -24
- package/build/src/types/metadata.d.ts.map +0 -1
- package/build/src/types/metadata.js +0 -7
- package/build/src/types/mixin.d.ts +0 -17
- package/build/src/types/mixin.d.ts.map +0 -1
- package/build/src/types/mixin.js +0 -7
- package/build/src/types/regenerate.d.ts +0 -12
- package/build/src/types/regenerate.d.ts.map +0 -1
- package/build/src/types/regenerate.js +0 -7
- package/build/src/types/service.d.ts +0 -25
- package/build/src/types/service.d.ts.map +0 -1
- package/build/src/types/service.js +0 -7
- package/build/src/utils/default_values.d.ts +0 -20
- package/build/src/utils/default_values.d.ts.map +0 -1
- package/build/src/utils/default_values.js +0 -19
- package/build/src/utils/helpers.d.ts +0 -19
- package/build/src/utils/helpers.d.ts.map +0 -1
- package/build/src/utils/helpers.js +0 -131
- package/build/src/utils/hooks.d.ts +0 -12
- package/build/src/utils/hooks.d.ts.map +0 -1
- package/build/src/utils/hooks.js +0 -42
- package/build/src/utils/symbols.d.ts +0 -8
- package/build/src/utils/symbols.d.ts.map +0 -1
- package/build/src/utils/symbols.js +0 -7
- package/build/stubs/config.stub +0 -140
- package/build/stubs/make/converter/main.stub +0 -20
- package/build/tsconfig.tsbuildinfo +0 -1
package/README.md
CHANGED
|
@@ -1,93 +1,22 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Adonis Attachment
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
> Ready for AdonisJS 7 🎉
|
|
3
|
+
Attachment primitives for AdonisJS 7. Version 6 separates file storage, persistence, variants, and queues while keeping Lucid optional.
|
|
5
4
|
|
|
5
|
+
This branch is currently published as a `6.0.0-alpha` refactor.
|
|
6
6
|
|
|
7
|
-
##
|
|
8
|
-
|
|
9
|
-
[View documentation](https://adonis-attachment.jrmc.dev/)
|
|
10
|
-
|
|
11
|
-
[ChangeLog](https://adonis-attachment.jrmc.dev/changelog.html)
|
|
12
|
-
|
|
13
|
-
Project sample : [adonis-starter-kit](https://github.com/batosai/adonis-starter-kit)
|
|
14
|
-
|
|
15
|
-
## Roadmap
|
|
16
|
-
|
|
17
|
-
- [x] attachment file by file system
|
|
18
|
-
- [x] attachment file by buffer
|
|
19
|
-
- [x] attachment file by path
|
|
20
|
-
- [x] attachment file by url
|
|
21
|
-
- [x] attachment file by stream
|
|
22
|
-
- [x] attachment file by Base64
|
|
23
|
-
- [x] attachment files
|
|
24
|
-
- [x] save meta data
|
|
25
|
-
- [x] variantes
|
|
26
|
-
- [x] images
|
|
27
|
-
- [x] [blurhash](https://blurha.sh/)
|
|
28
|
-
- [x] documents thumbnail
|
|
29
|
-
- [x] videos thumbnail
|
|
30
|
-
- [x] command regenerate
|
|
31
|
-
- [x] command make:convert
|
|
32
|
-
- [x] adonis-drive/flydrive
|
|
33
|
-
- [x] jobs queue
|
|
34
|
-
- [x] serialize
|
|
35
|
-
- [x] attachments route
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
## Setup
|
|
39
|
-
|
|
40
|
-
Install and configure the package:
|
|
7
|
+
## Installation
|
|
41
8
|
|
|
42
9
|
```sh
|
|
10
|
+
npm install @jrmc/adonis-attachment
|
|
43
11
|
node ace add @jrmc/adonis-attachment
|
|
44
12
|
```
|
|
45
13
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
If you use an AI coding agent (Claude Code, Cursor, Codex...), you can install skills that teach it the package API, variants/converters configuration and version migrations:
|
|
49
|
-
|
|
50
|
-
```sh
|
|
51
|
-
npx skills add batosai/adonis-attachment
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
## Sample
|
|
55
|
-
|
|
56
|
-
Simple upload file
|
|
57
|
-
|
|
58
|
-
```ts
|
|
59
|
-
// app/models/user.ts
|
|
60
|
-
import { BaseModel } from '@adonisjs/lucid/orm'
|
|
61
|
-
import { attachment } from '@jrmc/adonis-attachment'
|
|
62
|
-
import type { Attachment } from '@jrmc/adonis-attachment/types/attachment'
|
|
63
|
-
|
|
64
|
-
class User extends BaseModel {
|
|
65
|
-
@attachment()
|
|
66
|
-
declare avatar: Attachment
|
|
67
|
-
}
|
|
68
|
-
```
|
|
14
|
+
Configure storage in `config/attachment.ts`, then add Lucid, Drive, or `@adonisjs/queue` only when the application uses those integrations.
|
|
69
15
|
|
|
70
|
-
|
|
16
|
+
## Documentation
|
|
71
17
|
|
|
72
|
-
|
|
73
|
-
// app/controllers/users_controller.ts
|
|
74
|
-
import { attachmentManager } from '@jrmc/adonis-attachment'
|
|
18
|
+
The VitePress guide in [`docs`](./docs) covers configuration, Lucid persistence, custom persistence, queues, routes, variants, and migration from v5.
|
|
75
19
|
|
|
76
|
-
|
|
77
|
-
public store({ request }: HttpContext) {
|
|
78
|
-
const avatar = request.file('avatar')!
|
|
79
|
-
const user = new User()
|
|
80
|
-
|
|
81
|
-
user.avatar = await attachmentManager.createFromFile(avatar)
|
|
82
|
-
await user.save()
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
---
|
|
88
|
-
|
|
89
|
-
```edge
|
|
90
|
-
<img src="{{ await user.avatar.getUrl() }}" loading="lazy" alt="" />
|
|
91
|
-
```
|
|
20
|
+
## License
|
|
92
21
|
|
|
93
|
-
|
|
22
|
+
MIT
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test.d.ts","sourceRoot":"","sources":["../../bin/test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { assert } from '@japa/assert';
|
|
2
|
+
import { configure, processCLIArgs, run } from '@japa/runner';
|
|
3
|
+
processCLIArgs(process.argv.slice(2));
|
|
4
|
+
configure({
|
|
5
|
+
files: ['build/tests/**/*.spec.js'],
|
|
6
|
+
plugins: [assert()],
|
|
7
|
+
});
|
|
8
|
+
run();
|
|
9
|
+
//# sourceMappingURL=test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test.js","sourceRoot":"","sources":["../../bin/test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AACrC,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,GAAG,EAAE,MAAM,cAAc,CAAA;AAE7D,cAAc,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;AAErC,SAAS,CAAC;IACR,KAAK,EAAE,CAAC,0BAA0B,CAAC;IACnC,OAAO,EAAE,CAAC,MAAM,EAAE,CAAC;CACpB,CAAC,CAAA;AAEF,GAAG,EAAE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"commands":[{"commandName":"make:
|
|
1
|
+
{"commands":[{"commandName":"make:attachment-v5-migration","description":"Create a script for migrating v5 attachment JSON values","help":"","namespace":"make","aliases":[],"flags":[],"args":[],"options":{"startApp":true,"allowUnknownFlags":true},"filePath":"make/attachment_v5_migration.js"},{"commandName":"make:attachments-table","description":"Create the polymorphic attachments table migration","help":"","namespace":"make","aliases":[],"flags":[],"args":[],"options":{"startApp":true,"allowUnknownFlags":true},"filePath":"make/attachments_table.js"}],"version":1}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jrmc/adonis-attachment
|
|
3
|
+
*
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
+
*/
|
|
7
|
+
import { BaseCommand } from '@adonisjs/core/ace';
|
|
8
|
+
export default class MakeAttachmentV5Migration extends BaseCommand {
|
|
9
|
+
static commandName: string;
|
|
10
|
+
static description: string;
|
|
11
|
+
static options: {
|
|
12
|
+
startApp: boolean;
|
|
13
|
+
allowUnknownFlags: boolean;
|
|
14
|
+
};
|
|
15
|
+
run(): Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=attachment_v5_migration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachment_v5_migration.d.ts","sourceRoot":"","sources":["../../../commands/make/attachment_v5_migration.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAIhD,MAAM,CAAC,OAAO,OAAO,yBAA0B,SAAQ,WAAW;IAChE,MAAM,CAAC,WAAW,SAAiC;IACnD,MAAM,CAAC,WAAW,SAA4D;IAC9E,MAAM,CAAC,OAAO;;;MAGb;IAEK,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAU3B"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jrmc/adonis-attachment
|
|
3
|
+
*
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
+
*/
|
|
7
|
+
import { BaseCommand } from '@adonisjs/core/ace';
|
|
8
|
+
import { createLegacyAttachmentMigrationScript } from '../../src/integrations/lucid/create_legacy_attachment_migration_script.js';
|
|
9
|
+
export default class MakeAttachmentV5Migration extends BaseCommand {
|
|
10
|
+
static commandName = 'make:attachment-v5-migration';
|
|
11
|
+
static description = 'Create a script for migrating v5 attachment JSON values';
|
|
12
|
+
static options = {
|
|
13
|
+
startApp: true,
|
|
14
|
+
allowUnknownFlags: true,
|
|
15
|
+
};
|
|
16
|
+
async run() {
|
|
17
|
+
const flags = this.parsed.flags;
|
|
18
|
+
const folder = flags.folder ?? 'database/scripts';
|
|
19
|
+
const filePath = await createLegacyAttachmentMigrationScript({
|
|
20
|
+
directory: this.app.makePath(folder),
|
|
21
|
+
...(flags.disk ? { defaultDisk: flags.disk } : {}),
|
|
22
|
+
});
|
|
23
|
+
this.logger.success(`Created ${filePath}`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=attachment_v5_migration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachment_v5_migration.js","sourceRoot":"","sources":["../../../commands/make/attachment_v5_migration.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAEhD,OAAO,EAAE,qCAAqC,EAAE,MAAM,2EAA2E,CAAA;AAEjI,MAAM,CAAC,OAAO,OAAO,yBAA0B,SAAQ,WAAW;IAChE,MAAM,CAAC,WAAW,GAAG,8BAA8B,CAAA;IACnD,MAAM,CAAC,WAAW,GAAG,yDAAyD,CAAA;IAC9E,MAAM,CAAC,OAAO,GAAG;QACf,QAAQ,EAAE,IAAI;QACd,iBAAiB,EAAE,IAAI;KACxB,CAAA;IAED,KAAK,CAAC,GAAG;QACP,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,KAA2C,CAAA;QACrE,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,IAAI,kBAAkB,CAAA;QACjD,MAAM,QAAQ,GAAG,MAAM,qCAAqC,CAAC;YAC3D,SAAS,EAAE,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC;YACpC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SACnD,CAAC,CAAA;QAEF,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,WAAW,QAAQ,EAAE,CAAC,CAAA;IAC5C,CAAC"}
|
|
@@ -5,11 +5,13 @@
|
|
|
5
5
|
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
6
|
*/
|
|
7
7
|
import { BaseCommand } from '@adonisjs/core/ace';
|
|
8
|
-
export default class
|
|
8
|
+
export default class MakeAttachmentsTable extends BaseCommand {
|
|
9
9
|
static commandName: string;
|
|
10
10
|
static description: string;
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
static options: {
|
|
12
|
+
startApp: boolean;
|
|
13
|
+
allowUnknownFlags: boolean;
|
|
14
|
+
};
|
|
13
15
|
run(): Promise<void>;
|
|
14
16
|
}
|
|
15
|
-
//# sourceMappingURL=
|
|
17
|
+
//# sourceMappingURL=attachments_table.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachments_table.d.ts","sourceRoot":"","sources":["../../../commands/make/attachments_table.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAKhD,MAAM,CAAC,OAAO,OAAO,oBAAqB,SAAQ,WAAW;IAC3D,MAAM,CAAC,WAAW,SAA2B;IAC7C,MAAM,CAAC,WAAW,SAAuD;IACzE,MAAM,CAAC,OAAO;;;MAGb;IAEK,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAa3B"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jrmc/adonis-attachment
|
|
3
|
+
*
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
+
*/
|
|
7
|
+
import { BaseCommand } from '@adonisjs/core/ace';
|
|
8
|
+
import { stubsRoot } from '../../stubs/main.js';
|
|
9
|
+
import { createAttachmentsTableStubState } from '../../src/integrations/lucid/attachments_table_stub.js';
|
|
10
|
+
export default class MakeAttachmentsTable extends BaseCommand {
|
|
11
|
+
static commandName = 'make:attachments-table';
|
|
12
|
+
static description = 'Create the polymorphic attachments table migration';
|
|
13
|
+
static options = {
|
|
14
|
+
startApp: true,
|
|
15
|
+
allowUnknownFlags: true,
|
|
16
|
+
};
|
|
17
|
+
async run() {
|
|
18
|
+
const flags = this.parsed.flags;
|
|
19
|
+
const tableName = flags.table ?? 'attachments';
|
|
20
|
+
const folder = flags.folder ?? 'database/migrations';
|
|
21
|
+
const state = createAttachmentsTableStubState({
|
|
22
|
+
directory: this.app.makePath(folder),
|
|
23
|
+
tableName,
|
|
24
|
+
});
|
|
25
|
+
const codemods = await this.createCodemods();
|
|
26
|
+
await codemods.makeUsingStub(stubsRoot, 'migrations/attachments_table.stub', state);
|
|
27
|
+
this.logger.success(`Created ${state.destination}`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=attachments_table.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachments_table.js","sourceRoot":"","sources":["../../../commands/make/attachments_table.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAEhD,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAC/C,OAAO,EAAE,+BAA+B,EAAE,MAAM,wDAAwD,CAAA;AAExG,MAAM,CAAC,OAAO,OAAO,oBAAqB,SAAQ,WAAW;IAC3D,MAAM,CAAC,WAAW,GAAG,wBAAwB,CAAA;IAC7C,MAAM,CAAC,WAAW,GAAG,oDAAoD,CAAA;IACzE,MAAM,CAAC,OAAO,GAAG;QACf,QAAQ,EAAE,IAAI;QACd,iBAAiB,EAAE,IAAI;KACxB,CAAA;IAED,KAAK,CAAC,GAAG;QACP,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,KAA4C,CAAA;QACtE,MAAM,SAAS,GAAG,KAAK,CAAC,KAAK,IAAI,aAAa,CAAA;QAC9C,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,IAAI,qBAAqB,CAAA;QACpD,MAAM,KAAK,GAAG,+BAA+B,CAAC;YAC5C,SAAS,EAAE,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC;YACpC,SAAS;SACV,CAAC,CAAA;QACF,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,cAAc,EAAE,CAAA;QAE5C,MAAM,QAAQ,CAAC,aAAa,CAAC,SAAS,EAAE,mCAAmC,EAAE,KAAK,CAAC,CAAA;QACnF,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,WAAW,KAAK,CAAC,WAAW,EAAE,CAAC,CAAA;IACrD,CAAC"}
|
package/build/configure.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configure.d.ts","sourceRoot":"","sources":["../configure.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"configure.d.ts","sourceRoot":"","sources":["../configure.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,SAAS,MAAM,mCAAmC,CAAA;AAE9D,wBAAsB,SAAS,CAAC,OAAO,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAejE"}
|
package/build/configure.js
CHANGED
|
@@ -10,7 +10,7 @@ export async function configure(command) {
|
|
|
10
10
|
/**
|
|
11
11
|
* Create default config file
|
|
12
12
|
*/
|
|
13
|
-
await codemods.makeUsingStub(stubsRoot, 'config.stub', {});
|
|
13
|
+
await codemods.makeUsingStub(stubsRoot, 'config/attachment.stub', {});
|
|
14
14
|
/**
|
|
15
15
|
* Register provider
|
|
16
16
|
*/
|
|
@@ -19,3 +19,4 @@ export async function configure(command) {
|
|
|
19
19
|
rcFile.addCommand('@jrmc/adonis-attachment/commands');
|
|
20
20
|
});
|
|
21
21
|
}
|
|
22
|
+
//# sourceMappingURL=configure.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configure.js","sourceRoot":"","sources":["../configure.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAI3C,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,OAAkB;IAChD,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,cAAc,EAAE,CAAA;IAE/C;;OAEG;IACH,MAAM,QAAQ,CAAC,aAAa,CAAC,SAAS,EAAE,wBAAwB,EAAE,EAAE,CAAC,CAAA;IAErE;;OAEG;IACH,MAAM,QAAQ,CAAC,YAAY,CAAC,CAAC,MAAM,EAAE,EAAE;QACrC,MAAM,CAAC,WAAW,CAAC,6CAA6C,CAAC,CAAA;QACjE,MAAM,CAAC,UAAU,CAAC,kCAAkC,CAAC,CAAA;IACvD,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
package/build/index.d.ts
CHANGED
|
@@ -1,12 +1,28 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import type { AttachmentService } from "./src/core/attachment_service.js";
|
|
2
|
+
import type { AttachmentRepository } from "./src/core/attachment_repository.js";
|
|
3
|
+
import type { AttachmentManager } from "./src/sources/attachment_manager.js";
|
|
4
|
+
import attachmentManager from "./services/main.js";
|
|
5
|
+
declare module "@adonisjs/core/types" {
|
|
6
|
+
interface ContainerBindings {
|
|
7
|
+
"jrmc.attachment": AttachmentService;
|
|
8
|
+
"jrmc.attachment.manager": AttachmentManager;
|
|
9
|
+
"jrmc.attachment.repository": AttachmentRepository;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export * from "./src/core/index.js";
|
|
13
|
+
export { configure } from "./configure.js";
|
|
9
14
|
export { attachmentManager };
|
|
10
|
-
export {
|
|
11
|
-
export {
|
|
15
|
+
export { defineConfig, type AttachmentConfig, type ResolvedAttachmentConfig, } from "./src/define_config.js";
|
|
16
|
+
export { AdonisDriveStorage } from "./src/adapters/adonis_drive_storage.js";
|
|
17
|
+
export { LocalFileStorage, type LocalFileStorageOptions, } from "./src/adapters/local_file_storage.js";
|
|
18
|
+
export { attachment, type LucidAttachmentOptions, } from "./src/integrations/lucid/attachment_column.js";
|
|
19
|
+
export { attachmentRelation, attachmentsRelation, AttachmentRelation, AttachmentCollectionRelation, type AttachmentRelationOptions, } from "./src/integrations/lucid/attachment_relation.js";
|
|
20
|
+
export { VariantGenerationService, UnknownVariantConverterError, type GeneratedVariant, type VariantGenerationServiceOptions, } from "./src/variants/variant_generation_service.js";
|
|
21
|
+
export { type VariantConverter, type VariantConversionInput, type VariantConversionOutput, } from "./src/variants/variant_converter.js";
|
|
22
|
+
export { MemoryAttachmentQueue } from "./src/queues/memory_queue.js";
|
|
23
|
+
export { AttachmentManager, AttachmentSourceError, type AttachmentManagerOptions, type AttachmentSourceFetch, type AttachmentSourceOptions, type AttachmentSourceResponse, type MultipartAttachmentFile, } from "./src/sources/attachment_manager.js";
|
|
24
|
+
export { AdonisAttachmentQueue, type AdonisAttachmentJob, type AdonisAttachmentQueueOptions, type AdonisQueueDispatcher, } from "./src/queues/adonis_queue.js";
|
|
25
|
+
export { migrateLegacyAttachment, migrateLegacyAttachmentColumn, type AttachmentOwner, type LegacyAttachment, type LegacyVariant, type MigrateLegacyAttachmentColumnOptions, type MigratedAttachmentRow, } from "./src/integrations/lucid/migrate_legacy_attachment.js";
|
|
26
|
+
export { createAttachmentOwnerKey } from "./src/integrations/lucid/attachment_owner.js";
|
|
27
|
+
export { createAttachmentsTableStubState } from "./src/integrations/lucid/attachments_table_stub.js";
|
|
12
28
|
//# sourceMappingURL=index.d.ts.map
|
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,iBAAiB,MAAM,oBAAoB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAC1E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAChF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AAE7E,OAAO,iBAAiB,MAAM,oBAAoB,CAAC;AAEnD,OAAO,QAAQ,sBAAsB,CAAC;IACpC,UAAiB,iBAAiB;QAChC,iBAAiB,EAAE,iBAAiB,CAAC;QACrC,yBAAyB,EAAE,iBAAiB,CAAC;QAC7C,4BAA4B,EAAE,oBAAoB,CAAC;KACpD;CACF;AAED,cAAc,qBAAqB,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,CAAC;AAC7B,OAAO,EACL,YAAY,EACZ,KAAK,gBAAgB,EACrB,KAAK,wBAAwB,GAC9B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAC5E,OAAO,EACL,gBAAgB,EAChB,KAAK,uBAAuB,GAC7B,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EACL,UAAU,EACV,KAAK,sBAAsB,GAC5B,MAAM,+CAA+C,CAAC;AACvD,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,kBAAkB,EAClB,4BAA4B,EAC5B,KAAK,yBAAyB,GAC/B,MAAM,iDAAiD,CAAC;AACzD,OAAO,EACL,wBAAwB,EACxB,4BAA4B,EAC5B,KAAK,gBAAgB,EACrB,KAAK,+BAA+B,GACrC,MAAM,8CAA8C,CAAC;AACtD,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,GAC7B,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,KAAK,wBAAwB,EAC7B,KAAK,qBAAqB,EAC1B,KAAK,uBAAuB,EAC5B,KAAK,wBAAwB,EAC7B,KAAK,uBAAuB,GAC7B,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EACL,qBAAqB,EACrB,KAAK,mBAAmB,EACxB,KAAK,4BAA4B,EACjC,KAAK,qBAAqB,GAC3B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,uBAAuB,EACvB,6BAA6B,EAC7B,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,oCAAoC,EACzC,KAAK,qBAAqB,GAC3B,MAAM,uDAAuD,CAAC;AAC/D,OAAO,EAAE,wBAAwB,EAAE,MAAM,8CAA8C,CAAC;AACxF,OAAO,EAAE,+BAA+B,EAAE,MAAM,oDAAoD,CAAC"}
|
package/build/index.js
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
|
-
import attachmentManager from
|
|
2
|
-
|
|
3
|
-
export { configure } from
|
|
4
|
-
export { Attachment } from './src/attachments/attachment.js';
|
|
5
|
-
export { attachment } from './src/decorators/attachment.js';
|
|
6
|
-
export { attachments } from './src/decorators/attachment.js';
|
|
7
|
-
export { defineConfig } from './src/define_config.js';
|
|
8
|
-
export * as errors from './src/errors.js';
|
|
1
|
+
import attachmentManager from "./services/main.js";
|
|
2
|
+
export * from "./src/core/index.js";
|
|
3
|
+
export { configure } from "./configure.js";
|
|
9
4
|
export { attachmentManager };
|
|
10
|
-
export {
|
|
5
|
+
export { defineConfig, } from "./src/define_config.js";
|
|
6
|
+
export { AdonisDriveStorage } from "./src/adapters/adonis_drive_storage.js";
|
|
7
|
+
export { LocalFileStorage, } from "./src/adapters/local_file_storage.js";
|
|
8
|
+
export { attachment, } from "./src/integrations/lucid/attachment_column.js";
|
|
9
|
+
export { attachmentRelation, attachmentsRelation, AttachmentRelation, AttachmentCollectionRelation, } from "./src/integrations/lucid/attachment_relation.js";
|
|
10
|
+
export { VariantGenerationService, UnknownVariantConverterError, } from "./src/variants/variant_generation_service.js";
|
|
11
|
+
export { MemoryAttachmentQueue } from "./src/queues/memory_queue.js";
|
|
12
|
+
export { AttachmentManager, AttachmentSourceError, } from "./src/sources/attachment_manager.js";
|
|
13
|
+
export { AdonisAttachmentQueue, } from "./src/queues/adonis_queue.js";
|
|
14
|
+
export { migrateLegacyAttachment, migrateLegacyAttachmentColumn, } from "./src/integrations/lucid/migrate_legacy_attachment.js";
|
|
15
|
+
export { createAttachmentOwnerKey } from "./src/integrations/lucid/attachment_owner.js";
|
|
16
|
+
export { createAttachmentsTableStubState } from "./src/integrations/lucid/attachments_table_stub.js";
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAIA,OAAO,iBAAiB,MAAM,oBAAoB,CAAC;AAUnD,cAAc,qBAAqB,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,CAAC;AAC7B,OAAO,EACL,YAAY,GAGb,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAC5E,OAAO,EACL,gBAAgB,GAEjB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EACL,UAAU,GAEX,MAAM,+CAA+C,CAAC;AACvD,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,kBAAkB,EAClB,4BAA4B,GAE7B,MAAM,iDAAiD,CAAC;AACzD,OAAO,EACL,wBAAwB,EACxB,4BAA4B,GAG7B,MAAM,8CAA8C,CAAC;AAMtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EACL,iBAAiB,EACjB,qBAAqB,GAMtB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EACL,qBAAqB,GAItB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,uBAAuB,EACvB,6BAA6B,GAM9B,MAAM,uDAAuD,CAAC;AAC/D,OAAO,EAAE,wBAAwB,EAAE,MAAM,8CAA8C,CAAC;AACxF,OAAO,EAAE,+BAA+B,EAAE,MAAM,oDAAoD,CAAC"}
|
|
@@ -5,26 +5,7 @@
|
|
|
5
5
|
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
6
|
*/
|
|
7
7
|
import type { ApplicationService } from '@adonisjs/core/types';
|
|
8
|
-
import type { Route } from '@adonisjs/core/http';
|
|
9
|
-
import type { AttachmentService } from '../src/types/config.js';
|
|
10
|
-
import type { AttachmentEventPayload } from '../src/types/event.js';
|
|
11
|
-
declare module '@adonisjs/core/types' {
|
|
12
|
-
interface ContainerBindings {
|
|
13
|
-
'jrmc.attachment': AttachmentService;
|
|
14
|
-
}
|
|
15
|
-
interface EventsList {
|
|
16
|
-
'attachment:variant_started': AttachmentEventPayload;
|
|
17
|
-
'attachment:variant_completed': AttachmentEventPayload;
|
|
18
|
-
'attachment:variant_failed': AttachmentEventPayload;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
declare module '@adonisjs/core/http' {
|
|
22
|
-
interface Router {
|
|
23
|
-
attachments: (pattern?: string) => Route;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
8
|
export default class AttachmentProvider {
|
|
27
|
-
#private;
|
|
28
9
|
protected app: ApplicationService;
|
|
29
10
|
constructor(app: ApplicationService);
|
|
30
11
|
register(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attachment_provider.d.ts","sourceRoot":"","sources":["../../providers/attachment_provider.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"attachment_provider.d.ts","sourceRoot":"","sources":["../../providers/attachment_provider.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AAG9D,MAAM,CAAC,OAAO,OAAO,kBAAkB;IACzB,SAAS,CAAC,GAAG,EAAE,kBAAkB;gBAAvB,GAAG,EAAE,kBAAkB;IAE7C,QAAQ,IAAI,IAAI;IA2CV,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAgB5B"}
|
|
@@ -5,46 +5,50 @@
|
|
|
5
5
|
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
6
|
*/
|
|
7
7
|
import { configProvider } from '@adonisjs/core';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
import { AttachmentService } from '../src/core/attachment_service.js';
|
|
9
|
+
import { AttachmentsController } from '../src/controllers/attachments_controller.js';
|
|
10
|
+
import { AttachmentManager } from '../src/sources/attachment_manager.js';
|
|
10
11
|
export default class AttachmentProvider {
|
|
11
12
|
app;
|
|
12
|
-
#manager = null;
|
|
13
13
|
constructor(app) {
|
|
14
14
|
this.app = app;
|
|
15
15
|
}
|
|
16
16
|
register() {
|
|
17
17
|
this.app.container.singleton('jrmc.attachment', async () => {
|
|
18
|
-
const { AttachmentManager } = await import('../src/attachment_manager.js');
|
|
19
18
|
const attachmentConfig = this.app.config.get('attachment');
|
|
20
19
|
const config = await configProvider.resolve(this.app, attachmentConfig);
|
|
21
|
-
const driveManager = await this.app.container.make('drive.manager');
|
|
22
|
-
const driveConfigProvider = this.app.config.get('drive');
|
|
23
|
-
const driveConfig = await configProvider.resolve(this.app, driveConfigProvider);
|
|
24
|
-
const drive = {
|
|
25
|
-
driveManager,
|
|
26
|
-
diskDefault: driveConfig.config.default,
|
|
27
|
-
};
|
|
28
|
-
let lock;
|
|
29
|
-
try {
|
|
30
|
-
const lockManager = await this.app.container.make('lock.manager');
|
|
31
|
-
lock = verrou(lockManager);
|
|
32
|
-
}
|
|
33
|
-
catch (error) {
|
|
34
|
-
lock = verrou();
|
|
35
|
-
}
|
|
36
20
|
if (!config) {
|
|
37
|
-
throw new
|
|
21
|
+
throw new Error('Invalid attachment config. Export the result of defineConfig from config/attachment.ts');
|
|
22
|
+
}
|
|
23
|
+
return new AttachmentService(config);
|
|
24
|
+
});
|
|
25
|
+
this.app.container.singleton('jrmc.attachment.repository', async () => {
|
|
26
|
+
const attachmentConfig = this.app.config.get('attachment');
|
|
27
|
+
const config = await configProvider.resolve(this.app, attachmentConfig);
|
|
28
|
+
if (!config?.repository) {
|
|
29
|
+
throw new Error('Attachment routes require a repository in config/attachment.ts');
|
|
38
30
|
}
|
|
39
|
-
|
|
40
|
-
|
|
31
|
+
return config.repository;
|
|
32
|
+
});
|
|
33
|
+
this.app.container.singleton('jrmc.attachment.manager', async () => {
|
|
34
|
+
const attachmentConfig = this.app.config.get('attachment');
|
|
35
|
+
const config = await configProvider.resolve(this.app, attachmentConfig);
|
|
36
|
+
const attachments = await this.app.container.make('jrmc.attachment');
|
|
37
|
+
return new AttachmentManager(attachments, config?.sources);
|
|
41
38
|
});
|
|
42
39
|
}
|
|
43
40
|
async boot() {
|
|
41
|
+
const attachmentConfig = this.app.config.get('attachment');
|
|
42
|
+
const config = await configProvider.resolve(this.app, attachmentConfig);
|
|
43
|
+
if (!config || config.route === false || !config.repository) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
44
46
|
const router = await this.app.container.make('router');
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
router.get(config.route.path, async (context) => {
|
|
48
|
+
const attachments = await this.app.container.make('jrmc.attachment');
|
|
49
|
+
const repository = await this.app.container.make('jrmc.attachment.repository');
|
|
50
|
+
return new AttachmentsController(attachments, repository).handle(context);
|
|
51
|
+
});
|
|
49
52
|
}
|
|
50
53
|
}
|
|
54
|
+
//# sourceMappingURL=attachment_provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachment_provider.js","sourceRoot":"","sources":["../../providers/attachment_provider.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAA;AACrE,OAAO,EAAE,qBAAqB,EAAE,MAAM,8CAA8C,CAAA;AACpF,OAAO,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAA;AAKxE,MAAM,CAAC,OAAO,OAAO,kBAAkB;IACf;IAAtB,YAAsB,GAAuB;QAAvB,QAAG,GAAH,GAAG,CAAoB;IAAG,CAAC;IAEjD,QAAQ;QACN,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,SAAS,CAAC,iBAAiB,EAAE,KAAK,IAAI,EAAE;YACzD,MAAM,gBAAgB,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,YAAY,CAAC,CAAA;YAC1D,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC,OAAO,CACzC,IAAI,CAAC,GAAG,EACR,gBAAgB,CACjB,CAAA;YAED,IAAI,CAAC,MAAM,EAAE,CAAC;gBACZ,MAAM,IAAI,KAAK,CACb,wFAAwF,CACzF,CAAA;YACH,CAAC;YAED,OAAO,IAAI,iBAAiB,CAAC,MAAM,CAAC,CAAA;QACtC,CAAC,CAAC,CAAA;QAEF,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,SAAS,CAAC,4BAA4B,EAAE,KAAK,IAAI,EAAE;YACpE,MAAM,gBAAgB,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,YAAY,CAAC,CAAA;YAC1D,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC,OAAO,CACzC,IAAI,CAAC,GAAG,EACR,gBAAgB,CACjB,CAAA;YAED,IAAI,CAAC,MAAM,EAAE,UAAU,EAAE,CAAC;gBACxB,MAAM,IAAI,KAAK,CAAC,gEAAgE,CAAC,CAAA;YACnF,CAAC;YAED,OAAO,MAAM,CAAC,UAAU,CAAA;QAC1B,CAAC,CAAC,CAAA;QAEF,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,SAAS,CAAC,yBAAyB,EAAE,KAAK,IAAI,EAAE;YACjE,MAAM,gBAAgB,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,YAAY,CAAC,CAAA;YAC1D,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC,OAAO,CACzC,IAAI,CAAC,GAAG,EACR,gBAAgB,CACjB,CAAA;YACD,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAA;YAEpE,OAAO,IAAI,iBAAiB,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,CAAC,CAAA;QAC5D,CAAC,CAAC,CAAA;IACJ,CAAC;IAED,KAAK,CAAC,IAAI;QACR,MAAM,gBAAgB,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,YAAY,CAAC,CAAA;QAC1D,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC,OAAO,CAA2B,IAAI,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAA;QAEjG,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,KAAK,KAAK,KAAK,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;YAC5D,OAAM;QACR,CAAC;QAED,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;QACtD,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;YAC9C,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAA;YACpE,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,4BAA4B,CAAC,CAAA;YAE9E,OAAO,IAAI,qBAAqB,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;QAC3E,CAAC,CAAC,CAAA;IACJ,CAAC;CACF"}
|
package/build/services/main.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @license MIT
|
|
5
5
|
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
6
|
*/
|
|
7
|
-
import type {
|
|
8
|
-
declare
|
|
9
|
-
export
|
|
7
|
+
import type { AttachmentManager } from '../src/sources/attachment_manager.js';
|
|
8
|
+
declare const _default: AttachmentManager;
|
|
9
|
+
export default _default;
|
|
10
10
|
//# sourceMappingURL=main.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../services/main.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../services/main.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAA;wBAoDjB,iBAAiB;AAA7E,wBAA6E"}
|
package/build/services/main.js
CHANGED
|
@@ -5,8 +5,45 @@
|
|
|
5
5
|
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
6
|
*/
|
|
7
7
|
import app from '@adonisjs/core/services/app';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
class AttachmentManagerService {
|
|
9
|
+
#manager;
|
|
10
|
+
createFromBuffer(...args) {
|
|
11
|
+
return this.#resolve().then((manager) => manager.createFromBuffer(...args));
|
|
12
|
+
}
|
|
13
|
+
createFromBase64(...args) {
|
|
14
|
+
return this.#resolve().then((manager) => manager.createFromBase64(...args));
|
|
15
|
+
}
|
|
16
|
+
createFromPath(...args) {
|
|
17
|
+
return this.#resolve().then((manager) => manager.createFromPath(...args));
|
|
18
|
+
}
|
|
19
|
+
createFromStream(...args) {
|
|
20
|
+
return this.#resolve().then((manager) => manager.createFromStream(...args));
|
|
21
|
+
}
|
|
22
|
+
createFromUrl(...args) {
|
|
23
|
+
return this.#resolve().then((manager) => manager.createFromUrl(...args));
|
|
24
|
+
}
|
|
25
|
+
createFromFile(...args) {
|
|
26
|
+
return this.#resolve().then((manager) => manager.createFromFile(...args));
|
|
27
|
+
}
|
|
28
|
+
createFromFiles(...args) {
|
|
29
|
+
return this.#resolve().then((manager) => manager.createFromFiles(...args));
|
|
30
|
+
}
|
|
31
|
+
#resolve() {
|
|
32
|
+
if (!app) {
|
|
33
|
+
throw new Error('attachmentManager requires a booted AdonisJS application');
|
|
34
|
+
}
|
|
35
|
+
this.#manager ??= new Promise((resolve, reject) => {
|
|
36
|
+
app.booted(async () => {
|
|
37
|
+
try {
|
|
38
|
+
resolve((await app.container.make('jrmc.attachment.manager')));
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
reject(error);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
return this.#manager;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
export default new AttachmentManagerService();
|
|
49
|
+
//# sourceMappingURL=main.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.js","sourceRoot":"","sources":["../../services/main.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,GAAG,MAAM,6BAA6B,CAAA;AAI7C,MAAM,wBAAwB;IAC5B,QAAQ,CAAwC;IAEhD,gBAAgB,CAAC,GAAG,IAAuD;QACzE,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,gBAAgB,CAAC,GAAG,IAAI,CAAC,CAAC,CAAA;IAC7E,CAAC;IAED,gBAAgB,CAAC,GAAG,IAAuD;QACzE,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,gBAAgB,CAAC,GAAG,IAAI,CAAC,CAAC,CAAA;IAC7E,CAAC;IAED,cAAc,CAAC,GAAG,IAAqD;QACrE,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC,CAAC,CAAA;IAC3E,CAAC;IAED,gBAAgB,CAAC,GAAG,IAAuD;QACzE,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,gBAAgB,CAAC,GAAG,IAAI,CAAC,CAAC,CAAA;IAC7E,CAAC;IAED,aAAa,CAAC,GAAG,IAAoD;QACnE,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,CAAC,CAAA;IAC1E,CAAC;IAED,cAAc,CAAC,GAAG,IAAqD;QACrE,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC,CAAC,CAAA;IAC3E,CAAC;IAED,eAAe,CAAC,GAAG,IAAsD;QACvE,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,eAAe,CAAC,GAAG,IAAI,CAAC,CAAC,CAAA;IAC5E,CAAC;IAED,QAAQ;QACN,IAAI,CAAC,GAAG,EAAE,CAAC;YACT,MAAM,IAAI,KAAK,CAAC,0DAA0D,CAAC,CAAA;QAC7E,CAAC;QAED,IAAI,CAAC,QAAQ,KAAK,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YAChD,GAAG,CAAC,MAAM,CAAC,KAAK,IAAI,EAAE;gBACpB,IAAI,CAAC;oBACH,OAAO,CAAC,CAAC,MAAM,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAsB,CAAC,CAAA;gBACrF,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,MAAM,CAAC,KAAK,CAAC,CAAA;gBACf,CAAC;YACH,CAAC,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;QAEF,OAAO,IAAI,CAAC,QAAQ,CAAA;IACtB,CAAC;CACF;AAED,eAAe,IAAI,wBAAwB,EAAkC,CAAA"}
|
|
@@ -0,0 +1,33 @@
|
|
|
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 AdonisDriveDisk = {
|
|
10
|
+
put(path: string, contents: Uint8Array): Promise<void>;
|
|
11
|
+
getBytes(path: string): Promise<Uint8Array>;
|
|
12
|
+
delete(path: string): Promise<void>;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Structural subset of Adonis DriveService. Keeping it local makes this adapter
|
|
16
|
+
* optional while still accepting the real Drive service through TypeScript's structural typing.
|
|
17
|
+
*/
|
|
18
|
+
export type AdonisDriveService = {
|
|
19
|
+
use(disk?: string): AdonisDriveDisk;
|
|
20
|
+
};
|
|
21
|
+
export declare class AdonisDriveStorage implements AttachmentStorage {
|
|
22
|
+
#private;
|
|
23
|
+
readonly defaultDisk: string | undefined;
|
|
24
|
+
constructor(drive: AdonisDriveService, defaultDisk?: string);
|
|
25
|
+
/**
|
|
26
|
+
* Creates a Drive adapter using the default disk declared in config/drive.ts.
|
|
27
|
+
*/
|
|
28
|
+
static fromApp(app: ApplicationService): Promise<AdonisDriveStorage>;
|
|
29
|
+
write(input: WriteAttachmentInput): Promise<void>;
|
|
30
|
+
read(location: StorageLocation): Promise<Uint8Array>;
|
|
31
|
+
remove(location: StorageLocation): Promise<void>;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=adonis_drive_storage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adonis_drive_storage.d.ts","sourceRoot":"","sources":["../../../src/adapters/adonis_drive_storage.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AAE9D,OAAO,KAAK,EAAE,iBAAiB,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAA;AAElG,MAAM,MAAM,eAAe,GAAG;IAC5B,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACtD,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;IAC3C,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CACpC,CAAA;AAED;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,GAAG,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,eAAe,CAAA;CACpC,CAAA;AAED,qBAAa,kBAAmB,YAAW,iBAAiB;;IAE1D,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,CAAA;gBAE5B,KAAK,EAAE,kBAAkB,EAAE,WAAW,CAAC,EAAE,MAAM;IAK3D;;OAEG;WACU,OAAO,CAAC,GAAG,EAAE,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAgBpE,KAAK,CAAC,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;IAIvD,IAAI,CAAC,QAAQ,EAAE,eAAe,GAAG,OAAO,CAAC,UAAU,CAAC;IAI9C,MAAM,CAAC,QAAQ,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;CAGvD"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jrmc/adonis-attachment
|
|
3
|
+
*
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
+
*/
|
|
7
|
+
import { configProvider } from '@adonisjs/core';
|
|
8
|
+
export class AdonisDriveStorage {
|
|
9
|
+
#drive;
|
|
10
|
+
defaultDisk;
|
|
11
|
+
constructor(drive, defaultDisk) {
|
|
12
|
+
this.#drive = drive;
|
|
13
|
+
this.defaultDisk = defaultDisk;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Creates a Drive adapter using the default disk declared in config/drive.ts.
|
|
17
|
+
*/
|
|
18
|
+
static async fromApp(app) {
|
|
19
|
+
const config = await configProvider.resolve(app, app.config.get('drive'));
|
|
20
|
+
if (!config) {
|
|
21
|
+
throw new Error('Drive config is required when using AdonisDriveStorage.fromApp');
|
|
22
|
+
}
|
|
23
|
+
return new AdonisDriveStorage((await app.container.make('drive.manager')), config.config.default);
|
|
24
|
+
}
|
|
25
|
+
async write(input) {
|
|
26
|
+
await this.#drive.use(input.disk).put(input.path, input.body);
|
|
27
|
+
}
|
|
28
|
+
read(location) {
|
|
29
|
+
return this.#drive.use(location.disk).getBytes(location.path);
|
|
30
|
+
}
|
|
31
|
+
async remove(location) {
|
|
32
|
+
await this.#drive.use(location.disk).delete(location.path);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=adonis_drive_storage.js.map
|