@magda/minion-framework 2.3.3 → 3.0.0-alpha.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/dist/Crawler.d.ts +8 -8
- package/dist/Crawler.js +62 -99
- package/dist/Crawler.js.map +1 -1
- package/dist/MinionOptions.d.ts +6 -5
- package/dist/MinionOptions.js +1 -2
- package/dist/buildWebhookConfig.d.ts +2 -2
- package/dist/buildWebhookConfig.js +4 -7
- package/dist/buildWebhookConfig.js.map +1 -1
- package/dist/commonYargs.d.ts +10 -10
- package/dist/commonYargs.js +31 -37
- package/dist/commonYargs.js.map +1 -1
- package/dist/getWebhookUrl.d.ts +1 -1
- package/dist/getWebhookUrl.js +2 -5
- package/dist/getWebhookUrl.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +111 -127
- package/dist/index.js.map +1 -1
- package/dist/isWebhookRegistered.d.ts +2 -2
- package/dist/isWebhookRegistered.js +14 -31
- package/dist/isWebhookRegistered.js.map +1 -1
- package/dist/registerWebhook.d.ts +5 -5
- package/dist/registerWebhook.js +33 -50
- package/dist/registerWebhook.js.map +1 -1
- package/dist/resumeWebhook.d.ts +3 -3
- package/dist/resumeWebhook.js +8 -22
- package/dist/resumeWebhook.js.map +1 -1
- package/dist/setupRecrawlEndpoint.d.ts +30 -30
- package/dist/setupRecrawlEndpoint.js +46 -45
- package/dist/setupRecrawlEndpoint.js.map +1 -1
- package/dist/setupWebhookEndpoint.d.ts +2 -2
- package/dist/setupWebhookEndpoint.js +22 -47
- package/dist/setupWebhookEndpoint.js.map +1 -1
- package/dist/startApiEndpoints.d.ts +1 -1
- package/dist/startApiEndpoints.js +4 -10
- package/dist/startApiEndpoints.js.map +1 -1
- package/dist/test/Crawler.spec.js +77 -93
- package/dist/test/Crawler.spec.js.map +1 -1
- package/dist/test/baseSpec.d.ts +10 -10
- package/dist/test/baseSpec.js +23 -25
- package/dist/test/baseSpec.js.map +1 -1
- package/dist/test/fakeArgv.d.ts +3 -3
- package/dist/test/fakeArgv.js +6 -6
- package/dist/test/fakeArgv.js.map +1 -1
- package/dist/test/makePromiseQueryable.d.ts +2 -2
- package/dist/test/makePromiseQueryable.js +2 -5
- package/dist/test/makePromiseQueryable.js.map +1 -1
- package/dist/test/registry.spec.js +27 -32
- package/dist/test/registry.spec.js.map +1 -1
- package/dist/test/setupRecrawlEndpoint.spec.js +29 -43
- package/dist/test/setupRecrawlEndpoint.spec.js.map +1 -1
- package/dist/test/startup.spec.js +33 -38
- package/dist/test/startup.spec.js.map +1 -1
- package/dist/test/webhooks.spec.js +43 -43
- package/dist/test/webhooks.spec.js.map +1 -1
- package/package.json +33 -21
|
@@ -1,75 +1,76 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
1
|
/**
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
function setupRecrawlEndpoint(server, options, crawler) {
|
|
2
|
+
* @apiGroup Minions
|
|
3
|
+
* @api {post} /v0/minions/recrawl Make the minion recrawl the registry
|
|
4
|
+
*
|
|
5
|
+
* @apiDescription Make the minion recrawl the registry
|
|
6
|
+
*
|
|
7
|
+
* @apiSuccess (Success 200) {json} Response the minion recrawl status
|
|
8
|
+
* @apiSuccessExample {json} Response:
|
|
9
|
+
* {
|
|
10
|
+
* isSuccess: true,
|
|
11
|
+
* isNewCrawler: true
|
|
12
|
+
* }
|
|
13
|
+
* @apiUse GenericErrorMinionJson
|
|
14
|
+
*/
|
|
15
|
+
export default function setupRecrawlEndpoint(server, options, crawler) {
|
|
18
16
|
server.post("/recrawl", (request, response) => {
|
|
19
17
|
try {
|
|
20
18
|
if (crawler.isInProgress()) {
|
|
21
19
|
response.status(200).json({
|
|
22
20
|
isSuccess: true,
|
|
23
|
-
isNewCrawler: false
|
|
24
|
-
|
|
21
|
+
isNewCrawler: false
|
|
22
|
+
});
|
|
25
23
|
} else
|
|
26
24
|
{
|
|
27
25
|
crawler.start();
|
|
28
26
|
response.status(200).json({
|
|
29
27
|
isSuccess: true,
|
|
30
|
-
isNewCrawler: true
|
|
31
|
-
|
|
28
|
+
isNewCrawler: true
|
|
29
|
+
});
|
|
32
30
|
}
|
|
33
31
|
}
|
|
34
32
|
catch (e) {
|
|
35
33
|
response.status(500).json({
|
|
36
34
|
isSuccess: false,
|
|
37
|
-
errorMessage: e
|
|
38
|
-
|
|
35
|
+
errorMessage: e?.message ?
|
|
36
|
+
e.message :
|
|
37
|
+
"Unknown Error"
|
|
38
|
+
});
|
|
39
39
|
}
|
|
40
40
|
});
|
|
41
41
|
/**
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
42
|
+
* @apiGroup Minions
|
|
43
|
+
* @api {get} /v0/minions/crawlerProgress Get the minion recrawl progress
|
|
44
|
+
*
|
|
45
|
+
* @apiDescription Get the minion recrawl progress
|
|
46
|
+
*
|
|
47
|
+
* @apiSuccess (Success 200) {json} Response the minion recrawl progress
|
|
48
|
+
* @apiSuccessExample {json} Response:
|
|
49
|
+
* {
|
|
50
|
+
* isSuccess: true,
|
|
51
|
+
* progress: {
|
|
52
|
+
* isCrawling: true,
|
|
53
|
+
* crawlingPageToken: "101",
|
|
54
|
+
* crawledRecordNumber: 100
|
|
55
|
+
* }
|
|
56
|
+
* }
|
|
57
|
+
* @apiUse GenericErrorMinionJson
|
|
58
|
+
*/
|
|
59
59
|
server.get("/crawlerProgress", (request, response) => {
|
|
60
60
|
try {
|
|
61
61
|
const progress = crawler.getProgress();
|
|
62
62
|
response.status(200).json({
|
|
63
63
|
isSuccess: true,
|
|
64
|
-
progress
|
|
65
|
-
|
|
64
|
+
progress
|
|
65
|
+
});
|
|
66
66
|
}
|
|
67
67
|
catch (e) {
|
|
68
68
|
response.status(500).json({
|
|
69
69
|
isSuccess: false,
|
|
70
|
-
errorMessage: e.message ?
|
|
71
|
-
|
|
70
|
+
errorMessage: e.message ?
|
|
71
|
+
e.message :
|
|
72
|
+
"Unknown Error"
|
|
73
|
+
});
|
|
72
74
|
}
|
|
73
75
|
});
|
|
74
|
-
}
|
|
75
|
-
exports.default = setupRecrawlEndpoint;
|
|
76
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setupRecrawlEndpoint.js","sourceRoot":"","sources":["../src/setupRecrawlEndpoint.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"setupRecrawlEndpoint.js","sourceRoot":"","sources":["../src/setupRecrawlEndpoint.ts"],"names":[],"mappings":"AAgCA;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,OAAO,UAAU,oBAAoB,CACxC,MAAmB,EACnB,OAAsB,EACtB,OAAgB;IAEhB,MAAM,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,OAAO,EAAE,QAAQ,EAAE,EAAE;QAC1C,IAAI;YACA,IAAI,OAAO,CAAC,YAAY,EAAE,EAAE;gBACxB,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;oBACtB,SAAS,EAAE,IAAI;oBACf,YAAY,EAAE,KAAK;iBACtB,CAAC,CAAC;aACN;iBAAM;gBACH,OAAO,CAAC,KAAK,EAAE,CAAC;gBAChB,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;oBACtB,SAAS,EAAE,IAAI;oBACf,YAAY,EAAE,IAAI;iBACrB,CAAC,CAAC;aACN;SACJ;QAAC,OAAO,CAAC,EAAE;YACR,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;gBACtB,SAAS,EAAE,KAAK;gBAChB,YAAY,EAAG,CAAS,EAAE,OAAO;oBAC7B,CAAC,CAAE,CAAS,CAAC,OAAO;oBACpB,CAAC,CAAC,eAAe;aACxB,CAAC,CAAC;SACN;IACL,CAAC,CAAC,CAAC;IAEH;;;;;;;;;;;;;;;;;OAiBG;IACH,MAAM,CAAC,GAAG,CAAC,kBAAkB,EAAE,CAAC,OAAO,EAAE,QAAQ,EAAE,EAAE;QACjD,IAAI;YACA,MAAM,QAAQ,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;YACvC,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;gBACtB,SAAS,EAAE,IAAI;gBACf,QAAQ;aACX,CAAC,CAAC;SACN;QAAC,OAAO,CAAC,EAAE;YACR,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;gBACtB,SAAS,EAAE,KAAK;gBAChB,YAAY,EAAG,CAAS,CAAC,OAAO;oBAC5B,CAAC,CAAE,CAAS,CAAC,OAAO;oBACpB,CAAC,CAAC,eAAe;aACxB,CAAC,CAAC;SACN;IACL,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import express from "express";
|
|
2
|
-
import Registry from "@magda/typescript-common/dist/registry/AuthorizedRegistryClient";
|
|
3
|
-
import MinionOptions from "./MinionOptions";
|
|
2
|
+
import Registry from "@magda/typescript-common/dist/registry/AuthorizedRegistryClient.js";
|
|
3
|
+
import MinionOptions from "./MinionOptions.js";
|
|
4
4
|
export default function setupWebhookEndpoint(server: express.Application, options: MinionOptions, registry: Registry): void;
|
|
@@ -1,37 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
} : function (o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
});
|
|
9
|
-
var __setModuleDefault = this && this.__setModuleDefault || (Object.create ? function (o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
} : function (o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = this && this.__importStar || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
var __importDefault = this && this.__importDefault || function (mod) {
|
|
22
|
-
return mod && mod.__esModule ? mod : { "default": mod };
|
|
23
|
-
};
|
|
24
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
const lodash_1 = __importDefault(require("lodash"));
|
|
26
|
-
const unionToThrowable_1 = __importDefault(require("@magda/typescript-common/dist/util/unionToThrowable"));
|
|
27
|
-
const AsyncPage_1 = __importStar(require("@magda/typescript-common/dist/AsyncPage"));
|
|
28
|
-
function setupWebhookEndpoint(server, options, registry) {
|
|
1
|
+
import _ from "lodash";
|
|
2
|
+
import unionToThrowable from "@magda/typescript-common/dist/util/unionToThrowable.js";
|
|
3
|
+
import AsyncPage, { forEachAsync } from "@magda/typescript-common/dist/AsyncPage.js";
|
|
4
|
+
export default function setupWebhookEndpoint(server, options, registry) {
|
|
29
5
|
server.post("/hook", (request, response) => {
|
|
30
6
|
const payload = request.body;
|
|
31
|
-
const recordsPage =
|
|
32
|
-
const megaPromise =
|
|
33
|
-
const lastEventIdExists = !
|
|
34
|
-
const deferredResponseUrlExists = !
|
|
7
|
+
const recordsPage = AsyncPage.single(payload.records);
|
|
8
|
+
const megaPromise = forEachAsync(recordsPage, options.concurrency || 1, (record) => options.onRecordFound(record, registry));
|
|
9
|
+
const lastEventIdExists = !_.isUndefined(payload.lastEventId);
|
|
10
|
+
const deferredResponseUrlExists = !_.isUndefined(payload.deferredResponseUrl);
|
|
35
11
|
if (options.async) {
|
|
36
12
|
if (!lastEventIdExists) {
|
|
37
13
|
console.warn("No event id was passed so the minion can't operate asynchronously - reverting to synchronous mode");
|
|
@@ -45,17 +21,17 @@ function setupWebhookEndpoint(server, options, registry) {
|
|
|
45
21
|
deferredResponseUrlExists) {
|
|
46
22
|
response.status(201).send({
|
|
47
23
|
status: "Working",
|
|
48
|
-
deferResponse: true
|
|
49
|
-
|
|
50
|
-
const sendResult = success => registry.
|
|
24
|
+
deferResponse: true
|
|
25
|
+
});
|
|
26
|
+
const sendResult = (success) => registry.
|
|
51
27
|
resumeHook(options.id, success, payload.lastEventId).
|
|
52
|
-
then(
|
|
53
|
-
then(result => {
|
|
28
|
+
then(unionToThrowable).
|
|
29
|
+
then((result) => {
|
|
54
30
|
console.info("Successfully posted back to registry for event " +
|
|
55
31
|
payload.lastEventId);
|
|
56
32
|
return result;
|
|
57
33
|
}).
|
|
58
|
-
catch(error => {
|
|
34
|
+
catch((error) => {
|
|
59
35
|
console.error(error);
|
|
60
36
|
throw error;
|
|
61
37
|
});
|
|
@@ -63,10 +39,10 @@ function setupWebhookEndpoint(server, options, registry) {
|
|
|
63
39
|
then(() =>
|
|
64
40
|
// On success, send the result as true, if we fail to send the result (even though the hook worked) then just log
|
|
65
41
|
// the error - this is presumably because the registry has gone down, when it comes back up it'll resume the hook.
|
|
66
|
-
sendResult(true).catch(err => {
|
|
42
|
+
sendResult(true).catch((err) => {
|
|
67
43
|
console.error(err);
|
|
68
44
|
})).
|
|
69
|
-
catch(err => {
|
|
45
|
+
catch((err) => {
|
|
70
46
|
// Something has actually gone wrong with the minion behaviour itself that hasn't been handled by the minion.
|
|
71
47
|
// We class this as pretty catastrophic, so we log it and shut down the hook (set to inactive)
|
|
72
48
|
// TODO: Figure out some way to notify of failures.
|
|
@@ -80,17 +56,16 @@ function setupWebhookEndpoint(server, options, registry) {
|
|
|
80
56
|
then(() => {
|
|
81
57
|
response.status(201).send({
|
|
82
58
|
status: "Received",
|
|
83
|
-
deferResponse: false
|
|
84
|
-
|
|
59
|
+
deferResponse: false
|
|
60
|
+
});
|
|
85
61
|
}).
|
|
86
|
-
catch(e => {
|
|
62
|
+
catch((e) => {
|
|
87
63
|
console.error(e);
|
|
88
64
|
response.status(500).send({
|
|
89
65
|
status: "Error",
|
|
90
|
-
deferResponse: false
|
|
91
|
-
|
|
66
|
+
deferResponse: false
|
|
67
|
+
});
|
|
92
68
|
});
|
|
93
69
|
}
|
|
94
70
|
});
|
|
95
|
-
}
|
|
96
|
-
exports.default = setupWebhookEndpoint;
|
|
71
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setupWebhookEndpoint.js","sourceRoot":"","sources":["../src/setupWebhookEndpoint.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"setupWebhookEndpoint.js","sourceRoot":"","sources":["../src/setupWebhookEndpoint.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,QAAQ,CAAC;AAKvB,OAAO,gBAAgB,MAAM,sDAAsD,CAAC;AAIpF,OAAO,SAAS,EAAE,EACd,YAAY,EACf,MAAM,0CAA0C,CAAC;AAElD,MAAM,CAAC,OAAO,UAAU,oBAAoB,CACxC,MAA2B,EAC3B,OAAsB,EACtB,QAAkB;IAElB,MAAM,CAAC,IAAI,CACP,OAAO,EACP,CAAC,OAAwB,EAAE,QAA0B,EAAE,EAAE;QACrD,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;QAE7B,MAAM,WAAW,GAAG,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QACtD,MAAM,WAAW,GAAG,YAAY,CAC5B,WAAW,EACX,OAAO,CAAC,WAAW,IAAI,CAAC,EACxB,CAAC,MAAc,EAAE,EAAE,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,EAAE,QAAQ,CAAC,CAC9D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KAAK,CAAC,GAAG,CAAC,CAAC;YACvB,CAAC,CAAC,CACL;iBACA,KAAK,CAAC,CAAC,GAAU,EAAE,EAAE;gBAClB,6GAA6G;gBAC7G,8FAA8F;gBAC9F,mDAAmD;gBACnD,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;gBAEnB,OAAO,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC;gBACzC,OAAO,QAAQ,CAAC,UAAU,CACtB,OAAO,CAAC,EAAE,EACV,KAAK,EACL,OAAO,CAAC,WAAW,EACnB,KAAK,CACR,CAAC;YACN,CAAC,CAAC,CAAC;SACV;aAAM;YACH,WAAW;iBACN,IAAI,CAAC,GAAG,EAAE;gBACP,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;oBACtB,MAAM,EAAE,UAAU;oBAClB,aAAa,EAAE,KAAK;iBACvB,CAAC,CAAC;YACP,CAAC,CAAC;iBACD,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;gBACT,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;gBACjB,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;oBACtB,MAAM,EAAE,OAAO;oBACf,aAAa,EAAE,KAAK;iBACvB,CAAC,CAAC;YACP,CAAC,CAAC,CAAC;SACV;IACL,CAAC,CACJ,CAAC;AACN,CAAC"}
|
|
@@ -1,14 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return mod && mod.__esModule ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const getWebhookUrl_1 = __importDefault(require("./getWebhookUrl"));
|
|
7
|
-
function startApiEndpoints(server, options) {
|
|
1
|
+
import getWebhookUrl from "./getWebhookUrl.js";
|
|
2
|
+
export default function startApiEndpoints(server, options) {
|
|
8
3
|
function getPort() {
|
|
9
4
|
return options.argv.listenPort;
|
|
10
5
|
}
|
|
11
6
|
server.listen(getPort());
|
|
12
|
-
console.info(`Listening at ${
|
|
13
|
-
}
|
|
14
|
-
exports.default = startApiEndpoints;
|
|
7
|
+
console.info(`Listening at ${getWebhookUrl(options)}`);
|
|
8
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"startApiEndpoints.js","sourceRoot":"","sources":["../src/startApiEndpoints.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"startApiEndpoints.js","sourceRoot":"","sources":["../src/startApiEndpoints.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,oBAAoB,CAAC;AAI/C,MAAM,CAAC,OAAO,UAAU,iBAAiB,CACrC,MAAmB,EACnB,OAAsB;IAEtB,SAAS,OAAO;QACZ,OAAO,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC;IACnC,CAAC;IAED,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;IACzB,OAAO,CAAC,IAAI,CAAC,gBAAgB,aAAa,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;AAC3D,CAAC"}
|
|
@@ -1,102 +1,86 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const nock_1 = __importDefault(require("nock"));
|
|
16
|
-
const lodash_1 = __importDefault(require("lodash"));
|
|
17
|
-
const chai_1 = require("chai");
|
|
18
|
-
const query_string_1 = __importDefault(require("query-string"));
|
|
19
|
-
const AuthorizedRegistryClient_1 = __importDefault(require("magda-typescript-common/src/registry/AuthorizedRegistryClient"));
|
|
20
|
-
const arbitraries_1 = require("magda-typescript-common/src/test/arbitraries");
|
|
21
|
-
const jsverify_1 = __importDefault(require("magda-typescript-common/src/test/jsverify"));
|
|
22
|
-
const fakeArgv_1 = __importDefault(require("./fakeArgv"));
|
|
23
|
-
const baseSpec_1 = __importDefault(require("./baseSpec"));
|
|
24
|
-
const Crawler_1 = __importDefault(require("../Crawler"));
|
|
25
|
-
const TenantConsts_1 = require("magda-typescript-common/src/registry/TenantConsts");
|
|
1
|
+
import nock from "nock";
|
|
2
|
+
import _ from "lodash";
|
|
3
|
+
import { expect } from "chai";
|
|
4
|
+
import queryString from "query-string";
|
|
5
|
+
import Registry from "magda-typescript-common/src/registry/AuthorizedRegistryClient.js";
|
|
6
|
+
import { lcAlphaNumStringArbNe } from "magda-typescript-common/src/test/arbitraries.js";
|
|
7
|
+
import jsc from "jsverify";
|
|
8
|
+
import fakeArgv from "./fakeArgv.js";
|
|
9
|
+
import baseSpec from "./baseSpec.js";
|
|
10
|
+
import Crawler from "../Crawler.js";
|
|
11
|
+
import { MAGDA_ADMIN_PORTAL_ID } from "magda-typescript-common/src/registry/TenantConsts.js";
|
|
26
12
|
const DEFAULT_CRAWLER_RECORD_FETCH_NUMBER = 198;
|
|
27
|
-
|
|
13
|
+
baseSpec("Crawler", (expressApp, _expressServer, listenPort, beforeEachProperty) => {
|
|
28
14
|
//--- avoid different property test hit into the same registry domain
|
|
29
15
|
let registryDomainCounter = 0;
|
|
30
16
|
//--- function implements generic crawler testing logic
|
|
31
|
-
function basecrawlerTest(registryTotalRecordsNumber, domain, jwtSecret, concurrency, async, enableMultiTenant,
|
|
17
|
+
async function basecrawlerTest(registryTotalRecordsNumber, domain, jwtSecret, concurrency, async, enableMultiTenant,
|
|
32
18
|
// --- init func creates other context variables shared among callbacks
|
|
33
19
|
envInit, onRecordFound, registryReplyFunc, propertyCheckingFunc) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
20
|
+
beforeEachProperty();
|
|
21
|
+
const internalUrl = `http://${domain}.com`;
|
|
22
|
+
const registryDomain = "registry_" + registryDomainCounter;
|
|
23
|
+
const tenantDomain = "tenant_" + registryDomainCounter;
|
|
24
|
+
registryDomainCounter++;
|
|
25
|
+
const registryUrl = `http://${registryDomain}.com:80`;
|
|
26
|
+
const tenantUrl = `http://${tenantDomain}.com:80`;
|
|
27
|
+
const registryScope = nock(registryUrl);
|
|
28
|
+
const tenantId = MAGDA_ADMIN_PORTAL_ID;
|
|
29
|
+
const userId = "b1fddd6f-e230-4068-bd2c-1a21844f1598";
|
|
30
|
+
const registry = new Registry({
|
|
31
|
+
baseUrl: registryUrl,
|
|
32
|
+
jwtSecret: jwtSecret,
|
|
33
|
+
userId: userId,
|
|
34
|
+
tenantId: tenantId
|
|
35
|
+
});
|
|
36
|
+
let context = {
|
|
37
|
+
registryTotalRecordsNumber,
|
|
38
|
+
domain,
|
|
39
|
+
jwtSecret,
|
|
40
|
+
userId,
|
|
41
|
+
concurrency,
|
|
42
|
+
async,
|
|
43
|
+
registryScope,
|
|
44
|
+
registry
|
|
45
|
+
};
|
|
46
|
+
const env = envInit.bind(context)();
|
|
47
|
+
if (env && typeof env === "object")
|
|
48
|
+
context = { ...context, ...env };
|
|
49
|
+
const options = {
|
|
50
|
+
argv: fakeArgv({
|
|
51
|
+
internalUrl,
|
|
52
|
+
registryUrl,
|
|
53
|
+
enableMultiTenant,
|
|
54
|
+
tenantUrl,
|
|
54
55
|
jwtSecret,
|
|
55
56
|
userId,
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
writeAspectDefs: [],
|
|
79
|
-
async,
|
|
80
|
-
express: expressApp,
|
|
81
|
-
concurrency: concurrency,
|
|
82
|
-
onRecordFound: onRecordFound.bind(context)
|
|
83
|
-
};
|
|
84
|
-
registryScope
|
|
85
|
-
.persist()
|
|
86
|
-
.get("/records")
|
|
87
|
-
.query(true)
|
|
88
|
-
.reply(registryReplyFunc.bind(context));
|
|
89
|
-
const crawler = new Crawler_1.default(registry, options);
|
|
90
|
-
context.crawler = crawler;
|
|
91
|
-
yield crawler.start();
|
|
92
|
-
registryScope.done();
|
|
93
|
-
return propertyCheckingFunc.bind(context)();
|
|
94
|
-
});
|
|
57
|
+
listenPort: listenPort(),
|
|
58
|
+
crawlerRecordFetchNumber: DEFAULT_CRAWLER_RECORD_FETCH_NUMBER
|
|
59
|
+
}),
|
|
60
|
+
id: "id",
|
|
61
|
+
aspects: [],
|
|
62
|
+
optionalAspects: [],
|
|
63
|
+
writeAspectDefs: [],
|
|
64
|
+
async,
|
|
65
|
+
express: expressApp,
|
|
66
|
+
concurrency: concurrency,
|
|
67
|
+
onRecordFound: onRecordFound.bind(context)
|
|
68
|
+
};
|
|
69
|
+
registryScope
|
|
70
|
+
.persist()
|
|
71
|
+
.get("/records")
|
|
72
|
+
.query(true)
|
|
73
|
+
.reply(registryReplyFunc.bind(context));
|
|
74
|
+
const crawler = new Crawler(registry, options);
|
|
75
|
+
context.crawler = crawler;
|
|
76
|
+
await crawler.start();
|
|
77
|
+
registryScope.done();
|
|
78
|
+
return propertyCheckingFunc.bind(context)();
|
|
95
79
|
}
|
|
96
80
|
function basePropertyTest(
|
|
97
81
|
// --- init func creates other context variables shared among callbacks
|
|
98
82
|
envInit, onRecordFound, registryReplyFunc, propertyCheckingFunc) {
|
|
99
|
-
return
|
|
83
|
+
return jsc.assert(jsc.forall(jsc.nat(100), lcAlphaNumStringArbNe, lcAlphaNumStringArbNe, jsc.integer(1, 10), jsc.bool, jsc.bool, _.partialRight(basecrawlerTest, envInit, onRecordFound, registryReplyFunc, propertyCheckingFunc)));
|
|
100
84
|
}
|
|
101
85
|
it("should crawl all records in registry ONCE start() called ", () => {
|
|
102
86
|
return basePropertyTest(function () {
|
|
@@ -108,7 +92,7 @@ baseSpec_1.default("Crawler", (expressApp, _expressServer, listenPort, beforeEac
|
|
|
108
92
|
name: "",
|
|
109
93
|
aspects: {},
|
|
110
94
|
sourceTag: "",
|
|
111
|
-
tenantId:
|
|
95
|
+
tenantId: MAGDA_ADMIN_PORTAL_ID
|
|
112
96
|
}));
|
|
113
97
|
return { recordsTestTable, registryRecords };
|
|
114
98
|
}, function (foundRecord, registry) {
|
|
@@ -120,12 +104,12 @@ baseSpec_1.default("Crawler", (expressApp, _expressServer, listenPort, beforeEac
|
|
|
120
104
|
return Promise.resolve();
|
|
121
105
|
}, function (uri, requestBody) {
|
|
122
106
|
//---registryReplyFunc
|
|
123
|
-
const params =
|
|
107
|
+
const params = queryString.parseUrl(uri).query;
|
|
124
108
|
const pageIdx = params.pageToken
|
|
125
109
|
? parseInt(params.pageToken, 10)
|
|
126
110
|
: 0;
|
|
127
111
|
const limit = parseInt(params.limit, 10);
|
|
128
|
-
|
|
112
|
+
expect(limit).to.equal(DEFAULT_CRAWLER_RECORD_FETCH_NUMBER);
|
|
129
113
|
if (limit < 1) {
|
|
130
114
|
throw new Error("Invalid limit param received!");
|
|
131
115
|
}
|
|
@@ -168,7 +152,7 @@ baseSpec_1.default("Crawler", (expressApp, _expressServer, listenPort, beforeEac
|
|
|
168
152
|
name: "",
|
|
169
153
|
aspects: {},
|
|
170
154
|
sourceTag: "",
|
|
171
|
-
tenantId:
|
|
155
|
+
tenantId: MAGDA_ADMIN_PORTAL_ID
|
|
172
156
|
}));
|
|
173
157
|
return {
|
|
174
158
|
totalCrawledRecordsNumber,
|
|
@@ -178,7 +162,7 @@ baseSpec_1.default("Crawler", (expressApp, _expressServer, listenPort, beforeEac
|
|
|
178
162
|
return Promise.resolve();
|
|
179
163
|
}, function (uri, requestBody) {
|
|
180
164
|
//---registryReplyFunc
|
|
181
|
-
const params =
|
|
165
|
+
const params = queryString.parseUrl(uri).query;
|
|
182
166
|
const pageIdx = params.pageToken
|
|
183
167
|
? parseInt(params.pageToken, 10)
|
|
184
168
|
: 0;
|
|
@@ -200,7 +184,7 @@ baseSpec_1.default("Crawler", (expressApp, _expressServer, listenPort, beforeEac
|
|
|
200
184
|
const crawlingPageToken = String(crawlingPageTokenValue);
|
|
201
185
|
this.totalCrawledRecordsNumber += recordPage.length;
|
|
202
186
|
const progress = this.crawler.getProgress();
|
|
203
|
-
|
|
187
|
+
expect(progress).to.deep.equal({
|
|
204
188
|
isCrawling: true,
|
|
205
189
|
crawlingPageToken: String(pageIdx ? pageIdx : ""),
|
|
206
190
|
crawledRecordNumber: pageIdx
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Crawler.spec.js","sourceRoot":"","sources":["../../src/test/Crawler.spec.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Crawler.spec.js","sourceRoot":"","sources":["../../src/test/Crawler.spec.ts"],"names":[],"mappings":"AAEA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,CAAC,MAAM,QAAQ,CAAC;AACvB,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAC9B,OAAO,WAAW,MAAM,cAAc,CAAC;AACvC,OAAO,QAAQ,MAAM,kEAAkE,CAAC;AAGxF,OAAO,EAAE,qBAAqB,EAAE,MAAM,iDAAiD,CAAC;AACxF,OAAO,GAAG,MAAM,UAAU,CAAC;AAG3B,OAAO,QAAQ,MAAM,eAAe,CAAC;AACrC,OAAO,QAAQ,MAAM,eAAe,CAAC;AACrC,OAAO,OAAO,MAAM,eAAe,CAAC;AACpC,OAAO,EAAE,qBAAqB,EAAE,MAAM,sDAAsD,CAAC;AAE7F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AAM;wBACvC,OAAO,EAAE,KAAK;wBACd,OAAO,EAAE,EAAE;qBACd;iBACJ,CAAC;aACL;YACD,MAAM,UAAU,GAAG,IAAI,CAAC,eAAe,CAAC,KAAK,CACzC,OAAO,EACP,OAAO,GAAG,KAAK,GAAG,CAAC,CACtB,CAAC;YACF,MAAM,sBAAsB,GAAG,OAAO,GAAG,UAAU,CAAC,MAAM,CAAC;YAC3D,MAAM,iBAAiB,GAAG,MAAM,CAAC,sBAAsB,CAAC,CAAC;YACzD,IAAI,CAAC,yBAAyB,IAAI,UAAU,CAAC,MAAM,CAAC;YACpD,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC;YAC5C,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC;gBAC3B,UAAU,EAAE,IAAI;gBAChB,iBAAiB,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;gBACjD,mBAAmB,EAAE,OAAO;aAC/B,CAAC,CAAC;YACH,OAAO;gBACH,GAAG;gBACH;oBACI,UAAU,EAAE,IAAI,CAAC,eAAe,CAAC,MAAM;oBACvC,OAAO,EAAE,IAAI;oBACb,aAAa,EAAE,iBAAiB;oBAChC,OAAO,EAAE,UAAU;iBACtB;aACJ,CAAC;QACN,CAAC,EACD;YACI,yBAAyB;YACzB,OAAO,IAAI,CAAC;QAChB,CAAC,CACJ,CAAC;IACN,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;AACvB,CAAC,CACJ,CAAC"}
|
package/dist/test/baseSpec.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
2
|
import express from "express";
|
|
3
3
|
import { Server } from "http";
|
|
4
4
|
/**
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
5
|
+
* This performs functions common to all the minion framework tests, like muting error logging
|
|
6
|
+
* (because we'll be deliberately causing errors in tests), finding free ports to listen on for
|
|
7
|
+
* testing the API, and setting up an express app to test against.
|
|
8
|
+
*
|
|
9
|
+
* @param caption The caption to put in the "describe" block that goes around this test
|
|
10
|
+
* @param fn A function in which to execute tests - this passes a number of arguments as no-arg functions
|
|
11
|
+
* that will return the latest value - these values change during test setup so they can't be
|
|
12
|
+
* passed directly during the test setup.
|
|
13
|
+
*/
|
|
14
14
|
export default function baseSpec(caption: string, fn: (expressApp: () => express.Express, expressServer: () => Server, listenPort: () => number, beforeEachProperty: () => void) => void): void;
|