@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
@@ -1,64 +1,52 @@
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.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
+ /**
41
+ * Keep any here because it can be a number of params. Method is internal so no need to complicate the code.
42
+ */
53
43
  async _execute(callback, params) {
54
- if (typeof this._params[callback] !== "function") {
44
+ const cb = this._params[callback];
45
+ if (typeof cb !== "function") {
55
46
  return;
56
47
  }
57
-
58
- await this._params[callback](params);
48
+ await cb(params);
59
49
  }
60
-
61
50
  }
62
-
63
51
  exports.FilePlugin = FilePlugin;
64
52
  (0, _defineProperty2.default)(FilePlugin, "type", "fm.file");
@@ -0,0 +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,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,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face ToParams {
3
+ export interface FileStorageTransformPluginToParams {
4
4
  /**
5
5
  * File that is being sent to the storage operations method.
6
6
  */
7
7
  file: File & Record<string, any>;
8
8
  }
9
- export interface FromParams {
9
+ export interface FileStorageTransformPluginFromParams {
10
10
  /**
11
11
  * File that was fetched from the storage operations method.
12
12
  */
13
13
  file: File & Record<string, any>;
14
14
  }
15
- export interface Params {
16
- toStorage?: (params: ToParams) => Promise<File & Record<string, any>>;
17
- fromStorage?: (params: FromParams) => Promise<File & Record<string, any>>;
15
+ export interface FileStorageTransformPluginParams {
16
+ toStorage?: (params: FileStorageTransformPluginToParams) => Promise<File & Record<string, any>>;
17
+ fromStorage?: (params: FileStorageTransformPluginFromParams) => Promise<File & Record<string, any>>;
18
18
  }
19
19
  export declare class FileStorageTransformPlugin extends Plugin {
20
- static readonly type = "fm.files.storage.transform";
20
+ static readonly type: string;
21
21
  private readonly _params;
22
- constructor(params: Params);
22
+ constructor(params: FileStorageTransformPluginParams);
23
23
  /**
24
24
  * Transform the file value into something that can be stored.
25
25
  * Be aware that you must return the whole file object.
26
26
  */
27
- toStorage(params: ToParams): Promise<File & Record<string, any>>;
27
+ toStorage(params: FileStorageTransformPluginToParams): Promise<File & Record<string, any>>;
28
28
  /**
29
29
  * Transform the file value from the storage type to one required by our system.
30
30
  * Be aware that you must return the whole file object.
31
31
  * This method MUST reverse what ever toStorage method changed on the file object.
32
32
  */
33
- fromStorage(params: FromParams): Promise<File & Record<string, any>>;
33
+ fromStorage(params: FileStorageTransformPluginFromParams): Promise<File & Record<string, any>>;
34
34
  }
@@ -1,33 +1,27 @@
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.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");
@@ -0,0 +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,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,9 +1,9 @@
1
1
  import { Plugin } from "@webiny/plugins";
2
2
  import { FileManagerContext, FileManagerFilesStorageOperations } from "../../types";
3
- export interface Params {
4
- context: FileManagerContext;
3
+ export interface FilesStorageOperationsProviderPluginParams<T = FileManagerContext> {
4
+ context: T;
5
5
  }
6
6
  export declare abstract class FilesStorageOperationsProviderPlugin extends Plugin {
7
- static readonly type = "fm.storageOperationsProvider.files";
8
- abstract provide(params: Params): Promise<FileManagerFilesStorageOperations>;
7
+ static readonly type: string;
8
+ abstract provide(params: FilesStorageOperationsProviderPluginParams): Promise<FileManagerFilesStorageOperations>;
9
9
  }
@@ -1,17 +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.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");
@@ -0,0 +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,oCAAoC,SAASC,eAAM,CAAC;AAMzE;AAAA,8BANqBD,oCAAoC,UACP,oCAAoC"}
@@ -1,19 +1,19 @@
1
1
  import { FileManagerContext } from "../../types";
2
2
  import { Plugin } from "@webiny/plugins";
3
- export declare type CallbackFunction<TParams> = (params: TParams) => Promise<void>;
4
- export interface Params {
3
+ export interface InstallationPluginParams {
5
4
  context: FileManagerContext;
6
5
  }
7
- interface Config {
8
- beforeInstall?: CallbackFunction<Params>;
9
- afterInstall?: CallbackFunction<Params>;
6
+ export declare type CallbackFunction<TParams> = (params: TParams) => Promise<void>;
7
+ interface InstallationPluginConfig {
8
+ beforeInstall?: CallbackFunction<InstallationPluginParams>;
9
+ afterInstall?: CallbackFunction<InstallationPluginParams>;
10
10
  }
11
11
  export declare abstract class InstallationPlugin extends Plugin {
12
- static readonly type = "fm.install";
12
+ static readonly type: string;
13
13
  private readonly _config;
14
- constructor(config?: Partial<Config>);
15
- beforeInstall(params: Params): Promise<void>;
16
- afterInstall(params: Params): Promise<void>;
14
+ constructor(config?: Partial<InstallationPluginConfig>);
15
+ beforeInstall(params: InstallationPluginParams): Promise<void>;
16
+ afterInstall(params: InstallationPluginParams): Promise<void>;
17
17
  private _execute;
18
18
  }
19
19
  export {};
@@ -1,40 +1,31 @@
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.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
- if (typeof this._config[callback] !== "function") {
23
+ const cb = this._config[callback];
24
+ if (!cb) {
31
25
  return;
32
26
  }
33
-
34
- return this._config[callback](params);
27
+ return cb(params);
35
28
  }
36
-
37
29
  }
38
-
39
30
  exports.InstallationPlugin = InstallationPlugin;
40
31
  (0, _defineProperty2.default)(InstallationPlugin, "type", "fm.install");
@@ -0,0 +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,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,9 +1,9 @@
1
1
  import { Plugin } from "@webiny/plugins";
2
2
  import { FileManagerContext, FileManagerSettingsStorageOperations } from "../../types";
3
- export interface Params {
4
- context: FileManagerContext;
3
+ export interface SettingsStorageOperationsProviderPluginParams<T = FileManagerContext> {
4
+ context: T;
5
5
  }
6
6
  export declare abstract class SettingsStorageOperationsProviderPlugin extends Plugin {
7
- static readonly type = "fm.storageOperationsProvider.settings";
8
- abstract provide(params: Params): Promise<FileManagerSettingsStorageOperations>;
7
+ static readonly type: string;
8
+ abstract provide(params: SettingsStorageOperationsProviderPluginParams): Promise<FileManagerSettingsStorageOperations>;
9
9
  }
@@ -1,17 +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.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");
@@ -0,0 +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,uCAAuC,SAASC,eAAM,CAAC;AAM5E;AAAA,8BANqBD,uCAAuC,UACV,uCAAuC"}
@@ -1,9 +1,9 @@
1
1
  import { Plugin } from "@webiny/plugins";
2
2
  import { FileManagerContext, FileManagerSystemStorageOperations } from "../../types";
3
- export interface Params {
4
- context: FileManagerContext;
3
+ export interface SystemStorageOperationsProviderPluginParams<T = FileManagerContext> {
4
+ context: T;
5
5
  }
6
6
  export declare abstract class SystemStorageOperationsProviderPlugin extends Plugin {
7
- static readonly type = "fm.storageOperationsProvider.system";
8
- abstract provide(params: Params): Promise<FileManagerSystemStorageOperations>;
7
+ static readonly type: string;
8
+ abstract provide(params: SystemStorageOperationsProviderPluginParams): Promise<FileManagerSystemStorageOperations>;
9
9
  }
@@ -1,17 +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.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");
@@ -0,0 +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,qCAAqC,SAASC,eAAM,CAAC;AAM1E;AAAA,8BANqBD,qCAAqC,UACR,qCAAqC"}
@@ -4,11 +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 = () => ({});
11
9
 
10
+ /**
11
+ * Use any because it really can be any.
12
+ * TODO @ts-refactor maybe use generics at some point?
13
+ */
14
+
12
15
  const resolve = async fn => {
13
16
  try {
14
17
  return new _handlerGraphql.Response(await fn());
@@ -16,13 +19,10 @@ const resolve = async fn => {
16
19
  return new _handlerGraphql.ErrorResponse(e);
17
20
  }
18
21
  };
19
-
20
22
  const plugin = {
21
23
  type: "graphql-schema",
22
24
  schema: {
23
- typeDefs:
24
- /* GraphQL */
25
- `
25
+ typeDefs: /* GraphQL */`
26
26
  type FmCreatedBy {
27
27
  id: ID
28
28
  displayName: String
@@ -60,6 +60,7 @@ const plugin = {
60
60
  code: String
61
61
  message: String
62
62
  data: JSON
63
+ stack: String
63
64
  }
64
65
 
65
66
  type FileListResponse {
@@ -99,11 +100,13 @@ const plugin = {
99
100
  type FileManagerSettings {
100
101
  uploadMinFileSize: Number
101
102
  uploadMaxFileSize: Number
103
+ srcPrefix: String
102
104
  }
103
105
 
104
106
  input FileManagerSettingsInput {
105
107
  uploadMinFileSize: Number
106
108
  uploadMaxFileSize: Number
109
+ srcPrefix: String
107
110
  }
108
111
 
109
112
  type FileManagerSettingsResponse {
@@ -118,8 +121,16 @@ const plugin = {
118
121
  tag: String
119
122
  tag_in: [String!]
120
123
  tag_and_in: [String!]
124
+ tag_startsWith: String
125
+ tag_not_startsWith: String
121
126
  id_in: [ID!]
122
127
  id: ID
128
+ createdBy: ID
129
+ }
130
+
131
+ input TagWhereInput {
132
+ tag_startsWith: String
133
+ tag_not_startsWith: String
123
134
  }
124
135
 
125
136
  type FmQuery {
@@ -135,7 +146,7 @@ const plugin = {
135
146
  where: FileWhereInput
136
147
  ): FileListResponse
137
148
 
138
- listTags: [String]
149
+ listTags(where: TagWhereInput): [String]
139
150
 
140
151
  # Get installed version
141
152
  version: String
@@ -178,9 +189,8 @@ const plugin = {
178
189
  File: {
179
190
  async src(file, _, context) {
180
191
  const settings = await context.fileManager.settings.getSettings();
181
- return settings.srcPrefix + file.key;
192
+ return ((settings === null || settings === void 0 ? void 0 : settings.srcPrefix) || "") + file.key;
182
193
  }
183
-
184
194
  },
185
195
  Query: {
186
196
  fileManager: emptyResolver
@@ -192,7 +202,6 @@ const plugin = {
192
202
  getFile(_, args, context) {
193
203
  return resolve(() => context.fileManager.files.getFile(args.id));
194
204
  },
195
-
196
205
  async listFiles(_, args, context) {
197
206
  try {
198
207
  const [data, meta] = await context.fileManager.files.listFiles(args);
@@ -201,7 +210,6 @@ const plugin = {
201
210
  return new _handlerGraphql.ErrorResponse(e);
202
211
  }
203
212
  },
204
-
205
213
  async listTags(_, args, context) {
206
214
  try {
207
215
  return await context.fileManager.files.listTags(args || {});
@@ -209,39 +217,31 @@ const plugin = {
209
217
  return new _handlerGraphql.ErrorResponse(error);
210
218
  }
211
219
  },
212
-
213
220
  async version(_, __, context) {
214
221
  const {
215
- i18nContent,
222
+ i18n,
216
223
  tenancy,
217
224
  fileManager
218
225
  } = context;
219
-
220
- if (!tenancy.getCurrentTenant() || !i18nContent.getLocale()) {
226
+ if (!tenancy.getCurrentTenant() || !i18n.getContentLocale()) {
221
227
  return null;
222
228
  }
223
-
224
229
  return await fileManager.system.getVersion();
225
230
  },
226
-
227
231
  async getSettings(_, __, context) {
228
232
  return resolve(() => context.fileManager.settings.getSettings());
229
233
  }
230
-
231
234
  },
232
235
  FmMutation: {
233
236
  async createFile(_, args, context) {
234
237
  return resolve(() => context.fileManager.files.createFile(args.data));
235
238
  },
236
-
237
239
  async updateFile(_, args, context) {
238
240
  return resolve(() => context.fileManager.files.updateFile(args.id, args.data));
239
241
  },
240
-
241
242
  async createFiles(_, args, context) {
242
243
  return resolve(() => context.fileManager.files.createFilesInBatch(args.data));
243
244
  },
244
-
245
245
  async deleteFile(_, args, context) {
246
246
  return resolve(async () => {
247
247
  const file = await context.fileManager.files.getFile(args.id);
@@ -251,21 +251,17 @@ const plugin = {
251
251
  });
252
252
  });
253
253
  },
254
-
255
254
  async install(_, args, context) {
256
255
  return resolve(() => context.fileManager.system.install({
257
256
  srcPrefix: args.srcPrefix
258
257
  }));
259
258
  },
260
-
261
259
  async upgrade(_, args, context) {
262
260
  return resolve(() => context.fileManager.system.upgrade(args.version));
263
261
  },
264
-
265
262
  async updateSettings(_, args, context) {
266
263
  return resolve(() => context.fileManager.settings.updateSettings(args.data));
267
264
  }
268
-
269
265
  }
270
266
  }
271
267
  }
@@ -0,0 +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,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,MAAMC,QAAQ,GAAG,MAAMD,OAAO,CAACE,WAAW,CAACD,QAAQ,CAACE,WAAW,EAAE;UACjE,OAAO,CAAC,CAAAF,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEG,SAAS,KAAI,EAAE,IAAIN,IAAI,CAACO,GAAG;QACjD;MACJ,CAAC;MACDC,KAAK,EAAE;QACHJ,WAAW,EAAEjB;MACjB,CAAC;MACDsB,QAAQ,EAAE;QACNL,WAAW,EAAEjB;MACjB,CAAC;MACDuB,OAAO,EAAE;QACLC,OAAO,CAACV,CAAC,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AAI,CAACN;UAAU,CAAC,CAAC,CACpE;QACL,CAAC;QACD,MAAMgC,OAAO,CAACrC,CAAC,EAAEW,IAAS,EAAEV,OAAO,EAAE;UACjC,OAAOd,OAAO,CAAC,MAAMc,OAAO,CAACE,WAAW,CAACuB,MAAM,CAACW,OAAO,CAAC1B,IAAI,CAACS,OAAO,CAAC,CAAC;QAC1E,CAAC;QACD,MAAMkB,cAAc,CAACtC,CAAC,EAAEW,IAAS,EAAEV,OAAO,EAAE;UACxC,OAAOd,OAAO,CAAC,MAAMc,OAAO,CAACE,WAAW,CAACD,QAAQ,CAACoC,cAAc,CAAC3B,IAAI,CAACI,IAAI,CAAC,CAAC;QAChF;MACJ;IACJ;EACJ;AACJ,CAAC;AAAC,eAEavB,MAAM;AAAA"}
@@ -1,2 +1,2 @@
1
- declare const _default: () => (import("@webiny/handler-graphql/types").GraphQLSchemaPlugin<import("../types").FileManagerContext> | import("./definitions/FilePlugin").FilePlugin[] | import("@webiny/handler/plugins/ContextPlugin").ContextPlugin<import("../types").FileManagerContext>)[];
1
+ declare const _default: () => (import("@webiny/handler-graphql/types").GraphQLSchemaPlugin<import("../types").FileManagerContext> | import("./definitions/FilePlugin").FilePlugin[] | import("@webiny/api").ContextPlugin<import("../types").FileManagerContext>)[];
2
2
  export default _default;
package/plugins/index.js CHANGED
@@ -1,24 +1,15 @@
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 _graphql = _interopRequireDefault(require("./graphql"));
11
-
12
9
  var _files = _interopRequireDefault(require("./crud/files.crud"));
13
-
14
10
  var _validation = _interopRequireDefault(require("./crud/files/validation"));
15
-
16
11
  var _settings = _interopRequireDefault(require("./crud/settings.crud"));
17
-
18
12
  var _system = _interopRequireDefault(require("./crud/system.crud"));
19
-
20
13
  var _storage = _interopRequireDefault(require("./storage"));
21
-
22
14
  var _default = () => [_system.default, _settings.default, _files.default, _storage.default, _graphql.default, (0, _validation.default)()];
23
-
24
15
  exports.default = _default;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["systemCRUD","settingsCRUD","filesCRUD","storage","graphql","fileValidationPlugin"],"sources":["index.ts"],"sourcesContent":["import graphql from \"./graphql\";\nimport filesCRUD from \"./crud/files.crud\";\nimport fileValidationPlugin from \"./crud/files/validation\";\nimport settingsCRUD from \"./crud/settings.crud\";\nimport systemCRUD from \"./crud/system.crud\";\nimport storage from \"./storage\";\n\nexport default () => [\n systemCRUD,\n settingsCRUD,\n filesCRUD,\n storage,\n graphql,\n fileValidationPlugin()\n];\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AAAgC,eAEjB,MAAM,CACjBA,eAAU,EACVC,iBAAY,EACZC,cAAS,EACTC,gBAAO,EACPC,gBAAO,EACP,IAAAC,mBAAoB,GAAE,CACzB;AAAA"}