Package io.kestra.plugin.graalvm.js
Class FileTransform
java.lang.Object
io.kestra.core.models.tasks.Task
io.kestra.plugin.graalvm.AbstractFileTransform
io.kestra.plugin.graalvm.js.FileTransform
- All Implemented Interfaces:
io.kestra.core.models.Plugin,io.kestra.core.models.PluginVersioning,io.kestra.core.models.tasks.RunnableTask<AbstractFileTransform.Output>,io.kestra.core.models.tasks.TaskInterface,io.kestra.core.models.WorkerJobLifecycle
@Plugin(examples=@Example(full=true,code="id: transformJs\nnamespace: company.team\n\ntasks:\n - id: download\n type: io.kestra.plugin.core.http.Download\n uri: https://dummyjson.com/carts/1\n - id: jsonToIon\n type: io.kestra.plugin.serdes.json.JsonToIon\n from: \"{{outputs.download.uri}}\"\n - id: transformJs\n type: io.kestra.plugin.graalvm.js.FileTransform\n from: \"{{ outputs.jsonToIon.uri }}\"\n script: |\n if (row[\'id\'] === 666) {\n // remove un-needed row\n row = null\n } else {\n // remove the \'products\' column\n row[\'products\'] = null;\n // add a \'totalItems\' column\n row[\'totalItems\'] = row[\'totalProducts\'] * row[\'totalQuantity\']\n }\n"),
metrics=@Metric(name="records",type="counter",unit="count",description="Number of records or entities processed by the JavaScript script. This includes both modified and filtered rows from the input file."))
public class FileTransform
extends AbstractFileTransform
-
Nested Class Summary
Nested classes/interfaces inherited from class io.kestra.plugin.graalvm.AbstractFileTransform
AbstractFileTransform.OutputNested classes/interfaces inherited from class io.kestra.core.models.tasks.Task
io.kestra.core.models.tasks.Task.TaskBuilder<C extends io.kestra.core.models.tasks.Task,B extends io.kestra.core.models.tasks.Task.TaskBuilder<C, B>> -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected @NotNull io.kestra.core.models.property.Property<String> Fields inherited from class io.kestra.core.models.tasks.Task
disabled, id, retry, timeout, type, versionFields inherited from interface io.kestra.core.models.PluginVersioning
DESCRIPTION, TITLE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected org.graalvm.polyglot.ContextbuildContext(io.kestra.core.runners.RunContext runContext, OutputStream out, OutputStream err) protected org.graalvm.polyglot.Context.BuildercontextBuilder(io.kestra.core.runners.RunContext runContext) protected org.graalvm.polyglot.SourcegenerateSource(String languageId, io.kestra.core.runners.RunContext runContext) protected org.graalvm.polyglot.ValuegetBindings(org.graalvm.polyglot.Context context, String languageId) io.kestra.core.models.property.Property<String> run(io.kestra.core.runners.RunContext runContext) Methods inherited from class io.kestra.plugin.graalvm.AbstractFileTransform
runMethods inherited from class io.kestra.core.models.tasks.Task
findById, findById, getAssets, getDescription, getDisabled, getId, getLogLevel, getRetry, getRunIf, getTaskCache, getTimeout, getType, getVersion, getWorkerGroup, isAllowFailure, isAllowWarning, isFlowable, isLogToFile, isSendToWorkerTaskMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.kestra.core.models.WorkerJobLifecycle
kill, stop
-
Field Details
-
script
@NotNull @PluginProperty(group="main") protected @NotNull io.kestra.core.models.property.Property<String> script
-
-
Constructor Details
-
FileTransform
public FileTransform()
-
-
Method Details
-
getScript
@PluginProperty(language=JAVASCRIPT) public io.kestra.core.models.property.Property<String> getScript() -
run
public AbstractFileTransform.Output run(io.kestra.core.runners.RunContext runContext) throws Exception - Throws:
Exception
-
buildContext
protected org.graalvm.polyglot.Context buildContext(io.kestra.core.runners.RunContext runContext, OutputStream out, OutputStream err) -
getBindings
protected org.graalvm.polyglot.Value getBindings(org.graalvm.polyglot.Context context, String languageId) -
contextBuilder
protected org.graalvm.polyglot.Context.Builder contextBuilder(io.kestra.core.runners.RunContext runContext) -
generateSource
protected org.graalvm.polyglot.Source generateSource(String languageId, io.kestra.core.runners.RunContext runContext) throws io.kestra.core.exceptions.IllegalVariableEvaluationException - Throws:
io.kestra.core.exceptions.IllegalVariableEvaluationException
-