@rafikidota/cuba-ofertas-scraping 0.27.2 → 0.28.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,4 +1,5 @@
1
1
  import { Response as PlaywrightResponse } from 'playwright';
2
+ import { PlainResponse } from 'crawlee';
2
3
  import { CheerioAPI } from 'cheerio';
3
4
  export interface HttpResponse {
4
5
  statusCode: number;
@@ -18,7 +19,7 @@ export interface JSDOMResponse extends HttpResponse {
18
19
  body: string;
19
20
  window: any;
20
21
  }
21
- export type CrawleeResponse = HttpResponse | CheerioResponse | PlaywrightResponse | PuppeteerResponse | JSDOMResponse;
22
+ export type CrawleeResponse = HttpResponse | CheerioResponse | PlaywrightResponse | PuppeteerResponse | JSDOMResponse | PlainResponse;
22
23
  export interface NormalizedResponse {
23
24
  statusCode: number;
24
25
  headers: Record<string, string>;
@@ -2,6 +2,7 @@ import { CrawleeResponse } from '../types/normalize-response.types';
2
2
  import { NormalizedResponse } from '../types/normalize-response.types';
3
3
  export declare class NormalizeCloudflareResponseUseCase {
4
4
  execute(response: CrawleeResponse): NormalizedResponse;
5
+ private isPlainResponse;
5
6
  private isPlaywrightResponse;
6
7
  private isPuppeteerResponse;
7
8
  private isHttpLikeResponse;
@@ -10,6 +10,13 @@ exports.NormalizeCloudflareResponseUseCase = void 0;
10
10
  const common_1 = require("@nestjs/common");
11
11
  let NormalizeCloudflareResponseUseCase = class NormalizeCloudflareResponseUseCase {
12
12
  execute(response) {
13
+ if (this.isPlainResponse(response)) {
14
+ return {
15
+ statusCode: response.statusCode,
16
+ headers: response.headers,
17
+ url: response.url,
18
+ };
19
+ }
13
20
  if (this.isPlaywrightResponse(response)) {
14
21
  return {
15
22
  statusCode: response.status(),
@@ -33,6 +40,12 @@ let NormalizeCloudflareResponseUseCase = class NormalizeCloudflareResponseUseCas
33
40
  }
34
41
  throw new Error('Unable to normalize response: unknown response type');
35
42
  }
43
+ isPlainResponse(response) {
44
+ return (response &&
45
+ 'statusCode' in response &&
46
+ 'headers' in response &&
47
+ !('status' in response));
48
+ }
36
49
  isPlaywrightResponse(response) {
37
50
  return response && typeof response.status === 'function';
38
51
  }
@@ -1 +1 @@
1
- {"version":3,"file":"normalize-cloudflare-response.use-case.js","sourceRoot":"","sources":["../../../../src/modules/cloudflare/use-cases/normalize-cloudflare-response.use-case.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA4C;AAUrC,IAAM,kCAAkC,GAAxC,MAAM,kCAAkC;IAC7C,OAAO,CAAC,QAAyB;QAC/B,IAAI,IAAI,CAAC,oBAAoB,CAAC,QAAQ,CAAC,EAAE,CAAC;YACxC,OAAO;gBACL,UAAU,EAAE,QAAQ,CAAC,MAAM,EAAE;gBAC7B,OAAO,EAAE,QAAQ,CAAC,OAAO,EAAE;gBAC3B,GAAG,EAAE,QAAQ,CAAC,GAAG,EAAE;aACpB,CAAC;QACJ,CAAC;QAED,IAAI,IAAI,CAAC,mBAAmB,CAAC,QAAQ,CAAC,EAAE,CAAC;YACvC,OAAO;gBACL,UAAU,EAAE,QAAQ,CAAC,MAAM,EAAE;gBAC7B,OAAO,EAAE,QAAQ,CAAC,OAAO,EAAE;gBAC3B,GAAG,EAAE,QAAQ,CAAC,GAAG,EAAE;aACpB,CAAC;QACJ,CAAC;QAED,IAAI,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAAC,EAAE,CAAC;YACtC,OAAO;gBACL,UAAU,EAAE,QAAQ,CAAC,UAAU;gBAC/B,OAAO,EAAE,QAAQ,CAAC,OAAO;gBACzB,GAAG,EAAE,QAAQ,CAAC,GAAG;aAClB,CAAC;QACJ,CAAC;QAED,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;IACzE,CAAC;IAEO,oBAAoB,CAAC,QAAa;QACxC,OAAO,QAAQ,IAAI,OAAO,QAAQ,CAAC,MAAM,KAAK,UAAU,CAAC;IAC3D,CAAC;IAEO,mBAAmB,CAAC,QAAa;QACvC,OAAO,CACL,QAAQ;YACR,OAAO,QAAQ,CAAC,MAAM,KAAK,UAAU;YACrC,OAAO,QAAQ,CAAC,OAAO,KAAK,UAAU,CACvC,CAAC;IACJ,CAAC;IAEO,kBAAkB,CACxB,QAAa;QAEb,OAAO,CACL,QAAQ;YACR,OAAO,QAAQ,CAAC,UAAU,KAAK,QAAQ;YACvC,OAAO,QAAQ,CAAC,OAAO,KAAK,QAAQ;YACpC,OAAO,QAAQ,CAAC,GAAG,KAAK,QAAQ,CACjC,CAAC;IACJ,CAAC;CACF,CAAA;AAnDY,gFAAkC;6CAAlC,kCAAkC;IAD9C,IAAA,mBAAU,GAAE;GACA,kCAAkC,CAmD9C"}
1
+ {"version":3,"file":"normalize-cloudflare-response.use-case.js","sourceRoot":"","sources":["../../../../src/modules/cloudflare/use-cases/normalize-cloudflare-response.use-case.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA4C;AAWrC,IAAM,kCAAkC,GAAxC,MAAM,kCAAkC;IAC7C,OAAO,CAAC,QAAyB;QAC/B,IAAI,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,EAAE,CAAC;YACnC,OAAO;gBACL,UAAU,EAAE,QAAQ,CAAC,UAAU;gBAC/B,OAAO,EAAE,QAAQ,CAAC,OAAiC;gBACnD,GAAG,EAAE,QAAQ,CAAC,GAAG;aAClB,CAAC;QACJ,CAAC;QAED,IAAI,IAAI,CAAC,oBAAoB,CAAC,QAAQ,CAAC,EAAE,CAAC;YACxC,OAAO;gBACL,UAAU,EAAE,QAAQ,CAAC,MAAM,EAAE;gBAC7B,OAAO,EAAE,QAAQ,CAAC,OAAO,EAAE;gBAC3B,GAAG,EAAE,QAAQ,CAAC,GAAG,EAAE;aACpB,CAAC;QACJ,CAAC;QAED,IAAI,IAAI,CAAC,mBAAmB,CAAC,QAAQ,CAAC,EAAE,CAAC;YACvC,OAAO;gBACL,UAAU,EAAE,QAAQ,CAAC,MAAM,EAAE;gBAC7B,OAAO,EAAE,QAAQ,CAAC,OAAO,EAAE;gBAC3B,GAAG,EAAE,QAAQ,CAAC,GAAG,EAAE;aACpB,CAAC;QACJ,CAAC;QAED,IAAI,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAAC,EAAE,CAAC;YACtC,OAAO;gBACL,UAAU,EAAE,QAAQ,CAAC,UAAU;gBAC/B,OAAO,EAAE,QAAQ,CAAC,OAAO;gBACzB,GAAG,EAAE,QAAQ,CAAC,GAAG;aAClB,CAAC;QACJ,CAAC;QAED,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;IACzE,CAAC;IAEO,eAAe,CAAC,QAAa;QACnC,OAAO,CACL,QAAQ;YACR,YAAY,IAAI,QAAQ;YACxB,SAAS,IAAI,QAAQ;YACrB,CAAC,CAAC,QAAQ,IAAI,QAAQ,CAAC,CACxB,CAAC;IACJ,CAAC;IAEO,oBAAoB,CAAC,QAAa;QACxC,OAAO,QAAQ,IAAI,OAAO,QAAQ,CAAC,MAAM,KAAK,UAAU,CAAC;IAC3D,CAAC;IAEO,mBAAmB,CAAC,QAAa;QACvC,OAAO,CACL,QAAQ;YACR,OAAO,QAAQ,CAAC,MAAM,KAAK,UAAU;YACrC,OAAO,QAAQ,CAAC,OAAO,KAAK,UAAU,CACvC,CAAC;IACJ,CAAC;IAEO,kBAAkB,CACxB,QAAa;QAEb,OAAO,CACL,QAAQ;YACR,OAAO,QAAQ,CAAC,UAAU,KAAK,QAAQ;YACvC,OAAO,QAAQ,CAAC,OAAO,KAAK,QAAQ;YACpC,OAAO,QAAQ,CAAC,GAAG,KAAK,QAAQ,CACjC,CAAC;IACJ,CAAC;CACF,CAAA;AApEY,gFAAkC;6CAAlC,kCAAkC;IAD9C,IAAA,mBAAU,GAAE;GACA,kCAAkC,CAoE9C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rafikidota/cuba-ofertas-scraping",
3
- "version": "0.27.2",
3
+ "version": "0.28.0",
4
4
  "description": "Sometimes, the best way to solve your own problems is to help someone else.",
5
5
  "repository": {
6
6
  "type": "git",