@agoric/vat-data 0.5.3-dev-9f8a76e.0 → 0.5.3-dev-e68f280.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agoric/vat-data",
3
- "version": "0.5.3-dev-9f8a76e.0+9f8a76e",
3
+ "version": "0.5.3-dev-e68f280.0+e68f280",
4
4
  "description": "Safe access to VatData global",
5
5
  "type": "module",
6
6
  "repository": "https://github.com/Agoric/agoric-sdk",
@@ -19,12 +19,13 @@
19
19
  "author": "Agoric",
20
20
  "license": "Apache-2.0",
21
21
  "dependencies": {
22
- "@agoric/assert": "0.6.1-dev-9f8a76e.0+9f8a76e",
23
- "@agoric/internal": "0.3.3-dev-9f8a76e.0+9f8a76e",
24
- "@agoric/store": "0.9.3-dev-9f8a76e.0+9f8a76e"
22
+ "@agoric/assert": "0.6.1-dev-e68f280.0+e68f280",
23
+ "@agoric/internal": "0.3.3-dev-e68f280.0+e68f280",
24
+ "@agoric/store": "0.9.3-dev-e68f280.0+e68f280",
25
+ "@agoric/swingset-liveslots": "0.10.3-dev-e68f280.0+e68f280"
25
26
  },
26
27
  "devDependencies": {
27
- "@agoric/swingset-vat": "0.32.3-dev-9f8a76e.0+9f8a76e",
28
+ "@endo/init": "^0.5.57",
28
29
  "ava": "^5.3.0",
29
30
  "tsd": "^0.28.1"
30
31
  },
@@ -34,5 +35,5 @@
34
35
  "engines": {
35
36
  "node": ">=14.15.0"
36
37
  },
37
- "gitHead": "9f8a76ee66bd74f028158b689c4b437921613f63"
38
+ "gitHead": "e68f2805dde79871d1421e50c60f08e854e1851d"
38
39
  }
package/src/exo-utils.js CHANGED
@@ -6,17 +6,17 @@ import { provide, VatData as globalVatData } from './vat-data-bindings.js';
6
6
 
7
7
  /** @template L,R @typedef {import('@endo/eventual-send').RemotableBrand<L, R>} RemotableBrand */
8
8
  /** @template T @typedef {import('@endo/far').ERef<T>} ERef */
9
- /** @typedef {import('./types.js').Baggage} Baggage */
10
- /** @template T @typedef {import('./types.js').DefineKindOptions<T>} DefineKindOptions */
11
- /** @template T @typedef {import('./types.js').KindFacet<T>} KindFacet */
12
- /** @template T @typedef {import('./types.js').KindFacets<T>} KindFacets */
13
- /** @typedef {import('./types.js').DurableKindHandle} DurableKindHandle */
9
+ /** @typedef {import('@agoric/swingset-liveslots').Baggage} Baggage */
10
+ /** @template T @typedef {import('@agoric/swingset-liveslots').DefineKindOptions<T>} DefineKindOptions */
11
+ /** @template T @typedef {import('@agoric/swingset-liveslots').KindFacet<T>} KindFacet */
12
+ /** @template T @typedef {import('@agoric/swingset-liveslots').KindFacets<T>} KindFacets */
13
+ /** @typedef {import('@agoric/swingset-liveslots').DurableKindHandle} DurableKindHandle */
14
14
 
15
15
  /**
16
16
  * Make a version of the argument function that takes a kind context but
17
17
  * ignores it.
18
18
  *
19
- * @type {<T extends Function>(fn: T) => import('./types.js').PlusContext<never, T>}
19
+ * @type {<T extends Function>(fn: T) => import('@agoric/swingset-liveslots').PlusContext<never, T>}
20
20
  */
21
21
  export const ignoreContext =
22
22
  fn =>
@@ -45,7 +45,7 @@ export const makeExoUtils = VatData => {
45
45
 
46
46
  /**
47
47
  * @deprecated Use prepareExoClass instead
48
- * @type {import('./types.js').PrepareKind}
48
+ * @type {import('@agoric/swingset-liveslots').PrepareKind}
49
49
  */
50
50
  const prepareKind = (
51
51
  baggage,
@@ -64,7 +64,7 @@ export const makeExoUtils = VatData => {
64
64
 
65
65
  /**
66
66
  * @deprecated Use prepareExoClassKit instead
67
- * @type {import('./types.js').PrepareKindMulti}
67
+ * @type {import('@agoric/swingset-liveslots').PrepareKindMulti}
68
68
  */
69
69
  const prepareKindMulti = (
70
70
  baggage,
package/src/index.js CHANGED
@@ -42,9 +42,9 @@ export {
42
42
  prepareSingleton,
43
43
  } from './exo-utils.js';
44
44
 
45
- /** @typedef {import('./types.js').Baggage} Baggage */
46
- /** @typedef {import('./types.js').DurableKindHandle} DurableKindHandle */
47
- /** @template T @typedef {import('./types.js').DefineKindOptions<T>} DefineKindOptions */
45
+ /** @typedef {import('@agoric/swingset-liveslots').Baggage} Baggage */
46
+ /** @typedef {import('@agoric/swingset-liveslots').DurableKindHandle} DurableKindHandle */
47
+ /** @template T @typedef {import('@agoric/swingset-liveslots').DefineKindOptions<T>} DefineKindOptions */
48
48
 
49
49
  // //////////////////////////// deprecated /////////////////////////////////////
50
50
 
@@ -1,5 +1,11 @@
1
1
  /* eslint-disable no-use-before-define */
2
2
  import { expectType } from 'tsd';
3
+ import type {
4
+ KindFacets,
5
+ DurableKindHandle,
6
+ KindFacet,
7
+ FunctionsPlusContext,
8
+ } from '@agoric/swingset-liveslots';
3
9
  import {
4
10
  defineKind,
5
11
  defineKindMulti,
@@ -7,12 +13,6 @@ import {
7
13
  defineDurableKind,
8
14
  partialAssign,
9
15
  } from '.';
10
- import {
11
- KindFacets,
12
- DurableKindHandle,
13
- KindFacet,
14
- FunctionsPlusContext,
15
- } from './types.js';
16
16
 
17
17
  /*
18
18
  export const makePaymentMaker = (allegedName: string, brand: unknown) => {
@@ -3,7 +3,7 @@
3
3
  import { Fail } from '@agoric/assert';
4
4
  import { provideLazy } from '@agoric/store';
5
5
 
6
- /** @type {import('./types').VatData} */
6
+ /** @type {import('@agoric/swingset-liveslots').VatData} */
7
7
  let VatDataGlobal;
8
8
  if ('VatData' in globalThis) {
9
9
  globalThis.VatData || Fail`VatData defined in global as null or undefined`;
@@ -62,7 +62,7 @@ export const {
62
62
  *
63
63
  * const makeFoo = pickFacet(makeFooBase, 'self');
64
64
  *
65
- * @type {import('./types').PickFacet}
65
+ * @type {import('@agoric/swingset-liveslots').PickFacet}
66
66
  */
67
67
  export const pickFacet =
68
68
  (maker, facetName) =>
@@ -107,8 +107,8 @@ harden(partialAssign);
107
107
  * intended to eventually be durable has not yet been made durable. A store
108
108
  * marked as fakeDurable will appear to operate normally but any attempt to
109
109
  * upgrade its containing vat will fail with an error.
110
- * @property {import('./types').Pattern} [keyShape]
111
- * @property {import('./types').Pattern} [valueShape]
110
+ * @property {import('@agoric/swingset-liveslots').Pattern} [keyShape]
111
+ * @property {import('@agoric/swingset-liveslots').Pattern} [valueShape]
112
112
  */
113
113
  /**
114
114
  * Unlike `provideLazy`, `provide` should be called at most once
@@ -138,12 +138,12 @@ harden(partialAssign);
138
138
 
139
139
  export const provide =
140
140
  // XXX cast because provideLazy is `any` due to broken type import
141
- /** @type {<K, V>(baggage: import('./types.js').Baggage, key: K, makeValue: (key: K) => V) => V} */ (
141
+ /** @type {<K, V>(baggage: import('@agoric/swingset-liveslots').Baggage, key: K, makeValue: (key: K) => V) => V} */ (
142
142
  provideLazy
143
143
  );
144
144
 
145
145
  // TODO: Find a good home for this function used by @agoric/vat-data and testing code
146
- /** @param {import('@agoric/vat-data/src/types').VatData} VatData */
146
+ /** @param {import('@agoric/swingset-liveslots').VatData} VatData */
147
147
  export const makeStoreUtils = VatData => {
148
148
  const {
149
149
  // eslint-disable-next-line no-shadow -- these literally do shadow the globals
@@ -157,7 +157,7 @@ export const makeStoreUtils = VatData => {
157
157
  } = VatData;
158
158
 
159
159
  /**
160
- * @param {import('./types').Baggage} baggage
160
+ * @param {import('@agoric/swingset-liveslots').Baggage} baggage
161
161
  * @param {string} name
162
162
  * @param {Omit<StoreOptions, 'durable'>} options
163
163
  */
@@ -168,7 +168,7 @@ export const makeStoreUtils = VatData => {
168
168
  harden(provideDurableMapStore);
169
169
 
170
170
  /**
171
- * @param {import('./types').Baggage} baggage
171
+ * @param {import('@agoric/swingset-liveslots').Baggage} baggage
172
172
  * @param {string} name
173
173
  * @param {Omit<StoreOptions, 'durable'>} options
174
174
  */
@@ -179,7 +179,7 @@ export const makeStoreUtils = VatData => {
179
179
  harden(provideDurableWeakMapStore);
180
180
 
181
181
  /**
182
- * @param {import('./types').Baggage} baggage
182
+ * @param {import('@agoric/swingset-liveslots').Baggage} baggage
183
183
  * @param {string} name
184
184
  * @param {Omit<StoreOptions, 'durable'>} options
185
185
  */
@@ -190,7 +190,7 @@ export const makeStoreUtils = VatData => {
190
190
  harden(provideDurableSetStore);
191
191
 
192
192
  /**
193
- * @param {import('./types').Baggage} baggage
193
+ * @param {import('@agoric/swingset-liveslots').Baggage} baggage
194
194
  * @param {string} name
195
195
  * @param {Omit<StoreOptions, 'durable'>} options
196
196
  */
@@ -1,9 +1,14 @@
1
- import { test } from '@agoric/swingset-vat/tools/prepare-test-env-ava.js';
1
+ import '@endo/init/debug.js';
2
+ import test from 'ava';
3
+
2
4
  /* global globalThis */
5
+ // @ts-expect-error VatData not optional
3
6
  delete globalThis.VatData;
4
7
 
5
8
  /** @see present.test.js */
6
9
  test('methods available that throw', async t => {
7
10
  const { defineKind } = await import('../src/index.js');
8
- t.throws(defineKind, { message: /VatData unavailable/ });
11
+ t.throws(() => defineKind('someTag', () => {}, {}), {
12
+ message: /VatData unavailable/,
13
+ });
9
14
  });
@@ -1,7 +1,13 @@
1
- import { test } from '@agoric/swingset-vat/tools/prepare-test-env-ava.js';
1
+ import '@endo/init/debug.js';
2
+ import test from 'ava';
3
+
4
+ const mockDefineKind = /** @type {any} */ (harden({}));
5
+
6
+ /* global globalThis */
7
+ // @ts-expect-error missing fields
8
+ globalThis.VatData ||= { defineKind: mockDefineKind };
2
9
 
3
10
  test('methods available', async t => {
4
11
  const { defineKind } = await import('../src/index.js');
5
- defineKind('test', () => {}, {});
6
- t.pass();
12
+ t.is(defineKind, mockDefineKind);
7
13
  });
@@ -1,6 +1,8 @@
1
1
  // Modeled on test-heap-classes.js
2
2
 
3
- import { test } from '@agoric/swingset-vat/tools/prepare-test-env-ava.js';
3
+ import '@agoric/swingset-liveslots/tools/prepare-test-env.js';
4
+
5
+ import test from 'ava';
4
6
  import { M } from '@agoric/store';
5
7
  import {
6
8
  makeKindHandle,
@@ -1,6 +1,8 @@
1
1
  // Modeled on test-heap-classes.js
2
2
 
3
- import { test } from '@agoric/swingset-vat/tools/prepare-test-env-ava.js';
3
+ import '@agoric/swingset-liveslots/tools/prepare-test-env.js';
4
+
5
+ import test from 'ava';
4
6
  import { M } from '@agoric/store';
5
7
  import {
6
8
  prepareExoClass,
@@ -1,14 +1,14 @@
1
1
  // From https://github.com/Agoric/agoric-sdk/pull/6903#discussion_r1098067133
2
2
 
3
- import { test } from '@agoric/swingset-vat/tools/prepare-test-env-ava.js';
3
+ import '@agoric/swingset-liveslots/tools/prepare-test-env.js';
4
4
 
5
+ import test from 'ava';
5
6
  import { M, makeScalarMapStore } from '@agoric/store';
6
-
7
7
  import { makeScalarBigMapStore } from '../src/vat-data-bindings.js';
8
8
 
9
9
  test('scalar maps should reject non-scalar keys', t => {
10
10
  const bigMap = makeScalarMapStore('dummy', { keyShape: M.key() });
11
- t.throws(() => bigMap.init(harden({ label: 'not a scalar' })), {
11
+ t.throws(() => bigMap.init(harden({ label: 'not a scalar' }), 'val'), {
12
12
  message:
13
13
  /A "copyRecord" cannot be a scalar key: \{"label":"not a scalar"\}/,
14
14
  });
@@ -1,6 +1,8 @@
1
1
  // Modeled on test-heap-classes.js
2
2
 
3
- import { test } from '@agoric/swingset-vat/tools/prepare-test-env-ava.js';
3
+ import '@agoric/swingset-liveslots/tools/prepare-test-env.js';
4
+
5
+ import test from 'ava';
4
6
  import { M } from '@agoric/store';
5
7
  import {
6
8
  defineVirtualExoClass,
package/tsconfig.json CHANGED
@@ -1,8 +1,10 @@
1
1
  {
2
2
  "extends": "../../tsconfig.json",
3
3
  "compilerOptions": {
4
- "strict": true,
5
- "noImplicitAny": false, // for compat with peer packages using ambient types
4
+ // XXX to resolve the swingset-liveslots types
5
+ "maxNodeModuleJsDepth": 1,
6
+ // "strict": true, // disabled for compat with >0 module depth
7
+ // "noImplicitAny": false, // for compat with peer packages using ambient types
6
8
  },
7
9
  "include": [
8
10
  "src/**/*.js",
package/src/types.d.ts DELETED
@@ -1,203 +0,0 @@
1
- /**
2
- * @file Types for vat-data
3
- *
4
- * Facet is a single object with methods.
5
- * Behavior is a description when defining a kind of what facets it will have.
6
- * For the non-multi defineKind, there is just one facet so it doesn't have a key.
7
- */
8
- import type {
9
- InterfaceGuard,
10
- MapStore,
11
- Pattern,
12
- SetStore,
13
- StoreOptions,
14
- WeakMapStore,
15
- WeakSetStore,
16
- } from '@agoric/store';
17
-
18
- export type { MapStore, Pattern };
19
-
20
- export type Baggage = MapStore<string, unknown>;
21
-
22
- type Tail<T extends any[]> = T extends [head: any, ...rest: infer Rest]
23
- ? Rest
24
- : [];
25
-
26
- type MinusContext<
27
- F extends (context, ...rest: any[]) => any,
28
- P extends any[] = Parameters<F>, // P: are the parameters of F
29
- R = ReturnType<F>, // R: the return type of F
30
- > = (...args: Tail<P>) => R;
31
-
32
- export type KindFacet<O> = { [K in keyof O]: MinusContext<O[K]> };
33
-
34
- export type KindFacets<B> = {
35
- [FacetKey in keyof B]: KindFacet<B[FacetKey]>;
36
- };
37
-
38
- export type KindContext<S, F> = { state: S; self: KindFacet<F> };
39
- export type MultiKindContext<S, B> = { state: S; facets: KindFacets<B> };
40
-
41
- export type PlusContext<C, M> = (c: C, ...args: Parameters<M>) => ReturnType<M>;
42
- export type FunctionsPlusContext<C, O> = {
43
- [K in keyof O]: PlusContext<C, O[K]>;
44
- };
45
-
46
- declare class DurableKindHandleClass {
47
- private descriptionTag: string;
48
- }
49
- export type DurableKindHandle = DurableKindHandleClass;
50
-
51
- /**
52
- * Grab bag of options that can be provided to `defineDurableKind` and its
53
- * siblings. Not all options are meaningful in all contexts. See the
54
- * doc-comments on each option.
55
- */
56
- export type DefineKindOptions<C> = {
57
- /**
58
- * If provided, the `finish` function will be called after the instance is
59
- * made and internally registered, but before it is returned. The finish
60
- * function is to do any post-intantiation initialization that should be
61
- * done before exposing the object to its clients.
62
- */
63
- finish?: (context: C) => void;
64
-
65
- /**
66
- * Meaningful to `makeScalarBigMapStore` and its siblings. These maker
67
- * fuctions will make either virtual or durable stores, depending on
68
- * this flag. Defaults to off, making virtual but not durable collections.
69
- *
70
- * Generally, durable collections are provided with `provideDurableMapStore`
71
- * and its sibling, which use this flag internally. If you do not make
72
- * durable collections by other means, you can consider this as
73
- * intended for internal use only.
74
- */
75
- durable?: boolean;
76
-
77
- /**
78
- * If provided, it describes the shape of all state records of instances
79
- * of this kind.
80
- */
81
- stateShape?: { [name: string]: Pattern };
82
-
83
- /**
84
- * Intended for internal use only.
85
- * Should the raw methods receive their `context` argument as their first
86
- * argument or as their `this` binding? For `defineDurableKind` and its
87
- * siblings (including `prepareSingleton`), this defaults to off, meaning that
88
- * their behavior methods receive `context` as their first argument.
89
- * `prepareExoClass` and its siblings (including `prepareExo`) use
90
- * this flag internally to indicate that their methods receive `context`
91
- * as their `this` binding.
92
- */
93
- thisfulMethods?: boolean;
94
-
95
- /**
96
- * Intended for internal use only.
97
- * If an `interfaceGuard` is provided, then the raw methods passed alongside
98
- * it are wrapped by a function that first checks that this method's guard
99
- * pattern is satisfied before calling the raw method.
100
- *
101
- * In `defineDurableKind` and its siblings, this defaults to off.
102
- * `prepareExoClass` use this internally to protect their raw class methods
103
- * using the provided interface.
104
- */
105
- interfaceGuard?: InterfaceGuard<unknown>;
106
- };
107
-
108
- export type VatData = {
109
- // virtual kinds
110
- /** @deprecated Use defineVirtualExoClass instead */
111
- defineKind: <P, S, F>(
112
- tag: string,
113
- init: (...args: P) => S,
114
- facet: F,
115
- options?: DefineKindOptions<KindContext<S, F>>,
116
- ) => (...args: P) => KindFacet<F>;
117
-
118
- /** @deprecated Use defineVirtualExoClassKit instead */
119
- defineKindMulti: <P, S, B>(
120
- tag: string,
121
- init: (...args: P) => S,
122
- behavior: B,
123
- options?: DefineKindOptions<MultiKindContext<S, B>>,
124
- ) => (...args: P) => KindFacets<B>;
125
-
126
- // durable kinds
127
- makeKindHandle: (descriptionTag: string) => DurableKindHandle;
128
-
129
- /** @deprecated Use defineDurableExoClass instead */
130
- defineDurableKind: <P, S, F>(
131
- kindHandle: DurableKindHandle,
132
- init: (...args: P) => S,
133
- facet: F,
134
- options?: DefineKindOptions<KindContext<S, F>>,
135
- ) => (...args: P) => KindFacet<F>;
136
-
137
- /** @deprecated Use defineDurableExoClassKit instead */
138
- defineDurableKindMulti: <P, S, B>(
139
- kindHandle: DurableKindHandle,
140
- init: (...args: P) => S,
141
- behavior: B,
142
- options?: DefineKindOptions<MultiKindContext<S, B>>,
143
- ) => (...args: P) => KindFacets<B>;
144
-
145
- providePromiseWatcher: unknown;
146
- watchPromise: unknown;
147
-
148
- makeScalarBigMapStore: <K, V>(
149
- label: string,
150
- options?: StoreOptions,
151
- ) => MapStore<K, V>;
152
- makeScalarBigWeakMapStore: <K, V>(
153
- label: string,
154
- options?: StoreOptions,
155
- ) => WeakMapStore<K, V>;
156
-
157
- makeScalarBigSetStore: <K>(
158
- label: string,
159
- options?: StoreOptions,
160
- ) => SetStore<K>;
161
- makeScalarBigWeakSetStore: <K>(
162
- label: string,
163
- options?: StoreOptions,
164
- ) => WeakSetStore<K>;
165
- canBeDurable: (specimen: unknown) => boolean;
166
- };
167
-
168
- // The JSDoc is repeated here and at the function definition so it appears
169
- // in IDEs where it's used, regardless of type resolution.
170
- export interface PickFacet {
171
- /**
172
- * When making a multi-facet kind, it's common to pick one facet to
173
- * expose. E.g.,
174
- *
175
- * const makeFoo = (a, b, c, d) => makeFooBase(a, b, c, d).self;
176
- *
177
- * This helper reduces the duplication:
178
- *
179
- * const makeFoo = pickFacet(makeFooBase, 'self');
180
- */
181
- <M extends (...args: any[]) => any, F extends keyof ReturnType<M>>(
182
- maker: M,
183
- facetName: F,
184
- ): (...args: Parameters<M>) => ReturnType<M>[F];
185
- }
186
-
187
- /** @deprecated Use prepareExoClass instead */
188
- export type PrepareKind = <P, S, F>(
189
- baggage: Baggage,
190
- tag: string,
191
- init: (...args: P) => S,
192
- facet: F,
193
- options?: DefineKindOptions<KindContext<S, F>>,
194
- ) => (...args: P) => KindFacet<F>;
195
-
196
- /** @deprecated Use prepareExoClassKit instead */
197
- export type PrepareKindMulti = <P, S, B>(
198
- baggage: Baggage,
199
- tag: string,
200
- init: (...args: P) => S,
201
- behavior: B,
202
- options?: DefineKindOptions<MultiKindContext<S, B>>,
203
- ) => (...args: P) => KindFacets<B>;