@ultimat3/scraping 9.0.0 → 11.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/package.json +5 -5
- package/src/cdp-target.ts +15 -1
- package/src/errors.ts +1 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ultimat3/scraping",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "11.0.0",
|
|
4
4
|
"description": "Browser automation as a job: scrape() returns a JobHandle",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -30,9 +30,9 @@
|
|
|
30
30
|
"test": "bun test"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@ultimat3/core": "
|
|
34
|
-
"@ultimat3/jobs": "
|
|
35
|
-
"@ultimat3/schema": "
|
|
36
|
-
"@ultimat3/storage": "
|
|
33
|
+
"@ultimat3/core": "11.0.0",
|
|
34
|
+
"@ultimat3/jobs": "11.0.0",
|
|
35
|
+
"@ultimat3/schema": "11.0.0",
|
|
36
|
+
"@ultimat3/storage": "11.0.0"
|
|
37
37
|
}
|
|
38
38
|
}
|
package/src/cdp-target.ts
CHANGED
|
@@ -79,6 +79,20 @@ const CONSOLE_LEVELS: Readonly<Record<string, ConsoleLine['level']>> = {
|
|
|
79
79
|
verbose: 'debug',
|
|
80
80
|
};
|
|
81
81
|
|
|
82
|
+
/**
|
|
83
|
+
* `Object.hasOwn`, never the read alone: the type word arrives off the WIRE, so
|
|
84
|
+
* `CONSOLE_LEVELS['__proto__']` answered `Object.prototype` and `['constructor']` the `Object`
|
|
85
|
+
* function — neither of which a `?? 'log'` fallback can rescue, because neither is `undefined`.
|
|
86
|
+
* `ConsoleLine.level` would then hold a value its own type says is one of five words, so the
|
|
87
|
+
* `level === 'error'` filter this ring exists for matched nothing and `JSON.stringify` dropped
|
|
88
|
+
* the field from a snapshot outright. Lowercasing is not the guard: `__proto__` and `constructor`
|
|
89
|
+
* are already lowercase. Same discriminator as `packages/flags/src/subject.ts`.
|
|
90
|
+
*/
|
|
91
|
+
const consoleLevel = (type: string): ConsoleLine['level'] => {
|
|
92
|
+
const word = type.toLowerCase();
|
|
93
|
+
return Object.hasOwn(CONSOLE_LEVELS, word) ? (CONSOLE_LEVELS[word] ?? 'log') : 'log';
|
|
94
|
+
};
|
|
95
|
+
|
|
82
96
|
/**
|
|
83
97
|
* Reads a string out of somebody else's event payload, calling an accessor THROUGH ITS OWNER.
|
|
84
98
|
*
|
|
@@ -184,7 +198,7 @@ async function arm(init: CdpTargetInit, sinks: CdpSinks): Promise<void> {
|
|
|
184
198
|
});
|
|
185
199
|
init.page.on('console', (payload) => {
|
|
186
200
|
console_.push({
|
|
187
|
-
level:
|
|
201
|
+
level: consoleLevel(readStringFrom(payload, 'type') ?? ''),
|
|
188
202
|
text: readStringFrom(payload, 'text') ?? '',
|
|
189
203
|
at: init.clock.now().getTime(),
|
|
190
204
|
});
|
package/src/errors.ts
CHANGED
|
@@ -4,12 +4,7 @@
|
|
|
4
4
|
// once, in this file, rather than re-decided by whichever `catch` saw it.
|
|
5
5
|
|
|
6
6
|
import type { ErrorRetry } from '@ultimat3/core';
|
|
7
|
-
import {
|
|
8
|
-
errorDocsUrl,
|
|
9
|
-
registerErrorCodes,
|
|
10
|
-
registerErrorRetry,
|
|
11
|
-
UltimateError,
|
|
12
|
-
} from '@ultimat3/core';
|
|
7
|
+
import { registerErrorCodes, registerErrorRetry, UltimateError } from '@ultimat3/core';
|
|
13
8
|
|
|
14
9
|
/** Codes this package declares and owns. */
|
|
15
10
|
export const SCRAPE_OWNED_ERROR_CODES = [
|
|
@@ -184,7 +179,6 @@ export class ScrapeError extends UltimateError {
|
|
|
184
179
|
code: init.code,
|
|
185
180
|
cause: init.cause,
|
|
186
181
|
fix: init.fix,
|
|
187
|
-
docs: errorDocsUrl(init.code),
|
|
188
182
|
meta: init.meta,
|
|
189
183
|
...(init.retry === undefined ? {} : { retry: init.retry }),
|
|
190
184
|
});
|