Skip to content

v0.2.0

Choose a tag to compare

@github-actions github-actions released this 28 Oct 03:20
· 5 commits to main since this release
v0.2.0
b1c1ac3

kzig 0.2.0 adds scheduled jobs, file storage and a database layer, and moves the docs to
https://forinda.github.io/kzig/, with a tutorial from
kzig new to a Docker image. Requires Zig 0.17.0. Pre-alpha: APIs will change.

Highlights

Database (kzig.db)

kick/db's code-first layer, in Zig.

  • Postgres without libpq. A pure-Zig client with SCRAM-SHA-256, a pool and transactions, and rows decoded into structs by column name.

    • TLS follows libpq's sslmode, with sslrootcert or the system's CAs, and sslnegotiation=direct (Postgres 17).
    • Channel binding (SCRAM-SHA-256-PLUS).
    • Client certificates on TLS 1.3 and 1.2: EC, RSA and Ed25519 keys, encrypted keys with sslpassword.
    • Revocation lists (sslcrl).
  • Schema and queries. Tables are Zig struct literals. The query builder covers select, insert, update, delete, joins, upsert, findOrCreate and insertMany, and a wrong column or value type is a compile error.

  • Relations. one, many and through are resolved with kick/db's rules. client.query(.t).findMany(.{ .with = … }) reads nested rows in one statement.

  • Migrations. kzig db generate writes kick/db's migration folders from your schema, with renames by prompt or flag; kzig db check is for CI. kzig db migrate, rollback and status, or kzig.db.migrate.onBoot, apply them, so a kick/db app and a kzig app can share a folder.

  • SQLite, Turso and Cloudflare D1. The same schema, builder, relations and migrations, in three forms:

    • sqlite:path for local files. Needs -Dsqlite, which builds SQLite's C library; the default build stays C-free.
    • libsql:// for Turso, over HTTP.
    • d1:// for D1, over its REST API.

    On SQLite, Turso and D1, parameters bind by their Zig type.

Also new

  • Scheduled jobs. pub const crons = .{ … } on any service: 5- or 6-field expressions checked at compile time, timezones from zoneinfo, overlap control, manual runs.
  • Storage. kzig.storage over memory, a disk folder, or S3 (AWS, R2, MinIO, SeaweedFS), with SigV4 signing (no SDK), presigned links and listing.
  • Routing. Routes now match through a segment tree built at compile time.

Docs

  • The guides moved from the README to a site built with MkDocs (Material).
  • The API reference is built from the source by Zig's autodoc, at /api/.
  • The tutorial builds a bookmarks API: SQLite with migrations, validation, an API key, Swagger UI, tests, production settings and a 25 MB Docker image.

Changes to note when upgrading

  • Pool.queryParams / execParams (and the Tx versions) take []const kzig.db.Param; wrap raw text with kzig.db.Param.texts(arena, values).
  • kzig db generate and kzig db check need --db <name> when the app has more than one database adapter with a schema.

Install

zig fetch --save git+https://github.com/forinda/kzig#v0.2.0

Prebuilt kzig CLIs for Linux (x86_64, aarch64) and macOS (x86_64, arm64) are attached below, with SHA256SUMS.