@serfab/quereus-plugin-sereus 0.10.0 → 0.11.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/README.md +367 -361
- package/dist/cached-storage.d.ts +66 -0
- package/dist/cached-storage.js +103 -0
- package/dist/cached-storage.js.map +1 -0
- package/dist/compose-strand.d.ts +2 -2
- package/dist/compose-strand.js +18 -22
- package/dist/compose-strand.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/parse-config.js +23 -11
- package/dist/parse-config.js.map +1 -1
- package/dist/plugin-browser.js +15040 -11647
- package/dist/plugin-browser.js.map +4 -4
- package/dist/strand-schema.js +503 -503
- package/dist/types.d.ts +37 -10
- package/package.json +8 -8
- package/src/cached-storage.ts +107 -0
- package/src/cluster-size.ts +248 -248
- package/src/compose-strand.ts +21 -23
- package/src/connect-browser.ts +57 -57
- package/src/connect.ts +38 -38
- package/src/index.ts +2 -1
- package/src/parse-config.ts +70 -55
- package/src/plugin-browser.ts +29 -29
- package/src/plugin.ts +39 -39
- package/src/strand-schema.ts +533 -533
- package/src/types.ts +106 -78
package/src/types.ts
CHANGED
|
@@ -1,78 +1,106 @@
|
|
|
1
|
-
import type { Libp2p } from '@libp2p/interface';
|
|
2
|
-
import type { IRepo } from '@optimystic/db-core';
|
|
3
|
-
import type { IRawStorage } from '@optimystic/db-p2p';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
*
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
1
|
+
import type { Libp2p } from '@libp2p/interface';
|
|
2
|
+
import type { IRepo } from '@optimystic/db-core';
|
|
3
|
+
import type { IRawStorage } from '@optimystic/db-p2p';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Which Optimystic transactor a strand connection commits through — a choice of
|
|
7
|
+
* storage engine, nothing more. See {@link StrandConnectionOptions.transactor}.
|
|
8
|
+
*
|
|
9
|
+
* Deliberately a closed union, and narrower than what Optimystic's
|
|
10
|
+
* `collection-factory.ts` accepts: that factory also switches on `'mesh-test'`
|
|
11
|
+
* (its production transactor stack over a one-node mock mesh) and falls through
|
|
12
|
+
* to a host-registered custom transactor for any other name. Neither is offered
|
|
13
|
+
* here — `composeStrand`'s node gate special-cases only `'test'`, so
|
|
14
|
+
* `'mesh-test'` would get a real libp2p node it does not want, and nothing in
|
|
15
|
+
* this repo registers a custom transactor. A closed union lets `parseConfig`
|
|
16
|
+
* reject a typo (`'locl'`) instead of handing it downstream; widen it (and the
|
|
17
|
+
* node gate with it) when one of those values is actually needed.
|
|
18
|
+
*/
|
|
19
|
+
export type StrandTransactor = 'local' | 'network' | 'test';
|
|
20
|
+
|
|
21
|
+
export interface StrandConnectionOptions {
|
|
22
|
+
/** UUID of the strand to connect to */
|
|
23
|
+
strandId: string;
|
|
24
|
+
/** Bootstrap multiaddrs for peer discovery */
|
|
25
|
+
bootstrapNodes?: string[];
|
|
26
|
+
/** sApp schema DDL to apply (optional - omit if schema already exists on strand) */
|
|
27
|
+
schema?: string;
|
|
28
|
+
/** sApp author public key */
|
|
29
|
+
sAppId?: string;
|
|
30
|
+
/** sApp version */
|
|
31
|
+
sAppVersion?: string;
|
|
32
|
+
/** libp2p listening port (default: 0 = random) */
|
|
33
|
+
port?: number;
|
|
34
|
+
/** Enable optimystic caching (default: true) */
|
|
35
|
+
enableCache?: boolean;
|
|
36
|
+
/** FRET profile (default: 'edge') */
|
|
37
|
+
fretProfile?: 'edge' | 'core';
|
|
38
|
+
/**
|
|
39
|
+
* Number of nodes Optimystic is told this strand's replication cluster should
|
|
40
|
+
* have. Ignored when {@link libp2pNode} is injected (the injected node was
|
|
41
|
+
* built with its own value). Every peer on the strand should use the same
|
|
42
|
+
* number — see `resolveStrandClusterSize`. Defaults to
|
|
43
|
+
* `DEFAULT_STRAND_CLUSTER_SIZE` (4 — the smallest breadth whose 0.75
|
|
44
|
+
* super-majority still commits with one holder offline).
|
|
45
|
+
*/
|
|
46
|
+
clusterSize?: number;
|
|
47
|
+
/** Inject an existing libp2p node instead of creating one */
|
|
48
|
+
libp2pNode?: Libp2p;
|
|
49
|
+
/** Required when libp2pNode is provided */
|
|
50
|
+
coordinatedRepo?: IRepo;
|
|
51
|
+
/**
|
|
52
|
+
* Persistent raw storage. When provided:
|
|
53
|
+
* - it is passed to `createLibp2pNode` as `storage` so the libp2p data path uses it,
|
|
54
|
+
* - with `transactor: 'local'` it is also handed to the optimystic plugin as
|
|
55
|
+
* `rawStorageFactory: () => storage` so the local transactor persists DML
|
|
56
|
+
* on the same instance (avoids cache divergence between the two consumers).
|
|
57
|
+
*
|
|
58
|
+
* The plugin treats `storage` as borrowed — it is NOT closed on `shutdown()`.
|
|
59
|
+
*/
|
|
60
|
+
storage?: IRawStorage;
|
|
61
|
+
/**
|
|
62
|
+
* Which Optimystic transactor writes and reads go through (default
|
|
63
|
+
* `'network'`):
|
|
64
|
+
*
|
|
65
|
+
* - `'network'` — transactions go through the strand's libp2p cohort. A node
|
|
66
|
+
* that is alone coordinates for itself, so this works with one peer or
|
|
67
|
+
* many; it is the only value an application should use.
|
|
68
|
+
* - `'local'` — transactions go straight to this process's raw storage, no
|
|
69
|
+
* peers consulted. For in-process tests and tooling; pair it with a
|
|
70
|
+
* persistent {@link storage} to survive restart.
|
|
71
|
+
* - `'test'` — Optimystic's in-memory fake. No libp2p node is created unless
|
|
72
|
+
* one is injected. Unit tests only.
|
|
73
|
+
*/
|
|
74
|
+
transactor?: StrandTransactor;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export interface SereusPluginResult {
|
|
78
|
+
vtables: [];
|
|
79
|
+
functions: [];
|
|
80
|
+
collations: [];
|
|
81
|
+
/**
|
|
82
|
+
* Catalog-hydration counts from the warm-restart hydrate that runs before
|
|
83
|
+
* `apply schema App;`. On a cold start (empty storage) both are 0; on a warm
|
|
84
|
+
* restart they report the persisted tables/indexes the catalog was primed
|
|
85
|
+
* with — so a test can assert hydration actually ran. `undefined` only if
|
|
86
|
+
* composition threw before hydrate.
|
|
87
|
+
*/
|
|
88
|
+
hydrated?: { tables: number; indexes: number };
|
|
89
|
+
/**
|
|
90
|
+
* The transactor this connection actually resolved to — the RESOLVED value,
|
|
91
|
+
* not the requested one, so a spec whose whole point is the arm it runs on can
|
|
92
|
+
* assert it rather than assume it. Equals `options.transactor` when one was
|
|
93
|
+
* given, `'network'` otherwise.
|
|
94
|
+
*/
|
|
95
|
+
transactor: StrandTransactor;
|
|
96
|
+
/** Shuts down the libp2p node and collection factory. Call when done. */
|
|
97
|
+
shutdown: () => Promise<void>;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Extended Libp2p node type with coordinatedRepo attached by createLibp2pNode.
|
|
102
|
+
* @internal
|
|
103
|
+
*/
|
|
104
|
+
export interface Libp2pNodeWithRepo extends Libp2p {
|
|
105
|
+
coordinatedRepo: IRepo;
|
|
106
|
+
}
|