@askdb/mysql 0.1.0-beta.2 → 0.1.0-beta.20
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/NOTICE +10 -0
- package/README.md +30 -3
- package/dist/connector/describe.d.ts +79 -67
- package/dist/connector/describe.d.ts.map +1 -1
- package/dist/connector/describe.js +169 -167
- package/dist/connector/describe.js.map +1 -1
- package/dist/connector/provider.d.ts +2 -0
- package/dist/connector/provider.d.ts.map +1 -0
- package/dist/connector/provider.js +19 -0
- package/dist/connector/provider.js.map +1 -0
- package/dist/exec/mysql.d.ts +9 -3
- package/dist/exec/mysql.d.ts.map +1 -1
- package/dist/exec/mysql.js +20 -17
- package/dist/exec/mysql.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/label.d.ts +17 -0
- package/dist/label.d.ts.map +1 -0
- package/dist/label.js +37 -0
- package/dist/label.js.map +1 -0
- package/package.json +11 -9
- package/dist/connector/glob.d.ts +0 -3
- package/dist/connector/glob.d.ts.map +0 -1
- package/dist/connector/glob.js +0 -27
- package/dist/connector/glob.js.map +0 -1
- package/dist/connector/ids.d.ts +0 -9
- package/dist/connector/ids.d.ts.map +0 -1
- package/dist/connector/ids.js +0 -13
- package/dist/connector/ids.js.map +0 -1
package/NOTICE
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
AskDB
|
|
2
|
+
Copyright 2026 Yahya Gilany
|
|
3
|
+
|
|
4
|
+
This product includes software developed by Yahya Gilany and contributors.
|
|
5
|
+
|
|
6
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
you may not use this file except in compliance with the License.
|
|
8
|
+
You may obtain a copy of the License at
|
|
9
|
+
|
|
10
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
package/README.md
CHANGED
|
@@ -9,15 +9,24 @@ MySQL / MariaDB integration for AskDB. Bundles three pieces:
|
|
|
9
9
|
## Install
|
|
10
10
|
|
|
11
11
|
```bash
|
|
12
|
-
pnpm add @askdb/core @askdb/introspect @askdb/mysql
|
|
12
|
+
pnpm add @askdb/core @askdb/introspect @askdb/mysql ai
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
+
`ai` (Vercel AI SDK 6 or 7) is a required peer dependency of `@askdb/core`; your app owns its version.
|
|
16
|
+
|
|
15
17
|
`mysql2` is an **optional peer dependency** — install it only when using live introspection mode:
|
|
16
18
|
|
|
17
19
|
```bash
|
|
18
20
|
pnpm add mysql2
|
|
19
21
|
```
|
|
20
22
|
|
|
23
|
+
For one-off CLI introspection, include the driver in the same ephemeral command:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
pnpm dlx -p askdb -p mysql2 askdb introspect --engine mysql --url "$MYSQL_URL"
|
|
27
|
+
npx -p askdb -p mysql2 askdb introspect --engine mysql --url "$MYSQL_URL"
|
|
28
|
+
```
|
|
29
|
+
|
|
21
30
|
## Usage
|
|
22
31
|
|
|
23
32
|
### NL→SQL
|
|
@@ -51,10 +60,28 @@ const result = await introspect(
|
|
|
51
60
|
);
|
|
52
61
|
```
|
|
53
62
|
|
|
63
|
+
By default the connector reads the connection URL's database and renders it under the `public` namespace. In that mode the connection string must name a database (`mysql://user:pass@host:3306/<database>`); introspection throws a clear error when the connection has no default database instead of returning an empty schema. To introspect several databases, list them in `filters.schemas`. Each database then becomes its own namespace, and foreign keys into another listed database keep the referenced database:
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
await introspect(
|
|
67
|
+
{
|
|
68
|
+
mode: "live",
|
|
69
|
+
runner: createMysqlCatalogQueryRunner(process.env.DATABASE_URL!),
|
|
70
|
+
filters: { schemas: ["app", "sales", "analytics"] },
|
|
71
|
+
},
|
|
72
|
+
{ outDir: "./my-app.schema", schemaId: "my-app" },
|
|
73
|
+
{ connector: createMysqlConnector() },
|
|
74
|
+
);
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
With the `askdb` CLI, set `introspection.schemas` in `askdb.config.ts`, or pass `--schemas app,sales`.
|
|
78
|
+
|
|
79
|
+
`mysqlConnectorProvider` parses a connection into display-safe parts, so a connector registry's `connectionLabel()` (and the `sourceLabel` from `resolveConnection()`) shows only the host, port and database of a `mysql://` URL, read the way `mysql2` reads it (WHATWG `URL`; `mysql://root:S3cret@db:3306/shop` → `mysql://db:3306/shop`). Anything else becomes `configured mysql connection`.
|
|
80
|
+
|
|
54
81
|
## Captured metadata
|
|
55
82
|
|
|
56
|
-
Tables, views, columns (MySQL-native type strings), primary keys, unique constraints, foreign keys (with referential actions), and indexes.
|
|
83
|
+
Tables, views, columns (MySQL-native type strings), primary keys, unique constraints, foreign keys (with referential actions), and indexes. Only the connection's database, or the databases listed in `filters.schemas`, is introspected: foreign keys that reference a table in any other database are omitted and reported as a `cross_database_fk` warning.
|
|
57
84
|
|
|
58
85
|
## License
|
|
59
86
|
|
|
60
|
-
Apache-2.0
|
|
87
|
+
Apache-2.0 © [Yahya Gilany](https://yahyagilany.io). See [LICENSE](./LICENSE) and [NOTICE](./NOTICE).
|
|
@@ -1,78 +1,90 @@
|
|
|
1
1
|
import type { CatalogQueryRunner, IntrospectionFilters, IntrospectionResult } from "@askdb/introspect";
|
|
2
|
-
import { compileTableFilters } from "./glob.js";
|
|
3
2
|
export type DescribeMysqlInput = {
|
|
4
3
|
runner: CatalogQueryRunner;
|
|
5
4
|
filters?: IntrospectionFilters;
|
|
6
5
|
/** Optional `schemaId` for the resulting `SqlSchema`. Defaults to `"introspected"`. */
|
|
7
6
|
schemaId?: string;
|
|
8
7
|
};
|
|
9
|
-
/**
|
|
8
|
+
/** The default (connection-database) catalog SQL strings the connector issues, keyed by query name. */
|
|
10
9
|
export declare const MYSQL_CATALOG_SQL: {
|
|
11
|
-
readonly tables:
|
|
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
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
10
|
+
readonly tables: `SELECT
|
|
11
|
+
table_schema AS table_schema,
|
|
12
|
+
table_name AS table_name,
|
|
13
|
+
table_type AS table_type,
|
|
14
|
+
table_comment AS table_comment
|
|
15
|
+
FROM information_schema.tables
|
|
16
|
+
WHERE ${string}
|
|
17
|
+
AND table_type IN ('BASE TABLE', 'VIEW')
|
|
18
|
+
ORDER BY table_schema, table_name`;
|
|
19
|
+
readonly columns: `SELECT
|
|
20
|
+
table_schema AS table_schema,
|
|
21
|
+
table_name AS table_name,
|
|
22
|
+
column_name AS column_name,
|
|
23
|
+
ordinal_position AS ordinal_position,
|
|
24
|
+
column_default AS column_default,
|
|
25
|
+
is_nullable AS is_nullable,
|
|
26
|
+
data_type AS data_type,
|
|
27
|
+
column_type AS column_type,
|
|
28
|
+
column_key AS column_key,
|
|
29
|
+
extra AS extra,
|
|
30
|
+
column_comment AS column_comment
|
|
31
|
+
FROM information_schema.columns
|
|
32
|
+
WHERE ${string}
|
|
33
|
+
ORDER BY table_schema, table_name, ordinal_position`;
|
|
34
|
+
readonly constraints: `SELECT
|
|
35
|
+
tc.table_schema AS table_schema,
|
|
36
|
+
tc.constraint_name AS constraint_name,
|
|
37
|
+
tc.table_name AS table_name,
|
|
38
|
+
kcu.column_name AS column_name,
|
|
39
|
+
kcu.ordinal_position AS ordinal_position,
|
|
40
|
+
tc.constraint_type AS constraint_type
|
|
41
|
+
FROM information_schema.table_constraints tc
|
|
42
|
+
JOIN information_schema.key_column_usage kcu
|
|
43
|
+
ON kcu.constraint_schema = tc.constraint_schema
|
|
44
|
+
AND kcu.constraint_name = tc.constraint_name
|
|
45
|
+
AND kcu.table_schema = tc.table_schema
|
|
46
|
+
AND kcu.table_name = tc.table_name
|
|
47
|
+
WHERE ${string}
|
|
48
|
+
AND tc.constraint_type IN ('PRIMARY KEY', 'UNIQUE')
|
|
49
|
+
ORDER BY tc.table_schema, tc.table_name, tc.constraint_name, kcu.ordinal_position`;
|
|
50
|
+
readonly foreign_keys: `SELECT
|
|
51
|
+
kcu.table_schema AS table_schema,
|
|
52
|
+
kcu.constraint_name AS constraint_name,
|
|
53
|
+
kcu.table_name AS table_name,
|
|
54
|
+
kcu.column_name AS column_name,
|
|
55
|
+
kcu.referenced_table_schema AS referenced_table_schema,
|
|
56
|
+
kcu.referenced_table_name AS referenced_table_name,
|
|
57
|
+
kcu.referenced_column_name AS referenced_column_name,
|
|
58
|
+
kcu.ordinal_position AS ordinal_position,
|
|
59
|
+
rc.update_rule AS update_rule,
|
|
60
|
+
rc.delete_rule AS delete_rule
|
|
61
|
+
FROM information_schema.key_column_usage kcu
|
|
62
|
+
JOIN information_schema.referential_constraints rc
|
|
63
|
+
ON rc.constraint_schema = kcu.constraint_schema
|
|
64
|
+
AND rc.constraint_name = kcu.constraint_name
|
|
65
|
+
WHERE ${string}
|
|
66
|
+
AND kcu.referenced_table_name IS NOT NULL
|
|
67
|
+
ORDER BY kcu.table_schema, kcu.table_name, kcu.constraint_name, kcu.ordinal_position`;
|
|
68
|
+
readonly indexes: `SELECT
|
|
69
|
+
table_schema AS table_schema,
|
|
70
|
+
table_name AS table_name,
|
|
71
|
+
index_name AS index_name,
|
|
72
|
+
column_name AS column_name,
|
|
73
|
+
seq_in_index AS seq_in_index,
|
|
74
|
+
non_unique AS non_unique,
|
|
75
|
+
index_type AS index_type
|
|
76
|
+
FROM information_schema.statistics
|
|
77
|
+
WHERE ${string}
|
|
78
|
+
AND index_name <> 'PRIMARY'
|
|
79
|
+
ORDER BY table_schema, table_name, index_name, seq_in_index`;
|
|
80
|
+
readonly views: `SELECT
|
|
81
|
+
table_schema AS table_schema,
|
|
82
|
+
table_name AS table_name,
|
|
83
|
+
view_definition AS view_definition
|
|
84
|
+
FROM information_schema.views
|
|
85
|
+
WHERE ${string}
|
|
86
|
+
ORDER BY table_schema, table_name`;
|
|
87
|
+
readonly current_database: "SELECT DATABASE() AS database_name";
|
|
63
88
|
};
|
|
64
89
|
export declare function describeMysql(input: DescribeMysqlInput): Promise<IntrospectionResult>;
|
|
65
|
-
type FoldInput = {
|
|
66
|
-
schemaId: string;
|
|
67
|
-
tableFilter: ReturnType<typeof compileTableFilters>;
|
|
68
|
-
tableRows: TableRow[];
|
|
69
|
-
columnRows: ColumnRow[];
|
|
70
|
-
constraintRows: ConstraintRow[];
|
|
71
|
-
fkRows: ForeignKeyRow[];
|
|
72
|
-
indexRows: IndexRow[];
|
|
73
|
-
viewRows: ViewRow[];
|
|
74
|
-
declaredFilters: ReadonlyArray<string>;
|
|
75
|
-
};
|
|
76
|
-
export declare function foldMysqlResult(input: FoldInput): IntrospectionResult;
|
|
77
|
-
export {};
|
|
78
90
|
//# sourceMappingURL=describe.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"describe.d.ts","sourceRoot":"","sources":["../../src/connector/describe.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAClB,oBAAoB,EACpB,mBAAmB,
|
|
1
|
+
{"version":3,"file":"describe.d.ts","sourceRoot":"","sources":["../../src/connector/describe.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAClB,oBAAoB,EACpB,mBAAmB,EAUpB,MAAM,mBAAmB,CAAC;AAkC3B,MAAM,MAAM,kBAAkB,GAAG;IAC/B,MAAM,EAAE,kBAAkB,CAAC;IAC3B,OAAO,CAAC,EAAE,oBAAoB,CAAC;IAC/B,uFAAuF;IACvF,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AA4GF,uGAAuG;AACvG,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAGpB,CAAC;AAyDX,wBAAsB,aAAa,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAsD3F"}
|
|
@@ -1,24 +1,51 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { makeColumnId, makeTableId } from "
|
|
1
|
+
import { AskDbError, SINGLE_NAMESPACE_LABEL } from "@askdb/core";
|
|
2
|
+
import { ambiguousFilterWarnings, buildOrderedGroups, byName, compileTableFilters, groupBy, makeColumnId, makeTableId, mapFkAction, rowsToRecords, } from "@askdb/introspect/kit";
|
|
3
3
|
/**
|
|
4
4
|
* MySQL doesn't have Postgres-style schemas (each "schema" is a database).
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
*
|
|
6
|
+
* - **Default (no `filters.schemas`)**: the connector reads the connection's
|
|
7
|
+
* database (`DATABASE()`) and emits it under a single namespace named
|
|
8
|
+
* `"public"`, matching `@askdb/prisma`'s convention so table ids stay stable
|
|
9
|
+
* across engines.
|
|
10
|
+
* - **Database list (`filters.schemas`)**: the connector reads every listed
|
|
11
|
+
* database (`table_schema IN (…)`) and each becomes its own namespace, named
|
|
12
|
+
* after the database. Foreign keys into another listed database keep the
|
|
13
|
+
* referenced database. `filters.excludeSchemas` removes entries from the list.
|
|
14
|
+
* `introspection.schemas` (askdb.config.ts) and
|
|
15
|
+
* `askdb introspect --schemas` both feed this list.
|
|
16
|
+
*
|
|
17
|
+
* In both modes a foreign key into a database that wasn't introspected has no
|
|
18
|
+
* target in the artifact; it is skipped and reported as a `cross_database_fk`
|
|
19
|
+
* warning.
|
|
8
20
|
*/
|
|
9
|
-
const
|
|
21
|
+
const DEFAULT_NAMESPACE = SINGLE_NAMESPACE_LABEL;
|
|
10
22
|
// information_schema is well-documented; pinning the SQL inside the package
|
|
11
|
-
// keeps the surface stable.
|
|
12
|
-
//
|
|
13
|
-
|
|
23
|
+
// keeps the surface stable. Every query is scoped by one predicate on the
|
|
24
|
+
// schema column: `= DATABASE()` by default, or `IN (?, …)` for a database list.
|
|
25
|
+
//
|
|
26
|
+
// In the default mode `DATABASE()` is NULL when the connection has no default
|
|
27
|
+
// database (e.g. `mysql://host:3306` with no path) — every catalog query would
|
|
28
|
+
// then silently match nothing, so we check it up front and fail loudly instead
|
|
29
|
+
// of emitting an empty schema.
|
|
30
|
+
const SQL_CURRENT_DATABASE = `SELECT DATABASE() AS database_name`;
|
|
31
|
+
const connectionDatabase = (column) => `${column} = DATABASE()`;
|
|
32
|
+
function listedDatabases(count) {
|
|
33
|
+
const markers = Array.from({ length: count }, () => "?").join(", ");
|
|
34
|
+
return (column) => `${column} IN (${markers})`;
|
|
35
|
+
}
|
|
36
|
+
function catalogSql(scope) {
|
|
37
|
+
return {
|
|
38
|
+
tables: `SELECT
|
|
39
|
+
table_schema AS table_schema,
|
|
14
40
|
table_name AS table_name,
|
|
15
41
|
table_type AS table_type,
|
|
16
42
|
table_comment AS table_comment
|
|
17
43
|
FROM information_schema.tables
|
|
18
|
-
WHERE table_schema
|
|
44
|
+
WHERE ${scope("table_schema")}
|
|
19
45
|
AND table_type IN ('BASE TABLE', 'VIEW')
|
|
20
|
-
ORDER BY table_name
|
|
21
|
-
|
|
46
|
+
ORDER BY table_schema, table_name`,
|
|
47
|
+
columns: `SELECT
|
|
48
|
+
table_schema AS table_schema,
|
|
22
49
|
table_name AS table_name,
|
|
23
50
|
column_name AS column_name,
|
|
24
51
|
ordinal_position AS ordinal_position,
|
|
@@ -30,9 +57,10 @@ const SQL_COLUMNS = `SELECT
|
|
|
30
57
|
extra AS extra,
|
|
31
58
|
column_comment AS column_comment
|
|
32
59
|
FROM information_schema.columns
|
|
33
|
-
WHERE table_schema
|
|
34
|
-
ORDER BY table_name, ordinal_position
|
|
35
|
-
|
|
60
|
+
WHERE ${scope("table_schema")}
|
|
61
|
+
ORDER BY table_schema, table_name, ordinal_position`,
|
|
62
|
+
constraints: `SELECT
|
|
63
|
+
tc.table_schema AS table_schema,
|
|
36
64
|
tc.constraint_name AS constraint_name,
|
|
37
65
|
tc.table_name AS table_name,
|
|
38
66
|
kcu.column_name AS column_name,
|
|
@@ -42,14 +70,17 @@ FROM information_schema.table_constraints tc
|
|
|
42
70
|
JOIN information_schema.key_column_usage kcu
|
|
43
71
|
ON kcu.constraint_schema = tc.constraint_schema
|
|
44
72
|
AND kcu.constraint_name = tc.constraint_name
|
|
73
|
+
AND kcu.table_schema = tc.table_schema
|
|
45
74
|
AND kcu.table_name = tc.table_name
|
|
46
|
-
WHERE tc.table_schema
|
|
75
|
+
WHERE ${scope("tc.table_schema")}
|
|
47
76
|
AND tc.constraint_type IN ('PRIMARY KEY', 'UNIQUE')
|
|
48
|
-
ORDER BY tc.table_name, tc.constraint_name, kcu.ordinal_position
|
|
49
|
-
|
|
77
|
+
ORDER BY tc.table_schema, tc.table_name, tc.constraint_name, kcu.ordinal_position`,
|
|
78
|
+
foreign_keys: `SELECT
|
|
79
|
+
kcu.table_schema AS table_schema,
|
|
50
80
|
kcu.constraint_name AS constraint_name,
|
|
51
81
|
kcu.table_name AS table_name,
|
|
52
82
|
kcu.column_name AS column_name,
|
|
83
|
+
kcu.referenced_table_schema AS referenced_table_schema,
|
|
53
84
|
kcu.referenced_table_name AS referenced_table_name,
|
|
54
85
|
kcu.referenced_column_name AS referenced_column_name,
|
|
55
86
|
kcu.ordinal_position AS ordinal_position,
|
|
@@ -59,10 +90,11 @@ FROM information_schema.key_column_usage kcu
|
|
|
59
90
|
JOIN information_schema.referential_constraints rc
|
|
60
91
|
ON rc.constraint_schema = kcu.constraint_schema
|
|
61
92
|
AND rc.constraint_name = kcu.constraint_name
|
|
62
|
-
WHERE kcu.table_schema
|
|
93
|
+
WHERE ${scope("kcu.table_schema")}
|
|
63
94
|
AND kcu.referenced_table_name IS NOT NULL
|
|
64
|
-
ORDER BY kcu.table_name, kcu.constraint_name, kcu.ordinal_position
|
|
65
|
-
|
|
95
|
+
ORDER BY kcu.table_schema, kcu.table_name, kcu.constraint_name, kcu.ordinal_position`,
|
|
96
|
+
indexes: `SELECT
|
|
97
|
+
table_schema AS table_schema,
|
|
66
98
|
table_name AS table_name,
|
|
67
99
|
index_name AS index_name,
|
|
68
100
|
column_name AS column_name,
|
|
@@ -70,51 +102,63 @@ const SQL_INDEXES = `SELECT
|
|
|
70
102
|
non_unique AS non_unique,
|
|
71
103
|
index_type AS index_type
|
|
72
104
|
FROM information_schema.statistics
|
|
73
|
-
WHERE table_schema
|
|
105
|
+
WHERE ${scope("table_schema")}
|
|
74
106
|
AND index_name <> 'PRIMARY'
|
|
75
|
-
ORDER BY table_name, index_name, seq_in_index
|
|
76
|
-
|
|
107
|
+
ORDER BY table_schema, table_name, index_name, seq_in_index`,
|
|
108
|
+
views: `SELECT
|
|
109
|
+
table_schema AS table_schema,
|
|
77
110
|
table_name AS table_name,
|
|
78
111
|
view_definition AS view_definition
|
|
79
112
|
FROM information_schema.views
|
|
80
|
-
WHERE table_schema
|
|
81
|
-
ORDER BY table_name
|
|
82
|
-
|
|
113
|
+
WHERE ${scope("table_schema")}
|
|
114
|
+
ORDER BY table_schema, table_name`,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
/** The default (connection-database) catalog SQL strings the connector issues, keyed by query name. */
|
|
83
118
|
export const MYSQL_CATALOG_SQL = {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
constraints: SQL_CONSTRAINTS,
|
|
87
|
-
foreign_keys: SQL_FOREIGN_KEYS,
|
|
88
|
-
indexes: SQL_INDEXES,
|
|
89
|
-
views: SQL_VIEWS,
|
|
119
|
+
current_database: SQL_CURRENT_DATABASE,
|
|
120
|
+
...catalogSql(connectionDatabase),
|
|
90
121
|
};
|
|
91
122
|
export async function describeMysql(input) {
|
|
92
123
|
const runner = input.runner;
|
|
93
124
|
const tableFilter = compileTableFilters(input.filters?.tables);
|
|
94
|
-
const
|
|
95
|
-
|
|
96
|
-
|
|
125
|
+
const excluded = new Set(input.filters?.excludeSchemas ?? []);
|
|
126
|
+
const databases = [...new Set(input.filters?.schemas ?? [])].filter((d) => d && !excluded.has(d));
|
|
127
|
+
const listed = (input.filters?.schemas?.length ?? 0) > 0;
|
|
128
|
+
const sql = listed ? catalogSql(listedDatabases(databases.length)) : MYSQL_CATALOG_SQL;
|
|
129
|
+
const params = listed ? databases : undefined;
|
|
130
|
+
const run = async (query) => {
|
|
131
|
+
// Every listed database was excluded: nothing to read.
|
|
132
|
+
if (listed && databases.length === 0)
|
|
97
133
|
return [];
|
|
98
|
-
|
|
99
|
-
for (let i = 0; i < result.columns.length; i++)
|
|
100
|
-
idx.set(result.columns[i], i);
|
|
101
|
-
return result.rows.map((row) => {
|
|
102
|
-
const record = {};
|
|
103
|
-
for (const [name, i] of idx)
|
|
104
|
-
record[name] = row[i];
|
|
105
|
-
return record;
|
|
106
|
-
});
|
|
134
|
+
return rowsToRecords(await runner(query, params));
|
|
107
135
|
};
|
|
136
|
+
// The default mode reads the connection's database; a database list names its own.
|
|
137
|
+
if (!listed) {
|
|
138
|
+
const [current] = await run(SQL_CURRENT_DATABASE);
|
|
139
|
+
if (!current?.database_name) {
|
|
140
|
+
throw new AskDbError("MySQL introspection needs a target database, but the connection has none selected " +
|
|
141
|
+
"(DATABASE() is NULL). Put the database name in the connection URL path, e.g. " +
|
|
142
|
+
"mysql://user:password@host:3306/<database>, or list databases with " +
|
|
143
|
+
"`introspection.schemas` / `--schemas`.");
|
|
144
|
+
}
|
|
145
|
+
}
|
|
108
146
|
const [tableRows, columnRows, constraintRows, fkRows, indexRows, viewRows] = await Promise.all([
|
|
109
|
-
run(
|
|
110
|
-
run(
|
|
111
|
-
run(
|
|
112
|
-
run(
|
|
113
|
-
run(
|
|
114
|
-
run(
|
|
147
|
+
run(sql.tables),
|
|
148
|
+
run(sql.columns),
|
|
149
|
+
run(sql.constraints),
|
|
150
|
+
run(sql.foreign_keys),
|
|
151
|
+
run(sql.indexes),
|
|
152
|
+
run(sql.views),
|
|
115
153
|
]);
|
|
154
|
+
const readDatabases = new Set(tableRows.map((row) => row.table_schema));
|
|
116
155
|
return foldMysqlResult({
|
|
117
156
|
schemaId: input.schemaId ?? "introspected",
|
|
157
|
+
namespaceOf: listed ? (database) => database : () => DEFAULT_NAMESPACE,
|
|
158
|
+
// The databases the catalog returned rows for, spelled as the catalog spells
|
|
159
|
+
// them: with case-insensitive names (lower_case_table_names 1 or 2),
|
|
160
|
+
// `--schemas Shop` reads the database stored as `shop`.
|
|
161
|
+
isIntrospected: listed ? (database) => readDatabases.has(database) : undefined,
|
|
118
162
|
tableFilter,
|
|
119
163
|
tableRows,
|
|
120
164
|
columnRows,
|
|
@@ -125,89 +169,88 @@ export async function describeMysql(input) {
|
|
|
125
169
|
declaredFilters: input.filters?.tables ?? [],
|
|
126
170
|
});
|
|
127
171
|
}
|
|
128
|
-
|
|
172
|
+
/** Grouping key for a table: database + name, so equal table names in two databases stay apart. */
|
|
173
|
+
function tableKey(row) {
|
|
174
|
+
return `${row.table_schema}\u0000${row.table_name}`;
|
|
175
|
+
}
|
|
176
|
+
function foldMysqlResult(input) {
|
|
129
177
|
const warnings = [];
|
|
130
|
-
const columnsByTable = groupBy(input.columnRows,
|
|
131
|
-
const constraintsByTable = groupBy(input.constraintRows,
|
|
132
|
-
const fksByTable = groupBy(input.fkRows,
|
|
133
|
-
const indexesByTable = groupBy(input.indexRows,
|
|
134
|
-
const
|
|
178
|
+
const columnsByTable = groupBy(input.columnRows, tableKey);
|
|
179
|
+
const constraintsByTable = groupBy(input.constraintRows, tableKey);
|
|
180
|
+
const fksByTable = groupBy(input.fkRows, tableKey);
|
|
181
|
+
const indexesByTable = groupBy(input.indexRows, tableKey);
|
|
182
|
+
const viewDefByTable = new Map();
|
|
135
183
|
for (const v of input.viewRows) {
|
|
136
184
|
if (v.view_definition)
|
|
137
|
-
|
|
185
|
+
viewDefByTable.set(tableKey(v), v.view_definition);
|
|
138
186
|
}
|
|
139
|
-
const
|
|
140
|
-
const
|
|
187
|
+
const namespaces = new Map();
|
|
188
|
+
const namespaceFor = (name) => {
|
|
189
|
+
let ns = namespaces.get(name);
|
|
190
|
+
if (!ns) {
|
|
191
|
+
ns = { name, tables: [], views: [], enums: [], sequences: [] };
|
|
192
|
+
namespaces.set(name, ns);
|
|
193
|
+
}
|
|
194
|
+
return ns;
|
|
195
|
+
};
|
|
141
196
|
const viewDefinitions = {};
|
|
142
197
|
for (const t of input.tableRows) {
|
|
143
|
-
const
|
|
144
|
-
if (!input.tableFilter(
|
|
198
|
+
const namespace = input.namespaceOf(t.table_schema);
|
|
199
|
+
if (!input.tableFilter(`${namespace}.${t.table_name}`))
|
|
145
200
|
continue;
|
|
146
|
-
const
|
|
201
|
+
const key = tableKey(t);
|
|
202
|
+
const cols = (columnsByTable.get(key) ?? [])
|
|
147
203
|
.slice()
|
|
148
204
|
.sort((a, b) => a.ordinal_position - b.ordinal_position);
|
|
149
|
-
const constraints = constraintsByTable.get(
|
|
205
|
+
const constraints = constraintsByTable.get(key) ?? [];
|
|
150
206
|
const pkRows = constraints
|
|
151
207
|
.filter((c) => c.constraint_type === "PRIMARY KEY")
|
|
152
208
|
.sort((a, b) => a.ordinal_position - b.ordinal_position);
|
|
153
209
|
const pkColumns = pkRows.map((r) => r.column_name);
|
|
154
210
|
const pkSet = new Set(pkColumns);
|
|
155
|
-
const columns = cols.map((c) => buildColumn(t.table_name, c, pkSet));
|
|
211
|
+
const columns = cols.map((c) => buildColumn(namespace, t.table_name, c, pkSet));
|
|
156
212
|
if (t.table_type === "VIEW") {
|
|
157
|
-
const def =
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
name: t.table_name,
|
|
161
|
-
definition: def,
|
|
162
|
-
columns,
|
|
163
|
-
};
|
|
164
|
-
views.push(view);
|
|
165
|
-
viewDefinitions[makeTableId(NAMESPACE, t.table_name)] = def;
|
|
213
|
+
const def = viewDefByTable.get(key) ?? "";
|
|
214
|
+
namespaceFor(namespace).views.push({ schema: namespace, name: t.table_name, definition: def, columns });
|
|
215
|
+
viewDefinitions[makeTableId(namespace, t.table_name)] = def;
|
|
166
216
|
continue;
|
|
167
217
|
}
|
|
168
|
-
tables.push({
|
|
169
|
-
id: makeTableId(
|
|
170
|
-
schema:
|
|
218
|
+
namespaceFor(namespace).tables.push({
|
|
219
|
+
id: makeTableId(namespace, t.table_name),
|
|
220
|
+
schema: namespace,
|
|
171
221
|
name: t.table_name,
|
|
172
222
|
comment: t.table_comment ?? undefined,
|
|
173
223
|
columns,
|
|
174
224
|
primaryKey: pkColumns.length > 0 ? { columns: pkColumns } : undefined,
|
|
175
|
-
foreignKeys: buildForeignKeys(fksByTable.get(
|
|
225
|
+
foreignKeys: buildForeignKeys(fksByTable.get(key) ?? [], input, warnings),
|
|
176
226
|
uniqueConstraints: buildUniques(constraints),
|
|
177
|
-
indexes: buildIndexes(indexesByTable.get(
|
|
227
|
+
indexes: buildIndexes(indexesByTable.get(key) ?? []),
|
|
178
228
|
checkConstraints: [],
|
|
179
229
|
});
|
|
180
230
|
}
|
|
181
231
|
// Sort for deterministic output.
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
tables,
|
|
187
|
-
views,
|
|
188
|
-
enums: [],
|
|
189
|
-
sequences: [],
|
|
190
|
-
};
|
|
191
|
-
const isEmpty = tables.length === 0 && views.length === 0;
|
|
192
|
-
for (const pattern of input.declaredFilters) {
|
|
193
|
-
const matched = tables.some((t) => compileTableFilters([pattern])(`${NAMESPACE}.${t.name}`)) ||
|
|
194
|
-
views.some((v) => compileTableFilters([pattern])(`${NAMESPACE}.${v.name}`));
|
|
195
|
-
if (!matched)
|
|
196
|
-
warnings.push({ code: "ambiguous_filter", filter: pattern });
|
|
232
|
+
const sortedNamespaces = [...namespaces.values()].sort(byName);
|
|
233
|
+
for (const ns of sortedNamespaces) {
|
|
234
|
+
ns.tables.sort(byName);
|
|
235
|
+
ns.views.sort(byName);
|
|
197
236
|
}
|
|
237
|
+
const allTables = sortedNamespaces.flatMap((ns) => ns.tables);
|
|
238
|
+
const allViews = sortedNamespaces.flatMap((ns) => ns.views);
|
|
239
|
+
const isEmpty = allTables.length === 0 && allViews.length === 0;
|
|
240
|
+
warnings.push(...ambiguousFilterWarnings(input.declaredFilters, [...allTables, ...allViews].map((t) => `${t.schema}.${t.name}`)));
|
|
198
241
|
const schema = {
|
|
199
242
|
schemaId: input.schemaId,
|
|
200
|
-
schemas: isEmpty ? [] :
|
|
243
|
+
schemas: isEmpty ? [] : sortedNamespaces,
|
|
201
244
|
};
|
|
202
245
|
return { schema, warnings, isEmpty, viewDefinitions, provider: "mysql" };
|
|
203
246
|
}
|
|
204
|
-
function buildColumn(table, c, pkSet) {
|
|
247
|
+
function buildColumn(namespace, table, c, pkSet) {
|
|
205
248
|
// `column_type` carries width/unsigned/enum-values info (e.g. `enum('a','b')`,
|
|
206
249
|
// `int(10) unsigned`); `data_type` is the bare type. Prefer `column_type` for
|
|
207
250
|
// accuracy in the NL→SQL prompt, fall back to `data_type`.
|
|
208
251
|
const dataType = c.column_type ?? c.data_type;
|
|
209
252
|
return {
|
|
210
|
-
id: makeColumnId(
|
|
253
|
+
id: makeColumnId(namespace, table, c.column_name),
|
|
211
254
|
name: c.column_name,
|
|
212
255
|
ordinalPosition: c.ordinal_position,
|
|
213
256
|
dataType,
|
|
@@ -219,72 +262,44 @@ function buildColumn(table, c, pkSet) {
|
|
|
219
262
|
};
|
|
220
263
|
}
|
|
221
264
|
function buildUniques(constraints) {
|
|
222
|
-
|
|
223
|
-
for (const c of constraints) {
|
|
224
|
-
if (c.constraint_type !== "UNIQUE")
|
|
225
|
-
continue;
|
|
226
|
-
const list = byName.get(c.constraint_name) ?? [];
|
|
227
|
-
list.push(c);
|
|
228
|
-
byName.set(c.constraint_name, list);
|
|
229
|
-
}
|
|
230
|
-
return Array.from(byName, ([name, list]) => ({
|
|
231
|
-
name,
|
|
232
|
-
columns: list
|
|
233
|
-
.slice()
|
|
234
|
-
.sort((a, b) => a.ordinal_position - b.ordinal_position)
|
|
235
|
-
.map((r) => r.column_name),
|
|
236
|
-
})).sort((a, b) => a.name.localeCompare(b.name));
|
|
265
|
+
return buildOrderedGroups(constraints.filter((c) => c.constraint_type === "UNIQUE"), (c) => c.constraint_name, (c) => c.ordinal_position, (name, ordered) => ({ name, columns: ordered.map((r) => r.column_name) }));
|
|
237
266
|
}
|
|
238
|
-
function buildForeignKeys(rows) {
|
|
239
|
-
|
|
240
|
-
for (const r of rows) {
|
|
241
|
-
const list = byName.get(r.constraint_name) ?? [];
|
|
242
|
-
list.push(r);
|
|
243
|
-
byName.set(r.constraint_name, list);
|
|
244
|
-
}
|
|
245
|
-
const fks = [];
|
|
246
|
-
for (const [name, list] of byName) {
|
|
247
|
-
const ordered = list.slice().sort((a, b) => a.ordinal_position - b.ordinal_position);
|
|
267
|
+
function buildForeignKeys(rows, input, warnings) {
|
|
268
|
+
return buildOrderedGroups(rows, (r) => r.constraint_name, (r) => r.ordinal_position, (name, ordered) => {
|
|
248
269
|
const sample = ordered[0];
|
|
249
|
-
|
|
270
|
+
const referencedDatabase = sample.referenced_table_schema ?? sample.table_schema;
|
|
271
|
+
const introspected = input.isIntrospected
|
|
272
|
+
? input.isIntrospected(referencedDatabase)
|
|
273
|
+
: referencedDatabase === sample.table_schema;
|
|
274
|
+
// A FK into a database that wasn't introspected has no target in the
|
|
275
|
+
// artifact. Rendering it (e.g. as `public.<table>` in the default mode)
|
|
276
|
+
// would point at the wrong (or a missing) table — skip it and say so.
|
|
277
|
+
if (!introspected) {
|
|
278
|
+
warnings.push({
|
|
279
|
+
code: "cross_database_fk",
|
|
280
|
+
table: makeTableId(input.namespaceOf(sample.table_schema), sample.table_name),
|
|
281
|
+
constraint: name,
|
|
282
|
+
referencedDatabase,
|
|
283
|
+
referencedTable: sample.referenced_table_name,
|
|
284
|
+
});
|
|
285
|
+
return undefined;
|
|
286
|
+
}
|
|
287
|
+
return {
|
|
250
288
|
name,
|
|
251
289
|
columns: ordered.map((r) => r.column_name),
|
|
252
290
|
references: {
|
|
253
|
-
|
|
291
|
+
// A FK into another listed database keeps that database as its namespace.
|
|
292
|
+
schema: input.namespaceOf(referencedDatabase),
|
|
254
293
|
table: sample.referenced_table_name,
|
|
255
294
|
columns: ordered.map((r) => r.referenced_column_name),
|
|
256
295
|
},
|
|
257
|
-
onDelete:
|
|
258
|
-
onUpdate:
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
return fks.sort((a, b) => a.name.localeCompare(b.name));
|
|
262
|
-
}
|
|
263
|
-
function mapAction(rule) {
|
|
264
|
-
if (!rule)
|
|
265
|
-
return undefined;
|
|
266
|
-
const r = rule.toLowerCase();
|
|
267
|
-
if (r === "cascade")
|
|
268
|
-
return "cascade";
|
|
269
|
-
if (r === "restrict")
|
|
270
|
-
return "restrict";
|
|
271
|
-
if (r === "set null")
|
|
272
|
-
return "set null";
|
|
273
|
-
if (r === "set default")
|
|
274
|
-
return "set default";
|
|
275
|
-
if (r === "no action")
|
|
276
|
-
return "no action";
|
|
277
|
-
return undefined;
|
|
296
|
+
onDelete: mapFkAction(sample.delete_rule),
|
|
297
|
+
onUpdate: mapFkAction(sample.update_rule),
|
|
298
|
+
};
|
|
299
|
+
});
|
|
278
300
|
}
|
|
279
301
|
function buildIndexes(rows) {
|
|
280
|
-
|
|
281
|
-
for (const r of rows) {
|
|
282
|
-
const list = byName.get(r.index_name) ?? [];
|
|
283
|
-
list.push(r);
|
|
284
|
-
byName.set(r.index_name, list);
|
|
285
|
-
}
|
|
286
|
-
return Array.from(byName, ([name, list]) => {
|
|
287
|
-
const ordered = list.slice().sort((a, b) => a.seq_in_index - b.seq_in_index);
|
|
302
|
+
return buildOrderedGroups(rows, (r) => r.index_name, (r) => r.seq_in_index, (name, ordered) => {
|
|
288
303
|
const sample = ordered[0];
|
|
289
304
|
return {
|
|
290
305
|
name,
|
|
@@ -292,19 +307,6 @@ function buildIndexes(rows) {
|
|
|
292
307
|
unique: sample.non_unique === 0,
|
|
293
308
|
method: sample.index_type,
|
|
294
309
|
};
|
|
295
|
-
})
|
|
296
|
-
}
|
|
297
|
-
function groupBy(rows, key) {
|
|
298
|
-
const out = new Map();
|
|
299
|
-
for (const row of rows) {
|
|
300
|
-
const k = key(row);
|
|
301
|
-
const list = out.get(k) ?? [];
|
|
302
|
-
list.push(row);
|
|
303
|
-
out.set(k, list);
|
|
304
|
-
}
|
|
305
|
-
return out;
|
|
306
|
-
}
|
|
307
|
-
function byName(a, b) {
|
|
308
|
-
return a.name.localeCompare(b.name);
|
|
310
|
+
});
|
|
309
311
|
}
|
|
310
312
|
//# sourceMappingURL=describe.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"describe.js","sourceRoot":"","sources":["../../src/connector/describe.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"describe.js","sourceRoot":"","sources":["../../src/connector/describe.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,UAAU,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACjE,OAAO,EACL,uBAAuB,EACvB,kBAAkB,EAClB,MAAM,EACN,mBAAmB,EACnB,OAAO,EACP,YAAY,EACZ,WAAW,EACX,WAAW,EACX,aAAa,GACd,MAAM,uBAAuB,CAAC;AAE/B;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,iBAAiB,GAAG,sBAAsB,CAAC;AASjD,4EAA4E;AAC5E,0EAA0E;AAC1E,gFAAgF;AAChF,EAAE;AACF,8EAA8E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AC,CAAC,CAAC,WAAW,IAAI,EAAE,CAAC;YAChD,MAAM,EAAE,MAAM,CAAC,UAAU,KAAK,CAAC;YAC/B,MAAM,EAAE,MAAM,CAAC,UAAU;SACP,CAAC;IACvB,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../src/connector/provider.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,sBAAsB,sDAcjC,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { defineLiveConnectorProvider } from "@askdb/introspect/kit";
|
|
2
|
+
import { createMysqlConnector } from "./index.js";
|
|
3
|
+
import { createMysqlCatalogQueryRunner } from "../exec/mysql.js";
|
|
4
|
+
import { parseMysqlConnection } from "../label.js";
|
|
5
|
+
export const mysqlConnectorProvider = defineLiveConnectorProvider({
|
|
6
|
+
provider: "mysql",
|
|
7
|
+
displayName: "MySQL",
|
|
8
|
+
runtimeKey: "mysqlDatabaseUrl",
|
|
9
|
+
connectionNoun: "a connection URL",
|
|
10
|
+
missingConnection: {
|
|
11
|
+
cli: "Provide --url <mysql-url> (or set introspection.providerConfig.mysql.databaseUrl / ASKDB_INTROSPECT_MYSQL_URL / DATABASE_URL).",
|
|
12
|
+
config: "No MySQL connection configured. Set introspection.providerConfig.mysql.databaseUrl in askdb.config.ts (bound to an env var in .env).",
|
|
13
|
+
},
|
|
14
|
+
fromExportUnsupported: "--from-export is currently supported only for --engine postgres (got mysql).",
|
|
15
|
+
createConnector: createMysqlConnector,
|
|
16
|
+
createRunner: (url) => createMysqlCatalogQueryRunner(url),
|
|
17
|
+
connectionLabelParts: parseMysqlConnection,
|
|
18
|
+
});
|
|
19
|
+
//# sourceMappingURL=provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../../src/connector/provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,EAAE,6BAA6B,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAEnD,MAAM,CAAC,MAAM,sBAAsB,GAAG,2BAA2B,CAAC;IAChE,QAAQ,EAAE,OAAO;IACjB,WAAW,EAAE,OAAO;IACpB,UAAU,EAAE,kBAAkB;IAC9B,cAAc,EAAE,kBAAkB;IAClC,iBAAiB,EAAE;QACjB,GAAG,EAAE,gIAAgI;QACrI,MAAM,EACJ,sIAAsI;KACzI;IACD,qBAAqB,EAAE,8EAA8E;IACrG,eAAe,EAAE,oBAAoB;IACrC,YAAY,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,6BAA6B,CAAC,GAAG,CAAC;IACzD,oBAAoB,EAAE,oBAAoB;CAC3C,CAAC,CAAC"}
|
package/dist/exec/mysql.d.ts
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
import type { CatalogQueryRunner } from "@askdb/introspect";
|
|
2
|
+
import { type DriverLoadOptions } from "@askdb/introspect/kit";
|
|
2
3
|
export type { CatalogQueryResult, CatalogQueryRunner } from "@askdb/introspect";
|
|
3
|
-
|
|
4
|
-
|
|
4
|
+
type Mysql2DriverModule = typeof import("mysql2/promise");
|
|
5
|
+
/**
|
|
6
|
+
* Resolve and cache the optional `mysql2` peer driver, with the same lazy-import
|
|
7
|
+
* + project-root fallback behavior as the catalog runner.
|
|
8
|
+
*/
|
|
9
|
+
export declare function loadMysql2Driver(options?: DriverLoadOptions): Promise<Mysql2DriverModule>;
|
|
10
|
+
export declare function isMysql2DriverInstalled(options?: DriverLoadOptions): boolean;
|
|
5
11
|
/**
|
|
6
12
|
* Build the built-in `mysql2`-backed catalog query runner used by live MySQL
|
|
7
13
|
* introspection. The connection string follows the standard MySQL URI form
|
|
8
14
|
* (`mysql://user:pass@host:port/database`); the named database is the target
|
|
9
15
|
* namespace for introspection.
|
|
10
16
|
*/
|
|
11
|
-
export declare function createMysqlCatalogQueryRunner(connectionString: string): CatalogQueryRunner;
|
|
17
|
+
export declare function createMysqlCatalogQueryRunner(connectionString: string, options?: DriverLoadOptions): CatalogQueryRunner;
|
|
12
18
|
//# sourceMappingURL=mysql.d.ts.map
|
package/dist/exec/mysql.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mysql.d.ts","sourceRoot":"","sources":["../../src/exec/mysql.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAsB,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"mysql.d.ts","sourceRoot":"","sources":["../../src/exec/mysql.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAsB,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAChF,OAAO,EAKL,KAAK,iBAAiB,EACvB,MAAM,uBAAuB,CAAC;AAE/B,YAAY,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAchF,KAAK,kBAAkB,GAAG,cAAc,gBAAgB,CAAC,CAAC;AAE1D;;;GAGG;AACH,wBAAsB,gBAAgB,CAAC,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAG/F;AAED,wBAAgB,uBAAuB,CAAC,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAE5E;AA+BD;;;;;GAKG;AACH,wBAAgB,6BAA6B,CAC3C,gBAAgB,EAAE,MAAM,EACxB,OAAO,CAAC,EAAE,iBAAiB,GAC1B,kBAAkB,CAEpB"}
|
package/dist/exec/mysql.js
CHANGED
|
@@ -1,26 +1,29 @@
|
|
|
1
1
|
import { AskDbError } from "@askdb/core";
|
|
2
|
+
import { createOptionalDriverLoader, rethrowDriverImportError, isDriverInstalled, missingDriverMessage, } from "@askdb/introspect/kit";
|
|
2
3
|
/**
|
|
3
4
|
* Lazily resolve the optional `mysql2` peer dependency. Mirrors the pattern in
|
|
4
5
|
* `@askdb/postgres` so consumers with a custom `CatalogQueryRunner` can use
|
|
5
6
|
* `@askdb/mysql` without installing `mysql2`.
|
|
6
7
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
8
|
+
const mysql2Loader = createOptionalDriverLoader({
|
|
9
|
+
packageName: "mysql2",
|
|
10
|
+
specifier: "mysql2/promise",
|
|
11
|
+
importDriver: () => import("mysql2/promise").catch(rethrowDriverImportError),
|
|
12
|
+
missingMessage: missingDriverMessage({ engine: "MySQL", packageName: "mysql2" }),
|
|
13
|
+
});
|
|
14
|
+
/**
|
|
15
|
+
* Resolve and cache the optional `mysql2` peer driver, with the same lazy-import
|
|
16
|
+
* + project-root fallback behavior as the catalog runner.
|
|
17
|
+
*/
|
|
18
|
+
export async function loadMysql2Driver(options) {
|
|
19
|
+
const mod = await mysql2Loader.load(options);
|
|
20
|
+
return mod.default ?? mod;
|
|
17
21
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
mysql2ModulePromise = undefined;
|
|
22
|
+
export function isMysql2DriverInstalled(options) {
|
|
23
|
+
return isDriverInstalled("mysql2", options);
|
|
21
24
|
}
|
|
22
|
-
async function runMysqlCatalogQuery(connectionString, sql, params) {
|
|
23
|
-
const mod = await
|
|
25
|
+
async function runMysqlCatalogQuery(connectionString, sql, params, options) {
|
|
26
|
+
const mod = await mysql2Loader.load(options);
|
|
24
27
|
const mysql = mod.default ?? mod;
|
|
25
28
|
const connection = await mysql.createConnection(connectionString);
|
|
26
29
|
try {
|
|
@@ -48,7 +51,7 @@ async function runMysqlCatalogQuery(connectionString, sql, params) {
|
|
|
48
51
|
* (`mysql://user:pass@host:port/database`); the named database is the target
|
|
49
52
|
* namespace for introspection.
|
|
50
53
|
*/
|
|
51
|
-
export function createMysqlCatalogQueryRunner(connectionString) {
|
|
52
|
-
return (sql, params) => runMysqlCatalogQuery(connectionString, sql, params);
|
|
54
|
+
export function createMysqlCatalogQueryRunner(connectionString, options) {
|
|
55
|
+
return (sql, params) => runMysqlCatalogQuery(connectionString, sql, params, options);
|
|
53
56
|
}
|
|
54
57
|
//# sourceMappingURL=mysql.js.map
|
package/dist/exec/mysql.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mysql.js","sourceRoot":"","sources":["../../src/exec/mysql.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"mysql.js","sourceRoot":"","sources":["../../src/exec/mysql.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EACL,0BAA0B,EAC1B,wBAAwB,EACxB,iBAAiB,EACjB,oBAAoB,GAErB,MAAM,uBAAuB,CAAC;AAI/B;;;;GAIG;AACH,MAAM,YAAY,GAAG,0BAA0B,CAAkC;IAC/E,WAAW,EAAE,QAAQ;IACrB,SAAS,EAAE,gBAAgB;IAC3B,YAAY,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC,KAAK,CAAC,wBAAwB,CAAC;IAC5E,cAAc,EAAE,oBAAoB,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC;CACjF,CAAC,CAAC;AAIH;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,OAA2B;IAChE,MAAM,GAAG,GAAG,MAAM,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC7C,OAAQ,GAAmD,CAAC,OAAO,IAAI,GAAG,CAAC;AAC7E,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,OAA2B;IACjE,OAAO,iBAAiB,CAAC,QAAQ,EAA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AM,CAAC,CAAC,CAAC,CAAC;QAC3D,MAAM,IAAI,UAAU,CAAC,+BAA+B,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;IACpE,CAAC;YAAS,CAAC;QACT,MAAM,UAAU,CAAC,GAAG,EAAE,CAAC;IACzB,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,6BAA6B,CAC3C,gBAAwB,EACxB,OAA2B;IAE3B,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,CAAC,oBAAoB,CAAC,gBAAgB,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;AACvF,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -7,5 +7,6 @@
|
|
|
7
7
|
*/
|
|
8
8
|
export { MYSQL_DIALECT, MARIADB_DIALECT, type DialectSpec as MysqlDialect, } from "@askdb/core";
|
|
9
9
|
export { createMysqlConnector, describeMysql, MYSQL_CATALOG_SQL, type DescribeMysqlInput, type MysqlIntrospectionInput, } from "./connector/index.js";
|
|
10
|
-
export { createMysqlCatalogQueryRunner, type CatalogQueryResult, type CatalogQueryRunner, } from "./exec/mysql.js";
|
|
10
|
+
export { createMysqlCatalogQueryRunner, loadMysql2Driver, isMysql2DriverInstalled, type CatalogQueryResult, type CatalogQueryRunner, } from "./exec/mysql.js";
|
|
11
|
+
export { mysqlConnectorProvider } from "./connector/provider.js";
|
|
11
12
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,aAAa,EACb,eAAe,EACf,KAAK,WAAW,IAAI,YAAY,GACjC,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,oBAAoB,EACpB,aAAa,EACb,iBAAiB,EACjB,KAAK,kBAAkB,EACvB,KAAK,uBAAuB,GAC7B,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,6BAA6B,EAC7B,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,GACxB,MAAM,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,aAAa,EACb,eAAe,EACf,KAAK,WAAW,IAAI,YAAY,GACjC,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,oBAAoB,EACpB,aAAa,EACb,iBAAiB,EACjB,KAAK,kBAAkB,EACvB,KAAK,uBAAuB,GAC7B,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,6BAA6B,EAC7B,gBAAgB,EAChB,uBAAuB,EACvB,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,GACxB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -7,5 +7,6 @@
|
|
|
7
7
|
*/
|
|
8
8
|
export { MYSQL_DIALECT, MARIADB_DIALECT, } from "@askdb/core";
|
|
9
9
|
export { createMysqlConnector, describeMysql, MYSQL_CATALOG_SQL, } from "./connector/index.js";
|
|
10
|
-
export { createMysqlCatalogQueryRunner, } from "./exec/mysql.js";
|
|
10
|
+
export { createMysqlCatalogQueryRunner, loadMysql2Driver, isMysql2DriverInstalled, } from "./exec/mysql.js";
|
|
11
|
+
export { mysqlConnectorProvider } from "./connector/provider.js";
|
|
11
12
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,aAAa,EACb,eAAe,GAEhB,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,oBAAoB,EACpB,aAAa,EACb,iBAAiB,GAGlB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,6BAA6B,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,aAAa,EACb,eAAe,GAEhB,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,oBAAoB,EACpB,aAAa,EACb,iBAAiB,GAGlB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,6BAA6B,EAC7B,gBAAgB,EAChB,uBAAuB,GAGxB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC"}
|
package/dist/label.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ConnectionLabelParts } from "@askdb/introspect/kit";
|
|
2
|
+
/**
|
|
3
|
+
* The display-safe parts of a MySQL connection string, read the way `mysql2`
|
|
4
|
+
* reads it: `ConnectionConfig.parseUrl` is WHATWG `new URL(url)` with
|
|
5
|
+
* `host = decodeURIComponent(hostname)`, `port = port`, and
|
|
6
|
+
* `database = decodeURIComponent(pathname.slice(1))`. `mysql2` itself isn't a
|
|
7
|
+
* dependency here (it is ~630 KB with seven dependencies, and an optional
|
|
8
|
+
* peer), so this uses the same built-in parser and mapping; a differential test
|
|
9
|
+
* checks it against `mysql2`'s own `parseUrl` (ADR 0011).
|
|
10
|
+
*
|
|
11
|
+
* Returns `undefined` (the registry labels it `configured mysql connection`)
|
|
12
|
+
* when `new URL` throws, when the scheme isn't `mysql:`, or when an `@` or `#`
|
|
13
|
+
* sits after the host: a password containing `/`, `?` or `#` is split there.
|
|
14
|
+
* `formatConnectionLabel`'s allowlist is the second check.
|
|
15
|
+
*/
|
|
16
|
+
export declare function parseMysqlConnection(input: string): ConnectionLabelParts | undefined;
|
|
17
|
+
//# sourceMappingURL=label.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"label.d.ts","sourceRoot":"","sources":["../src/label.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAElE;;;;;;;;;;;;;GAaG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,oBAAoB,GAAG,SAAS,CAkBpF"}
|
package/dist/label.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The display-safe parts of a MySQL connection string, read the way `mysql2`
|
|
3
|
+
* reads it: `ConnectionConfig.parseUrl` is WHATWG `new URL(url)` with
|
|
4
|
+
* `host = decodeURIComponent(hostname)`, `port = port`, and
|
|
5
|
+
* `database = decodeURIComponent(pathname.slice(1))`. `mysql2` itself isn't a
|
|
6
|
+
* dependency here (it is ~630 KB with seven dependencies, and an optional
|
|
7
|
+
* peer), so this uses the same built-in parser and mapping; a differential test
|
|
8
|
+
* checks it against `mysql2`'s own `parseUrl` (ADR 0011).
|
|
9
|
+
*
|
|
10
|
+
* Returns `undefined` (the registry labels it `configured mysql connection`)
|
|
11
|
+
* when `new URL` throws, when the scheme isn't `mysql:`, or when an `@` or `#`
|
|
12
|
+
* sits after the host: a password containing `/`, `?` or `#` is split there.
|
|
13
|
+
* `formatConnectionLabel`'s allowlist is the second check.
|
|
14
|
+
*/
|
|
15
|
+
export function parseMysqlConnection(input) {
|
|
16
|
+
let url;
|
|
17
|
+
let host;
|
|
18
|
+
let database;
|
|
19
|
+
try {
|
|
20
|
+
url = new URL(input);
|
|
21
|
+
host = decodeURIComponent(url.hostname);
|
|
22
|
+
database = decodeURIComponent(url.pathname.slice(1));
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
if (url.protocol !== "mysql:")
|
|
28
|
+
return undefined;
|
|
29
|
+
if (url.hash !== "" || `${url.pathname}${url.search}`.includes("@"))
|
|
30
|
+
return undefined;
|
|
31
|
+
return {
|
|
32
|
+
...(host !== "" ? { host } : {}),
|
|
33
|
+
...(url.port !== "" ? { port: url.port } : {}),
|
|
34
|
+
...(database !== "" ? { database } : {}),
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=label.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"label.js","sourceRoot":"","sources":["../src/label.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAa;IAChD,IAAI,GAAQ,CAAC;IACb,IAAI,IAAY,CAAC;IACjB,IAAI,QAAgB,CAAC;IACrB,IAAI,CAAC;QACH,GAAG,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC;QACrB,IAAI,GAAG,kBAAkB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QACxC,QAAQ,GAAG,kBAAkB,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IACvD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,IAAI,GAAG,CAAC,QAAQ,KAAK,QAAQ;QAAE,OAAO,SAAS,CAAC;IAChD,IAAI,GAAG,CAAC,IAAI,KAAK,EAAE,IAAI,GAAG,GAAG,CAAC,QAAQ,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC;QAAE,OAAO,SAAS,CAAC;IACtF,OAAO;QACL,GAAG,CAAC,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAChC,GAAG,CAAC,GAAG,CAAC,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC9C,GAAG,CAAC,QAAQ,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACzC,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@askdb/mysql",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.20",
|
|
4
4
|
"description": "AskDB MySQL integration: introspection connector via information_schema and a mysql2-backed catalog query runner. Pairs with @askdb/core's MYSQL_DIALECT.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"askdb",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"introspection",
|
|
13
13
|
"information-schema"
|
|
14
14
|
],
|
|
15
|
-
"homepage": "https://
|
|
15
|
+
"homepage": "https://askdb.tools/guides/switch-engines/",
|
|
16
16
|
"bugs": {
|
|
17
17
|
"url": "https://github.com/Ygilany/AskDB/issues"
|
|
18
18
|
},
|
|
@@ -24,12 +24,14 @@
|
|
|
24
24
|
"license": "Apache-2.0",
|
|
25
25
|
"author": "Yahya Gilany",
|
|
26
26
|
"type": "module",
|
|
27
|
+
"sideEffects": false,
|
|
27
28
|
"main": "./dist/index.js",
|
|
28
29
|
"types": "./dist/index.d.ts",
|
|
29
30
|
"exports": {
|
|
30
31
|
".": {
|
|
31
32
|
"types": "./dist/index.d.ts",
|
|
32
|
-
"import": "./dist/index.js"
|
|
33
|
+
"import": "./dist/index.js",
|
|
34
|
+
"default": "./dist/index.js"
|
|
33
35
|
}
|
|
34
36
|
},
|
|
35
37
|
"files": [
|
|
@@ -39,11 +41,11 @@
|
|
|
39
41
|
"NOTICE"
|
|
40
42
|
],
|
|
41
43
|
"engines": {
|
|
42
|
-
"node": ">=
|
|
44
|
+
"node": ">=22.23.4"
|
|
43
45
|
},
|
|
44
46
|
"dependencies": {
|
|
45
|
-
"@askdb/
|
|
46
|
-
"@askdb/
|
|
47
|
+
"@askdb/core": "1.0.0-beta.45",
|
|
48
|
+
"@askdb/introspect": "0.3.0-beta.19"
|
|
47
49
|
},
|
|
48
50
|
"peerDependencies": {
|
|
49
51
|
"mysql2": ">=3"
|
|
@@ -54,9 +56,9 @@
|
|
|
54
56
|
}
|
|
55
57
|
},
|
|
56
58
|
"devDependencies": {
|
|
57
|
-
"mysql2": "^3.
|
|
58
|
-
"typescript": "^
|
|
59
|
-
"vitest": "^
|
|
59
|
+
"mysql2": "^3.24.6",
|
|
60
|
+
"typescript": "^6.0.3",
|
|
61
|
+
"vitest": "^5.0.5"
|
|
60
62
|
},
|
|
61
63
|
"scripts": {
|
|
62
64
|
"build": "tsc -p tsconfig.build.json",
|
package/dist/connector/glob.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"glob.d.ts","sourceRoot":"","sources":["../../src/connector/glob.ts"],"names":[],"mappings":"AAiBA,MAAM,MAAM,WAAW,GAAG,CAAC,aAAa,EAAE,MAAM,KAAK,OAAO,CAAC;AAE7D,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,SAAS,GAC1C,WAAW,CAIb"}
|
package/dist/connector/glob.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Minimal glob matcher for `IntrospectionFilters.tables`. Matches against
|
|
3
|
-
* `"<schema>.<name>"` strings; supports `*` (any run) and `?` (single char).
|
|
4
|
-
* Identical to the postgres connector's matcher.
|
|
5
|
-
*/
|
|
6
|
-
function compileGlob(pattern) {
|
|
7
|
-
let out = "^";
|
|
8
|
-
for (const ch of pattern) {
|
|
9
|
-
if (ch === "*")
|
|
10
|
-
out += ".*";
|
|
11
|
-
else if (ch === "?")
|
|
12
|
-
out += ".";
|
|
13
|
-
else if (/[.+^${}()|[\]\\]/.test(ch))
|
|
14
|
-
out += "\\" + ch;
|
|
15
|
-
else
|
|
16
|
-
out += ch;
|
|
17
|
-
}
|
|
18
|
-
out += "$";
|
|
19
|
-
return new RegExp(out);
|
|
20
|
-
}
|
|
21
|
-
export function compileTableFilters(patterns) {
|
|
22
|
-
if (!patterns || patterns.length === 0)
|
|
23
|
-
return () => true;
|
|
24
|
-
const compiled = patterns.map(compileGlob);
|
|
25
|
-
return (qualifiedName) => compiled.some((re) => re.test(qualifiedName));
|
|
26
|
-
}
|
|
27
|
-
//# sourceMappingURL=glob.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"glob.js","sourceRoot":"","sources":["../../src/connector/glob.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,SAAS,WAAW,CAAC,OAAe;IAClC,IAAI,GAAG,GAAG,GAAG,CAAC;IACd,KAAK,MAAM,EAAE,IAAI,OAAO,EAAE,CAAC;QACzB,IAAI,EAAE,KAAK,GAAG;YAAE,GAAG,IAAI,IAAI,CAAC;aACvB,IAAI,EAAE,KAAK,GAAG;YAAE,GAAG,IAAI,GAAG,CAAC;aAC3B,IAAI,kBAAkB,CAAC,IAAI,CAAC,EAAE,CAAC;YAAE,GAAG,IAAI,IAAI,GAAG,EAAE,CAAC;;YAClD,GAAG,IAAI,EAAE,CAAC;IACjB,CAAC;IACD,GAAG,IAAI,GAAG,CAAC;IACX,OAAO,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC;AACzB,CAAC;AAID,MAAM,UAAU,mBAAmB,CACjC,QAA2C;IAE3C,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,GAAG,EAAE,CAAC,IAAI,CAAC;IAC1D,MAAM,QAAQ,GAAG,QAAQ,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IAC3C,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC;AAC1E,CAAC"}
|
package/dist/connector/ids.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Schema v2 ID conventions — kept aligned with `@askdb/postgres/connector/ids.ts`.
|
|
3
|
-
* MySQL doesn't have Postgres-style schemas, but to keep IDs stable and
|
|
4
|
-
* cross-engine queryable we always use the namespace `"public"` (the same
|
|
5
|
-
* convention `@askdb/prisma` uses for MySQL).
|
|
6
|
-
*/
|
|
7
|
-
export declare function makeTableId(schemaName: string, tableName: string): string;
|
|
8
|
-
export declare function makeColumnId(schemaName: string, tableName: string, columnName: string): string;
|
|
9
|
-
//# sourceMappingURL=ids.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ids.d.ts","sourceRoot":"","sources":["../../src/connector/ids.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAEzE;AAED,wBAAgB,YAAY,CAC1B,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,GACjB,MAAM,CAER"}
|
package/dist/connector/ids.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Schema v2 ID conventions — kept aligned with `@askdb/postgres/connector/ids.ts`.
|
|
3
|
-
* MySQL doesn't have Postgres-style schemas, but to keep IDs stable and
|
|
4
|
-
* cross-engine queryable we always use the namespace `"public"` (the same
|
|
5
|
-
* convention `@askdb/prisma` uses for MySQL).
|
|
6
|
-
*/
|
|
7
|
-
export function makeTableId(schemaName, tableName) {
|
|
8
|
-
return `table:${schemaName}.${tableName}`;
|
|
9
|
-
}
|
|
10
|
-
export function makeColumnId(schemaName, tableName, columnName) {
|
|
11
|
-
return `table:${schemaName}.${tableName}#${columnName}`;
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=ids.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ids.js","sourceRoot":"","sources":["../../src/connector/ids.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAC,UAAkB,EAAE,SAAiB;IAC/D,OAAO,SAAS,UAAU,IAAI,SAAS,EAAE,CAAC;AAC5C,CAAC;AAED,MAAM,UAAU,YAAY,CAC1B,UAAkB,EAClB,SAAiB,EACjB,UAAkB;IAElB,OAAO,SAAS,UAAU,IAAI,SAAS,IAAI,UAAU,EAAE,CAAC;AAC1D,CAAC"}
|