@procedures/sqlite 0.64.0 → 0.65.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # @procedures/sqlite
2
2
 
3
+ ## 0.65.0
4
+
5
+ ### Patch Changes
6
+
7
+ - 420ebdc: `@procedures/sqlite` has generated procedures for 9 functions of `@mark1russell7/sqlite` (d40-handles). `sqlite.openDatabase` gives a database handle in the scope of the caller. The other 8 procedures take the handle, for example `sqlite.tableColumns` and `sqlite.checkIntegrity`. The register entry also registers `handle.list` and `handle.close`.
8
+
9
+ `exportsModule()` of `@procedures/compiler` also takes a loader in place of the functions. The first call loads the package one time. A failed load does not stay. The overlay of a wrap can give the rules under a root of a host (`fsRoot`). The loader gives them to each procedure as `metadata.fsRoot`.
10
+
11
+ The MCP tools do not change: `@procedures/bundle-mcp` keeps the new procedures out of the tools.
12
+ - Updated dependencies [e7ec32b]
13
+ - Updated dependencies [4e20391]
14
+ - Updated dependencies [abf52af]
15
+ - Updated dependencies [a2a09b7]
16
+ - Updated dependencies [ffb85af]
17
+ - Updated dependencies [420ebdc]
18
+ - Updated dependencies [f1c599f]
19
+ - @procedures/compiler@0.65.0
20
+ - @procedures/client@0.65.0
21
+
3
22
  ## 0.64.0
4
23
 
5
24
  ### Patch Changes
package/README.md CHANGED
@@ -17,9 +17,12 @@ SQLite database operations via client procedures. Execute queries and store stru
17
17
  - **Default log database**: Pre-configured logging at `~/logs/cli/cli.db`
18
18
  - **A collection storage**: `SqliteStorage` keeps a collection in a SQLite table, with a change log
19
19
 
20
- The package has 9 procedures. Its register entry (`import "@procedures/sqlite/register"`) registers them:
20
+ The package has 18 procedures. Its register entry (`import "@procedures/sqlite/register"`) registers them:
21
21
  - **Database**: `sqlite.query`, `sqlite.execute`, `sqlite.tables`, `sqlite.schema`, `sqlite.transaction`, `sqlite.migrate`, `sqlite.backup`
22
22
  - **Logs**: `logs.store`, `logs.query`
23
+ - **Generated**: one procedure for each of 9 functions of `@mark1russell7/sqlite`, on database handles. The section [The generated procedures](#the-generated-procedures) gives them.
24
+
25
+ The register entry also registers `handle.list` and `handle.close` of `@procedures/client`.
23
26
 
24
27
  ### The old names `db.*`
25
28
 
@@ -510,6 +513,50 @@ const { logs } = await client.exec(
510
513
  );
511
514
  ```
512
515
 
516
+ ## The generated procedures
517
+
518
+ The package has a procedure for each function of `@mark1russell7/sqlite` with JSON inputs and a JSON output. These are 9 of the 25 functions. The generator of `@procedures/compiler` makes them from the types of the library. Thus a procedure cannot drift from its function.
519
+
520
+ - `sqlite.openDatabase` opens a database and gives a handle, for example `{ "handle": "h_..." }`. The handle is in the scope of the caller.
521
+ - The other 8 procedures take the handle in the input `db`: `sqlite.userVersion`, `sqlite.schemaVersion`, `sqlite.tableColumns`, `sqlite.addMissingColumns`, `sqlite.checkIntegrity`, `sqlite.checkpoint`, `sqlite.snapshot` and `sqlite.clearDatabase`.
522
+ - `handle.list` gives the open handles of the caller. `handle.close` closes a handle and its database. The end of the scope closes each database that is open.
523
+ - The procedures refuse the handle of a different caller.
524
+ - Under the root of a host, a relative `path` starts at the root. The host refuses a path outside the root. `:memory:` is not a path.
525
+ - The first call loads `@mark1russell7/sqlite`, as the other procedures do.
526
+
527
+ `sqliteManifest` gives the names, the schemas and the effects of each procedure. The MCP server of `@procedures/bundle-mcp` does not show these procedures as tools. A later change adds seven of them as tools.
528
+
529
+ ```ts
530
+ import { createRegistry, HandleScope, invokePath, outputValue } from "@procedures/client";
531
+ import { sqliteModule } from "@procedures/sqlite";
532
+
533
+ const registry = createRegistry(sqliteModule);
534
+ const handles = new HandleScope();
535
+ const db = await outputValue(await invokePath(["sqlite", "openDatabase"], { path: "./app.db" }, { registry, handles }));
536
+ const columns = await outputValue(await invokePath(["sqlite", "tableColumns"], { db, table: "logs" }, { registry, handles }));
537
+ await handles.end(); // This closes the database.
538
+ ```
539
+
540
+ ### The functions with no procedure
541
+
542
+ 16 functions have no procedure. The manifest gives the reason for each function:
543
+
544
+ - A parameter is a function, for example the migrations of `migrate` and the callback of `transaction`. A JSON input cannot give a function.
545
+ - An input is not JSON, for example a `Date` of `quarantine` or a connection of a different engine (`sqlJsConnection`, `wasmConnection`).
546
+ - The output is not JSON, for example the `Error` of `sqliteFault`.
547
+
548
+ The procedures `sqlite.transaction` and `sqlite.migrate` above do the work of two of these functions.
549
+
550
+ ### Update the manifest
551
+
552
+ After an update of `@mark1russell7/sqlite`, start this command from the root of the repository:
553
+
554
+ ```bash
555
+ node scripts/wraps.ts generate --package client-sqlite
556
+ ```
557
+
558
+ The command writes `src/manifest.ts` from the types of the library and the overlay in `wrap.json`. The overlay gives the effects of each function and its rules under a root. CI starts `node scripts/wraps.ts check`. The check fails when the manifest is not current.
559
+
513
560
  ## The collection storage
514
561
 
515
562
  `SqliteStorage` keeps the items of one collection in one table of a SQLite database. It implements `CollectionStorage` of `@procedures/client`. A `ProcedureServer`, an `ApiStorage` server and a `HybridStorage` use it as they use `InMemoryStorage`.
@@ -0,0 +1,3 @@
1
+ import type { ExportsManifest } from "@procedures/compiler";
2
+ export declare const manifest: ExportsManifest;
3
+ //# sourceMappingURL=manifest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../src/manifest.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE5D,eAAO,MAAM,QAAQ,EAAE,eAmuBtB,CAAC"}