@trayio/commons 4.43.0 → 4.45.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/dist/file/FakeFileStorage.js +1 -1
- package/dist/file/File.d.ts +0 -1
- package/dist/file/File.d.ts.map +1 -1
- package/dist/file/File.js +4 -9
- package/dist/file/FileStorage.abstract.test.d.ts.map +1 -1
- package/dist/file/FileStorage.abstract.test.js +1 -3
- package/dist/file/NodeFsFileStorage.d.ts +4 -2
- package/dist/file/NodeFsFileStorage.d.ts.map +1 -1
- package/dist/file/NodeFsFileStorage.integration.test.js +77 -1
- package/dist/file/NodeFsFileStorage.js +5 -4
- package/dist/http/Http.d.ts +2 -1
- package/dist/http/Http.d.ts.map +1 -1
- package/dist/http/Http.js +1 -0
- package/dist/http/HttpClient.abstract.test.d.ts.map +1 -1
- package/dist/http/HttpClient.abstract.test.js +6 -19
- package/package.json +1 -1
|
@@ -53,7 +53,7 @@ class FakeFileStorage {
|
|
|
53
53
|
createDirectory(key) {
|
|
54
54
|
return (0, function_1.pipe)(TE.fromEither(E.tryCatch(() => this.files.set(key, {
|
|
55
55
|
key,
|
|
56
|
-
metadata: {
|
|
56
|
+
metadata: {},
|
|
57
57
|
content: stream_1.Readable.from(''),
|
|
58
58
|
}), (error) => new Error(error))), TE.map(() => undefined));
|
|
59
59
|
}
|
package/dist/file/File.d.ts
CHANGED
package/dist/file/File.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"File.d.ts","sourceRoot":"","sources":["../../src/file/File.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,KAAK,CAAC,MAAM,OAAO,CAAC;AAC3B,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,4BA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AAK,EAAE,SAAS,CAAC,CAAC;IAClD,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;CAC3D"}
|
package/dist/file/File.js
CHANGED
|
@@ -25,12 +25,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.fileMetadataDescriptor = void 0;
|
|
27
27
|
const t = __importStar(require("io-ts"));
|
|
28
|
-
exports.fileMetadataDescriptor = t.
|
|
29
|
-
t.
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
t.partial({
|
|
33
|
-
size: t.number,
|
|
34
|
-
contentType: t.string,
|
|
35
|
-
}),
|
|
36
|
-
], 'FileMetadata');
|
|
28
|
+
exports.fileMetadataDescriptor = t.partial({
|
|
29
|
+
size: t.number,
|
|
30
|
+
contentType: t.string,
|
|
31
|
+
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileStorage.abstract.test.d.ts","sourceRoot":"","sources":["../../src/file/FileStorage.abstract.test.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,WAAW,EAAQ,MAAM,QAAQ,CAAC;AAE3C,eAAO,MAAM,eAAe,gBAAiB,WAAW,
|
|
1
|
+
{"version":3,"file":"FileStorage.abstract.test.d.ts","sourceRoot":"","sources":["../../src/file/FileStorage.abstract.test.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,WAAW,EAAQ,MAAM,QAAQ,CAAC;AAE3C,eAAO,MAAM,eAAe,gBAAiB,WAAW,SAwFvD,CAAC"}
|
|
@@ -45,9 +45,7 @@ const fileStorageTest = (fileStorage) => {
|
|
|
45
45
|
const fileName = `test-${(0, uuid_1.v4)()}.json`;
|
|
46
46
|
const file = {
|
|
47
47
|
key: fileName,
|
|
48
|
-
metadata: {
|
|
49
|
-
name: fileName,
|
|
50
|
-
},
|
|
48
|
+
metadata: {},
|
|
51
49
|
content: readableStream,
|
|
52
50
|
};
|
|
53
51
|
const writtenFile = await fileStorage.write(file, O.none)();
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import * as TE from 'fp-ts/lib/TaskEither';
|
|
3
3
|
import { Dirent } from 'fs';
|
|
4
|
+
import * as O from 'fp-ts/Option';
|
|
4
5
|
import { File, FileStorage, SharedUrl } from './File';
|
|
6
|
+
import { DynamicObject } from '../dynamictype/DynamicType';
|
|
5
7
|
export declare class NodeFsFileStorage implements FileStorage {
|
|
6
8
|
private basePath;
|
|
7
9
|
constructor(basePath?: string);
|
|
8
|
-
write(file: File): TE.TaskEither<Error, File>;
|
|
9
|
-
read(key: string
|
|
10
|
+
write(file: File, writeOptions?: O.Option<DynamicObject>): TE.TaskEither<Error, File>;
|
|
11
|
+
read(key: string): TE.TaskEither<Error, File>;
|
|
10
12
|
getSharedUrl(key: string): TE.TaskEither<Error, SharedUrl>;
|
|
11
13
|
delete(key: string): TE.TaskEither<Error, undefined>;
|
|
12
14
|
createDirectory(key: string): TE.TaskEither<Error, undefined>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NodeFsFileStorage.d.ts","sourceRoot":"","sources":["../../src/file/NodeFsFileStorage.ts"],"names":[],"mappings":";AAGA,OAAO,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAG3C,OAAO,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC;AAC5B,OAAO,EAAE,IAAI,EAAE,WAAW,EAAgB,SAAS,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"NodeFsFileStorage.d.ts","sourceRoot":"","sources":["../../src/file/NodeFsFileStorage.ts"],"names":[],"mappings":";AAGA,OAAO,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAG3C,OAAO,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC;AAC5B,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,WAAW,EAAgB,SAAS,EAAE,MAAM,QAAQ,CAAC;AAEpE,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAE3D,qBAAa,iBAAkB,YAAW,WAAW;IACxC,OAAO,CAAC,QAAQ;gBAAR,QAAQ,GAAE,MAAe;IAE7C,KAAK,CACJ,IAAI,EAAE,IAAI,EACV,YAAY,GAAE,CAAC,CAAC,MAAM,CAAC,aAAa,CAAU,GAC5C,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC;IAkB7B,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC;IAiB7C,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE,SAAS,CAAC;IAW1D,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE,SAAS,CAAC;IAYpD,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE,SAAS,CAAC;IAY7D,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC;CAW1D"}
|
|
@@ -1,7 +1,83 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
const stream_1 = require("stream");
|
|
27
|
+
const uuid_1 = require("uuid");
|
|
28
|
+
const O = __importStar(require("fp-ts/Option"));
|
|
29
|
+
const E = __importStar(require("fp-ts/Either"));
|
|
3
30
|
const FileStorage_abstract_test_1 = require("./FileStorage.abstract.test");
|
|
4
31
|
const NodeFsFileStorage_1 = require("./NodeFsFileStorage");
|
|
5
32
|
describe('NodeFsFileStorage Tests', () => {
|
|
6
|
-
|
|
33
|
+
const fileStorage = new NodeFsFileStorage_1.NodeFsFileStorage();
|
|
34
|
+
(0, FileStorage_abstract_test_1.fileStorageTest)(fileStorage);
|
|
35
|
+
it('should write, append, read and delete the file', async () => {
|
|
36
|
+
const fileContent = 'This is the initial text.';
|
|
37
|
+
const readableStream = new stream_1.Readable({
|
|
38
|
+
read() {
|
|
39
|
+
this.push(Buffer.from(fileContent));
|
|
40
|
+
this.push(null);
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
const fileName = `test-${(0, uuid_1.v4)()}.txt`;
|
|
44
|
+
const file = {
|
|
45
|
+
key: fileName,
|
|
46
|
+
metadata: {},
|
|
47
|
+
content: readableStream,
|
|
48
|
+
};
|
|
49
|
+
const writtenFile = await fileStorage.write(file, O.none)();
|
|
50
|
+
expect(writtenFile).toEqual(E.right(file));
|
|
51
|
+
const secondFileContent = ' And we continue to write.';
|
|
52
|
+
const appendReadableStream = new stream_1.Readable({
|
|
53
|
+
read() {
|
|
54
|
+
this.push(Buffer.from(secondFileContent));
|
|
55
|
+
this.push(null);
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
const appendFile = {
|
|
59
|
+
key: fileName,
|
|
60
|
+
metadata: {},
|
|
61
|
+
content: appendReadableStream,
|
|
62
|
+
};
|
|
63
|
+
const appendedFile = await fileStorage.write(appendFile, O.some({ flag: 'a' }))();
|
|
64
|
+
expect(appendedFile).toEqual(E.right(appendFile));
|
|
65
|
+
// When reading the full contents.
|
|
66
|
+
const read = await fileStorage.read(file.key)();
|
|
67
|
+
const readResponse = E.getOrElse(() => {
|
|
68
|
+
throw new Error('Expected right');
|
|
69
|
+
})(read);
|
|
70
|
+
let data = '';
|
|
71
|
+
await new Promise((resolve) => {
|
|
72
|
+
readResponse.content.on('data', (chunk) => {
|
|
73
|
+
data += chunk;
|
|
74
|
+
});
|
|
75
|
+
readResponse.content.on('end', () => {
|
|
76
|
+
resolve(undefined);
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
expect(Buffer.from(data).toString()).toStrictEqual(`${fileContent}${secondFileContent}`);
|
|
80
|
+
const deleted = await fileStorage.delete(file.key)();
|
|
81
|
+
expect(deleted).toEqual(E.right(undefined));
|
|
82
|
+
});
|
|
7
83
|
});
|
|
@@ -28,25 +28,26 @@ const fs = __importStar(require("fs/promises"));
|
|
|
28
28
|
const path = __importStar(require("path"));
|
|
29
29
|
const TE = __importStar(require("fp-ts/lib/TaskEither"));
|
|
30
30
|
const function_1 = require("fp-ts/lib/function");
|
|
31
|
+
const O = __importStar(require("fp-ts/Option"));
|
|
31
32
|
const Task_1 = require("../task/Task");
|
|
32
33
|
class NodeFsFileStorage {
|
|
33
34
|
basePath;
|
|
34
35
|
constructor(basePath = '/tmp') {
|
|
35
36
|
this.basePath = basePath;
|
|
36
37
|
}
|
|
37
|
-
write(file) {
|
|
38
|
+
write(file, writeOptions = O.none) {
|
|
38
39
|
const filePath = `${this.basePath}/${file.key}`;
|
|
39
|
-
const
|
|
40
|
+
const uploadOptions = O.toNullable(writeOptions);
|
|
41
|
+
const result = (0, Task_1.createTaskEitherFromPromiseWithSimpleError)(() => fs.writeFile(filePath, file.content, uploadOptions?.flag ? { flag: uploadOptions.flag } : {}));
|
|
40
42
|
return (0, function_1.pipe)(result, TE.map(() => file));
|
|
41
43
|
}
|
|
42
|
-
read(key
|
|
44
|
+
read(key) {
|
|
43
45
|
const filePath = `${this.basePath}/${key}`;
|
|
44
46
|
return TE.tryCatch(async () => {
|
|
45
47
|
const fileHandle = await fs.open(filePath, 'r');
|
|
46
48
|
const stat = await fs.stat(filePath);
|
|
47
49
|
const stream = fileHandle.createReadStream();
|
|
48
50
|
const metadata = {
|
|
49
|
-
name,
|
|
50
51
|
size: stat.size,
|
|
51
52
|
};
|
|
52
53
|
return { metadata, key: filePath, content: stream };
|
package/dist/http/Http.d.ts
CHANGED
|
@@ -47,7 +47,8 @@ export declare enum HttpHeader {
|
|
|
47
47
|
ContentType = "Content-Type",
|
|
48
48
|
Impersonation = "X-Tray-Admin-Impersonate",
|
|
49
49
|
UserAgent = "User-Agent",
|
|
50
|
-
ContentLength = "Content-Length"
|
|
50
|
+
ContentLength = "Content-Length",
|
|
51
|
+
ContentDisposition = "Content-Disposition"
|
|
51
52
|
}
|
|
52
53
|
export interface HttpHeadersInterface {
|
|
53
54
|
get: (headers: HttpHeaders, name: string) => O.Option<HttpHeaderValue>;
|
package/dist/http/Http.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Http.d.ts","sourceRoot":"","sources":["../../src/http/Http.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,CAAC,MAAM,kBAAkB,CAAC;AAEtC,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAClC,OAAO,EAAE,IAAI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CAAC;AAEF,eAAO,MAAM,eAAe,SACrB,eAAe,qCAEkC,CAAC"}
|
package/dist/http/Http.js
CHANGED
|
@@ -59,6 +59,7 @@ var HttpHeader;
|
|
|
59
59
|
HttpHeader["Impersonation"] = "X-Tray-Admin-Impersonate";
|
|
60
60
|
HttpHeader["UserAgent"] = "User-Agent";
|
|
61
61
|
HttpHeader["ContentLength"] = "Content-Length";
|
|
62
|
+
HttpHeader["ContentDisposition"] = "Content-Disposition";
|
|
62
63
|
})(HttpHeader || (exports.HttpHeader = HttpHeader = {}));
|
|
63
64
|
exports.HttpHeaders = {
|
|
64
65
|
get: (headers, name) => getHeader(headers, name),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HttpClient.abstract.test.d.ts","sourceRoot":"","sources":["../../src/http/HttpClient.abstract.test.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAM1C,wBAAgB,cAAc,CAAC,UAAU,EAAE,UAAU,
|
|
1
|
+
{"version":3,"file":"HttpClient.abstract.test.d.ts","sourceRoot":"","sources":["../../src/http/HttpClient.abstract.test.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAM1C,wBAAgB,cAAc,CAAC,UAAU,EAAE,UAAU,QAufpD"}
|
|
@@ -130,7 +130,6 @@ function httpClientTest(httpClient) {
|
|
|
130
130
|
const convertFormidableFileToTrayFile = (file) => ({
|
|
131
131
|
key: file.newFilename,
|
|
132
132
|
metadata: {
|
|
133
|
-
name: file.originalFilename ?? '',
|
|
134
133
|
size: file.size,
|
|
135
134
|
},
|
|
136
135
|
content: stream_1.Readable.from(file.filepath),
|
|
@@ -231,16 +230,12 @@ function httpClientTest(httpClient) {
|
|
|
231
230
|
await fileStorage.delete('file2')();
|
|
232
231
|
const file1 = await fileStorage.write({
|
|
233
232
|
key: 'file1',
|
|
234
|
-
metadata: {
|
|
235
|
-
name: 'file1',
|
|
236
|
-
},
|
|
233
|
+
metadata: {},
|
|
237
234
|
content: stream_1.Readable.from('file 1 content'),
|
|
238
235
|
})();
|
|
239
236
|
const file2 = await fileStorage.write({
|
|
240
237
|
key: 'file2',
|
|
241
|
-
metadata: {
|
|
242
|
-
name: 'file2',
|
|
243
|
-
},
|
|
238
|
+
metadata: {},
|
|
244
239
|
content: stream_1.Readable.from('file 2 content'),
|
|
245
240
|
})();
|
|
246
241
|
if (file1._tag === 'Left') {
|
|
@@ -257,16 +252,12 @@ function httpClientTest(httpClient) {
|
|
|
257
252
|
files: {
|
|
258
253
|
file1: {
|
|
259
254
|
key: 'file1',
|
|
260
|
-
metadata: {
|
|
261
|
-
name: 'file1',
|
|
262
|
-
},
|
|
255
|
+
metadata: {},
|
|
263
256
|
content: stream_1.Readable.from('Hello world'),
|
|
264
257
|
},
|
|
265
258
|
file2: {
|
|
266
259
|
key: 'file2',
|
|
267
|
-
metadata: {
|
|
268
|
-
name: 'file2',
|
|
269
|
-
},
|
|
260
|
+
metadata: {},
|
|
270
261
|
content: stream_1.Readable.from('Hello world'),
|
|
271
262
|
},
|
|
272
263
|
},
|
|
@@ -287,15 +278,11 @@ function httpClientTest(httpClient) {
|
|
|
287
278
|
files: expect.objectContaining({
|
|
288
279
|
file1: expect.objectContaining({
|
|
289
280
|
key: expect.any(String),
|
|
290
|
-
metadata: expect.objectContaining({
|
|
291
|
-
name: 'file1',
|
|
292
|
-
}),
|
|
281
|
+
metadata: expect.objectContaining({}),
|
|
293
282
|
}),
|
|
294
283
|
file2: expect.objectContaining({
|
|
295
284
|
key: expect.any(String),
|
|
296
|
-
metadata: expect.objectContaining({
|
|
297
|
-
name: 'file2',
|
|
298
|
-
}),
|
|
285
|
+
metadata: expect.objectContaining({}),
|
|
299
286
|
}),
|
|
300
287
|
}),
|
|
301
288
|
})));
|