@agoric/internal 0.3.3-dev-9835fb0.0 → 0.3.3-dev-bfca51a.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/internal",
3
- "version": "0.3.3-dev-9835fb0.0+9835fb0",
3
+ "version": "0.3.3-dev-bfca51a.0+bfca51a",
4
4
  "description": "Externally unsupported utilities internal to agoric-sdk",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -20,7 +20,7 @@
20
20
  "lint:types": "tsc"
21
21
  },
22
22
  "dependencies": {
23
- "@agoric/base-zone": "0.1.1-dev-9835fb0.0+9835fb0",
23
+ "@agoric/base-zone": "0.1.1-dev-bfca51a.0+bfca51a",
24
24
  "@endo/common": "^1.2.8",
25
25
  "@endo/errors": "^1.2.8",
26
26
  "@endo/far": "^1.1.9",
@@ -34,7 +34,7 @@
34
34
  "jessie.js": "^0.3.4"
35
35
  },
36
36
  "devDependencies": {
37
- "@agoric/cosmic-proto": "0.4.1-dev-9835fb0.0+9835fb0",
37
+ "@agoric/cosmic-proto": "0.4.1-dev-bfca51a.0+bfca51a",
38
38
  "@endo/exo": "^1.5.7",
39
39
  "@endo/init": "^1.1.7",
40
40
  "ava": "^5.3.0",
@@ -60,5 +60,5 @@
60
60
  "typeCoverage": {
61
61
  "atLeast": 93.06
62
62
  },
63
- "gitHead": "9835fb0e5e8322e9e3eb5af21d3c69cbde4247c8"
63
+ "gitHead": "bfca51a6114a29205a8ec05f793edee1249f8953"
64
64
  }
package/src/index.d.ts CHANGED
@@ -7,6 +7,7 @@ export * from "./ses-utils.js";
7
7
  export * from "./typeCheck.js";
8
8
  export * from "./typeGuards.js";
9
9
  export * from "./types-index.js";
10
+ export { pureDataMarshaller } from "./marshal.js";
10
11
  export { objectMap } from "@endo/common/object-map.js";
11
12
  export { objectMetaMap } from "@endo/common/object-meta-map.js";
12
13
  export { fromUniqueEntries } from "@endo/common/from-unique-entries.js";
package/src/index.js CHANGED
@@ -6,6 +6,7 @@ export * from './config.js';
6
6
  export * from './debug.js';
7
7
  export * from './errors.js';
8
8
  export * from './js-utils.js';
9
+ export { pureDataMarshaller } from './marshal.js';
9
10
  export * from './method-tools.js';
10
11
  export * from './ses-utils.js';
11
12
  export * from './typeCheck.js';
package/src/marshal.d.ts CHANGED
@@ -10,6 +10,12 @@ export function makeHistoryReviver(entries: [string, string][], slotToVal?: (slo
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
@@ -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,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;;;;;0BA9HY;IAAE,UAAU,EAAE,MAAM,MAAM,GAAG,IAAI,CAAA;CAAE"}
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);
@@ -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,6 +24,7 @@ export function makeFakeStorageKit(rootPath: string, rootOptions?: Parameters<ty
20
24
  setValue(value: string): Promise<void>;
21
25
  }>;
22
26
  data: Map<string, string>;
27
+ getValues: (path: string) => string[];
23
28
  messages: StorageMessage[];
24
29
  toStorage: ((message: StorageMessage) => string | number | any[] | {
25
30
  storeName: string;
@@ -1 +1 @@
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;AA4CH,8CAtBuB,GAAG,KAAK,GAAG,CAsB+B;AAU1D,6CAHI,MAAM,gBACN,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC,CAAC,CAAC;;;;;oBAyGF,CAAC;;;;UAI/B,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;;0BAjFxB,cAAc;;;0JAAd,cAAc;;;;EAqF7B;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,M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AAA;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;qCA1OJ,uBAAuB;iCAOF,uBAAuB;oCAAvB,uBAAuB;gCAAvB,uBAAuB"}
@@ -2,12 +2,12 @@
2
2
  import { Fail } from '@endo/errors';
3
3
  import { Far } from '@endo/far';
4
4
  import { makeMarshal, Remotable } from '@endo/marshal';
5
- import { unmarshalFromVstorage } from './marshal.js';
6
5
  import { makeTracer } from './debug.js';
6
+ import { NonNullish } from './errors.js';
7
7
  import { isStreamCell, makeChainStorageRoot } from './lib-chainStorage.js';
8
+ import { unmarshalFromVstorage } from './marshal.js';
8
9
  import { bindAllMethods } from './method-tools.js';
9
10
  import { eventLoopIteration } from './testing-utils.js';
10
- import { NonNullish } from './errors.js';
11
11
 
12
12
  /**
13
13
  * @import {TotalMap} from './types.js';
@@ -34,6 +34,16 @@ export const defaultMarshaller = makeMarshal(undefined, slotToRemotable, {
34
34
  serializeBodyFormat: 'smallcaps',
35
35
  });
36
36
 
37
+ /**
38
+ * Serialize/deserialize functions using {@link defaultMarshaller}
39
+ */
40
+ export const defaultSerializer = {
41
+ /** @type {(text: string) => unknown} */
42
+ parse: txt => defaultMarshaller.fromCapData(JSON.parse(txt)),
43
+ /** @type {(obj: any) => string} */
44
+ stringify: obj => JSON.stringify(defaultMarshaller.toCapData(obj)),
45
+ };
46
+
37
47
  /**
38
48
  * A deserializer which produces slot strings instead of Remotables, so if `a =
39
49
  * Far('iface')`, and serializing `{ a }` into `capData` assigned it slot
@@ -190,10 +200,24 @@ export const makeFakeStorageKit = (rootPath, rootOptions) => {
190
200
  },
191
201
  );
192
202
  const rootNode = makeChainStorageRoot(toStorage, rootPath, resolvedOptions);
203
+
204
+ /**
205
+ * Get the values at a sequence node
206
+ *
207
+ * @param {string} path
208
+ * @returns {string[]}
209
+ */
210
+ const getValues = path => {
211
+ assert(resolvedOptions.sequence);
212
+ const wrapper = JSON.parse(data.get(path));
213
+ return wrapper.values;
214
+ };
215
+
193
216
  return {
194
217
  rootNode,
195
218
  // eslint-disable-next-line object-shorthand
196
219
  data: /** @type {Map<string, string>} */ (data),
220
+ getValues,
197
221
  messages,
198
222
  toStorage,
199
223
  };