@agoric/vow 0.1.1-dev-0006934.0 → 0.1.1-dev-12ce494.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 +4 -4
- package/src/tools.d.ts +10 -3
- package/src/tools.d.ts.map +1 -1
- package/src/tools.js +20 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/vow",
|
|
3
|
-
"version": "0.1.1-dev-
|
|
3
|
+
"version": "0.1.1-dev-12ce494.0+12ce494",
|
|
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-
|
|
24
|
-
"@agoric/internal": "0.3.3-dev-
|
|
23
|
+
"@agoric/base-zone": "0.1.1-dev-12ce494.0+12ce494",
|
|
24
|
+
"@agoric/internal": "0.3.3-dev-12ce494.0+12ce494",
|
|
25
25
|
"@endo/env-options": "^1.1.4",
|
|
26
26
|
"@endo/errors": "^1.2.2",
|
|
27
27
|
"@endo/eventual-send": "^1.2.2",
|
|
@@ -55,5 +55,5 @@
|
|
|
55
55
|
"typeCoverage": {
|
|
56
56
|
"atLeast": 89.6
|
|
57
57
|
},
|
|
58
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "12ce49423c9afe6eb2396e7cac79b7f2f003cbb0"
|
|
59
59
|
}
|
package/src/tools.d.ts
CHANGED
|
@@ -5,15 +5,22 @@ 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: (
|
|
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>>;
|
|
9
11
|
asPromise: AsPromiseFunction;
|
|
10
|
-
retriable: <
|
|
12
|
+
retriable: <F extends (...args: any[]) => any>(fnZone: Zone, name: string, fn: F) => PromiseToVow<F>;
|
|
11
13
|
};
|
|
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;
|
|
12
20
|
export type VowTools = ReturnType<typeof prepareVowTools>;
|
|
13
21
|
import type { Zone } from '@agoric/base-zone';
|
|
14
22
|
import type { IsRetryableReason } from './types.js';
|
|
15
23
|
import type { EVow } from './types.js';
|
|
16
24
|
import type { Vow } from './types.js';
|
|
17
25
|
import type { AsPromiseFunction } from './types.js';
|
|
18
|
-
import type { ERef } from './types.js';
|
|
19
26
|
//# sourceMappingURL=tools.d.ts.map
|
package/src/tools.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["tools.js"],"names":[],"mappings":"
|
|
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"}
|
package/src/tools.js
CHANGED
|
@@ -10,6 +10,22 @@ 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
|
+
|
|
13
29
|
/**
|
|
14
30
|
* NB: Not to be used in a Vat. It doesn't know what an upgrade is. For that you
|
|
15
31
|
* need `prepareVowTools` from `vat.js`.
|
|
@@ -40,14 +56,15 @@ export const prepareVowTools = (zone, powers = {}) => {
|
|
|
40
56
|
*
|
|
41
57
|
* The internal functions
|
|
42
58
|
*
|
|
43
|
-
* @template
|
|
59
|
+
* @template {(...args: any[]) => any} F
|
|
44
60
|
* @param {Zone} fnZone - the zone for the named function
|
|
45
61
|
* @param {string} name
|
|
46
|
-
* @param {
|
|
47
|
-
* @returns {
|
|
62
|
+
* @param {F} fn
|
|
63
|
+
* @returns {PromiseToVow<F>}
|
|
48
64
|
*/
|
|
49
65
|
const retriable =
|
|
50
66
|
(fnZone, name, fn) =>
|
|
67
|
+
// @ts-expect-error cast
|
|
51
68
|
(...args) => {
|
|
52
69
|
return watch(fn(...args));
|
|
53
70
|
};
|