@serfab/quereus-plugin-sereus 1.22.0 → 1.23.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@serfab/quereus-plugin-sereus",
3
- "version": "1.22.0",
3
+ "version": "1.23.0",
4
4
  "type": "module",
5
5
  "description": "Quereus plugin that connects to a Sereus strand for SQL access",
6
6
  "main": "dist/index.js",
@@ -68,13 +68,13 @@
68
68
  "@libp2p/circuit-relay-v2": "^4.2.13",
69
69
  "@libp2p/interface": "^3.3.0",
70
70
  "@libp2p/websockets": "^10.1.21",
71
- "@optimystic/db-core": "^1.26.0",
72
- "@optimystic/db-p2p": "^1.26.0",
73
- "@optimystic/db-p2p-storage-fs": "^1.26.0",
74
- "@optimystic/db-p2p-storage-web": "^1.26.0",
75
- "@optimystic/quereus-plugin-crypto": "^1.26.0",
76
- "@optimystic/quereus-plugin-optimystic": "^1.26.0",
77
- "@quereus/quereus": "^5.0.0",
71
+ "@optimystic/db-core": "^1.27.0",
72
+ "@optimystic/db-p2p": "^1.27.0",
73
+ "@optimystic/db-p2p-storage-fs": "^1.27.0",
74
+ "@optimystic/db-p2p-storage-web": "^1.27.0",
75
+ "@optimystic/quereus-plugin-crypto": "^1.27.0",
76
+ "@optimystic/quereus-plugin-optimystic": "^1.27.0",
77
+ "@quereus/quereus": "^5.4.0",
78
78
  "debug": "^4.4.3"
79
79
  },
80
80
  "quereus": {
package/src/app-schema.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import debug from 'debug';
2
- import { QuereusError, StatusCode, TransactionActiveError, type Database } from '@quereus/quereus';
2
+ import { Database, QuereusError, StatusCode, TransactionActiveError } from '@quereus/quereus';
3
3
  import type { Libp2p } from '@libp2p/interface';
4
4
  import { classifyCommitFailure } from '@optimystic/db-core';
5
5
  import { QueuedEntriesBlockSchemaChangeError, QueueDisposedError } from '@optimystic/quereus-plugin-optimystic/plugin';
@@ -36,6 +36,23 @@ export async function applyAppSchema(db: Database, schema: string): Promise<void
36
36
  }
37
37
  }
38
38
 
39
+ /**
40
+ * The refusals of {@link applyAppSchema} decided by the schema text alone (a seed item, an item the
41
+ * parser skipped, a syntax error), thrown as {@link AppSchemaRefusedError} without a strand database:
42
+ * `declare schema` only parses and records, so it runs on a throwaway Quereus database that writes
43
+ * nothing anywhere. A refusal decided against a strand's tables and rows needs that strand, so it passes here.
44
+ */
45
+ export async function checkAppSchema(schema: string): Promise<void> {
46
+ const db = new Database();
47
+ try {
48
+ await declareAppSchema(db, schema);
49
+ } catch (err) {
50
+ throw asAppSchemaRefusal(err);
51
+ } finally {
52
+ await db.close();
53
+ }
54
+ }
55
+
39
56
  /** Declare `schema` as `App`, refusing the items {@link applyAppSchema} refuses. Writes nothing to the strand. */
40
57
  async function declareAppSchema(db: Database, schema: string): Promise<void> {
41
58
  await db.exec(`
package/src/index.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { connectToStrand } from './connect.js';
2
2
  export { offlineControllerOf } from './compose-strand.js';
3
- export { applyAppSchema, AppSchemaRefusedError, appSchemaRefusalOf } from './app-schema.js';
3
+ export { applyAppSchema, checkAppSchema, AppSchemaRefusedError, appSchemaRefusalOf } from './app-schema.js';
4
4
  export { createEmptyCollections, type CollectionRegistrySource } from './empty-collections.js';
5
5
  export {
6
6
  MIN_CLUSTER_SIZE,