@polyglot-sql/sdk 0.3.8 → 0.3.10

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.cjs CHANGED
@@ -1723,6 +1723,26 @@ function ast_qualify_columns$1(ast_json, table_name) {
1723
1723
  wasm$3.__wbindgen_export4(deferred3_0, deferred3_1, 1);
1724
1724
  }
1725
1725
  }
1726
+ function ast_qualify_tables$1(ast_json, options_json) {
1727
+ let deferred3_0;
1728
+ let deferred3_1;
1729
+ try {
1730
+ const retptr = wasm$3.__wbindgen_add_to_stack_pointer(-16);
1731
+ const ptr0 = passStringToWasm0(ast_json, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
1732
+ const len0 = WASM_VECTOR_LEN;
1733
+ const ptr1 = passStringToWasm0(options_json, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
1734
+ const len1 = WASM_VECTOR_LEN;
1735
+ wasm$3.ast_qualify_tables(retptr, ptr0, len0, ptr1, len1);
1736
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1737
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1738
+ deferred3_0 = r0;
1739
+ deferred3_1 = r1;
1740
+ return getStringFromWasm0(r0, r1);
1741
+ } finally {
1742
+ wasm$3.__wbindgen_add_to_stack_pointer(16);
1743
+ wasm$3.__wbindgen_export4(deferred3_0, deferred3_1, 1);
1744
+ }
1745
+ }
1726
1746
  function ast_remove_where$1(ast_json) {
1727
1747
  let deferred2_0;
1728
1748
  let deferred2_1;
@@ -1781,6 +1801,28 @@ function ast_rename_tables$1(ast_json, mapping_json) {
1781
1801
  wasm$3.__wbindgen_export4(deferred3_0, deferred3_1, 1);
1782
1802
  }
1783
1803
  }
1804
+ function ast_rename_tables_with_options$1(ast_json, mapping_json, options_json) {
1805
+ let deferred4_0;
1806
+ let deferred4_1;
1807
+ try {
1808
+ const retptr = wasm$3.__wbindgen_add_to_stack_pointer(-16);
1809
+ const ptr0 = passStringToWasm0(ast_json, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
1810
+ const len0 = WASM_VECTOR_LEN;
1811
+ const ptr1 = passStringToWasm0(mapping_json, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
1812
+ const len1 = WASM_VECTOR_LEN;
1813
+ const ptr2 = passStringToWasm0(options_json, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
1814
+ const len2 = WASM_VECTOR_LEN;
1815
+ wasm$3.ast_rename_tables_with_options(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
1816
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1817
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1818
+ deferred4_0 = r0;
1819
+ deferred4_1 = r1;
1820
+ return getStringFromWasm0(r0, r1);
1821
+ } finally {
1822
+ wasm$3.__wbindgen_add_to_stack_pointer(16);
1823
+ wasm$3.__wbindgen_export4(deferred4_0, deferred4_1, 1);
1824
+ }
1825
+ }
1784
1826
  function ast_set_distinct$1(ast_json, distinct) {
1785
1827
  let deferred2_0;
1786
1828
  let deferred2_1;
@@ -2884,9 +2926,11 @@ async function __polyglot_init_wasm() {
2884
2926
  ast_get_window_functions = __vite__wasmModule.ast_get_window_functions;
2885
2927
  ast_node_count = __vite__wasmModule.ast_node_count;
2886
2928
  ast_qualify_columns = __vite__wasmModule.ast_qualify_columns;
2929
+ ast_qualify_tables = __vite__wasmModule.ast_qualify_tables;
2887
2930
  ast_remove_where = __vite__wasmModule.ast_remove_where;
2888
2931
  ast_rename_columns = __vite__wasmModule.ast_rename_columns;
2889
2932
  ast_rename_tables = __vite__wasmModule.ast_rename_tables;
2933
+ ast_rename_tables_with_options = __vite__wasmModule.ast_rename_tables_with_options;
2890
2934
  ast_set_distinct = __vite__wasmModule.ast_set_distinct;
2891
2935
  ast_set_limit = __vite__wasmModule.ast_set_limit;
2892
2936
  diff_sql = __vite__wasmModule.diff_sql;
@@ -3070,9 +3114,11 @@ let ast_get_table_names;
3070
3114
  let ast_get_window_functions;
3071
3115
  let ast_node_count;
3072
3116
  let ast_qualify_columns;
3117
+ let ast_qualify_tables;
3073
3118
  let ast_remove_where;
3074
3119
  let ast_rename_columns;
3075
3120
  let ast_rename_tables;
3121
+ let ast_rename_tables_with_options;
3076
3122
  let ast_set_distinct;
3077
3123
  let ast_set_limit;
3078
3124
  let diff_sql;
@@ -3258,9 +3304,11 @@ const wasm$2 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProper
3258
3304
  ast_get_window_functions,
3259
3305
  ast_node_count,
3260
3306
  ast_qualify_columns,
3307
+ ast_qualify_tables,
3261
3308
  ast_remove_where,
3262
3309
  ast_rename_columns,
3263
3310
  ast_rename_tables,
3311
+ ast_rename_tables_with_options,
3264
3312
  ast_set_distinct,
3265
3313
  ast_set_limit,
3266
3314
  diff_sql,
@@ -3438,9 +3486,11 @@ const wasmModule = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePr
3438
3486
  ast_get_window_functions: ast_get_window_functions$1,
3439
3487
  ast_node_count: ast_node_count$1,
3440
3488
  ast_qualify_columns: ast_qualify_columns$1,
3489
+ ast_qualify_tables: ast_qualify_tables$1,
3441
3490
  ast_remove_where: ast_remove_where$1,
3442
3491
  ast_rename_columns: ast_rename_columns$1,
3443
3492
  ast_rename_tables: ast_rename_tables$1,
3493
+ ast_rename_tables_with_options: ast_rename_tables_with_options$1,
3444
3494
  ast_set_distinct: ast_set_distinct$1,
3445
3495
  ast_set_limit: ast_set_limit$1,
3446
3496
  diff_sql: diff_sql$1,
@@ -3729,9 +3779,13 @@ function renameColumns(node, mapping) {
3729
3779
  );
3730
3780
  return result ?? node;
3731
3781
  }
3732
- function renameTables(node, mapping) {
3782
+ function renameTables(node, mapping, options) {
3733
3783
  const result = parseAstResult(
3734
- ast_rename_tables$1(exprToJson$1(node), JSON.stringify(mapping))
3784
+ options ? ast_rename_tables_with_options$1(
3785
+ exprToJson$1(node),
3786
+ JSON.stringify(mapping),
3787
+ JSON.stringify(options)
3788
+ ) : ast_rename_tables$1(exprToJson$1(node), JSON.stringify(mapping))
3735
3789
  );
3736
3790
  return result ?? node;
3737
3791
  }
@@ -3741,6 +3795,12 @@ function qualifyColumns(node, tableName) {
3741
3795
  );
3742
3796
  return result ?? node;
3743
3797
  }
3798
+ function qualifyTables(node, options = {}) {
3799
+ const result = parseAstResult(
3800
+ ast_qualify_tables$1(exprToJson$1(node), JSON.stringify(options))
3801
+ );
3802
+ return result ?? node;
3803
+ }
3744
3804
  function addWhere(node, condition2, operator = "and") {
3745
3805
  const result = parseAstResult(
3746
3806
  ast_add_where$1(exprToJson$1(node), exprToJson$1(condition2), operator === "or")
@@ -4182,6 +4242,7 @@ const index$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePrope
4182
4242
  makeExpr,
4183
4243
  nodeCount,
4184
4244
  qualifyColumns,
4245
+ qualifyTables,
4185
4246
  remove,
4186
4247
  removeLimitOffset,
4187
4248
  removeSelectColumns,
package/dist/index.d.cts CHANGED
@@ -1039,6 +1039,7 @@ export declare namespace ast {
1039
1039
  addWhere,
1040
1040
  clone,
1041
1041
  qualifyColumns,
1042
+ qualifyTables,
1042
1043
  remove,
1043
1044
  removeLimitOffset,
1044
1045
  removeSelectColumns,
@@ -1058,6 +1059,8 @@ export declare namespace ast {
1058
1059
  VisitorCallback,
1059
1060
  VisitorConfig,
1060
1061
  VisitorContext,
1062
+ QualifyTablesOptions,
1063
+ RenameTablesOptions,
1061
1064
  countNodes,
1062
1065
  every,
1063
1066
  findAll,
@@ -10716,6 +10719,29 @@ declare type Qualify = {
10716
10719
  */
10717
10720
  declare function qualifyColumns(node: Expression, tableName: string): Expression;
10718
10721
 
10722
+ /**
10723
+ * Qualify table references and optionally generate stable aliases (via WASM)
10724
+ *
10725
+ * @example
10726
+ * ```typescript
10727
+ * const newAst = qualifyTables(ast, {
10728
+ * canonicalizeTableAliases: true
10729
+ * });
10730
+ * ```
10731
+ */
10732
+ declare function qualifyTables(node: Expression, options?: QualifyTablesOptions): Expression;
10733
+
10734
+ declare interface QualifyTablesOptions {
10735
+ db?: string;
10736
+ catalog?: string;
10737
+ dialect?: string;
10738
+ canonicalizeTableAliases?: boolean;
10739
+ aliasUnaliasedTables?: boolean;
10740
+ aliasUnaliasedSubqueries?: boolean;
10741
+ aliasPrefix?: string;
10742
+ normalizeSetOperationSubqueries?: boolean;
10743
+ }
10744
+
10719
10745
  /**
10720
10746
  * ANY / ALL quantified expression
10721
10747
  */
@@ -11184,7 +11210,12 @@ export declare function renameColumns(node: Expression, mapping: Record<string,
11184
11210
  * });
11185
11211
  * ```
11186
11212
  */
11187
- declare function renameTables(node: Expression, mapping: Record<string, string>): Expression;
11213
+ declare function renameTables(node: Expression, mapping: Record<string, string>, options?: RenameTablesOptions): Expression;
11214
+
11215
+ declare interface RenameTablesOptions {
11216
+ aliasRenamedTables?: boolean;
11217
+ preserveExistingAliases?: boolean;
11218
+ }
11188
11219
 
11189
11220
  /**
11190
11221
  * REPEAT function
package/dist/index.d.ts CHANGED
@@ -1039,6 +1039,7 @@ export declare namespace ast {
1039
1039
  addWhere,
1040
1040
  clone,
1041
1041
  qualifyColumns,
1042
+ qualifyTables,
1042
1043
  remove,
1043
1044
  removeLimitOffset,
1044
1045
  removeSelectColumns,
@@ -1058,6 +1059,8 @@ export declare namespace ast {
1058
1059
  VisitorCallback,
1059
1060
  VisitorConfig,
1060
1061
  VisitorContext,
1062
+ QualifyTablesOptions,
1063
+ RenameTablesOptions,
1061
1064
  countNodes,
1062
1065
  every,
1063
1066
  findAll,
@@ -10716,6 +10719,29 @@ declare type Qualify = {
10716
10719
  */
10717
10720
  declare function qualifyColumns(node: Expression, tableName: string): Expression;
10718
10721
 
10722
+ /**
10723
+ * Qualify table references and optionally generate stable aliases (via WASM)
10724
+ *
10725
+ * @example
10726
+ * ```typescript
10727
+ * const newAst = qualifyTables(ast, {
10728
+ * canonicalizeTableAliases: true
10729
+ * });
10730
+ * ```
10731
+ */
10732
+ declare function qualifyTables(node: Expression, options?: QualifyTablesOptions): Expression;
10733
+
10734
+ declare interface QualifyTablesOptions {
10735
+ db?: string;
10736
+ catalog?: string;
10737
+ dialect?: string;
10738
+ canonicalizeTableAliases?: boolean;
10739
+ aliasUnaliasedTables?: boolean;
10740
+ aliasUnaliasedSubqueries?: boolean;
10741
+ aliasPrefix?: string;
10742
+ normalizeSetOperationSubqueries?: boolean;
10743
+ }
10744
+
10719
10745
  /**
10720
10746
  * ANY / ALL quantified expression
10721
10747
  */
@@ -11184,7 +11210,12 @@ export declare function renameColumns(node: Expression, mapping: Record<string,
11184
11210
  * });
11185
11211
  * ```
11186
11212
  */
11187
- declare function renameTables(node: Expression, mapping: Record<string, string>): Expression;
11213
+ declare function renameTables(node: Expression, mapping: Record<string, string>, options?: RenameTablesOptions): Expression;
11214
+
11215
+ declare interface RenameTablesOptions {
11216
+ aliasRenamedTables?: boolean;
11217
+ preserveExistingAliases?: boolean;
11218
+ }
11188
11219
 
11189
11220
  /**
11190
11221
  * REPEAT function
package/dist/index.js CHANGED
@@ -1894,6 +1894,33 @@ function ast_qualify_columns$1(ast_json, table_name) {
1894
1894
  }
1895
1895
  }
1896
1896
 
1897
+ /**
1898
+ * Qualify table references in an AST.
1899
+ * @param {string} ast_json
1900
+ * @param {string} options_json
1901
+ * @returns {string}
1902
+ */
1903
+ function ast_qualify_tables$1(ast_json, options_json) {
1904
+ let deferred3_0;
1905
+ let deferred3_1;
1906
+ try {
1907
+ const retptr = wasm$3.__wbindgen_add_to_stack_pointer(-16);
1908
+ const ptr0 = passStringToWasm0(ast_json, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
1909
+ const len0 = WASM_VECTOR_LEN;
1910
+ const ptr1 = passStringToWasm0(options_json, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
1911
+ const len1 = WASM_VECTOR_LEN;
1912
+ wasm$3.ast_qualify_tables(retptr, ptr0, len0, ptr1, len1);
1913
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1914
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1915
+ deferred3_0 = r0;
1916
+ deferred3_1 = r1;
1917
+ return getStringFromWasm0(r0, r1);
1918
+ } finally {
1919
+ wasm$3.__wbindgen_add_to_stack_pointer(16);
1920
+ wasm$3.__wbindgen_export4(deferred3_0, deferred3_1, 1);
1921
+ }
1922
+ }
1923
+
1897
1924
  /**
1898
1925
  * Remove the WHERE clause from a SELECT AST.
1899
1926
  * @param {string} ast_json
@@ -1972,6 +1999,36 @@ function ast_rename_tables$1(ast_json, mapping_json) {
1972
1999
  }
1973
2000
  }
1974
2001
 
2002
+ /**
2003
+ * Rename tables in an AST with table-renaming options.
2004
+ * @param {string} ast_json
2005
+ * @param {string} mapping_json
2006
+ * @param {string} options_json
2007
+ * @returns {string}
2008
+ */
2009
+ function ast_rename_tables_with_options$1(ast_json, mapping_json, options_json) {
2010
+ let deferred4_0;
2011
+ let deferred4_1;
2012
+ try {
2013
+ const retptr = wasm$3.__wbindgen_add_to_stack_pointer(-16);
2014
+ const ptr0 = passStringToWasm0(ast_json, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
2015
+ const len0 = WASM_VECTOR_LEN;
2016
+ const ptr1 = passStringToWasm0(mapping_json, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
2017
+ const len1 = WASM_VECTOR_LEN;
2018
+ const ptr2 = passStringToWasm0(options_json, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
2019
+ const len2 = WASM_VECTOR_LEN;
2020
+ wasm$3.ast_rename_tables_with_options(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
2021
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2022
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2023
+ deferred4_0 = r0;
2024
+ deferred4_1 = r1;
2025
+ return getStringFromWasm0(r0, r1);
2026
+ } finally {
2027
+ wasm$3.__wbindgen_add_to_stack_pointer(16);
2028
+ wasm$3.__wbindgen_export4(deferred4_0, deferred4_1, 1);
2029
+ }
2030
+ }
2031
+
1975
2032
  /**
1976
2033
  * Set DISTINCT on a SELECT AST.
1977
2034
  * @param {string} ast_json
@@ -3495,9 +3552,11 @@ const ast_get_table_names = __vite__wasmModule.ast_get_table_names;
3495
3552
  const ast_get_window_functions = __vite__wasmModule.ast_get_window_functions;
3496
3553
  const ast_node_count = __vite__wasmModule.ast_node_count;
3497
3554
  const ast_qualify_columns = __vite__wasmModule.ast_qualify_columns;
3555
+ const ast_qualify_tables = __vite__wasmModule.ast_qualify_tables;
3498
3556
  const ast_remove_where = __vite__wasmModule.ast_remove_where;
3499
3557
  const ast_rename_columns = __vite__wasmModule.ast_rename_columns;
3500
3558
  const ast_rename_tables = __vite__wasmModule.ast_rename_tables;
3559
+ const ast_rename_tables_with_options = __vite__wasmModule.ast_rename_tables_with_options;
3501
3560
  const ast_set_distinct = __vite__wasmModule.ast_set_distinct;
3502
3561
  const ast_set_limit = __vite__wasmModule.ast_set_limit;
3503
3562
  const diff_sql = __vite__wasmModule.diff_sql;
@@ -3684,9 +3743,11 @@ const wasm$2 = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
3684
3743
  ast_get_window_functions,
3685
3744
  ast_node_count,
3686
3745
  ast_qualify_columns,
3746
+ ast_qualify_tables,
3687
3747
  ast_remove_where,
3688
3748
  ast_rename_columns,
3689
3749
  ast_rename_tables,
3750
+ ast_rename_tables_with_options,
3690
3751
  ast_set_distinct,
3691
3752
  ast_set_limit,
3692
3753
  diff_sql,
@@ -3869,9 +3930,11 @@ const wasmModule = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty
3869
3930
  ast_get_window_functions: ast_get_window_functions$1,
3870
3931
  ast_node_count: ast_node_count$1,
3871
3932
  ast_qualify_columns: ast_qualify_columns$1,
3933
+ ast_qualify_tables: ast_qualify_tables$1,
3872
3934
  ast_remove_where: ast_remove_where$1,
3873
3935
  ast_rename_columns: ast_rename_columns$1,
3874
3936
  ast_rename_tables: ast_rename_tables$1,
3937
+ ast_rename_tables_with_options: ast_rename_tables_with_options$1,
3875
3938
  ast_set_distinct: ast_set_distinct$1,
3876
3939
  ast_set_limit: ast_set_limit$1,
3877
3940
  diff_sql: diff_sql$1,
@@ -4163,9 +4226,13 @@ function renameColumns(node, mapping) {
4163
4226
  );
4164
4227
  return result ?? node;
4165
4228
  }
4166
- function renameTables(node, mapping) {
4229
+ function renameTables(node, mapping, options) {
4167
4230
  const result = parseAstResult(
4168
- ast_rename_tables$1(exprToJson$1(node), JSON.stringify(mapping))
4231
+ options ? ast_rename_tables_with_options$1(
4232
+ exprToJson$1(node),
4233
+ JSON.stringify(mapping),
4234
+ JSON.stringify(options)
4235
+ ) : ast_rename_tables$1(exprToJson$1(node), JSON.stringify(mapping))
4169
4236
  );
4170
4237
  return result ?? node;
4171
4238
  }
@@ -4175,6 +4242,12 @@ function qualifyColumns(node, tableName) {
4175
4242
  );
4176
4243
  return result ?? node;
4177
4244
  }
4245
+ function qualifyTables(node, options = {}) {
4246
+ const result = parseAstResult(
4247
+ ast_qualify_tables$1(exprToJson$1(node), JSON.stringify(options))
4248
+ );
4249
+ return result ?? node;
4250
+ }
4178
4251
  function addWhere(node, condition, operator = "and") {
4179
4252
  const result = parseAstResult(
4180
4253
  ast_add_where$1(exprToJson$1(node), exprToJson$1(condition), operator === "or")
@@ -4618,6 +4691,7 @@ const index$1 = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
4618
4691
  makeExpr,
4619
4692
  nodeCount,
4620
4693
  qualifyColumns,
4694
+ qualifyTables,
4621
4695
  remove,
4622
4696
  removeLimitOffset,
4623
4697
  removeSelectColumns,
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polyglot-sql/sdk",
3
- "version": "0.3.8",
3
+ "version": "0.3.10",
4
4
  "description": "SQL dialect translator powered by WebAssembly",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",