@polyglot-sql/sdk 0.4.4 → 0.5.0

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
@@ -2227,6 +2227,40 @@ function transpile_value$1(sql, read_dialect, write_dialect) {
2227
2227
  const ret = wasm$3.transpile_value(ptr0, len0, ptr1, len1, ptr2, len2);
2228
2228
  return takeObject(ret);
2229
2229
  }
2230
+ function transpile_with_options$1(sql, read_dialect, write_dialect, options_json) {
2231
+ let deferred5_0;
2232
+ let deferred5_1;
2233
+ try {
2234
+ const retptr = wasm$3.__wbindgen_add_to_stack_pointer(-16);
2235
+ const ptr0 = passStringToWasm0(sql, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
2236
+ const len0 = WASM_VECTOR_LEN;
2237
+ const ptr1 = passStringToWasm0(read_dialect, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
2238
+ const len1 = WASM_VECTOR_LEN;
2239
+ const ptr2 = passStringToWasm0(write_dialect, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
2240
+ const len2 = WASM_VECTOR_LEN;
2241
+ const ptr3 = passStringToWasm0(options_json, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
2242
+ const len3 = WASM_VECTOR_LEN;
2243
+ wasm$3.transpile_with_options(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
2244
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2245
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2246
+ deferred5_0 = r0;
2247
+ deferred5_1 = r1;
2248
+ return getStringFromWasm0(r0, r1);
2249
+ } finally {
2250
+ wasm$3.__wbindgen_add_to_stack_pointer(16);
2251
+ wasm$3.__wbindgen_export4(deferred5_0, deferred5_1, 1);
2252
+ }
2253
+ }
2254
+ function transpile_with_options_value$1(sql, read_dialect, write_dialect, options) {
2255
+ const ptr0 = passStringToWasm0(sql, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
2256
+ const len0 = WASM_VECTOR_LEN;
2257
+ const ptr1 = passStringToWasm0(read_dialect, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
2258
+ const len1 = WASM_VECTOR_LEN;
2259
+ const ptr2 = passStringToWasm0(write_dialect, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
2260
+ const len2 = WASM_VECTOR_LEN;
2261
+ const ret = wasm$3.transpile_with_options_value(ptr0, len0, ptr1, len1, ptr2, len2, addHeapObject(options));
2262
+ return takeObject(ret);
2263
+ }
2230
2264
  function validate$2(sql, dialect) {
2231
2265
  let deferred3_0;
2232
2266
  let deferred3_1;
@@ -3021,6 +3055,8 @@ async function __polyglot_init_wasm() {
3021
3055
  tokenize_value = __vite__wasmModule.tokenize_value;
3022
3056
  transpile$1 = __vite__wasmModule.transpile;
3023
3057
  transpile_value = __vite__wasmModule.transpile_value;
3058
+ transpile_with_options = __vite__wasmModule.transpile_with_options;
3059
+ transpile_with_options_value = __vite__wasmModule.transpile_with_options_value;
3024
3060
  validate$1 = __vite__wasmModule.validate;
3025
3061
  validate_with_options = __vite__wasmModule.validate_with_options;
3026
3062
  validate_with_schema = __vite__wasmModule.validate_with_schema;
@@ -3212,6 +3248,8 @@ let tokenize$1;
3212
3248
  let tokenize_value;
3213
3249
  let transpile$1;
3214
3250
  let transpile_value;
3251
+ let transpile_with_options;
3252
+ let transpile_with_options_value;
3215
3253
  let validate$1;
3216
3254
  let validate_with_options;
3217
3255
  let validate_with_schema;
@@ -3406,6 +3444,8 @@ const wasm$2 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProper
3406
3444
  tokenize_value,
3407
3445
  transpile: transpile$1,
3408
3446
  transpile_value,
3447
+ transpile_with_options,
3448
+ transpile_with_options_value,
3409
3449
  validate: validate$1,
3410
3450
  validate_with_options,
3411
3451
  validate_with_schema,
@@ -3590,6 +3630,8 @@ const wasmModule = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePr
3590
3630
  tokenize_value: tokenize_value$1,
3591
3631
  transpile: transpile$2,
3592
3632
  transpile_value: transpile_value$1,
3633
+ transpile_with_options: transpile_with_options$1,
3634
+ transpile_with_options_value: transpile_with_options_value$1,
3593
3635
  validate: validate$2,
3594
3636
  validate_with_options: validate_with_options$1,
3595
3637
  validate_with_schema: validate_with_schema$1,
@@ -5344,8 +5386,25 @@ async function init() {
5344
5386
  function isInitialized() {
5345
5387
  return !!__vite__wasmModule;
5346
5388
  }
5347
- function transpile(sql, read, write) {
5389
+ function transpile(sql, read, write, options) {
5348
5390
  try {
5391
+ if (options && Object.keys(options).length > 0) {
5392
+ if (typeof wasm.transpile_with_options_value === "function") {
5393
+ return decodeWasmPayload(
5394
+ wasm.transpile_with_options_value(sql, read, write, options)
5395
+ );
5396
+ }
5397
+ if (typeof wasm.transpile_with_options === "function") {
5398
+ return JSON.parse(
5399
+ wasm.transpile_with_options(sql, read, write, JSON.stringify(options))
5400
+ );
5401
+ }
5402
+ return {
5403
+ success: false,
5404
+ sql: void 0,
5405
+ error: "WASM transpile options are not available in this build"
5406
+ };
5407
+ }
5349
5408
  if (typeof wasm.transpile_value === "function") {
5350
5409
  return decodeWasmPayload(
5351
5410
  wasm.transpile_value(sql, read, write)
@@ -5478,8 +5537,8 @@ class Polyglot {
5478
5537
  * Per-dialect builds only support same-dialect and to/from Generic transpilation.
5479
5538
  * Use {@link Polyglot.getDialects} to check available dialects.
5480
5539
  */
5481
- transpile(sql, read, write) {
5482
- return transpile(sql, read, write);
5540
+ transpile(sql, read, write, options) {
5541
+ return transpile(sql, read, write, options);
5483
5542
  }
5484
5543
  /**
5485
5544
  * Parse SQL into an AST.
package/dist/index.d.cts CHANGED
@@ -10590,7 +10590,7 @@ export declare class Polyglot {
10590
10590
  * Per-dialect builds only support same-dialect and to/from Generic transpilation.
10591
10591
  * Use {@link Polyglot.getDialects} to check available dialects.
10592
10592
  */
10593
- transpile(sql: string, read: Dialect, write: Dialect): TranspileResult;
10593
+ transpile(sql: string, read: Dialect, write: Dialect, options?: TranspileOptions): TranspileResult;
10594
10594
  /**
10595
10595
  * Parse SQL into an AST.
10596
10596
  */
@@ -13619,11 +13619,17 @@ declare type TranslateCharacters = {
13619
13619
  * // result.sql[0] = "SELECT COALESCE(a, b)"
13620
13620
  * ```
13621
13621
  */
13622
- export declare function transpile(sql: string, read: Dialect, write: Dialect): TranspileResult;
13622
+ export declare function transpile(sql: string, read: Dialect, write: Dialect, options?: TranspileOptions): TranspileResult;
13623
+
13624
+ export declare interface TranspileOptions {
13625
+ /** Pretty-print the generated SQL */
13626
+ pretty?: boolean;
13627
+ /** How unsupported target-dialect constructs should be handled */
13628
+ unsupportedLevel?: UnsupportedLevel;
13629
+ /** Maximum number of unsupported diagnostics to include in raised errors */
13630
+ maxUnsupported?: number;
13631
+ }
13623
13632
 
13624
- /**
13625
- * Transpilation options
13626
- */
13627
13633
  /**
13628
13634
  * Result of a transpilation operation
13629
13635
  */
@@ -14171,6 +14177,11 @@ declare type UnpivotColumns = {
14171
14177
  expressions: Array<Expression>;
14172
14178
  };
14173
14179
 
14180
+ /**
14181
+ * Transpilation options
14182
+ */
14183
+ export declare type UnsupportedLevel = 'ignore' | 'warn' | 'raise' | 'immediate';
14184
+
14174
14185
  /**
14175
14186
  * UPDATE statement
14176
14187
  */
package/dist/index.d.ts CHANGED
@@ -10590,7 +10590,7 @@ export declare class Polyglot {
10590
10590
  * Per-dialect builds only support same-dialect and to/from Generic transpilation.
10591
10591
  * Use {@link Polyglot.getDialects} to check available dialects.
10592
10592
  */
10593
- transpile(sql: string, read: Dialect, write: Dialect): TranspileResult;
10593
+ transpile(sql: string, read: Dialect, write: Dialect, options?: TranspileOptions): TranspileResult;
10594
10594
  /**
10595
10595
  * Parse SQL into an AST.
10596
10596
  */
@@ -13619,11 +13619,17 @@ declare type TranslateCharacters = {
13619
13619
  * // result.sql[0] = "SELECT COALESCE(a, b)"
13620
13620
  * ```
13621
13621
  */
13622
- export declare function transpile(sql: string, read: Dialect, write: Dialect): TranspileResult;
13622
+ export declare function transpile(sql: string, read: Dialect, write: Dialect, options?: TranspileOptions): TranspileResult;
13623
+
13624
+ export declare interface TranspileOptions {
13625
+ /** Pretty-print the generated SQL */
13626
+ pretty?: boolean;
13627
+ /** How unsupported target-dialect constructs should be handled */
13628
+ unsupportedLevel?: UnsupportedLevel;
13629
+ /** Maximum number of unsupported diagnostics to include in raised errors */
13630
+ maxUnsupported?: number;
13631
+ }
13623
13632
 
13624
- /**
13625
- * Transpilation options
13626
- */
13627
13633
  /**
13628
13634
  * Result of a transpilation operation
13629
13635
  */
@@ -14171,6 +14177,11 @@ declare type UnpivotColumns = {
14171
14177
  expressions: Array<Expression>;
14172
14178
  };
14173
14179
 
14180
+ /**
14181
+ * Transpilation options
14182
+ */
14183
+ export declare type UnsupportedLevel = 'ignore' | 'warn' | 'raise' | 'immediate';
14184
+
14174
14185
  /**
14175
14186
  * UPDATE statement
14176
14187
  */
package/dist/index.js CHANGED
@@ -2694,6 +2694,58 @@ function transpile_value$1(sql, read_dialect, write_dialect) {
2694
2694
  return takeObject(ret);
2695
2695
  }
2696
2696
 
2697
+ /**
2698
+ * Transpile SQL with explicit options encoded as a JSON string.
2699
+ * @param {string} sql
2700
+ * @param {string} read_dialect
2701
+ * @param {string} write_dialect
2702
+ * @param {string} options_json
2703
+ * @returns {string}
2704
+ */
2705
+ function transpile_with_options$1(sql, read_dialect, write_dialect, options_json) {
2706
+ let deferred5_0;
2707
+ let deferred5_1;
2708
+ try {
2709
+ const retptr = wasm$3.__wbindgen_add_to_stack_pointer(-16);
2710
+ const ptr0 = passStringToWasm0(sql, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
2711
+ const len0 = WASM_VECTOR_LEN;
2712
+ const ptr1 = passStringToWasm0(read_dialect, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
2713
+ const len1 = WASM_VECTOR_LEN;
2714
+ const ptr2 = passStringToWasm0(write_dialect, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
2715
+ const len2 = WASM_VECTOR_LEN;
2716
+ const ptr3 = passStringToWasm0(options_json, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
2717
+ const len3 = WASM_VECTOR_LEN;
2718
+ wasm$3.transpile_with_options(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
2719
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2720
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2721
+ deferred5_0 = r0;
2722
+ deferred5_1 = r1;
2723
+ return getStringFromWasm0(r0, r1);
2724
+ } finally {
2725
+ wasm$3.__wbindgen_add_to_stack_pointer(16);
2726
+ wasm$3.__wbindgen_export4(deferred5_0, deferred5_1, 1);
2727
+ }
2728
+ }
2729
+
2730
+ /**
2731
+ * Transpile SQL with explicit options and return a structured JS object.
2732
+ * @param {string} sql
2733
+ * @param {string} read_dialect
2734
+ * @param {string} write_dialect
2735
+ * @param {any} options
2736
+ * @returns {any}
2737
+ */
2738
+ function transpile_with_options_value$1(sql, read_dialect, write_dialect, options) {
2739
+ const ptr0 = passStringToWasm0(sql, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
2740
+ const len0 = WASM_VECTOR_LEN;
2741
+ const ptr1 = passStringToWasm0(read_dialect, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
2742
+ const len1 = WASM_VECTOR_LEN;
2743
+ const ptr2 = passStringToWasm0(write_dialect, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
2744
+ const len2 = WASM_VECTOR_LEN;
2745
+ const ret = wasm$3.transpile_with_options_value(ptr0, len0, ptr1, len1, ptr2, len2, addHeapObject(options));
2746
+ return takeObject(ret);
2747
+ }
2748
+
2697
2749
  /**
2698
2750
  * Validate SQL syntax.
2699
2751
  *
@@ -3667,6 +3719,8 @@ const tokenize$1 = __vite__wasmModule.tokenize;
3667
3719
  const tokenize_value = __vite__wasmModule.tokenize_value;
3668
3720
  const transpile$1 = __vite__wasmModule.transpile;
3669
3721
  const transpile_value = __vite__wasmModule.transpile_value;
3722
+ const transpile_with_options = __vite__wasmModule.transpile_with_options;
3723
+ const transpile_with_options_value = __vite__wasmModule.transpile_with_options_value;
3670
3724
  const validate$1 = __vite__wasmModule.validate;
3671
3725
  const validate_with_options = __vite__wasmModule.validate_with_options;
3672
3726
  const validate_with_schema = __vite__wasmModule.validate_with_schema;
@@ -3862,6 +3916,8 @@ const wasm$2 = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
3862
3916
  tokenize_value,
3863
3917
  transpile: transpile$1,
3864
3918
  transpile_value,
3919
+ transpile_with_options,
3920
+ transpile_with_options_value,
3865
3921
  validate: validate$1,
3866
3922
  validate_with_options,
3867
3923
  validate_with_schema,
@@ -4051,6 +4107,8 @@ const wasmModule = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty
4051
4107
  tokenize_value: tokenize_value$1,
4052
4108
  transpile: transpile$2,
4053
4109
  transpile_value: transpile_value$1,
4110
+ transpile_with_options: transpile_with_options$1,
4111
+ transpile_with_options_value: transpile_with_options_value$1,
4054
4112
  validate: validate$2,
4055
4113
  validate_with_options: validate_with_options$1,
4056
4114
  validate_with_schema: validate_with_schema$1,
@@ -5820,8 +5878,25 @@ async function init() {
5820
5878
  function isInitialized() {
5821
5879
  return true;
5822
5880
  }
5823
- function transpile(sql, read, write) {
5881
+ function transpile(sql, read, write, options) {
5824
5882
  try {
5883
+ if (options && Object.keys(options).length > 0) {
5884
+ if (typeof wasm.transpile_with_options_value === "function") {
5885
+ return decodeWasmPayload(
5886
+ wasm.transpile_with_options_value(sql, read, write, options)
5887
+ );
5888
+ }
5889
+ if (typeof wasm.transpile_with_options === "function") {
5890
+ return JSON.parse(
5891
+ wasm.transpile_with_options(sql, read, write, JSON.stringify(options))
5892
+ );
5893
+ }
5894
+ return {
5895
+ success: false,
5896
+ sql: void 0,
5897
+ error: "WASM transpile options are not available in this build"
5898
+ };
5899
+ }
5825
5900
  if (typeof wasm.transpile_value === "function") {
5826
5901
  return decodeWasmPayload(
5827
5902
  wasm.transpile_value(sql, read, write)
@@ -5954,8 +6029,8 @@ class Polyglot {
5954
6029
  * Per-dialect builds only support same-dialect and to/from Generic transpilation.
5955
6030
  * Use {@link Polyglot.getDialects} to check available dialects.
5956
6031
  */
5957
- transpile(sql, read, write) {
5958
- return transpile(sql, read, write);
6032
+ transpile(sql, read, write, options) {
6033
+ return transpile(sql, read, write, options);
5959
6034
  }
5960
6035
  /**
5961
6036
  * Parse SQL into an AST.
@@ -2256,6 +2256,40 @@ function transpile_value$1(sql, read_dialect, write_dialect) {
2256
2256
  const ret = wasm$3.transpile_value(ptr0, len0, ptr1, len1, ptr2, len2);
2257
2257
  return takeObject(ret);
2258
2258
  }
2259
+ function transpile_with_options$1(sql, read_dialect, write_dialect, options_json) {
2260
+ let deferred5_0;
2261
+ let deferred5_1;
2262
+ try {
2263
+ const retptr = wasm$3.__wbindgen_add_to_stack_pointer(-16);
2264
+ const ptr0 = passStringToWasm0(sql, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
2265
+ const len0 = WASM_VECTOR_LEN;
2266
+ const ptr1 = passStringToWasm0(read_dialect, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
2267
+ const len1 = WASM_VECTOR_LEN;
2268
+ const ptr2 = passStringToWasm0(write_dialect, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
2269
+ const len2 = WASM_VECTOR_LEN;
2270
+ const ptr3 = passStringToWasm0(options_json, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
2271
+ const len3 = WASM_VECTOR_LEN;
2272
+ wasm$3.transpile_with_options(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
2273
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2274
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2275
+ deferred5_0 = r0;
2276
+ deferred5_1 = r1;
2277
+ return getStringFromWasm0(r0, r1);
2278
+ } finally {
2279
+ wasm$3.__wbindgen_add_to_stack_pointer(16);
2280
+ wasm$3.__wbindgen_export4(deferred5_0, deferred5_1, 1);
2281
+ }
2282
+ }
2283
+ function transpile_with_options_value$1(sql, read_dialect, write_dialect, options) {
2284
+ const ptr0 = passStringToWasm0(sql, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
2285
+ const len0 = WASM_VECTOR_LEN;
2286
+ const ptr1 = passStringToWasm0(read_dialect, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
2287
+ const len1 = WASM_VECTOR_LEN;
2288
+ const ptr2 = passStringToWasm0(write_dialect, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
2289
+ const len2 = WASM_VECTOR_LEN;
2290
+ const ret = wasm$3.transpile_with_options_value(ptr0, len0, ptr1, len1, ptr2, len2, addHeapObject(options));
2291
+ return takeObject(ret);
2292
+ }
2259
2293
  function validate$2(sql, dialect) {
2260
2294
  let deferred3_0;
2261
2295
  let deferred3_1;
@@ -3040,6 +3074,8 @@ const tokenize$1 = __vite__wasmModule.tokenize;
3040
3074
  const tokenize_value = __vite__wasmModule.tokenize_value;
3041
3075
  const transpile$1 = __vite__wasmModule.transpile;
3042
3076
  const transpile_value = __vite__wasmModule.transpile_value;
3077
+ const transpile_with_options = __vite__wasmModule.transpile_with_options;
3078
+ const transpile_with_options_value = __vite__wasmModule.transpile_with_options_value;
3043
3079
  const validate$1 = __vite__wasmModule.validate;
3044
3080
  const validate_with_options = __vite__wasmModule.validate_with_options;
3045
3081
  const validate_with_schema = __vite__wasmModule.validate_with_schema;
@@ -3234,6 +3270,8 @@ const wasm$2 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProper
3234
3270
  tokenize_value,
3235
3271
  transpile: transpile$1,
3236
3272
  transpile_value,
3273
+ transpile_with_options,
3274
+ transpile_with_options_value,
3237
3275
  validate: validate$1,
3238
3276
  validate_with_options,
3239
3277
  validate_with_schema,
@@ -3419,6 +3457,8 @@ const wasmModule = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePr
3419
3457
  tokenize_value: tokenize_value$1,
3420
3458
  transpile: transpile$2,
3421
3459
  transpile_value: transpile_value$1,
3460
+ transpile_with_options: transpile_with_options$1,
3461
+ transpile_with_options_value: transpile_with_options_value$1,
3422
3462
  validate: validate$2,
3423
3463
  validate_with_options: validate_with_options$1,
3424
3464
  validate_with_schema: validate_with_schema$1,
@@ -5173,8 +5213,25 @@ async function init() {
5173
5213
  function isInitialized() {
5174
5214
  return true;
5175
5215
  }
5176
- function transpile(sql, read, write) {
5216
+ function transpile(sql, read, write, options) {
5177
5217
  try {
5218
+ if (options && Object.keys(options).length > 0) {
5219
+ if (typeof wasm.transpile_with_options_value === "function") {
5220
+ return decodeWasmPayload(
5221
+ wasm.transpile_with_options_value(sql, read, write, options)
5222
+ );
5223
+ }
5224
+ if (typeof wasm.transpile_with_options === "function") {
5225
+ return JSON.parse(
5226
+ wasm.transpile_with_options(sql, read, write, JSON.stringify(options))
5227
+ );
5228
+ }
5229
+ return {
5230
+ success: false,
5231
+ sql: void 0,
5232
+ error: "WASM transpile options are not available in this build"
5233
+ };
5234
+ }
5178
5235
  if (typeof wasm.transpile_value === "function") {
5179
5236
  return decodeWasmPayload(
5180
5237
  wasm.transpile_value(sql, read, write)
@@ -5307,8 +5364,8 @@ class Polyglot {
5307
5364
  * Per-dialect builds only support same-dialect and to/from Generic transpilation.
5308
5365
  * Use {@link Polyglot.getDialects} to check available dialects.
5309
5366
  */
5310
- transpile(sql, read, write) {
5311
- return transpile(sql, read, write);
5367
+ transpile(sql, read, write, options) {
5368
+ return transpile(sql, read, write, options);
5312
5369
  }
5313
5370
  /**
5314
5371
  * Parse SQL into an AST.
package/dist/manual.js CHANGED
@@ -2654,6 +2654,58 @@ function transpile_value(sql, read_dialect, write_dialect) {
2654
2654
  return takeObject(ret);
2655
2655
  }
2656
2656
 
2657
+ /**
2658
+ * Transpile SQL with explicit options encoded as a JSON string.
2659
+ * @param {string} sql
2660
+ * @param {string} read_dialect
2661
+ * @param {string} write_dialect
2662
+ * @param {string} options_json
2663
+ * @returns {string}
2664
+ */
2665
+ function transpile_with_options(sql, read_dialect, write_dialect, options_json) {
2666
+ let deferred5_0;
2667
+ let deferred5_1;
2668
+ try {
2669
+ const retptr = wasm$2.__wbindgen_add_to_stack_pointer(-16);
2670
+ const ptr0 = passStringToWasm0(sql, wasm$2.__wbindgen_export, wasm$2.__wbindgen_export2);
2671
+ const len0 = WASM_VECTOR_LEN;
2672
+ const ptr1 = passStringToWasm0(read_dialect, wasm$2.__wbindgen_export, wasm$2.__wbindgen_export2);
2673
+ const len1 = WASM_VECTOR_LEN;
2674
+ const ptr2 = passStringToWasm0(write_dialect, wasm$2.__wbindgen_export, wasm$2.__wbindgen_export2);
2675
+ const len2 = WASM_VECTOR_LEN;
2676
+ const ptr3 = passStringToWasm0(options_json, wasm$2.__wbindgen_export, wasm$2.__wbindgen_export2);
2677
+ const len3 = WASM_VECTOR_LEN;
2678
+ wasm$2.transpile_with_options(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
2679
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2680
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2681
+ deferred5_0 = r0;
2682
+ deferred5_1 = r1;
2683
+ return getStringFromWasm0(r0, r1);
2684
+ } finally {
2685
+ wasm$2.__wbindgen_add_to_stack_pointer(16);
2686
+ wasm$2.__wbindgen_export4(deferred5_0, deferred5_1, 1);
2687
+ }
2688
+ }
2689
+
2690
+ /**
2691
+ * Transpile SQL with explicit options and return a structured JS object.
2692
+ * @param {string} sql
2693
+ * @param {string} read_dialect
2694
+ * @param {string} write_dialect
2695
+ * @param {any} options
2696
+ * @returns {any}
2697
+ */
2698
+ function transpile_with_options_value(sql, read_dialect, write_dialect, options) {
2699
+ const ptr0 = passStringToWasm0(sql, wasm$2.__wbindgen_export, wasm$2.__wbindgen_export2);
2700
+ const len0 = WASM_VECTOR_LEN;
2701
+ const ptr1 = passStringToWasm0(read_dialect, wasm$2.__wbindgen_export, wasm$2.__wbindgen_export2);
2702
+ const len1 = WASM_VECTOR_LEN;
2703
+ const ptr2 = passStringToWasm0(write_dialect, wasm$2.__wbindgen_export, wasm$2.__wbindgen_export2);
2704
+ const len2 = WASM_VECTOR_LEN;
2705
+ const ret = wasm$2.transpile_with_options_value(ptr0, len0, ptr1, len1, ptr2, len2, addHeapObject(options));
2706
+ return takeObject(ret);
2707
+ }
2708
+
2657
2709
  /**
2658
2710
  * Validate SQL syntax.
2659
2711
  *
@@ -3686,6 +3738,8 @@ const wasmModule = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty
3686
3738
  tokenize_value,
3687
3739
  transpile: transpile$1,
3688
3740
  transpile_value,
3741
+ transpile_with_options,
3742
+ transpile_with_options_value,
3689
3743
  validate: validate$1,
3690
3744
  validate_with_options,
3691
3745
  validate_with_schema,
@@ -5455,8 +5509,25 @@ async function init$1() {
5455
5509
  function isInitialized$1() {
5456
5510
  return true;
5457
5511
  }
5458
- function transpile(sql, read, write) {
5512
+ function transpile(sql, read, write, options) {
5459
5513
  try {
5514
+ if (options && Object.keys(options).length > 0) {
5515
+ if (typeof wasm.transpile_with_options_value === "function") {
5516
+ return decodeWasmPayload(
5517
+ wasm.transpile_with_options_value(sql, read, write, options)
5518
+ );
5519
+ }
5520
+ if (typeof wasm.transpile_with_options === "function") {
5521
+ return JSON.parse(
5522
+ wasm.transpile_with_options(sql, read, write, JSON.stringify(options))
5523
+ );
5524
+ }
5525
+ return {
5526
+ success: false,
5527
+ sql: void 0,
5528
+ error: "WASM transpile options are not available in this build"
5529
+ };
5530
+ }
5460
5531
  if (typeof wasm.transpile_value === "function") {
5461
5532
  return decodeWasmPayload(
5462
5533
  wasm.transpile_value(sql, read, write)
@@ -5589,8 +5660,8 @@ class Polyglot {
5589
5660
  * Per-dialect builds only support same-dialect and to/from Generic transpilation.
5590
5661
  * Use {@link Polyglot.getDialects} to check available dialects.
5591
5662
  */
5592
- transpile(sql, read, write) {
5593
- return transpile(sql, read, write);
5663
+ transpile(sql, read, write, options) {
5664
+ return transpile(sql, read, write, options);
5594
5665
  }
5595
5666
  /**
5596
5667
  * Parse SQL into an AST.
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polyglot-sql/sdk",
3
- "version": "0.4.4",
3
+ "version": "0.5.0",
4
4
  "description": "SQL dialect translator powered by WebAssembly",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",