feat(typed-nocodb-api): extend LIST query schema and fix URLSearchParams serialization#292
Conversation
|
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (3)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
@stephansama/ai-commit-msg
@stephansama/alfred-kaomoji
@stephansama/astro-iconify-svgmap
@stephansama/auto-readme
@stephansama/catppuccin-jsonresume-theme
@stephansama/catppuccin-opml
@stephansama/catppuccin-rss
@stephansama/catppuccin-typedoc
@stephansama/catppuccin-xsl
@stephansama/eslint-config
create-stephansama-example
@stephansama/find-makefile-targets
@stephansama/github-env
@stephansama/multipublish
@stephansama/pnpm-hooks
@stephansama/prettier-plugin-handlebars
@stephansama/remark-asciinema
@stephansama/single-file
@stephansama/svelte-social-share-links
@stephansama/typed-env
@stephansama/typed-events
@stephansama/typed-nocodb-api
@stephansama/typed-templates
@stephansama/types-github-action-env
@stephansama/types-lhci
commit: |
There was a problem hiding this comment.
Code Review
This pull request expands the LIST action in the typed-nocodb-api by adding support for several optional query parameters, including limit, offset, shuffle, nestedFields, viewId, and where. It introduces a toQueryString utility to handle NocoDB-specific serialization requirements, such as bracketed keys for nested objects and comma-separated arrays. Additionally, the sort parameter transformation was updated to use the standard string format (e.g., -field for descending). A review comment suggests refining the URL construction to avoid a trailing question mark when no query parameters are provided.
| if ("query" in props && "querySchema" in current) { | ||
| const parsed = current.querySchema.parse(props.query); | ||
| parameters = "?" + new URLSearchParams(parsed).toString(); | ||
| parameters = "?" + toQueryString(parsed); |
There was a problem hiding this comment.
If toQueryString returns an empty string (which happens when all optional query parameters are omitted), the resulting parameters string will be just "?". This leads to a trailing question mark in the final URL (e.g., .../records?). While most servers handle this gracefully, it is cleaner to omit the prefix entirely if there are no parameters to serialize.
const qs = toQueryString(parsed);
parameters = qs ? "?" + qs : "";
Summary
Closes STE-77.
querySchemato exposewhere,viewId,limit,offset,shuffle, andnestedFieldsso callers can drive the full set of nocodb v3 records-endpoint parameters.string[][]pair construction with a smalltoQueryStringhelper. Arrays now comma-join into a single param (fields=a,b,c) and object-valued params likenestedFieldsexpand into bracketed keys (nestedFields[Author]=name,email) instead of being coerced to[object Object].sortto nocodb's-field/fieldprefix-dash format instead of JSON-stringifying it.Test plan
pnpm exec vitest --run core/typed-nocodb-api— existing LIST/COUNT/CREATE/DELETE/UPDATE tests plus a new fetch-mock test that asserts the generated URL contains every new query parameter.pnpm --filter @stephansama/typed-nocodb-api lintpnpm --filter @stephansama/typed-nocodb-api build:snapshot— API snapshot refreshed.