@webiny/api-file-manager 0.0.0-unstable.d7f521b032 → 0.0.0-unstable.de38392959

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 (289) hide show
  1. package/FileManagerContextSetup.d.ts +13 -0
  2. package/FileManagerContextSetup.js +115 -0
  3. package/FileManagerContextSetup.js.map +1 -0
  4. package/cmsFileStorage/CmsFilesStorage.d.ts +27 -0
  5. package/cmsFileStorage/CmsFilesStorage.js +176 -0
  6. package/cmsFileStorage/CmsFilesStorage.js.map +1 -0
  7. package/cmsFileStorage/ListFilesWhereProcessor.d.ts +7 -0
  8. package/cmsFileStorage/ListFilesWhereProcessor.js +33 -0
  9. package/cmsFileStorage/ListFilesWhereProcessor.js.map +1 -0
  10. package/cmsFileStorage/ListTagsWhereProcessor.d.ts +7 -0
  11. package/cmsFileStorage/ListTagsWhereProcessor.js +33 -0
  12. package/cmsFileStorage/ListTagsWhereProcessor.js.map +1 -0
  13. package/cmsFileStorage/createFileManagerPlugins.d.ts +7 -0
  14. package/cmsFileStorage/createFileManagerPlugins.js +17 -0
  15. package/cmsFileStorage/createFileManagerPlugins.js.map +1 -0
  16. package/cmsFileStorage/createModelField.d.ts +5 -0
  17. package/cmsFileStorage/createModelField.js +41 -0
  18. package/cmsFileStorage/createModelField.js.map +1 -0
  19. package/cmsFileStorage/file.model.d.ts +6 -0
  20. package/cmsFileStorage/file.model.js +153 -0
  21. package/cmsFileStorage/file.model.js.map +1 -0
  22. package/cmsFileStorage/isInstallationPending.d.ts +4 -0
  23. package/cmsFileStorage/isInstallationPending.js +23 -0
  24. package/cmsFileStorage/isInstallationPending.js.map +1 -0
  25. package/contants.d.ts +1 -0
  26. package/contants.js +10 -0
  27. package/contants.js.map +1 -0
  28. package/createFileManager/files.crud.d.ts +3 -0
  29. package/createFileManager/files.crud.js +328 -0
  30. package/createFileManager/files.crud.js.map +1 -0
  31. package/createFileManager/index.d.ts +15 -0
  32. package/createFileManager/index.js +23 -0
  33. package/createFileManager/index.js.map +1 -0
  34. package/createFileManager/permissions/FilesPermissions.d.ts +4 -0
  35. package/createFileManager/permissions/FilesPermissions.js +11 -0
  36. package/createFileManager/permissions/FilesPermissions.js.map +1 -0
  37. package/createFileManager/settings.crud.d.ts +3 -0
  38. package/{plugins/crud → createFileManager}/settings.crud.js +47 -56
  39. package/createFileManager/settings.crud.js.map +1 -0
  40. package/createFileManager/system.crud.d.ts +3 -0
  41. package/createFileManager/system.crud.js +88 -0
  42. package/createFileManager/system.crud.js.map +1 -0
  43. package/delivery/AssetDelivery/AliasAssetRequestResolver.d.ts +10 -0
  44. package/delivery/AssetDelivery/AliasAssetRequestResolver.js +74 -0
  45. package/delivery/AssetDelivery/AliasAssetRequestResolver.js.map +1 -0
  46. package/delivery/AssetDelivery/Asset.d.ts +30 -0
  47. package/delivery/AssetDelivery/Asset.js +64 -0
  48. package/delivery/AssetDelivery/Asset.js.map +1 -0
  49. package/delivery/AssetDelivery/AssetDeliveryConfig.d.ts +63 -0
  50. package/delivery/AssetDelivery/AssetDeliveryConfig.js +102 -0
  51. package/delivery/AssetDelivery/AssetDeliveryConfig.js.map +1 -0
  52. package/delivery/AssetDelivery/AssetRequest.d.ts +24 -0
  53. package/delivery/AssetDelivery/AssetRequest.js +29 -0
  54. package/delivery/AssetDelivery/AssetRequest.js.map +1 -0
  55. package/delivery/AssetDelivery/FilesAssetRequestResolver.d.ts +6 -0
  56. package/delivery/AssetDelivery/FilesAssetRequestResolver.js +33 -0
  57. package/delivery/AssetDelivery/FilesAssetRequestResolver.js.map +1 -0
  58. package/delivery/AssetDelivery/NullAssetOutputStrategy.d.ts +4 -0
  59. package/delivery/AssetDelivery/NullAssetOutputStrategy.js +15 -0
  60. package/delivery/AssetDelivery/NullAssetOutputStrategy.js.map +1 -0
  61. package/delivery/AssetDelivery/NullAssetReply.d.ts +4 -0
  62. package/delivery/AssetDelivery/NullAssetReply.js +20 -0
  63. package/delivery/AssetDelivery/NullAssetReply.js.map +1 -0
  64. package/delivery/AssetDelivery/NullAssetResolver.d.ts +5 -0
  65. package/delivery/AssetDelivery/NullAssetResolver.js +14 -0
  66. package/delivery/AssetDelivery/NullAssetResolver.js.map +1 -0
  67. package/delivery/AssetDelivery/NullRequestResolver.d.ts +4 -0
  68. package/delivery/AssetDelivery/NullRequestResolver.js +14 -0
  69. package/delivery/AssetDelivery/NullRequestResolver.js.map +1 -0
  70. package/delivery/AssetDelivery/SetCacheControlHeaders.d.ts +8 -0
  71. package/delivery/AssetDelivery/SetCacheControlHeaders.js +25 -0
  72. package/delivery/AssetDelivery/SetCacheControlHeaders.js.map +1 -0
  73. package/delivery/AssetDelivery/SetResponseHeaders.d.ts +18 -0
  74. package/delivery/AssetDelivery/SetResponseHeaders.js +25 -0
  75. package/delivery/AssetDelivery/SetResponseHeaders.js.map +1 -0
  76. package/delivery/AssetDelivery/abstractions/AssetContentsReader.d.ts +5 -0
  77. package/delivery/AssetDelivery/abstractions/AssetContentsReader.js +7 -0
  78. package/delivery/AssetDelivery/abstractions/AssetContentsReader.js.map +1 -0
  79. package/delivery/AssetDelivery/abstractions/AssetOutputStrategy.d.ts +4 -0
  80. package/delivery/AssetDelivery/abstractions/AssetOutputStrategy.js +7 -0
  81. package/delivery/AssetDelivery/abstractions/AssetOutputStrategy.js.map +1 -0
  82. package/delivery/AssetDelivery/abstractions/AssetProcessor.d.ts +4 -0
  83. package/delivery/AssetDelivery/abstractions/AssetProcessor.js +7 -0
  84. package/delivery/AssetDelivery/abstractions/AssetProcessor.js.map +1 -0
  85. package/delivery/AssetDelivery/abstractions/AssetReply.d.ts +25 -0
  86. package/delivery/AssetDelivery/abstractions/AssetReply.js +38 -0
  87. package/delivery/AssetDelivery/abstractions/AssetReply.js.map +1 -0
  88. package/delivery/AssetDelivery/abstractions/AssetRequestResolver.d.ts +5 -0
  89. package/delivery/AssetDelivery/abstractions/AssetRequestResolver.js +7 -0
  90. package/delivery/AssetDelivery/abstractions/AssetRequestResolver.js.map +1 -0
  91. package/delivery/AssetDelivery/abstractions/AssetResolver.d.ts +4 -0
  92. package/delivery/AssetDelivery/abstractions/AssetResolver.js +7 -0
  93. package/delivery/AssetDelivery/abstractions/AssetResolver.js.map +1 -0
  94. package/delivery/AssetDelivery/abstractions/AssetTransformationStrategy.d.ts +4 -0
  95. package/delivery/AssetDelivery/abstractions/AssetTransformationStrategy.js +7 -0
  96. package/delivery/AssetDelivery/abstractions/AssetTransformationStrategy.js.map +1 -0
  97. package/delivery/AssetDelivery/createAssetDeliveryPluginLoader.d.ts +2 -0
  98. package/delivery/AssetDelivery/createAssetDeliveryPluginLoader.js +15 -0
  99. package/delivery/AssetDelivery/createAssetDeliveryPluginLoader.js.map +1 -0
  100. package/delivery/AssetDelivery/privateFiles/AssetAuthorizer.d.ts +4 -0
  101. package/delivery/AssetDelivery/privateFiles/AssetAuthorizer.js +7 -0
  102. package/delivery/AssetDelivery/privateFiles/AssetAuthorizer.js.map +1 -0
  103. package/delivery/AssetDelivery/privateFiles/NotAuthorizedAssetReply.d.ts +4 -0
  104. package/delivery/AssetDelivery/privateFiles/NotAuthorizedAssetReply.js +26 -0
  105. package/delivery/AssetDelivery/privateFiles/NotAuthorizedAssetReply.js.map +1 -0
  106. package/delivery/AssetDelivery/privateFiles/NotAuthorizedOutputStrategy.d.ts +4 -0
  107. package/delivery/AssetDelivery/privateFiles/NotAuthorizedOutputStrategy.js +15 -0
  108. package/delivery/AssetDelivery/privateFiles/NotAuthorizedOutputStrategy.js.map +1 -0
  109. package/delivery/AssetDelivery/privateFiles/PrivateAuthenticatedAuthorizer.d.ts +7 -0
  110. package/delivery/AssetDelivery/privateFiles/PrivateAuthenticatedAuthorizer.js +28 -0
  111. package/delivery/AssetDelivery/privateFiles/PrivateAuthenticatedAuthorizer.js.map +1 -0
  112. package/delivery/AssetDelivery/privateFiles/PrivateCache.d.ts +4 -0
  113. package/delivery/AssetDelivery/privateFiles/PrivateCache.js +18 -0
  114. package/delivery/AssetDelivery/privateFiles/PrivateCache.js.map +1 -0
  115. package/delivery/AssetDelivery/privateFiles/PrivateFileAssetRequestResolver.d.ts +7 -0
  116. package/delivery/AssetDelivery/privateFiles/PrivateFileAssetRequestResolver.js +37 -0
  117. package/delivery/AssetDelivery/privateFiles/PrivateFileAssetRequestResolver.js.map +1 -0
  118. package/delivery/AssetDelivery/privateFiles/PrivateFilesAssetProcessor.d.ts +13 -0
  119. package/delivery/AssetDelivery/privateFiles/PrivateFilesAssetProcessor.js +62 -0
  120. package/delivery/AssetDelivery/privateFiles/PrivateFilesAssetProcessor.js.map +1 -0
  121. package/delivery/AssetDelivery/privateFiles/PublicCache.d.ts +4 -0
  122. package/delivery/AssetDelivery/privateFiles/PublicCache.js +18 -0
  123. package/delivery/AssetDelivery/privateFiles/PublicCache.js.map +1 -0
  124. package/delivery/AssetDelivery/privateFiles/RedirectToPrivateUrlOutputStrategy.d.ts +6 -0
  125. package/delivery/AssetDelivery/privateFiles/RedirectToPrivateUrlOutputStrategy.js +27 -0
  126. package/delivery/AssetDelivery/privateFiles/RedirectToPrivateUrlOutputStrategy.js.map +1 -0
  127. package/delivery/AssetDelivery/privateFiles/RedirectToPublicUrlOutputStrategy.d.ts +6 -0
  128. package/delivery/AssetDelivery/privateFiles/RedirectToPublicUrlOutputStrategy.js +27 -0
  129. package/delivery/AssetDelivery/privateFiles/RedirectToPublicUrlOutputStrategy.js.map +1 -0
  130. package/delivery/AssetDelivery/privateFiles/internalIdentity.d.ts +7 -0
  131. package/delivery/AssetDelivery/privateFiles/internalIdentity.js +19 -0
  132. package/delivery/AssetDelivery/privateFiles/internalIdentity.js.map +1 -0
  133. package/delivery/AssetDelivery/transformation/PassthroughAssetProcessor.d.ts +4 -0
  134. package/delivery/AssetDelivery/transformation/PassthroughAssetProcessor.js +14 -0
  135. package/delivery/AssetDelivery/transformation/PassthroughAssetProcessor.js.map +1 -0
  136. package/delivery/AssetDelivery/transformation/PassthroughAssetTransformationStrategy.d.ts +4 -0
  137. package/delivery/AssetDelivery/transformation/PassthroughAssetTransformationStrategy.js +14 -0
  138. package/delivery/AssetDelivery/transformation/PassthroughAssetTransformationStrategy.js.map +1 -0
  139. package/delivery/AssetDelivery/transformation/TransformationAssetProcessor.d.ts +6 -0
  140. package/delivery/AssetDelivery/transformation/TransformationAssetProcessor.js +25 -0
  141. package/delivery/AssetDelivery/transformation/TransformationAssetProcessor.js.map +1 -0
  142. package/delivery/index.d.ts +17 -0
  143. package/delivery/index.js +194 -0
  144. package/delivery/index.js.map +1 -0
  145. package/delivery/setupAssetDelivery.d.ts +6 -0
  146. package/delivery/setupAssetDelivery.js +126 -0
  147. package/delivery/setupAssetDelivery.js.map +1 -0
  148. package/graphql/baseSchema.d.ts +3 -0
  149. package/graphql/baseSchema.js +120 -0
  150. package/graphql/baseSchema.js.map +1 -0
  151. package/graphql/createFilesTypeDefs.d.ts +7 -0
  152. package/graphql/createFilesTypeDefs.js +185 -0
  153. package/graphql/createFilesTypeDefs.js.map +1 -0
  154. package/graphql/filesSchema.d.ts +4 -0
  155. package/graphql/filesSchema.js +91 -0
  156. package/graphql/filesSchema.js.map +1 -0
  157. package/graphql/getFileByUrl.d.ts +3 -0
  158. package/graphql/getFileByUrl.js +78 -0
  159. package/graphql/getFileByUrl.js.map +1 -0
  160. package/graphql/index.d.ts +4 -0
  161. package/graphql/index.js +55 -0
  162. package/graphql/index.js.map +1 -0
  163. package/graphql/utils.d.ts +11 -0
  164. package/graphql/utils.js +24 -0
  165. package/graphql/utils.js.map +1 -0
  166. package/handlers/{transform/managers → manage}/imageManager.d.ts +2 -3
  167. package/handlers/manage/imageManager.js +76 -0
  168. package/handlers/manage/imageManager.js.map +1 -0
  169. package/handlers/manage/index.d.ts +1 -1
  170. package/handlers/manage/index.js +7 -19
  171. package/handlers/manage/index.js.map +1 -1
  172. package/handlers/{transform/utils.js → manage/legacyUtils.js} +2 -10
  173. package/handlers/manage/legacyUtils.js.map +1 -0
  174. package/handlers/manage/utils.d.ts +12 -0
  175. package/handlers/manage/utils.js +38 -0
  176. package/handlers/manage/utils.js.map +1 -0
  177. package/handlers/types.d.ts +1 -1
  178. package/handlers/types.js +3 -1
  179. package/handlers/types.js.map +1 -1
  180. package/handlers/utils/getEnvironment.js +2 -2
  181. package/handlers/utils/getEnvironment.js.map +1 -1
  182. package/handlers/utils/getObjectParams.js +2 -4
  183. package/handlers/utils/getObjectParams.js.map +1 -1
  184. package/handlers/utils/index.js +2 -3
  185. package/handlers/utils/index.js.map +1 -1
  186. package/index.d.ts +10 -0
  187. package/index.js +72 -0
  188. package/index.js.map +1 -0
  189. package/modelModifier/CmsModelModifier.d.ts +26 -0
  190. package/modelModifier/CmsModelModifier.js +62 -0
  191. package/modelModifier/CmsModelModifier.js.map +1 -0
  192. package/package.json +32 -33
  193. package/plugins/{definitions/FilePhysicalStoragePlugin.d.ts → FilePhysicalStoragePlugin.d.ts} +1 -1
  194. package/plugins/{definitions/FilePhysicalStoragePlugin.js → FilePhysicalStoragePlugin.js} +3 -14
  195. package/plugins/FilePhysicalStoragePlugin.js.map +1 -0
  196. package/plugins/{definitions/FileStorageTransformPlugin.d.ts → FileStorageTransformPlugin.d.ts} +1 -1
  197. package/plugins/{definitions/FileStorageTransformPlugin.js → FileStorageTransformPlugin.js} +4 -16
  198. package/plugins/FileStorageTransformPlugin.js.map +1 -0
  199. package/plugins/index.d.ts +2 -2
  200. package/plugins/index.js +23 -18
  201. package/plugins/index.js.map +1 -1
  202. package/{plugins/storage → storage}/FileStorage.d.ts +8 -5
  203. package/storage/FileStorage.js +90 -0
  204. package/storage/FileStorage.js.map +1 -0
  205. package/types/file.d.ts +48 -0
  206. package/types/file.js +7 -0
  207. package/types/file.js.map +1 -0
  208. package/types/file.lifecycle.d.ts +44 -0
  209. package/types/file.lifecycle.js +7 -0
  210. package/types/file.lifecycle.js.map +1 -0
  211. package/types.d.ts +82 -73
  212. package/types.js +25 -1
  213. package/types.js.map +1 -1
  214. package/handlers/download/index.d.ts +0 -3
  215. package/handlers/download/index.js +0 -132
  216. package/handlers/download/index.js.map +0 -1
  217. package/handlers/transform/index.d.ts +0 -2
  218. package/handlers/transform/index.js +0 -91
  219. package/handlers/transform/index.js.map +0 -1
  220. package/handlers/transform/loaders/imageLoader.d.ts +0 -30
  221. package/handlers/transform/loaders/imageLoader.js +0 -105
  222. package/handlers/transform/loaders/imageLoader.js.map +0 -1
  223. package/handlers/transform/loaders/index.d.ts +0 -8
  224. package/handlers/transform/loaders/index.js +0 -13
  225. package/handlers/transform/loaders/index.js.map +0 -1
  226. package/handlers/transform/loaders/sanitizeImageTransformations.d.ts +0 -11
  227. package/handlers/transform/loaders/sanitizeImageTransformations.js +0 -58
  228. package/handlers/transform/loaders/sanitizeImageTransformations.js.map +0 -1
  229. package/handlers/transform/managers/imageManager.js +0 -63
  230. package/handlers/transform/managers/imageManager.js.map +0 -1
  231. package/handlers/transform/managers/index.d.ts +0 -5
  232. package/handlers/transform/managers/index.js +0 -13
  233. package/handlers/transform/managers/index.js.map +0 -1
  234. package/handlers/transform/optimizeImage.d.ts +0 -3
  235. package/handlers/transform/optimizeImage.js +0 -48
  236. package/handlers/transform/optimizeImage.js.map +0 -1
  237. package/handlers/transform/transformImage.d.ts +0 -10
  238. package/handlers/transform/transformImage.js +0 -30
  239. package/handlers/transform/transformImage.js.map +0 -1
  240. package/handlers/transform/utils.js.map +0 -1
  241. package/plugins/crud/files/validation.d.ts +0 -3
  242. package/plugins/crud/files/validation.js +0 -41
  243. package/plugins/crud/files/validation.js.map +0 -1
  244. package/plugins/crud/files.crud.d.ts +0 -4
  245. package/plugins/crud/files.crud.js +0 -431
  246. package/plugins/crud/files.crud.js.map +0 -1
  247. package/plugins/crud/settings.crud.d.ts +0 -5
  248. package/plugins/crud/settings.crud.js.map +0 -1
  249. package/plugins/crud/system.crud.d.ts +0 -4
  250. package/plugins/crud/system.crud.js +0 -153
  251. package/plugins/crud/system.crud.js.map +0 -1
  252. package/plugins/crud/utils/checkBasePermissions.d.ts +0 -5
  253. package/plugins/crud/utils/checkBasePermissions.js +0 -33
  254. package/plugins/crud/utils/checkBasePermissions.js.map +0 -1
  255. package/plugins/crud/utils/createFileModel.d.ts +0 -5
  256. package/plugins/crud/utils/createFileModel.js +0 -77
  257. package/plugins/crud/utils/createFileModel.js.map +0 -1
  258. package/plugins/crud/utils/lifecycleEvents.d.ts +0 -6
  259. package/plugins/crud/utils/lifecycleEvents.js +0 -38
  260. package/plugins/crud/utils/lifecycleEvents.js.map +0 -1
  261. package/plugins/definitions/FilePhysicalStoragePlugin.js.map +0 -1
  262. package/plugins/definitions/FilePlugin.d.ts +0 -136
  263. package/plugins/definitions/FilePlugin.js +0 -70
  264. package/plugins/definitions/FilePlugin.js.map +0 -1
  265. package/plugins/definitions/FileStorageTransformPlugin.js.map +0 -1
  266. package/plugins/definitions/FilesStorageOperationsProviderPlugin.d.ts +0 -9
  267. package/plugins/definitions/FilesStorageOperationsProviderPlugin.js +0 -17
  268. package/plugins/definitions/FilesStorageOperationsProviderPlugin.js.map +0 -1
  269. package/plugins/definitions/InstallationPlugin.d.ts +0 -19
  270. package/plugins/definitions/InstallationPlugin.js +0 -42
  271. package/plugins/definitions/InstallationPlugin.js.map +0 -1
  272. package/plugins/definitions/SettingsStorageOperationsProviderPlugin.d.ts +0 -9
  273. package/plugins/definitions/SettingsStorageOperationsProviderPlugin.js +0 -17
  274. package/plugins/definitions/SettingsStorageOperationsProviderPlugin.js.map +0 -1
  275. package/plugins/definitions/SystemStorageOperationsProviderPlugin.d.ts +0 -9
  276. package/plugins/definitions/SystemStorageOperationsProviderPlugin.js +0 -17
  277. package/plugins/definitions/SystemStorageOperationsProviderPlugin.js.map +0 -1
  278. package/plugins/graphql.d.ts +0 -4
  279. package/plugins/graphql.js +0 -290
  280. package/plugins/graphql.js.map +0 -1
  281. package/plugins/storage/FileStorage.js +0 -103
  282. package/plugins/storage/FileStorage.js.map +0 -1
  283. package/plugins/storage/index.d.ts +0 -4
  284. package/plugins/storage/index.js +0 -26
  285. package/plugins/storage/index.js.map +0 -1
  286. package/utils.d.ts +0 -4
  287. package/utils.js +0 -16
  288. package/utils.js.map +0 -1
  289. /package/handlers/{transform/utils.d.ts → manage/legacyUtils.d.ts} +0 -0
@@ -0,0 +1,13 @@
1
+ import { FileManagerContext } from "./types";
2
+ import { FileManagerConfig } from "./createFileManager";
3
+ export declare class FileManagerContextSetup {
4
+ private readonly context;
5
+ constructor(context: FileManagerContext);
6
+ setupContext(storageOperations: FileManagerConfig["storageOperations"]): Promise<import("./types").FileManagerContextObject>;
7
+ private getLocaleCode;
8
+ private getIdentity;
9
+ private getTenantId;
10
+ private getPermissions;
11
+ private setupCmsStorageOperations;
12
+ private getModel;
13
+ }
@@ -0,0 +1,115 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.FileManagerContextSetup = void 0;
8
+ var _createFileManager = require("./createFileManager");
9
+ var _FileStorage = require("./storage/FileStorage");
10
+ var _error = _interopRequireDefault(require("@webiny/error"));
11
+ var _isInstallationPending = require("./cmsFileStorage/isInstallationPending");
12
+ var _createFileManagerPlugins = require("./cmsFileStorage/createFileManagerPlugins");
13
+ var _file = require("./cmsFileStorage/file.model");
14
+ var _CmsFilesStorage = require("./cmsFileStorage/CmsFilesStorage");
15
+ var _CmsModelModifier = require("./modelModifier/CmsModelModifier");
16
+ var _apiHeadlessCms = require("@webiny/api-headless-cms");
17
+ var _FilesPermissions = require("./createFileManager/permissions/FilesPermissions");
18
+ class FileManagerContextSetup {
19
+ constructor(context) {
20
+ this.context = context;
21
+ }
22
+ async setupContext(storageOperations) {
23
+ if (storageOperations.beforeInit) {
24
+ await storageOperations.beforeInit(this.context);
25
+ }
26
+ const fileStorageOps = await this.context.security.withoutAuthorization(() => {
27
+ return this.setupCmsStorageOperations(storageOperations.aliases);
28
+ });
29
+ if (fileStorageOps) {
30
+ storageOperations.files = fileStorageOps;
31
+ }
32
+ const filesPermissions = new _FilesPermissions.FilesPermissions({
33
+ getIdentity: this.context.security.getIdentity,
34
+ getPermissions: () => this.context.security.getPermissions("fm.file"),
35
+ fullAccessPermissionName: "fm.*"
36
+ });
37
+ return (0, _createFileManager.createFileManager)({
38
+ storageOperations,
39
+ filesPermissions,
40
+ getTenantId: this.getTenantId.bind(this),
41
+ getLocaleCode: this.getLocaleCode.bind(this),
42
+ getIdentity: this.getIdentity.bind(this),
43
+ getPermissions: this.getPermissions.bind(this),
44
+ storage: new _FileStorage.FileStorage({
45
+ context: this.context
46
+ }),
47
+ // TODO: maybe this is no longer necessary, as this wil be managed by CMS?
48
+ WEBINY_VERSION: this.context.WEBINY_VERSION
49
+ });
50
+ }
51
+ getLocaleCode() {
52
+ const locale = this.context.i18n.getContentLocale();
53
+ if (!locale) {
54
+ throw new _error.default("Missing locale on context.i18n locale in File Manager API.", "LOCALE_ERROR");
55
+ }
56
+ return locale.code;
57
+ }
58
+ getIdentity() {
59
+ return this.context.security.getIdentity();
60
+ }
61
+ getTenantId() {
62
+ return this.context.tenancy.getCurrentTenant().id;
63
+ }
64
+ async getPermissions(name) {
65
+ return this.context.security.getPermissions(name);
66
+ }
67
+ async setupCmsStorageOperations(aliases) {
68
+ if ((0, _isInstallationPending.isInstallationPending)({
69
+ tenancy: this.context.tenancy,
70
+ i18n: this.context.i18n
71
+ })) {
72
+ console.log("Installation pending!");
73
+ return;
74
+ }
75
+ const withPrivateFiles = this.context.wcp.canUsePrivateFiles();
76
+
77
+ // This registers code plugins (model group, models)
78
+ const {
79
+ fileModelDefinition
80
+ } = (0, _createFileManagerPlugins.createFileModel)({
81
+ withPrivateFiles
82
+ });
83
+ const modelModifiers = this.context.plugins.byType(_CmsModelModifier.CmsModelModifierPlugin.type);
84
+ for (const modifier of modelModifiers) {
85
+ await modifier.modifyModel(fileModelDefinition);
86
+ }
87
+
88
+ // Finally, register all plugins
89
+ this.context.plugins.register([new _apiHeadlessCms.CmsModelPlugin(fileModelDefinition)]);
90
+
91
+ // Now load the file model registered in the previous step
92
+ const fileModel = await this.getModel(_file.FILE_MODEL_ID);
93
+
94
+ // Overwrite the original `files` storage ops
95
+ return await _CmsFilesStorage.CmsFilesStorage.create({
96
+ fileModel,
97
+ cms: this.context.cms,
98
+ security: this.context.security,
99
+ aliases
100
+ });
101
+ }
102
+ async getModel(modelId) {
103
+ const model = await this.context.cms.getModel(modelId);
104
+ if (!model) {
105
+ throw new _error.default({
106
+ code: "MODEL_NOT_FOUND",
107
+ message: `Content model "${modelId}" was not found!`
108
+ });
109
+ }
110
+ return model;
111
+ }
112
+ }
113
+ exports.FileManagerContextSetup = FileManagerContextSetup;
114
+
115
+ //# sourceMappingURL=FileManagerContextSetup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_createFileManager","require","_FileStorage","_error","_interopRequireDefault","_isInstallationPending","_createFileManagerPlugins","_file","_CmsFilesStorage","_CmsModelModifier","_apiHeadlessCms","_FilesPermissions","FileManagerContextSetup","constructor","context","setupContext","storageOperations","beforeInit","fileStorageOps","security","withoutAuthorization","setupCmsStorageOperations","aliases","files","filesPermissions","FilesPermissions","getIdentity","getPermissions","fullAccessPermissionName","createFileManager","getTenantId","bind","getLocaleCode","storage","FileStorage","WEBINY_VERSION","locale","i18n","getContentLocale","WebinyError","code","tenancy","getCurrentTenant","id","name","isInstallationPending","console","log","withPrivateFiles","wcp","canUsePrivateFiles","fileModelDefinition","createFileModel","modelModifiers","plugins","byType","CmsModelModifierPlugin","type","modifier","modifyModel","register","CmsModelPlugin","fileModel","getModel","FILE_MODEL_ID","CmsFilesStorage","create","cms","modelId","model","message","exports"],"sources":["FileManagerContextSetup.ts"],"sourcesContent":["import { FileManagerAliasesStorageOperations, FileManagerContext } from \"~/types\";\nimport { createFileManager, FileManagerConfig } from \"~/createFileManager\";\nimport { FileStorage } from \"~/storage/FileStorage\";\nimport WebinyError from \"@webiny/error\";\nimport { SecurityPermission } from \"@webiny/api-security/types\";\nimport { isInstallationPending } from \"~/cmsFileStorage/isInstallationPending\";\nimport { createFileModel } from \"~/cmsFileStorage/createFileManagerPlugins\";\nimport { FILE_MODEL_ID } from \"~/cmsFileStorage/file.model\";\nimport { CmsFilesStorage } from \"~/cmsFileStorage/CmsFilesStorage\";\nimport { CmsModelModifierPlugin } from \"~/modelModifier/CmsModelModifier\";\nimport { CmsModelPlugin } from \"@webiny/api-headless-cms\";\nimport { FilesPermissions } from \"~/createFileManager/permissions/FilesPermissions\";\n\nexport class FileManagerContextSetup {\n private readonly context: FileManagerContext;\n\n constructor(context: FileManagerContext) {\n this.context = context;\n }\n\n async setupContext(storageOperations: FileManagerConfig[\"storageOperations\"]) {\n if (storageOperations.beforeInit) {\n await storageOperations.beforeInit(this.context);\n }\n\n const fileStorageOps = await this.context.security.withoutAuthorization(() => {\n return this.setupCmsStorageOperations(storageOperations.aliases);\n });\n\n if (fileStorageOps) {\n storageOperations.files = fileStorageOps;\n }\n\n const filesPermissions = new FilesPermissions({\n getIdentity: this.context.security.getIdentity,\n getPermissions: () => this.context.security.getPermissions(\"fm.file\"),\n fullAccessPermissionName: \"fm.*\"\n });\n\n return createFileManager({\n storageOperations,\n filesPermissions,\n getTenantId: this.getTenantId.bind(this),\n getLocaleCode: this.getLocaleCode.bind(this),\n getIdentity: this.getIdentity.bind(this),\n getPermissions: this.getPermissions.bind(this),\n storage: new FileStorage({\n context: this.context\n }),\n // TODO: maybe this is no longer necessary, as this wil be managed by CMS?\n WEBINY_VERSION: this.context.WEBINY_VERSION\n });\n }\n\n private getLocaleCode() {\n const locale = this.context.i18n.getContentLocale();\n if (!locale) {\n throw new WebinyError(\n \"Missing locale on context.i18n locale in File Manager API.\",\n \"LOCALE_ERROR\"\n );\n }\n return locale.code;\n }\n\n private getIdentity() {\n return this.context.security.getIdentity();\n }\n\n private getTenantId() {\n return this.context.tenancy.getCurrentTenant().id;\n }\n\n private async getPermissions<T extends SecurityPermission = SecurityPermission>(\n name: string\n ): Promise<T[]> {\n return this.context.security.getPermissions(name);\n }\n\n private async setupCmsStorageOperations(aliases: FileManagerAliasesStorageOperations) {\n if (isInstallationPending({ tenancy: this.context.tenancy, i18n: this.context.i18n })) {\n console.log(\"Installation pending!\");\n return;\n }\n\n const withPrivateFiles = this.context.wcp.canUsePrivateFiles();\n\n // This registers code plugins (model group, models)\n const { fileModelDefinition } = createFileModel({ withPrivateFiles });\n\n const modelModifiers = this.context.plugins.byType<CmsModelModifierPlugin>(\n CmsModelModifierPlugin.type\n );\n\n for (const modifier of modelModifiers) {\n await modifier.modifyModel(fileModelDefinition);\n }\n\n // Finally, register all plugins\n this.context.plugins.register([new CmsModelPlugin(fileModelDefinition)]);\n\n // Now load the file model registered in the previous step\n const fileModel = await this.getModel(FILE_MODEL_ID);\n\n // Overwrite the original `files` storage ops\n return await CmsFilesStorage.create({\n fileModel,\n cms: this.context.cms,\n security: this.context.security,\n aliases\n });\n }\n\n private async getModel(modelId: string) {\n const model = await this.context.cms.getModel(modelId);\n if (!model) {\n throw new WebinyError({\n code: \"MODEL_NOT_FOUND\",\n message: `Content model \"${modelId}\" was not found!`\n });\n }\n\n return model;\n }\n}\n"],"mappings":";;;;;;;AACA,IAAAA,kBAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAC,sBAAA,CAAAH,OAAA;AAEA,IAAAI,sBAAA,GAAAJ,OAAA;AACA,IAAAK,yBAAA,GAAAL,OAAA;AACA,IAAAM,KAAA,GAAAN,OAAA;AACA,IAAAO,gBAAA,GAAAP,OAAA;AACA,IAAAQ,iBAAA,GAAAR,OAAA;AACA,IAAAS,eAAA,GAAAT,OAAA;AACA,IAAAU,iBAAA,GAAAV,OAAA;AAEO,MAAMW,uBAAuB,CAAC;EAGjCC,WAAWA,CAACC,OAA2B,EAAE;IACrC,IAAI,CAACA,OAAO,GAAGA,OAAO;EAC1B;EAEA,MAAMC,YAAYA,CAACC,iBAAyD,EAAE;IAC1E,IAAIA,iBAAiB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SAAS,GAAG,MAAM,IAAI,CAACC,QAAQ,CAACC,mBAAa,CAAC;;IAEpD;IACA,OAAO,MAAMC,gCAAe,CAACC,MAAM,CAAC;MAChCJ,SAAS;MACTK,GAAG,EAAE,IAAI,CAACrD,OAAO,CAACqD,GAAG;MACrBhD,QAAQ,EAAE,IAAI,CAACL,OAAO,CAACK,QAAQ;MAC/BG;IACJ,CAAC,CAAC;EACN;EAEA,MAAcyC,QAAQA,CAACK,OAAe,EAAE;IACpC,MAAMC,KAAK,GAAG,MAAM,IAAI,CAACvD,OAAO,CAACqD,GAAG,CAACJ,QAAQ,CAACK,OAAO,CAAC;IACtD,IAAI,CAACC,KAAK,EAAE;MACR,MAAM,IAAI9B,cAAW,CAAC;QAClBC,IAAI,EAAE,iBAAiB;QACvB8B,OAAO,EAAG,kBAAiBF,OAAQ;MACvC,CAAC,CAAC;IACN;IAEA,OAAOC,KAAK;EAChB;AACJ;AAACE,OAAA,CAAA3D,uBAAA,GAAAA,uBAAA"}
@@ -0,0 +1,27 @@
1
+ import { CmsModel, HeadlessCms } from "@webiny/api-headless-cms/types";
2
+ import { Security } from "@webiny/api-security/types";
3
+ import { File, FileManagerAliasesStorageOperations, FileManagerFilesStorageOperations, FileManagerFilesStorageOperationsCreateBatchParams, FileManagerFilesStorageOperationsCreateParams, FileManagerFilesStorageOperationsDeleteParams, FileManagerFilesStorageOperationsGetParams, FileManagerFilesStorageOperationsListParams, FileManagerFilesStorageOperationsListResponse, FileManagerFilesStorageOperationsTagsParams, FileManagerFilesStorageOperationsTagsResponse, FileManagerFilesStorageOperationsUpdateParams } from "../types";
4
+ export declare class CmsFilesStorage implements FileManagerFilesStorageOperations {
5
+ private readonly cms;
6
+ private readonly security;
7
+ private readonly model;
8
+ private readonly aliases;
9
+ private readonly filesWhereProcessor;
10
+ private readonly tagsWhereProcessor;
11
+ static create(params: {
12
+ fileModel: CmsModel;
13
+ cms: HeadlessCms;
14
+ security: Security;
15
+ aliases: FileManagerAliasesStorageOperations;
16
+ }): Promise<CmsFilesStorage>;
17
+ private constructor();
18
+ private modelWithContext;
19
+ create({ file }: FileManagerFilesStorageOperationsCreateParams): Promise<File>;
20
+ createBatch({ files }: FileManagerFilesStorageOperationsCreateBatchParams): Promise<File[]>;
21
+ delete({ file }: FileManagerFilesStorageOperationsDeleteParams): Promise<void>;
22
+ get({ where }: FileManagerFilesStorageOperationsGetParams): Promise<File | null>;
23
+ list(params: FileManagerFilesStorageOperationsListParams): Promise<FileManagerFilesStorageOperationsListResponse>;
24
+ tags(params: FileManagerFilesStorageOperationsTagsParams): Promise<FileManagerFilesStorageOperationsTagsResponse[]>;
25
+ update({ file }: FileManagerFilesStorageOperationsUpdateParams): Promise<File>;
26
+ private getFileFieldValues;
27
+ }
@@ -0,0 +1,176 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.CmsFilesStorage = void 0;
8
+ var _omit = _interopRequireDefault(require("lodash/omit"));
9
+ var _ListFilesWhereProcessor = require("./ListFilesWhereProcessor");
10
+ var _ListTagsWhereProcessor = require("./ListTagsWhereProcessor");
11
+ var _contants = require("../contants");
12
+ class CmsFilesStorage {
13
+ static async create(params) {
14
+ return new CmsFilesStorage(params.fileModel, params.cms, params.security, params.aliases);
15
+ }
16
+ constructor(fileModel, cms, security, aliases) {
17
+ this.model = fileModel;
18
+ this.aliases = aliases;
19
+ this.cms = cms;
20
+ this.security = security;
21
+ this.filesWhereProcessor = new _ListFilesWhereProcessor.ListFilesWhereProcessor();
22
+ this.tagsWhereProcessor = new _ListTagsWhereProcessor.ListTagsWhereProcessor();
23
+ }
24
+ modelWithContext({
25
+ tenant,
26
+ locale
27
+ }) {
28
+ return {
29
+ ...this.model,
30
+ tenant,
31
+ locale
32
+ };
33
+ }
34
+ async create({
35
+ file
36
+ }) {
37
+ const model = this.modelWithContext(file);
38
+ if (!file.location?.folderId) {
39
+ file.location = {
40
+ ...file.location,
41
+ folderId: _contants.ROOT_FOLDER
42
+ };
43
+ }
44
+ const entry = await this.security.withoutAuthorization(() => {
45
+ return this.cms.createEntry(model, {
46
+ ...file,
47
+ wbyAco_location: file.location
48
+ });
49
+ });
50
+ await this.aliases.storeAliases(file);
51
+ return this.getFileFieldValues(entry);
52
+ }
53
+ async createBatch({
54
+ files
55
+ }) {
56
+ return await Promise.all(files.map(file => {
57
+ return this.create({
58
+ file
59
+ });
60
+ }));
61
+ }
62
+ async delete({
63
+ file
64
+ }) {
65
+ const model = this.modelWithContext(file);
66
+ await this.security.withoutAuthorization(() => {
67
+ return this.cms.deleteEntry(model, file.id);
68
+ });
69
+ await this.aliases.deleteAliases(file);
70
+ }
71
+ async get({
72
+ where
73
+ }) {
74
+ const {
75
+ id,
76
+ tenant,
77
+ locale
78
+ } = where;
79
+ const model = this.modelWithContext({
80
+ tenant,
81
+ locale
82
+ });
83
+ const entry = await this.security.withoutAuthorization(() => {
84
+ return this.cms.getEntry(model, {
85
+ where: {
86
+ entryId: id,
87
+ latest: true
88
+ }
89
+ });
90
+ });
91
+ return entry ? this.getFileFieldValues(entry) : null;
92
+ }
93
+ async list(params) {
94
+ const tenant = params.where.tenant;
95
+ const locale = params.where.locale;
96
+ const model = this.modelWithContext({
97
+ tenant,
98
+ locale
99
+ });
100
+ const [entries, meta] = await this.security.withoutAuthorization(() => {
101
+ const where = this.filesWhereProcessor.process(params.where);
102
+ return this.cms.listLatestEntries(model, {
103
+ after: params.after,
104
+ limit: params.limit,
105
+ sort: params.sort,
106
+ where,
107
+ search: params.search
108
+ });
109
+ });
110
+ return [entries.map(entry => this.getFileFieldValues(entry)), meta];
111
+ }
112
+ async tags(params) {
113
+ const tenant = params.where.tenant;
114
+ const locale = params.where.locale;
115
+ const model = this.modelWithContext({
116
+ tenant,
117
+ locale
118
+ });
119
+ const uniqueValues = await this.security.withoutAuthorization(() => {
120
+ return this.cms.getUniqueFieldValues(model, {
121
+ fieldId: "tags",
122
+ where: {
123
+ ...this.tagsWhereProcessor.process(params.where),
124
+ latest: true
125
+ }
126
+ });
127
+ });
128
+ return uniqueValues.map(uv => ({
129
+ tag: uv.value,
130
+ count: uv.count
131
+ })).sort((a, b) => {
132
+ return a.tag < b.tag ? -1 : 1;
133
+ }).sort((a, b) => {
134
+ return a.count > b.count ? -1 : 1;
135
+ });
136
+ }
137
+ async update({
138
+ file
139
+ }) {
140
+ const model = this.modelWithContext(file);
141
+ return await this.security.withoutAuthorization(async () => {
142
+ const entry = await this.cms.getEntry(model, {
143
+ where: {
144
+ entryId: file.id,
145
+ latest: true
146
+ }
147
+ });
148
+ const values = (0, _omit.default)(file, ["id", "tenant", "locale", "webinyVersion"]);
149
+ const updatedEntry = await this.cms.updateEntry(model, entry.id, {
150
+ ...values,
151
+ wbyAco_location: values.location ?? entry.location
152
+ });
153
+ await this.aliases.storeAliases(file);
154
+ return this.getFileFieldValues(updatedEntry);
155
+ });
156
+ }
157
+ getFileFieldValues(entry) {
158
+ return {
159
+ id: entry.entryId,
160
+ // We're safe to use entry-level meta fields because we don't use revisions with files.
161
+ createdBy: entry.createdBy,
162
+ modifiedBy: entry.modifiedBy || null,
163
+ savedBy: entry.savedBy,
164
+ createdOn: entry.createdOn,
165
+ modifiedOn: entry.modifiedOn || null,
166
+ savedOn: entry.savedOn,
167
+ locale: entry.locale,
168
+ tenant: entry.tenant,
169
+ webinyVersion: entry.webinyVersion,
170
+ ...entry.values
171
+ };
172
+ }
173
+ }
174
+ exports.CmsFilesStorage = CmsFilesStorage;
175
+
176
+ //# sourceMappingURL=CmsFilesStorage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_omit","_interopRequireDefault","require","_ListFilesWhereProcessor","_ListTagsWhereProcessor","_contants","CmsFilesStorage","create","params","fileModel","cms","security","aliases","constructor","model","filesWhereProcessor","ListFilesWhereProcessor","tagsWhereProcessor","ListTagsWhereProcessor","modelWithContext","tenant","locale","file","location","folderId","ROOT_FOLDER","entry","withoutAuthorization","createEntry","wbyAco_location","storeAliases","getFileFieldValues","createBatch","files","Promise","all","map","delete","deleteEntry","id","deleteAliases","get","where","getEntry","entryId","latest","list","entries","meta","process","listLatestEntries","after","limit","sort","search","tags","uniqueValues","getUniqueFieldValues","fieldId","uv","tag","value","count","a","b","update","values","omit","updatedEntry","updateEntry","createdBy","modifiedBy","savedBy","createdOn","modifiedOn","savedOn","webinyVersion","exports"],"sources":["CmsFilesStorage.ts"],"sourcesContent":["import omit from \"lodash/omit\";\nimport { CmsEntry, CmsModel, HeadlessCms } from \"@webiny/api-headless-cms/types\";\nimport { Security } from \"@webiny/api-security/types\";\nimport {\n File,\n FileManagerAliasesStorageOperations,\n FileManagerFilesStorageOperations,\n FileManagerFilesStorageOperationsCreateBatchParams,\n FileManagerFilesStorageOperationsCreateParams,\n FileManagerFilesStorageOperationsDeleteParams,\n FileManagerFilesStorageOperationsGetParams,\n FileManagerFilesStorageOperationsListParams,\n FileManagerFilesStorageOperationsListResponse,\n FileManagerFilesStorageOperationsTagsParams,\n FileManagerFilesStorageOperationsTagsResponse,\n FileManagerFilesStorageOperationsUpdateParams\n} from \"~/types\";\nimport { ListFilesWhereProcessor } from \"~/cmsFileStorage/ListFilesWhereProcessor\";\nimport { ListTagsWhereProcessor } from \"~/cmsFileStorage/ListTagsWhereProcessor\";\nimport { ROOT_FOLDER } from \"~/contants\";\n\ninterface ModelContext {\n tenant: string;\n locale: string;\n}\n\nexport class CmsFilesStorage implements FileManagerFilesStorageOperations {\n private readonly cms: HeadlessCms;\n private readonly security: Security;\n private readonly model: CmsModel;\n private readonly aliases: FileManagerAliasesStorageOperations;\n private readonly filesWhereProcessor: ListFilesWhereProcessor;\n private readonly tagsWhereProcessor: ListTagsWhereProcessor;\n\n static async create(params: {\n fileModel: CmsModel;\n cms: HeadlessCms;\n security: Security;\n aliases: FileManagerAliasesStorageOperations;\n }) {\n return new CmsFilesStorage(params.fileModel, params.cms, params.security, params.aliases);\n }\n\n private constructor(\n fileModel: CmsModel,\n cms: HeadlessCms,\n security: Security,\n aliases: FileManagerAliasesStorageOperations\n ) {\n this.model = fileModel;\n this.aliases = aliases;\n this.cms = cms;\n this.security = security;\n this.filesWhereProcessor = new ListFilesWhereProcessor();\n this.tagsWhereProcessor = new ListTagsWhereProcessor();\n }\n\n private modelWithContext({ tenant, locale }: ModelContext): CmsModel {\n return { ...this.model, tenant, locale };\n }\n\n async create({ file }: FileManagerFilesStorageOperationsCreateParams): Promise<File> {\n const model = this.modelWithContext(file);\n\n if (!file.location?.folderId) {\n file.location = {\n ...file.location,\n folderId: ROOT_FOLDER\n };\n }\n\n const entry = await this.security.withoutAuthorization(() => {\n return this.cms.createEntry(model, {\n ...file,\n wbyAco_location: file.location\n });\n });\n\n await this.aliases.storeAliases(file);\n\n return this.getFileFieldValues(entry);\n }\n\n async createBatch({\n files\n }: FileManagerFilesStorageOperationsCreateBatchParams): Promise<File[]> {\n return await Promise.all(\n files.map(file => {\n return this.create({ file });\n })\n );\n }\n\n async delete({ file }: FileManagerFilesStorageOperationsDeleteParams): Promise<void> {\n const model = this.modelWithContext(file);\n await this.security.withoutAuthorization(() => {\n return this.cms.deleteEntry(model, file.id);\n });\n\n await this.aliases.deleteAliases(file);\n }\n\n async get({ where }: FileManagerFilesStorageOperationsGetParams): Promise<File | null> {\n const { id, tenant, locale } = where;\n const model = this.modelWithContext({ tenant, locale });\n const entry = await this.security.withoutAuthorization(() => {\n return this.cms.getEntry(model, { where: { entryId: id, latest: true } });\n });\n return entry ? this.getFileFieldValues(entry) : null;\n }\n\n async list(\n params: FileManagerFilesStorageOperationsListParams\n ): Promise<FileManagerFilesStorageOperationsListResponse> {\n const tenant = params.where.tenant;\n const locale = params.where.locale;\n\n const model = this.modelWithContext({ tenant, locale });\n const [entries, meta] = await this.security.withoutAuthorization(() => {\n const where = this.filesWhereProcessor.process(params.where);\n return this.cms.listLatestEntries(model, {\n after: params.after,\n limit: params.limit,\n sort: params.sort,\n where,\n search: params.search\n });\n });\n\n return [entries.map(entry => this.getFileFieldValues(entry)), meta];\n }\n\n async tags(\n params: FileManagerFilesStorageOperationsTagsParams\n ): Promise<FileManagerFilesStorageOperationsTagsResponse[]> {\n const tenant = params.where.tenant;\n const locale = params.where.locale;\n const model = this.modelWithContext({ tenant, locale });\n const uniqueValues = await this.security.withoutAuthorization(() => {\n return this.cms.getUniqueFieldValues(model, {\n fieldId: \"tags\",\n where: {\n ...this.tagsWhereProcessor.process(params.where),\n latest: true\n }\n });\n });\n\n return uniqueValues\n .map(uv => ({\n tag: uv.value,\n count: uv.count\n }))\n .sort((a, b) => {\n return a.tag < b.tag ? -1 : 1;\n })\n .sort((a, b) => {\n return a.count > b.count ? -1 : 1;\n });\n }\n\n async update({ file }: FileManagerFilesStorageOperationsUpdateParams): Promise<File> {\n const model = this.modelWithContext(file);\n\n return await this.security.withoutAuthorization(async () => {\n const entry = await this.cms.getEntry(model, {\n where: { entryId: file.id, latest: true }\n });\n\n const values = omit(file, [\"id\", \"tenant\", \"locale\", \"webinyVersion\"]);\n\n const updatedEntry = await this.cms.updateEntry(model, entry.id, {\n ...values,\n wbyAco_location: values.location ?? entry.location\n });\n\n await this.aliases.storeAliases(file);\n\n return this.getFileFieldValues(updatedEntry);\n });\n }\n\n private getFileFieldValues(entry: CmsEntry) {\n return {\n id: entry.entryId,\n\n // We're safe to use entry-level meta fields because we don't use revisions with files.\n createdBy: entry.createdBy,\n modifiedBy: entry.modifiedBy || null,\n savedBy: entry.savedBy,\n createdOn: entry.createdOn,\n modifiedOn: entry.modifiedOn || null,\n savedOn: entry.savedOn,\n\n locale: entry.locale,\n tenant: entry.tenant,\n webinyVersion: entry.webinyVersion,\n ...entry.values\n } as File;\n }\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAiBA,IAAAC,wBAAA,GAAAD,OAAA;AACA,IAAAE,uBAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AAOO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CAACvD,KAAK,EAAEY,KAAK,CAACa,EAAE,EAAE;QAC7D,GAAG2B,MAAM;QACTrC,eAAe,EAAEqC,MAAM,CAAC3C,QAAQ,IAAIG,KAAK,CAACH;MAC9C,CAAC,CAAC;MAEF,MAAM,IAAI,CAACX,OAAO,CAACkB,YAAY,CAACR,IAAI,CAAC;MAErC,OAAO,IAAI,CAACS,kBAAkB,CAACqC,YAAY,CAAC;IAChD,CAAC,CAAC;EACN;EAEQrC,kBAAkBA,CAACL,KAAe,EAAE;IACxC,OAAO;MACHa,EAAE,EAAEb,KAAK,CAACkB,OAAO;MAEjB;MACA0B,SAAS,EAAE5C,KAAK,CAAC4C,SAAS;MAC1BC,UAAU,EAAE7C,KAAK,CAAC6C,UAAU,IAAI,IAAI;MACpCC,OAAO,EAAE9C,KAAK,CAAC8C,OAAO;MACtBC,SAAS,EAAE/C,KAAK,CAAC+C,SAAS;MAC1BC,UAAU,EAAEhD,KAAK,CAACgD,UAAU,IAAI,IAAI;MACpCC,OAAO,EAAEjD,KAAK,CAACiD,OAAO;MAEtBtD,MAAM,EAAEK,KAAK,CAACL,MAAM;MACpBD,MAAM,EAAEM,KAAK,CAACN,MAAM;MACpBwD,aAAa,EAAElD,KAAK,CAACkD,aAAa;MAClC,GAAGlD,KAAK,CAACwC;IACb,CAAC;EACL;AACJ;AAACW,OAAA,CAAAvE,eAAA,GAAAA,eAAA"}
@@ -0,0 +1,7 @@
1
+ import { CmsEntryListWhere } from "@webiny/api-headless-cms/types";
2
+ import { FileManagerFilesStorageOperationsListParamsWhere } from "../types";
3
+ export declare class ListFilesWhereProcessor {
4
+ private readonly skipKeys;
5
+ private readonly keyMap;
6
+ process(input: FileManagerFilesStorageOperationsListParamsWhere): CmsEntryListWhere;
7
+ }
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.ListFilesWhereProcessor = void 0;
7
+ class ListFilesWhereProcessor {
8
+ skipKeys = ["tenant", "locale"];
9
+ keyMap = {
10
+ id: "entryId",
11
+ id_in: "entryId_in"
12
+ };
13
+ process(input) {
14
+ const where = {
15
+ meta: {
16
+ private_not: true
17
+ }
18
+ };
19
+ Object.keys(input).filter(key => !this.skipKeys.includes(key)).forEach(key => {
20
+ const remappedKey = this.keyMap[key];
21
+ const value = input[key];
22
+ if (remappedKey && value !== undefined) {
23
+ where[remappedKey] = value;
24
+ } else if (value !== undefined) {
25
+ where[key] = value;
26
+ }
27
+ });
28
+ return where;
29
+ }
30
+ }
31
+ exports.ListFilesWhereProcessor = ListFilesWhereProcessor;
32
+
33
+ //# sourceMappingURL=ListFilesWhereProcessor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["ListFilesWhereProcessor","skipKeys","keyMap","id","id_in","process","input","where","meta","private_not","Object","keys","filter","key","includes","forEach","remappedKey","value","undefined","exports"],"sources":["ListFilesWhereProcessor.ts"],"sourcesContent":["import { CmsEntryListWhere } from \"@webiny/api-headless-cms/types\";\nimport { FileManagerFilesStorageOperationsListParamsWhere } from \"~/types\";\n\ntype StandardFileKey = keyof FileManagerFilesStorageOperationsListParamsWhere;\ntype CmsEntryListWhereKey = keyof CmsEntryListWhere;\n\nexport class ListFilesWhereProcessor {\n private readonly skipKeys = [\"tenant\", \"locale\"];\n private readonly keyMap: Partial<Record<StandardFileKey, CmsEntryListWhereKey>> = {\n id: \"entryId\",\n id_in: \"entryId_in\"\n };\n\n process(input: FileManagerFilesStorageOperationsListParamsWhere): CmsEntryListWhere {\n const where: CmsEntryListWhere = { meta: { private_not: true } };\n\n Object.keys(input)\n .filter(key => !this.skipKeys.includes(key))\n .forEach(key => {\n const remappedKey = this.keyMap[key];\n const value = input[key];\n\n if (remappedKey && value !== undefined) {\n where[remappedKey] = value;\n } else if (value !== undefined) {\n where[key] = value;\n }\n });\n\n return where;\n }\n}\n"],"mappings":";;;;;;AAMO,MAAMA,uBAAuB,CAAC;EAChBC,QAAQ,GAAG,CAAC,QAAQ,EAAE,QAAQ,CAAC;EAC/BC,MAAM,GAA2D;IAC9EC,EAAE,EAAE,SAAS;IACbC,KAAK,EAAE;EACX,CAAC;EAEDC,OAAOA,CAACC,KAAuD,EAAqB;IAChF,MAAMC,KAAwB,GAAG;MAAEC,IAAI,EAAE;QAAEC,WAAW,EAAE;MAAK;IAAE,CAAC;IAEhEC,MAAM,CAACC,IAAI,CAACL,KAAK,CAAC,CACbM,MAAM,CAACC,GAAG,IAAI,CAAC,IAAI,CAACZ,QAAQ,CAACa,QAAQ,CAACD,GAAG,CAAC,CAAC,CAC3CE,OAAO,CAACF,GAAG,IAAI;MACZ,MAAMG,WAAW,GAAG,IAAI,CAACd,MAAM,CAACW,GAAG,CAAC;MACpC,MAAMI,KAAK,GAAGX,KAAK,CAACO,GAAG,CAAC;MAExB,IAAIG,WAAW,IAAIC,KAAK,KAAKC,SAAS,EAAE;QACpCX,KAAK,CAACS,WAAW,CAAC,GAAGC,KAAK;MAC9B,CAAC,MAAM,IAAIA,KAAK,KAAKC,SAAS,EAAE;QAC5BX,KAAK,CAACM,GAAG,CAAC,GAAGI,KAAK;MACtB;IACJ,CAAC,CAAC;IAEN,OAAOV,KAAK;EAChB;AACJ;AAACY,OAAA,CAAAnB,uBAAA,GAAAA,uBAAA"}
@@ -0,0 +1,7 @@
1
+ import { CmsEntryListWhere } from "@webiny/api-headless-cms/types";
2
+ import { FileManagerFilesStorageOperationsListParamsWhere } from "../types";
3
+ export declare class ListTagsWhereProcessor {
4
+ private readonly skipKeys;
5
+ private readonly keyMap;
6
+ process(input: FileManagerFilesStorageOperationsListParamsWhere): CmsEntryListWhere;
7
+ }
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.ListTagsWhereProcessor = void 0;
7
+ class ListTagsWhereProcessor {
8
+ skipKeys = ["tenant", "locale"];
9
+ keyMap = {
10
+ tag_startsWith: "tags_startsWith",
11
+ tag_not_startsWith: "tags_not_startsWith"
12
+ };
13
+ process(input) {
14
+ const where = {
15
+ meta: {
16
+ private_not: true
17
+ }
18
+ };
19
+ Object.keys(input).filter(key => !this.skipKeys.includes(key)).forEach(key => {
20
+ const remappedKey = this.keyMap[key];
21
+ const value = input[key];
22
+ if (remappedKey && value !== undefined) {
23
+ where[remappedKey] = value;
24
+ } else if (value !== undefined) {
25
+ where[key] = value;
26
+ }
27
+ });
28
+ return where;
29
+ }
30
+ }
31
+ exports.ListTagsWhereProcessor = ListTagsWhereProcessor;
32
+
33
+ //# sourceMappingURL=ListTagsWhereProcessor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["ListTagsWhereProcessor","skipKeys","keyMap","tag_startsWith","tag_not_startsWith","process","input","where","meta","private_not","Object","keys","filter","key","includes","forEach","remappedKey","value","undefined","exports"],"sources":["ListTagsWhereProcessor.ts"],"sourcesContent":["import { CmsEntryListWhere } from \"@webiny/api-headless-cms/types\";\nimport { FileManagerFilesStorageOperationsListParamsWhere } from \"~/types\";\n\ntype StandardFileKey = keyof FileManagerFilesStorageOperationsListParamsWhere;\ntype CmsEntryListWhereKey = keyof CmsEntryListWhere;\n\nexport class ListTagsWhereProcessor {\n private readonly skipKeys = [\"tenant\", \"locale\"];\n private readonly keyMap: Partial<Record<StandardFileKey, CmsEntryListWhereKey>> = {\n tag_startsWith: \"tags_startsWith\",\n tag_not_startsWith: \"tags_not_startsWith\"\n };\n\n process(input: FileManagerFilesStorageOperationsListParamsWhere): CmsEntryListWhere {\n const where: CmsEntryListWhere = { meta: { private_not: true } };\n\n Object.keys(input)\n .filter(key => !this.skipKeys.includes(key))\n .forEach(key => {\n const remappedKey = this.keyMap[key];\n const value = input[key];\n\n if (remappedKey && value !== undefined) {\n where[remappedKey] = value;\n } else if (value !== undefined) {\n where[key] = value;\n }\n });\n\n return where;\n }\n}\n"],"mappings":";;;;;;AAMO,MAAMA,sBAAsB,CAAC;EACfC,QAAQ,GAAG,CAAC,QAAQ,EAAE,QAAQ,CAAC;EAC/BC,MAAM,GAA2D;IAC9EC,cAAc,EAAE,iBAAiB;IACjCC,kBAAkB,EAAE;EACxB,CAAC;EAEDC,OAAOA,CAACC,KAAuD,EAAqB;IAChF,MAAMC,KAAwB,GAAG;MAAEC,IAAI,EAAE;QAAEC,WAAW,EAAE;MAAK;IAAE,CAAC;IAEhEC,MAAM,CAACC,IAAI,CAACL,KAAK,CAAC,CACbM,MAAM,CAACC,GAAG,IAAI,CAAC,IAAI,CAACZ,QAAQ,CAACa,QAAQ,CAACD,GAAG,CAAC,CAAC,CAC3CE,OAAO,CAACF,GAAG,IAAI;MACZ,MAAMG,WAAW,GAAG,IAAI,CAACd,MAAM,CAACW,GAAG,CAAC;MACpC,MAAMI,KAAK,GAAGX,KAAK,CAACO,GAAG,CAAC;MAExB,IAAIG,WAAW,IAAIC,KAAK,KAAKC,SAAS,EAAE;QACpCX,KAAK,CAACS,WAAW,CAAC,GAAGC,KAAK;MAC9B,CAAC,MAAM,IAAIA,KAAK,KAAKC,SAAS,EAAE;QAC5BX,KAAK,CAACM,GAAG,CAAC,GAAGI,KAAK;MACtB;IACJ,CAAC,CAAC;IAEN,OAAOV,KAAK;EAChB;AACJ;AAACY,OAAA,CAAAnB,sBAAA,GAAAA,sBAAA"}
@@ -0,0 +1,7 @@
1
+ interface CreateFileManagerPluginsParams {
2
+ withPrivateFiles: boolean;
3
+ }
4
+ export declare const createFileModel: (params: CreateFileManagerPluginsParams) => {
5
+ fileModelDefinition: import("@webiny/api-headless-cms").CmsPrivateModelFull;
6
+ };
7
+ export {};
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createFileModel = void 0;
7
+ var _file = require("./file.model");
8
+ const createFileModel = params => {
9
+ return {
10
+ fileModelDefinition: (0, _file.createFileModelDefinition)({
11
+ withPrivateFiles: params.withPrivateFiles
12
+ })
13
+ };
14
+ };
15
+ exports.createFileModel = createFileModel;
16
+
17
+ //# sourceMappingURL=createFileManagerPlugins.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_file","require","createFileModel","params","fileModelDefinition","createFileModelDefinition","withPrivateFiles","exports"],"sources":["createFileManagerPlugins.ts"],"sourcesContent":["import { createFileModelDefinition } from \"~/cmsFileStorage/file.model\";\n\ninterface CreateFileManagerPluginsParams {\n withPrivateFiles: boolean;\n}\n\nexport const createFileModel = (params: CreateFileManagerPluginsParams) => {\n return {\n fileModelDefinition: createFileModelDefinition({\n withPrivateFiles: params.withPrivateFiles\n })\n };\n};\n"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAMO,MAAMC,eAAe,GAAIC,MAAsC,IAAK;EACvE,OAAO;IACHC,mBAAmB,EAAE,IAAAC,+BAAyB,EAAC;MAC3CC,gBAAgB,EAAEH,MAAM,CAACG;IAC7B,CAAC;EACL,CAAC;AACL,CAAC;AAACC,OAAA,CAAAL,eAAA,GAAAA,eAAA"}
@@ -0,0 +1,5 @@
1
+ import { CmsModelField } from "@webiny/api-headless-cms/types";
2
+ export interface CreateModelFieldParams extends Omit<CmsModelField, "id" | "storageId" | "fieldId"> {
3
+ fieldId?: string;
4
+ }
5
+ export declare const createModelField: (params: CreateModelFieldParams) => CmsModelField;
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.createModelField = void 0;
8
+ var _camelCase = _interopRequireDefault(require("lodash/camelCase"));
9
+ const createModelField = params => {
10
+ const {
11
+ label,
12
+ fieldId: initialFieldId,
13
+ type,
14
+ tags,
15
+ settings = {},
16
+ listValidation = [],
17
+ validation = [],
18
+ multipleValues = false,
19
+ predefinedValues = {
20
+ values: [],
21
+ enabled: false
22
+ }
23
+ } = params;
24
+ const fieldId = initialFieldId ? (0, _camelCase.default)(initialFieldId) : (0, _camelCase.default)(label);
25
+ return {
26
+ id: fieldId,
27
+ storageId: `${type}@${fieldId}`,
28
+ fieldId,
29
+ label,
30
+ type,
31
+ settings,
32
+ tags,
33
+ listValidation,
34
+ validation,
35
+ multipleValues,
36
+ predefinedValues
37
+ };
38
+ };
39
+ exports.createModelField = createModelField;
40
+
41
+ //# sourceMappingURL=createModelField.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_camelCase","_interopRequireDefault","require","createModelField","params","label","fieldId","initialFieldId","type","tags","settings","listValidation","validation","multipleValues","predefinedValues","values","enabled","camelCase","id","storageId","exports"],"sources":["createModelField.ts"],"sourcesContent":["import { CmsModelField } from \"@webiny/api-headless-cms/types\";\nimport camelCase from \"lodash/camelCase\";\n\nexport interface CreateModelFieldParams\n extends Omit<CmsModelField, \"id\" | \"storageId\" | \"fieldId\"> {\n fieldId?: string;\n}\n\nexport const createModelField = (params: CreateModelFieldParams): CmsModelField => {\n const {\n label,\n fieldId: initialFieldId,\n type,\n tags,\n settings = {},\n listValidation = [],\n validation = [],\n multipleValues = false,\n predefinedValues = {\n values: [],\n enabled: false\n }\n } = params;\n\n const fieldId = initialFieldId ? camelCase(initialFieldId) : camelCase(label);\n\n return {\n id: fieldId,\n storageId: `${type}@${fieldId}`,\n fieldId,\n label,\n type,\n settings,\n tags,\n listValidation,\n validation,\n multipleValues,\n predefinedValues\n };\n};\n"],"mappings":";;;;;;;AACA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AAOO,MAAMC,gBAAgB,GAAIC,MAA8B,IAAoB;EAC/E,MAAM;IACFC,KAAK;IACLC,OAAO,EAAEC,cAAc;IACvBC,IAAI;IACJC,IAAI;IACJC,QAAQ,GAAG,CAAC,CAAC;IACbC,cAAc,GAAG,EAAE;IACnBC,UAAU,GAAG,EAAE;IACfC,cAAc,GAAG,KAAK;IACtBC,gBAAgB,GAAG;MACfC,MAAM,EAAE,EAAE;MACVC,OAAO,EAAE;IACb;EACJ,CAAC,GAAGZ,MAAM;EAEV,MAAME,OAAO,GAAGC,cAAc,GAAG,IAAAU,kBAAS,EAACV,cAAc,CAAC,GAAG,IAAAU,kBAAS,EAACZ,KAAK,CAAC;EAE7E,OAAO;IACHa,EAAE,EAAEZ,OAAO;IACXa,SAAS,EAAG,GAAEX,IAAK,IAAGF,OAAQ,EAAC;IAC/BA,OAAO;IACPD,KAAK;IACLG,IAAI;IACJE,QAAQ;IACRD,IAAI;IACJE,cAAc;IACdC,UAAU;IACVC,cAAc;IACdC;EACJ,CAAC;AACL,CAAC;AAACM,OAAA,CAAAjB,gBAAA,GAAAA,gBAAA"}
@@ -0,0 +1,6 @@
1
+ export declare const FILE_MODEL_ID = "fmFile";
2
+ interface CreateFileModelDefinitionParams {
3
+ withPrivateFiles: boolean;
4
+ }
5
+ export declare const createFileModelDefinition: (params: CreateFileModelDefinitionParams) => import("@webiny/api-headless-cms").CmsPrivateModelFull;
6
+ export {};