@printobserver/sdk 0.6.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.
@@ -177,6 +177,30 @@ export interface ChargePendedPayload {
177
177
  /** What was held. */
178
178
  pending: PendingCharge;
179
179
  }
180
+ /**
181
+ * What a charge took from a spool, and the whole calculation behind it.
182
+ *
183
+ * Present or absent as one: a debit names its spool exactly when it carries
184
+ * the grams, the figures they were worked out with, and the spool's figure
185
+ * either side of them.
186
+ */
187
+ export interface ChargedFilament {
188
+ /**
189
+ * The density the grams were worked out with, in grams per cubic
190
+ * centimetre.
191
+ */
192
+ density_g_cm3: number;
193
+ /** The diameter the grams were worked out with, in millimetres. */
194
+ diameter_mm: number;
195
+ /** What the length weighs, in grams; what is subtracted from the spool. */
196
+ grams: number;
197
+ /** The spool's figure after it, in grams. */
198
+ remaining_after_g: number;
199
+ /** The spool's figure before the charge, in grams. */
200
+ remaining_before_g: number;
201
+ /** The spool charged. */
202
+ spool_id: SpoolId;
203
+ }
180
204
  /** One mark a spool command cleared, and the spool it was cleared from. */
181
205
  export interface ClearedMark {
182
206
  /** The reason that no longer stands. */
@@ -294,13 +318,11 @@ export type ExecutionOutcome = "succeeded" | {
294
318
  };
295
319
  /** A filament change was signalled during a print. */
296
320
  export interface FilamentChangeSignalledPayload {
297
- /** The position the spool was charged up to, when one was known. */
298
- position?: FilePosition | null;
299
321
  /**
300
- * Whether that position was read when the signal was handled, rather than
301
- * being the last one recorded; never with no position at all.
322
+ * The position the spool was charged up to, and how fresh it is, when one
323
+ * was known; absent, there is no position and so no claim about one.
302
324
  */
303
- position_read_at_signal: boolean;
325
+ position?: SignalPosition | null;
304
326
  /** The kind of the alert that carried the signal. */
305
327
  source_kind: EventKind;
306
328
  /** The spool that was on it, when one was tracked. */
@@ -318,17 +340,11 @@ export interface FilamentConsumedPayload {
318
340
  /** The durable identity of this debit. */
319
341
  charge_key: ChargeKey;
320
342
  /**
321
- * The density the grams were worked out with, in grams per cubic
322
- * centimetre.
323
- */
324
- density_g_cm3?: number | null;
325
- /** The diameter the grams were worked out with, in millimetres. */
326
- diameter_mm?: number | null;
327
- /**
328
- * What that length weighs, in grams, when a spool gave its diameter and
329
- * density.
343
+ * The spool charged and the whole calculation of what it was charged;
344
+ * absent when nothing was tracked on the tool, and the filament was
345
+ * recorded uncharged.
330
346
  */
331
- grams?: number | null;
347
+ charged?: ChargedFilament | null;
332
348
  /** How much was fed, in millimetres. */
333
349
  length_mm: number;
334
350
  /** How the length was worked out. */
@@ -337,16 +353,7 @@ export interface FilamentConsumedPayload {
337
353
  note?: string | null;
338
354
  /** How far into the file the charge runs, when that was read. */
339
355
  position?: FilePosition | null;
340
- /** The spool's figure after it, in grams. */
341
- remaining_after_g?: number | null;
342
- /** The spool's figure before the charge, in grams. */
343
- remaining_before_g?: number | null;
344
- /**
345
- * The spool charged; absent when nothing was tracked on the tool, and the
346
- * filament was recorded uncharged.
347
- */
348
- spool_id?: SpoolId | null;
349
- /** The tool that fed it. */
356
+ /** The tool that fed it, as its key names it. */
350
357
  tool: number;
351
358
  }
352
359
  /**
@@ -718,8 +725,11 @@ export interface PendingCharge {
718
725
  * one.
719
726
  */
720
727
  analysed_length_mm?: number | null;
721
- /** The key of the print segment the filament was fed in. */
722
- charge_key: ChargeKey;
728
+ /**
729
+ * The print segment the filament was fed in, which names the print and
730
+ * the tool that fed it.
731
+ */
732
+ charge_key: PrintSegmentKey;
723
733
  /** How much was fed, in millimetres. */
724
734
  length_mm: number;
725
735
  /** How that length was worked out. */
@@ -730,10 +740,6 @@ export interface PendingCharge {
730
740
  pended_at: Timestamp;
731
741
  /** How far into the file the segment ran, when that was read. */
732
742
  position?: FilePosition | null;
733
- /** The print it was fed in. */
734
- print_id: PrintId;
735
- /** The tool that fed it. */
736
- tool: number;
737
743
  }
738
744
  /** One pending charge a spool command took. */
739
745
  export interface PendingTaken {
@@ -806,6 +812,8 @@ export interface PortFailurePayload {
806
812
  * a second version of one fact.
807
813
  */
808
814
  export type PortFailureSite = "printer_snapshot" | "printer_job" | "image_write" | "supervision_turn" | "camera_look" | "detector_acknowledgement";
815
+ /** How fresh the position a filament change charged up to is. */
816
+ export type PositionFreshness = "read_at_signal" | "last_recorded";
809
817
  /** What a filament check found for one print. */
810
818
  export interface Preflight {
811
819
  /** When the check was made. */
@@ -832,31 +840,88 @@ export interface PreflightCheckedPayload {
832
840
  /** What the check found. */
833
841
  preflight: Preflight;
834
842
  }
835
- /** What a filament check found for one tool. */
836
- export interface PreflightTool {
837
- /** The margin asked for beyond that, in grams. */
838
- buffer_g?: number | null;
843
+ /**
844
+ * What a print needs from one spool, in grams: both figures a comparison
845
+ * with what the spool holds uses, or neither.
846
+ */
847
+ export interface PreflightNeed {
848
+ /** The margin asked for beyond that. */
849
+ buffer_g: number;
839
850
  /**
840
- * The loaded spool's marks at the check, oldest first, whatever the
841
- * verdict, so a spool both short and unverified says both.
851
+ * What the print needs from the spool, by the file's analysis and the
852
+ * spool's own diameter and density.
842
853
  */
854
+ required_g: number;
855
+ }
856
+ /** What a check that refuses a start found for one tool. */
857
+ export type PreflightObjection = {
858
+ verdict: "insufficient";
843
859
  marks?: Array<UnverifiedMark>;
844
- /** What the spool holds, in grams. */
845
- remaining_g?: number | null;
846
- /** What the print needs from it, in grams, when the file's analysis says. */
847
- required_g?: number | null;
848
- /** The spool loaded on it, when one is. */
849
- spool_id?: SpoolId | null;
850
- /**
851
- * That spool's name, beside its identifier, so a reader need not look it
852
- * up.
853
- */
854
- spool_name?: string | null;
860
+ need: PreflightNeed;
861
+ remaining_g: number;
862
+ spool: PreflightSpool;
863
+ } | {
864
+ verdict: "unverified_spool";
865
+ marks: Array<UnverifiedMark>;
866
+ need?: PreflightNeed | null;
867
+ remaining_g: number;
868
+ spool: PreflightSpool;
869
+ } | {
870
+ verdict: "no_analysis";
871
+ remaining_g: number;
872
+ spool: PreflightSpool;
873
+ };
874
+ /**
875
+ * The spool a check judged, named beside its identifier so a reader need
876
+ * not look it up.
877
+ */
878
+ export interface PreflightSpool {
879
+ /** The spool's identifier. */
880
+ id: SpoolId;
881
+ /** The spool's name. */
882
+ name: string;
883
+ }
884
+ /** What a filament check found for one tool. */
885
+ export interface PreflightTool {
886
+ /** What the check found for it, with the evidence that finding rests on. */
887
+ result: PreflightToolResult;
855
888
  /** The tool, in the printer's own numbering. */
856
889
  tool: number;
857
- /** What the check found for this tool. */
858
- verdict: PreflightVerdict;
859
890
  }
891
+ /**
892
+ * What a filament check found for one tool, tagged by its verdict, each
893
+ * verdict carrying exactly the evidence it rests on.
894
+ */
895
+ export type PreflightToolResult = {
896
+ verdict: "passed";
897
+ need: PreflightNeed;
898
+ remaining_g: number;
899
+ spool: PreflightSpool;
900
+ } | {
901
+ verdict: "unchecked";
902
+ } | {
903
+ verdict: "insufficient";
904
+ marks?: Array<UnverifiedMark>;
905
+ need: PreflightNeed;
906
+ remaining_g: number;
907
+ spool: PreflightSpool;
908
+ } | {
909
+ verdict: "unverified_spool";
910
+ marks: Array<UnverifiedMark>;
911
+ need?: PreflightNeed | null;
912
+ remaining_g: number;
913
+ spool: PreflightSpool;
914
+ } | {
915
+ verdict: "no_analysis";
916
+ remaining_g: number;
917
+ spool: PreflightSpool;
918
+ } | {
919
+ verdict: "overridden";
920
+ objection: PreflightObjection;
921
+ } | {
922
+ verdict: "warned";
923
+ objection: PreflightObjection;
924
+ };
860
925
  /** What a filament check found, for one tool or for a whole print. */
861
926
  export type PreflightVerdict = "passed" | "unchecked" | "insufficient" | "unverified_spool" | "no_analysis" | "overridden" | "warned";
862
927
  /** The whole vocabulary an actor may ask for, and there is no other. */
@@ -1013,6 +1078,19 @@ export interface PrintRecord {
1013
1078
  /** The state the print is in. */
1014
1079
  state: PrinterState;
1015
1080
  }
1081
+ /**
1082
+ * One segment of a print this system watched, on one tool: the key of a
1083
+ * `ChargeKey::Print` debit, and the only key filament held pending can be
1084
+ * under.
1085
+ */
1086
+ export interface PrintSegmentKey {
1087
+ /** The print. */
1088
+ print_id: PrintId;
1089
+ /** Which segment, numbered as `ChargeKey::Print` numbers it. */
1090
+ segment: number;
1091
+ /** The tool, in the printer's own numbering. */
1092
+ tool: number;
1093
+ }
1016
1094
  /** A print started. */
1017
1095
  export interface PrintStartedPayload {
1018
1096
  /** The file being printed, when it is known. */
@@ -1146,7 +1224,8 @@ export type RejectionReason = {
1146
1224
  };
1147
1225
  } | {
1148
1226
  spool_refused: {
1149
- detail: string;
1227
+ cause: SpoolRefusalCause;
1228
+ message: string;
1150
1229
  };
1151
1230
  };
1152
1231
  /**
@@ -1159,6 +1238,16 @@ export interface Reported {
1159
1238
  /** One shape of the contracts, which say nothing more about it. */
1160
1239
  value: number;
1161
1240
  }
1241
+ /** The position a filament change charged up to, and how fresh it is. */
1242
+ export interface SignalPosition {
1243
+ /**
1244
+ * Whether it was read when the signal was handled, or is the last one
1245
+ * recorded before it.
1246
+ */
1247
+ freshness: PositionFreshness;
1248
+ /** The position. */
1249
+ position: FilePosition;
1250
+ }
1162
1251
  /** A spool's remaining figure was corrected. */
1163
1252
  export interface SpoolAdjustedPayload {
1164
1253
  /** Who corrected it. */
@@ -1254,8 +1343,25 @@ export interface SpoolCommandRejectedPayload {
1254
1343
  /** The whole decision, carrying which refusal it was. */
1255
1344
  decision: PolicyDecision;
1256
1345
  }
1346
+ /** One field of a spool command, as the command names it. */
1347
+ export type SpoolField = "name" | "material" | "diameter_mm" | "density_g_cm3" | "initial_g" | "remaining_g" | "tare_g" | "gross_g";
1257
1348
  /** A lowercase hyphenated version 7 UUID identifying one registered spool. */
1258
1349
  export type SpoolId = string;
1350
+ /**
1351
+ * Where a spool is in its life.
1352
+ *
1353
+ * One state rather than a loaded tool beside a retirement instant, because a
1354
+ * retired spool is on no tool: retiring a loaded spool takes it off.
1355
+ */
1356
+ export type SpoolLifecycle = {
1357
+ state: "shelved";
1358
+ } | {
1359
+ state: "loaded";
1360
+ tool: number;
1361
+ } | {
1362
+ state: "retired";
1363
+ at: Timestamp;
1364
+ };
1259
1365
  /** A spool was loaded onto a tool, or confirmed as never having left it. */
1260
1366
  export interface SpoolLoadedPayload {
1261
1367
  /** Who loaded it. */
@@ -1288,8 +1394,11 @@ export interface SpoolRecord {
1288
1394
  id: SpoolId;
1289
1395
  /** The net filament on the spool when it was full, in grams; above zero. */
1290
1396
  initial_g: number;
1291
- /** The tool the spool is loaded on, when it is loaded. */
1292
- loaded_on_tool?: number | null;
1397
+ /**
1398
+ * Where the spool is in its life: on the shelf, loaded on a tool, or
1399
+ * retired — and never both of the last two.
1400
+ */
1401
+ lifecycle: SpoolLifecycle;
1293
1402
  /** The material, as given and trimmed, such as `PLA`; never empty. */
1294
1403
  material: string;
1295
1404
  /** The operator's own label for the spool; never empty. */
@@ -1303,8 +1412,6 @@ export interface SpoolRecord {
1303
1412
  * charge is never refused or clamped, so this may go below zero.
1304
1413
  */
1305
1414
  remaining_g: number;
1306
- /** When the spool was retired, if it has been. */
1307
- retired_at?: Timestamp | null;
1308
1415
  /** The empty spool's own weight, in grams, when the operator gave it. */
1309
1416
  tare_g?: number | null;
1310
1417
  /** How far the remaining figure can be trusted. */
@@ -1312,6 +1419,45 @@ export interface SpoolRecord {
1312
1419
  /** When anything about the spool last changed. */
1313
1420
  updated_at: Timestamp;
1314
1421
  }
1422
+ /**
1423
+ * Why the spool ledger refused a command, each cause carrying what a client
1424
+ * needs to choose the next valid request.
1425
+ */
1426
+ export type SpoolRefusalCause = {
1427
+ cause: "unknown_spool";
1428
+ spool_id: SpoolId;
1429
+ } | {
1430
+ cause: "retired_spool";
1431
+ spool_id: SpoolId;
1432
+ } | {
1433
+ cause: "nothing_to_confirm";
1434
+ tool: number;
1435
+ } | {
1436
+ cause: "invalid_adjustment_figure";
1437
+ field: SpoolField;
1438
+ value: number;
1439
+ } | {
1440
+ cause: "tare_required";
1441
+ spool_id: SpoolId;
1442
+ } | {
1443
+ cause: "density_required";
1444
+ material: string;
1445
+ spool_id?: SpoolId | null;
1446
+ } | {
1447
+ cause: "missing_field";
1448
+ field: SpoolField;
1449
+ } | {
1450
+ cause: "conflicting_fields";
1451
+ fields: Array<SpoolField>;
1452
+ } | {
1453
+ cause: "unknown_tool";
1454
+ tool: number;
1455
+ } | {
1456
+ cause: "not_loaded";
1457
+ spool_id: SpoolId;
1458
+ } | {
1459
+ cause: "ledger_refused";
1460
+ };
1315
1461
  /** A spool was registered. */
1316
1462
  export interface SpoolRegisteredPayload {
1317
1463
  /** Who registered it. */
package/dist/contract.js CHANGED
@@ -7,7 +7,7 @@
7
7
  * generate-clients`, and commit what that writes.
8
8
  */
9
9
  import { GeneratedSurface, reasonGiven } from "./surface.js";
10
- export const CONTRACT_VERSION = "0.6.0";
10
+ export const CONTRACT_VERSION = "0.7.0";
11
11
  /**
12
12
  * Every operation this client exposes a method for, which is every operation
13
13
  * the server declares and no other.
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.6.0",
15
+ "printobserverContractVersion": "0.7.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.6.0"
22
+ "version": "0.7.0"
23
23
  }