lozick
v0.1.0
Published
Author functional-domain-modeling business logic and review it as node graphs.
Maintainers
Readme
lozick
Author business logic as functional, typed step-flows — and review the same definition as a node graph.
The workflow definition is both the code your server runs and the source the graph is drawn from, so the picture can never drift from the code.
📖 Docs: lozickjs.com · Getting Started · API reference
npm i lozick zod neverthrow🔎 Looking for the
lozick devcommand? The graph viewer is a separate, dev-time package — install@lozickjs/cli(npm i -D @lozickjs/cli), then runnpx lozick dev. Thelozickpackage itself is the runtime library youimport; it ships no CLI.
import { z } from "zod";
import { ok, err } from "neverthrow";
import { workflow, step, check, run } from "lozick";
const Cart = z.object({ items: z.number(), coupon: z.string().optional() });
const EmptyCart = z.object({ tag: z.literal("EmptyCart") });
const ensureNotEmpty = check({
name: "ensureNotEmpty",
input: Cart,
errors: [EmptyCart],
handler: ({ input }) =>
input.items > 0 ? ok(true) : err({ tag: "EmptyCart" as const }),
});
export const placeOrder = workflow("placeOrder")
.input(Cart)
.check(ensureNotEmpty)
.build();
const outcome = await run(placeOrder, { items: 2 });
// { ok: true, value: { items: 2 } }Review it as a graph with the viewer — a separate dev-time package,
@lozickjs/cli:
npm i -D @lozickjs/cli
npx lozick dev # discovers *.flow.ts and serves the graphlozick is just Zod + neverthrow + TypeScript — no server, no bundler.
License
MIT © Go Kobayashi
