@solidxai/core 0.1.22-beta.2 → 0.1.22-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (284) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/controllers/media-migration-item.controller.d.ts +8 -0
  3. package/dist/controllers/media-migration-item.controller.d.ts.map +1 -0
  4. package/dist/controllers/media-migration-item.controller.js +66 -0
  5. package/dist/controllers/media-migration-item.controller.js.map +1 -0
  6. package/dist/controllers/media-migration-job.controller.d.ts +8 -0
  7. package/dist/controllers/media-migration-job.controller.d.ts.map +1 -0
  8. package/dist/controllers/media-migration-job.controller.js +66 -0
  9. package/dist/controllers/media-migration-job.controller.js.map +1 -0
  10. package/dist/controllers/media-migration.controller.d.ts +321 -0
  11. package/dist/controllers/media-migration.controller.d.ts.map +1 -0
  12. package/dist/controllers/media-migration.controller.js +197 -0
  13. package/dist/controllers/media-migration.controller.js.map +1 -0
  14. package/dist/controllers/media-migration.controller.spec.d.ts +2 -0
  15. package/dist/controllers/media-migration.controller.spec.d.ts.map +1 -0
  16. package/dist/controllers/media-migration.controller.spec.js +72 -0
  17. package/dist/controllers/media-migration.controller.spec.js.map +1 -0
  18. package/dist/dtos/create-media-migration.dto.d.ts +21 -0
  19. package/dist/dtos/create-media-migration.dto.d.ts.map +1 -0
  20. package/dist/dtos/create-media-migration.dto.js +126 -0
  21. package/dist/dtos/create-media-migration.dto.js.map +1 -0
  22. package/dist/dtos/create-media-storage-provider-metadata.dto.d.ts.map +1 -1
  23. package/dist/dtos/create-media-storage-provider-metadata.dto.js +11 -0
  24. package/dist/dtos/create-media-storage-provider-metadata.dto.js.map +1 -1
  25. package/dist/dtos/create-media-storage-provider-metadata.dto.spec.d.ts +2 -0
  26. package/dist/dtos/create-media-storage-provider-metadata.dto.spec.d.ts.map +1 -0
  27. package/dist/dtos/create-media-storage-provider-metadata.dto.spec.js +29 -0
  28. package/dist/dtos/create-media-storage-provider-metadata.dto.spec.js.map +1 -0
  29. package/dist/entities/media-migration-item.entity.d.ts +19 -0
  30. package/dist/entities/media-migration-item.entity.d.ts.map +1 -0
  31. package/dist/entities/media-migration-item.entity.js +85 -0
  32. package/dist/entities/media-migration-item.entity.js.map +1 -0
  33. package/dist/entities/media-migration-job.entity.d.ts +30 -0
  34. package/dist/entities/media-migration-job.entity.d.ts.map +1 -0
  35. package/dist/entities/media-migration-job.entity.js +131 -0
  36. package/dist/entities/media-migration-job.entity.js.map +1 -0
  37. package/dist/helpers/typeorm-db-helper.d.ts.map +1 -1
  38. package/dist/helpers/typeorm-db-helper.js +9 -0
  39. package/dist/helpers/typeorm-db-helper.js.map +1 -1
  40. package/dist/index.d.ts +3 -0
  41. package/dist/index.d.ts.map +1 -1
  42. package/dist/index.js +3 -0
  43. package/dist/index.js.map +1 -1
  44. package/dist/jobs/database/media-migration-publisher-database.service.d.ts +13 -0
  45. package/dist/jobs/database/media-migration-publisher-database.service.d.ts.map +1 -0
  46. package/dist/jobs/database/media-migration-publisher-database.service.js +39 -0
  47. package/dist/jobs/database/media-migration-publisher-database.service.js.map +1 -0
  48. package/dist/jobs/database/media-migration-queue-options-database.d.ts +8 -0
  49. package/dist/jobs/database/media-migration-queue-options-database.d.ts.map +1 -0
  50. package/dist/jobs/database/media-migration-queue-options-database.js +10 -0
  51. package/dist/jobs/database/media-migration-queue-options-database.js.map +1 -0
  52. package/dist/jobs/database/media-migration-subscriber-database.service.d.ts +21 -0
  53. package/dist/jobs/database/media-migration-subscriber-database.service.d.ts.map +1 -0
  54. package/dist/jobs/database/media-migration-subscriber-database.service.js +48 -0
  55. package/dist/jobs/database/media-migration-subscriber-database.service.js.map +1 -0
  56. package/dist/jobs/media-migration-queues.spec.d.ts +2 -0
  57. package/dist/jobs/media-migration-queues.spec.d.ts.map +1 -0
  58. package/dist/jobs/media-migration-queues.spec.js +49 -0
  59. package/dist/jobs/media-migration-queues.spec.js.map +1 -0
  60. package/dist/jobs/rabbitmq/media-migration-publisher.service.d.ts +13 -0
  61. package/dist/jobs/rabbitmq/media-migration-publisher.service.d.ts.map +1 -0
  62. package/dist/jobs/rabbitmq/media-migration-publisher.service.js +39 -0
  63. package/dist/jobs/rabbitmq/media-migration-publisher.service.js.map +1 -0
  64. package/dist/jobs/rabbitmq/media-migration-queue-options.d.ts +8 -0
  65. package/dist/jobs/rabbitmq/media-migration-queue-options.d.ts.map +1 -0
  66. package/dist/jobs/rabbitmq/media-migration-queue-options.js +10 -0
  67. package/dist/jobs/rabbitmq/media-migration-queue-options.js.map +1 -0
  68. package/dist/jobs/rabbitmq/media-migration-subscriber.service.d.ts +19 -0
  69. package/dist/jobs/rabbitmq/media-migration-subscriber.service.d.ts.map +1 -0
  70. package/dist/jobs/rabbitmq/media-migration-subscriber.service.js +45 -0
  71. package/dist/jobs/rabbitmq/media-migration-subscriber.service.js.map +1 -0
  72. package/dist/jobs/redis/media-migration-publisher-redis.service.d.ts +13 -0
  73. package/dist/jobs/redis/media-migration-publisher-redis.service.d.ts.map +1 -0
  74. package/dist/jobs/redis/media-migration-publisher-redis.service.js +39 -0
  75. package/dist/jobs/redis/media-migration-publisher-redis.service.js.map +1 -0
  76. package/dist/jobs/redis/media-migration-queue-options-redis.d.ts +8 -0
  77. package/dist/jobs/redis/media-migration-queue-options-redis.d.ts.map +1 -0
  78. package/dist/jobs/redis/media-migration-queue-options-redis.js +10 -0
  79. package/dist/jobs/redis/media-migration-queue-options-redis.js.map +1 -0
  80. package/dist/jobs/redis/media-migration-subscriber-redis.service.d.ts +19 -0
  81. package/dist/jobs/redis/media-migration-subscriber-redis.service.d.ts.map +1 -0
  82. package/dist/jobs/redis/media-migration-subscriber-redis.service.js +45 -0
  83. package/dist/jobs/redis/media-migration-subscriber-redis.service.js.map +1 -0
  84. package/dist/repository/media-migration-item.repository.d.ts +12 -0
  85. package/dist/repository/media-migration-item.repository.d.ts.map +1 -0
  86. package/dist/repository/media-migration-item.repository.js +34 -0
  87. package/dist/repository/media-migration-item.repository.js.map +1 -0
  88. package/dist/repository/media-migration-job.repository.d.ts +12 -0
  89. package/dist/repository/media-migration-job.repository.d.ts.map +1 -0
  90. package/dist/repository/media-migration-job.repository.js +34 -0
  91. package/dist/repository/media-migration-job.repository.js.map +1 -0
  92. package/dist/resources/agent-embed/solid-agent-embed.js +2 -1
  93. package/dist/seeders/media-migration-metadata.spec.d.ts +2 -0
  94. package/dist/seeders/media-migration-metadata.spec.d.ts.map +1 -0
  95. package/dist/seeders/media-migration-metadata.spec.js +119 -0
  96. package/dist/seeders/media-migration-metadata.spec.js.map +1 -0
  97. package/dist/seeders/seed-data/solid-core-metadata.json +2279 -1143
  98. package/dist/services/file/disk-file.service.d.ts +3 -0
  99. package/dist/services/file/disk-file.service.d.ts.map +1 -1
  100. package/dist/services/file/disk-file.service.js +12 -0
  101. package/dist/services/file/disk-file.service.js.map +1 -1
  102. package/dist/services/file/file-service.interface.d.ts +1 -0
  103. package/dist/services/file/file-service.interface.d.ts.map +1 -1
  104. package/dist/services/file/file-service.interface.js.map +1 -1
  105. package/dist/services/file/multipart-part-size.d.ts +3 -0
  106. package/dist/services/file/multipart-part-size.d.ts.map +1 -0
  107. package/dist/services/file/multipart-part-size.js +16 -0
  108. package/dist/services/file/multipart-part-size.js.map +1 -0
  109. package/dist/services/file/multipart-part-size.spec.d.ts +2 -0
  110. package/dist/services/file/multipart-part-size.spec.d.ts.map +1 -0
  111. package/dist/services/file/multipart-part-size.spec.js +25 -0
  112. package/dist/services/file/multipart-part-size.spec.js.map +1 -0
  113. package/dist/services/file/s3-file.service.d.ts +5 -0
  114. package/dist/services/file/s3-file.service.d.ts.map +1 -1
  115. package/dist/services/file/s3-file.service.js +42 -12
  116. package/dist/services/file/s3-file.service.js.map +1 -1
  117. package/dist/services/file/s3-file.service.spec.d.ts +2 -0
  118. package/dist/services/file/s3-file.service.spec.d.ts.map +1 -0
  119. package/dist/services/file/s3-file.service.spec.js +54 -0
  120. package/dist/services/file/s3-file.service.spec.js.map +1 -0
  121. package/dist/services/media-download-url.service.d.ts +5 -2
  122. package/dist/services/media-download-url.service.d.ts.map +1 -1
  123. package/dist/services/media-download-url.service.js +22 -1
  124. package/dist/services/media-download-url.service.js.map +1 -1
  125. package/dist/services/media-download-url.service.spec.d.ts +2 -0
  126. package/dist/services/media-download-url.service.spec.d.ts.map +1 -0
  127. package/dist/services/media-download-url.service.spec.js +55 -0
  128. package/dist/services/media-download-url.service.spec.js.map +1 -0
  129. package/dist/services/media-file-storage.service.d.ts +17 -0
  130. package/dist/services/media-file-storage.service.d.ts.map +1 -0
  131. package/dist/services/media-file-storage.service.js +73 -0
  132. package/dist/services/media-file-storage.service.js.map +1 -0
  133. package/dist/services/media-file-storage.service.spec.d.ts +2 -0
  134. package/dist/services/media-file-storage.service.spec.d.ts.map +1 -0
  135. package/dist/services/media-file-storage.service.spec.js +46 -0
  136. package/dist/services/media-file-storage.service.spec.js.map +1 -0
  137. package/dist/services/media-migration/media-location.d.ts +20 -0
  138. package/dist/services/media-migration/media-location.d.ts.map +1 -0
  139. package/dist/services/media-migration/media-location.js +140 -0
  140. package/dist/services/media-migration/media-location.js.map +1 -0
  141. package/dist/services/media-migration/media-location.spec.d.ts +2 -0
  142. package/dist/services/media-migration/media-location.spec.d.ts.map +1 -0
  143. package/dist/services/media-migration/media-location.spec.js +148 -0
  144. package/dist/services/media-migration/media-location.spec.js.map +1 -0
  145. package/dist/services/media-migration/media-migration-runner.service.d.ts +44 -0
  146. package/dist/services/media-migration/media-migration-runner.service.d.ts.map +1 -0
  147. package/dist/services/media-migration/media-migration-runner.service.js +434 -0
  148. package/dist/services/media-migration/media-migration-runner.service.js.map +1 -0
  149. package/dist/services/media-migration/media-migration-scope.d.ts +21 -0
  150. package/dist/services/media-migration/media-migration-scope.d.ts.map +1 -0
  151. package/dist/services/media-migration/media-migration-scope.js +128 -0
  152. package/dist/services/media-migration/media-migration-scope.js.map +1 -0
  153. package/dist/services/media-migration/media-migration.integration.spec.d.ts +2 -0
  154. package/dist/services/media-migration/media-migration.integration.spec.d.ts.map +1 -0
  155. package/dist/services/media-migration/media-migration.integration.spec.js +688 -0
  156. package/dist/services/media-migration/media-migration.integration.spec.js.map +1 -0
  157. package/dist/services/media-migration/media-migration.service.d.ts +86 -0
  158. package/dist/services/media-migration/media-migration.service.d.ts.map +1 -0
  159. package/dist/services/media-migration/media-migration.service.js +468 -0
  160. package/dist/services/media-migration/media-migration.service.js.map +1 -0
  161. package/dist/services/media-migration/media-transfer.service.d.ts +26 -0
  162. package/dist/services/media-migration/media-transfer.service.d.ts.map +1 -0
  163. package/dist/services/media-migration/media-transfer.service.js +274 -0
  164. package/dist/services/media-migration/media-transfer.service.js.map +1 -0
  165. package/dist/services/media-migration/media-transfer.service.spec.d.ts +2 -0
  166. package/dist/services/media-migration/media-transfer.service.spec.d.ts.map +1 -0
  167. package/dist/services/media-migration/media-transfer.service.spec.js +266 -0
  168. package/dist/services/media-migration/media-transfer.service.spec.js.map +1 -0
  169. package/dist/services/media-migration/migration-error.d.ts +10 -0
  170. package/dist/services/media-migration/migration-error.d.ts.map +1 -0
  171. package/dist/services/media-migration/migration-error.js +40 -0
  172. package/dist/services/media-migration/migration-error.js.map +1 -0
  173. package/dist/services/media-migration/migration-error.spec.d.ts +2 -0
  174. package/dist/services/media-migration/migration-error.spec.d.ts.map +1 -0
  175. package/dist/services/media-migration/migration-error.spec.js +37 -0
  176. package/dist/services/media-migration/migration-error.spec.js.map +1 -0
  177. package/dist/services/media-migration-item.service.d.ts +12 -0
  178. package/dist/services/media-migration-item.service.d.ts.map +1 -0
  179. package/dist/services/media-migration-item.service.js +38 -0
  180. package/dist/services/media-migration-item.service.js.map +1 -0
  181. package/dist/services/media-migration-job.service.d.ts +12 -0
  182. package/dist/services/media-migration-job.service.d.ts.map +1 -0
  183. package/dist/services/media-migration-job.service.js +38 -0
  184. package/dist/services/media-migration-job.service.js.map +1 -0
  185. package/dist/services/media-storage-provider-changes.d.ts +15 -0
  186. package/dist/services/media-storage-provider-changes.d.ts.map +1 -0
  187. package/dist/services/media-storage-provider-changes.js +39 -0
  188. package/dist/services/media-storage-provider-changes.js.map +1 -0
  189. package/dist/services/media-storage-provider-changes.spec.d.ts +2 -0
  190. package/dist/services/media-storage-provider-changes.spec.d.ts.map +1 -0
  191. package/dist/services/media-storage-provider-changes.spec.js +47 -0
  192. package/dist/services/media-storage-provider-changes.spec.js.map +1 -0
  193. package/dist/services/media-storage-provider-metadata.service.d.ts +6 -1
  194. package/dist/services/media-storage-provider-metadata.service.d.ts.map +1 -1
  195. package/dist/services/media-storage-provider-metadata.service.js +59 -5
  196. package/dist/services/media-storage-provider-metadata.service.js.map +1 -1
  197. package/dist/services/media-storage-provider-metadata.service.spec.d.ts +2 -0
  198. package/dist/services/media-storage-provider-metadata.service.spec.d.ts.map +1 -0
  199. package/dist/services/media-storage-provider-metadata.service.spec.js +88 -0
  200. package/dist/services/media-storage-provider-metadata.service.spec.js.map +1 -0
  201. package/dist/services/media.service.d.ts +3 -1
  202. package/dist/services/media.service.d.ts.map +1 -1
  203. package/dist/services/media.service.js +12 -35
  204. package/dist/services/media.service.js.map +1 -1
  205. package/dist/services/mediaStorageProviders/file-s3-storage-provider.d.ts +4 -1
  206. package/dist/services/mediaStorageProviders/file-s3-storage-provider.d.ts.map +1 -1
  207. package/dist/services/mediaStorageProviders/file-s3-storage-provider.js +33 -23
  208. package/dist/services/mediaStorageProviders/file-s3-storage-provider.js.map +1 -1
  209. package/dist/services/mediaStorageProviders/file-s3-storage-provider.spec.d.ts +2 -0
  210. package/dist/services/mediaStorageProviders/file-s3-storage-provider.spec.d.ts.map +1 -0
  211. package/dist/services/mediaStorageProviders/file-s3-storage-provider.spec.js +63 -0
  212. package/dist/services/mediaStorageProviders/file-s3-storage-provider.spec.js.map +1 -0
  213. package/dist/services/mediaStorageProviders/file-storage-provider.d.ts +3 -1
  214. package/dist/services/mediaStorageProviders/file-storage-provider.d.ts.map +1 -1
  215. package/dist/services/mediaStorageProviders/file-storage-provider.js +8 -9
  216. package/dist/services/mediaStorageProviders/file-storage-provider.js.map +1 -1
  217. package/dist/solid-core.module.d.ts.map +1 -1
  218. package/dist/solid-core.module.js +38 -0
  219. package/dist/solid-core.module.js.map +1 -1
  220. package/dist/transformers/typeorm/bigint-to-number-transformer.d.ts +3 -0
  221. package/dist/transformers/typeorm/bigint-to-number-transformer.d.ts.map +1 -0
  222. package/dist/transformers/typeorm/bigint-to-number-transformer.js +8 -0
  223. package/dist/transformers/typeorm/bigint-to-number-transformer.js.map +1 -0
  224. package/package.json +2 -1
  225. package/postman/media-migration.postman_collection.json +519 -0
  226. package/postman/media-migration.test.postman_collection.json +1013 -0
  227. package/resources/agent-embed/solid-agent-embed.js +2 -1
  228. package/src/controllers/media-migration-item.controller.ts +32 -0
  229. package/src/controllers/media-migration-job.controller.ts +32 -0
  230. package/src/controllers/media-migration.controller.spec.ts +85 -0
  231. package/src/controllers/media-migration.controller.ts +123 -0
  232. package/src/dtos/create-media-migration.dto.ts +95 -0
  233. package/src/dtos/create-media-storage-provider-metadata.dto.spec.ts +35 -0
  234. package/src/dtos/create-media-storage-provider-metadata.dto.ts +9 -0
  235. package/src/entities/media-migration-item.entity.ts +67 -0
  236. package/src/entities/media-migration-job.entity.ts +103 -0
  237. package/src/helpers/typeorm-db-helper.ts +12 -0
  238. package/src/index.ts +3 -0
  239. package/src/jobs/database/media-migration-publisher-database.service.ts +24 -0
  240. package/src/jobs/database/media-migration-queue-options-database.ts +9 -0
  241. package/src/jobs/database/media-migration-subscriber-database.service.ts +37 -0
  242. package/src/jobs/media-migration-queues.spec.ts +53 -0
  243. package/src/jobs/rabbitmq/media-migration-publisher.service.ts +24 -0
  244. package/src/jobs/rabbitmq/media-migration-queue-options.ts +9 -0
  245. package/src/jobs/rabbitmq/media-migration-subscriber.service.ts +31 -0
  246. package/src/jobs/redis/media-migration-publisher-redis.service.ts +24 -0
  247. package/src/jobs/redis/media-migration-queue-options-redis.ts +9 -0
  248. package/src/jobs/redis/media-migration-subscriber-redis.service.ts +31 -0
  249. package/src/repository/media-migration-item.repository.ts +17 -0
  250. package/src/repository/media-migration-job.repository.ts +17 -0
  251. package/src/seeders/media-migration-metadata.spec.ts +97 -0
  252. package/src/seeders/seed-data/solid-core-metadata.json +2279 -1143
  253. package/src/services/file/disk-file.service.ts +16 -0
  254. package/src/services/file/file-service.interface.ts +2 -0
  255. package/src/services/file/multipart-part-size.spec.ts +26 -0
  256. package/src/services/file/multipart-part-size.ts +18 -0
  257. package/src/services/file/s3-file.service.spec.ts +65 -0
  258. package/src/services/file/s3-file.service.ts +56 -15
  259. package/src/services/media-download-url.service.spec.ts +62 -0
  260. package/src/services/media-download-url.service.ts +33 -2
  261. package/src/services/media-file-storage.service.spec.ts +51 -0
  262. package/src/services/media-file-storage.service.ts +75 -0
  263. package/src/services/media-migration/media-location.spec.ts +130 -0
  264. package/src/services/media-migration/media-location.ts +149 -0
  265. package/src/services/media-migration/media-migration-runner.service.ts +563 -0
  266. package/src/services/media-migration/media-migration-scope.ts +136 -0
  267. package/src/services/media-migration/media-migration.integration.spec.ts +802 -0
  268. package/src/services/media-migration/media-migration.service.ts +576 -0
  269. package/src/services/media-migration/media-transfer.service.spec.ts +288 -0
  270. package/src/services/media-migration/media-transfer.service.ts +285 -0
  271. package/src/services/media-migration/migration-error.spec.ts +41 -0
  272. package/src/services/media-migration/migration-error.ts +70 -0
  273. package/src/services/media-migration-item.service.ts +20 -0
  274. package/src/services/media-migration-job.service.ts +20 -0
  275. package/src/services/media-storage-provider-changes.spec.ts +55 -0
  276. package/src/services/media-storage-provider-changes.ts +70 -0
  277. package/src/services/media-storage-provider-metadata.service.spec.ts +99 -0
  278. package/src/services/media-storage-provider-metadata.service.ts +71 -4
  279. package/src/services/media.service.ts +10 -50
  280. package/src/services/mediaStorageProviders/file-s3-storage-provider.spec.ts +69 -0
  281. package/src/services/mediaStorageProviders/file-s3-storage-provider.ts +40 -30
  282. package/src/services/mediaStorageProviders/file-storage-provider.ts +8 -9
  283. package/src/solid-core.module.ts +38 -0
  284. package/src/transformers/typeorm/bigint-to-number-transformer.ts +7 -0
@@ -0,0 +1,197 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ 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;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.MediaMigrationController = void 0;
16
+ const openapi = require("@nestjs/swagger");
17
+ const common_1 = require("@nestjs/common");
18
+ const swagger_1 = require("@nestjs/swagger");
19
+ const typeorm_1 = require("@nestjs/typeorm");
20
+ const typeorm_2 = require("typeorm");
21
+ const create_media_migration_dto_1 = require("../dtos/create-media-migration.dto");
22
+ const media_migration_item_entity_1 = require("../entities/media-migration-item.entity");
23
+ const media_migration_job_entity_1 = require("../entities/media-migration-job.entity");
24
+ const media_migration_service_1 = require("../services/media-migration/media-migration.service");
25
+ function withProgress(job) {
26
+ const done = (job.migratedCount ?? 0) + (job.failedCount ?? 0) + (job.skippedCount ?? 0);
27
+ const progressPercent = job.totalCount > 0
28
+ ? Math.min(100, Math.floor((done / job.totalCount) * 100))
29
+ : (job.status === 'completed' ? 100 : 0);
30
+ return { ...job, progressPercent };
31
+ }
32
+ let MediaMigrationController = class MediaMigrationController {
33
+ constructor(service, dataSource) {
34
+ this.service = service;
35
+ this.dataSource = dataSource;
36
+ }
37
+ preview(dto) {
38
+ return this.service.preview(dto);
39
+ }
40
+ async create(dto) {
41
+ return withProgress(await this.service.create(dto));
42
+ }
43
+ async list(limit = 20, offset = 0) {
44
+ const [records, total] = await this.dataSource.getRepository(media_migration_job_entity_1.MediaMigrationJob).findAndCount({
45
+ relations: ['sourceProvider', 'targetProvider'],
46
+ order: { id: 'DESC' },
47
+ take: Math.min(Math.max(+limit, 1), 100),
48
+ skip: Math.max(+offset, 0),
49
+ });
50
+ return { totalRecords: total, records: records.map(withProgress) };
51
+ }
52
+ async findOne(id) {
53
+ const job = await this.dataSource.getRepository(media_migration_job_entity_1.MediaMigrationJob).findOne({
54
+ where: { id },
55
+ relations: ['sourceProvider', 'targetProvider'],
56
+ });
57
+ if (!job) {
58
+ throw new common_1.NotFoundException(`Media migration job #${id} not found`);
59
+ }
60
+ return withProgress(job);
61
+ }
62
+ async items(id, status, limit = 50, offset = 0) {
63
+ const [records, total] = await this.dataSource.getRepository(media_migration_item_entity_1.MediaMigrationItem).findAndCount({
64
+ where: { job: { id }, ...(status ? { status } : {}) },
65
+ order: { id: 'ASC' },
66
+ take: Math.min(Math.max(+limit, 1), 200),
67
+ skip: Math.max(+offset, 0),
68
+ });
69
+ return { totalRecords: total, records };
70
+ }
71
+ async cancel(id) {
72
+ return withProgress(await this.service.cancel(id));
73
+ }
74
+ async resume(id) {
75
+ return withProgress(await this.service.resume(id));
76
+ }
77
+ async retryFailed(id) {
78
+ return withProgress(await this.service.retryFailed(id));
79
+ }
80
+ async rollback(id) {
81
+ const { job, targetFilesLeft } = await this.service.rollback(id);
82
+ return { ...withProgress(job), targetFilesLeft };
83
+ }
84
+ cleanup(id, dto) {
85
+ return this.service.cleanup(id, dto.confirm);
86
+ }
87
+ };
88
+ exports.MediaMigrationController = MediaMigrationController;
89
+ __decorate([
90
+ (0, swagger_1.ApiBearerAuth)('jwt'),
91
+ (0, common_1.Post)('preview'),
92
+ openapi.ApiResponse({ status: 201 }),
93
+ __param(0, (0, common_1.Body)()),
94
+ __metadata("design:type", Function),
95
+ __metadata("design:paramtypes", [create_media_migration_dto_1.CreateMediaMigrationDto]),
96
+ __metadata("design:returntype", void 0)
97
+ ], MediaMigrationController.prototype, "preview", null);
98
+ __decorate([
99
+ (0, swagger_1.ApiBearerAuth)('jwt'),
100
+ (0, common_1.Post)(),
101
+ (0, common_1.HttpCode)(202),
102
+ openapi.ApiResponse({ status: 202 }),
103
+ __param(0, (0, common_1.Body)()),
104
+ __metadata("design:type", Function),
105
+ __metadata("design:paramtypes", [create_media_migration_dto_1.CreateMediaMigrationDto]),
106
+ __metadata("design:returntype", Promise)
107
+ ], MediaMigrationController.prototype, "create", null);
108
+ __decorate([
109
+ (0, swagger_1.ApiBearerAuth)('jwt'),
110
+ (0, swagger_1.ApiQuery)({ name: 'limit', required: false, type: Number }),
111
+ (0, swagger_1.ApiQuery)({ name: 'offset', required: false, type: Number }),
112
+ (0, common_1.Get)(),
113
+ openapi.ApiResponse({ status: 200 }),
114
+ __param(0, (0, common_1.Query)('limit')),
115
+ __param(1, (0, common_1.Query)('offset')),
116
+ __metadata("design:type", Function),
117
+ __metadata("design:paramtypes", [Object, Object]),
118
+ __metadata("design:returntype", Promise)
119
+ ], MediaMigrationController.prototype, "list", null);
120
+ __decorate([
121
+ (0, swagger_1.ApiBearerAuth)('jwt'),
122
+ (0, common_1.Get)(':id'),
123
+ openapi.ApiResponse({ status: 200 }),
124
+ __param(0, (0, common_1.Param)('id', common_1.ParseIntPipe)),
125
+ __metadata("design:type", Function),
126
+ __metadata("design:paramtypes", [Number]),
127
+ __metadata("design:returntype", Promise)
128
+ ], MediaMigrationController.prototype, "findOne", null);
129
+ __decorate([
130
+ (0, swagger_1.ApiBearerAuth)('jwt'),
131
+ (0, swagger_1.ApiQuery)({ name: 'status', required: false, type: String }),
132
+ (0, swagger_1.ApiQuery)({ name: 'limit', required: false, type: Number }),
133
+ (0, swagger_1.ApiQuery)({ name: 'offset', required: false, type: Number }),
134
+ (0, common_1.Get)(':id/items'),
135
+ openapi.ApiResponse({ status: 200 }),
136
+ __param(0, (0, common_1.Param)('id', common_1.ParseIntPipe)),
137
+ __param(1, (0, common_1.Query)('status')),
138
+ __param(2, (0, common_1.Query)('limit')),
139
+ __param(3, (0, common_1.Query)('offset')),
140
+ __metadata("design:type", Function),
141
+ __metadata("design:paramtypes", [Number, String, Object, Object]),
142
+ __metadata("design:returntype", Promise)
143
+ ], MediaMigrationController.prototype, "items", null);
144
+ __decorate([
145
+ (0, swagger_1.ApiBearerAuth)('jwt'),
146
+ (0, common_1.Post)(':id/cancel'),
147
+ openapi.ApiResponse({ status: 201 }),
148
+ __param(0, (0, common_1.Param)('id', common_1.ParseIntPipe)),
149
+ __metadata("design:type", Function),
150
+ __metadata("design:paramtypes", [Number]),
151
+ __metadata("design:returntype", Promise)
152
+ ], MediaMigrationController.prototype, "cancel", null);
153
+ __decorate([
154
+ (0, swagger_1.ApiBearerAuth)('jwt'),
155
+ (0, common_1.Post)(':id/resume'),
156
+ openapi.ApiResponse({ status: 201 }),
157
+ __param(0, (0, common_1.Param)('id', common_1.ParseIntPipe)),
158
+ __metadata("design:type", Function),
159
+ __metadata("design:paramtypes", [Number]),
160
+ __metadata("design:returntype", Promise)
161
+ ], MediaMigrationController.prototype, "resume", null);
162
+ __decorate([
163
+ (0, swagger_1.ApiBearerAuth)('jwt'),
164
+ (0, common_1.Post)(':id/retry-failed'),
165
+ openapi.ApiResponse({ status: 201 }),
166
+ __param(0, (0, common_1.Param)('id', common_1.ParseIntPipe)),
167
+ __metadata("design:type", Function),
168
+ __metadata("design:paramtypes", [Number]),
169
+ __metadata("design:returntype", Promise)
170
+ ], MediaMigrationController.prototype, "retryFailed", null);
171
+ __decorate([
172
+ (0, swagger_1.ApiBearerAuth)('jwt'),
173
+ (0, common_1.Post)(':id/rollback'),
174
+ openapi.ApiResponse({ status: 201 }),
175
+ __param(0, (0, common_1.Param)('id', common_1.ParseIntPipe)),
176
+ __metadata("design:type", Function),
177
+ __metadata("design:paramtypes", [Number]),
178
+ __metadata("design:returntype", Promise)
179
+ ], MediaMigrationController.prototype, "rollback", null);
180
+ __decorate([
181
+ (0, swagger_1.ApiBearerAuth)('jwt'),
182
+ (0, common_1.Post)(':id/cleanup'),
183
+ openapi.ApiResponse({ status: 201 }),
184
+ __param(0, (0, common_1.Param)('id', common_1.ParseIntPipe)),
185
+ __param(1, (0, common_1.Body)()),
186
+ __metadata("design:type", Function),
187
+ __metadata("design:paramtypes", [Number, create_media_migration_dto_1.CleanupMediaMigrationDto]),
188
+ __metadata("design:returntype", void 0)
189
+ ], MediaMigrationController.prototype, "cleanup", null);
190
+ exports.MediaMigrationController = MediaMigrationController = __decorate([
191
+ (0, swagger_1.ApiTags)('Solid Core'),
192
+ (0, common_1.Controller)('media-migration'),
193
+ __param(1, (0, typeorm_1.InjectDataSource)()),
194
+ __metadata("design:paramtypes", [media_migration_service_1.MediaMigrationService,
195
+ typeorm_2.DataSource])
196
+ ], MediaMigrationController);
197
+ //# sourceMappingURL=media-migration.controller.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"media-migration.controller.js","sourceRoot":"","sources":["../../src/controllers/media-migration.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAsH;AACtH,6CAAmE;AACnE,6CAAmD;AACnD,qCAAqC;AACrC,mFAAuG;AACvG,yFAAuG;AACvG,uFAA2E;AAC3E,iGAA4F;AAG5F,SAAS,YAAY,CAAC,GAAsB;IAC1C,MAAM,IAAI,GAAG,CAAC,GAAG,CAAC,aAAa,IAAI,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,WAAW,IAAI,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,YAAY,IAAI,CAAC,CAAC,CAAC;IACzF,MAAM,eAAe,GAAG,GAAG,CAAC,UAAU,GAAG,CAAC;QACxC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,CA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B,IAAA,aAAI,EAAC,YAAY,CAAC;;IACL,WAAA,IAAA,cAAK,EAAC,IAAI,EAAE,qBAAY,CAAC,CAAA;;;;sDAEtC;AAIK;IAFL,IAAA,uBAAa,EAAC,KAAK,CAAC;IACpB,IAAA,aAAI,EAAC,kBAAkB,CAAC;;IACN,WAAA,IAAA,cAAK,EAAC,IAAI,EAAE,qBAAY,CAAC,CAAA;;;;2DAE3C;AAIK;IAFL,IAAA,uBAAa,EAAC,KAAK,CAAC;IACpB,IAAA,aAAI,EAAC,cAAc,CAAC;;IACL,WAAA,IAAA,cAAK,EAAC,IAAI,EAAE,qBAAY,CAAC,CAAA;;;;wDAGxC;AAID;IAFC,IAAA,uBAAa,EAAC,KAAK,CAAC;IACpB,IAAA,aAAI,EAAC,aAAa,CAAC;;IACX,WAAA,IAAA,cAAK,EAAC,IAAI,EAAE,qBAAY,CAAC,CAAA;IAAc,WAAA,IAAA,aAAI,GAAE,CAAA;;6CAAM,qDAAwB;;uDAEnF;mCAhGU,wBAAwB;IAFpC,IAAA,iBAAO,EAAC,YAAY,CAAC;IACrB,IAAA,mBAAU,EAAC,iBAAiB,CAAC;IAIzB,WAAA,IAAA,0BAAgB,GAAE,CAAA;qCADO,+CAAqB;QAElB,oBAAU;GAJ9B,wBAAwB,CAiGpC","sourcesContent":["import { Body, Controller, Get, HttpCode, NotFoundException, Param, ParseIntPipe, Post, Query } from '@nestjs/common';\nimport { ApiBearerAuth, ApiQuery, ApiTags } from '@nestjs/swagger';\nimport { InjectDataSource } from '@nestjs/typeorm';\nimport { DataSource } from 'typeorm';\nimport { CleanupMediaMigrationDto, CreateMediaMigrationDto } from '../dtos/create-media-migration.dto';\nimport { MediaMigrationItem, MediaMigrationItemStatus } from '../entities/media-migration-item.entity';\nimport { MediaMigrationJob } from '../entities/media-migration-job.entity';\nimport { MediaMigrationService } from '../services/media-migration/media-migration.service';\n\n/** Progress as a percentage of the files in scope that have reached a final result. */\nfunction withProgress(job: MediaMigrationJob) {\n const done = (job.migratedCount ?? 0) + (job.failedCount ?? 0) + (job.skippedCount ?? 0);\n const progressPercent = job.totalCount > 0\n ? Math.min(100, Math.floor((done / job.totalCount) * 100))\n : (job.status === 'completed' ? 100 : 0);\n return { ...job, progressPercent };\n}\n\n/**\n * Media migration over HTTP. Access follows the usual permission rules: admins are granted these\n * methods automatically by the permission seeder. Nothing here runs a migration directly; start and\n * control are queued, and the job's own status shows what happens.\n */\n@ApiTags('Solid Core')\n@Controller('media-migration')\nexport class MediaMigrationController {\n constructor(\n private readonly service: MediaMigrationService,\n @InjectDataSource()\n private readonly dataSource: DataSource,\n ) { }\n\n @ApiBearerAuth('jwt')\n @Post('preview')\n preview(@Body() dto: CreateMediaMigrationDto) {\n return this.service.preview(dto);\n }\n\n @ApiBearerAuth('jwt')\n @Post()\n @HttpCode(202)\n async create(@Body() dto: CreateMediaMigrationDto) {\n return withProgress(await this.service.create(dto));\n }\n\n @ApiBearerAuth('jwt')\n @ApiQuery({ name: 'limit', required: false, type: Number })\n @ApiQuery({ name: 'offset', required: false, type: Number })\n @Get()\n async list(@Query('limit') limit = 20, @Query('offset') offset = 0) {\n const [records, total] = await this.dataSource.getRepository(MediaMigrationJob).findAndCount({\n relations: ['sourceProvider', 'targetProvider'],\n order: { id: 'DESC' },\n take: Math.min(Math.max(+limit, 1), 100),\n skip: Math.max(+offset, 0),\n });\n return { totalRecords: total, records: records.map(withProgress) };\n }\n\n @ApiBearerAuth('jwt')\n @Get(':id')\n async findOne(@Param('id', ParseIntPipe) id: number) {\n const job = await this.dataSource.getRepository(MediaMigrationJob).findOne({\n where: { id },\n relations: ['sourceProvider', 'targetProvider'],\n });\n if (!job) {\n throw new NotFoundException(`Media migration job #${id} not found`);\n }\n return withProgress(job);\n }\n\n @ApiBearerAuth('jwt')\n @ApiQuery({ name: 'status', required: false, type: String })\n @ApiQuery({ name: 'limit', required: false, type: Number })\n @ApiQuery({ name: 'offset', required: false, type: Number })\n @Get(':id/items')\n async items(\n @Param('id', ParseIntPipe) id: number,\n @Query('status') status?: MediaMigrationItemStatus,\n @Query('limit') limit = 50,\n @Query('offset') offset = 0,\n ) {\n const [records, total] = await this.dataSource.getRepository(MediaMigrationItem).findAndCount({\n where: { job: { id }, ...(status ? { status } : {}) },\n order: { id: 'ASC' },\n take: Math.min(Math.max(+limit, 1), 200),\n skip: Math.max(+offset, 0),\n });\n return { totalRecords: total, records };\n }\n\n @ApiBearerAuth('jwt')\n @Post(':id/cancel')\n async cancel(@Param('id', ParseIntPipe) id: number) {\n return withProgress(await this.service.cancel(id));\n }\n\n @ApiBearerAuth('jwt')\n @Post(':id/resume')\n async resume(@Param('id', ParseIntPipe) id: number) {\n return withProgress(await this.service.resume(id));\n }\n\n @ApiBearerAuth('jwt')\n @Post(':id/retry-failed')\n async retryFailed(@Param('id', ParseIntPipe) id: number) {\n return withProgress(await this.service.retryFailed(id));\n }\n\n @ApiBearerAuth('jwt')\n @Post(':id/rollback')\n async rollback(@Param('id', ParseIntPipe) id: number) {\n const { job, targetFilesLeft } = await this.service.rollback(id);\n return { ...withProgress(job), targetFilesLeft };\n }\n\n @ApiBearerAuth('jwt')\n @Post(':id/cleanup')\n cleanup(@Param('id', ParseIntPipe) id: number, @Body() dto: CleanupMediaMigrationDto) {\n return this.service.cleanup(id, dto.confirm);\n }\n}\n"]}
@@ -0,0 +1,2 @@
1
+ import 'reflect-metadata';
2
+ //# sourceMappingURL=media-migration.controller.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"media-migration.controller.spec.d.ts","sourceRoot":"","sources":["../../src/controllers/media-migration.controller.spec.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC"}
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ require("reflect-metadata");
4
+ const class_validator_1 = require("class-validator");
5
+ const class_transformer_1 = require("class-transformer");
6
+ const constants_1 = require("@nestjs/common/constants");
7
+ const common_1 = require("@nestjs/common");
8
+ const media_migration_controller_1 = require("./media-migration.controller");
9
+ const create_media_migration_dto_1 = require("../dtos/create-media-migration.dto");
10
+ const routes = (method) => Object.getOwnPropertyNames(method.prototype)
11
+ .filter(name => name !== 'constructor')
12
+ .map(name => ({
13
+ name,
14
+ method: Reflect.getMetadata(constants_1.METHOD_METADATA, method.prototype[name]),
15
+ path: Reflect.getMetadata(constants_1.PATH_METADATA, method.prototype[name]),
16
+ }));
17
+ describe('MediaMigrationController routes', () => {
18
+ const found = routes(media_migration_controller_1.MediaMigrationController);
19
+ const has = (method, path) => found.some(route => route.method === method && route.path === path);
20
+ it('exposes every endpoint in the migration spec', () => {
21
+ expect(has(common_1.RequestMethod.POST, 'preview')).toBe(true);
22
+ expect(has(common_1.RequestMethod.POST, '/')).toBe(true);
23
+ expect(has(common_1.RequestMethod.GET, '/')).toBe(true);
24
+ expect(has(common_1.RequestMethod.GET, ':id')).toBe(true);
25
+ expect(has(common_1.RequestMethod.GET, ':id/items')).toBe(true);
26
+ for (const action of ['cancel', 'resume', 'retry-failed', 'rollback', 'cleanup']) {
27
+ expect(has(common_1.RequestMethod.POST, `:id/${action}`)).toBe(true);
28
+ }
29
+ });
30
+ it('gives every method its own name, so the permission check can tell them apart', () => {
31
+ const names = found.map(route => route.name);
32
+ expect(new Set(names).size).toBe(names.length);
33
+ });
34
+ });
35
+ describe('request bodies', () => {
36
+ const create = (body) => (0, class_validator_1.validateSync)((0, class_transformer_1.plainToInstance)(create_media_migration_dto_1.CreateMediaMigrationDto, body, { enableImplicitConversion: true }));
37
+ it('accepts a whole-provider migration by name', () => {
38
+ expect(create({ sourceProviderName: 'fs-public', targetProviderName: 'aws-main' })).toEqual([]);
39
+ });
40
+ it('accepts numbers sent as text, as multipart and query forms do', () => {
41
+ expect(create({ sourceProviderId: '1', targetProviderId: '3', fieldMetadataIds: ['45', '46'] })).toEqual([]);
42
+ });
43
+ it('rejects a provider id that is not a whole number', () => {
44
+ expect(create({ sourceProviderId: 'abc' }).map(error => error.property)).toContain('sourceProviderId');
45
+ });
46
+ it('rejects a scope list that contains something other than whole numbers', () => {
47
+ expect(create({ fieldMetadataIds: [1, 'x'] }).map(error => error.property)).toContain('fieldMetadataIds');
48
+ });
49
+ it('reads the text "false" for overwriteExisting as false, not true', () => {
50
+ const dto = (0, class_transformer_1.plainToInstance)(create_media_migration_dto_1.CreateMediaMigrationDto, { overwriteExisting: 'false' }, { enableImplicitConversion: true });
51
+ expect(dto.overwriteExisting).toBe(false);
52
+ expect((0, class_validator_1.validateSync)(dto)).toEqual([]);
53
+ });
54
+ it('accepts model and field user keys', () => {
55
+ expect(create({ modelUserKeys: ['product'], fieldUserKeys: [{ modelUserKey: 'product', fieldUserKey: 'photo' }] })).toEqual([]);
56
+ });
57
+ it('requires a field user key to name its model, since field names repeat across models', () => {
58
+ const errors = create({ fieldUserKeys: [{ fieldUserKey: 'photo' }] });
59
+ expect(errors.length).toBeGreaterThan(0);
60
+ });
61
+ it('rejects a model user key that is not text', () => {
62
+ expect(create({ modelUserKeys: [42] }).map(error => error.property)).toContain('modelUserKeys');
63
+ });
64
+ it('no longer accepts repointFields', () => {
65
+ expect(Object.keys(new create_media_migration_dto_1.CreateMediaMigrationDto())).not.toContain('repointFields');
66
+ });
67
+ it('requires the confirmation text to be given for cleanup', () => {
68
+ const cleanup = (0, class_transformer_1.plainToInstance)(create_media_migration_dto_1.CleanupMediaMigrationDto, {});
69
+ expect((0, class_validator_1.validateSync)(cleanup).map(error => error.property)).toContain('confirm');
70
+ });
71
+ });
72
+ //# sourceMappingURL=media-migration.controller.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"media-migration.controller.spec.js","sourceRoot":"","sources":["../../src/controllers/media-migration.controller.spec.ts"],"names":[],"mappings":";;AAAA,4BAA0B;AAC1B,qDAA+C;AAC/C,yDAAoD;AACpD,wDAA0E;AAC1E,2CAA+C;AAC/C,6EAAwE;AACxE,mFAAuG;AAEvG,MAAM,MAAM,GAAG,CAAC,MAAW,EAAE,EAAE,CA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EAAE,CAAC,CAAC;IAClI,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,qFAAqF,EAAE,GAAG,EAAE;QAC7F,MAAM,MAAM,GAAG,MAAM,CAAC,EAAE,aAAa,EAAE,CAAC,EAAE,YAAY,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC;QACtE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;IAC3C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,2CAA2C,EAAE,GAAG,EAAE;QACnD,MAAM,CAAC,MAAM,CAAC,EAAE,aAAa,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC;IAClG,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,iCAAiC,EAAE,GAAG,EAAE;QACzC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,oDAAuB,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC;IACpF,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,wDAAwD,EAAE,GAAG,EAAE;QAChE,MAAM,OAAO,GAAG,IAAA,mCAAe,EAAC,qDAAwB,EAAE,EAAE,CAAC,CAAC;QAC9D,MAAM,CAAC,IAAA,8BAAY,EAAC,OAAO,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;IAClF,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import 'reflect-metadata';\nimport { validateSync } from 'class-validator';\nimport { plainToInstance } from 'class-transformer';\nimport { PATH_METADATA, METHOD_METADATA } from '@nestjs/common/constants';\nimport { RequestMethod } from '@nestjs/common';\nimport { MediaMigrationController } from './media-migration.controller';\nimport { CleanupMediaMigrationDto, CreateMediaMigrationDto } from '../dtos/create-media-migration.dto';\n\nconst routes = (method: any) => Object.getOwnPropertyNames(method.prototype)\n .filter(name => name !== 'constructor')\n .map(name => ({\n name,\n method: Reflect.getMetadata(METHOD_METADATA, method.prototype[name]) as RequestMethod,\n path: Reflect.getMetadata(PATH_METADATA, method.prototype[name]) as string,\n }));\n\ndescribe('MediaMigrationController routes', () => {\n const found = routes(MediaMigrationController);\n const has = (method: RequestMethod, path: string) => found.some(route => route.method === method && route.path === path);\n\n it('exposes every endpoint in the migration spec', () => {\n expect(has(RequestMethod.POST, 'preview')).toBe(true);\n expect(has(RequestMethod.POST, '/')).toBe(true);\n expect(has(RequestMethod.GET, '/')).toBe(true);\n expect(has(RequestMethod.GET, ':id')).toBe(true);\n expect(has(RequestMethod.GET, ':id/items')).toBe(true);\n for (const action of ['cancel', 'resume', 'retry-failed', 'rollback', 'cleanup']) {\n expect(has(RequestMethod.POST, `:id/${action}`)).toBe(true);\n }\n });\n\n it('gives every method its own name, so the permission check can tell them apart', () => {\n const names = found.map(route => route.name);\n expect(new Set(names).size).toBe(names.length);\n });\n});\n\ndescribe('request bodies', () => {\n const create = (body: Record<string, unknown>) =>\n validateSync(plainToInstance(CreateMediaMigrationDto, body, { enableImplicitConversion: true }));\n\n it('accepts a whole-provider migration by name', () => {\n expect(create({ sourceProviderName: 'fs-public', targetProviderName: 'aws-main' })).toEqual([]);\n });\n\n it('accepts numbers sent as text, as multipart and query forms do', () => {\n expect(create({ sourceProviderId: '1', targetProviderId: '3', fieldMetadataIds: ['45', '46'] })).toEqual([]);\n });\n\n it('rejects a provider id that is not a whole number', () => {\n expect(create({ sourceProviderId: 'abc' }).map(error => error.property)).toContain('sourceProviderId');\n });\n\n it('rejects a scope list that contains something other than whole numbers', () => {\n expect(create({ fieldMetadataIds: [1, 'x'] }).map(error => error.property)).toContain('fieldMetadataIds');\n });\n\n it('reads the text \"false\" for overwriteExisting as false, not true', () => {\n const dto = plainToInstance(CreateMediaMigrationDto, { overwriteExisting: 'false' }, { enableImplicitConversion: true });\n expect(dto.overwriteExisting).toBe(false);\n expect(validateSync(dto)).toEqual([]);\n });\n\n it('accepts model and field user keys', () => {\n expect(create({ modelUserKeys: ['product'], fieldUserKeys: [{ modelUserKey: 'product', fieldUserKey: 'photo' }] })).toEqual([]);\n });\n\n it('requires a field user key to name its model, since field names repeat across models', () => {\n const errors = create({ fieldUserKeys: [{ fieldUserKey: 'photo' }] });\n expect(errors.length).toBeGreaterThan(0);\n });\n\n it('rejects a model user key that is not text', () => {\n expect(create({ modelUserKeys: [42] }).map(error => error.property)).toContain('modelUserKeys');\n });\n\n it('no longer accepts repointFields', () => {\n expect(Object.keys(new CreateMediaMigrationDto())).not.toContain('repointFields');\n });\n\n it('requires the confirmation text to be given for cleanup', () => {\n const cleanup = plainToInstance(CleanupMediaMigrationDto, {});\n expect(validateSync(cleanup).map(error => error.property)).toContain('confirm');\n });\n});\n"]}
@@ -0,0 +1,21 @@
1
+ export declare class FieldUserKeyDto {
2
+ modelUserKey: string;
3
+ fieldUserKey: string;
4
+ }
5
+ export declare class CreateMediaMigrationDto {
6
+ sourceProviderId?: number;
7
+ sourceProviderName?: string;
8
+ targetProviderId?: number;
9
+ targetProviderName?: string;
10
+ modelMetadataIds?: number[];
11
+ fieldMetadataIds?: number[];
12
+ modelUserKeys?: string[];
13
+ fieldUserKeys?: FieldUserKeyDto[];
14
+ overwriteExisting?: boolean;
15
+ batchSize?: number;
16
+ concurrency?: number;
17
+ }
18
+ export declare class CleanupMediaMigrationDto {
19
+ confirm: string;
20
+ }
21
+ //# sourceMappingURL=create-media-migration.dto.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-media-migration.dto.d.ts","sourceRoot":"","sources":["../../src/dtos/create-media-migration.dto.ts"],"names":[],"mappings":"AAKA,qBAAa,eAAe;IAG1B,YAAY,EAAE,MAAM,CAAC;IAIrB,YAAY,EAAE,MAAM,CAAC;CACtB;AAMD,qBAAa,uBAAuB;IAIlC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAI1B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAK5B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAI1B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAM5B,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IAM5B,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IAO5B,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IAOzB,aAAa,CAAC,EAAE,eAAe,EAAE,CAAC;IAalC,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAM5B,SAAS,CAAC,EAAE,MAAM,CAAC;IAKnB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,qBAAa,wBAAwB;IAInC,OAAO,EAAE,MAAM,CAAC;CACjB"}
@@ -0,0 +1,126 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ 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;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.CleanupMediaMigrationDto = exports.CreateMediaMigrationDto = exports.FieldUserKeyDto = void 0;
13
+ const openapi = require("@nestjs/swagger");
14
+ const class_transformer_1 = require("class-transformer");
15
+ const class_transformer_2 = require("class-transformer");
16
+ const class_validator_1 = require("class-validator");
17
+ class FieldUserKeyDto {
18
+ static _OPENAPI_METADATA_FACTORY() {
19
+ return { modelUserKey: { required: true, type: () => String }, fieldUserKey: { required: true, type: () => String } };
20
+ }
21
+ }
22
+ exports.FieldUserKeyDto = FieldUserKeyDto;
23
+ __decorate([
24
+ (0, class_validator_1.IsString)(),
25
+ (0, class_validator_1.IsNotEmpty)(),
26
+ __metadata("design:type", String)
27
+ ], FieldUserKeyDto.prototype, "modelUserKey", void 0);
28
+ __decorate([
29
+ (0, class_validator_1.IsString)(),
30
+ (0, class_validator_1.IsNotEmpty)(),
31
+ __metadata("design:type", String)
32
+ ], FieldUserKeyDto.prototype, "fieldUserKey", void 0);
33
+ class CreateMediaMigrationDto {
34
+ static _OPENAPI_METADATA_FACTORY() {
35
+ return { sourceProviderId: { required: false, type: () => Number }, sourceProviderName: { required: false, type: () => String }, targetProviderId: { required: false, type: () => Number }, targetProviderName: { required: false, type: () => String }, modelMetadataIds: { required: false, type: () => [Number] }, fieldMetadataIds: { required: false, type: () => [Number] }, modelUserKeys: { required: false, type: () => [String] }, fieldUserKeys: { required: false, type: () => [require("./create-media-migration.dto").FieldUserKeyDto] }, overwriteExisting: { required: false, type: () => Boolean }, batchSize: { required: false, type: () => Number }, concurrency: { required: false, type: () => Number } };
36
+ }
37
+ }
38
+ exports.CreateMediaMigrationDto = CreateMediaMigrationDto;
39
+ __decorate([
40
+ (0, class_validator_1.IsOptional)(),
41
+ (0, class_transformer_1.Type)(() => Number),
42
+ (0, class_validator_1.IsInt)(),
43
+ __metadata("design:type", Number)
44
+ ], CreateMediaMigrationDto.prototype, "sourceProviderId", void 0);
45
+ __decorate([
46
+ (0, class_validator_1.IsOptional)(),
47
+ (0, class_validator_1.IsString)(),
48
+ __metadata("design:type", String)
49
+ ], CreateMediaMigrationDto.prototype, "sourceProviderName", void 0);
50
+ __decorate([
51
+ (0, class_validator_1.IsOptional)(),
52
+ (0, class_transformer_1.Type)(() => Number),
53
+ (0, class_validator_1.IsInt)(),
54
+ __metadata("design:type", Number)
55
+ ], CreateMediaMigrationDto.prototype, "targetProviderId", void 0);
56
+ __decorate([
57
+ (0, class_validator_1.IsOptional)(),
58
+ (0, class_validator_1.IsString)(),
59
+ __metadata("design:type", String)
60
+ ], CreateMediaMigrationDto.prototype, "targetProviderName", void 0);
61
+ __decorate([
62
+ (0, class_validator_1.IsOptional)(),
63
+ (0, class_validator_1.IsArray)(),
64
+ (0, class_transformer_1.Type)(() => Number),
65
+ (0, class_validator_1.IsInt)({ each: true }),
66
+ __metadata("design:type", Array)
67
+ ], CreateMediaMigrationDto.prototype, "modelMetadataIds", void 0);
68
+ __decorate([
69
+ (0, class_validator_1.IsOptional)(),
70
+ (0, class_validator_1.IsArray)(),
71
+ (0, class_transformer_1.Type)(() => Number),
72
+ (0, class_validator_1.IsInt)({ each: true }),
73
+ __metadata("design:type", Array)
74
+ ], CreateMediaMigrationDto.prototype, "fieldMetadataIds", void 0);
75
+ __decorate([
76
+ (0, class_validator_1.IsOptional)(),
77
+ (0, class_validator_1.IsArray)(),
78
+ (0, class_validator_1.IsString)({ each: true }),
79
+ (0, class_validator_1.IsNotEmpty)({ each: true }),
80
+ __metadata("design:type", Array)
81
+ ], CreateMediaMigrationDto.prototype, "modelUserKeys", void 0);
82
+ __decorate([
83
+ (0, class_validator_1.IsOptional)(),
84
+ (0, class_validator_1.IsArray)(),
85
+ (0, class_validator_1.ValidateNested)({ each: true }),
86
+ (0, class_transformer_1.Type)(() => FieldUserKeyDto),
87
+ __metadata("design:type", Array)
88
+ ], CreateMediaMigrationDto.prototype, "fieldUserKeys", void 0);
89
+ __decorate([
90
+ (0, class_validator_1.IsOptional)(),
91
+ (0, class_transformer_2.Transform)(({ obj, key }) => {
92
+ const raw = obj[key];
93
+ if (raw === 'true')
94
+ return true;
95
+ if (raw === 'false')
96
+ return false;
97
+ if (raw === '')
98
+ return undefined;
99
+ return raw;
100
+ }),
101
+ (0, class_validator_1.IsBoolean)(),
102
+ __metadata("design:type", Boolean)
103
+ ], CreateMediaMigrationDto.prototype, "overwriteExisting", void 0);
104
+ __decorate([
105
+ (0, class_validator_1.IsOptional)(),
106
+ (0, class_transformer_1.Type)(() => Number),
107
+ (0, class_validator_1.IsInt)(),
108
+ __metadata("design:type", Number)
109
+ ], CreateMediaMigrationDto.prototype, "batchSize", void 0);
110
+ __decorate([
111
+ (0, class_validator_1.IsOptional)(),
112
+ (0, class_transformer_1.Type)(() => Number),
113
+ (0, class_validator_1.IsInt)(),
114
+ __metadata("design:type", Number)
115
+ ], CreateMediaMigrationDto.prototype, "concurrency", void 0);
116
+ class CleanupMediaMigrationDto {
117
+ static _OPENAPI_METADATA_FACTORY() {
118
+ return { confirm: { required: true, type: () => String } };
119
+ }
120
+ }
121
+ exports.CleanupMediaMigrationDto = CleanupMediaMigrationDto;
122
+ __decorate([
123
+ (0, class_validator_1.IsString)(),
124
+ __metadata("design:type", String)
125
+ ], CleanupMediaMigrationDto.prototype, "confirm", void 0);
126
+ //# sourceMappingURL=create-media-migration.dto.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-media-migration.dto.js","sourceRoot":"","sources":["../../src/dtos/create-media-migration.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,yDAAyC;AACzC,yDAA8C;AAC9C,qDAA8G;AAG9G,MAAa,eAAe;;;;CAQ3B;AARD,0CAQC;AALC;IAFC,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;qDACQ;AAIrB;IAFC,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;qDACQ;AAOvB,MAAa,uBAAuB;;;;CAoEnC;AApED,0DAoEC;AAhEC;IAHC,IAAA,4BAAU,GAAE;IACZ,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,MAAM,CAAC;IAClB,IAAA,uBAAK,GAAE;;iEACkB;AAI1B;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;mEACiB;AAK5B;IAHC,IAAA,4BAAU,GAAE;IACZ,IAAA,wBA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;IACD,IAAA,2BAAS,GAAE;;kEACgB;AAM5B;IAHC,IAAA,4BAAU,GAAE;IACZ,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,MAAM,CAAC;IAClB,IAAA,uBAAK,GAAE;;0DACW;AAKnB;IAHC,IAAA,4BAAU,GAAE;IACZ,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,MAAM,CAAC;IAClB,IAAA,uBAAK,GAAE;;4DACa;AAGvB,MAAa,wBAAwB;;;;CAKpC;AALD,4DAKC;AADC;IADC,IAAA,0BAAQ,GAAE;;yDACK","sourcesContent":["import { Type } from 'class-transformer';\nimport { Transform } from 'class-transformer';\nimport { IsArray, IsBoolean, IsInt, IsNotEmpty, IsOptional, IsString, ValidateNested } from 'class-validator';\n\n/** A field, named by its userKey (its name) and the userKey of the model it belongs to. */\nexport class FieldUserKeyDto {\n @IsString()\n @IsNotEmpty()\n modelUserKey: string;\n\n @IsString()\n @IsNotEmpty()\n fieldUserKey: string;\n}\n\n/**\n * Starts a media migration from one storage provider to another. Providers can be given by id or by\n * name. Scope lists are optional: none means the whole source provider.\n */\nexport class CreateMediaMigrationDto {\n @IsOptional()\n @Type(() => Number)\n @IsInt()\n sourceProviderId?: number;\n\n @IsOptional()\n @IsString()\n sourceProviderName?: string;\n\n @IsOptional()\n @Type(() => Number)\n @IsInt()\n targetProviderId?: number;\n\n @IsOptional()\n @IsString()\n targetProviderName?: string;\n\n @IsOptional()\n @IsArray()\n @Type(() => Number)\n @IsInt({ each: true })\n modelMetadataIds?: number[];\n\n @IsOptional()\n @IsArray()\n @Type(() => Number)\n @IsInt({ each: true })\n fieldMetadataIds?: number[];\n\n // Same scope by user key. A model's userKey is its singularName, so \"product\".\n @IsOptional()\n @IsArray()\n @IsString({ each: true })\n @IsNotEmpty({ each: true })\n modelUserKeys?: string[];\n\n // A field's userKey is its name, which can repeat across models, so each field also names its model.\n @IsOptional()\n @IsArray()\n @ValidateNested({ each: true })\n @Type(() => FieldUserKeyDto)\n fieldUserKeys?: FieldUserKeyDto[];\n\n // Replace a same-named file at the target that has different content. Defaults to false.\n // Form posts send \"false\" as text, which implicit conversion would turn into true, so read the raw value.\n @IsOptional()\n @Transform(({ obj, key }) => {\n const raw = obj[key];\n if (raw === 'true') return true;\n if (raw === 'false') return false;\n if (raw === '') return undefined;\n return raw;\n })\n @IsBoolean()\n overwriteExisting?: boolean;\n\n // Clamped by the engine: batchSize to 10-1000, concurrency to 1-16.\n @IsOptional()\n @Type(() => Number)\n @IsInt()\n batchSize?: number;\n\n @IsOptional()\n @Type(() => Number)\n @IsInt()\n concurrency?: number;\n}\n\nexport class CleanupMediaMigrationDto {\n // DELETE_SOURCE_FILES for a finished migration, DELETE_TARGET_FILES for a rolled-back one.\n // Deleting files cannot be undone.\n @IsString()\n confirm: string;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"create-media-storage-provider-metadata.dto.d.ts","sourceRoot":"","sources":["../../src/dtos/create-media-storage-provider-metadata.dto.ts"],"names":[],"mappings":"AAEA,oBAAY,wBAAwB;IAChC,UAAU,eAAe;IACzB,KAAK,WAAW;IAChB,gBAAgB,uBAAuB;CAC1C;AACD,qBAAa,qCAAqC;IAI9C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAKtB,QAAQ,CAAC,IAAI,EAAE,wBAAwB,CAAC;IAKxC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAKxB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAK5B,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAK3B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAI3B,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;CACpC"}
1
+ {"version":3,"file":"create-media-storage-provider-metadata.dto.d.ts","sourceRoot":"","sources":["../../src/dtos/create-media-storage-provider-metadata.dto.ts"],"names":[],"mappings":"AAEA,oBAAY,wBAAwB;IAChC,UAAU,eAAe;IACzB,KAAK,WAAW;IAChB,gBAAgB,uBAAuB;CAC1C;AACD,qBAAa,qCAAqC;IAI9C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAKtB,QAAQ,CAAC,IAAI,EAAE,wBAAwB,CAAC;IAKxC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAKxB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAc5B,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAK3B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAI3B,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;CACpC"}
@@ -11,6 +11,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.CreateMediaStorageProviderMetadataDto = exports.MediaStorageProviderType = void 0;
13
13
  const openapi = require("@nestjs/swagger");
14
+ const class_transformer_1 = require("class-transformer");
14
15
  const class_validator_1 = require("class-validator");
15
16
  var MediaStorageProviderType;
16
17
  (function (MediaStorageProviderType) {
@@ -46,6 +47,16 @@ __decorate([
46
47
  ], CreateMediaStorageProviderMetadataDto.prototype, "bucketName", void 0);
47
48
  __decorate([
48
49
  (0, class_validator_1.IsOptional)(),
50
+ (0, class_transformer_1.Transform)(({ obj, key }) => {
51
+ const raw = obj[key];
52
+ if (raw === 'true')
53
+ return true;
54
+ if (raw === 'false')
55
+ return false;
56
+ if (raw === '')
57
+ return undefined;
58
+ return raw;
59
+ }),
49
60
  (0, class_validator_1.IsBoolean)(),
50
61
  __metadata("design:type", Boolean)
51
62
  ], CreateMediaStorageProviderMetadataDto.prototype, "isPublic", void 0);
@@ -1 +1 @@
1
- {"version":3,"file":"create-media-storage-provider-metadata.dto.js","sourceRoot":"","sources":["../../src/dtos/create-media-storage-provider-metadata.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;;AACA,qDAA2G;AAC3G,IAAY,wBAIX;AAJD,WAAY,wBAAwB;IAChC,qDAAyB,CAAA;IACzB,4CAAgB,CAAA;IAChB,mEAAuC,CAAA;AAC3C,CAAC,EAJW,wBAAwB,wCAAxB,wBAAwB,QAInC;AACD,MAAa,qCAAqC;;;;CAkCjD;AAlCD,sFAkCC;AA9BY;IAFR,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;mEACW;AAKb;IAFR,IAAA,4BAAU,GAAE;IACZ,IAAA,wBAAM,EAAC,wBAAwB,CAAC;;mEACO;AAK/B;IAFR,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;qEACW;AAKf;IAFR,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;yEACe;AAKnB;IAFR,IAAA,4BAAU,GAAE;IACZ,IAAA,2BAAS,GAAE;;uEACe;AAKlB;IAFR,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;wEACc;AAIlB;IAFR,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;8EACsB","sourcesContent":["import { Transform } from \"class-transformer\";\nimport { IsBoolean, IsEnum, IsNotEmpty, IsNumber, IsOptional, IsString, isBoolean } from \"class-validator\";\nexport enum MediaStorageProviderType {\n Filesystem = 'filesystem',\n AwsS3 = 'aws-s3',\n AzureBlobStorage = 'azure-blob-storage'\n}\nexport class CreateMediaStorageProviderMetadataDto {\n // name\n @IsNotEmpty()\n @IsString()\n readonly name: string;\n\n // type filesystem|aws-s3|azure-blob-storage\n @IsNotEmpty()\n @IsEnum(MediaStorageProviderType)\n readonly type: MediaStorageProviderType;\n\n // region\n @IsString()\n @IsOptional()\n readonly region: string;\n\n // bucketName\n @IsString()\n @IsOptional()\n readonly bucketName: string;\n\n // isPublic\n @IsOptional()\n @IsBoolean()\n readonly isPublic: boolean;\n\n // localPath\n @IsString()\n @IsOptional()\n readonly localPath: string;\n\n @IsOptional()\n @IsNumber()\n readonly signedUrlExpiry: number; // stored in minutes\n}"]}
1
+ {"version":3,"file":"create-media-storage-provider-metadata.dto.js","sourceRoot":"","sources":["../../src/dtos/create-media-storage-provider-metadata.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,yDAA8C;AAC9C,qDAA2G;AAC3G,IAAY,wBAIX;AAJD,WAAY,wBAAwB;IAChC,qDAAyB,CAAA;IACzB,4CAAgB,CAAA;IAChB,mEAAuC,CAAA;AAC3C,CAAC,EAJW,wBAAwB,wCAAxB,wBAAwB,QAInC;AACD,MAAa,qCAAqC;;;;CA2CjD;AA3CD,sFA2CC;AAvCY;IAFR,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;mEACW;AAKb;IAFR,IAAA,4BAAU,GAAE;IACZ,IAAA,wBAAM,EAAC,wBAAwB,CAAC;;mEACO;AAK/B;IAFR,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;qEACW;AAKf;IAFR,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;yEACe;AAcnB;IATR,IAAA,4BAAU,GAAE;IACZ,IAAA,6BAAS,EAAC,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE,EAAE;QACxB,MAAM,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;QACrB,IAAI,GAAG,KAAK,MAAM;YAAE,OAAO,IAAI,CAAC;QAChC,IAAI,GAAG,KAAK,OAAO;YAAE,OAAO,KAAK,CAAC;QAClC,IAAI,GAAG,KAAK,EAAE;YAAE,OAAO,SAAS,CAAC;QACjC,OAAO,GAAG,CAAC;IACf,CAAC,CAAC;IACD,IAAA,2BAAS,GAAE;;uEACe;AAKlB;IAFR,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;wEACc;AAIlB;IAFR,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;8EACsB","sourcesContent":["import { Transform } from \"class-transformer\";\nimport { IsBoolean, IsEnum, IsNotEmpty, IsNumber, IsOptional, IsString, isBoolean } from \"class-validator\";\nexport enum MediaStorageProviderType {\n Filesystem = 'filesystem',\n AwsS3 = 'aws-s3',\n AzureBlobStorage = 'azure-blob-storage'\n}\nexport class CreateMediaStorageProviderMetadataDto {\n // name\n @IsNotEmpty()\n @IsString()\n readonly name: string;\n\n // type filesystem|aws-s3|azure-blob-storage\n @IsNotEmpty()\n @IsEnum(MediaStorageProviderType)\n readonly type: MediaStorageProviderType;\n\n // region\n @IsString()\n @IsOptional()\n readonly region: string;\n\n // bucketName\n @IsString()\n @IsOptional()\n readonly bucketName: string;\n\n // isPublic\n // Multipart form posts send \"false\" as text. Implicit conversion would turn that into true\n // (any non-empty text is truthy), so read the raw submitted value instead.\n @IsOptional()\n @Transform(({ obj, key }) => {\n const raw = obj[key];\n if (raw === 'true') return true;\n if (raw === 'false') return false;\n if (raw === '') return undefined;\n return raw;\n })\n @IsBoolean()\n readonly isPublic: boolean;\n\n // localPath\n @IsString()\n @IsOptional()\n readonly localPath: string;\n\n @IsOptional()\n @IsNumber()\n readonly signedUrlExpiry: number; // stored in minutes\n}"]}
@@ -0,0 +1,2 @@
1
+ import 'reflect-metadata';
2
+ //# sourceMappingURL=create-media-storage-provider-metadata.dto.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-media-storage-provider-metadata.dto.spec.d.ts","sourceRoot":"","sources":["../../src/dtos/create-media-storage-provider-metadata.dto.spec.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC"}
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ require("reflect-metadata");
4
+ const class_transformer_1 = require("class-transformer");
5
+ const class_validator_1 = require("class-validator");
6
+ const create_media_storage_provider_metadata_dto_1 = require("./create-media-storage-provider-metadata.dto");
7
+ const toDto = (payload) => (0, class_transformer_1.plainToInstance)(create_media_storage_provider_metadata_dto_1.CreateMediaStorageProviderMetadataDto, payload, { enableImplicitConversion: true });
8
+ describe('CreateMediaStorageProviderMetadataDto isPublic', () => {
9
+ const base = { name: 'p', type: 'filesystem' };
10
+ it('reads the text "false" from a multipart form as false, not true', () => {
11
+ expect(toDto({ ...base, isPublic: 'false' }).isPublic).toBe(false);
12
+ });
13
+ it('reads the text "true" as true', () => {
14
+ expect(toDto({ ...base, isPublic: 'true' }).isPublic).toBe(true);
15
+ });
16
+ it('keeps real booleans from a JSON body', () => {
17
+ expect(toDto({ ...base, isPublic: false }).isPublic).toBe(false);
18
+ expect(toDto({ ...base, isPublic: true }).isPublic).toBe(true);
19
+ });
20
+ it('treats a blank field as not sent', () => {
21
+ const dto = toDto({ ...base, isPublic: '' });
22
+ expect(dto.isPublic).toBeUndefined();
23
+ expect((0, class_validator_1.validateSync)(dto)).toEqual([]);
24
+ });
25
+ it('still rejects text that is not a boolean', () => {
26
+ expect((0, class_validator_1.validateSync)(toDto({ ...base, isPublic: 'maybe' })).map(e => e.property)).toContain('isPublic');
27
+ });
28
+ });
29
+ //# sourceMappingURL=create-media-storage-provider-metadata.dto.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-media-storage-provider-metadata.dto.spec.js","sourceRoot":"","sources":["../../src/dtos/create-media-storage-provider-metadata.dto.spec.ts"],"names":[],"mappings":";;AAAA,4BAA0B;AAC1B,yDAAoD;AACpD,qDAA+C;AAC/C,6GAAqG;AAGrG,MAAM,KAAK,GAAG,CAAC,OAAgC,EAAE,EAAE,CACjD,IAAA,mCAAe,EAAC,kFAAqC,EAAE,OAAO,EAAE,EAAE,wBAAwB,EAAE,IAAI,EAAE,CAAC,CAAC;AAEtG,QAAQ,CAAC,gDAAgD,EAAE,GAAG,EAAE;IAC9D,MAAM,IAAI,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC;IAE/C,EAAE,CAAC,iEAAiE,EAAE,GAAG,EAAE;QACzE,MAAM,CAAC,KAAK,CAAC,EAAE,GAAG,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;I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import 'reflect-metadata';\nimport { plainToInstance } from 'class-transformer';\nimport { validateSync } from 'class-validator';\nimport { CreateMediaStorageProviderMetadataDto } from './create-media-storage-provider-metadata.dto';\n\n// Mirrors the app's global ValidationPipe settings (see bootstrap.helper.ts).\nconst toDto = (payload: Record<string, unknown>) =>\n plainToInstance(CreateMediaStorageProviderMetadataDto, payload, { enableImplicitConversion: true });\n\ndescribe('CreateMediaStorageProviderMetadataDto isPublic', () => {\n const base = { name: 'p', type: 'filesystem' };\n\n it('reads the text \"false\" from a multipart form as false, not true', () => {\n expect(toDto({ ...base, isPublic: 'false' }).isPublic).toBe(false);\n });\n\n it('reads the text \"true\" as true', () => {\n expect(toDto({ ...base, isPublic: 'true' }).isPublic).toBe(true);\n });\n\n it('keeps real booleans from a JSON body', () => {\n expect(toDto({ ...base, isPublic: false }).isPublic).toBe(false);\n expect(toDto({ ...base, isPublic: true }).isPublic).toBe(true);\n });\n\n it('treats a blank field as not sent', () => {\n const dto = toDto({ ...base, isPublic: '' });\n expect(dto.isPublic).toBeUndefined();\n expect(validateSync(dto)).toEqual([]);\n });\n\n it('still rejects text that is not a boolean', () => {\n expect(validateSync(toDto({ ...base, isPublic: 'maybe' })).map(e => e.property)).toContain('isPublic');\n });\n});\n"]}
@@ -0,0 +1,19 @@
1
+ import { CommonEntity } from '../entities/common.entity';
2
+ import { MediaMigrationJob } from '../entities/media-migration-job.entity';
3
+ export declare const MEDIA_MIGRATION_ITEM_STATUSES: readonly ["pending", "completed", "skipped", "failed", "rolled_back", "source_deleted", "target_deleted"];
4
+ export type MediaMigrationItemStatus = typeof MEDIA_MIGRATION_ITEM_STATUSES[number];
5
+ export declare const MEDIA_MIGRATION_KEY_MAX_LENGTH = 450;
6
+ export declare class MediaMigrationItem extends CommonEntity {
7
+ job: MediaMigrationJob;
8
+ sourceKey: string;
9
+ targetKey: string | null;
10
+ mediaIds: number[];
11
+ status: MediaMigrationItemStatus;
12
+ copied: boolean;
13
+ sourceSize: number | null;
14
+ targetSize: number | null;
15
+ errorCode: string | null;
16
+ errorMessage: string | null;
17
+ attempts: number;
18
+ }
19
+ //# sourceMappingURL=media-migration-item.entity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"media-migration-item.entity.d.ts","sourceRoot":"","sources":["../../src/entities/media-migration-item.entity.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,yCAAyC,CAAC;AAI5E,eAAO,MAAM,6BAA6B,2GAQhC,CAAC;AACX,MAAM,MAAM,wBAAwB,GAAG,OAAO,6BAA6B,CAAC,MAAM,CAAC,CAAC;AAKpF,eAAO,MAAM,8BAA8B,MAAM,CAAC;AAMlD,qBAEa,kBAAmB,SAAQ,YAAY;IAGlD,GAAG,EAAE,iBAAiB,CAAC;IAGvB,SAAS,EAAE,MAAM,CAAC;IAGlB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAIzB,QAAQ,EAAE,MAAM,EAAE,CAAC;IAInB,MAAM,EAAE,wBAAwB,CAAC;IAKjC,MAAM,EAAE,OAAO,CAAC;IAGhB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAG1B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAG1B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAGzB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAG5B,QAAQ,EAAE,MAAM,CAAC;CAClB"}