@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
package/src/utils.js CHANGED
@@ -1,156 +1,18 @@
1
1
  // @ts-check
2
2
  // @jessie-check
3
3
 
4
- import { E } from '@endo/far';
5
4
  import { deeplyFulfilled, isObject } from '@endo/marshal';
6
- import { isPromise, makePromiseKit } from '@endo/promise-kit';
5
+ import { makePromiseKit } from '@endo/promise-kit';
7
6
  import { makeQueue } from '@endo/stream';
8
- import { asyncGenerate, makeSet } from 'jessie.js';
7
+ import { asyncGenerate } from 'jessie.js';
9
8
 
10
- const { entries, fromEntries, keys, values } = Object;
11
- const { ownKeys } = Reflect;
9
+ const { fromEntries, keys, values } = Object;
12
10
 
13
- const { details: X, quote: q, Fail } = assert;
11
+ const { quote: q, Fail } = assert;
14
12
 
15
13
  export const BASIS_POINTS = 10_000n;
16
14
 
17
- /** @template T @typedef {import('@endo/eventual-send').ERef<T>} ERef<T> */
18
-
19
- /**
20
- * Throws if multiple entries use the same property name. Otherwise acts
21
- * like `Object.fromEntries` but hardens the result.
22
- * Use it to protect from property names computed from user-provided data.
23
- *
24
- * @template K,V
25
- * @param {Iterable<[K,V]>} allEntries
26
- * @returns {{[k: K]: V}}
27
- */
28
- export const fromUniqueEntries = allEntries => {
29
- const entriesArray = [...allEntries];
30
- const result = harden(fromEntries(entriesArray));
31
- if (ownKeys(result).length === entriesArray.length) {
32
- return result;
33
- }
34
- const names = makeSet();
35
- for (const [name, _] of entriesArray) {
36
- if (names.has(name)) {
37
- Fail`collision on property name ${q(name)}: ${entriesArray}`;
38
- }
39
- names.add(name);
40
- }
41
- throw Fail`internal: failed to create object from unique entries`;
42
- };
43
- harden(fromUniqueEntries);
44
-
45
- /**
46
- * By analogy with how `Array.prototype.map` will map the elements of
47
- * an array to transformed elements of an array of the same shape,
48
- * `objectMap` will do likewise for the string-named own enumerable
49
- * properties of an object.
50
- *
51
- * Typical usage applies `objectMap` to a CopyRecord, i.e.,
52
- * an object for which `passStyleOf(original) === 'copyRecord'`. For these,
53
- * none of the following edge cases arise. The result will be a CopyRecord
54
- * with exactly the same property names, whose values are the mapped form of
55
- * the original's values.
56
- *
57
- * When the original is not a CopyRecord, some edge cases to be aware of
58
- * * No matter how mutable the original object, the returned object is
59
- * hardened.
60
- * * Only the string-named enumerable own properties of the original
61
- * are mapped. All other properties are ignored.
62
- * * If any of the original properties were accessors, `Object.entries`
63
- * will cause its `getter` to be called and will use the resulting
64
- * value.
65
- * * No matter whether the original property was an accessor, writable,
66
- * or configurable, all the properties of the returned object will be
67
- * non-writable, non-configurable, data properties.
68
- * * No matter what the original object may have inherited from, and
69
- * no matter whether it was a special kind of object such as an array,
70
- * the returned object will always be a plain object inheriting directly
71
- * from `Object.prototype` and whose state is only these new mapped
72
- * own properties.
73
- *
74
- * With these differences, even if the original object was not a CopyRecord,
75
- * if all the mapped values are Passable, then the returned object will be
76
- * a CopyRecord.
77
- *
78
- * @template {Record<string, any>} O
79
- * @param {O} original
80
- * @template R map result
81
- * @param {(value: O[keyof O], key: keyof O) => R} mapFn
82
- * @returns {{ [P in keyof O]: R}}
83
- */
84
- export const objectMap = (original, mapFn) => {
85
- const ents = entries(original);
86
- const mapEnts = ents.map(([k, v]) => [k, mapFn(v, k)]);
87
- return harden(fromEntries(mapEnts));
88
- };
89
- harden(objectMap);
90
-
91
- /**
92
- * @param {Array<string | symbol>} leftNames
93
- * @param {Array<string | symbol>} rightNames
94
- */
95
- export const listDifference = (leftNames, rightNames) => {
96
- const rightSet = makeSet(rightNames);
97
- return leftNames.filter(name => !rightSet.has(name));
98
- };
99
- harden(listDifference);
100
-
101
- /**
102
- * @param {Error} innerErr
103
- * @param {string|number} label
104
- * @param {ErrorConstructor} [ErrorConstructor]
105
- * @returns {never}
106
- */
107
- export const throwLabeled = (innerErr, label, ErrorConstructor = undefined) => {
108
- if (typeof label === 'number') {
109
- label = `[${label}]`;
110
- }
111
- const outerErr = assert.error(
112
- `${label}: ${innerErr.message}`,
113
- ErrorConstructor,
114
- );
115
- assert.note(outerErr, X`Caused by ${innerErr}`);
116
- throw outerErr;
117
- };
118
- harden(throwLabeled);
119
-
120
- /**
121
- * @template A,R
122
- * @param {(...args: A[]) => R} func
123
- * @param {A[]} args
124
- * @param {string|number} [label]
125
- * @returns {R}
126
- */
127
- export const applyLabelingError = (func, args, label = undefined) => {
128
- if (label === undefined) {
129
- return func(...args);
130
- }
131
- let result;
132
- try {
133
- result = func(...args);
134
- } catch (err) {
135
- throwLabeled(err, label);
136
- }
137
- if (isPromise(result)) {
138
- // If result is a rejected promise, this will return a promise with a
139
- // different rejection reason. But this confuses TypeScript because it types
140
- // that case as `Promise<never>` which is cool for a promise that will never
141
- // fulfill. But TypeScript doesn't understand that this will only happen
142
- // when `result` was a rejected promise. In only this case `R` should
143
- // already allow `Promise<never>` as a subtype.
144
- /** @type {unknown} */
145
- const relabeled = E.when(result, undefined, reason =>
146
- throwLabeled(reason, label),
147
- );
148
- return /** @type {R} */ (relabeled);
149
- } else {
150
- return result;
151
- }
152
- };
153
- harden(applyLabelingError);
15
+ /** @import { ERef } from '@endo/far' */
154
16
 
155
17
  /**
156
18
  * @template T
@@ -205,23 +67,6 @@ export const makeMeasureSeconds = currentTimeMillisec => {
205
67
  return measureSeconds;
206
68
  };
207
69
 
208
- /**
209
- * @param {Error[]} errors
210
- * @param {string} [message]
211
- */
212
- export const makeAggregateError = (errors, message) => {
213
- const err = Error(message);
214
- Object.defineProperties(err, {
215
- name: {
216
- value: 'AggregateError',
217
- },
218
- errors: {
219
- value: errors,
220
- },
221
- });
222
- return err;
223
- };
224
-
225
70
  /**
226
71
  * @template T
227
72
  * @param {readonly (T | PromiseLike<T>)[]} items
@@ -239,7 +84,7 @@ export const PromiseAllOrErrors = async items => {
239
84
  } else if (errors.length === 1) {
240
85
  throw errors[0];
241
86
  } else {
242
- throw makeAggregateError(errors);
87
+ throw AggregateError(errors);
243
88
  }
244
89
  });
245
90
  };
@@ -249,14 +94,15 @@ export const PromiseAllOrErrors = async items => {
249
94
  * trier: () => Promise<T>,
250
95
  * finalizer: (error?: unknown) => Promise<void>,
251
96
  * ) => Promise<T>}
252
- */ export const aggregateTryFinally = async (trier, finalizer) =>
97
+ */
98
+ export const aggregateTryFinally = async (trier, finalizer) =>
253
99
  trier().then(
254
100
  async result => finalizer().then(() => result),
255
101
  async tryError =>
256
102
  finalizer(tryError)
257
103
  .then(
258
104
  () => tryError,
259
- finalizeError => makeAggregateError([tryError, finalizeError]),
105
+ finalizeError => AggregateError([tryError, finalizeError]),
260
106
  )
261
107
  .then(error => Promise.reject(error)),
262
108
  );
@@ -275,7 +121,6 @@ export const PromiseAllOrErrors = async items => {
275
121
  * @throws if any value in the object entries is not defined
276
122
  * @returns {asserts obj is AllDefined<T>}
277
123
  */
278
-
279
124
  export const assertAllDefined = obj => {
280
125
  const missing = [];
281
126
  for (const [key, val] of Object.entries(obj)) {
package/CHANGELOG.md DELETED
@@ -1,106 +0,0 @@
1
- # Change Log
2
-
3
- All notable changes to this project will be documented in this file.
4
- See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
-
6
- ### [0.3.3-u11.0](https://github.com/Agoric/agoric-sdk/compare/@agoric/internal@0.3.2...@agoric/internal@0.3.3-u11.0) (2023-08-24)
7
-
8
- **Note:** Version bump only for package @agoric/internal
9
-
10
-
11
-
12
-
13
-
14
- ### [0.3.2](https://github.com/Agoric/agoric-sdk/compare/@agoric/internal@0.3.1...@agoric/internal@0.3.2) (2023-06-02)
15
-
16
- **Note:** Version bump only for package @agoric/internal
17
-
18
-
19
-
20
-
21
-
22
- ### [0.3.1](https://github.com/Agoric/agoric-sdk/compare/@agoric/internal@0.3.0...@agoric/internal@0.3.1) (2023-05-24)
23
-
24
- **Note:** Version bump only for package @agoric/internal
25
-
26
-
27
-
28
-
29
-
30
- ## [0.3.0](https://github.com/Agoric/agoric-sdk/compare/@agoric/internal@0.2.1...@agoric/internal@0.3.0) (2023-05-19)
31
-
32
-
33
- ### ⚠ BREAKING CHANGES
34
-
35
- * emit smallcaps-format data in all marshallers
36
-
37
- ### Features
38
-
39
- * Add SwingSet configuration to purge vstorage within (re-)bootstrap ([f248e91](https://github.com/Agoric/agoric-sdk/commit/f248e9116512374fb95f789b26e27b66cd5c34ca)), closes [#7681](https://github.com/Agoric/agoric-sdk/issues/7681)
40
- * **auction:** add an auctioneer to manage vault liquidation ([#7000](https://github.com/Agoric/agoric-sdk/issues/7000)) ([398b70f](https://github.com/Agoric/agoric-sdk/commit/398b70f7e028f957afc1582f0ee31eb2574c94d0)), closes [#6992](https://github.com/Agoric/agoric-sdk/issues/6992) [#7047](https://github.com/Agoric/agoric-sdk/issues/7047) [#7074](https://github.com/Agoric/agoric-sdk/issues/7074)
41
- * **casting:** handle noData value encoding ([530bc41](https://github.com/Agoric/agoric-sdk/commit/530bc41854cc7f5e5749e97e87fabc6163a17864))
42
- * **cosmic-swingset:** add after-commit action ([970a53f](https://github.com/Agoric/agoric-sdk/commit/970a53f827ded21b27525f6b0042bbc124c62d48))
43
- * **internal:** makeFakeStorageKit supports "get" and "entries" ([6a69aab](https://github.com/Agoric/agoric-sdk/commit/6a69aab5cb54faae5af631bbc2281e4fc4ede8e0))
44
- * **internal:** new `prepareAttenuator` leveraging callbacks ([55599df](https://github.com/Agoric/agoric-sdk/commit/55599dfe7ec43a27387ca64e8bae57be13a38115))
45
- * emit smallcaps-format data in all marshallers ([1753df8](https://github.com/Agoric/agoric-sdk/commit/1753df83465785b5ee71b250770c9b012d750ffc)), closes [#6822](https://github.com/Agoric/agoric-sdk/issues/6822)
46
- * **core:** HighPrioritySendersManager ([7b382e4](https://github.com/Agoric/agoric-sdk/commit/7b382e49a1521d367c5b8db18fa7efa2b77ef7e3))
47
- * **cosmic-swingset:** basic snapshot wiring ([b1072d8](https://github.com/Agoric/agoric-sdk/commit/b1072d8b1ddabbb5f2835eb503c945fed3b6b080))
48
- * **cosmic-swingset:** export swingStore kvData to vstorage ([be68431](https://github.com/Agoric/agoric-sdk/commit/be684315dc68ecf0cb603a8eb38ddd5418e996a6))
49
- * **cosmic-swingset:** process highPriorityQueue actions ([182a96e](https://github.com/Agoric/agoric-sdk/commit/182a96e169c8cac7f31fbce014783fd6db72b64c))
50
- * **cosmic-swingset:** remove unnecessary explicit activityhash ([5dcc44d](https://github.com/Agoric/agoric-sdk/commit/5dcc44d31be0c8a95a5749d768791fa35b72dbd3))
51
- * **internal:** add BufferLineTransform ([6e7db7a](https://github.com/Agoric/agoric-sdk/commit/6e7db7af7d93500caf71d817afbb358d33ef01f6))
52
- * **internal:** add sync tee util ([#7560](https://github.com/Agoric/agoric-sdk/issues/7560)) ([0f800a6](https://github.com/Agoric/agoric-sdk/commit/0f800a622b81c61101d96b0ad620ab3065f4b146))
53
- * **internal:** build `chainStorage` from `zone` ([74c62da](https://github.com/Agoric/agoric-sdk/commit/74c62dae7964b488bfdf7c7ee8a9bd930074cea8))
54
- * **internal:** iterable produces values and can be async ([cf4110f](https://github.com/Agoric/agoric-sdk/commit/cf4110f59c228e42e09254b271209a66b9faf3e0))
55
- * **internal:** new `callback` module for durable classless callbacks ([b94d600](https://github.com/Agoric/agoric-sdk/commit/b94d60052e1043fd6fb1ce39530a6072e38ef0d9))
56
- * **internal:** shutdown informs of interrupt signal ([2ce1e89](https://github.com/Agoric/agoric-sdk/commit/2ce1e892eb381a28c31805f48ba65511896ef406))
57
- * assertAllDefined ([d4d6cbd](https://github.com/Agoric/agoric-sdk/commit/d4d6cbd798eee051a8a699c85cc620c6a8298258))
58
- * board-utils ([4f80ad3](https://github.com/Agoric/agoric-sdk/commit/4f80ad3cac3e47a89834f7f98330a47141b6e235))
59
- * type assertion for assertAllDefined ([afa7b5b](https://github.com/Agoric/agoric-sdk/commit/afa7b5bfaf4558a38bdba2c44bf91691f6db26b8))
60
- * **store:** M.splitArray and M.splitRecord ([#6597](https://github.com/Agoric/agoric-sdk/issues/6597)) ([e7427e3](https://github.com/Agoric/agoric-sdk/commit/e7427e386bcbfbe99312b41342b1fa2e722c57c7))
61
- * **vats:** harmonise core/boot.js and boot-psm.js ([4f6635e](https://github.com/Agoric/agoric-sdk/commit/4f6635e550b926d3ca43d9075f26fef3b810817d))
62
-
63
-
64
- ### Bug Fixes
65
-
66
- * **internal:** add typing to makeWithQueue ([5b1539b](https://github.com/Agoric/agoric-sdk/commit/5b1539bfc61ea4f937e2f85cbe93c7bccfc84a40))
67
- * **internal:** Make makeFakeStorageKit value auto-wrapping depend upon `sequence: true` ([2751e76](https://github.com/Agoric/agoric-sdk/commit/2751e7626e0ca617cdb2b1d92e5d4d9315b5674a))
68
- * **internal:** more callback typing ([e78e14d](https://github.com/Agoric/agoric-sdk/commit/e78e14d60a78d2e5f9fb9a899053bf778bb51360))
69
- * **internal:** properly inherit from `chainStorageNode` ([134a977](https://github.com/Agoric/agoric-sdk/commit/134a977f7bc4a2fc6eff3868d4d415c8c9714b4b))
70
- * **internal:** Restore support for passable-symbol method keys ([54271af](https://github.com/Agoric/agoric-sdk/commit/54271af10adb144fe6d562193afa473d74425854))
71
- * **internal:** shutdown beforeExit avoids forced exit ([34c9f44](https://github.com/Agoric/agoric-sdk/commit/34c9f442f124cd7181b538cf8754c6180c863b32))
72
- * **internal:** Validate Callback targets ([8880ada](https://github.com/Agoric/agoric-sdk/commit/8880ada791d70dd487770e8a0fa4b6b725aa8769))
73
- * **notifier:** Add a makeDurablePublishKit "onAdvance" option ([4c62b52](https://github.com/Agoric/agoric-sdk/commit/4c62b52b94cbc9ccb3c7388f5e94589809e6d7fd)), closes [#7303](https://github.com/Agoric/agoric-sdk/issues/7303)
74
- * adapt to deeplyFulfilled being async ([#6816](https://github.com/Agoric/agoric-sdk/issues/6816)) ([ec315e1](https://github.com/Agoric/agoric-sdk/commit/ec315e1634f6d5cdef1cddafc18777de7c04fecc))
75
- * **telemetry:** partially undo [#6684](https://github.com/Agoric/agoric-sdk/issues/6684) ([b9fa85b](https://github.com/Agoric/agoric-sdk/commit/b9fa85b7307124e50cc3a84d3b694307cde55f54))
76
- * avoid using top-level `require` ([57ca2db](https://github.com/Agoric/agoric-sdk/commit/57ca2dbfbadb373f97d43b2fb4e90302c9149976))
77
- * **types:** type assertion for assertAllDefined ([25f16b2](https://github.com/Agoric/agoric-sdk/commit/25f16b2e935931b81313d2ee1d491b305088bb7a))
78
- * track endo 1382 fix to 6570 ([#6612](https://github.com/Agoric/agoric-sdk/issues/6612)) ([7897761](https://github.com/Agoric/agoric-sdk/commit/7897761d6e19e6bbba42e7bd0bd5befb507afa08))
79
-
80
-
81
-
82
- ### [0.2.1](https://github.com/Agoric/agoric-sdk/compare/@agoric/internal@0.2.0...@agoric/internal@0.2.1) (2022-10-05)
83
-
84
-
85
- ### Bug Fixes
86
-
87
- * protect zoe from keyword collision ([#6370](https://github.com/Agoric/agoric-sdk/issues/6370)) ([02af4a0](https://github.com/Agoric/agoric-sdk/commit/02af4a07ad1f99b545d0bf525bd1ea97d74639d1))
88
-
89
-
90
-
91
- ## 0.2.0 (2022-09-20)
92
-
93
-
94
- ### ⚠ BREAKING CHANGES
95
-
96
- * **SwingSet:** Representatives inherit bound methods (#5970)
97
-
98
- ### Features
99
-
100
- * **internal:** add async utils from loadgen ([5d9f411](https://github.com/Agoric/agoric-sdk/commit/5d9f411a124e4028cd88764084999fb1fd791609))
101
- * **internal:** deeplyFulfilledObject ([11fd071](https://github.com/Agoric/agoric-sdk/commit/11fd071005741719286ae6a1bb6bb9a7fd1f65b7))
102
-
103
-
104
- ### Bug Fixes
105
-
106
- * **SwingSet:** Representatives inherit bound methods ([#5970](https://github.com/Agoric/agoric-sdk/issues/5970)) ([ba1ed62](https://github.com/Agoric/agoric-sdk/commit/ba1ed62062a63862e2eecb598b0bd1d2ac828e1f))