@webiny/api-file-manager 5.23.1 → 5.25.0-beta.0

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 (84) hide show
  1. package/handlers/download/index.d.ts +5 -1
  2. package/handlers/download/index.js +25 -19
  3. package/handlers/download/index.js.map +1 -0
  4. package/handlers/manage/index.d.ts +2 -1
  5. package/handlers/manage/index.js +17 -16
  6. package/handlers/manage/index.js.map +1 -0
  7. package/handlers/transform/index.d.ts +2 -1
  8. package/handlers/transform/index.js +7 -4
  9. package/handlers/transform/index.js.map +1 -0
  10. package/handlers/transform/loaders/imageLoader.d.ts +25 -9
  11. package/handlers/transform/loaders/imageLoader.js +2 -3
  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.map +1 -0
  15. package/handlers/transform/loaders/sanitizeImageTransformations.d.ts +7 -3
  16. package/handlers/transform/loaders/sanitizeImageTransformations.js +27 -20
  17. package/handlers/transform/loaders/sanitizeImageTransformations.js.map +1 -0
  18. package/handlers/transform/managers/imageManager.d.ts +12 -6
  19. package/handlers/transform/managers/imageManager.js +22 -17
  20. package/handlers/transform/managers/imageManager.js.map +1 -0
  21. package/handlers/transform/managers/index.d.ts +2 -6
  22. package/handlers/transform/managers/index.js.map +1 -0
  23. package/handlers/transform/optimizeImage.d.ts +2 -1
  24. package/handlers/transform/optimizeImage.js +3 -0
  25. package/handlers/transform/optimizeImage.js.map +1 -0
  26. package/handlers/transform/transformImage.d.ts +5 -4
  27. package/handlers/transform/transformImage.js +3 -3
  28. package/handlers/transform/transformImage.js.map +1 -0
  29. package/handlers/transform/utils.d.ts +2 -2
  30. package/handlers/transform/utils.js.map +1 -0
  31. package/handlers/types.d.ts +33 -0
  32. package/handlers/types.js +5 -0
  33. package/handlers/types.js.map +1 -0
  34. package/handlers/utils/createHandler.d.ts +16 -16
  35. package/handlers/utils/createHandler.js +43 -42
  36. package/handlers/utils/createHandler.js.map +1 -0
  37. package/handlers/utils/getEnvironment.js.map +1 -0
  38. package/handlers/utils/getObjectParams.d.ts +3 -4
  39. package/handlers/utils/getObjectParams.js +0 -2
  40. package/handlers/utils/getObjectParams.js.map +1 -0
  41. package/handlers/utils/index.d.ts +1 -1
  42. package/handlers/utils/index.js +17 -7
  43. package/handlers/utils/index.js.map +1 -0
  44. package/package.json +20 -20
  45. package/plugins/crud/files/validation.js.map +1 -0
  46. package/plugins/crud/files.crud.js +4 -7
  47. package/plugins/crud/files.crud.js.map +1 -0
  48. package/plugins/crud/settings.crud.js +1 -0
  49. package/plugins/crud/settings.crud.js.map +1 -0
  50. package/plugins/crud/system.crud.js.map +1 -0
  51. package/plugins/crud/utils/checkBasePermissions.js.map +1 -0
  52. package/plugins/crud/utils/createFileModel.d.ts +3 -0
  53. package/plugins/crud/utils/createFileModel.js +13 -0
  54. package/plugins/crud/utils/createFileModel.js.map +1 -0
  55. package/plugins/crud/utils/lifecycleEvents.d.ts +2 -2
  56. package/plugins/crud/utils/lifecycleEvents.js +5 -0
  57. package/plugins/crud/utils/lifecycleEvents.js.map +1 -0
  58. package/plugins/definitions/FilePhysicalStoragePlugin.d.ts +10 -11
  59. package/plugins/definitions/FilePhysicalStoragePlugin.js.map +1 -0
  60. package/plugins/definitions/FilePlugin.d.ts +6 -3
  61. package/plugins/definitions/FilePlugin.js +8 -2
  62. package/plugins/definitions/FilePlugin.js.map +1 -0
  63. package/plugins/definitions/FileStorageTransformPlugin.d.ts +9 -9
  64. package/plugins/definitions/FileStorageTransformPlugin.js.map +1 -0
  65. package/plugins/definitions/FilesStorageOperationsProviderPlugin.d.ts +3 -3
  66. package/plugins/definitions/FilesStorageOperationsProviderPlugin.js.map +1 -0
  67. package/plugins/definitions/InstallationPlugin.d.ts +9 -9
  68. package/plugins/definitions/InstallationPlugin.js +4 -2
  69. package/plugins/definitions/InstallationPlugin.js.map +1 -0
  70. package/plugins/definitions/SettingsStorageOperationsProviderPlugin.d.ts +3 -3
  71. package/plugins/definitions/SettingsStorageOperationsProviderPlugin.js.map +1 -0
  72. package/plugins/definitions/SystemStorageOperationsProviderPlugin.d.ts +3 -3
  73. package/plugins/definitions/SystemStorageOperationsProviderPlugin.js.map +1 -0
  74. package/plugins/graphql.js +9 -1
  75. package/plugins/graphql.js.map +1 -0
  76. package/plugins/index.js.map +1 -0
  77. package/plugins/storage/FileStorage.d.ts +23 -24
  78. package/plugins/storage/FileStorage.js +23 -13
  79. package/plugins/storage/FileStorage.js.map +1 -0
  80. package/plugins/storage/index.js +4 -0
  81. package/plugins/storage/index.js.map +1 -0
  82. package/types.d.ts +10 -9
  83. package/types.js.map +1 -0
  84. package/utils.js.map +1 -0
@@ -1,22 +1,21 @@
1
1
  /// <reference types="node" />
2
2
  import { Plugin } from "@webiny/plugins";
3
3
  import { FileManagerSettings } from "../../types";
4
- export interface Params {
5
- upload: (args: UploadParams) => Promise<any>;
6
- delete: (args: DeleteParams) => Promise<void>;
4
+ export interface FilePhysicalStoragePluginParams<U extends FilePhysicalStoragePluginUploadParams, D extends FilePhysicalStoragePluginDeleteParams> {
5
+ upload: (args: U) => Promise<any>;
6
+ delete: (args: D) => Promise<void>;
7
7
  }
8
- export interface UploadParams {
8
+ export interface FilePhysicalStoragePluginUploadParams {
9
9
  settings: FileManagerSettings;
10
10
  buffer: Buffer;
11
- [key: string]: any;
12
11
  }
13
- export interface DeleteParams {
12
+ export interface FilePhysicalStoragePluginDeleteParams {
14
13
  key: string;
15
14
  }
16
- export declare class FilePhysicalStoragePlugin extends Plugin {
17
- static readonly type = "api-file-manager-storage";
15
+ export declare class FilePhysicalStoragePlugin<U extends FilePhysicalStoragePluginUploadParams = FilePhysicalStoragePluginUploadParams, D extends FilePhysicalStoragePluginDeleteParams = FilePhysicalStoragePluginDeleteParams> extends Plugin {
16
+ static readonly type: string;
18
17
  private readonly _params;
19
- constructor(params: Params);
20
- upload(params: UploadParams): Promise<any>;
21
- delete(params: DeleteParams): Promise<any>;
18
+ constructor(params: FilePhysicalStoragePluginParams<U, D>);
19
+ upload(params: U): Promise<any>;
20
+ delete(params: D): Promise<any>;
22
21
  }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["FilePhysicalStoragePlugin.ts"],"names":["FilePhysicalStoragePlugin","Plugin","constructor","params","_params","upload","WebinyError","delete"],"mappings":";;;;;;;;;;;AAAA;;AACA;;AAoBO,MAAMA,yBAAN,SAGGC,eAHH,CAGU;AAINC,EAAAA,WAAW,CAACC,MAAD,EAAgD;AAC9D;AAD8D;AAE9D,SAAKC,OAAL,GAAeD,MAAf;AACH;;AAEkB,QAANE,MAAM,CAACF,MAAD,EAA0B;AACzC,QAAI,CAAC,KAAKC,OAAL,CAAaC,MAAlB,EAA0B;AACtB,YAAM,IAAIC,cAAJ,CACD,qDADC,EAEF,qBAFE,CAAN;AAIH;;AACD,WAAO,KAAKF,OAAL,CAAaC,MAAb,CAAoBF,MAApB,CAAP;AACH;;AAEkB,QAANI,MAAM,CAACJ,MAAD,EAA0B;AACzC,QAAI,CAAC,KAAKC,OAAL,CAAaG,MAAlB,EAA0B;AACtB,YAAM,IAAID,cAAJ,CACD,qDADC,EAEF,qBAFE,CAAN;AAIH;;AACD,WAAO,KAAKF,OAAL,CAAaG,MAAb,CAAoBJ,MAApB,CAAP;AACH;;AA3BY;;;8BAHJH,yB,UAIsC,0B","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"]}
@@ -107,7 +107,7 @@ export interface AfterDeleteParams {
107
107
  *
108
108
  * @category FilePlugin
109
109
  */
110
- export interface Params {
110
+ export interface FilePluginParams {
111
111
  beforeCreate?: (params: BeforeCreateParams) => Promise<void>;
112
112
  afterCreate?: (params: AfterCreateParams) => Promise<void>;
113
113
  beforeUpdate?: (params: BeforeUpdateParams) => Promise<void>;
@@ -118,9 +118,9 @@ export interface Params {
118
118
  afterDelete?: (params: AfterDeleteParams) => Promise<void>;
119
119
  }
120
120
  export declare class FilePlugin extends Plugin {
121
- static readonly type = "fm.file";
121
+ static readonly type: string;
122
122
  private readonly _params;
123
- constructor(params?: Params);
123
+ constructor(params?: FilePluginParams);
124
124
  beforeCreate(params: BeforeCreateParams): Promise<void>;
125
125
  afterCreate(params: AfterCreateParams): Promise<void>;
126
126
  beforeUpdate(params: BeforeUpdateParams): Promise<void>;
@@ -129,5 +129,8 @@ export declare class FilePlugin extends Plugin {
129
129
  afterBatchCreate(params: AfterBatchCreateParams): Promise<void>;
130
130
  beforeDelete(params: BeforeDeleteParams): Promise<void>;
131
131
  afterDelete(params: AfterDeleteParams): Promise<void>;
132
+ /**
133
+ * Keep any here because it can be a number of params. Method is internal so no need to complicate the code.
134
+ */
132
135
  private _execute;
133
136
  }
@@ -49,13 +49,19 @@ class FilePlugin extends _plugins.Plugin {
49
49
  async afterDelete(params) {
50
50
  await this._execute("afterDelete", params);
51
51
  }
52
+ /**
53
+ * Keep any here because it can be a number of params. Method is internal so no need to complicate the code.
54
+ */
55
+
52
56
 
53
57
  async _execute(callback, params) {
54
- if (typeof this._params[callback] !== "function") {
58
+ const cb = this._params[callback];
59
+
60
+ if (typeof cb !== "function") {
55
61
  return;
56
62
  }
57
63
 
58
- await this._params[callback](params);
64
+ await cb(params);
59
65
  }
60
66
 
61
67
  }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["FilePlugin.ts"],"names":["FilePlugin","Plugin","constructor","params","_params","beforeCreate","_execute","afterCreate","beforeUpdate","afterUpdate","beforeBatchCreate","afterBatchCreate","beforeDelete","afterDelete","callback","cb"],"mappings":";;;;;;;;;;;AAAA;;AA2HO,MAAMA,UAAN,SAAyBC,eAAzB,CAAgC;AAI5BC,EAAAA,WAAW,CAACC,MAAD,EAA4B;AAC1C;AAD0C;AAE1C,SAAKC,OAAL,GAAeD,MAAM,IAAK,EAA1B;AACH;;AAEwB,QAAZE,YAAY,CAACF,MAAD,EAA4C;AACjE,UAAM,KAAKG,QAAL,CAAc,cAAd,EAA8BH,MAA9B,CAAN;AACH;;AAEuB,QAAXI,WAAW,CAACJ,MAAD,EAA2C;AAC/D,UAAM,KAAKG,QAAL,CAAc,aAAd,EAA6BH,MAA7B,CAAN;AACH;;AAEwB,QAAZK,YAAY,CAACL,MAAD,EAA4C;AACjE,UAAM,KAAKG,QAAL,CAAc,cAAd,EAA8BH,MAA9B,CAAN;AACH;;AAEuB,QAAXM,WAAW,CAACN,MAAD,EAA2C;AAC/D,UAAM,KAAKG,QAAL,CAAc,aAAd,EAA6BH,MAA7B,CAAN;AACH;;AAE6B,QAAjBO,iBAAiB,CAACP,MAAD,EAAiD;AAC3E,UAAM,KAAKG,QAAL,CAAc,mBAAd,EAAmCH,MAAnC,CAAN;AACH;;AAE4B,QAAhBQ,gBAAgB,CAACR,MAAD,EAAgD;AACzE,UAAM,KAAKG,QAAL,CAAc,kBAAd,EAAkCH,MAAlC,CAAN;AACH;;AAEwB,QAAZS,YAAY,CAACT,MAAD,EAA4C;AACjE,UAAM,KAAKG,QAAL,CAAc,cAAd,EAA8BH,MAA9B,CAAN;AACH;;AAEuB,QAAXU,WAAW,CAACV,MAAD,EAA2C;AAC/D,UAAM,KAAKG,QAAL,CAAc,aAAd,EAA6BH,MAA7B,CAAN;AACH;AACD;AACJ;AACA;;;AAC0B,QAARG,QAAQ,CAACQ,QAAD,EAAmCX,MAAnC,EAA+D;AACjF,UAAMY,EAAE,GAAG,KAAKX,OAAL,CAAaU,QAAb,CAAX;;AACA,QAAI,OAAOC,EAAP,KAAc,UAAlB,EAA8B;AAC1B;AACH;;AACD,UAAMA,EAAE,CAACZ,MAAD,CAAR;AACH;;AAjDkC;;;8BAA1BH,U,UACsC,S","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"]}
@@ -1,34 +1,34 @@
1
1
  import { Plugin } from "@webiny/plugins";
2
2
  import { File } from "../../types";
3
- export interface 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
  }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["FileStorageTransformPlugin.ts"],"names":["FileStorageTransformPlugin","Plugin","constructor","params","_params","toStorage","file","fromStorage"],"mappings":";;;;;;;;;;;AAAA;;AAwBO,MAAMA,0BAAN,SAAyCC,eAAzC,CAAgD;AAI5CC,EAAAA,WAAW,CAACC,MAAD,EAA2C;AACzD;AADyD;AAGzD,SAAKC,OAAL,GAAeD,MAAf;AACH;AAED;AACJ;AACA;AACA;;;AAC0B,QAATE,SAAS,CAClBF,MADkB,EAEiB;AACnC,QAAI,CAAC,KAAKC,OAAL,CAAaC,SAAlB,EAA6B;AACzB,aAAOF,MAAM,CAACG,IAAd;AACH;;AACD,WAAO,KAAKF,OAAL,CAAaC,SAAb,CAAuBF,MAAvB,CAAP;AACH;AACD;AACJ;AACA;AACA;AACA;;;AAC4B,QAAXI,WAAW,CACpBJ,MADoB,EAEe;AACnC,QAAI,CAAC,KAAKC,OAAL,CAAaG,WAAlB,EAA+B;AAC3B,aAAOJ,MAAM,CAACG,IAAd;AACH;;AACD,WAAO,KAAKF,OAAL,CAAaG,WAAb,CAAyBJ,MAAzB,CAAP;AACH;;AAlCkD;;;8BAA1CH,0B,UACsC,4B","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"]}
@@ -1,9 +1,9 @@
1
1
  import { Plugin } from "@webiny/plugins";
2
2
  import { FileManagerContext, FileManagerFilesStorageOperations } from "../../types";
3
- export interface Params {
3
+ export interface FilesStorageOperationsProviderPluginParams {
4
4
  context: FileManagerContext;
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
  }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["FilesStorageOperationsProviderPlugin.ts"],"names":["FilesStorageOperationsProviderPlugin","Plugin"],"mappings":";;;;;;;;;;;AAAA;;AAOO,MAAeA,oCAAf,SAA4DC,eAA5D,CAAmE;;;8BAApDD,oC,UAC6B,oC","sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport { FileManagerContext, FileManagerFilesStorageOperations } from \"~/types\";\n\nexport interface FilesStorageOperationsProviderPluginParams {\n context: FileManagerContext;\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"]}
@@ -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 {};
@@ -27,11 +27,13 @@ class InstallationPlugin extends _plugins.Plugin {
27
27
  }
28
28
 
29
29
  async _execute(callback, params) {
30
- if (typeof this._config[callback] !== "function") {
30
+ const cb = this._config[callback];
31
+
32
+ if (!cb) {
31
33
  return;
32
34
  }
33
35
 
34
- return this._config[callback](params);
36
+ return cb(params);
35
37
  }
36
38
 
37
39
  }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["InstallationPlugin.ts"],"names":["InstallationPlugin","Plugin","constructor","config","_config","beforeInstall","params","_execute","afterInstall","callback","cb"],"mappings":";;;;;;;;;;;AACA;;AAYO,MAAeA,kBAAf,SAA0CC,eAA1C,CAAiD;AAIpDC,EAAAA,WAAW,CAACC,MAAD,EAA6C;AACpD;AADoD;AAEpD,SAAKC,OAAL,GAAeD,MAAM,IAAI,EAAzB;AACH;;AAEyB,QAAbE,aAAa,CAACC,MAAD,EAAkD;AACxE,WAAO,KAAKC,QAAL,CAAc,eAAd,EAA+BD,MAA/B,CAAP;AACH;;AAEwB,QAAZE,YAAY,CAACF,MAAD,EAAkD;AACvE,WAAO,KAAKC,QAAL,CAAc,cAAd,EAA8BD,MAA9B,CAAP;AACH;;AAEqB,QAARC,QAAQ,CAClBE,QADkB,EAElBH,MAFkB,EAGL;AACb,UAAMI,EAAE,GAAG,KAAKN,OAAL,CAAaK,QAAb,CAAX;;AACA,QAAI,CAACC,EAAL,EAAS;AACL;AACH;;AACD,WAAOA,EAAE,CAACJ,MAAD,CAAT;AACH;;AA1BmD;;;8BAAlCN,kB,UAC6B,Y","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"]}
@@ -1,9 +1,9 @@
1
1
  import { Plugin } from "@webiny/plugins";
2
2
  import { FileManagerContext, FileManagerSettingsStorageOperations } from "../../types";
3
- export interface Params {
3
+ export interface SettingsStorageOperationsProviderPluginParams {
4
4
  context: FileManagerContext;
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
  }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["SettingsStorageOperationsProviderPlugin.ts"],"names":["SettingsStorageOperationsProviderPlugin","Plugin"],"mappings":";;;;;;;;;;;AAAA;;AAOO,MAAeA,uCAAf,SAA+DC,eAA/D,CAAsE;;;8BAAvDD,uC,UAC6B,uC","sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport { FileManagerContext, FileManagerSettingsStorageOperations } from \"~/types\";\n\nexport interface SettingsStorageOperationsProviderPluginParams {\n context: FileManagerContext;\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"]}
@@ -1,9 +1,9 @@
1
1
  import { Plugin } from "@webiny/plugins";
2
2
  import { FileManagerContext, FileManagerSystemStorageOperations } from "../../types";
3
- export interface Params {
3
+ export interface SystemStorageOperationsProviderPluginParams {
4
4
  context: FileManagerContext;
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
  }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["SystemStorageOperationsProviderPlugin.ts"],"names":["SystemStorageOperationsProviderPlugin","Plugin"],"mappings":";;;;;;;;;;;AAAA;;AAOO,MAAeA,qCAAf,SAA6DC,eAA7D,CAAoE;;;8BAArDD,qC,UAC6B,qC","sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport { FileManagerContext, FileManagerSystemStorageOperations } from \"~/types\";\n\nexport interface SystemStorageOperationsProviderPluginParams {\n context: FileManagerContext;\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"]}
@@ -8,6 +8,11 @@ exports.default = void 0;
8
8
  var _handlerGraphql = require("@webiny/handler-graphql");
9
9
 
10
10
  const emptyResolver = () => ({});
11
+ /**
12
+ * Use any because it really can be any.
13
+ * TODO @ts-refactor maybe use generics at some point?
14
+ */
15
+
11
16
 
12
17
  const resolve = async fn => {
13
18
  try {
@@ -60,6 +65,7 @@ const plugin = {
60
65
  code: String
61
66
  message: String
62
67
  data: JSON
68
+ stack: String
63
69
  }
64
70
 
65
71
  type FileListResponse {
@@ -99,11 +105,13 @@ const plugin = {
99
105
  type FileManagerSettings {
100
106
  uploadMinFileSize: Number
101
107
  uploadMaxFileSize: Number
108
+ srcPrefix: String
102
109
  }
103
110
 
104
111
  input FileManagerSettingsInput {
105
112
  uploadMinFileSize: Number
106
113
  uploadMaxFileSize: Number
114
+ srcPrefix: String
107
115
  }
108
116
 
109
117
  type FileManagerSettingsResponse {
@@ -178,7 +186,7 @@ const plugin = {
178
186
  File: {
179
187
  async src(file, _, context) {
180
188
  const settings = await context.fileManager.settings.getSettings();
181
- return settings.srcPrefix + file.key;
189
+ return ((settings === null || settings === void 0 ? void 0 : settings.srcPrefix) || "") + file.key;
182
190
  }
183
191
 
184
192
  },
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["graphql.ts"],"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","__","i18nContent","tenancy","getCurrentTenant","getCurrentLocale","system","getVersion","FmMutation","createFile","updateFile","createFiles","createFilesInBatch","deleteFile","storage","delete","install","upgrade","updateSettings"],"mappings":";;;;;;;AAAA;;AAIA,MAAMA,aAAa,GAAG,OAAO,EAAP,CAAtB;AAEA;AACA;AACA;AACA;;;AAKA,MAAMC,OAAO,GAAG,MAAOC,EAAP,IAA+B;AAC3C,MAAI;AACA,WAAO,IAAIC,wBAAJ,CAAa,MAAMD,EAAE,EAArB,CAAP;AACH,GAFD,CAEE,OAAOE,CAAP,EAAU;AACR,WAAO,IAAIC,6BAAJ,CAAkBD,CAAlB,CAAP;AACH;AACJ,CAND;;AAQA,MAAME,MAA+C,GAAG;AACpDC,EAAAA,IAAI,EAAE,gBAD8C;AAEpDC,EAAAA,MAAM,EAAE;AACJC,IAAAA,QAAQ;AAAE;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;A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iBAAOd,OAAO,CAAC,MAAMc,OAAO,CAACE,WAAR,CAAoBuB,MAApB,CAA2BW,OAA3B,CAAmC1B,IAAI,CAACS,OAAxC,CAAP,CAAd;AACH,SA1BO;;AA2BR,cAAMkB,cAAN,CAAqBtC,CAArB,EAAwBW,IAAxB,EAAmCV,OAAnC,EAA4C;AACxC,iBAAOd,OAAO,CAAC,MAAMc,OAAO,CAACE,WAAR,CAAoBD,QAApB,CAA6BoC,cAA7B,CAA4C3B,IAAI,CAACI,IAAjD,CAAP,CAAd;AACH;;AA7BO;AA5CL;AA5JP;AAF4C,CAAxD;eA6OevB,M","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 id_in: [ID!]\n id: ID\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: [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 { i18nContent, tenancy, fileManager } = context;\n if (!tenancy.getCurrentTenant() || !i18nContent.getCurrentLocale()) {\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"]}
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["index.ts"],"names":["systemCRUD","settingsCRUD","filesCRUD","storage","graphql"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;eAEe,MAAM,CACjBA,eADiB,EAEjBC,iBAFiB,EAGjBC,cAHiB,EAIjBC,gBAJiB,EAKjBC,gBALiB,EAMjB,0BANiB,C","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"]}
@@ -1,31 +1,30 @@
1
1
  /// <reference types="node" />
2
2
  import { FileManagerContext } from "../../types";
3
- export declare type Args = {
4
- name: string;
5
- type: string;
6
- size: number;
3
+ export declare type Result = Record<string, any>;
4
+ export interface FileStorageUploadParams {
7
5
  buffer: Buffer;
8
- keyPrefix?: string;
9
- hideInFileManager?: boolean;
6
+ hideInFileManager: boolean | string;
10
7
  tags?: string[];
11
- };
12
- export declare type Result = Record<string, any>;
13
- export interface FileStoragePlugin {
14
- upload: (args: Args) => Promise<Result>;
15
- delete: (args: {
16
- key: string;
17
- }) => Promise<void>;
8
+ size: number;
9
+ name: string;
10
+ keyPrefix: string;
11
+ type: string;
18
12
  }
19
- export declare class FileStorage {
20
- storagePlugin: FileStoragePlugin;
13
+ export interface FileStorageDeleteParams {
14
+ id: string;
15
+ key: string;
16
+ }
17
+ export interface FileStorageUploadMultipleParams {
18
+ files: FileStorageUploadParams[];
19
+ }
20
+ export interface FileStorageParams {
21
21
  context: FileManagerContext;
22
- constructor({ context }: {
23
- context: any;
24
- });
25
- upload(args: any): Promise<Result>;
26
- uploadFiles(args: any): Promise<import("../../types").File[]>;
27
- delete(args: {
28
- id: string;
29
- key: string;
30
- }): Promise<boolean>;
22
+ }
23
+ export declare class FileStorage {
24
+ private readonly storagePlugin;
25
+ private readonly context;
26
+ constructor({ context }: FileStorageParams);
27
+ upload(params: FileStorageUploadParams): Promise<Result>;
28
+ uploadFiles(params: FileStorageUploadMultipleParams): Promise<import("../../types").File[]>;
29
+ delete(params: FileStorageDeleteParams): Promise<boolean>;
31
30
  }
@@ -23,21 +23,27 @@ class FileStorage {
23
23
  }) {
24
24
  (0, _defineProperty2.default)(this, "storagePlugin", void 0);
25
25
  (0, _defineProperty2.default)(this, "context", void 0);
26
- this.storagePlugin = context.plugins.byType(storagePluginType).pop();
26
+ const storagePlugin = context.plugins.byType(storagePluginType).pop();
27
27
 
28
- if (!this.storagePlugin) {
28
+ if (!storagePlugin) {
29
29
  throw new _error.default(`Missing plugin of type "${storagePluginType}".`, "STORAGE_PLUGIN_ERROR");
30
30
  }
31
31
 
32
+ this.storagePlugin = storagePlugin;
32
33
  this.context = context;
33
34
  }
34
35
 
35
- async upload(args) {
36
- const settings = await this.context.fileManager.settings.getSettings(); // Add file to cloud storage.
36
+ async upload(params) {
37
+ const settings = await this.context.fileManager.settings.getSettings();
38
+
39
+ if (!settings) {
40
+ throw new _error.default("Missing File Manager Settings.", "FILE_MANAGER_ERROR");
41
+ } // Add file to cloud storage.
42
+
37
43
 
38
44
  const {
39
45
  file: fileData
40
- } = await this.storagePlugin.upload(_objectSpread(_objectSpread({}, args), {}, {
46
+ } = await this.storagePlugin.upload(_objectSpread(_objectSpread({}, params), {}, {
41
47
  settings
42
48
  }));
43
49
  const {
@@ -46,19 +52,23 @@ class FileStorage {
46
52
 
47
53
  return await fileManager.files.createFile(_objectSpread(_objectSpread({}, fileData), {}, {
48
54
  meta: {
49
- private: Boolean(args.hideInFileManager)
55
+ private: Boolean(params.hideInFileManager)
50
56
  },
51
- tags: Array.isArray(args.tags) ? args.tags : []
57
+ tags: Array.isArray(params.tags) ? params.tags : []
52
58
  }));
53
59
  }
54
60
 
55
- async uploadFiles(args) {
56
- const settings = await this.context.fileManager.settings.getSettings(); // Upload files to cloud storage.
61
+ async uploadFiles(params) {
62
+ const settings = await this.context.fileManager.settings.getSettings();
63
+
64
+ if (!settings) {
65
+ throw new _error.default("Missing File Manager Settings.", "FILE_MANAGER_ERROR");
66
+ } // Upload files to cloud storage.
67
+
57
68
 
58
69
  const promises = [];
59
70
 
60
- for (let i = 0; i < args.files.length; i++) {
61
- const item = args.files[i];
71
+ for (const item of params.files) {
62
72
  promises.push(this.storagePlugin.upload(_objectSpread(_objectSpread({}, item), {}, {
63
73
  settings
64
74
  })));
@@ -74,11 +84,11 @@ class FileStorage {
74
84
  return fileManager.files.createFilesInBatch(filesData);
75
85
  }
76
86
 
77
- async delete(args) {
87
+ async delete(params) {
78
88
  const {
79
89
  id,
80
90
  key
81
- } = args;
91
+ } = params;
82
92
  const {
83
93
  fileManager
84
94
  } = this.context; // Delete file from cloud storage.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["FileStorage.ts"],"names":["storagePluginType","FileStorage","constructor","context","storagePlugin","plugins","byType","pop","WebinyError","upload","params","settings","fileManager","getSettings","file","fileData","files","createFile","meta","private","Boolean","hideInFileManager","tags","Array","isArray","uploadFiles","promises","item","push","uploadFileResponses","Promise","all","filesData","map","response","createFilesInBatch","delete","id","key","deleteFile"],"mappings":";;;;;;;;;;;AACA;;;;;;AAKA,MAAMA,iBAAiB,GAAG,0BAA1B;;AAuBO,MAAMC,WAAN,CAAkB;AAIrBC,EAAAA,WAAW,CAAC;AAAEC,IAAAA;AAAF,GAAD,EAAiC;AAAA;AAAA;AACxC,UAAMC,aAAa,GAAGD,OAAO,CAACE,OAAR,CACjBC,MADiB,CACiBN,iBADjB,EAEjBO,GAFiB,EAAtB;;AAGA,QAAI,CAACH,aAAL,EAAoB;AAChB,YAAM,IAAII,cAAJ,CACD,2BAA0BR,iBAAkB,IAD3C,EAEF,sBAFE,CAAN;AAIH;;AACD,SAAKI,aAAL,GAAqBA,aAArB;AACA,SAAKD,OAAL,GAAeA,OAAf;AACH;;AAEW,QAANM,MAAM,CAACC,MAAD,EAAmD;AAC3D,UAAMC,QAAQ,GAAG,MAAM,KAAKR,OAAL,CAAaS,WAAb,CAAyBD,QAAzB,CAAkCE,WAAlC,EAAvB;;AACA,QAAI,CAACF,QAAL,EAAe;AACX,YAAM,IAAIH,cAAJ,CAAgB,gCAAhB,EAAkD,oBAAlD,CAAN;AACH,KAJ0D,CAK3D;;;AACA,UAAM;AAAEM,MAAAA,IAAI,EAAEC;AAAR,QAAqB,MAAM,KAAKX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ANI,MAAM,CAAC1B,MAAD,EAAkC;AAC1C,UAAM;AAAE2B,MAAAA,EAAF;AAAMC,MAAAA;AAAN,QAAc5B,MAApB;AACA,UAAM;AAAEE,MAAAA;AAAF,QAAkB,KAAKT,OAA7B,CAF0C,CAG1C;;AACA,UAAM,KAAKC,aAAL,CAAmBgC,MAAnB,CAA0B;AAC5BE,MAAAA;AAD4B,KAA1B,CAAN,CAJ0C,CAO1C;;AACA,WAAO,MAAM1B,WAAW,CAACI,KAAZ,CAAkBuB,UAAlB,CAA6BF,EAA7B,CAAb;AACH;;AA3EoB","sourcesContent":["import { FileManagerContext } from \"~/types\";\nimport WebinyError from \"@webiny/error\";\nimport { FilePhysicalStoragePlugin } from \"~/plugins/definitions/FilePhysicalStoragePlugin\";\n\nexport type Result = Record<string, any>;\n\nconst storagePluginType = \"api-file-manager-storage\";\n\nexport interface FileStorageUploadParams {\n buffer: Buffer;\n hideInFileManager: boolean | string;\n tags?: string[];\n size: number;\n name: string;\n keyPrefix: string;\n type: string;\n}\nexport interface FileStorageDeleteParams {\n id: string;\n key: string;\n}\n\nexport interface FileStorageUploadMultipleParams {\n files: FileStorageUploadParams[];\n}\n\nexport interface FileStorageParams {\n context: FileManagerContext;\n}\nexport class FileStorage {\n private readonly storagePlugin: FilePhysicalStoragePlugin;\n private readonly context: FileManagerContext;\n\n constructor({ context }: FileStorageParams) {\n const storagePlugin = context.plugins\n .byType<FilePhysicalStoragePlugin>(storagePluginType)\n .pop();\n if (!storagePlugin) {\n throw new WebinyError(\n `Missing plugin of type \"${storagePluginType}\".`,\n \"STORAGE_PLUGIN_ERROR\"\n );\n }\n this.storagePlugin = storagePlugin;\n this.context = context;\n }\n\n async upload(params: FileStorageUploadParams): Promise<Result> {\n const settings = await this.context.fileManager.settings.getSettings();\n if (!settings) {\n throw new WebinyError(\"Missing File Manager Settings.\", \"FILE_MANAGER_ERROR\");\n }\n // Add file to cloud storage.\n const { file: fileData } = await this.storagePlugin.upload({\n ...params,\n settings\n });\n\n const { fileManager } = this.context;\n\n // Save file in DB.\n return await fileManager.files.createFile({\n ...(fileData as any),\n meta: {\n private: Boolean(params.hideInFileManager)\n },\n tags: Array.isArray(params.tags) ? params.tags : []\n });\n }\n\n async uploadFiles(params: FileStorageUploadMultipleParams) {\n const settings = await this.context.fileManager.settings.getSettings();\n if (!settings) {\n throw new WebinyError(\"Missing File Manager Settings.\", \"FILE_MANAGER_ERROR\");\n }\n // Upload files to cloud storage.\n const promises = [];\n for (const item of params.files) {\n promises.push(\n this.storagePlugin.upload({\n ...item,\n settings\n })\n );\n }\n // Wait for all to resolve.\n const uploadFileResponses = await Promise.all(promises);\n\n const filesData = uploadFileResponses.map(response => response.file);\n\n const { fileManager } = this.context;\n // Save files in DB.\n return fileManager.files.createFilesInBatch(filesData);\n }\n\n async delete(params: FileStorageDeleteParams) {\n const { id, key } = params;\n const { fileManager } = this.context;\n // Delete file from cloud storage.\n await this.storagePlugin.delete({\n key\n });\n // Delete file from the DB.\n return await fileManager.files.deleteFile(id);\n }\n}\n"]}
@@ -11,6 +11,10 @@ var _FileStorage = require("./FileStorage");
11
11
 
12
12
  const fileStorageContextPlugin = new _handler.ContextPlugin(async context => {
13
13
  if (!context.fileManager) {
14
+ /**
15
+ * We need to define the fileManager initial property as empty object.
16
+ * When casting as FileManagerContext, typescript is complaining.
17
+ */
14
18
  context.fileManager = {};
15
19
  }
16
20
 
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["index.ts"],"names":["fileStorageContextPlugin","ContextPlugin","context","fileManager","storage","FileStorage"],"mappings":";;;;;;;AACA;;AACA;;AAEA,MAAMA,wBAAwB,GAAG,IAAIC,sBAAJ,CAAsC,MAAMC,OAAN,IAAiB;AACpF,MAAI,CAACA,OAAO,CAACC,WAAb,EAA0B;AACtB;AACR;AACA;AACA;AACQD,IAAAA,OAAO,CAACC,WAAR,GAAsB,EAAtB;AACH;;AACDD,EAAAA,OAAO,CAACC,WAAR,CAAoBC,OAApB,GAA8B,IAAIC,wBAAJ,CAAgB;AAC1CH,IAAAA;AAD0C,GAAhB,CAA9B;AAGH,CAXgC,CAAjC;eAaeF,wB","sourcesContent":["import { FileManagerContext } from \"~/types\";\nimport { ContextPlugin } from \"@webiny/handler\";\nimport { FileStorage } from \"./FileStorage\";\n\nconst fileStorageContextPlugin = new ContextPlugin<FileManagerContext>(async context => {\n if (!context.fileManager) {\n /**\n * We need to define the fileManager initial property as empty object.\n * When casting as FileManagerContext, typescript is complaining.\n */\n context.fileManager = {} as any;\n }\n context.fileManager.storage = new FileStorage({\n context\n });\n});\n\nexport default fileStorageContextPlugin;\n"]}
package/types.d.ts CHANGED
@@ -39,7 +39,7 @@ export interface File {
39
39
  }
40
40
  export interface CreatedBy {
41
41
  id: string;
42
- displayName: string;
42
+ displayName: string | null;
43
43
  type: string;
44
44
  }
45
45
  export interface FileInput {
@@ -48,7 +48,7 @@ export interface FileInput {
48
48
  size: number;
49
49
  type: string;
50
50
  meta: Record<string, any>;
51
- tags: [string];
51
+ tags: string[];
52
52
  }
53
53
  export interface FileListWhereParams {
54
54
  search?: string;
@@ -71,8 +71,9 @@ export interface FilesListOpts {
71
71
  sort?: string[];
72
72
  }
73
73
  export interface FileListMeta {
74
- cursor: string;
74
+ cursor: string | null;
75
75
  totalCount: number;
76
+ hasMoreItems: boolean;
76
77
  }
77
78
  interface FilesCrudListTagsWhere {
78
79
  tag?: string;
@@ -94,7 +95,7 @@ export interface FilesCRUD {
94
95
  createFilesInBatch(data: FileInput[]): Promise<File[]>;
95
96
  }
96
97
  export interface SystemCRUD {
97
- getVersion(): Promise<string>;
98
+ getVersion(): Promise<string | null>;
98
99
  setVersion(version: string): Promise<void>;
99
100
  install(args: {
100
101
  srcPrefix: string;
@@ -112,7 +113,7 @@ export interface FileManagerSystem {
112
113
  tenant: string;
113
114
  }
114
115
  export declare type SettingsCRUD = {
115
- getSettings(): Promise<FileManagerSettings>;
116
+ getSettings(): Promise<FileManagerSettings | null>;
116
117
  createSettings(data?: Partial<FileManagerSettings>): Promise<FileManagerSettings>;
117
118
  updateSettings(data: Partial<FileManagerSettings>): Promise<FileManagerSettings>;
118
119
  deleteSettings(): Promise<boolean>;
@@ -294,10 +295,10 @@ export interface FileManagerFilesStorageOperationsListParams {
294
295
  * @category FilesStorageOperations
295
296
  * @category FilesStorageOperationsParams
296
297
  */
297
- interface FileManagerFilesStorageOperationsListResponseMeta {
298
+ export interface FileManagerFilesStorageOperationsListResponseMeta {
298
299
  hasMoreItems: boolean;
299
300
  totalCount: number;
300
- cursor: string;
301
+ cursor: string | null;
301
302
  }
302
303
  export declare type FileManagerFilesStorageOperationsListResponse = [
303
304
  File[],
@@ -333,11 +334,11 @@ export interface FileManagerFilesStorageOperations {
333
334
  /**
334
335
  * Insert the file data into the database.
335
336
  */
336
- create: (params: FileManagerFilesStorageOperationsCreateParams) => Promise<File | null>;
337
+ create: (params: FileManagerFilesStorageOperationsCreateParams) => Promise<File>;
337
338
  /**
338
339
  * Update the file data in the database.
339
340
  */
340
- update: (params: FileManagerFilesStorageOperationsUpdateParams) => Promise<File | null>;
341
+ update: (params: FileManagerFilesStorageOperationsUpdateParams) => Promise<File>;
341
342
  /**
342
343
  * Delete the file from the database.
343
344
  */
package/types.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
package/utils.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["utils.ts"],"names":["executeCallbacks","plugins","hook","args","plugin"],"mappings":";;;;;;;AAIO,MAAMA,gBAAgB,GAAG,OAG5BC,OAH4B,EAI5BC,IAJ4B,EAK5BC,IAL4B,KAM3B;AACD,OAAK,MAAMC,MAAX,IAAqBH,OAArB,EAA8B;AAC1B,QAAI,OAAOG,MAAM,CAACF,IAAD,CAAb,KAAwB,UAA5B,EAAwC;AACpC,YAAME,MAAM,CAACF,IAAD,CAAN,CAAaC,IAAb,CAAN;AACH;AACJ;AACJ,CAZM","sourcesContent":["import { Plugin } from \"@webiny/plugins/types\";\n\ntype CallbackFallback = (args: any) => void | Promise<void>;\n\nexport const executeCallbacks = async <\n TCallbackFunction extends CallbackFallback = CallbackFallback\n>(\n plugins: Plugin[],\n hook: string,\n args: Parameters<TCallbackFunction>[0]\n) => {\n for (const plugin of plugins) {\n if (typeof plugin[hook] === \"function\") {\n await plugin[hook](args);\n }\n }\n};\n"]}