@webiny/api-file-manager 0.0.0-unstable.6f45466a1d → 0.0.0-unstable.7be00a75a9

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 (377) hide show
  1. package/contants.js +2 -1
  2. package/contants.js.map +1 -1
  3. package/delivery/AssetDelivery/Asset.js +50 -56
  4. package/delivery/AssetDelivery/Asset.js.map +1 -1
  5. package/delivery/AssetDelivery/AssetRequest.js +20 -19
  6. package/delivery/AssetDelivery/AssetRequest.js.map +1 -1
  7. package/delivery/AssetDelivery/abstractions/AssetReply.js +28 -27
  8. package/delivery/AssetDelivery/abstractions/AssetReply.js.map +1 -1
  9. package/delivery/AssetDelivery/createAssetDeliveryPluginLoader.js +4 -5
  10. package/delivery/AssetDelivery/createAssetDeliveryPluginLoader.js.map +1 -1
  11. package/delivery/index.d.ts +3 -12
  12. package/delivery/index.js +2 -8
  13. package/delivery/setupAssetDelivery.d.ts +1 -2
  14. package/delivery/setupAssetDelivery.js +60 -105
  15. package/delivery/setupAssetDelivery.js.map +1 -1
  16. package/domain/file/abstractions.js +2 -5
  17. package/domain/file/abstractions.js.map +1 -1
  18. package/domain/file/errors.js +67 -76
  19. package/domain/file/errors.js.map +1 -1
  20. package/domain/file/file.model.js +57 -45
  21. package/domain/file/file.model.js.map +1 -1
  22. package/domain/file/types.d.ts +2 -0
  23. package/domain/file/types.js +0 -3
  24. package/domain/identity/Identity.js +9 -8
  25. package/domain/identity/Identity.js.map +1 -1
  26. package/domain/permissionsSchema.d.ts +16 -0
  27. package/domain/permissionsSchema.js +30 -0
  28. package/domain/permissionsSchema.js.map +1 -0
  29. package/domain/settings/constants.js +2 -1
  30. package/domain/settings/constants.js.map +1 -1
  31. package/domain/settings/errors.js +22 -24
  32. package/domain/settings/errors.js.map +1 -1
  33. package/domain/settings/types.js +0 -3
  34. package/domain/settings/validation.d.ts +4 -12
  35. package/domain/settings/validation.js +18 -27
  36. package/domain/settings/validation.js.map +1 -1
  37. package/exports/api/file-manager/file.d.ts +12 -0
  38. package/exports/api/file-manager/file.js +12 -0
  39. package/exports/api/file-manager/permissions.d.ts +1 -0
  40. package/exports/api/file-manager/permissions.js +1 -0
  41. package/exports/api/file-manager/settings.d.ts +3 -0
  42. package/exports/api/file-manager/settings.js +3 -0
  43. package/features/FileManagerFeature.d.ts +4 -1
  44. package/features/FileManagerFeature.js +17 -14
  45. package/features/FileManagerFeature.js.map +1 -1
  46. package/features/assetDelivery/FilesAssetRequestResolver.d.ts +9 -0
  47. package/features/assetDelivery/FilesAssetRequestResolver.js +29 -0
  48. package/features/assetDelivery/FilesAssetRequestResolver.js.map +1 -0
  49. package/features/assetDelivery/NullAssetOutputStrategy.d.ts +8 -0
  50. package/features/assetDelivery/NullAssetOutputStrategy.js +14 -0
  51. package/features/assetDelivery/NullAssetOutputStrategy.js.map +1 -0
  52. package/features/assetDelivery/NullAssetReply.js +14 -0
  53. package/features/assetDelivery/NullAssetReply.js.map +1 -0
  54. package/features/assetDelivery/NullAssetResolver.d.ts +8 -0
  55. package/features/assetDelivery/NullAssetResolver.js +13 -0
  56. package/features/assetDelivery/NullAssetResolver.js.map +1 -0
  57. package/features/assetDelivery/abstractions.d.ts +54 -0
  58. package/features/assetDelivery/abstractions.js +11 -0
  59. package/features/assetDelivery/abstractions.js.map +1 -0
  60. package/features/assetDelivery/feature.d.ts +4 -0
  61. package/features/assetDelivery/feature.js +29 -0
  62. package/features/assetDelivery/feature.js.map +1 -0
  63. package/features/assetDelivery/privateFiles/NotAuthorizedAssetReply.d.ts +4 -0
  64. package/features/assetDelivery/privateFiles/NotAuthorizedAssetReply.js +20 -0
  65. package/features/assetDelivery/privateFiles/NotAuthorizedAssetReply.js.map +1 -0
  66. package/features/assetDelivery/privateFiles/NotAuthorizedOutputStrategy.d.ts +5 -0
  67. package/features/assetDelivery/privateFiles/NotAuthorizedOutputStrategy.js +9 -0
  68. package/features/assetDelivery/privateFiles/NotAuthorizedOutputStrategy.js.map +1 -0
  69. package/features/assetDelivery/privateFiles/PrivateAuthenticatedAuthorizer.d.ts +11 -0
  70. package/features/assetDelivery/privateFiles/PrivateAuthenticatedAuthorizer.js +26 -0
  71. package/features/assetDelivery/privateFiles/PrivateAuthenticatedAuthorizer.js.map +1 -0
  72. package/features/assetDelivery/privateFiles/PrivateCache.d.ts +8 -0
  73. package/features/assetDelivery/privateFiles/PrivateCache.js +22 -0
  74. package/features/assetDelivery/privateFiles/PrivateCache.js.map +1 -0
  75. package/features/assetDelivery/privateFiles/PrivateFileAssetRequestResolver.d.ts +11 -0
  76. package/features/assetDelivery/privateFiles/PrivateFileAssetRequestResolver.js +31 -0
  77. package/features/assetDelivery/privateFiles/PrivateFileAssetRequestResolver.js.map +1 -0
  78. package/features/assetDelivery/privateFiles/PrivateFilesAssetProcessor.d.ts +19 -0
  79. package/features/assetDelivery/privateFiles/PrivateFilesAssetProcessor.js +65 -0
  80. package/features/assetDelivery/privateFiles/PrivateFilesAssetProcessor.js.map +1 -0
  81. package/features/assetDelivery/privateFiles/PublicCache.d.ts +8 -0
  82. package/features/assetDelivery/privateFiles/PublicCache.js +22 -0
  83. package/features/assetDelivery/privateFiles/PublicCache.js.map +1 -0
  84. package/features/assetDelivery/privateFiles/RedirectToPrivateUrlOutputStrategy.d.ts +9 -0
  85. package/features/assetDelivery/privateFiles/RedirectToPrivateUrlOutputStrategy.js +21 -0
  86. package/features/assetDelivery/privateFiles/RedirectToPrivateUrlOutputStrategy.js.map +1 -0
  87. package/features/assetDelivery/privateFiles/RedirectToPublicUrlOutputStrategy.d.ts +9 -0
  88. package/features/assetDelivery/privateFiles/RedirectToPublicUrlOutputStrategy.js +21 -0
  89. package/features/assetDelivery/privateFiles/RedirectToPublicUrlOutputStrategy.js.map +1 -0
  90. package/features/assetDelivery/transformation/PassthroughAssetTransformationStrategy.d.ts +9 -0
  91. package/features/assetDelivery/transformation/PassthroughAssetTransformationStrategy.js +13 -0
  92. package/features/assetDelivery/transformation/PassthroughAssetTransformationStrategy.js.map +1 -0
  93. package/features/assetDelivery/transformation/TransformationAssetProcessor.d.ts +11 -0
  94. package/features/assetDelivery/transformation/TransformationAssetProcessor.js +23 -0
  95. package/features/assetDelivery/transformation/TransformationAssetProcessor.js.map +1 -0
  96. package/features/file/CreateFile/CreateFileRepository.js +20 -18
  97. package/features/file/CreateFile/CreateFileRepository.js.map +1 -1
  98. package/features/file/CreateFile/CreateFileUseCase.d.ts +4 -4
  99. package/features/file/CreateFile/CreateFileUseCase.js +70 -78
  100. package/features/file/CreateFile/CreateFileUseCase.js.map +1 -1
  101. package/features/file/CreateFile/abstractions.d.ts +3 -0
  102. package/features/file/CreateFile/abstractions.js +3 -12
  103. package/features/file/CreateFile/abstractions.js.map +1 -1
  104. package/features/file/CreateFile/events.d.ts +8 -6
  105. package/features/file/CreateFile/events.js +18 -23
  106. package/features/file/CreateFile/events.js.map +1 -1
  107. package/features/file/CreateFile/feature.d.ts +4 -1
  108. package/features/file/CreateFile/feature.js +7 -6
  109. package/features/file/CreateFile/feature.js.map +1 -1
  110. package/features/file/CreateFile/index.d.ts +1 -1
  111. package/features/file/CreateFile/index.js +1 -3
  112. package/features/file/CreateFilesInBatch/CreateFilesInBatchRepository.js +15 -17
  113. package/features/file/CreateFilesInBatch/CreateFilesInBatchRepository.js.map +1 -1
  114. package/features/file/CreateFilesInBatch/CreateFilesInBatchUseCase.d.ts +4 -4
  115. package/features/file/CreateFilesInBatch/CreateFilesInBatchUseCase.js +61 -75
  116. package/features/file/CreateFilesInBatch/CreateFilesInBatchUseCase.js.map +1 -1
  117. package/features/file/CreateFilesInBatch/abstractions.d.ts +2 -0
  118. package/features/file/CreateFilesInBatch/abstractions.js +3 -12
  119. package/features/file/CreateFilesInBatch/abstractions.js.map +1 -1
  120. package/features/file/CreateFilesInBatch/events.d.ts +8 -6
  121. package/features/file/CreateFilesInBatch/events.js +18 -23
  122. package/features/file/CreateFilesInBatch/events.js.map +1 -1
  123. package/features/file/CreateFilesInBatch/feature.d.ts +4 -1
  124. package/features/file/CreateFilesInBatch/feature.js +7 -6
  125. package/features/file/CreateFilesInBatch/feature.js.map +1 -1
  126. package/features/file/CreateFilesInBatch/index.js +0 -2
  127. package/features/file/DeleteFile/DeleteFileRepository.js +21 -20
  128. package/features/file/DeleteFile/DeleteFileRepository.js.map +1 -1
  129. package/features/file/DeleteFile/DeleteFileUseCase.d.ts +4 -4
  130. package/features/file/DeleteFile/DeleteFileUseCase.js +33 -38
  131. package/features/file/DeleteFile/DeleteFileUseCase.js.map +1 -1
  132. package/features/file/DeleteFile/abstractions.d.ts +2 -0
  133. package/features/file/DeleteFile/abstractions.js +3 -12
  134. package/features/file/DeleteFile/abstractions.js.map +1 -1
  135. package/features/file/DeleteFile/events.d.ts +8 -6
  136. package/features/file/DeleteFile/events.js +18 -23
  137. package/features/file/DeleteFile/events.js.map +1 -1
  138. package/features/file/DeleteFile/feature.d.ts +4 -1
  139. package/features/file/DeleteFile/feature.js +7 -6
  140. package/features/file/DeleteFile/feature.js.map +1 -1
  141. package/features/file/DeleteFile/index.d.ts +1 -1
  142. package/features/file/DeleteFile/index.js +1 -3
  143. package/features/file/FileUrlGenerator/abstractions.d.ts +1 -0
  144. package/features/file/FileUrlGenerator/abstractions.js +2 -1
  145. package/features/file/FileUrlGenerator/abstractions.js.map +1 -1
  146. package/features/file/GetFile/GetFileRepository.js +22 -22
  147. package/features/file/GetFile/GetFileRepository.js.map +1 -1
  148. package/features/file/GetFile/GetFileUseCase.d.ts +3 -3
  149. package/features/file/GetFile/GetFileUseCase.js +20 -30
  150. package/features/file/GetFile/GetFileUseCase.js.map +1 -1
  151. package/features/file/GetFile/abstractions.d.ts +2 -0
  152. package/features/file/GetFile/abstractions.js +3 -12
  153. package/features/file/GetFile/abstractions.js.map +1 -1
  154. package/features/file/GetFile/feature.d.ts +4 -1
  155. package/features/file/GetFile/feature.js +7 -6
  156. package/features/file/GetFile/feature.js.map +1 -1
  157. package/features/file/GetFile/index.js +0 -2
  158. package/features/file/GetFileContentsById/abstractions.d.ts +20 -0
  159. package/features/file/GetFileContentsById/abstractions.js +5 -0
  160. package/features/file/GetFileContentsById/abstractions.js.map +1 -0
  161. package/features/file/GetFileContentsById/index.d.ts +1 -0
  162. package/features/file/GetFileContentsById/index.js +1 -0
  163. package/features/file/GetFileContentsByKey/abstractions.d.ts +17 -0
  164. package/features/file/GetFileContentsByKey/abstractions.js +5 -0
  165. package/features/file/GetFileContentsByKey/abstractions.js.map +1 -0
  166. package/features/file/GetFileContentsByKey/index.d.ts +1 -0
  167. package/features/file/GetFileContentsByKey/index.js +1 -0
  168. package/features/file/ListFiles/ListFilesRepository.d.ts +3 -1
  169. package/features/file/ListFiles/ListFilesRepository.js +42 -34
  170. package/features/file/ListFiles/ListFilesRepository.js.map +1 -1
  171. package/features/file/ListFiles/ListFilesUseCase.d.ts +4 -4
  172. package/features/file/ListFiles/ListFilesUseCase.js +35 -39
  173. package/features/file/ListFiles/ListFilesUseCase.js.map +1 -1
  174. package/features/file/ListFiles/abstractions.d.ts +2 -0
  175. package/features/file/ListFiles/abstractions.js +3 -12
  176. package/features/file/ListFiles/abstractions.js.map +1 -1
  177. package/features/file/ListFiles/feature.d.ts +4 -1
  178. package/features/file/ListFiles/feature.js +7 -6
  179. package/features/file/ListFiles/feature.js.map +1 -1
  180. package/features/file/ListFiles/index.js +0 -2
  181. package/features/file/ListImagesByTagTool/ListImagesByTagTool.d.ts +27 -0
  182. package/features/file/ListImagesByTagTool/ListImagesByTagTool.js +42 -0
  183. package/features/file/ListImagesByTagTool/ListImagesByTagTool.js.map +1 -0
  184. package/features/file/ListImagesByTagTool/feature.d.ts +4 -0
  185. package/features/file/ListImagesByTagTool/feature.js +11 -0
  186. package/features/file/ListImagesByTagTool/feature.js.map +1 -0
  187. package/features/file/ListTags/ListTagsRepository.js +31 -36
  188. package/features/file/ListTags/ListTagsRepository.js.map +1 -1
  189. package/features/file/ListTags/ListTagsUseCase.d.ts +3 -3
  190. package/features/file/ListTags/ListTagsUseCase.js +22 -23
  191. package/features/file/ListTags/ListTagsUseCase.js.map +1 -1
  192. package/features/file/ListTags/abstractions.d.ts +2 -0
  193. package/features/file/ListTags/abstractions.js +3 -12
  194. package/features/file/ListTags/abstractions.js.map +1 -1
  195. package/features/file/ListTags/feature.d.ts +4 -1
  196. package/features/file/ListTags/feature.js +7 -6
  197. package/features/file/ListTags/feature.js.map +1 -1
  198. package/features/file/ListTags/index.js +0 -2
  199. package/features/file/UpdateFile/UpdateFileRepository.js +26 -28
  200. package/features/file/UpdateFile/UpdateFileRepository.js.map +1 -1
  201. package/features/file/UpdateFile/UpdateFileUseCase.d.ts +5 -5
  202. package/features/file/UpdateFile/UpdateFileUseCase.js +60 -70
  203. package/features/file/UpdateFile/UpdateFileUseCase.js.map +1 -1
  204. package/features/file/UpdateFile/abstractions.d.ts +3 -0
  205. package/features/file/UpdateFile/abstractions.js +3 -12
  206. package/features/file/UpdateFile/abstractions.js.map +1 -1
  207. package/features/file/UpdateFile/events.d.ts +8 -6
  208. package/features/file/UpdateFile/events.js +18 -23
  209. package/features/file/UpdateFile/events.js.map +1 -1
  210. package/features/file/UpdateFile/feature.d.ts +4 -1
  211. package/features/file/UpdateFile/feature.js +7 -6
  212. package/features/file/UpdateFile/feature.js.map +1 -1
  213. package/features/file/UpdateFile/index.d.ts +1 -1
  214. package/features/file/UpdateFile/index.js +1 -3
  215. package/features/file/shared/EntryToFileMapper.js +25 -23
  216. package/features/file/shared/EntryToFileMapper.js.map +1 -1
  217. package/features/file/shared/FileInputToEntryInputMapper.js +29 -27
  218. package/features/file/shared/FileInputToEntryInputMapper.js.map +1 -1
  219. package/features/file/shared/FileToEntryMapper.js +28 -26
  220. package/features/file/shared/FileToEntryMapper.js.map +1 -1
  221. package/features/permissions/abstractions.d.ts +21 -0
  222. package/features/permissions/abstractions.js +6 -0
  223. package/features/permissions/abstractions.js.map +1 -0
  224. package/features/permissions/feature.d.ts +4 -0
  225. package/features/permissions/feature.js +7 -0
  226. package/features/permissions/feature.js.map +1 -0
  227. package/features/settings/GetSettings/GetSettingsUseCase.js +19 -19
  228. package/features/settings/GetSettings/GetSettingsUseCase.js.map +1 -1
  229. package/features/settings/GetSettings/abstractions.d.ts +1 -0
  230. package/features/settings/GetSettings/abstractions.js +2 -6
  231. package/features/settings/GetSettings/abstractions.js.map +1 -1
  232. package/features/settings/GetSettings/feature.d.ts +4 -1
  233. package/features/settings/GetSettings/feature.js +6 -5
  234. package/features/settings/GetSettings/feature.js.map +1 -1
  235. package/features/settings/SettingsInstaller/SettingsInstaller.d.ts +1 -1
  236. package/features/settings/SettingsInstaller/SettingsInstaller.js +26 -25
  237. package/features/settings/SettingsInstaller/SettingsInstaller.js.map +1 -1
  238. package/features/settings/SettingsInstaller/feature.d.ts +4 -1
  239. package/features/settings/SettingsInstaller/feature.js +6 -5
  240. package/features/settings/SettingsInstaller/feature.js.map +1 -1
  241. package/features/settings/UpdateSettings/UpdateSettingsUseCase.d.ts +1 -1
  242. package/features/settings/UpdateSettings/UpdateSettingsUseCase.js +42 -49
  243. package/features/settings/UpdateSettings/UpdateSettingsUseCase.js.map +1 -1
  244. package/features/settings/UpdateSettings/abstractions.d.ts +1 -0
  245. package/features/settings/UpdateSettings/abstractions.js +2 -6
  246. package/features/settings/UpdateSettings/abstractions.js.map +1 -1
  247. package/features/settings/UpdateSettings/events.d.ts +8 -6
  248. package/features/settings/UpdateSettings/events.js +18 -23
  249. package/features/settings/UpdateSettings/events.js.map +1 -1
  250. package/features/settings/UpdateSettings/feature.d.ts +4 -1
  251. package/features/settings/UpdateSettings/feature.js +6 -5
  252. package/features/settings/UpdateSettings/feature.js.map +1 -1
  253. package/features/settings/UpdateSettings/index.d.ts +1 -1
  254. package/features/settings/UpdateSettings/index.js +1 -3
  255. package/features/shared/abstractions.d.ts +1 -13
  256. package/features/shared/abstractions.js +1 -5
  257. package/graphql/baseSchema.js +30 -33
  258. package/graphql/baseSchema.js.map +1 -1
  259. package/graphql/createFilesTypeDefs.d.ts +3 -2
  260. package/graphql/createFilesTypeDefs.js +61 -66
  261. package/graphql/createFilesTypeDefs.js.map +1 -1
  262. package/graphql/filesSchema.js +79 -99
  263. package/graphql/filesSchema.js.map +1 -1
  264. package/graphql/getFileByUrl.js +45 -53
  265. package/graphql/getFileByUrl.js.map +1 -1
  266. package/graphql/index.js +37 -43
  267. package/graphql/index.js.map +1 -1
  268. package/graphql/utils.js +9 -14
  269. package/graphql/utils.js.map +1 -1
  270. package/index.d.ts +2 -2
  271. package/index.js +31 -39
  272. package/index.js.map +1 -1
  273. package/modelModifier/CmsModelModifier.js +40 -43
  274. package/modelModifier/CmsModelModifier.js.map +1 -1
  275. package/package.json +28 -23
  276. package/types.d.ts +1 -3
  277. package/types.js +1 -3
  278. package/delivery/AssetDelivery/AssetDeliveryConfig.d.ts +0 -65
  279. package/delivery/AssetDelivery/AssetDeliveryConfig.js +0 -94
  280. package/delivery/AssetDelivery/AssetDeliveryConfig.js.map +0 -1
  281. package/delivery/AssetDelivery/FilesAssetRequestResolver.d.ts +0 -6
  282. package/delivery/AssetDelivery/FilesAssetRequestResolver.js +0 -30
  283. package/delivery/AssetDelivery/FilesAssetRequestResolver.js.map +0 -1
  284. package/delivery/AssetDelivery/NullAssetOutputStrategy.d.ts +0 -4
  285. package/delivery/AssetDelivery/NullAssetOutputStrategy.js +0 -8
  286. package/delivery/AssetDelivery/NullAssetOutputStrategy.js.map +0 -1
  287. package/delivery/AssetDelivery/NullAssetReply.js +0 -13
  288. package/delivery/AssetDelivery/NullAssetReply.js.map +0 -1
  289. package/delivery/AssetDelivery/NullAssetResolver.d.ts +0 -5
  290. package/delivery/AssetDelivery/NullAssetResolver.js +0 -7
  291. package/delivery/AssetDelivery/NullAssetResolver.js.map +0 -1
  292. package/delivery/AssetDelivery/NullRequestResolver.d.ts +0 -4
  293. package/delivery/AssetDelivery/NullRequestResolver.js +0 -7
  294. package/delivery/AssetDelivery/NullRequestResolver.js.map +0 -1
  295. package/delivery/AssetDelivery/SetCacheControlHeaders.d.ts +0 -8
  296. package/delivery/AssetDelivery/SetCacheControlHeaders.js +0 -18
  297. package/delivery/AssetDelivery/SetCacheControlHeaders.js.map +0 -1
  298. package/delivery/AssetDelivery/SetResponseHeaders.d.ts +0 -18
  299. package/delivery/AssetDelivery/SetResponseHeaders.js +0 -18
  300. package/delivery/AssetDelivery/SetResponseHeaders.js.map +0 -1
  301. package/delivery/AssetDelivery/abstractions/AssetContentsReader.d.ts +0 -4
  302. package/delivery/AssetDelivery/abstractions/AssetContentsReader.js +0 -3
  303. package/delivery/AssetDelivery/abstractions/AssetContentsReader.js.map +0 -1
  304. package/delivery/AssetDelivery/abstractions/AssetOutputStrategy.d.ts +0 -4
  305. package/delivery/AssetDelivery/abstractions/AssetOutputStrategy.js +0 -3
  306. package/delivery/AssetDelivery/abstractions/AssetOutputStrategy.js.map +0 -1
  307. package/delivery/AssetDelivery/abstractions/AssetProcessor.d.ts +0 -4
  308. package/delivery/AssetDelivery/abstractions/AssetProcessor.js +0 -3
  309. package/delivery/AssetDelivery/abstractions/AssetProcessor.js.map +0 -1
  310. package/delivery/AssetDelivery/abstractions/AssetRequestResolver.d.ts +0 -5
  311. package/delivery/AssetDelivery/abstractions/AssetRequestResolver.js +0 -3
  312. package/delivery/AssetDelivery/abstractions/AssetRequestResolver.js.map +0 -1
  313. package/delivery/AssetDelivery/abstractions/AssetResolver.d.ts +0 -4
  314. package/delivery/AssetDelivery/abstractions/AssetResolver.js +0 -3
  315. package/delivery/AssetDelivery/abstractions/AssetResolver.js.map +0 -1
  316. package/delivery/AssetDelivery/abstractions/AssetTransformationStrategy.d.ts +0 -4
  317. package/delivery/AssetDelivery/abstractions/AssetTransformationStrategy.js +0 -3
  318. package/delivery/AssetDelivery/abstractions/AssetTransformationStrategy.js.map +0 -1
  319. package/delivery/AssetDelivery/privateFiles/AssetAuthorizer.d.ts +0 -4
  320. package/delivery/AssetDelivery/privateFiles/AssetAuthorizer.js +0 -3
  321. package/delivery/AssetDelivery/privateFiles/AssetAuthorizer.js.map +0 -1
  322. package/delivery/AssetDelivery/privateFiles/NotAuthorizedAssetReply.d.ts +0 -4
  323. package/delivery/AssetDelivery/privateFiles/NotAuthorizedAssetReply.js +0 -19
  324. package/delivery/AssetDelivery/privateFiles/NotAuthorizedAssetReply.js.map +0 -1
  325. package/delivery/AssetDelivery/privateFiles/NotAuthorizedOutputStrategy.d.ts +0 -4
  326. package/delivery/AssetDelivery/privateFiles/NotAuthorizedOutputStrategy.js +0 -8
  327. package/delivery/AssetDelivery/privateFiles/NotAuthorizedOutputStrategy.js.map +0 -1
  328. package/delivery/AssetDelivery/privateFiles/PrivateAuthenticatedAuthorizer.d.ts +0 -8
  329. package/delivery/AssetDelivery/privateFiles/PrivateAuthenticatedAuthorizer.js +0 -20
  330. package/delivery/AssetDelivery/privateFiles/PrivateAuthenticatedAuthorizer.js.map +0 -1
  331. package/delivery/AssetDelivery/privateFiles/PrivateCache.d.ts +0 -6
  332. package/delivery/AssetDelivery/privateFiles/PrivateCache.js +0 -21
  333. package/delivery/AssetDelivery/privateFiles/PrivateCache.js.map +0 -1
  334. package/delivery/AssetDelivery/privateFiles/PrivateFileAssetRequestResolver.d.ts +0 -8
  335. package/delivery/AssetDelivery/privateFiles/PrivateFileAssetRequestResolver.js +0 -30
  336. package/delivery/AssetDelivery/privateFiles/PrivateFileAssetRequestResolver.js.map +0 -1
  337. package/delivery/AssetDelivery/privateFiles/PrivateFilesAssetProcessor.d.ts +0 -13
  338. package/delivery/AssetDelivery/privateFiles/PrivateFilesAssetProcessor.js +0 -63
  339. package/delivery/AssetDelivery/privateFiles/PrivateFilesAssetProcessor.js.map +0 -1
  340. package/delivery/AssetDelivery/privateFiles/PublicCache.d.ts +0 -6
  341. package/delivery/AssetDelivery/privateFiles/PublicCache.js +0 -21
  342. package/delivery/AssetDelivery/privateFiles/PublicCache.js.map +0 -1
  343. package/delivery/AssetDelivery/privateFiles/RedirectToPrivateUrlOutputStrategy.d.ts +0 -7
  344. package/delivery/AssetDelivery/privateFiles/RedirectToPrivateUrlOutputStrategy.js +0 -20
  345. package/delivery/AssetDelivery/privateFiles/RedirectToPrivateUrlOutputStrategy.js.map +0 -1
  346. package/delivery/AssetDelivery/privateFiles/RedirectToPublicUrlOutputStrategy.d.ts +0 -7
  347. package/delivery/AssetDelivery/privateFiles/RedirectToPublicUrlOutputStrategy.js +0 -20
  348. package/delivery/AssetDelivery/privateFiles/RedirectToPublicUrlOutputStrategy.js.map +0 -1
  349. package/delivery/AssetDelivery/transformation/PassthroughAssetProcessor.d.ts +0 -4
  350. package/delivery/AssetDelivery/transformation/PassthroughAssetProcessor.js +0 -7
  351. package/delivery/AssetDelivery/transformation/PassthroughAssetProcessor.js.map +0 -1
  352. package/delivery/AssetDelivery/transformation/PassthroughAssetTransformationStrategy.d.ts +0 -4
  353. package/delivery/AssetDelivery/transformation/PassthroughAssetTransformationStrategy.js +0 -7
  354. package/delivery/AssetDelivery/transformation/PassthroughAssetTransformationStrategy.js.map +0 -1
  355. package/delivery/AssetDelivery/transformation/TransformationAssetProcessor.d.ts +0 -6
  356. package/delivery/AssetDelivery/transformation/TransformationAssetProcessor.js +0 -19
  357. package/delivery/AssetDelivery/transformation/TransformationAssetProcessor.js.map +0 -1
  358. package/delivery/index.js.map +0 -1
  359. package/domain/file/types.js.map +0 -1
  360. package/domain/settings/types.js.map +0 -1
  361. package/features/file/CreateFile/index.js.map +0 -1
  362. package/features/file/CreateFilesInBatch/index.js.map +0 -1
  363. package/features/file/DeleteFile/index.js.map +0 -1
  364. package/features/file/GetFile/index.js.map +0 -1
  365. package/features/file/ListFiles/index.js.map +0 -1
  366. package/features/file/ListTags/index.js.map +0 -1
  367. package/features/file/UpdateFile/index.js.map +0 -1
  368. package/features/settings/UpdateSettings/index.js.map +0 -1
  369. package/features/shared/abstractions.js.map +0 -1
  370. package/permissions/FilesPermissions.d.ts +0 -4
  371. package/permissions/FilesPermissions.js +0 -4
  372. package/permissions/FilesPermissions.js.map +0 -1
  373. package/permissions/SettingsPermissions.d.ts +0 -4
  374. package/permissions/SettingsPermissions.js +0 -4
  375. package/permissions/SettingsPermissions.js.map +0 -1
  376. package/types.js.map +0 -1
  377. /package/{delivery/AssetDelivery → features/assetDelivery}/NullAssetReply.d.ts +0 -0
@@ -1 +1 @@
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,CAACE,SAAS,CAAC1B,OAAO,CAACU,kBAAkB,CA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CAAC;QAC7B;MACJ;IACJ;EACJ,CAAC,CAAC;EACFgB,kBAAkB,CAAC0C,IAAI,GAAG,kBAAkB;EAE5C,OAAO1C,kBAAkB;AAC7B,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"graphql/filesSchema.js","sources":["../../src/graphql/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"],"names":["createFilesSchema","params","fileManagerGraphQL","GraphQLSchemaPlugin","createFilesTypeDefs","emptyResolver","file","_","context","getSettings","GetSettingsUseCase","result","settings","__","identity","NotAuthorizedResponse","resolve","FileModel","args","getFile","GetFileUseCase","ErrorResponse","Response","listFiles","ListFilesUseCase","ListResponse","listTags","ListTagsUseCase","createFile","CreateFileUseCase","createFilesInBatch","CreateFilesInBatchUseCase","updateFile","UpdateFileUseCase","deleteFile","DeleteFileUseCase"],"mappings":";;;;;;;;;;;;;AAqBO,MAAMA,oBAAoB,CAACC;IAC9B,MAAMC,qBAAqB,IAAIC,oBAAoC;QAC/D,UAAUC,oBAAoBH;QAC9B,WAAW;YACP,OAAO;gBACH,aAAaI;YACjB;YACA,UAAU;gBACN,aAAaA;YACjB;YACA,QAAQ;gBACJ,MAAM,KAAIC,IAAI,EAAEC,CAAC,EAAEC,OAAO;oBAEtB,MAAMC,cAAcD,QAAQ,SAAS,CAAC,OAAO,CAACE;oBAC9C,MAAMC,SAAS,MAAMF,YAAY,OAAO;oBACxC,MAAMG,WAAWD,OAAO,KAAK;oBAC7B,OAAQC,AAAAA,CAAAA,UAAU,aAAa,EAAC,IAAKN,KAAK,GAAG;gBACjD;YACJ;YACA,SAAS;gBACL,cAAaC,CAAC,EAAEM,EAAE,EAAEL,OAAO;oBACvB,MAAMM,WAAWN,QAAQ,QAAQ,CAAC,WAAW;oBAC7C,IAAI,CAACM,UACD,OAAO,IAAIC;oBAGf,OAAOC,QAAQ,UACJR,QAAQ,SAAS,CAAC,OAAO,CAACS;gBAEzC;gBACA,MAAM,SAAQV,CAAC,EAAEW,IAAS,EAAEV,OAAO;oBAC/B,MAAMW,UAAUX,QAAQ,SAAS,CAAC,OAAO,CAACY;oBAC1C,MAAMT,SAAS,MAAMQ,QAAQ,OAAO,CAACD,KAAK,EAAE;oBAE5C,IAAIP,OAAO,MAAM,IACb,OAAO,IAAIU,cAAcV,OAAO,KAAK;oBAGzC,OAAO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W,SAASX,OAAO,KAAK;gBACpC;gBACA,MAAM,YAAWJ,CAAC,EAAEW,IAAS,EAAEV,OAAO;oBAClC,MAAMwB,aAAaxB,QAAQ,SAAS,CAAC,OAAO,CAACyB;oBAC7C,MAAMtB,SAAS,MAAMqB,WAAW,OAAO,CAAC;wBACpC,IAAId,KAAK,EAAE;wBACX,GAAGA,KAAK,IAAI;oBAChB;oBAEA,IAAIP,OAAO,MAAM,IACb,OAAO,IAAIU,cAAcV,OAAO,KAAK;oBAGzC,OAAO,IAAIW,SAASX,OAAO,KAAK;gBACpC;gBACA,MAAM,YAAWJ,CAAC,EAAEW,IAAS,EAAEV,OAAO;oBAClC,MAAM0B,aAAa1B,QAAQ,SAAS,CAAC,OAAO,CAAC2B;oBAC7C,MAAMxB,SAAS,MAAMuB,WAAW,OAAO,CAAChB,KAAK,EAAE;oBAE/C,IAAIP,OAAO,MAAM,IACb,OAAO,IAAIU,cAAcV,OAAO,KAAK;oBAIzC,OAAO,IAAIW,SAAS;gBACxB;YACJ;QACJ;IACJ;IACApB,mBAAmB,IAAI,GAAG;IAE1B,OAAOA;AACX"}
@@ -1,69 +1,61 @@
1
- import { ErrorResponse, GraphQLSchemaPlugin } from "@webiny/handler-graphql";
2
- import { Response, NotFoundResponse } from "@webiny/handler-graphql";
1
+ import { ErrorResponse, GraphQLSchemaPlugin, NotFoundResponse, Response } from "@webiny/handler-graphql";
3
2
  import { NotAuthorizedError } from "@webiny/api-core/features/security/shared/index.js";
4
3
  import { ListFilesUseCase } from "../features/file/ListFiles/index.js";
5
- export const getFileByUrl = () => {
6
- const fileManagerGraphQL = new GraphQLSchemaPlugin({
7
- typeDefs: /* GraphQL */`
4
+ const getFileByUrl = ()=>{
5
+ const fileManagerGraphQL = new GraphQLSchemaPlugin({
6
+ typeDefs: `
8
7
  extend type FmQuery {
9
8
  getFileByUrl(url: String!): FmFileResponse
10
9
  }
11
10
  `,
12
- resolvers: {
13
- FmQuery: {
14
- async getFileByUrl(_, args, context) {
15
- const {
16
- url
17
- } = args;
18
- const useCase = new SecureGetFileByUrl(context.security, new GetFileByUrlUseCase(context.container.resolve(ListFilesUseCase)));
19
- try {
20
- const file = await useCase.execute(url);
21
- if (file) {
22
- return new Response(file);
11
+ resolvers: {
12
+ FmQuery: {
13
+ async getFileByUrl (_, args, context) {
14
+ const { url } = args;
15
+ const useCase = new SecureGetFileByUrl(context.security, new GetFileByUrlUseCase(context.container.resolve(ListFilesUseCase)));
16
+ try {
17
+ const file = await useCase.execute(url);
18
+ if (file) return new Response(file);
19
+ return new NotFoundResponse("File not found!");
20
+ } catch (error) {
21
+ return new ErrorResponse(error);
22
+ }
23
+ }
23
24
  }
24
- return new NotFoundResponse("File not found!");
25
- } catch (error) {
26
- return new ErrorResponse(error);
27
- }
28
25
  }
29
- }
30
- }
31
- });
32
- fileManagerGraphQL.name = "fm.graphql.getFileByUrl";
33
- return fileManagerGraphQL;
26
+ });
27
+ fileManagerGraphQL.name = "fm.graphql.getFileByUrl";
28
+ return fileManagerGraphQL;
34
29
  };
35
30
  class GetFileByUrlUseCase {
36
- constructor(listFiles) {
37
- this.listFiles = listFiles;
38
- }
39
- async execute(url) {
40
- const {
41
- pathname
42
- } = new URL(url);
43
- const query = pathname.replace("/files/", "").replace("/private/", "");
44
- const filesResult = await this.listFiles.execute({
45
- where: {
46
- key: query
47
- },
48
- limit: 1
49
- });
50
- const files = filesResult.value.items;
51
- return files.length ? files[0] : undefined;
52
- }
31
+ constructor(listFiles){
32
+ this.listFiles = listFiles;
33
+ }
34
+ async execute(url) {
35
+ const { pathname } = new URL(url);
36
+ const query = pathname.replace("/files/", "").replace("/private/", "");
37
+ const filesResult = await this.listFiles.execute({
38
+ where: {
39
+ key: query
40
+ },
41
+ limit: 1
42
+ });
43
+ const files = filesResult.value.items;
44
+ return files.length ? files[0] : void 0;
45
+ }
53
46
  }
54
47
  class SecureGetFileByUrl {
55
- constructor(security, useCase) {
56
- this.security = security;
57
- this.useCase = useCase;
58
- }
59
- execute(url) {
60
- if (!this.security.getIdentity()) {
61
- throw new NotAuthorizedError({
62
- message: "You're not authorized to edit this file!"
63
- });
48
+ constructor(security, useCase){
49
+ this.security = security;
50
+ this.useCase = useCase;
51
+ }
52
+ execute(url) {
53
+ if (!this.security.getIdentity()) throw new NotAuthorizedError({
54
+ message: "You're not authorized to edit this file!"
55
+ });
56
+ return this.useCase.execute(url);
64
57
  }
65
- return this.useCase.execute(url);
66
- }
67
58
  }
59
+ export { getFileByUrl };
68
60
 
69
61
  //# sourceMappingURL=getFileByUrl.js.map
@@ -1 +1 @@
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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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
+ {"version":3,"file":"graphql/getFileByUrl.js","sources":["../../src/graphql/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"],"names":["getFileByUrl","fileManagerGraphQL","GraphQLSchemaPlugin","_","args","context","url","useCase","SecureGetFileByUrl","GetFileByUrlUseCase","ListFilesUseCase","file","Response","NotFoundResponse","error","ErrorResponse","listFiles","pathname","URL","query","filesResult","files","undefined","security","NotAuthorizedError"],"mappings":";;;AAQO,MAAMA,eAAe;IACxB,MAAMC,qBAAqB,IAAIC,oBAAoC;QAC/D,UAAwB,CAAC;;;;QAIzB,CAAC;QACD,WAAW;YACP,SAAS;gBACL,MAAM,cAAaC,CAAC,EAAEC,IAAI,EAAEC,OAAO;oBAC/B,MAAM,EAAEC,GAAG,EAAE,GAAGF;oBAChB,MAAMG,UAAU,IAAIC,mBAChBH,QAAQ,QAAQ,EAChB,IAAII,oBAAoBJ,QAAQ,SAAS,CAAC,OAAO,CAACK;oBAEtD,IAAI;wBACA,MAAMC,OAAO,MAAMJ,QAAQ,OAAO,CAACD;wBACnC,IAAIK,MACA,OAAO,IAAIC,SAASD;wBAExB,OAAO,IAAIE,iBAAiB;oBAChC,EAAE,OAAOC,OAAO;wBACZ,OAAO,IAAIC,cAAcD;oBAC7B;gBACJ;YACJ;QACJ;IACJ;IACAb,mBAAmB,IAAI,GAAG;IAE1B,OAAOA;AACX;AAMA,MAAMQ;IACF,YAAoBO,SAAqC,CAAE;aAAvCA,SAAS,GAATA;IAAwC;IAE5D,MAAM,QAAQV,GAAW,EAA6B;QAClD,MAAM,EAAEW,QAAQ,EAAE,GAAG,IAAIC,IAAIZ;QAC7B,MAAMa,QAAQF,SAAS,OAAO,CAAC,WAAW,IAAI,OAAO,CAAC,aAAa;QAEnE,MAAMG,cAAc,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;YAC7C,OAAO;gBACH,KAAKD;YACT;YACA,OAAO;QACX;QAEA,MAAME,QAAQD,YAAY,KAAK,CAAC,KAAK;QAErC,OAAOC,MAAM,MAAM,GAAGA,KAAK,CAAC,EAAE,GAAGC;IACrC;AACJ;AAEA,MAAMd;IAIF,YAAYe,QAAkB,EAAEhB,OAAsB,CAAE;QACpD,IAAI,CAAC,QAAQ,GAAGgB;QAChB,IAAI,CAAC,OAAO,GAAGhB;IACnB;IAEA,QAAQD,GAAW,EAA6B;QAC5C,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,WAAW,IAC1B,MAAM,IAAIkB,mBAAmB;YAAE,SAAS;QAA2C;QAGvF,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,CAAClB;IAChC;AACJ"}
package/graphql/index.js CHANGED
@@ -1,53 +1,47 @@
1
1
  import { ContextPlugin } from "@webiny/api";
2
2
  import { GraphQLSchemaPlugin } from "@webiny/handler-graphql";
3
3
  import { ListModelsUseCase } from "@webiny/api-headless-cms/features/contentModel/ListModels/index.js";
4
- import { createFieldTypePluginRecords } from "@webiny/api-headless-cms/graphql/schema/createFieldTypePluginRecords.js";
5
4
  import { createGraphQLSchemaPluginFromFieldPlugins } from "@webiny/api-headless-cms/utils/getSchemaFromFieldPlugins.js";
6
5
  import { createBaseSchema } from "./baseSchema.js";
7
6
  import { createFilesSchema } from "./filesSchema.js";
8
7
  import { getFileByUrl } from "./getFileByUrl.js";
9
8
  import { FileModel } from "../domain/file/abstractions.js";
10
- import { TenantContext } from "@webiny/api-core/features/TenantContext";
11
- export const createGraphQLSchemaPlugin = () => {
12
- return [createBaseSchema(),
13
- // Files schema is generated dynamically, based on a CMS model, so we need to
14
- // register it from a ContextPlugin, to perform additional bootstrap.
15
- new ContextPlugin(async context => {
16
- const tenantContext = context.container.resolve(TenantContext);
17
- if (!tenantContext.getTenant()) {
18
- return;
19
- }
20
- const fileModel = context.container.resolve(FileModel);
21
- const listModels = context.container.resolve(ListModelsUseCase);
22
- await context.security.withoutAuthorization(async () => {
23
- const modelsResult = await listModels.execute();
24
- const models = modelsResult.value;
25
- const fieldPlugins = createFieldTypePluginRecords(context.plugins);
26
- /**
27
- * We need to register all plugins for all the CMS fields.
28
- */
29
- const plugins = createGraphQLSchemaPluginFromFieldPlugins({
30
- models,
31
- type: "manage",
32
- fieldTypePlugins: fieldPlugins,
33
- createPlugin: ({
34
- schema,
35
- type,
36
- fieldType
37
- }) => {
38
- const plugin = new GraphQLSchemaPlugin(schema);
39
- plugin.name = `fm.graphql.schema.${type}.field.${fieldType}`;
40
- return plugin;
41
- }
42
- });
43
- const graphQlPlugin = createFilesSchema({
44
- model: fileModel,
45
- models,
46
- plugins: fieldPlugins
47
- });
48
- context.plugins.register([...plugins, graphQlPlugin, getFileByUrl()]);
49
- });
50
- })];
51
- };
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
+ const createGraphQLSchemaPlugin = ()=>[
12
+ createBaseSchema(),
13
+ new ContextPlugin(async (context)=>{
14
+ const tenantContext = context.container.resolve(TenantContext);
15
+ if (!tenantContext.getTenant()) return;
16
+ const fileModel = context.container.resolve(FileModel);
17
+ const listModels = context.container.resolve(ListModelsUseCase);
18
+ const fieldRegistry = context.container.resolve(CmsModelFieldToGraphQLRegistry);
19
+ await context.security.withoutAuthorization(async ()=>{
20
+ const modelsResult = await listModels.execute();
21
+ const models = modelsResult.value;
22
+ const plugins = createGraphQLSchemaPluginFromFieldPlugins({
23
+ models,
24
+ type: "manage",
25
+ fieldRegistry,
26
+ createPlugin: ({ schema, type, fieldType })=>{
27
+ const plugin = new GraphQLSchemaPlugin(schema);
28
+ plugin.name = `fm.graphql.schema.${type}.field.${fieldType}`;
29
+ return plugin;
30
+ }
31
+ });
32
+ const graphQlPlugin = createFilesSchema({
33
+ model: fileModel,
34
+ models,
35
+ fieldRegistry
36
+ });
37
+ context.plugins.register([
38
+ ...plugins,
39
+ graphQlPlugin,
40
+ getFileByUrl()
41
+ ]);
42
+ });
43
+ })
44
+ ];
45
+ export { createGraphQLSchemaPlugin };
52
46
 
53
47
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["ContextPlugin","GraphQLSchemaPlugin","ListModelsUseCase","createFieldTypePluginRecords","createGraphQLSchemaPluginFromFieldPlugins","createBaseSchema","createFilesSchema","getFileByUrl","FileModel","TenantContext","createGraphQLSchemaPlugin","context","tenantContext","container","resolve","getTenant","fileModel","listModels","security","withoutAuthorization","modelsResult","execute","models","value","fieldPlugins","plugins","type","fieldTypePlugins","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 { createFieldTypePluginRecords } from \"@webiny/api-headless-cms/graphql/schema/createFieldTypePluginRecords.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/TenantContext\";\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\n await context.security.withoutAuthorization(async () => {\n const modelsResult = await listModels.execute();\n const models = modelsResult.value;\n\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,SAASA,aAAa,QAAQ,aAAa;AAE3C,SAASC,mBAAmB,QAAQ,yBAAyB;AAC7D,SAASC,iBAAiB,QAAQ,oEAAoE;AACtG,SAASC,4BAA4B,QAAQ,yEAAyE;AACtH,SAASC,yCAAyC,QAAQ,6DAA6D;AACvH,SAASC,gBAAgB;AACzB,SAASC,iBAAiB;AAC1B,SAASC,YAAY;AACrB,SAASC,SAAS;AAClB,SAASC,aAAa,QAAQ,yCAAyC;AAEvE,OAAO,MAAMC,yBAAyB,GAAGA,CAAA,KAAM;EAC3C,OAAO,CACHL,gBAAgB,CAAC,CAAC;EAClB;EACA;EACA,IAAIL,aAAa,CAAiB,MAAMW,OAAO,IAAI;IAC/C,MAAMC,aAAa,GAAGD,OAAO,CAACE,SAAS,CAACC,OAAO,CAACL,aAAa,CAAC;IAC9D,IAAI,CAACG,aAAa,CAACG,SAAS,CAAC,CAAC,EAAE;MAC5B;IACJ;IAEA,MAAMC,SAAS,GAAGL,OAAO,CAACE,SAAS,CAACC,OAAO,CAACN,SAAS,CAAC;IACtD,MAAMS,UAAU,GAAGN,OAAO,CAACE,SAAS,CAACC,OAAO,CAACZ,iBAAiB,CAAC;IAE/D,MAAMS,OAAO,CAACO,QAAQ,CAACC,oBAAoB,CAAC,YAAY;MACpD,MAAMC,YAAY,GAAG,MAAMH,UAAU,CAACI,OAAO,CAAC,CAAC;MAC/C,MAAMC,MAAM,GAAGF,YAAY,CAACG,KAAK;MAEjC,MAAMC,YAAY,GAAGrB,4BAA4B,CAACQ,OAAO,CAACc,OAAO,CAAC;MAClE;AAChB;AACA;MACgB,MAAMA,OAAO,GAAGrB,yCAAyC,CAAC;QACtDkB,MAAM;QACNI,IAAI,EAAE,QAAQ;QACdC,gBAAgB,EAAEH,YAAY;QAC9BI,YAAY,EAAEA,CAAC;UAAEC,MAAM;UAAEH,IAAI;UAAEI;QAAU,CAAC,KAAK;UAC3C,MAAMC,MAAM,GAAG,IAAI9B,mBAAmB,CAAC4B,MAAM,CAAC;UAC9CE,MAAM,CAACC,IAAI,GAAG,qBAAqBN,IAAI,UAAUI,SAAS,EAAE;UAC5D,OAAOC,MAAM;QACjB;MACJ,CAAC,CAAC;MAEF,MAAME,aAAa,GAAG3B,iBAAiB,CAAC;QACpC4B,KAAK,EAAElB,SAAS;QAChBM,MAAM;QACNG,OAAO,EAAED;MACb,CAAC,CAAC;MAEFb,OAAO,CAACc,OAAO,CAACU,QAAQ,CAAC,CAAC,GAAGV,OAAO,EAAEQ,aAAa,EAAE1B,YAAY,CAAC,CAAC,CAAC,CAAC;IACzE,CAAC,CAAC;EACN,CAAC,CAAC,CACL;AACL,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"graphql/index.js","sources":["../../src/graphql/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"],"names":["createGraphQLSchemaPlugin","createBaseSchema","ContextPlugin","context","tenantContext","TenantContext","fileModel","FileModel","listModels","ListModelsUseCase","fieldRegistry","CmsModelFieldToGraphQLRegistry","modelsResult","models","plugins","createGraphQLSchemaPluginFromFieldPlugins","schema","type","fieldType","plugin","GraphQLSchemaPlugin","graphQlPlugin","createFilesSchema","getFileByUrl"],"mappings":";;;;;;;;;;AAYO,MAAMA,4BAA4B,IAC9B;QACHC;QAGA,IAAIC,cAA8B,OAAMC;YACpC,MAAMC,gBAAgBD,QAAQ,SAAS,CAAC,OAAO,CAACE;YAChD,IAAI,CAACD,cAAc,SAAS,IACxB;YAGJ,MAAME,YAAYH,QAAQ,SAAS,CAAC,OAAO,CAACI;YAC5C,MAAMC,aAAaL,QAAQ,SAAS,CAAC,OAAO,CAACM;YAC7C,MAAMC,gBAAgBP,QAAQ,SAAS,CAAC,OAAO,CAACQ;YAEhD,MAAMR,QAAQ,QAAQ,CAAC,oBAAoB,CAAC;gBACxC,MAAMS,eAAe,MAAMJ,WAAW,OAAO;gBAC7C,MAAMK,SAASD,aAAa,KAAK;gBAKjC,MAAME,UAAUC,0CAA0C;oBACtDF;oBACA,MAAM;oBACNH;oBACA,cAAc,CAAC,EAAEM,MAAM,EAAEC,IAAI,EAAEC,SAAS,EAAE;wBACtC,MAAMC,SAAS,IAAIC,oBAAoBJ;wBACvCG,OAAO,IAAI,GAAG,CAAC,kBAAkB,EAAEF,KAAK,OAAO,EAAEC,WAAW;wBAC5D,OAAOC;oBACX;gBACJ;gBAEA,MAAME,gBAAgBC,kBAAkB;oBACpC,OAAOhB;oBACPO;oBACAH;gBACJ;gBAEAP,QAAQ,OAAO,CAAC,QAAQ,CAAC;uBAAIW;oBAASO;oBAAeE;iBAAe;YACxE;QACJ;KACH"}
package/graphql/utils.js CHANGED
@@ -1,17 +1,12 @@
1
- import { Response, ErrorResponse } from "@webiny/handler-graphql";
2
- export const emptyResolver = () => ({});
3
-
4
- /**
5
- * Use any because it really can be any.
6
- * TODO @ts-refactor maybe use generics at some point?
7
- */
8
-
9
- export const resolve = async fn => {
10
- try {
11
- return new Response(await fn());
12
- } catch (e) {
13
- return new ErrorResponse(e);
14
- }
1
+ import { ErrorResponse, Response } from "@webiny/handler-graphql";
2
+ const emptyResolver = ()=>({});
3
+ const resolve = async (fn)=>{
4
+ try {
5
+ return new Response(await fn());
6
+ } catch (e) {
7
+ return new ErrorResponse(e);
8
+ }
15
9
  };
10
+ export { emptyResolver, resolve };
16
11
 
17
12
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
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":[]}
1
+ {"version":3,"file":"graphql/utils.js","sources":["../../src/graphql/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"],"names":["emptyResolver","resolve","fn","Response","e","ErrorResponse"],"mappings":";AAEO,MAAMA,gBAAgB,IAAO,EAAC;AAU9B,MAAMC,UAAU,OAAOC;IAC1B,IAAI;QACA,OAAO,IAAIC,SAAS,MAAMD;IAC9B,EAAE,OAAOE,GAAG;QACR,OAAO,IAAIC,cAAcD;IAC7B;AACJ"}
package/index.d.ts CHANGED
@@ -2,6 +2,6 @@ import type { ApiCoreContext } from "@webiny/api-core/types/core.js";
2
2
  import { ContextPlugin } from "@webiny/api";
3
3
  export * from "./modelModifier/CmsModelModifier.js";
4
4
  export * from "./delivery/index.js";
5
- export declare const createFileManagerContext: () => ContextPlugin<ApiCoreContext>;
5
+ export declare const createFileManagerContext: () => (ContextPlugin<ApiCoreContext> | import("@webiny/handler").RegisterExtensionPlugin<import("@webiny/handler/types.js").Context>)[];
6
6
  export declare const createFileManagerGraphQL: () => (import("@webiny/handler-graphql/index.js").GraphQLSchemaPlugin<ApiCoreContext> | ContextPlugin<ApiCoreContext>)[];
7
- export declare const createAssetDelivery: () => (import("./delivery/index.js").AssetDeliveryConfigModifierPlugin | import("@webiny/handler/index.js").ModifyFastifyPlugin)[];
7
+ export declare const createAssetDelivery: () => (import("@webiny/handler").ModifyFastifyPlugin | import("@webiny/handler").RegisterExtensionPlugin<import("@webiny/handler/types.js").Context>)[];
package/index.js CHANGED
@@ -1,52 +1,44 @@
1
1
  import { ContextPlugin } from "@webiny/api";
2
- import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
3
2
  import { setupAssetDelivery } from "./delivery/setupAssetDelivery.js";
4
3
  import { createGraphQLSchemaPlugin } from "./graphql/index.js";
5
4
  import { FileManagerFeature } from "./features/FileManagerFeature.js";
6
- import { FilesPermissions as FilePermissionsImpl } from "./permissions/FilesPermissions.js";
7
- import { SettingsPermissions as SettingsPermissionsImpl } from "./permissions/SettingsPermissions.js";
8
- import { FilePermissions, SettingsPermissions } from "./features/shared/abstractions.js";
5
+ import { FmPermissionsFeature } from "./features/permissions/feature.js";
9
6
  import { GetModelUseCase } from "@webiny/api-headless-cms/features/contentModel/GetModel/index.js";
10
- import { FileModel as FileModelAbstraction } from "./domain/file/abstractions.js";
7
+ import { FileModel } from "./domain/file/abstractions.js";
11
8
  import { TenantContext } from "@webiny/api-core/features/tenancy/TenantContext/index.js";
12
- import { FileModel, FILE_MODEL_ID } from "./domain/file/file.model.js";
9
+ import { FILE_MODEL_ID, FileModel as file_model_js_FileModel } from "./domain/file/file.model.js";
10
+ import { createRegisterExtensionPlugin } from "@webiny/handler";
11
+ import { AssetDeliveryFeature } from "./features/assetDelivery/feature.js";
13
12
  export * from "./modelModifier/CmsModelModifier.js";
14
13
  export * from "./delivery/index.js";
15
- export const createFileManagerContext = () => {
16
- const plugin = new ContextPlugin(async context => {
17
- const tenantContext = context.container.resolve(TenantContext);
18
- const getModel = context.container.resolve(GetModelUseCase);
19
- if (!tenantContext.getTenant()) {
20
- return;
21
- }
22
- context.container.register(FileModel);
23
- await context.security.withoutAuthorization(async () => {
24
- const fileModel = await getModel.execute(FILE_MODEL_ID);
25
- context.container.registerInstance(FileModelAbstraction, fileModel.value);
14
+ const createFileManagerContext = ()=>{
15
+ const fileManagerContextPlugin = new ContextPlugin(async (context)=>{
16
+ const tenantContext = context.container.resolve(TenantContext);
17
+ const getModel = context.container.resolve(GetModelUseCase);
18
+ if (!tenantContext.getTenant()) return;
19
+ await context.security.withoutAuthorization(async ()=>{
20
+ const fileModel = await getModel.execute(FILE_MODEL_ID);
21
+ context.container.registerInstance(FileModel, fileModel.value);
22
+ });
23
+ FmPermissionsFeature.register(context.container);
24
+ FileManagerFeature.register(context.container);
26
25
  });
27
- const identityContext = context.container.resolve(IdentityContext);
28
- const filePermissions = new FilePermissionsImpl({
29
- getIdentity: () => identityContext.getIdentity(),
30
- getPermissions: () => identityContext.getPermissions("fm.file"),
31
- fullAccessPermissionName: "fm.*"
26
+ fileManagerContextPlugin.name = "file-manager.createContext";
27
+ const modelsPlugin = createRegisterExtensionPlugin((context)=>{
28
+ context.container.register(file_model_js_FileModel);
32
29
  });
33
- const settingsPermissions = new SettingsPermissionsImpl({
34
- getIdentity: () => identityContext.getIdentity(),
35
- getPermissions: () => identityContext.getPermissions("fm.settings"),
36
- fullAccessPermissionName: "fm.*"
37
- });
38
- context.container.registerInstance(FilePermissions, filePermissions);
39
- context.container.registerInstance(SettingsPermissions, settingsPermissions);
40
- FileManagerFeature.register(context.container);
41
- });
42
- plugin.name = "file-manager.createContext";
43
- return plugin;
44
- };
45
- export const createFileManagerGraphQL = () => {
46
- return createGraphQLSchemaPlugin();
47
- };
48
- export const createAssetDelivery = () => {
49
- return setupAssetDelivery();
30
+ return [
31
+ fileManagerContextPlugin,
32
+ modelsPlugin
33
+ ];
50
34
  };
35
+ const createFileManagerGraphQL = ()=>createGraphQLSchemaPlugin();
36
+ const createAssetDelivery = ()=>[
37
+ createRegisterExtensionPlugin((context)=>{
38
+ AssetDeliveryFeature.register(context.container);
39
+ }),
40
+ ...setupAssetDelivery()
41
+ ];
42
+ export { createAssetDelivery, createFileManagerContext, createFileManagerGraphQL };
51
43
 
52
44
  //# sourceMappingURL=index.js.map
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["ContextPlugin","IdentityContext","setupAssetDelivery","createGraphQLSchemaPlugin","FileManagerFeature","FilesPermissions","FilePermissionsImpl","SettingsPermissions","SettingsPermissionsImpl","FilePermissions","GetModelUseCase","FileModel","FileModelAbstraction","TenantContext","FILE_MODEL_ID","createFileManagerContext","plugin","context","tenantContext","container","resolve","getModel","getTenant","register","security","withoutAuthorization","fileModel","execute","registerInstance","value","identityContext","filePermissions","getIdentity","getPermissions","fullAccessPermissionName","settingsPermissions","name","createFileManagerGraphQL","createAssetDelivery"],"sources":["index.ts"],"sourcesContent":["import type { ApiCoreContext } from \"@webiny/api-core/types/core.js\";\nimport { ContextPlugin } from \"@webiny/api\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport type { FilePermission, SettingsPermission } from \"~/types.js\";\nimport { setupAssetDelivery } from \"./delivery/setupAssetDelivery.js\";\nimport { createGraphQLSchemaPlugin } from \"./graphql/index.js\";\nimport { FileManagerFeature } from \"~/features/FileManagerFeature.js\";\nimport { FilesPermissions as FilePermissionsImpl } from \"~/permissions/FilesPermissions.js\";\nimport { SettingsPermissions as SettingsPermissionsImpl } from \"~/permissions/SettingsPermissions.js\";\nimport { FilePermissions, SettingsPermissions } from \"~/features/shared/abstractions.js\";\nimport { GetModelUseCase } from \"@webiny/api-headless-cms/features/contentModel/GetModel/index.js\";\nimport { FileModel as FileModelAbstraction } from \"~/domain/file/abstractions.js\";\nimport { TenantContext } from \"@webiny/api-core/features/tenancy/TenantContext/index.js\";\nimport { FileModel, FILE_MODEL_ID } from \"~/domain/file/file.model.js\";\n\nexport * from \"./modelModifier/CmsModelModifier.js\";\nexport * from \"./delivery/index.js\";\n\nexport const createFileManagerContext = () => {\n const plugin = new ContextPlugin<ApiCoreContext>(async context => {\n const tenantContext = context.container.resolve(TenantContext);\n const getModel = context.container.resolve(GetModelUseCase);\n\n if (!tenantContext.getTenant()) {\n return;\n }\n\n context.container.register(FileModel);\n\n await context.security.withoutAuthorization(async () => {\n const fileModel = await getModel.execute(FILE_MODEL_ID);\n context.container.registerInstance(FileModelAbstraction, fileModel.value);\n });\n\n const identityContext = context.container.resolve(IdentityContext);\n\n const filePermissions = new FilePermissionsImpl({\n getIdentity: () => identityContext.getIdentity(),\n getPermissions: () => identityContext.getPermissions<FilePermission>(\"fm.file\"),\n fullAccessPermissionName: \"fm.*\"\n });\n\n const settingsPermissions = new SettingsPermissionsImpl({\n getIdentity: () => identityContext.getIdentity(),\n getPermissions: () => identityContext.getPermissions<SettingsPermission>(\"fm.settings\"),\n fullAccessPermissionName: \"fm.*\"\n });\n\n context.container.registerInstance(FilePermissions, filePermissions);\n context.container.registerInstance(SettingsPermissions, settingsPermissions);\n\n FileManagerFeature.register(context.container);\n });\n\n plugin.name = \"file-manager.createContext\";\n\n return plugin;\n};\n\nexport const createFileManagerGraphQL = () => {\n return createGraphQLSchemaPlugin();\n};\n\nexport const createAssetDelivery = () => {\n return setupAssetDelivery();\n};\n"],"mappings":"AACA,SAASA,aAAa,QAAQ,aAAa;AAC3C,SAASC,eAAe,QAAQ,6DAA6D;AAE7F,SAASC,kBAAkB;AAC3B,SAASC,yBAAyB;AAClC,SAASC,kBAAkB;AAC3B,SAASC,gBAAgB,IAAIC,mBAAmB;AAChD,SAASC,mBAAmB,IAAIC,uBAAuB;AACvD,SAASC,eAAe,EAAEF,mBAAmB;AAC7C,SAASG,eAAe,QAAQ,kEAAkE;AAClG,SAASC,SAAS,IAAIC,oBAAoB;AAC1C,SAASC,aAAa,QAAQ,0DAA0D;AACxF,SAASF,SAAS,EAAEG,aAAa;AAEjC;AACA;AAEA,OAAO,MAAMC,wBAAwB,GAAGA,CAAA,KAAM;EAC1C,MAAMC,MAAM,GAAG,IAAIhB,aAAa,CAAiB,MAAMiB,OAAO,IAAI;IAC9D,MAAMC,aAAa,GAAGD,OAAO,CAACE,SAAS,CAACC,OAAO,CAACP,aAAa,CAAC;IAC9D,MAAMQ,QAAQ,GAAGJ,OAAO,CAACE,SAAS,CAACC,OAAO,CAACV,eAAe,CAAC;IAE3D,IAAI,CAACQ,aAAa,CAACI,SAAS,CAAC,CAAC,EAAE;MAC5B;IACJ;IAEAL,OAAO,CAACE,SAAS,CAACI,QAAQ,CAACZ,SAAS,CAAC;IAErC,MAAMM,OAAO,CAACO,QAAQ,CAACC,oBAAoB,CAAC,YAAY;MACpD,MAAMC,SAAS,GAAG,MAAML,QAAQ,CAACM,OAAO,CAACb,aAAa,CAAC;MACvDG,OAAO,CAACE,SAAS,CAACS,gBAAgB,CAAChB,oBAAoB,EAAEc,SAAS,CAACG,KAAK,CAAC;IAC7E,CAAC,CAAC;IAEF,MAAMC,eAAe,GAAGb,OAAO,CAACE,SAAS,CAACC,OAAO,CAACnB,eAAe,CAAC;IAElE,MAAM8B,eAAe,GAAG,IAAIzB,mBAAmB,CAAC;MAC5C0B,WAAW,EAAEA,CAAA,KAAMF,eAAe,CAACE,WAAW,CAAC,CAAC;MAChDC,cAAc,EAAEA,CAAA,KAAMH,eAAe,CAACG,cAAc,CAAiB,SAAS,CAAC;MAC/EC,wBAAwB,EAAE;IAC9B,CAAC,CAAC;IAEF,MAAMC,mBAAmB,GAAG,IAAI3B,uBAAuB,CAAC;MACpDwB,WAAW,EAAEA,CAAA,KAAMF,eAAe,CAACE,WAAW,CAAC,CAAC;MAChDC,cAAc,EAAEA,CAAA,KAAMH,eAAe,CAACG,cAAc,CAAqB,aAAa,CAAC;MACvFC,wBAAwB,EAAE;IAC9B,CAAC,CAAC;IAEFjB,OAAO,CAACE,SAAS,CAACS,gBAAgB,CAACnB,eAAe,EAAEsB,eAAe,CAAC;IACpEd,OAAO,CAACE,SAAS,CAACS,gBAAgB,CAACrB,mBAAmB,EAAE4B,mBAAmB,CAAC;IAE5E/B,kBAAkB,CAACmB,QAAQ,CAACN,OAAO,CAACE,SAAS,CAAC;EAClD,CAAC,CAAC;EAEFH,MAAM,CAACoB,IAAI,GAAG,4BAA4B;EAE1C,OAAOpB,MAAM;AACjB,CAAC;AAED,OAAO,MAAMqB,wBAAwB,GAAGA,CAAA,KAAM;EAC1C,OAAOlC,yBAAyB,CAAC,CAAC;AACtC,CAAC;AAED,OAAO,MAAMmC,mBAAmB,GAAGA,CAAA,KAAM;EACrC,OAAOpC,kBAAkB,CAAC,CAAC;AAC/B,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import type { ApiCoreContext } from \"@webiny/api-core/types/core.js\";\nimport { ContextPlugin } from \"@webiny/api\";\nimport { setupAssetDelivery } from \"./delivery/setupAssetDelivery.js\";\nimport { createGraphQLSchemaPlugin } from \"./graphql/index.js\";\nimport { FileManagerFeature } from \"~/features/FileManagerFeature.js\";\nimport { FmPermissionsFeature } from \"~/features/permissions/feature.js\";\nimport { GetModelUseCase } from \"@webiny/api-headless-cms/features/contentModel/GetModel/index.js\";\nimport { FileModel as FileModelAbstraction } from \"~/domain/file/abstractions.js\";\nimport { TenantContext } from \"@webiny/api-core/features/tenancy/TenantContext/index.js\";\nimport { FileModel, FILE_MODEL_ID } from \"~/domain/file/file.model.js\";\nimport { createRegisterExtensionPlugin } from \"@webiny/handler\";\nimport { AssetDeliveryFeature } from \"~/features/assetDelivery/feature.js\";\n\nexport * from \"./modelModifier/CmsModelModifier.js\";\nexport * from \"./delivery/index.js\";\n\nexport const createFileManagerContext = () => {\n const fileManagerContextPlugin = new ContextPlugin<ApiCoreContext>(async context => {\n const tenantContext = context.container.resolve(TenantContext);\n const getModel = context.container.resolve(GetModelUseCase);\n\n if (!tenantContext.getTenant()) {\n return;\n }\n\n await context.security.withoutAuthorization(async () => {\n const fileModel = await getModel.execute(FILE_MODEL_ID);\n context.container.registerInstance(FileModelAbstraction, fileModel.value);\n });\n\n FmPermissionsFeature.register(context.container);\n FileManagerFeature.register(context.container);\n });\n\n fileManagerContextPlugin.name = \"file-manager.createContext\";\n\n const modelsPlugin = createRegisterExtensionPlugin(context => {\n context.container.register(FileModel);\n });\n\n return [fileManagerContextPlugin, modelsPlugin];\n};\n\nexport const createFileManagerGraphQL = () => {\n return createGraphQLSchemaPlugin();\n};\n\nexport const createAssetDelivery = () => {\n return [\n createRegisterExtensionPlugin(context => {\n AssetDeliveryFeature.register(context.container);\n }),\n ...setupAssetDelivery()\n ];\n};\n"],"names":["createFileManagerContext","fileManagerContextPlugin","ContextPlugin","context","tenantContext","TenantContext","getModel","GetModelUseCase","fileModel","FILE_MODEL_ID","FileModelAbstraction","FmPermissionsFeature","FileManagerFeature","modelsPlugin","createRegisterExtensionPlugin","FileModel","createFileManagerGraphQL","createGraphQLSchemaPlugin","createAssetDelivery","AssetDeliveryFeature","setupAssetDelivery"],"mappings":";;;;;;;;;;;;;AAgBO,MAAMA,2BAA2B;IACpC,MAAMC,2BAA2B,IAAIC,cAA8B,OAAMC;QACrE,MAAMC,gBAAgBD,QAAQ,SAAS,CAAC,OAAO,CAACE;QAChD,MAAMC,WAAWH,QAAQ,SAAS,CAAC,OAAO,CAACI;QAE3C,IAAI,CAACH,cAAc,SAAS,IACxB;QAGJ,MAAMD,QAAQ,QAAQ,CAAC,oBAAoB,CAAC;YACxC,MAAMK,YAAY,MAAMF,SAAS,OAAO,CAACG;YACzCN,QAAQ,SAAS,CAAC,gBAAgB,CAACO,WAAsBF,UAAU,KAAK;QAC5E;QAEAG,qBAAqB,QAAQ,CAACR,QAAQ,SAAS;QAC/CS,mBAAmB,QAAQ,CAACT,QAAQ,SAAS;IACjD;IAEAF,yBAAyB,IAAI,GAAG;IAEhC,MAAMY,eAAeC,8BAA8BX,CAAAA;QAC/CA,QAAQ,SAAS,CAAC,QAAQ,CAACY;IAC/B;IAEA,OAAO;QAACd;QAA0BY;KAAa;AACnD;AAEO,MAAMG,2BAA2B,IAC7BC;AAGJ,MAAMC,sBAAsB,IACxB;QACHJ,8BAA8BX,CAAAA;YAC1BgB,qBAAqB,QAAQ,CAAChB,QAAQ,SAAS;QACnD;WACGiB;KACN"}
@@ -2,53 +2,50 @@ import { Plugin } from "@webiny/plugins";
2
2
  import { createModelField } from "@webiny/api-headless-cms";
3
3
  import { FILE_MODEL_ID } from "../domain/file/file.model.js";
4
4
  class CmsModelFieldsModifier {
5
- constructor(fields) {
6
- this.fields = fields;
7
- }
8
- addField(field) {
9
- const {
10
- bulkEdit,
11
- tags,
12
- ...rest
13
- } = field;
14
- this.fields.push({
15
- ...rest,
16
- tags: (tags ?? []).concat(bulkEdit ? ["$bulk-edit"] : []),
17
- storageId: `${field.type}@${field.id}`
18
- });
19
- }
5
+ constructor(fields){
6
+ this.fields = fields;
7
+ }
8
+ addField(field) {
9
+ const { bulkEdit, tags, ...rest } = field;
10
+ this.fields.push({
11
+ ...rest,
12
+ tags: (tags ?? []).concat(bulkEdit ? [
13
+ "$bulk-edit"
14
+ ] : []),
15
+ storageId: `${field.type}@${field.id}`
16
+ });
17
+ }
20
18
  }
21
- export class CmsModelModifierPlugin extends Plugin {
22
- static type = "fm.cms-model-modifier";
23
- constructor(modelId, cb) {
24
- super();
25
- this.modelId = modelId;
26
- this.cb = cb;
27
- }
28
- async modifyModel(model) {
29
- if (model.modelId !== this.modelId) {
30
- return;
19
+ class CmsModelModifierPlugin extends Plugin {
20
+ static{
21
+ this.type = "fm.cms-model-modifier";
22
+ }
23
+ constructor(modelId, cb){
24
+ super();
25
+ this.modelId = modelId;
26
+ this.cb = cb;
31
27
  }
32
- let extensionsField = model.fields.find(field => field.fieldId === "extensions");
33
- if (!extensionsField) {
34
- extensionsField = createModelField({
35
- label: "Extensions",
36
- type: "object",
37
- settings: {
38
- layout: [],
39
- fields: []
28
+ async modifyModel(model) {
29
+ if (model.modelId !== this.modelId) return;
30
+ let extensionsField = model.fields.find((field)=>"extensions" === field.fieldId);
31
+ if (!extensionsField) {
32
+ extensionsField = createModelField({
33
+ label: "Extensions",
34
+ type: "object",
35
+ settings: {
36
+ layout: [],
37
+ fields: []
38
+ }
39
+ });
40
+ model.fields.push(extensionsField);
40
41
  }
41
- });
42
- model.fields.push(extensionsField);
42
+ const modifier = new CmsModelFieldsModifier(extensionsField.settings.fields);
43
+ await this.cb({
44
+ modifier
45
+ });
43
46
  }
44
- const modifier = new CmsModelFieldsModifier(extensionsField.settings.fields);
45
- await this.cb({
46
- modifier
47
- });
48
- }
49
47
  }
50
- export const createFileModelModifier = cb => {
51
- return new CmsModelModifierPlugin(FILE_MODEL_ID, cb);
52
- };
48
+ const createFileModelModifier = (cb)=>new CmsModelModifierPlugin(FILE_MODEL_ID, cb);
49
+ export { CmsModelModifierPlugin, createFileModelModifier };
53
50
 
54
51
  //# sourceMappingURL=CmsModelModifier.js.map