@uipath/packager-tool-functions
v1.196.0
Published
UiPath Functions tool implementation
Maintainers
Keywords
Readme
@uipath/packager-tool-functions
UiPath solution packager plugin for ProjectType.Function. Used by Studio Web to build and pack JS/TS and Python Functions projects.
Architecture
Studio Web publish (JS/TS)
→ FunctionsTool.buildAsync() ← this package
→ buildJsFunctionsPackage() ← src/js (thin wrapper)
→ buildFunctionsPackage() ← @uipath/coded-functions-js-packager
Studio Web publish (Python)
→ FunctionsTool.buildAsync() ← this package
→ buildPyFunctionsPackage() ← src/py (local implementation)
CLI: uip functions pack (JS/TS)
→ uipath-functions pack ← @uipath/uipath-functions CLI
→ buildFunctionsPackage() ← same shared library
CLI: uip functions pack (Python)
→ uipath pack ← Python CLI subprocessHow it works
FunctionsTool implements ProjectTool for ProjectType.Function. On buildAsync:
- Detects language from
uipath.jsonfunctions map (.ts/.js/.mjs→ javascript,.py→ python); fallback:pyproject.tomlpresence → python. - JS/TS: delegates to
buildFunctionsPackage(fs, options)from@uipath/coded-functions-js-packager(externally-published library, shared with theuipath-functionsCLI). - Python: delegates to the local
buildPyFunctionsPackage(fs, options)implementation insrc/py/.
Language detection
| Signal | Result |
|---|---|
| uipath.json functions map extension .ts/.js/.mjs | javascript |
| uipath.json functions map extension .py | python |
| pyproject.toml present | python (fallback) |
| Neither | javascript (default) |
Python build pipeline
buildPyFunctionsPackage produces a fully-formed nupkg content folder from the Python project sources. Pipeline:
- Validate inputs — requires
uipath.jsonandentry-points.jsonat the project root. Throws a readable error if either is missing. - Copy source files to
content/, filtered byEXCLUDED_NAMES(agent.json,project.uiproj,bindings.json,entry-points.json, OS metadata) andEXCLUDED_DIRECTORIES(virtualenvs, caches, editor dirs, VCS dirs).bindings.jsonandentry-points.jsonare excluded because the packager re-emits canonical versions — see steps 3 and 5. - Normalize
content/entry-points.json— reads the source file and rewrites it with:- Canonical
$schema(https://cloud.uipath.com/draft/2024-12/entry-point) and$id(entry-points.json). - Per-entry
uniqueId— backfilled withcrypto.randomUUID()when the source is missing it. - Per-entry
type— defaults to"function"when missing. - All other fields (
filePath,input,output, etc.) are passed through.
- Canonical
- Write
content/operate.json—$schema=operate,contentType="function",targetRuntime="python",main= first entry-point'sfilePath,projectId= the platform-assigned storage id. - Write
content/bindings_v2.json— uses the sourcebindings.jsonif present and parseable; otherwise emits the default{ $schema, version: "2.0", resources: [] }. - Write
content/package-descriptor.json— registersoperate.json,entry-points.json, andbindings.json(the latter pointing atcontent/bindings_v2.json).
Expected source-project shape
The upstream tool (uipath init / Function Builder MFE) is responsible for producing a valid source layout before this packager runs. In particular:
uipath.json.functions— map of entrypoint key →"<file>.py:<python-function>"(the runtime uses this to resolve the function body).entry-points.json— each entry'sfilePathmust equal the functions-map key. The packager will fill inuniqueIdandtype: "function"if they're missing, but nothing can recover the real function-name mapping — that lives inuipath.json.functions.- The Python function must take exactly one parameter typed as a dataclass, Pydantic model, or annotated class; the UiPath runtime calls
func(input)with a single argument and converts the input dict into that type.
Project structure
src/
├── functions-tool.ts # ProjectTool implementation (language detection, build/pack lifecycle)
├── functions-tool-factory.ts # Factory for the tool loader
├── js/ # JS/TS build path (delegates to @uipath/coded-functions-js-packager)
├── py/ # Python build path
│ ├── build-py-functions-package.ts
│ ├── constants.ts # All Python-packager constants (schemas, file names, exclusions)
│ └── index.ts
├── types.ts # BuildPackageOptions, Language enum, labels
└── index.tsDevelopment
bun install
bun run build # bun build → dist/ (ESM, browser target)
bun run test # vitest
bun run lint # biome check