@aigne/afs-sqlite 1.11.0-beta → 1.11.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. package/LICENSE.md +17 -84
  2. package/README.md +0 -3
  3. package/dist/actions/built-in.cjs +142 -0
  4. package/dist/actions/built-in.d.cts +10 -0
  5. package/dist/actions/built-in.d.cts.map +1 -0
  6. package/dist/actions/built-in.d.mts +10 -0
  7. package/dist/actions/built-in.d.mts.map +1 -0
  8. package/dist/actions/built-in.mjs +143 -0
  9. package/dist/actions/built-in.mjs.map +1 -0
  10. package/dist/actions/registry.cjs +91 -0
  11. package/dist/actions/registry.d.cts +54 -0
  12. package/dist/actions/registry.d.cts.map +1 -0
  13. package/dist/actions/registry.d.mts +54 -0
  14. package/dist/actions/registry.d.mts.map +1 -0
  15. package/dist/actions/registry.mjs +91 -0
  16. package/dist/actions/registry.mjs.map +1 -0
  17. package/dist/actions/types.d.cts +56 -0
  18. package/dist/actions/types.d.cts.map +1 -0
  19. package/dist/actions/types.d.mts +56 -0
  20. package/dist/actions/types.d.mts.map +1 -0
  21. package/dist/config.cjs +27 -0
  22. package/dist/config.d.cts +81 -0
  23. package/dist/config.d.cts.map +1 -0
  24. package/dist/config.d.mts +81 -0
  25. package/dist/config.d.mts.map +1 -0
  26. package/dist/config.mjs +28 -0
  27. package/dist/config.mjs.map +1 -0
  28. package/dist/index.cjs +38 -1324
  29. package/dist/index.d.cts +14 -758
  30. package/dist/index.d.mts +14 -758
  31. package/dist/index.mjs +12 -1299
  32. package/dist/node/builder.cjs +179 -0
  33. package/dist/node/builder.d.cts +48 -0
  34. package/dist/node/builder.d.cts.map +1 -0
  35. package/dist/node/builder.d.mts +48 -0
  36. package/dist/node/builder.d.mts.map +1 -0
  37. package/dist/node/builder.mjs +172 -0
  38. package/dist/node/builder.mjs.map +1 -0
  39. package/dist/operations/crud.cjs +176 -0
  40. package/dist/operations/crud.d.cts +69 -0
  41. package/dist/operations/crud.d.cts.map +1 -0
  42. package/dist/operations/crud.d.mts +69 -0
  43. package/dist/operations/crud.d.mts.map +1 -0
  44. package/dist/operations/crud.mjs +177 -0
  45. package/dist/operations/crud.mjs.map +1 -0
  46. package/dist/operations/query-builder.cjs +77 -0
  47. package/dist/operations/query-builder.d.cts +34 -0
  48. package/dist/operations/query-builder.d.cts.map +1 -0
  49. package/dist/operations/query-builder.d.mts +34 -0
  50. package/dist/operations/query-builder.d.mts.map +1 -0
  51. package/dist/operations/query-builder.mjs +72 -0
  52. package/dist/operations/query-builder.mjs.map +1 -0
  53. package/dist/operations/search.cjs +141 -0
  54. package/dist/operations/search.d.cts +79 -0
  55. package/dist/operations/search.d.cts.map +1 -0
  56. package/dist/operations/search.d.mts +79 -0
  57. package/dist/operations/search.d.mts.map +1 -0
  58. package/dist/operations/search.mjs +141 -0
  59. package/dist/operations/search.mjs.map +1 -0
  60. package/dist/router/path-router.cjs +79 -0
  61. package/dist/router/path-router.d.cts +42 -0
  62. package/dist/router/path-router.d.cts.map +1 -0
  63. package/dist/router/path-router.d.mts +42 -0
  64. package/dist/router/path-router.d.mts.map +1 -0
  65. package/dist/router/path-router.mjs +76 -0
  66. package/dist/router/path-router.mjs.map +1 -0
  67. package/dist/router/types.d.cts +34 -0
  68. package/dist/router/types.d.cts.map +1 -0
  69. package/dist/router/types.d.mts +34 -0
  70. package/dist/router/types.d.mts.map +1 -0
  71. package/dist/schema/introspector.cjs +160 -0
  72. package/dist/schema/introspector.d.cts +49 -0
  73. package/dist/schema/introspector.d.cts.map +1 -0
  74. package/dist/schema/introspector.d.mts +49 -0
  75. package/dist/schema/introspector.d.mts.map +1 -0
  76. package/dist/schema/introspector.mjs +161 -0
  77. package/dist/schema/introspector.mjs.map +1 -0
  78. package/dist/schema/types.cjs +15 -0
  79. package/dist/schema/types.d.cts +104 -0
  80. package/dist/schema/types.d.cts.map +1 -0
  81. package/dist/schema/types.d.mts +104 -0
  82. package/dist/schema/types.d.mts.map +1 -0
  83. package/dist/schema/types.mjs +15 -0
  84. package/dist/schema/types.mjs.map +1 -0
  85. package/dist/sqlite-afs.cjs +264 -0
  86. package/dist/sqlite-afs.d.cts +152 -0
  87. package/dist/sqlite-afs.d.cts.map +1 -0
  88. package/dist/sqlite-afs.d.mts +152 -0
  89. package/dist/sqlite-afs.d.mts.map +1 -0
  90. package/dist/sqlite-afs.mjs +265 -0
  91. package/dist/sqlite-afs.mjs.map +1 -0
  92. package/package.json +3 -3
  93. package/dist/index.d.cts.map +0 -1
  94. package/dist/index.d.mts.map +0 -1
  95. package/dist/index.mjs.map +0 -1
@@ -0,0 +1,76 @@
1
+ import { createRouter } from "radix3";
2
+
3
+ //#region src/router/path-router.ts
4
+ /**
5
+ * Creates a radix3 router for SQLite AFS path routing
6
+ *
7
+ * Routes:
8
+ * - / → listTables
9
+ * - /:table → listTable
10
+ * - /:table/new → createRow
11
+ * - /:table/@schema → getSchema
12
+ * - /:table/:pk → readRow
13
+ * - /:table/:pk/@attr → listAttributes
14
+ * - /:table/:pk/@attr/:column → getAttribute
15
+ * - /:table/:pk/@meta → getMeta
16
+ * - /:table/:pk/@actions → listActions
17
+ * - /:table/:pk/@actions/:action → executeAction
18
+ */
19
+ function createPathRouter() {
20
+ return createRouter({ routes: {
21
+ "/": { action: "listTables" },
22
+ "/:table": { action: "listTable" },
23
+ "/:table/new": { action: "createRow" },
24
+ "/:table/@schema": { action: "getSchema" },
25
+ "/:table/:pk": { action: "readRow" },
26
+ "/:table/:pk/@attr": { action: "listAttributes" },
27
+ "/:table/:pk/@attr/:column": { action: "getAttribute" },
28
+ "/:table/:pk/@meta": { action: "getMeta" },
29
+ "/:table/:pk/@actions": { action: "listActions" },
30
+ "/:table/:pk/@actions/:action": { action: "executeAction" }
31
+ } });
32
+ }
33
+ /**
34
+ * Parses a path and returns the matched route with params
35
+ * @param router - The radix3 router instance
36
+ * @param path - The path to match
37
+ * @returns RouteMatch if matched, undefined otherwise
38
+ */
39
+ function matchPath(router, path) {
40
+ const result = router.lookup(path);
41
+ if (!result) return void 0;
42
+ return {
43
+ action: result.action,
44
+ params: result.params ?? {}
45
+ };
46
+ }
47
+ /**
48
+ * Builds a path from components
49
+ */
50
+ function buildPath(table, pk, suffix) {
51
+ const parts = ["/"];
52
+ if (table) parts.push(table);
53
+ if (pk) parts.push(pk);
54
+ if (suffix) parts.push(suffix);
55
+ return parts.join("/").replace(/\/+/g, "/");
56
+ }
57
+ /**
58
+ * Checks if a path segment is a virtual path (@attr, @meta, @actions, @schema)
59
+ */
60
+ function isVirtualPath(segment) {
61
+ return segment.startsWith("@");
62
+ }
63
+ /**
64
+ * Gets the type of virtual path
65
+ */
66
+ function getVirtualPathType(segment) {
67
+ if (segment === "@attr") return "attr";
68
+ if (segment === "@meta") return "meta";
69
+ if (segment === "@actions") return "actions";
70
+ if (segment === "@schema") return "schema";
71
+ return null;
72
+ }
73
+
74
+ //#endregion
75
+ export { buildPath, createPathRouter, getVirtualPathType, isVirtualPath, matchPath };
76
+ //# sourceMappingURL=path-router.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"path-router.mjs","names":[],"sources":["../../src/router/path-router.ts"],"sourcesContent":["import { createRouter, type RadixRouter } from \"radix3\";\nimport type { RouteData, RouteMatch, RouteParams } from \"./types.js\";\n\nexport type { RouteData };\n\n/**\n * Creates a radix3 router for SQLite AFS path routing\n *\n * Routes:\n * - / → listTables\n * - /:table → listTable\n * - /:table/new → createRow\n * - /:table/@schema → getSchema\n * - /:table/:pk → readRow\n * - /:table/:pk/@attr → listAttributes\n * - /:table/:pk/@attr/:column → getAttribute\n * - /:table/:pk/@meta → getMeta\n * - /:table/:pk/@actions → listActions\n * - /:table/:pk/@actions/:action → executeAction\n */\nexport function createPathRouter(): RadixRouter<RouteData> {\n return createRouter<RouteData>({\n routes: {\n // Root - list all tables\n \"/\": { action: \"listTables\" },\n\n // Table-level routes\n \"/:table\": { action: \"listTable\" },\n \"/:table/new\": { action: \"createRow\" },\n \"/:table/@schema\": { action: \"getSchema\" },\n\n // Row-level routes\n \"/:table/:pk\": { action: \"readRow\" },\n \"/:table/:pk/@attr\": { action: \"listAttributes\" },\n \"/:table/:pk/@attr/:column\": { action: \"getAttribute\" },\n \"/:table/:pk/@meta\": { action: \"getMeta\" },\n \"/:table/:pk/@actions\": { action: \"listActions\" },\n \"/:table/:pk/@actions/:action\": { action: \"executeAction\" },\n },\n });\n}\n\n/**\n * Parses a path and returns the matched route with params\n * @param router - The radix3 router instance\n * @param path - The path to match\n * @returns RouteMatch if matched, undefined otherwise\n */\nexport function matchPath(router: RadixRouter<RouteData>, path: string): RouteMatch | undefined {\n const result = router.lookup(path);\n if (!result) return undefined;\n\n return {\n action: result.action,\n params: (result.params ?? {}) as RouteParams,\n };\n}\n\n/**\n * Builds a path from components\n */\nexport function buildPath(table?: string, pk?: string, suffix?: string): string {\n const parts = [\"/\"];\n if (table) parts.push(table);\n if (pk) parts.push(pk);\n if (suffix) parts.push(suffix);\n return parts.join(\"/\").replace(/\\/+/g, \"/\");\n}\n\n/**\n * Checks if a path segment is a virtual path (@attr, @meta, @actions, @schema)\n */\nexport function isVirtualPath(segment: string): boolean {\n return segment.startsWith(\"@\");\n}\n\n/**\n * Gets the type of virtual path\n */\nexport function getVirtualPathType(segment: string): \"attr\" | \"meta\" | \"actions\" | \"schema\" | null {\n if (segment === \"@attr\") return \"attr\";\n if (segment === \"@meta\") return \"meta\";\n if (segment === \"@actions\") return \"actions\";\n if (segment === \"@schema\") return \"schema\";\n return null;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAoBA,SAAgB,mBAA2C;AACzD,QAAO,aAAwB,EAC7B,QAAQ;EAEN,KAAK,EAAE,QAAQ,cAAc;EAG7B,WAAW,EAAE,QAAQ,aAAa;EAClC,eAAe,EAAE,QAAQ,aAAa;EACtC,mBAAmB,EAAE,QAAQ,aAAa;EAG1C,eAAe,EAAE,QAAQ,WAAW;EACpC,qBAAqB,EAAE,QAAQ,kBAAkB;EACjD,6BAA6B,EAAE,QAAQ,gBAAgB;EACvD,qBAAqB,EAAE,QAAQ,WAAW;EAC1C,wBAAwB,EAAE,QAAQ,eAAe;EACjD,gCAAgC,EAAE,QAAQ,iBAAiB;EAC5D,EACF,CAAC;;;;;;;;AASJ,SAAgB,UAAU,QAAgC,MAAsC;CAC9F,MAAM,SAAS,OAAO,OAAO,KAAK;AAClC,KAAI,CAAC,OAAQ,QAAO;AAEpB,QAAO;EACL,QAAQ,OAAO;EACf,QAAS,OAAO,UAAU,EAAE;EAC7B;;;;;AAMH,SAAgB,UAAU,OAAgB,IAAa,QAAyB;CAC9E,MAAM,QAAQ,CAAC,IAAI;AACnB,KAAI,MAAO,OAAM,KAAK,MAAM;AAC5B,KAAI,GAAI,OAAM,KAAK,GAAG;AACtB,KAAI,OAAQ,OAAM,KAAK,OAAO;AAC9B,QAAO,MAAM,KAAK,IAAI,CAAC,QAAQ,QAAQ,IAAI;;;;;AAM7C,SAAgB,cAAc,SAA0B;AACtD,QAAO,QAAQ,WAAW,IAAI;;;;;AAMhC,SAAgB,mBAAmB,SAAgE;AACjG,KAAI,YAAY,QAAS,QAAO;AAChC,KAAI,YAAY,QAAS,QAAO;AAChC,KAAI,YAAY,WAAY,QAAO;AACnC,KAAI,YAAY,UAAW,QAAO;AAClC,QAAO"}
@@ -0,0 +1,34 @@
1
+ //#region src/router/types.d.ts
2
+ /**
3
+ * Route action types for SQLite AFS
4
+ */
5
+ type RouteAction = "listTables" | "listTable" | "readRow" | "createRow" | "getSchema" | "listAttributes" | "getAttribute" | "getMeta" | "listActions" | "executeAction";
6
+ /**
7
+ * Route data associated with each path pattern
8
+ */
9
+ interface RouteData {
10
+ /** The action to perform for this route */
11
+ action: RouteAction;
12
+ }
13
+ /**
14
+ * Route match result with params
15
+ */
16
+ interface RouteMatch extends RouteData {
17
+ params: RouteParams;
18
+ }
19
+ /**
20
+ * Dynamic route parameters extracted from path
21
+ */
22
+ interface RouteParams {
23
+ /** Table name */
24
+ table?: string;
25
+ /** Primary key value */
26
+ pk?: string;
27
+ /** Column name for attribute access */
28
+ column?: string;
29
+ /** Action name for @actions */
30
+ action?: string;
31
+ }
32
+ //#endregion
33
+ export { RouteAction, RouteData, RouteMatch, RouteParams };
34
+ //# sourceMappingURL=types.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.cts","names":[],"sources":["../../src/router/types.ts"],"mappings":";;AAGA;AAeA;KAfY,WAAA;AAAA;AAeZ;AAQA;AAvBY,UAeK,SAAA;EAAA;EAAA,MAAA,EAEP,WAAA;AAAA;AAAA;AAMV;AAOA;AAbU,UAMO,UAAA,SAAmB,SAAA;EAAA,MAAA,EAC1B,WAAA;AAAA;AAAA;AAMV;;AANU,UAMO,WAAA;EAAA;EAAA,KAAA;EAAA;EAAA,EAAA;EAAA;EAAA,MAAA;EAAA;EAAA,MAAA;AAAA"}
@@ -0,0 +1,34 @@
1
+ //#region src/router/types.d.ts
2
+ /**
3
+ * Route action types for SQLite AFS
4
+ */
5
+ type RouteAction = "listTables" | "listTable" | "readRow" | "createRow" | "getSchema" | "listAttributes" | "getAttribute" | "getMeta" | "listActions" | "executeAction";
6
+ /**
7
+ * Route data associated with each path pattern
8
+ */
9
+ interface RouteData {
10
+ /** The action to perform for this route */
11
+ action: RouteAction;
12
+ }
13
+ /**
14
+ * Route match result with params
15
+ */
16
+ interface RouteMatch extends RouteData {
17
+ params: RouteParams;
18
+ }
19
+ /**
20
+ * Dynamic route parameters extracted from path
21
+ */
22
+ interface RouteParams {
23
+ /** Table name */
24
+ table?: string;
25
+ /** Primary key value */
26
+ pk?: string;
27
+ /** Column name for attribute access */
28
+ column?: string;
29
+ /** Action name for @actions */
30
+ action?: string;
31
+ }
32
+ //#endregion
33
+ export { RouteAction, RouteData, RouteMatch, RouteParams };
34
+ //# sourceMappingURL=types.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.mts","names":[],"sources":["../../src/router/types.ts"],"mappings":";;AAGA;AAeA;KAfY,WAAA;AAAA;AAeZ;AAQA;AAvBY,UAeK,SAAA;EAAA;EAAA,MAAA,EAEP,WAAA;AAAA;AAAA;AAMV;AAOA;AAbU,UAMO,UAAA,SAAmB,SAAA;EAAA,MAAA,EAC1B,WAAA;AAAA;AAAA;AAMV;;AANU,UAMO,WAAA;EAAA;EAAA,KAAA;EAAA;EAAA,EAAA;EAAA;EAAA,MAAA;EAAA;EAAA,MAAA;AAAA"}
@@ -0,0 +1,160 @@
1
+ const require_types = require('./types.cjs');
2
+ let _aigne_sqlite = require("@aigne/sqlite");
3
+
4
+ //#region src/schema/introspector.ts
5
+ /**
6
+ * Executes a raw SQL query and returns all rows
7
+ */
8
+ async function execAll(db, query) {
9
+ return db.all(_aigne_sqlite.sql.raw(query)).execute();
10
+ }
11
+ /**
12
+ * Executes a raw SQL query (for INSERT, UPDATE, DELETE)
13
+ */
14
+ async function execRun(db, query) {
15
+ await db.run(_aigne_sqlite.sql.raw(query)).execute();
16
+ }
17
+ /**
18
+ * Maps raw PRAGMA table_info row to ColumnInfo
19
+ */
20
+ function mapColumn(row) {
21
+ return {
22
+ name: row.name,
23
+ type: row.type,
24
+ notnull: row.notnull === 1,
25
+ pk: row.pk,
26
+ dfltValue: row.dflt_value
27
+ };
28
+ }
29
+ /**
30
+ * Maps raw PRAGMA foreign_key_list row to ForeignKeyInfo
31
+ */
32
+ function mapForeignKey(row) {
33
+ return {
34
+ id: row.id,
35
+ seq: row.seq,
36
+ table: row.table,
37
+ from: row.from,
38
+ to: row.to,
39
+ onUpdate: row.on_update,
40
+ onDelete: row.on_delete,
41
+ match: row.match
42
+ };
43
+ }
44
+ /**
45
+ * Maps raw PRAGMA index_list row to IndexInfo
46
+ */
47
+ function mapIndex(row) {
48
+ return {
49
+ seq: row.seq,
50
+ name: row.name,
51
+ unique: row.unique === 1,
52
+ origin: row.origin,
53
+ partial: row.partial === 1
54
+ };
55
+ }
56
+ /**
57
+ * Schema introspector that uses SQLite PRAGMA queries to discover database schema
58
+ */
59
+ var SchemaIntrospector = class {
60
+ /**
61
+ * Introspects all tables in the database
62
+ * @param db - Drizzle database instance
63
+ * @param options - Introspection options
64
+ * @returns Map of table name to TableSchema
65
+ */
66
+ async introspect(db, options) {
67
+ const schemas = /* @__PURE__ */ new Map();
68
+ const tablesResult = await execAll(db, `
69
+ SELECT name FROM sqlite_master
70
+ WHERE type = 'table'
71
+ AND name NOT LIKE 'sqlite_%'
72
+ AND name NOT LIKE '%_fts%'
73
+ ORDER BY name
74
+ `);
75
+ for (const { name } of tablesResult) {
76
+ if (require_types.SYSTEM_TABLES.includes(name)) continue;
77
+ if (options?.tables && !options.tables.includes(name)) continue;
78
+ if (options?.excludeTables?.includes(name)) continue;
79
+ const schema = await this.introspectTable(db, name);
80
+ schemas.set(name, schema);
81
+ }
82
+ return schemas;
83
+ }
84
+ /**
85
+ * Introspects a single table
86
+ * @param db - Drizzle database instance
87
+ * @param tableName - Name of the table to introspect
88
+ * @returns TableSchema for the specified table
89
+ */
90
+ async introspectTable(db, tableName) {
91
+ const columns = (await execAll(db, `PRAGMA table_info("${tableName}")`)).map(mapColumn);
92
+ return {
93
+ name: tableName,
94
+ columns,
95
+ primaryKey: columns.filter((c) => c.pk > 0).map((c) => c.name),
96
+ foreignKeys: (await execAll(db, `PRAGMA foreign_key_list("${tableName}")`)).map(mapForeignKey),
97
+ indexes: (await execAll(db, `PRAGMA index_list("${tableName}")`)).map(mapIndex)
98
+ };
99
+ }
100
+ /**
101
+ * Gets the primary key column name for a table
102
+ * Returns the first PK column, or 'rowid' if no explicit PK
103
+ */
104
+ getPrimaryKeyColumn(schema) {
105
+ if (schema.primaryKey.length > 0 && schema.primaryKey[0]) return schema.primaryKey[0];
106
+ return "rowid";
107
+ }
108
+ /**
109
+ * Checks if a table has FTS (Full-Text Search) enabled
110
+ */
111
+ async hasFTS(db, tableName) {
112
+ return (await execAll(db, `
113
+ SELECT name FROM sqlite_master
114
+ WHERE type = 'table'
115
+ AND name = '${`${tableName}_fts`}'
116
+ `)).length > 0;
117
+ }
118
+ /**
119
+ * Creates FTS5 table for full-text search on specified columns
120
+ */
121
+ async createFTS(db, tableName, columns, options) {
122
+ const ftsTableName = `${tableName}_fts`;
123
+ const contentTable = options?.contentTable ?? tableName;
124
+ const contentRowid = options?.contentRowid ?? "rowid";
125
+ const columnList = columns.join(", ");
126
+ await execRun(db, `
127
+ CREATE VIRTUAL TABLE IF NOT EXISTS "${ftsTableName}" USING fts5(
128
+ ${columnList},
129
+ content="${contentTable}",
130
+ content_rowid="${contentRowid}"
131
+ )
132
+ `);
133
+ await execRun(db, `
134
+ CREATE TRIGGER IF NOT EXISTS "${tableName}_ai" AFTER INSERT ON "${tableName}" BEGIN
135
+ INSERT INTO "${ftsTableName}"(rowid, ${columnList}) VALUES (new.${contentRowid}, ${columns.map((c) => `new."${c}"`).join(", ")});
136
+ END
137
+ `);
138
+ await execRun(db, `
139
+ CREATE TRIGGER IF NOT EXISTS "${tableName}_ad" AFTER DELETE ON "${tableName}" BEGIN
140
+ INSERT INTO "${ftsTableName}"("${ftsTableName}", rowid, ${columnList}) VALUES ('delete', old.${contentRowid}, ${columns.map((c) => `old."${c}"`).join(", ")});
141
+ END
142
+ `);
143
+ await execRun(db, `
144
+ CREATE TRIGGER IF NOT EXISTS "${tableName}_au" AFTER UPDATE ON "${tableName}" BEGIN
145
+ INSERT INTO "${ftsTableName}"("${ftsTableName}", rowid, ${columnList}) VALUES ('delete', old.${contentRowid}, ${columns.map((c) => `old."${c}"`).join(", ")});
146
+ INSERT INTO "${ftsTableName}"(rowid, ${columnList}) VALUES (new.${contentRowid}, ${columns.map((c) => `new."${c}"`).join(", ")});
147
+ END
148
+ `);
149
+ }
150
+ /**
151
+ * Rebuilds FTS index for a table (useful after bulk inserts)
152
+ */
153
+ async rebuildFTS(db, tableName) {
154
+ const ftsTableName = `${tableName}_fts`;
155
+ await execRun(db, `INSERT INTO "${ftsTableName}"("${ftsTableName}") VALUES ('rebuild')`);
156
+ }
157
+ };
158
+
159
+ //#endregion
160
+ exports.SchemaIntrospector = SchemaIntrospector;
@@ -0,0 +1,49 @@
1
+ import { TableSchema } from "./types.cjs";
2
+ import { LibSQLDatabase } from "drizzle-orm/libsql";
3
+
4
+ //#region src/schema/introspector.d.ts
5
+ /**
6
+ * Schema introspector that uses SQLite PRAGMA queries to discover database schema
7
+ */
8
+ declare class SchemaIntrospector {
9
+ /**
10
+ * Introspects all tables in the database
11
+ * @param db - Drizzle database instance
12
+ * @param options - Introspection options
13
+ * @returns Map of table name to TableSchema
14
+ */
15
+ introspect(db: LibSQLDatabase, options?: {
16
+ /** Whitelist of tables to include */tables?: string[]; /** Tables to exclude */
17
+ excludeTables?: string[];
18
+ }): Promise<Map<string, TableSchema>>;
19
+ /**
20
+ * Introspects a single table
21
+ * @param db - Drizzle database instance
22
+ * @param tableName - Name of the table to introspect
23
+ * @returns TableSchema for the specified table
24
+ */
25
+ introspectTable(db: LibSQLDatabase, tableName: string): Promise<TableSchema>;
26
+ /**
27
+ * Gets the primary key column name for a table
28
+ * Returns the first PK column, or 'rowid' if no explicit PK
29
+ */
30
+ getPrimaryKeyColumn(schema: TableSchema): string;
31
+ /**
32
+ * Checks if a table has FTS (Full-Text Search) enabled
33
+ */
34
+ hasFTS(db: LibSQLDatabase, tableName: string): Promise<boolean>;
35
+ /**
36
+ * Creates FTS5 table for full-text search on specified columns
37
+ */
38
+ createFTS(db: LibSQLDatabase, tableName: string, columns: string[], options?: {
39
+ /** Content table (defaults to tableName) */contentTable?: string; /** Content rowid column (defaults to 'rowid') */
40
+ contentRowid?: string;
41
+ }): Promise<void>;
42
+ /**
43
+ * Rebuilds FTS index for a table (useful after bulk inserts)
44
+ */
45
+ rebuildFTS(db: LibSQLDatabase, tableName: string): Promise<void>;
46
+ }
47
+ //#endregion
48
+ export { SchemaIntrospector };
49
+ //# sourceMappingURL=introspector.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"introspector.d.cts","names":[],"sources":["../../src/schema/introspector.ts"],"mappings":";;;;;AAwEA;;cAAa,kBAAA;EAAA;;;;;;EAAA,WAAA,EAAA,EAQL,cAAA,EAAA,OAAA;IAAA,qCAAA,MAAA;IAAA,aAAA;EAAA,IAOH,OAAA,CAAQ,GAAA,SAAY,WAAA;EAAA;;;;;;EAAA,gBAAA,EAAA,EA4CG,cAAA,EAAA,SAAA,WAAoC,OAAA,CAAQ,WAAA;EAAA;;;;EAAA,oBAAA,MAAA,EAsC1C,WAAA;EAAA;;;EAAA,OAAA,EAAA,EAWX,cAAA,EAAA,SAAA,WAAoC,OAAA;EAAA;;;EAAA,UAAA,EAAA,EAiB/C,cAAA,EAAA,SAAA,UAAA,OAAA,YAAA,OAAA;IAAA,4CAAA,YAAA;IAAA,YAAA;EAAA,IASH,OAAA;EAAA;;;EAAA,WAAA,EAAA,EAmDkB,cAAA,EAAA,SAAA,WAAoC,OAAA;AAAA"}
@@ -0,0 +1,49 @@
1
+ import { TableSchema } from "./types.mjs";
2
+ import { LibSQLDatabase } from "drizzle-orm/libsql";
3
+
4
+ //#region src/schema/introspector.d.ts
5
+ /**
6
+ * Schema introspector that uses SQLite PRAGMA queries to discover database schema
7
+ */
8
+ declare class SchemaIntrospector {
9
+ /**
10
+ * Introspects all tables in the database
11
+ * @param db - Drizzle database instance
12
+ * @param options - Introspection options
13
+ * @returns Map of table name to TableSchema
14
+ */
15
+ introspect(db: LibSQLDatabase, options?: {
16
+ /** Whitelist of tables to include */tables?: string[]; /** Tables to exclude */
17
+ excludeTables?: string[];
18
+ }): Promise<Map<string, TableSchema>>;
19
+ /**
20
+ * Introspects a single table
21
+ * @param db - Drizzle database instance
22
+ * @param tableName - Name of the table to introspect
23
+ * @returns TableSchema for the specified table
24
+ */
25
+ introspectTable(db: LibSQLDatabase, tableName: string): Promise<TableSchema>;
26
+ /**
27
+ * Gets the primary key column name for a table
28
+ * Returns the first PK column, or 'rowid' if no explicit PK
29
+ */
30
+ getPrimaryKeyColumn(schema: TableSchema): string;
31
+ /**
32
+ * Checks if a table has FTS (Full-Text Search) enabled
33
+ */
34
+ hasFTS(db: LibSQLDatabase, tableName: string): Promise<boolean>;
35
+ /**
36
+ * Creates FTS5 table for full-text search on specified columns
37
+ */
38
+ createFTS(db: LibSQLDatabase, tableName: string, columns: string[], options?: {
39
+ /** Content table (defaults to tableName) */contentTable?: string; /** Content rowid column (defaults to 'rowid') */
40
+ contentRowid?: string;
41
+ }): Promise<void>;
42
+ /**
43
+ * Rebuilds FTS index for a table (useful after bulk inserts)
44
+ */
45
+ rebuildFTS(db: LibSQLDatabase, tableName: string): Promise<void>;
46
+ }
47
+ //#endregion
48
+ export { SchemaIntrospector };
49
+ //# sourceMappingURL=introspector.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"introspector.d.mts","names":[],"sources":["../../src/schema/introspector.ts"],"mappings":";;;;;AAwEA;;cAAa,kBAAA;EAAA;;;;;;EAAA,WAAA,EAAA,EAQL,cAAA,EAAA,OAAA;IAAA,qCAAA,MAAA;IAAA,aAAA;EAAA,IAOH,OAAA,CAAQ,GAAA,SAAY,WAAA;EAAA;;;;;;EAAA,gBAAA,EAAA,EA4CG,cAAA,EAAA,SAAA,WAAoC,OAAA,CAAQ,WAAA;EAAA;;;;EAAA,oBAAA,MAAA,EAsC1C,WAAA;EAAA;;;EAAA,OAAA,EAAA,EAWX,cAAA,EAAA,SAAA,WAAoC,OAAA;EAAA;;;EAAA,UAAA,EAAA,EAiB/C,cAAA,EAAA,SAAA,UAAA,OAAA,YAAA,OAAA;IAAA,4CAAA,YAAA;IAAA,YAAA;EAAA,IASH,OAAA;EAAA;;;EAAA,WAAA,EAAA,EAmDkB,cAAA,EAAA,SAAA,WAAoC,OAAA;AAAA"}
@@ -0,0 +1,161 @@
1
+ import { SYSTEM_TABLES } from "./types.mjs";
2
+ import { sql } from "@aigne/sqlite";
3
+
4
+ //#region src/schema/introspector.ts
5
+ /**
6
+ * Executes a raw SQL query and returns all rows
7
+ */
8
+ async function execAll(db, query) {
9
+ return db.all(sql.raw(query)).execute();
10
+ }
11
+ /**
12
+ * Executes a raw SQL query (for INSERT, UPDATE, DELETE)
13
+ */
14
+ async function execRun(db, query) {
15
+ await db.run(sql.raw(query)).execute();
16
+ }
17
+ /**
18
+ * Maps raw PRAGMA table_info row to ColumnInfo
19
+ */
20
+ function mapColumn(row) {
21
+ return {
22
+ name: row.name,
23
+ type: row.type,
24
+ notnull: row.notnull === 1,
25
+ pk: row.pk,
26
+ dfltValue: row.dflt_value
27
+ };
28
+ }
29
+ /**
30
+ * Maps raw PRAGMA foreign_key_list row to ForeignKeyInfo
31
+ */
32
+ function mapForeignKey(row) {
33
+ return {
34
+ id: row.id,
35
+ seq: row.seq,
36
+ table: row.table,
37
+ from: row.from,
38
+ to: row.to,
39
+ onUpdate: row.on_update,
40
+ onDelete: row.on_delete,
41
+ match: row.match
42
+ };
43
+ }
44
+ /**
45
+ * Maps raw PRAGMA index_list row to IndexInfo
46
+ */
47
+ function mapIndex(row) {
48
+ return {
49
+ seq: row.seq,
50
+ name: row.name,
51
+ unique: row.unique === 1,
52
+ origin: row.origin,
53
+ partial: row.partial === 1
54
+ };
55
+ }
56
+ /**
57
+ * Schema introspector that uses SQLite PRAGMA queries to discover database schema
58
+ */
59
+ var SchemaIntrospector = class {
60
+ /**
61
+ * Introspects all tables in the database
62
+ * @param db - Drizzle database instance
63
+ * @param options - Introspection options
64
+ * @returns Map of table name to TableSchema
65
+ */
66
+ async introspect(db, options) {
67
+ const schemas = /* @__PURE__ */ new Map();
68
+ const tablesResult = await execAll(db, `
69
+ SELECT name FROM sqlite_master
70
+ WHERE type = 'table'
71
+ AND name NOT LIKE 'sqlite_%'
72
+ AND name NOT LIKE '%_fts%'
73
+ ORDER BY name
74
+ `);
75
+ for (const { name } of tablesResult) {
76
+ if (SYSTEM_TABLES.includes(name)) continue;
77
+ if (options?.tables && !options.tables.includes(name)) continue;
78
+ if (options?.excludeTables?.includes(name)) continue;
79
+ const schema = await this.introspectTable(db, name);
80
+ schemas.set(name, schema);
81
+ }
82
+ return schemas;
83
+ }
84
+ /**
85
+ * Introspects a single table
86
+ * @param db - Drizzle database instance
87
+ * @param tableName - Name of the table to introspect
88
+ * @returns TableSchema for the specified table
89
+ */
90
+ async introspectTable(db, tableName) {
91
+ const columns = (await execAll(db, `PRAGMA table_info("${tableName}")`)).map(mapColumn);
92
+ return {
93
+ name: tableName,
94
+ columns,
95
+ primaryKey: columns.filter((c) => c.pk > 0).map((c) => c.name),
96
+ foreignKeys: (await execAll(db, `PRAGMA foreign_key_list("${tableName}")`)).map(mapForeignKey),
97
+ indexes: (await execAll(db, `PRAGMA index_list("${tableName}")`)).map(mapIndex)
98
+ };
99
+ }
100
+ /**
101
+ * Gets the primary key column name for a table
102
+ * Returns the first PK column, or 'rowid' if no explicit PK
103
+ */
104
+ getPrimaryKeyColumn(schema) {
105
+ if (schema.primaryKey.length > 0 && schema.primaryKey[0]) return schema.primaryKey[0];
106
+ return "rowid";
107
+ }
108
+ /**
109
+ * Checks if a table has FTS (Full-Text Search) enabled
110
+ */
111
+ async hasFTS(db, tableName) {
112
+ return (await execAll(db, `
113
+ SELECT name FROM sqlite_master
114
+ WHERE type = 'table'
115
+ AND name = '${`${tableName}_fts`}'
116
+ `)).length > 0;
117
+ }
118
+ /**
119
+ * Creates FTS5 table for full-text search on specified columns
120
+ */
121
+ async createFTS(db, tableName, columns, options) {
122
+ const ftsTableName = `${tableName}_fts`;
123
+ const contentTable = options?.contentTable ?? tableName;
124
+ const contentRowid = options?.contentRowid ?? "rowid";
125
+ const columnList = columns.join(", ");
126
+ await execRun(db, `
127
+ CREATE VIRTUAL TABLE IF NOT EXISTS "${ftsTableName}" USING fts5(
128
+ ${columnList},
129
+ content="${contentTable}",
130
+ content_rowid="${contentRowid}"
131
+ )
132
+ `);
133
+ await execRun(db, `
134
+ CREATE TRIGGER IF NOT EXISTS "${tableName}_ai" AFTER INSERT ON "${tableName}" BEGIN
135
+ INSERT INTO "${ftsTableName}"(rowid, ${columnList}) VALUES (new.${contentRowid}, ${columns.map((c) => `new."${c}"`).join(", ")});
136
+ END
137
+ `);
138
+ await execRun(db, `
139
+ CREATE TRIGGER IF NOT EXISTS "${tableName}_ad" AFTER DELETE ON "${tableName}" BEGIN
140
+ INSERT INTO "${ftsTableName}"("${ftsTableName}", rowid, ${columnList}) VALUES ('delete', old.${contentRowid}, ${columns.map((c) => `old."${c}"`).join(", ")});
141
+ END
142
+ `);
143
+ await execRun(db, `
144
+ CREATE TRIGGER IF NOT EXISTS "${tableName}_au" AFTER UPDATE ON "${tableName}" BEGIN
145
+ INSERT INTO "${ftsTableName}"("${ftsTableName}", rowid, ${columnList}) VALUES ('delete', old.${contentRowid}, ${columns.map((c) => `old."${c}"`).join(", ")});
146
+ INSERT INTO "${ftsTableName}"(rowid, ${columnList}) VALUES (new.${contentRowid}, ${columns.map((c) => `new."${c}"`).join(", ")});
147
+ END
148
+ `);
149
+ }
150
+ /**
151
+ * Rebuilds FTS index for a table (useful after bulk inserts)
152
+ */
153
+ async rebuildFTS(db, tableName) {
154
+ const ftsTableName = `${tableName}_fts`;
155
+ await execRun(db, `INSERT INTO "${ftsTableName}"("${ftsTableName}") VALUES ('rebuild')`);
156
+ }
157
+ };
158
+
159
+ //#endregion
160
+ export { SchemaIntrospector };
161
+ //# sourceMappingURL=introspector.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"introspector.mjs","names":[],"sources":["../../src/schema/introspector.ts"],"sourcesContent":["import { sql } from \"@aigne/sqlite\";\nimport type { LibSQLDatabase } from \"drizzle-orm/libsql\";\nimport {\n type ColumnInfo,\n type ForeignKeyInfo,\n type IndexInfo,\n type PragmaForeignKeyRow,\n type PragmaIndexListRow,\n type PragmaTableInfoRow,\n SYSTEM_TABLES,\n type TableSchema,\n} 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 * Executes a raw SQL query (for INSERT, UPDATE, DELETE)\n */\nasync function execRun(db: LibSQLDatabase, query: string): Promise<void> {\n await db.run(sql.raw(query)).execute();\n}\n\n/**\n * Maps raw PRAGMA table_info row to ColumnInfo\n */\nfunction mapColumn(row: PragmaTableInfoRow): ColumnInfo {\n return {\n name: row.name,\n type: row.type,\n notnull: row.notnull === 1,\n pk: row.pk,\n dfltValue: row.dflt_value,\n };\n}\n\n/**\n * Maps raw PRAGMA foreign_key_list row to ForeignKeyInfo\n */\nfunction mapForeignKey(row: PragmaForeignKeyRow): ForeignKeyInfo {\n return {\n id: row.id,\n seq: row.seq,\n table: row.table,\n from: row.from,\n to: row.to,\n onUpdate: row.on_update,\n onDelete: row.on_delete,\n match: row.match,\n };\n}\n\n/**\n * Maps raw PRAGMA index_list row to IndexInfo\n */\nfunction mapIndex(row: PragmaIndexListRow): IndexInfo {\n return {\n seq: row.seq,\n name: row.name,\n unique: row.unique === 1,\n origin: row.origin,\n partial: row.partial === 1,\n };\n}\n\n/**\n * Schema introspector that uses SQLite PRAGMA queries to discover database schema\n */\nexport class SchemaIntrospector {\n /**\n * Introspects all tables in the database\n * @param db - Drizzle database instance\n * @param options - Introspection options\n * @returns Map of table name to TableSchema\n */\n async introspect(\n db: LibSQLDatabase,\n options?: {\n /** Whitelist of tables to include */\n tables?: string[];\n /** Tables to exclude */\n excludeTables?: string[];\n },\n ): Promise<Map<string, TableSchema>> {\n const schemas = new Map<string, TableSchema>();\n\n // Get all user tables (exclude system tables and FTS tables)\n const tablesResult = await execAll<{ name: string }>(\n 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 for (const { name } of tablesResult) {\n // Skip system tables\n if (SYSTEM_TABLES.includes(name as (typeof SYSTEM_TABLES)[number])) {\n continue;\n }\n\n // Apply whitelist filter\n if (options?.tables && !options.tables.includes(name)) {\n continue;\n }\n\n // Apply exclude filter\n if (options?.excludeTables?.includes(name)) {\n continue;\n }\n\n const schema = await this.introspectTable(db, name);\n schemas.set(name, schema);\n }\n\n return schemas;\n }\n\n /**\n * Introspects a single table\n * @param db - Drizzle database instance\n * @param tableName - Name of the table to introspect\n * @returns TableSchema for the specified table\n */\n async introspectTable(db: LibSQLDatabase, tableName: string): Promise<TableSchema> {\n // Get column information\n const columnsResult = await execAll<PragmaTableInfoRow>(\n db,\n `PRAGMA table_info(\"${tableName}\")`,\n );\n const columns = columnsResult.map(mapColumn);\n\n // Get primary key columns (pk > 0 indicates part of primary key)\n const primaryKey = columns.filter((c) => c.pk > 0).map((c) => c.name);\n\n // Get foreign keys\n const fksResult = await execAll<PragmaForeignKeyRow>(\n db,\n `PRAGMA foreign_key_list(\"${tableName}\")`,\n );\n const foreignKeys = fksResult.map(mapForeignKey);\n\n // Get indexes\n const indexesResult = await execAll<PragmaIndexListRow>(\n db,\n `PRAGMA index_list(\"${tableName}\")`,\n );\n const indexes = indexesResult.map(mapIndex);\n\n return {\n name: tableName,\n columns,\n primaryKey,\n foreignKeys,\n indexes,\n };\n }\n\n /**\n * Gets the primary key column name for a table\n * Returns the first PK column, or 'rowid' if no explicit PK\n */\n getPrimaryKeyColumn(schema: TableSchema): string {\n if (schema.primaryKey.length > 0 && schema.primaryKey[0]) {\n return schema.primaryKey[0];\n }\n // SQLite tables without explicit PK use rowid\n return \"rowid\";\n }\n\n /**\n * Checks if a table has FTS (Full-Text Search) enabled\n */\n async hasFTS(db: LibSQLDatabase, tableName: string): Promise<boolean> {\n const ftsTableName = `${tableName}_fts`;\n const result = await execAll<{ name: string }>(\n db,\n `\n SELECT name FROM sqlite_master\n WHERE type = 'table'\n AND name = '${ftsTableName}'\n `,\n );\n return result.length > 0;\n }\n\n /**\n * Creates FTS5 table for full-text search on specified columns\n */\n async createFTS(\n db: LibSQLDatabase,\n tableName: string,\n columns: string[],\n options?: {\n /** Content table (defaults to tableName) */\n contentTable?: string;\n /** Content rowid column (defaults to 'rowid') */\n contentRowid?: string;\n },\n ): Promise<void> {\n const ftsTableName = `${tableName}_fts`;\n const contentTable = options?.contentTable ?? tableName;\n const contentRowid = options?.contentRowid ?? \"rowid\";\n const columnList = columns.join(\", \");\n\n // Create FTS5 virtual table\n await execRun(\n db,\n `\n CREATE VIRTUAL TABLE IF NOT EXISTS \"${ftsTableName}\" USING fts5(\n ${columnList},\n content=\"${contentTable}\",\n content_rowid=\"${contentRowid}\"\n )\n `,\n );\n\n // Create triggers to keep FTS in sync\n await execRun(\n db,\n `\n CREATE TRIGGER IF NOT EXISTS \"${tableName}_ai\" AFTER INSERT ON \"${tableName}\" BEGIN\n INSERT INTO \"${ftsTableName}\"(rowid, ${columnList}) VALUES (new.${contentRowid}, ${columns.map((c) => `new.\"${c}\"`).join(\", \")});\n END\n `,\n );\n\n await execRun(\n db,\n `\n CREATE TRIGGER IF NOT EXISTS \"${tableName}_ad\" AFTER DELETE ON \"${tableName}\" BEGIN\n INSERT INTO \"${ftsTableName}\"(\"${ftsTableName}\", rowid, ${columnList}) VALUES ('delete', old.${contentRowid}, ${columns.map((c) => `old.\"${c}\"`).join(\", \")});\n END\n `,\n );\n\n await execRun(\n db,\n `\n CREATE TRIGGER IF NOT EXISTS \"${tableName}_au\" AFTER UPDATE ON \"${tableName}\" BEGIN\n INSERT INTO \"${ftsTableName}\"(\"${ftsTableName}\", rowid, ${columnList}) VALUES ('delete', old.${contentRowid}, ${columns.map((c) => `old.\"${c}\"`).join(\", \")});\n INSERT INTO \"${ftsTableName}\"(rowid, ${columnList}) VALUES (new.${contentRowid}, ${columns.map((c) => `new.\"${c}\"`).join(\", \")});\n END\n `,\n );\n }\n\n /**\n * Rebuilds FTS index for a table (useful after bulk inserts)\n */\n async rebuildFTS(db: LibSQLDatabase, tableName: string): Promise<void> {\n const ftsTableName = `${tableName}_fts`;\n await execRun(db, `INSERT INTO \"${ftsTableName}\"(\"${ftsTableName}\") VALUES ('rebuild')`);\n }\n}\n"],"mappings":"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"}
@@ -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;