@crawlee/core 4.0.0-beta.164 → 4.0.0-beta.166
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/configuration.d.ts +15 -15
- package/log.d.ts +8 -8
- package/log.js +42 -12
- package/package.json +12 -12
- package/validators.d.ts +2 -1
- package/validators.js +2 -1
package/configuration.d.ts
CHANGED
|
@@ -6,47 +6,47 @@ export interface ConfigField<T extends z.ZodType = z.ZodType> {
|
|
|
6
6
|
}
|
|
7
7
|
export declare function field<T extends z.ZodType>(schema: T, envVar?: string | string[]): ConfigField<T>;
|
|
8
8
|
/** Zod preprocessor treating `'0'` and `'false'` as falsy. */
|
|
9
|
-
export declare const coerceBoolean: z.ZodPreprocess<z.ZodBoolean>;
|
|
10
|
-
export declare const coerceNumber: z.ZodPreprocess<z.ZodNumber>;
|
|
9
|
+
export declare const coerceBoolean: z.ZodPreprocess<z.ZodBoolean, unknown>;
|
|
10
|
+
export declare const coerceNumber: z.ZodPreprocess<z.ZodNumber, unknown>;
|
|
11
11
|
export declare const crawleeConfigFields: {
|
|
12
12
|
/** @default 'default' */
|
|
13
13
|
defaultDatasetId: ConfigField<z.ZodDefault<z.ZodString>>;
|
|
14
14
|
/** @default true */
|
|
15
|
-
purgeOnStart: ConfigField<z.ZodDefault<z.ZodPreprocess<z.ZodBoolean>>>;
|
|
15
|
+
purgeOnStart: ConfigField<z.ZodDefault<z.ZodPreprocess<z.ZodBoolean, unknown>>>;
|
|
16
16
|
/** @default 'default' */
|
|
17
17
|
defaultKeyValueStoreId: ConfigField<z.ZodDefault<z.ZodString>>;
|
|
18
18
|
/** @default 'default' */
|
|
19
19
|
defaultRequestQueueId: ConfigField<z.ZodDefault<z.ZodString>>;
|
|
20
20
|
/** @default 0.95 */
|
|
21
|
-
maxUsedCpuRatio: ConfigField<z.ZodDefault<z.ZodPreprocess<z.ZodNumber>>>;
|
|
21
|
+
maxUsedCpuRatio: ConfigField<z.ZodDefault<z.ZodPreprocess<z.ZodNumber, unknown>>>;
|
|
22
22
|
/** @default 0.25 */
|
|
23
|
-
availableMemoryRatio: ConfigField<z.ZodDefault<z.ZodPreprocess<z.ZodNumber>>>;
|
|
24
|
-
memoryMbytes: ConfigField<z.ZodOptional<z.ZodPreprocess<z.ZodNumber>>>;
|
|
23
|
+
availableMemoryRatio: ConfigField<z.ZodDefault<z.ZodPreprocess<z.ZodNumber, unknown>>>;
|
|
24
|
+
memoryMbytes: ConfigField<z.ZodOptional<z.ZodPreprocess<z.ZodNumber, unknown>>>;
|
|
25
25
|
/** @default 60_000 */
|
|
26
|
-
persistStateIntervalMillis: ConfigField<z.ZodDefault<z.ZodPreprocess<z.ZodNumber>>>;
|
|
26
|
+
persistStateIntervalMillis: ConfigField<z.ZodDefault<z.ZodPreprocess<z.ZodNumber, unknown>>>;
|
|
27
27
|
/**
|
|
28
28
|
* Internal safety-net timeout for a single request, in milliseconds. When unset the crawler derives it from
|
|
29
29
|
* the request handler timeout (twice it, and never below 5 minutes).
|
|
30
30
|
*/
|
|
31
|
-
internalTimeoutMillis: ConfigField<z.ZodOptional<z.ZodPreprocess<z.ZodNumber>>>;
|
|
31
|
+
internalTimeoutMillis: ConfigField<z.ZodOptional<z.ZodPreprocess<z.ZodNumber, unknown>>>;
|
|
32
32
|
/** @default 1_000 */
|
|
33
|
-
systemInfoIntervalMillis: ConfigField<z.ZodDefault<z.ZodPreprocess<z.ZodNumber>>>;
|
|
33
|
+
systemInfoIntervalMillis: ConfigField<z.ZodDefault<z.ZodPreprocess<z.ZodNumber, unknown>>>;
|
|
34
34
|
/** @default 'INPUT' */
|
|
35
35
|
inputKey: ConfigField<z.ZodDefault<z.ZodString>>;
|
|
36
36
|
/** @default true */
|
|
37
|
-
headless: ConfigField<z.ZodDefault<z.ZodPreprocess<z.ZodBoolean>>>;
|
|
37
|
+
headless: ConfigField<z.ZodDefault<z.ZodPreprocess<z.ZodBoolean, unknown>>>;
|
|
38
38
|
/** @default false */
|
|
39
|
-
xvfb: ConfigField<z.ZodDefault<z.ZodPreprocess<z.ZodBoolean>>>;
|
|
39
|
+
xvfb: ConfigField<z.ZodDefault<z.ZodPreprocess<z.ZodBoolean, unknown>>>;
|
|
40
40
|
chromeExecutablePath: ConfigField<z.ZodOptional<z.ZodString>>;
|
|
41
41
|
defaultBrowserPath: ConfigField<z.ZodOptional<z.ZodString>>;
|
|
42
42
|
/** @default false */
|
|
43
|
-
disableBrowserSandbox: ConfigField<z.ZodDefault<z.ZodPreprocess<z.ZodBoolean>>>;
|
|
44
|
-
logLevel: ConfigField<z.ZodOptional<z.ZodPreprocess<z.ZodEnum<typeof LogLevel
|
|
43
|
+
disableBrowserSandbox: ConfigField<z.ZodDefault<z.ZodPreprocess<z.ZodBoolean, unknown>>>;
|
|
44
|
+
logLevel: ConfigField<z.ZodOptional<z.ZodPreprocess<z.ZodEnum<typeof LogLevel>, unknown>>>;
|
|
45
45
|
/** @default true */
|
|
46
|
-
persistStorage: ConfigField<z.ZodDefault<z.ZodPreprocess<z.ZodBoolean>>>;
|
|
46
|
+
persistStorage: ConfigField<z.ZodDefault<z.ZodPreprocess<z.ZodBoolean, unknown>>>;
|
|
47
47
|
/** @default './storage' */
|
|
48
48
|
storageDir: ConfigField<z.ZodDefault<z.ZodString>>;
|
|
49
|
-
containerized: ConfigField<z.ZodOptional<z.ZodPreprocess<z.ZodBoolean>>>;
|
|
49
|
+
containerized: ConfigField<z.ZodOptional<z.ZodPreprocess<z.ZodBoolean, unknown>>>;
|
|
50
50
|
};
|
|
51
51
|
export type FieldsInput<F extends Record<string, ConfigField>> = {
|
|
52
52
|
[K in keyof F]?: z.output<F[K]['schema']>;
|
package/log.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { CrawleeLogger, CrawleeLoggerOptions } from '@crawlee/types';
|
|
1
|
+
import type { CrawleeLogger, CrawleeLoggerOptions, LogOptions } from '@crawlee/types';
|
|
2
2
|
import type { LoggerOptions } from '@apify/log';
|
|
3
3
|
import log, { Log, Logger, LoggerJson, LoggerText, LogLevel } from '@apify/log';
|
|
4
|
-
export type { CrawleeLogger, CrawleeLoggerOptions };
|
|
4
|
+
export type { CrawleeLogger, CrawleeLoggerOptions, LogOptions };
|
|
5
5
|
/**
|
|
6
6
|
* Abstract base class for custom Crawlee logger implementations.
|
|
7
7
|
*
|
|
@@ -55,14 +55,14 @@ export declare abstract class BaseCrawleeLogger implements CrawleeLogger {
|
|
|
55
55
|
getOptions(): CrawleeLoggerOptions;
|
|
56
56
|
setOptions(options: Partial<CrawleeLoggerOptions>): void;
|
|
57
57
|
child(options: Partial<CrawleeLoggerOptions>): CrawleeLogger;
|
|
58
|
-
error(message: string, data?: Record<string, unknown
|
|
58
|
+
error(message: string, data?: Record<string, unknown>, options?: LogOptions): void;
|
|
59
59
|
exception(exception: Error, message: string, data?: Record<string, unknown>): void;
|
|
60
|
-
softFail(message: string, data?: Record<string, unknown
|
|
61
|
-
warning(message: string, data?: Record<string, unknown
|
|
60
|
+
softFail(message: string, data?: Record<string, unknown>, options?: LogOptions): void;
|
|
61
|
+
warning(message: string, data?: Record<string, unknown>, options?: LogOptions): void;
|
|
62
62
|
warningOnce(message: string): void;
|
|
63
|
-
info(message: string, data?: Record<string, unknown
|
|
64
|
-
debug(message: string, data?: Record<string, unknown
|
|
65
|
-
perf(message: string, data?: Record<string, unknown
|
|
63
|
+
info(message: string, data?: Record<string, unknown>, options?: LogOptions): void;
|
|
64
|
+
debug(message: string, data?: Record<string, unknown>, options?: LogOptions): void;
|
|
65
|
+
perf(message: string, data?: Record<string, unknown>, options?: LogOptions): void;
|
|
66
66
|
deprecated(message: string): void;
|
|
67
67
|
}
|
|
68
68
|
/**
|
package/log.js
CHANGED
|
@@ -33,7 +33,7 @@ export class BaseCrawleeLogger {
|
|
|
33
33
|
// Note: If wrapping logger in a Proxy, unbound methods calling #-fields throw TypeError
|
|
34
34
|
// unless bound to the target (see createLogProxy in adaptive-playwright-crawler.ts).
|
|
35
35
|
#options;
|
|
36
|
-
#
|
|
36
|
+
#loggedOnce = new Set();
|
|
37
37
|
constructor(options = {}) {
|
|
38
38
|
this.#options = options;
|
|
39
39
|
}
|
|
@@ -46,7 +46,27 @@ export class BaseCrawleeLogger {
|
|
|
46
46
|
child(options) {
|
|
47
47
|
return this.createChild(options);
|
|
48
48
|
}
|
|
49
|
-
|
|
49
|
+
/**
|
|
50
|
+
* Whether `once` suppresses this message. Keyed by level as well as text, so that a message logged once as
|
|
51
|
+
* `info` does not swallow the same text logged as a `warning`.
|
|
52
|
+
*
|
|
53
|
+
* Handled here rather than in {@link BaseCrawleeLogger.logWithLevel} so that every logger gets it, instead
|
|
54
|
+
* of each implementation having to dedupe for itself.
|
|
55
|
+
*/
|
|
56
|
+
#suppressedAsRepeat(level, message, options) {
|
|
57
|
+
if (!options?.once) {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
const key = `${level}:${message}`;
|
|
61
|
+
if (this.#loggedOnce.has(key)) {
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
this.#loggedOnce.add(key);
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
error(message, data, options) {
|
|
68
|
+
if (this.#suppressedAsRepeat(LogLevel.ERROR, message, options))
|
|
69
|
+
return;
|
|
50
70
|
this.logWithLevel(LogLevel.ERROR, message, data);
|
|
51
71
|
}
|
|
52
72
|
exception(exception, message, data) {
|
|
@@ -56,25 +76,35 @@ export class BaseCrawleeLogger {
|
|
|
56
76
|
exception,
|
|
57
77
|
});
|
|
58
78
|
}
|
|
59
|
-
softFail(message, data) {
|
|
79
|
+
softFail(message, data, options) {
|
|
80
|
+
if (this.#suppressedAsRepeat(LogLevel.SOFT_FAIL, message, options))
|
|
81
|
+
return;
|
|
60
82
|
this.logWithLevel(LogLevel.SOFT_FAIL, message, data);
|
|
61
83
|
}
|
|
62
|
-
warning(message, data) {
|
|
84
|
+
warning(message, data, options) {
|
|
85
|
+
if (this.#suppressedAsRepeat(LogLevel.WARNING, message, options))
|
|
86
|
+
return;
|
|
63
87
|
this.logWithLevel(LogLevel.WARNING, message, data);
|
|
64
88
|
}
|
|
65
89
|
warningOnce(message) {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
info(message, data) {
|
|
90
|
+
// Gates before delegating, so that a suppressed repeat is not even a `warning()` call.
|
|
91
|
+
if (this.#suppressedAsRepeat(LogLevel.WARNING, message, { once: true }))
|
|
92
|
+
return;
|
|
93
|
+
this.warning(message);
|
|
94
|
+
}
|
|
95
|
+
info(message, data, options) {
|
|
96
|
+
if (this.#suppressedAsRepeat(LogLevel.INFO, message, options))
|
|
97
|
+
return;
|
|
72
98
|
this.logWithLevel(LogLevel.INFO, message, data);
|
|
73
99
|
}
|
|
74
|
-
debug(message, data) {
|
|
100
|
+
debug(message, data, options) {
|
|
101
|
+
if (this.#suppressedAsRepeat(LogLevel.DEBUG, message, options))
|
|
102
|
+
return;
|
|
75
103
|
this.logWithLevel(LogLevel.DEBUG, message, data);
|
|
76
104
|
}
|
|
77
|
-
perf(message, data) {
|
|
105
|
+
perf(message, data, options) {
|
|
106
|
+
if (this.#suppressedAsRepeat(LogLevel.PERF, message, options))
|
|
107
|
+
return;
|
|
78
108
|
this.logWithLevel(LogLevel.PERF, `[PERF] ${message}`, data);
|
|
79
109
|
}
|
|
80
110
|
deprecated(message) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crawlee/core",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.166",
|
|
4
4
|
"description": "The scalable web crawling and scraping library for JavaScript/Node.js. Enables development of data extraction and web automation jobs (not only) with headless Chrome and Puppeteer.",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=22.0.0"
|
|
@@ -47,15 +47,15 @@
|
|
|
47
47
|
"access": "public"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@apify/consts": "^
|
|
51
|
-
"@apify/datastructures": "^
|
|
52
|
-
"@apify/log": "^
|
|
53
|
-
"@apify/timeout": "^0.
|
|
54
|
-
"@apify/utilities": "^
|
|
55
|
-
"@crawlee/fs-storage": "4.0.0-beta.
|
|
56
|
-
"@crawlee/http-client": "4.0.0-beta.
|
|
57
|
-
"@crawlee/types": "4.0.0-beta.
|
|
58
|
-
"@crawlee/utils": "4.0.0-beta.
|
|
50
|
+
"@apify/consts": "^3.0.1",
|
|
51
|
+
"@apify/datastructures": "^3.0.1",
|
|
52
|
+
"@apify/log": "^3.0.1",
|
|
53
|
+
"@apify/timeout": "^1.0.1",
|
|
54
|
+
"@apify/utilities": "^3.0.1",
|
|
55
|
+
"@crawlee/fs-storage": "4.0.0-beta.166",
|
|
56
|
+
"@crawlee/http-client": "4.0.0-beta.166",
|
|
57
|
+
"@crawlee/types": "4.0.0-beta.166",
|
|
58
|
+
"@crawlee/utils": "4.0.0-beta.166",
|
|
59
59
|
"@sapphire/async-queue": "^1.5.5",
|
|
60
60
|
"@standard-schema/spec": "^1.0.0",
|
|
61
61
|
"@vladfrangu/async_event_emitter": "^2.4.6",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"tough-cookie": "^6.0.0",
|
|
70
70
|
"tslib": "^2.8.1",
|
|
71
71
|
"type-fest": "^4.41.0",
|
|
72
|
-
"zod": "^4.4
|
|
72
|
+
"zod": "^4.5.4"
|
|
73
73
|
},
|
|
74
74
|
"lerna": {
|
|
75
75
|
"command": {
|
|
@@ -78,5 +78,5 @@
|
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
80
|
},
|
|
81
|
-
"gitHead": "
|
|
81
|
+
"gitHead": "5d34cf3b9da170f22cf5b346014ba44060dad827"
|
|
82
82
|
}
|
package/validators.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export { ArgumentValidationError
|
|
1
|
+
export { ArgumentValidationError } from '@crawlee/utils';
|
|
2
|
+
export { parseArgument } from '@crawlee/utils/internal';
|
|
2
3
|
export { schemas } from '@crawlee/utils/internal';
|
|
3
4
|
/** @internal */
|
|
4
5
|
export declare const validators: {
|
package/validators.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { schemas } from '@crawlee/utils/internal';
|
|
2
|
-
export { ArgumentValidationError
|
|
2
|
+
export { ArgumentValidationError } from '@crawlee/utils';
|
|
3
|
+
export { parseArgument } from '@crawlee/utils/internal';
|
|
3
4
|
export { schemas } from '@crawlee/utils/internal';
|
|
4
5
|
/** @internal */
|
|
5
6
|
export const validators = {
|