function __cfHardenFn(fn: Function) { Object.freeze(fn); const prototype = fn.prototype; if (prototype && typeof prototype === "object") { Object.freeze(prototype); } return fn; } import { __cfHelpers } from "commonfabric"; import { type Cell, sqliteDatabase } from "commonfabric"; const define = undefined; const runtimeDeps = undefined; const __cfAmdHooks = undefined; interface User { name: string; } // FIXTURE: db-query-row-schema // Verifies: the METHOD form db.query(sql, options?) lowers the Row type // argument to an injected `rowSchema` in the OPTIONS object (arg 1, not arg 0). // Cell Row fields become asCell, keyed by the Row field name — so an aliased // link column (SELECT author_cf_link AS author) is detected with no _cf_link // suffix, exactly like the free-function sqliteQuery form. export default function TestDbQueryRowSchema() { const db = sqliteDatabase().for("db", true); const q = db.query<{ author: Cell; n: number; }>("SELECT author_cf_link AS author, count(*) AS n FROM m GROUP BY author_cf_link", { rowSchema: { type: "object", properties: { author: { $ref: "#/$defs/User", asCell: ["cell"] }, n: { type: "number" } }, required: ["author", "n"], $defs: { User: { type: "object", properties: { name: { type: "string" } }, required: ["name"] } } } as const satisfies __cfHelpers.JSONSchema }).for("q", true); return { q }; } __cfHardenFn(TestDbQueryRowSchema); // @ts-ignore: Internals function h(...args: any[]) { return __cfHelpers.h.apply(null, args); } __cfHardenFn(h);