@aigne/afs-sqlite 1.11.0-beta → 1.11.0-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +17 -84
- package/README.md +3 -6
- package/dist/_virtual/_@oxc-project_runtime@0.108.0/helpers/decorate.cjs +11 -0
- package/dist/_virtual/_@oxc-project_runtime@0.108.0/helpers/decorate.mjs +10 -0
- package/dist/_virtual/rolldown_runtime.mjs +7 -0
- package/dist/actions/built-in.cjs +1389 -0
- package/dist/actions/built-in.d.cts +10 -0
- package/dist/actions/built-in.d.cts.map +1 -0
- package/dist/actions/built-in.d.mts +10 -0
- package/dist/actions/built-in.d.mts.map +1 -0
- package/dist/actions/built-in.mjs +1390 -0
- package/dist/actions/built-in.mjs.map +1 -0
- package/dist/actions/operators.cjs +156 -0
- package/dist/actions/operators.mjs +157 -0
- package/dist/actions/operators.mjs.map +1 -0
- package/dist/actions/registry.cjs +123 -0
- package/dist/actions/registry.d.cts +73 -0
- package/dist/actions/registry.d.cts.map +1 -0
- package/dist/actions/registry.d.mts +73 -0
- package/dist/actions/registry.d.mts.map +1 -0
- package/dist/actions/registry.mjs +123 -0
- package/dist/actions/registry.mjs.map +1 -0
- package/dist/actions/types.cjs +33 -0
- package/dist/actions/types.d.cts +97 -0
- package/dist/actions/types.d.cts.map +1 -0
- package/dist/actions/types.d.mts +97 -0
- package/dist/actions/types.d.mts.map +1 -0
- package/dist/actions/types.mjs +32 -0
- package/dist/actions/types.mjs.map +1 -0
- package/dist/config.cjs +27 -0
- package/dist/config.d.cts +54 -0
- package/dist/config.d.cts.map +1 -0
- package/dist/config.d.mts +54 -0
- package/dist/config.d.mts.map +1 -0
- package/dist/config.mjs +28 -0
- package/dist/config.mjs.map +1 -0
- package/dist/index.cjs +39 -1324
- package/dist/index.d.cts +15 -758
- package/dist/index.d.mts +15 -758
- package/dist/index.mjs +13 -1299
- package/dist/node/builder.cjs +162 -0
- package/dist/node/builder.d.cts +44 -0
- package/dist/node/builder.d.cts.map +1 -0
- package/dist/node/builder.d.mts +44 -0
- package/dist/node/builder.d.mts.map +1 -0
- package/dist/node/builder.mjs +155 -0
- package/dist/node/builder.mjs.map +1 -0
- package/dist/operations/crud.cjs +132 -0
- package/dist/operations/crud.d.cts +54 -0
- package/dist/operations/crud.d.cts.map +1 -0
- package/dist/operations/crud.d.mts +54 -0
- package/dist/operations/crud.d.mts.map +1 -0
- package/dist/operations/crud.mjs +133 -0
- package/dist/operations/crud.mjs.map +1 -0
- package/dist/operations/query-builder.cjs +77 -0
- package/dist/operations/query-builder.d.cts +34 -0
- package/dist/operations/query-builder.d.cts.map +1 -0
- package/dist/operations/query-builder.d.mts +34 -0
- package/dist/operations/query-builder.d.mts.map +1 -0
- package/dist/operations/query-builder.mjs +72 -0
- package/dist/operations/query-builder.mjs.map +1 -0
- package/dist/operations/search.cjs +135 -0
- package/dist/operations/search.d.cts +75 -0
- package/dist/operations/search.d.cts.map +1 -0
- package/dist/operations/search.d.mts +75 -0
- package/dist/operations/search.d.mts.map +1 -0
- package/dist/operations/search.mjs +135 -0
- package/dist/operations/search.mjs.map +1 -0
- package/dist/router/path-router.cjs +71 -0
- package/dist/router/path-router.d.cts +39 -0
- package/dist/router/path-router.d.cts.map +1 -0
- package/dist/router/path-router.d.mts +39 -0
- package/dist/router/path-router.d.mts.map +1 -0
- package/dist/router/path-router.mjs +68 -0
- package/dist/router/path-router.mjs.map +1 -0
- package/dist/router/types.d.cts +34 -0
- package/dist/router/types.d.cts.map +1 -0
- package/dist/router/types.d.mts +34 -0
- package/dist/router/types.d.mts.map +1 -0
- package/dist/schema/introspector.cjs +160 -0
- package/dist/schema/introspector.d.cts +49 -0
- package/dist/schema/introspector.d.cts.map +1 -0
- package/dist/schema/introspector.d.mts +49 -0
- package/dist/schema/introspector.d.mts.map +1 -0
- package/dist/schema/introspector.mjs +161 -0
- package/dist/schema/introspector.mjs.map +1 -0
- package/dist/schema/service.cjs +86 -0
- package/dist/schema/service.d.cts +52 -0
- package/dist/schema/service.d.cts.map +1 -0
- package/dist/schema/service.d.mts +52 -0
- package/dist/schema/service.d.mts.map +1 -0
- package/dist/schema/service.mjs +87 -0
- package/dist/schema/service.mjs.map +1 -0
- package/dist/schema/types.cjs +15 -0
- package/dist/schema/types.d.cts +104 -0
- package/dist/schema/types.d.cts.map +1 -0
- package/dist/schema/types.d.mts +104 -0
- package/dist/schema/types.d.mts.map +1 -0
- package/dist/schema/types.mjs +15 -0
- package/dist/schema/types.mjs.map +1 -0
- package/dist/sqlite-afs.cjs +836 -0
- package/dist/sqlite-afs.d.cts +330 -0
- package/dist/sqlite-afs.d.cts.map +1 -0
- package/dist/sqlite-afs.d.mts +330 -0
- package/dist/sqlite-afs.d.mts.map +1 -0
- package/dist/sqlite-afs.mjs +838 -0
- package/dist/sqlite-afs.mjs.map +1 -0
- package/package.json +6 -5
- package/dist/index.d.cts.map +0 -1
- package/dist/index.d.mts.map +0 -1
- package/dist/index.mjs.map +0 -1
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { SYSTEM_TABLES } from "./types.mjs";
|
|
2
|
+
import { SchemaIntrospector } from "./introspector.mjs";
|
|
3
|
+
import { sql } from "@aigne/sqlite";
|
|
4
|
+
|
|
5
|
+
//#region src/schema/service.ts
|
|
6
|
+
/**
|
|
7
|
+
* Executes a raw SQL query and returns all rows
|
|
8
|
+
*/
|
|
9
|
+
async function execAll(db, query) {
|
|
10
|
+
return db.all(sql.raw(query)).execute();
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Schema service that queries schema on-demand (no caching)
|
|
14
|
+
*
|
|
15
|
+
* SQLite PRAGMA queries are extremely fast, so real-time queries
|
|
16
|
+
* are preferred over caching to avoid staleness issues.
|
|
17
|
+
*/
|
|
18
|
+
var SchemaService = class {
|
|
19
|
+
introspector = new SchemaIntrospector();
|
|
20
|
+
constructor(db, options) {
|
|
21
|
+
this.db = db;
|
|
22
|
+
this.options = options;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Gets schema for a specific table (real-time query)
|
|
26
|
+
*/
|
|
27
|
+
async getSchema(tableName) {
|
|
28
|
+
if (!tableName) return;
|
|
29
|
+
if (SYSTEM_TABLES.includes(tableName)) return;
|
|
30
|
+
if (this.options?.tables && !this.options.tables.includes(tableName)) return;
|
|
31
|
+
if (this.options?.excludeTables?.includes(tableName)) return;
|
|
32
|
+
if (!await this.hasTable(tableName)) return;
|
|
33
|
+
return this.introspector.introspectTable(this.db, tableName);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Checks if a table exists (real-time query)
|
|
37
|
+
*/
|
|
38
|
+
async hasTable(tableName) {
|
|
39
|
+
if (!tableName) return false;
|
|
40
|
+
if (SYSTEM_TABLES.includes(tableName)) return false;
|
|
41
|
+
if (this.options?.tables && !this.options.tables.includes(tableName)) return false;
|
|
42
|
+
if (this.options?.excludeTables?.includes(tableName)) return false;
|
|
43
|
+
return ((await execAll(this.db, `SELECT COUNT(*) as count FROM sqlite_master WHERE type = 'table' AND name = '${tableName.replace(/'/g, "''")}'`))[0]?.count ?? 0) > 0;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Gets all table schemas (real-time query)
|
|
47
|
+
*/
|
|
48
|
+
async getAllSchemas() {
|
|
49
|
+
return this.introspector.introspect(this.db, {
|
|
50
|
+
tables: this.options?.tables,
|
|
51
|
+
excludeTables: this.options?.excludeTables
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Lists all table names (real-time query)
|
|
56
|
+
*/
|
|
57
|
+
async listTableNames() {
|
|
58
|
+
return (await execAll(this.db, `
|
|
59
|
+
SELECT name FROM sqlite_master
|
|
60
|
+
WHERE type = 'table'
|
|
61
|
+
AND name NOT LIKE 'sqlite_%'
|
|
62
|
+
AND name NOT LIKE '%_fts%'
|
|
63
|
+
ORDER BY name
|
|
64
|
+
`)).map((r) => r.name).filter((name) => {
|
|
65
|
+
if (SYSTEM_TABLES.includes(name)) return false;
|
|
66
|
+
if (this.options?.tables && !this.options.tables.includes(name)) return false;
|
|
67
|
+
if (this.options?.excludeTables?.includes(name)) return false;
|
|
68
|
+
return true;
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Gets the count of tables
|
|
73
|
+
*/
|
|
74
|
+
async getTableCount() {
|
|
75
|
+
return (await this.listTableNames()).length;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Gets the primary key column name for a table
|
|
79
|
+
*/
|
|
80
|
+
getPrimaryKeyColumn(schema) {
|
|
81
|
+
return this.introspector.getPrimaryKeyColumn(schema);
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
//#endregion
|
|
86
|
+
export { SchemaService };
|
|
87
|
+
//# sourceMappingURL=service.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.mjs","names":[],"sources":["../../src/schema/service.ts"],"sourcesContent":["import { sql } from \"@aigne/sqlite\";\nimport type { LibSQLDatabase } from \"drizzle-orm/libsql\";\nimport { SchemaIntrospector } from \"./introspector.js\";\nimport { SYSTEM_TABLES, type TableSchema } from \"./types.js\";\n\n/**\n * Executes a raw SQL query and returns all rows\n */\nasync function execAll<T>(db: LibSQLDatabase, query: string): Promise<T[]> {\n return db.all<T>(sql.raw(query)).execute();\n}\n\n/**\n * Options for schema service\n */\nexport interface SchemaServiceOptions {\n /** Whitelist of tables to include */\n tables?: string[];\n /** Tables to exclude */\n excludeTables?: string[];\n}\n\n/**\n * Schema service that queries schema on-demand (no caching)\n *\n * SQLite PRAGMA queries are extremely fast, so real-time queries\n * are preferred over caching to avoid staleness issues.\n */\nexport class SchemaService {\n private introspector = new SchemaIntrospector();\n\n constructor(\n private db: LibSQLDatabase,\n private options?: SchemaServiceOptions,\n ) {}\n\n /**\n * Gets schema for a specific table (real-time query)\n */\n async getSchema(tableName: string): Promise<TableSchema | undefined> {\n // Guard against undefined/null\n if (!tableName) {\n return undefined;\n }\n\n // Skip system tables\n if (SYSTEM_TABLES.includes(tableName as (typeof SYSTEM_TABLES)[number])) {\n return undefined;\n }\n\n // Apply whitelist filter\n if (this.options?.tables && !this.options.tables.includes(tableName)) {\n return undefined;\n }\n\n // Apply exclude filter\n if (this.options?.excludeTables?.includes(tableName)) {\n return undefined;\n }\n\n // Check if table exists\n const exists = await this.hasTable(tableName);\n if (!exists) {\n return undefined;\n }\n\n return this.introspector.introspectTable(this.db, tableName);\n }\n\n /**\n * Checks if a table exists (real-time query)\n */\n async hasTable(tableName: string): Promise<boolean> {\n // Guard against undefined/null\n if (!tableName) {\n return false;\n }\n\n // Skip system tables\n if (SYSTEM_TABLES.includes(tableName as (typeof SYSTEM_TABLES)[number])) {\n return false;\n }\n\n // Apply whitelist filter\n if (this.options?.tables && !this.options.tables.includes(tableName)) {\n return false;\n }\n\n // Apply exclude filter\n if (this.options?.excludeTables?.includes(tableName)) {\n return false;\n }\n\n const result = await execAll<{ count: number }>(\n this.db,\n `SELECT COUNT(*) as count FROM sqlite_master WHERE type = 'table' AND name = '${tableName.replace(/'/g, \"''\")}'`,\n );\n return (result[0]?.count ?? 0) > 0;\n }\n\n /**\n * Gets all table schemas (real-time query)\n */\n async getAllSchemas(): Promise<Map<string, TableSchema>> {\n return this.introspector.introspect(this.db, {\n tables: this.options?.tables,\n excludeTables: this.options?.excludeTables,\n });\n }\n\n /**\n * Lists all table names (real-time query)\n */\n async listTableNames(): Promise<string[]> {\n const result = await execAll<{ name: string }>(\n this.db,\n `\n SELECT name FROM sqlite_master\n WHERE type = 'table'\n AND name NOT LIKE 'sqlite_%'\n AND name NOT LIKE '%_fts%'\n ORDER BY name\n `,\n );\n\n return result\n .map((r) => r.name)\n .filter((name) => {\n // Skip system tables\n if (SYSTEM_TABLES.includes(name as (typeof SYSTEM_TABLES)[number])) {\n return false;\n }\n // Apply whitelist filter\n if (this.options?.tables && !this.options.tables.includes(name)) {\n return false;\n }\n // Apply exclude filter\n if (this.options?.excludeTables?.includes(name)) {\n return false;\n }\n return true;\n });\n }\n\n /**\n * Gets the count of tables\n */\n async getTableCount(): Promise<number> {\n const names = await this.listTableNames();\n return names.length;\n }\n\n /**\n * Gets the primary key column name for a table\n */\n getPrimaryKeyColumn(schema: TableSchema): string {\n return this.introspector.getPrimaryKeyColumn(schema);\n }\n}\n"],"mappings":";;;;;;;;AAQA,eAAe,QAAW,IAAoB,OAA6B;AACzE,QAAO,GAAG,IAAO,IAAI,IAAI,MAAM,CAAC,CAAC,SAAS;;;;;;;;AAmB5C,IAAa,gBAAb,MAA2B;CACzB,AAAQ,eAAe,IAAI,oBAAoB;CAE/C,YACE,AAAQ,IACR,AAAQ,SACR;EAFQ;EACA;;;;;CAMV,MAAM,UAAU,WAAqD;AAEnE,MAAI,CAAC,UACH;AAIF,MAAI,cAAc,SAAS,UAA4C,CACrE;AAIF,MAAI,KAAK,SAAS,UAAU,CAAC,KAAK,QAAQ,OAAO,SAAS,UAAU,CAClE;AAIF,MAAI,KAAK,SAAS,eAAe,SAAS,UAAU,CAClD;AAKF,MAAI,CADW,MAAM,KAAK,SAAS,UAAU,CAE3C;AAGF,SAAO,KAAK,aAAa,gBAAgB,KAAK,IAAI,UAAU;;;;;CAM9D,MAAM,SAAS,WAAqC;AAElD,MAAI,CAAC,UACH,QAAO;AAIT,MAAI,cAAc,SAAS,UAA4C,CACrE,QAAO;AAIT,MAAI,KAAK,SAAS,UAAU,CAAC,KAAK,QAAQ,OAAO,SAAS,UAAU,CAClE,QAAO;AAIT,MAAI,KAAK,SAAS,eAAe,SAAS,UAAU,CAClD,QAAO;AAOT,WAJe,MAAM,QACnB,KAAK,IACL,gFAAgF,UAAU,QAAQ,MAAM,KAAK,CAAC,GAC/G,EACc,IAAI,SAAS,KAAK;;;;;CAMnC,MAAM,gBAAmD;AACvD,SAAO,KAAK,aAAa,WAAW,KAAK,IAAI;GAC3C,QAAQ,KAAK,SAAS;GACtB,eAAe,KAAK,SAAS;GAC9B,CAAC;;;;;CAMJ,MAAM,iBAAoC;AAYxC,UAXe,MAAM,QACnB,KAAK,IACL;;;;;;MAOD,EAGE,KAAK,MAAM,EAAE,KAAK,CAClB,QAAQ,SAAS;AAEhB,OAAI,cAAc,SAAS,KAAuC,CAChE,QAAO;AAGT,OAAI,KAAK,SAAS,UAAU,CAAC,KAAK,QAAQ,OAAO,SAAS,KAAK,CAC7D,QAAO;AAGT,OAAI,KAAK,SAAS,eAAe,SAAS,KAAK,CAC7C,QAAO;AAET,UAAO;IACP;;;;;CAMN,MAAM,gBAAiC;AAErC,UADc,MAAM,KAAK,gBAAgB,EAC5B;;;;;CAMf,oBAAoB,QAA6B;AAC/C,SAAO,KAAK,aAAa,oBAAoB,OAAO"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/schema/types.ts
|
|
3
|
+
/**
|
|
4
|
+
* System tables that should be excluded from introspection
|
|
5
|
+
*/
|
|
6
|
+
const SYSTEM_TABLES = [
|
|
7
|
+
"sqlite_sequence",
|
|
8
|
+
"sqlite_stat1",
|
|
9
|
+
"sqlite_stat2",
|
|
10
|
+
"sqlite_stat3",
|
|
11
|
+
"sqlite_stat4"
|
|
12
|
+
];
|
|
13
|
+
|
|
14
|
+
//#endregion
|
|
15
|
+
exports.SYSTEM_TABLES = SYSTEM_TABLES;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
//#region src/schema/types.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Column information from SQLite PRAGMA table_info
|
|
4
|
+
*/
|
|
5
|
+
interface ColumnInfo {
|
|
6
|
+
/** Column name */
|
|
7
|
+
name: string;
|
|
8
|
+
/** SQLite type (INTEGER, TEXT, REAL, BLOB, etc.) */
|
|
9
|
+
type: string;
|
|
10
|
+
/** Whether the column has NOT NULL constraint */
|
|
11
|
+
notnull: boolean;
|
|
12
|
+
/** Whether this column is part of the primary key */
|
|
13
|
+
pk: number;
|
|
14
|
+
/** Default value for the column */
|
|
15
|
+
dfltValue: unknown;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Foreign key information from SQLite PRAGMA foreign_key_list
|
|
19
|
+
*/
|
|
20
|
+
interface ForeignKeyInfo {
|
|
21
|
+
/** Foreign key id */
|
|
22
|
+
id: number;
|
|
23
|
+
/** Sequence number for composite foreign keys */
|
|
24
|
+
seq: number;
|
|
25
|
+
/** Referenced table */
|
|
26
|
+
table: string;
|
|
27
|
+
/** Column in this table */
|
|
28
|
+
from: string;
|
|
29
|
+
/** Column in referenced table */
|
|
30
|
+
to: string;
|
|
31
|
+
/** ON UPDATE action */
|
|
32
|
+
onUpdate: string;
|
|
33
|
+
/** ON DELETE action */
|
|
34
|
+
onDelete: string;
|
|
35
|
+
/** MATCH clause */
|
|
36
|
+
match: string;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Index information from SQLite PRAGMA index_list
|
|
40
|
+
*/
|
|
41
|
+
interface IndexInfo {
|
|
42
|
+
/** Index sequence number */
|
|
43
|
+
seq: number;
|
|
44
|
+
/** Index name */
|
|
45
|
+
name: string;
|
|
46
|
+
/** Whether this is a unique index */
|
|
47
|
+
unique: boolean;
|
|
48
|
+
/** Origin of the index (c = CREATE INDEX, u = UNIQUE constraint, pk = PRIMARY KEY) */
|
|
49
|
+
origin: string;
|
|
50
|
+
/** Whether the index is partial */
|
|
51
|
+
partial: boolean;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Complete schema information for a single table
|
|
55
|
+
*/
|
|
56
|
+
interface TableSchema {
|
|
57
|
+
/** Table name */
|
|
58
|
+
name: string;
|
|
59
|
+
/** Column definitions */
|
|
60
|
+
columns: ColumnInfo[];
|
|
61
|
+
/** Primary key column names */
|
|
62
|
+
primaryKey: string[];
|
|
63
|
+
/** Foreign key relationships */
|
|
64
|
+
foreignKeys: ForeignKeyInfo[];
|
|
65
|
+
/** Indexes on this table */
|
|
66
|
+
indexes: IndexInfo[];
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Raw PRAGMA table_info result row
|
|
70
|
+
*/
|
|
71
|
+
interface PragmaTableInfoRow {
|
|
72
|
+
cid: number;
|
|
73
|
+
name: string;
|
|
74
|
+
type: string;
|
|
75
|
+
notnull: number;
|
|
76
|
+
dflt_value: unknown;
|
|
77
|
+
pk: number;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Raw PRAGMA foreign_key_list result row
|
|
81
|
+
*/
|
|
82
|
+
interface PragmaForeignKeyRow {
|
|
83
|
+
id: number;
|
|
84
|
+
seq: number;
|
|
85
|
+
table: string;
|
|
86
|
+
from: string;
|
|
87
|
+
to: string;
|
|
88
|
+
on_update: string;
|
|
89
|
+
on_delete: string;
|
|
90
|
+
match: string;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Raw PRAGMA index_list result row
|
|
94
|
+
*/
|
|
95
|
+
interface PragmaIndexListRow {
|
|
96
|
+
seq: number;
|
|
97
|
+
name: string;
|
|
98
|
+
unique: number;
|
|
99
|
+
origin: string;
|
|
100
|
+
partial: number;
|
|
101
|
+
}
|
|
102
|
+
//#endregion
|
|
103
|
+
export { ColumnInfo, ForeignKeyInfo, IndexInfo, PragmaForeignKeyRow, PragmaIndexListRow, PragmaTableInfoRow, TableSchema };
|
|
104
|
+
//# sourceMappingURL=types.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.cts","names":[],"sources":["../../src/schema/types.ts"],"mappings":";;AAGA;;UAAiB,UAAA;EAAU;EAEzB,IAAA;EAEA;EAAA,IAAA;EAIA;EAFA,OAAA;EAIS;EAFT,EAAA;EAQe;EANf,SAAA;AAAA;;;;UAMe,cAAA;EAQf;EANA,EAAA;EAUA;EARA,GAAA;EAYA;EAVA,KAAA;EAUK;EARL,IAAA;EAcwB;EAZxB,EAAA;EAYwB;EAVxB,QAAA;EAcA;EAZA,QAAA;EAgBA;EAdA,KAAA;AAAA;;AAsBF;;UAhBiB,SAAA;EAoBN;EAlBT,GAAA;EAwBS;EAtBT,IAAA;EAsBkB;EApBlB,MAAA;EAcA;EAZA,MAAA;EAcA;EAZA,OAAA;AAAA;;;;UAMe,WAAA;EAgBA;EAdf,IAAA;;EAEA,OAAA,EAAS,UAAA;EAaT;EAXA,UAAA;EAaA;EAXA,WAAA,EAAa,cAAA;EAab;EAXA,OAAA,EAAS,SAAA;AAAA;;AAkBX;;UAZiB,kBAAA;EACf,GAAA;EACA,IAAA;EACA,IAAA;EACA,OAAA;EACA,UAAA;EACA,EAAA;AAAA;;;;UAMe,mBAAA;EACf,EAAA;EACA,GAAA;EACA,KAAA;EACA,IAAA;EACA,EAAA;EACA,SAAA;EACA,SAAA;EACA,KAAA;AAAA;;;;UAMe,kBAAA;EACf,GAAA;EACA,IAAA;EACA,MAAA;EACA,MAAA;EACA,OAAA;AAAA"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
//#region src/schema/types.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Column information from SQLite PRAGMA table_info
|
|
4
|
+
*/
|
|
5
|
+
interface ColumnInfo {
|
|
6
|
+
/** Column name */
|
|
7
|
+
name: string;
|
|
8
|
+
/** SQLite type (INTEGER, TEXT, REAL, BLOB, etc.) */
|
|
9
|
+
type: string;
|
|
10
|
+
/** Whether the column has NOT NULL constraint */
|
|
11
|
+
notnull: boolean;
|
|
12
|
+
/** Whether this column is part of the primary key */
|
|
13
|
+
pk: number;
|
|
14
|
+
/** Default value for the column */
|
|
15
|
+
dfltValue: unknown;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Foreign key information from SQLite PRAGMA foreign_key_list
|
|
19
|
+
*/
|
|
20
|
+
interface ForeignKeyInfo {
|
|
21
|
+
/** Foreign key id */
|
|
22
|
+
id: number;
|
|
23
|
+
/** Sequence number for composite foreign keys */
|
|
24
|
+
seq: number;
|
|
25
|
+
/** Referenced table */
|
|
26
|
+
table: string;
|
|
27
|
+
/** Column in this table */
|
|
28
|
+
from: string;
|
|
29
|
+
/** Column in referenced table */
|
|
30
|
+
to: string;
|
|
31
|
+
/** ON UPDATE action */
|
|
32
|
+
onUpdate: string;
|
|
33
|
+
/** ON DELETE action */
|
|
34
|
+
onDelete: string;
|
|
35
|
+
/** MATCH clause */
|
|
36
|
+
match: string;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Index information from SQLite PRAGMA index_list
|
|
40
|
+
*/
|
|
41
|
+
interface IndexInfo {
|
|
42
|
+
/** Index sequence number */
|
|
43
|
+
seq: number;
|
|
44
|
+
/** Index name */
|
|
45
|
+
name: string;
|
|
46
|
+
/** Whether this is a unique index */
|
|
47
|
+
unique: boolean;
|
|
48
|
+
/** Origin of the index (c = CREATE INDEX, u = UNIQUE constraint, pk = PRIMARY KEY) */
|
|
49
|
+
origin: string;
|
|
50
|
+
/** Whether the index is partial */
|
|
51
|
+
partial: boolean;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Complete schema information for a single table
|
|
55
|
+
*/
|
|
56
|
+
interface TableSchema {
|
|
57
|
+
/** Table name */
|
|
58
|
+
name: string;
|
|
59
|
+
/** Column definitions */
|
|
60
|
+
columns: ColumnInfo[];
|
|
61
|
+
/** Primary key column names */
|
|
62
|
+
primaryKey: string[];
|
|
63
|
+
/** Foreign key relationships */
|
|
64
|
+
foreignKeys: ForeignKeyInfo[];
|
|
65
|
+
/** Indexes on this table */
|
|
66
|
+
indexes: IndexInfo[];
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Raw PRAGMA table_info result row
|
|
70
|
+
*/
|
|
71
|
+
interface PragmaTableInfoRow {
|
|
72
|
+
cid: number;
|
|
73
|
+
name: string;
|
|
74
|
+
type: string;
|
|
75
|
+
notnull: number;
|
|
76
|
+
dflt_value: unknown;
|
|
77
|
+
pk: number;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Raw PRAGMA foreign_key_list result row
|
|
81
|
+
*/
|
|
82
|
+
interface PragmaForeignKeyRow {
|
|
83
|
+
id: number;
|
|
84
|
+
seq: number;
|
|
85
|
+
table: string;
|
|
86
|
+
from: string;
|
|
87
|
+
to: string;
|
|
88
|
+
on_update: string;
|
|
89
|
+
on_delete: string;
|
|
90
|
+
match: string;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Raw PRAGMA index_list result row
|
|
94
|
+
*/
|
|
95
|
+
interface PragmaIndexListRow {
|
|
96
|
+
seq: number;
|
|
97
|
+
name: string;
|
|
98
|
+
unique: number;
|
|
99
|
+
origin: string;
|
|
100
|
+
partial: number;
|
|
101
|
+
}
|
|
102
|
+
//#endregion
|
|
103
|
+
export { ColumnInfo, ForeignKeyInfo, IndexInfo, PragmaForeignKeyRow, PragmaIndexListRow, PragmaTableInfoRow, TableSchema };
|
|
104
|
+
//# sourceMappingURL=types.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.mts","names":[],"sources":["../../src/schema/types.ts"],"mappings":";;AAGA;;UAAiB,UAAA;EAAU;EAEzB,IAAA;EAEA;EAAA,IAAA;EAIA;EAFA,OAAA;EAIS;EAFT,EAAA;EAQe;EANf,SAAA;AAAA;;;;UAMe,cAAA;EAQf;EANA,EAAA;EAUA;EARA,GAAA;EAYA;EAVA,KAAA;EAUK;EARL,IAAA;EAcwB;EAZxB,EAAA;EAYwB;EAVxB,QAAA;EAcA;EAZA,QAAA;EAgBA;EAdA,KAAA;AAAA;;AAsBF;;UAhBiB,SAAA;EAoBN;EAlBT,GAAA;EAwBS;EAtBT,IAAA;EAsBkB;EApBlB,MAAA;EAcA;EAZA,MAAA;EAcA;EAZA,OAAA;AAAA;;;;UAMe,WAAA;EAgBA;EAdf,IAAA;;EAEA,OAAA,EAAS,UAAA;EAaT;EAXA,UAAA;EAaA;EAXA,WAAA,EAAa,cAAA;EAab;EAXA,OAAA,EAAS,SAAA;AAAA;;AAkBX;;UAZiB,kBAAA;EACf,GAAA;EACA,IAAA;EACA,IAAA;EACA,OAAA;EACA,UAAA;EACA,EAAA;AAAA;;;;UAMe,mBAAA;EACf,EAAA;EACA,GAAA;EACA,KAAA;EACA,IAAA;EACA,EAAA;EACA,SAAA;EACA,SAAA;EACA,KAAA;AAAA;;;;UAMe,kBAAA;EACf,GAAA;EACA,IAAA;EACA,MAAA;EACA,MAAA;EACA,OAAA;AAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//#region src/schema/types.ts
|
|
2
|
+
/**
|
|
3
|
+
* System tables that should be excluded from introspection
|
|
4
|
+
*/
|
|
5
|
+
const SYSTEM_TABLES = [
|
|
6
|
+
"sqlite_sequence",
|
|
7
|
+
"sqlite_stat1",
|
|
8
|
+
"sqlite_stat2",
|
|
9
|
+
"sqlite_stat3",
|
|
10
|
+
"sqlite_stat4"
|
|
11
|
+
];
|
|
12
|
+
|
|
13
|
+
//#endregion
|
|
14
|
+
export { SYSTEM_TABLES };
|
|
15
|
+
//# sourceMappingURL=types.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.mjs","names":[],"sources":["../../src/schema/types.ts"],"sourcesContent":["/**\n * Column information from SQLite PRAGMA table_info\n */\nexport interface ColumnInfo {\n /** Column name */\n name: string;\n /** SQLite type (INTEGER, TEXT, REAL, BLOB, etc.) */\n type: string;\n /** Whether the column has NOT NULL constraint */\n notnull: boolean;\n /** Whether this column is part of the primary key */\n pk: number;\n /** Default value for the column */\n dfltValue: unknown;\n}\n\n/**\n * Foreign key information from SQLite PRAGMA foreign_key_list\n */\nexport interface ForeignKeyInfo {\n /** Foreign key id */\n id: number;\n /** Sequence number for composite foreign keys */\n seq: number;\n /** Referenced table */\n table: string;\n /** Column in this table */\n from: string;\n /** Column in referenced table */\n to: string;\n /** ON UPDATE action */\n onUpdate: string;\n /** ON DELETE action */\n onDelete: string;\n /** MATCH clause */\n match: string;\n}\n\n/**\n * Index information from SQLite PRAGMA index_list\n */\nexport interface IndexInfo {\n /** Index sequence number */\n seq: number;\n /** Index name */\n name: string;\n /** Whether this is a unique index */\n unique: boolean;\n /** Origin of the index (c = CREATE INDEX, u = UNIQUE constraint, pk = PRIMARY KEY) */\n origin: string;\n /** Whether the index is partial */\n partial: boolean;\n}\n\n/**\n * Complete schema information for a single table\n */\nexport interface TableSchema {\n /** Table name */\n name: string;\n /** Column definitions */\n columns: ColumnInfo[];\n /** Primary key column names */\n primaryKey: string[];\n /** Foreign key relationships */\n foreignKeys: ForeignKeyInfo[];\n /** Indexes on this table */\n indexes: IndexInfo[];\n}\n\n/**\n * Raw PRAGMA table_info result row\n */\nexport interface PragmaTableInfoRow {\n cid: number;\n name: string;\n type: string;\n notnull: number;\n dflt_value: unknown;\n pk: number;\n}\n\n/**\n * Raw PRAGMA foreign_key_list result row\n */\nexport interface PragmaForeignKeyRow {\n id: number;\n seq: number;\n table: string;\n from: string;\n to: string;\n on_update: string;\n on_delete: string;\n match: string;\n}\n\n/**\n * Raw PRAGMA index_list result row\n */\nexport interface PragmaIndexListRow {\n seq: number;\n name: string;\n unique: number;\n origin: string;\n partial: number;\n}\n\n/**\n * System tables that should be excluded from introspection\n */\nexport const SYSTEM_TABLES = [\n \"sqlite_sequence\",\n \"sqlite_stat1\",\n \"sqlite_stat2\",\n \"sqlite_stat3\",\n \"sqlite_stat4\",\n] as const;\n"],"mappings":";;;;AA8GA,MAAa,gBAAgB;CAC3B;CACA;CACA;CACA;CACA;CACD"}
|