@procedures/sqlite 0.63.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/src/module.ts CHANGED
@@ -7,9 +7,14 @@
7
7
  * sqlite.tables, sqlite.schema, sqlite.transaction, sqlite.migrate, sqlite.backup, logs.store
8
8
  * and logs.query. Version 0.4.0 renamed the namespace db to sqlite, and 0.6.0 removed the old names.
9
9
  * This file is referenced by package.json's client.procedures field.
10
+ *
11
+ * The module also has the generated procedures of the functions of `@mark1russell7/sqlite`, for
12
+ * example `sqlite.openDatabase`. They come from the types of the home: `node scripts/wraps.ts
13
+ * generate` writes `src/manifest.ts`, so no generated procedure can drift from its function.
10
14
  */
11
15
 
12
16
  import { definePackage, createProcedure, type AnyProcedure, type FsRootRules, type ProcedureModule, type PackageDefinition } from "@procedures/client";
17
+ import { exportsModule } from "@procedures/compiler";
13
18
  import * as z from "zod";
14
19
  import type { DatabaseSync } from "node:sqlite";
15
20
  import {
@@ -38,7 +43,8 @@ import {
38
43
  type OpenMode,
39
44
  type SqlParam,
40
45
  } from "./procedures/db/shared.js";
41
- import type { Sqlite } from "./load.js";
46
+ import { loadSqlite, type Sqlite } from "./load.js";
47
+ import { manifest } from "./manifest.js";
42
48
  import {
43
49
  DbTablesInputSchema,
44
50
  DbTablesOutputSchema,
@@ -564,11 +570,25 @@ const sqliteProcedures: readonly AnyProcedure[] = [
564
570
  // Registration
565
571
  // =============================================================================
566
572
 
567
- const sqlitePackage: PackageDefinition = definePackage("@procedures/sqlite", [
568
- ...sqliteProcedures,
569
- logsStoreProcedure,
570
- logsQueryProcedure,
571
- ]);
573
+ /** The manifest of the generated procedures: the names, the schemas, the effects and each exemption with its reason. */
574
+ export { manifest as sqliteManifest };
575
+
576
+ /**
577
+ * The generated module of the functions of `@mark1russell7/sqlite` (d40-handles). The database of
578
+ * `sqlite.openDatabase` is a handle in the scope of the caller, and the other procedures take the
579
+ * handle. The first call loads the package, as the other procedures do.
580
+ */
581
+ const sqliteHomeModule: ProcedureModule = exportsModule(manifest, loadSqlite, { name: "@procedures/sqlite" });
582
+
583
+ /** The generated procedures `sqlite.*`: one for each function of the home with JSON inputs and a JSON output. */
584
+ export const sqliteHomeProcedures: readonly AnyProcedure[] = sqliteHomeModule.procedures;
585
+
586
+ // The generated procedures use handles, so the package requires the module of handle.list and handle.close
587
+ const sqlitePackage: PackageDefinition = definePackage(
588
+ "@procedures/sqlite",
589
+ [...sqliteProcedures, logsStoreProcedure, logsQueryProcedure, ...sqliteHomeProcedures],
590
+ sqliteHomeModule.requires,
591
+ );
572
592
 
573
593
  /**
574
594
  * The module of this package, for `createRegistry()`: its procedures as data. Importing this