sqlparser-rs 0.60.3 → 0.60.4

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.
package/dist/index.d.cts CHANGED
@@ -101,20 +101,7 @@ declare class OracleDialect implements Dialect {
101
101
  */
102
102
  declare const SUPPORTED_DIALECTS: readonly ["generic", "ansi", "mysql", "postgresql", "sqlite", "snowflake", "redshift", "mssql", "clickhouse", "bigquery", "duckdb", "databricks", "hive", "oracle"];
103
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
- */
104
+ /** Create a dialect instance from a string name (case-insensitive) */
118
105
  declare function dialectFromString(name: string): Dialect | undefined;
119
106
  //#endregion
120
107
  //#region src/types/ast.d.ts
@@ -1215,120 +1202,83 @@ type MergeClause = {
1215
1202
  };
1216
1203
  type CommentObject = 'Column' | 'Table';
1217
1204
  //#endregion
1205
+ //#region src/wasm.d.ts
1206
+ /**
1207
+ * Wait for WASM module to be ready
1208
+ */
1209
+ declare function ready(): Promise<void>;
1210
+ /**
1211
+ * Initialize the WASM module explicitly.
1212
+ * Usually not needed - the module auto-initializes on first use.
1213
+ */
1214
+ declare function initWasm(): Promise<void>;
1215
+ //#endregion
1218
1216
  //#region src/parser.d.ts
1217
+ /** Dialect can be specified as a Dialect instance or a string name */
1218
+ type DialectInput = Dialect | DialectName;
1219
1219
  /**
1220
1220
  * Parser options
1221
1221
  */
1222
1222
  interface ParserOptions {
1223
- /**
1224
- * Allow trailing commas in SELECT lists
1225
- */
1223
+ /** Allow trailing commas in SELECT lists */
1226
1224
  trailingCommas?: boolean;
1227
- /**
1228
- * Maximum recursion depth for parsing nested expressions
1229
- */
1225
+ /** Maximum recursion depth for parsing nested expressions */
1230
1226
  recursionLimit?: number;
1231
1227
  }
1232
1228
  /**
1233
- * SQL Parser
1234
- *
1235
- * Parses SQL statements into an Abstract Syntax Tree (AST).
1229
+ * SQL Parser - parses SQL statements into AST
1236
1230
  *
1237
1231
  * @example
1238
1232
  * ```typescript
1239
1233
  * import { Parser, PostgreSqlDialect } from 'sqlparser-rs';
1240
1234
  *
1241
- * // Simple parsing
1242
- * const statements = Parser.parse('SELECT * FROM users', new PostgreSqlDialect());
1235
+ * const statements = Parser.parse('SELECT * FROM users', 'postgresql');
1243
1236
  *
1244
- * // With builder pattern
1237
+ * // With options
1245
1238
  * const parser = new Parser(new PostgreSqlDialect())
1246
- * .withRecursionLimit(50)
1247
1239
  * .withOptions({ trailingCommas: true });
1248
- *
1249
- * const ast = parser.parse('SELECT * FROM users');
1240
+ * const ast = parser.parse('SELECT a, b, FROM users');
1250
1241
  * ```
1251
1242
  */
1252
1243
  declare class Parser {
1253
1244
  private dialect;
1254
1245
  private options;
1255
- /**
1256
- * Create a new parser instance
1257
- *
1258
- * @param dialect - The SQL dialect to use (defaults to GenericDialect)
1259
- */
1260
1246
  constructor(dialect?: Dialect);
1261
- /**
1262
- * Set the recursion limit for parsing nested expressions
1263
- *
1264
- * @param limit - Maximum recursion depth
1265
- * @returns This parser instance for chaining
1266
- */
1247
+ /** Set recursion limit for parsing nested expressions */
1267
1248
  withRecursionLimit(limit: number): Parser;
1268
- /**
1269
- * Set parser options
1270
- *
1271
- * @param options - Parser options
1272
- * @returns This parser instance for chaining
1273
- */
1249
+ /** Set parser options */
1274
1250
  withOptions(options: ParserOptions): Parser;
1275
- /**
1276
- * Parse SQL statements
1277
- *
1278
- * @param sql - SQL string to parse
1279
- * @returns Array of parsed statements
1280
- */
1251
+ /** Parse SQL statements */
1281
1252
  parse(sql: string): Statement[];
1253
+ /** Parse SQL into AST */
1254
+ static parse(sql: string, dialect?: DialectInput): Statement[];
1255
+ /** Parse SQL and return AST as JSON string */
1256
+ static parseToJson(sql: string, dialect?: DialectInput): string;
1257
+ /** Parse SQL and return formatted string representation */
1258
+ static parseToString(sql: string, dialect?: DialectInput): string;
1259
+ /** Format SQL by parsing and regenerating it */
1260
+ static format(sql: string, dialect?: DialectInput): string;
1282
1261
  /**
1283
- * Parse SQL statements
1284
- *
1285
- * @param sql - SQL string to parse
1286
- * @param dialect - SQL dialect to use
1287
- * @returns Array of parsed statements
1288
- *
1289
- * @example
1290
- * ```typescript
1291
- * const statements = Parser.parse('SELECT 1', new GenericDialect());
1292
- * ```
1293
- */
1294
- static parse(sql: string, dialect?: Dialect): Statement[];
1295
- /**
1296
- * Parse SQL and return the AST as a JSON string
1297
- *
1298
- * @param sql - SQL string to parse
1299
- * @param dialect - SQL dialect to use
1300
- * @returns JSON string representation of the AST
1301
- */
1302
- static parseToJson(sql: string, dialect?: Dialect): string;
1303
- /**
1304
- * Parse SQL and return a formatted string representation
1305
- *
1306
- * @param sql - SQL string to parse
1307
- * @param dialect - SQL dialect to use
1308
- * @returns String representation of the parsed SQL
1309
- */
1310
- static parseToString(sql: string, dialect?: Dialect): string;
1311
- /**
1312
- * Format SQL by parsing and regenerating it (round-trip)
1313
- *
1314
- * @param sql - SQL string to format
1315
- * @param dialect - SQL dialect to use
1316
- * @returns Formatted SQL string
1317
- */
1318
- static format(sql: string, dialect?: Dialect): string;
1319
- /**
1320
- * Validate SQL syntax without returning the full AST
1321
- *
1322
- * @param sql - SQL string to validate
1323
- * @param dialect - SQL dialect to use
1324
- * @returns true if valid, throws ParserError if invalid
1325
- */
1326
- static validate(sql: string, dialect?: Dialect): boolean;
1327
- /**
1328
- * Get the list of supported dialect names
1262
+ * Validate SQL syntax
1263
+ * @throws ParserError if SQL is invalid
1329
1264
  */
1265
+ static validate(sql: string, dialect?: DialectInput): boolean;
1266
+ /** Get list of supported dialect names */
1330
1267
  static getSupportedDialects(): string[];
1331
1268
  }
1269
+ /**
1270
+ * Parse SQL into AST
1271
+ */
1272
+ declare function parse(sql: string, dialect?: DialectInput): Statement[];
1273
+ /**
1274
+ * Validate SQL syntax
1275
+ * @throws ParserError if SQL is invalid
1276
+ */
1277
+ declare function validate(sql: string, dialect?: DialectInput): boolean;
1278
+ /**
1279
+ * Format SQL by parsing and regenerating it
1280
+ */
1281
+ declare function format(sql: string, dialect?: DialectInput): string;
1332
1282
  //#endregion
1333
1283
  //#region src/types/errors.d.ts
1334
1284
  /**
@@ -1356,4 +1306,4 @@ declare class WasmInitError extends Error {
1356
1306
  constructor(message: string);
1357
1307
  }
1358
1308
  //#endregion
1359
- 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 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 };
1309
+ 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 };
package/dist/index.d.mts CHANGED
@@ -101,20 +101,7 @@ declare class OracleDialect implements Dialect {
101
101
  */
102
102
  declare const SUPPORTED_DIALECTS: readonly ["generic", "ansi", "mysql", "postgresql", "sqlite", "snowflake", "redshift", "mssql", "clickhouse", "bigquery", "duckdb", "databricks", "hive", "oracle"];
103
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
- */
104
+ /** Create a dialect instance from a string name (case-insensitive) */
118
105
  declare function dialectFromString(name: string): Dialect | undefined;
119
106
  //#endregion
120
107
  //#region src/types/ast.d.ts
@@ -1215,120 +1202,83 @@ type MergeClause = {
1215
1202
  };
1216
1203
  type CommentObject = 'Column' | 'Table';
1217
1204
  //#endregion
1205
+ //#region src/wasm.d.ts
1206
+ /**
1207
+ * Wait for WASM module to be ready
1208
+ */
1209
+ declare function ready(): Promise<void>;
1210
+ /**
1211
+ * Initialize the WASM module explicitly.
1212
+ * Usually not needed - the module auto-initializes on first use.
1213
+ */
1214
+ declare function initWasm(): Promise<void>;
1215
+ //#endregion
1218
1216
  //#region src/parser.d.ts
1217
+ /** Dialect can be specified as a Dialect instance or a string name */
1218
+ type DialectInput = Dialect | DialectName;
1219
1219
  /**
1220
1220
  * Parser options
1221
1221
  */
1222
1222
  interface ParserOptions {
1223
- /**
1224
- * Allow trailing commas in SELECT lists
1225
- */
1223
+ /** Allow trailing commas in SELECT lists */
1226
1224
  trailingCommas?: boolean;
1227
- /**
1228
- * Maximum recursion depth for parsing nested expressions
1229
- */
1225
+ /** Maximum recursion depth for parsing nested expressions */
1230
1226
  recursionLimit?: number;
1231
1227
  }
1232
1228
  /**
1233
- * SQL Parser
1234
- *
1235
- * Parses SQL statements into an Abstract Syntax Tree (AST).
1229
+ * SQL Parser - parses SQL statements into AST
1236
1230
  *
1237
1231
  * @example
1238
1232
  * ```typescript
1239
1233
  * import { Parser, PostgreSqlDialect } from 'sqlparser-rs';
1240
1234
  *
1241
- * // Simple parsing
1242
- * const statements = Parser.parse('SELECT * FROM users', new PostgreSqlDialect());
1235
+ * const statements = Parser.parse('SELECT * FROM users', 'postgresql');
1243
1236
  *
1244
- * // With builder pattern
1237
+ * // With options
1245
1238
  * const parser = new Parser(new PostgreSqlDialect())
1246
- * .withRecursionLimit(50)
1247
1239
  * .withOptions({ trailingCommas: true });
1248
- *
1249
- * const ast = parser.parse('SELECT * FROM users');
1240
+ * const ast = parser.parse('SELECT a, b, FROM users');
1250
1241
  * ```
1251
1242
  */
1252
1243
  declare class Parser {
1253
1244
  private dialect;
1254
1245
  private options;
1255
- /**
1256
- * Create a new parser instance
1257
- *
1258
- * @param dialect - The SQL dialect to use (defaults to GenericDialect)
1259
- */
1260
1246
  constructor(dialect?: Dialect);
1261
- /**
1262
- * Set the recursion limit for parsing nested expressions
1263
- *
1264
- * @param limit - Maximum recursion depth
1265
- * @returns This parser instance for chaining
1266
- */
1247
+ /** Set recursion limit for parsing nested expressions */
1267
1248
  withRecursionLimit(limit: number): Parser;
1268
- /**
1269
- * Set parser options
1270
- *
1271
- * @param options - Parser options
1272
- * @returns This parser instance for chaining
1273
- */
1249
+ /** Set parser options */
1274
1250
  withOptions(options: ParserOptions): Parser;
1275
- /**
1276
- * Parse SQL statements
1277
- *
1278
- * @param sql - SQL string to parse
1279
- * @returns Array of parsed statements
1280
- */
1251
+ /** Parse SQL statements */
1281
1252
  parse(sql: string): Statement[];
1253
+ /** Parse SQL into AST */
1254
+ static parse(sql: string, dialect?: DialectInput): Statement[];
1255
+ /** Parse SQL and return AST as JSON string */
1256
+ static parseToJson(sql: string, dialect?: DialectInput): string;
1257
+ /** Parse SQL and return formatted string representation */
1258
+ static parseToString(sql: string, dialect?: DialectInput): string;
1259
+ /** Format SQL by parsing and regenerating it */
1260
+ static format(sql: string, dialect?: DialectInput): string;
1282
1261
  /**
1283
- * Parse SQL statements
1284
- *
1285
- * @param sql - SQL string to parse
1286
- * @param dialect - SQL dialect to use
1287
- * @returns Array of parsed statements
1288
- *
1289
- * @example
1290
- * ```typescript
1291
- * const statements = Parser.parse('SELECT 1', new GenericDialect());
1292
- * ```
1293
- */
1294
- static parse(sql: string, dialect?: Dialect): Statement[];
1295
- /**
1296
- * Parse SQL and return the AST as a JSON string
1297
- *
1298
- * @param sql - SQL string to parse
1299
- * @param dialect - SQL dialect to use
1300
- * @returns JSON string representation of the AST
1301
- */
1302
- static parseToJson(sql: string, dialect?: Dialect): string;
1303
- /**
1304
- * Parse SQL and return a formatted string representation
1305
- *
1306
- * @param sql - SQL string to parse
1307
- * @param dialect - SQL dialect to use
1308
- * @returns String representation of the parsed SQL
1309
- */
1310
- static parseToString(sql: string, dialect?: Dialect): string;
1311
- /**
1312
- * Format SQL by parsing and regenerating it (round-trip)
1313
- *
1314
- * @param sql - SQL string to format
1315
- * @param dialect - SQL dialect to use
1316
- * @returns Formatted SQL string
1317
- */
1318
- static format(sql: string, dialect?: Dialect): string;
1319
- /**
1320
- * Validate SQL syntax without returning the full AST
1321
- *
1322
- * @param sql - SQL string to validate
1323
- * @param dialect - SQL dialect to use
1324
- * @returns true if valid, throws ParserError if invalid
1325
- */
1326
- static validate(sql: string, dialect?: Dialect): boolean;
1327
- /**
1328
- * Get the list of supported dialect names
1262
+ * Validate SQL syntax
1263
+ * @throws ParserError if SQL is invalid
1329
1264
  */
1265
+ static validate(sql: string, dialect?: DialectInput): boolean;
1266
+ /** Get list of supported dialect names */
1330
1267
  static getSupportedDialects(): string[];
1331
1268
  }
1269
+ /**
1270
+ * Parse SQL into AST
1271
+ */
1272
+ declare function parse(sql: string, dialect?: DialectInput): Statement[];
1273
+ /**
1274
+ * Validate SQL syntax
1275
+ * @throws ParserError if SQL is invalid
1276
+ */
1277
+ declare function validate(sql: string, dialect?: DialectInput): boolean;
1278
+ /**
1279
+ * Format SQL by parsing and regenerating it
1280
+ */
1281
+ declare function format(sql: string, dialect?: DialectInput): string;
1332
1282
  //#endregion
1333
1283
  //#region src/types/errors.d.ts
1334
1284
  /**
@@ -1356,4 +1306,4 @@ declare class WasmInitError extends Error {
1356
1306
  constructor(message: string);
1357
1307
  }
1358
1308
  //#endregion
1359
- 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 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 };
1309
+ 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 };