From 3b42f55442f133083ed916a4eaf865399a8cb068 Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Mon, 22 Sep 2025 16:30:14 -0300 Subject: [PATCH 1/3] Adding pagination to search-issues-with-jql --- .../search-issues-with-jql.mjs | 66 ++++++++++++++++--- components/jira/package.json | 2 +- 2 files changed, 59 insertions(+), 9 deletions(-) diff --git a/components/jira/actions/search-issues-with-jql/search-issues-with-jql.mjs b/components/jira/actions/search-issues-with-jql/search-issues-with-jql.mjs index 1b320bc7033a9..06023cbb31ad2 100644 --- a/components/jira/actions/search-issues-with-jql/search-issues-with-jql.mjs +++ b/components/jira/actions/search-issues-with-jql/search-issues-with-jql.mjs @@ -4,7 +4,7 @@ export default { name: "Search Issues with JQL", description: "Search for issues using JQL (Jira Query Language). [See the documentation](https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-search/#api-rest-api-3-search-jql-get)", key: "jira-search-issues-with-jql", - version: "0.0.4", + version: "0.1.0", type: "action", props: { jira, @@ -17,16 +17,15 @@ export default { jql: { type: "string", label: "JQL Query", - description: "The [JQL](https://support.atlassian.com/jira-software-cloud/docs/what-is-advanced-search-in-jira-cloud/) query to search for issues", + description: "The JQL query query to search for issues. [See the documentation for syntax and examples](https://support.atlassian.com/jira-software-cloud/docs/what-is-advanced-search-in-jira-cloud/)", }, maxResults: { type: "integer", label: "Max Results", - description: "Maximum number of issues to return (default: 50, max: 100)", + description: "Maximum number of issues to return (default: 50)", optional: true, default: 50, min: 1, - max: 100, }, fields: { type: "string", @@ -90,14 +89,62 @@ export default { optional: true, }, }, + methods: { + getMaxResultsPerPage() { + return Math.min(this.maxResults, 500); + }, + async paginate({ + params, maxResults, ...otherArgs + }) { + const results = []; + let nextPageToken; + let response; + + do { + response = await this.jira.searchIssues({ + ...otherArgs, + params: { + ...params, + ...(nextPageToken && { + nextPageToken, + }), + }, + }); + + const pageResults = response.issues; + const pageLength = pageResults?.length; + if (!pageLength) { + break; + } + + // If maxResults is specified, only add what we need + if (maxResults && results.length + pageLength > maxResults) { + const remainingSlots = maxResults - results.length; + results.push(...pageResults.slice(0, remainingSlots)); + break; + } else { + results.push(...pageResults); + } + + // Also break if we've reached maxResults exactly + if (maxResults && results.length >= maxResults) { + break; + } + + nextPageToken = response.nextPageToken; + } while (nextPageToken && !response.isLast); + + return results; + }, + }, async run({ $ }) { try { - const response = await this.jira.searchIssues({ + const issues = await this.paginate({ $, cloudId: this.cloudId, params: { jql: this.jql, - maxResults: this.maxResults, + maxResults: this.getMaxResultsPerPage(), fields: this.fields, expand: this.expand ? this.expand.join(",") @@ -106,9 +153,12 @@ export default { fieldsByKeys: this.fieldsByKeys, failFast: this.failFast, }, + maxResults: this.maxResults, }); - $.export("$summary", `Successfully retrieved ${response.issues.length} issues`); - return response; + $.export("$summary", `Successfully retrieved ${issues.length} issues`); + return { + issues, + }; } catch (error) { throw new Error(`Failed to search issues: ${error.message}`); } diff --git a/components/jira/package.json b/components/jira/package.json index cf9fa35512055..68272573ec0ba 100644 --- a/components/jira/package.json +++ b/components/jira/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/jira", - "version": "1.0.4", + "version": "1.1.0", "description": "Pipedream Jira Components", "main": "jira.app.mjs", "keywords": [ From 3c3509ea5e1a7d4a2554b8feffd545f004906878 Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Mon, 22 Sep 2025 16:37:03 -0300 Subject: [PATCH 2/3] Page adjustments --- .../actions/search-issues-with-jql/search-issues-with-jql.mjs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/jira/actions/search-issues-with-jql/search-issues-with-jql.mjs b/components/jira/actions/search-issues-with-jql/search-issues-with-jql.mjs index 06023cbb31ad2..2a7319da640ec 100644 --- a/components/jira/actions/search-issues-with-jql/search-issues-with-jql.mjs +++ b/components/jira/actions/search-issues-with-jql/search-issues-with-jql.mjs @@ -26,6 +26,7 @@ export default { optional: true, default: 50, min: 1, + max: 5000, }, fields: { type: "string", @@ -91,7 +92,7 @@ export default { }, methods: { getMaxResultsPerPage() { - return Math.min(this.maxResults, 500); + return Math.min(this.maxResults, 1000); }, async paginate({ params, maxResults, ...otherArgs From 344369c48f86c8477df9cf3e755e754976d7067c Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Mon, 22 Sep 2025 16:40:01 -0300 Subject: [PATCH 3/3] Typo fix --- .../actions/search-issues-with-jql/search-issues-with-jql.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/jira/actions/search-issues-with-jql/search-issues-with-jql.mjs b/components/jira/actions/search-issues-with-jql/search-issues-with-jql.mjs index 2a7319da640ec..199641e224588 100644 --- a/components/jira/actions/search-issues-with-jql/search-issues-with-jql.mjs +++ b/components/jira/actions/search-issues-with-jql/search-issues-with-jql.mjs @@ -17,7 +17,7 @@ export default { jql: { type: "string", label: "JQL Query", - description: "The JQL query query to search for issues. [See the documentation for syntax and examples](https://support.atlassian.com/jira-software-cloud/docs/what-is-advanced-search-in-jira-cloud/)", + description: "The JQL query to search for issues. [See the documentation for syntax and examples](https://support.atlassian.com/jira-software-cloud/docs/what-is-advanced-search-in-jira-cloud/)", }, maxResults: { type: "integer",