@aigne/afs-sqlite 1.1.0-beta.1 → 1.11.0-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 (82) hide show
  1. package/README.md +51 -36
  2. package/dist/index.cjs +1324 -0
  3. package/dist/index.d.cts +758 -0
  4. package/dist/index.d.cts.map +1 -0
  5. package/dist/index.d.mts +758 -0
  6. package/dist/index.d.mts.map +1 -0
  7. package/dist/index.mjs +1299 -0
  8. package/dist/index.mjs.map +1 -0
  9. package/package.json +31 -44
  10. package/CHANGELOG.md +0 -61
  11. package/lib/cjs/actions/built-in.d.ts +0 -5
  12. package/lib/cjs/actions/built-in.js +0 -165
  13. package/lib/cjs/actions/registry.d.ts +0 -49
  14. package/lib/cjs/actions/registry.js +0 -102
  15. package/lib/cjs/actions/types.d.ts +0 -51
  16. package/lib/cjs/actions/types.js +0 -2
  17. package/lib/cjs/config.d.ts +0 -89
  18. package/lib/cjs/config.js +0 -33
  19. package/lib/cjs/index.d.ts +0 -13
  20. package/lib/cjs/index.js +0 -47
  21. package/lib/cjs/node/builder.d.ts +0 -43
  22. package/lib/cjs/node/builder.js +0 -187
  23. package/lib/cjs/operations/crud.d.ts +0 -64
  24. package/lib/cjs/operations/crud.js +0 -225
  25. package/lib/cjs/operations/query-builder.d.ts +0 -37
  26. package/lib/cjs/operations/query-builder.js +0 -102
  27. package/lib/cjs/operations/search.d.ts +0 -75
  28. package/lib/cjs/operations/search.js +0 -172
  29. package/lib/cjs/package.json +0 -3
  30. package/lib/cjs/router/path-router.d.ts +0 -38
  31. package/lib/cjs/router/path-router.js +0 -90
  32. package/lib/cjs/router/types.d.ts +0 -30
  33. package/lib/cjs/router/types.js +0 -2
  34. package/lib/cjs/schema/introspector.d.ts +0 -48
  35. package/lib/cjs/schema/introspector.js +0 -186
  36. package/lib/cjs/schema/types.d.ts +0 -104
  37. package/lib/cjs/schema/types.js +0 -13
  38. package/lib/cjs/sqlite-afs.d.ts +0 -144
  39. package/lib/cjs/sqlite-afs.js +0 -337
  40. package/lib/dts/actions/built-in.d.ts +0 -5
  41. package/lib/dts/actions/registry.d.ts +0 -49
  42. package/lib/dts/actions/types.d.ts +0 -51
  43. package/lib/dts/config.d.ts +0 -89
  44. package/lib/dts/index.d.ts +0 -13
  45. package/lib/dts/node/builder.d.ts +0 -43
  46. package/lib/dts/operations/crud.d.ts +0 -64
  47. package/lib/dts/operations/query-builder.d.ts +0 -37
  48. package/lib/dts/operations/search.d.ts +0 -75
  49. package/lib/dts/router/path-router.d.ts +0 -38
  50. package/lib/dts/router/types.d.ts +0 -30
  51. package/lib/dts/schema/introspector.d.ts +0 -48
  52. package/lib/dts/schema/types.d.ts +0 -104
  53. package/lib/dts/sqlite-afs.d.ts +0 -144
  54. package/lib/esm/actions/built-in.d.ts +0 -5
  55. package/lib/esm/actions/built-in.js +0 -162
  56. package/lib/esm/actions/registry.d.ts +0 -49
  57. package/lib/esm/actions/registry.js +0 -98
  58. package/lib/esm/actions/types.d.ts +0 -51
  59. package/lib/esm/actions/types.js +0 -1
  60. package/lib/esm/config.d.ts +0 -89
  61. package/lib/esm/config.js +0 -30
  62. package/lib/esm/index.d.ts +0 -13
  63. package/lib/esm/index.js +0 -17
  64. package/lib/esm/node/builder.d.ts +0 -43
  65. package/lib/esm/node/builder.js +0 -177
  66. package/lib/esm/operations/crud.d.ts +0 -64
  67. package/lib/esm/operations/crud.js +0 -221
  68. package/lib/esm/operations/query-builder.d.ts +0 -37
  69. package/lib/esm/operations/query-builder.js +0 -92
  70. package/lib/esm/operations/search.d.ts +0 -75
  71. package/lib/esm/operations/search.js +0 -167
  72. package/lib/esm/package.json +0 -3
  73. package/lib/esm/router/path-router.d.ts +0 -38
  74. package/lib/esm/router/path-router.js +0 -83
  75. package/lib/esm/router/types.d.ts +0 -30
  76. package/lib/esm/router/types.js +0 -1
  77. package/lib/esm/schema/introspector.d.ts +0 -48
  78. package/lib/esm/schema/introspector.js +0 -182
  79. package/lib/esm/schema/types.d.ts +0 -104
  80. package/lib/esm/schema/types.js +0 -10
  81. package/lib/esm/sqlite-afs.d.ts +0 -144
  82. package/lib/esm/sqlite-afs.js +0 -333
@@ -0,0 +1,758 @@
1
+ import { LibSQLDatabase } from "drizzle-orm/libsql";
2
+ import { AFSAccessMode, AFSDeleteOptions, AFSDeleteResult, AFSEntry, AFSExecOptions, AFSExecResult, AFSListOptions, AFSListResult, AFSModule, AFSModuleLoadParams, AFSReadOptions, AFSReadResult, AFSRoot, AFSSearchOptions, AFSSearchResult, AFSWriteEntryPayload, AFSWriteOptions, AFSWriteResult } from "@aigne/afs";
3
+ import * as zod0 from "zod";
4
+ import { z } from "zod";
5
+ import { RadixRouter } from "radix3";
6
+
7
+ //#region src/schema/types.d.ts
8
+ /**
9
+ * Column information from SQLite PRAGMA table_info
10
+ */
11
+ interface ColumnInfo {
12
+ /** Column name */
13
+ name: string;
14
+ /** SQLite type (INTEGER, TEXT, REAL, BLOB, etc.) */
15
+ type: string;
16
+ /** Whether the column has NOT NULL constraint */
17
+ notnull: boolean;
18
+ /** Whether this column is part of the primary key */
19
+ pk: number;
20
+ /** Default value for the column */
21
+ dfltValue: unknown;
22
+ }
23
+ /**
24
+ * Foreign key information from SQLite PRAGMA foreign_key_list
25
+ */
26
+ interface ForeignKeyInfo {
27
+ /** Foreign key id */
28
+ id: number;
29
+ /** Sequence number for composite foreign keys */
30
+ seq: number;
31
+ /** Referenced table */
32
+ table: string;
33
+ /** Column in this table */
34
+ from: string;
35
+ /** Column in referenced table */
36
+ to: string;
37
+ /** ON UPDATE action */
38
+ onUpdate: string;
39
+ /** ON DELETE action */
40
+ onDelete: string;
41
+ /** MATCH clause */
42
+ match: string;
43
+ }
44
+ /**
45
+ * Index information from SQLite PRAGMA index_list
46
+ */
47
+ interface IndexInfo {
48
+ /** Index sequence number */
49
+ seq: number;
50
+ /** Index name */
51
+ name: string;
52
+ /** Whether this is a unique index */
53
+ unique: boolean;
54
+ /** Origin of the index (c = CREATE INDEX, u = UNIQUE constraint, pk = PRIMARY KEY) */
55
+ origin: string;
56
+ /** Whether the index is partial */
57
+ partial: boolean;
58
+ }
59
+ /**
60
+ * Complete schema information for a single table
61
+ */
62
+ interface TableSchema {
63
+ /** Table name */
64
+ name: string;
65
+ /** Column definitions */
66
+ columns: ColumnInfo[];
67
+ /** Primary key column names */
68
+ primaryKey: string[];
69
+ /** Foreign key relationships */
70
+ foreignKeys: ForeignKeyInfo[];
71
+ /** Indexes on this table */
72
+ indexes: IndexInfo[];
73
+ }
74
+ /**
75
+ * Raw PRAGMA table_info result row
76
+ */
77
+ interface PragmaTableInfoRow {
78
+ cid: number;
79
+ name: string;
80
+ type: string;
81
+ notnull: number;
82
+ dflt_value: unknown;
83
+ pk: number;
84
+ }
85
+ /**
86
+ * Raw PRAGMA foreign_key_list result row
87
+ */
88
+ interface PragmaForeignKeyRow {
89
+ id: number;
90
+ seq: number;
91
+ table: string;
92
+ from: string;
93
+ to: string;
94
+ on_update: string;
95
+ on_delete: string;
96
+ match: string;
97
+ }
98
+ /**
99
+ * Raw PRAGMA index_list result row
100
+ */
101
+ interface PragmaIndexListRow {
102
+ seq: number;
103
+ name: string;
104
+ unique: number;
105
+ origin: string;
106
+ partial: number;
107
+ }
108
+ //#endregion
109
+ //#region src/actions/types.d.ts
110
+ /**
111
+ * Context provided to action handlers
112
+ */
113
+ interface ActionContext {
114
+ /** Database instance */
115
+ db: LibSQLDatabase;
116
+ /** All table schemas */
117
+ schemas: Map<string, TableSchema>;
118
+ /** Table this action is being executed on */
119
+ table: string;
120
+ /** Primary key of the row (if row-level action) */
121
+ pk?: string;
122
+ /** The row data (if available) */
123
+ row?: Record<string, unknown>;
124
+ /** Reference to the parent module for advanced operations */
125
+ module: {
126
+ refreshSchema(): Promise<void>;
127
+ exportTable(table: string, format: string): Promise<unknown>;
128
+ };
129
+ }
130
+ /**
131
+ * Action handler function signature
132
+ */
133
+ type ActionHandler = (ctx: ActionContext, params: Record<string, unknown>) => Promise<ActionResult>;
134
+ /**
135
+ * Result from an action execution
136
+ */
137
+ interface ActionResult {
138
+ success: boolean;
139
+ data?: unknown;
140
+ message?: string;
141
+ }
142
+ /**
143
+ * Action definition with metadata
144
+ */
145
+ interface ActionDefinition {
146
+ /** Action name */
147
+ name: string;
148
+ /** Description of what the action does */
149
+ description?: string;
150
+ /** Whether this action is available at table level (vs row level) */
151
+ tableLevel?: boolean;
152
+ /** Whether this action is available at row level */
153
+ rowLevel?: boolean;
154
+ /** Input schema for the action parameters */
155
+ inputSchema?: Record<string, unknown>;
156
+ /** The handler function */
157
+ handler: ActionHandler;
158
+ }
159
+ //#endregion
160
+ //#region src/actions/registry.d.ts
161
+ /**
162
+ * Registry for managing action handlers
163
+ */
164
+ declare class ActionsRegistry {
165
+ private handlers;
166
+ /**
167
+ * Registers an action handler
168
+ */
169
+ register(definition: ActionDefinition): void;
170
+ /**
171
+ * Registers a simple action with just name and handler
172
+ */
173
+ registerSimple(name: string, handler: ActionHandler, options?: {
174
+ description?: string;
175
+ tableLevel?: boolean;
176
+ rowLevel?: boolean;
177
+ }): void;
178
+ /**
179
+ * Unregisters an action
180
+ */
181
+ unregister(name: string): boolean;
182
+ /**
183
+ * Checks if an action is registered
184
+ */
185
+ has(name: string): boolean;
186
+ /**
187
+ * Gets an action definition
188
+ */
189
+ get(name: string): ActionDefinition | undefined;
190
+ /**
191
+ * Lists all registered actions
192
+ */
193
+ list(options?: {
194
+ tableLevel?: boolean;
195
+ rowLevel?: boolean;
196
+ }): ActionDefinition[];
197
+ /**
198
+ * Lists action names
199
+ */
200
+ listNames(options?: {
201
+ tableLevel?: boolean;
202
+ rowLevel?: boolean;
203
+ }): string[];
204
+ /**
205
+ * Executes an action
206
+ */
207
+ execute(name: string, ctx: ActionContext, params?: Record<string, unknown>): Promise<ActionResult>;
208
+ }
209
+ //#endregion
210
+ //#region src/actions/built-in.d.ts
211
+ /**
212
+ * Registers built-in actions to the registry
213
+ */
214
+ declare function registerBuiltInActions(registry: ActionsRegistry): void;
215
+ //#endregion
216
+ //#region src/config.d.ts
217
+ /**
218
+ * SQLite AFS module configuration schema
219
+ */
220
+ declare const sqliteAFSConfigSchema: z.ZodObject<{
221
+ url: z.ZodString;
222
+ name: z.ZodOptional<z.ZodString>;
223
+ description: z.ZodOptional<z.ZodString>;
224
+ accessMode: z.ZodOptional<z.ZodEnum<["readonly", "readwrite"]>>;
225
+ tables: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
226
+ excludeTables: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
227
+ fts: z.ZodOptional<z.ZodObject<{
228
+ enabled: z.ZodDefault<z.ZodBoolean>;
229
+ tables: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString, "many">>>;
230
+ }, "strip", z.ZodTypeAny, {
231
+ enabled: boolean;
232
+ tables?: Record<string, string[]> | undefined;
233
+ }, {
234
+ tables?: Record<string, string[]> | undefined;
235
+ enabled?: boolean | undefined;
236
+ }>>;
237
+ wal: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
238
+ }, "strip", z.ZodTypeAny, {
239
+ url: string;
240
+ wal: boolean;
241
+ name?: string | undefined;
242
+ description?: string | undefined;
243
+ accessMode?: "readonly" | "readwrite" | undefined;
244
+ tables?: string[] | undefined;
245
+ excludeTables?: string[] | undefined;
246
+ fts?: {
247
+ enabled: boolean;
248
+ tables?: Record<string, string[]> | undefined;
249
+ } | undefined;
250
+ }, {
251
+ url: string;
252
+ name?: string | undefined;
253
+ description?: string | undefined;
254
+ accessMode?: "readonly" | "readwrite" | undefined;
255
+ tables?: string[] | undefined;
256
+ excludeTables?: string[] | undefined;
257
+ fts?: {
258
+ tables?: Record<string, string[]> | undefined;
259
+ enabled?: boolean | undefined;
260
+ } | undefined;
261
+ wal?: boolean | undefined;
262
+ }>;
263
+ /**
264
+ * SQLite AFS module configuration type
265
+ */
266
+ type SQLiteAFSConfig = z.infer<typeof sqliteAFSConfigSchema>;
267
+ /**
268
+ * SQLite AFS module options (after parsing)
269
+ */
270
+ interface SQLiteAFSOptions {
271
+ /** SQLite database URL */
272
+ url: string;
273
+ /** Module name */
274
+ name?: string;
275
+ /** Module description */
276
+ description?: string;
277
+ /** Access mode */
278
+ accessMode?: AFSAccessMode;
279
+ /** Tables to expose */
280
+ tables?: string[];
281
+ /** Tables to exclude */
282
+ excludeTables?: string[];
283
+ /** FTS configuration */
284
+ fts?: {
285
+ enabled?: boolean;
286
+ tables?: Record<string, string[]>;
287
+ };
288
+ /** Enable WAL mode */
289
+ wal?: boolean;
290
+ }
291
+ //#endregion
292
+ //#region src/node/builder.d.ts
293
+ /**
294
+ * Options for building an AFSEntry
295
+ */
296
+ interface BuildEntryOptions {
297
+ /** Base path prefix (e.g., empty string or module mount path) */
298
+ basePath?: string;
299
+ }
300
+ /**
301
+ * Builds an AFSEntry from a database row
302
+ */
303
+ declare function buildRowEntry(table: string, schema: TableSchema, row: Record<string, unknown>, options?: BuildEntryOptions): AFSEntry;
304
+ /**
305
+ * Builds an AFSEntry for a table listing
306
+ */
307
+ declare function buildTableEntry(table: string, schema: TableSchema, options?: BuildEntryOptions & {
308
+ rowCount?: number;
309
+ }): AFSEntry;
310
+ /**
311
+ * Builds an AFSEntry for table schema
312
+ */
313
+ declare function buildSchemaEntry(table: string, schema: TableSchema, options?: BuildEntryOptions): AFSEntry;
314
+ /**
315
+ * Builds an AFSEntry for an attribute (single column value)
316
+ */
317
+ declare function buildAttributeEntry(table: string, pk: string, column: string, value: unknown, options?: BuildEntryOptions): AFSEntry;
318
+ /**
319
+ * Builds an AFSEntry listing all attributes for a row
320
+ */
321
+ declare function buildAttributeListEntry(table: string, schema: TableSchema, pk: string, row: Record<string, unknown>, options?: BuildEntryOptions): AFSEntry[];
322
+ /**
323
+ * Builds an AFSEntry for row metadata
324
+ */
325
+ declare function buildMetaEntry(table: string, schema: TableSchema, pk: string, row: Record<string, unknown>, options?: BuildEntryOptions): AFSEntry;
326
+ /**
327
+ * Builds AFSEntry for actions list
328
+ */
329
+ declare function buildActionsListEntry(table: string, pk: string, actions: string[], options?: BuildEntryOptions): AFSEntry[];
330
+ /**
331
+ * Builds a search result entry with highlights
332
+ */
333
+ declare function buildSearchEntry(table: string, schema: TableSchema, row: Record<string, unknown>, snippet?: string, options?: BuildEntryOptions): AFSEntry;
334
+ //#endregion
335
+ //#region src/operations/crud.d.ts
336
+ /**
337
+ * CRUD operations for SQLite AFS
338
+ */
339
+ declare class CRUDOperations {
340
+ private db;
341
+ private schemas;
342
+ private basePath;
343
+ constructor(db: LibSQLDatabase, schemas: Map<string, TableSchema>, basePath?: string);
344
+ /**
345
+ * Lists all tables
346
+ */
347
+ listTables(): Promise<AFSListResult>;
348
+ /**
349
+ * Lists rows in a table
350
+ */
351
+ listTable(table: string, options?: AFSListOptions): Promise<AFSListResult>;
352
+ /**
353
+ * Reads a single row by primary key
354
+ */
355
+ readRow(table: string, pk: string): Promise<AFSReadResult>;
356
+ /**
357
+ * Gets table schema
358
+ */
359
+ getSchema(table: string): AFSReadResult;
360
+ /**
361
+ * Lists attributes (columns) for a row
362
+ */
363
+ listAttributes(table: string, pk: string): Promise<AFSListResult>;
364
+ /**
365
+ * Gets a single attribute (column value) for a row
366
+ */
367
+ getAttribute(table: string, pk: string, column: string): Promise<AFSReadResult>;
368
+ /**
369
+ * Gets row metadata
370
+ */
371
+ getMeta(table: string, pk: string): Promise<AFSReadResult>;
372
+ /**
373
+ * Creates a new row in a table
374
+ */
375
+ createRow(table: string, content: Record<string, unknown>): Promise<AFSWriteResult>;
376
+ /**
377
+ * Updates an existing row
378
+ */
379
+ updateRow(table: string, pk: string, content: Record<string, unknown>): Promise<AFSWriteResult>;
380
+ /**
381
+ * Deletes a row by primary key
382
+ */
383
+ deleteRow(table: string, pk: string): Promise<AFSDeleteResult>;
384
+ /**
385
+ * Checks if a table exists
386
+ */
387
+ hasTable(table: string): boolean;
388
+ /**
389
+ * Gets the schema for a table
390
+ */
391
+ getTableSchema(table: string): TableSchema | undefined;
392
+ /**
393
+ * Updates the schemas map (after refresh)
394
+ */
395
+ setSchemas(schemas: Map<string, TableSchema>): void;
396
+ }
397
+ //#endregion
398
+ //#region src/operations/query-builder.d.ts
399
+ /**
400
+ * Builds a SELECT query string for a single row by primary key
401
+ */
402
+ declare function buildSelectByPK(tableName: string, schema: TableSchema, pk: string): string;
403
+ /**
404
+ * Builds a SELECT query string for listing rows with optional limit and offset
405
+ */
406
+ declare function buildSelectAll(tableName: string, options?: {
407
+ limit?: number;
408
+ offset?: number;
409
+ orderBy?: [string, "asc" | "desc"][];
410
+ }): string;
411
+ /**
412
+ * Builds an INSERT query string from content object
413
+ */
414
+ declare function buildInsert(tableName: string, schema: TableSchema, content: Record<string, unknown>): string;
415
+ /**
416
+ * Builds an UPDATE query string from content object
417
+ */
418
+ declare function buildUpdate(tableName: string, schema: TableSchema, pk: string, content: Record<string, unknown>): string;
419
+ /**
420
+ * Builds a DELETE query string by primary key
421
+ */
422
+ declare function buildDelete(tableName: string, schema: TableSchema, pk: string): string;
423
+ /**
424
+ * Gets the last inserted rowid query string
425
+ */
426
+ declare function buildGetLastRowId(): string;
427
+ //#endregion
428
+ //#region src/operations/search.d.ts
429
+ /**
430
+ * FTS5 search configuration for a table
431
+ */
432
+ interface FTSTableConfig {
433
+ /** Columns to include in FTS index */
434
+ columns: string[];
435
+ /** Whether FTS table has been created */
436
+ initialized?: boolean;
437
+ }
438
+ /**
439
+ * FTS5 search configuration
440
+ */
441
+ interface FTSConfig {
442
+ /** Whether FTS is enabled */
443
+ enabled: boolean;
444
+ /** Per-table FTS configuration */
445
+ tables: Map<string, FTSTableConfig>;
446
+ }
447
+ /**
448
+ * FTS5 Search operations for SQLite AFS
449
+ */
450
+ declare class FTSSearch {
451
+ private db;
452
+ private schemas;
453
+ private config;
454
+ private basePath;
455
+ constructor(db: LibSQLDatabase, schemas: Map<string, TableSchema>, config: FTSConfig, basePath?: string);
456
+ /**
457
+ * Performs full-text search across configured tables
458
+ */
459
+ search(query: string, options?: AFSSearchOptions & {
460
+ /** Specific tables to search (defaults to all FTS-enabled tables) */tables?: string[];
461
+ }): Promise<AFSSearchResult>;
462
+ /**
463
+ * Searches within a specific table
464
+ */
465
+ searchTable(tableName: string, query: string, options?: AFSSearchOptions): Promise<AFSSearchResult>;
466
+ /**
467
+ * Checks if FTS is configured for a table
468
+ */
469
+ hasFTS(tableName: string): boolean;
470
+ /**
471
+ * Gets FTS configuration for a table
472
+ */
473
+ getFTSConfig(tableName: string): FTSTableConfig | undefined;
474
+ /**
475
+ * Checks if an FTS table exists
476
+ */
477
+ private ftsTableExists;
478
+ /**
479
+ * Prepares a query string for FTS5
480
+ * Handles special characters and case sensitivity
481
+ */
482
+ private prepareFTSQuery;
483
+ /**
484
+ * Updates the schemas map (after refresh)
485
+ */
486
+ setSchemas(schemas: Map<string, TableSchema>): void;
487
+ /**
488
+ * Simple search fallback when FTS is not available
489
+ * Uses LIKE queries on specified columns
490
+ */
491
+ simpleLikeSearch(tableName: string, query: string, columns: string[], options?: AFSSearchOptions): Promise<AFSSearchResult>;
492
+ }
493
+ /**
494
+ * Creates FTS configuration from options
495
+ */
496
+ declare function createFTSConfig(options?: {
497
+ enabled?: boolean;
498
+ tables?: Record<string, string[]>;
499
+ }): FTSConfig;
500
+ //#endregion
501
+ //#region src/router/types.d.ts
502
+ /**
503
+ * Route action types for SQLite AFS
504
+ */
505
+ type RouteAction = "listTables" | "listTable" | "readRow" | "createRow" | "getSchema" | "listAttributes" | "getAttribute" | "getMeta" | "listActions" | "executeAction";
506
+ /**
507
+ * Route data associated with each path pattern
508
+ */
509
+ interface RouteData {
510
+ /** The action to perform for this route */
511
+ action: RouteAction;
512
+ }
513
+ /**
514
+ * Route match result with params
515
+ */
516
+ interface RouteMatch extends RouteData {
517
+ params: RouteParams;
518
+ }
519
+ /**
520
+ * Dynamic route parameters extracted from path
521
+ */
522
+ interface RouteParams {
523
+ /** Table name */
524
+ table?: string;
525
+ /** Primary key value */
526
+ pk?: string;
527
+ /** Column name for attribute access */
528
+ column?: string;
529
+ /** Action name for @actions */
530
+ action?: string;
531
+ }
532
+ //#endregion
533
+ //#region src/router/path-router.d.ts
534
+ /**
535
+ * Creates a radix3 router for SQLite AFS path routing
536
+ *
537
+ * Routes:
538
+ * - / → listTables
539
+ * - /:table → listTable
540
+ * - /:table/new → createRow
541
+ * - /:table/@schema → getSchema
542
+ * - /:table/:pk → readRow
543
+ * - /:table/:pk/@attr → listAttributes
544
+ * - /:table/:pk/@attr/:column → getAttribute
545
+ * - /:table/:pk/@meta → getMeta
546
+ * - /:table/:pk/@actions → listActions
547
+ * - /:table/:pk/@actions/:action → executeAction
548
+ */
549
+ declare function createPathRouter(): RadixRouter<RouteData>;
550
+ /**
551
+ * Parses a path and returns the matched route with params
552
+ * @param router - The radix3 router instance
553
+ * @param path - The path to match
554
+ * @returns RouteMatch if matched, undefined otherwise
555
+ */
556
+ declare function matchPath(router: RadixRouter<RouteData>, path: string): RouteMatch | undefined;
557
+ /**
558
+ * Builds a path from components
559
+ */
560
+ declare function buildPath(table?: string, pk?: string, suffix?: string): string;
561
+ /**
562
+ * Checks if a path segment is a virtual path (@attr, @meta, @actions, @schema)
563
+ */
564
+ declare function isVirtualPath(segment: string): boolean;
565
+ /**
566
+ * Gets the type of virtual path
567
+ */
568
+ declare function getVirtualPathType(segment: string): "attr" | "meta" | "actions" | "schema" | null;
569
+ //#endregion
570
+ //#region src/schema/introspector.d.ts
571
+ /**
572
+ * Schema introspector that uses SQLite PRAGMA queries to discover database schema
573
+ */
574
+ declare class SchemaIntrospector {
575
+ /**
576
+ * Introspects all tables in the database
577
+ * @param db - Drizzle database instance
578
+ * @param options - Introspection options
579
+ * @returns Map of table name to TableSchema
580
+ */
581
+ introspect(db: LibSQLDatabase, options?: {
582
+ /** Whitelist of tables to include */tables?: string[]; /** Tables to exclude */
583
+ excludeTables?: string[];
584
+ }): Promise<Map<string, TableSchema>>;
585
+ /**
586
+ * Introspects a single table
587
+ * @param db - Drizzle database instance
588
+ * @param tableName - Name of the table to introspect
589
+ * @returns TableSchema for the specified table
590
+ */
591
+ introspectTable(db: LibSQLDatabase, tableName: string): Promise<TableSchema>;
592
+ /**
593
+ * Gets the primary key column name for a table
594
+ * Returns the first PK column, or 'rowid' if no explicit PK
595
+ */
596
+ getPrimaryKeyColumn(schema: TableSchema): string;
597
+ /**
598
+ * Checks if a table has FTS (Full-Text Search) enabled
599
+ */
600
+ hasFTS(db: LibSQLDatabase, tableName: string): Promise<boolean>;
601
+ /**
602
+ * Creates FTS5 table for full-text search on specified columns
603
+ */
604
+ createFTS(db: LibSQLDatabase, tableName: string, columns: string[], options?: {
605
+ /** Content table (defaults to tableName) */contentTable?: string; /** Content rowid column (defaults to 'rowid') */
606
+ contentRowid?: string;
607
+ }): Promise<void>;
608
+ /**
609
+ * Rebuilds FTS index for a table (useful after bulk inserts)
610
+ */
611
+ rebuildFTS(db: LibSQLDatabase, tableName: string): Promise<void>;
612
+ }
613
+ //#endregion
614
+ //#region src/sqlite-afs.d.ts
615
+ /**
616
+ * SQLite AFS Module
617
+ *
618
+ * Exposes SQLite databases as AFS nodes with full CRUD support,
619
+ * schema introspection, FTS5 search, and virtual paths (@attr, @meta, @actions).
620
+ */
621
+ declare class SQLiteAFS implements AFSModule {
622
+ private options;
623
+ readonly name: string;
624
+ readonly description: string;
625
+ readonly accessMode: AFSAccessMode;
626
+ private db;
627
+ private schemas;
628
+ private router;
629
+ private crud;
630
+ private ftsSearch;
631
+ private actions;
632
+ private ftsConfig;
633
+ private initialized;
634
+ constructor(options: SQLiteAFSOptions);
635
+ /**
636
+ * Returns the Zod schema for configuration validation
637
+ */
638
+ static schema(): zod0.ZodObject<{
639
+ url: zod0.ZodString;
640
+ name: zod0.ZodOptional<zod0.ZodString>;
641
+ description: zod0.ZodOptional<zod0.ZodString>;
642
+ accessMode: zod0.ZodOptional<zod0.ZodEnum<["readonly", "readwrite"]>>;
643
+ tables: zod0.ZodOptional<zod0.ZodArray<zod0.ZodString, "many">>;
644
+ excludeTables: zod0.ZodOptional<zod0.ZodArray<zod0.ZodString, "many">>;
645
+ fts: zod0.ZodOptional<zod0.ZodObject<{
646
+ enabled: zod0.ZodDefault<zod0.ZodBoolean>;
647
+ tables: zod0.ZodOptional<zod0.ZodRecord<zod0.ZodString, zod0.ZodArray<zod0.ZodString, "many">>>;
648
+ }, "strip", zod0.ZodTypeAny, {
649
+ enabled: boolean;
650
+ tables?: Record<string, string[]> | undefined;
651
+ }, {
652
+ tables?: Record<string, string[]> | undefined;
653
+ enabled?: boolean | undefined;
654
+ }>>;
655
+ wal: zod0.ZodDefault<zod0.ZodOptional<zod0.ZodBoolean>>;
656
+ }, "strip", zod0.ZodTypeAny, {
657
+ url: string;
658
+ wal: boolean;
659
+ name?: string | undefined;
660
+ description?: string | undefined;
661
+ accessMode?: "readonly" | "readwrite" | undefined;
662
+ tables?: string[] | undefined;
663
+ excludeTables?: string[] | undefined;
664
+ fts?: {
665
+ enabled: boolean;
666
+ tables?: Record<string, string[]> | undefined;
667
+ } | undefined;
668
+ }, {
669
+ url: string;
670
+ name?: string | undefined;
671
+ description?: string | undefined;
672
+ accessMode?: "readonly" | "readwrite" | undefined;
673
+ tables?: string[] | undefined;
674
+ excludeTables?: string[] | undefined;
675
+ fts?: {
676
+ tables?: Record<string, string[]> | undefined;
677
+ enabled?: boolean | undefined;
678
+ } | undefined;
679
+ wal?: boolean | undefined;
680
+ }>;
681
+ /**
682
+ * Loads a module instance from configuration
683
+ */
684
+ static load({
685
+ parsed
686
+ }: AFSModuleLoadParams): Promise<SQLiteAFS>;
687
+ /**
688
+ * Called when the module is mounted to AFS
689
+ */
690
+ onMount(_afs: AFSRoot): Promise<void>;
691
+ /**
692
+ * Initializes the database connection and introspects schema
693
+ */
694
+ private initialize;
695
+ /**
696
+ * Ensures the module is initialized
697
+ */
698
+ private ensureInitialized;
699
+ /**
700
+ * Lists entries at a path
701
+ */
702
+ list(path: string, options?: AFSListOptions): Promise<AFSListResult>;
703
+ /**
704
+ * Reads an entry at a path
705
+ */
706
+ read(path: string, _options?: AFSReadOptions): Promise<AFSReadResult>;
707
+ /**
708
+ * Writes an entry at a path
709
+ */
710
+ write(path: string, content: AFSWriteEntryPayload, _options?: AFSWriteOptions): Promise<AFSWriteResult>;
711
+ /**
712
+ * Deletes an entry at a path
713
+ */
714
+ delete(path: string, _options?: AFSDeleteOptions): Promise<AFSDeleteResult>;
715
+ /**
716
+ * Searches for entries matching a query
717
+ */
718
+ search(path: string, query: string, options?: AFSSearchOptions): Promise<AFSSearchResult>;
719
+ /**
720
+ * Executes a module operation
721
+ */
722
+ exec(path: string, args: Record<string, unknown>, _options: AFSExecOptions): Promise<AFSExecResult>;
723
+ /**
724
+ * Lists available actions for a row
725
+ */
726
+ private listActions;
727
+ /**
728
+ * Executes an action
729
+ */
730
+ private executeAction;
731
+ /**
732
+ * Refreshes the schema cache
733
+ */
734
+ refreshSchema(): Promise<void>;
735
+ /**
736
+ * Exports table data in specified format
737
+ */
738
+ exportTable(table: string, format: string): Promise<unknown>;
739
+ /**
740
+ * Registers a custom action
741
+ */
742
+ registerAction(name: string, handler: (ctx: ActionContext, params: Record<string, unknown>) => Promise<unknown>, options?: {
743
+ description?: string;
744
+ tableLevel?: boolean;
745
+ rowLevel?: boolean;
746
+ }): void;
747
+ /**
748
+ * Gets table schemas (for external access)
749
+ */
750
+ getSchemas(): Map<string, TableSchema>;
751
+ /**
752
+ * Gets the database instance (for advanced operations)
753
+ */
754
+ getDatabase(): LibSQLDatabase;
755
+ }
756
+ //#endregion
757
+ export { type ActionContext, type ActionDefinition, type ActionHandler, type ActionResult, ActionsRegistry, type BuildEntryOptions, CRUDOperations, type ColumnInfo, type FTSConfig, FTSSearch, type FTSTableConfig, type ForeignKeyInfo, type IndexInfo, type PragmaForeignKeyRow, type PragmaIndexListRow, type PragmaTableInfoRow, type RouteAction, type RouteData, type RouteMatch, type RouteParams, SQLiteAFS, type SQLiteAFSConfig, type SQLiteAFSOptions, SchemaIntrospector, type TableSchema, buildActionsListEntry, buildAttributeEntry, buildAttributeListEntry, buildDelete, buildGetLastRowId, buildInsert, buildMetaEntry, buildPath, buildRowEntry, buildSchemaEntry, buildSearchEntry, buildSelectAll, buildSelectByPK, buildTableEntry, buildUpdate, createFTSConfig, createPathRouter, getVirtualPathType, isVirtualPath, matchPath, registerBuiltInActions, sqliteAFSConfigSchema };
758
+ //# sourceMappingURL=index.d.cts.map