Skip to content

Scripting

Built-in TypeScript modules

Import the packages included with Varc using static ESM syntax, editor completion, and no installation step.

Varc ships familiar packages inside the app so a saved script remains portable and bounded:

import { z } from "zod";
import { formatISO } from "date-fns";
import _ from "lodash";

const input = z.object({ createdAt: z.string() }).parse({
  createdAt: "2026-08-18T10:30:00Z",
});

return {
  createdAt: formatISO(new Date(input.createdAt)),
  keys: _.sortBy(["customer:2", "customer:1"]),
};

Imports use standard static TypeScript/ESM syntax. They look like npm package imports, but Varc supports only the package roots included with the application.

Supported import forms

Use named, default, namespace, aliased, or type-only static imports when the package exports them:

import Decimal from "decimal.js";
import * as YAML from "yaml";
import { v4 as createUuid } from "uuid";
import { z } from "zod";
import type { ZodType } from "zod";

const schema: ZodType<string> = z.string();
const config = YAML.parse('mode: "strict"');
return { id: createUuid(), total: new Decimal("0.1").plus("0.2").toString(), config, schema };

Imports must stay at the top level. Authored export declarations are rejected because a saved script is one executable entry body, not a package for another script to load.

Package catalog

This catalog lists the exact versions, licenses, upstream links, and execution-class availability included with the current Varc release.

ModuleUse it forVersionAvailable inLicenseUpstream
@msgpack/msgpackEncode and decode MessagePack payloads.3.1.3Scripts, Macros, Transformers, DashboardsISCProject site
chaiWrite familiar assertions inside scripts and fixtures.6.2.2Scripts, Macros, Transformers, DashboardsMITProject site
date-fnsParse, compare, and format dates without mutable date wrappers.4.4.0Scripts, Macros, Transformers, DashboardsMITProject site
decimal.jsPerform decimal arithmetic without binary floating-point surprises.10.6.0Scripts, Macros, Transformers, DashboardsMITProject site
fast-json-patchCreate and apply RFC 6902 JSON Patch operations.3.1.1Scripts, Macros, Transformers, DashboardsMITProject site
fast-xml-parserParse XML into JavaScript objects and build XML output.5.11.0Scripts, Macros, Transformers, DashboardsMITProject site
jsonpath-plusSelect values from JSON documents with JSONPath expressions.10.4.0Scripts, Macros, Transformers, DashboardsMITProject site
lodashTransform, group, sort, and compare collections and objects.4.18.1Scripts, Macros, Transformers, DashboardsMITProject site
nanoidGenerate compact URL-friendly random identifiers.6.0.1Scripts, Macros, Transformers, DashboardsMITProject site
papaparseParse and produce CSV data.5.6.0Scripts, Macros, Transformers, DashboardsMITProject site
semverParse, compare, and test semantic versions and ranges.7.8.5Scripts, Macros, Transformers, DashboardsISCProject site
uuidGenerate and validate UUID values.14.0.1Scripts, Macros, Transformers, DashboardsMITProject site
yamlParse and stringify YAML documents.2.9.0Scripts, Macros, Transformers, DashboardsISCProject site
zodValidate unknown data and infer TypeScript-friendly result shapes.4.4.3Scripts, Macros, Transformers, DashboardsMITProject site

Every app release pins one exact version. Saved scripts do not carry their own dependency lockfile. Package upgrades are application changes with compatibility tests and release notes.

Only the documented package-root exports are available. Node-only entry points, command-line tools, filesystem adapters, and undocumented subpaths are not included merely because the upstream npm package contains them.

Common recipes

Validate unknown JSON

import { z } from "zod";

const payload = z
  .object({ id: z.string().uuid(), enabled: z.boolean().default(false) })
  .parse(JSON.parse((await redis.get("feature:payload")) ?? "{}"));

return payload;

Parse CSV and XML

import Papa from "papaparse";
import { XMLParser } from "fast-xml-parser";

const csv = Papa.parse<{ name: string }>("name\nAda", { header: true });
const xml = new XMLParser().parse("<person><name>Ada</name></person>");

return { csv: csv.data, xml };

Compare structured data

import { expect } from "chai";
import { compare } from "fast-json-patch";
import { JSONPath } from "jsonpath-plus";

const before = { users: [{ id: 1, active: false }] };
const after = { users: [{ id: 1, active: true }] };
const active = JSONPath({ path: "$.users[?(@.active)]", json: after });

expect(active).to.have.length(1);
return compare(before, after);

Encode MessagePack

import { encode, decode } from "@msgpack/msgpack";

const bytes = encode({ status: "ready", attempts: 2 });
return { bytes, decoded: decode(bytes) };

Editor completion and diagnostics

Varc embeds a declaration bundle beside every module. The editor uses those declarations without consulting your machine’s node_modules.

  • Begin a module string after from " to complete allowed package roots.
  • Complete named exports inside { ... } and members on imported namespaces or values.
  • Hover an import or exported API for declaration documentation and follow it to its embedded declaration.
  • Use aliased imports and import type; both participate in diagnostics and navigation.
  • Importing a missing export or passing the wrong types produces a TypeScript diagnostic before the run.

Varc does not currently add an import automatically when you type an otherwise unimported symbol. Write the import declaration first, then use completion within it.

Planned capture: one package-root completion list and one declaration hover, without showing local filesystem paths.

External libraries and unsupported imports

There is no install step and no developer mode that opens Node.js resolution. Varc deliberately rejects:

require("zod"); // CommonJS
await import("zod"); // dynamic import
import helper from "./helper.js"; // relative filesystem path
import data from "/tmp/data.js"; // absolute filesystem path
import parse from "yaml/parse-cst"; // package subpath
import fs from "node:fs"; // Node built-in
import lib from "https://example/lib"; // remote module

Unknown package roots fail before execution. Varc never searches a project directory, reads package.json, contacts an npm registry, follows an import map, or loads a remote URL.

If a workflow needs a package that is not in the catalog, use the existing supported primitives or propose it as a reviewed catalog addition. Arbitrary npm installation, Axios, CommonJS, user-defined modules, and remote imports are outside this release.

Declaration-only packages

The editor uses declarations derived from @types/lodash@4.17.25, @types/semver@7.8.0, @types/papaparse@5.5.2, and @types/chai@5.2.3 for the corresponding packages above.

Those @types names are editor metadata, not available imports. They are MIT-licensed type inputs from DefinitelyTyped.

Network access is a global API

Importing a package never grants network access. Use the global fetch only in a saved script or macro with Network enabled. Transformers and dashboard scripts can import every pure catalog module but cannot reach Fetch.