@foldrun/core 24.9.0 → 24.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/ops-log.js +2 -2
- package/dist/src/providers.js +3 -3
- package/package.json +1 -1
- package/src/ops-log.ts +2 -2
- package/src/providers.ts +3 -3
package/dist/src/ops-log.js
CHANGED
|
@@ -178,7 +178,7 @@ const boundary = () => shared[BOUNDARY] ?? null;
|
|
|
178
178
|
export function opsBoundaryInstalled() {
|
|
179
179
|
return boundary() !== null;
|
|
180
180
|
}
|
|
181
|
-
function readable(
|
|
181
|
+
function readable(line, detail) {
|
|
182
182
|
const parts = Object.entries(line)
|
|
183
183
|
.filter(([k]) => k !== "ops" && k !== "level" && k !== "event")
|
|
184
184
|
.map(([k, v]) => `${k}=${Array.isArray(v) ? v.join(",") : String(v)}`);
|
|
@@ -192,7 +192,7 @@ function emit(level, line, detail) {
|
|
|
192
192
|
}
|
|
193
193
|
// No boundary: a laptop, a test, `next dev` — the reader is the person
|
|
194
194
|
// whose content it is, so the error's own words come along.
|
|
195
|
-
const text = readable(
|
|
195
|
+
const text = readable(line, detail);
|
|
196
196
|
if (level === "info")
|
|
197
197
|
console.log(text);
|
|
198
198
|
else if (level === "warn")
|
package/dist/src/providers.js
CHANGED
|
@@ -434,20 +434,20 @@ export function readBrowseSession(raw, key = "vendor_session") {
|
|
|
434
434
|
return { error: `${at} is a block — what the vendor's own session is asked for: proxy, captcha, stealth, region, timeout, keep, record, block, options.` };
|
|
435
435
|
}
|
|
436
436
|
const out = {};
|
|
437
|
-
const bool = (
|
|
437
|
+
const bool = (v) => (v === true || v === "true" ? true : v === false || v === "false" ? false : undefined);
|
|
438
438
|
for (const [k, v] of Object.entries(raw)) {
|
|
439
439
|
if (!SESSION_KEYS.includes(k))
|
|
440
440
|
return { error: `${at}.${k}: is not a session setting. They are ${SESSION_KEYS.join(", ")}.` };
|
|
441
441
|
if (v === undefined || v === null || v === "")
|
|
442
442
|
continue;
|
|
443
443
|
if (k === "captcha" || k === "stealth" || k === "record") {
|
|
444
|
-
const b = bool(
|
|
444
|
+
const b = bool(v);
|
|
445
445
|
if (b === undefined)
|
|
446
446
|
return { error: `${at}.${k} is true or false, not ${JSON.stringify(v)}.` };
|
|
447
447
|
out[k] = b;
|
|
448
448
|
}
|
|
449
449
|
else if (k === "proxy") {
|
|
450
|
-
const b = bool(
|
|
450
|
+
const b = bool(v);
|
|
451
451
|
if (b !== undefined) {
|
|
452
452
|
out.proxy = b;
|
|
453
453
|
continue;
|
package/package.json
CHANGED
package/src/ops-log.ts
CHANGED
|
@@ -198,7 +198,7 @@ export function opsBoundaryInstalled(): boolean {
|
|
|
198
198
|
return boundary() !== null;
|
|
199
199
|
}
|
|
200
200
|
|
|
201
|
-
function readable(
|
|
201
|
+
function readable(line: Record<string, unknown>, detail?: string): string {
|
|
202
202
|
const parts = Object.entries(line)
|
|
203
203
|
.filter(([k]) => k !== "ops" && k !== "level" && k !== "event")
|
|
204
204
|
.map(([k, v]) => `${k}=${Array.isArray(v) ? v.join(",") : String(v)}`);
|
|
@@ -213,7 +213,7 @@ function emit(level: OpsLevel, line: Record<string, unknown>, detail?: string):
|
|
|
213
213
|
}
|
|
214
214
|
// No boundary: a laptop, a test, `next dev` — the reader is the person
|
|
215
215
|
// whose content it is, so the error's own words come along.
|
|
216
|
-
const text = readable(
|
|
216
|
+
const text = readable(line, detail);
|
|
217
217
|
if (level === "info") console.log(text);
|
|
218
218
|
else if (level === "warn") console.warn(text);
|
|
219
219
|
else console.error(text);
|
package/src/providers.ts
CHANGED
|
@@ -778,16 +778,16 @@ export function readBrowseSession(raw: unknown, key: "vendor_session" | "session
|
|
|
778
778
|
return { error: `${at} is a block — what the vendor's own session is asked for: proxy, captcha, stealth, region, timeout, keep, record, block, options.` };
|
|
779
779
|
}
|
|
780
780
|
const out: BrowseSession = {};
|
|
781
|
-
const bool = (
|
|
781
|
+
const bool = (v: unknown) => (v === true || v === "true" ? true : v === false || v === "false" ? false : undefined);
|
|
782
782
|
for (const [k, v] of Object.entries(raw as Record<string, unknown>)) {
|
|
783
783
|
if (!(SESSION_KEYS as readonly string[]).includes(k)) return { error: `${at}.${k}: is not a session setting. They are ${SESSION_KEYS.join(", ")}.` };
|
|
784
784
|
if (v === undefined || v === null || v === "") continue;
|
|
785
785
|
if (k === "captcha" || k === "stealth" || k === "record") {
|
|
786
|
-
const b = bool(
|
|
786
|
+
const b = bool(v);
|
|
787
787
|
if (b === undefined) return { error: `${at}.${k} is true or false, not ${JSON.stringify(v)}.` };
|
|
788
788
|
out[k] = b;
|
|
789
789
|
} else if (k === "proxy") {
|
|
790
|
-
const b = bool(
|
|
790
|
+
const b = bool(v);
|
|
791
791
|
if (b !== undefined) { out.proxy = b; continue; }
|
|
792
792
|
if (typeof v !== "object" || Array.isArray(v)) return { error: `${at}.proxy is true, false, or a block: country, state, city — or own: a secret holding your proxy's URL.` };
|
|
793
793
|
const p: { country?: string; state?: string; city?: string; own?: string } = {};
|