@trayio/commons 2.5.0 → 2.6.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/File.d.ts +11 -3
- package/dist/file/File.d.ts.map +1 -1
- package/dist/file/File.js +9 -3
- package/dist/file/FileStorage.abstract.test.d.ts.map +1 -1
- package/dist/file/FileStorage.abstract.test.js +15 -4
- package/dist/file/NodeFsFileStorage.d.ts +4 -3
- package/dist/file/NodeFsFileStorage.d.ts.map +1 -1
- package/dist/file/NodeFsFileStorage.js +18 -7
- package/dist/http/Http.d.ts +2 -2
- package/dist/http/Http.d.ts.map +1 -1
- package/dist/http/HttpClient.abstract.test.d.ts.map +1 -1
- package/dist/http/HttpClient.abstract.test.js +31 -6
- package/package.json +2 -2
package/dist/file/File.d.ts
CHANGED
|
@@ -3,16 +3,24 @@ import { Readable } from 'stream';
|
|
|
3
3
|
import { TaskEither } from 'fp-ts/TaskEither';
|
|
4
4
|
import * as t from 'io-ts';
|
|
5
5
|
export type FileMetadata = {
|
|
6
|
-
|
|
6
|
+
name: string;
|
|
7
|
+
size?: number;
|
|
8
|
+
contentType?: string;
|
|
7
9
|
};
|
|
8
10
|
export declare const fileMetadataDescriptor: t.Type<FileMetadata, unknown>;
|
|
9
11
|
export type File = {
|
|
12
|
+
key: string;
|
|
10
13
|
metadata: FileMetadata;
|
|
11
14
|
content: Readable;
|
|
12
15
|
};
|
|
16
|
+
export type SharedUrl = {
|
|
17
|
+
url: string;
|
|
18
|
+
expires?: number;
|
|
19
|
+
};
|
|
13
20
|
export interface FileStorage {
|
|
14
|
-
write(file: File): TaskEither<Error,
|
|
15
|
-
read(key: string): TaskEither<Error, File>;
|
|
21
|
+
write(file: File): TaskEither<Error, File>;
|
|
22
|
+
read(key: string, name?: string): TaskEither<Error, File>;
|
|
23
|
+
getSharedUrl(key: string): TaskEither<Error, SharedUrl>;
|
|
16
24
|
delete(key: string): TaskEither<Error, undefined>;
|
|
17
25
|
}
|
|
18
26
|
//# sourceMappingURL=File.d.ts.map
|
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;AAE3B,MAAM,MAAM,YAAY,GAAG;IAC1B,
|
|
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;AAE3B,MAAM,MAAM,YAAY,GAAG;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AACF,eAAO,MAAM,sBAAsB,EAAE,CAAC,CAAC,IAAI,CAAC,YAAY,EAAE,OAAO,CAY/D,CAAC;AAKH,MAAM,MAAM,IAAI,GAAG;IAElB,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,YAAY,CAAC;IACvB,OAAO,EAAE,QAAQ,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,WAAW,WAAW;IAC3B,KAAK,CAAC,IAAI,EAAE,IAAI,GAAG,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IAC3C,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IAC1D,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;IACxD,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;CAClD"}
|
package/dist/file/File.js
CHANGED
|
@@ -25,6 +25,12 @@ 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
|
-
|
|
30
|
-
|
|
28
|
+
exports.fileMetadataDescriptor = t.intersection([
|
|
29
|
+
t.type({
|
|
30
|
+
name: t.string,
|
|
31
|
+
}),
|
|
32
|
+
t.partial({
|
|
33
|
+
size: t.number,
|
|
34
|
+
contentType: t.string,
|
|
35
|
+
}),
|
|
36
|
+
], 'FileMetadata');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileStorage.abstract.test.d.ts","sourceRoot":"","sources":["../../src/file/FileStorage.abstract.test.ts"],"names":[],"mappings":"AAIA,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":"AAIA,OAAO,EAAE,WAAW,EAAQ,MAAM,QAAQ,CAAC;AAE3C,eAAO,MAAM,eAAe,gBAAiB,WAAW,SA0FvD,CAAC"}
|
|
@@ -50,15 +50,26 @@ const fileStorageTest = (fileStorage) => {
|
|
|
50
50
|
this.push(null);
|
|
51
51
|
},
|
|
52
52
|
});
|
|
53
|
+
const fileName = `test-${(0, uuid_1.v4)()}.json`;
|
|
53
54
|
const file = {
|
|
55
|
+
key: fileName,
|
|
54
56
|
metadata: {
|
|
55
|
-
|
|
57
|
+
name: fileName,
|
|
56
58
|
},
|
|
57
59
|
content: readableStream,
|
|
58
60
|
};
|
|
59
61
|
const writtenFile = yield fileStorage.write(file)();
|
|
60
|
-
expect(writtenFile).toEqual(E.right(
|
|
61
|
-
const
|
|
62
|
+
expect(writtenFile).toEqual(E.right(file));
|
|
63
|
+
const sharedUrl = yield fileStorage.getSharedUrl(file.key)();
|
|
64
|
+
expect(sharedUrl).toEqual(E.right(expect.objectContaining({
|
|
65
|
+
url: expect.any(String),
|
|
66
|
+
})));
|
|
67
|
+
if (E.isRight(sharedUrl)) {
|
|
68
|
+
if (typeof sharedUrl.right.expires !== 'undefined') {
|
|
69
|
+
expect(sharedUrl.right.expires).toEqual(expect.any(Number));
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
const read = yield fileStorage.read(file.key)();
|
|
62
73
|
const readResponse = E.getOrElse(() => {
|
|
63
74
|
throw new Error('Expected right');
|
|
64
75
|
})(read);
|
|
@@ -76,7 +87,7 @@ const fileStorageTest = (fileStorage) => {
|
|
|
76
87
|
throw new Error('failed to deserialise stream contents');
|
|
77
88
|
}
|
|
78
89
|
expect(deserializedData.right).toStrictEqual(fileContent);
|
|
79
|
-
const deleted = yield fileStorage.delete(file.
|
|
90
|
+
const deleted = yield fileStorage.delete(file.key)();
|
|
80
91
|
expect(deleted).toEqual(E.right(undefined));
|
|
81
92
|
}));
|
|
82
93
|
});
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import * as TE from 'fp-ts/lib/TaskEither';
|
|
2
|
-
import { File, FileStorage } from './File';
|
|
2
|
+
import { File, FileStorage, SharedUrl } from './File';
|
|
3
3
|
export declare class NodeFsFileStorage implements FileStorage {
|
|
4
4
|
private basePath;
|
|
5
5
|
constructor(basePath?: string);
|
|
6
|
-
write(file: File): TE.TaskEither<Error,
|
|
7
|
-
read(key: string): TE.TaskEither<Error, File>;
|
|
6
|
+
write(file: File): TE.TaskEither<Error, File>;
|
|
7
|
+
read(key: string, name?: string): TE.TaskEither<Error, File>;
|
|
8
|
+
getSharedUrl(key: string): TE.TaskEither<Error, SharedUrl>;
|
|
8
9
|
delete(key: string): TE.TaskEither<Error, undefined>;
|
|
9
10
|
}
|
|
10
11
|
//# sourceMappingURL=NodeFsFileStorage.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NodeFsFileStorage.d.ts","sourceRoot":"","sources":["../../src/file/NodeFsFileStorage.ts"],"names":[],"mappings":"
|
|
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,IAAI,EAAE,WAAW,EAAgB,SAAS,EAAE,MAAM,QAAQ,CAAC;AAGpE,qBAAa,iBAAkB,YAAW,WAAW;IACxC,OAAO,CAAC,QAAQ;gBAAR,QAAQ,GAAE,MAAe;IAE7C,KAAK,CAAC,IAAI,EAAE,IAAI,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC;IAa7C,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,GAAE,MAAY,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC;IAkBjE,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;CAWpD"}
|
|
@@ -33,8 +33,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
33
33
|
};
|
|
34
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
35
|
exports.NodeFsFileStorage = void 0;
|
|
36
|
-
const TE = __importStar(require("fp-ts/lib/TaskEither"));
|
|
37
36
|
const fs = __importStar(require("fs/promises"));
|
|
37
|
+
const path = __importStar(require("path"));
|
|
38
|
+
const TE = __importStar(require("fp-ts/lib/TaskEither"));
|
|
38
39
|
const function_1 = require("fp-ts/lib/function");
|
|
39
40
|
const Task_1 = require("../task/Task");
|
|
40
41
|
class NodeFsFileStorage {
|
|
@@ -42,19 +43,29 @@ class NodeFsFileStorage {
|
|
|
42
43
|
this.basePath = basePath;
|
|
43
44
|
}
|
|
44
45
|
write(file) {
|
|
45
|
-
const
|
|
46
|
-
const result = (0, Task_1.createTaskEitherFromPromiseWithSimpleError)(() => fs.writeFile(
|
|
47
|
-
return (0, function_1.pipe)(result, TE.map(() =>
|
|
46
|
+
const filePath = `${this.basePath}/${file.key}`;
|
|
47
|
+
const result = (0, Task_1.createTaskEitherFromPromiseWithSimpleError)(() => fs.writeFile(filePath, file.content));
|
|
48
|
+
return (0, function_1.pipe)(result, TE.map(() => file));
|
|
48
49
|
}
|
|
49
|
-
read(key) {
|
|
50
|
+
read(key, name = key) {
|
|
50
51
|
const filePath = `${this.basePath}/${key}`;
|
|
51
52
|
return TE.tryCatch(() => __awaiter(this, void 0, void 0, function* () {
|
|
52
53
|
const fileHandle = yield fs.open(filePath, 'r');
|
|
54
|
+
const stat = yield fs.stat(filePath);
|
|
53
55
|
const stream = fileHandle.createReadStream();
|
|
54
56
|
const metadata = {
|
|
55
|
-
|
|
57
|
+
name,
|
|
58
|
+
size: stat.size,
|
|
56
59
|
};
|
|
57
|
-
return { metadata, content: stream };
|
|
60
|
+
return { metadata, key: filePath, content: stream };
|
|
61
|
+
}), (reason) => new Error(String(reason)));
|
|
62
|
+
}
|
|
63
|
+
getSharedUrl(key) {
|
|
64
|
+
const filePath = `${this.basePath}/${key}`;
|
|
65
|
+
return TE.tryCatch(() => __awaiter(this, void 0, void 0, function* () {
|
|
66
|
+
return ({
|
|
67
|
+
url: path.resolve(filePath),
|
|
68
|
+
});
|
|
58
69
|
}), (reason) => new Error(String(reason)));
|
|
59
70
|
}
|
|
60
71
|
delete(key) {
|
package/dist/http/Http.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import * as O from 'fp-ts/lib/Option';
|
|
3
3
|
import { Readable } from 'stream';
|
|
4
|
-
import {
|
|
4
|
+
import { File } from '../file/File';
|
|
5
5
|
import { SerializationFormat } from '../serialization/Serialization';
|
|
6
6
|
export type HttpHeaderValue = string | string[];
|
|
7
7
|
export type HttpHeaders = Record<string, HttpHeaderValue | HttpContentType>;
|
|
@@ -11,7 +11,7 @@ export type HttpQueryString = Record<string, HttpQueryStringValue>;
|
|
|
11
11
|
export type RegularHttpRequestBody = Readable;
|
|
12
12
|
export type MultipartHttpRequestBody = {
|
|
13
13
|
fields: Record<string, string>;
|
|
14
|
-
files: Record<string,
|
|
14
|
+
files: Record<string, File>;
|
|
15
15
|
};
|
|
16
16
|
export type HttpRequestBody = RegularHttpRequestBody | MultipartHttpRequestBody;
|
|
17
17
|
export type HttpRequest = {
|
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,
|
|
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,EAAE,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAOrE,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,MAAM,EAAE,CAAC;AAEhD,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,eAAe,GAAG,eAAe,CAAC,CAAC;AAE5E,MAAM,MAAM,0BAA0B,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAEnE,MAAM,MAAM,oBAAoB,GAC7B,0BAA0B,GAC1B,0BAA0B,EAAE,CAAC;AAEhC,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC;AAEnE,MAAM,MAAM,sBAAsB,GAAG,QAAQ,CAAC;AAE9C,MAAM,MAAM,wBAAwB,GAAG;IACtC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,sBAAsB,GAAG,wBAAwB,CAAC;AAEhF,MAAM,MAAM,WAAW,GAAG;IACzB,OAAO,EAAE,WAAW,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC,WAAW,EAAE,eAAe,CAAC;IAC7B,IAAI,EAAE,eAAe,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,WAAW,CAAC;IACrB,IAAI,EAAE,QAAQ,CAAC;CACf,CAAC;AAEF,oBAAY,UAAU;IACrB,GAAG,QAAQ;IACX,GAAG,QAAQ;IACX,IAAI,SAAS;IACb,KAAK,UAAU;IACf,MAAM,WAAW;CACjB;AAED,oBAAY,eAAe;IAC1B,IAAI,qBAAqB;IACzB,WAAW,6BAA6B;IACxC,oBAAoB,wBAAwB;IAC5C,IAAI,eAAe;CACnB;AAED,oBAAY,UAAU;IACrB,aAAa,kBAAkB;IAC/B,WAAW,iBAAiB;IAC5B,aAAa,6BAA6B;IAC1C,SAAS,eAAe;CACxB;AAED,MAAM,WAAW,oBAAoB;IACpC,GAAG,EAAE,CAAC,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;IACvE,kBAAkB,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;CAC/D;AAED,eAAO,MAAM,WAAW,EAAE,oBAYzB,CAAC;AAEF,eAAO,MAAM,oCAAoC,EAAE,MAAM,CACxD,mBAAmB,EACnB,eAAe,CAGf,CAAC;AAEF,eAAO,MAAM,eAAe,SACrB,eAAe,qCAEkC,CAAC"}
|
|
@@ -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,QAogBpD"}
|
|
@@ -48,6 +48,7 @@ const Task_1 = require("../task/Task");
|
|
|
48
48
|
const JsonSerialization_1 = require("../serialization/JsonSerialization");
|
|
49
49
|
const TypeCodec_1 = require("../codec/TypeCodec");
|
|
50
50
|
const Http_1 = require("./Http");
|
|
51
|
+
const File_1 = require("../file/File");
|
|
51
52
|
const NodeFsFileStorage_1 = require("../file/NodeFsFileStorage");
|
|
52
53
|
const BufferExtensions_1 = require("../buffer/BufferExtensions");
|
|
53
54
|
function httpClientTest(httpClient) {
|
|
@@ -60,10 +61,13 @@ function httpClientTest(httpClient) {
|
|
|
60
61
|
strField: t.string,
|
|
61
62
|
intField: t.number,
|
|
62
63
|
}));
|
|
64
|
+
const ReadableCodec = new t.Type('Readable', (input) => input instanceof stream_1.Readable, (input, ctx) => input instanceof stream_1.Readable ? t.success(input) : t.failure(input, ctx), (input) => input);
|
|
63
65
|
const testMultiPartBodyTypeCodec = TypeCodec_1.TypeCodec.fromDescriptor(t.type({
|
|
64
66
|
fields: t.record(t.string, t.string),
|
|
65
67
|
files: t.record(t.string, t.type({
|
|
66
68
|
key: t.string,
|
|
69
|
+
metadata: File_1.fileMetadataDescriptor,
|
|
70
|
+
content: t.any,
|
|
67
71
|
})),
|
|
68
72
|
}));
|
|
69
73
|
const testInputCodec = TypeCodec_1.TypeCodec.fromDescriptor(t.type({
|
|
@@ -122,7 +126,7 @@ function httpClientTest(httpClient) {
|
|
|
122
126
|
const flattenFiles = (files) => {
|
|
123
127
|
const flattenedFiles = {};
|
|
124
128
|
Object.entries(files)
|
|
125
|
-
.filter(([
|
|
129
|
+
.filter(([_key, file]) => file !== null)
|
|
126
130
|
.forEach(([key, file]) => {
|
|
127
131
|
if (Array.isArray(file) && file.length > 1) {
|
|
128
132
|
throw new Error(`Field ${key} has more than one file and is currently not supported`);
|
|
@@ -137,7 +141,12 @@ function httpClientTest(httpClient) {
|
|
|
137
141
|
const convertFormidableFileToTrayFile = (file) => {
|
|
138
142
|
var _a;
|
|
139
143
|
return ({
|
|
140
|
-
key:
|
|
144
|
+
key: file.newFilename,
|
|
145
|
+
metadata: {
|
|
146
|
+
name: (_a = file.originalFilename) !== null && _a !== void 0 ? _a : '',
|
|
147
|
+
size: file.size,
|
|
148
|
+
},
|
|
149
|
+
content: stream_1.Readable.from(file.filepath),
|
|
141
150
|
});
|
|
142
151
|
};
|
|
143
152
|
const requestListener = (req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -236,14 +245,16 @@ function httpClientTest(httpClient) {
|
|
|
236
245
|
yield fileStorage.delete('file1')();
|
|
237
246
|
yield fileStorage.delete('file2')();
|
|
238
247
|
const file1 = yield fileStorage.write({
|
|
248
|
+
key: 'file1',
|
|
239
249
|
metadata: {
|
|
240
|
-
|
|
250
|
+
name: 'file1',
|
|
241
251
|
},
|
|
242
252
|
content: stream_1.Readable.from('file 1 content'),
|
|
243
253
|
})();
|
|
244
254
|
const file2 = yield fileStorage.write({
|
|
255
|
+
key: 'file2',
|
|
245
256
|
metadata: {
|
|
246
|
-
|
|
257
|
+
name: 'file2',
|
|
247
258
|
},
|
|
248
259
|
content: stream_1.Readable.from('file 2 content'),
|
|
249
260
|
})();
|
|
@@ -261,9 +272,17 @@ function httpClientTest(httpClient) {
|
|
|
261
272
|
files: {
|
|
262
273
|
file1: {
|
|
263
274
|
key: 'file1',
|
|
275
|
+
metadata: {
|
|
276
|
+
name: 'file1',
|
|
277
|
+
},
|
|
278
|
+
content: stream_1.Readable.from('Hello world'),
|
|
264
279
|
},
|
|
265
280
|
file2: {
|
|
266
281
|
key: 'file2',
|
|
282
|
+
metadata: {
|
|
283
|
+
name: 'file2',
|
|
284
|
+
},
|
|
285
|
+
content: stream_1.Readable.from('Hello world'),
|
|
267
286
|
},
|
|
268
287
|
},
|
|
269
288
|
};
|
|
@@ -282,10 +301,16 @@ function httpClientTest(httpClient) {
|
|
|
282
301
|
fields: testInput.fields,
|
|
283
302
|
files: expect.objectContaining({
|
|
284
303
|
file1: expect.objectContaining({
|
|
285
|
-
key:
|
|
304
|
+
key: expect.any(String),
|
|
305
|
+
metadata: expect.objectContaining({
|
|
306
|
+
name: 'file1',
|
|
307
|
+
}),
|
|
286
308
|
}),
|
|
287
309
|
file2: expect.objectContaining({
|
|
288
|
-
key:
|
|
310
|
+
key: expect.any(String),
|
|
311
|
+
metadata: expect.objectContaining({
|
|
312
|
+
name: 'file2',
|
|
313
|
+
}),
|
|
289
314
|
}),
|
|
290
315
|
}),
|
|
291
316
|
})));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trayio/commons",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.6.0",
|
|
4
4
|
"description": "Extensions to the standard/core libraries and basic features",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./*": "./dist/*.js"
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"@types/uuid": "9.0.2",
|
|
20
20
|
"formidable": "^3.5.1",
|
|
21
21
|
"fp-ts": "2.12.3",
|
|
22
|
-
"io-ts": "2.2.
|
|
22
|
+
"io-ts": "2.2.20",
|
|
23
23
|
"io-ts-types": "0.5.19",
|
|
24
24
|
"lodash": "4.17.21",
|
|
25
25
|
"monocle-ts": "2.3.13",
|