Skip to content

[SCR-383] Auto-Mode (mode=auto) node fields#4

Open
kostas-jakeliunas-sb wants to merge 1 commit into
masterfrom
SCR-383/auto-mode-support
Open

[SCR-383] Auto-Mode (mode=auto) node fields#4
kostas-jakeliunas-sb wants to merge 1 commit into
masterfrom
SCR-383/auto-mode-support

Conversation

@kostas-jakeliunas-sb

@kostas-jakeliunas-sb kostas-jakeliunas-sb commented Jun 30, 2026

Copy link
Copy Markdown

Merge order: part of the [SCR-383] Auto-Mode client rollout — merge once the server PR ScrapingBee/scrapingbee-API#1242 is merged + the flag is enabled.

tl;dr

Adds Mode (Auto) and Max Cost fields to the HTML API node so users can opt into server-side Auto-Mode (mode=auto), which escalates cheapest→expensive and charges only the winning config. Opt-in (neutral default), GET-only feature, with incompatible toggles auto-hidden. Build + lint green. Hold until the API ships mode=auto.

Summary

  • nodes/ScrapingBee/ScrapingBee.node.ts — two new fields added inside the htmlAPI "Additional Fields" collection (the only block whose keys are auto snake-cased into the request querystring — there is no request-building code to change):
    • modeoptions field, single option { name: 'Auto', value: 'auto' }, neutral empty default ('') so it's opt-in. Description carries the contract (GET-only cheapest-first escalation, charged only for the winning config, 0 on full failure, incompatible toggles hidden).
    • maxCosttype: 'number', typeOptions: { minValue: 1 }, displayOptions.show so it appears only when mode = auto. Description: "Max credits a request may cost. Omit for no cap. Requires Mode = Auto."
  • Mutual exclusivitydisplayOptions.hide (mode: ['auto']) added to renderJs, premiumProxy, stealthProxy, and transparentStatusCode (the four params the server 400s on when combined with mode=auto). All are siblings of mode within the same collection, so plain-name sibling references resolve at render time. Reverse hiding wasn't needed: while mode=auto is selected those toggles are hidden, so a server-rejected combo can't be built.
  • package.json — version bumped 0.1.60.1.7. No CHANGELOG file exists in the repo, so none was added.

camel→snake key verification (the critical bit)

The node has no arbitrary key/value entry; for the HTML API it iterates additionalFields and snake-cases each key via:

const snakeKey = key.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);

I verified this transforms maxCostmax_cost (each uppercase letter → _ + lowercase) — exactly the API param name — so I named the property maxCost and relied on the existing loop (no explicit mapping or request-code change). mode is already lowercase → stays mode. Confirmed in the compiled dist output: both keys present, 5× mode: ['auto'] (1 show + 4 hide). The empty-string guard in the same loop (!== '') means a neutral mode emits nothing, and an un-added maxCost (n8n only serializes explicitly-added collection fields) means omit = uncapped, matching the contract.

Test plan

  • npm install
  • npm run build (tsc + gulp icons) — clean
  • npm run lint (eslint n8n-nodes-base ruleset) — 0 errors/warnings
  • prepublish lint (.eslintrc.prepublish.js) — clean
  • Verified compiled dist contains mode + maxCost and the 5 displayOptions rules
  • Manual n8n check (post server-ship): Mode = Auto hides Render JS / Premium Proxy / Stealth Proxy / Transparent Status Code; Max Cost appears only under Auto; emitted querystring is &mode=auto[&max_cost=N]; Spb-auto-cost header observed

🤖 Generated with Claude Code

Add `mode` (Auto) and `maxCost` to the HTML API "Additional Fields"
collection so the node can drive the server-side Auto-Mode feature:
mode=auto escalates cheapest-first and charges only the winning config.

- `mode`: options field, single value `auto`, neutral empty default
  (opt-in). Emitted as `&mode=auto`.
- `maxCost`: number (minValue 1), shown only when mode=auto. The generic
  camelCase->snake_case querystring loop turns `maxCost` into `max_cost`.
- Mutual exclusivity: hide renderJs / premiumProxy / stealthProxy /
  transparentStatusCode while mode=auto (server 400s on those combos).
- Bump package version 0.1.6 -> 0.1.7.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@kostas-jakeliunas-sb kostas-jakeliunas-sb marked this pull request as ready for review June 30, 2026 12:57
@kostas-jakeliunas-sb kostas-jakeliunas-sb changed the title [DRAFT — DO NOT MERGE] [SCR-383] Auto-Mode (mode=auto) node fields [SCR-383] Auto-Mode (mode=auto) node fields Jun 30, 2026
@kostas-jakeliunas-sb kostas-jakeliunas-sb self-assigned this Jun 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants