@agoric/async-flow 0.1.1-dev-a9e951a.0 → 0.1.1-dev-607ed82.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 +8 -8
- package/src/types.d.ts +5 -3
- package/test/types.test-d.ts +56 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/async-flow",
|
|
3
|
-
"version": "0.1.1-dev-
|
|
3
|
+
"version": "0.1.1-dev-607ed82.0+607ed82",
|
|
4
4
|
"description": "Upgrade async functions at await points by replay",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": "https://github.com/Agoric/agoric-sdk",
|
|
@@ -24,10 +24,10 @@
|
|
|
24
24
|
"author": "Agoric",
|
|
25
25
|
"license": "Apache-2.0",
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@agoric/base-zone": "0.1.1-dev-
|
|
28
|
-
"@agoric/internal": "0.3.3-dev-
|
|
29
|
-
"@agoric/store": "0.9.3-dev-
|
|
30
|
-
"@agoric/vow": "0.1.1-dev-
|
|
27
|
+
"@agoric/base-zone": "0.1.1-dev-607ed82.0+607ed82",
|
|
28
|
+
"@agoric/internal": "0.3.3-dev-607ed82.0+607ed82",
|
|
29
|
+
"@agoric/store": "0.9.3-dev-607ed82.0+607ed82",
|
|
30
|
+
"@agoric/vow": "0.1.1-dev-607ed82.0+607ed82",
|
|
31
31
|
"@endo/common": "^1.2.5",
|
|
32
32
|
"@endo/errors": "^1.2.5",
|
|
33
33
|
"@endo/eventual-send": "^1.2.5",
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
"@endo/promise-kit": "^1.1.5"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@agoric/swingset-liveslots": "0.10.3-dev-
|
|
41
|
-
"@agoric/zone": "0.2.3-dev-
|
|
40
|
+
"@agoric/swingset-liveslots": "0.10.3-dev-607ed82.0+607ed82",
|
|
41
|
+
"@agoric/zone": "0.2.3-dev-607ed82.0+607ed82",
|
|
42
42
|
"@endo/env-options": "^1.1.6",
|
|
43
43
|
"@endo/ses-ava": "^1.2.5",
|
|
44
44
|
"ava": "^5.3.0",
|
|
@@ -63,5 +63,5 @@
|
|
|
63
63
|
"typeCoverage": {
|
|
64
64
|
"atLeast": 77.1
|
|
65
65
|
},
|
|
66
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "607ed82dddecb1296b2c9507a55cd2c73be3537e"
|
|
67
67
|
}
|
package/src/types.d.ts
CHANGED
|
@@ -68,9 +68,11 @@ export type GuestInterface<T> = {
|
|
|
68
68
|
? (...args: Parameters<T[K]>) => Promise<R>
|
|
69
69
|
: T[K] extends HostAsyncFuncWrapper
|
|
70
70
|
? GuestOf<T[K]>
|
|
71
|
-
: T[K] extends
|
|
72
|
-
?
|
|
73
|
-
: T[K]
|
|
71
|
+
: T[K] extends (...args: any[]) => infer R
|
|
72
|
+
? T[K]
|
|
73
|
+
: T[K] extends object
|
|
74
|
+
? GuestInterface<T[K]>
|
|
75
|
+
: T[K];
|
|
74
76
|
};
|
|
75
77
|
|
|
76
78
|
/**
|
package/test/types.test-d.ts
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import { expectType } from 'tsd';
|
|
2
|
-
import type { Zone } from '@agoric/base-zone';
|
|
3
2
|
import type { Vow, VowTools } from '@agoric/vow';
|
|
4
|
-
import type {
|
|
3
|
+
import type {
|
|
4
|
+
HostOf,
|
|
5
|
+
GuestOf,
|
|
6
|
+
HostInterface,
|
|
7
|
+
GuestInterface,
|
|
8
|
+
} from '../src/types.js';
|
|
5
9
|
|
|
10
|
+
const castable: unknown = null;
|
|
6
11
|
const vt: VowTools = null as any;
|
|
7
12
|
|
|
8
13
|
const sumVow = (a: number, b: number) => vt.asVow(() => a + b);
|
|
@@ -10,13 +15,59 @@ const sumVow = (a: number, b: number) => vt.asVow(() => a + b);
|
|
|
10
15
|
const sumPromise = (a: number, b: number) => Promise.resolve(a + b);
|
|
11
16
|
|
|
12
17
|
expectType<(p1: number, p2: number) => Promise<number>>(
|
|
13
|
-
|
|
18
|
+
castable as GuestOf<typeof sumVow>,
|
|
14
19
|
);
|
|
15
20
|
|
|
16
21
|
expectType<(p1: number, p2: number) => Vow<number>>(
|
|
17
|
-
|
|
22
|
+
castable as HostOf<typeof sumPromise>,
|
|
18
23
|
);
|
|
19
24
|
expectType<(p1: number, p2: number) => Vow<void>>(
|
|
20
25
|
// @ts-expect-error incompatible return type
|
|
21
|
-
|
|
26
|
+
castable as HostOf<typeof sumPromise>,
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
// Test HostInterface and GuestInterface with an exoClass object
|
|
30
|
+
type ExoAPIBase = {
|
|
31
|
+
getValue: () => number;
|
|
32
|
+
setValue: (value: number) => void;
|
|
33
|
+
getCopyData: () => Record<string, number>[];
|
|
34
|
+
// TODO include `getRemote() => Guarded<...>`, since durable exos are passable
|
|
35
|
+
};
|
|
36
|
+
type ExoGuestAPI = ExoAPIBase & {
|
|
37
|
+
getValueAsync: () => Promise<number>;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
type ExoHostAPI = ExoAPIBase & {
|
|
41
|
+
getValueAsync: () => Vow<number>;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
expectType<
|
|
45
|
+
ExoAPIBase & {
|
|
46
|
+
getValueAsync: () => Vow<number>;
|
|
47
|
+
}
|
|
48
|
+
>(castable as HostInterface<ExoGuestAPI>);
|
|
49
|
+
expectType<
|
|
50
|
+
ExoAPIBase & {
|
|
51
|
+
getValueAsync: () => Promise<number>;
|
|
52
|
+
}
|
|
53
|
+
>(castable as GuestInterface<ExoHostAPI>);
|
|
54
|
+
|
|
55
|
+
// Test HostInterface and GuestInterface with classKit (nested) objects
|
|
56
|
+
expectType<{
|
|
57
|
+
facet: ExoAPIBase & {
|
|
58
|
+
getValueAsync: () => Vow<number>;
|
|
59
|
+
};
|
|
60
|
+
}>(
|
|
61
|
+
castable as HostInterface<{
|
|
62
|
+
facet: ExoGuestAPI;
|
|
63
|
+
}>,
|
|
64
|
+
);
|
|
65
|
+
expectType<{
|
|
66
|
+
facet: ExoAPIBase & {
|
|
67
|
+
getValueAsync: () => Promise<number>;
|
|
68
|
+
};
|
|
69
|
+
}>(
|
|
70
|
+
castable as GuestInterface<{
|
|
71
|
+
facet: ExoHostAPI;
|
|
72
|
+
}>,
|
|
22
73
|
);
|