sumak 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,659 @@
1
+ import { A as RawNode, B as createSelectNode, C as IsNullNode, D as OnConflictNode, E as LiteralNode, F as UnaryOpNode, G as JoinType, H as tableRef, I as UpdateNode, J as SQLDialect, K as OrderDirection, L as WindowFunctionNode, M as StarNode, N as SubqueryNode, O as OrderByNode, P as TableRefNode, R as createDeleteNode, S as InsertNode, T as JsonAccessNode, U as CompiledQuery, V as createUpdateNode, W as DialectConfig, Y as SetOperator, _ as FrameBound, a as PrinterOptions, b as FunctionCallNode, c as BetweenNode, d as CaseNode, f as CastNode, g as ExpressionNode, h as ExistsNode, i as Printer, j as SelectNode, k as ParamNode, l as BinaryOpNode, m as DeleteNode, n as BasePrinter, o as ASTNode, p as ColumnRefNode, q as Primitive, r as PrintMode, s as ArrayExprNode, t as Dialect, u as CTENode, v as FrameKind, w as JoinNode, x as InNode, y as FrameSpec, z as createInsertNode } from "./_chunks/types.mjs";
2
+ import { n as PgPrinter, t as pgDialect } from "./_chunks/pg.mjs";
3
+ import { n as MysqlPrinter, t as mysqlDialect } from "./_chunks/mysql.mjs";
4
+ import { n as SqlitePrinter, t as sqliteDialect } from "./_chunks/sqlite.mjs";
5
+ import { A as GeneratedAlways, C as time, D as varchar, E as uuid, F as Selectable, I as UpdateType, L as Updateable, M as Insertable, N as Nullable$1, O as ColumnType, P as SelectType, S as text$1, T as timestamptz, _ as jsonb, a as ColumnBuilder, b as serial, c as bigserial, d as char, f as date, g as json, h as integer, i as defineTable, j as InsertType, k as Generated, l as boolean, m as enumType, n as InferTable, o as ColumnDef, p as doublePrecision, r as TableDefinition, s as bigint, t as Nullable, u as bytea, v as numeric, w as timestamp, x as smallint, y as real } from "./_chunks/index.mjs";
6
+ declare function col(column: string, table?: string): ColumnRefNode;
7
+ declare function colAs(column: string, alias: string, table?: string): ColumnRefNode;
8
+ declare function lit(value: string | number | boolean | null): LiteralNode;
9
+ declare function star(table?: string): StarNode;
10
+ declare function param(index: number, value: unknown): ParamNode;
11
+ declare function raw(sql: string, params?: unknown[]): RawNode;
12
+ declare function subquery(query: SelectNode, alias?: string): SubqueryNode;
13
+ declare function fn(name: string, args: ExpressionNode[], alias?: string): FunctionCallNode;
14
+ declare function binOp(op: string, left: ExpressionNode, right: ExpressionNode): BinaryOpNode;
15
+ declare function unaryOp(op: string, operand: ExpressionNode, position?: "prefix" | "postfix"): UnaryOpNode;
16
+ declare function eq(left: ExpressionNode, right: ExpressionNode): BinaryOpNode;
17
+ declare function neq(left: ExpressionNode, right: ExpressionNode): BinaryOpNode;
18
+ declare function gt(left: ExpressionNode, right: ExpressionNode): BinaryOpNode;
19
+ declare function gte(left: ExpressionNode, right: ExpressionNode): BinaryOpNode;
20
+ declare function lt(left: ExpressionNode, right: ExpressionNode): BinaryOpNode;
21
+ declare function lte(left: ExpressionNode, right: ExpressionNode): BinaryOpNode;
22
+ declare function like(expr: ExpressionNode, pattern: ExpressionNode): BinaryOpNode;
23
+ declare function between(expr: ExpressionNode, low: ExpressionNode, high: ExpressionNode, negated?: boolean): BetweenNode;
24
+ declare function inList(expr: ExpressionNode, values: ExpressionNode[] | SelectNode, negated?: boolean): InNode;
25
+ declare function isNull(expr: ExpressionNode, negated?: boolean): IsNullNode;
26
+ declare function cast(expr: ExpressionNode, dataType: string): CastNode;
27
+ declare function exists(query: SelectNode, negated?: boolean): ExistsNode;
28
+ declare function not(operand: ExpressionNode): UnaryOpNode;
29
+ declare class ASTTransformer {
30
+ transform(node: ASTNode): ASTNode;
31
+ transformSelect(node: SelectNode): SelectNode;
32
+ transformInsert(node: InsertNode): InsertNode;
33
+ transformUpdate(node: UpdateNode): UpdateNode;
34
+ transformDelete(node: DeleteNode): DeleteNode;
35
+ transformExpression(node: ExpressionNode): ExpressionNode;
36
+ }
37
+ interface ASTVisitor<R = void> {
38
+ visitSelect(node: SelectNode): R;
39
+ visitInsert(node: InsertNode): R;
40
+ visitUpdate(node: UpdateNode): R;
41
+ visitDelete(node: DeleteNode): R;
42
+ visitExpression(node: ExpressionNode): R;
43
+ visitJoin(node: JoinNode): R;
44
+ visitOrderBy(node: OrderByNode): R;
45
+ visitCTE(node: CTENode): R;
46
+ }
47
+ declare function visitNode<R>(node: ASTNode, visitor: ASTVisitor<R>): R;
48
+ /**
49
+ * Type-safe expression wrapper. The T parameter tracks the expression's
50
+ * output type at compile time. At runtime, this is just an ExpressionNode.
51
+ *
52
+ * The `__type` field is a phantom — it never exists at runtime.
53
+ */
54
+ interface Expression<T> {
55
+ readonly __type: T;
56
+ readonly node: ExpressionNode;
57
+ }
58
+ declare class SelectBuilder {
59
+ private node;
60
+ constructor(node?: SelectNode);
61
+ columns(...cols: (string | ExpressionNode)[]): SelectBuilder;
62
+ allColumns(): SelectBuilder;
63
+ distinct(): SelectBuilder;
64
+ from(table: string | TableRefNode | SubqueryNode, alias?: string): SelectBuilder;
65
+ where(expr: ExpressionNode): SelectBuilder;
66
+ join(type: JoinType, table: string | TableRefNode, on?: ExpressionNode, alias?: string): SelectBuilder;
67
+ innerJoin(table: string | TableRefNode, on: ExpressionNode, alias?: string): SelectBuilder;
68
+ leftJoin(table: string | TableRefNode, on: ExpressionNode, alias?: string): SelectBuilder;
69
+ rightJoin(table: string | TableRefNode, on: ExpressionNode, alias?: string): SelectBuilder;
70
+ groupBy(...exprs: (string | ExpressionNode)[]): SelectBuilder;
71
+ having(expr: ExpressionNode): SelectBuilder;
72
+ orderBy(expr: string | ExpressionNode, direction?: OrderDirection, nulls?: "FIRST" | "LAST"): SelectBuilder;
73
+ limit(expr: ExpressionNode): SelectBuilder;
74
+ offset(expr: ExpressionNode): SelectBuilder;
75
+ forUpdate(): SelectBuilder;
76
+ with(name: string, query: SelectNode, recursive?: boolean): SelectBuilder;
77
+ union(query: SelectNode): SelectBuilder;
78
+ unionAll(query: SelectNode): SelectBuilder;
79
+ intersect(query: SelectNode): SelectBuilder;
80
+ except(query: SelectNode): SelectBuilder;
81
+ private setOp;
82
+ build(): SelectNode;
83
+ }
84
+ declare function select(...cols: (string | ExpressionNode)[]): SelectBuilder;
85
+ declare class InsertBuilder {
86
+ private node;
87
+ private paramIndex;
88
+ constructor(node?: InsertNode, paramIndex?: number);
89
+ into(table: string | TableRefNode): InsertBuilder;
90
+ columns(...cols: string[]): InsertBuilder;
91
+ values(...vals: unknown[]): InsertBuilder;
92
+ returning(...exprs: ExpressionNode[]): InsertBuilder;
93
+ onConflictDoNothing(...columns: string[]): InsertBuilder;
94
+ onConflictDoUpdate(columns: string[], set: {
95
+ column: string;
96
+ value: ExpressionNode;
97
+ }[], where?: ExpressionNode): InsertBuilder;
98
+ with(name: string, query: SelectNode, recursive?: boolean): InsertBuilder;
99
+ build(): InsertNode;
100
+ }
101
+ declare function insert(table: string | TableRefNode): InsertBuilder;
102
+ declare class UpdateBuilder {
103
+ private node;
104
+ constructor(node?: UpdateNode);
105
+ table(table: string | TableRefNode): UpdateBuilder;
106
+ set(column: string, value: ExpressionNode): UpdateBuilder;
107
+ where(expr: ExpressionNode): UpdateBuilder;
108
+ from(table: string | TableRefNode): UpdateBuilder;
109
+ returning(...exprs: ExpressionNode[]): UpdateBuilder;
110
+ with(name: string, query: SelectNode, recursive?: boolean): UpdateBuilder;
111
+ build(): UpdateNode;
112
+ }
113
+ declare function update(table: string | TableRefNode): UpdateBuilder;
114
+ declare class DeleteBuilder {
115
+ private node;
116
+ constructor(node?: DeleteNode);
117
+ from(table: string | TableRefNode): DeleteBuilder;
118
+ where(expr: ExpressionNode): DeleteBuilder;
119
+ returning(...exprs: ExpressionNode[]): DeleteBuilder;
120
+ with(name: string, query: SelectNode, recursive?: boolean): DeleteBuilder;
121
+ build(): DeleteNode;
122
+ }
123
+ declare function deleteFrom(table: string | TableRefNode): DeleteBuilder;
124
+ interface FormatOptions {
125
+ indent?: string;
126
+ uppercase?: boolean;
127
+ }
128
+ declare function formatSQL(sql: string, options?: FormatOptions): string;
129
+ /**
130
+ * Wadler-style pretty printer document algebra.
131
+ *
132
+ * Based on "A prettier printer" (Wadler 1998) and "Strictly Pretty" (Lindig 2000).
133
+ * Used to format SQL output with width-sensitive line breaking.
134
+ */
135
+ type Doc = {
136
+ tag: "empty";
137
+ } | {
138
+ tag: "text";
139
+ text: string;
140
+ } | {
141
+ tag: "line";
142
+ } | {
143
+ tag: "nest";
144
+ indent: number;
145
+ doc: Doc;
146
+ } | {
147
+ tag: "group";
148
+ doc: Doc;
149
+ } | {
150
+ tag: "concat";
151
+ docs: Doc[];
152
+ };
153
+ declare function empty(): Doc;
154
+ declare function text(s: string): Doc;
155
+ /** A line break. In flat mode, renders as a single space. */
156
+ declare function line(): Doc;
157
+ /** Increase indentation for the nested document. */
158
+ declare function nest(indent: number, doc: Doc): Doc;
159
+ /** Try to render flat; if too wide, break lines. */
160
+ declare function group(doc: Doc): Doc;
161
+ /** Concatenate documents. */
162
+ declare function concat(...docs: Doc[]): Doc;
163
+ /** Join documents with a separator. */
164
+ declare function join(sep: Doc, docs: Doc[]): Doc;
165
+ /** Convenience: text + line */
166
+ declare function textLine(s: string): Doc;
167
+ /**
168
+ * Render a document to a string.
169
+ *
170
+ * Uses Wadler/Lindig's algorithm: maintain a stack of (indent, mode, doc) triples.
171
+ * mode = "flat" (try single line) or "break" (use line breaks).
172
+ */
173
+ declare function render(doc: Doc, width?: number): string;
174
+ declare function quoteIdentifier(name: string, dialect: SQLDialect): string;
175
+ declare function quoteTableRef(name: string, dialect: SQLDialect, schema?: string): string;
176
+ declare function formatParam(index: number, dialect: SQLDialect): string;
177
+ /**
178
+ * A typed column reference that exposes comparison methods.
179
+ *
180
+ * ```ts
181
+ * // users.id.eq(42) → ("id" = $1) with param [42]
182
+ * // users.name.like("%ali%") → ("name" LIKE '%ali%')
183
+ * ```
184
+ */
185
+ declare class Col$1<T> {
186
+ /** @internal */
187
+ readonly _node: ExpressionNode;
188
+ readonly _type: T;
189
+ constructor(column: string, table?: string);
190
+ /** = */
191
+ eq(value: T): Expression<boolean>;
192
+ /** != */
193
+ neq(value: T): Expression<boolean>;
194
+ /** > */
195
+ gt(value: T): Expression<boolean>;
196
+ /** >= */
197
+ gte(value: T): Expression<boolean>;
198
+ /** < */
199
+ lt(value: T): Expression<boolean>;
200
+ /** <= */
201
+ lte(value: T): Expression<boolean>;
202
+ /** LIKE (string columns only) */
203
+ like(this: Col$1<string>, pattern: string): Expression<boolean>;
204
+ /** IN (value1, value2, ...) */
205
+ in(values: T[]): Expression<boolean>;
206
+ /** NOT IN */
207
+ notIn(values: T[]): Expression<boolean>;
208
+ /** IS NULL */
209
+ isNull(): Expression<boolean>;
210
+ /** IS NOT NULL */
211
+ isNotNull(): Expression<boolean>;
212
+ /** BETWEEN low AND high */
213
+ between(low: T, high: T): Expression<boolean>;
214
+ /** Compare with another column: col1.eqCol(col2) */
215
+ eqCol(other: Col$1<T>): Expression<boolean>;
216
+ /** As raw Expression<T> for advanced use */
217
+ toExpr(): Expression<T>;
218
+ }
219
+ declare function resetParams(): void;
220
+ /**
221
+ * Create typed column proxies for a table's columns.
222
+ *
223
+ * Type: { id: Col<number>, name: Col<string>, ... }
224
+ */
225
+ type ColumnProxies<DB, TB extends keyof DB> = { [K in keyof DB[TB] & string]: Col$1<SelectType<DB[TB][K]>> };
226
+ /**
227
+ * Expression builder callback type.
228
+ *
229
+ * ```ts
230
+ * .where(({ id, name }) => id.eq(42))
231
+ * ```
232
+ */
233
+ type WhereCallback<DB, TB extends keyof DB> = (cols: ColumnProxies<DB, TB>) => Expression<boolean>;
234
+ /** AND two expressions */
235
+ declare function and(left: Expression<boolean>, right: Expression<boolean>): Expression<boolean>;
236
+ /** OR two expressions */
237
+ declare function or(left: Expression<boolean>, right: Expression<boolean>): Expression<boolean>;
238
+ /** Raw literal value as expression */
239
+ declare function val<T extends string | number | boolean | null>(value: T): Expression<T>;
240
+ /** SQL function call */
241
+ declare function sqlFn(name: string, ...args: Expression<any>[]): Expression<any>;
242
+ /** COUNT(*) */
243
+ declare function count(): Expression<number>;
244
+ /**
245
+ * Type-safe SELECT query builder.
246
+ *
247
+ * DB = full database schema
248
+ * TB = tables currently in scope (FROM + JOINs)
249
+ * O = output row type
250
+ */
251
+ declare class TypedSelectBuilder<DB, TB extends keyof DB, O> {
252
+ /** @internal */
253
+ readonly _builder: SelectBuilder;
254
+ private _table;
255
+ constructor(builder: SelectBuilder, table?: string);
256
+ /** Select specific columns. Narrows O. */
257
+ select<K extends keyof O & string>(...cols: K[]): TypedSelectBuilder<DB, TB, Pick<O, K>>;
258
+ /** Select all columns. */
259
+ selectAll(): TypedSelectBuilder<DB, TB, O>;
260
+ /** Select with Expression<T> for computed columns. */
261
+ selectExpr<Alias extends string, T>(expr: Expression<T>, alias: Alias): TypedSelectBuilder<DB, TB, O & Record<Alias, T>>;
262
+ /** DISTINCT */
263
+ distinct(): TypedSelectBuilder<DB, TB, O>;
264
+ /**
265
+ * WHERE — accepts callback with typed column proxies OR raw Expression.
266
+ *
267
+ * ```ts
268
+ * // Callback style (recommended)
269
+ * .where(({ id, name }) => id.eq(42))
270
+ * .where(({ age }) => age.between(18, 65))
271
+ *
272
+ * // Raw Expression style
273
+ * .where(typedEq(typedCol<number>("id"), typedParam(0, 42)))
274
+ * ```
275
+ */
276
+ where(exprOrCallback: Expression<boolean> | WhereCallback<DB, TB>): TypedSelectBuilder<DB, TB, O>;
277
+ /**
278
+ * INNER JOIN.
279
+ *
280
+ * ```ts
281
+ * .innerJoin("posts", ({ users, posts }) => users.id.eqCol(posts.userId))
282
+ * ```
283
+ */
284
+ innerJoin<T extends keyof DB & string>(table: T, onOrCallback: Expression<boolean> | ((cols: JoinProxies<DB, TB, T>) => Expression<boolean>)): TypedSelectBuilder<DB, TB | T, O & { [K in keyof DB[T]]: SelectType<DB[T][K]> }>;
285
+ /**
286
+ * LEFT JOIN — joined columns become nullable.
287
+ */
288
+ leftJoin<T extends keyof DB & string>(table: T, onOrCallback: Expression<boolean> | ((cols: JoinProxies<DB, TB, T>) => Expression<boolean>)): TypedSelectBuilder<DB, TB | T, O & Nullable$1<{ [K in keyof DB[T]]: SelectType<DB[T][K]> }>>;
289
+ /** RIGHT JOIN */
290
+ rightJoin<T extends keyof DB & string>(table: T, onOrCallback: Expression<boolean> | ((cols: JoinProxies<DB, TB, T>) => Expression<boolean>)): TypedSelectBuilder<DB, TB | T, Nullable$1<O> & { [K in keyof DB[T]]: SelectType<DB[T][K]> }>;
291
+ /** GROUP BY */
292
+ groupBy(...cols: (keyof O & string)[]): TypedSelectBuilder<DB, TB, O>;
293
+ /** HAVING */
294
+ having(exprOrCallback: Expression<boolean> | WhereCallback<DB, TB>): TypedSelectBuilder<DB, TB, O>;
295
+ /** ORDER BY */
296
+ orderBy(col: keyof O & string, direction?: OrderDirection, nulls?: "FIRST" | "LAST"): TypedSelectBuilder<DB, TB, O>;
297
+ /** LIMIT */
298
+ limit(n: number): TypedSelectBuilder<DB, TB, O>;
299
+ /** OFFSET */
300
+ offset(n: number): TypedSelectBuilder<DB, TB, O>;
301
+ /** FOR UPDATE */
302
+ forUpdate(): TypedSelectBuilder<DB, TB, O>;
303
+ /** WITH (CTE) */
304
+ with(name: string, query: SelectNode, recursive?: boolean): TypedSelectBuilder<DB, TB, O>;
305
+ /** UNION */
306
+ union(query: TypedSelectBuilder<DB, any, O>): TypedSelectBuilder<DB, TB, O>;
307
+ /** UNION ALL */
308
+ unionAll(query: TypedSelectBuilder<DB, any, O>): TypedSelectBuilder<DB, TB, O>;
309
+ /** Build the AST node. */
310
+ build(): SelectNode;
311
+ /** Compile to SQL. */
312
+ compile(printer: Printer): CompiledQuery;
313
+ }
314
+ type JoinProxies<DB, TB extends keyof DB, T extends keyof DB> = { [Table in (TB | T) & string]: ColumnProxies<DB, Table & keyof DB> };
315
+ /**
316
+ * Type-safe INSERT query builder.
317
+ */
318
+ declare class TypedInsertBuilder<DB, TB extends keyof DB> {
319
+ /** @internal */
320
+ readonly _builder: InsertBuilder;
321
+ private _paramIdx;
322
+ constructor(table: TB & string, paramIdx?: number);
323
+ /** @internal */
324
+ private _withBuilder;
325
+ /**
326
+ * Insert a single row. Columns/values inferred from Insertable<DB[TB]>.
327
+ */
328
+ values(row: Insertable<DB[TB]>): TypedInsertBuilder<DB, TB>;
329
+ /**
330
+ * RETURNING specific columns.
331
+ */
332
+ returning<K extends keyof DB[TB] & string>(...cols: K[]): TypedInsertReturningBuilder<DB, TB, Pick<{ [C in keyof DB[TB]]: SelectType<DB[TB][C]> }, K>>;
333
+ /**
334
+ * RETURNING all columns.
335
+ */
336
+ returningAll(): TypedInsertReturningBuilder<DB, TB, { [K in keyof DB[TB]]: SelectType<DB[TB][K]> }>;
337
+ /**
338
+ * ON CONFLICT DO NOTHING.
339
+ */
340
+ onConflictDoNothing(...columns: (keyof DB[TB] & string)[]): TypedInsertBuilder<DB, TB>;
341
+ /**
342
+ * ON CONFLICT DO UPDATE.
343
+ */
344
+ onConflictDoUpdate(columns: (keyof DB[TB] & string)[], set: {
345
+ column: keyof DB[TB] & string;
346
+ value: Expression<any>;
347
+ }[]): TypedInsertBuilder<DB, TB>;
348
+ build(): InsertNode;
349
+ compile(printer: Printer): CompiledQuery;
350
+ }
351
+ declare class TypedInsertReturningBuilder<DB, _TB extends keyof DB, _R> {
352
+ /** @internal */
353
+ readonly _builder: InsertBuilder;
354
+ constructor(builder: InsertBuilder);
355
+ build(): InsertNode;
356
+ compile(printer: Printer): CompiledQuery;
357
+ }
358
+ /**
359
+ * Type-safe UPDATE query builder.
360
+ */
361
+ declare class TypedUpdateBuilder<DB, TB extends keyof DB> {
362
+ /** @internal */
363
+ readonly _builder: UpdateBuilder;
364
+ private _paramIdx;
365
+ constructor(table: TB & string, paramIdx?: number);
366
+ /** @internal */
367
+ private _with;
368
+ /**
369
+ * SET columns from an object. All keys optional (Updateable).
370
+ */
371
+ set(values: Updateable<DB[TB]>): TypedUpdateBuilder<DB, TB>;
372
+ /**
373
+ * SET a single column with an expression.
374
+ */
375
+ setExpr(column: keyof DB[TB] & string, value: Expression<any>): TypedUpdateBuilder<DB, TB>;
376
+ /**
377
+ * WHERE — callback or raw Expression.
378
+ */
379
+ where(exprOrCallback: Expression<boolean> | WhereCallback<DB, TB>): TypedUpdateBuilder<DB, TB>;
380
+ private get _table();
381
+ /**
382
+ * RETURNING specific columns.
383
+ */
384
+ returning<K extends keyof DB[TB] & string>(...cols: K[]): TypedUpdateReturningBuilder<DB, TB, Pick<{ [C in keyof DB[TB]]: SelectType<DB[TB][C]> }, K>>;
385
+ /**
386
+ * RETURNING all columns.
387
+ */
388
+ returningAll(): TypedUpdateReturningBuilder<DB, TB, { [K in keyof DB[TB]]: SelectType<DB[TB][K]> }>;
389
+ build(): UpdateNode;
390
+ compile(printer: Printer): CompiledQuery;
391
+ }
392
+ declare class TypedUpdateReturningBuilder<DB, _TB extends keyof DB, _R> {
393
+ /** @internal */
394
+ readonly _builder: UpdateBuilder;
395
+ constructor(builder: UpdateBuilder);
396
+ build(): UpdateNode;
397
+ compile(printer: Printer): CompiledQuery;
398
+ }
399
+ /**
400
+ * Type-safe DELETE query builder.
401
+ */
402
+ declare class TypedDeleteBuilder<DB, TB extends keyof DB> {
403
+ /** @internal */
404
+ readonly _builder: DeleteBuilder;
405
+ constructor(table: TB & string);
406
+ /** @internal */
407
+ private _with;
408
+ /**
409
+ * WHERE — callback or raw Expression.
410
+ */
411
+ where(exprOrCallback: Expression<boolean> | WhereCallback<DB, TB>): TypedDeleteBuilder<DB, TB>;
412
+ /**
413
+ * RETURNING specific columns.
414
+ */
415
+ returning<K extends keyof DB[TB] & string>(...cols: K[]): TypedDeleteReturningBuilder<DB, TB, Pick<{ [C in keyof DB[TB]]: SelectType<DB[TB][C]> }, K>>;
416
+ /**
417
+ * RETURNING all columns.
418
+ */
419
+ returningAll(): TypedDeleteReturningBuilder<DB, TB, { [K in keyof DB[TB]]: SelectType<DB[TB][K]> }>;
420
+ build(): DeleteNode;
421
+ compile(printer: Printer): CompiledQuery;
422
+ }
423
+ declare class TypedDeleteReturningBuilder<DB, _TB extends keyof DB, _R> {
424
+ /** @internal */
425
+ readonly _builder: DeleteBuilder;
426
+ constructor(builder: DeleteBuilder);
427
+ build(): DeleteNode;
428
+ compile(printer: Printer): CompiledQuery;
429
+ }
430
+ /**
431
+ * Plugin interface for pamuk.
432
+ *
433
+ * Plugins can intercept at three points:
434
+ * 1. transformNode — modify the AST before compilation
435
+ * 2. transformQuery — modify the compiled SQL after generation
436
+ * 3. transformResult — modify result rows after execution
437
+ */
438
+ interface PamukPlugin {
439
+ readonly name: string;
440
+ /** Transform AST before compilation. Return a new node (never mutate). */
441
+ transformNode?(node: ASTNode): ASTNode;
442
+ /** Transform compiled query after SQL generation. */
443
+ transformQuery?(query: CompiledQuery): CompiledQuery;
444
+ /** Transform result rows after execution. */
445
+ transformResult?(rows: Record<string, unknown>[]): Record<string, unknown>[];
446
+ }
447
+ /**
448
+ * Hook context passed to hook handlers.
449
+ */
450
+ interface HookContext<T extends ASTNode = ASTNode> {
451
+ /** The AST node being processed */
452
+ node: T;
453
+ /** Table name (if applicable) */
454
+ table?: string;
455
+ /** Compiled query (only in after hooks) */
456
+ query?: CompiledQuery;
457
+ }
458
+ /**
459
+ * All available hook points in the query lifecycle.
460
+ */
461
+ interface PamukHooks {
462
+ /** Fires before any query is compiled. Can modify the AST. */
463
+ "query:before": (ctx: HookContext) => ASTNode | void;
464
+ /** Fires after a query is compiled to SQL. Can modify the compiled query. */
465
+ "query:after": (ctx: HookContext & {
466
+ query: CompiledQuery;
467
+ }) => CompiledQuery | void;
468
+ /** Fires before SELECT compilation. Can modify the SelectNode. */
469
+ "select:before": (ctx: HookContext<SelectNode>) => SelectNode | void;
470
+ /** Fires before INSERT compilation. Can modify the InsertNode. */
471
+ "insert:before": (ctx: HookContext<InsertNode>) => InsertNode | void;
472
+ /** Fires before UPDATE compilation. Can modify the UpdateNode. */
473
+ "update:before": (ctx: HookContext<UpdateNode>) => UpdateNode | void;
474
+ /** Fires before DELETE compilation. Can modify the DeleteNode. */
475
+ "delete:before": (ctx: HookContext<DeleteNode>) => DeleteNode | void;
476
+ /** Transform result rows. */
477
+ "result:transform": (rows: Record<string, unknown>[]) => Record<string, unknown>[];
478
+ }
479
+ type HookName = keyof PamukHooks;
480
+ /**
481
+ * Hookable system — register and execute hooks.
482
+ *
483
+ * ```ts
484
+ * const hooks = new Hookable();
485
+ * hooks.hook("select:before", (ctx) => {
486
+ * // Add soft delete filter
487
+ * return { ...ctx.node, where: addSoftDelete(ctx.node.where) };
488
+ * });
489
+ * ```
490
+ */
491
+ declare class Hookable {
492
+ private _hooks;
493
+ /**
494
+ * Register a hook handler.
495
+ * Returns an unregister function.
496
+ */
497
+ hook<K extends HookName>(name: K, handler: PamukHooks[K]): () => void;
498
+ /**
499
+ * Execute all handlers for a hook.
500
+ * For AST hooks: each handler can return a modified node, which feeds into the next.
501
+ * For result hooks: each handler transforms the rows.
502
+ */
503
+ callHook<K extends HookName>(name: K, ...args: Parameters<PamukHooks[K]>): ReturnType<PamukHooks[K]> | undefined;
504
+ /**
505
+ * Check if any handlers are registered for a hook.
506
+ */
507
+ hasHook(name: HookName): boolean;
508
+ /**
509
+ * Remove all handlers for a hook.
510
+ */
511
+ removeHook(name: HookName): void;
512
+ /**
513
+ * Remove all hooks.
514
+ */
515
+ removeAllHooks(): void;
516
+ }
517
+ /**
518
+ * Extract the DB type from a tables config object.
519
+ */
520
+ type InferDB<T extends Record<string, Record<string, ColumnBuilder<any, any, any>>>> = { [Table in keyof T]: { [Col in keyof T[Table]]: T[Table][Col] extends ColumnBuilder<infer S, infer I, infer U> ? ColumnType<S, I, U> : never } };
521
+ interface PamukConfig<T extends Record<string, Record<string, ColumnBuilder<any, any, any>>>> {
522
+ dialect: Dialect;
523
+ tables: T;
524
+ plugins?: PamukPlugin[];
525
+ }
526
+ /**
527
+ * Create a fully typed pamuk instance. DB type is inferred automatically.
528
+ *
529
+ * ```ts
530
+ * const db = pamuk({
531
+ * dialect: pgDialect(),
532
+ * tables: {
533
+ * users: { id: serial(), name: text().notNull() },
534
+ * },
535
+ * });
536
+ *
537
+ * // Hook into the query lifecycle
538
+ * db.hook("select:before", (ctx) => {
539
+ * console.log("Selecting from:", ctx.table);
540
+ * });
541
+ *
542
+ * db.selectFrom("users").select("id", "name")...
543
+ * ```
544
+ */
545
+ declare function pamuk<T extends Record<string, Record<string, ColumnBuilder<any, any, any>>>>(config: PamukConfig<T>): Lale<InferDB<T>>;
546
+ /**
547
+ * Core pamuk instance with hook system.
548
+ */
549
+ declare class Pamuk<DB> {
550
+ private _dialect;
551
+ private _plugins;
552
+ private _hooks;
553
+ constructor(dialect: Dialect, plugins?: PamukPlugin[]);
554
+ /**
555
+ * Register a hook handler. Returns an unregister function.
556
+ *
557
+ * ```ts
558
+ * const off = db.hook("query:before", (ctx) => { ... });
559
+ * off(); // unregister
560
+ * ```
561
+ */
562
+ hook<K extends HookName>(name: K, handler: PamukHooks[K]): () => void;
563
+ selectFrom<T extends keyof DB & string>(table: T, alias?: string): TypedSelectBuilder<DB, T, { [K in keyof DB[T]]: SelectType<DB[T][K]> }>;
564
+ insertInto<T extends keyof DB & string>(table: T): TypedInsertBuilder<DB, T>;
565
+ update<T extends keyof DB & string>(table: T): TypedUpdateBuilder<DB, T>;
566
+ deleteFrom<T extends keyof DB & string>(table: T): TypedDeleteBuilder<DB, T>;
567
+ /**
568
+ * Compile an AST node through the full pipeline:
569
+ * plugins.transformNode → type-specific hooks → printer → plugins.transformQuery → query hooks
570
+ */
571
+ compile(node: ASTNode): CompiledQuery;
572
+ /**
573
+ * Transform result rows through plugins and hooks.
574
+ */
575
+ transformResult(rows: Record<string, unknown>[]): Record<string, unknown>[];
576
+ printer(): Printer;
577
+ private _extractTableName;
578
+ }
579
+ /**
580
+ * Manages plugin execution pipeline.
581
+ * Plugins are applied sequentially in registration order.
582
+ */
583
+ declare class PluginManager {
584
+ private readonly plugins;
585
+ constructor(plugins: PamukPlugin[]);
586
+ /** Apply all transformNode phases in order. */
587
+ transformNode(node: ASTNode): ASTNode;
588
+ /** Apply all transformQuery phases in order. */
589
+ transformQuery(query: CompiledQuery): CompiledQuery;
590
+ /** Apply all transformResult phases in order. */
591
+ transformResult(rows: Record<string, unknown>[]): Record<string, unknown>[];
592
+ }
593
+ /**
594
+ * Plugin that prepends a schema name to all table references.
595
+ *
596
+ * ```ts
597
+ * const plugin = new WithSchemaPlugin("public");
598
+ * // SELECT * FROM "users" → SELECT * FROM "public"."users"
599
+ * ```
600
+ */
601
+ declare class WithSchemaPlugin implements PamukPlugin {
602
+ readonly name = "with-schema";
603
+ private schema;
604
+ constructor(schema: string);
605
+ transformNode(node: ASTNode): ASTNode;
606
+ private addSchema;
607
+ private transformSelect;
608
+ private transformInsert;
609
+ private transformUpdate;
610
+ private transformDelete;
611
+ }
612
+ /**
613
+ * Plugin that automatically adds `WHERE deleted_at IS NULL` to
614
+ * SELECT, UPDATE, and DELETE queries for configured tables.
615
+ *
616
+ * ```ts
617
+ * const plugin = new SoftDeletePlugin({ tables: ["users", "posts"] });
618
+ * // SELECT * FROM "users" → SELECT * FROM "users" WHERE "deleted_at" IS NULL
619
+ * ```
620
+ */
621
+ declare class SoftDeletePlugin implements PamukPlugin {
622
+ readonly name = "soft-delete";
623
+ private tables;
624
+ private column;
625
+ constructor(config: {
626
+ tables: string[];
627
+ column?: string;
628
+ });
629
+ transformNode(node: ASTNode): ASTNode;
630
+ private isTargetTable;
631
+ private softDeleteCondition;
632
+ private addCondition;
633
+ private transformSelect;
634
+ private transformUpdate;
635
+ private transformDelete;
636
+ }
637
+ /**
638
+ * Plugin that converts snake_case result column names to camelCase.
639
+ *
640
+ * This plugin operates on results only — it does NOT transform the AST.
641
+ * Use it when your database uses snake_case but your TypeScript code uses camelCase.
642
+ */
643
+ declare class CamelCasePlugin implements PamukPlugin {
644
+ readonly name = "camel-case";
645
+ transformResult(rows: Record<string, unknown>[]): Record<string, unknown>[];
646
+ }
647
+ declare class PamukError extends Error {
648
+ constructor(message: string);
649
+ }
650
+ declare class InvalidExpressionError extends PamukError {
651
+ constructor(message: string);
652
+ }
653
+ declare class UnsupportedDialectFeatureError extends PamukError {
654
+ constructor(dialect: string, feature: string);
655
+ }
656
+ declare class EmptyQueryError extends PamukError {
657
+ constructor(queryType: string);
658
+ }
659
+ export { type ASTNode, ASTTransformer, type ASTVisitor, type ArrayExprNode, BasePrinter, type BetweenNode, type BinaryOpNode, type CTENode, CamelCasePlugin, type CaseNode, type CastNode, Col$1 as Col, ColumnBuilder, type ColumnDef, type ColumnProxies, type ColumnRefNode, type ColumnType, type CompiledQuery, DeleteBuilder, type DeleteNode, type Dialect, type DialectConfig, type Doc, EmptyQueryError, type ExistsNode, type Expression, type ExpressionNode, type FormatOptions, type FrameBound, type FrameKind, type FrameSpec, type FunctionCallNode, type Generated, type GeneratedAlways, type HookContext, type HookName, Hookable, type InNode, type InferTable, InsertBuilder, type InsertNode, type InsertType, type Insertable, InvalidExpressionError, type IsNullNode, type JoinNode, type JoinType, type JsonAccessNode, type LiteralNode, MysqlPrinter, type Nullable, type OnConflictNode, type OrderByNode, type OrderDirection, Pamuk, type PamukConfig, PamukError, type PamukHooks, type PamukPlugin, type ParamNode, PgPrinter, PluginManager, type Primitive, type PrintMode, type Printer, type PrinterOptions, type RawNode, type SQLDialect, SelectBuilder, type SelectNode, type SelectType, type Selectable, type SetOperator, SoftDeletePlugin, SqlitePrinter, type StarNode, type SubqueryNode, type TableDefinition, type TableRefNode, TypedDeleteBuilder, TypedDeleteReturningBuilder, TypedInsertBuilder, TypedInsertReturningBuilder, TypedSelectBuilder, TypedUpdateBuilder, TypedUpdateReturningBuilder, type UnaryOpNode, UnsupportedDialectFeatureError, UpdateBuilder, type UpdateNode, type UpdateType, type Updateable, type WhereCallback, type WindowFunctionNode, WithSchemaPlugin, and, between, bigint, bigserial, binOp, boolean, bytea, cast, char, col, colAs, count, createDeleteNode, createInsertNode, createSelectNode, createUpdateNode, date, defineTable, deleteFrom, concat as docConcat, empty as docEmpty, group as docGroup, join as docJoin, line as docLine, nest as docNest, render as docRender, text as docText, textLine as docTextLine, doublePrecision, enumType, eq, exists, fn, formatParam, formatSQL, gt, gte, inList, insert, integer, isNull, json, jsonb, like, lit, lt, lte, mysqlDialect, neq, not, numeric, or, pamuk, param, pgDialect, quoteIdentifier, quoteTableRef, raw, real, resetParams, select, serial, smallint, sqlFn, sqliteDialect, star, subquery, tableRef, text$1 as text, time, timestamp, timestamptz, unaryOp, update, uuid, val, varchar, visitNode };