Deprecate old JS script block, mark new one as... well, new.

This commit is contained in:
Sam Rose 2025-01-14 17:09:35 +00:00
parent bf281fdff5
commit 96869c2b4d
No known key found for this signature in database
4 changed files with 24 additions and 2 deletions

View File

@ -186,6 +186,12 @@
</div>
{:else if isDisabled}
<Icon name="Help" tooltip={disabled()[idx].message} />
{:else if action.new}
<div class="tag-color">
<Tags>
<Tag>New</Tag>
</Tags>
</div>
{/if}
</div>
</div>

View File

@ -15,6 +15,7 @@ import { EventEmitter } from "events"
export const definition: AutomationStepDefinition = {
name: "JS Scripting",
deprecated: true,
tagline: "Execute JavaScript Code",
icon: "Code",
description: "Run a piece of JavaScript code in your automation",

View File

@ -12,12 +12,13 @@ import {
import { processStringSync } from "@budibase/string-templates"
export const definition: AutomationStepDefinition = {
name: "JS Scripting V2",
name: "JS Scripting",
tagline: "Execute JavaScript Code",
icon: "Code",
description: "Run a piece of JavaScript code in your automation",
type: AutomationStepType.ACTION,
internal: true,
new: true,
stepId: AutomationActionStepId.EXECUTE_SCRIPT_V2,
inputs: {},
features: {
@ -57,7 +58,9 @@ export async function run({
inputs: ExecuteScriptStepInputs
context: Record<string, any>
}): Promise<ExecuteScriptStepOutputs> {
if (inputs.code == null) {
let { code } = inputs
if (code == null) {
return {
success: false,
response: {
@ -66,6 +69,17 @@ export async function run({
}
}
code = code.trim()
if (!code.startsWith("{{ js ")) {
return {
success: false,
response: {
message: "Expected code to be a {{ js }} template block",
},
}
}
try {
return {
success: true,

View File

@ -154,6 +154,7 @@ export interface AutomationStepSchemaBase {
type: AutomationStepType
internal?: boolean
deprecated?: boolean
new?: boolean
blockToLoop?: string
schema: {
inputs: InputOutputBlock