sqlparser-rs 0.60.2 → 0.60.3-rc2

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.
Files changed (48) hide show
  1. package/README.md +65 -32
  2. package/dist/index.cjs +526 -0
  3. package/dist/index.d.cts +1438 -0
  4. package/dist/index.d.mts +1438 -0
  5. package/dist/index.mjs +502 -0
  6. package/package.json +11 -11
  7. package/wasm/README.md +65 -32
  8. package/wasm/package.json +1 -1
  9. package/wasm/sqlparser_rs_wasm_bg.wasm +0 -0
  10. package/wasm/sqlparser_rs_wasm_web.js +628 -0
  11. package/wasm/sqlparser_rs_wasm_web_bg.wasm +0 -0
  12. package/dist/cjs/dialects.js +0 -202
  13. package/dist/cjs/dialects.js.map +0 -1
  14. package/dist/cjs/index.js +0 -81
  15. package/dist/cjs/index.js.map +0 -1
  16. package/dist/cjs/parser.js +0 -191
  17. package/dist/cjs/parser.js.map +0 -1
  18. package/dist/cjs/types/ast.js +0 -10
  19. package/dist/cjs/types/ast.js.map +0 -1
  20. package/dist/cjs/types/errors.js +0 -49
  21. package/dist/cjs/types/errors.js.map +0 -1
  22. package/dist/cjs/types/index.js +0 -19
  23. package/dist/cjs/types/index.js.map +0 -1
  24. package/dist/esm/dialects.js +0 -184
  25. package/dist/esm/dialects.js.map +0 -1
  26. package/dist/esm/index.js +0 -47
  27. package/dist/esm/index.js.map +0 -1
  28. package/dist/esm/package.json +0 -1
  29. package/dist/esm/parser.js +0 -187
  30. package/dist/esm/parser.js.map +0 -1
  31. package/dist/esm/types/ast.js +0 -9
  32. package/dist/esm/types/ast.js.map +0 -1
  33. package/dist/esm/types/errors.js +0 -44
  34. package/dist/esm/types/errors.js.map +0 -1
  35. package/dist/esm/types/index.js +0 -3
  36. package/dist/esm/types/index.js.map +0 -1
  37. package/dist/types/dialects.d.ts +0 -118
  38. package/dist/types/dialects.d.ts.map +0 -1
  39. package/dist/types/index.d.ts +0 -46
  40. package/dist/types/index.d.ts.map +0 -1
  41. package/dist/types/parser.d.ts +0 -116
  42. package/dist/types/parser.d.ts.map +0 -1
  43. package/dist/types/types/ast.d.ts +0 -1097
  44. package/dist/types/types/ast.d.ts.map +0 -1
  45. package/dist/types/types/errors.d.ts +0 -25
  46. package/dist/types/types/errors.d.ts.map +0 -1
  47. package/dist/types/types/index.d.ts +0 -3
  48. package/dist/types/types/index.d.ts.map +0 -1
@@ -0,0 +1,1438 @@
1
+ //#region src/dialects.d.ts
2
+ /**
3
+ * SQL Dialects
4
+ *
5
+ * Each dialect class represents a specific SQL dialect supported by the parser.
6
+ * These are thin wrappers that provide type safety and a clean API.
7
+ */
8
+ /**
9
+ * Base interface for all dialects
10
+ */
11
+ interface Dialect {
12
+ /** The name of the dialect as recognized by the WASM module */
13
+ readonly name: string;
14
+ }
15
+ /**
16
+ * Generic SQL dialect - accepts most SQL syntax
17
+ */
18
+ declare class GenericDialect implements Dialect {
19
+ readonly name = "generic";
20
+ }
21
+ /**
22
+ * ANSI SQL standard dialect
23
+ */
24
+ declare class AnsiDialect implements Dialect {
25
+ readonly name = "ansi";
26
+ }
27
+ /**
28
+ * MySQL dialect
29
+ */
30
+ declare class MySqlDialect implements Dialect {
31
+ readonly name = "mysql";
32
+ }
33
+ /**
34
+ * PostgreSQL dialect
35
+ */
36
+ declare class PostgreSqlDialect implements Dialect {
37
+ readonly name = "postgresql";
38
+ }
39
+ /**
40
+ * SQLite dialect
41
+ */
42
+ declare class SQLiteDialect implements Dialect {
43
+ readonly name = "sqlite";
44
+ }
45
+ /**
46
+ * Snowflake dialect
47
+ */
48
+ declare class SnowflakeDialect implements Dialect {
49
+ readonly name = "snowflake";
50
+ }
51
+ /**
52
+ * Amazon Redshift dialect
53
+ */
54
+ declare class RedshiftDialect implements Dialect {
55
+ readonly name = "redshift";
56
+ }
57
+ /**
58
+ * Microsoft SQL Server dialect
59
+ */
60
+ declare class MsSqlDialect implements Dialect {
61
+ readonly name = "mssql";
62
+ }
63
+ /**
64
+ * ClickHouse dialect
65
+ */
66
+ declare class ClickHouseDialect implements Dialect {
67
+ readonly name = "clickhouse";
68
+ }
69
+ /**
70
+ * Google BigQuery dialect
71
+ */
72
+ declare class BigQueryDialect implements Dialect {
73
+ readonly name = "bigquery";
74
+ }
75
+ /**
76
+ * DuckDB dialect
77
+ */
78
+ declare class DuckDbDialect implements Dialect {
79
+ readonly name = "duckdb";
80
+ }
81
+ /**
82
+ * Databricks dialect
83
+ */
84
+ declare class DatabricksDialect implements Dialect {
85
+ readonly name = "databricks";
86
+ }
87
+ /**
88
+ * Apache Hive dialect
89
+ */
90
+ declare class HiveDialect implements Dialect {
91
+ readonly name = "hive";
92
+ }
93
+ /**
94
+ * Oracle dialect
95
+ */
96
+ declare class OracleDialect implements Dialect {
97
+ readonly name = "oracle";
98
+ }
99
+ /**
100
+ * All supported dialect names
101
+ */
102
+ declare const SUPPORTED_DIALECTS: readonly ["generic", "ansi", "mysql", "postgresql", "sqlite", "snowflake", "redshift", "mssql", "clickhouse", "bigquery", "duckdb", "databricks", "hive", "oracle"];
103
+ type DialectName = (typeof SUPPORTED_DIALECTS)[number];
104
+ /**
105
+ * Create a dialect instance from a string name
106
+ *
107
+ * @param name - The name of the dialect (case-insensitive)
108
+ * @returns A dialect instance, or undefined if the dialect is not recognized
109
+ *
110
+ * @example
111
+ * ```typescript
112
+ * const dialect = dialectFromString('postgresql');
113
+ * if (dialect) {
114
+ * const ast = Parser.parse('SELECT 1', dialect);
115
+ * }
116
+ * ```
117
+ */
118
+ declare function dialectFromString(name: string): Dialect | undefined;
119
+ //#endregion
120
+ //#region src/types/ast.d.ts
121
+ /**
122
+ * TypeScript type definitions for sqlparser-rs AST
123
+ *
124
+ * These types mirror the Rust AST structure from the sqlparser crate.
125
+ * The AST is serialized as JSON from Rust, so these types represent
126
+ * the JSON structure.
127
+ */
128
+ /**
129
+ * An identifier (table name, column name, etc.)
130
+ */
131
+ interface Ident {
132
+ value: string;
133
+ quoteStyle?: string | null;
134
+ }
135
+ /**
136
+ * A compound identifier like schema.table.column
137
+ */
138
+ type ObjectName = Ident[];
139
+ /**
140
+ * Binary operators
141
+ */
142
+ type BinaryOperator = 'Plus' | 'Minus' | 'Multiply' | 'Divide' | 'Modulo' | 'StringConcat' | 'Gt' | 'Lt' | 'GtEq' | 'LtEq' | 'Spaceship' | 'Eq' | 'NotEq' | 'And' | 'Or' | 'Xor' | 'BitwiseOr' | 'BitwiseAnd' | 'BitwiseXor' | 'PGBitwiseXor' | 'PGBitwiseShiftLeft' | 'PGBitwiseShiftRight' | 'PGRegexMatch' | 'PGRegexIMatch' | 'PGRegexNotMatch' | 'PGRegexNotIMatch';
143
+ /**
144
+ * Unary operators
145
+ */
146
+ type UnaryOperator = 'Plus' | 'Minus' | 'Not' | 'PGBitwiseNot' | 'PGSquareRoot' | 'PGCubeRoot' | 'PGPostfixFactorial' | 'PGPrefixFactorial' | 'PGAbs';
147
+ /**
148
+ * SQL Value types
149
+ */
150
+ type Value = {
151
+ Number: [string, boolean];
152
+ } | {
153
+ SingleQuotedString: string;
154
+ } | {
155
+ DoubleQuotedString: string;
156
+ } | {
157
+ DollarQuotedString: {
158
+ value: string;
159
+ tag?: string;
160
+ };
161
+ } | {
162
+ EscapedStringLiteral: string;
163
+ } | {
164
+ NationalStringLiteral: string;
165
+ } | {
166
+ HexStringLiteral: string;
167
+ } | {
168
+ Boolean: boolean;
169
+ } | {
170
+ Null: null;
171
+ } | {
172
+ Placeholder: string;
173
+ };
174
+ /**
175
+ * SQL Expression
176
+ */
177
+ type Expr = {
178
+ Identifier: Ident;
179
+ } | {
180
+ CompoundIdentifier: Ident[];
181
+ } | {
182
+ Value: Value;
183
+ } | {
184
+ BinaryOp: {
185
+ left: Expr;
186
+ op: BinaryOperator;
187
+ right: Expr;
188
+ };
189
+ } | {
190
+ UnaryOp: {
191
+ op: UnaryOperator;
192
+ expr: Expr;
193
+ };
194
+ } | {
195
+ Nested: Expr;
196
+ } | {
197
+ IsNull: Expr;
198
+ } | {
199
+ IsNotNull: Expr;
200
+ } | {
201
+ IsTrue: Expr;
202
+ } | {
203
+ IsFalse: Expr;
204
+ } | {
205
+ IsUnknown: Expr;
206
+ } | {
207
+ IsNotTrue: Expr;
208
+ } | {
209
+ IsNotFalse: Expr;
210
+ } | {
211
+ IsNotUnknown: Expr;
212
+ } | {
213
+ InList: {
214
+ expr: Expr;
215
+ list: Expr[];
216
+ negated: boolean;
217
+ };
218
+ } | {
219
+ InSubquery: {
220
+ expr: Expr;
221
+ subquery: Query;
222
+ negated: boolean;
223
+ };
224
+ } | {
225
+ Between: {
226
+ expr: Expr;
227
+ negated: boolean;
228
+ low: Expr;
229
+ high: Expr;
230
+ };
231
+ } | {
232
+ Like: {
233
+ expr: Expr;
234
+ negated: boolean;
235
+ pattern: Expr;
236
+ escapeChar?: string;
237
+ };
238
+ } | {
239
+ ILike: {
240
+ expr: Expr;
241
+ negated: boolean;
242
+ pattern: Expr;
243
+ escapeChar?: string;
244
+ };
245
+ } | {
246
+ SimilarTo: {
247
+ expr: Expr;
248
+ negated: boolean;
249
+ pattern: Expr;
250
+ escapeChar?: string;
251
+ };
252
+ } | {
253
+ Case: {
254
+ operand?: Expr;
255
+ conditions: Expr[];
256
+ results: Expr[];
257
+ elseResult?: Expr;
258
+ };
259
+ } | {
260
+ Cast: {
261
+ expr: Expr;
262
+ dataType: DataType;
263
+ };
264
+ } | {
265
+ TryCast: {
266
+ expr: Expr;
267
+ dataType: DataType;
268
+ };
269
+ } | {
270
+ SafeCast: {
271
+ expr: Expr;
272
+ dataType: DataType;
273
+ };
274
+ } | {
275
+ Extract: {
276
+ field: DateTimeField;
277
+ expr: Expr;
278
+ };
279
+ } | {
280
+ Substring: {
281
+ expr: Expr;
282
+ substringFrom?: Expr;
283
+ substringFor?: Expr;
284
+ };
285
+ } | {
286
+ Trim: {
287
+ expr: Expr;
288
+ trimWhere?: TrimWhereField;
289
+ trimWhat?: Expr;
290
+ };
291
+ } | {
292
+ Collate: {
293
+ expr: Expr;
294
+ collation: ObjectName;
295
+ };
296
+ } | {
297
+ Function: FunctionExpr;
298
+ } | {
299
+ Subquery: Query;
300
+ } | {
301
+ Exists: {
302
+ subquery: Query;
303
+ negated: boolean;
304
+ };
305
+ } | {
306
+ Wildcard: null;
307
+ } | {
308
+ QualifiedWildcard: ObjectName;
309
+ } | {
310
+ Tuple: Expr[];
311
+ } | {
312
+ Array: {
313
+ elem: Expr[];
314
+ named: boolean;
315
+ };
316
+ } | {
317
+ MapAccess: {
318
+ column: Expr;
319
+ keys: Expr[];
320
+ };
321
+ } | {
322
+ CompositeAccess: {
323
+ expr: Expr;
324
+ key: Ident;
325
+ };
326
+ } | {
327
+ TypedString: {
328
+ dataType: DataType;
329
+ value: string;
330
+ };
331
+ } | {
332
+ AtTimeZone: {
333
+ timestamp: Expr;
334
+ timeZone: string;
335
+ };
336
+ } | {
337
+ Interval: IntervalExpr;
338
+ } | 'Wildcard';
339
+ /**
340
+ * Function expression
341
+ */
342
+ interface FunctionExpr {
343
+ name: ObjectName;
344
+ args: FunctionArg[];
345
+ over?: WindowSpec;
346
+ distinct: boolean;
347
+ special: boolean;
348
+ orderBy: OrderByExpr[];
349
+ }
350
+ /**
351
+ * Function argument
352
+ */
353
+ type FunctionArg = {
354
+ Unnamed: FunctionArgExpr;
355
+ } | {
356
+ Named: {
357
+ name: Ident;
358
+ arg: FunctionArgExpr;
359
+ };
360
+ };
361
+ type FunctionArgExpr = {
362
+ Expr: Expr;
363
+ } | {
364
+ QualifiedWildcard: ObjectName;
365
+ } | 'Wildcard';
366
+ /**
367
+ * Interval expression
368
+ */
369
+ interface IntervalExpr {
370
+ value: Expr;
371
+ leadingField?: DateTimeField;
372
+ leadingPrecision?: number;
373
+ lastField?: DateTimeField;
374
+ fractionalSecondsPrecision?: number;
375
+ }
376
+ /**
377
+ * Date/time field for EXTRACT
378
+ */
379
+ type DateTimeField = 'Year' | 'Month' | 'Week' | 'Day' | 'Hour' | 'Minute' | 'Second' | 'Millisecond' | 'Microsecond' | 'Nanosecond' | 'Century' | 'Decade' | 'Dow' | 'Doy' | 'Epoch' | 'Isodow' | 'Isoyear' | 'Julian' | 'Quarter' | 'Timezone' | 'TimezoneHour' | 'TimezoneMinute';
380
+ /**
381
+ * Trim where field
382
+ */
383
+ type TrimWhereField = 'Both' | 'Leading' | 'Trailing';
384
+ /**
385
+ * SQL Data types
386
+ */
387
+ type DataType = 'Boolean' | 'TinyInt' | 'SmallInt' | 'Int' | 'Integer' | 'BigInt' | {
388
+ Float: number | null;
389
+ } | 'Real' | 'Double' | {
390
+ Decimal: [number | null, number | null];
391
+ } | {
392
+ Numeric: [number | null, number | null];
393
+ } | {
394
+ Varchar: number | null;
395
+ } | {
396
+ Char: number | null;
397
+ } | 'Text' | 'Uuid' | 'Date' | {
398
+ Time: [number | null, boolean];
399
+ } | {
400
+ Timestamp: [number | null, boolean];
401
+ } | 'Interval' | 'Binary' | {
402
+ Varbinary: number | null;
403
+ } | 'Blob' | 'Bytes' | 'Json' | 'Jsonb' | {
404
+ Array: DataType;
405
+ } | {
406
+ Custom: [ObjectName, string[]];
407
+ } | 'Regclass' | 'String';
408
+ /**
409
+ * Window specification
410
+ */
411
+ interface WindowSpec {
412
+ partitionBy: Expr[];
413
+ orderBy: OrderByExpr[];
414
+ windowFrame?: WindowFrame;
415
+ }
416
+ /**
417
+ * Window frame
418
+ */
419
+ interface WindowFrame {
420
+ units: WindowFrameUnits;
421
+ startBound: WindowFrameBound;
422
+ endBound?: WindowFrameBound;
423
+ }
424
+ type WindowFrameUnits = 'Rows' | 'Range' | 'Groups';
425
+ type WindowFrameBound = 'CurrentRow' | 'UnboundedPreceding' | 'UnboundedFollowing' | {
426
+ Preceding: Expr | null;
427
+ } | {
428
+ Following: Expr | null;
429
+ };
430
+ /**
431
+ * ORDER BY expression
432
+ */
433
+ interface OrderByExpr {
434
+ expr: Expr;
435
+ asc?: boolean;
436
+ nullsFirst?: boolean;
437
+ }
438
+ /**
439
+ * SELECT item
440
+ */
441
+ type SelectItem = 'UnnamedExpr' | {
442
+ UnnamedExpr: Expr;
443
+ } | {
444
+ ExprWithAlias: {
445
+ expr: Expr;
446
+ alias: Ident;
447
+ };
448
+ } | {
449
+ QualifiedWildcard: [ObjectName, WildcardAdditionalOptions];
450
+ } | {
451
+ Wildcard: WildcardAdditionalOptions;
452
+ };
453
+ interface WildcardAdditionalOptions {
454
+ optExclude?: ExcludeSelectItem;
455
+ optExcept?: ExceptSelectItem;
456
+ optRename?: RenameSelectItem;
457
+ optReplace?: ReplaceSelectItem;
458
+ }
459
+ interface ExcludeSelectItem {
460
+ items: Ident[];
461
+ }
462
+ interface ExceptSelectItem {
463
+ firstElement: Ident;
464
+ additionalElements: Ident[];
465
+ }
466
+ interface RenameSelectItem {
467
+ items: IdentWithAlias[];
468
+ }
469
+ interface ReplaceSelectItem {
470
+ items: ReplaceSelectElement[];
471
+ }
472
+ interface IdentWithAlias {
473
+ ident: Ident;
474
+ alias: Ident;
475
+ }
476
+ interface ReplaceSelectElement {
477
+ expr: Expr;
478
+ columnName: Ident;
479
+ asKeyword: boolean;
480
+ }
481
+ /**
482
+ * FROM clause table reference
483
+ */
484
+ type TableFactor = {
485
+ Table: {
486
+ name: ObjectName;
487
+ alias?: TableAlias;
488
+ args?: FunctionArg[];
489
+ withHints: Expr[];
490
+ };
491
+ } | {
492
+ Derived: {
493
+ lateral: boolean;
494
+ subquery: Query;
495
+ alias?: TableAlias;
496
+ };
497
+ } | {
498
+ TableFunction: {
499
+ expr: Expr;
500
+ alias?: TableAlias;
501
+ };
502
+ } | {
503
+ NestedJoin: {
504
+ tableWithJoins: TableWithJoins;
505
+ alias?: TableAlias;
506
+ };
507
+ } | {
508
+ UNNEST: {
509
+ alias?: TableAlias;
510
+ arrayExprs: Expr[];
511
+ withOffset: boolean;
512
+ withOffsetAlias?: Ident;
513
+ };
514
+ };
515
+ /**
516
+ * Table alias
517
+ */
518
+ interface TableAlias {
519
+ name: Ident;
520
+ columns: Ident[];
521
+ }
522
+ /**
523
+ * Table with joins
524
+ */
525
+ interface TableWithJoins {
526
+ relation: TableFactor;
527
+ joins: Join[];
528
+ }
529
+ /**
530
+ * JOIN clause
531
+ */
532
+ interface Join {
533
+ relation: TableFactor;
534
+ joinOperator: JoinOperator;
535
+ }
536
+ type JoinOperator = {
537
+ Inner: JoinConstraint;
538
+ } | {
539
+ LeftOuter: JoinConstraint;
540
+ } | {
541
+ RightOuter: JoinConstraint;
542
+ } | {
543
+ FullOuter: JoinConstraint;
544
+ } | 'CrossJoin' | {
545
+ LeftSemi: JoinConstraint;
546
+ } | {
547
+ RightSemi: JoinConstraint;
548
+ } | {
549
+ LeftAnti: JoinConstraint;
550
+ } | {
551
+ RightAnti: JoinConstraint;
552
+ } | 'CrossApply' | 'OuterApply';
553
+ type JoinConstraint = {
554
+ On: Expr;
555
+ } | {
556
+ Using: Ident[];
557
+ } | 'Natural' | 'None';
558
+ /**
559
+ * SELECT statement
560
+ */
561
+ interface Select {
562
+ distinct?: Distinct;
563
+ top?: Top;
564
+ projection: SelectItem[];
565
+ into?: SelectInto;
566
+ from: TableWithJoins[];
567
+ lateralViews: LateralView[];
568
+ selection?: Expr;
569
+ groupBy: GroupByExpr;
570
+ clusterBy: Expr[];
571
+ distributeBy: Expr[];
572
+ sortBy: Expr[];
573
+ having?: Expr;
574
+ namedWindow: NamedWindowDefinition[];
575
+ qualify?: Expr;
576
+ }
577
+ type Distinct = boolean | {
578
+ On: Expr[];
579
+ };
580
+ interface Top {
581
+ withTies: boolean;
582
+ percent: boolean;
583
+ quantity?: Expr;
584
+ }
585
+ interface SelectInto {
586
+ temporary: boolean;
587
+ unlogged: boolean;
588
+ table: boolean;
589
+ name: ObjectName;
590
+ }
591
+ interface LateralView {
592
+ lateralViewExpr: Expr;
593
+ lateralViewName: ObjectName;
594
+ lateralColAlias: Ident[];
595
+ outer: boolean;
596
+ }
597
+ type GroupByExpr = {
598
+ Expressions: Expr[];
599
+ } | 'All';
600
+ interface NamedWindowDefinition {
601
+ name: Ident;
602
+ windowSpec: WindowSpec;
603
+ }
604
+ /**
605
+ * Set expression (UNION, INTERSECT, EXCEPT)
606
+ */
607
+ type SetExpr = {
608
+ Select: Select;
609
+ } | {
610
+ Query: Query;
611
+ } | {
612
+ SetOperation: {
613
+ op: SetOperator;
614
+ setQuantifier: SetQuantifier;
615
+ left: SetExpr;
616
+ right: SetExpr;
617
+ };
618
+ } | {
619
+ Values: Values;
620
+ } | {
621
+ Insert: Statement;
622
+ };
623
+ type SetOperator = 'Union' | 'Except' | 'Intersect';
624
+ type SetQuantifier = 'All' | 'Distinct' | 'None';
625
+ interface Values {
626
+ explicit_row: boolean;
627
+ rows: Expr[][];
628
+ }
629
+ /**
630
+ * WITH clause (CTE)
631
+ */
632
+ interface With {
633
+ recursive: boolean;
634
+ cteTables: Cte[];
635
+ }
636
+ interface Cte {
637
+ alias: TableAlias;
638
+ query: Query;
639
+ from?: Ident;
640
+ }
641
+ /**
642
+ * Query (top-level SELECT)
643
+ */
644
+ interface Query {
645
+ with?: With;
646
+ body: SetExpr;
647
+ orderBy: OrderByExpr[];
648
+ limit?: Expr;
649
+ offset?: Offset;
650
+ fetch?: Fetch;
651
+ locks: LockClause[];
652
+ }
653
+ interface Offset {
654
+ value: Expr;
655
+ rows: OffsetRows;
656
+ }
657
+ type OffsetRows = 'None' | 'Row' | 'Rows';
658
+ interface Fetch {
659
+ withTies: boolean;
660
+ percent: boolean;
661
+ quantity?: Expr;
662
+ }
663
+ interface LockClause {
664
+ lockType: LockType;
665
+ of?: ObjectName;
666
+ nonblock?: NonBlock;
667
+ }
668
+ type LockType = 'Share' | 'Update';
669
+ type NonBlock = 'Wait' | 'Nowait' | 'SkipLocked';
670
+ /**
671
+ * Column definition for CREATE TABLE
672
+ */
673
+ interface ColumnDef {
674
+ name: Ident;
675
+ dataType: DataType;
676
+ collation?: ObjectName;
677
+ options: ColumnOptionDef[];
678
+ }
679
+ interface ColumnOptionDef {
680
+ name?: Ident;
681
+ option: ColumnOption;
682
+ }
683
+ type ColumnOption = 'Null' | 'NotNull' | {
684
+ Default: Expr;
685
+ } | {
686
+ Unique: {
687
+ isPrimary: boolean;
688
+ };
689
+ } | {
690
+ ForeignKey: ForeignKeyOption;
691
+ } | {
692
+ Check: Expr;
693
+ } | 'AutoIncrement' | {
694
+ OnUpdate: Expr;
695
+ } | {
696
+ Generated: GeneratedAs;
697
+ } | {
698
+ Comment: string;
699
+ };
700
+ interface ForeignKeyOption {
701
+ foreignTable: ObjectName;
702
+ referredColumns: Ident[];
703
+ onDelete?: ReferentialAction;
704
+ onUpdate?: ReferentialAction;
705
+ }
706
+ type ReferentialAction = 'Restrict' | 'Cascade' | 'SetNull' | 'NoAction' | 'SetDefault';
707
+ interface GeneratedAs {
708
+ generationType?: GeneratedExpressionMode;
709
+ expr: Expr;
710
+ }
711
+ type GeneratedExpressionMode = 'Virtual' | 'Stored';
712
+ /**
713
+ * Table constraint
714
+ */
715
+ type TableConstraint = {
716
+ Unique: {
717
+ name?: Ident;
718
+ columns: Ident[];
719
+ isPrimary: boolean;
720
+ };
721
+ } | {
722
+ ForeignKey: {
723
+ name?: Ident;
724
+ columns: Ident[];
725
+ foreignTable: ObjectName;
726
+ referredColumns: Ident[];
727
+ onDelete?: ReferentialAction;
728
+ onUpdate?: ReferentialAction;
729
+ };
730
+ } | {
731
+ Check: {
732
+ name?: Ident;
733
+ expr: Expr;
734
+ };
735
+ } | {
736
+ Index: {
737
+ displayAsKey: boolean;
738
+ name?: Ident;
739
+ indexType?: IndexType;
740
+ columns: Ident[];
741
+ };
742
+ };
743
+ type IndexType = 'BTree' | 'Hash';
744
+ /**
745
+ * All SQL statement types
746
+ */
747
+ type Statement = {
748
+ Query: Query;
749
+ } | {
750
+ Insert: {
751
+ orConflict?: SqliteOnConflict;
752
+ into: boolean;
753
+ tableName: ObjectName;
754
+ columns: Ident[];
755
+ overwrite: boolean;
756
+ source: Query;
757
+ partitioned?: Expr[];
758
+ afterColumns: Ident[];
759
+ table: boolean;
760
+ on?: OnInsert;
761
+ returning?: SelectItem[];
762
+ };
763
+ } | {
764
+ Update: {
765
+ table: TableWithJoins;
766
+ assignments: Assignment[];
767
+ from?: TableWithJoins;
768
+ selection?: Expr;
769
+ returning?: SelectItem[];
770
+ };
771
+ } | {
772
+ Delete: {
773
+ tables: ObjectName[];
774
+ from: TableWithJoins[];
775
+ using?: TableWithJoins[];
776
+ selection?: Expr;
777
+ returning?: SelectItem[];
778
+ };
779
+ } | {
780
+ CreateTable: {
781
+ orReplace: boolean;
782
+ temporary: boolean;
783
+ external: boolean;
784
+ global?: boolean;
785
+ ifNotExists: boolean;
786
+ transient: boolean;
787
+ name: ObjectName;
788
+ columns: ColumnDef[];
789
+ constraints: TableConstraint[];
790
+ hiveDistribution: HiveDistributionStyle;
791
+ hiveFormats?: HiveFormat;
792
+ tableProperties: SqlOption[];
793
+ withOptions: SqlOption[];
794
+ fileFormat?: FileFormat;
795
+ location?: string;
796
+ query?: Query;
797
+ withoutRowid: boolean;
798
+ like?: ObjectName;
799
+ cloneClause?: ObjectName;
800
+ engine?: string;
801
+ defaultCharset?: string;
802
+ collation?: string;
803
+ onCommit?: OnCommit;
804
+ onCluster?: string;
805
+ orderBy?: Ident[];
806
+ strict: boolean;
807
+ };
808
+ } | {
809
+ CreateView: {
810
+ orReplace: boolean;
811
+ materialized: boolean;
812
+ name: ObjectName;
813
+ columns: Ident[];
814
+ query: Query;
815
+ withOptions: SqlOption[];
816
+ clusterBy: Ident[];
817
+ };
818
+ } | {
819
+ CreateIndex: {
820
+ name?: ObjectName;
821
+ tableName: ObjectName;
822
+ using?: Ident;
823
+ columns: OrderByExpr[];
824
+ unique: boolean;
825
+ concurrently: boolean;
826
+ ifNotExists: boolean;
827
+ include: Ident[];
828
+ nullsDistinct?: boolean;
829
+ predicate?: Expr;
830
+ };
831
+ } | {
832
+ AlterTable: {
833
+ name: ObjectName;
834
+ ifExists: boolean;
835
+ only: boolean;
836
+ operations: AlterTableOperation[];
837
+ };
838
+ } | {
839
+ Drop: DropStatement;
840
+ } | {
841
+ Truncate: {
842
+ tableName: ObjectName;
843
+ partitions?: Expr[];
844
+ table: boolean;
845
+ };
846
+ } | {
847
+ SetVariable: {
848
+ local: boolean;
849
+ hivevar: boolean;
850
+ variable: ObjectName;
851
+ value: Expr[];
852
+ };
853
+ } | {
854
+ ShowVariable: {
855
+ variable: Ident[];
856
+ };
857
+ } | {
858
+ ShowCreate: {
859
+ objType: ShowCreateObject;
860
+ objName: ObjectName;
861
+ };
862
+ } | {
863
+ ShowTables: {
864
+ extended: boolean;
865
+ full: boolean;
866
+ dbName?: Ident;
867
+ filter?: ShowStatementFilter;
868
+ };
869
+ } | {
870
+ ShowColumns: {
871
+ extended: boolean;
872
+ full: boolean;
873
+ tableName: ObjectName;
874
+ filter?: ShowStatementFilter;
875
+ };
876
+ } | {
877
+ StartTransaction: {
878
+ modes: TransactionMode[];
879
+ begin: boolean;
880
+ };
881
+ } | {
882
+ Commit: {
883
+ chain: boolean;
884
+ };
885
+ } | {
886
+ Rollback: {
887
+ chain: boolean;
888
+ savepoint?: Ident;
889
+ };
890
+ } | {
891
+ Savepoint: {
892
+ name: Ident;
893
+ };
894
+ } | {
895
+ ReleaseSavepoint: {
896
+ name: Ident;
897
+ };
898
+ } | {
899
+ CreateSchema: {
900
+ schemaName: SchemaName;
901
+ ifNotExists: boolean;
902
+ };
903
+ } | {
904
+ CreateDatabase: {
905
+ dbName: ObjectName;
906
+ ifNotExists: boolean;
907
+ location?: string;
908
+ managedLocation?: string;
909
+ };
910
+ } | {
911
+ Grant: {
912
+ privileges: Privileges;
913
+ objects: GrantObjects;
914
+ grantees: Ident[];
915
+ withGrantOption: boolean;
916
+ grantedBy?: Ident;
917
+ };
918
+ } | {
919
+ Revoke: {
920
+ privileges: Privileges;
921
+ objects: GrantObjects;
922
+ grantees: Ident[];
923
+ grantedBy?: Ident;
924
+ cascade: boolean;
925
+ };
926
+ } | {
927
+ Explain: {
928
+ describeAlias: DescribeAlias;
929
+ analyze: boolean;
930
+ verbose: boolean;
931
+ statement: Statement;
932
+ };
933
+ } | {
934
+ Copy: {
935
+ source: CopySource;
936
+ to: boolean;
937
+ target: CopyTarget;
938
+ options: CopyOption[];
939
+ legacyOptions: CopyLegacyOption[];
940
+ values: string[][];
941
+ };
942
+ } | {
943
+ Close: {
944
+ cursor: CloseCursor;
945
+ };
946
+ } | {
947
+ Declare: {
948
+ name: Ident;
949
+ binary: boolean;
950
+ sensitive?: boolean;
951
+ scroll?: boolean;
952
+ hold?: boolean;
953
+ query: Query;
954
+ };
955
+ } | {
956
+ Fetch: {
957
+ name: Ident;
958
+ direction: FetchDirection;
959
+ into?: ObjectName;
960
+ };
961
+ } | {
962
+ Discard: {
963
+ objectType: DiscardObject;
964
+ };
965
+ } | 'ExplainTable' | {
966
+ Analyze: {
967
+ tableName: ObjectName;
968
+ partitions?: Expr[];
969
+ forColumns: boolean;
970
+ columns: Ident[];
971
+ cacheMetadata: boolean;
972
+ noscan: boolean;
973
+ computeStatistics: boolean;
974
+ };
975
+ } | {
976
+ Merge: {
977
+ into: boolean;
978
+ table: TableFactor;
979
+ source: TableFactor;
980
+ on: Expr;
981
+ clauses: MergeClause[];
982
+ };
983
+ } | {
984
+ Execute: {
985
+ name: ObjectName;
986
+ parameters: Expr[];
987
+ };
988
+ } | {
989
+ Prepare: {
990
+ name: Ident;
991
+ dataTypes: DataType[];
992
+ statement: Statement;
993
+ };
994
+ } | {
995
+ Deallocate: {
996
+ name: Ident;
997
+ prepare: boolean;
998
+ };
999
+ } | {
1000
+ Comment: {
1001
+ objectType: CommentObject;
1002
+ objectName: ObjectName;
1003
+ comment?: string;
1004
+ ifExists: boolean;
1005
+ };
1006
+ } | {
1007
+ Assert: {
1008
+ condition: Expr;
1009
+ message?: Expr;
1010
+ };
1011
+ } | 'Kill' | 'Use';
1012
+ type SqliteOnConflict = 'Rollback' | 'Abort' | 'Fail' | 'Ignore' | 'Replace';
1013
+ type OnInsert = {
1014
+ DoUpdate: DoUpdate;
1015
+ } | 'DoNothing';
1016
+ interface DoUpdate {
1017
+ assignments: Assignment[];
1018
+ selection?: Expr;
1019
+ }
1020
+ interface Assignment {
1021
+ id: Ident[];
1022
+ value: Expr;
1023
+ }
1024
+ type HiveDistributionStyle = 'PARTITIONED' | 'CLUSTERED' | 'SKEWED' | 'NONE';
1025
+ interface HiveFormat {
1026
+ rowFormat?: HiveRowFormat;
1027
+ storage?: HiveIOFormat;
1028
+ location?: string;
1029
+ }
1030
+ type HiveRowFormat = {
1031
+ Serde: {
1032
+ class: string;
1033
+ };
1034
+ } | {
1035
+ Delimited: null;
1036
+ };
1037
+ interface HiveIOFormat {
1038
+ inputFormat: string;
1039
+ outputFormat: string;
1040
+ }
1041
+ interface SqlOption {
1042
+ name: Ident;
1043
+ value: Value;
1044
+ }
1045
+ type FileFormat = 'TEXTFILE' | 'SEQUENCEFILE' | 'ORC' | 'PARQUET' | 'AVRO' | 'RCFILE' | 'JSONFILE';
1046
+ type OnCommit = 'DeleteRows' | 'PreserveRows' | 'Drop';
1047
+ type AlterTableOperation = {
1048
+ AddConstraint: TableConstraint;
1049
+ } | {
1050
+ AddColumn: {
1051
+ columnKeyword: boolean;
1052
+ ifNotExists: boolean;
1053
+ columnDef: ColumnDef;
1054
+ };
1055
+ } | {
1056
+ DropConstraint: {
1057
+ ifExists: boolean;
1058
+ name: Ident;
1059
+ cascade: boolean;
1060
+ };
1061
+ } | {
1062
+ DropColumn: {
1063
+ columnName: Ident;
1064
+ ifExists: boolean;
1065
+ cascade: boolean;
1066
+ };
1067
+ } | {
1068
+ RenameColumn: {
1069
+ oldColumnName: Ident;
1070
+ newColumnName: Ident;
1071
+ };
1072
+ } | {
1073
+ RenameTable: {
1074
+ tableName: ObjectName;
1075
+ };
1076
+ } | {
1077
+ ChangeColumn: {
1078
+ oldName: Ident;
1079
+ newName: Ident;
1080
+ dataType: DataType;
1081
+ options: ColumnOption[];
1082
+ };
1083
+ } | {
1084
+ AlterColumn: {
1085
+ columnName: Ident;
1086
+ op: AlterColumnOperation;
1087
+ };
1088
+ } | {
1089
+ RenameConstraint: {
1090
+ oldName: Ident;
1091
+ newName: Ident;
1092
+ };
1093
+ };
1094
+ type AlterColumnOperation = {
1095
+ SetNotNull: null;
1096
+ } | {
1097
+ DropNotNull: null;
1098
+ } | {
1099
+ SetDefault: Expr;
1100
+ } | {
1101
+ DropDefault: null;
1102
+ } | {
1103
+ SetDataType: DataType;
1104
+ };
1105
+ interface DropStatement {
1106
+ objectType: ObjectType;
1107
+ ifExists: boolean;
1108
+ names: ObjectName[];
1109
+ cascade: boolean;
1110
+ restrict: boolean;
1111
+ purge: boolean;
1112
+ }
1113
+ type ObjectType = 'Table' | 'View' | 'Index' | 'Schema' | 'Role' | 'Sequence' | 'Stage';
1114
+ type ShowCreateObject = 'Event' | 'Function' | 'Procedure' | 'Table' | 'Trigger' | 'View';
1115
+ type ShowStatementFilter = {
1116
+ Like: string;
1117
+ } | {
1118
+ ILike: string;
1119
+ } | {
1120
+ Where: Expr;
1121
+ };
1122
+ type TransactionMode = {
1123
+ AccessMode: TransactionAccessMode;
1124
+ } | {
1125
+ IsolationLevel: TransactionIsolationLevel;
1126
+ };
1127
+ type TransactionAccessMode = 'ReadOnly' | 'ReadWrite';
1128
+ type TransactionIsolationLevel = 'ReadUncommitted' | 'ReadCommitted' | 'RepeatableRead' | 'Serializable';
1129
+ type SchemaName = {
1130
+ Simple: ObjectName;
1131
+ } | {
1132
+ UnnamedAuthorization: Ident;
1133
+ } | {
1134
+ NamedAuthorization: [ObjectName, Ident];
1135
+ };
1136
+ type Privileges = {
1137
+ Actions: Action[];
1138
+ } | 'All';
1139
+ type Action = 'Select' | {
1140
+ Select: Ident[];
1141
+ } | 'Insert' | {
1142
+ Insert: Ident[];
1143
+ } | 'Update' | {
1144
+ Update: Ident[];
1145
+ } | 'Delete' | 'Truncate' | 'References' | {
1146
+ References: Ident[];
1147
+ } | 'Trigger' | 'Connect' | 'Create' | 'Execute' | 'Temporary' | 'Usage';
1148
+ type GrantObjects = {
1149
+ AllSequencesInSchema: ObjectName[];
1150
+ } | {
1151
+ AllTablesInSchema: ObjectName[];
1152
+ } | {
1153
+ Schemas: ObjectName[];
1154
+ } | {
1155
+ Sequences: ObjectName[];
1156
+ } | {
1157
+ Tables: ObjectName[];
1158
+ };
1159
+ type DescribeAlias = 'Describe' | 'Explain' | 'Desc';
1160
+ type CopySource = {
1161
+ Table: ObjectName;
1162
+ columns: Ident[];
1163
+ } | {
1164
+ Query: Query;
1165
+ };
1166
+ type CopyTarget = {
1167
+ File: {
1168
+ filename: string;
1169
+ };
1170
+ } | {
1171
+ Program: {
1172
+ command: string;
1173
+ };
1174
+ } | 'Stdout' | 'Stdin';
1175
+ interface CopyOption {
1176
+ key: string;
1177
+ value?: string;
1178
+ }
1179
+ interface CopyLegacyOption {
1180
+ key: string;
1181
+ value?: string;
1182
+ }
1183
+ type CloseCursor = 'All' | {
1184
+ Specific: {
1185
+ name: Ident;
1186
+ };
1187
+ };
1188
+ type FetchDirection = {
1189
+ Count: Expr;
1190
+ } | 'Next' | 'Prior' | 'First' | 'Last' | 'Absolute' | 'Relative' | {
1191
+ Absolute: Expr;
1192
+ } | {
1193
+ Relative: Expr;
1194
+ } | 'All' | 'Forward' | {
1195
+ Forward: Expr;
1196
+ } | 'ForwardAll' | 'Backward' | {
1197
+ Backward: Expr;
1198
+ } | 'BackwardAll';
1199
+ type DiscardObject = 'All' | 'Plans' | 'Sequences' | 'Temp';
1200
+ type MergeClause = {
1201
+ MatchedUpdate: {
1202
+ predicate?: Expr;
1203
+ assignments: Assignment[];
1204
+ };
1205
+ } | {
1206
+ MatchedDelete: {
1207
+ predicate?: Expr;
1208
+ };
1209
+ } | {
1210
+ NotMatched: {
1211
+ predicate?: Expr;
1212
+ columns: Ident[];
1213
+ values: Values;
1214
+ };
1215
+ };
1216
+ type CommentObject = 'Column' | 'Table';
1217
+ //#endregion
1218
+ //#region src/parser.d.ts
1219
+ /** Dialect can be specified as a Dialect instance or a string name */
1220
+ type DialectInput = Dialect | DialectName;
1221
+ /**
1222
+ * Parser options
1223
+ */
1224
+ interface ParserOptions {
1225
+ /**
1226
+ * Allow trailing commas in SELECT lists
1227
+ */
1228
+ trailingCommas?: boolean;
1229
+ /**
1230
+ * Maximum recursion depth for parsing nested expressions
1231
+ */
1232
+ recursionLimit?: number;
1233
+ }
1234
+ /**
1235
+ * Wait for WASM to be ready (useful for ensuring sync APIs work)
1236
+ */
1237
+ declare function ready(): Promise<void>;
1238
+ /**
1239
+ * Initialize the WASM module.
1240
+ * This must be called before using the Parser in browsers and Node.js ESM.
1241
+ * In Node.js CommonJS, the module is loaded automatically.
1242
+ *
1243
+ * @example
1244
+ * ```typescript
1245
+ * import { initWasm, Parser, GenericDialect } from 'sqlparser-rs';
1246
+ *
1247
+ * // Initialize first
1248
+ * await initWasm();
1249
+ *
1250
+ * // Then use the parser
1251
+ * const ast = Parser.parse('SELECT 1', new GenericDialect());
1252
+ * ```
1253
+ */
1254
+ declare function initWasm(): Promise<void>;
1255
+ /**
1256
+ * SQL Parser
1257
+ *
1258
+ * Parses SQL statements into an Abstract Syntax Tree (AST).
1259
+ *
1260
+ * @example
1261
+ * ```typescript
1262
+ * import { Parser, PostgreSqlDialect } from 'sqlparser-rs';
1263
+ *
1264
+ * // Simple parsing
1265
+ * const statements = Parser.parse('SELECT * FROM users', new PostgreSqlDialect());
1266
+ *
1267
+ * // With builder pattern
1268
+ * const parser = new Parser(new PostgreSqlDialect())
1269
+ * .withRecursionLimit(50)
1270
+ * .withOptions({ trailingCommas: true });
1271
+ *
1272
+ * const ast = parser.parse('SELECT * FROM users');
1273
+ * ```
1274
+ */
1275
+ declare class Parser {
1276
+ private dialect;
1277
+ private options;
1278
+ /**
1279
+ * Create a new parser instance
1280
+ *
1281
+ * @param dialect - The SQL dialect to use (defaults to GenericDialect)
1282
+ */
1283
+ constructor(dialect?: Dialect);
1284
+ /**
1285
+ * Set the recursion limit for parsing nested expressions
1286
+ *
1287
+ * @param limit - Maximum recursion depth
1288
+ * @returns This parser instance for chaining
1289
+ */
1290
+ withRecursionLimit(limit: number): Parser;
1291
+ /**
1292
+ * Set parser options
1293
+ *
1294
+ * @param options - Parser options
1295
+ * @returns This parser instance for chaining
1296
+ */
1297
+ withOptions(options: ParserOptions): Parser;
1298
+ /**
1299
+ * Parse SQL statements
1300
+ *
1301
+ * @param sql - SQL string to parse
1302
+ * @returns Array of parsed statements
1303
+ */
1304
+ parse(sql: string): Statement[];
1305
+ /**
1306
+ * Parse SQL statements
1307
+ *
1308
+ * @param sql - SQL string to parse
1309
+ * @param dialect - SQL dialect to use (string name or Dialect instance, defaults to 'generic')
1310
+ * @returns Array of parsed statements
1311
+ *
1312
+ * @example
1313
+ * ```typescript
1314
+ * // Using default dialect
1315
+ * const statements = Parser.parse('SELECT 1');
1316
+ *
1317
+ * // Using string dialect name
1318
+ * const pgStatements = Parser.parse('SELECT $1', 'postgresql');
1319
+ *
1320
+ * // Using dialect instance
1321
+ * const mysqlStatements = Parser.parse('SELECT 1', new MySqlDialect());
1322
+ * ```
1323
+ */
1324
+ static parse(sql: string, dialect?: DialectInput): Statement[];
1325
+ /**
1326
+ * Parse SQL and return the AST as a JSON string
1327
+ *
1328
+ * @param sql - SQL string to parse
1329
+ * @param dialect - SQL dialect to use (string name or Dialect instance, defaults to 'generic')
1330
+ * @returns JSON string representation of the AST
1331
+ */
1332
+ static parseToJson(sql: string, dialect?: DialectInput): string;
1333
+ /**
1334
+ * Parse SQL and return a formatted string representation
1335
+ *
1336
+ * @param sql - SQL string to parse
1337
+ * @param dialect - SQL dialect to use (string name or Dialect instance, defaults to 'generic')
1338
+ * @returns String representation of the parsed SQL
1339
+ */
1340
+ static parseToString(sql: string, dialect?: DialectInput): string;
1341
+ /**
1342
+ * Format SQL by parsing and regenerating it (round-trip)
1343
+ *
1344
+ * @param sql - SQL string to format
1345
+ * @param dialect - SQL dialect to use (string name or Dialect instance, defaults to 'generic')
1346
+ * @returns Formatted SQL string
1347
+ */
1348
+ static format(sql: string, dialect?: DialectInput): string;
1349
+ /**
1350
+ * Validate SQL syntax without returning the full AST
1351
+ *
1352
+ * @param sql - SQL string to validate
1353
+ * @param dialect - SQL dialect to use (string name or Dialect instance, defaults to 'generic')
1354
+ * @returns true if valid, throws ParserError if invalid
1355
+ */
1356
+ static validate(sql: string, dialect?: DialectInput): boolean;
1357
+ /**
1358
+ * Get the list of supported dialect names
1359
+ */
1360
+ static getSupportedDialects(): string[];
1361
+ }
1362
+ /**
1363
+ * Parse SQL statements (convenience function)
1364
+ *
1365
+ * @param sql - SQL string to parse
1366
+ * @param dialect - SQL dialect to use (string name or Dialect instance, defaults to 'generic')
1367
+ * @returns Array of parsed statements
1368
+ *
1369
+ * @example
1370
+ * ```typescript
1371
+ * import { parse } from 'sqlparser-rs';
1372
+ *
1373
+ * const statements = parse('SELECT * FROM users');
1374
+ * const pgStatements = parse('SELECT $1', 'postgresql');
1375
+ * ```
1376
+ */
1377
+ declare function parse(sql: string, dialect?: DialectInput): Statement[];
1378
+ /**
1379
+ * Validate SQL syntax (convenience function)
1380
+ *
1381
+ * @param sql - SQL string to validate
1382
+ * @param dialect - SQL dialect to use (string name or Dialect instance, defaults to 'generic')
1383
+ * @returns true if valid, throws ParserError if invalid
1384
+ *
1385
+ * @example
1386
+ * ```typescript
1387
+ * import { validate } from 'sqlparser-rs';
1388
+ *
1389
+ * if (validate('SELECT * FROM users')) {
1390
+ * console.log('Valid SQL!');
1391
+ * }
1392
+ * ```
1393
+ */
1394
+ declare function validate(sql: string, dialect?: DialectInput): boolean;
1395
+ /**
1396
+ * Format SQL by parsing and regenerating it (convenience function)
1397
+ *
1398
+ * @param sql - SQL string to format
1399
+ * @param dialect - SQL dialect to use (string name or Dialect instance, defaults to 'generic')
1400
+ * @returns Formatted SQL string
1401
+ *
1402
+ * @example
1403
+ * ```typescript
1404
+ * import { format } from 'sqlparser-rs';
1405
+ *
1406
+ * const formatted = format('select * from users');
1407
+ * // Returns: "SELECT * FROM users"
1408
+ * ```
1409
+ */
1410
+ declare function format(sql: string, dialect?: DialectInput): string;
1411
+ //#endregion
1412
+ //#region src/types/errors.d.ts
1413
+ /**
1414
+ * Location information for parser errors
1415
+ */
1416
+ interface ErrorLocation {
1417
+ line: number;
1418
+ column: number;
1419
+ }
1420
+ /**
1421
+ * Error thrown when SQL parsing fails
1422
+ */
1423
+ declare class ParserError extends Error {
1424
+ readonly location?: ErrorLocation;
1425
+ constructor(message: string, location?: ErrorLocation);
1426
+ /**
1427
+ * Create a ParserError from a WASM error object
1428
+ */
1429
+ static fromWasmError(error: unknown): ParserError;
1430
+ }
1431
+ /**
1432
+ * Error thrown when WASM module fails to initialize
1433
+ */
1434
+ declare class WasmInitError extends Error {
1435
+ constructor(message: string);
1436
+ }
1437
+ //#endregion
1438
+ export { Action, AlterColumnOperation, AlterTableOperation, AnsiDialect, Assignment, BigQueryDialect, BinaryOperator, ClickHouseDialect, CloseCursor, ColumnDef, ColumnOption, ColumnOptionDef, CommentObject, CopyLegacyOption, CopyOption, CopySource, CopyTarget, Cte, DataType, DatabricksDialect, DateTimeField, DescribeAlias, type Dialect, type DialectInput, type DialectName, DiscardObject, Distinct, DoUpdate, DropStatement, DuckDbDialect, ErrorLocation, ExceptSelectItem, ExcludeSelectItem, Expr, Fetch, FetchDirection, FileFormat, ForeignKeyOption, FunctionArg, FunctionArgExpr, FunctionExpr, GeneratedAs, GeneratedExpressionMode, GenericDialect, GrantObjects, GroupByExpr, HiveDialect, HiveDistributionStyle, HiveFormat, HiveIOFormat, HiveRowFormat, Ident, IdentWithAlias, IndexType, IntervalExpr, Join, JoinConstraint, JoinOperator, LateralView, LockClause, LockType, MergeClause, MsSqlDialect, MySqlDialect, NamedWindowDefinition, NonBlock, ObjectName, ObjectType, Offset, OffsetRows, OnCommit, OnInsert, OracleDialect, OrderByExpr, Parser, ParserError, type ParserOptions, PostgreSqlDialect, Privileges, Query, RedshiftDialect, ReferentialAction, RenameSelectItem, ReplaceSelectElement, ReplaceSelectItem, SQLiteDialect, SUPPORTED_DIALECTS, SchemaName, Select, SelectInto, SelectItem, SetExpr, SetOperator, SetQuantifier, ShowCreateObject, ShowStatementFilter, SnowflakeDialect, SqlOption, SqliteOnConflict, Statement, TableAlias, TableConstraint, TableFactor, TableWithJoins, Top, TransactionAccessMode, TransactionIsolationLevel, TransactionMode, TrimWhereField, UnaryOperator, Value, Values, WasmInitError, WildcardAdditionalOptions, WindowFrame, WindowFrameBound, WindowFrameUnits, WindowSpec, With, dialectFromString, format, initWasm, parse, ready, validate };