@dealcrawl/sdk 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/README.md +540 -0
- package/dist/sdk/src/client.d.ts +285 -0
- package/dist/sdk/src/client.d.ts.map +1 -0
- package/dist/sdk/src/client.js +336 -0
- package/dist/sdk/src/client.js.map +1 -0
- package/dist/sdk/src/error.d.ts +54 -0
- package/dist/sdk/src/error.d.ts.map +1 -0
- package/dist/sdk/src/error.js +115 -0
- package/dist/sdk/src/error.js.map +1 -0
- package/dist/sdk/src/index.d.ts +58 -0
- package/dist/sdk/src/index.d.ts.map +1 -0
- package/dist/sdk/src/index.js +65 -0
- package/dist/sdk/src/index.js.map +1 -0
- package/dist/sdk/src/resources/account.d.ts +143 -0
- package/dist/sdk/src/resources/account.d.ts.map +1 -0
- package/dist/sdk/src/resources/account.js +186 -0
- package/dist/sdk/src/resources/account.js.map +1 -0
- package/dist/sdk/src/resources/crawl.d.ts +87 -0
- package/dist/sdk/src/resources/crawl.d.ts.map +1 -0
- package/dist/sdk/src/resources/crawl.js +205 -0
- package/dist/sdk/src/resources/crawl.js.map +1 -0
- package/dist/sdk/src/resources/data.d.ts +157 -0
- package/dist/sdk/src/resources/data.d.ts.map +1 -0
- package/dist/sdk/src/resources/data.js +239 -0
- package/dist/sdk/src/resources/data.js.map +1 -0
- package/dist/sdk/src/resources/dork.d.ts +104 -0
- package/dist/sdk/src/resources/dork.d.ts.map +1 -0
- package/dist/sdk/src/resources/dork.js +163 -0
- package/dist/sdk/src/resources/dork.js.map +1 -0
- package/dist/sdk/src/resources/extract.d.ts +105 -0
- package/dist/sdk/src/resources/extract.d.ts.map +1 -0
- package/dist/sdk/src/resources/extract.js +246 -0
- package/dist/sdk/src/resources/extract.js.map +1 -0
- package/dist/sdk/src/resources/index.d.ts +14 -0
- package/dist/sdk/src/resources/index.d.ts.map +1 -0
- package/dist/sdk/src/resources/index.js +14 -0
- package/dist/sdk/src/resources/index.js.map +1 -0
- package/dist/sdk/src/resources/keys.d.ts +124 -0
- package/dist/sdk/src/resources/keys.d.ts.map +1 -0
- package/dist/sdk/src/resources/keys.js +168 -0
- package/dist/sdk/src/resources/keys.js.map +1 -0
- package/dist/sdk/src/resources/scrape.d.ts +53 -0
- package/dist/sdk/src/resources/scrape.d.ts.map +1 -0
- package/dist/sdk/src/resources/scrape.js +85 -0
- package/dist/sdk/src/resources/scrape.js.map +1 -0
- package/dist/sdk/src/resources/status.d.ts +100 -0
- package/dist/sdk/src/resources/status.d.ts.map +1 -0
- package/dist/sdk/src/resources/status.js +133 -0
- package/dist/sdk/src/resources/status.js.map +1 -0
- package/dist/sdk/src/resources/webhooks.d.ts +126 -0
- package/dist/sdk/src/resources/webhooks.d.ts.map +1 -0
- package/dist/sdk/src/resources/webhooks.js +167 -0
- package/dist/sdk/src/resources/webhooks.js.map +1 -0
- package/dist/sdk/src/types/config.d.ts +45 -0
- package/dist/sdk/src/types/config.d.ts.map +1 -0
- package/dist/sdk/src/types/config.js +10 -0
- package/dist/sdk/src/types/config.js.map +1 -0
- package/dist/sdk/src/types/index.d.ts +8 -0
- package/dist/sdk/src/types/index.d.ts.map +1 -0
- package/dist/sdk/src/types/index.js +8 -0
- package/dist/sdk/src/types/index.js.map +1 -0
- package/dist/sdk/src/types/options.d.ts +286 -0
- package/dist/sdk/src/types/options.d.ts.map +1 -0
- package/dist/sdk/src/types/options.js +6 -0
- package/dist/sdk/src/types/options.js.map +1 -0
- package/dist/sdk/src/types/responses.d.ts +385 -0
- package/dist/sdk/src/types/responses.d.ts.map +1 -0
- package/dist/sdk/src/types/responses.js +6 -0
- package/dist/sdk/src/types/responses.js.map +1 -0
- package/dist/sdk/src/utils/polling.d.ts +57 -0
- package/dist/sdk/src/utils/polling.d.ts.map +1 -0
- package/dist/sdk/src/utils/polling.js +110 -0
- package/dist/sdk/src/utils/polling.js.map +1 -0
- package/dist/sdk/src/utils/request.d.ts +47 -0
- package/dist/sdk/src/utils/request.d.ts.map +1 -0
- package/dist/sdk/src/utils/request.js +161 -0
- package/dist/sdk/src/utils/request.js.map +1 -0
- package/dist/shared/src/constants/errors.d.ts +26 -0
- package/dist/shared/src/constants/errors.d.ts.map +1 -0
- package/dist/shared/src/constants/errors.js +39 -0
- package/dist/shared/src/constants/errors.js.map +1 -0
- package/dist/shared/src/constants/http.d.ts +26 -0
- package/dist/shared/src/constants/http.d.ts.map +1 -0
- package/dist/shared/src/constants/http.js +26 -0
- package/dist/shared/src/constants/http.js.map +1 -0
- package/dist/shared/src/constants/index.d.ts +4 -0
- package/dist/shared/src/constants/index.d.ts.map +1 -0
- package/dist/shared/src/constants/index.js +5 -0
- package/dist/shared/src/constants/index.js.map +1 -0
- package/dist/shared/src/constants/limits.d.ts +52 -0
- package/dist/shared/src/constants/limits.d.ts.map +1 -0
- package/dist/shared/src/constants/limits.js +43 -0
- package/dist/shared/src/constants/limits.js.map +1 -0
- package/dist/shared/src/index.d.ts +5 -0
- package/dist/shared/src/index.d.ts.map +1 -0
- package/dist/shared/src/index.js +11 -0
- package/dist/shared/src/index.js.map +1 -0
- package/dist/shared/src/lib/index.d.ts +2 -0
- package/dist/shared/src/lib/index.d.ts.map +1 -0
- package/dist/shared/src/lib/index.js +2 -0
- package/dist/shared/src/lib/index.js.map +1 -0
- package/dist/shared/src/lib/redis.d.ts +14 -0
- package/dist/shared/src/lib/redis.d.ts.map +1 -0
- package/dist/shared/src/lib/redis.js +60 -0
- package/dist/shared/src/lib/redis.js.map +1 -0
- package/dist/shared/src/types/api-key.types.d.ts +94 -0
- package/dist/shared/src/types/api-key.types.d.ts.map +1 -0
- package/dist/shared/src/types/api-key.types.js +30 -0
- package/dist/shared/src/types/api-key.types.js.map +1 -0
- package/dist/shared/src/types/api.types.d.ts +38 -0
- package/dist/shared/src/types/api.types.d.ts.map +1 -0
- package/dist/shared/src/types/api.types.js +2 -0
- package/dist/shared/src/types/api.types.js.map +1 -0
- package/dist/shared/src/types/client.types.d.ts +73 -0
- package/dist/shared/src/types/client.types.d.ts.map +1 -0
- package/dist/shared/src/types/client.types.js +9 -0
- package/dist/shared/src/types/client.types.js.map +1 -0
- package/dist/shared/src/types/crawl.types.d.ts +65 -0
- package/dist/shared/src/types/crawl.types.d.ts.map +1 -0
- package/dist/shared/src/types/crawl.types.js +2 -0
- package/dist/shared/src/types/crawl.types.js.map +1 -0
- package/dist/shared/src/types/deal.types.d.ts +210 -0
- package/dist/shared/src/types/deal.types.d.ts.map +1 -0
- package/dist/shared/src/types/deal.types.js +6 -0
- package/dist/shared/src/types/deal.types.js.map +1 -0
- package/dist/shared/src/types/dork.types.d.ts +29 -0
- package/dist/shared/src/types/dork.types.d.ts.map +1 -0
- package/dist/shared/src/types/dork.types.js +2 -0
- package/dist/shared/src/types/dork.types.js.map +1 -0
- package/dist/shared/src/types/index.d.ts +8 -0
- package/dist/shared/src/types/index.d.ts.map +1 -0
- package/dist/shared/src/types/index.js +9 -0
- package/dist/shared/src/types/index.js.map +1 -0
- package/dist/shared/src/types/scrape.types.d.ts +151 -0
- package/dist/shared/src/types/scrape.types.d.ts.map +1 -0
- package/dist/shared/src/types/scrape.types.js +2 -0
- package/dist/shared/src/types/scrape.types.js.map +1 -0
- package/dist/shared/src/utils/date.d.ts +7 -0
- package/dist/shared/src/utils/date.d.ts.map +1 -0
- package/dist/shared/src/utils/date.js +25 -0
- package/dist/shared/src/utils/date.js.map +1 -0
- package/dist/shared/src/utils/hash.d.ts +4 -0
- package/dist/shared/src/utils/hash.d.ts.map +1 -0
- package/dist/shared/src/utils/hash.js +21 -0
- package/dist/shared/src/utils/hash.js.map +1 -0
- package/dist/shared/src/utils/index.d.ts +7 -0
- package/dist/shared/src/utils/index.d.ts.map +1 -0
- package/dist/shared/src/utils/index.js +8 -0
- package/dist/shared/src/utils/index.js.map +1 -0
- package/dist/shared/src/utils/logger.d.ts +66 -0
- package/dist/shared/src/utils/logger.d.ts.map +1 -0
- package/dist/shared/src/utils/logger.js +268 -0
- package/dist/shared/src/utils/logger.js.map +1 -0
- package/dist/shared/src/utils/retry.d.ts +11 -0
- package/dist/shared/src/utils/retry.d.ts.map +1 -0
- package/dist/shared/src/utils/retry.js +36 -0
- package/dist/shared/src/utils/retry.js.map +1 -0
- package/dist/shared/src/utils/url-validator.d.ts +37 -0
- package/dist/shared/src/utils/url-validator.d.ts.map +1 -0
- package/dist/shared/src/utils/url-validator.js +179 -0
- package/dist/shared/src/utils/url-validator.js.map +1 -0
- package/dist/shared/src/utils/url.d.ts +6 -0
- package/dist/shared/src/utils/url.d.ts.map +1 -0
- package/dist/shared/src/utils/url.js +56 -0
- package/dist/shared/src/utils/url.js.map +1 -0
- package/package.json +49 -0
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/** Screenshot configuration options */
|
|
2
|
+
export interface ScreenshotOptions {
|
|
3
|
+
/** Enable screenshot capture */
|
|
4
|
+
enabled: boolean;
|
|
5
|
+
/** Capture full page or viewport only (default: false = viewport) */
|
|
6
|
+
fullPage?: boolean;
|
|
7
|
+
/** Viewport width in pixels (default: 1280) */
|
|
8
|
+
width?: number;
|
|
9
|
+
/** Viewport height in pixels (default: 720) */
|
|
10
|
+
height?: number;
|
|
11
|
+
/** Image format (default: png) */
|
|
12
|
+
format?: "png" | "jpeg" | "webp";
|
|
13
|
+
/** JPEG/WebP quality 0-100 (default: 80) */
|
|
14
|
+
quality?: number;
|
|
15
|
+
}
|
|
16
|
+
/** Screenshot result with metadata */
|
|
17
|
+
export interface ScreenshotResult {
|
|
18
|
+
/** Public URL to the screenshot */
|
|
19
|
+
url: string;
|
|
20
|
+
/** Screenshot width in pixels */
|
|
21
|
+
width: number;
|
|
22
|
+
/** Screenshot height in pixels */
|
|
23
|
+
height: number;
|
|
24
|
+
/** Image format */
|
|
25
|
+
format: "png" | "jpeg" | "webp";
|
|
26
|
+
/** File size in bytes */
|
|
27
|
+
sizeBytes: number;
|
|
28
|
+
}
|
|
29
|
+
export interface ScrapeOptions {
|
|
30
|
+
url?: string;
|
|
31
|
+
headers?: Record<string, string>;
|
|
32
|
+
timeout?: number;
|
|
33
|
+
detectSignals?: boolean;
|
|
34
|
+
extractWithAI?: boolean;
|
|
35
|
+
/** Extract deal-specific information with AI */
|
|
36
|
+
extractDeal?: boolean;
|
|
37
|
+
/** Use advanced AI model for complex pages */
|
|
38
|
+
useAdvancedModel?: boolean;
|
|
39
|
+
/** Minimum deal score threshold (0-100) */
|
|
40
|
+
minDealScore?: number;
|
|
41
|
+
/** @deprecated Use screenshot.enabled instead */
|
|
42
|
+
takeScreenshot?: boolean;
|
|
43
|
+
/** Screenshot configuration */
|
|
44
|
+
screenshot?: ScreenshotOptions;
|
|
45
|
+
/** HTML tags to exclude from content (e.g., ["nav", "footer", "aside"]) */
|
|
46
|
+
excludeTags?: string[];
|
|
47
|
+
/** CSS selectors to exclude from content (e.g., [".sidebar", "#comments"]) */
|
|
48
|
+
excludeSelectors?: string[];
|
|
49
|
+
/** Only extract main content area (default: true) */
|
|
50
|
+
onlyMainContent?: boolean;
|
|
51
|
+
}
|
|
52
|
+
/** Enhanced link metadata with internal/external classification */
|
|
53
|
+
export interface LinkMetadata {
|
|
54
|
+
/** Total number of links found */
|
|
55
|
+
total: number;
|
|
56
|
+
/** Internal links (same domain) */
|
|
57
|
+
internal: string[];
|
|
58
|
+
/** External links (different domain) */
|
|
59
|
+
external: string[];
|
|
60
|
+
}
|
|
61
|
+
/** Enhanced image metadata */
|
|
62
|
+
export interface ImageMetadata {
|
|
63
|
+
/** Total number of images found */
|
|
64
|
+
total: number;
|
|
65
|
+
/** Image URLs */
|
|
66
|
+
urls: string[];
|
|
67
|
+
}
|
|
68
|
+
/** OpenGraph metadata */
|
|
69
|
+
export interface OpenGraphMetadata {
|
|
70
|
+
title?: string;
|
|
71
|
+
description?: string;
|
|
72
|
+
image?: string;
|
|
73
|
+
url?: string;
|
|
74
|
+
siteName?: string;
|
|
75
|
+
type?: string;
|
|
76
|
+
locale?: string;
|
|
77
|
+
localeAlternate?: string[];
|
|
78
|
+
}
|
|
79
|
+
export interface ParsedPage {
|
|
80
|
+
url: string;
|
|
81
|
+
/** Crawl depth (0 = start URL, 1 = first hop, etc.) */
|
|
82
|
+
depth?: number;
|
|
83
|
+
title?: string;
|
|
84
|
+
description?: string;
|
|
85
|
+
content?: string;
|
|
86
|
+
/** Language of the page (from html lang attribute) */
|
|
87
|
+
language?: string;
|
|
88
|
+
/** @deprecated Use linksMetadata instead */
|
|
89
|
+
links?: string[];
|
|
90
|
+
/** Enhanced link metadata with internal/external classification */
|
|
91
|
+
linksMetadata?: LinkMetadata;
|
|
92
|
+
/** @deprecated Use imagesMetadata instead */
|
|
93
|
+
images?: string[];
|
|
94
|
+
/** Enhanced image metadata */
|
|
95
|
+
imagesMetadata?: ImageMetadata;
|
|
96
|
+
/** OpenGraph metadata */
|
|
97
|
+
openGraph?: OpenGraphMetadata;
|
|
98
|
+
/** Raw metadata (JSON-LD, microdata, etc.) */
|
|
99
|
+
metadata?: Record<string, unknown>;
|
|
100
|
+
/** HTTP status code */
|
|
101
|
+
statusCode?: number;
|
|
102
|
+
/** Crawl duration in milliseconds */
|
|
103
|
+
crawlDurationMs?: number;
|
|
104
|
+
signals?: Signal[];
|
|
105
|
+
}
|
|
106
|
+
export interface Signal {
|
|
107
|
+
type: string;
|
|
108
|
+
value: string;
|
|
109
|
+
confidence: number;
|
|
110
|
+
metadata?: Record<string, unknown>;
|
|
111
|
+
}
|
|
112
|
+
export interface DealScoreSummary {
|
|
113
|
+
score: number;
|
|
114
|
+
quality: "excellent" | "good" | "average" | "poor" | "very_poor";
|
|
115
|
+
recommendation: "highly_recommended" | "recommended" | "consider" | "skip";
|
|
116
|
+
breakdown: {
|
|
117
|
+
discount: number;
|
|
118
|
+
urgency: number;
|
|
119
|
+
legitimacy: number;
|
|
120
|
+
priceClarity: number;
|
|
121
|
+
productInfo: number;
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
export interface ScrapeResult {
|
|
125
|
+
url: string;
|
|
126
|
+
parsed: ParsedPage;
|
|
127
|
+
signals: Signal[];
|
|
128
|
+
aiExtraction?: AIExtraction;
|
|
129
|
+
/** Deal extraction result from Phase 4 AI */
|
|
130
|
+
dealExtraction?: import("./deal.types").ExtractedDeal;
|
|
131
|
+
/** Deal quality score from AI */
|
|
132
|
+
dealScore?: DealScoreSummary;
|
|
133
|
+
/** Screenshot URL or base64 data */
|
|
134
|
+
screenshot?: string;
|
|
135
|
+
/** Screenshot metadata with dimensions and format */
|
|
136
|
+
screenshotMetadata?: ScreenshotResult;
|
|
137
|
+
scrapedAt: string;
|
|
138
|
+
}
|
|
139
|
+
export interface AIExtraction {
|
|
140
|
+
summary?: string;
|
|
141
|
+
entities?: Entity[];
|
|
142
|
+
sentiment?: "positive" | "negative" | "neutral";
|
|
143
|
+
topics?: string[];
|
|
144
|
+
raw?: Record<string, unknown>;
|
|
145
|
+
}
|
|
146
|
+
export interface Entity {
|
|
147
|
+
type: "person" | "organization" | "location" | "product" | "other";
|
|
148
|
+
value: string;
|
|
149
|
+
confidence: number;
|
|
150
|
+
}
|
|
151
|
+
//# sourceMappingURL=scrape.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scrape.types.d.ts","sourceRoot":"","sources":["../../../../../shared/src/types/scrape.types.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,MAAM,WAAW,iBAAiB;IAChC,gCAAgC;IAChC,OAAO,EAAE,OAAO,CAAC;IACjB,qEAAqE;IACrE,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,+CAA+C;IAC/C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,+CAA+C;IAC/C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,kCAAkC;IAClC,MAAM,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,MAAM,CAAC;IACjC,4CAA4C;IAC5C,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,sCAAsC;AACtC,MAAM,WAAW,gBAAgB;IAC/B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,UAAU,GAAG,SAAS,GAAG,OAAO,CAAC;IACnE,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;CACpB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scrape.types.js","sourceRoot":"","sources":["../../../../../shared/src/types/scrape.types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare function now(): string;
|
|
2
|
+
export declare function timestamp(): number;
|
|
3
|
+
export declare function formatDuration(ms: number): string;
|
|
4
|
+
export declare function startOfMonth(date?: Date): Date;
|
|
5
|
+
export declare function endOfMonth(date?: Date): Date;
|
|
6
|
+
export declare function isExpired(expiresAt: string | Date): boolean;
|
|
7
|
+
//# sourceMappingURL=date.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date.d.ts","sourceRoot":"","sources":["../../../../../shared/src/utils/date.ts"],"names":[],"mappings":"AAAA,wBAAgB,GAAG,IAAI,MAAM,CAE5B;AAED,wBAAgB,SAAS,IAAI,MAAM,CAElC;AAED,wBAAgB,cAAc,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAKjD;AAED,wBAAgB,YAAY,CAAC,IAAI,GAAE,IAAiB,GAAG,IAAI,CAE1D;AAED,wBAAgB,UAAU,CAAC,IAAI,GAAE,IAAiB,GAAG,IAAI,CAExD;AAED,wBAAgB,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAE3D"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export function now() {
|
|
2
|
+
return new Date().toISOString();
|
|
3
|
+
}
|
|
4
|
+
export function timestamp() {
|
|
5
|
+
return Date.now();
|
|
6
|
+
}
|
|
7
|
+
export function formatDuration(ms) {
|
|
8
|
+
if (ms < 1000)
|
|
9
|
+
return `${ms}ms`;
|
|
10
|
+
if (ms < 60000)
|
|
11
|
+
return `${(ms / 1000).toFixed(1)}s`;
|
|
12
|
+
if (ms < 3600000)
|
|
13
|
+
return `${Math.floor(ms / 60000)}m ${Math.floor((ms % 60000) / 1000)}s`;
|
|
14
|
+
return `${Math.floor(ms / 3600000)}h ${Math.floor((ms % 3600000) / 60000)}m`;
|
|
15
|
+
}
|
|
16
|
+
export function startOfMonth(date = new Date()) {
|
|
17
|
+
return new Date(date.getFullYear(), date.getMonth(), 1);
|
|
18
|
+
}
|
|
19
|
+
export function endOfMonth(date = new Date()) {
|
|
20
|
+
return new Date(date.getFullYear(), date.getMonth() + 1, 0, 23, 59, 59, 999);
|
|
21
|
+
}
|
|
22
|
+
export function isExpired(expiresAt) {
|
|
23
|
+
return new Date(expiresAt) < new Date();
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=date.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date.js","sourceRoot":"","sources":["../../../../../shared/src/utils/date.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,GAAG;IACjB,OAAO,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;AAClC,CAAC;AAED,MAAM,UAAU,SAAS;IACvB,OAAO,IAAI,CAAC,GAAG,EAAE,CAAC;AACpB,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,EAAU;IACvC,IAAI,EAAE,GAAG,IAAI;QAAE,OAAO,GAAG,EAAE,IAAI,CAAC;IAChC,IAAI,EAAE,GAAG,KAAK;QAAE,OAAO,GAAG,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC;IACpD,IAAI,EAAE,GAAG,OAAO;QAAE,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,KAAK,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,KAAK,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC;IAC1F,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,OAAO,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,OAAO,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC;AAC/E,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,OAAa,IAAI,IAAI,EAAE;IAClD,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,IAAI,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC;AAC1D,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,OAAa,IAAI,IAAI,EAAE;IAChD,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,CAAC,CAAC;AAC/E,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,SAAwB;IAChD,OAAO,IAAI,IAAI,CAAC,SAAS,CAAC,GAAG,IAAI,IAAI,EAAE,CAAC;AAC1C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hash.d.ts","sourceRoot":"","sources":["../../../../../shared/src/utils/hash.ts"],"names":[],"mappings":"AAAA,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAQ9C;AAED,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAI3C;AAED,wBAAgB,UAAU,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAKlD"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export function simpleHash(str) {
|
|
2
|
+
let hash = 0;
|
|
3
|
+
for (let i = 0; i < str.length; i++) {
|
|
4
|
+
const char = str.charCodeAt(i);
|
|
5
|
+
hash = (hash << 5) - hash + char;
|
|
6
|
+
hash = hash & hash; // Convert to 32bit integer
|
|
7
|
+
}
|
|
8
|
+
return Math.abs(hash).toString(36);
|
|
9
|
+
}
|
|
10
|
+
export function urlHash(url) {
|
|
11
|
+
// Create a consistent hash for URL deduplication
|
|
12
|
+
const normalized = url.toLowerCase().replace(/\/$/, "");
|
|
13
|
+
return simpleHash(normalized);
|
|
14
|
+
}
|
|
15
|
+
export function generateId(prefix) {
|
|
16
|
+
const random = Math.random().toString(36).substring(2, 15);
|
|
17
|
+
const time = Date.now().toString(36);
|
|
18
|
+
const id = `${time}${random}`;
|
|
19
|
+
return prefix ? `${prefix}_${id}` : id;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=hash.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hash.js","sourceRoot":"","sources":["../../../../../shared/src/utils/hash.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,UAAU,CAAC,GAAW;IACpC,IAAI,IAAI,GAAG,CAAC,CAAC;IACb,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACpC,MAAM,IAAI,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QAC/B,IAAI,GAAG,CAAC,IAAI,IAAI,CAAC,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;QACjC,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC,2BAA2B;IACjD,CAAC;IACD,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;AACrC,CAAC;AAED,MAAM,UAAU,OAAO,CAAC,GAAW;IACjC,iDAAiD;IACjD,MAAM,UAAU,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IACxD,OAAO,UAAU,CAAC,UAAU,CAAC,CAAC;AAChC,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,MAAe;IACxC,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAC3D,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IACrC,MAAM,EAAE,GAAG,GAAG,IAAI,GAAG,MAAM,EAAE,CAAC;IAC9B,OAAO,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;AACzC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../shared/src/utils/index.ts"],"names":[],"mappings":"AACA,cAAc,OAAO,CAAC;AACtB,cAAc,iBAAiB,CAAC;AAChC,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../shared/src/utils/index.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB,cAAc,OAAO,CAAC;AACtB,cAAc,iBAAiB,CAAC;AAChC,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Professional structured logger for DealCrawl
|
|
3
|
+
* - Environment-aware (verbose in dev, minimal in prod)
|
|
4
|
+
* - Structured JSON output in production
|
|
5
|
+
* - Colored console output in development
|
|
6
|
+
* - Correlation ID support for request tracing
|
|
7
|
+
*/
|
|
8
|
+
export type LogLevel = "debug" | "info" | "warn" | "error";
|
|
9
|
+
export interface LogContext {
|
|
10
|
+
/** Correlation/request ID for tracing */
|
|
11
|
+
requestId?: string;
|
|
12
|
+
/** Job ID for worker logs */
|
|
13
|
+
jobId?: string;
|
|
14
|
+
/** Client ID */
|
|
15
|
+
clientId?: string;
|
|
16
|
+
/** Operation being performed */
|
|
17
|
+
operation?: string;
|
|
18
|
+
/** Duration in ms */
|
|
19
|
+
durationMs?: number;
|
|
20
|
+
/** Any additional metadata */
|
|
21
|
+
[key: string]: unknown;
|
|
22
|
+
}
|
|
23
|
+
declare class Logger {
|
|
24
|
+
private service;
|
|
25
|
+
private defaultContext;
|
|
26
|
+
constructor(service: string, defaultContext?: LogContext);
|
|
27
|
+
/**
|
|
28
|
+
* Create a child logger with additional default context
|
|
29
|
+
*/
|
|
30
|
+
child(context: LogContext): Logger;
|
|
31
|
+
/**
|
|
32
|
+
* Create a logger for a specific request/job
|
|
33
|
+
*/
|
|
34
|
+
forRequest(requestId: string): Logger;
|
|
35
|
+
forJob(jobId: string, clientId?: string): Logger;
|
|
36
|
+
private log;
|
|
37
|
+
private logDev;
|
|
38
|
+
private logProd;
|
|
39
|
+
debug(message: string, context?: LogContext): void;
|
|
40
|
+
info(message: string, context?: LogContext): void;
|
|
41
|
+
warn(message: string, context?: LogContext, error?: Error): void;
|
|
42
|
+
error(message: string, error?: Error, context?: LogContext): void;
|
|
43
|
+
/**
|
|
44
|
+
* Log the start of an operation (returns a function to log completion with duration)
|
|
45
|
+
*/
|
|
46
|
+
startOperation(operation: string, context?: LogContext): () => void;
|
|
47
|
+
/**
|
|
48
|
+
* Measure and log an async operation
|
|
49
|
+
*/
|
|
50
|
+
measure<T>(operation: string, fn: () => Promise<T>, context?: LogContext): Promise<T>;
|
|
51
|
+
/**
|
|
52
|
+
* Log HTTP request (for API middleware)
|
|
53
|
+
*/
|
|
54
|
+
request(method: string, path: string, statusCode: number, durationMs: number, context?: LogContext): void;
|
|
55
|
+
/**
|
|
56
|
+
* Log job progress
|
|
57
|
+
*/
|
|
58
|
+
jobProgress(progress: number, step: string, context?: LogContext): void;
|
|
59
|
+
}
|
|
60
|
+
export declare const apiLogger: Logger;
|
|
61
|
+
export declare const workerLogger: Logger;
|
|
62
|
+
export declare const coreLogger: Logger;
|
|
63
|
+
export declare const aiLogger: Logger;
|
|
64
|
+
export declare function createLogger(service: string, defaultContext?: LogContext): Logger;
|
|
65
|
+
export { Logger };
|
|
66
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../../../shared/src/utils/logger.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAE3D,MAAM,WAAW,UAAU;IACzB,yCAAyC;IACzC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,6BAA6B;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gBAAgB;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gCAAgC;IAChC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,qBAAqB;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,8BAA8B;IAC9B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAgJD,cAAM,MAAM;IACV,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,cAAc,CAAa;gBAEvB,OAAO,EAAE,MAAM,EAAE,cAAc,GAAE,UAAe;IAK5D;;OAEG;IACH,KAAK,CAAC,OAAO,EAAE,UAAU,GAAG,MAAM;IAIlC;;OAEG;IACH,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM;IAIrC,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM;IAIhD,OAAO,CAAC,GAAG;IA0BX,OAAO,CAAC,MAAM;IA2Bd,OAAO,CAAC,OAAO;IAYf,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,UAAU,GAAG,IAAI;IAIlD,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,UAAU,GAAG,IAAI;IAIjD,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,UAAU,EAAE,KAAK,CAAC,EAAE,KAAK,GAAG,IAAI;IAIhE,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,EAAE,UAAU,GAAG,IAAI;IAMjE;;OAEG;IACH,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,UAAU,GAAG,MAAM,IAAI;IAcnE;;OAEG;IACG,OAAO,CAAC,CAAC,EACb,SAAS,EAAE,MAAM,EACjB,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACpB,OAAO,CAAC,EAAE,UAAU,GACnB,OAAO,CAAC,CAAC,CAAC;IAwBb;;OAEG;IACH,OAAO,CACL,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,UAAU,GACnB,IAAI;IAUP;;OAEG;IACH,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,UAAU,GAAG,IAAI;CAMxE;AAGD,eAAO,MAAM,SAAS,QAAoB,CAAC;AAC3C,eAAO,MAAM,YAAY,QAAuB,CAAC;AACjD,eAAO,MAAM,UAAU,QAAqB,CAAC;AAC7C,eAAO,MAAM,QAAQ,QAAmB,CAAC;AAGzC,wBAAgB,YAAY,CAC1B,OAAO,EAAE,MAAM,EACf,cAAc,CAAC,EAAE,UAAU,GAC1B,MAAM,CAER;AAGD,OAAO,EAAE,MAAM,EAAE,CAAC"}
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Professional structured logger for DealCrawl
|
|
3
|
+
* - Environment-aware (verbose in dev, minimal in prod)
|
|
4
|
+
* - Structured JSON output in production
|
|
5
|
+
* - Colored console output in development
|
|
6
|
+
* - Correlation ID support for request tracing
|
|
7
|
+
*/
|
|
8
|
+
// ANSI color codes for terminal
|
|
9
|
+
const colors = {
|
|
10
|
+
reset: "\x1b[0m",
|
|
11
|
+
bright: "\x1b[1m",
|
|
12
|
+
dim: "\x1b[2m",
|
|
13
|
+
// Foreground
|
|
14
|
+
red: "\x1b[31m",
|
|
15
|
+
green: "\x1b[32m",
|
|
16
|
+
yellow: "\x1b[33m",
|
|
17
|
+
blue: "\x1b[34m",
|
|
18
|
+
magenta: "\x1b[35m",
|
|
19
|
+
cyan: "\x1b[36m",
|
|
20
|
+
white: "\x1b[37m",
|
|
21
|
+
gray: "\x1b[90m",
|
|
22
|
+
// Background
|
|
23
|
+
bgRed: "\x1b[41m",
|
|
24
|
+
bgYellow: "\x1b[43m",
|
|
25
|
+
};
|
|
26
|
+
const levelColors = {
|
|
27
|
+
debug: colors.gray,
|
|
28
|
+
info: colors.cyan,
|
|
29
|
+
warn: colors.yellow,
|
|
30
|
+
error: colors.red,
|
|
31
|
+
};
|
|
32
|
+
const levelIcons = {
|
|
33
|
+
debug: "🔍",
|
|
34
|
+
info: "ℹ️ ",
|
|
35
|
+
warn: "⚠️ ",
|
|
36
|
+
error: "❌",
|
|
37
|
+
};
|
|
38
|
+
// Log level priority (lower = more verbose)
|
|
39
|
+
const levelPriority = {
|
|
40
|
+
debug: 0,
|
|
41
|
+
info: 1,
|
|
42
|
+
warn: 2,
|
|
43
|
+
error: 3,
|
|
44
|
+
};
|
|
45
|
+
function getMinLevel() {
|
|
46
|
+
const env = process.env.NODE_ENV || "development";
|
|
47
|
+
const logLevel = process.env.LOG_LEVEL;
|
|
48
|
+
if (logLevel && levelPriority[logLevel] !== undefined) {
|
|
49
|
+
return logLevel;
|
|
50
|
+
}
|
|
51
|
+
// Default: debug in dev, info in prod
|
|
52
|
+
return env === "production" ? "info" : "debug";
|
|
53
|
+
}
|
|
54
|
+
function shouldLog(level) {
|
|
55
|
+
const minLevel = getMinLevel();
|
|
56
|
+
return levelPriority[level] >= levelPriority[minLevel];
|
|
57
|
+
}
|
|
58
|
+
function isDev() {
|
|
59
|
+
return process.env.NODE_ENV !== "production";
|
|
60
|
+
}
|
|
61
|
+
function formatTimestamp() {
|
|
62
|
+
const now = new Date();
|
|
63
|
+
if (isDev()) {
|
|
64
|
+
// Shorter format for dev: HH:MM:SS.mmm
|
|
65
|
+
return now.toISOString().slice(11, 23);
|
|
66
|
+
}
|
|
67
|
+
return now.toISOString();
|
|
68
|
+
}
|
|
69
|
+
function formatContextForDev(context) {
|
|
70
|
+
if (!context || Object.keys(context).length === 0)
|
|
71
|
+
return "";
|
|
72
|
+
const parts = [];
|
|
73
|
+
// Priority fields first
|
|
74
|
+
if (context.requestId)
|
|
75
|
+
parts.push(`${colors.magenta}req:${context.requestId.slice(0, 8)}${colors.reset}`);
|
|
76
|
+
if (context.jobId)
|
|
77
|
+
parts.push(`${colors.blue}job:${context.jobId.slice(0, 8)}${colors.reset}`);
|
|
78
|
+
if (context.clientId)
|
|
79
|
+
parts.push(`${colors.green}client:${context.clientId.slice(0, 8)}${colors.reset}`);
|
|
80
|
+
if (context.operation)
|
|
81
|
+
parts.push(`${colors.cyan}op:${context.operation}${colors.reset}`);
|
|
82
|
+
if (context.durationMs !== undefined)
|
|
83
|
+
parts.push(`${colors.yellow}${context.durationMs}ms${colors.reset}`);
|
|
84
|
+
// Other fields
|
|
85
|
+
const skipFields = [
|
|
86
|
+
"requestId",
|
|
87
|
+
"jobId",
|
|
88
|
+
"clientId",
|
|
89
|
+
"operation",
|
|
90
|
+
"durationMs",
|
|
91
|
+
];
|
|
92
|
+
const otherFields = Object.entries(context)
|
|
93
|
+
.filter(([key]) => !skipFields.includes(key))
|
|
94
|
+
.map(([key, value]) => {
|
|
95
|
+
const displayValue = typeof value === "object" ? JSON.stringify(value) : String(value);
|
|
96
|
+
return `${colors.gray}${key}=${displayValue}${colors.reset}`;
|
|
97
|
+
});
|
|
98
|
+
parts.push(...otherFields);
|
|
99
|
+
return parts.length > 0
|
|
100
|
+
? ` ${colors.dim}[${parts.join(" ")}]${colors.reset}`
|
|
101
|
+
: "";
|
|
102
|
+
}
|
|
103
|
+
function formatError(error) {
|
|
104
|
+
return {
|
|
105
|
+
message: error.message,
|
|
106
|
+
stack: isDev() ? error.stack : undefined,
|
|
107
|
+
code: error.code,
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
class Logger {
|
|
111
|
+
service;
|
|
112
|
+
defaultContext;
|
|
113
|
+
constructor(service, defaultContext = {}) {
|
|
114
|
+
this.service = service;
|
|
115
|
+
this.defaultContext = defaultContext;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Create a child logger with additional default context
|
|
119
|
+
*/
|
|
120
|
+
child(context) {
|
|
121
|
+
return new Logger(this.service, { ...this.defaultContext, ...context });
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Create a logger for a specific request/job
|
|
125
|
+
*/
|
|
126
|
+
forRequest(requestId) {
|
|
127
|
+
return this.child({ requestId });
|
|
128
|
+
}
|
|
129
|
+
forJob(jobId, clientId) {
|
|
130
|
+
return this.child({ jobId, clientId });
|
|
131
|
+
}
|
|
132
|
+
log(level, message, context, error) {
|
|
133
|
+
if (!shouldLog(level))
|
|
134
|
+
return;
|
|
135
|
+
const mergedContext = { ...this.defaultContext, ...context };
|
|
136
|
+
const entry = {
|
|
137
|
+
timestamp: formatTimestamp(),
|
|
138
|
+
level,
|
|
139
|
+
service: this.service,
|
|
140
|
+
message,
|
|
141
|
+
context: Object.keys(mergedContext).length > 0 ? mergedContext : undefined,
|
|
142
|
+
error: error ? formatError(error) : undefined,
|
|
143
|
+
};
|
|
144
|
+
if (isDev()) {
|
|
145
|
+
this.logDev(entry);
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
this.logProd(entry);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
logDev(entry) {
|
|
152
|
+
const color = levelColors[entry.level];
|
|
153
|
+
const icon = levelIcons[entry.level];
|
|
154
|
+
const contextStr = formatContextForDev(entry.context);
|
|
155
|
+
const prefix = `${colors.dim}${entry.timestamp}${colors.reset} ${icon} ${color}${entry.level.toUpperCase().padEnd(5)}${colors.reset}`;
|
|
156
|
+
const serviceTag = `${colors.bright}[${this.service}]${colors.reset}`;
|
|
157
|
+
let output = `${prefix} ${serviceTag} ${entry.message}${contextStr}`;
|
|
158
|
+
if (entry.error) {
|
|
159
|
+
output += `\n${colors.red} └─ Error: ${entry.error.message}${colors.reset}`;
|
|
160
|
+
if (entry.error.stack) {
|
|
161
|
+
const stackLines = entry.error.stack.split("\n").slice(1, 4);
|
|
162
|
+
output += `\n${colors.dim}${stackLines.map((l) => " " + l.trim()).join("\n")}${colors.reset}`;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
const logFn = entry.level === "error"
|
|
166
|
+
? console.error
|
|
167
|
+
: entry.level === "warn"
|
|
168
|
+
? console.warn
|
|
169
|
+
: console.log;
|
|
170
|
+
logFn(output);
|
|
171
|
+
}
|
|
172
|
+
logProd(entry) {
|
|
173
|
+
// Structured JSON for production (easy to parse by log aggregators)
|
|
174
|
+
const logFn = entry.level === "error"
|
|
175
|
+
? console.error
|
|
176
|
+
: entry.level === "warn"
|
|
177
|
+
? console.warn
|
|
178
|
+
: console.log;
|
|
179
|
+
logFn(JSON.stringify(entry));
|
|
180
|
+
}
|
|
181
|
+
// Log level methods
|
|
182
|
+
debug(message, context) {
|
|
183
|
+
this.log("debug", message, context);
|
|
184
|
+
}
|
|
185
|
+
info(message, context) {
|
|
186
|
+
this.log("info", message, context);
|
|
187
|
+
}
|
|
188
|
+
warn(message, context, error) {
|
|
189
|
+
this.log("warn", message, context, error);
|
|
190
|
+
}
|
|
191
|
+
error(message, error, context) {
|
|
192
|
+
this.log("error", message, context, error);
|
|
193
|
+
}
|
|
194
|
+
// Convenience methods
|
|
195
|
+
/**
|
|
196
|
+
* Log the start of an operation (returns a function to log completion with duration)
|
|
197
|
+
*/
|
|
198
|
+
startOperation(operation, context) {
|
|
199
|
+
const startTime = Date.now();
|
|
200
|
+
this.debug(`Starting ${operation}`, { ...context, operation });
|
|
201
|
+
return () => {
|
|
202
|
+
const durationMs = Date.now() - startTime;
|
|
203
|
+
this.info(`Completed ${operation}`, {
|
|
204
|
+
...context,
|
|
205
|
+
operation,
|
|
206
|
+
durationMs,
|
|
207
|
+
});
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Measure and log an async operation
|
|
212
|
+
*/
|
|
213
|
+
async measure(operation, fn, context) {
|
|
214
|
+
const startTime = Date.now();
|
|
215
|
+
this.debug(`Starting ${operation}`, { ...context, operation });
|
|
216
|
+
try {
|
|
217
|
+
const result = await fn();
|
|
218
|
+
const durationMs = Date.now() - startTime;
|
|
219
|
+
this.info(`Completed ${operation}`, {
|
|
220
|
+
...context,
|
|
221
|
+
operation,
|
|
222
|
+
durationMs,
|
|
223
|
+
});
|
|
224
|
+
return result;
|
|
225
|
+
}
|
|
226
|
+
catch (error) {
|
|
227
|
+
const durationMs = Date.now() - startTime;
|
|
228
|
+
this.error(`Failed ${operation}`, error, {
|
|
229
|
+
...context,
|
|
230
|
+
operation,
|
|
231
|
+
durationMs,
|
|
232
|
+
});
|
|
233
|
+
throw error;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Log HTTP request (for API middleware)
|
|
238
|
+
*/
|
|
239
|
+
request(method, path, statusCode, durationMs, context) {
|
|
240
|
+
const level = statusCode >= 500 ? "error" : statusCode >= 400 ? "warn" : "info";
|
|
241
|
+
this.log(level, `${method} ${path} ${statusCode}`, {
|
|
242
|
+
...context,
|
|
243
|
+
durationMs,
|
|
244
|
+
statusCode,
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Log job progress
|
|
249
|
+
*/
|
|
250
|
+
jobProgress(progress, step, context) {
|
|
251
|
+
this.debug(`Job progress: ${progress}% - ${step}`, {
|
|
252
|
+
...context,
|
|
253
|
+
progress,
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
// Pre-configured loggers for each service
|
|
258
|
+
export const apiLogger = new Logger("api");
|
|
259
|
+
export const workerLogger = new Logger("worker");
|
|
260
|
+
export const coreLogger = new Logger("core");
|
|
261
|
+
export const aiLogger = new Logger("ai");
|
|
262
|
+
// Factory function for custom loggers
|
|
263
|
+
export function createLogger(service, defaultContext) {
|
|
264
|
+
return new Logger(service, defaultContext);
|
|
265
|
+
}
|
|
266
|
+
// Export the class for type usage
|
|
267
|
+
export { Logger };
|
|
268
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../../../../shared/src/utils/logger.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAgCH,gCAAgC;AAChC,MAAM,MAAM,GAAG;IACb,KAAK,EAAE,SAAS;IAChB,MAAM,EAAE,SAAS;IACjB,GAAG,EAAE,SAAS;IAEd,aAAa;IACb,GAAG,EAAE,UAAU;IACf,KAAK,EAAE,UAAU;IACjB,MAAM,EAAE,UAAU;IAClB,IAAI,EAAE,UAAU;IAChB,OAAO,EAAE,UAAU;IACnB,IAAI,EAAE,UAAU;IAChB,KAAK,EAAE,UAAU;IACjB,IAAI,EAAE,UAAU;IAEhB,aAAa;IACb,KAAK,EAAE,UAAU;IACjB,QAAQ,EAAE,UAAU;CACZ,CAAC;AAEX,MAAM,WAAW,GAA6B;IAC5C,KAAK,EAAE,MAAM,CAAC,IAAI;IAClB,IAAI,EAAE,MAAM,CAAC,IAAI;IACjB,IAAI,EAAE,MAAM,CAAC,MAAM;IACnB,KAAK,EAAE,MAAM,CAAC,GAAG;CAClB,CAAC;AAEF,MAAM,UAAU,GAA6B;IAC3C,KAAK,EAAE,IAAI;IACX,IAAI,EAAE,KAAK;IACX,IAAI,EAAE,KAAK;IAC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C,QAAgB,EAAE,IAAY,EAAE,OAAoB;QAC9D,IAAI,CAAC,KAAK,CAAC,iBAAiB,QAAQ,OAAO,IAAI,EAAE,EAAE;YACjD,GAAG,OAAO;YACV,QAAQ;SACT,CAAC,CAAC;IACL,CAAC;CACF;AAED,0CAA0C;AAC1C,MAAM,CAAC,MAAM,SAAS,GAAG,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC;AAC3C,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,MAAM,CAAC,QAAQ,CAAC,CAAC;AACjD,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,CAAC;AAC7C,MAAM,CAAC,MAAM,QAAQ,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC;AAEzC,sCAAsC;AACtC,MAAM,UAAU,YAAY,CAC1B,OAAe,EACf,cAA2B;IAE3B,OAAO,IAAI,MAAM,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;AAC7C,CAAC;AAED,kCAAkC;AAClC,OAAO,EAAE,MAAM,EAAE,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface RetryOptions {
|
|
2
|
+
maxRetries?: number;
|
|
3
|
+
initialDelayMs?: number;
|
|
4
|
+
maxDelayMs?: number;
|
|
5
|
+
backoffMultiplier?: number;
|
|
6
|
+
shouldRetry?: (error: Error, attempt: number) => boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare function retry<T>(fn: () => Promise<T>, options?: RetryOptions): Promise<T>;
|
|
9
|
+
export declare function sleep(ms: number): Promise<void>;
|
|
10
|
+
export declare function withTimeout<T>(promise: Promise<T>, timeoutMs: number): Promise<T>;
|
|
11
|
+
//# sourceMappingURL=retry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retry.d.ts","sourceRoot":"","sources":["../../../../../shared/src/utils/retry.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IAC3B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC;CAC1D;AAUD,wBAAsB,KAAK,CAAC,CAAC,EAC3B,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACpB,OAAO,CAAC,EAAE,YAAY,GACrB,OAAO,CAAC,CAAC,CAAC,CAqBZ;AAED,wBAAgB,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE/C;AAED,wBAAsB,WAAW,CAAC,CAAC,EACjC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EACnB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,CAAC,CAAC,CAMZ"}
|