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/package.json CHANGED
@@ -1,24 +1,24 @@
1
1
  {
2
2
  "name": "sql-typechecker",
3
- "version": "0.0.7",
3
+ "version": "0.0.10",
4
4
  "main": "out/typeparsers.js",
5
+ "files": ["out/**"],
5
6
  "bin": "out/cli.js",
6
7
  "dependencies": {
7
8
  "@js-joda/core": "^4.3.1",
8
9
  "pg": "^8.7.3",
9
- "pgsql-ast-parser": "git+https://github.com/frigoeu/pgsql-ast-parser#b675dc860429ae6749b54b688caae836d510054",
10
+ "pgsql-ast-parser": "git+https://github.com/frigoeu/pgsql-ast-parser#75da5fa1cddd9ef774805ee264a5f3eebc824ae",
10
11
  "postgres-range": "^1.1.2"
11
12
  },
12
13
  "scripts": {
13
14
  "check": "tsc -p . --noEmit",
14
15
  "build": "node esbuild.js && npm run build:types",
15
16
  "build:types": "tsc --emitDeclarationOnly --declaration --outDir ./out --module commonjs --target ES2019 --esModuleInterop src/typeparsers.ts",
16
- "install": "npm run build",
17
17
  "test": "alsatian ./test/**/*.ts",
18
18
  "start": "npm run build && node --enable-source-maps ./out/cli.js -d ./sample -o ./sample/out.ts && ts-node index.ts",
19
- "start_debug": "npm run debug -- -d ./sample -o ./sample/out.ts && ts-node index.ts",
19
+ "start_debug": "npm run debug -- -d ./sample -o ./sample/out.ts && ts-node index.ts",
20
20
  "start_index": "ts-node index.ts",
21
- "start_school": "npm run build && node --enable-source-maps ./out/cli.js -d ./school -o ./school/out",
21
+ "start_school": "npm run build && node --enable-source-maps ./out/cli.js -d ./school -o ./school/db",
22
22
  "start_school_debug": "npm run build && node --inspect-brk --enable-source-maps ./out/cli.js -d ./school -o ./school/out",
23
23
  "debug": "npm run build && node --inspect-brk --enable-source-maps ./out/cli.js ",
24
24
  "test_debug": "node --inspect-brk ./node_modules/alsatian/dist/cli/alsatian-cli.js ./test/**/*.ts -t 20000000",
package/.envrc DELETED
@@ -1,2 +0,0 @@
1
- eval "$(lorri direnv)"
2
- export PATH="$PWD/node_modules/.bin/:$PATH"
package/esbuild.js DELETED
@@ -1,12 +0,0 @@
1
- const esbuild = require("esbuild");
2
-
3
- const buildOptions = {
4
- entryPoints: ["src/cli.ts", "src/typeparsers.ts"],
5
- bundle: true,
6
- sourcemap: true,
7
- platform: "node",
8
- outdir: 'out',
9
- external: ["pg-native"]
10
- };
11
-
12
- esbuild.build(buildOptions).catch(() => process.exit(1));
package/index.ts DELETED
@@ -1,22 +0,0 @@
1
- import * as sample from "./sample/out";
2
- import postgres from "postgres";
3
-
4
- const dbSettings = {
5
- host: process.env.dbhost || "localhost",
6
- database: process.env.dbname || "sqltypertest",
7
- };
8
-
9
- async function go() {
10
- const sqlclient = postgres(dbSettings);
11
- const resInsert = await sample.insertintotestje(sqlclient, {
12
- id: 2,
13
- name: "ble",
14
- });
15
- console.log(resInsert?.toString());
16
- const resSelect = await sample.selectallfromtestje(sqlclient, {});
17
- resSelect.map((r) => console.log(r.name + ": " + r.id));
18
- }
19
-
20
- go()
21
- .catch((err) => console.error(err))
22
- .then(() => process.exit());
@@ -1,26 +0,0 @@
1
- CREATE OR REPLACE 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;
8
-
9
-
10
- CREATE OR REPLACE FUNCTION selectFromTestje1()
11
- RETURNS record
12
- AS $$
13
- SELECT *
14
- FROM testje
15
- $$ LANGUAGE sql;
16
-
17
- CREATE FUNCTION selectFromTestje2()
18
- RETURNS SETOF record
19
- AS $$
20
- SELECT *
21
- FROM testje
22
- $$ LANGUAGE sql;
23
-
24
- -- select * from selectFromTestje1() AS (id int, name text);
25
-
26
- -- select * from selectFromTestje2() AS (id int, name text);
package/sample/out.ts DELETED
@@ -1,70 +0,0 @@
1
- import postgres from "postgres";
2
- export async function insertintotestje(
3
- pg: postgres.Sql<any>,
4
- args: { id: number; name: string | null }
5
- ): Promise<number | null | undefined> {
6
- /*
7
- CREATE FUNCTION insertintotestje(id integer, name text DEFAULT NULL) RETURNS integer AS
8
- $$
9
- INSERT INTO testje (id, name)
10
- VALUES (id, name)
11
- RETURNING id;
12
- $$ LANGUAGE sql;
13
- */
14
- return (
15
- (await pg`SELECT * FROM insertintotestje(${args.id}, ${args.name})`) as any
16
- )[0]?.insertintotestje;
17
- }
18
- export async function selectfromtestje1(
19
- pg: postgres.Sql<any>,
20
- args: {}
21
- ): Promise<{ id: number; name: string | null } | undefined> {
22
- /*
23
- CREATE FUNCTION selectfromtestje1() RETURNS RECORD AS
24
- $$
25
- SELECT *
26
- FROM testje
27
- $$ LANGUAGE sql;
28
- */
29
- return (
30
- (await pg`SELECT * FROM selectfromtestje1() AS selectfromtestje1(id integer, name text)`) as any
31
- )[0];
32
- }
33
- export async function selectfromtestje2(
34
- pg: postgres.Sql<any>,
35
- args: {}
36
- ): Promise<{ id: number; name: string | null }[]> {
37
- /*
38
- CREATE FUNCTION selectfromtestje2() RETURNS SETOF RECORD AS
39
- $$
40
- SELECT *
41
- FROM testje
42
- $$ LANGUAGE sql;
43
- */
44
- return (await pg`SELECT * FROM selectfromtestje2() AS selectfromtestje2(id integer, name text)`) as any;
45
- }
46
- export async function selectfromtestje(
47
- pg: postgres.Sql<any>,
48
- args: {}
49
- ): Promise<{ "?": number[] }[]> {
50
- /*
51
- CREATE FUNCTION selectfromtestje() RETURNS SETOF RECORD AS
52
- $$
53
- SELECT ARRAY(SELECT id from testje)
54
- $$ LANGUAGE sql;
55
- */
56
- return (await pg`SELECT * FROM selectfromtestje() AS selectfromtestje( integer[])`) as any;
57
- }
58
- export async function selectallfromtestje(
59
- pg: postgres.Sql<any>,
60
- args: {}
61
- ): Promise<{ id: number; name: string | null }[]> {
62
- /*
63
- CREATE FUNCTION selectallfromtestje() RETURNS SETOF RECORD AS
64
- $$
65
- SELECT id, name
66
- FROM testje
67
- $$ LANGUAGE sql;
68
- */
69
- return (await pg`SELECT * FROM selectallfromtestje() AS selectallfromtestje(id integer, name text)`) as any;
70
- }
@@ -1,20 +0,0 @@
1
- CREATE TABLE testje (
2
- id int NOT NULL,
3
- name text
4
- );
5
-
6
- CREATE OR REPLACE FUNCTION selectFromTestje()
7
- RETURNS SETOF record
8
- AS $$
9
- SELECT ARRAY(SELECT id from testje)
10
- $$ LANGUAGE sql;
11
-
12
- CREATE OR REPLACE FUNCTION selectAllFromTestje()
13
- RETURNS SETOF record
14
- AS $$
15
- SELECT id, name
16
- FROM testje
17
- $$ LANGUAGE sql;
18
-
19
-
20
-