@saanuregh/trigger-sdk
v0.5.3
Published
SDK for writing custom Trigger pipeline actions
Downloads
235
Maintainers
Readme
@saanuregh/trigger-sdk
SDK for writing custom Trigger pipeline actions.
Install
bun add @saanuregh/trigger-sdkUsage
Create a .ts file in your actions directory (default ./actions/):
import { defineAction, z } from "@saanuregh/trigger-sdk";
export default defineAction({
name: "slack-notify",
schema: z.object({
webhook_url: z.string().url(),
message: z.string(),
}).strict(),
handler: async (config, ctx) => {
ctx.log("sending notification");
const res = await fetch(config.webhook_url, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ text: config.message }),
signal: ctx.signal,
});
if (!res.ok) throw new Error(`Failed: ${res.status}`);
return { output: { ok: true } };
},
});Actions are auto-discovered at startup. See the examples for more.
