@zukhruf/sqlite-data-version 0.3.52 → 0.3.53

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
@@ -57,7 +57,7 @@ no change
57
57
  - Each read of `current` reads the status of the file at the path one time (`stat`).
58
58
  - A commit by the same connection does not change the number. The `DataVersion` connection never writes, so each commit that it sees comes from another connection.
59
59
  - Dispose closes the connection. Use `using`, or call `[Symbol.dispose]()`.
60
- - The package throws its own `UnavailableError`. A host that needs its own error translates the error of the package at its boundary, and keeps the error of the package as `cause`. [ADR 0003](./docs/adr/0003-the-package-throws-its-own-errors.md) tells why.
60
+ - The package throws its own `UnavailableError`. It is the class of `@zukhruf/sqlite-reader`, which opens the connection. The package exports it, so a catch with `instanceof` works with either package. A host that needs its own error translates the error of the package at its boundary, and keeps the error of the package as `cause`. [ADR 0003](./docs/adr/0003-the-package-throws-its-own-errors.md) tells why.
61
61
 
62
62
  ## The last write
63
63
 
@@ -105,7 +105,6 @@ console.log(`The owner last wrote at ${written.toISOString()}`);
105
105
  - [0001 Poll data_version](./docs/adr/0001-poll-data-version.md)
106
106
  - [0002 A replaced file is followed by name](./docs/adr/0002-a-replaced-file-is-followed-by-name.md)
107
107
  - [0003 The package throws its own errors](./docs/adr/0003-the-package-throws-its-own-errors.md)
108
- - [Code copied into this package](./docs/copied-code.md)
109
108
 
110
109
  ## Development
111
110
 
@@ -123,7 +122,6 @@ src/
123
122
  index.ts the exports
124
123
  data-version.ts DataVersion
125
124
  followed-database.ts the connection that follows the path to a replaced file
126
- unavailable-error.ts UnavailableError
127
125
  data-version.test.ts the tests, on real SQLite files
128
126
  last-write.ts lastWrite
129
127
  last-write.test.ts the tests, on real SQLite files
@@ -1 +1 @@
1
- {"version":3,"file":"followed-database.d.ts","sourceRoot":"","sources":["../src/followed-database.ts"],"names":[],"mappings":"AAmEA,qBAAa,gBAAiB,YAAW,UAAU;;gBAIrC,IAAI,EAAE,MAAM;IAQxB,OAAO,IAAI,MAAM;IAYjB,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI;CAGzB"}
1
+ {"version":3,"file":"followed-database.d.ts","sourceRoot":"","sources":["../src/followed-database.ts"],"names":[],"mappings":"AAiDA,qBAAa,gBAAiB,YAAW,UAAU;;gBAIrC,IAAI,EAAE,MAAM;IAQxB,OAAO,IAAI,MAAM;IAYjB,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI;CAGzB"}
@@ -1,22 +1,5 @@
1
1
  import { statSync } from 'node:fs';
2
- import { DatabaseSync } from 'node:sqlite';
3
- import { UnavailableError } from "./unavailable-error.js";
4
- function open(path) {
5
- try {
6
- return new DatabaseSync(path, { readOnly: true });
7
- }
8
- catch (cause) {
9
- if (cause instanceof Error &&
10
- 'errcode' in cause &&
11
- // SQLite's CANTOPEN (14). A missing or denied file fails the open()
12
- // syscall, and SQLite reports that as CANTOPEN, a privacy denial too.
13
- // SQLite gives AUTH only for an authorizer, and this private connection
14
- // has none. Any other failure is not one that access can fix.
15
- cause.errcode === 14)
16
- throw new UnavailableError(path, cause);
17
- throw cause;
18
- }
19
- }
2
+ import { openReader } from '@zukhruf/sqlite-reader';
20
3
  // The device and inode of the file at the path, or undefined when this
21
4
  // process cannot see the path: it is missing, or a folder's mode denies it.
22
5
  // Bigint, because inode numbers on NTFS and ReFS exceed 2^53.
@@ -43,7 +26,7 @@ class OpenFile {
43
26
  // identity to the old connection, and then the replace is never seen.
44
27
  // A path this process cannot see fails the open too, as CANTOPEN.
45
28
  this.identity = identify(path);
46
- this.#database = open(path);
29
+ this.#database = openReader(path);
47
30
  this.#version = this.#database.prepare('PRAGMA data_version');
48
31
  }
49
32
  get observation() {
@@ -1 +1 @@
1
- {"version":3,"file":"followed-database.js","sourceRoot":"","sources":["../src/followed-database.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,YAAY,EAAsB,MAAM,aAA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ts';
3
- export { UnavailableError } from './unavailable-error.ts';
3
+ export { UnavailableError } from '@zukhruf/sqlite-reader';
4
4
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
1
  export { DataVersion } from "./data-version.js";
2
2
  export { lastWrite } from "./last-write.js";
3
- export { UnavailableError } from "./unavailable-error.js";
3
+ export { UnavailableError } from '@zukhruf/sqlite-reader';
4
4
  //# sourceMappingURL=index.js.map
@@ -1,5 +1,5 @@
1
1
  import { statSync } from 'node:fs';
2
- import { UnavailableError } from "./unavailable-error.js";
2
+ import { UnavailableError } from '@zukhruf/sqlite-reader';
3
3
  // A missing file, or one in a folder whose mode denies this process. macOS
4
4
  // privacy controls do not deny it: they stop a read of the file and a list of
5
5
  // its folder with EPERM, but not stat of the file.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zukhruf/sqlite-data-version",
3
- "version": "0.3.52",
3
+ "version": "0.3.53",
4
4
  "description": "The data version of a SQLite database that another process owns and writes. It polls PRAGMA data_version on its own read-only connection, which changes on each commit by another connection, also while the owner keeps the file open.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -39,7 +39,10 @@
39
39
  "publishConfig": {
40
40
  "access": "public"
41
41
  },
42
+ "dependencies": {
43
+ "@zukhruf/sqlite-reader": "^0.3.53"
44
+ },
42
45
  "devDependencies": {
43
- "@zukhruf/testing": "^0.3.52"
46
+ "@zukhruf/testing": "^0.3.53"
44
47
  }
45
48
  }
@@ -1,6 +0,0 @@
1
- /** The database file is missing, or this process has no access to it. */
2
- export declare class UnavailableError extends Error {
3
- readonly path: string;
4
- constructor(path: string, cause: unknown);
5
- }
6
- //# sourceMappingURL=unavailable-error.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"unavailable-error.d.ts","sourceRoot":"","sources":["../src/unavailable-error.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,qBAAa,gBAAiB,SAAQ,KAAK;IACzC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;gBAEV,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO;CAQzC"}
@@ -1,10 +0,0 @@
1
- /** The database file is missing, or this process has no access to it. */
2
- export class UnavailableError extends Error {
3
- path;
4
- constructor(path, cause) {
5
- super(`The database at ${JSON.stringify(path)} cannot be opened: the file is missing, or this process has no access to it. Give the process access, or check the path.`, { cause });
6
- this.name = 'UnavailableError';
7
- this.path = path;
8
- }
9
- }
10
- //# sourceMappingURL=unavailable-error.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"unavailable-error.js","sourceRoot":"","sources":["../src/unavailable-error.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IAChC,IAAI,CAAS;IAEtB,YAAY,IAAY,EAAE,KAAc;QACtC,KAAK,CACH,mBAAmB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,0HAA0H,EACjK,EAAE,KAAK,EAAE,CACV,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;QAC/B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF"}