@agoric/notifier 0.6.3-dev-d15cb41.0 → 0.6.3-dev-e456308.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.
@@ -1,335 +0,0 @@
1
- // @jessie-check
2
-
3
- /** @import { ERef } from '@endo/far' */
4
-
5
- /**
6
- * @import {PromiseKit, PromiseRecord} from '@endo/promise-kit'
7
- */
8
-
9
- /**
10
- * @template T
11
- * @template [TReturn=any]
12
- * @template [TNext=undefined]
13
- * @typedef {AsyncIterator<T, TReturn, TNext> & {
14
- * fork(): ForkableAsyncIterator<T, TReturn, TNext>
15
- * }} ForkableAsyncIterator An AsyncIterator that can be forked at a given position
16
- * into multiple independent ForkableAsyncIterators starting from that position.
17
- */
18
-
19
- /**
20
- * @template T
21
- * @template [TReturn=any]
22
- * @template [TNext=undefined]
23
- * @typedef {{ [Symbol.asyncIterator](): AsyncIterableIterator<T, TReturn, TNext> }} AsyncIterableOnly
24
- */
25
-
26
- /**
27
- * @template T
28
- * @template [TReturn=any]
29
- * @template [TNext=undefined]
30
- * @typedef {{
31
- * [Symbol.asyncIterator](): ForkableAsyncIterableIterator<T, TReturn, TNext>,
32
- * fork(): ForkableAsyncIterableIterator<T, TReturn, TNext> } &
33
- * ForkableAsyncIterator<T, TReturn, TNext>
34
- * } ForkableAsyncIterableIterator
35
- */
36
-
37
- /**
38
- * @template T
39
- * @template [TReturn=any]
40
- * @template [TNext=undefined]
41
- * @typedef {{
42
- * [Symbol.asyncIterator]: () => ForkableAsyncIterator<T, TReturn, TNext>
43
- * }} ForkableAsyncIterable
44
- * An AsyncIterable that produces ForkableAsyncIterators.
45
- */
46
-
47
- /**
48
- * @template T
49
- * @typedef {object} IterationObserver<T>
50
- * A valid sequence of calls to the methods of an `IterationObserver`
51
- * represents an iteration. A valid sequence consists of any number of calls
52
- * to `updateState` with the successive non-final values, followed by a
53
- * final call to either `finish` with a successful `completion` value
54
- * or `fail` with the alleged `reason` for failure. After at most one
55
- * terminating calls, no further calls to these methods are valid and must be
56
- * rejected.
57
- * @property {(nonFinalValue: T) => void} updateState
58
- * @property {(completion: T) => void} finish
59
- * @property {(reason: unknown) => void} fail
60
- */
61
-
62
- // /////////////////////////////////////////////////////////////////////////////
63
-
64
- /**
65
- * @template T
66
- * @typedef {object} PublicationRecord
67
- * Will be shared between machines, so it must be safe to expose. But software
68
- * outside the current package should consider it opaque, not depending on its
69
- * internal structure.
70
- * @property {IteratorResult<T>} head
71
- * @property {bigint} publishCount starts at 1 for the first result
72
- * and advances by 1 for each subsequent result
73
- * @property {Promise<PublicationRecord<T>>} tail
74
- */
75
-
76
- /**
77
- * @template T
78
- * @typedef {object} EachTopic
79
- * @property {(publishCount?: bigint) => Promise<PublicationRecord<T>>} subscribeAfter
80
- * Returns a promise for a "current" PublicationRecord (referencing its
81
- * immediate successor via a `tail` promise) that is later than the
82
- * provided publishCount.
83
- * Used to make forward-lossless ("each") iterators.
84
- */
85
-
86
- /**
87
- * @template T
88
- * @typedef {ForkableAsyncIterable<T, T> & EachTopic<T>} IterableEachTopic
89
- * An EachTopic with default asyncIterable behaviour.
90
- *
91
- * NOTE: the publication records and iterators returned by this object are
92
- * ephemeral and will be severed during upgrade. A caller should use
93
- * `subscribeEach` to wrap this topic in a local iterable which automatically
94
- * attempts to reconnect upon being severed.
95
- */
96
-
97
- /**
98
- * @template T
99
- * @typedef {AsyncIterableOnly<T, T> & LatestTopic<T>} IterableLatestTopic
100
- * A LatestTopic with default asyncIterable behaviour.
101
- *
102
- * NOTE: the iterators returned by this object are ephemeral and will be severed
103
- * during upgrade. A caller should use `subscribeLatest` to wrap this topic in
104
- * a local iterable which automatically attempts to reconnect upon being
105
- * severed.
106
- */
107
-
108
- /**
109
- * @template T
110
- * @typedef {object} LatestTopic
111
- * @property {(updateCount?: bigint | number) => Promise<UpdateRecord<T>>} getUpdateSince
112
- * Returns a promise for an update record as of an update count.
113
- * If the `updateCount` argument is omitted or differs from the current update count,
114
- * the promise promptly resolves to the current record.
115
- * Otherwise, after the next state change, the promise resolves to the resulting record.
116
- * This is an attenuated form of `subscribeAfter` whose return value stands alone and
117
- * does not allow consumers to pin a chain of historical PublicationRecords.
118
- * Used to make lossy ("latest") iterators.
119
- * NOTE: Use of `number` as an `updateCount` is deprecated.
120
- */
121
-
122
- /**
123
- * @template T
124
- * @typedef {LatestTopic<T>} BaseNotifier This type is deprecated but is still
125
- * used externally.
126
- */
127
-
128
- /**
129
- * @template T
130
- * @typedef {LatestTopic<T> & EachTopic<T>} Subscriber
131
- * A stream of results that allows consumers to configure
132
- * forward-lossless "each" iteration with `subscribeEach` and
133
- * lossy "latest" iteration with `subscribeLatest`.
134
- */
135
-
136
- /**
137
- * @template T
138
- * @typedef {object} Publisher
139
- * A valid sequence of calls to the methods of an `IterationObserver`
140
- * represents an iteration. A valid sequence consists of any number of calls
141
- * to `publish` with the successive non-final values, followed by a
142
- * final call to either `finish` with a successful `completion` value
143
- * or `fail` with the alleged `reason` for failure. After at most one
144
- * terminating calls, no further calls to these methods are valid and must be
145
- * rejected.
146
- * @property {(nonFinalValue: T) => void} publish
147
- * @property {(completion: T) => void} finish
148
- * @property {(reason: any) => void} fail
149
- */
150
-
151
- /**
152
- * @template T
153
- * @typedef {Partial<Publisher<T>>} PublishObserver
154
- */
155
-
156
- /**
157
- * @template T
158
- * @typedef {object} PublishKit<T>
159
- * @property {Publisher<T>} publisher
160
- * @property {Subscriber<T>} subscriber
161
- */
162
-
163
- /**
164
- * @template T
165
- * @typedef {object} StoredPublishKit<T>
166
- * @property {Publisher<T>} publisher
167
- * @property {StoredSubscriber<T>} subscriber
168
- */
169
-
170
- // /////////////////////////////////////////////////////////////////////////////
171
-
172
- /**
173
- * @typedef {'mandatory' | 'opportunistic' | 'ignored'} DurablePublishKitValueDurability
174
- *
175
- * Durability configures constraints on non-terminal values that can be
176
- * published to a durable publish kit (terminal values sent to finish or fail
177
- * must always be durable).
178
- * - 'mandatory' means that each value must be durable, so it can be restored
179
- * on upgrade.
180
- * - 'opportunistic' means that a durable value is persisted for post-upgrade
181
- * restoration, but a non-durable value is still accepted (and will result in
182
- * valueless restoration).
183
- * - 'ignored' means that a value is not persisted for restoration even if it
184
- * is durable.
185
- *
186
- * 'mandatory' is the only currently-supported value, and others must not be
187
- * enabled without test coverage.
188
- */
189
-
190
- /**
191
- * @typedef {object} DurablePublishKitState
192
- *
193
- * @property {DurablePublishKitValueDurability} valueDurability
194
- *
195
- * @property {bigint} publishCount
196
- *
197
- * @property {'live' | 'finished' | 'failed'} status
198
- *
199
- * @property {boolean} hasValue
200
- * hasValue indicates the presence of value. It starts off false,
201
- * and can be reset to false when a durable publish kit is restored and
202
- * the previous value was not durable, or non-terminal and valueDurablity is 'ignored'.
203
- *
204
- * @property {any} value
205
- * value holds either a non-terminal value from `publish` or a terminal value
206
- * from `finish` or `fail`, depending upon the value in status.
207
- */
208
-
209
- // /////////////////////////////////////////////////////////////////////////////
210
-
211
- /**
212
- * @template T
213
- * @typedef {object} UpdateRecord<T>
214
- * @property {T} value is whatever state the service wants to publish
215
- * @property {bigint} [updateCount] is a value that identifies the update. For
216
- * the last update, it is `undefined`.
217
- */
218
-
219
- /**
220
- * @template T
221
- * @typedef {BaseNotifier<T>} NotifierInternals Will be shared between machines,
222
- * so it must be safe to expose. But other software should avoid depending on
223
- * its internal structure.
224
- */
225
-
226
- /**
227
- * @template T
228
- * @typedef {NotifierInternals<T> &
229
- * ForkableAsyncIterable<T, T> &
230
- * SharableNotifier<T>
231
- * } Notifier<T> an object that can be used to get the current state or updates
232
- */
233
-
234
- /**
235
- * @template T
236
- * @typedef {object} SharableNotifier
237
- * @property {() => Promise<NotifierInternals<T>>} getSharableNotifierInternals
238
- * Used to replicate the multicast values at other sites. To manually create a
239
- * local representative of a Notification, do
240
- * ```js
241
- * localIterable =
242
- * makeNotifier(E(remoteIterable).getSharableNotifierInternals());
243
- * ```
244
- * The resulting `localIterable` also supports such remote use, and
245
- * will return access to the same representation.
246
- */
247
-
248
- /**
249
- * @template T
250
- * @typedef {object} NotifierRecord<T> the produced notifier/updater pair
251
- * @property {IterationObserver<T>} updater the (closely-held) notifier producer
252
- * @property {Notifier<T>} notifier the (widely-held) notifier consumer
253
- */
254
-
255
- // /////////////////////////////////////////////////////////////////////////////
256
-
257
- /**
258
- * @template T
259
- * @typedef {IterableEachTopic<T> & EachTopic<T> &
260
- * SharableSubscription<T>} Subscription<T>
261
- * A form of AsyncIterable supporting distributed and multicast usage.
262
- */
263
-
264
- /**
265
- * @template T
266
- * @typedef {object} SharableSubscription
267
- * @property {() => Promise<EachTopic<T>>} getSharableSubscriptionInternals
268
- * Used to replicate the multicast values at other sites. To manually create a
269
- * local representative of a Subscription, do
270
- * ```js
271
- * localIterable =
272
- * makeSubscription(E(remoteIterable).getSharableSubscriptionInternals());
273
- * ```
274
- * The resulting `localIterable` also supports such remote use, and
275
- * will return access to the same representation.
276
- */
277
-
278
- /**
279
- * @template T
280
- * @typedef {object} SubscriptionRecord<T>
281
- * @property {IterationObserver<T>} publication
282
- * @property {Subscription<T>} subscription
283
- */
284
-
285
- // /////////////////////////////////////////////////////////////////////////////
286
-
287
- /** @template [Slot=unknown] @typedef {import('@endo/marshal').Marshal<Slot>} Marshaller */
288
- /** @typedef {Pick<Marshaller, 'fromCapData'>} Unserializer */
289
-
290
- /**
291
- * Defined by vstorageStoreKey in vstorage.go
292
- *
293
- * @typedef VStorageKey
294
- * @property {string} storeName
295
- * @property {string} storeSubkey
296
- * @property {string} dataPrefixBytes
297
- * @property {string} [noDataValue]
298
- */
299
-
300
- /**
301
- * This represents a node in an IAVL tree.
302
- *
303
- * The active implementation is x/vstorage, an Agoric extension of the Cosmos SDK.
304
- *
305
- * Vstorage is a hierarchical externally-reachable storage structure that
306
- * identifies children by restricted ASCII name and is associated with arbitrary
307
- * string-valued data for each node, defaulting to the empty string.
308
- *
309
- * @typedef {object} StorageNode
310
- * @property {(data: string) => Promise<void>} setValue publishes some data (append to the node)
311
- * @property {() => string} getPath the chain storage path at which the node was constructed
312
- * @property {() => Promise<VStorageKey>} getStoreKey DEPRECATED use getPath
313
- * @property {(subPath: string, options?: {sequence?: boolean}) => StorageNode} makeChildNode
314
- */
315
-
316
- /**
317
- * @typedef {object} StoredFacet
318
- * @property {() => Promise<string>} getPath the chain storage path at which the node was constructed
319
- * @property {StorageNode['getStoreKey']} getStoreKey DEPRECATED use getPath
320
- * @property {() => Unserializer} getUnserializer get the unserializer for the stored data
321
- */
322
-
323
- /**
324
- * @deprecated use StoredSubscriber
325
- * @template T
326
- * @typedef {Subscription<T> & {
327
- * getStoreKey: () => Promise<VStorageKey & { subscription: Subscription<T> }>,
328
- * getUnserializer: () => Unserializer,
329
- * }} StoredSubscription
330
- */
331
-
332
- /**
333
- * @template T
334
- * @typedef {Subscriber<T> & StoredFacet} StoredSubscriber
335
- */