@devrev/ts-adaas 1.10.1-beta.4 → 1.10.1-beta.5

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":"AAAA,OAAO,EAGL,2BAA2B,EAC5B,MAAM,UAAU,CAAC;AAClB,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;IAQjD,OAAO,CAAC,cAAc;IAOhB,SAAS,IAAI,OAAO,CAAC,2BAA2B,CAAC;IAuCjD,kBAAkB;CAiEzB"}
1
+ {"version":3,"file":"attachments-streaming-pool.d.ts","sourceRoot":"","sources":["../../src/attachments-streaming/attachments-streaming-pool.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,2BAA2B,EAC5B,MAAM,UAAU,CAAC;AAClB,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;IAQjD,OAAO,CAAC,cAAc;IAOhB,SAAS,IAAI,OAAO,CAAC,2BAA2B,CAAC;IAuCjD,kBAAkB;CAgEzB"}
@@ -64,7 +64,6 @@ class AttachmentsStreamingPool {
64
64
  }
65
65
  if (this.adapter.state.toDevRev &&
66
66
  ((_a = this.adapter.state.toDevRev.attachmentsMetadata.lastProcessedAttachmentsIdsList) === null || _a === void 0 ? void 0 : _a.includes(attachment.id))) {
67
- this.updateProgress();
68
67
  continue; // Skip if the attachment ID is already processed
69
68
  }
70
69
  try {
@@ -5,34 +5,30 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const axios_1 = __importDefault(require("axios"));
7
7
  const index_1 = require("../../index");
8
- const axios_client_internal_1 = require("../../http/axios-client-internal");
9
8
  const constants_1 = require("../../common/constants");
10
9
  const getAttachmentStream = async ({ item, }) => {
11
10
  const { id, url } = item;
12
11
  let fileStreamResponse = null;
13
12
  try {
14
- // First, check file size with HEAD request to avoid downloading large files
15
- const headResponse = await axios_client_internal_1.axiosClient.head(url, {
13
+ // Get the stream response directly
14
+ fileStreamResponse = await axios_1.default.get(url, {
15
+ responseType: 'stream',
16
16
  headers: {
17
17
  'Accept-Encoding': 'identity',
18
18
  },
19
19
  });
20
- const contentLength = headResponse.headers['content-length'];
20
+ // Check content-length from the stream response headers
21
+ const contentLength = fileStreamResponse.headers['content-length'];
21
22
  if (contentLength && parseInt(contentLength) > constants_1.MAX_DEVREV_ARTIFACT_SIZE) {
22
23
  console.warn(`Attachment ${id} size (${contentLength} bytes) exceeds maximum limit of ${constants_1.MAX_DEVREV_ARTIFACT_SIZE} bytes. Skipping download.`);
24
+ // Destroy the stream since we won't use it
25
+ destroyHttpStream(fileStreamResponse);
23
26
  return {
24
27
  error: {
25
28
  message: `File size exceeds maximum limit of ${constants_1.MAX_DEVREV_ARTIFACT_SIZE} bytes.`,
26
29
  },
27
30
  };
28
31
  }
29
- // If size is acceptable, proceed with streaming
30
- fileStreamResponse = await axios_client_internal_1.axiosClient.get(url, {
31
- responseType: 'stream',
32
- headers: {
33
- 'Accept-Encoding': 'identity',
34
- },
35
- });
36
32
  return { httpStream: fileStreamResponse };
37
33
  }
38
34
  catch (error) {
@@ -40,17 +36,9 @@ const getAttachmentStream = async ({ item, }) => {
40
36
  if (fileStreamResponse) {
41
37
  destroyHttpStream(fileStreamResponse);
42
38
  }
43
- if (axios_1.default.isAxiosError(error)) {
44
- console.warn(`Error while fetching attachment ${id} from URL.`, (0, index_1.serializeAxiosError)(error));
45
- console.warn('Failed attachment metadata', item);
46
- }
47
- else {
48
- console.warn(`Error while fetching attachment ${id} from URL.`, error);
49
- console.warn('Failed attachment metadata', item);
50
- }
51
39
  return {
52
40
  error: {
53
- message: 'Error while fetching attachment ' + id + ' from URL.',
41
+ message: `Error while getting attachment stream for attachment with id ${id}.`,
54
42
  },
55
43
  };
56
44
  }
@@ -79,6 +67,7 @@ const destroyHttpStream = (httpStream) => {
79
67
  try {
80
68
  const response = await adapter.streamAttachments({
81
69
  stream: getAttachmentStream,
70
+ batchSize: 10,
82
71
  });
83
72
  if (response === null || response === void 0 ? void 0 : response.delay) {
84
73
  await adapter.emit(index_1.ExtractorEventType.ExtractionAttachmentsDelay, {
@@ -99,8 +88,6 @@ const destroyHttpStream = (httpStream) => {
99
88
  }
100
89
  },
101
90
  onTimeout: async ({ adapter }) => {
102
- await adapter.emit(index_1.ExtractorEventType.ExtractionAttachmentsProgress, {
103
- progress: 50,
104
- });
91
+ await adapter.emit(index_1.ExtractorEventType.ExtractionAttachmentsProgress);
105
92
  },
106
93
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devrev/ts-adaas",
3
- "version": "1.10.1-beta.4",
3
+ "version": "1.10.1-beta.5",
4
4
  "description": "Typescript library containing the ADaaS(AirDrop as a Service) control protocol.",
5
5
  "type": "commonjs",
6
6
  "main": "./dist/index.js",