@jrmc/adonis-attachment 6.0.0-alpha.1 → 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 +6 -6
- package/build/index.d.ts.map +1 -1
- package/build/index.js +5 -5
- 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/define_config.d.ts +13 -0
- package/build/src/define_config.d.ts.map +1 -1
- package/build/src/define_config.js +8 -0
- package/build/src/define_config.js.map +1 -1
- 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 +16 -13
- package/build/src/integrations/lucid/index.d.ts.map +1 -1
- package/build/src/integrations/lucid/index.js +16 -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} +19 -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} +28 -23
- 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 -7
- 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 -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} +17 -13
- package/build/src/integrations/lucid/persistence/lucid_attachment_lifecycle_service.d.ts.map +1 -0
- package/build/src/integrations/lucid/{lucid_attachment_lifecycle_service.js → persistence/lucid_attachment_lifecycle_service.js} +27 -20
- 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/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} +25 -14
- 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/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/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_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/define_config.spec.js +22 -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 -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_lifecycle_service.spec.js +96 -262
- package/build/tests/lucid_attachment_lifecycle_service.spec.js.map +1 -1
- package/build/tests/lucid_attachment_relation.spec.js +103 -24
- 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 +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 +48 -43
- 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 +1 -1
- 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.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/{lucid_variant_generation_service.js → persistence/lucid_variant_generation_service.js} +0 -0
- /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,38 +4,47 @@
|
|
|
4
4
|
* @license MIT
|
|
5
5
|
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
6
|
*/
|
|
7
|
-
import { createAttachmentOwnerKey, } from "
|
|
7
|
+
import { createAttachmentOwnerKey, } from "../../relations/attachment_owner.js";
|
|
8
8
|
/**
|
|
9
|
-
* Converts one v5 JSON attachment document into
|
|
9
|
+
* Converts one v5 JSON attachment document into blob and polymorphic-link rows.
|
|
10
10
|
* Callers can run it from an Ace command, another ORM migration, or a one-off script.
|
|
11
11
|
*/
|
|
12
12
|
export function migrateLegacyAttachment(value, options) {
|
|
13
13
|
const attachment = typeof value === "string" ? parseLegacyAttachment(value) : value;
|
|
14
14
|
const id = options.createId();
|
|
15
15
|
const originalName = attachment.originalName ?? attachment.name;
|
|
16
|
-
const original =
|
|
16
|
+
const original = toBlob({
|
|
17
17
|
id,
|
|
18
18
|
attachment,
|
|
19
|
-
owner: options.owner,
|
|
20
|
-
ownerKey: createAttachmentOwnerKey(options.owner),
|
|
21
19
|
parentId: null,
|
|
22
20
|
variantKey: null,
|
|
23
21
|
originalName,
|
|
24
22
|
defaultDisk: options.defaultDisk,
|
|
25
23
|
});
|
|
26
|
-
return
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
24
|
+
return {
|
|
25
|
+
blobs: [
|
|
26
|
+
original,
|
|
27
|
+
...(attachment.variants ?? []).map((variant) => toBlob({
|
|
28
|
+
id: options.createId(),
|
|
29
|
+
attachment: variant,
|
|
30
|
+
parentId: id,
|
|
31
|
+
variantKey: variant.key,
|
|
32
|
+
originalName,
|
|
33
|
+
defaultDisk: options.defaultDisk,
|
|
34
|
+
})),
|
|
35
|
+
],
|
|
36
|
+
links: [
|
|
37
|
+
{
|
|
38
|
+
id: options.createId(),
|
|
39
|
+
attachableType: options.owner.type,
|
|
40
|
+
attachableId: options.owner.id,
|
|
41
|
+
field: options.owner.field,
|
|
42
|
+
ownerKey: createAttachmentOwnerKey(options.owner),
|
|
43
|
+
position: null,
|
|
44
|
+
attachmentId: id,
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
};
|
|
39
48
|
}
|
|
40
49
|
/**
|
|
41
50
|
* Converts one v5 JSON value for a retained single attachment column. Legacy
|
|
@@ -67,13 +76,9 @@ function parseLegacyAttachment(value) {
|
|
|
67
76
|
throw new Error("Legacy attachment value must be valid JSON");
|
|
68
77
|
}
|
|
69
78
|
}
|
|
70
|
-
function
|
|
79
|
+
function toBlob({ id, attachment, parentId, variantKey, originalName, defaultDisk, }) {
|
|
71
80
|
return {
|
|
72
81
|
id,
|
|
73
|
-
attachableType: owner.type,
|
|
74
|
-
attachableId: owner.id,
|
|
75
|
-
field: owner.field,
|
|
76
|
-
ownerKey,
|
|
77
82
|
parentId,
|
|
78
83
|
variantKey,
|
|
79
84
|
disk: attachment.disk ?? defaultDisk,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrate_legacy_attachment.js","sourceRoot":"","sources":["../../../../../../src/integrations/lucid/migrations/legacy/migrate_legacy_attachment.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAyBH,OAAO,EACL,wBAAwB,GAEzB,MAAM,qCAAqC,CAAC;AA6C7C;;;GAGG;AACH,MAAM,UAAU,uBAAuB,CACrC,KAAgC,EAChC,OAAuC;IAEvC,MAAM,UAAU,GACd,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IACnE,MAAM,EAAE,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;IAC9B,MAAM,YAAY,GAAG,UAAU,CAAC,YAAY,IAAI,UAAU,CAAC,IAAI,CAAC;IAChE,MAAM,QAAQ,GAAG,MAAM,CAAC;QACtB,EAAE;QACF,UAAU;QACV,QAAQ,EAAE,IAAI;QACd,UAAU,EAAE,IAAI;QAChB,YAAY;QACZ,WAAW,EAAE,OAAO,CAAC,WAAW;KACjC,CAAC,CAAC;IAEH,OAAO;QACL,KAAK,EAAE;YACL,QAAQ;YACR,GAAG,CAAC,UAAU,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,GAAG,CAA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UAAU,CAAC,QAAQ;QAC7B,OAAO,EAAE,UAAU,CAAC,OAAO;QAC3B,IAAI,EAAE,UAAU,CAAC,IAAI;QACrB,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC1D,CAAC;AACJ,CAAC;AAED,SAAS,qBAAqB,CAAC,KAAa;IAC1C,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAqB,CAAC;IAC/C,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;IAChE,CAAC;AACH,CAAC;AAED,SAAS,MAAM,CAAC,EACd,EAAE,EACF,UAAU,EACV,QAAQ,EACR,UAAU,EACV,YAAY,EACZ,WAAW,GAQZ;IACC,OAAO;QACL,EAAE;QACF,QAAQ;QACR,UAAU;QACV,IAAI,EAAE,UAAU,CAAC,IAAI,IAAI,WAAW;QACpC,IAAI,EAAE,UAAU,CAAC,IAAI,IAAI,UAAU,CAAC,IAAI;QACxC,IAAI,EAAE,UAAU,CAAC,IAAI;QACrB,YAAY;QACZ,QAAQ,EAAE,UAAU,CAAC,QAAQ;QAC7B,OAAO,EAAE,UAAU,CAAC,OAAO;QAC3B,IAAI,EAAE,UAAU,CAAC,IAAI;QACrB,QAAQ,EAAE,UAAU,CAAC,IAAI,IAAI,IAAI;KAClC,CAAC;AACJ,CAAC"}
|
|
@@ -4,14 +4,14 @@
|
|
|
4
4
|
* @license MIT
|
|
5
5
|
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
6
|
*/
|
|
7
|
-
import type { AttachmentOwner } from '
|
|
8
|
-
import { type LegacyAttachment, type
|
|
7
|
+
import type { AttachmentOwner } from '../../relations/attachment_owner.js';
|
|
8
|
+
import { type LegacyAttachment, type MigratedAttachmentRows } from './migrate_legacy_attachment.js';
|
|
9
9
|
export type LegacyAttachmentMigrationRecord = {
|
|
10
10
|
owner: AttachmentOwner;
|
|
11
11
|
value: LegacyAttachment | string | null | undefined;
|
|
12
12
|
};
|
|
13
13
|
export type LegacyAttachmentMigrationWriter = {
|
|
14
|
-
insert(rows:
|
|
14
|
+
insert(rows: MigratedAttachmentRows): Promise<void>;
|
|
15
15
|
};
|
|
16
16
|
export type MigrateLegacyAttachmentRecordsOptions = {
|
|
17
17
|
records: Iterable<LegacyAttachmentMigrationRecord> | AsyncIterable<LegacyAttachmentMigrationRecord>;
|
package/build/src/integrations/lucid/migrations/legacy/migrate_legacy_attachment_records.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrate_legacy_attachment_records.d.ts","sourceRoot":"","sources":["../../../../../../src/integrations/lucid/migrations/legacy/migrate_legacy_attachment_records.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAA;AAC1E,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,sBAAsB,EAC5B,MAAM,gCAAgC,CAAA;AAEvC,MAAM,MAAM,+BAA+B,GAAG;IAC5C,KAAK,EAAE,eAAe,CAAA;IACtB,KAAK,EAAE,gBAAgB,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;CACpD,CAAA;AAED,MAAM,MAAM,+BAA+B,GAAG;IAC5C,MAAM,CAAC,IAAI,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CACpD,CAAA;AAED,MAAM,MAAM,qCAAqC,GAAG;IAClD,OAAO,EAAE,QAAQ,CAAC,+BAA+B,CAAC,GAAG,aAAa,CAAC,+BAA+B,CAAC,CAAA;IACnG,WAAW,EAAE,MAAM,CAAA;IACnB,QAAQ,EAAE,MAAM,MAAM,CAAA;IACtB,MAAM,EAAE,+BAA+B,CAAA;IACvC,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,MAAM,MAAM,+BAA+B,GAAG;IAC5C,WAAW,EAAE,MAAM,CAAA;IACnB,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,MAAM,CAAA;CAChB,CAAA;AAED;;;;GAIG;AACH,wBAAsB,8BAA8B,CAClD,OAAO,EAAE,qCAAqC,GAC7C,OAAO,CAAC,+BAA+B,CAAC,CA0C1C"}
|
|
@@ -20,7 +20,7 @@ export async function migrateLegacyAttachmentRecords(options) {
|
|
|
20
20
|
variants: 0,
|
|
21
21
|
skipped: 0,
|
|
22
22
|
};
|
|
23
|
-
let batch = [];
|
|
23
|
+
let batch = { blobs: [], links: [] };
|
|
24
24
|
for await (const record of options.records) {
|
|
25
25
|
if (record.value === null || record.value === undefined) {
|
|
26
26
|
result.skipped += 1;
|
|
@@ -32,14 +32,15 @@ export async function migrateLegacyAttachmentRecords(options) {
|
|
|
32
32
|
createId: options.createId,
|
|
33
33
|
});
|
|
34
34
|
result.attachments += 1;
|
|
35
|
-
result.variants += rows.length - 1;
|
|
36
|
-
batch.push(...rows);
|
|
37
|
-
|
|
35
|
+
result.variants += rows.blobs.length - 1;
|
|
36
|
+
batch.blobs.push(...rows.blobs);
|
|
37
|
+
batch.links.push(...rows.links);
|
|
38
|
+
if (batch.blobs.length >= batchSize) {
|
|
38
39
|
await options.writer.insert(batch);
|
|
39
|
-
batch = [];
|
|
40
|
+
batch = { blobs: [], links: [] };
|
|
40
41
|
}
|
|
41
42
|
}
|
|
42
|
-
if (batch.length > 0) {
|
|
43
|
+
if (batch.blobs.length > 0) {
|
|
43
44
|
await options.writer.insert(batch);
|
|
44
45
|
}
|
|
45
46
|
return result;
|
package/build/src/integrations/lucid/migrations/legacy/migrate_legacy_attachment_records.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrate_legacy_attachment_records.js","sourceRoot":"","sources":["../../../../../../src/integrations/lucid/migrations/legacy/migrate_legacy_attachment_records.ts"],"names":[],"mappings":"AAAA;;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,CAAA;QAE/B,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM,IAAI,SAAS,EAAE,CAAC;YACpC,MAAM,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;YAClC,KAAK,GAAG,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,CAAA;QAClC,CAAC;IACH,CAAC;IAED,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC3B,MAAM,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;IACpC,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jrmc/adonis-attachment
|
|
3
|
+
*
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
+
*/
|
|
7
|
+
import { BaseModel } from '@adonisjs/lucid/orm';
|
|
8
|
+
import type { BelongsTo } from '@adonisjs/lucid/types/relations';
|
|
9
|
+
import type { DateTime } from 'luxon';
|
|
10
|
+
import type { Attachment } from '../../../core/attachment.js';
|
|
11
|
+
import { AttachmentModel } from './attachment_model.js';
|
|
12
|
+
/**
|
|
13
|
+
* Polymorphic relation between an application record and an attachment blob.
|
|
14
|
+
*/
|
|
15
|
+
export declare class AttachmentLinkModel extends BaseModel {
|
|
16
|
+
static table: string;
|
|
17
|
+
static selfAssignPrimaryKey: boolean;
|
|
18
|
+
id: string;
|
|
19
|
+
attachableType: string;
|
|
20
|
+
attachableId: string;
|
|
21
|
+
field: string;
|
|
22
|
+
ownerKey: string | null;
|
|
23
|
+
position: number | null;
|
|
24
|
+
attachmentId: string;
|
|
25
|
+
attachment: BelongsTo<typeof AttachmentModel>;
|
|
26
|
+
createdAt: DateTime;
|
|
27
|
+
updatedAt: DateTime;
|
|
28
|
+
toAttachment(): Attachment;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=attachment_link_model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachment_link_model.d.ts","sourceRoot":"","sources":["../../../../../src/integrations/lucid/models/attachment_link_model.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,SAAS,EAAqB,MAAM,qBAAqB,CAAA;AAClE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAA;AAChE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAErC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAA;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAEvD;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,SAAS;IAChD,MAAM,CAAC,KAAK,SAAqB;IACjC,MAAM,CAAC,oBAAoB,UAAO;IAG1B,EAAE,EAAE,MAAM,CAAA;IAGV,cAAc,EAAE,MAAM,CAAA;IAGtB,YAAY,EAAE,MAAM,CAAA;IAGpB,KAAK,EAAE,MAAM,CAAA;IAGb,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;IAGvB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;IAGvB,YAAY,EAAE,MAAM,CAAA;IAGpB,UAAU,EAAE,SAAS,CAAC,OAAO,eAAe,CAAC,CAAA;IAG7C,SAAS,EAAE,QAAQ,CAAA;IAGnB,SAAS,EAAE,QAAQ,CAAA;IAE3B,YAAY,IAAI,UAAU;CAO3B"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jrmc/adonis-attachment
|
|
3
|
+
*
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
+
*/
|
|
7
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
8
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
10
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
11
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
12
|
+
};
|
|
13
|
+
import { BaseModel, belongsTo, column } from '@adonisjs/lucid/orm';
|
|
14
|
+
import { AttachmentModel } from './attachment_model.js';
|
|
15
|
+
/**
|
|
16
|
+
* Polymorphic relation between an application record and an attachment blob.
|
|
17
|
+
*/
|
|
18
|
+
export class AttachmentLinkModel extends BaseModel {
|
|
19
|
+
static table = 'attachment_links';
|
|
20
|
+
static selfAssignPrimaryKey = true;
|
|
21
|
+
toAttachment() {
|
|
22
|
+
if (!this.attachment) {
|
|
23
|
+
throw new Error('Attachment links must load their attachment blob before they can be read');
|
|
24
|
+
}
|
|
25
|
+
return this.attachment.toAttachment();
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
__decorate([
|
|
29
|
+
column({ isPrimary: true })
|
|
30
|
+
], AttachmentLinkModel.prototype, "id", void 0);
|
|
31
|
+
__decorate([
|
|
32
|
+
column()
|
|
33
|
+
], AttachmentLinkModel.prototype, "attachableType", void 0);
|
|
34
|
+
__decorate([
|
|
35
|
+
column()
|
|
36
|
+
], AttachmentLinkModel.prototype, "attachableId", void 0);
|
|
37
|
+
__decorate([
|
|
38
|
+
column()
|
|
39
|
+
], AttachmentLinkModel.prototype, "field", void 0);
|
|
40
|
+
__decorate([
|
|
41
|
+
column({ serializeAs: null })
|
|
42
|
+
], AttachmentLinkModel.prototype, "ownerKey", void 0);
|
|
43
|
+
__decorate([
|
|
44
|
+
column()
|
|
45
|
+
], AttachmentLinkModel.prototype, "position", void 0);
|
|
46
|
+
__decorate([
|
|
47
|
+
column()
|
|
48
|
+
], AttachmentLinkModel.prototype, "attachmentId", void 0);
|
|
49
|
+
__decorate([
|
|
50
|
+
belongsTo(() => AttachmentModel, { foreignKey: 'attachmentId' })
|
|
51
|
+
], AttachmentLinkModel.prototype, "attachment", void 0);
|
|
52
|
+
__decorate([
|
|
53
|
+
column.dateTime({ autoCreate: true })
|
|
54
|
+
], AttachmentLinkModel.prototype, "createdAt", void 0);
|
|
55
|
+
__decorate([
|
|
56
|
+
column.dateTime({ autoCreate: true, autoUpdate: true })
|
|
57
|
+
], AttachmentLinkModel.prototype, "updatedAt", void 0);
|
|
58
|
+
//# sourceMappingURL=attachment_link_model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachment_link_model.js","sourceRoot":"","sources":["../../../../../src/integrations/lucid/models/attachment_link_model.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;;;;;;;AAEH,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAKlE,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAEvD;;GAEG;AACH,MAAM,OAAO,mBAAoB,SAAQ,SAAS;IAChD,MAAM,CAAC,KAAK,GAAG,kBAAkB,CAAA;IACjC,MAAM,CAAC,oBAAoB,GAAG,IAAI,CAAA;IAgClC,YAAY;QACV,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;YACrB,MAAM,IAAI,KAAK,CAAC,0EAA0E,CAAC,CAAA;QAC7F,CAAC;QAED,OAAO,IAAI,CAAC,UAAU,CAAC,YAAY,EAAE,CAAA;IACvC,CAAC;;AAnCO;IADP,MAAM,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;+CACV;AAGV;IADP,MAAM,EAAE;2DACqB;AAGtB;IADP,MAAM,EAAE;yDACmB;AAGpB;IADP,MAAM,EAAE;kDACY;AAGb;IADP,MAAM,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;qDACC;AAGvB;IADP,MAAM,EAAE;qDACsB;AAGvB;IADP,MAAM,EAAE;yDACmB;AAGpB;IADP,SAAS,CAAC,GAAG,EAAE,CAAC,eAAe,EAAE,EAAE,UAAU,EAAE,cAAc,EAAE,CAAC;uDACZ;AAG7C;IADP,MAAM,CAAC,QAAQ,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;sDACX;AAGnB;IADP,MAAM,CAAC,QAAQ,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;sDAC7B"}
|
|
@@ -6,20 +6,15 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { BaseModel } from '@adonisjs/lucid/orm';
|
|
8
8
|
import type { DateTime } from 'luxon';
|
|
9
|
-
import type { Attachment } from '
|
|
9
|
+
import type { Attachment } from '../../../core/attachment.js';
|
|
10
10
|
/**
|
|
11
|
-
* Default Lucid model for
|
|
11
|
+
* Default Lucid model for a stored attachment blob.
|
|
12
12
|
* Applications may extend this model to add their own scopes and serialization rules.
|
|
13
13
|
*/
|
|
14
14
|
export declare class AttachmentModel extends BaseModel {
|
|
15
15
|
static table: string;
|
|
16
16
|
static selfAssignPrimaryKey: boolean;
|
|
17
17
|
id: string;
|
|
18
|
-
attachableType: string;
|
|
19
|
-
attachableId: string;
|
|
20
|
-
field: string;
|
|
21
|
-
ownerKey: string | null;
|
|
22
|
-
position: number | null;
|
|
23
18
|
parentId: string | null;
|
|
24
19
|
variantKey: string | null;
|
|
25
20
|
disk: string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachment_model.d.ts","sourceRoot":"","sources":["../../../../../src/integrations/lucid/models/attachment_model.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,SAAS,EAAU,MAAM,qBAAqB,CAAA;AACvD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAErC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAA;AAE7D;;;GAGG;AACH,qBAAa,eAAgB,SAAQ,SAAS;IAC5C,MAAM,CAAC,KAAK,SAAgB;IAC5B,MAAM,CAAC,oBAAoB,UAAO;IAG1B,EAAE,EAAE,MAAM,CAAA;IAGV,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;IAGvB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;IAGzB,IAAI,EAAE,MAAM,CAAA;IAGZ,IAAI,EAAE,MAAM,CAAA;IAGZ,IAAI,EAAE,MAAM,CAAA;IAGZ,YAAY,EAAE,MAAM,CAAA;IAGpB,QAAQ,EAAE,MAAM,CAAA;IAGhB,OAAO,EAAE,MAAM,CAAA;IAGf,IAAI,EAAE,MAAM,CAAA;IAcZ,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAA;IAGxC,SAAS,EAAE,QAAQ,CAAA;IAGnB,SAAS,EAAE,QAAQ,CAAA;IAE3B,YAAY,IAAI,UAAU;CAa3B"}
|
|
@@ -12,7 +12,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
12
12
|
};
|
|
13
13
|
import { BaseModel, column } from '@adonisjs/lucid/orm';
|
|
14
14
|
/**
|
|
15
|
-
* Default Lucid model for
|
|
15
|
+
* Default Lucid model for a stored attachment blob.
|
|
16
16
|
* Applications may extend this model to add their own scopes and serialization rules.
|
|
17
17
|
*/
|
|
18
18
|
export class AttachmentModel extends BaseModel {
|
|
@@ -35,21 +35,6 @@ export class AttachmentModel extends BaseModel {
|
|
|
35
35
|
__decorate([
|
|
36
36
|
column({ isPrimary: true })
|
|
37
37
|
], AttachmentModel.prototype, "id", void 0);
|
|
38
|
-
__decorate([
|
|
39
|
-
column()
|
|
40
|
-
], AttachmentModel.prototype, "attachableType", void 0);
|
|
41
|
-
__decorate([
|
|
42
|
-
column()
|
|
43
|
-
], AttachmentModel.prototype, "attachableId", void 0);
|
|
44
|
-
__decorate([
|
|
45
|
-
column()
|
|
46
|
-
], AttachmentModel.prototype, "field", void 0);
|
|
47
|
-
__decorate([
|
|
48
|
-
column({ serializeAs: null })
|
|
49
|
-
], AttachmentModel.prototype, "ownerKey", void 0);
|
|
50
|
-
__decorate([
|
|
51
|
-
column()
|
|
52
|
-
], AttachmentModel.prototype, "position", void 0);
|
|
53
38
|
__decorate([
|
|
54
39
|
column()
|
|
55
40
|
], AttachmentModel.prototype, "parentId", void 0);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachment_model.js","sourceRoot":"","sources":["../../../../../src/integrations/lucid/models/attachment_model.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;;;;;;;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAKvD;;;GAGG;AACH,MAAM,OAAO,eAAgB,SAAQ,SAAS;IAC5C,MAAM,CAAC,KAAK,GAAG,aAAa,CAAA;IAC5B,MAAM,CAAC,oBAAoB,GAAG,IAAI,CAAA;IAoDlC,YAAY;QACV,OAAO;YACL,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SACtD,CAAA;IACH,CAAC;;AA7DO;IADP,MAAM,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;2CACV;AAGV;IADP,MAAM,EAAE;iDACsB;AAGvB;IADP,MAAM,EAAE;mDACwB;AAGzB;IADP,MAAM,EAAE;6CACW;AAGZ;IADP,MAAM,EAAE;6CACW;AAGZ;IADP,MAAM,EAAE;6CACW;AAGZ;IADP,MAAM,EAAE;qDACmB;AAGpB;IADP,MAAM,EAAE;iDACe;AAGhB;IADP,MAAM,EAAE;gDACc;AAGf;IADP,MAAM,EAAE;6CACW;AAcZ;IAZP,MAAM,CAAC;QACN,OAAO,CAAC,KAAqC;YAC3C,OAAO,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAA;QACtD,CAAC;QACD,OAAO,CAAC,KAAc;YACpB,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;gBACvE,OAAO,KAAuC,CAAA;YAChD,CAAC;YAED,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAA4B,CAAA;QACrD,CAAC;KACF,CAAC;iDAC8C;AAGxC;IADP,MAAM,CAAC,QAAQ,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;kDACX;AAGnB;IADP,MAAM,CAAC,QAAQ,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;kDAC7B"}
|
|
@@ -4,27 +4,31 @@
|
|
|
4
4
|
* @license MIT
|
|
5
5
|
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
6
|
*/
|
|
7
|
-
import { type AttachmentDraft, type CreateAttachmentInput } from '
|
|
8
|
-
import type { AttachmentService } from '
|
|
9
|
-
import type { AttachmentPersistenceOptions } from '
|
|
10
|
-
import type { AttachmentOwner } from '
|
|
11
|
-
import {
|
|
7
|
+
import { type AttachmentDraft, type CreateAttachmentInput } from '../../../core/attachment.js';
|
|
8
|
+
import type { AttachmentService } from '../../../core/attachment_service.js';
|
|
9
|
+
import type { AttachmentPersistenceOptions } from '../../../core/attachment_options.js';
|
|
10
|
+
import type { AttachmentOwner } from '../relations/attachment_owner.js';
|
|
11
|
+
import { AttachmentLinkModel } from '../models/attachment_link_model.js';
|
|
12
|
+
import { AttachmentModel } from '../models/attachment_model.js';
|
|
12
13
|
import { LucidAttachmentStore } from './lucid_attachment_store.js';
|
|
13
14
|
export type AttachmentFileService = Pick<AttachmentService, 'create' | 'remove'> & Partial<Pick<AttachmentService, 'createDraft'>>;
|
|
14
|
-
export type LucidAttachmentPersistence = Pick<LucidAttachmentStore, 'createOriginal' | 'findOriginal' | 'listVariants' | 'releaseOwner' | 'restoreOwner' | 'remove'> & Partial<Pick<LucidAttachmentStore, 'createCollectionItem' | 'findCollectionItem' | 'listCollection' | 'moveCollectionItem' | 'removeCollectionItem'>>;
|
|
15
|
+
export type LucidAttachmentPersistence = Pick<LucidAttachmentStore, 'createOriginal' | 'findOriginal' | 'listVariants' | 'releaseOwner' | 'restoreOwner' | 'remove' | 'listOwnerLinks'> & Partial<Pick<LucidAttachmentStore, 'createCollectionItem' | 'findCollectionItem' | 'listCollection' | 'moveCollectionItem' | 'removeCollectionItem' | 'createOriginalLink' | 'createCollectionLink'>>;
|
|
15
16
|
export declare class LucidAttachmentLifecycleService {
|
|
16
17
|
#private;
|
|
17
18
|
constructor(attachments: AttachmentFileService, store: LucidAttachmentPersistence);
|
|
18
|
-
get(owner: AttachmentOwner): Promise<
|
|
19
|
-
attach(owner: AttachmentOwner, input: CreateAttachmentInput | AttachmentDraft, options?: AttachmentPersistenceOptions<any>): Promise<
|
|
20
|
-
replace(owner: AttachmentOwner, input: CreateAttachmentInput | AttachmentDraft, options?: AttachmentPersistenceOptions<any>): Promise<
|
|
19
|
+
get(owner: AttachmentOwner): Promise<AttachmentLinkModel | null>;
|
|
20
|
+
attach(owner: AttachmentOwner, input: CreateAttachmentInput | AttachmentDraft, options?: AttachmentPersistenceOptions<any>): Promise<AttachmentLinkModel>;
|
|
21
|
+
replace(owner: AttachmentOwner, input: CreateAttachmentInput | AttachmentDraft, options?: AttachmentPersistenceOptions<any>): Promise<AttachmentLinkModel>;
|
|
21
22
|
detach(owner: AttachmentOwner): Promise<void>;
|
|
22
23
|
listVariants(owner: AttachmentOwner): Promise<AttachmentModel[]>;
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
purgeOwner(owner: AttachmentOwner): Promise<void>;
|
|
25
|
+
add(owner: AttachmentOwner, input: CreateAttachmentInput | AttachmentDraft, position?: number, options?: AttachmentPersistenceOptions<any>): Promise<AttachmentLinkModel>;
|
|
26
|
+
attachExisting(owner: AttachmentOwner, attachmentId: string): Promise<AttachmentLinkModel>;
|
|
27
|
+
addExisting(owner: AttachmentOwner, attachmentId: string, position?: number): Promise<AttachmentLinkModel>;
|
|
28
|
+
listCollection(owner: AttachmentOwner): Promise<AttachmentLinkModel[]>;
|
|
25
29
|
removeCollectionItem(owner: AttachmentOwner, id: string): Promise<boolean>;
|
|
26
30
|
clearCollection(owner: AttachmentOwner): Promise<void>;
|
|
27
|
-
replaceCollection(owner: AttachmentOwner, inputs: readonly (CreateAttachmentInput | AttachmentDraft)[], options?: AttachmentPersistenceOptions<any>): Promise<
|
|
28
|
-
moveCollectionItem(owner: AttachmentOwner, id: string, position: number): Promise<
|
|
31
|
+
replaceCollection(owner: AttachmentOwner, inputs: readonly (CreateAttachmentInput | AttachmentDraft)[], options?: AttachmentPersistenceOptions<any>): Promise<AttachmentLinkModel[]>;
|
|
32
|
+
moveCollectionItem(owner: AttachmentOwner, id: string, position: number): Promise<AttachmentLinkModel[]>;
|
|
29
33
|
}
|
|
30
34
|
//# sourceMappingURL=lucid_attachment_lifecycle_service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lucid_attachment_lifecycle_service.d.ts","sourceRoot":"","sources":["../../../../../src/integrations/lucid/persistence/lucid_attachment_lifecycle_service.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAGL,KAAK,eAAe,EACpB,KAAK,qBAAqB,EAC3B,MAAM,6BAA6B,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 -4,7 +4,7 @@
|
|
|
4
4
|
* @license MIT
|
|
5
5
|
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
6
|
*/
|
|
7
|
-
import { isAttachmentDraft, } from '
|
|
7
|
+
import { isAttachmentDraft, } from '../../../core/attachment.js';
|
|
8
8
|
export class LucidAttachmentLifecycleService {
|
|
9
9
|
#attachments;
|
|
10
10
|
#store;
|
|
@@ -32,7 +32,6 @@ export class LucidAttachmentLifecycleService {
|
|
|
32
32
|
if (!previous) {
|
|
33
33
|
return this.attach(owner, input, options);
|
|
34
34
|
}
|
|
35
|
-
const previousVariants = await this.#store.listVariants(previous.id);
|
|
36
35
|
const attachment = await this.#persist(owner, input, options);
|
|
37
36
|
let current;
|
|
38
37
|
try {
|
|
@@ -45,7 +44,8 @@ export class LucidAttachmentLifecycleService {
|
|
|
45
44
|
throw error;
|
|
46
45
|
}
|
|
47
46
|
try {
|
|
48
|
-
await this.#store.remove(previous);
|
|
47
|
+
const removed = await this.#store.remove(previous);
|
|
48
|
+
await this.#removeOnCommit(owner, removed.map((item) => item.toAttachment()));
|
|
49
49
|
}
|
|
50
50
|
catch (error) {
|
|
51
51
|
await this.#store.remove(current).catch(() => undefined);
|
|
@@ -53,10 +53,6 @@ export class LucidAttachmentLifecycleService {
|
|
|
53
53
|
await this.#removeStoredFile(current.toAttachment());
|
|
54
54
|
throw error;
|
|
55
55
|
}
|
|
56
|
-
await this.#removeOnCommit(owner, [
|
|
57
|
-
previous.toAttachment(),
|
|
58
|
-
...previousVariants.map((variant) => variant.toAttachment()),
|
|
59
|
-
]);
|
|
60
56
|
this.#removeOnRollback(owner, [current.toAttachment()]);
|
|
61
57
|
return current;
|
|
62
58
|
}
|
|
@@ -65,16 +61,18 @@ export class LucidAttachmentLifecycleService {
|
|
|
65
61
|
if (!original) {
|
|
66
62
|
return;
|
|
67
63
|
}
|
|
68
|
-
const
|
|
69
|
-
await this.#
|
|
70
|
-
await this.#removeOnCommit(owner, [
|
|
71
|
-
original.toAttachment(),
|
|
72
|
-
...variants.map((variant) => variant.toAttachment()),
|
|
73
|
-
]);
|
|
64
|
+
const removed = await this.#store.remove(original);
|
|
65
|
+
await this.#removeOnCommit(owner, removed.map((item) => item.toAttachment()));
|
|
74
66
|
}
|
|
75
67
|
async listVariants(owner) {
|
|
76
68
|
const original = await this.#store.findOriginal(owner);
|
|
77
|
-
return original ? this.#store.listVariants(original.
|
|
69
|
+
return original ? this.#store.listVariants(original.attachmentId) : [];
|
|
70
|
+
}
|
|
71
|
+
async purgeOwner(owner) {
|
|
72
|
+
for (const link of await this.#store.listOwnerLinks(owner)) {
|
|
73
|
+
const removed = await this.#store.remove(link);
|
|
74
|
+
await this.#removeOnCommit(owner, removed.map((attachment) => attachment.toAttachment()));
|
|
75
|
+
}
|
|
78
76
|
}
|
|
79
77
|
async add(owner, input, position, options) {
|
|
80
78
|
const attachment = await this.#persist(owner, input, options);
|
|
@@ -88,6 +86,12 @@ export class LucidAttachmentLifecycleService {
|
|
|
88
86
|
throw error;
|
|
89
87
|
}
|
|
90
88
|
}
|
|
89
|
+
attachExisting(owner, attachmentId) {
|
|
90
|
+
return this.#linkStore().createOriginalLink(owner, attachmentId);
|
|
91
|
+
}
|
|
92
|
+
addExisting(owner, attachmentId, position) {
|
|
93
|
+
return this.#linkStore().createCollectionLink(owner, attachmentId, position);
|
|
94
|
+
}
|
|
91
95
|
listCollection(owner) {
|
|
92
96
|
return this.#collectionStore().listCollection(owner);
|
|
93
97
|
}
|
|
@@ -145,12 +149,8 @@ export class LucidAttachmentLifecycleService {
|
|
|
145
149
|
return Promise.all(attachments.map((attachment) => this.#removeStoredFile(attachment))).then(() => undefined);
|
|
146
150
|
}
|
|
147
151
|
async #detachCollectionItem(owner, item) {
|
|
148
|
-
const
|
|
149
|
-
await this.#
|
|
150
|
-
await this.#removeOnCommit(owner, [
|
|
151
|
-
item.toAttachment(),
|
|
152
|
-
...variants.map((variant) => variant.toAttachment()),
|
|
153
|
-
]);
|
|
152
|
+
const removed = await this.#collectionStore().removeCollectionItem(owner, item);
|
|
153
|
+
await this.#removeOnCommit(owner, removed.map((attachment) => attachment.toAttachment()));
|
|
154
154
|
}
|
|
155
155
|
#collectionStore() {
|
|
156
156
|
const store = this.#store;
|
|
@@ -163,6 +163,13 @@ export class LucidAttachmentLifecycleService {
|
|
|
163
163
|
}
|
|
164
164
|
return store;
|
|
165
165
|
}
|
|
166
|
+
#linkStore() {
|
|
167
|
+
const store = this.#store;
|
|
168
|
+
if (!store.createOriginalLink || !store.createCollectionLink) {
|
|
169
|
+
throw new Error('Lucid attachment link operations require a link-capable store');
|
|
170
|
+
}
|
|
171
|
+
return store;
|
|
172
|
+
}
|
|
166
173
|
async #persist(owner, input, options) {
|
|
167
174
|
if (isAttachmentDraft(input)) {
|
|
168
175
|
return input.persist({
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lucid_attachment_lifecycle_service.js","sourceRoot":"","sources":["../../../../../src/integrations/lucid/persistence/lucid_attachment_lifecycle_service.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,iBAAiB,GAIlB,MAAM,6BAA6B,CAAA;AAiCpC,MAAM,OAAO,+BAA+B;IACjC,YAAY,CAAuB;IACnC,MAAM,CAA4B;IAE3C,YAAY,WAAkC,EAAE,KAAiC;QAC/E,IAAI,CAAC,YAAY,GAAG,WAAW,CAAA;QAC/B,IAAI,CAAC,MAAM,GAAG,KAAK,CAAA;IACrB,CAAC;IAED,GAAG,CAAC,KAAsB;QACxB,OAAO,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,CAAA;IACxC,CAAC;IAED,KAAK,CAAC,MAAM,CACV,KAAsB,EACtB,KAA8C,EAC9C,OAA2C;QAE3C,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,CAAC,CAAA;QAE7D,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,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,QAAQ,CACZ,KAAsB,EACtB,KAA8C,EAC9C,OAA2C;QAE3C,IAAI,iBAAiB,CAAC,KAAK,CAAC,EAAE,CAAC;YAC7B,OAAO,KAAK,CAAC,OAAO,CAAC;gBACnB,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC/B,OAAO,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE;aACpD,CAAC,CAAA;QACJ,CAAC;QAED,IAAI,IAAI,CAAC,YAAY,CAAC,WAAW,EAAE,CAAC;YAClC,OAAO,IAAI,CAAC,YAAY;iBACrB,WAAW,CAAC,KAAK,CAAC;iBAClB,OAAO,CAAC;gBACP,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC/B,OAAO,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE;aACpD,CAAC,CAAA;QACN,CAAC;QAED,OAAO,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;IACxC,CAAC;CACF;AAED,SAAS,mBAAmB,CAAC,KAAsB;IAGjD,MAAM,KAAK,GAAG,KAAK,CAAC,KAMP,CAAA;IAEb,OAAO,KAAK,EAAE,IAAI,IAAI,IAAI,CAAA;AAC5B,CAAC"}
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
* @license MIT
|
|
5
5
|
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
6
|
*/
|
|
7
|
-
import type { Attachment } from '
|
|
8
|
-
import type { AttachmentRepository } from '
|
|
9
|
-
import { AttachmentModel } from '
|
|
7
|
+
import type { Attachment } from '../../../core/attachment.js';
|
|
8
|
+
import type { AttachmentRepository } from '../../../core/attachment_repository.js';
|
|
9
|
+
import { AttachmentModel } from '../models/attachment_model.js';
|
|
10
10
|
/**
|
|
11
11
|
* Attachment repository used by workers when attachments are persisted by Lucid.
|
|
12
12
|
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lucid_attachment_repository.d.ts","sourceRoot":"","sources":["../../../../../src/integrations/lucid/persistence/lucid_attachment_repository.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAA;AAC7D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wCAAwC,CAAA;AAClF,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAE/D;;GAEG;AACH,qBAAa,yBAA0B,YAAW,oBAAoB;;gBAGxD,KAAK,GAAE,OAAO,eAAiC;IAIrD,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;CAKvD"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @license MIT
|
|
5
5
|
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
6
|
*/
|
|
7
|
-
import { AttachmentModel } from '
|
|
7
|
+
import { AttachmentModel } from '../models/attachment_model.js';
|
|
8
8
|
/**
|
|
9
9
|
* Attachment repository used by workers when attachments are persisted by Lucid.
|
|
10
10
|
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lucid_attachment_repository.js","sourceRoot":"","sources":["../../../../../src/integrations/lucid/persistence/lucid_attachment_repository.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAE/D;;GAEG;AACH,MAAM,OAAO,yBAAyB;IAC3B,MAAM,CAAwB;IAEvC,YAAY,QAAgC,eAAe;QACzD,IAAI,CAAC,MAAM,GAAG,KAAK,CAAA;IACrB,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,EAAU;QACvB,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;QAEtC,OAAO,GAAG,EAAE,YAAY,EAAE,IAAI,IAAI,CAAA;IACpC,CAAC;CACF"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jrmc/adonis-attachment
|
|
3
|
+
*
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
|
+
*/
|
|
7
|
+
import type { TransactionClientContract } from '@adonisjs/lucid/types/database';
|
|
8
|
+
import type { Attachment } from '../../../core/attachment.js';
|
|
9
|
+
import { type AttachmentOwner } from '../relations/attachment_owner.js';
|
|
10
|
+
import { AttachmentLinkModel } from '../models/attachment_link_model.js';
|
|
11
|
+
import { AttachmentModel } from '../models/attachment_model.js';
|
|
12
|
+
export type LucidAttachmentWithVariants = {
|
|
13
|
+
original: AttachmentLinkModel;
|
|
14
|
+
variants: AttachmentModel[];
|
|
15
|
+
};
|
|
16
|
+
export type LucidAttachmentStoreOptions = {
|
|
17
|
+
client?: TransactionClientContract;
|
|
18
|
+
linkModel?: typeof AttachmentLinkModel;
|
|
19
|
+
createLinkId?: () => string;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Persists immutable file blobs separately from their polymorphic owner links.
|
|
23
|
+
*/
|
|
24
|
+
export declare class LucidAttachmentStore {
|
|
25
|
+
#private;
|
|
26
|
+
constructor(blobModel?: typeof AttachmentModel, options?: LucidAttachmentStoreOptions);
|
|
27
|
+
createOriginal(owner: AttachmentOwner, attachment: Attachment): Promise<AttachmentLinkModel>;
|
|
28
|
+
createCollectionItem(owner: AttachmentOwner, attachment: Attachment, position?: number): Promise<AttachmentLinkModel>;
|
|
29
|
+
createOriginalLink(owner: AttachmentOwner, attachmentId: string): Promise<AttachmentLinkModel>;
|
|
30
|
+
createCollectionLink(owner: AttachmentOwner, attachmentId: string, position?: number): Promise<AttachmentLinkModel>;
|
|
31
|
+
createVariant(original: AttachmentModel, key: string, attachment: Attachment): Promise<AttachmentModel>;
|
|
32
|
+
releaseOwner(original: AttachmentLinkModel): Promise<void>;
|
|
33
|
+
restoreOwner(original: AttachmentLinkModel): Promise<void>;
|
|
34
|
+
findOriginal(owner: AttachmentOwner): Promise<AttachmentLinkModel | null>;
|
|
35
|
+
listCollection(owner: AttachmentOwner): Promise<AttachmentLinkModel[]>;
|
|
36
|
+
findCollectionItem(owner: AttachmentOwner, id: string): Promise<AttachmentLinkModel | null>;
|
|
37
|
+
removeCollectionItem(owner: AttachmentOwner, item: AttachmentLinkModel): Promise<AttachmentModel[]>;
|
|
38
|
+
moveCollectionItem(owner: AttachmentOwner, id: string, position: number): Promise<AttachmentLinkModel[]>;
|
|
39
|
+
findById(id: string): Promise<AttachmentModel | null>;
|
|
40
|
+
findByOwner(owner: AttachmentOwner): Promise<LucidAttachmentWithVariants | null>;
|
|
41
|
+
listVariants(originalId: string): Promise<AttachmentModel[]>;
|
|
42
|
+
/**
|
|
43
|
+
* Deletes a link and returns blobs that became unreferenced and were removed.
|
|
44
|
+
*/
|
|
45
|
+
remove(link: AttachmentLinkModel): Promise<AttachmentModel[]>;
|
|
46
|
+
listOwnerLinks(owner: AttachmentOwner): Promise<AttachmentLinkModel[]>;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=lucid_attachment_store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lucid_attachment_store.d.ts","sourceRoot":"","sources":["../../../../../src/integrations/lucid/persistence/lucid_attachment_store.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAA;AAE/E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAA;AAE7D,OAAO,EAA4B,KAAK,eAAe,EAAE,MAAM,kCAAkC,CAAA;AACjG,OAAO,EAAE,m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