sql-typechecker 0.0.6 → 0.0.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/out/cli.js CHANGED
@@ -2654,15 +2654,15 @@ var require_lib = __commonJS((exports2) => {
2654
2654
  let intervalTextCompiled;
2655
2655
  let intervalIsoCompiled;
2656
2656
  function parseFirst(sql) {
2657
- const first = parse3(sql);
2657
+ const first = parse4(sql);
2658
2658
  return first[0];
2659
2659
  }
2660
2660
  exports3.parseFirst = parseFirst;
2661
2661
  function parseWithComments(sql, options) {
2662
- return lexer_1.trackingComments(() => parse3(sql, options));
2662
+ return lexer_1.trackingComments(() => parse4(sql, options));
2663
2663
  }
2664
2664
  exports3.parseWithComments = parseWithComments;
2665
- function parse3(sql, optEntry) {
2665
+ function parse4(sql, optEntry) {
2666
2666
  if (!sqlCompiled) {
2667
2667
  sqlCompiled = nearley_1.Grammar.fromCompiled(main_ne_1.default);
2668
2668
  }
@@ -2675,7 +2675,7 @@ var require_lib = __commonJS((exports2) => {
2675
2675
  }
2676
2676
  return parsed;
2677
2677
  }
2678
- exports3.parse = parse3;
2678
+ exports3.parse = parse4;
2679
2679
  function parseArrayLiteral(sql) {
2680
2680
  if (!arrayCompiled) {
2681
2681
  arrayCompiled = nearley_1.Grammar.fromCompiled(array_ne_1.default);
@@ -12378,7 +12378,7 @@ ${ctx}
12378
12378
  };
12379
12379
  }
12380
12380
  };
12381
- function parse3(src) {
12381
+ function parse4(src) {
12382
12382
  const cr = [];
12383
12383
  if (src.indexOf("\r") !== -1) {
12384
12384
  src = src.replace(/\r\n?/g, (match, offset2) => {
@@ -12412,7 +12412,7 @@ ${ctx}
12412
12412
  documents.toString = () => documents.join("...\n");
12413
12413
  return documents;
12414
12414
  }
12415
- exports22.parse = parse3;
12415
+ exports22.parse = parse4;
12416
12416
  }
12417
12417
  });
12418
12418
  var require_resolveSeq_d03cb037 = __commonJS2({
@@ -13102,7 +13102,7 @@ ${ctx.indent}`;
13102
13102
  };
13103
13103
  function resolveScalar(str, tags, scalarFallback) {
13104
13104
  for (const {
13105
- format: format2,
13105
+ format: format3,
13106
13106
  test,
13107
13107
  resolve: resolve2
13108
13108
  } of tags) {
@@ -13112,8 +13112,8 @@ ${ctx.indent}`;
13112
13112
  let res = resolve2.apply(null, match);
13113
13113
  if (!(res instanceof Scalar))
13114
13114
  res = new Scalar(res);
13115
- if (format2)
13116
- res.format = format2;
13115
+ if (format3)
13116
+ res.format = format3;
13117
13117
  return res;
13118
13118
  }
13119
13119
  }
@@ -13516,7 +13516,7 @@ ${indent}`);
13516
13516
  return res;
13517
13517
  }
13518
13518
  function stringifyNumber({
13519
- format: format2,
13519
+ format: format3,
13520
13520
  minFractionDigits,
13521
13521
  tag,
13522
13522
  value: value2
@@ -13526,7 +13526,7 @@ ${indent}`);
13526
13526
  if (!isFinite(value2))
13527
13527
  return isNaN(value2) ? ".nan" : value2 < 0 ? "-.inf" : ".inf";
13528
13528
  let n = JSON.stringify(value2);
13529
- if (!format2 && minFractionDigits && (!tag || tag === "tag:yaml.org,2002:float") && /^\d/.test(n)) {
13529
+ if (!format3 && minFractionDigits && (!tag || tag === "tag:yaml.org,2002:float") && /^\d/.test(n)) {
13530
13530
  let i = n.indexOf(".");
13531
13531
  if (i < 0) {
13532
13532
  i = n.length;
@@ -15904,7 +15904,7 @@ ${cbNode.commentBefore}` : cb;
15904
15904
  }
15905
15905
  return doc;
15906
15906
  }
15907
- function parse3(src, options) {
15907
+ function parse4(src, options) {
15908
15908
  const doc = parseDocument(src, options);
15909
15909
  doc.warnings.forEach((warning) => warnings2.warn(warning));
15910
15910
  if (doc.errors.length > 0)
@@ -15920,7 +15920,7 @@ ${cbNode.commentBefore}` : cb;
15920
15920
  createNode,
15921
15921
  defaultOptions: Document$1.defaultOptions,
15922
15922
  Document,
15923
- parse: parse3,
15923
+ parse: parse4,
15924
15924
  parseAllDocuments,
15925
15925
  parseCST: parseCst.parse,
15926
15926
  parseDocument,
@@ -199952,7 +199952,7 @@ ${frame}`;
199952
199952
  return loadParser(opts.parser);
199953
199953
  }
199954
199954
  }
199955
- function parse3(text, opts) {
199955
+ function parse4(text, opts) {
199956
199956
  const parsers = getParsers(opts);
199957
199957
  const parsersForCustomParserApi = Object.defineProperties({}, Object.fromEntries(Object.keys(parsers).map((parserName) => [parserName, {
199958
199958
  enumerable: true,
@@ -199987,7 +199987,7 @@ ${frame}`;
199987
199987
  }
199988
199988
  }
199989
199989
  module22.exports = {
199990
- parse: parse3,
199990
+ parse: parse4,
199991
199991
  resolveParser
199992
199992
  };
199993
199993
  }
@@ -201999,7 +201999,7 @@ ${frame}`;
201999
201999
  let padded = zeros(startString) || zeros(endString) || zeros(stepString);
202000
202000
  let maxLen = padded ? Math.max(startString.length, endString.length, stepString.length) : 0;
202001
202001
  let toNumber = padded === false && stringify(start, end, options) === false;
202002
- let format2 = options.transform || transform(toNumber);
202002
+ let format3 = options.transform || transform(toNumber);
202003
202003
  if (options.toRegex && step === 1) {
202004
202004
  return toRange(toMaxLen(start, maxLen), toMaxLen(end, maxLen), true, options);
202005
202005
  }
@@ -202014,7 +202014,7 @@ ${frame}`;
202014
202014
  if (options.toRegex === true && step > 1) {
202015
202015
  push(a);
202016
202016
  } else {
202017
- range.push(pad(format2(a, index), maxLen, toNumber));
202017
+ range.push(pad(format3(a, index), maxLen, toNumber));
202018
202018
  }
202019
202019
  a = descending ? a - step : a + step;
202020
202020
  index++;
@@ -202030,7 +202030,7 @@ ${frame}`;
202030
202030
  if (!isNumber(start) && start.length > 1 || !isNumber(end) && end.length > 1) {
202031
202031
  return invalidRange(start, end, options);
202032
202032
  }
202033
- let format2 = options.transform || ((val) => String.fromCharCode(val));
202033
+ let format3 = options.transform || ((val) => String.fromCharCode(val));
202034
202034
  let a = `${start}`.charCodeAt(0);
202035
202035
  let b = `${end}`.charCodeAt(0);
202036
202036
  let descending = a > b;
@@ -202042,7 +202042,7 @@ ${frame}`;
202042
202042
  let range = [];
202043
202043
  let index = 0;
202044
202044
  while (descending ? a >= b : a <= b) {
202045
- range.push(format2(a, index));
202045
+ range.push(format3(a, index));
202046
202046
  a = descending ? a - step : a + step;
202047
202047
  index++;
202048
202048
  }
@@ -202306,7 +202306,7 @@ ${frame}`;
202306
202306
  CHAR_NO_BREAK_SPACE,
202307
202307
  CHAR_ZERO_WIDTH_NOBREAK_SPACE
202308
202308
  } = require_constants2();
202309
- var parse3 = (input, options = {}) => {
202309
+ var parse4 = (input, options = {}) => {
202310
202310
  if (typeof input !== "string") {
202311
202311
  throw new TypeError("Expected a string");
202312
202312
  }
@@ -202568,7 +202568,7 @@ ${frame}`;
202568
202568
  });
202569
202569
  return ast;
202570
202570
  };
202571
- module22.exports = parse3;
202571
+ module22.exports = parse4;
202572
202572
  }
202573
202573
  });
202574
202574
  var require_braces = __commonJS22({
@@ -202577,7 +202577,7 @@ ${frame}`;
202577
202577
  var stringify = require_stringify();
202578
202578
  var compile = require_compile();
202579
202579
  var expand = require_expand();
202580
- var parse3 = require_parse();
202580
+ var parse4 = require_parse();
202581
202581
  var braces = (input, options = {}) => {
202582
202582
  let output = [];
202583
202583
  if (Array.isArray(input)) {
@@ -202597,7 +202597,7 @@ ${frame}`;
202597
202597
  }
202598
202598
  return output;
202599
202599
  };
202600
- braces.parse = (input, options = {}) => parse3(input, options);
202600
+ braces.parse = (input, options = {}) => parse4(input, options);
202601
202601
  braces.stringify = (input, options = {}) => {
202602
202602
  if (typeof input === "string") {
202603
202603
  return stringify(braces.parse(input, options), options);
@@ -203205,7 +203205,7 @@ ${frame}`;
203205
203205
  var syntaxError = (type, char) => {
203206
203206
  return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
203207
203207
  };
203208
- var parse3 = (input, options) => {
203208
+ var parse4 = (input, options) => {
203209
203209
  if (typeof input !== "string") {
203210
203210
  throw new TypeError("Expected a string");
203211
203211
  }
@@ -203371,7 +203371,7 @@ ${frame}`;
203371
203371
  output = token.close = `)$))${extglobStar}`;
203372
203372
  }
203373
203373
  if (token.inner.includes("*") && (rest = remaining()) && /^\.[^\\/.]+$/.test(rest)) {
203374
- const expression = parse3(rest, Object.assign(Object.assign({}, options), {}, {
203374
+ const expression = parse4(rest, Object.assign(Object.assign({}, options), {}, {
203375
203375
  fastpaths: false
203376
203376
  })).output;
203377
203377
  output = token.close = `)${expression})${extglobStar})`;
@@ -204024,7 +204024,7 @@ ${frame}`;
204024
204024
  }
204025
204025
  return state;
204026
204026
  };
204027
- parse3.fastpaths = (input, options) => {
204027
+ parse4.fastpaths = (input, options) => {
204028
204028
  const opts = Object.assign({}, options);
204029
204029
  const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
204030
204030
  const len = input.length;
@@ -204096,7 +204096,7 @@ ${frame}`;
204096
204096
  }
204097
204097
  return source;
204098
204098
  };
204099
- module22.exports = parse3;
204099
+ module22.exports = parse4;
204100
204100
  }
204101
204101
  });
204102
204102
  var require_picomatch = __commonJS22({
@@ -204104,7 +204104,7 @@ ${frame}`;
204104
204104
  "use strict";
204105
204105
  var path2 = require("path");
204106
204106
  var scan = require_scan();
204107
- var parse3 = require_parse2();
204107
+ var parse4 = require_parse2();
204108
204108
  var utils = require_utils3();
204109
204109
  var constants = require_constants3();
204110
204110
  var isObject = (val) => val && typeof val === "object" && !Array.isArray(val);
@@ -204196,11 +204196,11 @@ ${frame}`;
204196
204196
  };
204197
204197
  }
204198
204198
  const opts = options || {};
204199
- const format2 = opts.format || (posix ? utils.toPosixSlashes : null);
204199
+ const format3 = opts.format || (posix ? utils.toPosixSlashes : null);
204200
204200
  let match = input === glob;
204201
- let output = match && format2 ? format2(input) : input;
204201
+ let output = match && format3 ? format3(input) : input;
204202
204202
  if (match === false) {
204203
- output = format2 ? format2(input) : input;
204203
+ output = format3 ? format3(input) : input;
204204
204204
  match = output === glob;
204205
204205
  }
204206
204206
  if (match === false || opts.capture === true) {
@@ -204224,7 +204224,7 @@ ${frame}`;
204224
204224
  picomatch.parse = (pattern, options) => {
204225
204225
  if (Array.isArray(pattern))
204226
204226
  return pattern.map((p) => picomatch.parse(p, options));
204227
- return parse3(pattern, Object.assign(Object.assign({}, options), {}, {
204227
+ return parse4(pattern, Object.assign(Object.assign({}, options), {}, {
204228
204228
  fastpaths: false
204229
204229
  }));
204230
204230
  };
@@ -204255,10 +204255,10 @@ ${frame}`;
204255
204255
  fastpaths: true
204256
204256
  };
204257
204257
  if (options.fastpaths !== false && (input[0] === "." || input[0] === "*")) {
204258
- parsed.output = parse3.fastpaths(input, options);
204258
+ parsed.output = parse4.fastpaths(input, options);
204259
204259
  }
204260
204260
  if (!parsed.output) {
204261
- parsed = parse3(input, options);
204261
+ parsed = parse4(input, options);
204262
204262
  }
204263
204263
  return picomatch.compileRe(parsed, options, returnOutput, returnState);
204264
204264
  };
@@ -206075,10 +206075,10 @@ ${frame}`;
206075
206075
  var require_load_toml = __commonJS22({
206076
206076
  "src/utils/load-toml.js"(exports22, module22) {
206077
206077
  "use strict";
206078
- var parse3 = require_parse_string();
206078
+ var parse4 = require_parse_string();
206079
206079
  module22.exports = function(filePath, content) {
206080
206080
  try {
206081
- return parse3(content);
206081
+ return parse4(content);
206082
206082
  } catch (error) {
206083
206083
  error.message = `TOML Error in ${filePath}:
206084
206084
  ${error.message}`;
@@ -206128,7 +206128,7 @@ ${error.message}`;
206128
206128
  var token;
206129
206129
  var key;
206130
206130
  var root;
206131
- module22.exports = function parse3(text, reviver) {
206131
+ module22.exports = function parse4(text, reviver) {
206132
206132
  source = String(text);
206133
206133
  parseState = "start";
206134
206134
  stack = [];
@@ -207157,10 +207157,10 @@ ${error.message}`;
207157
207157
  });
207158
207158
  var require_lib6 = __commonJS22({
207159
207159
  "node_modules/json5/lib/index.js"(exports22, module22) {
207160
- var parse3 = require_parse3();
207160
+ var parse4 = require_parse3();
207161
207161
  var stringify = require_stringify2();
207162
207162
  var JSON5 = {
207163
- parse: parse3,
207163
+ parse: parse4,
207164
207164
  stringify
207165
207165
  };
207166
207166
  module22.exports = JSON5;
@@ -207170,11 +207170,11 @@ ${error.message}`;
207170
207170
  "src/utils/load-json5.js"(exports22, module22) {
207171
207171
  "use strict";
207172
207172
  var {
207173
- parse: parse3
207173
+ parse: parse4
207174
207174
  } = require_lib6();
207175
207175
  module22.exports = function(filePath, content) {
207176
207176
  try {
207177
- return parse3(content);
207177
+ return parse4(content);
207178
207178
  } catch (error) {
207179
207179
  error.message = `JSON5 Error in ${filePath}:
207180
207180
  ${error.message}`;
@@ -207286,7 +207286,7 @@ ${error.message}`;
207286
207286
  var require_node_modules_paths = __commonJS22({
207287
207287
  "node_modules/resolve/lib/node-modules-paths.js"(exports22, module22) {
207288
207288
  var path2 = require("path");
207289
- var parse3 = path2.parse || require_path_parse();
207289
+ var parse4 = path2.parse || require_path_parse();
207290
207290
  var getNodeModulesDirs = function getNodeModulesDirs2(absoluteStart, modules) {
207291
207291
  var prefix = "/";
207292
207292
  if (/^([A-Za-z]:)/.test(absoluteStart)) {
@@ -207295,10 +207295,10 @@ ${error.message}`;
207295
207295
  prefix = "\\\\";
207296
207296
  }
207297
207297
  var paths = [absoluteStart];
207298
- var parsed = parse3(absoluteStart);
207298
+ var parsed = parse4(absoluteStart);
207299
207299
  while (parsed.dir !== paths[paths.length - 1]) {
207300
207300
  paths.push(parsed.dir);
207301
- parsed = parse3(parsed.dir);
207301
+ parsed = parse4(parsed.dir);
207302
207302
  }
207303
207303
  return paths.reduce(function(dirs, aPath) {
207304
207304
  return dirs.concat(modules.map(function(moduleDir) {
@@ -209750,9 +209750,9 @@ ${fromBody}`;
209750
209750
  }
209751
209751
  return ret;
209752
209752
  }
209753
- Minimatch.prototype.parse = parse3;
209753
+ Minimatch.prototype.parse = parse4;
209754
209754
  var SUBPARSE = {};
209755
- function parse3(pattern, isSub) {
209755
+ function parse4(pattern, isSub) {
209756
209756
  var options = this.options;
209757
209757
  if (!options.noglobstar && pattern === "**")
209758
209758
  return GLOBSTAR;
@@ -210241,7 +210241,7 @@ ${fromBody}`;
210241
210241
  param: /^\s*([\w\.\-\_]+)\s*[=:]\s*(.*?)\s*([#;].*)?$/,
210242
210242
  comment: /^\s*[#;].*$/
210243
210243
  };
210244
- function parse3(file) {
210244
+ function parse4(file) {
210245
210245
  return __awaiter2(this, void 0, void 0, function() {
210246
210246
  return __generator2(this, function(_a) {
210247
210247
  return [2, new Promise(function(resolve2, reject) {
@@ -210256,7 +210256,7 @@ ${fromBody}`;
210256
210256
  });
210257
210257
  });
210258
210258
  }
210259
- exports22.parse = parse3;
210259
+ exports22.parse = parse4;
210260
210260
  function parseSync(file) {
210261
210261
  return parseString(fs2.readFileSync(file, "utf8"));
210262
210262
  }
@@ -210673,7 +210673,7 @@ ${fromBody}`;
210673
210673
  return parseFromConfigs(getConfigsForFiles(files), resolvedFilePath, processedOptions);
210674
210674
  }
210675
210675
  exports22.parseFromFilesSync = parseFromFilesSync;
210676
- function parse3(_filepath, _options) {
210676
+ function parse4(_filepath, _options) {
210677
210677
  if (_options === void 0) {
210678
210678
  _options = {};
210679
210679
  }
@@ -210688,7 +210688,7 @@ ${fromBody}`;
210688
210688
  });
210689
210689
  });
210690
210690
  }
210691
- exports22.parse = parse3;
210691
+ exports22.parse = parse4;
210692
210692
  function parseSync(_filepath, _options) {
210693
210693
  if (_options === void 0) {
210694
210694
  _options = {};
@@ -210790,7 +210790,7 @@ ${fromBody}`;
210790
210790
  var jsonStringifyMem = (fn) => mem2(fn, {
210791
210791
  cacheKey: JSON.stringify
210792
210792
  });
210793
- var maybeParse = (filePath, parse3) => filePath && parse3(filePath, {
210793
+ var maybeParse = (filePath, parse4) => filePath && parse4(filePath, {
210794
210794
  root: findProjectRoot(path2.dirname(path2.resolve(filePath)))
210795
210795
  });
210796
210796
  var editorconfigAsyncNoCache = async (filePath) => editorConfigToPrettier(await maybeParse(filePath, editorconfig.parse));
@@ -215099,7 +215099,7 @@ ${fromBody}`;
215099
215099
  var {
215100
215100
  escapeTemplateCharacters
215101
215101
  } = require_template_literal();
215102
- function format2(path2, print, textToDoc) {
215102
+ function format3(path2, print, textToDoc) {
215103
215103
  const node = path2.getValue();
215104
215104
  let text = node.quasis[0].value.raw.replace(/((?:\\\\)*)\\`/g, (_, backslashes) => "\\".repeat(backslashes.length / 2) + "`");
215105
215105
  const indentation = getIndentation(text);
@@ -215119,7 +215119,7 @@ ${fromBody}`;
215119
215119
  const firstMatchedIndent = str.match(/^([^\S\n]*)\S/m);
215120
215120
  return firstMatchedIndent === null ? "" : firstMatchedIndent[1];
215121
215121
  }
215122
- module22.exports = format2;
215122
+ module22.exports = format3;
215123
215123
  }
215124
215124
  });
215125
215125
  var require_css = __commonJS22({
@@ -215143,7 +215143,7 @@ ${fromBody}`;
215143
215143
  var {
215144
215144
  printTemplateExpressions
215145
215145
  } = require_template_literal();
215146
- function format2(path2, print, textToDoc) {
215146
+ function format3(path2, print, textToDoc) {
215147
215147
  const node = path2.getValue();
215148
215148
  const rawQuasis = node.quasis.map((q) => q.value.raw);
215149
215149
  let placeholderID = 0;
@@ -215186,7 +215186,7 @@ ${fromBody}`;
215186
215186
  });
215187
215187
  return expressionDocs.length === replaceCounter ? newDoc : null;
215188
215188
  }
215189
- module22.exports = format2;
215189
+ module22.exports = format3;
215190
215190
  }
215191
215191
  });
215192
215192
  var require_graphql = __commonJS22({
@@ -215203,7 +215203,7 @@ ${fromBody}`;
215203
215203
  escapeTemplateCharacters,
215204
215204
  printTemplateExpressions
215205
215205
  } = require_template_literal();
215206
- function format2(path2, print, textToDoc) {
215206
+ function format3(path2, print, textToDoc) {
215207
215207
  const node = path2.getValue();
215208
215208
  const numQuasis = node.quasis.length;
215209
215209
  if (numQuasis === 1 && node.quasis[0].value.raw.trim() === "") {
@@ -215270,7 +215270,7 @@ ${fromBody}`;
215270
215270
  }
215271
215271
  return parts.length === 0 ? null : join2(hardline, parts);
215272
215272
  }
215273
- module22.exports = format2;
215273
+ module22.exports = format3;
215274
215274
  }
215275
215275
  });
215276
215276
  var require_html = __commonJS22({
@@ -215292,7 +215292,7 @@ ${fromBody}`;
215292
215292
  uncookTemplateElementValue
215293
215293
  } = require_template_literal();
215294
215294
  var htmlTemplateLiteralCounter = 0;
215295
- function format2(path2, print, textToDoc, options, {
215295
+ function format3(path2, print, textToDoc, options, {
215296
215296
  parser
215297
215297
  }) {
215298
215298
  const node = path2.getValue();
@@ -215345,7 +215345,7 @@ ${fromBody}`;
215345
215345
  }
215346
215346
  return group(["`", leadingWhitespace, topLevelCount > 1 ? indent(group(contentDoc)) : group(contentDoc), trailingWhitespace, "`"]);
215347
215347
  }
215348
- module22.exports = format2;
215348
+ module22.exports = format3;
215349
215349
  }
215350
215350
  });
215351
215351
  var require_embed = __commonJS22({
@@ -215595,7 +215595,7 @@ ${fromBody}`;
215595
215595
  value: true
215596
215596
  });
215597
215597
  exports22.extract = extract;
215598
- exports22.parse = parse3;
215598
+ exports22.parse = parse4;
215599
215599
  exports22.parseWithComments = parseWithComments;
215600
215600
  exports22.print = print;
215601
215601
  exports22.strip = strip;
@@ -215635,7 +215635,7 @@ ${fromBody}`;
215635
215635
  const match = contents.match(docblockRe);
215636
215636
  return match && match[0] ? contents.substring(match[0].length) : contents;
215637
215637
  }
215638
- function parse3(docblock) {
215638
+ function parse4(docblock) {
215639
215639
  return parseWithComments(docblock).pragmas;
215640
215640
  }
215641
215641
  function parseWithComments(docblock) {
@@ -222465,7 +222465,7 @@ ${fromBody}`;
222465
222465
  "src/utils/front-matter/parse.js"(exports22, module22) {
222466
222466
  "use strict";
222467
222467
  var frontMatterRegex = new RegExp("^(?<startDelimiter>-{3}|\\+{3})(?<language>[^\\n]*)\\n(?:|(?<value>.*?)\\n)(?<endDelimiter>\\k<startDelimiter>|\\.{3})[^\\S\\n]*(?:\\n|$)", "s");
222468
- function parse3(text) {
222468
+ function parse4(text) {
222469
222469
  const match = text.match(frontMatterRegex);
222470
222470
  if (!match) {
222471
222471
  return {
@@ -222501,7 +222501,7 @@ ${fromBody}`;
222501
222501
  content: raw.replace(/[^\n]/g, " ") + text.slice(raw.length)
222502
222502
  };
222503
222503
  }
222504
- module22.exports = parse3;
222504
+ module22.exports = parse4;
222505
222505
  }
222506
222506
  });
222507
222507
  var require_pragma2 = __commonJS22({
@@ -237248,7 +237248,7 @@ async function go() {
237248
237248
  const outArgs = findInArgs({argv: process.argv, flags: ["-o", "--out"]});
237249
237249
  const outArg = outArgs[0];
237250
237250
  if (!outArg) {
237251
- throw new Error("Please provide -o/--out parameter");
237251
+ throw new Error("Please provide -o/--out parameter for the domain and crud files");
237252
237252
  }
237253
237253
  const dirs = findInArgs({argv: process.argv, flags: ["-d", "--dir"]});
237254
237254
  const files = findInArgs({argv: process.argv, flags: ["-f", "--file"]});
@@ -237258,42 +237258,75 @@ async function go() {
237258
237258
  }
237259
237259
  const allStatements = [];
237260
237260
  for (let sqlFile of allSqlFiles) {
237261
- console.log("Processing file ${sqlFile}");
237261
+ console.log(`Processing file ${sqlFile}`);
237262
237262
  const fileContents = await fs.readFile(sqlFile, "utf-8");
237263
237263
  const statements = import_pgsql_ast_parser2.parse(fileContents, {
237264
237264
  locationTracking: true
237265
237265
  });
237266
- allStatements.push(...statements);
237266
+ allStatements.push({fileName: sqlFile, statements});
237267
237267
  }
237268
237268
  console.log(`Processing ${allStatements.length} statements`);
237269
- const g = parseSetupScripts(allStatements);
237270
- const createFunctionStatements = allStatements.filter(isCreateFunctionStatement);
237271
- await fs.mkdir(path.resolve(process.cwd(), outArg), {recursive: true});
237272
- const functionsOutFile = await prepOutFile(path.join(path.resolve(process.cwd(), outArg), "functions.ts"));
237269
+ const g = parseSetupScripts(allStatements.flatMap((f) => f.statements));
237270
+ const outDir = path.resolve(process.cwd(), outArg);
237271
+ await fs.mkdir(outDir, {recursive: true});
237272
+ const domainFile = path.format({
237273
+ dir: outDir,
237274
+ name: "domains",
237275
+ ext: ".ts"
237276
+ });
237277
+ await prepOutFile(domainFile);
237273
237278
  for (let dom of g.domains) {
237274
- await fs.appendFile(functionsOutFile, genDomain(dom) + "\n", "utf-8");
237279
+ await fs.appendFile(domainFile, genDomain(dom) + "\n", "utf-8");
237275
237280
  }
237276
- await fs.appendFile(functionsOutFile, `
237281
+ await fs.appendFile(domainFile, `
237277
237282
  `, "utf-8");
237278
- for (let st of createFunctionStatements) {
237279
- try {
237280
- const res = doCreateFunction(g, {decls: [], froms: []}, st);
237281
- const writing = prettier.format(functionToTypescript(res), {
237282
- parser: "typescript"
237283
- });
237284
- await fs.appendFile(functionsOutFile, writing, "utf-8");
237285
- } catch (err) {
237286
- console.error(err instanceof Error ? err.message : JSON.stringify(err));
237287
- return;
237288
- }
237289
- }
237290
- const crudDir = path.join(path.resolve(process.cwd(), outArg), "crud");
237291
- await fs.mkdir(crudDir, {recursive: true});
237283
+ const tablesIndexFile = path.format({
237284
+ dir: outDir,
237285
+ name: "tables",
237286
+ ext: ".ts"
237287
+ });
237288
+ await fs.mkdir(path.join(outDir, "tables"), {recursive: true});
237289
+ await prepOutFile(tablesIndexFile);
237292
237290
  for (let table of g.tables) {
237293
- const tableOutFile = await prepOutFile(path.join(crudDir, table.name.name + ".ts"));
237291
+ const tableOutFile = path.format({
237292
+ dir: path.join(outDir, "tables"),
237293
+ name: table.name.name,
237294
+ ext: ".ts"
237295
+ });
237296
+ await prepOutFile(tableOutFile);
237294
237297
  const text = genCrudOperations(table);
237298
+ await fs.appendFile(tableOutFile, mkImportDomainsStatement(g.domains, tableOutFile, domainFile), "utf8");
237295
237299
  await fs.appendFile(tableOutFile, prettier.format(text, {parser: "typescript"}), "utf-8");
237300
+ await fs.appendFile(tablesIndexFile, `export * as ${table.name.name} from "./tables/${table.name.name}";
237301
+ `);
237296
237302
  }
237303
+ for (let f of allStatements) {
237304
+ const createFunctionStatements = f.statements.filter(isCreateFunctionStatement);
237305
+ const fParsed = path.parse(f.fileName);
237306
+ const outFileName = path.format({
237307
+ dir: fParsed.dir,
237308
+ name: fParsed.name,
237309
+ ext: ".ts"
237310
+ });
237311
+ const functionsOutFile = await prepOutFile(outFileName);
237312
+ await fs.appendFile(outFileName, mkImportDomainsStatement(g.domains, outFileName, domainFile), "utf8");
237313
+ console.log(`Writing functions to ${outFileName}`);
237314
+ for (let st of createFunctionStatements) {
237315
+ try {
237316
+ const res = doCreateFunction(g, {decls: [], froms: []}, st);
237317
+ const writing = prettier.format(functionToTypescript(res), {
237318
+ parser: "typescript"
237319
+ });
237320
+ await fs.appendFile(functionsOutFile, writing, "utf-8");
237321
+ } catch (err) {
237322
+ console.error(err instanceof Error ? err.message : JSON.stringify(err));
237323
+ return;
237324
+ }
237325
+ }
237326
+ await fs.appendFile(functionsOutFile, `
237327
+ `, "utf-8");
237328
+ }
237329
+ console.log("Done!");
237297
237330
  }
237298
237331
  async function prepOutFile(path2) {
237299
237332
  await fs.writeFile(path2, getImports() + "\n", "utf-8");
@@ -237310,4 +237343,16 @@ function findInArgs(opts) {
237310
237343
  }
237311
237344
  return res;
237312
237345
  }
237346
+ function mkImportDomainsStatement(domains, thisFile, domainFile) {
237347
+ const p = path.relative(path.dirname(thisFile), path.dirname(domainFile));
237348
+ const formatted = path.format({
237349
+ dir: p,
237350
+ name: "domains",
237351
+ ext: ""
237352
+ });
237353
+ const doms = domains.map((d) => d.name.name).join(", ");
237354
+ return `import {${doms}} from "${formatted}";
237355
+
237356
+ `;
237357
+ }
237313
237358
  //# sourceMappingURL=cli.js.map