@webiny/api-file-manager 0.0.0-mt-3 → 0.0.0-unstable.2af142b57e

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 (102) hide show
  1. package/handlers/download/index.d.ts +3 -3
  2. package/handlers/download/index.js +64 -76
  3. package/handlers/download/index.js.map +1 -0
  4. package/handlers/manage/index.d.ts +5 -3
  5. package/handlers/manage/index.js +43 -58
  6. package/handlers/manage/index.js.map +1 -0
  7. package/handlers/transform/index.d.ts +2 -3
  8. package/handlers/transform/index.js +62 -77
  9. package/handlers/transform/index.js.map +1 -0
  10. package/handlers/transform/loaders/imageLoader.d.ts +26 -9
  11. package/handlers/transform/loaders/imageLoader.js +3 -21
  12. package/handlers/transform/loaders/imageLoader.js.map +1 -0
  13. package/handlers/transform/loaders/index.d.ts +4 -9
  14. package/handlers/transform/loaders/index.js +1 -4
  15. package/handlers/transform/loaders/index.js.map +1 -0
  16. package/handlers/transform/loaders/sanitizeImageTransformations.d.ts +7 -3
  17. package/handlers/transform/loaders/sanitizeImageTransformations.js +24 -30
  18. package/handlers/transform/loaders/sanitizeImageTransformations.js.map +1 -0
  19. package/handlers/transform/managers/imageManager.d.ts +12 -6
  20. package/handlers/transform/managers/imageManager.js +25 -25
  21. package/handlers/transform/managers/imageManager.js.map +1 -0
  22. package/handlers/transform/managers/index.d.ts +2 -6
  23. package/handlers/transform/managers/index.js +1 -4
  24. package/handlers/transform/managers/index.js.map +1 -0
  25. package/handlers/transform/optimizeImage.d.ts +2 -1
  26. package/handlers/transform/optimizeImage.js +4 -7
  27. package/handlers/transform/optimizeImage.js.map +1 -0
  28. package/handlers/transform/transformImage.d.ts +5 -4
  29. package/handlers/transform/transformImage.js +4 -9
  30. package/handlers/transform/transformImage.js.map +1 -0
  31. package/handlers/transform/utils.d.ts +2 -2
  32. package/handlers/transform/utils.js +1 -11
  33. package/handlers/transform/utils.js.map +1 -0
  34. package/handlers/types.d.ts +8 -0
  35. package/handlers/types.js +5 -0
  36. package/handlers/types.js.map +1 -0
  37. package/handlers/utils/getEnvironment.js +0 -2
  38. package/handlers/utils/getEnvironment.js.map +1 -0
  39. package/handlers/utils/getObjectParams.d.ts +3 -4
  40. package/handlers/utils/getObjectParams.js +1 -7
  41. package/handlers/utils/getObjectParams.js.map +1 -0
  42. package/handlers/utils/index.d.ts +0 -1
  43. package/handlers/utils/index.js +1 -12
  44. package/handlers/utils/index.js.map +1 -0
  45. package/package.json +28 -27
  46. package/plugins/crud/files/validation.js +1 -7
  47. package/plugins/crud/files/validation.js.map +1 -0
  48. package/plugins/crud/files.crud.d.ts +1 -1
  49. package/plugins/crud/files.crud.js +43 -98
  50. package/plugins/crud/files.crud.js.map +1 -0
  51. package/plugins/crud/settings.crud.d.ts +1 -1
  52. package/plugins/crud/settings.crud.js +10 -26
  53. package/plugins/crud/settings.crud.js.map +1 -0
  54. package/plugins/crud/system.crud.d.ts +1 -1
  55. package/plugins/crud/system.crud.js +17 -39
  56. package/plugins/crud/system.crud.js.map +1 -0
  57. package/plugins/crud/utils/checkBasePermissions.js +1 -9
  58. package/plugins/crud/utils/checkBasePermissions.js.map +1 -0
  59. package/plugins/crud/utils/createFileModel.d.ts +3 -0
  60. package/plugins/crud/utils/createFileModel.js +11 -10
  61. package/plugins/crud/utils/createFileModel.js.map +1 -0
  62. package/plugins/crud/utils/lifecycleEvents.d.ts +2 -2
  63. package/plugins/crud/utils/lifecycleEvents.js +8 -11
  64. package/plugins/crud/utils/lifecycleEvents.js.map +1 -0
  65. package/plugins/definitions/FilePhysicalStoragePlugin.d.ts +10 -11
  66. package/plugins/definitions/FilePhysicalStoragePlugin.js +1 -12
  67. package/plugins/definitions/FilePhysicalStoragePlugin.js.map +1 -0
  68. package/plugins/definitions/FilePlugin.d.ts +6 -3
  69. package/plugins/definitions/FilePlugin.js +7 -19
  70. package/plugins/definitions/FilePlugin.js.map +1 -0
  71. package/plugins/definitions/FileStorageTransformPlugin.d.ts +9 -9
  72. package/plugins/definitions/FileStorageTransformPlugin.js +2 -13
  73. package/plugins/definitions/FileStorageTransformPlugin.js.map +1 -0
  74. package/plugins/definitions/FilesStorageOperationsProviderPlugin.d.ts +4 -4
  75. package/plugins/definitions/FilesStorageOperationsProviderPlugin.js +1 -6
  76. package/plugins/definitions/FilesStorageOperationsProviderPlugin.js.map +1 -0
  77. package/plugins/definitions/InstallationPlugin.d.ts +9 -9
  78. package/plugins/definitions/InstallationPlugin.js +4 -13
  79. package/plugins/definitions/InstallationPlugin.js.map +1 -0
  80. package/plugins/definitions/SettingsStorageOperationsProviderPlugin.d.ts +4 -4
  81. package/plugins/definitions/SettingsStorageOperationsProviderPlugin.js +1 -6
  82. package/plugins/definitions/SettingsStorageOperationsProviderPlugin.js.map +1 -0
  83. package/plugins/definitions/SystemStorageOperationsProviderPlugin.d.ts +4 -4
  84. package/plugins/definitions/SystemStorageOperationsProviderPlugin.js +1 -6
  85. package/plugins/definitions/SystemStorageOperationsProviderPlugin.js.map +1 -0
  86. package/plugins/graphql.js +21 -25
  87. package/plugins/graphql.js.map +1 -0
  88. package/plugins/index.d.ts +1 -1
  89. package/plugins/index.js +1 -10
  90. package/plugins/index.js.map +1 -0
  91. package/plugins/storage/FileStorage.d.ts +23 -24
  92. package/plugins/storage/FileStorage.js +35 -45
  93. package/plugins/storage/FileStorage.js.map +1 -0
  94. package/plugins/storage/index.d.ts +1 -1
  95. package/plugins/storage/index.js +6 -6
  96. package/plugins/storage/index.js.map +1 -0
  97. package/types.d.ts +16 -12
  98. package/types.js.map +1 -0
  99. package/utils.js +0 -2
  100. package/utils.js.map +1 -0
  101. package/handlers/utils/createHandler.d.ts +0 -24
  102. package/handlers/utils/createHandler.js +0 -68
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/api-file-manager",
3
- "version": "0.0.0-mt-3",
3
+ "version": "0.0.0-unstable.2af142b57e",
4
4
  "main": "index.js",
5
5
  "keywords": [
6
6
  "fm:base"
@@ -18,39 +18,40 @@
18
18
  ],
19
19
  "license": "MIT",
20
20
  "dependencies": {
21
- "@babel/runtime": "7.15.4",
21
+ "@babel/runtime": "7.20.13",
22
22
  "@commodo/fields": "1.1.2-beta.20",
23
- "@webiny/api-i18n-content": "0.0.0-mt-3",
24
- "@webiny/api-security": "0.0.0-mt-3",
25
- "@webiny/api-tenancy": "0.0.0-mt-3",
26
- "@webiny/api-upgrade": "0.0.0-mt-3",
27
- "@webiny/error": "0.0.0-mt-3",
28
- "@webiny/handler": "0.0.0-mt-3",
29
- "@webiny/handler-client": "0.0.0-mt-3",
30
- "@webiny/handler-graphql": "0.0.0-mt-3",
31
- "@webiny/plugins": "0.0.0-mt-3",
32
- "@webiny/project-utils": "0.0.0-mt-3",
33
- "@webiny/validation": "0.0.0-mt-3",
34
- "aws-sdk": "2.1026.0",
23
+ "@webiny/api": "0.0.0-unstable.2af142b57e",
24
+ "@webiny/api-security": "0.0.0-unstable.2af142b57e",
25
+ "@webiny/api-tenancy": "0.0.0-unstable.2af142b57e",
26
+ "@webiny/api-upgrade": "0.0.0-unstable.2af142b57e",
27
+ "@webiny/error": "0.0.0-unstable.2af142b57e",
28
+ "@webiny/handler": "0.0.0-unstable.2af142b57e",
29
+ "@webiny/handler-aws": "0.0.0-unstable.2af142b57e",
30
+ "@webiny/handler-client": "0.0.0-unstable.2af142b57e",
31
+ "@webiny/handler-graphql": "0.0.0-unstable.2af142b57e",
32
+ "@webiny/plugins": "0.0.0-unstable.2af142b57e",
33
+ "@webiny/project-utils": "0.0.0-unstable.2af142b57e",
34
+ "@webiny/validation": "0.0.0-unstable.2af142b57e",
35
+ "aws-sdk": "2.1310.0",
35
36
  "commodo-fields-object": "1.0.6",
36
37
  "mdbid": "1.0.0",
37
- "object-hash": "1.3.1",
38
+ "object-hash": "2.2.0",
38
39
  "sanitize-filename": "1.6.3"
39
40
  },
40
41
  "devDependencies": {
41
- "@babel/cli": "^7.5.5",
42
- "@babel/core": "^7.5.5",
43
- "@babel/plugin-proposal-object-rest-spread": "^7.5.5",
44
- "@babel/plugin-transform-runtime": "^7.5.5",
45
- "@babel/preset-env": "^7.5.5",
46
- "@babel/preset-typescript": "^7.0.0",
47
- "@webiny/api-i18n": "^0.0.0-mt-3",
48
- "@webiny/api-i18n-ddb": "^0.0.0-mt-3",
49
- "@webiny/cli": "^0.0.0-mt-3",
50
- "jest": "^26.6.3",
42
+ "@babel/cli": "^7.19.3",
43
+ "@babel/core": "^7.19.3",
44
+ "@babel/plugin-proposal-object-rest-spread": "^7.16.0",
45
+ "@babel/plugin-transform-runtime": "^7.16.4",
46
+ "@babel/preset-env": "^7.19.4",
47
+ "@babel/preset-typescript": "^7.18.6",
48
+ "@webiny/api-i18n": "^0.0.0-unstable.2af142b57e",
49
+ "@webiny/api-i18n-ddb": "^0.0.0-unstable.2af142b57e",
50
+ "@webiny/cli": "^0.0.0-unstable.2af142b57e",
51
+ "jest": "^28.1.0",
51
52
  "rimraf": "^3.0.2",
52
53
  "ttypescript": "^1.5.12",
53
- "typescript": "^4.1.3"
54
+ "typescript": "4.7.4"
54
55
  },
55
56
  "publishConfig": {
56
57
  "access": "public",
@@ -71,5 +72,5 @@
71
72
  ]
72
73
  }
73
74
  },
74
- "gitHead": "ebea815be2be99404591cba465cc1fe88355bd48"
75
+ "gitHead": "2af142b57e7cdc433f5098b3b6d43ae6caa5d54e"
75
76
  }
@@ -1,16 +1,12 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.default = void 0;
9
-
10
8
  var _FilePlugin = require("../../definitions/FilePlugin");
11
-
12
9
  var _createFileModel = _interopRequireDefault(require("../utils/createFileModel"));
13
-
14
10
  var _default = () => [new _FilePlugin.FilePlugin({
15
11
  beforeCreate: async ({
16
12
  data
@@ -30,12 +26,10 @@ var _default = () => [new _FilePlugin.FilePlugin({
30
26
  data
31
27
  }) => {
32
28
  const FileModel = (0, _createFileModel.default)();
33
-
34
29
  for (const input of data) {
35
30
  const fileInstance = new FileModel().populate(input);
36
31
  await fileInstance.validate();
37
32
  }
38
33
  }
39
34
  })];
40
-
41
35
  exports.default = _default;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["FilePlugin","beforeCreate","data","FileModel","createFileModel","fileData","populate","validate","beforeUpdate","updatedFileData","beforeBatchCreate","input","fileInstance"],"sources":["validation.ts"],"sourcesContent":["import { FilePlugin } from \"~/plugins/definitions/FilePlugin\";\nimport createFileModel from \"~/plugins/crud/utils/createFileModel\";\n\nexport default (): FilePlugin[] => [\n new FilePlugin({\n beforeCreate: async ({ data }) => {\n const FileModel = createFileModel();\n const fileData = new FileModel().populate(data);\n await fileData.validate();\n },\n beforeUpdate: async ({ data }) => {\n const FileModel = createFileModel(false);\n const updatedFileData = new FileModel().populate(data);\n await updatedFileData.validate();\n },\n beforeBatchCreate: async ({ data }) => {\n const FileModel = createFileModel();\n for (const input of data) {\n const fileInstance = new FileModel().populate(input);\n await fileInstance.validate();\n }\n }\n })\n];\n"],"mappings":";;;;;;;AAAA;AACA;AAAmE,eAEpD,MAAoB,CAC/B,IAAIA,sBAAU,CAAC;EACXC,YAAY,EAAE,OAAO;IAAEC;EAAK,CAAC,KAAK;IAC9B,MAAMC,SAAS,GAAG,IAAAC,wBAAe,GAAE;IACnC,MAAMC,QAAQ,GAAG,IAAIF,SAAS,EAAE,CAACG,QAAQ,CAACJ,IAAI,CAAC;IAC/C,MAAMG,QAAQ,CAACE,QAAQ,EAAE;EAC7B,CAAC;EACDC,YAAY,EAAE,OAAO;IAAEN;EAAK,CAAC,KAAK;IAC9B,MAAMC,SAAS,GAAG,IAAAC,wBAAe,EAAC,KAAK,CAAC;IACxC,MAAMK,eAAe,GAAG,IAAIN,SAAS,EAAE,CAACG,QAAQ,CAACJ,IAAI,CAAC;IACtD,MAAMO,eAAe,CAACF,QAAQ,EAAE;EACpC,CAAC;EACDG,iBAAiB,EAAE,OAAO;IAAER;EAAK,CAAC,KAAK;IACnC,MAAMC,SAAS,GAAG,IAAAC,wBAAe,GAAE;IACnC,KAAK,MAAMO,KAAK,IAAIT,IAAI,EAAE;MACtB,MAAMU,YAAY,GAAG,IAAIT,SAAS,EAAE,CAACG,QAAQ,CAACK,KAAK,CAAC;MACpD,MAAMC,YAAY,CAACL,QAAQ,EAAE;IACjC;EACJ;AACJ,CAAC,CAAC,CACL;AAAA"}
@@ -1,4 +1,4 @@
1
1
  import { FileManagerContext } from "../../types";
2
- import { ContextPlugin } from "@webiny/handler/plugins/ContextPlugin";
2
+ import { ContextPlugin } from "@webiny/api";
3
3
  declare const filesContextCrudPlugin: ContextPlugin<FileManagerContext>;
4
4
  export default filesContextCrudPlugin;
@@ -1,81 +1,65 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.default = void 0;
9
-
10
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
-
8
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
12
9
  var _mdbid = _interopRequireDefault(require("mdbid"));
13
-
14
10
  var _handlerGraphql = require("@webiny/handler-graphql");
15
-
16
11
  var _apiSecurity = require("@webiny/api-security");
17
-
18
- var _error = _interopRequireDefault(require("@webiny/error"));
19
-
20
12
  var _checkBasePermissions = _interopRequireDefault(require("./utils/checkBasePermissions"));
21
-
22
- var _ContextPlugin = require("@webiny/handler/plugins/ContextPlugin");
23
-
13
+ var _api = require("@webiny/api");
24
14
  var _FilePlugin = require("../definitions/FilePlugin");
25
-
26
15
  var _FilesStorageOperationsProviderPlugin = require("../definitions/FilesStorageOperationsProviderPlugin");
27
-
16
+ var _error = _interopRequireDefault(require("@webiny/error"));
28
17
  var _lifecycleEvents = require("./utils/lifecycleEvents");
29
-
30
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
31
-
32
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
18
+ /**
19
+ * Package mdbid does not have types.
20
+ */
21
+ // @ts-ignore
33
22
 
34
23
  const BATCH_CREATE_MAX_FILES = 20;
24
+
35
25
  /**
36
26
  * If permission is limited to "own" files only, check that current identity owns the file.
37
27
  */
38
-
39
28
  const checkOwnership = (file, permission, context) => {
40
29
  if ((permission === null || permission === void 0 ? void 0 : permission.own) === true) {
41
30
  const identity = context.security.getIdentity();
42
-
43
31
  if (file.createdBy.id !== identity.id) {
44
32
  throw new _apiSecurity.NotAuthorizedError();
45
33
  }
46
34
  }
47
35
  };
48
-
49
36
  const getLocaleCode = context => {
50
- if (!context.i18nContent) {
51
- throw new _error.default("Missing i18nContent on the FileManagerContext.", "MISSING_I18N_CONTENT");
52
- } else if (!context.i18nContent.locale) {
53
- throw new _error.default("Missing i18nContent.locale on the FileManagerContext.", "MISSING_I18N_CONTENT_LOCALE");
54
- } else if (!context.i18nContent.locale.code) {
55
- throw new _error.default("Missing i18nContent.locale.code on the FileManagerContext.", "MISSING_I18N_CONTENT_LOCALE_CODE");
37
+ if (!context.i18n) {
38
+ throw new _error.default("Missing i18n on the FileManagerContext.", "MISSING_I18N");
56
39
  }
57
-
58
- return context.i18nContent.locale.code;
40
+ const locale = context.i18n.getContentLocale();
41
+ if (!locale) {
42
+ throw new _error.default("Missing content locale on the FileManagerContext.", "MISSING_I18N_CONTENT_LOCALE");
43
+ }
44
+ if (!locale.code) {
45
+ throw new _error.default("Missing content locale code on the FileManagerContext.", "MISSING_I18N_CONTENT_LOCALE_CODE");
46
+ }
47
+ return locale.code;
59
48
  };
60
-
61
- const filesContextCrudPlugin = new _ContextPlugin.ContextPlugin(async context => {
49
+ const filesContextCrudPlugin = new _api.ContextPlugin(async context => {
62
50
  const pluginType = _FilesStorageOperationsProviderPlugin.FilesStorageOperationsProviderPlugin.type;
63
51
  const providerPlugin = context.plugins.byType(pluginType).find(() => true);
64
-
65
52
  if (!providerPlugin) {
66
53
  throw new _error.default(`Missing "${pluginType}" plugin.`, "PLUGIN_NOT_FOUND", {
67
54
  type: pluginType
68
55
  });
69
56
  }
70
-
71
57
  const storageOperations = await providerPlugin.provide({
72
58
  context
73
59
  });
74
-
75
60
  if (!context.fileManager) {
76
61
  context.fileManager = {};
77
62
  }
78
-
79
63
  const filePlugins = context.plugins.byType(_FilePlugin.FilePlugin.type);
80
64
  context.fileManager.files = {
81
65
  async getFile(id) {
@@ -89,15 +73,12 @@ const filesContextCrudPlugin = new _ContextPlugin.ContextPlugin(async context =>
89
73
  locale: getLocaleCode(context)
90
74
  }
91
75
  });
92
-
93
76
  if (!file) {
94
77
  throw new _handlerGraphql.NotFoundError(`File with id "${id}" does not exists.`);
95
78
  }
96
-
97
79
  checkOwnership(file, permission, context);
98
80
  return file;
99
81
  },
100
-
101
82
  async createFile(input) {
102
83
  await (0, _checkBasePermissions.default)(context, {
103
84
  rwd: "w"
@@ -105,10 +86,10 @@ const filesContextCrudPlugin = new _ContextPlugin.ContextPlugin(async context =>
105
86
  const identity = context.security.getIdentity();
106
87
  const tenant = context.tenancy.getCurrentTenant();
107
88
  const id = (0, _mdbid.default)();
108
-
109
- const file = _objectSpread(_objectSpread({}, input), {}, {
89
+ const file = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, input), {}, {
90
+ tags: Array.isArray(input.tags) ? input.tags : [],
110
91
  id,
111
- meta: _objectSpread({
92
+ meta: (0, _objectSpread2.default)({
112
93
  private: false
113
94
  }, input.meta || {}),
114
95
  tenant: tenant.id,
@@ -121,7 +102,6 @@ const filesContextCrudPlugin = new _ContextPlugin.ContextPlugin(async context =>
121
102
  locale: getLocaleCode(context),
122
103
  webinyVersion: context.WEBINY_VERSION
123
104
  });
124
-
125
105
  try {
126
106
  await (0, _lifecycleEvents.runLifecycleEvent)("beforeCreate", {
127
107
  context,
@@ -139,12 +119,11 @@ const filesContextCrudPlugin = new _ContextPlugin.ContextPlugin(async context =>
139
119
  });
140
120
  return result;
141
121
  } catch (ex) {
142
- throw new _error.default(ex.message || "Could not create a file.", ex.code || "CREATE_FILE_ERROR", _objectSpread(_objectSpread({}, ex.data || {}), {}, {
122
+ throw new _error.default(ex.message || "Could not create a file.", ex.code || "CREATE_FILE_ERROR", (0, _objectSpread2.default)((0, _objectSpread2.default)({}, ex.data || {}), {}, {
143
123
  file
144
124
  }));
145
125
  }
146
126
  },
147
-
148
127
  async updateFile(id, input) {
149
128
  const permission = await (0, _checkBasePermissions.default)(context, {
150
129
  rwd: "w"
@@ -156,18 +135,15 @@ const filesContextCrudPlugin = new _ContextPlugin.ContextPlugin(async context =>
156
135
  locale: getLocaleCode(context)
157
136
  }
158
137
  });
159
-
160
138
  if (!original) {
161
139
  throw new _handlerGraphql.NotFoundError(`File with id "${id}" does not exists.`);
162
140
  }
163
-
164
141
  checkOwnership(original, permission, context);
165
-
166
- const file = _objectSpread(_objectSpread(_objectSpread({}, original), input), {}, {
142
+ const file = (0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, original), input), {}, {
143
+ tags: Array.isArray(input.tags) ? input.tags : Array.isArray(original.tags) ? original.tags : [],
167
144
  id: original.id,
168
145
  webinyVersion: context.WEBINY_VERSION
169
146
  });
170
-
171
147
  try {
172
148
  await (0, _lifecycleEvents.runLifecycleEvent)("beforeUpdate", {
173
149
  context,
@@ -188,13 +164,12 @@ const filesContextCrudPlugin = new _ContextPlugin.ContextPlugin(async context =>
188
164
  });
189
165
  return result;
190
166
  } catch (ex) {
191
- throw new _error.default(ex.message || "Could not update a file.", ex.code || "UPDATE_FILE_ERROR", _objectSpread(_objectSpread({}, ex.data || {}), {}, {
167
+ throw new _error.default(ex.message || "Could not update a file.", ex.code || "UPDATE_FILE_ERROR", (0, _objectSpread2.default)((0, _objectSpread2.default)({}, ex.data || {}), {}, {
192
168
  original,
193
169
  file
194
170
  }));
195
171
  }
196
172
  },
197
-
198
173
  async deleteFile(id) {
199
174
  const permission = await (0, _checkBasePermissions.default)(context, {
200
175
  rwd: "d"
@@ -206,13 +181,10 @@ const filesContextCrudPlugin = new _ContextPlugin.ContextPlugin(async context =>
206
181
  locale: getLocaleCode(context)
207
182
  }
208
183
  });
209
-
210
184
  if (!file) {
211
185
  throw new _handlerGraphql.NotFoundError(`File with id "${id}" does not exists.`);
212
186
  }
213
-
214
187
  checkOwnership(file, permission, context);
215
-
216
188
  try {
217
189
  await (0, _lifecycleEvents.runLifecycleEvent)("beforeDelete", {
218
190
  context,
@@ -228,28 +200,23 @@ const filesContextCrudPlugin = new _ContextPlugin.ContextPlugin(async context =>
228
200
  file
229
201
  });
230
202
  } catch (ex) {
231
- throw new _error.default(ex.message || "Could not delete a file.", ex.code || "DELETE_FILE_ERROR", _objectSpread(_objectSpread({}, ex.data || {}), {}, {
203
+ throw new _error.default(ex.message || "Could not delete a file.", ex.code || "DELETE_FILE_ERROR", (0, _objectSpread2.default)((0, _objectSpread2.default)({}, ex.data || {}), {}, {
232
204
  id,
233
205
  file
234
206
  }));
235
207
  }
236
-
237
208
  return true;
238
209
  },
239
-
240
210
  async createFilesInBatch(inputs) {
241
211
  if (!Array.isArray(inputs)) {
242
212
  throw new _error.default(`"data" must be an array.`, "CREATE_FILES_NON_ARRAY");
243
213
  }
244
-
245
214
  if (inputs.length === 0) {
246
215
  throw new _error.default(`"data" argument must contain at least one file.`, "CREATE_FILES_MIN_FILES");
247
216
  }
248
-
249
217
  if (inputs.length > BATCH_CREATE_MAX_FILES) {
250
218
  throw new _error.default(`"data" argument must not contain more than ${BATCH_CREATE_MAX_FILES} files.`, "CREATE_FILES_MAX_FILES");
251
219
  }
252
-
253
220
  await (0, _checkBasePermissions.default)(context, {
254
221
  rwd: "w"
255
222
  });
@@ -261,8 +228,9 @@ const filesContextCrudPlugin = new _ContextPlugin.ContextPlugin(async context =>
261
228
  type: identity.type
262
229
  };
263
230
  const files = inputs.map(input => {
264
- return _objectSpread(_objectSpread({}, input), {}, {
265
- meta: _objectSpread({
231
+ return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, input), {}, {
232
+ tags: Array.isArray(input.tags) ? input.tags : [],
233
+ meta: (0, _objectSpread2.default)({
266
234
  private: false
267
235
  }, input.meta || {}),
268
236
  id: (0, _mdbid.default)(),
@@ -273,7 +241,6 @@ const filesContextCrudPlugin = new _ContextPlugin.ContextPlugin(async context =>
273
241
  webinyVersion: context.WEBINY_VERSION
274
242
  });
275
243
  });
276
-
277
244
  try {
278
245
  await (0, _lifecycleEvents.runLifecycleEvent)("beforeBatchCreate", {
279
246
  context,
@@ -291,12 +258,11 @@ const filesContextCrudPlugin = new _ContextPlugin.ContextPlugin(async context =>
291
258
  });
292
259
  return results;
293
260
  } catch (ex) {
294
- throw new _error.default(ex.message || "Could not create a batch of files.", ex.code || "CREATE_FILES_ERROR", _objectSpread(_objectSpread({}, ex.data || {}), {}, {
261
+ throw new _error.default(ex.message || "Could not create a batch of files.", ex.code || "CREATE_FILES_ERROR", (0, _objectSpread2.default)((0, _objectSpread2.default)({}, ex.data || {}), {}, {
295
262
  files
296
263
  }));
297
264
  }
298
265
  },
299
-
300
266
  async listFiles(params = {}) {
301
267
  const permission = await (0, _checkBasePermissions.default)(context, {
302
268
  rwd: "r"
@@ -311,17 +277,14 @@ const filesContextCrudPlugin = new _ContextPlugin.ContextPlugin(async context =>
311
277
  where: initialWhere,
312
278
  sort: initialSort
313
279
  } = params;
314
-
315
- const where = _objectSpread(_objectSpread({}, initialWhere), {}, {
280
+ const where = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, initialWhere), {}, {
316
281
  private: false,
317
- locale: context.i18nContent.getLocale().code,
282
+ locale: getLocaleCode(context),
318
283
  tenant: context.tenancy.getCurrentTenant().id
319
284
  });
320
285
  /**
321
286
  * Always override the createdBy received from the user, if any.
322
287
  */
323
-
324
-
325
288
  if (permission.own === true) {
326
289
  const identity = context.security.getIdentity();
327
290
  where.createdBy = identity.id;
@@ -330,12 +293,9 @@ const filesContextCrudPlugin = new _ContextPlugin.ContextPlugin(async context =>
330
293
  * We need to map the old GraphQL definition to the new one.
331
294
  * That GQL definition is marked as deprecated.
332
295
  */
333
-
334
296
  /**
335
297
  * To have standardized where objects across the applications, we transform the types into type_in.
336
298
  */
337
-
338
-
339
299
  if (Array.isArray(types) && types.length > 0 && !where.type_in) {
340
300
  where.type_in = types;
341
301
  }
@@ -343,30 +303,22 @@ const filesContextCrudPlugin = new _ContextPlugin.ContextPlugin(async context =>
343
303
  * We are assigning search to tag and name search.
344
304
  * This should be treated as OR condition in the storage operations.
345
305
  */
346
-
347
-
348
306
  if (search && !where.search) {
349
307
  where.search = search;
350
308
  }
351
309
  /**
352
310
  * Same as on types/type_in.
353
311
  */
354
-
355
-
356
312
  if (Array.isArray(tags) && tags.length > 0 && !where.tag_in) {
357
313
  where.tag_in = tags.map(tag => tag.toLowerCase());
358
314
  }
359
315
  /**
360
316
  * Same as on types/type_in.
361
317
  */
362
-
363
-
364
318
  if (Array.isArray(ids) && ids.length > 0 && !where.id_in) {
365
319
  where.id_in = ids;
366
320
  }
367
-
368
321
  const sort = Array.isArray(initialSort) && initialSort.length > 0 ? initialSort : ["id_DESC"];
369
-
370
322
  try {
371
323
  return await storageOperations.list({
372
324
  where,
@@ -375,7 +327,7 @@ const filesContextCrudPlugin = new _ContextPlugin.ContextPlugin(async context =>
375
327
  sort
376
328
  });
377
329
  } catch (ex) {
378
- throw new _error.default(ex.message || "Could not list files by given parameters.", ex.code || "FILE_TAG_SEARCH_ERROR", _objectSpread(_objectSpread({}, ex.data || {}), {}, {
330
+ throw new _error.default(ex.message || "Could not list files by given parameters.", ex.code || "FILE_TAG_SEARCH_ERROR", (0, _objectSpread2.default)((0, _objectSpread2.default)({}, ex.data || {}), {}, {
379
331
  where,
380
332
  after,
381
333
  limit,
@@ -383,43 +335,36 @@ const filesContextCrudPlugin = new _ContextPlugin.ContextPlugin(async context =>
383
335
  }));
384
336
  }
385
337
  },
386
-
387
338
  async listTags({
339
+ where: initialWhere,
388
340
  after,
389
341
  limit
390
342
  }) {
391
343
  await (0, _checkBasePermissions.default)(context);
392
- const {
393
- i18nContent
394
- } = context;
395
- const where = {
344
+ const where = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, initialWhere), {}, {
396
345
  tenant: context.tenancy.getCurrentTenant().id,
397
- locale: i18nContent.locale.code
398
- };
346
+ locale: getLocaleCode(context)
347
+ });
399
348
  const params = {
400
349
  where,
401
350
  limit: limit || 100000,
402
351
  after
403
352
  };
404
-
405
353
  try {
406
- /**
407
- * There is a meta object on the second key.
408
- * TODO: use when changing GraphQL output of the tags.
409
- */
410
354
  const [tags] = await storageOperations.tags(params);
355
+ if (Array.isArray(tags) === false) {
356
+ return [];
357
+ }
411
358
  /**
412
359
  * just to keep it standardized, sort by the tag ASC
413
360
  */
414
-
415
361
  return tags.sort();
416
362
  } catch (ex) {
417
- throw new _error.default(ex.message || "Could not search for tags.", ex.code || "FILE_TAG_SEARCH_ERROR", _objectSpread(_objectSpread({}, ex.data || {}), {}, {
363
+ 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 || {}), {}, {
418
364
  params
419
365
  }));
420
366
  }
421
367
  }
422
-
423
368
  };
424
369
  });
425
370
  filesContextCrudPlugin.name = "FileManagerFilesCrud";
@@ -0,0 +1 @@
1
+ {"version":3,"names":["BATCH_CREATE_MAX_FILES","checkOwnership","file","permission","context","own","identity","security","getIdentity","createdBy","id","NotAuthorizedError","getLocaleCode","i18n","WebinyError","locale","getContentLocale","code","filesContextCrudPlugin","ContextPlugin","pluginType","FilesStorageOperationsProviderPlugin","type","providerPlugin","plugins","byType","find","storageOperations","provide","fileManager","filePlugins","FilePlugin","files","getFile","checkBasePermissions","rwd","get","where","tenant","tenancy","getCurrentTenant","NotFoundError","createFile","input","mdbid","tags","Array","isArray","meta","private","createdOn","Date","toISOString","displayName","webinyVersion","WEBINY_VERSION","runLifecycleEvent","data","result","create","ex","message","updateFile","original","update","deleteFile","delete","createFilesInBatch","inputs","length","map","results","createBatch","listFiles","params","limit","search","types","ids","after","initialWhere","sort","initialSort","type_in","tag_in","tag","toLowerCase","id_in","list","listTags","name"],"sources":["files.crud.ts"],"sourcesContent":["/**\n * Package mdbid does not have types.\n */\n// @ts-ignore\nimport mdbid from \"mdbid\";\nimport { NotFoundError } from \"@webiny/handler-graphql\";\nimport { NotAuthorizedError } from \"@webiny/api-security\";\nimport {\n CreatedBy,\n File,\n FileManagerContext,\n FileManagerFilesStorageOperationsListParamsWhere,\n FileManagerFilesStorageOperationsTagsParamsWhere,\n FilePermission,\n FilesListOpts\n} from \"~/types\";\nimport checkBasePermissions from \"./utils/checkBasePermissions\";\nimport { ContextPlugin } from \"@webiny/api\";\nimport { FilePlugin } from \"~/plugins/definitions/FilePlugin\";\nimport { FilesStorageOperationsProviderPlugin } from \"~/plugins/definitions/FilesStorageOperationsProviderPlugin\";\nimport WebinyError from \"@webiny/error\";\nimport { runLifecycleEvent } from \"~/plugins/crud/utils/lifecycleEvents\";\n\nconst BATCH_CREATE_MAX_FILES = 20;\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, context: FileManagerContext) => {\n if (permission?.own === true) {\n const identity = context.security.getIdentity();\n if (file.createdBy.id !== identity.id) {\n throw new NotAuthorizedError();\n }\n }\n};\n\nconst getLocaleCode = (context: FileManagerContext): string => {\n if (!context.i18n) {\n throw new WebinyError(\"Missing i18n on the FileManagerContext.\", \"MISSING_I18N\");\n }\n\n const locale = context.i18n.getContentLocale();\n if (!locale) {\n throw new WebinyError(\n \"Missing content locale on the FileManagerContext.\",\n \"MISSING_I18N_CONTENT_LOCALE\"\n );\n }\n\n if (!locale.code) {\n throw new WebinyError(\n \"Missing content locale code on the FileManagerContext.\",\n \"MISSING_I18N_CONTENT_LOCALE_CODE\"\n );\n }\n return locale.code;\n};\n\nconst filesContextCrudPlugin = new ContextPlugin<FileManagerContext>(async context => {\n const pluginType = FilesStorageOperationsProviderPlugin.type;\n\n const providerPlugin = context.plugins\n .byType<FilesStorageOperationsProviderPlugin>(pluginType)\n .find(() => true);\n\n if (!providerPlugin) {\n throw new WebinyError(`Missing \"${pluginType}\" plugin.`, \"PLUGIN_NOT_FOUND\", {\n type: pluginType\n });\n }\n\n const storageOperations = await providerPlugin.provide({\n context\n });\n\n if (!context.fileManager) {\n context.fileManager = {} as any;\n }\n\n const filePlugins = context.plugins.byType<FilePlugin>(FilePlugin.type);\n\n context.fileManager.files = {\n async getFile(id: string) {\n const permission = await checkBasePermissions(context, { rwd: \"r\" });\n\n const file = await storageOperations.get({\n where: {\n id,\n tenant: context.tenancy.getCurrentTenant().id,\n locale: getLocaleCode(context)\n }\n });\n\n if (!file) {\n throw new NotFoundError(`File with id \"${id}\" does not exists.`);\n }\n\n checkOwnership(file, permission, context);\n\n return file;\n },\n async createFile(input) {\n await checkBasePermissions(context, { rwd: \"w\" });\n const identity = context.security.getIdentity();\n const tenant = context.tenancy.getCurrentTenant();\n\n const id = mdbid();\n\n const file: File = {\n ...input,\n tags: Array.isArray(input.tags) ? input.tags : [],\n id,\n meta: {\n private: false,\n ...(input.meta || {})\n },\n tenant: tenant.id,\n createdOn: new Date().toISOString(),\n createdBy: {\n id: identity.id,\n displayName: identity.displayName,\n type: identity.type\n },\n locale: getLocaleCode(context),\n webinyVersion: context.WEBINY_VERSION\n };\n\n try {\n await runLifecycleEvent(\"beforeCreate\", {\n context,\n plugins: filePlugins,\n data: file\n });\n const result = await storageOperations.create({\n file\n });\n await runLifecycleEvent(\"afterCreate\", {\n context,\n plugins: filePlugins,\n data: file,\n file: result\n });\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(context, { rwd: \"w\" });\n\n const original = await storageOperations.get({\n where: {\n id,\n tenant: context.tenancy.getCurrentTenant().id,\n locale: getLocaleCode(context)\n }\n });\n\n if (!original) {\n throw new NotFoundError(`File with id \"${id}\" does not exists.`);\n }\n\n checkOwnership(original, permission, context);\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 id: original.id,\n webinyVersion: context.WEBINY_VERSION\n };\n\n try {\n await runLifecycleEvent(\"beforeUpdate\", {\n context,\n plugins: filePlugins,\n original,\n data: file\n });\n const result = await storageOperations.update({\n original,\n file\n });\n await runLifecycleEvent(\"afterUpdate\", {\n context,\n plugins: filePlugins,\n original,\n data: file,\n file: result\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(context, { rwd: \"d\" });\n\n const file = await storageOperations.get({\n where: {\n id,\n tenant: context.tenancy.getCurrentTenant().id,\n locale: getLocaleCode(context)\n }\n });\n if (!file) {\n throw new NotFoundError(`File with id \"${id}\" does not exists.`);\n }\n\n checkOwnership(file, permission, context);\n\n try {\n await runLifecycleEvent(\"beforeDelete\", {\n context,\n plugins: filePlugins,\n file\n });\n await storageOperations.delete({\n file\n });\n await runLifecycleEvent(\"afterDelete\", {\n context,\n plugins: filePlugins,\n file\n });\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) {\n if (!Array.isArray(inputs)) {\n throw new WebinyError(`\"data\" must be an array.`, \"CREATE_FILES_NON_ARRAY\");\n }\n\n if (inputs.length === 0) {\n throw new WebinyError(\n `\"data\" argument must contain at least one file.`,\n \"CREATE_FILES_MIN_FILES\"\n );\n }\n\n if (inputs.length > BATCH_CREATE_MAX_FILES) {\n throw new WebinyError(\n `\"data\" argument must not contain more than ${BATCH_CREATE_MAX_FILES} files.`,\n \"CREATE_FILES_MAX_FILES\"\n );\n }\n\n await checkBasePermissions(context, { rwd: \"w\" });\n\n const identity = context.security.getIdentity();\n const tenant = context.tenancy.getCurrentTenant();\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 meta: {\n private: false,\n ...(input.meta || {})\n },\n id: mdbid(),\n tenant: tenant.id,\n createdOn: new Date().toISOString(),\n createdBy,\n locale: getLocaleCode(context),\n webinyVersion: context.WEBINY_VERSION\n };\n });\n\n try {\n await runLifecycleEvent(\"beforeBatchCreate\", {\n context,\n plugins: filePlugins,\n data: files\n });\n const results = await storageOperations.createBatch({\n files\n });\n await runLifecycleEvent(\"afterBatchCreate\", {\n context,\n plugins: filePlugins,\n data: files,\n files: results\n });\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(context, { 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(context),\n tenant: context.tenancy.getCurrentTenant().id\n };\n /**\n * Always override the createdBy received from the user, if any.\n */\n if (permission.own === true) {\n const identity = context.security.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.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(context);\n\n const where: FileManagerFilesStorageOperationsTagsParamsWhere = {\n ...initialWhere,\n tenant: context.tenancy.getCurrentTenant().id,\n locale: getLocaleCode(context)\n };\n\n const params = {\n where,\n limit: limit || 100000,\n after\n };\n\n try {\n const [tags] = await storageOperations.tags(params);\n if (Array.isArray(tags) === false) {\n return [];\n }\n /**\n * just to keep it standardized, sort by the tag ASC\n */\n return tags.sort();\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\nfilesContextCrudPlugin.name = \"FileManagerFilesCrud\";\n\nexport default filesContextCrudPlugin;\n"],"mappings":";;;;;;;;AAIA;AACA;AACA;AAUA;AACA;AACA;AACA;AACA;AACA;AArBA;AACA;AACA;AACA;;AAoBA,MAAMA,sBAAsB,GAAG,EAAE;;AAEjC;AACA;AACA;AACA,MAAMC,cAAc,GAAG,CAACC,IAAU,EAAEC,UAA0B,EAAEC,OAA2B,KAAK;EAC5F,IAAI,CAAAD,UAAU,aAAVA,UAAU,uBAAVA,UAAU,CAAEE,GAAG,MAAK,IAAI,EAAE;IAC1B,MAAMC,QAAQ,GAAGF,OAAO,CAACG,QAAQ,CAACC,WAAW,EAAE;IAC/C,IAAIN,IAAI,CAACO,SAAS,CAACC,EAAE,KAAKJ,QAAQ,CAACI,EAAE,EAAE;MACnC,MAAM,IAAIC,+BAAkB,EAAE;IAClC;EACJ;AACJ,CAAC;AAED,MAAMC,aAAa,GAAIR,OAA2B,IAAa;EAC3D,IAAI,CAACA,OAAO,CAACS,IAAI,EAAE;IACf,MAAM,IAAIC,cAAW,CAAC,yCAAyC,EAAE,cAAc,CAAC;EACpF;EAEA,MAAMC,MAAM,GAAGX,OAAO,CAACS,IAAI,CAACG,gBAAgB,EAAE;EAC9C,IAAI,CAACD,MAAM,EAAE;IACT,MAAM,IAAID,cAAW,CACjB,mDAAmD,EACnD,6BAA6B,CAChC;EACL;EAEA,IAAI,CAACC,MAAM,CAACE,IAAI,EAAE;IACd,MAAM,IAAIH,cAAW,CACjB,wDAAwD,EACxD,kCAAkC,CACrC;EACL;EACA,OAAOC,MAAM,CAACE,IAAI;AACtB,CAAC;AAED,MAAMC,sBAAsB,GAAG,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AAK,EAAEA,KAAK,IAAI,MAAM;QACtBI;MACJ,CAAC;MAED,IAAI;QACA,MAAM,CAAClC,IAAI,CAAC,GAAG,MAAMlB,iBAAiB,CAACkB,IAAI,CAAC6B,MAAM,CAAC;QACnD,IAAI5B,KAAK,CAACC,OAAO,CAACF,IAAI,CAAC,KAAK,KAAK,EAAE;UAC/B,OAAO,EAAE;QACb;QACA;AAChB;AACA;QACgB,OAAOA,IAAI,CAACoC,IAAI,EAAE;MACtB,CAAC,CAAC,OAAOrB,EAAE,EAAE;QACT,MAAM,IAAI9C,cAAW,CACjB8C,EAAE,CAACC,OAAO,IAAI,4BAA4B,EAC1CD,EAAE,CAAC3C,IAAI,IAAI,uBAAuB,8DAE1B2C,EAAE,CAACH,IAAI,IAAI,CAAC,CAAC;UACjBiB;QAAM,GAEb;MACL;IACJ;EACJ,CAAC;AACL,CAAC,CAAC;AAEFxD,sBAAsB,CAACwE,IAAI,GAAG,sBAAsB;AAAC,eAEtCxE,sBAAsB;AAAA"}
@@ -1,5 +1,5 @@
1
1
  import { FileManagerContext } from "../../types";
2
- import { ContextPlugin } from "@webiny/handler/plugins/ContextPlugin";
2
+ import { ContextPlugin } from "@webiny/api";
3
3
  export declare const SETTINGS_KEY = "file-manager";
4
4
  declare const settingsCrudContextPlugin: ContextPlugin<FileManagerContext>;
5
5
  export default settingsCrudContextPlugin;