@agoric/vow 0.1.1-dev-12ce494.0 → 0.1.1-dev-3915e4c.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/vow",
3
- "version": "0.1.1-dev-12ce494.0+12ce494",
3
+ "version": "0.1.1-dev-3915e4c.0+3915e4c",
4
4
  "description": "Remote (shortening and disconnection-tolerant) Promise-likes",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -20,8 +20,8 @@
20
20
  "lint:types": "tsc"
21
21
  },
22
22
  "dependencies": {
23
- "@agoric/base-zone": "0.1.1-dev-12ce494.0+12ce494",
24
- "@agoric/internal": "0.3.3-dev-12ce494.0+12ce494",
23
+ "@agoric/base-zone": "0.1.1-dev-3915e4c.0+3915e4c",
24
+ "@agoric/internal": "0.3.3-dev-3915e4c.0+3915e4c",
25
25
  "@endo/env-options": "^1.1.4",
26
26
  "@endo/errors": "^1.2.2",
27
27
  "@endo/eventual-send": "^1.2.2",
@@ -33,7 +33,8 @@
33
33
  "@agoric/internal": "^0.3.2",
34
34
  "@endo/far": "^1.1.2",
35
35
  "@endo/init": "^1.1.2",
36
- "ava": "^5.3.0"
36
+ "ava": "^5.3.0",
37
+ "tsd": "^0.31.1"
37
38
  },
38
39
  "ava": {
39
40
  "require": [
@@ -55,5 +56,5 @@
55
56
  "typeCoverage": {
56
57
  "atLeast": 89.6
57
58
  },
58
- "gitHead": "12ce49423c9afe6eb2396e7cac79b7f2f003cbb0"
59
+ "gitHead": "3915e4cfaf6b3a86d0f5d5e69a57ca5166e2d721"
59
60
  }
package/src/tools.d.ts CHANGED
@@ -5,18 +5,10 @@ export function prepareVowTools(zone: Zone, powers?: {
5
5
  watch: <T = any, TResult1 = T, TResult2 = never, C extends any[] = any[]>(specimenP: EVow<T>, watcher?: import("./types.js").Watcher<T, TResult1, TResult2, C> | undefined, ...watcherArgs: C) => Vow<Exclude<TResult1, void> | Exclude<TResult2, void> extends never ? TResult1 : Exclude<TResult1, void> | Exclude<TResult2, void>>;
6
6
  makeVowKit: <T>() => import("./types.js").VowKit<T>;
7
7
  allVows: (maybeVows: EVow<unknown>[]) => Vow<any[]>;
8
- asVow: <T extends unknown>(fn: (
9
- /** @typedef {ReturnType<typeof prepareVowTools>} VowTools */
10
- ...args: any[]) => Vow<Awaited<T>> | Awaited<T> | import("./types.js").PromiseVow<T>) => Vow<Awaited<T>>;
8
+ asVow: <T extends unknown>(fn: (...args: any[]) => Vow<Awaited<T>> | Awaited<T> | import("./types.js").PromiseVow<T>) => Vow<Awaited<T>>;
11
9
  asPromise: AsPromiseFunction;
12
- retriable: <F extends (...args: any[]) => any>(fnZone: Zone, name: string, fn: F) => PromiseToVow<F>;
10
+ retriable: <F extends (...args: any[]) => Promise<any>>(fnZone: Zone, name: string, fn: F) => F extends (...args: infer Args) => Promise<infer R> ? (...args: Args) => Vow<R> : never;
13
11
  };
14
- /**
15
- * Converts a function type that returns a Promise to a function type that
16
- * returns a Vow. If the input is not a function returning a Promise, it
17
- * preserves the original type.
18
- */
19
- export type PromiseToVow<T> = T extends (...args: infer Args) => Promise<infer R> ? (...args: Args) => Vow<R> : T extends (...args: infer Args) => infer R ? (...args: Args) => R : T;
20
12
  export type VowTools = ReturnType<typeof prepareVowTools>;
21
13
  import type { Zone } from '@agoric/base-zone';
22
14
  import type { IsRetryableReason } from './types.js';
@@ -1 +1 @@
1
- {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["tools.js"],"names":[],"mappings":"AAoCO,sCAJI,IAAI;;;;;;yBA0CF,KAAK,OAAO,CAAC,EAAE;;IAoB5B,6DAA6D;IAC7D,GADE;;gBApCuC,CAAC,SAA3B,CAAE,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAI,UAC3B,IAAI,QACJ,MAAM,MACN,CAAC,KACC,YAAY,CAAC,CAAC,CAAC;EA6B7B;;;;;;yBAzEY,CAAC,IACD,CAAC,SAAS,CACtB,GAAK,IAAI,EAAE,MAAM,IAAI,KACd,OAAO,CAAC,MAAM,CAAC,CAAC,GACnB,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC,CAAC,GACzB,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,MAAM,IAAI,KAAK,MAAM,CAAC,GAC1C,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,CAAC,GACpB,CAAC;uBAqEQ,UAAU,CAAC,OAAO,eAAe,CAAC;0BAtFzB,mBAAmB;uCAC8B,YAAY;0BAAZ,YAAY;yBAAZ,YAAY;uCAAZ,YAAY"}
1
+ {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["tools.js"],"names":[],"mappings":"AAoBO,sCAJI,IAAI;;;;;;yBAwCF,KAAK,OAAO,CAAC,EAAE;oCAqB6V,GAAG;;gBArC1U,CAAC,SAApC,CAAE,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,GAAG,CAAE,UACpC,IAAI,QACJ,MAAM,MACN,CAAC,KACC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,MAAM,IAAI,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC,CAAC,GAAG,KAAK;EA6BrG;uBAGa,UAAU,CAAC,OAAO,eAAe,CAAC;0BApEzB,mBAAmB;uCAC8B,YAAY;0BAAZ,YAAY;yBAAZ,YAAY;uCAAZ,YAAY"}
package/src/tools.js CHANGED
@@ -10,22 +10,6 @@ import { makeWhen } from './when.js';
10
10
  * @import {IsRetryableReason, AsPromiseFunction, EVow, Vow, ERef} from './types.js';
11
11
  */
12
12
 
13
- // TODO find a good home, DRY with orchestration package.
14
- /**
15
- * Converts a function type that returns a Promise to a function type that
16
- * returns a Vow. If the input is not a function returning a Promise, it
17
- * preserves the original type.
18
- *
19
- * @template T - The type to transform
20
- * @typedef {T extends (
21
- * ...args: infer Args
22
- * ) => Promise<infer R>
23
- * ? (...args: Args) => Vow<R>
24
- * : T extends (...args: infer Args) => infer R
25
- * ? (...args: Args) => R
26
- * : T} PromiseToVow
27
- */
28
-
29
13
  /**
30
14
  * NB: Not to be used in a Vat. It doesn't know what an upgrade is. For that you
31
15
  * need `prepareVowTools` from `vat.js`.
@@ -54,13 +38,11 @@ export const prepareVowTools = (zone, powers = {}) => {
54
38
  * Create a function that retries the given function if the underlying
55
39
  * functions rejects due to upgrade disconnection.
56
40
  *
57
- * The internal functions
58
- *
59
- * @template {(...args: any[]) => any} F
41
+ * @template {(...args: any[]) => Promise<any>} F
60
42
  * @param {Zone} fnZone - the zone for the named function
61
43
  * @param {string} name
62
44
  * @param {F} fn
63
- * @returns {PromiseToVow<F>}
45
+ * @returns {F extends (...args: infer Args) => Promise<infer R> ? (...args: Args) => Vow<R> : never}
64
46
  */
65
47
  const retriable =
66
48
  (fnZone, name, fn) =>