KScript docs
EN

Built-in API gaps

Files, data, cache, and tests

Proposed API Today Gap
Binary file read and write @read_text(), @write_text(), and Base64 text helpers. @download() can save a remote file. Read and write byte-preserving values. Share the representation with response bodies and encoders instead of treating arbitrary bytes as Unicode.
CSV read and write IO has JSON, YAML and line readers. ->split(',') only handles simple rows. Round-trip quoted delimiters, escaped quotes, and embedded newlines. Set a header and typing contract.
@with_temp_file(fn) and @with_temp_folder(fn) @temp_folder(), @create_folder(), and @delete(). Allocate a unique temporary path and clean it up even when the callback throws.
Atomic replacement for arbitrary IO paths storage->write() safely replaces files in application storage. Provide the same explicit guarantee for general IO paths and keep existing path checks.
query->cursor_paginate(...) ->paginate() supplies offset pages and a total. Traverse large changing datasets using a stable sort and cursor, without counting all matching rows.
Atomic upsert and bulk insert Models offer ->create() and ->first_or_create(). Queries can run raw parameterized SQL. Expose unique-key conflict handling and multi-row writes with defined validation, transaction, and cross-provider behavior.
database->columns(table) or a schema description method ->tables(), ->has_table() and CLI migration/schema tooling. Inspect column types, nullability, defaults, indexes and keys without provider-specific SQL.
cache->set_if_absent(key, value, ttl: ...) ->has(), ->set(), ->remember(), and ->increment(). Reserve a key in one operation and specify the guarantee for both memory and file stores.
Cache invalidation by group ->keys(), ->remove(), and ->clear(). Expire related entries without scanning every key or clearing unrelated entries.
Clock and environment overrides for tests Core exposes @now(), @today(), and @env(). Queue tests can use @fake_queue(). Exercise time-dependent and configuration-dependent branches with scoped overrides and automatic restoration.
HTTP response assertions for tests expect can inspect status, headers, and JSON as individual values. Provide reusable assertions for status, redirects, headers, and typed JSON with failure messages that point to the field that differed.

Edit this page on GitHub