@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
package/build/src/integrations/lucid/{attachments_table_stub.js → schema/attachments_table_stub.js}
RENAMED
|
@@ -5,14 +5,12 @@
|
|
|
5
5
|
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
6
|
*/
|
|
7
7
|
import { join } from 'node:path';
|
|
8
|
+
import { resolveAttachmentTableNames } from './attachment_table_names.js';
|
|
8
9
|
/**
|
|
9
10
|
* Builds the state consumed by the attachments-table migration stub.
|
|
10
11
|
*/
|
|
11
12
|
export function createAttachmentsTableStubState(options) {
|
|
12
|
-
const tableName = options.tableName
|
|
13
|
-
if (!/^[a-z][a-z0-9_]*$/.test(tableName)) {
|
|
14
|
-
throw new Error('Lucid attachment table names must be snake_case identifiers');
|
|
15
|
-
}
|
|
13
|
+
const { tableName } = resolveAttachmentTableNames(options.tableName);
|
|
16
14
|
const timestamp = options.timestamp ?? Date.now();
|
|
17
15
|
return {
|
|
18
16
|
destination: join(options.directory, `${timestamp}_create_${tableName}_table.ts`),
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachments_table_stub.js","sourceRoot":"","sources":["../../../../../src/integrations/lucid/schema/attachments_table_stub.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,2BAA2B,EAAE,MAAM,6BAA6B,CAAA;AAczE;;GAEG;AACH,MAAM,UAAU,+BAA+B,CAC7C,OAAoC;IAEpC,MAAM,EAAE,SAAS,EAAE,GAAG,2BAA2B,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;IAEpE,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,IAAI,CAAC,GAAG,EAAE,CAAA;IAEjD,OAAO;QACL,WAAW,EAAE,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,GAAG,SAAS,WAAW,SAAS,WAAW,CAAC;QACjF,SAAS;QACT,SAAS,EAAE,YAAY,CAAC,SAAS,CAAC;KACnC,CAAA;AACH,CAAC;AAED,SAAS,YAAY,CAAC,KAAa;IACjC,OAAO,KAAK,CAAC,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAAC,EAAE,UAAkB,EAAE,SAAiB,EAAE,EAAE,CACpF,SAAS,CAAC,WAAW,EAAE,CACxB,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jrmc/adonis-attachment
|
|
3
|
+
*
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
+
*/
|
|
7
|
+
import { type AttachmentTableNames } from './attachment_table_names.js';
|
|
8
|
+
/**
|
|
9
|
+
* Applies an application's configured attachment table names to the default Lucid models.
|
|
10
|
+
*/
|
|
11
|
+
export declare function configureLucidAttachmentTables(tableName?: string): AttachmentTableNames;
|
|
12
|
+
//# sourceMappingURL=configure_lucid_attachment_tables.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configure_lucid_attachment_tables.d.ts","sourceRoot":"","sources":["../../../../../src/integrations/lucid/schema/configure_lucid_attachment_tables.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAA+B,KAAK,oBAAoB,EAAE,MAAM,6BAA6B,CAAA;AAEpG;;GAEG;AACH,wBAAgB,8BAA8B,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,oBAAoB,CAOvF"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jrmc/adonis-attachment
|
|
3
|
+
*
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
+
*/
|
|
7
|
+
import { AttachmentLinkModel } from '../models/attachment_link_model.js';
|
|
8
|
+
import { AttachmentModel } from '../models/attachment_model.js';
|
|
9
|
+
import { resolveAttachmentTableNames } from './attachment_table_names.js';
|
|
10
|
+
/**
|
|
11
|
+
* Applies an application's configured attachment table names to the default Lucid models.
|
|
12
|
+
*/
|
|
13
|
+
export function configureLucidAttachmentTables(tableName) {
|
|
14
|
+
const tables = resolveAttachmentTableNames(tableName);
|
|
15
|
+
AttachmentModel.table = tables.tableName;
|
|
16
|
+
AttachmentLinkModel.table = tables.linksTableName;
|
|
17
|
+
return tables;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=configure_lucid_attachment_tables.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configure_lucid_attachment_tables.js","sourceRoot":"","sources":["../../../../../src/integrations/lucid/schema/configure_lucid_attachment_tables.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAA;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAC/D,OAAO,EAAE,2BAA2B,EAA6B,MAAM,6BAA6B,CAAA;AAEpG;;GAEG;AACH,MAAM,UAAU,8BAA8B,CAAC,SAAkB;IAC/D,MAAM,MAAM,GAAG,2BAA2B,CAAC,SAAS,CAAC,CAAA;IAErD,eAAe,CAAC,KAAK,GAAG,MAAM,CAAC,SAAS,CAAA;IACxC,mBAAmB,CAAC,KAAK,GAAG,MAAM,CAAC,cAAc,CAAA;IAEjD,OAAO,MAAM,CAAA;AACf,CAAC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jrmc/adonis-attachment
|
|
3
|
+
*
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
+
*/
|
|
7
|
+
import type { MediaMetadataExtractor } from './media_metadata.js';
|
|
8
|
+
import type { VariantConverter } from '../variants/variant_converter.js';
|
|
9
|
+
import { AttachmentError } from '../errors.js';
|
|
10
|
+
export type CommandExecution = {
|
|
11
|
+
command: string;
|
|
12
|
+
args: readonly string[];
|
|
13
|
+
cwd?: string;
|
|
14
|
+
timeout?: number;
|
|
15
|
+
};
|
|
16
|
+
export type CommandResult = {
|
|
17
|
+
stdout: Uint8Array;
|
|
18
|
+
stderr: Uint8Array;
|
|
19
|
+
};
|
|
20
|
+
export interface CommandRunner {
|
|
21
|
+
run(execution: CommandExecution): Promise<CommandResult>;
|
|
22
|
+
}
|
|
23
|
+
/** Executes a command without a shell and rejects when it returns a non-zero status. */
|
|
24
|
+
export declare class NodeCommandRunner implements CommandRunner {
|
|
25
|
+
run(execution: CommandExecution): Promise<CommandResult>;
|
|
26
|
+
}
|
|
27
|
+
export declare class CommandExecutionError extends AttachmentError {
|
|
28
|
+
static code: string;
|
|
29
|
+
constructor(execution: CommandExecution, code: number | null, stderr: string, options?: ErrorOptions);
|
|
30
|
+
}
|
|
31
|
+
export declare class CommandTimeoutError extends AttachmentError {
|
|
32
|
+
static code: string;
|
|
33
|
+
static status: number;
|
|
34
|
+
constructor(execution: CommandExecution);
|
|
35
|
+
}
|
|
36
|
+
export type FfprobeMetadataExtractorOptions = {
|
|
37
|
+
runner?: CommandRunner;
|
|
38
|
+
command?: string;
|
|
39
|
+
timeout?: number;
|
|
40
|
+
};
|
|
41
|
+
export type PdfInfoMetadataExtractorOptions = {
|
|
42
|
+
runner?: CommandRunner;
|
|
43
|
+
command?: string;
|
|
44
|
+
timeout?: number;
|
|
45
|
+
};
|
|
46
|
+
/** Extracts the v5 PDF dimensions, page count, version, and creation date through pdfinfo. */
|
|
47
|
+
export declare function createPdfInfoMetadataExtractor(options?: PdfInfoMetadataExtractorOptions): MediaMetadataExtractor;
|
|
48
|
+
/** Extracts duration, codecs and video dimensions through ffprobe. */
|
|
49
|
+
export declare function createFfprobeMetadataExtractor(options?: FfprobeMetadataExtractorOptions): MediaMetadataExtractor;
|
|
50
|
+
export type FfmpegThumbnailConverterOptions = {
|
|
51
|
+
key: string;
|
|
52
|
+
runner?: CommandRunner;
|
|
53
|
+
command?: string;
|
|
54
|
+
time?: number;
|
|
55
|
+
width?: number;
|
|
56
|
+
height?: number;
|
|
57
|
+
format?: 'jpeg' | 'png' | 'webp';
|
|
58
|
+
folder?: string;
|
|
59
|
+
timeout?: number;
|
|
60
|
+
};
|
|
61
|
+
/** Creates a video-frame thumbnail converter backed by ffmpeg. */
|
|
62
|
+
export declare function createFfmpegThumbnailConverter(options: FfmpegThumbnailConverterOptions): VariantConverter;
|
|
63
|
+
export type PdfThumbnailConverterOptions = {
|
|
64
|
+
key: string;
|
|
65
|
+
runner?: CommandRunner;
|
|
66
|
+
command?: string;
|
|
67
|
+
width?: number;
|
|
68
|
+
page?: number;
|
|
69
|
+
folder?: string;
|
|
70
|
+
timeout?: number;
|
|
71
|
+
};
|
|
72
|
+
/** Renders the first PDF page to a PNG thumbnail with Poppler's pdftoppm. */
|
|
73
|
+
export declare function createPdfThumbnailConverter(options: PdfThumbnailConverterOptions): VariantConverter;
|
|
74
|
+
export type DocumentThumbnailConverterOptions = PdfThumbnailConverterOptions & {
|
|
75
|
+
officeCommand?: string;
|
|
76
|
+
};
|
|
77
|
+
/** Converts an office document to PDF with LibreOffice, then renders its first page. */
|
|
78
|
+
export declare function createDocumentThumbnailConverter(options: DocumentThumbnailConverterOptions): VariantConverter;
|
|
79
|
+
//# sourceMappingURL=binaries.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"binaries.d.ts","sourceRoot":"","sources":["../../../src/media/binaries.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH,OAAO,KAAK,EAAE,sBAAsB,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BAAgB,CAyBlB"}
|
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jrmc/adonis-attachment
|
|
3
|
+
*
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
+
*/
|
|
7
|
+
import { mkdtemp, readFile, rm, writeFile } from 'node:fs/promises';
|
|
8
|
+
import { tmpdir } from 'node:os';
|
|
9
|
+
import { basename, extname, join } from 'node:path';
|
|
10
|
+
import { spawn } from 'node:child_process';
|
|
11
|
+
import { AttachmentError } from '../errors.js';
|
|
12
|
+
/** Executes a command without a shell and rejects when it returns a non-zero status. */
|
|
13
|
+
export class NodeCommandRunner {
|
|
14
|
+
run(execution) {
|
|
15
|
+
return new Promise((resolve, reject) => {
|
|
16
|
+
const controller = new AbortController();
|
|
17
|
+
const timeout = execution.timeout === undefined
|
|
18
|
+
? undefined
|
|
19
|
+
: setTimeout(() => controller.abort(), execution.timeout);
|
|
20
|
+
const child = spawn(execution.command, execution.args, {
|
|
21
|
+
...(execution.cwd ? { cwd: execution.cwd } : {}),
|
|
22
|
+
signal: controller.signal,
|
|
23
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
24
|
+
});
|
|
25
|
+
const stdout = [];
|
|
26
|
+
const stderr = [];
|
|
27
|
+
let settled = false;
|
|
28
|
+
const finish = (callback) => {
|
|
29
|
+
if (settled) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
settled = true;
|
|
33
|
+
if (timeout) {
|
|
34
|
+
clearTimeout(timeout);
|
|
35
|
+
}
|
|
36
|
+
callback();
|
|
37
|
+
};
|
|
38
|
+
child.stdout.on('data', (chunk) => stdout.push(chunk));
|
|
39
|
+
child.stderr.on('data', (chunk) => stderr.push(chunk));
|
|
40
|
+
child.once('error', (error) => finish(() => {
|
|
41
|
+
if (controller.signal.aborted && execution.timeout !== undefined) {
|
|
42
|
+
reject(new CommandTimeoutError(execution));
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
reject(new CommandExecutionError(execution, null, error.message, { cause: error }));
|
|
46
|
+
}));
|
|
47
|
+
child.once('close', (code) => {
|
|
48
|
+
const result = { stdout: Buffer.concat(stdout), stderr: Buffer.concat(stderr) };
|
|
49
|
+
finish(() => {
|
|
50
|
+
if (controller.signal.aborted && execution.timeout !== undefined) {
|
|
51
|
+
reject(new CommandTimeoutError(execution));
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
if (code === 0) {
|
|
55
|
+
resolve(result);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
reject(new CommandExecutionError(execution, code, Buffer.from(result.stderr).toString()));
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
export class CommandExecutionError extends AttachmentError {
|
|
65
|
+
static code = 'E_COMMAND_EXECUTION_FAILED';
|
|
66
|
+
constructor(execution, code, stderr, options) {
|
|
67
|
+
super(`Command "${execution.command}" exited with code ${code ?? 'unknown'}${stderr ? `: ${stderr}` : ''}`);
|
|
68
|
+
if (options?.cause) {
|
|
69
|
+
this.cause = options.cause;
|
|
70
|
+
}
|
|
71
|
+
this.name = 'CommandExecutionError';
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
export class CommandTimeoutError extends AttachmentError {
|
|
75
|
+
static code = 'E_COMMAND_TIMEOUT';
|
|
76
|
+
static status = 504;
|
|
77
|
+
constructor(execution) {
|
|
78
|
+
super(`Command "${execution.command}" exceeded its ${execution.timeout}ms timeout`);
|
|
79
|
+
this.name = 'CommandTimeoutError';
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
/** Extracts the v5 PDF dimensions, page count, version, and creation date through pdfinfo. */
|
|
83
|
+
export function createPdfInfoMetadataExtractor(options = {}) {
|
|
84
|
+
const runner = options.runner ?? new NodeCommandRunner();
|
|
85
|
+
const command = options.command ?? 'pdfinfo';
|
|
86
|
+
return {
|
|
87
|
+
supports({ attachment }) {
|
|
88
|
+
return attachment.mimeType === 'application/pdf';
|
|
89
|
+
},
|
|
90
|
+
async extract({ attachment, body }) {
|
|
91
|
+
return withTemporarySource(attachment.name, body, async (source) => {
|
|
92
|
+
const result = await runner.run({
|
|
93
|
+
command,
|
|
94
|
+
args: [source],
|
|
95
|
+
...(options.timeout !== undefined ? { timeout: options.timeout } : {}),
|
|
96
|
+
});
|
|
97
|
+
return mapPdfInfoMetadata(Buffer.from(result.stdout).toString());
|
|
98
|
+
});
|
|
99
|
+
},
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
/** Extracts duration, codecs and video dimensions through ffprobe. */
|
|
103
|
+
export function createFfprobeMetadataExtractor(options = {}) {
|
|
104
|
+
const runner = options.runner ?? new NodeCommandRunner();
|
|
105
|
+
const command = options.command ?? 'ffprobe';
|
|
106
|
+
return {
|
|
107
|
+
supports({ attachment }) {
|
|
108
|
+
return attachment.mimeType.startsWith('audio/') || attachment.mimeType.startsWith('video/');
|
|
109
|
+
},
|
|
110
|
+
async extract({ attachment, body }) {
|
|
111
|
+
return withTemporarySource(attachment.name, body, async (source) => {
|
|
112
|
+
const result = await runner.run({
|
|
113
|
+
command,
|
|
114
|
+
args: ['-v', 'error', '-show_format', '-show_streams', '-of', 'json', source],
|
|
115
|
+
...(options.timeout !== undefined ? { timeout: options.timeout } : {}),
|
|
116
|
+
});
|
|
117
|
+
return mapFfprobeMetadata(JSON.parse(Buffer.from(result.stdout).toString()));
|
|
118
|
+
});
|
|
119
|
+
},
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
/** Creates a video-frame thumbnail converter backed by ffmpeg. */
|
|
123
|
+
export function createFfmpegThumbnailConverter(options) {
|
|
124
|
+
const runner = options.runner ?? new NodeCommandRunner();
|
|
125
|
+
const command = options.command ?? 'ffmpeg';
|
|
126
|
+
const format = options.format ?? 'jpeg';
|
|
127
|
+
return createTemporaryThumbnailConverter(options.key, options.folder, async ({ attachment, body }, directory) => {
|
|
128
|
+
const source = await writeSource(directory, attachment.name, body);
|
|
129
|
+
const output = join(directory, `thumbnail.${format}`);
|
|
130
|
+
const args = ['-y'];
|
|
131
|
+
if (options.time !== undefined) {
|
|
132
|
+
args.push('-ss', String(options.time));
|
|
133
|
+
}
|
|
134
|
+
args.push('-i', source, '-frames:v', '1');
|
|
135
|
+
if (options.width !== undefined || options.height !== undefined) {
|
|
136
|
+
args.push('-vf', `scale=${options.width ?? -1}:${options.height ?? -1}`);
|
|
137
|
+
}
|
|
138
|
+
args.push(output);
|
|
139
|
+
await runner.run({ command, args, ...(options.timeout !== undefined ? { timeout: options.timeout } : {}) });
|
|
140
|
+
return { output, format };
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
/** Renders the first PDF page to a PNG thumbnail with Poppler's pdftoppm. */
|
|
144
|
+
export function createPdfThumbnailConverter(options) {
|
|
145
|
+
const runner = options.runner ?? new NodeCommandRunner();
|
|
146
|
+
const command = options.command ?? 'pdftoppm';
|
|
147
|
+
return createTemporaryThumbnailConverter(options.key, options.folder, async ({ attachment, body }, directory) => {
|
|
148
|
+
const source = await writeSource(directory, attachment.name, body);
|
|
149
|
+
const outputBase = join(directory, 'thumbnail');
|
|
150
|
+
const args = ['-f', String(options.page ?? 1), '-singlefile', '-png'];
|
|
151
|
+
if (options.width !== undefined) {
|
|
152
|
+
args.push('-scale-to-x', String(options.width), '-scale-to-y', '-1');
|
|
153
|
+
}
|
|
154
|
+
args.push(source, outputBase);
|
|
155
|
+
await runner.run({ command, args, ...(options.timeout !== undefined ? { timeout: options.timeout } : {}) });
|
|
156
|
+
return { output: `${outputBase}.png`, format: 'png' };
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
/** Converts an office document to PDF with LibreOffice, then renders its first page. */
|
|
160
|
+
export function createDocumentThumbnailConverter(options) {
|
|
161
|
+
const runner = options.runner ?? new NodeCommandRunner();
|
|
162
|
+
const officeCommand = options.officeCommand ?? 'libreoffice';
|
|
163
|
+
const pdfCommand = options.command ?? 'pdftoppm';
|
|
164
|
+
return createTemporaryThumbnailConverter(options.key, options.folder, async ({ attachment, body }, directory) => {
|
|
165
|
+
const source = await writeSource(directory, attachment.name, body);
|
|
166
|
+
const converted = join(directory, `${basename(source, extname(source))}.pdf`);
|
|
167
|
+
const outputBase = join(directory, 'thumbnail');
|
|
168
|
+
await runner.run({
|
|
169
|
+
command: officeCommand,
|
|
170
|
+
args: ['--headless', '--convert-to', 'pdf', '--outdir', directory, source],
|
|
171
|
+
...(options.timeout !== undefined ? { timeout: options.timeout } : {}),
|
|
172
|
+
});
|
|
173
|
+
const args = ['-f', String(options.page ?? 1), '-singlefile', '-png'];
|
|
174
|
+
if (options.width !== undefined) {
|
|
175
|
+
args.push('-scale-to-x', String(options.width), '-scale-to-y', '-1');
|
|
176
|
+
}
|
|
177
|
+
args.push(converted, outputBase);
|
|
178
|
+
await runner.run({ command: pdfCommand, args, ...(options.timeout !== undefined ? { timeout: options.timeout } : {}) });
|
|
179
|
+
return { output: `${outputBase}.png`, format: 'png' };
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
function createTemporaryThumbnailConverter(key, folder, convert) {
|
|
183
|
+
return {
|
|
184
|
+
key,
|
|
185
|
+
async convert(input) {
|
|
186
|
+
return withTemporaryDirectory(async (directory) => {
|
|
187
|
+
const result = await convert(input, directory);
|
|
188
|
+
const body = await readFile(result.output);
|
|
189
|
+
return {
|
|
190
|
+
body,
|
|
191
|
+
fileName: `${key}.${result.format}`,
|
|
192
|
+
mimeType: mimeTypeForFormat(result.format),
|
|
193
|
+
...(folder ? { folder } : {}),
|
|
194
|
+
};
|
|
195
|
+
});
|
|
196
|
+
},
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
async function withTemporarySource(name, body, callback) {
|
|
200
|
+
return withTemporaryDirectory(async (directory) => callback(await writeSource(directory, name, body)));
|
|
201
|
+
}
|
|
202
|
+
async function withTemporaryDirectory(callback) {
|
|
203
|
+
const directory = await mkdtemp(join(tmpdir(), 'adonis-attachment-'));
|
|
204
|
+
try {
|
|
205
|
+
return await callback(directory);
|
|
206
|
+
}
|
|
207
|
+
finally {
|
|
208
|
+
await rm(directory, { recursive: true, force: true });
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
async function writeSource(directory, name, body) {
|
|
212
|
+
const extension = extname(name) || '.bin';
|
|
213
|
+
const source = join(directory, `source${extension}`);
|
|
214
|
+
await writeFile(source, body);
|
|
215
|
+
return source;
|
|
216
|
+
}
|
|
217
|
+
function mapFfprobeMetadata(result) {
|
|
218
|
+
const video = result.streams?.find((stream) => stream.codec_type === 'video');
|
|
219
|
+
const audio = result.streams?.find((stream) => stream.codec_type === 'audio');
|
|
220
|
+
const duration = numberValue(result.format?.duration);
|
|
221
|
+
const bitRate = numberValue(result.format?.bit_rate);
|
|
222
|
+
const metadata = {
|
|
223
|
+
...(duration !== undefined ? { duration } : {}),
|
|
224
|
+
...(bitRate !== undefined ? { bitRate } : {}),
|
|
225
|
+
...(result.format?.format_name ? { format: result.format.format_name } : {}),
|
|
226
|
+
...(video?.width !== undefined && video.height !== undefined
|
|
227
|
+
? { dimension: { width: video.width, height: video.height } }
|
|
228
|
+
: {}),
|
|
229
|
+
...(video?.codec_name ? { videoCodec: video.codec_name } : {}),
|
|
230
|
+
...(audio?.codec_name ? { audioCodec: audio.codec_name } : {}),
|
|
231
|
+
};
|
|
232
|
+
return Object.keys(metadata).length > 0 ? metadata : undefined;
|
|
233
|
+
}
|
|
234
|
+
function numberValue(value) {
|
|
235
|
+
if (value === undefined) {
|
|
236
|
+
return undefined;
|
|
237
|
+
}
|
|
238
|
+
const number = Number(value);
|
|
239
|
+
return Number.isFinite(number) ? number : undefined;
|
|
240
|
+
}
|
|
241
|
+
function mapPdfInfoMetadata(stdout) {
|
|
242
|
+
const values = Object.fromEntries(stdout.split('\n').flatMap((line) => {
|
|
243
|
+
const separator = line.indexOf(':');
|
|
244
|
+
if (separator < 1) {
|
|
245
|
+
return [];
|
|
246
|
+
}
|
|
247
|
+
return [[line.slice(0, separator).trim().toLowerCase(), line.slice(separator + 1).trim()]];
|
|
248
|
+
}));
|
|
249
|
+
const pageSize = values['page size']?.match(/(\d+(?:\.\d+)?)\s*x\s*(\d+(?:\.\d+)?)/i);
|
|
250
|
+
const pages = integerValue(values.pages);
|
|
251
|
+
const date = pdfDate(values.creationdate);
|
|
252
|
+
const metadata = {
|
|
253
|
+
...(pageSize ? { dimension: { width: Number.parseInt(pageSize[1], 10), height: Number.parseInt(pageSize[2], 10) } } : {}),
|
|
254
|
+
...(pages !== undefined ? { pages } : {}),
|
|
255
|
+
...(values['pdf version'] ? { version: values['pdf version'] } : {}),
|
|
256
|
+
...(date ? { date } : {}),
|
|
257
|
+
};
|
|
258
|
+
return Object.keys(metadata).length > 0 ? metadata : undefined;
|
|
259
|
+
}
|
|
260
|
+
function integerValue(value) {
|
|
261
|
+
if (!value) {
|
|
262
|
+
return undefined;
|
|
263
|
+
}
|
|
264
|
+
const number = Number.parseInt(value, 10);
|
|
265
|
+
return Number.isFinite(number) ? number : undefined;
|
|
266
|
+
}
|
|
267
|
+
function pdfDate(value) {
|
|
268
|
+
if (!value) {
|
|
269
|
+
return undefined;
|
|
270
|
+
}
|
|
271
|
+
const parsed = Date.parse(value);
|
|
272
|
+
if (Number.isFinite(parsed)) {
|
|
273
|
+
return new Date(parsed).toISOString();
|
|
274
|
+
}
|
|
275
|
+
const parts = value.match(/^D:(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/);
|
|
276
|
+
if (!parts) {
|
|
277
|
+
return undefined;
|
|
278
|
+
}
|
|
279
|
+
return new Date(Date.UTC(Number(parts[1]), Number(parts[2]) - 1, Number(parts[3]), Number(parts[4]), Number(parts[5]), Number(parts[6]))).toISOString();
|
|
280
|
+
}
|
|
281
|
+
function mimeTypeForFormat(format) {
|
|
282
|
+
switch (format) {
|
|
283
|
+
case 'jpeg': return 'image/jpeg';
|
|
284
|
+
case 'png': return 'image/png';
|
|
285
|
+
case 'webp': return 'image/webp';
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
//# sourceMappingURL=binaries.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"binaries.js","sourceRoot":"","sources":["../../../src/media/binaries.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAChC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AACnD,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAK1C,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAkB9C,wFAAwF;AACxF,MAAM,OAAO,iBAAiB;IAC5B,GAAG,CAAC,SAA2B;QAC7B,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACrC,MAAM,UAAU,GAAG,IAAI,eAAe,EAAE,CAAA;YACxC,MAAM,OAAO,GAAG,SAAS,CAAC,OAAO,KAAK,SAAS;gBAC7C,CAAC,CAAC,SAAS;gBACX,CAAC,CAAC,UAAU,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE,EAAE,SAAS,CAAC,OAAO,CAAC,CAAA;YAC3D,MAAM,KAAK,GAAG,KAAK,CAAC,SAAS,CAAC,OAAO,EAAE,SAAS,CAAC,IAAI,EAAE;gBACrD,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,SAAS,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBAChD,MAAM,EAAE,UAAU,CAAC,MAAM;gBACzB,KAAK,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC;aAClC,CAAC,C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AC,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAC/G,CAAC,CAAC,WAAW,EAAE,CAAA;AAClB,CAAC;AAED,SAAS,iBAAiB,CAAC,MAA+B;IACxD,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,MAAM,CAAC,CAAC,OAAO,YAAY,CAAA;QAChC,KAAK,KAAK,CAAC,CAAC,OAAO,WAAW,CAAA;QAC9B,KAAK,MAAM,CAAC,CAAC,OAAO,YAAY,CAAA;IAClC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jrmc/adonis-attachment
|
|
3
|
+
*
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
+
*/
|
|
7
|
+
export type BlurhashComponent = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
|
|
8
|
+
/** Matches the v5 blurhash declaration accepted by converter configuration. */
|
|
9
|
+
export type BlurhashOptions = boolean | {
|
|
10
|
+
enabled: boolean;
|
|
11
|
+
componentX?: BlurhashComponent;
|
|
12
|
+
componentY?: BlurhashComponent;
|
|
13
|
+
};
|
|
14
|
+
export type BlurhashGeneratorInput = {
|
|
15
|
+
body: Uint8Array;
|
|
16
|
+
componentX: BlurhashComponent;
|
|
17
|
+
componentY: BlurhashComponent;
|
|
18
|
+
};
|
|
19
|
+
/** Generates a blurhash from the final bytes of an image variant. */
|
|
20
|
+
export interface BlurhashGenerator {
|
|
21
|
+
generate(input: BlurhashGeneratorInput): Promise<string>;
|
|
22
|
+
}
|
|
23
|
+
type SharpRawImage = {
|
|
24
|
+
raw(): SharpRawImage;
|
|
25
|
+
ensureAlpha(): SharpRawImage;
|
|
26
|
+
toBuffer(options: {
|
|
27
|
+
resolveWithObject: true;
|
|
28
|
+
}): Promise<{
|
|
29
|
+
data: Uint8Array;
|
|
30
|
+
info: {
|
|
31
|
+
width: number;
|
|
32
|
+
height: number;
|
|
33
|
+
};
|
|
34
|
+
}>;
|
|
35
|
+
};
|
|
36
|
+
export type BlurhashSharpFactory = (input: Uint8Array) => SharpRawImage;
|
|
37
|
+
export type BlurhashEncoder = (pixels: Uint8ClampedArray, width: number, height: number, componentX: BlurhashComponent, componentY: BlurhashComponent) => string | Promise<string>;
|
|
38
|
+
/** Builds a generator from injected Sharp and blurhash implementations. */
|
|
39
|
+
export declare function createSharpBlurhashGenerator(sharp: BlurhashSharpFactory, encode: BlurhashEncoder): BlurhashGenerator;
|
|
40
|
+
/** Loads the optional Sharp and blurhash dependencies only when a converter enables blurhash. */
|
|
41
|
+
export declare class DynamicBlurhashGenerator implements BlurhashGenerator {
|
|
42
|
+
#private;
|
|
43
|
+
generate(input: BlurhashGeneratorInput): Promise<string>;
|
|
44
|
+
}
|
|
45
|
+
export declare function isBlurhashEnabled(options: BlurhashOptions | undefined): boolean;
|
|
46
|
+
export declare function resolveBlurhashComponents(options: BlurhashOptions | undefined): Pick<BlurhashGeneratorInput, 'componentX' | 'componentY'>;
|
|
47
|
+
export {};
|
|
48
|
+
//# sourceMappingURL=blurhash.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blurhash.d.ts","sourceRoot":"","sources":["../../../src/media/blurhash.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,MAAM,MAAM,iBAAiB,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;AAEjE,+EAA+E;AAC/E,MAAM,MAAM,eAAe,GACvB,OAAO,GACP;IACE,OAAO,EAAE,OAAO,CAAA;IAChB,UAAU,CAAC,EAAE,iBAAiB,CAAA;IAC9B,UAAU,CAAC,EAAE,iBAAiB,CAAA;CAC/B,CAAA;AAEL,MAAM,MAAM,sBAAsB,GAAG;IACnC,IAAI,EAAE,UAAU,CA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Y,CAAC,CAK3D"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jrmc/adonis-attachment
|
|
3
|
+
*
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
+
*/
|
|
7
|
+
import { MissingOptionalDependencyError } from '../errors.js';
|
|
8
|
+
/** Builds a generator from injected Sharp and blurhash implementations. */
|
|
9
|
+
export function createSharpBlurhashGenerator(sharp, encode) {
|
|
10
|
+
return {
|
|
11
|
+
async generate({ body, componentX, componentY }) {
|
|
12
|
+
const { data, info } = await sharp(body).raw().ensureAlpha().toBuffer({ resolveWithObject: true });
|
|
13
|
+
return encode(new Uint8ClampedArray(data), info.width, info.height, componentX, componentY);
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
/** Loads the optional Sharp and blurhash dependencies only when a converter enables blurhash. */
|
|
18
|
+
export class DynamicBlurhashGenerator {
|
|
19
|
+
#generator;
|
|
20
|
+
generate(input) {
|
|
21
|
+
this.#generator ??= loadGenerator();
|
|
22
|
+
return this.#generator.then((generator) => generator.generate(input));
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export function isBlurhashEnabled(options) {
|
|
26
|
+
return options === true || (typeof options === 'object' && options.enabled);
|
|
27
|
+
}
|
|
28
|
+
export function resolveBlurhashComponents(options) {
|
|
29
|
+
return {
|
|
30
|
+
componentX: typeof options === 'object' ? options.componentX ?? 4 : 4,
|
|
31
|
+
componentY: typeof options === 'object' ? options.componentY ?? 4 : 4,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
async function loadGenerator() {
|
|
35
|
+
const sharpSpecifier = 'sharp';
|
|
36
|
+
const blurhashSpecifier = 'blurhash';
|
|
37
|
+
const [sharpModule, blurhashModule] = await Promise.all([
|
|
38
|
+
import(sharpSpecifier),
|
|
39
|
+
import(blurhashSpecifier),
|
|
40
|
+
]);
|
|
41
|
+
if (typeof sharpModule.default !== 'function' || typeof blurhashModule.encode !== 'function') {
|
|
42
|
+
throw new MissingOptionalDependencyError(['sharp', 'blurhash']);
|
|
43
|
+
}
|
|
44
|
+
return createSharpBlurhashGenerator(sharpModule.default, blurhashModule.encode);
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=blurhash.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blurhash.js","sourceRoot":"","sources":["../../../src/media/blurhash.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,8BAA8B,EAAE,MAAM,cAAc,CAAA;AA0C7D,2EAA2E;AAC3E,MAAM,UAAU,4BAA4B,CAC1C,KAA2B,EAC3B,MAAuB;IAEvB,OAAO;QACL,KAAK,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,UAAU,EAAE;YAC7C,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,MAAM,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,EAAE,iBAAiB,EAAE,IAAI,EAAE,CAAC,CAAA;YAElG,OAAO,MAAM,CAAC,IAAI,iBAAiB,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,UAAU,EAAE,UAAU,CAAC,CAAA;QAC7F,CAAC;KACF,CAAA;AACH,CAAC;AAED,iGAAiG;AACjG,MAAM,OAAO,wBAAwB;IACnC,UAAU,CAAwC;IAElD,QAAQ,CAAC,KAA6B;QACpC,IAAI,CAAC,UAAU,KAAK,aAAa,EAAE,CAAA;QACnC,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAA;IACvE,CAAC;CACF;AAED,MAAM,UAAU,iBAAiB,CAAC,OAAoC;IACpE,OAAO,OAAO,KAAK,IAAI,IAAI,CAAC,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,CAAC,OAAO,CAAC,CAAA;AAC7E,CAAC;AAED,MAAM,UAAU,yBAAyB,CACvC,OAAoC;IAEpC,OAAO;QACL,UAAU,EAAE,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,UAAU,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QACrE,UAAU,EAAE,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,UAAU,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;KACtE,CAAA;AACH,CAAC;AAED,KAAK,UAAU,aAAa;IAC1B,MAAM,cAAc,GAAG,OAAO,CAAA;IAC9B,MAAM,iBAAiB,GAAG,UAAU,CAAA;IACpC,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QACtD,MAAM,CAAC,cAAc,CAAmC;QACxD,MAAM,CAAC,iBAAiB,CAAkC;KAC3D,CAAC,CAAA;IAEF,IAAI,OAAO,WAAW,CAAC,OAAO,KAAK,UAAU,IAAI,OAAO,cAAc,CAAC,MAAM,KAAK,UAAU,EAAE,CAAC;QAC7F,MAAM,IAAI,8BAA8B,CAAC,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC,CAAA;IACjE,CAAC;IAED,OAAO,4BAA4B,CACjC,WAAW,CAAC,OAA+B,EAC3C,cAAc,CAAC,MAAyB,CACzC,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jrmc/adonis-attachment
|
|
3
|
+
*
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
+
*/
|
|
7
|
+
import type { MediaMetadataExtractor } from './media_metadata.js';
|
|
8
|
+
export type ExifReaderTag = {
|
|
9
|
+
value?: unknown;
|
|
10
|
+
description?: string;
|
|
11
|
+
};
|
|
12
|
+
export type ExifReaderTags = Record<string, Record<string, ExifReaderTag | undefined> | undefined>;
|
|
13
|
+
export interface ExifReader {
|
|
14
|
+
load(input: Uint8Array, options?: {
|
|
15
|
+
expanded?: boolean;
|
|
16
|
+
}): ExifReaderTags | Promise<ExifReaderTags>;
|
|
17
|
+
}
|
|
18
|
+
export type ExifMetadataExtractorOptions = {
|
|
19
|
+
reader?: ExifReader | (() => Promise<ExifReader>);
|
|
20
|
+
};
|
|
21
|
+
/** Extracts the v5 EXIF, PNG, ICC, and GPS metadata shape for image attachments. */
|
|
22
|
+
export declare function createExifMetadataExtractor(options?: ExifMetadataExtractorOptions): MediaMetadataExtractor;
|
|
23
|
+
//# sourceMappingURL=exif.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exif.d.ts","sourceRoot":"","sources":["../../../src/media/exif.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAsB,sBAAsB,EAAE,MAAM,qBAAqB,CAAA;AAGrF,MAAM,MAAM,aAAa,GAAG;IAC1B,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,CAAA;AAED,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,GAAG,SAAS,CAAC,GAAG,SAAS,CAAC,CAAA;AAElG,MAAM,WAAW,UAAU;IACzB,IAAI,CAAC,KAAK,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC,CAAA;CACpG;AAED,MAAM,MAAM,4BAA4B,GAAG;IACzC,MAAM,CAAC,EAAE,UAAU,GAAG,CAAC,MAAM,OAAO,CAAC,UAAU,CAAC,CAAC,CAAA;CAClD,CAAA;AAED,oFAAoF;AACpF,wBAAgB,2BAA2B,CACzC,OAAO,GAAE,4BAAiC,GACzC,sBAAsB,CAYxB"}
|