@uipath/coded-functions-js-sdk
v0.6.9
Published
Primitives for defining UiPath JS/TypeScript functions
Maintainers
Keywords
Readme
@uipath/coded-functions-js-sdk
Primitives for authoring UiPath coded functions in TypeScript and JavaScript.
A function is a single defineFunction call with a typed input and output. The package provides that
call, the schema helpers, the function context, a logger, HTTP response helpers and an error type.
Install
Projects are scaffolded with the UiPath CLI (@uipath/cli),
which declares this package as a dev dependency:
uip functions new my-functions -l tsFor an existing project:
npm install --save-dev @uipath/coded-functions-js-sdkExample
import { defineFunction, defineSchema, type FunctionContext } from "@uipath/coded-functions-js-sdk";
interface HelloInput {
/** @default "World" */
name?: string;
}
interface HelloOutput {
message: string;
}
function main(input: HelloInput, ctx: FunctionContext): HelloOutput {
return { message: `Hello, ${input.name}!` };
}
export default defineFunction({
name: "hello",
description: "Greets a person by name.",
input: defineSchema<HelloInput>(),
output: defineSchema<HelloOutput>(),
handler: main,
});Exports
| Export | Purpose |
| --- | --- |
| defineFunction | Declares the function — its name, contract and handler. One per file, as the default export. |
| defineSchema | Derives the JSON Schema for the input and output from their TypeScript types. |
| FunctionContext | Caller identity, robot and tenant details, and HTTP request data when the function declares HTTP semantics. |
| logger | Emits log lines that reach the job's logs. |
| ok, badRequest, notFound, response, … | Explicit HTTP responses, for functions that declare HTTP semantics. |
| FunctionError | Fails a run with a message and a category the platform recognizes. |
