dirsql 0.4.146 → 0.4.147

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/dirsql.d.ts CHANGED
@@ -163,9 +163,10 @@ export declare class DirSQL {
163
163
  /**
164
164
  * Execute a SQL query and return results as an array of row objects.
165
165
  *
166
- * Awaits the initial scan if it has not yet finished, then runs the
167
- * query on the libuv threadpool, so the JS event loop stays responsive
168
- * even for large result sets or long-running queries.
166
+ * Awaits the initial scan if it has not yet finished, then reads the
167
+ * files that changed since the last query, so the rows match the disk.
168
+ * The query itself runs on the libuv threadpool, so the JS event loop
169
+ * stays responsive even for large result sets or long-running queries.
169
170
  *
170
171
  * `params` binds to the statement's placeholders through SQLite, so the
171
172
  * values never enter the SQL text:
package/dist/dirsql.js CHANGED
@@ -101,9 +101,10 @@ export class DirSQL {
101
101
  /**
102
102
  * Execute a SQL query and return results as an array of row objects.
103
103
  *
104
- * Awaits the initial scan if it has not yet finished, then runs the
105
- * query on the libuv threadpool, so the JS event loop stays responsive
106
- * even for large result sets or long-running queries.
104
+ * Awaits the initial scan if it has not yet finished, then reads the
105
+ * files that changed since the last query, so the rows match the disk.
106
+ * The query itself runs on the libuv threadpool, so the JS event loop
107
+ * stays responsive even for large result sets or long-running queries.
107
108
  *
108
109
  * `params` binds to the statement's placeholders through SQLite, so the
109
110
  * values never enter the SQL text:
@@ -83,7 +83,7 @@ the fastest way to see whether a parser produces the rows you expect.
83
83
 
84
84
  The inline flag re-scans and re-parses every file on every query, defines one
85
85
  parser for the whole query, and forgets everything when the process exits. When
86
- you want a **watcher** that keeps the rows fresh, **persistence** across
86
+ you want **row events** as files change, **persistence** across
87
87
  restarts, or **different parsers for different file sets**, move the parser into
88
88
  a `.dirsql.toml` [`[[table]]`](../reference/config.md#table) — and paste the
89
89
  command in verbatim:
@@ -110,7 +110,8 @@ dirsql query "SELECT title, author FROM posts ORDER BY title" -c ./.dirsql.toml
110
110
  ```
111
111
 
112
112
  Same command, same rows. The difference is what a declared table brings: it is
113
- indexed on build, kept fresh by the watcher, survives restarts with
113
+ indexed on build, re-reads only the files that changed on each query, streams
114
+ row events as files change, survives restarts with
114
115
  [`--persist`](./persist.md), and a config can declare
115
116
  [many tables](./define-tables.md) — each with its own `on-file` — where the flag
116
117
  gives every path-table one parser. In both spellings the table's columns are
@@ -72,6 +72,9 @@ works — `EventSource` in a browser, an SSE client library, or plain
72
72
 
73
73
  ## Notes
74
74
 
75
+ - Querying never waits on this stream: a query reads what is on disk when it
76
+ starts ([`query`](../reference/sdk.md#query)). A change a query reads first
77
+ still arrives here, once.
75
78
  - Events reflect *row* changes, not raw filesystem events: a file edit
76
79
  that leaves a table's rows identical emits nothing, and one file change
77
80
  can emit several events. The diffing model is part of
@@ -97,7 +97,8 @@ DirSQL::builder()
97
97
  :::
98
98
 
99
99
  Creates a SQLite index over a directory. The index root is the explicit
100
- `root` when given, else the **process cwd** — the `config` file's location
100
+ `root` when given (a relative `root` resolves against the cwd once, at build
101
+ time), else the **process cwd** — the `config` file's location
101
102
  never sets the root. A config's `[[table]]` globs anchor at the config file's
102
103
  own directory instead (see [glob anchor](./config.md#glob-anchor)); `root`
103
104
  governs programmatic tables and path-tables.
@@ -291,6 +292,24 @@ db.query_with(
291
292
  - Without `params`, a statement with placeholders fails the same way: a
292
293
  placeholder is never left unbound.
293
294
 
295
+ - **Accurate to the filesystem.** A query reads what is on disk when it
296
+ starts: a file written, edited, renamed or deleted before the call is
297
+ reflected in its rows, with no watcher, wait or retry. Before reading, the
298
+ query walks each named table's glob and stats every match; a file whose stat
299
+ moved, or that changed within the last two seconds, is parsed again, and a
300
+ file that is gone loses its rows. The row events those re-reads produce reach
301
+ [`watch`](#watch) streams and the next poll, once each. If a file on disk
302
+ breaks a foreign key, the query fails with the error a build over that tree
303
+ returns. In TypeScript the re-reads run on the JavaScript thread, where
304
+ `onFile` runs, and the SQL then runs on the threadpool.
305
+
306
+ The check trusts the file's stat, so it shares the limits of every
307
+ stat-based tool (`make`, `rsync`, `git status`): a write through a shared
308
+ memory map can land without the file's times moving until the writer
309
+ unmaps or syncs it; a network filesystem that caches attributes can report
310
+ a stale stat; and a clock stepped backwards can stamp a new write with a
311
+ time older than the last read.
312
+
294
313
  - **Read-only.** Each statement is classified by SQLite itself
295
314
  (`sqlite3_stmt_readonly`); anything classified as a write — `INSERT`,
296
315
  `UPDATE`, `DELETE`, `DROP`, `CREATE`, `ALTER`, `VACUUM`, … — is rejected
@@ -371,7 +390,9 @@ to stop.
371
390
  The watcher is live once both `watch()` and [`ready`](#ready) have returned,
372
391
  in either order (a Rust `DirSQL` is ready when `build()` returns); a file
373
392
  written after that point produces an event and reaches the index. A write
374
- made while the initial scan is still running may be missed.
393
+ made while the initial scan is still running may be missed by the stream, but
394
+ never by a query (see [`query`](#query)). A change a query read first still
395
+ arrives on the stream, once.
375
396
 
376
397
  An instance with no named tables cannot be watched: path-tables emit no
377
398
  watch events, so `watch()` (and the polling primitives) raise an error naming
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dirsql",
3
- "version": "0.4.146",
3
+ "version": "0.4.147",
4
4
  "description": "Ephemeral SQL index over a local directory",
5
5
  "license": "MIT",
6
6
  "repository": "https://github.com/thekevinscott/dirsql",
@@ -221,10 +221,10 @@
221
221
  ]
222
222
  },
223
223
  "optionalDependencies": {
224
- "@dirsql/lib-linux-x64-gnu": "0.4.146",
225
- "@dirsql/lib-linux-arm64-gnu": "0.4.146",
226
- "@dirsql/lib-darwin-x64": "0.4.146",
227
- "@dirsql/lib-darwin-arm64": "0.4.146",
228
- "@dirsql/lib-win32-x64-msvc": "0.4.146"
224
+ "@dirsql/lib-linux-x64-gnu": "0.4.147",
225
+ "@dirsql/lib-linux-arm64-gnu": "0.4.147",
226
+ "@dirsql/lib-darwin-x64": "0.4.147",
227
+ "@dirsql/lib-darwin-arm64": "0.4.147",
228
+ "@dirsql/lib-win32-x64-msvc": "0.4.147"
229
229
  }
230
230
  }