@trayio/commons 5.21.0 → 5.22.0-unstable
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/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;AACtC,OAAO,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAE3C,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAElC,OAAO,EAAE,IAAI,EAAkB,WAAW,EAAE,MAAM,cAAc,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAgB3D,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,WAAW,CAAC;AAEjD,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,qBAAqB,GAAG,QAAQ,CAAC;AAE7C,MAAM,WAAW,iCAAiC;IACjD,MAAM,EAAE,CACP,KAAK,EAAE,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using dot notation for nested structures
|
|
94
94
|
const fields = extractFields(value);
|
|
95
95
|
return (0, function_1.pipe)(TE.sequenceArray(fileDescriptorPaths.map(({ path, descriptor }) => (0, function_1.pipe)(fileStorage.read(descriptor.key), TE.map((file) => ({
|
|
96
|
-
|
|
97
|
-
// This tells the server where to place the FileDescriptor in the reconstructed object
|
|
98
|
-
key: path.join('.'),
|
|
96
|
+
key: file.reference.key,
|
|
99
97
|
file: {
|
|
100
98
|
...file,
|
|
101
99
|
reference: {
|
|
@@ -168,8 +168,7 @@ describe('MultipartHttpRequestBody - E2E', () => {
|
|
|
168
168
|
}
|
|
169
169
|
const multipartBody = multipartResult.right;
|
|
170
170
|
// Verify the file was detected in the nested structure
|
|
171
|
-
|
|
172
|
-
expect(Object.keys(multipartBody.files)).toContain('imageContent.reference');
|
|
171
|
+
expect(Object.keys(multipartBody.files)).toContain('test-image-key');
|
|
173
172
|
expect(multipartBody.fields).toHaveProperty('fileName', 'test-image.png');
|
|
174
173
|
expect(multipartBody.fields).toHaveProperty('overrideIfPresent', 'true');
|
|
175
174
|
// 3. Send HTTP POST with multipart data
|
|
@@ -221,10 +220,9 @@ describe('MultipartHttpRequestBody - E2E', () => {
|
|
|
221
220
|
});
|
|
222
221
|
});
|
|
223
222
|
// 4. Verify server received the file correctly
|
|
224
|
-
// Files are now keyed by object path, not storage key
|
|
225
223
|
expect(response.files).toBeDefined();
|
|
226
|
-
expect(response.files['
|
|
227
|
-
const receivedFile = response.files['
|
|
224
|
+
expect(response.files['test-image-key']).toBeDefined();
|
|
225
|
+
const receivedFile = response.files['test-image-key'];
|
|
228
226
|
expect(receivedFile.content).toBe(originalContent);
|
|
229
227
|
expect(receivedFile.hash).toBe(originalHash);
|
|
230
228
|
// 5. Verify fields were sent correctly
|
|
@@ -277,10 +275,9 @@ describe('MultipartHttpRequestBody - E2E', () => {
|
|
|
277
275
|
}
|
|
278
276
|
const multipartBody = multipartResult.right;
|
|
279
277
|
// Verify both files were detected
|
|
280
|
-
// Files are now keyed by their object paths, not storage keys
|
|
281
278
|
expect(Object.keys(multipartBody.files)).toHaveLength(2);
|
|
282
|
-
expect(multipartBody.files['
|
|
283
|
-
expect(multipartBody.files['
|
|
279
|
+
expect(multipartBody.files['file-1']).toBeDefined();
|
|
280
|
+
expect(multipartBody.files['file-2']).toBeDefined();
|
|
284
281
|
// Send to server
|
|
285
282
|
// eslint-disable-next-line global-require
|
|
286
283
|
const FormData = require('form-data');
|
|
@@ -326,11 +323,10 @@ describe('MultipartHttpRequestBody - E2E', () => {
|
|
|
326
323
|
});
|
|
327
324
|
});
|
|
328
325
|
// Verify both files received correctly
|
|
329
|
-
|
|
330
|
-
expect(response.files['
|
|
331
|
-
expect(response.files['
|
|
332
|
-
expect(response.files['
|
|
333
|
-
expect(response.files['nested.deepFile.reference'].hash).toBe(hash2);
|
|
326
|
+
expect(response.files['file-1'].content).toBe(content1);
|
|
327
|
+
expect(response.files['file-1'].hash).toBe(hash1);
|
|
328
|
+
expect(response.files['file-2'].content).toBe(content2);
|
|
329
|
+
expect(response.files['file-2'].hash).toBe(hash2);
|
|
334
330
|
// eslint-disable-next-line no-console
|
|
335
331
|
console.log('✅ Multiple nested files successfully transferred!');
|
|
336
332
|
});
|
|
@@ -59,8 +59,7 @@ describe('MultipartHttpRequestBody.create', () => {
|
|
|
59
59
|
const result = await Http_1.MultipartHttpRequestBody.create({ file: fileDescriptor }, clientStorage)();
|
|
60
60
|
expect(result._tag).toBe('Right');
|
|
61
61
|
if (result._tag === 'Right') {
|
|
62
|
-
|
|
63
|
-
expect(Object.keys(result.right.files)).toContain('file');
|
|
62
|
+
expect(Object.keys(result.right.files)).toContain('root-file');
|
|
64
63
|
}
|
|
65
64
|
});
|
|
66
65
|
it('should detect FileDescriptor nested one level deep', async () => {
|
|
@@ -77,8 +76,7 @@ describe('MultipartHttpRequestBody.create', () => {
|
|
|
77
76
|
}, clientStorage)();
|
|
78
77
|
expect(result._tag).toBe('Right');
|
|
79
78
|
if (result._tag === 'Right') {
|
|
80
|
-
|
|
81
|
-
expect(Object.keys(result.right.files)).toContain('data.file');
|
|
79
|
+
expect(Object.keys(result.right.files)).toContain('nested-file');
|
|
82
80
|
}
|
|
83
81
|
});
|
|
84
82
|
it('should detect FileDescriptor nested multiple levels deep', async () => {
|
|
@@ -99,8 +97,7 @@ describe('MultipartHttpRequestBody.create', () => {
|
|
|
99
97
|
}, clientStorage)();
|
|
100
98
|
expect(result._tag).toBe('Right');
|
|
101
99
|
if (result._tag === 'Right') {
|
|
102
|
-
|
|
103
|
-
expect(Object.keys(result.right.files)).toContain('level1.level2.level3.file');
|
|
100
|
+
expect(Object.keys(result.right.files)).toContain('deep-file');
|
|
104
101
|
}
|
|
105
102
|
});
|
|
106
103
|
it('should detect multiple FileDescriptors at different levels', async () => {
|
|
@@ -125,9 +122,8 @@ describe('MultipartHttpRequestBody.create', () => {
|
|
|
125
122
|
expect(result._tag).toBe('Right');
|
|
126
123
|
if (result._tag === 'Right') {
|
|
127
124
|
expect(Object.keys(result.right.files)).toHaveLength(2);
|
|
128
|
-
|
|
129
|
-
expect(result.right.files['
|
|
130
|
-
expect(result.right.files['nested.deepFile']).toBeDefined();
|
|
125
|
+
expect(result.right.files['file-1']).toBeDefined();
|
|
126
|
+
expect(result.right.files['file-2']).toBeDefined();
|
|
131
127
|
}
|
|
132
128
|
});
|
|
133
129
|
});
|
|
@@ -231,8 +227,7 @@ describe('MultipartHttpRequestBody.create', () => {
|
|
|
231
227
|
const result = await Http_1.MultipartHttpRequestBody.create({ file: fileDescriptor }, clientStorage)();
|
|
232
228
|
expect(result._tag).toBe('Right');
|
|
233
229
|
if (result._tag === 'Right') {
|
|
234
|
-
|
|
235
|
-
const { file } = result.right.files;
|
|
230
|
+
const file = result.right.files['test-file'];
|
|
236
231
|
expect(file.reference.metadata.contentType).toBe('image/png');
|
|
237
232
|
expect(file.reference.metadata.name).toBe('image.png');
|
|
238
233
|
}
|
|
@@ -266,160 +261,9 @@ describe('MultipartHttpRequestBody.create', () => {
|
|
|
266
261
|
expect(result.right.fields.category).toBe('report');
|
|
267
262
|
expect(result.right.fields['metadata.author']).toBe('Alice');
|
|
268
263
|
expect(result.right.fields['metadata.tags']).toBe('important,confidential');
|
|
269
|
-
// Check file
|
|
270
|
-
expect(result.right.files.
|
|
271
|
-
expect(result.right.files.
|
|
272
|
-
}
|
|
273
|
-
});
|
|
274
|
-
});
|
|
275
|
-
describe('File Field Naming with Object Paths', () => {
|
|
276
|
-
it('should use object path (not file key) as the form field name for root-level files', async () => {
|
|
277
|
-
const fileDescriptor = {
|
|
278
|
-
_tag: 'FileDescriptor',
|
|
279
|
-
key: 'some-storage-key-123',
|
|
280
|
-
metadata: {
|
|
281
|
-
name: 'document.pdf',
|
|
282
|
-
size: 1024,
|
|
283
|
-
contentType: 'application/pdf',
|
|
284
|
-
},
|
|
285
|
-
};
|
|
286
|
-
await clientStorage.write({ reference: fileDescriptor, content: stream_1.Readable.from('file content') }, undefined)();
|
|
287
|
-
const result = await Http_1.MultipartHttpRequestBody.create({
|
|
288
|
-
file: fileDescriptor,
|
|
289
|
-
}, clientStorage)();
|
|
290
|
-
expect(result._tag).toBe('Right');
|
|
291
|
-
if (result._tag === 'Right') {
|
|
292
|
-
// The file should be keyed by the object path 'file', not the storage key
|
|
293
|
-
expect(Object.keys(result.right.files)).toContain('file');
|
|
294
|
-
expect(result.right.files['file']).toBeDefined();
|
|
295
|
-
}
|
|
296
|
-
});
|
|
297
|
-
it('should use nested object path as form field name for nested files', async () => {
|
|
298
|
-
const fileDescriptor = {
|
|
299
|
-
_tag: 'FileDescriptor',
|
|
300
|
-
key: 'storage-key-456',
|
|
301
|
-
metadata: {
|
|
302
|
-
name: 'attachment.png',
|
|
303
|
-
size: 2048,
|
|
304
|
-
contentType: 'image/png',
|
|
305
|
-
},
|
|
306
|
-
};
|
|
307
|
-
await clientStorage.write({ reference: fileDescriptor, content: stream_1.Readable.from('image data') }, undefined)();
|
|
308
|
-
const result = await Http_1.MultipartHttpRequestBody.create({
|
|
309
|
-
data: {
|
|
310
|
-
attachment: fileDescriptor,
|
|
311
|
-
},
|
|
312
|
-
}, clientStorage)();
|
|
313
|
-
expect(result._tag).toBe('Right');
|
|
314
|
-
if (result._tag === 'Right') {
|
|
315
|
-
// The file should be keyed by 'data.attachment', not the storage key
|
|
316
|
-
expect(Object.keys(result.right.files)).toContain('data.attachment');
|
|
317
|
-
expect(result.right.files['data.attachment']).toBeDefined();
|
|
318
|
-
}
|
|
319
|
-
});
|
|
320
|
-
it('should use deeply nested object path as form field name', async () => {
|
|
321
|
-
const fileDescriptor = {
|
|
322
|
-
_tag: 'FileDescriptor',
|
|
323
|
-
key: 'deep-storage-key',
|
|
324
|
-
metadata: {
|
|
325
|
-
name: 'report.pdf',
|
|
326
|
-
size: 5000,
|
|
327
|
-
contentType: 'application/pdf',
|
|
328
|
-
},
|
|
329
|
-
};
|
|
330
|
-
await clientStorage.write({ reference: fileDescriptor, content: stream_1.Readable.from('report content') }, undefined)();
|
|
331
|
-
const result = await Http_1.MultipartHttpRequestBody.create({
|
|
332
|
-
project: {
|
|
333
|
-
documents: {
|
|
334
|
-
reports: {
|
|
335
|
-
annual: fileDescriptor,
|
|
336
|
-
},
|
|
337
|
-
},
|
|
338
|
-
},
|
|
339
|
-
}, clientStorage)();
|
|
340
|
-
expect(result._tag).toBe('Right');
|
|
341
|
-
if (result._tag === 'Right') {
|
|
342
|
-
// The file should be keyed by the full object path
|
|
343
|
-
expect(Object.keys(result.right.files)).toContain('project.documents.reports.annual');
|
|
344
|
-
expect(result.right.files['project.documents.reports.annual']).toBeDefined();
|
|
345
|
-
}
|
|
346
|
-
});
|
|
347
|
-
it('should use correct object paths for multiple files at different levels', async () => {
|
|
348
|
-
const file1 = {
|
|
349
|
-
_tag: 'FileDescriptor',
|
|
350
|
-
key: 'key-1',
|
|
351
|
-
metadata: {
|
|
352
|
-
name: 'file1.txt',
|
|
353
|
-
size: 100,
|
|
354
|
-
contentType: 'text/plain',
|
|
355
|
-
},
|
|
356
|
-
};
|
|
357
|
-
const file2 = {
|
|
358
|
-
_tag: 'FileDescriptor',
|
|
359
|
-
key: 'key-2',
|
|
360
|
-
metadata: {
|
|
361
|
-
name: 'file2.txt',
|
|
362
|
-
size: 200,
|
|
363
|
-
contentType: 'text/plain',
|
|
364
|
-
},
|
|
365
|
-
};
|
|
366
|
-
const file3 = {
|
|
367
|
-
_tag: 'FileDescriptor',
|
|
368
|
-
key: 'key-3',
|
|
369
|
-
metadata: {
|
|
370
|
-
name: 'file3.txt',
|
|
371
|
-
size: 300,
|
|
372
|
-
contentType: 'text/plain',
|
|
373
|
-
},
|
|
374
|
-
};
|
|
375
|
-
await clientStorage.write({ reference: file1, content: stream_1.Readable.from('content1') }, undefined)();
|
|
376
|
-
await clientStorage.write({ reference: file2, content: stream_1.Readable.from('content2') }, undefined)();
|
|
377
|
-
await clientStorage.write({ reference: file3, content: stream_1.Readable.from('content3') }, undefined)();
|
|
378
|
-
const result = await Http_1.MultipartHttpRequestBody.create({
|
|
379
|
-
avatar: file1,
|
|
380
|
-
data: {
|
|
381
|
-
document: file2,
|
|
382
|
-
nested: {
|
|
383
|
-
attachment: file3,
|
|
384
|
-
},
|
|
385
|
-
},
|
|
386
|
-
}, clientStorage)();
|
|
387
|
-
expect(result._tag).toBe('Right');
|
|
388
|
-
if (result._tag === 'Right') {
|
|
389
|
-
// Each file should be keyed by its object path, not its storage key
|
|
390
|
-
expect(Object.keys(result.right.files)).toHaveLength(3);
|
|
391
|
-
expect(result.right.files['avatar']).toBeDefined();
|
|
392
|
-
expect(result.right.files['data.document']).toBeDefined();
|
|
393
|
-
expect(result.right.files['data.nested.attachment']).toBeDefined();
|
|
394
|
-
// Verify storage keys are NOT used as field names
|
|
395
|
-
expect(result.right.files['key-1']).toBeUndefined();
|
|
396
|
-
expect(result.right.files['key-2']).toBeUndefined();
|
|
397
|
-
expect(result.right.files['key-3']).toBeUndefined();
|
|
398
|
-
}
|
|
399
|
-
});
|
|
400
|
-
it('should preserve metadata when using object path as field name', async () => {
|
|
401
|
-
const fileDescriptor = {
|
|
402
|
-
_tag: 'FileDescriptor',
|
|
403
|
-
key: 'some-key',
|
|
404
|
-
metadata: {
|
|
405
|
-
name: 'important.pdf',
|
|
406
|
-
size: 999,
|
|
407
|
-
contentType: 'application/pdf',
|
|
408
|
-
},
|
|
409
|
-
};
|
|
410
|
-
await clientStorage.write({ reference: fileDescriptor, content: stream_1.Readable.from('pdf data') }, undefined)();
|
|
411
|
-
const result = await Http_1.MultipartHttpRequestBody.create({
|
|
412
|
-
nested: {
|
|
413
|
-
file: fileDescriptor,
|
|
414
|
-
},
|
|
415
|
-
}, clientStorage)();
|
|
416
|
-
expect(result._tag).toBe('Right');
|
|
417
|
-
if (result._tag === 'Right') {
|
|
418
|
-
const file = result.right.files['nested.file'];
|
|
419
|
-
expect(file).toBeDefined();
|
|
420
|
-
expect(file.reference.metadata.name).toBe('important.pdf');
|
|
421
|
-
expect(file.reference.metadata.size).toBe(999);
|
|
422
|
-
expect(file.reference.metadata.contentType).toBe('application/pdf');
|
|
264
|
+
// Check file
|
|
265
|
+
expect(result.right.files.doc).toBeDefined();
|
|
266
|
+
expect(result.right.files.doc.reference.metadata.contentType).toBe('application/pdf');
|
|
423
267
|
}
|
|
424
268
|
});
|
|
425
269
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trayio/commons",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.22.0-unstable",
|
|
4
4
|
"description": "Extensions to the standard/core libraries and basic features",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./*": "./dist/*.js"
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"io-ts": "2.2.20",
|
|
30
30
|
"io-ts-reporters": "2.0.1",
|
|
31
31
|
"io-ts-types": "0.5.19",
|
|
32
|
-
"lodash": "4.18.
|
|
32
|
+
"lodash": "4.18.1",
|
|
33
33
|
"mime-types": "^2.1.35",
|
|
34
34
|
"monocle-ts": "2.3.13",
|
|
35
35
|
"newtype-ts": "0.3.5",
|
|
@@ -46,5 +46,6 @@
|
|
|
46
46
|
},
|
|
47
47
|
"files": [
|
|
48
48
|
"/dist"
|
|
49
|
-
]
|
|
49
|
+
],
|
|
50
|
+
"stableVersion": "0.0.0"
|
|
50
51
|
}
|