@webiny/api-file-manager 5.15.0 → 5.17.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-file-manager",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.17.0-beta.0",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"fm:base"
|
|
@@ -20,17 +20,17 @@
|
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@babel/runtime": "7.15.3",
|
|
22
22
|
"@commodo/fields": "1.1.2-beta.20",
|
|
23
|
-
"@webiny/api-i18n-content": "5.
|
|
24
|
-
"@webiny/api-security": "5.
|
|
25
|
-
"@webiny/api-tenancy": "5.
|
|
26
|
-
"@webiny/api-upgrade": "5.
|
|
27
|
-
"@webiny/error": "5.
|
|
28
|
-
"@webiny/handler": "5.
|
|
29
|
-
"@webiny/handler-client": "5.
|
|
30
|
-
"@webiny/handler-graphql": "5.
|
|
31
|
-
"@webiny/plugins": "5.
|
|
32
|
-
"@webiny/project-utils": "5.
|
|
33
|
-
"@webiny/validation": "5.
|
|
23
|
+
"@webiny/api-i18n-content": "5.17.0-beta.0",
|
|
24
|
+
"@webiny/api-security": "5.17.0-beta.0",
|
|
25
|
+
"@webiny/api-tenancy": "5.17.0-beta.0",
|
|
26
|
+
"@webiny/api-upgrade": "5.17.0-beta.0",
|
|
27
|
+
"@webiny/error": "5.17.0-beta.0",
|
|
28
|
+
"@webiny/handler": "5.17.0-beta.0",
|
|
29
|
+
"@webiny/handler-client": "5.17.0-beta.0",
|
|
30
|
+
"@webiny/handler-graphql": "5.17.0-beta.0",
|
|
31
|
+
"@webiny/plugins": "5.17.0-beta.0",
|
|
32
|
+
"@webiny/project-utils": "5.17.0-beta.0",
|
|
33
|
+
"@webiny/validation": "5.17.0-beta.0",
|
|
34
34
|
"aws-sdk": "2.968.0",
|
|
35
35
|
"commodo-fields-object": "1.0.6",
|
|
36
36
|
"mdbid": "1.0.0",
|
|
@@ -44,9 +44,9 @@
|
|
|
44
44
|
"@babel/plugin-transform-runtime": "^7.5.5",
|
|
45
45
|
"@babel/preset-env": "^7.5.5",
|
|
46
46
|
"@babel/preset-typescript": "^7.0.0",
|
|
47
|
-
"@webiny/api-i18n": "^5.
|
|
48
|
-
"@webiny/api-i18n-ddb": "^5.
|
|
49
|
-
"@webiny/cli": "^5.
|
|
47
|
+
"@webiny/api-i18n": "^5.17.0-beta.0",
|
|
48
|
+
"@webiny/api-i18n-ddb": "^5.17.0-beta.0",
|
|
49
|
+
"@webiny/cli": "^5.17.0-beta.0",
|
|
50
50
|
"jest": "^26.6.3",
|
|
51
51
|
"rimraf": "^3.0.2",
|
|
52
52
|
"ttypescript": "^1.5.12",
|
|
@@ -71,5 +71,5 @@
|
|
|
71
71
|
]
|
|
72
72
|
}
|
|
73
73
|
},
|
|
74
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "4b43404bf5ed84250bc9e3e5a64cc80501ae7e34"
|
|
75
75
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/plugins/storage/FileStorage.ts"],"names":["storagePluginType","FileStorage","constructor","context","storagePlugin","plugins","byType","pop","WebinyError","upload","args","settings","fileManager","getSettings","file","fileData","files","createFile","meta","private","Boolean","hideInFileManager","uploadFiles","promises","i","length","item","push","uploadFileResponses","Promise","all","filesData","map","response","createFilesInBatch","delete","id","key","deleteFile"],"mappings":";;;;;;;;;;;AACA;;;;;;
|
|
1
|
+
{"version":3,"sources":["../../../src/plugins/storage/FileStorage.ts"],"names":["storagePluginType","FileStorage","constructor","context","storagePlugin","plugins","byType","pop","WebinyError","upload","args","settings","fileManager","getSettings","file","fileData","files","createFile","meta","private","Boolean","hideInFileManager","tags","Array","isArray","uploadFiles","promises","i","length","item","push","uploadFileResponses","Promise","all","filesData","map","response","createFiles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CAEpB;;AACA,UAAMa,QAAQ,GAAG,EAAjB;;AACA,SAAK,IAAIC,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGjB,IAAI,CAACM,KAAL,CAAWY,MAA/B,EAAuCD,CAAC,EAAxC,EAA4C;AACxC,YAAME,IAAI,GAAGnB,IAAI,CAACM,KAAL,CAAWW,CAAX,CAAb;AACAD,MAAAA,QAAQ,CAACI,IAAT,CACI,KAAK1B,aAAL,CAAmBK,MAAnB,iCACOoB,IADP;AAEIlB,QAAAA;AAFJ,SADJ;AAMH,KAZmB,CAapB;;;AACA,UAAMoB,mBAAmB,GAAG,MAAMC,OAAO,CAACC,GAAR,CAAYP,QAAZ,CAAlC;AAEA,UAAMQ,SAAS,GAAGH,mBAAmB,CAACI,GAApB,CAAwBC,QAAQ,IAAIA,QAAQ,CAACtB,IAA7C,CAAlB;AAEA,UAAM;AAAEF,MAAAA;AAAF,QAAkB,KAAKT,OAA7B,CAlBoB,CAmBpB;;AACA,WAAOS,WAAW,CAACI,KAAZ,CAAkBqB,kBAAlB,CAAqCH,SAArC,CAAP;AACH;;AAEW,QAANI,MAAM,CAAC5B,IAAD,EAAoC;AAC5C,UAAM;AAAE6B,MAAAA,EAAF;AAAMC,MAAAA;AAAN,QAAc9B,IAApB;AACA,UAAM;AAAEE,MAAAA;AAAF,QAAkB,KAAKT,OAA7B,CAF4C,CAG5C;;AACA,UAAM,KAAKC,aAAL,CAAmBkC,MAAnB,CAA0B;AAC5BE,MAAAA;AAD4B,KAA1B,CAAN,CAJ4C,CAO5C;;AACA,WAAO,MAAM5B,WAAW,CAACI,KAAZ,CAAkByB,UAAlB,CAA6BF,EAA7B,CAAb;AACH;;AAjEoB","sourcesContent":["import { FileManagerContext } from \"~/types\";\nimport WebinyError from \"@webiny/error\";\n\nexport type Args = {\n name: string;\n type: string;\n size: number;\n buffer: Buffer;\n keyPrefix?: string;\n hideInFileManager?: boolean;\n tags?: string[];\n};\n\nexport type Result = Record<string, any>;\n\nexport interface FileStoragePlugin {\n upload: (args: Args) => Promise<Result>;\n delete: (args: { key: string }) => Promise<void>;\n}\n\nconst storagePluginType = \"api-file-manager-storage\";\n\nexport class FileStorage {\n storagePlugin: FileStoragePlugin;\n context: FileManagerContext;\n\n constructor({ context }) {\n this.storagePlugin = context.plugins.byType(storagePluginType).pop();\n if (!this.storagePlugin) {\n throw new WebinyError(\n `Missing plugin of type \"${storagePluginType}\".`,\n \"STORAGE_PLUGIN_ERROR\"\n );\n }\n this.context = context;\n }\n\n async upload(args): Promise<Result> {\n const settings = await this.context.fileManager.settings.getSettings();\n // Add file to cloud storage.\n const { file: fileData } = await this.storagePlugin.upload({\n ...args,\n settings\n });\n\n const { fileManager } = this.context;\n\n // Save file in DB.\n return await fileManager.files.createFile({\n ...fileData,\n meta: { private: Boolean(args.hideInFileManager) },\n tags: Array.isArray(args.tags) ? args.tags : []\n });\n }\n\n async uploadFiles(args) {\n const settings = await this.context.fileManager.settings.getSettings();\n // Upload files to cloud storage.\n const promises = [];\n for (let i = 0; i < args.files.length; i++) {\n const item = args.files[i];\n promises.push(\n this.storagePlugin.upload({\n ...item,\n settings\n })\n );\n }\n // Wait for all to resolve.\n const uploadFileResponses = await Promise.all(promises);\n\n const filesData = uploadFileResponses.map(response => response.file);\n\n const { fileManager } = this.context;\n // Save files in DB.\n return fileManager.files.createFilesInBatch(filesData);\n }\n\n async delete(args: { id: string; key: string }) {\n const { id, key } = args;\n const { fileManager } = this.context;\n // Delete file from cloud storage.\n await this.storagePlugin.delete({\n key\n });\n // Delete file from the DB.\n return await fileManager.files.deleteFile(id);\n }\n}\n"],"file":"FileStorage.js"}
|