@agoric/internal 0.3.3-u11.0 → 0.3.3-upgrade-16-dev-8879538.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/README.md +7 -2
  2. package/exported.js +2 -0
  3. package/package.json +32 -16
  4. package/src/batched-deliver.d.ts +6 -6
  5. package/src/batched-deliver.d.ts.map +1 -1
  6. package/src/batched-deliver.js +6 -3
  7. package/src/callback.d.ts +23 -16
  8. package/src/callback.d.ts.map +1 -1
  9. package/src/callback.js +19 -25
  10. package/src/config.d.ts +21 -12
  11. package/src/config.d.ts.map +1 -1
  12. package/src/config.js +10 -2
  13. package/src/debug.d.ts +1 -1
  14. package/src/index.d.ts +3 -0
  15. package/src/index.js +7 -1
  16. package/src/install-ses-debug.d.ts +2 -0
  17. package/src/install-ses-debug.d.ts.map +1 -0
  18. package/src/install-ses-debug.js +6 -0
  19. package/src/lib-chainStorage.d.ts +25 -45
  20. package/src/lib-chainStorage.d.ts.map +1 -1
  21. package/src/lib-chainStorage.js +16 -41
  22. package/src/lib-nodejs/engine-gc.d.ts +3 -0
  23. package/src/lib-nodejs/engine-gc.d.ts.map +1 -0
  24. package/src/lib-nodejs/engine-gc.js +22 -0
  25. package/src/lib-nodejs/gc-and-finalize.d.ts +2 -0
  26. package/src/lib-nodejs/gc-and-finalize.d.ts.map +1 -0
  27. package/src/lib-nodejs/gc-and-finalize.js +91 -0
  28. package/src/lib-nodejs/spawnSubprocessWorker.d.ts +15 -0
  29. package/src/lib-nodejs/spawnSubprocessWorker.d.ts.map +1 -0
  30. package/src/lib-nodejs/spawnSubprocessWorker.js +87 -0
  31. package/src/lib-nodejs/waitUntilQuiescent.d.ts +2 -0
  32. package/src/lib-nodejs/waitUntilQuiescent.d.ts.map +1 -0
  33. package/src/lib-nodejs/waitUntilQuiescent.js +18 -0
  34. package/src/lib-nodejs/worker-protocol.d.ts +4 -0
  35. package/src/lib-nodejs/worker-protocol.d.ts.map +1 -0
  36. package/src/lib-nodejs/worker-protocol.js +56 -0
  37. package/src/marshal.d.ts +19 -0
  38. package/src/marshal.d.ts.map +1 -0
  39. package/src/marshal.js +132 -0
  40. package/src/method-tools.d.ts +1 -0
  41. package/src/method-tools.d.ts.map +1 -1
  42. package/src/method-tools.js +12 -0
  43. package/src/netstring.d.ts +25 -0
  44. package/src/netstring.d.ts.map +1 -0
  45. package/src/netstring.js +127 -0
  46. package/src/node/buffer-line-transform.d.ts +2 -3
  47. package/src/node/buffer-line-transform.d.ts.map +1 -1
  48. package/src/node/createBundles.d.ts.map +1 -1
  49. package/src/node/createBundles.js +9 -2
  50. package/src/node/fs-stream.d.ts.map +1 -1
  51. package/src/node/fs-stream.js +1 -2
  52. package/src/priority-senders.d.ts +1 -1
  53. package/src/priority-senders.d.ts.map +1 -1
  54. package/src/queue.d.ts +1 -1
  55. package/src/queue.d.ts.map +1 -1
  56. package/src/queue.js +5 -6
  57. package/src/scratch.d.ts +1 -1
  58. package/src/scratch.d.ts.map +1 -1
  59. package/src/storage-test-utils.d.ts +34 -75
  60. package/src/storage-test-utils.d.ts.map +1 -1
  61. package/src/storage-test-utils.js +27 -14
  62. package/src/tagged.d.ts +155 -0
  63. package/src/tokens.d.ts +34 -0
  64. package/src/tokens.d.ts.map +1 -0
  65. package/src/tokens.js +35 -0
  66. package/src/typeGuards.d.ts +2 -0
  67. package/src/typeGuards.d.ts.map +1 -1
  68. package/src/typeGuards.js +8 -0
  69. package/src/types.d.ts +37 -0
  70. package/src/types.js +2 -0
  71. package/src/upgrade-api.d.ts +13 -4
  72. package/src/upgrade-api.d.ts.map +1 -1
  73. package/src/upgrade-api.js +26 -18
  74. package/src/utils.d.ts +5 -13
  75. package/src/utils.d.ts.map +1 -1
  76. package/src/utils.js +9 -164
  77. package/CHANGELOG.md +0 -106
@@ -0,0 +1,127 @@
1
+ /* global Buffer */
2
+ import { Fail } from '@agoric/assert';
3
+
4
+ // adapted from 'netstring-stream', https://github.com/tlivings/netstring-stream/
5
+ import { Transform } from 'stream';
6
+
7
+ const COLON = 58;
8
+ const COMMA = 44;
9
+
10
+ /**
11
+ * @param {Buffer} data
12
+ * @returns {Buffer} netstring-wrapped
13
+ */
14
+ export function encode(data) {
15
+ const prefix = Buffer.from(`${data.length}:`);
16
+ const suffix = Buffer.from(',');
17
+ return Buffer.concat([prefix, data, suffix]);
18
+ }
19
+
20
+ // input is a sequence of strings, output is a byte pipe
21
+ export function netstringEncoderStream() {
22
+ /**
23
+ *
24
+ * @this {{ push: (b: Buffer) => void }}
25
+ * @param {Buffer} chunk
26
+ * @param {BufferEncoding} encoding
27
+ * @param {*} callback
28
+ */
29
+ function transform(chunk, encoding, callback) {
30
+ if (!Buffer.isBuffer(chunk)) {
31
+ throw Error('stream requires Buffers');
32
+ }
33
+ let err;
34
+ try {
35
+ this.push(encode(chunk));
36
+ } catch (e) {
37
+ err = e;
38
+ }
39
+ callback(err);
40
+ }
41
+ // (maybe empty) Buffer in, Buffer out. We use writableObjectMode to
42
+ // indicate that empty input buffers are important
43
+ return new Transform({ transform, writableObjectMode: true });
44
+ }
45
+
46
+ /**
47
+ *
48
+ * @param {Buffer} data containing zero or more netstrings and maybe some
49
+ * leftover bytes
50
+ * @param {number} [optMaxChunkSize]
51
+ * @returns {{ leftover: Buffer, payloads: Buffer[] }} zero or more decoded Buffers, one per netstring,
52
+ */
53
+ export function decode(data, optMaxChunkSize) {
54
+ // TODO: it would be more efficient to accumulate pending data in an array,
55
+ // rather than doing a concat each time
56
+ let start = 0;
57
+ const payloads = [];
58
+
59
+ for (;;) {
60
+ const colon = data.indexOf(COLON, start);
61
+ if (colon === -1) {
62
+ break; // still waiting for `${LENGTH}:`
63
+ }
64
+ const sizeString = data.toString('utf-8', start, colon);
65
+ const size = parseInt(sizeString, 10);
66
+ if (!(size > -1)) {
67
+ // reject NaN, all negative numbers
68
+ Fail`unparsable size ${sizeString}, should be integer`;
69
+ }
70
+ if (optMaxChunkSize) {
71
+ size <= optMaxChunkSize ||
72
+ Fail`size ${size} exceeds limit of ${optMaxChunkSize}`;
73
+ }
74
+ if (data.length < colon + 1 + size + 1) {
75
+ break; // still waiting for `${DATA}.`
76
+ }
77
+ data[colon + 1 + size] === COMMA ||
78
+ Fail`malformed netstring: not terminated by comma`;
79
+ payloads.push(data.subarray(colon + 1, colon + 1 + size));
80
+ start = colon + 1 + size + 1;
81
+ }
82
+
83
+ const leftover = data.subarray(start);
84
+ return { leftover, payloads };
85
+ }
86
+
87
+ /**
88
+ *
89
+ * @param {number} [optMaxChunkSize ]
90
+ * @returns {Transform}
91
+ */
92
+ // input is a byte pipe, output is a sequence of Buffers
93
+ export function netstringDecoderStream(optMaxChunkSize) {
94
+ let buffered = Buffer.from('');
95
+ /**
96
+ *
97
+ * @this {{ push: (b: Buffer) => void }}
98
+ * @param {Buffer} chunk
99
+ * @param {BufferEncoding} encoding
100
+ * @param {*} callback
101
+ */
102
+ function transform(chunk, encoding, callback) {
103
+ if (!Buffer.isBuffer(chunk)) {
104
+ throw Error('stream requires Buffers');
105
+ }
106
+ buffered = Buffer.concat([buffered, chunk]);
107
+ let err;
108
+ try {
109
+ const { leftover, payloads } = decode(buffered, optMaxChunkSize);
110
+ buffered = leftover;
111
+ for (let i = 0; i < payloads.length; i += 1) {
112
+ this.push(payloads[i]);
113
+ }
114
+ } catch (e) {
115
+ err = e;
116
+ }
117
+ // we buffer all data internally, to accommodate netstrings larger than
118
+ // Transform's default buffer size, and callback() indicates that we've
119
+ // consumed the input
120
+ callback(err);
121
+ }
122
+
123
+ // Buffer in, Buffer out, except that each output Buffer is precious, even
124
+ // empty ones, and without readableObjectMode the Stream will discard empty
125
+ // buffers
126
+ return new Transform({ transform, readableObjectMode: true });
127
+ }
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  /**
3
2
  * @typedef {object} BufferLineTransformOptions
4
3
  * @property {Buffer | string | number} [break] line break matcher for Buffer.indexOf() (default: 10)
@@ -23,7 +22,7 @@ export default class BufferLineTransform extends Transform {
23
22
  * @param {BufferEncoding | 'buffer'} encoding
24
23
  * @param {import('node:stream').TransformCallback} cb
25
24
  */
26
- override _transform(chunk: any, encoding: BufferEncoding | 'buffer', cb: import('node:stream').TransformCallback): void;
25
+ override _transform(chunk: any, encoding: BufferEncoding | "buffer", cb: import("node:stream").TransformCallback): void;
27
26
  /** @param {Buffer} line */
28
27
  _writeItem(line: Buffer): void;
29
28
  }
@@ -37,5 +36,5 @@ export type BufferLineTransformOptions = {
37
36
  */
38
37
  breakEncoding?: BufferEncoding | undefined;
39
38
  };
40
- import { Transform } from "stream";
39
+ import { Transform } from 'node:stream';
41
40
  //# 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;;;;GAIG;AAEH;IACE;;;;;OAKG;IACH,oGAuBC;IAhBC,sCAAmC;IACnC,2CAAmC;IAWnC,qBAA+B;IAE/B,4BAA4B;IAC5B,SADW,MAAM,MAAM,CAAC,CACP;IAGnB;;;;;OAKG;IACH,2BAJW,GAAG,YACH,cAAc,GAAG,QAAQ,MACzB,OAAO,aAAa,EAAE,iBAAiB,QAgDjD;IAeD,2BAA2B;IAC3B,iBADY,MAAM,QAOjB;CACF"}
1
+ {"version":3,"file":"buffer-line-transform.d.ts","sourceRoot":"","sources":["buffer-line-transform.js"],"names":[],"mappings":"AAKA;;;;GAIG;AAEH;IACE;;;;;OAKG;IACH,oGAuBC;IAhBC,sCAAmC;IACnC,2CAAmC;IAWnC,qBAA+B;IAE/B,4BAA4B;IAC5B,SADW,KAAK,CAAC,MAAM,CAAC,CACP;IAGnB;;;;;OAKG;IACH,2BAJW,GAAG,YACH,cAAc,GAAG,QAAQ,MACzB,OAAO,aAAa,EAAE,iBAAiB,QAgDjD;IAeD,2BAA2B;IAC3B,iBADY,MAAM,QAOjB;CACF;;;;;;;;;;;0BAnHyB,aAAa"}
@@ -1 +1 @@
1
- {"version":3,"file":"createBundles.d.ts","sourceRoot":"","sources":["createBundles.js"],"names":[],"mappings":"AAUO,6EAyBN;AAEM,mFAMN;AAEM,iGAkCN"}
1
+ {"version":3,"file":"createBundles.d.ts","sourceRoot":"","sources":["createBundles.js"],"names":[],"mappings":"AAWO,6EA+BN;AAEM,mFAMN;AAEM,iGAkCN"}
@@ -1,3 +1,4 @@
1
+ /* global process */
1
2
  // Use modules not prefixed with `node:` since some deploy scripts may
2
3
  // still be running in esm emulation
3
4
  import path from 'path';
@@ -22,14 +23,20 @@ export const createBundlesFromAbsolute = async sourceBundles => {
22
23
  }
23
24
  const bundle = match[1];
24
25
 
25
- const args = cacheToArgs.get(cache) || ['--to', cache];
26
+ const args = cacheToArgs.get(cache) || ['--cache-js', cache];
26
27
  args.push(srcPath, bundle);
27
28
  cacheToArgs.set(cache, args);
28
29
  }
29
30
 
30
31
  for (const args of cacheToArgs.values()) {
31
32
  console.log(BUNDLE_SOURCE_PROGRAM, ...args);
32
- const { status } = spawnSync(prog, args, { stdio: 'inherit' });
33
+ const env = /** @type {NodeJS.ProcessEnv} */ (
34
+ /** @type {unknown} */ ({
35
+ __proto__: process.env,
36
+ LOCKDOWN_OVERRIDE_TAMING: 'severe',
37
+ })
38
+ );
39
+ const { status } = spawnSync(prog, args, { stdio: 'inherit', env });
33
40
  status === 0 ||
34
41
  Fail`${q(BUNDLE_SOURCE_PROGRAM)} failed with status ${q(status)}`;
35
42
  }
@@ -1 +1 @@
1
- {"version":3,"file":"fs-stream.d.ts","sourceRoot":"","sources":["fs-stream.js"],"names":[],"mappings":"AAQO,sCAHI,OAAO,IAAI,EAAE,UAAU,GAAG,OAAO,IAAI,EAAE,WAAW,GAChD,QAAQ,IAAI,CAAC,CAgCtB;AAQG,6CADK,MAAM,GAAG,SAAS,GAAG,IAAI;;;;eA2DpC;6BA5Da,YAAY,QAAQ,WAAW,yBAAyB,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"fs-stream.d.ts","sourceRoot":"","sources":["fs-stream.js"],"names":[],"mappings":"AAOO,sCAHI,OAAO,IAAI,EAAE,UAAU,GAAG,OAAO,IAAI,EAAE,WAAW,GAChD,OAAO,CAAC,IAAI,CAAC,CAgCtB;AAQG,6CADK,MAAM,GAAG,SAAS,GAAG,IAAI;;;;eA2DpC;6BA5Da,WAAW,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC,CAAC"}
@@ -1,6 +1,5 @@
1
1
  import { createWriteStream } from 'node:fs';
2
2
  import { open } from 'node:fs/promises';
3
- import { makeAggregateError } from '../utils.js';
4
3
 
5
4
  /**
6
5
  * @param {import("fs").ReadStream | import("fs").WriteStream} stream
@@ -78,7 +77,7 @@ export const makeFsStreamWriter = async filePath => {
78
77
  Promise.reject(
79
78
  written.then(
80
79
  () => err,
81
- writtenError => makeAggregateError([err, writtenError]),
80
+ writtenError => AggregateError([err, writtenError]),
82
81
  ),
83
82
  ),
84
83
  );
@@ -13,7 +13,7 @@ export function makePrioritySendersManager(sendersNode: ERef<import("./lib-chain
13
13
  * @returns {Promise<void>}
14
14
  */
15
15
  remove: (rawNamespace: string, address: string) => Promise<void>;
16
- } & import("@endo/eventual-send").RemotableBrand<{}, {
16
+ } & import("@endo/pass-style").RemotableObject<`Alleged: ${string}`> & import("@endo/eventual-send").RemotableBrand<{}, {
17
17
  /**
18
18
  * @param {string} rawNamespace
19
19
  * @param {string} address
@@ -1 +1 @@
1
- {"version":3,"file":"priority-senders.d.ts","sourceRoot":"","sources":["priority-senders.js"],"names":[],"mappings":"AAMA,4CAA4C;AAC5C,mDADuB,MAAM,KAAK,MAAM,CAMtC;AAQK;IAoCH;;;;OAIG;wBAHQ,MAAM,WACN,MAAM,KACJ,QAAQ,IAAI,CAAC;IAe1B;;;;OAIG;2BAHQ,MAAM,WACN,MAAM,KACJ,QAAQ,IAAI,CAAC;;IArB1B;;;;OAIG;wBAHQ,MAAM,WACN,MAAM,KACJ,QAAQ,IAAI,CAAC;IAe1B;;;;OAIG;2BAHQ,MAAM,WACN,MAAM,KACJ,QAAQ,IAAI,CAAC;GAuB7B;qCAGa,WAAW,iCAAiC,CAAC"}
1
+ {"version":3,"file":"priority-senders.d.ts","sourceRoot":"","sources":["priority-senders.js"],"names":[],"mappings":"AAMA,4CAA4C;AAC5C,uCADW,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,CAMtC;AAQK,wDAFI,IAAI,CAAC,OAAO,uBAAuB,EAAE,WAAW,CAAC;IAsCxD;;;;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"}
package/src/queue.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export function makeWithQueue(): <T extends any[], R>(inner: (...args: T) => Promise<R>) => (...args: T) => Promise<R>;
1
+ export function makeWithQueue(): <T extends (...args: any[]) => any>(inner: T) => (...args: Parameters<T>) => Promise<Awaited<ReturnType<T>>>;
2
2
  //# sourceMappingURL=queue.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["queue.js"],"names":[],"mappings":"AAQO,uHAiDN"}
1
+ {"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["queue.js"],"names":[],"mappings":"AAQO,kCA8BqC,CAAC,mBANnB,GAAG,EAAE,KAAK,GAAG,SAMK,CAAC,AAL/B,eAIC,UAAU,CACmB,CAAC,AADlB,CAAC,KACX,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAkB/C"}
package/src/queue.js CHANGED
@@ -16,7 +16,7 @@ export const makeWithQueue = () => {
16
16
  }
17
17
  const [thunk, resolve, reject] = queue[0];
18
18
  // Run the thunk in a new turn.
19
- Promise.resolve()
19
+ void Promise.resolve()
20
20
  .then(thunk)
21
21
  // Resolve or reject our caller with the thunk's value.
22
22
  .then(resolve, reject)
@@ -30,14 +30,13 @@ export const makeWithQueue = () => {
30
30
  };
31
31
 
32
32
  /**
33
- * @template {any[]} T
34
- * @template R
35
- * @param {(...args: T) => Promise<R>} inner
33
+ * @template {(...args: any[]) => any} T
34
+ * @param {T} inner
36
35
  */
37
36
  return function withQueue(inner) {
38
37
  /**
39
- * @param {T} args
40
- * @returns {Promise<R>}
38
+ * @param {Parameters<T>} args
39
+ * @returns {Promise<Awaited<ReturnType<T>>>}
41
40
  */
42
41
  return function queueCall(...args) {
43
42
  // Curry the arguments into the inner function, and
package/src/scratch.d.ts CHANGED
@@ -6,7 +6,7 @@ export default function makeScratchPad(): {
6
6
  keys: () => Promise<any[]>;
7
7
  list: () => Promise<any[]>;
8
8
  set: (keyP: any, objP: any) => Promise<any>;
9
- } & import("@endo/eventual-send").RemotableBrand<{}, {
9
+ } & import("@endo/pass-style").RemotableObject<`Alleged: ${string}`> & import("@endo/eventual-send").RemotableBrand<{}, {
10
10
  delete: (keyP: any) => Promise<void>;
11
11
  get: (keyP: any) => Promise<any>;
12
12
  lookup: (...path: any[]) => any;
@@ -1 +1 @@
1
- {"version":3,"file":"scratch.d.ts","sourceRoot":"","sources":["scratch.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;GAgDC;yBACa,WAAW,qBAAqB,CAAC"}
1
+ {"version":3,"file":"scratch.d.ts","sourceRoot":"","sources":["scratch.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;GAgDC;yBACa,UAAU,CAAC,OAAO,cAAc,CAAC"}
@@ -1,99 +1,58 @@
1
- export function slotToRemotable(_slotId: string, iface?: string): import("@endo/eventual-send").RemotableBrand<{}, {}>;
1
+ export function slotToRemotable(_slotId: string, iface?: string): import("@endo/marshal").RemotableObject<string> & import("@endo/eventual-send").RemotableBrand<{}, {}>;
2
2
  /**
3
3
  * A basic marshaller whose unserializer produces Remotables. It can
4
4
  * only serialize plain data, not Remotables.
5
5
  */
6
6
  export const defaultMarshaller: {
7
- toCapData: import("@endo/marshal/src/marshal.js").ToCapData<string>;
8
- fromCapData: import("@endo/marshal/src/marshal.js").FromCapData<string>;
9
- serialize: import("@endo/marshal/src/marshal.js").ToCapData<string>;
10
- unserialize: import("@endo/marshal/src/marshal.js").FromCapData<string>;
7
+ toCapData: import("@endo/marshal").ToCapData<string>;
8
+ fromCapData: import("@endo/marshal").FromCapData<string>;
9
+ serialize: import("@endo/marshal").ToCapData<string>;
10
+ unserialize: import("@endo/marshal").FromCapData<string>;
11
11
  };
12
- export function slotStringUnserialize(capData: any): any;
13
- export function makeFakeStorageKit(rootPath: string, rootOptions?: [handleStorageMessage: (message: import("./lib-chainStorage.js").StorageMessage) => any, rootPath: string, rootOptions?: {
14
- sequence?: boolean | undefined;
15
- } | undefined][2]): {
16
- rootNode: {
12
+ export const slotStringUnserialize: (capData: any) => any;
13
+ export function makeFakeStorageKit(rootPath: string, rootOptions?: Parameters<typeof makeChainStorageRoot>[2]): {
14
+ rootNode: import("@endo/exo").Guarded<{
17
15
  getPath(): string;
18
- getStoreKey(): Promise<import("./lib-chainStorage.js").VStorageKey>;
16
+ getStoreKey(): Promise<globalThis.VStorageKey>;
19
17
  makeChildNode(name: string, childNodeOptions?: {
20
- sequence?: boolean | undefined;
21
- } | undefined): import("./lib-chainStorage.js").StorageNode;
22
- setValue(value: string): Promise<void>;
23
- } & import("@endo/eventual-send").RemotableBrand<{}, {
24
- getPath(): string;
25
- getStoreKey(): Promise<import("./lib-chainStorage.js").VStorageKey>;
26
- makeChildNode(name: string, childNodeOptions?: {
27
- sequence?: boolean | undefined;
28
- } | undefined): import("./lib-chainStorage.js").StorageNode;
18
+ sequence?: boolean;
19
+ }): StorageNode;
29
20
  setValue(value: string): Promise<void>;
30
21
  }>;
31
22
  data: Map<string, string>;
32
- messages: import("./lib-chainStorage.js").StorageMessage[];
33
- toStorage: (message: import('../src/lib-chainStorage.js').StorageMessage) => string | number | any[] | {
23
+ messages: StorageMessage[];
24
+ toStorage: (message: StorageMessage) => string | number | any[] | {
34
25
  storeName: string;
35
26
  storeSubkey: string;
36
27
  } | null | undefined;
37
28
  };
38
- export function makeMockChainStorageRoot(): {
39
- /**
40
- * Defaults to deserializing slot references into plain Remotable
41
- * objects having the specified interface name (as from `Far(iface)`),
42
- * but can accept a different marshaller for producing Remotables
43
- * that e.g. embed the slot string in their iface name.
44
- *
45
- * @param {string} path
46
- * @param {import('./lib-chainStorage.js').Marshaller} marshaller
47
- * @returns {unknown}
48
- */
49
- getBody: (path: string, marshaller?: import('./lib-chainStorage.js').Marshaller) => unknown;
50
- keys: () => string[];
51
- getPath(): string;
52
- getStoreKey(): Promise<import("./lib-chainStorage.js").VStorageKey>;
53
- makeChildNode(name: string, childNodeOptions?: {
54
- sequence?: boolean | undefined;
55
- } | undefined): import("./lib-chainStorage.js").StorageNode;
56
- setValue(value: string): Promise<void>;
57
- } & import("@endo/eventual-send").RemotableBrand<{}, {
58
- /**
59
- * Defaults to deserializing slot references into plain Remotable
60
- * objects having the specified interface name (as from `Far(iface)`),
61
- * but can accept a different marshaller for producing Remotables
62
- * that e.g. embed the slot string in their iface name.
63
- *
64
- * @param {string} path
65
- * @param {import('./lib-chainStorage.js').Marshaller} marshaller
66
- * @returns {unknown}
67
- */
68
- getBody: (path: string, marshaller?: import('./lib-chainStorage.js').Marshaller) => unknown;
69
- keys: () => string[];
70
- getPath(): string;
71
- getStoreKey(): Promise<import("./lib-chainStorage.js").VStorageKey>;
72
- makeChildNode(name: string, childNodeOptions?: {
73
- sequence?: boolean | undefined;
74
- } | undefined): import("./lib-chainStorage.js").StorageNode;
75
- setValue(value: string): Promise<void>;
76
- }>;
29
+ export function makeMockChainStorageRoot(): MockChainStorageRoot;
77
30
  /**
78
31
  * A map corresponding with a total function such that `get(key)`
79
32
  * is assumed to always succeed.
80
33
  */
81
- export type TotalMap<K, V> = {
82
- [Symbol.iterator]: () => IterableIterator<[K, V]>;
83
- [Symbol.toStringTag]: string;
84
- entries: () => IterableIterator<[K, V]>;
85
- keys: () => IterableIterator<K>;
86
- values: () => IterableIterator<V>;
87
- has: (key: K) => boolean;
88
- size: number;
89
- set: (key: K, value: V) => Map<K, V>;
90
- clear: () => void;
91
- delete: (key: K) => boolean;
92
- forEach: (callbackfn: (value: V, key: K, map: Map<K, V>) => void, thisArg?: any) => void;
93
- } & {
34
+ export type TotalMap<K, V> = { [k in Exclude<keyof Map<K, V>, "get">]: Map<K, V>[k]; } & {
94
35
  get: (key: K) => V;
95
36
  };
96
37
  export type TotalMapFrom<T> = T extends Map<infer K, infer V> ? TotalMap<K, V> : never;
97
38
  export type FakeStorageKit = ReturnType<typeof makeFakeStorageKit>;
98
- export type MockChainStorageRoot = ReturnType<typeof makeMockChainStorageRoot>;
39
+ export type MockChainStorageRootMethods = {
40
+ /**
41
+ * Defaults to deserializing slot references into plain Remotable
42
+ * objects having the specified interface name (as from `Far(iface)`),
43
+ * but can accept a different marshaller for producing Remotables
44
+ * that e.g. embed the slot string in their iface name.
45
+ */
46
+ getBody: (path: string, marshaller?: {
47
+ toCapData: import("@endo/marshal").ToCapData<unknown>;
48
+ fromCapData: import("@endo/marshal").FromCapData<unknown>;
49
+ serialize: import("@endo/marshal").ToCapData<unknown>;
50
+ unserialize: import("@endo/marshal").FromCapData<unknown>;
51
+ } | undefined, index?: number) => unknown;
52
+ keys: () => string[];
53
+ };
54
+ export type MockChainStorageRoot = StorageNode & MockChainStorageRootMethods;
55
+ import { makeChainStorageRoot } from './lib-chainStorage.js';
56
+ import type { StorageNode } from './lib-chainStorage.js';
57
+ import type { StorageMessage } from './lib-chainStorage.js';
99
58
  //# sourceMappingURL=storage-test-utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"storage-test-utils.d.ts","sourceRoot":"","sources":["storage-test-utils.js"],"names":[],"mappings":"AAkCO,yCAHI,MAAM,UACN,MAAM,wDAGC;AAElB;;;GAGG;AACH;;;;;EAEG;AAsBW,+CAAU,GAAG,GAAK,GAAG,CAAA;AAgC5B,6CAHI,MAAM,gBACN;;eAAwC,CAAC,CAAC;;;;;;;;;;;;;;;;;;yBAyBvC,OAAO,4BAA4B,EAAE,cAAc;;;;EAoFhE;AAIM;IAIH;;;;;;;;;OASG;oBAHQ,MAAM,eACN,OAAO,uBAAuB,EAAE,UAAU,KACxC,OAAO;;;;;;;;;IARpB;;;;;;;;;OASG;oBAHQ,MAAM,eACN,OAAO,uBAAuB,EAAE,UAAU,KACxC,OAAO;;;;;;;;GAWvB;;;;;;;;;;;;;;;;;;eAnNiF,CAAC,KAAK,CAAC;;;6BA0L3E,WAAY,yBAAyB,CAAC;mCA0BtC,WAAW,+BAA+B,CAAC"}
1
+ {"version":3,"file":"storage-test-utils.d.ts","sourceRoot":"","sources":["storage-test-utils.js"],"names":[],"mappings":"AAmCO,yCAHI,MAAM,UACN,MAAM,0GAGC;AAElB;;;GAGG;AACH;;;;;EAEG;AA4CH,8CAtBwB,GAAG,KAAK,GAAG,CAsB8B;AAU1D,6CAHI,MAAM,gBACN,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC,CAAC,CAAC;;;;uDA+FtC;YAAE,QAAQ,CAAC,UAAS;SAAC;;;UAUf,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;;;;;;EAIvC;AAgBM,4CADO,oBAAoB,CAyBjC;;;;;qBAhOiF,CAAC,EAAK,CAAC,IAA5E,GAAE,CAAC,IAAI,OAAO,CAAC,MAAM,GAAG,CAA6C,CAAC,AAA5C,EAAiD,CAAC,AAA/C,CAAC,EAAE,KAAK,CAAC,GAAG,GAAG,CAAyB,CAAC,AAAxB,EAA6B,CAAC,AAA3B,CAAC,CAAC,CAAC,CAAC,GAAC,GAAG;IAAC,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,CAAA;CAAC;yBAI7E,CAAC,IAAD,CAAC,SAAS,GAAG,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,KAAK;6BAsLvD,UAAU,CAAE,OAAO,kBAAkB,CAAC;;;;;;;;oBAI/B,MAAM;;;;;2BAAmC,MAAM,KAAK,OAAO;UAKlE,MAAM,MAAM,EAAE;;;qCAnNuB,uBAAuB;iCAIF,uBAAuB;oCAAvB,uBAAuB"}
@@ -1,14 +1,15 @@
1
1
  // @ts-check
2
2
  import { Far } from '@endo/far';
3
3
  import { makeMarshal, Remotable } from '@endo/marshal';
4
+ import { unmarshalFromVstorage } from './marshal.js';
4
5
  import { makeTracer } from './debug.js';
5
- import {
6
- isStreamCell,
7
- makeChainStorageRoot,
8
- unmarshalFromVstorage,
9
- } from './lib-chainStorage.js';
6
+ import { isStreamCell, makeChainStorageRoot } from './lib-chainStorage.js';
10
7
  import { bindAllMethods } from './method-tools.js';
11
8
 
9
+ /**
10
+ * @import {Marshaller, StorageEntry, StorageMessage, StorageNode} from './lib-chainStorage.js';
11
+ */
12
+
12
13
  const { Fail } = assert;
13
14
 
14
15
  const trace = makeTracer('StorTU', false);
@@ -116,10 +117,10 @@ export const makeFakeStorageKit = (rootPath, rootOptions) => {
116
117
  }
117
118
  return childEntries;
118
119
  };
119
- /** @type {import('../src/lib-chainStorage.js').StorageMessage[]} */
120
+ /** @type {StorageMessage[]} */
120
121
  const messages = [];
121
- /** @param {import('../src/lib-chainStorage.js').StorageMessage} message */
122
- // eslint-disable-next-line consistent-return
122
+ /** @param {StorageMessage} message */
123
+
123
124
  const toStorage = message => {
124
125
  messages.push(message);
125
126
  switch (message.method) {
@@ -146,7 +147,7 @@ export const makeFakeStorageKit = (rootPath, rootOptions) => {
146
147
  case 'set':
147
148
  case 'setWithoutNotify': {
148
149
  trace('toStorage set', message);
149
- /** @type {import('../src/lib-chainStorage.js').StorageEntry[]} */
150
+ /** @type {StorageEntry[]} */
150
151
  const newEntries = message.args;
151
152
  for (const [key, value] of newEntries) {
152
153
  if (value != null) {
@@ -159,7 +160,7 @@ export const makeFakeStorageKit = (rootPath, rootOptions) => {
159
160
  }
160
161
  case 'append': {
161
162
  trace('toStorage append', message);
162
- /** @type {import('../src/lib-chainStorage.js').StorageEntry[]} */
163
+ /** @type {StorageEntry[]} */
163
164
  const newEntries = message.args;
164
165
  for (const [key, value] of newEntries) {
165
166
  value != null || Fail`attempt to append with no value`;
@@ -206,6 +207,18 @@ export const makeFakeStorageKit = (rootPath, rootOptions) => {
206
207
  harden(makeFakeStorageKit);
207
208
  /** @typedef {ReturnType< typeof makeFakeStorageKit>} FakeStorageKit */
208
209
 
210
+ /**
211
+ * @typedef MockChainStorageRootMethods
212
+ * @property {(path: string, marshaller?: Marshaller, index?: number) => unknown} getBody
213
+ * Defaults to deserializing slot references into plain Remotable
214
+ * objects having the specified interface name (as from `Far(iface)`),
215
+ * but can accept a different marshaller for producing Remotables
216
+ * that e.g. embed the slot string in their iface name.
217
+ * @property {() => string[]} keys
218
+ */
219
+ /** @typedef {StorageNode & MockChainStorageRootMethods} MockChainStorageRoot */
220
+
221
+ /** @returns {MockChainStorageRoot} */
209
222
  export const makeMockChainStorageRoot = () => {
210
223
  const { rootNode, data } = makeFakeStorageKit('mockChainStorageRoot');
211
224
  return Far('mockChainStorage', {
@@ -217,17 +230,17 @@ export const makeMockChainStorageRoot = () => {
217
230
  * that e.g. embed the slot string in their iface name.
218
231
  *
219
232
  * @param {string} path
220
- * @param {import('./lib-chainStorage.js').Marshaller} marshaller
233
+ * @param {Marshaller} marshaller
234
+ * @param {number} [index]
221
235
  * @returns {unknown}
222
236
  */
223
- getBody: (path, marshaller = defaultMarshaller) => {
237
+ getBody: (path, marshaller = defaultMarshaller, index = -1) => {
224
238
  data.size || Fail`no data in storage`;
225
239
  /** @type {ReturnType<typeof import('@endo/marshal').makeMarshal>['fromCapData']} */
226
240
  const fromCapData = (...args) =>
227
241
  Reflect.apply(marshaller.fromCapData, marshaller, args);
228
- return unmarshalFromVstorage(data, path, fromCapData);
242
+ return unmarshalFromVstorage(data, path, fromCapData, index);
229
243
  },
230
244
  keys: () => [...data.keys()],
231
245
  });
232
246
  };
233
- /** @typedef {ReturnType<typeof makeMockChainStorageRoot>} MockChainStorageRoot */