@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
@@ -4,8 +4,9 @@
4
4
  * @license MIT
5
5
  * @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
6
6
  */
7
- import { AttachmentFactory, } from './attachment.js';
7
+ import { AttachmentDraft, AttachmentFactory, } from './attachment.js';
8
8
  import { markAttachmentPending } from './attachment_state.js';
9
+ import { resolveAttachmentPersistenceOptions, } from './attachment_options.js';
9
10
  /**
10
11
  * Creates files and delegates persistence to the configured storage backend.
11
12
  * Database persistence deliberately remains the responsibility of the caller.
@@ -14,20 +15,53 @@ export class AttachmentService {
14
15
  #storage;
15
16
  #queue;
16
17
  #factory;
18
+ #defaults;
17
19
  constructor(options) {
18
20
  this.#storage = options.storage;
19
21
  this.#queue = options.queue;
20
22
  this.#factory = new AttachmentFactory(options);
23
+ this.#defaults = options.defaults ?? {};
21
24
  }
25
+ createDraft(input, options = {}) {
26
+ const draftOptions = {
27
+ ...(input.disk !== undefined ? { disk: input.disk } : {}),
28
+ ...(input.folder !== undefined ? { folder: input.folder } : {}),
29
+ ...options,
30
+ };
31
+ const provisional = this.#factory.create(input, {
32
+ ...(typeof draftOptions.disk === 'string' ? { disk: draftOptions.disk } : {}),
33
+ ...(typeof draftOptions.folder === 'string' ? { folder: draftOptions.folder } : {}),
34
+ });
35
+ return new AttachmentDraft(input, provisional, draftOptions, (draft, request) => this.#persistDraft(draft, request));
36
+ }
37
+ /**
38
+ * Backward-compatible immediate persistence for direct service consumers.
39
+ */
22
40
  async create(input) {
23
- const attachment = this.#factory.create(input);
41
+ return this.createDraft(input).persist();
42
+ }
43
+ async #persistDraft(draft, request) {
44
+ const source = draft.source;
45
+ const context = {
46
+ ...request?.context,
47
+ originalName: source.originalName,
48
+ };
49
+ const options = resolveAttachmentPersistenceOptions(this.#defaults, request?.options, draft.options);
50
+ const folder = await resolveFolder(options.folder, context);
51
+ const name = await resolveName(options.rename, context);
52
+ const attachment = this.#factory.create(source, {
53
+ id: draft.id,
54
+ ...(options.disk ? { disk: options.disk } : {}),
55
+ ...(folder ? { folder } : {}),
56
+ ...(name ? { name } : {}),
57
+ });
24
58
  await this.#storage.write({
25
59
  disk: attachment.disk,
26
60
  path: attachment.path,
27
- body: input.body,
61
+ body: source.body,
28
62
  mimeType: attachment.mimeType,
29
63
  });
30
- markAttachmentPending(attachment);
64
+ markAttachmentPending(draft);
31
65
  return attachment;
32
66
  }
33
67
  remove(attachment) {
@@ -44,4 +78,16 @@ export class AttachmentService {
44
78
  });
45
79
  }
46
80
  }
81
+ async function resolveFolder(folder, context) {
82
+ if (typeof folder === 'function') {
83
+ return folder(context);
84
+ }
85
+ return folder;
86
+ }
87
+ async function resolveName(rename, context) {
88
+ if (typeof rename === 'function') {
89
+ return rename(context);
90
+ }
91
+ return rename === false ? context.originalName : undefined;
92
+ }
47
93
  //# sourceMappingURL=attachment_service.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"attachment_service.js","sourceRoot":"","sources":["../../../src/core/attachment_service.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,iBAAiB,GAGlB,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAA;AAW7D;;;GAGG;AACH,MAAM,OAAO,iBAAiB;IACnB,QAAQ,CAAmB;IAC3B,MAAM,CAAiB;IACvB,QAAQ,CAAmB;IAEpC,YAAY,OAAiC;QAC3C,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAA;QAC/B,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,KAAK,CAAA;QAC3B,IAAI,CAAC,QAAQ,GAAG,IAAI,iBAAiB,CAAC,OAAO,CAAC,CAAA;IAChD,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,KAA4B;QACvC,MAAM,UAAU,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CA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Factory, type Attachment, type AttachmentFactoryOptions, type CreateAttachmentInput, } from './attachment.js';
7
+ export { AttachmentFactory, AttachmentDraft, isAttachmentDraft, type Attachment, type AttachmentDraftPersistence, type AttachmentFactoryOptions, type AttachmentPersistRequest, type CreateAttachmentInput, } from './attachment.js';
8
+ export { resolveAttachmentPersistenceOptions, type AttachmentFolder, type AttachmentPersistenceContext, type AttachmentPersistenceOptions, type AttachmentRename, type ResolvedAttachmentPersistenceOptions, } from './attachment_options.js';
8
9
  export { AttachmentService, type AttachmentServiceOptions } from './attachment_service.js';
9
10
  export { AttachmentJobProcessor, AttachmentNotFoundError, type AttachmentJobProcessorOptions, type VariantGenerationRequest, type VariantGenerator, type VariantGeneratorFactory, } from './attachment_job_processor.js';
10
11
  export { type AttachmentRepository } from './attachment_repository.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,iBAAiB,EACjB,KAAK,UAAU,EACf,KAAK,wBAAwB,EAC7B,KAAK,qBAAqB,GAC3B,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,iBAAiB,EAAE,KAAK,wBAAwB,EAAE,MAAM,yBAAyB,CAAA;AAC1F,OAAO,EACL,sBAAsB,EACtB,uBAAuB,EACvB,KAAK,6BAA6B,EAClC,KAAK,wBAAwB,EAC7B,KAAK,gBAAgB,EACrB,KAAK,uBAAuB,GAC7B,MAAM,+BAA+B,CAAA;AACtC,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,4BAA4B,CAAA;AACtE,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,oBAAoB,EACzB,KAAK,eAAe,EACpB,KAAK,mBAAmB,GACzB,MAAM,YAAY,CAAA;AACnB,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,oBAAoB,GAC1B,MAAM,cAAc,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,iBAAiB,EACjB,KAAK,UAAU,EACf,KAAK,0BAA0B,EAC/B,KAAK,wBAAwB,EAC7B,KAAK,wBAAwB,EAC7B,KAAK,qBAAqB,GAC3B,MAAM,iBAAiB,CAAA;AACxB,OAAO,EACL,mCAAmC,EACnC,KAAK,gBAAgB,EACrB,KAAK,4BAA4B,EACjC,KAAK,4BAA4B,EACjC,KAAK,gBAAgB,EACrB,KAAK,oCAAoC,GAC1C,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAAE,iBAAiB,EAAE,KAAK,wBAAwB,EAAE,MAAM,yBAAyB,CAAA;AAC1F,OAAO,EACL,sBAAsB,EACtB,uBAAuB,EACvB,KAAK,6BAA6B,EAClC,KAAK,wBAAwB,EAC7B,KAAK,gBAAgB,EACrB,KAAK,uBAAuB,GAC7B,MAAM,+BAA+B,CAAA;AACtC,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,4BAA4B,CAAA;AACtE,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,oBAAoB,EACzB,KAAK,eAAe,EACpB,KAAK,mBAAmB,GACzB,MAAM,YAAY,CAAA;AACnB,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,oBAAoB,GAC1B,MAAM,cAAc,CAAA"}
@@ -4,7 +4,8 @@
4
4
  * @license MIT
5
5
  * @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
6
6
  */
7
- export { AttachmentFactory, } from './attachment.js';
7
+ export { AttachmentFactory, AttachmentDraft, isAttachmentDraft, } from './attachment.js';
8
+ export { resolveAttachmentPersistenceOptions, } from './attachment_options.js';
8
9
  export { AttachmentService } from './attachment_service.js';
9
10
  export { AttachmentJobProcessor, AttachmentNotFoundError, } from './attachment_job_processor.js';
10
11
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,iBAAiB,GAIlB,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,iBAAiB,EAAiC,MAAM,yBAAyB,CAAA;AAC1F,OAAO,EACL,sBAAsB,EACtB,uBAAuB,GAKxB,MAAM,+BAA+B,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,iBAAiB,GAMlB,MAAM,iBAAiB,CAAA;AACxB,OAAO,EACL,mCAAmC,GAMpC,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAAE,iBAAiB,EAAiC,MAAM,yBAAyB,CAAA;AAC1F,OAAO,EACL,sBAAsB,EACtB,uBAAuB,GAKxB,MAAM,+BAA+B,CAAA"}
@@ -4,6 +4,7 @@
4
4
  * @license MIT
5
5
  * @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
6
6
  */
7
+ import { type AttachmentTableNames } from './integrations/lucid/schema/attachment_table_names.js';
7
8
  import type { ApplicationService, ConfigProvider } from '@adonisjs/core/types';
8
9
  import type { AttachmentServiceOptions } from './core/attachment_service.js';
9
10
  import type { AttachmentJobProcessor } from './core/attachment_job_processor.js';
@@ -11,6 +12,7 @@ import type { AttachmentRepository } from './core/attachment_repository.js';
11
12
  import type { AttachmentJobHandler, AttachmentQueue } from './core/queue.js';
12
13
  import type { AttachmentStorage } from './core/storage.js';
13
14
  import type { AttachmentManagerOptions } from './sources/attachment_manager.js';
15
+ import type { AttachmentPersistenceOptions } from './core/attachment_options.js';
14
16
  type Integration<T> = T | ((app: ApplicationService) => T | Promise<T>);
15
17
  export type AttachmentRouteConfig = false | {
16
18
  prefix?: string;
@@ -18,6 +20,14 @@ export type AttachmentRouteConfig = false | {
18
20
  export type ResolvedAttachmentRouteConfig = {
19
21
  path: string;
20
22
  };
23
+ export type LucidAttachmentConfig = {
24
+ /** Blob table name. The link table is derived as `${singular(tableName)}_links`. */
25
+ tableName?: string;
26
+ };
27
+ export type AttachmentIntegrationsConfig = {
28
+ /** Optional configuration for the Lucid persistence integration. */
29
+ lucid?: LucidAttachmentConfig;
30
+ };
21
31
  export type AttachmentConfig = {
22
32
  /** Overrides the storage default. Falls back to `fs` when no adapter provides one. */
23
33
  defaultDisk?: string;
@@ -26,15 +36,22 @@ export type AttachmentConfig = {
26
36
  jobHandler?: Integration<AttachmentJobHandler>;
27
37
  processor?: Integration<AttachmentJobProcessor>;
28
38
  repository?: Integration<AttachmentRepository>;
39
+ /** Lowest-priority defaults for file persistence. */
40
+ defaults?: AttachmentPersistenceOptions;
29
41
  sources?: AttachmentManagerOptions;
30
42
  route?: AttachmentRouteConfig;
43
+ integrations?: AttachmentIntegrationsConfig;
31
44
  queueConcurrency?: number;
32
45
  createId?: () => string;
33
46
  };
34
47
  export type ResolvedAttachmentConfig = AttachmentServiceOptions & {
35
48
  repository?: AttachmentRepository;
49
+ defaults?: AttachmentPersistenceOptions;
36
50
  sources?: AttachmentManagerOptions;
37
51
  route: ResolvedAttachmentRouteConfig | false;
52
+ integrations?: {
53
+ lucid?: AttachmentTableNames;
54
+ };
38
55
  };
39
56
  /**
40
57
  * Defers resolution of optional Adonis integrations until application boot.
@@ -1 +1 @@
1
- {"version":3,"file":"define_config.d.ts","sourceRoot":"","sources":["../../src/define_config.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,KAAK,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAC9E,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAA;AAC5E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAA;AAChF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAA;AAC3E,OAAO,KAAK,EAAE,oBAAoB,E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,sFAAsF;IACtF,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,OAAO,EAAE,WAAW,CAAC,iBAAiB,CAAC,CAAA;IACvC,KAAK,CAAC,EAAE,WAAW,CAAC,eAAe,CAAC,CAAA;IACpC,UAAU,CAAC,EAAE,WAAW,CAAC,oBAAoB,CAAC,CAAA;IAC9C,SAAS,CAAC,EAAE,WAAW,CAAC,sBAAsB,CAAC,CAAA;IAC/C,UAAU,CAAC,EAAE,WAAW,CAAC,oBAAoB,CAAC,CAAA;IAC9C,qDAAqD;IACrD,QAAQ,CAAC,EAAE,4BAA4B,CAAA;IACvC,OAAO,CAAC,EAAE,wBAAwB,CAAA;IAClC,KAAK,CAAC,EAAE,qBAAqB,CAAA;IAC7B,YAAY,CAAC,EAAE,4BAA4B,CAAA;IAC3C,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,EAAE,MAAM,MAAM,CAAA;CACxB,CAAA;AAED,MAAM,MAAM,wBAAwB,GAAG,wBAAwB,GAAG;IAChE,UAAU,CAAC,EAAE,oBAAoB,CAAA;IACjC,QAAQ,CAAC,EAAE,4BAA4B,CAAA;IACvC,OAAO,CAAC,EAAE,wBAAwB,CAAA;IAClC,KAAK,EAAE,6BAA6B,GAAG,KAAK,CAAA;IAC5C,YAAY,CAAC,EAAE;QACb,KAAK,CAAC,EAAE,oBAAoB,CAAA;KAC7B,CAAA;CACF,CAAA;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,gBAAgB,GAAG,cAAc,CAAC,wBAAwB,CAAC,CAqC/F"}
@@ -6,6 +6,7 @@
6
6
  */
7
7
  import { configProvider } from '@adonisjs/core';
8
8
  import { MemoryAttachmentQueue } from './queues/memory_queue.js';
9
+ import { resolveAttachmentTableNames, } from './integrations/lucid/schema/attachment_table_names.js';
9
10
  /**
10
11
  * Defers resolution of optional Adonis integrations until application boot.
11
12
  */
@@ -33,7 +34,15 @@ export function defineConfig(config) {
33
34
  ...(config.repository
34
35
  ? { repository: await resolveIntegration(config.repository, app) }
35
36
  : {}),
37
+ ...(config.defaults ? { defaults: config.defaults } : {}),
36
38
  ...(config.sources ? { sources: config.sources } : {}),
39
+ ...(config.integrations?.lucid
40
+ ? {
41
+ integrations: {
42
+ lucid: resolveAttachmentTableNames(config.integrations.lucid.tableName),
43
+ },
44
+ }
45
+ : {}),
37
46
  ...(config.createId ? { createId: config.createId } : {}),
38
47
  };
39
48
  });
@@ -1 +1 @@
1
- {"version":3,"file":"define_config.js","sourceRoot":"","sources":["../../src/define_config.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAC/C,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAA;AAsChE;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,MAAwB;IACnD,OAAO,cAAc,CAAC,MAAM,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;QACzC,MAAM,OAAO,GAAG,MAAM,kBAAkB,CAAC,MAAM,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;QAC7D,MAAM,SAAS,GAAG,MAAM,CAAC,SAAS;YAChC,CAAC,CAAC,MAAM,kBAAkB,CAAC,MAAM,CAAC,SAAS,EAAE,GAAG,CAAC;YACjD,CAAC,CAAC,SAAS,CAAA;QACb,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK;YACxB,CAAC,CAAC,MAAM,kBAAkB,CAAC,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC;YAC7C,CAAC,CAAC,IAAI,qBAAqB,CAAC;gBACxB,OAAO,EAAE,MAAM,CAAC,UAAU;oBACxB,CAAC,CAAC,MAAM,kBAAkB,CAAC,MAAM,CAAC,UAAU,EAAE,GAAG,CAAC;oBAClD,CAAC,CAAC,SAAS;wBACT,CAAC,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC;wBACnC,CAAC,CAAC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QACpB,OAAO,KAAK,CAAA;IACd,CAAC;IAED,MAAM,MAAM,GAAG,KAAK,EAAE,MAAM,IAAI,cAAc,CAAA;IAE9C,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QACpD,MAAM,IAAI,KAAK,CAAC,2EAA2E,CAAC,CAAA;IAC9F,CAAC;IAED,OAAO,EAAE,IAAI,EAAE,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,CAAA;AAC5D,CAAC;AAED,KAAK,UAAU,kBAAkB,CAC/B,WAA2B,EAC3B,GAAuB;IAEvB,IAAI,OAAO,WAAW,KAAK,UAAU,EAAE,CAAC;QACtC,OAAQ,WAAmE,CAAC,GAAG,CAAC,CAAA;IAClF,CAAC;IAED,OAAO,WAAW,CAAA;AACpB,CAAC"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * @jrmc/adonis-attachment
3
+ *
4
+ * @license MIT
5
+ * @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
6
+ */
7
+ import type { LucidRow } from '@adonisjs/lucid/types/model';
8
+ import { type Attachment } from '../../../core/attachment.js';
9
+ import type { AttachmentPersistenceOptions } from '../../../core/attachment_options.js';
10
+ export type LucidAttachmentOptions<Model = any> = AttachmentPersistenceOptions<Model> & {
11
+ serialize?: (value: Attachment | null | undefined) => unknown;
12
+ serializeAs?: string | null;
13
+ };
14
+ /**
15
+ * Persists one Attachment JSON value in a Lucid column and coordinates file cleanup.
16
+ */
17
+ export declare function attachment<Model = LucidRow>(options?: LucidAttachmentOptions<Model>): PropertyDecorator;
18
+ //# sourceMappingURL=attachment_column.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attachment_column.d.ts","sourceRoot":"","sources":["../../../../../src/integrations/lucid/column/attachment_column.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAc,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AAEvE,OAAO,EAAqB,KAAK,UAAU,EAAE,MAAM,6BAA6B,CAAA;AAEhF,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,qCAAqC,CAAA;AAoBvF,MAAM,MAAM,sBAAsB,CAAC,KAAK,GAAG,GAAG,IAAI,4BAA4B,CAAC,KAAK,CAAC,GAAG;IACtF,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI,GAAG,SAAS,KAAK,OAAO,CAAA;IAC7D,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAC5B,CAAA;AAOD;;GAEG;AACH,wBAAgB,UAAU,CAAC,KAAK,GAAG,QAAQ,EAAE,OAAO,GAAE,sBAAsB,CAAC,KAAK,CAAM,GAAG,iBAAiB,CAoB3G"}
@@ -5,23 +5,24 @@
5
5
  * @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
6
6
  */
7
7
  import app from '@adonisjs/core/services/app';
8
- import { isAttachmentPending, markAttachmentPersisted } from '../../core/attachment_state.js';
9
- const columnNames = new WeakMap();
8
+ import { isAttachmentDraft } from '../../../core/attachment.js';
9
+ import { isAttachmentPending, markAttachmentPersisted } from '../../../core/attachment_state.js';
10
+ const columnOptions = new WeakMap();
10
11
  const saveStates = new WeakMap();
11
12
  const deleteStates = new WeakMap();
12
13
  const patchedModels = new WeakSet();
13
14
  /**
14
15
  * Persists one Attachment JSON value in a Lucid column and coordinates file cleanup.
15
16
  */
16
- export function attachment() {
17
+ export function attachment(options = {}) {
17
18
  return (target, propertyKey) => {
18
19
  const Model = target.constructor;
19
20
  const name = String(propertyKey);
20
21
  Model.boot();
21
- const columns = columnNames.get(Model) ?? new Set();
22
- columns.add(name);
23
- columnNames.set(Model, columns);
24
- Model.$addColumn(name, makeColumnOptions());
22
+ const columns = columnOptions.get(Model) ?? new Map();
23
+ columns.set(name, options);
24
+ columnOptions.set(Model, columns);
25
+ Model.$addColumn(name, makeColumnOptions(options));
25
26
  if (!patchedModels.has(Model)) {
26
27
  patchedModels.add(Model);
27
28
  Model.before('save', prepareSave);
@@ -32,7 +33,7 @@ export function attachment() {
32
33
  }
33
34
  };
34
35
  }
35
- function makeColumnOptions() {
36
+ function makeColumnOptions(options) {
36
37
  return {
37
38
  prepare(value) {
38
39
  return value ? JSON.stringify(value) : null;
@@ -43,16 +44,15 @@ function makeColumnOptions() {
43
44
  }
44
45
  return JSON.parse(value);
45
46
  },
46
- serialize(value) {
47
- return value ?? null;
48
- },
47
+ serialize: options.serialize ?? ((value) => value ?? null),
48
+ ...(options.serializeAs !== undefined ? { serializeAs: options.serializeAs } : {}),
49
49
  };
50
50
  }
51
51
  async function prepareSave(row) {
52
52
  const state = { attached: [], detached: [] };
53
53
  for (const name of getColumnNames(row)) {
54
54
  const previous = toAttachment(row.$original[name]);
55
- const current = toAttachment(row.$attributes[name]);
55
+ const current = await persistDraft(row, name);
56
56
  if (previous?.id === current?.id) {
57
57
  continue;
58
58
  }
@@ -117,7 +117,20 @@ function wrapSave(Model) {
117
117
  };
118
118
  }
119
119
  function getColumnNames(row) {
120
- return columnNames.get(row.constructor) ?? new Set();
120
+ return new Set(columnOptions.get(row.constructor)?.keys());
121
+ }
122
+ async function persistDraft(row, name) {
123
+ const value = row.$attributes[name];
124
+ if (!isAttachmentDraft(value)) {
125
+ return toAttachment(value);
126
+ }
127
+ const options = columnOptions.get(row.constructor)?.get(name);
128
+ const attachment = await value.persist({
129
+ ...(options ? { options } : {}),
130
+ context: { model: row, field: name },
131
+ });
132
+ row.$attributes[name] = attachment;
133
+ return attachment;
121
134
  }
122
135
  function toAttachment(value) {
123
136
  if (!value || typeof value !== 'object' || !('id' in value) || !('disk' in value) || !('path' in value)) {
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attachment_column.js","sourceRoot":"","sources":["../../../../../src/integrations/lucid/column/attachment_column.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,GAAG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AAM,OAAO,GAAG,CAAC,MAAM,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAsB,CAAA;IAClF,MAAM,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAA;AACvF,CAAC"}
@@ -4,16 +4,20 @@
4
4
  * @license MIT
5
5
  * @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
6
6
  */
7
- export { AttachmentModel } from './attachment_model.js';
8
- export { attachment } from './attachment_column.js';
9
- export { LucidAttachmentRepository } from './lucid_attachment_repository.js';
10
- export { LucidAttachmentStore, type LucidAttachmentWithVariants, } from './lucid_attachment_store.js';
11
- export { LucidAttachmentLifecycleService, type AttachmentFileService, type LucidAttachmentPersistence, } from './lucid_attachment_lifecycle_service.js';
12
- export { LucidVariantGenerationService, PersistedAttachmentNotFoundError, type LucidVariantGenerationServiceOptions, } from './lucid_variant_generation_service.js';
13
- export { createAttachmentOwnerKey, type AttachmentOwner } from './attachment_owner.js';
14
- export { createAttachmentsTableStubState, type AttachmentsTableStubOptions, type AttachmentsTableStubState, } from './attachments_table_stub.js';
15
- export { migrateLegacyAttachment, type LegacyAttachment, type LegacyVariant, type MigrateLegacyAttachmentOptions, type MigratedAttachmentRow, } from './migrate_legacy_attachment.js';
16
- export { migrateLegacyAttachmentRecords, type LegacyAttachmentMigrationRecord, type LegacyAttachmentMigrationResult, type LegacyAttachmentMigrationWriter, type MigrateLegacyAttachmentRecordsOptions, } from './migrate_legacy_attachment_records.js';
17
- export { createLegacyAttachmentMigrationScript, type CreateLegacyAttachmentMigrationScriptOptions, } from './create_legacy_attachment_migration_script.js';
18
- export { renderLegacyAttachmentMigrationScript, type RenderLegacyAttachmentMigrationScriptOptions, } from './render_legacy_attachment_migration_script.js';
7
+ export { AttachmentModel } from "./models/attachment_model.js";
8
+ export { AttachmentLinkModel } from "./models/attachment_link_model.js";
9
+ export { configureLucidAttachmentTables, } from "./schema/configure_lucid_attachment_tables.js";
10
+ export { resolveAttachmentTableNames, type AttachmentTableNames, } from "./schema/attachment_table_names.js";
11
+ export { AttachmentSchemaService, type AttachmentSchemaServiceOptions, } from "./schema/attachment_schema_service.js";
12
+ export { attachment, type LucidAttachmentOptions, } from "./column/attachment_column.js";
13
+ export { attachmentRelation, attachmentsRelation, AttachmentRelation, AttachmentCollectionRelation, type AttachmentRelationOptions, } from "./relations/attachment_relation.js";
14
+ export { LucidAttachmentRepository } from "./persistence/lucid_attachment_repository.js";
15
+ export { LucidAttachmentStore, type LucidAttachmentWithVariants, type LucidAttachmentStoreOptions, } from "./persistence/lucid_attachment_store.js";
16
+ export { LucidAttachmentLifecycleService, type AttachmentFileService, type LucidAttachmentPersistence, } from "./persistence/lucid_attachment_lifecycle_service.js";
17
+ export { LucidVariantGenerationService, PersistedAttachmentNotFoundError, type LucidVariantGenerationServiceOptions, } from "./persistence/lucid_variant_generation_service.js";
18
+ export { createAttachmentOwnerKey, type AttachmentOwner, } from "./relations/attachment_owner.js";
19
+ export { createAttachmentsTableStubState, type AttachmentsTableStubOptions, type AttachmentsTableStubState, } from "./schema/attachments_table_stub.js";
20
+ export { migrateLegacyAttachment, migrateLegacyAttachmentColumn, type LegacyAttachment, type LegacyVariant, type MigrateLegacyAttachmentOptions, type MigrateLegacyAttachmentColumnOptions, type MigratedAttachmentBlob, type MigratedAttachmentLink, type MigratedAttachmentRows, } from "./migrations/legacy/migrate_legacy_attachment.js";
21
+ export { migrateLegacyAttachmentRecords, type LegacyAttachmentMigrationRecord, type LegacyAttachmentMigrationResult, type LegacyAttachmentMigrationWriter, type MigrateLegacyAttachmentRecordsOptions, } from "./migrations/legacy/migrate_legacy_attachment_records.js";
22
+ export { createLegacyAttachmentMigrationStubState, type LegacyAttachmentMigrationStubOptions, type LegacyAttachmentMigrationStubState, } from "./migrations/legacy/legacy_attachment_migration_stub.js";
19
23
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/integrations/lucid/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AACnD,OAAO,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAA;AAC5E,OAAO,EACL,oBAAoB,EACpB,KAAK,2BAA2B,GACjC,MAAM,6BAA6B,CAAA;AACpC,OAAO,EACL,+BAA+B,EAC/B,KAAK,qBAAqB,EAC1B,KAAK,0BAA0B,GAChC,MAAM,yCAAyC,CAAA;AAChD,OAAO,EACL,6BAA6B,EAC7B,gCAAgC,EAChC,KAAK,oCAAoC,GAC1C,MAAM,uCAAuC,CAAA;AAC9C,OAAO,EAAE,wBAAwB,EAAE,KAAK,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACtF,OAAO,EACL,+BAA+B,EAC/B,KAAK,2BAA2B,EAChC,KAAK,yBAAyB,GAC/B,MAAM,6BAA6B,CAAA;AACpC,OAAO,EACL,uBAAuB,EACvB,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,8BAA8B,EACnC,KAAK,qBAAqB,GAC3B,MAAM,gCAAgC,CAAA;AACvC,OAAO,EACL,8BAA8B,EAC9B,KAAK,+BAA+B,EACpC,KAAK,+BAA+B,EACpC,KAAK,+BAA+B,EACpC,KAAK,qCAAqC,GAC3C,MAAM,wCAAwC,CAAA;AAC/C,OAAO,EACL,qCAAqC,EACrC,KAAK,4CAA4C,GAClD,MAAM,gDAAgD,CAAA;AACvD,OAAO,EACL,qCAAqC,EACrC,KAAK,4CAA4C,GAClD,MAAM,gDAAgD,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/integrations/lucid/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAA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AA+B,EACpC,KAAK,+BAA+B,EACpC,KAAK,+BAA+B,EACpC,KAAK,qCAAqC,GAC3C,MAAM,0DAA0D,CAAC;AAClE,OAAO,EACL,wCAAwC,EACxC,KAAK,oCAAoC,EACzC,KAAK,kCAAkC,GACxC,MAAM,yDAAyD,CAAC"}
@@ -4,16 +4,20 @@
4
4
  * @license MIT
5
5
  * @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
6
6
  */
7
- export { AttachmentModel } from './attachment_model.js';
8
- export { attachment } from './attachment_column.js';
9
- export { LucidAttachmentRepository } from './lucid_attachment_repository.js';
10
- export { LucidAttachmentStore, } from './lucid_attachment_store.js';
11
- export { LucidAttachmentLifecycleService, } from './lucid_attachment_lifecycle_service.js';
12
- export { LucidVariantGenerationService, PersistedAttachmentNotFoundError, } from './lucid_variant_generation_service.js';
13
- export { createAttachmentOwnerKey } from './attachment_owner.js';
14
- export { createAttachmentsTableStubState, } from './attachments_table_stub.js';
15
- export { migrateLegacyAttachment, } from './migrate_legacy_attachment.js';
16
- export { migrateLegacyAttachmentRecords, } from './migrate_legacy_attachment_records.js';
17
- export { createLegacyAttachmentMigrationScript, } from './create_legacy_attachment_migration_script.js';
18
- export { renderLegacyAttachmentMigrationScript, } from './render_legacy_attachment_migration_script.js';
7
+ export { AttachmentModel } from "./models/attachment_model.js";
8
+ export { AttachmentLinkModel } from "./models/attachment_link_model.js";
9
+ export { configureLucidAttachmentTables, } from "./schema/configure_lucid_attachment_tables.js";
10
+ export { resolveAttachmentTableNames, } from "./schema/attachment_table_names.js";
11
+ export { AttachmentSchemaService, } from "./schema/attachment_schema_service.js";
12
+ export { attachment, } from "./column/attachment_column.js";
13
+ export { attachmentRelation, attachmentsRelation, AttachmentRelation, AttachmentCollectionRelation, } from "./relations/attachment_relation.js";
14
+ export { LucidAttachmentRepository } from "./persistence/lucid_attachment_repository.js";
15
+ export { LucidAttachmentStore, } from "./persistence/lucid_attachment_store.js";
16
+ export { LucidAttachmentLifecycleService, } from "./persistence/lucid_attachment_lifecycle_service.js";
17
+ export { LucidVariantGenerationService, PersistedAttachmentNotFoundError, } from "./persistence/lucid_variant_generation_service.js";
18
+ export { createAttachmentOwnerKey, } from "./relations/attachment_owner.js";
19
+ export { createAttachmentsTableStubState, } from "./schema/attachments_table_stub.js";
20
+ export { migrateLegacyAttachment, migrateLegacyAttachmentColumn, } from "./migrations/legacy/migrate_legacy_attachment.js";
21
+ export { migrateLegacyAttachmentRecords, } from "./migrations/legacy/migrate_legacy_attachment_records.js";
22
+ export { createLegacyAttachmentMigrationStubState, } from "./migrations/legacy/legacy_attachment_migration_stub.js";
19
23
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/integrations/lucid/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AACnD,OAAO,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAA;AAC5E,OAAO,EACL,oBAAoB,GAErB,MAAM,6BAA6B,CAAA;AACpC,OAAO,EACL,+BAA+B,GAGhC,MAAM,yCAAyC,CAAA;AAChD,OAAO,EACL,6BAA6B,EAC7B,gCAAgC,GAEjC,MAAM,uCAAuC,CAAA;AAC9C,OAAO,EAAE,wBAAwB,EAAwB,MAAM,uBAAuB,CAAA;AACtF,OAAO,EACL,+BAA+B,GAGhC,MAAM,6BAA6B,CAAA;AACpC,OAAO,EACL,uBAAuB,GAKxB,MAAM,gCAAgC,CAAA;AACvC,OAAO,EACL,8BAA8B,GAK/B,MAAM,wCAAwC,CAAA;AAC/C,OAAO,EACL,qCAAqC,GAEtC,MAAM,gDAAgD,CAAA;AACvD,OAAO,EACL,qCAAqC,GAEtC,MAAM,gDAAgD,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/integrations/lucid/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,EACL,8BAA8B,GAC/B,MAAM,+CAA+C,CAAC;AACvD,OAAO,EACL,2BAA2B,GAE5B,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACL,uBAAuB,GAExB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EACL,UAAU,GAEX,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,kBAAkB,EAClB,4BAA4B,GAE7B,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,yBAAyB,EAAE,MAAM,8CAA8C,CAAC;AACzF,OAAO,EACL,oBAAoB,GAGrB,MAAM,yCAAyC,CAAC;AACjD,OAAO,EACL,+BAA+B,GAGhC,MAAM,qDAAqD,CAAC;AAC7D,OAAO,EACL,6BAA6B,EAC7B,gCAAgC,GAEjC,MAAM,mDAAmD,CAAC;AAC3D,OAAO,EACL,wBAAwB,GAEzB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACL,+BAA+B,GAGhC,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACL,uBAAuB,EACvB,6BAA6B,GAQ9B,MAAM,kDAAkD,CAAC;AAC1D,OAAO,EACL,8BAA8B,GAK/B,MAAM,0DAA0D,CAAC;AAClE,OAAO,EACL,wCAAwC,GAGzC,MAAM,yDAAyD,CAAC"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * @jrmc/adonis-attachment
3
+ *
4
+ * @license MIT
5
+ * @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
6
+ */
7
+ export type LegacyAttachmentMigrationStubOptions = {
8
+ directory: string;
9
+ defaultDisk?: string;
10
+ timestamp?: number;
11
+ };
12
+ export type LegacyAttachmentMigrationStubState = {
13
+ destination: string;
14
+ defaultDisk: string;
15
+ };
16
+ /**
17
+ * Builds the state consumed by the legacy attachment data-migration stub.
18
+ */
19
+ export declare function createLegacyAttachmentMigrationStubState(options: LegacyAttachmentMigrationStubOptions): LegacyAttachmentMigrationStubState;
20
+ //# sourceMappingURL=legacy_attachment_migration_stub.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"legacy_attachment_migration_stub.d.ts","sourceRoot":"","sources":["../../../../../../src/integrations/lucid/migrations/legacy/legacy_attachment_migration_stub.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,MAAM,MAAM,oCAAoC,GAAG;IACjD,SAAS,EAAE,MAAM,CAAA;IACjB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,MAAM,MAAM,kCAAkC,GAAG;IAC/C,WAAW,EAAE,MAAM,CAAA;IACnB,WAAW,EAAE,MAAM,CAAA;CACpB,CAAA;AAED;;GAEG;AACH,wBAAgB,wCAAwC,CACtD,OAAO,EAAE,oCAAoC,GAC5C,kCAAkC,CAOpC"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * @jrmc/adonis-attachment
3
+ *
4
+ * @license MIT
5
+ * @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
6
+ */
7
+ import { join } from 'node:path';
8
+ /**
9
+ * Builds the state consumed by the legacy attachment data-migration stub.
10
+ */
11
+ export function createLegacyAttachmentMigrationStubState(options) {
12
+ const timestamp = options.timestamp ?? Date.now();
13
+ return {
14
+ destination: join(options.directory, `${timestamp}_migrate_v5_attachments.ts`),
15
+ defaultDisk: options.defaultDisk ?? 'public',
16
+ };
17
+ }
18
+ //# sourceMappingURL=legacy_attachment_migration_stub.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"legacy_attachment_migration_stub.js","sourceRoot":"","sources":["../../../../../../src/integrations/lucid/migrations/legacy/legacy_attachment_migration_stub.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAahC;;GAEG;AACH,MAAM,UAAU,wCAAwC,CACtD,OAA6C;IAE7C,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,IAAI,CAAC,GAAG,EAAE,CAAA;IAEjD,OAAO;QACL,WAAW,EAAE,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,GAAG,SAAS,4BAA4B,CAAC;QAC9E,WAAW,EAAE,OAAO,CAAC,WAAW,IAAI,QAAQ;KAC7C,CAAA;AACH,CAAC"}
@@ -25,14 +25,11 @@ export type LegacyVariant = {
25
25
  path?: string;
26
26
  meta?: Record<string, unknown>;
27
27
  };
28
- import { type AttachmentOwner } from './attachment_owner.js';
29
- export type { AttachmentOwner } from './attachment_owner.js';
30
- export type MigratedAttachmentRow = {
28
+ import { type AttachmentOwner } from "../../relations/attachment_owner.js";
29
+ import type { Attachment } from "../../../../core/attachment.js";
30
+ export type { AttachmentOwner } from "../../relations/attachment_owner.js";
31
+ export type MigratedAttachmentBlob = {
31
32
  id: string;
32
- attachableType: string;
33
- attachableId: string;
34
- field: string;
35
- ownerKey: string | null;
36
33
  parentId: string | null;
37
34
  variantKey: string | null;
38
35
  disk: string;
@@ -44,14 +41,33 @@ export type MigratedAttachmentRow = {
44
41
  size: number;
45
42
  metadata: Record<string, unknown> | null;
46
43
  };
44
+ export type MigratedAttachmentLink = {
45
+ id: string;
46
+ attachableType: string;
47
+ attachableId: string;
48
+ field: string;
49
+ ownerKey: string | null;
50
+ position: number | null;
51
+ attachmentId: string;
52
+ };
53
+ export type MigratedAttachmentRows = {
54
+ blobs: MigratedAttachmentBlob[];
55
+ links: MigratedAttachmentLink[];
56
+ };
47
57
  export type MigrateLegacyAttachmentOptions = {
48
58
  owner: AttachmentOwner;
49
59
  defaultDisk: string;
50
60
  createId: () => string;
51
61
  };
62
+ export type MigrateLegacyAttachmentColumnOptions = Omit<MigrateLegacyAttachmentOptions, "owner">;
52
63
  /**
53
- * Converts one v5 JSON attachment document into rows for the polymorphic table.
64
+ * Converts one v5 JSON attachment document into blob and polymorphic-link rows.
54
65
  * Callers can run it from an Ace command, another ORM migration, or a one-off script.
55
66
  */
56
- export declare function migrateLegacyAttachment(value: LegacyAttachment | string, options: MigrateLegacyAttachmentOptions): MigratedAttachmentRow[];
67
+ export declare function migrateLegacyAttachment(value: LegacyAttachment | string, options: MigrateLegacyAttachmentOptions): MigratedAttachmentRows;
68
+ /**
69
+ * Converts one v5 JSON value for a retained single attachment column. Legacy
70
+ * variants require the polymorphic table and therefore cannot be kept here.
71
+ */
72
+ export declare function migrateLegacyAttachmentColumn(value: LegacyAttachment | string, options: MigrateLegacyAttachmentColumnOptions): Attachment;
57
73
  //# sourceMappingURL=migrate_legacy_attachment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migrate_legacy_attachment.d.ts","sourceRoot":"","sources":["../../../../../../src/integrations/lucid/migrations/legacy/migrate_legacy_attachment.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,QAAQ,CAAC,EAAE,aAAa,EAAE,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MA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