@webiny/api-file-manager 0.0.0-unstable.e53eceafb5 → 0.0.0-unstable.e6f0dc8ca7

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 (438) hide show
  1. package/README.md +7 -13
  2. package/contants.js +1 -7
  3. package/contants.js.map +1 -1
  4. package/delivery/AssetDelivery/Asset.d.ts +3 -7
  5. package/delivery/AssetDelivery/Asset.js +1 -11
  6. package/delivery/AssetDelivery/Asset.js.map +1 -1
  7. package/delivery/AssetDelivery/AssetDeliveryConfig.d.ts +11 -9
  8. package/delivery/AssetDelivery/AssetDeliveryConfig.js +18 -26
  9. package/delivery/AssetDelivery/AssetDeliveryConfig.js.map +1 -1
  10. package/delivery/AssetDelivery/AssetRequest.d.ts +1 -1
  11. package/delivery/AssetDelivery/AssetRequest.js +1 -8
  12. package/delivery/AssetDelivery/AssetRequest.js.map +1 -1
  13. package/delivery/AssetDelivery/FilesAssetRequestResolver.d.ts +3 -3
  14. package/delivery/AssetDelivery/FilesAssetRequestResolver.js +3 -10
  15. package/delivery/AssetDelivery/FilesAssetRequestResolver.js.map +1 -1
  16. package/delivery/AssetDelivery/NullAssetOutputStrategy.d.ts +1 -1
  17. package/delivery/AssetDelivery/NullAssetOutputStrategy.js +3 -10
  18. package/delivery/AssetDelivery/NullAssetOutputStrategy.js.map +1 -1
  19. package/delivery/AssetDelivery/NullAssetReply.d.ts +1 -1
  20. package/delivery/AssetDelivery/NullAssetReply.js +2 -9
  21. package/delivery/AssetDelivery/NullAssetReply.js.map +1 -1
  22. package/delivery/AssetDelivery/NullAssetResolver.d.ts +2 -2
  23. package/delivery/AssetDelivery/NullAssetResolver.js +1 -8
  24. package/delivery/AssetDelivery/NullAssetResolver.js.map +1 -1
  25. package/delivery/AssetDelivery/NullRequestResolver.d.ts +1 -1
  26. package/delivery/AssetDelivery/NullRequestResolver.js +1 -8
  27. package/delivery/AssetDelivery/NullRequestResolver.js.map +1 -1
  28. package/delivery/AssetDelivery/SetCacheControlHeaders.d.ts +1 -1
  29. package/delivery/AssetDelivery/SetCacheControlHeaders.js +1 -8
  30. package/delivery/AssetDelivery/SetCacheControlHeaders.js.map +1 -1
  31. package/delivery/AssetDelivery/SetResponseHeaders.d.ts +3 -3
  32. package/delivery/AssetDelivery/SetResponseHeaders.js +1 -8
  33. package/delivery/AssetDelivery/SetResponseHeaders.js.map +1 -1
  34. package/delivery/AssetDelivery/abstractions/AssetContentsReader.d.ts +1 -3
  35. package/delivery/AssetDelivery/abstractions/AssetContentsReader.js +1 -5
  36. package/delivery/AssetDelivery/abstractions/AssetContentsReader.js.map +1 -1
  37. package/delivery/AssetDelivery/abstractions/AssetOutputStrategy.d.ts +1 -1
  38. package/delivery/AssetDelivery/abstractions/AssetOutputStrategy.js +1 -5
  39. package/delivery/AssetDelivery/abstractions/AssetOutputStrategy.js.map +1 -1
  40. package/delivery/AssetDelivery/abstractions/AssetProcessor.d.ts +1 -1
  41. package/delivery/AssetDelivery/abstractions/AssetProcessor.js +1 -5
  42. package/delivery/AssetDelivery/abstractions/AssetProcessor.js.map +1 -1
  43. package/delivery/AssetDelivery/abstractions/AssetReply.js +3 -10
  44. package/delivery/AssetDelivery/abstractions/AssetReply.js.map +1 -1
  45. package/delivery/AssetDelivery/abstractions/AssetRequestResolver.d.ts +2 -2
  46. package/delivery/AssetDelivery/abstractions/AssetRequestResolver.js +1 -5
  47. package/delivery/AssetDelivery/abstractions/AssetRequestResolver.js.map +1 -1
  48. package/delivery/AssetDelivery/abstractions/AssetResolver.d.ts +1 -1
  49. package/delivery/AssetDelivery/abstractions/AssetResolver.js +1 -5
  50. package/delivery/AssetDelivery/abstractions/AssetResolver.js.map +1 -1
  51. package/delivery/AssetDelivery/abstractions/AssetTransformationStrategy.d.ts +1 -1
  52. package/delivery/AssetDelivery/abstractions/AssetTransformationStrategy.js +1 -5
  53. package/delivery/AssetDelivery/abstractions/AssetTransformationStrategy.js.map +1 -1
  54. package/delivery/AssetDelivery/createAssetDeliveryPluginLoader.d.ts +1 -1
  55. package/delivery/AssetDelivery/createAssetDeliveryPluginLoader.js +1 -8
  56. package/delivery/AssetDelivery/createAssetDeliveryPluginLoader.js.map +1 -1
  57. package/delivery/AssetDelivery/privateFiles/AssetAuthorizer.d.ts +1 -1
  58. package/delivery/AssetDelivery/privateFiles/AssetAuthorizer.js +1 -5
  59. package/delivery/AssetDelivery/privateFiles/AssetAuthorizer.js.map +1 -1
  60. package/delivery/AssetDelivery/privateFiles/NotAuthorizedAssetReply.d.ts +1 -1
  61. package/delivery/AssetDelivery/privateFiles/NotAuthorizedAssetReply.js +4 -11
  62. package/delivery/AssetDelivery/privateFiles/NotAuthorizedAssetReply.js.map +1 -1
  63. package/delivery/AssetDelivery/privateFiles/NotAuthorizedOutputStrategy.d.ts +1 -1
  64. package/delivery/AssetDelivery/privateFiles/NotAuthorizedOutputStrategy.js +3 -10
  65. package/delivery/AssetDelivery/privateFiles/NotAuthorizedOutputStrategy.js.map +1 -1
  66. package/delivery/AssetDelivery/privateFiles/PrivateAuthenticatedAuthorizer.d.ts +4 -3
  67. package/delivery/AssetDelivery/privateFiles/PrivateAuthenticatedAuthorizer.js +3 -11
  68. package/delivery/AssetDelivery/privateFiles/PrivateAuthenticatedAuthorizer.js.map +1 -1
  69. package/delivery/AssetDelivery/privateFiles/PrivateCache.d.ts +1 -1
  70. package/delivery/AssetDelivery/privateFiles/PrivateCache.js +4 -11
  71. package/delivery/AssetDelivery/privateFiles/PrivateCache.js.map +1 -1
  72. package/delivery/AssetDelivery/privateFiles/PrivateFileAssetRequestResolver.d.ts +3 -3
  73. package/delivery/AssetDelivery/privateFiles/PrivateFileAssetRequestResolver.js +3 -10
  74. package/delivery/AssetDelivery/privateFiles/PrivateFileAssetRequestResolver.js.map +1 -1
  75. package/delivery/AssetDelivery/privateFiles/PrivateFilesAssetProcessor.d.ts +4 -4
  76. package/delivery/AssetDelivery/privateFiles/PrivateFilesAssetProcessor.js +21 -21
  77. package/delivery/AssetDelivery/privateFiles/PrivateFilesAssetProcessor.js.map +1 -1
  78. package/delivery/AssetDelivery/privateFiles/PublicCache.d.ts +1 -1
  79. package/delivery/AssetDelivery/privateFiles/PublicCache.js +4 -11
  80. package/delivery/AssetDelivery/privateFiles/PublicCache.js.map +1 -1
  81. package/delivery/AssetDelivery/privateFiles/RedirectToPrivateUrlOutputStrategy.d.ts +2 -2
  82. package/delivery/AssetDelivery/privateFiles/RedirectToPrivateUrlOutputStrategy.js +5 -12
  83. package/delivery/AssetDelivery/privateFiles/RedirectToPrivateUrlOutputStrategy.js.map +1 -1
  84. package/delivery/AssetDelivery/privateFiles/RedirectToPublicUrlOutputStrategy.d.ts +2 -2
  85. package/delivery/AssetDelivery/privateFiles/RedirectToPublicUrlOutputStrategy.js +5 -12
  86. package/delivery/AssetDelivery/privateFiles/RedirectToPublicUrlOutputStrategy.js.map +1 -1
  87. package/delivery/AssetDelivery/transformation/PassthroughAssetProcessor.d.ts +1 -1
  88. package/delivery/AssetDelivery/transformation/PassthroughAssetProcessor.js +1 -8
  89. package/delivery/AssetDelivery/transformation/PassthroughAssetProcessor.js.map +1 -1
  90. package/delivery/AssetDelivery/transformation/PassthroughAssetTransformationStrategy.d.ts +1 -1
  91. package/delivery/AssetDelivery/transformation/PassthroughAssetTransformationStrategy.js +1 -8
  92. package/delivery/AssetDelivery/transformation/PassthroughAssetTransformationStrategy.js.map +1 -1
  93. package/delivery/AssetDelivery/transformation/TransformationAssetProcessor.d.ts +1 -1
  94. package/delivery/AssetDelivery/transformation/TransformationAssetProcessor.js +1 -8
  95. package/delivery/AssetDelivery/transformation/TransformationAssetProcessor.js.map +1 -1
  96. package/delivery/index.d.ts +16 -17
  97. package/delivery/index.js +10 -192
  98. package/delivery/index.js.map +1 -1
  99. package/delivery/setupAssetDelivery.d.ts +2 -6
  100. package/delivery/setupAssetDelivery.js +21 -35
  101. package/delivery/setupAssetDelivery.js.map +1 -1
  102. package/domain/file/abstractions.d.ts +9 -0
  103. package/domain/file/abstractions.js +8 -0
  104. package/domain/file/abstractions.js.map +1 -0
  105. package/domain/file/errors.d.ts +59 -0
  106. package/domain/file/errors.js +89 -0
  107. package/domain/file/errors.js.map +1 -0
  108. package/domain/file/file.model.d.ts +12 -0
  109. package/domain/file/file.model.js +57 -0
  110. package/domain/file/file.model.js.map +1 -0
  111. package/domain/file/types.d.ts +53 -0
  112. package/domain/file/types.js +3 -0
  113. package/domain/file/types.js.map +1 -0
  114. package/domain/identity/Identity.d.ts +9 -0
  115. package/domain/identity/Identity.js +11 -0
  116. package/domain/identity/Identity.js.map +1 -0
  117. package/domain/permissionsSchema.d.ts +16 -0
  118. package/domain/permissionsSchema.js +19 -0
  119. package/domain/permissionsSchema.js.map +1 -0
  120. package/domain/settings/constants.d.ts +1 -0
  121. package/domain/settings/constants.js +3 -0
  122. package/domain/settings/constants.js.map +1 -0
  123. package/domain/settings/errors.d.ts +18 -0
  124. package/domain/settings/errors.js +30 -0
  125. package/domain/settings/errors.js.map +1 -0
  126. package/domain/settings/types.d.ts +10 -0
  127. package/domain/settings/types.js +3 -0
  128. package/domain/settings/types.js.map +1 -0
  129. package/domain/settings/validation.d.ts +6 -0
  130. package/domain/settings/validation.js +36 -0
  131. package/domain/settings/validation.js.map +1 -0
  132. package/exports/api/file-manager/file.d.ts +12 -0
  133. package/exports/api/file-manager/file.js +14 -0
  134. package/exports/api/file-manager/file.js.map +1 -0
  135. package/exports/api/file-manager/permissions.d.ts +1 -0
  136. package/exports/api/file-manager/permissions.js +3 -0
  137. package/exports/api/file-manager/permissions.js.map +1 -0
  138. package/exports/api/file-manager/settings.d.ts +3 -0
  139. package/exports/api/file-manager/settings.js +5 -0
  140. package/exports/api/file-manager/settings.js.map +1 -0
  141. package/features/FileManagerFeature.d.ts +4 -0
  142. package/features/FileManagerFeature.js +30 -0
  143. package/features/FileManagerFeature.js.map +1 -0
  144. package/features/file/CreateFile/CreateFileRepository.d.ts +15 -0
  145. package/features/file/CreateFile/CreateFileRepository.js +30 -0
  146. package/features/file/CreateFile/CreateFileRepository.js.map +1 -0
  147. package/features/file/CreateFile/CreateFileUseCase.d.ts +21 -0
  148. package/features/file/CreateFile/CreateFileUseCase.js +90 -0
  149. package/features/file/CreateFile/CreateFileUseCase.js.map +1 -0
  150. package/features/file/CreateFile/abstractions.d.ts +60 -0
  151. package/features/file/CreateFile/abstractions.js +17 -0
  152. package/features/file/CreateFile/abstractions.js.map +1 -0
  153. package/features/file/CreateFile/events.d.ts +31 -0
  154. package/features/file/CreateFile/events.js +32 -0
  155. package/features/file/CreateFile/events.js.map +1 -0
  156. package/features/file/CreateFile/feature.d.ts +4 -0
  157. package/features/file/CreateFile/feature.js +12 -0
  158. package/features/file/CreateFile/feature.js.map +1 -0
  159. package/features/file/CreateFile/index.d.ts +2 -0
  160. package/features/file/CreateFile/index.js +4 -0
  161. package/features/file/CreateFile/index.js.map +1 -0
  162. package/features/file/CreateFilesInBatch/CreateFilesInBatchRepository.d.ts +13 -0
  163. package/features/file/CreateFilesInBatch/CreateFilesInBatchRepository.js +24 -0
  164. package/features/file/CreateFilesInBatch/CreateFilesInBatchRepository.js.map +1 -0
  165. package/features/file/CreateFilesInBatch/CreateFilesInBatchUseCase.d.ts +19 -0
  166. package/features/file/CreateFilesInBatch/CreateFilesInBatchUseCase.js +84 -0
  167. package/features/file/CreateFilesInBatch/CreateFilesInBatchUseCase.js.map +1 -0
  168. package/features/file/CreateFilesInBatch/abstractions.d.ts +42 -0
  169. package/features/file/CreateFilesInBatch/abstractions.js +17 -0
  170. package/features/file/CreateFilesInBatch/abstractions.js.map +1 -0
  171. package/features/file/CreateFilesInBatch/events.d.ts +31 -0
  172. package/features/file/CreateFilesInBatch/events.js +32 -0
  173. package/features/file/CreateFilesInBatch/events.js.map +1 -0
  174. package/features/file/CreateFilesInBatch/feature.d.ts +4 -0
  175. package/features/file/CreateFilesInBatch/feature.js +12 -0
  176. package/features/file/CreateFilesInBatch/feature.js.map +1 -0
  177. package/features/file/CreateFilesInBatch/index.d.ts +1 -0
  178. package/features/file/CreateFilesInBatch/index.js +3 -0
  179. package/features/file/CreateFilesInBatch/index.js.map +1 -0
  180. package/features/file/DeleteFile/DeleteFileRepository.d.ts +15 -0
  181. package/features/file/DeleteFile/DeleteFileRepository.js +30 -0
  182. package/features/file/DeleteFile/DeleteFileRepository.js.map +1 -0
  183. package/features/file/DeleteFile/DeleteFileUseCase.d.ts +17 -0
  184. package/features/file/DeleteFile/DeleteFileUseCase.js +45 -0
  185. package/features/file/DeleteFile/DeleteFileUseCase.js.map +1 -0
  186. package/features/file/DeleteFile/abstractions.d.ts +39 -0
  187. package/features/file/DeleteFile/abstractions.js +17 -0
  188. package/features/file/DeleteFile/abstractions.js.map +1 -0
  189. package/features/file/DeleteFile/events.d.ts +29 -0
  190. package/features/file/DeleteFile/events.js +32 -0
  191. package/features/file/DeleteFile/events.js.map +1 -0
  192. package/features/file/DeleteFile/feature.d.ts +4 -0
  193. package/features/file/DeleteFile/feature.js +12 -0
  194. package/features/file/DeleteFile/feature.js.map +1 -0
  195. package/features/file/DeleteFile/index.d.ts +2 -0
  196. package/features/file/DeleteFile/index.js +4 -0
  197. package/features/file/DeleteFile/index.js.map +1 -0
  198. package/features/file/FileUrlGenerator/abstractions.d.ts +9 -0
  199. package/features/file/FileUrlGenerator/abstractions.js +5 -0
  200. package/features/file/FileUrlGenerator/abstractions.js.map +1 -0
  201. package/features/file/GetFile/GetFileRepository.d.ts +15 -0
  202. package/features/file/GetFile/GetFileRepository.js +33 -0
  203. package/features/file/GetFile/GetFileRepository.js.map +1 -0
  204. package/features/file/GetFile/GetFileUseCase.d.ts +14 -0
  205. package/features/file/GetFile/GetFileUseCase.js +31 -0
  206. package/features/file/GetFile/GetFileUseCase.js.map +1 -0
  207. package/features/file/GetFile/abstractions.d.ts +40 -0
  208. package/features/file/GetFile/abstractions.js +17 -0
  209. package/features/file/GetFile/abstractions.js.map +1 -0
  210. package/features/file/GetFile/feature.d.ts +4 -0
  211. package/features/file/GetFile/feature.js +12 -0
  212. package/features/file/GetFile/feature.js.map +1 -0
  213. package/features/file/GetFile/index.d.ts +1 -0
  214. package/features/file/GetFile/index.js +3 -0
  215. package/features/file/GetFile/index.js.map +1 -0
  216. package/features/file/GetFileContents/abstractions.d.ts +20 -0
  217. package/features/file/GetFileContents/abstractions.js +4 -0
  218. package/features/file/GetFileContents/abstractions.js.map +1 -0
  219. package/features/file/GetFileContents/index.d.ts +1 -0
  220. package/features/file/GetFileContents/index.js +3 -0
  221. package/features/file/GetFileContents/index.js.map +1 -0
  222. package/features/file/ListFiles/ListFilesRepository.d.ts +18 -0
  223. package/features/file/ListFiles/ListFilesRepository.js +51 -0
  224. package/features/file/ListFiles/ListFilesRepository.js.map +1 -0
  225. package/features/file/ListFiles/ListFilesUseCase.d.ts +15 -0
  226. package/features/file/ListFiles/ListFilesUseCase.js +45 -0
  227. package/features/file/ListFiles/ListFilesUseCase.js.map +1 -0
  228. package/features/file/ListFiles/abstractions.d.ts +49 -0
  229. package/features/file/ListFiles/abstractions.js +17 -0
  230. package/features/file/ListFiles/abstractions.js.map +1 -0
  231. package/features/file/ListFiles/feature.d.ts +4 -0
  232. package/features/file/ListFiles/feature.js +12 -0
  233. package/features/file/ListFiles/feature.js.map +1 -0
  234. package/features/file/ListFiles/index.d.ts +1 -0
  235. package/features/file/ListFiles/index.js +3 -0
  236. package/features/file/ListFiles/index.js.map +1 -0
  237. package/features/file/ListImagesByTagTool/ListImagesByTagTool.d.ts +27 -0
  238. package/features/file/ListImagesByTagTool/ListImagesByTagTool.js +39 -0
  239. package/features/file/ListImagesByTagTool/ListImagesByTagTool.js.map +1 -0
  240. package/features/file/ListImagesByTagTool/feature.d.ts +4 -0
  241. package/features/file/ListImagesByTagTool/feature.js +10 -0
  242. package/features/file/ListImagesByTagTool/feature.js.map +1 -0
  243. package/features/file/ListTags/ListTagsRepository.d.ts +16 -0
  244. package/features/file/ListTags/ListTagsRepository.js +47 -0
  245. package/features/file/ListTags/ListTagsRepository.js.map +1 -0
  246. package/features/file/ListTags/ListTagsUseCase.d.ts +13 -0
  247. package/features/file/ListTags/ListTagsUseCase.js +31 -0
  248. package/features/file/ListTags/ListTagsUseCase.js.map +1 -0
  249. package/features/file/ListTags/abstractions.d.ts +45 -0
  250. package/features/file/ListTags/abstractions.js +17 -0
  251. package/features/file/ListTags/abstractions.js.map +1 -0
  252. package/features/file/ListTags/feature.d.ts +4 -0
  253. package/features/file/ListTags/feature.js +12 -0
  254. package/features/file/ListTags/feature.js.map +1 -0
  255. package/features/file/ListTags/index.d.ts +1 -0
  256. package/features/file/ListTags/index.js +3 -0
  257. package/features/file/ListTags/index.js.map +1 -0
  258. package/features/file/UpdateFile/UpdateFileRepository.d.ts +15 -0
  259. package/features/file/UpdateFile/UpdateFileRepository.js +39 -0
  260. package/features/file/UpdateFile/UpdateFileRepository.js.map +1 -0
  261. package/features/file/UpdateFile/UpdateFileUseCase.d.ts +20 -0
  262. package/features/file/UpdateFile/UpdateFileUseCase.js +79 -0
  263. package/features/file/UpdateFile/UpdateFileUseCase.js.map +1 -0
  264. package/features/file/UpdateFile/abstractions.d.ts +56 -0
  265. package/features/file/UpdateFile/abstractions.js +17 -0
  266. package/features/file/UpdateFile/abstractions.js.map +1 -0
  267. package/features/file/UpdateFile/events.d.ts +34 -0
  268. package/features/file/UpdateFile/events.js +32 -0
  269. package/features/file/UpdateFile/events.js.map +1 -0
  270. package/features/file/UpdateFile/feature.d.ts +4 -0
  271. package/features/file/UpdateFile/feature.js +12 -0
  272. package/features/file/UpdateFile/feature.js.map +1 -0
  273. package/features/file/UpdateFile/index.d.ts +2 -0
  274. package/features/file/UpdateFile/index.js +4 -0
  275. package/features/file/UpdateFile/index.js.map +1 -0
  276. package/features/file/shared/EntryToFileMapper.d.ts +5 -0
  277. package/features/file/shared/EntryToFileMapper.js +27 -0
  278. package/features/file/shared/EntryToFileMapper.js.map +1 -0
  279. package/features/file/shared/FileInputToEntryInputMapper.d.ts +5 -0
  280. package/features/file/shared/FileInputToEntryInputMapper.js +31 -0
  281. package/features/file/shared/FileInputToEntryInputMapper.js.map +1 -0
  282. package/features/file/shared/FileToEntryMapper.d.ts +5 -0
  283. package/features/file/shared/FileToEntryMapper.js +30 -0
  284. package/features/file/shared/FileToEntryMapper.js.map +1 -0
  285. package/features/permissions/abstractions.d.ts +21 -0
  286. package/features/permissions/abstractions.js +5 -0
  287. package/features/permissions/abstractions.js.map +1 -0
  288. package/features/permissions/feature.d.ts +4 -0
  289. package/features/permissions/feature.js +6 -0
  290. package/features/permissions/feature.js.map +1 -0
  291. package/features/settings/GetSettings/GetSettingsUseCase.d.ts +13 -0
  292. package/features/settings/GetSettings/GetSettingsUseCase.js +28 -0
  293. package/features/settings/GetSettings/GetSettingsUseCase.js.map +1 -0
  294. package/features/settings/GetSettings/abstractions.d.ts +18 -0
  295. package/features/settings/GetSettings/abstractions.js +10 -0
  296. package/features/settings/GetSettings/abstractions.js.map +1 -0
  297. package/features/settings/GetSettings/feature.d.ts +4 -0
  298. package/features/settings/GetSettings/feature.js +10 -0
  299. package/features/settings/GetSettings/feature.js.map +1 -0
  300. package/features/settings/SettingsInstaller/SettingsInstaller.d.ts +15 -0
  301. package/features/settings/SettingsInstaller/SettingsInstaller.js +35 -0
  302. package/features/settings/SettingsInstaller/SettingsInstaller.js.map +1 -0
  303. package/features/settings/SettingsInstaller/feature.d.ts +4 -0
  304. package/features/settings/SettingsInstaller/feature.js +10 -0
  305. package/features/settings/SettingsInstaller/feature.js.map +1 -0
  306. package/features/settings/UpdateSettings/UpdateSettingsUseCase.d.ts +18 -0
  307. package/features/settings/UpdateSettings/UpdateSettingsUseCase.js +62 -0
  308. package/features/settings/UpdateSettings/UpdateSettingsUseCase.js.map +1 -0
  309. package/features/settings/UpdateSettings/abstractions.d.ts +23 -0
  310. package/features/settings/UpdateSettings/abstractions.js +10 -0
  311. package/features/settings/UpdateSettings/abstractions.js.map +1 -0
  312. package/features/settings/UpdateSettings/events.d.ts +34 -0
  313. package/features/settings/UpdateSettings/events.js +32 -0
  314. package/features/settings/UpdateSettings/events.js.map +1 -0
  315. package/features/settings/UpdateSettings/feature.d.ts +4 -0
  316. package/features/settings/UpdateSettings/feature.js +10 -0
  317. package/features/settings/UpdateSettings/feature.js.map +1 -0
  318. package/features/settings/UpdateSettings/index.d.ts +2 -0
  319. package/features/settings/UpdateSettings/index.js +4 -0
  320. package/features/settings/UpdateSettings/index.js.map +1 -0
  321. package/features/shared/abstractions.d.ts +1 -0
  322. package/features/shared/abstractions.js +3 -0
  323. package/features/shared/abstractions.js.map +1 -0
  324. package/graphql/baseSchema.d.ts +2 -2
  325. package/graphql/baseSchema.js +20 -38
  326. package/graphql/baseSchema.js.map +1 -1
  327. package/graphql/createFilesTypeDefs.d.ts +3 -2
  328. package/graphql/createFilesTypeDefs.js +45 -30
  329. package/graphql/createFilesTypeDefs.js.map +1 -1
  330. package/graphql/filesSchema.d.ts +3 -3
  331. package/graphql/filesSchema.js +73 -46
  332. package/graphql/filesSchema.js.map +1 -1
  333. package/graphql/getFileByUrl.d.ts +2 -2
  334. package/graphql/getFileByUrl.js +17 -26
  335. package/graphql/getFileByUrl.js.map +1 -1
  336. package/graphql/index.d.ts +2 -2
  337. package/graphql/index.js +27 -28
  338. package/graphql/index.js.map +1 -1
  339. package/graphql/utils.d.ts +1 -1
  340. package/graphql/utils.js +6 -13
  341. package/graphql/utils.js.map +1 -1
  342. package/index.d.ts +6 -9
  343. package/index.js +28 -67
  344. package/index.js.map +1 -1
  345. package/modelModifier/CmsModelModifier.d.ts +1 -1
  346. package/modelModifier/CmsModelModifier.js +7 -15
  347. package/modelModifier/CmsModelModifier.js.map +1 -1
  348. package/package.json +31 -29
  349. package/types.d.ts +2 -367
  350. package/types.js +1 -27
  351. package/types.js.map +1 -1
  352. package/FileManagerContextSetup.d.ts +0 -13
  353. package/FileManagerContextSetup.js +0 -115
  354. package/FileManagerContextSetup.js.map +0 -1
  355. package/cmsFileStorage/CmsFilesStorage.d.ts +0 -27
  356. package/cmsFileStorage/CmsFilesStorage.js +0 -164
  357. package/cmsFileStorage/CmsFilesStorage.js.map +0 -1
  358. package/cmsFileStorage/ListFilesWhereProcessor.d.ts +0 -7
  359. package/cmsFileStorage/ListFilesWhereProcessor.js +0 -33
  360. package/cmsFileStorage/ListFilesWhereProcessor.js.map +0 -1
  361. package/cmsFileStorage/ListTagsWhereProcessor.d.ts +0 -7
  362. package/cmsFileStorage/ListTagsWhereProcessor.js +0 -33
  363. package/cmsFileStorage/ListTagsWhereProcessor.js.map +0 -1
  364. package/cmsFileStorage/file.model.d.ts +0 -6
  365. package/cmsFileStorage/file.model.js +0 -158
  366. package/cmsFileStorage/file.model.js.map +0 -1
  367. package/createFileManager/files.crud.d.ts +0 -3
  368. package/createFileManager/files.crud.js +0 -328
  369. package/createFileManager/files.crud.js.map +0 -1
  370. package/createFileManager/index.d.ts +0 -3
  371. package/createFileManager/index.js +0 -23
  372. package/createFileManager/index.js.map +0 -1
  373. package/createFileManager/permissions/FilesPermissions.d.ts +0 -4
  374. package/createFileManager/permissions/FilesPermissions.js +0 -11
  375. package/createFileManager/permissions/FilesPermissions.js.map +0 -1
  376. package/createFileManager/permissions/SettingsPermissions.d.ts +0 -4
  377. package/createFileManager/permissions/SettingsPermissions.js +0 -11
  378. package/createFileManager/permissions/SettingsPermissions.js.map +0 -1
  379. package/createFileManager/settings.crud.d.ts +0 -3
  380. package/createFileManager/settings.crud.js +0 -117
  381. package/createFileManager/settings.crud.js.map +0 -1
  382. package/createFileManager/system.crud.d.ts +0 -3
  383. package/createFileManager/system.crud.js +0 -88
  384. package/createFileManager/system.crud.js.map +0 -1
  385. package/createFileManager/types.d.ts +0 -16
  386. package/createFileManager/types.js +0 -7
  387. package/createFileManager/types.js.map +0 -1
  388. package/delivery/AssetDelivery/AliasAssetRequestResolver.d.ts +0 -11
  389. package/delivery/AssetDelivery/AliasAssetRequestResolver.js +0 -74
  390. package/delivery/AssetDelivery/AliasAssetRequestResolver.js.map +0 -1
  391. package/delivery/AssetDelivery/privateFiles/internalIdentity.d.ts +0 -7
  392. package/delivery/AssetDelivery/privateFiles/internalIdentity.js +0 -18
  393. package/delivery/AssetDelivery/privateFiles/internalIdentity.js.map +0 -1
  394. package/enterprise/applyThreatScanning.d.ts +0 -2
  395. package/enterprise/applyThreatScanning.js +0 -20
  396. package/enterprise/applyThreatScanning.js.map +0 -1
  397. package/handlers/manage/imageManager.d.ts +0 -14
  398. package/handlers/manage/imageManager.js +0 -75
  399. package/handlers/manage/imageManager.js.map +0 -1
  400. package/handlers/manage/index.d.ts +0 -5
  401. package/handlers/manage/index.js +0 -59
  402. package/handlers/manage/index.js.map +0 -1
  403. package/handlers/manage/legacyUtils.d.ts +0 -12
  404. package/handlers/manage/legacyUtils.js +0 -34
  405. package/handlers/manage/legacyUtils.js.map +0 -1
  406. package/handlers/manage/utils.d.ts +0 -12
  407. package/handlers/manage/utils.js +0 -34
  408. package/handlers/manage/utils.js.map +0 -1
  409. package/handlers/types.d.ts +0 -8
  410. package/handlers/types.js +0 -7
  411. package/handlers/types.js.map +0 -1
  412. package/handlers/utils/getEnvironment.d.ts +0 -5
  413. package/handlers/utils/getEnvironment.js +0 -13
  414. package/handlers/utils/getEnvironment.js.map +0 -1
  415. package/handlers/utils/getObjectParams.d.ts +0 -9
  416. package/handlers/utils/getObjectParams.js +0 -23
  417. package/handlers/utils/getObjectParams.js.map +0 -1
  418. package/handlers/utils/index.d.ts +0 -2
  419. package/handlers/utils/index.js +0 -22
  420. package/handlers/utils/index.js.map +0 -1
  421. package/plugins/FilePhysicalStoragePlugin.d.ts +0 -22
  422. package/plugins/FilePhysicalStoragePlugin.js +0 -31
  423. package/plugins/FilePhysicalStoragePlugin.js.map +0 -1
  424. package/plugins/FileStorageTransformPlugin.d.ts +0 -34
  425. package/plugins/FileStorageTransformPlugin.js +0 -39
  426. package/plugins/FileStorageTransformPlugin.js.map +0 -1
  427. package/plugins/index.d.ts +0 -2
  428. package/plugins/index.js +0 -29
  429. package/plugins/index.js.map +0 -1
  430. package/storage/FileStorage.d.ts +0 -34
  431. package/storage/FileStorage.js +0 -90
  432. package/storage/FileStorage.js.map +0 -1
  433. package/types/file.d.ts +0 -49
  434. package/types/file.js +0 -7
  435. package/types/file.js.map +0 -1
  436. package/types/file.lifecycle.d.ts +0 -44
  437. package/types/file.lifecycle.js +0 -7
  438. package/types/file.lifecycle.js.map +0 -1
@@ -1,26 +1,32 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createFilesSchema = void 0;
7
- var _handlerGraphql = require("@webiny/handler-graphql");
8
- var _utils = require("./utils");
9
- var _createFilesTypeDefs = require("./createFilesTypeDefs");
10
- var _apiSecurity = require("@webiny/api-security");
11
- const createFilesSchema = params => {
12
- const fileManagerGraphQL = new _handlerGraphql.GraphQLSchemaPlugin({
13
- typeDefs: (0, _createFilesTypeDefs.createFilesTypeDefs)(params),
1
+ import { ErrorResponse, GraphQLSchemaPlugin, ListResponse, Response } from "@webiny/handler-graphql";
2
+ import { emptyResolver, resolve } from "./utils.js";
3
+ import { createFilesTypeDefs } from "./createFilesTypeDefs.js";
4
+ import NotAuthorizedResponse from "@webiny/api-core/graphql/security/NotAuthorizedResponse.js";
5
+ import { GetFileUseCase } from "../features/file/GetFile/abstractions.js";
6
+ import { ListFilesUseCase } from "../features/file/ListFiles/abstractions.js";
7
+ import { ListTagsUseCase } from "../features/file/ListTags/abstractions.js";
8
+ import { CreateFileUseCase } from "../features/file/CreateFile/abstractions.js";
9
+ import { CreateFilesInBatchUseCase } from "../features/file/CreateFilesInBatch/abstractions.js";
10
+ import { UpdateFileUseCase } from "../features/file/UpdateFile/abstractions.js";
11
+ import { DeleteFileUseCase } from "../features/file/DeleteFile/abstractions.js";
12
+ import { GetSettingsUseCase } from "../features/settings/GetSettings/abstractions.js";
13
+ import { FileModel } from "../domain/file/abstractions.js";
14
+ export const createFilesSchema = params => {
15
+ const fileManagerGraphQL = new GraphQLSchemaPlugin({
16
+ typeDefs: createFilesTypeDefs(params),
14
17
  resolvers: {
15
18
  Query: {
16
- fileManager: _utils.emptyResolver
19
+ fileManager: emptyResolver
17
20
  },
18
21
  Mutation: {
19
- fileManager: _utils.emptyResolver
22
+ fileManager: emptyResolver
20
23
  },
21
24
  FmFile: {
22
25
  async src(file, _, context) {
23
- const settings = await context.fileManager.getSettings();
26
+ // TODO: create `FileUrlGenerator` service to use here
27
+ const getSettings = context.container.resolve(GetSettingsUseCase);
28
+ const result = await getSettings.execute();
29
+ const settings = result.value;
24
30
  return (settings?.srcPrefix || "") + file.key;
25
31
  }
26
32
  },
@@ -28,55 +34,77 @@ const createFilesSchema = params => {
28
34
  getFileModel(_, __, context) {
29
35
  const identity = context.security.getIdentity();
30
36
  if (!identity) {
31
- return new _apiSecurity.NotAuthorizedResponse();
37
+ return new NotAuthorizedResponse();
32
38
  }
33
- return (0, _utils.resolve)(() => context.cms.getModel("fmFile"));
39
+ return resolve(async () => {
40
+ return context.container.resolve(FileModel);
41
+ });
34
42
  },
35
- getFile(_, args, context) {
36
- return (0, _utils.resolve)(() => context.fileManager.getFile(args.id));
43
+ async getFile(_, args, context) {
44
+ const getFile = context.container.resolve(GetFileUseCase);
45
+ const result = await getFile.execute(args.id);
46
+ if (result.isFail()) {
47
+ return new ErrorResponse(result.error);
48
+ }
49
+ return new Response(result.value);
37
50
  },
38
51
  async listFiles(_, args, context) {
39
- try {
40
- const [data, meta] = await context.fileManager.listFiles(args);
41
- return new _handlerGraphql.ListResponse(data, meta);
42
- } catch (e) {
43
- return new _handlerGraphql.ErrorResponse(e);
52
+ const listFiles = context.container.resolve(ListFilesUseCase);
53
+ const result = await listFiles.execute(args);
54
+ if (result.isFail()) {
55
+ return new ErrorResponse(result.error);
44
56
  }
57
+ return new ListResponse(result.value.items, result.value.meta);
45
58
  },
46
59
  async listTags(_, args, context) {
47
- try {
48
- const tags = await context.fileManager.listTags(args || {});
49
- return new _handlerGraphql.Response(tags);
50
- } catch (error) {
51
- return new _handlerGraphql.ErrorResponse(error);
60
+ const listTags = context.container.resolve(ListTagsUseCase);
61
+ const result = await listTags.execute(args || {});
62
+ if (result.isFail()) {
63
+ return new ErrorResponse(result.error);
52
64
  }
65
+ return new Response(result.value);
53
66
  }
54
67
  },
55
68
  FmMutation: {
56
69
  async createFile(_, args, context) {
57
- return (0, _utils.resolve)(() => {
58
- return context.fileManager.createFile(args.data, args.meta);
59
- });
70
+ const createFile = context.container.resolve(CreateFileUseCase);
71
+ const result = await createFile.execute(args.data);
72
+ if (result.isFail()) {
73
+ return new ErrorResponse(result.error);
74
+ }
75
+ return new Response(result.value);
60
76
  },
61
77
  async createFiles(_, args, context) {
62
- return (0, _utils.resolve)(() => {
63
- return context.fileManager.createFilesInBatch(args.data, args.meta);
78
+ const createFilesInBatch = context.container.resolve(CreateFilesInBatchUseCase);
79
+ const result = await createFilesInBatch.execute({
80
+ files: args.data,
81
+ meta: args.meta
64
82
  });
83
+ if (result.isFail()) {
84
+ return new ErrorResponse(result.error);
85
+ }
86
+ return new Response(result.value);
65
87
  },
66
88
  async updateFile(_, args, context) {
67
- return (0, _utils.resolve)(() => {
68
- return context.fileManager.updateFile(args.id, args.data);
89
+ const updateFile = context.container.resolve(UpdateFileUseCase);
90
+ const result = await updateFile.execute({
91
+ id: args.id,
92
+ ...args.data
69
93
  });
94
+ if (result.isFail()) {
95
+ return new ErrorResponse(result.error);
96
+ }
97
+ return new Response(result.value);
70
98
  },
71
99
  async deleteFile(_, args, context) {
72
- return (0, _utils.resolve)(async () => {
73
- // TODO: Ideally, this should work via a lifecycle hook; first we delete a record from DB, then from cloud storage.
74
- const file = await context.fileManager.getFile(args.id);
75
- return await context.fileManager.storage.delete({
76
- id: file.id,
77
- key: file.key
78
- });
79
- });
100
+ const deleteFile = context.container.resolve(DeleteFileUseCase);
101
+ const result = await deleteFile.execute(args.id);
102
+ if (result.isFail()) {
103
+ return new ErrorResponse(result.error);
104
+ }
105
+
106
+ // TODO: deletion from Cloud storage should be implemented in the `api-file-manager-s3` as an event handler
107
+ return new Response(true);
80
108
  }
81
109
  }
82
110
  }
@@ -84,6 +112,5 @@ const createFilesSchema = params => {
84
112
  fileManagerGraphQL.name = "fm.graphql.files";
85
113
  return fileManagerGraphQL;
86
114
  };
87
- exports.createFilesSchema = createFilesSchema;
88
115
 
89
116
  //# sourceMappingURL=filesSchema.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_handlerGraphql","require","_utils","_createFilesTypeDefs","_apiSecurity","createFilesSchema","params","fileManagerGraphQL","GraphQLSchemaPlugin","typeDefs","createFilesTypeDefs","resolvers","Query","fileManager","emptyResolver","Mutation","FmFile","src","file","_","context","settings","getSettings","srcPrefix","key","FmQuery","getFileModel","__","identity","security","getIdentity","NotAuthorizedResponse","resolve","cms","getModel","getFile","args","id","listFiles","data","meta","ListResponse","e","ErrorResponse","listTags","tags","Response","error","FmMutation","createFile","createFiles","createFilesInBatch","updateFile","deleteFile","storage","delete","name","exports"],"sources":["filesSchema.ts"],"sourcesContent":["import {\n ErrorResponse,\n GraphQLSchemaPlugin,\n ListResponse,\n Response\n} from \"@webiny/handler-graphql\";\nimport type { FileManagerContext, FilesListOpts } from \"~/types\";\nimport { emptyResolver, resolve } from \"./utils\";\nimport type { CreateFilesTypeDefsParams } from \"~/graphql/createFilesTypeDefs\";\nimport { createFilesTypeDefs } from \"~/graphql/createFilesTypeDefs\";\nimport { NotAuthorizedResponse } from \"@webiny/api-security\";\n\nexport const createFilesSchema = (params: CreateFilesTypeDefsParams) => {\n const fileManagerGraphQL = new GraphQLSchemaPlugin<FileManagerContext>({\n typeDefs: createFilesTypeDefs(params),\n resolvers: {\n Query: {\n fileManager: emptyResolver\n },\n Mutation: {\n fileManager: emptyResolver\n },\n FmFile: {\n async src(file, _, context) {\n const settings = await context.fileManager.getSettings();\n return (settings?.srcPrefix || \"\") + file.key;\n }\n },\n FmQuery: {\n getFileModel(_, __, context) {\n const identity = context.security.getIdentity();\n if (!identity) {\n return new NotAuthorizedResponse();\n }\n\n return resolve(() => context.cms.getModel(\"fmFile\"));\n },\n getFile(_, args: any, context) {\n return resolve(() => context.fileManager.getFile(args.id));\n },\n async listFiles(_, args: FilesListOpts, context) {\n try {\n const [data, meta] = await context.fileManager.listFiles(args);\n\n return new ListResponse(data, meta);\n } catch (e) {\n return new ErrorResponse(e);\n }\n },\n async listTags(_, args: any, context) {\n try {\n const tags = await context.fileManager.listTags(args || {});\n\n return new Response(tags);\n } catch (error) {\n return new ErrorResponse(error);\n }\n }\n },\n FmMutation: {\n async createFile(_, args: any, context) {\n return resolve(() => {\n return context.fileManager.createFile(args.data, args.meta);\n });\n },\n async createFiles(_, args: any, context) {\n return resolve(() => {\n return context.fileManager.createFilesInBatch(args.data, args.meta);\n });\n },\n async updateFile(_, args: any, context) {\n return resolve(() => {\n return context.fileManager.updateFile(args.id, args.data);\n });\n },\n async deleteFile(_, args: any, context) {\n return resolve(async () => {\n // TODO: Ideally, this should work via a lifecycle hook; first we delete a record from DB, then from cloud storage.\n const file = await context.fileManager.getFile(args.id);\n return await context.fileManager.storage.delete({\n id: file.id,\n key: file.key\n });\n });\n }\n }\n }\n });\n fileManagerGraphQL.name = \"fm.graphql.files\";\n\n return fileManagerGraphQL;\n};\n"],"mappings":";;;;;;AAAA,IAAAA,eAAA,GAAAC,OAAA;AAOA,IAAAC,MAAA,GAAAD,OAAA;AAEA,IAAAE,oBAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AAEO,MAAMI,iBAAiB,GAAIC,MAAiC,IAAK;EACpE,MAAMC,kBAAkB,GAAG,IAAIC,mCAAmB,CAAqB;IACnEC,QAAQ,EAAE,IAAAC,wCAAmB,EAACJ,MAAM,CAAC;IACrCK,SAAS,EAAE;MACPC,KAAK,EAAE;QACHC,WAAW,EAAEC;MACjB,CAAC;MACDC,QAAQ,EAAE;QACNF,WAAW,EAAEC;MACjB,CAAC;MACDE,MAAM,EAAE;QACJ,MAAMC,GAAGA,CAACC,IAAI,E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,IAAI,CAACM;YACd,CAAC,CAAC;UACN,CAAC,CAAC;QACN;MACJ;IACJ;EACJ,CAAC,CAAC;EACFjB,kBAAkB,CAACiD,IAAI,GAAG,kBAAkB;EAE5C,OAAOjD,kBAAkB;AAC7B,CAAC;AAACkD,OAAA,CAAApD,iBAAA,GAAAA,iBAAA","ignoreList":[]}
1
+ {"version":3,"names":["ErrorResponse","GraphQLSchemaPlugin","ListResponse","Response","emptyResolver","resolve","createFilesTypeDefs","NotAuthorizedResponse","GetFileUseCase","ListFilesUseCase","ListTagsUseCase","CreateFileUseCase","CreateFilesInBatchUseCase","UpdateFileUseCase","DeleteFileUseCase","GetSettingsUseCase","FileModel","createFilesSchema","params","fileManagerGraphQL","typeDefs","resolvers","Query","fileManager","Mutation","FmFile","src","file","_","context","getSettings","container","result","execute","settings","value","srcPrefix","key","FmQuery","getFileModel","__","identity","security","getIdentity","getFile","args","id","isFail","error","listFiles","items","meta","listTags","FmMutation","createFile","data","createFiles","createFilesInBatch","files","updateFile","deleteFile","name"],"sources":["filesSchema.ts"],"sourcesContent":["import {\n ErrorResponse,\n GraphQLSchemaPlugin,\n ListResponse,\n Response\n} from \"@webiny/handler-graphql\";\nimport { emptyResolver, resolve } from \"./utils.js\";\nimport type { CreateFilesTypeDefsParams } from \"~/graphql/createFilesTypeDefs.js\";\nimport { createFilesTypeDefs } from \"~/graphql/createFilesTypeDefs.js\";\nimport NotAuthorizedResponse from \"@webiny/api-core/graphql/security/NotAuthorizedResponse.js\";\nimport { GetFileUseCase } from \"~/features/file/GetFile/abstractions.js\";\nimport { ListFilesUseCase } from \"~/features/file/ListFiles/abstractions.js\";\nimport { ListTagsUseCase } from \"~/features/file/ListTags/abstractions.js\";\nimport { CreateFileUseCase } from \"~/features/file/CreateFile/abstractions.js\";\nimport { CreateFilesInBatchUseCase } from \"~/features/file/CreateFilesInBatch/abstractions.js\";\nimport { UpdateFileUseCase } from \"~/features/file/UpdateFile/abstractions.js\";\nimport { DeleteFileUseCase } from \"~/features/file/DeleteFile/abstractions.js\";\nimport { GetSettingsUseCase } from \"~/features/settings/GetSettings/abstractions.js\";\nimport type { ApiCoreContext } from \"@webiny/api-core/types/core.js\";\nimport { FileModel } from \"~/domain/file/abstractions.js\";\n\nexport const createFilesSchema = (params: CreateFilesTypeDefsParams) => {\n const fileManagerGraphQL = new GraphQLSchemaPlugin<ApiCoreContext>({\n typeDefs: createFilesTypeDefs(params),\n resolvers: {\n Query: {\n fileManager: emptyResolver\n },\n Mutation: {\n fileManager: emptyResolver\n },\n FmFile: {\n async src(file, _, context) {\n // TODO: create `FileUrlGenerator` service to use here\n const getSettings = context.container.resolve(GetSettingsUseCase);\n const result = await getSettings.execute();\n const settings = result.value;\n return (settings?.srcPrefix || \"\") + file.key;\n }\n },\n FmQuery: {\n getFileModel(_, __, context) {\n const identity = context.security.getIdentity();\n if (!identity) {\n return new NotAuthorizedResponse();\n }\n\n return resolve(async () => {\n return context.container.resolve(FileModel);\n });\n },\n async getFile(_, args: any, context) {\n const getFile = context.container.resolve(GetFileUseCase);\n const result = await getFile.execute(args.id);\n\n if (result.isFail()) {\n return new ErrorResponse(result.error);\n }\n\n return new Response(result.value);\n },\n async listFiles(_, args, context) {\n const listFiles = context.container.resolve(ListFilesUseCase);\n const result = await listFiles.execute(args);\n\n if (result.isFail()) {\n return new ErrorResponse(result.error);\n }\n\n return new ListResponse(result.value.items, result.value.meta);\n },\n async listTags(_, args: any, context) {\n const listTags = context.container.resolve(ListTagsUseCase);\n const result = await listTags.execute(args || {});\n\n if (result.isFail()) {\n return new ErrorResponse(result.error);\n }\n\n return new Response(result.value);\n }\n },\n FmMutation: {\n async createFile(_, args: any, context) {\n const createFile = context.container.resolve(CreateFileUseCase);\n const result = await createFile.execute(args.data);\n\n if (result.isFail()) {\n return new ErrorResponse(result.error);\n }\n\n return new Response(result.value);\n },\n async createFiles(_, args: any, context) {\n const createFilesInBatch = context.container.resolve(CreateFilesInBatchUseCase);\n const result = await createFilesInBatch.execute({\n files: args.data,\n meta: args.meta\n });\n\n if (result.isFail()) {\n return new ErrorResponse(result.error);\n }\n\n return new Response(result.value);\n },\n async updateFile(_, args: any, context) {\n const updateFile = context.container.resolve(UpdateFileUseCase);\n const result = await updateFile.execute({\n id: args.id,\n ...args.data\n });\n\n if (result.isFail()) {\n return new ErrorResponse(result.error);\n }\n\n return new Response(result.value);\n },\n async deleteFile(_, args: any, context) {\n const deleteFile = context.container.resolve(DeleteFileUseCase);\n const result = await deleteFile.execute(args.id);\n\n if (result.isFail()) {\n return new ErrorResponse(result.error);\n }\n\n // TODO: deletion from Cloud storage should be implemented in the `api-file-manager-s3` as an event handler\n return new Response(true);\n }\n }\n }\n });\n fileManagerGraphQL.name = \"fm.graphql.files\";\n\n return fileManagerGraphQL;\n};\n"],"mappings":"AAAA,SACIA,aAAa,EACbC,mBAAmB,EACnBC,YAAY,EACZC,QAAQ,QACL,yBAAyB;AAChC,SAASC,aAAa,EAAEC,OAAO;AAE/B,SAASC,mBAAmB;AAC5B,OAAOC,qBAAqB,MAAM,4DAA4D;AAC9F,SAASC,cAAc;AACvB,SAASC,gBAAgB;AACzB,SAASC,eAAe;AACxB,SAASC,iBAAiB;AAC1B,SAASC,yBAAyB;AAClC,SAASC,iBAAiB;AAC1B,SAASC,iBAAiB;AAC1B,SAASC,kBAAkB;AAE3B,SAASC,SAAS;AAElB,OAAO,MAAMC,iBAAiB,GAAIC,MAAiC,IAAK;EACpE,MAAMC,kBAAkB,GAAG,IAAIlB,mBAAmB,CAAiB;IAC/DmB,QAAQ,EAAEd,mBAAmB,CAACY,MAAM,CAAC;IACrCG,SAAS,EAAE;MACPC,KAAK,EAAE;QACHC,WAAW,EAAEnB;MACjB,CAAC;MACDoB,QAAQ,EAAE;QACND,WAAW,EAAEnB;MACjB,CAAC;MACDqB,MAAM,EAAE;QACJ,MAAMC,GAAGA,CAACC,IAAI,EAAEC,CAAC,EAAEC,OAAO,EAAE;UACxB;UACA,MAAMC,WAAW,GAAGD,OAAO,CA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A;UACA,OAAO,IAAI7C,QAAQ,CAAC,IAAI,CAAC;QAC7B;MACJ;IACJ;EACJ,CAAC,CAAC;EACFgB,kBAAkB,CAAC0C,IAAI,GAAG,kBAAkB;EAE5C,OAAO1C,kBAAkB;AAC7B,CAAC","ignoreList":[]}
@@ -1,3 +1,3 @@
1
1
  import { GraphQLSchemaPlugin } from "@webiny/handler-graphql";
2
- import type { FileManagerContext } from "../types";
3
- export declare const getFileByUrl: () => GraphQLSchemaPlugin<FileManagerContext>;
2
+ import type { ApiCoreContext } from "@webiny/api-core/types/core.js";
3
+ export declare const getFileByUrl: () => GraphQLSchemaPlugin<ApiCoreContext>;
@@ -1,13 +1,9 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getFileByUrl = void 0;
7
- var _handlerGraphql = require("@webiny/handler-graphql");
8
- var _apiSecurity = require("@webiny/api-security");
9
- const getFileByUrl = () => {
10
- const fileManagerGraphQL = new _handlerGraphql.GraphQLSchemaPlugin({
1
+ import { ErrorResponse, GraphQLSchemaPlugin } from "@webiny/handler-graphql";
2
+ import { Response, NotFoundResponse } from "@webiny/handler-graphql";
3
+ import { NotAuthorizedError } from "@webiny/api-core/features/security/shared/index.js";
4
+ import { ListFilesUseCase } from "../features/file/ListFiles/index.js";
5
+ export const getFileByUrl = () => {
6
+ const fileManagerGraphQL = new GraphQLSchemaPlugin({
11
7
  typeDefs: /* GraphQL */`
12
8
  extend type FmQuery {
13
9
  getFileByUrl(url: String!): FmFileResponse
@@ -19,15 +15,15 @@ const getFileByUrl = () => {
19
15
  const {
20
16
  url
21
17
  } = args;
22
- const useCase = new SecureGetFileByUrl(context.security, new GetFileByUrlUseCase(context.fileManager));
18
+ const useCase = new SecureGetFileByUrl(context.security, new GetFileByUrlUseCase(context.container.resolve(ListFilesUseCase)));
23
19
  try {
24
20
  const file = await useCase.execute(url);
25
21
  if (file) {
26
- return new _handlerGraphql.Response(file);
22
+ return new Response(file);
27
23
  }
28
- return new _handlerGraphql.NotFoundResponse("File not found!");
24
+ return new NotFoundResponse("File not found!");
29
25
  } catch (error) {
30
- return new _handlerGraphql.ErrorResponse(error);
26
+ return new ErrorResponse(error);
31
27
  }
32
28
  }
33
29
  }
@@ -36,27 +32,22 @@ const getFileByUrl = () => {
36
32
  fileManagerGraphQL.name = "fm.graphql.getFileByUrl";
37
33
  return fileManagerGraphQL;
38
34
  };
39
- exports.getFileByUrl = getFileByUrl;
40
35
  class GetFileByUrlUseCase {
41
- constructor(fileManager) {
42
- this.fileManager = fileManager;
36
+ constructor(listFiles) {
37
+ this.listFiles = listFiles;
43
38
  }
44
39
  async execute(url) {
45
40
  const {
46
41
  pathname
47
42
  } = new URL(url);
48
- const isAlias = !pathname.startsWith("/files/") && !pathname.startsWith("/private/");
49
- const query = isAlias ? pathname : pathname.replace("/files/", "").replace("/private/", "");
50
- const [files] = await this.fileManager.listFiles({
43
+ const query = pathname.replace("/files/", "").replace("/private/", "");
44
+ const filesResult = await this.listFiles.execute({
51
45
  where: {
52
- OR: [{
53
- key: query
54
- }, {
55
- aliases_contains: query
56
- }]
46
+ key: query
57
47
  },
58
48
  limit: 1
59
49
  });
50
+ const files = filesResult.value.items;
60
51
  return files.length ? files[0] : undefined;
61
52
  }
62
53
  }
@@ -67,7 +58,7 @@ class SecureGetFileByUrl {
67
58
  }
68
59
  execute(url) {
69
60
  if (!this.security.getIdentity()) {
70
- throw new _apiSecurity.NotAuthorizedError({
61
+ throw new NotAuthorizedError({
71
62
  message: "You're not authorized to edit this file!"
72
63
  });
73
64
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_handlerGraphql","require","_apiSecurity","getFileByUrl","fileManagerGraphQL","GraphQLSchemaPlugin","typeDefs","resolvers","FmQuery","_","args","context","url","useCase","SecureGetFileByUrl","security","GetFileByUrlUseCase","fileManager","file","execute","Response","NotFoundResponse","error","ErrorResponse","name","exports","constructor","pathname","URL","isAlias","startsWith","query","replace","files","listFiles","where","OR","key","aliases_contains","limit","length","undefined","getIdentity","NotAuthorizedError","message"],"sources":["getFileByUrl.ts"],"sourcesContent":["import { ErrorResponse, GraphQLSchemaPlugin } from \"@webiny/handler-graphql\";\nimport { Response, NotFoundResponse } from \"@webiny/handler-graphql\";\nimport type { FileManagerContext, FileManagerContextObject, File } from \"~/types\";\nimport type { Security } from \"@webiny/api-security/types\";\nimport { NotAuthorizedError } from \"@webiny/api-security\";\n\nexport const getFileByUrl = () => {\n const fileManagerGraphQL = new GraphQLSchemaPlugin<FileManagerContext>({\n typeDefs: /* GraphQL */ `\n extend type FmQuery {\n getFileByUrl(url: String!): FmFileResponse\n }\n `,\n resolvers: {\n FmQuery: {\n async getFileByUrl(_, args, context) {\n const { url } = args as { url: string };\n const useCase = new SecureGetFileByUrl(\n context.security,\n new GetFileByUrlUseCase(context.fileManager)\n );\n try {\n const file = await useCase.execute(url);\n if (file) {\n return new Response(file);\n }\n return new NotFoundResponse(\"File not found!\");\n } catch (error) {\n return new ErrorResponse(error);\n }\n }\n }\n }\n });\n fileManagerGraphQL.name = \"fm.graphql.getFileByUrl\";\n\n return fileManagerGraphQL;\n};\n\ninterface IGetFileByUrl {\n execute(url: string): Promise<File | undefined>;\n}\n\nclass GetFileByUrlUseCase implements IGetFileByUrl {\n private readonly fileManager: FileManagerContextObject;\n\n constructor(fileManager: FileManagerContextObject) {\n this.fileManager = fileManager;\n }\n\n async execute(url: string): Promise<File | undefined> {\n const { pathname } = new URL(url);\n const isAlias = !pathname.startsWith(\"/files/\") && !pathname.startsWith(\"/private/\");\n const query = isAlias ? pathname : pathname.replace(\"/files/\", \"\").replace(\"/private/\", \"\");\n\n const [files] = await this.fileManager.listFiles({\n where: {\n OR: [{ key: query }, { aliases_contains: query }]\n },\n limit: 1\n });\n\n return files.length ? files[0] : undefined;\n }\n}\n\nclass SecureGetFileByUrl implements IGetFileByUrl {\n private security: Security;\n private useCase: IGetFileByUrl;\n\n constructor(security: Security, useCase: IGetFileByUrl) {\n this.security = security;\n this.useCase = useCase;\n }\n\n execute(url: string): Promise<File | undefined> {\n if (!this.security.getIdentity()) {\n throw new NotAuthorizedError({ message: \"You're not authorized to edit this file!\" });\n }\n\n return this.useCase.execute(url);\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,eAAA,GAAAC,OAAA;AAIA,IAAAC,YAAA,GAAAD,OAAA;AAEO,MAAME,YAAY,GAAGA,CAAA,KAAM;EAC9B,MAAMC,kBAAkB,GAAG,IAAIC,mCAAmB,CAAqB;IACnEC,QAAQ,EAAE,aAAc;AAChC;AACA;AACA;AACA,SAAS;IACDC,SAAS,EAAE;MACPC,OAAO,EAAE;QACL,MAAML,YAAYA,CAACM,CAAC,EAAEC,IAAI,EAAEC,OAAO,EAAE;UACjC,MAAM;YAAEC;UAAI,CAAC,GAAGF,IAAuB;UACvC,MAAMG,OAAO,GAAG,IAAIC,kBAAkB,CAClCH,OAAO,CAACI,QAAQ,EAChB,IAAIC,mBAAmB,CAACL,OAAO,CAACM,WAAW,CAC/C,CAAC;UACD,IAAI;YACA,MAAMC,IAAI,GAAG,MAAML,OAAO,CAACM,OAAO,CAACP,GAAG,CAAC;YACvC,IAAIM,IAAI,EAAE;cACN,OAAO,IAAIE,wBAAQ,CAACF,IAAI,CAAC;YAC7B;YACA,OAAO,IAAIG,gCAAgB,CAAC,iBAAiB,CAAC;UAClD,CAAC,CAAC,OAAOC,KAAK,EAAE;YACZ,OAAO,IAAIC,6BAAa,CAACD,KAAK,CAAC;UACnC;QACJ;MACJ;IACJ;EACJ,CAAC,CAAC;EACFlB,kBAAkB,CAACoB,IAAI,GAAG,yBAAyB;EAEnD,OAAOpB,kBAAkB;AAC7B,CAAC;AAACqB,OAAA,CAAAtB,YAAA,GAAAA,YAAA;AAMF,MAAMa,mBAAmB,CAA0B;EAG/CU,WAAWA,CAACT,WAAqC,EAAE;IAC/C,IAAI,CAACA,WAAW,GAAGA,WAAW;EAClC;EAEA,MAAME,OAAOA,CAACP,GAAW,EAA6B;IAClD,MAAM;MAAEe;IAAS,CAAC,GAAG,IAAIC,GAAG,CAAChB,GAAG,CAAC;IACjC,MAAMiB,OAAO,GAAG,CAACF,QAAQ,CAACG,UAAU,CAAC,SAAS,CAAC,IAAI,CAACH,QAAQ,CAACG,UAAU,CAAC,WAAW,CAAC;IACpF,MAAMC,KAAK,GAAGF,OAAO,GAAGF,QAAQ,GAAGA,QAAQ,CAACK,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAACA,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC;IAE3F,MAAM,CAACC,KAAK,CAAC,GAAG,MAAM,IAAI,CAAChB,WAAW,CAACiB,SAAS,CAAC;MAC7CC,KAAK,EAAE;QACHC,EAAE,EAAE,CAAC;UAAEC,GAAG,EAAEN;QAAM,CAAC,EAAE;UAAEO,gBAAgB,EAAEP;QAAM,CAAC;MACpD,CAAC;MACDQ,KAAK,EAAE;IACX,CAAC,CAAC;IAEF,OAAON,KAAK,CAACO,MAAM,GAAGP,KAAK,CAAC,CAAC,CAAC,GAAGQ,SAAS;EAC9C;AACJ;AAEA,MAAM3B,kBAAkB,CAA0B;EAI9CY,WAAWA,CAACX,QAAkB,EAAEF,OAAsB,EAAE;IACpD,IAAI,CAACE,QAAQ,GAAGA,QAAQ;IACxB,IAAI,CAACF,OAAO,GAAGA,OAAO;EAC1B;EAEAM,OAAOA,CAACP,GAAW,EAA6B;IAC5C,IAAI,CAAC,IAAI,CAACG,QAAQ,CAAC2B,WAAW,CAAC,CAAC,EAAE;MAC9B,MAAM,IAAIC,+BAAkB,CAAC;QAAEC,OAAO,EAAE;MAA2C,CAAC,CAAC;IACzF;IAEA,OAAO,IAAI,CAAC/B,OAAO,CAACM,OAAO,CAACP,GAAG,CAAC;EACpC;AACJ","ignoreList":[]}
1
+ {"version":3,"names":["ErrorResponse","GraphQLSchemaPlugin","Response","NotFoundResponse","NotAuthorizedError","ListFilesUseCase","getFileByUrl","fileManagerGraphQL","typeDefs","resolvers","FmQuery","_","args","context","url","useCase","SecureGetFileByUrl","security","GetFileByUrlUseCase","container","resolve","file","execute","error","name","constructor","listFiles","pathname","URL","query","replace","filesResult","where","key","limit","files","value","items","length","undefined","getIdentity","message"],"sources":["getFileByUrl.ts"],"sourcesContent":["import { ErrorResponse, GraphQLSchemaPlugin } from \"@webiny/handler-graphql\";\nimport { Response, NotFoundResponse } from \"@webiny/handler-graphql\";\nimport type { File } from \"~/domain/file/types.js\";\nimport type { Security } from \"@webiny/api-core/types/security.js\";\nimport { NotAuthorizedError } from \"@webiny/api-core/features/security/shared/index.js\";\nimport type { ApiCoreContext } from \"@webiny/api-core/types/core.js\";\nimport { ListFilesUseCase } from \"~/features/file/ListFiles/index.js\";\n\nexport const getFileByUrl = () => {\n const fileManagerGraphQL = new GraphQLSchemaPlugin<ApiCoreContext>({\n typeDefs: /* GraphQL */ `\n extend type FmQuery {\n getFileByUrl(url: String!): FmFileResponse\n }\n `,\n resolvers: {\n FmQuery: {\n async getFileByUrl(_, args, context) {\n const { url } = args as { url: string };\n const useCase = new SecureGetFileByUrl(\n context.security,\n new GetFileByUrlUseCase(context.container.resolve(ListFilesUseCase))\n );\n try {\n const file = await useCase.execute(url);\n if (file) {\n return new Response(file);\n }\n return new NotFoundResponse(\"File not found!\");\n } catch (error) {\n return new ErrorResponse(error);\n }\n }\n }\n }\n });\n fileManagerGraphQL.name = \"fm.graphql.getFileByUrl\";\n\n return fileManagerGraphQL;\n};\n\ninterface IGetFileByUrl {\n execute(url: string): Promise<File | undefined>;\n}\n\nclass GetFileByUrlUseCase implements IGetFileByUrl {\n constructor(private listFiles: ListFilesUseCase.Interface) {}\n\n async execute(url: string): Promise<File | undefined> {\n const { pathname } = new URL(url);\n const query = pathname.replace(\"/files/\", \"\").replace(\"/private/\", \"\");\n\n const filesResult = await this.listFiles.execute({\n where: {\n key: query\n },\n limit: 1\n });\n\n const files = filesResult.value.items;\n\n return files.length ? files[0] : undefined;\n }\n}\n\nclass SecureGetFileByUrl implements IGetFileByUrl {\n private security: Security;\n private useCase: IGetFileByUrl;\n\n constructor(security: Security, useCase: IGetFileByUrl) {\n this.security = security;\n this.useCase = useCase;\n }\n\n execute(url: string): Promise<File | undefined> {\n if (!this.security.getIdentity()) {\n throw new NotAuthorizedError({ message: \"You're not authorized to edit this file!\" });\n }\n\n return this.useCase.execute(url);\n }\n}\n"],"mappings":"AAAA,SAASA,aAAa,EAAEC,mBAAmB,QAAQ,yBAAyB;AAC5E,SAASC,QAAQ,EAAEC,gBAAgB,QAAQ,yBAAyB;AAGpE,SAASC,kBAAkB,QAAQ,oDAAoD;AAEvF,SAASC,gBAAgB;AAEzB,OAAO,MAAMC,YAAY,GAAGA,CAAA,KAAM;EAC9B,MAAMC,kBAAkB,GAAG,IAAIN,mBAAmB,CAAiB;IAC/DO,QAAQ,EAAE,aAAc;AAChC;AACA;AACA;AACA,SAAS;IACDC,SAAS,EAAE;MACPC,OAAO,EAAE;QACL,MAAMJ,YAAYA,CAACK,CAAC,EAAEC,IAAI,EAAEC,OAAO,EAAE;UACjC,MAAM;YAAEC;UAAI,CAAC,GAAGF,IAAuB;UACvC,MAAMG,OAAO,GAAG,IAAIC,kBAAkB,CAClCH,OAAO,CAACI,QAAQ,EAChB,IAAIC,mBAAmB,CAACL,OAAO,CAACM,SAAS,CAACC,OAAO,CAACf,gBAAgB,CAAC,CACvE,CAAC;UACD,IAAI;YACA,MAAMgB,IAAI,GAAG,MAAMN,OAAO,CAACO,OAAO,CAACR,GAAG,CAAC;YACvC,IAAIO,IAAI,EAAE;cACN,OAAO,IAAInB,QAAQ,CAACmB,IAAI,CAAC;YAC7B;YACA,OAAO,IAAIlB,gBAAgB,CAAC,iBAAiB,CAAC;UAClD,CAAC,CAAC,OAAOoB,KAAK,EAAE;YACZ,OAAO,IAAIvB,aAAa,CAACuB,KAAK,CAAC;UACnC;QACJ;MACJ;IACJ;EACJ,CAAC,CAAC;EACFhB,kBAAkB,CAACiB,IAAI,GAAG,yBAAyB;EAEnD,OAAOjB,kBAAkB;AAC7B,CAAC;AAMD,MAAMW,mBAAmB,CAA0B;EAC/CO,WAAWA,CAASC,SAAqC,EAAE;IAAA,KAAvCA,SAAqC,GAArCA,SAAqC;EAAG;EAE5D,MAAMJ,OAAOA,CAACR,GAAW,EAA6B;IAClD,MAAM;MAAEa;IAAS,CAAC,GAAG,IAAIC,GAAG,CAACd,GAAG,CAAC;IACjC,MAAMe,KAAK,GAAGF,QAAQ,CAACG,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAACA,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC;IAEtE,MAAMC,WAAW,GAAG,MAAM,IAAI,CAACL,SAAS,CAACJ,OAAO,CAAC;MAC7CU,KAAK,EAAE;QACHC,GAAG,EAAEJ;MACT,CAAC;MACDK,KAAK,EAAE;IACX,CAAC,CAAC;IAEF,MAAMC,KAAK,GAAGJ,WAAW,CAACK,KAAK,CAACC,KAAK;IAErC,OAAOF,KAAK,CAACG,MAAM,GAAGH,KAAK,CAAC,CAAC,CAAC,GAAGI,SAAS;EAC9C;AACJ;AAEA,MAAMvB,kBAAkB,CAA0B;EAI9CS,WAAWA,CAACR,QAAkB,EAAEF,OAAsB,EAAE;IACpD,IAAI,CAACE,QAAQ,GAAGA,QAAQ;IACxB,IAAI,CAACF,OAAO,GAAGA,OAAO;EAC1B;EAEAO,OAAOA,CAACR,GAAW,EAA6B;IAC5C,IAAI,CAAC,IAAI,CAACG,QAAQ,CAACuB,WAAW,CAAC,CAAC,EAAE;MAC9B,MAAM,IAAIpC,kBAAkB,CAAC;QAAEqC,OAAO,EAAE;MAA2C,CAAC,CAAC;IACzF;IAEA,OAAO,IAAI,CAAC1B,OAAO,CAACO,OAAO,CAACR,GAAG,CAAC;EACpC;AACJ","ignoreList":[]}
@@ -1,4 +1,4 @@
1
1
  import { ContextPlugin } from "@webiny/api";
2
+ import type { ApiCoreContext } from "@webiny/api-core/types/core.js";
2
3
  import { GraphQLSchemaPlugin } from "@webiny/handler-graphql";
3
- import type { FileManagerContext } from "../types";
4
- export declare const createGraphQLSchemaPlugin: () => (GraphQLSchemaPlugin<FileManagerContext> | ContextPlugin<FileManagerContext>)[];
4
+ export declare const createGraphQLSchemaPlugin: () => (GraphQLSchemaPlugin<ApiCoreContext> | ContextPlugin<ApiCoreContext>)[];
package/graphql/index.js CHANGED
@@ -1,55 +1,54 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createGraphQLSchemaPlugin = void 0;
7
- var _api = require("@webiny/api");
8
- var _apiHeadlessCms = require("@webiny/api-headless-cms");
9
- var _createFieldTypePluginRecords = require("@webiny/api-headless-cms/graphql/schema/createFieldTypePluginRecords");
10
- var _getSchemaFromFieldPlugins = require("@webiny/api-headless-cms/utils/getSchemaFromFieldPlugins");
11
- var _baseSchema = require("./baseSchema");
12
- var _handlerGraphql = require("@webiny/handler-graphql");
13
- var _filesSchema = require("./filesSchema");
14
- var _getFileByUrl = require("./getFileByUrl");
15
- const createGraphQLSchemaPlugin = () => {
16
- return [(0, _baseSchema.createBaseSchema)(),
1
+ import { ContextPlugin } from "@webiny/api";
2
+ import { GraphQLSchemaPlugin } from "@webiny/handler-graphql";
3
+ import { ListModelsUseCase } from "@webiny/api-headless-cms/features/contentModel/ListModels/index.js";
4
+ import { createGraphQLSchemaPluginFromFieldPlugins } from "@webiny/api-headless-cms/utils/getSchemaFromFieldPlugins.js";
5
+ import { createBaseSchema } from "./baseSchema.js";
6
+ import { createFilesSchema } from "./filesSchema.js";
7
+ import { getFileByUrl } from "./getFileByUrl.js";
8
+ import { FileModel } from "../domain/file/abstractions.js";
9
+ import { TenantContext } from "@webiny/api-core/features/tenancy/TenantContext/index.js";
10
+ import { CmsModelFieldToGraphQLRegistry } from "@webiny/api-headless-cms/exports/api/cms/graphql.js";
11
+ export const createGraphQLSchemaPlugin = () => {
12
+ return [createBaseSchema(),
17
13
  // Files schema is generated dynamically, based on a CMS model, so we need to
18
14
  // register it from a ContextPlugin, to perform additional bootstrap.
19
- new _api.ContextPlugin(async context => {
20
- if (!(await (0, _apiHeadlessCms.isHeadlessCmsReady)(context))) {
15
+ new ContextPlugin(async context => {
16
+ const tenantContext = context.container.resolve(TenantContext);
17
+ if (!tenantContext.getTenant()) {
21
18
  return;
22
19
  }
20
+ const fileModel = context.container.resolve(FileModel);
21
+ const listModels = context.container.resolve(ListModelsUseCase);
22
+ const fieldRegistry = context.container.resolve(CmsModelFieldToGraphQLRegistry);
23
23
  await context.security.withoutAuthorization(async () => {
24
- const fileModel = await context.cms.getModel("fmFile");
25
- const models = await context.cms.listModels();
26
- const fieldPlugins = (0, _createFieldTypePluginRecords.createFieldTypePluginRecords)(context.plugins);
24
+ const modelsResult = await listModels.execute();
25
+ const models = modelsResult.value;
26
+
27
27
  /**
28
28
  * We need to register all plugins for all the CMS fields.
29
29
  */
30
- const plugins = (0, _getSchemaFromFieldPlugins.createGraphQLSchemaPluginFromFieldPlugins)({
30
+ const plugins = createGraphQLSchemaPluginFromFieldPlugins({
31
31
  models,
32
32
  type: "manage",
33
- fieldTypePlugins: fieldPlugins,
33
+ fieldRegistry,
34
34
  createPlugin: ({
35
35
  schema,
36
36
  type,
37
37
  fieldType
38
38
  }) => {
39
- const plugin = new _handlerGraphql.GraphQLSchemaPlugin(schema);
39
+ const plugin = new GraphQLSchemaPlugin(schema);
40
40
  plugin.name = `fm.graphql.schema.${type}.field.${fieldType}`;
41
41
  return plugin;
42
42
  }
43
43
  });
44
- const graphQlPlugin = (0, _filesSchema.createFilesSchema)({
44
+ const graphQlPlugin = createFilesSchema({
45
45
  model: fileModel,
46
46
  models,
47
- plugins: fieldPlugins
47
+ fieldRegistry
48
48
  });
49
- context.plugins.register([...plugins, graphQlPlugin, (0, _getFileByUrl.getFileByUrl)()]);
49
+ context.plugins.register([...plugins, graphQlPlugin, getFileByUrl()]);
50
50
  });
51
51
  })];
52
52
  };
53
- exports.createGraphQLSchemaPlugin = createGraphQLSchemaPlugin;
54
53
 
55
54
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_api","require","_apiHeadlessCms","_createFieldTypePluginRecords","_getSchemaFromFieldPlugins","_baseSchema","_handlerGraphql","_filesSchema","_getFileByUrl","createGraphQLSchemaPlugin","createBaseSchema","ContextPlugin","context","isHeadlessCmsReady","security","withoutAuthorization","fileModel","cms","getModel","models","listModels","fieldPlugins","createFieldTypePluginRecords","plugins","createGraphQLSchemaPluginFromFieldPlugins","type","fieldTypePlugins","createPlugin","schema","fieldType","plugin","GraphQLSchemaPlugin","name","graphQlPlugin","createFilesSchema","model","register","getFileByUrl","exports"],"sources":["index.ts"],"sourcesContent":["import { ContextPlugin } from \"@webiny/api\";\nimport { isHeadlessCmsReady } from \"@webiny/api-headless-cms\";\nimport type { CmsModel } from \"@webiny/api-headless-cms/types\";\nimport { createFieldTypePluginRecords } from \"@webiny/api-headless-cms/graphql/schema/createFieldTypePluginRecords\";\nimport { createGraphQLSchemaPluginFromFieldPlugins } from \"@webiny/api-headless-cms/utils/getSchemaFromFieldPlugins\";\nimport { createBaseSchema } from \"~/graphql/baseSchema\";\nimport { GraphQLSchemaPlugin } from \"@webiny/handler-graphql\";\nimport { createFilesSchema } from \"~/graphql/filesSchema\";\nimport { getFileByUrl } from \"~/graphql/getFileByUrl\";\nimport type { FileManagerContext } from \"~/types\";\n\nexport const createGraphQLSchemaPlugin = () => {\n return [\n createBaseSchema(),\n // Files schema is generated dynamically, based on a CMS model, so we need to\n // register it from a ContextPlugin, to perform additional bootstrap.\n new ContextPlugin<FileManagerContext>(async context => {\n if (!(await isHeadlessCmsReady(context))) {\n return;\n }\n\n await context.security.withoutAuthorization(async () => {\n const fileModel = (await context.cms.getModel(\"fmFile\")) as CmsModel;\n const models = await context.cms.listModels();\n const fieldPlugins = createFieldTypePluginRecords(context.plugins);\n /**\n * We need to register all plugins for all the CMS fields.\n */\n const plugins = createGraphQLSchemaPluginFromFieldPlugins({\n models,\n type: \"manage\",\n fieldTypePlugins: fieldPlugins,\n createPlugin: ({ schema, type, fieldType }) => {\n const plugin = new GraphQLSchemaPlugin(schema);\n plugin.name = `fm.graphql.schema.${type}.field.${fieldType}`;\n return plugin;\n }\n });\n\n const graphQlPlugin = createFilesSchema({\n model: fileModel,\n models,\n plugins: fieldPlugins\n });\n\n context.plugins.register([...plugins, graphQlPlugin, getFileByUrl()]);\n });\n })\n ];\n};\n"],"mappings":";;;;;;AAAA,IAAAA,IAAA,GAAAC,OAAA;AACA,IAAAC,eAAA,GAAAD,OAAA;AAEA,IAAAE,6BAAA,GAAAF,OAAA;AACA,IAAAG,0BAAA,GAAAH,OAAA;AACA,IAAAI,WAAA,GAAAJ,OAAA;AACA,IAAAK,eAAA,GAAAL,OAAA;AACA,IAAAM,YAAA,GAAAN,OAAA;AACA,IAAAO,aAAA,GAAAP,OAAA;AAGO,MAAMQ,yBAAyB,GAAGA,CAAA,KAAM;EAC3C,OAAO,CACH,IAAAC,4BAAgB,EAAC,CAAC;EAClB;EACA;EACA,IAAIC,kBAAa,CAAqB,MAAMC,OAAO,IAAI;IACnD,IAAI,EAAE,MAAM,IAAAC,kCAAkB,EAACD,OAAO,CAAC,CAAC,EAAE;MACtC;IACJ;IAEA,MAAMA,OAAO,CAACE,QAAQ,CAACC,oBAAoB,CAAC,YAAY;MACpD,MAAMC,SAAS,GAAI,MAAMJ,OAAO,CAACK,GAAG,CAACC,QAAQ,CAAC,QAAQ,CAAc;MACpE,MAAMC,MAAM,GAAG,MAAMP,OAAO,CAACK,GAAG,CAACG,UAAU,CAAC,CAAC;MAC7C,MAAMC,YAAY,GAAG,IAAAC,0DAA4B,EAACV,OAAO,CAACW,OAAO,CAAC;MAClE;AAChB;AACA;MACgB,MAAMA,OAAO,GAAG,IAAAC,oEAAyC,EAAC;QACtDL,MAAM;QACNM,IAAI,EAAE,QAAQ;QACdC,gBAAgB,EAAEL,YAAY;QAC9BM,YAAY,EAAEA,CAAC;UAAEC,MAAM;UAAEH,IAAI;UAAEI;QAAU,CAAC,KAAK;UAC3C,MAAMC,MAAM,GAAG,IAAIC,mCAAmB,CAACH,MAAM,CAAC;UAC9CE,MAAM,CAACE,IAAI,GAAG,qBAAqBP,IAAI,UAAUI,SAAS,EAAE;UAC5D,OAAOC,MAAM;QACjB;MACJ,CAAC,CAAC;MAEF,MAAMG,aAAa,GAAG,IAAAC,8BAAiB,EAAC;QACpCC,KAAK,EAAEnB,SAAS;QAChBG,MAAM;QACNI,OAAO,EAAEF;MACb,CAAC,CAAC;MAEFT,OAAO,CAACW,OAAO,CAACa,QAAQ,CAAC,CAAC,GAAGb,OAAO,EAAEU,aAAa,EAAE,IAAAI,0BAAY,EAAC,CAAC,CAAC,CAAC;IACzE,CAAC,CAAC;EACN,CAAC,CAAC,CACL;AACL,CAAC;AAACC,OAAA,CAAA7B,yBAAA,GAAAA,yBAAA","ignoreList":[]}
1
+ {"version":3,"names":["ContextPlugin","GraphQLSchemaPlugin","ListModelsUseCase","createGraphQLSchemaPluginFromFieldPlugins","createBaseSchema","createFilesSchema","getFileByUrl","FileModel","TenantContext","CmsModelFieldToGraphQLRegistry","createGraphQLSchemaPlugin","context","tenantContext","container","resolve","getTenant","fileModel","listModels","fieldRegistry","security","withoutAuthorization","modelsResult","execute","models","value","plugins","type","createPlugin","schema","fieldType","plugin","name","graphQlPlugin","model","register"],"sources":["index.ts"],"sourcesContent":["import { ContextPlugin } from \"@webiny/api\";\nimport type { ApiCoreContext } from \"@webiny/api-core/types/core.js\";\nimport { GraphQLSchemaPlugin } from \"@webiny/handler-graphql\";\nimport { ListModelsUseCase } from \"@webiny/api-headless-cms/features/contentModel/ListModels/index.js\";\nimport { createGraphQLSchemaPluginFromFieldPlugins } from \"@webiny/api-headless-cms/utils/getSchemaFromFieldPlugins.js\";\nimport { createBaseSchema } from \"~/graphql/baseSchema.js\";\nimport { createFilesSchema } from \"~/graphql/filesSchema.js\";\nimport { getFileByUrl } from \"~/graphql/getFileByUrl.js\";\nimport { FileModel } from \"~/domain/file/abstractions.js\";\nimport { TenantContext } from \"@webiny/api-core/features/tenancy/TenantContext/index.js\";\nimport { CmsModelFieldToGraphQLRegistry } from \"@webiny/api-headless-cms/exports/api/cms/graphql.js\";\n\nexport const createGraphQLSchemaPlugin = () => {\n return [\n createBaseSchema(),\n // Files schema is generated dynamically, based on a CMS model, so we need to\n // register it from a ContextPlugin, to perform additional bootstrap.\n new ContextPlugin<ApiCoreContext>(async context => {\n const tenantContext = context.container.resolve(TenantContext);\n if (!tenantContext.getTenant()) {\n return;\n }\n\n const fileModel = context.container.resolve(FileModel);\n const listModels = context.container.resolve(ListModelsUseCase);\n const fieldRegistry = context.container.resolve(CmsModelFieldToGraphQLRegistry);\n\n await context.security.withoutAuthorization(async () => {\n const modelsResult = await listModels.execute();\n const models = modelsResult.value;\n\n /**\n * We need to register all plugins for all the CMS fields.\n */\n const plugins = createGraphQLSchemaPluginFromFieldPlugins({\n models,\n type: \"manage\",\n fieldRegistry,\n createPlugin: ({ schema, type, fieldType }) => {\n const plugin = new GraphQLSchemaPlugin(schema);\n plugin.name = `fm.graphql.schema.${type}.field.${fieldType}`;\n return plugin;\n }\n });\n\n const graphQlPlugin = createFilesSchema({\n model: fileModel,\n models,\n fieldRegistry\n });\n\n context.plugins.register([...plugins, graphQlPlugin, getFileByUrl()]);\n });\n })\n ];\n};\n"],"mappings":"AAAA,SAASA,aAAa,QAAQ,aAAa;AAE3C,SAASC,mBAAmB,QAAQ,yBAAyB;AAC7D,SAASC,iBAAiB,QAAQ,oEAAoE;AACtG,SAASC,yCAAyC,QAAQ,6DAA6D;AACvH,SAASC,gBAAgB;AACzB,SAASC,iBAAiB;AAC1B,SAASC,YAAY;AACrB,SAASC,SAAS;AAClB,SAASC,aAAa,QAAQ,0DAA0D;AACxF,SAASC,8BAA8B,QAAQ,qDAAqD;AAEpG,OAAO,MAAMC,yBAAyB,GAAGA,CAAA,KAAM;EAC3C,OAAO,CACHN,gBAAgB,CAAC,CAAC;EAClB;EACA;EACA,IAAIJ,aAAa,CAAi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5 @@ export declare const emptyResolver: () => {};
7
7
  interface ResolveCallable {
8
8
  (): Promise<any>;
9
9
  }
10
- export declare const resolve: (fn: ResolveCallable) => Promise<ErrorResponse | Response<any>>;
10
+ export declare const resolve: (fn: ResolveCallable) => Promise<Response<any> | ErrorResponse>;
11
11
  export {};
package/graphql/utils.js CHANGED
@@ -1,24 +1,17 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.resolve = exports.emptyResolver = void 0;
7
- var _handlerGraphql = require("@webiny/handler-graphql");
8
- const emptyResolver = () => ({});
1
+ import { Response, ErrorResponse } from "@webiny/handler-graphql";
2
+ export const emptyResolver = () => ({});
9
3
 
10
4
  /**
11
5
  * Use any because it really can be any.
12
6
  * TODO @ts-refactor maybe use generics at some point?
13
7
  */
14
- exports.emptyResolver = emptyResolver;
15
- const resolve = async fn => {
8
+
9
+ export const resolve = async fn => {
16
10
  try {
17
- return new _handlerGraphql.Response(await fn());
11
+ return new Response(await fn());
18
12
  } catch (e) {
19
- return new _handlerGraphql.ErrorResponse(e);
13
+ return new ErrorResponse(e);
20
14
  }
21
15
  };
22
- exports.resolve = resolve;
23
16
 
24
17
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_handlerGraphql","require","emptyResolver","exports","resolve","fn","Response","e","ErrorResponse"],"sources":["utils.ts"],"sourcesContent":["import { Response, ErrorResponse } from \"@webiny/handler-graphql\";\n\nexport const emptyResolver = () => ({});\n\n/**\n * Use any because it really can be any.\n * TODO @ts-refactor maybe use generics at some point?\n */\ninterface ResolveCallable {\n (): Promise<any>;\n}\n\nexport const resolve = async (fn: ResolveCallable) => {\n try {\n return new Response(await fn());\n } catch (e) {\n return new ErrorResponse(e);\n }\n};\n"],"mappings":";;;;;;AAAA,IAAAA,eAAA,GAAAC,OAAA;AAEO,MAAMC,aAAa,GAAGA,CAAA,MAAO,CAAC,CAAC,CAAC;;AAEvC;AACA;AACA;AACA;AAHAC,OAAA,CAAAD,aAAA,GAAAA,aAAA;AAQO,MAAME,OAAO,GAAG,MAAOC,EAAmB,IAAK;EAClD,IAAI;IACA,OAAO,IAAIC,wBAAQ,CAAC,MAAMD,EAAE,CAAC,CAAC,CAAC;EACnC,CAAC,CAAC,OAAOE,CAAC,EAAE;IACR,OAAO,IAAIC,6BAAa,CAACD,CAAC,CAAC;EAC/B;AACJ,CAAC;AAACJ,OAAA,CAAAC,OAAA,GAAAA,OAAA","ignoreList":[]}
1
+ {"version":3,"names":["Response","ErrorResponse","emptyResolver","resolve","fn","e"],"sources":["utils.ts"],"sourcesContent":["import { Response, ErrorResponse } from \"@webiny/handler-graphql\";\n\nexport const emptyResolver = () => ({});\n\n/**\n * Use any because it really can be any.\n * TODO @ts-refactor maybe use generics at some point?\n */\ninterface ResolveCallable {\n (): Promise<any>;\n}\n\nexport const resolve = async (fn: ResolveCallable) => {\n try {\n return new Response(await fn());\n } catch (e) {\n return new ErrorResponse(e);\n }\n};\n"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,aAAa,QAAQ,yBAAyB;AAEjE,OAAO,MAAMC,aAAa,GAAGA,CAAA,MAAO,CAAC,CAAC,CAAC;;AAEvC;AACA;AACA;AACA;;AAKA,OAAO,MAAMC,OAAO,GAAG,MAAOC,EAAmB,IAAK;EAClD,IAAI;IACA,OAAO,IAAIJ,QAAQ,CAAC,MAAMI,EAAE,CAAC,CAAC,CAAC;EACnC,CAAC,CAAC,OAAOC,CAAC,EAAE;IACR,OAAO,IAAIJ,aAAa,CAACI,CAAC,CAAC;EAC/B;AACJ,CAAC","ignoreList":[]}
package/index.d.ts CHANGED
@@ -1,10 +1,7 @@
1
+ import type { ApiCoreContext } from "@webiny/api-core/types/core.js";
1
2
  import { ContextPlugin } from "@webiny/api";
2
- import type { FileManagerContext } from "./types";
3
- import type { AssetDeliveryParams } from "./delivery/setupAssetDelivery";
4
- import type { FileManagerConfig } from "./createFileManager/types";
5
- export * from "./modelModifier/CmsModelModifier";
6
- export * from "./plugins";
7
- export * from "./delivery";
8
- export declare const createFileManagerContext: ({ storageOperations }: Pick<FileManagerConfig, "storageOperations">) => ContextPlugin<FileManagerContext>;
9
- export declare const createFileManagerGraphQL: () => (import("@webiny/handler-graphql").GraphQLSchemaPlugin<FileManagerContext> | ContextPlugin<FileManagerContext>)[];
10
- export declare const createAssetDelivery: (config: AssetDeliveryParams) => (import("@webiny/handler").ModifyFastifyPlugin | import("./delivery").AssetDeliveryConfigModifierPlugin)[];
3
+ export * from "./modelModifier/CmsModelModifier.js";
4
+ export * from "./delivery/index.js";
5
+ export declare const createFileManagerContext: () => ContextPlugin<ApiCoreContext>;
6
+ export declare const createFileManagerGraphQL: () => (import("@webiny/handler-graphql/index.js").GraphQLSchemaPlugin<ApiCoreContext> | ContextPlugin<ApiCoreContext>)[];
7
+ export declare const createAssetDelivery: () => (import("./index.js").AssetDeliveryConfigModifierPlugin | import("@webiny/handler/index.js").ModifyFastifyPlugin)[];