sql-typechecker 0.0.7 → 0.0.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/out/cli.js +133 -88
- package/out/cli.js.map +2 -2
- package/out/typeparsers.js +1 -1
- package/out/typeparsers.js.map +2 -2
- package/package.json +5 -5
- package/.envrc +0 -2
- package/esbuild.js +0 -12
- package/index.ts +0 -22
- package/sample/nested/sample2.sql +0 -26
- package/sample/out.ts +0 -70
- package/sample/sample1.sql +0 -20
- package/school/sql.sql +0 -1055
- package/school/test.ts +0 -27
- package/shell.nix +0 -16
- package/src/builtincasts.ts +0 -277
- package/src/builtinoperators.ts +0 -5144
- package/src/builtinunaryoperators.ts +0 -291
- package/src/cli.ts +0 -144
- package/src/codegen.ts +0 -384
- package/src/readme.md +0 -23
- package/src/typecheck.ts +0 -2143
- package/src/typeparsers.ts +0 -33
- package/template1.sql +0 -43
- package/test/test.ts +0 -1378
- package/tsconfig.json +0 -23
package/out/cli.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
1
2
|
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getProtoOf = Object.getPrototypeOf;
|
|
@@ -2654,15 +2655,15 @@ var require_lib = __commonJS((exports2) => {
|
|
|
2654
2655
|
let intervalTextCompiled;
|
|
2655
2656
|
let intervalIsoCompiled;
|
|
2656
2657
|
function parseFirst(sql) {
|
|
2657
|
-
const first =
|
|
2658
|
+
const first = parse4(sql);
|
|
2658
2659
|
return first[0];
|
|
2659
2660
|
}
|
|
2660
2661
|
exports3.parseFirst = parseFirst;
|
|
2661
2662
|
function parseWithComments(sql, options) {
|
|
2662
|
-
return lexer_1.trackingComments(() =>
|
|
2663
|
+
return lexer_1.trackingComments(() => parse4(sql, options));
|
|
2663
2664
|
}
|
|
2664
2665
|
exports3.parseWithComments = parseWithComments;
|
|
2665
|
-
function
|
|
2666
|
+
function parse4(sql, optEntry) {
|
|
2666
2667
|
if (!sqlCompiled) {
|
|
2667
2668
|
sqlCompiled = nearley_1.Grammar.fromCompiled(main_ne_1.default);
|
|
2668
2669
|
}
|
|
@@ -2675,7 +2676,7 @@ var require_lib = __commonJS((exports2) => {
|
|
|
2675
2676
|
}
|
|
2676
2677
|
return parsed;
|
|
2677
2678
|
}
|
|
2678
|
-
exports3.parse =
|
|
2679
|
+
exports3.parse = parse4;
|
|
2679
2680
|
function parseArrayLiteral(sql) {
|
|
2680
2681
|
if (!arrayCompiled) {
|
|
2681
2682
|
arrayCompiled = nearley_1.Grammar.fromCompiled(array_ne_1.default);
|
|
@@ -12378,7 +12379,7 @@ ${ctx}
|
|
|
12378
12379
|
};
|
|
12379
12380
|
}
|
|
12380
12381
|
};
|
|
12381
|
-
function
|
|
12382
|
+
function parse4(src) {
|
|
12382
12383
|
const cr = [];
|
|
12383
12384
|
if (src.indexOf("\r") !== -1) {
|
|
12384
12385
|
src = src.replace(/\r\n?/g, (match, offset2) => {
|
|
@@ -12412,7 +12413,7 @@ ${ctx}
|
|
|
12412
12413
|
documents.toString = () => documents.join("...\n");
|
|
12413
12414
|
return documents;
|
|
12414
12415
|
}
|
|
12415
|
-
exports22.parse =
|
|
12416
|
+
exports22.parse = parse4;
|
|
12416
12417
|
}
|
|
12417
12418
|
});
|
|
12418
12419
|
var require_resolveSeq_d03cb037 = __commonJS2({
|
|
@@ -13102,7 +13103,7 @@ ${ctx.indent}`;
|
|
|
13102
13103
|
};
|
|
13103
13104
|
function resolveScalar(str, tags, scalarFallback) {
|
|
13104
13105
|
for (const {
|
|
13105
|
-
format:
|
|
13106
|
+
format: format3,
|
|
13106
13107
|
test,
|
|
13107
13108
|
resolve: resolve2
|
|
13108
13109
|
} of tags) {
|
|
@@ -13112,8 +13113,8 @@ ${ctx.indent}`;
|
|
|
13112
13113
|
let res = resolve2.apply(null, match);
|
|
13113
13114
|
if (!(res instanceof Scalar))
|
|
13114
13115
|
res = new Scalar(res);
|
|
13115
|
-
if (
|
|
13116
|
-
res.format =
|
|
13116
|
+
if (format3)
|
|
13117
|
+
res.format = format3;
|
|
13117
13118
|
return res;
|
|
13118
13119
|
}
|
|
13119
13120
|
}
|
|
@@ -13516,7 +13517,7 @@ ${indent}`);
|
|
|
13516
13517
|
return res;
|
|
13517
13518
|
}
|
|
13518
13519
|
function stringifyNumber({
|
|
13519
|
-
format:
|
|
13520
|
+
format: format3,
|
|
13520
13521
|
minFractionDigits,
|
|
13521
13522
|
tag,
|
|
13522
13523
|
value: value2
|
|
@@ -13526,7 +13527,7 @@ ${indent}`);
|
|
|
13526
13527
|
if (!isFinite(value2))
|
|
13527
13528
|
return isNaN(value2) ? ".nan" : value2 < 0 ? "-.inf" : ".inf";
|
|
13528
13529
|
let n = JSON.stringify(value2);
|
|
13529
|
-
if (!
|
|
13530
|
+
if (!format3 && minFractionDigits && (!tag || tag === "tag:yaml.org,2002:float") && /^\d/.test(n)) {
|
|
13530
13531
|
let i = n.indexOf(".");
|
|
13531
13532
|
if (i < 0) {
|
|
13532
13533
|
i = n.length;
|
|
@@ -15904,7 +15905,7 @@ ${cbNode.commentBefore}` : cb;
|
|
|
15904
15905
|
}
|
|
15905
15906
|
return doc;
|
|
15906
15907
|
}
|
|
15907
|
-
function
|
|
15908
|
+
function parse4(src, options) {
|
|
15908
15909
|
const doc = parseDocument(src, options);
|
|
15909
15910
|
doc.warnings.forEach((warning) => warnings2.warn(warning));
|
|
15910
15911
|
if (doc.errors.length > 0)
|
|
@@ -15920,7 +15921,7 @@ ${cbNode.commentBefore}` : cb;
|
|
|
15920
15921
|
createNode,
|
|
15921
15922
|
defaultOptions: Document$1.defaultOptions,
|
|
15922
15923
|
Document,
|
|
15923
|
-
parse:
|
|
15924
|
+
parse: parse4,
|
|
15924
15925
|
parseAllDocuments,
|
|
15925
15926
|
parseCST: parseCst.parse,
|
|
15926
15927
|
parseDocument,
|
|
@@ -199952,7 +199953,7 @@ ${frame}`;
|
|
|
199952
199953
|
return loadParser(opts.parser);
|
|
199953
199954
|
}
|
|
199954
199955
|
}
|
|
199955
|
-
function
|
|
199956
|
+
function parse4(text, opts) {
|
|
199956
199957
|
const parsers = getParsers(opts);
|
|
199957
199958
|
const parsersForCustomParserApi = Object.defineProperties({}, Object.fromEntries(Object.keys(parsers).map((parserName) => [parserName, {
|
|
199958
199959
|
enumerable: true,
|
|
@@ -199987,7 +199988,7 @@ ${frame}`;
|
|
|
199987
199988
|
}
|
|
199988
199989
|
}
|
|
199989
199990
|
module22.exports = {
|
|
199990
|
-
parse:
|
|
199991
|
+
parse: parse4,
|
|
199991
199992
|
resolveParser
|
|
199992
199993
|
};
|
|
199993
199994
|
}
|
|
@@ -201999,7 +202000,7 @@ ${frame}`;
|
|
|
201999
202000
|
let padded = zeros(startString) || zeros(endString) || zeros(stepString);
|
|
202000
202001
|
let maxLen = padded ? Math.max(startString.length, endString.length, stepString.length) : 0;
|
|
202001
202002
|
let toNumber = padded === false && stringify(start, end, options) === false;
|
|
202002
|
-
let
|
|
202003
|
+
let format3 = options.transform || transform(toNumber);
|
|
202003
202004
|
if (options.toRegex && step === 1) {
|
|
202004
202005
|
return toRange(toMaxLen(start, maxLen), toMaxLen(end, maxLen), true, options);
|
|
202005
202006
|
}
|
|
@@ -202014,7 +202015,7 @@ ${frame}`;
|
|
|
202014
202015
|
if (options.toRegex === true && step > 1) {
|
|
202015
202016
|
push(a);
|
|
202016
202017
|
} else {
|
|
202017
|
-
range.push(pad(
|
|
202018
|
+
range.push(pad(format3(a, index), maxLen, toNumber));
|
|
202018
202019
|
}
|
|
202019
202020
|
a = descending ? a - step : a + step;
|
|
202020
202021
|
index++;
|
|
@@ -202030,7 +202031,7 @@ ${frame}`;
|
|
|
202030
202031
|
if (!isNumber(start) && start.length > 1 || !isNumber(end) && end.length > 1) {
|
|
202031
202032
|
return invalidRange(start, end, options);
|
|
202032
202033
|
}
|
|
202033
|
-
let
|
|
202034
|
+
let format3 = options.transform || ((val) => String.fromCharCode(val));
|
|
202034
202035
|
let a = `${start}`.charCodeAt(0);
|
|
202035
202036
|
let b = `${end}`.charCodeAt(0);
|
|
202036
202037
|
let descending = a > b;
|
|
@@ -202042,7 +202043,7 @@ ${frame}`;
|
|
|
202042
202043
|
let range = [];
|
|
202043
202044
|
let index = 0;
|
|
202044
202045
|
while (descending ? a >= b : a <= b) {
|
|
202045
|
-
range.push(
|
|
202046
|
+
range.push(format3(a, index));
|
|
202046
202047
|
a = descending ? a - step : a + step;
|
|
202047
202048
|
index++;
|
|
202048
202049
|
}
|
|
@@ -202306,7 +202307,7 @@ ${frame}`;
|
|
|
202306
202307
|
CHAR_NO_BREAK_SPACE,
|
|
202307
202308
|
CHAR_ZERO_WIDTH_NOBREAK_SPACE
|
|
202308
202309
|
} = require_constants2();
|
|
202309
|
-
var
|
|
202310
|
+
var parse4 = (input, options = {}) => {
|
|
202310
202311
|
if (typeof input !== "string") {
|
|
202311
202312
|
throw new TypeError("Expected a string");
|
|
202312
202313
|
}
|
|
@@ -202568,7 +202569,7 @@ ${frame}`;
|
|
|
202568
202569
|
});
|
|
202569
202570
|
return ast;
|
|
202570
202571
|
};
|
|
202571
|
-
module22.exports =
|
|
202572
|
+
module22.exports = parse4;
|
|
202572
202573
|
}
|
|
202573
202574
|
});
|
|
202574
202575
|
var require_braces = __commonJS22({
|
|
@@ -202577,7 +202578,7 @@ ${frame}`;
|
|
|
202577
202578
|
var stringify = require_stringify();
|
|
202578
202579
|
var compile = require_compile();
|
|
202579
202580
|
var expand = require_expand();
|
|
202580
|
-
var
|
|
202581
|
+
var parse4 = require_parse();
|
|
202581
202582
|
var braces = (input, options = {}) => {
|
|
202582
202583
|
let output = [];
|
|
202583
202584
|
if (Array.isArray(input)) {
|
|
@@ -202597,7 +202598,7 @@ ${frame}`;
|
|
|
202597
202598
|
}
|
|
202598
202599
|
return output;
|
|
202599
202600
|
};
|
|
202600
|
-
braces.parse = (input, options = {}) =>
|
|
202601
|
+
braces.parse = (input, options = {}) => parse4(input, options);
|
|
202601
202602
|
braces.stringify = (input, options = {}) => {
|
|
202602
202603
|
if (typeof input === "string") {
|
|
202603
202604
|
return stringify(braces.parse(input, options), options);
|
|
@@ -203205,7 +203206,7 @@ ${frame}`;
|
|
|
203205
203206
|
var syntaxError = (type, char) => {
|
|
203206
203207
|
return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
|
|
203207
203208
|
};
|
|
203208
|
-
var
|
|
203209
|
+
var parse4 = (input, options) => {
|
|
203209
203210
|
if (typeof input !== "string") {
|
|
203210
203211
|
throw new TypeError("Expected a string");
|
|
203211
203212
|
}
|
|
@@ -203371,7 +203372,7 @@ ${frame}`;
|
|
|
203371
203372
|
output = token.close = `)$))${extglobStar}`;
|
|
203372
203373
|
}
|
|
203373
203374
|
if (token.inner.includes("*") && (rest = remaining()) && /^\.[^\\/.]+$/.test(rest)) {
|
|
203374
|
-
const expression =
|
|
203375
|
+
const expression = parse4(rest, Object.assign(Object.assign({}, options), {}, {
|
|
203375
203376
|
fastpaths: false
|
|
203376
203377
|
})).output;
|
|
203377
203378
|
output = token.close = `)${expression})${extglobStar})`;
|
|
@@ -204024,7 +204025,7 @@ ${frame}`;
|
|
|
204024
204025
|
}
|
|
204025
204026
|
return state;
|
|
204026
204027
|
};
|
|
204027
|
-
|
|
204028
|
+
parse4.fastpaths = (input, options) => {
|
|
204028
204029
|
const opts = Object.assign({}, options);
|
|
204029
204030
|
const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
|
204030
204031
|
const len = input.length;
|
|
@@ -204096,7 +204097,7 @@ ${frame}`;
|
|
|
204096
204097
|
}
|
|
204097
204098
|
return source;
|
|
204098
204099
|
};
|
|
204099
|
-
module22.exports =
|
|
204100
|
+
module22.exports = parse4;
|
|
204100
204101
|
}
|
|
204101
204102
|
});
|
|
204102
204103
|
var require_picomatch = __commonJS22({
|
|
@@ -204104,7 +204105,7 @@ ${frame}`;
|
|
|
204104
204105
|
"use strict";
|
|
204105
204106
|
var path2 = require("path");
|
|
204106
204107
|
var scan = require_scan();
|
|
204107
|
-
var
|
|
204108
|
+
var parse4 = require_parse2();
|
|
204108
204109
|
var utils = require_utils3();
|
|
204109
204110
|
var constants = require_constants3();
|
|
204110
204111
|
var isObject = (val) => val && typeof val === "object" && !Array.isArray(val);
|
|
@@ -204196,11 +204197,11 @@ ${frame}`;
|
|
|
204196
204197
|
};
|
|
204197
204198
|
}
|
|
204198
204199
|
const opts = options || {};
|
|
204199
|
-
const
|
|
204200
|
+
const format3 = opts.format || (posix ? utils.toPosixSlashes : null);
|
|
204200
204201
|
let match = input === glob;
|
|
204201
|
-
let output = match &&
|
|
204202
|
+
let output = match && format3 ? format3(input) : input;
|
|
204202
204203
|
if (match === false) {
|
|
204203
|
-
output =
|
|
204204
|
+
output = format3 ? format3(input) : input;
|
|
204204
204205
|
match = output === glob;
|
|
204205
204206
|
}
|
|
204206
204207
|
if (match === false || opts.capture === true) {
|
|
@@ -204224,7 +204225,7 @@ ${frame}`;
|
|
|
204224
204225
|
picomatch.parse = (pattern, options) => {
|
|
204225
204226
|
if (Array.isArray(pattern))
|
|
204226
204227
|
return pattern.map((p) => picomatch.parse(p, options));
|
|
204227
|
-
return
|
|
204228
|
+
return parse4(pattern, Object.assign(Object.assign({}, options), {}, {
|
|
204228
204229
|
fastpaths: false
|
|
204229
204230
|
}));
|
|
204230
204231
|
};
|
|
@@ -204255,10 +204256,10 @@ ${frame}`;
|
|
|
204255
204256
|
fastpaths: true
|
|
204256
204257
|
};
|
|
204257
204258
|
if (options.fastpaths !== false && (input[0] === "." || input[0] === "*")) {
|
|
204258
|
-
parsed.output =
|
|
204259
|
+
parsed.output = parse4.fastpaths(input, options);
|
|
204259
204260
|
}
|
|
204260
204261
|
if (!parsed.output) {
|
|
204261
|
-
parsed =
|
|
204262
|
+
parsed = parse4(input, options);
|
|
204262
204263
|
}
|
|
204263
204264
|
return picomatch.compileRe(parsed, options, returnOutput, returnState);
|
|
204264
204265
|
};
|
|
@@ -206075,10 +206076,10 @@ ${frame}`;
|
|
|
206075
206076
|
var require_load_toml = __commonJS22({
|
|
206076
206077
|
"src/utils/load-toml.js"(exports22, module22) {
|
|
206077
206078
|
"use strict";
|
|
206078
|
-
var
|
|
206079
|
+
var parse4 = require_parse_string();
|
|
206079
206080
|
module22.exports = function(filePath, content) {
|
|
206080
206081
|
try {
|
|
206081
|
-
return
|
|
206082
|
+
return parse4(content);
|
|
206082
206083
|
} catch (error) {
|
|
206083
206084
|
error.message = `TOML Error in ${filePath}:
|
|
206084
206085
|
${error.message}`;
|
|
@@ -206128,7 +206129,7 @@ ${error.message}`;
|
|
|
206128
206129
|
var token;
|
|
206129
206130
|
var key;
|
|
206130
206131
|
var root;
|
|
206131
|
-
module22.exports = function
|
|
206132
|
+
module22.exports = function parse4(text, reviver) {
|
|
206132
206133
|
source = String(text);
|
|
206133
206134
|
parseState = "start";
|
|
206134
206135
|
stack = [];
|
|
@@ -207157,10 +207158,10 @@ ${error.message}`;
|
|
|
207157
207158
|
});
|
|
207158
207159
|
var require_lib6 = __commonJS22({
|
|
207159
207160
|
"node_modules/json5/lib/index.js"(exports22, module22) {
|
|
207160
|
-
var
|
|
207161
|
+
var parse4 = require_parse3();
|
|
207161
207162
|
var stringify = require_stringify2();
|
|
207162
207163
|
var JSON5 = {
|
|
207163
|
-
parse:
|
|
207164
|
+
parse: parse4,
|
|
207164
207165
|
stringify
|
|
207165
207166
|
};
|
|
207166
207167
|
module22.exports = JSON5;
|
|
@@ -207170,11 +207171,11 @@ ${error.message}`;
|
|
|
207170
207171
|
"src/utils/load-json5.js"(exports22, module22) {
|
|
207171
207172
|
"use strict";
|
|
207172
207173
|
var {
|
|
207173
|
-
parse:
|
|
207174
|
+
parse: parse4
|
|
207174
207175
|
} = require_lib6();
|
|
207175
207176
|
module22.exports = function(filePath, content) {
|
|
207176
207177
|
try {
|
|
207177
|
-
return
|
|
207178
|
+
return parse4(content);
|
|
207178
207179
|
} catch (error) {
|
|
207179
207180
|
error.message = `JSON5 Error in ${filePath}:
|
|
207180
207181
|
${error.message}`;
|
|
@@ -207286,7 +207287,7 @@ ${error.message}`;
|
|
|
207286
207287
|
var require_node_modules_paths = __commonJS22({
|
|
207287
207288
|
"node_modules/resolve/lib/node-modules-paths.js"(exports22, module22) {
|
|
207288
207289
|
var path2 = require("path");
|
|
207289
|
-
var
|
|
207290
|
+
var parse4 = path2.parse || require_path_parse();
|
|
207290
207291
|
var getNodeModulesDirs = function getNodeModulesDirs2(absoluteStart, modules) {
|
|
207291
207292
|
var prefix = "/";
|
|
207292
207293
|
if (/^([A-Za-z]:)/.test(absoluteStart)) {
|
|
@@ -207295,10 +207296,10 @@ ${error.message}`;
|
|
|
207295
207296
|
prefix = "\\\\";
|
|
207296
207297
|
}
|
|
207297
207298
|
var paths = [absoluteStart];
|
|
207298
|
-
var parsed =
|
|
207299
|
+
var parsed = parse4(absoluteStart);
|
|
207299
207300
|
while (parsed.dir !== paths[paths.length - 1]) {
|
|
207300
207301
|
paths.push(parsed.dir);
|
|
207301
|
-
parsed =
|
|
207302
|
+
parsed = parse4(parsed.dir);
|
|
207302
207303
|
}
|
|
207303
207304
|
return paths.reduce(function(dirs, aPath) {
|
|
207304
207305
|
return dirs.concat(modules.map(function(moduleDir) {
|
|
@@ -209750,9 +209751,9 @@ ${fromBody}`;
|
|
|
209750
209751
|
}
|
|
209751
209752
|
return ret;
|
|
209752
209753
|
}
|
|
209753
|
-
Minimatch.prototype.parse =
|
|
209754
|
+
Minimatch.prototype.parse = parse4;
|
|
209754
209755
|
var SUBPARSE = {};
|
|
209755
|
-
function
|
|
209756
|
+
function parse4(pattern, isSub) {
|
|
209756
209757
|
var options = this.options;
|
|
209757
209758
|
if (!options.noglobstar && pattern === "**")
|
|
209758
209759
|
return GLOBSTAR;
|
|
@@ -210241,7 +210242,7 @@ ${fromBody}`;
|
|
|
210241
210242
|
param: /^\s*([\w\.\-\_]+)\s*[=:]\s*(.*?)\s*([#;].*)?$/,
|
|
210242
210243
|
comment: /^\s*[#;].*$/
|
|
210243
210244
|
};
|
|
210244
|
-
function
|
|
210245
|
+
function parse4(file) {
|
|
210245
210246
|
return __awaiter2(this, void 0, void 0, function() {
|
|
210246
210247
|
return __generator2(this, function(_a) {
|
|
210247
210248
|
return [2, new Promise(function(resolve2, reject) {
|
|
@@ -210256,7 +210257,7 @@ ${fromBody}`;
|
|
|
210256
210257
|
});
|
|
210257
210258
|
});
|
|
210258
210259
|
}
|
|
210259
|
-
exports22.parse =
|
|
210260
|
+
exports22.parse = parse4;
|
|
210260
210261
|
function parseSync(file) {
|
|
210261
210262
|
return parseString(fs2.readFileSync(file, "utf8"));
|
|
210262
210263
|
}
|
|
@@ -210673,7 +210674,7 @@ ${fromBody}`;
|
|
|
210673
210674
|
return parseFromConfigs(getConfigsForFiles(files), resolvedFilePath, processedOptions);
|
|
210674
210675
|
}
|
|
210675
210676
|
exports22.parseFromFilesSync = parseFromFilesSync;
|
|
210676
|
-
function
|
|
210677
|
+
function parse4(_filepath, _options) {
|
|
210677
210678
|
if (_options === void 0) {
|
|
210678
210679
|
_options = {};
|
|
210679
210680
|
}
|
|
@@ -210688,7 +210689,7 @@ ${fromBody}`;
|
|
|
210688
210689
|
});
|
|
210689
210690
|
});
|
|
210690
210691
|
}
|
|
210691
|
-
exports22.parse =
|
|
210692
|
+
exports22.parse = parse4;
|
|
210692
210693
|
function parseSync(_filepath, _options) {
|
|
210693
210694
|
if (_options === void 0) {
|
|
210694
210695
|
_options = {};
|
|
@@ -210790,7 +210791,7 @@ ${fromBody}`;
|
|
|
210790
210791
|
var jsonStringifyMem = (fn) => mem2(fn, {
|
|
210791
210792
|
cacheKey: JSON.stringify
|
|
210792
210793
|
});
|
|
210793
|
-
var maybeParse = (filePath,
|
|
210794
|
+
var maybeParse = (filePath, parse4) => filePath && parse4(filePath, {
|
|
210794
210795
|
root: findProjectRoot(path2.dirname(path2.resolve(filePath)))
|
|
210795
210796
|
});
|
|
210796
210797
|
var editorconfigAsyncNoCache = async (filePath) => editorConfigToPrettier(await maybeParse(filePath, editorconfig.parse));
|
|
@@ -215099,7 +215100,7 @@ ${fromBody}`;
|
|
|
215099
215100
|
var {
|
|
215100
215101
|
escapeTemplateCharacters
|
|
215101
215102
|
} = require_template_literal();
|
|
215102
|
-
function
|
|
215103
|
+
function format3(path2, print, textToDoc) {
|
|
215103
215104
|
const node = path2.getValue();
|
|
215104
215105
|
let text = node.quasis[0].value.raw.replace(/((?:\\\\)*)\\`/g, (_, backslashes) => "\\".repeat(backslashes.length / 2) + "`");
|
|
215105
215106
|
const indentation = getIndentation(text);
|
|
@@ -215119,7 +215120,7 @@ ${fromBody}`;
|
|
|
215119
215120
|
const firstMatchedIndent = str.match(/^([^\S\n]*)\S/m);
|
|
215120
215121
|
return firstMatchedIndent === null ? "" : firstMatchedIndent[1];
|
|
215121
215122
|
}
|
|
215122
|
-
module22.exports =
|
|
215123
|
+
module22.exports = format3;
|
|
215123
215124
|
}
|
|
215124
215125
|
});
|
|
215125
215126
|
var require_css = __commonJS22({
|
|
@@ -215143,7 +215144,7 @@ ${fromBody}`;
|
|
|
215143
215144
|
var {
|
|
215144
215145
|
printTemplateExpressions
|
|
215145
215146
|
} = require_template_literal();
|
|
215146
|
-
function
|
|
215147
|
+
function format3(path2, print, textToDoc) {
|
|
215147
215148
|
const node = path2.getValue();
|
|
215148
215149
|
const rawQuasis = node.quasis.map((q) => q.value.raw);
|
|
215149
215150
|
let placeholderID = 0;
|
|
@@ -215186,7 +215187,7 @@ ${fromBody}`;
|
|
|
215186
215187
|
});
|
|
215187
215188
|
return expressionDocs.length === replaceCounter ? newDoc : null;
|
|
215188
215189
|
}
|
|
215189
|
-
module22.exports =
|
|
215190
|
+
module22.exports = format3;
|
|
215190
215191
|
}
|
|
215191
215192
|
});
|
|
215192
215193
|
var require_graphql = __commonJS22({
|
|
@@ -215203,7 +215204,7 @@ ${fromBody}`;
|
|
|
215203
215204
|
escapeTemplateCharacters,
|
|
215204
215205
|
printTemplateExpressions
|
|
215205
215206
|
} = require_template_literal();
|
|
215206
|
-
function
|
|
215207
|
+
function format3(path2, print, textToDoc) {
|
|
215207
215208
|
const node = path2.getValue();
|
|
215208
215209
|
const numQuasis = node.quasis.length;
|
|
215209
215210
|
if (numQuasis === 1 && node.quasis[0].value.raw.trim() === "") {
|
|
@@ -215270,7 +215271,7 @@ ${fromBody}`;
|
|
|
215270
215271
|
}
|
|
215271
215272
|
return parts.length === 0 ? null : join2(hardline, parts);
|
|
215272
215273
|
}
|
|
215273
|
-
module22.exports =
|
|
215274
|
+
module22.exports = format3;
|
|
215274
215275
|
}
|
|
215275
215276
|
});
|
|
215276
215277
|
var require_html = __commonJS22({
|
|
@@ -215292,7 +215293,7 @@ ${fromBody}`;
|
|
|
215292
215293
|
uncookTemplateElementValue
|
|
215293
215294
|
} = require_template_literal();
|
|
215294
215295
|
var htmlTemplateLiteralCounter = 0;
|
|
215295
|
-
function
|
|
215296
|
+
function format3(path2, print, textToDoc, options, {
|
|
215296
215297
|
parser
|
|
215297
215298
|
}) {
|
|
215298
215299
|
const node = path2.getValue();
|
|
@@ -215345,7 +215346,7 @@ ${fromBody}`;
|
|
|
215345
215346
|
}
|
|
215346
215347
|
return group(["`", leadingWhitespace, topLevelCount > 1 ? indent(group(contentDoc)) : group(contentDoc), trailingWhitespace, "`"]);
|
|
215347
215348
|
}
|
|
215348
|
-
module22.exports =
|
|
215349
|
+
module22.exports = format3;
|
|
215349
215350
|
}
|
|
215350
215351
|
});
|
|
215351
215352
|
var require_embed = __commonJS22({
|
|
@@ -215595,7 +215596,7 @@ ${fromBody}`;
|
|
|
215595
215596
|
value: true
|
|
215596
215597
|
});
|
|
215597
215598
|
exports22.extract = extract;
|
|
215598
|
-
exports22.parse =
|
|
215599
|
+
exports22.parse = parse4;
|
|
215599
215600
|
exports22.parseWithComments = parseWithComments;
|
|
215600
215601
|
exports22.print = print;
|
|
215601
215602
|
exports22.strip = strip;
|
|
@@ -215635,7 +215636,7 @@ ${fromBody}`;
|
|
|
215635
215636
|
const match = contents.match(docblockRe);
|
|
215636
215637
|
return match && match[0] ? contents.substring(match[0].length) : contents;
|
|
215637
215638
|
}
|
|
215638
|
-
function
|
|
215639
|
+
function parse4(docblock) {
|
|
215639
215640
|
return parseWithComments(docblock).pragmas;
|
|
215640
215641
|
}
|
|
215641
215642
|
function parseWithComments(docblock) {
|
|
@@ -222465,7 +222466,7 @@ ${fromBody}`;
|
|
|
222465
222466
|
"src/utils/front-matter/parse.js"(exports22, module22) {
|
|
222466
222467
|
"use strict";
|
|
222467
222468
|
var frontMatterRegex = new RegExp("^(?<startDelimiter>-{3}|\\+{3})(?<language>[^\\n]*)\\n(?:|(?<value>.*?)\\n)(?<endDelimiter>\\k<startDelimiter>|\\.{3})[^\\S\\n]*(?:\\n|$)", "s");
|
|
222468
|
-
function
|
|
222469
|
+
function parse4(text) {
|
|
222469
222470
|
const match = text.match(frontMatterRegex);
|
|
222470
222471
|
if (!match) {
|
|
222471
222472
|
return {
|
|
@@ -222501,7 +222502,7 @@ ${fromBody}`;
|
|
|
222501
222502
|
content: raw.replace(/[^\n]/g, " ") + text.slice(raw.length)
|
|
222502
222503
|
};
|
|
222503
222504
|
}
|
|
222504
|
-
module22.exports =
|
|
222505
|
+
module22.exports = parse4;
|
|
222505
222506
|
}
|
|
222506
222507
|
});
|
|
222507
222508
|
var require_pragma2 = __commonJS22({
|
|
@@ -237126,7 +237127,6 @@ export async function ${f.name.name}(pool: Pool, args: ${argsType})
|
|
|
237126
237127
|
rowMode: "array",
|
|
237127
237128
|
});
|
|
237128
237129
|
const rows = res.rows.map(row => ${genDeserialization(f.returns, "row")});
|
|
237129
|
-
debugger;
|
|
237130
237130
|
return rows${f.multipleRows ? "" : "[0]"};
|
|
237131
237131
|
}
|
|
237132
237132
|
`;
|
|
@@ -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(
|
|
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(
|
|
237266
|
+
allStatements.push({fileName: sqlFile, statements});
|
|
237267
237267
|
}
|
|
237268
237268
|
console.log(`Processing ${allStatements.length} statements`);
|
|
237269
|
-
const g = parseSetupScripts(allStatements);
|
|
237270
|
-
const
|
|
237271
|
-
await fs.mkdir(
|
|
237272
|
-
const
|
|
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(
|
|
237279
|
+
await fs.appendFile(domainFile, genDomain(dom) + "\n", "utf-8");
|
|
237275
237280
|
}
|
|
237276
|
-
await fs.appendFile(
|
|
237281
|
+
await fs.appendFile(domainFile, `
|
|
237277
237282
|
`, "utf-8");
|
|
237278
|
-
|
|
237279
|
-
|
|
237280
|
-
|
|
237281
|
-
|
|
237282
|
-
|
|
237283
|
-
|
|
237284
|
-
|
|
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 =
|
|
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
|