@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
|
@@ -4,13 +4,14 @@
|
|
|
4
4
|
* @license MIT
|
|
5
5
|
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
6
|
*/
|
|
7
|
-
import type { AttachmentService } from '
|
|
8
|
-
import type { VariantGenerationRequest, VariantGenerator } from '
|
|
9
|
-
import type { VariantGenerationService } from '
|
|
7
|
+
import type { AttachmentService } from '../../../core/attachment_service.js';
|
|
8
|
+
import type { VariantGenerationRequest, VariantGenerator } from '../../../core/attachment_job_processor.js';
|
|
9
|
+
import type { VariantGenerationService } from '../../../variants/variant_generation_service.js';
|
|
10
10
|
import { LucidAttachmentStore } from './lucid_attachment_store.js';
|
|
11
|
+
import { AttachmentError } from '../../../errors.js';
|
|
11
12
|
export type LucidVariantGenerationServiceOptions = {
|
|
12
13
|
generator: Pick<VariantGenerationService, 'generateAll'>;
|
|
13
|
-
attachments: Pick<AttachmentService, 'remove'
|
|
14
|
+
attachments: Pick<AttachmentService, 'remove'> & Partial<Pick<AttachmentService, 'getMetadataMode' | 'scheduleMetadataExtraction'>>;
|
|
14
15
|
store: Pick<LucidAttachmentStore, 'findById' | 'createVariant'>;
|
|
15
16
|
};
|
|
16
17
|
export declare class LucidVariantGenerationService implements VariantGenerator {
|
|
@@ -18,7 +19,9 @@ export declare class LucidVariantGenerationService implements VariantGenerator {
|
|
|
18
19
|
constructor(options: LucidVariantGenerationServiceOptions);
|
|
19
20
|
generate(request: VariantGenerationRequest): Promise<void>;
|
|
20
21
|
}
|
|
21
|
-
export declare class PersistedAttachmentNotFoundError extends
|
|
22
|
+
export declare class PersistedAttachmentNotFoundError extends AttachmentError {
|
|
23
|
+
static code: string;
|
|
24
|
+
static status: number;
|
|
22
25
|
constructor(id: string);
|
|
23
26
|
}
|
|
24
27
|
//# sourceMappingURL=lucid_variant_generation_service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lucid_variant_generation_service.d.ts","sourceRoot":"","sources":["../../../../../src/integrations/lucid/persistence/lucid_variant_generation_service.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAA;AAC5E,OAAO,KAAK,EAAE,wBAAwB,EAAE,gBAAgB,EAAE,MAAM,2CAA2C,CAAA;AAC3G,OAAO,KAAK,EAAoB,wBAAwB,EAAE,MAAM,iDAAiD,CAAA;AAEjH,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAA;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAEpD,MAAM,MAAM,oCAAoC,GAAG;IACjD,SAAS,EAAE,IAAI,CAAC,wBAAwB,EAAE,aAAa,CAAC,CAAA;IACxD,WAAW,EAAE,IAAI,CAAC,iBAAiB,EAAE,QAAQ,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,iBAAiB,EAAE,iBAAiB,GAAG,4BAA4B,CAAC,CAAC,CAAA;IACnI,KAAK,EAAE,IAAI,CAAC,oBAAoB,EAAE,UAAU,GAAG,eAAe,CAAC,CAAA;CAChE,CAAA;AAED,qBAAa,6BAA8B,YAAW,gBAAgB;;gBAKxD,OAAO,EAAE,oCAAoC;IAMnD,QAAQ,CAAC,OAAO,EAAE,wBAAwB,GAAG,OAAO,CAAC,IAAI,CAAC;CA2BjE;AAED,qBAAa,gCAAiC,SAAQ,eAAe;IACnE,MAAM,CAAC,IAAI,SAAqC;IAChD,MAAM,CAAC,MAAM,SAAM;gBAEP,EAAE,EAAE,MAAM;CAIvB"}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* @license MIT
|
|
5
5
|
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
6
|
*/
|
|
7
|
+
import { AttachmentError } from '../../../errors.js';
|
|
7
8
|
export class LucidVariantGenerationService {
|
|
8
9
|
#generator;
|
|
9
10
|
#attachments;
|
|
@@ -20,12 +21,15 @@ export class LucidVariantGenerationService {
|
|
|
20
21
|
}
|
|
21
22
|
const variants = await this.#generator.generateAll(request);
|
|
22
23
|
for (const variant of variants) {
|
|
23
|
-
await this.#persist(original, variant);
|
|
24
|
+
await this.#persist(original, variant, request.meta);
|
|
24
25
|
}
|
|
25
26
|
}
|
|
26
|
-
async #persist(original, variant) {
|
|
27
|
+
async #persist(original, variant, meta) {
|
|
27
28
|
try {
|
|
28
29
|
await this.#store.createVariant(original, variant.key, variant.attachment);
|
|
30
|
+
if (this.#attachments.getMetadataMode?.(undefined, meta !== undefined ? { meta } : undefined) === 'deferred') {
|
|
31
|
+
await this.#attachments.scheduleMetadataExtraction?.(variant.attachment);
|
|
32
|
+
}
|
|
29
33
|
}
|
|
30
34
|
catch (error) {
|
|
31
35
|
await this.#attachments.remove(variant.attachment);
|
|
@@ -33,7 +37,9 @@ export class LucidVariantGenerationService {
|
|
|
33
37
|
}
|
|
34
38
|
}
|
|
35
39
|
}
|
|
36
|
-
export class PersistedAttachmentNotFoundError extends
|
|
40
|
+
export class PersistedAttachmentNotFoundError extends AttachmentError {
|
|
41
|
+
static code = 'E_PERSISTED_ATTACHMENT_NOT_FOUND';
|
|
42
|
+
static status = 404;
|
|
37
43
|
constructor(id) {
|
|
38
44
|
super(`Persisted attachment "${id}" was not found`);
|
|
39
45
|
this.name = 'PersistedAttachmentNotFoundError';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lucid_variant_generation_service.js","sourceRoot":"","sources":["../../../../../src/integrations/lucid/persistence/lucid_variant_generation_service.ts"],"names":[],"m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,UAAU,EAAE,CAAC;gBACjB,MAAM,IAAI,CAAC,YAAY,CAAC,0BAA0B,EAAE,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;YAC1E,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;YAClD,MAAM,KAAK,CAAA;QACb,CAAC;IACH,CAAC;CACF;AAED,MAAM,OAAO,gCAAiC,SAAQ,eAAe;IACnE,MAAM,CAAC,IAAI,GAAG,kCAAkC,CAAA;IAChD,MAAM,CAAC,MAAM,GAAG,GAAG,CAAA;IAEnB,YAAY,EAAU;QACpB,KAAK,CAAC,yBAAyB,EAAE,iBAAiB,CAAC,CAAA;QACnD,IAAI,CAAC,IAAI,GAAG,kCAAkC,CAAA;IAChD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachment_owner.d.ts","sourceRoot":"","sources":["../../../../../src/integrations/lucid/relations/attachment_owner.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,MAAM,MAAM,eAAe,CAAC,KAAK,GAAG,OAAO,IAAI;IAC7C,IAAI,EAAE,MAAM,CAAA;IACZ,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,KAAK,CAAA;CACd,CAAA;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,eAAe,GAAG,MAAM,CAEvE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachment_owner.js","sourceRoot":"","sources":["../../../../../src/integrations/lucid/relations/attachment_owner.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AASxC;;;GAGG;AACH,MAAM,UAAU,wBAAwB,CAAC,KAAsB;IAC7D,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;AACvG,CAAC"}
|
package/build/src/integrations/lucid/{attachment_relation.d.ts → relations/attachment_relation.d.ts}
RENAMED
|
@@ -5,9 +5,11 @@
|
|
|
5
5
|
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
6
|
*/
|
|
7
7
|
import type { LucidRow } from "@adonisjs/lucid/types/model";
|
|
8
|
-
import type {
|
|
9
|
-
import type {
|
|
10
|
-
import {
|
|
8
|
+
import type { AttachmentVariantKey } from "../../../../index.js";
|
|
9
|
+
import type { AttachmentDraft, CreateAttachmentInput } from "../../../core/attachment.js";
|
|
10
|
+
import type { AttachmentPersistenceOptions } from "../../../core/attachment_options.js";
|
|
11
|
+
import { AttachmentLinkModel } from "../models/attachment_link_model.js";
|
|
12
|
+
import { AttachmentModel } from "../models/attachment_model.js";
|
|
11
13
|
type AttachmentRelationInput = CreateAttachmentInput | AttachmentDraft;
|
|
12
14
|
type AttachmentRelationRow = LucidRow & {
|
|
13
15
|
$isPersisted: boolean;
|
|
@@ -16,6 +18,10 @@ type AttachmentRelationRow = LucidRow & {
|
|
|
16
18
|
table?: string;
|
|
17
19
|
name: string;
|
|
18
20
|
boot(): void;
|
|
21
|
+
prototype: AttachmentRelationRow & {
|
|
22
|
+
save(): Promise<unknown>;
|
|
23
|
+
};
|
|
24
|
+
after(event: "delete", callback: (row: AttachmentRelationRow) => void | Promise<void>): void;
|
|
19
25
|
};
|
|
20
26
|
};
|
|
21
27
|
type RelationKind = "one" | "many";
|
|
@@ -38,23 +44,31 @@ export declare function attachmentsRelation<Model = LucidRow>(options?: Attachme
|
|
|
38
44
|
export declare class AttachmentRelation {
|
|
39
45
|
#private;
|
|
40
46
|
constructor(row: AttachmentRelationRow, definition: RelationDefinition);
|
|
41
|
-
get(): Promise<
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
47
|
+
get(): Promise<AttachmentLinkModel | null>;
|
|
48
|
+
get hasPending(): boolean;
|
|
49
|
+
attach(input: AttachmentRelationInput): void;
|
|
50
|
+
attachExisting(attachmentId: string): void;
|
|
51
|
+
set(input: AttachmentRelationInput): void;
|
|
52
|
+
replace(input: AttachmentRelationInput): void;
|
|
53
|
+
detach(): void;
|
|
54
|
+
persist(): Promise<AttachmentLinkModel | null>;
|
|
46
55
|
variants(): Promise<AttachmentModel[]>;
|
|
47
|
-
regenerateVariants(variantKeys?: readonly
|
|
56
|
+
regenerateVariants(variantKeys?: readonly AttachmentVariantKey[]): Promise<boolean>;
|
|
48
57
|
}
|
|
49
58
|
export declare class AttachmentCollectionRelation {
|
|
50
59
|
#private;
|
|
51
60
|
constructor(row: AttachmentRelationRow, definition: RelationDefinition);
|
|
52
|
-
all(): Promise<
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
61
|
+
all(): Promise<AttachmentLinkModel[]>;
|
|
62
|
+
get hasPending(): boolean;
|
|
63
|
+
add(input: AttachmentRelationInput, position?: number): void;
|
|
64
|
+
/** Stages several attachments while retaining their input order. */
|
|
65
|
+
addMany(inputs: readonly AttachmentRelationInput[], position?: number): void;
|
|
66
|
+
addExisting(attachmentId: string, position?: number): void;
|
|
67
|
+
remove(id: string): void;
|
|
68
|
+
clear(): void;
|
|
69
|
+
replaceAll(inputs: readonly AttachmentRelationInput[]): void;
|
|
70
|
+
move(id: string, position: number): void;
|
|
71
|
+
persist(): Promise<AttachmentLinkModel[]>;
|
|
58
72
|
}
|
|
59
73
|
export {};
|
|
60
74
|
//# sourceMappingURL=attachment_relation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachment_relation.d.ts","sourceRoot":"","sources":["../../../../../src/integrations/lucid/relations/attachment_rel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AAQ,CAAC,EAAE,MAAM,GAChB,IAAI;IAMP,WAAW,CACT,YAAY,EAAE,MAAM,EACpB,QAAQ,CAAC,EAAE,MAAM,GAChB,IAAI;IAQP,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAIxB,KAAK,IAAI,IAAI;IAIb,UAAU,CACR,MAAM,EAAE,SAAS,uBAAuB,EAAE,GACzC,IAAI;IAIP,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI;IAIlC,OAAO,IAAI,OAAO,CAAC,mBAAmB,EAAE,CAAC;CAmDhD"}
|
|
@@ -0,0 +1,273 @@
|
|
|
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
|
+
import { AttachmentModel } from "../models/attachment_model.js";
|
|
9
|
+
import { LucidAttachmentLifecycleService } from "../persistence/lucid_attachment_lifecycle_service.js";
|
|
10
|
+
import { LucidAttachmentStore } from "../persistence/lucid_attachment_store.js";
|
|
11
|
+
import { AttachmentConfigurationError, AttachmentConflictError, AttachmentValidationError, } from "../../../errors.js";
|
|
12
|
+
const relationDefinitions = new WeakMap();
|
|
13
|
+
const relationInstances = new WeakMap();
|
|
14
|
+
const deleteHooks = new WeakSet();
|
|
15
|
+
const saveHooks = new WeakSet();
|
|
16
|
+
/**
|
|
17
|
+
* Declares one attachment persisted in the polymorphic attachments table.
|
|
18
|
+
*/
|
|
19
|
+
export function attachmentRelation(options = {}) {
|
|
20
|
+
return defineRelation("one", options);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Declares an ordered attachment collection persisted in the polymorphic attachments table.
|
|
24
|
+
*/
|
|
25
|
+
export function attachmentsRelation(options = {}) {
|
|
26
|
+
return defineRelation("many", options);
|
|
27
|
+
}
|
|
28
|
+
export class AttachmentRelation {
|
|
29
|
+
#row;
|
|
30
|
+
#definition;
|
|
31
|
+
#pending;
|
|
32
|
+
constructor(row, definition) {
|
|
33
|
+
this.#row = row;
|
|
34
|
+
this.#definition = definition;
|
|
35
|
+
}
|
|
36
|
+
async get() {
|
|
37
|
+
const lifecycle = await this.#lifecycle();
|
|
38
|
+
return lifecycle.get(this.#owner());
|
|
39
|
+
}
|
|
40
|
+
get hasPending() {
|
|
41
|
+
return this.#pending !== undefined;
|
|
42
|
+
}
|
|
43
|
+
attach(input) {
|
|
44
|
+
if (this.#pending && this.#pending.type !== "detach") {
|
|
45
|
+
throw new AttachmentConflictError(`Attachment relation "${this.#definition.field}" already has a pending attachment; use replace() or set()`);
|
|
46
|
+
}
|
|
47
|
+
this.#pending = { type: "attach", input };
|
|
48
|
+
}
|
|
49
|
+
attachExisting(attachmentId) {
|
|
50
|
+
if (this.#pending && this.#pending.type !== "detach") {
|
|
51
|
+
throw new AttachmentConflictError(`Attachment relation "${this.#definition.field}" already has a pending attachment; use replace() or set()`);
|
|
52
|
+
}
|
|
53
|
+
this.#pending = { type: "attachExisting", attachmentId };
|
|
54
|
+
}
|
|
55
|
+
set(input) {
|
|
56
|
+
this.replace(input);
|
|
57
|
+
}
|
|
58
|
+
replace(input) {
|
|
59
|
+
this.#pending = { type: "replace", input };
|
|
60
|
+
}
|
|
61
|
+
detach() {
|
|
62
|
+
this.#pending = { type: "detach" };
|
|
63
|
+
}
|
|
64
|
+
async persist() {
|
|
65
|
+
const pending = this.#pending;
|
|
66
|
+
if (!pending) {
|
|
67
|
+
return this.get();
|
|
68
|
+
}
|
|
69
|
+
const owner = this.#owner();
|
|
70
|
+
const lifecycle = await this.#lifecycle();
|
|
71
|
+
let result;
|
|
72
|
+
switch (pending.type) {
|
|
73
|
+
case "attach":
|
|
74
|
+
if (await lifecycle.get(owner)) {
|
|
75
|
+
throw new AttachmentConflictError(`Attachment relation "${owner.field}" already has an attachment; use replace() or set()`);
|
|
76
|
+
}
|
|
77
|
+
result = await lifecycle.attach(owner, pending.input, this.#definition.options);
|
|
78
|
+
break;
|
|
79
|
+
case "attachExisting":
|
|
80
|
+
if (await lifecycle.get(owner)) {
|
|
81
|
+
throw new AttachmentConflictError(`Attachment relation "${owner.field}" already has an attachment; use replace() or set()`);
|
|
82
|
+
}
|
|
83
|
+
result = await lifecycle.attachExisting(owner, pending.attachmentId);
|
|
84
|
+
break;
|
|
85
|
+
case "replace":
|
|
86
|
+
result = await lifecycle.replace(owner, pending.input, this.#definition.options);
|
|
87
|
+
break;
|
|
88
|
+
case "detach":
|
|
89
|
+
await lifecycle.detach(owner);
|
|
90
|
+
result = null;
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
this.#pending = undefined;
|
|
94
|
+
return result;
|
|
95
|
+
}
|
|
96
|
+
async variants() {
|
|
97
|
+
const lifecycle = await this.#lifecycle();
|
|
98
|
+
return lifecycle.listVariants(this.#owner());
|
|
99
|
+
}
|
|
100
|
+
async regenerateVariants(variantKeys) {
|
|
101
|
+
const attachment = await this.get();
|
|
102
|
+
if (!attachment) {
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
const service = await resolveAttachmentService();
|
|
106
|
+
await service.scheduleVariantGeneration(attachment.toAttachment(), variantKeys, service.getVariantMetadataEnabled(undefined, this.#definition.options));
|
|
107
|
+
return true;
|
|
108
|
+
}
|
|
109
|
+
async #lifecycle() {
|
|
110
|
+
return new LucidAttachmentLifecycleService(await resolveAttachmentService(), new LucidAttachmentStore(AttachmentModel, this.#row.$trx ? { client: this.#row.$trx } : {}));
|
|
111
|
+
}
|
|
112
|
+
#owner() {
|
|
113
|
+
return createOwner(this.#row, this.#definition);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
export class AttachmentCollectionRelation {
|
|
117
|
+
#row;
|
|
118
|
+
#definition;
|
|
119
|
+
#pending = [];
|
|
120
|
+
constructor(row, definition) {
|
|
121
|
+
this.#row = row;
|
|
122
|
+
this.#definition = definition;
|
|
123
|
+
}
|
|
124
|
+
async all() {
|
|
125
|
+
const lifecycle = await this.#lifecycle();
|
|
126
|
+
return lifecycle.listCollection(this.#owner());
|
|
127
|
+
}
|
|
128
|
+
get hasPending() {
|
|
129
|
+
return this.#pending.length > 0;
|
|
130
|
+
}
|
|
131
|
+
add(input, position) {
|
|
132
|
+
this.#pending.push({ type: "add", input, ...(position !== undefined ? { position } : {}) });
|
|
133
|
+
}
|
|
134
|
+
/** Stages several attachments while retaining their input order. */
|
|
135
|
+
addMany(inputs, position) {
|
|
136
|
+
inputs.forEach((input, index) => {
|
|
137
|
+
this.add(input, position === undefined ? undefined : position + index);
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
addExisting(attachmentId, position) {
|
|
141
|
+
this.#pending.push({
|
|
142
|
+
type: "addExisting",
|
|
143
|
+
attachmentId,
|
|
144
|
+
...(position !== undefined ? { position } : {}),
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
remove(id) {
|
|
148
|
+
this.#pending.push({ type: "remove", id });
|
|
149
|
+
}
|
|
150
|
+
clear() {
|
|
151
|
+
this.#pending = [{ type: "clear" }];
|
|
152
|
+
}
|
|
153
|
+
replaceAll(inputs) {
|
|
154
|
+
this.#pending = [{ type: "replaceAll", inputs }];
|
|
155
|
+
}
|
|
156
|
+
move(id, position) {
|
|
157
|
+
this.#pending.push({ type: "move", id, position });
|
|
158
|
+
}
|
|
159
|
+
async persist() {
|
|
160
|
+
if (this.#pending.length === 0) {
|
|
161
|
+
return this.all();
|
|
162
|
+
}
|
|
163
|
+
const lifecycle = await this.#lifecycle();
|
|
164
|
+
const owner = this.#owner();
|
|
165
|
+
while (this.#pending.length > 0) {
|
|
166
|
+
const operation = this.#pending[0];
|
|
167
|
+
switch (operation.type) {
|
|
168
|
+
case "add":
|
|
169
|
+
await lifecycle.add(owner, operation.input, operation.position, this.#definition.options);
|
|
170
|
+
break;
|
|
171
|
+
case "addExisting":
|
|
172
|
+
await lifecycle.addExisting(owner, operation.attachmentId, operation.position);
|
|
173
|
+
break;
|
|
174
|
+
case "remove":
|
|
175
|
+
await lifecycle.removeCollectionItem(owner, operation.id);
|
|
176
|
+
break;
|
|
177
|
+
case "clear":
|
|
178
|
+
await lifecycle.clearCollection(owner);
|
|
179
|
+
break;
|
|
180
|
+
case "replaceAll":
|
|
181
|
+
await lifecycle.replaceCollection(owner, operation.inputs, this.#definition.options);
|
|
182
|
+
break;
|
|
183
|
+
case "move":
|
|
184
|
+
await lifecycle.moveCollectionItem(owner, operation.id, operation.position);
|
|
185
|
+
break;
|
|
186
|
+
}
|
|
187
|
+
this.#pending.shift();
|
|
188
|
+
}
|
|
189
|
+
return lifecycle.listCollection(owner);
|
|
190
|
+
}
|
|
191
|
+
async #lifecycle() {
|
|
192
|
+
return new LucidAttachmentLifecycleService(await resolveAttachmentService(), new LucidAttachmentStore(AttachmentModel, this.#row.$trx ? { client: this.#row.$trx } : {}));
|
|
193
|
+
}
|
|
194
|
+
#owner() {
|
|
195
|
+
return createOwner(this.#row, this.#definition);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
function defineRelation(kind, options) {
|
|
199
|
+
return (target, propertyKey) => {
|
|
200
|
+
const Model = target.constructor;
|
|
201
|
+
const field = String(propertyKey);
|
|
202
|
+
const definitions = relationDefinitions.get(Model) ?? new Map();
|
|
203
|
+
if (definitions.has(field)) {
|
|
204
|
+
throw new AttachmentConfigurationError(`Attachment relation "${field}" is already declared on this model`);
|
|
205
|
+
}
|
|
206
|
+
Model.boot();
|
|
207
|
+
definitions.set(field, { kind, field, options });
|
|
208
|
+
relationDefinitions.set(Model, definitions);
|
|
209
|
+
if (!deleteHooks.has(Model)) {
|
|
210
|
+
deleteHooks.add(Model);
|
|
211
|
+
Model.after("delete", async (row) => {
|
|
212
|
+
for (const definition of relationDefinitions.get(Model)?.values() ?? []) {
|
|
213
|
+
const lifecycle = new LucidAttachmentLifecycleService(await resolveAttachmentService(), new LucidAttachmentStore(AttachmentModel, row.$trx ? { client: row.$trx } : {}));
|
|
214
|
+
await lifecycle.purgeOwner(createOwner(row, definition, true));
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
if (!saveHooks.has(Model)) {
|
|
219
|
+
saveHooks.add(Model);
|
|
220
|
+
wrapSave(Model);
|
|
221
|
+
}
|
|
222
|
+
Object.defineProperty(target, propertyKey, {
|
|
223
|
+
configurable: true,
|
|
224
|
+
enumerable: false,
|
|
225
|
+
get() {
|
|
226
|
+
const instances = relationInstances.get(this) ?? new Map();
|
|
227
|
+
const existing = instances.get(field);
|
|
228
|
+
if (existing) {
|
|
229
|
+
return existing;
|
|
230
|
+
}
|
|
231
|
+
const relation = kind === "one"
|
|
232
|
+
? new AttachmentRelation(this, definitions.get(field))
|
|
233
|
+
: new AttachmentCollectionRelation(this, definitions.get(field));
|
|
234
|
+
instances.set(field, relation);
|
|
235
|
+
relationInstances.set(this, instances);
|
|
236
|
+
return relation;
|
|
237
|
+
},
|
|
238
|
+
});
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
function createOwner(row, definition, allowDeleted = false) {
|
|
242
|
+
if ((!allowDeleted && !row.$isPersisted) ||
|
|
243
|
+
row.$primaryKeyValue === null ||
|
|
244
|
+
row.$primaryKeyValue === undefined) {
|
|
245
|
+
throw new AttachmentValidationError("Attachment relations require a persisted Lucid model");
|
|
246
|
+
}
|
|
247
|
+
const type = definition.options.type ?? row.constructor.table;
|
|
248
|
+
if (!type) {
|
|
249
|
+
throw new AttachmentConfigurationError("Attachment relations require a Lucid model table or an explicit relation type");
|
|
250
|
+
}
|
|
251
|
+
return {
|
|
252
|
+
type,
|
|
253
|
+
id: String(row.$primaryKeyValue),
|
|
254
|
+
field: definition.field,
|
|
255
|
+
model: row,
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
async function resolveAttachmentService() {
|
|
259
|
+
return (await app.container.make("jrmc.attachment"));
|
|
260
|
+
}
|
|
261
|
+
function wrapSave(Model) {
|
|
262
|
+
const save = Model.prototype.save;
|
|
263
|
+
Model.prototype.save = (async function saveWithAttachmentRelations() {
|
|
264
|
+
const result = await save.call(this);
|
|
265
|
+
for (const relation of relationInstances.get(this)?.values() ?? []) {
|
|
266
|
+
if (relation.hasPending) {
|
|
267
|
+
await relation.persist();
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
return result;
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
//# sourceMappingURL=attachment_relation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachment_relation.js","sourceRoot":"","sources":["../../../../../src/integrations/lucid/relations/attachment_relation.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,GAAG,MAAM,6BAA6B,CAAC;AAa9C,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,+BAA+B,EAAE,MAAM,sDAAsD,CAAC;AACvG,OAAO,EAAE,oBAAoB,EAAE,MAAM,0CAA0C,CAAC;AAChF,OAAO,EACL,4BAA4B,EAC5B,uBAAuB,EACvB,yBAAyB,GAC1B,MAAM,oBAAoB,CAAC;AAgD5B,MAAM,mBAAmB,GAAG,IAAI,OAAO,EAGpC,CAAC;AACJ,MAAM,iBAAiB,GAAG,IAAI,OAAO,EAGlC,CAAC;AACJ,MAAM,WAAW,GAAG,IAAI,OAAO,EAAU,CAAC;AAC1C,MAAM,SAAS,GAAG,IAAI,OAAO,EAAU,CAAC;AAExC;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAChC,UAA4C,EAAE;IAE9C,OAAO,cAAc,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;AACxC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,mBAAmB,CACjC,UAA4C,EAAE;IAE9C,OAAO,cAAc,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AACzC,CAAC;AAED,MAAM,OAAO,kBAAkB;IACpB,IA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C;QACV,MAAM,IAAI,4BAA4B,CACpC,+EAA+E,CAChF,CAAC;IACJ,CAAC;IAED,OAAO;QACL,IAAI;QACJ,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,gBAAgB,CAAC;QAChC,KAAK,EAAE,UAAU,CAAC,KAAK;QACvB,KAAK,EAAE,GAAG;KACX,CAAC;AACJ,CAAC;AAED,KAAK,UAAU,wBAAwB;IACrC,OAAO,CAAC,MAAM,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAsB,CAAC;AAC5E,CAAC;AAED,SAAS,QAAQ,CAAC,KAA2C;IAC3D,MAAM,IAAI,GAAG,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC;IAElC,KAAK,CAAC,SAAS,CAAC,IAAI,GAAG,CAAC,KAAK,UAAU,2BAA2B;QAChE,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAErC,KAAK,MAAM,QAAQ,IAAI,iBAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,CAAC;YACnE,IAAI,QAAQ,CAAC,UAAU,EAAE,CAAC;gBACxB,MAAM,QAAQ,CAAC,OAAO,EAAE,CAAC;YAC3B,CAAC;QACH,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC,CAAgC,CAAC;AACpC,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jrmc/adonis-attachment
|
|
3
|
+
*
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
+
*/
|
|
7
|
+
import type { Knex } from 'knex';
|
|
8
|
+
export type AttachmentSchemaServiceOptions = {
|
|
9
|
+
tableName?: string;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Owns the versioned database schema used by the Lucid attachment integration.
|
|
13
|
+
*/
|
|
14
|
+
export declare class AttachmentSchemaService {
|
|
15
|
+
#private;
|
|
16
|
+
constructor(connection: Knex, options?: AttachmentSchemaServiceOptions);
|
|
17
|
+
createTables(): Promise<void>;
|
|
18
|
+
createBlobsTable(): Promise<void>;
|
|
19
|
+
createLinksTable(): Promise<void>;
|
|
20
|
+
/** Adds the nullable blurhash column to a table created by an earlier v6 schema. */
|
|
21
|
+
addBlurhashColumn(): Promise<void>;
|
|
22
|
+
/** Removes the blurhash column when rolling back a schema upgrade. */
|
|
23
|
+
dropBlurhashColumn(): Promise<void>;
|
|
24
|
+
dropTables(): Promise<void>;
|
|
25
|
+
dropBlobsTable(): Promise<void>;
|
|
26
|
+
dropLinksTable(): Promise<void>;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=attachment_schema_service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachment_schema_service.d.ts","sourceRoot":"","sources":["../../../../../src/integrations/lucid/schema/attachment_schema_service.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAGhC,MAAM,MAAM,8BAA8B,GAAG;IAC3C,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,CAAA;AAED;;GAEG;AACH,qBAAa,uBAAuB;;gBAKtB,UAAU,EAAE,IAAI,EAAE,OAAO,GAAE,8BAAmC;IAO1E,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IAI7B,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC;IAsBjC,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC;IAiBjC,oFAAoF;IACpF,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC;IAMlC,sEAAsE;IACtE,kBAAkB,IAAI,OAAO,CAAC,IAAI,CAAC;IAMnC,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAI3B,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC;IAI/B,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC;CAGhC"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jrmc/adonis-attachment
|
|
3
|
+
*
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
+
*/
|
|
7
|
+
import { resolveAttachmentTableNames } from './attachment_table_names.js';
|
|
8
|
+
/**
|
|
9
|
+
* Owns the versioned database schema used by the Lucid attachment integration.
|
|
10
|
+
*/
|
|
11
|
+
export class AttachmentSchemaService {
|
|
12
|
+
#connection;
|
|
13
|
+
#tableName;
|
|
14
|
+
#linksTableName;
|
|
15
|
+
constructor(connection, options = {}) {
|
|
16
|
+
this.#connection = connection;
|
|
17
|
+
const tables = resolveAttachmentTableNames(options.tableName);
|
|
18
|
+
this.#tableName = tables.tableName;
|
|
19
|
+
this.#linksTableName = tables.linksTableName;
|
|
20
|
+
}
|
|
21
|
+
createTables() {
|
|
22
|
+
return this.createBlobsTable().then(() => this.createLinksTable());
|
|
23
|
+
}
|
|
24
|
+
createBlobsTable() {
|
|
25
|
+
return this.#connection.schema.createTable(this.#tableName, (table) => {
|
|
26
|
+
table.uuid('id').primary();
|
|
27
|
+
table.uuid('parent_id').nullable().references('id').inTable(this.#tableName).onDelete('CASCADE');
|
|
28
|
+
table.string('variant_key').nullable();
|
|
29
|
+
table.string('disk').notNullable();
|
|
30
|
+
table.string('path').notNullable();
|
|
31
|
+
table.string('name').notNullable();
|
|
32
|
+
table.string('original_name').notNullable();
|
|
33
|
+
table.string('mime_type').notNullable();
|
|
34
|
+
table.string('extname').notNullable();
|
|
35
|
+
table.bigInteger('size').unsigned().notNullable();
|
|
36
|
+
table.string('blurhash').nullable();
|
|
37
|
+
table.json('metadata').nullable();
|
|
38
|
+
table.timestamp('created_at').notNullable();
|
|
39
|
+
table.timestamp('updated_at').notNullable();
|
|
40
|
+
table.index(['parent_id']);
|
|
41
|
+
table.unique(['parent_id', 'variant_key']);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
createLinksTable() {
|
|
45
|
+
return this.#connection.schema.createTable(this.#linksTableName, (table) => {
|
|
46
|
+
table.uuid('id').primary();
|
|
47
|
+
table.string('attachable_type').notNullable();
|
|
48
|
+
table.string('attachable_id').notNullable();
|
|
49
|
+
table.string('field').notNullable();
|
|
50
|
+
table.string('owner_key', 64).nullable().unique();
|
|
51
|
+
table.integer('position').unsigned().nullable();
|
|
52
|
+
table.uuid('attachment_id').notNullable().references('id').inTable(this.#tableName).onDelete('CASCADE');
|
|
53
|
+
table.timestamp('created_at').notNullable();
|
|
54
|
+
table.timestamp('updated_at').notNullable();
|
|
55
|
+
table.index(['attachable_type', 'attachable_id', 'field']);
|
|
56
|
+
table.index(['attachment_id']);
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
/** Adds the nullable blurhash column to a table created by an earlier v6 schema. */
|
|
60
|
+
addBlurhashColumn() {
|
|
61
|
+
return this.#connection.schema.table(this.#tableName, (table) => {
|
|
62
|
+
table.string('blurhash').nullable();
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
/** Removes the blurhash column when rolling back a schema upgrade. */
|
|
66
|
+
dropBlurhashColumn() {
|
|
67
|
+
return this.#connection.schema.table(this.#tableName, (table) => {
|
|
68
|
+
table.dropColumn('blurhash');
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
dropTables() {
|
|
72
|
+
return this.dropLinksTable().then(() => this.dropBlobsTable());
|
|
73
|
+
}
|
|
74
|
+
dropBlobsTable() {
|
|
75
|
+
return this.#connection.schema.dropTableIfExists(this.#tableName);
|
|
76
|
+
}
|
|
77
|
+
dropLinksTable() {
|
|
78
|
+
return this.#connection.schema.dropTableIfExists(this.#linksTableName);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=attachment_schema_service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachment_schema_service.js","s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AM,CAAC,iBAAiB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;IACnE,CAAC;IAED,cAAc;QACZ,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,iBAAiB,CAAC,IAAI,CAAC,eAAe,CAAC,CAAA;IACxE,CAAC;CACF"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jrmc/adonis-attachment
|
|
3
|
+
*
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
+
*/
|
|
7
|
+
export type AttachmentTableNames = {
|
|
8
|
+
tableName: string;
|
|
9
|
+
linksTableName: string;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Resolves the blob and polymorphic-link table names from one base table name.
|
|
13
|
+
*/
|
|
14
|
+
export declare function resolveAttachmentTableNames(tableName?: string): AttachmentTableNames;
|
|
15
|
+
//# sourceMappingURL=attachment_table_names.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachment_table_names.d.ts","sourceRoot":"","sources":["../../../../../src/integrations/lucid/schema/attachment_table_names.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,MAAM,MAAM,oBAAoB,GAAG;IACjC,SAAS,EAAE,MAAM,CAAA;IACjB,cAAc,EAAE,MAAM,CAAA;CACvB,CAAA;AAED;;GAEG;AACH,wBAAgB,2BAA2B,CAAC,SAAS,SAAgB,GAAG,oBAAoB,CAW3F"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jrmc/adonis-attachment
|
|
3
|
+
*
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
+
*/
|
|
7
|
+
import string from '@adonisjs/core/helpers/string';
|
|
8
|
+
import { AttachmentError } from '../../../errors.js';
|
|
9
|
+
/**
|
|
10
|
+
* Resolves the blob and polymorphic-link table names from one base table name.
|
|
11
|
+
*/
|
|
12
|
+
export function resolveAttachmentTableNames(tableName = 'attachments') {
|
|
13
|
+
if (!/^[a-z][a-z0-9_]*$/.test(tableName)) {
|
|
14
|
+
throw new AttachmentError('Lucid attachment table names must be snake_case identifiers', {
|
|
15
|
+
code: 'E_INVALID_ATTACHMENT_TABLE_NAME',
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
return {
|
|
19
|
+
tableName,
|
|
20
|
+
linksTableName: `${string.singular(tableName)}_links`,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=attachment_table_names.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachment_table_names.js","sourceRoot":"","sources":["../../../../../src/integrations/lucid/schema/attachment_table_names.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,MAAM,MAAM,+BAA+B,CAAA;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAOpD;;GAEG;AACH,MAAM,UAAU,2BAA2B,CAAC,SAAS,GAAG,aAAa;IACnE,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC;QACzC,MAAM,IAAI,eAAe,CAAC,6DAA6D,EAAE;YACvF,IAAI,EAAE,iCAAiC;SACxC,CAAC,CAAA;IACJ,CAAC;IAED,OAAO;QACL,SAAS;QACT,cAAc,EAAE,GAAG,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,QAAQ;KACtD,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachments_table_stub.d.ts","sourceRoot":"","sources":["../../../../../src/integrations/lucid/schema/attachments_table_stub.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,MAAM,MAAM,2BAA2B,GAAG;IACxC,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,MAAM,MAAM,yBAAyB,GAAG;IACtC,WAAW,EAAE,MAAM,CAAA;IACnB,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;CAClB,CAAA;AAED;;GAEG;AACH,wBAAgB,+BAA+B,CAC7C,OAAO,EAAE,2BAA2B,GACnC,yBAAyB,CAU3B"}
|