@agoric/vow 0.1.1-dev-9f30228.0 → 0.1.1-dev-0b1501a.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 +6 -6
- package/src/tools.d.ts +41 -8
- package/src/tools.d.ts.map +1 -1
- package/src/tools.js +34 -4
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-0b1501a.0+0b1501a",
|
|
4
4
|
"description": "Remote (shortening and disconnection-tolerant) Promise-likes",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
"lint:types": "tsc"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@agoric/base-zone": "0.1.1-dev-
|
|
23
|
-
"@agoric/internal": "0.3.3-dev-
|
|
22
|
+
"@agoric/base-zone": "0.1.1-dev-0b1501a.0+0b1501a",
|
|
23
|
+
"@agoric/internal": "0.3.3-dev-0b1501a.0+0b1501a",
|
|
24
24
|
"@endo/env-options": "^1.1.6",
|
|
25
25
|
"@endo/errors": "^1.2.5",
|
|
26
26
|
"@endo/eventual-send": "^1.2.5",
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@agoric/internal": "^0.3.2",
|
|
33
|
-
"@agoric/swingset-vat": "0.32.3-dev-
|
|
34
|
-
"@agoric/zone": "0.2.3-dev-
|
|
33
|
+
"@agoric/swingset-vat": "0.32.3-dev-0b1501a.0+0b1501a",
|
|
34
|
+
"@agoric/zone": "0.2.3-dev-0b1501a.0+0b1501a",
|
|
35
35
|
"@endo/far": "^1.1.5",
|
|
36
36
|
"@endo/init": "^1.1.4",
|
|
37
37
|
"ava": "^5.3.0",
|
|
@@ -57,5 +57,5 @@
|
|
|
57
57
|
"typeCoverage": {
|
|
58
58
|
"atLeast": 89.96
|
|
59
59
|
},
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "0b1501ace92d3f53ba37e1c83f508f61c14fcd7d"
|
|
61
61
|
}
|
package/src/tools.d.ts
CHANGED
|
@@ -1,11 +1,22 @@
|
|
|
1
1
|
export function prepareBasicVowTools(zone: Zone, powers?: {
|
|
2
2
|
isRetryableReason?: IsRetryableReason | undefined;
|
|
3
|
-
} | undefined):
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
} | undefined): VowTools;
|
|
4
|
+
export type VowTools = {
|
|
5
|
+
/**
|
|
6
|
+
* Vow-tolerant implementation of Promise.all that takes an iterable of vows
|
|
7
|
+
* and other {@link Passable}s and returns a single {@link Vow}. It resolves
|
|
8
|
+
* with an array of values when all of the input's promises or vows are
|
|
9
|
+
* fulfilled and rejects when any of the input's promises or vows are rejected
|
|
10
|
+
* with the first rejection reason.
|
|
11
|
+
*/
|
|
7
12
|
all: (maybeVows: unknown[]) => Vow<any[]>;
|
|
8
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Vow-tolerant
|
|
15
|
+
* implementation of Promise.allSettled that takes an iterable of vows and other
|
|
16
|
+
* {@link Passable}s and returns a single {@link Vow}. It resolves when all of
|
|
17
|
+
* the input's promises or vows are settled with an array of settled outcome
|
|
18
|
+
* objects.
|
|
19
|
+
*/
|
|
9
20
|
allSettled: (maybeVows: unknown[]) => Vow<({
|
|
10
21
|
status: "fulfilled";
|
|
11
22
|
value: any;
|
|
@@ -13,14 +24,36 @@ export function prepareBasicVowTools(zone: Zone, powers?: {
|
|
|
13
24
|
status: "rejected";
|
|
14
25
|
reason: any;
|
|
15
26
|
})[]>;
|
|
16
|
-
|
|
27
|
+
allVows: (maybeVows: unknown[]) => Vow<any[]>;
|
|
28
|
+
/**
|
|
29
|
+
* Convert a vow or promise to a promise, ensuring proper handling of ephemeral promises.
|
|
30
|
+
*/
|
|
17
31
|
asPromise: AsPromiseFunction;
|
|
32
|
+
/**
|
|
33
|
+
* Helper function that
|
|
34
|
+
* coerces the result of a function to a Vow. Helpful for scenarios like a
|
|
35
|
+
* synchronously thrown error.
|
|
36
|
+
*/
|
|
37
|
+
asVow: <T extends unknown>(fn: (...args: any[]) => Vow<Awaited<T>> | Awaited<T> | PromiseVow<T>) => Vow<Awaited<T>>;
|
|
38
|
+
makeVowKit: <T>() => VowKit<T>;
|
|
18
39
|
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;
|
|
40
|
+
watch: <T = any, TResult1 = T, TResult2 = never, C extends any[] = any[]>(specimenP: EVow<T>, watcher?: Watcher<T, TResult1, TResult2, C> | undefined, ...watcherArgs: C) => Vow<Exclude<TResult1, void> | Exclude<TResult2, void> extends never ? TResult1 : Exclude<TResult1, void> | Exclude<TResult2, void>>;
|
|
41
|
+
/**
|
|
42
|
+
* Shorten `specimenP` until we achieve a final result.
|
|
43
|
+
*
|
|
44
|
+
* Does not survive upgrade (even if specimenP is a durable Vow).
|
|
45
|
+
*
|
|
46
|
+
* Use only if the Vow will resolve _promptly_ {@see {@link @agoric/swingset-vat/docs/async.md}}.
|
|
47
|
+
*/
|
|
48
|
+
when: <T, TResult1 = EUnwrap<T>, TResult2 = never>(specimenP: T, onFulfilled?: ((value: EUnwrap<T>) => TResult1 | PromiseLike<TResult1>) | undefined, onRejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined) => Promise<TResult1 | TResult2>;
|
|
19
49
|
};
|
|
20
|
-
export type VowTools = ReturnType<typeof prepareBasicVowTools>;
|
|
21
50
|
import type { Zone } from '@agoric/base-zone';
|
|
22
51
|
import type { IsRetryableReason } from './types.js';
|
|
23
|
-
import type { EVow } from './types.js';
|
|
24
52
|
import type { Vow } from './types.js';
|
|
25
53
|
import type { AsPromiseFunction } from './types.js';
|
|
54
|
+
import type { PromiseVow } from './types.js';
|
|
55
|
+
import type { VowKit } from './types.js';
|
|
56
|
+
import type { EVow } from './types.js';
|
|
57
|
+
import type { Watcher } from './types.js';
|
|
58
|
+
import type { EUnwrap } from './types.js';
|
|
26
59
|
//# 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":"AAmDO,2CALI,IAAI;;gBAGF,QAAQ,CA+EpB;;;;;;;;;SAjHa,CAAC,SAAS,EAAE,OAAO,EAAE,KAAK,IAAI,GAAG,EAAE,CAAC;;;;;;;;gBAKpC,CAAC,SAAS,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;QAAC,MAAM,EAAE,WAAW,CAAC;QAAC,KAAK,EAAE,GAAG,CAAA;KAAC,GAC7E;QAAG,MAAM,EAAE,UAAU,CAAC;QAAC,MAAM,EAAE,GAAG,CAAA;KAAC,CAAC,EAAE,CAAC;aAK1B,CAAC,SAAS,EAAE,OAAO,EAAE,KAAK,IAAI,GAAG,EAAE,CAAC;;;;eACpC,iBAAiB;;;;;;WACjB,CAAC,CAAiB,SAAP,OAAO,EAAE,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC,GACtE,OAAO,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,KAAK,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC;gBAGnC,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC;eAClB,CAAC,CAA0C,SAAhC,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,K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8,7 +8,36 @@ import { makeWhen } from './when.js';
|
|
|
8
8
|
/**
|
|
9
9
|
* @import {Zone} from '@agoric/base-zone';
|
|
10
10
|
* @import {Passable} from '@endo/pass-style';
|
|
11
|
-
* @import {IsRetryableReason, AsPromiseFunction, EVow,
|
|
11
|
+
* @import {EUnwrap, IsRetryableReason, AsPromiseFunction, Vow, VowKit, EVow, PromiseVow, Watcher} from './types.js';
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @typedef VowTools
|
|
16
|
+
* @property {(maybeVows: unknown[]) => Vow<any[]>} all Vow-tolerant implementation of Promise.all that takes an iterable of vows
|
|
17
|
+
* and other {@link Passable}s and returns a single {@link Vow}. It resolves
|
|
18
|
+
* with an array of values when all of the input's promises or vows are
|
|
19
|
+
* fulfilled and rejects when any of the input's promises or vows are rejected
|
|
20
|
+
* with the first rejection reason.
|
|
21
|
+
* @property {(maybeVows: unknown[]) => Vow<({status: 'fulfilled', value: any} |
|
|
22
|
+
* {status: 'rejected', reason: any})[]>} allSettled Vow-tolerant
|
|
23
|
+
* implementation of Promise.allSettled that takes an iterable of vows and other
|
|
24
|
+
* {@link Passable}s and returns a single {@link Vow}. It resolves when all of
|
|
25
|
+
* the input's promises or vows are settled with an array of settled outcome
|
|
26
|
+
* objects.
|
|
27
|
+
* @property {(maybeVows: unknown[]) => Vow<any[]>} allVows
|
|
28
|
+
* @property {AsPromiseFunction} asPromise Convert a vow or promise to a promise, ensuring proper handling of ephemeral promises.
|
|
29
|
+
* @property {<T extends unknown>(fn: (...args: any[]) => Vow<Awaited<T>> |
|
|
30
|
+
* Awaited<T> | PromiseVow<T>) => Vow<Awaited<T>>} asVow Helper function that
|
|
31
|
+
* coerces the result of a function to a Vow. Helpful for scenarios like a
|
|
32
|
+
* synchronously thrown error.
|
|
33
|
+
* @property {<T>() => VowKit<T>} makeVowKit
|
|
34
|
+
* @property {<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} retriable
|
|
35
|
+
* @property {<T = any, TResult1 = T, TResult2 = never, C extends any[] = any[]>(specimenP: EVow<T>, watcher?: Watcher<T, TResult1, TResult2, C> | undefined, ...watcherArgs: C) => Vow<Exclude<TResult1, void> | Exclude<TResult2, void> extends never ? TResult1 : Exclude<TResult1, void> | Exclude<TResult2, void>>} watch
|
|
36
|
+
* @property {<T, TResult1 = EUnwrap<T>, TResult2 = never>(specimenP: T, onFulfilled?: ((value: EUnwrap<T>) => TResult1 | PromiseLike<TResult1>) | undefined, onRejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined) => Promise<TResult1 | TResult2>} when Shorten `specimenP` until we achieve a final result.
|
|
37
|
+
*
|
|
38
|
+
* Does not survive upgrade (even if specimenP is a durable Vow).
|
|
39
|
+
*
|
|
40
|
+
* Use only if the Vow will resolve _promptly_ {@see {@link @agoric/swingset-vat/docs/async.md}}.
|
|
12
41
|
*/
|
|
13
42
|
|
|
14
43
|
/**
|
|
@@ -18,6 +47,7 @@ import { makeWhen } from './when.js';
|
|
|
18
47
|
* @param {Zone} zone
|
|
19
48
|
* @param {object} [powers]
|
|
20
49
|
* @param {IsRetryableReason} [powers.isRetryableReason]
|
|
50
|
+
* @returns {VowTools}
|
|
21
51
|
*/
|
|
22
52
|
export const prepareBasicVowTools = (zone, powers = {}) => {
|
|
23
53
|
const { isRetryableReason = /** @type {IsRetryableReason} */ (() => false) } =
|
|
@@ -34,8 +64,10 @@ export const prepareBasicVowTools = (zone, powers = {}) => {
|
|
|
34
64
|
const watchUtils = makeWatchUtils();
|
|
35
65
|
const asVow = makeAsVow(makeVowKit);
|
|
36
66
|
|
|
67
|
+
// FIXME in https://github.com/Agoric/agoric-sdk/pull/9785
|
|
37
68
|
/**
|
|
38
|
-
*
|
|
69
|
+
* @alpha Not yet implemented
|
|
70
|
+
*
|
|
39
71
|
* Create a function that retries the given function if the underlying
|
|
40
72
|
* functions rejects due to upgrade disconnection.
|
|
41
73
|
*
|
|
@@ -96,5 +128,3 @@ export const prepareBasicVowTools = (zone, powers = {}) => {
|
|
|
96
128
|
});
|
|
97
129
|
};
|
|
98
130
|
harden(prepareBasicVowTools);
|
|
99
|
-
|
|
100
|
-
/** @typedef {ReturnType<typeof prepareBasicVowTools>} VowTools */
|