@webiny/api-file-manager 5.36.2 → 5.37.0-beta.1

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 (98) 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 +124 -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.js +39 -61
  29. package/createFileManager/files.crud.js.map +1 -1
  30. package/createFileManager/index.d.ts +4 -2
  31. package/createFileManager/index.js.map +1 -1
  32. package/createFileManager/permissions/FilesPermissions.d.ts +4 -0
  33. package/createFileManager/permissions/FilesPermissions.js +9 -0
  34. package/createFileManager/permissions/FilesPermissions.js.map +1 -0
  35. package/createFileManager/settings.crud.js.map +1 -1
  36. package/createFileManager/system.crud.js.map +1 -1
  37. package/graphql/baseSchema.d.ts +3 -0
  38. package/graphql/baseSchema.js +117 -0
  39. package/graphql/baseSchema.js.map +1 -0
  40. package/graphql/createFilesTypeDefs.d.ts +7 -0
  41. package/graphql/createFilesTypeDefs.js +162 -0
  42. package/graphql/createFilesTypeDefs.js.map +1 -0
  43. package/graphql/filesSchema.d.ts +4 -0
  44. package/graphql/filesSchema.js +83 -0
  45. package/graphql/filesSchema.js.map +1 -0
  46. package/graphql/index.d.ts +2 -2
  47. package/graphql/index.js +23 -278
  48. package/graphql/index.js.map +1 -1
  49. package/graphql/utils.d.ts +11 -0
  50. package/graphql/utils.js +22 -0
  51. package/graphql/utils.js.map +1 -0
  52. package/handlers/download/byAlias.js +9 -9
  53. package/handlers/download/byAlias.js.map +1 -1
  54. package/handlers/download/byExactKey.js +9 -9
  55. package/handlers/download/byExactKey.js.map +1 -1
  56. package/handlers/download/extractFileInformation.js.map +1 -1
  57. package/handlers/download/getS3Object.d.ts +2 -0
  58. package/handlers/download/getS3Object.js +39 -24
  59. package/handlers/download/getS3Object.js.map +1 -1
  60. package/handlers/download/index.js.map +1 -1
  61. package/handlers/manage/index.js.map +1 -1
  62. package/handlers/transform/index.js +5 -2
  63. package/handlers/transform/index.js.map +1 -1
  64. package/handlers/transform/legacyUtils.js.map +1 -1
  65. package/handlers/transform/loaders/imageLoader.js.map +1 -1
  66. package/handlers/transform/loaders/index.js.map +1 -1
  67. package/handlers/transform/loaders/sanitizeImageTransformations.js.map +1 -1
  68. package/handlers/transform/managers/imageManager.js.map +1 -1
  69. package/handlers/transform/managers/index.js.map +1 -1
  70. package/handlers/transform/optimizeImage.js.map +1 -1
  71. package/handlers/transform/transformImage.d.ts +5 -2
  72. package/handlers/transform/transformImage.js +7 -4
  73. package/handlers/transform/transformImage.js.map +1 -1
  74. package/handlers/transform/utils.js +2 -2
  75. package/handlers/transform/utils.js.map +1 -1
  76. package/handlers/utils/getEnvironment.js.map +1 -1
  77. package/handlers/utils/getObjectParams.js.map +1 -1
  78. package/handlers/utils/index.js.map +1 -1
  79. package/index.d.ts +3 -2
  80. package/index.js +20 -36
  81. package/index.js.map +1 -1
  82. package/modelModifier/CmsModelModifier.d.ts +24 -0
  83. package/modelModifier/CmsModelModifier.js +59 -0
  84. package/modelModifier/CmsModelModifier.js.map +1 -0
  85. package/package.json +26 -25
  86. package/plugins/FilePhysicalStoragePlugin.js.map +1 -1
  87. package/plugins/FileStorageTransformPlugin.js.map +1 -1
  88. package/plugins/index.js.map +1 -1
  89. package/storage/FileStorage.d.ts +2 -1
  90. package/storage/FileStorage.js +5 -4
  91. package/storage/FileStorage.js.map +1 -1
  92. package/types/file.d.ts +5 -1
  93. package/types/file.js.map +1 -1
  94. package/types.d.ts +16 -26
  95. package/types.js.map +1 -1
  96. package/createFileManager/checkBasePermissions.d.ts +0 -5
  97. package/createFileManager/checkBasePermissions.js +0 -24
  98. package/createFileManager/checkBasePermissions.js.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/api-file-manager",
3
- "version": "5.36.2",
3
+ "version": "5.37.0-beta.1",
4
4
  "main": "index.js",
5
5
  "keywords": [
6
6
  "fm:base"
@@ -18,35 +18,36 @@
18
18
  ],
19
19
  "license": "MIT",
20
20
  "dependencies": {
21
- "@babel/runtime": "7.20.13",
21
+ "@babel/runtime": "7.22.6",
22
22
  "@commodo/fields": "1.1.2-beta.20",
23
- "@webiny/api": "5.36.2",
24
- "@webiny/api-security": "5.36.2",
25
- "@webiny/api-tenancy": "5.36.2",
26
- "@webiny/error": "5.36.2",
27
- "@webiny/handler": "5.36.2",
28
- "@webiny/handler-aws": "5.36.2",
29
- "@webiny/handler-client": "5.36.2",
30
- "@webiny/handler-graphql": "5.36.2",
31
- "@webiny/plugins": "5.36.2",
32
- "@webiny/project-utils": "5.36.2",
33
- "@webiny/pubsub": "5.36.2",
34
- "@webiny/validation": "5.36.2",
23
+ "@webiny/api": "5.37.0-beta.1",
24
+ "@webiny/api-headless-cms": "5.37.0-beta.1",
25
+ "@webiny/api-security": "5.37.0-beta.1",
26
+ "@webiny/api-tenancy": "5.37.0-beta.1",
27
+ "@webiny/error": "5.37.0-beta.1",
28
+ "@webiny/handler": "5.37.0-beta.1",
29
+ "@webiny/handler-aws": "5.37.0-beta.1",
30
+ "@webiny/handler-client": "5.37.0-beta.1",
31
+ "@webiny/handler-graphql": "5.37.0-beta.1",
32
+ "@webiny/plugins": "5.37.0-beta.1",
33
+ "@webiny/project-utils": "5.37.0-beta.1",
34
+ "@webiny/pubsub": "5.37.0-beta.1",
35
+ "@webiny/validation": "5.37.0-beta.1",
35
36
  "aws-sdk": "2.1310.0",
37
+ "lodash": "4.17.21",
36
38
  "object-hash": "2.2.0"
37
39
  },
38
40
  "devDependencies": {
39
- "@babel/cli": "7.20.7",
40
- "@babel/core": "7.20.12",
41
+ "@babel/cli": "7.22.6",
42
+ "@babel/core": "7.22.8",
41
43
  "@babel/plugin-proposal-object-rest-spread": "7.20.7",
42
- "@babel/plugin-transform-runtime": "7.19.6",
43
- "@babel/preset-env": "7.20.2",
44
- "@babel/preset-typescript": "7.18.6",
45
- "@webiny/api-i18n": "5.36.2",
46
- "@webiny/api-i18n-ddb": "5.36.2",
47
- "@webiny/cli": "5.36.2",
48
- "@webiny/utils": "5.36.2",
49
- "jest": "28.1.3",
44
+ "@babel/plugin-transform-runtime": "7.22.7",
45
+ "@babel/preset-env": "7.22.7",
46
+ "@babel/preset-typescript": "7.22.5",
47
+ "@webiny/api-i18n": "5.37.0-beta.1",
48
+ "@webiny/cli": "5.37.0-beta.1",
49
+ "@webiny/utils": "5.37.0-beta.1",
50
+ "jest": "29.5.0",
50
51
  "rimraf": "3.0.2",
51
52
  "ttypescript": "1.5.15",
52
53
  "typescript": "4.7.4"
@@ -70,5 +71,5 @@
70
71
  ]
71
72
  }
72
73
  },
73
- "gitHead": "908c591cd08d81da267ed6152e880b52e1157c8b"
74
+ "gitHead": "176c29425477d1daaca1b7da79bacc79a1d35f6e"
74
75
  }
@@ -1 +1 @@
1
- {"version":3,"names":["FilePhysicalStoragePlugin","Plugin","constructor","params","_params","upload","WebinyError","delete"],"sources":["FilePhysicalStoragePlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport WebinyError from \"@webiny/error\";\nimport { FileManagerSettings } from \"~/types\";\n\nexport interface FilePhysicalStoragePluginParams<\n U extends FilePhysicalStoragePluginUploadParams,\n D extends FilePhysicalStoragePluginDeleteParams\n> {\n upload: (args: U) => Promise<any>;\n delete: (args: D) => Promise<void>;\n}\n\nexport interface FilePhysicalStoragePluginUploadParams {\n settings: FileManagerSettings;\n buffer: Buffer;\n}\n\nexport interface FilePhysicalStoragePluginDeleteParams {\n key: string;\n}\n\nexport class FilePhysicalStoragePlugin<\n U extends FilePhysicalStoragePluginUploadParams = FilePhysicalStoragePluginUploadParams,\n D extends FilePhysicalStoragePluginDeleteParams = FilePhysicalStoragePluginDeleteParams\n> extends Plugin {\n public static override readonly type: string = \"api-file-manager-storage\";\n private readonly _params: FilePhysicalStoragePluginParams<U, D>;\n\n public constructor(params: FilePhysicalStoragePluginParams<U, D>) {\n super();\n this._params = params;\n }\n\n public async upload(params: U): Promise<any> {\n if (!this._params.upload) {\n throw new WebinyError(\n `You must define the \"upload\" method of this plugin.`,\n \"UPLOAD_METHOD_ERROR\"\n );\n }\n return this._params.upload(params);\n }\n\n public async delete(params: D): Promise<any> {\n if (!this._params.delete) {\n throw new WebinyError(\n `You must define the \"delete\" method of this plugin.`,\n \"DELETE_METHOD_ERROR\"\n );\n }\n return this._params.delete(params);\n }\n}\n"],"mappings":";;;;;;;;AAAA;AACA;AAoBO,MAAMA,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
+ {"version":3,"names":["_plugins","require","_error","_interopRequireDefault","FilePhysicalStoragePlugin","Plugin","constructor","params","_defineProperty2","default","_params","upload","WebinyError","delete","exports"],"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,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AAoBO,MAAMG,yBAAyB,SAG5BC,eAAM,CAAC;EAINC,WAAWA,CAACC,MAA6C,EAAE;IAC9D,KAAK,CAAC,CAAC;IAAC,IAAAC,gBAAA,CAAAC,OAAA;IACR,IAAI,CAACC,OAAO,GAAGH,MAAM;EACzB;EAEA,MAAaI,MAAMA,CAACJ,MAAS,EAAgB;IACzC,IAAI,CAAC,IAAI,CAACG,OAAO,CAACC,MAAM,EAAE;MACtB,MAAM,IAAIC,cAAW,CAChB,qDAAoD,EACrD,qBACJ,CAAC;IACL;IACA,OAAO,IAAI,CAACF,OAAO,CAACC,MAAM,CAACJ,MAAM,CAAC;EACtC;EAEA,MAAaM,MAAMA,CAACN,MAAS,EAAgB;IACzC,IAAI,CAAC,IAAI,CAACG,OAAO,CAACG,MAAM,EAAE;MACtB,MAAM,IAAID,cAAW,CAChB,qDAAoD,EACrD,qBACJ,CAAC;IACL;IACA,OAAO,IAAI,CAACF,OAAO,CAACG,MAAM,CAACN,MAAM,CAAC;EACtC;AACJ;AAACO,OAAA,CAAAV,yBAAA,GAAAA,yBAAA;AAAA,IAAAI,gBAAA,CAAAC,OAAA,EA/BYL,yBAAyB,UAIa,0BAA0B"}
@@ -1 +1 @@
1
- {"version":3,"names":["FileStorageTransformPlugin","Plugin","constructor","params","_params","toStorage","file","fromStorage"],"sources":["FileStorageTransformPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport { File } from \"~/types\";\n\nexport interface FileStorageTransformPluginToParams {\n /**\n * File that is being sent to the storage operations method.\n */\n file: File & Record<string, any>;\n}\n\nexport interface FileStorageTransformPluginFromParams {\n /**\n * File that was fetched from the storage operations method.\n */\n file: File & Record<string, any>;\n}\n\nexport interface FileStorageTransformPluginParams {\n toStorage?: (params: FileStorageTransformPluginToParams) => Promise<File & Record<string, any>>;\n fromStorage?: (\n params: FileStorageTransformPluginFromParams\n ) => Promise<File & Record<string, any>>;\n}\n\nexport class FileStorageTransformPlugin extends Plugin {\n public static override readonly type: string = \"fm.files.storage.transform\";\n private readonly _params: FileStorageTransformPluginParams;\n\n public constructor(params: FileStorageTransformPluginParams) {\n super();\n\n this._params = params;\n }\n\n /**\n * Transform the file value into something that can be stored.\n * Be aware that you must return the whole file object.\n */\n public async toStorage(\n params: FileStorageTransformPluginToParams\n ): Promise<File & Record<string, any>> {\n if (!this._params.toStorage) {\n return params.file;\n }\n return this._params.toStorage(params);\n }\n /**\n * Transform the file value from the storage type to one required by our system.\n * Be aware that you must return the whole file object.\n * This method MUST reverse what ever toStorage method changed on the file object.\n */\n public async fromStorage(\n params: FileStorageTransformPluginFromParams\n ): Promise<File & Record<string, any>> {\n if (!this._params.fromStorage) {\n return params.file;\n }\n return this._params.fromStorage(params);\n }\n}\n"],"mappings":";;;;;;;;AAAA;AAwBO,MAAMA,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
+ {"version":3,"names":["_plugins","require","FileStorageTransformPlugin","Plugin","constructor","params","_defineProperty2","default","_params","toStorage","file","fromStorage","exports"],"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,IAAAA,QAAA,GAAAC,OAAA;AAwBO,MAAMC,0BAA0B,SAASC,eAAM,CAAC;EAI5CC,WAAWA,CAACC,MAAwC,EAAE;IACzD,KAAK,CAAC,CAAC;IAAC,IAAAC,gBAAA,CAAAC,OAAA;IAER,IAAI,CAACC,OAAO,GAAGH,MAAM;EACzB;;EAEA;AACJ;AACA;AACA;EACI,MAAaI,SAASA,CAClBJ,MAA0C,EACP;IACnC,IAAI,CAAC,IAAI,CAACG,OAAO,CAACC,SAAS,EAAE;MACzB,OAAOJ,MAAM,CAACK,IAAI;IACtB;IACA,OAAO,IAAI,CAACF,OAAO,CAACC,SAAS,CAACJ,MAAM,CAAC;EACzC;EACA;AACJ;AACA;AACA;AACA;EACI,MAAaM,WAAWA,CACpBN,MAA4C,EACT;IACnC,IAAI,CAAC,IAAI,CAACG,OAAO,CAACG,WAAW,EAAE;MAC3B,OAAON,MAAM,CAACK,IAAI;IACtB;IACA,OAAO,IAAI,CAACF,OAAO,CAACG,WAAW,CAACN,MAAM,CAAC;EAC3C;AACJ;AAACO,OAAA,CAAAV,0BAAA,GAAAA,0BAAA;AAAA,IAAAI,gBAAA,CAAAC,OAAA,EAnCYL,0BAA0B,UACY,4BAA4B"}
@@ -1 +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"}
1
+ {"version":3,"names":["_FilePhysicalStoragePlugin","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_FileStorageTransformPlugin"],"sources":["index.ts"],"sourcesContent":["export * from \"./FilePhysicalStoragePlugin\";\nexport * from \"./FileStorageTransformPlugin\";\n"],"mappings":";;;;;AAAA,IAAAA,0BAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,0BAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,0BAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,0BAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,2BAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,2BAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,2BAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,2BAAA,CAAAL,GAAA;IAAA;EAAA;AAAA"}
@@ -1,5 +1,6 @@
1
1
  /// <reference types="node" />
2
2
  import { FileManagerContext } from "../types";
3
+ import { FilePhysicalStoragePlugin } from "../plugins/FilePhysicalStoragePlugin";
3
4
  export declare type Result = Record<string, any>;
4
5
  export interface FileStorageUploadParams {
5
6
  buffer: Buffer;
@@ -23,9 +24,9 @@ export interface FileStorageParams {
23
24
  context: FileManagerContext;
24
25
  }
25
26
  export declare class FileStorage {
26
- private readonly storagePlugin;
27
27
  private readonly context;
28
28
  constructor({ context }: FileStorageParams);
29
+ get storagePlugin(): FilePhysicalStoragePlugin<import("../plugins/FilePhysicalStoragePlugin").FilePhysicalStoragePluginUploadParams, import("../plugins/FilePhysicalStoragePlugin").FilePhysicalStoragePluginDeleteParams>;
29
30
  upload(params: FileStorageUploadParams): Promise<Result>;
30
31
  uploadFiles({ files }: FileStorageUploadMultipleParams): Promise<import("../types").File[]>;
31
32
  delete(params: FileStorageDeleteParams): Promise<boolean>;
@@ -13,14 +13,15 @@ class FileStorage {
13
13
  constructor({
14
14
  context
15
15
  }) {
16
- (0, _defineProperty2.default)(this, "storagePlugin", void 0);
17
16
  (0, _defineProperty2.default)(this, "context", void 0);
18
- const storagePlugin = context.plugins.byType(storagePluginType).pop();
17
+ this.context = context;
18
+ }
19
+ get storagePlugin() {
20
+ const storagePlugin = this.context.plugins.byType(storagePluginType).pop();
19
21
  if (!storagePlugin) {
20
22
  throw new _error.default(`Missing plugin of type "${storagePluginType}".`, "STORAGE_PLUGIN_ERROR");
21
23
  }
22
- this.storagePlugin = storagePlugin;
23
- this.context = context;
24
+ return storagePlugin;
24
25
  }
25
26
  async upload(params) {
26
27
  const settings = await this.context.fileManager.getSettings();
@@ -1 +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"}
1
+ {"version":3,"names":["_error","_interopRequireDefault","require","storagePluginType","FileStorage","constructor","context","_defineProperty2","default","storagePlugin","plugins","byType","pop","WebinyError","upload","params","settings","fileManager","getSettings","file","fileData","_objectSpread2","createFile","meta","private","Boolean","hideInFileManager","tags","Array","isArray","uploadFiles","files","filesData","Promise","all","map","item","createFilesInBatch","delete","id","key","deleteFile","exports"],"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 context: FileManagerContext;\n\n constructor({ context }: FileStorageParams) {\n this.context = context;\n }\n\n get storagePlugin() {\n const storagePlugin = this.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\n return storagePlugin;\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,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,MAAMC,iBAAiB,GAAG,0BAA0B;AAyB7C,MAAMC,WAAW,CAAC;EAGrBC,WAAWA,CAAC;IAAEC;EAA2B,CAAC,EAAE;IAAA,IAAAC,gBAAA,CAAAC,OAAA;IACxC,IAAI,CAACF,OAAO,GAAGA,OAAO;EAC1B;EAEA,IAAIG,aAAaA,CAAA,EAAG;IAChB,MAAMA,aAAa,GAAG,IAAI,CAACH,OAAO,CAACI,OAAO,CACrCC,MAAM,CAA4BR,iBAAiB,CAAC,CACpDS,GAAG,CAAC,CAAC;IAEV,IAAI,CAACH,aAAa,EAAE;MAChB,MAAM,IAAII,cAAW,CAChB,2BAA0BV,iBAAkB,IAAG,EAChD,sBACJ,CAAC;IACL;IAEA,OAAOM,aAAa;EACxB;EAEA,MAAMK,MAAMA,CAACC,MAA+B,EAAmB;IAC3D,MAAMC,QAAQ,GAAG,MAAM,IAAI,CAACV,OAAO,CAACW,WAAW,CAACC,WAAW,CAAC,CAAC;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,KAAAO,cAAA,CAAAb,OAAA,MAAAa,cAAA,CAAAb,OAAA,MACnDO,MAAM;MACTC;IAAQ,EACX,CAAC;;IAEF;IACA,OAAO,IAAI,CAACV,OAAO,CAACW,WAAW,CAACK,UAAU,KAAAD,cAAA,CAAAb,OAAA,MAAAa,cAAA,CAAAb,OAAA,MAClCY,QAAQ;MACZG,IAAI,EAAE;QACFC,OAAO,EAAEC,OAAO,CAACV,MAAM,CAACW,iBAAiB;MAC7C,CAAC;MACDC,IAAI,EAAEC,KAAK,CAACC,OAAO,CAACd,MAAM,CAACY,IAAI,CAAC,GAAGZ,MAAM,CAACY,IAAI,GAAG;IAAE,EACtD,CAAC;EACN;EAEA,MAAMG,WAAWA,CAAC;IAAEC;EAAuC,CAAC,EAAE;IAC1D,MAAMf,QAAQ,GAAG,MAAM,IAAI,CAACV,OAAO,CAACW,WAAW,CAACC,WAAW,CAAC,CAAC;IAC7D,IAAI,CAACF,QAAQ,EAAE;MACX,MAAM,IAAIH,cAAW,CAAC,gCAAgC,EAAE,oBAAoB,CAAC;IACjF;IAEA,MAAMmB,SAAS,GAAG,MAAMC,OAAO,CAACC,GAAG,CAC/BH,KAAK,CAACI,GAAG,CAAC,MAAMC,IAAI,IAAI;MACpB;MACA,MAAM;QAAEjB;MAAK,CAAC,GAAG,MAAM,IAAI,CAACV,aAAa,CAACK,MAAM,KAAAO,cAAA,CAAAb,OAAA,MAAAa,cAAA,CAAAb,OAAA,MACzC4B,IAAI;QACPpB;MAAQ,EACX,CAAC;MAEF,WAAAK,cAAA,CAAAb,OAAA,MAAAa,cAAA,CAAAb,OAAA,MACOW,IAAI;QACPI,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,CACL,CAAC;IAED,OAAO,IAAI,CAACrB,OAAO,CAACW,WAAW,CAACoB,kBAAkB,CAACL,SAAS,CAAC;EACjE;EAEA,MAAMM,MAAMA,CAACvB,MAA+B,EAAE;IAC1C,MAAM;MAAEwB,EAAE;MAAEC;IAAI,CAAC,GAAGzB,MAAM;IAC1B,MAAM;MAAEE;IAAY,CAAC,GAAG,IAAI,CAACX,OAAO;IACpC;IACA,MAAM,IAAI,CAACG,aAAa,CAAC6B,MAAM,CAAC;MAC5BE;IACJ,CAAC,CAAC;;IAEF;IACA,OAAO,MAAMvB,WAAW,CAACwB,UAAU,CAACF,EAAE,CAAC;EAC3C;AACJ;AAACG,OAAA,CAAAtC,WAAA,GAAAA,WAAA"}
package/types/file.d.ts CHANGED
@@ -5,9 +5,13 @@ export interface File {
5
5
  type: string;
6
6
  name: string;
7
7
  meta: Record<string, any>;
8
+ location: {
9
+ folderId: string;
10
+ };
8
11
  tags: string[];
9
12
  aliases: string[];
10
13
  createdOn: string;
14
+ savedOn: string;
11
15
  createdBy: CreatedBy;
12
16
  /**
13
17
  * Added with new storage operations refactoring.
@@ -16,7 +20,7 @@ export interface File {
16
20
  locale: string;
17
21
  webinyVersion: string;
18
22
  /**
19
- * User can add new fields to the File object so we must allow it in the types.
23
+ * User can add new fields to the File object, so we must allow it in the types.
20
24
  */
21
25
  [key: string]: any;
22
26
  }
package/types/file.js.map CHANGED
@@ -1 +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 tags: string[];\n aliases: string[];\n createdOn: 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":""}
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":""}
package/types.d.ts CHANGED
@@ -6,12 +6,13 @@ import { Context } from "@webiny/api/types";
6
6
  import { FileLifecycleEvents } from "./types/file.lifecycle";
7
7
  import { File } from "./types/file";
8
8
  import { Topic } from "@webiny/pubsub/types";
9
+ import { CmsContext } from "@webiny/api-headless-cms/types";
9
10
  export * from "./types/file.lifecycle";
10
11
  export * from "./types/file";
11
12
  export interface FileManagerContextObject extends FilesCRUD, SettingsCRUD, SystemCRUD {
12
13
  storage: FileStorage;
13
14
  }
14
- export interface FileManagerContext extends Context, SecurityContext, TenancyContext, I18NContext {
15
+ export interface FileManagerContext extends Context, SecurityContext, TenancyContext, I18NContext, CmsContext {
15
16
  fileManager: FileManagerContextObject;
16
17
  }
17
18
  export interface FilePermission extends SecurityPermission {
@@ -26,24 +27,20 @@ export interface FileInput {
26
27
  size: number;
27
28
  type: string;
28
29
  meta: Record<string, any>;
30
+ location?: {
31
+ folderId: string;
32
+ };
29
33
  tags: string[];
30
34
  aliases: string[];
35
+ extensions?: Record<string, any>;
31
36
  }
32
37
  export interface FileListWhereParams {
33
- search?: string;
34
- type?: string;
35
- type_in?: string[];
36
- tag?: string;
37
- tag_in?: string[];
38
- tag_and_in?: string[];
39
- id_in?: string[];
40
- id?: string;
38
+ AND?: FileListWhereParams[];
39
+ OR?: FileListWhereParams[];
40
+ [key: string]: any;
41
41
  }
42
42
  export interface FilesListOpts {
43
43
  search?: string;
44
- types?: string[];
45
- tags?: string[];
46
- ids?: string[];
47
44
  limit?: number;
48
45
  after?: string;
49
46
  where?: FileListWhereParams;
@@ -260,20 +257,7 @@ export interface FileManagerFilesStorageOperationsCreateBatchParams {
260
257
  * @category FilesStorageOperationsParams
261
258
  */
262
259
  export interface FileManagerFilesStorageOperationsListParamsWhere {
263
- id?: string;
264
- id_in?: string[];
265
- name?: string;
266
- name_contains?: string;
267
- tag?: string;
268
- tag_contains?: string;
269
- tag_in?: string[];
270
- createdBy?: string;
271
- locale: string;
272
- tenant: string;
273
- private?: boolean;
274
- type?: string;
275
- type_in?: string[];
276
- search?: string;
260
+ [key: string]: any;
277
261
  }
278
262
  /**
279
263
  * @category StorageOperations
@@ -285,6 +269,7 @@ export interface FileManagerFilesStorageOperationsListParams {
285
269
  sort: string[];
286
270
  limit: number;
287
271
  after: string | null;
272
+ search?: string;
288
273
  }
289
274
  /**
290
275
  * @category StorageOperations
@@ -352,9 +337,14 @@ export interface FileManagerFilesStorageOperations {
352
337
  */
353
338
  tags: (params: FileManagerFilesStorageOperationsTagsParams) => Promise<FileManagerFilesStorageOperationsTagsResponse[]>;
354
339
  }
340
+ export interface FileManagerAliasesStorageOperations {
341
+ storeAliases(file: File): Promise<void>;
342
+ deleteAliases(file: File): Promise<void>;
343
+ }
355
344
  export interface FileManagerStorageOperations<TContext = FileManagerContext> {
356
345
  beforeInit?: (context: TContext) => Promise<void>;
357
346
  files: FileManagerFilesStorageOperations;
347
+ aliases: FileManagerAliasesStorageOperations;
358
348
  settings: FileManagerSettingsStorageOperations;
359
349
  system: FileManagerSystemStorageOperations;
360
350
  }
package/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import { I18NContext } from \"@webiny/api-i18n/types\";\nimport { FileStorage } from \"./storage/FileStorage\";\nimport { TenancyContext } from \"@webiny/api-tenancy/types\";\nimport { SecurityContext, SecurityPermission } from \"@webiny/api-security/types\";\nimport { Context } from \"@webiny/api/types\";\nimport { FileLifecycleEvents } from \"./types/file.lifecycle\";\nimport { File } from \"./types/file\";\nimport { Topic } from \"@webiny/pubsub/types\";\nexport * from \"./types/file.lifecycle\";\nexport * from \"./types/file\";\n\nexport interface FileManagerContextObject extends FilesCRUD, SettingsCRUD, SystemCRUD {\n storage: FileStorage;\n}\n\nexport interface FileManagerContext extends Context, SecurityContext, TenancyContext, I18NContext {\n fileManager: FileManagerContextObject;\n}\n\nexport interface FilePermission extends SecurityPermission {\n name: \"fm.file\";\n rwd?: string;\n own?: boolean;\n}\n\nexport interface FileInput {\n id: string;\n key: string;\n name: string;\n size: number;\n type: string;\n meta: Record<string, any>;\n tags: string[];\n aliases: string[];\n}\n\nexport interface FileListWhereParams {\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?: string[];\n id?: string;\n}\nexport interface FilesListOpts {\n search?: string;\n types?: string[];\n tags?: string[];\n ids?: string[];\n limit?: number;\n after?: string;\n where?: FileListWhereParams;\n sort?: string[];\n}\n\nexport interface FileListMeta {\n cursor: string | null;\n totalCount: number;\n hasMoreItems: boolean;\n}\n\ninterface FilesCrudListTagsWhere {\n tag?: string;\n tag_contains?: string;\n tag_in?: string[];\n tag_not_startsWith?: string;\n tag_startsWith?: string;\n}\ninterface FilesCrudListTagsParams {\n where?: FilesCrudListTagsWhere;\n limit?: number;\n after?: string;\n}\n\nexport interface ListTagsResponse {\n tag: string;\n count: number;\n}\nexport interface FilesCRUD extends FileLifecycleEvents {\n getFile(id: string): Promise<File>;\n listFiles(opts?: FilesListOpts): Promise<[File[], FileListMeta]>;\n listTags(params: FilesCrudListTagsParams): Promise<ListTagsResponse[]>;\n createFile(data: FileInput, meta?: Record<string, any>): Promise<File>;\n updateFile(id: string, data: Partial<FileInput>): Promise<File>;\n deleteFile(id: string): Promise<boolean>;\n createFilesInBatch(data: FileInput[], meta?: Record<string, any>): Promise<File[]>;\n}\n\nexport interface SystemCRUD {\n onSystemBeforeInstall: Topic;\n onSystemAfterInstall: Topic;\n getVersion(): Promise<string | null>;\n setVersion(version: string): Promise<void>;\n install(args: { srcPrefix: string }): Promise<boolean>;\n}\n\nexport interface FileManagerSettings {\n tenant: string;\n key: string;\n uploadMinFileSize: number;\n uploadMaxFileSize: number;\n srcPrefix: string;\n}\n\nexport interface FileManagerSystem {\n version: string;\n tenant: string;\n}\n\nexport type SettingsCRUD = {\n getSettings(): Promise<FileManagerSettings | null>;\n createSettings(data?: Partial<FileManagerSettings>): Promise<FileManagerSettings>;\n updateSettings(data: Partial<FileManagerSettings>): Promise<FileManagerSettings>;\n deleteSettings(): Promise<boolean>;\n};\n/********\n * Storage operations\n *******/\n\n/**\n * @category StorageOperations\n * @category SystemStorageOperations\n * @category SystemStorageOperationsParams\n */\nexport interface FileManagerSystemStorageOperationsUpdateParams {\n /**\n * The system data to be updated.\n */\n original: FileManagerSystem;\n /**\n * The system data with the updated fields.\n */\n data: FileManagerSystem;\n}\n/**\n * @category StorageOperations\n * @category SystemStorageOperations\n * @category SystemStorageOperationsParams\n */\nexport interface FileManagerSystemStorageOperationsCreateParams {\n /**\n * The system fields.\n */\n data: FileManagerSystem;\n}\n\nexport interface FileManagerSystemStorageOperationsGetParams {\n tenant: string;\n}\n\n/**\n * @category StorageOperations\n * @category SystemStorageOperations\n */\nexport interface FileManagerSystemStorageOperations {\n /**\n * Get the FileManager system data.\n */\n get: (params: FileManagerSystemStorageOperationsGetParams) => Promise<FileManagerSystem | null>;\n /**\n * Update the FileManager system data..\n */\n update: (params: FileManagerSystemStorageOperationsUpdateParams) => Promise<FileManagerSystem>;\n /**\n * Create the FileManagerSystemData\n */\n create: (params: FileManagerSystemStorageOperationsCreateParams) => Promise<FileManagerSystem>;\n}\n\n/**\n * @category StorageOperations\n * @category SettingsStorageOperations\n * @category SettingsStorageOperationsParams\n */\nexport interface FileManagerSettingsStorageOperationsUpdateParams {\n /**\n * Original settings to be updated.\n */\n original: FileManagerSettings;\n /**\n * The settings with the updated fields.\n */\n data: FileManagerSettings;\n}\n/**\n * @category StorageOperations\n * @category SettingsStorageOperations\n * @category SettingsStorageOperationsParams\n */\nexport interface FileManagerSettingsStorageOperationsCreateParams {\n /**\n * The settings fields.\n */\n data: FileManagerSettings;\n}\n\nexport interface FileManagerStorageOperationsGetSettingsParams {\n tenant: string;\n}\n\nexport interface FileManagerStorageOperationsDeleteSettings {\n tenant: string;\n}\n\n/**\n * @category StorageOperations\n * @category SettingsStorageOperations\n */\nexport interface FileManagerSettingsStorageOperations {\n /**\n * Get the FileManager system data.\n */\n get: (\n params: FileManagerStorageOperationsGetSettingsParams\n ) => Promise<FileManagerSettings | null>;\n /**\n * Create the FileManagerSettingsData\n */\n create: (\n params: FileManagerSettingsStorageOperationsCreateParams\n ) => Promise<FileManagerSettings>;\n /**\n * Update the FileManager system data..\n */\n update: (\n params: FileManagerSettingsStorageOperationsUpdateParams\n ) => Promise<FileManagerSettings>;\n /**\n * Delete the existing settings.\n */\n delete: (params: FileManagerStorageOperationsDeleteSettings) => Promise<void>;\n}\n\n/**\n * @category StorageOperations\n * @category FilesStorageOperations\n * @category FilesStorageOperationsParams\n */\nexport interface FileManagerFilesStorageOperationsGetParams {\n where: {\n id: string;\n tenant: string;\n locale: string;\n };\n}\n/**\n * @category StorageOperations\n * @category FilesStorageOperations\n * @category FilesStorageOperationsParams\n */\nexport interface FileManagerFilesStorageOperationsCreateParams {\n file: File;\n}\n/**\n * @category StorageOperations\n * @category FilesStorageOperations\n * @category FilesStorageOperationsParams\n */\nexport interface FileManagerFilesStorageOperationsUpdateParams {\n original: File;\n file: File;\n}\n\n/**\n * @category StorageOperations\n * @category FilesStorageOperations\n * @category FilesStorageOperationsParams\n */\nexport interface FileManagerFilesStorageOperationsDeleteParams {\n file: File;\n}\n/**\n * @category StorageOperations\n * @category FilesStorageOperations\n * @category FilesStorageOperationsParams\n */\nexport interface FileManagerFilesStorageOperationsCreateBatchParams {\n files: File[];\n}\n/**\n * @category StorageOperations\n * @category FilesStorageOperations\n * @category FilesStorageOperationsParams\n */\nexport interface FileManagerFilesStorageOperationsListParamsWhere {\n id?: string;\n id_in?: string[];\n name?: string;\n name_contains?: string;\n tag?: string;\n tag_contains?: string;\n tag_in?: string[];\n createdBy?: string;\n locale: string;\n tenant: string;\n private?: boolean;\n type?: string;\n type_in?: string[];\n search?: string;\n}\n/**\n * @category StorageOperations\n * @category FilesStorageOperations\n * @category FilesStorageOperationsParams\n */\nexport interface FileManagerFilesStorageOperationsListParams {\n where: FileManagerFilesStorageOperationsListParamsWhere;\n sort: string[];\n limit: number;\n after: string | null;\n}\n\n/**\n * @category StorageOperations\n * @category FilesStorageOperations\n * @category FilesStorageOperationsParams\n */\nexport interface FileManagerFilesStorageOperationsListResponseMeta {\n hasMoreItems: boolean;\n totalCount: number;\n cursor: string | null;\n}\nexport type FileManagerFilesStorageOperationsListResponse = [\n File[],\n FileManagerFilesStorageOperationsListResponseMeta\n];\n\nexport interface FileManagerFilesStorageOperationsTagsResponse {\n tag: string;\n count: number;\n}\n\nexport interface FileManagerFilesStorageOperationsTagsParamsWhere extends FilesCrudListTagsWhere {\n locale: string;\n tenant: string;\n}\n/**\n * @category StorageOperations\n * @category FilesStorageOperations\n * @category FilesStorageOperationsParams\n */\nexport interface FileManagerFilesStorageOperationsTagsParams {\n where: FileManagerFilesStorageOperationsTagsParamsWhere;\n limit: number;\n after?: string;\n}\n/**\n * @category StorageOperations\n * @category FilesStorageOperations\n */\nexport interface FileManagerFilesStorageOperations {\n /**\n * Get a single file with given ID from the storage.\n */\n get: (params: FileManagerFilesStorageOperationsGetParams) => Promise<File | null>;\n /**\n * Insert the file data into the database.\n */\n create: (params: FileManagerFilesStorageOperationsCreateParams) => Promise<File>;\n /**\n * Update the file data in the database.\n */\n update: (params: FileManagerFilesStorageOperationsUpdateParams) => Promise<File>;\n /**\n * Delete the file from the database.\n */\n delete: (params: FileManagerFilesStorageOperationsDeleteParams) => Promise<void>;\n /**\n * Store multiple files at once to the database.\n */\n createBatch: (params: FileManagerFilesStorageOperationsCreateBatchParams) => Promise<File[]>;\n /**\n * Get a list of files filtered by given parameters.\n */\n list: (\n params: FileManagerFilesStorageOperationsListParams\n ) => Promise<FileManagerFilesStorageOperationsListResponse>;\n /**\n * Get a list of all file tags filtered by given parameters.\n */\n tags: (\n params: FileManagerFilesStorageOperationsTagsParams\n ) => Promise<FileManagerFilesStorageOperationsTagsResponse[]>;\n}\n\nexport interface FileManagerStorageOperations<TContext = FileManagerContext> {\n beforeInit?: (context: TContext) => Promise<void>;\n files: FileManagerFilesStorageOperations;\n settings: FileManagerSettingsStorageOperations;\n system: FileManagerSystemStorageOperations;\n}\n"],"mappings":";;;;;AAQA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
1
+ {"version":3,"names":["_file","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_file2"],"sources":["types.ts"],"sourcesContent":["import { I18NContext } from \"@webiny/api-i18n/types\";\nimport { FileStorage } from \"./storage/FileStorage\";\nimport { TenancyContext } from \"@webiny/api-tenancy/types\";\nimport { SecurityContext, SecurityPermission } from \"@webiny/api-security/types\";\nimport { Context } from \"@webiny/api/types\";\nimport { FileLifecycleEvents } from \"./types/file.lifecycle\";\nimport { File } from \"./types/file\";\nimport { Topic } from \"@webiny/pubsub/types\";\nimport { CmsContext } from \"@webiny/api-headless-cms/types\";\nexport * from \"./types/file.lifecycle\";\nexport * from \"./types/file\";\n\nexport interface FileManagerContextObject extends FilesCRUD, SettingsCRUD, SystemCRUD {\n storage: FileStorage;\n}\n\nexport interface FileManagerContext\n extends Context,\n SecurityContext,\n TenancyContext,\n I18NContext,\n CmsContext {\n fileManager: FileManagerContextObject;\n}\n\nexport interface FilePermission extends SecurityPermission {\n name: \"fm.file\";\n rwd?: string;\n own?: boolean;\n}\n\nexport interface FileInput {\n id: string;\n key: string;\n name: string;\n size: number;\n type: string;\n meta: Record<string, any>;\n location?: {\n folderId: string;\n };\n tags: string[];\n aliases: string[];\n extensions?: Record<string, any>;\n}\n\nexport interface FileListWhereParams {\n AND?: FileListWhereParams[];\n OR?: FileListWhereParams[];\n [key: string]: any;\n}\nexport interface FilesListOpts {\n search?: string;\n limit?: number;\n after?: string;\n where?: FileListWhereParams;\n sort?: string[];\n}\n\nexport interface FileListMeta {\n cursor: string | null;\n totalCount: number;\n hasMoreItems: boolean;\n}\n\ninterface FilesCrudListTagsWhere {\n tag?: string;\n tag_contains?: string;\n tag_in?: string[];\n tag_not_startsWith?: string;\n tag_startsWith?: string;\n}\ninterface FilesCrudListTagsParams {\n where?: FilesCrudListTagsWhere;\n limit?: number;\n after?: string;\n}\n\nexport interface ListTagsResponse {\n tag: string;\n count: number;\n}\nexport interface FilesCRUD extends FileLifecycleEvents {\n getFile(id: string): Promise<File>;\n listFiles(opts?: FilesListOpts): Promise<[File[], FileListMeta]>;\n listTags(params: FilesCrudListTagsParams): Promise<ListTagsResponse[]>;\n createFile(data: FileInput, meta?: Record<string, any>): Promise<File>;\n updateFile(id: string, data: Partial<FileInput>): Promise<File>;\n deleteFile(id: string): Promise<boolean>;\n createFilesInBatch(data: FileInput[], meta?: Record<string, any>): Promise<File[]>;\n}\n\nexport interface SystemCRUD {\n onSystemBeforeInstall: Topic;\n onSystemAfterInstall: Topic;\n getVersion(): Promise<string | null>;\n setVersion(version: string): Promise<void>;\n install(args: { srcPrefix: string }): Promise<boolean>;\n}\n\nexport interface FileManagerSettings {\n tenant: string;\n key: string;\n uploadMinFileSize: number;\n uploadMaxFileSize: number;\n srcPrefix: string;\n}\n\nexport interface FileManagerSystem {\n version: string;\n tenant: string;\n}\n\nexport type SettingsCRUD = {\n getSettings(): Promise<FileManagerSettings | null>;\n createSettings(data?: Partial<FileManagerSettings>): Promise<FileManagerSettings>;\n updateSettings(data: Partial<FileManagerSettings>): Promise<FileManagerSettings>;\n deleteSettings(): Promise<boolean>;\n};\n/********\n * Storage operations\n *******/\n\n/**\n * @category StorageOperations\n * @category SystemStorageOperations\n * @category SystemStorageOperationsParams\n */\nexport interface FileManagerSystemStorageOperationsUpdateParams {\n /**\n * The system data to be updated.\n */\n original: FileManagerSystem;\n /**\n * The system data with the updated fields.\n */\n data: FileManagerSystem;\n}\n/**\n * @category StorageOperations\n * @category SystemStorageOperations\n * @category SystemStorageOperationsParams\n */\nexport interface FileManagerSystemStorageOperationsCreateParams {\n /**\n * The system fields.\n */\n data: FileManagerSystem;\n}\n\nexport interface FileManagerSystemStorageOperationsGetParams {\n tenant: string;\n}\n\n/**\n * @category StorageOperations\n * @category SystemStorageOperations\n */\nexport interface FileManagerSystemStorageOperations {\n /**\n * Get the FileManager system data.\n */\n get: (params: FileManagerSystemStorageOperationsGetParams) => Promise<FileManagerSystem | null>;\n /**\n * Update the FileManager system data..\n */\n update: (params: FileManagerSystemStorageOperationsUpdateParams) => Promise<FileManagerSystem>;\n /**\n * Create the FileManagerSystemData\n */\n create: (params: FileManagerSystemStorageOperationsCreateParams) => Promise<FileManagerSystem>;\n}\n\n/**\n * @category StorageOperations\n * @category SettingsStorageOperations\n * @category SettingsStorageOperationsParams\n */\nexport interface FileManagerSettingsStorageOperationsUpdateParams {\n /**\n * Original settings to be updated.\n */\n original: FileManagerSettings;\n /**\n * The settings with the updated fields.\n */\n data: FileManagerSettings;\n}\n/**\n * @category StorageOperations\n * @category SettingsStorageOperations\n * @category SettingsStorageOperationsParams\n */\nexport interface FileManagerSettingsStorageOperationsCreateParams {\n /**\n * The settings fields.\n */\n data: FileManagerSettings;\n}\n\nexport interface FileManagerStorageOperationsGetSettingsParams {\n tenant: string;\n}\n\nexport interface FileManagerStorageOperationsDeleteSettings {\n tenant: string;\n}\n\n/**\n * @category StorageOperations\n * @category SettingsStorageOperations\n */\nexport interface FileManagerSettingsStorageOperations {\n /**\n * Get the FileManager system data.\n */\n get: (\n params: FileManagerStorageOperationsGetSettingsParams\n ) => Promise<FileManagerSettings | null>;\n /**\n * Create the FileManagerSettingsData\n */\n create: (\n params: FileManagerSettingsStorageOperationsCreateParams\n ) => Promise<FileManagerSettings>;\n /**\n * Update the FileManager system data..\n */\n update: (\n params: FileManagerSettingsStorageOperationsUpdateParams\n ) => Promise<FileManagerSettings>;\n /**\n * Delete the existing settings.\n */\n delete: (params: FileManagerStorageOperationsDeleteSettings) => Promise<void>;\n}\n\n/**\n * @category StorageOperations\n * @category FilesStorageOperations\n * @category FilesStorageOperationsParams\n */\nexport interface FileManagerFilesStorageOperationsGetParams {\n where: {\n id: string;\n tenant: string;\n locale: string;\n };\n}\n/**\n * @category StorageOperations\n * @category FilesStorageOperations\n * @category FilesStorageOperationsParams\n */\nexport interface FileManagerFilesStorageOperationsCreateParams {\n file: File;\n}\n/**\n * @category StorageOperations\n * @category FilesStorageOperations\n * @category FilesStorageOperationsParams\n */\nexport interface FileManagerFilesStorageOperationsUpdateParams {\n original: File;\n file: File;\n}\n\n/**\n * @category StorageOperations\n * @category FilesStorageOperations\n * @category FilesStorageOperationsParams\n */\nexport interface FileManagerFilesStorageOperationsDeleteParams {\n file: File;\n}\n/**\n * @category StorageOperations\n * @category FilesStorageOperations\n * @category FilesStorageOperationsParams\n */\nexport interface FileManagerFilesStorageOperationsCreateBatchParams {\n files: File[];\n}\n/**\n * @category StorageOperations\n * @category FilesStorageOperations\n * @category FilesStorageOperationsParams\n */\nexport interface FileManagerFilesStorageOperationsListParamsWhere {\n [key: string]: any;\n}\n/**\n * @category StorageOperations\n * @category FilesStorageOperations\n * @category FilesStorageOperationsParams\n */\nexport interface FileManagerFilesStorageOperationsListParams {\n where: FileManagerFilesStorageOperationsListParamsWhere;\n sort: string[];\n limit: number;\n after: string | null;\n search?: string;\n}\n\n/**\n * @category StorageOperations\n * @category FilesStorageOperations\n * @category FilesStorageOperationsParams\n */\nexport interface FileManagerFilesStorageOperationsListResponseMeta {\n hasMoreItems: boolean;\n totalCount: number;\n cursor: string | null;\n}\nexport type FileManagerFilesStorageOperationsListResponse = [\n File[],\n FileManagerFilesStorageOperationsListResponseMeta\n];\n\nexport interface FileManagerFilesStorageOperationsTagsResponse {\n tag: string;\n count: number;\n}\n\nexport interface FileManagerFilesStorageOperationsTagsParamsWhere extends FilesCrudListTagsWhere {\n locale: string;\n tenant: string;\n}\n/**\n * @category StorageOperations\n * @category FilesStorageOperations\n * @category FilesStorageOperationsParams\n */\nexport interface FileManagerFilesStorageOperationsTagsParams {\n where: FileManagerFilesStorageOperationsTagsParamsWhere;\n limit: number;\n after?: string;\n}\n/**\n * @category StorageOperations\n * @category FilesStorageOperations\n */\nexport interface FileManagerFilesStorageOperations {\n /**\n * Get a single file with given ID from the storage.\n */\n get: (params: FileManagerFilesStorageOperationsGetParams) => Promise<File | null>;\n /**\n * Insert the file data into the database.\n */\n create: (params: FileManagerFilesStorageOperationsCreateParams) => Promise<File>;\n /**\n * Update the file data in the database.\n */\n update: (params: FileManagerFilesStorageOperationsUpdateParams) => Promise<File>;\n /**\n * Delete the file from the database.\n */\n delete: (params: FileManagerFilesStorageOperationsDeleteParams) => Promise<void>;\n /**\n * Store multiple files at once to the database.\n */\n createBatch: (params: FileManagerFilesStorageOperationsCreateBatchParams) => Promise<File[]>;\n /**\n * Get a list of files filtered by given parameters.\n */\n list: (\n params: FileManagerFilesStorageOperationsListParams\n ) => Promise<FileManagerFilesStorageOperationsListResponse>;\n /**\n * Get a list of all file tags filtered by given parameters.\n */\n tags: (\n params: FileManagerFilesStorageOperationsTagsParams\n ) => Promise<FileManagerFilesStorageOperationsTagsResponse[]>;\n}\n\nexport interface FileManagerAliasesStorageOperations {\n storeAliases(file: File): Promise<void>;\n deleteAliases(file: File): Promise<void>;\n}\n\nexport interface FileManagerStorageOperations<TContext = FileManagerContext> {\n beforeInit?: (context: TContext) => Promise<void>;\n files: FileManagerFilesStorageOperations;\n aliases: FileManagerAliasesStorageOperations;\n settings: FileManagerSettingsStorageOperations;\n system: FileManagerSystemStorageOperations;\n}\n"],"mappings":";;;;;AASA,IAAAA,KAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,KAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,KAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,KAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,MAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,MAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,MAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,MAAA,CAAAL,GAAA;IAAA;EAAA;AAAA"}
@@ -1,5 +0,0 @@
1
- import { GetPermission } from "@webiny/api-security/types";
2
- import { FilePermission } from "../types";
3
- export declare const checkBasePermissions: (getPermission: GetPermission, check?: {
4
- rwd?: string;
5
- }) => Promise<FilePermission>;
@@ -1,24 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.checkBasePermissions = void 0;
7
- var _apiSecurity = require("@webiny/api-security");
8
- const checkBasePermissions = async (getPermission, check = {}) => {
9
- const filePermission = await getPermission("fm.file");
10
- if (!filePermission) {
11
- throw new _apiSecurity.NotAuthorizedError();
12
- }
13
- if (check.rwd && !hasRwd(filePermission, check.rwd)) {
14
- throw new _apiSecurity.NotAuthorizedError();
15
- }
16
- return filePermission;
17
- };
18
- exports.checkBasePermissions = checkBasePermissions;
19
- const hasRwd = (filesFilePermission, rwd) => {
20
- if (typeof filesFilePermission.rwd !== "string") {
21
- return true;
22
- }
23
- return filesFilePermission.rwd.includes(rwd);
24
- };
@@ -1 +0,0 @@
1
- {"version":3,"names":["checkBasePermissions","getPermission","check","filePermission","NotAuthorizedError","rwd","hasRwd","filesFilePermission","includes"],"sources":["checkBasePermissions.ts"],"sourcesContent":["import { NotAuthorizedError } from \"@webiny/api-security\";\nimport { GetPermission } from \"@webiny/api-security/types\";\nimport { FilePermission } from \"~/types\";\n\nexport const checkBasePermissions = async (\n getPermission: GetPermission,\n check: { rwd?: string } = {}\n): Promise<FilePermission> => {\n const filePermission = await getPermission<FilePermission>(\"fm.file\");\n\n if (!filePermission) {\n throw new NotAuthorizedError();\n }\n if (check.rwd && !hasRwd(filePermission, check.rwd)) {\n throw new NotAuthorizedError();\n }\n\n return filePermission;\n};\n\nconst hasRwd = (filesFilePermission: FilePermission, rwd: string): boolean => {\n if (typeof filesFilePermission.rwd !== \"string\") {\n return true;\n }\n\n return filesFilePermission.rwd.includes(rwd);\n};\n"],"mappings":";;;;;;AAAA;AAIO,MAAMA,oBAAoB,GAAG,OAChCC,aAA4B,EAC5BC,KAAuB,GAAG,CAAC,CAAC,KACF;EAC1B,MAAMC,cAAc,GAAG,MAAMF,aAAa,CAAiB,SAAS,CAAC;EAErE,IAAI,CAACE,cAAc,EAAE;IACjB,MAAM,IAAIC,+BAAkB,EAAE;EAClC;EACA,IAAIF,KAAK,CAACG,GAAG,IAAI,CAACC,MAAM,CAACH,cAAc,EAAED,KAAK,CAACG,GAAG,CAAC,EAAE;IACjD,MAAM,IAAID,+BAAkB,EAAE;EAClC;EAEA,OAAOD,cAAc;AACzB,CAAC;AAAC;AAEF,MAAMG,MAAM,GAAG,CAACC,mBAAmC,EAAEF,GAAW,KAAc;EAC1E,IAAI,OAAOE,mBAAmB,CAACF,GAAG,KAAK,QAAQ,EAAE;IAC7C,OAAO,IAAI;EACf;EAEA,OAAOE,mBAAmB,CAACF,GAAG,CAACG,QAAQ,CAACH,GAAG,CAAC;AAChD,CAAC"}