This example uses examples/typescript/functions/minimal_job/function.py to package a TypeScript job, build it with npm run build, and run the compiled node dist/index.js entrypoint as a Nullspace Function job.

Setup

python -m pip install "nullspace-sdk[cli]"
export NULLSPACE_API_KEY=ns_live_...
export NULLSPACE_API_URL=https://api.your-nullspace-domain
cd examples/typescript/functions/minimal_job

CLI

nullspace deploy --dry-run --json

NULLSPACE_ENVIRONMENT=staging nullspace deploy --json

nullspace run typescript-minimal-job \
  --env staging \
  --input-json '{"subject":"functions"}' \
  --json

nullspace functions logs typescript-minimal-job --env staging --run fnrun_123
nullspace functions outputs typescript-minimal-job --env staging --run fnrun_123
The job reads input from NULLSPACE_INPUT or .nullspace/run.json and writes result.json plus reports/summary.txt.

Function Definition

function.py
import nullspace

function = nullspace.Function(
    "typescript-minimal-job",
    mode="job",
    install="npm install && npm run build",
    entrypoint="node dist/index.js",
    outputs=nullspace.Outputs(paths=["result.json", "reports"]),
    max_concurrency=2,
)
max_concurrency uses the same shared Function config field as Python. Synchronous run/invoke calls fail fast with 429 capacity_exceeded and Retry-After when saturated; detached spawn calls use the bounded Function backlog.

TypeScript Client

import { NullspaceClient } from "@nullspace/sdk";

const client = new NullspaceClient();
const fn = client.functions.get("typescript-minimal-job", {
  environment: "staging",
});

const run = await fn.run({ input: { subject: "functions" } });
const result = await run.wait();

console.log(result.status, await run.outputs());

Project Files

examples/typescript/functions/minimal_job/
  README.md
  package.json
  tsconfig.json
  function.py
  src/index.ts
Related: Functions, TypeScript SDK, and TypeScript service.