Skip to main content

lightyear.defineaction

Home > @runlightyear/lightyear > defineAction

defineAction() function

Define an Action

Signature:
declare function defineAction(props: DefineActionProps): string;

Parameters

ParameterTypeDescription
propsDefineActionProps
Returns:

string

Example 1

Hello World

import { defineAction } from "@runlightyear/lightyear";

defineAction({
name: "helloWorld",
title: "Hello World",
run: async () => {
console.log("Hello world");
},
});

Example 2

Variables

import { defineAction } from "@runlightyear/lightyear";

defineAction({
name: "actionWithVariables",
title: "Action with Variables",
variables: [
"var1",
"var2?",
{ name: "var3", description: "Required variable 3" },
{ name: "var4?", description: "Optional variable 4" },
],
run: async ({ variables }) => {
console.log("required variable", variables.var1);
console.log("optional variable", variables.var2);
console.log("variable with description", variables.var3);
console.log("optional variable with description", variables.var4);
},
});

Example 3

Secrets

import { defineAction } from "@runlightyear/lightyear";

defineAction({
name: "actionWithSecrets",
title: "Action with Secrets",
secrets: [
"secret1",
"secret2?",
{
name: "secret3",
description: "Required secret 3",
},
{
name: "secret4?",
description: "Optional secret 4",
},
],
run: async ({ secrets }) => {
console.log("required secret", secrets.secret1);
console.log("optional secret", secrets.secret2);
console.log("secret with description", secrets.secret3);
console.log("optional secret with description", secrets.secret4);
},
});