@printobserver/sdk 0.2.0 → 0.4.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/dist/client.d.ts +6 -3
- package/dist/client.js +3 -1
- package/dist/contract.d.ts +879 -66
- package/dist/contract.js +312 -6
- package/dist/surface.d.ts +8 -4
- package/dist/surface.js +5 -1
- package/package.json +2 -2
package/dist/contract.js
CHANGED
|
@@ -7,22 +7,24 @@
|
|
|
7
7
|
* generate-clients`, and commit what that writes.
|
|
8
8
|
*/
|
|
9
9
|
import { GeneratedSurface, reasonGiven } from "./surface.js";
|
|
10
|
-
|
|
11
|
-
* The version of the server contract these types were generated from, which
|
|
12
|
-
* is the version the type crate declares in the tree they came from.
|
|
13
|
-
*/
|
|
14
|
-
export const CONTRACT_VERSION = "0.2.0";
|
|
10
|
+
export const CONTRACT_VERSION = "0.4.0";
|
|
15
11
|
/**
|
|
16
12
|
* Every operation this client exposes a method for, which is every operation
|
|
17
13
|
* the server declares and no other.
|
|
18
14
|
*/
|
|
19
15
|
export const OPERATION_NAMES = [
|
|
16
|
+
"prints",
|
|
20
17
|
"status",
|
|
21
18
|
"context",
|
|
22
19
|
"image",
|
|
23
20
|
"history",
|
|
24
21
|
"manifest_get",
|
|
22
|
+
"look",
|
|
25
23
|
"manifest_set",
|
|
24
|
+
"spools",
|
|
25
|
+
"spool",
|
|
26
|
+
"printer_history",
|
|
27
|
+
"preflight",
|
|
26
28
|
"pause",
|
|
27
29
|
"resume",
|
|
28
30
|
"cancel",
|
|
@@ -33,7 +35,58 @@ export const OPERATION_NAMES = [
|
|
|
33
35
|
"set_bed_target_c",
|
|
34
36
|
"set_fan_percent",
|
|
35
37
|
"acknowledge_failure",
|
|
38
|
+
"register_spool",
|
|
39
|
+
"load_spool",
|
|
40
|
+
"unload_spool",
|
|
41
|
+
"adjust_spool",
|
|
42
|
+
"retire_spool",
|
|
43
|
+
];
|
|
44
|
+
/** Every kind the server declares a payload type for, in name order. */
|
|
45
|
+
export const EVENT_KINDS = [
|
|
46
|
+
"action_executed",
|
|
47
|
+
"action_rejected",
|
|
48
|
+
"action_requested",
|
|
49
|
+
"agent_assessment",
|
|
50
|
+
"camera_look",
|
|
51
|
+
"charge_pended",
|
|
52
|
+
"filament_change_signalled",
|
|
53
|
+
"filament_consumed",
|
|
54
|
+
"file_tally_rebaselined",
|
|
55
|
+
"intervention_expired",
|
|
56
|
+
"malformed_external_event",
|
|
57
|
+
"obico_failure_alert",
|
|
58
|
+
"obico_printer_notification",
|
|
59
|
+
"operator_acknowledgement",
|
|
60
|
+
"periodic_observation",
|
|
61
|
+
"port_failure",
|
|
62
|
+
"preflight_checked",
|
|
63
|
+
"print_ended",
|
|
64
|
+
"print_started",
|
|
65
|
+
"print_untracked",
|
|
66
|
+
"spool_adjusted",
|
|
67
|
+
"spool_command_rejected",
|
|
68
|
+
"spool_loaded",
|
|
69
|
+
"spool_registered",
|
|
70
|
+
"spool_retired",
|
|
71
|
+
"spool_unloaded",
|
|
72
|
+
"spool_unverified",
|
|
73
|
+
"startup_reconciliation",
|
|
74
|
+
"supervision_session_closed",
|
|
75
|
+
"supervision_session_opened",
|
|
76
|
+
"unaccounted_print",
|
|
36
77
|
];
|
|
78
|
+
/**
|
|
79
|
+
* The payload of one event as the type its kind declares, or `undefined` for
|
|
80
|
+
* an event of any other kind — one this client knows or one it does not. No
|
|
81
|
+
* validation beyond the kind's name: the payload is the document the server
|
|
82
|
+
* sent, handed on as the type the table says it is.
|
|
83
|
+
*/
|
|
84
|
+
export function payloadOf(event, kind) {
|
|
85
|
+
if (event.kind !== kind) {
|
|
86
|
+
return undefined;
|
|
87
|
+
}
|
|
88
|
+
return event.payload;
|
|
89
|
+
}
|
|
37
90
|
/**
|
|
38
91
|
* One method per operation the server declares.
|
|
39
92
|
*
|
|
@@ -42,6 +95,21 @@ export const OPERATION_NAMES = [
|
|
|
42
95
|
* vocabulary are hand-written, and this class is written against them.
|
|
43
96
|
*/
|
|
44
97
|
export class GeneratedClient extends GeneratedSurface {
|
|
98
|
+
/**
|
|
99
|
+
* Call `prints` on the configured supervisor.
|
|
100
|
+
*
|
|
101
|
+
* Rejects with `Unreachable` when nothing answered, with `Unreadable` when
|
|
102
|
+
* the answer could not be read, and with `Refused` when the supervisor
|
|
103
|
+
* said no.
|
|
104
|
+
*/
|
|
105
|
+
// llmlint: ignore[names_match_behavior] See suppressions.toml.
|
|
106
|
+
async prints() {
|
|
107
|
+
const target = `/v1/prints`;
|
|
108
|
+
const asked = [];
|
|
109
|
+
const sending = undefined;
|
|
110
|
+
// llmlint: ignore[boundary_inputs_validated] See suppressions.toml.
|
|
111
|
+
return await this.call("GET", target, asked, sending);
|
|
112
|
+
}
|
|
45
113
|
/**
|
|
46
114
|
* Call `status` on the configured supervisor.
|
|
47
115
|
*
|
|
@@ -53,6 +121,7 @@ export class GeneratedClient extends GeneratedSurface {
|
|
|
53
121
|
const target = `/v1/prints/${printId}/status`;
|
|
54
122
|
const asked = [];
|
|
55
123
|
const sending = undefined;
|
|
124
|
+
// llmlint: ignore[boundary_inputs_validated] See suppressions.toml.
|
|
56
125
|
return await this.call("GET", target, asked, sending);
|
|
57
126
|
}
|
|
58
127
|
/**
|
|
@@ -66,6 +135,7 @@ export class GeneratedClient extends GeneratedSurface {
|
|
|
66
135
|
const target = `/v1/prints/${printId}/context`;
|
|
67
136
|
const asked = [];
|
|
68
137
|
const sending = undefined;
|
|
138
|
+
// llmlint: ignore[boundary_inputs_validated] See suppressions.toml.
|
|
69
139
|
return await this.call("GET", target, asked, sending);
|
|
70
140
|
}
|
|
71
141
|
/**
|
|
@@ -79,6 +149,7 @@ export class GeneratedClient extends GeneratedSurface {
|
|
|
79
149
|
const target = `/v1/images/${imageId}`;
|
|
80
150
|
const asked = [];
|
|
81
151
|
const sending = undefined;
|
|
152
|
+
// llmlint: ignore[boundary_inputs_validated] See suppressions.toml.
|
|
82
153
|
return await this.call("GET", target, asked, sending);
|
|
83
154
|
}
|
|
84
155
|
/**
|
|
@@ -95,6 +166,7 @@ export class GeneratedClient extends GeneratedSurface {
|
|
|
95
166
|
asked.push(["limit", String(limit)]);
|
|
96
167
|
}
|
|
97
168
|
const sending = undefined;
|
|
169
|
+
// llmlint: ignore[boundary_inputs_validated] See suppressions.toml.
|
|
98
170
|
return await this.call("GET", target, asked, sending);
|
|
99
171
|
}
|
|
100
172
|
/**
|
|
@@ -108,6 +180,24 @@ export class GeneratedClient extends GeneratedSurface {
|
|
|
108
180
|
const target = `/v1/prints/${printId}/manifest`;
|
|
109
181
|
const asked = [];
|
|
110
182
|
const sending = undefined;
|
|
183
|
+
// llmlint: ignore[boundary_inputs_validated] See suppressions.toml.
|
|
184
|
+
return await this.call("GET", target, asked, sending);
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Call `look` on the configured supervisor.
|
|
188
|
+
*
|
|
189
|
+
* Rejects with `Unreachable` when nothing answered, with `Unreadable` when
|
|
190
|
+
* the answer could not be read, and with `Refused` when the supervisor
|
|
191
|
+
* said no.
|
|
192
|
+
*/
|
|
193
|
+
async look(printId, waitS) {
|
|
194
|
+
const target = `/v1/prints/${printId}/look`;
|
|
195
|
+
const asked = [];
|
|
196
|
+
if (waitS !== undefined) {
|
|
197
|
+
asked.push(["wait_s", String(waitS)]);
|
|
198
|
+
}
|
|
199
|
+
const sending = undefined;
|
|
200
|
+
// llmlint: ignore[boundary_inputs_validated] See suppressions.toml.
|
|
111
201
|
return await this.call("GET", target, asked, sending);
|
|
112
202
|
}
|
|
113
203
|
/**
|
|
@@ -126,8 +216,91 @@ export class GeneratedClient extends GeneratedSurface {
|
|
|
126
216
|
const sending = {};
|
|
127
217
|
sending.reason = reason;
|
|
128
218
|
sending.manifest = manifest;
|
|
219
|
+
// llmlint: ignore[boundary_inputs_validated] See suppressions.toml.
|
|
129
220
|
return await this.call("PUT", target, asked, sending);
|
|
130
221
|
}
|
|
222
|
+
/**
|
|
223
|
+
* Call `spools` on the configured supervisor.
|
|
224
|
+
*
|
|
225
|
+
* Rejects with `Unreachable` when nothing answered, with `Unreadable` when
|
|
226
|
+
* the answer could not be read, and with `Refused` when the supervisor
|
|
227
|
+
* said no.
|
|
228
|
+
*/
|
|
229
|
+
async spools(includeRetired) {
|
|
230
|
+
const target = `/v1/spools`;
|
|
231
|
+
const asked = [];
|
|
232
|
+
if (includeRetired !== undefined) {
|
|
233
|
+
asked.push(["include_retired", String(includeRetired)]);
|
|
234
|
+
}
|
|
235
|
+
const sending = undefined;
|
|
236
|
+
// llmlint: ignore[boundary_inputs_validated] See suppressions.toml.
|
|
237
|
+
return await this.call("GET", target, asked, sending);
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Call `spool` on the configured supervisor.
|
|
241
|
+
*
|
|
242
|
+
* Rejects with `Unreachable` when nothing answered, with `Unreadable` when
|
|
243
|
+
* the answer could not be read, and with `Refused` when the supervisor
|
|
244
|
+
* said no.
|
|
245
|
+
*/
|
|
246
|
+
async spool(spoolId) {
|
|
247
|
+
const target = `/v1/spools/${spoolId}`;
|
|
248
|
+
const asked = [];
|
|
249
|
+
const sending = undefined;
|
|
250
|
+
// llmlint: ignore[boundary_inputs_validated] See suppressions.toml.
|
|
251
|
+
return await this.call("GET", target, asked, sending);
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Call `printer_history` on the configured supervisor.
|
|
255
|
+
*
|
|
256
|
+
* Rejects with `Unreachable` when nothing answered, with `Unreadable` when
|
|
257
|
+
* the answer could not be read, and with `Refused` when the supervisor
|
|
258
|
+
* said no.
|
|
259
|
+
*/
|
|
260
|
+
async printerHistory(kinds, since, until, spoolId, before, limit) {
|
|
261
|
+
const target = `/v1/history`;
|
|
262
|
+
const asked = [];
|
|
263
|
+
if (kinds !== undefined) {
|
|
264
|
+
for (const value of kinds) {
|
|
265
|
+
asked.push(["kinds", String(value)]);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
if (since !== undefined) {
|
|
269
|
+
asked.push(["since", String(since)]);
|
|
270
|
+
}
|
|
271
|
+
if (until !== undefined) {
|
|
272
|
+
asked.push(["until", String(until)]);
|
|
273
|
+
}
|
|
274
|
+
if (spoolId !== undefined) {
|
|
275
|
+
asked.push(["spool_id", String(spoolId)]);
|
|
276
|
+
}
|
|
277
|
+
if (before !== undefined) {
|
|
278
|
+
asked.push(["before", String(before)]);
|
|
279
|
+
}
|
|
280
|
+
if (limit !== undefined) {
|
|
281
|
+
asked.push(["limit", String(limit)]);
|
|
282
|
+
}
|
|
283
|
+
const sending = undefined;
|
|
284
|
+
// llmlint: ignore[boundary_inputs_validated] See suppressions.toml.
|
|
285
|
+
return await this.call("GET", target, asked, sending);
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Call `preflight` on the configured supervisor.
|
|
289
|
+
*
|
|
290
|
+
* Rejects with `Unreachable` when nothing answered, with `Unreadable` when
|
|
291
|
+
* the answer could not be read, and with `Refused` when the supervisor
|
|
292
|
+
* said no.
|
|
293
|
+
*/
|
|
294
|
+
async preflight(fileName) {
|
|
295
|
+
const target = `/v1/preflight`;
|
|
296
|
+
const asked = [];
|
|
297
|
+
if (fileName !== undefined) {
|
|
298
|
+
asked.push(["file_name", String(fileName)]);
|
|
299
|
+
}
|
|
300
|
+
const sending = undefined;
|
|
301
|
+
// llmlint: ignore[boundary_inputs_validated] See suppressions.toml.
|
|
302
|
+
return await this.call("GET", target, asked, sending);
|
|
303
|
+
}
|
|
131
304
|
/**
|
|
132
305
|
* Call `pause` on the configured supervisor.
|
|
133
306
|
*
|
|
@@ -144,6 +317,7 @@ export class GeneratedClient extends GeneratedSurface {
|
|
|
144
317
|
const sending = {};
|
|
145
318
|
sending.actor = this.actor;
|
|
146
319
|
sending.reason = reason;
|
|
320
|
+
// llmlint: ignore[boundary_inputs_validated] See suppressions.toml.
|
|
147
321
|
return await this.call("POST", target, asked, sending);
|
|
148
322
|
}
|
|
149
323
|
/**
|
|
@@ -162,6 +336,7 @@ export class GeneratedClient extends GeneratedSurface {
|
|
|
162
336
|
const sending = {};
|
|
163
337
|
sending.actor = this.actor;
|
|
164
338
|
sending.reason = reason;
|
|
339
|
+
// llmlint: ignore[boundary_inputs_validated] See suppressions.toml.
|
|
165
340
|
return await this.call("POST", target, asked, sending);
|
|
166
341
|
}
|
|
167
342
|
/**
|
|
@@ -180,6 +355,7 @@ export class GeneratedClient extends GeneratedSurface {
|
|
|
180
355
|
const sending = {};
|
|
181
356
|
sending.actor = this.actor;
|
|
182
357
|
sending.reason = reason;
|
|
358
|
+
// llmlint: ignore[boundary_inputs_validated] See suppressions.toml.
|
|
183
359
|
return await this.call("POST", target, asked, sending);
|
|
184
360
|
}
|
|
185
361
|
/**
|
|
@@ -191,7 +367,7 @@ export class GeneratedClient extends GeneratedSurface {
|
|
|
191
367
|
* is made, and the policy's own refusal arrives as `Rejected`, carrying
|
|
192
368
|
* the reason, the value asked for and the range allowed.
|
|
193
369
|
*/
|
|
194
|
-
async startPrint(printId, fileName, manifest, reason) {
|
|
370
|
+
async startPrint(printId, fileName, manifest, reason, overrideFilamentCheck) {
|
|
195
371
|
reasonGiven(reason);
|
|
196
372
|
const target = `/v1/prints/${printId}/actions/start_print`;
|
|
197
373
|
const asked = [];
|
|
@@ -199,7 +375,11 @@ export class GeneratedClient extends GeneratedSurface {
|
|
|
199
375
|
sending.actor = this.actor;
|
|
200
376
|
sending.file_name = fileName;
|
|
201
377
|
sending.manifest = manifest;
|
|
378
|
+
if (overrideFilamentCheck !== undefined) {
|
|
379
|
+
sending.override_filament_check = overrideFilamentCheck;
|
|
380
|
+
}
|
|
202
381
|
sending.reason = reason;
|
|
382
|
+
// llmlint: ignore[boundary_inputs_validated] See suppressions.toml.
|
|
203
383
|
return await this.call("POST", target, asked, sending);
|
|
204
384
|
}
|
|
205
385
|
/**
|
|
@@ -222,6 +402,7 @@ export class GeneratedClient extends GeneratedSurface {
|
|
|
222
402
|
}
|
|
223
403
|
sending.factor = factor;
|
|
224
404
|
sending.reason = reason;
|
|
405
|
+
// llmlint: ignore[boundary_inputs_validated] See suppressions.toml.
|
|
225
406
|
return await this.call("POST", target, asked, sending);
|
|
226
407
|
}
|
|
227
408
|
/**
|
|
@@ -244,6 +425,7 @@ export class GeneratedClient extends GeneratedSurface {
|
|
|
244
425
|
}
|
|
245
426
|
sending.factor = factor;
|
|
246
427
|
sending.reason = reason;
|
|
428
|
+
// llmlint: ignore[boundary_inputs_validated] See suppressions.toml.
|
|
247
429
|
return await this.call("POST", target, asked, sending);
|
|
248
430
|
}
|
|
249
431
|
/**
|
|
@@ -267,6 +449,7 @@ export class GeneratedClient extends GeneratedSurface {
|
|
|
267
449
|
sending.reason = reason;
|
|
268
450
|
sending.target_c = targetC;
|
|
269
451
|
sending.tool = tool;
|
|
452
|
+
// llmlint: ignore[boundary_inputs_validated] See suppressions.toml.
|
|
270
453
|
return await this.call("POST", target, asked, sending);
|
|
271
454
|
}
|
|
272
455
|
/**
|
|
@@ -289,6 +472,7 @@ export class GeneratedClient extends GeneratedSurface {
|
|
|
289
472
|
}
|
|
290
473
|
sending.reason = reason;
|
|
291
474
|
sending.target_c = targetC;
|
|
475
|
+
// llmlint: ignore[boundary_inputs_validated] See suppressions.toml.
|
|
292
476
|
return await this.call("POST", target, asked, sending);
|
|
293
477
|
}
|
|
294
478
|
/**
|
|
@@ -311,6 +495,7 @@ export class GeneratedClient extends GeneratedSurface {
|
|
|
311
495
|
}
|
|
312
496
|
sending.percent = percent;
|
|
313
497
|
sending.reason = reason;
|
|
498
|
+
// llmlint: ignore[boundary_inputs_validated] See suppressions.toml.
|
|
314
499
|
return await this.call("POST", target, asked, sending);
|
|
315
500
|
}
|
|
316
501
|
/**
|
|
@@ -331,6 +516,127 @@ export class GeneratedClient extends GeneratedSurface {
|
|
|
331
516
|
sending.disposition = disposition;
|
|
332
517
|
sending.event_id = eventId;
|
|
333
518
|
sending.reason = reason;
|
|
519
|
+
// llmlint: ignore[boundary_inputs_validated] See suppressions.toml.
|
|
520
|
+
return await this.call("POST", target, asked, sending);
|
|
521
|
+
}
|
|
522
|
+
/**
|
|
523
|
+
* Call `register_spool` on the configured supervisor.
|
|
524
|
+
*
|
|
525
|
+
* Rejects with `Unreachable` when nothing answered, with `Unreadable` when
|
|
526
|
+
* the answer could not be read, and with `Refused` when the supervisor
|
|
527
|
+
* said no. A call whose reason is empty is refused here, before a request
|
|
528
|
+
* is made, and the policy's own refusal arrives as `Rejected`, carrying
|
|
529
|
+
* the reason, the value asked for and the range allowed.
|
|
530
|
+
*/
|
|
531
|
+
async registerSpool(initialG, material, name, reason, color, densityGCm3, diameterMm, remainingG, tareG) {
|
|
532
|
+
reasonGiven(reason);
|
|
533
|
+
const target = `/v1/spools/actions/register_spool`;
|
|
534
|
+
const asked = [];
|
|
535
|
+
const sending = {};
|
|
536
|
+
sending.actor = this.actor;
|
|
537
|
+
if (color !== undefined) {
|
|
538
|
+
sending.color = color;
|
|
539
|
+
}
|
|
540
|
+
if (densityGCm3 !== undefined) {
|
|
541
|
+
sending.density_g_cm3 = densityGCm3;
|
|
542
|
+
}
|
|
543
|
+
if (diameterMm !== undefined) {
|
|
544
|
+
sending.diameter_mm = diameterMm;
|
|
545
|
+
}
|
|
546
|
+
sending.initial_g = initialG;
|
|
547
|
+
sending.material = material;
|
|
548
|
+
sending.name = name;
|
|
549
|
+
sending.reason = reason;
|
|
550
|
+
if (remainingG !== undefined) {
|
|
551
|
+
sending.remaining_g = remainingG;
|
|
552
|
+
}
|
|
553
|
+
if (tareG !== undefined) {
|
|
554
|
+
sending.tare_g = tareG;
|
|
555
|
+
}
|
|
556
|
+
// llmlint: ignore[boundary_inputs_validated] See suppressions.toml.
|
|
557
|
+
return await this.call("POST", target, asked, sending);
|
|
558
|
+
}
|
|
559
|
+
/**
|
|
560
|
+
* Call `load_spool` on the configured supervisor.
|
|
561
|
+
*
|
|
562
|
+
* Rejects with `Unreachable` when nothing answered, with `Unreadable` when
|
|
563
|
+
* the answer could not be read, and with `Refused` when the supervisor
|
|
564
|
+
* said no. A call whose reason is empty is refused here, before a request
|
|
565
|
+
* is made, and the policy's own refusal arrives as `Rejected`, carrying
|
|
566
|
+
* the reason, the value asked for and the range allowed.
|
|
567
|
+
*/
|
|
568
|
+
async loadSpool(spoolId, reason, tool) {
|
|
569
|
+
reasonGiven(reason);
|
|
570
|
+
const target = `/v1/spools/${spoolId}/actions/load_spool`;
|
|
571
|
+
const asked = [];
|
|
572
|
+
const sending = {};
|
|
573
|
+
sending.actor = this.actor;
|
|
574
|
+
sending.reason = reason;
|
|
575
|
+
sending.tool = tool;
|
|
576
|
+
// llmlint: ignore[boundary_inputs_validated] See suppressions.toml.
|
|
577
|
+
return await this.call("POST", target, asked, sending);
|
|
578
|
+
}
|
|
579
|
+
/**
|
|
580
|
+
* Call `unload_spool` on the configured supervisor.
|
|
581
|
+
*
|
|
582
|
+
* Rejects with `Unreachable` when nothing answered, with `Unreadable` when
|
|
583
|
+
* the answer could not be read, and with `Refused` when the supervisor
|
|
584
|
+
* said no. A call whose reason is empty is refused here, before a request
|
|
585
|
+
* is made, and the policy's own refusal arrives as `Rejected`, carrying
|
|
586
|
+
* the reason, the value asked for and the range allowed.
|
|
587
|
+
*/
|
|
588
|
+
async unloadSpool(spoolId, reason) {
|
|
589
|
+
reasonGiven(reason);
|
|
590
|
+
const target = `/v1/spools/${spoolId}/actions/unload_spool`;
|
|
591
|
+
const asked = [];
|
|
592
|
+
const sending = {};
|
|
593
|
+
sending.actor = this.actor;
|
|
594
|
+
sending.reason = reason;
|
|
595
|
+
// llmlint: ignore[boundary_inputs_validated] See suppressions.toml.
|
|
596
|
+
return await this.call("POST", target, asked, sending);
|
|
597
|
+
}
|
|
598
|
+
/**
|
|
599
|
+
* Call `adjust_spool` on the configured supervisor.
|
|
600
|
+
*
|
|
601
|
+
* Rejects with `Unreachable` when nothing answered, with `Unreadable` when
|
|
602
|
+
* the answer could not be read, and with `Refused` when the supervisor
|
|
603
|
+
* said no. A call whose reason is empty is refused here, before a request
|
|
604
|
+
* is made, and the policy's own refusal arrives as `Rejected`, carrying
|
|
605
|
+
* the reason, the value asked for and the range allowed.
|
|
606
|
+
*/
|
|
607
|
+
async adjustSpool(spoolId, reason, grossG, remainingG) {
|
|
608
|
+
reasonGiven(reason);
|
|
609
|
+
const target = `/v1/spools/${spoolId}/actions/adjust_spool`;
|
|
610
|
+
const asked = [];
|
|
611
|
+
const sending = {};
|
|
612
|
+
sending.actor = this.actor;
|
|
613
|
+
if (grossG !== undefined) {
|
|
614
|
+
sending.gross_g = grossG;
|
|
615
|
+
}
|
|
616
|
+
sending.reason = reason;
|
|
617
|
+
if (remainingG !== undefined) {
|
|
618
|
+
sending.remaining_g = remainingG;
|
|
619
|
+
}
|
|
620
|
+
// llmlint: ignore[boundary_inputs_validated] See suppressions.toml.
|
|
621
|
+
return await this.call("POST", target, asked, sending);
|
|
622
|
+
}
|
|
623
|
+
/**
|
|
624
|
+
* Call `retire_spool` on the configured supervisor.
|
|
625
|
+
*
|
|
626
|
+
* Rejects with `Unreachable` when nothing answered, with `Unreadable` when
|
|
627
|
+
* the answer could not be read, and with `Refused` when the supervisor
|
|
628
|
+
* said no. A call whose reason is empty is refused here, before a request
|
|
629
|
+
* is made, and the policy's own refusal arrives as `Rejected`, carrying
|
|
630
|
+
* the reason, the value asked for and the range allowed.
|
|
631
|
+
*/
|
|
632
|
+
async retireSpool(spoolId, reason) {
|
|
633
|
+
reasonGiven(reason);
|
|
634
|
+
const target = `/v1/spools/${spoolId}/actions/retire_spool`;
|
|
635
|
+
const asked = [];
|
|
636
|
+
const sending = {};
|
|
637
|
+
sending.actor = this.actor;
|
|
638
|
+
sending.reason = reason;
|
|
639
|
+
// llmlint: ignore[boundary_inputs_validated] See suppressions.toml.
|
|
334
640
|
return await this.call("POST", target, asked, sending);
|
|
335
641
|
}
|
|
336
642
|
}
|
package/dist/surface.d.ts
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* are that module's, imported as types alone, so that the two files can name
|
|
11
11
|
* each other's shapes without either being unloadable.
|
|
12
12
|
*/
|
|
13
|
-
import type { ActionAnswer, Actor, Range, RejectionReason } from "./contract.ts";
|
|
13
|
+
import type { ActionAnswer, Actor, Range, RejectionReason, SpoolCommandAnswer } from "./contract.ts";
|
|
14
14
|
/** Why a call did not answer what it asked for. */
|
|
15
15
|
export declare class ClientError extends Error {
|
|
16
16
|
constructor(said: string);
|
|
@@ -72,9 +72,13 @@ export declare class Rejected extends ClientError {
|
|
|
72
72
|
readonly requested: number | undefined;
|
|
73
73
|
/** The range that is allowed, where the policy ruled on a value. */
|
|
74
74
|
readonly allowed: Range | undefined;
|
|
75
|
-
/**
|
|
76
|
-
|
|
77
|
-
|
|
75
|
+
/**
|
|
76
|
+
* The whole answer: an action's, whose record carries the request and the
|
|
77
|
+
* decision, or a spool command's, carrying the decision and the events its
|
|
78
|
+
* refusal wrote.
|
|
79
|
+
*/
|
|
80
|
+
readonly answer: ActionAnswer | SpoolCommandAnswer;
|
|
81
|
+
constructor(reason: RejectionReason, requested: number | undefined, allowed: Range | undefined, answer: ActionAnswer | SpoolCommandAnswer);
|
|
78
82
|
}
|
|
79
83
|
/**
|
|
80
84
|
* Refuse a mutating call that carries no reason, before it is made.
|
package/dist/surface.js
CHANGED
|
@@ -99,7 +99,11 @@ export class Rejected extends ClientError {
|
|
|
99
99
|
requested;
|
|
100
100
|
/** The range that is allowed, where the policy ruled on a value. */
|
|
101
101
|
allowed;
|
|
102
|
-
/**
|
|
102
|
+
/**
|
|
103
|
+
* The whole answer: an action's, whose record carries the request and the
|
|
104
|
+
* decision, or a spool command's, carrying the decision and the events its
|
|
105
|
+
* refusal wrote.
|
|
106
|
+
*/
|
|
103
107
|
answer;
|
|
104
108
|
constructor(reason, requested, allowed, answer) {
|
|
105
109
|
super(`the supervisor's policy refused this action: ${JSON.stringify(reason)}` +
|
package/package.json
CHANGED
|
@@ -12,12 +12,12 @@
|
|
|
12
12
|
"license": "MIT",
|
|
13
13
|
"main": "dist/index.js",
|
|
14
14
|
"name": "@printobserver/sdk",
|
|
15
|
-
"printobserverContractVersion": "0.
|
|
15
|
+
"printobserverContractVersion": "0.4.0",
|
|
16
16
|
"repository": {
|
|
17
17
|
"type": "git",
|
|
18
18
|
"url": "https://github.com/nickderobertis/printobserver"
|
|
19
19
|
},
|
|
20
20
|
"type": "module",
|
|
21
21
|
"types": "dist/index.d.ts",
|
|
22
|
-
"version": "0.
|
|
22
|
+
"version": "0.4.0"
|
|
23
23
|
}
|