@agoric/internal 0.3.3-other-dev-d15096d.0.d15096d → 0.3.3-other-dev-ecf44df.0.ecf44df
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 +32 -36
- package/src/action-types.d.ts +47 -20
- package/src/action-types.d.ts.map +1 -1
- package/src/action-types.js +21 -21
- package/src/ava-force-exit.d.mts +2 -0
- package/src/ava-force-exit.d.mts.map +1 -0
- package/src/ava-force-exit.mjs +7 -0
- package/src/batched-deliver.d.ts +2 -2
- package/src/batched-deliver.d.ts.map +1 -1
- package/src/batched-deliver.js +2 -3
- package/src/build-cache-types.d.ts +33 -0
- package/src/build-cache-types.d.ts.map +1 -0
- package/src/build-cache-types.js +42 -0
- package/src/build-cache.d.ts +12 -0
- package/src/build-cache.d.ts.map +1 -0
- package/src/build-cache.js +184 -0
- package/src/callback.d.ts +1 -1
- package/src/callback.d.ts.map +1 -1
- package/src/callback.js +1 -0
- package/src/chain-storage-paths.d.ts.map +1 -1
- package/src/chain-storage-paths.js +0 -2
- package/src/config.d.ts +3 -3
- package/src/config.d.ts.map +1 -1
- package/src/config.js +6 -5
- package/src/debug.d.ts +2 -2
- package/src/debug.d.ts.map +1 -1
- package/src/debug.js +19 -5
- package/src/hex.d.ts.map +1 -1
- package/src/hex.js +18 -22
- package/src/index.d.ts +1 -0
- package/src/index.js +1 -2
- package/src/js-utils.d.ts +17 -2
- package/src/js-utils.d.ts.map +1 -1
- package/src/js-utils.js +49 -3
- package/src/keyMirror.d.ts +3 -0
- package/src/keyMirror.d.ts.map +1 -0
- package/src/keyMirror.js +45 -0
- package/src/kv-store.d.ts +33 -0
- package/src/kv-store.d.ts.map +1 -0
- package/src/kv-store.js +265 -0
- package/src/lib-chainStorage.d.ts +25 -42
- package/src/lib-chainStorage.d.ts.map +1 -1
- package/src/lib-chainStorage.js +38 -14
- package/src/lib-nodejs/ava-unhandled-rejection.d.ts +18 -3
- package/src/lib-nodejs/ava-unhandled-rejection.d.ts.map +1 -1
- package/src/lib-nodejs/ava-unhandled-rejection.js +217 -20
- package/src/lib-nodejs/engine-gc.js +2 -2
- package/src/lib-nodejs/gc-and-finalize.d.ts +2 -1
- package/src/lib-nodejs/gc-and-finalize.d.ts.map +1 -1
- package/src/lib-nodejs/gc-and-finalize.js +1 -0
- package/src/lib-nodejs/spawnSubprocessWorker.d.ts +11 -4
- package/src/lib-nodejs/spawnSubprocessWorker.d.ts.map +1 -1
- package/src/lib-nodejs/spawnSubprocessWorker.js +14 -4
- package/src/lib-nodejs/worker-protocol.d.ts +1 -1
- package/src/lib-nodejs/worker-protocol.d.ts.map +1 -1
- package/src/lib-nodejs/worker-protocol.js +5 -6
- package/src/magic-cookie-test-only.d.ts.map +1 -1
- package/src/magic-cookie-test-only.js +0 -2
- package/src/marshal/board-client-utils.d.ts.map +1 -1
- package/src/marshal/board-client-utils.js +4 -1
- package/src/marshal/cap-data.d.ts +9 -1
- package/src/marshal/cap-data.d.ts.map +1 -1
- package/src/marshal/cap-data.js +1 -2
- package/src/marshal/wrap-marshaller.d.ts +34 -7
- package/src/marshal/wrap-marshaller.d.ts.map +1 -1
- package/src/marshal/wrap-marshaller.js +64 -68
- package/src/metrics.d.ts +1 -4
- package/src/metrics.d.ts.map +1 -1
- package/src/metrics.js +7 -2
- package/src/module-utils.d.ts +1 -0
- package/src/module-utils.d.ts.map +1 -1
- package/src/module-utils.js +17 -0
- package/src/natural-sort.d.ts.map +1 -1
- package/src/natural-sort.js +7 -3
- package/src/netstring.d.ts +1 -1
- package/src/netstring.d.ts.map +1 -1
- package/src/netstring.js +5 -6
- package/src/node/buffer-line-transform.d.ts.map +1 -1
- package/src/node/buffer-line-transform.js +0 -1
- package/src/node/createBundles.d.ts +7 -3
- package/src/node/createBundles.d.ts.map +1 -1
- package/src/node/createBundles.js +31 -10
- package/src/node/fs-stream.d.ts +8 -5
- package/src/node/fs-stream.d.ts.map +1 -1
- package/src/node/fs-stream.js +120 -8
- package/src/node/read-json.d.ts +2 -0
- package/src/node/read-json.d.ts.map +1 -0
- package/src/node/read-json.js +16 -0
- package/src/node/shutdown.d.ts +6 -2
- package/src/node/shutdown.d.ts.map +1 -1
- package/src/node/shutdown.js +9 -3
- package/src/priority-senders.d.ts.map +1 -1
- package/src/priority-senders.js +1 -0
- package/src/queue.d.ts.map +1 -1
- package/src/queue.js +10 -2
- package/src/scratch.d.ts +32 -10
- package/src/scratch.d.ts.map +1 -1
- package/src/scratch.js +11 -0
- package/src/ses-utils.d.ts +14 -3
- package/src/ses-utils.d.ts.map +1 -1
- package/src/ses-utils.js +13 -15
- package/src/storage-test-utils.d.ts +4 -11
- package/src/storage-test-utils.d.ts.map +1 -1
- package/src/storage-test-utils.js +16 -14
- package/src/tagged.d.ts +18 -1
- package/src/testing-utils.d.ts +22 -1
- package/src/testing-utils.d.ts.map +1 -1
- package/src/testing-utils.js +131 -6
- package/src/tmpDir.d.ts.map +1 -1
- package/src/tmpDir.js +1 -1
- package/src/typeCheck.d.ts +4 -8
- package/src/typeCheck.d.ts.map +1 -1
- package/src/typeCheck.js +13 -6
- package/src/typeGuards.d.ts +5 -5
- package/src/typeGuards.d.ts.map +1 -1
- package/src/typeGuards.js +4 -5
- package/src/types-index.d.ts +1 -0
- package/src/types.d.ts +41 -14
- package/src/types.d.ts.map +1 -1
- package/src/types.js +161 -0
- package/src/upgrade-api.d.ts +2 -2
- package/src/upgrade-api.d.ts.map +1 -1
- package/src/upgrade-api.js +4 -3
- package/src/work-pool.d.ts.map +1 -1
- package/src/work-pool.js +9 -2
- package/vendor/anylogger.d.ts +98 -0
- package/vendor/anylogger.d.ts.map +1 -0
- package/vendor/anylogger.js +60 -0
- package/vendor/anylogger.ts +160 -0
- package/vendor/tsconfig.anylogger.json +15 -0
- package/exported.js +0 -2
- package/src/types.ts +0 -133
package/src/kv-store.js
ADDED
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
import { Fail } from '@endo/errors';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @import {Database} from 'better-sqlite3';
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @template [T=string]
|
|
10
|
+
* @typedef {{
|
|
11
|
+
* has: (key: string) => boolean;
|
|
12
|
+
* get: (key: string) => T | undefined;
|
|
13
|
+
* getNextKey: (previousKey: string) => string | undefined;
|
|
14
|
+
* set: (key: string, value: T) => void;
|
|
15
|
+
* delete: (key: string) => void;
|
|
16
|
+
* }} KVStore
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @param {Database} db The SQLite database connection.
|
|
21
|
+
* @param {() => void} beforeMutation Called before mutating methods to
|
|
22
|
+
* establish a DB transaction if needed
|
|
23
|
+
* @param {(...args: string[]) => void} trace Called after set/delete to record
|
|
24
|
+
* a debug log
|
|
25
|
+
* @returns {KVStore}
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
export function makeKVStore(db, beforeMutation, trace) {
|
|
29
|
+
db.exec(`
|
|
30
|
+
CREATE TABLE IF NOT EXISTS kvStore (
|
|
31
|
+
key TEXT,
|
|
32
|
+
value TEXT,
|
|
33
|
+
PRIMARY KEY (key)
|
|
34
|
+
)
|
|
35
|
+
`);
|
|
36
|
+
|
|
37
|
+
const sqlKVGet = db.prepare(`
|
|
38
|
+
SELECT value
|
|
39
|
+
FROM kvStore
|
|
40
|
+
WHERE key = ?
|
|
41
|
+
`);
|
|
42
|
+
sqlKVGet.pluck(true);
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Obtain the value stored for a given key.
|
|
46
|
+
*
|
|
47
|
+
* @param {string} key The key whose value is sought.
|
|
48
|
+
* @returns {string | undefined} the (string) value for the given key, or
|
|
49
|
+
* undefined if there is no such value.
|
|
50
|
+
* @throws if key is not a string.
|
|
51
|
+
*/
|
|
52
|
+
function get(key) {
|
|
53
|
+
typeof key === 'string' || Fail`key must be a string`;
|
|
54
|
+
return /** @type {string | undefined} */ (sqlKVGet.get(key));
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const sqlKVGetNextKey = db.prepare(`
|
|
58
|
+
SELECT key
|
|
59
|
+
FROM kvStore
|
|
60
|
+
WHERE key > ?
|
|
61
|
+
LIMIT 1
|
|
62
|
+
`);
|
|
63
|
+
sqlKVGetNextKey.pluck(true);
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* getNextKey enables callers to iterate over all keys within a given range.
|
|
67
|
+
* To build an iterator of all keys from start (inclusive) to end (exclusive),
|
|
68
|
+
* do:
|
|
69
|
+
*
|
|
70
|
+
* ```js
|
|
71
|
+
* function* iterate(start, end) {
|
|
72
|
+
* if (kvStore.has(start)) {
|
|
73
|
+
* yield start;
|
|
74
|
+
* }
|
|
75
|
+
* let prev = start;
|
|
76
|
+
* while (true) {
|
|
77
|
+
* let next = kvStore.getNextKey(prev);
|
|
78
|
+
* if (!next || next >= end) {
|
|
79
|
+
* break;
|
|
80
|
+
* }
|
|
81
|
+
* yield next;
|
|
82
|
+
* prev = next;
|
|
83
|
+
* }
|
|
84
|
+
* }
|
|
85
|
+
* ```
|
|
86
|
+
*
|
|
87
|
+
* @param {string} previousKey The key returned will always be later than this
|
|
88
|
+
* one.
|
|
89
|
+
* @returns {string | undefined} a key string, or undefined if we reach the
|
|
90
|
+
* end of the store
|
|
91
|
+
* @throws if previousKey is not a string
|
|
92
|
+
*/
|
|
93
|
+
|
|
94
|
+
function getNextKey(previousKey) {
|
|
95
|
+
typeof previousKey === 'string' || Fail`previousKey must be a string`;
|
|
96
|
+
return /** @type {string | undefined} */ (sqlKVGetNextKey.get(previousKey));
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Test if the state contains a value for a given key.
|
|
101
|
+
*
|
|
102
|
+
* @param {string} key The key that is of interest.
|
|
103
|
+
* @returns {boolean} true if a value is stored for the key, false if not.
|
|
104
|
+
* @throws if key is not a string.
|
|
105
|
+
*/
|
|
106
|
+
function has(key) {
|
|
107
|
+
typeof key === 'string' || Fail`key must be a string`;
|
|
108
|
+
return get(key) !== undefined;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const sqlKVSet = db.prepare(`
|
|
112
|
+
INSERT INTO kvStore (key, value)
|
|
113
|
+
VALUES (?, ?)
|
|
114
|
+
ON CONFLICT DO UPDATE SET value = excluded.value
|
|
115
|
+
`);
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Store a value for a given key. The value will replace any prior value if
|
|
119
|
+
* there was one.
|
|
120
|
+
*
|
|
121
|
+
* @param {string} key The key whose value is being set.
|
|
122
|
+
* @param {string} value The value to set the key to.
|
|
123
|
+
* @throws if either parameter is not a string.
|
|
124
|
+
*/
|
|
125
|
+
function set(key, value) {
|
|
126
|
+
typeof key === 'string' || Fail`key must be a string`;
|
|
127
|
+
typeof value === 'string' || Fail`value must be a string`;
|
|
128
|
+
// synchronous read after write within a transaction is safe
|
|
129
|
+
// The transaction's overall success will be awaited during commit
|
|
130
|
+
beforeMutation();
|
|
131
|
+
sqlKVSet.run(key, value);
|
|
132
|
+
trace('set', key, value);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const sqlKVDel = db.prepare(`
|
|
136
|
+
DELETE FROM kvStore
|
|
137
|
+
WHERE key = ?
|
|
138
|
+
`);
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Remove any stored value for a given key. It is permissible for there to be
|
|
142
|
+
* no existing stored value for the key.
|
|
143
|
+
*
|
|
144
|
+
* @param {string} key The key whose value is to be deleted
|
|
145
|
+
* @throws if key is not a string.
|
|
146
|
+
*/
|
|
147
|
+
function del(key) {
|
|
148
|
+
typeof key === 'string' || Fail`key must be a string`;
|
|
149
|
+
beforeMutation();
|
|
150
|
+
sqlKVDel.run(key);
|
|
151
|
+
trace('del', key);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const kvStore = {
|
|
155
|
+
has,
|
|
156
|
+
get,
|
|
157
|
+
getNextKey,
|
|
158
|
+
set,
|
|
159
|
+
delete: del,
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
return kvStore;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// TODO: Replace compareByCodePoints and makeKVStoreFromMap and
|
|
166
|
+
// provideEnhancedKVStore with imports when
|
|
167
|
+
// available.
|
|
168
|
+
// https://github.com/Agoric/agoric-sdk/pull/10299
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* @param {string} left
|
|
172
|
+
* @param {string} right
|
|
173
|
+
*/
|
|
174
|
+
export const compareByCodePoints = (left, right) => {
|
|
175
|
+
const leftIter = left[Symbol.iterator]();
|
|
176
|
+
const rightIter = right[Symbol.iterator]();
|
|
177
|
+
for (;;) {
|
|
178
|
+
const { value: leftChar } = leftIter.next();
|
|
179
|
+
const { value: rightChar } = rightIter.next();
|
|
180
|
+
if (leftChar === undefined && rightChar === undefined) {
|
|
181
|
+
return 0;
|
|
182
|
+
} else if (leftChar === undefined) {
|
|
183
|
+
// left is a prefix of right.
|
|
184
|
+
return -1;
|
|
185
|
+
} else if (rightChar === undefined) {
|
|
186
|
+
// right is a prefix of left.
|
|
187
|
+
return 1;
|
|
188
|
+
}
|
|
189
|
+
const leftCodepoint = /** @type {number} */ (leftChar.codePointAt(0));
|
|
190
|
+
const rightCodepoint = /** @type {number} */ (rightChar.codePointAt(0));
|
|
191
|
+
if (leftCodepoint < rightCodepoint) return -1;
|
|
192
|
+
if (leftCodepoint > rightCodepoint) return 1;
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* @template [T=unknown]
|
|
198
|
+
* @param {Map<string, T>} map
|
|
199
|
+
* @returns {KVStore<T>}
|
|
200
|
+
*/
|
|
201
|
+
export const makeKVStoreFromMap = map => {
|
|
202
|
+
/** @type {string[] | undefined} */
|
|
203
|
+
let sortedKeys;
|
|
204
|
+
/** @type {string | undefined} */
|
|
205
|
+
let priorKeyReturned;
|
|
206
|
+
/** @type {number} */
|
|
207
|
+
let priorKeyIndex;
|
|
208
|
+
|
|
209
|
+
const ensureSorted = () => {
|
|
210
|
+
if (sortedKeys) return;
|
|
211
|
+
sortedKeys = [...map.keys()].sort(compareByCodePoints);
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
const clearGetNextKeyCache = () => {
|
|
215
|
+
priorKeyReturned = undefined;
|
|
216
|
+
priorKeyIndex = -1;
|
|
217
|
+
};
|
|
218
|
+
clearGetNextKeyCache();
|
|
219
|
+
|
|
220
|
+
const clearSorted = () => {
|
|
221
|
+
sortedKeys = undefined;
|
|
222
|
+
clearGetNextKeyCache();
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
/** @type {KVStore<T>} */
|
|
226
|
+
const fakeStore = harden({
|
|
227
|
+
has: key => map.has(key),
|
|
228
|
+
get: key => map.get(key),
|
|
229
|
+
getNextKey: priorKey => {
|
|
230
|
+
assert.typeof(priorKey, 'string');
|
|
231
|
+
ensureSorted();
|
|
232
|
+
assert(sortedKeys, 'sortedKeys should be defined after ensureSorted');
|
|
233
|
+
const start =
|
|
234
|
+
priorKeyReturned === undefined
|
|
235
|
+
? 0
|
|
236
|
+
: // If priorKeyReturned <= priorKey, start just after it.
|
|
237
|
+
(compareByCodePoints(priorKeyReturned, priorKey) <= 0 &&
|
|
238
|
+
priorKeyIndex + 1) ||
|
|
239
|
+
// Else if priorKeyReturned immediately follows priorKey, start at
|
|
240
|
+
// its index (and expect to return it again).
|
|
241
|
+
(sortedKeys.at(priorKeyIndex - 1) === priorKey && priorKeyIndex) ||
|
|
242
|
+
// Otherwise, start at the beginning.
|
|
243
|
+
0;
|
|
244
|
+
for (let i = start; i < sortedKeys.length; i += 1) {
|
|
245
|
+
const key = sortedKeys[i];
|
|
246
|
+
if (compareByCodePoints(key, priorKey) <= 0) continue;
|
|
247
|
+
priorKeyReturned = key;
|
|
248
|
+
priorKeyIndex = i;
|
|
249
|
+
return key;
|
|
250
|
+
}
|
|
251
|
+
// reached end without finding the key, so clear our cache
|
|
252
|
+
clearGetNextKeyCache();
|
|
253
|
+
return undefined;
|
|
254
|
+
},
|
|
255
|
+
set: (key, value) => {
|
|
256
|
+
if (!map.has(key)) clearSorted();
|
|
257
|
+
map.set(key, value);
|
|
258
|
+
},
|
|
259
|
+
delete: key => {
|
|
260
|
+
if (map.has(key)) clearSorted();
|
|
261
|
+
map.delete(key);
|
|
262
|
+
},
|
|
263
|
+
});
|
|
264
|
+
return fakeStore;
|
|
265
|
+
};
|
|
@@ -10,17 +10,11 @@
|
|
|
10
10
|
* @param {boolean} [rootOptions.sequence] employ a wrapping structure that
|
|
11
11
|
* preserves each value set within a single block, and default child nodes to
|
|
12
12
|
* do the same
|
|
13
|
+
* @returns {StorageNode}
|
|
13
14
|
*/
|
|
14
15
|
export function makeChainStorageRoot(handleStorageMessage: (message: StorageMessage) => any, rootPath: string, rootOptions?: {
|
|
15
16
|
sequence?: boolean | undefined;
|
|
16
|
-
}):
|
|
17
|
-
getPath(): string;
|
|
18
|
-
getStoreKey(): Promise<VStorageKey>;
|
|
19
|
-
makeChildNode(name: string, childNodeOptions?: {
|
|
20
|
-
sequence?: boolean;
|
|
21
|
-
}): StorageNode;
|
|
22
|
-
setValue(value: string): Promise<void>;
|
|
23
|
-
}>;
|
|
17
|
+
}): StorageNode;
|
|
24
18
|
/**
|
|
25
19
|
* Convenience function for returning a storage node at or under its input,
|
|
26
20
|
* falling back to an inert object with the correct interface (but incomplete
|
|
@@ -32,22 +26,28 @@ export function makeChainStorageRoot(handleStorageMessage: (message: StorageMess
|
|
|
32
26
|
*/
|
|
33
27
|
export function makeStorageNodeChild(storageNodeRef: ERef<Remote<StorageNode> | null>, childName: string): Promise<Remote<StorageNode>>;
|
|
34
28
|
/**
|
|
29
|
+
* @import {RemotableBrand} from '@endo/eventual-send';
|
|
35
30
|
* @import {ERef} from '@endo/far';
|
|
36
31
|
* @import {Marshal, Passable} from '@endo/marshal';
|
|
37
|
-
* @import {Remote, ERemote
|
|
32
|
+
* @import {Remote, ERemote} from './types.js';
|
|
38
33
|
* @import {EMarshaller} from './marshal/wrap-marshaller.js';
|
|
39
34
|
* @import {Zone} from '@agoric/base-zone';
|
|
40
35
|
* @import {Callback} from './types.js';
|
|
36
|
+
* @import {CastedPattern} from '@endo/patterns';
|
|
37
|
+
* @import {MatcherOf} from '@endo/patterns';
|
|
41
38
|
*/
|
|
42
39
|
/** @typedef {Marshal<unknown>} Marshaller */
|
|
43
40
|
/** @typedef {Pick<Marshaller, 'fromCapData'>} Unserializer */
|
|
44
41
|
/**
|
|
45
42
|
* Defined by vstorageStoreKey in vstorage.go
|
|
46
43
|
*
|
|
44
|
+
* The backend provides all properties but for mock data flexibility we allow
|
|
45
|
+
* some to be optional in the JS typedef.
|
|
46
|
+
*
|
|
47
47
|
* @typedef VStorageKey
|
|
48
48
|
* @property {string} storeName
|
|
49
49
|
* @property {string} storeSubkey
|
|
50
|
-
* @property {string} dataPrefixBytes
|
|
50
|
+
* @property {string} [dataPrefixBytes]
|
|
51
51
|
* @property {string} [noDataValue]
|
|
52
52
|
*/
|
|
53
53
|
/**
|
|
@@ -57,31 +57,27 @@ export function makeStorageNodeChild(storageNodeRef: ERef<Remote<StorageNode> |
|
|
|
57
57
|
* (decimal representation of a natural number)
|
|
58
58
|
* @property {T[]} values
|
|
59
59
|
*/
|
|
60
|
-
/** @type {
|
|
61
|
-
export const StreamCellShape:
|
|
60
|
+
/** @type {CastedPattern<StreamCell>} */
|
|
61
|
+
export const StreamCellShape: CastedPattern<StreamCell>;
|
|
62
62
|
export function isStreamCell(cell: any): cell is StreamCell;
|
|
63
63
|
/** @type {(name: string) => void} */
|
|
64
64
|
export const assertPathSegment: (name: string) => void;
|
|
65
|
-
export function prepareChainStorageNode(zone: Zone): (messenger: Callback<(message: StorageMessage) => any>, path: string,
|
|
66
|
-
sequence?: boolean
|
|
67
|
-
}
|
|
68
|
-
getPath(): string;
|
|
69
|
-
getStoreKey(): Promise<VStorageKey>;
|
|
70
|
-
makeChildNode(name: string, childNodeOptions?: {
|
|
71
|
-
sequence?: boolean;
|
|
72
|
-
}): StorageNode;
|
|
73
|
-
setValue(value: string): Promise<void>;
|
|
74
|
-
}>;
|
|
65
|
+
export function prepareChainStorageNode(zone: Zone): (messenger: Callback<(message: StorageMessage) => any>, path: string, options?: {
|
|
66
|
+
sequence?: boolean;
|
|
67
|
+
}) => StorageNode;
|
|
75
68
|
export function makeSerializeToStorage(storageNode: ERemote<StorageNode>, marshaller: ERemote<EMarshaller>): (value: Passable) => Promise<void>;
|
|
76
69
|
export type Marshaller = Marshal<unknown>;
|
|
77
70
|
export type Unserializer = Pick<Marshaller, "fromCapData">;
|
|
78
71
|
/**
|
|
79
72
|
* Defined by vstorageStoreKey in vstorage.go
|
|
73
|
+
*
|
|
74
|
+
* The backend provides all properties but for mock data flexibility we allow
|
|
75
|
+
* some to be optional in the JS typedef.
|
|
80
76
|
*/
|
|
81
77
|
export type VStorageKey = {
|
|
82
78
|
storeName: string;
|
|
83
79
|
storeSubkey: string;
|
|
84
|
-
dataPrefixBytes
|
|
80
|
+
dataPrefixBytes?: string | undefined;
|
|
85
81
|
noDataValue?: string | undefined;
|
|
86
82
|
};
|
|
87
83
|
export type StreamCell<T = unknown> = {
|
|
@@ -101,25 +97,12 @@ export type StreamCell<T = unknown> = {
|
|
|
101
97
|
* Vstorage is a hierarchical externally-reachable storage structure that
|
|
102
98
|
* identifies children by restricted ASCII name and is associated with arbitrary
|
|
103
99
|
* string-valued data for each node, defaulting to the empty string.
|
|
100
|
+
*
|
|
101
|
+
* Defined as an interface in ./types.ts so its per-property documentation
|
|
102
|
+
* survives declaration emit. Re-exported here as an alias so existing
|
|
103
|
+
* `from '@agoric/internal/src/lib-chainStorage.js'` importers keep working.
|
|
104
104
|
*/
|
|
105
|
-
export type StorageNode =
|
|
106
|
-
/**
|
|
107
|
-
* publishes some data
|
|
108
|
-
*/
|
|
109
|
-
setValue: (data: string) => Promise<void>;
|
|
110
|
-
/**
|
|
111
|
-
* the chain storage path at which the node was
|
|
112
|
-
* constructed
|
|
113
|
-
*/
|
|
114
|
-
getPath: () => string;
|
|
115
|
-
/**
|
|
116
|
-
* DEPRECATED use getPath
|
|
117
|
-
*/
|
|
118
|
-
getStoreKey: () => Promise<VStorageKey>;
|
|
119
|
-
makeChildNode: (subPath: string, options?: {
|
|
120
|
-
sequence?: boolean;
|
|
121
|
-
}) => StorageNode;
|
|
122
|
-
};
|
|
105
|
+
export type StorageNode = import("./types.js").StorageNode;
|
|
123
106
|
export type StoredFacet = {
|
|
124
107
|
/**
|
|
125
108
|
* the chain storage path at which the
|
|
@@ -172,7 +155,7 @@ export type StorageMessage = {
|
|
|
172
155
|
};
|
|
173
156
|
import type { Remote } from './types.js';
|
|
174
157
|
import type { ERef } from '@endo/far';
|
|
175
|
-
import type {
|
|
158
|
+
import type { CastedPattern } from '@endo/patterns';
|
|
176
159
|
import type { Zone } from '@agoric/base-zone';
|
|
177
160
|
import type { Callback } from './types.js';
|
|
178
161
|
import type { ERemote } from './types.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lib-chainStorage.d.ts","sourceRoot":"","sources":["lib-chainStorage.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"lib-chainStorage.d.ts","sourceRoot":"","sources":["lib-chainStorage.js"],"names":[],"mappings":"AAwQA;;;;;;;;;;;;;GAaG;AACH,2DAVW,CAAC,OAAO,EAAE,cAAc,KAAK,GAAG,YAGhC,MAAM,gBAEd;IAA8B,QAAQ;CAGtC,GAAU,WAAW,CAYvB;AAcD;;;;;;;;GAQG;AACH,qDAJW,KAAK,OAAO,WAAW,CAAC,GAAG,IAAI,CAAC,aAChC,MAAM,GACJ,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,CAMxC;AAnTD;;;;;;;;;;GAUG;AAEH,6CAA6C;AAC7C,8DAA8D;AAE9D;;;;;;;;;;;GAWG;AAEH;;;;;;GAMG;AAEH,wCAAwC;AACxC,8BADW,cAAc,UAAU,CAAC,CAIjC;AAoDI,mCAHI,GAAG,GACD,IAAI,IAAI,UAAU,CAOa;AAmB5C,qCAAqC;AACrC,gCADW,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAI/B;AA8CK,8CAPI,IAAI,GACF,CACR,SAAS,EAAE,SAAS,CAAC,OAAO,EAAE,cAAc,KAAK,GAAG,CAAC,EACrD,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,KAC7B,WAAW,CAwFlB;AAgEM,oDAJI,QAAQ,WAAW,CAAC,cACpB,QAAQ,WAAW,CAAC,GAClB,CAAC,KAAK,EAAE,QAAQ,KAAK,OAAO,CAAC,IAAI,CAAC,CAQ9C;yBAtTa,QAAQ,OAAO,CAAC;2BAChB,IAAI,CAAC,UAAU,EAAE,aAAa,CAAC;;;;;;;;eAS/B,MAAM;iBACN,MAAM;;;;uBAMN,CAAC;;;;;iBAED,MAAM;YAEN,CAAC,EAAE;;;;;;;;;;;;;;;;0BAwBJ,OAAO,YAAY,EAAE,WAAW;;;;;;aA6C/B,MAAM,OAAO,CAAC,MAAM,CAAC;;;;iBAErB,WAAW,CAAC,aAAa,CAAC;;;;;qBAC1B,MAAM,YAAY;;;;;4CAqBnB,KAAK,GACX,aAAa,GACb,KAAK,GACL,UAAU,GACV,SAAS,GACT,QAAQ,GACR,MAAM;;;;gDAGA,KAAK,GAAG,kBAAkB,GAAG,QAAQ;;;;mCAGrC,6BAA6B,GACnC,iCAAiC;;;;0CAG3B,CAAC,IAAI,EAAE,MAAM,CAAC;;;;2BAEd,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;;;;8CAErC,YAAY,EAAE;;;;6BAEd;IACJ,MAAM,EAAE,6BAA6B,CAAC;IACtC,IAAI,EAAE,2BAA2B,CAAC;CACnC,GACD;IACE,MAAM,EAAE,iCAAiC,CAAC;IAC1C,IAAI,EAAE,+BAA+B,CAAC;CACvC;4BAvJ0B,YAAY;0BAFvB,WAAW;mCAMF,gBAAgB;0BAFzB,mBAAmB;8BACf,YAAY;6BAHL,YAAY;iCAChB,8BAA8B;8BAFxB,eAAe;6BAAf,eAAe"}
|
package/src/lib-chainStorage.js
CHANGED
|
@@ -7,12 +7,15 @@ import { makeHeapZone } from '@agoric/base-zone/heap.js';
|
|
|
7
7
|
import * as cb from './callback.js';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
+
* @import {RemotableBrand} from '@endo/eventual-send';
|
|
10
11
|
* @import {ERef} from '@endo/far';
|
|
11
12
|
* @import {Marshal, Passable} from '@endo/marshal';
|
|
12
|
-
* @import {Remote, ERemote
|
|
13
|
+
* @import {Remote, ERemote} from './types.js';
|
|
13
14
|
* @import {EMarshaller} from './marshal/wrap-marshaller.js';
|
|
14
15
|
* @import {Zone} from '@agoric/base-zone';
|
|
15
16
|
* @import {Callback} from './types.js';
|
|
17
|
+
* @import {CastedPattern} from '@endo/patterns';
|
|
18
|
+
* @import {MatcherOf} from '@endo/patterns';
|
|
16
19
|
*/
|
|
17
20
|
|
|
18
21
|
/** @typedef {Marshal<unknown>} Marshaller */
|
|
@@ -21,10 +24,13 @@ import * as cb from './callback.js';
|
|
|
21
24
|
/**
|
|
22
25
|
* Defined by vstorageStoreKey in vstorage.go
|
|
23
26
|
*
|
|
27
|
+
* The backend provides all properties but for mock data flexibility we allow
|
|
28
|
+
* some to be optional in the JS typedef.
|
|
29
|
+
*
|
|
24
30
|
* @typedef VStorageKey
|
|
25
31
|
* @property {string} storeName
|
|
26
32
|
* @property {string} storeSubkey
|
|
27
|
-
* @property {string} dataPrefixBytes
|
|
33
|
+
* @property {string} [dataPrefixBytes]
|
|
28
34
|
* @property {string} [noDataValue]
|
|
29
35
|
*/
|
|
30
36
|
|
|
@@ -36,12 +42,13 @@ import * as cb from './callback.js';
|
|
|
36
42
|
* @property {T[]} values
|
|
37
43
|
*/
|
|
38
44
|
|
|
39
|
-
/** @type {
|
|
45
|
+
/** @type {CastedPattern<StreamCell>} */
|
|
40
46
|
export const StreamCellShape = harden({
|
|
41
47
|
blockHeight: M.string(),
|
|
42
48
|
values: M.array(),
|
|
43
49
|
});
|
|
44
50
|
|
|
51
|
+
// eslint-disable-next-line @agoric/group-jsdoc-imports, @agoric/no-typedef-import -- top level import would conflict
|
|
45
52
|
/**
|
|
46
53
|
* This represents a node in an IAVL tree.
|
|
47
54
|
*
|
|
@@ -52,24 +59,35 @@ export const StreamCellShape = harden({
|
|
|
52
59
|
* identifies children by restricted ASCII name and is associated with arbitrary
|
|
53
60
|
* string-valued data for each node, defaulting to the empty string.
|
|
54
61
|
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
* @
|
|
58
|
-
*
|
|
59
|
-
* @
|
|
60
|
-
* @property {(
|
|
61
|
-
* subPath: string,
|
|
62
|
-
* options?: { sequence?: boolean },
|
|
63
|
-
* ) => StorageNode} makeChildNode
|
|
62
|
+
* Defined as an interface in ./types.ts so its per-property documentation
|
|
63
|
+
* survives declaration emit. Re-exported here as an alias so existing
|
|
64
|
+
* `from '@agoric/internal/src/lib-chainStorage.js'` importers keep working.
|
|
65
|
+
*
|
|
66
|
+
* @typedef {import('./types.js').StorageNode} StorageNode
|
|
64
67
|
*/
|
|
65
68
|
|
|
66
69
|
const ChainStorageNodeI = M.interface('StorageNode', {
|
|
67
70
|
setValue: M.callWhen(M.string()).returns(),
|
|
68
71
|
getPath: M.call().returns(M.string()),
|
|
69
|
-
getStoreKey: M.callWhen().returns(
|
|
72
|
+
getStoreKey: M.callWhen().returns(
|
|
73
|
+
M.splitRecord(
|
|
74
|
+
{
|
|
75
|
+
storeName: M.string(),
|
|
76
|
+
storeSubkey: M.string(),
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
dataPrefixBytes: M.string(),
|
|
80
|
+
noDataValue: M.string(),
|
|
81
|
+
},
|
|
82
|
+
),
|
|
83
|
+
),
|
|
70
84
|
makeChildNode: M.call(M.string())
|
|
71
85
|
.optional(M.splitRecord({}, { sequence: M.boolean() }, {}))
|
|
72
|
-
.returns(
|
|
86
|
+
.returns(
|
|
87
|
+
/** @type {MatcherOf<'remotable', StorageNode>} */ (
|
|
88
|
+
M.remotable('StorageNode')
|
|
89
|
+
),
|
|
90
|
+
),
|
|
73
91
|
});
|
|
74
92
|
|
|
75
93
|
/**
|
|
@@ -148,6 +166,11 @@ harden(assertPathSegment);
|
|
|
148
166
|
|
|
149
167
|
/**
|
|
150
168
|
* @param {Zone} zone
|
|
169
|
+
* @returns {(
|
|
170
|
+
* messenger: Callback<(message: StorageMessage) => any>,
|
|
171
|
+
* path: string,
|
|
172
|
+
* options?: { sequence?: boolean },
|
|
173
|
+
* ) => StorageNode}
|
|
151
174
|
*/
|
|
152
175
|
export const prepareChainStorageNode = zone => {
|
|
153
176
|
/**
|
|
@@ -251,6 +274,7 @@ const makeHeapChainStorageNode = prepareChainStorageNode(makeHeapZone());
|
|
|
251
274
|
* @param {boolean} [rootOptions.sequence] employ a wrapping structure that
|
|
252
275
|
* preserves each value set within a single block, and default child nodes to
|
|
253
276
|
* do the same
|
|
277
|
+
* @returns {StorageNode}
|
|
254
278
|
*/
|
|
255
279
|
export function makeChainStorageRoot(
|
|
256
280
|
handleStorageMessage,
|
|
@@ -1,12 +1,27 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @import {ExecutionContext, Macro, TestFn} from 'ava';
|
|
2
|
+
* @import {ExecutionContext, ImplementationFn, Macro, MacroDeclarationOptions,TestFn} from 'ava';
|
|
3
3
|
*/
|
|
4
|
+
/** Not an official AVA feature, so prefix with `AGORIC_` */
|
|
5
|
+
export const AGORIC_AVA_EXPECT_UNHANDLED_REJECTIONS: "AGORIC_AVA_EXPECT_UNHANDLED_REJECTIONS";
|
|
6
|
+
/** Backwards compatibility... */
|
|
4
7
|
export const AVA_EXPECT_UNHANDLED_REJECTIONS: "AGORIC_AVA_EXPECT_UNHANDLED_REJECTIONS";
|
|
5
|
-
export
|
|
6
|
-
|
|
8
|
+
export function countUnhandled(work: () => any | Promise<any>, { gcAndFinalize }: {
|
|
9
|
+
gcAndFinalize: () => Promise<void>;
|
|
10
|
+
}): Promise<{
|
|
11
|
+
unhandled: number;
|
|
12
|
+
pending: number;
|
|
13
|
+
seenUnhandled: number;
|
|
14
|
+
}>;
|
|
15
|
+
export function makeExpectUnhandledRejection<C>({ test, sameWorker, importMetaUrl, }: {
|
|
7
16
|
test: TestFn<C>;
|
|
17
|
+
sameWorker?: boolean | undefined;
|
|
8
18
|
importMetaUrl: string;
|
|
9
19
|
}): (expectedUnhandled: number) => Macro<[name: string, impl: (t: ExecutionContext<C>) => any], C>;
|
|
20
|
+
export function makeExpectUnhandledRejectionMacro<C = unknown>({ test, sameWorker, importMetaUrl, }: {
|
|
21
|
+
test: TestFn<C>;
|
|
22
|
+
sameWorker?: boolean | undefined;
|
|
23
|
+
importMetaUrl: string;
|
|
24
|
+
}): (numUnhandled: number, innerMacro?: Macro<A, C>) => Macro<A, C>;
|
|
10
25
|
import type { TestFn } from 'ava';
|
|
11
26
|
import type { ExecutionContext } from 'ava';
|
|
12
27
|
import type { Macro } from 'ava';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ava-unhandled-rejection.d.ts","sourceRoot":"","sources":["ava-unhandled-rejection.js"],"names":[],"mappings":"AAOA;;GAEG;AAEH,
|
|
1
|
+
{"version":3,"file":"ava-unhandled-rejection.d.ts","sourceRoot":"","sources":["ava-unhandled-rejection.js"],"names":[],"mappings":"AAOA;;GAEG;AAEH,4DAA4D;AAC5D,qDACE,wCAAwC,CAAC;AAC3C,iCAAiC;AACjC,uFACyC;AAkFlC,qCAJI,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,qBAEhC;IAAoC,aAAa,EAAzC,MAAM,OAAO,CAAC,IAAI,CAAC;CAC7B;;;;GA4BA;AAeM,6CARM,CAAC,wCAEX;IAA0B,IAAI,EAAtB,OAAO,CAAC,CAAC;IACQ,UAAU;IACZ,aAAa,EAA5B,MAAM;CACd,GAAU,CAAE,iBAAiB,EAAE,MAAM,KAAK,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,EACzE,iBAAqB,CAAC,CAAC,KAAK,GAAG,CAAC,EAAE,CAAC,CAAC,CAkEpC;AASM,kDANO,CAAC,kDAEZ;IAA0B,IAAI,EAAtB,OAAO,CAAC,CAAC;IACQ,UAAU;IACZ,aAAa,EAA5B,MAAM;CAChB,IAiBS,cAJG,MAIS,EAAE,aAHX,MAAM,CAAC,EAAE,CAAC,CAGW,KAFnB,MAAM,CAAC,EAAE,CAAC,CAAC,CAmCzB;4BA9P2F,KAAK;sCAAL,KAAK;2BAAL,KAAK"}
|