@zukhruf/sqlite-snapshot 0.3.50 → 0.3.52

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
@@ -18,19 +18,7 @@ import { tmpdir } from 'node:os';
18
18
  import { join } from 'node:path';
19
19
  import { DatabaseSync } from 'node:sqlite';
20
20
 
21
- import { Snapshot } from '@zukhruf/sqlite-snapshot';
22
-
23
- class Unavailable extends Error {
24
- constructor(path: string, cause: unknown) {
25
- super(`Cannot read ${path}`, { cause });
26
- }
27
- }
28
-
29
- class MissingColumns extends Error {
30
- constructor(path: string, missing: readonly string[]) {
31
- super(`${path} has no ${missing.join(', ')}`);
32
- }
33
- }
21
+ import { Snapshot, UnavailableError } from '@zukhruf/sqlite-snapshot';
34
22
 
35
23
  await using scratch = await mkdtempDisposable(join(tmpdir(), 'snapshot-'));
36
24
  const path = join(scratch.path, 'notes.sqlite');
@@ -42,20 +30,20 @@ owner.exec(`PRAGMA journal_mode = WAL;
42
30
  INSERT INTO notes (title) VALUES ('first')`);
43
31
 
44
32
  {
45
- using snapshot = new Snapshot(path, Unavailable);
46
- snapshot.requireColumns({ notes: ['id', 'title'] }, MissingColumns);
33
+ using snapshot = new Snapshot(path);
34
+ snapshot.requireColumns({ notes: ['id', 'title'] });
47
35
  owner.exec("INSERT INTO notes (title) VALUES ('second')");
48
36
  console.log(snapshot.all('SELECT title FROM notes'));
49
37
  }
50
38
 
51
- using next = new Snapshot(path, Unavailable);
39
+ using next = new Snapshot(path);
52
40
  console.log(next.missingColumns({ notes: ['title', 'body'] }));
53
41
  console.log(next.all('SELECT count(*) AS notes FROM notes'));
54
42
 
55
43
  try {
56
- new Snapshot(join(scratch.path, 'missing', 'notes.sqlite'), Unavailable);
44
+ new Snapshot(join(scratch.path, 'missing', 'notes.sqlite'));
57
45
  } catch (error) {
58
- console.log(error instanceof Unavailable);
46
+ console.log(error instanceof UnavailableError);
59
47
  }
60
48
  ```
61
49
 
@@ -70,22 +58,22 @@ true
70
58
 
71
59
  ## The rules
72
60
 
73
- - `new Snapshot(path, unavailable)` opens the database read-only. It runs `BEGIN` and a first read at once, so the snapshot holds the moment when it opens, not the moment of the first query of the caller.
61
+ - `new Snapshot(path)` opens the database read-only. It runs `BEGIN` and a first read at once, so the snapshot holds the moment when it opens, not the moment of the first query of the caller.
74
62
  - The snapshot never opens the file with `immutable`. The owner keeps a persistent WAL, and the newest rows are in it. [ADR 0001](./docs/adr/0001-never-immutable-and-held-only-while-reading.md) tells why.
75
63
  - Hold a snapshot only while you read. An open read transaction stops the checkpoint of the owner, and then the WAL of the owner grows. Dispose the snapshot with `using`, or call `[Symbol.dispose]()`.
76
64
  - `all(sql, ...parameters)` gives all rows. `iterate(sql, ...parameters)` gives the rows one at a time, for a table that is too large to hold in memory.
77
- - `requireColumns(columns, schema)` checks the columns that the reader needs, as `{ table: [column, ...] }`. When one is missing, it disposes the snapshot and throws `new schema(path, missing)`.
65
+ - `requireColumns(columns)` checks the columns that the reader needs, as `{ table: [column, ...] }`. When one is missing, it disposes the snapshot and throws `MissingColumnsError`.
78
66
  - `missingColumns(columns)` gives the missing columns as `table.column`, and keeps the snapshot open. A reader whose queries use different tables checks each query with it.
79
- - The caller gives the error classes. Thus each error names what the caller needs, for example the access that the user must give.
67
+ - The package throws its own errors: `UnavailableError` and `MissingColumnsError`. 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 0002](./docs/adr/0002-the-package-throws-its-own-errors.md) tells why.
80
68
  - Dispose commits the read transaction and closes the connection. A second dispose does nothing.
81
69
 
82
70
  ## Errors
83
71
 
84
- | Error | When |
85
- | ------------------------------ | ------------------------------------------------------------------------------------------------------------------------------- |
86
- | `new unavailable(path, cause)` | SQLite cannot open the file: `SQLITE_CANTOPEN` (14), for a missing file or a file that the system denies, a privacy denial too. |
87
- | `new schema(path, missing)` | `requireColumns` finds a missing column. The snapshot is closed. |
88
- | The error of SQLite | All other failures, for example a file that is not a database. The constructor closes the connection before it throws. |
72
+ | Error | When |
73
+ | --------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
74
+ | `UnavailableError` | SQLite cannot open the file: `SQLITE_CANTOPEN` (14), for a missing file or a file that the system denies, a privacy denial too. `path` is the path. `cause` is the error of SQLite. |
75
+ | `MissingColumnsError` | `requireColumns` finds a missing column. `path` is the path, and `missing` gives each missing column as `table.column`. The snapshot is closed. |
76
+ | The error of SQLite | All other failures, for example a file that is not a database. The constructor closes the connection before it throws. |
89
77
 
90
78
  ## The same concepts in other systems
91
79
 
@@ -98,6 +86,7 @@ true
98
86
  ## Documentation
99
87
 
100
88
  - [0001 Never immutable, and held only while reading](./docs/adr/0001-never-immutable-and-held-only-while-reading.md)
89
+ - [0002 The package throws its own errors](./docs/adr/0002-the-package-throws-its-own-errors.md)
101
90
  - [Code copied into this package](./docs/copied-code.md)
102
91
 
103
92
  ## Development
@@ -113,7 +102,9 @@ npx nx run sqlite-snapshot:build # compiles src/ to dist/
113
102
 
114
103
  ```
115
104
  src/
116
- index.ts the exports
117
- snapshot.ts Snapshot, SnapshotColumns, UnavailableError and SchemaError
118
- snapshot.test.ts the tests, on real SQLite files
105
+ index.ts the exports
106
+ snapshot.ts Snapshot and SnapshotColumns
107
+ unavailable-error.ts UnavailableError
108
+ missing-columns-error.ts MissingColumnsError
109
+ snapshot.test.ts the tests, on real SQLite files
119
110
  ```
package/dist/index.d.ts CHANGED
@@ -1,2 +1,4 @@
1
- export { type SchemaError, Snapshot, type SnapshotColumns, type UnavailableError, } from './snapshot.ts';
1
+ export { MissingColumnsError } from './missing-columns-error.ts';
2
+ export { Snapshot, type SnapshotColumns } from './snapshot.ts';
3
+ export { UnavailableError } from './unavailable-error.ts';
2
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,WAAW,EAChB,QAAQ,EACR,KAAK,eAAe,EACpB,KAAK,gBAAgB,GACtB,MAAM,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAE,KAAK,eAAe,EAAE,MAAM,eAAe,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC"}
package/dist/index.js CHANGED
@@ -1,2 +1,4 @@
1
- export { Snapshot, } from "./snapshot.js";
1
+ export { MissingColumnsError } from "./missing-columns-error.js";
2
+ export { Snapshot } from "./snapshot.js";
3
+ export { UnavailableError } from "./unavailable-error.js";
2
4
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,GAGT,MAAM,eAAe,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAwB,MAAM,eAAe,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC"}
@@ -0,0 +1,7 @@
1
+ /** The database lacks columns that a reader reads: its owner changed its layout. */
2
+ export declare class MissingColumnsError extends Error {
3
+ readonly path: string;
4
+ readonly missing: readonly string[];
5
+ constructor(path: string, missing: readonly string[]);
6
+ }
7
+ //# sourceMappingURL=missing-columns-error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"missing-columns-error.d.ts","sourceRoot":"","sources":["../src/missing-columns-error.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,qBAAa,mBAAoB,SAAQ,KAAK;IAC5C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;gBAExB,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,MAAM,EAAE;CAQrD"}
@@ -0,0 +1,12 @@
1
+ /** The database lacks columns that a reader reads: its owner changed its layout. */
2
+ export class MissingColumnsError extends Error {
3
+ path;
4
+ missing;
5
+ constructor(path, missing) {
6
+ super(`The database at ${JSON.stringify(path)} lacks the columns ${missing.join(', ')}: its owner changed its layout. Update the reader to the new layout.`);
7
+ this.name = 'MissingColumnsError';
8
+ this.path = path;
9
+ this.missing = missing;
10
+ }
11
+ }
12
+ //# sourceMappingURL=missing-columns-error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"missing-columns-error.js","sourceRoot":"","sources":["../src/missing-columns-error.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IACnC,IAAI,CAAS;IACb,OAAO,CAAoB;IAEpC,YAAY,IAAY,EAAE,OAA0B;QAClD,KAAK,CACH,mBAAmB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,sBAAsB,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,sEAAsE,CACtJ,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;QAClC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;CACF"}
@@ -1,12 +1,10 @@
1
1
  import { type SQLInputValue, type SQLOutputValue } from 'node:sqlite';
2
- export type UnavailableError = new (path: string, cause: unknown) => Error;
3
- export type SchemaError = new (path: string, missing: readonly string[]) => Error;
4
2
  export type SnapshotColumns = Readonly<Record<string, readonly string[]>>;
5
3
  export declare class Snapshot implements Disposable {
6
4
  #private;
7
5
  readonly path: string;
8
- constructor(path: string, unavailable: UnavailableError);
9
- requireColumns(columns: SnapshotColumns, schema: SchemaError): void;
6
+ constructor(path: string);
7
+ requireColumns(columns: SnapshotColumns): void;
10
8
  missingColumns(columns: SnapshotColumns): string[];
11
9
  all(sql: string, ...parameters: SQLInputValue[]): Record<string, SQLOutputValue>[];
12
10
  iterate(sql: string, ...parameters: SQLInputValue[]): IteratorObject<Record<string, SQLOutputValue>, undefined>;
@@ -1 +1 @@
1
- {"version":3,"file":"snapshot.d.ts","sourceRoot":"","sources":["../src/snapshot.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,aAAa,EAClB,KAAK,cAAc,EACpB,MAAM,aAAa,CAAC;AAIrB,MAAM,MAAM,gBAAgB,GAAG,KAAK,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,KAAK,KAAK,CAAC;AAI3E,MAAM,MAAM,WAAW,GAAG,KACxB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,SAAS,MAAM,EAAE,KACvB,KAAK,CAAC;AAGX,MAAM,MAAM,eAAe,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CAAC,CAAC;AAyB1E,qBAAa,QAAS,YAAW,UAAU;;IACzC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;gBAGV,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,gBAAgB;IAgBvD,cAAc,CAAC,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,WAAW,GAAG,IAAI;IAUnE,cAAc,CAAC,OAAO,EAAE,eAAe,GAAG,MAAM,EAAE;IAalD,GAAG,CACD,GAAG,EAAE,MAAM,EACX,GAAG,UAAU,EAAE,aAAa,EAAE,GAC7B,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,EAAE;IAKnC,OAAO,CACL,GAAG,EAAE,MAAM,EACX,GAAG,UAAU,EAAE,aAAa,EAAE,GAC7B,cAAc,CAAC,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,EAAE,SAAS,CAAC;IAI5D,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI;CAKzB"}
1
+ {"version":3,"file":"snapshot.d.ts","sourceRoot":"","sources":["../src/snapshot.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,aAAa,EAClB,KAAK,cAAc,EACpB,MAAM,aAAa,CAAC;AAMrB,MAAM,MAAM,eAAe,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CAAC,CAAC;AAyB1E,qBAAa,QAAS,YAAW,UAAU;;IACzC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;gBAGV,IAAI,EAAE,MAAM;IAgBxB,cAAc,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI;IAU9C,cAAc,CAAC,OAAO,EAAE,eAAe,GAAG,MAAM,EAAE;IAalD,GAAG,CACD,GAAG,EAAE,MAAM,EACX,GAAG,UAAU,EAAE,aAAa,EAAE,GAC7B,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,EAAE;IAKnC,OAAO,CACL,GAAG,EAAE,MAAM,EACX,GAAG,UAAU,EAAE,aAAa,EAAE,GAC7B,cAAc,CAAC,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,EAAE,SAAS,CAAC;IAI5D,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI;CAKzB"}
package/dist/snapshot.js CHANGED
@@ -1,5 +1,7 @@
1
1
  import { DatabaseSync, } from 'node:sqlite';
2
- function open(path, unavailable) {
2
+ import { MissingColumnsError } from "./missing-columns-error.js";
3
+ import { UnavailableError } from "./unavailable-error.js";
4
+ function open(path) {
3
5
  try {
4
6
  return new DatabaseSync(path, { readOnly: true });
5
7
  }
@@ -11,7 +13,7 @@ function open(path, unavailable) {
11
13
  // SQLite gives AUTH only for an authorizer, and this private connection
12
14
  // has none. Any other failure is not one that access can fix.
13
15
  cause.errcode === 14)
14
- throw new unavailable(path, cause);
16
+ throw new UnavailableError(path, cause);
15
17
  throw cause;
16
18
  }
17
19
  }
@@ -23,9 +25,9 @@ function open(path, unavailable) {
23
25
  export class Snapshot {
24
26
  path;
25
27
  #database;
26
- constructor(path, unavailable) {
28
+ constructor(path) {
27
29
  this.path = path;
28
- this.#database = open(path, unavailable);
30
+ this.#database = open(path);
29
31
  try {
30
32
  // The first read pins the snapshot, so it is taken now rather than at
31
33
  // the caller's first query; a file that is no database fails here.
@@ -39,12 +41,12 @@ export class Snapshot {
39
41
  }
40
42
  // Refuses a layout without these columns, and closes the database: the
41
43
  // check a reader makes while it opens the snapshot.
42
- requireColumns(columns, schema) {
44
+ requireColumns(columns) {
43
45
  const missing = this.missingColumns(columns);
44
46
  if (missing.length === 0)
45
47
  return;
46
48
  this[Symbol.dispose]();
47
- throw new schema(this.path, missing);
49
+ throw new MissingColumnsError(this.path, missing);
48
50
  }
49
51
  // The columns, as table.column, that this layout lacks. A reader whose
50
52
  // reads use different tables checks each read with it and keeps the
@@ -1 +1 @@
1
- {"version":3,"file":"snapshot.js","sourceRoot":"","sources":["../src/snapshot.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,GAGb,MAAM,aAAa,CAAC;AAgBrB,SAAS,IAAI,CAAC,IAAY,EAAE,WAA6B;IACvD,IAAI,CAAC;QACH,OAAO,IAAI,YAAY,CAAC,IAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;IACpD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IACE,KAAK,YAAY,KAAK;YACtB,SAAS,IAAI,KAAK;YAClB,oEAAoE;YACpE,sEAAsE;YACtE,wEAAwE;YACxE,8DAA8D;YAC9D,KAAK,CAAC,OAAO,KAAK,EAAE;YAEpB,MAAM,IAAI,WAAW,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QACrC,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC;AAED,wEAAwE;AACxE,0EAA0E;AAC1E,6EAA6E;AAC7E,6EAA6E;AAC7E,yBAAyB;AACzB,MAAM,OAAO,QAAQ;IACV,IAAI,CAAS;IACb,SAAS,CAAe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AK,CAAC,EAAE,EAAE;YACxD,MAAM,OAAO,GAAG,IAAI,GAAG,CACrB,IAAI,CAAC,GAAG,CAAC,uCAAuC,EAAE,KAAK,CAAC,CAAC,GAAG,CAC1D,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CACxB,CACF,CAAC;YACF,OAAO,KAAK;iBACT,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;iBACpC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,KAAK,IAAI,IAAI,EAAE,CAAC,CAAC;QACvC,CAAC,CAAC,CAAC;IACL,CAAC;IAED,GAAG,CACD,GAAW,EACX,GAAG,UAA2B;QAE9B,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,UAAU,CAAC,CAAC;IACxD,CAAC;IAED,2DAA2D;IAC3D,OAAO,CACL,GAAW,EACX,GAAG,UAA2B;QAE9B,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,GAAG,UAAU,CAAC,CAAC;IAC5D,CAAC;IAED,CAAC,MAAM,CAAC,OAAO,CAAC;QACd,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM;YAAE,OAAO;QACnC,IAAI,IAAI,CAAC,SAAS,CAAC,aAAa;YAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAChE,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;IACzB,CAAC;CACF"}
@@ -0,0 +1,6 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,10 @@
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
@@ -0,0 +1 @@
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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zukhruf/sqlite-snapshot",
3
- "version": "0.3.50",
3
+ "version": "0.3.52",
4
4
  "description": "A read-only snapshot of a SQLite database that another process owns and writes. It pins one moment with a read transaction, so the tables agree, and it never opens the file immutable, so it sees the newest rows in the WAL. It checks the columns that a reader needs, and gives the caller's own errors for a missing file or a missing column.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -40,6 +40,6 @@
40
40
  "access": "public"
41
41
  },
42
42
  "devDependencies": {
43
- "@zukhruf/testing": "^0.3.50"
43
+ "@zukhruf/testing": "^0.3.52"
44
44
  }
45
45
  }