@inflatable-cookie/longhorn 0.5.0 → 0.7.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/README.md +2 -2
- package/package.json +1 -7
- package/src/agent-control/generated/protocol.ts +228 -0
- package/src/agent-control/index.ts +1 -5
- package/src/agent-control/inject.ts +4 -1
- package/src/agent-control/selection.ts +42 -25
- package/src/agent-control/shim.ts +428 -198
- package/src/bridge/direct.ts +1 -1
- package/src/bridge/generated/fields.ts +4 -3
- package/src/bridge/generated/protocol.ts +62 -7
- package/src/bridge/generated/variant-fields.ts +1 -1
- package/src/bridge/job.ts +49 -12
- package/src/bridge/loopback.ts +7 -25
- package/src/bridge/operation.ts +13 -43
- package/src/bridge/router.ts +10 -23
- package/src/bridge/runtime/connection.ts +78 -109
- package/src/bridge/runtime/policy.ts +8 -28
- package/src/bridge/runtime/retry.ts +6 -18
- package/src/bridge/session.ts +4 -14
- package/src/bridge/stream/connection.ts +24 -55
- package/src/bridge/stream/source.ts +2 -6
- package/src/bridge/stream/tracker.ts +12 -12
- package/src/bridge/supervision.ts +104 -97
- package/src/bridge/validation/base.ts +21 -63
- package/src/bridge/validation/jobs.ts +11 -25
- package/src/bridge/validation/negotiation.ts +28 -43
- package/src/bridge/validation/operations.ts +29 -65
- package/src/bridge/validation/streams.ts +3 -10
- package/src/commands/client.ts +37 -28
- package/src/commands/controller.ts +119 -96
- package/src/commands/generated/fields.ts +7 -6
- package/src/commands/generated/protocol.ts +28 -1
- package/src/commands/generated/variant-fields.ts +1 -1
- package/src/commands/keyboard.ts +94 -100
- package/src/commands/physical-code.ts +11 -0
- package/src/commands/ports.ts +8 -13
- package/src/commands/projectors.ts +100 -75
- package/src/commands/validation.ts +434 -241
- package/src/config/client.ts +9 -22
- package/src/config/generated/base.ts +22 -6
- package/src/config/generated/fields.ts +4 -3
- package/src/config/generated/label-template.ts +1 -1
- package/src/config/generated/labels.ts +1 -1
- package/src/config/generated/protocol.ts +1 -1
- package/src/config/generated/restore.ts +35 -12
- package/src/config/generated/variant-fields.ts +1 -1
- package/src/config/names.ts +6 -12
- package/src/config/validation/commands.ts +11 -25
- package/src/config/validation/outcomes.ts +163 -70
- package/src/config/validation/primitives.ts +35 -80
- package/src/config/validation/projection.ts +100 -128
- package/src/core/connection.ts +187 -83
- package/src/core/controller-lifecycle.ts +144 -0
- package/src/core/generated/identifiers.ts +4 -0
- package/src/core/identifiers.ts +40 -0
- package/src/core/index.ts +10 -1
- package/src/core/json-value.ts +58 -0
- package/src/core/listeners.ts +35 -0
- package/src/core/record.ts +80 -0
- package/src/core/transport.ts +9 -11
- package/src/core/wire-copy.ts +7 -0
- package/src/history/client.ts +11 -13
- package/src/history/controller.ts +106 -108
- package/src/history/direct.ts +1 -3
- package/src/history/generated/fields.ts +4 -3
- package/src/history/generated/protocol.ts +8 -5
- package/src/history/generated/variant-fields.ts +1 -1
- package/src/history/ports.ts +7 -4
- package/src/history/serialized.ts +9 -13
- package/src/history/validation.ts +69 -75
- package/src/history-tree/client.ts +89 -11
- package/src/history-tree/controller.ts +380 -96
- package/src/history-tree/direct.ts +3 -1
- package/src/history-tree/generated/fields.ts +5 -3
- package/src/history-tree/generated/protocol.ts +43 -7
- package/src/history-tree/generated/variant-fields.ts +7 -1
- package/src/history-tree/ports.ts +12 -5
- package/src/history-tree/serialized.ts +39 -11
- package/src/history-tree/validation.ts +286 -78
- package/src/layout/generated/protocol.ts +4 -3
- package/src/layout/generated/variant-fields.ts +47 -0
- package/src/layout/index.ts +1 -1
- package/src/layout/ratio.ts +10 -9
- package/src/layout/validation.ts +98 -32
- package/src/layout/visibility.ts +1 -2
- package/src/licence/client.ts +48 -7
- package/src/licence/controller.ts +127 -70
- package/src/licence/direct.ts +3 -1
- package/src/licence/generated/fields.ts +4 -3
- package/src/licence/generated/key-conformance.json +28 -0
- package/src/licence/generated/protocol.ts +9 -5
- package/src/licence/generated/variant-fields.ts +1 -1
- package/src/licence/key.ts +42 -18
- package/src/licence/ports.ts +10 -3
- package/src/licence/serialized.ts +32 -9
- package/src/licence/validation.ts +134 -43
- package/src/native-content/client.ts +207 -234
- package/src/native-content/generated/fields.ts +6 -6
- package/src/native-content/generated/protocol.ts +16 -5
- package/src/native-content/generated/variant-fields.ts +1 -1
- package/src/native-content/ports.ts +11 -16
- package/src/native-content/serialized.ts +12 -19
- package/src/native-content/validation/base.ts +57 -80
- package/src/native-content/validation/messages.ts +24 -35
- package/src/native-content/validation/state.ts +31 -33
- package/src/notifications/client.ts +85 -51
- package/src/notifications/controller.ts +400 -145
- package/src/notifications/direct.ts +3 -1
- package/src/notifications/generated/fields.ts +4 -3
- package/src/notifications/generated/labels.ts +1 -1
- package/src/notifications/generated/protocol.ts +5 -1
- package/src/notifications/generated/variant-fields.ts +1 -1
- package/src/notifications/ports.ts +9 -4
- package/src/notifications/serialized.ts +11 -9
- package/src/notifications/tone.ts +1 -1
- package/src/notifications/validation.ts +165 -71
- package/src/operation/bridge.ts +187 -60
- package/src/operation/client.ts +48 -62
- package/src/operation/controller.ts +67 -97
- package/src/operation/direct.ts +1 -3
- package/src/operation/generated/fields.ts +4 -3
- package/src/operation/generated/labels.ts +1 -1
- package/src/operation/generated/protocol.ts +5 -1
- package/src/operation/generated/variant-fields.ts +1 -1
- package/src/operation/ports.ts +12 -10
- package/src/operation/serialized.ts +8 -9
- package/src/operation/validation.ts +189 -104
- package/src/settings/client.ts +11 -44
- package/src/settings/connection.ts +35 -53
- package/src/settings/generated/fields.ts +5 -4
- package/src/settings/generated/protocol.ts +14 -5
- package/src/settings/generated/variant-fields.ts +1 -1
- package/src/settings/names.ts +2 -4
- package/src/settings/registry.ts +23 -25
- package/src/settings/validation/authority.ts +21 -19
- package/src/settings/validation/command.ts +22 -41
- package/src/settings/validation/error.ts +2 -8
- package/src/settings/validation/primitives.ts +46 -97
- package/src/settings/validation/projection.ts +8 -24
- package/src/settings/validation/registry.ts +33 -79
- package/src/surface-transfer/client.ts +6 -18
- package/src/surface-transfer/generated/fields.ts +3 -3
- package/src/surface-transfer/generated/protocol.ts +3 -3
- package/src/surface-transfer/generated/variant-fields.ts +1 -1
- package/src/surface-transfer/validation.ts +91 -86
- package/src/surfaces/client.ts +33 -55
- package/src/surfaces/generated/fields.ts +3 -3
- package/src/surfaces/generated/protocol.ts +1 -1
- package/src/surfaces/generated/variant-fields.ts +1 -1
- package/src/surfaces/validation.ts +227 -99
- package/src/transfer/client.ts +26 -60
- package/src/transfer/connection.ts +29 -51
- package/src/transfer/generated/fields.ts +7 -6
- package/src/transfer/generated/protocol.ts +13 -5
- package/src/transfer/generated/variant-fields.ts +1 -1
- package/src/transfer/index.ts +8 -1
- package/src/transfer/payload.ts +20 -35
- package/src/transfer/validation.ts +169 -119
- package/src/update/client.ts +86 -9
- package/src/update/controller.ts +264 -116
- package/src/update/direct.ts +3 -1
- package/src/update/generated/fields.ts +5 -4
- package/src/update/generated/protocol.ts +25 -9
- package/src/update/generated/variant-fields.ts +4 -2
- package/src/update/ports.ts +14 -6
- package/src/update/serialized.ts +36 -10
- package/src/update/validation.ts +118 -48
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
type OperationRejection,
|
|
13
|
-
type OperationRequestId,
|
|
14
|
-
type OperationSnapshot,
|
|
1
|
+
import { ControllerLifecycle } from "../core/controller-lifecycle.ts";
|
|
2
|
+
import { isNewerOperationSnapshot, OperationClient } from "./client.ts";
|
|
3
|
+
import { OPERATION_PROTOCOL_VERSION } from "./generated/protocol.ts";
|
|
4
|
+
import type {
|
|
5
|
+
OperationCancellationResult,
|
|
6
|
+
OperationEntryProjection,
|
|
7
|
+
OperationId,
|
|
8
|
+
OperationMutationResult,
|
|
9
|
+
OperationRejection,
|
|
10
|
+
OperationRequestId,
|
|
11
|
+
OperationSnapshot,
|
|
15
12
|
} from "./generated/protocol.ts";
|
|
16
13
|
import type { OperationPort } from "./ports.ts";
|
|
17
14
|
|
|
@@ -50,9 +47,7 @@ export class OperationController {
|
|
|
50
47
|
#selectedOperationId: OperationId | undefined;
|
|
51
48
|
#commandRejection: OperationCommandRejection | undefined;
|
|
52
49
|
#commandFailure: OperationCommandFailure | undefined;
|
|
53
|
-
#
|
|
54
|
-
#started = false;
|
|
55
|
-
#lifecycleRevision = 0;
|
|
50
|
+
readonly #lifecycle = new ControllerLifecycle();
|
|
56
51
|
#commandRevision = 0;
|
|
57
52
|
|
|
58
53
|
constructor(options: OperationControllerOptions) {
|
|
@@ -60,18 +55,18 @@ export class OperationController {
|
|
|
60
55
|
}
|
|
61
56
|
|
|
62
57
|
get status(): OperationControllerStatus {
|
|
63
|
-
return this.#status;
|
|
58
|
+
return this.#lifecycle.eventFailure ?? this.#status;
|
|
64
59
|
}
|
|
65
60
|
|
|
66
61
|
get snapshot(): OperationSnapshot | undefined {
|
|
67
62
|
return this.#snapshot;
|
|
68
63
|
}
|
|
69
64
|
|
|
70
|
-
get active():
|
|
65
|
+
get active(): ReadonlyArray<OperationEntryProjection> {
|
|
71
66
|
return this.#snapshot?.active ?? [];
|
|
72
67
|
}
|
|
73
68
|
|
|
74
|
-
get recent():
|
|
69
|
+
get recent(): ReadonlyArray<OperationEntryProjection> {
|
|
75
70
|
return this.#snapshot?.recent ?? [];
|
|
76
71
|
}
|
|
77
72
|
|
|
@@ -80,11 +75,13 @@ export class OperationController {
|
|
|
80
75
|
}
|
|
81
76
|
|
|
82
77
|
get selected(): OperationEntryProjection | undefined {
|
|
83
|
-
if (this.#selectedOperationId === undefined)
|
|
78
|
+
if (this.#selectedOperationId === undefined) {
|
|
79
|
+
return undefined;
|
|
80
|
+
}
|
|
84
81
|
return this.#entry(this.#selectedOperationId);
|
|
85
82
|
}
|
|
86
83
|
|
|
87
|
-
get pendingCommands():
|
|
84
|
+
get pendingCommands(): ReadonlyArray<OperationPendingCommand> {
|
|
88
85
|
return [...this.#pending.values()];
|
|
89
86
|
}
|
|
90
87
|
|
|
@@ -101,53 +98,40 @@ export class OperationController {
|
|
|
101
98
|
return () => this.#observers.delete(observer);
|
|
102
99
|
}
|
|
103
100
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
}
|
|
101
|
+
start(): Promise<void> {
|
|
102
|
+
return this.#lifecycle.start({
|
|
103
|
+
loading: () => this.#setStatus({ kind: "loading" }),
|
|
104
|
+
connect: ({ isCurrent, reportFailure, watch }) => {
|
|
105
|
+
const subscription = this.#client.subscribe((snapshot) => {
|
|
106
|
+
if (isCurrent()) {
|
|
107
|
+
this.#install(snapshot);
|
|
108
|
+
}
|
|
109
|
+
}, reportFailure);
|
|
110
|
+
return watch(subscription, () => this.#setStatus({ kind: "ready" }));
|
|
115
111
|
},
|
|
116
|
-
({ error })
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
}
|
|
120
|
-
},
|
|
121
|
-
);
|
|
122
|
-
this.#subscription = subscription;
|
|
112
|
+
failed: (error) => this.#setStatus({ kind: "failed", error }),
|
|
113
|
+
});
|
|
114
|
+
}
|
|
123
115
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
this.#setStatus({ kind: "failed", error });
|
|
132
|
-
}
|
|
133
|
-
}
|
|
116
|
+
/** Replaces the current subscription, including after a reported failure. */
|
|
117
|
+
restart(): Promise<void> {
|
|
118
|
+
return this.#lifecycle.restart(
|
|
119
|
+
this.status,
|
|
120
|
+
() => this.stop(),
|
|
121
|
+
() => this.start(),
|
|
122
|
+
);
|
|
134
123
|
}
|
|
135
124
|
|
|
136
|
-
|
|
137
|
-
this.#
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
this.#commandFailure = undefined;
|
|
147
|
-
this.#setStatus({ kind: "idle" });
|
|
148
|
-
if (subscription !== undefined) {
|
|
149
|
-
await subscription.dispose();
|
|
150
|
-
}
|
|
125
|
+
stop(): Promise<void> {
|
|
126
|
+
return this.#lifecycle.stop(() => {
|
|
127
|
+
this.#commandRevision += 1;
|
|
128
|
+
this.#snapshot = undefined;
|
|
129
|
+
this.#selectedOperationId = undefined;
|
|
130
|
+
this.#pending.clear();
|
|
131
|
+
this.#commandRejection = undefined;
|
|
132
|
+
this.#commandFailure = undefined;
|
|
133
|
+
this.#setStatus({ kind: "idle" });
|
|
134
|
+
});
|
|
151
135
|
}
|
|
152
136
|
|
|
153
137
|
select(operationId: OperationId | undefined): void {
|
|
@@ -191,25 +175,19 @@ export class OperationController {
|
|
|
191
175
|
operationId,
|
|
192
176
|
expectedOperationRevision: operation.revision,
|
|
193
177
|
} as const;
|
|
194
|
-
return this.#runCommand(
|
|
195
|
-
|
|
196
|
-
() => this.#client.mutate(command),
|
|
178
|
+
return this.#runCommand({ requestId: command.requestId, operationId, kind: "dismissal" }, () =>
|
|
179
|
+
this.#client.mutate(command),
|
|
197
180
|
);
|
|
198
181
|
}
|
|
199
182
|
|
|
200
|
-
async #runCommand<
|
|
201
|
-
Result extends OperationCancellationResult | OperationMutationResult,
|
|
202
|
-
>(
|
|
183
|
+
async #runCommand<Result extends OperationCancellationResult | OperationMutationResult>(
|
|
203
184
|
pending: OperationPendingCommand,
|
|
204
185
|
run: () => Promise<Result>,
|
|
205
186
|
): Promise<Result> {
|
|
206
187
|
if (this.#hasPending(pending.operationId, pending.kind)) {
|
|
207
|
-
throw new OperationControllerCommandPendingError(
|
|
208
|
-
pending.operationId,
|
|
209
|
-
pending.kind,
|
|
210
|
-
);
|
|
188
|
+
throw new OperationControllerCommandPendingError(pending.operationId, pending.kind);
|
|
211
189
|
}
|
|
212
|
-
const lifecycleRevision = this.#
|
|
190
|
+
const lifecycleRevision = this.#lifecycle.revision;
|
|
213
191
|
const commandRevision = ++this.#commandRevision;
|
|
214
192
|
this.#pending.set(pending.requestId, pending);
|
|
215
193
|
this.#commandFailure = undefined;
|
|
@@ -218,26 +196,23 @@ export class OperationController {
|
|
|
218
196
|
|
|
219
197
|
try {
|
|
220
198
|
const result = await run();
|
|
221
|
-
if (this.#
|
|
199
|
+
if (this.#lifecycle.isCurrent(lifecycleRevision)) {
|
|
222
200
|
this.#install(result.snapshot);
|
|
223
|
-
if (
|
|
224
|
-
commandRevision === this.#commandRevision &&
|
|
225
|
-
result.status === "rejected"
|
|
226
|
-
) {
|
|
201
|
+
if (commandRevision === this.#commandRevision && result.status === "rejected") {
|
|
227
202
|
this.#commandRejection = { ...pending, rejection: result.rejection };
|
|
228
203
|
}
|
|
229
204
|
}
|
|
230
205
|
return result;
|
|
231
206
|
} catch (error) {
|
|
232
207
|
if (
|
|
233
|
-
this.#
|
|
208
|
+
this.#lifecycle.isCurrent(lifecycleRevision) &&
|
|
234
209
|
commandRevision === this.#commandRevision
|
|
235
210
|
) {
|
|
236
211
|
this.#commandFailure = { ...pending, error };
|
|
237
212
|
}
|
|
238
213
|
throw error;
|
|
239
214
|
} finally {
|
|
240
|
-
if (this.#
|
|
215
|
+
if (this.#lifecycle.isCurrent(lifecycleRevision)) {
|
|
241
216
|
this.#pending.delete(pending.requestId);
|
|
242
217
|
this.#notify();
|
|
243
218
|
}
|
|
@@ -245,7 +220,7 @@ export class OperationController {
|
|
|
245
220
|
}
|
|
246
221
|
|
|
247
222
|
#requireAvailableEntry(operationId: OperationId): OperationEntryProjection {
|
|
248
|
-
if (!this.#
|
|
223
|
+
if (!this.#lifecycle.active || this.#snapshot === undefined) {
|
|
249
224
|
throw new OperationControllerUnavailableError();
|
|
250
225
|
}
|
|
251
226
|
const operation = this.#entry(operationId);
|
|
@@ -256,22 +231,19 @@ export class OperationController {
|
|
|
256
231
|
}
|
|
257
232
|
|
|
258
233
|
#entry(operationId: OperationId): OperationEntryProjection | undefined {
|
|
259
|
-
return [...this.active, ...this.recent].find(
|
|
260
|
-
(entry) => entry.operationId === operationId,
|
|
261
|
-
);
|
|
234
|
+
return [...this.active, ...this.recent].find((entry) => entry.operationId === operationId);
|
|
262
235
|
}
|
|
263
236
|
|
|
264
|
-
#hasPending(
|
|
265
|
-
operationId: OperationId,
|
|
266
|
-
kind: OperationPendingCommandKind,
|
|
267
|
-
): boolean {
|
|
237
|
+
#hasPending(operationId: OperationId, kind: OperationPendingCommandKind): boolean {
|
|
268
238
|
return [...this.#pending.values()].some(
|
|
269
239
|
(pending) => pending.operationId === operationId && pending.kind === kind,
|
|
270
240
|
);
|
|
271
241
|
}
|
|
272
242
|
|
|
273
243
|
#install(snapshot: OperationSnapshot): void {
|
|
274
|
-
if (!isNewerOperationSnapshot(snapshot, this.#snapshot))
|
|
244
|
+
if (!isNewerOperationSnapshot(snapshot, this.#snapshot)) {
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
275
247
|
this.#snapshot = snapshot;
|
|
276
248
|
if (
|
|
277
249
|
this.#selectedOperationId !== undefined &&
|
|
@@ -282,17 +254,15 @@ export class OperationController {
|
|
|
282
254
|
this.#notify();
|
|
283
255
|
}
|
|
284
256
|
|
|
285
|
-
#isCurrentLifecycle(revision: number): boolean {
|
|
286
|
-
return this.#started && revision === this.#lifecycleRevision;
|
|
287
|
-
}
|
|
288
|
-
|
|
289
257
|
#setStatus(status: OperationControllerStatus): void {
|
|
290
258
|
this.#status = status;
|
|
291
259
|
this.#notify();
|
|
292
260
|
}
|
|
293
261
|
|
|
294
262
|
#notify(): void {
|
|
295
|
-
for (const observer of this.#observers)
|
|
263
|
+
for (const observer of this.#observers) {
|
|
264
|
+
observer();
|
|
265
|
+
}
|
|
296
266
|
}
|
|
297
267
|
}
|
|
298
268
|
|
package/src/operation/direct.ts
CHANGED
|
@@ -8,8 +8,6 @@ export interface DirectOperationHandlers {
|
|
|
8
8
|
readonly nextRequestId: OperationPort["nextRequestId"];
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
export function createDirectOperationPort(
|
|
12
|
-
handlers: DirectOperationHandlers,
|
|
13
|
-
): OperationPort {
|
|
11
|
+
export function createDirectOperationPort(handlers: DirectOperationHandlers): OperationPort {
|
|
14
12
|
return { ...handlers };
|
|
15
13
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
// @generated by `effigy generate:
|
|
1
|
+
// @generated by `effigy generate:bindings`; do not edit.
|
|
2
2
|
// Allowed field names per protocol type, from the Rust structs.
|
|
3
3
|
// A `record()` given one of these rejects unknown and missing keys —
|
|
4
4
|
// contract 010's Boundary Validation Target.
|
|
5
5
|
|
|
6
|
-
export const OPERATION_FIELDS
|
|
6
|
+
export const OPERATION_FIELDS = {
|
|
7
7
|
"OperationAuthorityProjection": ["authorityId", "authorityEpoch"],
|
|
8
8
|
"OperationPhaseProgressProjection": ["phaseId", "label", "completed", "total"],
|
|
9
9
|
"OperationProgressProjection": ["sequence", "overall", "phase"],
|
|
@@ -17,4 +17,5 @@ export const OPERATION_FIELDS: Record<string, readonly string[]> = {
|
|
|
17
17
|
"OperationRejection": ["code", "detail", "refreshRequired"],
|
|
18
18
|
"OperationCancellationReceiptProjection": ["operationId", "outcome", "previousState", "committedState", "previousOperationRevision", "committedOperationRevision", "previousCatalogueRevision", "committedCatalogueRevision", "evicted"],
|
|
19
19
|
"OperationChangedEvent": ["protocolVersion", "requestId", "authority", "previousCatalogueRevision", "committedCatalogueRevision", "operationId", "kind"],
|
|
20
|
-
|
|
20
|
+
"OperationHostError": ["code", "message", "retryable"],
|
|
21
|
+
} as const;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// @generated by `effigy generate:
|
|
1
|
+
// @generated by `effigy generate:bindings`; do not edit.
|
|
2
2
|
// Rust serde types are the wire authority. Product payloads are intentionally absent.
|
|
3
3
|
|
|
4
4
|
export const OPERATION_PROTOCOL_VERSION = 1 as const;
|
|
@@ -760,3 +760,7 @@ operationId: OperationId | null,
|
|
|
760
760
|
* Change source.
|
|
761
761
|
*/
|
|
762
762
|
kind: OperationChangedKind, };
|
|
763
|
+
|
|
764
|
+
export type OperationHostErrorCode = "authorityUnavailable" | "authorityStateUnavailable" | "executorStateUnavailable" | "eventPublication";
|
|
765
|
+
|
|
766
|
+
export type OperationHostError = { "code": OperationHostErrorCode, "message": string, "retryable": boolean, };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// @generated by `effigy generate:
|
|
1
|
+
// @generated by `effigy generate:bindings`; do not edit.
|
|
2
2
|
// Allowed field names per tagged-union variant, from the Rust enums.
|
|
3
3
|
// Keyed by type, then by discriminant. The discriminant itself is in
|
|
4
4
|
// each list, because `exact()` compares every key.
|
package/src/operation/ports.ts
CHANGED
|
@@ -1,29 +1,31 @@
|
|
|
1
|
+
import type { Unlisten } from "../core/transport.ts";
|
|
1
2
|
import type {
|
|
2
3
|
OperationCancellationCommand,
|
|
3
4
|
OperationChangedEvent,
|
|
4
5
|
OperationMutationCommand,
|
|
5
6
|
OperationRequestId,
|
|
6
7
|
OperationSnapshotQuery,
|
|
8
|
+
OperationSnapshotResponse,
|
|
9
|
+
OperationMutationResult,
|
|
10
|
+
OperationCancellationResult,
|
|
7
11
|
} from "./generated/protocol.ts";
|
|
8
12
|
|
|
9
|
-
export type OperationUnlisten =
|
|
13
|
+
export type OperationUnlisten = Unlisten;
|
|
10
14
|
|
|
11
15
|
export interface OperationPort {
|
|
12
16
|
snapshot(query: OperationSnapshotQuery): Promise<unknown>;
|
|
13
17
|
mutate(command: OperationMutationCommand): Promise<unknown>;
|
|
14
18
|
cancel(command: OperationCancellationCommand): Promise<unknown>;
|
|
15
|
-
listen
|
|
16
|
-
listener: (event: unknown) => void
|
|
17
|
-
|
|
19
|
+
listen?:
|
|
20
|
+
| ((listener: (event: unknown) => void) => OperationUnlisten | Promise<OperationUnlisten>)
|
|
21
|
+
| undefined;
|
|
18
22
|
nextRequestId(): OperationRequestId;
|
|
19
23
|
}
|
|
20
24
|
|
|
21
25
|
export interface CheckedOperationPort {
|
|
22
|
-
snapshot(query: OperationSnapshotQuery): Promise<
|
|
23
|
-
mutate(command: OperationMutationCommand): Promise<
|
|
24
|
-
cancel(command: OperationCancellationCommand): Promise<
|
|
25
|
-
listen?(
|
|
26
|
-
listener: (event: OperationChangedEvent) => void,
|
|
27
|
-
): Promise<OperationUnlisten>;
|
|
26
|
+
snapshot(query: OperationSnapshotQuery): Promise<OperationSnapshotResponse>;
|
|
27
|
+
mutate(command: OperationMutationCommand): Promise<OperationMutationResult>;
|
|
28
|
+
cancel(command: OperationCancellationCommand): Promise<OperationCancellationResult>;
|
|
29
|
+
listen?(listener: (event: OperationChangedEvent) => void): Promise<OperationUnlisten>;
|
|
28
30
|
nextRequestId(): OperationRequestId;
|
|
29
31
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { wireCopy } from "../core/wire-copy.ts";
|
|
1
2
|
import type {
|
|
2
3
|
OperationCancellationCommand,
|
|
3
4
|
OperationMutationCommand,
|
|
@@ -13,27 +14,25 @@ export class SerializedOperationPort implements OperationPort {
|
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
async snapshot(query: OperationSnapshotQuery): Promise<unknown> {
|
|
16
|
-
return
|
|
17
|
+
return wireCopy(await this.#inner.snapshot(wireCopy(query)));
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
async mutate(command: OperationMutationCommand): Promise<unknown> {
|
|
20
|
-
return
|
|
21
|
+
return wireCopy(await this.#inner.mutate(wireCopy(command)));
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
async cancel(command: OperationCancellationCommand): Promise<unknown> {
|
|
24
|
-
return
|
|
25
|
+
return wireCopy(await this.#inner.cancel(wireCopy(command)));
|
|
25
26
|
}
|
|
26
27
|
|
|
27
28
|
async listen(listener: (event: unknown) => void): Promise<OperationUnlisten> {
|
|
28
|
-
if (this.#inner.listen === undefined)
|
|
29
|
-
|
|
29
|
+
if (this.#inner.listen === undefined) {
|
|
30
|
+
return () => {};
|
|
31
|
+
}
|
|
32
|
+
return this.#inner.listen((event) => listener(wireCopy(event)));
|
|
30
33
|
}
|
|
31
34
|
|
|
32
35
|
nextRequestId(): string {
|
|
33
36
|
return this.#inner.nextRequestId();
|
|
34
37
|
}
|
|
35
38
|
}
|
|
36
|
-
|
|
37
|
-
function clone<Value>(value: Value): Value {
|
|
38
|
-
return JSON.parse(JSON.stringify(value)) as Value;
|
|
39
|
-
}
|