@jrmc/adonis-attachment 6.0.0-alpha.0 → 6.0.0-alpha.2
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/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/index.d.ts +23 -22
- package/build/index.d.ts.map +1 -1
- package/build/index.js +15 -14
- package/build/index.js.map +1 -1
- package/build/providers/attachment_provider.d.ts.map +1 -1
- package/build/providers/attachment_provider.js +16 -0
- package/build/providers/attachment_provider.js.map +1 -1
- package/build/src/core/attachment.d.ts +37 -2
- package/build/src/core/attachment.d.ts.map +1 -1
- package/build/src/core/attachment.js +108 -5
- package/build/src/core/attachment.js.map +1 -1
- package/build/src/core/attachment_options.d.ts +32 -0
- package/build/src/core/attachment_options.d.ts.map +1 -0
- package/build/src/core/attachment_options.js +24 -0
- package/build/src/core/attachment_options.js.map +1 -0
- package/build/src/core/attachment_service.d.ts +7 -1
- package/build/src/core/attachment_service.d.ts.map +1 -1
- package/build/src/core/attachment_service.js +50 -4
- package/build/src/core/attachment_service.js.map +1 -1
- package/build/src/core/index.d.ts +2 -1
- package/build/src/core/index.d.ts.map +1 -1
- package/build/src/core/index.js +2 -1
- package/build/src/core/index.js.map +1 -1
- package/build/src/define_config.d.ts +17 -0
- package/build/src/define_config.d.ts.map +1 -1
- package/build/src/define_config.js +9 -0
- package/build/src/define_config.js.map +1 -1
- package/build/src/integrations/lucid/column/attachment_column.d.ts +18 -0
- 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} +26 -13
- package/build/src/integrations/lucid/column/attachment_column.js.map +1 -0
- package/build/src/integrations/lucid/index.d.ts +16 -12
- package/build/src/integrations/lucid/index.d.ts.map +1 -1
- package/build/src/integrations/lucid/index.js +16 -12
- 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} +25 -9
- package/build/src/integrations/lucid/migrations/legacy/migrate_legacy_attachment.d.ts.map +1 -0
- package/build/src/integrations/lucid/migrations/legacy/migrate_legacy_attachment.js +94 -0
- 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} +7 -6
- 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 +58 -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} +2 -6
- 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} +1 -13
- package/build/src/integrations/lucid/models/attachment_model.js.map +1 -0
- package/build/src/integrations/lucid/persistence/lucid_attachment_lifecycle_service.d.ts +34 -0
- 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 +195 -0
- package/build/src/integrations/lucid/persistence/lucid_attachment_lifecycle_service.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 +224 -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} +3 -3
- package/build/src/integrations/lucid/persistence/lucid_variant_generation_service.d.ts.map +1 -0
- package/build/src/integrations/lucid/persistence/lucid_variant_generation_service.js.map +1 -0
- package/build/src/integrations/lucid/{attachment_owner.d.ts → relations/attachment_owner.d.ts} +2 -1
- 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/relations/attachment_relation.d.ts +71 -0
- package/build/src/integrations/lucid/relations/attachment_relation.d.ts.map +1 -0
- package/build/src/integrations/lucid/relations/attachment_relation.js +266 -0
- package/build/src/integrations/lucid/relations/attachment_relation.js.map +1 -0
- package/build/src/integrations/lucid/schema/attachment_schema_service.d.ts +24 -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 +68 -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 +20 -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/sources/attachment_manager.d.ts +14 -12
- package/build/src/sources/attachment_manager.d.ts.map +1 -1
- package/build/src/sources/attachment_manager.js +14 -6
- package/build/src/sources/attachment_manager.js.map +1 -1
- package/build/stubs/migrations/attachments_table.stub +7 -24
- package/build/{src/integrations/lucid/render_legacy_attachment_migration_script.js → stubs/migrations/legacy_attachment_migration.stub} +13 -15
- package/build/tests/attachment_manager.spec.js +21 -18
- package/build/tests/attachment_manager.spec.js.map +1 -1
- package/build/tests/attachment_manager_service.spec.js +2 -2
- package/build/tests/attachment_manager_service.spec.js.map +1 -1
- package/build/tests/attachment_options.spec.d.ts +2 -0
- package/build/tests/attachment_options.spec.d.ts.map +1 -0
- package/build/tests/attachment_options.spec.js +31 -0
- package/build/tests/attachment_options.spec.js.map +1 -0
- package/build/tests/attachment_provider.spec.js +30 -1
- package/build/tests/attachment_provider.spec.js.map +1 -1
- package/build/tests/{create_legacy_attachment_migration_script.spec.d.ts → attachment_schema_service.spec.d.ts} +1 -1
- package/build/tests/attachment_schema_service.spec.d.ts.map +1 -0
- package/build/tests/attachment_schema_service.spec.js +38 -0
- package/build/tests/attachment_schema_service.spec.js.map +1 -0
- package/build/tests/attachment_service.spec.js +55 -0
- 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 -5
- package/build/tests/attachments_table_stub.spec.js.map +1 -1
- package/build/tests/define_config.spec.js +34 -0
- package/build/tests/define_config.spec.js.map +1 -1
- package/build/tests/helpers/lucid_test_database.d.ts.map +1 -1
- package/build/tests/helpers/lucid_test_database.js +16 -6
- 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.d.ts +2 -0
- package/build/tests/lucid_attachment_collection_store.spec.d.ts.map +1 -0
- package/build/tests/lucid_attachment_collection_store.spec.js +53 -0
- package/build/tests/lucid_attachment_collection_store.spec.js.map +1 -0
- package/build/tests/lucid_attachment_column.spec.js +57 -1
- package/build/tests/lucid_attachment_column.spec.js.map +1 -1
- package/build/tests/lucid_attachment_lifecycle_service.spec.js +117 -111
- package/build/tests/lucid_attachment_lifecycle_service.spec.js.map +1 -1
- package/build/tests/lucid_attachment_relation.spec.d.ts +8 -0
- package/build/tests/lucid_attachment_relation.spec.d.ts.map +1 -0
- package/build/tests/lucid_attachment_relation.spec.js +295 -0
- package/build/tests/lucid_attachment_relation.spec.js.map +1 -0
- 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 -50
- package/build/tests/lucid_attachment_store.spec.js.map +1 -1
- package/build/tests/lucid_sqlite_integration.spec.js +23 -18
- package/build/tests/lucid_sqlite_integration.spec.js.map +1 -1
- package/build/tests/lucid_variant_generation_service.spec.js +1 -1
- package/build/tests/lucid_variant_generation_service.spec.js.map +1 -1
- package/build/tests/migrate_legacy_attachment.spec.js +114 -67
- 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/package.json +4 -2
- package/build/src/integrations/lucid/attachment_column.d.ts +0 -11
- 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/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 +0 -21
- 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 -68
- 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 -27
- package/build/src/integrations/lucid/lucid_attachment_store.d.ts.map +0 -1
- package/build/src/integrations/lucid/lucid_attachment_store.js +0 -84
- 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 +0 -67
- 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/{lucid_variant_generation_service.js → persistence/lucid_variant_generation_service.js} +0 -0
- /package/build/src/integrations/lucid/{attachment_owner.js → relations/attachment_owner.js} +0 -0
- /package/build/src/integrations/lucid/{attachments_table_stub.d.ts → schema/attachments_table_stub.d.ts} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attachment_v5_migration.d.ts","sourceRoot":"","sources":["../../../commands/make/attachment_v5_migration.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;
|
|
1
|
+
{"version":3,"file":"attachment_v5_migration.d.ts","sourceRoot":"","sources":["../../../commands/make/attachment_v5_migration.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAKhD,MAAM,CAAC,OAAO,OAAO,yBAA0B,SAAQ,WAAW;IAChE,MAAM,CAAC,WAAW,SAAiC;IACnD,MAAM,CAAC,WAAW,SAA4D;IAC9E,MAAM,CAAC,OAAO;;;MAGb;IAEK,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAY3B"}
|
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
6
|
*/
|
|
7
7
|
import { BaseCommand } from '@adonisjs/core/ace';
|
|
8
|
-
import {
|
|
8
|
+
import { stubsRoot } from '../../stubs/main.js';
|
|
9
|
+
import { createLegacyAttachmentMigrationStubState } from '../../src/integrations/lucid/migrations/legacy/legacy_attachment_migration_stub.js';
|
|
9
10
|
export default class MakeAttachmentV5Migration extends BaseCommand {
|
|
10
11
|
static commandName = 'make:attachment-v5-migration';
|
|
11
12
|
static description = 'Create a script for migrating v5 attachment JSON values';
|
|
@@ -16,11 +17,13 @@ export default class MakeAttachmentV5Migration extends BaseCommand {
|
|
|
16
17
|
async run() {
|
|
17
18
|
const flags = this.parsed.flags;
|
|
18
19
|
const folder = flags.folder ?? 'database/scripts';
|
|
19
|
-
const
|
|
20
|
+
const state = createLegacyAttachmentMigrationStubState({
|
|
20
21
|
directory: this.app.makePath(folder),
|
|
21
22
|
...(flags.disk ? { defaultDisk: flags.disk } : {}),
|
|
22
23
|
});
|
|
23
|
-
this.
|
|
24
|
+
const codemods = await this.createCodemods();
|
|
25
|
+
await codemods.makeUsingStub(stubsRoot, 'migrations/legacy_attachment_migration.stub', state);
|
|
26
|
+
this.logger.success(`Created ${state.destination}`);
|
|
24
27
|
}
|
|
25
28
|
}
|
|
26
29
|
//# sourceMappingURL=attachment_v5_migration.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attachment_v5_migration.js","sourceRoot":"","sources":["../../../commands/make/attachment_v5_migration.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAEhD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"attachment_v5_migration.js","sourceRoot":"","sources":["../../../commands/make/attachment_v5_migration.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAEhD,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAC/C,OAAO,EAAE,wCAAwC,EAAE,MAAM,oFAAoF,CAAA;AAE7I,MAAM,CAAC,OAAO,OAAO,yBAA0B,SAAQ,WAAW;IAChE,MAAM,CAAC,WAAW,GAAG,8BAA8B,CAAA;IACnD,MAAM,CAAC,WAAW,GAAG,yDAAyD,CAAA;IAC9E,MAAM,CAAC,OAAO,GAAG;QACf,QAAQ,EAAE,IAAI;QACd,iBAAiB,EAAE,IAAI;KACxB,CAAA;IAED,KAAK,CAAC,GAAG;QACP,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,KAA2C,CAAA;QACrE,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,IAAI,kBAAkB,CAAA;QACjD,MAAM,KAAK,GAAG,wCAAwC,CAAC;YACrD,SAAS,EAAE,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC;YACpC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SACnD,CAAC,CAAA;QACF,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,cAAc,EAAE,CAAA;QAE5C,MAAM,QAAQ,CAAC,aAAa,CAAC,SAAS,EAAE,6CAA6C,EAAE,KAAK,CAAC,CAAA;QAC7F,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,WAAW,KAAK,CAAC,WAAW,EAAE,CAAC,CAAA;IACrD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attachments_table.d.ts","sourceRoot":"","sources":["../../../commands/make/attachments_table.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;
|
|
1
|
+
{"version":3,"file":"attachments_table.d.ts","sourceRoot":"","sources":["../../../commands/make/attachments_table.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAQhD,MAAM,CAAC,OAAO,OAAO,oBAAqB,SAAQ,WAAW;IAC3D,MAAM,CAAC,WAAW,SAA2B;IAC7C,MAAM,CAAC,WAAW,SAAuD;IACzE,MAAM,CAAC,OAAO;;;MAGb;IAEK,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAa3B"}
|
|
@@ -5,8 +5,9 @@
|
|
|
5
5
|
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
6
|
*/
|
|
7
7
|
import { BaseCommand } from '@adonisjs/core/ace';
|
|
8
|
+
import { configProvider } from '@adonisjs/core';
|
|
8
9
|
import { stubsRoot } from '../../stubs/main.js';
|
|
9
|
-
import { createAttachmentsTableStubState } from '../../src/integrations/lucid/attachments_table_stub.js';
|
|
10
|
+
import { createAttachmentsTableStubState } from '../../src/integrations/lucid/schema/attachments_table_stub.js';
|
|
10
11
|
export default class MakeAttachmentsTable extends BaseCommand {
|
|
11
12
|
static commandName = 'make:attachments-table';
|
|
12
13
|
static description = 'Create the polymorphic attachments table migration';
|
|
@@ -16,7 +17,7 @@ export default class MakeAttachmentsTable extends BaseCommand {
|
|
|
16
17
|
};
|
|
17
18
|
async run() {
|
|
18
19
|
const flags = this.parsed.flags;
|
|
19
|
-
const tableName = flags.table ??
|
|
20
|
+
const tableName = flags.table ?? (await configuredTableName(this.app));
|
|
20
21
|
const folder = flags.folder ?? 'database/migrations';
|
|
21
22
|
const state = createAttachmentsTableStubState({
|
|
22
23
|
directory: this.app.makePath(folder),
|
|
@@ -27,4 +28,9 @@ export default class MakeAttachmentsTable extends BaseCommand {
|
|
|
27
28
|
this.logger.success(`Created ${state.destination}`);
|
|
28
29
|
}
|
|
29
30
|
}
|
|
31
|
+
async function configuredTableName(app) {
|
|
32
|
+
const attachmentConfig = app.config.get('attachment');
|
|
33
|
+
const config = await configProvider.resolve(app, attachmentConfig);
|
|
34
|
+
return config?.integrations?.lucid?.tableName ?? 'attachments';
|
|
35
|
+
}
|
|
30
36
|
//# sourceMappingURL=attachments_table.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attachments_table.js","sourceRoot":"","sources":["../../../commands/make/attachments_table.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;
|
|
1
|
+
{"version":3,"file":"attachments_table.js","sourceRoot":"","sources":["../../../commands/make/attachments_table.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAE/C,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAC/C,OAAO,EAAE,+BAA+B,EAAE,MAAM,+DAA+D,CAAA;AAI/G,MAAM,CAAC,OAAO,OAAO,oBAAqB,SAAQ,WAAW;IAC3D,MAAM,CAAC,WAAW,GAAG,wBAAwB,CAAA;IAC7C,MAAM,CAAC,WAAW,GAAG,oDAAoD,CAAA;IACzE,MAAM,CAAC,OAAO,GAAG;QACf,QAAQ,EAAE,IAAI;QACd,iBAAiB,EAAE,IAAI;KACxB,CAAA;IAED,KAAK,CAAC,GAAG;QACP,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,KAA4C,CAAA;QACtE,MAAM,SAAS,GAAG,KAAK,CAAC,KAAK,IAAI,CAAC,MAAM,mBAAmB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAA;QACtE,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,IAAI,qBAAqB,CAAA;QACpD,MAAM,KAAK,GAAG,+BAA+B,CAAC;YAC5C,SAAS,EAAE,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC;YACpC,SAAS;SACV,CAAC,CAAA;QACF,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,cAAc,EAAE,CAAA;QAE5C,MAAM,QAAQ,CAAC,aAAa,CAAC,SAAS,EAAE,mCAAmC,EAAE,KAAK,CAAC,CAAA;QACnF,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,WAAW,KAAK,CAAC,WAAW,EAAE,CAAC,CAAA;IACrD,CAAC;;AAGH,KAAK,UAAU,mBAAmB,CAAC,GAAuB;IACxD,MAAM,gBAAgB,GAAG,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,YAAY,CAAC,CAAA;IACrD,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC,OAAO,CAA2B,GAAG,EAAE,gBAAgB,CAAC,CAAA;IAE5F,OAAO,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,SAAS,IAAI,aAAa,CAAA;AAChE,CAAC"}
|
package/build/index.d.ts
CHANGED
|
@@ -1,27 +1,28 @@
|
|
|
1
|
-
import type { AttachmentService } from
|
|
2
|
-
import type { AttachmentRepository } from
|
|
3
|
-
import type { AttachmentManager } from
|
|
4
|
-
import attachmentManager from
|
|
5
|
-
declare module
|
|
1
|
+
import type { AttachmentService } from "./src/core/attachment_service.js";
|
|
2
|
+
import type { AttachmentRepository } from "./src/core/attachment_repository.js";
|
|
3
|
+
import type { AttachmentManager } from "./src/sources/attachment_manager.js";
|
|
4
|
+
import attachmentManager from "./services/main.js";
|
|
5
|
+
declare module "@adonisjs/core/types" {
|
|
6
6
|
interface ContainerBindings {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
"jrmc.attachment": AttachmentService;
|
|
8
|
+
"jrmc.attachment.manager": AttachmentManager;
|
|
9
|
+
"jrmc.attachment.repository": AttachmentRepository;
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
|
-
export * from
|
|
13
|
-
export { configure } from
|
|
12
|
+
export * from "./src/core/index.js";
|
|
13
|
+
export { configure } from "./configure.js";
|
|
14
14
|
export { attachmentManager };
|
|
15
|
-
export { defineConfig, type AttachmentConfig, type ResolvedAttachmentConfig } from
|
|
16
|
-
export { AdonisDriveStorage } from
|
|
17
|
-
export { LocalFileStorage, type LocalFileStorageOptions } from
|
|
18
|
-
export { attachment } from
|
|
19
|
-
export {
|
|
20
|
-
export {
|
|
21
|
-
export {
|
|
22
|
-
export {
|
|
23
|
-
export {
|
|
24
|
-
export {
|
|
25
|
-
export {
|
|
26
|
-
export {
|
|
15
|
+
export { defineConfig, type AttachmentIntegrationsConfig, type AttachmentConfig, type LucidAttachmentConfig, type ResolvedAttachmentConfig, } from "./src/define_config.js";
|
|
16
|
+
export { AdonisDriveStorage } from "./src/adapters/adonis_drive_storage.js";
|
|
17
|
+
export { LocalFileStorage, type LocalFileStorageOptions, } from "./src/adapters/local_file_storage.js";
|
|
18
|
+
export { attachment, type LucidAttachmentOptions, } from "./src/integrations/lucid/column/attachment_column.js";
|
|
19
|
+
export { attachmentRelation, attachmentsRelation, AttachmentRelation, AttachmentCollectionRelation, type AttachmentRelationOptions, } from "./src/integrations/lucid/relations/attachment_relation.js";
|
|
20
|
+
export { VariantGenerationService, UnknownVariantConverterError, type GeneratedVariant, type VariantGenerationServiceOptions, } from "./src/variants/variant_generation_service.js";
|
|
21
|
+
export { type VariantConverter, type VariantConversionInput, type VariantConversionOutput, } from "./src/variants/variant_converter.js";
|
|
22
|
+
export { MemoryAttachmentQueue } from "./src/queues/memory_queue.js";
|
|
23
|
+
export { AttachmentManager, AttachmentSourceError, type AttachmentManagerOptions, type AttachmentSourceFetch, type AttachmentSourceOptions, type AttachmentSourceResponse, type MultipartAttachmentFile, } from "./src/sources/attachment_manager.js";
|
|
24
|
+
export { AdonisAttachmentQueue, type AdonisAttachmentJob, type AdonisAttachmentQueueOptions, type AdonisQueueDispatcher, } from "./src/queues/adonis_queue.js";
|
|
25
|
+
export { migrateLegacyAttachment, migrateLegacyAttachmentColumn, type AttachmentOwner, type LegacyAttachment, type LegacyVariant, type MigrateLegacyAttachmentColumnOptions, type MigratedAttachmentBlob, type MigratedAttachmentLink, type MigratedAttachmentRows, } from "./src/integrations/lucid/migrations/legacy/migrate_legacy_attachment.js";
|
|
26
|
+
export { createAttachmentOwnerKey } from "./src/integrations/lucid/relations/attachment_owner.js";
|
|
27
|
+
export { createAttachmentsTableStubState } from "./src/integrations/lucid/schema/attachments_table_stub.js";
|
|
27
28
|
//# sourceMappingURL=index.d.ts.map
|
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAC1E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAChF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AAE7E,OAAO,iBAAiB,MAAM,oBAAoB,CAAC;AAEnD,OAAO,QAAQ,sBAAsB,CAAC;IACpC,UAAiB,iBAAiB;QAChC,iBAAiB,EAAE,iBAAiB,CAAC;QACrC,yBAAyB,EAAE,iBAAiB,CAAC;QAC7C,4BAA4B,EAAE,oBAAoB,CAAC;KACpD;CACF;AAED,cAAc,qBAAqB,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,CAAC;AAC7B,OAAO,EACL,YAAY,EACZ,KAAK,4BAA4B,EACjC,KAAK,gBAAgB,EACrB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AAM,2DAA2D,CAAC"}
|
package/build/index.js
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import attachmentManager from
|
|
2
|
-
export * from
|
|
3
|
-
export { configure } from
|
|
1
|
+
import attachmentManager from "./services/main.js";
|
|
2
|
+
export * from "./src/core/index.js";
|
|
3
|
+
export { configure } from "./configure.js";
|
|
4
4
|
export { attachmentManager };
|
|
5
|
-
export { defineConfig } from
|
|
6
|
-
export { AdonisDriveStorage } from
|
|
7
|
-
export { LocalFileStorage } from
|
|
8
|
-
export { attachment } from
|
|
9
|
-
export {
|
|
10
|
-
export {
|
|
11
|
-
export {
|
|
12
|
-
export {
|
|
13
|
-
export {
|
|
14
|
-
export {
|
|
15
|
-
export {
|
|
5
|
+
export { defineConfig, } from "./src/define_config.js";
|
|
6
|
+
export { AdonisDriveStorage } from "./src/adapters/adonis_drive_storage.js";
|
|
7
|
+
export { LocalFileStorage, } from "./src/adapters/local_file_storage.js";
|
|
8
|
+
export { attachment, } from "./src/integrations/lucid/column/attachment_column.js";
|
|
9
|
+
export { attachmentRelation, attachmentsRelation, AttachmentRelation, AttachmentCollectionRelation, } from "./src/integrations/lucid/relations/attachment_relation.js";
|
|
10
|
+
export { VariantGenerationService, UnknownVariantConverterError, } from "./src/variants/variant_generation_service.js";
|
|
11
|
+
export { MemoryAttachmentQueue } from "./src/queues/memory_queue.js";
|
|
12
|
+
export { AttachmentManager, AttachmentSourceError, } from "./src/sources/attachment_manager.js";
|
|
13
|
+
export { AdonisAttachmentQueue, } from "./src/queues/adonis_queue.js";
|
|
14
|
+
export { migrateLegacyAttachment, migrateLegacyAttachmentColumn, } from "./src/integrations/lucid/migrations/legacy/migrate_legacy_attachment.js";
|
|
15
|
+
export { createAttachmentOwnerKey } from "./src/integrations/lucid/relations/attachment_owner.js";
|
|
16
|
+
export { createAttachmentsTableStubState } from "./src/integrations/lucid/schema/attachments_table_stub.js";
|
|
16
17
|
//# sourceMappingURL=index.js.map
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAIA,OAAO,iBAAiB,MAAM,oBAAoB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAIA,OAAO,iBAAiB,MAAM,oBAAoB,CAAC;AAUnD,cAAc,qBAAqB,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,CAAC;AAC7B,OAAO,EACL,YAAY,GAKb,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAC5E,OAAO,EACL,gBAAgB,GAEjB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EACL,UAAU,GAEX,MAAM,sDAAsD,CAAC;AAC9D,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,kBAAkB,EAClB,4BAA4B,GAE7B,MAAM,2DAA2D,CAAC;AACnE,OAAO,EACL,wBAAwB,EACxB,4BAA4B,GAG7B,MAAM,8CAA8C,CAAC;AAMtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EACL,iBAAiB,EACjB,qBAAqB,GAMtB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EACL,qBAAqB,GAItB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,uBAAuB,EACvB,6BAA6B,GAQ9B,MAAM,yEAAyE,CAAC;AACjF,OAAO,EAAE,wBAAwB,EAAE,MAAM,wDAAwD,CAAC;AAClG,OAAO,EAAE,+BAA+B,EAAE,MAAM,2DAA2D,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attachment_provider.d.ts","sourceRoot":"","sources":["../../providers/attachment_provider.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AAG9D,MAAM,CAAC,OAAO,OAAO,kBAAkB;IACzB,SAAS,CAAC,GAAG,EAAE,kBAAkB;gBAAvB,GAAG,EAAE,kBAAkB;IAE7C,QAAQ,IAAI,IAAI;
|
|
1
|
+
{"version":3,"file":"attachment_provider.d.ts","sourceRoot":"","sources":["../../providers/attachment_provider.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AAG9D,MAAM,CAAC,OAAO,OAAO,kBAAkB;IACzB,SAAS,CAAC,GAAG,EAAE,kBAAkB;gBAAvB,GAAG,EAAE,kBAAkB;IAE7C,QAAQ,IAAI,IAAI;IAkDV,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAuB5B"}
|
|
@@ -20,6 +20,7 @@ export default class AttachmentProvider {
|
|
|
20
20
|
if (!config) {
|
|
21
21
|
throw new Error('Invalid attachment config. Export the result of defineConfig from config/attachment.ts');
|
|
22
22
|
}
|
|
23
|
+
await applyLucidConfig(config);
|
|
23
24
|
return new AttachmentService(config);
|
|
24
25
|
});
|
|
25
26
|
this.app.container.singleton('jrmc.attachment.repository', async () => {
|
|
@@ -28,11 +29,15 @@ export default class AttachmentProvider {
|
|
|
28
29
|
if (!config?.repository) {
|
|
29
30
|
throw new Error('Attachment routes require a repository in config/attachment.ts');
|
|
30
31
|
}
|
|
32
|
+
await applyLucidConfig(config);
|
|
31
33
|
return config.repository;
|
|
32
34
|
});
|
|
33
35
|
this.app.container.singleton('jrmc.attachment.manager', async () => {
|
|
34
36
|
const attachmentConfig = this.app.config.get('attachment');
|
|
35
37
|
const config = await configProvider.resolve(this.app, attachmentConfig);
|
|
38
|
+
if (config) {
|
|
39
|
+
await applyLucidConfig(config);
|
|
40
|
+
}
|
|
36
41
|
const attachments = await this.app.container.make('jrmc.attachment');
|
|
37
42
|
return new AttachmentManager(attachments, config?.sources);
|
|
38
43
|
});
|
|
@@ -40,6 +45,9 @@ export default class AttachmentProvider {
|
|
|
40
45
|
async boot() {
|
|
41
46
|
const attachmentConfig = this.app.config.get('attachment');
|
|
42
47
|
const config = await configProvider.resolve(this.app, attachmentConfig);
|
|
48
|
+
if (config) {
|
|
49
|
+
await applyLucidConfig(config);
|
|
50
|
+
}
|
|
43
51
|
if (!config || config.route === false || !config.repository) {
|
|
44
52
|
return;
|
|
45
53
|
}
|
|
@@ -51,4 +59,12 @@ export default class AttachmentProvider {
|
|
|
51
59
|
});
|
|
52
60
|
}
|
|
53
61
|
}
|
|
62
|
+
async function applyLucidConfig(config) {
|
|
63
|
+
const lucid = config.integrations?.lucid;
|
|
64
|
+
if (!lucid) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
const { configureLucidAttachmentTables } = await import('../src/integrations/lucid/schema/configure_lucid_attachment_tables.js');
|
|
68
|
+
configureLucidAttachmentTables(lucid.tableName);
|
|
69
|
+
}
|
|
54
70
|
//# sourceMappingURL=attachment_provider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attachment_provider.js","sourceRoot":"","sources":["../../providers/attachment_provider.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAA;AACrE,OAAO,EAAE,qBAAqB,EAAE,MAAM,8CAA8C,CAAA;AACpF,OAAO,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAA;AAKxE,MAAM,CAAC,OAAO,OAAO,kBAAkB;IACf;IAAtB,YAAsB,GAAuB;QAAvB,QAAG,GAAH,GAAG,CAAoB;IAAG,CAAC;IAEjD,QAAQ;QACN,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,SAAS,CAAC,iBAAiB,EAAE,KAAK,IAAI,EAAE;YACzD,MAAM,gBAAgB,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,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ED,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,KAAK,KAAK,KAAK,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;YAC5D,OAAM;QACR,CAAC;QAED,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;QACtD,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;YAC9C,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAA;YACpE,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,4BAA4B,CAAC,CAAA;YAE9E,OAAO,IAAI,qBAAqB,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;QAC3E,CAAC,CAAC,CAAA;IACJ,CAAC;CACF;AAED,KAAK,UAAU,gBAAgB,CAAC,MAAgC;IAC9D,MAAM,KAAK,GAAG,MAAM,CAAC,YAAY,EAAE,KAAK,CAAA;IAExC,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAM;IACR,CAAC;IAED,MAAM,EAAE,8BAA8B,EAAE,GACtC,MAAM,MAAM,CAAC,uEAAuE,CAAC,CAAA;IACvF,8BAA8B,CAAC,KAAK,CAAC,SAAS,CAAC,CAAA;AACjD,CAAC"}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* @license MIT
|
|
5
5
|
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
6
|
*/
|
|
7
|
+
import type { AttachmentPersistenceContext, AttachmentPersistenceOptions } from './attachment_options.js';
|
|
7
8
|
export type Attachment = Readonly<{
|
|
8
9
|
id: string;
|
|
9
10
|
disk: string;
|
|
@@ -13,8 +14,13 @@ export type Attachment = Readonly<{
|
|
|
13
14
|
size: number;
|
|
14
15
|
extname: string;
|
|
15
16
|
mimeType: string;
|
|
16
|
-
metadata?: Record<string, unknown
|
|
17
|
+
metadata?: Record<string, unknown> | undefined;
|
|
17
18
|
}>;
|
|
19
|
+
export type AttachmentPersistRequest<Model = any> = {
|
|
20
|
+
options?: AttachmentPersistenceOptions<Model>;
|
|
21
|
+
context?: Omit<AttachmentPersistenceContext<Model>, 'originalName'>;
|
|
22
|
+
};
|
|
23
|
+
export type AttachmentDraftPersistence = (draft: AttachmentDraft, request?: AttachmentPersistRequest<any>) => Promise<Attachment>;
|
|
18
24
|
export type CreateAttachmentInput = {
|
|
19
25
|
body: Uint8Array;
|
|
20
26
|
originalName: string;
|
|
@@ -23,6 +29,30 @@ export type CreateAttachmentInput = {
|
|
|
23
29
|
folder?: string;
|
|
24
30
|
metadata?: Record<string, unknown>;
|
|
25
31
|
};
|
|
32
|
+
/**
|
|
33
|
+
* A source-backed attachment that has not been written to storage yet.
|
|
34
|
+
* Its public properties become final after `persist()` resolves.
|
|
35
|
+
*/
|
|
36
|
+
export declare class AttachmentDraft implements Attachment {
|
|
37
|
+
#private;
|
|
38
|
+
readonly id: string;
|
|
39
|
+
disk: string;
|
|
40
|
+
name: string;
|
|
41
|
+
originalName: string;
|
|
42
|
+
path: string;
|
|
43
|
+
size: number;
|
|
44
|
+
extname: string;
|
|
45
|
+
mimeType: string;
|
|
46
|
+
metadata?: Record<string, unknown> | undefined;
|
|
47
|
+
constructor(source: CreateAttachmentInput, provisional: Attachment, options: AttachmentPersistenceOptions, persistence: AttachmentDraftPersistence);
|
|
48
|
+
get isPersisted(): boolean;
|
|
49
|
+
get source(): Readonly<CreateAttachmentInput>;
|
|
50
|
+
get options(): Readonly<AttachmentPersistenceOptions>;
|
|
51
|
+
persist(request?: AttachmentPersistRequest<any>): Promise<Attachment>;
|
|
52
|
+
toJSON(): Attachment;
|
|
53
|
+
toAttachment(): Attachment;
|
|
54
|
+
}
|
|
55
|
+
export declare function isAttachmentDraft(value: unknown): value is AttachmentDraft;
|
|
26
56
|
export type AttachmentFactoryOptions = {
|
|
27
57
|
defaultDisk: string;
|
|
28
58
|
createId?: () => string;
|
|
@@ -30,6 +60,11 @@ export type AttachmentFactoryOptions = {
|
|
|
30
60
|
export declare class AttachmentFactory {
|
|
31
61
|
#private;
|
|
32
62
|
constructor(options: AttachmentFactoryOptions);
|
|
33
|
-
create(input: CreateAttachmentInput
|
|
63
|
+
create(input: CreateAttachmentInput, options?: {
|
|
64
|
+
id?: string;
|
|
65
|
+
name?: string;
|
|
66
|
+
disk?: string;
|
|
67
|
+
folder?: string;
|
|
68
|
+
}): Attachment;
|
|
34
69
|
}
|
|
35
70
|
//# sourceMappingURL=attachment.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attachment.d.ts","sourceRoot":"","sources":["../../../src/core/attachment.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,MAAM,MAAM,UAAU,GAAG,QAAQ,CAAC;IAChC,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,YAAY,EAAE,MAAM,CAAA;IACpB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"attachment.d.ts","sourceRoot":"","sources":["../../../src/core/attachment.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,KAAK,EACV,4BAA4B,EAC5B,4BAA4B,EAC7B,MAAM,yBAAyB,CAAA;AAEhC,MAAM,MAAM,UAAU,GAAG,QAAQ,CAAC;IAChC,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,C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AAE,OAAO,CAAC,GAAG,SAAS,CAAA;gBAS5C,MAAM,EAAE,qBAAqB,EAC7B,WAAW,EAAE,UAAU,EACvB,OAAO,EAAE,4BAA4B,EACrC,WAAW,EAAE,0BAA0B;IAkBzC,IAAI,WAAW,IAAI,OAAO,CAEzB;IAED,IAAI,MAAM,IAAI,QAAQ,CAAC,qBAAqB,CAAC,CAM5C;IAED,IAAI,OAAO,IAAI,QAAQ,CAAC,4BAA4B,CAAC,CAEpD;IAED,OAAO,CAAC,OAAO,CAAC,EAAE,wBAAwB,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC;IAgCrE,MAAM,IAAI,UAAU;IAQpB,YAAY,IAAI,UAAU;CAa3B;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,eAAe,CAE1E;AAED,MAAM,MAAM,wBAAwB,GAAG;IACrC,WAAW,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,EAAE,MAAM,MAAM,CAAA;CACxB,CAAA;AAED,qBAAa,iBAAiB;;gBAIhB,OAAO,EAAE,wBAAwB;IAK7C,MAAM,CACJ,KAAK,EAAE,qBAAqB,EAC5B,OAAO,GAAE;QAAE,EAAE,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAO,GAC3E,UAAU;CAkBd"}
|
|
@@ -6,6 +6,106 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { randomUUID } from 'node:crypto';
|
|
8
8
|
import { extname } from 'node:path';
|
|
9
|
+
/**
|
|
10
|
+
* A source-backed attachment that has not been written to storage yet.
|
|
11
|
+
* Its public properties become final after `persist()` resolves.
|
|
12
|
+
*/
|
|
13
|
+
export class AttachmentDraft {
|
|
14
|
+
id;
|
|
15
|
+
disk;
|
|
16
|
+
name;
|
|
17
|
+
originalName;
|
|
18
|
+
path;
|
|
19
|
+
size;
|
|
20
|
+
extname;
|
|
21
|
+
mimeType;
|
|
22
|
+
metadata;
|
|
23
|
+
#options;
|
|
24
|
+
#source;
|
|
25
|
+
#persisted = false;
|
|
26
|
+
#persisting;
|
|
27
|
+
#persistence;
|
|
28
|
+
constructor(source, provisional, options, persistence) {
|
|
29
|
+
this.id = provisional.id;
|
|
30
|
+
this.disk = provisional.disk;
|
|
31
|
+
this.name = provisional.name;
|
|
32
|
+
this.originalName = provisional.originalName;
|
|
33
|
+
this.path = provisional.path;
|
|
34
|
+
this.size = provisional.size;
|
|
35
|
+
this.extname = provisional.extname;
|
|
36
|
+
this.mimeType = provisional.mimeType;
|
|
37
|
+
if (provisional.metadata) {
|
|
38
|
+
this.metadata = provisional.metadata;
|
|
39
|
+
}
|
|
40
|
+
this.#source = source;
|
|
41
|
+
this.#options = options;
|
|
42
|
+
this.#persistence = persistence;
|
|
43
|
+
}
|
|
44
|
+
get isPersisted() {
|
|
45
|
+
return this.#persisted;
|
|
46
|
+
}
|
|
47
|
+
get source() {
|
|
48
|
+
if (!this.#source) {
|
|
49
|
+
throw new Error('Attachment draft source is no longer available after persistence');
|
|
50
|
+
}
|
|
51
|
+
return this.#source;
|
|
52
|
+
}
|
|
53
|
+
get options() {
|
|
54
|
+
return this.#options;
|
|
55
|
+
}
|
|
56
|
+
persist(request) {
|
|
57
|
+
if (this.#persisted) {
|
|
58
|
+
return Promise.resolve(this);
|
|
59
|
+
}
|
|
60
|
+
if (!this.#persisting) {
|
|
61
|
+
this.#persisting = this.#persistence(this, request)
|
|
62
|
+
.then((attachment) => {
|
|
63
|
+
this.disk = attachment.disk;
|
|
64
|
+
this.name = attachment.name;
|
|
65
|
+
this.path = attachment.path;
|
|
66
|
+
this.size = attachment.size;
|
|
67
|
+
this.extname = attachment.extname;
|
|
68
|
+
this.mimeType = attachment.mimeType;
|
|
69
|
+
if (attachment.metadata) {
|
|
70
|
+
this.metadata = attachment.metadata;
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
delete this.metadata;
|
|
74
|
+
}
|
|
75
|
+
this.#source = undefined;
|
|
76
|
+
this.#persisted = true;
|
|
77
|
+
return this;
|
|
78
|
+
})
|
|
79
|
+
.catch((error) => {
|
|
80
|
+
this.#persisting = undefined;
|
|
81
|
+
throw error;
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
return this.#persisting;
|
|
85
|
+
}
|
|
86
|
+
toJSON() {
|
|
87
|
+
if (!this.#persisted) {
|
|
88
|
+
throw new Error('Attachment drafts must be persisted before serialization');
|
|
89
|
+
}
|
|
90
|
+
return this.toAttachment();
|
|
91
|
+
}
|
|
92
|
+
toAttachment() {
|
|
93
|
+
return {
|
|
94
|
+
id: this.id,
|
|
95
|
+
disk: this.disk,
|
|
96
|
+
name: this.name,
|
|
97
|
+
originalName: this.originalName,
|
|
98
|
+
path: this.path,
|
|
99
|
+
size: this.size,
|
|
100
|
+
extname: this.extname,
|
|
101
|
+
mimeType: this.mimeType,
|
|
102
|
+
...(this.metadata ? { metadata: this.metadata } : {}),
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
export function isAttachmentDraft(value) {
|
|
107
|
+
return value instanceof AttachmentDraft;
|
|
108
|
+
}
|
|
9
109
|
export class AttachmentFactory {
|
|
10
110
|
#defaultDisk;
|
|
11
111
|
#createId;
|
|
@@ -13,14 +113,14 @@ export class AttachmentFactory {
|
|
|
13
113
|
this.#defaultDisk = options.defaultDisk;
|
|
14
114
|
this.#createId = options.createId ?? randomUUID;
|
|
15
115
|
}
|
|
16
|
-
create(input) {
|
|
17
|
-
const id = this.#createId();
|
|
116
|
+
create(input, options = {}) {
|
|
117
|
+
const id = options.id ?? this.#createId();
|
|
18
118
|
const extension = getExtension(input.originalName);
|
|
19
|
-
const name = extension ? `${id}.${extension}` : id;
|
|
20
|
-
const path = joinPath(input.folder, name);
|
|
119
|
+
const name = options.name ?? (extension ? `${id}.${extension}` : id);
|
|
120
|
+
const path = joinPath(options.folder ?? input.folder, name);
|
|
21
121
|
return {
|
|
22
122
|
id,
|
|
23
|
-
disk: input.disk ?? this.#defaultDisk,
|
|
123
|
+
disk: options.disk ?? input.disk ?? this.#defaultDisk,
|
|
24
124
|
name,
|
|
25
125
|
originalName: input.originalName,
|
|
26
126
|
path,
|
|
@@ -35,6 +135,9 @@ function getExtension(fileName) {
|
|
|
35
135
|
return extname(fileName).slice(1).toLowerCase();
|
|
36
136
|
}
|
|
37
137
|
function joinPath(folder, name) {
|
|
138
|
+
if (name.includes('/') || name.includes('\\') || name === '.' || name === '..') {
|
|
139
|
+
throw new Error('Attachment names must not contain path separators');
|
|
140
|
+
}
|
|
38
141
|
if (!folder) {
|
|
39
142
|
return name;
|
|
40
143
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attachment.js","sourceRoot":"","sources":["../../../src/core/attachment.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"attachment.js","sourceRoot":"","sources":["../../../src/core/attachment.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAsCnC;;;GAGG;AACH,MAAM,OAAO,eAAe;IACjB,EAAE,CAAQ;IACnB,IAAI,CAAQ;IACZ,IAAI,CAAQ;IACZ,YAAY,CAAQ;IACpB,IAAI,CAAQ;IACZ,IAAI,CAAQ;IACZ,OAAO,CAAQ;IACf,QAAQ,CAAQ;IAChB,QAAQ,CAAsC;IAErC,QAAQ,CAA8B;IAC/C,OAAO,CAAmC;IAC1C,UAAU,GAAG,KAAK,CAAA;IAClB,WAAW,CAAiC;IACnC,YAAY,CAA4B;IAEjD,YACE,MAA6B,EAC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
|
3
|
+
field?: string;
|
|
4
|
+
originalName: string;
|
|
5
|
+
};
|
|
6
|
+
export type AttachmentFolder<Model = unknown> = string | ((context: AttachmentPersistenceContext<Model>) => string | Promise<string>);
|
|
7
|
+
export type AttachmentRename<Model = unknown> = boolean | ((context: AttachmentPersistenceContext<Model>) => string | Promise<string>);
|
|
8
|
+
/**
|
|
9
|
+
* File-persistence settings. `null` explicitly disables an inherited setting.
|
|
10
|
+
*/
|
|
11
|
+
export type AttachmentPersistenceOptions<Model = unknown> = {
|
|
12
|
+
disk?: string | null;
|
|
13
|
+
folder?: AttachmentFolder<Model> | null;
|
|
14
|
+
rename?: AttachmentRename<Model> | null;
|
|
15
|
+
meta?: boolean | null;
|
|
16
|
+
preComputeUrl?: boolean | null;
|
|
17
|
+
variants?: readonly string[] | null;
|
|
18
|
+
};
|
|
19
|
+
export type ResolvedAttachmentPersistenceOptions<Model = unknown> = {
|
|
20
|
+
disk?: string;
|
|
21
|
+
folder?: AttachmentFolder<Model>;
|
|
22
|
+
rename?: AttachmentRename<Model>;
|
|
23
|
+
meta?: boolean;
|
|
24
|
+
preComputeUrl?: boolean;
|
|
25
|
+
variants?: readonly string[];
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Resolves options from lowest to highest priority. An explicit `null` clears
|
|
29
|
+
* the inherited value for one setting.
|
|
30
|
+
*/
|
|
31
|
+
export declare function resolveAttachmentPersistenceOptions<Model = unknown>(...layers: ReadonlyArray<AttachmentPersistenceOptions<Model> | undefined>): ResolvedAttachmentPersistenceOptions<Model>;
|
|
32
|
+
//# sourceMappingURL=attachment_options.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachment_options.d.ts","sourceRoot":"","sources":["../../../src/core/attachment_options.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,4BAA4B,CAAC,KAAK,GAAG,OAAO,IAAI;IAC1D,KAAK,CAAC,EAAE,KAAK,CAAA;IACb,KAAK,CAAC,EAAE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,MAAM,EAAE,aAAa,CAAC,4BAA4B,CAAC,KAAK,CAAC,GAAG,SAAS,CAAC,GACxE,oCAAoC,CAAC,KAAK,CAAC,CAS7C"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolves options from lowest to highest priority. An explicit `null` clears
|
|
3
|
+
* the inherited value for one setting.
|
|
4
|
+
*/
|
|
5
|
+
export function resolveAttachmentPersistenceOptions(...layers) {
|
|
6
|
+
return {
|
|
7
|
+
...resolveOption('disk', layers),
|
|
8
|
+
...resolveOption('folder', layers),
|
|
9
|
+
...resolveOption('rename', layers),
|
|
10
|
+
...resolveOption('meta', layers),
|
|
11
|
+
...resolveOption('preComputeUrl', layers),
|
|
12
|
+
...resolveOption('variants', layers),
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
function resolveOption(key, layers) {
|
|
16
|
+
for (const layer of [...layers].reverse()) {
|
|
17
|
+
const value = layer?.[key];
|
|
18
|
+
if (value !== undefined) {
|
|
19
|
+
return value === null ? {} : { [key]: value };
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return {};
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=attachment_options.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachment_options.js","sourceRoot":"","sources":["../../../src/core/attachment_options.ts"],"names":[],"mappings":"AAmCA;;;GAGG;AACH,MAAM,UAAU,mCAAmC,CACjD,GAAG,MAAsE;IAEzE,OAAO;QACL,GAAG,aAAa,CAAC,MAAM,EAAE,MAAM,CAAC;QAChC,GAAG,aAAa,CAAC,QAAQ,EAAE,MAAM,CAAC;QAClC,GAAG,aAAa,CAAC,QAAQ,EAAE,MAAM,CAAC;QAClC,GAAG,aAAa,CAAC,MAAM,EAAE,MAAM,CAAC;QAChC,GAAG,aAAa,CAAC,eAAe,EAAE,MAAM,CAAC;QACzC,GAAG,aAAa,CAAC,UAAU,EAAE,MAAM,CAAC;KACrC,CAAA;AACH,CAAC;AAED,SAAS,aAAa,CACpB,GAAQ,EACR,MAAsE;IAEtE,KAAK,MAAM,KAAK,IAAI,CAAC,GAAG,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC;QAC1C,MAAM,KAAK,GAAG,KAAK,EAAE,CAAC,GAAG,CAAC,CAAA;QAE1B,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,OAAO,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,CAAA;QAC/C,CAAC;IACH,CAAC;IAED,OAAO,EAAE,CAAA;AACX,CAAC"}
|
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
* @license MIT
|
|
5
5
|
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
6
|
*/
|
|
7
|
-
import { type Attachment, type CreateAttachmentInput } from './attachment.js';
|
|
7
|
+
import { AttachmentDraft, type Attachment, type CreateAttachmentInput } from './attachment.js';
|
|
8
|
+
import { type AttachmentPersistenceOptions } from './attachment_options.js';
|
|
8
9
|
import type { AttachmentQueue } from './queue.js';
|
|
9
10
|
import type { AttachmentStorage } from './storage.js';
|
|
10
11
|
export type AttachmentServiceOptions = {
|
|
@@ -12,6 +13,7 @@ export type AttachmentServiceOptions = {
|
|
|
12
13
|
queue: AttachmentQueue;
|
|
13
14
|
defaultDisk: string;
|
|
14
15
|
createId?: () => string;
|
|
16
|
+
defaults?: AttachmentPersistenceOptions;
|
|
15
17
|
};
|
|
16
18
|
/**
|
|
17
19
|
* Creates files and delegates persistence to the configured storage backend.
|
|
@@ -20,6 +22,10 @@ export type AttachmentServiceOptions = {
|
|
|
20
22
|
export declare class AttachmentService {
|
|
21
23
|
#private;
|
|
22
24
|
constructor(options: AttachmentServiceOptions);
|
|
25
|
+
createDraft(input: CreateAttachmentInput, options?: AttachmentPersistenceOptions): AttachmentDraft;
|
|
26
|
+
/**
|
|
27
|
+
* Backward-compatible immediate persistence for direct service consumers.
|
|
28
|
+
*/
|
|
23
29
|
create(input: CreateAttachmentInput): Promise<Attachment>;
|
|
24
30
|
remove(attachment: Attachment): Promise<void>;
|
|
25
31
|
read(attachment: Attachment): Promise<Uint8Array>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attachment_service.d.ts","sourceRoot":"","sources":["../../../src/core/attachment_service.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"attachment_service.d.ts","sourceRoot":"","sources":["../../../src/core/attachment_service.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,eAAe,EAEf,KAAK,UAAU,EAEf,KAAK,qBAAqB,EAC3B,MAAM,iBAAiB,CAAA;AAExB,OAAO,EAIL,KAAK,4BAA4B,EAElC,MAAM,yBAAyB,CAAA;AAChC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AACjD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAErD,MAAM,MAAM,wBAAwB,GAAG;IACrC,OAAO,EAAE,iBAAiB,CAAA;IAC1B,KAAK,EAAE,eAAe,CAAA;IACtB,WAAW,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,EAAE,MAAM,MAAM,CAAA;IACvB,QAAQ,CAAC,EAAE,4BAA4B,CAAA;CACxC,CAAA;AAED;;;GAGG;AACH,qBAAa,iBAAiB;;gBAMhB,OAAO,EAAE,wBAAwB;IAO7C,WAAW,CACT,KAAK,EAAE,qBAAqB,EAC5B,OAAO,GAAE,4BAAiC,GACzC,eAAe;IAgBlB;;OAEG;IACG,MAAM,CAAC,KAAK,EAAE,qBAAqB,GAAG,OAAO,CAAC,UAAU,CAAC;IAmC/D,MAAM,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IAI7C,IAAI,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;IAIjD,yBAAyB,CACvB,UAAU,EAAE,UAAU,EACtB,WAAW,CAAC,EAAE,SAAS,MAAM,EAAE,GAC9B,OAAO,CAAC,IAAI,CAAC;CAOjB"}
|