@webiny/api-file-manager 0.0.0-unstable.99666aeb00 → 0.0.0-unstable.9bd236cf5e

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 (263) hide show
  1. package/FileManagerContextSetup.d.ts +2 -2
  2. package/FileManagerContextSetup.js +16 -14
  3. package/FileManagerContextSetup.js.map +1 -1
  4. package/README.md +1 -1
  5. package/cmsFileStorage/CmsFilesStorage.d.ts +3 -3
  6. package/cmsFileStorage/CmsFilesStorage.js +52 -61
  7. package/cmsFileStorage/CmsFilesStorage.js.map +1 -1
  8. package/cmsFileStorage/ListFilesWhereProcessor.d.ts +2 -2
  9. package/cmsFileStorage/ListFilesWhereProcessor.js +8 -10
  10. package/cmsFileStorage/ListFilesWhereProcessor.js.map +1 -1
  11. package/cmsFileStorage/ListTagsWhereProcessor.d.ts +2 -2
  12. package/cmsFileStorage/ListTagsWhereProcessor.js +8 -10
  13. package/cmsFileStorage/ListTagsWhereProcessor.js.map +1 -1
  14. package/cmsFileStorage/file.model.d.ts +5 -3
  15. package/cmsFileStorage/file.model.js +83 -43
  16. package/cmsFileStorage/file.model.js.map +1 -1
  17. package/contants.js +3 -2
  18. package/contants.js.map +1 -1
  19. package/createFileManager/files.crud.d.ts +3 -3
  20. package/createFileManager/files.crud.js +83 -55
  21. package/createFileManager/files.crud.js.map +1 -1
  22. package/createFileManager/index.d.ts +2 -14
  23. package/createFileManager/index.js +8 -5
  24. package/createFileManager/index.js.map +1 -1
  25. package/createFileManager/permissions/FilesPermissions.d.ts +1 -1
  26. package/createFileManager/permissions/FilesPermissions.js +3 -1
  27. package/createFileManager/permissions/FilesPermissions.js.map +1 -1
  28. package/createFileManager/permissions/SettingsPermissions.d.ts +4 -0
  29. package/createFileManager/permissions/SettingsPermissions.js +11 -0
  30. package/createFileManager/permissions/SettingsPermissions.js.map +1 -0
  31. package/createFileManager/settings.crud.d.ts +3 -3
  32. package/createFileManager/settings.crud.js +74 -48
  33. package/createFileManager/settings.crud.js.map +1 -1
  34. package/createFileManager/system.crud.d.ts +3 -3
  35. package/createFileManager/system.crud.js +6 -4
  36. package/createFileManager/system.crud.js.map +1 -1
  37. package/createFileManager/types.d.ts +16 -0
  38. package/createFileManager/types.js +7 -0
  39. package/createFileManager/types.js.map +1 -0
  40. package/delivery/AssetDelivery/AliasAssetRequestResolver.d.ts +11 -0
  41. package/delivery/AssetDelivery/AliasAssetRequestResolver.js +74 -0
  42. package/delivery/AssetDelivery/AliasAssetRequestResolver.js.map +1 -0
  43. package/delivery/AssetDelivery/Asset.d.ts +32 -0
  44. package/delivery/AssetDelivery/Asset.js +69 -0
  45. package/delivery/AssetDelivery/Asset.js.map +1 -0
  46. package/delivery/AssetDelivery/AssetDeliveryConfig.d.ts +63 -0
  47. package/delivery/AssetDelivery/AssetDeliveryConfig.js +102 -0
  48. package/delivery/AssetDelivery/AssetDeliveryConfig.js.map +1 -0
  49. package/delivery/AssetDelivery/AssetRequest.d.ts +25 -0
  50. package/delivery/AssetDelivery/AssetRequest.js +29 -0
  51. package/delivery/AssetDelivery/AssetRequest.js.map +1 -0
  52. package/delivery/AssetDelivery/FilesAssetRequestResolver.d.ts +6 -0
  53. package/delivery/AssetDelivery/FilesAssetRequestResolver.js +37 -0
  54. package/delivery/AssetDelivery/FilesAssetRequestResolver.js.map +1 -0
  55. package/delivery/AssetDelivery/NullAssetOutputStrategy.d.ts +4 -0
  56. package/delivery/AssetDelivery/NullAssetOutputStrategy.js +15 -0
  57. package/delivery/AssetDelivery/NullAssetOutputStrategy.js.map +1 -0
  58. package/delivery/AssetDelivery/NullAssetReply.d.ts +4 -0
  59. package/delivery/AssetDelivery/NullAssetReply.js +20 -0
  60. package/delivery/AssetDelivery/NullAssetReply.js.map +1 -0
  61. package/delivery/AssetDelivery/NullAssetResolver.d.ts +5 -0
  62. package/delivery/AssetDelivery/NullAssetResolver.js +14 -0
  63. package/delivery/AssetDelivery/NullAssetResolver.js.map +1 -0
  64. package/delivery/AssetDelivery/NullRequestResolver.d.ts +4 -0
  65. package/delivery/AssetDelivery/NullRequestResolver.js +14 -0
  66. package/delivery/AssetDelivery/NullRequestResolver.js.map +1 -0
  67. package/delivery/AssetDelivery/SetCacheControlHeaders.d.ts +8 -0
  68. package/delivery/AssetDelivery/SetCacheControlHeaders.js +25 -0
  69. package/delivery/AssetDelivery/SetCacheControlHeaders.js.map +1 -0
  70. package/delivery/AssetDelivery/SetResponseHeaders.d.ts +18 -0
  71. package/delivery/AssetDelivery/SetResponseHeaders.js +25 -0
  72. package/delivery/AssetDelivery/SetResponseHeaders.js.map +1 -0
  73. package/delivery/AssetDelivery/abstractions/AssetContentsReader.d.ts +6 -0
  74. package/delivery/AssetDelivery/abstractions/AssetContentsReader.js +7 -0
  75. package/delivery/AssetDelivery/abstractions/AssetContentsReader.js.map +1 -0
  76. package/delivery/AssetDelivery/abstractions/AssetOutputStrategy.d.ts +4 -0
  77. package/delivery/AssetDelivery/abstractions/AssetOutputStrategy.js +7 -0
  78. package/delivery/AssetDelivery/abstractions/AssetOutputStrategy.js.map +1 -0
  79. package/delivery/AssetDelivery/abstractions/AssetProcessor.d.ts +4 -0
  80. package/delivery/AssetDelivery/abstractions/AssetProcessor.js +7 -0
  81. package/delivery/AssetDelivery/abstractions/AssetProcessor.js.map +1 -0
  82. package/delivery/AssetDelivery/abstractions/AssetReply.d.ts +25 -0
  83. package/delivery/AssetDelivery/abstractions/AssetReply.js +38 -0
  84. package/delivery/AssetDelivery/abstractions/AssetReply.js.map +1 -0
  85. package/delivery/AssetDelivery/abstractions/AssetRequestResolver.d.ts +5 -0
  86. package/delivery/AssetDelivery/abstractions/AssetRequestResolver.js +7 -0
  87. package/delivery/AssetDelivery/abstractions/AssetRequestResolver.js.map +1 -0
  88. package/delivery/AssetDelivery/abstractions/AssetResolver.d.ts +4 -0
  89. package/delivery/AssetDelivery/abstractions/AssetResolver.js +7 -0
  90. package/delivery/AssetDelivery/abstractions/AssetResolver.js.map +1 -0
  91. package/delivery/AssetDelivery/abstractions/AssetTransformationStrategy.d.ts +4 -0
  92. package/delivery/AssetDelivery/abstractions/AssetTransformationStrategy.js +7 -0
  93. package/delivery/AssetDelivery/abstractions/AssetTransformationStrategy.js.map +1 -0
  94. package/delivery/AssetDelivery/createAssetDeliveryPluginLoader.d.ts +2 -0
  95. package/delivery/AssetDelivery/createAssetDeliveryPluginLoader.js +15 -0
  96. package/delivery/AssetDelivery/createAssetDeliveryPluginLoader.js.map +1 -0
  97. package/delivery/AssetDelivery/privateFiles/AssetAuthorizer.d.ts +4 -0
  98. package/delivery/AssetDelivery/privateFiles/AssetAuthorizer.js +7 -0
  99. package/delivery/AssetDelivery/privateFiles/AssetAuthorizer.js.map +1 -0
  100. package/delivery/AssetDelivery/privateFiles/NotAuthorizedAssetReply.d.ts +4 -0
  101. package/delivery/AssetDelivery/privateFiles/NotAuthorizedAssetReply.js +26 -0
  102. package/delivery/AssetDelivery/privateFiles/NotAuthorizedAssetReply.js.map +1 -0
  103. package/delivery/AssetDelivery/privateFiles/NotAuthorizedOutputStrategy.d.ts +4 -0
  104. package/delivery/AssetDelivery/privateFiles/NotAuthorizedOutputStrategy.js +15 -0
  105. package/delivery/AssetDelivery/privateFiles/NotAuthorizedOutputStrategy.js.map +1 -0
  106. package/delivery/AssetDelivery/privateFiles/PrivateAuthenticatedAuthorizer.d.ts +7 -0
  107. package/delivery/AssetDelivery/privateFiles/PrivateAuthenticatedAuthorizer.js +28 -0
  108. package/delivery/AssetDelivery/privateFiles/PrivateAuthenticatedAuthorizer.js.map +1 -0
  109. package/delivery/AssetDelivery/privateFiles/PrivateCache.d.ts +6 -0
  110. package/delivery/AssetDelivery/privateFiles/PrivateCache.js +28 -0
  111. package/delivery/AssetDelivery/privateFiles/PrivateCache.js.map +1 -0
  112. package/delivery/AssetDelivery/privateFiles/PrivateFileAssetRequestResolver.d.ts +8 -0
  113. package/delivery/AssetDelivery/privateFiles/PrivateFileAssetRequestResolver.js +37 -0
  114. package/delivery/AssetDelivery/privateFiles/PrivateFileAssetRequestResolver.js.map +1 -0
  115. package/delivery/AssetDelivery/privateFiles/PrivateFilesAssetProcessor.d.ts +13 -0
  116. package/delivery/AssetDelivery/privateFiles/PrivateFilesAssetProcessor.js +63 -0
  117. package/delivery/AssetDelivery/privateFiles/PrivateFilesAssetProcessor.js.map +1 -0
  118. package/delivery/AssetDelivery/privateFiles/PublicCache.d.ts +6 -0
  119. package/delivery/AssetDelivery/privateFiles/PublicCache.js +28 -0
  120. package/delivery/AssetDelivery/privateFiles/PublicCache.js.map +1 -0
  121. package/delivery/AssetDelivery/privateFiles/RedirectToPrivateUrlOutputStrategy.d.ts +7 -0
  122. package/delivery/AssetDelivery/privateFiles/RedirectToPrivateUrlOutputStrategy.js +27 -0
  123. package/delivery/AssetDelivery/privateFiles/RedirectToPrivateUrlOutputStrategy.js.map +1 -0
  124. package/delivery/AssetDelivery/privateFiles/RedirectToPublicUrlOutputStrategy.d.ts +7 -0
  125. package/delivery/AssetDelivery/privateFiles/RedirectToPublicUrlOutputStrategy.js +27 -0
  126. package/delivery/AssetDelivery/privateFiles/RedirectToPublicUrlOutputStrategy.js.map +1 -0
  127. package/delivery/AssetDelivery/privateFiles/internalIdentity.d.ts +7 -0
  128. package/delivery/AssetDelivery/privateFiles/internalIdentity.js +18 -0
  129. package/delivery/AssetDelivery/privateFiles/internalIdentity.js.map +1 -0
  130. package/delivery/AssetDelivery/transformation/PassthroughAssetProcessor.d.ts +4 -0
  131. package/delivery/AssetDelivery/transformation/PassthroughAssetProcessor.js +14 -0
  132. package/delivery/AssetDelivery/transformation/PassthroughAssetProcessor.js.map +1 -0
  133. package/delivery/AssetDelivery/transformation/PassthroughAssetTransformationStrategy.d.ts +4 -0
  134. package/delivery/AssetDelivery/transformation/PassthroughAssetTransformationStrategy.js +14 -0
  135. package/delivery/AssetDelivery/transformation/PassthroughAssetTransformationStrategy.js.map +1 -0
  136. package/delivery/AssetDelivery/transformation/TransformationAssetProcessor.d.ts +6 -0
  137. package/delivery/AssetDelivery/transformation/TransformationAssetProcessor.js +26 -0
  138. package/delivery/AssetDelivery/transformation/TransformationAssetProcessor.js.map +1 -0
  139. package/delivery/index.d.ts +17 -0
  140. package/delivery/index.js +194 -0
  141. package/delivery/index.js.map +1 -0
  142. package/delivery/setupAssetDelivery.d.ts +6 -0
  143. package/delivery/setupAssetDelivery.js +128 -0
  144. package/delivery/setupAssetDelivery.js.map +1 -0
  145. package/enterprise/applyThreatScanning.d.ts +2 -0
  146. package/enterprise/applyThreatScanning.js +20 -0
  147. package/enterprise/applyThreatScanning.js.map +1 -0
  148. package/graphql/baseSchema.d.ts +1 -1
  149. package/graphql/baseSchema.js +6 -2
  150. package/graphql/baseSchema.js.map +1 -1
  151. package/graphql/createFilesTypeDefs.d.ts +1 -1
  152. package/graphql/createFilesTypeDefs.js +31 -9
  153. package/graphql/createFilesTypeDefs.js.map +1 -1
  154. package/graphql/filesSchema.d.ts +2 -2
  155. package/graphql/filesSchema.js +14 -8
  156. package/graphql/filesSchema.js.map +1 -1
  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 +3 -2
  161. package/graphql/index.js +27 -5
  162. package/graphql/index.js.map +1 -1
  163. package/graphql/utils.js +3 -1
  164. package/graphql/utils.js.map +1 -1
  165. package/handlers/{transform/managers → manage}/imageManager.d.ts +2 -3
  166. package/handlers/{transform/managers → manage}/imageManager.js +10 -9
  167. package/handlers/manage/imageManager.js.map +1 -0
  168. package/handlers/manage/index.d.ts +1 -1
  169. package/handlers/manage/index.js +9 -5
  170. package/handlers/manage/index.js.map +1 -1
  171. package/handlers/{transform → manage}/legacyUtils.d.ts +0 -5
  172. package/handlers/{transform → manage}/legacyUtils.js +7 -15
  173. package/handlers/manage/legacyUtils.js.map +1 -0
  174. package/handlers/{transform → manage}/utils.js +7 -9
  175. package/handlers/manage/utils.js.map +1 -0
  176. package/handlers/types.d.ts +1 -1
  177. package/handlers/types.js +3 -1
  178. package/handlers/types.js.map +1 -1
  179. package/handlers/utils/getEnvironment.js +3 -1
  180. package/handlers/utils/getEnvironment.js.map +1 -1
  181. package/handlers/utils/getObjectParams.js +3 -1
  182. package/handlers/utils/getObjectParams.js.map +1 -1
  183. package/handlers/utils/index.js +3 -1
  184. package/handlers/utils/index.js.map +1 -1
  185. package/index.d.ts +6 -3
  186. package/index.js +31 -7
  187. package/index.js.map +1 -1
  188. package/modelModifier/CmsModelModifier.d.ts +5 -3
  189. package/modelModifier/CmsModelModifier.js +15 -12
  190. package/modelModifier/CmsModelModifier.js.map +1 -1
  191. package/package.json +25 -35
  192. package/plugins/FilePhysicalStoragePlugin.d.ts +2 -1
  193. package/plugins/FilePhysicalStoragePlugin.js +3 -3
  194. package/plugins/FilePhysicalStoragePlugin.js.map +1 -1
  195. package/plugins/FileStorageTransformPlugin.d.ts +1 -1
  196. package/plugins/FileStorageTransformPlugin.js +3 -4
  197. package/plugins/FileStorageTransformPlugin.js.map +1 -1
  198. package/plugins/index.js +3 -1
  199. package/plugins/index.js.map +1 -1
  200. package/storage/FileStorage.d.ts +5 -3
  201. package/storage/FileStorage.js +20 -16
  202. package/storage/FileStorage.js.map +1 -1
  203. package/types/file.d.ts +12 -0
  204. package/types/file.js +3 -1
  205. package/types/file.js.map +1 -1
  206. package/types/file.lifecycle.d.ts +2 -2
  207. package/types/file.lifecycle.js +3 -1
  208. package/types/file.lifecycle.js.map +1 -1
  209. package/types.d.ts +37 -15
  210. package/types.js +3 -1
  211. package/types.js.map +1 -1
  212. package/cmsFileStorage/createFileManagerPlugins.d.ts +0 -5
  213. package/cmsFileStorage/createFileManagerPlugins.js +0 -34
  214. package/cmsFileStorage/createFileManagerPlugins.js.map +0 -1
  215. package/cmsFileStorage/createModelField.d.ts +0 -5
  216. package/cmsFileStorage/createModelField.js +0 -37
  217. package/cmsFileStorage/createModelField.js.map +0 -1
  218. package/cmsFileStorage/isInstallationPending.d.ts +0 -4
  219. package/cmsFileStorage/isInstallationPending.js +0 -21
  220. package/cmsFileStorage/isInstallationPending.js.map +0 -1
  221. package/createFileManager/filevalidation.disabled.d.ts +0 -0
  222. package/createFileManager/filevalidation.disabled.js +0 -55
  223. package/createFileManager/filevalidation.disabled.js.map +0 -1
  224. package/handlers/download/byAlias.d.ts +0 -6
  225. package/handlers/download/byAlias.js +0 -89
  226. package/handlers/download/byAlias.js.map +0 -1
  227. package/handlers/download/byExactKey.d.ts +0 -2
  228. package/handlers/download/byExactKey.js +0 -57
  229. package/handlers/download/byExactKey.js.map +0 -1
  230. package/handlers/download/extractFileInformation.d.ts +0 -9
  231. package/handlers/download/extractFileInformation.js +0 -20
  232. package/handlers/download/extractFileInformation.js.map +0 -1
  233. package/handlers/download/getS3Object.d.ts +0 -12
  234. package/handlers/download/getS3Object.js +0 -72
  235. package/handlers/download/getS3Object.js.map +0 -1
  236. package/handlers/download/index.d.ts +0 -2
  237. package/handlers/download/index.js +0 -27
  238. package/handlers/download/index.js.map +0 -1
  239. package/handlers/transform/index.d.ts +0 -2
  240. package/handlers/transform/index.js +0 -92
  241. package/handlers/transform/index.js.map +0 -1
  242. package/handlers/transform/legacyUtils.js.map +0 -1
  243. package/handlers/transform/loaders/imageLoader.d.ts +0 -30
  244. package/handlers/transform/loaders/imageLoader.js +0 -94
  245. package/handlers/transform/loaders/imageLoader.js.map +0 -1
  246. package/handlers/transform/loaders/index.d.ts +0 -8
  247. package/handlers/transform/loaders/index.js +0 -10
  248. package/handlers/transform/loaders/index.js.map +0 -1
  249. package/handlers/transform/loaders/sanitizeImageTransformations.d.ts +0 -11
  250. package/handlers/transform/loaders/sanitizeImageTransformations.js +0 -45
  251. package/handlers/transform/loaders/sanitizeImageTransformations.js.map +0 -1
  252. package/handlers/transform/managers/imageManager.js.map +0 -1
  253. package/handlers/transform/managers/index.d.ts +0 -5
  254. package/handlers/transform/managers/index.js +0 -10
  255. package/handlers/transform/managers/index.js.map +0 -1
  256. package/handlers/transform/optimizeImage.d.ts +0 -3
  257. package/handlers/transform/optimizeImage.js +0 -42
  258. package/handlers/transform/optimizeImage.js.map +0 -1
  259. package/handlers/transform/transformImage.d.ts +0 -13
  260. package/handlers/transform/transformImage.js +0 -28
  261. package/handlers/transform/transformImage.js.map +0 -1
  262. package/handlers/transform/utils.js.map +0 -1
  263. /package/handlers/{transform → manage}/utils.d.ts +0 -0
@@ -5,22 +5,20 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.FileStorage = void 0;
8
- var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
9
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
8
  var _error = _interopRequireDefault(require("@webiny/error"));
11
9
  const storagePluginType = "api-file-manager-storage";
12
10
  class FileStorage {
13
11
  constructor({
14
12
  context
15
13
  }) {
16
- (0, _defineProperty2.default)(this, "storagePlugin", void 0);
17
- (0, _defineProperty2.default)(this, "context", void 0);
18
- const storagePlugin = context.plugins.byType(storagePluginType).pop();
14
+ this.context = context;
15
+ }
16
+ get storagePlugin() {
17
+ const storagePlugin = this.context.plugins.byType(storagePluginType).pop();
19
18
  if (!storagePlugin) {
20
19
  throw new _error.default(`Missing plugin of type "${storagePluginType}".`, "STORAGE_PLUGIN_ERROR");
21
20
  }
22
- this.storagePlugin = storagePlugin;
23
- this.context = context;
21
+ return storagePlugin;
24
22
  }
25
23
  async upload(params) {
26
24
  const settings = await this.context.fileManager.getSettings();
@@ -31,17 +29,19 @@ class FileStorage {
31
29
  // Add file to cloud storage.
32
30
  const {
33
31
  file: fileData
34
- } = await this.storagePlugin.upload((0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
32
+ } = await this.storagePlugin.upload({
33
+ ...params,
35
34
  settings
36
- }));
35
+ });
37
36
 
38
37
  // Save file in DB.
39
- return this.context.fileManager.createFile((0, _objectSpread2.default)((0, _objectSpread2.default)({}, fileData), {}, {
38
+ return this.context.fileManager.createFile({
39
+ ...fileData,
40
40
  meta: {
41
41
  private: Boolean(params.hideInFileManager)
42
42
  },
43
43
  tags: Array.isArray(params.tags) ? params.tags : []
44
- }));
44
+ });
45
45
  }
46
46
  async uploadFiles({
47
47
  files
@@ -54,15 +54,17 @@ class FileStorage {
54
54
  // TODO: improve types of this.storagePlugin.
55
55
  const {
56
56
  file
57
- } = await this.storagePlugin.upload((0, _objectSpread2.default)((0, _objectSpread2.default)({}, item), {}, {
57
+ } = await this.storagePlugin.upload({
58
+ ...item,
58
59
  settings
59
- }));
60
- return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, file), {}, {
60
+ });
61
+ return {
62
+ ...file,
61
63
  meta: {
62
64
  private: Boolean(item.hideInFileManager)
63
65
  },
64
66
  tags: Array.isArray(item.tags) ? item.tags : []
65
- });
67
+ };
66
68
  }));
67
69
  return this.context.fileManager.createFilesInBatch(filesData);
68
70
  }
@@ -83,4 +85,6 @@ class FileStorage {
83
85
  return await fileManager.deleteFile(id);
84
86
  }
85
87
  }
86
- exports.FileStorage = FileStorage;
88
+ exports.FileStorage = FileStorage;
89
+
90
+ //# sourceMappingURL=FileStorage.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["storagePluginType","FileStorage","constructor","context","storagePlugin","plugins","byType","pop","WebinyError","upload","params","settings","fileManager","getSettings","file","fileData","createFile","meta","private","Boolean","hideInFileManager","tags","Array","isArray","uploadFiles","files","filesData","Promise","all","map","item","createFilesInBatch","delete","id","key","deleteFile"],"sources":["FileStorage.ts"],"sourcesContent":["import { FileManagerContext } from \"~/types\";\nimport WebinyError from \"@webiny/error\";\nimport { FilePhysicalStoragePlugin } from \"~/plugins/FilePhysicalStoragePlugin\";\n\nexport type Result = Record<string, any>;\n\nconst storagePluginType = \"api-file-manager-storage\";\n\nexport interface FileStorageUploadParams {\n buffer: Buffer;\n hideInFileManager: boolean | string;\n size: number;\n name: string;\n type: string;\n id?: string;\n key?: string;\n tags?: string[];\n keyPrefix?: string;\n}\nexport interface FileStorageDeleteParams {\n id: string;\n key: string;\n}\n\nexport interface FileStorageUploadMultipleParams {\n files: FileStorageUploadParams[];\n}\n\nexport interface FileStorageParams {\n context: FileManagerContext;\n}\nexport class FileStorage {\n private readonly storagePlugin: FilePhysicalStoragePlugin;\n private readonly context: FileManagerContext;\n\n constructor({ context }: FileStorageParams) {\n const storagePlugin = context.plugins\n .byType<FilePhysicalStoragePlugin>(storagePluginType)\n .pop();\n\n if (!storagePlugin) {\n throw new WebinyError(\n `Missing plugin of type \"${storagePluginType}\".`,\n \"STORAGE_PLUGIN_ERROR\"\n );\n }\n this.storagePlugin = storagePlugin;\n this.context = context;\n }\n\n async upload(params: FileStorageUploadParams): Promise<Result> {\n const settings = await this.context.fileManager.getSettings();\n if (!settings) {\n throw new WebinyError(\"Missing File Manager Settings.\", \"FILE_MANAGER_ERROR\");\n }\n\n // Add file to cloud storage.\n const { file: fileData } = await this.storagePlugin.upload({\n ...params,\n settings\n });\n\n // Save file in DB.\n return this.context.fileManager.createFile({\n ...(fileData as any),\n meta: {\n private: Boolean(params.hideInFileManager)\n },\n tags: Array.isArray(params.tags) ? params.tags : []\n });\n }\n\n async uploadFiles({ files }: FileStorageUploadMultipleParams) {\n const settings = await this.context.fileManager.getSettings();\n if (!settings) {\n throw new WebinyError(\"Missing File Manager Settings.\", \"FILE_MANAGER_ERROR\");\n }\n\n const filesData = await Promise.all(\n files.map(async item => {\n // TODO: improve types of this.storagePlugin.\n const { file } = await this.storagePlugin.upload({\n ...item,\n settings\n });\n\n return {\n ...file,\n meta: {\n private: Boolean(item.hideInFileManager)\n },\n tags: Array.isArray(item.tags) ? item.tags : []\n };\n })\n );\n\n return this.context.fileManager.createFilesInBatch(filesData);\n }\n\n async delete(params: FileStorageDeleteParams) {\n const { id, key } = params;\n const { fileManager } = this.context;\n // Delete file from cloud storage.\n await this.storagePlugin.delete({\n key\n });\n\n // Delete file from the DB.\n return await fileManager.deleteFile(id);\n }\n}\n"],"mappings":";;;;;;;;;AACA;AAKA,MAAMA,iBAAiB,GAAG,0BAA0B;AAyB7C,MAAMC,WAAW,CAAC;EAIrBC,WAAW,CAAC;IAAEC;EAA2B,CAAC,EAAE;IAAA;IAAA;IACxC,MAAMC,aAAa,GAAGD,OAAO,CAACE,OAAO,CAChCC,MAAM,CAA4BN,iBAAiB,CAAC,CACpDO,GAAG,EAAE;IAEV,IAAI,CAACH,aAAa,EAAE;MAChB,MAAM,IAAII,cAAW,CAChB,2BAA0BR,iBAAkB,IAAG,EAChD,sBAAsB,CACzB;IACL;IACA,IAAI,CAACI,aAAa,GAAGA,aAAa;IAClC,IAAI,CAACD,OAAO,GAAGA,OAAO;EAC1B;EAEA,MAAMM,MAAM,CAACC,MAA+B,EAAmB;IAC3D,MAAMC,QAAQ,GAAG,MAAM,IAAI,CAACR,OAAO,CAACS,WAAW,CAACC,WAAW,EAAE;IAC7D,IAAI,CAACF,QAAQ,EAAE;MACX,MAAM,IAAIH,cAAW,CAAC,gCAAgC,EAAE,oBAAoB,CAAC;IACjF;;IAEA;IACA,MAAM;MAAEM,IAAI,EAAEC;IAAS,CAAC,GAAG,MAAM,IAAI,CAACX,aAAa,CAACK,MAAM,6DACnDC,MAAM;MACTC;IAAQ,GACV;;IAEF;IACA,OAAO,IAAI,CAACR,OAAO,CAACS,WAAW,CAACI,UAAU,6DAClCD,QAAQ;MACZE,IAAI,EAAE;QACFC,OAAO,EAAEC,OAAO,CAACT,MAAM,CAACU,iBAAiB;MAC7C,CAAC;MACDC,IAAI,EAAEC,KAAK,CAACC,OAAO,CAACb,MAAM,CAACW,IAAI,CAAC,GAAGX,MAAM,CAACW,IAAI,GAAG;IAAE,GACrD;EACN;EAEA,MAAMG,WAAW,CAAC;IAAEC;EAAuC,CAAC,EAAE;IAC1D,MAAMd,QAAQ,GAAG,MAAM,IAAI,CAACR,OAAO,CAACS,WAAW,CAACC,WAAW,EAAE;IAC7D,IAAI,CAACF,QAAQ,EAAE;MACX,MAAM,IAAIH,cAAW,CAAC,gCAAgC,EAAE,oBAAoB,CAAC;IACjF;IAEA,MAAMkB,SAAS,GAAG,MAAMC,OAAO,CAACC,GAAG,CAC/BH,KAAK,CAACI,GAAG,CAAC,MAAMC,IAAI,IAAI;MACpB;MACA,MAAM;QAAEhB;MAAK,CAAC,GAAG,MAAM,IAAI,CAACV,aAAa,CAACK,MAAM,6DACzCqB,IAAI;QACPnB;MAAQ,GACV;MAEF,mEACOG,IAAI;QACPG,IAAI,EAAE;UACFC,OAAO,EAAEC,OAAO,CAACW,IAAI,CAACV,iBAAiB;QAC3C,CAAC;QACDC,IAAI,EAAEC,KAAK,CAACC,OAAO,CAACO,IAAI,CAACT,IAAI,CAAC,GAAGS,IAAI,CAACT,IAAI,GAAG;MAAE;IAEvD,CAAC,CAAC,CACL;IAED,OAAO,IAAI,CAAClB,OAAO,CAACS,WAAW,CAACmB,kBAAkB,CAACL,SAAS,CAAC;EACjE;EAEA,MAAMM,MAAM,CAACtB,MAA+B,EAAE;IAC1C,MAAM;MAAEuB,EAAE;MAAEC;IAAI,CAAC,GAAGxB,MAAM;IAC1B,MAAM;MAAEE;IAAY,CAAC,GAAG,IAAI,CAACT,OAAO;IACpC;IACA,MAAM,IAAI,CAACC,aAAa,CAAC4B,MAAM,CAAC;MAC5BE;IACJ,CAAC,CAAC;;IAEF;IACA,OAAO,MAAMtB,WAAW,CAACuB,UAAU,CAACF,EAAE,CAAC;EAC3C;AACJ;AAAC"}
1
+ {"version":3,"names":["_error","_interopRequireDefault","require","storagePluginType","FileStorage","constructor","context","storagePlugin","plugins","byType","pop","WebinyError","upload","params","settings","fileManager","getSettings","file","fileData","createFile","meta","private","Boolean","hideInFileManager","tags","Array","isArray","uploadFiles","files","filesData","Promise","all","map","item","createFilesInBatch","delete","id","key","deleteFile","exports"],"sources":["FileStorage.ts"],"sourcesContent":["import type { FileManagerContext } from \"~/types\";\nimport WebinyError from \"@webiny/error\";\nimport type { FilePhysicalStoragePlugin } from \"~/plugins/FilePhysicalStoragePlugin\";\n\nexport type Result = Record<string, any>;\n\nconst storagePluginType = \"api-file-manager-storage\";\n\nexport interface FileStorageUploadParams {\n buffer: Buffer;\n hideInFileManager: boolean | string;\n size: number;\n name: string;\n type: string;\n id?: string;\n key?: string;\n tags?: string[];\n keyPrefix?: string;\n}\nexport interface FileStorageDeleteParams {\n id: string;\n key: string;\n}\n\nexport interface FileStorageUploadMultipleParams {\n files: FileStorageUploadParams[];\n}\n\nexport interface FileStorageParams {\n context: FileManagerContext;\n}\nexport class FileStorage {\n private readonly context: FileManagerContext;\n\n constructor({ context }: FileStorageParams) {\n this.context = context;\n }\n\n get storagePlugin() {\n const storagePlugin = this.context.plugins\n .byType<FilePhysicalStoragePlugin>(storagePluginType)\n .pop();\n\n if (!storagePlugin) {\n throw new WebinyError(\n `Missing plugin of type \"${storagePluginType}\".`,\n \"STORAGE_PLUGIN_ERROR\"\n );\n }\n\n return storagePlugin;\n }\n\n async upload(params: FileStorageUploadParams): Promise<Result> {\n const settings = await this.context.fileManager.getSettings();\n if (!settings) {\n throw new WebinyError(\"Missing File Manager Settings.\", \"FILE_MANAGER_ERROR\");\n }\n\n // Add file to cloud storage.\n const { file: fileData } = await this.storagePlugin.upload({\n ...params,\n settings\n });\n\n // Save file in DB.\n return this.context.fileManager.createFile({\n ...fileData,\n meta: {\n private: Boolean(params.hideInFileManager)\n },\n tags: Array.isArray(params.tags) ? params.tags : []\n });\n }\n\n async uploadFiles({ files }: FileStorageUploadMultipleParams) {\n const settings = await this.context.fileManager.getSettings();\n if (!settings) {\n throw new WebinyError(\"Missing File Manager Settings.\", \"FILE_MANAGER_ERROR\");\n }\n\n const filesData = await Promise.all(\n files.map(async item => {\n // TODO: improve types of this.storagePlugin.\n const { file } = await this.storagePlugin.upload({\n ...item,\n settings\n });\n\n return {\n ...file,\n meta: {\n private: Boolean(item.hideInFileManager)\n },\n tags: Array.isArray(item.tags) ? item.tags : []\n };\n })\n );\n\n return this.context.fileManager.createFilesInBatch(filesData);\n }\n\n async delete(params: FileStorageDeleteParams) {\n const { id, key } = params;\n const { fileManager } = this.context;\n // Delete file from cloud storage.\n await this.storagePlugin.delete({\n key\n });\n\n // Delete file from the DB.\n return await fileManager.deleteFile(id);\n }\n}\n"],"mappings":";;;;;;;AACA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,MAAMC,iBAAiB,GAAG,0BAA0B;AAyB7C,MAAMC,WAAW,CAAC;EAGrBC,WAAWA,CAAC;IAAEC;EAA2B,CAAC,EAAE;IACxC,IAAI,CAACA,OAAO,GAAGA,OAAO;EAC1B;EAEA,IAAIC,aAAaA,CAAA,EAAG;IAChB,MAAMA,aAAa,GAAG,IAAI,CAACD,OAAO,CAACE,OAAO,CACrCC,MAAM,CAA4BN,iBAAiB,CAAC,CACpDO,GAAG,CAAC,CAAC;IAEV,IAAI,CAACH,aAAa,EAAE;MAChB,MAAM,IAAII,cAAW,CACjB,2BAA2BR,iBAAiB,IAAI,EAChD,sBACJ,CAAC;IACL;IAEA,OAAOI,aAAa;EACxB;EAEA,MAAMK,MAAMA,CAACC,MAA+B,EAAmB;IAC3D,MAAMC,QAAQ,GAAG,MAAM,IAAI,CAACR,OAAO,CAACS,WAAW,CAACC,WAAW,CAAC,CAAC;IAC7D,IAAI,CAACF,QAAQ,EAAE;MACX,MAAM,IAAIH,cAAW,CAAC,gCAAgC,EAAE,oBAAoB,CAAC;IACjF;;IAEA;IACA,MAAM;MAAEM,IAAI,EAAEC;IAAS,CAAC,GAAG,MAAM,IAAI,CAACX,aAAa,CAACK,MAAM,CAAC;MACvD,GAAGC,MAAM;MACTC;IACJ,CAAC,CAAC;;IAEF;IACA,OAAO,IAAI,CAACR,OAAO,CAACS,WAAW,CAACI,UAAU,CAAC;MACvC,GAAGD,QAAQ;MACXE,IAAI,EAAE;QACFC,OAAO,EAAEC,OAAO,CAACT,MAAM,CAACU,iBAAiB;MAC7C,CAAC;MACDC,IAAI,EAAEC,KAAK,CAACC,OAAO,CAACb,MAAM,CAACW,IAAI,CAAC,GAAGX,MAAM,CAACW,IAAI,GAAG;IACrD,CAAC,CAAC;EACN;EAEA,MAAMG,WAAWA,CAAC;IAAEC;EAAuC,CAAC,EAAE;IAC1D,MAAMd,QAAQ,GAAG,MAAM,IAAI,CAACR,OAAO,CAACS,WAAW,CAACC,WAAW,CAAC,CAAC;IAC7D,IAAI,CAACF,QAAQ,EAAE;MACX,MAAM,IAAIH,cAAW,CAAC,gCAAgC,EAAE,oBAAoB,CAAC;IACjF;IAEA,MAAMkB,SAAS,GAAG,MAAMC,OAAO,CAACC,GAAG,CAC/BH,KAAK,CAACI,GAAG,CAAC,MAAMC,IAAI,IAAI;MACpB;MACA,MAAM;QAAEhB;MAAK,CAAC,GAAG,MAAM,IAAI,CAACV,aAAa,CAACK,MAAM,CAAC;QAC7C,GAAGqB,IAAI;QACPnB;MACJ,CAAC,CAAC;MAEF,OAAO;QACH,GAAGG,IAAI;QACPG,IAAI,EAAE;UACFC,OAAO,EAAEC,OAAO,CAACW,IAAI,CAACV,iBAAiB;QAC3C,CAAC;QACDC,IAAI,EAAEC,KAAK,CAACC,OAAO,CAACO,IAAI,CAACT,IAAI,CAAC,GAAGS,IAAI,CAACT,IAAI,GAAG;MACjD,CAAC;IACL,CAAC,CACL,CAAC;IAED,OAAO,IAAI,CAAClB,OAAO,CAACS,WAAW,CAACmB,kBAAkB,CAACL,SAAS,CAAC;EACjE;EAEA,MAAMM,MAAMA,CAACtB,MAA+B,EAAE;IAC1C,MAAM;MAAEuB,EAAE;MAAEC;IAAI,CAAC,GAAGxB,MAAM;IAC1B,MAAM;MAAEE;IAAY,CAAC,GAAG,IAAI,CAACT,OAAO;IACpC;IACA,MAAM,IAAI,CAACC,aAAa,CAAC4B,MAAM,CAAC;MAC5BE;IACJ,CAAC,CAAC;;IAEF;IACA,OAAO,MAAMtB,WAAW,CAACuB,UAAU,CAACF,EAAE,CAAC;EAC3C;AACJ;AAACG,OAAA,CAAAnC,WAAA,GAAAA,WAAA","ignoreList":[]}
package/types/file.d.ts CHANGED
@@ -1,3 +1,9 @@
1
+ type PublicAccess = {
2
+ type: "public";
3
+ };
4
+ type PrivateAuthenticatedAccess = {
5
+ type: "private-authenticated";
6
+ };
1
7
  export interface File {
2
8
  id: string;
3
9
  key: string;
@@ -5,14 +11,19 @@ export interface File {
5
11
  type: string;
6
12
  name: string;
7
13
  meta: Record<string, any>;
14
+ accessControl?: PublicAccess | PrivateAuthenticatedAccess;
8
15
  location: {
9
16
  folderId: string;
10
17
  };
11
18
  tags: string[];
12
19
  aliases: string[];
13
20
  createdOn: string;
21
+ modifiedOn: string | null;
14
22
  savedOn: string;
15
23
  createdBy: CreatedBy;
24
+ modifiedBy: CreatedBy | null;
25
+ savedBy: CreatedBy;
26
+ extensions?: Record<string, any>;
16
27
  /**
17
28
  * Added with new storage operations refactoring.
18
29
  */
@@ -35,3 +46,4 @@ export interface CreatedBy {
35
46
  displayName: string | null;
36
47
  type: string;
37
48
  }
49
+ export {};
package/types/file.js CHANGED
@@ -2,4 +2,6 @@
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
- });
5
+ });
6
+
7
+ //# sourceMappingURL=file.js.map
package/types/file.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["file.ts"],"sourcesContent":["export interface File {\n id: string;\n key: string;\n size: number;\n type: string;\n name: string;\n meta: Record<string, any>;\n location: {\n folderId: string;\n };\n tags: string[];\n aliases: string[];\n createdOn: string;\n savedOn: string;\n createdBy: CreatedBy;\n /**\n * Added with new storage operations refactoring.\n */\n tenant: string;\n locale: string;\n webinyVersion: string;\n /**\n * User can add new fields to the File object, so we must allow it in the types.\n */\n [key: string]: any;\n}\n\nexport interface FileAlias {\n tenant: string;\n locale: string;\n fileId: string;\n alias: string;\n}\n\nexport interface CreatedBy {\n id: string;\n displayName: string | null;\n type: string;\n}\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["file.ts"],"sourcesContent":["type PublicAccess = {\n type: \"public\";\n};\n\ntype PrivateAuthenticatedAccess = {\n type: \"private-authenticated\";\n};\n\nexport interface File {\n id: string;\n key: string;\n size: number;\n type: string;\n name: string;\n meta: Record<string, any>;\n accessControl?: PublicAccess | PrivateAuthenticatedAccess;\n location: {\n folderId: string;\n };\n tags: string[];\n aliases: string[];\n\n createdOn: string;\n modifiedOn: string | null;\n savedOn: string;\n createdBy: CreatedBy;\n modifiedBy: CreatedBy | null;\n savedBy: CreatedBy;\n extensions?: Record<string, any>;\n\n /**\n * Added with new storage operations refactoring.\n */\n tenant: string;\n locale: string;\n webinyVersion: string;\n /**\n * User can add new fields to the File object, so we must allow it in the types.\n */\n\n [key: string]: any;\n}\n\nexport interface FileAlias {\n tenant: string;\n locale: string;\n fileId: string;\n alias: string;\n}\n\nexport interface CreatedBy {\n id: string;\n displayName: string | null;\n type: string;\n}\n"],"mappings":"","ignoreList":[]}
@@ -1,5 +1,5 @@
1
- import { Topic } from "@webiny/pubsub/types";
2
- import { File } from "./file";
1
+ import type { Topic } from "@webiny/pubsub/types";
2
+ import type { File } from "./file";
3
3
  export interface OnFileBeforeCreateTopicParams<TFile extends File = File> {
4
4
  file: TFile;
5
5
  meta?: Record<string, any>;
@@ -2,4 +2,6 @@
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
- });
5
+ });
6
+
7
+ //# sourceMappingURL=file.lifecycle.js.map
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["file.lifecycle.ts"],"sourcesContent":["import { Topic } from \"@webiny/pubsub/types\";\nimport { File } from \"./file\";\n\nexport interface OnFileBeforeCreateTopicParams<TFile extends File = File> {\n file: TFile;\n meta?: Record<string, any>;\n}\n\nexport interface OnFileAfterCreateTopicParams<TFile extends File = File> {\n file: TFile;\n meta?: Record<string, any>;\n}\n\nexport interface OnFileBeforeBatchCreateTopicParams<TFile extends File = File> {\n files: TFile[];\n meta?: Record<string, any>;\n}\n\nexport interface OnFileAfterBatchCreateTopicParams<TFile extends File = File> {\n files: TFile[];\n meta?: Record<string, any>;\n}\n\nexport interface OnFileBeforeUpdateTopicParams<TFile extends File = File> {\n original: TFile;\n file: TFile;\n input: Record<string, any>;\n}\n\nexport interface OnFileAfterUpdateTopicParams<TFile extends File = File> {\n original: TFile;\n file: TFile;\n input: Record<string, any>;\n}\n\nexport interface OnFileBeforeDeleteTopicParams<TFile extends File = File> {\n file: TFile;\n}\n\nexport interface OnFileAfterDeleteTopicParams<TFile extends File = File> {\n file: TFile;\n}\n\nexport interface FileLifecycleEvents {\n onFileBeforeCreate: Topic<OnFileBeforeCreateTopicParams>;\n onFileAfterCreate: Topic<OnFileAfterCreateTopicParams>;\n onFileBeforeBatchCreate: Topic<OnFileBeforeBatchCreateTopicParams>;\n onFileAfterBatchCreate: Topic<OnFileAfterBatchCreateTopicParams>;\n onFileBeforeUpdate: Topic<OnFileBeforeUpdateTopicParams>;\n onFileAfterUpdate: Topic<OnFileAfterUpdateTopicParams>;\n onFileBeforeDelete: Topic<OnFileBeforeDeleteTopicParams>;\n onFileAfterDelete: Topic<OnFileAfterDeleteTopicParams>;\n}\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["file.lifecycle.ts"],"sourcesContent":["import type { Topic } from \"@webiny/pubsub/types\";\nimport type { File } from \"./file\";\n\nexport interface OnFileBeforeCreateTopicParams<TFile extends File = File> {\n file: TFile;\n meta?: Record<string, any>;\n}\n\nexport interface OnFileAfterCreateTopicParams<TFile extends File = File> {\n file: TFile;\n meta?: Record<string, any>;\n}\n\nexport interface OnFileBeforeBatchCreateTopicParams<TFile extends File = File> {\n files: TFile[];\n meta?: Record<string, any>;\n}\n\nexport interface OnFileAfterBatchCreateTopicParams<TFile extends File = File> {\n files: TFile[];\n meta?: Record<string, any>;\n}\n\nexport interface OnFileBeforeUpdateTopicParams<TFile extends File = File> {\n original: TFile;\n file: TFile;\n input: Record<string, any>;\n}\n\nexport interface OnFileAfterUpdateTopicParams<TFile extends File = File> {\n original: TFile;\n file: TFile;\n input: Record<string, any>;\n}\n\nexport interface OnFileBeforeDeleteTopicParams<TFile extends File = File> {\n file: TFile;\n}\n\nexport interface OnFileAfterDeleteTopicParams<TFile extends File = File> {\n file: TFile;\n}\n\nexport interface FileLifecycleEvents {\n onFileBeforeCreate: Topic<OnFileBeforeCreateTopicParams>;\n onFileAfterCreate: Topic<OnFileAfterCreateTopicParams>;\n onFileBeforeBatchCreate: Topic<OnFileBeforeBatchCreateTopicParams>;\n onFileAfterBatchCreate: Topic<OnFileAfterBatchCreateTopicParams>;\n onFileBeforeUpdate: Topic<OnFileBeforeUpdateTopicParams>;\n onFileAfterUpdate: Topic<OnFileAfterUpdateTopicParams>;\n onFileBeforeDelete: Topic<OnFileBeforeDeleteTopicParams>;\n onFileAfterDelete: Topic<OnFileAfterDeleteTopicParams>;\n}\n"],"mappings":"","ignoreList":[]}
package/types.d.ts CHANGED
@@ -1,18 +1,20 @@
1
- import { I18NContext } from "@webiny/api-i18n/types";
2
- import { FileStorage } from "./storage/FileStorage";
3
- import { TenancyContext } from "@webiny/api-tenancy/types";
4
- import { SecurityContext, SecurityPermission } from "@webiny/api-security/types";
5
- import { Context } from "@webiny/api/types";
6
- import { FileLifecycleEvents } from "./types/file.lifecycle";
7
- import { File } from "./types/file";
8
- import { Topic } from "@webiny/pubsub/types";
9
- import { CmsContext } from "@webiny/api-headless-cms/types";
1
+ import type { I18NContext } from "@webiny/api-i18n/types";
2
+ import type { FileStorage } from "./storage/FileStorage";
3
+ import type { TenancyContext } from "@webiny/api-tenancy/types";
4
+ import type { SecurityContext, SecurityPermission } from "@webiny/api-security/types";
5
+ import type { Context } from "@webiny/api/types";
6
+ import type { FileLifecycleEvents } from "./types/file.lifecycle";
7
+ import type { CreatedBy, File } from "./types/file";
8
+ import type { Topic } from "@webiny/pubsub/types";
9
+ import type { CmsContext, CmsEntryListSort } from "@webiny/api-headless-cms/types";
10
+ import type { Context as TasksContext } from "@webiny/tasks/types";
10
11
  export * from "./types/file.lifecycle";
11
12
  export * from "./types/file";
13
+ export * from "./types/file";
12
14
  export interface FileManagerContextObject extends FilesCRUD, SettingsCRUD, SystemCRUD {
13
15
  storage: FileStorage;
14
16
  }
15
- export interface FileManagerContext extends Context, SecurityContext, TenancyContext, I18NContext, CmsContext {
17
+ export interface FileManagerContext extends Context, SecurityContext, TenancyContext, I18NContext, CmsContext, TasksContext {
16
18
  fileManager: FileManagerContextObject;
17
19
  }
18
20
  export interface FilePermission extends SecurityPermission {
@@ -20,8 +22,17 @@ export interface FilePermission extends SecurityPermission {
20
22
  rwd?: string;
21
23
  own?: boolean;
22
24
  }
25
+ export interface SettingsPermission extends SecurityPermission {
26
+ name: "fm.setting";
27
+ }
23
28
  export interface FileInput {
24
29
  id: string;
30
+ createdOn?: string | Date | null;
31
+ modifiedOn?: string | Date | null;
32
+ savedOn?: string | Date | null;
33
+ createdBy?: CreatedBy | null;
34
+ modifiedBy?: CreatedBy | null;
35
+ savedBy?: CreatedBy | null;
25
36
  key: string;
26
37
  name: string;
27
38
  size: number;
@@ -44,7 +55,7 @@ export interface FilesListOpts {
44
55
  limit?: number;
45
56
  after?: string;
46
57
  where?: FileListWhereParams;
47
- sort?: string[];
58
+ sort?: CmsEntryListSort;
48
59
  }
49
60
  export interface FileListMeta {
50
61
  cursor: string | null;
@@ -87,7 +98,6 @@ export interface SystemCRUD {
87
98
  }
88
99
  export interface FileManagerSettings {
89
100
  tenant: string;
90
- key: string;
91
101
  uploadMinFileSize: number;
92
102
  uploadMaxFileSize: number;
93
103
  srcPrefix: string;
@@ -96,11 +106,23 @@ export interface FileManagerSystem {
96
106
  version: string;
97
107
  tenant: string;
98
108
  }
99
- export declare type SettingsCRUD = {
109
+ export interface OnSettingsBeforeUpdateTopicParams {
110
+ input: Partial<FileManagerSettings>;
111
+ original: FileManagerSettings;
112
+ settings: FileManagerSettings;
113
+ }
114
+ export interface OnSettingsAfterUpdateTopicParams {
115
+ input: Partial<FileManagerSettings>;
116
+ original: FileManagerSettings;
117
+ settings: FileManagerSettings;
118
+ }
119
+ export type SettingsCRUD = {
100
120
  getSettings(): Promise<FileManagerSettings | null>;
101
121
  createSettings(data?: Partial<FileManagerSettings>): Promise<FileManagerSettings>;
102
122
  updateSettings(data: Partial<FileManagerSettings>): Promise<FileManagerSettings>;
103
123
  deleteSettings(): Promise<boolean>;
124
+ onSettingsBeforeUpdate: Topic<OnSettingsBeforeUpdateTopicParams>;
125
+ onSettingsAfterUpdate: Topic<OnSettingsAfterUpdateTopicParams>;
104
126
  };
105
127
  /********
106
128
  * Storage operations
@@ -266,7 +288,7 @@ export interface FileManagerFilesStorageOperationsListParamsWhere {
266
288
  */
267
289
  export interface FileManagerFilesStorageOperationsListParams {
268
290
  where: FileManagerFilesStorageOperationsListParamsWhere;
269
- sort: string[];
291
+ sort: CmsEntryListSort;
270
292
  limit: number;
271
293
  after: string | null;
272
294
  search?: string;
@@ -281,7 +303,7 @@ export interface FileManagerFilesStorageOperationsListResponseMeta {
281
303
  totalCount: number;
282
304
  cursor: string | null;
283
305
  }
284
- export declare type FileManagerFilesStorageOperationsListResponse = [
306
+ export type FileManagerFilesStorageOperationsListResponse = [
285
307
  File[],
286
308
  FileManagerFilesStorageOperationsListResponseMeta
287
309
  ];
package/types.js CHANGED
@@ -24,4 +24,6 @@ Object.keys(_file2).forEach(function (key) {
24
24
  return _file2[key];
25
25
  }
26
26
  });
27
- });
27
+ });
28
+
29
+ //# sourceMappingURL=types.js.map
package/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import { I18NContext } from \"@webiny/api-i18n/types\";\nimport { FileStorage } from \"./storage/FileStorage\";\nimport { TenancyContext } from \"@webiny/api-tenancy/types\";\nimport { SecurityContext, SecurityPermission } from \"@webiny/api-security/types\";\nimport { Context } from \"@webiny/api/types\";\nimport { FileLifecycleEvents } from \"./types/file.lifecycle\";\nimport { File } from \"./types/file\";\nimport { Topic } from \"@webiny/pubsub/types\";\nimport { CmsContext } from \"@webiny/api-headless-cms/types\";\nexport * from \"./types/file.lifecycle\";\nexport * from \"./types/file\";\n\nexport interface FileManagerContextObject extends FilesCRUD, SettingsCRUD, SystemCRUD {\n storage: FileStorage;\n}\n\nexport interface FileManagerContext\n extends Context,\n SecurityContext,\n TenancyContext,\n I18NContext,\n CmsContext {\n fileManager: FileManagerContextObject;\n}\n\nexport interface FilePermission extends SecurityPermission {\n name: \"fm.file\";\n rwd?: string;\n own?: boolean;\n}\n\nexport interface FileInput {\n id: string;\n key: string;\n name: string;\n size: number;\n type: string;\n meta: Record<string, any>;\n location?: {\n folderId: string;\n };\n tags: string[];\n aliases: string[];\n extensions?: Record<string, any>;\n}\n\nexport interface FileListWhereParams {\n AND?: FileListWhereParams[];\n OR?: FileListWhereParams[];\n [key: string]: any;\n}\nexport interface FilesListOpts {\n search?: string;\n limit?: number;\n after?: string;\n where?: FileListWhereParams;\n sort?: string[];\n}\n\nexport interface FileListMeta {\n cursor: string | null;\n totalCount: number;\n hasMoreItems: boolean;\n}\n\ninterface FilesCrudListTagsWhere {\n tag?: string;\n tag_contains?: string;\n tag_in?: string[];\n tag_not_startsWith?: string;\n tag_startsWith?: string;\n}\ninterface FilesCrudListTagsParams {\n where?: FilesCrudListTagsWhere;\n limit?: number;\n after?: string;\n}\n\nexport interface ListTagsResponse {\n tag: string;\n count: number;\n}\nexport interface FilesCRUD extends FileLifecycleEvents {\n getFile(id: string): Promise<File>;\n listFiles(opts?: FilesListOpts): Promise<[File[], FileListMeta]>;\n listTags(params: FilesCrudListTagsParams): Promise<ListTagsResponse[]>;\n createFile(data: FileInput, meta?: Record<string, any>): Promise<File>;\n updateFile(id: string, data: Partial<FileInput>): Promise<File>;\n deleteFile(id: string): Promise<boolean>;\n createFilesInBatch(data: FileInput[], meta?: Record<string, any>): Promise<File[]>;\n}\n\nexport interface SystemCRUD {\n onSystemBeforeInstall: Topic;\n onSystemAfterInstall: Topic;\n getVersion(): Promise<string | null>;\n setVersion(version: string): Promise<void>;\n install(args: { srcPrefix: string }): Promise<boolean>;\n}\n\nexport interface FileManagerSettings {\n tenant: string;\n key: string;\n uploadMinFileSize: number;\n uploadMaxFileSize: number;\n srcPrefix: string;\n}\n\nexport interface FileManagerSystem {\n version: string;\n tenant: string;\n}\n\nexport type SettingsCRUD = {\n getSettings(): Promise<FileManagerSettings | null>;\n createSettings(data?: Partial<FileManagerSettings>): Promise<FileManagerSettings>;\n updateSettings(data: Partial<FileManagerSettings>): Promise<FileManagerSettings>;\n deleteSettings(): Promise<boolean>;\n};\n/********\n * Storage operations\n *******/\n\n/**\n * @category StorageOperations\n * @category SystemStorageOperations\n * @category SystemStorageOperationsParams\n */\nexport interface FileManagerSystemStorageOperationsUpdateParams {\n /**\n * The system data to be updated.\n */\n original: FileManagerSystem;\n /**\n * The system data with the updated fields.\n */\n data: FileManagerSystem;\n}\n/**\n * @category StorageOperations\n * @category SystemStorageOperations\n * @category SystemStorageOperationsParams\n */\nexport interface FileManagerSystemStorageOperationsCreateParams {\n /**\n * The system fields.\n */\n data: FileManagerSystem;\n}\n\nexport interface FileManagerSystemStorageOperationsGetParams {\n tenant: string;\n}\n\n/**\n * @category StorageOperations\n * @category SystemStorageOperations\n */\nexport interface FileManagerSystemStorageOperations {\n /**\n * Get the FileManager system data.\n */\n get: (params: FileManagerSystemStorageOperationsGetParams) => Promise<FileManagerSystem | null>;\n /**\n * Update the FileManager system data..\n */\n update: (params: FileManagerSystemStorageOperationsUpdateParams) => Promise<FileManagerSystem>;\n /**\n * Create the FileManagerSystemData\n */\n create: (params: FileManagerSystemStorageOperationsCreateParams) => Promise<FileManagerSystem>;\n}\n\n/**\n * @category StorageOperations\n * @category SettingsStorageOperations\n * @category SettingsStorageOperationsParams\n */\nexport interface FileManagerSettingsStorageOperationsUpdateParams {\n /**\n * Original settings to be updated.\n */\n original: FileManagerSettings;\n /**\n * The settings with the updated fields.\n */\n data: FileManagerSettings;\n}\n/**\n * @category StorageOperations\n * @category SettingsStorageOperations\n * @category SettingsStorageOperationsParams\n */\nexport interface FileManagerSettingsStorageOperationsCreateParams {\n /**\n * The settings fields.\n */\n data: FileManagerSettings;\n}\n\nexport interface FileManagerStorageOperationsGetSettingsParams {\n tenant: string;\n}\n\nexport interface FileManagerStorageOperationsDeleteSettings {\n tenant: string;\n}\n\n/**\n * @category StorageOperations\n * @category SettingsStorageOperations\n */\nexport interface FileManagerSettingsStorageOperations {\n /**\n * Get the FileManager system data.\n */\n get: (\n params: FileManagerStorageOperationsGetSettingsParams\n ) => Promise<FileManagerSettings | null>;\n /**\n * Create the FileManagerSettingsData\n */\n create: (\n params: FileManagerSettingsStorageOperationsCreateParams\n ) => Promise<FileManagerSettings>;\n /**\n * Update the FileManager system data..\n */\n update: (\n params: FileManagerSettingsStorageOperationsUpdateParams\n ) => Promise<FileManagerSettings>;\n /**\n * Delete the existing settings.\n */\n delete: (params: FileManagerStorageOperationsDeleteSettings) => Promise<void>;\n}\n\n/**\n * @category StorageOperations\n * @category FilesStorageOperations\n * @category FilesStorageOperationsParams\n */\nexport interface FileManagerFilesStorageOperationsGetParams {\n where: {\n id: string;\n tenant: string;\n locale: string;\n };\n}\n/**\n * @category StorageOperations\n * @category FilesStorageOperations\n * @category FilesStorageOperationsParams\n */\nexport interface FileManagerFilesStorageOperationsCreateParams {\n file: File;\n}\n/**\n * @category StorageOperations\n * @category FilesStorageOperations\n * @category FilesStorageOperationsParams\n */\nexport interface FileManagerFilesStorageOperationsUpdateParams {\n original: File;\n file: File;\n}\n\n/**\n * @category StorageOperations\n * @category FilesStorageOperations\n * @category FilesStorageOperationsParams\n */\nexport interface FileManagerFilesStorageOperationsDeleteParams {\n file: File;\n}\n/**\n * @category StorageOperations\n * @category FilesStorageOperations\n * @category FilesStorageOperationsParams\n */\nexport interface FileManagerFilesStorageOperationsCreateBatchParams {\n files: File[];\n}\n/**\n * @category StorageOperations\n * @category FilesStorageOperations\n * @category FilesStorageOperationsParams\n */\nexport interface FileManagerFilesStorageOperationsListParamsWhere {\n [key: string]: any;\n}\n/**\n * @category StorageOperations\n * @category FilesStorageOperations\n * @category FilesStorageOperationsParams\n */\nexport interface FileManagerFilesStorageOperationsListParams {\n where: FileManagerFilesStorageOperationsListParamsWhere;\n sort: string[];\n limit: number;\n after: string | null;\n search?: string;\n}\n\n/**\n * @category StorageOperations\n * @category FilesStorageOperations\n * @category FilesStorageOperationsParams\n */\nexport interface FileManagerFilesStorageOperationsListResponseMeta {\n hasMoreItems: boolean;\n totalCount: number;\n cursor: string | null;\n}\nexport type FileManagerFilesStorageOperationsListResponse = [\n File[],\n FileManagerFilesStorageOperationsListResponseMeta\n];\n\nexport interface FileManagerFilesStorageOperationsTagsResponse {\n tag: string;\n count: number;\n}\n\nexport interface FileManagerFilesStorageOperationsTagsParamsWhere extends FilesCrudListTagsWhere {\n locale: string;\n tenant: string;\n}\n/**\n * @category StorageOperations\n * @category FilesStorageOperations\n * @category FilesStorageOperationsParams\n */\nexport interface FileManagerFilesStorageOperationsTagsParams {\n where: FileManagerFilesStorageOperationsTagsParamsWhere;\n limit: number;\n after?: string;\n}\n/**\n * @category StorageOperations\n * @category FilesStorageOperations\n */\nexport interface FileManagerFilesStorageOperations {\n /**\n * Get a single file with given ID from the storage.\n */\n get: (params: FileManagerFilesStorageOperationsGetParams) => Promise<File | null>;\n /**\n * Insert the file data into the database.\n */\n create: (params: FileManagerFilesStorageOperationsCreateParams) => Promise<File>;\n /**\n * Update the file data in the database.\n */\n update: (params: FileManagerFilesStorageOperationsUpdateParams) => Promise<File>;\n /**\n * Delete the file from the database.\n */\n delete: (params: FileManagerFilesStorageOperationsDeleteParams) => Promise<void>;\n /**\n * Store multiple files at once to the database.\n */\n createBatch: (params: FileManagerFilesStorageOperationsCreateBatchParams) => Promise<File[]>;\n /**\n * Get a list of files filtered by given parameters.\n */\n list: (\n params: FileManagerFilesStorageOperationsListParams\n ) => Promise<FileManagerFilesStorageOperationsListResponse>;\n /**\n * Get a list of all file tags filtered by given parameters.\n */\n tags: (\n params: FileManagerFilesStorageOperationsTagsParams\n ) => Promise<FileManagerFilesStorageOperationsTagsResponse[]>;\n}\n\nexport interface FileManagerAliasesStorageOperations {\n storeAliases(file: File): Promise<void>;\n deleteAliases(file: File): Promise<void>;\n}\n\nexport interface FileManagerStorageOperations<TContext = FileManagerContext> {\n beforeInit?: (context: TContext) => Promise<void>;\n files: FileManagerFilesStorageOperations;\n aliases: FileManagerAliasesStorageOperations;\n settings: FileManagerSettingsStorageOperations;\n system: FileManagerSystemStorageOperations;\n}\n"],"mappings":";;;;;AASA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
1
+ {"version":3,"names":["_file","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_file2"],"sources":["types.ts"],"sourcesContent":["import type { I18NContext } from \"@webiny/api-i18n/types\";\nimport type { FileStorage } from \"./storage/FileStorage\";\nimport type { TenancyContext } from \"@webiny/api-tenancy/types\";\nimport type { SecurityContext, SecurityPermission } from \"@webiny/api-security/types\";\nimport type { Context } from \"@webiny/api/types\";\nimport type { FileLifecycleEvents } from \"./types/file.lifecycle\";\nimport type { CreatedBy, File } from \"./types/file\";\nimport type { Topic } from \"@webiny/pubsub/types\";\nimport type { CmsContext, CmsEntryListSort } from \"@webiny/api-headless-cms/types\";\nimport type { Context as TasksContext } from \"@webiny/tasks/types\";\n\nexport * from \"./types/file.lifecycle\";\nexport * from \"./types/file\";\nexport * from \"./types/file\";\n\nexport interface FileManagerContextObject extends FilesCRUD, SettingsCRUD, SystemCRUD {\n storage: FileStorage;\n}\n\nexport interface FileManagerContext\n extends Context,\n SecurityContext,\n TenancyContext,\n I18NContext,\n CmsContext,\n TasksContext {\n fileManager: FileManagerContextObject;\n}\n\nexport interface FilePermission extends SecurityPermission {\n name: \"fm.file\";\n rwd?: string;\n own?: boolean;\n}\n\nexport interface SettingsPermission extends SecurityPermission {\n name: \"fm.setting\";\n}\n\nexport interface FileInput {\n id: string;\n\n // In the background, we're actually mapping these to entry-level fields.\n // This is fine since we don't use revisions for files.\n createdOn?: string | Date | null;\n modifiedOn?: string | Date | null;\n savedOn?: string | Date | null;\n createdBy?: CreatedBy | null;\n modifiedBy?: CreatedBy | null;\n savedBy?: CreatedBy | null;\n\n key: string;\n name: string;\n size: number;\n type: string;\n meta: Record<string, any>;\n location?: {\n folderId: string;\n };\n tags: string[];\n aliases: string[];\n extensions?: Record<string, any>;\n}\n\nexport interface FileListWhereParams {\n AND?: FileListWhereParams[];\n OR?: FileListWhereParams[];\n [key: string]: any;\n}\nexport interface FilesListOpts {\n search?: string;\n limit?: number;\n after?: string;\n where?: FileListWhereParams;\n sort?: CmsEntryListSort;\n}\n\nexport interface FileListMeta {\n cursor: string | null;\n totalCount: number;\n hasMoreItems: boolean;\n}\n\ninterface FilesCrudListTagsWhere {\n tag?: string;\n tag_contains?: string;\n tag_in?: string[];\n tag_not_startsWith?: string;\n tag_startsWith?: string;\n}\ninterface FilesCrudListTagsParams {\n where?: FilesCrudListTagsWhere;\n limit?: number;\n after?: string;\n}\n\nexport interface ListTagsResponse {\n tag: string;\n count: number;\n}\nexport interface FilesCRUD extends FileLifecycleEvents {\n getFile(id: string): Promise<File>;\n listFiles(opts?: FilesListOpts): Promise<[File[], FileListMeta]>;\n listTags(params: FilesCrudListTagsParams): Promise<ListTagsResponse[]>;\n createFile(data: FileInput, meta?: Record<string, any>): Promise<File>;\n updateFile(id: string, data: Partial<FileInput>): Promise<File>;\n deleteFile(id: string): Promise<boolean>;\n createFilesInBatch(data: FileInput[], meta?: Record<string, any>): Promise<File[]>;\n}\n\nexport interface SystemCRUD {\n onSystemBeforeInstall: Topic;\n onSystemAfterInstall: Topic;\n getVersion(): Promise<string | null>;\n setVersion(version: string): Promise<void>;\n install(args: { srcPrefix: string }): Promise<boolean>;\n}\n\nexport interface FileManagerSettings {\n tenant: string;\n uploadMinFileSize: number;\n uploadMaxFileSize: number;\n srcPrefix: string;\n}\n\nexport interface FileManagerSystem {\n version: string;\n tenant: string;\n}\n\nexport interface OnSettingsBeforeUpdateTopicParams {\n input: Partial<FileManagerSettings>;\n original: FileManagerSettings;\n settings: FileManagerSettings;\n}\n\nexport interface OnSettingsAfterUpdateTopicParams {\n input: Partial<FileManagerSettings>;\n original: FileManagerSettings;\n settings: FileManagerSettings;\n}\n\nexport type SettingsCRUD = {\n getSettings(): Promise<FileManagerSettings | null>;\n createSettings(data?: Partial<FileManagerSettings>): Promise<FileManagerSettings>;\n updateSettings(data: Partial<FileManagerSettings>): Promise<FileManagerSettings>;\n deleteSettings(): Promise<boolean>;\n\n onSettingsBeforeUpdate: Topic<OnSettingsBeforeUpdateTopicParams>;\n onSettingsAfterUpdate: Topic<OnSettingsAfterUpdateTopicParams>;\n};\n/********\n * Storage operations\n *******/\n\n/**\n * @category StorageOperations\n * @category SystemStorageOperations\n * @category SystemStorageOperationsParams\n */\nexport interface FileManagerSystemStorageOperationsUpdateParams {\n /**\n * The system data to be updated.\n */\n original: FileManagerSystem;\n /**\n * The system data with the updated fields.\n */\n data: FileManagerSystem;\n}\n/**\n * @category StorageOperations\n * @category SystemStorageOperations\n * @category SystemStorageOperationsParams\n */\nexport interface FileManagerSystemStorageOperationsCreateParams {\n /**\n * The system fields.\n */\n data: FileManagerSystem;\n}\n\nexport interface FileManagerSystemStorageOperationsGetParams {\n tenant: string;\n}\n\n/**\n * @category StorageOperations\n * @category SystemStorageOperations\n */\nexport interface FileManagerSystemStorageOperations {\n /**\n * Get the FileManager system data.\n */\n get: (params: FileManagerSystemStorageOperationsGetParams) => Promise<FileManagerSystem | null>;\n /**\n * Update the FileManager system data..\n */\n update: (params: FileManagerSystemStorageOperationsUpdateParams) => Promise<FileManagerSystem>;\n /**\n * Create the FileManagerSystemData\n */\n create: (params: FileManagerSystemStorageOperationsCreateParams) => Promise<FileManagerSystem>;\n}\n\n/**\n * @category StorageOperations\n * @category SettingsStorageOperations\n * @category SettingsStorageOperationsParams\n */\nexport interface FileManagerSettingsStorageOperationsUpdateParams {\n /**\n * Original settings to be updated.\n */\n original: FileManagerSettings;\n /**\n * The settings with the updated fields.\n */\n data: FileManagerSettings;\n}\n/**\n * @category StorageOperations\n * @category SettingsStorageOperations\n * @category SettingsStorageOperationsParams\n */\nexport interface FileManagerSettingsStorageOperationsCreateParams {\n /**\n * The settings fields.\n */\n data: FileManagerSettings;\n}\n\nexport interface FileManagerStorageOperationsGetSettingsParams {\n tenant: string;\n}\n\nexport interface FileManagerStorageOperationsDeleteSettings {\n tenant: string;\n}\n\n/**\n * @category StorageOperations\n * @category SettingsStorageOperations\n */\nexport interface FileManagerSettingsStorageOperations {\n /**\n * Get the FileManager system data.\n */\n get: (\n params: FileManagerStorageOperationsGetSettingsParams\n ) => Promise<FileManagerSettings | null>;\n /**\n * Create the FileManagerSettingsData\n */\n create: (\n params: FileManagerSettingsStorageOperationsCreateParams\n ) => Promise<FileManagerSettings>;\n /**\n * Update the FileManager system data..\n */\n update: (\n params: FileManagerSettingsStorageOperationsUpdateParams\n ) => Promise<FileManagerSettings>;\n /**\n * Delete the existing settings.\n */\n delete: (params: FileManagerStorageOperationsDeleteSettings) => Promise<void>;\n}\n\n/**\n * @category StorageOperations\n * @category FilesStorageOperations\n * @category FilesStorageOperationsParams\n */\nexport interface FileManagerFilesStorageOperationsGetParams {\n where: {\n id: string;\n tenant: string;\n locale: string;\n };\n}\n/**\n * @category StorageOperations\n * @category FilesStorageOperations\n * @category FilesStorageOperationsParams\n */\nexport interface FileManagerFilesStorageOperationsCreateParams {\n file: File;\n}\n/**\n * @category StorageOperations\n * @category FilesStorageOperations\n * @category FilesStorageOperationsParams\n */\nexport interface FileManagerFilesStorageOperationsUpdateParams {\n original: File;\n file: File;\n}\n\n/**\n * @category StorageOperations\n * @category FilesStorageOperations\n * @category FilesStorageOperationsParams\n */\nexport interface FileManagerFilesStorageOperationsDeleteParams {\n file: File;\n}\n/**\n * @category StorageOperations\n * @category FilesStorageOperations\n * @category FilesStorageOperationsParams\n */\nexport interface FileManagerFilesStorageOperationsCreateBatchParams {\n files: File[];\n}\n/**\n * @category StorageOperations\n * @category FilesStorageOperations\n * @category FilesStorageOperationsParams\n */\nexport interface FileManagerFilesStorageOperationsListParamsWhere {\n [key: string]: any;\n}\n/**\n * @category StorageOperations\n * @category FilesStorageOperations\n * @category FilesStorageOperationsParams\n */\nexport interface FileManagerFilesStorageOperationsListParams {\n where: FileManagerFilesStorageOperationsListParamsWhere;\n sort: CmsEntryListSort;\n limit: number;\n after: string | null;\n search?: string;\n}\n\n/**\n * @category StorageOperations\n * @category FilesStorageOperations\n * @category FilesStorageOperationsParams\n */\nexport interface FileManagerFilesStorageOperationsListResponseMeta {\n hasMoreItems: boolean;\n totalCount: number;\n cursor: string | null;\n}\nexport type FileManagerFilesStorageOperationsListResponse = [\n File[],\n FileManagerFilesStorageOperationsListResponseMeta\n];\n\nexport interface FileManagerFilesStorageOperationsTagsResponse {\n tag: string;\n count: number;\n}\n\nexport interface FileManagerFilesStorageOperationsTagsParamsWhere extends FilesCrudListTagsWhere {\n locale: string;\n tenant: string;\n}\n/**\n * @category StorageOperations\n * @category FilesStorageOperations\n * @category FilesStorageOperationsParams\n */\nexport interface FileManagerFilesStorageOperationsTagsParams {\n where: FileManagerFilesStorageOperationsTagsParamsWhere;\n limit: number;\n after?: string;\n}\n/**\n * @category StorageOperations\n * @category FilesStorageOperations\n */\nexport interface FileManagerFilesStorageOperations {\n /**\n * Get a single file with given ID from the storage.\n */\n get: (params: FileManagerFilesStorageOperationsGetParams) => Promise<File | null>;\n /**\n * Insert the file data into the database.\n */\n create: (params: FileManagerFilesStorageOperationsCreateParams) => Promise<File>;\n /**\n * Update the file data in the database.\n */\n update: (params: FileManagerFilesStorageOperationsUpdateParams) => Promise<File>;\n /**\n * Delete the file from the database.\n */\n delete: (params: FileManagerFilesStorageOperationsDeleteParams) => Promise<void>;\n /**\n * Store multiple files at once to the database.\n */\n createBatch: (params: FileManagerFilesStorageOperationsCreateBatchParams) => Promise<File[]>;\n /**\n * Get a list of files filtered by given parameters.\n */\n list: (\n params: FileManagerFilesStorageOperationsListParams\n ) => Promise<FileManagerFilesStorageOperationsListResponse>;\n /**\n * Get a list of all file tags filtered by given parameters.\n */\n tags: (\n params: FileManagerFilesStorageOperationsTagsParams\n ) => Promise<FileManagerFilesStorageOperationsTagsResponse[]>;\n}\n\nexport interface FileManagerAliasesStorageOperations {\n storeAliases(file: File): Promise<void>;\n deleteAliases(file: File): Promise<void>;\n}\n\nexport interface FileManagerStorageOperations<TContext = FileManagerContext> {\n beforeInit?: (context: TContext) => Promise<void>;\n files: FileManagerFilesStorageOperations;\n aliases: FileManagerAliasesStorageOperations;\n settings: FileManagerSettingsStorageOperations;\n system: FileManagerSystemStorageOperations;\n}\n"],"mappings":";;;;;AAWA,IAAAA,KAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,KAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,KAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,KAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,MAAA,GAAAT,OAAA;AACAC,MAAA,CAAAC,IAAA,CAAAO,MAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,MAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,MAAA,CAAAL,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
@@ -1,5 +0,0 @@
1
- import { CmsGroupPlugin } from "@webiny/api-headless-cms";
2
- export declare const createFileManagerPlugins: () => {
3
- groupPlugin: CmsGroupPlugin;
4
- fileModelDefinition: import("@webiny/api-headless-cms").CmsPrivateModelFull;
5
- };
@@ -1,34 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createFileManagerPlugins = void 0;
7
- var _apiHeadlessCms = require("@webiny/api-headless-cms");
8
- var _file = require("./file.model");
9
- // import { modelFactory } from "~/cmsFileStorage/modelFactory";
10
-
11
- const createFileManagerPlugins = () => {
12
- const groupId = "contentModelGroup_fm";
13
- const groupPlugin = new _apiHeadlessCms.CmsGroupPlugin({
14
- id: groupId,
15
- slug: "fileManager",
16
- name: "File Manager",
17
- description: "Group for File Manager models",
18
- icon: "fas/folder",
19
- isPrivate: true
20
- });
21
-
22
- // const models = modelDefinitions.map(modelDefinition => {
23
- // return modelFactory({
24
- // group: cmsGroupPlugin.contentModelGroup,
25
- // modelDefinition
26
- // });
27
- // });
28
-
29
- return {
30
- groupPlugin,
31
- fileModelDefinition: (0, _file.createFileModelDefinition)(groupPlugin.contentModelGroup)
32
- };
33
- };
34
- exports.createFileManagerPlugins = createFileManagerPlugins;
@@ -1 +0,0 @@
1
- {"version":3,"names":["createFileManagerPlugins","groupId","groupPlugin","CmsGroupPlugin","id","slug","name","description","icon","isPrivate","fileModelDefinition","createFileModelDefinition","contentModelGroup"],"sources":["createFileManagerPlugins.ts"],"sourcesContent":["import { CmsGroupPlugin } from \"@webiny/api-headless-cms\";\n// import { modelFactory } from \"~/cmsFileStorage/modelFactory\";\nimport { createFileModelDefinition } from \"~/cmsFileStorage/file.model\";\n\nexport const createFileManagerPlugins = () => {\n const groupId = \"contentModelGroup_fm\";\n\n const groupPlugin = new CmsGroupPlugin({\n id: groupId,\n slug: \"fileManager\",\n name: \"File Manager\",\n description: \"Group for File Manager models\",\n icon: \"fas/folder\",\n isPrivate: true\n });\n\n // const models = modelDefinitions.map(modelDefinition => {\n // return modelFactory({\n // group: cmsGroupPlugin.contentModelGroup,\n // modelDefinition\n // });\n // });\n\n return {\n groupPlugin,\n fileModelDefinition: createFileModelDefinition(groupPlugin.contentModelGroup)\n };\n};\n"],"mappings":";;;;;;AAAA;AAEA;AADA;;AAGO,MAAMA,wBAAwB,GAAG,MAAM;EAC1C,MAAMC,OAAO,GAAG,sBAAsB;EAEtC,MAAMC,WAAW,GAAG,IAAIC,8BAAc,CAAC;IACnCC,EAAE,EAAEH,OAAO;IACXI,IAAI,EAAE,aAAa;IACnBC,IAAI,EAAE,cAAc;IACpBC,WAAW,EAAE,+BAA+B;IAC5CC,IAAI,EAAE,YAAY;IAClBC,SAAS,EAAE;EACf,CAAC,CAAC;;EAEF;EACA;EACA;EACA;EACA;EACA;;EAEA,OAAO;IACHP,WAAW;IACXQ,mBAAmB,EAAE,IAAAC,+BAAyB,EAACT,WAAW,CAACU,iBAAiB;EAChF,CAAC;AACL,CAAC;AAAC"}
@@ -1,5 +0,0 @@
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;
@@ -1,37 +0,0 @@
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
- settings = {},
15
- listValidation = [],
16
- validation = [],
17
- multipleValues = false,
18
- predefinedValues = {
19
- values: [],
20
- enabled: false
21
- }
22
- } = params;
23
- const fieldId = initialFieldId ? (0, _camelCase.default)(initialFieldId) : (0, _camelCase.default)(label);
24
- return {
25
- id: fieldId,
26
- storageId: `${type}@${fieldId}`,
27
- fieldId,
28
- label,
29
- type,
30
- settings,
31
- listValidation,
32
- validation,
33
- multipleValues,
34
- predefinedValues
35
- };
36
- };
37
- exports.createModelField = createModelField;
@@ -1 +0,0 @@
1
- {"version":3,"names":["createModelField","params","label","fieldId","initialFieldId","type","settings","listValidation","validation","multipleValues","predefinedValues","values","enabled","camelCase","id","storageId"],"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 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 listValidation,\n validation,\n multipleValues,\n predefinedValues\n };\n};\n"],"mappings":";;;;;;;AACA;AAOO,MAAMA,gBAAgB,GAAIC,MAA8B,IAAoB;EAC/E,MAAM;IACFC,KAAK;IACLC,OAAO,EAAEC,cAAc;IACvBC,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,GAAGX,MAAM;EAEV,MAAME,OAAO,GAAGC,cAAc,GAAG,IAAAS,kBAAS,EAACT,cAAc,CAAC,GAAG,IAAAS,kBAAS,EAACX,KAAK,CAAC;EAE7E,OAAO;IACHY,EAAE,EAAEX,OAAO;IACXY,SAAS,EAAG,GAAEV,IAAK,IAAGF,OAAQ,EAAC;IAC/BA,OAAO;IACPD,KAAK;IACLG,IAAI;IACJC,QAAQ;IACRC,cAAc;IACdC,UAAU;IACVC,cAAc;IACdC;EACJ,CAAC;AACL,CAAC;AAAC"}
@@ -1,4 +0,0 @@
1
- import { FileManagerContext } from "../types";
2
- declare type CheckInstallationParams = Pick<FileManagerContext, "tenancy" | "i18n">;
3
- export declare const isInstallationPending: ({ tenancy, i18n }: CheckInstallationParams) => boolean;
4
- export {};
@@ -1,21 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.isInstallationPending = void 0;
7
- const isInstallationPending = ({
8
- tenancy,
9
- i18n
10
- }) => {
11
- /**
12
- * In case of a fresh webiny project "tenant" and "locale" won't be there until
13
- * installation is completed. So, we need to skip "storage" creation till then.
14
- */
15
- const tenant = tenancy.getCurrentTenant();
16
- if (!tenant) {
17
- return true;
18
- }
19
- return !i18n.getContentLocale();
20
- };
21
- exports.isInstallationPending = isInstallationPending;
@@ -1 +0,0 @@
1
- {"version":3,"names":["isInstallationPending","tenancy","i18n","tenant","getCurrentTenant","getContentLocale"],"sources":["isInstallationPending.ts"],"sourcesContent":["import { FileManagerContext } from \"~/types\";\n\ntype CheckInstallationParams = Pick<FileManagerContext, \"tenancy\" | \"i18n\">;\nexport const isInstallationPending = ({ tenancy, i18n }: CheckInstallationParams): boolean => {\n /**\n * In case of a fresh webiny project \"tenant\" and \"locale\" won't be there until\n * installation is completed. So, we need to skip \"storage\" creation till then.\n */\n const tenant = tenancy.getCurrentTenant();\n if (!tenant) {\n return true;\n }\n\n return !i18n.getContentLocale();\n};\n"],"mappings":";;;;;;AAGO,MAAMA,qBAAqB,GAAG,CAAC;EAAEC,OAAO;EAAEC;AAA8B,CAAC,KAAc;EAC1F;AACJ;AACA;AACA;EACI,MAAMC,MAAM,GAAGF,OAAO,CAACG,gBAAgB,EAAE;EACzC,IAAI,CAACD,MAAM,EAAE;IACT,OAAO,IAAI;EACf;EAEA,OAAO,CAACD,IAAI,CAACG,gBAAgB,EAAE;AACnC,CAAC;AAAC"}
File without changes
@@ -1,55 +0,0 @@
1
- // /**
2
- // * Package @commodo/fields does not have types
3
- // */
4
- // // @ts-ignore
5
- // import { withFields, string, number, onSet } from "@commodo/fields";
6
- // /**
7
- // * Package commodo-fields-object does not have types
8
- // */
9
- // // @ts-ignore
10
- // import { object } from "commodo-fields-object";
11
- // import { validation } from "@webiny/validation";
12
- //
13
- // export default (create = true) => {
14
- // return withFields({
15
- // key: string({
16
- // validation: validation.create(`${create ? "required," : ""}maxLength:1000`)
17
- // }),
18
- // name: string({ validation: validation.create("maxLength:1000") }),
19
- // size: number(),
20
- // type: string({ validation: validation.create("maxLength:255") }),
21
- // meta: object({ value: { private: false } }),
22
- // tags: onSet((value: string[]) => {
23
- // if (!Array.isArray(value)) {
24
- // return null;
25
- // }
26
- //
27
- // return value.map(item => item.toLowerCase());
28
- // })(
29
- // string({
30
- // list: true,
31
- // validation: (tags: string[]) => {
32
- // if (!Array.isArray(tags)) {
33
- // return;
34
- // }
35
- //
36
- // if (tags.length > 15) {
37
- // throw Error("You cannot set more than 15 tags.");
38
- // }
39
- //
40
- // for (let i = 0; i < tags.length; i++) {
41
- // const tag = tags[i];
42
- // if (typeof tag !== "string") {
43
- // throw Error("Tag must be typeof string.");
44
- // }
45
- //
46
- // if (tag.length > 50) {
47
- // throw Error(`Tag ${tag} is more than 50 characters long.`);
48
- // }
49
- // }
50
- // }
51
- // })
52
- // )
53
- // })();
54
- // };
55
- "use strict";
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sources":["filevalidation.disabled.ts"],"sourcesContent":["// /**\n// * Package @commodo/fields does not have types\n// */\n// // @ts-ignore\n// import { withFields, string, number, onSet } from \"@commodo/fields\";\n// /**\n// * Package commodo-fields-object does not have types\n// */\n// // @ts-ignore\n// import { object } from \"commodo-fields-object\";\n// import { validation } from \"@webiny/validation\";\n//\n// export default (create = true) => {\n// return withFields({\n// key: string({\n// validation: validation.create(`${create ? \"required,\" : \"\"}maxLength:1000`)\n// }),\n// name: string({ validation: validation.create(\"maxLength:1000\") }),\n// size: number(),\n// type: string({ validation: validation.create(\"maxLength:255\") }),\n// meta: object({ value: { private: false } }),\n// tags: onSet((value: string[]) => {\n// if (!Array.isArray(value)) {\n// return null;\n// }\n//\n// return value.map(item => item.toLowerCase());\n// })(\n// string({\n// list: true,\n// validation: (tags: string[]) => {\n// if (!Array.isArray(tags)) {\n// return;\n// }\n//\n// if (tags.length > 15) {\n// throw Error(\"You cannot set more than 15 tags.\");\n// }\n//\n// for (let i = 0; i < tags.length; i++) {\n// const tag = tags[i];\n// if (typeof tag !== \"string\") {\n// throw Error(\"Tag must be typeof string.\");\n// }\n//\n// if (tag.length > 50) {\n// throw Error(`Tag ${tag} is more than 50 characters long.`);\n// }\n// }\n// }\n// })\n// )\n// })();\n// };\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA"}
@@ -1,6 +0,0 @@
1
- import { DocumentClient } from "aws-sdk/clients/dynamodb";
2
- import { RoutePlugin } from "@webiny/handler-aws/gateway";
3
- export interface DownloadByFileAliasConfig {
4
- documentClient: DocumentClient;
5
- }
6
- export declare const createDownloadFileByAliasPlugins: ({ documentClient }: DownloadByFileAliasConfig) => RoutePlugin<import("@webiny/handler/types").Context>[];