@8ms/helpers 1.1.44 → 1.1.47

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,7 +1,7 @@
1
1
  /**
2
2
  * Write a file to S3.
3
3
  */
4
- export declare const writeFile: ({ S3Lib, bucket, client, data, key }: {
4
+ export declare const writeFile: ({ S3Lib, bucket, client, data, key, ...options }: {
5
5
  S3Lib: any;
6
6
  bucket: string;
7
7
  client: any;
@@ -1,4 +1,15 @@
1
1
  "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
2
13
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
14
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
15
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -35,30 +46,35 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
35
46
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
47
  }
37
48
  };
49
+ var __rest = (this && this.__rest) || function (s, e) {
50
+ var t = {};
51
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
52
+ t[p] = s[p];
53
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
54
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
55
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
56
+ t[p[i]] = s[p[i]];
57
+ }
58
+ return t;
59
+ };
38
60
  Object.defineProperty(exports, "__esModule", { value: true });
39
61
  exports.writeFile = void 0;
40
62
  /**
41
63
  * Write a file to S3.
42
64
  */
43
- var writeFile = function (_a) {
44
- var S3Lib = _a.S3Lib, bucket = _a.bucket, client = _a.client, data = _a.data, key = _a.key;
45
- return __awaiter(void 0, void 0, void 0, function () {
46
- var PutObjectCommand, apiResponse;
47
- return __generator(this, function (_b) {
48
- switch (_b.label) {
49
- case 0:
50
- PutObjectCommand = S3Lib.PutObjectCommand;
51
- return [4 /*yield*/, client.send(new PutObjectCommand({
52
- Bucket: bucket,
53
- Body: data,
54
- Key: key,
55
- }))];
56
- case 1:
57
- apiResponse = _b.sent();
58
- return [2 /*return*/, apiResponse];
59
- }
60
- });
65
+ var writeFile = function (_a) { return __awaiter(void 0, void 0, void 0, function () {
66
+ var PutObjectCommand, apiResponse;
67
+ var S3Lib = _a.S3Lib, bucket = _a.bucket, client = _a.client, data = _a.data, key = _a.key, options = __rest(_a, ["S3Lib", "bucket", "client", "data", "key"]);
68
+ return __generator(this, function (_b) {
69
+ switch (_b.label) {
70
+ case 0:
71
+ PutObjectCommand = S3Lib.PutObjectCommand;
72
+ return [4 /*yield*/, client.send(new PutObjectCommand(__assign({ Bucket: bucket, Body: data, Key: key }, options)))];
73
+ case 1:
74
+ apiResponse = _b.sent();
75
+ return [2 /*return*/, apiResponse];
76
+ }
61
77
  });
62
- };
78
+ }); };
63
79
  exports.writeFile = writeFile;
64
80
  exports.default = exports.writeFile;
@@ -57,18 +57,18 @@ var getCredentials = function (_a) {
57
57
  })];
58
58
  case 1:
59
59
  parameter = _b.sent();
60
- privateKey = parameter.privateKey.replace(/\\n/g, '\n');
60
+ privateKey = parameter['private_key'].replace(/\\n/g, '\n');
61
61
  return [2 /*return*/, {
62
- type: 'service_account',
63
- project_id: parameter.projectId,
64
- private_key_id: 'private_key_id',
62
+ type: parameter['type'],
63
+ project_id: parameter['project_id'],
64
+ private_key_id: parameter['private_key_id'],
65
65
  private_key: privateKey,
66
- client_email: parameter.clientEmail,
67
- client_id: parameter.clientId,
68
- auth_uri: 'https://accounts.google.com/o/oauth2/auth',
69
- token_uri: 'https://oauth2.googleapis.com/token',
70
- auth_provider_x509_cert_url: 'https://www.googleapis.com/oauth2/v1/certs',
71
- client_x509_cert_url: parameter.x509CertUrl,
66
+ client_email: parameter['client_email'],
67
+ client_id: parameter['client_id'],
68
+ auth_uri: parameter['auth_uri'],
69
+ token_uri: parameter['token_uri'],
70
+ auth_provider_x509_cert_url: parameter['auth_provider_x509_cert_url'],
71
+ client_x509_cert_url: parameter['client_x509_cert_url'],
72
72
  }];
73
73
  }
74
74
  });
@@ -53,7 +53,11 @@ var writeFile = function (_a) {
53
53
  case 0:
54
54
  Storage = GoogleStorageLib.Storage;
55
55
  storage = new Storage({
56
- credentials: credentials,
56
+ credentials: {
57
+ client_email: credentials['client_email'],
58
+ private_key: credentials['private_key'],
59
+ },
60
+ projectId: credentials['project_id'],
57
61
  });
58
62
  data_stream = new stream_1.default.PassThrough();
59
63
  google_file = storage.bucket(bucket)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@8ms/helpers",
3
- "version": "1.1.44",
3
+ "version": "1.1.47",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/8millionstories-organisation/8ms-helpers-ts.git"