Skip to content

feat(function): type page, url, and headers on function args - #62

Merged
Kikobeats merged 2 commits into
masterfrom
feat/function-args
Sep 17, 2026
Merged

Kikobeats merged 2 commits into
masterfrom
feat/function-args

Conversation

@Kikobeats

@Kikobeats Kikobeats commented Sep 16, 2026

Copy link
Copy Markdown
Member

Summary

  • Type FunctionArgs as { page, response, headers, url } using Puppeteer's Page and HTTPResponse
  • Overload microlink.function() so inline callbacks get page. completions in editors
  • Export FunctionArgs / FunctionInput from microlink.io and @microlink/function

Test plan

  • pnpm exec tsd in packages/core and packages/function
  • In a consumer, ({ page, url }) => page.title() type-checks page as Page and url as string
  • String-form function(url, '() => 1') still type-checks

Made with Cursor

Summary by CodeRabbit

  • New Features
    • Function-based execution now provides typed access to the page, response, request headers, and URL.
    • The new exported FunctionArgs type makes these executor inputs easier to use in TypeScript.
    • client.function now supports submitting code as a string through a dedicated overload.
    • Function executors can access request headers such as user-agent and the current URL.

Co-authored-by: Cursor <cursoragent@cursor.com>
@coderabbitai

coderabbitai Bot commented Sep 16, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 4957ed5d-f14a-4b8b-bc63-4c288c924da1

📥 Commits

Reviewing files that changed from the base of the PR and between 4619a04 and 6db695b.

📒 Files selected for processing (5)
  • packages/core/package.json
  • packages/core/src/index.d.ts
  • packages/core/test/index.test-d.ts
  • packages/function/src/index.d.ts
  • packages/function/test/index.test-d.ts

📝 Walkthrough

Walkthrough

The PR updates function type declarations in the core and function packages. It exports argument types with page, response, headers, and URL properties, adds a string-code overload, and extends type-level tests.

Changes

Function type contracts

Layer / File(s) Summary
Function API declarations
packages/core/package.json, packages/core/src/index.d.ts, packages/function/src/index.d.ts
The core package adds puppeteer-core for development types. The core and function packages expose FunctionArgs with page, response, headers, and url. The core client adds a string-code overload.
Type-level coverage
packages/core/test/index.test-d.ts, packages/function/test/index.test-d.ts
Type tests verify the new executor argument types, the returned promise type, and access to headers['user-agent'] and url.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Feature

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/function-args

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coveralls

coveralls commented Sep 16, 2026

Copy link
Copy Markdown

Coverage Report for CI Build 35193824725

Warning

Build has drifted: This PR's base is out of sync with its target branch, so coverage data may include unrelated changes.
Quick fix: rebase this PR. Learn more →

Warning

No base build found for commit 4619a04 on master.
Coverage changes can't be calculated without a base build.
If a base build is processing, this comment will update automatically when it completes.

Coverage: 80.387%

Details

  • Patch coverage: No coverable lines changed in this PR.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

Requires a base build to compare against. How to fix this →


Coverage Stats

Coverage Status
Relevant Lines: 5453
Covered Lines: 4397
Line Coverage: 80.63%
Relevant Branches: 905
Covered Branches: 714
Branch Coverage: 78.9%
Branches in Coverage %: Yes
Coverage Strength: 25.06 hits per line

💛 - Coveralls

@Kikobeats
Kikobeats merged commit de12223 into master Sep 17, 2026
7 of 8 checks passed
@Kikobeats
Kikobeats deleted the feat/function-args branch September 17, 2026 07:18
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