@agoric/async-flow 0.1.1-other-dev-d15096d.0.d15096d → 0.1.1-other-dev-ecf44df.0.ecf44df
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/ava.config.js +10 -0
- package/package.json +22 -32
- package/src/async-flow.d.ts +104 -7
- package/src/async-flow.d.ts.map +1 -1
- package/src/async-flow.js +30 -22
- package/src/bijection.d.ts +13 -5
- package/src/bijection.d.ts.map +1 -1
- package/src/bijection.js +5 -4
- package/src/endowments.d.ts.map +1 -1
- package/src/endowments.js +15 -8
- package/src/equate.d.ts.map +1 -1
- package/src/equate.js +0 -1
- package/src/log-store.d.ts +316 -30
- package/src/log-store.d.ts.map +1 -1
- package/src/log-store.js +4 -4
- package/src/replay-membrane.d.ts.map +1 -1
- package/src/replay-membrane.js +12 -4
- package/src/type-guards.d.ts +51 -3
- package/src/type-guards.d.ts.map +1 -1
- package/src/types.d.ts +21 -4
- package/src/types.d.ts.map +1 -1
- package/src/types.js +244 -0
- package/test/async-flow-crank.test.js +2 -1
- package/test/bijection.test.js +0 -1
- package/test/exports.test.js +2 -0
- package/test/log-store.test.js +8 -17
- package/test/replay-membrane-eventual.test.js +2 -2
- package/test/types.test-d.ts +15 -1
- package/tsconfig.build.json +2 -0
- package/tsconfig.build.tsbuildinfo +1 -1
- package/tsconfig.json +2 -4
- package/src/types.ts +0 -212
package/tsconfig.json
CHANGED
package/src/types.ts
DELETED
|
@@ -1,212 +0,0 @@
|
|
|
1
|
-
import type { Passable } from '@endo/pass-style';
|
|
2
|
-
import type { Vow, VowTools } from '@agoric/vow';
|
|
3
|
-
import type { LogStore } from './log-store.js';
|
|
4
|
-
import type { Bijection } from './bijection.js';
|
|
5
|
-
import type { EndowmentTools } from './endowments.js';
|
|
6
|
-
|
|
7
|
-
export type FlowState =
|
|
8
|
-
| 'Running'
|
|
9
|
-
| 'Sleeping'
|
|
10
|
-
| 'Replaying'
|
|
11
|
-
| 'Failed'
|
|
12
|
-
| 'Done';
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* `T` defaults to `any`, not `Passable`, because unwrapped guests include
|
|
16
|
-
* non-passables, like unwrapped functions and unwrapped state records.
|
|
17
|
-
* (Unwrapped functions could be made into Remotables,
|
|
18
|
-
* but since they still could not be made durable, in this context
|
|
19
|
-
* it'd be pointless.)
|
|
20
|
-
*/
|
|
21
|
-
export type Guest<T = any> = T;
|
|
22
|
-
export type Host<T extends Passable = Passable> = T;
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* A HostVow must be durably storable. It corresponds to an
|
|
26
|
-
* ephemeral guest promise.
|
|
27
|
-
*/
|
|
28
|
-
export type HostVow<T extends Passable = Passable> = Host<Vow<T>>;
|
|
29
|
-
|
|
30
|
-
export type GuestAsyncFunc = (
|
|
31
|
-
...activationArgs: Guest[]
|
|
32
|
-
) => Guest<Promise<any>>;
|
|
33
|
-
|
|
34
|
-
export type HostAsyncFuncWrapper = (
|
|
35
|
-
...activationArgs: Host<any>[]
|
|
36
|
-
) => HostVow<any>;
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* The function from the host as it will be available in the guest.
|
|
40
|
-
*
|
|
41
|
-
* Specifically, Vow return values are converted to Promises.
|
|
42
|
-
*/
|
|
43
|
-
export type GuestOf<F extends HostAsyncFuncWrapper> = F extends (
|
|
44
|
-
...args: infer A
|
|
45
|
-
) => Vow<infer R>
|
|
46
|
-
? (...args: A) => Promise<R>
|
|
47
|
-
: F;
|
|
48
|
-
|
|
49
|
-
// from https://github.com/sindresorhus/type-fest/blob/main/source/simplify.d.ts
|
|
50
|
-
type Simplify<T> = { [KeyType in keyof T]: T[KeyType] } & {};
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Convert an entire Guest interface into what the host will implement.
|
|
54
|
-
*/
|
|
55
|
-
export type HostInterface<T> = {
|
|
56
|
-
[K in keyof T]: T[K] extends CallableFunction
|
|
57
|
-
? HostOf<T[K]>
|
|
58
|
-
: T[K] extends Record<string, any>
|
|
59
|
-
? Simplify<HostInterface<T[K]>>
|
|
60
|
-
: T[K];
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Convert an entire Host interface into what the Guest will receive.
|
|
65
|
-
*/
|
|
66
|
-
export type GuestInterface<T> = {
|
|
67
|
-
[K in keyof T]: T[K] extends (...args: any[]) => Vow<infer R>
|
|
68
|
-
? (...args: Parameters<T[K]>) => Promise<R>
|
|
69
|
-
: T[K] extends HostAsyncFuncWrapper
|
|
70
|
-
? GuestOf<T[K]>
|
|
71
|
-
: T[K] extends (...args: any[]) => any
|
|
72
|
-
? T[K]
|
|
73
|
-
: T[K] extends object
|
|
74
|
-
? GuestInterface<T[K]>
|
|
75
|
-
: T[K];
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* The function the host must provide to match an interface the guest expects.
|
|
80
|
-
*
|
|
81
|
-
* Specifically, Promise return values are converted to Vows.
|
|
82
|
-
*/
|
|
83
|
-
export type HostOf<F extends CallableFunction> = F extends (
|
|
84
|
-
...args: infer A
|
|
85
|
-
) => infer R
|
|
86
|
-
? R extends Promise<infer T>
|
|
87
|
-
? (...args: A) => Vow<T extends Passable ? T : HostInterface<T>>
|
|
88
|
-
: (...args: A) => HostInterface<R>
|
|
89
|
-
: F;
|
|
90
|
-
|
|
91
|
-
export type HostArgs<GA extends any[]> = { [K in keyof GA]: HostOf<GA[K]> };
|
|
92
|
-
|
|
93
|
-
export type PreparationOptions = {
|
|
94
|
-
vowTools?: VowTools;
|
|
95
|
-
makeLogStore?: (() => LogStore) | undefined;
|
|
96
|
-
makeBijection?: (() => Bijection) | undefined;
|
|
97
|
-
endowmentTools?: EndowmentTools;
|
|
98
|
-
panicHandler?: (e: any) => void;
|
|
99
|
-
};
|
|
100
|
-
export type OutcomeKind = 'return' | 'throw';
|
|
101
|
-
|
|
102
|
-
export type Outcome =
|
|
103
|
-
| {
|
|
104
|
-
kind: 'return';
|
|
105
|
-
result: any;
|
|
106
|
-
}
|
|
107
|
-
| {
|
|
108
|
-
kind: 'throw';
|
|
109
|
-
problem: any;
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
export type Ephemera<S extends WeakKey = WeakKey, V = any> = {
|
|
113
|
-
for: (self: S) => V;
|
|
114
|
-
resetFor: (self: S) => void;
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* This is the type alias for the membrane log entries we currently implement.
|
|
119
|
-
*
|
|
120
|
-
* @see {FutureLogEntry} below for the full membrane log entry, which we do not
|
|
121
|
-
* yet support.
|
|
122
|
-
*/
|
|
123
|
-
export type LogEntry =
|
|
124
|
-
| [op: 'startGeneration', generation: number]
|
|
125
|
-
// ///////////////// From Host to Guest /////////////////////////
|
|
126
|
-
| [op: 'doFulfill', vow: HostVow, fulfillment: Host]
|
|
127
|
-
| [op: 'doReject', vow: HostVow, reason: Host]
|
|
128
|
-
| [op: 'doReturn', callIndex: number, result: Host]
|
|
129
|
-
| [op: 'doThrow', callIndex: number, problem: Host]
|
|
130
|
-
// ///////////////////// From Guest to Host /////////////////////////
|
|
131
|
-
| [
|
|
132
|
-
op: 'checkCall',
|
|
133
|
-
target: Host,
|
|
134
|
-
optVerb: PropertyKey | undefined,
|
|
135
|
-
args: Host[],
|
|
136
|
-
callIndex: number,
|
|
137
|
-
]
|
|
138
|
-
| [
|
|
139
|
-
op: 'checkSendOnly',
|
|
140
|
-
target: Host,
|
|
141
|
-
optVerb: PropertyKey | undefined,
|
|
142
|
-
args: Host[],
|
|
143
|
-
callIndex: number,
|
|
144
|
-
]
|
|
145
|
-
| [
|
|
146
|
-
op: 'checkSend',
|
|
147
|
-
target: Host,
|
|
148
|
-
optVerb: PropertyKey | undefined,
|
|
149
|
-
args: Host[],
|
|
150
|
-
callIndex: number,
|
|
151
|
-
];
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* This would be the type alias for the full membrane log, if we supported:
|
|
155
|
-
* - the guest sending guest-promises and guest-remotables to the host
|
|
156
|
-
* - the guest using `E` to eventual-send to guest wrappers of the host
|
|
157
|
-
* vows and remotables.
|
|
158
|
-
*/
|
|
159
|
-
export type FutureLogEntry =
|
|
160
|
-
| [op: 'startGeneration', generation: number]
|
|
161
|
-
// ///////////////// From Host to Guest ///////////////////////
|
|
162
|
-
| [op: 'doFulfill', vow: HostVow, fulfillment: Host]
|
|
163
|
-
| [op: 'doReject', vow: HostVow, reason: Host]
|
|
164
|
-
| [
|
|
165
|
-
op: 'doCall',
|
|
166
|
-
target: Host,
|
|
167
|
-
optVerb: PropertyKey | undefined,
|
|
168
|
-
args: Host[],
|
|
169
|
-
callIndex: number,
|
|
170
|
-
]
|
|
171
|
-
| [
|
|
172
|
-
op: 'doSendOnly',
|
|
173
|
-
target: Host,
|
|
174
|
-
optVerb: PropertyKey | undefined,
|
|
175
|
-
args: Host[],
|
|
176
|
-
callIndex: number,
|
|
177
|
-
]
|
|
178
|
-
| [
|
|
179
|
-
op: 'doSend',
|
|
180
|
-
target: Host,
|
|
181
|
-
optVerb: PropertyKey | undefined,
|
|
182
|
-
args: Host[],
|
|
183
|
-
callIndex: number,
|
|
184
|
-
]
|
|
185
|
-
| [op: 'doReturn', callIndex: number, result: Host]
|
|
186
|
-
| [op: 'doThrow', callIndex: number, problem: Host]
|
|
187
|
-
// ///////////////////// From Guest to Host /////////////////////////
|
|
188
|
-
| [op: 'checkFulfill', vow: HostVow, fulfillment: Host]
|
|
189
|
-
| [op: 'checkReject', vow: HostVow, reason: Host]
|
|
190
|
-
| [
|
|
191
|
-
op: 'checkCall',
|
|
192
|
-
target: Host,
|
|
193
|
-
optVerb: PropertyKey | undefined,
|
|
194
|
-
args: Host[],
|
|
195
|
-
callIndex: number,
|
|
196
|
-
]
|
|
197
|
-
| [
|
|
198
|
-
op: 'checkSendOnly',
|
|
199
|
-
target: Host,
|
|
200
|
-
optVerb: PropertyKey | undefined,
|
|
201
|
-
args: Host[],
|
|
202
|
-
callIndex: number,
|
|
203
|
-
]
|
|
204
|
-
| [
|
|
205
|
-
op: 'checkSend',
|
|
206
|
-
target: Host,
|
|
207
|
-
optVerb: PropertyKey | undefined,
|
|
208
|
-
args: Host[],
|
|
209
|
-
callIndex: number,
|
|
210
|
-
]
|
|
211
|
-
| [op: 'checkReturn', callIndex: number, result: Host]
|
|
212
|
-
| [op: 'checkThrow', callIndex: number, problem: Host];
|