hydra-crawler 1.4.6 → 2.0.2
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/dist/apis/autocomplete.api.d.ts +7 -0
- package/dist/apis/autocomplete.api.js +15 -9
- package/dist/apis/autocomplete.api.js.map +1 -0
- package/dist/apis/bugs.api.d.ts +7 -0
- package/dist/apis/bugs.api.js +21 -15
- package/dist/apis/bugs.api.js.map +1 -0
- package/dist/apis/crawl.api.d.ts +7 -0
- package/dist/apis/crawl.api.js +15 -9
- package/dist/apis/crawl.api.js.map +1 -0
- package/dist/apis/domains.api.d.ts +7 -0
- package/dist/apis/domains.api.js +24 -19
- package/dist/apis/domains.api.js.map +1 -0
- package/dist/apis/images.api.d.ts +7 -0
- package/dist/apis/images.api.js +20 -14
- package/dist/apis/images.api.js.map +1 -0
- package/dist/apis/statistics.api.d.ts +8 -0
- package/dist/apis/statistics.api.js +27 -20
- package/dist/apis/statistics.api.js.map +1 -0
- package/dist/apis/test.api.d.ts +5 -0
- package/dist/apis/test.api.js +15 -9
- package/dist/apis/test.api.js.map +1 -0
- package/dist/apis/urls.api.d.ts +7 -0
- package/dist/apis/urls.api.js +21 -15
- package/dist/apis/urls.api.js.map +1 -0
- package/dist/apps/cleanup.app.d.ts +19 -0
- package/dist/apps/cleanup.app.js +118 -100
- package/dist/apps/cleanup.app.js.map +1 -0
- package/dist/apps/cross-populate-export.app.d.ts +12 -0
- package/dist/apps/cross-populate-export.app.js +60 -47
- package/dist/apps/cross-populate-export.app.js.map +1 -0
- package/dist/apps/cross-populate-import.app.d.ts +12 -0
- package/dist/apps/cross-populate-import.app.js +64 -51
- package/dist/apps/cross-populate-import.app.js.map +1 -0
- package/dist/apps/denylist.app.d.ts +17 -0
- package/dist/apps/denylist.app.js +115 -98
- package/dist/apps/denylist.app.js.map +1 -0
- package/dist/apps/expire.app.d.ts +19 -0
- package/dist/apps/expire.app.js +44 -31
- package/dist/apps/expire.app.js.map +1 -0
- package/dist/apps/extract-text.app.d.ts +8 -0
- package/dist/apps/extract-text.app.js +43 -35
- package/dist/apps/extract-text.app.js.map +1 -0
- package/dist/apps/hydra.app.d.ts +34 -0
- package/dist/apps/hydra.app.js +150 -137
- package/dist/apps/hydra.app.js.map +1 -0
- package/dist/apps/import.app.d.ts +11 -0
- package/dist/apps/import.app.js +44 -32
- package/dist/apps/import.app.js.map +1 -0
- package/dist/apps/internal-hydra-common.app.d.ts +28 -0
- package/dist/apps/internal-hydra-common.app.js +5 -11
- package/dist/apps/internal-hydra-common.app.js.map +1 -0
- package/dist/apps/query.app.d.ts +20 -0
- package/dist/apps/query.app.js +63 -49
- package/dist/apps/query.app.js.map +1 -0
- package/dist/apps/reattempt.app.d.ts +17 -0
- package/dist/apps/reattempt.app.js +66 -53
- package/dist/apps/reattempt.app.js.map +1 -0
- package/dist/apps/requeue-domain.app.d.ts +13 -0
- package/dist/apps/requeue-domain.app.js +50 -37
- package/dist/apps/requeue-domain.app.js.map +1 -0
- package/dist/apps/seed.app.d.ts +15 -0
- package/dist/apps/seed.app.js +53 -40
- package/dist/apps/seed.app.js.map +1 -0
- package/dist/apps/startup.app.d.ts +11 -0
- package/dist/apps/startup.app.js +51 -38
- package/dist/apps/startup.app.js.map +1 -0
- package/dist/apps/unarchive.app.d.ts +15 -0
- package/dist/apps/unarchive.app.js +67 -54
- package/dist/apps/unarchive.app.js.map +1 -0
- package/dist/classes/cleaner.d.ts +12 -0
- package/dist/classes/cleaner.js +227 -207
- package/dist/classes/cleaner.js.map +1 -0
- package/dist/classes/crawler.d.ts +34 -0
- package/dist/classes/crawler.js +248 -241
- package/dist/classes/crawler.js.map +1 -0
- package/dist/classes/dns.d.ts +3 -0
- package/dist/classes/dns.js +10 -13
- package/dist/classes/dns.js.map +1 -0
- package/dist/classes/expirer.d.ts +10 -0
- package/dist/classes/expirer.js +107 -94
- package/dist/classes/expirer.js.map +1 -0
- package/dist/classes/expiry.d.ts +8 -0
- package/dist/classes/expiry.js +16 -19
- package/dist/classes/expiry.js.map +1 -0
- package/dist/classes/lists.d.ts +9 -0
- package/dist/classes/lists.js +13 -18
- package/dist/classes/lists.js.map +1 -0
- package/dist/classes/robot.d.ts +15 -0
- package/dist/classes/robot.js +40 -30
- package/dist/classes/robot.js.map +1 -0
- package/dist/classes/tracker.d.ts +25 -0
- package/dist/classes/tracker.js +82 -64
- package/dist/classes/tracker.js.map +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +72 -65
- package/dist/cli.js.map +1 -0
- package/dist/enums/eavailable-strategy.d.ts +4 -0
- package/dist/enums/eavailable-strategy.js +3 -5
- package/dist/enums/eavailable-strategy.js.map +1 -0
- package/dist/enums/elist.d.ts +7 -0
- package/dist/enums/elist.js +7 -11
- package/dist/enums/elist.js.map +1 -0
- package/dist/enums/eserver.d.ts +8 -0
- package/dist/enums/eserver.js +3 -5
- package/dist/enums/eserver.js.map +1 -0
- package/dist/enums/ex-powered-by.d.ts +6 -0
- package/dist/enums/ex-powered-by.js +3 -5
- package/dist/enums/ex-powered-by.js.map +1 -0
- package/dist/helpers/matcher.d.ts +5 -0
- package/dist/helpers/matcher.js +2 -5
- package/dist/helpers/matcher.js.map +1 -0
- package/dist/helpers/random.d.ts +4 -0
- package/dist/helpers/random.js +2 -5
- package/dist/helpers/random.js.map +1 -0
- package/dist/helpers/utf-decoder.d.ts +4 -0
- package/dist/helpers/utf-decoder.js +3 -6
- package/dist/helpers/utf-decoder.js.map +1 -0
- package/dist/interfaces/iexpiry.d.ts +7 -0
- package/dist/interfaces/iexpiry.js +9 -13
- package/dist/interfaces/iexpiry.js.map +1 -0
- package/dist/interfaces/imatch.d.ts +6 -0
- package/dist/interfaces/imatch.js +6 -9
- package/dist/interfaces/imatch.js.map +1 -0
- package/dist/interfaces/iparser-config.d.ts +4 -0
- package/dist/interfaces/iparser-config.js +4 -7
- package/dist/interfaces/iparser-config.js.map +1 -0
- package/dist/interfaces/iparser.d.ts +8 -0
- package/dist/interfaces/iparser.js +2 -2
- package/dist/interfaces/iparser.js.map +1 -0
- package/dist/interfaces/irequest-outcome.d.ts +11 -0
- package/dist/interfaces/irequest-outcome.js +2 -2
- package/dist/interfaces/irequest-outcome.js.map +1 -0
- package/dist/interfaces/iserver.d.ts +4 -0
- package/dist/interfaces/iserver.js +2 -2
- package/dist/interfaces/iserver.js.map +1 -0
- package/dist/parsers/accessibility-metrics.parser.d.ts +11 -0
- package/dist/parsers/accessibility-metrics.parser.js +34 -26
- package/dist/parsers/accessibility-metrics.parser.js.map +1 -0
- package/dist/parsers/asp-error.parser.d.ts +12 -0
- package/dist/parsers/asp-error.parser.js +36 -28
- package/dist/parsers/asp-error.parser.js.map +1 -0
- package/dist/parsers/bad-words.parser.d.ts +10 -0
- package/dist/parsers/bad-words.parser.js +21 -13
- package/dist/parsers/bad-words.parser.js.map +1 -0
- package/dist/parsers/complex-english.parser.d.ts +15 -0
- package/dist/parsers/complex-english.parser.js +33 -25
- package/dist/parsers/complex-english.parser.js.map +1 -0
- package/dist/parsers/data.parser.d.ts +14 -0
- package/dist/parsers/data.parser.js +12 -16
- package/dist/parsers/data.parser.js.map +1 -0
- package/dist/parsers/dictionary.parser.d.ts +19 -0
- package/dist/parsers/dictionary.parser.js +47 -39
- package/dist/parsers/dictionary.parser.js.map +1 -0
- package/dist/parsers/html.parser.d.ts +13 -0
- package/dist/parsers/html.parser.js +4 -8
- package/dist/parsers/html.parser.js.map +1 -0
- package/dist/parsers/hyperlinks.parser.d.ts +20 -0
- package/dist/parsers/hyperlinks.parser.js +82 -77
- package/dist/parsers/hyperlinks.parser.js.map +1 -0
- package/dist/parsers/image-tags.parser.d.ts +19 -0
- package/dist/parsers/image-tags.parser.js +31 -35
- package/dist/parsers/image-tags.parser.js.map +1 -0
- package/dist/parsers/jpeg.parser.d.ts +11 -0
- package/dist/parsers/jpeg.parser.js +28 -20
- package/dist/parsers/jpeg.parser.js.map +1 -0
- package/dist/parsers/paragraphs.parser.d.ts +13 -0
- package/dist/parsers/paragraphs.parser.js +33 -40
- package/dist/parsers/paragraphs.parser.js.map +1 -0
- package/dist/parsers/parser.d.ts +19 -0
- package/dist/parsers/parser.js +30 -17
- package/dist/parsers/parser.js.map +1 -0
- package/dist/parsers/php-error.parser.d.ts +12 -0
- package/dist/parsers/php-error.parser.js +42 -34
- package/dist/parsers/php-error.parser.js.map +1 -0
- package/dist/parsers/phrase.parser.d.ts +8 -0
- package/dist/parsers/phrase.parser.js +16 -11
- package/dist/parsers/phrase.parser.js.map +1 -0
- package/dist/parsers/regex.parser.d.ts +10 -0
- package/dist/parsers/regex.parser.js +30 -22
- package/dist/parsers/regex.parser.js.map +1 -0
- package/dist/parsers/server.parser.d.ts +11 -0
- package/dist/parsers/server.parser.js +58 -57
- package/dist/parsers/server.parser.js.map +1 -0
- package/dist/parsers/spelling.parser.d.ts +10 -0
- package/dist/parsers/spelling.parser.js +21 -13
- package/dist/parsers/spelling.parser.js.map +1 -0
- package/dist/parsers/string.parser.d.ts +8 -0
- package/dist/parsers/string.parser.js +5 -8
- package/dist/parsers/string.parser.js.map +1 -0
- package/dist/parsers/text.parser.d.ts +8 -0
- package/dist/parsers/text.parser.js +24 -18
- package/dist/parsers/text.parser.js.map +1 -0
- package/dist/parsers/words.parser.d.ts +11 -0
- package/dist/parsers/words.parser.js +32 -28
- package/dist/parsers/words.parser.js.map +1 -0
- package/dist/queries/complex-english.query.d.ts +2 -0
- package/dist/queries/complex-english.query.js +37 -38
- package/dist/queries/complex-english.query.js.map +1 -0
- package/dist/queries/flash-content.query.d.ts +2 -0
- package/dist/queries/flash-content.query.js +39 -30
- package/dist/queries/flash-content.query.js.map +1 -0
- package/dist/queries/linking-to-domains.query.d.ts +2 -0
- package/dist/queries/linking-to-domains.query.js +35 -27
- package/dist/queries/linking-to-domains.query.js.map +1 -0
- package/dist/queries/readability-score.query.d.ts +2 -0
- package/dist/queries/readability-score.query.js +21 -13
- package/dist/queries/readability-score.query.js.map +1 -0
- package/dist/servers/crawl.server.d.ts +35 -0
- package/dist/servers/crawl.server.js +133 -121
- package/dist/servers/crawl.server.js.map +1 -0
- package/dist/servers/express.server.d.ts +8 -0
- package/dist/servers/express.server.js +7 -10
- package/dist/servers/express.server.js.map +1 -0
- package/dist/servers/maintenance.server.d.ts +22 -0
- package/dist/servers/maintenance.server.js +42 -36
- package/dist/servers/maintenance.server.js.map +1 -0
- package/dist/servers/rest.server.d.ts +7 -0
- package/dist/servers/rest.server.js +40 -51
- package/dist/servers/rest.server.js.map +1 -0
- package/dist/servers/socket-io.server.d.ts +12 -0
- package/dist/servers/socket-io.server.js +48 -15
- package/dist/servers/socket-io.server.js.map +1 -0
- package/dist/services/database.service.d.ts +68 -0
- package/dist/services/database.service.js +527 -462
- package/dist/services/database.service.js.map +1 -0
- package/dist/types/tcrawl-config.d.ts +14 -0
- package/dist/types/tcrawl-config.js +14 -17
- package/dist/types/tcrawl-config.js.map +1 -0
- package/dist/types/thydra-config.d.ts +4 -0
- package/dist/types/thydra-config.js +4 -7
- package/dist/types/thydra-config.js.map +1 -0
- package/dist/types/tparser-ctor.d.ts +7 -0
- package/dist/types/tparser-ctor.js +2 -2
- package/dist/types/tparser-ctor.js.map +1 -0
- package/dist/types/tquery.d.ts +7 -0
- package/dist/types/tquery.js +2 -2
- package/dist/types/tquery.js.map +1 -0
- package/dist/types/trobots-config.d.ts +4 -0
- package/dist/types/trobots-config.js +4 -7
- package/dist/types/trobots-config.js.map +1 -0
- package/package.json +41 -29
- package/angular/10-es2015.bacd4ae5dd7913ce55f0.js +0 -1
- package/angular/10-es5.bacd4ae5dd7913ce55f0.js +0 -1
- package/angular/11-es2015.0f031dcf752d1e8eda6b.js +0 -1
- package/angular/11-es5.0f031dcf752d1e8eda6b.js +0 -1
- package/angular/3rdpartylicenses.txt +0 -1127
- package/angular/5-es2015.951498ca9c1bc74e57bf.js +0 -1
- package/angular/5-es5.951498ca9c1bc74e57bf.js +0 -1
- package/angular/6-es2015.65f680261a3506b88381.js +0 -1
- package/angular/6-es5.65f680261a3506b88381.js +0 -1
- package/angular/7-es2015.625197f3af1dbf3e805d.js +0 -1
- package/angular/7-es5.625197f3af1dbf3e805d.js +0 -1
- package/angular/8-es2015.55518901987a5b834309.js +0 -1
- package/angular/8-es5.55518901987a5b834309.js +0 -1
- package/angular/9-es2015.6cc9bde262564e7836f2.js +0 -1
- package/angular/9-es5.6cc9bde262564e7836f2.js +0 -1
- package/angular/Roboto-Black.41ed1105a6ebb8ffe34e.woff2 +0 -0
- package/angular/Roboto-Black.937491dfcbe64ca9a9f1.woff +0 -0
- package/angular/Roboto-BlackItalic.2e1ee657996854c6f427.woff +0 -0
- package/angular/Roboto-BlackItalic.50ca4c51ebc27e7e7d2f.woff2 +0 -0
- package/angular/Roboto-Bold.73288d91c325e82a5b92.woff +0 -0
- package/angular/Roboto-Bold.92fbd4e93cf0a5dbebaa.woff2 +0 -0
- package/angular/Roboto-BoldItalic.5f600d98a73d800ae575.woff2 +0 -0
- package/angular/Roboto-BoldItalic.6d89acbd21d7e3fbecb2.woff +0 -0
- package/angular/Roboto-Light.c27d89ac77468ae18f28.woff2 +0 -0
- package/angular/Roboto-Light.d923dfafc0c5183b59aa.woff +0 -0
- package/angular/Roboto-LightItalic.506274c7228cf81cae4d.woff2 +0 -0
- package/angular/Roboto-LightItalic.d4b8c137518d9d92bb28.woff +0 -0
- package/angular/Roboto-Medium.092c6130df8fd2199888.woff +0 -0
- package/angular/Roboto-Medium.1d3bced88509b0838984.woff2 +0 -0
- package/angular/Roboto-MediumItalic.18ff1628c628080166c1.woff +0 -0
- package/angular/Roboto-MediumItalic.d620b8f53f75966fe42e.woff2 +0 -0
- package/angular/Roboto-Regular.64cfb66c866ea50cad47.woff2 +0 -0
- package/angular/Roboto-Regular.e02e9d6ff5547f7e9962.woff +0 -0
- package/angular/Roboto-RegularItalic.4dd2af1e8df532f41db8.woff2 +0 -0
- package/angular/Roboto-RegularItalic.5ea38fff9eebef99c5df.woff +0 -0
- package/angular/Roboto-Thin.dbd56bd3357dc3617fe5.woff2 +0 -0
- package/angular/Roboto-Thin.e7f7c82374bd0ebef14b.woff +0 -0
- package/angular/Roboto-ThinItalic.5dd9349c940073834e9a.woff +0 -0
- package/angular/Roboto-ThinItalic.a8cef84f735ef887abdc.woff2 +0 -0
- package/angular/assets/config/app-config.json +0 -16
- package/angular/assets/images/splashbg.jpg +0 -0
- package/angular/assets/web-app-commons/fonts/material-icons/MaterialDesignIcons-Community-2.7.94.woff +0 -0
- package/angular/assets/web-app-commons/fonts/material-icons/MaterialDesignIcons-Community-2.7.94.woff2 +0 -0
- package/angular/assets/web-app-commons/fonts/material-icons/material-design-icons-community.css +0 -11293
- package/angular/favicon.ico +0 -0
- package/angular/flUhRq6tzZclQEJ-Vdg-IuiaDsNa.f2a0933406f783065152.woff +0 -0
- package/angular/flUhRq6tzZclQEJ-Vdg-IuiaDsNc.6467d9a24f234e8e8e07.woff2 +0 -0
- package/angular/index.html +0 -16
- package/angular/main-es2015.3a582572476c7f292e52.js +0 -1
- package/angular/main-es5.3a582572476c7f292e52.js +0 -1
- package/angular/polyfills-es2015.7df68534018bc2f6cb09.js +0 -1
- package/angular/polyfills-es5.e79468f406fae2989221.js +0 -1
- package/angular/runtime-es2015.6d2cff76cdb2790d3308.js +0 -1
- package/angular/runtime-es5.6d2cff76cdb2790d3308.js +0 -1
- package/angular/styles.c5c6c2534225b85c4ff0.css +0 -1
- package/config/bad-words.json +0 -1
- package/config/complex-english.json +0 -400
- package/config/hydra-auth.json +0 -8
- package/config/hydra-crawler.json +0 -84
- package/config/list-allow.json +0 -171
- package/config/list-deny.json +0 -248
- package/config/list-expiry.json +0 -7
- package/config/schedule.json +0 -25
- package/config/spelling.json +0 -1
package/dist/apps/cleanup.app.js
CHANGED
|
@@ -1,18 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
+
import { commonsTypeHasPropertyNumber } from 'tscommons-es-core';
|
|
11
|
+
import { isIUrl } from 'hydra-crawler-ts-assets';
|
|
12
|
+
import { EStatus } from 'hydra-crawler-ts-assets';
|
|
13
|
+
import { commonsOutputDoing, commonsOutputProgress, commonsOutputResult, commonsOutputSuccess } from 'nodecommons-es-cli';
|
|
14
|
+
import { CommonsApp } from 'nodecommons-es-app';
|
|
15
|
+
import { Lists } from '../classes/lists';
|
|
16
|
+
import { Cleaner } from '../classes/cleaner';
|
|
17
|
+
export class CleanupApp extends CommonsApp {
|
|
11
18
|
constructor(includeReset = false, includeLinks = false) {
|
|
12
19
|
super('hydra-crawler');
|
|
13
20
|
this.includeReset = includeReset;
|
|
14
21
|
this.includeLinks = includeLinks;
|
|
15
|
-
this.lists = new
|
|
22
|
+
this.lists = new Lists();
|
|
16
23
|
}
|
|
17
24
|
getAppName() {
|
|
18
25
|
return 'Hydra - Cleanup';
|
|
@@ -23,100 +30,111 @@ class CleanupApp extends nodecommons_app_1.CommonsApp {
|
|
|
23
30
|
addToList(list, entries) {
|
|
24
31
|
this.lists.add(list, entries);
|
|
25
32
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
+
init() {
|
|
34
|
+
const _super = Object.create(null, {
|
|
35
|
+
init: { get: () => super.init }
|
|
36
|
+
});
|
|
37
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
+
if (!this.databaseService)
|
|
39
|
+
throw new Error('Database service has not been set yet');
|
|
40
|
+
commonsOutputDoing('Connecting to database');
|
|
41
|
+
yield this.databaseService.init();
|
|
42
|
+
commonsOutputSuccess();
|
|
43
|
+
yield _super.init.call(this);
|
|
44
|
+
});
|
|
33
45
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
46
|
+
reset() {
|
|
47
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
+
if (!this.databaseService)
|
|
49
|
+
throw new Error('Database service has not been set');
|
|
50
|
+
commonsOutputDoing('Reseting urls for DENY, FAILED, DEAD and DISALLOWED');
|
|
51
|
+
let tally = 0;
|
|
52
|
+
while (true) {
|
|
53
|
+
const result = this.databaseService.getUrls()
|
|
54
|
+
.find({ status: { $in: [
|
|
55
|
+
EStatus.DENY,
|
|
56
|
+
EStatus.FAILED,
|
|
57
|
+
EStatus.DEAD,
|
|
58
|
+
EStatus.DISALLOWED
|
|
59
|
+
] } })
|
|
60
|
+
.sort({ _id: 1 })
|
|
61
|
+
.skip(tally);
|
|
62
|
+
try {
|
|
63
|
+
while (true) {
|
|
64
|
+
tally++;
|
|
65
|
+
if ((tally % 100) === 0)
|
|
66
|
+
commonsOutputProgress(tally);
|
|
67
|
+
const row = yield result.next();
|
|
68
|
+
if (row === null)
|
|
69
|
+
break;
|
|
70
|
+
yield this.databaseService.getLinks().deleteMany({ url: row.url });
|
|
71
|
+
}
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
catch (err) {
|
|
75
|
+
if (!commonsTypeHasPropertyNumber(err, 'code') || err.code !== 43)
|
|
76
|
+
throw err;
|
|
58
77
|
}
|
|
59
|
-
break;
|
|
60
|
-
}
|
|
61
|
-
catch (err) {
|
|
62
|
-
if (err.code !== 43)
|
|
63
|
-
throw err;
|
|
64
78
|
}
|
|
65
|
-
|
|
66
|
-
|
|
79
|
+
commonsOutputResult(tally);
|
|
80
|
+
});
|
|
67
81
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
batch.
|
|
85
|
-
|
|
86
|
-
batch.
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
.
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
82
|
+
links() {
|
|
83
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
84
|
+
if (!this.databaseService)
|
|
85
|
+
throw new Error('Database service has not been set');
|
|
86
|
+
commonsOutputDoing('Searching for link orphans');
|
|
87
|
+
let tally = 0;
|
|
88
|
+
const result = this.databaseService.getLinks().find({}, {});
|
|
89
|
+
let batch = [];
|
|
90
|
+
const orphans = [];
|
|
91
|
+
while (true) {
|
|
92
|
+
tally++;
|
|
93
|
+
if ((tally % 1000) === 0)
|
|
94
|
+
commonsOutputProgress(`${tally}, ${orphans.length}`);
|
|
95
|
+
const link = yield result.next();
|
|
96
|
+
if (link === null)
|
|
97
|
+
break;
|
|
98
|
+
if (!batch.includes(link.url))
|
|
99
|
+
batch.push(link.url);
|
|
100
|
+
if (!batch.includes(link.outgoing))
|
|
101
|
+
batch.push(link.outgoing);
|
|
102
|
+
if (batch.length < 10000)
|
|
103
|
+
continue;
|
|
104
|
+
const result2 = this.databaseService.getUrls().find({ url: { $in: batch } });
|
|
105
|
+
const matches = (yield this.databaseService.listQueryResults(result2, isIUrl))
|
|
106
|
+
.map((u) => u.url);
|
|
107
|
+
for (const l of batch) {
|
|
108
|
+
if (!matches.includes(l))
|
|
109
|
+
orphans.push(l);
|
|
110
|
+
}
|
|
111
|
+
batch = [];
|
|
112
|
+
}
|
|
113
|
+
commonsOutputResult(orphans.length);
|
|
114
|
+
commonsOutputDoing('Removing orphan links');
|
|
115
|
+
tally = 0;
|
|
116
|
+
for (const orphan of orphans) {
|
|
117
|
+
tally++;
|
|
118
|
+
if ((tally % 100) === 0)
|
|
119
|
+
commonsOutputProgress(`${tally}`);
|
|
120
|
+
yield this.databaseService.getLinks().deleteMany({ url: orphan });
|
|
121
|
+
yield this.databaseService.getLinks().deleteMany({ outgoing: orphan });
|
|
95
122
|
}
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
nodecommons_cli_1.CommonsOutput.result(orphans.length);
|
|
99
|
-
nodecommons_cli_1.CommonsOutput.doing(`Removing orphan links`);
|
|
100
|
-
tally = 0;
|
|
101
|
-
for (const orphan of orphans) {
|
|
102
|
-
tally++;
|
|
103
|
-
if ((tally % 100) === 0)
|
|
104
|
-
nodecommons_cli_1.CommonsOutput.progress(`${tally}`);
|
|
105
|
-
await this.databaseService.getLinks().deleteMany({ url: orphan });
|
|
106
|
-
await this.databaseService.getLinks().deleteMany({ outgoing: orphan });
|
|
107
|
-
}
|
|
108
|
-
nodecommons_cli_1.CommonsOutput.success();
|
|
123
|
+
commonsOutputSuccess();
|
|
124
|
+
});
|
|
109
125
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
126
|
+
run() {
|
|
127
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
128
|
+
if (!this.databaseService)
|
|
129
|
+
throw new Error('Database service has not been set');
|
|
130
|
+
if (!this.includeReset)
|
|
131
|
+
yield this.reset();
|
|
132
|
+
if (!this.includeLinks)
|
|
133
|
+
yield this.links();
|
|
134
|
+
const cleaner = new Cleaner(this.lists, this.databaseService);
|
|
135
|
+
yield cleaner.purgeOrphanUrls();
|
|
136
|
+
yield cleaner.purgeEmptyDomains();
|
|
137
|
+
});
|
|
120
138
|
}
|
|
121
139
|
}
|
|
122
|
-
|
|
140
|
+
//# sourceMappingURL=cleanup.app.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cleanup.app.js","sourceRoot":"","sources":["../../src/apps/cleanup.app.ts"],"names":[],"mappings":";;;;;;;;;AAEA,OAAO,EAAE,4BAA4B,EAAE,MAAM,mBAAmB,CAAC;AAEjE,OAAO,EAAQ,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAEvD,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAElD,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1H,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAU7C,MAAM,OAAO,UAAW,SAAQ,UAAU;IAKzC,YACU,eAAwB,KAAK,EAC7B,eAAwB,KAAK;QAEtC,KAAK,CAAC,eAAe,CAAC,CAAC;QAHd,iBAAY,GAAZ,YAAY,CAAiB;QAC7B,iBAAY,GAAZ,YAAY,CAAiB;QAItC,IAAI,CAAC,KAAK,GAAG,IAAI,KAAK,EAAE,CAAC;IAC1B,CAAC;IAEM,UAAU;QAChB,OAAO,iBAAiB,CAAC;IAC1B,CAAC;IAEM,kBAAkB,CACvB,eAAgC;QAEjC,IAAI,CAAC,eAAe,GAA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,IAAI,CAAC,eAAe;gBAAE,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;YAEhF,IAAI,CAAC,IAAI,CAAC,YAAY;gBAAE,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC;YAC3C,IAAI,CAAC,IAAI,CAAC,YAAY;gBAAE,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC;YAE3C,MAAM,OAAO,GAAY,IAAI,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,eAAe,CAAC,CAAC;YACvE,MAAM,OAAO,CAAC,eAAe,EAAE,CAAC;YAChC,MAAM,OAAO,CAAC,iBAAiB,EAAE,CAAC;QACnC,CAAC;KAAA;CACD"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { CommonsApp } from 'nodecommons-es-app';
|
|
2
|
+
import { DatabaseService } from '../services/database.service';
|
|
3
|
+
import { IInternalHydraCommonDbApp } from './internal-hydra-common.app';
|
|
4
|
+
export declare class CrossPopulateExportApp extends CommonsApp implements IInternalHydraCommonDbApp {
|
|
5
|
+
private filename;
|
|
6
|
+
private databaseService;
|
|
7
|
+
constructor(filename: string);
|
|
8
|
+
getAppName(): string;
|
|
9
|
+
setDatabaseService(databaseService: DatabaseService): void;
|
|
10
|
+
init(): Promise<void>;
|
|
11
|
+
run(): Promise<void>;
|
|
12
|
+
}
|
|
@@ -1,12 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
+
import * as fs from 'fs';
|
|
11
|
+
import { EStatus } from 'hydra-crawler-ts-assets';
|
|
12
|
+
import { commonsOutputDoing, commonsOutputProgress, commonsOutputResult, commonsOutputSuccess } from 'nodecommons-es-cli';
|
|
13
|
+
import { CommonsApp } from 'nodecommons-es-app';
|
|
8
14
|
// export the QUEUED, DONE and FAILED urls for importing into another instance
|
|
9
|
-
class CrossPopulateExportApp extends
|
|
15
|
+
export class CrossPopulateExportApp extends CommonsApp {
|
|
10
16
|
constructor(filename) {
|
|
11
17
|
super('hydra-crawler');
|
|
12
18
|
this.filename = filename;
|
|
@@ -17,46 +23,53 @@ class CrossPopulateExportApp extends nodecommons_app_1.CommonsApp {
|
|
|
17
23
|
setDatabaseService(databaseService) {
|
|
18
24
|
this.databaseService = databaseService;
|
|
19
25
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
init() {
|
|
27
|
+
const _super = Object.create(null, {
|
|
28
|
+
init: { get: () => super.init }
|
|
29
|
+
});
|
|
30
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
31
|
+
if (!this.databaseService)
|
|
32
|
+
throw new Error('Database service has not been set yet');
|
|
33
|
+
commonsOutputDoing('Connecting to database');
|
|
34
|
+
yield this.databaseService.init();
|
|
35
|
+
commonsOutputSuccess();
|
|
36
|
+
yield _super.init.call(this);
|
|
37
|
+
});
|
|
27
38
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
39
|
+
run() {
|
|
40
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
+
if (!this.databaseService)
|
|
42
|
+
throw new Error('Database service has not been set');
|
|
43
|
+
const results = this.databaseService.getUrls().find({
|
|
44
|
+
status: { $in: [
|
|
45
|
+
EStatus.QUEUED,
|
|
46
|
+
EStatus.DONE,
|
|
47
|
+
EStatus.FAILED
|
|
48
|
+
] }
|
|
49
|
+
}, {});
|
|
50
|
+
// safer to do this directly rather than a call to listQueryResults
|
|
51
|
+
// ditto not using CommonsFile
|
|
52
|
+
const fd = fs.openSync(this.filename, 'w');
|
|
53
|
+
commonsOutputDoing('Exporting QUEUED, DONE and FAILED urls');
|
|
54
|
+
let tally = 0;
|
|
55
|
+
while (true) {
|
|
56
|
+
if (tally % 1000 === 0)
|
|
57
|
+
commonsOutputProgress(tally);
|
|
58
|
+
const row = yield results.next();
|
|
59
|
+
if (row === null)
|
|
60
|
+
break;
|
|
61
|
+
fs.writeSync(fd, JSON.stringify({
|
|
62
|
+
domain: row.domain,
|
|
63
|
+
url: row.url
|
|
64
|
+
}) + '\n');
|
|
65
|
+
if (tally % 1000 === 0)
|
|
66
|
+
fs.fdatasyncSync(fd);
|
|
67
|
+
tally++;
|
|
68
|
+
}
|
|
69
|
+
fs.fdatasyncSync(fd);
|
|
70
|
+
fs.closeSync(fd);
|
|
71
|
+
commonsOutputResult(tally);
|
|
37
72
|
});
|
|
38
|
-
// safer to do this directly rather than a call to listQueryResults
|
|
39
|
-
// ditto not using CommonsFile
|
|
40
|
-
const fd = fs.openSync(this.filename, 'w');
|
|
41
|
-
nodecommons_cli_1.CommonsOutput.doing('Exporting QUEUED, DONE and FAILED urls');
|
|
42
|
-
let tally = 0;
|
|
43
|
-
while (true) {
|
|
44
|
-
if (tally % 1000 === 0)
|
|
45
|
-
nodecommons_cli_1.CommonsOutput.progress(tally);
|
|
46
|
-
const row = await results.next();
|
|
47
|
-
if (row === null)
|
|
48
|
-
break;
|
|
49
|
-
fs.writeSync(fd, JSON.stringify({
|
|
50
|
-
domain: row.domain,
|
|
51
|
-
url: row.url
|
|
52
|
-
}) + '\n');
|
|
53
|
-
if (tally % 1000 === 0)
|
|
54
|
-
fs.fdatasyncSync(fd);
|
|
55
|
-
tally++;
|
|
56
|
-
}
|
|
57
|
-
fs.fdatasyncSync(fd);
|
|
58
|
-
fs.closeSync(fd);
|
|
59
|
-
nodecommons_cli_1.CommonsOutput.result(tally);
|
|
60
73
|
}
|
|
61
74
|
}
|
|
62
|
-
|
|
75
|
+
//# sourceMappingURL=cross-populate-export.app.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cross-populate-export.app.js","sourceRoot":"","sources":["../../src/apps/cross-populate-export.app.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AAKzB,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAElD,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1H,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAMhD,8EAA8E;AAE9E,MAAM,OAAO,sBAAuB,SAAQ,UAAU;IAGrD,YACU,QAAgB;QAEzB,KAAK,CAAC,eAAe,CAAC,CAAC;QAFd,aAAQ,GAAR,QAAQ,CAAQ;IAG1B,CAAC;IAEM,UAAU;QAChB,OAAO,+BAA+B,CAAC;IACxC,CAAC;IAEM,kBAAkB,CACvB,eAAgC;QAEjC,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;IACxC,CAAC;IAEY,IAAI;;;;;YAChB,IAAI,CAAC,IAAI,CAAC,eAAe;gBAAE,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;YAEpF,kBAAkB,CAAC,wBAAwB,CAAC,CAAC;YAC7C,MAAM,IAAI,CAAC,eAAe,CAAC,IAAI,EAAE,CAAC;YAClC,oBAAoB,EAAE,CAAC;YAEvB,MAAM,OAAM,IAAI,WAAE,CAAC;QACpB,CAAC;KAAA;I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
|
|
1
|
+
import { CommonsApp } from 'nodecommons-es-app';
|
|
2
|
+
import { DatabaseService } from '../services/database.service';
|
|
3
|
+
import { IInternalHydraCommonDbApp } from './internal-hydra-common.app';
|
|
4
|
+
export declare class CrossPopulateImportApp extends CommonsApp implements IInternalHydraCommonDbApp {
|
|
5
|
+
private filename;
|
|
6
|
+
private databaseService;
|
|
7
|
+
constructor(filename: string);
|
|
8
|
+
getAppName(): string;
|
|
9
|
+
setDatabaseService(databaseService: DatabaseService): void;
|
|
10
|
+
init(): Promise<void>;
|
|
11
|
+
run(): Promise<void>;
|
|
12
|
+
}
|
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
|
|
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
|
+
};
|
|
2
10
|
var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
3
11
|
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
4
12
|
var m = o[Symbol.asyncIterator], i;
|
|
@@ -6,21 +14,19 @@ var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
|
6
14
|
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
7
15
|
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
8
16
|
};
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const nodecommons_cli_1 = require("nodecommons-cli");
|
|
15
|
-
const nodecommons_app_1 = require("nodecommons-app");
|
|
17
|
+
import * as fs from 'fs';
|
|
18
|
+
import * as readline from 'readline';
|
|
19
|
+
import { commonsTypeHasPropertyString } from 'tscommons-es-core';
|
|
20
|
+
import { commonsOutputDoing, commonsOutputError, commonsOutputProgress, commonsOutputResult, commonsOutputSuccess } from 'nodecommons-es-cli';
|
|
21
|
+
import { CommonsApp } from 'nodecommons-es-app';
|
|
16
22
|
function isTRow(test) {
|
|
17
|
-
if (!
|
|
23
|
+
if (!commonsTypeHasPropertyString(test, 'domain'))
|
|
18
24
|
return false;
|
|
19
|
-
if (!
|
|
25
|
+
if (!commonsTypeHasPropertyString(test, 'url'))
|
|
20
26
|
return false;
|
|
21
27
|
return true;
|
|
22
28
|
}
|
|
23
|
-
class CrossPopulateImportApp extends
|
|
29
|
+
export class CrossPopulateImportApp extends CommonsApp {
|
|
24
30
|
constructor(filename) {
|
|
25
31
|
super('hydra-crawler');
|
|
26
32
|
this.filename = filename;
|
|
@@ -31,50 +37,57 @@ class CrossPopulateImportApp extends nodecommons_app_1.CommonsApp {
|
|
|
31
37
|
setDatabaseService(databaseService) {
|
|
32
38
|
this.databaseService = databaseService;
|
|
33
39
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
40
|
+
init() {
|
|
41
|
+
const _super = Object.create(null, {
|
|
42
|
+
init: { get: () => super.init }
|
|
43
|
+
});
|
|
44
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
if (!this.databaseService)
|
|
46
|
+
throw new Error('Database service has not been set yet');
|
|
47
|
+
commonsOutputDoing('Connecting to database');
|
|
48
|
+
yield this.databaseService.init();
|
|
49
|
+
commonsOutputSuccess();
|
|
50
|
+
yield _super.init.call(this);
|
|
51
|
+
});
|
|
41
52
|
}
|
|
42
|
-
|
|
53
|
+
run() {
|
|
43
54
|
var e_1, _a;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
55
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
56
|
+
if (!this.databaseService)
|
|
57
|
+
throw new Error('Database service has not been set');
|
|
58
|
+
const fileStream = fs.createReadStream(this.filename);
|
|
59
|
+
const rl = readline.createInterface({
|
|
60
|
+
input: fileStream,
|
|
61
|
+
crlfDelay: Infinity
|
|
62
|
+
});
|
|
63
|
+
commonsOutputDoing('Importing urls');
|
|
64
|
+
let tally = 0;
|
|
65
|
+
try {
|
|
66
|
+
for (var rl_1 = __asyncValues(rl), rl_1_1; rl_1_1 = yield rl_1.next(), !rl_1_1.done;) {
|
|
67
|
+
const line = rl_1_1.value;
|
|
68
|
+
if (line.trim() === '')
|
|
69
|
+
continue;
|
|
70
|
+
if (tally % 1000 === 0)
|
|
71
|
+
commonsOutputProgress(tally);
|
|
72
|
+
const json = JSON.parse(line);
|
|
73
|
+
if (!isTRow(json)) {
|
|
74
|
+
commonsOutputError('Invalid row. Skipping');
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
yield this.databaseService.queue(json.url, false);
|
|
78
|
+
tally++;
|
|
64
79
|
}
|
|
65
|
-
await this.databaseService.queue(json.url, false);
|
|
66
|
-
tally++;
|
|
67
80
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
81
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
82
|
+
finally {
|
|
83
|
+
try {
|
|
84
|
+
if (rl_1_1 && !rl_1_1.done && (_a = rl_1.return)) yield _a.call(rl_1);
|
|
85
|
+
}
|
|
86
|
+
finally { if (e_1) throw e_1.error; }
|
|
73
87
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
fileStream.close();
|
|
88
|
+
commonsOutputResult(tally);
|
|
89
|
+
fileStream.close();
|
|
90
|
+
});
|
|
78
91
|
}
|
|
79
92
|
}
|
|
80
|
-
|
|
93
|
+
//# sourceMappingURL=cross-populate-import.app.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cross-populate-import.app.js","sourceRoot":"","sources":["../../src/apps/cross-populate-import.app.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,QAAQ,MAAM,UAAU,CAAC;AAErC,OAAO,EAAE,4BAA4B,EAAE,MAAM,mBAAmB,CAAC;AAEjE,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC9I,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAahD,SAAS,MAAM,CAAC,IAAa;IAC5B,IAAI,CAAC,4BAA4B,CAAC,IAAI,EAAE,QAAQ,CAAC;QAAE,OAAO,KAAK,CAAC;IAChE,IAAI,CAAC,4BAA4B,CAAC,IAAI,EAAE,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAE7D,OAAO,IAAI,CAAC;AACb,CAAC;AAED,MAAM,OAAO,sBAAuB,SAAQ,UAAU;IAGrD,YACU,QAAgB;QAEzB,KAAK,CAAC,eAAe,CAAC,CAAC;QAFd,aAAQ,GAAR,QAAQ,CAAQ;IAG1B,CAAC;IAEM,UAAU;QAChB,OAAO,+BAA+B,CAAC;IACxC,CAAC;IAEM,kBAAkB,CACvB,eAAgC;QAEjC,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;I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CAAC,KAAK,CAAC,CAAC;YAE3B,UAAU,CAAC,KAAK,EAAE,CAAC;;KACnB;CACD"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { CommonsApp } from 'nodecommons-es-app';
|
|
2
|
+
import { DatabaseService } from '../services/database.service';
|
|
3
|
+
import { IMatch } from '../interfaces/imatch';
|
|
4
|
+
import { EList } from '../enums/elist';
|
|
5
|
+
import { IInternalHydraCommonListApp } from './internal-hydra-common.app';
|
|
6
|
+
export declare class DenylistApp extends CommonsApp implements IInternalHydraCommonListApp {
|
|
7
|
+
private databaseService;
|
|
8
|
+
private lists;
|
|
9
|
+
constructor();
|
|
10
|
+
getAppName(): string;
|
|
11
|
+
setDatabaseService(databaseService: DatabaseService): void;
|
|
12
|
+
addToList(list: EList, entries: IMatch[]): void;
|
|
13
|
+
init(): Promise<void>;
|
|
14
|
+
private forward;
|
|
15
|
+
private reverse;
|
|
16
|
+
run(): Promise<void>;
|
|
17
|
+
}
|