Browse sections

TypeScript SDK (code-first)

The @inquir/compute SDK turns functions into code you can review, type-check, and version: the handler, its limits, and its input/output schemas live in one file in your repository, and the CLI deploys exactly what the code declares.

Use it when the browser editor stops being the source of truth — team repositories, code review, CI deploys — while keeping the same runtime, gateway, and observability underneath.

Project layout

inquir init scaffolds a workspace with inquir.config.json at the root. The config tells the CLI where to discover assets:

inquir.config.json
{
  "functionsDir": "inquir/functions",
  "pipelinesDir": "inquir/pipelines",
  "generatedDir": ".inquir/generated"
}

Everything under functionsDir that exports a managed function is discovered automatically — no manifest to maintain by hand.

Define a function

defineFunction couples configuration with the handler. Input and output schemas are Zod types: the SDK validates the event before your code runs and infers the handler's TypeScript signature from the schema.

greet.ts
import { defineFunction } from '@inquir/compute';
import { z } from 'zod';

// Config, validation, and types live next to the code — no console clicking.
export const greet = defineFunction(
  {
    name: 'greet',
    timeoutMs: 10_000,
    memoryMB: 256,
    moduleType: 'esm', // skip content sniffing for .js entry files
    input: z.object({ name: z.string() }),
    output: z.object({ greeting: z.string() }),
  },
  async ({ name }) => ({ greeting: `Hello, ${name}!` })
);

All options mirror the console settings — timeoutMs, memoryMB, allowNetwork, environment, and moduleType for skipping ESM/CommonJS sniffing on plain .js entries.

Daily workflow

  • inquir list — show the local assets the SDK discovered (add -r for what's deployed remotely).
  • inquir run greet --payload '{"name":"World"}' — execute the function locally with schema validation, no deploy required.
  • inquir deploy greet — package the function and stream build logs until the endpoint is live.
  • inquir logs greet — tail recent remote invocations from the terminal.

When to use the SDK vs the editor

The browser editor is the fastest way to try an idea and remains fully supported — both edit the same functions. Prefer the SDK once changes need review, tests, or CI: code-first functions get typed contracts and reproducible deploys, and the editor stays useful for quick production inspection.