@zukhruf/sqlite-federation 0.8.43 → 0.8.45

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.
Files changed (2) hide show
  1. package/README.md +51 -0
  2. package/package.json +4 -4
package/README.md CHANGED
@@ -142,6 +142,57 @@ const result = database.query(
142
142
  | `q` (harelba/q) | It attaches databases up to the limit, and copies the tables of the others into a temporary database. |
143
143
  | PostgreSQL `postgres_fdw` | A foreign table reads a table of another server, and one query can join it with local tables. |
144
144
 
145
+ ## API
146
+
147
+ ```ts
148
+ // The read-only handle a statement runs on. It names each database as a schema.
149
+ type Query = Pick<SQLTagStore, 'all' | 'get'>; // of node:sqlite
150
+
151
+ type QueryResult = {
152
+ readonly columns: readonly string[];
153
+ readonly rows: readonly Readonly<Record<number, SQLOutputValue>>[];
154
+ };
155
+
156
+ // The path of the SQLite file a name stands for, or undefined when the host
157
+ // has no database by that name.
158
+ type Locate = (name: string) => string | undefined;
159
+
160
+ type FederationOptions = Pick<
161
+ DatabaseSyncOptions,
162
+ 'timeout' | 'readBigInts'
163
+ > & {
164
+ readonly main: string | { readonly name: string };
165
+ readonly locate: Locate;
166
+ };
167
+
168
+ class Federation implements Disposable {
169
+ constructor({ main, locate, ...options }: FederationOptions);
170
+ readonly sql: Query;
171
+ readonly function: DatabaseSync['function']; // of node:sqlite
172
+ exec(sql: string): void;
173
+ query(sql: string): QueryResult; // exactly one SQL statement
174
+ [Symbol.dispose](): void; // closes the connection
175
+ }
176
+
177
+ class TooManyDatabasesError extends Error {
178
+ readonly names: readonly string[];
179
+ constructor(limit: number, names: readonly string[]);
180
+ }
181
+
182
+ // The classes of @zukhruf/sqlite-open, which the package exports.
183
+ class UnavailableError extends Error {
184
+ readonly path: string;
185
+ constructor(path: string, cause: unknown);
186
+ static from(path: string, error: unknown): UnavailableError | undefined;
187
+ }
188
+ class MissingError extends UnavailableError {
189
+ constructor(path: string, cause: unknown);
190
+ }
191
+ class DeniedError extends UnavailableError {
192
+ constructor(path: string, cause: unknown);
193
+ }
194
+ ```
195
+
145
196
  ## Documentation
146
197
 
147
198
  - [0001 Each statement attaches what it names](./docs/adr/0001-each-statement-attaches-what-it-names.md)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zukhruf/sqlite-federation",
3
- "version": "0.8.43",
3
+ "version": "0.8.45",
4
4
  "description": "One read-only handle over many SQLite databases. Each statement attaches the databases it names and detaches them when it ends. So a host can keep more databases than the SQLite attach limit, and one statement can read 10 plus the primary database.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -41,10 +41,10 @@
41
41
  "access": "public"
42
42
  },
43
43
  "dependencies": {
44
- "@zukhruf/sqlite-open": "^0.8.43"
44
+ "@zukhruf/sqlite-open": "^0.8.45"
45
45
  },
46
46
  "devDependencies": {
47
- "@zukhruf/fs": "^0.8.43",
48
- "@zukhruf/testing": "^0.8.43"
47
+ "@zukhruf/fs": "^0.8.45",
48
+ "@zukhruf/testing": "^0.8.45"
49
49
  }
50
50
  }