@agoric/notifier 0.6.3-dev-d756c83.0.d756c83 → 0.6.3-dev-e9efaa1.0.e9efaa1

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.
Files changed (3) hide show
  1. package/package.json +10 -10
  2. package/src/types.js +253 -0
  3. package/src/types.ts +0 -253
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agoric/notifier",
3
- "version": "0.6.3-dev-d756c83.0.d756c83",
3
+ "version": "0.6.3-dev-e9efaa1.0.e9efaa1",
4
4
  "description": "Notifier allows services to update clients about state changes using a stream of promises",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -9,8 +9,8 @@
9
9
  },
10
10
  "scripts": {
11
11
  "build": "exit 0",
12
- "prepack": "yarn run -T tsc --build tsconfig.build.json",
13
- "postpack": "git clean -f '*.d.*ts*' '*.tsbuildinfo'",
12
+ "prepack": "yarn run -T prepack-package",
13
+ "postpack": "yarn run -T postpack-package",
14
14
  "test": "ava",
15
15
  "test:c8": "c8 --all ${C8_OPTIONS:-} ava",
16
16
  "test:xs": "exit 0",
@@ -33,8 +33,8 @@
33
33
  },
34
34
  "homepage": "https://github.com/Agoric/agoric-sdk#readme",
35
35
  "dependencies": {
36
- "@agoric/internal": "0.3.3-dev-d756c83.0.d756c83",
37
- "@agoric/vat-data": "0.5.3-dev-d756c83.0.d756c83",
36
+ "@agoric/internal": "0.3.3-dev-e9efaa1.0.e9efaa1",
37
+ "@agoric/vat-data": "0.5.3-dev-e9efaa1.0.e9efaa1",
38
38
  "@endo/errors": "^1.2.13",
39
39
  "@endo/far": "^1.1.14",
40
40
  "@endo/marshal": "^1.8.0",
@@ -42,10 +42,10 @@
42
42
  "@endo/promise-kit": "^1.1.13"
43
43
  },
44
44
  "devDependencies": {
45
- "@agoric/kmarshal": "0.1.1-dev-d756c83.0.d756c83",
46
- "@agoric/swing-store": "0.9.2-dev-d756c83.0.d756c83",
47
- "@agoric/swingset-liveslots": "0.10.3-dev-d756c83.0.d756c83",
48
- "@agoric/swingset-vat": "0.32.3-dev-d756c83.0.d756c83",
45
+ "@agoric/kmarshal": "0.1.1-dev-e9efaa1.0.e9efaa1",
46
+ "@agoric/swing-store": "0.9.2-dev-e9efaa1.0.e9efaa1",
47
+ "@agoric/swingset-liveslots": "0.10.3-dev-e9efaa1.0.e9efaa1",
48
+ "@agoric/swingset-vat": "0.32.3-dev-e9efaa1.0.e9efaa1",
49
49
  "@endo/init": "^1.1.12",
50
50
  "@endo/ses-ava": "^1.3.2",
51
51
  "ava": "^5.3.0",
@@ -78,5 +78,5 @@
78
78
  "typeCoverage": {
79
79
  "atLeast": 90.92
80
80
  },
81
- "gitHead": "d756c838c7eb3e3cec4a8bdf5c24b97f942b754e"
81
+ "gitHead": "e9efaa12254f2c9a6faffc40ade2f1d9a70b87ae"
82
82
  }
package/src/types.js ADDED
@@ -0,0 +1,253 @@
1
+
2
+
3
+
4
+
5
+
6
+
7
+ /**
8
+ * An AsyncIterator that can be forked at a given position
9
+ * into multiple independent ForkableAsyncIterators starting from that position.
10
+ */
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+
20
+
21
+
22
+
23
+
24
+
25
+
26
+
27
+
28
+
29
+ /**
30
+ * An AsyncIterable that produces ForkableAsyncIterators.
31
+ */
32
+
33
+
34
+
35
+ /**
36
+ * A valid sequence of calls to the methods of an `IterationObserver`
37
+ * represents an iteration. A valid sequence consists of any number of calls
38
+ * to `updateState` with the successive non-final values, followed by a
39
+ * final call to either `finish` with a successful `completion` value
40
+ * or `fail` with the alleged `reason` for failure. After at most one
41
+ * terminating calls, no further calls to these methods are valid and must be
42
+ * rejected.
43
+ */
44
+
45
+
46
+
47
+
48
+
49
+ /**
50
+ * Will be shared between machines, so it must be safe to expose. But software
51
+ * outside the current package should consider it opaque, not depending on its
52
+ * internal structure.
53
+ */
54
+
55
+
56
+
57
+
58
+
59
+
60
+
61
+
62
+
63
+
64
+
65
+
66
+
67
+
68
+
69
+
70
+
71
+
72
+ /**
73
+ * An EachTopic with default asyncIterable behaviour.
74
+ *
75
+ * NOTE: the publication records and iterators returned by this object are
76
+ * ephemeral and will be severed during upgrade. A caller should use
77
+ * `subscribeEach` to wrap this topic in a local iterable which automatically
78
+ * attempts to reconnect upon being severed.
79
+ */
80
+
81
+ /**
82
+ * A LatestTopic with default asyncIterable behaviour.
83
+ *
84
+ * NOTE: the iterators returned by this object are ephemeral and will be severed
85
+ * during upgrade. A caller should use `subscribeLatest` to wrap this topic in
86
+ * a local iterable which automatically attempts to reconnect upon being
87
+ * severed.
88
+ */
89
+
90
+
91
+
92
+
93
+
94
+
95
+
96
+
97
+
98
+
99
+
100
+
101
+
102
+
103
+ /**
104
+ * This type is deprecated but is still
105
+ * used externally.
106
+ */
107
+
108
+ /**
109
+ * A stream of results that allows consumers to configure
110
+ * forward-lossless "each" iteration with `subscribeEach` and
111
+ * lossy "latest" iteration with `subscribeLatest`.
112
+ */
113
+
114
+ /**
115
+ * A valid sequence of calls to the methods of an `IterationObserver`
116
+ * represents an iteration. A valid sequence consists of any number of calls
117
+ * to `publish` with the successive non-final values, followed by a
118
+ * final call to either `finish` with a successful `completion` value
119
+ * or `fail` with the alleged `reason` for failure. After at most one
120
+ * terminating calls, no further calls to these methods are valid and must be
121
+ * rejected.
122
+ */
123
+
124
+
125
+
126
+
127
+
128
+
129
+
130
+
131
+
132
+
133
+
134
+
135
+
136
+
137
+ /**
138
+ * Durability configures constraints on non-terminal values that can be
139
+ * published to a durable publish kit (terminal values sent to finish or fail
140
+ * must always be durable).
141
+ * - 'mandatory' means that each value must be durable, so it can be restored
142
+ * on upgrade.
143
+ * - 'opportunistic' means that a durable value is persisted for post-upgrade
144
+ * restoration, but a non-durable value is still accepted (and will result in
145
+ * valueless restoration).
146
+ * - 'ignored' means that a value is not persisted for restoration even if it
147
+ * is durable.
148
+ *
149
+ * 'mandatory' is the only currently-supported value, and others must not be
150
+ * enabled without test coverage.
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
+ * Will be shared between machines,
185
+ * so it must be safe to expose. But other software should avoid depending on
186
+ * its internal structure.
187
+ */
188
+
189
+ /**
190
+ * an object that can be used to get the current state or updates
191
+ */
192
+
193
+
194
+
195
+
196
+
197
+
198
+
199
+
200
+
201
+
202
+
203
+
204
+
205
+
206
+
207
+
208
+
209
+ /**
210
+ * the produced notifier/updater pair
211
+ */
212
+
213
+
214
+
215
+
216
+
217
+
218
+
219
+
220
+
221
+
222
+ /**
223
+ * A form of AsyncIterable supporting distributed and multicast usage.
224
+ */
225
+
226
+
227
+
228
+
229
+
230
+
231
+
232
+
233
+
234
+
235
+
236
+
237
+
238
+
239
+
240
+
241
+
242
+
243
+
244
+
245
+
246
+
247
+
248
+
249
+
250
+
251
+
252
+
253
+
package/src/types.ts DELETED
@@ -1,253 +0,0 @@
1
- import type {
2
- StoredFacet,
3
- Unserializer,
4
- VStorageKey,
5
- } from '@agoric/internal/src/lib-chainStorage.js';
6
-
7
- /**
8
- * An AsyncIterator that can be forked at a given position
9
- * into multiple independent ForkableAsyncIterators starting from that position.
10
- */
11
- export type ForkableAsyncIterator<
12
- T,
13
- TReturn = any,
14
- TNext = undefined,
15
- > = AsyncIterator<T, TReturn, TNext> & {
16
- fork(): ForkableAsyncIterator<T, TReturn, TNext>;
17
- };
18
- export type AsyncIterableOnly<T, TReturn = any, TNext = undefined> = {
19
- [Symbol.asyncIterator](): AsyncIterableIterator<T, TReturn, TNext>;
20
- };
21
- export type ForkableAsyncIterableIterator<
22
- T,
23
- TReturn = any,
24
- TNext = undefined,
25
- > = {
26
- [Symbol.asyncIterator](): ForkableAsyncIterableIterator<T, TReturn, TNext>;
27
- fork(): ForkableAsyncIterableIterator<T, TReturn, TNext>;
28
- } & ForkableAsyncIterator<T, TReturn, TNext>;
29
- /**
30
- * An AsyncIterable that produces ForkableAsyncIterators.
31
- */
32
- export type ForkableAsyncIterable<T, TReturn = any, TNext = undefined> = {
33
- [Symbol.asyncIterator]: () => ForkableAsyncIterator<T, TReturn, TNext>;
34
- };
35
- /**
36
- * A valid sequence of calls to the methods of an `IterationObserver`
37
- * represents an iteration. A valid sequence consists of any number of calls
38
- * to `updateState` with the successive non-final values, followed by a
39
- * final call to either `finish` with a successful `completion` value
40
- * or `fail` with the alleged `reason` for failure. After at most one
41
- * terminating calls, no further calls to these methods are valid and must be
42
- * rejected.
43
- */
44
- export type IterationObserver<T> = {
45
- updateState: (nonFinalValue: T) => void;
46
- finish: (completion: T) => void;
47
- fail: (reason: unknown) => void;
48
- };
49
- /**
50
- * Will be shared between machines, so it must be safe to expose. But software
51
- * outside the current package should consider it opaque, not depending on its
52
- * internal structure.
53
- */
54
- export type PublicationRecord<T> = {
55
- head: IteratorResult<T>;
56
- /**
57
- * starts at 1 for the first result
58
- * and advances by 1 for each subsequent result
59
- */
60
- publishCount: bigint;
61
- tail: Promise<PublicationRecord<T>>;
62
- };
63
- export type EachTopic<T> = {
64
- /**
65
- * Returns a promise for a "current" PublicationRecord (referencing its
66
- * immediate successor via a `tail` promise) that is later than the
67
- * provided publishCount.
68
- * Used to make forward-lossless ("each") iterators.
69
- */
70
- subscribeAfter: (publishCount?: bigint) => Promise<PublicationRecord<T>>;
71
- };
72
- /**
73
- * An EachTopic with default asyncIterable behaviour.
74
- *
75
- * NOTE: the publication records and iterators returned by this object are
76
- * ephemeral and will be severed during upgrade. A caller should use
77
- * `subscribeEach` to wrap this topic in a local iterable which automatically
78
- * attempts to reconnect upon being severed.
79
- */
80
- export type IterableEachTopic<T> = ForkableAsyncIterable<T, T> & EachTopic<T>;
81
- /**
82
- * A LatestTopic with default asyncIterable behaviour.
83
- *
84
- * NOTE: the iterators returned by this object are ephemeral and will be severed
85
- * during upgrade. A caller should use `subscribeLatest` to wrap this topic in
86
- * a local iterable which automatically attempts to reconnect upon being
87
- * severed.
88
- */
89
- export type IterableLatestTopic<T> = AsyncIterableOnly<T, T> & LatestTopic<T>;
90
- export type LatestTopic<T> = {
91
- /**
92
- * Returns a promise for an update record as of an update count.
93
- * If the `updateCount` argument is omitted or differs from the current update count,
94
- * the promise promptly resolves to the current record.
95
- * Otherwise, after the next state change, the promise resolves to the resulting record.
96
- * This is an attenuated form of `subscribeAfter` whose return value stands alone and
97
- * does not allow consumers to pin a chain of historical PublicationRecords.
98
- * Used to make lossy ("latest") iterators.
99
- * NOTE: Use of `number` as an `updateCount` is deprecated.
100
- */
101
- getUpdateSince: (updateCount?: bigint | number) => Promise<UpdateRecord<T>>;
102
- };
103
- /**
104
- * This type is deprecated but is still
105
- * used externally.
106
- */
107
- export type BaseNotifier<T> = LatestTopic<T>;
108
- /**
109
- * A stream of results that allows consumers to configure
110
- * forward-lossless "each" iteration with `subscribeEach` and
111
- * lossy "latest" iteration with `subscribeLatest`.
112
- */
113
- export type Subscriber<T> = LatestTopic<T> & EachTopic<T>;
114
- /**
115
- * A valid sequence of calls to the methods of an `IterationObserver`
116
- * represents an iteration. A valid sequence consists of any number of calls
117
- * to `publish` with the successive non-final values, followed by a
118
- * final call to either `finish` with a successful `completion` value
119
- * or `fail` with the alleged `reason` for failure. After at most one
120
- * terminating calls, no further calls to these methods are valid and must be
121
- * rejected.
122
- */
123
- export type Publisher<T> = {
124
- publish: (nonFinalValue: T) => void;
125
- finish: (completion: T) => void;
126
- fail: (reason: any) => void;
127
- };
128
- export type PublishObserver<T> = Partial<Publisher<T>>;
129
- export type PublishKit<T> = {
130
- publisher: Publisher<T>;
131
- subscriber: Subscriber<T>;
132
- };
133
- export type StoredPublishKit<T> = {
134
- publisher: Publisher<T>;
135
- subscriber: StoredSubscriber<T>;
136
- };
137
- /**
138
- * Durability configures constraints on non-terminal values that can be
139
- * published to a durable publish kit (terminal values sent to finish or fail
140
- * must always be durable).
141
- * - 'mandatory' means that each value must be durable, so it can be restored
142
- * on upgrade.
143
- * - 'opportunistic' means that a durable value is persisted for post-upgrade
144
- * restoration, but a non-durable value is still accepted (and will result in
145
- * valueless restoration).
146
- * - 'ignored' means that a value is not persisted for restoration even if it
147
- * is durable.
148
- *
149
- * 'mandatory' is the only currently-supported value, and others must not be
150
- * enabled without test coverage.
151
- */
152
- export type DurablePublishKitValueDurability =
153
- | 'mandatory'
154
- | 'opportunistic'
155
- | 'ignored';
156
- export type DurablePublishKitState = {
157
- valueDurability: DurablePublishKitValueDurability;
158
- publishCount: bigint;
159
- status: 'live' | 'finished' | 'failed';
160
- /**
161
- * hasValue indicates the presence of value. It starts off false,
162
- * and can be reset to false when a durable publish kit is restored and
163
- * the previous value was not durable, or non-terminal and valueDurablity is 'ignored'.
164
- */
165
- hasValue: boolean;
166
- /**
167
- * value holds either a non-terminal value from `publish` or a terminal value
168
- * from `finish` or `fail`, depending upon the value in status.
169
- */
170
- value: any;
171
- };
172
- export type UpdateRecord<T> = {
173
- /**
174
- * is whatever state the service wants to publish
175
- */
176
- value: T;
177
- /**
178
- * is a value that identifies the update. For
179
- * the last update, it is `undefined`.
180
- */
181
- updateCount?: bigint | undefined;
182
- };
183
- /**
184
- * Will be shared between machines,
185
- * so it must be safe to expose. But other software should avoid depending on
186
- * its internal structure.
187
- */
188
- export type NotifierInternals<T> = BaseNotifier<T>;
189
- /**
190
- * an object that can be used to get the current state or updates
191
- */
192
- export type Notifier<T> = import('@endo/marshal').RemotableObject &
193
- NotifierInternals<T> &
194
- ForkableAsyncIterable<T, T> &
195
- SharableNotifier<T>;
196
- export type SharableNotifier<T> = {
197
- /**
198
- * Used to replicate the multicast values at other sites. To manually create a
199
- * local representative of a Notification, do
200
- * ```js
201
- * localIterable =
202
- * makeNotifier(E(remoteIterable).getSharableNotifierInternals());
203
- * ```
204
- * The resulting `localIterable` also supports such remote use, and
205
- * will return access to the same representation.
206
- */
207
- getSharableNotifierInternals: () => Promise<NotifierInternals<T>>;
208
- };
209
- /**
210
- * the produced notifier/updater pair
211
- */
212
- export type NotifierRecord<T> = {
213
- /**
214
- * the (closely-held) notifier producer
215
- */
216
- updater: import('@endo/marshal').RemotableObject & IterationObserver<T>;
217
- /**
218
- * the (widely-held) notifier consumer
219
- */
220
- notifier: Notifier<T>;
221
- };
222
- /**
223
- * A form of AsyncIterable supporting distributed and multicast usage.
224
- */
225
- export type Subscription<T> = IterableEachTopic<T> &
226
- EachTopic<T> &
227
- SharableSubscription<T>;
228
- export type SharableSubscription<T> = {
229
- /**
230
- * Used to replicate the multicast values at other sites. To manually create a
231
- * local representative of a Subscription, do
232
- * ```js
233
- * localIterable =
234
- * makeSubscription(E(remoteIterable).getSharableSubscriptionInternals());
235
- * ```
236
- * The resulting `localIterable` also supports such remote use, and
237
- * will return access to the same representation.
238
- */
239
- getSharableSubscriptionInternals: () => Promise<EachTopic<T>>;
240
- };
241
- export type SubscriptionRecord<T> = {
242
- publication: IterationObserver<T>;
243
- subscription: Subscription<T>;
244
- };
245
- export type StoredSubscription<T> = Subscription<T> & {
246
- getStoreKey: () => Promise<
247
- VStorageKey & {
248
- subscription: Subscription<T>;
249
- }
250
- >;
251
- getUnserializer: () => Unserializer;
252
- };
253
- export type StoredSubscriber<T> = Subscriber<T> & StoredFacet;