@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.
Files changed (199) hide show
  1. package/build/commands/make/attachment_v5_migration.d.ts.map +1 -1
  2. package/build/commands/make/attachment_v5_migration.js +6 -3
  3. package/build/commands/make/attachment_v5_migration.js.map +1 -1
  4. package/build/commands/make/attachments_table.d.ts.map +1 -1
  5. package/build/commands/make/attachments_table.js +8 -2
  6. package/build/commands/make/attachments_table.js.map +1 -1
  7. package/build/index.d.ts +23 -22
  8. package/build/index.d.ts.map +1 -1
  9. package/build/index.js +15 -14
  10. package/build/index.js.map +1 -1
  11. package/build/providers/attachment_provider.d.ts.map +1 -1
  12. package/build/providers/attachment_provider.js +16 -0
  13. package/build/providers/attachment_provider.js.map +1 -1
  14. package/build/src/core/attachment.d.ts +37 -2
  15. package/build/src/core/attachment.d.ts.map +1 -1
  16. package/build/src/core/attachment.js +108 -5
  17. package/build/src/core/attachment.js.map +1 -1
  18. package/build/src/core/attachment_options.d.ts +32 -0
  19. package/build/src/core/attachment_options.d.ts.map +1 -0
  20. package/build/src/core/attachment_options.js +24 -0
  21. package/build/src/core/attachment_options.js.map +1 -0
  22. package/build/src/core/attachment_service.d.ts +7 -1
  23. package/build/src/core/attachment_service.d.ts.map +1 -1
  24. package/build/src/core/attachment_service.js +50 -4
  25. package/build/src/core/attachment_service.js.map +1 -1
  26. package/build/src/core/index.d.ts +2 -1
  27. package/build/src/core/index.d.ts.map +1 -1
  28. package/build/src/core/index.js +2 -1
  29. package/build/src/core/index.js.map +1 -1
  30. package/build/src/define_config.d.ts +17 -0
  31. package/build/src/define_config.d.ts.map +1 -1
  32. package/build/src/define_config.js +9 -0
  33. package/build/src/define_config.js.map +1 -1
  34. package/build/src/integrations/lucid/column/attachment_column.d.ts +18 -0
  35. package/build/src/integrations/lucid/column/attachment_column.d.ts.map +1 -0
  36. package/build/src/integrations/lucid/{attachment_column.js → column/attachment_column.js} +26 -13
  37. package/build/src/integrations/lucid/column/attachment_column.js.map +1 -0
  38. package/build/src/integrations/lucid/index.d.ts +16 -12
  39. package/build/src/integrations/lucid/index.d.ts.map +1 -1
  40. package/build/src/integrations/lucid/index.js +16 -12
  41. package/build/src/integrations/lucid/index.js.map +1 -1
  42. package/build/src/integrations/lucid/migrations/legacy/legacy_attachment_migration_stub.d.ts +20 -0
  43. package/build/src/integrations/lucid/migrations/legacy/legacy_attachment_migration_stub.d.ts.map +1 -0
  44. package/build/src/integrations/lucid/migrations/legacy/legacy_attachment_migration_stub.js +18 -0
  45. package/build/src/integrations/lucid/migrations/legacy/legacy_attachment_migration_stub.js.map +1 -0
  46. package/build/src/integrations/lucid/{migrate_legacy_attachment.d.ts → migrations/legacy/migrate_legacy_attachment.d.ts} +25 -9
  47. package/build/src/integrations/lucid/migrations/legacy/migrate_legacy_attachment.d.ts.map +1 -0
  48. package/build/src/integrations/lucid/migrations/legacy/migrate_legacy_attachment.js +94 -0
  49. package/build/src/integrations/lucid/migrations/legacy/migrate_legacy_attachment.js.map +1 -0
  50. package/build/src/integrations/lucid/{migrate_legacy_attachment_records.d.ts → migrations/legacy/migrate_legacy_attachment_records.d.ts} +3 -3
  51. package/build/src/integrations/lucid/migrations/legacy/migrate_legacy_attachment_records.d.ts.map +1 -0
  52. package/build/src/integrations/lucid/{migrate_legacy_attachment_records.js → migrations/legacy/migrate_legacy_attachment_records.js} +7 -6
  53. package/build/src/integrations/lucid/migrations/legacy/migrate_legacy_attachment_records.js.map +1 -0
  54. package/build/src/integrations/lucid/models/attachment_link_model.d.ts +30 -0
  55. package/build/src/integrations/lucid/models/attachment_link_model.d.ts.map +1 -0
  56. package/build/src/integrations/lucid/models/attachment_link_model.js +58 -0
  57. package/build/src/integrations/lucid/models/attachment_link_model.js.map +1 -0
  58. package/build/src/integrations/lucid/{attachment_model.d.ts → models/attachment_model.d.ts} +2 -6
  59. package/build/src/integrations/lucid/models/attachment_model.d.ts.map +1 -0
  60. package/build/src/integrations/lucid/{attachment_model.js → models/attachment_model.js} +1 -13
  61. package/build/src/integrations/lucid/models/attachment_model.js.map +1 -0
  62. package/build/src/integrations/lucid/persistence/lucid_attachment_lifecycle_service.d.ts +34 -0
  63. package/build/src/integrations/lucid/persistence/lucid_attachment_lifecycle_service.d.ts.map +1 -0
  64. package/build/src/integrations/lucid/persistence/lucid_attachment_lifecycle_service.js +195 -0
  65. package/build/src/integrations/lucid/persistence/lucid_attachment_lifecycle_service.js.map +1 -0
  66. package/build/src/integrations/lucid/{lucid_attachment_repository.d.ts → persistence/lucid_attachment_repository.d.ts} +3 -3
  67. package/build/src/integrations/lucid/persistence/lucid_attachment_repository.d.ts.map +1 -0
  68. package/build/src/integrations/lucid/{lucid_attachment_repository.js → persistence/lucid_attachment_repository.js} +1 -1
  69. package/build/src/integrations/lucid/persistence/lucid_attachment_repository.js.map +1 -0
  70. package/build/src/integrations/lucid/persistence/lucid_attachment_store.d.ts +48 -0
  71. package/build/src/integrations/lucid/persistence/lucid_attachment_store.d.ts.map +1 -0
  72. package/build/src/integrations/lucid/persistence/lucid_attachment_store.js +224 -0
  73. package/build/src/integrations/lucid/persistence/lucid_attachment_store.js.map +1 -0
  74. package/build/src/integrations/lucid/{lucid_variant_generation_service.d.ts → persistence/lucid_variant_generation_service.d.ts} +3 -3
  75. package/build/src/integrations/lucid/persistence/lucid_variant_generation_service.d.ts.map +1 -0
  76. package/build/src/integrations/lucid/persistence/lucid_variant_generation_service.js.map +1 -0
  77. package/build/src/integrations/lucid/{attachment_owner.d.ts → relations/attachment_owner.d.ts} +2 -1
  78. package/build/src/integrations/lucid/relations/attachment_owner.d.ts.map +1 -0
  79. package/build/src/integrations/lucid/relations/attachment_owner.js.map +1 -0
  80. package/build/src/integrations/lucid/relations/attachment_relation.d.ts +71 -0
  81. package/build/src/integrations/lucid/relations/attachment_relation.d.ts.map +1 -0
  82. package/build/src/integrations/lucid/relations/attachment_relation.js +266 -0
  83. package/build/src/integrations/lucid/relations/attachment_relation.js.map +1 -0
  84. package/build/src/integrations/lucid/schema/attachment_schema_service.d.ts +24 -0
  85. package/build/src/integrations/lucid/schema/attachment_schema_service.d.ts.map +1 -0
  86. package/build/src/integrations/lucid/schema/attachment_schema_service.js +68 -0
  87. package/build/src/integrations/lucid/schema/attachment_schema_service.js.map +1 -0
  88. package/build/src/integrations/lucid/schema/attachment_table_names.d.ts +15 -0
  89. package/build/src/integrations/lucid/schema/attachment_table_names.d.ts.map +1 -0
  90. package/build/src/integrations/lucid/schema/attachment_table_names.js +20 -0
  91. package/build/src/integrations/lucid/schema/attachment_table_names.js.map +1 -0
  92. package/build/src/integrations/lucid/schema/attachments_table_stub.d.ts.map +1 -0
  93. package/build/src/integrations/lucid/{attachments_table_stub.js → schema/attachments_table_stub.js} +2 -4
  94. package/build/src/integrations/lucid/schema/attachments_table_stub.js.map +1 -0
  95. package/build/src/integrations/lucid/schema/configure_lucid_attachment_tables.d.ts +12 -0
  96. package/build/src/integrations/lucid/schema/configure_lucid_attachment_tables.d.ts.map +1 -0
  97. package/build/src/integrations/lucid/schema/configure_lucid_attachment_tables.js +19 -0
  98. package/build/src/integrations/lucid/schema/configure_lucid_attachment_tables.js.map +1 -0
  99. package/build/src/sources/attachment_manager.d.ts +14 -12
  100. package/build/src/sources/attachment_manager.d.ts.map +1 -1
  101. package/build/src/sources/attachment_manager.js +14 -6
  102. package/build/src/sources/attachment_manager.js.map +1 -1
  103. package/build/stubs/migrations/attachments_table.stub +7 -24
  104. package/build/{src/integrations/lucid/render_legacy_attachment_migration_script.js → stubs/migrations/legacy_attachment_migration.stub} +13 -15
  105. package/build/tests/attachment_manager.spec.js +21 -18
  106. package/build/tests/attachment_manager.spec.js.map +1 -1
  107. package/build/tests/attachment_manager_service.spec.js +2 -2
  108. package/build/tests/attachment_manager_service.spec.js.map +1 -1
  109. package/build/tests/attachment_options.spec.d.ts +2 -0
  110. package/build/tests/attachment_options.spec.d.ts.map +1 -0
  111. package/build/tests/attachment_options.spec.js +31 -0
  112. package/build/tests/attachment_options.spec.js.map +1 -0
  113. package/build/tests/attachment_provider.spec.js +30 -1
  114. package/build/tests/attachment_provider.spec.js.map +1 -1
  115. package/build/tests/{create_legacy_attachment_migration_script.spec.d.ts → attachment_schema_service.spec.d.ts} +1 -1
  116. package/build/tests/attachment_schema_service.spec.d.ts.map +1 -0
  117. package/build/tests/attachment_schema_service.spec.js +38 -0
  118. package/build/tests/attachment_schema_service.spec.js.map +1 -0
  119. package/build/tests/attachment_service.spec.js +55 -0
  120. package/build/tests/attachment_service.spec.js.map +1 -1
  121. package/build/tests/attachment_table_names.spec.d.ts +8 -0
  122. package/build/tests/attachment_table_names.spec.d.ts.map +1 -0
  123. package/build/tests/attachment_table_names.spec.js +36 -0
  124. package/build/tests/attachment_table_names.spec.js.map +1 -0
  125. package/build/tests/attachments_table_stub.spec.js +41 -5
  126. package/build/tests/attachments_table_stub.spec.js.map +1 -1
  127. package/build/tests/define_config.spec.js +34 -0
  128. package/build/tests/define_config.spec.js.map +1 -1
  129. package/build/tests/helpers/lucid_test_database.d.ts.map +1 -1
  130. package/build/tests/helpers/lucid_test_database.js +16 -6
  131. package/build/tests/helpers/lucid_test_database.js.map +1 -1
  132. package/build/tests/legacy_attachment_migration_stub.spec.d.ts +8 -0
  133. package/build/tests/legacy_attachment_migration_stub.spec.d.ts.map +1 -0
  134. package/build/tests/legacy_attachment_migration_stub.spec.js +57 -0
  135. package/build/tests/legacy_attachment_migration_stub.spec.js.map +1 -0
  136. package/build/tests/lucid_attachment_collection_store.spec.d.ts +2 -0
  137. package/build/tests/lucid_attachment_collection_store.spec.d.ts.map +1 -0
  138. package/build/tests/lucid_attachment_collection_store.spec.js +53 -0
  139. package/build/tests/lucid_attachment_collection_store.spec.js.map +1 -0
  140. package/build/tests/lucid_attachment_column.spec.js +57 -1
  141. package/build/tests/lucid_attachment_column.spec.js.map +1 -1
  142. package/build/tests/lucid_attachment_lifecycle_service.spec.js +117 -111
  143. package/build/tests/lucid_attachment_lifecycle_service.spec.js.map +1 -1
  144. package/build/tests/lucid_attachment_relation.spec.d.ts +8 -0
  145. package/build/tests/lucid_attachment_relation.spec.d.ts.map +1 -0
  146. package/build/tests/lucid_attachment_relation.spec.js +295 -0
  147. package/build/tests/lucid_attachment_relation.spec.js.map +1 -0
  148. package/build/tests/lucid_attachment_repository.spec.js +1 -1
  149. package/build/tests/lucid_attachment_repository.spec.js.map +1 -1
  150. package/build/tests/lucid_attachment_store.spec.js +24 -50
  151. package/build/tests/lucid_attachment_store.spec.js.map +1 -1
  152. package/build/tests/lucid_sqlite_integration.spec.js +23 -18
  153. package/build/tests/lucid_sqlite_integration.spec.js.map +1 -1
  154. package/build/tests/lucid_variant_generation_service.spec.js +1 -1
  155. package/build/tests/lucid_variant_generation_service.spec.js.map +1 -1
  156. package/build/tests/migrate_legacy_attachment.spec.js +114 -67
  157. package/build/tests/migrate_legacy_attachment.spec.js.map +1 -1
  158. package/build/tests/migrate_legacy_attachment_records.spec.js +4 -3
  159. package/build/tests/migrate_legacy_attachment_records.spec.js.map +1 -1
  160. package/package.json +4 -2
  161. package/build/src/integrations/lucid/attachment_column.d.ts +0 -11
  162. package/build/src/integrations/lucid/attachment_column.d.ts.map +0 -1
  163. package/build/src/integrations/lucid/attachment_column.js.map +0 -1
  164. package/build/src/integrations/lucid/attachment_model.d.ts.map +0 -1
  165. package/build/src/integrations/lucid/attachment_model.js.map +0 -1
  166. package/build/src/integrations/lucid/attachment_owner.d.ts.map +0 -1
  167. package/build/src/integrations/lucid/attachment_owner.js.map +0 -1
  168. package/build/src/integrations/lucid/attachments_table_stub.d.ts.map +0 -1
  169. package/build/src/integrations/lucid/attachments_table_stub.js.map +0 -1
  170. package/build/src/integrations/lucid/create_legacy_attachment_migration_script.d.ts +0 -13
  171. package/build/src/integrations/lucid/create_legacy_attachment_migration_script.d.ts.map +0 -1
  172. package/build/src/integrations/lucid/create_legacy_attachment_migration_script.js +0 -20
  173. package/build/src/integrations/lucid/create_legacy_attachment_migration_script.js.map +0 -1
  174. package/build/src/integrations/lucid/lucid_attachment_lifecycle_service.d.ts +0 -21
  175. package/build/src/integrations/lucid/lucid_attachment_lifecycle_service.d.ts.map +0 -1
  176. package/build/src/integrations/lucid/lucid_attachment_lifecycle_service.js +0 -68
  177. package/build/src/integrations/lucid/lucid_attachment_lifecycle_service.js.map +0 -1
  178. package/build/src/integrations/lucid/lucid_attachment_repository.d.ts.map +0 -1
  179. package/build/src/integrations/lucid/lucid_attachment_repository.js.map +0 -1
  180. package/build/src/integrations/lucid/lucid_attachment_store.d.ts +0 -27
  181. package/build/src/integrations/lucid/lucid_attachment_store.d.ts.map +0 -1
  182. package/build/src/integrations/lucid/lucid_attachment_store.js +0 -84
  183. package/build/src/integrations/lucid/lucid_attachment_store.js.map +0 -1
  184. package/build/src/integrations/lucid/lucid_variant_generation_service.d.ts.map +0 -1
  185. package/build/src/integrations/lucid/lucid_variant_generation_service.js.map +0 -1
  186. package/build/src/integrations/lucid/migrate_legacy_attachment.d.ts.map +0 -1
  187. package/build/src/integrations/lucid/migrate_legacy_attachment.js +0 -67
  188. package/build/src/integrations/lucid/migrate_legacy_attachment.js.map +0 -1
  189. package/build/src/integrations/lucid/migrate_legacy_attachment_records.d.ts.map +0 -1
  190. package/build/src/integrations/lucid/migrate_legacy_attachment_records.js.map +0 -1
  191. package/build/src/integrations/lucid/render_legacy_attachment_migration_script.d.ts +0 -11
  192. package/build/src/integrations/lucid/render_legacy_attachment_migration_script.d.ts.map +0 -1
  193. package/build/src/integrations/lucid/render_legacy_attachment_migration_script.js.map +0 -1
  194. package/build/tests/create_legacy_attachment_migration_script.spec.d.ts.map +0 -1
  195. package/build/tests/create_legacy_attachment_migration_script.spec.js +0 -31
  196. package/build/tests/create_legacy_attachment_migration_script.spec.js.map +0 -1
  197. /package/build/src/integrations/lucid/{lucid_variant_generation_service.js → persistence/lucid_variant_generation_service.js} +0 -0
  198. /package/build/src/integrations/lucid/{attachment_owner.js → relations/attachment_owner.js} +0 -0
  199. /package/build/src/integrations/lucid/{attachments_table_stub.d.ts → schema/attachments_table_stub.d.ts} +0 -0
@@ -0,0 +1,94 @@
1
+ /**
2
+ * @jrmc/adonis-attachment
3
+ *
4
+ * @license MIT
5
+ * @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
6
+ */
7
+ import { createAttachmentOwnerKey, } from "../../relations/attachment_owner.js";
8
+ /**
9
+ * Converts one v5 JSON attachment document into blob and polymorphic-link rows.
10
+ * Callers can run it from an Ace command, another ORM migration, or a one-off script.
11
+ */
12
+ export function migrateLegacyAttachment(value, options) {
13
+ const attachment = typeof value === "string" ? parseLegacyAttachment(value) : value;
14
+ const id = options.createId();
15
+ const originalName = attachment.originalName ?? attachment.name;
16
+ const original = toBlob({
17
+ id,
18
+ attachment,
19
+ parentId: null,
20
+ variantKey: null,
21
+ originalName,
22
+ defaultDisk: options.defaultDisk,
23
+ });
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
+ };
48
+ }
49
+ /**
50
+ * Converts one v5 JSON value for a retained single attachment column. Legacy
51
+ * variants require the polymorphic table and therefore cannot be kept here.
52
+ */
53
+ export function migrateLegacyAttachmentColumn(value, options) {
54
+ const attachment = typeof value === "string" ? parseLegacyAttachment(value) : value;
55
+ if (attachment.variants?.length) {
56
+ throw new Error("Legacy attachments with variants must migrate to the polymorphic table");
57
+ }
58
+ const originalName = attachment.originalName ?? attachment.name;
59
+ return {
60
+ id: options.createId(),
61
+ disk: attachment.disk ?? options.defaultDisk,
62
+ path: attachment.path ?? attachment.name,
63
+ name: attachment.name,
64
+ originalName,
65
+ mimeType: attachment.mimeType,
66
+ extname: attachment.extname,
67
+ size: attachment.size,
68
+ ...(attachment.meta ? { metadata: attachment.meta } : {}),
69
+ };
70
+ }
71
+ function parseLegacyAttachment(value) {
72
+ try {
73
+ return JSON.parse(value);
74
+ }
75
+ catch {
76
+ throw new Error("Legacy attachment value must be valid JSON");
77
+ }
78
+ }
79
+ function toBlob({ id, attachment, parentId, variantKey, originalName, defaultDisk, }) {
80
+ return {
81
+ id,
82
+ parentId,
83
+ variantKey,
84
+ disk: attachment.disk ?? defaultDisk,
85
+ path: attachment.path ?? attachment.name,
86
+ name: attachment.name,
87
+ originalName,
88
+ mimeType: attachment.mimeType,
89
+ extname: attachment.extname,
90
+ size: attachment.size,
91
+ metadata: attachment.meta ?? null,
92
+ };
93
+ }
94
+ //# sourceMappingURL=migrate_legacy_attachment.js.map
@@ -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,IAA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owner.js';
8
- import { type LegacyAttachment, type MigratedAttachmentRow } from './migrate_legacy_attachment.js';
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: readonly MigratedAttachmentRow[]): Promise<void>;
14
+ insert(rows: MigratedAttachmentRows): Promise<void>;
15
15
  };
16
16
  export type MigrateLegacyAttachmentRecordsOptions = {
17
17
  records: Iterable<LegacyAttachmentMigrationRecord> | AsyncIterable<LegacyAttachmentMigrationRecord>;
@@ -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
- if (batch.length >= batchSize) {
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;
@@ -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;;;;;GAKG;AAGH,OAAO,EACL,uBAAuB,GAGxB,MAAM,gCAAgC,CAAA;AAyBvC;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,8BAA8B,CAClD,OAA8C;IAE9C,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,GAAG,CAAA;IAE1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AE,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,19 +6,15 @@
6
6
  */
7
7
  import { BaseModel } from '@adonisjs/lucid/orm';
8
8
  import type { DateTime } from 'luxon';
9
- import type { Attachment } from '../../core/attachment.js';
9
+ import type { Attachment } from '../../../core/attachment.js';
10
10
  /**
11
- * Default Lucid model for the polymorphic attachments table.
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
18
  parentId: string | null;
23
19
  variantKey: string | null;
24
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 the polymorphic attachments table.
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,18 +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
38
  __decorate([
51
39
  column()
52
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"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * @jrmc/adonis-attachment
3
+ *
4
+ * @license MIT
5
+ * @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
6
+ */
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';
13
+ import { LucidAttachmentStore } from './lucid_attachment_store.js';
14
+ export type AttachmentFileService = Pick<AttachmentService, 'create' | 'remove'> & Partial<Pick<AttachmentService, 'createDraft'>>;
15
+ export type LucidAttachmentPersistence = Pick<LucidAttachmentStore, 'createOriginal' | 'findOriginal' | 'listVariants' | 'releaseOwner' | 'restoreOwner' | 'remove' | 'listOwnerLinks'> & Partial<Pick<LucidAttachmentStore, 'createCollectionItem' | 'findCollectionItem' | 'listCollection' | 'moveCollectionItem' | 'removeCollectionItem' | 'createOriginalLink' | 'createCollectionLink'>>;
16
+ export declare class LucidAttachmentLifecycleService {
17
+ #private;
18
+ constructor(attachments: AttachmentFileService, store: LucidAttachmentPersistence);
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>;
22
+ detach(owner: AttachmentOwner): Promise<void>;
23
+ listVariants(owner: AttachmentOwner): Promise<AttachmentModel[]>;
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[]>;
29
+ removeCollectionItem(owner: AttachmentOwner, id: string): Promise<boolean>;
30
+ clearCollection(owner: AttachmentOwner): Promise<void>;
31
+ replaceCollection(owner: AttachmentOwner, inputs: readonly (CreateAttachmentInput | AttachmentDraft)[], options?: AttachmentPersistenceOptions<any>): Promise<AttachmentLinkModel[]>;
32
+ moveCollectionItem(owner: AttachmentOwner, id: string, position: number): Promise<AttachmentLinkModel[]>;
33
+ }
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,CAAA;AACpC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAA;AAC5E,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,qCAAqC,CAAA;AACvF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAA;AACvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAA;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAC/D,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAA;AAElE,MAAM,MAAM,qBAAqB,GAAG,IAAI,CAAC,iBAAiB,EAAE,QAAQ,GAAG,QAAQ,CAAC,GAC9E,OAAO,CAAC,IAAI,CAAC,iBAAiB,EAAE,aAAa,CAAC,CAAC,CAAA;AACjD,MAAM,MAAM,0BAA0B,GAAG,IAAI,CAC3C,oBAAoB,EAClB,gBAAgB,GAChB,cAAc,GACd,cAAc,GACd,cAAc,GACd,cAAc,GACd,QAAQ,GACR,gBAAgB,CACnB,GACC,OAAO,CACL,IAAI,CACF,oBAAoB,EAClB,sBAAsB,GACtB,oBAAoB,GACpB,gBAAgB,GAChB,oBAAoB,GACpB,sBAAsB,GACtB,oBAAoB,GACpB,sBAAsB,CACzB,CACF,CAAA;AAEH,qBAAa,+BAA+B;;gBAI9B,WAAW,EAAE,qBAAqB,EAAE,KAAK,EAAE,0BAA0B;IAKjF,GAAG,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAAC;IAI1D,MAAM,CACV,KAAK,EAAE,eAAe,EACtB,KAAK,EAAE,qBAAqB,GAAG,e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4BAA4B,CAAC,GAAG,CAAC,GAC1C,OAAO,CAAC,mBAAmB,EAAE,CAAC;IAoBjC,kBAAkB,CAChB,KAAK,EAAE,eAAe,EACtB,EAAE,EAAE,MAAM,EACV,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,mBAAmB,EAAE,CAAC;CA6GlC"}
@@ -0,0 +1,195 @@
1
+ /**
2
+ * @jrmc/adonis-attachment
3
+ *
4
+ * @license MIT
5
+ * @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
6
+ */
7
+ import { isAttachmentDraft, } from '../../../core/attachment.js';
8
+ export class LucidAttachmentLifecycleService {
9
+ #attachments;
10
+ #store;
11
+ constructor(attachments, store) {
12
+ this.#attachments = attachments;
13
+ this.#store = store;
14
+ }
15
+ get(owner) {
16
+ return this.#store.findOriginal(owner);
17
+ }
18
+ async attach(owner, input, options) {
19
+ const attachment = await this.#persist(owner, input, options);
20
+ try {
21
+ const original = await this.#store.createOriginal(owner, attachment);
22
+ this.#removeOnRollback(owner, [attachment]);
23
+ return original;
24
+ }
25
+ catch (error) {
26
+ await this.#removeStoredFile(attachment);
27
+ throw error;
28
+ }
29
+ }
30
+ async replace(owner, input, options) {
31
+ const previous = await this.#store.findOriginal(owner);
32
+ if (!previous) {
33
+ return this.attach(owner, input, options);
34
+ }
35
+ const attachment = await this.#persist(owner, input, options);
36
+ let current;
37
+ try {
38
+ await this.#store.releaseOwner(previous);
39
+ current = await this.#store.createOriginal(owner, attachment);
40
+ }
41
+ catch (error) {
42
+ await this.#store.restoreOwner(previous).catch(() => undefined);
43
+ await this.#removeStoredFile(attachment);
44
+ throw error;
45
+ }
46
+ try {
47
+ const removed = await this.#store.remove(previous);
48
+ await this.#removeOnCommit(owner, removed.map((item) => item.toAttachment()));
49
+ }
50
+ catch (error) {
51
+ await this.#store.remove(current).catch(() => undefined);
52
+ await this.#store.restoreOwner(previous).catch(() => undefined);
53
+ await this.#removeStoredFile(current.toAttachment());
54
+ throw error;
55
+ }
56
+ this.#removeOnRollback(owner, [current.toAttachment()]);
57
+ return current;
58
+ }
59
+ async detach(owner) {
60
+ const original = await this.#store.findOriginal(owner);
61
+ if (!original) {
62
+ return;
63
+ }
64
+ const removed = await this.#store.remove(original);
65
+ await this.#removeOnCommit(owner, removed.map((item) => item.toAttachment()));
66
+ }
67
+ async listVariants(owner) {
68
+ const original = await this.#store.findOriginal(owner);
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
+ }
76
+ }
77
+ async add(owner, input, position, options) {
78
+ const attachment = await this.#persist(owner, input, options);
79
+ try {
80
+ const item = await this.#collectionStore().createCollectionItem(owner, attachment, position);
81
+ this.#removeOnRollback(owner, [attachment]);
82
+ return item;
83
+ }
84
+ catch (error) {
85
+ await this.#removeStoredFile(attachment);
86
+ throw error;
87
+ }
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
+ }
95
+ listCollection(owner) {
96
+ return this.#collectionStore().listCollection(owner);
97
+ }
98
+ async removeCollectionItem(owner, id) {
99
+ const item = await this.#collectionStore().findCollectionItem(owner, id);
100
+ if (!item) {
101
+ return false;
102
+ }
103
+ await this.#detachCollectionItem(owner, item);
104
+ return true;
105
+ }
106
+ async clearCollection(owner) {
107
+ for (const item of await this.#collectionStore().listCollection(owner)) {
108
+ await this.#detachCollectionItem(owner, item);
109
+ }
110
+ }
111
+ async replaceCollection(owner, inputs, options) {
112
+ const previous = await this.#collectionStore().listCollection(owner);
113
+ const created = [];
114
+ try {
115
+ for (const input of inputs) {
116
+ created.push(await this.add(owner, input, undefined, options));
117
+ }
118
+ }
119
+ catch (error) {
120
+ await Promise.all(created.map((item) => this.#detachCollectionItem(owner, item)));
121
+ throw error;
122
+ }
123
+ for (const item of previous) {
124
+ await this.#detachCollectionItem(owner, item);
125
+ }
126
+ return this.#collectionStore().listCollection(owner);
127
+ }
128
+ moveCollectionItem(owner, id, position) {
129
+ return this.#collectionStore().moveCollectionItem(owner, id, position);
130
+ }
131
+ async #removeStoredFile(attachment) {
132
+ await this.#attachments.remove(attachment);
133
+ }
134
+ async #removeOnCommit(owner, attachments) {
135
+ const transaction = getOwnerTransaction(owner);
136
+ if (transaction) {
137
+ transaction.after('commit', () => this.#removeStoredFiles(attachments));
138
+ return;
139
+ }
140
+ await this.#removeStoredFiles(attachments);
141
+ }
142
+ #removeOnRollback(owner, attachments) {
143
+ const transaction = getOwnerTransaction(owner);
144
+ if (transaction) {
145
+ transaction.after('rollback', () => this.#removeStoredFiles(attachments));
146
+ }
147
+ }
148
+ #removeStoredFiles(attachments) {
149
+ return Promise.all(attachments.map((attachment) => this.#removeStoredFile(attachment))).then(() => undefined);
150
+ }
151
+ async #detachCollectionItem(owner, item) {
152
+ const removed = await this.#collectionStore().removeCollectionItem(owner, item);
153
+ await this.#removeOnCommit(owner, removed.map((attachment) => attachment.toAttachment()));
154
+ }
155
+ #collectionStore() {
156
+ const store = this.#store;
157
+ if (!store.createCollectionItem ||
158
+ !store.findCollectionItem ||
159
+ !store.listCollection ||
160
+ !store.moveCollectionItem ||
161
+ !store.removeCollectionItem) {
162
+ throw new Error('Lucid attachment collection operations require a collection-capable store');
163
+ }
164
+ return store;
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
+ }
173
+ async #persist(owner, input, options) {
174
+ if (isAttachmentDraft(input)) {
175
+ return input.persist({
176
+ ...(options ? { options } : {}),
177
+ context: { model: owner.model, field: owner.field },
178
+ });
179
+ }
180
+ if (this.#attachments.createDraft) {
181
+ return this.#attachments
182
+ .createDraft(input)
183
+ .persist({
184
+ ...(options ? { options } : {}),
185
+ context: { model: owner.model, field: owner.field },
186
+ });
187
+ }
188
+ return this.#attachments.create(input);
189
+ }
190
+ }
191
+ function getOwnerTransaction(owner) {
192
+ const model = owner.model;
193
+ return model?.$trx ?? null;
194
+ }
195
+ //# sourceMappingURL=lucid_attachment_lifecycle_service.js.map
@@ -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,MAAM,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,KAAK,EAAE,UAAU,CAAC,CAAA;YACpE,IAAI,CAAC,iBAAiB,CAAC,KAAK,EAAE,CAAC,UAAU,CAAC,CAAC,CAAA;YAC3C,OAAO,QAAQ,CAAA;QACjB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,IAAI,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAA;YACxC,MAAM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AAK,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 '../../core/attachment.js';
8
- import type { AttachmentRepository } from '../../core/attachment_repository.js';
9
- import { AttachmentModel } from './attachment_model.js';
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 './attachment_model.js';
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"}