dirsql 0.4.55 → 0.4.56
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/core.d.ts +2 -1
- package/dist/dirsql.d.ts +20 -0
- package/dist/dirsql.js +13 -0
- package/dist/index.d.ts +1 -1
- package/docs/reference/sdk.md +19 -0
- package/package.json +6 -6
package/dist/core.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import type { ExtensionSpec, RowEvent, ScanFailure } from "./dirsql.js";
|
|
1
|
+
import type { ExtensionSpec, QueryResult, RowEvent, ScanFailure } from "./dirsql.js";
|
|
2
2
|
import type { TableDef } from "./table.js";
|
|
3
3
|
export interface NativeDirSQL {
|
|
4
4
|
query(sql: string): Promise<Record<string, unknown>[]>;
|
|
5
|
+
queryOrdered(sql: string): Promise<QueryResult>;
|
|
5
6
|
startWatcher(): Promise<void>;
|
|
6
7
|
pollEvents(timeoutMs: number): Promise<RowEvent[]>;
|
|
7
8
|
scanFailures(): ScanFailure[];
|
package/dist/dirsql.d.ts
CHANGED
|
@@ -81,6 +81,16 @@ export interface RowEvent {
|
|
|
81
81
|
error?: string | null;
|
|
82
82
|
filePath?: string | null;
|
|
83
83
|
}
|
|
84
|
+
/** The result of {@link DirSQL.queryOrdered}. */
|
|
85
|
+
export interface QueryResult {
|
|
86
|
+
/**
|
|
87
|
+
* Column names in the order the SELECT list names them. Iterate this, not
|
|
88
|
+
* a row's keys: object keys that look like integers enumerate first.
|
|
89
|
+
*/
|
|
90
|
+
columns: string[];
|
|
91
|
+
/** The rows, exactly as {@link DirSQL.query} returns them. */
|
|
92
|
+
rows: Record<string, unknown>[];
|
|
93
|
+
}
|
|
84
94
|
/**
|
|
85
95
|
* One file the initial scan could not index.
|
|
86
96
|
*
|
|
@@ -147,6 +157,16 @@ export declare class DirSQL {
|
|
|
147
157
|
* even for large result sets or long-running queries.
|
|
148
158
|
*/
|
|
149
159
|
query(sql: string): Promise<Record<string, unknown>[]>;
|
|
160
|
+
/**
|
|
161
|
+
* {@link query}, plus the column order the SELECT list names. Use it to
|
|
162
|
+
* render columns in the order the caller asked for.
|
|
163
|
+
*
|
|
164
|
+
* ```ts
|
|
165
|
+
* const { columns, rows } = await db.queryOrdered("SELECT path, size FROM './'");
|
|
166
|
+
* // columns: ["path", "size"]
|
|
167
|
+
* ```
|
|
168
|
+
*/
|
|
169
|
+
queryOrdered(sql: string): Promise<QueryResult>;
|
|
150
170
|
/**
|
|
151
171
|
* The files the initial scan could not index, each with its root-relative
|
|
152
172
|
* `path` and the hook's own `message`.
|
package/dist/dirsql.js
CHANGED
|
@@ -97,6 +97,19 @@ export class DirSQL {
|
|
|
97
97
|
await this.ready;
|
|
98
98
|
return this._inner.query(sql);
|
|
99
99
|
}
|
|
100
|
+
/**
|
|
101
|
+
* {@link query}, plus the column order the SELECT list names. Use it to
|
|
102
|
+
* render columns in the order the caller asked for.
|
|
103
|
+
*
|
|
104
|
+
* ```ts
|
|
105
|
+
* const { columns, rows } = await db.queryOrdered("SELECT path, size FROM './'");
|
|
106
|
+
* // columns: ["path", "size"]
|
|
107
|
+
* ```
|
|
108
|
+
*/
|
|
109
|
+
async queryOrdered(sql) {
|
|
110
|
+
await this.ready;
|
|
111
|
+
return this._inner.queryOrdered(sql);
|
|
112
|
+
}
|
|
100
113
|
/**
|
|
101
114
|
* The files the initial scan could not index, each with its root-relative
|
|
102
115
|
* `path` and the hook's own `message`.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { DirSQL } from "./dirsql.js";
|
|
2
|
-
export type { DirSQLOptions, ExtensionSpec, RowEvent, ScanFailure, } from "./dirsql.js";
|
|
2
|
+
export type { DirSQLOptions, ExtensionSpec, QueryResult, RowEvent, ScanFailure, } from "./dirsql.js";
|
|
3
3
|
export { Table } from "./table.js";
|
|
4
4
|
export type { TableDef } from "./table.js";
|
package/docs/reference/sdk.md
CHANGED
|
@@ -239,6 +239,25 @@ than `Number.MAX_SAFE_INTEGER`, 2^53 − 1) cannot be represented as a JS
|
|
|
239
239
|
than return a rounded value. Python's `int` is unbounded, so it always
|
|
240
240
|
round-trips.
|
|
241
241
|
|
|
242
|
+
### `queryOrdered`
|
|
243
|
+
|
|
244
|
+
::: code-group
|
|
245
|
+
|
|
246
|
+
```typescript [TypeScript]
|
|
247
|
+
await db.queryOrdered(sql: string) -> { columns: string[]; rows: Record<string, unknown>[] }
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
```rust [Rust]
|
|
251
|
+
db.query_ordered(sql: &str) -> Result<QueryResult> // QueryResult { columns, rows }
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
:::
|
|
255
|
+
|
|
256
|
+
Runs `query` and also returns the column names in the order the SELECT list
|
|
257
|
+
names them. Use it to render columns in the order the caller asked for: a
|
|
258
|
+
row's keys do not carry that order. In TypeScript, object keys that look like
|
|
259
|
+
integers always enumerate first.
|
|
260
|
+
|
|
242
261
|
### `watch`
|
|
243
262
|
|
|
244
263
|
::: code-group
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dirsql",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.56",
|
|
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.56",
|
|
225
|
+
"@dirsql/lib-linux-arm64-gnu": "0.4.56",
|
|
226
|
+
"@dirsql/lib-darwin-x64": "0.4.56",
|
|
227
|
+
"@dirsql/lib-darwin-arm64": "0.4.56",
|
|
228
|
+
"@dirsql/lib-win32-x64-msvc": "0.4.56"
|
|
229
229
|
}
|
|
230
230
|
}
|