Linear getAll type error (weirdly not in VSCode…) and removed the pagination example that uses the SDK as won’t work with timeouts

This commit is contained in:
Matt Aitken
2023-09-22 10:23:24 -07:00
parent b5e37bfa61
commit dcc807d716
6 changed files with 29 additions and 68 deletions
+5 -19
View File
@@ -124,11 +124,10 @@ client.defineJob({
### Pagination
You can paginate responses three different ways:
You can paginate responses two different ways:
1. Via the raw Linear SDK exposed in `io.runTask()`
2. Iterating the same integration task with different params
3. Using the `getAll` helper exposed on the integration (**recommended!**)
1. Iterating the same integration task with different params
2. Using the `getAll` helper exposed on the integration (**recommended!**)
_When ordering results, make sure to use the `PaginationOrderBy` enum._
@@ -149,20 +148,7 @@ client.defineJob({
//the same params will be used for all tasks
const params = { first: 5, orderBy: PaginationOrderBy.UpdatedAt };
//1. Linear SDK
const sdkIssues = await io.linear.runTask("all-issues-via-sdk", async (client) => {
const edges = await client.issues(params);
//this will keep appending nodes until there are no more
while (edges.pageInfo.hasNextPage) {
await edges.fetchNext();
}
//use serialization helper to remove functions etc
return serializeLinearOutput(edges.nodes);
});
//2. Linear integration - no pagination helper
//1. Linear integration - no pagination helper
let edges = await io.linear.issues("get-issues", params);
let noHelper = edges.nodes;
@@ -174,7 +160,7 @@ client.defineJob({
noHelper = noHelper.concat(edges.nodes);
}
//3. Linear integration - with the pagination helper
//2. Linear integration - with the pagination helper
const withHelper = await io.linear.getAll(io.linear.issues, "get-all", params);
return {
+2 -1
View File
@@ -13,6 +13,7 @@
"dist/index.js.map"
],
"devDependencies": {
"@trigger.dev/tsconfig": "workspace:*",
"@types/node": "16.x",
"rimraf": "^3.0.2",
"tsup": "7.1.x",
@@ -33,4 +34,4 @@
"engines": {
"node": ">=16.8.0"
}
}
}
+4 -4
View File
@@ -184,7 +184,7 @@ export class Linear implements TriggerIntegration {
key: IntegrationTaskKey,
params: Nullable<QueryVariables> = {}
): Promise<Awaited<ReturnType<TTask>>["nodes"]> {
const boundTask = task.bind(this);
const boundTask = task.bind(this as any);
let edges = await boundTask(`${key}-0`, params);
let nodes = edges.nodes;
@@ -286,7 +286,7 @@ export class Linear implements TriggerIntegration {
messageId: string;
url: string;
variables?: Omit<
L.AttachmentLinkDiscordMutationVariables,
L.AttachmentLinkDiscordMutationVariables,
"channelId" | "issueId" | "messageId" | "url"
>;
}
@@ -406,7 +406,7 @@ export class Linear implements TriggerIntegration {
latest: string;
url: string;
variables?: Omit<
L.AttachmentLinkSlackMutationVariables,
L.AttachmentLinkSlackMutationVariables,
"channel" | "issueId" | "latest" | "url"
>;
}
@@ -2026,4 +2026,4 @@ export const serializeLinearOutput = <T>(obj: T): Prettify<SerializedLinearOutpu
export { events };
export const PaginationOrderBy = L.PaginationOrderBy
export const PaginationOrderBy = L.PaginationOrderBy;
+13 -28
View File
@@ -1,33 +1,18 @@
{
"extends": "@trigger.dev/tsconfig/node18.json",
"include": ["./src/**/*.ts", "tsup.config.ts"],
"compilerOptions": {
"composite": false,
"lib": ["DOM", "DOM.Iterable", "ES2019"],
"paths": {
"@trigger.dev/sdk/*": ["../../packages/trigger-sdk/src/*"],
"@trigger.dev/sdk": ["../../packages/trigger-sdk/src/index"],
"@trigger.dev/integration-kit/*": ["../../packages/integration-kit/src/*"],
"@trigger.dev/integration-kit": ["../../packages/integration-kit/src/index"]
},
"declaration": false,
"declarationMap": false,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"inlineSources": false,
"isolatedModules": true,
"moduleResolution": "node16",
"noUnusedLocals": false,
"noUnusedParameters": false,
"preserveWatchOutput": true,
"skipLibCheck": true,
"strict": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"sourceMap": true,
"resolveJsonModule": true,
"lib": [
"es2019"
],
"module": "commonjs",
"target": "es2021"
"baseUrl": ".",
"stripInternal": true
},
"include": [
"./src/**/*.ts",
"tsup.config.ts"
],
"exclude": [
"node_modules"
]
}
"exclude": ["node_modules"]
}
+2
View File
@@ -423,6 +423,7 @@ importers:
'@linear/sdk': ^8.0.0
'@trigger.dev/integration-kit': workspace:^2.1.0
'@trigger.dev/sdk': workspace:^2.1.0
'@trigger.dev/tsconfig': workspace:*
'@types/node': 16.x
rimraf: ^3.0.2
tsup: 7.1.x
@@ -434,6 +435,7 @@ importers:
'@trigger.dev/sdk': link:../../packages/trigger-sdk
zod: 3.21.4
devDependencies:
'@trigger.dev/tsconfig': link:../../config-packages/tsconfig
'@types/node': 16.18.11
rimraf: 3.0.2
tsup: 7.1.0_typescript@4.9.4
+3 -16
View File
@@ -121,20 +121,7 @@ client.defineJob({
//the same params will be used for all tasks
const params = { first: 5, orderBy: PaginationOrderBy.UpdatedAt };
//1. Linear SDK
const sdkIssues = await io.linear.runTask("all-issues-via-sdk", async (client) => {
const edges = await client.issues(params);
//this will keep appending nodes until there are no more
while (edges.pageInfo.hasNextPage) {
await edges.fetchNext();
}
//use serialization helper to remove functions etc
return serializeLinearOutput(edges.nodes);
});
//2. Linear integration - no pagination helper
//1. Linear integration - no pagination helper
let edges = await io.linear.issues("get-issues", params);
let noHelper = edges.nodes;
@@ -146,12 +133,12 @@ client.defineJob({
noHelper = noHelper.concat(edges.nodes);
}
//3. Linear integration - with the pagination helper
//2. Linear integration - with the pagination helper
const withHelper = await io.linear.getAll(io.linear.issues, "get-all", params);
return {
issueCounts: {
withSdk: sdkIssues.length,
// withSdk: sdkIssues.length,
noHelper: noHelper.length,
withHelper: withHelper.length,
},