cogniscrape 1.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/LICENSE +21 -0
- package/README.md +308 -0
- package/dist/graphs/AbstractGraph.d.ts +27 -0
- package/dist/graphs/AbstractGraph.d.ts.map +1 -0
- package/dist/graphs/AbstractGraph.js +44 -0
- package/dist/graphs/AbstractGraph.js.map +1 -0
- package/dist/graphs/BaseGraph.d.ts +30 -0
- package/dist/graphs/BaseGraph.d.ts.map +1 -0
- package/dist/graphs/BaseGraph.js +62 -0
- package/dist/graphs/BaseGraph.js.map +1 -0
- package/dist/graphs/CSVScraperGraph.d.ts +16 -0
- package/dist/graphs/CSVScraperGraph.d.ts.map +1 -0
- package/dist/graphs/CSVScraperGraph.js +84 -0
- package/dist/graphs/CSVScraperGraph.js.map +1 -0
- package/dist/graphs/DepthSearchGraph.d.ts +14 -0
- package/dist/graphs/DepthSearchGraph.d.ts.map +1 -0
- package/dist/graphs/DepthSearchGraph.js +45 -0
- package/dist/graphs/DepthSearchGraph.js.map +1 -0
- package/dist/graphs/JSONScraperGraph.d.ts +18 -0
- package/dist/graphs/JSONScraperGraph.d.ts.map +1 -0
- package/dist/graphs/JSONScraperGraph.js +100 -0
- package/dist/graphs/JSONScraperGraph.js.map +1 -0
- package/dist/graphs/SearchGraph.d.ts +14 -0
- package/dist/graphs/SearchGraph.d.ts.map +1 -0
- package/dist/graphs/SearchGraph.js +42 -0
- package/dist/graphs/SearchGraph.js.map +1 -0
- package/dist/graphs/SmartScraperGraph.d.ts +16 -0
- package/dist/graphs/SmartScraperGraph.d.ts.map +1 -0
- package/dist/graphs/SmartScraperGraph.js +57 -0
- package/dist/graphs/SmartScraperGraph.js.map +1 -0
- package/dist/graphs/SmartScraperMultiGraph.d.ts +17 -0
- package/dist/graphs/SmartScraperMultiGraph.d.ts.map +1 -0
- package/dist/graphs/SmartScraperMultiGraph.js +71 -0
- package/dist/graphs/SmartScraperMultiGraph.js.map +1 -0
- package/dist/graphs/index.d.ts +12 -0
- package/dist/graphs/index.d.ts.map +1 -0
- package/dist/graphs/index.js +23 -0
- package/dist/graphs/index.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +43 -0
- package/dist/index.js.map +1 -0
- package/dist/models/GeminiModel.d.ts +16 -0
- package/dist/models/GeminiModel.d.ts.map +1 -0
- package/dist/models/GeminiModel.js +127 -0
- package/dist/models/GeminiModel.js.map +1 -0
- package/dist/models/OllamaModel.d.ts +15 -0
- package/dist/models/OllamaModel.d.ts.map +1 -0
- package/dist/models/OllamaModel.js +134 -0
- package/dist/models/OllamaModel.js.map +1 -0
- package/dist/models/index.d.ts +8 -0
- package/dist/models/index.d.ts.map +1 -0
- package/dist/models/index.js +24 -0
- package/dist/models/index.js.map +1 -0
- package/dist/nodes/BaseNode.d.ts +37 -0
- package/dist/nodes/BaseNode.d.ts.map +1 -0
- package/dist/nodes/BaseNode.js +116 -0
- package/dist/nodes/BaseNode.js.map +1 -0
- package/dist/nodes/CSVExporterNode.d.ts +16 -0
- package/dist/nodes/CSVExporterNode.d.ts.map +1 -0
- package/dist/nodes/CSVExporterNode.js +85 -0
- package/dist/nodes/CSVExporterNode.js.map +1 -0
- package/dist/nodes/ConditionalNode.d.ts +16 -0
- package/dist/nodes/ConditionalNode.d.ts.map +1 -0
- package/dist/nodes/ConditionalNode.js +68 -0
- package/dist/nodes/ConditionalNode.js.map +1 -0
- package/dist/nodes/FetchNode.d.ts +15 -0
- package/dist/nodes/FetchNode.d.ts.map +1 -0
- package/dist/nodes/FetchNode.js +182 -0
- package/dist/nodes/FetchNode.js.map +1 -0
- package/dist/nodes/GenerateAnswerNode.d.ts +14 -0
- package/dist/nodes/GenerateAnswerNode.d.ts.map +1 -0
- package/dist/nodes/GenerateAnswerNode.js +86 -0
- package/dist/nodes/GenerateAnswerNode.js.map +1 -0
- package/dist/nodes/JSONExporterNode.d.ts +16 -0
- package/dist/nodes/JSONExporterNode.d.ts.map +1 -0
- package/dist/nodes/JSONExporterNode.js +42 -0
- package/dist/nodes/JSONExporterNode.js.map +1 -0
- package/dist/nodes/MergeNode.d.ts +10 -0
- package/dist/nodes/MergeNode.d.ts.map +1 -0
- package/dist/nodes/MergeNode.js +51 -0
- package/dist/nodes/MergeNode.js.map +1 -0
- package/dist/nodes/PDFScraperNode.d.ts +10 -0
- package/dist/nodes/PDFScraperNode.d.ts.map +1 -0
- package/dist/nodes/PDFScraperNode.js +80 -0
- package/dist/nodes/PDFScraperNode.js.map +1 -0
- package/dist/nodes/ParseNode.d.ts +12 -0
- package/dist/nodes/ParseNode.d.ts.map +1 -0
- package/dist/nodes/ParseNode.js +44 -0
- package/dist/nodes/ParseNode.js.map +1 -0
- package/dist/nodes/RAGNode.d.ts +13 -0
- package/dist/nodes/RAGNode.d.ts.map +1 -0
- package/dist/nodes/RAGNode.js +64 -0
- package/dist/nodes/RAGNode.js.map +1 -0
- package/dist/nodes/ReasoningNode.d.ts +10 -0
- package/dist/nodes/ReasoningNode.d.ts.map +1 -0
- package/dist/nodes/ReasoningNode.js +51 -0
- package/dist/nodes/ReasoningNode.js.map +1 -0
- package/dist/nodes/SearchNode.d.ts +13 -0
- package/dist/nodes/SearchNode.d.ts.map +1 -0
- package/dist/nodes/SearchNode.js +81 -0
- package/dist/nodes/SearchNode.js.map +1 -0
- package/dist/nodes/XMLScraperNode.d.ts +11 -0
- package/dist/nodes/XMLScraperNode.d.ts.map +1 -0
- package/dist/nodes/XMLScraperNode.js +99 -0
- package/dist/nodes/XMLScraperNode.js.map +1 -0
- package/dist/nodes/index.d.ts +17 -0
- package/dist/nodes/index.d.ts.map +1 -0
- package/dist/nodes/index.js +33 -0
- package/dist/nodes/index.js.map +1 -0
- package/dist/prompts/index.d.ts +12 -0
- package/dist/prompts/index.d.ts.map +1 -0
- package/dist/prompts/index.js +117 -0
- package/dist/prompts/index.js.map +1 -0
- package/dist/types.d.ts +106 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +13 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/cache.d.ts +28 -0
- package/dist/utils/cache.d.ts.map +1 -0
- package/dist/utils/cache.js +72 -0
- package/dist/utils/cache.js.map +1 -0
- package/dist/utils/chunking.d.ts +8 -0
- package/dist/utils/chunking.d.ts.map +1 -0
- package/dist/utils/chunking.js +51 -0
- package/dist/utils/chunking.js.map +1 -0
- package/dist/utils/cleanupHtml.d.ts +7 -0
- package/dist/utils/cleanupHtml.d.ts.map +1 -0
- package/dist/utils/cleanupHtml.js +81 -0
- package/dist/utils/cleanupHtml.js.map +1 -0
- package/dist/utils/convertToMarkdown.d.ts +6 -0
- package/dist/utils/convertToMarkdown.d.ts.map +1 -0
- package/dist/utils/convertToMarkdown.js +61 -0
- package/dist/utils/convertToMarkdown.js.map +1 -0
- package/dist/utils/index.d.ts +13 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +40 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/logger.d.ts +14 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +35 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/proxy.d.ts +30 -0
- package/dist/utils/proxy.d.ts.map +1 -0
- package/dist/utils/proxy.js +62 -0
- package/dist/utils/proxy.js.map +1 -0
- package/dist/utils/rateLimiter.d.ts +24 -0
- package/dist/utils/rateLimiter.d.ts.map +1 -0
- package/dist/utils/rateLimiter.js +61 -0
- package/dist/utils/rateLimiter.js.map +1 -0
- package/dist/utils/retry.d.ts +17 -0
- package/dist/utils/retry.d.ts.map +1 -0
- package/dist/utils/retry.js +43 -0
- package/dist/utils/retry.js.map +1 -0
- package/dist/utils/schemaValidator.d.ts +69 -0
- package/dist/utils/schemaValidator.d.ts.map +1 -0
- package/dist/utils/schemaValidator.js +133 -0
- package/dist/utils/schemaValidator.js.map +1 -0
- package/package.json +64 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Utility functions index
|
|
4
|
+
*/
|
|
5
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
+
}
|
|
11
|
+
Object.defineProperty(o, k2, desc);
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
17
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
18
|
+
};
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.CommonSchemas = exports.SchemaValidator = exports.proxyRotator = exports.ProxyRotator = exports.globalCache = exports.cache = exports.Cache = exports.rateLimiter = exports.RateLimiter = exports.retry = void 0;
|
|
21
|
+
__exportStar(require("./cleanupHtml"), exports);
|
|
22
|
+
__exportStar(require("./convertToMarkdown"), exports);
|
|
23
|
+
__exportStar(require("./logger"), exports);
|
|
24
|
+
__exportStar(require("./chunking"), exports);
|
|
25
|
+
var retry_1 = require("./retry");
|
|
26
|
+
Object.defineProperty(exports, "retry", { enumerable: true, get: function () { return retry_1.retry; } });
|
|
27
|
+
var rateLimiter_1 = require("./rateLimiter");
|
|
28
|
+
Object.defineProperty(exports, "RateLimiter", { enumerable: true, get: function () { return rateLimiter_1.RateLimiter; } });
|
|
29
|
+
Object.defineProperty(exports, "rateLimiter", { enumerable: true, get: function () { return rateLimiter_1.rateLimiter; } });
|
|
30
|
+
var cache_1 = require("./cache");
|
|
31
|
+
Object.defineProperty(exports, "Cache", { enumerable: true, get: function () { return cache_1.Cache; } });
|
|
32
|
+
Object.defineProperty(exports, "cache", { enumerable: true, get: function () { return cache_1.cache; } });
|
|
33
|
+
Object.defineProperty(exports, "globalCache", { enumerable: true, get: function () { return cache_1.globalCache; } });
|
|
34
|
+
var proxy_1 = require("./proxy");
|
|
35
|
+
Object.defineProperty(exports, "ProxyRotator", { enumerable: true, get: function () { return proxy_1.ProxyRotator; } });
|
|
36
|
+
Object.defineProperty(exports, "proxyRotator", { enumerable: true, get: function () { return proxy_1.proxyRotator; } });
|
|
37
|
+
var schemaValidator_1 = require("./schemaValidator");
|
|
38
|
+
Object.defineProperty(exports, "SchemaValidator", { enumerable: true, get: function () { return schemaValidator_1.SchemaValidator; } });
|
|
39
|
+
Object.defineProperty(exports, "CommonSchemas", { enumerable: true, get: function () { return schemaValidator_1.CommonSchemas; } });
|
|
40
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;;AAEH,gDAA8B;AAC9B,sDAAoC;AACpC,2CAAyB;AACzB,6CAA2B;AAC3B,iCAAgC;AAAvB,8FAAA,KAAK,OAAA;AACd,6CAAyD;AAAhD,0GAAA,WAAW,OAAA;AAAE,0GAAA,WAAW,OAAA;AACjC,iCAAoD;AAA3C,8FAAA,KAAK,OAAA;AAAE,8FAAA,KAAK,OAAA;AAAE,oGAAA,WAAW,OAAA;AAClC,iCAAqD;AAA5C,qGAAA,YAAY,OAAA;AAAE,qGAAA,YAAY,OAAA;AACnC,qDAAmE;AAA1D,kHAAA,eAAe,OAAA;AAAE,gHAAA,aAAa,OAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Logging utility
|
|
3
|
+
*/
|
|
4
|
+
export declare class Logger {
|
|
5
|
+
private verbose;
|
|
6
|
+
private context;
|
|
7
|
+
constructor(context: string, verbose?: boolean);
|
|
8
|
+
info(message: string, ...args: any[]): void;
|
|
9
|
+
warn(message: string, ...args: any[]): void;
|
|
10
|
+
error(message: string, ...args: any[]): void;
|
|
11
|
+
success(message: string, ...args: any[]): void;
|
|
12
|
+
debug(message: string, ...args: any[]): void;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,qBAAa,MAAM;IACjB,OAAO,CAAC,OAAO,CAAU;IACzB,OAAO,CAAC,OAAO,CAAS;gBAEZ,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,OAAe;IAKrD,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;IAM3C,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;IAI3C,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;IAI5C,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;IAM9C,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;CAK7C"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Logging utility
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Logger = void 0;
|
|
7
|
+
class Logger {
|
|
8
|
+
constructor(context, verbose = false) {
|
|
9
|
+
this.context = context;
|
|
10
|
+
this.verbose = verbose;
|
|
11
|
+
}
|
|
12
|
+
info(message, ...args) {
|
|
13
|
+
if (this.verbose) {
|
|
14
|
+
console.log(`[${this.context}] ℹ️ ${message}`, ...args);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
warn(message, ...args) {
|
|
18
|
+
console.warn(`[${this.context}] ⚠️ ${message}`, ...args);
|
|
19
|
+
}
|
|
20
|
+
error(message, ...args) {
|
|
21
|
+
console.error(`[${this.context}] ❌ ${message}`, ...args);
|
|
22
|
+
}
|
|
23
|
+
success(message, ...args) {
|
|
24
|
+
if (this.verbose) {
|
|
25
|
+
console.log(`[${this.context}] ✅ ${message}`, ...args);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
debug(message, ...args) {
|
|
29
|
+
if (this.verbose) {
|
|
30
|
+
console.debug(`[${this.context}] 🔍 ${message}`, ...args);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.Logger = Logger;
|
|
35
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,MAAa,MAAM;IAIjB,YAAY,OAAe,EAAE,UAAmB,KAAK;QACnD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED,IAAI,CAAC,OAAe,EAAE,GAAG,IAAW;QAClC,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACjB,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,OAAO,SAAS,OAAO,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC;QAC3D,CAAC;IACH,CAAC;IAED,IAAI,CAAC,OAAe,EAAE,GAAG,IAAW;QAClC,OAAO,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,OAAO,SAAS,OAAO,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC;IAC5D,CAAC;IAED,KAAK,CAAC,OAAe,EAAE,GAAG,IAAW;QACnC,OAAO,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,OAAO,OAAO,OAAO,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC;IAC3D,CAAC;IAED,OAAO,CAAC,OAAe,EAAE,GAAG,IAAW;QACrC,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACjB,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,OAAO,OAAO,OAAO,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC;QACzD,CAAC;IACH,CAAC;IAED,KAAK,CAAC,OAAe,EAAE,GAAG,IAAW;QACnC,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACjB,OAAO,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,OAAO,QAAQ,OAAO,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC;QAC5D,CAAC;IACH,CAAC;CACF;AAlCD,wBAkCC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Proxy configuration and rotation
|
|
3
|
+
*/
|
|
4
|
+
export interface ProxyConfig {
|
|
5
|
+
host: string;
|
|
6
|
+
port: number;
|
|
7
|
+
username?: string;
|
|
8
|
+
password?: string;
|
|
9
|
+
protocol?: 'http' | 'https' | 'socks4' | 'socks5';
|
|
10
|
+
}
|
|
11
|
+
export declare class ProxyRotator {
|
|
12
|
+
private proxies;
|
|
13
|
+
private currentIndex;
|
|
14
|
+
private failedProxies;
|
|
15
|
+
constructor(proxies?: string[]);
|
|
16
|
+
getNext(): string | null;
|
|
17
|
+
markFailed(proxy: string): void;
|
|
18
|
+
markSuccess(proxy: string): void;
|
|
19
|
+
getStats(): {
|
|
20
|
+
total: number;
|
|
21
|
+
failed: number;
|
|
22
|
+
active: number;
|
|
23
|
+
};
|
|
24
|
+
reset(): void;
|
|
25
|
+
getNextProxy(): string | null;
|
|
26
|
+
markProxyFailed(): void;
|
|
27
|
+
setProxies(proxies: string[]): void;
|
|
28
|
+
}
|
|
29
|
+
export declare const proxyRotator: ProxyRotator;
|
|
30
|
+
//# sourceMappingURL=proxy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proxy.d.ts","sourceRoot":"","sources":["../../src/utils/proxy.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,CAAC;CACnD;AAED,qBAAa,YAAY;IACvB,OAAO,CAAC,OAAO,CAAW;IAC1B,OAAO,CAAC,YAAY,CAAa;IACjC,OAAO,CAAC,aAAa,CAAqB;gBAE9B,OAAO,GAAE,MAAM,EAAO;IAIlC,OAAO,IAAI,MAAM,GAAG,IAAI;IAmBxB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAI/B,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAIhC,QAAQ,IAAI;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE;IAQ7D,KAAK,IAAI,IAAI;IAKb,YAAY,IAAI,MAAM,GAAG,IAAI;IAI7B,eAAe,IAAI,IAAI;IAMvB,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI;CAIpC;AAGD,eAAO,MAAM,YAAY,cAAuB,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Proxy configuration and rotation
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.proxyRotator = exports.ProxyRotator = void 0;
|
|
7
|
+
class ProxyRotator {
|
|
8
|
+
constructor(proxies = []) {
|
|
9
|
+
this.currentIndex = 0;
|
|
10
|
+
this.failedProxies = new Set();
|
|
11
|
+
this.proxies = proxies;
|
|
12
|
+
}
|
|
13
|
+
getNext() {
|
|
14
|
+
if (this.proxies.length === 0)
|
|
15
|
+
return null;
|
|
16
|
+
// Try to find a working proxy
|
|
17
|
+
for (let i = 0; i < this.proxies.length; i++) {
|
|
18
|
+
const proxy = this.proxies[this.currentIndex];
|
|
19
|
+
this.currentIndex = (this.currentIndex + 1) % this.proxies.length;
|
|
20
|
+
if (!this.failedProxies.has(proxy)) {
|
|
21
|
+
return proxy;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
// If all proxies failed, reset failed list and try again
|
|
25
|
+
this.failedProxies.clear();
|
|
26
|
+
return this.proxies[0];
|
|
27
|
+
}
|
|
28
|
+
markFailed(proxy) {
|
|
29
|
+
this.failedProxies.add(proxy);
|
|
30
|
+
}
|
|
31
|
+
markSuccess(proxy) {
|
|
32
|
+
this.failedProxies.delete(proxy);
|
|
33
|
+
}
|
|
34
|
+
getStats() {
|
|
35
|
+
return {
|
|
36
|
+
total: this.proxies.length,
|
|
37
|
+
failed: this.failedProxies.size,
|
|
38
|
+
active: this.proxies.length - this.failedProxies.size,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
reset() {
|
|
42
|
+
this.failedProxies.clear();
|
|
43
|
+
this.currentIndex = 0;
|
|
44
|
+
}
|
|
45
|
+
getNextProxy() {
|
|
46
|
+
return this.getNext();
|
|
47
|
+
}
|
|
48
|
+
markProxyFailed() {
|
|
49
|
+
if (this.proxies.length === 0)
|
|
50
|
+
return;
|
|
51
|
+
const currentProxy = this.proxies[(this.currentIndex - 1 + this.proxies.length) % this.proxies.length];
|
|
52
|
+
this.markFailed(currentProxy);
|
|
53
|
+
}
|
|
54
|
+
setProxies(proxies) {
|
|
55
|
+
this.proxies = proxies;
|
|
56
|
+
this.reset();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
exports.ProxyRotator = ProxyRotator;
|
|
60
|
+
// Global proxy rotator instance
|
|
61
|
+
exports.proxyRotator = new ProxyRotator([]);
|
|
62
|
+
//# sourceMappingURL=proxy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proxy.js","sourceRoot":"","sources":["../../src/utils/proxy.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAUH,MAAa,YAAY;IAKvB,YAAY,UAAoB,EAAE;QAH1B,iBAAY,GAAW,CAAC,CAAC;QACzB,kBAAa,GAAG,IAAI,GAAG,EAAU,CAAC;QAGxC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED,OAAO;QACL,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,IAAI,CAAC;QAE3C,8BAA8B;QAC9B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAC7C,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;YAE9C,IAAI,CAAC,YAAY,GAAG,CAAC,IAAI,CAAC,YAAY,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;YAElE,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;gBACnC,OAAO,KAAK,CAAC;YACf,CAAC;QACH,CAAC;QAED,yDAAyD;QACzD,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;QAC3B,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IACzB,CAAC;IAED,UAAU,CAAC,KAAa;QACtB,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAChC,CAAC;IAED,WAAW,CAAC,KAAa;QACvB,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACnC,CAAC;IAED,QAAQ;QACN,OAAO;YACL,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM;YAC1B,MAAM,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI;YAC/B,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI;SACtD,CAAC;IACJ,CAAC;IAED,KAAK;QACH,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;QAC3B,IAAI,CAAC,YAAY,GAAG,CAAC,CAAC;IACxB,CAAC;IAED,YAAY;QACV,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC;IACxB,CAAC;IAED,eAAe;QACb,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO;QACtC,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,YAAY,GAAG,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACvG,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;IAChC,CAAC;IAED,UAAU,CAAC,OAAiB;QAC1B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,KAAK,EAAE,CAAC;IACf,CAAC;CACF;AA/DD,oCA+DC;AAED,gCAAgC;AACnB,QAAA,YAAY,GAAG,IAAI,YAAY,CAAC,EAAE,CAAC,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rate limiter for API calls and web requests
|
|
3
|
+
*/
|
|
4
|
+
export interface RateLimiterOptions {
|
|
5
|
+
maxRequests: number;
|
|
6
|
+
windowMs: number;
|
|
7
|
+
minDelay?: number;
|
|
8
|
+
}
|
|
9
|
+
export declare class RateLimiter {
|
|
10
|
+
private options;
|
|
11
|
+
private requests;
|
|
12
|
+
private lastRequestTime;
|
|
13
|
+
constructor(options: RateLimiterOptions);
|
|
14
|
+
acquire(): Promise<void>;
|
|
15
|
+
wait(): Promise<void>;
|
|
16
|
+
reset(): void;
|
|
17
|
+
getStats(): {
|
|
18
|
+
current: number;
|
|
19
|
+
limit: number;
|
|
20
|
+
window: number;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export declare const rateLimiter: RateLimiter;
|
|
24
|
+
//# sourceMappingURL=rateLimiter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rateLimiter.d.ts","sourceRoot":"","sources":["../../src/utils/rateLimiter.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,kBAAkB;IACjC,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,qBAAa,WAAW;IAIV,OAAO,CAAC,OAAO;IAH3B,OAAO,CAAC,QAAQ,CAAgB;IAChC,OAAO,CAAC,eAAe,CAAa;gBAEhB,OAAO,EAAE,kBAAkB;IAEzC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAgCxB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAI3B,KAAK,IAAI,IAAI;IAKb,QAAQ,IAAI;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE;CAY/D;AAGD,eAAO,MAAM,WAAW,aAItB,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Rate limiter for API calls and web requests
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.rateLimiter = exports.RateLimiter = void 0;
|
|
7
|
+
class RateLimiter {
|
|
8
|
+
constructor(options) {
|
|
9
|
+
this.options = options;
|
|
10
|
+
this.requests = [];
|
|
11
|
+
this.lastRequestTime = 0;
|
|
12
|
+
}
|
|
13
|
+
async acquire() {
|
|
14
|
+
const now = Date.now();
|
|
15
|
+
// Remove old requests outside the window
|
|
16
|
+
this.requests = this.requests.filter((time) => now - time < this.options.windowMs);
|
|
17
|
+
// Check if we're at the limit
|
|
18
|
+
if (this.requests.length >= this.options.maxRequests) {
|
|
19
|
+
const oldestRequest = Math.min(...this.requests);
|
|
20
|
+
const waitTime = this.options.windowMs - (now - oldestRequest);
|
|
21
|
+
if (waitTime > 0) {
|
|
22
|
+
await new Promise((resolve) => setTimeout(resolve, waitTime));
|
|
23
|
+
return this.acquire(); // Try again after waiting
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
// Enforce minimum delay between requests
|
|
27
|
+
if (this.options.minDelay) {
|
|
28
|
+
const timeSinceLastRequest = now - this.lastRequestTime;
|
|
29
|
+
if (timeSinceLastRequest < this.options.minDelay) {
|
|
30
|
+
const waitTime = this.options.minDelay - timeSinceLastRequest;
|
|
31
|
+
await new Promise((resolve) => setTimeout(resolve, waitTime));
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
this.requests.push(Date.now());
|
|
35
|
+
this.lastRequestTime = Date.now();
|
|
36
|
+
}
|
|
37
|
+
async wait() {
|
|
38
|
+
return this.acquire();
|
|
39
|
+
}
|
|
40
|
+
reset() {
|
|
41
|
+
this.requests = [];
|
|
42
|
+
this.lastRequestTime = 0;
|
|
43
|
+
}
|
|
44
|
+
getStats() {
|
|
45
|
+
const now = Date.now();
|
|
46
|
+
this.requests = this.requests.filter((time) => now - time < this.options.windowMs);
|
|
47
|
+
return {
|
|
48
|
+
current: this.requests.length,
|
|
49
|
+
limit: this.options.maxRequests,
|
|
50
|
+
window: this.options.windowMs,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
exports.RateLimiter = RateLimiter;
|
|
55
|
+
// Global rate limiter instance
|
|
56
|
+
exports.rateLimiter = new RateLimiter({
|
|
57
|
+
maxRequests: 10,
|
|
58
|
+
windowMs: 1000,
|
|
59
|
+
minDelay: 100,
|
|
60
|
+
});
|
|
61
|
+
//# sourceMappingURL=rateLimiter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rateLimiter.js","sourceRoot":"","sources":["../../src/utils/rateLimiter.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAQH,MAAa,WAAW;IAItB,YAAoB,OAA2B;QAA3B,YAAO,GAAP,OAAO,CAAoB;QAHvC,aAAQ,GAAa,EAAE,CAAC;QACxB,oBAAe,GAAW,CAAC,CAAC;IAEc,CAAC;IAEnD,KAAK,CAAC,OAAO;QACX,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAEvB,yCAAyC;QACzC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAClC,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,GAAG,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAC7C,CAAC;QAEF,8BAA8B;QAC9B,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,IAAI,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC;YACrD,MAAM,aAAa,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC;YACjD,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,GAAG,CAAC,GAAG,GAAG,aAAa,CAAC,CAAC;YAE/D,IAAI,QAAQ,GAAG,CAAC,EAAE,CAAC;gBACjB,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC;gBAC9D,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,0BAA0B;YACnD,CAAC;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AAG,IAAI,WAAW,CAAC;IACzC,WAAW,EAAE,EAAE;IACf,QAAQ,EAAE,IAAI;IACd,QAAQ,EAAE,GAAG;CACd,CAAC,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Retry utility with exponential backoff
|
|
3
|
+
*/
|
|
4
|
+
export interface RetryOptions {
|
|
5
|
+
maxRetries?: number;
|
|
6
|
+
initialDelay?: number;
|
|
7
|
+
maxDelay?: number;
|
|
8
|
+
backoffMultiplier?: number;
|
|
9
|
+
retryableErrors?: string[];
|
|
10
|
+
}
|
|
11
|
+
export declare class RetryError extends Error {
|
|
12
|
+
attempts: number;
|
|
13
|
+
lastError: Error;
|
|
14
|
+
constructor(message: string, attempts: number, lastError: Error);
|
|
15
|
+
}
|
|
16
|
+
export declare function retry<T>(fn: () => Promise<T>, options?: RetryOptions): Promise<T>;
|
|
17
|
+
//# sourceMappingURL=retry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retry.d.ts","sourceRoot":"","sources":["../../src/utils/retry.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,YAAY;IAC3B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;CAC5B;AAED,qBAAa,UAAW,SAAQ,KAAK;IAG1B,QAAQ,EAAE,MAAM;IAChB,SAAS,EAAE,KAAK;gBAFvB,OAAO,EAAE,MAAM,EACR,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,KAAK;CAK1B;AAED,wBAAsB,KAAK,CAAC,CAAC,EAC3B,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACpB,OAAO,GAAE,YAAiB,GACzB,OAAO,CAAC,CAAC,CAAC,CAgDZ"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Retry utility with exponential backoff
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.RetryError = void 0;
|
|
7
|
+
exports.retry = retry;
|
|
8
|
+
class RetryError extends Error {
|
|
9
|
+
constructor(message, attempts, lastError) {
|
|
10
|
+
super(message);
|
|
11
|
+
this.attempts = attempts;
|
|
12
|
+
this.lastError = lastError;
|
|
13
|
+
this.name = 'RetryError';
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.RetryError = RetryError;
|
|
17
|
+
async function retry(fn, options = {}) {
|
|
18
|
+
const { maxRetries = 3, initialDelay = 1000, maxDelay = 30000, backoffMultiplier = 2, retryableErrors = ['ECONNREFUSED', 'ETIMEDOUT', 'ENOTFOUND', '429', '503', '502', '504'], } = options;
|
|
19
|
+
let lastError;
|
|
20
|
+
let delay = initialDelay;
|
|
21
|
+
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
22
|
+
try {
|
|
23
|
+
return await fn();
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
lastError = error;
|
|
27
|
+
// Check if error is retryable
|
|
28
|
+
const isRetryable = retryableErrors.some((retryableError) => error.message?.includes(retryableError) ||
|
|
29
|
+
error.code?.includes(retryableError) ||
|
|
30
|
+
error.status?.toString() === retryableError);
|
|
31
|
+
// Don't retry if not retryable or max retries reached
|
|
32
|
+
if (!isRetryable || attempt === maxRetries) {
|
|
33
|
+
throw new RetryError(`Failed after ${attempt + 1} attempts: ${error.message}`, attempt + 1, error);
|
|
34
|
+
}
|
|
35
|
+
// Wait before retrying
|
|
36
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
37
|
+
// Exponential backoff
|
|
38
|
+
delay = Math.min(delay * backoffMultiplier, maxDelay);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
throw new RetryError(`Failed after ${maxRetries + 1} attempts`, maxRetries + 1, lastError);
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=retry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retry.js","sourceRoot":"","sources":["../../src/utils/retry.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAqBH,sBAmDC;AA9DD,MAAa,UAAW,SAAQ,KAAK;IACnC,YACE,OAAe,EACR,QAAgB,EAChB,SAAgB;QAEvB,KAAK,CAAC,OAAO,CAAC,CAAC;QAHR,aAAQ,GAAR,QAAQ,CAAQ;QAChB,cAAS,GAAT,SAAS,CAAO;QAGvB,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC;IAC3B,CAAC;CACF;AATD,gCASC;AAEM,KAAK,UAAU,KAAK,CACzB,EAAoB,EACpB,UAAwB,EAAE;IAE1B,MAAM,EACJ,UAAU,GAAG,CAAC,EACd,YAAY,GAAG,IAAI,EACnB,QAAQ,GAAG,KAAK,EAChB,iBAAiB,GAAG,CAAC,EACrB,eAAe,GAAG,CAAC,cAAc,EAAE,WAAW,EAAE,WAAW,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,GACzF,GAAG,OAAO,CAAC;IAEZ,IAAI,SAAgB,CAAC;IACrB,IAAI,KAAK,GAAG,YAAY,CAAC;IAEzB,KAAK,IAAI,OAAO,GAAG,CAAC,EAAE,OAAO,IAAI,UAAU,EAAE,OAAO,EAAE,EAAE,CAAC;QACvD,IAAI,CAAC;YACH,OAAO,MAAM,EAAE,EAAE,CAAC;QACpB,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,SAAS,GAAG,KAAK,CAAC;YAElB,8BAA8B;YAC9B,MAAM,WAAW,GAAG,eAAe,CAAC,IAAI,CACtC,CAAC,cAAc,EAAE,EAAE,CACjB,KAAK,CAAC,OAAO,EAAE,QAAQ,CAAC,cAAc,CAAC;gBACvC,KAAK,CAAC,IAAI,EAAE,QAAQ,CAAC,cAAc,CAAC;gBACpC,KAAK,CAAC,MAAM,EAAE,QAAQ,EAAE,KAAK,cAAc,CAC9C,CAAC;YAEF,sDAAsD;YACtD,IAAI,CAAC,WAAW,IAAI,OAAO,KAAK,UAAU,EAAE,CAAC;gBAC3C,MAAM,IAAI,UAAU,CAClB,gBAAgB,OAAO,GAAG,CAAC,cAAc,KAAK,CAAC,OAAO,EAAE,EACxD,OAAO,GAAG,CAAC,EACX,KAAK,CACN,CAAC;YACJ,CAAC;YAED,uBAAuB;YACvB,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC;YAE3D,sBAAsB;YACtB,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,iBAAiB,EAAE,QAAQ,CAAC,CAAC;QACxD,CAAC;IACH,CAAC;IAED,MAAM,IAAI,UAAU,CAClB,gBAAgB,UAAU,GAAG,CAAC,WAAW,EACzC,UAAU,GAAG,CAAC,EACd,SAAU,CACX,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Schema validation utilities using Zod
|
|
3
|
+
*/
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
export declare class SchemaValidator {
|
|
6
|
+
/**
|
|
7
|
+
* Validate data against a Zod schema
|
|
8
|
+
*/
|
|
9
|
+
static validate<T>(schema: z.ZodType<T>, data: unknown): {
|
|
10
|
+
success: true;
|
|
11
|
+
data: T;
|
|
12
|
+
} | {
|
|
13
|
+
success: false;
|
|
14
|
+
error: string;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Parse and validate JSON string against schema
|
|
18
|
+
*/
|
|
19
|
+
static validateJson<T>(schema: z.ZodType<T>, jsonString: string): {
|
|
20
|
+
success: true;
|
|
21
|
+
data: T;
|
|
22
|
+
} | {
|
|
23
|
+
success: false;
|
|
24
|
+
error: string;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Create a schema-aware prompt wrapper
|
|
28
|
+
*/
|
|
29
|
+
static wrapPromptWithSchema(prompt: string, schema: z.ZodType<any>): string;
|
|
30
|
+
/**
|
|
31
|
+
* Generate human-readable schema description from Zod schema
|
|
32
|
+
*/
|
|
33
|
+
private static generateSchemaDescription;
|
|
34
|
+
/**
|
|
35
|
+
* Get simple type name from Zod schema
|
|
36
|
+
*/
|
|
37
|
+
private static getZodTypeName;
|
|
38
|
+
}
|
|
39
|
+
export declare const CommonSchemas: {
|
|
40
|
+
Product: z.ZodObject<{
|
|
41
|
+
name: z.ZodString;
|
|
42
|
+
price: z.ZodNumber;
|
|
43
|
+
description: z.ZodOptional<z.ZodString>;
|
|
44
|
+
inStock: z.ZodOptional<z.ZodBoolean>;
|
|
45
|
+
category: z.ZodOptional<z.ZodString>;
|
|
46
|
+
}, z.core.$strip>;
|
|
47
|
+
Article: z.ZodObject<{
|
|
48
|
+
title: z.ZodString;
|
|
49
|
+
author: z.ZodOptional<z.ZodString>;
|
|
50
|
+
publishDate: z.ZodOptional<z.ZodString>;
|
|
51
|
+
content: z.ZodString;
|
|
52
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
53
|
+
}, z.core.$strip>;
|
|
54
|
+
Company: z.ZodObject<{
|
|
55
|
+
name: z.ZodString;
|
|
56
|
+
description: z.ZodString;
|
|
57
|
+
founded: z.ZodOptional<z.ZodString>;
|
|
58
|
+
founders: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
59
|
+
website: z.ZodOptional<z.ZodString>;
|
|
60
|
+
industry: z.ZodOptional<z.ZodString>;
|
|
61
|
+
}, z.core.$strip>;
|
|
62
|
+
ContactInfo: z.ZodObject<{
|
|
63
|
+
name: z.ZodString;
|
|
64
|
+
email: z.ZodOptional<z.ZodString>;
|
|
65
|
+
phone: z.ZodOptional<z.ZodString>;
|
|
66
|
+
address: z.ZodOptional<z.ZodString>;
|
|
67
|
+
}, z.core.$strip>;
|
|
68
|
+
};
|
|
69
|
+
//# sourceMappingURL=schemaValidator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemaValidator.d.ts","sourceRoot":"","sources":["../../src/utils/schemaValidator.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,qBAAa,eAAe;IAC1B;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,GAAG;QAAE,OAAO,EAAE,IAAI,CAAC;QAAC,IAAI,EAAE,CAAC,CAAA;KAAE,GAAG;QAAE,OAAO,EAAE,KAAK,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE;IAiBvH;;OAEG;IACH,MAAM,CAAC,YAAY,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,MAAM,GAAG;QAAE,OAAO,EAAE,IAAI,CAAC;QAAC,IAAI,EAAE,CAAC,CAAA;KAAE,GAAG;QAAE,OAAO,EAAE,KAAK,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE;IAShI;;OAEG;IACH,MAAM,CAAC,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,MAAM;IAW3E;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,yBAAyB;IA0BxC;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,cAAc;CAU9B;AAGD,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgCzB,CAAC"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Schema validation utilities using Zod
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.CommonSchemas = exports.SchemaValidator = void 0;
|
|
7
|
+
const zod_1 = require("zod");
|
|
8
|
+
class SchemaValidator {
|
|
9
|
+
/**
|
|
10
|
+
* Validate data against a Zod schema
|
|
11
|
+
*/
|
|
12
|
+
static validate(schema, data) {
|
|
13
|
+
try {
|
|
14
|
+
const result = schema.safeParse(data);
|
|
15
|
+
if (result.success) {
|
|
16
|
+
return { success: true, data: result.data };
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
const errorMessage = result.error.issues
|
|
20
|
+
.map((err) => `${err.path.join('.')}: ${err.message}`)
|
|
21
|
+
.join(', ');
|
|
22
|
+
return { success: false, error: errorMessage };
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
return { success: false, error: error.message };
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Parse and validate JSON string against schema
|
|
31
|
+
*/
|
|
32
|
+
static validateJson(schema, jsonString) {
|
|
33
|
+
try {
|
|
34
|
+
const parsed = JSON.parse(jsonString);
|
|
35
|
+
return this.validate(schema, parsed);
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
return { success: false, error: `JSON parse error: ${error.message}` };
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Create a schema-aware prompt wrapper
|
|
43
|
+
*/
|
|
44
|
+
static wrapPromptWithSchema(prompt, schema) {
|
|
45
|
+
const schemaDescription = this.generateSchemaDescription(schema);
|
|
46
|
+
return `${prompt}
|
|
47
|
+
|
|
48
|
+
IMPORTANT: Your response must be valid JSON matching this exact structure:
|
|
49
|
+
${schemaDescription}
|
|
50
|
+
|
|
51
|
+
Respond with valid JSON only, no explanations or markdown.`;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Generate human-readable schema description from Zod schema
|
|
55
|
+
*/
|
|
56
|
+
static generateSchemaDescription(schema) {
|
|
57
|
+
try {
|
|
58
|
+
// For object schemas, describe the structure
|
|
59
|
+
if (schema instanceof zod_1.z.ZodObject) {
|
|
60
|
+
const shape = schema.shape;
|
|
61
|
+
const fields = Object.entries(shape).map(([key, value]) => {
|
|
62
|
+
const fieldSchema = value;
|
|
63
|
+
const isOptional = fieldSchema instanceof zod_1.z.ZodOptional;
|
|
64
|
+
const type = this.getZodTypeName(fieldSchema);
|
|
65
|
+
return ` "${key}": ${type}${isOptional ? ' (optional)' : ''}`;
|
|
66
|
+
});
|
|
67
|
+
return `{\n${fields.join(',\n')}\n}`;
|
|
68
|
+
}
|
|
69
|
+
// For array schemas
|
|
70
|
+
if (schema instanceof zod_1.z.ZodArray) {
|
|
71
|
+
const elementType = this.getZodTypeName(schema._def.type);
|
|
72
|
+
return `Array<${elementType}>`;
|
|
73
|
+
}
|
|
74
|
+
return 'object';
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
return 'object';
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Get simple type name from Zod schema
|
|
82
|
+
*/
|
|
83
|
+
static getZodTypeName(schema) {
|
|
84
|
+
if (schema instanceof zod_1.z.ZodString)
|
|
85
|
+
return 'string';
|
|
86
|
+
if (schema instanceof zod_1.z.ZodNumber)
|
|
87
|
+
return 'number';
|
|
88
|
+
if (schema instanceof zod_1.z.ZodBoolean)
|
|
89
|
+
return 'boolean';
|
|
90
|
+
if (schema instanceof zod_1.z.ZodArray)
|
|
91
|
+
return `array<${this.getZodTypeName(schema._def.type)}>`;
|
|
92
|
+
if (schema instanceof zod_1.z.ZodObject)
|
|
93
|
+
return 'object';
|
|
94
|
+
if (schema instanceof zod_1.z.ZodOptional)
|
|
95
|
+
return this.getZodTypeName(schema._def.innerType);
|
|
96
|
+
if (schema instanceof zod_1.z.ZodNullable)
|
|
97
|
+
return `${this.getZodTypeName(schema._def.innerType)} | null`;
|
|
98
|
+
return 'any';
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
exports.SchemaValidator = SchemaValidator;
|
|
102
|
+
// Common schema examples
|
|
103
|
+
exports.CommonSchemas = {
|
|
104
|
+
Product: zod_1.z.object({
|
|
105
|
+
name: zod_1.z.string(),
|
|
106
|
+
price: zod_1.z.number(),
|
|
107
|
+
description: zod_1.z.string().optional(),
|
|
108
|
+
inStock: zod_1.z.boolean().optional(),
|
|
109
|
+
category: zod_1.z.string().optional(),
|
|
110
|
+
}),
|
|
111
|
+
Article: zod_1.z.object({
|
|
112
|
+
title: zod_1.z.string(),
|
|
113
|
+
author: zod_1.z.string().optional(),
|
|
114
|
+
publishDate: zod_1.z.string().optional(),
|
|
115
|
+
content: zod_1.z.string(),
|
|
116
|
+
tags: zod_1.z.array(zod_1.z.string()).optional(),
|
|
117
|
+
}),
|
|
118
|
+
Company: zod_1.z.object({
|
|
119
|
+
name: zod_1.z.string(),
|
|
120
|
+
description: zod_1.z.string(),
|
|
121
|
+
founded: zod_1.z.string().optional(),
|
|
122
|
+
founders: zod_1.z.array(zod_1.z.string()).optional(),
|
|
123
|
+
website: zod_1.z.string().optional(),
|
|
124
|
+
industry: zod_1.z.string().optional(),
|
|
125
|
+
}),
|
|
126
|
+
ContactInfo: zod_1.z.object({
|
|
127
|
+
name: zod_1.z.string(),
|
|
128
|
+
email: zod_1.z.string().email().optional(),
|
|
129
|
+
phone: zod_1.z.string().optional(),
|
|
130
|
+
address: zod_1.z.string().optional(),
|
|
131
|
+
}),
|
|
132
|
+
};
|
|
133
|
+
//# sourceMappingURL=schemaValidator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemaValidator.js","sourceRoot":"","sources":["../../src/utils/schemaValidator.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,6BAAwB;AAExB,MAAa,eAAe;IAC1B;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAI,MAAoB,EAAE,IAAa;QACpD,IAAI,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AC,KAAK,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;KACrC,CAAC;IAEF,OAAO,EAAE,OAAC,CAAC,MAAM,CAAC;QAChB,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE;QAChB,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE;QACvB,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;QAC9B,QAAQ,EAAE,OAAC,CAAC,KAAK,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;QACxC,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;QAC9B,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;KAChC,CAAC;IAEF,WAAW,EAAE,OAAC,CAAC,MAAM,CAAC;QACpB,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE;QAChB,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC,QAAQ,EAAE;QACpC,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;QAC5B,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;KAC/B,CAAC;CACH,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "cogniscrape",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A TypeScript web scraping library using LLMs (Ollama & Google Gemini) and graph logic - 100% free version",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "tsc",
|
|
9
|
+
"dev": "tsc --watch",
|
|
10
|
+
"test": "jest",
|
|
11
|
+
"example": "ts-node examples/smart-scraper.ts",
|
|
12
|
+
"prepublishOnly": "npm run build"
|
|
13
|
+
},
|
|
14
|
+
"keywords": [
|
|
15
|
+
"scraping",
|
|
16
|
+
"llm",
|
|
17
|
+
"ollama",
|
|
18
|
+
"gemini",
|
|
19
|
+
"ai",
|
|
20
|
+
"graph",
|
|
21
|
+
"web-scraping",
|
|
22
|
+
"automation",
|
|
23
|
+
"typescript",
|
|
24
|
+
"playwright",
|
|
25
|
+
"rag",
|
|
26
|
+
"intelligent-scraping"
|
|
27
|
+
],
|
|
28
|
+
"author": "Your Name <your.email@example.com>",
|
|
29
|
+
"license": "MIT",
|
|
30
|
+
"repository": {
|
|
31
|
+
"type": "git",
|
|
32
|
+
"url": "https://github.com/yourusername/cogniscrape.git"
|
|
33
|
+
},
|
|
34
|
+
"bugs": {
|
|
35
|
+
"url": "https://github.com/yourusername/cogniscrape/issues"
|
|
36
|
+
},
|
|
37
|
+
"homepage": "https://github.com/yourusername/cogniscrape#readme",
|
|
38
|
+
"files": [
|
|
39
|
+
"dist",
|
|
40
|
+
"README.md",
|
|
41
|
+
"LICENSE"
|
|
42
|
+
],
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"@google/generative-ai": "^0.21.0",
|
|
45
|
+
"axios": "^1.7.9",
|
|
46
|
+
"cheerio": "^1.0.0",
|
|
47
|
+
"cheerio-tableparser": "^1.0.1",
|
|
48
|
+
"fast-xml-parser": "^5.3.3",
|
|
49
|
+
"html-minifier": "^4.0.0",
|
|
50
|
+
"pdf-parse": "^2.4.5",
|
|
51
|
+
"playwright": "^1.49.1",
|
|
52
|
+
"turndown": "^7.2.0",
|
|
53
|
+
"zod": "^4.3.5"
|
|
54
|
+
},
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"@types/html-minifier": "^4.0.5",
|
|
57
|
+
"@types/jest": "^29.5.14",
|
|
58
|
+
"@types/node": "^22.10.5",
|
|
59
|
+
"@types/turndown": "^5.0.5",
|
|
60
|
+
"jest": "^29.7.0",
|
|
61
|
+
"ts-node": "^10.9.2",
|
|
62
|
+
"typescript": "^5.7.2"
|
|
63
|
+
}
|
|
64
|
+
}
|