@jrmc/adonis-attachment 6.0.0-alpha.1 → 6.0.0-alpha.3
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/build/commands/commands.json +1 -1
- package/build/commands/make/attachment_v5_migration.d.ts.map +1 -1
- package/build/commands/make/attachment_v5_migration.js +6 -3
- package/build/commands/make/attachment_v5_migration.js.map +1 -1
- package/build/commands/make/attachments_table.d.ts.map +1 -1
- package/build/commands/make/attachments_table.js +8 -2
- package/build/commands/make/attachments_table.js.map +1 -1
- package/build/commands/make/converter.d.ts +17 -0
- package/build/commands/make/converter.d.ts.map +1 -0
- package/build/commands/make/converter.js +27 -0
- package/build/commands/make/converter.js.map +1 -0
- package/build/index.d.ts +12 -6
- package/build/index.d.ts.map +1 -1
- package/build/index.js +3 -5
- package/build/index.js.map +1 -1
- package/build/providers/attachment_provider.d.ts.map +1 -1
- package/build/providers/attachment_provider.js +36 -1
- package/build/providers/attachment_provider.js.map +1 -1
- package/build/services/converters.d.ts +10 -0
- package/build/services/converters.d.ts.map +1 -0
- package/build/services/converters.js +17 -0
- package/build/services/converters.js.map +1 -0
- package/build/src/adapters/adonis_drive_storage.d.ts.map +1 -1
- package/build/src/adapters/adonis_drive_storage.js +4 -1
- package/build/src/adapters/adonis_drive_storage.js.map +1 -1
- package/build/src/adapters/local_file_storage.d.ts.map +1 -1
- package/build/src/adapters/local_file_storage.js +9 -2
- package/build/src/adapters/local_file_storage.js.map +1 -1
- package/build/src/converters/autodetect_converter.d.ts +24 -0
- package/build/src/converters/autodetect_converter.d.ts.map +1 -0
- package/build/src/converters/autodetect_converter.js +113 -0
- package/build/src/converters/autodetect_converter.js.map +1 -0
- package/build/src/converters/configured_variant_converter_registry.d.ts +36 -0
- package/build/src/converters/configured_variant_converter_registry.d.ts.map +1 -0
- package/build/src/converters/configured_variant_converter_registry.js +81 -0
- package/build/src/converters/configured_variant_converter_registry.js.map +1 -0
- package/build/src/converters/converter.d.ts +148 -0
- package/build/src/converters/converter.d.ts.map +1 -0
- package/build/src/converters/converter.js +24 -0
- package/build/src/converters/converter.js.map +1 -0
- package/build/src/core/attachment.d.ts +7 -3
- package/build/src/core/attachment.d.ts.map +1 -1
- package/build/src/core/attachment.js +29 -4
- package/build/src/core/attachment.js.map +1 -1
- package/build/src/core/attachment_job_processor.d.ts +17 -1
- package/build/src/core/attachment_job_processor.d.ts.map +1 -1
- package/build/src/core/attachment_job_processor.js +81 -8
- package/build/src/core/attachment_job_processor.js.map +1 -1
- package/build/src/core/attachment_metadata_persister.d.ts +13 -0
- package/build/src/core/attachment_metadata_persister.d.ts.map +1 -0
- package/build/{tests/create_legacy_attachment_migration_script.spec.d.ts → src/core/attachment_metadata_persister.js} +1 -1
- package/build/src/core/attachment_metadata_persister.js.map +1 -0
- package/build/src/core/attachment_options.d.ts +3 -2
- package/build/src/core/attachment_options.d.ts.map +1 -1
- package/build/src/core/attachment_options.js.map +1 -1
- package/build/src/core/attachment_service.d.ts +24 -1
- package/build/src/core/attachment_service.d.ts.map +1 -1
- package/build/src/core/attachment_service.js +95 -4
- package/build/src/core/attachment_service.js.map +1 -1
- package/build/src/core/index.d.ts +9 -2
- package/build/src/core/index.d.ts.map +1 -1
- package/build/src/core/index.js +8 -2
- package/build/src/core/index.js.map +1 -1
- package/build/src/core/queue.d.ts +11 -1
- package/build/src/core/queue.d.ts.map +1 -1
- package/build/src/define_config.d.ts +40 -3
- package/build/src/define_config.d.ts.map +1 -1
- package/build/src/define_config.js +43 -1
- package/build/src/define_config.js.map +1 -1
- package/build/src/errors.d.ts +57 -0
- package/build/src/errors.d.ts.map +1 -0
- package/build/src/errors.js +96 -0
- package/build/src/errors.js.map +1 -0
- package/build/src/events/adonis_attachment_event_emitter.d.ts +17 -0
- package/build/src/events/adonis_attachment_event_emitter.d.ts.map +1 -0
- package/build/src/events/adonis_attachment_event_emitter.js +17 -0
- package/build/src/events/adonis_attachment_event_emitter.js.map +1 -0
- package/build/src/events/attachment_events.d.ts +43 -0
- package/build/src/events/attachment_events.d.ts.map +1 -0
- package/build/src/events/attachment_events.js +32 -0
- package/build/src/events/attachment_events.js.map +1 -0
- package/build/src/integrations/lucid/{attachment_column.d.ts → column/attachment_column.d.ts} +2 -2
- package/build/src/integrations/lucid/column/attachment_column.d.ts.map +1 -0
- package/build/src/integrations/lucid/{attachment_column.js → column/attachment_column.js} +2 -2
- package/build/src/integrations/lucid/column/attachment_column.js.map +1 -0
- package/build/src/integrations/lucid/index.d.ts +17 -13
- package/build/src/integrations/lucid/index.d.ts.map +1 -1
- package/build/src/integrations/lucid/index.js +17 -13
- package/build/src/integrations/lucid/index.js.map +1 -1
- package/build/src/integrations/lucid/migrations/legacy/legacy_attachment_migration_stub.d.ts +20 -0
- package/build/src/integrations/lucid/migrations/legacy/legacy_attachment_migration_stub.d.ts.map +1 -0
- package/build/src/integrations/lucid/migrations/legacy/legacy_attachment_migration_stub.js +18 -0
- package/build/src/integrations/lucid/migrations/legacy/legacy_attachment_migration_stub.js.map +1 -0
- package/build/src/integrations/lucid/{migrate_legacy_attachment.d.ts → migrations/legacy/migrate_legacy_attachment.d.ts} +22 -10
- package/build/src/integrations/lucid/migrations/legacy/migrate_legacy_attachment.d.ts.map +1 -0
- package/build/src/integrations/lucid/{migrate_legacy_attachment.js → migrations/legacy/migrate_legacy_attachment.js} +35 -25
- package/build/src/integrations/lucid/migrations/legacy/migrate_legacy_attachment.js.map +1 -0
- package/build/src/integrations/lucid/{migrate_legacy_attachment_records.d.ts → migrations/legacy/migrate_legacy_attachment_records.d.ts} +3 -3
- package/build/src/integrations/lucid/migrations/legacy/migrate_legacy_attachment_records.d.ts.map +1 -0
- package/build/src/integrations/lucid/{migrate_legacy_attachment_records.js → migrations/legacy/migrate_legacy_attachment_records.js} +11 -7
- package/build/src/integrations/lucid/migrations/legacy/migrate_legacy_attachment_records.js.map +1 -0
- package/build/src/integrations/lucid/models/attachment_link_model.d.ts +30 -0
- package/build/src/integrations/lucid/models/attachment_link_model.d.ts.map +1 -0
- package/build/src/integrations/lucid/models/attachment_link_model.js +59 -0
- package/build/src/integrations/lucid/models/attachment_link_model.js.map +1 -0
- package/build/src/integrations/lucid/{attachment_model.d.ts → models/attachment_model.d.ts} +5 -8
- package/build/src/integrations/lucid/models/attachment_model.d.ts.map +1 -0
- package/build/src/integrations/lucid/{attachment_model.js → models/attachment_model.js} +5 -16
- package/build/src/integrations/lucid/models/attachment_model.js.map +1 -0
- package/build/src/integrations/lucid/{lucid_attachment_lifecycle_service.d.ts → persistence/lucid_attachment_lifecycle_service.d.ts} +18 -14
- package/build/src/integrations/lucid/persistence/lucid_attachment_lifecycle_service.d.ts.map +1 -0
- package/build/src/integrations/lucid/persistence/lucid_attachment_lifecycle_service.js +252 -0
- package/build/src/integrations/lucid/persistence/lucid_attachment_lifecycle_service.js.map +1 -0
- package/build/src/integrations/lucid/persistence/lucid_attachment_metadata_persister.d.ts +17 -0
- package/build/src/integrations/lucid/persistence/lucid_attachment_metadata_persister.d.ts.map +1 -0
- package/build/src/integrations/lucid/persistence/lucid_attachment_metadata_persister.js +18 -0
- package/build/src/integrations/lucid/persistence/lucid_attachment_metadata_persister.js.map +1 -0
- package/build/src/integrations/lucid/{lucid_attachment_repository.d.ts → persistence/lucid_attachment_repository.d.ts} +3 -3
- package/build/src/integrations/lucid/persistence/lucid_attachment_repository.d.ts.map +1 -0
- package/build/src/integrations/lucid/{lucid_attachment_repository.js → persistence/lucid_attachment_repository.js} +1 -1
- package/build/src/integrations/lucid/persistence/lucid_attachment_repository.js.map +1 -0
- package/build/src/integrations/lucid/persistence/lucid_attachment_store.d.ts +48 -0
- package/build/src/integrations/lucid/persistence/lucid_attachment_store.d.ts.map +1 -0
- package/build/src/integrations/lucid/persistence/lucid_attachment_store.js +226 -0
- package/build/src/integrations/lucid/persistence/lucid_attachment_store.js.map +1 -0
- package/build/src/integrations/lucid/{lucid_variant_generation_service.d.ts → persistence/lucid_variant_generation_service.d.ts} +8 -5
- package/build/src/integrations/lucid/persistence/lucid_variant_generation_service.d.ts.map +1 -0
- package/build/src/integrations/lucid/{lucid_variant_generation_service.js → persistence/lucid_variant_generation_service.js} +9 -3
- package/build/src/integrations/lucid/persistence/lucid_variant_generation_service.js.map +1 -0
- package/build/src/integrations/lucid/relations/attachment_owner.d.ts.map +1 -0
- package/build/src/integrations/lucid/relations/attachment_owner.js.map +1 -0
- package/build/src/integrations/lucid/{attachment_relation.d.ts → relations/attachment_relation.d.ts} +29 -15
- package/build/src/integrations/lucid/relations/attachment_relation.d.ts.map +1 -0
- package/build/src/integrations/lucid/relations/attachment_relation.js +273 -0
- package/build/src/integrations/lucid/relations/attachment_relation.js.map +1 -0
- package/build/src/integrations/lucid/schema/attachment_schema_service.d.ts +28 -0
- package/build/src/integrations/lucid/schema/attachment_schema_service.d.ts.map +1 -0
- package/build/src/integrations/lucid/schema/attachment_schema_service.js +81 -0
- package/build/src/integrations/lucid/schema/attachment_schema_service.js.map +1 -0
- package/build/src/integrations/lucid/schema/attachment_table_names.d.ts +15 -0
- package/build/src/integrations/lucid/schema/attachment_table_names.d.ts.map +1 -0
- package/build/src/integrations/lucid/schema/attachment_table_names.js +23 -0
- package/build/src/integrations/lucid/schema/attachment_table_names.js.map +1 -0
- package/build/src/integrations/lucid/schema/attachments_table_stub.d.ts.map +1 -0
- package/build/src/integrations/lucid/{attachments_table_stub.js → schema/attachments_table_stub.js} +2 -4
- package/build/src/integrations/lucid/schema/attachments_table_stub.js.map +1 -0
- package/build/src/integrations/lucid/schema/configure_lucid_attachment_tables.d.ts +12 -0
- package/build/src/integrations/lucid/schema/configure_lucid_attachment_tables.d.ts.map +1 -0
- package/build/src/integrations/lucid/schema/configure_lucid_attachment_tables.js +19 -0
- package/build/src/integrations/lucid/schema/configure_lucid_attachment_tables.js.map +1 -0
- package/build/src/media/binaries.d.ts +79 -0
- package/build/src/media/binaries.d.ts.map +1 -0
- package/build/src/media/binaries.js +288 -0
- package/build/src/media/binaries.js.map +1 -0
- package/build/src/media/blurhash.d.ts +48 -0
- package/build/src/media/blurhash.d.ts.map +1 -0
- package/build/src/media/blurhash.js +46 -0
- package/build/src/media/blurhash.js.map +1 -0
- package/build/src/media/exif.d.ts +23 -0
- package/build/src/media/exif.d.ts.map +1 -0
- package/build/src/media/exif.js +98 -0
- package/build/src/media/exif.js.map +1 -0
- package/build/src/media/media_metadata.d.ts +55 -0
- package/build/src/media/media_metadata.d.ts.map +1 -0
- package/build/src/media/media_metadata.js +27 -0
- package/build/src/media/media_metadata.js.map +1 -0
- package/build/src/media/sharp.d.ts +45 -0
- package/build/src/media/sharp.d.ts.map +1 -0
- package/build/src/media/sharp.js +76 -0
- package/build/src/media/sharp.js.map +1 -0
- package/build/src/media/v5_metadata.d.ts +20 -0
- package/build/src/media/v5_metadata.d.ts.map +1 -0
- package/build/src/media/v5_metadata.js +20 -0
- package/build/src/media/v5_metadata.js.map +1 -0
- package/build/src/queues/memory_queue.d.ts.map +1 -1
- package/build/src/queues/memory_queue.js +4 -1
- package/build/src/queues/memory_queue.js.map +1 -1
- package/build/src/sources/attachment_manager.d.ts +1 -3
- package/build/src/sources/attachment_manager.d.ts.map +1 -1
- package/build/src/sources/attachment_manager.js +19 -12
- package/build/src/sources/attachment_manager.js.map +1 -1
- package/build/src/variants/variant_converter.d.ts +4 -1
- package/build/src/variants/variant_converter.d.ts.map +1 -1
- package/build/src/variants/variant_generation_service.d.ts +9 -3
- package/build/src/variants/variant_generation_service.d.ts.map +1 -1
- package/build/src/variants/variant_generation_service.js +47 -6
- package/build/src/variants/variant_generation_service.js.map +1 -1
- package/build/stubs/config/attachment.stub +23 -2
- package/build/stubs/converters/converter.stub +18 -0
- package/build/stubs/migrations/attachments_table.stub +7 -25
- package/build/{src/integrations/lucid/render_legacy_attachment_migration_script.js → stubs/migrations/legacy_attachment_migration.stub} +13 -15
- package/build/tests/adonis_queue.spec.js +56 -1
- package/build/tests/adonis_queue.spec.js.map +1 -1
- package/build/tests/attachment_events.spec.d.ts +8 -0
- package/build/tests/attachment_events.spec.d.ts.map +1 -0
- package/build/tests/attachment_events.spec.js +65 -0
- package/build/tests/attachment_events.spec.js.map +1 -0
- package/build/tests/attachment_job_processor.spec.js +77 -2
- package/build/tests/attachment_job_processor.spec.js.map +1 -1
- package/build/tests/attachment_provider.spec.js +84 -1
- package/build/tests/attachment_provider.spec.js.map +1 -1
- package/build/tests/attachment_schema_service.spec.d.ts +8 -0
- package/build/tests/attachment_schema_service.spec.d.ts.map +1 -0
- package/build/tests/attachment_schema_service.spec.js +52 -0
- package/build/tests/attachment_schema_service.spec.js.map +1 -0
- package/build/tests/attachment_service.spec.js +81 -2
- package/build/tests/attachment_service.spec.js.map +1 -1
- package/build/tests/attachment_table_names.spec.d.ts +8 -0
- package/build/tests/attachment_table_names.spec.d.ts.map +1 -0
- package/build/tests/attachment_table_names.spec.js +36 -0
- package/build/tests/attachment_table_names.spec.js.map +1 -0
- package/build/tests/attachments_table_stub.spec.js +41 -6
- package/build/tests/attachments_table_stub.spec.js.map +1 -1
- package/build/tests/autodetect_converter.spec.d.ts +8 -0
- package/build/tests/autodetect_converter.spec.d.ts.map +1 -0
- package/build/tests/autodetect_converter.spec.js +55 -0
- package/build/tests/autodetect_converter.spec.js.map +1 -0
- package/build/tests/binary_media.spec.d.ts +8 -0
- package/build/tests/binary_media.spec.d.ts.map +1 -0
- package/build/tests/binary_media.spec.js +106 -0
- package/build/tests/binary_media.spec.js.map +1 -0
- package/build/tests/blurhash_media.spec.d.ts +8 -0
- package/build/tests/blurhash_media.spec.d.ts.map +1 -0
- package/build/tests/blurhash_media.spec.js +40 -0
- package/build/tests/blurhash_media.spec.js.map +1 -0
- package/build/tests/configure.spec.js +1 -0
- package/build/tests/configure.spec.js.map +1 -1
- package/build/tests/configured_variant_converter_registry.spec.d.ts +8 -0
- package/build/tests/configured_variant_converter_registry.spec.d.ts.map +1 -0
- package/build/tests/configured_variant_converter_registry.spec.js +73 -0
- package/build/tests/configured_variant_converter_registry.spec.js.map +1 -0
- package/build/tests/converter_config.types.d.ts +36 -0
- package/build/tests/converter_config.types.d.ts.map +1 -0
- package/build/tests/converter_config.types.js +60 -0
- package/build/tests/converter_config.types.js.map +1 -0
- package/build/tests/define_config.spec.js +113 -0
- package/build/tests/define_config.spec.js.map +1 -1
- package/build/tests/errors.spec.d.ts +8 -0
- package/build/tests/errors.spec.d.ts.map +1 -0
- package/build/tests/errors.spec.js +43 -0
- package/build/tests/errors.spec.js.map +1 -0
- package/build/tests/exif_media.spec.d.ts +8 -0
- package/build/tests/exif_media.spec.d.ts.map +1 -0
- package/build/tests/exif_media.spec.js +50 -0
- package/build/tests/exif_media.spec.js.map +1 -0
- package/build/tests/helpers/lucid_test_database.d.ts.map +1 -1
- package/build/tests/helpers/lucid_test_database.js +17 -7
- package/build/tests/helpers/lucid_test_database.js.map +1 -1
- package/build/tests/legacy_attachment_migration_stub.spec.d.ts +8 -0
- package/build/tests/legacy_attachment_migration_stub.spec.d.ts.map +1 -0
- package/build/tests/legacy_attachment_migration_stub.spec.js +57 -0
- package/build/tests/legacy_attachment_migration_stub.spec.js.map +1 -0
- package/build/tests/lucid_attachment_collection_store.spec.js +5 -4
- package/build/tests/lucid_attachment_collection_store.spec.js.map +1 -1
- package/build/tests/lucid_attachment_column.spec.js +1 -1
- package/build/tests/lucid_attachment_column.spec.js.map +1 -1
- package/build/tests/lucid_attachment_lifecycle_service.spec.js +144 -256
- package/build/tests/lucid_attachment_lifecycle_service.spec.js.map +1 -1
- package/build/tests/lucid_attachment_metadata_persister.spec.d.ts +8 -0
- package/build/tests/lucid_attachment_metadata_persister.spec.d.ts.map +1 -0
- package/build/tests/lucid_attachment_metadata_persister.spec.js +34 -0
- package/build/tests/lucid_attachment_metadata_persister.spec.js.map +1 -0
- package/build/tests/lucid_attachment_relation.spec.js +167 -27
- package/build/tests/lucid_attachment_relation.spec.js.map +1 -1
- package/build/tests/lucid_attachment_repository.spec.js +1 -1
- package/build/tests/lucid_attachment_repository.spec.js.map +1 -1
- package/build/tests/lucid_attachment_store.spec.js +24 -52
- package/build/tests/lucid_attachment_store.spec.js.map +1 -1
- package/build/tests/lucid_sqlite_integration.spec.js +24 -18
- package/build/tests/lucid_sqlite_integration.spec.js.map +1 -1
- package/build/tests/lucid_variant_generation_service.spec.js +18 -1
- package/build/tests/lucid_variant_generation_service.spec.js.map +1 -1
- package/build/tests/make_converter.spec.d.ts +8 -0
- package/build/tests/make_converter.spec.d.ts.map +1 -0
- package/build/tests/make_converter.spec.js +32 -0
- package/build/tests/make_converter.spec.js.map +1 -0
- package/build/tests/media_metadata.spec.d.ts +8 -0
- package/build/tests/media_metadata.spec.d.ts.map +1 -0
- package/build/tests/media_metadata.spec.js +51 -0
- package/build/tests/media_metadata.spec.js.map +1 -0
- package/build/tests/migrate_legacy_attachment.spec.js +62 -47
- package/build/tests/migrate_legacy_attachment.spec.js.map +1 -1
- package/build/tests/migrate_legacy_attachment_records.spec.js +4 -3
- package/build/tests/migrate_legacy_attachment_records.spec.js.map +1 -1
- package/build/tests/package_exports.spec.js +18 -2
- package/build/tests/package_exports.spec.js.map +1 -1
- package/build/tests/sharp_media.spec.d.ts +8 -0
- package/build/tests/sharp_media.spec.d.ts.map +1 -0
- package/build/tests/sharp_media.spec.js +84 -0
- package/build/tests/sharp_media.spec.js.map +1 -0
- package/build/tests/v5_metadata.spec.d.ts +8 -0
- package/build/tests/v5_metadata.spec.d.ts.map +1 -0
- package/build/tests/v5_metadata.spec.js +19 -0
- package/build/tests/v5_metadata.spec.js.map +1 -0
- package/build/tests/variant_generation_service.spec.js +122 -0
- package/build/tests/variant_generation_service.spec.js.map +1 -1
- package/package.json +50 -2
- package/build/src/integrations/lucid/attachment_column.d.ts.map +0 -1
- package/build/src/integrations/lucid/attachment_column.js.map +0 -1
- package/build/src/integrations/lucid/attachment_model.d.ts.map +0 -1
- package/build/src/integrations/lucid/attachment_model.js.map +0 -1
- package/build/src/integrations/lucid/attachment_owner.d.ts.map +0 -1
- package/build/src/integrations/lucid/attachment_owner.js.map +0 -1
- package/build/src/integrations/lucid/attachment_relation.d.ts.map +0 -1
- package/build/src/integrations/lucid/attachment_relation.js +0 -163
- package/build/src/integrations/lucid/attachment_relation.js.map +0 -1
- package/build/src/integrations/lucid/attachments_table_stub.d.ts.map +0 -1
- package/build/src/integrations/lucid/attachments_table_stub.js.map +0 -1
- package/build/src/integrations/lucid/create_legacy_attachment_migration_script.d.ts +0 -13
- package/build/src/integrations/lucid/create_legacy_attachment_migration_script.d.ts.map +0 -1
- package/build/src/integrations/lucid/create_legacy_attachment_migration_script.js +0 -20
- package/build/src/integrations/lucid/create_legacy_attachment_migration_script.js.map +0 -1
- package/build/src/integrations/lucid/lucid_attachment_lifecycle_service.d.ts.map +0 -1
- package/build/src/integrations/lucid/lucid_attachment_lifecycle_service.js +0 -188
- package/build/src/integrations/lucid/lucid_attachment_lifecycle_service.js.map +0 -1
- package/build/src/integrations/lucid/lucid_attachment_repository.d.ts.map +0 -1
- package/build/src/integrations/lucid/lucid_attachment_repository.js.map +0 -1
- package/build/src/integrations/lucid/lucid_attachment_store.d.ts +0 -36
- package/build/src/integrations/lucid/lucid_attachment_store.d.ts.map +0 -1
- package/build/src/integrations/lucid/lucid_attachment_store.js +0 -179
- package/build/src/integrations/lucid/lucid_attachment_store.js.map +0 -1
- package/build/src/integrations/lucid/lucid_variant_generation_service.d.ts.map +0 -1
- package/build/src/integrations/lucid/lucid_variant_generation_service.js.map +0 -1
- package/build/src/integrations/lucid/migrate_legacy_attachment.d.ts.map +0 -1
- package/build/src/integrations/lucid/migrate_legacy_attachment.js.map +0 -1
- package/build/src/integrations/lucid/migrate_legacy_attachment_records.d.ts.map +0 -1
- package/build/src/integrations/lucid/migrate_legacy_attachment_records.js.map +0 -1
- package/build/src/integrations/lucid/render_legacy_attachment_migration_script.d.ts +0 -11
- package/build/src/integrations/lucid/render_legacy_attachment_migration_script.d.ts.map +0 -1
- package/build/src/integrations/lucid/render_legacy_attachment_migration_script.js.map +0 -1
- package/build/tests/create_legacy_attachment_migration_script.spec.d.ts.map +0 -1
- package/build/tests/create_legacy_attachment_migration_script.spec.js +0 -31
- package/build/tests/create_legacy_attachment_migration_script.spec.js.map +0 -1
- /package/build/src/integrations/lucid/{attachment_owner.d.ts → relations/attachment_owner.d.ts} +0 -0
- /package/build/src/integrations/lucid/{attachment_owner.js → relations/attachment_owner.js} +0 -0
- /package/build/src/integrations/lucid/{attachments_table_stub.d.ts → schema/attachments_table_stub.d.ts} +0 -0
|
@@ -1 +1 @@
|
|
|
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}
|
|
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"},{"commandName":"make:converter","description":"Create a new attachment variant converter","help":"","namespace":"make","aliases":[],"flags":[],"args":[{"name":"name","argumentName":"name","required":true,"description":"The converter name","type":"string"}],"options":{"startApp":true},"filePath":"make/converter.js"}],"version":1}
|
|
@@ -1 +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;
|
|
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;AAKhD,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;CAY3B"}
|
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
6
|
*/
|
|
7
7
|
import { BaseCommand } from '@adonisjs/core/ace';
|
|
8
|
-
import {
|
|
8
|
+
import { stubsRoot } from '../../stubs/main.js';
|
|
9
|
+
import { createLegacyAttachmentMigrationStubState } from '../../src/integrations/lucid/migrations/legacy/legacy_attachment_migration_stub.js';
|
|
9
10
|
export default class MakeAttachmentV5Migration extends BaseCommand {
|
|
10
11
|
static commandName = 'make:attachment-v5-migration';
|
|
11
12
|
static description = 'Create a script for migrating v5 attachment JSON values';
|
|
@@ -16,11 +17,13 @@ export default class MakeAttachmentV5Migration extends BaseCommand {
|
|
|
16
17
|
async run() {
|
|
17
18
|
const flags = this.parsed.flags;
|
|
18
19
|
const folder = flags.folder ?? 'database/scripts';
|
|
19
|
-
const
|
|
20
|
+
const state = createLegacyAttachmentMigrationStubState({
|
|
20
21
|
directory: this.app.makePath(folder),
|
|
21
22
|
...(flags.disk ? { defaultDisk: flags.disk } : {}),
|
|
22
23
|
});
|
|
23
|
-
this.
|
|
24
|
+
const codemods = await this.createCodemods();
|
|
25
|
+
await codemods.makeUsingStub(stubsRoot, 'migrations/legacy_attachment_migration.stub', state);
|
|
26
|
+
this.logger.success(`Created ${state.destination}`);
|
|
24
27
|
}
|
|
25
28
|
}
|
|
26
29
|
//# sourceMappingURL=attachment_v5_migration.js.map
|
|
@@ -1 +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,
|
|
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,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAC/C,OAAO,EAAE,wCAAwC,EAAE,MAAM,oFAAoF,CAAA;AAE7I,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,KAAK,GAAG,wCAAwC,CAAC;YACrD,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;QACF,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,cAAc,EAAE,CAAA;QAE5C,MAAM,QAAQ,CAAC,aAAa,CAAC,SAAS,EAAE,6CAA6C,EAAE,KAAK,CAAC,CAAA;QAC7F,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,WAAW,KAAK,CAAC,WAAW,EAAE,CAAC,CAAA;IACrD,CAAC"}
|
|
@@ -1 +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;
|
|
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;AAQhD,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"}
|
|
@@ -5,8 +5,9 @@
|
|
|
5
5
|
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
6
|
*/
|
|
7
7
|
import { BaseCommand } from '@adonisjs/core/ace';
|
|
8
|
+
import { configProvider } from '@adonisjs/core';
|
|
8
9
|
import { stubsRoot } from '../../stubs/main.js';
|
|
9
|
-
import { createAttachmentsTableStubState } from '../../src/integrations/lucid/attachments_table_stub.js';
|
|
10
|
+
import { createAttachmentsTableStubState } from '../../src/integrations/lucid/schema/attachments_table_stub.js';
|
|
10
11
|
export default class MakeAttachmentsTable extends BaseCommand {
|
|
11
12
|
static commandName = 'make:attachments-table';
|
|
12
13
|
static description = 'Create the polymorphic attachments table migration';
|
|
@@ -16,7 +17,7 @@ export default class MakeAttachmentsTable extends BaseCommand {
|
|
|
16
17
|
};
|
|
17
18
|
async run() {
|
|
18
19
|
const flags = this.parsed.flags;
|
|
19
|
-
const tableName = flags.table ??
|
|
20
|
+
const tableName = flags.table ?? (await configuredTableName(this.app));
|
|
20
21
|
const folder = flags.folder ?? 'database/migrations';
|
|
21
22
|
const state = createAttachmentsTableStubState({
|
|
22
23
|
directory: this.app.makePath(folder),
|
|
@@ -27,4 +28,9 @@ export default class MakeAttachmentsTable extends BaseCommand {
|
|
|
27
28
|
this.logger.success(`Created ${state.destination}`);
|
|
28
29
|
}
|
|
29
30
|
}
|
|
31
|
+
async function configuredTableName(app) {
|
|
32
|
+
const attachmentConfig = app.config.get('attachment');
|
|
33
|
+
const config = await configProvider.resolve(app, attachmentConfig);
|
|
34
|
+
return config?.integrations?.lucid?.tableName ?? 'attachments';
|
|
35
|
+
}
|
|
30
36
|
//# sourceMappingURL=attachments_table.js.map
|
|
@@ -1 +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;
|
|
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;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAE/C,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAC/C,OAAO,EAAE,+BAA+B,EAAE,MAAM,+DAA+D,CAAA;AAI/G,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,CAAC,MAAM,mBAAmB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAA;QACtE,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;;AAGH,KAAK,UAAU,mBAAmB,CAAC,GAAuB;IACxD,MAAM,gBAAgB,GAAG,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,YAAY,CAAC,CAAA;IACrD,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC,OAAO,CAA2B,GAAG,EAAE,gBAAgB,CAAC,CAAA;IAE5F,OAAO,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,SAAS,IAAI,aAAa,CAAA;AAChE,CAAC"}
|
|
@@ -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 MakeConverter extends BaseCommand {
|
|
9
|
+
static commandName: string;
|
|
10
|
+
static description: string;
|
|
11
|
+
static options: {
|
|
12
|
+
startApp: boolean;
|
|
13
|
+
};
|
|
14
|
+
name: string;
|
|
15
|
+
run(): Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=converter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"converter.d.ts","sourceRoot":"","sources":["../../../commands/make/converter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAQ,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAItD,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,WAAW;IACpD,MAAM,CAAC,WAAW,SAAmB;IACrC,MAAM,CAAC,WAAW,SAA8C;IAChE,MAAM,CAAC,OAAO;;MAAqB;IAG3B,IAAI,EAAE,MAAM,CAAA;IAEd,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAK3B"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jrmc/adonis-attachment
|
|
3
|
+
*
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
+
*/
|
|
7
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
8
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
10
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
11
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
12
|
+
};
|
|
13
|
+
import { args, BaseCommand } from '@adonisjs/core/ace';
|
|
14
|
+
import { stubsRoot } from '../../stubs/main.js';
|
|
15
|
+
export default class MakeConverter extends BaseCommand {
|
|
16
|
+
static commandName = 'make:converter';
|
|
17
|
+
static description = 'Create a new attachment variant converter';
|
|
18
|
+
static options = { startApp: true };
|
|
19
|
+
async run() {
|
|
20
|
+
const codemods = await this.createCodemods();
|
|
21
|
+
await codemods.makeUsingStub(stubsRoot, 'converters/converter.stub', { name: this.name });
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
__decorate([
|
|
25
|
+
args.string({ description: 'The converter name' })
|
|
26
|
+
], MakeConverter.prototype, "name", void 0);
|
|
27
|
+
//# sourceMappingURL=converter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"converter.js","sourceRoot":"","sources":["../../../commands/make/converter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;;;;;;;AAEH,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAEtD,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAE/C,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,WAAW;IACpD,MAAM,CAAC,WAAW,GAAG,gBAAgB,CAAA;IACrC,MAAM,CAAC,WAAW,GAAG,2CAA2C,CAAA;IAChE,MAAM,CAAC,OAAO,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAA;IAKnC,KAAK,CAAC,GAAG;QACP,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,cAAc,EAAE,CAAA;QAE5C,MAAM,QAAQ,CAAC,aAAa,CAAC,SAAS,EAAE,2BAA2B,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAA;IAC3F,CAAC;;AANO;IADP,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,oBAAoB,EAAE,CAAC;2CAC/B"}
|
package/build/index.d.ts
CHANGED
|
@@ -1,28 +1,34 @@
|
|
|
1
1
|
import type { AttachmentService } from "./src/core/attachment_service.js";
|
|
2
2
|
import type { AttachmentRepository } from "./src/core/attachment_repository.js";
|
|
3
3
|
import type { AttachmentManager } from "./src/sources/attachment_manager.js";
|
|
4
|
+
import type { VariantConverterRegistry } from "./src/converters/configured_variant_converter_registry.js";
|
|
5
|
+
import type { AttachmentEventEmitter } from "./src/events/attachment_events.js";
|
|
4
6
|
import attachmentManager from "./services/main.js";
|
|
7
|
+
import attachmentConverters from "./services/converters.js";
|
|
8
|
+
/** Augment this interface with `InferConverters<typeof attachmentConfig>` for typed variant keys. */
|
|
9
|
+
export interface AttachmentVariants {
|
|
10
|
+
}
|
|
11
|
+
export type AttachmentVariantKey = [keyof AttachmentVariants] extends [never] ? string : Extract<keyof AttachmentVariants, string>;
|
|
5
12
|
declare module "@adonisjs/core/types" {
|
|
6
13
|
interface ContainerBindings {
|
|
7
14
|
"jrmc.attachment": AttachmentService;
|
|
8
15
|
"jrmc.attachment.manager": AttachmentManager;
|
|
16
|
+
"jrmc.attachment.converters": VariantConverterRegistry;
|
|
9
17
|
"jrmc.attachment.repository": AttachmentRepository;
|
|
18
|
+
"jrmc.attachment.events": AttachmentEventEmitter;
|
|
10
19
|
}
|
|
11
20
|
}
|
|
12
21
|
export * from "./src/core/index.js";
|
|
13
22
|
export { configure } from "./configure.js";
|
|
14
23
|
export { attachmentManager };
|
|
15
|
-
export {
|
|
24
|
+
export { attachmentConverters };
|
|
25
|
+
export { defineConfig, type AttachmentIntegrationsConfig, type AttachmentMediaConfig, type AttachmentEventsConfig, type AttachmentConvertersConfig, type AttachmentConfig, type InferConverters, type LucidAttachmentConfig, type ResolvedAttachmentConfig, } from "./src/define_config.js";
|
|
26
|
+
export { emitAttachmentEvent, toAttachmentEventFailure, type AttachmentEventContext, type AttachmentEventEmitter, type AttachmentEventFailure, type AttachmentEventName, type AttachmentEventPayload, } from "./src/events/attachment_events.js";
|
|
16
27
|
export { AdonisDriveStorage } from "./src/adapters/adonis_drive_storage.js";
|
|
17
28
|
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
29
|
export { VariantGenerationService, UnknownVariantConverterError, type GeneratedVariant, type VariantGenerationServiceOptions, } from "./src/variants/variant_generation_service.js";
|
|
21
30
|
export { type VariantConverter, type VariantConversionInput, type VariantConversionOutput, } from "./src/variants/variant_converter.js";
|
|
22
31
|
export { MemoryAttachmentQueue } from "./src/queues/memory_queue.js";
|
|
23
32
|
export { AttachmentManager, AttachmentSourceError, type AttachmentManagerOptions, type AttachmentSourceFetch, type AttachmentSourceOptions, type AttachmentSourceResponse, type MultipartAttachmentFile, } from "./src/sources/attachment_manager.js";
|
|
24
33
|
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";
|
|
28
34
|
//# 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,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;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iB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C3B,KAAK,sBAAsB,EAC3B,KAAK,sBAAsB,EAC3B,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,GAC5B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAC5E,OAAO,EACL,gBAAgB,EAChB,KAAK,uBAAuB,GAC7B,MAAM,sCAAsC,CAAC;AAC9C,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"}
|
package/build/index.js
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
import attachmentManager from "./services/main.js";
|
|
2
|
+
import attachmentConverters from "./services/converters.js";
|
|
2
3
|
export * from "./src/core/index.js";
|
|
3
4
|
export { configure } from "./configure.js";
|
|
4
5
|
export { attachmentManager };
|
|
6
|
+
export { attachmentConverters };
|
|
5
7
|
export { defineConfig, } from "./src/define_config.js";
|
|
8
|
+
export { emitAttachmentEvent, toAttachmentEventFailure, } from "./src/events/attachment_events.js";
|
|
6
9
|
export { AdonisDriveStorage } from "./src/adapters/adonis_drive_storage.js";
|
|
7
10
|
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
11
|
export { VariantGenerationService, UnknownVariantConverterError, } from "./src/variants/variant_generation_service.js";
|
|
11
12
|
export { MemoryAttachmentQueue } from "./src/queues/memory_queue.js";
|
|
12
13
|
export { AttachmentManager, AttachmentSourceError, } from "./src/sources/attachment_manager.js";
|
|
13
14
|
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
15
|
//# sourceMappingURL=index.js.map
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAMA,OAAO,iBAAiB,MAAM,oBAAoB,CAAC;AACnD,OAAO,oBAAoB,MAAM,0BAA0B,CAAC;AAmB5D,cAAc,qBAAqB,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,CAAC;AAC7B,OAAO,EAAE,oBAAoB,EAAE,CAAC;AAChC,OAAO,EACL,YAAY,GASb,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,mBAAmB,EACnB,wBAAwB,GAMzB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAC5E,OAAO,EACL,gBAAgB,GAEjB,MAAM,sCAAsC,CAAC;AAC9C,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"}
|
|
@@ -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;AAQH,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;IAgFV,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAuB5B"}
|
|
@@ -8,6 +8,7 @@ import { configProvider } from '@adonisjs/core';
|
|
|
8
8
|
import { AttachmentService } from '../src/core/attachment_service.js';
|
|
9
9
|
import { AttachmentsController } from '../src/controllers/attachments_controller.js';
|
|
10
10
|
import { AttachmentManager } from '../src/sources/attachment_manager.js';
|
|
11
|
+
import { AdonisAttachmentEventEmitter } from '../src/events/adonis_attachment_event_emitter.js';
|
|
11
12
|
export default class AttachmentProvider {
|
|
12
13
|
app;
|
|
13
14
|
constructor(app) {
|
|
@@ -20,7 +21,18 @@ export default class AttachmentProvider {
|
|
|
20
21
|
if (!config) {
|
|
21
22
|
throw new Error('Invalid attachment config. Export the result of defineConfig from config/attachment.ts');
|
|
22
23
|
}
|
|
23
|
-
|
|
24
|
+
await applyLucidConfig(config);
|
|
25
|
+
const events = await this.app.container.make('jrmc.attachment.events');
|
|
26
|
+
return new AttachmentService({ ...config, events });
|
|
27
|
+
});
|
|
28
|
+
this.app.container.singleton('jrmc.attachment.events', async () => {
|
|
29
|
+
const attachmentConfig = this.app.config.get('attachment');
|
|
30
|
+
const config = await configProvider.resolve(this.app, attachmentConfig);
|
|
31
|
+
if (config?.events) {
|
|
32
|
+
return config.events;
|
|
33
|
+
}
|
|
34
|
+
const { default: emitter } = await import('@adonisjs/core/services/emitter');
|
|
35
|
+
return new AdonisAttachmentEventEmitter(emitter);
|
|
24
36
|
});
|
|
25
37
|
this.app.container.singleton('jrmc.attachment.repository', async () => {
|
|
26
38
|
const attachmentConfig = this.app.config.get('attachment');
|
|
@@ -28,18 +40,33 @@ export default class AttachmentProvider {
|
|
|
28
40
|
if (!config?.repository) {
|
|
29
41
|
throw new Error('Attachment routes require a repository in config/attachment.ts');
|
|
30
42
|
}
|
|
43
|
+
await applyLucidConfig(config);
|
|
31
44
|
return config.repository;
|
|
32
45
|
});
|
|
33
46
|
this.app.container.singleton('jrmc.attachment.manager', async () => {
|
|
34
47
|
const attachmentConfig = this.app.config.get('attachment');
|
|
35
48
|
const config = await configProvider.resolve(this.app, attachmentConfig);
|
|
49
|
+
if (config) {
|
|
50
|
+
await applyLucidConfig(config);
|
|
51
|
+
}
|
|
36
52
|
const attachments = await this.app.container.make('jrmc.attachment');
|
|
37
53
|
return new AttachmentManager(attachments, config?.sources);
|
|
38
54
|
});
|
|
55
|
+
this.app.container.singleton('jrmc.attachment.converters', async () => {
|
|
56
|
+
const attachmentConfig = this.app.config.get('attachment');
|
|
57
|
+
const config = await configProvider.resolve(this.app, attachmentConfig);
|
|
58
|
+
if (!config?.converters) {
|
|
59
|
+
throw new Error('Attachment converters require a converters entry in config/attachment.ts');
|
|
60
|
+
}
|
|
61
|
+
return config.converters;
|
|
62
|
+
});
|
|
39
63
|
}
|
|
40
64
|
async boot() {
|
|
41
65
|
const attachmentConfig = this.app.config.get('attachment');
|
|
42
66
|
const config = await configProvider.resolve(this.app, attachmentConfig);
|
|
67
|
+
if (config) {
|
|
68
|
+
await applyLucidConfig(config);
|
|
69
|
+
}
|
|
43
70
|
if (!config || config.route === false || !config.repository) {
|
|
44
71
|
return;
|
|
45
72
|
}
|
|
@@ -51,4 +78,12 @@ export default class AttachmentProvider {
|
|
|
51
78
|
});
|
|
52
79
|
}
|
|
53
80
|
}
|
|
81
|
+
async function applyLucidConfig(config) {
|
|
82
|
+
const lucid = config.integrations?.lucid;
|
|
83
|
+
if (!lucid) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
const { configureLucidAttachmentTables } = await import('../src/integrations/lucid/schema/configure_lucid_attachment_tables.js');
|
|
87
|
+
configureLucidAttachmentTables(lucid.tableName);
|
|
88
|
+
}
|
|
54
89
|
//# sourceMappingURL=attachment_provider.js.map
|
|
@@ -1 +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;
|
|
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;AACxE,OAAO,EAAE,4BAA4B,EAAE,MAAM,kDAAkD,CAAA;AAK/F,MAAM,CAAC,OAAO,OAA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;IACJ,CAAC;CACF;AAED,KAAK,UAAU,gBAAgB,CAAC,MAAgC;IAC9D,MAAM,KAAK,GAAG,MAAM,CAAC,YAAY,EAAE,KAAK,CAAA;IAExC,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAM;IACR,CAAC;IAED,MAAM,EAAE,8BAA8B,EAAE,GACtC,MAAM,MAAM,CAAC,uEAAuE,CAAC,CAAA;IACvF,8BAA8B,CAAC,KAAK,CAAC,SAAS,CAAC,CAAA;AACjD,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jrmc/adonis-attachment
|
|
3
|
+
*
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
+
*/
|
|
7
|
+
import type { VariantConverterRegistry } from '../src/converters/configured_variant_converter_registry.js';
|
|
8
|
+
declare const attachmentConverters: VariantConverterRegistry;
|
|
9
|
+
export default attachmentConverters;
|
|
10
|
+
//# sourceMappingURL=converters.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"converters.d.ts","sourceRoot":"","sources":["../../services/converters.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,4DAA4D,CAAA;AAE1G,QAAA,MAAM,oBAAoB,EAAE,wBAO3B,CAAA;AAED,eAAe,oBAAoB,CAAA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jrmc/adonis-attachment
|
|
3
|
+
*
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
+
*/
|
|
7
|
+
import app from '@adonisjs/core/services/app';
|
|
8
|
+
const attachmentConverters = {
|
|
9
|
+
async keys() {
|
|
10
|
+
return (await app.container.make('jrmc.attachment.converters')).keys();
|
|
11
|
+
},
|
|
12
|
+
async get(key) {
|
|
13
|
+
return (await app.container.make('jrmc.attachment.converters')).get(key);
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
export default attachmentConverters;
|
|
17
|
+
//# sourceMappingURL=converters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"converters.js","sourceRoot":"","sources":["../../services/converters.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,GAAG,MAAM,6BAA6B,CAAA;AAK7C,MAAM,oBAAoB,GAA6B;IACrD,KAAK,CAAC,IAAI;QACR,OAAO,CAAC,MAAM,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,4BAA4B,CAA8B,CAAA,CAAC,IAAI,EAAE,CAAA;IACpG,CAAC;IACD,KAAK,CAAC,GAAG,CAAC,GAAW;QACnB,OAAO,CAAC,MAAM,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,4BAA4B,CAA8B,CAAA,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;IACtG,CAAC;CACF,CAAA;AAED,eAAe,oBAAoB,CAAA"}
|
|
@@ -1 +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;
|
|
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;AAGlG,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;IAkBpE,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"}
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
6
|
*/
|
|
7
7
|
import { configProvider } from '@adonisjs/core';
|
|
8
|
+
import { AttachmentError } from '../errors.js';
|
|
8
9
|
export class AdonisDriveStorage {
|
|
9
10
|
#drive;
|
|
10
11
|
defaultDisk;
|
|
@@ -18,7 +19,9 @@ export class AdonisDriveStorage {
|
|
|
18
19
|
static async fromApp(app) {
|
|
19
20
|
const config = await configProvider.resolve(app, app.config.get('drive'));
|
|
20
21
|
if (!config) {
|
|
21
|
-
throw new
|
|
22
|
+
throw new AttachmentError('Drive config is required when using AdonisDriveStorage.fromApp', {
|
|
23
|
+
code: 'E_DRIVE_CONFIG_NOT_FOUND',
|
|
24
|
+
});
|
|
22
25
|
}
|
|
23
26
|
return new AdonisDriveStorage((await app.container.make('drive.manager')), config.config.default);
|
|
24
27
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adonis_drive_storage.js","sourceRoot":"","sources":["../../../src/adapters/adonis_drive_storage.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"adonis_drive_storage.js","sourceRoot":"","sources":["../../../src/adapters/adonis_drive_storage.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAI/C,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAgB9C,MAAM,OAAO,kBAAkB;IACpB,MAAM,CAAoB;IAC1B,WAAW,CAAoB;IAExC,YAAY,KAAyB,EAAE,WAAoB;QACzD,IAAI,CAAC,MAAM,GAAG,KAAK,CAAA;QACnB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;IAChC,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,GAAuB;QAC1C,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC,OAAO,CACzC,GAAG,EACH,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CACxB,CAAA;QAED,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,IAAI,eAAe,CAAC,gEAAgE,EAAE;gBAC1F,IAAI,EAAE,0BAA0B;aACjC,CAAC,CAAA;QACJ,CAAC;QAED,OAAO,IAAI,kBAAkB,CAC3B,CAAC,MAAM,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,eAAe,CAAC,CAAuB,EACjE,MAAM,CAAC,MAAM,CAAC,OAAO,CACtB,CAAA;IACH,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,KAA2B;QACrC,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,CAAA;IAC/D,CAAC;IAED,IAAI,CAAC,QAAyB;QAC5B,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;IAC/D,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,QAAyB;QACpC,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;IAC5D,CAAC;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local_file_storage.d.ts","sourceRoot":"","sources":["../../../src/adapters/local_file_storage.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AAE9D,OAAO,KAAK,EAAE,iBAAiB,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAA;
|
|
1
|
+
{"version":3,"file":"local_file_storage.d.ts","sourceRoot":"","sources":["../../../src/adapters/local_file_storage.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AAE9D,OAAO,KAAK,EAAE,iBAAiB,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAA;AAGlG,MAAM,MAAM,uBAAuB,GAAG;IACpC,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,CAAC,EAAE,MAAM,CAAA;CACd,CAAA;AAED;;GAEG;AACH,qBAAa,gBAAiB,YAAW,iBAAiB;;IAExD,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;gBAEhB,OAAO,EAAE,uBAAuB;IAK5C,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,kBAAkB,GAAG,gBAAgB;IAInD,KAAK,CAAC,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;IAejD,IAAI,CAAC,QAAQ,EAAE,eAAe,GAAG,OAAO,CAAC,UAAU,CAAC;IAIpD,MAAM,CAAC,QAAQ,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;CAwBvD"}
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
import { mkdir, readFile, rename, rm, writeFile } from 'node:fs/promises';
|
|
8
8
|
import { dirname, relative, resolve, sep } from 'node:path';
|
|
9
9
|
import { randomUUID } from 'node:crypto';
|
|
10
|
+
import { AttachmentError } from '../errors.js';
|
|
10
11
|
/**
|
|
11
12
|
* Stores attachment bytes on the local filesystem without requiring Drive.
|
|
12
13
|
*/
|
|
@@ -41,12 +42,18 @@ export class LocalFileStorage {
|
|
|
41
42
|
}
|
|
42
43
|
#resolve(location) {
|
|
43
44
|
if (location.disk !== this.defaultDisk) {
|
|
44
|
-
throw new
|
|
45
|
+
throw new AttachmentError(`LocalFileStorage cannot access the "${location.disk}" disk`, {
|
|
46
|
+
code: 'E_STORAGE_DISK_NOT_FOUND',
|
|
47
|
+
status: 404,
|
|
48
|
+
});
|
|
45
49
|
}
|
|
46
50
|
const filePath = resolve(this.#location, location.path);
|
|
47
51
|
const pathFromRoot = relative(this.#location, filePath);
|
|
48
52
|
if (!pathFromRoot || pathFromRoot === '..' || pathFromRoot.startsWith(`..${sep}`)) {
|
|
49
|
-
throw new
|
|
53
|
+
throw new AttachmentError('Attachment paths must stay inside the local storage directory', {
|
|
54
|
+
code: 'E_STORAGE_PATH_OUTSIDE_ROOT',
|
|
55
|
+
status: 400,
|
|
56
|
+
});
|
|
50
57
|
}
|
|
51
58
|
return filePath;
|
|
52
59
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local_file_storage.js","sourceRoot":"","sources":["../../../src/adapters/local_file_storage.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACzE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAA;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"local_file_storage.js","sourceRoot":"","sources":["../../../src/adapters/local_file_storage.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACzE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAA;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAKxC,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAO9C;;GAEG;AACH,MAAM,OAAO,gBAAgB;IAClB,SAAS,CAAQ;IACjB,WAAW,CAAQ;IAE5B,YAAY,OAAgC;QAC1C,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAA;QAC1C,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,IAAI,IAAI,IAAI,CAAA;IACzC,CAAC;IAED,MAAM,CAAC,OAAO,CAAC,GAAuB;QACpC,OAAO,IAAI,gBAAgB,CAAC,EAAE,QAAQ,EAAE,GAAG,CAAC,QAAQ,CAAC,qBAAqB,CAAC,EAAE,CAAC,CAAA;IAChF,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,KAA2B;QACrC,MAAM,QAAQ,GAA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AY,GAAG,QAAQ,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAA;QAEvD,IAAI,CAAC,YAAY,IAAI,YAAY,KAAK,IAAI,IAAI,YAAY,CAAC,UAAU,CAAC,KAAK,GAAG,EAAE,CAAC,EAAE,CAAC;YAClF,MAAM,IAAI,eAAe,CAAC,+DAA+D,EAAE;gBACzF,IAAI,EAAE,6BAA6B;gBACnC,MAAM,EAAE,GAAG;aACZ,CAAC,CAAA;QACJ,CAAC;QAED,OAAO,QAAQ,CAAA;IACjB,CAAC;CACF"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jrmc/adonis-attachment
|
|
3
|
+
*
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
+
*/
|
|
7
|
+
import Converter, { type ConverterAttributes, type ConverterOptions } from './converter.js';
|
|
8
|
+
import { type CommandRunner } from '../media/binaries.js';
|
|
9
|
+
export type AutodetectConverterOptions = ConverterOptions & {
|
|
10
|
+
runner?: CommandRunner;
|
|
11
|
+
ffmpegCommand?: string;
|
|
12
|
+
pdftoppmCommand?: string;
|
|
13
|
+
officeCommand?: string;
|
|
14
|
+
timeout?: number;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Default v5-compatible converter selected when a configured key has no
|
|
18
|
+
* explicit `converter` loader.
|
|
19
|
+
*/
|
|
20
|
+
export default class AutodetectConverter extends Converter {
|
|
21
|
+
readonly options: Readonly<AutodetectConverterOptions>;
|
|
22
|
+
handle({ attachment, body }: ConverterAttributes): Promise<import("../variants/variant_converter.js").VariantConversionOutput | undefined>;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=autodetect_converter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"autodetect_converter.d.ts","sourceRoot":"","sources":["../../../src/converters/autodetect_converter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,SAAS,EAAE,EAAE,KAAK,mBAAmB,EAAE,KAAK,gBAAgB,EAAoB,MAAM,gBAAgB,CAAA;AAC7G,OAAO,EAIL,KAAK,aAAa,EACnB,MAAM,sBAAsB,CAAA;AAI7B,MAAM,MAAM,0BAA0B,GAAG,gBAAgB,GAAG;IAC1D,MAAM,CAAC,EAAE,aAAa,CAAA;IACtB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB,CAAA;AAED;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,mBAAoB,SAAQ,SAAS;IACxD,SAAiB,OAAO,EAAE,QAAQ,CAAC,0BAA0B,CAAC,CAAA;IAExD,MAAM,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,EAAE,mBAAmB;CA2DvD"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jrmc/adonis-attachment
|
|
3
|
+
*
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
+
*/
|
|
7
|
+
import Converter from './converter.js';
|
|
8
|
+
import { createDocumentThumbnailConverter, createFfmpegThumbnailConverter, createPdfThumbnailConverter, } from '../media/binaries.js';
|
|
9
|
+
import { createSharpVariantConverter } from '../media/sharp.js';
|
|
10
|
+
import { MissingOptionalDependencyError } from '../errors.js';
|
|
11
|
+
/**
|
|
12
|
+
* Default v5-compatible converter selected when a configured key has no
|
|
13
|
+
* explicit `converter` loader.
|
|
14
|
+
*/
|
|
15
|
+
export default class AutodetectConverter extends Converter {
|
|
16
|
+
async handle({ attachment, body }) {
|
|
17
|
+
const options = this.options;
|
|
18
|
+
const resize = normalizeResize(options.resize);
|
|
19
|
+
if (attachment.mimeType.startsWith('image/')) {
|
|
20
|
+
const sharp = await loadSharp();
|
|
21
|
+
return createSharpVariantConverter({
|
|
22
|
+
key: 'autodetect',
|
|
23
|
+
sharp,
|
|
24
|
+
...resize,
|
|
25
|
+
...(options.format ? { format: options.format } : {}),
|
|
26
|
+
autoOrient: options.autoOrient ?? true,
|
|
27
|
+
...(options.folder ? { folder: options.folder } : {}),
|
|
28
|
+
...(options.timeout !== undefined ? { timeout: options.timeout } : {}),
|
|
29
|
+
}).convert({ attachment, body });
|
|
30
|
+
}
|
|
31
|
+
if (attachment.mimeType.startsWith('video/')) {
|
|
32
|
+
const format = binaryFormat(options.format);
|
|
33
|
+
return createFfmpegThumbnailConverter({
|
|
34
|
+
key: 'autodetect',
|
|
35
|
+
...(options.runner ? { runner: options.runner } : {}),
|
|
36
|
+
...(options.ffmpegCommand ? { command: options.ffmpegCommand } : {}),
|
|
37
|
+
...(options.startTime !== undefined ? { time: options.startTime } : {}),
|
|
38
|
+
...(resize.width !== undefined ? { width: resize.width } : {}),
|
|
39
|
+
...(resize.height !== undefined ? { height: resize.height } : {}),
|
|
40
|
+
...(format ? { format } : {}),
|
|
41
|
+
...(options.folder ? { folder: options.folder } : {}),
|
|
42
|
+
...(options.timeout !== undefined ? { timeout: options.timeout } : {}),
|
|
43
|
+
}).convert({ attachment, body });
|
|
44
|
+
}
|
|
45
|
+
if (attachment.mimeType === 'application/pdf') {
|
|
46
|
+
return createPdfThumbnailConverter({
|
|
47
|
+
key: 'autodetect',
|
|
48
|
+
...(options.runner ? { runner: options.runner } : {}),
|
|
49
|
+
...(options.pdftoppmCommand ? { command: options.pdftoppmCommand } : {}),
|
|
50
|
+
...(resize.width !== undefined ? { width: resize.width } : {}),
|
|
51
|
+
...(options.startPage !== undefined ? { page: options.startPage } : {}),
|
|
52
|
+
...(options.folder ? { folder: options.folder } : {}),
|
|
53
|
+
...(options.timeout !== undefined ? { timeout: options.timeout } : {}),
|
|
54
|
+
}).convert({ attachment, body });
|
|
55
|
+
}
|
|
56
|
+
if (isOfficeDocument(attachment.mimeType)) {
|
|
57
|
+
return createDocumentThumbnailConverter({
|
|
58
|
+
key: 'autodetect',
|
|
59
|
+
...(options.runner ? { runner: options.runner } : {}),
|
|
60
|
+
...(options.pdftoppmCommand ? { command: options.pdftoppmCommand } : {}),
|
|
61
|
+
...(options.officeCommand ? { officeCommand: options.officeCommand } : {}),
|
|
62
|
+
...(resize.width !== undefined ? { width: resize.width } : {}),
|
|
63
|
+
...(options.startPage !== undefined ? { page: options.startPage } : {}),
|
|
64
|
+
...(options.folder ? { folder: options.folder } : {}),
|
|
65
|
+
}).convert({ attachment, body });
|
|
66
|
+
}
|
|
67
|
+
return undefined;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
function normalizeResize(value) {
|
|
71
|
+
if (typeof value === 'number') {
|
|
72
|
+
return { width: value };
|
|
73
|
+
}
|
|
74
|
+
if (!value) {
|
|
75
|
+
return {};
|
|
76
|
+
}
|
|
77
|
+
const { width, height, ...options } = value;
|
|
78
|
+
const resize = Object.keys(options).length > 0 ? options : undefined;
|
|
79
|
+
return {
|
|
80
|
+
...(width !== undefined ? { width } : {}),
|
|
81
|
+
...(height !== undefined ? { height } : {}),
|
|
82
|
+
...(resize ? { resize } : {}),
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
function binaryFormat(format) {
|
|
86
|
+
const value = typeof format === 'string' ? format : format?.format;
|
|
87
|
+
if (value === 'jpg' || value === 'jpeg') {
|
|
88
|
+
return 'jpeg';
|
|
89
|
+
}
|
|
90
|
+
return value === 'png' || value === 'webp' ? value : undefined;
|
|
91
|
+
}
|
|
92
|
+
function isOfficeDocument(mimeType) {
|
|
93
|
+
return [
|
|
94
|
+
'application/msword',
|
|
95
|
+
'application/vnd.ms-excel',
|
|
96
|
+
'application/vnd.ms-powerpoint',
|
|
97
|
+
'application/vnd.openxmlformats-officedocument.presentationml.presentation',
|
|
98
|
+
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
|
99
|
+
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
|
100
|
+
'application/vnd.oasis.opendocument.presentation',
|
|
101
|
+
'application/vnd.oasis.opendocument.spreadsheet',
|
|
102
|
+
'application/vnd.oasis.opendocument.text',
|
|
103
|
+
].includes(mimeType);
|
|
104
|
+
}
|
|
105
|
+
async function loadSharp() {
|
|
106
|
+
const specifier = 'sharp';
|
|
107
|
+
const module = await import(specifier);
|
|
108
|
+
if (typeof module.default !== 'function') {
|
|
109
|
+
throw new MissingOptionalDependencyError('sharp');
|
|
110
|
+
}
|
|
111
|
+
return module.default;
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=autodetect_converter.js.map
|