@webiny/api-file-manager 0.0.0-unstable.bca7b3e350 → 0.0.0-unstable.c59b9cc5b9

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 (135) hide show
  1. package/createFileManager/checkBasePermissions.d.ts +5 -0
  2. package/{plugins/crud/utils → createFileManager}/checkBasePermissions.js +4 -13
  3. package/createFileManager/checkBasePermissions.js.map +1 -0
  4. package/createFileManager/files.crud.d.ts +3 -0
  5. package/{plugins/crud → createFileManager}/files.crud.js +95 -204
  6. package/createFileManager/files.crud.js.map +1 -0
  7. package/createFileManager/filevalidation.disabled.d.ts +0 -0
  8. package/createFileManager/filevalidation.disabled.js +55 -0
  9. package/createFileManager/filevalidation.disabled.js.map +1 -0
  10. package/createFileManager/index.d.ts +13 -0
  11. package/createFileManager/index.js +20 -0
  12. package/createFileManager/index.js.map +1 -0
  13. package/createFileManager/settings.crud.d.ts +3 -0
  14. package/{plugins/crud → createFileManager}/settings.crud.js +27 -52
  15. package/createFileManager/settings.crud.js.map +1 -0
  16. package/createFileManager/system.crud.d.ts +3 -0
  17. package/createFileManager/system.crud.js +86 -0
  18. package/createFileManager/system.crud.js.map +1 -0
  19. package/graphql/index.d.ts +3 -0
  20. package/{plugins/graphql.js → graphql/index.js} +66 -68
  21. package/graphql/index.js.map +1 -0
  22. package/handlers/download/byAlias.d.ts +6 -0
  23. package/handlers/download/byAlias.js +89 -0
  24. package/handlers/download/byAlias.js.map +1 -0
  25. package/handlers/download/byExactKey.d.ts +2 -0
  26. package/handlers/download/byExactKey.js +57 -0
  27. package/handlers/download/byExactKey.js.map +1 -0
  28. package/handlers/download/extractFileInformation.d.ts +9 -0
  29. package/handlers/download/extractFileInformation.js +20 -0
  30. package/handlers/download/extractFileInformation.js.map +1 -0
  31. package/handlers/download/getS3Object.d.ts +10 -0
  32. package/handlers/download/getS3Object.js +57 -0
  33. package/handlers/download/getS3Object.js.map +1 -0
  34. package/handlers/download/index.d.ts +2 -3
  35. package/handlers/download/index.js +21 -126
  36. package/handlers/download/index.js.map +1 -1
  37. package/handlers/manage/index.js +0 -16
  38. package/handlers/manage/index.js.map +1 -1
  39. package/handlers/transform/index.js +19 -21
  40. package/handlers/transform/index.js.map +1 -1
  41. package/handlers/transform/legacyUtils.d.ts +17 -0
  42. package/handlers/transform/legacyUtils.js +42 -0
  43. package/handlers/transform/legacyUtils.js.map +1 -0
  44. package/handlers/transform/loaders/imageLoader.d.ts +1 -1
  45. package/handlers/transform/loaders/imageLoader.js +12 -23
  46. package/handlers/transform/loaders/imageLoader.js.map +1 -1
  47. package/handlers/transform/loaders/index.d.ts +1 -1
  48. package/handlers/transform/loaders/index.js +0 -3
  49. package/handlers/transform/loaders/index.js.map +1 -1
  50. package/handlers/transform/loaders/sanitizeImageTransformations.js +0 -13
  51. package/handlers/transform/loaders/sanitizeImageTransformations.js.map +1 -1
  52. package/handlers/transform/managers/imageManager.js +32 -21
  53. package/handlers/transform/managers/imageManager.js.map +1 -1
  54. package/handlers/transform/managers/index.js +0 -3
  55. package/handlers/transform/managers/index.js.map +1 -1
  56. package/handlers/transform/optimizeImage.js +0 -6
  57. package/handlers/transform/optimizeImage.js.map +1 -1
  58. package/handlers/transform/transformImage.js +0 -5
  59. package/handlers/transform/transformImage.js.map +1 -1
  60. package/handlers/transform/utils.d.ts +1 -1
  61. package/handlers/transform/utils.js +7 -17
  62. package/handlers/transform/utils.js.map +1 -1
  63. package/handlers/utils/getEnvironment.js +0 -2
  64. package/handlers/utils/getEnvironment.js.map +1 -1
  65. package/handlers/utils/getObjectParams.js +0 -4
  66. package/handlers/utils/getObjectParams.js.map +1 -1
  67. package/handlers/utils/index.js +0 -3
  68. package/handlers/utils/index.js.map +1 -1
  69. package/index.d.ts +6 -0
  70. package/index.js +68 -0
  71. package/index.js.map +1 -0
  72. package/package.json +28 -30
  73. package/plugins/{definitions/FilePhysicalStoragePlugin.d.ts → FilePhysicalStoragePlugin.d.ts} +1 -1
  74. package/plugins/{definitions/FilePhysicalStoragePlugin.js → FilePhysicalStoragePlugin.js} +0 -11
  75. package/plugins/{definitions/FilePhysicalStoragePlugin.js.map → FilePhysicalStoragePlugin.js.map} +1 -1
  76. package/plugins/{definitions/FileStorageTransformPlugin.d.ts → FileStorageTransformPlugin.d.ts} +1 -1
  77. package/plugins/{definitions/FileStorageTransformPlugin.js → FileStorageTransformPlugin.js} +1 -12
  78. package/plugins/{definitions/FileStorageTransformPlugin.js.map → FileStorageTransformPlugin.js.map} +1 -1
  79. package/plugins/index.d.ts +2 -2
  80. package/plugins/index.js +22 -19
  81. package/plugins/index.js.map +1 -1
  82. package/{plugins/storage → storage}/FileStorage.d.ts +6 -4
  83. package/{plugins/storage → storage}/FileStorage.js +29 -46
  84. package/storage/FileStorage.js.map +1 -0
  85. package/types/file.d.ts +33 -0
  86. package/types/file.js +5 -0
  87. package/types/file.js.map +1 -0
  88. package/types/file.lifecycle.d.ts +44 -0
  89. package/types/file.lifecycle.js +5 -0
  90. package/types/file.lifecycle.js.map +1 -0
  91. package/types.d.ts +46 -47
  92. package/types.js +22 -0
  93. package/types.js.map +1 -1
  94. package/plugins/crud/files/validation.d.ts +0 -3
  95. package/plugins/crud/files/validation.js +0 -41
  96. package/plugins/crud/files/validation.js.map +0 -1
  97. package/plugins/crud/files.crud.d.ts +0 -4
  98. package/plugins/crud/files.crud.js.map +0 -1
  99. package/plugins/crud/settings.crud.d.ts +0 -5
  100. package/plugins/crud/settings.crud.js.map +0 -1
  101. package/plugins/crud/system.crud.d.ts +0 -4
  102. package/plugins/crud/system.crud.js +0 -153
  103. package/plugins/crud/system.crud.js.map +0 -1
  104. package/plugins/crud/utils/checkBasePermissions.d.ts +0 -5
  105. package/plugins/crud/utils/checkBasePermissions.js.map +0 -1
  106. package/plugins/crud/utils/createFileModel.d.ts +0 -5
  107. package/plugins/crud/utils/createFileModel.js +0 -77
  108. package/plugins/crud/utils/createFileModel.js.map +0 -1
  109. package/plugins/crud/utils/lifecycleEvents.d.ts +0 -6
  110. package/plugins/crud/utils/lifecycleEvents.js +0 -38
  111. package/plugins/crud/utils/lifecycleEvents.js.map +0 -1
  112. package/plugins/definitions/FilePlugin.d.ts +0 -136
  113. package/plugins/definitions/FilePlugin.js +0 -70
  114. package/plugins/definitions/FilePlugin.js.map +0 -1
  115. package/plugins/definitions/FilesStorageOperationsProviderPlugin.d.ts +0 -9
  116. package/plugins/definitions/FilesStorageOperationsProviderPlugin.js +0 -17
  117. package/plugins/definitions/FilesStorageOperationsProviderPlugin.js.map +0 -1
  118. package/plugins/definitions/InstallationPlugin.d.ts +0 -19
  119. package/plugins/definitions/InstallationPlugin.js +0 -42
  120. package/plugins/definitions/InstallationPlugin.js.map +0 -1
  121. package/plugins/definitions/SettingsStorageOperationsProviderPlugin.d.ts +0 -9
  122. package/plugins/definitions/SettingsStorageOperationsProviderPlugin.js +0 -17
  123. package/plugins/definitions/SettingsStorageOperationsProviderPlugin.js.map +0 -1
  124. package/plugins/definitions/SystemStorageOperationsProviderPlugin.d.ts +0 -9
  125. package/plugins/definitions/SystemStorageOperationsProviderPlugin.js +0 -17
  126. package/plugins/definitions/SystemStorageOperationsProviderPlugin.js.map +0 -1
  127. package/plugins/graphql.d.ts +0 -4
  128. package/plugins/graphql.js.map +0 -1
  129. package/plugins/storage/FileStorage.js.map +0 -1
  130. package/plugins/storage/index.d.ts +0 -4
  131. package/plugins/storage/index.js +0 -26
  132. package/plugins/storage/index.js.map +0 -1
  133. package/utils.d.ts +0 -4
  134. package/utils.js +0 -16
  135. package/utils.js.map +0 -1
@@ -0,0 +1,5 @@
1
+ import { GetPermission } from "@webiny/api-security/types";
2
+ import { FilePermission } from "../types";
3
+ export declare const checkBasePermissions: (getPermission: GetPermission, check?: {
4
+ rwd?: string;
5
+ }) => Promise<FilePermission>;
@@ -3,31 +3,22 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = void 0;
7
-
6
+ exports.checkBasePermissions = void 0;
8
7
  var _apiSecurity = require("@webiny/api-security");
9
-
10
- var _default = async (context, check = {}) => {
11
- await context.i18n.checkI18NContentPermission();
12
- const filePermission = await context.security.getPermission("fm.file");
13
-
8
+ const checkBasePermissions = async (getPermission, check = {}) => {
9
+ const filePermission = await getPermission("fm.file");
14
10
  if (!filePermission) {
15
11
  throw new _apiSecurity.NotAuthorizedError();
16
12
  }
17
-
18
13
  if (check.rwd && !hasRwd(filePermission, check.rwd)) {
19
14
  throw new _apiSecurity.NotAuthorizedError();
20
15
  }
21
-
22
16
  return filePermission;
23
17
  };
24
-
25
- exports.default = _default;
26
-
18
+ exports.checkBasePermissions = checkBasePermissions;
27
19
  const hasRwd = (filesFilePermission, rwd) => {
28
20
  if (typeof filesFilePermission.rwd !== "string") {
29
21
  return true;
30
22
  }
31
-
32
23
  return filesFilePermission.rwd.includes(rwd);
33
24
  };
@@ -0,0 +1 @@
1
+ {"version":3,"names":["checkBasePermissions","getPermission","check","filePermission","NotAuthorizedError","rwd","hasRwd","filesFilePermission","includes"],"sources":["checkBasePermissions.ts"],"sourcesContent":["import { NotAuthorizedError } from \"@webiny/api-security\";\nimport { GetPermission } from \"@webiny/api-security/types\";\nimport { FilePermission } from \"~/types\";\n\nexport const checkBasePermissions = async (\n getPermission: GetPermission,\n check: { rwd?: string } = {}\n): Promise<FilePermission> => {\n const filePermission = await getPermission<FilePermission>(\"fm.file\");\n\n if (!filePermission) {\n throw new NotAuthorizedError();\n }\n if (check.rwd && !hasRwd(filePermission, check.rwd)) {\n throw new NotAuthorizedError();\n }\n\n return filePermission;\n};\n\nconst hasRwd = (filesFilePermission: FilePermission, rwd: string): boolean => {\n if (typeof filesFilePermission.rwd !== \"string\") {\n return true;\n }\n\n return filesFilePermission.rwd.includes(rwd);\n};\n"],"mappings":";;;;;;AAAA;AAIO,MAAMA,oBAAoB,GAAG,OAChCC,aAA4B,EAC5BC,KAAuB,GAAG,CAAC,CAAC,KACF;EAC1B,MAAMC,cAAc,GAAG,MAAMF,aAAa,CAAiB,SAAS,CAAC;EAErE,IAAI,CAACE,cAAc,EAAE;IACjB,MAAM,IAAIC,+BAAkB,EAAE;EAClC;EACA,IAAIF,KAAK,CAACG,GAAG,IAAI,CAACC,MAAM,CAACH,cAAc,EAAED,KAAK,CAACG,GAAG,CAAC,EAAE;IACjD,MAAM,IAAID,+BAAkB,EAAE;EAClC;EAEA,OAAOD,cAAc;AACzB,CAAC;AAAC;AAEF,MAAMG,MAAM,GAAG,CAACC,mBAAmC,EAAEF,GAAW,KAAc;EAC1E,IAAI,OAAOE,mBAAmB,CAACF,GAAG,KAAK,QAAQ,EAAE;IAC7C,OAAO,IAAI;EACf;EAEA,OAAOE,mBAAmB,CAACF,GAAG,CAACG,QAAQ,CAACH,GAAG,CAAC;AAChD,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { FilesCRUD } from "../types";
2
+ import { FileManagerConfig } from "./index";
3
+ export declare const createFilesCrud: (config: FileManagerConfig) => FilesCRUD;
@@ -1,147 +1,97 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
- exports.default = void 0;
9
-
7
+ exports.createFilesCrud = void 0;
10
8
  var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
-
12
- var _mdbid = _interopRequireDefault(require("mdbid"));
13
-
14
9
  var _handlerGraphql = require("@webiny/handler-graphql");
15
-
16
10
  var _apiSecurity = require("@webiny/api-security");
17
-
18
- var _checkBasePermissions = _interopRequireDefault(require("./utils/checkBasePermissions"));
19
-
20
- var _api = require("@webiny/api");
21
-
22
- var _FilePlugin = require("../definitions/FilePlugin");
23
-
24
- var _FilesStorageOperationsProviderPlugin = require("../definitions/FilesStorageOperationsProviderPlugin");
25
-
11
+ var _pubsub = require("@webiny/pubsub");
26
12
  var _error = _interopRequireDefault(require("@webiny/error"));
27
-
28
- var _lifecycleEvents = require("./utils/lifecycleEvents");
29
-
30
- /**
31
- * Package mdbid does not have types.
32
- */
33
- // @ts-ignore
34
- const BATCH_CREATE_MAX_FILES = 20;
13
+ var _checkBasePermissions = require("./checkBasePermissions");
35
14
  /**
36
15
  * If permission is limited to "own" files only, check that current identity owns the file.
37
16
  */
38
-
39
- const checkOwnership = (file, permission, context) => {
17
+ const checkOwnership = (file, permission, identity) => {
40
18
  if ((permission === null || permission === void 0 ? void 0 : permission.own) === true) {
41
- const identity = context.security.getIdentity();
42
-
43
19
  if (file.createdBy.id !== identity.id) {
44
20
  throw new _apiSecurity.NotAuthorizedError();
45
21
  }
46
22
  }
47
23
  };
48
-
49
- const getLocaleCode = context => {
50
- if (!context.i18n) {
51
- throw new _error.default("Missing i18n on the FileManagerContext.", "MISSING_I18N");
52
- }
53
-
54
- const locale = context.i18n.getContentLocale();
55
-
56
- if (!locale) {
57
- throw new _error.default("Missing content locale on the FileManagerContext.", "MISSING_I18N_CONTENT_LOCALE");
58
- }
59
-
60
- if (!locale.code) {
61
- throw new _error.default("Missing content locale code on the FileManagerContext.", "MISSING_I18N_CONTENT_LOCALE_CODE");
62
- }
63
-
64
- return locale.code;
65
- };
66
-
67
- const filesContextCrudPlugin = new _api.ContextPlugin(async context => {
68
- const pluginType = _FilesStorageOperationsProviderPlugin.FilesStorageOperationsProviderPlugin.type;
69
- const providerPlugin = context.plugins.byType(pluginType).find(() => true);
70
-
71
- if (!providerPlugin) {
72
- throw new _error.default(`Missing "${pluginType}" plugin.`, "PLUGIN_NOT_FOUND", {
73
- type: pluginType
74
- });
75
- }
76
-
77
- const storageOperations = await providerPlugin.provide({
78
- context
79
- });
80
-
81
- if (!context.fileManager) {
82
- context.fileManager = {};
83
- }
84
-
85
- const filePlugins = context.plugins.byType(_FilePlugin.FilePlugin.type);
86
- context.fileManager.files = {
24
+ const createFilesCrud = config => {
25
+ const {
26
+ storageOperations,
27
+ getLocaleCode,
28
+ getTenantId,
29
+ getIdentity,
30
+ getPermission,
31
+ WEBINY_VERSION
32
+ } = config;
33
+ return {
34
+ onFileBeforeCreate: (0, _pubsub.createTopic)("fileManager.onFileBeforeCreate"),
35
+ onFileAfterCreate: (0, _pubsub.createTopic)("fileManager.onFileAfterCreate"),
36
+ onFileBeforeBatchCreate: (0, _pubsub.createTopic)("fileManager.onFileBeforeBatchCreate"),
37
+ onFileAfterBatchCreate: (0, _pubsub.createTopic)("fileManager.onFileAfterBatchCreate"),
38
+ onFileBeforeUpdate: (0, _pubsub.createTopic)("fileManager.onFileBeforeUpdate"),
39
+ onFileAfterUpdate: (0, _pubsub.createTopic)("fileManager.onFileAfterUpdate"),
40
+ onFileBeforeDelete: (0, _pubsub.createTopic)("fileManager.onFileBeforeDelete"),
41
+ onFileAfterDelete: (0, _pubsub.createTopic)("fileManager.onFileAfterDelete"),
87
42
  async getFile(id) {
88
- const permission = await (0, _checkBasePermissions.default)(context, {
43
+ const permission = await (0, _checkBasePermissions.checkBasePermissions)(getPermission, {
89
44
  rwd: "r"
90
45
  });
91
- const file = await storageOperations.get({
46
+ const file = await storageOperations.files.get({
92
47
  where: {
93
48
  id,
94
- tenant: context.tenancy.getCurrentTenant().id,
95
- locale: getLocaleCode(context)
49
+ tenant: getTenantId(),
50
+ locale: getLocaleCode()
96
51
  }
97
52
  });
98
-
99
53
  if (!file) {
100
54
  throw new _handlerGraphql.NotFoundError(`File with id "${id}" does not exists.`);
101
55
  }
102
-
103
- checkOwnership(file, permission, context);
56
+ checkOwnership(file, permission, getIdentity());
104
57
  return file;
105
58
  },
106
-
107
- async createFile(input) {
108
- await (0, _checkBasePermissions.default)(context, {
59
+ async createFile(input, meta) {
60
+ await (0, _checkBasePermissions.checkBasePermissions)(getPermission, {
109
61
  rwd: "w"
110
62
  });
111
- const identity = context.security.getIdentity();
112
- const tenant = context.tenancy.getCurrentTenant();
113
- const id = (0, _mdbid.default)();
63
+ const identity = getIdentity();
64
+
65
+ // Extract ID from file key
66
+ const [id] = input.key.split("/");
114
67
  const file = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, input), {}, {
115
68
  tags: Array.isArray(input.tags) ? input.tags : [],
116
- id,
69
+ aliases: Array.isArray(input.aliases) ? input.aliases : [],
70
+ id: input.id || id,
117
71
  meta: (0, _objectSpread2.default)({
118
72
  private: false
119
73
  }, input.meta || {}),
120
- tenant: tenant.id,
74
+ tenant: getTenantId(),
121
75
  createdOn: new Date().toISOString(),
122
76
  createdBy: {
123
77
  id: identity.id,
124
78
  displayName: identity.displayName,
125
79
  type: identity.type
126
80
  },
127
- locale: getLocaleCode(context),
128
- webinyVersion: context.WEBINY_VERSION
81
+ locale: getLocaleCode(),
82
+ webinyVersion: WEBINY_VERSION
129
83
  });
130
-
131
84
  try {
132
- await (0, _lifecycleEvents.runLifecycleEvent)("beforeCreate", {
133
- context,
134
- plugins: filePlugins,
135
- data: file
85
+ await this.onFileBeforeCreate.publish({
86
+ file,
87
+ meta
136
88
  });
137
- const result = await storageOperations.create({
89
+ const result = await storageOperations.files.create({
138
90
  file
139
91
  });
140
- await (0, _lifecycleEvents.runLifecycleEvent)("afterCreate", {
141
- context,
142
- plugins: filePlugins,
143
- data: file,
144
- file: result
92
+ await this.onFileAfterCreate.publish({
93
+ file,
94
+ meta
145
95
  });
146
96
  return result;
147
97
  } catch (ex) {
@@ -150,47 +100,41 @@ const filesContextCrudPlugin = new _api.ContextPlugin(async context => {
150
100
  }));
151
101
  }
152
102
  },
153
-
154
103
  async updateFile(id, input) {
155
- const permission = await (0, _checkBasePermissions.default)(context, {
104
+ const permission = await (0, _checkBasePermissions.checkBasePermissions)(getPermission, {
156
105
  rwd: "w"
157
106
  });
158
- const original = await storageOperations.get({
107
+ const original = await storageOperations.files.get({
159
108
  where: {
160
109
  id,
161
- tenant: context.tenancy.getCurrentTenant().id,
162
- locale: getLocaleCode(context)
110
+ tenant: getTenantId(),
111
+ locale: getLocaleCode()
163
112
  }
164
113
  });
165
-
166
114
  if (!original) {
167
115
  throw new _handlerGraphql.NotFoundError(`File with id "${id}" does not exists.`);
168
116
  }
169
-
170
- checkOwnership(original, permission, context);
117
+ checkOwnership(original, permission, getIdentity());
171
118
  const file = (0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, original), input), {}, {
172
119
  tags: Array.isArray(input.tags) ? input.tags : Array.isArray(original.tags) ? original.tags : [],
120
+ aliases: Array.isArray(input.aliases) ? input.aliases : Array.isArray(original.aliases) ? original.aliases : [],
173
121
  id: original.id,
174
- webinyVersion: context.WEBINY_VERSION
122
+ webinyVersion: WEBINY_VERSION
175
123
  });
176
-
177
124
  try {
178
- await (0, _lifecycleEvents.runLifecycleEvent)("beforeUpdate", {
179
- context,
180
- plugins: filePlugins,
125
+ await this.onFileBeforeUpdate.publish({
181
126
  original,
182
- data: file
127
+ file,
128
+ input
183
129
  });
184
- const result = await storageOperations.update({
130
+ const result = await storageOperations.files.update({
185
131
  original,
186
132
  file
187
133
  });
188
- await (0, _lifecycleEvents.runLifecycleEvent)("afterUpdate", {
189
- context,
190
- plugins: filePlugins,
134
+ await this.onFileAfterUpdate.publish({
191
135
  original,
192
- data: file,
193
- file: result
136
+ file,
137
+ input
194
138
  });
195
139
  return result;
196
140
  } catch (ex) {
@@ -200,37 +144,29 @@ const filesContextCrudPlugin = new _api.ContextPlugin(async context => {
200
144
  }));
201
145
  }
202
146
  },
203
-
204
147
  async deleteFile(id) {
205
- const permission = await (0, _checkBasePermissions.default)(context, {
148
+ const permission = await (0, _checkBasePermissions.checkBasePermissions)(getPermission, {
206
149
  rwd: "d"
207
150
  });
208
- const file = await storageOperations.get({
151
+ const file = await storageOperations.files.get({
209
152
  where: {
210
153
  id,
211
- tenant: context.tenancy.getCurrentTenant().id,
212
- locale: getLocaleCode(context)
154
+ tenant: getTenantId(),
155
+ locale: getLocaleCode()
213
156
  }
214
157
  });
215
-
216
158
  if (!file) {
217
159
  throw new _handlerGraphql.NotFoundError(`File with id "${id}" does not exists.`);
218
160
  }
219
-
220
- checkOwnership(file, permission, context);
221
-
161
+ checkOwnership(file, permission, getIdentity());
222
162
  try {
223
- await (0, _lifecycleEvents.runLifecycleEvent)("beforeDelete", {
224
- context,
225
- plugins: filePlugins,
163
+ await this.onFileBeforeDelete.publish({
226
164
  file
227
165
  });
228
- await storageOperations.delete({
166
+ await storageOperations.files.delete({
229
167
  file
230
168
  });
231
- await (0, _lifecycleEvents.runLifecycleEvent)("afterDelete", {
232
- context,
233
- plugins: filePlugins,
169
+ await this.onFileAfterDelete.publish({
234
170
  file
235
171
  });
236
172
  } catch (ex) {
@@ -239,28 +175,15 @@ const filesContextCrudPlugin = new _api.ContextPlugin(async context => {
239
175
  file
240
176
  }));
241
177
  }
242
-
243
178
  return true;
244
179
  },
245
-
246
- async createFilesInBatch(inputs) {
247
- if (!Array.isArray(inputs)) {
248
- throw new _error.default(`"data" must be an array.`, "CREATE_FILES_NON_ARRAY");
249
- }
250
-
251
- if (inputs.length === 0) {
252
- throw new _error.default(`"data" argument must contain at least one file.`, "CREATE_FILES_MIN_FILES");
253
- }
254
-
255
- if (inputs.length > BATCH_CREATE_MAX_FILES) {
256
- throw new _error.default(`"data" argument must not contain more than ${BATCH_CREATE_MAX_FILES} files.`, "CREATE_FILES_MAX_FILES");
257
- }
258
-
259
- await (0, _checkBasePermissions.default)(context, {
180
+ async createFilesInBatch(inputs, meta) {
181
+ await (0, _checkBasePermissions.checkBasePermissions)(getPermission, {
260
182
  rwd: "w"
261
183
  });
262
- const identity = context.security.getIdentity();
263
- const tenant = context.tenancy.getCurrentTenant();
184
+ const identity = getIdentity();
185
+ const tenant = getTenantId();
186
+ const locale = getLocaleCode();
264
187
  const createdBy = {
265
188
  id: identity.id,
266
189
  displayName: identity.displayName,
@@ -269,32 +192,28 @@ const filesContextCrudPlugin = new _api.ContextPlugin(async context => {
269
192
  const files = inputs.map(input => {
270
193
  return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, input), {}, {
271
194
  tags: Array.isArray(input.tags) ? input.tags : [],
195
+ aliases: Array.isArray(input.aliases) ? input.aliases : [],
272
196
  meta: (0, _objectSpread2.default)({
273
197
  private: false
274
198
  }, input.meta || {}),
275
- id: (0, _mdbid.default)(),
276
- tenant: tenant.id,
199
+ tenant,
277
200
  createdOn: new Date().toISOString(),
278
201
  createdBy,
279
- locale: getLocaleCode(context),
280
- webinyVersion: context.WEBINY_VERSION
202
+ locale,
203
+ webinyVersion: WEBINY_VERSION
281
204
  });
282
205
  });
283
-
284
206
  try {
285
- await (0, _lifecycleEvents.runLifecycleEvent)("beforeBatchCreate", {
286
- context,
287
- plugins: filePlugins,
288
- data: files
207
+ await this.onFileBeforeBatchCreate.publish({
208
+ files,
209
+ meta
289
210
  });
290
- const results = await storageOperations.createBatch({
211
+ const results = await storageOperations.files.createBatch({
291
212
  files
292
213
  });
293
- await (0, _lifecycleEvents.runLifecycleEvent)("afterBatchCreate", {
294
- context,
295
- plugins: filePlugins,
296
- data: files,
297
- files: results
214
+ await this.onFileAfterBatchCreate.publish({
215
+ files,
216
+ meta
298
217
  });
299
218
  return results;
300
219
  } catch (ex) {
@@ -303,9 +222,8 @@ const filesContextCrudPlugin = new _api.ContextPlugin(async context => {
303
222
  }));
304
223
  }
305
224
  },
306
-
307
225
  async listFiles(params = {}) {
308
- const permission = await (0, _checkBasePermissions.default)(context, {
226
+ const permission = await (0, _checkBasePermissions.checkBasePermissions)(getPermission, {
309
227
  rwd: "r"
310
228
  });
311
229
  const {
@@ -320,27 +238,23 @@ const filesContextCrudPlugin = new _api.ContextPlugin(async context => {
320
238
  } = params;
321
239
  const where = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, initialWhere), {}, {
322
240
  private: false,
323
- locale: getLocaleCode(context),
324
- tenant: context.tenancy.getCurrentTenant().id
241
+ locale: getLocaleCode(),
242
+ tenant: getTenantId()
325
243
  });
326
244
  /**
327
245
  * Always override the createdBy received from the user, if any.
328
246
  */
329
-
330
247
  if (permission.own === true) {
331
- const identity = context.security.getIdentity();
248
+ const identity = getIdentity();
332
249
  where.createdBy = identity.id;
333
250
  }
334
251
  /**
335
252
  * We need to map the old GraphQL definition to the new one.
336
253
  * That GQL definition is marked as deprecated.
337
254
  */
338
-
339
255
  /**
340
256
  * To have standardized where objects across the applications, we transform the types into type_in.
341
257
  */
342
-
343
-
344
258
  if (Array.isArray(types) && types.length > 0 && !where.type_in) {
345
259
  where.type_in = types;
346
260
  }
@@ -348,32 +262,24 @@ const filesContextCrudPlugin = new _api.ContextPlugin(async context => {
348
262
  * We are assigning search to tag and name search.
349
263
  * This should be treated as OR condition in the storage operations.
350
264
  */
351
-
352
-
353
265
  if (search && !where.search) {
354
266
  where.search = search;
355
267
  }
356
268
  /**
357
269
  * Same as on types/type_in.
358
270
  */
359
-
360
-
361
271
  if (Array.isArray(tags) && tags.length > 0 && !where.tag_in) {
362
272
  where.tag_in = tags.map(tag => tag.toLowerCase());
363
273
  }
364
274
  /**
365
275
  * Same as on types/type_in.
366
276
  */
367
-
368
-
369
277
  if (Array.isArray(ids) && ids.length > 0 && !where.id_in) {
370
278
  where.id_in = ids;
371
279
  }
372
-
373
280
  const sort = Array.isArray(initialSort) && initialSort.length > 0 ? initialSort : ["id_DESC"];
374
-
375
281
  try {
376
- return await storageOperations.list({
282
+ return await storageOperations.files.list({
377
283
  where,
378
284
  after,
379
285
  limit,
@@ -388,44 +294,29 @@ const filesContextCrudPlugin = new _api.ContextPlugin(async context => {
388
294
  }));
389
295
  }
390
296
  },
391
-
392
297
  async listTags({
393
298
  where: initialWhere,
394
299
  after,
395
300
  limit
396
301
  }) {
397
- await (0, _checkBasePermissions.default)(context);
302
+ await (0, _checkBasePermissions.checkBasePermissions)(getPermission);
398
303
  const where = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, initialWhere), {}, {
399
- tenant: context.tenancy.getCurrentTenant().id,
400
- locale: getLocaleCode(context)
304
+ tenant: getTenantId(),
305
+ locale: getLocaleCode()
401
306
  });
402
307
  const params = {
403
308
  where,
404
- limit: limit || 100000,
309
+ limit: limit || 1000000,
405
310
  after
406
311
  };
407
-
408
312
  try {
409
- const [tags] = await storageOperations.tags(params);
410
-
411
- if (Array.isArray(tags) === false) {
412
- return [];
413
- }
414
- /**
415
- * just to keep it standardized, sort by the tag ASC
416
- */
417
-
418
-
419
- return tags.sort();
313
+ return await storageOperations.files.tags(params);
420
314
  } catch (ex) {
421
315
  throw new _error.default(ex.message || "Could not search for tags.", ex.code || "FILE_TAG_SEARCH_ERROR", (0, _objectSpread2.default)((0, _objectSpread2.default)({}, ex.data || {}), {}, {
422
316
  params
423
317
  }));
424
318
  }
425
319
  }
426
-
427
320
  };
428
- });
429
- filesContextCrudPlugin.name = "FileManagerFilesCrud";
430
- var _default = filesContextCrudPlugin;
431
- exports.default = _default;
321
+ };
322
+ exports.createFilesCrud = createFilesCrud;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["checkOwnership","file","permission","identity","own","createdBy","id","NotAuthorizedError","createFilesCrud","config","storageOperations","getLocaleCode","getTenantId","getIdentity","getPermission","WEBINY_VERSION","onFileBeforeCreate","createTopic","onFileAfterCreate","onFileBeforeBatchCreate","onFileAfterBatchCreate","onFileBeforeUpdate","onFileAfterUpdate","onFileBeforeDelete","onFileAfterDelete","getFile","checkBasePermissions","rwd","files","get","where","tenant","locale","NotFoundError","createFile","input","meta","key","split","tags","Array","isArray","aliases","private","createdOn","Date","toISOString","displayName","type","webinyVersion","publish","result","create","ex","WebinyError","message","code","data","updateFile","original","update","deleteFile","delete","createFilesInBatch","inputs","map","results","createBatch","listFiles","params","limit","search","types","ids","after","initialWhere","sort","initialSort","length","type_in","tag_in","tag","toLowerCase","id_in","list","listTags"],"sources":["files.crud.ts"],"sourcesContent":["import { NotFoundError } from \"@webiny/handler-graphql\";\nimport { NotAuthorizedError } from \"@webiny/api-security\";\nimport { createTopic } from \"@webiny/pubsub\";\nimport WebinyError from \"@webiny/error\";\nimport { SecurityIdentity } from \"@webiny/api-security/types\";\nimport {\n CreatedBy,\n File,\n FileManagerFilesStorageOperationsListParamsWhere,\n FileManagerFilesStorageOperationsTagsParamsWhere,\n FilePermission,\n FilesCRUD,\n FilesListOpts\n} from \"~/types\";\nimport { checkBasePermissions } from \"./checkBasePermissions\";\nimport { FileManagerConfig } from \"~/createFileManager/index\";\n\n/**\n * If permission is limited to \"own\" files only, check that current identity owns the file.\n */\nconst checkOwnership = (file: File, permission: FilePermission, identity: SecurityIdentity) => {\n if (permission?.own === true) {\n if (file.createdBy.id !== identity.id) {\n throw new NotAuthorizedError();\n }\n }\n};\n\nexport const createFilesCrud = (config: FileManagerConfig): FilesCRUD => {\n const {\n storageOperations,\n getLocaleCode,\n getTenantId,\n getIdentity,\n getPermission,\n WEBINY_VERSION\n } = config;\n\n return {\n onFileBeforeCreate: createTopic(\"fileManager.onFileBeforeCreate\"),\n onFileAfterCreate: createTopic(\"fileManager.onFileAfterCreate\"),\n onFileBeforeBatchCreate: createTopic(\"fileManager.onFileBeforeBatchCreate\"),\n onFileAfterBatchCreate: createTopic(\"fileManager.onFileAfterBatchCreate\"),\n onFileBeforeUpdate: createTopic(\"fileManager.onFileBeforeUpdate\"),\n onFileAfterUpdate: createTopic(\"fileManager.onFileAfterUpdate\"),\n onFileBeforeDelete: createTopic(\"fileManager.onFileBeforeDelete\"),\n onFileAfterDelete: createTopic(\"fileManager.onFileAfterDelete\"),\n async getFile(id: string) {\n const permission = await checkBasePermissions(getPermission, { rwd: \"r\" });\n\n const file = await storageOperations.files.get({\n where: {\n id,\n tenant: getTenantId(),\n locale: getLocaleCode()\n }\n });\n\n if (!file) {\n throw new NotFoundError(`File with id \"${id}\" does not exists.`);\n }\n\n checkOwnership(file, permission, getIdentity());\n\n return file;\n },\n async createFile(input, meta) {\n await checkBasePermissions(getPermission, { rwd: \"w\" });\n const identity = getIdentity();\n\n // Extract ID from file key\n const [id] = input.key.split(\"/\");\n\n const file: File = {\n ...input,\n tags: Array.isArray(input.tags) ? input.tags : [],\n aliases: Array.isArray(input.aliases) ? input.aliases : [],\n id: input.id || id,\n meta: {\n private: false,\n ...(input.meta || {})\n },\n tenant: getTenantId(),\n createdOn: new Date().toISOString(),\n createdBy: {\n id: identity.id,\n displayName: identity.displayName,\n type: identity.type\n },\n locale: getLocaleCode(),\n webinyVersion: WEBINY_VERSION\n };\n\n try {\n await this.onFileBeforeCreate.publish({ file, meta });\n\n const result = await storageOperations.files.create({ file });\n\n await this.onFileAfterCreate.publish({ file, meta });\n return result;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not create a file.\",\n ex.code || \"CREATE_FILE_ERROR\",\n {\n ...(ex.data || {}),\n file\n }\n );\n }\n },\n async updateFile(id, input) {\n const permission = await checkBasePermissions(getPermission, { rwd: \"w\" });\n\n const original = await storageOperations.files.get({\n where: {\n id,\n tenant: getTenantId(),\n locale: getLocaleCode()\n }\n });\n\n if (!original) {\n throw new NotFoundError(`File with id \"${id}\" does not exists.`);\n }\n\n checkOwnership(original, permission, getIdentity());\n\n const file: File = {\n ...original,\n ...input,\n tags: Array.isArray(input.tags)\n ? input.tags\n : Array.isArray(original.tags)\n ? original.tags\n : [],\n aliases: Array.isArray(input.aliases)\n ? input.aliases\n : Array.isArray(original.aliases)\n ? original.aliases\n : [],\n id: original.id,\n webinyVersion: WEBINY_VERSION\n };\n\n try {\n await this.onFileBeforeUpdate.publish({\n original,\n file,\n input\n });\n\n const result = await storageOperations.files.update({\n original,\n file\n });\n\n await this.onFileAfterUpdate.publish({\n original,\n file,\n input\n });\n return result;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update a file.\",\n ex.code || \"UPDATE_FILE_ERROR\",\n {\n ...(ex.data || {}),\n original,\n file\n }\n );\n }\n },\n async deleteFile(id) {\n const permission = await checkBasePermissions(getPermission, { rwd: \"d\" });\n\n const file = await storageOperations.files.get({\n where: {\n id,\n tenant: getTenantId(),\n locale: getLocaleCode()\n }\n });\n\n if (!file) {\n throw new NotFoundError(`File with id \"${id}\" does not exists.`);\n }\n\n checkOwnership(file, permission, getIdentity());\n\n try {\n await this.onFileBeforeDelete.publish({ file });\n\n await storageOperations.files.delete({\n file\n });\n\n await this.onFileAfterDelete.publish({ file });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not delete a file.\",\n ex.code || \"DELETE_FILE_ERROR\",\n {\n ...(ex.data || {}),\n id,\n file\n }\n );\n }\n\n return true;\n },\n async createFilesInBatch(inputs, meta) {\n await checkBasePermissions(getPermission, { rwd: \"w\" });\n\n const identity = getIdentity();\n const tenant = getTenantId();\n const locale = getLocaleCode();\n\n const createdBy: CreatedBy = {\n id: identity.id,\n displayName: identity.displayName,\n type: identity.type\n };\n\n const files: File[] = inputs.map(input => {\n return {\n ...input,\n tags: Array.isArray(input.tags) ? input.tags : [],\n aliases: Array.isArray(input.aliases) ? input.aliases : [],\n meta: {\n private: false,\n ...(input.meta || {})\n },\n tenant,\n createdOn: new Date().toISOString(),\n createdBy,\n locale,\n webinyVersion: WEBINY_VERSION\n };\n });\n\n try {\n await this.onFileBeforeBatchCreate.publish({ files, meta });\n const results = await storageOperations.files.createBatch({\n files\n });\n await this.onFileAfterBatchCreate.publish({ files, meta });\n return results;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not create a batch of files.\",\n ex.code || \"CREATE_FILES_ERROR\",\n {\n ...(ex.data || {}),\n files\n }\n );\n }\n },\n async listFiles(params: FilesListOpts = {}) {\n const permission = await checkBasePermissions(getPermission, { rwd: \"r\" });\n\n const {\n limit = 40,\n search = \"\",\n types = [],\n tags = [],\n ids = [],\n after = null,\n where: initialWhere,\n sort: initialSort\n } = params;\n\n const where: FileManagerFilesStorageOperationsListParamsWhere = {\n ...initialWhere,\n private: false,\n locale: getLocaleCode(),\n tenant: getTenantId()\n };\n /**\n * Always override the createdBy received from the user, if any.\n */\n if (permission.own === true) {\n const identity = getIdentity();\n where.createdBy = identity.id;\n }\n /**\n * We need to map the old GraphQL definition to the new one.\n * That GQL definition is marked as deprecated.\n */\n /**\n * To have standardized where objects across the applications, we transform the types into type_in.\n */\n if (Array.isArray(types) && types.length > 0 && !where.type_in) {\n where.type_in = types;\n }\n /**\n * We are assigning search to tag and name search.\n * This should be treated as OR condition in the storage operations.\n */\n if (search && !where.search) {\n where.search = search;\n }\n /**\n * Same as on types/type_in.\n */\n if (Array.isArray(tags) && tags.length > 0 && !where.tag_in) {\n where.tag_in = tags.map(tag => tag.toLowerCase());\n }\n /**\n * Same as on types/type_in.\n */\n if (Array.isArray(ids) && ids.length > 0 && !where.id_in) {\n where.id_in = ids;\n }\n\n const sort =\n Array.isArray(initialSort) && initialSort.length > 0 ? initialSort : [\"id_DESC\"];\n try {\n return await storageOperations.files.list({\n where,\n after,\n limit,\n sort\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not list files by given parameters.\",\n ex.code || \"FILE_TAG_SEARCH_ERROR\",\n {\n ...(ex.data || {}),\n where,\n after,\n limit,\n sort\n }\n );\n }\n },\n async listTags({ where: initialWhere, after, limit }) {\n await checkBasePermissions(getPermission);\n\n const where: FileManagerFilesStorageOperationsTagsParamsWhere = {\n ...initialWhere,\n tenant: getTenantId(),\n locale: getLocaleCode()\n };\n\n const params = {\n where,\n limit: limit || 1000000,\n after\n };\n\n try {\n return await storageOperations.files.tags(params);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not search for tags.\",\n ex.code || \"FILE_TAG_SEARCH_ERROR\",\n {\n ...(ex.data || {}),\n params\n }\n );\n }\n }\n };\n};\n"],"mappings":";;;;;;;;AAAA;AACA;AACA;AACA;AAWA;AAGA;AACA;AACA;AACA,MAAMA,cAAc,GAAG,CAACC,IAAU,EAAEC,UAA0B,EAAEC,QAA0B,KAAK;EAC3F,IAAI,CAAAD,UAAU,aAAVA,UAAU,uBAAVA,UAAU,CAAEE,GAAG,MAAK,IAAI,EAAE;IAC1B,IAAIH,IAAI,CAACI,SAAS,CAACC,EAAE,KAAKH,QAAQ,CAACG,EAAE,EAAE;MACnC,MAAM,IAAIC,+BAAkB,EAAE;IAClC;EACJ;AACJ,CAAC;AA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