@agoric/internal 0.4.0 → 0.4.1-upgrade-23-dev-bd79330.0.bd79330
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 +1 -4
- package/package.json +13 -11
- package/src/action-types.d.ts +47 -20
- package/src/action-types.d.ts.map +1 -1
- package/src/action-types.js +19 -19
- 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 +6 -0
- package/src/batched-deliver.d.ts +6 -2
- package/src/batched-deliver.d.ts.map +1 -1
- package/src/batched-deliver.js +7 -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 +9 -11
- package/src/callback.d.ts.map +1 -1
- package/src/callback.js +16 -10
- package/src/chain-storage-paths.d.ts.map +1 -1
- package/src/chain-storage-paths.js +0 -2
- package/src/chain-utils.d.ts +3 -1
- package/src/chain-utils.d.ts.map +1 -1
- package/src/chain-utils.js +6 -1
- package/src/config.d.ts +22 -3
- package/src/config.d.ts.map +1 -1
- package/src/config.js +25 -3
- package/src/debug.d.ts +4 -1
- package/src/debug.d.ts.map +1 -1
- package/src/debug.js +26 -15
- package/src/index.d.ts +2 -1
- package/src/index.js +10 -3
- package/src/js-utils.d.ts +7 -3
- package/src/js-utils.d.ts.map +1 -1
- package/src/js-utils.js +24 -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 +257 -0
- package/src/lib-chainStorage.d.ts +23 -12
- package/src/lib-chainStorage.d.ts.map +1 -1
- package/src/lib-chainStorage.js +18 -18
- 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 +211 -20
- package/src/lib-nodejs/engine-gc.js +2 -2
- package/src/lib-nodejs/spawnSubprocessWorker.d.ts +0 -2
- package/src/lib-nodejs/spawnSubprocessWorker.d.ts.map +1 -1
- package/src/lib-nodejs/spawnSubprocessWorker.js +8 -7
- package/src/lib-nodejs/waitUntilQuiescent.d.ts +3 -0
- package/src/lib-nodejs/waitUntilQuiescent.d.ts.map +1 -1
- package/src/lib-nodejs/waitUntilQuiescent.js +5 -1
- 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 -5
- 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 +19 -0
- package/src/marshal/board-client-utils.d.ts.map +1 -0
- package/src/{marshal.js → marshal/board-client-utils.js} +27 -52
- package/src/marshal/cap-data.d.ts +11 -0
- package/src/marshal/cap-data.d.ts.map +1 -0
- package/src/marshal/cap-data.js +19 -0
- package/src/marshal/inaccessible-val.d.ts +2 -0
- package/src/marshal/inaccessible-val.d.ts.map +1 -0
- package/src/marshal/inaccessible-val.js +15 -0
- package/src/marshal/pure-data.d.ts +8 -0
- package/src/marshal/pure-data.d.ts.map +1 -0
- package/src/marshal/pure-data.js +14 -0
- package/src/marshal/wrap-marshaller.d.ts +60 -0
- package/src/marshal/wrap-marshaller.d.ts.map +1 -0
- package/src/marshal/wrap-marshaller.js +432 -0
- package/src/module-utils.d.ts +1 -0
- package/src/module-utils.d.ts.map +1 -1
- package/src/module-utils.js +16 -0
- package/src/natural-sort.d.ts.map +1 -1
- package/src/natural-sort.js +48 -13
- package/src/netstring.d.ts +1 -1
- package/src/netstring.d.ts.map +1 -1
- package/src/netstring.js +5 -5
- package/src/node/buffer-line-transform.d.ts +10 -5
- package/src/node/buffer-line-transform.d.ts.map +1 -1
- package/src/node/buffer-line-transform.js +8 -4
- package/src/node/createBundles.d.ts.map +1 -1
- package/src/node/createBundles.js +3 -5
- package/src/node/fs-stream.d.ts +4 -1
- package/src/node/fs-stream.d.ts.map +1 -1
- package/src/node/fs-stream.js +58 -9
- 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 +18 -0
- package/src/node/shutdown.js +1 -1
- package/src/priority-senders.d.ts +2 -1
- package/src/priority-senders.d.ts.map +1 -1
- package/src/priority-senders.js +6 -4
- package/src/queue.d.ts.map +1 -1
- package/src/queue.js +0 -2
- package/src/ses-utils.d.ts +27 -5
- package/src/ses-utils.d.ts.map +1 -1
- package/src/ses-utils.js +115 -20
- package/src/storage-test-utils.d.ts +15 -5
- package/src/storage-test-utils.d.ts.map +1 -1
- package/src/storage-test-utils.js +62 -8
- package/src/tagged.d.ts +18 -1
- package/src/testing-utils.d.ts +4 -0
- package/src/testing-utils.d.ts.map +1 -1
- package/src/testing-utils.js +88 -2
- package/src/typeGuards.d.ts +6 -2
- package/src/typeGuards.d.ts.map +1 -1
- package/src/typeGuards.js +7 -4
- package/src/types-index.d.ts +1 -0
- package/src/types.d.ts +34 -19
- package/src/types.d.ts.map +1 -1
- package/src/types.js +173 -0
- package/src/upgrade-api.d.ts.map +1 -1
- package/src/upgrade-api.js +4 -3
- package/src/work-pool.d.ts +13 -0
- package/src/work-pool.d.ts.map +1 -0
- package/src/work-pool.js +233 -0
- 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/marshal.d.ts +0 -33
- package/src/marshal.d.ts.map +0 -1
- package/src/types.ts +0 -129
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @import {TransformOptions} from 'node:stream';
|
|
3
|
+
* @import {TransformCallback} from 'node:stream';
|
|
4
|
+
*/
|
|
1
5
|
/**
|
|
2
6
|
* @typedef {object} BufferLineTransformOptions
|
|
3
7
|
* @property {Buffer | string | number} [break] line break matcher for
|
|
@@ -10,10 +14,9 @@ export default class BufferLineTransform extends Transform {
|
|
|
10
14
|
* The BufferLineTransform is reading String or Buffer content from a Readable
|
|
11
15
|
* stream and writing each line as a Buffer in object mode
|
|
12
16
|
*
|
|
13
|
-
* @param {
|
|
14
|
-
* BufferLineTransformOptions} [options]
|
|
17
|
+
* @param {TransformOptions & BufferLineTransformOptions} [options]
|
|
15
18
|
*/
|
|
16
|
-
constructor(options?:
|
|
19
|
+
constructor(options?: TransformOptions & BufferLineTransformOptions);
|
|
17
20
|
_breakValue: string | number | Buffer<ArrayBufferLike>;
|
|
18
21
|
_breakEncoding: BufferEncoding | undefined;
|
|
19
22
|
_breakLength: number;
|
|
@@ -22,10 +25,10 @@ export default class BufferLineTransform extends Transform {
|
|
|
22
25
|
/**
|
|
23
26
|
* @param {any} chunk
|
|
24
27
|
* @param {BufferEncoding | 'buffer'} encoding
|
|
25
|
-
* @param {
|
|
28
|
+
* @param {TransformCallback} cb
|
|
26
29
|
* @override
|
|
27
30
|
*/
|
|
28
|
-
override _transform(chunk: any, encoding: BufferEncoding | "buffer", cb:
|
|
31
|
+
override _transform(chunk: any, encoding: BufferEncoding | "buffer", cb: TransformCallback): void;
|
|
29
32
|
/** @param {Buffer} line */
|
|
30
33
|
_writeItem(line: Buffer): void;
|
|
31
34
|
}
|
|
@@ -42,4 +45,6 @@ export type BufferLineTransformOptions = {
|
|
|
42
45
|
breakEncoding?: BufferEncoding | undefined;
|
|
43
46
|
};
|
|
44
47
|
import { Transform } from 'node:stream';
|
|
48
|
+
import type { TransformCallback } from 'node:stream';
|
|
49
|
+
import type { TransformOptions } from 'node:stream';
|
|
45
50
|
//# sourceMappingURL=buffer-line-transform.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buffer-line-transform.d.ts","sourceRoot":"","sources":["buffer-line-transform.js"],"names":[],"mappings":"AAKA;;;;;;GAMG;AAEH;IACE
|
|
1
|
+
{"version":3,"file":"buffer-line-transform.d.ts","sourceRoot":"","sources":["buffer-line-transform.js"],"names":[],"mappings":"AAKA;;;GAGG;AAEH;;;;;;GAMG;AAEH;IACE;;;;;OAKG;IACH,sBAFW,gBAAgB,GAAG,0BAA0B,EAyBvD;IAhBC,uDAAmC;IACnC,2CAAmC;IAWnC,qBAA+B;IAE/B,uBAAuB;IACvB,SADW,MAAM,EAAE,CACF;IAGnB;;;;;OAKG;IACH,2BALW,GAAG,YACH,cAAc,GAAG,QAAQ,MACzB,iBAAiB,QAiD3B;IAeD,2BAA2B;IAC3B,iBADY,MAAM,QAOjB;CACF;;;;;;;;;;;;;0BA1HyB,aAAa;uCAIH,aAAa;sCADd,aAAa"}
|
|
@@ -3,6 +3,11 @@
|
|
|
3
3
|
|
|
4
4
|
import { Transform } from 'node:stream';
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* @import {TransformOptions} from 'node:stream';
|
|
8
|
+
* @import {TransformCallback} from 'node:stream';
|
|
9
|
+
*/
|
|
10
|
+
|
|
6
11
|
/**
|
|
7
12
|
* @typedef {object} BufferLineTransformOptions
|
|
8
13
|
* @property {Buffer | string | number} [break] line break matcher for
|
|
@@ -16,8 +21,7 @@ export default class BufferLineTransform extends Transform {
|
|
|
16
21
|
* The BufferLineTransform is reading String or Buffer content from a Readable
|
|
17
22
|
* stream and writing each line as a Buffer in object mode
|
|
18
23
|
*
|
|
19
|
-
* @param {
|
|
20
|
-
* BufferLineTransformOptions} [options]
|
|
24
|
+
* @param {TransformOptions & BufferLineTransformOptions} [options]
|
|
21
25
|
*/
|
|
22
26
|
constructor(options) {
|
|
23
27
|
const {
|
|
@@ -47,7 +51,7 @@ export default class BufferLineTransform extends Transform {
|
|
|
47
51
|
/**
|
|
48
52
|
* @param {any} chunk
|
|
49
53
|
* @param {BufferEncoding | 'buffer'} encoding
|
|
50
|
-
* @param {
|
|
54
|
+
* @param {TransformCallback} cb
|
|
51
55
|
* @override
|
|
52
56
|
*/
|
|
53
57
|
_transform(chunk, encoding, cb) {
|
|
@@ -99,7 +103,7 @@ export default class BufferLineTransform extends Transform {
|
|
|
99
103
|
}
|
|
100
104
|
|
|
101
105
|
/**
|
|
102
|
-
* @param {
|
|
106
|
+
* @param {TransformCallback} cb
|
|
103
107
|
* @override
|
|
104
108
|
*/
|
|
105
109
|
_flush(cb) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createBundles.d.ts","sourceRoot":"","sources":["createBundles.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"createBundles.d.ts","sourceRoot":"","sources":["createBundles.js"],"names":[],"mappings":"AAUO,6EAgCN;AAEM,mFAMN;AAEM,iGAkCN"}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
/* eslint-env node */
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
import { spawnSync } from 'child_process';
|
|
6
|
-
import { createRequire } from 'module';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { spawnSync } from 'node:child_process';
|
|
4
|
+
import { createRequire } from 'node:module';
|
|
7
5
|
|
|
8
6
|
import { Fail, q } from '@endo/errors';
|
|
9
7
|
|
package/src/node/fs-stream.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
export function fsStreamReady(stream:
|
|
1
|
+
export function fsStreamReady(stream: ReadStream | WriteStream | Socket): Promise<void>;
|
|
2
2
|
export function makeFsStreamWriter(filePath: string | undefined | null): Promise<{
|
|
3
3
|
write: (data: any) => Promise<void>;
|
|
4
4
|
flush: () => Promise<void>;
|
|
5
5
|
close: () => Promise<void>;
|
|
6
6
|
} | undefined>;
|
|
7
7
|
export type FsStreamWriter = NonNullable<Awaited<ReturnType<typeof makeFsStreamWriter>>>;
|
|
8
|
+
import type { ReadStream } from 'fs';
|
|
9
|
+
import type { WriteStream } from 'fs';
|
|
10
|
+
import type { Socket } from 'net';
|
|
8
11
|
//# sourceMappingURL=fs-stream.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fs-stream.d.ts","sourceRoot":"","sources":["fs-stream.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fs-stream.d.ts","sourceRoot":"","sources":["fs-stream.js"],"names":[],"mappings":"AAcO,sCAHI,UAAU,GAAG,WAAW,GAAG,MAAM,GAC/B,OAAO,CAAC,IAAI,CAAC,CAgCtB;AAmDG,6CADK,MAAM,GAAG,SAAS,GAAG,IAAI;;;;eAsEpC;6BAvEa,WAAW,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC,CAAC;gCAxF5C,IAAI;iCACH,IAAI;4BACT,KAAK"}
|
package/src/node/fs-stream.js
CHANGED
|
@@ -3,9 +3,13 @@ import process from 'node:process';
|
|
|
3
3
|
import { promisify } from 'node:util';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* @
|
|
7
|
-
*
|
|
8
|
-
*
|
|
6
|
+
* @import {ReadStream} from 'fs';
|
|
7
|
+
* @import {WriteStream} from 'fs';
|
|
8
|
+
* @import {Socket} from 'net';
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @param {ReadStream | WriteStream | Socket} stream
|
|
9
13
|
* @returns {Promise<void>}
|
|
10
14
|
*/
|
|
11
15
|
export const fsStreamReady = stream =>
|
|
@@ -40,6 +44,53 @@ export const fsStreamReady = stream =>
|
|
|
40
44
|
stream.on('error', onError);
|
|
41
45
|
});
|
|
42
46
|
|
|
47
|
+
/**
|
|
48
|
+
* Wait for a stream event and reject on stream error first.
|
|
49
|
+
*
|
|
50
|
+
* @param {ReadStream | WriteStream | Socket} stream
|
|
51
|
+
* @param {'drain' | 'ready'} eventName
|
|
52
|
+
* @returns {Promise<void>}
|
|
53
|
+
*/
|
|
54
|
+
const onceWithError = (stream, eventName) =>
|
|
55
|
+
new Promise((resolve, reject) => {
|
|
56
|
+
const onEvent = () => {
|
|
57
|
+
cleanup();
|
|
58
|
+
resolve();
|
|
59
|
+
};
|
|
60
|
+
/** @param {Error} err */
|
|
61
|
+
const onError = err => {
|
|
62
|
+
cleanup();
|
|
63
|
+
reject(err);
|
|
64
|
+
};
|
|
65
|
+
const cleanup = () => {
|
|
66
|
+
stream.off(eventName, onEvent);
|
|
67
|
+
stream.off('error', onError);
|
|
68
|
+
};
|
|
69
|
+
stream.on(eventName, onEvent);
|
|
70
|
+
stream.on('error', onError);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* @param {WriteStream | Socket} stream
|
|
75
|
+
* @param {string | Uint8Array} data
|
|
76
|
+
* @returns {Promise<boolean>} whether caller must await drain
|
|
77
|
+
*/
|
|
78
|
+
const writeChunk = (stream, data) =>
|
|
79
|
+
new Promise((resolve, reject) => {
|
|
80
|
+
let waitForDrain;
|
|
81
|
+
try {
|
|
82
|
+
waitForDrain = !stream.write(data, err => {
|
|
83
|
+
if (err) {
|
|
84
|
+
reject(err);
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
resolve(waitForDrain);
|
|
88
|
+
});
|
|
89
|
+
} catch (err) {
|
|
90
|
+
reject(err);
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
|
|
43
94
|
/** @typedef {NonNullable<Awaited<ReturnType<typeof makeFsStreamWriter>>>} FsStreamWriter */
|
|
44
95
|
/** @param {string | undefined | null} filePath */
|
|
45
96
|
export const makeFsStreamWriter = async filePath => {
|
|
@@ -56,13 +107,11 @@ export const makeFsStreamWriter = async filePath => {
|
|
|
56
107
|
return { handle: fh, stream: fh.createWriteStream({ flush: true }) };
|
|
57
108
|
})();
|
|
58
109
|
await fsStreamReady(stream);
|
|
59
|
-
const
|
|
110
|
+
const waitForDrainAsync = () => onceWithError(stream, 'drain');
|
|
60
111
|
const closeAsync =
|
|
61
112
|
useStdout || !(/** @type {any} */ (stream).close)
|
|
62
113
|
? undefined
|
|
63
|
-
: promisify(
|
|
64
|
-
/** @type {import('fs').WriteStream} */ (stream).close.bind(stream),
|
|
65
|
-
);
|
|
114
|
+
: promisify(/** @type {WriteStream} */ (stream).close.bind(stream));
|
|
66
115
|
|
|
67
116
|
let flushed = Promise.resolve();
|
|
68
117
|
let closed = false;
|
|
@@ -85,11 +134,11 @@ export const makeFsStreamWriter = async filePath => {
|
|
|
85
134
|
const write = async data => {
|
|
86
135
|
const written = closed
|
|
87
136
|
? Promise.reject(Error('Stream closed'))
|
|
88
|
-
:
|
|
137
|
+
: writeChunk(stream, data);
|
|
89
138
|
updateFlushed(written);
|
|
90
139
|
const waitForDrain = await written;
|
|
91
140
|
if (waitForDrain) {
|
|
92
|
-
await
|
|
141
|
+
await waitForDrainAsync();
|
|
93
142
|
}
|
|
94
143
|
};
|
|
95
144
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read-json.d.ts","sourceRoot":"","sources":["read-json.js"],"names":[],"mappings":"AASO,iCAJO,CAAC,sBACJ,IAAI,CAAC,cAAc,kBAAkB,CAAC,EAAE,UAAU,CAAC,mBACnD,CAAC,KAAK,EAAE,UAAU,CAAC,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,UAGlC,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,CAOxC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/* eslint-env node */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Build a function that reads and parses a JSON file.
|
|
5
|
+
*
|
|
6
|
+
* @template [U=ReturnType<typeof JSON.parse>]
|
|
7
|
+
* @param {Pick<typeof import('node:fs/promises'), 'readFile'>} fsp
|
|
8
|
+
* @param {(input: ReturnType<typeof JSON.parse>) => U} [resultReplacer]
|
|
9
|
+
*/
|
|
10
|
+
export const makeReadJsonFile = ({ readFile }, resultReplacer) => {
|
|
11
|
+
/** @type {(path: string) => Promise<U>} */
|
|
12
|
+
const readJsonFile = async path => {
|
|
13
|
+
const text = await readFile(path, 'utf8');
|
|
14
|
+
const result = JSON.parse(text);
|
|
15
|
+
return resultReplacer ? resultReplacer(result) : /** @type {U} */ (result);
|
|
16
|
+
};
|
|
17
|
+
return readJsonFile;
|
|
18
|
+
};
|
package/src/node/shutdown.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** @type {(namespace: string) => string} */
|
|
2
2
|
export const normalizeSenderNamespace: (namespace: string) => string;
|
|
3
|
-
export function makePrioritySendersManager(sendersNode: ERef<
|
|
3
|
+
export function makePrioritySendersManager(sendersNode: ERef<StorageNode>): {
|
|
4
4
|
/**
|
|
5
5
|
* @param {string} rawNamespace
|
|
6
6
|
* @param {string} address
|
|
@@ -28,5 +28,6 @@ export function makePrioritySendersManager(sendersNode: ERef<import("./lib-chain
|
|
|
28
28
|
remove: (rawNamespace: string, address: string) => Promise<void>;
|
|
29
29
|
}>;
|
|
30
30
|
export type PrioritySendersManager = ReturnType<typeof makePrioritySendersManager>;
|
|
31
|
+
import type { StorageNode } from './lib-chainStorage.js';
|
|
31
32
|
import type { ERef } from '@endo/far';
|
|
32
33
|
//# sourceMappingURL=priority-senders.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"priority-senders.d.ts","sourceRoot":"","sources":["priority-senders.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"priority-senders.d.ts","sourceRoot":"","sources":["priority-senders.js"],"names":[],"mappings":"AAUA,4CAA4C;AAC5C,uCADW,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,CAMtC;AAQK,wDAFI,KAAK,WAAW,CAAC;IA0CxB;;;;OAIG;wBAHQ,MAAM,WACN,MAAM,KACJ,OAAO,CAAC,IAAI,CAAC;IAe1B;;;;OAIG;2BAHQ,MAAM,WACN,MAAM,KACJ,OAAO,CAAC,IAAI,CAAC;;IArB1B;;;;OAIG;wBAHQ,MAAM,WACN,MAAM,KACJ,OAAO,CAAC,IAAI,CAAC;IAe1B;;;;OAIG;2BAHQ,MAAM,WACN,MAAM,KACJ,OAAO,CAAC,IAAI,CAAC;GAuB7B;qCAGa,UAAU,CAAC,OAAO,0BAA0B,CAAC;iCA1G7B,uBAAuB;0BAD9B,WAAW"}
|
package/src/priority-senders.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { Fail, q } from '@endo/errors';
|
|
2
2
|
import { E, Far } from '@endo/far';
|
|
3
3
|
|
|
4
|
-
/**
|
|
5
|
-
|
|
4
|
+
/**
|
|
5
|
+
* @import {ERef} from '@endo/far';
|
|
6
|
+
* @import {StorageNode} from './lib-chainStorage.js';
|
|
7
|
+
*/
|
|
6
8
|
|
|
7
9
|
const PRIORITY_SENDERS_NAMESPACE_RE = /^[a-zA-Z0-9_-]{1,50}$/;
|
|
8
10
|
|
|
@@ -18,7 +20,7 @@ harden(normalizeSenderNamespace);
|
|
|
18
20
|
/**
|
|
19
21
|
* XXX lets holder manage sender list for all namespaces
|
|
20
22
|
*
|
|
21
|
-
* @param {ERef<
|
|
23
|
+
* @param {ERef<StorageNode>} sendersNode
|
|
22
24
|
*/
|
|
23
25
|
export const makePrioritySendersManager = sendersNode => {
|
|
24
26
|
/**
|
|
@@ -35,7 +37,7 @@ export const makePrioritySendersManager = sendersNode => {
|
|
|
35
37
|
/**
|
|
36
38
|
* Write a list of namespaces into a storage node.
|
|
37
39
|
*
|
|
38
|
-
* @param {
|
|
40
|
+
* @param {StorageNode} node
|
|
39
41
|
* @param {Set<string>} namespaces
|
|
40
42
|
*/
|
|
41
43
|
const refreshVstorage = (node, namespaces) => {
|
package/src/queue.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["queue.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["queue.js"],"names":[],"mappings":"AAMO,kCA2BqB,OAFf,CAEoB,MAKH,GAAG,MAHlB,UAAU,CAAC,CAAC,CAGU,KAFpB,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAkB/C"}
|
package/src/queue.js
CHANGED
package/src/ses-utils.d.ts
CHANGED
|
@@ -18,9 +18,11 @@ export function makeLimitedConsole(makeLogger: (level: string) => (...args: unkn
|
|
|
18
18
|
* @template T
|
|
19
19
|
* @typedef {T extends PromiseLike<any>
|
|
20
20
|
* ? Awaited<T>
|
|
21
|
-
* : T extends
|
|
22
|
-
* ?
|
|
23
|
-
* :
|
|
21
|
+
* : T extends RemotableBrand<any, any> | RemotableObject
|
|
22
|
+
* ? T
|
|
23
|
+
* : T extends {}
|
|
24
|
+
* ? Simplify<DeeplyAwaitedObject<T>>
|
|
25
|
+
* : Awaited<T>} DeeplyAwaited
|
|
24
26
|
*/
|
|
25
27
|
/**
|
|
26
28
|
* A more constrained version of {deeplyFulfilled} for type safety until
|
|
@@ -30,10 +32,27 @@ export function makeLimitedConsole(makeLogger: (level: string) => (...args: unkn
|
|
|
30
32
|
* @type {<T extends {}>(unfulfilledTerms: T) => Promise<DeeplyAwaited<T>>}
|
|
31
33
|
*/
|
|
32
34
|
export const deeplyFulfilledObject: <T extends {}>(unfulfilledTerms: T) => Promise<DeeplyAwaited<T>>;
|
|
35
|
+
export function stripPrefix(prefix: string, str: string): string;
|
|
36
|
+
export function throwErrorCode<Code extends string>(details: Parameters<typeof makeError>[0], code: Code, opts?: Parameters<typeof makeError>[2] & {
|
|
37
|
+
constructor?: Parameters<typeof makeError>[1];
|
|
38
|
+
}): never;
|
|
39
|
+
export function tryNow<F extends (...args: any[]) => any, U = ReturnType<F>>(fn: F, transformError: (err: Error) => U, ...args: Parameters<F>): ReturnType<F> | U;
|
|
40
|
+
export function tryJsonParse(jsonText: string, onError: string | ((err: Error) => unknown)): any;
|
|
33
41
|
export function PromiseAllOrErrors<T>(items: readonly (T | PromiseLike<T>)[]): Promise<T[]>;
|
|
34
42
|
export function aggregateTryFinally<T>(trier: () => Promise<T>, finalizer: (error?: unknown) => Promise<unknown>): ReturnType<() => Promise<T>>;
|
|
35
43
|
export function withDeferredCleanup<T>(fn: (addCleanup: (fn: (err?: unknown) => Promise<void>) => void) => Promise<T>): ReturnType<(addCleanup: (fn: (err?: unknown) => Promise<void>) => void) => Promise<T>>;
|
|
36
|
-
|
|
44
|
+
/**
|
|
45
|
+
* @template {Record<string, unknown>} T
|
|
46
|
+
* @typedef {{ [P in keyof T]: Exclude<T[P], undefined> }} AllDefined
|
|
47
|
+
*/
|
|
48
|
+
/**
|
|
49
|
+
* Concise way to check values are available from object literal shorthand.
|
|
50
|
+
* Throws error message to specify the missing values.
|
|
51
|
+
*
|
|
52
|
+
* @type {<T extends Record<string, unknown>>(obj: T) => asserts obj is AllDefined<T>}
|
|
53
|
+
* @throws if any value in the object entries is not defined
|
|
54
|
+
*/
|
|
55
|
+
export const assertAllDefined: <T extends Record<string, unknown>>(obj: T) => asserts obj is AllDefined<T>;
|
|
37
56
|
export function attenuate<T, P extends Permit<T>>(specimen: T, permit: P, transform?: <U, SubP extends Permit<U>>(attenuation: U, permit: SubP) => U): Attenuated<T, P>;
|
|
38
57
|
export const forever: AsyncIterable<undefined>;
|
|
39
58
|
export function whileTrue<T>(produce: () => T): AsyncIterable<Awaited<T>>;
|
|
@@ -55,14 +74,17 @@ export function synchronizedTee<T = unknown>(sourceStream: AsyncIterator<T, void
|
|
|
55
74
|
export type Simplify<T> = { [KeyType in keyof T]: T[KeyType]; } & {};
|
|
56
75
|
export type Callable = (...args: any[]) => any;
|
|
57
76
|
export type DeeplyAwaitedObject<T extends {}> = { [K in keyof T]: T[K] extends Callable ? T[K] : DeeplyAwaited<T[K]>; };
|
|
58
|
-
export type DeeplyAwaited<T> = T extends PromiseLike<any> ? Awaited<T> : T extends {} ? Simplify<DeeplyAwaitedObject<T>> : Awaited<T>;
|
|
77
|
+
export type DeeplyAwaited<T> = T extends PromiseLike<any> ? Awaited<T> : T extends RemotableBrand<any, any> | RemotableObject ? T : T extends {} ? Simplify<DeeplyAwaitedObject<T>> : Awaited<T>;
|
|
59
78
|
export type AllDefined<T extends Record<string, unknown>> = { [P in keyof T]: Exclude<T[P], undefined>; };
|
|
60
79
|
import { objectMap } from '@endo/common/object-map.js';
|
|
61
80
|
import { objectMetaMap } from '@endo/common/object-meta-map.js';
|
|
62
81
|
import { fromUniqueEntries } from '@endo/common/from-unique-entries.js';
|
|
63
82
|
import type { LimitedConsole } from './js-utils.js';
|
|
83
|
+
import { makeError } from '@endo/errors';
|
|
64
84
|
import type { Permit } from './types.js';
|
|
65
85
|
import type { Attenuated } from './types.js';
|
|
66
86
|
import type { ERef } from '@endo/far';
|
|
87
|
+
import type { RemotableBrand } from '@endo/eventual-send';
|
|
88
|
+
import type { RemotableObject } from '@endo/pass-style';
|
|
67
89
|
export { objectMap, objectMetaMap, fromUniqueEntries };
|
|
68
90
|
//# sourceMappingURL=ses-utils.d.ts.map
|
package/src/ses-utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ses-utils.d.ts","sourceRoot":"","sources":["ses-utils.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ses-utils.d.ts","sourceRoot":"","sources":["ses-utils.js"],"names":[],"mappings":"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"}
|
package/src/ses-utils.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
// @ts-check
|
|
2
|
-
// @jessie-check
|
|
3
2
|
/**
|
|
4
3
|
* @file Utility functions that are dependent upon a hardened environment,
|
|
5
4
|
* either directly or indirectly (e.g. by @endo imports).
|
|
@@ -8,7 +7,7 @@
|
|
|
8
7
|
import { objectMap } from '@endo/common/object-map.js';
|
|
9
8
|
import { objectMetaMap } from '@endo/common/object-meta-map.js';
|
|
10
9
|
import { fromUniqueEntries } from '@endo/common/from-unique-entries.js';
|
|
11
|
-
import { q, Fail, makeError, annotateError, X } from '@endo/errors';
|
|
10
|
+
import { q, b, Fail, makeError, annotateError, X } from '@endo/errors';
|
|
12
11
|
import { deeplyFulfilled, isPrimitive } from '@endo/pass-style';
|
|
13
12
|
import { makePromiseKit } from '@endo/promise-kit';
|
|
14
13
|
import { makeQueue } from '@endo/stream';
|
|
@@ -17,10 +16,15 @@ import { makeQueue } from '@endo/stream';
|
|
|
17
16
|
import { asyncGenerate } from 'jessie.js';
|
|
18
17
|
import { logLevels } from './js-utils.js';
|
|
19
18
|
|
|
20
|
-
/**
|
|
19
|
+
/**
|
|
20
|
+
* @import {LimitedConsole} from './js-utils.js';
|
|
21
|
+
* @import {AsyncQueue} from '@endo/stream';
|
|
22
|
+
* @import {PromiseKit} from '@endo/promise-kit';
|
|
23
|
+
*/
|
|
21
24
|
|
|
22
25
|
/** @import {ERef} from '@endo/far'; */
|
|
23
|
-
/** @import {
|
|
26
|
+
/** @import {RemotableBrand} from '@endo/eventual-send'; */
|
|
27
|
+
/** @import {Primitive, RemotableObject} from '@endo/pass-style'; */
|
|
24
28
|
/** @import {Permit, Attenuated} from './types.js'; */
|
|
25
29
|
|
|
26
30
|
export { objectMap, objectMetaMap, fromUniqueEntries };
|
|
@@ -58,9 +62,11 @@ harden(makeLimitedConsole);
|
|
|
58
62
|
* @template T
|
|
59
63
|
* @typedef {T extends PromiseLike<any>
|
|
60
64
|
* ? Awaited<T>
|
|
61
|
-
* : T extends
|
|
62
|
-
* ?
|
|
63
|
-
* :
|
|
65
|
+
* : T extends RemotableBrand<any, any> | RemotableObject
|
|
66
|
+
* ? T
|
|
67
|
+
* : T extends {}
|
|
68
|
+
* ? Simplify<DeeplyAwaitedObject<T>>
|
|
69
|
+
* : Awaited<T>} DeeplyAwaited
|
|
64
70
|
*/
|
|
65
71
|
|
|
66
72
|
/**
|
|
@@ -90,6 +96,101 @@ const makeAggregateError =
|
|
|
90
96
|
});
|
|
91
97
|
};
|
|
92
98
|
|
|
99
|
+
/**
|
|
100
|
+
* Assert that a string has a prefix, and return the part that follows it.
|
|
101
|
+
*
|
|
102
|
+
* @param {string} prefix
|
|
103
|
+
* @param {string} str
|
|
104
|
+
* @returns {string}
|
|
105
|
+
*/
|
|
106
|
+
export const stripPrefix = (prefix, str) => {
|
|
107
|
+
str.startsWith(prefix) || Fail`${str} is missing prefix ${q(prefix)}`;
|
|
108
|
+
return str.slice(prefix.length);
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Throw an error with an own "code" data property, supporting identification
|
|
113
|
+
* without parsing `message`. Note that such errors are not Passable and thus
|
|
114
|
+
* cannot appear inside a Passable structure, and even at top level the "code"
|
|
115
|
+
* property will be silently dropped by marshalling.
|
|
116
|
+
*
|
|
117
|
+
* @template {string} Code
|
|
118
|
+
* @param {Parameters<typeof makeError>[0]} details
|
|
119
|
+
* @param {Code} code
|
|
120
|
+
* @param {Parameters<typeof makeError>[2] & {
|
|
121
|
+
* constructor?: Parameters<typeof makeError>[1];
|
|
122
|
+
* }} [opts]
|
|
123
|
+
*/
|
|
124
|
+
export const throwErrorCode = (details, code, opts) => {
|
|
125
|
+
const err = makeError(details, opts?.constructor, {
|
|
126
|
+
...opts,
|
|
127
|
+
sanitize: false,
|
|
128
|
+
});
|
|
129
|
+
Object.defineProperty(err, 'code', { value: code, enumerable: true });
|
|
130
|
+
harden(err);
|
|
131
|
+
throw err;
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Synchronusly invoke a function with the opportunity to handle any error
|
|
136
|
+
* similarly to a Promise `catch` callback (e.g., substituting a non-error
|
|
137
|
+
* returned value or throwing a possibly-new error). This is useful for (among
|
|
138
|
+
* other things) replacing generic error messages with specific ones (as in
|
|
139
|
+
* {@link tryJsonParse}).
|
|
140
|
+
*
|
|
141
|
+
* @template {(...args: any[]) => any} F
|
|
142
|
+
* @template [U=ReturnType<F>]
|
|
143
|
+
* @param {F} fn to invoke
|
|
144
|
+
* @param {(err: Error) => U} transformError callback to receive any error from
|
|
145
|
+
* invoking `fn` and either return a substitute value or throw a potentially
|
|
146
|
+
* new error
|
|
147
|
+
* @param {Parameters<F>} args for `fn`
|
|
148
|
+
* @returns {ReturnType<F> | U}
|
|
149
|
+
*/
|
|
150
|
+
export const tryNow = (fn, transformError, ...args) => {
|
|
151
|
+
try {
|
|
152
|
+
return fn(...args);
|
|
153
|
+
} catch (err) {
|
|
154
|
+
try {
|
|
155
|
+
return transformError(err);
|
|
156
|
+
} catch (newErr) {
|
|
157
|
+
// Try to associate `err` with `newErr`.
|
|
158
|
+
if (!newErr.cause) {
|
|
159
|
+
const desc = {
|
|
160
|
+
value: err,
|
|
161
|
+
configurable: true,
|
|
162
|
+
enumerable: false,
|
|
163
|
+
writable: true,
|
|
164
|
+
};
|
|
165
|
+
if (!Reflect.defineProperty(newErr, 'cause', desc)) {
|
|
166
|
+
assert.note(newErr, err.message);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
throw newErr;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Parse JSON text, or handle an error by e.g. substituting a default value or
|
|
176
|
+
* replacing it with one bearing a non-generic message.
|
|
177
|
+
*
|
|
178
|
+
* @param {string} jsonText
|
|
179
|
+
* @param {string | ((err: Error) => unknown)} onError an error message or
|
|
180
|
+
* callback
|
|
181
|
+
*/
|
|
182
|
+
export const tryJsonParse = (jsonText, onError) => {
|
|
183
|
+
const transformError =
|
|
184
|
+
typeof onError === 'function'
|
|
185
|
+
? onError
|
|
186
|
+
: err => Fail([`${onError}: ${err.message} for input `, ''], jsonText);
|
|
187
|
+
return tryNow(() => {
|
|
188
|
+
const type = typeof jsonText;
|
|
189
|
+
type === 'string' || Fail`Input must be a string, not ${b(type)}`;
|
|
190
|
+
return JSON.parse(jsonText);
|
|
191
|
+
}, transformError);
|
|
192
|
+
};
|
|
193
|
+
|
|
93
194
|
/**
|
|
94
195
|
* @template T
|
|
95
196
|
* @param {readonly (T | PromiseLike<T>)[]} items
|
|
@@ -167,9 +268,7 @@ export const withDeferredCleanup = async fn => {
|
|
|
167
268
|
* Concise way to check values are available from object literal shorthand.
|
|
168
269
|
* Throws error message to specify the missing values.
|
|
169
270
|
*
|
|
170
|
-
* @
|
|
171
|
-
* @param {T} obj
|
|
172
|
-
* @returns {asserts obj is AllDefined<T>}
|
|
271
|
+
* @type {<T extends Record<string, unknown>>(obj: T) => asserts obj is AllDefined<T>}
|
|
173
272
|
* @throws if any value in the object entries is not defined
|
|
174
273
|
*/
|
|
175
274
|
export const assertAllDefined = obj => {
|
|
@@ -320,7 +419,7 @@ export const synchronizedTee = (sourceStream, readerCount) => {
|
|
|
320
419
|
* (value: PromiseLike<IteratorResult<T>>) => void
|
|
321
420
|
* >} QueuePayload
|
|
322
421
|
*/
|
|
323
|
-
/** @type {
|
|
422
|
+
/** @type {AsyncQueue<QueuePayload>[]} */
|
|
324
423
|
const queues = [];
|
|
325
424
|
|
|
326
425
|
/** @returns {Promise<void>} */
|
|
@@ -374,7 +473,7 @@ export const synchronizedTee = (sourceStream, readerCount) => {
|
|
|
374
473
|
};
|
|
375
474
|
|
|
376
475
|
const readers = Array.from({ length: readerCount }).map(() => {
|
|
377
|
-
/** @type {
|
|
476
|
+
/** @type {AsyncQueue<QueuePayload>} */
|
|
378
477
|
const queue = makeQueue();
|
|
379
478
|
queues.push(queue);
|
|
380
479
|
|
|
@@ -382,9 +481,7 @@ export const synchronizedTee = (sourceStream, readerCount) => {
|
|
|
382
481
|
const reader = harden({
|
|
383
482
|
async next() {
|
|
384
483
|
/**
|
|
385
|
-
* @type {
|
|
386
|
-
* IteratorResult<T>
|
|
387
|
-
* >}
|
|
484
|
+
* @type {PromiseKit<IteratorResult<T>>}
|
|
388
485
|
*/
|
|
389
486
|
const { promise, resolve } = makePromiseKit();
|
|
390
487
|
queue.put({ value: resolve, done: false });
|
|
@@ -392,9 +489,7 @@ export const synchronizedTee = (sourceStream, readerCount) => {
|
|
|
392
489
|
},
|
|
393
490
|
async return() {
|
|
394
491
|
/**
|
|
395
|
-
* @type {
|
|
396
|
-
* IteratorResult<T>
|
|
397
|
-
* >}
|
|
492
|
+
* @type {PromiseKit<IteratorResult<T>>}
|
|
398
493
|
*/
|
|
399
494
|
const { promise, resolve } = makePromiseKit();
|
|
400
495
|
queue.put({ value: resolve, done: true });
|
|
@@ -405,11 +500,11 @@ export const synchronizedTee = (sourceStream, readerCount) => {
|
|
|
405
500
|
queue.put(rejection);
|
|
406
501
|
return rejection;
|
|
407
502
|
},
|
|
408
|
-
|
|
503
|
+
|
|
409
504
|
[Symbol.asyncIterator]() {
|
|
410
505
|
return reader;
|
|
411
506
|
},
|
|
412
|
-
|
|
507
|
+
|
|
413
508
|
async [Symbol.asyncDispose]() {
|
|
414
509
|
await reader.return();
|
|
415
510
|
},
|