dirsql 0.4.66 → 0.4.68
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://
|
|
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://
|
|
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
|
|
package/docs/getting-started.md
CHANGED
|
@@ -68,11 +68,11 @@ this directory anyway — from inside `my-notes`, run one command:
|
|
|
68
68
|
::: code-group
|
|
69
69
|
|
|
70
70
|
```bash [npm]
|
|
71
|
-
npx dirsql "SELECT COUNT(*) AS files FROM '
|
|
71
|
+
npx dirsql "SELECT COUNT(*) AS files FROM './**'"
|
|
72
72
|
```
|
|
73
73
|
|
|
74
74
|
```bash [PyPI]
|
|
75
|
-
uvx dirsql "SELECT COUNT(*) AS files FROM '
|
|
75
|
+
uvx dirsql "SELECT COUNT(*) AS files FROM './**'"
|
|
76
76
|
```
|
|
77
77
|
|
|
78
78
|
:::
|
|
@@ -91,10 +91,11 @@ files
|
|
|
91
91
|
Three files, three rows. That one command scanned the directory, handed
|
|
92
92
|
SQLite one row per file, ran your SQL, and printed the answer.
|
|
93
93
|
|
|
94
|
-
There is no named table here — you never declared one. `'
|
|
94
|
+
There is no named table here — you never declared one. `'./**'` is a
|
|
95
95
|
[path-table](./reference/path-tables.md): a quoted path written where a table
|
|
96
|
-
name goes. `'
|
|
97
|
-
in
|
|
96
|
+
name goes. `'./**'` means every file under the directory you ran the command
|
|
97
|
+
in, at any depth; `'./'` alone would list only the files directly inside it,
|
|
98
|
+
like `ls`. The path *is* the query.
|
|
98
99
|
|
|
99
100
|
## 3. Select some columns
|
|
100
101
|
|
|
@@ -105,11 +106,11 @@ pretty-print. Ask for two columns instead of a count:
|
|
|
105
106
|
::: code-group
|
|
106
107
|
|
|
107
108
|
```bash [npm]
|
|
108
|
-
npx dirsql query "SELECT path, size FROM '
|
|
109
|
+
npx dirsql query "SELECT path, size FROM './**' ORDER BY path" | jq
|
|
109
110
|
```
|
|
110
111
|
|
|
111
112
|
```bash [PyPI]
|
|
112
|
-
uvx dirsql query "SELECT path, size FROM '
|
|
113
|
+
uvx dirsql query "SELECT path, size FROM './**' ORDER BY path" | jq
|
|
113
114
|
```
|
|
114
115
|
|
|
115
116
|
:::
|
|
@@ -67,5 +67,5 @@ why indexes belong to only one of them, are in
|
|
|
67
67
|
- Paths outside the root resolve too — `'/var/log/*.log'`, `'../notes'`,
|
|
68
68
|
`'~/notes/*.md'` — reporting absolute paths
|
|
69
69
|
([path-tables reference](../reference/path-tables.md#paths-outside-the-index-root)).
|
|
70
|
-
- `node_modules/` and `.git/` are skipped by default so a bare `'
|
|
71
|
-
drown in machinery ([skip rules](../reference/path-tables.md#skip-rules)).
|
|
70
|
+
- `node_modules/` and `.git/` are skipped by default so a bare `'./**'` does
|
|
71
|
+
not drown in machinery ([skip rules](../reference/path-tables.md#skip-rules)).
|
package/docs/reference/cli.md
CHANGED
|
@@ -88,7 +88,7 @@ front.
|
|
|
88
88
|
### Output format
|
|
89
89
|
|
|
90
90
|
Rows go where they are useful: a **table** when stdout is a terminal, the
|
|
91
|
-
**JSON array** when it is piped or redirected. `SELECT * FROM '
|
|
91
|
+
**JSON array** when it is piped or redirected. `SELECT * FROM './**'` in a
|
|
92
92
|
5000-file tree should not put a 5000-element JSON array in front of a person,
|
|
93
93
|
and `dirsql "…" | jq` should not have to parse a table.
|
|
94
94
|
|
|
@@ -283,7 +283,7 @@ curl -s localhost:7117/query -H 'content-type: application/json' \
|
|
|
283
283
|
```
|
|
284
284
|
|
|
285
285
|
Earlier versions served an implicit table named `files` here. It is gone; a
|
|
286
|
-
`SELECT ... FROM files` with no config now fails and points at `FROM '
|
|
286
|
+
`SELECT ... FROM files` with no config now fails and points at `FROM './**'`.
|
|
287
287
|
|
|
288
288
|
Passing a config with `-c` fully overrules this default. A `-c` naming a file
|
|
289
289
|
that does not exist is an error (not a fallback to the default); a config that
|
|
@@ -403,8 +403,8 @@ takes, with the same `auto` default. A one-shot query is usually piped, so
|
|
|
403
403
|
## `dirsql init`
|
|
404
404
|
|
|
405
405
|
Writes a starter `.dirsql.toml` as a scaffold to edit. It does **not**
|
|
406
|
-
duplicate the zero-config floor (`SELECT * FROM '
|
|
407
|
-
with no config); instead it shows the **escalation**: one named `[[table]]`
|
|
406
|
+
duplicate the zero-config floor (`SELECT * FROM './**'` already lists every
|
|
407
|
+
file with no config); instead it shows the **escalation**: one named `[[table]]`
|
|
408
408
|
with a glob, a schema, and a real `on-file` hook that pulls structured rows
|
|
409
409
|
out of your files.
|
|
410
410
|
|
package/docs/reference/config.md
CHANGED
|
@@ -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
|
|
|
@@ -386,7 +396,7 @@ SDKs raise/reject) when:
|
|
|
386
396
|
- A `[[table]]` entry omits `on-file` (or it is empty/whitespace). The error
|
|
387
397
|
names the offending glob and points at the fix:
|
|
388
398
|
|
|
389
|
-
> `[[table]] '**/*.md' has no on-file hook, so every row would be all-NULL. Add an `on-file` hook that emits the columns, or, for stat columns with no code, query the path directly: `FROM '
|
|
399
|
+
> `[[table]] '**/*.md' has no on-file hook, so every row would be all-NULL. Add an `on-file` hook that emits the columns, or, for stat columns with no code, query the path directly: `FROM './**'``
|
|
390
400
|
|
|
391
401
|
- A `[[dirsql.extension]]` entry omits `path`, or `path` is empty.
|
|
392
402
|
- A `[[dirsql.function]]` entry omits `name`, `command`, or `args` (or
|
|
@@ -35,20 +35,27 @@ Two consequences follow directly:
|
|
|
35
35
|
A `./` path is relative to the **index root** — the directory dirsql is
|
|
36
36
|
indexing, not your shell's working directory.
|
|
37
37
|
|
|
38
|
-
**
|
|
39
|
-
|
|
38
|
+
**A directory name is one level, like `ls`.** Naming a directory lists the
|
|
39
|
+
files directly inside it and no deeper; `*` matches one level and `**` any
|
|
40
|
+
depth, as in the shell.
|
|
40
41
|
|
|
41
42
|
| You write | dirsql scans |
|
|
42
43
|
| --- | --- |
|
|
43
|
-
| `'./'` |
|
|
44
|
-
| `'./docs'` |
|
|
45
|
-
| `'./*'` |
|
|
44
|
+
| `'./'` | files directly inside the index root, and no deeper |
|
|
45
|
+
| `'./docs'`, `'./docs/'` | files directly inside `docs/` |
|
|
46
|
+
| `'./*'` | the same as `'./'` |
|
|
47
|
+
| `'./**'` | every file under the index root, recursively |
|
|
46
48
|
| `'./docs/*.md'` | markdown files directly inside `docs/` |
|
|
47
49
|
| `'./docs/**/*.md'` | markdown files at any depth under `docs/` |
|
|
48
50
|
| `'./notes/today.md'` | exactly that one file — one file is one row |
|
|
49
51
|
|
|
50
|
-
A path containing `*`,
|
|
51
|
-
matches within a single directory, `**` crosses directories.
|
|
52
|
+
A path containing `*`, `?`, `[` or `{` is a glob and is used exactly as
|
|
53
|
+
written: `*` matches within a single directory, `**` crosses directories.
|
|
54
|
+
|
|
55
|
+
The scan starts at the last directory named outright before the first glob
|
|
56
|
+
component -- `'./small/*.md'` walks `small/` and nothing else -- so a query
|
|
57
|
+
over one directory costs what `find ./small` costs, however large the
|
|
58
|
+
directories beside it.
|
|
52
59
|
|
|
53
60
|
A path naming a single file yields exactly one row. dirsql never splits a file
|
|
54
61
|
into rows on its own — that is what a table's `on_file` hook is for.
|
|
@@ -82,6 +89,7 @@ Three other prefixes resolve, with their usual shell meanings:
|
|
|
82
89
|
| `'../notes'` | relative to the index root's parent |
|
|
83
90
|
| `'~/notes/*.md'` | relative to your home directory |
|
|
84
91
|
|
|
92
|
+
A directory named this way is one level too; `'../notes/**'` descends.
|
|
85
93
|
`..` is folded out textually, not followed through symlinks, so the directory
|
|
86
94
|
scanned is a function of the string you wrote.
|
|
87
95
|
|
|
@@ -186,8 +194,9 @@ bug to design around.
|
|
|
186
194
|
The table itself is per-connection: it lives in `temp`, so it cannot leak into
|
|
187
195
|
`sqlite_master` or survive a restart. Under `--persist` a *parsed* table's rows
|
|
188
196
|
outlive the connection in the cache (above), but the table is still minted
|
|
189
|
-
fresh each run and the scan still decides what exists.
|
|
190
|
-
|
|
197
|
+
fresh each run and the scan still decides what exists. A `.dirsql/` directory
|
|
198
|
+
at the top of the directory the scan starts in is reserved and excluded, as
|
|
199
|
+
everywhere else.
|
|
191
200
|
|
|
192
201
|
### When to promote to a declared table
|
|
193
202
|
|
|
@@ -207,8 +216,10 @@ choice is stated as one trade in
|
|
|
207
216
|
## Skip rules
|
|
208
217
|
|
|
209
218
|
A path-table scan applies the same [`ignore`](/reference/config) patterns your
|
|
210
|
-
declared tables use
|
|
211
|
-
|
|
219
|
+
declared tables use — matched against root-relative paths under the same
|
|
220
|
+
[glob rule](/reference/config#glob-rule) as the path itself, `*` one level and
|
|
221
|
+
`**` any depth — plus two built-in defaults so a zero-config
|
|
222
|
+
`SELECT * FROM './**'` does not drown in machinery:
|
|
212
223
|
|
|
213
224
|
- `**/node_modules/**`
|
|
214
225
|
- `**/.git/**`
|
|
@@ -234,17 +245,17 @@ defaults and configured `ignore` patterns still apply.
|
|
|
234
245
|
|
|
235
246
|
### Naming a skipped directory
|
|
236
247
|
|
|
237
|
-
Skip rules are judged
|
|
238
|
-
|
|
248
|
+
Skip rules are judged from the directory the scan starts in, so pointing at a
|
|
249
|
+
skipped directory — built-in or gitignored — still scans it:
|
|
239
250
|
|
|
240
251
|
```sql
|
|
241
|
-
SELECT path FROM '
|
|
252
|
+
SELECT path FROM './**'; -- no node_modules rows
|
|
242
253
|
SELECT path FROM './node_modules/*/package.json'; -- scans it anyway
|
|
243
254
|
SELECT path FROM './dist'; -- scans dist/ even when gitignored
|
|
244
255
|
```
|
|
245
256
|
|
|
246
|
-
A `.gitignore` at or below the directory
|
|
247
|
-
|
|
257
|
+
A `.gitignore` at or below the directory the scan starts in still filters
|
|
258
|
+
beneath it; one above it is never read.
|
|
248
259
|
|
|
249
260
|
### Hidden files
|
|
250
261
|
|
package/docs/reference/sdk.md
CHANGED
|
@@ -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
|
|
120
|
-
|
|
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.
|
|
3
|
+
"version": "0.4.68",
|
|
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.
|
|
225
|
-
"@dirsql/lib-linux-arm64-gnu": "0.4.
|
|
226
|
-
"@dirsql/lib-darwin-x64": "0.4.
|
|
227
|
-
"@dirsql/lib-darwin-arm64": "0.4.
|
|
228
|
-
"@dirsql/lib-win32-x64-msvc": "0.4.
|
|
224
|
+
"@dirsql/lib-linux-x64-gnu": "0.4.68",
|
|
225
|
+
"@dirsql/lib-linux-arm64-gnu": "0.4.68",
|
|
226
|
+
"@dirsql/lib-darwin-x64": "0.4.68",
|
|
227
|
+
"@dirsql/lib-darwin-arm64": "0.4.68",
|
|
228
|
+
"@dirsql/lib-win32-x64-msvc": "0.4.68"
|
|
229
229
|
}
|
|
230
230
|
}
|