aragog-client 1.0.2 → 1.1.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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Aragog Client
2
2
 
3
- [![Build Status](https://img.shields.io/travis/crawlerlab/aragog/master?style=flat-square)](https://travis-ci.com/crawlerlab/aragog)
3
+ [![Build Status](https://img.shields.io/travis/com/crawlerlab/aragog/master?style=flat-square)](https://app.travis-ci.com/github/crawlerlab/aragog)
4
4
  [![NPM Version](https://img.shields.io/npm/v/aragog-client?style=flat-square)](https://www.npmjs.com/package/aragog-client)
5
5
  [![License](https://img.shields.io/github/license/crawlerlab/aragog?style=flat-square)](https://github.com/crawlerlab/aragog/blob/master/LICENSE)
6
6
 
package/lib/management.js CHANGED
@@ -5,7 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.createManagementApi = void 0;
7
7
  const axios_1 = __importDefault(require("axios"));
8
- /* eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types */
9
8
  const createManagementApi = (conn, { ssl = false }) => {
10
9
  const request = axios_1.default.create({
11
10
  baseURL: `${ssl ? 'https' : 'http'}://${conn.hostname}:${conn.port || 15672}/api/`,
package/lib/types.d.ts CHANGED
@@ -12,7 +12,8 @@ export interface Cookie {
12
12
  export interface QueueItem {
13
13
  appName: string
14
14
  url: string
15
- script: string
15
+ script?: string
16
+ readable?: boolean // 是否自动提取网页正文内容
16
17
  disableImage?: boolean
17
18
  encoding?: string
18
19
  method?: 'GET' | 'POST'
package/lib/utils.js CHANGED
@@ -2,10 +2,17 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.checkConnectParam = exports.checkTaskInput = void 0;
4
4
  const checkTaskInput = (data) => {
5
+ if (!data.readable) {
6
+ if (!data.script) {
7
+ throw new Error('script is required');
8
+ }
9
+ if (typeof data.script !== 'string') {
10
+ throw new Error('script must be of type string');
11
+ }
12
+ }
5
13
  const allKeys = [
6
14
  'id',
7
15
  'url',
8
- 'script',
9
16
  'disableImage',
10
17
  'encoding',
11
18
  'method',
@@ -19,7 +26,7 @@ const checkTaskInput = (data) => {
19
26
  ];
20
27
  allKeys.forEach((key) => {
21
28
  var _a, _b;
22
- if (['id', 'url', 'script'].includes(key)) {
29
+ if (['id', 'url'].includes(key)) {
23
30
  if (!data[key]) {
24
31
  throw new Error(`${key} is required`);
25
32
  }
@@ -75,7 +82,6 @@ const checkTaskInput = (data) => {
75
82
  }
76
83
  Object.entries(fieldTypes).forEach(([k, type]) => {
77
84
  const cookieKey = k;
78
- /* eslint-disable-next-line valid-typeof */
79
85
  if (cookie[cookieKey] !== undefined && typeof cookie[cookieKey] !== type) {
80
86
  throw new Error(`cookies.${k} must be of type ${type}`);
81
87
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aragog-client",
3
- "version": "1.0.2",
3
+ "version": "1.1.0",
4
4
  "description": "Aragog web scraping framework client",
5
5
  "keywords": [
6
6
  "scraping",