sql-typechecker 0.0.1

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/.envrc ADDED
@@ -0,0 +1,2 @@
1
+ eval "$(lorri direnv)"
2
+ export PATH="$PWD/node_modules/.bin/:$PATH"
package/esbuild.js ADDED
@@ -0,0 +1,12 @@
1
+ const esbuild = require("esbuild");
2
+
3
+ const buildOptions = {
4
+ entryPoints: ["src/cli.ts"],
5
+ bundle: true,
6
+ sourcemap: true,
7
+ platform: "node",
8
+ outdir: 'out'
9
+ };
10
+
11
+ esbuild.build(buildOptions)
12
+ .catch(() => process.exit(1));
package/package.json ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "sql-typechecker",
3
+ "version": "0.0.1",
4
+ "main": "out/cli.js",
5
+ "bin": "out/cli.js",
6
+ "dependencies": {
7
+ "pgsql-ast-parser": "frigoeu/pgsql-ast-parser#plpgsql",
8
+ "prettier": "2.2.1"
9
+ },
10
+ "scripts": {
11
+ "check": "tsc -p . --noEmit",
12
+ "build": "node esbuild.js",
13
+ "install": "npm run build",
14
+ "test": "alsatian ./test/**/*.ts",
15
+ "start": "npm run build && node --enable-source-maps ./out/cli.js ./sample -o ./sample/out.ts",
16
+ "start_school": "npm run build && node --enable-source-maps ./out/cli.js ./school -o ./school/out.ts",
17
+ "debug": "npm run build && node --inspect-brk --enable-source-maps ./out/cli.js ",
18
+ "test_debug": "node --inspect-brk ./node_modules/alsatian/dist/cli/alsatian-cli.js ./test/**/*.ts -t 20000000"
19
+ },
20
+ "devDependencies": {
21
+ "@types/node": "^14.14.10",
22
+ "@types/prettier": "^2.4.2",
23
+ "alsatian": "^3.2.1",
24
+ "esbuild": "0.8.34",
25
+ "purify-ts": "^1.0.0",
26
+ "typescript": "4.4.3"
27
+ }
28
+ }
@@ -0,0 +1,7 @@
1
+ CREATE FUNCTION insertIntoTestje(id int, name text DEFAULT NULL)
2
+ RETURNS int
3
+ AS $$
4
+ INSERT INTO testje (id, name)
5
+ VALUES (id, name)
6
+ RETURNING id;
7
+ $$ LANGUAGE sql;
package/sample/out.ts ADDED
@@ -0,0 +1,13 @@
1
+ import postgres from "postgres";
2
+ export function insertintotestje(
3
+ pg: postgres.Sql<any>,
4
+ args: { id: number; name: string | null }
5
+ ): Promise<{ id: number }[]> {
6
+ return pg`select insertintotestje(${args.id}, ${args.name})`;
7
+ }
8
+ export function selectfromtestje(
9
+ pg: postgres.Sql<any>,
10
+ args: {}
11
+ ): Promise<{ "?": number[] }[]> {
12
+ return pg`select selectfromtestje()`;
13
+ }
@@ -0,0 +1,10 @@
1
+ CREATE TABLE testje (
2
+ id int NOT NULL,
3
+ name text
4
+ );
5
+
6
+ CREATE FUNCTION selectFromTestje()
7
+ RETURNS SETOF
8
+ AS $$
9
+ SELECT ARRAY(SELECT id from testje)
10
+ $$ LANGUAGE sql;
package/school/out.ts ADDED
@@ -0,0 +1,59 @@
1
+ import postgres from "postgres";
2
+ export function getemailstosend(
3
+ pg: postgres.Sql<any>,
4
+ args: {}
5
+ ): Promise<
6
+ {
7
+ uw_id: bigint;
8
+ uw_from: string;
9
+ uw_replyto: string | null;
10
+ uw_address: string;
11
+ uw_addressee: string;
12
+ uw_subject: string;
13
+ uw_text: string;
14
+ uw_html: string | null;
15
+ uw_externalid: string;
16
+ uw_filename: string | null;
17
+ uw_content: Buffer | null;
18
+ }[]
19
+ > {
20
+ return pg`select getemailstosend()`;
21
+ /*
22
+ CREATE FUNCTION getemailstosend() RETURNS SETOF __todo__ AS
23
+ $$
24
+ SELECT
25
+ e.uw_id,
26
+ e.uw_from,
27
+ e.uw_replyto,
28
+ e.uw_address,
29
+ e.uw_addressee,
30
+ e.uw_subject,
31
+ e.uw_text,
32
+ e.uw_html,
33
+ e.uw_externalid,
34
+ a.uw_filename,
35
+ a.uw_content
36
+ FROM uw_email_emails e
37
+ JOIN uw_email_statusses s ON e.uw_id = s.uw_emailid AND s.uw_islastversion = TRUE
38
+ LEFT OUTER JOIN uw_email_attachments a ON a.uw_emailid = e.uw_id
39
+ WHERE s.uw_status = 'Waiting/_'
40
+ AND e.uw_html IS NOT NULL -- NULL = ARCHIVED
41
+ $$ LANGUAGE sql;
42
+ */
43
+ }
44
+ export function insertnewemailstatus(
45
+ pg: postgres.Sql<any>,
46
+ args: { uw_emailid: number; version: number; uw_status: string }
47
+ ): Promise<{ uw_emailid: bigint }[]> {
48
+ return pg`select insertnewemailstatus(${args.uw_emailid}, ${args.version}, ${args.uw_status})`;
49
+ /*
50
+ CREATE FUNCTION insertnewemailstatus(uw_emailidinteger, versioninteger, uw_statustext) RETURNS SETOF __todo__ AS
51
+ $$
52
+ INSERT INTO uw_email_statusses
53
+ (uw_emailid, uw_version, uw_status, uw_stamp, uw_islastversion)
54
+ VALUES
55
+ (uw_emailid, version, uw_status, CURRENT_TIMESTAMP, TRUE)
56
+ RETURNING uw_emailid;
57
+ $$ LANGUAGE sql;
58
+ */
59
+ }