@arcblock/crawler 1.1.6 → 1.2.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.
Files changed (39) hide show
  1. package/lib/cjs/crawler.d.ts +3 -4
  2. package/lib/cjs/crawler.js +58 -32
  3. package/lib/cjs/index.d.ts +1 -0
  4. package/lib/cjs/index.js +3 -5
  5. package/lib/cjs/services/snapshot.d.ts +5 -2
  6. package/lib/cjs/services/snapshot.js +36 -6
  7. package/lib/cjs/site.d.ts +1 -1
  8. package/lib/cjs/site.js +9 -3
  9. package/lib/cjs/store/index.d.ts +4 -1
  10. package/lib/cjs/store/index.js +37 -45
  11. package/lib/cjs/store/job.d.ts +2 -0
  12. package/lib/cjs/store/migrate.d.ts +4 -0
  13. package/lib/cjs/store/migrate.js +63 -0
  14. package/lib/cjs/store/migrations/20250615-genesis.d.ts +6 -0
  15. package/lib/cjs/store/migrations/20250615-genesis.js +114 -0
  16. package/lib/cjs/store/migrations/20250616-replace.d.ts +6 -0
  17. package/lib/cjs/store/migrations/20250616-replace.js +40 -0
  18. package/lib/cjs/store/snapshot.d.ts +2 -0
  19. package/lib/cjs/store/snapshot.js +7 -0
  20. package/lib/esm/crawler.d.ts +3 -4
  21. package/lib/esm/crawler.js +55 -29
  22. package/lib/esm/index.d.ts +1 -0
  23. package/lib/esm/index.js +1 -4
  24. package/lib/esm/services/snapshot.d.ts +5 -2
  25. package/lib/esm/services/snapshot.js +33 -4
  26. package/lib/esm/site.d.ts +1 -1
  27. package/lib/esm/site.js +9 -3
  28. package/lib/esm/store/index.d.ts +4 -1
  29. package/lib/esm/store/index.js +23 -45
  30. package/lib/esm/store/job.d.ts +2 -0
  31. package/lib/esm/store/migrate.d.ts +4 -0
  32. package/lib/esm/store/migrate.js +26 -0
  33. package/lib/esm/store/migrations/20250615-genesis.d.ts +6 -0
  34. package/lib/esm/store/migrations/20250615-genesis.js +110 -0
  35. package/lib/esm/store/migrations/20250616-replace.d.ts +6 -0
  36. package/lib/esm/store/migrations/20250616-replace.js +36 -0
  37. package/lib/esm/store/snapshot.d.ts +2 -0
  38. package/lib/esm/store/snapshot.js +7 -0
  39. package/package.json +3 -2
@@ -0,0 +1,36 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ /* eslint-disable no-console */
11
+ import { DataTypes } from '@sequelize/core';
12
+ export function up(_a) {
13
+ return __awaiter(this, arguments, void 0, function* ({ context }) {
14
+ console.log('[20250616-replace:up] Migrating...');
15
+ yield context.addColumn('snap', 'replace', {
16
+ type: DataTypes.BOOLEAN,
17
+ allowNull: false,
18
+ defaultValue: false,
19
+ index: true,
20
+ });
21
+ yield context.addIndex('snap', ['createdAt']);
22
+ yield context.addIndex('snap', ['updatedAt']);
23
+ yield context.addIndex('snap', ['status']);
24
+ console.log('[20250616-replace:up] Migrated successfully!');
25
+ });
26
+ }
27
+ export function down(_a) {
28
+ return __awaiter(this, arguments, void 0, function* ({ context }) {
29
+ console.log('[20250616-replace:down] Migrating...');
30
+ yield context.removeColumn('snap', 'replace');
31
+ yield context.removeIndex('snap', ['createdAt']);
32
+ yield context.removeIndex('snap', ['updatedAt']);
33
+ yield context.removeIndex('snap', ['status']);
34
+ console.log('[20250616-replace:down] Migrated successfully!');
35
+ });
36
+ }
@@ -8,6 +8,7 @@ export interface SnapshotModel {
8
8
  screenshot?: string | null;
9
9
  error?: string;
10
10
  lastModified?: string;
11
+ replace?: boolean;
11
12
  meta?: {
12
13
  title?: string;
13
14
  description?: string;
@@ -35,6 +36,7 @@ export declare class Snapshot extends Model<SnapshotModel> implements SnapshotMo
35
36
  screenshot?: SnapshotModel['screenshot'];
36
37
  error?: SnapshotModel['error'];
37
38
  lastModified?: SnapshotModel['lastModified'];
39
+ replace?: SnapshotModel['replace'];
38
40
  meta?: SnapshotModel['meta'];
39
41
  options: SnapshotModel['options'];
40
42
  static initModel(sequelize: Sequelize): typeof Snapshot;
@@ -24,6 +24,7 @@ export class Snapshot extends Model {
24
24
  status: {
25
25
  type: DataTypes.ENUM('success', 'failed', 'pending'),
26
26
  allowNull: false,
27
+ index: true,
27
28
  },
28
29
  html: {
29
30
  type: DataTypes.TEXT,
@@ -41,6 +42,12 @@ export class Snapshot extends Model {
41
42
  type: DataTypes.STRING,
42
43
  allowNull: true,
43
44
  },
45
+ replace: {
46
+ type: DataTypes.BOOLEAN,
47
+ allowNull: false,
48
+ defaultValue: false,
49
+ index: true,
50
+ },
44
51
  meta: {
45
52
  type: DataTypes.JSON,
46
53
  allowNull: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcblock/crawler",
3
- "version": "1.1.6",
3
+ "version": "1.2.0",
4
4
  "main": "lib/cjs/index.js",
5
5
  "module": "lib/esm/index.js",
6
6
  "types": "lib/cjs/index.d.ts",
@@ -61,7 +61,8 @@
61
61
  "robots-parser": "^3.0.1",
62
62
  "sitemap": "^7.1.2",
63
63
  "sqlite3": "^5.1.7",
64
- "ufo": "^1.5.4"
64
+ "ufo": "^1.5.4",
65
+ "umzug": "^3.8.2"
65
66
  },
66
67
  "devDependencies": {
67
68
  "@types/dotenv-flow": "^3.3.3",