Skip to content

Commit 426d08a

Browse files
committed
feat(sdk): add before,after pagination cursor support (1.0.12)
1 parent 9cb0d95 commit 426d08a

File tree

3 files changed

+29
-8
lines changed

3 files changed

+29
-8
lines changed

packages/sdk/CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
<!-- markdownlint-disable MD024 -->
22
# Changelog
33

4-
## [1.0.11] - 2024-12-04
4+
## [1.0.12] - 2024-12-06
5+
6+
### Added
7+
8+
- Allow passing `before`, `after` pagination cursors for apps, accounts, components endpoints
9+
10+
## [1.0.11] - 2024-12-06
511

612
### Added
713

packages/sdk/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/sdk",
3-
"version": "1.0.11",
3+
"version": "1.0.12",
44
"description": "Pipedream SDK",
55
"main": "dist/server/server/index.js",
66
"module": "dist/server/server/index.js",

packages/sdk/src/shared/index.ts

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,10 @@ export type ComponentConfigureResponse = {
9696
};
9797

9898
export type RelationOpts = {
99-
limit?: number
100-
}
99+
after?: string;
100+
before?: string;
101+
limit?: number;
102+
};
101103

102104
/**
103105
* Parameters for the retrieval of apps from the Connect API
@@ -523,9 +525,7 @@ export abstract class BaseClient {
523525
if (opts?.q) {
524526
params.q = opts.q;
525527
}
526-
if (opts?.limit != null) {
527-
params.limit = "" + opts.limit
528-
}
528+
this.addRelationOpts(params, opts);
529529
const resp = await this.makeAuthorizedRequest<AppsRequestResponse>(
530530
"/apps",
531531
{
@@ -553,7 +553,7 @@ export abstract class BaseClient {
553553
if (opts?.q) {
554554
params.q = opts.q;
555555
}
556-
params.limit = "" + (opts?.limit ?? 20)
556+
this.addRelationOpts(params, opts, 20);
557557
// XXX can just use /components and ?type instead when supported
558558
let path = "/components";
559559
if (opts?.componentType === "trigger") {
@@ -871,4 +871,19 @@ export abstract class BaseClient {
871871
HTTPAuthType.OAuth,
872872
); // OAuth auth is required for invoking workflows for external users
873873
}
874+
875+
private addRelationOpts(params: Record<string, string>, opts?: RelationOpts, defaultLimit?: number) {
876+
if (opts?.limit != null) {
877+
params.limit = "" + opts.limit;
878+
}
879+
if (defaultLimit != null && !params.limit) {
880+
params.limit = "" + defaultLimit;
881+
}
882+
if (opts?.after) {
883+
params.after = opts.after;
884+
}
885+
if (opts?.before) {
886+
params.before = opts.before;
887+
}
888+
}
874889
}

0 commit comments

Comments
 (0)