Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
2 changes: 1 addition & 1 deletion components/linear_app/actions/get-issue/get-issue.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
19 changes: 17 additions & 2 deletions components/linear_app/actions/get-teams/get-teams.mjs
Original file line number Diff line number Diff line change
@@ -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)`);

Expand Down
59 changes: 51 additions & 8 deletions components/linear_app/actions/search-issues/search-issues.mjs
Original file line number Diff line number Diff line change
@@ -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: [
Expand All @@ -52,24 +63,56 @@ 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,
teamId: this.teamId,
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,
Expand All @@ -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`);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
2 changes: 2 additions & 0 deletions components/linear_app/common/constants.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -49,6 +50,7 @@ export default {
LINEAR_DELIVERY_HEADER,
DEFAULT_LIMIT,
DEFAULT_MAX_RECORDS,
DEFAULT_NO_QUERY_LIMIT,
ACTION,
RESOURCE_TYPE,
RESOURCE_TYPES,
Expand Down
12 changes: 11 additions & 1 deletion components/linear_app/common/utils.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
9 changes: 8 additions & 1 deletion components/linear_app/linear_app.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion components/linear_app/package.json
Original file line number Diff line number Diff line change
@@ -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": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
11 changes: 11 additions & 0 deletions components/linear_app/sources/common/webhook.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
...common,
key: "linear_app-new-projectupdate-created",
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)",

Check warning on line 9 in components/linear_app/sources/new-projectupdate-created/new-projectupdate-created.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Source descriptions should start with "Emit new". See https://pipedream.com/docs/components/guidelines/#source-description
type: "source",
version: "0.0.1",
version: "0.0.2",
dedupe: "unique",
props: {
linearApp,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
12 changes: 4 additions & 8 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading