@orion-js/file-manager 3.6.1 → 3.6.3

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.
@@ -1,11 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const resolvers_1 = require("@orion-js/resolvers");
4
+ const credentials_1 = require("../../credentials");
4
5
  exports.default = (0, resolvers_1.modelResolver)({
5
6
  returns: String,
6
7
  async resolve(file, viewer) {
7
8
  if (file.externalUrl)
8
9
  return file.externalUrl;
10
+ const options = (0, credentials_1.getAWSCredentials)();
11
+ if (options.getFileURL)
12
+ return options.getFileURL(file);
9
13
  return `https://s3.amazonaws.com/${file.bucket}/${encodeURIComponent(file.key)}`;
10
14
  }
11
15
  });
@@ -4,7 +4,10 @@ export interface Credentials {
4
4
  region: string;
5
5
  bucket: string;
6
6
  canUpload: Function;
7
+ getFileURL?: Function;
7
8
  basePath: string;
9
+ endpoint?: string;
10
+ s3ForcePathStyle?: boolean;
8
11
  }
9
12
  export declare const setupFileManager: (options: any) => any;
10
13
  export declare const getAWSCredentials: () => Partial<Credentials>;
@@ -40,11 +40,13 @@ exports.default = (0, resolvers_1.resolver)({
40
40
  }),
41
41
  mutation: true,
42
42
  async resolve(params, viewer) {
43
- const { accessKeyId, secretAccessKey, region, bucket, canUpload, basePath } = (0, credentials_1.getAWSCredentials)();
43
+ const { accessKeyId, secretAccessKey, region, bucket, endpoint, s3ForcePathStyle, canUpload, basePath } = (0, credentials_1.getAWSCredentials)();
44
44
  const s3 = new aws_sdk_1.default.S3({
45
45
  accessKeyId,
46
46
  secretAccessKey,
47
- region
47
+ region,
48
+ endpoint,
49
+ s3ForcePathStyle
48
50
  });
49
51
  if (canUpload) {
50
52
  if (!(await canUpload(params, viewer)))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orion-js/file-manager",
3
- "version": "3.6.1",
3
+ "version": "3.6.3",
4
4
  "main": "lib/index.js",
5
5
  "author": "nicolaslopezj",
6
6
  "license": "MIT",
@@ -18,7 +18,7 @@
18
18
  "@orion-js/paginated-mongodb": "^3.6.1",
19
19
  "@orion-js/resolvers": "^3.6.1",
20
20
  "@orion-js/schema": "^3.6.1",
21
- "aws-sdk": "^2.1028.0",
21
+ "aws-sdk": "^2.1367.0",
22
22
  "escape-string-regexp": "^4.0.0",
23
23
  "lodash": "^4.17.21",
24
24
  "luxon": "^2.1.1"
@@ -38,5 +38,5 @@
38
38
  "publishConfig": {
39
39
  "access": "public"
40
40
  },
41
- "gitHead": "ce643e657e199d1893c8c0f1d067d96e542f1796"
41
+ "gitHead": "3925ac7f2a4806b68665d7cb07ef2f2c55b873d9"
42
42
  }