diff --git a/4.0-Upgrade.md b/4.0-Upgrade.md new file mode 100644 index 0000000..8dc46ab --- /dev/null +++ b/4.0-Upgrade.md @@ -0,0 +1,30 @@ +# Upgrading to chartmogul-node 3.0.0 + +This new version replaces the existing pagination for the `.all()` endpoints that used a combination of `page` and `per_page` parameters, and instead uses a `cursor` based pagination. So to list (as an example) Plans you now can: + +```javascript +const ChartMogul = require('chartmogul-node'); +const config = new ChartMogul.Config('apiKey'); + +// Getting the first page +plans = ChartMogul.Plan.all(config, { per_page: 10, cursor: 'cursor==' }) + +// This will return an array of plans (if available), and a cursor + has_more fields +{ + "plans": [ + { + "uuid": "some_uuid", + "data_source_uuid": "some_uuid", + "name": "Master Plan" + } + ], + "has_more": true, + "cursor": "MjAyMy0wNy0yOFQwODowOToyMi4xNTQyMDMwMDBaJjk0NDQ0Mg==" +} + +if (plans.has_more) { + more_plans = ChartMogul.Plan.all(config, { per_page: 10, cursor: plans.cursor }) +} +``` + +If you have existing code that relies on the `page` parameter, those requests will throw an error now alerting you of their deprecation. diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..9393ce7 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,15 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog], +and this project adheres to [Semantic Versioning]. + +[Keep a Changelog]: https://keepachangelog.com/en/1.0.0/ +[Semantic Versioning]: https://semver.org/spec/v2.0.0.html + +## [3.0.0] - 2023-09-15 + +### Added +- Support for cursor based pagination to `.all()` endpoints. +- Changelog and 3.0.0 upgrade instructions. diff --git a/package-lock.json b/package-lock.json index 76d4ce1..f966548 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "chartmogul-node", - "version": "2.2.0", + "version": "3.0.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "chartmogul-node", - "version": "2.2.0", + "version": "3.0.0", "license": "MIT", "dependencies": { "dependency-lint": "^7.1.0",