@devrev/ts-adaas 1.15.3-beta.5 → 1.16.1-beta.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.
@@ -1 +1 @@
1
- {"version":3,"file":"attachments-streaming-pool.d.ts","sourceRoot":"","sources":["../../src/attachments-streaming/attachments-streaming-pool.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,2BAA2B,EAC5B,MAAM,UAAU,CAAC;AAElB,OAAO,EAAE,8BAA8B,EAAE,MAAM,yCAAyC,CAAC;AAGzF,qBAAa,wBAAwB,CAAC,cAAc;IAClD,OAAO,CAAC,OAAO,CAAgC;IAC/C,OAAO,CAAC,WAAW,CAAyB;IAC5C,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,KAAK,CAAqB;IAClC,OAAO,CAAC,MAAM,CAA4C;IAE1D,OAAO,CAAC,mBAAmB,CAAa;IACxC,OAAO,CAAC,QAAQ,CAAC,wBAAwB,CAAM;gBAEnC,EACV,OAAO,EACP,WAAW,EACX,SAAc,EACd,MAAM,GACP,EAAE,8BAA8B,CAAC,cAAc,CAAC;YAQnC,cAAc;IAS5B;;;;;OAKG;IAEH,OAAO,CAAC,2BAA2B;IAsB7B,SAAS,IAAI,OAAO,CAAC,2BAA2B,CAAC;IA8CjD,kBAAkB;CAkFzB"}
1
+ {"version":3,"file":"attachments-streaming-pool.d.ts","sourceRoot":"","sources":["../../src/attachments-streaming/attachments-streaming-pool.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,2BAA2B,EAC5B,MAAM,UAAU,CAAC;AAElB,OAAO,EAAE,8BAA8B,EAAE,MAAM,yCAAyC,CAAC;AAGzF,qBAAa,wBAAwB,CAAC,cAAc;IAClD,OAAO,CAAC,OAAO,CAAgC;IAC/C,OAAO,CAAC,WAAW,CAAyB;IAC5C,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,KAAK,CAAqB;IAClC,OAAO,CAAC,MAAM,CAA4C;IAE1D,OAAO,CAAC,mBAAmB,CAAa;IACxC,OAAO,CAAC,QAAQ,CAAC,wBAAwB,CAAM;gBAEnC,EACV,OAAO,EACP,WAAW,EACX,SAAc,EACd,MAAM,GACP,EAAE,8BAA8B,CAAC,cAAc,CAAC;YAQnC,cAAc;IAS5B;;;;;OAKG;IAEH,OAAO,CAAC,2BAA2B;IAsB7B,SAAS,IAAI,OAAO,CAAC,2BAA2B,CAAC;IA8CjD,kBAAkB;CA0FzB"}
@@ -110,7 +110,10 @@ class AttachmentsStreamingPool {
110
110
  const fileSizeInfo = response.error.fileSize
111
111
  ? `and size ${response.error.fileSize} bytes `
112
112
  : '';
113
- console.warn(`Skipping attachment with ID ${attachment.id} with extension ${fileExtension} ${fileSizeInfo}due to error returned by the stream function`, response.error.message);
113
+ const contentTypeInfo = attachment.content_type
114
+ ? `and content_type ${attachment.content_type} `
115
+ : '';
116
+ console.warn(`Skipping attachment with ID ${attachment.id} with extension ${fileExtension} ${fileSizeInfo}${contentTypeInfo}due to error returned by the stream function`, response.error.message);
114
117
  await this.updateProgress();
115
118
  continue;
116
119
  }
@@ -122,7 +125,10 @@ class AttachmentsStreamingPool {
122
125
  }
123
126
  catch (error) {
124
127
  const fileExtension = attachment.file_name.split('.').pop() || '';
125
- console.warn(`Skipping attachment with ID ${attachment.id} with extension ${fileExtension} due to error in processAttachment function`, error);
128
+ const contentTypeInfo = attachment.content_type
129
+ ? ` and content_type ${attachment.content_type}`
130
+ : '';
131
+ console.warn(`Skipping attachment with ID ${attachment.id} with extension ${fileExtension}${contentTypeInfo} due to error in processAttachment function`, error);
126
132
  await this.updateProgress();
127
133
  }
128
134
  }
@@ -330,6 +330,117 @@ describe(attachments_streaming_pool_1.AttachmentsStreamingPool.name, () => {
330
330
  await pool.streamAll();
331
331
  expect(mockAdapter.processAttachment).toHaveBeenCalledTimes(3);
332
332
  });
333
+ describe('content_type handling', () => {
334
+ it('should pass attachment with content_type to processAttachment', async () => {
335
+ mockAdapter.processAttachment.mockResolvedValue({});
336
+ const attachmentWithContentType = {
337
+ id: 'attachment-ct',
338
+ url: 'https://example.com/report.pdf',
339
+ file_name: 'report.pdf',
340
+ parent_id: 'parent-ct',
341
+ content_type: 'application/pdf',
342
+ };
343
+ const pool = new attachments_streaming_pool_1.AttachmentsStreamingPool({
344
+ adapter: mockAdapter,
345
+ attachments: [attachmentWithContentType],
346
+ stream: mockStream,
347
+ });
348
+ await pool.streamAll();
349
+ expect(mockAdapter.processAttachment).toHaveBeenCalledWith(attachmentWithContentType, mockStream);
350
+ expect(mockAdapter.processAttachment.mock.calls[0][0].content_type).toBe('application/pdf');
351
+ });
352
+ it('should handle mixed attachments with and without content_type', async () => {
353
+ mockAdapter.processAttachment.mockResolvedValue({});
354
+ const mixedAttachments = [
355
+ {
356
+ id: 'att-with-ct',
357
+ url: 'https://example.com/image.png',
358
+ file_name: 'image.png',
359
+ parent_id: 'parent-1',
360
+ content_type: 'image/png',
361
+ },
362
+ {
363
+ id: 'att-without-ct',
364
+ url: 'https://example.com/file.bin',
365
+ file_name: 'file.bin',
366
+ parent_id: 'parent-2',
367
+ },
368
+ {
369
+ id: 'att-with-ct-2',
370
+ url: 'https://example.com/doc.pdf',
371
+ file_name: 'doc.pdf',
372
+ parent_id: 'parent-3',
373
+ content_type: 'application/pdf',
374
+ },
375
+ ];
376
+ const pool = new attachments_streaming_pool_1.AttachmentsStreamingPool({
377
+ adapter: mockAdapter,
378
+ attachments: mixedAttachments,
379
+ batchSize: 1,
380
+ stream: mockStream,
381
+ });
382
+ await pool.streamAll();
383
+ expect(mockAdapter.processAttachment).toHaveBeenCalledTimes(3);
384
+ expect(mockAdapter.processAttachment.mock.calls[0][0].content_type).toBe('image/png');
385
+ expect(mockAdapter.processAttachment.mock.calls[1][0].content_type).toBeUndefined();
386
+ expect(mockAdapter.processAttachment.mock.calls[2][0].content_type).toBe('application/pdf');
387
+ });
388
+ it('should include content_type in error log when processAttachment returns error', async () => {
389
+ mockAdapter.processAttachment.mockResolvedValue({
390
+ error: { message: 'Upload failed' },
391
+ });
392
+ const warnSpy = jest.spyOn(console, 'warn');
393
+ const attachmentWithContentType = {
394
+ id: 'att-error-ct',
395
+ url: 'https://example.com/file.pdf',
396
+ file_name: 'file.pdf',
397
+ parent_id: 'parent-err',
398
+ content_type: 'application/pdf',
399
+ };
400
+ const pool = new attachments_streaming_pool_1.AttachmentsStreamingPool({
401
+ adapter: mockAdapter,
402
+ attachments: [attachmentWithContentType],
403
+ batchSize: 1,
404
+ stream: mockStream,
405
+ });
406
+ await pool.streamAll();
407
+ expect(warnSpy).toHaveBeenCalledWith(expect.stringContaining('content_type application/pdf'), expect.any(String));
408
+ });
409
+ it('should include content_type in error log when processAttachment throws', async () => {
410
+ const error = new Error('Processing crashed');
411
+ mockAdapter.processAttachment.mockRejectedValue(error);
412
+ const warnSpy = jest.spyOn(console, 'warn');
413
+ const attachmentWithContentType = {
414
+ id: 'att-throw-ct',
415
+ url: 'https://example.com/file.png',
416
+ file_name: 'file.png',
417
+ parent_id: 'parent-throw',
418
+ content_type: 'image/png',
419
+ };
420
+ const pool = new attachments_streaming_pool_1.AttachmentsStreamingPool({
421
+ adapter: mockAdapter,
422
+ attachments: [attachmentWithContentType],
423
+ batchSize: 1,
424
+ stream: mockStream,
425
+ });
426
+ await pool.streamAll();
427
+ expect(warnSpy).toHaveBeenCalledWith(expect.stringContaining('content_type image/png'), error);
428
+ });
429
+ it('should not include content_type in error log when content_type is not set', async () => {
430
+ mockAdapter.processAttachment.mockResolvedValue({
431
+ error: { message: 'Upload failed' },
432
+ });
433
+ const warnSpy = jest.spyOn(console, 'warn');
434
+ const pool = new attachments_streaming_pool_1.AttachmentsStreamingPool({
435
+ adapter: mockAdapter,
436
+ attachments: [mockAttachments[0]],
437
+ batchSize: 1,
438
+ stream: mockStream,
439
+ });
440
+ await pool.streamAll();
441
+ expect(warnSpy).toHaveBeenCalledWith(expect.not.stringContaining('content_type'), expect.any(String));
442
+ });
443
+ });
333
444
  describe('concurrency behavior', () => {
334
445
  it('should process attachments concurrently within batch size', async () => {
335
446
  let processCallCount = 0;
@@ -1 +1 @@
1
- {"version":3,"file":"worker-adapter.d.ts","sourceRoot":"","sources":["../../../src/multithreading/worker-adapter/worker-adapter.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAEhD,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EACL,oBAAoB,EACpB,aAAa,EACd,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EACL,YAAY,EACZ,SAAS,EAET,kCAAkC,EAClC,yCAAyC,EACzC,kBAAkB,EAClB,2BAA2B,EAC3B,2BAA2B,EAC5B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAEL,wBAAwB,EACxB,kBAAkB,EAClB,6BAA6B,EAC7B,UAAU,EACV,qBAAqB,EACrB,cAAc,EACd,eAAe,EACf,YAAY,EACZ,gBAAgB,EAChB,qBAAqB,EAEtB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,sBAAsB,EACtB,oBAAoB,EAGrB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,QAAQ,EAAkB,MAAM,oCAAoC,CAAC;AAI9E,wBAAgB,mBAAmB,CAAC,cAAc,EAAE,EAClD,KAAK,EACL,YAAY,EACZ,OAAO,GACR,EAAE,sBAAsB,CAAC,cAAc,CAAC,GAAG,aAAa,CAAC,cAAc,CAAC,CAMxE;AAED;;;;;;;;;;;;;;GAcG;AACH,qBAAa,aAAa,CAAC,cAAc;IACvC,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;IAC7B,QAAQ,CAAC,OAAO,CAAC,EAAE,oBAAoB,CAAC;IACxC,SAAS,EAAE,OAAO,CAAC;IACnB,gBAAgB,EAAE,OAAO,CAAC;IAE1B,OAAO,CAAC,YAAY,CAAwB;IAC5C,OAAO,CAAC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,CAAC,EACb,IAAI,EACJ,cAAc,GACf,EAAE;QACD,IAAI,EAAE,kBAAkB,CAAC;QACzB,cAAc,EAAE,cAAc,CAAC;KAChC,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAkMvB,iBAAiB,CACrB,UAAU,EAAE,oBAAoB,EAChC,MAAM,EAAE,yCAAyC,GAChD,OAAO,CAAC,2BAA2B,CAAC;IA2GvC;;;OAGG;IACH,OAAO,CAAC,iBAAiB;IAcnB,cAAc,CAAC,EACnB,IAAI,EACJ,MAAM,GACP,EAAE;QACD,IAAI,EAAE,wBAAwB,CAAC;QAC/B,MAAM,EAAE,6BAA6B,CAAC,wBAAwB,CAAC,CAAC;KACjE,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAqD7B;;;;;;OAMG;IACG,iBAAiB,CAAC,QAAQ,EAAE,EAChC,MAAM,EACN,UAAU,EACV,SAAa,GACd,EAAE;QACD,MAAM,EAAE,yCAAyC,CAAC;QAClD,UAAU,CAAC,EAAE,kCAAkC,CAC7C,cAAc,EACd,oBAAoB,EAAE,EACtB,QAAQ,CACT,CAAC;QACF,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,GAAG,OAAO,CAAC,2BAA2B,CAAC;CAyHzC"}
1
+ {"version":3,"file":"worker-adapter.d.ts","sourceRoot":"","sources":["../../../src/multithreading/worker-adapter/worker-adapter.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAEhD,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EACL,oBAAoB,EACpB,aAAa,EACd,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EACL,YAAY,EACZ,SAAS,EAET,kCAAkC,EAClC,yCAAyC,EACzC,kBAAkB,EAClB,2BAA2B,EAC3B,2BAA2B,EAC5B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAEL,w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EACV,SAAa,GACd,EAAE;QACD,MAAM,EAAE,yCAAyC,CAAC;QAClD,UAAU,CAAC,EAAE,kCAAkC,CAC7C,cAAc,EACd,oBAAoB,EAAE,EACtB,QAAQ,CACT,CAAC;QACF,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,GAAG,OAAO,CAAC,2BAA2B,CAAC;CAyHzC"}
@@ -535,7 +535,9 @@ class WorkerAdapter {
535
535
  return { delay };
536
536
  }
537
537
  if (httpStream) {
538
- const fileType = httpStream.headers['content-type'] || 'application/octet-stream';
538
+ const fileType = attachment.content_type ||
539
+ httpStream.headers['content-type'] ||
540
+ 'application/octet-stream';
539
541
  const fileSize = httpStream.headers['content-length']
540
542
  ? parseInt(httpStream.headers['content-length'])
541
543
  : undefined;
@@ -394,6 +394,96 @@ describe(worker_adapter_1.WorkerAdapter.name, () => {
394
394
  expect(adapter.state.toDevRev.attachmentsMetadata.lastProcessed).toBe(0);
395
395
  });
396
396
  });
397
+ describe(worker_adapter_1.WorkerAdapter.prototype.processAttachment.name, () => {
398
+ const createMockHttpStream = (headers = {}) => ({
399
+ headers,
400
+ data: { destroy: jest.fn() },
401
+ });
402
+ beforeEach(() => {
403
+ adapter.initializeRepos([{ itemType: 'ssor_attachment' }]);
404
+ const mockRepo = { push: jest.fn().mockResolvedValue(undefined) };
405
+ adapter.getRepo = jest.fn().mockReturnValue(mockRepo);
406
+ });
407
+ it('should use attachment.content_type when provided, ignoring HTTP header', async () => {
408
+ const mockStream = jest.fn().mockResolvedValue({
409
+ httpStream: createMockHttpStream({
410
+ 'content-type': 'text/plain',
411
+ 'content-length': '100',
412
+ }),
413
+ });
414
+ adapter['uploader'].getArtifactUploadUrl = jest
415
+ .fn()
416
+ .mockResolvedValue({
417
+ response: { artifact_id: 'art_1', upload_url: 'https://upload', form_data: [] },
418
+ });
419
+ adapter['uploader'].streamArtifact = jest
420
+ .fn()
421
+ .mockResolvedValue({ response: {} });
422
+ adapter['uploader'].confirmArtifactUpload = jest
423
+ .fn()
424
+ .mockResolvedValue({ response: {} });
425
+ const attachment = {
426
+ id: 'att-1',
427
+ url: 'https://example.com/file.pdf',
428
+ file_name: 'file.pdf',
429
+ parent_id: 'parent-1',
430
+ content_type: 'application/pdf',
431
+ };
432
+ await adapter.processAttachment(attachment, mockStream);
433
+ expect(adapter['uploader'].getArtifactUploadUrl).toHaveBeenCalledWith('file.pdf', 'application/pdf', 100);
434
+ });
435
+ it('should use HTTP header content-type when attachment.content_type is not set', async () => {
436
+ const mockStream = jest.fn().mockResolvedValue({
437
+ httpStream: createMockHttpStream({
438
+ 'content-type': 'image/jpeg',
439
+ 'content-length': '200',
440
+ }),
441
+ });
442
+ adapter['uploader'].getArtifactUploadUrl = jest
443
+ .fn()
444
+ .mockResolvedValue({
445
+ response: { artifact_id: 'art_2', upload_url: 'https://upload', form_data: [] },
446
+ });
447
+ adapter['uploader'].streamArtifact = jest
448
+ .fn()
449
+ .mockResolvedValue({ response: {} });
450
+ adapter['uploader'].confirmArtifactUpload = jest
451
+ .fn()
452
+ .mockResolvedValue({ response: {} });
453
+ const attachment = {
454
+ id: 'att-2',
455
+ url: 'https://example.com/photo.jpg',
456
+ file_name: 'photo.jpg',
457
+ parent_id: 'parent-2',
458
+ };
459
+ await adapter.processAttachment(attachment, mockStream);
460
+ expect(adapter['uploader'].getArtifactUploadUrl).toHaveBeenCalledWith('photo.jpg', 'image/jpeg', 200);
461
+ });
462
+ it('should fall back to application/octet-stream when neither content_type nor HTTP header is set', async () => {
463
+ const mockStream = jest.fn().mockResolvedValue({
464
+ httpStream: createMockHttpStream({}),
465
+ });
466
+ adapter['uploader'].getArtifactUploadUrl = jest
467
+ .fn()
468
+ .mockResolvedValue({
469
+ response: { artifact_id: 'art_3', upload_url: 'https://upload', form_data: [] },
470
+ });
471
+ adapter['uploader'].streamArtifact = jest
472
+ .fn()
473
+ .mockResolvedValue({ response: {} });
474
+ adapter['uploader'].confirmArtifactUpload = jest
475
+ .fn()
476
+ .mockResolvedValue({ response: {} });
477
+ const attachment = {
478
+ id: 'att-3',
479
+ url: 'https://example.com/file.bin',
480
+ file_name: 'file.bin',
481
+ parent_id: 'parent-3',
482
+ };
483
+ await adapter.processAttachment(attachment, mockStream);
484
+ expect(adapter['uploader'].getArtifactUploadUrl).toHaveBeenCalledWith('file.bin', 'application/octet-stream', undefined);
485
+ });
486
+ });
397
487
  describe(worker_adapter_1.WorkerAdapter.prototype.emit.name, () => {
398
488
  let counter;
399
489
  let mockPostMessage;
@@ -37,6 +37,7 @@ export interface NormalizedAttachment {
37
37
  parent_id: string;
38
38
  author_id?: string;
39
39
  inline?: boolean;
40
+ content_type?: string;
40
41
  grand_parent_id?: number | string;
41
42
  }
42
43
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"repo.interfaces.d.ts","sourceRoot":"","sources":["../../src/repo/repo.interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAE3D,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAExD;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,cAAc,GAAG,oBAAoB,CAAC;CACvE;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,YAAY,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,cAAc,GAAG,oBAAoB,CAAC;IACtE,QAAQ,EAAE,CAAC,QAAQ,EAAE,QAAQ,KAAK,IAAI,CAAC;IACvC,OAAO,CAAC,EAAE,oBAAoB,CAAC;CAChC;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,YAAY,EAAE,MAAM,CAAC;I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AAM,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,GAAG,EAAE,MAAM,CAAC;IACZ,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;IAItB,eAAe,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CACnC;AAED;;GAEG;AAEH,MAAM,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devrev/ts-adaas",
3
- "version": "1.15.3-beta.5",
3
+ "version": "1.16.1-beta.0",
4
4
  "description": "Typescript library containing the ADaaS(AirDrop as a Service) control protocol.",
5
5
  "type": "commonjs",
6
6
  "main": "./dist/index.js",
@@ -28,18 +28,17 @@
28
28
  "author": "devrev",
29
29
  "license": "ISC",
30
30
  "devDependencies": {
31
- "@microsoft/api-extractor": "^7.52.11",
31
+ "@microsoft/api-extractor": "^7.57.6",
32
32
  "@microsoft/api-extractor-model": "^7.30.7",
33
33
  "@types/express": "^5.0.3",
34
34
  "@types/jest": "^29.5.14",
35
35
  "@types/node": "^22.18.0",
36
36
  "@types/yargs": "^17.0.33",
37
- "@typescript-eslint/eslint-plugin": "^8.46.0",
38
- "@typescript-eslint/parser": "^8.46.0",
39
37
  "ajv": "^8.18.0",
40
38
  "eslint": "9.32.0",
41
39
  "eslint-config-prettier": "^9.1.2",
42
40
  "eslint-plugin-prettier": "4.0.0",
41
+ "express": "^5.2.1",
43
42
  "jest": "^29.7.0",
44
43
  "jiti": "^2.6.1",
45
44
  "prettier": "^2.8.3",
@@ -51,7 +50,6 @@
51
50
  "@devrev/typescript-sdk": "^1.1.59",
52
51
  "axios": "^1.13.5",
53
52
  "axios-retry": "^4.5.0",
54
- "express": "^5.2.1",
55
53
  "form-data": "^4.0.4",
56
54
  "js-jsonl": "^1.1.1",
57
55
  "ts-node": "^10.9.2",