@polyglot-sql/sdk 0.1.7 → 0.1.9

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.ts CHANGED
@@ -6089,6 +6089,20 @@ declare type Format = {
6089
6089
  */
6090
6090
  export declare function format(sql: string, dialect?: Dialect): TranspileResult;
6091
6091
 
6092
+ /**
6093
+ * Guard options for formatting very large/complex SQL safely.
6094
+ */
6095
+ export declare interface FormatOptions {
6096
+ /** Maximum SQL input size in bytes */
6097
+ maxInputBytes?: number;
6098
+ /** Maximum token count after tokenization */
6099
+ maxTokens?: number;
6100
+ /** Maximum AST node count after parsing */
6101
+ maxAstNodes?: number;
6102
+ /** Maximum set-operation count (UNION/INTERSECT/EXCEPT) before parse */
6103
+ maxSetOpChain?: number;
6104
+ }
6105
+
6092
6106
  /**
6093
6107
  * Format override for a column in Teradata
6094
6108
  */
@@ -6097,6 +6111,13 @@ declare type FormatPhrase = {
6097
6111
  format: string;
6098
6112
  };
6099
6113
 
6114
+ /**
6115
+ * Format/pretty-print SQL with explicit guard limits.
6116
+ *
6117
+ * This can be used to tune handling for very large SQL inputs.
6118
+ */
6119
+ export declare function formatWithOptions(sql: string, dialect?: Dialect, options?: FormatOptions): TranspileResult;
6120
+
6100
6121
  /**
6101
6122
  * FreespaceProperty
6102
6123
  */
@@ -10036,6 +10057,10 @@ export declare class Polyglot {
10036
10057
  * Format SQL.
10037
10058
  */
10038
10059
  format(sql: string, dialect?: Dialect): TranspileResult;
10060
+ /**
10061
+ * Format SQL with explicit guard limits.
10062
+ */
10063
+ formatWithOptions(sql: string, dialect?: Dialect, options?: FormatOptions): TranspileResult;
10039
10064
  /**
10040
10065
  * Get supported dialects in this build.
10041
10066
  * Per-dialect builds return only `"generic"` and the selected dialect.
package/dist/index.js CHANGED
@@ -2055,6 +2055,52 @@ function format_sql_value$1(sql, dialect) {
2055
2055
  return takeObject(ret);
2056
2056
  }
2057
2057
 
2058
+ /**
2059
+ * Format SQL with explicit guard options supplied as JSON.
2060
+ * @param {string} sql
2061
+ * @param {string} dialect
2062
+ * @param {string} options_json
2063
+ * @returns {string}
2064
+ */
2065
+ function format_sql_with_options$1(sql, dialect, options_json) {
2066
+ let deferred4_0;
2067
+ let deferred4_1;
2068
+ try {
2069
+ const retptr = wasm$3.__wbindgen_add_to_stack_pointer(-16);
2070
+ const ptr0 = passStringToWasm0(sql, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
2071
+ const len0 = WASM_VECTOR_LEN;
2072
+ const ptr1 = passStringToWasm0(dialect, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
2073
+ const len1 = WASM_VECTOR_LEN;
2074
+ const ptr2 = passStringToWasm0(options_json, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
2075
+ const len2 = WASM_VECTOR_LEN;
2076
+ wasm$3.format_sql_with_options(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
2077
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2078
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2079
+ deferred4_0 = r0;
2080
+ deferred4_1 = r1;
2081
+ return getStringFromWasm0(r0, r1);
2082
+ } finally {
2083
+ wasm$3.__wbindgen_add_to_stack_pointer(16);
2084
+ wasm$3.__wbindgen_export4(deferred4_0, deferred4_1, 1);
2085
+ }
2086
+ }
2087
+
2088
+ /**
2089
+ * Format SQL with explicit guard options supplied as a JS object.
2090
+ * @param {string} sql
2091
+ * @param {string} dialect
2092
+ * @param {any} options
2093
+ * @returns {any}
2094
+ */
2095
+ function format_sql_with_options_value$1(sql, dialect, options) {
2096
+ const ptr0 = passStringToWasm0(sql, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
2097
+ const len0 = WASM_VECTOR_LEN;
2098
+ const ptr1 = passStringToWasm0(dialect, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
2099
+ const len1 = WASM_VECTOR_LEN;
2100
+ const ret = wasm$3.format_sql_with_options_value(ptr0, len0, ptr1, len1, addHeapObject(options));
2101
+ return takeObject(ret);
2102
+ }
2103
+
2058
2104
  /**
2059
2105
  * Generate SQL from an AST (provided as JSON).
2060
2106
  *
@@ -3302,6 +3348,8 @@ const ast_set_limit = __vite__wasmModule.ast_set_limit;
3302
3348
  const diff_sql = __vite__wasmModule.diff_sql;
3303
3349
  const format_sql = __vite__wasmModule.format_sql;
3304
3350
  const format_sql_value = __vite__wasmModule.format_sql_value;
3351
+ const format_sql_with_options = __vite__wasmModule.format_sql_with_options;
3352
+ const format_sql_with_options_value = __vite__wasmModule.format_sql_with_options_value;
3305
3353
  const generate$1 = __vite__wasmModule.generate;
3306
3354
  const generate_value = __vite__wasmModule.generate_value;
3307
3355
  const get_dialects = __vite__wasmModule.get_dialects;
@@ -3484,6 +3532,8 @@ const wasm$2 = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
3484
3532
  diff_sql,
3485
3533
  format_sql,
3486
3534
  format_sql_value,
3535
+ format_sql_with_options,
3536
+ format_sql_with_options_value,
3487
3537
  generate: generate$1,
3488
3538
  generate_value,
3489
3539
  get_dialects,
@@ -3662,6 +3712,8 @@ const wasmModule = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty
3662
3712
  diff_sql: diff_sql$1,
3663
3713
  format_sql: format_sql$1,
3664
3714
  format_sql_value: format_sql_value$1,
3715
+ format_sql_with_options: format_sql_with_options$1,
3716
+ format_sql_with_options_value: format_sql_with_options_value$1,
3665
3717
  generate: generate$2,
3666
3718
  generate_value: generate_value$1,
3667
3719
  get_dialects: get_dialects$1,
@@ -5397,7 +5449,20 @@ function generate(ast2, dialect = "generic" /* Generic */) {
5397
5449
  }
5398
5450
  }
5399
5451
  function format(sql, dialect = "generic" /* Generic */) {
5452
+ return formatWithOptions(sql, dialect, {});
5453
+ }
5454
+ function formatWithOptions(sql, dialect = "generic" /* Generic */, options = {}) {
5400
5455
  try {
5456
+ if (typeof wasm.format_sql_with_options_value === "function") {
5457
+ return decodeWasmPayload(
5458
+ wasm.format_sql_with_options_value(sql, dialect, options)
5459
+ );
5460
+ }
5461
+ if (typeof wasm.format_sql_with_options === "function") {
5462
+ return JSON.parse(
5463
+ wasm.format_sql_with_options(sql, dialect, JSON.stringify(options))
5464
+ );
5465
+ }
5401
5466
  if (typeof wasm.format_sql_value === "function") {
5402
5467
  return decodeWasmPayload(
5403
5468
  wasm.format_sql_value(sql, dialect)
@@ -5459,6 +5524,12 @@ class Polyglot {
5459
5524
  format(sql, dialect = "generic" /* Generic */) {
5460
5525
  return format(sql, dialect);
5461
5526
  }
5527
+ /**
5528
+ * Format SQL with explicit guard limits.
5529
+ */
5530
+ formatWithOptions(sql, dialect = "generic" /* Generic */, options = {}) {
5531
+ return formatWithOptions(sql, dialect, options);
5532
+ }
5462
5533
  /**
5463
5534
  * Get supported dialects in this build.
5464
5535
  * Per-dialect builds return only `"generic"` and the selected dialect.
@@ -5492,4 +5563,4 @@ const index = {
5492
5563
  Polyglot
5493
5564
  };
5494
5565
 
5495
- export { CaseBuilder, DeleteBuilder, Dialect, Expr, InsertBuilder, MergeBuilder, Polyglot, SelectBuilder, SetOpBuilder, UpdateBuilder, ValidationSeverity, WindowDefBuilder, abs, alias, and, index$1 as ast, avg, boolean, caseOf, caseWhen, cast, ceil, changesOnly, coalesce, col, concatWs, condition, count, countDistinct, currentDate, currentTime, currentTimestamp, index as default, del, deleteFrom, denseRank, diff, except, exp, extract, findAll, floor, format, func, generate, getColumns, getDialects, getSourceTables, getVersion, greatest, hasChanges, ifNull, init, initcap, insert, insertInto, intersect, isColumn, isFunction, isInitialized, isLiteral, isSelect, least, length, lineage, lit, ln, lower, ltrim, max, mergeInto, min, not, nullIf, or, parse, plan, power, rank, renameColumns, replace, reverse, round, rowNumber, rtrim, select, sign, sqlExpr, sqlNull, sqrt, star, subquery, substring, sum, table, transform, transpile, trim, union, unionAll, update, upper, validate, validateWithSchema, walk };
5566
+ export { CaseBuilder, DeleteBuilder, Dialect, Expr, InsertBuilder, MergeBuilder, Polyglot, SelectBuilder, SetOpBuilder, UpdateBuilder, ValidationSeverity, WindowDefBuilder, abs, alias, and, index$1 as ast, avg, boolean, caseOf, caseWhen, cast, ceil, changesOnly, coalesce, col, concatWs, condition, count, countDistinct, currentDate, currentTime, currentTimestamp, index as default, del, deleteFrom, denseRank, diff, except, exp, extract, findAll, floor, format, formatWithOptions, func, generate, getColumns, getDialects, getSourceTables, getVersion, greatest, hasChanges, ifNull, init, initcap, insert, insertInto, intersect, isColumn, isFunction, isInitialized, isLiteral, isSelect, least, length, lineage, lit, ln, lower, ltrim, max, mergeInto, min, not, nullIf, or, parse, plan, power, rank, renameColumns, replace, reverse, round, rowNumber, rtrim, select, sign, sqlExpr, sqlNull, sqrt, star, subquery, substring, sum, table, transform, transpile, trim, union, unionAll, update, upper, validate, validateWithSchema, walk };
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polyglot-sql/sdk",
3
- "version": "0.1.7",
3
+ "version": "0.1.9",
4
4
  "description": "SQL dialect translator powered by WebAssembly",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",