Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions stdlib/Ajv.affine
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// SPDX-License-Identifier: PMPL-1.0-or-later
// Copyright (c) 2026 Jonathan D.A. Jewell <j.d.a.jewell@open.ac.uk>
//
// Ajv.affine — extern bindings for AJV v8 JSON Schema Validator.
// The Node-CJS shim instantiates ajv@8 with allErrors:true, strict:false
// and ajv-formats@3 applied. All handles are opaque Int.

module Ajv;

pub extern type AjvInstance;
pub extern type Validator;

pub extern fn ajv_new() -> AjvInstance;
pub extern fn ajv_compile(a: AjvInstance, schema_json: String) -> Validator;
pub extern fn ajv_validate(v: Validator, value_json: String) -> Bool;
pub extern fn ajv_errors_json(v: Validator) -> String;
11 changes: 11 additions & 0 deletions stdlib/Crypto.affine
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// SPDX-License-Identifier: PMPL-1.0-or-later
// Copyright (c) 2026 Jonathan D.A. Jewell <j.d.a.jewell@open.ac.uk>
//
// Crypto.affine — extern bindings for crypto primitives and wall-clock time.
// The Node-CJS shim wraps Node's built-in node:crypto and Date.now().

module Crypto;

pub extern fn random_string(n: Int) -> String;
pub extern fn random_f64() -> Float;
pub extern fn time_ms() -> Int;
30 changes: 30 additions & 0 deletions stdlib/Grammy.affine
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// SPDX-License-Identifier: PMPL-1.0-or-later
// Copyright (c) 2026 Jonathan D.A. Jewell <j.d.a.jewell@open.ac.uk>
//
// Grammy.affine — extern bindings for the Grammy Telegram Bot framework.
//
// All Grammy host objects are opaque Int handles maintained by the Node-CJS
// shim. Function names mirror the Grammy/Telegram API where possible, with
// namespaces flattened (e.g. bot.api.sendMessage -> bot_send_message).
//
// API surface: the subset used by avow-protocol/telegram-bot in standards.

module Grammy;

pub extern type Bot;
pub extern type Context;
pub extern type BotInfo;

pub extern fn bot_new(token: String) -> Bot;
pub extern fn bot_command(b: Bot, command: String, handler: Int) -> Int;
pub extern fn bot_catch(b: Bot, err_handler: Int) -> Int;
pub extern fn bot_start(b: Bot, on_start_handler: Int) -> Int;
pub extern fn bot_send_message(b: Bot, chat_id: Int, text: String, parse_mode: String) -> Int;

pub extern fn ctx_from_id(ctx: Context) -> Option<Int>;
pub extern fn ctx_from_username(ctx: Context) -> Option<String>;
pub extern fn ctx_reply(ctx: Context, text: String, parse_mode: String) -> Int;

pub extern fn botinfo_username(info: BotInfo) -> String;

pub extern fn set_interval(handler: Int, interval_ms: Int) -> Int;
10 changes: 10 additions & 0 deletions stdlib/Network.affine
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// SPDX-License-Identifier: PMPL-1.0-or-later
// Copyright (c) 2026 Jonathan D.A. Jewell <j.d.a.jewell@open.ac.uk>
//
// Network.affine — extern bindings for synchronous HTTP requests.
// The Node-CJS shim wraps Node's built-in node:https via a sync adapter.

module Network;

pub extern fn http_get_status(url: String) -> Int;
pub extern fn http_get_response_time_ms(url: String) -> Int;
19 changes: 19 additions & 0 deletions stdlib/Sqlite.affine
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// SPDX-License-Identifier: PMPL-1.0-or-later
// Copyright (c) 2026 Jonathan D.A. Jewell <j.d.a.jewell@open.ac.uk>
//
// Sqlite.affine — extern bindings for an SQLite backend.
//
// All database handles are opaque Int. Query parameters are JSON-encoded
// strings; each result row is returned as a JSON-encoded string for
// caller-side decoding. The Node-CJS shim wraps Deno sqlite or node:sqlite.

module Sqlite;

pub extern type Db;

pub extern fn db_open(path: String) -> Db;
pub extern fn db_close(d: Db) -> Int;
pub extern fn db_execute(d: Db, sql: String) -> Int;
pub extern fn db_query(d: Db, sql: String, params_json: String) -> String;
pub extern fn db_query_one(d: Db, sql: String, params_json: String) -> String;
pub extern fn db_query_int(d: Db, sql: String, params_json: String) -> Int;
Loading