@aigne/afs-sqlite 1.0.1-beta

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 (76) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/LICENSE.md +93 -0
  3. package/README.md +277 -0
  4. package/lib/cjs/actions/built-in.d.ts +5 -0
  5. package/lib/cjs/actions/built-in.js +165 -0
  6. package/lib/cjs/actions/registry.d.ts +49 -0
  7. package/lib/cjs/actions/registry.js +102 -0
  8. package/lib/cjs/actions/types.d.ts +51 -0
  9. package/lib/cjs/actions/types.js +2 -0
  10. package/lib/cjs/config.d.ts +89 -0
  11. package/lib/cjs/config.js +33 -0
  12. package/lib/cjs/index.d.ts +13 -0
  13. package/lib/cjs/index.js +47 -0
  14. package/lib/cjs/node/builder.d.ts +43 -0
  15. package/lib/cjs/node/builder.js +187 -0
  16. package/lib/cjs/operations/crud.d.ts +64 -0
  17. package/lib/cjs/operations/crud.js +225 -0
  18. package/lib/cjs/operations/query-builder.d.ts +37 -0
  19. package/lib/cjs/operations/query-builder.js +102 -0
  20. package/lib/cjs/operations/search.d.ts +75 -0
  21. package/lib/cjs/operations/search.js +172 -0
  22. package/lib/cjs/package.json +3 -0
  23. package/lib/cjs/router/path-router.d.ts +38 -0
  24. package/lib/cjs/router/path-router.js +90 -0
  25. package/lib/cjs/router/types.d.ts +30 -0
  26. package/lib/cjs/router/types.js +2 -0
  27. package/lib/cjs/schema/introspector.d.ts +48 -0
  28. package/lib/cjs/schema/introspector.js +186 -0
  29. package/lib/cjs/schema/types.d.ts +104 -0
  30. package/lib/cjs/schema/types.js +13 -0
  31. package/lib/cjs/sqlite-afs.d.ts +144 -0
  32. package/lib/cjs/sqlite-afs.js +337 -0
  33. package/lib/dts/actions/built-in.d.ts +5 -0
  34. package/lib/dts/actions/registry.d.ts +49 -0
  35. package/lib/dts/actions/types.d.ts +51 -0
  36. package/lib/dts/config.d.ts +89 -0
  37. package/lib/dts/index.d.ts +13 -0
  38. package/lib/dts/node/builder.d.ts +43 -0
  39. package/lib/dts/operations/crud.d.ts +64 -0
  40. package/lib/dts/operations/query-builder.d.ts +37 -0
  41. package/lib/dts/operations/search.d.ts +75 -0
  42. package/lib/dts/router/path-router.d.ts +38 -0
  43. package/lib/dts/router/types.d.ts +30 -0
  44. package/lib/dts/schema/introspector.d.ts +48 -0
  45. package/lib/dts/schema/types.d.ts +104 -0
  46. package/lib/dts/sqlite-afs.d.ts +144 -0
  47. package/lib/esm/actions/built-in.d.ts +5 -0
  48. package/lib/esm/actions/built-in.js +162 -0
  49. package/lib/esm/actions/registry.d.ts +49 -0
  50. package/lib/esm/actions/registry.js +98 -0
  51. package/lib/esm/actions/types.d.ts +51 -0
  52. package/lib/esm/actions/types.js +1 -0
  53. package/lib/esm/config.d.ts +89 -0
  54. package/lib/esm/config.js +30 -0
  55. package/lib/esm/index.d.ts +13 -0
  56. package/lib/esm/index.js +17 -0
  57. package/lib/esm/node/builder.d.ts +43 -0
  58. package/lib/esm/node/builder.js +177 -0
  59. package/lib/esm/operations/crud.d.ts +64 -0
  60. package/lib/esm/operations/crud.js +221 -0
  61. package/lib/esm/operations/query-builder.d.ts +37 -0
  62. package/lib/esm/operations/query-builder.js +92 -0
  63. package/lib/esm/operations/search.d.ts +75 -0
  64. package/lib/esm/operations/search.js +167 -0
  65. package/lib/esm/package.json +3 -0
  66. package/lib/esm/router/path-router.d.ts +38 -0
  67. package/lib/esm/router/path-router.js +83 -0
  68. package/lib/esm/router/types.d.ts +30 -0
  69. package/lib/esm/router/types.js +1 -0
  70. package/lib/esm/schema/introspector.d.ts +48 -0
  71. package/lib/esm/schema/introspector.js +182 -0
  72. package/lib/esm/schema/types.d.ts +104 -0
  73. package/lib/esm/schema/types.js +10 -0
  74. package/lib/esm/sqlite-afs.d.ts +144 -0
  75. package/lib/esm/sqlite-afs.js +333 -0
  76. package/package.json +71 -0
@@ -0,0 +1,83 @@
1
+ import { createRouter } from "radix3";
2
+ /**
3
+ * Creates a radix3 router for SQLite AFS path routing
4
+ *
5
+ * Routes:
6
+ * - / → listTables
7
+ * - /:table → listTable
8
+ * - /:table/new → createRow
9
+ * - /:table/@schema → getSchema
10
+ * - /:table/:pk → readRow
11
+ * - /:table/:pk/@attr → listAttributes
12
+ * - /:table/:pk/@attr/:column → getAttribute
13
+ * - /:table/:pk/@meta → getMeta
14
+ * - /:table/:pk/@actions → listActions
15
+ * - /:table/:pk/@actions/:action → executeAction
16
+ */
17
+ export function createPathRouter() {
18
+ return createRouter({
19
+ routes: {
20
+ // Root - list all tables
21
+ "/": { action: "listTables" },
22
+ // Table-level routes
23
+ "/:table": { action: "listTable" },
24
+ "/:table/new": { action: "createRow" },
25
+ "/:table/@schema": { action: "getSchema" },
26
+ // Row-level routes
27
+ "/:table/:pk": { action: "readRow" },
28
+ "/:table/:pk/@attr": { action: "listAttributes" },
29
+ "/:table/:pk/@attr/:column": { action: "getAttribute" },
30
+ "/:table/:pk/@meta": { action: "getMeta" },
31
+ "/:table/:pk/@actions": { action: "listActions" },
32
+ "/:table/:pk/@actions/:action": { action: "executeAction" },
33
+ },
34
+ });
35
+ }
36
+ /**
37
+ * Parses a path and returns the matched route with params
38
+ * @param router - The radix3 router instance
39
+ * @param path - The path to match
40
+ * @returns RouteMatch if matched, undefined otherwise
41
+ */
42
+ export function matchPath(router, path) {
43
+ const result = router.lookup(path);
44
+ if (!result)
45
+ return undefined;
46
+ return {
47
+ action: result.action,
48
+ params: (result.params ?? {}),
49
+ };
50
+ }
51
+ /**
52
+ * Builds a path from components
53
+ */
54
+ export function buildPath(table, pk, suffix) {
55
+ const parts = ["/"];
56
+ if (table)
57
+ parts.push(table);
58
+ if (pk)
59
+ parts.push(pk);
60
+ if (suffix)
61
+ parts.push(suffix);
62
+ return parts.join("/").replace(/\/+/g, "/");
63
+ }
64
+ /**
65
+ * Checks if a path segment is a virtual path (@attr, @meta, @actions, @schema)
66
+ */
67
+ export function isVirtualPath(segment) {
68
+ return segment.startsWith("@");
69
+ }
70
+ /**
71
+ * Gets the type of virtual path
72
+ */
73
+ export function getVirtualPathType(segment) {
74
+ if (segment === "@attr")
75
+ return "attr";
76
+ if (segment === "@meta")
77
+ return "meta";
78
+ if (segment === "@actions")
79
+ return "actions";
80
+ if (segment === "@schema")
81
+ return "schema";
82
+ return null;
83
+ }
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Route action types for SQLite AFS
3
+ */
4
+ export type RouteAction = "listTables" | "listTable" | "readRow" | "createRow" | "getSchema" | "listAttributes" | "getAttribute" | "getMeta" | "listActions" | "executeAction";
5
+ /**
6
+ * Route data associated with each path pattern
7
+ */
8
+ export interface RouteData {
9
+ /** The action to perform for this route */
10
+ action: RouteAction;
11
+ }
12
+ /**
13
+ * Route match result with params
14
+ */
15
+ export interface RouteMatch extends RouteData {
16
+ params: RouteParams;
17
+ }
18
+ /**
19
+ * Dynamic route parameters extracted from path
20
+ */
21
+ export interface RouteParams {
22
+ /** Table name */
23
+ table?: string;
24
+ /** Primary key value */
25
+ pk?: string;
26
+ /** Column name for attribute access */
27
+ column?: string;
28
+ /** Action name for @actions */
29
+ action?: string;
30
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,48 @@
1
+ import type { LibSQLDatabase } from "drizzle-orm/libsql";
2
+ import { type TableSchema } from "./types.js";
3
+ /**
4
+ * Schema introspector that uses SQLite PRAGMA queries to discover database schema
5
+ */
6
+ export declare class SchemaIntrospector {
7
+ /**
8
+ * Introspects all tables in the database
9
+ * @param db - Drizzle database instance
10
+ * @param options - Introspection options
11
+ * @returns Map of table name to TableSchema
12
+ */
13
+ introspect(db: LibSQLDatabase, options?: {
14
+ /** Whitelist of tables to include */
15
+ tables?: string[];
16
+ /** 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) */
40
+ contentTable?: string;
41
+ /** Content rowid column (defaults to 'rowid') */
42
+ contentRowid?: string;
43
+ }): Promise<void>;
44
+ /**
45
+ * Rebuilds FTS index for a table (useful after bulk inserts)
46
+ */
47
+ rebuildFTS(db: LibSQLDatabase, tableName: string): Promise<void>;
48
+ }
@@ -0,0 +1,182 @@
1
+ import { sql } from "@aigne/sqlite";
2
+ import { SYSTEM_TABLES, } from "./types.js";
3
+ /**
4
+ * Executes a raw SQL query and returns all rows
5
+ */
6
+ async function execAll(db, query) {
7
+ return db.all(sql.raw(query)).execute();
8
+ }
9
+ /**
10
+ * Executes a raw SQL query (for INSERT, UPDATE, DELETE)
11
+ */
12
+ async function execRun(db, query) {
13
+ await db.run(sql.raw(query)).execute();
14
+ }
15
+ /**
16
+ * Maps raw PRAGMA table_info row to ColumnInfo
17
+ */
18
+ function mapColumn(row) {
19
+ return {
20
+ name: row.name,
21
+ type: row.type,
22
+ notnull: row.notnull === 1,
23
+ pk: row.pk,
24
+ dfltValue: row.dflt_value,
25
+ };
26
+ }
27
+ /**
28
+ * Maps raw PRAGMA foreign_key_list row to ForeignKeyInfo
29
+ */
30
+ function mapForeignKey(row) {
31
+ return {
32
+ id: row.id,
33
+ seq: row.seq,
34
+ table: row.table,
35
+ from: row.from,
36
+ to: row.to,
37
+ onUpdate: row.on_update,
38
+ onDelete: row.on_delete,
39
+ match: row.match,
40
+ };
41
+ }
42
+ /**
43
+ * Maps raw PRAGMA index_list row to IndexInfo
44
+ */
45
+ function mapIndex(row) {
46
+ return {
47
+ seq: row.seq,
48
+ name: row.name,
49
+ unique: row.unique === 1,
50
+ origin: row.origin,
51
+ partial: row.partial === 1,
52
+ };
53
+ }
54
+ /**
55
+ * Schema introspector that uses SQLite PRAGMA queries to discover database schema
56
+ */
57
+ export class SchemaIntrospector {
58
+ /**
59
+ * Introspects all tables in the database
60
+ * @param db - Drizzle database instance
61
+ * @param options - Introspection options
62
+ * @returns Map of table name to TableSchema
63
+ */
64
+ async introspect(db, options) {
65
+ const schemas = new Map();
66
+ // Get all user tables (exclude system tables and FTS tables)
67
+ const tablesResult = await execAll(db, `
68
+ SELECT name FROM sqlite_master
69
+ WHERE type = 'table'
70
+ AND name NOT LIKE 'sqlite_%'
71
+ AND name NOT LIKE '%_fts%'
72
+ ORDER BY name
73
+ `);
74
+ for (const { name } of tablesResult) {
75
+ // Skip system tables
76
+ if (SYSTEM_TABLES.includes(name)) {
77
+ continue;
78
+ }
79
+ // Apply whitelist filter
80
+ if (options?.tables && !options.tables.includes(name)) {
81
+ continue;
82
+ }
83
+ // Apply exclude filter
84
+ if (options?.excludeTables?.includes(name)) {
85
+ continue;
86
+ }
87
+ const schema = await this.introspectTable(db, name);
88
+ schemas.set(name, schema);
89
+ }
90
+ return schemas;
91
+ }
92
+ /**
93
+ * Introspects a single table
94
+ * @param db - Drizzle database instance
95
+ * @param tableName - Name of the table to introspect
96
+ * @returns TableSchema for the specified table
97
+ */
98
+ async introspectTable(db, tableName) {
99
+ // Get column information
100
+ const columnsResult = await execAll(db, `PRAGMA table_info("${tableName}")`);
101
+ const columns = columnsResult.map(mapColumn);
102
+ // Get primary key columns (pk > 0 indicates part of primary key)
103
+ const primaryKey = columns.filter((c) => c.pk > 0).map((c) => c.name);
104
+ // Get foreign keys
105
+ const fksResult = await execAll(db, `PRAGMA foreign_key_list("${tableName}")`);
106
+ const foreignKeys = fksResult.map(mapForeignKey);
107
+ // Get indexes
108
+ const indexesResult = await execAll(db, `PRAGMA index_list("${tableName}")`);
109
+ const indexes = indexesResult.map(mapIndex);
110
+ return {
111
+ name: tableName,
112
+ columns,
113
+ primaryKey,
114
+ foreignKeys,
115
+ indexes,
116
+ };
117
+ }
118
+ /**
119
+ * Gets the primary key column name for a table
120
+ * Returns the first PK column, or 'rowid' if no explicit PK
121
+ */
122
+ getPrimaryKeyColumn(schema) {
123
+ if (schema.primaryKey.length > 0 && schema.primaryKey[0]) {
124
+ return schema.primaryKey[0];
125
+ }
126
+ // SQLite tables without explicit PK use rowid
127
+ return "rowid";
128
+ }
129
+ /**
130
+ * Checks if a table has FTS (Full-Text Search) enabled
131
+ */
132
+ async hasFTS(db, tableName) {
133
+ const ftsTableName = `${tableName}_fts`;
134
+ const result = await execAll(db, `
135
+ SELECT name FROM sqlite_master
136
+ WHERE type = 'table'
137
+ AND name = '${ftsTableName}'
138
+ `);
139
+ return result.length > 0;
140
+ }
141
+ /**
142
+ * Creates FTS5 table for full-text search on specified columns
143
+ */
144
+ async createFTS(db, tableName, columns, options) {
145
+ const ftsTableName = `${tableName}_fts`;
146
+ const contentTable = options?.contentTable ?? tableName;
147
+ const contentRowid = options?.contentRowid ?? "rowid";
148
+ const columnList = columns.join(", ");
149
+ // Create FTS5 virtual table
150
+ await execRun(db, `
151
+ CREATE VIRTUAL TABLE IF NOT EXISTS "${ftsTableName}" USING fts5(
152
+ ${columnList},
153
+ content="${contentTable}",
154
+ content_rowid="${contentRowid}"
155
+ )
156
+ `);
157
+ // Create triggers to keep FTS in sync
158
+ await execRun(db, `
159
+ CREATE TRIGGER IF NOT EXISTS "${tableName}_ai" AFTER INSERT ON "${tableName}" BEGIN
160
+ INSERT INTO "${ftsTableName}"(rowid, ${columnList}) VALUES (new.${contentRowid}, ${columns.map((c) => `new."${c}"`).join(", ")});
161
+ END
162
+ `);
163
+ await execRun(db, `
164
+ CREATE TRIGGER IF NOT EXISTS "${tableName}_ad" AFTER DELETE ON "${tableName}" BEGIN
165
+ INSERT INTO "${ftsTableName}"("${ftsTableName}", rowid, ${columnList}) VALUES ('delete', old.${contentRowid}, ${columns.map((c) => `old."${c}"`).join(", ")});
166
+ END
167
+ `);
168
+ await execRun(db, `
169
+ CREATE TRIGGER IF NOT EXISTS "${tableName}_au" AFTER UPDATE ON "${tableName}" BEGIN
170
+ INSERT INTO "${ftsTableName}"("${ftsTableName}", rowid, ${columnList}) VALUES ('delete', old.${contentRowid}, ${columns.map((c) => `old."${c}"`).join(", ")});
171
+ INSERT INTO "${ftsTableName}"(rowid, ${columnList}) VALUES (new.${contentRowid}, ${columns.map((c) => `new."${c}"`).join(", ")});
172
+ END
173
+ `);
174
+ }
175
+ /**
176
+ * Rebuilds FTS index for a table (useful after bulk inserts)
177
+ */
178
+ async rebuildFTS(db, tableName) {
179
+ const ftsTableName = `${tableName}_fts`;
180
+ await execRun(db, `INSERT INTO "${ftsTableName}"("${ftsTableName}") VALUES ('rebuild')`);
181
+ }
182
+ }
@@ -0,0 +1,104 @@
1
+ /**
2
+ * Column information from SQLite PRAGMA table_info
3
+ */
4
+ export interface ColumnInfo {
5
+ /** Column name */
6
+ name: string;
7
+ /** SQLite type (INTEGER, TEXT, REAL, BLOB, etc.) */
8
+ type: string;
9
+ /** Whether the column has NOT NULL constraint */
10
+ notnull: boolean;
11
+ /** Whether this column is part of the primary key */
12
+ pk: number;
13
+ /** Default value for the column */
14
+ dfltValue: unknown;
15
+ }
16
+ /**
17
+ * Foreign key information from SQLite PRAGMA foreign_key_list
18
+ */
19
+ export interface ForeignKeyInfo {
20
+ /** Foreign key id */
21
+ id: number;
22
+ /** Sequence number for composite foreign keys */
23
+ seq: number;
24
+ /** Referenced table */
25
+ table: string;
26
+ /** Column in this table */
27
+ from: string;
28
+ /** Column in referenced table */
29
+ to: string;
30
+ /** ON UPDATE action */
31
+ onUpdate: string;
32
+ /** ON DELETE action */
33
+ onDelete: string;
34
+ /** MATCH clause */
35
+ match: string;
36
+ }
37
+ /**
38
+ * Index information from SQLite PRAGMA index_list
39
+ */
40
+ export interface IndexInfo {
41
+ /** Index sequence number */
42
+ seq: number;
43
+ /** Index name */
44
+ name: string;
45
+ /** Whether this is a unique index */
46
+ unique: boolean;
47
+ /** Origin of the index (c = CREATE INDEX, u = UNIQUE constraint, pk = PRIMARY KEY) */
48
+ origin: string;
49
+ /** Whether the index is partial */
50
+ partial: boolean;
51
+ }
52
+ /**
53
+ * Complete schema information for a single table
54
+ */
55
+ export interface TableSchema {
56
+ /** Table name */
57
+ name: string;
58
+ /** Column definitions */
59
+ columns: ColumnInfo[];
60
+ /** Primary key column names */
61
+ primaryKey: string[];
62
+ /** Foreign key relationships */
63
+ foreignKeys: ForeignKeyInfo[];
64
+ /** Indexes on this table */
65
+ indexes: IndexInfo[];
66
+ }
67
+ /**
68
+ * Raw PRAGMA table_info result row
69
+ */
70
+ export interface PragmaTableInfoRow {
71
+ cid: number;
72
+ name: string;
73
+ type: string;
74
+ notnull: number;
75
+ dflt_value: unknown;
76
+ pk: number;
77
+ }
78
+ /**
79
+ * Raw PRAGMA foreign_key_list result row
80
+ */
81
+ export interface PragmaForeignKeyRow {
82
+ id: number;
83
+ seq: number;
84
+ table: string;
85
+ from: string;
86
+ to: string;
87
+ on_update: string;
88
+ on_delete: string;
89
+ match: string;
90
+ }
91
+ /**
92
+ * Raw PRAGMA index_list result row
93
+ */
94
+ export interface PragmaIndexListRow {
95
+ seq: number;
96
+ name: string;
97
+ unique: number;
98
+ origin: string;
99
+ partial: number;
100
+ }
101
+ /**
102
+ * System tables that should be excluded from introspection
103
+ */
104
+ export declare const SYSTEM_TABLES: readonly ["sqlite_sequence", "sqlite_stat1", "sqlite_stat2", "sqlite_stat3", "sqlite_stat4"];
@@ -0,0 +1,10 @@
1
+ /**
2
+ * System tables that should be excluded from introspection
3
+ */
4
+ export const SYSTEM_TABLES = [
5
+ "sqlite_sequence",
6
+ "sqlite_stat1",
7
+ "sqlite_stat2",
8
+ "sqlite_stat3",
9
+ "sqlite_stat4",
10
+ ];
@@ -0,0 +1,144 @@
1
+ import type { AFSAccessMode, AFSDeleteOptions, AFSDeleteResult, AFSExecOptions, AFSExecResult, AFSListOptions, AFSListResult, AFSModule, AFSModuleLoadParams, AFSReadOptions, AFSReadResult, AFSRoot, AFSSearchOptions, AFSSearchResult, AFSWriteEntryPayload, AFSWriteOptions, AFSWriteResult } from "@aigne/afs";
2
+ import type { LibSQLDatabase } from "drizzle-orm/libsql";
3
+ import type { ActionContext } from "./actions/types.js";
4
+ import { type SQLiteAFSOptions } from "./config.js";
5
+ import type { TableSchema } from "./schema/types.js";
6
+ /**
7
+ * SQLite AFS Module
8
+ *
9
+ * Exposes SQLite databases as AFS nodes with full CRUD support,
10
+ * schema introspection, FTS5 search, and virtual paths (@attr, @meta, @actions).
11
+ */
12
+ export declare class SQLiteAFS implements AFSModule {
13
+ private options;
14
+ readonly name: string;
15
+ readonly description: string;
16
+ readonly accessMode: AFSAccessMode;
17
+ private db;
18
+ private schemas;
19
+ private router;
20
+ private crud;
21
+ private ftsSearch;
22
+ private actions;
23
+ private ftsConfig;
24
+ private initialized;
25
+ constructor(options: SQLiteAFSOptions);
26
+ /**
27
+ * Returns the Zod schema for configuration validation
28
+ */
29
+ static schema(): import("zod").ZodObject<{
30
+ url: import("zod").ZodString;
31
+ name: import("zod").ZodOptional<import("zod").ZodString>;
32
+ description: import("zod").ZodOptional<import("zod").ZodString>;
33
+ accessMode: import("zod").ZodOptional<import("zod").ZodEnum<["readonly", "readwrite"]>>;
34
+ tables: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString, "many">>;
35
+ excludeTables: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString, "many">>;
36
+ fts: import("zod").ZodOptional<import("zod").ZodObject<{
37
+ enabled: import("zod").ZodDefault<import("zod").ZodBoolean>;
38
+ tables: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodArray<import("zod").ZodString, "many">>>;
39
+ }, "strip", import("zod").ZodTypeAny, {
40
+ enabled: boolean;
41
+ tables?: Record<string, string[]> | undefined;
42
+ }, {
43
+ enabled?: boolean | undefined;
44
+ tables?: Record<string, string[]> | undefined;
45
+ }>>;
46
+ wal: import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodBoolean>>;
47
+ }, "strip", import("zod").ZodTypeAny, {
48
+ url: string;
49
+ wal: boolean;
50
+ tables?: string[] | undefined;
51
+ name?: string | undefined;
52
+ description?: string | undefined;
53
+ accessMode?: "readonly" | "readwrite" | undefined;
54
+ excludeTables?: string[] | undefined;
55
+ fts?: {
56
+ enabled: boolean;
57
+ tables?: Record<string, string[]> | undefined;
58
+ } | undefined;
59
+ }, {
60
+ url: string;
61
+ tables?: string[] | undefined;
62
+ name?: string | undefined;
63
+ description?: string | undefined;
64
+ accessMode?: "readonly" | "readwrite" | undefined;
65
+ excludeTables?: string[] | undefined;
66
+ fts?: {
67
+ enabled?: boolean | undefined;
68
+ tables?: Record<string, string[]> | undefined;
69
+ } | undefined;
70
+ wal?: boolean | undefined;
71
+ }>;
72
+ /**
73
+ * Loads a module instance from configuration
74
+ */
75
+ static load({ parsed }: AFSModuleLoadParams): Promise<SQLiteAFS>;
76
+ /**
77
+ * Called when the module is mounted to AFS
78
+ */
79
+ onMount(_afs: AFSRoot): Promise<void>;
80
+ /**
81
+ * Initializes the database connection and introspects schema
82
+ */
83
+ private initialize;
84
+ /**
85
+ * Ensures the module is initialized
86
+ */
87
+ private ensureInitialized;
88
+ /**
89
+ * Lists entries at a path
90
+ */
91
+ list(path: string, options?: AFSListOptions): Promise<AFSListResult>;
92
+ /**
93
+ * Reads an entry at a path
94
+ */
95
+ read(path: string, _options?: AFSReadOptions): Promise<AFSReadResult>;
96
+ /**
97
+ * Writes an entry at a path
98
+ */
99
+ write(path: string, content: AFSWriteEntryPayload, _options?: AFSWriteOptions): Promise<AFSWriteResult>;
100
+ /**
101
+ * Deletes an entry at a path
102
+ */
103
+ delete(path: string, _options?: AFSDeleteOptions): Promise<AFSDeleteResult>;
104
+ /**
105
+ * Searches for entries matching a query
106
+ */
107
+ search(path: string, query: string, options?: AFSSearchOptions): Promise<AFSSearchResult>;
108
+ /**
109
+ * Executes a module operation
110
+ */
111
+ exec(path: string, args: Record<string, unknown>, _options: AFSExecOptions): Promise<AFSExecResult>;
112
+ /**
113
+ * Lists available actions for a row
114
+ */
115
+ private listActions;
116
+ /**
117
+ * Executes an action
118
+ */
119
+ private executeAction;
120
+ /**
121
+ * Refreshes the schema cache
122
+ */
123
+ refreshSchema(): Promise<void>;
124
+ /**
125
+ * Exports table data in specified format
126
+ */
127
+ exportTable(table: string, format: string): Promise<unknown>;
128
+ /**
129
+ * Registers a custom action
130
+ */
131
+ registerAction(name: string, handler: (ctx: ActionContext, params: Record<string, unknown>) => Promise<unknown>, options?: {
132
+ description?: string;
133
+ tableLevel?: boolean;
134
+ rowLevel?: boolean;
135
+ }): void;
136
+ /**
137
+ * Gets table schemas (for external access)
138
+ */
139
+ getSchemas(): Map<string, TableSchema>;
140
+ /**
141
+ * Gets the database instance (for advanced operations)
142
+ */
143
+ getDatabase(): LibSQLDatabase;
144
+ }