dbctx 1.0.0 → 1.0.2
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/README.md +9 -0
- package/dist/index.mjs +0 -0
- package/package.json +44 -41
- package/.prettierrc.cjs +0 -7
- package/.turbo/turbo-build.log +0 -5
- package/src/App.tsx +0 -44
- package/src/components/Error.tsx +0 -16
- package/src/db/analyze.mts +0 -22
- package/src/db/attributes.mts +0 -58
- package/src/db/enums.mts +0 -43
- package/src/db/file-stats.mts +0 -57
- package/src/db/foreign-keys.mts +0 -61
- package/src/db/index.mts +0 -9
- package/src/db/indexes.mts +0 -57
- package/src/db/relations.mts +0 -35
- package/src/db/stats.mts +0 -51
- package/src/db/version.mts +0 -34
- package/src/index.mts +0 -116
- package/src/logger.mts +0 -10
- package/src/schemas/index.mts +0 -102
- package/src/validatePaths.mts +0 -77
- package/tsconfig.json +0 -104
package/README.md
ADDED
package/dist/index.mjs
CHANGED
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,43 +1,46 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
"
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
2
|
+
"name": "dbctx",
|
|
3
|
+
"version": "1.0.2",
|
|
4
|
+
"description": "dbctx CLI",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.mjs",
|
|
7
|
+
"bin": {
|
|
8
|
+
"dbctx": "./dist/index.mjs"
|
|
9
|
+
},
|
|
10
|
+
"keywords": [],
|
|
11
|
+
"author": {
|
|
12
|
+
"name": "AirState",
|
|
13
|
+
"email": "hello@airstate.dev",
|
|
14
|
+
"url": "https://airstate.dev"
|
|
15
|
+
},
|
|
16
|
+
"license": "UNLICENSED",
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"commander": "14.0.3",
|
|
19
|
+
"es-toolkit": "1.44.0",
|
|
20
|
+
"ink": "6.6.0",
|
|
21
|
+
"pg": "8.18.0",
|
|
22
|
+
"react": "19.2.4",
|
|
23
|
+
"winston": "3.19.0",
|
|
24
|
+
"zod": "4.3.6"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@types/node": "24.0.0",
|
|
28
|
+
"@types/pg": "8.16.0",
|
|
29
|
+
"@types/react": "19.2.10",
|
|
30
|
+
"concurrently": "9.2.1",
|
|
31
|
+
"cross-env": "7.0.3",
|
|
32
|
+
"typescript": "5.9.3"
|
|
33
|
+
},
|
|
34
|
+
"volta": {
|
|
35
|
+
"node": "24.0.0"
|
|
36
|
+
},
|
|
37
|
+
"files": [
|
|
38
|
+
"dist/"
|
|
39
|
+
],
|
|
40
|
+
"scripts": {
|
|
41
|
+
"start": "tsc && node ./dist/index.mjs",
|
|
42
|
+
"dev": "tsc --watch --preserveWatchOutput",
|
|
43
|
+
"build": "tsc",
|
|
44
|
+
"build:ts:watch": "tsc --watch --preserveWatchOutput"
|
|
45
|
+
}
|
|
43
46
|
}
|
package/.prettierrc.cjs
DELETED
package/.turbo/turbo-build.log
DELETED
package/src/App.tsx
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { Text, Box } from "ink";
|
|
2
|
-
import type { ReactNode } from "react";
|
|
3
|
-
import type { TSSLMode } from "./index.mjs";
|
|
4
|
-
|
|
5
|
-
export type TConnectionConfig = {
|
|
6
|
-
connectionString?: string;
|
|
7
|
-
hostname?: string;
|
|
8
|
-
port?: number;
|
|
9
|
-
database?: string;
|
|
10
|
-
username?: string;
|
|
11
|
-
sslmode?: TSSLMode;
|
|
12
|
-
sslcert?: string;
|
|
13
|
-
sslkey?: string;
|
|
14
|
-
sslrootcert?: string;
|
|
15
|
-
sshHost?: string;
|
|
16
|
-
sshPort?: number;
|
|
17
|
-
sshUsername?: string;
|
|
18
|
-
sshPrivateKey?: string;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
type TAppProps = {
|
|
22
|
-
config: TConnectionConfig;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
export function App({ config }: TAppProps): ReactNode {
|
|
26
|
-
const connectionTarget = config.connectionString
|
|
27
|
-
? config.connectionString.replace(/:[^:@]+@/, ":***@") // mask password
|
|
28
|
-
: `${config.hostname}:${config.port}/${config.database}`;
|
|
29
|
-
|
|
30
|
-
return (
|
|
31
|
-
<Box flexDirection="column" padding={1}>
|
|
32
|
-
<Box marginBottom={1}>
|
|
33
|
-
<Text color="cyan" bold>
|
|
34
|
-
dbctx
|
|
35
|
-
</Text>
|
|
36
|
-
<Text dimColor> - AI generated docs from your application database</Text>
|
|
37
|
-
</Box>
|
|
38
|
-
<Box>
|
|
39
|
-
<Text dimColor>Connecting to: </Text>
|
|
40
|
-
<Text color="yellow">{connectionTarget}</Text>
|
|
41
|
-
</Box>
|
|
42
|
-
</Box>
|
|
43
|
-
);
|
|
44
|
-
}
|
package/src/components/Error.tsx
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { Text, Box } from "ink";
|
|
2
|
-
import type { ReactNode } from "react";
|
|
3
|
-
|
|
4
|
-
interface ErrorProps {
|
|
5
|
-
message: string;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export function Error({ message }: ErrorProps): ReactNode {
|
|
9
|
-
return (
|
|
10
|
-
<Box>
|
|
11
|
-
<Text color="red" bold>
|
|
12
|
-
Error: {message}
|
|
13
|
-
</Text>
|
|
14
|
-
</Box>
|
|
15
|
-
);
|
|
16
|
-
}
|
package/src/db/analyze.mts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { Pool } from "pg";
|
|
2
|
-
|
|
3
|
-
export const analyzeRelation = async (pool: Pool, relationName: string): Promise<void> => {
|
|
4
|
-
// Validate relation exists and get properly quoted name to prevent SQL injection
|
|
5
|
-
const validation = await pool.query<{ quoted_name: string }>(
|
|
6
|
-
`
|
|
7
|
-
SELECT format('%I', c.relname) AS quoted_name
|
|
8
|
-
FROM pg_catalog.pg_class c
|
|
9
|
-
JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
|
|
10
|
-
WHERE n.nspname = 'public'
|
|
11
|
-
AND c.relname = $1
|
|
12
|
-
AND c.relkind IN ('r', 'p', 'm')
|
|
13
|
-
`,
|
|
14
|
-
[relationName]
|
|
15
|
-
);
|
|
16
|
-
|
|
17
|
-
if (validation.rows.length === 0) {
|
|
18
|
-
throw new Error(`Relation "${relationName}" not found in public schema`);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
await pool.query(`ANALYZE public.${validation.rows[0].quoted_name}`);
|
|
22
|
-
};
|
package/src/db/attributes.mts
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import type { Pool } from "pg";
|
|
2
|
-
|
|
3
|
-
export type TAttributeKind = "regular" | "generated";
|
|
4
|
-
|
|
5
|
-
export type TGeneratedStorage = "stored" | "virtual";
|
|
6
|
-
|
|
7
|
-
export type TAttributeInfo = {
|
|
8
|
-
attribute_name: string;
|
|
9
|
-
data_type: string;
|
|
10
|
-
is_nullable: boolean;
|
|
11
|
-
has_default: boolean;
|
|
12
|
-
default_expression: string | null;
|
|
13
|
-
kind: TAttributeKind;
|
|
14
|
-
generated_storage: TGeneratedStorage | null;
|
|
15
|
-
generated_expression: string | null;
|
|
16
|
-
comment: string | null;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export const fetchRelationAttributes = async (pool: Pool, relationName: string): Promise<TAttributeInfo[]> => {
|
|
20
|
-
const result = await pool.query<TAttributeInfo>(
|
|
21
|
-
`
|
|
22
|
-
SELECT
|
|
23
|
-
a.attname AS attribute_name,
|
|
24
|
-
format_type(a.atttypid, a.atttypemod) AS data_type,
|
|
25
|
-
NOT a.attnotnull AS is_nullable,
|
|
26
|
-
ad.adbin IS NOT NULL AS has_default,
|
|
27
|
-
CASE
|
|
28
|
-
WHEN a.attgenerated = '' AND ad.adbin IS NOT NULL THEN pg_get_expr(ad.adbin, ad.adrelid)
|
|
29
|
-
ELSE NULL
|
|
30
|
-
END AS default_expression,
|
|
31
|
-
CASE a.attgenerated
|
|
32
|
-
WHEN '' THEN 'regular'
|
|
33
|
-
ELSE 'generated'
|
|
34
|
-
END AS kind,
|
|
35
|
-
CASE a.attgenerated
|
|
36
|
-
WHEN 's' THEN 'stored'
|
|
37
|
-
WHEN 'v' THEN 'virtual'
|
|
38
|
-
ELSE NULL
|
|
39
|
-
END AS generated_storage,
|
|
40
|
-
CASE
|
|
41
|
-
WHEN a.attgenerated != '' THEN pg_get_expr(ad.adbin, ad.adrelid)
|
|
42
|
-
ELSE NULL
|
|
43
|
-
END AS generated_expression,
|
|
44
|
-
col_description(c.oid, a.attnum) AS comment
|
|
45
|
-
FROM pg_catalog.pg_class c
|
|
46
|
-
JOIN pg_catalog.pg_attribute a ON a.attrelid = c.oid
|
|
47
|
-
LEFT JOIN pg_catalog.pg_attrdef ad ON ad.adrelid = a.attrelid AND ad.adnum = a.attnum
|
|
48
|
-
WHERE c.relname = $1
|
|
49
|
-
AND c.relnamespace = (SELECT oid FROM pg_namespace WHERE nspname = 'public')
|
|
50
|
-
AND a.attnum > 0
|
|
51
|
-
AND NOT a.attisdropped
|
|
52
|
-
ORDER BY a.attnum
|
|
53
|
-
`,
|
|
54
|
-
[relationName]
|
|
55
|
-
);
|
|
56
|
-
|
|
57
|
-
return result.rows;
|
|
58
|
-
};
|
package/src/db/enums.mts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import type { Pool } from "pg";
|
|
2
|
-
import { groupBy } from "es-toolkit";
|
|
3
|
-
|
|
4
|
-
type TEnumValueRow = {
|
|
5
|
-
enum_name: string;
|
|
6
|
-
value: string;
|
|
7
|
-
sort_order: number;
|
|
8
|
-
comment: string | null;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export type TEnumInfo = {
|
|
12
|
-
values: string[];
|
|
13
|
-
comment: string | null;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export type TGroupedEnums = Record<string, TEnumInfo>;
|
|
17
|
-
|
|
18
|
-
export const fetchPublicEnums = async (pool: Pool): Promise<TGroupedEnums> => {
|
|
19
|
-
const result = await pool.query<TEnumValueRow>(`
|
|
20
|
-
SELECT
|
|
21
|
-
t.typname AS enum_name,
|
|
22
|
-
e.enumlabel AS value,
|
|
23
|
-
e.enumsortorder AS sort_order,
|
|
24
|
-
obj_description(t.oid, 'pg_type') AS comment
|
|
25
|
-
FROM pg_catalog.pg_type t
|
|
26
|
-
JOIN pg_catalog.pg_enum e ON t.oid = e.enumtypid
|
|
27
|
-
JOIN pg_catalog.pg_namespace n ON t.typnamespace = n.oid
|
|
28
|
-
WHERE n.nspname = 'public'
|
|
29
|
-
ORDER BY enum_name, sort_order
|
|
30
|
-
`);
|
|
31
|
-
|
|
32
|
-
const grouped = groupBy(result.rows, (row) => row.enum_name);
|
|
33
|
-
|
|
34
|
-
return Object.fromEntries(
|
|
35
|
-
Object.entries(grouped).map(([name, rows]) => [
|
|
36
|
-
name,
|
|
37
|
-
{
|
|
38
|
-
values: rows.map((r) => r.value),
|
|
39
|
-
comment: rows[0]?.comment ?? null,
|
|
40
|
-
},
|
|
41
|
-
])
|
|
42
|
-
);
|
|
43
|
-
};
|
package/src/db/file-stats.mts
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import type { Pool } from "pg";
|
|
2
|
-
|
|
3
|
-
export type TRelationFileStats = {
|
|
4
|
-
relation_name: string;
|
|
5
|
-
file_path: string | null;
|
|
6
|
-
modification_time: Date;
|
|
7
|
-
size_bytes: number;
|
|
8
|
-
is_partitioned: boolean;
|
|
9
|
-
partition_count: number | null;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export const fetchRelationFileStats = async (pool: Pool, relationName: string): Promise<TRelationFileStats> => {
|
|
13
|
-
const result = await pool.query<TRelationFileStats>(
|
|
14
|
-
`
|
|
15
|
-
WITH target AS (
|
|
16
|
-
SELECT c.oid, c.relname, c.relkind
|
|
17
|
-
FROM pg_catalog.pg_class c
|
|
18
|
-
JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
|
|
19
|
-
WHERE n.nspname = 'public'
|
|
20
|
-
AND c.relname = $1
|
|
21
|
-
AND c.relkind IN ('r', 'p', 'm')
|
|
22
|
-
),
|
|
23
|
-
partition_stats AS (
|
|
24
|
-
SELECT
|
|
25
|
-
(pg_stat_file(pg_relation_filepath(child.oid))).modification AS modification_time,
|
|
26
|
-
(pg_stat_file(pg_relation_filepath(child.oid))).size AS size_bytes
|
|
27
|
-
FROM target t
|
|
28
|
-
JOIN pg_catalog.pg_inherits i ON i.inhparent = t.oid
|
|
29
|
-
JOIN pg_catalog.pg_class child ON child.oid = i.inhrelid
|
|
30
|
-
WHERE t.relkind = 'p'
|
|
31
|
-
)
|
|
32
|
-
SELECT
|
|
33
|
-
t.relname AS relation_name,
|
|
34
|
-
CASE
|
|
35
|
-
WHEN t.relkind = 'p' THEN NULL
|
|
36
|
-
ELSE pg_relation_filepath(t.oid)
|
|
37
|
-
END AS file_path,
|
|
38
|
-
CASE
|
|
39
|
-
WHEN t.relkind = 'p' THEN (SELECT MAX(modification_time) FROM partition_stats)
|
|
40
|
-
ELSE (pg_stat_file(pg_relation_filepath(t.oid))).modification
|
|
41
|
-
END AS modification_time,
|
|
42
|
-
CASE
|
|
43
|
-
WHEN t.relkind = 'p' THEN (SELECT COALESCE(SUM(size_bytes), 0) FROM partition_stats)
|
|
44
|
-
ELSE (pg_stat_file(pg_relation_filepath(t.oid))).size
|
|
45
|
-
END AS size_bytes,
|
|
46
|
-
t.relkind = 'p' AS is_partitioned,
|
|
47
|
-
CASE
|
|
48
|
-
WHEN t.relkind = 'p' THEN (SELECT COUNT(*) FROM partition_stats)
|
|
49
|
-
ELSE NULL
|
|
50
|
-
END AS partition_count
|
|
51
|
-
FROM target t
|
|
52
|
-
`,
|
|
53
|
-
[relationName]
|
|
54
|
-
);
|
|
55
|
-
|
|
56
|
-
return result.rows[0];
|
|
57
|
-
};
|
package/src/db/foreign-keys.mts
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import type { Pool } from "pg";
|
|
2
|
-
|
|
3
|
-
type TForeignKeyAction = "NO ACTION" | "RESTRICT" | "CASCADE" | "SET NULL" | "SET DEFAULT";
|
|
4
|
-
|
|
5
|
-
export type TForeignKeyInfo = {
|
|
6
|
-
constraint_name: string;
|
|
7
|
-
attributes: string[];
|
|
8
|
-
referenced_relation: string;
|
|
9
|
-
referenced_attributes: string[];
|
|
10
|
-
on_update: TForeignKeyAction;
|
|
11
|
-
on_delete: TForeignKeyAction;
|
|
12
|
-
comment: string | null;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export const fetchRelationForeignKeys = async (pool: Pool, relationName: string): Promise<TForeignKeyInfo[]> => {
|
|
16
|
-
const result = await pool.query<TForeignKeyInfo>(
|
|
17
|
-
`
|
|
18
|
-
SELECT
|
|
19
|
-
con.conname AS constraint_name,
|
|
20
|
-
ARRAY(
|
|
21
|
-
SELECT a.attname
|
|
22
|
-
FROM unnest(con.conkey) WITH ORDINALITY AS cols(attnum, ord)
|
|
23
|
-
JOIN pg_attribute a ON a.attrelid = con.conrelid AND a.attnum = cols.attnum
|
|
24
|
-
ORDER BY cols.ord
|
|
25
|
-
) AS attributes,
|
|
26
|
-
ref_cl.relname AS referenced_relation,
|
|
27
|
-
ARRAY(
|
|
28
|
-
SELECT a.attname
|
|
29
|
-
FROM unnest(con.confkey) WITH ORDINALITY AS cols(attnum, ord)
|
|
30
|
-
JOIN pg_attribute a ON a.attrelid = con.confrelid AND a.attnum = cols.attnum
|
|
31
|
-
ORDER BY cols.ord
|
|
32
|
-
) AS referenced_attributes,
|
|
33
|
-
CASE con.confupdtype
|
|
34
|
-
WHEN 'a' THEN 'NO ACTION'
|
|
35
|
-
WHEN 'r' THEN 'RESTRICT'
|
|
36
|
-
WHEN 'c' THEN 'CASCADE'
|
|
37
|
-
WHEN 'n' THEN 'SET NULL'
|
|
38
|
-
WHEN 'd' THEN 'SET DEFAULT'
|
|
39
|
-
END AS on_update,
|
|
40
|
-
CASE con.confdeltype
|
|
41
|
-
WHEN 'a' THEN 'NO ACTION'
|
|
42
|
-
WHEN 'r' THEN 'RESTRICT'
|
|
43
|
-
WHEN 'c' THEN 'CASCADE'
|
|
44
|
-
WHEN 'n' THEN 'SET NULL'
|
|
45
|
-
WHEN 'd' THEN 'SET DEFAULT'
|
|
46
|
-
END AS on_delete,
|
|
47
|
-
obj_description(con.oid, 'pg_constraint') AS comment
|
|
48
|
-
FROM pg_catalog.pg_constraint con
|
|
49
|
-
JOIN pg_catalog.pg_class cl ON cl.oid = con.conrelid
|
|
50
|
-
JOIN pg_catalog.pg_class ref_cl ON ref_cl.oid = con.confrelid
|
|
51
|
-
JOIN pg_catalog.pg_namespace n ON n.oid = cl.relnamespace
|
|
52
|
-
WHERE con.contype = 'f'
|
|
53
|
-
AND n.nspname = 'public'
|
|
54
|
-
AND cl.relname = $1
|
|
55
|
-
ORDER BY con.conname
|
|
56
|
-
`,
|
|
57
|
-
[relationName]
|
|
58
|
-
);
|
|
59
|
-
|
|
60
|
-
return result.rows;
|
|
61
|
-
};
|
package/src/db/index.mts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export { fetchPublicRelations, type TRelationType, type TRelationInfo, type TGroupedRelations } from "./relations.mjs";
|
|
2
|
-
export { fetchRelationAttributes, type TAttributeKind, type TGeneratedStorage, type TAttributeInfo } from "./attributes.mjs";
|
|
3
|
-
export { fetchPublicEnums, type TEnumInfo, type TGroupedEnums } from "./enums.mjs";
|
|
4
|
-
export { fetchRelationIndexes, type TIndexInfo } from "./indexes.mjs";
|
|
5
|
-
export { fetchRelationForeignKeys, type TForeignKeyInfo } from "./foreign-keys.mjs";
|
|
6
|
-
export { fetchPostgresVersion, type TPostgresVersion, fetchDatabaseIdentifier, type TDatabaseIdentifier } from "./version.mjs";
|
|
7
|
-
export { fetchRelationFileStats, type TRelationFileStats } from "./file-stats.mjs";
|
|
8
|
-
export { analyzeRelation } from "./analyze.mjs";
|
|
9
|
-
export { fetchRelationStats, type TRelationStats, type TAttributeStats } from "./stats.mjs";
|
package/src/db/indexes.mts
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import type { Pool } from "pg";
|
|
2
|
-
|
|
3
|
-
export type TIndexInfo = {
|
|
4
|
-
index_name: string;
|
|
5
|
-
relation_name: string;
|
|
6
|
-
is_unique: boolean;
|
|
7
|
-
is_primary: boolean;
|
|
8
|
-
is_exclusion: boolean;
|
|
9
|
-
is_partial: boolean;
|
|
10
|
-
partial_predicate: string | null;
|
|
11
|
-
attributes: string[];
|
|
12
|
-
exclusion_operators: string[] | null;
|
|
13
|
-
definition: string;
|
|
14
|
-
comment: string | null;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export const fetchRelationIndexes = async (pool: Pool, relationName: string): Promise<TIndexInfo[]> => {
|
|
18
|
-
const result = await pool.query<TIndexInfo>(
|
|
19
|
-
`
|
|
20
|
-
SELECT
|
|
21
|
-
i.relname AS index_name,
|
|
22
|
-
t.relname AS relation_name,
|
|
23
|
-
ix.indisunique AS is_unique,
|
|
24
|
-
ix.indisprimary AS is_primary,
|
|
25
|
-
ix.indisexclusion AS is_exclusion,
|
|
26
|
-
ix.indpred IS NOT NULL AS is_partial,
|
|
27
|
-
pg_get_expr(ix.indpred, ix.indrelid) AS partial_predicate,
|
|
28
|
-
ARRAY(
|
|
29
|
-
SELECT pg_get_indexdef(ix.indexrelid, k + 1, true)
|
|
30
|
-
FROM generate_subscripts(ix.indkey, 1) AS k
|
|
31
|
-
ORDER BY k
|
|
32
|
-
) AS attributes,
|
|
33
|
-
CASE
|
|
34
|
-
WHEN ix.indisexclusion THEN (
|
|
35
|
-
SELECT ARRAY_AGG(op.oprname ORDER BY ord.n)
|
|
36
|
-
FROM pg_constraint con
|
|
37
|
-
CROSS JOIN LATERAL unnest(con.conexclop) WITH ORDINALITY AS ord(opoid, n)
|
|
38
|
-
JOIN pg_operator op ON op.oid = ord.opoid
|
|
39
|
-
WHERE con.conindid = ix.indexrelid
|
|
40
|
-
)
|
|
41
|
-
ELSE NULL
|
|
42
|
-
END AS exclusion_operators,
|
|
43
|
-
pg_get_indexdef(ix.indexrelid) AS definition,
|
|
44
|
-
obj_description(i.oid, 'pg_class') AS comment
|
|
45
|
-
FROM pg_catalog.pg_index ix
|
|
46
|
-
JOIN pg_catalog.pg_class i ON i.oid = ix.indexrelid
|
|
47
|
-
JOIN pg_catalog.pg_class t ON t.oid = ix.indrelid
|
|
48
|
-
JOIN pg_catalog.pg_namespace n ON n.oid = t.relnamespace
|
|
49
|
-
WHERE n.nspname = 'public'
|
|
50
|
-
AND t.relname = $1
|
|
51
|
-
ORDER BY i.relname
|
|
52
|
-
`,
|
|
53
|
-
[relationName]
|
|
54
|
-
);
|
|
55
|
-
|
|
56
|
-
return result.rows;
|
|
57
|
-
};
|
package/src/db/relations.mts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import type { Pool } from "pg";
|
|
2
|
-
import { groupBy } from "es-toolkit";
|
|
3
|
-
|
|
4
|
-
export type TRelationType = "partitioned_table" | "table" | "view" | "materialized_view";
|
|
5
|
-
|
|
6
|
-
export type TRelationInfo = {
|
|
7
|
-
name: string;
|
|
8
|
-
type: TRelationType;
|
|
9
|
-
comment: string | null;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export type TGroupedRelations = Record<TRelationType, TRelationInfo[]>;
|
|
13
|
-
|
|
14
|
-
export const fetchPublicRelations = async (pool: Pool): Promise<TGroupedRelations> => {
|
|
15
|
-
const result = await pool.query<TRelationInfo>(`
|
|
16
|
-
SELECT relname AS name,
|
|
17
|
-
CASE relkind
|
|
18
|
-
WHEN 'p' THEN 'partitioned_table'
|
|
19
|
-
WHEN 'r' THEN 'table'
|
|
20
|
-
WHEN 'v' THEN 'view'
|
|
21
|
-
WHEN 'm' THEN 'materialized_view'
|
|
22
|
-
END AS type,
|
|
23
|
-
obj_description(oid, 'pg_class') AS comment
|
|
24
|
-
FROM pg_catalog.pg_class
|
|
25
|
-
WHERE relnamespace = (SELECT oid FROM pg_namespace WHERE nspname = 'public')
|
|
26
|
-
AND (
|
|
27
|
-
relkind = 'p'
|
|
28
|
-
OR (relkind = 'r' AND NOT relispartition)
|
|
29
|
-
OR relkind IN ('v', 'm')
|
|
30
|
-
)
|
|
31
|
-
ORDER BY type, name
|
|
32
|
-
`);
|
|
33
|
-
|
|
34
|
-
return groupBy(result.rows, (row) => row.type) as TGroupedRelations;
|
|
35
|
-
};
|
package/src/db/stats.mts
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import type { Pool } from "pg";
|
|
2
|
-
|
|
3
|
-
export type TAttributeStats = {
|
|
4
|
-
attribute_name: string;
|
|
5
|
-
estimated_distinct: number;
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
export type TRelationStats = {
|
|
9
|
-
relation_name: string;
|
|
10
|
-
estimated_row_count: number;
|
|
11
|
-
attributes: TAttributeStats[];
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export const fetchRelationStats = async (pool: Pool, relationName: string): Promise<TRelationStats> => {
|
|
15
|
-
const result = await pool.query<TAttributeStats & { relation_name: string; estimated_row_count: number }>(
|
|
16
|
-
`
|
|
17
|
-
SELECT
|
|
18
|
-
s.tablename AS relation_name,
|
|
19
|
-
c.reltuples::bigint AS estimated_row_count,
|
|
20
|
-
s.attname AS attribute_name,
|
|
21
|
-
CASE
|
|
22
|
-
WHEN s.n_distinct > 0 THEN s.n_distinct
|
|
23
|
-
ELSE abs(s.n_distinct) * c.reltuples
|
|
24
|
-
END::bigint AS estimated_distinct
|
|
25
|
-
FROM pg_catalog.pg_stats s
|
|
26
|
-
JOIN pg_catalog.pg_class c ON c.relname = s.tablename
|
|
27
|
-
JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace AND n.nspname = s.schemaname
|
|
28
|
-
WHERE s.schemaname = 'public'
|
|
29
|
-
AND s.tablename = $1
|
|
30
|
-
ORDER BY s.attnum
|
|
31
|
-
`,
|
|
32
|
-
[relationName]
|
|
33
|
-
);
|
|
34
|
-
|
|
35
|
-
if (result.rows.length === 0) {
|
|
36
|
-
return {
|
|
37
|
-
relation_name: relationName,
|
|
38
|
-
estimated_row_count: 0,
|
|
39
|
-
attributes: [],
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return {
|
|
44
|
-
relation_name: result.rows[0].relation_name,
|
|
45
|
-
estimated_row_count: result.rows[0].estimated_row_count,
|
|
46
|
-
attributes: result.rows.map(({ attribute_name, estimated_distinct }) => ({
|
|
47
|
-
attribute_name,
|
|
48
|
-
estimated_distinct,
|
|
49
|
-
})),
|
|
50
|
-
};
|
|
51
|
-
};
|
package/src/db/version.mts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import type { Pool } from "pg";
|
|
2
|
-
|
|
3
|
-
export type TPostgresVersion = {
|
|
4
|
-
version: string;
|
|
5
|
-
version_num: number;
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
export const fetchPostgresVersion = async (pool: Pool): Promise<TPostgresVersion> => {
|
|
9
|
-
const result = await pool.query<TPostgresVersion>(`
|
|
10
|
-
SELECT
|
|
11
|
-
current_setting('server_version') AS version,
|
|
12
|
-
current_setting('server_version_num')::int AS version_num
|
|
13
|
-
`);
|
|
14
|
-
|
|
15
|
-
return result.rows[0];
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export type TDatabaseIdentifier = {
|
|
19
|
-
system_identifier: string;
|
|
20
|
-
database_oid: number;
|
|
21
|
-
database_name: string;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export const fetchDatabaseIdentifier = async (pool: Pool): Promise<TDatabaseIdentifier> => {
|
|
25
|
-
const result = await pool.query<TDatabaseIdentifier>(`
|
|
26
|
-
SELECT
|
|
27
|
-
system_identifier::text AS system_identifier,
|
|
28
|
-
(SELECT oid::int FROM pg_database WHERE datname = current_database()) AS database_oid,
|
|
29
|
-
current_database() AS database_name
|
|
30
|
-
FROM pg_control_system()
|
|
31
|
-
`);
|
|
32
|
-
|
|
33
|
-
return result.rows[0];
|
|
34
|
-
};
|
package/src/index.mts
DELETED
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { Command } from "commander";
|
|
3
|
-
import { render } from "ink";
|
|
4
|
-
import { Error } from "./components/Error.js";
|
|
5
|
-
import { App, type TConnectionConfig } from "./App.js";
|
|
6
|
-
import { validatePathOptions, type TPathValidationError } from "./validatePaths.mjs";
|
|
7
|
-
|
|
8
|
-
export type TSSLMode = "disable" | "allow" | "prefer" | "require" | "verify-ca" | "verify-full";
|
|
9
|
-
|
|
10
|
-
export interface ConnectionOptions {
|
|
11
|
-
hostname?: string;
|
|
12
|
-
port?: number;
|
|
13
|
-
database?: string;
|
|
14
|
-
username?: string;
|
|
15
|
-
sslmode?: TSSLMode;
|
|
16
|
-
sslcert?: string;
|
|
17
|
-
sslkey?: string;
|
|
18
|
-
sslrootcert?: string;
|
|
19
|
-
sshHost?: string;
|
|
20
|
-
sshPort?: number;
|
|
21
|
-
sshUsername?: string;
|
|
22
|
-
sshPrivateKey?: string;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const program = new Command();
|
|
26
|
-
|
|
27
|
-
program
|
|
28
|
-
.name("dbctx")
|
|
29
|
-
.description("AI generated docs from your application database")
|
|
30
|
-
.version("1.0.0")
|
|
31
|
-
.argument("[connection-string]", "PostgreSQL connection string (env: DATABASE_URL)")
|
|
32
|
-
.option("-h, --hostname <host>", "database hostname (env: PGHOST, default: localhost)")
|
|
33
|
-
.option("-p, --port <port>", "database port (env: PGPORT, default: 5432)", parseInt)
|
|
34
|
-
.option("-d, --database <name>", "database name (env: PGDATABASE, default: postgres)")
|
|
35
|
-
.option("-U, --username <user>", "database username (env: PGUSER, default: postgres)")
|
|
36
|
-
.option("--sslmode <mode>", "SSL mode: disable|allow|prefer|require|verify-ca|verify-full (env: PGSSLMODE, default: prefer)")
|
|
37
|
-
.option("--sslcert <path>", "path to client certificate (env: PGSSLCERT)")
|
|
38
|
-
.option("--sslkey <path>", "path to client private key (env: PGSSLKEY)")
|
|
39
|
-
.option("--sslrootcert <path>", "path to root CA certificate (env: PGSSLROOTCERT)")
|
|
40
|
-
.option("--ssh-host <host>", "SSH tunnel host (bastion/jump server)")
|
|
41
|
-
.option("--ssh-port <port>", "SSH tunnel port (default: 22)", parseInt)
|
|
42
|
-
.option("--ssh-username <user>", "SSH tunnel username (default: $USER)")
|
|
43
|
-
.option("--ssh-private-key <path>", "path to SSH private key (default: ~/.ssh/id_rsa)")
|
|
44
|
-
.action((connectionString: string | undefined, options: ConnectionOptions) => {
|
|
45
|
-
const hasConnectionString = Boolean(connectionString);
|
|
46
|
-
const hasIndividualOptions = Boolean(
|
|
47
|
-
options.hostname || options.port || options.database || options.username
|
|
48
|
-
);
|
|
49
|
-
|
|
50
|
-
if (hasConnectionString && hasIndividualOptions) {
|
|
51
|
-
render(
|
|
52
|
-
Error({
|
|
53
|
-
message:
|
|
54
|
-
"Cannot use both connection string and individual options (-h, -p, -d, -U). Use one or the other.",
|
|
55
|
-
})
|
|
56
|
-
);
|
|
57
|
-
|
|
58
|
-
process.exit(1);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// Validate path options exist on filesystem
|
|
62
|
-
const { errors: pathErrors, expandedPaths } = validatePathOptions(options);
|
|
63
|
-
|
|
64
|
-
if (pathErrors.length > 0) {
|
|
65
|
-
const errorMessages = pathErrors
|
|
66
|
-
.map(({ option, path }: TPathValidationError) => ` ${option}: ${path}`)
|
|
67
|
-
.join("\n");
|
|
68
|
-
|
|
69
|
-
render(
|
|
70
|
-
Error({
|
|
71
|
-
message: `The following paths do not exist:\n${errorMessages}`,
|
|
72
|
-
})
|
|
73
|
-
);
|
|
74
|
-
|
|
75
|
-
process.exit(1);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// Replace original paths with expanded paths (~ resolved to home directory)
|
|
79
|
-
const validatedOptions: ConnectionOptions = {
|
|
80
|
-
...options,
|
|
81
|
-
...expandedPaths,
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
if (hasIndividualOptions) {
|
|
85
|
-
const requiredOptions = [
|
|
86
|
-
{ key: "hostname", flag: "-h/--hostname" },
|
|
87
|
-
{ key: "port", flag: "-p/--port" },
|
|
88
|
-
{ key: "database", flag: "-d/--database" },
|
|
89
|
-
{ key: "username", flag: "-U/--username" },
|
|
90
|
-
] as const;
|
|
91
|
-
|
|
92
|
-
const missing = requiredOptions
|
|
93
|
-
.filter(({ key }) => !validatedOptions[key])
|
|
94
|
-
.map(({ flag }) => flag);
|
|
95
|
-
|
|
96
|
-
if (missing.length > 0) {
|
|
97
|
-
render(
|
|
98
|
-
Error({
|
|
99
|
-
message: `Missing required options: ${missing.join(", ")}`,
|
|
100
|
-
})
|
|
101
|
-
);
|
|
102
|
-
|
|
103
|
-
process.exit(1);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
// All validations passed - build config and render the app
|
|
108
|
-
const config: TConnectionConfig = {
|
|
109
|
-
connectionString,
|
|
110
|
-
...validatedOptions,
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
render(App({ config }));
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
program.parse();
|
package/src/logger.mts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import winston from 'winston';
|
|
2
|
-
|
|
3
|
-
export const logger = winston.createLogger({
|
|
4
|
-
level: process.env.NODE_ENV === 'development' ? 'debug' : 'info',
|
|
5
|
-
format: winston.format.combine(
|
|
6
|
-
winston.format.timestamp(),
|
|
7
|
-
winston.format.json(),
|
|
8
|
-
),
|
|
9
|
-
transports: [new winston.transports.Console()],
|
|
10
|
-
});
|
package/src/schemas/index.mts
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import {z} from 'zod';
|
|
2
|
-
|
|
3
|
-
const relationAttribute = z
|
|
4
|
-
.object({
|
|
5
|
-
name: z.string(),
|
|
6
|
-
data_type: z.string(),
|
|
7
|
-
is_nullable: z.boolean(),
|
|
8
|
-
comment: z.string().nullable(),
|
|
9
|
-
})
|
|
10
|
-
.and(
|
|
11
|
-
z.discriminatedUnion('kind', [
|
|
12
|
-
z.discriminatedUnion('has_default', [
|
|
13
|
-
z.object({
|
|
14
|
-
kind: z.literal('regular'),
|
|
15
|
-
has_default: z.literal(false),
|
|
16
|
-
}),
|
|
17
|
-
z.object({
|
|
18
|
-
kind: z.literal('regular'),
|
|
19
|
-
has_default: z.literal(true),
|
|
20
|
-
default_expression: z.string(),
|
|
21
|
-
}),
|
|
22
|
-
]),
|
|
23
|
-
z.object({
|
|
24
|
-
kind: z.literal('generated'),
|
|
25
|
-
generated_storage: z.enum(['stored', 'virtual']),
|
|
26
|
-
generated_expression: z.string(),
|
|
27
|
-
}),
|
|
28
|
-
]),
|
|
29
|
-
);
|
|
30
|
-
|
|
31
|
-
const indexInfo = z
|
|
32
|
-
.object({
|
|
33
|
-
index_name: z.string(),
|
|
34
|
-
relation_name: z.string(),
|
|
35
|
-
attributes: z.array(z.string()),
|
|
36
|
-
definition: z.string(),
|
|
37
|
-
comment: z.string().nullable(),
|
|
38
|
-
})
|
|
39
|
-
.and(
|
|
40
|
-
z.discriminatedUnion('index_kind', [
|
|
41
|
-
z.object({ index_kind: z.literal('primary') }),
|
|
42
|
-
z.object({ index_kind: z.literal('unique') }),
|
|
43
|
-
z.object({
|
|
44
|
-
index_kind: z.literal('exclusion'),
|
|
45
|
-
exclusion_operators: z.array(z.string()),
|
|
46
|
-
}),
|
|
47
|
-
z.object({ index_kind: z.literal('plain') }),
|
|
48
|
-
]),
|
|
49
|
-
)
|
|
50
|
-
.and(
|
|
51
|
-
z.discriminatedUnion('is_partial', [
|
|
52
|
-
z.object({ is_partial: z.literal(false) }),
|
|
53
|
-
z.object({
|
|
54
|
-
is_partial: z.literal(true),
|
|
55
|
-
partial_predicate: z.string(),
|
|
56
|
-
}),
|
|
57
|
-
]),
|
|
58
|
-
);
|
|
59
|
-
|
|
60
|
-
const reference = z.object({
|
|
61
|
-
constraint_name: z.string(),
|
|
62
|
-
attributes: z.array(z.string()),
|
|
63
|
-
referenced_relation: z.string(),
|
|
64
|
-
referenced_attributes: z.array(z.string()),
|
|
65
|
-
on_update: z.enum([
|
|
66
|
-
'NO ACTION',
|
|
67
|
-
'RESTRICT',
|
|
68
|
-
'CASCADE',
|
|
69
|
-
'SET NULL',
|
|
70
|
-
'SET DEFAULT',
|
|
71
|
-
]),
|
|
72
|
-
on_delete: z.enum([
|
|
73
|
-
'NO ACTION',
|
|
74
|
-
'RESTRICT',
|
|
75
|
-
'CASCADE',
|
|
76
|
-
'SET NULL',
|
|
77
|
-
'SET DEFAULT',
|
|
78
|
-
]),
|
|
79
|
-
comment: z.string().nullable(),
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
const relation = z.object({
|
|
83
|
-
name: z.string(),
|
|
84
|
-
comment: z.string().nullable(),
|
|
85
|
-
kind: z.enum(['partitioned_table', 'table', 'view', 'materialized_view']),
|
|
86
|
-
summary: z.string().optional(),
|
|
87
|
-
details: z.string().optional(),
|
|
88
|
-
attributes: z.record(z.string(), relationAttribute),
|
|
89
|
-
references: z.record(z.string(), reference),
|
|
90
|
-
indexes: z.record(z.string(), indexInfo),
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
const relations = z.record(z.string(), relation);
|
|
94
|
-
|
|
95
|
-
const database = z.object({
|
|
96
|
-
type: z.enum(['postgresql']),
|
|
97
|
-
name: z.string(),
|
|
98
|
-
comment: z.string().nullable(),
|
|
99
|
-
summary: z.string().optional(),
|
|
100
|
-
details: z.string().optional(),
|
|
101
|
-
relations: relations,
|
|
102
|
-
});
|
package/src/validatePaths.mts
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { existsSync } from "node:fs";
|
|
2
|
-
import { homedir } from "node:os";
|
|
3
|
-
import { resolve } from "node:path";
|
|
4
|
-
|
|
5
|
-
type TPathValidationResult =
|
|
6
|
-
| { valid: true; expandedPath: string }
|
|
7
|
-
| { valid: false; error: string };
|
|
8
|
-
|
|
9
|
-
type TPathOptionKey = "sslcert" | "sslkey" | "sslrootcert" | "sshPrivateKey";
|
|
10
|
-
|
|
11
|
-
export type TPathValidationError = {
|
|
12
|
-
option: string;
|
|
13
|
-
path: string;
|
|
14
|
-
error: string;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
const expandTilde = (path: string): string =>
|
|
18
|
-
path.startsWith("~/") || path === "~"
|
|
19
|
-
? path.replace(/^~/, homedir())
|
|
20
|
-
: path;
|
|
21
|
-
|
|
22
|
-
const normalizePath = (path: string): string =>
|
|
23
|
-
resolve(expandTilde(path));
|
|
24
|
-
|
|
25
|
-
const validatePathExists = (path: string): TPathValidationResult => {
|
|
26
|
-
const expandedPath = normalizePath(path);
|
|
27
|
-
|
|
28
|
-
return existsSync(expandedPath)
|
|
29
|
-
? { valid: true, expandedPath }
|
|
30
|
-
: { valid: false, error: `Path does not exist: ${path}` };
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
const PATH_OPTION_LABELS: Record<TPathOptionKey, string> = {
|
|
34
|
-
sslcert: "--sslcert",
|
|
35
|
-
sslkey: "--sslkey",
|
|
36
|
-
sslrootcert: "--sslrootcert",
|
|
37
|
-
sshPrivateKey: "--ssh-private-key",
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
export const validatePathOptions = <T extends Partial<Record<TPathOptionKey, string>>>(
|
|
41
|
-
options: T
|
|
42
|
-
): { errors: TPathValidationError[]; expandedPaths: Partial<Record<TPathOptionKey, string>> } => {
|
|
43
|
-
const pathKeys: TPathOptionKey[] = ["sslcert", "sslkey", "sslrootcert", "sshPrivateKey"];
|
|
44
|
-
|
|
45
|
-
const results = pathKeys
|
|
46
|
-
.filter((key) => options[key] !== undefined)
|
|
47
|
-
.map((key) => {
|
|
48
|
-
const path = options[key] as string;
|
|
49
|
-
const result = validatePathExists(path);
|
|
50
|
-
|
|
51
|
-
return {
|
|
52
|
-
key,
|
|
53
|
-
path,
|
|
54
|
-
result,
|
|
55
|
-
};
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
const errors = results
|
|
59
|
-
.filter((r) => !r.result.valid)
|
|
60
|
-
.map((r) => ({
|
|
61
|
-
option: PATH_OPTION_LABELS[r.key],
|
|
62
|
-
path: r.path,
|
|
63
|
-
error: (r.result as { valid: false; error: string }).error,
|
|
64
|
-
}));
|
|
65
|
-
|
|
66
|
-
const expandedPaths = results
|
|
67
|
-
.filter((r) => r.result.valid)
|
|
68
|
-
.reduce(
|
|
69
|
-
(acc, r) => ({
|
|
70
|
-
...acc,
|
|
71
|
-
[r.key]: (r.result as { valid: true; expandedPath: string }).expandedPath,
|
|
72
|
-
}),
|
|
73
|
-
{} as Partial<Record<TPathOptionKey, string>>
|
|
74
|
-
);
|
|
75
|
-
|
|
76
|
-
return { errors, expandedPaths };
|
|
77
|
-
};
|
package/tsconfig.json
DELETED
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"include": ["./src/**/*", "./src/**/*.json"],
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"target": "ESNext",
|
|
5
|
-
"module": "nodenext",
|
|
6
|
-
"rootDir": "./src",
|
|
7
|
-
"moduleResolution": "nodenext",
|
|
8
|
-
"outDir": "./dist",
|
|
9
|
-
"sourceRoot": "./src",
|
|
10
|
-
"lib": ["ESNext"],
|
|
11
|
-
/* Visit https://aka.ms/tsconfig.json to read more about this file */
|
|
12
|
-
|
|
13
|
-
/* Projects */
|
|
14
|
-
"incremental": true /* Enable incremental compilation */,
|
|
15
|
-
"composite": true /* Enable constraints that allow a TypeScript project to be used with project references. */,
|
|
16
|
-
// "tsBuildInfoFile": "./", /* Specify the folder for .tsbuildinfo incremental compilation files. */
|
|
17
|
-
// "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects */
|
|
18
|
-
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
|
|
19
|
-
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
|
|
20
|
-
|
|
21
|
-
/* Language and Environment */
|
|
22
|
-
// "jsx": "preserve", /* Specify what JSX code is generated. */
|
|
23
|
-
"experimentalDecorators": true /* Enable experimental support for TC39 stage 2 draft decorators. */,
|
|
24
|
-
"emitDecoratorMetadata": true /* Emit design-type metadata for decorated declarations in source files. */,
|
|
25
|
-
// "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h' */
|
|
26
|
-
// "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
|
|
27
|
-
// "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using `jsx: react-jsx*`.` */
|
|
28
|
-
// "reactNamespace": "", /* Specify the object invoked for `createElement`. This only applies when targeting `react` JSX emit. */
|
|
29
|
-
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
|
|
30
|
-
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
|
|
31
|
-
|
|
32
|
-
/* Modules */
|
|
33
|
-
|
|
34
|
-
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
|
|
35
|
-
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
|
|
36
|
-
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
|
|
37
|
-
// "typeRoots": [], /* Specify multiple folders that act like `./node_modules/@types`. */
|
|
38
|
-
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
|
|
39
|
-
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
|
40
|
-
"resolveJsonModule": true /* Enable importing .json files */,
|
|
41
|
-
// "noResolve": true, /* Disallow `import`s, `require`s or `<reference>`s from expanding the number of files TypeScript should add to a project. */
|
|
42
|
-
|
|
43
|
-
/* JavaScript Support */
|
|
44
|
-
"allowJs": false /* Allow JavaScript files to be a part of your program. Use the `checkJS` option to get errors from these files. */,
|
|
45
|
-
"checkJs": false /* Enable error reporting in type-checked JavaScript files. */,
|
|
46
|
-
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from `node_modules`. Only applicable with `allowJs`. */
|
|
47
|
-
|
|
48
|
-
/* Emit */
|
|
49
|
-
"declaration": true /* Generate .d.ts files from TypeScript and JavaScript files in your project. */,
|
|
50
|
-
"declarationMap": true /* Create sourcemaps for d.ts files. */,
|
|
51
|
-
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
|
|
52
|
-
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
|
|
53
|
-
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If `declaration` is true, also designates a file that bundles all .d.ts output. */
|
|
54
|
-
|
|
55
|
-
// "removeComments": true, /* Disable emitting comments. */
|
|
56
|
-
// "noEmit": true, /* Disable emitting files from a compilation. */
|
|
57
|
-
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
|
|
58
|
-
// "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types */
|
|
59
|
-
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
|
|
60
|
-
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
|
61
|
-
"inlineSourceMap": true /* Include sourcemap files inside the emitted JavaScript. */,
|
|
62
|
-
"inlineSources": true /* Include source code in the sourcemaps inside the emitted JavaScript. */,
|
|
63
|
-
// "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
|
|
64
|
-
// "newLine": "crlf", /* Set the newline character for emitting files. */
|
|
65
|
-
// "stripInternal": true, /* Disable emitting declarations that have `@internal` in their JSDoc comments. */
|
|
66
|
-
// "noEmitHelpers": true, /* Disable generating custom helper functions like `__extends` in compiled output. */
|
|
67
|
-
// "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
|
|
68
|
-
// "preserveConstEnums": true, /* Disable erasing `const enum` declarations in generated code. */
|
|
69
|
-
// "declarationDir": "./", /* Specify the output directory for generated declaration files. */
|
|
70
|
-
|
|
71
|
-
/* Interop Constraints */
|
|
72
|
-
// "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
|
|
73
|
-
"allowSyntheticDefaultImports": true /* Allow 'import x from y' when a module doesn't have a default export. */,
|
|
74
|
-
"esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables `allowSyntheticDefaultImports` for type compatibility. */,
|
|
75
|
-
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
|
|
76
|
-
"forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
|
|
77
|
-
|
|
78
|
-
/* Type Checking */
|
|
79
|
-
"strict": true /* Enable all strict type-checking options. */,
|
|
80
|
-
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied `any` type.. */
|
|
81
|
-
// "strictNullChecks": true, /* When type checking, take into account `null` and `undefined`. */
|
|
82
|
-
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
|
|
83
|
-
// "strictBindCallApply": true, /* Check that the arguments for `bind`, `call`, and `apply` methods match the original function. */
|
|
84
|
-
// "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
|
|
85
|
-
// "noImplicitThis": true, /* Enable error reporting when `this` is given the type `any`. */
|
|
86
|
-
// "useUnknownInCatchVariables": true, /* Type catch clause variables as 'unknown' instead of 'any'. */
|
|
87
|
-
// "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
|
|
88
|
-
// "noUnusedLocals": true, /* Enable error reporting when a local variables aren't read. */
|
|
89
|
-
// "noUnusedParameters": true, /* Raise an error when a function parameter isn't read */
|
|
90
|
-
// "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
|
|
91
|
-
// "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
|
|
92
|
-
// "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
|
|
93
|
-
// "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */
|
|
94
|
-
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
|
|
95
|
-
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type */
|
|
96
|
-
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
|
|
97
|
-
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
|
|
98
|
-
|
|
99
|
-
/* Completeness */
|
|
100
|
-
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
|
|
101
|
-
"skipLibCheck": true,
|
|
102
|
-
"jsx": "react-jsx"
|
|
103
|
-
}
|
|
104
|
-
}
|