gizdb:source
One typed data-source contract. An adapter reports its actual abilities and returns owned column pages. It never manufactures global snapshot/CDC semantics.
import * as Source from "gizdb:source";Types
Capabilities
type Capabilities = { schema: bool; projection: bool; filter: bool; group: bool; join: bool; snapshot: bool; changeLog: bool; write: bool; transaction: bool; cancel: bool; compute: bool; order: bool; limit: bool; window: bool; set: bool; }What a source can do itself: the parts of a query that it runs, and whether it gives snapshots, a change log, writes and transactions.
schema:boolprojection:boolfilter:boolgroup:booljoin:boolsnapshot:boolchangeLog:boolwrite:booltransaction:boolcancel:boolcompute:boolorder:boollimit:boolwindow:boolset:bool
Semantics
type Semantics = { dialect: string; collation: string; timezone: string; nulls: string; }How a source compares and shows values: its SQL dialect, collation, time zone and null order.
dialect:stringcollation:stringtimezone:stringnulls:string
Version
type Version = { source: string; revision: string; snapshot: bool; }Revisions remain per source; "snapshot=false" is never upgraded by a federation.
source:stringrevision:stringsnapshot:bool
Request
type Request = { tree: Select; parameters: Vec<Typed.Slot>; values: Vec<Value>; outputs: Vec<Typed.Slot>; rows: i64; bytes: i64; sql: string; }A query for a source: its tree, parameters and their values, outputs, and the most rows and bytes to read.
tree:_gizlang_lib_db__sql__ast.Selectparameters:Vec<M54.Slot>values:Vec<M55.Value>outputs:Vec<M54.Slot>rows:i64bytes:i64sql:string
Cursor
type Cursor = { slots: Vec<Typed.Slot>; versions: Vec<Version>; poll: (rows: i64, bytes: i64) => Result<FinitePoll, DbError>; close: () => Result<bool, DbError>; }The open result of a query: its columns, the versions of the sources that it reads, and how to poll and close it.
slots:Vec<M54.Slot>versions:Vec<M61.Version>poll:(rows: i64, bytes: i64) => _gizlang_sdk_core.Result<_gizlang_lib_db__sql__exec__vm.FinitePoll, M56.DbError>close:() => _gizlang_sdk_core.Result<bool, M56.DbError>
Source
type Source = { identity: string; semantics: Semantics; capabilities: Capabilities; prepare: (request: Request) => Result<Cursor, DbError>; change: (commands: Vec<Statement>) => Result<i64, DbError>; read: Option<NativeRead>; }A data source that a query reads: its identity, semantics and capabilities, and how to prepare queries and run changes.
identity:stringsemantics:M61.Semanticscapabilities:M61.Capabilitiesprepare:(request: M61.Request) => _gizlang_sdk_core.Result<M61.Cursor, M56.DbError>change:(commands: Vec<_gizlang_lib_db__sql__ast.Statement>) => _gizlang_sdk_core.Result<i64, M56.DbError>read:_gizlang_sdk_core.Option<(sql: string, rows: i64, bytes: i64) => _gizlang_sdk_core.Result<M61.Cursor, M56.DbError>>
Requirement
type Requirement = { snapshot: bool; changeLog: bool; write: bool; transaction: bool; }What a caller needs of a source.
snapshot:boolchangeLog:boolwrite:booltransaction:bool
Descriptor
type Descriptor = { version: string; identity: string; revision: bytes; semantics: Semantics; capabilities: Capabilities; maxRows: i64; maxBytes: i64; }This is the adapter contract revision, not a fabricated data revision. Actual data cuts remain Cursor.versions and are scoped to each source.
version:stringidentity:stringrevision:bytessemantics:M61.Semanticscapabilities:M61.CapabilitiesmaxRows:i64maxBytes:i64
TextRows
type TextRows = { columns: Vec<string>; rows: Vec<Vec<Option<string>>>; }A text client's answer: the column names the database gives and the text cells (none for NULL).
columns:Vec<string>rows:Vec<Vec<_gizlang_sdk_core.Option<string>>>
TextClient
type TextClient = { query: (sql: string, parameters: Vec<Option<string>>) => Result<TextRows, DbError>; atomic: (statements: Vec<string>) => Result<i64, DbError>; numbered: bool; }A database client that runs SQL text with text parameters and gives text cells
(gizlang:sqlite, gizlang:postgres). atomic runs statements in one transaction.
query:(sql: string, parameters: Vec<_gizlang_sdk_core.Option<string>>) => _gizlang_sdk_core.Result<M61.TextRows, M56.DbError>atomic:(statements: Vec<string>) => _gizlang_sdk_core.Result<i64, M56.DbError>numbered:bool
Functions
pinSchema
function pinSchema(expected: bytes, slots: Vec<Typed.Slot>): Result<bool, DbError>Database-first callers pin observed result schemas rather than guessing a row type.
Effects: fail.
odbc
function odbc(connection: Odbc.Connection, identity: string, semantics: Semantics): Result<Source, DbError>One driver contract covers PostgreSQL/MySQL/SQL Server/Oracle/SQLite and other ODBC sources. A particular driver is usable only after its type/semantic checks.
Effects: fail, read, io.
federated
function federated(sources: Vec<Source>, atomic: bool, live: bool): Result<Vec<Version>, DbError>A federation requires identical semantics for a moved calculation and keeps source frontiers distinct. Atomic distributed writes are never implied.
Effects: fail.
document
function document(identity: string, slots: Vec<Typed.Slot>, text: string): Result<Source, DbError>Arrays of records are the shared JSON/API/SaaS/spreadsheet export boundary. Nested fields are explicit text/extension codecs; no DOM f64 round-trip occurs.
Effects: fail.
files
function files(directory: Dir, identity: string, pattern: string, format: i64, text: Files.TextOptions, planning: Files.FilePlanningLimits, limits: Files.FileCursorLimits, context: ResourceContext): SourceCSV, NDJSON and Parquet all use the existing bounded physical file reader. The supplied context is the caller's original resource issuer. Mutable files are not advertised as transaction snapshots.
httpJson
function httpJson(sys: System, host: string, port: i64, request: Http.Request, identity: string, slots: Vec<Typed.Slot>, bodyBytes: i64): Result<Source, DbError>Caller supplies the HTTP endpoint and request; this adapter does no redirects. Body admission occurs during Incoming consumption, before JSON record decoding.
Effects: fail, read, write, console, io.
semantics
function semantics(dialect: string): Result<Semantics, DbError>The semantics of a SQL engine that an external source runs: its dialect, the collation of its text, its time zone and how it types NULL. A federation requires equal semantics.
Effects: fail.
text
function text(client: TextClient, identity: string, semantics: Semantics): SourceA source on a text client. A query's declared output slots type the text cells; a query that declares none (discover) gets the columns the database names, each cell kept as nullable text. It has no snapshot or change log, so a watch is refused as a missing capability.
Effects: fail.
postgres
function postgres(connection: Pg.Connection, identity: string): SourceA source on a PostgreSQL connection (gizlang:postgres).
Effects: fail.
Methods
Source.describe
function Source.describe(self: Source): DescriptorThe descriptor of the source: its contract version, identity, semantics, capabilities and limits.
Effects: fail.
Source.admit
function Source.admit(self: Source, request: Request, need: Requirement, revision: bytes): Result<bool, DbError>Admit an exact typed request under a pinned adapter contract. The provider's prepare/binder remains the final authority for its actual operator support.
Effects: fail.
Source.require
function Source.require(self: Source, need: Requirement): Result<bool, DbError>Fails with an error that names the first capability of NEED that the source does not have.
Effects: fail.
Source.transaction
function Source.transaction<T>(self: Source, commands: Vec<Statement>, result: T): Result<T, DbError>Runs COMMANDS as one transaction of the source; RESULT when they all succeed.
Source.discover
function Source.discover(self: Source, tree: Select, parameters: Vec<Typed.Slot>, values: Vec<Value>, rows: i64, bytes: i64): Result<Cursor, DbError>A cursor of TREE with PARAMETERS and VALUES, after the source admits each part of it, reading at most ROWS rows and BYTES bytes.
Effects: fail, read, write, console, io.