Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 67b5365d50 | |||
| ea25c37a10 | |||
| c1710ae72d | |||
| 9c5a7cf073 | |||
| 8eedf994af | |||
| 2c91c492df | |||
| b859abdb66 | |||
| 0876b87526 | |||
| 9c4be40adc | |||
| 2635f4bd10 | |||
| 401b7ee03d |
@@ -20,7 +20,7 @@ All of October we're participating in Hacktoberfest and invite you to join us! W
|
||||
|
||||
- Check out our [Hacktoberfest landing page](https://trigger.dev/hacktoberfest) for how to participate and win swag.
|
||||
- Contribute to either our [/trigger.dev](https://github.com/triggerdotdev/trigger.dev/labels/%F0%9F%8E%83%20hacktoberfest), [/api-reference](https://github.com/triggerdotdev/api-reference/issues?q=is%3Aopen+is%3Aissue+label%3A%F0%9F%8E%83hacktoberfest) or [/jobs-showcase](https://github.com/triggerdotdev/jobs-showcase/labels/%F0%9F%8E%83%20hacktoberfest) repositories and complete issues marked `🎃 Hacktoberfest` to be eligible for swag.
|
||||
- Join our [Discord](https://discord.gg/JtBAxBr2m3) and get involved in with the community.
|
||||
- Join our [Discord](https://discord.gg/JtBAxBr2m3) and get involved with the community.
|
||||
|
||||
_New to Hacktober? Check out the [Hacktoberfest website](https://hacktoberfest.digitalocean.com/) for more information._
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { Preview } from "@storybook/react";
|
||||
import "../app/tailwind.css";
|
||||
import { unstable_createRemixStub } from "@remix-run/testing";
|
||||
import { createRemixStub } from "@remix-run/testing";
|
||||
import React from "react";
|
||||
import { LocaleContextProvider } from "../app/components/primitives/LocaleProvider";
|
||||
import { OperatingSystemContextProvider } from "../app/components/primitives/OperatingSystemProvider";
|
||||
@@ -26,10 +26,10 @@ const preview: Preview = {
|
||||
},
|
||||
decorators: [
|
||||
(Story) => {
|
||||
const RemixStub = unstable_createRemixStub([
|
||||
const RemixStub = createRemixStub([
|
||||
{
|
||||
path: "/*",
|
||||
element: <Story />,
|
||||
Component: Story,
|
||||
},
|
||||
]);
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ export function RunPanel({
|
||||
? "border-slate-850"
|
||||
: "border-slate-900",
|
||||
onClick && "cursor-pointer",
|
||||
onClick && !selected && "hover:border-green-500/30",
|
||||
onClick && !selected && "hover:border-slate-500/30",
|
||||
className
|
||||
)}
|
||||
onClick={() => onClick && onClick()}
|
||||
|
||||
@@ -159,6 +159,16 @@ export function RunOverview({ run, trigger, showRerun, paths }: RunOverviewProps
|
||||
<div className="grid h-full grid-cols-2 gap-2">
|
||||
<div className="flex flex-col gap-6 overflow-y-auto py-4 pl-4 pr-2 scrollbar-thin scrollbar-track-transparent scrollbar-thumb-slate-700">
|
||||
<div>
|
||||
{(run.tasks.length === 0 || run.tasks.every((t) => t.noop)) && (
|
||||
<Callout
|
||||
variant={"warning"}
|
||||
to="https://trigger.dev/docs/documentation/concepts/tasks"
|
||||
className="mb-4"
|
||||
>
|
||||
This Run completed but it did not use any Tasks – this can cause unpredictable
|
||||
results. Read the docs to view the solution.
|
||||
</Callout>
|
||||
)}
|
||||
<Header2 className="mb-2">Trigger</Header2>
|
||||
<RunPanel
|
||||
selected={selectedId === "trigger"}
|
||||
|
||||
@@ -15,6 +15,8 @@ import omit from "lodash.omit";
|
||||
import { z } from "zod";
|
||||
import { PrismaClient, PrismaClientOrTransaction } from "~/db.server";
|
||||
import { workerLogger as logger } from "~/services/logger.server";
|
||||
import { PgListenService } from "~/services/db/pgListen.server";
|
||||
import { safeJsonParse } from "~/utils/json";
|
||||
|
||||
export interface MessageCatalogSchema {
|
||||
[key: string]: z.ZodFirstPartySchemaTypes | z.ZodDiscriminatedUnion<any, any>;
|
||||
@@ -164,8 +166,23 @@ export class ZodWorker<TMessageCatalog extends MessageCatalogSchema> {
|
||||
this.#logDebug("pool:create", { attempts });
|
||||
});
|
||||
|
||||
this.#runner?.events.on("pool:listen:success", ({ workerPool, client }) => {
|
||||
this.#runner?.events.on("pool:listen:success", async ({ workerPool, client }) => {
|
||||
this.#logDebug("pool:listen:success");
|
||||
|
||||
// hijack client instance to listen and react to incoming NOTIFY events
|
||||
const pgListen = new PgListenService(client, this.#name, logger);
|
||||
|
||||
await pgListen.on("trigger:graphile:migrate", async ({ latestMigration }) => {
|
||||
this.#logDebug("Detected incoming migration", { latestMigration });
|
||||
|
||||
if (latestMigration > 10) {
|
||||
// already migrated past v0.14 - nothing to do
|
||||
return;
|
||||
}
|
||||
|
||||
// simulate SIGTERM to trigger graceful shutdown
|
||||
this._handleSignal("SIGTERM");
|
||||
});
|
||||
});
|
||||
|
||||
this.#runner?.events.on("pool:listen:error", ({ error }) => {
|
||||
|
||||
@@ -156,6 +156,7 @@ export class RunPresenter {
|
||||
completedAt: true,
|
||||
style: true,
|
||||
parentId: true,
|
||||
noop: true,
|
||||
runConnection: {
|
||||
select: {
|
||||
integration: {
|
||||
|
||||
@@ -10,6 +10,7 @@ import { authenticateApiRequest } from "~/services/apiAuth.server";
|
||||
import { IngestSendEvent } from "~/services/events/ingestSendEvent.server";
|
||||
import { logger } from "~/services/logger.server";
|
||||
import { RegisterTriggerSourceServiceV2 } from "~/services/triggers/registerTriggerSourceV2.server";
|
||||
import { nanoid } from "nanoid";
|
||||
|
||||
const ParamsSchema = z.object({
|
||||
endpointSlug: z.string(),
|
||||
@@ -17,6 +18,10 @@ const ParamsSchema = z.object({
|
||||
key: z.string(),
|
||||
});
|
||||
|
||||
const HeadersSchema = z.object({
|
||||
"idempotency-key": z.string().optional(),
|
||||
});
|
||||
|
||||
export async function action({ request, params }: ActionFunctionArgs) {
|
||||
logger.info("Registering trigger", { url: request.url });
|
||||
|
||||
@@ -77,11 +82,18 @@ export async function action({ request, params }: ActionFunctionArgs) {
|
||||
dynamicTriggerId: parsedParams.data.id,
|
||||
};
|
||||
|
||||
const headers = HeadersSchema.safeParse(Object.fromEntries(request.headers));
|
||||
|
||||
const eventId =
|
||||
headers.success && headers.data["idempotency-key"]
|
||||
? headers.data["idempotency-key"]
|
||||
: `${registration.id}:${nanoid()}`;
|
||||
|
||||
const ingestEventService = new IngestSendEvent();
|
||||
await ingestEventService.call(
|
||||
authenticatedEnv,
|
||||
{
|
||||
id: registration.id,
|
||||
id: eventId,
|
||||
name: REGISTER_SOURCE_EVENT_V2,
|
||||
source: "trigger.dev",
|
||||
payload,
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
import type { PoolClient } from "pg";
|
||||
import { z } from "zod";
|
||||
import { Logger } from "@trigger.dev/core";
|
||||
import { logger } from "~/services/logger.server";
|
||||
import { NotificationCatalog, NotificationChannel, notificationCatalog } from "./types";
|
||||
import { safeJsonParse } from "~/utils/json";
|
||||
|
||||
export class PgListenService {
|
||||
#poolClient: PoolClient;
|
||||
#logger: Logger;
|
||||
#loggerNamespace: string;
|
||||
|
||||
constructor(poolClient: PoolClient, loggerNamespace?: string, loggerInstance?: Logger) {
|
||||
this.#poolClient = poolClient;
|
||||
this.#logger = loggerInstance ?? logger;
|
||||
this.#loggerNamespace = loggerNamespace ?? "";
|
||||
}
|
||||
|
||||
public async on<TChannel extends NotificationChannel>(
|
||||
channelName: TChannel,
|
||||
callback: (payload: z.infer<NotificationCatalog[TChannel]>) => Promise<void>
|
||||
) {
|
||||
this.#logDebug("Registering notification handler", { channelName });
|
||||
|
||||
const isValidChannel = channelName.match(/^[a-zA-Z0-9:-_]+$/);
|
||||
|
||||
if (!isValidChannel) {
|
||||
throw new Error(`Invalid channel name: ${channelName}`);
|
||||
}
|
||||
|
||||
this.#poolClient.query(`LISTEN "${channelName}"`).then(null, (error) => {
|
||||
this.#logDebug("LISTEN error", error);
|
||||
});
|
||||
|
||||
this.#poolClient.on("notification", async (notification) => {
|
||||
if (notification.channel !== channelName) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.#logDebug("Notification received", { notification });
|
||||
|
||||
if (!notification.payload) {
|
||||
return;
|
||||
}
|
||||
|
||||
const payload = safeJsonParse(notification.payload);
|
||||
|
||||
const parsedPayload = notificationCatalog[channelName].safeParse(payload);
|
||||
|
||||
if (!parsedPayload.success) {
|
||||
throw new Error(
|
||||
`Failed to parse notification payload: ${channelName} - ${JSON.stringify(
|
||||
parsedPayload.error
|
||||
)}`
|
||||
);
|
||||
}
|
||||
|
||||
await callback(parsedPayload.data);
|
||||
});
|
||||
}
|
||||
|
||||
#logDebug(message: string, args?: any) {
|
||||
const namespace = this.#loggerNamespace ? `[${this.#loggerNamespace}]` : "";
|
||||
this.#logger.debug(`[pgListen]${namespace} ${message}`, args);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
import { z } from "zod";
|
||||
import { PrismaClient, prisma } from "~/db.server";
|
||||
import { logger } from "~/services/logger.server";
|
||||
import { NotificationCatalog, NotificationChannel } from "./types";
|
||||
|
||||
export class PgNotifyService {
|
||||
#prismaClient: PrismaClient;
|
||||
|
||||
constructor(prismaClient: PrismaClient = prisma) {
|
||||
this.#prismaClient = prismaClient;
|
||||
}
|
||||
|
||||
public async call<TChannel extends NotificationChannel>(
|
||||
channelName: TChannel,
|
||||
payload: z.infer<NotificationCatalog[TChannel]>
|
||||
) {
|
||||
this.#logDebug("Sending notification", { channelName, notifyPayload: payload });
|
||||
|
||||
await this.#prismaClient.$executeRaw`
|
||||
SELECT pg_notify(${channelName}, ${JSON.stringify(payload)})
|
||||
`;
|
||||
}
|
||||
|
||||
#logDebug(message: string, args?: any) {
|
||||
logger.debug(`[pgNotify] ${message}`, args);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import { z } from "zod";
|
||||
|
||||
export const notificationCatalog = {
|
||||
"trigger:graphile:migrate": z.object({
|
||||
latestMigration: z.number(),
|
||||
}),
|
||||
};
|
||||
|
||||
export type NotificationCatalog = typeof notificationCatalog;
|
||||
|
||||
export type NotificationChannel = keyof NotificationCatalog;
|
||||
@@ -1,9 +1,9 @@
|
||||
import {
|
||||
API_VERSIONS,
|
||||
BloomFilter,
|
||||
ApiEventLog,
|
||||
ConnectionAuth,
|
||||
EndpointHeadersSchema,
|
||||
RunJobAutoYieldWithCompletedTaskExecutionError,
|
||||
RunJobBody,
|
||||
RunJobError,
|
||||
RunJobInvalidPayloadError,
|
||||
RunJobResumeWithTask,
|
||||
@@ -14,27 +14,25 @@ import {
|
||||
RunSourceContextSchema,
|
||||
supportsFeature,
|
||||
} from "@trigger.dev/core";
|
||||
import { BloomFilter } from "@trigger.dev/core-backend";
|
||||
import { RuntimeEnvironmentType, type Task } from "@trigger.dev/database";
|
||||
import { generateErrorMessage } from "zod-error";
|
||||
import { eventRecordToApiJson } from "~/api.server";
|
||||
import {
|
||||
MAX_RUN_CHUNK_EXECUTION_LIMIT,
|
||||
MAX_RUN_YIELDED_EXECUTIONS,
|
||||
RUN_CHUNK_EXECUTION_BUFFER,
|
||||
} from "~/consts";
|
||||
import { $transaction, PrismaClient, PrismaClientOrTransaction, prisma } from "~/db.server";
|
||||
import { detectResponseIsTimeout } from "~/models/endpoint.server";
|
||||
import { enqueueRunExecutionV2 } from "~/models/jobRunExecution.server";
|
||||
import { resolveRunConnections } from "~/models/runConnection.server";
|
||||
import { prepareTasksForCaching, prepareTasksForCachingLegacy } from "~/models/task.server";
|
||||
import { CompleteRunTaskService } from "~/routes/api.v1.runs.$runId.tasks.$id.complete";
|
||||
import { formatError } from "~/utils/formatErrors.server";
|
||||
import { safeJsonZodParse } from "~/utils/json";
|
||||
import { EndpointApi } from "../endpointApi.server";
|
||||
import { logger } from "../logger.server";
|
||||
import { prepareTasksForCaching, prepareTasksForCachingLegacy } from "~/models/task.server";
|
||||
import {
|
||||
MAX_RUN_CHUNK_EXECUTION_LIMIT,
|
||||
MAX_RUN_YIELDED_EXECUTIONS,
|
||||
RESPONSE_TIMEOUT_STATUS_CODES,
|
||||
RUN_CHUNK_EXECUTION_BUFFER,
|
||||
} from "~/consts";
|
||||
import { ApiEventLog } from "@trigger.dev/core";
|
||||
import { RunJobBody } from "@trigger.dev/core";
|
||||
import { CompleteRunTaskService } from "~/routes/api.v1.runs.$runId.tasks.$id.complete";
|
||||
import { detectResponseIsTimeout } from "~/models/endpoint.server";
|
||||
import { forceYieldCoordinator } from "./forceYieldCoordinator.server";
|
||||
|
||||
type FoundRun = NonNullable<Awaited<ReturnType<typeof findRun>>>;
|
||||
|
||||
@@ -21,6 +21,7 @@ import { DeliverHttpSourceRequestService } from "./sources/deliverHttpSourceRequ
|
||||
import { PerformTaskOperationService } from "./tasks/performTaskOperation.server";
|
||||
import { ProcessCallbackTimeoutService } from "./tasks/processCallbackTimeout";
|
||||
import { ProbeEndpointService } from "./endpoints/probeEndpoint.server";
|
||||
import { PgNotifyService } from "./db/pgNotify.server";
|
||||
|
||||
const workerCatalog = {
|
||||
indexEndpoint: z.object({
|
||||
@@ -121,6 +122,10 @@ if (env.NODE_ENV === "production") {
|
||||
}
|
||||
|
||||
export async function init() {
|
||||
// const pgNotify = new PgNotifyService();
|
||||
// await pgNotify.call("trigger:graphile:migrate", { latestMigration: 10 });
|
||||
// await new Promise((resolve) => setTimeout(resolve, 10000))
|
||||
|
||||
if (env.WORKER_ENABLED === "true") {
|
||||
await workerQueue.initialize();
|
||||
}
|
||||
|
||||
@@ -63,8 +63,10 @@
|
||||
"@team-plain/typescript-sdk": "^2.2.0",
|
||||
"@trigger.dev/companyicons": "^1.5.14",
|
||||
"@trigger.dev/core": "workspace:*",
|
||||
"@trigger.dev/core-backend": "workspace:*",
|
||||
"@trigger.dev/database": "workspace:*",
|
||||
"@trigger.dev/sdk": "workspace:*",
|
||||
"@types/pg": "8.6.6",
|
||||
"@uiw/react-codemirror": "^4.19.5",
|
||||
"class-variance-authority": "^0.5.2",
|
||||
"clsx": "^1.2.1",
|
||||
|
||||
@@ -12,6 +12,7 @@ module.exports = {
|
||||
"marked",
|
||||
"axios",
|
||||
"@trigger.dev/core",
|
||||
"@trigger.dev/core-backend",
|
||||
"@trigger.dev/sdk",
|
||||
"emails",
|
||||
"highlight.run",
|
||||
@@ -19,6 +20,7 @@ module.exports = {
|
||||
watchPaths: async () => {
|
||||
return [
|
||||
"../../packages/core/src/**/*",
|
||||
"../../packages/core-backend/src/**/*",
|
||||
"../../packages/trigger-sdk/src/**/*",
|
||||
"../../packages/emails/src/**/*",
|
||||
];
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
"@trigger.dev/sdk/*": ["../../packages/trigger-sdk/src/*"],
|
||||
"@trigger.dev/core": ["../../packages/core/src/index"],
|
||||
"@trigger.dev/core/*": ["../../packages/core/src/*"],
|
||||
"@trigger.dev/core-backend": ["../../packages/core-backend/src/index"],
|
||||
"@trigger.dev/core-backend/*": ["../../packages/core-backend/src/*"],
|
||||
"@trigger.dev/database": ["../../packages/database/src/index"],
|
||||
"@trigger.dev/database/*": ["../../packages/database/src/*"],
|
||||
"emails": ["../../packages/emails/src/index"],
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
## Troubleshooting
|
||||
|
||||
### `'TriggerProvider' not found`
|
||||
|
||||
When running the Remix app, you may see an error like this:
|
||||
|
||||
```
|
||||
import { TriggerProvider } from "@trigger.dev/react";
|
||||
^^^^^^^^^^^^^^^
|
||||
SyntaxError: Named export 'TriggerProvider' not found. The requested module '@trigger.dev/react' is a CommonJS module, which may not support all module.exports as named exports.
|
||||
CommonJS modules can always be imported via the default export, for example using:
|
||||
|
||||
import pkg from '@trigger.dev/react';
|
||||
const { TriggerProvider } = pkg;
|
||||
```
|
||||
|
||||
To fix this, edit your `remix.config.js` file and add the `@trigger.dev/react` package to your list of `serverDependenciesToBundle`:
|
||||
|
||||
```js
|
||||
export default {
|
||||
// ... other config
|
||||
serverDependenciesToBundle: ["@trigger.dev/react"],
|
||||
};
|
||||
```
|
||||
|
||||
### `[ERROR] Node builtin "buffer"`
|
||||
|
||||
When running the Remix app, you may see an error like this:
|
||||
|
||||
```
|
||||
✘ [ERROR] Node builtin "buffer" (imported by "node_modules/@trigger.dev/core/dist/index.js") must be polyfilled for the browser.
|
||||
You can enable this polyfill in your Remix config, e.g. `browserNodeBuiltinsPolyfill: { modules: { buffer: true } }`
|
||||
[plugin browser-node-builtins-polyfill-plugin]
|
||||
```
|
||||
|
||||
To fix this, edit your `remix.config.js` file and add the `browserNodeBuiltinsPolyfill` config:
|
||||
|
||||
```js
|
||||
export default {
|
||||
browserNodeBuiltinsPolyfill: {
|
||||
modules: {
|
||||
buffer: "empty",
|
||||
},
|
||||
},
|
||||
};
|
||||
```
|
||||
@@ -5,3 +5,5 @@ description: "How to manually setup Trigger.dev in your Remix project"
|
||||
---
|
||||
|
||||
<Snippet file="manual-setup-remix.mdx" />
|
||||
|
||||
<Snippet file="remix/troubleshooting.mdx" />
|
||||
|
||||
@@ -16,3 +16,5 @@ View our [guide for writing Jobs](/documentation/guides/create-a-job).
|
||||
## Deployment
|
||||
|
||||
View our [deployment guide](/documentation/guides/deployment) to learn how to deploy your Jobs.
|
||||
|
||||
<Snippet file="remix/troubleshooting.mdx" />
|
||||
|
||||
@@ -29,6 +29,14 @@ ENCRYPTION_KEY=1189c93e399856a2a9a1454496171b2e
|
||||
...
|
||||
```
|
||||
|
||||
3. Set `NODE_ENV` to production:
|
||||
|
||||
```sh .env (excerpt)
|
||||
...
|
||||
NODE_ENV=production
|
||||
...
|
||||
```
|
||||
|
||||
## Create a Supabase DB
|
||||
|
||||
<Tip>Alternative: [Self-host Supabase](https://supabase.com/docs/guides/self-hosting/docker)</Tip>
|
||||
@@ -84,7 +92,7 @@ ENCRYPTION_KEY=1189c93e399856a2a9a1454496171b2e
|
||||
DATABASE_URL=postgresql://postgres:<PASSWORD>@db.<ID>.supabase.co:5432/postgres?schema=triggerdotdev
|
||||
DIRECT_URL=${DATABASE_URL}
|
||||
|
||||
NODE_ENV=development
|
||||
NODE_ENV=production
|
||||
RUNTIME_PLATFORM=docker-compose
|
||||
```
|
||||
|
||||
|
||||
@@ -5,6 +5,8 @@ description: "Start creating Jobs in 5 minutes in your Remix project."
|
||||
icon: "r"
|
||||
---
|
||||
|
||||
## Quickstart
|
||||
|
||||
This quick start guide will get you up and running with Trigger.dev.
|
||||
|
||||
<Accordion title="Need to create a new Remix project to add Trigger.dev to?">
|
||||
@@ -84,6 +86,8 @@ If you navigate to your Trigger.dev project you will see this Job in the "Jobs"
|
||||
|
||||
</Steps>
|
||||
|
||||
<Snippet file="remix/troubleshooting.mdx" />
|
||||
|
||||
<Snippet file="quickstart-whats-next.mdx" />
|
||||
<CardGroup cols={2}>
|
||||
<Snippet file="card-react-hooks.mdx" />
|
||||
|
||||
@@ -1,5 +1,15 @@
|
||||
# @trigger.dev/airtable
|
||||
|
||||
## 2.2.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 9c5a7cf0: Extend the Airtable field set to accept formula errors and special values
|
||||
- Updated dependencies [c1710ae7]
|
||||
- Updated dependencies [9c4be40a]
|
||||
- @trigger.dev/sdk@2.2.4
|
||||
- @trigger.dev/integration-kit@2.2.4
|
||||
|
||||
## 2.2.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@trigger.dev/airtable",
|
||||
"version": "2.2.3",
|
||||
"version": "2.2.4",
|
||||
"description": "Trigger.dev integration for airtable",
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
@@ -26,8 +26,8 @@
|
||||
"typecheck": "tsc --noEmit"
|
||||
},
|
||||
"dependencies": {
|
||||
"@trigger.dev/integration-kit": "workspace:^2.2.3",
|
||||
"@trigger.dev/sdk": "workspace:^2.2.3",
|
||||
"@trigger.dev/integration-kit": "workspace:^2.2.4",
|
||||
"@trigger.dev/sdk": "workspace:^2.2.4",
|
||||
"airtable": "^0.12.1",
|
||||
"zod": "3.22.3"
|
||||
},
|
||||
|
||||
@@ -38,6 +38,8 @@ export class Table<TFields extends AirtableFieldSet> {
|
||||
async (client) => {
|
||||
const result = await client
|
||||
.base(this.baseId)
|
||||
// official types are wrong - we need to use our extended AirtableFieldSet here
|
||||
// @ts-ignore
|
||||
.table<TFields>(this.tableName)
|
||||
.select(params)
|
||||
.all();
|
||||
@@ -55,6 +57,8 @@ export class Table<TFields extends AirtableFieldSet> {
|
||||
return this.runTask(
|
||||
key,
|
||||
async (client) => {
|
||||
// official types are wrong - we need to use our extended AirtableFieldSet here
|
||||
// @ts-ignore
|
||||
const result = await client.base(this.baseId).table<TFields>(this.tableName).find(recordId);
|
||||
return toSerializableRecord<TFields>(result);
|
||||
},
|
||||
@@ -75,6 +79,8 @@ export class Table<TFields extends AirtableFieldSet> {
|
||||
async (client) => {
|
||||
const result = await client
|
||||
.base(this.baseId)
|
||||
// official types are wrong - we need to use our extended AirtableFieldSet here
|
||||
// @ts-ignore
|
||||
.table<TFields>(this.tableName)
|
||||
.create(records);
|
||||
return result.map((record) => toSerializableRecord<TFields>(record));
|
||||
@@ -96,6 +102,8 @@ export class Table<TFields extends AirtableFieldSet> {
|
||||
async (client) => {
|
||||
const result = await client
|
||||
.base(this.baseId)
|
||||
// official types are wrong - we need to use our extended AirtableFieldSet here
|
||||
// @ts-ignore
|
||||
.table<TFields>(this.tableName)
|
||||
.update(records);
|
||||
return result.map((record) => toSerializableRecord<TFields>(record));
|
||||
@@ -117,6 +125,8 @@ export class Table<TFields extends AirtableFieldSet> {
|
||||
async (client) => {
|
||||
const result = await client
|
||||
.base(this.baseId)
|
||||
// official types are wrong - we need to use our extended AirtableFieldSet here
|
||||
// @ts-ignore
|
||||
.table<TFields>(this.tableName)
|
||||
.destroy(recordIds);
|
||||
return result.map((record) => toSerializableRecord<TFields>(record));
|
||||
|
||||
@@ -9,7 +9,8 @@ export type AirtableFieldSet = {
|
||||
| Collaborator
|
||||
| Collaborator[]
|
||||
| string[]
|
||||
| Attachment[];
|
||||
| Attachment[]
|
||||
| Formula;
|
||||
};
|
||||
|
||||
export type Collaborator = {
|
||||
@@ -31,6 +32,16 @@ export type Attachment = {
|
||||
};
|
||||
};
|
||||
|
||||
export type FormulaError = {
|
||||
error: string;
|
||||
};
|
||||
|
||||
export type FormulaSpecialValue = {
|
||||
specialValue: "Infinity" | "NaN";
|
||||
};
|
||||
|
||||
export type Formula = string | number | FormulaError | FormulaSpecialValue;
|
||||
|
||||
export type Thumbnail = {
|
||||
url: string;
|
||||
width: number;
|
||||
|
||||
@@ -1,5 +1,14 @@
|
||||
# @trigger.dev/github
|
||||
|
||||
## 2.2.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [c1710ae7]
|
||||
- Updated dependencies [9c4be40a]
|
||||
- @trigger.dev/sdk@2.2.4
|
||||
- @trigger.dev/integration-kit@2.2.4
|
||||
|
||||
## 2.2.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@trigger.dev/github",
|
||||
"version": "2.2.3",
|
||||
"version": "2.2.4",
|
||||
"description": "The official GitHub integration for Trigger.dev",
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
@@ -29,8 +29,8 @@
|
||||
"@octokit/request": "^6.2.5",
|
||||
"@octokit/request-error": "^4.0.1",
|
||||
"@octokit/webhooks": "^10.4.0",
|
||||
"@trigger.dev/integration-kit": "workspace:^2.2.3",
|
||||
"@trigger.dev/sdk": "workspace:^2.2.3",
|
||||
"@trigger.dev/integration-kit": "workspace:^2.2.4",
|
||||
"@trigger.dev/sdk": "workspace:^2.2.4",
|
||||
"octokit": "^2.0.14",
|
||||
"zod": "3.22.3"
|
||||
},
|
||||
|
||||
@@ -1,5 +1,14 @@
|
||||
# @trigger.dev/linear
|
||||
|
||||
## 2.2.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [c1710ae7]
|
||||
- Updated dependencies [9c4be40a]
|
||||
- @trigger.dev/sdk@2.2.4
|
||||
- @trigger.dev/integration-kit@2.2.4
|
||||
|
||||
## 2.2.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@trigger.dev/linear",
|
||||
"version": "2.2.3",
|
||||
"version": "2.2.4",
|
||||
"description": "Trigger.dev integration for @linear/sdk",
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
@@ -27,8 +27,8 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@linear/sdk": "^8.0.0",
|
||||
"@trigger.dev/integration-kit": "workspace:^2.2.3",
|
||||
"@trigger.dev/sdk": "workspace:^2.2.3",
|
||||
"@trigger.dev/integration-kit": "workspace:^2.2.4",
|
||||
"@trigger.dev/sdk": "workspace:^2.2.4",
|
||||
"zod": "3.22.3"
|
||||
},
|
||||
"engines": {
|
||||
|
||||
@@ -1,5 +1,14 @@
|
||||
# @trigger.dev/slack
|
||||
|
||||
## 2.2.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [c1710ae7]
|
||||
- Updated dependencies [9c4be40a]
|
||||
- @trigger.dev/sdk@2.2.4
|
||||
- @trigger.dev/integration-kit@2.2.4
|
||||
|
||||
## 2.2.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@trigger.dev/openai",
|
||||
"version": "2.2.3",
|
||||
"version": "2.2.4",
|
||||
"description": "The official OpenAI integration for Trigger.dev",
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
@@ -27,8 +27,8 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"openai": "^4.13.0",
|
||||
"@trigger.dev/sdk": "workspace:^2.2.3",
|
||||
"@trigger.dev/integration-kit": "workspace:^2.2.3"
|
||||
"@trigger.dev/sdk": "workspace:^2.2.4",
|
||||
"@trigger.dev/integration-kit": "workspace:^2.2.4"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18.0.0"
|
||||
|
||||
@@ -1,5 +1,14 @@
|
||||
# @trigger.dev/plain
|
||||
|
||||
## 2.2.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [c1710ae7]
|
||||
- Updated dependencies [9c4be40a]
|
||||
- @trigger.dev/sdk@2.2.4
|
||||
- @trigger.dev/integration-kit@2.2.4
|
||||
|
||||
## 2.2.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@trigger.dev/plain",
|
||||
"version": "2.2.3",
|
||||
"version": "2.2.4",
|
||||
"description": "The official Plain.com integration for Trigger.dev",
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
@@ -24,8 +24,8 @@
|
||||
"build:tsup": "tsup"
|
||||
},
|
||||
"dependencies": {
|
||||
"@trigger.dev/integration-kit": "workspace:^2.2.3",
|
||||
"@trigger.dev/sdk": "workspace:^2.2.3",
|
||||
"@trigger.dev/integration-kit": "workspace:^2.2.4",
|
||||
"@trigger.dev/sdk": "workspace:^2.2.4",
|
||||
"@team-plain/typescript-sdk": "^2.7.0"
|
||||
},
|
||||
"engines": {
|
||||
|
||||
@@ -1,5 +1,14 @@
|
||||
# @trigger.dev/replicate
|
||||
|
||||
## 2.2.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [c1710ae7]
|
||||
- Updated dependencies [9c4be40a]
|
||||
- @trigger.dev/sdk@2.2.4
|
||||
- @trigger.dev/integration-kit@2.2.4
|
||||
|
||||
## 2.2.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@trigger.dev/replicate",
|
||||
"version": "2.2.3",
|
||||
"version": "2.2.4",
|
||||
"description": "Trigger.dev integration for replicate",
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
@@ -26,8 +26,8 @@
|
||||
"typecheck": "tsc --noEmit"
|
||||
},
|
||||
"dependencies": {
|
||||
"@trigger.dev/integration-kit": "workspace:^2.2.3",
|
||||
"@trigger.dev/sdk": "workspace:^2.2.3",
|
||||
"@trigger.dev/integration-kit": "workspace:^2.2.4",
|
||||
"@trigger.dev/sdk": "workspace:^2.2.4",
|
||||
"replicate": "^0.18.1",
|
||||
"zod": "3.22.3"
|
||||
},
|
||||
|
||||
@@ -1,5 +1,14 @@
|
||||
# @trigger.dev/resend
|
||||
|
||||
## 2.2.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [c1710ae7]
|
||||
- Updated dependencies [9c4be40a]
|
||||
- @trigger.dev/sdk@2.2.4
|
||||
- @trigger.dev/integration-kit@2.2.4
|
||||
|
||||
## 2.2.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@trigger.dev/resend",
|
||||
"version": "2.2.3",
|
||||
"version": "2.2.4",
|
||||
"description": "The official Resend.com integration for Trigger.dev",
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
@@ -24,8 +24,8 @@
|
||||
"build:tsup": "tsup"
|
||||
},
|
||||
"dependencies": {
|
||||
"@trigger.dev/integration-kit": "workspace:^2.2.3",
|
||||
"@trigger.dev/sdk": "workspace:^2.2.3",
|
||||
"@trigger.dev/integration-kit": "workspace:^2.2.4",
|
||||
"@trigger.dev/sdk": "workspace:^2.2.4",
|
||||
"resend": "^1.0.0"
|
||||
},
|
||||
"engines": {
|
||||
|
||||
@@ -1,5 +1,14 @@
|
||||
# @trigger.dev/sendgrid
|
||||
|
||||
## 2.2.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [c1710ae7]
|
||||
- Updated dependencies [9c4be40a]
|
||||
- @trigger.dev/sdk@2.2.4
|
||||
- @trigger.dev/integration-kit@2.2.4
|
||||
|
||||
## 2.2.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@trigger.dev/sendgrid",
|
||||
"version": "2.2.3",
|
||||
"version": "2.2.4",
|
||||
"description": "Trigger.dev integration for @sendgrid/mail",
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
@@ -27,8 +27,8 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@sendgrid/mail": "^7.7.0",
|
||||
"@trigger.dev/sdk": "workspace:^2.2.3",
|
||||
"@trigger.dev/integration-kit": "workspace:^2.2.3"
|
||||
"@trigger.dev/sdk": "workspace:^2.2.4",
|
||||
"@trigger.dev/integration-kit": "workspace:^2.2.4"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=16.8.0"
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
# @trigger.dev/slack
|
||||
|
||||
## 2.2.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [c1710ae7]
|
||||
- Updated dependencies [9c4be40a]
|
||||
- @trigger.dev/sdk@2.2.4
|
||||
|
||||
## 2.2.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@trigger.dev/slack",
|
||||
"version": "2.2.3",
|
||||
"version": "2.2.4",
|
||||
"description": "The official Slack integration for Trigger.dev",
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
@@ -25,7 +25,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@slack/web-api": "^6.8.1",
|
||||
"@trigger.dev/sdk": "workspace:^2.2.3",
|
||||
"@trigger.dev/sdk": "workspace:^2.2.4",
|
||||
"zod": "3.22.3"
|
||||
},
|
||||
"engines": {
|
||||
|
||||
@@ -1,5 +1,14 @@
|
||||
# @trigger.dev/stripe
|
||||
|
||||
## 2.2.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [c1710ae7]
|
||||
- Updated dependencies [9c4be40a]
|
||||
- @trigger.dev/sdk@2.2.4
|
||||
- @trigger.dev/integration-kit@2.2.4
|
||||
|
||||
## 2.2.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@trigger.dev/stripe",
|
||||
"version": "2.2.3",
|
||||
"version": "2.2.4",
|
||||
"description": "Trigger.dev integration for stripe",
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
@@ -26,8 +26,8 @@
|
||||
"typecheck": "tsc --noEmit"
|
||||
},
|
||||
"dependencies": {
|
||||
"@trigger.dev/integration-kit": "workspace:^2.2.3",
|
||||
"@trigger.dev/sdk": "workspace:^2.2.3",
|
||||
"@trigger.dev/integration-kit": "workspace:^2.2.4",
|
||||
"@trigger.dev/sdk": "workspace:^2.2.4",
|
||||
"stripe": "^12.14.0",
|
||||
"zod": "3.22.3"
|
||||
},
|
||||
|
||||
@@ -1,5 +1,14 @@
|
||||
# @trigger.dev/supabase
|
||||
|
||||
## 2.2.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [c1710ae7]
|
||||
- Updated dependencies [9c4be40a]
|
||||
- @trigger.dev/sdk@2.2.4
|
||||
- @trigger.dev/integration-kit@2.2.4
|
||||
|
||||
## 2.2.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@trigger.dev/supabase",
|
||||
"version": "2.2.3",
|
||||
"version": "2.2.4",
|
||||
"description": "Trigger.dev integration for @supabase/supabase-js",
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
@@ -27,8 +27,8 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@supabase/supabase-js": "^2.26.0",
|
||||
"@trigger.dev/integration-kit": "workspace:^2.2.3",
|
||||
"@trigger.dev/sdk": "workspace:^2.2.3",
|
||||
"@trigger.dev/integration-kit": "workspace:^2.2.4",
|
||||
"@trigger.dev/sdk": "workspace:^2.2.4",
|
||||
"supabase-management-js": "^0.1.4",
|
||||
"zod": "3.22.3"
|
||||
},
|
||||
|
||||
@@ -1,5 +1,14 @@
|
||||
# @trigger.dev/typeform
|
||||
|
||||
## 2.2.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [c1710ae7]
|
||||
- Updated dependencies [9c4be40a]
|
||||
- @trigger.dev/sdk@2.2.4
|
||||
- @trigger.dev/integration-kit@2.2.4
|
||||
|
||||
## 2.2.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@trigger.dev/typeform",
|
||||
"version": "2.2.3",
|
||||
"version": "2.2.4",
|
||||
"description": "The official Typeform integration for Trigger.dev",
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
@@ -25,8 +25,8 @@
|
||||
"typecheck": "tsc --noEmit"
|
||||
},
|
||||
"dependencies": {
|
||||
"@trigger.dev/integration-kit": "workspace:^2.2.3",
|
||||
"@trigger.dev/sdk": "workspace:^2.2.3",
|
||||
"@trigger.dev/integration-kit": "workspace:^2.2.4",
|
||||
"@trigger.dev/sdk": "workspace:^2.2.4",
|
||||
"@typeform/api-client": "^1.8.0",
|
||||
"zod": "3.22.3"
|
||||
},
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
# @trigger.dev/astro
|
||||
|
||||
## 2.2.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [c1710ae7]
|
||||
- Updated dependencies [9c4be40a]
|
||||
- @trigger.dev/sdk@2.2.4
|
||||
|
||||
## 2.2.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@trigger.dev/astro",
|
||||
"description": "An Astro-native integration for Trigger.dev background jobs platform",
|
||||
"version": "2.2.3",
|
||||
"version": "2.2.4",
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
"files": [
|
||||
@@ -20,7 +20,7 @@
|
||||
"build:tsup": "tsup"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@trigger.dev/sdk": "workspace:^2.2.3"
|
||||
"@trigger.dev/sdk": "workspace:^2.2.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"astro": "^3.0.12",
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
# create-trigger
|
||||
|
||||
## 2.2.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 0876b875: Added new example job which uses Tasks
|
||||
- Updated dependencies [c1710ae7]
|
||||
- @trigger.dev/core@2.2.4
|
||||
|
||||
## 2.2.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@trigger.dev/cli",
|
||||
"version": "2.2.3",
|
||||
"version": "2.2.4",
|
||||
"description": "The Trigger.dev CLI",
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
|
||||
@@ -2,9 +2,9 @@ import { eventTrigger } from "@trigger.dev/sdk";
|
||||
import { client } from "${jobsPathPrefix}trigger";
|
||||
|
||||
// Your first job
|
||||
// This Job will be triggered by an event, log a joke to the console, and then wait 5 seconds before logging the punchline
|
||||
// This Job will be triggered by an event, log a joke to the console, and then wait 5 seconds before logging the punchline.
|
||||
client.defineJob({
|
||||
// This is the unique identifier for your Job, it must be unique across all Jobs in your project
|
||||
// This is the unique identifier for your Job, it must be unique across all Jobs in your project.
|
||||
id: "example-job",
|
||||
name: "Example Job: a joke with a delay",
|
||||
version: "0.0.1",
|
||||
@@ -13,12 +13,29 @@ client.defineJob({
|
||||
name: "example.event",
|
||||
}),
|
||||
run: async (payload, io, ctx) => {
|
||||
// This logs a message to the console
|
||||
await io.logger.info("🧪 Example Job: a joke with a delay");
|
||||
await io.logger.info("How do you comfort a JavaScript bug?");
|
||||
// This waits for 5 seconds, the second parameter is the number of seconds to wait, you can add delays of up to a year
|
||||
// Use a Task to generate a random number. Using a Tasks means it only runs once.
|
||||
const result = await io.runTask("generate-random-number", async () => {
|
||||
return {
|
||||
num: Math.floor(Math.random() * 10000),
|
||||
};
|
||||
});
|
||||
|
||||
// Use the random number in a joke and log it to the console.
|
||||
await io.logger.info(`Why was the number ${result.num} afraid of the number 7?`);
|
||||
|
||||
// Wait for 5 seconds, the second parameter is the number of seconds to wait, you can add delays of up to a year.
|
||||
await io.wait("Wait 5 seconds for the punchline...", 5);
|
||||
await io.logger.info("You console it! 🤦");
|
||||
|
||||
// Use a Task to display the answer. Tasks are important to use in all Jobs as they allow your Runs to resume again after e.g. a serverless function timeout. Learn more about Tasks in the docs: https://trigger.dev/docs/documentation/concepts/tasks
|
||||
await io.runTask(
|
||||
"task-example",
|
||||
async () => {
|
||||
return {
|
||||
foo: "bar",
|
||||
};
|
||||
},
|
||||
{ name: `Answer: Because 7,8,9! And ${result.num} was next 🤦` }
|
||||
);
|
||||
await io.logger.info(
|
||||
"✨ Congratulations, You just ran your first successful Trigger.dev Job! ✨"
|
||||
);
|
||||
|
||||
@@ -2,9 +2,9 @@ import { eventTrigger } from "@trigger.dev/sdk";
|
||||
import { client } from "${jobsPathPrefix}trigger";
|
||||
|
||||
// Your first job
|
||||
// This Job will be triggered by an event, log a joke to the console, and then wait 5 seconds before logging the punchline
|
||||
// This Job will be triggered by an event, log a joke to the console, and then wait 5 seconds before logging the punchline.
|
||||
client.defineJob({
|
||||
// This is the unique identifier for your Job, it must be unique across all Jobs in your project
|
||||
// This is the unique identifier for your Job, it must be unique across all Jobs in your project.
|
||||
id: "example-job",
|
||||
name: "Example Job: a joke with a delay",
|
||||
version: "0.0.1",
|
||||
@@ -13,15 +13,32 @@ client.defineJob({
|
||||
name: "example.event",
|
||||
}),
|
||||
run: async (payload, io, ctx) => {
|
||||
// This logs a message to the console
|
||||
await io.logger.info("🧪 Example Job: a joke with a delay");
|
||||
await io.logger.info("How do you comfort a JavaScript bug?");
|
||||
// This waits for 5 seconds, the second parameter is the number of seconds to wait, you can add delays of up to a year
|
||||
// Use a Task to generate a random number. Using a Tasks means it only runs once.
|
||||
const result = await io.runTask("generate-random-number", async () => {
|
||||
return {
|
||||
num: Math.floor(Math.random() * 10000),
|
||||
};
|
||||
});
|
||||
|
||||
// Use the random number in a joke and log it to the console.
|
||||
await io.logger.info(`Why was the number ${result.num} afraid of the number 7?`);
|
||||
|
||||
// Wait for 5 seconds, the second parameter is the number of seconds to wait, you can add delays of up to a year.
|
||||
await io.wait("Wait 5 seconds for the punchline...", 5);
|
||||
await io.logger.info("You console it! 🤦");
|
||||
|
||||
// Use a Task to display the answer. Tasks are important to use in all Jobs as they allow your Runs to resume again after e.g. a serverless function timeout. Learn more about Tasks in the docs: https://trigger.dev/docs/documentation/concepts/tasks
|
||||
await io.runTask(
|
||||
"task-example",
|
||||
async () => {
|
||||
return {
|
||||
foo: "bar",
|
||||
};
|
||||
},
|
||||
{ name: `Answer: Because 7,8,9! And ${result.num} was next 🤦` }
|
||||
);
|
||||
await io.logger.info(
|
||||
"✨ Congratulations, You just ran your first successful Trigger.dev Job! ✨"
|
||||
);
|
||||
// To learn how to write much more complex (and probably funnier) Jobs, check out our docs: https://trigger.dev/docs/documentation/guides/create-a-job
|
||||
},
|
||||
});
|
||||
});
|
||||
@@ -2,9 +2,9 @@ import { eventTrigger } from "@trigger.dev/sdk";
|
||||
import { client } from "${jobsPathPrefix}trigger.server";
|
||||
|
||||
// Your first job
|
||||
// This Job will be triggered by an event, log a joke to the console, and then wait 5 seconds before logging the punchline
|
||||
// This Job will be triggered by an event, log a joke to the console, and then wait 5 seconds before logging the punchline.
|
||||
export const job = client.defineJob({
|
||||
// This is the unique identifier for your Job, it must be unique across all Jobs in your project
|
||||
// This is the unique identifier for your Job, it must be unique across all Jobs in your project.
|
||||
id: "example-job",
|
||||
name: "Example Job: a joke with a delay",
|
||||
version: "0.0.1",
|
||||
@@ -13,12 +13,29 @@ export const job = client.defineJob({
|
||||
name: "example.event",
|
||||
}),
|
||||
run: async (payload, io, ctx) => {
|
||||
// This logs a message to the console
|
||||
await io.logger.info("🧪 Example Job: a joke with a delay");
|
||||
await io.logger.info("How do you comfort a JavaScript bug?");
|
||||
// This waits for 5 seconds, the second parameter is the number of seconds to wait, you can add delays of up to a year
|
||||
// Use a Task to generate a random number. Using a Tasks means it only runs once.
|
||||
const result = await io.runTask("generate-random-number", async () => {
|
||||
return {
|
||||
num: Math.floor(Math.random() * 10000),
|
||||
};
|
||||
});
|
||||
|
||||
// Use the random number in a joke and log it to the console.
|
||||
await io.logger.info(`Why was the number ${result.num} afraid of the number 7?`);
|
||||
|
||||
// Wait for 5 seconds, the second parameter is the number of seconds to wait, you can add delays of up to a year.
|
||||
await io.wait("Wait 5 seconds for the punchline...", 5);
|
||||
await io.logger.info("You console it! 🤦");
|
||||
|
||||
// Use a Task to display the answer. Tasks are important to use in all Jobs as they allow your Runs to resume again after e.g. a serverless function timeout. Learn more about Tasks in the docs: https://trigger.dev/docs/documentation/concepts/tasks
|
||||
await io.runTask(
|
||||
"task-example",
|
||||
async () => {
|
||||
return {
|
||||
foo: "bar",
|
||||
};
|
||||
},
|
||||
{ name: `Answer: Because 7,8,9! And ${result.num} was next 🤦` }
|
||||
);
|
||||
await io.logger.info(
|
||||
"✨ Congratulations, You just ran your first successful Trigger.dev Job! ✨"
|
||||
);
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
# @trigger.dev/core-backend
|
||||
|
||||
## 2.2.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- c1710ae7: Creates a new package @trigger.dev/core-backend that includes code shared between @trigger.dev/sdk and the Trigger.dev server
|
||||
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2023 Trigger.dev
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -0,0 +1,8 @@
|
||||
module.exports = {
|
||||
moduleFileExtensions: ["ts", "tsx", "js"],
|
||||
transform: {
|
||||
"^.+\\.(ts|tsx)$": "ts-jest",
|
||||
},
|
||||
testMatch: ["<rootDir>/test/**/*.ts?(x)", "<rootDir>/test/**/?(*.)+(spec|test).ts?(x)"],
|
||||
testEnvironment: "node",
|
||||
};
|
||||
@@ -0,0 +1,42 @@
|
||||
{
|
||||
"name": "@trigger.dev/core-backend",
|
||||
"version": "2.2.4",
|
||||
"description": "Core code used across `@trigger.dev/sdk` and Trigger.dev server",
|
||||
"license": "MIT",
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"exports": {
|
||||
".": {
|
||||
"import": "./dist/index.js",
|
||||
"require": "./dist/index.js"
|
||||
},
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"sideEffects": false,
|
||||
"scripts": {
|
||||
"clean": "rimraf dist",
|
||||
"build": "npm run clean && npm run build:tsup",
|
||||
"build:tsup": "tsup --dts-resolve",
|
||||
"typecheck": "tsc --noEmit",
|
||||
"test": "jest"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@trigger.dev/tsconfig": "workspace:*",
|
||||
"@types/jest": "^29.5.3",
|
||||
"@types/node": "18",
|
||||
"jest": "^29.6.2",
|
||||
"rimraf": "^3.0.2",
|
||||
"ts-jest": "^29.1.1",
|
||||
"tsup": "^7.1.0",
|
||||
"typescript": "^5.1.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18.0.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export * from "./bloom";
|
||||
@@ -0,0 +1,28 @@
|
||||
import { BloomFilter } from "../src";
|
||||
|
||||
describe("BloomFilter", () => {
|
||||
it("should be able to correct test for inclusion in the set", () => {
|
||||
const filter = new BloomFilter(1000);
|
||||
|
||||
filter.add("hello");
|
||||
filter.add("world");
|
||||
|
||||
expect(filter.test("hello")).toBe(true);
|
||||
expect(filter.test("world")).toBe(true);
|
||||
expect(filter.test("foo")).toBe(false);
|
||||
});
|
||||
|
||||
it("should be able to serialize and deserialize", () => {
|
||||
const filter = new BloomFilter(1000);
|
||||
|
||||
filter.add("hello");
|
||||
filter.add("world");
|
||||
|
||||
const serialized = filter.serialize();
|
||||
const deserialized = BloomFilter.deserialize(serialized, 1000);
|
||||
|
||||
expect(deserialized.test("hello")).toBe(true);
|
||||
expect(deserialized.test("world")).toBe(true);
|
||||
expect(deserialized.test("foo")).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"extends": "@trigger.dev/tsconfig/node18.json",
|
||||
"include": ["src/globals.d.ts", "./src/**/*.ts", "tsup.config.ts"],
|
||||
"compilerOptions": {
|
||||
"experimentalDecorators": true,
|
||||
"emitDecoratorMetadata": true,
|
||||
"declaration": false,
|
||||
"declarationMap": false
|
||||
},
|
||||
"exclude": ["node_modules"]
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"extends": "@trigger.dev/tsconfig/node18.json",
|
||||
"include": ["src/globals.d.ts", "./src/**/*.ts", "tsup.config.ts", "./test/**/*.ts"],
|
||||
"compilerOptions": {
|
||||
"experimentalDecorators": true,
|
||||
"emitDecoratorMetadata": true,
|
||||
"declaration": false,
|
||||
"declarationMap": false,
|
||||
"types": ["jest"]
|
||||
},
|
||||
"exclude": ["node_modules"]
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import { defineConfig } from "tsup";
|
||||
|
||||
export default defineConfig([
|
||||
{
|
||||
name: "main",
|
||||
config: "tsconfig.build.json",
|
||||
entry: ["./src/index.ts"],
|
||||
outDir: "./dist",
|
||||
platform: "neutral",
|
||||
format: ["cjs"],
|
||||
legacyOutput: true,
|
||||
sourcemap: true,
|
||||
clean: true,
|
||||
bundle: true,
|
||||
splitting: false,
|
||||
dts: true,
|
||||
external: ["http", "https", "util", "events", "tty", "os", "timers"],
|
||||
esbuildPlugins: [],
|
||||
},
|
||||
]);
|
||||
@@ -1,5 +1,11 @@
|
||||
# internal-platform
|
||||
|
||||
## 2.2.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- c1710ae7: Creates a new package @trigger.dev/core-backend that includes code shared between @trigger.dev/sdk and the Trigger.dev server
|
||||
|
||||
## 2.2.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@trigger.dev/core",
|
||||
"version": "2.2.3",
|
||||
"version": "2.2.4",
|
||||
"description": "Core code used across the Trigger.dev SDK and platform",
|
||||
"license": "MIT",
|
||||
"main": "./dist/index.js",
|
||||
|
||||
@@ -6,7 +6,6 @@ export * from "./retry";
|
||||
export * from "./replacements";
|
||||
export * from "./searchParams";
|
||||
export * from "./eventFilterMatches";
|
||||
export * from "./bloom";
|
||||
|
||||
export const API_VERSIONS = {
|
||||
LAZY_LOADED_CACHED_TASKS: "2023-09-29",
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
# @trigger.dev/eslint-plugin
|
||||
|
||||
## 2.2.4
|
||||
|
||||
## 2.2.3
|
||||
|
||||
## 2.2.2
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@trigger.dev/eslint-plugin",
|
||||
"version": "2.2.3",
|
||||
"version": "2.2.4",
|
||||
"description": "ESLint plugin with trigger.dev best practices",
|
||||
"keywords": [
|
||||
"eslint",
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
# @trigger.dev/express
|
||||
|
||||
## 2.2.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [c1710ae7]
|
||||
- Updated dependencies [9c4be40a]
|
||||
- @trigger.dev/sdk@2.2.4
|
||||
|
||||
## 2.2.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@trigger.dev/express",
|
||||
"version": "2.2.3",
|
||||
"version": "2.2.4",
|
||||
"description": "Official Express adapter for Trigger.dev",
|
||||
"license": "MIT",
|
||||
"main": "./dist/index.js",
|
||||
@@ -19,7 +19,7 @@
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@trigger.dev/sdk": "workspace:^2.2.3",
|
||||
"@trigger.dev/sdk": "workspace:^2.2.4",
|
||||
"@trigger.dev/tsconfig": "workspace:*",
|
||||
"@types/debug": "^4.1.7",
|
||||
"@types/express": "^4.17.13",
|
||||
@@ -33,7 +33,7 @@
|
||||
"build:tsup": "tsup"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@trigger.dev/sdk": "workspace:^2.2.3"
|
||||
"@trigger.dev/sdk": "workspace:^2.2.4"
|
||||
},
|
||||
"dependencies": {
|
||||
"debug": "^4.3.4",
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
# @trigger.dev/integration-kit
|
||||
|
||||
## 2.2.4
|
||||
|
||||
## 2.2.3
|
||||
|
||||
## 2.2.2
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@trigger.dev/integration-kit",
|
||||
"version": "2.2.3",
|
||||
"version": "2.2.4",
|
||||
"description": "Trigger.dev Integration Kit has helpers to make creating integrations easier",
|
||||
"license": "MIT",
|
||||
"main": "./dist/index.js",
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
# @trigger.dev/nestjs
|
||||
|
||||
## 2.2.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [c1710ae7]
|
||||
- Updated dependencies [9c4be40a]
|
||||
- @trigger.dev/sdk@2.2.4
|
||||
|
||||
## 2.2.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@trigger.dev/nestjs",
|
||||
"version": "2.2.3",
|
||||
"version": "2.2.4",
|
||||
"description": "Official NestJS adapter for Trigger.dev",
|
||||
"license": "MIT",
|
||||
"main": "./dist/index.js",
|
||||
@@ -19,7 +19,7 @@
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@trigger.dev/sdk": "workspace:^2.2.3",
|
||||
"@trigger.dev/sdk": "workspace:^2.2.4",
|
||||
"@trigger.dev/tsconfig": "workspace:*",
|
||||
"@types/debug": "^4.1.7",
|
||||
"@types/express": "^4.17.13",
|
||||
@@ -35,7 +35,7 @@
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@nestjs/common": ">=10.0.0",
|
||||
"@trigger.dev/sdk": "workspace:^2.2.3"
|
||||
"@trigger.dev/sdk": "workspace:^2.2.4"
|
||||
},
|
||||
"dependencies": {
|
||||
"@nestjs/common": "^10.2.4",
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
# @trigger.dev/nextjs
|
||||
|
||||
## 2.2.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [c1710ae7]
|
||||
- Updated dependencies [9c4be40a]
|
||||
- @trigger.dev/sdk@2.2.4
|
||||
|
||||
## 2.2.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@trigger.dev/nextjs",
|
||||
"version": "2.2.3",
|
||||
"version": "2.2.4",
|
||||
"description": "Trigger.dev Next.js integration",
|
||||
"license": "MIT",
|
||||
"main": "./dist/index.js",
|
||||
@@ -36,7 +36,7 @@
|
||||
"build:tsup": "tsup"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@trigger.dev/sdk": "workspace:^2.2.3",
|
||||
"@trigger.dev/sdk": "workspace:^2.2.4",
|
||||
"next": ">=12.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
# @trigger.dev/react
|
||||
|
||||
## 2.2.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [c1710ae7]
|
||||
- @trigger.dev/core@2.2.4
|
||||
|
||||
## 2.2.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@trigger.dev/react",
|
||||
"version": "2.2.3",
|
||||
"version": "2.2.4",
|
||||
"description": "Trigger.dev React SDK",
|
||||
"license": "MIT",
|
||||
"types": "dist/index.d.ts",
|
||||
@@ -27,7 +27,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@tanstack/react-query": "5.0.0-beta.2",
|
||||
"@trigger.dev/core": "workspace:^2.2.3",
|
||||
"@trigger.dev/core": "workspace:^2.2.4",
|
||||
"debug": "^4.3.4",
|
||||
"zod": "3.22.3"
|
||||
},
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
# @trigger.dev/remix
|
||||
|
||||
## 2.2.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [c1710ae7]
|
||||
- Updated dependencies [9c4be40a]
|
||||
- @trigger.dev/sdk@2.2.4
|
||||
|
||||
## 2.2.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@trigger.dev/remix",
|
||||
"version": "2.2.3",
|
||||
"version": "2.2.4",
|
||||
"description": "Trigger.dev Remix integration",
|
||||
"license": "MIT",
|
||||
"main": "./dist/index.js",
|
||||
@@ -34,7 +34,7 @@
|
||||
"build:tsup": "tsup"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@trigger.dev/sdk": "workspace:^2.2.3",
|
||||
"@trigger.dev/sdk": "workspace:^2.2.4",
|
||||
"@remix-run/server-runtime": ">1.19.0"
|
||||
},
|
||||
"dependencies": {
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
# @trigger.dev/sveltekit
|
||||
|
||||
## 2.2.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [c1710ae7]
|
||||
- Updated dependencies [9c4be40a]
|
||||
- @trigger.dev/sdk@2.2.4
|
||||
|
||||
## 2.2.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@trigger.dev/sveltekit",
|
||||
"version": "2.2.3",
|
||||
"version": "2.2.4",
|
||||
"description": "Trigger.dev svelteKit integration",
|
||||
"license": "MIT",
|
||||
"main": "./dist/index.js",
|
||||
@@ -33,7 +33,7 @@
|
||||
"build:tsup": "tsup"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@trigger.dev/sdk": "workspace:^2.2.3"
|
||||
"@trigger.dev/sdk": "workspace:^2.2.4"
|
||||
},
|
||||
"dependencies": {
|
||||
"debug": "^4.3.4"
|
||||
|
||||
@@ -1,5 +1,14 @@
|
||||
# @trigger.dev/testing
|
||||
|
||||
## 2.2.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [c1710ae7]
|
||||
- Updated dependencies [9c4be40a]
|
||||
- @trigger.dev/sdk@2.2.4
|
||||
- @trigger.dev/core@2.2.4
|
||||
|
||||
## 2.2.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@trigger.dev/testing",
|
||||
"description": "A collection of useful tools to write tests for Trigger.dev.",
|
||||
"version": "2.2.3",
|
||||
"version": "2.2.4",
|
||||
"license": "MIT",
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
|
||||
@@ -1,5 +1,15 @@
|
||||
# @trigger.dev/sdk
|
||||
|
||||
## 2.2.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- c1710ae7: Creates a new package @trigger.dev/core-backend that includes code shared between @trigger.dev/sdk and the Trigger.dev server
|
||||
- 9c4be40a: use idempotency-key as event-id for dynamic-trigger registrations
|
||||
- Updated dependencies [c1710ae7]
|
||||
- @trigger.dev/core-backend@2.2.4
|
||||
- @trigger.dev/core@2.2.4
|
||||
|
||||
## 2.2.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@trigger.dev/sdk",
|
||||
"version": "2.2.3",
|
||||
"version": "2.2.4",
|
||||
"description": "trigger.dev Node.JS SDK",
|
||||
"license": "MIT",
|
||||
"main": "./dist/index.js",
|
||||
@@ -25,7 +25,8 @@
|
||||
"typecheck": "tsc --noEmit"
|
||||
},
|
||||
"dependencies": {
|
||||
"@trigger.dev/core": "workspace:^2.2.3",
|
||||
"@trigger.dev/core": "workspace:^2.2.4",
|
||||
"@trigger.dev/core-backend": "workspace:^2.2.4",
|
||||
"chalk": "^5.2.0",
|
||||
"cronstrue": "^2.21.0",
|
||||
"debug": "^4.3.4",
|
||||
|
||||
@@ -289,7 +289,8 @@ export class ApiClient {
|
||||
client: string,
|
||||
id: string,
|
||||
key: string,
|
||||
payload: RegisterTriggerBodyV2
|
||||
payload: RegisterTriggerBodyV2,
|
||||
idempotencyKey?: string
|
||||
): Promise<RegisterSourceEventV2> {
|
||||
const apiKey = await this.#apiKey();
|
||||
|
||||
@@ -298,15 +299,21 @@ export class ApiClient {
|
||||
payload,
|
||||
});
|
||||
|
||||
const headers: HeadersInit = {
|
||||
"Content-Type": "application/json",
|
||||
Authorization: `Bearer ${apiKey}`,
|
||||
};
|
||||
|
||||
if (idempotencyKey) {
|
||||
headers["Idempotency-Key"] = idempotencyKey;
|
||||
}
|
||||
|
||||
const response = await zodfetch(
|
||||
RegisterSourceEventSchemaV2,
|
||||
`${this.#apiUrl}/api/v2/${client}/triggers/${id}/registrations/${key}`,
|
||||
{
|
||||
method: "PUT",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Authorization: `Bearer ${apiKey}`,
|
||||
},
|
||||
headers: headers,
|
||||
body: JSON.stringify(payload),
|
||||
}
|
||||
);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import {
|
||||
API_VERSIONS,
|
||||
BloomFilter,
|
||||
CachedTask,
|
||||
ConnectionAuth,
|
||||
CronOptions,
|
||||
@@ -19,6 +18,7 @@ import {
|
||||
UpdateTriggerSourceBodyV2,
|
||||
supportsFeature,
|
||||
} from "@trigger.dev/core";
|
||||
import { BloomFilter } from "@trigger.dev/core-backend";
|
||||
import { AsyncLocalStorage } from "node:async_hooks";
|
||||
import { webcrypto } from "node:crypto";
|
||||
import { ApiClient } from "./apiClient";
|
||||
|
||||
@@ -623,8 +623,13 @@ export class TriggerClient {
|
||||
this.#registeredSchedules[key] = jobs;
|
||||
}
|
||||
|
||||
async registerTrigger(id: string, key: string, options: RegisterTriggerBodyV2) {
|
||||
return this.#client.registerTrigger(this.id, id, key, options);
|
||||
async registerTrigger(
|
||||
id: string,
|
||||
key: string,
|
||||
options: RegisterTriggerBodyV2,
|
||||
idempotencyKey?: string
|
||||
) {
|
||||
return this.#client.registerTrigger(this.id, id, key, options, idempotencyKey);
|
||||
}
|
||||
|
||||
async getAuth(id: string) {
|
||||
|
||||
@@ -140,7 +140,8 @@ export class DynamicTrigger<
|
||||
return this.#client.registerTrigger(
|
||||
this.id,
|
||||
key,
|
||||
this.registeredTriggerForParams(params, options)
|
||||
this.registeredTriggerForParams(params, options),
|
||||
task.idempotencyKey
|
||||
);
|
||||
},
|
||||
{
|
||||
|
||||
@@ -6,7 +6,9 @@
|
||||
"emitDecoratorMetadata": true,
|
||||
"paths": {
|
||||
"@trigger.dev/core/*": ["../core/src/*"],
|
||||
"@trigger.dev/core": ["../core/src/index"]
|
||||
"@trigger.dev/core": ["../core/src/index"],
|
||||
"@trigger.dev/core-backend/*": ["../core-backend/src/*"],
|
||||
"@trigger.dev/core-backend": ["../core-backend/src/index"]
|
||||
},
|
||||
"lib": ["DOM", "DOM.Iterable"],
|
||||
"declaration": false,
|
||||
|
||||
Generated
+177
-28
@@ -107,6 +107,7 @@ importers:
|
||||
'@total-typescript/ts-reset': ^0.4.2
|
||||
'@trigger.dev/companyicons': ^1.5.14
|
||||
'@trigger.dev/core': workspace:*
|
||||
'@trigger.dev/core-backend': workspace:*
|
||||
'@trigger.dev/database': workspace:*
|
||||
'@trigger.dev/sdk': workspace:*
|
||||
'@trigger.dev/tailwind-config': workspace:*
|
||||
@@ -121,6 +122,7 @@ importers:
|
||||
'@types/morgan': ^1.9.3
|
||||
'@types/node': ^18.11.15
|
||||
'@types/node-fetch': ^2.6.2
|
||||
'@types/pg': 8.6.6
|
||||
'@types/prismjs': ^1.26.0
|
||||
'@types/qs': ^6.9.7
|
||||
'@types/react': 18.2.17
|
||||
@@ -234,8 +236,10 @@ importers:
|
||||
'@team-plain/typescript-sdk': 2.2.0
|
||||
'@trigger.dev/companyicons': 1.5.14_biqbaboplfbrettd7655fr4n2y
|
||||
'@trigger.dev/core': link:../../packages/core
|
||||
'@trigger.dev/core-backend': link:../../packages/core-backend
|
||||
'@trigger.dev/database': link:../../packages/database
|
||||
'@trigger.dev/sdk': link:../../packages/trigger-sdk
|
||||
'@types/pg': 8.6.6
|
||||
'@uiw/react-codemirror': 4.19.5_th22fcplkuhrqjnlojwclcaim4
|
||||
class-variance-authority: 0.5.2_typescript@5.2.2
|
||||
clsx: 1.2.1
|
||||
@@ -378,8 +382,8 @@ importers:
|
||||
|
||||
integrations/airtable:
|
||||
specifiers:
|
||||
'@trigger.dev/integration-kit': workspace:^2.2.3
|
||||
'@trigger.dev/sdk': workspace:^2.2.3
|
||||
'@trigger.dev/integration-kit': workspace:^2.2.4
|
||||
'@trigger.dev/sdk': workspace:^2.2.4
|
||||
'@trigger.dev/tsconfig': workspace:*
|
||||
'@types/node': 16.x
|
||||
airtable: ^0.12.1
|
||||
@@ -406,8 +410,8 @@ importers:
|
||||
'@octokit/types': ^9.2.3
|
||||
'@octokit/webhooks': ^10.4.0
|
||||
'@octokit/webhooks-types': ^6.10.0
|
||||
'@trigger.dev/integration-kit': workspace:^2.2.3
|
||||
'@trigger.dev/sdk': workspace:^2.2.3
|
||||
'@trigger.dev/integration-kit': workspace:^2.2.4
|
||||
'@trigger.dev/sdk': workspace:^2.2.4
|
||||
'@trigger.dev/tsconfig': workspace:*
|
||||
'@types/node': '18'
|
||||
octokit: ^2.0.14
|
||||
@@ -433,8 +437,8 @@ importers:
|
||||
integrations/linear:
|
||||
specifiers:
|
||||
'@linear/sdk': ^8.0.0
|
||||
'@trigger.dev/integration-kit': workspace:^2.2.3
|
||||
'@trigger.dev/sdk': workspace:^2.2.3
|
||||
'@trigger.dev/integration-kit': workspace:^2.2.4
|
||||
'@trigger.dev/sdk': workspace:^2.2.4
|
||||
'@trigger.dev/tsconfig': workspace:*
|
||||
'@types/node': 16.x
|
||||
rimraf: ^3.0.2
|
||||
@@ -455,8 +459,8 @@ importers:
|
||||
|
||||
integrations/openai:
|
||||
specifiers:
|
||||
'@trigger.dev/integration-kit': workspace:^2.2.3
|
||||
'@trigger.dev/sdk': workspace:^2.2.3
|
||||
'@trigger.dev/integration-kit': workspace:^2.2.4
|
||||
'@trigger.dev/sdk': workspace:^2.2.4
|
||||
'@trigger.dev/tsconfig': workspace:*
|
||||
'@types/node': '18'
|
||||
openai: ^4.13.0
|
||||
@@ -477,8 +481,8 @@ importers:
|
||||
integrations/plain:
|
||||
specifiers:
|
||||
'@team-plain/typescript-sdk': ^2.7.0
|
||||
'@trigger.dev/integration-kit': workspace:^2.2.3
|
||||
'@trigger.dev/sdk': workspace:^2.2.3
|
||||
'@trigger.dev/integration-kit': workspace:^2.2.4
|
||||
'@trigger.dev/sdk': workspace:^2.2.4
|
||||
'@trigger.dev/tsconfig': workspace:*
|
||||
'@types/node': '18'
|
||||
rimraf: ^3.0.2
|
||||
@@ -495,8 +499,8 @@ importers:
|
||||
|
||||
integrations/replicate:
|
||||
specifiers:
|
||||
'@trigger.dev/integration-kit': workspace:^2.2.3
|
||||
'@trigger.dev/sdk': workspace:^2.2.3
|
||||
'@trigger.dev/integration-kit': workspace:^2.2.4
|
||||
'@trigger.dev/sdk': workspace:^2.2.4
|
||||
'@trigger.dev/tsconfig': workspace:*
|
||||
'@types/node': 16.x
|
||||
replicate: ^0.18.1
|
||||
@@ -518,8 +522,8 @@ importers:
|
||||
|
||||
integrations/resend:
|
||||
specifiers:
|
||||
'@trigger.dev/integration-kit': workspace:^2.2.3
|
||||
'@trigger.dev/sdk': workspace:^2.2.3
|
||||
'@trigger.dev/integration-kit': workspace:^2.2.4
|
||||
'@trigger.dev/sdk': workspace:^2.2.4
|
||||
'@trigger.dev/tsconfig': workspace:*
|
||||
'@types/node': '18'
|
||||
resend: ^1.0.0
|
||||
@@ -538,8 +542,8 @@ importers:
|
||||
integrations/sendgrid:
|
||||
specifiers:
|
||||
'@sendgrid/mail': ^7.7.0
|
||||
'@trigger.dev/integration-kit': workspace:^2.2.3
|
||||
'@trigger.dev/sdk': workspace:^2.2.3
|
||||
'@trigger.dev/integration-kit': workspace:^2.2.4
|
||||
'@trigger.dev/sdk': workspace:^2.2.4
|
||||
'@trigger.dev/tsconfig': workspace:*
|
||||
'@types/node': 16.x
|
||||
rimraf: ^3.0.2
|
||||
@@ -559,7 +563,7 @@ importers:
|
||||
integrations/slack:
|
||||
specifiers:
|
||||
'@slack/web-api': ^6.8.1
|
||||
'@trigger.dev/sdk': workspace:^2.2.3
|
||||
'@trigger.dev/sdk': workspace:^2.2.4
|
||||
'@trigger.dev/tsconfig': workspace:*
|
||||
'@types/node': '18'
|
||||
rimraf: ^3.0.2
|
||||
@@ -577,8 +581,8 @@ importers:
|
||||
|
||||
integrations/stripe:
|
||||
specifiers:
|
||||
'@trigger.dev/integration-kit': workspace:^2.2.3
|
||||
'@trigger.dev/sdk': workspace:^2.2.3
|
||||
'@trigger.dev/integration-kit': workspace:^2.2.4
|
||||
'@trigger.dev/sdk': workspace:^2.2.4
|
||||
'@types/node': 16.x
|
||||
rimraf: ^3.0.2
|
||||
stripe: ^12.14.0
|
||||
@@ -601,8 +605,8 @@ importers:
|
||||
integrations/supabase:
|
||||
specifiers:
|
||||
'@supabase/supabase-js': ^2.26.0
|
||||
'@trigger.dev/integration-kit': workspace:^2.2.3
|
||||
'@trigger.dev/sdk': workspace:^2.2.3
|
||||
'@trigger.dev/integration-kit': workspace:^2.2.4
|
||||
'@trigger.dev/sdk': workspace:^2.2.4
|
||||
'@trigger.dev/tsconfig': workspace:*
|
||||
'@types/node': 18.x
|
||||
rimraf: ^3.0.2
|
||||
@@ -625,8 +629,8 @@ importers:
|
||||
|
||||
integrations/typeform:
|
||||
specifiers:
|
||||
'@trigger.dev/integration-kit': workspace:^2.2.3
|
||||
'@trigger.dev/sdk': workspace:^2.2.3
|
||||
'@trigger.dev/integration-kit': workspace:^2.2.4
|
||||
'@trigger.dev/sdk': workspace:^2.2.4
|
||||
'@typeform/api-client': ^1.8.0
|
||||
'@types/node': 16.x
|
||||
rimraf: ^3.0.2
|
||||
@@ -781,6 +785,26 @@ importers:
|
||||
tsup: 7.1.0_typescript@4.9.5
|
||||
typescript: 4.9.5
|
||||
|
||||
packages/core-backend:
|
||||
specifiers:
|
||||
'@trigger.dev/tsconfig': workspace:*
|
||||
'@types/jest': ^29.5.3
|
||||
'@types/node': '18'
|
||||
jest: ^29.6.2
|
||||
rimraf: ^3.0.2
|
||||
ts-jest: ^29.1.1
|
||||
tsup: ^7.1.0
|
||||
typescript: ^5.1.0
|
||||
devDependencies:
|
||||
'@trigger.dev/tsconfig': link:../../config-packages/tsconfig
|
||||
'@types/jest': 29.5.3
|
||||
'@types/node': 18.17.1
|
||||
jest: 29.6.2_@types+node@18.17.1
|
||||
rimraf: 3.0.2
|
||||
ts-jest: 29.1.1_uvjn2wawyirmlmi655a42v3ske
|
||||
tsup: 7.2.0_typescript@5.2.2
|
||||
typescript: 5.2.2
|
||||
|
||||
packages/database:
|
||||
specifiers:
|
||||
'@prisma/client': 5.4.1
|
||||
@@ -860,7 +884,7 @@ importers:
|
||||
|
||||
packages/express:
|
||||
specifiers:
|
||||
'@trigger.dev/sdk': workspace:^2.2.3
|
||||
'@trigger.dev/sdk': workspace:^2.2.4
|
||||
'@trigger.dev/tsconfig': workspace:*
|
||||
'@types/debug': ^4.1.7
|
||||
'@types/express': ^4.17.13
|
||||
@@ -906,7 +930,7 @@ importers:
|
||||
specifiers:
|
||||
'@nestjs/common': ^10.2.4
|
||||
'@remix-run/web-fetch': ^4.3.5
|
||||
'@trigger.dev/sdk': workspace:^2.2.3
|
||||
'@trigger.dev/sdk': workspace:^2.2.4
|
||||
'@trigger.dev/tsconfig': workspace:*
|
||||
'@types/debug': ^4.1.7
|
||||
'@types/express': ^4.17.13
|
||||
@@ -959,7 +983,7 @@ importers:
|
||||
packages/react:
|
||||
specifiers:
|
||||
'@tanstack/react-query': 5.0.0-beta.2
|
||||
'@trigger.dev/core': workspace:^2.2.3
|
||||
'@trigger.dev/core': workspace:^2.2.4
|
||||
'@trigger.dev/tsconfig': workspace:*
|
||||
'@types/debug': ^4.1.7
|
||||
'@types/react': 18.2.17
|
||||
@@ -1054,7 +1078,8 @@ importers:
|
||||
|
||||
packages/trigger-sdk:
|
||||
specifiers:
|
||||
'@trigger.dev/core': workspace:^2.2.3
|
||||
'@trigger.dev/core': workspace:^2.2.4
|
||||
'@trigger.dev/core-backend': workspace:^2.2.4
|
||||
'@trigger.dev/tsconfig': workspace:*
|
||||
'@types/debug': ^4.1.7
|
||||
'@types/node': '18'
|
||||
@@ -1081,6 +1106,7 @@ importers:
|
||||
zod: 3.22.3
|
||||
dependencies:
|
||||
'@trigger.dev/core': link:../core
|
||||
'@trigger.dev/core-backend': link:../core-backend
|
||||
chalk: 5.2.0
|
||||
cronstrue: 2.21.0
|
||||
debug: 4.3.4
|
||||
@@ -22544,6 +22570,35 @@ packages:
|
||||
- ts-node
|
||||
dev: true
|
||||
|
||||
/jest-cli/29.6.2_@types+node@18.17.1:
|
||||
resolution: {integrity: sha512-TT6O247v6dCEX2UGHGyflMpxhnrL0DNqP2fRTKYm3nJJpCTfXX3GCMQPGFjXDoj0i5/Blp3jriKXFgdfmbYB6Q==}
|
||||
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
|
||||
hasBin: true
|
||||
peerDependencies:
|
||||
node-notifier: ^8.0.1 || ^9.0.0 || ^10.0.0
|
||||
peerDependenciesMeta:
|
||||
node-notifier:
|
||||
optional: true
|
||||
dependencies:
|
||||
'@jest/core': 29.6.2
|
||||
'@jest/test-result': 29.6.2
|
||||
'@jest/types': 29.6.1
|
||||
chalk: 4.1.2
|
||||
exit: 0.1.2
|
||||
graceful-fs: 4.2.10
|
||||
import-local: 3.1.0
|
||||
jest-config: 29.6.2_@types+node@18.17.1
|
||||
jest-util: 29.6.2
|
||||
jest-validate: 29.6.2
|
||||
prompts: 2.4.2
|
||||
yargs: 17.7.2
|
||||
transitivePeerDependencies:
|
||||
- '@types/node'
|
||||
- babel-plugin-macros
|
||||
- supports-color
|
||||
- ts-node
|
||||
dev: true
|
||||
|
||||
/jest-config/29.6.2_@types+node@16.18.11:
|
||||
resolution: {integrity: sha512-VxwFOC8gkiJbuodG9CPtMRjBUNZEHxwfQXmIudSTzFWxaci3Qub1ddTRbFNQlD/zUeaifLndh/eDccFX4wCMQw==}
|
||||
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
|
||||
@@ -22584,6 +22639,46 @@ packages:
|
||||
- supports-color
|
||||
dev: true
|
||||
|
||||
/jest-config/29.6.2_@types+node@18.17.1:
|
||||
resolution: {integrity: sha512-VxwFOC8gkiJbuodG9CPtMRjBUNZEHxwfQXmIudSTzFWxaci3Qub1ddTRbFNQlD/zUeaifLndh/eDccFX4wCMQw==}
|
||||
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
|
||||
peerDependencies:
|
||||
'@types/node': '*'
|
||||
ts-node: '>=9.0.0'
|
||||
peerDependenciesMeta:
|
||||
'@types/node':
|
||||
optional: true
|
||||
ts-node:
|
||||
optional: true
|
||||
dependencies:
|
||||
'@babel/core': 7.22.17
|
||||
'@jest/test-sequencer': 29.6.2
|
||||
'@jest/types': 29.6.1
|
||||
'@types/node': 18.17.1
|
||||
babel-jest: 29.6.2_@babel+core@7.22.17
|
||||
chalk: 4.1.2
|
||||
ci-info: 3.8.0
|
||||
deepmerge: 4.3.1
|
||||
glob: 7.2.3
|
||||
graceful-fs: 4.2.10
|
||||
jest-circus: 29.6.2
|
||||
jest-environment-node: 29.6.2
|
||||
jest-get-type: 29.4.3
|
||||
jest-regex-util: 29.4.3
|
||||
jest-resolve: 29.6.2
|
||||
jest-runner: 29.6.2
|
||||
jest-util: 29.6.2
|
||||
jest-validate: 29.6.2
|
||||
micromatch: 4.0.5
|
||||
parse-json: 5.2.0
|
||||
pretty-format: 29.6.2
|
||||
slash: 3.0.0
|
||||
strip-json-comments: 3.1.1
|
||||
transitivePeerDependencies:
|
||||
- babel-plugin-macros
|
||||
- supports-color
|
||||
dev: true
|
||||
|
||||
/jest-config/29.6.2_@types+node@20.6.0:
|
||||
resolution: {integrity: sha512-VxwFOC8gkiJbuodG9CPtMRjBUNZEHxwfQXmIudSTzFWxaci3Qub1ddTRbFNQlD/zUeaifLndh/eDccFX4wCMQw==}
|
||||
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
|
||||
@@ -22964,6 +23059,27 @@ packages:
|
||||
- ts-node
|
||||
dev: true
|
||||
|
||||
/jest/29.6.2_@types+node@18.17.1:
|
||||
resolution: {integrity: sha512-8eQg2mqFbaP7CwfsTpCxQ+sHzw1WuNWL5UUvjnWP4hx2riGz9fPSzYOaU5q8/GqWn1TfgZIVTqYJygbGbWAANg==}
|
||||
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
|
||||
hasBin: true
|
||||
peerDependencies:
|
||||
node-notifier: ^8.0.1 || ^9.0.0 || ^10.0.0
|
||||
peerDependenciesMeta:
|
||||
node-notifier:
|
||||
optional: true
|
||||
dependencies:
|
||||
'@jest/core': 29.6.2
|
||||
'@jest/types': 29.6.1
|
||||
import-local: 3.1.0
|
||||
jest-cli: 29.6.2_@types+node@18.17.1
|
||||
transitivePeerDependencies:
|
||||
- '@types/node'
|
||||
- babel-plugin-macros
|
||||
- supports-color
|
||||
- ts-node
|
||||
dev: true
|
||||
|
||||
/jiti/1.18.2:
|
||||
resolution: {integrity: sha512-QAdOptna2NYiSSpv0O/BwoHBSmz4YhpzJHyi+fnMRTXFjp7B8i/YG5Z8IfusxB1ufjcD2Sre1F3R+nX3fvy7gg==}
|
||||
hasBin: true
|
||||
@@ -30183,6 +30299,39 @@ packages:
|
||||
/ts-interface-checker/0.1.13:
|
||||
resolution: {integrity: sha512-Y/arvbn+rrz3JCKl9C4kVNfTfSm2/mEp5FSz5EsZSANGPSlQrpRI5M4PKF+mJnE52jOO90PnPSc3Ur3bTQw0gA==}
|
||||
|
||||
/ts-jest/29.1.1_uvjn2wawyirmlmi655a42v3ske:
|
||||
resolution: {integrity: sha512-D6xjnnbP17cC85nliwGiL+tpoKN0StpgE0TeOjXQTU6MVCfsB4v7aW05CgQ/1OywGb0x/oy9hHFnN+sczTiRaA==}
|
||||
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
|
||||
hasBin: true
|
||||
peerDependencies:
|
||||
'@babel/core': '>=7.0.0-beta.0 <8'
|
||||
'@jest/types': ^29.0.0
|
||||
babel-jest: ^29.0.0
|
||||
esbuild: '*'
|
||||
jest: ^29.0.0
|
||||
typescript: '>=4.3 <6'
|
||||
peerDependenciesMeta:
|
||||
'@babel/core':
|
||||
optional: true
|
||||
'@jest/types':
|
||||
optional: true
|
||||
babel-jest:
|
||||
optional: true
|
||||
esbuild:
|
||||
optional: true
|
||||
dependencies:
|
||||
bs-logger: 0.2.6
|
||||
fast-json-stable-stringify: 2.1.0
|
||||
jest: 29.6.2_@types+node@18.17.1
|
||||
jest-util: 29.6.2
|
||||
json5: 2.2.3
|
||||
lodash.memoize: 4.1.2
|
||||
make-error: 1.3.6
|
||||
semver: 7.5.4
|
||||
typescript: 5.2.2
|
||||
yargs-parser: 21.1.1
|
||||
dev: true
|
||||
|
||||
/ts-jest/29.1.1_xlkreayjyan5lfqjb5gzdqf3my:
|
||||
resolution: {integrity: sha512-D6xjnnbP17cC85nliwGiL+tpoKN0StpgE0TeOjXQTU6MVCfsB4v7aW05CgQ/1OywGb0x/oy9hHFnN+sczTiRaA==}
|
||||
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
|
||||
@@ -30685,7 +30834,7 @@ packages:
|
||||
joycon: 3.1.1
|
||||
postcss-load-config: 4.0.1
|
||||
resolve-from: 5.0.0
|
||||
rollup: 3.10.0
|
||||
rollup: 3.29.1
|
||||
source-map: 0.8.0-beta.0
|
||||
sucrase: 3.32.0
|
||||
tree-kill: 1.2.2
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
"replicate": "nodemon --watch src/replicate.ts -r tsconfig-paths/register -r dotenv/config src/replicate.ts",
|
||||
"misconfigured": "nodemon --watch src/misconfigured.ts -r tsconfig-paths/register -r dotenv/config src/misconfigured.ts",
|
||||
"auto-yield": "nodemon --watch src/auto-yield.ts -r tsconfig-paths/register -r dotenv/config src/auto-yield.ts",
|
||||
"cli-example": "nodemon --watch src/cli-example.ts -r tsconfig-paths/register -r dotenv/config src/cli-example.ts",
|
||||
"dev:trigger": "trigger-cli dev --port 8080"
|
||||
},
|
||||
"dependencies": {
|
||||
@@ -62,4 +63,4 @@
|
||||
"ts-node": "^10.9.1",
|
||||
"tsconfig-paths": "^3.14.1"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { TriggerClient, eventTrigger } from "@trigger.dev/sdk";
|
||||
import { createExpressServer } from "@trigger.dev/express";
|
||||
import { z } from "zod";
|
||||
import { Airtable, Collaborator } from "@trigger.dev/airtable";
|
||||
import { Airtable, Collaborator, Formula } from "@trigger.dev/airtable";
|
||||
|
||||
export const client = new TriggerClient({
|
||||
id: "job-catalog",
|
||||
@@ -77,6 +77,55 @@ client.defineJob({
|
||||
},
|
||||
});
|
||||
|
||||
type Formulas = {
|
||||
ValueOne?: number;
|
||||
ValueTwo?: number;
|
||||
Division: Formula; // ValueOne / ValueTwo
|
||||
};
|
||||
|
||||
client.defineJob({
|
||||
id: "airtable-formulas",
|
||||
name: "Airtable Formulas",
|
||||
version: "0.1.0",
|
||||
trigger: eventTrigger({
|
||||
name: "airtable.formulas",
|
||||
schema: z.object({
|
||||
baseId: z.string(),
|
||||
tableName: z.string(),
|
||||
}),
|
||||
}),
|
||||
integrations: {
|
||||
airtable,
|
||||
},
|
||||
run: async (payload, io, ctx) => {
|
||||
const table = io.airtable.base(payload.baseId).table<Formulas>(payload.tableName);
|
||||
|
||||
const records = await table.getRecords("muliple records", {
|
||||
fields: ["ValueOne", "ValueTwo", "Division"],
|
||||
});
|
||||
|
||||
const divisionField = records[0].fields.Division;
|
||||
|
||||
if (typeof divisionField !== "object") {
|
||||
return records;
|
||||
}
|
||||
|
||||
if ("specialValue" in divisionField) {
|
||||
await io.logger.log(
|
||||
`Special value: ${divisionField.specialValue}${
|
||||
divisionField.specialValue === "Infinity" ? " - did you divide by zero?" : ""
|
||||
}`
|
||||
);
|
||||
} else if ("error" in divisionField) {
|
||||
await io.logger.error(`Error: ${divisionField.error}`);
|
||||
} else {
|
||||
await io.logger.warn("Unknown formula value!");
|
||||
}
|
||||
|
||||
return divisionField;
|
||||
},
|
||||
});
|
||||
|
||||
//todo webhooks require batch support
|
||||
// client.defineJob({
|
||||
// id: "airtable-delete-webhooks",
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
import { createExpressServer } from "@trigger.dev/express";
|
||||
import { TriggerClient, eventTrigger } from "@trigger.dev/sdk";
|
||||
|
||||
export const client = new TriggerClient({
|
||||
id: "job-catalog",
|
||||
apiKey: process.env["TRIGGER_API_KEY"],
|
||||
apiUrl: process.env["TRIGGER_API_URL"],
|
||||
verbose: false,
|
||||
ioLogLocalEnabled: true,
|
||||
});
|
||||
|
||||
// Your first job
|
||||
// This Job will be triggered by an event, log a joke to the console, and then wait 5 seconds before logging the punchline.
|
||||
client.defineJob({
|
||||
// This is the unique identifier for your Job, it must be unique across all Jobs in your project.
|
||||
id: "example-job",
|
||||
name: "Example Job: a joke with a delay",
|
||||
version: "0.0.1",
|
||||
// This is triggered by an event using eventTrigger. You can also trigger Jobs with webhooks, on schedules, and more: https://trigger.dev/docs/documentation/concepts/triggers/introduction
|
||||
trigger: eventTrigger({
|
||||
name: "example.event",
|
||||
}),
|
||||
run: async (payload, io, ctx) => {
|
||||
// Use a Task to generate a random number. Using a Tasks means it only runs once.
|
||||
const result = await io.runTask("generate-random-number", async () => {
|
||||
return {
|
||||
num: Math.floor(Math.random() * 10000),
|
||||
};
|
||||
});
|
||||
|
||||
// Use the random number in a joke and log it to the console.
|
||||
await io.logger.info(`Why was the number ${result.num} afraid of the number 7?`);
|
||||
|
||||
// Wait for 5 seconds, the second parameter is the number of seconds to wait, you can add delays of up to a year.
|
||||
await io.wait("Wait 5 seconds for the punchline...", 5);
|
||||
|
||||
// Use a Task to display the answer. Tasks are important to use in all Jobs as they allow your Runs to resume again after e.g. a serverless function timeout. Learn more about Tasks in the docs: https://trigger.dev/docs/documentation/concepts/tasks
|
||||
await io.runTask(
|
||||
"task-example",
|
||||
async () => {
|
||||
return {
|
||||
foo: "bar",
|
||||
};
|
||||
},
|
||||
{ name: `Answer: Because 7,8,9! And ${result.num} was next 🤦` }
|
||||
);
|
||||
await io.logger.info(
|
||||
"✨ Congratulations, You just ran your first successful Trigger.dev Job! ✨"
|
||||
);
|
||||
// To learn how to write much more complex (and probably funnier) Jobs, check out our docs: https://trigger.dev/docs/documentation/guides/create-a-job
|
||||
},
|
||||
});
|
||||
|
||||
createExpressServer(client);
|
||||
@@ -77,6 +77,28 @@ client.defineJob({
|
||||
},
|
||||
});
|
||||
|
||||
client.defineJob({
|
||||
id: "no-real-task",
|
||||
name: "No real Task",
|
||||
version: "0.0.1",
|
||||
trigger: eventTrigger({
|
||||
name: "no.real.task",
|
||||
schema: z.object({
|
||||
userId: z.string(),
|
||||
}),
|
||||
}),
|
||||
run: async (payload, io, ctx) => {
|
||||
await io.logger.info("Hello World", { ctx, payload });
|
||||
await io.wait("Wait 1 sec", 1);
|
||||
//this is a real task
|
||||
// await io.runTask("task-example-1", async () => {
|
||||
// return {
|
||||
// message: "Hello World",
|
||||
// };
|
||||
// });
|
||||
}
|
||||
});
|
||||
|
||||
client.defineJob({
|
||||
id: "cancel-runs-example",
|
||||
name: "Cancel Runs Example",
|
||||
|
||||
Reference in New Issue
Block a user