@polyglot-sql/sdk 0.4.3 → 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.
@@ -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,
@@ -4884,6 +4924,67 @@ function intersect(left, right) {
4884
4924
  function except(left, right) {
4885
4925
  return left.except(right);
4886
4926
  }
4927
+ function diff(source, target, dialect = "generic", options = {}) {
4928
+ const { deltaOnly = false, f = 0.6, t = 0.6 } = options;
4929
+ const resultJson = diff_sql$1(source, target, dialect, deltaOnly, f, t);
4930
+ return JSON.parse(resultJson);
4931
+ }
4932
+ function hasChanges(edits) {
4933
+ return edits.some((e) => e.type !== "keep");
4934
+ }
4935
+ function changesOnly(edits) {
4936
+ return edits.filter((e) => e.type !== "keep");
4937
+ }
4938
+ function lineage(column, sql, dialect = "generic", trimSelects = false) {
4939
+ const resultJson = lineage_sql$1(sql, column, dialect, trimSelects);
4940
+ return JSON.parse(resultJson);
4941
+ }
4942
+ function lineageWithSchema(column, sql, schema, dialect = "generic", trimSelects = false) {
4943
+ const resultJson = lineage_sql_with_schema$1(
4944
+ sql,
4945
+ column,
4946
+ JSON.stringify(schema),
4947
+ dialect,
4948
+ trimSelects
4949
+ );
4950
+ return JSON.parse(resultJson);
4951
+ }
4952
+ function getSourceTables(column, sql, dialect = "generic") {
4953
+ const resultJson = source_tables$1(sql, column, dialect);
4954
+ return JSON.parse(resultJson);
4955
+ }
4956
+ function normalizeOptions(options) {
4957
+ return {
4958
+ dialect: "generic",
4959
+ datasetMappings: {},
4960
+ ...options
4961
+ };
4962
+ }
4963
+ function openLineageColumnLineage(sql, options) {
4964
+ const resultJson = openlineage_column_lineage$1(
4965
+ sql,
4966
+ JSON.stringify(normalizeOptions(options))
4967
+ );
4968
+ return JSON.parse(resultJson);
4969
+ }
4970
+ function openLineageJobEvent(sql, options) {
4971
+ const resultJson = openlineage_job_event$1(
4972
+ sql,
4973
+ JSON.stringify(normalizeOptions(options))
4974
+ );
4975
+ return JSON.parse(resultJson);
4976
+ }
4977
+ function openLineageRunEvent(sql, options) {
4978
+ const resultJson = openlineage_run_event$1(
4979
+ sql,
4980
+ JSON.stringify(normalizeOptions(options))
4981
+ );
4982
+ return JSON.parse(resultJson);
4983
+ }
4984
+ function plan(sql, dialect = "generic") {
4985
+ const resultJson = plan$2(sql, dialect);
4986
+ return JSON.parse(resultJson);
4987
+ }
4887
4988
  function validateSemantics(expr, options) {
4888
4989
  const errors = [];
4889
4990
  if (getExprType(expr) === "select") {
@@ -5035,67 +5136,6 @@ function validate(sql, dialect = "generic", options = {}) {
5035
5136
  errors: allErrors
5036
5137
  };
5037
5138
  }
5038
- function lineage(column, sql, dialect = "generic", trimSelects = false) {
5039
- const resultJson = lineage_sql$1(sql, column, dialect, trimSelects);
5040
- return JSON.parse(resultJson);
5041
- }
5042
- function lineageWithSchema(column, sql, schema, dialect = "generic", trimSelects = false) {
5043
- const resultJson = lineage_sql_with_schema$1(
5044
- sql,
5045
- column,
5046
- JSON.stringify(schema),
5047
- dialect,
5048
- trimSelects
5049
- );
5050
- return JSON.parse(resultJson);
5051
- }
5052
- function getSourceTables(column, sql, dialect = "generic") {
5053
- const resultJson = source_tables$1(sql, column, dialect);
5054
- return JSON.parse(resultJson);
5055
- }
5056
- function normalizeOptions(options) {
5057
- return {
5058
- dialect: "generic",
5059
- datasetMappings: {},
5060
- ...options
5061
- };
5062
- }
5063
- function openLineageColumnLineage(sql, options) {
5064
- const resultJson = openlineage_column_lineage$1(
5065
- sql,
5066
- JSON.stringify(normalizeOptions(options))
5067
- );
5068
- return JSON.parse(resultJson);
5069
- }
5070
- function openLineageJobEvent(sql, options) {
5071
- const resultJson = openlineage_job_event$1(
5072
- sql,
5073
- JSON.stringify(normalizeOptions(options))
5074
- );
5075
- return JSON.parse(resultJson);
5076
- }
5077
- function openLineageRunEvent(sql, options) {
5078
- const resultJson = openlineage_run_event$1(
5079
- sql,
5080
- JSON.stringify(normalizeOptions(options))
5081
- );
5082
- return JSON.parse(resultJson);
5083
- }
5084
- function diff(source, target, dialect = "generic", options = {}) {
5085
- const { deltaOnly = false, f = 0.6, t = 0.6 } = options;
5086
- const resultJson = diff_sql$1(source, target, dialect, deltaOnly, f, t);
5087
- return JSON.parse(resultJson);
5088
- }
5089
- function hasChanges(edits) {
5090
- return edits.some((e) => e.type !== "keep");
5091
- }
5092
- function changesOnly(edits) {
5093
- return edits.filter((e) => e.type !== "keep");
5094
- }
5095
- function plan(sql, dialect = "generic") {
5096
- const resultJson = plan$2(sql, dialect);
5097
- return JSON.parse(resultJson);
5098
- }
5099
5139
  var Dialect = /* @__PURE__ */ ((Dialect2) => {
5100
5140
  Dialect2["Generic"] = "generic";
5101
5141
  Dialect2["PostgreSQL"] = "postgresql";
@@ -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,
@@ -5158,6 +5212,71 @@ function except(left, right) {
5158
5212
  return left.except(right);
5159
5213
  }
5160
5214
 
5215
+ function diff(source, target, dialect = "generic", options = {}) {
5216
+ const { deltaOnly = false, f = 0.6, t = 0.6 } = options;
5217
+ const resultJson = diff_sql(source, target, dialect, deltaOnly, f, t);
5218
+ return JSON.parse(resultJson);
5219
+ }
5220
+ function hasChanges(edits) {
5221
+ return edits.some((e) => e.type !== "keep");
5222
+ }
5223
+ function changesOnly(edits) {
5224
+ return edits.filter((e) => e.type !== "keep");
5225
+ }
5226
+
5227
+ function lineage(column, sql, dialect = "generic", trimSelects = false) {
5228
+ const resultJson = lineage_sql(sql, column, dialect, trimSelects);
5229
+ return JSON.parse(resultJson);
5230
+ }
5231
+ function lineageWithSchema(column, sql, schema, dialect = "generic", trimSelects = false) {
5232
+ const resultJson = lineage_sql_with_schema(
5233
+ sql,
5234
+ column,
5235
+ JSON.stringify(schema),
5236
+ dialect,
5237
+ trimSelects
5238
+ );
5239
+ return JSON.parse(resultJson);
5240
+ }
5241
+ function getSourceTables(column, sql, dialect = "generic") {
5242
+ const resultJson = source_tables(sql, column, dialect);
5243
+ return JSON.parse(resultJson);
5244
+ }
5245
+
5246
+ function normalizeOptions(options) {
5247
+ return {
5248
+ dialect: "generic",
5249
+ datasetMappings: {},
5250
+ ...options
5251
+ };
5252
+ }
5253
+ function openLineageColumnLineage(sql, options) {
5254
+ const resultJson = openlineage_column_lineage(
5255
+ sql,
5256
+ JSON.stringify(normalizeOptions(options))
5257
+ );
5258
+ return JSON.parse(resultJson);
5259
+ }
5260
+ function openLineageJobEvent(sql, options) {
5261
+ const resultJson = openlineage_job_event(
5262
+ sql,
5263
+ JSON.stringify(normalizeOptions(options))
5264
+ );
5265
+ return JSON.parse(resultJson);
5266
+ }
5267
+ function openLineageRunEvent(sql, options) {
5268
+ const resultJson = openlineage_run_event(
5269
+ sql,
5270
+ JSON.stringify(normalizeOptions(options))
5271
+ );
5272
+ return JSON.parse(resultJson);
5273
+ }
5274
+
5275
+ function plan(sql, dialect = "generic") {
5276
+ const resultJson = plan$1(sql, dialect);
5277
+ return JSON.parse(resultJson);
5278
+ }
5279
+
5161
5280
  function validateSemantics(expr, options) {
5162
5281
  const errors = [];
5163
5282
  if (getExprType(expr) === "select") {
@@ -5313,71 +5432,6 @@ function validate(sql, dialect = "generic", options = {}) {
5313
5432
  };
5314
5433
  }
5315
5434
 
5316
- function lineage(column, sql, dialect = "generic", trimSelects = false) {
5317
- const resultJson = lineage_sql(sql, column, dialect, trimSelects);
5318
- return JSON.parse(resultJson);
5319
- }
5320
- function lineageWithSchema(column, sql, schema, dialect = "generic", trimSelects = false) {
5321
- const resultJson = lineage_sql_with_schema(
5322
- sql,
5323
- column,
5324
- JSON.stringify(schema),
5325
- dialect,
5326
- trimSelects
5327
- );
5328
- return JSON.parse(resultJson);
5329
- }
5330
- function getSourceTables(column, sql, dialect = "generic") {
5331
- const resultJson = source_tables(sql, column, dialect);
5332
- return JSON.parse(resultJson);
5333
- }
5334
-
5335
- function normalizeOptions(options) {
5336
- return {
5337
- dialect: "generic",
5338
- datasetMappings: {},
5339
- ...options
5340
- };
5341
- }
5342
- function openLineageColumnLineage(sql, options) {
5343
- const resultJson = openlineage_column_lineage(
5344
- sql,
5345
- JSON.stringify(normalizeOptions(options))
5346
- );
5347
- return JSON.parse(resultJson);
5348
- }
5349
- function openLineageJobEvent(sql, options) {
5350
- const resultJson = openlineage_job_event(
5351
- sql,
5352
- JSON.stringify(normalizeOptions(options))
5353
- );
5354
- return JSON.parse(resultJson);
5355
- }
5356
- function openLineageRunEvent(sql, options) {
5357
- const resultJson = openlineage_run_event(
5358
- sql,
5359
- JSON.stringify(normalizeOptions(options))
5360
- );
5361
- return JSON.parse(resultJson);
5362
- }
5363
-
5364
- function diff(source, target, dialect = "generic", options = {}) {
5365
- const { deltaOnly = false, f = 0.6, t = 0.6 } = options;
5366
- const resultJson = diff_sql(source, target, dialect, deltaOnly, f, t);
5367
- return JSON.parse(resultJson);
5368
- }
5369
- function hasChanges(edits) {
5370
- return edits.some((e) => e.type !== "keep");
5371
- }
5372
- function changesOnly(edits) {
5373
- return edits.filter((e) => e.type !== "keep");
5374
- }
5375
-
5376
- function plan(sql, dialect = "generic") {
5377
- const resultJson = plan$1(sql, dialect);
5378
- return JSON.parse(resultJson);
5379
- }
5380
-
5381
5435
  var Dialect = /* @__PURE__ */ ((Dialect2) => {
5382
5436
  Dialect2["Generic"] = "generic";
5383
5437
  Dialect2["PostgreSQL"] = "postgresql";
@@ -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.3",
3
+ "version": "0.5.0",
4
4
  "description": "SQL dialect translator powered by WebAssembly",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",