@agoric/vow 0.2.0 → 0.2.1-upgrade-23-dev-bd79330.0.bd79330
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 +11 -11
- package/src/E.d.ts +4 -54
- package/src/E.d.ts.map +1 -1
- package/src/E.js +6 -8
- package/src/retryable.d.ts +1 -30
- package/src/retryable.d.ts.map +1 -1
- package/src/retryable.js +1 -1
- package/src/tools.d.ts.map +1 -1
- package/src/tools.js +10 -4
- package/src/types.d.ts +24 -12
- package/src/types.d.ts.map +1 -1
- package/src/types.js +206 -0
- package/src/watch-utils.d.ts +13 -10
- package/src/watch-utils.d.ts.map +1 -1
- package/src/watch-utils.js +16 -6
- package/vat.js +7 -2
- package/src/types.ts +0 -195
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/vow",
|
|
3
|
-
"version": "0.2.0",
|
|
3
|
+
"version": "0.2.1-upgrade-23-dev-bd79330.0.bd79330",
|
|
4
4
|
"description": "Remote (shortening and disconnection-tolerant) Promise-likes",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -9,19 +9,19 @@
|
|
|
9
9
|
},
|
|
10
10
|
"scripts": {
|
|
11
11
|
"build": "exit 0",
|
|
12
|
-
"prepack": "yarn run -T
|
|
13
|
-
"postpack": "
|
|
12
|
+
"prepack": "yarn run -T prepack-package",
|
|
13
|
+
"postpack": "yarn run -T postpack-package",
|
|
14
14
|
"test": "ava",
|
|
15
15
|
"test:xs": "exit 0",
|
|
16
16
|
"test:xs:ci": "npm run test:xs",
|
|
17
17
|
"lint-fix": "yarn lint:eslint --fix",
|
|
18
18
|
"lint": "yarn run -T run-s --continue-on-error 'lint:*'",
|
|
19
|
-
"lint:eslint": "
|
|
19
|
+
"lint:eslint": "node ../../scripts/eslint-repo.mjs .",
|
|
20
20
|
"lint:types": "yarn run -T tsc"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@agoric/base-zone": "0.2.0",
|
|
24
|
-
"@agoric/internal": "0.4.0",
|
|
23
|
+
"@agoric/base-zone": "0.2.1-upgrade-23-dev-bd79330.0.bd79330",
|
|
24
|
+
"@agoric/internal": "0.4.1-upgrade-23-dev-bd79330.0.bd79330",
|
|
25
25
|
"@endo/env-options": "^1.1.11",
|
|
26
26
|
"@endo/errors": "^1.2.13",
|
|
27
27
|
"@endo/eventual-send": "^1.3.4",
|
|
@@ -31,11 +31,11 @@
|
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@agoric/internal": "workspace:*",
|
|
34
|
-
"@agoric/swingset-vat": "0.33.0",
|
|
35
|
-
"@agoric/zone": "0.3.0",
|
|
34
|
+
"@agoric/swingset-vat": "0.33.1-upgrade-23-dev-bd79330.0.bd79330",
|
|
35
|
+
"@agoric/zone": "0.3.1-upgrade-23-dev-bd79330.0.bd79330",
|
|
36
36
|
"@endo/far": "^1.1.14",
|
|
37
37
|
"@endo/init": "^1.1.12",
|
|
38
|
-
"ava": "^
|
|
38
|
+
"ava": "^6.4.1",
|
|
39
39
|
"tsd": "^0.33.0"
|
|
40
40
|
},
|
|
41
41
|
"ava": {
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"access": "public"
|
|
57
57
|
},
|
|
58
58
|
"typeCoverage": {
|
|
59
|
-
"atLeast":
|
|
59
|
+
"atLeast": 92.06
|
|
60
60
|
},
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "bd79330f78dae2faf9cc3d8b10063567700da07b"
|
|
62
62
|
}
|
package/src/E.d.ts
CHANGED
|
@@ -1,62 +1,12 @@
|
|
|
1
1
|
export default makeE;
|
|
2
2
|
export type Callable = (...args: unknown[]) => any;
|
|
3
|
-
export type EProxy = ReturnType<
|
|
4
|
-
unwrap?: (<T>(x: T) => Promise<EUnwrap<T>>) | undefined;
|
|
5
|
-
additional?: A | undefined;
|
|
6
|
-
}) => (<T>(x: T) => ECallableOrMethods<RemoteFunctions<T>>) & {
|
|
7
|
-
/**
|
|
8
|
-
* E.get(x) returns a proxy on which you can get arbitrary properties.
|
|
9
|
-
* Each of these properties returns a promise for the property. The promise
|
|
10
|
-
* value will be the property fetched from whatever 'x' designates (or
|
|
11
|
-
* resolves to) in a future turn, not this one.
|
|
12
|
-
*
|
|
13
|
-
* @template T
|
|
14
|
-
* @param {T} x target for property get
|
|
15
|
-
* @returns {EGetters<LocalRecord<T>>} property get proxy
|
|
16
|
-
* @readonly
|
|
17
|
-
*/
|
|
18
|
-
readonly get: <T>(x: T) => EGetters<LocalRecord<T>>;
|
|
19
|
-
/**
|
|
20
|
-
* E.resolve(x) converts x to a handled promise. It is
|
|
21
|
-
* shorthand for HandledPromise.resolve(x)
|
|
22
|
-
*
|
|
23
|
-
* @template T
|
|
24
|
-
* @param {T} x value to convert to a handled promise
|
|
25
|
-
* @returns {Promise<Awaited<T>>} handled promise for x
|
|
26
|
-
* @readonly
|
|
27
|
-
*/
|
|
28
|
-
readonly resolve: <T>(x: T) => Promise<Awaited<T>>;
|
|
29
|
-
/**
|
|
30
|
-
* E.sendOnly returns a proxy similar to E, but for which the results
|
|
31
|
-
* are ignored (undefined is returned).
|
|
32
|
-
*
|
|
33
|
-
* @template T
|
|
34
|
-
* @param {T} x target for method/function call
|
|
35
|
-
* @returns {ESendOnlyCallableOrMethods<RemoteFunctions<T>>} method/function call proxy
|
|
36
|
-
* @readonly
|
|
37
|
-
*/
|
|
38
|
-
readonly sendOnly: <T>(x: T) => ESendOnlyCallableOrMethods<RemoteFunctions<T>>;
|
|
39
|
-
/**
|
|
40
|
-
* E.when(x, res, rej) is equivalent to
|
|
41
|
-
* unwrap(x).then(onfulfilled, onrejected)
|
|
42
|
-
*
|
|
43
|
-
* @template T
|
|
44
|
-
* @template [TResult1=EUnwrap<T>]
|
|
45
|
-
* @template [TResult2=never]
|
|
46
|
-
* @param {ERef<T>} x value to convert to a handled promise
|
|
47
|
-
* @param {(value: EUnwrap<T>) => ERef<TResult1>} [onfulfilled]
|
|
48
|
-
* @param {(reason: any) => ERef<TResult2>} [onrejected]
|
|
49
|
-
* @returns {Promise<TResult1 | TResult2>}
|
|
50
|
-
* @readonly
|
|
51
|
-
*/
|
|
52
|
-
readonly when: <T, TResult1 = EUnwrap<T>, TResult2 = never>(x: ERef<T>, onfulfilled?: (value: EUnwrap<T>) => ERef<TResult1>, onrejected?: (reason: any) => ERef<TResult2>) => Promise<TResult1 | TResult2>;
|
|
53
|
-
} & A)>;
|
|
3
|
+
export type EProxy = ReturnType<typeof makeE>;
|
|
54
4
|
/**
|
|
55
5
|
* `DataOnly<T>` means to return a record type `T2` consisting only of
|
|
56
6
|
* properties that are *not* functions.
|
|
57
7
|
*/
|
|
58
8
|
export type DataOnly<T> = Omit<T, FilteredKeys<T, Callable>>;
|
|
59
|
-
export type ECallable<T extends Callable> = ReturnType<T> extends
|
|
9
|
+
export type ECallable<T extends Callable> = ReturnType<T> extends Promise<EUnwrap<ReturnType<T>>> ? T : (...args: Parameters<T>) => Promise<EUnwrap<ReturnType<T>>>;
|
|
60
10
|
export type EMethods<T> = { readonly [P in keyof T]: T[P] extends Callable ? ECallable<T[P]> : never; };
|
|
61
11
|
export type EGetters<T> = { readonly [P in keyof T]: T[P] extends PromiseLike<any> ? T[P] : Promise<Awaited<T[P]>>; };
|
|
62
12
|
export type ESendOnlyCallable<T extends Callable> = (...args: Parameters<T>) => Promise<void>;
|
|
@@ -147,8 +97,8 @@ declare function makeE<A = {}>(HandledPromise: HandledPromiseConstructor, powers
|
|
|
147
97
|
*/
|
|
148
98
|
readonly when: <T, TResult1 = EUnwrap<T>, TResult2 = never>(x: ERef<T>, onfulfilled?: (value: EUnwrap<T>) => ERef<TResult1>, onrejected?: (reason: any) => ERef<TResult2>) => Promise<TResult1 | TResult2>;
|
|
149
99
|
} & A;
|
|
150
|
-
import type { HandledPromiseConstructor } from '@endo/eventual-send';
|
|
151
100
|
import type { EUnwrap } from './types.js';
|
|
152
|
-
import type { ERef } from '@endo/far';
|
|
153
101
|
import type { RemotableBrand } from '@endo/eventual-send';
|
|
102
|
+
import type { ERef } from '@endo/far';
|
|
103
|
+
import type { HandledPromiseConstructor } from '@endo/eventual-send';
|
|
154
104
|
//# sourceMappingURL=E.d.ts.map
|
package/src/E.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"E.d.ts","sourceRoot":"","sources":["E.js"],"names":[],"mappings":";uBAiCc,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,GAAG;qBAuR3B,UAAU,
|
|
1
|
+
{"version":3,"file":"E.d.ts","sourceRoot":"","sources":["E.js"],"names":[],"mappings":";uBAiCc,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,GAAG;qBAuR3B,UAAU,CAAC,OAAO,KAAK,CAAC;;;;;qBAMzB,CAAC,IACD,IAAI,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;sBAIvB,CAAC,SAAX,QAAS,IACV,UAAU,CAAC,CAAC,CAAC,SAAS,OAAO,CAAC,QAAQ,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,GACzD,CAAC,GACD,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,QAAQ,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;qBAIvD,CAAC,IACD,EACZ,QAAY,EAAE,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,QAAQ,GAC1C,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GACf,KAAK,GACV;qBAIS,CAAC,IACD,EACZ,QAAY,EAAE,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,WAAW,CAAC,GAAG,CAAC,GAClD,CAAC,CAAC,CAAC,CAAC,GACJ,OAAO,CAAC,OAAO,CAA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W3D;;;;;;;;;;;;OAYG;oBARU,CAAC,EACA,QAAQ,eACR,QAAQ,aACX,KAAK,CAAC,CAAC,gBACP,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,KAAK,KAAK,QAAQ,CAAC,eACrC,CAAC,MAAM,EAAE,GAAG,KAAK,KAAK,QAAQ,CAAC,KAC7B,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAC;MAgBhD;6BA7RyB,YAAY;oCAQwB,qBAAqB;0BAT5D,WAAW;+CAS4B,qBAAqB"}
|
package/src/E.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
/**
|
|
3
3
|
* @file provides a `makeE` that can be parameterized with an `unwrap` function
|
|
4
|
-
* and corresponding `
|
|
4
|
+
* and corresponding `EUnwrap<T>`. These will be used to
|
|
5
5
|
* extract the final settlement from a chain of PromiseLikes and PromiseSteps or
|
|
6
6
|
* similar non-thenable pseudo-promises.
|
|
7
7
|
*
|
|
@@ -21,6 +21,7 @@ import { makeMessageBreakpointTester } from './message-breakpoints.js';
|
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* @import {ERef} from '@endo/far';
|
|
24
|
+
* @import {EUnwrap} from './types.js';
|
|
24
25
|
*/
|
|
25
26
|
|
|
26
27
|
const { assign, create } = Object;
|
|
@@ -29,7 +30,6 @@ const onSend = makeMessageBreakpointTester('ENDO_SEND_BREAKPOINTS');
|
|
|
29
30
|
|
|
30
31
|
/**
|
|
31
32
|
* @import { HandledPromiseConstructor, RemotableBrand } from '@endo/eventual-send'
|
|
32
|
-
* @import { EUnwrap } from './types.js'
|
|
33
33
|
*/
|
|
34
34
|
/** @typedef {(...args: unknown[]) => any} Callable */
|
|
35
35
|
|
|
@@ -310,7 +310,7 @@ const makeE = (HandledPromise, powers = {}) => {
|
|
|
310
310
|
|
|
311
311
|
export default makeE;
|
|
312
312
|
|
|
313
|
-
/** @typedef {ReturnType<makeE>} EProxy */
|
|
313
|
+
/** @typedef {ReturnType<typeof makeE>} EProxy */
|
|
314
314
|
|
|
315
315
|
/**
|
|
316
316
|
* `DataOnly<T>` means to return a record type `T2` consisting only of
|
|
@@ -322,11 +322,9 @@ export default makeE;
|
|
|
322
322
|
|
|
323
323
|
/**
|
|
324
324
|
* @template {Callable} T
|
|
325
|
-
* @typedef {ReturnType<T> extends EUnwrap<ReturnType<T
|
|
326
|
-
* ?
|
|
327
|
-
* :
|
|
328
|
-
* ? T
|
|
329
|
-
* : (...args: Parameters<T>) => Promise<EUnwrap<ReturnType<T>>>} ECallable
|
|
325
|
+
* @typedef {ReturnType<T> extends Promise<EUnwrap<ReturnType<T>>>
|
|
326
|
+
* ? T
|
|
327
|
+
* : (...args: Parameters<T>) => Promise<EUnwrap<ReturnType<T>>>} ECallable
|
|
330
328
|
*/
|
|
331
329
|
|
|
332
330
|
/**
|
package/src/retryable.d.ts
CHANGED
|
@@ -33,36 +33,7 @@ export type PreparationOptions = {
|
|
|
33
33
|
isRetryableReason: IsRetryableReason;
|
|
34
34
|
};
|
|
35
35
|
export type RetryableFunc = (...args: Passable[]) => Promise<any>;
|
|
36
|
-
export type RetryableTools = ReturnType<
|
|
37
|
-
prepareRetryableFlowKit: (zone: Zone, tag: string, retryableFunc: RetryableFunc) => (activationArgs: any) => import("@endo/exo").GuardedKit<{
|
|
38
|
-
flow: {
|
|
39
|
-
/**
|
|
40
|
-
* Calls the retryable function, either for the initial run or when
|
|
41
|
-
* the result of the previous run fails with a retryable reason.
|
|
42
|
-
*/
|
|
43
|
-
restart(): void;
|
|
44
|
-
getOutcome(): Vow<any>;
|
|
45
|
-
};
|
|
46
|
-
resultWatcher: {
|
|
47
|
-
onFulfilled(value: any, runId: any): void;
|
|
48
|
-
onRejected(reason: any, runId: any): void;
|
|
49
|
-
};
|
|
50
|
-
}>;
|
|
51
|
-
adminRetryableFlow: import("@endo/exo").Guarded<{
|
|
52
|
-
/**
|
|
53
|
-
* @param {Vow} outcomeVow
|
|
54
|
-
*/
|
|
55
|
-
getFlowForOutcomeVow(outcomeVow: Vow): import("@endo/exo").Guarded<{
|
|
56
|
-
/**
|
|
57
|
-
* Calls the retryable function, either for the initial run or when
|
|
58
|
-
* the result of the previous run fails with a retryable reason.
|
|
59
|
-
*/
|
|
60
|
-
restart(): void;
|
|
61
|
-
getOutcome(): Vow<any>;
|
|
62
|
-
}>;
|
|
63
|
-
}>;
|
|
64
|
-
retryable: import("./types.js").RetryableTool;
|
|
65
|
-
}>;
|
|
36
|
+
export type RetryableTools = ReturnType<typeof prepareRetryableTools>;
|
|
66
37
|
export type AdminRetryableFlow = RetryableTools["adminRetryableFlow"];
|
|
67
38
|
export type MakeRetryableFlowKit = ReturnType<RetryableTools["prepareRetryableFlowKit"]>;
|
|
68
39
|
export type RetryableFlowKit = ReturnType<MakeRetryableFlowKit>;
|
package/src/retryable.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retryable.d.ts","sourceRoot":"","sources":["retryable.js"],"names":[],"mappings":"AAwCO,iDAHI,IAAI,gBACJ,kBAAkB;oCAoBhB,IAAI,OACJ,MAAM,iBACN,aAAa;;YAsBhB;;;eAGG;;;;;;;;;;QAuGP;;WAEG;yCADQ,GAAG;YA3GV;;;eAGG;;;;;;EAqHZ;;gBA5La,MAAM,OAAO,GAAG,CAAC;uBACjB,iBAAiB;;4BAIlB,CAAC,GAAG,IAAI,EAAE,QAAQ,EAAE,KAAK,OAAO,CAAC,GAAG,CAAC;6BA2LrC,UAAU,
|
|
1
|
+
{"version":3,"file":"retryable.d.ts","sourceRoot":"","sources":["retryable.js"],"names":[],"mappings":"AAwCO,iDAHI,IAAI,gBACJ,kBAAkB;oCAoBhB,IAAI,OACJ,MAAM,iBACN,aAAa;;YAsBhB;;;eAGG;;;;;;;;;;QAuGP;;WAEG;yCADQ,GAAG;YA3GV;;;eAGG;;;;;;EAqHZ;;gBA5La,MAAM,OAAO,GAAG,CAAC;uBACjB,iBAAiB;;4BAIlB,CAAC,GAAG,IAAI,EAAE,QAAQ,EAAE,KAAK,OAAO,CAAC,GAAG,CAAC;6BA2LrC,UAAU,CAAC,OAAO,qBAAqB,CAAC;iCAIxC,cAAc,CAAC,oBAAoB,CAAC;mCAIpC,UAAU,CAAC,cAAc,CAAC,yBAAyB,CAAC,CAAC;+BAIrD,UAAU,CAAC,oBAAoB,CAAC;4BAIhC,gBAAgB,CAAC,MAAM,CAAC;0BAvNd,mBAAmB;yBACiB,YAAY;4BAAZ,YAAY;uCAAZ,YAAY;8BAC/B,kBAAkB"}
|
package/src/retryable.js
CHANGED
|
@@ -204,7 +204,7 @@ export const prepareRetryableTools = (outerZone, outerOptions) => {
|
|
|
204
204
|
harden(prepareRetryableTools);
|
|
205
205
|
|
|
206
206
|
/**
|
|
207
|
-
* @typedef {ReturnType<prepareRetryableTools>} RetryableTools
|
|
207
|
+
* @typedef {ReturnType<typeof prepareRetryableTools>} RetryableTools
|
|
208
208
|
*/
|
|
209
209
|
|
|
210
210
|
/**
|
package/src/tools.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["tools.js"],"names":[],"mappings":"AAwBO,2CALI,IAAI,WAEZ;IAAmC,iBAAiB;CACpD,GAAU,QAAQ,
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["tools.js"],"names":[],"mappings":"AAwBO,2CALI,IAAI,WAEZ;IAAmC,iBAAiB;CACpD,GAAU,QAAQ,CAwEpB;0BApFsB,mBAAmB;uCAEuC,YAAY;8BAAZ,YAAY"}
|
package/src/tools.js
CHANGED
|
@@ -10,7 +10,7 @@ import { makeWhen } from './when.js';
|
|
|
10
10
|
/**
|
|
11
11
|
* @import {Zone} from '@agoric/base-zone';
|
|
12
12
|
* @import {Passable} from '@endo/pass-style';
|
|
13
|
-
* @import {IsRetryableReason, AsPromiseFunction, Vow, VowTools} from './types.js';
|
|
13
|
+
* @import {IsRetryableReason, AsPromiseFunction, Fulfilled, Vow, VowTools} from './types.js';
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
16
|
/**
|
|
@@ -50,13 +50,17 @@ export const prepareBasicVowTools = (zone, powers = {}) => {
|
|
|
50
50
|
* fulfilled and rejects when any of the input's promises or vows are
|
|
51
51
|
* rejected with the first rejection reason.
|
|
52
52
|
*
|
|
53
|
-
* @
|
|
53
|
+
* @template {readonly unknown[]} TS
|
|
54
|
+
* @param {TS} maybeVows
|
|
55
|
+
* @returns {Vow<{ [P in keyof TS]: Fulfilled<TS[P]> }>}
|
|
54
56
|
*/
|
|
55
57
|
const all = maybeVows => watchUtils.all(maybeVows);
|
|
56
58
|
|
|
57
59
|
/**
|
|
58
|
-
* @param {unknown[]} maybeVows
|
|
59
60
|
* @deprecated use `vowTools.all`
|
|
61
|
+
* @template {readonly unknown[]} TS
|
|
62
|
+
* @param {TS} maybeVows
|
|
63
|
+
* @returns {Vow<{ [P in keyof TS]: Fulfilled<TS[P]>}>}
|
|
60
64
|
*/
|
|
61
65
|
const allVows = all;
|
|
62
66
|
|
|
@@ -66,7 +70,9 @@ export const prepareBasicVowTools = (zone, powers = {}) => {
|
|
|
66
70
|
* resolves when all of the input's promises or vows are settled with an
|
|
67
71
|
* array of settled outcome objects.
|
|
68
72
|
*
|
|
69
|
-
* @
|
|
73
|
+
* @template {readonly unknown[]} TS
|
|
74
|
+
* @param {TS} maybeVows
|
|
75
|
+
* @returns {Vow<{ [P in keyof TS]: PromiseSettledResult<Fulfilled<TS[P]>> }>}
|
|
70
76
|
*/
|
|
71
77
|
const allSettled = maybeVows => watchUtils.allSettled(maybeVows);
|
|
72
78
|
|
package/src/types.d.ts
CHANGED
|
@@ -1,16 +1,25 @@
|
|
|
1
1
|
import type { Remote } from '@agoric/internal';
|
|
2
2
|
import type { Zone } from '@agoric/zone';
|
|
3
|
+
import type { ERef } from '@endo/far';
|
|
3
4
|
import type { CopyTagged, RemotableObject } from '@endo/pass-style';
|
|
5
|
+
export type { ERef };
|
|
4
6
|
/**
|
|
5
7
|
* Return truthy if a rejection reason should result in a retry.
|
|
6
8
|
*/
|
|
7
9
|
export type IsRetryableReason = (reason: any, priorRetryValue: any) => any;
|
|
10
|
+
/**
|
|
11
|
+
* Types that are conceptually similar to Promise<F> in that they wrap a fulfilled type.
|
|
12
|
+
*/
|
|
13
|
+
export type VowLike<F> = Promise<F> | PromiseLike<F> | Vow<F>;
|
|
14
|
+
/**
|
|
15
|
+
* Extract the final fulfilment type from a chain of VowLikes.
|
|
16
|
+
*/
|
|
17
|
+
export type Fulfilled<T> = T extends VowLike<infer F> ? Fulfilled<F> : T;
|
|
8
18
|
/**
|
|
9
19
|
* Return type of a function that may
|
|
10
20
|
* return a promise or a vow.
|
|
11
21
|
*/
|
|
12
22
|
export type PromiseVow<T> = Promise<T | Vow<T>>;
|
|
13
|
-
export type ERef<T> = T | PromiseLike<T>;
|
|
14
23
|
/**
|
|
15
24
|
* Eventually a value T or Vow for it.
|
|
16
25
|
*/
|
|
@@ -19,7 +28,7 @@ export type EVow<T> = ERef<T | Vow<T>>;
|
|
|
19
28
|
* Follow the chain of vow shortening to the end, returning the final value.
|
|
20
29
|
* This is used within E, so we must narrow the type to its remote form.
|
|
21
30
|
*/
|
|
22
|
-
export type EUnwrap<T> =
|
|
31
|
+
export type EUnwrap<T> = Fulfilled<T>;
|
|
23
32
|
/**
|
|
24
33
|
* The first version of the vow implementation
|
|
25
34
|
* object. CAVEAT: These methods must never be changed or added to, to provide
|
|
@@ -80,7 +89,9 @@ export type VowTools = {
|
|
|
80
89
|
* fulfilled and rejects when any of the input's promises or vows are rejected
|
|
81
90
|
* with the first rejection reason.
|
|
82
91
|
*/
|
|
83
|
-
all: (maybeVows:
|
|
92
|
+
all: <TS extends readonly unknown[]>(maybeVows: TS) => Vow<{
|
|
93
|
+
[K in keyof TS]: Fulfilled<TS[K]>;
|
|
94
|
+
}>;
|
|
84
95
|
/**
|
|
85
96
|
* Vow-tolerant
|
|
86
97
|
* implementation of Promise.allSettled that takes an iterable of vows and other
|
|
@@ -88,14 +99,15 @@ export type VowTools = {
|
|
|
88
99
|
* the input's promises or vows are settled with an array of settled outcome
|
|
89
100
|
* objects.
|
|
90
101
|
*/
|
|
91
|
-
allSettled: (maybeVows:
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
102
|
+
allSettled: <TS extends readonly unknown[]>(maybeVows: TS) => Vow<{
|
|
103
|
+
[K in keyof TS]: PromiseSettledResult<Fulfilled<TS[K]>>;
|
|
104
|
+
}>;
|
|
105
|
+
/**
|
|
106
|
+
* @deprecated use `all`
|
|
107
|
+
*/
|
|
108
|
+
allVows: <TS extends readonly unknown[]>(maybeVows: TS) => Vow<{
|
|
109
|
+
[K in keyof TS]: Fulfilled<TS[K]>;
|
|
110
|
+
}>;
|
|
99
111
|
/**
|
|
100
112
|
* Convert a vow or promise to a promise, ensuring proper handling of ephemeral promises.
|
|
101
113
|
*/
|
|
@@ -118,7 +130,7 @@ export type VowTools = {
|
|
|
118
130
|
*
|
|
119
131
|
* Does not survive upgrade (even if specimenP is a durable Vow).
|
|
120
132
|
*
|
|
121
|
-
* Use only if the Vow will resolve _promptly_ {@
|
|
133
|
+
* Use only if the Vow will resolve _promptly_ {@link @agoric/swingset-vat/docs/async.md}.
|
|
122
134
|
*/
|
|
123
135
|
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>;
|
|
124
136
|
};
|
package/src/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,KAA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AQ,EAAE,IAAI,CAAC,SAAS,KAAK,GAC3D,QAAQ,GACR,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC,GAAG,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC,CACtD,CAAC;IACF;;;;;;OAMG;IACH,IAAI,EAAE,CAAC,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC,CAAC,CAAC,EAAE,QAAQ,GAAG,KAAK,EAC/C,SAAS,EAAE,CAAC,EACZ,WAAW,CAAC,EACR,CAAC,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,KAAK,QAAQ,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC,GACzD,SAAS,EACb,UAAU,CAAC,EACP,CAAC,CAAC,MAAM,EAAE,GAAG,KAAK,QAAQ,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC,GACnD,SAAS,KACV,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAC,CAAC;CACnC,CAAC"}
|
package/src/types.js
ADDED
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Return truthy if a rejection reason should result in a retry.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Types that are conceptually similar to Promise<F> in that they wrap a fulfilled type.
|
|
15
|
+
*/
|
|
16
|
+
// s| PromiseStep<F> …etc.
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Extract the final fulfilment type from a chain of VowLikes.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Return type of a function that may
|
|
25
|
+
* return a promise or a vow.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Eventually a value T or Vow for it.
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Follow the chain of vow shortening to the end, returning the final value.
|
|
36
|
+
* This is used within E, so we must narrow the type to its remote form.
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* The first version of the vow implementation
|
|
42
|
+
* object. CAVEAT: These methods must never be changed or added to, to provide
|
|
43
|
+
* forward/backward compatibility. Create a new object and bump its version
|
|
44
|
+
* number instead.
|
|
45
|
+
*/
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Vows are objects that represent promises that can be stored durably.
|
|
62
|
+
*/
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Converts a vow or promise to a promise, ensuring proper handling of ephemeral promises.
|
|
97
|
+
*/
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
|
package/src/watch-utils.d.ts
CHANGED
|
@@ -4,16 +4,18 @@ export function prepareWatchUtils(zone: Zone, { watch, when, makeVowKit, isRetry
|
|
|
4
4
|
makeVowKit: () => VowKit<any>;
|
|
5
5
|
isRetryableReason: IsRetryableReason;
|
|
6
6
|
}): () => import("@endo/exo").Guarded<{
|
|
7
|
-
/**
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
7
|
+
/**
|
|
8
|
+
* @template {readonly unknown[]} S
|
|
9
|
+
* @param {S} specimens
|
|
10
|
+
* @returns {Vow<{ [P in keyof S]: Fulfilled<S[P]> }>}
|
|
11
|
+
*/
|
|
12
|
+
all<S extends readonly unknown[]>(specimens: S): Vow<{ [P in keyof S]: Fulfilled<S[P]>; }>;
|
|
13
|
+
/**
|
|
14
|
+
* @template {readonly unknown[]} S
|
|
15
|
+
* @param {S} specimens
|
|
16
|
+
* @returns {Vow<{ [P in keyof S]: PromiseSettledResult<Fulfilled<S[P]>> }>}
|
|
17
|
+
*/
|
|
18
|
+
allSettled<S extends readonly unknown[]>(specimens: S): Vow<{ [P in keyof S]: PromiseSettledResult<Fulfilled<S[P]>>; }>;
|
|
17
19
|
asPromise(specimenP: any, watcher?: import("./types.js").Watcher<any, any, never, any[]> | undefined, watcherArgs?: any[] | undefined): Promise<any>;
|
|
18
20
|
}>;
|
|
19
21
|
import type { Zone } from '@agoric/base-zone';
|
|
@@ -21,5 +23,6 @@ import type { Watch } from './watch.js';
|
|
|
21
23
|
import type { When } from './when.js';
|
|
22
24
|
import type { VowKit } from './types.js';
|
|
23
25
|
import type { IsRetryableReason } from './types.js';
|
|
26
|
+
import type { Fulfilled } from './types.js';
|
|
24
27
|
import type { Vow } from './types.js';
|
|
25
28
|
//# sourceMappingURL=watch-utils.d.ts.map
|
package/src/watch-utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"watch-utils.d.ts","sourceRoot":"","sources":["watch-utils.js"],"names":[],"mappings":"AA+BO,wCAPI,IAAI,kDAEZ;IAAsB,KAAK,EAAnB,KAAK;IACQ,IAAI,EAAjB,IAAI;IACsB,UAAU,EAApC,MAAM,OAAO,GAAG,CAAC;IACS,iBAAiB,EAA3C,iBAAiB;CAC3B;IA4CO
|
|
1
|
+
{"version":3,"file":"watch-utils.d.ts","sourceRoot":"","sources":["watch-utils.js"],"names":[],"mappings":"AA+BO,wCAPI,IAAI,kDAEZ;IAAsB,KAAK,EAAnB,KAAK;IACQ,IAAI,EAAjB,IAAI;IACsB,UAAU,EAApC,MAAM,OAAO,GAAG,CAAC;IACS,iBAAiB,EAA3C,iBAAiB;CAC3B;IA4CO;;;;OAIG;QAH+B,CAAC,SAAtB,SAAU,OAAO,EAAG,aACtB,CAAC,GACC,IAAI,GAAG,CAAC,IAAI,MAAM,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,GAAE,CAAC;IAOrD;;;;OAIG;eAH+B,CAAC,SAAtB,SAAU,OAAO,EAAG,aACtB,CAAC,GACC,IAAI,GAAG,CAAC,IAAI,MAAM,CAAC,GAAG,oBAAoB,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAE,CAAC;;GA6LlF;0BA1QsB,mBAAmB;2BAClB,YAAY;0BACb,WAAW;4BAC6C,YAAY;uCAAZ,YAAY;+BAAZ,YAAY;yBAAZ,YAAY"}
|
package/src/watch-utils.js
CHANGED
|
@@ -11,7 +11,7 @@ const { Fail, bare, details: X } = assert;
|
|
|
11
11
|
* @import {Zone} from '@agoric/base-zone';
|
|
12
12
|
* @import {Watch} from './watch.js';
|
|
13
13
|
* @import {When} from './when.js';
|
|
14
|
-
* @import {VowKit, AsPromiseFunction, IsRetryableReason, Vow} from './types.js';
|
|
14
|
+
* @import {VowKit, AsPromiseFunction, Fulfilled, IsRetryableReason, Vow} from './types.js';
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
const VowShape = M.tagged(
|
|
@@ -72,13 +72,23 @@ export const prepareWatchUtils = (
|
|
|
72
72
|
},
|
|
73
73
|
{
|
|
74
74
|
utils: {
|
|
75
|
-
/**
|
|
75
|
+
/**
|
|
76
|
+
* @template {readonly unknown[]} S
|
|
77
|
+
* @param {S} specimens
|
|
78
|
+
* @returns {Vow<{ [P in keyof S]: Fulfilled<S[P]> }>}
|
|
79
|
+
*/
|
|
76
80
|
all(specimens) {
|
|
77
|
-
return
|
|
81
|
+
return /** @type {Vow<{ [P in keyof S]: Fulfilled<S[P]> }>} */ (
|
|
82
|
+
this.facets.helper.createVow(specimens, false)
|
|
83
|
+
);
|
|
78
84
|
},
|
|
79
|
-
/**
|
|
85
|
+
/**
|
|
86
|
+
* @template {readonly unknown[]} S
|
|
87
|
+
* @param {S} specimens
|
|
88
|
+
* @returns {Vow<{ [P in keyof S]: PromiseSettledResult<Fulfilled<S[P]>> }>}
|
|
89
|
+
*/
|
|
80
90
|
allSettled(specimens) {
|
|
81
|
-
return /** @type {Vow<
|
|
91
|
+
return /** @type {Vow<{ [P in keyof S]: PromiseSettledResult<Fulfilled<S[P]>> }>} */ (
|
|
82
92
|
this.facets.helper.createVow(specimens, true)
|
|
83
93
|
);
|
|
84
94
|
},
|
|
@@ -121,7 +131,7 @@ export const prepareWatchUtils = (
|
|
|
121
131
|
},
|
|
122
132
|
helper: {
|
|
123
133
|
/**
|
|
124
|
-
* @param {unknown[]} specimens
|
|
134
|
+
* @param {readonly unknown[]} specimens
|
|
125
135
|
* @param {boolean} isAllSettled
|
|
126
136
|
*/
|
|
127
137
|
createVow(specimens, isAllSettled) {
|
package/vat.js
CHANGED
|
@@ -14,7 +14,12 @@ import { makeHeapZone } from '@agoric/base-zone/heap.js';
|
|
|
14
14
|
import { prepareBasicVowTools } from './src/tools.js';
|
|
15
15
|
import makeE from './src/E.js';
|
|
16
16
|
|
|
17
|
-
/**
|
|
17
|
+
/**
|
|
18
|
+
* @import {IsRetryableReason} from './src/types.js';
|
|
19
|
+
* @import {E} from '@endo/far';
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/** @type {IsRetryableReason} */
|
|
18
23
|
const isRetryableReason = (reason, priorRetryValue) => {
|
|
19
24
|
if (
|
|
20
25
|
isUpgradeDisconnection(reason) &&
|
|
@@ -63,7 +68,7 @@ export const heapVowTools = prepareSwingsetVowTools(makeHeapZone());
|
|
|
63
68
|
*
|
|
64
69
|
* This produces long-lived ephemeral promises that encapsulate the shortening
|
|
65
70
|
* behaviour, and so provides no way for `watch` to durably shorten. Use the
|
|
66
|
-
* standard `
|
|
71
|
+
* standard `E` if you need to `watch` its resulting
|
|
67
72
|
* promises.
|
|
68
73
|
*/
|
|
69
74
|
export const heapVowE = makeE(globalThis.HandledPromise, {
|
package/src/types.ts
DELETED
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
import type { Remote } from '@agoric/internal';
|
|
2
|
-
import type { Zone } from '@agoric/zone';
|
|
3
|
-
import type { CopyTagged, RemotableObject } from '@endo/pass-style';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Return truthy if a rejection reason should result in a retry.
|
|
7
|
-
*/
|
|
8
|
-
export type IsRetryableReason = (reason: any, priorRetryValue: any) => any;
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Return type of a function that may
|
|
12
|
-
* return a promise or a vow.
|
|
13
|
-
*/
|
|
14
|
-
export type PromiseVow<T> = Promise<T | Vow<T>>;
|
|
15
|
-
|
|
16
|
-
export type ERef<T> = T | PromiseLike<T>;
|
|
17
|
-
/**
|
|
18
|
-
* Eventually a value T or Vow for it.
|
|
19
|
-
*/
|
|
20
|
-
export type EVow<T> = ERef<T | Vow<T>>;
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Follow the chain of vow shortening to the end, returning the final value.
|
|
24
|
-
* This is used within E, so we must narrow the type to its remote form.
|
|
25
|
-
*/
|
|
26
|
-
export type EUnwrap<T> =
|
|
27
|
-
T extends Vow<infer U>
|
|
28
|
-
? EUnwrap<U>
|
|
29
|
-
: T extends PromiseLike<infer U>
|
|
30
|
-
? EUnwrap<U>
|
|
31
|
-
: T;
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* The first version of the vow implementation
|
|
35
|
-
* object. CAVEAT: These methods must never be changed or added to, to provide
|
|
36
|
-
* forward/backward compatibility. Create a new object and bump its version
|
|
37
|
-
* number instead.
|
|
38
|
-
*/
|
|
39
|
-
export type VowPayloadV0<T = any> = {
|
|
40
|
-
/**
|
|
41
|
-
* Attempt to unwrap all vows in this
|
|
42
|
-
* promise chain, returning a promise for the final value. A rejection may
|
|
43
|
-
* indicate a temporary routing failure requiring a retry, otherwise that the
|
|
44
|
-
* decider of the terminal promise rejected it.
|
|
45
|
-
*/
|
|
46
|
-
shorten: () => Promise<T>;
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
export type VowPayload<T = any> = {
|
|
50
|
-
vowV0: RemotableObject & Remote<VowPayloadV0<T>>;
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Vows are objects that represent promises that can be stored durably.
|
|
55
|
-
*/
|
|
56
|
-
export type Vow<T = any> = CopyTagged<'Vow', VowPayload<T>>;
|
|
57
|
-
|
|
58
|
-
export type VowKit<T = any> = {
|
|
59
|
-
vow: Vow<T>;
|
|
60
|
-
resolver: VowResolver<T>;
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
export type VowResolver<T = any> = {
|
|
64
|
-
resolve(value?: T | PromiseVow<T>): void;
|
|
65
|
-
reject(reason?: any): void;
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
export type Watcher<
|
|
69
|
-
T = any,
|
|
70
|
-
TResult1 = T,
|
|
71
|
-
TResult2 = never,
|
|
72
|
-
C extends any[] = any[],
|
|
73
|
-
> = {
|
|
74
|
-
onFulfilled?:
|
|
75
|
-
| ((
|
|
76
|
-
value: T,
|
|
77
|
-
...args: C
|
|
78
|
-
) => Vow<TResult1> | PromiseVow<TResult1> | TResult1)
|
|
79
|
-
| undefined;
|
|
80
|
-
onRejected?:
|
|
81
|
-
| ((
|
|
82
|
-
reason: any,
|
|
83
|
-
...args: C
|
|
84
|
-
) => Vow<TResult2> | PromiseVow<TResult2> | TResult2)
|
|
85
|
-
| undefined;
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Converts a vow or promise to a promise, ensuring proper handling of ephemeral promises.
|
|
90
|
-
*/
|
|
91
|
-
export type AsPromiseFunction<
|
|
92
|
-
T = any,
|
|
93
|
-
TResult1 = T,
|
|
94
|
-
TResult2 = never,
|
|
95
|
-
C extends any[] = any[],
|
|
96
|
-
> = (
|
|
97
|
-
specimenP: ERef<T | Vow<T>>,
|
|
98
|
-
watcher?: Watcher<T, TResult1, TResult2, C> | undefined,
|
|
99
|
-
watcherArgs?: C | undefined,
|
|
100
|
-
) => Promise<TResult1 | TResult2>;
|
|
101
|
-
|
|
102
|
-
export interface RetryableTool {
|
|
103
|
-
/**
|
|
104
|
-
* Create a function that retries the given function if the underlying
|
|
105
|
-
* async function rejects due to an upgrade disconnection. The return value
|
|
106
|
-
* of the created function is a vow that settles to the final retry result.
|
|
107
|
-
*
|
|
108
|
-
* The retried function should be idempotent.
|
|
109
|
-
*
|
|
110
|
-
* @param fnZone the zone for the named function
|
|
111
|
-
* @param name base name to use in the zone
|
|
112
|
-
* @param fn the retried function
|
|
113
|
-
*/
|
|
114
|
-
<F extends (...args: any[]) => Promise<any>>(
|
|
115
|
-
fnZone: Zone,
|
|
116
|
-
name: string,
|
|
117
|
-
fn: F,
|
|
118
|
-
): F extends (...args: infer Args) => Promise<infer R>
|
|
119
|
-
? (...args: Args) => Vow<R>
|
|
120
|
-
: never;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
export type VowTools = {
|
|
124
|
-
/**
|
|
125
|
-
* Vow-tolerant implementation of Promise.all that takes an iterable of vows
|
|
126
|
-
* and other {@link Passable}s and returns a single {@link Vow}. It resolves
|
|
127
|
-
* with an array of values when all of the input's promises or vows are
|
|
128
|
-
* fulfilled and rejects when any of the input's promises or vows are rejected
|
|
129
|
-
* with the first rejection reason.
|
|
130
|
-
*/
|
|
131
|
-
all: (maybeVows: unknown[]) => Vow<any[]>;
|
|
132
|
-
/**
|
|
133
|
-
* Vow-tolerant
|
|
134
|
-
* implementation of Promise.allSettled that takes an iterable of vows and other
|
|
135
|
-
* {@link Passable}s and returns a single {@link Vow}. It resolves when all of
|
|
136
|
-
* the input's promises or vows are settled with an array of settled outcome
|
|
137
|
-
* objects.
|
|
138
|
-
*/
|
|
139
|
-
allSettled: (maybeVows: unknown[]) => Vow<
|
|
140
|
-
(
|
|
141
|
-
| {
|
|
142
|
-
status: 'fulfilled';
|
|
143
|
-
value: any;
|
|
144
|
-
}
|
|
145
|
-
| {
|
|
146
|
-
status: 'rejected';
|
|
147
|
-
reason: any;
|
|
148
|
-
}
|
|
149
|
-
)[]
|
|
150
|
-
>;
|
|
151
|
-
allVows: (maybeVows: unknown[]) => Vow<any[]>;
|
|
152
|
-
/**
|
|
153
|
-
* Convert a vow or promise to a promise, ensuring proper handling of ephemeral promises.
|
|
154
|
-
*/
|
|
155
|
-
asPromise: AsPromiseFunction;
|
|
156
|
-
/**
|
|
157
|
-
* Helper function that
|
|
158
|
-
* coerces the result of a function to a Vow. Helpful for scenarios like a
|
|
159
|
-
* synchronously thrown error.
|
|
160
|
-
*/
|
|
161
|
-
asVow: <T>(
|
|
162
|
-
fn: (...args: any[]) => Vow<Awaited<T>> | Awaited<T> | PromiseVow<T>,
|
|
163
|
-
) => Vow<Awaited<T>>;
|
|
164
|
-
makeVowKit: <T>() => VowKit<T>;
|
|
165
|
-
retryable: RetryableTool;
|
|
166
|
-
/**
|
|
167
|
-
* @deprecated use `retryable`
|
|
168
|
-
*/
|
|
169
|
-
retriable: RetryableTool;
|
|
170
|
-
watch: <T = any, TResult1 = T, TResult2 = never, C extends any[] = any[]>(
|
|
171
|
-
specimenP: EVow<T>,
|
|
172
|
-
watcher?: Watcher<T, TResult1, TResult2, C> | undefined,
|
|
173
|
-
...watcherArgs: C
|
|
174
|
-
) => Vow<
|
|
175
|
-
Exclude<TResult1, void> | Exclude<TResult2, void> extends never
|
|
176
|
-
? TResult1
|
|
177
|
-
: Exclude<TResult1, void> | Exclude<TResult2, void>
|
|
178
|
-
>;
|
|
179
|
-
/**
|
|
180
|
-
* Shorten `specimenP` until we achieve a final result.
|
|
181
|
-
*
|
|
182
|
-
* Does not survive upgrade (even if specimenP is a durable Vow).
|
|
183
|
-
*
|
|
184
|
-
* Use only if the Vow will resolve _promptly_ {@see {@link @agoric/swingset-vat/docs/async.md}}.
|
|
185
|
-
*/
|
|
186
|
-
when: <T, TResult1 = EUnwrap<T>, TResult2 = never>(
|
|
187
|
-
specimenP: T,
|
|
188
|
-
onFulfilled?:
|
|
189
|
-
| ((value: EUnwrap<T>) => TResult1 | PromiseLike<TResult1>)
|
|
190
|
-
| undefined,
|
|
191
|
-
onRejected?:
|
|
192
|
-
| ((reason: any) => TResult2 | PromiseLike<TResult2>)
|
|
193
|
-
| undefined,
|
|
194
|
-
) => Promise<TResult1 | TResult2>;
|
|
195
|
-
};
|