@webiny/api-file-manager 0.0.0-unstable.78f581c1d2 → 0.0.0-unstable.7f63ea0744

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 (67) hide show
  1. package/handlers/download/index.js +7 -26
  2. package/handlers/download/index.js.map +1 -1
  3. package/handlers/manage/index.js +0 -16
  4. package/handlers/manage/index.js.map +1 -1
  5. package/handlers/transform/index.js +6 -16
  6. package/handlers/transform/index.js.map +1 -1
  7. package/handlers/transform/loaders/imageLoader.js +0 -17
  8. package/handlers/transform/loaders/imageLoader.js.map +1 -1
  9. package/handlers/transform/loaders/index.js +0 -3
  10. package/handlers/transform/loaders/index.js.map +1 -1
  11. package/handlers/transform/loaders/sanitizeImageTransformations.js +0 -13
  12. package/handlers/transform/loaders/sanitizeImageTransformations.js.map +1 -1
  13. package/handlers/transform/managers/imageManager.js +6 -14
  14. package/handlers/transform/managers/imageManager.js.map +1 -1
  15. package/handlers/transform/managers/index.js +0 -3
  16. package/handlers/transform/managers/index.js.map +1 -1
  17. package/handlers/transform/optimizeImage.js +0 -6
  18. package/handlers/transform/optimizeImage.js.map +1 -1
  19. package/handlers/transform/transformImage.js +0 -5
  20. package/handlers/transform/transformImage.js.map +1 -1
  21. package/handlers/transform/utils.js +0 -10
  22. package/handlers/transform/utils.js.map +1 -1
  23. package/handlers/utils/getEnvironment.js +0 -2
  24. package/handlers/utils/getEnvironment.js.map +1 -1
  25. package/handlers/utils/getObjectParams.js +0 -4
  26. package/handlers/utils/getObjectParams.js.map +1 -1
  27. package/handlers/utils/index.js +0 -3
  28. package/handlers/utils/index.js.map +1 -1
  29. package/package.json +19 -19
  30. package/plugins/crud/files/validation.js +0 -6
  31. package/plugins/crud/files/validation.js.map +1 -1
  32. package/plugins/crud/files.crud.js +2 -61
  33. package/plugins/crud/files.crud.js.map +1 -1
  34. package/plugins/crud/settings.crud.js +1 -18
  35. package/plugins/crud/settings.crud.js.map +1 -1
  36. package/plugins/crud/system.crud.js +2 -32
  37. package/plugins/crud/system.crud.js.map +1 -1
  38. package/plugins/crud/utils/checkBasePermissions.js +0 -8
  39. package/plugins/crud/utils/checkBasePermissions.js.map +1 -1
  40. package/plugins/crud/utils/createFileModel.js +0 -12
  41. package/plugins/crud/utils/createFileModel.js.map +1 -1
  42. package/plugins/crud/utils/lifecycleEvents.js +4 -12
  43. package/plugins/crud/utils/lifecycleEvents.js.map +1 -1
  44. package/plugins/definitions/FilePhysicalStoragePlugin.js +0 -11
  45. package/plugins/definitions/FilePhysicalStoragePlugin.js.map +1 -1
  46. package/plugins/definitions/FilePlugin.js +0 -18
  47. package/plugins/definitions/FilePlugin.js.map +1 -1
  48. package/plugins/definitions/FileStorageTransformPlugin.js +1 -12
  49. package/plugins/definitions/FileStorageTransformPlugin.js.map +1 -1
  50. package/plugins/definitions/FilesStorageOperationsProviderPlugin.js +0 -5
  51. package/plugins/definitions/FilesStorageOperationsProviderPlugin.js.map +1 -1
  52. package/plugins/definitions/InstallationPlugin.js +0 -11
  53. package/plugins/definitions/InstallationPlugin.js.map +1 -1
  54. package/plugins/definitions/SettingsStorageOperationsProviderPlugin.js +0 -5
  55. package/plugins/definitions/SettingsStorageOperationsProviderPlugin.js.map +1 -1
  56. package/plugins/definitions/SystemStorageOperationsProviderPlugin.js +0 -5
  57. package/plugins/definitions/SystemStorageOperationsProviderPlugin.js.map +1 -1
  58. package/plugins/graphql.js +2 -22
  59. package/plugins/graphql.js.map +1 -1
  60. package/plugins/index.js +0 -9
  61. package/plugins/index.js.map +1 -1
  62. package/plugins/storage/FileStorage.js +14 -32
  63. package/plugins/storage/FileStorage.js.map +1 -1
  64. package/plugins/storage/index.js +0 -4
  65. package/plugins/storage/index.js.map +1 -1
  66. package/utils.js +0 -2
  67. package/utils.js.map +1 -1
@@ -1,27 +1,22 @@
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
7
  exports.runLifecycleEvent = void 0;
9
-
10
8
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
11
-
12
9
  const _excluded = ["plugins"];
13
-
14
10
  // TODO @ts-refactor introduce pubsub methods
11
+
15
12
  const runLifecycleEvent = async (hook, params) => {
16
13
  const {
17
- plugins
18
- } = params,
19
- rest = (0, _objectWithoutProperties2.default)(params, _excluded);
20
-
14
+ plugins
15
+ } = params,
16
+ rest = (0, _objectWithoutProperties2.default)(params, _excluded);
21
17
  if (plugins.length === 0) {
22
18
  return;
23
19
  }
24
-
25
20
  for (const plugin of plugins) {
26
21
  if (!plugin[hook]) {
27
22
  continue;
@@ -29,10 +24,7 @@ const runLifecycleEvent = async (hook, params) => {
29
24
  /**
30
25
  * Keep any because we do not know which hook needs to be executed. This will be removed, so it does not matter.
31
26
  */
32
-
33
-
34
27
  await plugin[hook](rest);
35
28
  }
36
29
  };
37
-
38
30
  exports.runLifecycleEvent = runLifecycleEvent;
@@ -1 +1 @@
1
- {"version":3,"names":["runLifecycleEvent","hook","params","plugins","rest","length","plugin"],"sources":["lifecycleEvents.ts"],"sourcesContent":["// TODO @ts-refactor introduce pubsub methods\nimport { FilePlugin, FilePluginParams } from \"~/plugins/definitions/FilePlugin\";\nimport { FileManagerContext } from \"~/types\";\n\nexport const runLifecycleEvent = async (\n hook: keyof FilePluginParams,\n params: { context: FileManagerContext; plugins: FilePlugin[] } & Record<string, any>\n): Promise<void> => {\n const { plugins, ...rest } = params;\n if (plugins.length === 0) {\n return;\n }\n for (const plugin of plugins) {\n if (!plugin[hook]) {\n continue;\n }\n /**\n * Keep any because we do not know which hook needs to be executed. This will be removed, so it does not matter.\n */\n await plugin[hook](rest as any);\n }\n};\n"],"mappings":";;;;;;;;;;;;;AAAA;AAIO,MAAMA,iBAAiB,GAAG,OAC7BC,IAD6B,EAE7BC,MAF6B,KAGb;EAChB,MAAM;IAAEC;EAAF,IAAuBD,MAA7B;EAAA,MAAoBE,IAApB,0CAA6BF,MAA7B;;EACA,IAAIC,OAAO,CAACE,MAAR,KAAmB,CAAvB,EAA0B;IACtB;EACH;;EACD,KAAK,MAAMC,MAAX,IAAqBH,OAArB,EAA8B;IAC1B,IAAI,CAACG,MAAM,CAACL,IAAD,CAAX,EAAmB;MACf;IACH;IACD;AACR;AACA;;;IACQ,MAAMK,MAAM,CAACL,IAAD,CAAN,CAAaG,IAAb,CAAN;EACH;AACJ,CAjBM"}
1
+ {"version":3,"names":["runLifecycleEvent","hook","params","plugins","rest","length","plugin"],"sources":["lifecycleEvents.ts"],"sourcesContent":["// TODO @ts-refactor introduce pubsub methods\nimport { FilePlugin, FilePluginParams } from \"~/plugins/definitions/FilePlugin\";\nimport { FileManagerContext } from \"~/types\";\n\nexport const runLifecycleEvent = async (\n hook: keyof FilePluginParams,\n params: { context: FileManagerContext; plugins: FilePlugin[] } & Record<string, any>\n): Promise<void> => {\n const { plugins, ...rest } = params;\n if (plugins.length === 0) {\n return;\n }\n for (const plugin of plugins) {\n if (!plugin[hook]) {\n continue;\n }\n /**\n * Keep any because we do not know which hook needs to be executed. This will be removed, so it does not matter.\n */\n await plugin[hook](rest as any);\n }\n};\n"],"mappings":";;;;;;;;;AAAA;;AAIO,MAAMA,iBAAiB,GAAG,OAC7BC,IAA4B,EAC5BC,MAAoF,KACpE;EAChB,MAAM;MAAEC;IAAiB,CAAC,GAAGD,MAAM;IAAfE,IAAI,0CAAKF,MAAM;EACnC,IAAIC,OAAO,CAACE,MAAM,KAAK,CAAC,EAAE;IACtB;EACJ;EACA,KAAK,MAAMC,MAAM,IAAIH,OAAO,EAAE;IAC1B,IAAI,CAACG,MAAM,CAACL,IAAI,CAAC,EAAE;MACf;IACJ;IACA;AACR;AACA;IACQ,MAAMK,MAAM,CAACL,IAAI,CAAC,CAACG,IAAI,CAAQ;EACnC;AACJ,CAAC;AAAC"}
@@ -1,42 +1,31 @@
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
7
  exports.FilePhysicalStoragePlugin = void 0;
9
-
10
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
-
12
9
  var _plugins = require("@webiny/plugins");
13
-
14
10
  var _error = _interopRequireDefault(require("@webiny/error"));
15
-
16
11
  class FilePhysicalStoragePlugin extends _plugins.Plugin {
17
12
  constructor(params) {
18
13
  super();
19
14
  (0, _defineProperty2.default)(this, "_params", void 0);
20
15
  this._params = params;
21
16
  }
22
-
23
17
  async upload(params) {
24
18
  if (!this._params.upload) {
25
19
  throw new _error.default(`You must define the "upload" method of this plugin.`, "UPLOAD_METHOD_ERROR");
26
20
  }
27
-
28
21
  return this._params.upload(params);
29
22
  }
30
-
31
23
  async delete(params) {
32
24
  if (!this._params.delete) {
33
25
  throw new _error.default(`You must define the "delete" method of this plugin.`, "DELETE_METHOD_ERROR");
34
26
  }
35
-
36
27
  return this._params.delete(params);
37
28
  }
38
-
39
29
  }
40
-
41
30
  exports.FilePhysicalStoragePlugin = FilePhysicalStoragePlugin;
42
31
  (0, _defineProperty2.default)(FilePhysicalStoragePlugin, "type", "api-file-manager-storage");
@@ -1 +1 @@
1
- {"version":3,"names":["FilePhysicalStoragePlugin","Plugin","constructor","params","_params","upload","WebinyError","delete"],"sources":["FilePhysicalStoragePlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport WebinyError from \"@webiny/error\";\nimport { FileManagerSettings } from \"~/types\";\n\nexport interface FilePhysicalStoragePluginParams<\n U extends FilePhysicalStoragePluginUploadParams,\n D extends FilePhysicalStoragePluginDeleteParams\n> {\n upload: (args: U) => Promise<any>;\n delete: (args: D) => Promise<void>;\n}\n\nexport interface FilePhysicalStoragePluginUploadParams {\n settings: FileManagerSettings;\n buffer: Buffer;\n}\n\nexport interface FilePhysicalStoragePluginDeleteParams {\n key: string;\n}\n\nexport class FilePhysicalStoragePlugin<\n U extends FilePhysicalStoragePluginUploadParams = FilePhysicalStoragePluginUploadParams,\n D extends FilePhysicalStoragePluginDeleteParams = FilePhysicalStoragePluginDeleteParams\n> extends Plugin {\n public static override readonly type: string = \"api-file-manager-storage\";\n private readonly _params: FilePhysicalStoragePluginParams<U, D>;\n\n public constructor(params: FilePhysicalStoragePluginParams<U, D>) {\n super();\n this._params = params;\n }\n\n public async upload(params: U): Promise<any> {\n if (!this._params.upload) {\n throw new WebinyError(\n `You must define the \"upload\" method of this plugin.`,\n \"UPLOAD_METHOD_ERROR\"\n );\n }\n return this._params.upload(params);\n }\n\n public async delete(params: D): Promise<any> {\n if (!this._params.delete) {\n throw new WebinyError(\n `You must define the \"delete\" method of this plugin.`,\n \"DELETE_METHOD_ERROR\"\n );\n }\n return this._params.delete(params);\n }\n}\n"],"mappings":";;;;;;;;;;;AAAA;;AACA;;AAoBO,MAAMA,yBAAN,SAGGC,eAHH,CAGU;EAINC,WAAW,CAACC,MAAD,EAAgD;IAC9D;IAD8D;IAE9D,KAAKC,OAAL,GAAeD,MAAf;EACH;;EAEkB,MAANE,MAAM,CAACF,MAAD,EAA0B;IACzC,IAAI,CAAC,KAAKC,OAAL,CAAaC,MAAlB,EAA0B;MACtB,MAAM,IAAIC,cAAJ,CACD,qDADC,EAEF,qBAFE,CAAN;IAIH;;IACD,OAAO,KAAKF,OAAL,CAAaC,MAAb,CAAoBF,MAApB,CAAP;EACH;;EAEkB,MAANI,MAAM,CAACJ,MAAD,EAA0B;IACzC,IAAI,CAAC,KAAKC,OAAL,CAAaG,MAAlB,EAA0B;MACtB,MAAM,IAAID,cAAJ,CACD,qDADC,EAEF,qBAFE,CAAN;IAIH;;IACD,OAAO,KAAKF,OAAL,CAAaG,MAAb,CAAoBJ,MAApB,CAAP;EACH;;AA3BY;;;8BAHJH,yB,UAIsC,0B"}
1
+ {"version":3,"names":["FilePhysicalStoragePlugin","Plugin","constructor","params","_params","upload","WebinyError","delete"],"sources":["FilePhysicalStoragePlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport WebinyError from \"@webiny/error\";\nimport { FileManagerSettings } from \"~/types\";\n\nexport interface FilePhysicalStoragePluginParams<\n U extends FilePhysicalStoragePluginUploadParams,\n D extends FilePhysicalStoragePluginDeleteParams\n> {\n upload: (args: U) => Promise<any>;\n delete: (args: D) => Promise<void>;\n}\n\nexport interface FilePhysicalStoragePluginUploadParams {\n settings: FileManagerSettings;\n buffer: Buffer;\n}\n\nexport interface FilePhysicalStoragePluginDeleteParams {\n key: string;\n}\n\nexport class FilePhysicalStoragePlugin<\n U extends FilePhysicalStoragePluginUploadParams = FilePhysicalStoragePluginUploadParams,\n D extends FilePhysicalStoragePluginDeleteParams = FilePhysicalStoragePluginDeleteParams\n> extends Plugin {\n public static override readonly type: string = \"api-file-manager-storage\";\n private readonly _params: FilePhysicalStoragePluginParams<U, D>;\n\n public constructor(params: FilePhysicalStoragePluginParams<U, D>) {\n super();\n this._params = params;\n }\n\n public async upload(params: U): Promise<any> {\n if (!this._params.upload) {\n throw new WebinyError(\n `You must define the \"upload\" method of this plugin.`,\n \"UPLOAD_METHOD_ERROR\"\n );\n }\n return this._params.upload(params);\n }\n\n public async delete(params: D): Promise<any> {\n if (!this._params.delete) {\n throw new WebinyError(\n `You must define the \"delete\" method of this plugin.`,\n \"DELETE_METHOD_ERROR\"\n );\n }\n return this._params.delete(params);\n }\n}\n"],"mappings":";;;;;;;;AAAA;AACA;AAoBO,MAAMA,yBAAyB,SAG5BC,eAAM,CAAC;EAINC,WAAW,CAACC,MAA6C,EAAE;IAC9D,KAAK,EAAE;IAAC;IACR,IAAI,CAACC,OAAO,GAAGD,MAAM;EACzB;EAEA,MAAaE,MAAM,CAACF,MAAS,EAAgB;IACzC,IAAI,CAAC,IAAI,CAACC,OAAO,CAACC,MAAM,EAAE;MACtB,MAAM,IAAIC,cAAW,CAChB,qDAAoD,EACrD,qBAAqB,CACxB;IACL;IACA,OAAO,IAAI,CAACF,OAAO,CAACC,MAAM,CAACF,MAAM,CAAC;EACtC;EAEA,MAAaI,MAAM,CAACJ,MAAS,EAAgB;IACzC,IAAI,CAAC,IAAI,CAACC,OAAO,CAACG,MAAM,EAAE;MACtB,MAAM,IAAID,cAAW,CAChB,qDAAoD,EACrD,qBAAqB,CACxB;IACL;IACA,OAAO,IAAI,CAACF,OAAO,CAACG,MAAM,CAACJ,MAAM,CAAC;EACtC;AACJ;AAAC;AAAA,8BA/BYH,yBAAyB,UAIa,0BAA0B"}
@@ -1,70 +1,52 @@
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
7
  exports.FilePlugin = void 0;
9
-
10
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
-
12
9
  var _plugins = require("@webiny/plugins");
13
-
14
10
  class FilePlugin extends _plugins.Plugin {
15
11
  constructor(params) {
16
12
  super();
17
13
  (0, _defineProperty2.default)(this, "_params", void 0);
18
14
  this._params = params || {};
19
15
  }
20
-
21
16
  async beforeCreate(params) {
22
17
  await this._execute("beforeCreate", params);
23
18
  }
24
-
25
19
  async afterCreate(params) {
26
20
  await this._execute("afterCreate", params);
27
21
  }
28
-
29
22
  async beforeUpdate(params) {
30
23
  await this._execute("beforeUpdate", params);
31
24
  }
32
-
33
25
  async afterUpdate(params) {
34
26
  await this._execute("afterUpdate", params);
35
27
  }
36
-
37
28
  async beforeBatchCreate(params) {
38
29
  await this._execute("beforeBatchCreate", params);
39
30
  }
40
-
41
31
  async afterBatchCreate(params) {
42
32
  await this._execute("afterBatchCreate", params);
43
33
  }
44
-
45
34
  async beforeDelete(params) {
46
35
  await this._execute("beforeDelete", params);
47
36
  }
48
-
49
37
  async afterDelete(params) {
50
38
  await this._execute("afterDelete", params);
51
39
  }
52
40
  /**
53
41
  * Keep any here because it can be a number of params. Method is internal so no need to complicate the code.
54
42
  */
55
-
56
-
57
43
  async _execute(callback, params) {
58
44
  const cb = this._params[callback];
59
-
60
45
  if (typeof cb !== "function") {
61
46
  return;
62
47
  }
63
-
64
48
  await cb(params);
65
49
  }
66
-
67
50
  }
68
-
69
51
  exports.FilePlugin = FilePlugin;
70
52
  (0, _defineProperty2.default)(FilePlugin, "type", "fm.file");
@@ -1 +1 @@
1
- {"version":3,"names":["FilePlugin","Plugin","constructor","params","_params","beforeCreate","_execute","afterCreate","beforeUpdate","afterUpdate","beforeBatchCreate","afterBatchCreate","beforeDelete","afterDelete","callback","cb"],"sources":["FilePlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport { File, FileManagerContext } from \"~/types\";\n\n/**\n * Parameters for beforeCreate lifecycle.\n */\nexport interface BeforeCreateParams {\n context: FileManagerContext;\n /**\n * Data to be inserted into the storage.\n */\n data: File;\n}\n/**\n * Parameters for afterCreate lifecycle.\n */\nexport interface AfterCreateParams {\n context: FileManagerContext;\n /**\n * Data that was inserted into the storage.\n */\n data: File;\n /**\n * Result of the storage operations create method.\n * Possibly changed something on the \"data\".\n */\n file: File;\n}\n/**\n * Parameters for beforeUpdate lifecycle.\n */\nexport interface BeforeUpdateParams {\n context: FileManagerContext;\n /**\n * Original file from the storage.\n */\n original: File;\n /**\n * Data to be updated to the storage.\n */\n data: File;\n}\n/**\n * Parameters for afterUpdate lifecycle.\n */\nexport interface AfterUpdateParams {\n context: FileManagerContext;\n /**\n * Original file from the storage.\n */\n original: File;\n /**\n * Data that was updated in the storage.\n */\n data: File;\n /**\n * Result of the storage operations update method.\n * Possibly changed something on the \"data\".\n */\n file: File;\n}\n/**\n * Parameters for beforeBatchCreate lifecycle.\n */\nexport interface BeforeBatchCreateParams {\n context: FileManagerContext;\n /**\n * Files to be inserted into the storage.\n */\n data: File[];\n}\n\n/**\n * Parameters for afterBatchCreate lifecycle.\n */\nexport interface AfterBatchCreateParams {\n context: FileManagerContext;\n /**\n * Files that were inserted into the storage.\n */\n data: File[];\n /**\n * Results of the insert.\n */\n files: File[];\n}\n/**\n * Parameters for beforeDelete lifecycle.\n */\nexport interface BeforeDeleteParams {\n context: FileManagerContext;\n /**\n * File to be deleted from the storage.\n */\n file: File;\n}\n/**\n * Parameters for afterDelete lifecycle.\n */\nexport interface AfterDeleteParams {\n context: FileManagerContext;\n /**\n * File that was deleted from the storage.\n */\n file: File;\n}\n\n/**\n * Definition for the constructor parameters of the FilePlugin.\n *\n * @category FilePlugin\n */\nexport interface FilePluginParams {\n beforeCreate?: (params: BeforeCreateParams) => Promise<void>;\n afterCreate?: (params: AfterCreateParams) => Promise<void>;\n beforeUpdate?: (params: BeforeUpdateParams) => Promise<void>;\n afterUpdate?: (params: AfterUpdateParams) => Promise<void>;\n beforeBatchCreate?: (params: BeforeBatchCreateParams) => Promise<void>;\n afterBatchCreate?: (params: AfterBatchCreateParams) => Promise<void>;\n beforeDelete?: (params: BeforeDeleteParams) => Promise<void>;\n afterDelete?: (params: AfterDeleteParams) => Promise<void>;\n}\n\nexport class FilePlugin extends Plugin {\n public static override readonly type: string = \"fm.file\";\n private readonly _params: FilePluginParams;\n\n public constructor(params?: FilePluginParams) {\n super();\n this._params = params || ({} as any);\n }\n\n public async beforeCreate(params: BeforeCreateParams): Promise<void> {\n await this._execute(\"beforeCreate\", params);\n }\n\n public async afterCreate(params: AfterCreateParams): Promise<void> {\n await this._execute(\"afterCreate\", params);\n }\n\n public async beforeUpdate(params: BeforeUpdateParams): Promise<void> {\n await this._execute(\"beforeUpdate\", params);\n }\n\n public async afterUpdate(params: AfterUpdateParams): Promise<void> {\n await this._execute(\"afterUpdate\", params);\n }\n\n public async beforeBatchCreate(params: BeforeBatchCreateParams): Promise<void> {\n await this._execute(\"beforeBatchCreate\", params);\n }\n\n public async afterBatchCreate(params: AfterBatchCreateParams): Promise<void> {\n await this._execute(\"afterBatchCreate\", params);\n }\n\n public async beforeDelete(params: BeforeDeleteParams): Promise<void> {\n await this._execute(\"beforeDelete\", params);\n }\n\n public async afterDelete(params: AfterDeleteParams): Promise<void> {\n await this._execute(\"afterDelete\", params);\n }\n /**\n * Keep any here because it can be a number of params. Method is internal so no need to complicate the code.\n */\n private async _execute(callback: keyof FilePluginParams, params: any): Promise<void> {\n const cb = this._params[callback];\n if (typeof cb !== \"function\") {\n return;\n }\n await cb(params);\n }\n}\n"],"mappings":";;;;;;;;;;;AAAA;;AA2HO,MAAMA,UAAN,SAAyBC,eAAzB,CAAgC;EAI5BC,WAAW,CAACC,MAAD,EAA4B;IAC1C;IAD0C;IAE1C,KAAKC,OAAL,GAAeD,MAAM,IAAK,EAA1B;EACH;;EAEwB,MAAZE,YAAY,CAACF,MAAD,EAA4C;IACjE,MAAM,KAAKG,QAAL,CAAc,cAAd,EAA8BH,MAA9B,CAAN;EACH;;EAEuB,MAAXI,WAAW,CAACJ,MAAD,EAA2C;IAC/D,MAAM,KAAKG,QAAL,CAAc,aAAd,EAA6BH,MAA7B,CAAN;EACH;;EAEwB,MAAZK,YAAY,CAACL,MAAD,EAA4C;IACjE,MAAM,KAAKG,QAAL,CAAc,cAAd,EAA8BH,MAA9B,CAAN;EACH;;EAEuB,MAAXM,WAAW,CAACN,MAAD,EAA2C;IAC/D,MAAM,KAAKG,QAAL,CAAc,aAAd,EAA6BH,MAA7B,CAAN;EACH;;EAE6B,MAAjBO,iBAAiB,CAACP,MAAD,EAAiD;IAC3E,MAAM,KAAKG,QAAL,CAAc,mBAAd,EAAmCH,MAAnC,CAAN;EACH;;EAE4B,MAAhBQ,gBAAgB,CAACR,MAAD,EAAgD;IACzE,MAAM,KAAKG,QAAL,CAAc,kBAAd,EAAkCH,MAAlC,CAAN;EACH;;EAEwB,MAAZS,YAAY,CAACT,MAAD,EAA4C;IACjE,MAAM,KAAKG,QAAL,CAAc,cAAd,EAA8BH,MAA9B,CAAN;EACH;;EAEuB,MAAXU,WAAW,CAACV,MAAD,EAA2C;IAC/D,MAAM,KAAKG,QAAL,CAAc,aAAd,EAA6BH,MAA7B,CAAN;EACH;EACD;AACJ;AACA;;;EAC0B,MAARG,QAAQ,CAACQ,QAAD,EAAmCX,MAAnC,EAA+D;IACjF,MAAMY,EAAE,GAAG,KAAKX,OAAL,CAAaU,QAAb,CAAX;;IACA,IAAI,OAAOC,EAAP,KAAc,UAAlB,EAA8B;MAC1B;IACH;;IACD,MAAMA,EAAE,CAACZ,MAAD,CAAR;EACH;;AAjDkC;;;8BAA1BH,U,UACsC,S"}
1
+ {"version":3,"names":["FilePlugin","Plugin","constructor","params","_params","beforeCreate","_execute","afterCreate","beforeUpdate","afterUpdate","beforeBatchCreate","afterBatchCreate","beforeDelete","afterDelete","callback","cb"],"sources":["FilePlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport { File, FileManagerContext } from \"~/types\";\n\n/**\n * Parameters for beforeCreate lifecycle.\n */\nexport interface BeforeCreateParams {\n context: FileManagerContext;\n /**\n * Data to be inserted into the storage.\n */\n data: File;\n}\n/**\n * Parameters for afterCreate lifecycle.\n */\nexport interface AfterCreateParams {\n context: FileManagerContext;\n /**\n * Data that was inserted into the storage.\n */\n data: File;\n /**\n * Result of the storage operations create method.\n * Possibly changed something on the \"data\".\n */\n file: File;\n}\n/**\n * Parameters for beforeUpdate lifecycle.\n */\nexport interface BeforeUpdateParams {\n context: FileManagerContext;\n /**\n * Original file from the storage.\n */\n original: File;\n /**\n * Data to be updated to the storage.\n */\n data: File;\n}\n/**\n * Parameters for afterUpdate lifecycle.\n */\nexport interface AfterUpdateParams {\n context: FileManagerContext;\n /**\n * Original file from the storage.\n */\n original: File;\n /**\n * Data that was updated in the storage.\n */\n data: File;\n /**\n * Result of the storage operations update method.\n * Possibly changed something on the \"data\".\n */\n file: File;\n}\n/**\n * Parameters for beforeBatchCreate lifecycle.\n */\nexport interface BeforeBatchCreateParams {\n context: FileManagerContext;\n /**\n * Files to be inserted into the storage.\n */\n data: File[];\n}\n\n/**\n * Parameters for afterBatchCreate lifecycle.\n */\nexport interface AfterBatchCreateParams {\n context: FileManagerContext;\n /**\n * Files that were inserted into the storage.\n */\n data: File[];\n /**\n * Results of the insert.\n */\n files: File[];\n}\n/**\n * Parameters for beforeDelete lifecycle.\n */\nexport interface BeforeDeleteParams {\n context: FileManagerContext;\n /**\n * File to be deleted from the storage.\n */\n file: File;\n}\n/**\n * Parameters for afterDelete lifecycle.\n */\nexport interface AfterDeleteParams {\n context: FileManagerContext;\n /**\n * File that was deleted from the storage.\n */\n file: File;\n}\n\n/**\n * Definition for the constructor parameters of the FilePlugin.\n *\n * @category FilePlugin\n */\nexport interface FilePluginParams {\n beforeCreate?: (params: BeforeCreateParams) => Promise<void>;\n afterCreate?: (params: AfterCreateParams) => Promise<void>;\n beforeUpdate?: (params: BeforeUpdateParams) => Promise<void>;\n afterUpdate?: (params: AfterUpdateParams) => Promise<void>;\n beforeBatchCreate?: (params: BeforeBatchCreateParams) => Promise<void>;\n afterBatchCreate?: (params: AfterBatchCreateParams) => Promise<void>;\n beforeDelete?: (params: BeforeDeleteParams) => Promise<void>;\n afterDelete?: (params: AfterDeleteParams) => Promise<void>;\n}\n\nexport class FilePlugin extends Plugin {\n public static override readonly type: string = \"fm.file\";\n private readonly _params: FilePluginParams;\n\n public constructor(params?: FilePluginParams) {\n super();\n this._params = params || ({} as any);\n }\n\n public async beforeCreate(params: BeforeCreateParams): Promise<void> {\n await this._execute(\"beforeCreate\", params);\n }\n\n public async afterCreate(params: AfterCreateParams): Promise<void> {\n await this._execute(\"afterCreate\", params);\n }\n\n public async beforeUpdate(params: BeforeUpdateParams): Promise<void> {\n await this._execute(\"beforeUpdate\", params);\n }\n\n public async afterUpdate(params: AfterUpdateParams): Promise<void> {\n await this._execute(\"afterUpdate\", params);\n }\n\n public async beforeBatchCreate(params: BeforeBatchCreateParams): Promise<void> {\n await this._execute(\"beforeBatchCreate\", params);\n }\n\n public async afterBatchCreate(params: AfterBatchCreateParams): Promise<void> {\n await this._execute(\"afterBatchCreate\", params);\n }\n\n public async beforeDelete(params: BeforeDeleteParams): Promise<void> {\n await this._execute(\"beforeDelete\", params);\n }\n\n public async afterDelete(params: AfterDeleteParams): Promise<void> {\n await this._execute(\"afterDelete\", params);\n }\n /**\n * Keep any here because it can be a number of params. Method is internal so no need to complicate the code.\n */\n private async _execute(callback: keyof FilePluginParams, params: any): Promise<void> {\n const cb = this._params[callback];\n if (typeof cb !== \"function\") {\n return;\n }\n await cb(params);\n }\n}\n"],"mappings":";;;;;;;;AAAA;AA2HO,MAAMA,UAAU,SAASC,eAAM,CAAC;EAI5BC,WAAW,CAACC,MAAyB,EAAE;IAC1C,KAAK,EAAE;IAAC;IACR,IAAI,CAACC,OAAO,GAAGD,MAAM,IAAK,CAAC,CAAS;EACxC;EAEA,MAAaE,YAAY,CAACF,MAA0B,EAAiB;IACjE,MAAM,IAAI,CAACG,QAAQ,CAAC,cAAc,EAAEH,MAAM,CAAC;EAC/C;EAEA,MAAaI,WAAW,CAACJ,MAAyB,EAAiB;IAC/D,MAAM,IAAI,CAACG,QAAQ,CAAC,aAAa,EAAEH,MAAM,CAAC;EAC9C;EAEA,MAAaK,YAAY,CAACL,MAA0B,EAAiB;IACjE,MAAM,IAAI,CAACG,QAAQ,CAAC,cAAc,EAAEH,MAAM,CAAC;EAC/C;EAEA,MAAaM,WAAW,CAACN,MAAyB,EAAiB;IAC/D,MAAM,IAAI,CAACG,QAAQ,CAAC,aAAa,EAAEH,MAAM,CAAC;EAC9C;EAEA,MAAaO,iBAAiB,CAACP,MAA+B,EAAiB;IAC3E,MAAM,IAAI,CAACG,QAAQ,CAAC,mBAAmB,EAAEH,MAAM,CAAC;EACpD;EAEA,MAAaQ,gBAAgB,CAACR,MAA8B,EAAiB;IACzE,MAAM,IAAI,CAACG,QAAQ,CAAC,kBAAkB,EAAEH,MAAM,CAAC;EACnD;EAEA,MAAaS,YAAY,CAACT,MAA0B,EAAiB;IACjE,MAAM,IAAI,CAACG,QAAQ,CAAC,cAAc,EAAEH,MAAM,CAAC;EAC/C;EAEA,MAAaU,WAAW,CAACV,MAAyB,EAAiB;IAC/D,MAAM,IAAI,CAACG,QAAQ,CAAC,aAAa,EAAEH,MAAM,CAAC;EAC9C;EACA;AACJ;AACA;EACI,MAAcG,QAAQ,CAACQ,QAAgC,EAAEX,MAAW,EAAiB;IACjF,MAAMY,EAAE,GAAG,IAAI,CAACX,OAAO,CAACU,QAAQ,CAAC;IACjC,IAAI,OAAOC,EAAE,KAAK,UAAU,EAAE;MAC1B;IACJ;IACA,MAAMA,EAAE,CAACZ,MAAM,CAAC;EACpB;AACJ;AAAC;AAAA,8BAlDYH,UAAU,UAC4B,SAAS"}
@@ -1,33 +1,27 @@
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
7
  exports.FileStorageTransformPlugin = void 0;
9
-
10
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
-
12
9
  var _plugins = require("@webiny/plugins");
13
-
14
10
  class FileStorageTransformPlugin extends _plugins.Plugin {
15
11
  constructor(params) {
16
12
  super();
17
13
  (0, _defineProperty2.default)(this, "_params", void 0);
18
14
  this._params = params;
19
15
  }
16
+
20
17
  /**
21
18
  * Transform the file value into something that can be stored.
22
19
  * Be aware that you must return the whole file object.
23
20
  */
24
-
25
-
26
21
  async toStorage(params) {
27
22
  if (!this._params.toStorage) {
28
23
  return params.file;
29
24
  }
30
-
31
25
  return this._params.toStorage(params);
32
26
  }
33
27
  /**
@@ -35,17 +29,12 @@ class FileStorageTransformPlugin extends _plugins.Plugin {
35
29
  * Be aware that you must return the whole file object.
36
30
  * This method MUST reverse what ever toStorage method changed on the file object.
37
31
  */
38
-
39
-
40
32
  async fromStorage(params) {
41
33
  if (!this._params.fromStorage) {
42
34
  return params.file;
43
35
  }
44
-
45
36
  return this._params.fromStorage(params);
46
37
  }
47
-
48
38
  }
49
-
50
39
  exports.FileStorageTransformPlugin = FileStorageTransformPlugin;
51
40
  (0, _defineProperty2.default)(FileStorageTransformPlugin, "type", "fm.files.storage.transform");
@@ -1 +1 @@
1
- {"version":3,"names":["FileStorageTransformPlugin","Plugin","constructor","params","_params","toStorage","file","fromStorage"],"sources":["FileStorageTransformPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport { File } from \"~/types\";\n\nexport interface FileStorageTransformPluginToParams {\n /**\n * File that is being sent to the storage operations method.\n */\n file: File & Record<string, any>;\n}\n\nexport interface FileStorageTransformPluginFromParams {\n /**\n * File that was fetched from the storage operations method.\n */\n file: File & Record<string, any>;\n}\n\nexport interface FileStorageTransformPluginParams {\n toStorage?: (params: FileStorageTransformPluginToParams) => Promise<File & Record<string, any>>;\n fromStorage?: (\n params: FileStorageTransformPluginFromParams\n ) => Promise<File & Record<string, any>>;\n}\n\nexport class FileStorageTransformPlugin extends Plugin {\n public static override readonly type: string = \"fm.files.storage.transform\";\n private readonly _params: FileStorageTransformPluginParams;\n\n public constructor(params: FileStorageTransformPluginParams) {\n super();\n\n this._params = params;\n }\n\n /**\n * Transform the file value into something that can be stored.\n * Be aware that you must return the whole file object.\n */\n public async toStorage(\n params: FileStorageTransformPluginToParams\n ): Promise<File & Record<string, any>> {\n if (!this._params.toStorage) {\n return params.file;\n }\n return this._params.toStorage(params);\n }\n /**\n * Transform the file value from the storage type to one required by our system.\n * Be aware that you must return the whole file object.\n * This method MUST reverse what ever toStorage method changed on the file object.\n */\n public async fromStorage(\n params: FileStorageTransformPluginFromParams\n ): Promise<File & Record<string, any>> {\n if (!this._params.fromStorage) {\n return params.file;\n }\n return this._params.fromStorage(params);\n }\n}\n"],"mappings":";;;;;;;;;;;AAAA;;AAwBO,MAAMA,0BAAN,SAAyCC,eAAzC,CAAgD;EAI5CC,WAAW,CAACC,MAAD,EAA2C;IACzD;IADyD;IAGzD,KAAKC,OAAL,GAAeD,MAAf;EACH;EAED;AACJ;AACA;AACA;;;EAC0B,MAATE,SAAS,CAClBF,MADkB,EAEiB;IACnC,IAAI,CAAC,KAAKC,OAAL,CAAaC,SAAlB,EAA6B;MACzB,OAAOF,MAAM,CAACG,IAAd;IACH;;IACD,OAAO,KAAKF,OAAL,CAAaC,SAAb,CAAuBF,MAAvB,CAAP;EACH;EACD;AACJ;AACA;AACA;AACA;;;EAC4B,MAAXI,WAAW,CACpBJ,MADoB,EAEe;IACnC,IAAI,CAAC,KAAKC,OAAL,CAAaG,WAAlB,EAA+B;MAC3B,OAAOJ,MAAM,CAACG,IAAd;IACH;;IACD,OAAO,KAAKF,OAAL,CAAaG,WAAb,CAAyBJ,MAAzB,CAAP;EACH;;AAlCkD;;;8BAA1CH,0B,UACsC,4B"}
1
+ {"version":3,"names":["FileStorageTransformPlugin","Plugin","constructor","params","_params","toStorage","file","fromStorage"],"sources":["FileStorageTransformPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport { File } from \"~/types\";\n\nexport interface FileStorageTransformPluginToParams {\n /**\n * File that is being sent to the storage operations method.\n */\n file: File & Record<string, any>;\n}\n\nexport interface FileStorageTransformPluginFromParams {\n /**\n * File that was fetched from the storage operations method.\n */\n file: File & Record<string, any>;\n}\n\nexport interface FileStorageTransformPluginParams {\n toStorage?: (params: FileStorageTransformPluginToParams) => Promise<File & Record<string, any>>;\n fromStorage?: (\n params: FileStorageTransformPluginFromParams\n ) => Promise<File & Record<string, any>>;\n}\n\nexport class FileStorageTransformPlugin extends Plugin {\n public static override readonly type: string = \"fm.files.storage.transform\";\n private readonly _params: FileStorageTransformPluginParams;\n\n public constructor(params: FileStorageTransformPluginParams) {\n super();\n\n this._params = params;\n }\n\n /**\n * Transform the file value into something that can be stored.\n * Be aware that you must return the whole file object.\n */\n public async toStorage(\n params: FileStorageTransformPluginToParams\n ): Promise<File & Record<string, any>> {\n if (!this._params.toStorage) {\n return params.file;\n }\n return this._params.toStorage(params);\n }\n /**\n * Transform the file value from the storage type to one required by our system.\n * Be aware that you must return the whole file object.\n * This method MUST reverse what ever toStorage method changed on the file object.\n */\n public async fromStorage(\n params: FileStorageTransformPluginFromParams\n ): Promise<File & Record<string, any>> {\n if (!this._params.fromStorage) {\n return params.file;\n }\n return this._params.fromStorage(params);\n }\n}\n"],"mappings":";;;;;;;;AAAA;AAwBO,MAAMA,0BAA0B,SAASC,eAAM,CAAC;EAI5CC,WAAW,CAACC,MAAwC,EAAE;IACzD,KAAK,EAAE;IAAC;IAER,IAAI,CAACC,OAAO,GAAGD,MAAM;EACzB;;EAEA;AACJ;AACA;AACA;EACI,MAAaE,SAAS,CAClBF,MAA0C,EACP;IACnC,IAAI,CAAC,IAAI,CAACC,OAAO,CAACC,SAAS,EAAE;MACzB,OAAOF,MAAM,CAACG,IAAI;IACtB;IACA,OAAO,IAAI,CAACF,OAAO,CAACC,SAAS,CAACF,MAAM,CAAC;EACzC;EACA;AACJ;AACA;AACA;AACA;EACI,MAAaI,WAAW,CACpBJ,MAA4C,EACT;IACnC,IAAI,CAAC,IAAI,CAACC,OAAO,CAACG,WAAW,EAAE;MAC3B,OAAOJ,MAAM,CAACG,IAAI;IACtB;IACA,OAAO,IAAI,CAACF,OAAO,CAACG,WAAW,CAACJ,MAAM,CAAC;EAC3C;AACJ;AAAC;AAAA,8BAnCYH,0BAA0B,UACY,4BAA4B"}
@@ -1,17 +1,12 @@
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
7
  exports.FilesStorageOperationsProviderPlugin = void 0;
9
-
10
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
-
12
9
  var _plugins = require("@webiny/plugins");
13
-
14
10
  class FilesStorageOperationsProviderPlugin extends _plugins.Plugin {}
15
-
16
11
  exports.FilesStorageOperationsProviderPlugin = FilesStorageOperationsProviderPlugin;
17
12
  (0, _defineProperty2.default)(FilesStorageOperationsProviderPlugin, "type", "fm.storageOperationsProvider.files");
@@ -1 +1 @@
1
- {"version":3,"names":["FilesStorageOperationsProviderPlugin","Plugin"],"sources":["FilesStorageOperationsProviderPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport { FileManagerContext, FileManagerFilesStorageOperations } from \"~/types\";\n\nexport interface FilesStorageOperationsProviderPluginParams<T = FileManagerContext> {\n context: T;\n}\n\nexport abstract class FilesStorageOperationsProviderPlugin extends Plugin {\n public static override readonly type: string = \"fm.storageOperationsProvider.files\";\n\n public abstract provide(\n params: FilesStorageOperationsProviderPluginParams\n ): Promise<FileManagerFilesStorageOperations>;\n}\n"],"mappings":";;;;;;;;;;;AAAA;;AAOO,MAAeA,oCAAf,SAA4DC,eAA5D,CAAmE;;;8BAApDD,oC,UAC6B,oC"}
1
+ {"version":3,"names":["FilesStorageOperationsProviderPlugin","Plugin"],"sources":["FilesStorageOperationsProviderPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport { FileManagerContext, FileManagerFilesStorageOperations } from \"~/types\";\n\nexport interface FilesStorageOperationsProviderPluginParams<T = FileManagerContext> {\n context: T;\n}\n\nexport abstract class FilesStorageOperationsProviderPlugin extends Plugin {\n public static override readonly type: string = \"fm.storageOperationsProvider.files\";\n\n public abstract provide(\n params: FilesStorageOperationsProviderPluginParams\n ): Promise<FileManagerFilesStorageOperations>;\n}\n"],"mappings":";;;;;;;;AAAA;AAOO,MAAeA,oCAAoC,SAASC,eAAM,CAAC;AAMzE;AAAA,8BANqBD,oCAAoC,UACP,oCAAoC"}
@@ -1,42 +1,31 @@
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
7
  exports.InstallationPlugin = void 0;
9
-
10
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
-
12
9
  var _plugins = require("@webiny/plugins");
13
-
14
10
  class InstallationPlugin extends _plugins.Plugin {
15
11
  constructor(config) {
16
12
  super();
17
13
  (0, _defineProperty2.default)(this, "_config", void 0);
18
14
  this._config = config || {};
19
15
  }
20
-
21
16
  async beforeInstall(params) {
22
17
  return this._execute("beforeInstall", params);
23
18
  }
24
-
25
19
  async afterInstall(params) {
26
20
  return this._execute("afterInstall", params);
27
21
  }
28
-
29
22
  async _execute(callback, params) {
30
23
  const cb = this._config[callback];
31
-
32
24
  if (!cb) {
33
25
  return;
34
26
  }
35
-
36
27
  return cb(params);
37
28
  }
38
-
39
29
  }
40
-
41
30
  exports.InstallationPlugin = InstallationPlugin;
42
31
  (0, _defineProperty2.default)(InstallationPlugin, "type", "fm.install");
@@ -1 +1 @@
1
- {"version":3,"names":["InstallationPlugin","Plugin","constructor","config","_config","beforeInstall","params","_execute","afterInstall","callback","cb"],"sources":["InstallationPlugin.ts"],"sourcesContent":["import { FileManagerContext } from \"~/types\";\nimport { Plugin } from \"@webiny/plugins\";\n\nexport interface InstallationPluginParams {\n context: FileManagerContext;\n}\nexport type CallbackFunction<TParams> = (params: TParams) => Promise<void>;\n\ninterface InstallationPluginConfig {\n beforeInstall?: CallbackFunction<InstallationPluginParams>;\n afterInstall?: CallbackFunction<InstallationPluginParams>;\n}\n\nexport abstract class InstallationPlugin extends Plugin {\n public static override readonly type: string = \"fm.install\";\n private readonly _config: Partial<InstallationPluginConfig>;\n\n constructor(config?: Partial<InstallationPluginConfig>) {\n super();\n this._config = config || {};\n }\n\n public async beforeInstall(params: InstallationPluginParams): Promise<void> {\n return this._execute(\"beforeInstall\", params);\n }\n\n public async afterInstall(params: InstallationPluginParams): Promise<void> {\n return this._execute(\"afterInstall\", params);\n }\n\n private async _execute(\n callback: keyof InstallationPluginConfig,\n params: InstallationPluginParams\n ): Promise<void> {\n const cb = this._config[callback];\n if (!cb) {\n return;\n }\n return cb(params);\n }\n}\n"],"mappings":";;;;;;;;;;;AACA;;AAYO,MAAeA,kBAAf,SAA0CC,eAA1C,CAAiD;EAIpDC,WAAW,CAACC,MAAD,EAA6C;IACpD;IADoD;IAEpD,KAAKC,OAAL,GAAeD,MAAM,IAAI,EAAzB;EACH;;EAEyB,MAAbE,aAAa,CAACC,MAAD,EAAkD;IACxE,OAAO,KAAKC,QAAL,CAAc,eAAd,EAA+BD,MAA/B,CAAP;EACH;;EAEwB,MAAZE,YAAY,CAACF,MAAD,EAAkD;IACvE,OAAO,KAAKC,QAAL,CAAc,cAAd,EAA8BD,MAA9B,CAAP;EACH;;EAEqB,MAARC,QAAQ,CAClBE,QADkB,EAElBH,MAFkB,EAGL;IACb,MAAMI,EAAE,GAAG,KAAKN,OAAL,CAAaK,QAAb,CAAX;;IACA,IAAI,CAACC,EAAL,EAAS;MACL;IACH;;IACD,OAAOA,EAAE,CAACJ,MAAD,CAAT;EACH;;AA1BmD;;;8BAAlCN,kB,UAC6B,Y"}
1
+ {"version":3,"names":["InstallationPlugin","Plugin","constructor","config","_config","beforeInstall","params","_execute","afterInstall","callback","cb"],"sources":["InstallationPlugin.ts"],"sourcesContent":["import { FileManagerContext } from \"~/types\";\nimport { Plugin } from \"@webiny/plugins\";\n\nexport interface InstallationPluginParams {\n context: FileManagerContext;\n}\nexport type CallbackFunction<TParams> = (params: TParams) => Promise<void>;\n\ninterface InstallationPluginConfig {\n beforeInstall?: CallbackFunction<InstallationPluginParams>;\n afterInstall?: CallbackFunction<InstallationPluginParams>;\n}\n\nexport abstract class InstallationPlugin extends Plugin {\n public static override readonly type: string = \"fm.install\";\n private readonly _config: Partial<InstallationPluginConfig>;\n\n constructor(config?: Partial<InstallationPluginConfig>) {\n super();\n this._config = config || {};\n }\n\n public async beforeInstall(params: InstallationPluginParams): Promise<void> {\n return this._execute(\"beforeInstall\", params);\n }\n\n public async afterInstall(params: InstallationPluginParams): Promise<void> {\n return this._execute(\"afterInstall\", params);\n }\n\n private async _execute(\n callback: keyof InstallationPluginConfig,\n params: InstallationPluginParams\n ): Promise<void> {\n const cb = this._config[callback];\n if (!cb) {\n return;\n }\n return cb(params);\n }\n}\n"],"mappings":";;;;;;;;AACA;AAYO,MAAeA,kBAAkB,SAASC,eAAM,CAAC;EAIpDC,WAAW,CAACC,MAA0C,EAAE;IACpD,KAAK,EAAE;IAAC;IACR,IAAI,CAACC,OAAO,GAAGD,MAAM,IAAI,CAAC,CAAC;EAC/B;EAEA,MAAaE,aAAa,CAACC,MAAgC,EAAiB;IACxE,OAAO,IAAI,CAACC,QAAQ,CAAC,eAAe,EAAED,MAAM,CAAC;EACjD;EAEA,MAAaE,YAAY,CAACF,MAAgC,EAAiB;IACvE,OAAO,IAAI,CAACC,QAAQ,CAAC,cAAc,EAAED,MAAM,CAAC;EAChD;EAEA,MAAcC,QAAQ,CAClBE,QAAwC,EACxCH,MAAgC,EACnB;IACb,MAAMI,EAAE,GAAG,IAAI,CAACN,OAAO,CAACK,QAAQ,CAAC;IACjC,IAAI,CAACC,EAAE,EAAE;MACL;IACJ;IACA,OAAOA,EAAE,CAACJ,MAAM,CAAC;EACrB;AACJ;AAAC;AAAA,8BA3BqBN,kBAAkB,UACW,YAAY"}
@@ -1,17 +1,12 @@
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
7
  exports.SettingsStorageOperationsProviderPlugin = void 0;
9
-
10
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
-
12
9
  var _plugins = require("@webiny/plugins");
13
-
14
10
  class SettingsStorageOperationsProviderPlugin extends _plugins.Plugin {}
15
-
16
11
  exports.SettingsStorageOperationsProviderPlugin = SettingsStorageOperationsProviderPlugin;
17
12
  (0, _defineProperty2.default)(SettingsStorageOperationsProviderPlugin, "type", "fm.storageOperationsProvider.settings");
@@ -1 +1 @@
1
- {"version":3,"names":["SettingsStorageOperationsProviderPlugin","Plugin"],"sources":["SettingsStorageOperationsProviderPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport { FileManagerContext, FileManagerSettingsStorageOperations } from \"~/types\";\n\nexport interface SettingsStorageOperationsProviderPluginParams<T = FileManagerContext> {\n context: T;\n}\n\nexport abstract class SettingsStorageOperationsProviderPlugin extends Plugin {\n public static override readonly type: string = \"fm.storageOperationsProvider.settings\";\n\n public abstract provide(\n params: SettingsStorageOperationsProviderPluginParams\n ): Promise<FileManagerSettingsStorageOperations>;\n}\n"],"mappings":";;;;;;;;;;;AAAA;;AAOO,MAAeA,uCAAf,SAA+DC,eAA/D,CAAsE;;;8BAAvDD,uC,UAC6B,uC"}
1
+ {"version":3,"names":["SettingsStorageOperationsProviderPlugin","Plugin"],"sources":["SettingsStorageOperationsProviderPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport { FileManagerContext, FileManagerSettingsStorageOperations } from \"~/types\";\n\nexport interface SettingsStorageOperationsProviderPluginParams<T = FileManagerContext> {\n context: T;\n}\n\nexport abstract class SettingsStorageOperationsProviderPlugin extends Plugin {\n public static override readonly type: string = \"fm.storageOperationsProvider.settings\";\n\n public abstract provide(\n params: SettingsStorageOperationsProviderPluginParams\n ): Promise<FileManagerSettingsStorageOperations>;\n}\n"],"mappings":";;;;;;;;AAAA;AAOO,MAAeA,uCAAuC,SAASC,eAAM,CAAC;AAM5E;AAAA,8BANqBD,uCAAuC,UACV,uCAAuC"}
@@ -1,17 +1,12 @@
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
7
  exports.SystemStorageOperationsProviderPlugin = void 0;
9
-
10
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
-
12
9
  var _plugins = require("@webiny/plugins");
13
-
14
10
  class SystemStorageOperationsProviderPlugin extends _plugins.Plugin {}
15
-
16
11
  exports.SystemStorageOperationsProviderPlugin = SystemStorageOperationsProviderPlugin;
17
12
  (0, _defineProperty2.default)(SystemStorageOperationsProviderPlugin, "type", "fm.storageOperationsProvider.system");
@@ -1 +1 @@
1
- {"version":3,"names":["SystemStorageOperationsProviderPlugin","Plugin"],"sources":["SystemStorageOperationsProviderPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport { FileManagerContext, FileManagerSystemStorageOperations } from \"~/types\";\n\nexport interface SystemStorageOperationsProviderPluginParams<T = FileManagerContext> {\n context: T;\n}\n\nexport abstract class SystemStorageOperationsProviderPlugin extends Plugin {\n public static override readonly type: string = \"fm.storageOperationsProvider.system\";\n\n public abstract provide(\n params: SystemStorageOperationsProviderPluginParams\n ): Promise<FileManagerSystemStorageOperations>;\n}\n"],"mappings":";;;;;;;;;;;AAAA;;AAOO,MAAeA,qCAAf,SAA6DC,eAA7D,CAAoE;;;8BAArDD,qC,UAC6B,qC"}
1
+ {"version":3,"names":["SystemStorageOperationsProviderPlugin","Plugin"],"sources":["SystemStorageOperationsProviderPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport { FileManagerContext, FileManagerSystemStorageOperations } from \"~/types\";\n\nexport interface SystemStorageOperationsProviderPluginParams<T = FileManagerContext> {\n context: T;\n}\n\nexport abstract class SystemStorageOperationsProviderPlugin extends Plugin {\n public static override readonly type: string = \"fm.storageOperationsProvider.system\";\n\n public abstract provide(\n params: SystemStorageOperationsProviderPluginParams\n ): Promise<FileManagerSystemStorageOperations>;\n}\n"],"mappings":";;;;;;;;AAAA;AAOO,MAAeA,qCAAqC,SAASC,eAAM,CAAC;AAM1E;AAAA,8BANqBD,qCAAqC,UACR,qCAAqC"}
@@ -4,16 +4,14 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _handlerGraphql = require("@webiny/handler-graphql");
9
-
10
8
  const emptyResolver = () => ({});
9
+
11
10
  /**
12
11
  * Use any because it really can be any.
13
12
  * TODO @ts-refactor maybe use generics at some point?
14
13
  */
15
14
 
16
-
17
15
  const resolve = async fn => {
18
16
  try {
19
17
  return new _handlerGraphql.Response(await fn());
@@ -21,13 +19,10 @@ const resolve = async fn => {
21
19
  return new _handlerGraphql.ErrorResponse(e);
22
20
  }
23
21
  };
24
-
25
22
  const plugin = {
26
23
  type: "graphql-schema",
27
24
  schema: {
28
- typeDefs:
29
- /* GraphQL */
30
- `
25
+ typeDefs: /* GraphQL */`
31
26
  type FmCreatedBy {
32
27
  id: ID
33
28
  displayName: String
@@ -196,7 +191,6 @@ const plugin = {
196
191
  const settings = await context.fileManager.settings.getSettings();
197
192
  return ((settings === null || settings === void 0 ? void 0 : settings.srcPrefix) || "") + file.key;
198
193
  }
199
-
200
194
  },
201
195
  Query: {
202
196
  fileManager: emptyResolver
@@ -208,7 +202,6 @@ const plugin = {
208
202
  getFile(_, args, context) {
209
203
  return resolve(() => context.fileManager.files.getFile(args.id));
210
204
  },
211
-
212
205
  async listFiles(_, args, context) {
213
206
  try {
214
207
  const [data, meta] = await context.fileManager.files.listFiles(args);
@@ -217,7 +210,6 @@ const plugin = {
217
210
  return new _handlerGraphql.ErrorResponse(e);
218
211
  }
219
212
  },
220
-
221
213
  async listTags(_, args, context) {
222
214
  try {
223
215
  return await context.fileManager.files.listTags(args || {});
@@ -225,39 +217,31 @@ const plugin = {
225
217
  return new _handlerGraphql.ErrorResponse(error);
226
218
  }
227
219
  },
228
-
229
220
  async version(_, __, context) {
230
221
  const {
231
222
  i18n,
232
223
  tenancy,
233
224
  fileManager
234
225
  } = context;
235
-
236
226
  if (!tenancy.getCurrentTenant() || !i18n.getContentLocale()) {
237
227
  return null;
238
228
  }
239
-
240
229
  return await fileManager.system.getVersion();
241
230
  },
242
-
243
231
  async getSettings(_, __, context) {
244
232
  return resolve(() => context.fileManager.settings.getSettings());
245
233
  }
246
-
247
234
  },
248
235
  FmMutation: {
249
236
  async createFile(_, args, context) {
250
237
  return resolve(() => context.fileManager.files.createFile(args.data));
251
238
  },
252
-
253
239
  async updateFile(_, args, context) {
254
240
  return resolve(() => context.fileManager.files.updateFile(args.id, args.data));
255
241
  },
256
-
257
242
  async createFiles(_, args, context) {
258
243
  return resolve(() => context.fileManager.files.createFilesInBatch(args.data));
259
244
  },
260
-
261
245
  async deleteFile(_, args, context) {
262
246
  return resolve(async () => {
263
247
  const file = await context.fileManager.files.getFile(args.id);
@@ -267,21 +251,17 @@ const plugin = {
267
251
  });
268
252
  });
269
253
  },
270
-
271
254
  async install(_, args, context) {
272
255
  return resolve(() => context.fileManager.system.install({
273
256
  srcPrefix: args.srcPrefix
274
257
  }));
275
258
  },
276
-
277
259
  async upgrade(_, args, context) {
278
260
  return resolve(() => context.fileManager.system.upgrade(args.version));
279
261
  },
280
-
281
262
  async updateSettings(_, args, context) {
282
263
  return resolve(() => context.fileManager.settings.updateSettings(args.data));
283
264
  }
284
-
285
265
  }
286
266
  }
287
267
  }
@@ -1 +1 @@
1
- {"version":3,"names":["emptyResolver","resolve","fn","Response","e","ErrorResponse","plugin","type","schema","typeDefs","resolvers","File","src","file","_","context","settings","fileManager","getSettings","srcPrefix","key","Query","Mutation","FmQuery","getFile","args","files","id","listFiles","data","meta","ListResponse","listTags","error","version","__","i18n","tenancy","getCurrentTenant","getContentLocale","system","getVersion","FmMutation","createFile","updateFile","createFiles","createFilesInBatch","deleteFile","storage","delete","install","upgrade","updateSettings"],"sources":["graphql.ts"],"sourcesContent":["import { Response, ErrorResponse, ListResponse } from \"@webiny/handler-graphql\";\nimport { FileManagerContext, FilesListOpts } from \"~/types\";\nimport { GraphQLSchemaPlugin } from \"@webiny/handler-graphql/types\";\n\nconst emptyResolver = () => ({});\n\n/**\n * Use any because it really can be any.\n * TODO @ts-refactor maybe use generics at some point?\n */\ninterface ResolveCallable {\n (): Promise<any>;\n}\n\nconst resolve = async (fn: ResolveCallable) => {\n try {\n return new Response(await fn());\n } catch (e) {\n return new ErrorResponse(e);\n }\n};\n\nconst plugin: GraphQLSchemaPlugin<FileManagerContext> = {\n type: \"graphql-schema\",\n schema: {\n typeDefs: /* GraphQL */ `\n type FmCreatedBy {\n id: ID\n displayName: String\n }\n\n input FileInput {\n key: String\n name: String\n size: Int\n type: String\n tags: [String]\n meta: JSON\n }\n\n type UploadFileResponseDataFile {\n name: String\n type: String\n size: Int\n key: String\n }\n\n type UploadFileResponseData {\n # Contains data that is necessary for initiating a file upload.\n data: JSON\n file: UploadFileResponseDataFile\n }\n\n type FileListMeta {\n cursor: String\n totalCount: Int\n hasMoreItems: Boolean\n }\n\n type FileError {\n code: String\n message: String\n data: JSON\n stack: String\n }\n\n type FileListResponse {\n data: [File]\n meta: FileListMeta\n error: FileError\n }\n\n type FileResponse {\n data: File\n error: FileError\n }\n\n type CreateFilesResponse {\n data: [File]!\n error: FileError\n }\n\n type File {\n id: ID\n key: String\n name: String\n size: Int\n type: String\n src: String\n tags: [String]\n meta: JSON\n createdOn: DateTime\n createdBy: FmCreatedBy\n }\n\n type FileManagerBooleanResponse {\n data: Boolean\n error: FileError\n }\n\n type FileManagerSettings {\n uploadMinFileSize: Number\n uploadMaxFileSize: Number\n srcPrefix: String\n }\n\n input FileManagerSettingsInput {\n uploadMinFileSize: Number\n uploadMaxFileSize: Number\n srcPrefix: String\n }\n\n type FileManagerSettingsResponse {\n data: FileManagerSettings\n error: FileError\n }\n\n input FileWhereInput {\n search: String\n type: String\n type_in: [String!]\n tag: String\n tag_in: [String!]\n tag_and_in: [String!]\n tag_startsWith: String\n tag_not_startsWith: String\n id_in: [ID!]\n id: ID\n createdBy: ID\n }\n\n input TagWhereInput {\n tag_startsWith: String\n tag_not_startsWith: String\n }\n\n type FmQuery {\n getFile(id: ID, where: JSON, sort: String): FileResponse\n\n listFiles(\n limit: Int\n after: String\n types: [String]\n tags: [String]\n ids: [ID]\n search: String\n where: FileWhereInput\n ): FileListResponse\n\n listTags(where: TagWhereInput): [String]\n\n # Get installed version\n version: String\n\n getSettings: FileManagerSettingsResponse\n }\n\n type FilesDeleteResponse {\n data: Boolean\n error: FileError\n }\n\n type FmMutation {\n createFile(data: FileInput!): FileResponse\n createFiles(data: [FileInput]!): CreateFilesResponse\n updateFile(id: ID!, data: FileInput!): FileResponse\n deleteFile(id: ID!): FilesDeleteResponse\n\n # Install File manager\n install(srcPrefix: String): FileManagerBooleanResponse\n\n upgrade(version: String!): FileManagerBooleanResponse\n\n updateSettings(data: FileManagerSettingsInput): FileManagerSettingsResponse\n }\n\n input FilesInstallInput {\n srcPrefix: String!\n }\n\n extend type Query {\n fileManager: FmQuery\n }\n\n extend type Mutation {\n fileManager: FmMutation\n }\n `,\n resolvers: {\n File: {\n async src(file, _, context: FileManagerContext) {\n const settings = await context.fileManager.settings.getSettings();\n return (settings?.srcPrefix || \"\") + file.key;\n }\n },\n Query: {\n fileManager: emptyResolver\n },\n Mutation: {\n fileManager: emptyResolver\n },\n FmQuery: {\n getFile(_, args: any, context) {\n return resolve(() => context.fileManager.files.getFile(args.id));\n },\n async listFiles(_, args: FilesListOpts, context) {\n try {\n const [data, meta] = await context.fileManager.files.listFiles(args);\n return new ListResponse(data, meta);\n } catch (e) {\n return new ErrorResponse(e);\n }\n },\n async listTags(_, args: any, context) {\n try {\n return await context.fileManager.files.listTags(args || {});\n } catch (error) {\n return new ErrorResponse(error);\n }\n },\n async version(_, __, context) {\n const { i18n, tenancy, fileManager } = context;\n if (!tenancy.getCurrentTenant() || !i18n.getContentLocale()) {\n return null;\n }\n\n return await fileManager.system.getVersion();\n },\n async getSettings(_, __, context) {\n return resolve(() => context.fileManager.settings.getSettings());\n }\n },\n FmMutation: {\n async createFile(_, args: any, context) {\n return resolve(() => context.fileManager.files.createFile(args.data));\n },\n async updateFile(_, args: any, context) {\n return resolve(() => context.fileManager.files.updateFile(args.id, args.data));\n },\n async createFiles(_, args: any, context) {\n return resolve(() => context.fileManager.files.createFilesInBatch(args.data));\n },\n async deleteFile(_, args: any, context) {\n return resolve(async () => {\n const file = await context.fileManager.files.getFile(args.id);\n return await context.fileManager.storage.delete({\n id: file.id,\n key: file.key\n });\n });\n },\n async install(_, args: any, context) {\n return resolve(() =>\n context.fileManager.system.install({ srcPrefix: args.srcPrefix })\n );\n },\n async upgrade(_, args: any, context) {\n return resolve(() => context.fileManager.system.upgrade(args.version));\n },\n async updateSettings(_, args: any, context) {\n return resolve(() => context.fileManager.settings.updateSettings(args.data));\n }\n }\n }\n }\n};\n\nexport default plugin;\n"],"mappings":";;;;;;;AAAA;;AAIA,MAAMA,aAAa,GAAG,OAAO,EAAP,CAAtB;AAEA;AACA;AACA;AACA;;;AAKA,MAAMC,OAAO,GAAG,MAAOC,EAAP,IAA+B;EAC3C,IAAI;IACA,OAAO,IAAIC,wBAAJ,CAAa,MAAMD,EAAE,EAArB,CAAP;EACH,CAFD,CAEE,OAAOE,CAAP,EAAU;IACR,OAAO,IAAIC,6BAAJ,CAAkBD,CAAlB,CAAP;EACH;AACJ,CAND;;AAQA,MAAME,MAA+C,GAAG;EACpDC,IAAI,EAAE,gBAD8C;EAEpDC,MAAM,EAAE;IACJC,QAAQ;IAAE;IAAe;AACjC;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;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;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CA1BO;;QA2BR,MAAMkB,cAAN,CAAqBtC,CAArB,EAAwBW,IAAxB,EAAmCV,OAAnC,EAA4C;UACxC,OAAOd,OAAO,CAAC,MAAMc,OAAO,CAACE,WAAR,CAAoBD,QAApB,CAA6BoC,cAA7B,CAA4C3B,IAAI,CAACI,IAAjD,CAAP,CAAd;QACH;;MA7BO;IA5CL;EApKP;AAF4C,CAAxD;eAqPevB,M"}
1
+ {"version":3,"names":["emptyResolver","resolve","fn","Response","e","ErrorResponse","plugin","type","schema","typeDefs","resolvers","File","src","file","_","context","settings","fileManager","getSettings","srcPrefix","key","Query","Mutation","FmQuery","getFile","args","files","id","listFiles","data","meta","ListResponse","listTags","error","version","__","i18n","tenancy","getCurrentTenant","getContentLocale","system","getVersion","FmMutation","createFile","updateFile","createFiles","createFilesInBatch","deleteFile","storage","delete","install","upgrade","updateSettings"],"sources":["graphql.ts"],"sourcesContent":["import { Response, ErrorResponse, ListResponse } from \"@webiny/handler-graphql\";\nimport { FileManagerContext, FilesListOpts } from \"~/types\";\nimport { GraphQLSchemaPlugin } from \"@webiny/handler-graphql/types\";\n\nconst emptyResolver = () => ({});\n\n/**\n * Use any because it really can be any.\n * TODO @ts-refactor maybe use generics at some point?\n */\ninterface ResolveCallable {\n (): Promise<any>;\n}\n\nconst resolve = async (fn: ResolveCallable) => {\n try {\n return new Response(await fn());\n } catch (e) {\n return new ErrorResponse(e);\n }\n};\n\nconst plugin: GraphQLSchemaPlugin<FileManagerContext> = {\n type: \"graphql-schema\",\n schema: {\n typeDefs: /* GraphQL */ `\n type FmCreatedBy {\n id: ID\n displayName: String\n }\n\n input FileInput {\n key: String\n name: String\n size: Int\n type: String\n tags: [String]\n meta: JSON\n }\n\n type UploadFileResponseDataFile {\n name: String\n type: String\n size: Int\n key: String\n }\n\n type UploadFileResponseData {\n # Contains data that is necessary for initiating a file upload.\n data: JSON\n file: UploadFileResponseDataFile\n }\n\n type FileListMeta {\n cursor: String\n totalCount: Int\n hasMoreItems: Boolean\n }\n\n type FileError {\n code: String\n message: String\n data: JSON\n stack: String\n }\n\n type FileListResponse {\n data: [File]\n meta: FileListMeta\n error: FileError\n }\n\n type FileResponse {\n data: File\n error: FileError\n }\n\n type CreateFilesResponse {\n data: [File]!\n error: FileError\n }\n\n type File {\n id: ID\n key: String\n name: String\n size: Int\n type: String\n src: String\n tags: [String]\n meta: JSON\n createdOn: DateTime\n createdBy: FmCreatedBy\n }\n\n type FileManagerBooleanResponse {\n data: Boolean\n error: FileError\n }\n\n type FileManagerSettings {\n uploadMinFileSize: Number\n uploadMaxFileSize: Number\n srcPrefix: String\n }\n\n input FileManagerSettingsInput {\n uploadMinFileSize: Number\n uploadMaxFileSize: Number\n srcPrefix: String\n }\n\n type FileManagerSettingsResponse {\n data: FileManagerSettings\n error: FileError\n }\n\n input FileWhereInput {\n search: String\n type: String\n type_in: [String!]\n tag: String\n tag_in: [String!]\n tag_and_in: [String!]\n tag_startsWith: String\n tag_not_startsWith: String\n id_in: [ID!]\n id: ID\n createdBy: ID\n }\n\n input TagWhereInput {\n tag_startsWith: String\n tag_not_startsWith: String\n }\n\n type FmQuery {\n getFile(id: ID, where: JSON, sort: String): FileResponse\n\n listFiles(\n limit: Int\n after: String\n types: [String]\n tags: [String]\n ids: [ID]\n search: String\n where: FileWhereInput\n ): FileListResponse\n\n listTags(where: TagWhereInput): [String]\n\n # Get installed version\n version: String\n\n getSettings: FileManagerSettingsResponse\n }\n\n type FilesDeleteResponse {\n data: Boolean\n error: FileError\n }\n\n type FmMutation {\n createFile(data: FileInput!): FileResponse\n createFiles(data: [FileInput]!): CreateFilesResponse\n updateFile(id: ID!, data: FileInput!): FileResponse\n deleteFile(id: ID!): FilesDeleteResponse\n\n # Install File manager\n install(srcPrefix: String): FileManagerBooleanResponse\n\n upgrade(version: String!): FileManagerBooleanResponse\n\n updateSettings(data: FileManagerSettingsInput): FileManagerSettingsResponse\n }\n\n input FilesInstallInput {\n srcPrefix: String!\n }\n\n extend type Query {\n fileManager: FmQuery\n }\n\n extend type Mutation {\n fileManager: FmMutation\n }\n `,\n resolvers: {\n File: {\n async src(file, _, context: FileManagerContext) {\n const settings = await context.fileManager.settings.getSettings();\n return (settings?.srcPrefix || \"\") + file.key;\n }\n },\n Query: {\n fileManager: emptyResolver\n },\n Mutation: {\n fileManager: emptyResolver\n },\n FmQuery: {\n getFile(_, args: any, context) {\n return resolve(() => context.fileManager.files.getFile(args.id));\n },\n async listFiles(_, args: FilesListOpts, context) {\n try {\n const [data, meta] = await context.fileManager.files.listFiles(args);\n return new ListResponse(data, meta);\n } catch (e) {\n return new ErrorResponse(e);\n }\n },\n async listTags(_, args: any, context) {\n try {\n return await context.fileManager.files.listTags(args || {});\n } catch (error) {\n return new ErrorResponse(error);\n }\n },\n async version(_, __, context) {\n const { i18n, tenancy, fileManager } = context;\n if (!tenancy.getCurrentTenant() || !i18n.getContentLocale()) {\n return null;\n }\n\n return await fileManager.system.getVersion();\n },\n async getSettings(_, __, context) {\n return resolve(() => context.fileManager.settings.getSettings());\n }\n },\n FmMutation: {\n async createFile(_, args: any, context) {\n return resolve(() => context.fileManager.files.createFile(args.data));\n },\n async updateFile(_, args: any, context) {\n return resolve(() => context.fileManager.files.updateFile(args.id, args.data));\n },\n async createFiles(_, args: any, context) {\n return resolve(() => context.fileManager.files.createFilesInBatch(args.data));\n },\n async deleteFile(_, args: any, context) {\n return resolve(async () => {\n const file = await context.fileManager.files.getFile(args.id);\n return await context.fileManager.storage.delete({\n id: file.id,\n key: file.key\n });\n });\n },\n async install(_, args: any, context) {\n return resolve(() =>\n context.fileManager.system.install({ srcPrefix: args.srcPrefix })\n );\n },\n async upgrade(_, args: any, context) {\n return resolve(() => context.fileManager.system.upgrade(args.version));\n },\n async updateSettings(_, args: any, context) {\n return resolve(() => context.fileManager.settings.updateSettings(args.data));\n }\n }\n }\n }\n};\n\nexport default plugin;\n"],"mappings":";;;;;;AAAA;AAIA,MAAMA,aAAa,GAAG,OAAO,CAAC,CAAC,CAAC;;AAEhC;AACA;AACA;AACA;;AAKA,MAAMC,OAAO,GAAG,MAAOC,EAAmB,IAAK;EAC3C,IAAI;IACA,OAAO,IAAIC,wBAAQ,CAAC,MAAMD,EAAE,EAAE,CAAC;EACnC,CAAC,CAAC,OAAOE,CAAC,EAAE;IACR,OAAO,IAAIC,6BAAa,CAACD,CAAC,CAAC;EAC/B;AACJ,CAAC;AAED,MAAME,MAA+C,GAAG;EACpDC,IAAI,EAAE,gBAAgB;EACtBC,MAAM,EAAE;IACJC,QAAQ,EAAE,aAAe;AACjC;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;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;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;AACA;AACA,SAAS;IACDC,SAAS,EAAE;MACPC,IAAI,EAAE;QACF,MAAMC,GAAG,CAACC,IAAI,EAAEC,CAAC,EAAEC,OAA2B,EAAE;UAC5C,MAAM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