feat: Add async iterable methods for paged API responses #24
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
This PR adds async generator methods to the
OnspringClientclass, enabling developers to easily iterate over paged API responses using modern JavaScriptfor await...ofsyntax. This addresses issue #[issue_number] by providing a more ergonomic way to work with large datasets without manual pagination management.What's Changed
Added five new async iterable methods that automatically handle pagination:
getAppsIterable(pageSize = 50)- Iterate over all apps/surveysgetFieldsByAppIdIterable(appId, pageSize = 50)- Iterate over fields in an appgetRecordsByAppIdIterable(appId, fieldIds = [], dataFormat = DataFormat.Raw, pageSize = 50)- Iterate over records in an appqueryRecordsIterable(appId, filter, fieldIds = [], dataFormat = DataFormat.Raw, pageSize = 50)- Iterate over query resultsgetReportsByAppIdIterable(appId, pageSize = 50)- Iterate over reports in an appUsage Example
Before (manual pagination):
After (async iteration):
Implementation Details
pageSizeparameter (default: 50) for controlling request sizesTesting
Documentation
Breaking Changes
None. This is a purely additive change that introduces new methods without modifying any existing functionality.
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
api.onspring.devnode /home/REDACTED/work/onspring-api-sdk-javascript/onspring-api-sdk-javascript/node_modules/.bin/mocha -R progress -r ts-node/register ./tests/**/*.spec.ts(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
Fixes #17
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.