@webiny/api-file-manager-s3 5.23.1 → 5.24.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/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- declare const _default: () => (import("@webiny/handler-graphql/types").GraphQLSchemaPlugin<import("@webiny/api-file-manager/types").FileManagerContext> | import("@webiny/api-file-manager/plugins/definitions/FilePhysicalStoragePlugin").FilePhysicalStoragePlugin)[];
1
+ declare const _default: () => (import("@webiny/handler-graphql/types").GraphQLSchemaPlugin<import("@webiny/api-file-manager/types").FileManagerContext> | import("@webiny/api-file-manager/plugins/definitions/FilePhysicalStoragePlugin").FilePhysicalStoragePlugin<import("@webiny/api-file-manager/plugins/definitions/FilePhysicalStoragePlugin").FilePhysicalStoragePluginUploadParams, import("@webiny/api-file-manager/plugins/definitions/FilePhysicalStoragePlugin").FilePhysicalStoragePluginDeleteParams>)[];
2
2
  export default _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/api-file-manager-s3",
3
- "version": "5.23.1",
3
+ "version": "5.24.0-beta.0",
4
4
  "main": "index.js",
5
5
  "repository": {
6
6
  "type": "git",
@@ -10,9 +10,9 @@
10
10
  "author": "Webiny Ltd",
11
11
  "license": "MIT",
12
12
  "dependencies": {
13
- "@webiny/api-file-manager": "5.23.1",
14
- "@webiny/handler-graphql": "5.23.1",
15
- "@webiny/validation": "5.23.1",
13
+ "@webiny/api-file-manager": "5.24.0-beta.0",
14
+ "@webiny/handler-graphql": "5.24.0-beta.0",
15
+ "@webiny/validation": "5.24.0-beta.0",
16
16
  "form-data": "3.0.1",
17
17
  "node-fetch": "2.6.7",
18
18
  "sanitize-filename": "1.6.3",
@@ -21,8 +21,8 @@
21
21
  "devDependencies": {
22
22
  "@babel/cli": "^7.16.0",
23
23
  "@babel/core": "^7.16.0",
24
- "@webiny/cli": "^5.23.1",
25
- "@webiny/project-utils": "^5.23.1",
24
+ "@webiny/cli": "^5.24.0-beta.0",
25
+ "@webiny/project-utils": "^5.24.0-beta.0",
26
26
  "rimraf": "^3.0.2",
27
27
  "typescript": "^4.1.3"
28
28
  },
@@ -34,5 +34,5 @@
34
34
  "build": "yarn webiny run build",
35
35
  "watch": "yarn webiny run watch"
36
36
  },
37
- "gitHead": "a726d09d2647d13e5a4f376cef23463564ef7ca0"
37
+ "gitHead": "05b90b92bbaf2ef3adf275d008c4641580cf5f42"
38
38
  }
@@ -1,3 +1,6 @@
1
- import { FilePhysicalStoragePlugin } from "@webiny/api-file-manager/plugins/definitions/FilePhysicalStoragePlugin";
1
+ import { FilePhysicalStoragePlugin, FilePhysicalStoragePluginUploadParams } from "@webiny/api-file-manager/plugins/definitions/FilePhysicalStoragePlugin";
2
+ import { PresignedPostPayloadData } from "../types";
3
+ export interface S3FilePhysicalStoragePluginUploadParams extends FilePhysicalStoragePluginUploadParams, PresignedPostPayloadData {
4
+ }
2
5
  declare const _default: () => FilePhysicalStoragePlugin;
3
6
  export default _default;
@@ -21,13 +21,17 @@ const _excluded = ["settings", "buffer"];
21
21
  const S3_BUCKET = process.env.S3_BUCKET;
22
22
 
23
23
  var _default = () => {
24
+ /**
25
+ * We need to extends the type for FilePhysicalStoragePlugin.
26
+ * Otherwise the getPresignedPostPayload does not know it has all required values in params.
27
+ */
24
28
  return new _FilePhysicalStoragePlugin.FilePhysicalStoragePlugin({
25
- upload: async args => {
29
+ upload: async params => {
26
30
  const {
27
31
  settings,
28
32
  buffer
29
- } = args,
30
- data = (0, _objectWithoutProperties2.default)(args, _excluded);
33
+ } = params,
34
+ data = (0, _objectWithoutProperties2.default)(params, _excluded);
31
35
  const {
32
36
  data: preSignedPostPayload,
33
37
  file
@@ -43,10 +47,10 @@ var _default = () => {
43
47
  file
44
48
  };
45
49
  },
46
- delete: async args => {
50
+ delete: async params => {
47
51
  const {
48
52
  key
49
- } = args;
53
+ } = params;
50
54
  const s3 = new _s.default();
51
55
  await s3.deleteObject({
52
56
  Bucket: S3_BUCKET,
@@ -113,8 +113,7 @@ const plugin = {
113
113
  const settings = await context.fileManager.settings.getSettings();
114
114
  const promises = [];
115
115
 
116
- for (let i = 0; i < files.length; i++) {
117
- const item = files[i];
116
+ for (const item of files) {
118
117
  promises.push((0, _getPresignedPostPayload.default)(item, settings));
119
118
  }
120
119
 
package/types.d.ts CHANGED
@@ -0,0 +1,16 @@
1
+ import S3 from "aws-sdk/clients/s3";
2
+ export interface PresignedPostPayloadData {
3
+ name: string;
4
+ type: string;
5
+ size: number;
6
+ keyPrefix: string;
7
+ }
8
+ export interface PresignedPostPayloadDataResponse {
9
+ data: S3.PresignedPost;
10
+ file: {
11
+ name: string;
12
+ key: string;
13
+ type: string;
14
+ size: number;
15
+ };
16
+ }
package/types.js CHANGED
@@ -1 +1,5 @@
1
- "use strict";
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -1,11 +1,4 @@
1
- import S3 from "aws-sdk/clients/s3";
2
- declare const _default: (data: any, settings: any) => Promise<{
3
- data: S3.PresignedPost;
4
- file: {
5
- name: string;
6
- key: string;
7
- type: any;
8
- size: any;
9
- };
10
- }>;
1
+ import { PresignedPostPayloadData, PresignedPostPayloadDataResponse } from "../types";
2
+ import { FileManagerSettings } from "@webiny/api-file-manager/types";
3
+ declare const _default: (data: PresignedPostPayloadData, settings: FileManagerSettings) => Promise<PresignedPostPayloadDataResponse>;
11
4
  export default _default;
@@ -24,6 +24,7 @@ const sanitizeFileSizeValue = (value, defaultValue) => {
24
24
 
25
25
  return value;
26
26
  } catch (e) {
27
+ // TODO @ts-refactor No need to log the error?
27
28
  return defaultValue;
28
29
  }
29
30
  };
@@ -1,2 +1,5 @@
1
- declare const _default: (buffer: any, preSignedPostPayload: any) => Promise<import("node-fetch").Response>;
1
+ /// <reference types="node" />
2
+ import { Response } from "node-fetch";
3
+ import S3 from "aws-sdk/clients/s3";
4
+ declare const _default: (buffer: Buffer, preSignedPostPayload: S3.PresignedPost) => Promise<Response>;
2
5
  export default _default;