@odg/chemical-x 1.29.0 → 2.0.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/Container.d.ts +3 -47
- package/dist/Container.js +3 -23
- package/dist/Container.js.map +1 -1
- package/dist/Helpers/index.d.ts +1 -1
- package/dist/Helpers/index.js +1 -1
- package/dist/Helpers/index.js.map +1 -1
- package/dist/Helpers/retry.d.ts +1 -1
- package/dist/Helpers/retry.js +2 -2
- package/dist/Helpers/retry.js.map +1 -1
- package/dist/Helpers/sleep.d.ts +1 -1
- package/dist/Helpers/{throwIf.d.ts → throw-if.d.ts} +1 -1
- package/dist/Helpers/{throwIf.js → throw-if.js} +1 -1
- package/dist/Helpers/throw-if.js.map +1 -0
- package/dist/Helpers/timeout.d.ts +1 -1
- package/dist/Helpers/timeout.js +1 -1
- package/dist/Helpers/timeout.js.map +1 -1
- package/dist/Interfaces/AttemptableFlow.d.ts +5 -5
- package/dist/Interfaces/RetryInterface.d.ts +6 -6
- package/dist/Interfaces/TimeoutInterface.d.ts +1 -1
- package/dist/Interfaces/index.d.ts +1 -1
- package/dist/Interfaces/index.js +0 -15
- package/dist/Interfaces/index.js.map +1 -1
- package/dist/Support/Arr.d.ts +1 -7
- package/dist/Support/Arr.js +0 -6
- package/dist/Support/Arr.js.map +1 -1
- package/dist/Support/Decorators/OdgDecorators.d.ts +16 -0
- package/dist/Support/Decorators/{ODGDecorators.js → OdgDecorators.js} +44 -25
- package/dist/Support/Decorators/OdgDecorators.js.map +1 -0
- package/dist/Support/Decorators/index.d.ts +1 -2
- package/dist/Support/Decorators/index.js +1 -2
- package/dist/Support/Decorators/index.js.map +1 -1
- package/dist/Support/Num.d.ts +1 -1
- package/dist/Support/Num.js.map +1 -1
- package/dist/Support/Str.d.ts +2 -2
- package/dist/Support/Str.js +6 -6
- package/dist/Support/Str.js.map +1 -1
- package/dist/crawler/@types/Browser.d.ts +1 -1
- package/dist/crawler/@types/Context.d.ts +1 -2
- package/dist/crawler/@types/ManagerBrowserType.d.ts +4 -4
- package/dist/crawler/@types/Page.d.ts +3 -4
- package/dist/crawler/Browser.d.ts +7 -7
- package/dist/crawler/Browser.js +1 -1
- package/dist/crawler/Browser.js.map +1 -1
- package/dist/crawler/BrowserManager.d.ts +5 -5
- package/dist/crawler/BrowserManager.js.map +1 -1
- package/dist/crawler/Context.d.ts +7 -7
- package/dist/crawler/Context.js +2 -2
- package/dist/crawler/Context.js.map +1 -1
- package/dist/crawler/Handlers/BaseHandler.d.ts +8 -7
- package/dist/crawler/Handlers/BaseHandler.js +3 -4
- package/dist/crawler/Handlers/BaseHandler.js.map +1 -1
- package/dist/crawler/Interfaces/HandlerInterface.d.ts +34 -15
- package/dist/crawler/Interfaces/PageInterface.d.ts +1 -1
- package/dist/crawler/Interfaces/index.d.ts +1 -1
- package/dist/crawler/Interfaces/index.js +0 -15
- package/dist/crawler/Interfaces/index.js.map +1 -1
- package/dist/crawler/Page.d.ts +5 -5
- package/dist/crawler/Page.js +1 -1
- package/dist/crawler/Page.js.map +1 -1
- package/dist/crawler/Pages/BasePage.d.ts +12 -19
- package/dist/crawler/Pages/BasePage.js +3 -13
- package/dist/crawler/Pages/BasePage.js.map +1 -1
- package/dist/crawler/Pages/Components/BaseComponentPage.d.ts +2 -2
- package/dist/crawler/Pages/Components/BaseComponentPage.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +37 -19
- package/dist/Helpers/throwIf.js.map +0 -1
- package/dist/Support/Decorators/GetterDecorator.d.ts +0 -1
- package/dist/Support/Decorators/GetterDecorator.js +0 -18
- package/dist/Support/Decorators/GetterDecorator.js.map +0 -1
- package/dist/Support/Decorators/ODGDecorators.d.ts +0 -15
- package/dist/Support/Decorators/ODGDecorators.js.map +0 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
export declare class Browser<
|
|
4
|
-
readonly $browserInstance:
|
|
1
|
+
import type { GetterAccessInterface } from "../Interfaces";
|
|
2
|
+
import { CreateContextFactoryType, CreatePageFactoryType, type BrowserChemicalXInterface, type BrowserEngineInterface, type ContextChemicalXInterface, type ContextEngineInterface, type ContextOptionsLibraryInterface, type PageEngineInterface } from ".";
|
|
3
|
+
export declare class Browser<BrowserClassEngine extends BrowserEngineInterface, ContextClassEngine extends ContextEngineInterface, PageClassEngine extends PageEngineInterface> implements GetterAccessInterface, BrowserChemicalXInterface<BrowserClassEngine, ContextClassEngine> {
|
|
4
|
+
readonly $browserInstance: BrowserClassEngine;
|
|
5
5
|
private readonly $newContext;
|
|
6
6
|
private readonly $newPage;
|
|
7
|
-
constructor($browserInstance:
|
|
7
|
+
constructor($browserInstance: BrowserClassEngine, $newContext: CreateContextFactoryType<ContextClassEngine, PageClassEngine>, $newPage: CreatePageFactoryType<ContextChemicalXInterface<ContextClassEngine>, PageClassEngine>);
|
|
8
8
|
defaultContextOptions(): Promise<ContextOptionsLibraryInterface>;
|
|
9
|
-
newContext(options?: ContextOptionsLibraryInterface): Promise<ContextChemicalXInterface<
|
|
10
|
-
contexts(): Array<ContextChemicalXInterface<
|
|
9
|
+
newContext(options?: ContextOptionsLibraryInterface): Promise<ContextChemicalXInterface<ContextClassEngine> & ContextClassEngine>;
|
|
10
|
+
contexts(): Array<ContextChemicalXInterface<ContextClassEngine> & ContextClassEngine>;
|
|
11
11
|
__get(key: PropertyKey): unknown;
|
|
12
12
|
}
|
package/dist/crawler/Browser.js
CHANGED
|
@@ -51,7 +51,7 @@ let Browser = class Browser {
|
|
|
51
51
|
};
|
|
52
52
|
exports.Browser = Browser;
|
|
53
53
|
exports.Browser = Browser = __decorate([
|
|
54
|
-
|
|
54
|
+
Decorators_1.ODGDecorators.getterAccess(),
|
|
55
55
|
__metadata("design:paramtypes", [Object, Function, Function])
|
|
56
56
|
], Browser);
|
|
57
57
|
//# sourceMappingURL=Browser.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Browser.js","sourceRoot":"","sources":["../../src/crawler/Browser.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,
|
|
1
|
+
{"version":3,"file":"Browser.js","sourceRoot":"","sources":["../../src/crawler/Browser.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,oDAAoD;AAc7C,IAAM,OAAO,GAAb,MAAM,OAAO;IAOI;IACC;IACA;IAHrB,YACoB,gBAAoC,EACnC,WAA0E,EAC1E,QAGhB;QALe,qBAAgB,GAAhB,gBAAgB,CAAoB;QACnC,gBAAW,GAAX,WAAW,CAA+D;QAC1E,aAAQ,GAAR,QAAQ,CAGxB;IAGL,CAAC;IAEM,KAAK,CAAC,qBAAqB;QAC9B,OAAO,EACN,CAAC;IACN,CAAC;IAEM,KAAK,CAAC,UAAU,CACnB,OAAwC;QAExC,MAAM,WAAW,GAAG,CAChB,IAAI,CAAC,gBAAgB,CAAC,UAAU;eAC7B,IAAI,CAAC,gBAAgB,CAAC,6BAA6B;eACnD,IAAI,CAAC,gBAAgB,CAAC,oBAAoB,CACa,CAAC;QAE/D,OAAO,IAAI,CAAC,WAAW,CACnB,MAAM,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE;YAC1C,GAAG,MAAM,IAAI,CAAC,qBAAqB,EAAE;YACrC,GAAG,OAAO;SACb,CAAC,EACF,IAAI,CAAC,QAAQ,CACsD,CAAC;IAC5E,CAAC;IAEM,QAAQ;QACX,MAAM,cAAc,GAAG,UAAU,IAAI,IAAI,CAAC,gBAAgB;eACnD,OAAO,IAAI,CAAC,gBAAgB,CAAC,QAAQ,KAAK,UAAU;eACnD,IAAI,CAAC,gBAAgB,CAAC,QAAuC,EAAE,CAAC;QACxE,MAAM,QAAQ,GAAG,cAAc,IAAI,EAAE,CAAC;QAEtC,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,CAC7C,OAAO,EACP,IAAI,CAAC,QAAQ,CACsD,CAAC,CAAC;IAC7E,CAAC;IAEM,KAAK,CAAC,GAAgB;QACzB,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;YACd,OAAO,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;QAClC,CAAC;QAED,MAAM,aAAa,GAAI,IAAI,CAAC,gBAAiD,CAAC,GAAG,CAAC,CAAC;QAEnF,OAAO,OAAO,aAAa,KAAK,UAAU;YACtC,CAAC,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC;YAC3C,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,gBAAgB,EAAE,GAAG,CAAC,CAAC;IAClD,CAAC;CAEJ,CAAA;AAhEY,0BAAO;kBAAP,OAAO;IADnB,0BAAa,CAAC,YAAY,EAAE;;GAChB,OAAO,CAgEnB"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare class BrowserManager<
|
|
1
|
+
import type { BrowserChemicalXInterface, BrowserEngineInterface, ContextChemicalXInterface, ContextEngineInterface, CreateBrowserFactoryType, CreateContextFactoryType, CreatePageFactoryType, PageEngineInterface } from "..";
|
|
2
|
+
export declare class BrowserManager<BrowserClassEngine extends BrowserEngineInterface, ContextClassEngine extends ContextEngineInterface, PageClassEngine extends PageEngineInterface> {
|
|
3
3
|
private readonly $newBrowser;
|
|
4
4
|
private readonly $newContext;
|
|
5
5
|
private readonly $newPage;
|
|
6
|
-
constructor($newBrowser: CreateBrowserFactoryType<
|
|
7
|
-
newBrowser(browser: () => Promise<
|
|
8
|
-
newPersistentContext(context: () => Promise<
|
|
6
|
+
constructor($newBrowser: CreateBrowserFactoryType<BrowserClassEngine, ContextClassEngine, PageClassEngine>, $newContext: CreateContextFactoryType<ContextClassEngine, PageClassEngine>, $newPage: CreatePageFactoryType<ContextChemicalXInterface<ContextClassEngine>, PageClassEngine>);
|
|
7
|
+
newBrowser(browser: () => Promise<BrowserClassEngine>): Promise<BrowserChemicalXInterface<BrowserClassEngine, ContextClassEngine> & BrowserClassEngine>;
|
|
8
|
+
newPersistentContext(context: () => Promise<ContextClassEngine>): Promise<ContextChemicalXInterface<ContextClassEngine> & ContextClassEngine>;
|
|
9
9
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BrowserManager.js","sourceRoot":"","sources":["../../src/crawler/BrowserManager.ts"],"names":[],"mappings":";;;AAWA,MAAa,cAAc;IAOF;IACA;IACA;IAHrB,YACqB,
|
|
1
|
+
{"version":3,"file":"BrowserManager.js","sourceRoot":"","sources":["../../src/crawler/BrowserManager.ts"],"names":[],"mappings":";;;AAWA,MAAa,cAAc;IAOF;IACA;IACA;IAHrB,YACqB,WAA8F,EAC9F,WAA0E,EAC1E,QAGhB;QALgB,gBAAW,GAAX,WAAW,CAAmF;QAC9F,gBAAW,GAAX,WAAW,CAA+D;QAC1E,aAAQ,GAAR,QAAQ,CAGxB;IAEL,CAAC;IAEM,KAAK,CAAC,UAAU,CACnB,OAA0C;QAE1C,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,OAAO,EAAE,EAAE,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,QAAQ,CAGlD,CAAC;IAC3B,CAAC;IAEM,KAAK,CAAC,oBAAoB,CAC7B,OAA0C;QAE1C,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,OAAO,EAAE,EAAE,IAAI,CAAC,QAAQ,CAEhC,CAAC;IAC3B,CAAC;CAEJ;AAjCD,wCAiCC"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
export declare class Context<
|
|
3
|
-
readonly $contextInstance:
|
|
4
|
-
readonly $newPage: CreatePageFactoryType<ContextChemicalXInterface<
|
|
5
|
-
constructor($contextInstance:
|
|
1
|
+
import { type ContextChemicalXInterface, type ContextEngineInterface, type CreatePageFactoryType, type GetterAccessInterface, type PageChemicalXInterface, type PageEngineInterface, type PageOptionsLibraryInterface } from "..";
|
|
2
|
+
export declare class Context<ContextClassEngine extends ContextEngineInterface, PageClassEngine extends PageEngineInterface> implements GetterAccessInterface, ContextChemicalXInterface<ContextClassEngine> {
|
|
3
|
+
readonly $contextInstance: ContextClassEngine;
|
|
4
|
+
readonly $newPage: CreatePageFactoryType<ContextChemicalXInterface<ContextClassEngine>, PageClassEngine>;
|
|
5
|
+
constructor($contextInstance: ContextClassEngine, $newPage: CreatePageFactoryType<ContextChemicalXInterface<ContextClassEngine>, PageClassEngine>);
|
|
6
6
|
defaultPageOptions(): Promise<PageOptionsLibraryInterface>;
|
|
7
|
-
newPage(options?: Record<string, unknown>): Promise<PageChemicalXInterface<
|
|
8
|
-
pages(): Array<PageChemicalXInterface<
|
|
7
|
+
newPage(options?: Record<string, unknown>): Promise<PageChemicalXInterface<PageClassEngine> & PageClassEngine>;
|
|
8
|
+
pages(): Array<PageChemicalXInterface<PageClassEngine> & PageClassEngine>;
|
|
9
9
|
__get(key: PropertyKey): unknown;
|
|
10
10
|
}
|
package/dist/crawler/Context.js
CHANGED
|
@@ -10,7 +10,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.Context = void 0;
|
|
13
|
-
const
|
|
13
|
+
const __1 = require("..");
|
|
14
14
|
let Context = class Context {
|
|
15
15
|
$contextInstance;
|
|
16
16
|
$newPage;
|
|
@@ -43,7 +43,7 @@ let Context = class Context {
|
|
|
43
43
|
};
|
|
44
44
|
exports.Context = Context;
|
|
45
45
|
exports.Context = Context = __decorate([
|
|
46
|
-
|
|
46
|
+
__1.ODGDecorators.getterAccess(),
|
|
47
47
|
__metadata("design:paramtypes", [Object, Function])
|
|
48
48
|
], Context);
|
|
49
49
|
//# sourceMappingURL=Context.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Context.js","sourceRoot":"","sources":["../../src/crawler/Context.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"Context.js","sourceRoot":"","sources":["../../src/crawler/Context.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,0BASY;AAGL,IAAM,OAAO,GAAb,MAAM,OAAO;IAMI;IACA;IAFpB,YACoB,gBAAoC,EACpC,QAA+F;QAD/F,qBAAgB,GAAhB,gBAAgB,CAAoB;QACpC,aAAQ,GAAR,QAAQ,CAAuF;IAGnH,CAAC;IAEM,KAAK,CAAC,kBAAkB;QAC3B,OAAO,EACN,CAAC;IACN,CAAC;IAEM,KAAK,CAAC,OAAO,CAChB,OAAiC;QAEjC,OAAO,IAAI,CAAC,QAAQ,CAChB,IAAI,EACJ,MAAO,IAAI,CAAC,gBAAgB,CAAC,OAA6D,CACtF,IAAI,CAAC,gBAAgB,EACrB;YACI,GAAG,MAAM,IAAI,CAAC,kBAAkB,EAAE;YAClC,GAAG,OAAO;SACb,CACJ,CACyD,CAAC;IACnE,CAAC;IAEM,KAAK;QACR,MAAM,KAAK,GAAI,IAAI,CAAC,gBAAgB,CAAC,KAAiC,EAAE,CAAC;QAEzE,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CACpC,IAAI,EACJ,IAAI,CACsD,CAAC,CAAC;IACpE,CAAC;IAEM,KAAK,CAAC,GAAgB;QACzB,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;YACd,OAAO,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;QAClC,CAAC;QAED,MAAM,aAAa,GAAI,IAAI,CAAC,gBAAiD,CAAC,GAAG,CAAC,CAAC;QAEnF,OAAO,OAAO,aAAa,KAAK,UAAU;YACtC,CAAC,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC;YAC3C,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,gBAAgB,EAAE,GAAG,CAAC,CAAC;IAClD,CAAC;CAEJ,CAAA;AArDY,0BAAO;kBAAP,OAAO;IADnB,iBAAa,CAAC,YAAY,EAAE;;GAChB,OAAO,CAqDnB"}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { Exception } from "@odg/exception";
|
|
2
2
|
import { RetryAction } from "../../Enums";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
readonly $$s: SelectorBaseType;
|
|
3
|
+
import type { HandlerFunction, HandlerInterface, HandlerSolutionType } from "../../Interfaces";
|
|
4
|
+
import type { PageEngineInterface } from "../@types";
|
|
5
|
+
import type { SelectorType } from "../Selectors/SelectorsType";
|
|
6
|
+
export declare abstract class BaseHandler<PageClassEngine extends PageEngineInterface> implements HandlerInterface {
|
|
8
7
|
currentAttempt: number;
|
|
9
|
-
|
|
8
|
+
page?: PageClassEngine;
|
|
9
|
+
abstract readonly $$s: Record<number | string | symbol, SelectorType>;
|
|
10
|
+
setPage(page: PageClassEngine): this;
|
|
10
11
|
/**
|
|
11
12
|
* Called if the handler completes successfully.
|
|
12
13
|
*
|
|
@@ -27,7 +28,7 @@ export declare abstract class BaseHandler<SelectorBaseType, PageEngineType exten
|
|
|
27
28
|
*
|
|
28
29
|
* Return a `RetryAction` to control the retry behavior.
|
|
29
30
|
*
|
|
30
|
-
* @param {Exception} exception Exception
|
|
31
|
+
* @param {Exception} exception Exception that caused the retry.
|
|
31
32
|
* @param {number} attempt The current attempt number.
|
|
32
33
|
* @returns {Promise<RetryAction>} The action to take before the next retry.
|
|
33
34
|
*/
|
|
@@ -5,12 +5,11 @@ const exception_1 = require("@odg/exception");
|
|
|
5
5
|
const _enums_1 = require("../../Enums");
|
|
6
6
|
const _helpers_1 = require("../../Helpers");
|
|
7
7
|
class BaseHandler {
|
|
8
|
-
page;
|
|
9
|
-
$$s;
|
|
10
8
|
currentAttempt = 0;
|
|
11
|
-
|
|
9
|
+
page;
|
|
10
|
+
setPage(page) {
|
|
12
11
|
this.page = page;
|
|
13
|
-
this
|
|
12
|
+
return this;
|
|
14
13
|
}
|
|
15
14
|
/**
|
|
16
15
|
* Executes the handler with retry, failure, and finish logic.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseHandler.js","sourceRoot":"","sources":["../../../src/crawler/Handlers/BaseHandler.ts"],"names":[],"mappings":";;;AAAA,8CAA6D;AAE7D,mCAAqC;AACrC,uCAAiC;
|
|
1
|
+
{"version":3,"file":"BaseHandler.js","sourceRoot":"","sources":["../../../src/crawler/Handlers/BaseHandler.ts"],"names":[],"mappings":";;;AAAA,8CAA6D;AAE7D,mCAAqC;AACrC,uCAAiC;AAUjC,MAAsB,WAAW;IAItB,cAAc,GAAW,CAAC,CAAC;IAE3B,IAAI,CAAmB;IAIvB,OAAO,CAAC,IAAqB;QAChC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QAEjB,OAAO,IAAI,CAAC;IAChB,CAAC;IAkDD;;;;OAIG;IACI,KAAK,CAAC,OAAO;QAChB,IAAI,CAAC;YACD,MAAM,eAAe,GAAG,MAAM,IAAI,CAAC,sBAAsB,EAAE,CAAC;YAE5D,IAAI,eAAe,YAAY,qBAAS,EAAE,CAAC;gBACvC,MAAM,eAAe,CAAC;YAC1B,CAAC;YAED,MAAM,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC;YACtB,MAAM,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC;QAC3B,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACtB,MAAM,SAAS,GAAG,4BAAgB,CAAC,cAAc,CAAC,KAAK,EAAE,0BAA0B,CAAC,CAAC;YAErF,MAAM,IAAI,CAAC,MAAM,EAAE,CAAC,SAAS,CAAC,CAAC;YAE/B,IAAI,IAAI,CAAC,OAAO;gBAAE,MAAM,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;;gBAC3C,MAAM,SAAS,CAAC;QACzB,CAAC;IACL,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,eAAe;QACxB,OAAO,oBAAW,CAAC,OAAO,CAAC;IAC/B,CAAC;IAEO,KAAK,CAAC,sBAAsB;QAChC,MAAM,eAAe,GAAG,MAAM,IAAA,gBAAK,EAAC;YAChC,QAAQ,EAAE,KAAK,IAAI,EAAE;gBACjB,EAAE,IAAI,CAAC,cAAc,CAAC;gBACtB,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;gBAEhD,IAAI,WAAW,YAAY,qBAAS,EAAE,CAAC;oBACnC,OAAO,WAAW,CAAC;gBACvB,CAAC;gBAED,OAAO,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAClC,CAAC;YACD,KAAK,EAAE,MAAM,IAAI,CAAC,OAAO,EAAE;YAC3B,KAAK,EAAE,MAAM,IAAI,CAAC,KAAK,EAAE,EAAE;YAC3B,IAAI,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC;SAClC,CAAC,CAAC;QAEH,IAAI,eAAe,KAAK,oBAAW,CAAC,KAAK,EAAE,CAAC;YACxC,OAAO,IAAI,CAAC,sBAAsB,EAAE,CAAC;QACzC,CAAC;QAED,OAAO,eAAe,CAAC;IAC3B,CAAC;CAoBJ;AA5ID,kCA4IC"}
|
|
@@ -1,22 +1,41 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import type { Exception } from "@odg/exception";
|
|
2
|
+
import type { RetryAction } from "../../Enums";
|
|
3
|
+
import type { AttemptableInterface } from "../../Interfaces/AttemptableFlow";
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Represents the possible return types from a handler function's execution.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* handler execution from the beginning. This action *does not* trigger the handler's `retrying`
|
|
10
|
-
* method. resetting the attempt count and starting all over again
|
|
7
|
+
* This type union defines the allowed outcomes that can be returned by a handler,
|
|
8
|
+
* which guide the retry mechanism and control flow of the handler execution cycle.
|
|
11
9
|
*
|
|
12
|
-
*
|
|
13
|
-
* successfully completed its task, and no further retries or error handling are needed for this
|
|
14
|
-
* specific execution.
|
|
10
|
+
* Handler functions can return the following values:
|
|
15
11
|
*
|
|
16
|
-
* - `Exception
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
12
|
+
* - **`Exception`**: When an `Exception` instance is returned (not thrown), it indicates
|
|
13
|
+
* that an error occurred and the process must be interrupted. No further retries will be
|
|
14
|
+
* performed, and the handler will terminate with the returned error. This has the same
|
|
15
|
+
* utility as `RetryAction.Throw`, but `RetryAction.Throw` cannot be used in this context
|
|
16
|
+
* because no error has occurred yet - the return itself indicates the error condition.
|
|
17
|
+
*
|
|
18
|
+
* - **`RetryAction.Retry`**: Forces a retry by restarting the entire handler execution from
|
|
19
|
+
* the beginning. When this action is returned, the attempt counter is reset, so if you
|
|
20
|
+
* configured 3 attempts and return `RetryAction.Retry`, it will start counting the 3 attempts
|
|
21
|
+
* from zero again. Additionally, this action does *not* call the `retrying` method, which is
|
|
22
|
+
* normally called on all retry attempts. **Warning**: This is discouraged as improper use can
|
|
23
|
+
* lead to infinite loops.
|
|
24
|
+
*
|
|
25
|
+
* - **`RetryAction.Resolve`**: Indicates that the handler completed successfully. The expected
|
|
26
|
+
* condition was met, and the code can proceed to the next step of the robot workflow.
|
|
27
|
+
*
|
|
28
|
+
* The following `RetryAction` values are explicitly **not supported** and are excluded
|
|
29
|
+
* from this type:
|
|
30
|
+
*
|
|
31
|
+
* - **`RetryAction.Throw`**: Not supported in Handler Solutions. Use returning an `Exception`
|
|
32
|
+
* instance instead when you need to signal an error condition.
|
|
33
|
+
*
|
|
34
|
+
* - **`RetryAction.Default`**: Not supported in Handler Solutions. To simulate retry behavior
|
|
35
|
+
* when an error condition is detected, throw an exception instead (e.g., `throw new Exception("Page did not load")`).
|
|
36
|
+
* This will attempt the number of times configured in the `attempt` method. If all attempts
|
|
37
|
+
* fail and the same condition occurs again, it will terminate with that error or any other
|
|
38
|
+
* error that may have occurred.
|
|
20
39
|
*/
|
|
21
40
|
export type HandlerSolutionType = Exception | Exclude<RetryAction, RetryAction.Default | RetryAction.Throw>;
|
|
22
41
|
/**
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export type * from "./PageInterface";
|
|
2
|
-
export * from "./HandlerInterface";
|
|
2
|
+
export type * from "./HandlerInterface";
|
|
@@ -1,18 +1,3 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./HandlerInterface"), exports);
|
|
18
3
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/crawler/Interfaces/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/crawler/Interfaces/index.ts"],"names":[],"mappings":""}
|
package/dist/crawler/Page.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ContextChemicalXInterface, ContextEngineInterface, type GetterAccessInterface, type PageChemicalXInterface, type PageEngineInterface } from "..";
|
|
2
|
-
export declare class Page<
|
|
3
|
-
readonly $context: ContextChemicalXInterface<
|
|
4
|
-
readonly $pageInstance:
|
|
5
|
-
constructor($context: ContextChemicalXInterface<
|
|
6
|
-
context(): ContextChemicalXInterface<
|
|
2
|
+
export declare class Page<ContextClassEngine extends ContextEngineInterface, PageClassEngine extends PageEngineInterface> implements GetterAccessInterface, PageChemicalXInterface<PageClassEngine> {
|
|
3
|
+
readonly $context: ContextChemicalXInterface<ContextClassEngine>;
|
|
4
|
+
readonly $pageInstance: PageClassEngine;
|
|
5
|
+
constructor($context: ContextChemicalXInterface<ContextClassEngine>, $pageInstance: PageClassEngine);
|
|
6
|
+
context(): ContextChemicalXInterface<ContextClassEngine> & ContextClassEngine;
|
|
7
7
|
__get(key: PropertyKey): unknown;
|
|
8
8
|
}
|
package/dist/crawler/Page.js
CHANGED
|
@@ -33,7 +33,7 @@ let Page = class Page {
|
|
|
33
33
|
};
|
|
34
34
|
exports.Page = Page;
|
|
35
35
|
exports.Page = Page = __decorate([
|
|
36
|
-
|
|
36
|
+
__1.ODGDecorators.getterAccess(),
|
|
37
37
|
__metadata("design:paramtypes", [Object, Object])
|
|
38
38
|
], Page);
|
|
39
39
|
//# sourceMappingURL=Page.js.map
|
package/dist/crawler/Page.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Page.js","sourceRoot":"","sources":["../../src/crawler/Page.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"Page.js","sourceRoot":"","sources":["../../src/crawler/Page.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,0BAOY;AAGL,IAAM,IAAI,GAAV,MAAM,IAAI;IAMO;IACA;IAFpB,YACoB,QAAuD,EACvD,aAA8B;QAD9B,aAAQ,GAAR,QAAQ,CAA+C;QACvD,kBAAa,GAAb,aAAa,CAAiB;IAGlD,CAAC;IAEM,OAAO;QACV,OAAO,IAAI,CAAC,QAA8E,CAAC;IAC/F,CAAC;IAEM,KAAK,CAAC,GAAgB;QACzB,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;YACd,OAAO,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;QAClC,CAAC;QAED,MAAM,aAAa,GAAI,IAAI,CAAC,aAA8C,CAAC,GAAG,CAAC,CAAC;QAEhF,OAAO,OAAO,aAAa,KAAK,UAAU;YACtC,CAAC,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC;YACxC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,aAAa,EAAE,GAAG,CAAC,CAAC;IAC/C,CAAC;CAEJ,CAAA;AA5BY,oBAAI;eAAJ,IAAI;IADhB,iBAAa,CAAC,YAAY,EAAE;;GAChB,IAAI,CA4BhB"}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
export declare abstract class BasePage<
|
|
6
|
-
readonly page: PageClassEngine;
|
|
7
|
-
readonly $$s: SelectorBaseType;
|
|
1
|
+
import type { Exception } from "@odg/exception";
|
|
2
|
+
import type { PageInterface, RetryAction } from "../..";
|
|
3
|
+
import type { PageEngineInterface } from "../index";
|
|
4
|
+
import type { SelectorType } from "../Selectors/SelectorsType";
|
|
5
|
+
export declare abstract class BasePage<PageClassEngine extends PageEngineInterface> implements PageInterface {
|
|
8
6
|
/**
|
|
9
7
|
* Current attempt number
|
|
10
8
|
*
|
|
@@ -12,26 +10,21 @@ export declare abstract class BasePage<SelectorBaseType, PageClassEngine extends
|
|
|
12
10
|
* @memberof BasePage
|
|
13
11
|
*/
|
|
14
12
|
currentAttempt: number;
|
|
15
|
-
|
|
13
|
+
page?: PageClassEngine;
|
|
16
14
|
/**
|
|
17
|
-
*
|
|
15
|
+
* Selector of this page
|
|
18
16
|
*
|
|
19
|
-
* @
|
|
17
|
+
* @type {SelectorType}
|
|
20
18
|
* @memberof BasePage
|
|
21
19
|
*/
|
|
22
|
-
|
|
20
|
+
abstract readonly $s?: SelectorType;
|
|
21
|
+
abstract readonly $$s?: Record<number | string | symbol, SelectorType>;
|
|
22
|
+
setPage(page: PageClassEngine): this;
|
|
23
23
|
success?(): Promise<void>;
|
|
24
|
-
finish?(exception?: Exception
|
|
24
|
+
finish?(exception?: Exception): Promise<void>;
|
|
25
25
|
failure?(exception: Exception): Promise<void>;
|
|
26
26
|
retrying?(exception: Exception, attempt: number): Promise<RetryAction>;
|
|
27
27
|
sleep?(): Promise<number>;
|
|
28
|
-
/**
|
|
29
|
-
* Selector of this page
|
|
30
|
-
*
|
|
31
|
-
* @type {SelectorType}
|
|
32
|
-
* @memberof BasePage
|
|
33
|
-
*/
|
|
34
|
-
abstract readonly $s: SelectorType;
|
|
35
28
|
abstract execute(): Promise<void>;
|
|
36
29
|
abstract attempt(): Promise<number>;
|
|
37
30
|
}
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BasePage = void 0;
|
|
4
4
|
class BasePage {
|
|
5
|
-
page;
|
|
6
|
-
$$s;
|
|
7
5
|
/**
|
|
8
6
|
* Current attempt number
|
|
9
7
|
*
|
|
@@ -11,18 +9,10 @@ class BasePage {
|
|
|
11
9
|
* @memberof BasePage
|
|
12
10
|
*/
|
|
13
11
|
currentAttempt = 0;
|
|
14
|
-
|
|
12
|
+
page;
|
|
13
|
+
setPage(page) {
|
|
15
14
|
this.page = page;
|
|
16
|
-
this
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Pre Start Page
|
|
20
|
-
*
|
|
21
|
-
* @deprecated removed (Empty function)
|
|
22
|
-
* @memberof BasePage
|
|
23
|
-
*/
|
|
24
|
-
async preStart() {
|
|
25
|
-
// Deprecated AttemptableFlow implement currentAttempt Count
|
|
15
|
+
return this;
|
|
26
16
|
}
|
|
27
17
|
}
|
|
28
18
|
exports.BasePage = BasePage;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BasePage.js","sourceRoot":"","sources":["../../../src/crawler/Pages/BasePage.ts"],"names":[],"mappings":";;;AAMA,MAAsB,QAAQ;
|
|
1
|
+
{"version":3,"file":"BasePage.js","sourceRoot":"","sources":["../../../src/crawler/Pages/BasePage.ts"],"names":[],"mappings":";;;AAMA,MAAsB,QAAQ;IAI1B;;;;;OAKG;IACI,cAAc,GAAW,CAAC,CAAC;IAE3B,IAAI,CAAmB;IAYvB,OAAO,CAAC,IAAqB;QAChC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QAEjB,OAAO,IAAI,CAAC;IAChB,CAAC;CAgBJ;AA5CD,4BA4CC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { PageEngineInterface } from "../../index";
|
|
2
2
|
import { BasePage } from "../BasePage";
|
|
3
|
-
export declare abstract class BaseComponentPage<
|
|
3
|
+
export declare abstract class BaseComponentPage<PageClassEngine extends PageEngineInterface> extends BasePage<PageClassEngine> {
|
|
4
4
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseComponentPage.js","sourceRoot":"","sources":["../../../../src/crawler/Pages/Components/BaseComponentPage.ts"],"names":[],"mappings":";;;AACA,0CAAuC;AAEvC,MAAsB,
|
|
1
|
+
{"version":3,"file":"BaseComponentPage.js","sourceRoot":"","sources":["../../../../src/crawler/Pages/Components/BaseComponentPage.ts"],"names":[],"mappings":";;;AACA,0CAAuC;AAEvC,MAAsB,iBAEpB,SAAQ,mBAAyB;CAElC;AAJD,8CAIC"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -17,7 +17,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./Support"), exports);
|
|
18
18
|
__exportStar(require("./Helpers/index"), exports);
|
|
19
19
|
__exportStar(require("./crawler/index"), exports);
|
|
20
|
-
__exportStar(require("./Interfaces"), exports);
|
|
21
20
|
__exportStar(require("./Exceptions"), exports);
|
|
22
21
|
__exportStar(require("./Enums"), exports);
|
|
23
22
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAA0B;AAE1B,kDAAgC;AAEhC,kDAAgC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAA0B;AAE1B,kDAAgC;AAEhC,kDAAgC;AAIhC,+CAA6B;AAE7B,0CAAwB"}
|