@aigne/afs-sqlite 1.1.0 → 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 -73
  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
package/README.md CHANGED
@@ -36,10 +36,12 @@ import { SQLiteAFS } from "@aigne/afs-sqlite";
36
36
  const afs = new AFS();
37
37
 
38
38
  // Mount SQLite module
39
- afs.mount(new SQLiteAFS({
40
- url: "file:./database.sqlite3",
41
- accessMode: "readwrite"
42
- }));
39
+ afs.mount(
40
+ new SQLiteAFS({
41
+ url: "file:./database.sqlite3",
42
+ accessMode: "readwrite",
43
+ }),
44
+ );
43
45
 
44
46
  // List all tables
45
47
  const tables = await afs.list("/modules/sqlite-afs");
@@ -52,12 +54,12 @@ const user = await afs.read("/modules/sqlite-afs/users/1");
52
54
 
53
55
  // Create a new row
54
56
  await afs.write("/modules/sqlite-afs/users", {
55
- content: { name: "John", email: "john@example.com" }
57
+ content: { name: "John", email: "john@example.com" },
56
58
  });
57
59
 
58
60
  // Update an existing row
59
61
  await afs.write("/modules/sqlite-afs/users/1", {
60
- content: { name: "John Doe" }
62
+ content: { name: "John Doe" },
61
63
  });
62
64
 
63
65
  // Delete a row
@@ -104,17 +106,17 @@ interface SQLiteAFSOptions {
104
106
 
105
107
  The module exposes the following path patterns:
106
108
 
107
- | Path | Description |
108
- |------|-------------|
109
- | `/` | List all tables |
110
- | `/:table` | List rows in table or create new row |
111
- | `/:table/@schema` | Get table schema |
112
- | `/:table/:pk` | Read/update/delete specific row |
113
- | `/:table/:pk/@attr` | List row attributes (columns) |
114
- | `/:table/:pk/@attr/:column` | Get specific column value |
115
- | `/:table/:pk/@meta` | Get row metadata |
116
- | `/:table/:pk/@actions` | List available actions |
117
- | `/:table/:pk/@actions/:action` | Execute an action |
109
+ | Path | Description |
110
+ | ------------------------------ | ------------------------------------ |
111
+ | `/` | List all tables |
112
+ | `/:table` | List rows in table or create new row |
113
+ | `/:table/@schema` | Get table schema |
114
+ | `/:table/:pk` | Read/update/delete specific row |
115
+ | `/:table/:pk/@attr` | List row attributes (columns) |
116
+ | `/:table/:pk/@attr/:column` | Get specific column value |
117
+ | `/:table/:pk/@meta` | Get row metadata |
118
+ | `/:table/:pk/@actions` | List available actions |
119
+ | `/:table/:pk/@actions/:action` | Execute an action |
118
120
 
119
121
  ## Built-in Actions
120
122
 
@@ -131,14 +133,20 @@ The module exposes the following path patterns:
131
133
 
132
134
  ```typescript
133
135
  // Validate a row
134
- const result = await afs.write("/modules/sqlite-afs/users/1/@actions/validate", {
135
- content: {}
136
- });
136
+ const result = await afs.write(
137
+ "/modules/sqlite-afs/users/1/@actions/validate",
138
+ {
139
+ content: {},
140
+ },
141
+ );
137
142
 
138
143
  // Duplicate a row
139
- const result = await afs.write("/modules/sqlite-afs/users/1/@actions/duplicate", {
140
- content: {}
141
- });
144
+ const result = await afs.write(
145
+ "/modules/sqlite-afs/users/1/@actions/duplicate",
146
+ {
147
+ content: {},
148
+ },
149
+ );
142
150
 
143
151
  // Export table data
144
152
  const jsonData = await sqliteAfs.exportTable("users", "json");
@@ -156,14 +164,16 @@ sqliteAfs.registerAction(
156
164
  "archive",
157
165
  async (ctx, params) => {
158
166
  // ctx contains: db, schemas, table, pk, row, module
159
- await ctx.db.run(sql.raw(`UPDATE "${ctx.table}" SET archived = 1 WHERE id = '${ctx.pk}'`));
167
+ await ctx.db.run(
168
+ sql.raw(`UPDATE "${ctx.table}" SET archived = 1 WHERE id = '${ctx.pk}'`),
169
+ );
160
170
  return { archived: true };
161
171
  },
162
172
  {
163
173
  description: "Archive the row",
164
174
  rowLevel: true,
165
- tableLevel: false
166
- }
175
+ tableLevel: false,
176
+ },
167
177
  );
168
178
  ```
169
179
 
@@ -178,16 +188,19 @@ const sqliteAfs = new SQLiteAFS({
178
188
  enabled: true,
179
189
  tables: {
180
190
  posts: ["title", "content"],
181
- users: ["name", "bio"]
182
- }
183
- }
191
+ users: ["name", "bio"],
192
+ },
193
+ },
184
194
  });
185
195
 
186
196
  // Search across all FTS-enabled tables
187
197
  const results = await afs.search("/modules/sqlite-afs", "search query");
188
198
 
189
199
  // Search within a specific table
190
- const postResults = await afs.search("/modules/sqlite-afs/posts", "search query");
200
+ const postResults = await afs.search(
201
+ "/modules/sqlite-afs/posts",
202
+ "search query",
203
+ );
191
204
  ```
192
205
 
193
206
  ## Advanced Usage
@@ -223,19 +236,21 @@ import { AFS } from "@aigne/afs";
223
236
  import { SQLiteAFS } from "@aigne/afs-sqlite";
224
237
 
225
238
  const afs = new AFS();
226
- afs.mount(new SQLiteAFS({
227
- url: "file:./database.sqlite3",
228
- accessMode: "readwrite"
229
- }));
239
+ afs.mount(
240
+ new SQLiteAFS({
241
+ url: "file:./database.sqlite3",
242
+ accessMode: "readwrite",
243
+ }),
244
+ );
230
245
 
231
246
  const agent = AIAgent.from({
232
247
  name: "database-assistant",
233
- afs: afs
248
+ afs: afs,
234
249
  });
235
250
 
236
251
  const context = aigne.newContext();
237
252
  const result = await context.invoke(agent, {
238
- message: "Show me all users in the database"
253
+ message: "Show me all users in the database",
239
254
  });
240
255
  ```
241
256