@cero-base/core 1.18.2 → 1.19.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.
Files changed (46) hide show
  1. package/README.md +5 -6
  2. package/package.json +8 -8
  3. package/src/blobs/index.js +2 -2
  4. package/src/database/changes.js +37 -59
  5. package/src/database/dispatch.js +31 -45
  6. package/src/database/index.js +395 -343
  7. package/src/database/rotation.js +201 -189
  8. package/src/identity/index.js +3 -3
  9. package/src/lib/utils.js +50 -18
  10. package/src/pairing/candidate.js +125 -0
  11. package/src/pairing/index.js +6 -223
  12. package/src/pairing/request.js +102 -0
  13. package/src/storage/index.js +11 -18
  14. package/types/blobs/codec.d.ts +8 -8
  15. package/types/blobs/index.d.ts +34 -33
  16. package/types/blobs/server.d.ts +8 -8
  17. package/types/database/changes.d.ts +5 -7
  18. package/types/database/dispatch.d.ts +30 -23
  19. package/types/database/encryption.d.ts +14 -10
  20. package/types/database/envelope.d.ts +2 -2
  21. package/types/database/index.d.ts +173 -181
  22. package/types/database/rotation.d.ts +53 -30
  23. package/types/identity/index.d.ts +81 -81
  24. package/types/index.d.ts +37 -51
  25. package/types/lib/constants.d.ts +34 -38
  26. package/types/lib/errors.d.ts +10 -10
  27. package/types/lib/schema.d.ts +47 -37
  28. package/types/lib/spec/index.d.ts +29 -55
  29. package/types/lib/utils.d.ts +27 -17
  30. package/types/network/discovery.d.ts +7 -7
  31. package/types/network/index.d.ts +50 -48
  32. package/types/pairing/candidate.d.ts +37 -0
  33. package/types/pairing/index.d.ts +87 -139
  34. package/types/pairing/invite.d.ts +88 -88
  35. package/types/pairing/request.d.ts +135 -0
  36. package/types/rpc/client.d.ts +2 -2
  37. package/types/rpc/index.d.ts +33 -33
  38. package/types/rpc/peer.d.ts +9 -7
  39. package/types/rpc/server.d.ts +2 -2
  40. package/types/storage/index.d.ts +70 -68
  41. package/src/database/bootstrap.js +0 -133
  42. package/src/database/hooks.js +0 -112
  43. package/src/database/membership.js +0 -67
  44. package/types/database/bootstrap.d.ts +0 -20
  45. package/types/database/hooks.d.ts +0 -8
  46. package/types/database/membership.d.ts +0 -7
@@ -1,3 +1,69 @@
1
+ export type InviteFields = {
2
+ /**
3
+ * Signer's long-lived public key.
4
+ */
5
+ publicKey: Uint8Array;
6
+ /**
7
+ * Optional role tag baked into the signed body.
8
+ */
9
+ role: string;
10
+ /**
11
+ * Absolute expiry timestamp; `0` means never.
12
+ */
13
+ expires: number;
14
+ /**
15
+ * Encoded payload (raw or via `encoding`).
16
+ */
17
+ data: Uint8Array | null;
18
+ /**
19
+ * Raw blind-pairing invite handed to candidates.
20
+ */
21
+ blind: Uint8Array;
22
+ /**
23
+ * Ed25519 signature over the canonical body.
24
+ */
25
+ sig?: Uint8Array;
26
+ /**
27
+ * Cached z32 string form.
28
+ */
29
+ _str?: string | null;
30
+ };
31
+ export type CreateInviteOpts = {
32
+ /**
33
+ * 64-byte Ed25519 secret key used to sign.
34
+ */
35
+ secretKey: Uint8Array;
36
+ /**
37
+ * 32-byte Ed25519 public key matching `secretKey`.
38
+ */
39
+ publicKey: Uint8Array;
40
+ /**
41
+ * Optional role tag for the joiner.
42
+ */
43
+ role: string;
44
+ /**
45
+ * TTL in ms from now; `0` means never expires.
46
+ */
47
+ expiresIn: number;
48
+ /**
49
+ * Caller payload; encoded via `encoding` when provided.
50
+ */
51
+ data: any;
52
+ /**
53
+ * Raw blind-pairing invite to wrap.
54
+ */
55
+ blind: Uint8Array;
56
+ /**
57
+ * compact-encoding type used to encode `data`.
58
+ */
59
+ encoding?: any;
60
+ };
61
+ export type ParseInviteOpts = {
62
+ /**
63
+ * compact-encoding type used to decode the embedded payload.
64
+ */
65
+ encoding?: any;
66
+ };
1
67
  /**
2
68
  * @typedef {object} InviteFields
3
69
  * @property {Uint8Array} publicKey Signer's long-lived public key.
@@ -28,33 +94,7 @@
28
94
  * @property {any} [_rawData] Decoded payload kept alongside the encoded `data` for convenience.
29
95
  * @property {Uint8Array} _discoveryKey Cached discovery key of the wrapped blind invite.
30
96
  */
31
- export class Invite {
32
- /**
33
- * Build and sign a new invite envelope wrapping a blind-pairing invite.
34
- *
35
- * @param {CreateInviteOpts} opts
36
- * @returns {Invite}
37
- */
38
- static create({ secretKey, publicKey, role, expiresIn, data, blind, encoding }: CreateInviteOpts): Invite;
39
- /**
40
- * Parse a z32 invite string, verify its signature and (optionally) decode
41
- * its payload.
42
- *
43
- * @param {string} str
44
- * @param {ParseInviteOpts} [opts]
45
- * @returns {Invite}
46
- */
47
- static parse(str: string, { encoding }?: ParseInviteOpts): Invite;
48
- /**
49
- * Cheap structural test — does `str` decode as an invite envelope? Does not
50
- * verify the signature.
51
- *
52
- * @param {unknown} str
53
- * @returns {boolean}
54
- */
55
- static isInvite(str: unknown): boolean;
56
- /** @param {InviteFields} fields */
57
- constructor(fields: InviteFields);
97
+ export declare class Invite {
58
98
  version: number;
59
99
  publicKey: Uint8Array<ArrayBufferLike>;
60
100
  role: string;
@@ -64,6 +104,8 @@ export class Invite {
64
104
  sig: Uint8Array<ArrayBufferLike>;
65
105
  _str: string;
66
106
  _discoveryKey: any;
107
+ /** @param {InviteFields} fields */
108
+ constructor(fields: InviteFields);
67
109
  /**
68
110
  * Whether the invite is past its TTL (always `false` when `expires === 0`).
69
111
  *
@@ -88,70 +130,28 @@ export class Invite {
88
130
  * @returns {string}
89
131
  */
90
132
  toString(): string;
91
- }
92
- export type InviteFields = {
93
- /**
94
- * Signer's long-lived public key.
95
- */
96
- publicKey: Uint8Array;
97
- /**
98
- * Optional role tag baked into the signed body.
99
- */
100
- role: string;
101
- /**
102
- * Absolute expiry timestamp; `0` means never.
103
- */
104
- expires: number;
105
- /**
106
- * Encoded payload (raw or via `encoding`).
107
- */
108
- data: Uint8Array | null;
109
- /**
110
- * Raw blind-pairing invite handed to candidates.
111
- */
112
- blind: Uint8Array;
113
- /**
114
- * Ed25519 signature over the canonical body.
115
- */
116
- sig?: Uint8Array;
117
133
  /**
118
- * Cached z32 string form.
119
- */
120
- _str?: string | null;
121
- };
122
- export type CreateInviteOpts = {
123
- /**
124
- * 64-byte Ed25519 secret key used to sign.
125
- */
126
- secretKey: Uint8Array;
127
- /**
128
- * 32-byte Ed25519 public key matching `secretKey`.
129
- */
130
- publicKey: Uint8Array;
131
- /**
132
- * Optional role tag for the joiner.
133
- */
134
- role: string;
135
- /**
136
- * TTL in ms from now; `0` means never expires.
137
- */
138
- expiresIn: number;
139
- /**
140
- * Caller payload; encoded via `encoding` when provided.
141
- */
142
- data: any;
143
- /**
144
- * Raw blind-pairing invite to wrap.
134
+ * Build and sign a new invite envelope wrapping a blind-pairing invite.
135
+ *
136
+ * @param {CreateInviteOpts} opts
137
+ * @returns {Invite}
145
138
  */
146
- blind: Uint8Array;
139
+ static create({ secretKey, publicKey, role, expiresIn, data, blind, encoding }: CreateInviteOpts): Invite;
147
140
  /**
148
- * compact-encoding type used to encode `data`.
141
+ * Parse a z32 invite string, verify its signature and (optionally) decode
142
+ * its payload.
143
+ *
144
+ * @param {string} str
145
+ * @param {ParseInviteOpts} [opts]
146
+ * @returns {Invite}
149
147
  */
150
- encoding?: any;
151
- };
152
- export type ParseInviteOpts = {
148
+ static parse(str: string, { encoding }?: ParseInviteOpts): Invite;
153
149
  /**
154
- * compact-encoding type used to decode the embedded payload.
150
+ * Cheap structural test — does `str` decode as an invite envelope? Does not
151
+ * verify the signature.
152
+ *
153
+ * @param {unknown} str
154
+ * @returns {boolean}
155
155
  */
156
- encoding?: any;
157
- };
156
+ static isInvite(str: unknown): boolean;
157
+ }
@@ -0,0 +1,135 @@
1
+ export declare const STATUS_ACCEPTED = 0;
2
+ export declare const STATUS_DENIED = 1;
3
+ export declare const Response: {
4
+ preencode(state: any, m: any): void;
5
+ encode(state: any, m: any): void;
6
+ decode(state: any): {
7
+ status: any;
8
+ reason: any;
9
+ key: any;
10
+ encryptionKey: any;
11
+ extra: any;
12
+ };
13
+ } | {
14
+ preencode(state: any, m: any): void;
15
+ encode(state: any, m: any): void;
16
+ decode(state: any): {
17
+ data: any;
18
+ };
19
+ } | {
20
+ preencode(state: any, m: any): void;
21
+ encode(state: any, m: any): void;
22
+ decode(state: any): {
23
+ id: any;
24
+ name: any;
25
+ role: any;
26
+ noAccept: boolean;
27
+ };
28
+ } | {
29
+ preencode(state: any, m: any): void;
30
+ encode(state: any, m: any): void;
31
+ decode(state: any): {
32
+ coreKey: any;
33
+ blockOffset: any;
34
+ blockLength: any;
35
+ byteOffset: any;
36
+ byteLength: any;
37
+ type: any;
38
+ };
39
+ } | {
40
+ preencode(state: any, m: any): void;
41
+ encode(state: any, m: any): void;
42
+ decode(state: any): {
43
+ prev: any;
44
+ next: any;
45
+ };
46
+ };
47
+ export type ConfirmOpts = {
48
+ /**
49
+ * 32-byte resource key delivered to the joiner; required at runtime.
50
+ */
51
+ key?: Uint8Array;
52
+ /**
53
+ * Optional 32-byte symmetric key.
54
+ */
55
+ encryptionKey?: Uint8Array | null;
56
+ /**
57
+ * Extra opaque bytes piggybacked on the response.
58
+ */
59
+ additional?: Uint8Array | null;
60
+ };
61
+ export type RequestOpts = {
62
+ /**
63
+ * Owning Pairing instance.
64
+ */
65
+ pairing: import('./index.js').Pairing;
66
+ /**
67
+ * blind-pairing candidate request being answered.
68
+ */
69
+ req: any;
70
+ /**
71
+ * Invite the candidate paired against.
72
+ */
73
+ invite: import('./invite.js').Invite;
74
+ /**
75
+ * Per-invite seed used to sign the response.
76
+ */
77
+ seed: Uint8Array;
78
+ /**
79
+ * Decoded joiner payload (raw bytes when no encoding).
80
+ */
81
+ userData: any;
82
+ /**
83
+ * Called once when the candidate is confirmed or denied.
84
+ */
85
+ onsettle: () => void;
86
+ };
87
+ /**
88
+ * @typedef {object} ConfirmOpts
89
+ * @property {Uint8Array} [key] 32-byte resource key delivered to the joiner; required at runtime.
90
+ * @property {Uint8Array | null} [encryptionKey] Optional 32-byte symmetric key.
91
+ * @property {Uint8Array | null} [additional] Extra opaque bytes piggybacked on the response.
92
+ *
93
+ * @typedef {object} RequestOpts
94
+ * @property {import('./index.js').Pairing} pairing Owning Pairing instance.
95
+ * @property {any} req blind-pairing candidate request being answered.
96
+ * @property {import('./invite.js').Invite} invite Invite the candidate paired against.
97
+ * @property {Uint8Array} seed Per-invite seed used to sign the response.
98
+ * @property {any} userData Decoded joiner payload (raw bytes when no encoding).
99
+ * @property {() => void} onsettle Called once when the candidate is confirmed or denied.
100
+ */
101
+ /**
102
+ * Internal — a pairing request from an incoming candidate, awaiting the host's
103
+ * accept/deny. Built in `_oncandidate` and emitted on the `'candidate'` event so
104
+ * the host can decide via `confirm` / `deny`. (The candidate is the joiner; this
105
+ * is the host's handle to answer it.)
106
+ *
107
+ * @property {boolean} _settled Whether confirm/deny has already run.
108
+ */
109
+ export declare class Request {
110
+ pairing: import("./index.js").Pairing;
111
+ _req: any;
112
+ _seed: Uint8Array<ArrayBufferLike>;
113
+ _settled: boolean;
114
+ _onsettle: () => void;
115
+ invite: import("./invite.js").Invite;
116
+ userData: any;
117
+ publicKey: any;
118
+ /** @param {RequestOpts} opts */
119
+ constructor(opts: RequestOpts);
120
+ /**
121
+ * Accept the candidate and reveal the resource key. Idempotent.
122
+ *
123
+ * @param {ConfirmOpts} opts
124
+ * @returns {Promise<void>}
125
+ */
126
+ confirm({ key, encryptionKey, additional }?: ConfirmOpts): Promise<void>;
127
+ /**
128
+ * Reject the candidate with an optional reason. Idempotent.
129
+ *
130
+ * @param {string} [reason]
131
+ * @returns {Promise<void>}
132
+ */
133
+ deny(reason?: string): Promise<void>;
134
+ _respond(envelope: any): void;
135
+ }
@@ -1,7 +1,7 @@
1
+ import { RPCPeer } from './peer.js';
1
2
  /**
2
3
  * Client-side RPC adapter — issues requests over the framed IPC stream.
3
4
  * All wiring lives in {@link RPCPeer}; this is the client-named role.
4
5
  */
5
- export class RPCClient extends RPCPeer {
6
+ export declare class RPCClient extends RPCPeer {
6
7
  }
7
- import { RPCPeer } from './peer.js';
@@ -1,36 +1,5 @@
1
- /**
2
- * @typedef {object} Spec
3
- * @property {{ encode: (type: string, value: any) => Uint8Array, decode: (type: string, buf: Uint8Array) => any, getEncoding?: (name: string) => any }} schema hyperschema-shaped module.
4
- * @property {{ ns?: string }} [meta] Optional metadata; `ns` controls envelope type fqns.
5
- * @property {any} [rpc] hrpc constructor used by RPCServer/RPCClient.
6
- * @property {Codec} [codec] Filled in by `bindCodec`.
7
- *
8
- * @typedef {object} Codec
9
- * @property {(type: string, row: any) => Uint8Array} encodeRow
10
- * @property {(type: string, buf: Uint8Array) => any} decodeRow
11
- * @property {(type: string, rows: any[]) => Uint8Array} encodeRows
12
- * @property {(type: string, changes: Array<{ prev: any, next: any }>) => Uint8Array} encodeChanges
13
- * @property {(type: string, buf: Uint8Array) => Array<{ prev: any, next: any }>} decodeChanges
14
- * @property {(type: string, buf: Uint8Array) => any[]} decodeRows
15
- * @property {(q: any) => Uint8Array} encodeQuery
16
- * @property {(buf: Uint8Array) => any} decodeQuery
17
- * @property {(row: any) => Uint8Array} encodeCreate
18
- * @property {(buf: Uint8Array) => any} decodeCreate
19
- * @property {(handle: any, op: string, data: any) => Uint8Array} encodeAction
20
- * @property {(handle: any, op: string, buf: Uint8Array) => any} decodeAction
21
- */
22
- /**
23
- * Attach a `codec` namespace to a hyperschema-shaped `spec`. Looks up
24
- * envelope types using the spec's namespace (`@<ns>/rows` etc.) and falls
25
- * back to the bundled `@cero/*` envelopes when the spec has not declared
26
- * its own. Returns the spec for chaining.
27
- *
28
- * @param {Spec} spec
29
- * @returns {Spec}
30
- */
31
- export function bindCodec(spec: Spec): Spec;
32
- export { RPCServer } from "./server.js";
33
- export { RPCClient } from "./client.js";
1
+ export { RPCServer } from './server.js';
2
+ export { RPCClient } from './client.js';
34
3
  export type Spec = {
35
4
  /**
36
5
  * hyperschema-shaped module.
@@ -75,3 +44,34 @@ export type Codec = {
75
44
  encodeAction: (handle: any, op: string, data: any) => Uint8Array;
76
45
  decodeAction: (handle: any, op: string, buf: Uint8Array) => any;
77
46
  };
47
+ /**
48
+ * @typedef {object} Spec
49
+ * @property {{ encode: (type: string, value: any) => Uint8Array, decode: (type: string, buf: Uint8Array) => any, getEncoding?: (name: string) => any }} schema hyperschema-shaped module.
50
+ * @property {{ ns?: string }} [meta] Optional metadata; `ns` controls envelope type fqns.
51
+ * @property {any} [rpc] hrpc constructor used by RPCServer/RPCClient.
52
+ * @property {Codec} [codec] Filled in by `bindCodec`.
53
+ *
54
+ * @typedef {object} Codec
55
+ * @property {(type: string, row: any) => Uint8Array} encodeRow
56
+ * @property {(type: string, buf: Uint8Array) => any} decodeRow
57
+ * @property {(type: string, rows: any[]) => Uint8Array} encodeRows
58
+ * @property {(type: string, changes: Array<{ prev: any, next: any }>) => Uint8Array} encodeChanges
59
+ * @property {(type: string, buf: Uint8Array) => Array<{ prev: any, next: any }>} decodeChanges
60
+ * @property {(type: string, buf: Uint8Array) => any[]} decodeRows
61
+ * @property {(q: any) => Uint8Array} encodeQuery
62
+ * @property {(buf: Uint8Array) => any} decodeQuery
63
+ * @property {(row: any) => Uint8Array} encodeCreate
64
+ * @property {(buf: Uint8Array) => any} decodeCreate
65
+ * @property {(handle: any, op: string, data: any) => Uint8Array} encodeAction
66
+ * @property {(handle: any, op: string, buf: Uint8Array) => any} decodeAction
67
+ */
68
+ /**
69
+ * Attach a `codec` namespace to a hyperschema-shaped `spec`. Looks up
70
+ * envelope types using the spec's namespace (`@<ns>/rows` etc.) and falls
71
+ * back to the bundled `@cero/*` envelopes when the spec has not declared
72
+ * its own. Returns the spec for chaining.
73
+ *
74
+ * @param {Spec} spec
75
+ * @returns {Spec}
76
+ */
77
+ export declare function bindCodec(spec: Spec): Spec;
@@ -1,18 +1,20 @@
1
+ import ReadyResource from 'ready-resource';
1
2
  /**
2
3
  * Shared RPC peer: wraps an IPC duplex in a length-framed stream and constructs
3
4
  * the spec's hrpc binding. Frames are paused until `_open` runs so handlers
4
5
  * registered before `ready()` see a clean slate. `RPCClient` and `RPCServer`
5
6
  * are thin named subclasses — identical wiring, distinct roles.
6
7
  */
7
- export class RPCPeer extends ReadyResource {
8
- /**
9
- * @param {any} ipc Duplex IPC stream (e.g. a socket or pipe).
10
- * @param {import('./index.js').Spec} spec Spec object exposing `rpc` and `schema`.
11
- */
12
- constructor(ipc: any, spec: import("./index.js").Spec);
8
+ export declare class RPCPeer extends ReadyResource {
13
9
  ipc: any;
14
10
  spec: import("./index.js").Spec;
15
11
  framed: any;
16
12
  rpc: any;
13
+ /**
14
+ * @param {any} ipc Duplex IPC stream (e.g. a socket or pipe).
15
+ * @param {import('./index.js').Spec} spec Spec object exposing `rpc` and `schema`.
16
+ */
17
+ constructor(ipc: any, spec: import('./index.js').Spec);
18
+ _open(): Promise<void>;
19
+ _close(): Promise<void>;
17
20
  }
18
- import ReadyResource from 'ready-resource';
@@ -1,7 +1,7 @@
1
+ import { RPCPeer } from './peer.js';
1
2
  /**
2
3
  * Server-side RPC adapter — serves the spec's handlers over the framed IPC
3
4
  * stream. All wiring lives in {@link RPCPeer}; this is the server-named role.
4
5
  */
5
- export class RPCServer extends RPCPeer {
6
+ export declare class RPCServer extends RPCPeer {
6
7
  }
7
- import { RPCPeer } from './peer.js';
@@ -1,3 +1,49 @@
1
+ import ReadyResource from 'ready-resource';
2
+ export type StorageOpts = {
3
+ spec: {
4
+ database: any;
5
+ meta?: {
6
+ ns?: string;
7
+ refs?: Record<string, {
8
+ kind?: string;
9
+ }>;
10
+ };
11
+ };
12
+ backend: 'rocks' | 'bee';
13
+ /**
14
+ * Pre-existing HypercoreStorage to reuse.
15
+ */
16
+ root?: any;
17
+ /**
18
+ * Pre-existing Corestore to reuse.
19
+ */
20
+ store?: any;
21
+ /**
22
+ * 32-byte key encrypting the backing core at rest (bee backend only).
23
+ */
24
+ storageKey?: Uint8Array;
25
+ };
26
+ export type Ref = {
27
+ name: string;
28
+ kind: string;
29
+ };
30
+ export type StoredRow = {
31
+ id?: string;
32
+ createdAt: number;
33
+ updatedAt: number;
34
+ [k: string]: any;
35
+ };
36
+ export type SingleResult = {
37
+ data: any;
38
+ };
39
+ export type ListResult = {
40
+ data: any[];
41
+ total: number;
42
+ size: number;
43
+ };
44
+ export type GetByIdResult = {
45
+ data: any | null;
46
+ };
1
47
  /**
2
48
  * @typedef {object} StorageOpts
3
49
  * @property {{ database: any, meta?: { ns?: string, refs?: Record<string, { kind?: string }> } }} spec
@@ -17,26 +63,7 @@
17
63
  * Hyperbee on top of corestore (`bee`). Exposes the same `put/get/...`
18
64
  * surface as `Database` but without networking or multi-writer apply.
19
65
  */
20
- export class Storage extends ReadyResource {
21
- /**
22
- * Construct a RocksDB-backed Storage.
23
- *
24
- * @param {string} dir
25
- * @param {Omit<StorageOpts, 'backend'>} opts
26
- */
27
- static rocks(dir: string, opts: Omit<StorageOpts, "backend">): Storage;
28
- /**
29
- * Construct a Hyperbee-backed Storage.
30
- *
31
- * @param {string} dir
32
- * @param {Omit<StorageOpts, 'backend'>} opts
33
- */
34
- static bee(dir: string, opts: Omit<StorageOpts, "backend">): Storage;
35
- /**
36
- * @param {string} dir
37
- * @param {StorageOpts} [opts]
38
- */
39
- constructor(dir: string, { spec, backend, root, store, storageKey }?: StorageOpts);
66
+ export declare class Storage extends ReadyResource {
40
67
  dir: string;
41
68
  spec: {
42
69
  database: any;
@@ -47,7 +74,7 @@ export class Storage extends ReadyResource {
47
74
  }>;
48
75
  };
49
76
  };
50
- backend: "rocks" | "bee";
77
+ backend: "bee" | "rocks";
51
78
  storageKey: Uint8Array<ArrayBufferLike>;
52
79
  ns: string;
53
80
  refs: Record<string, {
@@ -59,6 +86,27 @@ export class Storage extends ReadyResource {
59
86
  root: any;
60
87
  store: any;
61
88
  db: any;
89
+ /**
90
+ * @param {string} dir
91
+ * @param {StorageOpts} [opts]
92
+ */
93
+ constructor(dir: string, { spec, backend, root, store, storageKey }?: StorageOpts);
94
+ /**
95
+ * Construct a RocksDB-backed Storage.
96
+ *
97
+ * @param {string} dir
98
+ * @param {Omit<StorageOpts, 'backend'>} opts
99
+ */
100
+ static rocks(dir: string, opts: Omit<StorageOpts, 'backend'>): Storage;
101
+ /**
102
+ * Construct a Hyperbee-backed Storage.
103
+ *
104
+ * @param {string} dir
105
+ * @param {Omit<StorageOpts, 'backend'>} opts
106
+ */
107
+ static bee(dir: string, opts: Omit<StorageOpts, 'backend'>): Storage;
108
+ _open(): Promise<void>;
109
+ _close(): Promise<void>;
62
110
  /**
63
111
  * Insert (or overwrite by id) a row, stamping `id`/`createdAt`/`updatedAt`.
64
112
  *
@@ -115,7 +163,7 @@ export class Storage extends ReadyResource {
115
163
  * @param {Record<string, any>} [query]
116
164
  * @returns {import('streamx').Readable}
117
165
  */
118
- watch(name: string, query?: Record<string, any>): import("streamx").Readable;
166
+ watch(name: string, query?: Record<string, any>): import('streamx').Readable;
119
167
  _guard(): void;
120
168
  /** @param {string} name @returns {Ref} */
121
169
  _ref(name: string): Ref;
@@ -126,49 +174,3 @@ export class Storage extends ReadyResource {
126
174
  /** @param {Ref} ref @param {Record<string, any>} row @returns {Promise<void>} */
127
175
  _write(ref: Ref, row: Record<string, any>): Promise<void>;
128
176
  }
129
- export type StorageOpts = {
130
- spec: {
131
- database: any;
132
- meta?: {
133
- ns?: string;
134
- refs?: Record<string, {
135
- kind?: string;
136
- }>;
137
- };
138
- };
139
- backend: "rocks" | "bee";
140
- /**
141
- * Pre-existing HypercoreStorage to reuse.
142
- */
143
- root?: any;
144
- /**
145
- * Pre-existing Corestore to reuse.
146
- */
147
- store?: any;
148
- /**
149
- * 32-byte key encrypting the backing core at rest (bee backend only).
150
- */
151
- storageKey?: Uint8Array;
152
- };
153
- export type Ref = {
154
- name: string;
155
- kind: string;
156
- };
157
- export type StoredRow = {
158
- id?: string;
159
- createdAt: number;
160
- updatedAt: number;
161
- [k: string]: any;
162
- };
163
- export type SingleResult = {
164
- data: any;
165
- };
166
- export type ListResult = {
167
- data: any[];
168
- total: number;
169
- size: number;
170
- };
171
- export type GetByIdResult = {
172
- data: any | null;
173
- };
174
- import ReadyResource from 'ready-resource';