diff --git a/components/linear_app/actions/create-issue/create-issue.mjs b/components/linear_app/actions/create-issue/create-issue.mjs index dce521454c01c..ee0b1660cce58 100644 --- a/components/linear_app/actions/create-issue/create-issue.mjs +++ b/components/linear_app/actions/create-issue/create-issue.mjs @@ -5,7 +5,7 @@ export default { key: "linear_app-create-issue", name: "Create Issue", description: "Create an issue (API Key). See the docs [here](https://developers.linear.app/docs/graphql/working-with-the-graphql-api#creating-and-editing-issues)", - version: "0.4.7", + version: "0.4.8", props: { linearApp, teamId: { diff --git a/components/linear_app/actions/get-issue/get-issue.mjs b/components/linear_app/actions/get-issue/get-issue.mjs index 0dd7e2b3de2b0..090e1752af518 100644 --- a/components/linear_app/actions/get-issue/get-issue.mjs +++ b/components/linear_app/actions/get-issue/get-issue.mjs @@ -4,7 +4,7 @@ export default { key: "linear_app-get-issue", name: "Get Issue", description: "Get an issue by ID (API Key). See the docs [here](https://developers.linear.app/docs/graphql/working-with-the-graphql-api)", - version: "0.1.7", + version: "0.1.8", type: "action", props: { linearApp, diff --git a/components/linear_app/actions/get-teams/get-teams.mjs b/components/linear_app/actions/get-teams/get-teams.mjs index f1bbf6efbfd47..523fac9207fdc 100644 --- a/components/linear_app/actions/get-teams/get-teams.mjs +++ b/components/linear_app/actions/get-teams/get-teams.mjs @@ -1,16 +1,31 @@ import linearApp from "../../linear_app.app.mjs"; +import constants from "../../common/constants.mjs"; export default { key: "linear_app-get-teams", name: "Get Teams", description: "Get all the teams (API Key). See the docs [here](https://developers.linear.app/docs/graphql/working-with-the-graphql-api)", - version: "0.2.7", + version: "0.2.8", type: "action", props: { linearApp, + limit: { + propDefinition: [ + linearApp, + "limit", + ], + description: "Maximum number of teams to return. Defaults to 20 if not specified.", + }, }, async run({ $ }) { - const { nodes: teams } = await this.linearApp.listTeams(); + // Use the specified limit or default to a reasonable number + const limit = this.limit || constants.DEFAULT_NO_QUERY_LIMIT; + + const variables = { + first: limit, + }; + + const { nodes: teams } = await this.linearApp.listTeams(variables); $.export("$summary", `Found ${teams.length} teams(s)`); diff --git a/components/linear_app/actions/search-issues/search-issues.mjs b/components/linear_app/actions/search-issues/search-issues.mjs index b0227f121ca96..b3aa745b4e3db 100644 --- a/components/linear_app/actions/search-issues/search-issues.mjs +++ b/components/linear_app/actions/search-issues/search-issues.mjs @@ -1,32 +1,43 @@ import linearApp from "../../linear_app.app.mjs"; import utils from "../../common/utils.mjs"; +import constants from "../../common/constants.mjs"; export default { key: "linear_app-search-issues", name: "Search Issues", description: "Search issues (API Key). See the docs [here](https://developers.linear.app/docs/graphql/working-with-the-graphql-api)", type: "action", - version: "0.2.7", + version: "0.2.8", props: { linearApp, - query: { + teamId: { propDefinition: [ linearApp, - "query", + "teamId", ], }, - teamId: { + projectId: { propDefinition: [ linearApp, - "teamId", + "projectId", + ], + }, + query: { + propDefinition: [ + linearApp, + "query", ], optional: true, }, - projectId: { + stateId: { propDefinition: [ linearApp, - "projectId", + "stateId", + ({ teamId }) => ({ + teamId, + }), ], + description: "Filter issues by their workflow state (status). States are scoped to the selected team.", }, assigneeId: { propDefinition: [ @@ -52,13 +63,36 @@ export default { "includeArchived", ], }, + limit: { + propDefinition: [ + linearApp, + "limit", + ], + }, }, async run({ $ }) { const issues = []; let hasNextPage; let after; + // Determine the overall max limit for all pages combined + const maxLimit = this.limit || (this.query + ? constants.DEFAULT_MAX_RECORDS + : constants.DEFAULT_NO_QUERY_LIMIT); + + // For pagination, we'll use a smaller page size + const pageSize = Math.min(maxLimit, constants.DEFAULT_LIMIT); + do { + // If we've already reached our limit, stop fetching more data + if (issues.length >= maxLimit) { + break; + } + + // Calculate how many more items we need for this page + const remainingNeeded = maxLimit - issues.length; + const thisPageLimit = Math.min(pageSize, remainingNeeded); + const variables = utils.buildVariables(after, { filter: { query: this.query, @@ -66,10 +100,19 @@ export default { projectId: this.projectId, assigneeId: this.assigneeId, issueLabels: this.issueLabels, + state: this.stateId + ? { + id: { + eq: this.stateId, + }, + } + : undefined, }, orderBy: this.orderBy, includeArchived: this.includeArchived, + limit: thisPageLimit, // Use calculated limit for this page }); + const { nodes, pageInfo, @@ -78,7 +121,7 @@ export default { issues.push(...nodes); after = pageInfo.endCursor; hasNextPage = pageInfo.hasNextPage; - } while (hasNextPage); + } while (hasNextPage && issues.length < maxLimit); $.export("$summary", `Found ${issues.length} issues`); diff --git a/components/linear_app/actions/update-issue/update-issue.mjs b/components/linear_app/actions/update-issue/update-issue.mjs index 1b4d1e6a517ad..1484d33fb3a4d 100644 --- a/components/linear_app/actions/update-issue/update-issue.mjs +++ b/components/linear_app/actions/update-issue/update-issue.mjs @@ -5,7 +5,7 @@ export default { name: "Update Issue", description: "Update an issue (API Key). See the docs [here](https://developers.linear.app/docs/graphql/working-with-the-graphql-api#creating-and-editing-issues)", type: "action", - version: "0.1.7", + version: "0.1.8", props: { linearApp, teamId: { diff --git a/components/linear_app/common/constants.mjs b/components/linear_app/common/constants.mjs index 30c487543a70a..c62e5c784347e 100644 --- a/components/linear_app/common/constants.mjs +++ b/components/linear_app/common/constants.mjs @@ -2,6 +2,7 @@ const WEBHOOK_ID = "webhookId"; const LINEAR_DELIVERY_HEADER = "linear-delivery"; const DEFAULT_LIMIT = 100; const DEFAULT_MAX_RECORDS = 200; +const DEFAULT_NO_QUERY_LIMIT = 20; const ACTION = { CREATE: "create", @@ -49,6 +50,7 @@ export default { LINEAR_DELIVERY_HEADER, DEFAULT_LIMIT, DEFAULT_MAX_RECORDS, + DEFAULT_NO_QUERY_LIMIT, ACTION, RESOURCE_TYPE, RESOURCE_TYPES, diff --git a/components/linear_app/common/utils.mjs b/components/linear_app/common/utils.mjs index c5d9c214c8463..a2f07b3a0e695 100644 --- a/components/linear_app/common/utils.mjs +++ b/components/linear_app/common/utils.mjs @@ -59,7 +59,17 @@ function buildVariables(endCursor, args) { const after = endCursor ? `, after: "${endCursor}"` : ""; - return strToObj(`{ filter: { ${filter} }, first: ${constants.DEFAULT_LIMIT}${orderBy}${includeArchived}${after} }`); + // Determine the appropriate limit: + // 1. Use custom limit if provided + // 2. Use a smaller default limit when no query is provided to avoid returning too many results + // 3. Otherwise use the standard default limit + const limit = args.limit + ? args.limit + : (args.filter.query + ? constants.DEFAULT_LIMIT + : constants.DEFAULT_NO_QUERY_LIMIT); + + return strToObj(`{ filter: { ${filter} }, first: ${limit}${orderBy}${includeArchived}${after} }`); } export default { diff --git a/components/linear_app/linear_app.app.mjs b/components/linear_app/linear_app.app.mjs index c6c0986e06f51..18ce53e9ee9a5 100644 --- a/components/linear_app/linear_app.app.mjs +++ b/components/linear_app/linear_app.app.mjs @@ -164,7 +164,8 @@ export default { query: { type: "string", label: "Query", - description: "Search string to look for", + description: "Search string to look for in issue titles. The query is used to filter issues where the title contains the query text (case insensitive).", + optional: true, }, orderBy: { type: "string", @@ -179,6 +180,12 @@ export default { description: "Should archived resources be included? (default: `false`)", optional: true, }, + limit: { + type: "integer", + label: "Limit", + description: "Maximum number of issues to return. If no query is provided, this defaults to 20 to avoid returning too many results.", + optional: true, + }, }, methods: { getAxiosHeaders() { diff --git a/components/linear_app/package.json b/components/linear_app/package.json index 48a839d2c50b9..b76ef411339cb 100644 --- a/components/linear_app/package.json +++ b/components/linear_app/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/linear_app", - "version": "0.7.0", + "version": "0.7.1", "description": "Pipedream Linear_app Components", "main": "linear_app.app.mjs", "keywords": [ diff --git a/components/linear_app/sources/comment-created-instant/comment-created-instant.mjs b/components/linear_app/sources/comment-created-instant/comment-created-instant.mjs index 5d0af9f2e99c3..602e35792c1da 100644 --- a/components/linear_app/sources/comment-created-instant/comment-created-instant.mjs +++ b/components/linear_app/sources/comment-created-instant/comment-created-instant.mjs @@ -7,7 +7,7 @@ export default { name: "New Created Comment (Instant)", description: "Emit new event when a new comment is created. [See the documentation](https://developers.linear.app/docs/graphql/webhooks)", type: "source", - version: "0.1.9", + version: "0.1.10", dedupe: "unique", methods: { ...common.methods, diff --git a/components/linear_app/sources/common/webhook.mjs b/components/linear_app/sources/common/webhook.mjs index 0b7fb23767c77..6395daced4d1a 100644 --- a/components/linear_app/sources/common/webhook.mjs +++ b/components/linear_app/sources/common/webhook.mjs @@ -21,6 +21,13 @@ export default { "projectId", ], }, + limit: { + propDefinition: [ + linearApp, + "limit", + ], + description: "Maximum number of items to return when polling. Defaults to 20 if not specified.", + }, db: "$.service.db", }, async additionalProps() { @@ -102,10 +109,14 @@ export default { return data?.user?.admin; }, async emitPolledResources() { + // Use the specified limit or default to a reasonable number + const maxLimit = this.limit || constants.DEFAULT_NO_QUERY_LIMIT; + const stream = this.linearApp.paginateResources({ resourcesFn: this.getResourcesFn(), resourcesFnArgs: this.getResourcesFnArgs(), useGraphQl: this.useGraphQl(), + max: maxLimit, // Apply the limit to pagination }); const resources = await utils.streamIterator(stream); diff --git a/components/linear_app/sources/issue-created-instant/issue-created-instant.mjs b/components/linear_app/sources/issue-created-instant/issue-created-instant.mjs index 4a92022348116..14978cb173bc5 100644 --- a/components/linear_app/sources/issue-created-instant/issue-created-instant.mjs +++ b/components/linear_app/sources/issue-created-instant/issue-created-instant.mjs @@ -7,7 +7,7 @@ export default { name: "New Created Issue (Instant)", description: "Emit new event when a new issue is created. [See the documentation](https://developers.linear.app/docs/graphql/webhooks)", type: "source", - version: "0.3.9", + version: "0.3.10", dedupe: "unique", methods: { ...common.methods, diff --git a/components/linear_app/sources/issue-updated-instant/issue-updated-instant.mjs b/components/linear_app/sources/issue-updated-instant/issue-updated-instant.mjs index 40d1faefbd43b..37a2eaff1d80b 100644 --- a/components/linear_app/sources/issue-updated-instant/issue-updated-instant.mjs +++ b/components/linear_app/sources/issue-updated-instant/issue-updated-instant.mjs @@ -7,7 +7,7 @@ export default { name: "New Updated Issue (Instant)", description: "Emit new event when an issue is updated. [See the documentation](https://developers.linear.app/docs/graphql/webhooks)", type: "source", - version: "0.3.9", + version: "0.3.10", dedupe: "unique", methods: { ...common.methods, diff --git a/components/linear_app/sources/new-issue-status-updated/new-issue-status-updated.mjs b/components/linear_app/sources/new-issue-status-updated/new-issue-status-updated.mjs index 0583e546a0fea..2d971e2c58598 100644 --- a/components/linear_app/sources/new-issue-status-updated/new-issue-status-updated.mjs +++ b/components/linear_app/sources/new-issue-status-updated/new-issue-status-updated.mjs @@ -8,7 +8,7 @@ export default { name: "New Issue Status Updated (Instant)", description: "Emit new event when the status of an issue is updated. [See the documentation](https://developers.linear.app/docs/graphql/webhooks)", type: "source", - version: "0.1.9", + version: "0.1.10", dedupe: "unique", props: { linearApp: common.props.linearApp, @@ -108,11 +108,14 @@ export default { const previousStatuses = this._getPreviousStatuses(); const newStatuses = {}; + // Use the specified limit or default to a reasonable number + const maxLimit = this.limit || constants.DEFAULT_NO_QUERY_LIMIT; + const stream = this.linearApp.paginateResources({ resourcesFn: this.getResourcesFn(), resourcesFnArgs: this.getResourcesFnArgs(), useGraphQl: this.useGraphQl(), - max: 1000, + max: maxLimit, // Use the configured limit instead of hardcoded 1000 }); const resources = await utils.streamIterator(stream); diff --git a/components/linear_app/sources/new-projectupdate-created/new-projectupdate-created.mjs b/components/linear_app/sources/new-projectupdate-created/new-projectupdate-created.mjs index 2f6963dba9110..e9059854c0470 100644 --- a/components/linear_app/sources/new-projectupdate-created/new-projectupdate-created.mjs +++ b/components/linear_app/sources/new-projectupdate-created/new-projectupdate-created.mjs @@ -8,7 +8,7 @@ export default { name: "New Project Update Written (Instant)", description: "Project updates are short status reports on the health of your projects. Emit new event when a new Project Update is written. [See the documentation](https://developers.linear.app/docs/graphql/webhooks)", type: "source", - version: "0.0.1", + version: "0.0.2", dedupe: "unique", props: { linearApp, diff --git a/components/linear_app/sources/project-updated-instant/project-updated-instant.mjs b/components/linear_app/sources/project-updated-instant/project-updated-instant.mjs index fa890ec44efa7..612138bba93da 100644 --- a/components/linear_app/sources/project-updated-instant/project-updated-instant.mjs +++ b/components/linear_app/sources/project-updated-instant/project-updated-instant.mjs @@ -8,7 +8,7 @@ export default { name: "New Updated Project (Instant)", description: "Emit new event when a project is updated. [See the documentation](https://developers.linear.app/docs/graphql/webhooks)", type: "source", - version: "0.0.2", + version: "0.0.3", dedupe: "unique", props: { linearApp, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4c0245be37368..f77192311faf8 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1401,8 +1401,7 @@ importers: components/better_uptime: {} - components/bettercontact: - specifiers: {} + components/bettercontact: {} components/bettervoice: dependencies: @@ -1930,8 +1929,7 @@ importers: specifier: ^4.2.0 version: 4.2.0 - components/bytebot: - specifiers: {} + components/bytebot: {} components/byteforms: dependencies: @@ -8611,8 +8609,7 @@ importers: specifier: ^1.3.0 version: 1.6.6 - components/notiff: - specifiers: {} + components/notiff: {} components/notion: dependencies: @@ -12782,8 +12779,7 @@ importers: specifier: ^1.6.0 version: 1.6.6 - components/teltel: - specifiers: {} + components/teltel: {} components/temi: dependencies: