@inflatable-cookie/longhorn 0.1.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/LICENSE +21 -0
- package/README.md +38 -0
- package/package.json +205 -0
- package/src/agent-control/index.ts +20 -0
- package/src/agent-control/inject.ts +4 -0
- package/src/agent-control/shim.ts +722 -0
- package/src/bridge/direct.ts +22 -0
- package/src/bridge/generated/fields.ts +32 -0
- package/src/bridge/generated/protocol.ts +218 -0
- package/src/bridge/generated/variant-fields.ts +10 -0
- package/src/bridge/index.ts +15 -0
- package/src/bridge/job.ts +51 -0
- package/src/bridge/loopback.ts +84 -0
- package/src/bridge/operation.ts +166 -0
- package/src/bridge/router.ts +71 -0
- package/src/bridge/runtime/connection.ts +318 -0
- package/src/bridge/runtime/policy.ts +89 -0
- package/src/bridge/runtime/retry.ts +60 -0
- package/src/bridge/runtime.ts +3 -0
- package/src/bridge/session.ts +67 -0
- package/src/bridge/stream/connection.ts +146 -0
- package/src/bridge/stream/source.ts +61 -0
- package/src/bridge/stream/tracker.ts +109 -0
- package/src/bridge/stream.ts +6 -0
- package/src/bridge/supervision.ts +204 -0
- package/src/bridge/validation/base.ts +164 -0
- package/src/bridge/validation/jobs.ts +105 -0
- package/src/bridge/validation/negotiation.ts +242 -0
- package/src/bridge/validation/operations.ts +213 -0
- package/src/bridge/validation/streams.ts +47 -0
- package/src/bridge/validation.ts +5 -0
- package/src/commands/client.ts +124 -0
- package/src/commands/controller.ts +411 -0
- package/src/commands/generated/fields.ts +43 -0
- package/src/commands/generated/protocol.ts +876 -0
- package/src/commands/generated/variant-fields.ts +88 -0
- package/src/commands/index.ts +13 -0
- package/src/commands/keyboard.ts +361 -0
- package/src/commands/ports.ts +82 -0
- package/src/commands/projectors.ts +306 -0
- package/src/commands/validation.ts +444 -0
- package/src/config/client.ts +215 -0
- package/src/config/generated/base.ts +714 -0
- package/src/config/generated/fields.ts +54 -0
- package/src/config/generated/label-template.ts +14 -0
- package/src/config/generated/labels.ts +30 -0
- package/src/config/generated/protocol.ts +3 -0
- package/src/config/generated/restore.ts +658 -0
- package/src/config/generated/variant-fields.ts +129 -0
- package/src/config/index.ts +12 -0
- package/src/config/names.ts +19 -0
- package/src/config/validation/commands.ts +155 -0
- package/src/config/validation/outcomes.ts +243 -0
- package/src/config/validation/primitives.ts +174 -0
- package/src/config/validation/projection.ts +351 -0
- package/src/config/validation.ts +7 -0
- package/src/core/connection.ts +252 -0
- package/src/core/index.ts +2 -0
- package/src/core/transport.ts +24 -0
- package/src/history/client.ts +65 -0
- package/src/history/controller.ts +385 -0
- package/src/history/direct.ts +21 -0
- package/src/history/generated/fields.ts +18 -0
- package/src/history/generated/protocol.ts +389 -0
- package/src/history/generated/variant-fields.ts +27 -0
- package/src/history/index.ts +13 -0
- package/src/history/ports.ts +31 -0
- package/src/history/serialized.ts +38 -0
- package/src/history/validation.ts +334 -0
- package/src/history-tree/client.ts +16 -0
- package/src/history-tree/controller.ts +199 -0
- package/src/history-tree/direct.ts +3 -0
- package/src/history-tree/generated/fields.ts +26 -0
- package/src/history-tree/generated/protocol.ts +711 -0
- package/src/history-tree/generated/variant-fields.ts +39 -0
- package/src/history-tree/index.ts +13 -0
- package/src/history-tree/ports.ts +43 -0
- package/src/history-tree/serialized.ts +15 -0
- package/src/history-tree/validation.ts +269 -0
- package/src/layout/generated/protocol.ts +289 -0
- package/src/layout/index.ts +4 -0
- package/src/layout/ratio.ts +22 -0
- package/src/layout/validation.ts +110 -0
- package/src/layout/visibility.ts +30 -0
- package/src/licence/client.ts +32 -0
- package/src/licence/controller.ts +301 -0
- package/src/licence/direct.ts +3 -0
- package/src/licence/generated/fields.ts +17 -0
- package/src/licence/generated/key-conformance.json +42 -0
- package/src/licence/generated/protocol.ts +249 -0
- package/src/licence/generated/variant-fields.ts +34 -0
- package/src/licence/index.ts +14 -0
- package/src/licence/key.ts +125 -0
- package/src/licence/ports.ts +39 -0
- package/src/licence/serialized.ts +13 -0
- package/src/licence/validation.ts +226 -0
- package/src/native-content/client.ts +474 -0
- package/src/native-content/direct.ts +16 -0
- package/src/native-content/generated/fields.ts +32 -0
- package/src/native-content/generated/protocol.ts +498 -0
- package/src/native-content/generated/variant-fields.ts +77 -0
- package/src/native-content/index.ts +12 -0
- package/src/native-content/ports.ts +46 -0
- package/src/native-content/serialized.ts +50 -0
- package/src/native-content/validation/base.ts +194 -0
- package/src/native-content/validation/messages.ts +192 -0
- package/src/native-content/validation/state.ts +404 -0
- package/src/native-content/validation.ts +7 -0
- package/src/notifications/client.ts +106 -0
- package/src/notifications/controller.ts +240 -0
- package/src/notifications/direct.ts +12 -0
- package/src/notifications/generated/fields.ts +19 -0
- package/src/notifications/generated/labels.ts +20 -0
- package/src/notifications/generated/protocol.ts +522 -0
- package/src/notifications/generated/variant-fields.ts +37 -0
- package/src/notifications/index.ts +16 -0
- package/src/notifications/ports.ts +22 -0
- package/src/notifications/serialized.ts +27 -0
- package/src/notifications/toast.ts +41 -0
- package/src/notifications/tone.ts +27 -0
- package/src/notifications/validation.ts +246 -0
- package/src/operation/bridge.ts +168 -0
- package/src/operation/client.ts +167 -0
- package/src/operation/controller.ts +321 -0
- package/src/operation/direct.ts +15 -0
- package/src/operation/generated/fields.ts +20 -0
- package/src/operation/generated/labels.ts +15 -0
- package/src/operation/generated/protocol.ts +762 -0
- package/src/operation/generated/variant-fields.ts +60 -0
- package/src/operation/index.ts +14 -0
- package/src/operation/ports.ts +29 -0
- package/src/operation/serialized.ts +39 -0
- package/src/operation/validation.ts +479 -0
- package/src/settings/client.ts +142 -0
- package/src/settings/connection.ts +246 -0
- package/src/settings/generated/fields.ts +34 -0
- package/src/settings/generated/protocol.ts +668 -0
- package/src/settings/generated/variant-fields.ts +26 -0
- package/src/settings/index.ts +12 -0
- package/src/settings/names.ts +8 -0
- package/src/settings/registry.ts +141 -0
- package/src/settings/validation/authority.ts +66 -0
- package/src/settings/validation/command.ts +165 -0
- package/src/settings/validation/error.ts +33 -0
- package/src/settings/validation/primitives.ts +203 -0
- package/src/settings/validation/projection.ts +50 -0
- package/src/settings/validation/registry.ts +170 -0
- package/src/settings/validation.ts +4 -0
- package/src/surface-transfer/client.ts +54 -0
- package/src/surface-transfer/generated/fields.ts +12 -0
- package/src/surface-transfer/generated/protocol.ts +61 -0
- package/src/surface-transfer/generated/variant-fields.ts +30 -0
- package/src/surface-transfer/index.ts +9 -0
- package/src/surface-transfer/validation.ts +209 -0
- package/src/surfaces/client.ts +140 -0
- package/src/surfaces/generated/fields.ts +19 -0
- package/src/surfaces/generated/protocol.ts +217 -0
- package/src/surfaces/generated/variant-fields.ts +42 -0
- package/src/surfaces/index.ts +9 -0
- package/src/surfaces/validation.ts +199 -0
- package/src/transfer/client.ts +133 -0
- package/src/transfer/connection.ts +87 -0
- package/src/transfer/generated/fields.ts +23 -0
- package/src/transfer/generated/protocol.ts +171 -0
- package/src/transfer/generated/variant-fields.ts +45 -0
- package/src/transfer/index.ts +11 -0
- package/src/transfer/payload.ts +71 -0
- package/src/transfer/validation.ts +282 -0
- package/src/update/client.ts +29 -0
- package/src/update/controller.ts +255 -0
- package/src/update/direct.ts +3 -0
- package/src/update/generated/fields.ts +14 -0
- package/src/update/generated/protocol.ts +238 -0
- package/src/update/generated/variant-fields.ts +44 -0
- package/src/update/index.ts +14 -0
- package/src/update/ports.ts +36 -0
- package/src/update/serialized.ts +12 -0
- package/src/update/validation.ts +191 -0
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isNewerOperationSnapshot,
|
|
3
|
+
OperationClient,
|
|
4
|
+
type OperationSubscription,
|
|
5
|
+
} from "./client.ts";
|
|
6
|
+
import {
|
|
7
|
+
OPERATION_PROTOCOL_VERSION,
|
|
8
|
+
type OperationCancellationResult,
|
|
9
|
+
type OperationEntryProjection,
|
|
10
|
+
type OperationId,
|
|
11
|
+
type OperationMutationResult,
|
|
12
|
+
type OperationRejection,
|
|
13
|
+
type OperationRequestId,
|
|
14
|
+
type OperationSnapshot,
|
|
15
|
+
} from "./generated/protocol.ts";
|
|
16
|
+
import type { OperationPort } from "./ports.ts";
|
|
17
|
+
|
|
18
|
+
export type OperationControllerStatus =
|
|
19
|
+
| { readonly kind: "idle" }
|
|
20
|
+
| { readonly kind: "loading" }
|
|
21
|
+
| { readonly kind: "ready" }
|
|
22
|
+
| { readonly kind: "failed"; readonly error: unknown };
|
|
23
|
+
|
|
24
|
+
export type OperationPendingCommandKind = "cancellation" | "dismissal";
|
|
25
|
+
|
|
26
|
+
export interface OperationPendingCommand {
|
|
27
|
+
readonly requestId: OperationRequestId;
|
|
28
|
+
readonly operationId: OperationId;
|
|
29
|
+
readonly kind: OperationPendingCommandKind;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface OperationCommandRejection extends OperationPendingCommand {
|
|
33
|
+
readonly rejection: OperationRejection;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface OperationCommandFailure extends OperationPendingCommand {
|
|
37
|
+
readonly error: unknown;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface OperationControllerOptions {
|
|
41
|
+
readonly port: OperationPort;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export class OperationController {
|
|
45
|
+
readonly #client: OperationClient;
|
|
46
|
+
readonly #observers = new Set<() => void>();
|
|
47
|
+
readonly #pending = new Map<OperationRequestId, OperationPendingCommand>();
|
|
48
|
+
#status: OperationControllerStatus = { kind: "idle" };
|
|
49
|
+
#snapshot: OperationSnapshot | undefined;
|
|
50
|
+
#selectedOperationId: OperationId | undefined;
|
|
51
|
+
#commandRejection: OperationCommandRejection | undefined;
|
|
52
|
+
#commandFailure: OperationCommandFailure | undefined;
|
|
53
|
+
#subscription: OperationSubscription | undefined;
|
|
54
|
+
#started = false;
|
|
55
|
+
#lifecycleRevision = 0;
|
|
56
|
+
#commandRevision = 0;
|
|
57
|
+
|
|
58
|
+
constructor(options: OperationControllerOptions) {
|
|
59
|
+
this.#client = new OperationClient(options.port);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
get status(): OperationControllerStatus {
|
|
63
|
+
return this.#status;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
get snapshot(): OperationSnapshot | undefined {
|
|
67
|
+
return this.#snapshot;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
get active(): readonly OperationEntryProjection[] {
|
|
71
|
+
return this.#snapshot?.active ?? [];
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
get recent(): readonly OperationEntryProjection[] {
|
|
75
|
+
return this.#snapshot?.recent ?? [];
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
get selectedOperationId(): OperationId | undefined {
|
|
79
|
+
return this.#selectedOperationId;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
get selected(): OperationEntryProjection | undefined {
|
|
83
|
+
if (this.#selectedOperationId === undefined) return undefined;
|
|
84
|
+
return this.#entry(this.#selectedOperationId);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
get pendingCommands(): readonly OperationPendingCommand[] {
|
|
88
|
+
return [...this.#pending.values()];
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
get commandRejection(): OperationCommandRejection | undefined {
|
|
92
|
+
return this.#commandRejection;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
get commandFailure(): OperationCommandFailure | undefined {
|
|
96
|
+
return this.#commandFailure;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
observe(observer: () => void): () => void {
|
|
100
|
+
this.#observers.add(observer);
|
|
101
|
+
return () => this.#observers.delete(observer);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
async start(): Promise<void> {
|
|
105
|
+
if (this.#started) return;
|
|
106
|
+
this.#started = true;
|
|
107
|
+
const lifecycleRevision = ++this.#lifecycleRevision;
|
|
108
|
+
this.#setStatus({ kind: "loading" });
|
|
109
|
+
|
|
110
|
+
const subscription = this.#client.subscribe(
|
|
111
|
+
(snapshot) => {
|
|
112
|
+
if (this.#isCurrentLifecycle(lifecycleRevision)) {
|
|
113
|
+
this.#install(snapshot);
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
({ error }) => {
|
|
117
|
+
if (this.#isCurrentLifecycle(lifecycleRevision)) {
|
|
118
|
+
this.#setStatus({ kind: "failed", error });
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
);
|
|
122
|
+
this.#subscription = subscription;
|
|
123
|
+
|
|
124
|
+
try {
|
|
125
|
+
await subscription.ready;
|
|
126
|
+
if (this.#isCurrentLifecycle(lifecycleRevision)) {
|
|
127
|
+
this.#setStatus({ kind: "ready" });
|
|
128
|
+
}
|
|
129
|
+
} catch (error) {
|
|
130
|
+
if (this.#isCurrentLifecycle(lifecycleRevision)) {
|
|
131
|
+
this.#setStatus({ kind: "failed", error });
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
async stop(): Promise<void> {
|
|
137
|
+
this.#started = false;
|
|
138
|
+
this.#lifecycleRevision += 1;
|
|
139
|
+
this.#commandRevision += 1;
|
|
140
|
+
const subscription = this.#subscription;
|
|
141
|
+
this.#subscription = undefined;
|
|
142
|
+
this.#snapshot = undefined;
|
|
143
|
+
this.#selectedOperationId = undefined;
|
|
144
|
+
this.#pending.clear();
|
|
145
|
+
this.#commandRejection = undefined;
|
|
146
|
+
this.#commandFailure = undefined;
|
|
147
|
+
this.#setStatus({ kind: "idle" });
|
|
148
|
+
if (subscription !== undefined) {
|
|
149
|
+
await subscription.dispose();
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
select(operationId: OperationId | undefined): void {
|
|
154
|
+
if (operationId !== undefined && this.#entry(operationId) === undefined) {
|
|
155
|
+
throw new OperationControllerUnknownOperationError(operationId);
|
|
156
|
+
}
|
|
157
|
+
this.#selectedOperationId = operationId;
|
|
158
|
+
this.#notify();
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
isCancellationPending(operationId: OperationId): boolean {
|
|
162
|
+
return this.#hasPending(operationId, "cancellation");
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
isDismissalPending(operationId: OperationId): boolean {
|
|
166
|
+
return this.#hasPending(operationId, "dismissal");
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
async cancel(operationId: OperationId): Promise<OperationCancellationResult> {
|
|
170
|
+
const operation = this.#requireAvailableEntry(operationId);
|
|
171
|
+
const command = {
|
|
172
|
+
protocolVersion: OPERATION_PROTOCOL_VERSION,
|
|
173
|
+
requestId: this.#client.nextRequestId(),
|
|
174
|
+
authority: operation.authority,
|
|
175
|
+
operationId,
|
|
176
|
+
expectedOperationRevision: operation.revision,
|
|
177
|
+
} as const;
|
|
178
|
+
return this.#runCommand(
|
|
179
|
+
{ requestId: command.requestId, operationId, kind: "cancellation" },
|
|
180
|
+
() => this.#client.cancel(command),
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
async dismiss(operationId: OperationId): Promise<OperationMutationResult> {
|
|
185
|
+
const operation = this.#requireAvailableEntry(operationId);
|
|
186
|
+
const command = {
|
|
187
|
+
kind: "dismiss",
|
|
188
|
+
protocolVersion: OPERATION_PROTOCOL_VERSION,
|
|
189
|
+
requestId: this.#client.nextRequestId(),
|
|
190
|
+
authority: operation.authority,
|
|
191
|
+
operationId,
|
|
192
|
+
expectedOperationRevision: operation.revision,
|
|
193
|
+
} as const;
|
|
194
|
+
return this.#runCommand(
|
|
195
|
+
{ requestId: command.requestId, operationId, kind: "dismissal" },
|
|
196
|
+
() => this.#client.mutate(command),
|
|
197
|
+
);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
async #runCommand<
|
|
201
|
+
Result extends OperationCancellationResult | OperationMutationResult,
|
|
202
|
+
>(
|
|
203
|
+
pending: OperationPendingCommand,
|
|
204
|
+
run: () => Promise<Result>,
|
|
205
|
+
): Promise<Result> {
|
|
206
|
+
if (this.#hasPending(pending.operationId, pending.kind)) {
|
|
207
|
+
throw new OperationControllerCommandPendingError(
|
|
208
|
+
pending.operationId,
|
|
209
|
+
pending.kind,
|
|
210
|
+
);
|
|
211
|
+
}
|
|
212
|
+
const lifecycleRevision = this.#lifecycleRevision;
|
|
213
|
+
const commandRevision = ++this.#commandRevision;
|
|
214
|
+
this.#pending.set(pending.requestId, pending);
|
|
215
|
+
this.#commandFailure = undefined;
|
|
216
|
+
this.#commandRejection = undefined;
|
|
217
|
+
this.#notify();
|
|
218
|
+
|
|
219
|
+
try {
|
|
220
|
+
const result = await run();
|
|
221
|
+
if (this.#isCurrentLifecycle(lifecycleRevision)) {
|
|
222
|
+
this.#install(result.snapshot);
|
|
223
|
+
if (
|
|
224
|
+
commandRevision === this.#commandRevision &&
|
|
225
|
+
result.status === "rejected"
|
|
226
|
+
) {
|
|
227
|
+
this.#commandRejection = { ...pending, rejection: result.rejection };
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
return result;
|
|
231
|
+
} catch (error) {
|
|
232
|
+
if (
|
|
233
|
+
this.#isCurrentLifecycle(lifecycleRevision) &&
|
|
234
|
+
commandRevision === this.#commandRevision
|
|
235
|
+
) {
|
|
236
|
+
this.#commandFailure = { ...pending, error };
|
|
237
|
+
}
|
|
238
|
+
throw error;
|
|
239
|
+
} finally {
|
|
240
|
+
if (this.#isCurrentLifecycle(lifecycleRevision)) {
|
|
241
|
+
this.#pending.delete(pending.requestId);
|
|
242
|
+
this.#notify();
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
#requireAvailableEntry(operationId: OperationId): OperationEntryProjection {
|
|
248
|
+
if (!this.#started || this.#snapshot === undefined) {
|
|
249
|
+
throw new OperationControllerUnavailableError();
|
|
250
|
+
}
|
|
251
|
+
const operation = this.#entry(operationId);
|
|
252
|
+
if (operation === undefined) {
|
|
253
|
+
throw new OperationControllerUnknownOperationError(operationId);
|
|
254
|
+
}
|
|
255
|
+
return operation;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
#entry(operationId: OperationId): OperationEntryProjection | undefined {
|
|
259
|
+
return [...this.active, ...this.recent].find(
|
|
260
|
+
(entry) => entry.operationId === operationId,
|
|
261
|
+
);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
#hasPending(
|
|
265
|
+
operationId: OperationId,
|
|
266
|
+
kind: OperationPendingCommandKind,
|
|
267
|
+
): boolean {
|
|
268
|
+
return [...this.#pending.values()].some(
|
|
269
|
+
(pending) => pending.operationId === operationId && pending.kind === kind,
|
|
270
|
+
);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
#install(snapshot: OperationSnapshot): void {
|
|
274
|
+
if (!isNewerOperationSnapshot(snapshot, this.#snapshot)) return;
|
|
275
|
+
this.#snapshot = snapshot;
|
|
276
|
+
if (
|
|
277
|
+
this.#selectedOperationId !== undefined &&
|
|
278
|
+
this.#entry(this.#selectedOperationId) === undefined
|
|
279
|
+
) {
|
|
280
|
+
this.#selectedOperationId = undefined;
|
|
281
|
+
}
|
|
282
|
+
this.#notify();
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
#isCurrentLifecycle(revision: number): boolean {
|
|
286
|
+
return this.#started && revision === this.#lifecycleRevision;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
#setStatus(status: OperationControllerStatus): void {
|
|
290
|
+
this.#status = status;
|
|
291
|
+
this.#notify();
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
#notify(): void {
|
|
295
|
+
for (const observer of this.#observers) observer();
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
export class OperationControllerUnavailableError extends Error {
|
|
300
|
+
constructor() {
|
|
301
|
+
super("operation controller is not connected");
|
|
302
|
+
this.name = "OperationControllerUnavailableError";
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
export class OperationControllerUnknownOperationError extends Error {
|
|
307
|
+
constructor(readonly operationId: OperationId) {
|
|
308
|
+
super(`unknown operation: ${operationId}`);
|
|
309
|
+
this.name = "OperationControllerUnknownOperationError";
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
export class OperationControllerCommandPendingError extends Error {
|
|
314
|
+
constructor(
|
|
315
|
+
readonly operationId: OperationId,
|
|
316
|
+
readonly kind: OperationPendingCommandKind,
|
|
317
|
+
) {
|
|
318
|
+
super(`${kind} already pending for operation: ${operationId}`);
|
|
319
|
+
this.name = "OperationControllerCommandPendingError";
|
|
320
|
+
}
|
|
321
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { OperationPort } from "./ports.ts";
|
|
2
|
+
|
|
3
|
+
export interface DirectOperationHandlers {
|
|
4
|
+
readonly snapshot: OperationPort["snapshot"];
|
|
5
|
+
readonly mutate: OperationPort["mutate"];
|
|
6
|
+
readonly cancel: OperationPort["cancel"];
|
|
7
|
+
readonly listen?: OperationPort["listen"];
|
|
8
|
+
readonly nextRequestId: OperationPort["nextRequestId"];
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function createDirectOperationPort(
|
|
12
|
+
handlers: DirectOperationHandlers,
|
|
13
|
+
): OperationPort {
|
|
14
|
+
return { ...handlers };
|
|
15
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// @generated by `effigy generate:operation`; do not edit.
|
|
2
|
+
// Allowed field names per protocol type, from the Rust structs.
|
|
3
|
+
// A `record()` given one of these rejects unknown and missing keys —
|
|
4
|
+
// contract 010's Boundary Validation Target.
|
|
5
|
+
|
|
6
|
+
export const OPERATION_FIELDS: Record<string, readonly string[]> = {
|
|
7
|
+
"OperationAuthorityProjection": ["authorityId", "authorityEpoch"],
|
|
8
|
+
"OperationPhaseProgressProjection": ["phaseId", "label", "completed", "total"],
|
|
9
|
+
"OperationProgressProjection": ["sequence", "overall", "phase"],
|
|
10
|
+
"OperationEntryProjection": ["authority", "operationId", "kindId", "scopeId", "label", "cancellationSupport", "retryOf", "sequence", "revision", "lastChangedCatalogueRevision", "state", "progress", "encodedMetadataWeight"],
|
|
11
|
+
"OperationCatalogueLimitsProjection": ["maximumActiveOperations", "maximumTerminalOperations", "maximumTerminalEncodedWeight"],
|
|
12
|
+
"OperationSnapshot": ["protocolVersion", "authority", "catalogueRevision", "closed", "limits", "terminalEvictionCount", "retainedTerminalEncodedWeight", "active", "recent"],
|
|
13
|
+
"OperationSnapshotQuery": ["protocolVersion", "requestId"],
|
|
14
|
+
"OperationSnapshotResponse": ["requestId", "snapshot"],
|
|
15
|
+
"OperationCancellationCommand": ["requestId", "protocolVersion", "authority", "operationId", "expectedOperationRevision"],
|
|
16
|
+
"OperationRemovalProjection": ["operationId", "sequence", "encodedWeight", "reason"],
|
|
17
|
+
"OperationRejection": ["code", "detail", "refreshRequired"],
|
|
18
|
+
"OperationCancellationReceiptProjection": ["operationId", "outcome", "previousState", "committedState", "previousOperationRevision", "committedOperationRevision", "previousCatalogueRevision", "committedCatalogueRevision", "evicted"],
|
|
19
|
+
"OperationChangedEvent": ["protocolVersion", "requestId", "authority", "previousCatalogueRevision", "committedCatalogueRevision", "operationId", "kind"],
|
|
20
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// @generated by `effigy generate:operation`; do not edit.
|
|
2
|
+
// Wording lives in Rust, on the enum that owns it. A label edited here is
|
|
3
|
+
// a label that disagrees with the native surface.
|
|
4
|
+
|
|
5
|
+
import type { OperationStateProjection } from "./protocol.ts";
|
|
6
|
+
|
|
7
|
+
export const OPERATION_STATE_LABELS: Record<OperationStateProjection, string> = {
|
|
8
|
+
queued: "Queued",
|
|
9
|
+
running: "Running",
|
|
10
|
+
cancelling: "Cancelling",
|
|
11
|
+
succeeded: "Succeeded",
|
|
12
|
+
failed: "Failed",
|
|
13
|
+
cancelled: "Cancelled",
|
|
14
|
+
interrupted: "Interrupted",
|
|
15
|
+
};
|