Files
nicktrn 067e19fec9 Feature: New Webhook Triggers, KV Store, and Shopify integration (#745)
* Attach webhook to http endpoint

* Create internal webhook handler job

* Fix delivery

* Add webhook trigger

* Index webhooks

* Fix webhook connect

* Webhook activation

* Rename to TriggerWebhook

* Save webhooks to index

* Extend register payload

* Revert attachSource

* Add update webhook helper

* Use crud interface for registration

* Remove filter from params

* Destructure options

* Missing ohash dep

* Chainable trigger filter

* Optional request verification

* Handler call with context

* Update config on register success

* Rename to webhookData

* Add basic key-value store

* Improve kv store

* Webhook trigger UI

* Webhook delivery UI

* Some fixes

* Airtable experiments

* Fix tabs transitions

* Only run register if config differs

* Use subtasks for delivery

* Missing dep

* Error handing and fixes

* Namespace cursor

* Fix hmac verification

* Gut Airtable

* Lockfile

* Template optional api key

* Template event sources and icons

* Template remove filter from params

* Fix models template

* Template fixme

* Fix webhook trigger header

* Actually send params for registration..

* Add back oauthed client

* Verify signature header encoding param

* Fix delivery context

* Webhook create retry with prior delete

* Webhook source type fixes

* Webhook config merge

* Update webhook icon

* Verify webhook task options

* Rename handler to generateEvents

* Send event icons

* Shopify with webhooks

* Shopify job-catalog entry

* Lockfile

* Add webhook migration

* Better icons

* Type fixes

* Make param type optional

* Scope type

* More examples

* More schemas

* Trigger catalog

* Bump versions

* Just a few more events they said

* Simplify session and config

* Typed serializer

* Fix payload type

* Remove unused getters

* Reduce logging output

* Rest resource tasks

* Lockfile

* Bump version

* Remaining triggers

* Fix event types

* Fix import

* Link from webhook trigger to http endpoint

* Use rest resource tasks for crud

* Fix rest save type

* Improve KV types

* Improve attach webhook logging

* Make header schema more lenient

* Fix save type again

* Final error callback

* Shorten keys

* Remove ohash diff

* Disable Airtable webhooks

* Webhook environments

* Fix shopify error import

* Link to integration and http endpoint

* Integration catalog entry

* Disable oauth

* Require api key, simplify client secret

* Move trigger types

* Update catalog example

* Small KV endpoint refactor

* Fix custom migration

* Webhook environment migration

* Improve crud types

* Remove unused schema

* Fix crud context type

* KV limits and HTTP verbs

* KV improvements

* Jobless webhook delivery

* Airtable delivery fixes

* Make deliveries sexy again

* Some docs

* Fix payload types.. again

* Final payload pass

* Schema cleanup

* Refactor handler service

* Remove more stale schemas

* registerJobNamespace import

* Expose KV on TriggerClient

* Remove dummy click handler

* Remove unused components

* Fix delivery pagination

* Enable registration rerun button

* Comment out registration route action handler

* Rename KV as not tied to IO anymore

* Swap api with trigger client

* Disabled fields param

* KV docs

* Changeset

* Shopify docs fixes
2023-11-24 10:22:12 +00:00

110 lines
2.6 KiB
TypeScript

import type { HelpSample, Integration } from "../types";
function usageSample(hasApiKey: boolean): HelpSample {
return {
title: "Using the client",
code: `
import { Linear } from "@trigger.dev/linear";
const linear = new Linear({
id: "__SLUG__",${hasApiKey ? "\n apiKey: process.env.LINEAR_API_KEY!," : ""}
});
client.defineJob({
id: "linear-react-to-new-issue",
name: "Linear - React To New Issue",
version: "0.1.0",
integrations: { linear },
trigger: linear.onIssueCreated(),
run: async (payload, io, ctx) => {
await io.linear.createComment("create-comment", {
issueId: payload.data.id,
body: "Thank's for opening this issue!"
});
await io.linear.createReaction("create-reaction", {
issueId: payload.data.id,
emoji: "+1"
});
return { payload, ctx };
},
});
`,
};
}
export const linear: Integration = {
identifier: "linear",
name: "Linear",
packageName: "@trigger.dev/linear@latest",
authenticationMethods: {
oauth2: {
name: "OAuth",
type: "oauth2",
client: {
id: {
envName: "CLOUD_LINEAR_CLIENT_ID",
},
secret: {
envName: "CLOUD_LINEAR_CLIENT_SECRET",
},
},
config: {
authorization: {
url: "https://linear.app/oauth/authorize",
scopeSeparator: ",",
},
token: {
url: "https://api.linear.app/oauth/token",
metadata: {},
},
refresh: {
url: "https://linear.app/oauth/authorize",
},
pkce: false,
},
scopes: [
{
name: "read",
description: "Read access for the user's account. This scope must always be present.",
defaultChecked: true,
},
{
name: "write",
description:
"Grants global write access to the user's account. Use a more targeted scope if you don't need full access.",
defaultChecked: true,
},
{
name: "issues:create",
description: "Grants access to create issues and attachments only.",
annotations: [{ label: "Issues" }],
},
{
name: "comments:create",
description: "Grants access to create new issue comments.",
annotations: [{ label: "Comments" }],
},
{
name: "admin",
description:
"Grants full access to admin-level endpoints. Don't use this unless you really need it.",
},
],
help: {
samples: [usageSample(false)],
},
},
apikey: {
type: "apikey",
help: {
samples: [usageSample(true)],
},
},
},
};