c0dfa8048a
* feat: BYO Auth Define client-side auth resolvers to be able to supply custom authentication credentials for integrations before a run is performed - Added new defineAuthResolver - Update all integrations to support the new auth resolvers - Strip internal symbols from .d.ts in integrations and trigger-sdk - Added BYO Auth docs - Update Dynamic Schedule to support associated account IDs - Create external accounts just-in-time - Added Account ID field to test job when there are external auth integrations - Show Account ID on run dashboard - Added new Run error state called “Unresolved auth” * Added changeset * Remove @internal from TriggerIntegration public methods * Add void to the result union * DynamicTriggers now work with the new BYO auth system, and added a bunch of docs and docs changes * Add additional key material for registering dynamic trigger task * Add new define* instance methods to the overview
67 lines
1.6 KiB
Plaintext
67 lines
1.6 KiB
Plaintext
---
|
|
title: "Job"
|
|
description: "Job is used to create and configure a Job"
|
|
---
|
|
|
|
A [Job](/documentation/concepts/jobs) is used to define the [Trigger](/documentation/concepts/triggers), metadata, and what happens when it runs.
|
|
|
|
You can define a job in one of two ways, using the `new Job` constructor or by using the `TriggerClient.defineJob` instance method.
|
|
|
|
<RequestExample>
|
|
|
|
```ts constructor
|
|
new Job(client, {
|
|
id: "slack-kpi-summary",
|
|
name: "Slack kpi summary",
|
|
version: "0.1.1",
|
|
integrations: {
|
|
slack,
|
|
},
|
|
trigger: cronTrigger({
|
|
cron: "0 9 * * *", // 9am every day (UTC)
|
|
}),
|
|
run: async (payload, io, ctx) => {
|
|
const { revenue } = await db.getKpiSummary(payload.ts);
|
|
const response = await io.slack.postMessage("Slack 📝", {
|
|
text: `Yesterday's revenue was $${revenue}`,
|
|
channel: "C04GWUTDC3W",
|
|
});
|
|
|
|
return response;
|
|
},
|
|
});
|
|
```
|
|
|
|
```ts client.defineJob
|
|
client.defineJob({
|
|
id: "github-integration-on-issue",
|
|
name: "GitHub Integration - On Issue",
|
|
version: "0.1.0",
|
|
trigger: github.triggers.repo({
|
|
event: events.onIssue,
|
|
owner: "triggerdotdev",
|
|
repo: "empty",
|
|
}),
|
|
run: async (payload, io, ctx) => {
|
|
await io.logger.info("This is a simple log info message");
|
|
return { payload, ctx };
|
|
},
|
|
});
|
|
```
|
|
|
|
</RequestExample>
|
|
|
|
# Constructor
|
|
|
|
## Parameters
|
|
|
|
<ParamField body="client" type="object" required>
|
|
An instance of [TriggerClient](/sdk/triggerclient) that is used to send events to the Trigger API.
|
|
</ParamField>
|
|
|
|
<Snippet file="jobs/options.mdx" />
|
|
|
|
## Returns
|
|
|
|
<ResponseField name="Job instance" type="Job" />
|