- isQueue table option adds queue columns and a (status, available_at) index; BunSQLite.queue exposes add, claim, complete, fail and release_stale with atomic claims - Set busy_timeout on connections so workers in separate processes wait instead of failing with SQLITE_BUSY - Quote table and column names with backticks in generated SQL, so reserved words (to, order, group) work and unknown columns error instead of matching as string literals - Tests for queue ops, multi-process claims and reserved-word names Co-Authored-By: Claude Opus 5.5 <[email protected]>
44 lines
1.9 KiB
TypeScript
44 lines
1.9 KiB
TypeScript
import { SQlComparisons, ServerQueryOperators } from "../types";
|
|
declare const JOIN_TYPES: readonly ["INNER JOIN", "JOIN", "LEFT JOIN", "RIGHT JOIN"];
|
|
/**
|
|
* # Validate a bare SQL identifier (table, column, alias)
|
|
* @description Identifiers can't be bound as parameters, so anything that
|
|
* gets interpolated into SQL must pass this check first.
|
|
*/
|
|
export declare function sqlIdent(name: unknown, label?: string): string;
|
|
/**
|
|
* # Validate a column reference
|
|
* @description Accepts `field`, `table.field` or `table.*`
|
|
*/
|
|
export declare function sqlField(name: unknown, label?: string): string;
|
|
/**
|
|
* # Validate and quote an identifier for queries
|
|
* @description Quoting lets reserved words (`to`, `order`, ...) be used as
|
|
* names. Backticks, not double quotes: SQLite reads an unknown `"name"` as
|
|
* a string literal, so a typo would silently match nothing instead of
|
|
* failing with "no such column".
|
|
*/
|
|
export declare function sqlName(name: unknown, label?: string): string;
|
|
/**
|
|
* # Validate and quote a column reference
|
|
* @description Accepts `field`, `table.field` or `table.*`
|
|
*/
|
|
export declare function sqlColumn(name: unknown, label?: string): string;
|
|
/**
|
|
* # Quote an identifier for DDL statements
|
|
*/
|
|
export declare function sqlQuoteIdent(name: string): string;
|
|
/**
|
|
* # Quote a string literal
|
|
*/
|
|
export declare function sqlStringLiteral(value: string): string;
|
|
/**
|
|
* # Validate a non-negative integer (LIMIT, OFFSET, page)
|
|
*/
|
|
export declare function sqlInt(value: unknown, label?: string): number;
|
|
export declare function sqlOrderStrategy(strategy: unknown): "ASC" | "DESC";
|
|
export declare function sqlOperator(operator: unknown, fallback?: (typeof ServerQueryOperators)[number]): (typeof ServerQueryOperators)[number];
|
|
export declare function sqlRawEquality(equality: unknown): (typeof SQlComparisons)[number];
|
|
export declare function sqlJoinType(joinType: unknown): (typeof JOIN_TYPES)[number];
|
|
export {};
|