@quatrain/storage-s3 1.2.1 → 1.2.2

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,5 +1,5 @@
1
1
  import { AbstractStorageAdapter, FileType, FileResponseLinkType, StorageParameters, DownloadFileMetaType } from '@quatrain/storage';
2
- import { Readable, Stream } from 'stream';
2
+ import { Readable, Stream } from 'node:stream';
3
3
  import { S3Client } from '@aws-sdk/client-s3';
4
4
  export declare class S3StorageAdapter extends AbstractStorageAdapter {
5
5
  protected _client: S3Client;
@@ -17,7 +17,7 @@ export declare class S3StorageAdapter extends AbstractStorageAdapter {
17
17
  * @returns
18
18
  */
19
19
  move(file: FileType, destFile: FileType): Promise<FileType>;
20
- getUrl(file: FileType, expiresIn?: number, action?: any, extra?: any): Promise<{
20
+ _getUrl(file: FileType, expiresIn?: number, action?: any, extra?: any): Promise<{
21
21
  url: string;
22
22
  expiresIn: number;
23
23
  }>;
@@ -11,9 +11,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.S3StorageAdapter = void 0;
13
13
  const storage_1 = require("@quatrain/storage");
14
- const stream_1 = require("stream");
14
+ const node_stream_1 = require("node:stream");
15
15
  const s3_request_presigner_1 = require("@aws-sdk/s3-request-presigner");
16
- const fs_1 = require("fs");
16
+ const node_fs_1 = require("node:fs");
17
17
  const client_s3_1 = require("@aws-sdk/client-s3");
18
18
  class S3StorageAdapter extends storage_1.AbstractStorageAdapter {
19
19
  constructor(params) {
@@ -114,7 +114,7 @@ class S3StorageAdapter extends storage_1.AbstractStorageAdapter {
114
114
  return destFile;
115
115
  });
116
116
  }
117
- getUrl(file_1) {
117
+ _getUrl(file_1) {
118
118
  return __awaiter(this, arguments, void 0, function* (file, expiresIn = 3600, action = 'read', extra = {}) {
119
119
  const commandArgs = {
120
120
  Bucket: file.bucket,
@@ -154,7 +154,7 @@ class S3StorageAdapter extends storage_1.AbstractStorageAdapter {
154
154
  const item = yield ((_a = this._client) === null || _a === void 0 ? void 0 : _a.send(command));
155
155
  const ByteArray = yield ((_b = item === null || item === void 0 ? void 0 : item.Body) === null || _b === void 0 ? void 0 : _b.transformToByteArray());
156
156
  const buffer = Buffer.from(ByteArray, 'base64');
157
- const readable = new stream_1.Readable();
157
+ const readable = new node_stream_1.Readable();
158
158
  readable.push(buffer);
159
159
  readable.push(null);
160
160
  return readable;
@@ -181,7 +181,7 @@ class S3StorageAdapter extends storage_1.AbstractStorageAdapter {
181
181
  const item = yield this._client.send(command);
182
182
  const ByteArray = yield ((_a = item.Body) === null || _a === void 0 ? void 0 : _a.transformToByteArray());
183
183
  const buffer = Buffer.from(ByteArray, 'base64');
184
- const readable = new stream_1.Readable();
184
+ const readable = new node_stream_1.Readable();
185
185
  readable.push(buffer);
186
186
  readable.push(null);
187
187
  return readable.pipe(res);
@@ -190,7 +190,7 @@ class S3StorageAdapter extends storage_1.AbstractStorageAdapter {
190
190
  download(file, meta) {
191
191
  return __awaiter(this, void 0, void 0, function* () {
192
192
  const stream = yield this.getReadable(file);
193
- yield new Promise((res) => stream.pipe((0, fs_1.createWriteStream)(meta.path)).on('close', () => res(true)));
193
+ yield new Promise((res) => stream.pipe((0, node_fs_1.createWriteStream)(meta.path)).on('close', () => res(true)));
194
194
  return meta.path;
195
195
  });
196
196
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quatrain/storage-s3",
3
- "version": "1.2.1",
3
+ "version": "1.2.2",
4
4
  "description": "Storage adapter for S3 compatible services",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -33,7 +33,7 @@
33
33
  "dependencies": {
34
34
  "@aws-sdk/client-s3": "^3.337.0",
35
35
  "@aws-sdk/s3-request-presigner": "^3.342.0",
36
- "@quatrain/storage": "^1.2.1",
36
+ "@quatrain/storage": "^1.2.2",
37
37
  "fs-extra": "^11.2.0"
38
38
  },
39
39
  "scripts": {
@@ -6,9 +6,9 @@ import {
6
6
  StorageParameters,
7
7
  DownloadFileMetaType,
8
8
  } from '@quatrain/storage'
9
- import { Readable, Stream } from 'stream'
9
+ import { Readable, Stream } from 'node:stream'
10
10
  import { getSignedUrl } from '@aws-sdk/s3-request-presigner'
11
- import { createWriteStream } from 'fs'
11
+ import { createWriteStream } from 'node:fs'
12
12
  import {
13
13
  S3Client,
14
14
  PutObjectCommand,
@@ -141,7 +141,7 @@ export class S3StorageAdapter extends AbstractStorageAdapter {
141
141
  return destFile
142
142
  }
143
143
 
144
- async getUrl(file: FileType, expiresIn = 3600, action: any = 'read', extra: any = {}) {
144
+ async _getUrl(file: FileType, expiresIn = 3600, action: any = 'read', extra: any = {}) {
145
145
  const commandArgs: any = {
146
146
  Bucket: file.bucket,
147
147
  Key: encodeURI(file.ref),