@webiny/api-file-manager 0.0.0-mt-3 → 0.0.0-unstable.085ff6572f

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 (182) hide show
  1. package/FileManagerContextSetup.d.ts +13 -0
  2. package/FileManagerContextSetup.js +113 -0
  3. package/FileManagerContextSetup.js.map +1 -0
  4. package/cmsFileStorage/CmsFilesStorage.d.ts +27 -0
  5. package/cmsFileStorage/CmsFilesStorage.js +173 -0
  6. package/cmsFileStorage/CmsFilesStorage.js.map +1 -0
  7. package/cmsFileStorage/ListFilesWhereProcessor.d.ts +7 -0
  8. package/cmsFileStorage/ListFilesWhereProcessor.js +35 -0
  9. package/cmsFileStorage/ListFilesWhereProcessor.js.map +1 -0
  10. package/cmsFileStorage/ListTagsWhereProcessor.d.ts +7 -0
  11. package/cmsFileStorage/ListTagsWhereProcessor.js +35 -0
  12. package/cmsFileStorage/ListTagsWhereProcessor.js.map +1 -0
  13. package/cmsFileStorage/createFileManagerPlugins.d.ts +5 -0
  14. package/cmsFileStorage/createFileManagerPlugins.js +34 -0
  15. package/cmsFileStorage/createFileManagerPlugins.js.map +1 -0
  16. package/cmsFileStorage/createModelField.d.ts +5 -0
  17. package/cmsFileStorage/createModelField.js +37 -0
  18. package/cmsFileStorage/createModelField.js.map +1 -0
  19. package/cmsFileStorage/file.model.d.ts +4 -0
  20. package/cmsFileStorage/file.model.js +118 -0
  21. package/cmsFileStorage/file.model.js.map +1 -0
  22. package/cmsFileStorage/isInstallationPending.d.ts +4 -0
  23. package/cmsFileStorage/isInstallationPending.js +21 -0
  24. package/cmsFileStorage/isInstallationPending.js.map +1 -0
  25. package/contants.d.ts +1 -0
  26. package/contants.js +8 -0
  27. package/contants.js.map +1 -0
  28. package/createFileManager/files.crud.d.ts +3 -0
  29. package/createFileManager/files.crud.js +300 -0
  30. package/createFileManager/files.crud.js.map +1 -0
  31. package/createFileManager/filevalidation.disabled.d.ts +0 -0
  32. package/createFileManager/filevalidation.disabled.js +55 -0
  33. package/createFileManager/filevalidation.disabled.js.map +1 -0
  34. package/createFileManager/index.d.ts +15 -0
  35. package/createFileManager/index.js +20 -0
  36. package/createFileManager/index.js.map +1 -0
  37. package/createFileManager/permissions/FilesPermissions.d.ts +4 -0
  38. package/createFileManager/permissions/FilesPermissions.js +9 -0
  39. package/createFileManager/permissions/FilesPermissions.js.map +1 -0
  40. package/createFileManager/settings.crud.d.ts +3 -0
  41. package/createFileManager/settings.crud.js +91 -0
  42. package/createFileManager/settings.crud.js.map +1 -0
  43. package/createFileManager/system.crud.d.ts +3 -0
  44. package/createFileManager/system.crud.js +86 -0
  45. package/createFileManager/system.crud.js.map +1 -0
  46. package/graphql/baseSchema.d.ts +3 -0
  47. package/graphql/baseSchema.js +117 -0
  48. package/graphql/baseSchema.js.map +1 -0
  49. package/graphql/createFilesTypeDefs.d.ts +7 -0
  50. package/graphql/createFilesTypeDefs.js +162 -0
  51. package/graphql/createFilesTypeDefs.js.map +1 -0
  52. package/graphql/filesSchema.d.ts +4 -0
  53. package/graphql/filesSchema.js +83 -0
  54. package/graphql/filesSchema.js.map +1 -0
  55. package/graphql/index.d.ts +3 -0
  56. package/graphql/index.js +33 -0
  57. package/graphql/index.js.map +1 -0
  58. package/graphql/utils.d.ts +11 -0
  59. package/graphql/utils.js +22 -0
  60. package/graphql/utils.js.map +1 -0
  61. package/handlers/download/byAlias.d.ts +6 -0
  62. package/handlers/download/byAlias.js +89 -0
  63. package/handlers/download/byAlias.js.map +1 -0
  64. package/handlers/download/byExactKey.d.ts +2 -0
  65. package/handlers/download/byExactKey.js +57 -0
  66. package/handlers/download/byExactKey.js.map +1 -0
  67. package/handlers/download/extractFileInformation.d.ts +9 -0
  68. package/handlers/download/extractFileInformation.js +20 -0
  69. package/handlers/download/extractFileInformation.js.map +1 -0
  70. package/handlers/download/getS3Object.d.ts +10 -0
  71. package/handlers/download/getS3Object.js +60 -0
  72. package/handlers/download/getS3Object.js.map +1 -0
  73. package/handlers/download/index.d.ts +2 -3
  74. package/handlers/download/index.js +20 -118
  75. package/handlers/download/index.js.map +1 -0
  76. package/handlers/manage/index.d.ts +5 -3
  77. package/handlers/manage/index.js +43 -58
  78. package/handlers/manage/index.js.map +1 -0
  79. package/handlers/transform/index.d.ts +2 -3
  80. package/handlers/transform/index.js +71 -78
  81. package/handlers/transform/index.js.map +1 -0
  82. package/handlers/transform/legacyUtils.d.ts +17 -0
  83. package/handlers/transform/legacyUtils.js +42 -0
  84. package/handlers/transform/legacyUtils.js.map +1 -0
  85. package/handlers/transform/loaders/imageLoader.d.ts +26 -9
  86. package/handlers/transform/loaders/imageLoader.js +13 -25
  87. package/handlers/transform/loaders/imageLoader.js.map +1 -0
  88. package/handlers/transform/loaders/index.d.ts +4 -9
  89. package/handlers/transform/loaders/index.js +1 -4
  90. package/handlers/transform/loaders/index.js.map +1 -0
  91. package/handlers/transform/loaders/sanitizeImageTransformations.d.ts +7 -3
  92. package/handlers/transform/loaders/sanitizeImageTransformations.js +24 -30
  93. package/handlers/transform/loaders/sanitizeImageTransformations.js.map +1 -0
  94. package/handlers/transform/managers/imageManager.d.ts +12 -6
  95. package/handlers/transform/managers/imageManager.js +46 -27
  96. package/handlers/transform/managers/imageManager.js.map +1 -0
  97. package/handlers/transform/managers/index.d.ts +2 -6
  98. package/handlers/transform/managers/index.js +1 -4
  99. package/handlers/transform/managers/index.js.map +1 -0
  100. package/handlers/transform/optimizeImage.d.ts +2 -1
  101. package/handlers/transform/optimizeImage.js +4 -7
  102. package/handlers/transform/optimizeImage.js.map +1 -0
  103. package/handlers/transform/transformImage.d.ts +5 -4
  104. package/handlers/transform/transformImage.js +4 -9
  105. package/handlers/transform/transformImage.js.map +1 -0
  106. package/handlers/transform/utils.d.ts +2 -2
  107. package/handlers/transform/utils.js +8 -18
  108. package/handlers/transform/utils.js.map +1 -0
  109. package/handlers/types.d.ts +8 -0
  110. package/handlers/types.js +5 -0
  111. package/handlers/types.js.map +1 -0
  112. package/handlers/utils/getEnvironment.js +0 -2
  113. package/handlers/utils/getEnvironment.js.map +1 -0
  114. package/handlers/utils/getObjectParams.d.ts +3 -4
  115. package/handlers/utils/getObjectParams.js +1 -7
  116. package/handlers/utils/getObjectParams.js.map +1 -0
  117. package/handlers/utils/index.d.ts +0 -1
  118. package/handlers/utils/index.js +1 -12
  119. package/handlers/utils/index.js.map +1 -0
  120. package/index.d.ts +7 -0
  121. package/index.js +52 -0
  122. package/index.js.map +1 -0
  123. package/modelModifier/CmsModelModifier.d.ts +24 -0
  124. package/modelModifier/CmsModelModifier.js +59 -0
  125. package/modelModifier/CmsModelModifier.js.map +1 -0
  126. package/package.json +32 -32
  127. package/plugins/FilePhysicalStoragePlugin.d.ts +21 -0
  128. package/plugins/{definitions/FilePhysicalStoragePlugin.js → FilePhysicalStoragePlugin.js} +1 -12
  129. package/plugins/FilePhysicalStoragePlugin.js.map +1 -0
  130. package/plugins/{definitions/FileStorageTransformPlugin.d.ts → FileStorageTransformPlugin.d.ts} +10 -10
  131. package/plugins/{definitions/FileStorageTransformPlugin.js → FileStorageTransformPlugin.js} +2 -13
  132. package/plugins/FileStorageTransformPlugin.js.map +1 -0
  133. package/plugins/index.d.ts +2 -2
  134. package/plugins/index.js +22 -19
  135. package/plugins/index.js.map +1 -0
  136. package/storage/FileStorage.d.ts +32 -0
  137. package/storage/FileStorage.js +86 -0
  138. package/storage/FileStorage.js.map +1 -0
  139. package/types/file.d.ts +37 -0
  140. package/types/file.js +5 -0
  141. package/types/file.js.map +1 -0
  142. package/types/file.lifecycle.d.ts +44 -0
  143. package/types/file.lifecycle.js +5 -0
  144. package/types/file.lifecycle.js.map +1 -0
  145. package/types.d.ts +76 -83
  146. package/types.js +22 -0
  147. package/types.js.map +1 -0
  148. package/handlers/utils/createHandler.d.ts +0 -24
  149. package/handlers/utils/createHandler.js +0 -68
  150. package/plugins/crud/files/validation.d.ts +0 -3
  151. package/plugins/crud/files/validation.js +0 -41
  152. package/plugins/crud/files.crud.d.ts +0 -4
  153. package/plugins/crud/files.crud.js +0 -427
  154. package/plugins/crud/settings.crud.d.ts +0 -5
  155. package/plugins/crud/settings.crud.js +0 -115
  156. package/plugins/crud/system.crud.d.ts +0 -4
  157. package/plugins/crud/system.crud.js +0 -145
  158. package/plugins/crud/utils/checkBasePermissions.d.ts +0 -5
  159. package/plugins/crud/utils/checkBasePermissions.js +0 -33
  160. package/plugins/crud/utils/createFileModel.d.ts +0 -2
  161. package/plugins/crud/utils/createFileModel.js +0 -64
  162. package/plugins/crud/utils/lifecycleEvents.d.ts +0 -6
  163. package/plugins/crud/utils/lifecycleEvents.js +0 -33
  164. package/plugins/definitions/FilePhysicalStoragePlugin.d.ts +0 -22
  165. package/plugins/definitions/FilePlugin.d.ts +0 -133
  166. package/plugins/definitions/FilePlugin.js +0 -64
  167. package/plugins/definitions/FilesStorageOperationsProviderPlugin.d.ts +0 -9
  168. package/plugins/definitions/FilesStorageOperationsProviderPlugin.js +0 -17
  169. package/plugins/definitions/InstallationPlugin.d.ts +0 -19
  170. package/plugins/definitions/InstallationPlugin.js +0 -40
  171. package/plugins/definitions/SettingsStorageOperationsProviderPlugin.d.ts +0 -9
  172. package/plugins/definitions/SettingsStorageOperationsProviderPlugin.js +0 -17
  173. package/plugins/definitions/SystemStorageOperationsProviderPlugin.d.ts +0 -9
  174. package/plugins/definitions/SystemStorageOperationsProviderPlugin.js +0 -17
  175. package/plugins/graphql.d.ts +0 -4
  176. package/plugins/graphql.js +0 -274
  177. package/plugins/storage/FileStorage.d.ts +0 -31
  178. package/plugins/storage/FileStorage.js +0 -95
  179. package/plugins/storage/index.d.ts +0 -4
  180. package/plugins/storage/index.js +0 -22
  181. package/utils.d.ts +0 -4
  182. package/utils.js +0 -16
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.createFileModelModifier = exports.CmsModelModifierPlugin = void 0;
8
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
9
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
+ var _plugins = require("@webiny/plugins");
11
+ var _file = require("../cmsFileStorage/file.model");
12
+ var _createModelField = require("../cmsFileStorage/createModelField");
13
+ class CmsModelFieldsModifier {
14
+ constructor(fields) {
15
+ (0, _defineProperty2.default)(this, "fields", void 0);
16
+ this.fields = fields;
17
+ }
18
+ addField(field) {
19
+ this.fields.push((0, _objectSpread2.default)((0, _objectSpread2.default)({}, field), {}, {
20
+ storageId: `${field.type}@${field.id}`
21
+ }));
22
+ }
23
+ }
24
+ class CmsModelModifierPlugin extends _plugins.Plugin {
25
+ constructor(modelId, cb) {
26
+ super();
27
+ (0, _defineProperty2.default)(this, "modelId", void 0);
28
+ (0, _defineProperty2.default)(this, "cb", void 0);
29
+ this.modelId = modelId;
30
+ this.cb = cb;
31
+ }
32
+ async modifyModel(model) {
33
+ if (model.modelId !== this.modelId) {
34
+ return;
35
+ }
36
+ let extensionsField = model.fields.find(field => field.fieldId === "extensions");
37
+ if (!extensionsField) {
38
+ extensionsField = (0, _createModelField.createModelField)({
39
+ label: "Extensions",
40
+ type: "object",
41
+ settings: {
42
+ layout: [],
43
+ fields: []
44
+ }
45
+ });
46
+ model.fields.push(extensionsField);
47
+ }
48
+ const modifier = new CmsModelFieldsModifier(extensionsField.settings.fields);
49
+ await this.cb({
50
+ modifier
51
+ });
52
+ }
53
+ }
54
+ exports.CmsModelModifierPlugin = CmsModelModifierPlugin;
55
+ (0, _defineProperty2.default)(CmsModelModifierPlugin, "type", "fm.cms-model-modifier");
56
+ const createFileModelModifier = cb => {
57
+ return new CmsModelModifierPlugin(_file.FILE_MODEL_ID, cb);
58
+ };
59
+ exports.createFileModelModifier = createFileModelModifier;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["CmsModelFieldsModifier","constructor","fields","addField","field","push","storageId","type","id","CmsModelModifierPlugin","Plugin","modelId","cb","modifyModel","model","extensionsField","find","fieldId","createModelField","label","settings","layout","modifier","createFileModelModifier","FILE_MODEL_ID"],"sources":["CmsModelModifier.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport { CmsModelField as BaseModelField } from \"@webiny/api-headless-cms/types\";\nimport { FILE_MODEL_ID } from \"~/cmsFileStorage/file.model\";\nimport { createModelField } from \"~/cmsFileStorage/createModelField\";\nimport { CmsPrivateModelFull } from \"@webiny/api-headless-cms\";\n\ntype CmsModelField = Omit<BaseModelField, \"storageId\">;\n\nclass CmsModelFieldsModifier {\n private fields: BaseModelField[];\n\n constructor(fields: BaseModelField[]) {\n this.fields = fields;\n }\n\n addField(field: CmsModelField) {\n this.fields.push({\n ...field,\n storageId: `${field.type}@${field.id}`\n });\n }\n}\n\ninterface CmsModelModifierCallableParams {\n modifier: CmsModelFieldsModifier;\n}\n\ninterface CmsModelModifierCallable {\n (params: CmsModelModifierCallableParams): Promise<void> | void;\n}\n\nexport class CmsModelModifierPlugin extends Plugin {\n public static override type = \"fm.cms-model-modifier\";\n private readonly modelId: string;\n private readonly cb: CmsModelModifierCallable;\n\n constructor(modelId: string, cb: CmsModelModifierCallable) {\n super();\n this.modelId = modelId;\n this.cb = cb;\n }\n\n async modifyModel(model: CmsPrivateModelFull): Promise<void> {\n if (model.modelId !== this.modelId) {\n return;\n }\n\n let extensionsField = model.fields.find(field => field.fieldId === \"extensions\");\n if (!extensionsField) {\n extensionsField = createModelField({\n label: \"Extensions\",\n type: \"object\",\n settings: {\n layout: [],\n fields: []\n }\n });\n model.fields.push(extensionsField);\n }\n\n const modifier = new CmsModelFieldsModifier(extensionsField.settings!.fields!);\n await this.cb({ modifier });\n }\n}\n\nexport const createFileModelModifier = (cb: CmsModelModifierCallable) => {\n return new CmsModelModifierPlugin(FILE_MODEL_ID, cb);\n};\n"],"mappings":";;;;;;;;;AAAA;AAEA;AACA;AAKA,MAAMA,sBAAsB,CAAC;EAGzBC,WAAW,CAACC,MAAwB,EAAE;IAAA;IAClC,IAAI,CAACA,MAAM,GAAGA,MAAM;EACxB;EAEAC,QAAQ,CAACC,KAAoB,EAAE;IAC3B,IAAI,CAACF,MAAM,CAACG,IAAI,6DACTD,KAAK;MACRE,SAAS,EAAG,GAAEF,KAAK,CAACG,IAAK,IAAGH,KAAK,CAACI,EAAG;IAAC,GACxC;EACN;AACJ;AAUO,MAAMC,sBAAsB,SAASC,eAAM,CAAC;EAK/CT,WAAW,CAACU,OAAe,EAAEC,EAA4B,EAAE;IACvD,KAAK,EAAE;IAAC;IAAA;IACR,IAAI,CAACD,OAAO,GAAGA,OAAO;IACtB,IAAI,CAACC,EAAE,GAAGA,EAAE;EAChB;EAEA,MAAMC,WAAW,CAACC,KAA0B,EAAiB;IACzD,IAAIA,KAAK,CAACH,OAAO,KAAK,IAAI,CAACA,OAAO,EAAE;MAChC;IACJ;IAEA,IAAII,eAAe,GAAGD,KAAK,CAACZ,MAAM,CAACc,IAAI,CAACZ,KAAK,IAAIA,KAAK,CAACa,OAAO,KAAK,YAAY,CAAC;IAChF,IAAI,CAACF,eAAe,EAAE;MAClBA,eAAe,GAAG,IAAAG,kCAAgB,EAAC;QAC/BC,KAAK,EAAE,YAAY;QACnBZ,IAAI,EAAE,QAAQ;QACda,QAAQ,EAAE;UACNC,MAAM,EAAE,EAAE;UACVnB,MAAM,EAAE;QACZ;MACJ,CAAC,CAAC;MACFY,KAAK,CAACZ,MAAM,CAACG,IAAI,CAACU,eAAe,CAAC;IACtC;IAEA,MAAMO,QAAQ,GAAG,IAAItB,sBAAsB,CAACe,eAAe,CAACK,QAAQ,CAAElB,MAAM,CAAE;IAC9E,MAAM,IAAI,CAACU,EAAE,CAAC;MAAEU;IAAS,CAAC,CAAC;EAC/B;AACJ;AAAC;AAAA,8BAhCYb,sBAAsB,UACD,uBAAuB;AAiClD,MAAMc,uBAAuB,GAAIX,EAA4B,IAAK;EACrE,OAAO,IAAIH,sBAAsB,CAACe,mBAAa,EAAEZ,EAAE,CAAC;AACxD,CAAC;AAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/api-file-manager",
3
- "version": "0.0.0-mt-3",
3
+ "version": "0.0.0-unstable.085ff6572f",
4
4
  "main": "index.js",
5
5
  "keywords": [
6
6
  "fm:base"
@@ -18,39 +18,39 @@
18
18
  ],
19
19
  "license": "MIT",
20
20
  "dependencies": {
21
- "@babel/runtime": "7.15.4",
21
+ "@babel/runtime": "7.20.13",
22
22
  "@commodo/fields": "1.1.2-beta.20",
23
- "@webiny/api-i18n-content": "0.0.0-mt-3",
24
- "@webiny/api-security": "0.0.0-mt-3",
25
- "@webiny/api-tenancy": "0.0.0-mt-3",
26
- "@webiny/api-upgrade": "0.0.0-mt-3",
27
- "@webiny/error": "0.0.0-mt-3",
28
- "@webiny/handler": "0.0.0-mt-3",
29
- "@webiny/handler-client": "0.0.0-mt-3",
30
- "@webiny/handler-graphql": "0.0.0-mt-3",
31
- "@webiny/plugins": "0.0.0-mt-3",
32
- "@webiny/project-utils": "0.0.0-mt-3",
33
- "@webiny/validation": "0.0.0-mt-3",
34
- "aws-sdk": "2.1026.0",
35
- "commodo-fields-object": "1.0.6",
36
- "mdbid": "1.0.0",
37
- "object-hash": "1.3.1",
38
- "sanitize-filename": "1.6.3"
23
+ "@webiny/api": "0.0.0-unstable.085ff6572f",
24
+ "@webiny/api-headless-cms": "0.0.0-unstable.085ff6572f",
25
+ "@webiny/api-security": "0.0.0-unstable.085ff6572f",
26
+ "@webiny/api-tenancy": "0.0.0-unstable.085ff6572f",
27
+ "@webiny/error": "0.0.0-unstable.085ff6572f",
28
+ "@webiny/handler": "0.0.0-unstable.085ff6572f",
29
+ "@webiny/handler-aws": "0.0.0-unstable.085ff6572f",
30
+ "@webiny/handler-client": "0.0.0-unstable.085ff6572f",
31
+ "@webiny/handler-graphql": "0.0.0-unstable.085ff6572f",
32
+ "@webiny/plugins": "0.0.0-unstable.085ff6572f",
33
+ "@webiny/project-utils": "0.0.0-unstable.085ff6572f",
34
+ "@webiny/pubsub": "0.0.0-unstable.085ff6572f",
35
+ "@webiny/validation": "0.0.0-unstable.085ff6572f",
36
+ "aws-sdk": "2.1310.0",
37
+ "lodash": "4.17.21",
38
+ "object-hash": "2.2.0"
39
39
  },
40
40
  "devDependencies": {
41
- "@babel/cli": "^7.5.5",
42
- "@babel/core": "^7.5.5",
43
- "@babel/plugin-proposal-object-rest-spread": "^7.5.5",
44
- "@babel/plugin-transform-runtime": "^7.5.5",
45
- "@babel/preset-env": "^7.5.5",
46
- "@babel/preset-typescript": "^7.0.0",
47
- "@webiny/api-i18n": "^0.0.0-mt-3",
48
- "@webiny/api-i18n-ddb": "^0.0.0-mt-3",
49
- "@webiny/cli": "^0.0.0-mt-3",
50
- "jest": "^26.6.3",
51
- "rimraf": "^3.0.2",
52
- "ttypescript": "^1.5.12",
53
- "typescript": "^4.1.3"
41
+ "@babel/cli": "7.20.7",
42
+ "@babel/core": "7.20.12",
43
+ "@babel/plugin-proposal-object-rest-spread": "7.20.7",
44
+ "@babel/plugin-transform-runtime": "7.19.6",
45
+ "@babel/preset-env": "7.20.2",
46
+ "@babel/preset-typescript": "7.18.6",
47
+ "@webiny/api-i18n": "0.0.0-unstable.085ff6572f",
48
+ "@webiny/cli": "0.0.0-unstable.085ff6572f",
49
+ "@webiny/utils": "0.0.0-unstable.085ff6572f",
50
+ "jest": "29.5.0",
51
+ "rimraf": "3.0.2",
52
+ "ttypescript": "1.5.15",
53
+ "typescript": "4.7.4"
54
54
  },
55
55
  "publishConfig": {
56
56
  "access": "public",
@@ -71,5 +71,5 @@
71
71
  ]
72
72
  }
73
73
  },
74
- "gitHead": "ebea815be2be99404591cba465cc1fe88355bd48"
74
+ "gitHead": "085ff6572f6bb6a76d218088b06d9f4ef92bbea7"
75
75
  }
@@ -0,0 +1,21 @@
1
+ /// <reference types="node" />
2
+ import { Plugin } from "@webiny/plugins";
3
+ import { FileManagerSettings } from "../types";
4
+ export interface FilePhysicalStoragePluginParams<U extends FilePhysicalStoragePluginUploadParams, D extends FilePhysicalStoragePluginDeleteParams> {
5
+ upload: (args: U) => Promise<any>;
6
+ delete: (args: D) => Promise<void>;
7
+ }
8
+ export interface FilePhysicalStoragePluginUploadParams {
9
+ settings: FileManagerSettings;
10
+ buffer: Buffer;
11
+ }
12
+ export interface FilePhysicalStoragePluginDeleteParams {
13
+ key: string;
14
+ }
15
+ export declare class FilePhysicalStoragePlugin<U extends FilePhysicalStoragePluginUploadParams = FilePhysicalStoragePluginUploadParams, D extends FilePhysicalStoragePluginDeleteParams = FilePhysicalStoragePluginDeleteParams> extends Plugin {
16
+ static readonly type: string;
17
+ private readonly _params;
18
+ constructor(params: FilePhysicalStoragePluginParams<U, D>);
19
+ upload(params: U): Promise<any>;
20
+ delete(params: D): Promise<any>;
21
+ }
@@ -1,42 +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.FilePhysicalStoragePlugin = void 0;
9
-
10
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
-
12
9
  var _plugins = require("@webiny/plugins");
13
-
14
10
  var _error = _interopRequireDefault(require("@webiny/error"));
15
-
16
11
  class FilePhysicalStoragePlugin extends _plugins.Plugin {
17
12
  constructor(params) {
18
13
  super();
19
14
  (0, _defineProperty2.default)(this, "_params", void 0);
20
15
  this._params = params;
21
16
  }
22
-
23
17
  async upload(params) {
24
18
  if (!this._params.upload) {
25
19
  throw new _error.default(`You must define the "upload" method of this plugin.`, "UPLOAD_METHOD_ERROR");
26
20
  }
27
-
28
21
  return this._params.upload(params);
29
22
  }
30
-
31
23
  async delete(params) {
32
24
  if (!this._params.delete) {
33
25
  throw new _error.default(`You must define the "delete" method of this plugin.`, "DELETE_METHOD_ERROR");
34
26
  }
35
-
36
27
  return this._params.delete(params);
37
28
  }
38
-
39
29
  }
40
-
41
30
  exports.FilePhysicalStoragePlugin = FilePhysicalStoragePlugin;
42
31
  (0, _defineProperty2.default)(FilePhysicalStoragePlugin, "type", "api-file-manager-storage");
@@ -0,0 +1 @@
1
+ {"version":3,"names":["FilePhysicalStoragePlugin","Plugin","constructor","params","_params","upload","WebinyError","delete"],"sources":["FilePhysicalStoragePlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport WebinyError from \"@webiny/error\";\nimport { FileManagerSettings } from \"~/types\";\n\nexport interface FilePhysicalStoragePluginParams<\n U extends FilePhysicalStoragePluginUploadParams,\n D extends FilePhysicalStoragePluginDeleteParams\n> {\n upload: (args: U) => Promise<any>;\n delete: (args: D) => Promise<void>;\n}\n\nexport interface FilePhysicalStoragePluginUploadParams {\n settings: FileManagerSettings;\n buffer: Buffer;\n}\n\nexport interface FilePhysicalStoragePluginDeleteParams {\n key: string;\n}\n\nexport class FilePhysicalStoragePlugin<\n U extends FilePhysicalStoragePluginUploadParams = FilePhysicalStoragePluginUploadParams,\n D extends FilePhysicalStoragePluginDeleteParams = FilePhysicalStoragePluginDeleteParams\n> extends Plugin {\n public static override readonly type: string = \"api-file-manager-storage\";\n private readonly _params: FilePhysicalStoragePluginParams<U, D>;\n\n public constructor(params: FilePhysicalStoragePluginParams<U, D>) {\n super();\n this._params = params;\n }\n\n public async upload(params: U): Promise<any> {\n if (!this._params.upload) {\n throw new WebinyError(\n `You must define the \"upload\" method of this plugin.`,\n \"UPLOAD_METHOD_ERROR\"\n );\n }\n return this._params.upload(params);\n }\n\n public async delete(params: D): Promise<any> {\n if (!this._params.delete) {\n throw new WebinyError(\n `You must define the \"delete\" method of this plugin.`,\n \"DELETE_METHOD_ERROR\"\n );\n }\n return this._params.delete(params);\n }\n}\n"],"mappings":";;;;;;;;AAAA;AACA;AAoBO,MAAMA,yBAAyB,SAG5BC,eAAM,CAAC;EAINC,WAAW,CAACC,MAA6C,EAAE;IAC9D,KAAK,EAAE;IAAC;IACR,IAAI,CAACC,OAAO,GAAGD,MAAM;EACzB;EAEA,MAAaE,MAAM,CAACF,MAAS,EAAgB;IACzC,IAAI,CAAC,IAAI,CAACC,OAAO,CAACC,MAAM,EAAE;MACtB,MAAM,IAAIC,cAAW,CAChB,qDAAoD,EACrD,qBAAqB,CACxB;IACL;IACA,OAAO,IAAI,CAACF,OAAO,CAACC,MAAM,CAACF,MAAM,CAAC;EACtC;EAEA,MAAaI,MAAM,CAACJ,MAAS,EAAgB;IACzC,IAAI,CAAC,IAAI,CAACC,OAAO,CAACG,MAAM,EAAE;MACtB,MAAM,IAAID,cAAW,CAChB,qDAAoD,EACrD,qBAAqB,CACxB;IACL;IACA,OAAO,IAAI,CAACF,OAAO,CAACG,MAAM,CAACJ,MAAM,CAAC;EACtC;AACJ;AAAC;AAAA,8BA/BYH,yBAAyB,UAIa,0BAA0B"}
@@ -1,34 +1,34 @@
1
1
  import { Plugin } from "@webiny/plugins";
2
- import { File } from "../../types";
3
- export interface ToParams {
2
+ import { File } from "../types";
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,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>)[];
2
- export default _default;
1
+ export * from "./FilePhysicalStoragePlugin";
2
+ export * from "./FileStorageTransformPlugin";
package/plugins/index.js CHANGED
@@ -1,24 +1,27 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
3
  Object.defineProperty(exports, "__esModule", {
6
4
  value: true
7
5
  });
8
- exports.default = void 0;
9
-
10
- var _graphql = _interopRequireDefault(require("./graphql"));
11
-
12
- var _files = _interopRequireDefault(require("./crud/files.crud"));
13
-
14
- var _validation = _interopRequireDefault(require("./crud/files/validation"));
15
-
16
- var _settings = _interopRequireDefault(require("./crud/settings.crud"));
17
-
18
- var _system = _interopRequireDefault(require("./crud/system.crud"));
19
-
20
- var _storage = _interopRequireDefault(require("./storage"));
21
-
22
- var _default = () => [_system.default, _settings.default, _files.default, _storage.default, _graphql.default, (0, _validation.default)()];
23
-
24
- exports.default = _default;
6
+ var _FilePhysicalStoragePlugin = require("./FilePhysicalStoragePlugin");
7
+ Object.keys(_FilePhysicalStoragePlugin).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _FilePhysicalStoragePlugin[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _FilePhysicalStoragePlugin[key];
14
+ }
15
+ });
16
+ });
17
+ var _FileStorageTransformPlugin = require("./FileStorageTransformPlugin");
18
+ Object.keys(_FileStorageTransformPlugin).forEach(function (key) {
19
+ if (key === "default" || key === "__esModule") return;
20
+ if (key in exports && exports[key] === _FileStorageTransformPlugin[key]) return;
21
+ Object.defineProperty(exports, key, {
22
+ enumerable: true,
23
+ get: function () {
24
+ return _FileStorageTransformPlugin[key];
25
+ }
26
+ });
27
+ });
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./FilePhysicalStoragePlugin\";\nexport * from \"./FileStorageTransformPlugin\";\n"],"mappings":";;;;;AAAA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
@@ -0,0 +1,32 @@
1
+ /// <reference types="node" />
2
+ import { FileManagerContext } from "../types";
3
+ export declare type Result = Record<string, any>;
4
+ export interface FileStorageUploadParams {
5
+ buffer: Buffer;
6
+ hideInFileManager: boolean | string;
7
+ size: number;
8
+ name: string;
9
+ type: string;
10
+ id?: string;
11
+ key?: string;
12
+ tags?: string[];
13
+ keyPrefix?: string;
14
+ }
15
+ export interface FileStorageDeleteParams {
16
+ id: string;
17
+ key: string;
18
+ }
19
+ export interface FileStorageUploadMultipleParams {
20
+ files: FileStorageUploadParams[];
21
+ }
22
+ export interface FileStorageParams {
23
+ context: FileManagerContext;
24
+ }
25
+ export declare class FileStorage {
26
+ private readonly storagePlugin;
27
+ private readonly context;
28
+ constructor({ context }: FileStorageParams);
29
+ upload(params: FileStorageUploadParams): Promise<Result>;
30
+ uploadFiles({ files }: FileStorageUploadMultipleParams): Promise<import("../types").File[]>;
31
+ delete(params: FileStorageDeleteParams): Promise<boolean>;
32
+ }
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.FileStorage = void 0;
8
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
9
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
+ var _error = _interopRequireDefault(require("@webiny/error"));
11
+ const storagePluginType = "api-file-manager-storage";
12
+ class FileStorage {
13
+ constructor({
14
+ context
15
+ }) {
16
+ (0, _defineProperty2.default)(this, "storagePlugin", void 0);
17
+ (0, _defineProperty2.default)(this, "context", void 0);
18
+ const storagePlugin = context.plugins.byType(storagePluginType).pop();
19
+ if (!storagePlugin) {
20
+ throw new _error.default(`Missing plugin of type "${storagePluginType}".`, "STORAGE_PLUGIN_ERROR");
21
+ }
22
+ this.storagePlugin = storagePlugin;
23
+ this.context = context;
24
+ }
25
+ async upload(params) {
26
+ const settings = await this.context.fileManager.getSettings();
27
+ if (!settings) {
28
+ throw new _error.default("Missing File Manager Settings.", "FILE_MANAGER_ERROR");
29
+ }
30
+
31
+ // Add file to cloud storage.
32
+ const {
33
+ file: fileData
34
+ } = await this.storagePlugin.upload((0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
35
+ settings
36
+ }));
37
+
38
+ // Save file in DB.
39
+ return this.context.fileManager.createFile((0, _objectSpread2.default)((0, _objectSpread2.default)({}, fileData), {}, {
40
+ meta: {
41
+ private: Boolean(params.hideInFileManager)
42
+ },
43
+ tags: Array.isArray(params.tags) ? params.tags : []
44
+ }));
45
+ }
46
+ async uploadFiles({
47
+ files
48
+ }) {
49
+ const settings = await this.context.fileManager.getSettings();
50
+ if (!settings) {
51
+ throw new _error.default("Missing File Manager Settings.", "FILE_MANAGER_ERROR");
52
+ }
53
+ const filesData = await Promise.all(files.map(async item => {
54
+ // TODO: improve types of this.storagePlugin.
55
+ const {
56
+ file
57
+ } = await this.storagePlugin.upload((0, _objectSpread2.default)((0, _objectSpread2.default)({}, item), {}, {
58
+ settings
59
+ }));
60
+ return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, file), {}, {
61
+ meta: {
62
+ private: Boolean(item.hideInFileManager)
63
+ },
64
+ tags: Array.isArray(item.tags) ? item.tags : []
65
+ });
66
+ }));
67
+ return this.context.fileManager.createFilesInBatch(filesData);
68
+ }
69
+ async delete(params) {
70
+ const {
71
+ id,
72
+ key
73
+ } = params;
74
+ const {
75
+ fileManager
76
+ } = this.context;
77
+ // Delete file from cloud storage.
78
+ await this.storagePlugin.delete({
79
+ key
80
+ });
81
+
82
+ // Delete file from the DB.
83
+ return await fileManager.deleteFile(id);
84
+ }
85
+ }
86
+ exports.FileStorage = FileStorage;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["storagePluginType","FileStorage","constructor","context","storagePlugin","plugins","byType","pop","WebinyError","upload","params","settings","fileManager","getSettings","file","fileData","createFile","meta","private","Boolean","hideInFileManager","tags","Array","isArray","uploadFiles","files","filesData","Promise","all","map","item","createFilesInBatch","delete","id","key","deleteFile"],"sources":["FileStorage.ts"],"sourcesContent":["import { FileManagerContext } from \"~/types\";\nimport WebinyError from \"@webiny/error\";\nimport { FilePhysicalStoragePlugin } from \"~/plugins/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 size: number;\n name: string;\n type: string;\n id?: string;\n key?: string;\n tags?: string[];\n keyPrefix?: 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\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.getSettings();\n if (!settings) {\n throw new WebinyError(\"Missing File Manager Settings.\", \"FILE_MANAGER_ERROR\");\n }\n\n // Add file to cloud storage.\n const { file: fileData } = await this.storagePlugin.upload({\n ...params,\n settings\n });\n\n // Save file in DB.\n return this.context.fileManager.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({ files }: FileStorageUploadMultipleParams) {\n const settings = await this.context.fileManager.getSettings();\n if (!settings) {\n throw new WebinyError(\"Missing File Manager Settings.\", \"FILE_MANAGER_ERROR\");\n }\n\n const filesData = await Promise.all(\n files.map(async item => {\n // TODO: improve types of this.storagePlugin.\n const { file } = await this.storagePlugin.upload({\n ...item,\n settings\n });\n\n return {\n ...file,\n meta: {\n private: Boolean(item.hideInFileManager)\n },\n tags: Array.isArray(item.tags) ? item.tags : []\n };\n })\n );\n\n return this.context.fileManager.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\n // Delete file from the DB.\n return await fileManager.deleteFile(id);\n }\n}\n"],"mappings":";;;;;;;;;AACA;AAKA,MAAMA,iBAAiB,GAAG,0BAA0B;AAyB7C,MAAMC,WAAW,CAAC;EAIrBC,WAAW,CAAC;IAAEC;EAA2B,CAAC,EAAE;IAAA;IAAA;IACxC,MAAMC,aAAa,GAAGD,OAAO,CAACE,OAAO,CAChCC,MAAM,CAA4BN,iBAAiB,CAAC,CACpDO,GAAG,EAAE;IAEV,IAAI,CAACH,aAAa,EAAE;MAChB,MAAM,IAAII,cAAW,CAChB,2BAA0BR,iBAAkB,IAAG,EAChD,sBAAsB,CACzB;IACL;IACA,IAAI,CAACI,aAAa,GAAGA,aAAa;IAClC,IAAI,CAACD,OAAO,GAAGA,OAAO;EAC1B;EAEA,MAAMM,MAAM,CAACC,MAA+B,EAAmB;IAC3D,MAAMC,QAAQ,GAAG,MAAM,IAAI,CAACR,OAAO,CAACS,WAAW,CAACC,WAAW,EAAE;IAC7D,IAAI,CAACF,QAAQ,EAAE;MACX,MAAM,IAAIH,cAAW,CAAC,gCAAgC,EAAE,oBAAoB,CAAC;IACjF;;IAEA;IACA,MAAM;MAAEM,IAAI,EAAEC;IAAS,CAAC,GAAG,MAAM,IAAI,CAACX,aAAa,CAACK,MAAM,6DACnDC,MAAM;MACTC;IAAQ,GACV;;IAEF;IACA,OAAO,IAAI,CAACR,OAAO,CAACS,WAAW,CAACI,UAAU,6DAClCD,QAAQ;MACZE,IAAI,EAAE;QACFC,OAAO,EAAEC,OAAO,CAACT,MAAM,CAACU,iBAAiB;MAC7C,CAAC;MACDC,IAAI,EAAEC,KAAK,CAACC,OAAO,CAACb,MAAM,CAACW,IAAI,CAAC,GAAGX,MAAM,CAACW,IAAI,GAAG;IAAE,GACrD;EACN;EAEA,MAAMG,WAAW,CAAC;IAAEC;EAAuC,CAAC,EAAE;IAC1D,MAAMd,QAAQ,GAAG,MAAM,IAAI,CAACR,OAAO,CAACS,WAAW,CAACC,WAAW,EAAE;IAC7D,IAAI,CAACF,QAAQ,EAAE;MACX,MAAM,IAAIH,cAAW,CAAC,gCAAgC,EAAE,oBAAoB,CAAC;IACjF;IAEA,MAAMkB,SAAS,GAAG,MAAMC,OAAO,CAACC,GAAG,CAC/BH,KAAK,CAACI,GAAG,CAAC,MAAMC,IAAI,IAAI;MACpB;MACA,MAAM;QAAEhB;MAAK,CAAC,GAAG,MAAM,IAAI,CAACV,aAAa,CAACK,MAAM,6DACzCqB,IAAI;QACPnB;MAAQ,GACV;MAEF,mEACOG,IAAI;QACPG,IAAI,EAAE;UACFC,OAAO,EAAEC,OAAO,CAACW,IAAI,CAACV,iBAAiB;QAC3C,CAAC;QACDC,IAAI,EAAEC,KAAK,CAACC,OAAO,CAACO,IAAI,CAACT,IAAI,CAAC,GAAGS,IAAI,CAACT,IAAI,GAAG;MAAE;IAEvD,CAAC,CAAC,CACL;IAED,OAAO,IAAI,CAAClB,OAAO,CAACS,WAAW,CAACmB,kBAAkB,CAACL,SAAS,CAAC;EACjE;EAEA,MAAMM,MAAM,CAACtB,MAA+B,EAAE;IAC1C,MAAM;MAAEuB,EAAE;MAAEC;IAAI,CAAC,GAAGxB,MAAM;IAC1B,MAAM;MAAEE;IAAY,CAAC,GAAG,IAAI,CAACT,OAAO;IACpC;IACA,MAAM,IAAI,CAACC,aAAa,CAAC4B,MAAM,CAAC;MAC5BE;IACJ,CAAC,CAAC;;IAEF;IACA,OAAO,MAAMtB,WAAW,CAACuB,UAAU,CAACF,EAAE,CAAC;EAC3C;AACJ;AAAC"}
@@ -0,0 +1,37 @@
1
+ export interface File {
2
+ id: string;
3
+ key: string;
4
+ size: number;
5
+ type: string;
6
+ name: string;
7
+ meta: Record<string, any>;
8
+ location: {
9
+ folderId: string;
10
+ };
11
+ tags: string[];
12
+ aliases: string[];
13
+ createdOn: string;
14
+ savedOn: string;
15
+ createdBy: CreatedBy;
16
+ /**
17
+ * Added with new storage operations refactoring.
18
+ */
19
+ tenant: string;
20
+ locale: string;
21
+ webinyVersion: string;
22
+ /**
23
+ * User can add new fields to the File object, so we must allow it in the types.
24
+ */
25
+ [key: string]: any;
26
+ }
27
+ export interface FileAlias {
28
+ tenant: string;
29
+ locale: string;
30
+ fileId: string;
31
+ alias: string;
32
+ }
33
+ export interface CreatedBy {
34
+ id: string;
35
+ displayName: string | null;
36
+ type: string;
37
+ }
package/types/file.js ADDED
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["file.ts"],"sourcesContent":["export interface File {\n id: string;\n key: string;\n size: number;\n type: string;\n name: string;\n meta: Record<string, any>;\n location: {\n folderId: string;\n };\n tags: string[];\n aliases: string[];\n createdOn: string;\n savedOn: string;\n createdBy: CreatedBy;\n /**\n * Added with new storage operations refactoring.\n */\n tenant: string;\n locale: string;\n webinyVersion: string;\n /**\n * User can add new fields to the File object, so we must allow it in the types.\n */\n [key: string]: any;\n}\n\nexport interface FileAlias {\n tenant: string;\n locale: string;\n fileId: string;\n alias: string;\n}\n\nexport interface CreatedBy {\n id: string;\n displayName: string | null;\n type: string;\n}\n"],"mappings":""}
@@ -0,0 +1,44 @@
1
+ import { Topic } from "@webiny/pubsub/types";
2
+ import { File } from "./file";
3
+ export interface OnFileBeforeCreateTopicParams<TFile extends File = File> {
4
+ file: TFile;
5
+ meta?: Record<string, any>;
6
+ }
7
+ export interface OnFileAfterCreateTopicParams<TFile extends File = File> {
8
+ file: TFile;
9
+ meta?: Record<string, any>;
10
+ }
11
+ export interface OnFileBeforeBatchCreateTopicParams<TFile extends File = File> {
12
+ files: TFile[];
13
+ meta?: Record<string, any>;
14
+ }
15
+ export interface OnFileAfterBatchCreateTopicParams<TFile extends File = File> {
16
+ files: TFile[];
17
+ meta?: Record<string, any>;
18
+ }
19
+ export interface OnFileBeforeUpdateTopicParams<TFile extends File = File> {
20
+ original: TFile;
21
+ file: TFile;
22
+ input: Record<string, any>;
23
+ }
24
+ export interface OnFileAfterUpdateTopicParams<TFile extends File = File> {
25
+ original: TFile;
26
+ file: TFile;
27
+ input: Record<string, any>;
28
+ }
29
+ export interface OnFileBeforeDeleteTopicParams<TFile extends File = File> {
30
+ file: TFile;
31
+ }
32
+ export interface OnFileAfterDeleteTopicParams<TFile extends File = File> {
33
+ file: TFile;
34
+ }
35
+ export interface FileLifecycleEvents {
36
+ onFileBeforeCreate: Topic<OnFileBeforeCreateTopicParams>;
37
+ onFileAfterCreate: Topic<OnFileAfterCreateTopicParams>;
38
+ onFileBeforeBatchCreate: Topic<OnFileBeforeBatchCreateTopicParams>;
39
+ onFileAfterBatchCreate: Topic<OnFileAfterBatchCreateTopicParams>;
40
+ onFileBeforeUpdate: Topic<OnFileBeforeUpdateTopicParams>;
41
+ onFileAfterUpdate: Topic<OnFileAfterUpdateTopicParams>;
42
+ onFileBeforeDelete: Topic<OnFileBeforeDeleteTopicParams>;
43
+ onFileAfterDelete: Topic<OnFileAfterDeleteTopicParams>;
44
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["file.lifecycle.ts"],"sourcesContent":["import { Topic } from \"@webiny/pubsub/types\";\nimport { File } from \"./file\";\n\nexport interface OnFileBeforeCreateTopicParams<TFile extends File = File> {\n file: TFile;\n meta?: Record<string, any>;\n}\n\nexport interface OnFileAfterCreateTopicParams<TFile extends File = File> {\n file: TFile;\n meta?: Record<string, any>;\n}\n\nexport interface OnFileBeforeBatchCreateTopicParams<TFile extends File = File> {\n files: TFile[];\n meta?: Record<string, any>;\n}\n\nexport interface OnFileAfterBatchCreateTopicParams<TFile extends File = File> {\n files: TFile[];\n meta?: Record<string, any>;\n}\n\nexport interface OnFileBeforeUpdateTopicParams<TFile extends File = File> {\n original: TFile;\n file: TFile;\n input: Record<string, any>;\n}\n\nexport interface OnFileAfterUpdateTopicParams<TFile extends File = File> {\n original: TFile;\n file: TFile;\n input: Record<string, any>;\n}\n\nexport interface OnFileBeforeDeleteTopicParams<TFile extends File = File> {\n file: TFile;\n}\n\nexport interface OnFileAfterDeleteTopicParams<TFile extends File = File> {\n file: TFile;\n}\n\nexport interface FileLifecycleEvents {\n onFileBeforeCreate: Topic<OnFileBeforeCreateTopicParams>;\n onFileAfterCreate: Topic<OnFileAfterCreateTopicParams>;\n onFileBeforeBatchCreate: Topic<OnFileBeforeBatchCreateTopicParams>;\n onFileAfterBatchCreate: Topic<OnFileAfterBatchCreateTopicParams>;\n onFileBeforeUpdate: Topic<OnFileBeforeUpdateTopicParams>;\n onFileAfterUpdate: Topic<OnFileAfterUpdateTopicParams>;\n onFileBeforeDelete: Topic<OnFileBeforeDeleteTopicParams>;\n onFileAfterDelete: Topic<OnFileAfterDeleteTopicParams>;\n}\n"],"mappings":""}