@agoric/internal 0.3.3-upgrade-18-dev-a0f4883.0 → 0.3.3-upgrade-19-dev-c605745.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 +4 -4
- package/package.json +16 -15
- package/src/action-types.d.ts +49 -5
- package/src/action-types.d.ts.map +1 -1
- package/src/action-types.js +74 -17
- package/src/batched-deliver.d.ts.map +1 -1
- package/src/callback.d.ts +1 -1
- package/src/callback.d.ts.map +1 -1
- package/src/chain-storage-paths.d.ts.map +1 -1
- package/src/chain-utils.d.ts +25 -0
- package/src/chain-utils.d.ts.map +1 -0
- package/src/chain-utils.js +57 -0
- package/src/errors.d.ts +1 -1
- package/src/errors.d.ts.map +1 -1
- package/src/index.d.ts +3 -1
- package/src/index.js +3 -1
- package/src/js-utils.d.ts +14 -0
- package/src/js-utils.d.ts.map +1 -0
- package/src/js-utils.js +102 -0
- package/src/lib-chainStorage.d.ts +1 -23
- package/src/lib-chainStorage.d.ts.map +1 -1
- package/src/lib-nodejs/ava-unhandled-rejection.d.ts +13 -0
- package/src/lib-nodejs/ava-unhandled-rejection.d.ts.map +1 -0
- package/src/lib-nodejs/ava-unhandled-rejection.js +66 -0
- package/src/lib-nodejs/engine-gc.d.ts +1 -1
- package/src/marshal.d.ts +8 -2
- package/src/marshal.d.ts.map +1 -1
- package/src/marshal.js +7 -0
- package/src/natural-sort.d.ts +2 -0
- package/src/natural-sort.d.ts.map +1 -0
- package/src/natural-sort.js +48 -0
- package/src/netstring.d.ts +2 -2
- package/src/netstring.d.ts.map +1 -1
- package/src/netstring.js +1 -0
- package/src/node/buffer-line-transform.d.ts +3 -3
- package/src/node/buffer-line-transform.d.ts.map +1 -1
- package/src/node/fs-stream.js +2 -2
- package/src/node/shutdown.d.ts.map +1 -1
- package/src/node/shutdown.js +0 -1
- package/src/priority-senders.d.ts +1 -0
- package/src/priority-senders.d.ts.map +1 -1
- package/src/priority-senders.js +3 -0
- package/src/queue.d.ts +1 -1
- package/src/queue.d.ts.map +1 -1
- package/src/{utils.d.ts → ses-utils.d.ts} +3 -8
- package/src/ses-utils.d.ts.map +1 -0
- package/src/{utils.js → ses-utils.js} +16 -72
- package/src/storage-test-utils.d.ts +12 -4
- package/src/storage-test-utils.d.ts.map +1 -1
- package/src/storage-test-utils.js +81 -16
- package/src/tagged.d.ts +4 -1
- package/src/testing-utils.js +1 -1
- package/src/tokens.d.ts.map +1 -1
- package/src/typeGuards.d.ts +15 -0
- package/src/typeGuards.d.ts.map +1 -1
- package/src/typeGuards.js +12 -0
- package/src/types.d.ts +1 -1
- package/src/types.d.ts.map +1 -1
- package/src/types.ts +1 -1
- package/src/utils.d.ts.map +0 -1
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
import { spawn } from 'child_process';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
|
|
5
|
+
import engineGC from './engine-gc.js';
|
|
6
|
+
import { makeGcAndFinalize } from './gc-and-finalize.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @import {ExecutionContext, Macro, TestFn} from 'ava';
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
export const AVA_EXPECT_UNHANDLED_REJECTIONS =
|
|
13
|
+
'AGORIC_AVA_EXPECT_UNHANDLED_REJECTIONS';
|
|
14
|
+
|
|
15
|
+
export const SUBTEST_PREFIX = '(unhandled rejection subprocess): ';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @template C
|
|
19
|
+
* @param {object} powers
|
|
20
|
+
* @param {TestFn<C>} powers.test
|
|
21
|
+
* @param {string} powers.importMetaUrl
|
|
22
|
+
* @returns {(
|
|
23
|
+
* expectedUnhandled: number,
|
|
24
|
+
* ) => Macro<[name: string, impl: (t: ExecutionContext<C>) => any], C>}
|
|
25
|
+
*/
|
|
26
|
+
export const makeExpectUnhandledRejection = ({ test, importMetaUrl }) => {
|
|
27
|
+
const self = fileURLToPath(importMetaUrl);
|
|
28
|
+
const gcAndFinalize = makeGcAndFinalize(engineGC);
|
|
29
|
+
|
|
30
|
+
if (process.env[AVA_EXPECT_UNHANDLED_REJECTIONS]) {
|
|
31
|
+
return _expectedUnhandled =>
|
|
32
|
+
test.macro({
|
|
33
|
+
title: (_, name, _impl) => SUBTEST_PREFIX + name,
|
|
34
|
+
exec: async (t, _name, impl) => {
|
|
35
|
+
await null;
|
|
36
|
+
try {
|
|
37
|
+
const result = await impl(t);
|
|
38
|
+
return result;
|
|
39
|
+
} finally {
|
|
40
|
+
await gcAndFinalize();
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return expectedUnhandled =>
|
|
47
|
+
test.macro({
|
|
48
|
+
title: (_, name, _impl) => name,
|
|
49
|
+
exec: async (t, name, _impl) =>
|
|
50
|
+
new Promise((resolve, reject) => {
|
|
51
|
+
const ps = spawn('ava', [self, '-m', SUBTEST_PREFIX + name], {
|
|
52
|
+
env: {
|
|
53
|
+
...process.env,
|
|
54
|
+
[AVA_EXPECT_UNHANDLED_REJECTIONS]: `${expectedUnhandled}`,
|
|
55
|
+
},
|
|
56
|
+
stdio: ['ignore', 'inherit', 'inherit', 'ignore'],
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
ps.on('close', code => {
|
|
60
|
+
t.is(code, 0, `got exit code ${code}, expected 0 for ${name}`);
|
|
61
|
+
resolve();
|
|
62
|
+
});
|
|
63
|
+
ps.on('error', reject);
|
|
64
|
+
}),
|
|
65
|
+
});
|
|
66
|
+
};
|
package/src/marshal.d.ts
CHANGED
|
@@ -3,13 +3,19 @@ export function makeBoardRemote({ boardId, iface }: {
|
|
|
3
3
|
iface?: string;
|
|
4
4
|
}): BoardRemote;
|
|
5
5
|
export function slotToBoardRemote(boardId: string, iface: string): BoardRemote;
|
|
6
|
-
export function boardSlottingMarshaller(slotToVal?: (
|
|
6
|
+
export function boardSlottingMarshaller(slotToVal?: (slot: string, iface: string) => any): Omit<import("@endo/marshal").Marshal<string | null>, "serialize" | "unserialize">;
|
|
7
7
|
export function unmarshalFromVstorage(data: Map<string, string>, key: string, fromCapData: ReturnType<typeof import("@endo/marshal").makeMarshal>["fromCapData"], index: number): any;
|
|
8
|
-
export function makeHistoryReviver(entries: [string, string][], slotToVal?: (
|
|
8
|
+
export function makeHistoryReviver(entries: [string, string][], slotToVal?: (slot: string, iface?: string) => any): {
|
|
9
9
|
getItem: (key: string) => any;
|
|
10
10
|
children: (prefix: string) => string[];
|
|
11
11
|
has: (k: string) => boolean;
|
|
12
12
|
};
|
|
13
|
+
export const pureDataMarshaller: {
|
|
14
|
+
toCapData: import("@endo/marshal").ToCapData<import("@endo/marshal").CapData<unknown>>;
|
|
15
|
+
fromCapData: import("@endo/marshal").FromCapData<import("@endo/marshal").CapData<unknown>>;
|
|
16
|
+
serialize: import("@endo/marshal").ToCapData<import("@endo/marshal").CapData<unknown>>;
|
|
17
|
+
unserialize: import("@endo/marshal").FromCapData<import("@endo/marshal").CapData<unknown>>;
|
|
18
|
+
};
|
|
13
19
|
/**
|
|
14
20
|
* Should be a union with Remotable, but that's `any`, making this type
|
|
15
21
|
* meaningless
|
package/src/marshal.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"marshal.d.ts","sourceRoot":"","sources":["marshal.js"],"names":[],"mappings":"AAiBO,oDAHI;IAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,GACxC,WAAW,CAKvB;AAMM,2CAHI,MAAM,SACN,MAAM,eAGoB;AAqB9B,
|
|
1
|
+
{"version":3,"file":"marshal.d.ts","sourceRoot":"","sources":["marshal.js"],"names":[],"mappings":"AAiBO,oDAHI;IAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,GACxC,WAAW,CAKvB;AAMM,2CAHI,MAAM,SACN,MAAM,eAGoB;AAqB9B,oDANI,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,GAAG,GAClC,IAAI,CAChB,OAAW,eAAe,EAAE,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,EAClD,WAAe,GAAG,aAAa,CAC5B,CAMH;AA6BM,4CATI,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,OACnB,MAAM,eACN,UAAU,CACpB,cAAkB,eAAe,EAAE,WAAW,CAC3C,CAAC,aAAa,CAAC,SACR,MAAM,GAEJ,GAAG,CAwBf;AASM,4CAHI,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,cAClB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,KAAK,GAAG;mBAQlC,MAAM;uBAEN,MAAM;aAYN,MAAM;EAInB;AAID;;;;;EAEG;;;;;0BApIU;IAAE,UAAU,EAAE,MAAM,MAAM,GAAG,IAAI,CAAA;CAAE"}
|
package/src/marshal.js
CHANGED
|
@@ -135,3 +135,10 @@ export const makeHistoryReviver = (entries, slotToVal = undefined) => {
|
|
|
135
135
|
|
|
136
136
|
return harden({ getItem, children, has });
|
|
137
137
|
};
|
|
138
|
+
|
|
139
|
+
/** @param {import('@endo/marshal').CapData<unknown>} cap */
|
|
140
|
+
const rejectOCap = cap => Fail`${cap} is not pure data`;
|
|
141
|
+
export const pureDataMarshaller = makeMarshal(rejectOCap, rejectOCap, {
|
|
142
|
+
serializeBodyFormat: 'smallcaps',
|
|
143
|
+
});
|
|
144
|
+
harden(pureDataMarshaller);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"natural-sort.d.ts","sourceRoot":"","sources":["natural-sort.js"],"names":[],"mappings":"AAqCO,kCAJI,MAAM,KACN,MAAM,GACJ,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAWtB"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {string} a
|
|
3
|
+
* @param {string} b
|
|
4
|
+
* @returns {-1 | 0 | 1}
|
|
5
|
+
*/
|
|
6
|
+
const compareNats = (a, b) => {
|
|
7
|
+
// Default to IEEE 754 number arithmetic for speed, but fall back on bigint
|
|
8
|
+
// arithmetic to resolve ties because big numbers can lose resolution
|
|
9
|
+
// (sometimes even becoming infinite) and then ultimately on length to resolve
|
|
10
|
+
// ties by ascending count of leading zeros.
|
|
11
|
+
const diff = +a - +b;
|
|
12
|
+
const finiteDiff =
|
|
13
|
+
(Number.isFinite(diff) && diff) ||
|
|
14
|
+
(a === b ? 0 : Number(BigInt(a) - BigInt(b)) || a.length - b.length);
|
|
15
|
+
|
|
16
|
+
// @ts-expect-error this call really does return -1 | 0 | 1
|
|
17
|
+
return Math.sign(finiteDiff);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
// TODO: compareByCodePoints
|
|
21
|
+
// https://github.com/endojs/endo/pull/2008
|
|
22
|
+
// eslint-disable-next-line no-nested-ternary
|
|
23
|
+
const compareStrings = (a, b) => (a > b ? 1 : a < b ? -1 : 0);
|
|
24
|
+
|
|
25
|
+
const rPrefixedDigits = /^(\D*)(\d+)(\D.*|)/s;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Perform a single-level natural-sort comparison, finding the first decimal
|
|
29
|
+
* digit sequence in each operand and comparing first by the (possibly empty)
|
|
30
|
+
* preceding prefix as strings, then by the digits as integers, then by any
|
|
31
|
+
* following suffix (e.g., sorting 'ko42' before 'ko100' as ['ko', 42] vs.
|
|
32
|
+
* ['ko', 100]).
|
|
33
|
+
*
|
|
34
|
+
* @param {string} a
|
|
35
|
+
* @param {string} b
|
|
36
|
+
* @returns {-1 | 0 | 1}
|
|
37
|
+
*/
|
|
38
|
+
export const naturalCompare = (a, b) => {
|
|
39
|
+
const [_a, aPrefix, aDigits, aSuffix] = rPrefixedDigits.exec(a) || [];
|
|
40
|
+
if (aPrefix !== undefined) {
|
|
41
|
+
const [_b, bPrefix, bDigits, bSuffix] = rPrefixedDigits.exec(b) || [];
|
|
42
|
+
if (bPrefix === aPrefix) {
|
|
43
|
+
return compareNats(aDigits, bDigits) || compareStrings(aSuffix, bSuffix);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return compareStrings(a, b);
|
|
47
|
+
};
|
|
48
|
+
harden(naturalCompare);
|
package/src/netstring.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export function netstringEncoderStream(): Transform;
|
|
|
11
11
|
* @returns {{ leftover: Buffer; payloads: Buffer[] }} zero or more decoded
|
|
12
12
|
* Buffers, one per netstring,
|
|
13
13
|
*/
|
|
14
|
-
export function decode(data: Buffer, optMaxChunkSize?: number
|
|
14
|
+
export function decode(data: Buffer, optMaxChunkSize?: number): {
|
|
15
15
|
leftover: Buffer;
|
|
16
16
|
payloads: Buffer[];
|
|
17
17
|
};
|
|
@@ -19,6 +19,6 @@ export function decode(data: Buffer, optMaxChunkSize?: number | undefined): {
|
|
|
19
19
|
* @param {number} [optMaxChunkSize]
|
|
20
20
|
* @returns {Transform}
|
|
21
21
|
*/
|
|
22
|
-
export function netstringDecoderStream(optMaxChunkSize?: number
|
|
22
|
+
export function netstringDecoderStream(optMaxChunkSize?: number): Transform;
|
|
23
23
|
import { Transform } from 'stream';
|
|
24
24
|
//# sourceMappingURL=netstring.d.ts.map
|
package/src/netstring.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"netstring.d.ts","sourceRoot":"","sources":["netstring.js"],"names":[],"mappings":"AASA;;;GAGG;AACH,6BAHW,MAAM,GACJ,MAAM,CAMlB;AAGD,oDAsBC;AAED;;;;;;GAMG;AACH,6BANW,MAAM,
|
|
1
|
+
{"version":3,"file":"netstring.d.ts","sourceRoot":"","sources":["netstring.js"],"names":[],"mappings":"AASA;;;GAGG;AACH,6BAHW,MAAM,GACJ,MAAM,CAMlB;AAGD,oDAsBC;AAED;;;;;;GAMG;AACH,6BANW,MAAM,oBAEN,MAAM,GACJ;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;CAAE,CAmCpD;AAED;;;GAGG;AAEH,yDAJW,MAAM,GACJ,SAAS,CAqCrB;0BAxHyB,QAAQ"}
|
package/src/netstring.js
CHANGED
|
@@ -89,6 +89,7 @@ export function decode(data, optMaxChunkSize) {
|
|
|
89
89
|
*/
|
|
90
90
|
// input is a byte pipe, output is a sequence of Buffers
|
|
91
91
|
export function netstringDecoderStream(optMaxChunkSize) {
|
|
92
|
+
/** @type {Buffer<ArrayBufferLike>} */
|
|
92
93
|
let buffered = Buffer.from('');
|
|
93
94
|
/**
|
|
94
95
|
* @param {Buffer} chunk
|
|
@@ -13,8 +13,8 @@ export default class BufferLineTransform extends Transform {
|
|
|
13
13
|
* @param {import('node:stream').TransformOptions &
|
|
14
14
|
* BufferLineTransformOptions} [options]
|
|
15
15
|
*/
|
|
16
|
-
constructor(options?:
|
|
17
|
-
_breakValue: string | number | Buffer
|
|
16
|
+
constructor(options?: import("node:stream").TransformOptions & BufferLineTransformOptions);
|
|
17
|
+
_breakValue: string | number | Buffer<ArrayBufferLike>;
|
|
18
18
|
_breakEncoding: BufferEncoding | undefined;
|
|
19
19
|
_breakLength: number;
|
|
20
20
|
/** @type {Buffer[]} */
|
|
@@ -34,7 +34,7 @@ export type BufferLineTransformOptions = {
|
|
|
34
34
|
* line break matcher for
|
|
35
35
|
* Buffer.indexOf() (default: 10)
|
|
36
36
|
*/
|
|
37
|
-
break?: string | number | Buffer | undefined;
|
|
37
|
+
break?: string | number | Buffer<ArrayBufferLike> | undefined;
|
|
38
38
|
/**
|
|
39
39
|
* if break is a string, the encoding
|
|
40
40
|
* to use
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buffer-line-transform.d.ts","sourceRoot":"","sources":["buffer-line-transform.js"],"names":[],"mappings":"AAKA;;;;;;GAMG;AAEH;IACE;;;;;;OAMG;IACH,
|
|
1
|
+
{"version":3,"file":"buffer-line-transform.d.ts","sourceRoot":"","sources":["buffer-line-transform.js"],"names":[],"mappings":"AAKA;;;;;;GAMG;AAEH;IACE;;;;;;OAMG;IACH,sBAHW,OAAO,aAAa,EAAE,gBAAgB,GAC5C,0BAA0B,EAyB9B;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,OAAO,aAAa,EAAE,iBAAiB,QAiDjD;IAeD,2BAA2B;IAC3B,iBADY,MAAM,QAOjB;CACF;;;;;;;;;;;;;0BAtHyB,aAAa"}
|
package/src/node/fs-stream.js
CHANGED
|
@@ -21,13 +21,13 @@ export const fsStreamReady = stream =>
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
const onReady = () => {
|
|
24
|
-
cleanup();
|
|
24
|
+
cleanup();
|
|
25
25
|
resolve();
|
|
26
26
|
};
|
|
27
27
|
|
|
28
28
|
/** @param {Error} err */
|
|
29
29
|
const onError = err => {
|
|
30
|
-
cleanup();
|
|
30
|
+
cleanup();
|
|
31
31
|
reject(err);
|
|
32
32
|
};
|
|
33
33
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shutdown.d.ts","sourceRoot":"","sources":["shutdown.js"],"names":[],"mappings":"AAKO;;
|
|
1
|
+
{"version":3,"file":"shutdown.d.ts","sourceRoot":"","sources":["shutdown.js"],"names":[],"mappings":"AAKO;;EA8DN;AAGM,wDAON"}
|
package/src/node/shutdown.js
CHANGED
|
@@ -22,7 +22,6 @@ export const makeFreshShutdown = (verbose = true) => {
|
|
|
22
22
|
process.off('SIGINT', shutdown);
|
|
23
23
|
process.off('SIGTERM', shutdown);
|
|
24
24
|
process.off('beforeExit', shutdown);
|
|
25
|
-
// eslint-disable-next-line no-use-before-define
|
|
26
25
|
process.off('uncaughtException', uncaughtShutdown);
|
|
27
26
|
verbose && console.error(`Shutting down cleanly...`);
|
|
28
27
|
const shutdowners = [...shutdownThunks.keys()];
|
|
@@ -28,4 +28,5 @@ 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 { ERef } from '@endo/far';
|
|
31
32
|
//# 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":"AAQA,4CAA4C;AAC5C,uCADW,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,CAMtC;AAQK,wDAFI,KAAK,OAAO,uBAAuB,EAAE,WAAW,CAAC;IA0CxD;;;;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;0BA1GnC,WAAW"}
|
package/src/priority-senders.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { Fail, q } from '@endo/errors';
|
|
2
2
|
import { E, Far } from '@endo/far';
|
|
3
3
|
|
|
4
|
+
/** @import {ERef} from '@endo/far'; */
|
|
5
|
+
/** @import {StorageNode} from './lib-chainStorage.js'; */
|
|
6
|
+
|
|
4
7
|
const PRIORITY_SENDERS_NAMESPACE_RE = /^[a-zA-Z0-9_-]{1,50}$/;
|
|
5
8
|
|
|
6
9
|
/** @type {(namespace: string) => string} */
|
package/src/queue.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export function makeWithQueue():
|
|
1
|
+
export function makeWithQueue(): (inner: T) => (...args: Parameters<T>) => Promise<Awaited<ReturnType<T>>>;
|
|
2
2
|
//# sourceMappingURL=queue.d.ts.map
|
package/src/queue.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["queue.js"],"names":[],"mappings":"AAQO,
|
|
1
|
+
{"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["queue.js"],"names":[],"mappings":"AAQO,kCA2BqB,OAFf,CAEoB,MAKH,GAAG,MAHlB,UAAU,CAAC,CAAC,CAGU,KAFpB,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAkB/C"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
export
|
|
2
|
-
/** @import {ERef} from '@endo/far' */
|
|
1
|
+
export function makeLimitedConsole(makeLogger: (level: string) => (...args: unknown[]) => void): LimitedConsole;
|
|
3
2
|
/**
|
|
4
3
|
* @template T
|
|
5
4
|
* @typedef {{ [KeyType in keyof T]: T[KeyType] } & {}} Simplify flatten the
|
|
@@ -31,14 +30,9 @@ export const BASIS_POINTS: 10000n;
|
|
|
31
30
|
* @type {<T extends {}>(unfulfilledTerms: T) => Promise<DeeplyAwaited<T>>}
|
|
32
31
|
*/
|
|
33
32
|
export const deeplyFulfilledObject: <T extends {}>(unfulfilledTerms: T) => Promise<DeeplyAwaited<T>>;
|
|
34
|
-
export function deepMapObject(obj: object, mapper: (value: any, name: string, record: object) => any): object;
|
|
35
33
|
export function PromiseAllOrErrors<T>(items: readonly (T | PromiseLike<T>)[]): Promise<T[]>;
|
|
36
34
|
export function aggregateTryFinally<T>(trier: () => Promise<T>, finalizer: (error?: unknown) => Promise<unknown>): ReturnType<() => Promise<T>>;
|
|
37
35
|
export function withDeferredCleanup<T>(fn: (addCleanup: (fn: (err?: unknown) => Promise<void>) => void) => Promise<T>): ReturnType<(addCleanup: (fn: (err?: unknown) => Promise<void>) => void) => Promise<T>>;
|
|
38
|
-
export function makeMeasureSeconds(currentTimeMillisec: typeof import("perf_hooks").performance.now): <T>(fn: () => Promise<T>) => Promise<{
|
|
39
|
-
result: T;
|
|
40
|
-
duration: number;
|
|
41
|
-
}>;
|
|
42
36
|
export function assertAllDefined<T extends Record<string, unknown>>(obj: T): asserts obj is AllDefined<T>;
|
|
43
37
|
export const forever: AsyncIterable<undefined>;
|
|
44
38
|
export function whileTrue<T>(produce: () => T): AsyncIterable<Awaited<T>>;
|
|
@@ -62,5 +56,6 @@ export type Callable = (...args: any[]) => any;
|
|
|
62
56
|
export type DeeplyAwaitedObject<T extends {}> = { [K in keyof T]: T[K] extends Callable ? T[K] : DeeplyAwaited<T[K]>; };
|
|
63
57
|
export type DeeplyAwaited<T> = T extends PromiseLike<any> ? Awaited<T> : T extends {} ? Simplify<DeeplyAwaitedObject<T>> : Awaited<T>;
|
|
64
58
|
export type AllDefined<T extends Record<string, unknown>> = { [P in keyof T]: Exclude<T[P], undefined>; };
|
|
59
|
+
import type { LimitedConsole } from './js-utils.js';
|
|
65
60
|
import type { ERef } from '@endo/far';
|
|
66
|
-
//# sourceMappingURL=utils.d.ts.map
|
|
61
|
+
//# sourceMappingURL=ses-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ses-utils.d.ts","sourceRoot":"","sources":["ses-utils.js"],"names":[],"mappings":"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"}
|
|
@@ -1,18 +1,32 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
// @jessie-check
|
|
3
|
+
/**
|
|
4
|
+
* @file Utility functions that are dependent upon a hardened environment,
|
|
5
|
+
* either directly or indirectly (e.g. by @endo imports).
|
|
6
|
+
*/
|
|
3
7
|
|
|
4
8
|
import { q, Fail, makeError, annotateError, X } from '@endo/errors';
|
|
5
9
|
import { deeplyFulfilled, isObject } from '@endo/marshal';
|
|
6
10
|
import { makePromiseKit } from '@endo/promise-kit';
|
|
7
11
|
import { makeQueue } from '@endo/stream';
|
|
8
12
|
import { asyncGenerate } from 'jessie.js';
|
|
13
|
+
import { logLevels } from './js-utils.js';
|
|
9
14
|
|
|
10
|
-
|
|
15
|
+
/** @import {LimitedConsole} from './js-utils.js'; */
|
|
11
16
|
|
|
12
|
-
|
|
17
|
+
const { fromEntries, keys, values } = Object;
|
|
13
18
|
|
|
14
19
|
/** @import {ERef} from '@endo/far' */
|
|
15
20
|
|
|
21
|
+
/** @param {(level: string) => (...args: unknown[]) => void} makeLogger */
|
|
22
|
+
export const makeLimitedConsole = makeLogger => {
|
|
23
|
+
const limitedConsole = /** @type {any} */ (
|
|
24
|
+
fromEntries(logLevels.map(level => [level, makeLogger(level)]))
|
|
25
|
+
);
|
|
26
|
+
return /** @type {LimitedConsole} */ (harden(limitedConsole));
|
|
27
|
+
};
|
|
28
|
+
harden(makeLimitedConsole);
|
|
29
|
+
|
|
16
30
|
/**
|
|
17
31
|
* @template T
|
|
18
32
|
* @typedef {{ [KeyType in keyof T]: T[KeyType] } & {}} Simplify flatten the
|
|
@@ -52,55 +66,6 @@ export const deeplyFulfilledObject = async obj => {
|
|
|
52
66
|
return deeplyFulfilled(obj);
|
|
53
67
|
};
|
|
54
68
|
|
|
55
|
-
/**
|
|
56
|
-
* @param {any} value
|
|
57
|
-
* @param {string | undefined} name
|
|
58
|
-
* @param {object | undefined} container
|
|
59
|
-
* @param {(value: any, name: string, record: object) => any} mapper
|
|
60
|
-
* @returns {any}
|
|
61
|
-
*/
|
|
62
|
-
const deepMapObjectInternal = (value, name, container, mapper) => {
|
|
63
|
-
if (container && typeof name === 'string') {
|
|
64
|
-
const mapped = mapper(value, name, container);
|
|
65
|
-
if (mapped !== value) {
|
|
66
|
-
return mapped;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
if (typeof value !== 'object' || !value) {
|
|
71
|
-
return value;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
let wasMapped = false;
|
|
75
|
-
const mappedEntries = Object.entries(value).map(([innerName, innerValue]) => {
|
|
76
|
-
const mappedInnerValue = deepMapObjectInternal(
|
|
77
|
-
innerValue,
|
|
78
|
-
innerName,
|
|
79
|
-
value,
|
|
80
|
-
mapper,
|
|
81
|
-
);
|
|
82
|
-
wasMapped ||= mappedInnerValue !== innerValue;
|
|
83
|
-
return [innerName, mappedInnerValue];
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
return wasMapped ? Object.fromEntries(mappedEntries) : value;
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Traverses a record object structure deeply, calling a replacer for each
|
|
91
|
-
* enumerable string property values of an object. If none of the values are
|
|
92
|
-
* changed, the original object is used as-is, maintaining its identity.
|
|
93
|
-
*
|
|
94
|
-
* When an object is found as a property value, the replacer is first called on
|
|
95
|
-
* it. If not replaced, the object is then traversed.
|
|
96
|
-
*
|
|
97
|
-
* @param {object} obj
|
|
98
|
-
* @param {(value: any, name: string, record: object) => any} mapper
|
|
99
|
-
* @returns {object}
|
|
100
|
-
*/
|
|
101
|
-
export const deepMapObject = (obj, mapper) =>
|
|
102
|
-
deepMapObjectInternal(obj, undefined, undefined, mapper);
|
|
103
|
-
|
|
104
69
|
/**
|
|
105
70
|
* Tolerate absence of AggregateError in e.g. xsnap.
|
|
106
71
|
*
|
|
@@ -184,27 +149,6 @@ export const withDeferredCleanup = async fn => {
|
|
|
184
149
|
return aggregateTryFinally(() => fn(addCleanup), finalizer);
|
|
185
150
|
};
|
|
186
151
|
|
|
187
|
-
/**
|
|
188
|
-
* Returns a function that uses a millisecond-based time-since-epoch capability
|
|
189
|
-
* (such as `performance.now`) to measure execution time of an async function
|
|
190
|
-
* and report the result in seconds to match our telemetry standard.
|
|
191
|
-
*
|
|
192
|
-
* @param {typeof import('perf_hooks').performance.now} currentTimeMillisec
|
|
193
|
-
* @returns {<T>(
|
|
194
|
-
* fn: () => Promise<T>,
|
|
195
|
-
* ) => Promise<{ result: T; duration: number }>}
|
|
196
|
-
*/
|
|
197
|
-
export const makeMeasureSeconds = currentTimeMillisec => {
|
|
198
|
-
/** @param {() => any} fn */
|
|
199
|
-
const measureSeconds = async fn => {
|
|
200
|
-
const t0 = currentTimeMillisec();
|
|
201
|
-
const result = await fn();
|
|
202
|
-
const durationMillisec = currentTimeMillisec() - t0;
|
|
203
|
-
return { result, duration: durationMillisec / 1000 };
|
|
204
|
-
};
|
|
205
|
-
return measureSeconds;
|
|
206
|
-
};
|
|
207
|
-
|
|
208
152
|
/**
|
|
209
153
|
* @template {Record<string, unknown>} T
|
|
210
154
|
* @typedef {{ [P in keyof T]: Exclude<T[P], undefined> }} AllDefined
|
|
@@ -9,6 +9,10 @@ export const defaultMarshaller: {
|
|
|
9
9
|
serialize: import("@endo/marshal").ToCapData<string>;
|
|
10
10
|
unserialize: import("@endo/marshal").FromCapData<string>;
|
|
11
11
|
};
|
|
12
|
+
export namespace defaultSerializer {
|
|
13
|
+
let parse: (text: string) => unknown;
|
|
14
|
+
let stringify: (obj: any) => string;
|
|
15
|
+
}
|
|
12
16
|
export const slotStringUnserialize: (capData: any) => any;
|
|
13
17
|
export function makeFakeStorageKit(rootPath: string, rootOptions?: Parameters<typeof makeChainStorageRoot>[2]): {
|
|
14
18
|
rootNode: import("@endo/exo").Guarded<{
|
|
@@ -20,14 +24,16 @@ export function makeFakeStorageKit(rootPath: string, rootOptions?: Parameters<ty
|
|
|
20
24
|
setValue(value: string): Promise<void>;
|
|
21
25
|
}>;
|
|
22
26
|
data: Map<string, string>;
|
|
27
|
+
updateNewCellBlockHeight: (blockHeight?: number) => void;
|
|
28
|
+
getValues: (path: string) => string[];
|
|
23
29
|
messages: StorageMessage[];
|
|
24
|
-
toStorage: ((message: StorageMessage) => string | number | any[] | {
|
|
30
|
+
toStorage: ((message: StorageMessage) => string | number | true | any[] | {
|
|
25
31
|
storeName: string;
|
|
26
32
|
storeSubkey: string;
|
|
27
|
-
} | null
|
|
33
|
+
} | null) & import("@endo/pass-style").RemotableObject<`Alleged: ${string}`> & import("@endo/eventual-send").RemotableBrand<{}, (message: StorageMessage) => string | number | true | any[] | {
|
|
28
34
|
storeName: string;
|
|
29
35
|
storeSubkey: string;
|
|
30
|
-
} | null
|
|
36
|
+
} | null>;
|
|
31
37
|
};
|
|
32
38
|
export function makeMockChainStorageRoot(): MockChainStorageRoot;
|
|
33
39
|
export function documentStorageSchema(t: import("ava").ExecutionContext<unknown>, storage: MockChainStorageRoot | FakeStorageKit, opts: ({
|
|
@@ -38,7 +44,9 @@ export function documentStorageSchema(t: import("ava").ExecutionContext<unknown>
|
|
|
38
44
|
}) & ({
|
|
39
45
|
pattern: string;
|
|
40
46
|
replacement: string;
|
|
41
|
-
} | {})
|
|
47
|
+
} | {}) & {
|
|
48
|
+
showValue?: (v: string) => unknown;
|
|
49
|
+
}): Promise<void>;
|
|
42
50
|
export type FakeStorageKit = ReturnType<typeof makeFakeStorageKit>;
|
|
43
51
|
export type MockChainStorageRootMethods = {
|
|
44
52
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage-test-utils.d.ts","sourceRoot":"","sources":["storage-test-utils.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"storage-test-utils.d.ts","sourceRoot":"","sources":["storage-test-utils.js"],"names":[],"mappings":"AAyBO,yCAHI,MAAM,UACN,MAAM,6GAGC;AAElB;;;GAGG;AACH;;;;;EAEG;;eAMU,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO;mBAEzB,CAAC,GAAG,EAAE,GAAG,KAAK,MAAM;;AA8CjC,8CAtBuB,GAAG,KAAK,GAAG,CAsB+B;AAU1D,6CAHI,MAAM,gBACN,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC,CAAC,CAAC;;;;;oBA+Fb,CAAC;;;;UAgDpB,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;;sBAd3B,MAAM,KACJ,MAAM,EAAE;;0BA9FP,cAAc;;;8IAAd,cAAc;;;;EAiH7B;AAoBM,4CADO,oBAAoB,CA6BjC;AAUM,yCAPI,OAAO,KAAK,EAAE,gBAAgB,CAAC,OAAO,CAAC,WACvC,oBAAoB,GAAG,cAAc,QACrC,CAAC;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,GAC9D,CAAK;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,GAAG,EAAE,CAAC,GAAG;IAChD,SAAS,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC;CACpC,iBAkDL;6BAxGa,UAAU,CAAC,OAAO,kBAAkB,CAAC;;;;;;;;aAIrC,CACT,IAAI,EAAE,MAAM,EACZ,UAAU,CAAC,EAAE,UAAU,EACvB,KAAK,CAAC,EAAE,MAAM,KACX,OAAO;UAKD,MAAM,MAAM,EAAE;;mCAEd,WAAW,GAAG,2BAA2B;qCAhQJ,uBAAuB;iCAOU,uBAAuB;oCAAvB,uBAAuB;gCAAvB,uBAAuB"}
|