dirsql 0.4.66 → 0.4.67

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/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Ephemeral SQL index over a local directory. `dirsql` watches a filesystem, ingests structured files into an in-memory SQLite database, and exposes a SQL query interface -- the filesystem is always the source of truth. Built on the Rust core via napi-rs bindings.
4
4
 
5
- [Documentation](https://thekevinscott.github.io/dirsql/?lang=typescript)
5
+ [Documentation](https://dirsql.dev/?lang=typescript)
6
6
 
7
7
  Also available as [`dirsql` on crates.io](https://crates.io/crates/dirsql) and [`dirsql` on PyPI](https://pypi.org/project/dirsql/).
8
8
 
@@ -89,7 +89,7 @@ Each event has `.action` (`'insert'` | `'update'` | `'delete'` | `'error'`), `.t
89
89
 
90
90
  ## CLI
91
91
 
92
- `npx dirsql "<sql>"` runs one query and prints the rows as JSON — the default. `npx dirsql server` starts an HTTP server exposing the SDK over HTTP: `POST /query` for SQL and `GET /events` for a Server-Sent Events change stream. Requires **Node >= 20.11**. See the [CLI reference](https://thekevinscott.github.io/dirsql/reference/cli).
92
+ `npx dirsql "<sql>"` runs one query and prints the rows as JSON — the default. `npx dirsql server` starts an HTTP server exposing the SDK over HTTP: `POST /query` for SQL and `GET /events` for a Server-Sent Events change stream. Requires **Node >= 20.11**. See the [CLI reference](https://dirsql.dev/reference/cli).
93
93
 
94
94
  ## License
95
95
 
@@ -24,7 +24,7 @@ the config file's location. See [`--config`](./cli.md#flags).
24
24
 
25
25
  | Key | Type | Default | Description |
26
26
  |---|---|---|---|
27
- | `ignore` | array of strings | `[]` | Glob patterns matched against root-relative paths. Matched files are skipped entirely — excluded from the initial scan and from watch events. |
27
+ | `ignore` | array of strings | `[]` | Glob patterns matched against root-relative paths, under the [one glob rule](#glob-rule): `*` matches one level, `**` any depth. Matched files are skipped entirely — excluded from the initial scan and from watch events. |
28
28
 
29
29
  There is no timeout key. `on-file` hook runs are unbounded; to bound one, wrap
30
30
  its command in `timeout(1)` (see [Command hooks](./hooks.md#bounding-a-hook)).
@@ -43,6 +43,16 @@ directory.
43
43
  ignore = ["node_modules/**", ".git/**"]
44
44
  ```
45
45
 
46
+ ### Glob rule
47
+
48
+ Every glob in dirsql — `ignore`, a `[[table]]`'s `glob`, and a
49
+ [path-table](./path-tables.md#writing-the-path) — reads as the shell does:
50
+ `*` and `?` match within one path segment and never cross `/`; `**` matches
51
+ any depth. So `ignore = ["*"]` hides only the files directly inside the root,
52
+ `ignore = ["build/*"]` hides `build/a.o` but not `build/sub/b.o`, and
53
+ `glob = "*.json"` selects only the top-level `.json` files; write
54
+ `**/*.json` to select them at every depth.
55
+
46
56
  Persistence is not a config key. Keep the SQLite index on disk between runs
47
57
  with the [`--persist [PATH]` CLI flag](./cli.md#dirsql-server) — a machine-local
48
58
  operational choice that belongs to the runner, not to shareable config.
@@ -220,7 +230,7 @@ what its required `on-file` command emits — dirsql injects nothing (see
220
230
  |---|---|---|
221
231
  | `name` | yes | The table's SQL name — the name you query it by. Declared, never derived from `ddl`: dirsql does not read the DDL text. The `ddl` must create a table by this name; if it doesn't, loading fails. |
222
232
  | `ddl` | yes | A SQL batch, run verbatim — any number of statements. It must create a table called `name`; that table holds the file rows, and only the columns it declares are kept (keys the `on-file` command emits that are not declared are dropped). The rest of the batch is yours: indexes, virtual tables, triggers. See [Batch `ddl`](#batch-ddl). |
223
- | `glob` | yes | Glob pattern matched against root-relative paths. Every table whose glob matches a file receives that file's rows — a file can populate multiple tables. A `{name}` segment is rewritten to `*` (it matches one path segment but captures nothing). |
233
+ | `glob` | yes | Glob pattern matched against root-relative paths, under the [one glob rule](#glob-rule): `*` matches one level, `**` any depth. Every table whose glob matches a file receives that file's rows — a file can populate multiple tables. A `{name}` segment is rewritten to `*` (it matches one path segment but captures nothing). |
224
234
  | `on-file` | **yes** | A command run once per table, with every matched file's absolute path appended as a trailing argument; its stdout (one JSON array of row objects) is the table's rows. Must be non-empty. A `[[table]]` with no `on-file` is a load error (see [parse errors](#parse-errors)). See [Command hooks](./hooks.md#on-file). |
225
235
  | `strict` | no (default `false`) | When `true`, rows whose keys do not exactly match the declared columns are rejected with an error: extra keys error, and every declared column must be supplied by the `on-file` output. When `false`, extra keys are dropped and missing columns become `NULL`. |
226
236
 
@@ -47,8 +47,13 @@ beneath it; the non-recursive form is spelled explicitly with `*`.
47
47
  | `'./docs/**/*.md'` | markdown files at any depth under `docs/` |
48
48
  | `'./notes/today.md'` | exactly that one file — one file is one row |
49
49
 
50
- A path containing `*`, `?` or `[` is a glob and is used exactly as written: `*`
51
- matches within a single directory, `**` crosses directories.
50
+ A path containing `*`, `?`, `[` or `{` is a glob and is used exactly as
51
+ written: `*` matches within a single directory, `**` crosses directories.
52
+
53
+ The scan starts at the last directory named outright before the first glob
54
+ component -- `'./small/*.md'` walks `small/` and nothing else -- so a query
55
+ over one directory costs what `find ./small` costs, however large the
56
+ directories beside it.
52
57
 
53
58
  A path naming a single file yields exactly one row. dirsql never splits a file
54
59
  into rows on its own — that is what a table's `on_file` hook is for.
@@ -186,8 +191,9 @@ bug to design around.
186
191
  The table itself is per-connection: it lives in `temp`, so it cannot leak into
187
192
  `sqlite_master` or survive a restart. Under `--persist` a *parsed* table's rows
188
193
  outlive the connection in the cache (above), but the table is still minted
189
- fresh each run and the scan still decides what exists. The reserved top-level
190
- `.dirsql/` directory is excluded from the scan, as everywhere else.
194
+ fresh each run and the scan still decides what exists. A `.dirsql/` directory
195
+ at the top of the directory the scan starts in is reserved and excluded, as
196
+ everywhere else.
191
197
 
192
198
  ### When to promote to a declared table
193
199
 
@@ -207,7 +213,9 @@ choice is stated as one trade in
207
213
  ## Skip rules
208
214
 
209
215
  A path-table scan applies the same [`ignore`](/reference/config) patterns your
210
- declared tables use, plus two built-in defaults so a zero-config
216
+ declared tables use — matched against root-relative paths under the same
217
+ [glob rule](/reference/config#glob-rule) as the path itself, `*` one level and
218
+ `**` any depth — plus two built-in defaults so a zero-config
211
219
  `SELECT * FROM './'` does not drown in machinery:
212
220
 
213
221
  - `**/node_modules/**`
@@ -234,8 +242,8 @@ defaults and configured `ignore` patterns still apply.
234
242
 
235
243
  ### Naming a skipped directory
236
244
 
237
- Skip rules are judged on the part of the path *below* what you named outright,
238
- so pointing at a skipped directory — built-in or gitignored — still scans it:
245
+ Skip rules are judged from the directory the scan starts in, so pointing at a
246
+ skipped directory — built-in or gitignored — still scans it:
239
247
 
240
248
  ```sql
241
249
  SELECT path FROM './'; -- no node_modules rows
@@ -243,8 +251,8 @@ SELECT path FROM './node_modules/*/package.json'; -- scans it anyway
243
251
  SELECT path FROM './dist'; -- scans dist/ even when gitignored
244
252
  ```
245
253
 
246
- A `.gitignore` at or below the directory you named still filters beneath it;
247
- only rules inherited from above it are set aside.
254
+ A `.gitignore` at or below the directory the scan starts in still filters
255
+ beneath it; one above it is never read.
248
256
 
249
257
  ### Hidden files
250
258
 
@@ -116,8 +116,9 @@ shortcut was removed in #603 — use
116
116
  - `root` — Directory to index. When omitted, the index roots at the process
117
117
  cwd (even when `config` is supplied).
118
118
  - `tables` — Programmatic [`Table`](#table) definitions.
119
- - `ignore` — Glob patterns matched against root-relative paths; matched
120
- files are skipped entirely (scan and watch).
119
+ - `ignore` — Glob patterns matched against root-relative paths under the
120
+ [glob rule](./config.md#glob-rule) (`*` one level, `**` any depth);
121
+ matched files are skipped entirely (scan and watch).
121
122
  - `no_ignore` / `noIgnore` — Scan files a `.gitignore` would hide.
122
123
  [Path-tables](./path-tables.md#skip-rules) respect `.gitignore` files by
123
124
  default; the built-in `node_modules`/`.git` skips and any `ignore` patterns
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dirsql",
3
- "version": "0.4.66",
3
+ "version": "0.4.67",
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.66",
225
- "@dirsql/lib-linux-arm64-gnu": "0.4.66",
226
- "@dirsql/lib-darwin-x64": "0.4.66",
227
- "@dirsql/lib-darwin-arm64": "0.4.66",
228
- "@dirsql/lib-win32-x64-msvc": "0.4.66"
224
+ "@dirsql/lib-linux-x64-gnu": "0.4.67",
225
+ "@dirsql/lib-linux-arm64-gnu": "0.4.67",
226
+ "@dirsql/lib-darwin-x64": "0.4.67",
227
+ "@dirsql/lib-darwin-arm64": "0.4.67",
228
+ "@dirsql/lib-win32-x64-msvc": "0.4.67"
229
229
  }
230
230
  }